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

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

Space optimizations in the Boot Menu and BootInfo routines, taking advantage of nested %s. Optimization in the init of RamVars to avoid writing the signature twice. Preparing for addition of serial floppy support, starting to break the assumption that our drives are always 80h or higher.

File size: 4.1 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Defines for BOOTVARS struct used by boot menu
3;                   and drive initialization.
4%ifndef BOOTVARS_INC
5%define BOOTVARS_INC
6
7
8BOOT_READ_RETRY_TIMES       EQU     3
9
10
11; Boot Menu Information Table. These are generated for all XTIDE Universal
12; BIOS drives. Available only until boot is successfull.
13LEN_BOOTNFO_DRV     EQU     26      ; Bytes reserved for drive name
14struc BOOTNFO
15    .szDrvName      resb    LEN_BOOTNFO_DRV     ; Drive name
16                    resb    2       ; Zero word (ensures string terminates)
17    .twSectCnt      resb    6       ; Total user addressable sectors
18                    resb    2       ; padding to make BOOTNFO size an even multiple of DPT size
19endstruc
20
21DPT_BOOTNFO_SIZE_MULTIPLIER  equ    BOOTNFO_size / LARGEST_DPT_SIZE
22
23%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS               
24
25%if BOOTNFO_size % LARGEST_DPT_SIZE <> 0
26%error "BOOTNFO's size must be an even multiple of DPT's size.  Add or remove padding at the bottom of BOOTNFO to bring the two sizes into alignment.  As BOOTNFO is only used at boot time, with plenty of memory to consume, it is OK to waste some space here."
27%endif
28
29%if BOOTNFO.szDrvName <> 0
30%error "BOOTNFO.szDrvName is assumed to be the first member of struc BOOTNFO, in BootMenuPrint_RefreshItem"
31%endif
32
33%if BOOTNFO.szDrvName + LEN_BOOTNFO_DRV + 2 <> BOOTNFO.twSectCnt
34%error "BOOTNFO.twSectCnt is assumed to come immediately after BOOTNFO.szDrvName (with zero padding), in BootInfo_CreateForHardDisk"
35%endif
36
37%endif
38
39
40; Pre-boot variables. These do not exist after successfull boot to OS.
41; Segment is always 0000h, same as BDA segment
42struc BOOTVARS
43                    resb    7C00h
44    .rgbAtaInfo:                    ; 7C00h, ATA Information for drive detection
45    .rgbBootSect    resb    512     ; 7C00h, Boot sector
46                    resb    256     ; Boot Menu stack
47    .rgbMnuStack:
48    .dwPostStack    resb    4       ; POST stack pointer when entering INT 19h
49    .rgBootNfo:                     ; Array containing BOOTNFO structs
50endstruc
51
52
53;--------------------------------------------------------------------
54; Stores POST stack pointer to BOOTVARS.
55;
56; STORE_POST_STACK_POINTER
57;   Parameters:
58;       DS:     BDA and Interrupt Vector segment (zero)
59;   Returns:
60;       Nothing
61;   Corrupts registers:
62;       Nothing
63;--------------------------------------------------------------------
64%macro STORE_POST_STACK_POINTER 0
65    mov     [BOOTVARS.dwPostStack], sp
66    mov     [BOOTVARS.dwPostStack+2], ss
67%endmacro
68
69
70;--------------------------------------------------------------------
71; Initializes stack for boot menu usage.
72; POST stack is not large enough when DPTs are stored to 30:0h.
73;
74; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
75; then you also have to unconditionally enable the CLI/STI pair.
76; The reason for this is that only some buggy 808x CPU:s need the
77; CLI/STI instruction pair when changing stacks. Other CPU:s disable
78; interrupts automatically when SS is modified for the duration of
79; the immediately following instruction to give time to change SP.
80;
81; SWITCH_TO_BOOT_MENU_STACK
82;   Parameters:
83;       Nothing
84;   Returns:
85;       SS:SP:  Pointer to top of Boot Menu stack
86;   Corrupts registers:
87;       Nothing
88;--------------------------------------------------------------------
89%macro SWITCH_TO_BOOT_MENU_STACK 0
90%ifndef USE_186
91    cli                                 ; Disable interrupts
92%endif
93    LOAD_BDA_SEGMENT_TO ss, sp
94    mov     sp, BOOTVARS.rgbMnuStack    ; Load offset to stack
95%ifndef USE_186
96    sti                                 ; Enable interrupts
97%endif
98%endmacro
99
100
101;--------------------------------------------------------------------
102; Restores SS and SP to initial boot loader values.
103;
104; Before doing any changes, see the note regarding
105; LOAD_BDA_SEGMENT_TO in BootVars_SwitchToBootMenuStack
106;
107; SWITCH_BACK_TO_POST_STACK
108;   Parameters:
109;       Nothing
110;   Returns:
111;       SS:SP:  Ptr to POST stack
112;   Corrupts registers:
113;       Nothing
114;--------------------------------------------------------------------
115%macro SWITCH_BACK_TO_POST_STACK 0
116%ifndef USE_386
117    cli                                 ; Disable interrupts
118    LOAD_BDA_SEGMENT_TO ss, sp
119    mov     sp, [ss:BOOTVARS.dwPostStack]
120    mov     ss, [ss:BOOTVARS.dwPostStack+2]
121    sti                                 ; Enable interrupts
122%else
123    LOAD_BDA_SEGMENT_TO ss, sp
124    lss     sp, [ss:BOOTVARS.dwPostStack]
125%endif
126%endmacro
127
128
129%endif ; BOOTVARS_INC
Note: See TracBrowser for help on using the repository browser.