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 |
|
---|
8 | BOOT_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.
|
---|
13 | LEN_BOOTNFO_DRV EQU 26 ; Bytes reserved for drive name
|
---|
14 | struc BOOTNFO
|
---|
15 | .twSectCnt resb 6 ; Total user addressable sectors
|
---|
16 | .szDrvName resb LEN_BOOTNFO_DRV+1 ; Drive name
|
---|
17 | resb 1 ; Alignment
|
---|
18 | endstruc
|
---|
19 |
|
---|
20 |
|
---|
21 | ; Pre-boot variables. These do not exist after successfull boot to OS.
|
---|
22 | ; Segment is always 0000h, same as BDA segment
|
---|
23 | struc BOOTVARS
|
---|
24 | resb 7C00h
|
---|
25 | .rgbAtaInfo: ; 7C00h, ATA Information for drive detection
|
---|
26 | .rgbBootSect resb 512 ; 7C00h, Boot sector
|
---|
27 | resb 256 ; Boot Menu stack
|
---|
28 | .rgbMnuStack:
|
---|
29 | .dwPostStack resb 4 ; POST stack pointer when entering INT 19h
|
---|
30 | .rgBootNfo: ; Array containing BOOTNFO structs
|
---|
31 | endstruc
|
---|
32 |
|
---|
33 |
|
---|
34 | ;--------------------------------------------------------------------
|
---|
35 | ; Stores POST stack pointer to BOOTVARS.
|
---|
36 | ;
|
---|
37 | ; STORE_POST_STACK_POINTER
|
---|
38 | ; Parameters:
|
---|
39 | ; DS: BDA and Interrupt Vector segment (zero)
|
---|
40 | ; Returns:
|
---|
41 | ; Nothing
|
---|
42 | ; Corrupts registers:
|
---|
43 | ; Nothing
|
---|
44 | ;--------------------------------------------------------------------
|
---|
45 | %macro STORE_POST_STACK_POINTER 0
|
---|
46 | mov [BOOTVARS.dwPostStack], sp
|
---|
47 | mov [BOOTVARS.dwPostStack+2], ss
|
---|
48 | %endmacro
|
---|
49 |
|
---|
50 |
|
---|
51 | ;--------------------------------------------------------------------
|
---|
52 | ; Initializes stack for boot menu usage.
|
---|
53 | ; POST stack is not large enough when DPTs are stored to 30:0h.
|
---|
54 | ;
|
---|
55 | ; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
|
---|
56 | ; then you also have to unconditionally enable the CLI/STI pair.
|
---|
57 | ; The reason for this is that only some buggy 808x CPU:s need the
|
---|
58 | ; CLI/STI instruction pair when changing stacks. Other CPU:s disable
|
---|
59 | ; interrupts automatically when SS is modified for the duration of
|
---|
60 | ; the immediately following instruction to give time to change SP.
|
---|
61 | ;
|
---|
62 | ; SWITCH_TO_BOOT_MENU_STACK
|
---|
63 | ; Parameters:
|
---|
64 | ; Nothing
|
---|
65 | ; Returns:
|
---|
66 | ; SS:SP: Pointer to top of Boot Menu stack
|
---|
67 | ; Corrupts registers:
|
---|
68 | ; Nothing
|
---|
69 | ;--------------------------------------------------------------------
|
---|
70 | %macro SWITCH_TO_BOOT_MENU_STACK 0
|
---|
71 | %ifndef USE_186
|
---|
72 | cli ; Disable interrupts
|
---|
73 | %endif
|
---|
74 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
75 | mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack
|
---|
76 | %ifndef USE_186
|
---|
77 | sti ; Enable interrupts
|
---|
78 | %endif
|
---|
79 | %endmacro
|
---|
80 |
|
---|
81 |
|
---|
82 | ;--------------------------------------------------------------------
|
---|
83 | ; Restores SS and SP to initial boot loader values.
|
---|
84 | ;
|
---|
85 | ; Before doing any changes, see the note regarding
|
---|
86 | ; LOAD_BDA_SEGMENT_TO in BootVars_SwitchToBootMenuStack
|
---|
87 | ;
|
---|
88 | ; SWITCH_BACK_TO_POST_STACK
|
---|
89 | ; Parameters:
|
---|
90 | ; Nothing
|
---|
91 | ; Returns:
|
---|
92 | ; SS:SP: Ptr to POST stack
|
---|
93 | ; Corrupts registers:
|
---|
94 | ; Nothing
|
---|
95 | ;--------------------------------------------------------------------
|
---|
96 | %macro SWITCH_BACK_TO_POST_STACK 0
|
---|
97 | %ifndef USE_386
|
---|
98 | cli ; Disable interrupts
|
---|
99 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
100 | mov sp, [ss:BOOTVARS.dwPostStack]
|
---|
101 | mov ss, [ss:BOOTVARS.dwPostStack+2]
|
---|
102 | sti ; Enable interrupts
|
---|
103 | %else
|
---|
104 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
105 | lss sp, [ss:BOOTVARS.dwPostStack]
|
---|
106 | %endif
|
---|
107 | %endmacro
|
---|
108 |
|
---|
109 |
|
---|
110 | %endif ; BOOTVARS_INC
|
---|