add efi_putc

This commit is contained in:
rgimad
2025-01-25 13:15:48 +03:00
parent fa217d4578
commit 1843c9ff69
2 changed files with 48 additions and 16 deletions

4
.gitignore vendored
View File

@@ -1,3 +1,5 @@
*.code-workspace
*.efi
image/
image/
*.fas
*.prep

View File

@@ -19,24 +19,50 @@ include '../const.inc'
purge DQ ; because of some struct DQ in const.inc
include 'uefi64.inc'
; rbx - efi table
; hmm proc64.inc uses TCHAR. to define string literals (?)
struc TCHAR [val] {
common match any, val \{ . du val \}
match , val \{ . du ? \}
}
sizeof.TCHAR = 2
; rcx - color = fore | back
proc set_text_color; uses rax
mov rax, rcx
mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut]
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute], rcx, rax
proc efi_set_text_color
mov rax, [efi_table]
mov rax, [rax+EFI_SYSTEM_TABLE.ConOut]
mov rdx, rcx ; arg2 - color
mov rcx, rax ; arg1 - this
fstcall [rax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute]
ret
endp
; rbx - efi table
; rcx - string
proc print_string; uses rax
mov rax, rcx
mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut]
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, rax
; rcx - null-terminated string
proc efi_puts
mov rax, [efi_table]
mov rax, [rax+EFI_SYSTEM_TABLE.ConOut]
mov rdx, rcx ; arg2 - string
mov rcx, rax ; arg1 - this
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
ret
endp
; rcx - char
proc efi_putc
locals
cstr dq 0
endl
mov rax, [efi_table]
mov rax, [rax+EFI_SYSTEM_TABLE.ConOut]
mov byte [cstr], cl
lea rdx, [cstr]
mov rcx, rax
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
ret
endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
proc main _efi_handle, _efi_table
mov [efi_handle], rcx
mov [efi_table], rdx
@@ -47,11 +73,15 @@ proc main _efi_handle, _efi_table
test eax, eax
jnz $ ; loop if fail to init text
fstcall set_text_color, EFI_BLUE or EFI_BACKGROUND_GREEN
fstcall print_string, msg_hello_k64_loader
fstcall efi_set_text_color, EFI_BLUE or EFI_BACKGROUND_GREEN
fstcall efi_puts, msg_hello_k64_loader
fstcall efi_puts, <'hi there', 13, 10> ;; didnt work unless declared TCHAR
fstcall set_text_color, EFI_LIGHTRED
fstcall print_string, msg_2
fstcall efi_set_text_color, EFI_LIGHTRED
fstcall efi_puts, msg_2
fstcall efi_set_text_color, EFI_CYAN
fstcall efi_putc, 0+'a' ;; 0+ is to cast it to number to put in register it itself, not the address of string literal 'a' but function expects char in rcx
;; TODO: print some dec, hex. => impl simple printf. fdo.inc