[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 |
|
---|
[492] | 24 | ; Default drives
|
---|
| 25 | DEFAULT_FLOPPY_DRIVE_LETTER EQU 'A'
|
---|
| 26 | DEFAULT_HARD_DRIVE_LETTER EQU 'C'
|
---|
| 27 |
|
---|
[397] | 28 | ; Number of times to retry booting before accepting error
|
---|
[96] | 29 | BOOT_READ_RETRY_TIMES EQU 3
|
---|
| 30 |
|
---|
[294] | 31 | ; Pre-boot variables. These do not exist after successful boot to OS.
|
---|
[3] | 32 | ; Segment is always 0000h, same as BDA segment
|
---|
| 33 | struc BOOTVARS
|
---|
[392] | 34 | resb 7C00h
|
---|
| 35 | .rgbAtaInfo: ; 7C00h, ATA Information for drive detection
|
---|
| 36 | .rgbBootSect resb 512 ; 7C00h, Boot sector
|
---|
| 37 | resb 256 ; Boot Menu stack
|
---|
[221] | 38 | .rgbMnuStack:
|
---|
[392] | 39 | .dwPostStack resb 4 ; POST stack pointer when entering INT 19h
|
---|
[397] | 40 | %ifdef MODULE_HOTKEYS
|
---|
[589] | 41 | .hotkeyVars resb HOTKEYVARS_size
|
---|
[397] | 42 | %endif
|
---|
| 43 | .rgDrvDetectInfo: ; Array containing DRVDETECTINFO structs
|
---|
[3] | 44 | endstruc
|
---|
| 45 |
|
---|
[520] | 46 |
|
---|
[397] | 47 | %ifdef MODULE_HOTKEYS
|
---|
[492] | 48 |
|
---|
[392] | 49 | struc HOTKEYVARS
|
---|
[524] | 50 | .wTimeWhenDisplayed resb 2 ; System time (ticks) when Hotkey bar was first displayed
|
---|
[500] | 51 | .wFddAndHddLetters:
|
---|
[492] | 52 | .bFddLetter resb 1 ; Floppy Drive letter hotkey (upper case)
|
---|
[528] | 53 | .bHddLetter resb 1 ; Hard Drive letter hotkey (upper case). Must be after .bFddLetter!
|
---|
[492] | 54 | .bFlags resb 1 ; Must be just after .bHddLetter! (dependency in Hotkeybar.asm)
|
---|
| 55 | .bScancode resb 1 ; Function hotkey scancode, must be just after .bFlags!
|
---|
[392] | 56 | endstruc
|
---|
[3] | 57 |
|
---|
[492] | 58 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
|
---|
[526] | 59 | %if HOTKEYVARS.bFddLetter+1 != HOTKEYVARS.bHddLetter || HOTKEYVARS.bHddLetter+1 != HOTKEYVARS.bFlags || HOTKEYVARS.bFlags+1 != HOTKEYVARS.bScancode
|
---|
[492] | 60 | %error "HOTKEYVARS: bytes need to come in the order .bFddLetter, then .bHddLetter, then .bFlags, then .bScancode"
|
---|
| 61 | %endif
|
---|
| 62 | %endif
|
---|
| 63 |
|
---|
[524] | 64 | ; Bit defines for HOTKEYVARS.bFlags
|
---|
| 65 | FLG_HOTKEY_HD_FIRST EQU (1<<0) ; First try to boot from HDD, then FDD
|
---|
[392] | 66 |
|
---|
[492] | 67 | %endif ; MODULE_HOTKEYS
|
---|
[392] | 68 |
|
---|
[592] | 69 | ; MAX_HARD_DISK_NAME_LENGTH must be defined ahead of the DRVDETECTINFO structure to avoid problems with NASM
|
---|
| 70 | MAX_HARD_DISK_NAME_LENGTH EQU 30 ; Bytes reserved for drive name
|
---|
| 71 |
|
---|
[397] | 72 | struc DRVDETECTINFO
|
---|
[422] | 73 | .StartOfDrvDetectInfo:
|
---|
[397] | 74 | .szDrvName resb MAX_HARD_DISK_NAME_LENGTH
|
---|
| 75 | resb 2 ; Zero word (ensures string terminates)
|
---|
| 76 | .wInitErrorFlags resb 2 ; Errors during initialization
|
---|
[421] | 77 |
|
---|
[422] | 78 | ; DRVDETECTINFO's size must be an even multiple of DPT's size
|
---|
| 79 | .EndOfDriveDetectInfo: resb LARGEST_DPT_SIZE - (.EndOfDriveDetectInfo % LARGEST_DPT_SIZE)
|
---|
[397] | 80 | endstruc
|
---|
| 81 |
|
---|
| 82 | DPT_DRVDETECTINFO_SIZE_MULTIPLIER EQU DRVDETECTINFO_size / LARGEST_DPT_SIZE
|
---|
| 83 |
|
---|
| 84 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
|
---|
| 85 | %if MAX_HARD_DISK_NAME_LENGTH % 2 <> 0
|
---|
| 86 | %error "MAX_HARD_DISK_NAME_LENGTH needs to be a multiple of 2, memory is moved with word operations."
|
---|
| 87 | %endif
|
---|
| 88 | %endif
|
---|
| 89 |
|
---|
| 90 |
|
---|
[121] | 91 | ;--------------------------------------------------------------------
|
---|
| 92 | ; Stores POST stack pointer to BOOTVARS.
|
---|
| 93 | ;
|
---|
| 94 | ; STORE_POST_STACK_POINTER
|
---|
| 95 | ; Parameters:
|
---|
[243] | 96 | ; ES: BDA and Interrupt Vector segment (zero)
|
---|
[121] | 97 | ; Returns:
|
---|
| 98 | ; Nothing
|
---|
| 99 | ; Corrupts registers:
|
---|
| 100 | ; Nothing
|
---|
| 101 | ;--------------------------------------------------------------------
|
---|
| 102 | %macro STORE_POST_STACK_POINTER 0
|
---|
[243] | 103 | mov [es:BOOTVARS.dwPostStack], sp
|
---|
| 104 | mov [es:BOOTVARS.dwPostStack+2], ss
|
---|
[121] | 105 | %endmacro
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | ;--------------------------------------------------------------------
|
---|
| 109 | ; Initializes stack for boot menu usage.
|
---|
| 110 | ; POST stack is not large enough when DPTs are stored to 30:0h.
|
---|
| 111 | ;
|
---|
| 112 | ; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
|
---|
| 113 | ; then you also have to unconditionally enable the CLI/STI pair.
|
---|
| 114 | ; The reason for this is that only some buggy 808x CPU:s need the
|
---|
| 115 | ; CLI/STI instruction pair when changing stacks. Other CPU:s disable
|
---|
| 116 | ; interrupts automatically when SS is modified for the duration of
|
---|
| 117 | ; the immediately following instruction to give time to change SP.
|
---|
| 118 | ;
|
---|
| 119 | ; SWITCH_TO_BOOT_MENU_STACK
|
---|
| 120 | ; Parameters:
|
---|
| 121 | ; Nothing
|
---|
| 122 | ; Returns:
|
---|
| 123 | ; SS:SP: Pointer to top of Boot Menu stack
|
---|
| 124 | ; Corrupts registers:
|
---|
| 125 | ; Nothing
|
---|
| 126 | ;--------------------------------------------------------------------
|
---|
| 127 | %macro SWITCH_TO_BOOT_MENU_STACK 0
|
---|
| 128 | %ifndef USE_186
|
---|
| 129 | cli ; Disable interrupts
|
---|
| 130 | %endif
|
---|
| 131 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
| 132 | mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack
|
---|
| 133 | %ifndef USE_186
|
---|
| 134 | sti ; Enable interrupts
|
---|
| 135 | %endif
|
---|
| 136 | %endmacro
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | ;--------------------------------------------------------------------
|
---|
| 140 | ; Restores SS and SP to initial boot loader values.
|
---|
| 141 | ;
|
---|
[243] | 142 | ; Note! Must return with AX=0 and CF preserved.
|
---|
| 143 | ; See Int19hMenu_JumpToBootSector_or_RomBoot.
|
---|
[121] | 144 | ;
|
---|
| 145 | ; SWITCH_BACK_TO_POST_STACK
|
---|
| 146 | ; Parameters:
|
---|
[243] | 147 | ; AX: BDA and Interrupt Vector segment (zero)
|
---|
[121] | 148 | ; Returns:
|
---|
| 149 | ; SS:SP: Ptr to POST stack
|
---|
| 150 | ; Corrupts registers:
|
---|
[243] | 151 | ; Nothing (not even FLAGS)
|
---|
[121] | 152 | ;--------------------------------------------------------------------
|
---|
| 153 | %macro SWITCH_BACK_TO_POST_STACK 0
|
---|
| 154 | %ifndef USE_386
|
---|
[243] | 155 | cli
|
---|
| 156 | mov ss, ax
|
---|
[121] | 157 | mov sp, [ss:BOOTVARS.dwPostStack]
|
---|
| 158 | mov ss, [ss:BOOTVARS.dwPostStack+2]
|
---|
[243] | 159 | sti
|
---|
[121] | 160 | %else
|
---|
[243] | 161 | mov ss, ax
|
---|
[121] | 162 | lss sp, [ss:BOOTVARS.dwPostStack]
|
---|
[294] | 163 | %endif
|
---|
[121] | 164 | %endmacro
|
---|
| 165 |
|
---|
| 166 |
|
---|
[3] | 167 | %endif ; BOOTVARS_INC
|
---|