VirtualBox

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

Last change on this file since 103068 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1; $Id: bs3-mode-TrapSetJmpAndRestoreInRmAsm.asm 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; BS3Kit - Bs3TrapSetJmpAndRestoreInRm helper
4;
5
6;
7; Copyright (C) 2007-2023 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;* External Symbols *
45;*********************************************************************************************************************************
46BS3_BEGIN_TEXT16
47extern RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_rm)
48extern _Bs3TrapSetJmpAndRestore_c16
49
50TMPL_BEGIN_TEXT
51extern TMPL_NM(Bs3SwitchToRM)
52
53
54;;
55; Shared prologue code.
56; @param xAX Where to jump to for the main event.
57;
58BS3_PROC_BEGIN_MODE Bs3TrapSetJmpAndRestoreInRmAsm, BS3_PBC_NEAR
59 BS3_CALL_CONV_PROLOG 2
60 push xBP
61 mov xBP, xSP
62 xPUSHF
63
64 ;
65 ; Save non-volatile registers so the DO function doesn't have to.
66 ;
67 push xBX
68 push xCX
69 push xDX
70 push xSI
71 push xDI
72%if TMPL_BITS != 64
73 push ds
74 push es
75 push ss
76 %if TMPL_BITS != 16
77 push fs
78 push gs
79 %endif
80%endif
81%if TMPL_BITS == 64
82 push r8
83 push r9
84 push r10
85 push r11
86 push r12
87 push r13
88 push r14
89 push r15
90%endif
91
92 ;
93 ; Load EAX and EDX with the two pointers.
94 ;
95 mov eax, [xBP + xCB + cbCurRetAddr]
96 mov edx, [xBP + xCB + cbCurRetAddr + sCB]
97
98 ;
99 ; Jump to 16-bit segment for the mode switching.
100 ;
101%if TMPL_BITS != 16
102 jmp .in_16bit_segment
103BS3_BEGIN_TEXT16
104 BS3_SET_BITS TMPL_BITS
105.in_16bit_segment:
106%endif
107
108 ;
109 ; Switch to real-mode.
110 ;
111 call TMPL_NM(Bs3SwitchToRM)
112 BS3_SET_BITS 16
113
114 ;
115 ; Now we do the
116 ;
117 push edx
118 push eax
119 call _Bs3TrapSetJmpAndRestore_c16
120 add sp, 8h
121
122 ;
123 ; Switch back to the original mode.
124 ;
125 call RT_CONCAT3(_Bs3SwitchTo,TMPL_MODE_UNAME,_Safe_rm)
126 BS3_SET_BITS TMPL_BITS
127
128 ;
129 ; Jump back to the 32-bit or 64-bit segment.
130 ;
131%if TMPL_BITS != 16
132 jmp .in_text_segment
133TMPL_BEGIN_TEXT
134.in_text_segment:
135%endif
136
137 ;
138 ; Restore registers.
139 ;
140%if TMPL_BITS == 16
141 sub bp, (1+5+3)*2
142 mov sp, bp
143%elif TMPL_BITS == 32
144 lea xSP, [xBP - (1+5+5)*4]
145%else
146 lea xSP, [xBP - (1+5+8)*8]
147 pop r15
148 pop r14
149 pop r13
150 pop r12
151 pop r11
152 pop r10
153 pop r9
154 pop r8
155%endif
156%if TMPL_BITS != 64
157 %if TMPL_BITS != 16
158 pop gs
159 pop fs
160 %endif
161 pop ss
162 pop es
163 pop ds
164%endif
165 pop xDI
166 pop xSI
167 pop xDX
168 pop xCX
169 pop xBX
170 xPOPF
171 pop xBP
172 ret
173BS3_PROC_END_MODE Bs3TrapSetJmpAndRestoreInRmAsm
174
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