; vi:ft=nasm:
bits 64
- org 100000h
+ org 1000h
+
+BOOT_SERVICES equ 96
+BOOT_GET_MEMORY_MAP equ 56
+BOOT_EXIT_BOOT_SERVICES equ 232
start:
+ mov [efihandle], rcx
+ mov [systab], rdx
+
+ ; retrieve memory map
+ ; args: RCX, RDX, R8, and R9.
+ lea rcx, [mmap_size]
+ lea rdx, [mmapbuf]
+ lea r8, [mmap_key]
+ lea r9, [mmap_descsz]
+ lea rax, [mmap_descver]
+ push rax
+ sub rsp, 32
+ mov rax, [systab]
+ mov rbx, [rax + BOOT_SERVICES]
+ call [rbx + BOOT_GET_MEMORY_MAP]
+ add rsp, 40
+ ; exit boot services
+ mov rcx, [efihandle]
+ mov rdx, [mmap_key]
+ mov rax, [systab]
+ mov rbx, [rax + BOOT_SERVICES]
+ call [rbx + BOOT_EXIT_BOOT_SERVICES]
+
+ ; move code to absolute 1000h
call get_rip
.after_call:
sub rax, .after_call - start
out dx, al
ret
+
+ align 8
+efihandle dq 0
+systab dq 0
+; memory map data
+mmap_size dq 4096
+mmap_key dq 0
+mmap_descsz dq 0
+mmap_descver dq 0
+
+ align 4096
+mmapbuf: times 4096 db 0
+
str_hello db 'hello!',13,10,0
align 4
and eax, 0fffffeffh
wrmsr
+ mov edi, 0a0000h
+ mov ecx, 16000
+ mov eax, 00ff0000h
+ rep stosd
+
mov esi, str_hello
call ser_putstr
.done: ret
+ align 4
end: