feat(boot): simple efi logger
This commit is contained in:
parent
3349ec20ae
commit
d1927d8180
1
Makefile
1
Makefile
|
@ -106,7 +106,6 @@ run-iso: all
|
||||||
.PHONY: run-efi
|
.PHONY: run-efi
|
||||||
run-efi: all OVMF32.fd
|
run-efi: all OVMF32.fd
|
||||||
qemu-system-i386 \
|
qemu-system-i386 \
|
||||||
$(QEMU_COMMON) \
|
|
||||||
-bios OVMF32.fd \
|
-bios OVMF32.fd \
|
||||||
-drive file=fat:rw:./sysroot,if=none,id=hdd \
|
-drive file=fat:rw:./sysroot,if=none,id=hdd \
|
||||||
-device ide-hd,drive=hdd
|
-device ide-hd,drive=hdd
|
||||||
|
|
|
@ -2,6 +2,7 @@ TARGET = BOOTIA32.EFI
|
||||||
|
|
||||||
BOOTIA32_EFI_SRCS = bootia32.asm \
|
BOOTIA32_EFI_SRCS = bootia32.asm \
|
||||||
uefi.inc \
|
uefi.inc \
|
||||||
|
logger.inc \
|
||||||
../common/const.inc \
|
../common/const.inc \
|
||||||
../common/macro.inc
|
../common/macro.inc
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
format PE DLL EFI at 10000000h
|
format PE DLL EFI at 10000000h
|
||||||
entry efimain
|
entry efimain
|
||||||
|
|
||||||
section '.text' code executable readable
|
|
||||||
|
|
||||||
include '../common/const.inc'
|
include '../common/const.inc'
|
||||||
include '../common/macro.inc'
|
include '../common/macro.inc'
|
||||||
include 'uefi.inc'
|
include 'uefi.inc'
|
||||||
|
include '../../kernel/sys/bootinfo.inc'
|
||||||
|
include 'logger.inc'
|
||||||
|
|
||||||
|
section '.text' code executable readable
|
||||||
|
|
||||||
;; Function: efimain
|
;; Function: efimain
|
||||||
;;
|
;;
|
||||||
|
@ -46,24 +48,10 @@ efimain:
|
||||||
mov ecx, [ebx + EFI_BOOT_SERVICES.Exit]
|
mov ecx, [ebx + EFI_BOOT_SERVICES.Exit]
|
||||||
mov [fnExit], ecx
|
mov [fnExit], ecx
|
||||||
|
|
||||||
mov ebx, [eax + EFI_SYSTEM_TABLE.ConOut]
|
call efi_log_init
|
||||||
mov [pConOut], ebx
|
|
||||||
|
|
||||||
mov ecx, [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset]
|
mov esi, szHelloMsg
|
||||||
mov [fnOutputReset], ecx
|
call efi_log
|
||||||
mov ecx, [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
|
|
||||||
mov [fnOutputStr], ecx
|
|
||||||
|
|
||||||
mov eax, 1
|
|
||||||
push eax
|
|
||||||
push [pConOut]
|
|
||||||
call [fnOutputReset]
|
|
||||||
add esp, 8
|
|
||||||
|
|
||||||
push szHelloMsg
|
|
||||||
push [pConOut]
|
|
||||||
call [fnOutputStr]
|
|
||||||
add esp, 8
|
|
||||||
|
|
||||||
; #=======================#
|
; #=======================#
|
||||||
; search and load kernel
|
; search and load kernel
|
||||||
|
@ -89,7 +77,7 @@ efimain:
|
||||||
|
|
||||||
section '.data' data readable writeable
|
section '.data' data readable writeable
|
||||||
|
|
||||||
szHelloMsg du 'StupidOS EFI Bootloader', CR, LF, 0
|
szHelloMsg du 'StupidOS EFI Bootloader', 0
|
||||||
|
|
||||||
; Search path: / /boot /boot/efi
|
; Search path: / /boot /boot/efi
|
||||||
aSearchPaths du '\\', 0, \
|
aSearchPaths du '\\', 0, \
|
||||||
|
@ -98,6 +86,8 @@ aSearchPaths du '\\', 0, \
|
||||||
szKernelFile du 'vmstupid.sys', 0
|
szKernelFile du 'vmstupid.sys', 0
|
||||||
szConfigFile du 'stpdboot.ini', 0
|
szConfigFile du 'stpdboot.ini', 0
|
||||||
|
|
||||||
|
stBootInfo BootInfo
|
||||||
|
|
||||||
hImage dd ?
|
hImage dd ?
|
||||||
pSystemTable dd ?
|
pSystemTable dd ?
|
||||||
|
|
||||||
|
@ -113,13 +103,6 @@ fnExit dd ?
|
||||||
;; Variable: pRuntimeServices
|
;; Variable: pRuntimeServices
|
||||||
pRuntimeServices dd ?
|
pRuntimeServices dd ?
|
||||||
|
|
||||||
|
|
||||||
;; Variable: pConOut
|
|
||||||
;; Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
|
|
||||||
pConOut dd ?
|
|
||||||
fnOutputReset dd ?
|
|
||||||
fnOutputStr dd ?
|
|
||||||
|
|
||||||
;; Variable: pLoadFileProtocol
|
;; Variable: pLoadFileProtocol
|
||||||
;; Pointer to EFI_LOAD_FILE_PROTOCOL
|
;; Pointer to EFI_LOAD_FILE_PROTOCOL
|
||||||
pLoadFileProtocol dd ?
|
pLoadFileProtocol dd ?
|
||||||
|
|
119
boot/efi/logger.inc
Normal file
119
boot/efi/logger.inc
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
section '.text' code executable readable
|
||||||
|
|
||||||
|
;; Function: efi_log_init
|
||||||
|
efi_log_init:
|
||||||
|
mov eax, [pSystemTable]
|
||||||
|
add eax, EFI_SYSTEM_TABLE.ConOut
|
||||||
|
mov eax, [eax]
|
||||||
|
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]
|
||||||
|
mov ecx, [eax + EFI_RUNTIMES_SERVICES.GetTime]
|
||||||
|
mov [fnGetTime], ecx
|
||||||
|
|
||||||
|
push 1
|
||||||
|
push [pConOut]
|
||||||
|
call [fnOutputReset]
|
||||||
|
add esp, 8
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
;; Function: efi_log_time
|
||||||
|
efi_log_time:
|
||||||
|
; GetTime(EFI_TIME *time, EFI_TIME_CAPS *cap)
|
||||||
|
push 0
|
||||||
|
push stEfiTime
|
||||||
|
call [fnGetTime]
|
||||||
|
add esp, 8
|
||||||
|
|
||||||
|
; 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
|
||||||
|
|
||||||
|
push szTime
|
||||||
|
push [pConOut]
|
||||||
|
call [fnOutputStr]
|
||||||
|
add esp, 8
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
;; Function: efi_log
|
||||||
|
;;
|
||||||
|
;; In:
|
||||||
|
;; ESI - string to print
|
||||||
|
efi_log:
|
||||||
|
call efi_log_time
|
||||||
|
|
||||||
|
push esi
|
||||||
|
push [pConOut]
|
||||||
|
call [fnOutputStr]
|
||||||
|
add esp, 8
|
||||||
|
|
||||||
|
; print CRLF
|
||||||
|
push szEndLine
|
||||||
|
push [pConOut]
|
||||||
|
call [fnOutputStr]
|
||||||
|
add esp, 8
|
||||||
|
|
||||||
|
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 ?
|
|
@ -242,6 +242,7 @@ struc EFI_RUNTIMES_SERVICES
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
DEFN EFI_RUNTIMES_SERVICES
|
||||||
|
|
||||||
;; ========================================================================
|
;; ========================================================================
|
||||||
;; EFI_LOADED_IMAGE_PROTOCOL
|
;; EFI_LOADED_IMAGE_PROTOCOL
|
||||||
|
|
|
@ -247,7 +247,7 @@ common32:
|
||||||
cmp ecx, 1024
|
cmp ecx, 1024
|
||||||
jb @b
|
jb @b
|
||||||
|
|
||||||
mov dword [boot_page_directory], boot_0_page_table + (PDE_P or PDE_W) ; preset and writable
|
mov dword [boot_page_directory], boot_0_page_table + (PDE_P or PDE_W) ; present and writable
|
||||||
|
|
||||||
mov dword [boot_page_directory + (768 * 4)], boot_0_page_table + (PDE_P or PDE_W)
|
mov dword [boot_page_directory + (768 * 4)], boot_0_page_table + (PDE_P or PDE_W)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue