[88] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Defines for BOOTVARS struct used by boot menu
|
---|
| 3 | ; and drive initialization.
|
---|
| 4 | %ifndef BOOTVARS_INC
|
---|
| 5 | %define BOOTVARS_INC
|
---|
| 6 |
|
---|
| 7 |
|
---|
[96] | 8 | BOOT_READ_RETRY_TIMES EQU 3
|
---|
| 9 |
|
---|
| 10 |
|
---|
[3] | 11 | ; Boot Menu Information Table. These are generated for all XTIDE Universal
|
---|
| 12 | ; BIOS drives. Available only until boot is successfull.
|
---|
| 13 | LEN_BOOTNFO_DRV EQU 26 ; Bytes reserved for drive name
|
---|
| 14 | struc BOOTNFO
|
---|
[241] | 15 | .szDrvName resb LEN_BOOTNFO_DRV ; Drive name
|
---|
| 16 | resb 2 ; Zero word (ensures string terminates)
|
---|
[3] | 17 | .twSectCnt resb 6 ; Total user addressable sectors
|
---|
[241] | 18 | resb 2 ; padding to make BOOTNFO size an even multiple of DPT size
|
---|
[3] | 19 | endstruc
|
---|
| 20 |
|
---|
[241] | 21 | DPT_BOOTNFO_SIZE_MULTIPLIER equ BOOTNFO_size / LARGEST_DPT_SIZE
|
---|
[3] | 22 |
|
---|
[241] | 23 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
|
---|
| 24 |
|
---|
| 25 | %if BOOTNFO_size % LARGEST_DPT_SIZE <> 0
|
---|
| 26 | %error "BOOTNFO's size must be an even multiple of DPT's size. Add or remove padding at the bottom of BOOTNFO to bring the two sizes into alignment. As BOOTNFO is only used at boot time, with plenty of memory to consume, it is OK to waste some space here."
|
---|
| 27 | %endif
|
---|
| 28 |
|
---|
| 29 | %if BOOTNFO.szDrvName <> 0
|
---|
| 30 | %error "BOOTNFO.szDrvName is assumed to be the first member of struc BOOTNFO, in BootMenuPrint_RefreshItem"
|
---|
| 31 | %endif
|
---|
| 32 |
|
---|
| 33 | %if BOOTNFO.szDrvName + LEN_BOOTNFO_DRV + 2 <> BOOTNFO.twSectCnt
|
---|
| 34 | %error "BOOTNFO.twSectCnt is assumed to come immediately after BOOTNFO.szDrvName (with zero padding), in BootInfo_CreateForHardDisk"
|
---|
| 35 | %endif
|
---|
| 36 |
|
---|
| 37 | %endif
|
---|
| 38 |
|
---|
| 39 |
|
---|
[3] | 40 | ; Pre-boot variables. These do not exist after successfull boot to OS.
|
---|
| 41 | ; Segment is always 0000h, same as BDA segment
|
---|
| 42 | struc BOOTVARS
|
---|
[221] | 43 | resb 7C00h
|
---|
[3] | 44 | .rgbAtaInfo: ; 7C00h, ATA Information for drive detection
|
---|
| 45 | .rgbBootSect resb 512 ; 7C00h, Boot sector
|
---|
[221] | 46 | resb 256 ; Boot Menu stack
|
---|
| 47 | .rgbMnuStack:
|
---|
| 48 | .dwPostStack resb 4 ; POST stack pointer when entering INT 19h
|
---|
| 49 | .rgBootNfo: ; Array containing BOOTNFO structs
|
---|
[3] | 50 | endstruc
|
---|
| 51 |
|
---|
| 52 |
|
---|
[121] | 53 | ;--------------------------------------------------------------------
|
---|
| 54 | ; Stores POST stack pointer to BOOTVARS.
|
---|
| 55 | ;
|
---|
| 56 | ; STORE_POST_STACK_POINTER
|
---|
| 57 | ; Parameters:
|
---|
[243] | 58 | ; ES: BDA and Interrupt Vector segment (zero)
|
---|
[121] | 59 | ; Returns:
|
---|
| 60 | ; Nothing
|
---|
| 61 | ; Corrupts registers:
|
---|
| 62 | ; Nothing
|
---|
| 63 | ;--------------------------------------------------------------------
|
---|
| 64 | %macro STORE_POST_STACK_POINTER 0
|
---|
[243] | 65 | mov [es:BOOTVARS.dwPostStack], sp
|
---|
| 66 | mov [es:BOOTVARS.dwPostStack+2], ss
|
---|
[121] | 67 | %endmacro
|
---|
| 68 |
|
---|
| 69 |
|
---|
| 70 | ;--------------------------------------------------------------------
|
---|
| 71 | ; Initializes stack for boot menu usage.
|
---|
| 72 | ; POST stack is not large enough when DPTs are stored to 30:0h.
|
---|
| 73 | ;
|
---|
| 74 | ; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
|
---|
| 75 | ; then you also have to unconditionally enable the CLI/STI pair.
|
---|
| 76 | ; The reason for this is that only some buggy 808x CPU:s need the
|
---|
| 77 | ; CLI/STI instruction pair when changing stacks. Other CPU:s disable
|
---|
| 78 | ; interrupts automatically when SS is modified for the duration of
|
---|
| 79 | ; the immediately following instruction to give time to change SP.
|
---|
| 80 | ;
|
---|
| 81 | ; SWITCH_TO_BOOT_MENU_STACK
|
---|
| 82 | ; Parameters:
|
---|
| 83 | ; Nothing
|
---|
| 84 | ; Returns:
|
---|
| 85 | ; SS:SP: Pointer to top of Boot Menu stack
|
---|
| 86 | ; Corrupts registers:
|
---|
| 87 | ; Nothing
|
---|
| 88 | ;--------------------------------------------------------------------
|
---|
| 89 | %macro SWITCH_TO_BOOT_MENU_STACK 0
|
---|
| 90 | %ifndef USE_186
|
---|
| 91 | cli ; Disable interrupts
|
---|
| 92 | %endif
|
---|
| 93 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
| 94 | mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack
|
---|
| 95 | %ifndef USE_186
|
---|
| 96 | sti ; Enable interrupts
|
---|
| 97 | %endif
|
---|
| 98 | %endmacro
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | ;--------------------------------------------------------------------
|
---|
| 102 | ; Restores SS and SP to initial boot loader values.
|
---|
| 103 | ;
|
---|
[243] | 104 | ; Note! Must return with AX=0 and CF preserved.
|
---|
| 105 | ; See Int19hMenu_JumpToBootSector_or_RomBoot.
|
---|
[121] | 106 | ;
|
---|
| 107 | ; SWITCH_BACK_TO_POST_STACK
|
---|
| 108 | ; Parameters:
|
---|
[243] | 109 | ; AX: BDA and Interrupt Vector segment (zero)
|
---|
[121] | 110 | ; Returns:
|
---|
| 111 | ; SS:SP: Ptr to POST stack
|
---|
| 112 | ; Corrupts registers:
|
---|
[243] | 113 | ; Nothing (not even FLAGS)
|
---|
[121] | 114 | ;--------------------------------------------------------------------
|
---|
| 115 | %macro SWITCH_BACK_TO_POST_STACK 0
|
---|
| 116 | %ifndef USE_386
|
---|
[243] | 117 | cli
|
---|
| 118 | mov ss, ax
|
---|
[121] | 119 | mov sp, [ss:BOOTVARS.dwPostStack]
|
---|
| 120 | mov ss, [ss:BOOTVARS.dwPostStack+2]
|
---|
[243] | 121 | sti
|
---|
[121] | 122 | %else
|
---|
[243] | 123 | mov ss, ax
|
---|
[121] | 124 | lss sp, [ss:BOOTVARS.dwPostStack]
|
---|
[243] | 125 | %endif
|
---|
[121] | 126 | %endmacro
|
---|
| 127 |
|
---|
| 128 |
|
---|
[3] | 129 | %endif ; BOOTVARS_INC
|
---|