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