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

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

Changes to XTIDE Universal BIOS:

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