VirtualBox

source: vbox/trunk/src/VBox/Devices/BiosCommonCode/commondefs.inc

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