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

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

Changes to XTIDE Universal BIOS:

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