VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmpAndRestoreInRm.c@ 95491

Last change on this file since 95491 was 95491, checked in by vboxsync, 3 years ago

ValKit/bs3kit: Added Bs3ExtCtxRestoreEx, Bs3ExtCtxSaveEx, Bs3RegCtxConvertV86ToRm, Bs3TrapSetJmpAndRestoreInRm, and BS3TESTMODEBYONEENTRY_F_REAL_MODE_READY so that it is possible to use a 32-bit test driver to do 64-bit testing as well as real-mode. bugref:9898

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