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

Last change on this file since 599 was 599, checked in by Tomi Tilli, 6 years ago

Hotkey bar is now updated and drawn from system timer tick handler 1Ch. This gives much more responsive key input and makes possible to implement some simple detection animation to show that system has not frozen.

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