X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=efitest.asm;fp=efitest.asm;h=bae6aa2eb82802c07e39c088853429e49130cd61;hb=2117a112ad4a45811ce270a2be0e1c6cbc83febb;hp=26d29d14e64bd554bdb4f46b2eb2525c4147efdb;hpb=ec88f1d0899fa575bb443d547779a4fa22c9fcb5;p=efitest3 diff --git a/efitest.asm b/efitest.asm index 26d29d1..bae6aa2 100644 --- a/efitest.asm +++ b/efitest.asm @@ -1,8 +1,36 @@ ; 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 @@ -72,6 +100,19 @@ setup_serial: 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 @@ -110,6 +151,11 @@ start32: and eax, 0fffffeffh wrmsr + mov edi, 0a0000h + mov ecx, 16000 + mov eax, 00ff0000h + rep stosd + mov esi, str_hello call ser_putstr @@ -139,4 +185,5 @@ ser_putstr: .done: ret + align 4 end: