1 | ; $Id: bootsector2-common-routines.mac 96407 2022-08-22 17:43:14Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; Common bootsector routines.
|
---|
4 | ;
|
---|
5 | ; This is just a bit file with common code that can be included at the end of
|
---|
6 | ; a bootsector2-xxx.asm file. Conventions (used elsewhere as well):
|
---|
7 | ; - _rm - real-mode function suffix.
|
---|
8 | ; - _r86 - common real and virtual 8086 mode suffix.
|
---|
9 | ; - _p16 - common 16-bit protected mode suffix.
|
---|
10 | ; - _p32 - common 32-bit protected mode suffix.
|
---|
11 | ; - _p64 - common 64-bit long mode suffix.
|
---|
12 | ; - _pe16 - 16-bit unpaged protected mode suffix.
|
---|
13 | ; - _pe32 - 32-bit unpaged protected mode suffix.
|
---|
14 | ; - _pev86 - v8086 unpaged protected mode suffix.
|
---|
15 | ; - _pp16 - 16-bit paged protected mode suffix.
|
---|
16 | ; - _pp32 - 32-bit paged protected mode suffix.
|
---|
17 | ; - _ppv86 - v8086 paged protected mode suffix.
|
---|
18 | ; - _pae16 - 16-bit pae protected mode suffix.
|
---|
19 | ; - _pae32 - 32-bit pae protected mode suffix.
|
---|
20 | ; - _paev86- v8086 pae protected mode suffix.
|
---|
21 | ; - _lm16 - 16-bit long mode suffix.
|
---|
22 | ; - _lm32 - 32-bit long mode suffix.
|
---|
23 | ; - _lm64 - 64-bit long mode suffix.
|
---|
24 | ;
|
---|
25 | ; The routines uses a custom register based calling convention for all cpu
|
---|
26 | ; modes so that the users can template multi mode code. To make life easy for
|
---|
27 | ; the programmer all registers are preserved with the exception of rflags and
|
---|
28 | ; any return registers that may be used. Routines that does not return
|
---|
29 | ; anything will only clobber eflags.
|
---|
30 | ;
|
---|
31 | ; The parameter register allocation order:
|
---|
32 | ; rax, rdx, rcx, rbx, rsi, rdi(, r8, r9, r10, r11)
|
---|
33 | ;
|
---|
34 | ; When pointers are passed by 16-bit code, segments registers are allocated in
|
---|
35 | ; the following order:
|
---|
36 | ; ds, es, fs, gs.
|
---|
37 | ;
|
---|
38 | ; The return register allocations are:
|
---|
39 | ; - edx:eax for 64-bit values in 16 and 32-bit mode,
|
---|
40 | ; - eax for 32-bit,
|
---|
41 | ; - ax for 16-bit,
|
---|
42 | ; - al for 8-bit.
|
---|
43 | ;
|
---|
44 | ; Routines may use other calling convensions will be named differently.
|
---|
45 | ;
|
---|
46 |
|
---|
47 | ;
|
---|
48 | ; Copyright (C) 2007-2022 Oracle and/or its affiliates.
|
---|
49 | ;
|
---|
50 | ; This file is part of VirtualBox base platform packages, as
|
---|
51 | ; available from https://www.virtualbox.org.
|
---|
52 | ;
|
---|
53 | ; This program is free software; you can redistribute it and/or
|
---|
54 | ; modify it under the terms of the GNU General Public License
|
---|
55 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
56 | ; License.
|
---|
57 | ;
|
---|
58 | ; This program is distributed in the hope that it will be useful, but
|
---|
59 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
60 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
61 | ; General Public License for more details.
|
---|
62 | ;
|
---|
63 | ; You should have received a copy of the GNU General Public License
|
---|
64 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
65 | ;
|
---|
66 | ; The contents of this file may alternatively be used under the terms
|
---|
67 | ; of the Common Development and Distribution License Version 1.0
|
---|
68 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
69 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
70 | ; CDDL are applicable instead of those of the GPL.
|
---|
71 | ;
|
---|
72 | ; You may elect to license modified versions of this file under the
|
---|
73 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
74 | ;
|
---|
75 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
76 | ;
|
---|
77 |
|
---|
78 |
|
---|
79 | ;*******************************************************************************
|
---|
80 | ;* Structures and Typedefs *
|
---|
81 | ;*******************************************************************************
|
---|
82 |
|
---|
83 |
|
---|
84 | ;*******************************************************************************
|
---|
85 | ;* Global Variables *
|
---|
86 | ;*******************************************************************************
|
---|
87 | BEGINCODELOW
|
---|
88 | ALIGNDATA(32)
|
---|
89 | ;; Indicates whether the VMMDev is operational.
|
---|
90 | GLOBALNAME g_fbBs2VMMDevTesting
|
---|
91 | db 1
|
---|
92 | db 0 ; padding
|
---|
93 |
|
---|
94 | ;; The test name (DS16:xxx).
|
---|
95 | g_npszBs2Test:
|
---|
96 | dd 0
|
---|
97 | ;; The number of tests that have failed.
|
---|
98 | g_uscBs2TestErrors:
|
---|
99 | dw 0
|
---|
100 | ;; The subtest name (DS16:xxx).
|
---|
101 | g_npszBs2SubTest
|
---|
102 | dd 0
|
---|
103 | ;; The start error count of the current subtest.
|
---|
104 | g_uscBs2SubTestAtErrors:
|
---|
105 | dw 0
|
---|
106 | ;; Whether we've reported the sub-test result or not.
|
---|
107 | g_fbBs2SubTestReported:
|
---|
108 | db 0
|
---|
109 | db 0 ; padding
|
---|
110 | ;; The number of sub tests.
|
---|
111 | g_uscBs2SubTests:
|
---|
112 | dw 0
|
---|
113 | ;; The number of sub tests that failed.
|
---|
114 | g_uscBs2SubTestsFailed:
|
---|
115 | dw 0
|
---|
116 |
|
---|
117 |
|
---|
118 | ;; VMMDEV_TESTING_UNIT_XXX -> string
|
---|
119 | g_aszBs2TestUnitNames:
|
---|
120 | db 'i','n','v', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
121 | db '%', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
122 | db 'b','y','t','e','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
123 | db 'b','y','t','e','s','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
124 | db 'K','B', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
125 | db 'K','B','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
126 | db 'M','B', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
127 | db 'M','B','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
128 | db 'p','a','c','k','e','t','s', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
129 | db 'p','a','c','k','e','t','s','/','s', 0, 0, 0, 0, 0, 0, 0
|
---|
130 | db 'f','r','a','m','e','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
131 | db 'f','r','a','m','e','s','/', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
132 | db 'o','c','c', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
133 | db 'o','c','c','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
134 | db 'r','n','d','t','r','p', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
135 | db 'c','a','l','l','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
136 | db 'c','a','l','l','s','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
137 | db 's', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
138 | db 'm','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
139 | db 'n','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
140 | db 'n','s','/','c','a','l','l', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
141 | db 'n','s','/','f','r','a','m','e', 0, 0, 0, 0, 0, 0, 0, 0
|
---|
142 | db 'n','s','/','o','c','c', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
143 | db 'n','s','/','p','a','c','k','e','t', 0, 0, 0, 0, 0, 0, 0
|
---|
144 | db 'n','s','/','r','n','d','t','r','p', 0, 0, 0, 0, 0, 0, 0
|
---|
145 | db 'i','n','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
146 | db 'i','n','s','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
147 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; none
|
---|
148 | db 'p','p','1','k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
149 | db 'p','p','1','0','k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
150 | db 'p','p','m', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
151 | db 'p','p','b', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
152 | db 't','i','c','k','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
153 | db 't','i','c','k','s','/','c','a','l','l', 0, 0, 0, 0, 0, 0
|
---|
154 | db 't','i','c','k','s','/','o','c','c', 0, 0, 0, 0, 0, 0, 0
|
---|
155 | db 'p','a','g','e','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
156 | db 'p','a','g','e','s','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
157 | db 't','i','c','k','s','/','p','a','g','e', 0, 0, 0, 0, 0, 0
|
---|
158 | db 'n','s','/','p','a','g','e', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
159 | db 'p','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
160 | db 'p','s','/','c','a','l','l', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
161 | db 'p','s','/','f','r','a','m','e', 0, 0, 0, 0, 0, 0, 0, 0
|
---|
162 | db 'p','s','/','o','c','c', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
163 | db 'p','s','/','p','a','c','k','e','t', 0, 0, 0, 0, 0, 0, 0
|
---|
164 | db 'p','s','/','r','n','d','t','r','p', 0, 0, 0, 0, 0, 0, 0
|
---|
165 | db 'p','s','/','p','a','g','e', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
166 | ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f
|
---|
167 |
|
---|
168 |
|
---|
169 | ;
|
---|
170 | ; Instantiate the common template code.
|
---|
171 | ;
|
---|
172 | %ifdef BS2_INC_CMN_R86
|
---|
173 | %define TMPL_RM
|
---|
174 | %include "bootsector2-common-routines-template-1.mac"
|
---|
175 | %endif
|
---|
176 | %ifdef BS2_INC_CMN_P16
|
---|
177 | %define TMPL_PE16
|
---|
178 | %include "bootsector2-common-routines-template-1.mac"
|
---|
179 | %endif
|
---|
180 | %ifdef BS2_INC_CMN_P32
|
---|
181 | %define TMPL_PE32
|
---|
182 | %include "bootsector2-common-routines-template-1.mac"
|
---|
183 | %endif
|
---|
184 | %ifdef BS2_INC_LM64
|
---|
185 | %define TMPL_LM64
|
---|
186 | %include "bootsector2-common-routines-template-1.mac"
|
---|
187 | %endif
|
---|
188 |
|
---|
189 | ;
|
---|
190 | ; Instantiate the mode specific code.
|
---|
191 | ;
|
---|
192 | %ifdef BS2_INC_RM
|
---|
193 | %define TMPL_RM
|
---|
194 | %include "bootsector2-common-routines-template-2.mac"
|
---|
195 | %endif
|
---|
196 | %ifdef BS2_INC_PE16
|
---|
197 | %define TMPL_PE16
|
---|
198 | %include "bootsector2-common-routines-template-2.mac"
|
---|
199 | %endif
|
---|
200 | %ifdef BS2_INC_PE32
|
---|
201 | %define TMPL_PE32
|
---|
202 | %include "bootsector2-common-routines-template-2.mac"
|
---|
203 | %endif
|
---|
204 | %ifdef BS2_INC_PEV86
|
---|
205 | %define TMPL_PEV86
|
---|
206 | %include "bootsector2-common-routines-template-2.mac"
|
---|
207 | %endif
|
---|
208 | %ifdef BS2_INC_PP16
|
---|
209 | %define TMPL_PP16
|
---|
210 | %include "bootsector2-common-routines-template-2.mac"
|
---|
211 | %endif
|
---|
212 | %ifdef BS2_INC_PP32
|
---|
213 | %define TMPL_PP32
|
---|
214 | %include "bootsector2-common-routines-template-2.mac"
|
---|
215 | %endif
|
---|
216 | %ifdef BS2_INC_PPV86
|
---|
217 | %define TMPL_PPV86
|
---|
218 | %include "bootsector2-common-routines-template-2.mac"
|
---|
219 | %endif
|
---|
220 | %ifdef BS2_INC_PAE16
|
---|
221 | %define TMPL_PAE16
|
---|
222 | %include "bootsector2-common-routines-template-2.mac"
|
---|
223 | %endif
|
---|
224 | %ifdef BS2_INC_PAE32
|
---|
225 | %define TMPL_PAE32
|
---|
226 | %include "bootsector2-common-routines-template-2.mac"
|
---|
227 | %endif
|
---|
228 | %ifdef BS2_INC_PAEV86
|
---|
229 | %define TMPL_PAEV86
|
---|
230 | %include "bootsector2-common-routines-template-2.mac"
|
---|
231 | %endif
|
---|
232 | %ifdef BS2_INC_LM16
|
---|
233 | %define TMPL_LM16
|
---|
234 | %include "bootsector2-common-routines-template-2.mac"
|
---|
235 | %endif
|
---|
236 | %ifdef BS2_INC_LM32
|
---|
237 | %define TMPL_LM32
|
---|
238 | %include "bootsector2-common-routines-template-2.mac"
|
---|
239 | %endif
|
---|
240 | %ifdef BS2_INC_LM64
|
---|
241 | %define TMPL_LM64
|
---|
242 | %include "bootsector2-common-routines-template-2.mac"
|
---|
243 | %endif
|
---|
244 |
|
---|
245 | BEGINCODELOW
|
---|
246 |
|
---|