1 | /* $Id: bs3-cmn-TrapSetJmpAndRestoreInRm.c 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - Bs3TrapSetJmpAndRestoreInRm
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-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 | /*********************************************************************************************************************************
|
---|
39 | * Header Files *
|
---|
40 | *********************************************************************************************************************************/
|
---|
41 | #include "bs3kit-template-header.h"
|
---|
42 |
|
---|
43 |
|
---|
44 | /*********************************************************************************************************************************
|
---|
45 | * Internal Functions *
|
---|
46 | *********************************************************************************************************************************/
|
---|
47 | /* assembly helpers */
|
---|
48 | BS3_MODE_PROTO_NOSB(void, Bs3TrapSetJmpAndRestoreInRmAsm, (uint32_t, uint32_t));
|
---|
49 |
|
---|
50 |
|
---|
51 | #undef Bs3TrapSetJmpAndRestoreInRm
|
---|
52 | BS3_CMN_DEF(void, Bs3TrapSetJmpAndRestoreInRm,(PCBS3REGCTX pCtxRestore, PBS3TRAPFRAME pTrapFrame))
|
---|
53 | {
|
---|
54 | #if TMPL_BITS == 16
|
---|
55 | if (g_bBs3CurrentMode == BS3_MODE_RM)
|
---|
56 | Bs3TrapSetJmpAndRestore(pCtxRestore, pTrapFrame);
|
---|
57 | else
|
---|
58 | #endif
|
---|
59 | {
|
---|
60 | uint32_t const pfRealModeCtxRestore = Bs3SelFlatDataToRealMode(Bs3SelPtrToFlat((PBS3REGCTX)pCtxRestore));
|
---|
61 | uint32_t const pfRealModeTrapFrame = Bs3SelFlatDataToRealMode(Bs3SelPtrToFlat(pTrapFrame));
|
---|
62 |
|
---|
63 | #if TMPL_BITS == 16
|
---|
64 | switch (g_bBs3CurrentMode & BS3_MODE_SYS_MASK)
|
---|
65 | {
|
---|
66 | case BS3_MODE_SYS_PE16:
|
---|
67 | Bs3TrapSetJmpAndRestoreInRmAsm_pe16(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
68 | break;
|
---|
69 | case BS3_MODE_SYS_PE32:
|
---|
70 | Bs3TrapSetJmpAndRestoreInRmAsm_pe32_16(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
71 | break;
|
---|
72 | case BS3_MODE_SYS_PP16:
|
---|
73 | Bs3TrapSetJmpAndRestoreInRmAsm_pp16(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
74 | break;
|
---|
75 | case BS3_MODE_SYS_PP32:
|
---|
76 | Bs3TrapSetJmpAndRestoreInRmAsm_pp32_16(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
77 | break;
|
---|
78 | case BS3_MODE_SYS_PAE16:
|
---|
79 | Bs3TrapSetJmpAndRestoreInRmAsm_pae16(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
80 | break;
|
---|
81 | case BS3_MODE_SYS_PAE32:
|
---|
82 | Bs3TrapSetJmpAndRestoreInRmAsm_pae32_16(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
83 | break;
|
---|
84 | case BS3_MODE_SYS_LM:
|
---|
85 | Bs3TrapSetJmpAndRestoreInRmAsm_lm16(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
86 | break;
|
---|
87 | default:
|
---|
88 | BS3_ASSERT(0);
|
---|
89 | }
|
---|
90 |
|
---|
91 | #elif TMPL_BITS == 32
|
---|
92 | switch (g_bBs3CurrentMode & BS3_MODE_SYS_MASK)
|
---|
93 | {
|
---|
94 | case BS3_MODE_SYS_PE16:
|
---|
95 | Bs3TrapSetJmpAndRestoreInRmAsm_pe16_32(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
96 | break;
|
---|
97 | case BS3_MODE_SYS_PE32:
|
---|
98 | Bs3TrapSetJmpAndRestoreInRmAsm_pe32(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
99 | break;
|
---|
100 | case BS3_MODE_SYS_PP16:
|
---|
101 | Bs3TrapSetJmpAndRestoreInRmAsm_pp16_32(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
102 | break;
|
---|
103 | case BS3_MODE_SYS_PP32:
|
---|
104 | Bs3TrapSetJmpAndRestoreInRmAsm_pp32(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
105 | break;
|
---|
106 | case BS3_MODE_SYS_PAE16:
|
---|
107 | Bs3TrapSetJmpAndRestoreInRmAsm_pae16_32(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
108 | break;
|
---|
109 | case BS3_MODE_SYS_PAE32:
|
---|
110 | Bs3TrapSetJmpAndRestoreInRmAsm_pae32(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
111 | break;
|
---|
112 | case BS3_MODE_SYS_LM:
|
---|
113 | Bs3TrapSetJmpAndRestoreInRmAsm_lm32(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
114 | break;
|
---|
115 | default:
|
---|
116 | BS3_ASSERT(0);
|
---|
117 | }
|
---|
118 |
|
---|
119 | #elif TMPL_BITS == 64
|
---|
120 | switch (g_bBs3CurrentMode & BS3_MODE_SYS_MASK)
|
---|
121 | {
|
---|
122 | case BS3_MODE_SYS_LM:
|
---|
123 | Bs3TrapSetJmpAndRestoreInRmAsm_lm64(pfRealModeCtxRestore, pfRealModeTrapFrame);
|
---|
124 | break;
|
---|
125 | default:
|
---|
126 | BS3_ASSERT(0);
|
---|
127 | }
|
---|
128 | #else
|
---|
129 | # error Bogus TMPL_BITS
|
---|
130 | #endif
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|