-;; vim: syntax=fasm
-
format pe64 dll efi
entry main
.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
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
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
;; 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
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