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