Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


8b22b5d1036061f787e54ccc17d3516a8c4b557c
[palacios.git] / palacios / src / palacios / vmm_lowlevel.asm
1 ; -*- fundamental -*-
2 ;;
3 ;; This file is part of the Palacios Virtual Machine Monitor developed
4 ;; by the V3VEE Project with funding from the United States National 
5 ;; Science Foundation and the Department of Energy.  
6 ;;
7 ;; The V3VEE Project is a joint project between Northwestern University
8 ;; and the University of New Mexico.  You can find out more at 
9 ;; http://www.v3vee.org
10 ;;
11 ;; Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
12 ;; Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
13 ;; All rights reserved.
14 ;;
15 ;; Author: Jack Lange <jarusl@cs.northwestern.edu>
16 ;;
17 ;; This is free software.  You are permitted to use,
18 ;; redistribute, and modify it as specified in the file "V3VEE_LICENSE"
19 ;;
20
21 %ifndef VMM_ASM
22 %define VMM_ASM
23
24 %include "vmm_symbol.asm"
25
26 EXPORT DisableInts
27 EXPORT EnableInts
28
29 EXPORT GetGDTR
30 EXPORT GetIDTR
31 EXPORT GetTR
32
33
34 ; CPUID functions
35 EXPORT cpuid_ecx
36 EXPORT cpuid_eax
37 EXPORT cpuid_edx
38
39 ; Utility Functions
40 EXPORT Set_MSR
41 EXPORT Get_MSR
42
43
44
45 align 8
46 DisableInts:
47         cli
48         ret
49
50
51 align 8
52 EnableInts:
53         sti
54         ret
55
56 align 8
57 GetGDTR:
58         push    ebp
59         mov     ebp, esp
60         pusha   
61         mov     ebx, [ebp + 8]
62         sgdt    [ebx]
63         
64         popa
65         pop     ebp
66         ret
67
68
69 align 8
70 GetIDTR:
71         push    ebp
72         mov     ebp, esp
73         pusha   
74
75         mov     ebx, [ebp + 8]
76         sidt    [ebx]
77         
78         popa
79         pop     ebp
80         ret
81
82
83
84 align 8
85 GetTR:
86         push    ebp
87         mov     ebp, esp
88         pusha   
89         mov     ebx, [ebp + 8]
90         str     [ebx]
91         
92         popa
93         pop     ebp
94         ret
95
96
97 ;
98 ; cpuid_edx - return the edx register from cpuid
99 ;
100 align 8
101 cpuid_edx:
102         push    ebp
103         mov     ebp, esp
104         push    edx
105         push    ecx
106         push    ebx
107
108         mov     eax, [ebp + 8]
109         cpuid
110         mov     eax, edx
111
112         pop     ebx
113         pop     ecx
114         pop     edx
115         pop     ebp
116         ret
117
118
119 ;
120 ; cpuid_ecx - return the ecx register from cpuid
121 ;
122 align 8
123 cpuid_ecx:
124         push    ebp
125         mov     ebp, esp
126         push    edx
127         push    ecx
128         push    ebx
129
130         mov     eax, [ebp + 8]
131         cpuid
132         mov     eax, ecx
133
134         pop     ebx
135         pop     ecx
136         pop     edx
137         pop     ebp
138         ret
139
140 ;
141 ; cpuid_eax - return the eax register from cpuid
142 ;
143 align 8
144 cpuid_eax:
145         push    ebp
146         mov     ebp, esp
147         push    edx
148         push    ecx
149         push    ebx
150
151         mov     eax, [esp+4]
152         cpuid
153
154         pop     ebx
155         pop     ecx
156         pop     edx
157         pop     ebp
158         ret
159
160 ;
161 ; Set_MSR  - Set the value of a given MSR
162 ;
163 align 8
164 Set_MSR:
165         push    ebp
166         mov     ebp, esp
167         pusha
168         mov     eax, [ebp+16]
169         mov     edx, [ebp+12]
170         mov     ecx, [ebp+8]
171         wrmsr
172         popa
173         pop     ebp
174         ret
175
176
177
178 ;
179 ; Get_MSR  -  Get the value of a given MSR
180 ; void Get_MSR(int MSR, void * high_byte, void * low_byte);
181 ;
182 align 8
183 Get_MSR:
184         push    ebp
185         mov     ebp, esp
186         pusha
187         mov     ecx, [ebp+8]
188         rdmsr
189         mov     ebx, [ebp+12]
190         mov     [ebx], edx
191         mov     ebx, [ebp+16]
192         mov     [ebx], eax
193         popa
194         pop     ebp
195         ret
196
197
198
199
200
201 %endif