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

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

Changes to XTIDE Universal BIOS:

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