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.


b7f46fafe2214800457a2ed94a1ab945d2e39de9
[palacios.git] / palacios / include / palacios / vmm_lowlevel.h
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #include <palacios/vmm_types.h>
21
22
23 #ifdef __V3_32BIT__
24
25 void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx, addr_t * edx) {
26     __asm__ __volatile__ (
27                           "pushl %%ebx\n\t"
28                           "cpuid\n\t"
29                           "movl %%ebx, %%esi\n\t"
30                           "popl %%ebx\n\t"
31                           : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
32                           : "a" (target)
33                           );
34     return;
35 }
36
37 #elif __V3_64BIT__
38
39 void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx, addr_t * edx) {
40     __asm__ __volatile__ (
41                           "pushq %%rbx\n\t"
42                           "cpuid\n\t"
43                           "movq %%rbx, %%rsi\n\t"
44                           "popq %%rbx\n\t"
45                           : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
46                           : "a" (target)
47                           );
48     return;
49 }
50
51 #endif
52
53
54 void __inline__ v3_set_msr(uint_t msr, uint_t high_byte, uint_t low_byte) {
55     __asm__ __volatile__ (
56                           "wrmsr"
57                           : 
58                           : "c" (msr), "d" (high_byte), "a" (low_byte)
59                           );
60
61
62 }
63
64
65
66 void __inline__ v3_get_msr(uint_t msr, uint_t * high_byte, uint_t * low_byte) {
67     __asm__ __volatile__ (
68                           "rdmsr"
69                           : "=d" (*high_byte), "=a" (*low_byte) 
70                           : "c" (msr)
71                           );
72 }
73
74
75
76 void __inline__ v3_enable_ints() {
77     __asm__ __volatile__ ("sti");
78 }
79
80 void __inline__ v3_disable_ints() {
81     __asm__ __volatile__ ("cli");
82 }
83