add efi_putc
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
*.code-workspace
|
*.code-workspace
|
||||||
*.efi
|
*.efi
|
||||||
image/
|
image/
|
||||||
|
*.fas
|
||||||
|
*.prep
|
@@ -19,24 +19,50 @@ include '../const.inc'
|
|||||||
purge DQ ; because of some struct DQ in const.inc
|
purge DQ ; because of some struct DQ in const.inc
|
||||||
include 'uefi64.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
|
; rcx - color = fore | back
|
||||||
proc set_text_color; uses rax
|
proc efi_set_text_color
|
||||||
mov rax, rcx
|
mov rax, [efi_table]
|
||||||
mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut]
|
mov rax, [rax+EFI_SYSTEM_TABLE.ConOut]
|
||||||
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute], rcx, rax
|
mov rdx, rcx ; arg2 - color
|
||||||
|
mov rcx, rax ; arg1 - this
|
||||||
|
fstcall [rax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute]
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
; rbx - efi table
|
; rcx - null-terminated string
|
||||||
; rcx - string
|
proc efi_puts
|
||||||
proc print_string; uses rax
|
mov rax, [efi_table]
|
||||||
mov rax, rcx
|
mov rax, [rax+EFI_SYSTEM_TABLE.ConOut]
|
||||||
mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut]
|
mov rdx, rcx ; arg2 - string
|
||||||
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, rax
|
mov rcx, rax ; arg1 - this
|
||||||
|
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
|
||||||
ret
|
ret
|
||||||
endp
|
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
|
proc main _efi_handle, _efi_table
|
||||||
mov [efi_handle], rcx
|
mov [efi_handle], rcx
|
||||||
mov [efi_table], rdx
|
mov [efi_table], rdx
|
||||||
@@ -47,11 +73,15 @@ proc main _efi_handle, _efi_table
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jnz $ ; loop if fail to init text
|
jnz $ ; loop if fail to init text
|
||||||
|
|
||||||
fstcall set_text_color, EFI_BLUE or EFI_BACKGROUND_GREEN
|
fstcall efi_set_text_color, EFI_BLUE or EFI_BACKGROUND_GREEN
|
||||||
fstcall print_string, msg_hello_k64_loader
|
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 efi_set_text_color, EFI_LIGHTRED
|
||||||
fstcall print_string, msg_2
|
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
|
;; TODO: print some dec, hex. => impl simple printf. fdo.inc
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user