diff --git a/boot/common/const.inc b/boot/common/const.inc index 69f2b25..f78dd79 100644 --- a/boot/common/const.inc +++ b/boot/common/const.inc @@ -1,6 +1,9 @@ CR = 0x0D LF = 0x0A +TRUE = 1 +FALSE = 0 + ; -------- Address ---------- MBR_BASE = 0x0600 BOOTSECT_BASE = 0x7C00 diff --git a/boot/efi/bootia32.asm b/boot/efi/bootia32.asm index 28301c8..ca3b984 100644 --- a/boot/efi/bootia32.asm +++ b/boot/efi/bootia32.asm @@ -31,8 +31,20 @@ efimain: mov ebx, [eax + EFI_SYSTEM_TABLE.BootServices] mov [pBootServices], ebx - ;mov ecx, [ebx + EFI_BOOT_SERVICES.OpenProtocol] - ;mov [fnOpenProtocol], ecx + 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 mov ebx, [eax + EFI_SYSTEM_TABLE.ConOut] mov [pConOut], ebx @@ -53,8 +65,7 @@ efimain: call [fnOutputStr] add esp, 8 - ; load config - + ; #=======================# ; search and load kernel ; openVolume() @@ -93,11 +104,12 @@ pSystemTable dd ? ;; Variable: pBootServices pBootServices dd ? -fnAllocatePages dd ? -fnFreePages dd ? +fnAllocatePool dd ? +fnFreePool dd ? fnGetMemoryMap dd ? fnOpenProtocol dd ? fnCloseProtocol dd ? +fnExit dd ? ;; Variable: pRuntimeServices pRuntimeServices dd ? diff --git a/boot/efi/uefi.inc b/boot/efi/uefi.inc index ecce118..5bdcc4d 100644 --- a/boot/efi/uefi.inc +++ b/boot/efi/uefi.inc @@ -210,6 +210,7 @@ struc EFI_BOOT_SERVICES .SetMem UINTPTR .CreateEventEx UINTPTR } +defn EFI_BOOT_SERVICES ;; ======================================================================== ;; EFI_RUNTIMES_SERVICES diff --git a/boot/loader/disk.inc b/boot/loader/disk.inc index 47412d9..c55e76b 100644 --- a/boot/loader/disk.inc +++ b/boot/loader/disk.inc @@ -1,6 +1,6 @@ disk_read_sectors: - test byte [drive_lba], 1 + test byte [bDriveLBA], TRUE je .lba_read push ax push bx @@ -18,7 +18,7 @@ disk_read_sectors: mov ch, byte [C] mov cl, byte [S] mov dh, byte [H] - mov dl, [drive_number] + mov dl, [uDrive] int 0x13 jc @f pop cx @@ -29,7 +29,7 @@ disk_read_sectors: loop disk_read_sectors ret @@: - mov si, msg_error_sector + mov si, szMsgErrorSector call bios_print ret .lba_read: @@ -38,12 +38,11 @@ disk_read_sectors: mov word [disk_packet.offset], bx mov word [disk_packet.lba], ax mov ds, [disk_packet] - mov dl, [drive_number] + mov dl, [uDrive] mov ah, 0x42 int 0x13 ret - C dw 0x00 H dw 0x00 S dw 0x00 diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 8454a38..25e4036 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -27,9 +27,9 @@ _start: push cs pop ds - mov [drive_number], dl + mov [uDrive], dl - mov si, msg_stage2 + mov si, szMsgStage2 call bios_log ; enable A20 line @@ -43,7 +43,7 @@ _start: ; dl >= 0x80 == hard drive ; dl == 0xE0 ~= CD/DVD ; dl <= 0xFF == hard drive - mov dl, [drive_number] + mov dl, [uDrive] cmp dl, 0x7F ; skip disk extension check jle @f @@ -53,19 +53,19 @@ _start: mov bx, 0x55AA int 0x13 jc @f - mov [drive_lba], 1 + mov [bDriveLBA], TRUE @@: ; detect filesystem (FAT12/16 or StpdFS) ; load kernel from filesystem ; +---------+--------+---------+ - ; | bootsec | sect 1 | stpd sb | + ; | bootsec | sect 1 | stpd sb | ; +---------+--------+---------+ ; 0 512 1024 ; ; for now fat12 is asumed call fat_load_root - mov si, kernel_fat12_file + mov si, szKernelFile call fat_search_root jc .error_not_found @@ -95,13 +95,13 @@ _start: jmp 0x8:common32 .error_not_found: - mov si, msg_error_not_found + mov si, szMsgErrorNotFound jmp .error .error_memory: - mov si, msg_error_memory + mov si, szMsgErrorMemory jmp .error .error_a20: - mov si, msg_error_a20 + mov si, szMsgErrorA20 .error: call bios_log @@ -118,15 +118,15 @@ _start: include 'video.inc' include 'gdt.inc' -drive_number rb 1 -drive_lba db 0 +uDrive rb 1 +bDriveLBA db FALSE -msg_stage2 db "StupidOS Loader", 0 -kernel_fat12_file db "VMSTUPIDSYS", 0 -msg_error_a20 db "ERROR: can't enable a20 line", 0 -msg_error_memory db "ERROR: can't detect available memory", 0 -msg_error_sector db "ERROR: reading sector", CR, LF, 0 -msg_error_not_found db "ERROR: kernel not found", 0 +szMsgStage2 db "StupidOS Loader", 0 +szKernelFile db "VMSTUPIDSYS", 0 +szMsgErrorA20 db "ERROR: can't enable a20 line", 0 +szMsgErrorMemory db "ERROR: can't detect available memory", 0 +szMsgErrorSector db "ERROR: reading sector", CR, LF, 0 +szMsgErrorNotFound db "ERROR: kernel not found", 0 use32 ; ========================================================================= @@ -143,11 +143,12 @@ multiboot: common32: - mov [0xB8000], dword 0x07690748 + ; paging ; identity map first 1MB - ; map kernel to 0xC0000000 + ; map kernel to 0xC000000 + ; ----------------------- push STPDBOOT_MAGIC