1 | ; $Id: bs3-first-common.mac 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - First Object, common stuff.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2024 Oracle and/or its affiliates.
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox base platform packages, as
|
---|
10 | ; available from https://www.virtualbox.org.
|
---|
11 | ;
|
---|
12 | ; This program is free software; you can redistribute it and/or
|
---|
13 | ; modify it under the terms of the GNU General Public License
|
---|
14 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
15 | ; License.
|
---|
16 | ;
|
---|
17 | ; This program is distributed in the hope that it will be useful, but
|
---|
18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | ; General Public License for more details.
|
---|
21 | ;
|
---|
22 | ; You should have received a copy of the GNU General Public License
|
---|
23 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | ;
|
---|
25 | ; The contents of this file may alternatively be used under the terms
|
---|
26 | ; of the Common Development and Distribution License Version 1.0
|
---|
27 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | ; CDDL are applicable instead of those of the GPL.
|
---|
30 | ;
|
---|
31 | ; You may elect to license modified versions of this file under the
|
---|
32 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | ;
|
---|
34 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | ;
|
---|
36 |
|
---|
37 |
|
---|
38 | %define BS3_BEGIN_TEXT16_WITHOUT_GROUP
|
---|
39 | %define BS3_BEGIN_DATA16_WITHOUT_GROUP
|
---|
40 | %define BS3_BEGIN_RMTEXT16_WITHOUT_GROUP
|
---|
41 | %define BS3_BEGIN_X0TEXT16_WITHOUT_GROUP
|
---|
42 | %define BS3_BEGIN_X1TEXT16_WITHOUT_GROUP
|
---|
43 |
|
---|
44 | %include "bs3kit.mac"
|
---|
45 |
|
---|
46 |
|
---|
47 | ;
|
---|
48 | ;
|
---|
49 | ; Define all the segments and their grouping, just to get that right once at
|
---|
50 | ; the start of everything.
|
---|
51 | ;
|
---|
52 | ;
|
---|
53 |
|
---|
54 |
|
---|
55 | ; 0x86a00
|
---|
56 | ; 16-bit text 442368 = 0x6C000 (442368)
|
---|
57 | ;
|
---|
58 | %ifndef BS3_IS_DOS_EXE
|
---|
59 | BS3_BEGIN_TEXT16
|
---|
60 | %else
|
---|
61 | section BEGTEXT align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
62 | BS3_BEGIN_TEXT16
|
---|
63 | section BEGTEXT
|
---|
64 | %endif
|
---|
65 | BS3_GLOBAL_DATA Bs3Text16_StartOfSegment, 0
|
---|
66 |
|
---|
67 | ; Entry point with eye-catcher.
|
---|
68 | GLOBALNAME start
|
---|
69 | global __ImageBase ; for MS compiler - must be first!
|
---|
70 | __ImageBase:
|
---|
71 | global ___begtext ; for DOS EXEs (causes harmless duplicate symbol warning)
|
---|
72 | ___begtext:
|
---|
73 | %ifndef BS3_IS_DOS_EXE
|
---|
74 | jmp .after_eye_catcher
|
---|
75 | %else
|
---|
76 | int3
|
---|
77 | jmp __ImageBase
|
---|
78 | %endif
|
---|
79 | db 10,13,'eye-catcher: BS3TEXT16',10,13
|
---|
80 | BS3_BEGIN_TEXT16
|
---|
81 | .after_eye_catcher:
|
---|
82 |
|
---|
83 | section _TEXT align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
84 | section BS3TEXT16_NEARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
85 | section BS3TEXT16_FARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
86 | section BS3TEXT16_END align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
87 |
|
---|
88 | BS3_GLOBAL_DATA Bs3Text16_EndOfSegment, 0
|
---|
89 |
|
---|
90 | %ifndef BS3_IS_DOS_EXE
|
---|
91 | GROUP CGROUP16 BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
|
---|
92 | %else
|
---|
93 | GROUP CGROUP16 BEGTEXT BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
|
---|
94 | %endif
|
---|
95 |
|
---|
96 |
|
---|
97 | ;
|
---|
98 | ; 16-bit data
|
---|
99 | ;
|
---|
100 | BS3_BEGIN_DATA16
|
---|
101 | BS3_GLOBAL_DATA Bs3Data16_StartOfSegment, 0
|
---|
102 | db 10,13,'eye-catcher: BS3DATA16',10,13
|
---|
103 |
|
---|
104 | ALIGNDATA(16)
|
---|
105 | BS3_GLOBAL_DATA Bs3Data16_Size, 4
|
---|
106 | dd BS3_DATA_NM(Bs3Data16_EndOfSegment) wrt BS3KIT_GRPNM_DATA16
|
---|
107 | BS3_GLOBAL_DATA Bs3Data16Thru64Text32And64_TotalSize, 4
|
---|
108 | dd BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3KIT_GRPNM_DATA16
|
---|
109 | BS3_GLOBAL_DATA Bs3TotalImageSize, 4
|
---|
110 | dd BS3_DATA_NM(Bs3Text64_EndOfSegment) wrt CGROUP16 ; ASSUMES TEXT64 is last.
|
---|
111 |
|
---|
112 | BS3_GLOBAL_DATA Bs3Text16_Size, 2
|
---|
113 | dw BS3_DATA_NM(Bs3Text16_EndOfSegment) wrt CGROUP16
|
---|
114 | %ifndef BS3_IS_HIGH_IMAGE
|
---|
115 | BS3_GLOBAL_DATA Bs3RmText16_Size, 2
|
---|
116 | dw BS3_DATA_NM(Bs3RmText16_EndOfSegment) wrt BS3GROUPRMTEXT16
|
---|
117 | %endif ; !BS3_IS_HIGH_IMAGE
|
---|
118 | BS3_GLOBAL_DATA Bs3X0Text16_Size, 2
|
---|
119 | dw BS3_DATA_NM(Bs3X0Text16_EndOfSegment) wrt BS3GROUPX0TEXT16
|
---|
120 | BS3_GLOBAL_DATA Bs3X1Text16_Size, 2
|
---|
121 | dw BS3_DATA_NM(Bs3X1Text16_EndOfSegment) wrt BS3GROUPX1TEXT16
|
---|
122 |
|
---|
123 | %ifndef BS3_IS_HIGH_IMAGE
|
---|
124 | BS3_GLOBAL_DATA Bs3RmText16_FlatAddr, 4
|
---|
125 | dd BS3_DATA_NM(Bs3RmText16_StartOfSegment) wrt BS3FLAT
|
---|
126 | %endif ; !BS3_IS_HIGH_IMAGE
|
---|
127 | BS3_GLOBAL_DATA Bs3X0Text16_FlatAddr, 4
|
---|
128 | dd BS3_DATA_NM(Bs3X0Text16_StartOfSegment) wrt BS3FLAT
|
---|
129 | BS3_GLOBAL_DATA Bs3X1Text16_FlatAddr, 4
|
---|
130 | dd BS3_DATA_NM(Bs3X1Text16_StartOfSegment) wrt BS3FLAT
|
---|
131 |
|
---|
132 | section BS3DATA16CONST align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
|
---|
133 | section BS3DATA16CONST2 align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
|
---|
134 | section BS3DATA16_DATA align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
|
---|
135 | %ifdef BS3_IS_DOS_EXE
|
---|
136 | section _NULL align=16 CLASS=BEGDATA PUBLIC USE16
|
---|
137 | section _AFTERNULL align=2 CLASS=BEGDATA PUBLIC USE16
|
---|
138 | %endif
|
---|
139 | section CONST align=2 CLASS=DATA PUBLIC USE16
|
---|
140 | section CONST2 align=2 CLASS=DATA PUBLIC USE16
|
---|
141 | section _DATA align=2 CLASS=DATA PUBLIC USE16
|
---|
142 | %ifdef BS3_IS_DOS_EXE
|
---|
143 | section XIB align=1 CLASS=DATA PUBLIC USE16
|
---|
144 | section XI align=1 CLASS=DATA PUBLIC USE16
|
---|
145 | section XIE align=1 CLASS=DATA PUBLIC USE16
|
---|
146 | section YIB align=1 CLASS=DATA PUBLIC USE16
|
---|
147 | section YI align=1 CLASS=DATA PUBLIC USE16
|
---|
148 | section YIE align=1 CLASS=DATA PUBLIC USE16
|
---|
149 | %endif
|
---|
150 | section STRINGS align=2 CLASS=DATA PUBLIC USE16
|
---|
151 | section DATA align=2 CLASS=DATA PUBLIC USE16
|
---|
152 | section _BSS align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
|
---|
153 | section BSS align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
|
---|
154 | %ifdef BS3_IS_DOS_EXE
|
---|
155 | section STACK align=16 CLASS=STACK STACK USE16
|
---|
156 | %endif
|
---|
157 | section BS3DATA16_END align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
|
---|
158 |
|
---|
159 | BS3_GLOBAL_DATA Bs3Data16_EndOfSegment, 0
|
---|
160 |
|
---|
161 | %ifndef BS3_IS_DOS_EXE
|
---|
162 | GROUP BS3KIT_GRPNM_DATA16 BS3DATA16 BS3DATA16_DATA _DATA DATA BS3DATA16CONST CONST BS3DATA16CONST2 CONST2 STRINGS _BSS BSS BS3DATA16_END
|
---|
163 | %else
|
---|
164 | GROUP BS3KIT_GRPNM_DATA16 \
|
---|
165 | _NULL _AFTERNULL \
|
---|
166 | CONST BS3DATA16CONST CONST2 BS3DATA16CONST2 _DATA XIB XI XIE YIB YI YIE STRINGS DATA BS3DATA16 BS3DATA16_DATA \
|
---|
167 | _BSS BSS BS3DATA16_END \
|
---|
168 | STACK
|
---|
169 | %endif
|
---|
170 |
|
---|
171 | %ifndef BS3_IS_HIGH_IMAGE
|
---|
172 | ;
|
---|
173 | ; 16-bit real-mode text
|
---|
174 | ;
|
---|
175 | section BS3RMTEXT16_START align=16 CLASS=BS3CLASS16RMCODE PUBLIC USE16
|
---|
176 | BS3_GLOBAL_DATA Bs3RmText16_StartOfSegment, 0
|
---|
177 | ;db 10,13,'eye-catcher: BS3RMTEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
|
---|
178 | BS3_BEGIN_RMTEXT16
|
---|
179 | section BS3RMTEXT16_END align=1 CLASS=BS3CLASS16RMCODE PUBLIC USE16
|
---|
180 | BS3_GLOBAL_DATA Bs3RmText16_EndOfSegment, 0
|
---|
181 | GROUP BS3GROUPRMTEXT16 BS3RMTEXT16_START BS3RMTEXT16 BS3RMTEXT16_END
|
---|
182 | %endif ; !BS3_IS_HIGH_IMAGE
|
---|
183 |
|
---|
184 | ;
|
---|
185 | ; 16-bit extra text segment #0.
|
---|
186 | ;
|
---|
187 | section BS3X0TEXT16_START align=16 CLASS=BS3CLASS16X0CODE PUBLIC USE16
|
---|
188 | BS3_GLOBAL_DATA Bs3X0Text16_StartOfSegment, 0
|
---|
189 | ;db 10,13,'eye-catcher: BS3X0TEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
|
---|
190 | BS3_BEGIN_X0TEXT16 4
|
---|
191 | section BS3X0TEXT16_END align=1 CLASS=BS3CLASS16X0CODE PUBLIC USE16
|
---|
192 | BS3_GLOBAL_DATA Bs3X0Text16_EndOfSegment, 0
|
---|
193 | GROUP BS3GROUPX0TEXT16 BS3X0TEXT16_START BS3X0TEXT16 BS3X0TEXT16_END
|
---|
194 |
|
---|
195 |
|
---|
196 | ;
|
---|
197 | ; 16-bit extra text segment #1.
|
---|
198 | ;
|
---|
199 | section BS3X1TEXT16_START align=16 CLASS=BS3CLASS16X1CODE PUBLIC USE16
|
---|
200 | BS3_GLOBAL_DATA Bs3X1Text16_StartOfSegment, 0
|
---|
201 | ;db 10,13,'eye-catcher: BS3X1TEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
|
---|
202 | BS3_BEGIN_X1TEXT16 4
|
---|
203 | BS3_GLOBAL_DATA Bs3X1Text16_EndOfSegment, 0
|
---|
204 | section BS3X1TEXT16_END align=1 CLASS=BS3CLASS16X1CODE PUBLIC USE16
|
---|
205 | GROUP BS3GROUPX1TEXT16 BS3X1TEXT16_START BS3X1TEXT16 BS3X1TEXT16_END
|
---|
206 |
|
---|
207 | %ifndef BS3_IS_HIGH_IMAGE
|
---|
208 | ;
|
---|
209 | ; Separate the BS3X1TEXT16_END from BS3_BEGIN_TEXT32 to better help pinpoint
|
---|
210 | ; the rigth segment when getting an E2083 linker error.
|
---|
211 | ;
|
---|
212 | section BS3SEPARATE16AND32BITCODE align=16 CLASS=BS3CLASSSEPARATE16AND32BITCODE PUBLIC USE16
|
---|
213 | BS3_GLOBAL_DATA BS3SEPARATE16AND32BITCODE_StartOfSegment, 0
|
---|
214 | db 10,13,'eye-catcher: 16-32 wedge',10,13
|
---|
215 | BS3_GLOBAL_DATA BS3SEPARATE16AND32BITCODE_EndOfSegment, 0
|
---|
216 | GROUP BS3SEPARATE16AND32BITCODEGROUP BS3SEPARATE16AND32BITCODE
|
---|
217 | %endif ; !BS3_IS_HIGH_IMAGE
|
---|
218 |
|
---|
219 |
|
---|
220 | ;
|
---|
221 | ; 32-bit text
|
---|
222 | ;
|
---|
223 | BS3_BEGIN_TEXT32
|
---|
224 | BS3_GLOBAL_DATA Bs3Text32_StartOfSegment, 0
|
---|
225 | db 10,13,'eye-catcher: BS3TEXT32',10,13
|
---|
226 | section BS3TEXT32_END align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT
|
---|
227 | BS3_GLOBAL_DATA Bs3Text32_EndOfSegment, 0
|
---|
228 |
|
---|
229 |
|
---|
230 | %ifndef BS3_IS_HIGH_IMAGE
|
---|
231 | ;
|
---|
232 | ; This is a hack to separate the 32-bit and 64-bit text segments when linking,
|
---|
233 | ; such that they don't share the same base frame because they're both assigned
|
---|
234 | ; to the AUTO group by the linker.
|
---|
235 | ;
|
---|
236 | section BS3SEPARATE32AND64BITCODE align=16 CLASS=BS3CLASSSEPARATE32AND64BITCODE PUBLIC USE16
|
---|
237 | BS3_GLOBAL_DATA Bs3Separate32And64BitCode_StartOfSegment, 0
|
---|
238 | db 10,13,'eye-catcher: 32-64 wedge',10,13
|
---|
239 | BS3_GLOBAL_DATA Bs3Separate32And64BitCode_EndOfSegment, 0
|
---|
240 | GROUP BS3SEPARATE32AND64BITCODEGROUP BS3SEPARATE32AND64BITCODE
|
---|
241 | %endif ; !BS3_IS_HIGH_IMAGE
|
---|
242 |
|
---|
243 |
|
---|
244 | ;
|
---|
245 | ; 64-bit text
|
---|
246 | ;
|
---|
247 | BS3_BEGIN_TEXT64
|
---|
248 | BS3_GLOBAL_DATA Bs3Text64_StartOfSegment, 0
|
---|
249 | db 10,13,'eye-catcher: BS3TEXT64',10,13
|
---|
250 | section BS3TEXT64_END align=1 CLASS=BS3CLASS64CODE PUBLIC USE32 FLAT
|
---|
251 | BS3_GLOBAL_DATA Bs3Text64_EndOfSegment, 0
|
---|
252 |
|
---|
253 |
|
---|
254 | ;
|
---|
255 | ; FAR_DATA segment in DOS EXEs should be near the other FAR_DATA class segments.
|
---|
256 | ;
|
---|
257 | %ifdef BS3_IS_DOS_EXE
|
---|
258 | section FAR_DATA align=1 CLASS=FAR_DATA PUBLIC USE16
|
---|
259 | %endif
|
---|
260 |
|
---|
261 | ;
|
---|
262 | ; 32-bit data
|
---|
263 | ;
|
---|
264 | BS3_BEGIN_DATA32
|
---|
265 | BS3_GLOBAL_DATA Bs3Data32_StartOfSegment, 0
|
---|
266 | db 10,13,'eye-catcher: BS3DATA32',10,13
|
---|
267 | section BS3DATA32CONST align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
268 | section BS3DATA32CONST2 align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
269 | section BS3DATA32_DATA align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
270 | section BS3DATA32_BSS align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
271 | section BS3DATA32_END align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
272 | BS3_GLOBAL_DATA Bs3Data32_EndOfSegment, 0
|
---|
273 | GROUP BS3DATA32_GROUP BS3DATA32 BS3DATA32_DATA BS3DATA32CONST BS3DATA32CONST2 BS3DATA32_BSS BS3DATA32_END
|
---|
274 |
|
---|
275 | ;
|
---|
276 | ; 64-bit data
|
---|
277 | ;
|
---|
278 | BS3_BEGIN_DATA64
|
---|
279 | BS3_GLOBAL_DATA Bs3Data64_StartOfSegment, 0
|
---|
280 | db 10,13,'eye-catcher: BS3DATA64',10,13
|
---|
281 | section BS3DATA64CONST align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
282 | section BS3DATA64_BSS align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
283 | section BS3DATA64_END align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
284 | BS3_GLOBAL_DATA Bs3Data64_EndOfSegment, 0
|
---|
285 | GROUP BS3DATA64_GROUP BS3DATA64 BS3DATA64CONST BS3DATA64_BSS BS3DATA64_END
|
---|
286 |
|
---|
287 |
|
---|
288 | %ifndef BS3_IS_HIGH_IMAGE
|
---|
289 | ;
|
---|
290 | ; The high dll table segment.
|
---|
291 | ;
|
---|
292 | section BS3HIGHDLLSEGMENTS align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
|
---|
293 | section BS3HIGHDLLEXPORTS align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT ;; @todo Consider moving this to DATA16...
|
---|
294 | section BS3HIGHDLLIMPORTS align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
|
---|
295 | section BS3HIGHDLLSTRINGS align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
|
---|
296 | section BS3HIGHDLLTABLE align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
|
---|
297 | BS3_GLOBAL_DATA g_aBs3HighDllTable, 0
|
---|
298 | section BS3HIGHDLLTABLE_END align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
|
---|
299 | BS3_GLOBAL_DATA g_Bs3HighDllTable_End, 0
|
---|
300 | GROUP BS3HIGHDLLGROUP BS3HIGHDLLSEGMENTS BS3HIGHDLLEXPORTS BS3HIGHDLLIMPORTS BS3HIGHDLLSTRINGS BS3HIGHDLLTABLE BS3HIGHDLLTABLE_END
|
---|
301 |
|
---|
302 | ;
|
---|
303 | ; 16-bit accessible system data.
|
---|
304 | ; No need to do anything here.
|
---|
305 | ;
|
---|
306 | BS3_BEGIN_SYSTEM16
|
---|
307 |
|
---|
308 |
|
---|
309 | ;
|
---|
310 | ; Switch back to the 16-bit code segment and the startup code.
|
---|
311 | ;
|
---|
312 | BS3_BEGIN_TEXT16
|
---|
313 | BS3_GLOBAL_NAME_EX Bs3KitEntryPoint, function, 0
|
---|
314 | %endif ; !BS3_IS_HIGH_IMAGE
|
---|
315 |
|
---|