X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=src%2Fuefi.asm;h=aca71de7944f51d8bf65b866c31c7c2754391114;hb=3ee67e335626610219a3c08ba38263547f5afff8;hp=16fc85d589fd8f147d0187352fc35cf5cdfe1826;hpb=184d6bc9567f2e1efe1a9a39263f0be4ef1d5c96;p=rrq%2Fjonasforth.git diff --git a/src/uefi.asm b/src/uefi.asm index 16fc85d..aca71de 100644 --- a/src/uefi.asm +++ b/src/uefi.asm @@ -1,5 +1,3 @@ -;; vim: syntax=fasm - format pe64 dll efi entry main @@ -27,11 +25,16 @@ struc EFI_SYSTEM_TABLE { .FirmwareVendor dq ? ; CHAR16* .FirmwareRevision dd ? ; UINT32 align 8 - .ConsoleInHandle dq ? ; EFI_HANDLE - .ConIn dq ? ; EFI_SIMPLE_TEXT_INPUT_PROTOCOL* - .ConsoleOutHandle dq ? ; EFI_HANDLE - .ConOut dq ? ; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* - ; ... + .ConsoleInHandle dq ? ; EFI_HANDLE + .ConIn dq ? ; EFI_SIMPLE_TEXT_INPUT_PROTOCOL* + .ConsoleOutHandle dq ? ; EFI_HANDLE + .ConOut dq ? ; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* + .StandardErroHandle dq ? ; EFI_HANDLE + .StdErr dq ? ; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* + .RuntimeServices dq ? ; EFI_RUNTIME_SERVICES* + .BootServices dq ? ; EFI_BOOT_SERVICES* + .NumberOfTableEntries dq ? ; UINTN (native width!!) + .ConfigurationTable dq ? ; EFI_CONFIGURATION_TABLE* } struct EFI_SYSTEM_TABLE @@ -66,13 +69,15 @@ os_initialize: ret os_print_string: - ;; We take an input string of bytes without any terminator. We need to turn - ;; this string into a string of words, terminated by a null character. + ;; We take an input string of bytes without any terminator. We need + ;; to turn this string into a string of words, terminated by a null + ;; character. mov rdi, .output_buffer ; Current location in output string .copy_byte: - ;; When there are no characters left in the input string, we are done. + ;; When there are no characters left in the input string, we are + ;; done. cmp rdx, 0 je .done @@ -100,14 +105,14 @@ os_print_string: mov byte [rdi], al inc rdi - ;; The output string has words rather than bytes for charactesr, so we need - ;; to add an extra zero: + ;; The output string has words rather than bytes for charactesr, so + ;; we need to add an extra zero: mov byte [rdi], 0 inc rdi .pop: - ;; We finished copying character to output string, so pop it from the input - ;; string. + ;; We finished copying character to output string, so pop it from + ;; the input string. inc rcx dec rdx @@ -116,13 +121,15 @@ os_print_string: ;; Append a final null-word: mov word [rdi], 0 - ; At this point we have our null-terminated word-string at .output_buffer. Now - ; we just need to print it. + ; At this point we have our null-terminated word-string at + ; .output_buffer. Now we just need to print it. - mov rcx, [system_table] ; EFI_SYSTEM_TABLE* rcx - mov rcx, [rcx + EFI_SYSTEM_TABLE.ConOut] ; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* rcx + mov rcx, [system_table] ; EFI_SYSTEM_TABLE* rcx + mov rcx, [rcx + EFI_SYSTEM_TABLE.ConOut] + ; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* rcx mov rdx, .output_buffer - mov rbx, [rcx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString] ; EFI_TEXT_STRING rbx + mov rbx, [rcx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString] + ; EFI_TEXT_STRING rbx sub rsp, 32 call rbx add rsp, 32 @@ -130,10 +137,12 @@ os_print_string: os_read_char: .read_key: - mov rcx, [system_table] ; EFI_SYSTEM_TABLE* rcx - mov rcx, [rcx + EFI_SYSTEM_TABLE.ConIn] ; EFI_SIMPLE_TEXT_INPUT_PROTOCOL* rcx - mov rbx, [rcx + EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke] ; EFI_INPUT_READ_KEY rbx - mov rdx, input_key ; EFI_INPUT_KEY* rdx + mov rcx, [system_table] ; EFI_SYSTEM_TABLE* rcx + mov rcx, [rcx + EFI_SYSTEM_TABLE.ConIn] + ; EFI_SIMPLE_TEXT_INPUT_PROTOCOL* rcx + mov rbx, [rcx + EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke] + ; EFI_INPUT_READ_KEY rbx + mov rdx, input_key ; EFI_INPUT_KEY* rdx sub rsp, 32 call rbx add rsp, 32