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

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

Changes to XTIDE Universal BIOS:

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