-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathrom32.s
More file actions
38 lines (32 loc) · 955 Bytes
/
rom32.s
File metadata and controls
38 lines (32 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
.section .rom32, "ax"
.code32
.align 16
rom32_start:
# Now that we are in 32-bit mode, setup all the Data-Segments to be 32-bit.
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
movw %ax, %fs
movw %ax, %gs
# Needed for the REP instructions below
cld
copy_rom_to_ram:
# This is equivalent to: memcpy(data_start, rom_data_start, data_size)
movl $rom_data_start, %esi
movl $data_start, %edi
movl $data_size, %ecx
rep movsb (%esi), (%edi)
zero_bss_in_ram:
# This is equivalent to: memset(bss_start, 0, bss_size)
xorb %al, %al
movl $bss_start, %edi
movl $bss_size, %ecx
rep stosb %al, (%edi)
jump_to_ram:
# Zero out %ebx, as we don't have a PVH StartInfo struct.
xorl %ebx, %ebx
# Jumping all that way from ROM (~4 GiB) to RAM (~1 MiB) is too far for a
# 32-bit relative jump, so we use a 32-bit absolute jump.
movl $ram32_start, %eax
jmp *%eax