VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/TRPMR0A.asm@ 400

Last change on this file since 400 was 400, checked in by vboxsync, 18 years ago

fixed

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1; $Id: TRPMR0A.asm 400 2007-01-28 03:21:49Z vboxsync $
2;; @file
3; TRPM - Host Context Ring-0
4;
5
6;
7; Copyright (C) 2006 InnoTek Systemberatung GmbH
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 as published by the Free Software Foundation,
13; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14; distribution. VirtualBox OSE is distributed in the hope that it will
15; be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; If you received this file as part of a commercial VirtualBox
18; distribution, then only the terms of your commercial VirtualBox
19; license agreement apply instead of the previous paragraph.
20;
21
22;*******************************************************************************
23;* Header Files *
24;*******************************************************************************
25%include "VBox/asmdefs.mac"
26%include "VBox/x86.mac"
27
28
29BEGINCODE
30 align 16
31
32;;
33; Calls the interrupt gate as if we received an interrupt while in Ring-0.
34;
35; Returns with interrupts enabled.
36;
37; @param uIP x86:[ebp+8] msc:rcx gcc:rdi The interrupt gate IP.
38; @param SelCS x86:[ebp+12] msc:dx gcc:si The interrupt gate CS.
39; @param RSP msc:r8 gcc:rdx The interrupt gate RSP. ~0 if no stack switch should take place. (only AMD64)
40;DECLASM(void) trpmR0DispatchHostInterrupt(RTR0UINTPTR uIP, RTSEL SelCS, RTR0UINTPTR RSP);
41BEGINPROC trpmR0DispatchHostInterrupt
42 push xBP
43 mov xBP, xSP
44
45%ifdef __AMD64__
46 mov rax, rsp
47 and rsp, 15h ; align the stack. (do it unconditionally saves some jump mess)
48
49 ; switch stack?
50 %ifdef ASM_CALL64_MSC
51 cmp r8, 0ffffffffffffffffh
52 je .no_stack_switch
53 mov rsp, r8
54 %else
55 cmp rdx, 0ffffffffffffffffh
56 je .no_stack_switch
57 mov rsp, rdx
58 %endif
59.no_stack_switch:
60
61 ; create the iret frame
62 push 0 ; SS
63 push rax ; RSP
64 pushfd ; RFLAGS
65 and dword [rsp], ~X86_EFL_IF
66 mov ax, cs
67 push rax ; CS
68 mov rax, .return ; RIP
69 push rax
70
71 ; create the retf frame
72 %ifdef ASM_CALL64_MSC
73 movzx rdx, dx
74 push rdx
75 push rcx
76 %else
77 movzx rdi, di
78 push rdi
79 push rsi
80 %endif
81
82 ; dispatch it!
83 db 048h
84 retf
85
86%else ; 32-bit:
87 mov ecx, [ebp + 8] ; uIP
88 movzx edx, word [ebp + 12] ; SelCS
89
90 ; create the iret frame
91 pushfd ; EFLAGS
92 and dword [esp], ~X86_EFL_IF
93 push cs ; CS
94 push .return ; EIP
95
96 ; create the retf frame
97 push edx
98 push ecx
99
100 ; dispatch it!
101 retf
102%endif
103.return:
104
105 leave
106 ret
107ENDPROC trpmR0DispatchHostInterrupt
108
109
110%ifndef VBOX_WITHOUT_IDT_PATCHING
111
112 align 16
113;;
114; This is the alternative return from VMMR0Entry() used when
115; we need to dispatch an interrupt to the Host (we received it in GC).
116;
117; As seen in TRPMR0SetupInterruptDispatcherFrame() the stack is different
118; than for the normal VMMR0Entry() return.
119;
120; 32-bit:
121; 18 iret frame
122; 14 retf selector (interrupt handler)
123; 10 retf offset (interrupt handler)
124; c es
125; 8 fs
126; 4 ds
127; 0 pVM (esp here)
128;
129; 64-bit:
130; 24 iret frame
131; 18 retf selector (interrupt handler)
132; 10 retf offset (interrupt handler)
133; 8 uOperation
134; 0 pVM
135;
136BEGINPROC trpmR0InterruptDispatcher
137%ifdef __AMD64__
138 lea rsp, [rsp + 10h] ; skip pVM and uOperation
139 db 48h
140 retf
141%else ; !__AMD64__
142 add esp, byte 4 ; skip pVM
143 pop ds
144 pop fs
145 pop es
146 retf
147%endif ; !__AMD64__
148ENDPROC trpmR0InterruptDispatcher
149
150%endif ; !VBOX_WITHOUT_IDT_PATCHING
151
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