refactor: hungarian notation (wip)

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-06-07 11:25:28 +02:00
parent d8f68619d6
commit eb24cb88c2
5 changed files with 46 additions and 30 deletions

View file

@ -1,6 +1,9 @@
CR = 0x0D
LF = 0x0A
TRUE = 1
FALSE = 0
; -------- Address ----------
MBR_BASE = 0x0600
BOOTSECT_BASE = 0x7C00

View file

@ -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,7 +65,6 @@ efimain:
call [fnOutputStr]
add esp, 8
; load config
; #=======================#
; search and load kernel
@ -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 ?

View file

@ -210,6 +210,7 @@ struc EFI_BOOT_SERVICES
.SetMem UINTPTR
.CreateEventEx UINTPTR
}
defn EFI_BOOT_SERVICES
;; ========================================================================
;; EFI_RUNTIMES_SERVICES

View file

@ -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

View file

@ -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,7 +53,7 @@ _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
@ -65,7 +65,7 @@ _start:
; 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