some refactoring, try show firmware vendor and revision

This commit is contained in:
rgimad
2025-02-01 21:21:36 +03:00
parent 5c18f0cbba
commit bd4a478855

View File

@@ -20,28 +20,30 @@ purge DQ ; because of some struct DQ in const.inc
include 'uefi64.inc' include 'uefi64.inc'
; rcx - color = fore | back ; rcx - color = fore | back
; uses - rax, rdx ; TODO maybe just save them?? or doesnt worth ??
efi_set_text_color: efi_set_text_color:
push rax rdx
mov rax, [efi_table] mov rax, [efi_table]
mov rax, [rax+EFI_SYSTEM_TABLE.ConOut] mov rax, [rax+EFI_SYSTEM_TABLE.ConOut]
mov rdx, rcx ; arg2 - color mov rdx, rcx ; arg2 - color
mov rcx, rax ; arg1 - this mov rcx, rax ; arg1 - this
fstcall [rax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute] fstcall [rax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute]
pop rdx rax
ret ret
; rcx - null-terminated string ; rcx - null-terminated string
; uses - rax, rdx
efi_puts: efi_puts:
push rax rdx
mov rax, [efi_table] mov rax, [efi_table]
mov rax, [rax+EFI_SYSTEM_TABLE.ConOut] mov rax, [rax+EFI_SYSTEM_TABLE.ConOut]
mov rdx, rcx ; arg2 - string mov rdx, rcx ; arg2 - string
mov rcx, rax ; arg1 - this mov rcx, rax ; arg1 - this
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString] fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
pop rdx rax
ret ret
; rcx - char ; rcx - char
; uses - rax, rdx
efi_putc: efi_putc:
push rax rdx
mov rax, [efi_table] mov rax, [efi_table]
mov rax, [rax+EFI_SYSTEM_TABLE.ConOut] mov rax, [rax+EFI_SYSTEM_TABLE.ConOut]
push qword 0 push qword 0
@@ -50,10 +52,10 @@ efi_putc:
mov rcx, rax mov rcx, rax
fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString] fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
add rsp, 8 add rsp, 8
pop rdx rax
ret ret
; rcx - number ; rcx - number
; uses - rax
efi_print_hex: efi_print_hex:
push rax rbx rcx rdx r8 push rax rbx rcx rdx r8
@@ -103,6 +105,19 @@ 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
mov rcx, msg_firmware_vendor
call efi_puts
mov rcx, [rdx + EFI_SYSTEM_TABLE.FirmwareVendor]
call efi_puts
mov rcx, msg_newline
call efi_puts
mov rcx, msg_firmware_revision
call efi_puts
mov rcx, qword [rdx + EFI_SYSTEM_TABLE.FirmwareRevision]
call efi_print_hex
mov rcx, msg_newline
call efi_puts
mov rcx, EFI_BLUE or EFI_BACKGROUND_CYAN mov rcx, EFI_BLUE or EFI_BACKGROUND_CYAN
call efi_set_text_color call efi_set_text_color
mov rcx, msg_hello_k64_loader mov rcx, msg_hello_k64_loader
@@ -125,6 +140,7 @@ proc main _efi_handle, _efi_table
mov rcx, 0xCAFEBABEFEEDCAFE mov rcx, 0xCAFEBABEFEEDCAFE
call efi_print_hex call efi_print_hex
jmp $ jmp $
endp endp
@@ -139,6 +155,9 @@ hex_codes:
section '.rodata' data readable section '.rodata' data readable
msg_hello_k64_loader du "Hello from Kolibri64 efi loader",13,10,0 msg_hello_k64_loader du "Hello from Kolibri64 efi loader",13,10,0
msg_2 du "Lorem ipsum ! !",13,10,0 msg_2 du "Lorem ipsum ! !",13,10,0
msg_firmware_vendor du "UEFI vendor: ", 0
msg_firmware_revision du "UEFI revision: ", 0
msg_newline du 13,10,0
section '.reloc' fixups data discardable section '.reloc' fixups data discardable