VirtualBox

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

Last change on this file since 102127 was 102127, checked in by vboxsync, 15 months ago

ValKit/bs3kit: Added Bs3SelLnkCodePtrToCurPtr and Bs3SelRealModeCodeToProtFar16; fixed some wlink segment name typos (harmless); and added a segment between BS3X1TEXT16_END and BS3TEXT32 to better tell linker errors apart. bugref:10371

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.2 KB
Line 
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
58BS3_BEGIN_TEXT16
59%else
60section BEGTEXT align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
61BS3_BEGIN_TEXT16
62section BEGTEXT
63%endif
64BS3_GLOBAL_DATA Bs3Text16_StartOfSegment, 0
65
66; Entry point with eye-catcher.
67GLOBALNAME start
68global __ImageBase ; for MS compiler - must be first!
69__ImageBase:
70global ___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
79BS3_BEGIN_TEXT16
80.after_eye_catcher:
81
82section _TEXT align=2 CLASS=BS3CLASS16CODE PUBLIC USE16
83section BS3TEXT16_NEARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
84section BS3TEXT16_FARSTUBS align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
85section BS3TEXT16_END align=1 CLASS=BS3CLASS16CODE PUBLIC USE16
86
87BS3_GLOBAL_DATA Bs3Text16_EndOfSegment, 0
88
89%ifndef BS3_IS_DOS_EXE
90GROUP CGROUP16 BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
91%else
92GROUP CGROUP16 BEGTEXT BS3TEXT16 _TEXT BS3TEXT16_NEARSTUBS BS3TEXT16_FARSTUBS BS3TEXT16_END
93%endif
94
95
96;
97; 16-bit data
98;
99BS3_BEGIN_DATA16
100BS3_GLOBAL_DATA Bs3Data16_StartOfSegment, 0
101 db 10,13,'eye-catcher: BS3DATA16',10,13
102
103ALIGNDATA(16)
104BS3_GLOBAL_DATA Bs3Data16_Size, 4
105 dd BS3_DATA_NM(Bs3Data16_EndOfSegment) wrt BS3KIT_GRPNM_DATA16
106BS3_GLOBAL_DATA Bs3Data16Thru64Text32And64_TotalSize, 4
107 dd BS3_DATA_NM(Bs3Data64_EndOfSegment) wrt BS3KIT_GRPNM_DATA16
108BS3_GLOBAL_DATA Bs3TotalImageSize, 4
109 dd BS3_DATA_NM(Bs3Text64_EndOfSegment) wrt CGROUP16 ; ASSUMES TEXT64 is last.
110
111BS3_GLOBAL_DATA Bs3Text16_Size, 2
112 dw BS3_DATA_NM(Bs3Text16_EndOfSegment) wrt CGROUP16
113BS3_GLOBAL_DATA Bs3RmText16_Size, 2
114 dw BS3_DATA_NM(Bs3RmText16_EndOfSegment) wrt BS3GROUPRMTEXT16
115BS3_GLOBAL_DATA Bs3X0Text16_Size, 2
116 dw BS3_DATA_NM(Bs3X0Text16_EndOfSegment) wrt BS3GROUPX0TEXT16
117BS3_GLOBAL_DATA Bs3X1Text16_Size, 2
118 dw BS3_DATA_NM(Bs3X1Text16_EndOfSegment) wrt BS3GROUPX1TEXT16
119
120BS3_GLOBAL_DATA Bs3RmText16_FlatAddr, 4
121 dd BS3_DATA_NM(Bs3RmText16_StartOfSegment) wrt BS3FLAT
122BS3_GLOBAL_DATA Bs3X0Text16_FlatAddr, 4
123 dd BS3_DATA_NM(Bs3X0Text16_StartOfSegment) wrt BS3FLAT
124BS3_GLOBAL_DATA Bs3X1Text16_FlatAddr, 4
125 dd BS3_DATA_NM(Bs3X1Text16_StartOfSegment) wrt BS3FLAT
126
127section BS3DATA16CONST align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
128section BS3DATA16CONST2 align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
129section BS3DATA16_DATA align=2 CLASS=BS3KIT_CLASS_DATA16 PUBLIC USE16
130%ifdef BS3_IS_DOS_EXE
131section _NULL align=16 CLASS=BEGDATA PUBLIC USE16
132section _AFTERNULL align=2 CLASS=BEGDATA PUBLIC USE16
133%endif
134section CONST align=2 CLASS=DATA PUBLIC USE16
135section CONST2 align=2 CLASS=DATA PUBLIC USE16
136section _DATA align=2 CLASS=DATA PUBLIC USE16
137%ifdef BS3_IS_DOS_EXE
138section XIB align=1 CLASS=DATA PUBLIC USE16
139section XI align=1 CLASS=DATA PUBLIC USE16
140section XIE align=1 CLASS=DATA PUBLIC USE16
141section YIB align=1 CLASS=DATA PUBLIC USE16
142section YI align=1 CLASS=DATA PUBLIC USE16
143section YIE align=1 CLASS=DATA PUBLIC USE16
144%endif
145section STRINGS align=2 CLASS=DATA PUBLIC USE16
146section DATA align=2 CLASS=DATA PUBLIC USE16
147section _BSS align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
148section BSS align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
149%ifdef BS3_IS_DOS_EXE
150section STACK align=16 CLASS=STACK STACK USE16
151%endif
152section BS3DATA16_END align=2 CLASS=BS3KIT_CLASS_BSS16 PUBLIC USE16
153
154BS3_GLOBAL_DATA Bs3Data16_EndOfSegment, 0
155
156%ifndef BS3_IS_DOS_EXE
157GROUP BS3KIT_GRPNM_DATA16 BS3DATA16 BS3DATA16_DATA _DATA DATA BS3DATA16CONST CONST BS3DATA16CONST2 CONST2 STRINGS _BSS BSS BS3DATA16_END
158%else
159GROUP 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;
169section BS3RMTEXT16_START align=16 CLASS=BS3CLASS16RMCODE PUBLIC USE16
170BS3_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.
172BS3_BEGIN_RMTEXT16
173section BS3RMTEXT16_END align=1 CLASS=BS3CLASS16RMCODE PUBLIC USE16
174BS3_GLOBAL_DATA Bs3RmText16_EndOfSegment, 0
175GROUP BS3GROUPRMTEXT16 BS3RMTEXT16_START BS3RMTEXT16 BS3RMTEXT16_END
176
177
178;
179; 16-bit extra text segment #0.
180;
181section BS3X0TEXT16_START align=16 CLASS=BS3CLASS16X0CODE PUBLIC USE16
182BS3_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.
184BS3_BEGIN_X0TEXT16 4
185section BS3X0TEXT16_END align=1 CLASS=BS3CLASS16X0CODE PUBLIC USE16
186BS3_GLOBAL_DATA Bs3X0Text16_EndOfSegment, 0
187GROUP BS3GROUPX0TEXT16 BS3X0TEXT16_START BS3X0TEXT16 BS3X0TEXT16_END
188
189
190;
191; 16-bit extra text segment #1.
192;
193section BS3X1TEXT16_START align=16 CLASS=BS3CLASS16X1CODE PUBLIC USE16
194BS3_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.
196BS3_BEGIN_X1TEXT16 4
197BS3_GLOBAL_DATA Bs3X1Text16_EndOfSegment, 0
198section BS3X1TEXT16_END align=1 CLASS=BS3CLASS16X1CODE PUBLIC USE16
199GROUP 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;
205section BS3SEPARATE16AND32BITCODE align=16 CLASS=BS3CLASSSEPARATE16AND32BITCODE PUBLIC USE16
206BS3_GLOBAL_DATA BS3SEPARATE16AND32BITCODE_StartOfSegment, 0
207 db 10,13,'eye-catcher: 16-32 wedge',10,13
208section BS3SEPARATE16AND32BITCODE_END align=16 CLASS=BS3CLASSSEPARATE16AND32BITCODE PUBLIC USE16
209BS3_GLOBAL_DATA BS3SEPARATE16AND32BITCODE_EndOfSegment, 0
210GROUP BS3SEPARATE16AND32BITCODEGROUP BS3SEPARATE16AND32BITCODE BS3SEPARATE16AND32BITCODE_END
211
212
213;
214; 32-bit text
215;
216BS3_BEGIN_TEXT32
217BS3_GLOBAL_DATA Bs3Text32_StartOfSegment, 0
218 db 10,13,'eye-catcher: BS3TEXT32',10,13
219section BS3TEXT32_END align=1 CLASS=BS3CLASS32CODE PUBLIC USE32 FLAT
220BS3_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;
228section BS3SEPARATE32AND64BITCODE align=16 CLASS=BS3CLASSSEPARATE32AND64BITCODE PUBLIC USE16
229BS3_GLOBAL_DATA Bs3Separate32And64BitCode_StartOfSegment, 0
230 db 10,13,'eye-catcher: 32-64 wedge',10,13
231section BS3SEPARATE32AND64BITCODE_END align=16 CLASS=BS3CLASSSEPARATE32AND64BITCODE PUBLIC USE16
232BS3_GLOBAL_DATA Bs3Separate32And64BitCode_EndOfSegment, 0
233GROUP BS3SEPARATE32AND64BITCODEGROUP BS3SEPARATE32AND64BITCODE BS3SEPARATE32AND64BITCODE_END
234
235
236;
237; 64-bit text
238;
239BS3_BEGIN_TEXT64
240BS3_GLOBAL_DATA Bs3Text64_StartOfSegment, 0
241 db 10,13,'eye-catcher: BS3TEXT64',10,13
242section BS3TEXT64_END align=1 CLASS=BS3CLASS64CODE PUBLIC USE32 FLAT
243BS3_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
250section FAR_DATA align=1 CLASS=FAR_DATA PUBLIC USE16
251%endif
252
253;
254; 32-bit data
255;
256BS3_BEGIN_DATA32
257BS3_GLOBAL_DATA Bs3Data32_StartOfSegment, 0
258 db 10,13,'eye-catcher: BS3DATA32',10,13
259section BS3DATA32CONST align=16 CLASS=FAR_DATA PUBLIC USE32
260section BS3DATA32CONST2 align=16 CLASS=FAR_DATA PUBLIC USE32
261section BS3DATA32_DATA align=16 CLASS=FAR_DATA PUBLIC USE32
262section BS3DATA32_BSS align=16 CLASS=FAR_DATA PUBLIC USE32
263section BS3DATA32_END align=16 CLASS=FAR_DATA PUBLIC USE32
264BS3_GLOBAL_DATA Bs3Data32_EndOfSegment, 0
265GROUP BS3DATA32_GROUP BS3DATA32 BS3DATA32_DATA BS3DATA32CONST BS3DATA32CONST2 BS3DATA32_BSS BS3DATA32_END
266
267;
268; 64-bit data
269;
270BS3_BEGIN_DATA64
271BS3_GLOBAL_DATA Bs3Data64_StartOfSegment, 0
272 db 10,13,'eye-catcher: BS3DATA64',10,13
273section BS3DATA64CONST align=16 CLASS=FAR_DATA PUBLIC USE32
274section BS3DATA64_BSS align=16 CLASS=FAR_DATA PUBLIC USE32
275section BS3DATA64_END align=16 CLASS=FAR_DATA PUBLIC USE32
276BS3_GLOBAL_DATA Bs3Data64_EndOfSegment, 0
277GROUP 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;
284BS3_BEGIN_SYSTEM16
285
286
287;
288; Switch back to the 16-bit code segment and the startup code.
289;
290BS3_BEGIN_TEXT16
291BS3_GLOBAL_NAME_EX Bs3KitEntryPoint, function, 0
292
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