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 | |
---|
25 | BOOT_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 |
---|
31 | struc 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 | .rgBootNfo: ; Array containing BOOTNFO structs |
---|
39 | endstruc |
---|
40 | |
---|
41 | |
---|
42 | ;-------------------------------------------------------------------- |
---|
43 | ; Stores POST stack pointer to BOOTVARS. |
---|
44 | ; |
---|
45 | ; STORE_POST_STACK_POINTER |
---|
46 | ; Parameters: |
---|
47 | ; ES: BDA and Interrupt Vector segment (zero) |
---|
48 | ; Returns: |
---|
49 | ; Nothing |
---|
50 | ; Corrupts registers: |
---|
51 | ; Nothing |
---|
52 | ;-------------------------------------------------------------------- |
---|
53 | %macro STORE_POST_STACK_POINTER 0 |
---|
54 | mov [es:BOOTVARS.dwPostStack], sp |
---|
55 | mov [es:BOOTVARS.dwPostStack+2], ss |
---|
56 | %endmacro |
---|
57 | |
---|
58 | |
---|
59 | ;-------------------------------------------------------------------- |
---|
60 | ; Initializes stack for boot menu usage. |
---|
61 | ; POST stack is not large enough when DPTs are stored to 30:0h. |
---|
62 | ; |
---|
63 | ; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP |
---|
64 | ; then you also have to unconditionally enable the CLI/STI pair. |
---|
65 | ; The reason for this is that only some buggy 808x CPU:s need the |
---|
66 | ; CLI/STI instruction pair when changing stacks. Other CPU:s disable |
---|
67 | ; interrupts automatically when SS is modified for the duration of |
---|
68 | ; the immediately following instruction to give time to change SP. |
---|
69 | ; |
---|
70 | ; SWITCH_TO_BOOT_MENU_STACK |
---|
71 | ; Parameters: |
---|
72 | ; Nothing |
---|
73 | ; Returns: |
---|
74 | ; SS:SP: Pointer to top of Boot Menu stack |
---|
75 | ; Corrupts registers: |
---|
76 | ; Nothing |
---|
77 | ;-------------------------------------------------------------------- |
---|
78 | %macro SWITCH_TO_BOOT_MENU_STACK 0 |
---|
79 | %ifndef USE_186 |
---|
80 | cli ; Disable interrupts |
---|
81 | %endif |
---|
82 | LOAD_BDA_SEGMENT_TO ss, sp |
---|
83 | mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack |
---|
84 | %ifndef USE_186 |
---|
85 | sti ; Enable interrupts |
---|
86 | %endif |
---|
87 | %endmacro |
---|
88 | |
---|
89 | |
---|
90 | ;-------------------------------------------------------------------- |
---|
91 | ; Restores SS and SP to initial boot loader values. |
---|
92 | ; |
---|
93 | ; Note! Must return with AX=0 and CF preserved. |
---|
94 | ; See Int19hMenu_JumpToBootSector_or_RomBoot. |
---|
95 | ; |
---|
96 | ; SWITCH_BACK_TO_POST_STACK |
---|
97 | ; Parameters: |
---|
98 | ; AX: BDA and Interrupt Vector segment (zero) |
---|
99 | ; Returns: |
---|
100 | ; SS:SP: Ptr to POST stack |
---|
101 | ; Corrupts registers: |
---|
102 | ; Nothing (not even FLAGS) |
---|
103 | ;-------------------------------------------------------------------- |
---|
104 | %macro SWITCH_BACK_TO_POST_STACK 0 |
---|
105 | %ifndef USE_386 |
---|
106 | cli |
---|
107 | mov ss, ax |
---|
108 | mov sp, [ss:BOOTVARS.dwPostStack] |
---|
109 | mov ss, [ss:BOOTVARS.dwPostStack+2] |
---|
110 | sti |
---|
111 | %else |
---|
112 | mov ss, ax |
---|
113 | lss sp, [ss:BOOTVARS.dwPostStack] |
---|
114 | %endif |
---|
115 | %endmacro |
---|
116 | |
---|
117 | |
---|
118 | %endif ; BOOTVARS_INC |
---|