VirtualBox

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

Last change on this file since 25062 was 22949, checked in by vboxsync, 15 years ago

TRPMR0A.asm: Align the trpmR0DispatchHostInterruptSimple code better.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1; $Id: TRPMR0A.asm 22949 2009-09-11 10:14:48Z vboxsync $
2;; @file
3; TRPM - Host Context Ring-0
4;
5
6;
7; Copyright (C) 2006-2007 Sun Microsystems, Inc.
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; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18; Clara, CA 95054 USA or visit http://www.sun.com if you need
19; additional information or have any questions.
20;
21
22;*******************************************************************************
23;* Header Files *
24;*******************************************************************************
25%include "VBox/asmdefs.mac"
26%include "VBox/x86.mac"
27
28
29BEGINCODE
30
31;;
32; Calls the interrupt gate as if we received an interrupt while in Ring-0.
33;
34; @param uIP x86:[ebp+8] msc:rcx gcc:rdi The interrupt gate IP.
35; @param SelCS x86:[ebp+12] msc:dx gcc:si The interrupt gate CS.
36; @param RSP msc:r8 gcc:rdx The interrupt gate RSP. ~0 if no stack switch should take place. (only AMD64)
37;DECLASM(void) trpmR0DispatchHostInterrupt(RTR0UINTPTR uIP, RTSEL SelCS, RTR0UINTPTR RSP);
38ALIGNCODE(16)
39BEGINPROC trpmR0DispatchHostInterrupt
40 push xBP
41 mov xBP, xSP
42
43%ifdef RT_ARCH_AMD64
44 mov r11, rsp ; save the RSP for the iret frame.
45 and rsp, 0fffffffffffffff0h ; align the stack. (do it unconditionally saves some jump mess)
46
47 ; switch stack?
48 %ifdef ASM_CALL64_MSC
49 cmp r8, 0ffffffffffffffffh
50 je .no_stack_switch
51 mov rsp, r8
52 %else
53 cmp rdx, 0ffffffffffffffffh
54 je .no_stack_switch
55 mov rsp, rdx
56 %endif
57.no_stack_switch:
58
59 ; create the iret frame
60 push 0 ; SS
61 push r11 ; RSP
62 pushfq ; RFLAGS
63 and dword [rsp], ~X86_EFL_IF
64 mov ax, cs
65 push rax ; CS
66 lea r10, [.return wrt rip] ; RIP
67 push r10
68
69 ; create the retf frame
70 %ifdef ASM_CALL64_MSC
71 movzx rdx, dx
72 cmp rdx, r11
73 je .dir_jump
74 push rdx
75 push rcx
76 %else
77 movzx rsi, si
78 cmp rsi, r11
79 je .dir_jump
80 push rsi
81 push rdi
82 %endif
83
84 ; dispatch it
85 db 048h
86 retf
87
88 ; dispatch it by a jmp (don't mess up the IST stack)
89.dir_jump:
90 %ifdef ASM_CALL64_MSC
91 jmp rcx
92 %else
93 jmp rdi
94 %endif
95
96%else ; 32-bit:
97 mov ecx, [ebp + 8] ; uIP
98 movzx edx, word [ebp + 12] ; SelCS
99
100 ; create the iret frame
101 pushfd ; EFLAGS
102 and dword [esp], ~X86_EFL_IF
103 push cs ; CS
104 push .return ; EIP
105
106 ; create the retf frame
107 push edx
108 push ecx
109
110 ; dispatch it!
111 retf
112%endif
113.return:
114 cli
115
116 leave
117 ret
118ENDPROC trpmR0DispatchHostInterrupt
119
120
121;;
122; Issues a software interrupt to the specified interrupt vector.
123;
124; @param uActiveVector x86:[esp+4] msc:rcx gcc:rdi The vector number.
125;
126;DECLASM(void) trpmR0DispatchHostInterruptSimple(RTUINT uActiveVector);
127ALIGNCODE(16)
128BEGINPROC trpmR0DispatchHostInterruptSimple
129%ifdef RT_ARCH_X86
130 mov eax, [esp + 4]
131 jmp dword [.jmp_table + eax * 4]
132%else
133 lea r9, [.jmp_table wrt rip]
134 %ifdef ASM_CALL64_MSC
135 jmp qword [r9 + rcx * 8]
136 %else
137 jmp qword [r9 + rdi * 8]
138 %endif
139%endif
140
141ALIGNCODE(4)
142.jmp_table:
143%assign i 0
144%rep 256
145RTCCPTR_DEF .int_ %+ i
146%assign i i+1
147%endrep
148
149%assign i 0
150%rep 256
151 ALIGNCODE(4)
152.int_ %+ i:
153 int i
154 ret
155%assign i i+1
156%endrep
157
158ENDPROC trpmR0DispatchHostInterruptSimple
159
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