StupidOS/boot/efi/bootia32.asm

127 lines
2.3 KiB
NASM
Raw Normal View History

;; File: bootia32.asm
2024-03-21 10:42:18 +00:00
format PE DLL EFI at 10000000h
entry efimain
section '.text' code executable readable
include '../common/const.inc'
include '../common/macro.inc'
2024-03-21 10:42:18 +00:00
include 'uefi.inc'
;; Function: efimain
;;
;; Parameters:
;;
;; [esp+4] - handle
;; [esp+8] - <EFI_SYSTEM_TABLE>
;;
;; Returns:
;;
;; eax - efi status
;;
2024-03-21 10:42:18 +00:00
efimain:
mov eax, [esp+4]
2024-06-05 15:15:00 +00:00
mov [hImage], eax
2024-03-21 10:42:18 +00:00
mov eax, [esp+8]
2024-06-05 15:15:00 +00:00
mov [pSystemTable], eax
mov ebx, [eax + EFI_SYSTEM_TABLE.RuntimeServices]
mov [pRuntimeServices], ebx
mov ebx, [eax + EFI_SYSTEM_TABLE.BootServices]
mov [pBootServices], ebx
2024-06-07 09:25:28 +00:00
mov ecx, [ebx + EFI_BOOT_SERVICES.AllocatePool]
mov [fnAllocatePool], ecx
mov ecx, [ebx + EFI_BOOT_SERVICES.FreePool]
mov [fnFreePool], ecx
mov ecx, [ebx + EFI_BOOT_SERVICES.GetMemoryMap]
mov [fnGetMemoryMap], ecx
mov ecx, [ebx + EFI_BOOT_SERVICES.OpenProtocol]
mov [fnOpenProtocol], ecx
mov ecx, [ebx + EFI_BOOT_SERVICES.Exit]
mov [fnExit], ecx
2024-03-21 10:42:18 +00:00
mov ebx, [eax + EFI_SYSTEM_TABLE.ConOut]
2024-06-05 15:15:00 +00:00
mov [pConOut], ebx
mov ecx, [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset]
mov [fnOutputReset], ecx
mov ecx, [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
mov [fnOutputStr], ecx
2024-03-21 10:42:18 +00:00
mov eax, 1
push eax
2024-06-05 15:15:00 +00:00
push [pConOut]
call [fnOutputReset]
2024-03-21 10:42:18 +00:00
add esp, 8
2024-06-05 15:15:00 +00:00
push szHelloMsg
push [pConOut]
call [fnOutputStr]
2024-03-21 10:42:18 +00:00
add esp, 8
2024-05-28 04:54:10 +00:00
; #=======================#
2024-05-03 10:00:17 +00:00
; search and load kernel
2024-05-28 04:54:10 +00:00
; openVolume()
; for path in search_path
; if (open(path + file) == ok)
; break
; if not found
; error
2024-05-03 10:00:17 +00:00
; get memory map
; paging
; jump to kernel
2024-03-21 10:42:18 +00:00
jmp $
xor eax, eax
2024-03-21 10:42:18 +00:00
ret
section '.reloc' fixups data discardable
section '.data' data readable writeable
2024-06-05 15:15:00 +00:00
szHelloMsg du 'StupidOS EFI Bootloader', CR, LF, 0
2024-04-02 10:03:47 +00:00
; Search path: / /boot /boot/efi
2024-06-05 15:15:00 +00:00
aSearchPaths du '\\', 0, \
2024-05-03 10:00:17 +00:00
'\\boot', 0, \
'\\boot\\efi', 0, 0
2024-06-05 15:15:00 +00:00
szKernelFile du 'vmstupid.sys', 0
2024-07-02 08:32:11 +00:00
szConfigFile du 'stpdboot.ini', 0
2024-06-05 15:15:00 +00:00
hImage dd ?
pSystemTable dd ?
;; Variable: pBootServices
pBootServices dd ?
2024-06-07 09:25:28 +00:00
fnAllocatePool dd ?
fnFreePool dd ?
2024-06-05 15:15:00 +00:00
fnGetMemoryMap dd ?
fnOpenProtocol dd ?
fnCloseProtocol dd ?
2024-06-07 09:25:28 +00:00
fnExit dd ?
2024-06-05 15:15:00 +00:00
;; Variable: pRuntimeServices
pRuntimeServices dd ?
;; Variable: pConOut
;; Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
pConOut dd ?
fnOutputReset dd ?
fnOutputStr dd ?
;; Variable: pLoadFileProtocol
;; Pointer to EFI_LOAD_FILE_PROTOCOL
pLoadFileProtocol dd ?
fnLoadFile dd ?