source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Inc/BootVars.inc@ 544

Last change on this file since 544 was 528, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Swapping Floppy and Hard Drives at the same time work again (broke in r492).
  • Hotkeys again work in boot menu (broke in r492).
File size: 6.2 KB
Line 
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
25DEFAULT_FLOPPY_DRIVE_LETTER EQU 'A'
26DEFAULT_HARD_DRIVE_LETTER EQU 'C'
27
28; Number of times to retry booting before accepting error
29BOOT_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
35struc 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
43%ifdef MODULE_8BIT_IDE_ADVANCED
44 .wNextXTCFportToScan resb 2 ; Needed for XT-CF port autodetection
45%endif
46%ifdef MODULE_HOTKEYS
47 .hotkeyVars resb HOTKEYVARS_size
48%endif
49 .rgDrvDetectInfo: ; Array containing DRVDETECTINFO structs
50endstruc
51
52
53%ifdef MODULE_HOTKEYS
54
55struc HOTKEYVARS
56 .wTimeWhenDisplayed resb 2 ; System time (ticks) when Hotkey bar was first displayed
57 .wFddAndHddLetters:
58 .bFddLetter resb 1 ; Floppy Drive letter hotkey (upper case)
59 .bHddLetter resb 1 ; Hard Drive letter hotkey (upper case). Must be after .bFddLetter!
60 .bFlags resb 1 ; Must be just after .bHddLetter! (dependency in Hotkeybar.asm)
61 .bScancode resb 1 ; Function hotkey scancode, must be just after .bFlags!
62endstruc
63
64%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
65%if HOTKEYVARS.bFddLetter+1 != HOTKEYVARS.bHddLetter || HOTKEYVARS.bHddLetter+1 != HOTKEYVARS.bFlags || HOTKEYVARS.bFlags+1 != HOTKEYVARS.bScancode
66%error "HOTKEYVARS: bytes need to come in the order .bFddLetter, then .bHddLetter, then .bFlags, then .bScancode"
67%endif
68%endif
69
70; Bit defines for HOTKEYVARS.bFlags
71FLG_HOTKEY_HD_FIRST EQU (1<<0) ; First try to boot from HDD, then FDD
72
73%endif ; MODULE_HOTKEYS
74
75struc DRVDETECTINFO
76 .StartOfDrvDetectInfo:
77 .szDrvName resb MAX_HARD_DISK_NAME_LENGTH
78 resb 2 ; Zero word (ensures string terminates)
79 .wInitErrorFlags resb 2 ; Errors during initialization
80
81 ; DRVDETECTINFO's size must be an even multiple of DPT's size
82 .EndOfDriveDetectInfo: resb LARGEST_DPT_SIZE - (.EndOfDriveDetectInfo % LARGEST_DPT_SIZE)
83endstruc
84
85; Boot Menu Information Table. These are generated for all XTIDE Universal
86; BIOS drives. Available only until boot is successful.
87MAX_HARD_DISK_NAME_LENGTH EQU 30 ; Bytes reserved for drive name
88DPT_DRVDETECTINFO_SIZE_MULTIPLIER EQU DRVDETECTINFO_size / LARGEST_DPT_SIZE
89
90
91%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
92
93%if MAX_HARD_DISK_NAME_LENGTH % 2 <> 0
94 %error "MAX_HARD_DISK_NAME_LENGTH needs to be a multiple of 2, memory is moved with word operations."
95%endif
96
97%if DRVDETECTINFO_size % LARGEST_DPT_SIZE <> 0
98 %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."
99%endif
100
101%if DRVDETECTINFO.szDrvName <> 0
102 %error "DRVDETECTINFO.szDrvName is assumed to be the first member of struc DRVDETECTINFO, in BootMenuPrint_RefreshItem"
103%endif
104
105%endif
106
107
108;--------------------------------------------------------------------
109; Stores POST stack pointer to BOOTVARS.
110;
111; STORE_POST_STACK_POINTER
112; Parameters:
113; ES: BDA and Interrupt Vector segment (zero)
114; Returns:
115; Nothing
116; Corrupts registers:
117; Nothing
118;--------------------------------------------------------------------
119%macro STORE_POST_STACK_POINTER 0
120 mov [es:BOOTVARS.dwPostStack], sp
121 mov [es:BOOTVARS.dwPostStack+2], ss
122%endmacro
123
124
125;--------------------------------------------------------------------
126; Initializes stack for boot menu usage.
127; POST stack is not large enough when DPTs are stored to 30:0h.
128;
129; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
130; then you also have to unconditionally enable the CLI/STI pair.
131; The reason for this is that only some buggy 808x CPU:s need the
132; CLI/STI instruction pair when changing stacks. Other CPU:s disable
133; interrupts automatically when SS is modified for the duration of
134; the immediately following instruction to give time to change SP.
135;
136; SWITCH_TO_BOOT_MENU_STACK
137; Parameters:
138; Nothing
139; Returns:
140; SS:SP: Pointer to top of Boot Menu stack
141; Corrupts registers:
142; Nothing
143;--------------------------------------------------------------------
144%macro SWITCH_TO_BOOT_MENU_STACK 0
145%ifndef USE_186
146 cli ; Disable interrupts
147%endif
148 LOAD_BDA_SEGMENT_TO ss, sp
149 mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack
150%ifndef USE_186
151 sti ; Enable interrupts
152%endif
153%endmacro
154
155
156;--------------------------------------------------------------------
157; Restores SS and SP to initial boot loader values.
158;
159; Note! Must return with AX=0 and CF preserved.
160; See Int19hMenu_JumpToBootSector_or_RomBoot.
161;
162; SWITCH_BACK_TO_POST_STACK
163; Parameters:
164; AX: BDA and Interrupt Vector segment (zero)
165; Returns:
166; SS:SP: Ptr to POST stack
167; Corrupts registers:
168; Nothing (not even FLAGS)
169;--------------------------------------------------------------------
170%macro SWITCH_BACK_TO_POST_STACK 0
171%ifndef USE_386
172 cli
173 mov ss, ax
174 mov sp, [ss:BOOTVARS.dwPostStack]
175 mov ss, [ss:BOOTVARS.dwPostStack+2]
176 sti
177%else
178 mov ss, ax
179 lss sp, [ss:BOOTVARS.dwPostStack]
180%endif
181%endmacro
182
183
184%endif ; BOOTVARS_INC
Note: See TracBrowser for help on using the repository browser.