VirtualBox

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

Last change on this file since 60194 was 60194, checked in by vboxsync, 9 years ago

bs3kit: updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1; $Id: bs3-cmn-TrapSetJmp.asm 60194 2016-03-26 13:17:53Z vboxsync $
2;; @file
3; BS3Kit - Bs3TrapSetJmp.
4;
5
6;
7; Copyright (C) 2007-2016 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 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
52 BS3_CALL_CONV_PROLOG 1
53 push xBP
54 mov xBP, xSP
55 push xBX
56 BS3_ONLY_64BIT_STMT sub xSP, 20h
57
58 ;
59 ; Save the current register context.
60 ;
61 BS3_ONLY_16BIT_STMT 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 mov xAX, [xBP]
74 mov [xBX + BS3REGCTX.rbp], xAX
75 lea xAX, [xBP + xCB*2]
76 mov [xBX + BS3REGCTX.rsp], xAX
77 mov xAX, [xBP - xCB]
78 mov [xBX + BS3REGCTX.rbx], xAX
79 xor xAX, xAX
80 mov [xBX + BS3REGCTX.rax], xAX ; the return value.
81
82 ;
83 ; Fill the trap frame return structure.
84 ;
85 push xDI
86%if TMPL_BITS == 16
87 push es
88 les di, [xBP + xCB*2]
89 mov cx, BS3TRAPFRAME_size / 2
90 mov ax, 0faceh
91 rep stosw
92 pop es
93%else
94 mov xDI, [xBP + xCB*2]
95 mov ecx, BS3TRAPFRAME_size / 4
96 mov xAX, 0feedfaceh
97 rep stosd
98%endif
99 pop xDI
100
101 ;
102 ; Save the (flat) pointer to the trap frame return structure.
103 ;
104%if TMPL_BITS == 16
105 xor ax, ax
106 push word [xBP + xCB*2 + 2]
107 push ax
108 push word [xBP + xCB*2]
109 call Bs3SelFar32ToFlat32
110 add sp, 6h
111 mov [BS3_DATA16_WRT(g_pBs3TrapSetJmpFrame)], ax
112 mov [2 + BS3_DATA16_WRT(g_pBs3TrapSetJmpFrame)], dx
113%else
114 mov xAX, [xBP + xCB*2]
115 mov [BS3_DATA16_WRT(g_pBs3TrapSetJmpFrame)], eax
116%endif
117
118 ;
119 ; Return 'true'.
120 ;
121 mov xAX, 1
122 BS3_ONLY_64BIT_STMT add xSP, 20h
123 pop xBX
124 pop xBP
125 BS3_CALL_CONV_EPILOG 1
126 ret
127BS3_PROC_END_CMN Bs3TrapSetJmp
128
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