StupidOS/boot/efi/bootia32.asm

103 lines
1.8 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
include '../common/const.inc'
include '../common/macro.inc'
2024-03-21 10:42:18 +00:00
include 'uefi.inc'
2024-09-07 12:40:28 +00:00
include '../../kernel/sys/bootinfo.inc'
include 'logger.inc'
2024-09-08 10:01:20 +00:00
include 'memory.inc'
include 'fs.inc'
2024-09-07 12:40:28 +00:00
section '.text' code executable readable
2024-03-21 10:42:18 +00:00
;; 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.OpenProtocol]
mov [fnOpenProtocol], ecx
mov ecx, [ebx + EFI_BOOT_SERVICES.Exit]
mov [fnExit], ecx
2024-03-21 10:42:18 +00:00
2024-09-08 10:01:20 +00:00
call efi_memory_init
2024-09-07 12:40:28 +00:00
call efi_log_init
2024-03-21 10:42:18 +00:00
2024-09-07 12:40:28 +00:00
mov esi, szHelloMsg
call efi_log
2024-03-21 10:42:18 +00:00
2024-09-08 10:01:20 +00:00
call efi_fs_init
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-09-07 12:40:28 +00:00
szHelloMsg du 'StupidOS EFI Bootloader', 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
2024-09-07 12:40:28 +00:00
stBootInfo BootInfo
2024-06-05 15:15:00 +00:00
hImage dd ?
pSystemTable dd ?
;; Variable: pBootServices
pBootServices 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: pLoadFileProtocol
;; Pointer to EFI_LOAD_FILE_PROTOCOL
pLoadFileProtocol dd ?
fnLoadFile dd ?