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