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

Last change on this file since 595 was 595, checked in by Tomi Tilli, 6 years ago
  • Int 19h reset handler now tries to boot from drive A before warm reset. This should help to get INT 10h hooked before launching booter games (meaning system reset without reseting interrupt vector table).
  • Win 95 hack temporarily removed (module not included by default). Very limited testing shows that CMOS hack seems to work with AMI bios but locks on Award BIOS.
File size: 5.9 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
25; Temporary locations for system interrupt handlers. Stored during ROM initialization
26; and needed when we do full initialization and drive detection on INT 19h
27TEMPORARY_VECTOR_FOR_SYSTEM_INT13h EQU 32h ; Unused by BIOS (reserved for DOS)
28TEMPORARY_VECTOR_FOR_SYSTEM_INT19h EQU 33h ; Unused by BIOS (reserved for DOS)
29
30
31; Default drives
32DEFAULT_FLOPPY_DRIVE_LETTER EQU 'A'
33DEFAULT_HARD_DRIVE_LETTER EQU 'C'
34
35; Number of times to retry booting before accepting error
36BOOT_READ_RETRY_TIMES EQU 3
37
38
39%ifdef MODULE_HOTKEYS
40
41struc HOTKEYVARS
42 .wTimeWhenDisplayed resb 2 ; System time (ticks) when Hotkey bar was first displayed
43 .wFddAndHddLetters:
44 .bFddLetter resb 1 ; Floppy Drive letter hotkey (upper case)
45 .bHddLetter resb 1 ; Hard Drive letter hotkey (upper case). Must be after .bFddLetter!
46 .bFlags resb 1 ; Must be just after .bHddLetter! (dependency in Hotkeybar.asm)
47 .bScancode resb 1 ; Function hotkey scancode, must be just after .bFlags!
48endstruc
49
50%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
51%if HOTKEYVARS.bFddLetter+1 != HOTKEYVARS.bHddLetter || HOTKEYVARS.bHddLetter+1 != HOTKEYVARS.bFlags || HOTKEYVARS.bFlags+1 != HOTKEYVARS.bScancode
52%error "HOTKEYVARS: bytes need to come in the order .bFddLetter, then .bHddLetter, then .bFlags, then .bScancode"
53%endif
54%endif
55
56; Bit defines for HOTKEYVARS.bFlags
57FLG_HOTKEY_HD_FIRST EQU (1<<0) ; First try to boot from HDD, then FDD
58
59%endif ; MODULE_HOTKEYS
60
61
62; Pre-boot variables. These do not exist after successful boot to OS.
63; Segment is always 0000h, same as BDA segment
64struc BOOTVARS
65 resb 7C00h
66 .rgbAtaInfo: ; 7C00h, ATA Information for drive detection
67 .rgbBootSect resb 512 ; 7C00h, Boot sector
68 resb 256 ; Boot Menu stack
69 .rgbMnuStack:
70 .dwPostStack resb 4 ; POST stack pointer when entering INT 19h
71%ifdef MODULE_HOTKEYS
72 .hotkeyVars resb HOTKEYVARS_size ; Must be located just before DRVDETECTINFO structs
73%endif
74 .rgDrvDetectInfo: ; Array containing DRVDETECTINFO structs
75endstruc
76
77
78; MAX_HARD_DISK_NAME_LENGTH must be defined ahead of the DRVDETECTINFO structure to avoid problems with NASM
79MAX_HARD_DISK_NAME_LENGTH EQU 30 ; Bytes reserved for drive name
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
91DPT_DRVDETECTINFO_SIZE_MULTIPLIER EQU DRVDETECTINFO_size / LARGEST_DPT_SIZE
92
93%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
94%if MAX_HARD_DISK_NAME_LENGTH % 2 <> 0
95 %error "MAX_HARD_DISK_NAME_LENGTH needs to be a multiple of 2, memory is moved with word operations."
96%endif
97%endif
98
99
100;--------------------------------------------------------------------
101; Stores POST stack pointer to BOOTVARS.
102;
103; STORE_POST_STACK_POINTER
104; Parameters:
105; ES: BDA and Interrupt Vector segment (zero)
106; Returns:
107; Nothing
108; Corrupts registers:
109; Nothing
110;--------------------------------------------------------------------
111%macro STORE_POST_STACK_POINTER 0
112 mov [es:BOOTVARS.dwPostStack], sp
113 mov [es:BOOTVARS.dwPostStack+2], ss
114%endmacro
115
116
117;--------------------------------------------------------------------
118; Initializes stack for boot menu usage.
119; POST stack is not large enough when DPTs are stored to 30:0h.
120;
121; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
122; then you also have to unconditionally enable the CLI/STI pair.
123; The reason for this is that only some buggy 808x CPU:s need the
124; CLI/STI instruction pair when changing stacks. Other CPU:s disable
125; interrupts automatically when SS is modified for the duration of
126; the immediately following instruction to give time to change SP.
127;
128; SWITCH_TO_BOOT_MENU_STACK
129; Parameters:
130; Nothing
131; Returns:
132; SS:SP: Pointer to top of Boot Menu stack
133; Corrupts registers:
134; Nothing
135;--------------------------------------------------------------------
136%macro SWITCH_TO_BOOT_MENU_STACK 0
137%ifndef USE_186
138 cli ; Disable interrupts
139%endif
140 LOAD_BDA_SEGMENT_TO ss, sp
141 mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack
142%ifndef USE_186
143 sti ; Enable interrupts
144%endif
145%endmacro
146
147
148;--------------------------------------------------------------------
149; Restores SS and SP to initial boot loader values.
150;
151; Note! Must return with AX=0 and CF preserved.
152; See Int19hMenu_JumpToBootSector_or_RomBoot.
153;
154; SWITCH_BACK_TO_POST_STACK
155; Parameters:
156; AX: BDA and Interrupt Vector segment (zero)
157; Returns:
158; SS:SP: Ptr to POST stack
159; Corrupts registers:
160; Nothing (not even FLAGS)
161;--------------------------------------------------------------------
162%macro SWITCH_BACK_TO_POST_STACK 0
163%ifndef USE_386
164 cli
165 mov ss, ax
166 mov sp, [ss:BOOTVARS.dwPostStack]
167 mov ss, [ss:BOOTVARS.dwPostStack+2]
168 sti
169%else
170 mov ss, ax
171 lss sp, [ss:BOOTVARS.dwPostStack]
172%endif
173%endmacro
174
175
176%endif ; BOOTVARS_INC
Note: See TracBrowser for help on using the repository browser.