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

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

Changes to XTIDE Universal BIOS:

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