VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-TrapSetJmp.asm@ 69111

Last change on this file since 69111 was 69111, checked in by vboxsync, 7 years ago

(C) year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1; $Id: bs3-cmn-TrapSetJmp.asm 69111 2017-10-17 14:26:02Z vboxsync $
2;; @file
3; BS3Kit - Bs3TrapSetJmp.
4;
5
6;
7; Copyright (C) 2007-2017 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.mac"
32
33
34;*********************************************************************************************************************************
35;* External Symbols *
36;*********************************************************************************************************************************
37BS3_EXTERN_CMN Bs3RegCtxSave
38%if TMPL_BITS == 16
39BS3_EXTERN_CMN_FAR Bs3SelFar32ToFlat32
40%endif
41BS3_EXTERN_DATA16 g_Bs3TrapSetJmpCtx
42BS3_EXTERN_DATA16 g_pBs3TrapSetJmpFrame
43TMPL_BEGIN_TEXT
44
45
46;;
47; Sets up a one-shot set-jmp-on-trap.
48;
49; @uses See, applicable C calling convention.
50;
51BS3_PROC_BEGIN_CMN Bs3TrapSetJmp, BS3_PBC_HYBRID
52 BS3_CALL_CONV_PROLOG 1
53 push xBP
54 mov xBP, xSP
55 push xBX
56BONLY64 sub xSP, 20h
57
58 ;
59 ; Save the current register context.
60 ;
61BONLY16 push ds
62 BS3_LEA_MOV_WRT_RIP(xAX, BS3_DATA16_WRT(g_Bs3TrapSetJmpCtx))
63 push xAX
64 BS3_CALL Bs3RegCtxSave, 1
65 add xSP, sCB
66
67 ;
68 ; Adjust the return context a little.
69 ;
70 BS3_LEA_MOV_WRT_RIP(xBX, BS3_DATA16_WRT(g_Bs3TrapSetJmpCtx))
71 mov xAX, [xBP + xCB] ; The return address of this function
72 mov [xBX + BS3REGCTX.rip], xAX
73%if TMPL_BITS == 16
74 mov xAX, [xBP + xCB+2] ; The return address CS of this function.
75 mov [xBX + BS3REGCTX.cs], xAX
76%endif
77 mov xAX, [xBP]
78 mov [xBX + BS3REGCTX.rbp], xAX
79 lea xAX, [xBP + xCB + cbCurRetAddr]
80 mov [xBX + BS3REGCTX.rsp], xAX
81 mov xAX, [xBP - xCB]
82 mov [xBX + BS3REGCTX.rbx], xAX
83 xor xAX, xAX
84 mov [xBX + BS3REGCTX.rax], xAX ; the return value.
85
86 ;
87 ; Fill the trap frame return structure.
88 ;
89 push xDI
90%if TMPL_BITS == 16
91 push es
92 les di, [xBP + xCB + cbCurRetAddr]
93 mov cx, BS3TRAPFRAME_size / 2
94 mov ax, 0faceh
95 rep stosw
96 pop es
97%else
98 mov xDI, [xBP + xCB*2]
99 mov ecx, BS3TRAPFRAME_size / 4
100 mov xAX, 0feedfaceh
101 rep stosd
102%endif
103 pop xDI
104
105 ;
106 ; Save the (flat) pointer to the trap frame return structure.
107 ;
108%if TMPL_BITS == 16
109 xor ax, ax
110 push word [xBP + xCB + cbCurRetAddr + 2]
111 push ax
112 push word [xBP + xCB + cbCurRetAddr]
113 push cs
114 call Bs3SelFar32ToFlat32
115 add sp, 6h
116 mov [BS3_DATA16_WRT(g_pBs3TrapSetJmpFrame)], ax
117 mov [2 + BS3_DATA16_WRT(g_pBs3TrapSetJmpFrame)], dx
118%else
119 mov xAX, [xBP + xCB*2]
120 mov [BS3_DATA16_WRT(g_pBs3TrapSetJmpFrame)], eax
121%endif
122
123 ;
124 ; Return 'true'.
125 ;
126 mov xAX, 1
127BONLY64 add xSP, 20h
128 pop xBX
129 pop xBP
130 BS3_CALL_CONV_EPILOG 1
131 BS3_HYBRID_RET
132BS3_PROC_END_CMN Bs3TrapSetJmp
133
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