2024-09-08 10:01:20 +00:00
|
|
|
;; File: logger.inc
|
|
|
|
|
2024-09-07 12:40:28 +00:00
|
|
|
section '.text' code executable readable
|
|
|
|
|
|
|
|
;; Function: efi_log_init
|
|
|
|
efi_log_init:
|
2025-01-27 13:11:59 +00:00
|
|
|
EFI_GET_INTERFACE eax, ConOut
|
2024-09-07 12:40:28 +00:00
|
|
|
mov [pConOut], eax
|
|
|
|
|
|
|
|
mov ecx, [eax + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset]
|
|
|
|
mov [fnOutputReset], ecx
|
|
|
|
|
|
|
|
mov ecx, [eax + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
|
|
|
|
mov [fnOutputStr], ecx
|
|
|
|
|
|
|
|
mov eax, [pRuntimeServices]
|
2025-01-27 13:11:59 +00:00
|
|
|
mov eax, [eax + EFI_RUNTIMES_SERVICES.GetTime]
|
|
|
|
mov [fnGetTime], eax
|
2024-09-07 12:40:28 +00:00
|
|
|
|
2025-01-27 13:11:59 +00:00
|
|
|
EFI_CALL [fnOutputReset], [pConOut], 1
|
2024-09-07 12:40:28 +00:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
;; Function: efi_log_time
|
|
|
|
efi_log_time:
|
|
|
|
; GetTime(EFI_TIME *time, EFI_TIME_CAPS *cap)
|
2025-01-27 13:11:59 +00:00
|
|
|
|
|
|
|
EFI_CALL [fnGetTime], stEfiTime, 0
|
2024-09-07 12:40:28 +00:00
|
|
|
|
|
|
|
; Hours
|
|
|
|
mov al, [stEfiTime + EFI_TIME.Hour]
|
|
|
|
xor ah, ah
|
|
|
|
mov cl, 10
|
|
|
|
div cl
|
|
|
|
|
|
|
|
add ah, 0x30
|
|
|
|
add al, 0x30
|
|
|
|
|
|
|
|
movzx cx, al
|
|
|
|
mov [szTime + 2], cx
|
|
|
|
|
|
|
|
movzx cx, ah
|
|
|
|
mov [szTime + 4], cx
|
|
|
|
|
|
|
|
; Minutes
|
|
|
|
mov al, [stEfiTime + EFI_TIME.Minute]
|
|
|
|
xor ah, ah
|
|
|
|
mov cl, 10
|
|
|
|
div cl
|
|
|
|
|
|
|
|
add ah, 0x30
|
|
|
|
add al, 0x30
|
|
|
|
|
|
|
|
movzx cx, al
|
|
|
|
mov [szTime + 8], cx
|
|
|
|
|
|
|
|
movzx cx, ah
|
|
|
|
mov [szTime + 10], cx
|
|
|
|
|
|
|
|
; Secondes
|
|
|
|
mov al, [stEfiTime + EFI_TIME.Second]
|
|
|
|
xor ah, ah
|
|
|
|
mov cl, 10
|
|
|
|
div cl
|
|
|
|
|
|
|
|
add ah, 0x30
|
|
|
|
add al, 0x30
|
|
|
|
|
|
|
|
movzx cx, al
|
|
|
|
mov [szTime + 14], cx
|
|
|
|
|
|
|
|
movzx cx, ah
|
|
|
|
mov [szTime + 16], cx
|
|
|
|
|
2025-01-27 13:11:59 +00:00
|
|
|
EFI_CALL [fnOutputStr], [pConOut], szTime
|
2024-09-07 12:40:28 +00:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
;; Function: efi_log
|
|
|
|
;;
|
|
|
|
;; In:
|
2025-01-27 13:11:59 +00:00
|
|
|
;; EAX - string to print
|
2024-09-07 12:40:28 +00:00
|
|
|
efi_log:
|
2025-01-27 13:11:59 +00:00
|
|
|
push ebp
|
|
|
|
mov ebp, esp
|
2024-09-07 12:40:28 +00:00
|
|
|
|
|
|
|
push esi
|
2025-01-27 13:11:59 +00:00
|
|
|
mov esi, eax
|
|
|
|
|
|
|
|
call efi_log_time
|
|
|
|
|
|
|
|
EFI_CALL [fnOutputStr], [pConOut], esi
|
2024-09-07 12:40:28 +00:00
|
|
|
|
|
|
|
; print CRLF
|
2025-01-27 13:11:59 +00:00
|
|
|
EFI_CALL [fnOutputStr], [pConOut], szEndLine
|
|
|
|
|
|
|
|
pop esi
|
2024-09-07 12:40:28 +00:00
|
|
|
|
2025-01-27 13:11:59 +00:00
|
|
|
leave
|
2024-09-07 12:40:28 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
section '.data' data readable writable
|
|
|
|
|
|
|
|
szTime du '[00:00:00] ', 0
|
|
|
|
szEndLine du CR, LF, 0
|
|
|
|
|
|
|
|
;; Variable: pConOut
|
|
|
|
;; Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
|
|
|
|
pConOut dd ?
|
|
|
|
fnOutputReset dd ?
|
|
|
|
fnOutputStr dd ?
|
|
|
|
|
|
|
|
stEfiTime EFI_TIME
|
|
|
|
fnGetTime dd ?
|