1 | ; $Id: bs3-first-common.mac 102127 2023-11-16 22:39:49Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - First Object, common stuff.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2023 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 | ; 16-bit text
|
---|
56 | ;
|
---|
57 | %ifndef BS3_IS_DOS_EXE
|
---|
58 | BS3_BEGIN_TEXT16
|
---|
59 | %else
|
---|
60 | section BEGTEXT align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
61 | BS3_BEGIN_TEXT16
|
---|
62 | section BEGTEXT
|
---|
63 | %endif
|
---|
64 | BS3_GLOBAL_DATA Bs3Text16_StartOfSegment, 0
|
---|
65 |
|
---|
66 | ; Entry point with eye-catcher.
|
---|
67 | GLOBALNAME start
|
---|
68 | global __ImageBase ; for MS compiler - must be first!
|
---|
69 | __ImageBase:
|
---|
70 | global ___begtext ; for DOS EXEs (causes harmless duplicate symbol warning)
|
---|
71 | ___begtext:
|
---|
72 | %ifndef BS3_IS_DOS_EXE
|
---|
73 | jmp .after_eye_catcher
|
---|
74 | %else
|
---|
75 | int3
|
---|
76 | jmp __ImageBase
|
---|
77 | %endif
|
---|
78 | db 10,13,'eye-catcher: BS3TEXT16',10,13
|
---|
79 | BS3_BEGIN_TEXT16
|
---|
80 | .after_eye_catcher:
|
---|
81 |
|
---|
82 | section _TEXT align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
83 | section BS3TEXT16_NEARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
84 | section BS3TEXT16_FARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
85 | section BS3TEXT16_END align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
|
---|
86 |
|
---|
87 | BS3_GLOBAL_DATA Bs3Text16_EndOfSegment, 0
|
---|
88 |
|
---|
89 | %ifndef BS3_IS_DOS_EXE
|
---|
90 | GROUP CGROUP16 BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
|
---|
91 | %else
|
---|
92 | GROUP CGROUP16 BEGTEXT BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
|
---|
93 | %endif
|
---|
94 |
|
---|
95 |
|
---|
96 | ;
|
---|
97 | ; 16-bit data
|
---|
98 | ;
|
---|
99 | BS3_BEGIN_DATA16
|
---|
100 | BS3_GLOBAL_DATA Bs3Data16_StartOfSegment, 0
|
---|
101 | db 10,13,'eye-catcher: BS3DATA16',10,13
|
---|
102 |
|
---|
103 | ALIGNDATA(16)
|
---|
104 | BS3_GLOBAL_DATA Bs3Data16_Size, 4
|
---|
105 | dd BS3_DATA_NM(Bs3Data16_EndOfSegment) wrt BS3KIT_GRPNM_DATA16
|
---|
106 | BS3_GLOBAL_DATA Bs3Data16Thru64Text32And64_TotalSize, 4
|
---|
107 | dd BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3KIT_GRPNM_DATA16
|
---|
108 | BS3_GLOBAL_DATA Bs3TotalImageSize, 4
|
---|
109 | dd BS3_DATA_NM(Bs3Text64_EndOfSegment) wrt CGROUP16 ; ASSUMES TEXT64 is last.
|
---|
110 |
|
---|
111 | BS3_GLOBAL_DATA Bs3Text16_Size, 2
|
---|
112 | dw BS3_DATA_NM(Bs3Text16_EndOfSegment) wrt CGROUP16
|
---|
113 | BS3_GLOBAL_DATA Bs3RmText16_Size, 2
|
---|
114 | dw BS3_DATA_NM(Bs3RmText16_EndOfSegment) wrt BS3GROUPRMTEXT16
|
---|
115 | BS3_GLOBAL_DATA Bs3X0Text16_Size, 2
|
---|
116 | dw BS3_DATA_NM(Bs3X0Text16_EndOfSegment) wrt BS3GROUPX0TEXT16
|
---|
117 | BS3_GLOBAL_DATA Bs3X1Text16_Size, 2
|
---|
118 | dw BS3_DATA_NM(Bs3X1Text16_EndOfSegment) wrt BS3GROUPX1TEXT16
|
---|
119 |
|
---|
120 | BS3_GLOBAL_DATA Bs3RmText16_FlatAddr, 4
|
---|
121 | dd BS3_DATA_NM(Bs3RmText16_StartOfSegment) wrt BS3FLAT
|
---|
122 | BS3_GLOBAL_DATA Bs3X0Text16_FlatAddr, 4
|
---|
123 | dd BS3_DATA_NM(Bs3X0Text16_StartOfSegment) wrt BS3FLAT
|
---|
124 | BS3_GLOBAL_DATA Bs3X1Text16_FlatAddr, 4
|
---|
125 | dd BS3_DATA_NM(Bs3X1Text16_StartOfSegment) wrt BS3FLAT
|
---|
126 |
|
---|
127 | section BS3DATA16CONST align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
|
---|
128 | section BS3DATA16CONST2 align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
|
---|
129 | section BS3DATA16_DATA align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
|
---|
130 | %ifdef BS3_IS_DOS_EXE
|
---|
131 | section _NULL align=16 CLASS=BEGDATA PUBLIC USE16
|
---|
132 | section _AFTERNULL align=2 CLASS=BEGDATA PUBLIC USE16
|
---|
133 | %endif
|
---|
134 | section CONST align=2 CLASS=DATA PUBLIC USE16
|
---|
135 | section CONST2 align=2 CLASS=DATA PUBLIC USE16
|
---|
136 | section _DATA align=2 CLASS=DATA PUBLIC USE16
|
---|
137 | %ifdef BS3_IS_DOS_EXE
|
---|
138 | section XIB align=1 CLASS=DATA PUBLIC USE16
|
---|
139 | section XI align=1 CLASS=DATA PUBLIC USE16
|
---|
140 | section XIE align=1 CLASS=DATA PUBLIC USE16
|
---|
141 | section YIB align=1 CLASS=DATA PUBLIC USE16
|
---|
142 | section YI align=1 CLASS=DATA PUBLIC USE16
|
---|
143 | section YIE align=1 CLASS=DATA PUBLIC USE16
|
---|
144 | %endif
|
---|
145 | section STRINGS align=2 CLASS=DATA PUBLIC USE16
|
---|
146 | section DATA align=2 CLASS=DATA PUBLIC USE16
|
---|
147 | section _BSS align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
|
---|
148 | section BSS align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
|
---|
149 | %ifdef BS3_IS_DOS_EXE
|
---|
150 | section STACK align=16 CLASS=STACK STACK USE16
|
---|
151 | %endif
|
---|
152 | section BS3DATA16_END align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
|
---|
153 |
|
---|
154 | BS3_GLOBAL_DATA Bs3Data16_EndOfSegment, 0
|
---|
155 |
|
---|
156 | %ifndef BS3_IS_DOS_EXE
|
---|
157 | GROUP BS3KIT_GRPNM_DATA16 BS3DATA16 BS3DATA16_DATA _DATA DATA BS3DATA16CONST CONST BS3DATA16CONST2 CONST2 STRINGS _BSS BSS BS3DATA16_END
|
---|
158 | %else
|
---|
159 | GROUP BS3KIT_GRPNM_DATA16 \
|
---|
160 | _NULL _AFTERNULL \
|
---|
161 | CONST BS3DATA16CONST CONST2 BS3DATA16CONST2 _DATA XIB XI XIE YIB YI YIE STRINGS DATA BS3DATA16 BS3DATA16_DATA \
|
---|
162 | _BSS BSS BS3DATA16_END \
|
---|
163 | STACK
|
---|
164 | %endif
|
---|
165 |
|
---|
166 | ;
|
---|
167 | ; 16-bit real-mode text
|
---|
168 | ;
|
---|
169 | section BS3RMTEXT16_START align=16 CLASS=BS3CLASS16RMCODE PUBLIC USE16
|
---|
170 | BS3_GLOBAL_DATA Bs3RmText16_StartOfSegment, 0
|
---|
171 | ;db 10,13,'eye-catcher: BS3RMTEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
|
---|
172 | BS3_BEGIN_RMTEXT16
|
---|
173 | section BS3RMTEXT16_END align=1 CLASS=BS3CLASS16RMCODE PUBLIC USE16
|
---|
174 | BS3_GLOBAL_DATA Bs3RmText16_EndOfSegment, 0
|
---|
175 | GROUP BS3GROUPRMTEXT16 BS3RMTEXT16_START BS3RMTEXT16 BS3RMTEXT16_END
|
---|
176 |
|
---|
177 |
|
---|
178 | ;
|
---|
179 | ; 16-bit extra text segment #0.
|
---|
180 | ;
|
---|
181 | section BS3X0TEXT16_START align=16 CLASS=BS3CLASS16X0CODE PUBLIC USE16
|
---|
182 | BS3_GLOBAL_DATA Bs3X0Text16_StartOfSegment, 0
|
---|
183 | ;db 10,13,'eye-catcher: BS3X0TEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
|
---|
184 | BS3_BEGIN_X0TEXT16 4
|
---|
185 | section BS3X0TEXT16_END align=1 CLASS=BS3CLASS16X0CODE PUBLIC USE16
|
---|
186 | BS3_GLOBAL_DATA Bs3X0Text16_EndOfSegment, 0
|
---|
187 | GROUP BS3GROUPX0TEXT16 BS3X0TEXT16_START BS3X0TEXT16 BS3X0TEXT16_END
|
---|
188 |
|
---|
189 |
|
---|
190 | ;
|
---|
191 | ; 16-bit extra text segment #1.
|
---|
192 | ;
|
---|
193 | section BS3X1TEXT16_START align=16 CLASS=BS3CLASS16X1CODE PUBLIC USE16
|
---|
194 | BS3_GLOBAL_DATA Bs3X1Text16_StartOfSegment, 0
|
---|
195 | ;db 10,13,'eye-catcher: BS3X1TEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
|
---|
196 | BS3_BEGIN_X1TEXT16 4
|
---|
197 | BS3_GLOBAL_DATA Bs3X1Text16_EndOfSegment, 0
|
---|
198 | section BS3X1TEXT16_END align=1 CLASS=BS3CLASS16X1CODE PUBLIC USE16
|
---|
199 | GROUP BS3GROUPX1TEXT16 BS3X1TEXT16_START BS3X1TEXT16 BS3X1TEXT16_END
|
---|
200 |
|
---|
201 | ;
|
---|
202 | ; Separate the BS3X1TEXT16_END from BS3_BEGIN_TEXT32 to better help pinpoint
|
---|
203 | ; the rigth segment when getting an E2083 linker error.
|
---|
204 | ;
|
---|
205 | section BS3SEPARATE16AND32BITCODE align=16 CLASS=BS3CLASSSEPARATE16AND32BITCODE PUBLIC USE16
|
---|
206 | BS3_GLOBAL_DATA BS3SEPARATE16AND32BITCODE_StartOfSegment, 0
|
---|
207 | db 10,13,'eye-catcher: 16-32 wedge',10,13
|
---|
208 | section BS3SEPARATE16AND32BITCODE_END align=16 CLASS=BS3CLASSSEPARATE16AND32BITCODE PUBLIC USE16
|
---|
209 | BS3_GLOBAL_DATA BS3SEPARATE16AND32BITCODE_EndOfSegment, 0
|
---|
210 | GROUP BS3SEPARATE16AND32BITCODEGROUP BS3SEPARATE16AND32BITCODE BS3SEPARATE16AND32BITCODE_END
|
---|
211 |
|
---|
212 |
|
---|
213 | ;
|
---|
214 | ; 32-bit text
|
---|
215 | ;
|
---|
216 | BS3_BEGIN_TEXT32
|
---|
217 | BS3_GLOBAL_DATA Bs3Text32_StartOfSegment, 0
|
---|
218 | db 10,13,'eye-catcher: BS3TEXT32',10,13
|
---|
219 | section BS3TEXT32_END align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT
|
---|
220 | BS3_GLOBAL_DATA Bs3Text32_EndOfSegment, 0
|
---|
221 |
|
---|
222 |
|
---|
223 | ;
|
---|
224 | ; This is a hack to separate the 32-bit and 64-bit text segments when linking,
|
---|
225 | ; such that they don't share the same base frame because they're both assigned
|
---|
226 | ; to the AUTO group by the linker.
|
---|
227 | ;
|
---|
228 | section BS3SEPARATE32AND64BITCODE align=16 CLASS=BS3CLASSSEPARATE32AND64BITCODE PUBLIC USE16
|
---|
229 | BS3_GLOBAL_DATA Bs3Separate32And64BitCode_StartOfSegment, 0
|
---|
230 | db 10,13,'eye-catcher: 32-64 wedge',10,13
|
---|
231 | section BS3SEPARATE32AND64BITCODE_END align=16 CLASS=BS3CLASSSEPARATE32AND64BITCODE PUBLIC USE16
|
---|
232 | BS3_GLOBAL_DATA Bs3Separate32And64BitCode_EndOfSegment, 0
|
---|
233 | GROUP BS3SEPARATE32AND64BITCODEGROUP BS3SEPARATE32AND64BITCODE BS3SEPARATE32AND64BITCODE_END
|
---|
234 |
|
---|
235 |
|
---|
236 | ;
|
---|
237 | ; 64-bit text
|
---|
238 | ;
|
---|
239 | BS3_BEGIN_TEXT64
|
---|
240 | BS3_GLOBAL_DATA Bs3Text64_StartOfSegment, 0
|
---|
241 | db 10,13,'eye-catcher: BS3TEXT64',10,13
|
---|
242 | section BS3TEXT64_END align=1 CLASS=BS3CLASS64CODE PUBLIC USE32 FLAT
|
---|
243 | BS3_GLOBAL_DATA Bs3Text64_EndOfSegment, 0
|
---|
244 |
|
---|
245 |
|
---|
246 | ;
|
---|
247 | ; FAR_DATA segment in DOS EXEs should be near the other FAR_DATA class segments.
|
---|
248 | ;
|
---|
249 | %ifdef BS3_IS_DOS_EXE
|
---|
250 | section FAR_DATA align=1 CLASS=FAR_DATA PUBLIC USE16
|
---|
251 | %endif
|
---|
252 |
|
---|
253 | ;
|
---|
254 | ; 32-bit data
|
---|
255 | ;
|
---|
256 | BS3_BEGIN_DATA32
|
---|
257 | BS3_GLOBAL_DATA Bs3Data32_StartOfSegment, 0
|
---|
258 | db 10,13,'eye-catcher: BS3DATA32',10,13
|
---|
259 | section BS3DATA32CONST align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
260 | section BS3DATA32CONST2 align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
261 | section BS3DATA32_DATA align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
262 | section BS3DATA32_BSS align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
263 | section BS3DATA32_END align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
264 | BS3_GLOBAL_DATA Bs3Data32_EndOfSegment, 0
|
---|
265 | GROUP BS3DATA32_GROUP BS3DATA32 BS3DATA32_DATA BS3DATA32CONST BS3DATA32CONST2 BS3DATA32_BSS BS3DATA32_END
|
---|
266 |
|
---|
267 | ;
|
---|
268 | ; 64-bit data
|
---|
269 | ;
|
---|
270 | BS3_BEGIN_DATA64
|
---|
271 | BS3_GLOBAL_DATA Bs3Data64_StartOfSegment, 0
|
---|
272 | db 10,13,'eye-catcher: BS3DATA64',10,13
|
---|
273 | section BS3DATA64CONST align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
274 | section BS3DATA64_BSS align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
275 | section BS3DATA64_END align=16 CLASS=FAR_DATA PUBLIC USE32
|
---|
276 | BS3_GLOBAL_DATA Bs3Data64_EndOfSegment, 0
|
---|
277 | GROUP BS3DATA64_GROUP BS3DATA64 BS3DATA64CONST BS3DATA64_BSS BS3DATA64_END
|
---|
278 |
|
---|
279 |
|
---|
280 | ;
|
---|
281 | ; 16-bit accessible system data.
|
---|
282 | ; No need to do anything here.
|
---|
283 | ;
|
---|
284 | BS3_BEGIN_SYSTEM16
|
---|
285 |
|
---|
286 |
|
---|
287 | ;
|
---|
288 | ; Switch back to the 16-bit code segment and the startup code.
|
---|
289 | ;
|
---|
290 | BS3_BEGIN_TEXT16
|
---|
291 | BS3_GLOBAL_NAME_EX Bs3KitEntryPoint, function, 0
|
---|
292 |
|
---|