VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-mode-BiosInt15hE820.asm@ 106215

Last change on this file since 106215 was 106061, checked in by vboxsync, 3 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: 7.5 KB
Line 
1; $Id: bs3-mode-BiosInt15hE820.asm 106061 2024-09-16 14:03:52Z vboxsync $
2;; @file
3; BS3Kit - Bs3BiosInt15hE820
4;
5
6;
7; Copyright (C) 2021-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;* Header Files *
39;*********************************************************************************************************************************
40%include "bs3kit-template-header.mac"
41
42
43;*********************************************************************************************************************************
44;* Defined Constants And Macros *
45;*********************************************************************************************************************************
46;; Signature: 'SMAP'
47%define INT15_E820_SIGNATURE 0534d4150h
48
49
50;*********************************************************************************************************************************
51;* External symbols *
52;*********************************************************************************************************************************
53TMPL_BEGIN_TEXT
54extern TMPL_NM(Bs3SwitchToRM)
55BS3_BEGIN_TEXT16
56extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_rm)
57
58
59;;
60; Performs a int 15h function 0xe820 call.
61;
62; @cproto BS3_MODE_PROTO_STUB(bool, Bs3BiosInt15hE820,(INT15E820ENTRY BS3_FAR *pEntry, uint32_t BS3_FAR *pcbEntry,
63; uint32_t BS3_FAR *puContinuationValue));
64;
65; @returns Success indicator.
66; @param pEntry The return buffer.
67; @param pcbEntry Input: The size of the buffer (min 20 bytes);
68; Output: The size of the returned data.
69; @param puContinuationValue Where to get and return the continuation value (EBX)
70; Set to zero the for the first call. Returned as zero
71; after the last entry.
72;
73; @remarks ASSUMES we're in ring-0 when not in some kind of real mode.
74; @remarks ASSUMES we're on a 16-bit suitable stack.
75;
76; @uses rax
77;
78TMPL_BEGIN_TEXT
79BS3_PROC_BEGIN_MODE Bs3BiosInt15hE820, BS3_PBC_HYBRID
80 push xBP
81 mov xBP, xSP
82 sPUSHF
83 cli
84 push sBX
85 push sCX
86 push sDX
87 push sSI
88 push sDI
89%ifdef TMPL_16BIT
90 push ds
91 push es
92%endif
93 ; Load/Save parameters.
94%define a_pEntry [xBP + xCB + cbCurRetAddr + sCB*0]
95%define a_pcbEntry [xBP + xCB + cbCurRetAddr + sCB*1]
96%define a_puContinuationValue [xBP + xCB + cbCurRetAddr + sCB*2]
97%ifdef TMPL_64BIT
98 mov a_pEntry, rcx ; save pEntry
99 mov a_pcbEntry, rdx ; save pcbEntry
100 mov a_puContinuationValue, r8 ; save a_puContinuationValue
101 mov ebx, [r8] ; uContinuationValue for int15
102 mov ecx, [rdx] ; Buffer size for int15.
103%elifdef TMPL_16BIT
104 les bx, a_pcbEntry
105 mov ecx, [es:bx] ; Buffer size for int15.
106 les bx, a_puContinuationValue
107 mov ebx, [es:bx] ; Buffer size for int15.
108%else
109 mov ecx, a_pcbEntry
110 mov ecx, [ecx] ; Buffer size for int15.
111 mov ebx, a_puContinuationValue
112 mov ebx, [ebx] ; uContinuationValue for int15
113%endif
114 ;
115 ; Check that the cbEntry isn't too big or too small before doing
116 ; the stack allocation. (Our BIOS doesn't check if too small.)
117 ;
118 cmp ecx, 100h
119 jae .failed
120 cmp cl, 14h
121 jb .failed
122
123%if TMPL_MODE != BS3_MODE_RM
124 sub xSP, xCX ; allocate a temporary buffer on the stack.
125 and xSP, ~0fh
126%endif
127
128 ;
129 ; Switch to real mode, first we just ot the 16-bit text segment.
130 ; This preserve all 32-bit register values.
131 ;
132%if TMPL_MODE != BS3_MODE_RM
133 %ifndef TMPL_16BIT
134 jmp .to_text16
135BS3_BEGIN_TEXT16
136.to_text16:
137 BS3_SET_BITS TMPL_BITS
138 %endif
139 call TMPL_NM(Bs3SwitchToRM)
140 BS3_SET_BITS 16
141%endif
142
143 ;
144 ; Make the call.
145 ;
146%if TMPL_MODE == BS3_MODE_RM
147 les di, a_pEntry
148%else
149 push ss ; es:di -> ss:sp
150 pop es
151 mov di, sp
152%endif
153 mov edx, INT15_E820_SIGNATURE
154 mov eax, 0e820h ; BIOS function number
155 int 15h
156
157 ;
158 ; Switch back.
159 ;
160%if TMPL_MODE != BS3_MODE_RM
161 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_rm)
162 BS3_SET_BITS TMPL_BITS
163 %ifndef TMPL_16BIT
164 jmp .from_text16
165TMPL_BEGIN_TEXT
166.from_text16:
167 %endif
168%endif
169 ;
170 ; Check that we didn't failed.
171 ;
172 jc .failed
173 cmp eax, INT15_E820_SIGNATURE
174 jne .failed
175 cmp ecx, 20
176 jb .failed
177
178 ;
179 ; Save the continuation value.
180 ;
181%ifdef TMPL_16BIT
182 mov eax, ebx
183 lds bx, a_puContinuationValue
184 mov [bx], eax
185%else
186 mov xAX, a_puContinuationValue
187 mov [xAX], ebx
188%endif
189
190 ;
191 ; Save the entry size.
192 ;
193%ifdef TMPL_16BIT
194 lds bx, a_pcbEntry
195%else
196 mov xBX, a_pcbEntry
197%endif
198 mov [xBX], ecx
199
200%if TMPL_MODE != BS3_MODE_RM
201 ;
202 ; Copy the returned stuff into the caller's buffer.
203 ;
204 mov xSI, xSP
205 %ifdef TMPL_16BIT
206 push ss
207 pop es
208 lds di, a_pEntry
209 %else
210 mov xDI, a_pEntry
211 %endif
212 cld
213 rep movsb
214%endif
215
216 ;
217 ; Return success
218 ;
219 mov al, 1
220
221.return:
222%ifdef TMPL_16BIT
223 lea xSP, [xBP - sCB * 6 - xCB*2]
224 pop es
225 pop ds
226%else
227 lea xSP, [xBP - sCB * 6]
228%endif
229 pop sDI
230 pop sSI
231 pop sDX
232 pop sCX
233 pop sBX
234 sPOPF
235 leave
236 BS3_HYBRID_RET
237
238 ;
239 ; Failed.
240 ;
241.failed:
242 xor al, al
243 jmp .return
244BS3_PROC_END_MODE Bs3BiosInt15hE820
245
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