[88] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Defines for BOOTVARS struct used by boot menu |
---|
| 3 | ; and drive initialization. |
---|
[376] | 4 | |
---|
| 5 | ; |
---|
[526] | 6 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[376] | 8 | ; |
---|
| 9 | ; This program is free software; you can redistribute it and/or modify |
---|
| 10 | ; it under the terms of the GNU General Public License as published by |
---|
| 11 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 12 | ; (at your option) any later version. |
---|
[526] | 13 | ; |
---|
[376] | 14 | ; This program is distributed in the hope that it will be useful, |
---|
| 15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[526] | 17 | ; GNU General Public License for more details. |
---|
[376] | 18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 19 | ; |
---|
| 20 | |
---|
[3] | 21 | %ifndef BOOTVARS_INC |
---|
| 22 | %define BOOTVARS_INC |
---|
| 23 | |
---|
[595] | 24 | |
---|
| 25 | ; Temporary locations for system interrupt handlers. Stored during ROM initialization |
---|
| 26 | ; and needed when we do full initialization and drive detection on INT 19h |
---|
| 27 | TEMPORARY_VECTOR_FOR_SYSTEM_INT13h EQU 32h ; Unused by BIOS (reserved for DOS) |
---|
| 28 | TEMPORARY_VECTOR_FOR_SYSTEM_INT19h EQU 33h ; Unused by BIOS (reserved for DOS) |
---|
| 29 | |
---|
| 30 | |
---|
[492] | 31 | ; Default drives |
---|
| 32 | DEFAULT_FLOPPY_DRIVE_LETTER EQU 'A' |
---|
| 33 | DEFAULT_HARD_DRIVE_LETTER EQU 'C' |
---|
| 34 | |
---|
[397] | 35 | ; Number of times to retry booting before accepting error |
---|
[96] | 36 | BOOT_READ_RETRY_TIMES EQU 3 |
---|
| 37 | |
---|
[3] | 38 | |
---|
[397] | 39 | %ifdef MODULE_HOTKEYS |
---|
[492] | 40 | |
---|
[392] | 41 | struc HOTKEYVARS |
---|
[599] | 42 | .fpPrevTimerHandler resb 4 ; Previous 1Ch timer hander |
---|
[524] | 43 | .wTimeWhenDisplayed resb 2 ; System time (ticks) when Hotkey bar was first displayed |
---|
[500] | 44 | .wFddAndHddLetters: |
---|
[492] | 45 | .bFddLetter resb 1 ; Floppy Drive letter hotkey (upper case) |
---|
[596] | 46 | .wHddLetterAndFlags: |
---|
[528] | 47 | .bHddLetter resb 1 ; Hard Drive letter hotkey (upper case). Must be after .bFddLetter! |
---|
[492] | 48 | .bFlags resb 1 ; Must be just after .bHddLetter! (dependency in Hotkeybar.asm) |
---|
| 49 | .bScancode resb 1 ; Function hotkey scancode, must be just after .bFlags! |
---|
[392] | 50 | endstruc |
---|
[3] | 51 | |
---|
[492] | 52 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS |
---|
[526] | 53 | %if HOTKEYVARS.bFddLetter+1 != HOTKEYVARS.bHddLetter || HOTKEYVARS.bHddLetter+1 != HOTKEYVARS.bFlags || HOTKEYVARS.bFlags+1 != HOTKEYVARS.bScancode |
---|
[492] | 54 | %error "HOTKEYVARS: bytes need to come in the order .bFddLetter, then .bHddLetter, then .bFlags, then .bScancode" |
---|
| 55 | %endif |
---|
| 56 | %endif |
---|
| 57 | |
---|
[524] | 58 | ; Bit defines for HOTKEYVARS.bFlags |
---|
| 59 | FLG_HOTKEY_HD_FIRST EQU (1<<0) ; First try to boot from HDD, then FDD |
---|
[599] | 60 | FLG_HOTKEY_UPDATING EQU (1<<1) ; Hotkeybar update in progress |
---|
[392] | 61 | |
---|
[492] | 62 | %endif ; MODULE_HOTKEYS |
---|
[392] | 63 | |
---|
[593] | 64 | |
---|
| 65 | ; Pre-boot variables. These do not exist after successful boot to OS. |
---|
| 66 | ; Segment is always 0000h, same as BDA segment |
---|
| 67 | struc BOOTVARS |
---|
| 68 | resb 7C00h |
---|
| 69 | .rgbAtaInfo: ; 7C00h, ATA Information for drive detection |
---|
| 70 | .rgbBootSect resb 512 ; 7C00h, Boot sector |
---|
| 71 | resb 256 ; Boot Menu stack |
---|
| 72 | .rgbMnuStack: |
---|
| 73 | .dwPostStack resb 4 ; POST stack pointer when entering INT 19h |
---|
| 74 | %ifdef MODULE_HOTKEYS |
---|
| 75 | .hotkeyVars resb HOTKEYVARS_size ; Must be located just before DRVDETECTINFO structs |
---|
| 76 | %endif |
---|
| 77 | .rgDrvDetectInfo: ; Array containing DRVDETECTINFO structs |
---|
| 78 | endstruc |
---|
| 79 | |
---|
| 80 | |
---|
[592] | 81 | ; MAX_HARD_DISK_NAME_LENGTH must be defined ahead of the DRVDETECTINFO structure to avoid problems with NASM |
---|
| 82 | MAX_HARD_DISK_NAME_LENGTH EQU 30 ; Bytes reserved for drive name |
---|
| 83 | |
---|
[397] | 84 | struc DRVDETECTINFO |
---|
[422] | 85 | .StartOfDrvDetectInfo: |
---|
[397] | 86 | .szDrvName resb MAX_HARD_DISK_NAME_LENGTH |
---|
| 87 | resb 2 ; Zero word (ensures string terminates) |
---|
| 88 | .wInitErrorFlags resb 2 ; Errors during initialization |
---|
[421] | 89 | |
---|
[422] | 90 | ; DRVDETECTINFO's size must be an even multiple of DPT's size |
---|
| 91 | .EndOfDriveDetectInfo: resb LARGEST_DPT_SIZE - (.EndOfDriveDetectInfo % LARGEST_DPT_SIZE) |
---|
[397] | 92 | endstruc |
---|
| 93 | |
---|
| 94 | DPT_DRVDETECTINFO_SIZE_MULTIPLIER EQU DRVDETECTINFO_size / LARGEST_DPT_SIZE |
---|
| 95 | |
---|
| 96 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS |
---|
| 97 | %if MAX_HARD_DISK_NAME_LENGTH % 2 <> 0 |
---|
| 98 | %error "MAX_HARD_DISK_NAME_LENGTH needs to be a multiple of 2, memory is moved with word operations." |
---|
| 99 | %endif |
---|
| 100 | %endif |
---|
| 101 | |
---|
| 102 | |
---|
[121] | 103 | ;-------------------------------------------------------------------- |
---|
| 104 | ; Stores POST stack pointer to BOOTVARS. |
---|
| 105 | ; |
---|
| 106 | ; STORE_POST_STACK_POINTER |
---|
| 107 | ; Parameters: |
---|
[243] | 108 | ; ES: BDA and Interrupt Vector segment (zero) |
---|
[121] | 109 | ; Returns: |
---|
| 110 | ; Nothing |
---|
| 111 | ; Corrupts registers: |
---|
| 112 | ; Nothing |
---|
| 113 | ;-------------------------------------------------------------------- |
---|
| 114 | %macro STORE_POST_STACK_POINTER 0 |
---|
[243] | 115 | mov [es:BOOTVARS.dwPostStack], sp |
---|
| 116 | mov [es:BOOTVARS.dwPostStack+2], ss |
---|
[121] | 117 | %endmacro |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | ;-------------------------------------------------------------------- |
---|
| 121 | ; Initializes stack for boot menu usage. |
---|
| 122 | ; POST stack is not large enough when DPTs are stored to 30:0h. |
---|
| 123 | ; |
---|
| 124 | ; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP |
---|
| 125 | ; then you also have to unconditionally enable the CLI/STI pair. |
---|
| 126 | ; The reason for this is that only some buggy 808x CPU:s need the |
---|
| 127 | ; CLI/STI instruction pair when changing stacks. Other CPU:s disable |
---|
| 128 | ; interrupts automatically when SS is modified for the duration of |
---|
| 129 | ; the immediately following instruction to give time to change SP. |
---|
| 130 | ; |
---|
| 131 | ; SWITCH_TO_BOOT_MENU_STACK |
---|
| 132 | ; Parameters: |
---|
| 133 | ; Nothing |
---|
| 134 | ; Returns: |
---|
| 135 | ; SS:SP: Pointer to top of Boot Menu stack |
---|
| 136 | ; Corrupts registers: |
---|
| 137 | ; Nothing |
---|
| 138 | ;-------------------------------------------------------------------- |
---|
| 139 | %macro SWITCH_TO_BOOT_MENU_STACK 0 |
---|
| 140 | %ifndef USE_186 |
---|
| 141 | cli ; Disable interrupts |
---|
| 142 | %endif |
---|
| 143 | LOAD_BDA_SEGMENT_TO ss, sp |
---|
| 144 | mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack |
---|
| 145 | %ifndef USE_186 |
---|
| 146 | sti ; Enable interrupts |
---|
| 147 | %endif |
---|
| 148 | %endmacro |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | ;-------------------------------------------------------------------- |
---|
| 152 | ; Restores SS and SP to initial boot loader values. |
---|
| 153 | ; |
---|
[243] | 154 | ; Note! Must return with AX=0 and CF preserved. |
---|
| 155 | ; See Int19hMenu_JumpToBootSector_or_RomBoot. |
---|
[121] | 156 | ; |
---|
| 157 | ; SWITCH_BACK_TO_POST_STACK |
---|
| 158 | ; Parameters: |
---|
[243] | 159 | ; AX: BDA and Interrupt Vector segment (zero) |
---|
[121] | 160 | ; Returns: |
---|
| 161 | ; SS:SP: Ptr to POST stack |
---|
| 162 | ; Corrupts registers: |
---|
[243] | 163 | ; Nothing (not even FLAGS) |
---|
[121] | 164 | ;-------------------------------------------------------------------- |
---|
| 165 | %macro SWITCH_BACK_TO_POST_STACK 0 |
---|
| 166 | %ifndef USE_386 |
---|
[243] | 167 | cli |
---|
| 168 | mov ss, ax |
---|
[121] | 169 | mov sp, [ss:BOOTVARS.dwPostStack] |
---|
| 170 | mov ss, [ss:BOOTVARS.dwPostStack+2] |
---|
[243] | 171 | sti |
---|
[121] | 172 | %else |
---|
[243] | 173 | mov ss, ax |
---|
[121] | 174 | lss sp, [ss:BOOTVARS.dwPostStack] |
---|
[294] | 175 | %endif |
---|
[121] | 176 | %endmacro |
---|
| 177 | |
---|
| 178 | |
---|
[3] | 179 | %endif ; BOOTVARS_INC |
---|