VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-common.mac@ 106560

Last change on this file since 106560 was 106061, checked in by vboxsync, 4 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.2 KB
Line 
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
59BS3_BEGIN_TEXT16
60%else
61section BEGTEXT align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
62BS3_BEGIN_TEXT16
63section BEGTEXT
64%endif
65BS3_GLOBAL_DATA Bs3Text16_StartOfSegment, 0
66
67; Entry point with eye-catcher.
68GLOBALNAME start
69global __ImageBase ; for MS compiler - must be first!
70__ImageBase:
71global ___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
80BS3_BEGIN_TEXT16
81.after_eye_catcher:
82
83section _TEXT align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
84section BS3TEXT16_NEARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
85section BS3TEXT16_FARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
86section BS3TEXT16_END align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
87
88BS3_GLOBAL_DATA Bs3Text16_EndOfSegment, 0
89
90%ifndef BS3_IS_DOS_EXE
91GROUP CGROUP16 BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
92%else
93GROUP CGROUP16 BEGTEXT BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
94%endif
95
96
97;
98; 16-bit data
99;
100BS3_BEGIN_DATA16
101BS3_GLOBAL_DATA Bs3Data16_StartOfSegment, 0
102 db 10,13,'eye-catcher: BS3DATA16',10,13
103
104ALIGNDATA(16)
105BS3_GLOBAL_DATA Bs3Data16_Size, 4
106 dd BS3_DATA_NM(Bs3Data16_EndOfSegment) wrt BS3KIT_GRPNM_DATA16
107BS3_GLOBAL_DATA Bs3Data16Thru64Text32And64_TotalSize, 4
108 dd BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3KIT_GRPNM_DATA16
109BS3_GLOBAL_DATA Bs3TotalImageSize, 4
110 dd BS3_DATA_NM(Bs3Text64_EndOfSegment) wrt CGROUP16 ; ASSUMES TEXT64 is last.
111
112BS3_GLOBAL_DATA Bs3Text16_Size, 2
113 dw BS3_DATA_NM(Bs3Text16_EndOfSegment) wrt CGROUP16
114%ifndef BS3_IS_HIGH_IMAGE
115BS3_GLOBAL_DATA Bs3RmText16_Size, 2
116 dw BS3_DATA_NM(Bs3RmText16_EndOfSegment) wrt BS3GROUPRMTEXT16
117%endif ; !BS3_IS_HIGH_IMAGE
118BS3_GLOBAL_DATA Bs3X0Text16_Size, 2
119 dw BS3_DATA_NM(Bs3X0Text16_EndOfSegment) wrt BS3GROUPX0TEXT16
120BS3_GLOBAL_DATA Bs3X1Text16_Size, 2
121 dw BS3_DATA_NM(Bs3X1Text16_EndOfSegment) wrt BS3GROUPX1TEXT16
122
123%ifndef BS3_IS_HIGH_IMAGE
124BS3_GLOBAL_DATA Bs3RmText16_FlatAddr, 4
125 dd BS3_DATA_NM(Bs3RmText16_StartOfSegment) wrt BS3FLAT
126%endif ; !BS3_IS_HIGH_IMAGE
127BS3_GLOBAL_DATA Bs3X0Text16_FlatAddr, 4
128 dd BS3_DATA_NM(Bs3X0Text16_StartOfSegment) wrt BS3FLAT
129BS3_GLOBAL_DATA Bs3X1Text16_FlatAddr, 4
130 dd BS3_DATA_NM(Bs3X1Text16_StartOfSegment) wrt BS3FLAT
131
132section BS3DATA16CONST align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
133section BS3DATA16CONST2 align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
134section BS3DATA16_DATA align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
135%ifdef BS3_IS_DOS_EXE
136section _NULL align=16 CLASS=BEGDATA PUBLIC USE16
137section _AFTERNULL align=2 CLASS=BEGDATA PUBLIC USE16
138%endif
139section CONST align=2 CLASS=DATA PUBLIC USE16
140section CONST2 align=2 CLASS=DATA PUBLIC USE16
141section _DATA align=2 CLASS=DATA PUBLIC USE16
142%ifdef BS3_IS_DOS_EXE
143section XIB align=1 CLASS=DATA PUBLIC USE16
144section XI align=1 CLASS=DATA PUBLIC USE16
145section XIE align=1 CLASS=DATA PUBLIC USE16
146section YIB align=1 CLASS=DATA PUBLIC USE16
147section YI align=1 CLASS=DATA PUBLIC USE16
148section YIE align=1 CLASS=DATA PUBLIC USE16
149%endif
150section STRINGS align=2 CLASS=DATA PUBLIC USE16
151section DATA align=2 CLASS=DATA PUBLIC USE16
152section _BSS align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
153section BSS align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
154%ifdef BS3_IS_DOS_EXE
155section STACK align=16 CLASS=STACK STACK USE16
156%endif
157section BS3DATA16_END align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
158
159BS3_GLOBAL_DATA Bs3Data16_EndOfSegment, 0
160
161%ifndef BS3_IS_DOS_EXE
162GROUP BS3KIT_GRPNM_DATA16 BS3DATA16 BS3DATA16_DATA _DATA DATA BS3DATA16CONST CONST BS3DATA16CONST2 CONST2 STRINGS _BSS BSS BS3DATA16_END
163%else
164GROUP 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;
175section BS3RMTEXT16_START align=16 CLASS=BS3CLASS16RMCODE PUBLIC USE16
176BS3_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.
178BS3_BEGIN_RMTEXT16
179section BS3RMTEXT16_END align=1 CLASS=BS3CLASS16RMCODE PUBLIC USE16
180BS3_GLOBAL_DATA Bs3RmText16_EndOfSegment, 0
181GROUP BS3GROUPRMTEXT16 BS3RMTEXT16_START BS3RMTEXT16 BS3RMTEXT16_END
182%endif ; !BS3_IS_HIGH_IMAGE
183
184;
185; 16-bit extra text segment #0.
186;
187section BS3X0TEXT16_START align=16 CLASS=BS3CLASS16X0CODE PUBLIC USE16
188BS3_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.
190BS3_BEGIN_X0TEXT16 4
191section BS3X0TEXT16_END align=1 CLASS=BS3CLASS16X0CODE PUBLIC USE16
192BS3_GLOBAL_DATA Bs3X0Text16_EndOfSegment, 0
193GROUP BS3GROUPX0TEXT16 BS3X0TEXT16_START BS3X0TEXT16 BS3X0TEXT16_END
194
195
196;
197; 16-bit extra text segment #1.
198;
199section BS3X1TEXT16_START align=16 CLASS=BS3CLASS16X1CODE PUBLIC USE16
200BS3_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.
202BS3_BEGIN_X1TEXT16 4
203BS3_GLOBAL_DATA Bs3X1Text16_EndOfSegment, 0
204section BS3X1TEXT16_END align=1 CLASS=BS3CLASS16X1CODE PUBLIC USE16
205GROUP 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;
212section BS3SEPARATE16AND32BITCODE align=16 CLASS=BS3CLASSSEPARATE16AND32BITCODE PUBLIC USE16
213BS3_GLOBAL_DATA BS3SEPARATE16AND32BITCODE_StartOfSegment, 0
214 db 10,13,'eye-catcher: 16-32 wedge',10,13
215BS3_GLOBAL_DATA BS3SEPARATE16AND32BITCODE_EndOfSegment, 0
216GROUP BS3SEPARATE16AND32BITCODEGROUP BS3SEPARATE16AND32BITCODE
217%endif ; !BS3_IS_HIGH_IMAGE
218
219
220;
221; 32-bit text
222;
223BS3_BEGIN_TEXT32
224BS3_GLOBAL_DATA Bs3Text32_StartOfSegment, 0
225 db 10,13,'eye-catcher: BS3TEXT32',10,13
226section BS3TEXT32_END align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT
227BS3_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;
236section BS3SEPARATE32AND64BITCODE align=16 CLASS=BS3CLASSSEPARATE32AND64BITCODE PUBLIC USE16
237BS3_GLOBAL_DATA Bs3Separate32And64BitCode_StartOfSegment, 0
238 db 10,13,'eye-catcher: 32-64 wedge',10,13
239BS3_GLOBAL_DATA Bs3Separate32And64BitCode_EndOfSegment, 0
240GROUP BS3SEPARATE32AND64BITCODEGROUP BS3SEPARATE32AND64BITCODE
241%endif ; !BS3_IS_HIGH_IMAGE
242
243
244;
245; 64-bit text
246;
247BS3_BEGIN_TEXT64
248BS3_GLOBAL_DATA Bs3Text64_StartOfSegment, 0
249 db 10,13,'eye-catcher: BS3TEXT64',10,13
250section BS3TEXT64_END align=1 CLASS=BS3CLASS64CODE PUBLIC USE32 FLAT
251BS3_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
258section FAR_DATA align=1 CLASS=FAR_DATA PUBLIC USE16
259%endif
260
261;
262; 32-bit data
263;
264BS3_BEGIN_DATA32
265BS3_GLOBAL_DATA Bs3Data32_StartOfSegment, 0
266 db 10,13,'eye-catcher: BS3DATA32',10,13
267section BS3DATA32CONST align=16 CLASS=FAR_DATA PUBLIC USE32
268section BS3DATA32CONST2 align=16 CLASS=FAR_DATA PUBLIC USE32
269section BS3DATA32_DATA align=16 CLASS=FAR_DATA PUBLIC USE32
270section BS3DATA32_BSS align=16 CLASS=FAR_DATA PUBLIC USE32
271section BS3DATA32_END align=16 CLASS=FAR_DATA PUBLIC USE32
272BS3_GLOBAL_DATA Bs3Data32_EndOfSegment, 0
273GROUP BS3DATA32_GROUP BS3DATA32 BS3DATA32_DATA BS3DATA32CONST BS3DATA32CONST2 BS3DATA32_BSS BS3DATA32_END
274
275;
276; 64-bit data
277;
278BS3_BEGIN_DATA64
279BS3_GLOBAL_DATA Bs3Data64_StartOfSegment, 0
280 db 10,13,'eye-catcher: BS3DATA64',10,13
281section BS3DATA64CONST align=16 CLASS=FAR_DATA PUBLIC USE32
282section BS3DATA64_BSS align=16 CLASS=FAR_DATA PUBLIC USE32
283section BS3DATA64_END align=16 CLASS=FAR_DATA PUBLIC USE32
284BS3_GLOBAL_DATA Bs3Data64_EndOfSegment, 0
285GROUP BS3DATA64_GROUP BS3DATA64 BS3DATA64CONST BS3DATA64_BSS BS3DATA64_END
286
287
288%ifndef BS3_IS_HIGH_IMAGE
289;
290; The high dll table segment.
291;
292section BS3HIGHDLLSEGMENTS align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
293section BS3HIGHDLLEXPORTS align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT ;; @todo Consider moving this to DATA16...
294section BS3HIGHDLLIMPORTS align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
295section BS3HIGHDLLSTRINGS align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
296section BS3HIGHDLLTABLE align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
297BS3_GLOBAL_DATA g_aBs3HighDllTable, 0
298section BS3HIGHDLLTABLE_END align=4 CLASS=BS3HIGHDLLCLASS PUBLIC USE32 FLAT
299BS3_GLOBAL_DATA g_Bs3HighDllTable_End, 0
300GROUP BS3HIGHDLLGROUP BS3HIGHDLLSEGMENTS BS3HIGHDLLEXPORTS BS3HIGHDLLIMPORTS BS3HIGHDLLSTRINGS BS3HIGHDLLTABLE BS3HIGHDLLTABLE_END
301
302;
303; 16-bit accessible system data.
304; No need to do anything here.
305;
306BS3_BEGIN_SYSTEM16
307
308
309;
310; Switch back to the 16-bit code segment and the startup code.
311;
312BS3_BEGIN_TEXT16
313BS3_GLOBAL_NAME_EX Bs3KitEntryPoint, function, 0
314%endif ; !BS3_IS_HIGH_IMAGE
315
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette