1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Defines for BOOTVARS struct used by boot menu
|
---|
3 | ; and drive initialization.
|
---|
4 |
|
---|
5 | ;
|
---|
6 | ; XTIDE Universal BIOS and Associated Tools
|
---|
7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
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.
|
---|
13 | ;
|
---|
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
|
---|
17 | ; GNU General Public License for more details.
|
---|
18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
19 | ;
|
---|
20 |
|
---|
21 | %ifndef BOOTVARS_INC
|
---|
22 | %define BOOTVARS_INC
|
---|
23 |
|
---|
24 | ; Default drives
|
---|
25 | DEFAULT_FLOPPY_DRIVE_LETTER EQU 'A'
|
---|
26 | DEFAULT_HARD_DRIVE_LETTER EQU 'C'
|
---|
27 |
|
---|
28 | ; Number of times to retry booting before accepting error
|
---|
29 | BOOT_READ_RETRY_TIMES EQU 3
|
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 | ; Pre-boot variables. These do not exist after successful boot to OS.
|
---|
34 | ; Segment is always 0000h, same as BDA segment
|
---|
35 | struc BOOTVARS
|
---|
36 | resb 7C00h
|
---|
37 | .rgbAtaInfo: ; 7C00h, ATA Information for drive detection
|
---|
38 | .rgbBootSect resb 512 ; 7C00h, Boot sector
|
---|
39 | resb 256 ; Boot Menu stack
|
---|
40 | .rgbMnuStack:
|
---|
41 | .dwPostStack resb 4 ; POST stack pointer when entering INT 19h
|
---|
42 | %ifdef MODULE_HOTKEYS
|
---|
43 | .hotkeyVars resb HOTKEYVARS_size
|
---|
44 | %endif
|
---|
45 | .rgDrvDetectInfo: ; Array containing DRVDETECTINFO structs
|
---|
46 | endstruc
|
---|
47 |
|
---|
48 |
|
---|
49 | %ifdef MODULE_HOTKEYS
|
---|
50 |
|
---|
51 | struc HOTKEYVARS
|
---|
52 | .wTimeWhenDisplayed resb 2 ; System time (ticks) when Hotkey bar was first displayed
|
---|
53 | .wFddAndHddLetters:
|
---|
54 | .bFddLetter resb 1 ; Floppy Drive letter hotkey (upper case)
|
---|
55 | .bHddLetter resb 1 ; Hard Drive letter hotkey (upper case). Must be after .bFddLetter!
|
---|
56 | .bFlags resb 1 ; Must be just after .bHddLetter! (dependency in Hotkeybar.asm)
|
---|
57 | .bScancode resb 1 ; Function hotkey scancode, must be just after .bFlags!
|
---|
58 | endstruc
|
---|
59 |
|
---|
60 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
|
---|
61 | %if HOTKEYVARS.bFddLetter+1 != HOTKEYVARS.bHddLetter || HOTKEYVARS.bHddLetter+1 != HOTKEYVARS.bFlags || HOTKEYVARS.bFlags+1 != HOTKEYVARS.bScancode
|
---|
62 | %error "HOTKEYVARS: bytes need to come in the order .bFddLetter, then .bHddLetter, then .bFlags, then .bScancode"
|
---|
63 | %endif
|
---|
64 | %endif
|
---|
65 |
|
---|
66 | ; Bit defines for HOTKEYVARS.bFlags
|
---|
67 | FLG_HOTKEY_HD_FIRST EQU (1<<0) ; First try to boot from HDD, then FDD
|
---|
68 |
|
---|
69 | %endif ; MODULE_HOTKEYS
|
---|
70 |
|
---|
71 | struc DRVDETECTINFO
|
---|
72 | .StartOfDrvDetectInfo:
|
---|
73 | .szDrvName resb MAX_HARD_DISK_NAME_LENGTH
|
---|
74 | resb 2 ; Zero word (ensures string terminates)
|
---|
75 | .wInitErrorFlags resb 2 ; Errors during initialization
|
---|
76 |
|
---|
77 | ; DRVDETECTINFO's size must be an even multiple of DPT's size
|
---|
78 | .EndOfDriveDetectInfo: resb LARGEST_DPT_SIZE - (.EndOfDriveDetectInfo % LARGEST_DPT_SIZE)
|
---|
79 | endstruc
|
---|
80 |
|
---|
81 | ; Boot Menu Information Table. These are generated for all XTIDE Universal
|
---|
82 | ; BIOS drives. Available only until boot is successful.
|
---|
83 | MAX_HARD_DISK_NAME_LENGTH EQU 30 ; Bytes reserved for drive name
|
---|
84 | DPT_DRVDETECTINFO_SIZE_MULTIPLIER EQU DRVDETECTINFO_size / LARGEST_DPT_SIZE
|
---|
85 |
|
---|
86 |
|
---|
87 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
|
---|
88 |
|
---|
89 | %if MAX_HARD_DISK_NAME_LENGTH % 2 <> 0
|
---|
90 | %error "MAX_HARD_DISK_NAME_LENGTH needs to be a multiple of 2, memory is moved with word operations."
|
---|
91 | %endif
|
---|
92 |
|
---|
93 | %if DRVDETECTINFO_size % LARGEST_DPT_SIZE <> 0
|
---|
94 | %error "DRVDETECTINFO's size must be an even multiple of DPT's size. Add or remove padding at the bottom of DRVDETECTINFO to bring the two sizes into alignment. As DRVDETECTINFO is only used at boot time, with plenty of memory to consume, it is OK to waste some space here."
|
---|
95 | %endif
|
---|
96 |
|
---|
97 | %if DRVDETECTINFO.szDrvName <> 0
|
---|
98 | %error "DRVDETECTINFO.szDrvName is assumed to be the first member of struc DRVDETECTINFO, in BootMenuPrint_RefreshItem"
|
---|
99 | %endif
|
---|
100 |
|
---|
101 | %endif
|
---|
102 |
|
---|
103 |
|
---|
104 | ;--------------------------------------------------------------------
|
---|
105 | ; Stores POST stack pointer to BOOTVARS.
|
---|
106 | ;
|
---|
107 | ; STORE_POST_STACK_POINTER
|
---|
108 | ; Parameters:
|
---|
109 | ; ES: BDA and Interrupt Vector segment (zero)
|
---|
110 | ; Returns:
|
---|
111 | ; Nothing
|
---|
112 | ; Corrupts registers:
|
---|
113 | ; Nothing
|
---|
114 | ;--------------------------------------------------------------------
|
---|
115 | %macro STORE_POST_STACK_POINTER 0
|
---|
116 | mov [es:BOOTVARS.dwPostStack], sp
|
---|
117 | mov [es:BOOTVARS.dwPostStack+2], ss
|
---|
118 | %endmacro
|
---|
119 |
|
---|
120 |
|
---|
121 | ;--------------------------------------------------------------------
|
---|
122 | ; Initializes stack for boot menu usage.
|
---|
123 | ; POST stack is not large enough when DPTs are stored to 30:0h.
|
---|
124 | ;
|
---|
125 | ; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
|
---|
126 | ; then you also have to unconditionally enable the CLI/STI pair.
|
---|
127 | ; The reason for this is that only some buggy 808x CPU:s need the
|
---|
128 | ; CLI/STI instruction pair when changing stacks. Other CPU:s disable
|
---|
129 | ; interrupts automatically when SS is modified for the duration of
|
---|
130 | ; the immediately following instruction to give time to change SP.
|
---|
131 | ;
|
---|
132 | ; SWITCH_TO_BOOT_MENU_STACK
|
---|
133 | ; Parameters:
|
---|
134 | ; Nothing
|
---|
135 | ; Returns:
|
---|
136 | ; SS:SP: Pointer to top of Boot Menu stack
|
---|
137 | ; Corrupts registers:
|
---|
138 | ; Nothing
|
---|
139 | ;--------------------------------------------------------------------
|
---|
140 | %macro SWITCH_TO_BOOT_MENU_STACK 0
|
---|
141 | %ifndef USE_186
|
---|
142 | cli ; Disable interrupts
|
---|
143 | %endif
|
---|
144 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
145 | mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack
|
---|
146 | %ifndef USE_186
|
---|
147 | sti ; Enable interrupts
|
---|
148 | %endif
|
---|
149 | %endmacro
|
---|
150 |
|
---|
151 |
|
---|
152 | ;--------------------------------------------------------------------
|
---|
153 | ; Restores SS and SP to initial boot loader values.
|
---|
154 | ;
|
---|
155 | ; Note! Must return with AX=0 and CF preserved.
|
---|
156 | ; See Int19hMenu_JumpToBootSector_or_RomBoot.
|
---|
157 | ;
|
---|
158 | ; SWITCH_BACK_TO_POST_STACK
|
---|
159 | ; Parameters:
|
---|
160 | ; AX: BDA and Interrupt Vector segment (zero)
|
---|
161 | ; Returns:
|
---|
162 | ; SS:SP: Ptr to POST stack
|
---|
163 | ; Corrupts registers:
|
---|
164 | ; Nothing (not even FLAGS)
|
---|
165 | ;--------------------------------------------------------------------
|
---|
166 | %macro SWITCH_BACK_TO_POST_STACK 0
|
---|
167 | %ifndef USE_386
|
---|
168 | cli
|
---|
169 | mov ss, ax
|
---|
170 | mov sp, [ss:BOOTVARS.dwPostStack]
|
---|
171 | mov ss, [ss:BOOTVARS.dwPostStack+2]
|
---|
172 | sti
|
---|
173 | %else
|
---|
174 | mov ss, ax
|
---|
175 | lss sp, [ss:BOOTVARS.dwPostStack]
|
---|
176 | %endif
|
---|
177 | %endmacro
|
---|
178 |
|
---|
179 |
|
---|
180 | %endif ; BOOTVARS_INC
|
---|