1 | ; $Id: commondefs.inc 76553 2019-01-01 01:45:53Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; Stuff for drawing the BIOS logo.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2004-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 |
|
---|
18 |
|
---|
19 | ;; Switches back to default CPU mode.
|
---|
20 | SET_DEFAULT_CPU macro
|
---|
21 | if VBOX_BIOS_CPU eq 8086
|
---|
22 | .8086
|
---|
23 | elseif VBOX_BIOS_CPU eq 80186
|
---|
24 | .186
|
---|
25 | elseif VBOX_BIOS_CPU eq 80286
|
---|
26 | .286
|
---|
27 | elseif VBOX_BIOS_CPU eq 80386
|
---|
28 | .386
|
---|
29 | else
|
---|
30 | .errnz 1, Unsupported target CPU value: VBOX_BIOS_CPU
|
---|
31 | .386
|
---|
32 | endif
|
---|
33 | endm
|
---|
34 |
|
---|
35 |
|
---|
36 | ;; Switches back to default CPU mode, max 286.
|
---|
37 | SET_DEFAULT_CPU_286 macro
|
---|
38 | if VBOX_BIOS_CPU eq 8086
|
---|
39 | .8086
|
---|
40 | elseif VBOX_BIOS_CPU eq 80186
|
---|
41 | .186
|
---|
42 | else
|
---|
43 | .286
|
---|
44 | endif
|
---|
45 | endm
|
---|
46 |
|
---|
47 |
|
---|
48 | ;;
|
---|
49 | ; Pretends to do a call by pushing the return address and jumping
|
---|
50 | ; to the function.
|
---|
51 | ;
|
---|
52 | ; This is slightly problematic on 8086 since it doesn't support pushing
|
---|
53 | ; word immediates. OTOH, it support pushing memory, so we'll do that
|
---|
54 | ; instead when targeting 8086.
|
---|
55 | ;
|
---|
56 | if 0 ;; this crap crashes wasm, makes it call exit(0), or similar weird stuff.
|
---|
57 | ;; switched to a simpler approach where I define the one return address variable myself.
|
---|
58 | DO_JMP_CALL macro calling, returning
|
---|
59 | if VBOX_BIOS_CPU gt 8086
|
---|
60 | push returning
|
---|
61 | jmp calling
|
---|
62 | else
|
---|
63 | push word ptr cs:[%jmp_call_addr_&returning]
|
---|
64 | jmp calling
|
---|
65 | ;public jmp_call_addr_&returning
|
---|
66 | %jmp_call_addr_&returning: dw offset retaddr
|
---|
67 | endif
|
---|
68 | endm
|
---|
69 |
|
---|
70 | DO_JMP_CALL_AGAIN macro calling, returning
|
---|
71 | if VBOX_BIOS_CPU gt 8086
|
---|
72 | push returning
|
---|
73 | jmp calling
|
---|
74 | else
|
---|
75 | push word ptr cs:[%jmp_call_addr_&returning]
|
---|
76 | jmp calling
|
---|
77 | endif
|
---|
78 | endm
|
---|
79 |
|
---|
80 | else ; Simplified.
|
---|
81 | DO_JMP_CALL_EX macro calling, returning, returning_ptr_var
|
---|
82 | if VBOX_BIOS_CPU gt 8086
|
---|
83 | push returning
|
---|
84 | jmp calling
|
---|
85 | else
|
---|
86 | push word ptr cs:[returning_ptr_var]
|
---|
87 | jmp calling
|
---|
88 | endif
|
---|
89 | endm
|
---|
90 |
|
---|
91 | endif ; Simplified.
|
---|
92 |
|
---|
93 |
|
---|
94 | ;; For handling the pusha instruction depending on target CPU.
|
---|
95 | DO_pusha macro
|
---|
96 | if VBOX_BIOS_CPU gt 8086
|
---|
97 | pusha
|
---|
98 | else
|
---|
99 | push ax
|
---|
100 | push cx
|
---|
101 | push dx
|
---|
102 | push bx
|
---|
103 | push sp
|
---|
104 | push bp
|
---|
105 | push si
|
---|
106 | push di
|
---|
107 | endif
|
---|
108 | endm
|
---|
109 |
|
---|
110 |
|
---|
111 | ;; For handling the popad/popa instruction depending on target CPU.
|
---|
112 | DO_popa macro
|
---|
113 | if VBOX_BIOS_CPU gt 8086
|
---|
114 | popa
|
---|
115 | else
|
---|
116 | pop di
|
---|
117 | pop si
|
---|
118 | pop bp
|
---|
119 | pop bx ;pop sp
|
---|
120 | pop bx
|
---|
121 | pop dx
|
---|
122 | pop cx
|
---|
123 | pop ax
|
---|
124 | endif
|
---|
125 | endm
|
---|
126 |
|
---|
127 |
|
---|
128 | ;; For handling the pushad/pusha instruction depending on target CPU.
|
---|
129 | DO_PUSHAD macro
|
---|
130 | if VBOX_BIOS_CPU ge 80386
|
---|
131 | pushad
|
---|
132 | elseif VBOX_BIOS_CPU gt 8086
|
---|
133 | pusha
|
---|
134 | else
|
---|
135 | push ax
|
---|
136 | push cx
|
---|
137 | push dx
|
---|
138 | push bx
|
---|
139 | push sp
|
---|
140 | push bp
|
---|
141 | push si
|
---|
142 | push di
|
---|
143 | endif
|
---|
144 | endm
|
---|
145 |
|
---|
146 |
|
---|
147 | ;; For handling the popad/popa instruction depending on target CPU.
|
---|
148 | DO_POPAD macro
|
---|
149 | if VBOX_BIOS_CPU ge 80386
|
---|
150 | popad
|
---|
151 | elseif VBOX_BIOS_CPU gt 8086
|
---|
152 | popa
|
---|
153 | else
|
---|
154 | pop di
|
---|
155 | pop si
|
---|
156 | pop bp
|
---|
157 | pop bx ;pop sp
|
---|
158 | pop bx
|
---|
159 | pop dx
|
---|
160 | pop cx
|
---|
161 | pop ax
|
---|
162 | endif
|
---|
163 | endm
|
---|
164 |
|
---|
165 |
|
---|
166 | ;; ASSUMES working stack.
|
---|
167 | DO_shr macro reg, count
|
---|
168 | if VBOX_BIOS_CPU ge 80186
|
---|
169 | shr reg, count
|
---|
170 | else
|
---|
171 | if count ge 6
|
---|
172 | push cx
|
---|
173 | mov cl, count
|
---|
174 | shr reg, cl
|
---|
175 | pop cx
|
---|
176 | else
|
---|
177 | if count ge 5
|
---|
178 | shr reg, 1
|
---|
179 | endif
|
---|
180 | if count ge 4
|
---|
181 | shr reg, 1
|
---|
182 | endif
|
---|
183 | if count ge 3
|
---|
184 | shr reg, 1
|
---|
185 | endif
|
---|
186 | if count ge 2
|
---|
187 | shr reg, 1
|
---|
188 | endif
|
---|
189 | if count ge 1
|
---|
190 | shr reg, 1
|
---|
191 | endif
|
---|
192 | endif
|
---|
193 | endif
|
---|
194 | endm
|
---|
195 |
|
---|
196 |
|
---|
197 | ;; ASSUMES working stack.
|
---|
198 | DO_shl macro reg, count
|
---|
199 | if VBOX_BIOS_CPU ge 80186
|
---|
200 | shl reg, count
|
---|
201 | else
|
---|
202 | if count ge 6
|
---|
203 | push cx
|
---|
204 | mov cl, count
|
---|
205 | shl reg, cl
|
---|
206 | pop cx
|
---|
207 | else
|
---|
208 | if count ge 5
|
---|
209 | shl reg, 1
|
---|
210 | endif
|
---|
211 | if count ge 4
|
---|
212 | shl reg, 1
|
---|
213 | endif
|
---|
214 | if count ge 3
|
---|
215 | shl reg, 1
|
---|
216 | endif
|
---|
217 | if count ge 2
|
---|
218 | shl reg, 1
|
---|
219 | endif
|
---|
220 | if count ge 1
|
---|
221 | shl reg, 1
|
---|
222 | endif
|
---|
223 | endif
|
---|
224 | endif
|
---|
225 | endm
|
---|
226 |
|
---|
227 |
|
---|
228 |
|
---|
229 |
|
---|
230 | ;; Adds a special label that will have its address checked after linking.
|
---|
231 | BIOSORG_CHECK macro addr
|
---|
232 | public biosorg_check_at_&addr
|
---|
233 | biosorg_check_at_&addr:
|
---|
234 | endm
|
---|
235 |
|
---|
236 | ;; Adds a special label that will have its address checked after linking.
|
---|
237 | BIOSORG_CHECK_BEFORE macro addr
|
---|
238 | public biosorg_check_before_or_at_&addr
|
---|
239 | biosorg_check_before_or_at_&addr:
|
---|
240 | endm
|
---|
241 |
|
---|