VirtualBox

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

Last change on this file since 399 was 399, 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 399 2007-01-28 03:09:35Z 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 push cs ; CS
67 mov rax, .return ; RIP
68 push rax
69
70 ; create the retf frame
71 %ifdef ASM_CALL64_MSC
72 movzx rdx, dx
73 push rdx
74 push rcx
75 %else
76 movzx rdi, di
77 push rdi
78 push rsi
79 %endif
80
81 ; dispatch it!
82 db 048h
83 retf
84
85%else ; 32-bit:
86 mov ecx, [ebp + 8] ; uIP
87 movzx edx, word [ebp + 12] ; SelCS
88
89 ; create the iret frame
90 pushfd ; EFLAGS
91 and dword [esp], ~X86_EFL_IF
92 push cs ; CS
93 push .return ; EIP
94
95 ; create the retf frame
96 push edx
97 push ecx
98
99 ; dispatch it!
100 retf
101%endif
102.return:
103
104 leave
105 ret
106ENDPROC trpmR0DispatchHostInterrupt
107
108
109%ifndef VBOX_WITHOUT_IDT_PATCHING
110
111 align 16
112;;
113; This is the alternative return from VMMR0Entry() used when
114; we need to dispatch an interrupt to the Host (we received it in GC).
115;
116; As seen in TRPMR0SetupInterruptDispatcherFrame() the stack is different
117; than for the normal VMMR0Entry() return.
118;
119; 32-bit:
120; 18 iret frame
121; 14 retf selector (interrupt handler)
122; 10 retf offset (interrupt handler)
123; c es
124; 8 fs
125; 4 ds
126; 0 pVM (esp here)
127;
128; 64-bit:
129; 24 iret frame
130; 18 retf selector (interrupt handler)
131; 10 retf offset (interrupt handler)
132; 8 uOperation
133; 0 pVM
134;
135BEGINPROC trpmR0InterruptDispatcher
136%ifdef __AMD64__
137 lea rsp, [rsp + 10h] ; skip pVM and uOperation
138 db 48h
139 retf
140%else ; !__AMD64__
141 add esp, byte 4 ; skip pVM
142 pop ds
143 pop fs
144 pop es
145 retf
146%endif ; !__AMD64__
147ENDPROC trpmR0InterruptDispatcher
148
149%endif ; !VBOX_WITHOUT_IDT_PATCHING
150
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