Compare commits
2 Commits
766c67c041
...
1e181bc22c
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e181bc22c | |||
| 68c8200aa4 |
@@ -96,28 +96,6 @@
|
|||||||
%endmacro
|
%endmacro
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
|
||||||
; __CDECL16_INVOKE func, arg1[, arg2 ...]
|
|
||||||
; pushes args right-to-left, calls, then add sp by (#args)*2
|
|
||||||
; !!! warning for word sized args only !!!
|
|
||||||
%ifnmacro __CDECL16_INVOKE
|
|
||||||
%macro __CDECL16_INVOKE 1-*
|
|
||||||
%push __CDECL16_INVOKE
|
|
||||||
%define %$fn %1
|
|
||||||
%assign %$argc %0-1
|
|
||||||
%rotate -1 ; drop function name; %1.. are args
|
|
||||||
%rep %$argc
|
|
||||||
%rotate -1
|
|
||||||
push %1
|
|
||||||
%endrep
|
|
||||||
call %$fn
|
|
||||||
%if %$argc
|
|
||||||
add sp, %$argc*2
|
|
||||||
%endif
|
|
||||||
%pop
|
|
||||||
%endmacro
|
|
||||||
%endif
|
|
||||||
|
|
||||||
%ifnmacro __CDECL16_CLOB
|
%ifnmacro __CDECL16_CLOB
|
||||||
; Save registers in the order listed. Supports "flags" as a pseudo-reg.
|
; Save registers in the order listed. Supports "flags" as a pseudo-reg.
|
||||||
%macro __CDECL16_CLOB 1-*
|
%macro __CDECL16_CLOB 1-*
|
||||||
|
|||||||
@@ -106,7 +106,9 @@ ALIGN 4, db 0x90
|
|||||||
SearchFATDIR:
|
SearchFATDIR:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.file_lookup:
|
.file_lookup:
|
||||||
print_string SearchFATDIR_info
|
__CDECL16_CALL_ARGS SearchFATDIR_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
mov bx, fat32_state
|
mov bx, fat32_state
|
||||||
.load_first_dir:
|
.load_first_dir:
|
||||||
mov eax, dword [bx + FAT32_State_t.curr_dir_cluster_32]
|
mov eax, dword [bx + FAT32_State_t.curr_dir_cluster_32]
|
||||||
@@ -176,7 +178,9 @@ SearchFATDIR:
|
|||||||
|
|
||||||
; TODO: move this to a seperate string search function
|
; TODO: move this to a seperate string search function
|
||||||
.parse_dir:
|
.parse_dir:
|
||||||
print_string MaybeFound_Boot_info
|
__CDECL16_CALL_ARGS MaybeFound_Boot_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
.lfn_check:
|
.lfn_check:
|
||||||
; check for ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID (0x0F) in offset 11
|
; check for ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID (0x0F) in offset 11
|
||||||
; TODO: going to skip LFN for now, since all valid volumes will have SFN's
|
; TODO: going to skip LFN for now, since all valid volumes will have SFN's
|
||||||
@@ -212,7 +216,8 @@ ALIGN 4, db 0x90
|
|||||||
NextCluster:
|
NextCluster:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.func:
|
.func:
|
||||||
print_string NextFATCluster_info
|
__CDECL16_CALL_ARGS NextFATCluster_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
mov ax, FAT32_NextClusterData_t_size
|
mov ax, FAT32_NextClusterData_t_size
|
||||||
push ax ; length
|
push ax ; length
|
||||||
@@ -285,7 +290,8 @@ ALIGN 4, db 0x90
|
|||||||
ReadFATCluster:
|
ReadFATCluster:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.func:
|
.func:
|
||||||
print_string ReadFATCluster_info
|
__CDECL16_CALL_ARGS ReadFATCluster_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
mov bx, fat32_bpb
|
mov bx, fat32_bpb
|
||||||
mov si, fat32_ebpb
|
mov si, fat32_ebpb
|
||||||
|
|||||||
@@ -34,13 +34,6 @@
|
|||||||
%include "early_mem.inc"
|
%include "early_mem.inc"
|
||||||
%include "error_codes.inc"
|
%include "error_codes.inc"
|
||||||
|
|
||||||
%macro print_string 1
|
|
||||||
mov ax, %1
|
|
||||||
push ax
|
|
||||||
call PrintString
|
|
||||||
add sp, 0x2
|
|
||||||
%endmacro
|
|
||||||
|
|
||||||
section .text
|
section .text
|
||||||
begin_text:
|
begin_text:
|
||||||
; dl = byte boot_drive
|
; dl = byte boot_drive
|
||||||
@@ -145,37 +138,43 @@ main:
|
|||||||
|
|
||||||
call SetTextMode
|
call SetTextMode
|
||||||
call disable_cursor_bios
|
call disable_cursor_bios
|
||||||
print_string HelloPrompt_info
|
|
||||||
|
__CDECL16_CALL_ARGS HelloPrompt_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
; setup the early heap
|
; setup the early heap
|
||||||
__CDECL16_CALL_ARGS early_heap_state
|
__CDECL16_CALL_ARGS early_heap_state
|
||||||
__CDECL16_CALL arena_init, 1
|
|
||||||
|
|
||||||
; enable A20 gate
|
; enable A20 gate
|
||||||
call EnableA20
|
call EnableA20
|
||||||
print_string A20_Enabled_OK_info
|
__CDECL16_CALL_ARGS A20_Enabled_OK_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
; get system memory map
|
; get system memory map
|
||||||
call GetMemoryMap
|
call GetMemoryMap
|
||||||
print_string MemoryMap_OK_info
|
__CDECL16_CALL_ARGS MemoryMap_OK_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
; enter unreal mode (enter PM w/ 16 bit code, 32 bit flat memory model & return to real)
|
; enter unreal mode (enter PM w/ 16 bit code, 32 bit flat memory model & return to real)
|
||||||
; ds, es will be set to the 64KiB STAGE2_SEGMENT, fs/gs will be flat/huge memory (4GiB)
|
; ds, es will be set to the 64KiB STAGE2_SEGMENT, fs/gs will be flat/huge memory (4GiB)
|
||||||
; use __REFLAT macros to re-flat ds/es for easy transfers to >1MiB
|
; use __REFLAT macros to re-flat ds/es for easy transfers to >1MiB
|
||||||
; NOTE: if you modify a segment register you will need to re-unreal it
|
; NOTE: if you modify a segment register you will need to re-unreal it
|
||||||
call EnterUnrealMode
|
call EnterUnrealMode
|
||||||
print_string UnrealMode_OK_info
|
__CDECL16_CALL_ARGS UnrealMode_OK_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
; FAT Driver setup
|
; FAT Driver setup
|
||||||
call InitFATDriver
|
call InitFATDriver
|
||||||
print_string InitFATSYS_OK_info
|
__CDECL16_CALL_ARGS InitFATSYS_OK_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
;
|
;
|
||||||
; Find first cluster of bootable file
|
; Find first cluster of bootable file
|
||||||
call SearchFATDIR
|
call SearchFATDIR
|
||||||
push dword eax ; save first cluster of bootable file
|
push dword eax ; save first cluster of bootable file
|
||||||
|
|
||||||
print_string FileFound_OK_info
|
__CDECL16_CALL_ARGS FileFound_OK_info
|
||||||
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
pop dword eax
|
pop dword eax
|
||||||
push dword eax ; print Cluster of boot file
|
push dword eax ; print Cluster of boot file
|
||||||
|
|||||||
Reference in New Issue
Block a user