2022-06-27 11:48:03 +03:00
|
|
|
section .data
|
|
|
|
|
2022-06-28 09:47:40 +03:00
|
|
|
bits 32
|
|
|
|
|
2022-06-27 11:48:03 +03:00
|
|
|
global multiboot_reloc_stub
|
|
|
|
multiboot_reloc_stub:
|
|
|
|
jmp .code
|
|
|
|
|
|
|
|
times 4-($-multiboot_reloc_stub) db 0
|
|
|
|
|
|
|
|
; EBX = self
|
2022-06-29 11:27:04 +03:00
|
|
|
; ESI = magic value
|
|
|
|
; EDI = protocol info
|
|
|
|
; ECX = entry point
|
|
|
|
; EAX = ranges
|
|
|
|
; EDX = ranges count
|
2022-06-27 11:48:03 +03:00
|
|
|
|
|
|
|
.code:
|
2022-06-29 13:41:42 +03:00
|
|
|
mov esp, ebx
|
|
|
|
add esp, .mini_stack_top - multiboot_reloc_stub
|
2022-06-27 11:48:03 +03:00
|
|
|
|
2022-06-29 11:27:04 +03:00
|
|
|
push edi
|
|
|
|
push esi
|
|
|
|
push ecx
|
2022-06-27 11:48:03 +03:00
|
|
|
|
2022-06-29 11:27:04 +03:00
|
|
|
.ranges_loop:
|
|
|
|
test edx, edx ; Loop until we're done
|
|
|
|
jz .ranges_loop_out
|
2022-06-27 11:48:03 +03:00
|
|
|
|
2022-06-29 11:27:04 +03:00
|
|
|
mov esi, [eax] ; ESI = range.elsewhere
|
|
|
|
mov edi, [eax+8] ; EDI = range.target
|
|
|
|
mov ecx, [eax+16] ; ECX = range.length
|
|
|
|
rep movsb ; Copy range to target location
|
2022-06-27 11:48:03 +03:00
|
|
|
|
2022-06-29 11:27:04 +03:00
|
|
|
add eax, 24 ; Move to the next range
|
2022-06-27 11:48:03 +03:00
|
|
|
|
2022-06-29 11:27:04 +03:00
|
|
|
dec edx
|
|
|
|
jmp .ranges_loop
|
2022-06-27 11:48:03 +03:00
|
|
|
|
2022-06-29 11:27:04 +03:00
|
|
|
.ranges_loop_out:
|
2022-06-27 11:48:03 +03:00
|
|
|
; We're done relocating!
|
2022-06-29 11:27:04 +03:00
|
|
|
pop ecx
|
|
|
|
pop esi
|
|
|
|
pop edi
|
2022-06-27 11:48:03 +03:00
|
|
|
|
2022-06-29 11:27:04 +03:00
|
|
|
push ecx
|
2022-06-27 11:48:03 +03:00
|
|
|
|
2022-06-29 11:27:04 +03:00
|
|
|
mov eax, esi ; EAX = magic value
|
|
|
|
mov ebx, edi ; EBX = protocol info
|
2022-06-27 11:48:03 +03:00
|
|
|
xor ecx, ecx
|
|
|
|
xor edx, edx
|
|
|
|
xor esi, esi
|
|
|
|
xor edi, edi
|
|
|
|
xor ebp, ebp
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2022-06-29 13:41:42 +03:00
|
|
|
align 16
|
2022-06-29 13:32:50 +03:00
|
|
|
.mini_stack:
|
|
|
|
times 3 dq 0
|
|
|
|
.mini_stack_top:
|
|
|
|
|
2022-06-27 11:48:03 +03:00
|
|
|
global multiboot_reloc_stub_end
|
|
|
|
multiboot_reloc_stub_end:
|
2023-09-28 12:15:33 +03:00
|
|
|
|
|
|
|
section .note.GNU-stack noalloc noexec nowrite progbits
|