1 | ; $Id: bootsector2-common-routines.mac 93115 2022-01-01 11:31:46Z 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 Corporation
|
---|
49 | ;
|
---|
50 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
51 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
52 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
53 | ; General Public License (GPL) as published by the Free Software
|
---|
54 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
55 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
56 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
57 | ;
|
---|
58 | ; The contents of this file may alternatively be used under the terms
|
---|
59 | ; of the Common Development and Distribution License Version 1.0
|
---|
60 | ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
61 | ; VirtualBox OSE distribution, in which case the provisions of the
|
---|
62 | ; CDDL are applicable instead of those of the GPL.
|
---|
63 | ;
|
---|
64 | ; You may elect to license modified versions of this file under the
|
---|
65 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
66 | ;
|
---|
67 |
|
---|
68 |
|
---|
69 | ;*******************************************************************************
|
---|
70 | ;* Structures and Typedefs *
|
---|
71 | ;*******************************************************************************
|
---|
72 |
|
---|
73 |
|
---|
74 | ;*******************************************************************************
|
---|
75 | ;* Global Variables *
|
---|
76 | ;*******************************************************************************
|
---|
77 | BEGINCODELOW
|
---|
78 | ALIGNDATA(32)
|
---|
79 | ;; Indicates whether the VMMDev is operational.
|
---|
80 | GLOBALNAME g_fbBs2VMMDevTesting
|
---|
81 | db 1
|
---|
82 | db 0 ; padding
|
---|
83 |
|
---|
84 | ;; The test name (DS16:xxx).
|
---|
85 | g_npszBs2Test:
|
---|
86 | dd 0
|
---|
87 | ;; The number of tests that have failed.
|
---|
88 | g_uscBs2TestErrors:
|
---|
89 | dw 0
|
---|
90 | ;; The subtest name (DS16:xxx).
|
---|
91 | g_npszBs2SubTest
|
---|
92 | dd 0
|
---|
93 | ;; The start error count of the current subtest.
|
---|
94 | g_uscBs2SubTestAtErrors:
|
---|
95 | dw 0
|
---|
96 | ;; Whether we've reported the sub-test result or not.
|
---|
97 | g_fbBs2SubTestReported:
|
---|
98 | db 0
|
---|
99 | db 0 ; padding
|
---|
100 | ;; The number of sub tests.
|
---|
101 | g_uscBs2SubTests:
|
---|
102 | dw 0
|
---|
103 | ;; The number of sub tests that failed.
|
---|
104 | g_uscBs2SubTestsFailed:
|
---|
105 | dw 0
|
---|
106 |
|
---|
107 |
|
---|
108 | ;; VMMDEV_TESTING_UNIT_XXX -> string
|
---|
109 | g_aszBs2TestUnitNames:
|
---|
110 | db 'i','n','v', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
111 | db '%', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
112 | db 'b','y','t','e','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
113 | db 'b','y','t','e','s','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
114 | db 'K','B', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
115 | db 'K','B','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
116 | db 'M','B', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
117 | db 'M','B','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
118 | db 'p','a','c','k','e','t','s', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
119 | db 'p','a','c','k','e','t','s','/','s', 0, 0, 0, 0, 0, 0, 0
|
---|
120 | db 'f','r','a','m','e','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
121 | db 'f','r','a','m','e','s','/', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
122 | db 'o','c','c', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
123 | db 'o','c','c','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
124 | db 'r','n','d','t','r','p', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
125 | db 'c','a','l','l','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
126 | db 'c','a','l','l','s','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
127 | db 's', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
128 | db 'm','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
129 | db 'n','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
130 | db 'n','s','/','c','a','l','l', 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
131 | db 'n','s','/','f','r','a','m','e', 0, 0, 0, 0, 0, 0, 0, 0
|
---|
132 | db 'n','s','/','o','c','c', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
133 | db 'n','s','/','p','a','c','k','e','t', 0, 0, 0, 0, 0, 0, 0
|
---|
134 | db 'n','s','/','r','n','d','t','r','p', 0, 0, 0, 0, 0, 0, 0
|
---|
135 | db 'i','n','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
136 | db 'i','n','s','/','s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
137 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; none
|
---|
138 | db 'p','p','1','k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
139 | db 'p','p','1','0','k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
140 | db 'p','p','m', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
141 | db 'p','p','b', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
---|
142 | ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f
|
---|
143 |
|
---|
144 |
|
---|
145 | ;
|
---|
146 | ; Instantiate the common template code.
|
---|
147 | ;
|
---|
148 | %ifdef BS2_INC_CMN_R86
|
---|
149 | %define TMPL_RM
|
---|
150 | %include "bootsector2-common-routines-template-1.mac"
|
---|
151 | %endif
|
---|
152 | %ifdef BS2_INC_CMN_P16
|
---|
153 | %define TMPL_PE16
|
---|
154 | %include "bootsector2-common-routines-template-1.mac"
|
---|
155 | %endif
|
---|
156 | %ifdef BS2_INC_CMN_P32
|
---|
157 | %define TMPL_PE32
|
---|
158 | %include "bootsector2-common-routines-template-1.mac"
|
---|
159 | %endif
|
---|
160 | %ifdef BS2_INC_LM64
|
---|
161 | %define TMPL_LM64
|
---|
162 | %include "bootsector2-common-routines-template-1.mac"
|
---|
163 | %endif
|
---|
164 |
|
---|
165 | ;
|
---|
166 | ; Instantiate the mode specific code.
|
---|
167 | ;
|
---|
168 | %ifdef BS2_INC_RM
|
---|
169 | %define TMPL_RM
|
---|
170 | %include "bootsector2-common-routines-template-2.mac"
|
---|
171 | %endif
|
---|
172 | %ifdef BS2_INC_PE16
|
---|
173 | %define TMPL_PE16
|
---|
174 | %include "bootsector2-common-routines-template-2.mac"
|
---|
175 | %endif
|
---|
176 | %ifdef BS2_INC_PE32
|
---|
177 | %define TMPL_PE32
|
---|
178 | %include "bootsector2-common-routines-template-2.mac"
|
---|
179 | %endif
|
---|
180 | %ifdef BS2_INC_PEV86
|
---|
181 | %define TMPL_PEV86
|
---|
182 | %include "bootsector2-common-routines-template-2.mac"
|
---|
183 | %endif
|
---|
184 | %ifdef BS2_INC_PP16
|
---|
185 | %define TMPL_PP16
|
---|
186 | %include "bootsector2-common-routines-template-2.mac"
|
---|
187 | %endif
|
---|
188 | %ifdef BS2_INC_PP32
|
---|
189 | %define TMPL_PP32
|
---|
190 | %include "bootsector2-common-routines-template-2.mac"
|
---|
191 | %endif
|
---|
192 | %ifdef BS2_INC_PPV86
|
---|
193 | %define TMPL_PPV86
|
---|
194 | %include "bootsector2-common-routines-template-2.mac"
|
---|
195 | %endif
|
---|
196 | %ifdef BS2_INC_PAE16
|
---|
197 | %define TMPL_PAE16
|
---|
198 | %include "bootsector2-common-routines-template-2.mac"
|
---|
199 | %endif
|
---|
200 | %ifdef BS2_INC_PAE32
|
---|
201 | %define TMPL_PAE32
|
---|
202 | %include "bootsector2-common-routines-template-2.mac"
|
---|
203 | %endif
|
---|
204 | %ifdef BS2_INC_PAEV86
|
---|
205 | %define TMPL_PAEV86
|
---|
206 | %include "bootsector2-common-routines-template-2.mac"
|
---|
207 | %endif
|
---|
208 | %ifdef BS2_INC_LM16
|
---|
209 | %define TMPL_LM16
|
---|
210 | %include "bootsector2-common-routines-template-2.mac"
|
---|
211 | %endif
|
---|
212 | %ifdef BS2_INC_LM32
|
---|
213 | %define TMPL_LM32
|
---|
214 | %include "bootsector2-common-routines-template-2.mac"
|
---|
215 | %endif
|
---|
216 | %ifdef BS2_INC_LM64
|
---|
217 | %define TMPL_LM64
|
---|
218 | %include "bootsector2-common-routines-template-2.mac"
|
---|
219 | %endif
|
---|
220 |
|
---|
221 | BEGINCODELOW
|
---|
222 |
|
---|