direct-io.hg

view tools/firmware/vmxassist/machine.h @ 7477:5a7baecb1c70

Fix an issue for passing arguement from control panel to deivce model
for some arguemnt like 'localtime', 'isa', device model need an argument
"-localtime", instead of "-localtime 1"
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Oct 23 16:51:47 2005 +0100 (2005-10-23)
parents a83ac0806d6b
children f9e912842006
line source
1 /*
2 * machine.h: Intel CPU specific definitions
3 *
4 * Leendert van Doorn, leendert@watson.ibm.com
5 * Copyright (c) 2005, International Business Machines Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place - Suite 330, Boston, MA 02111-1307 USA.
19 */
20 #ifndef __MACHINE_H__
21 #define __MACHINE_H__
23 /* the size of our stack (4KB) */
24 #define STACK_SIZE 8192
26 #define TSS_SELECTOR 0x08
27 #define CODE_SELECTOR 0x10
28 #define DATA_SELECTOR 0x18
30 #define CR0_PE (1 << 0)
31 #define CR0_EM (1 << 2)
32 #define CR0_TS (1 << 3)
33 #define CR0_NE (1 << 5)
34 #define CR0_PG (1 << 31)
36 #define CR4_VME (1 << 0)
37 #define CR4_PVI (1 << 1)
38 #define CR4_PSE (1 << 4)
40 #define EFLAGS_TF (1 << 8)
41 #define EFLAGS_IF (1 << 9)
42 #define EFLAGS_DF (1 << 10)
43 #define EFLAGS_IOPL (3 << 12)
44 #define EFLAGS_VM ((1 << 17) | EFLAGS_IOPL)
45 #define EFLAGS_VIF (1 << 19)
46 #define EFLAGS_VIP (1 << 20)
48 #define LOG_PGSIZE 12 /* log2(page size) */
49 #define LOG_PDSIZE 22 /* log2(page directory size) */
51 /* Derived constants */
52 #define PGSIZE (1 << LOG_PGSIZE) /* page size */
53 #define PGMASK (~(PGSIZE - 1)) /* page mask */
54 #define LPGSIZE (1 << LOG_PDSIZE) /* large page size */
55 #define LPGMASK (~(LPGSIZE - 1)) /* large page mask */
57 #ifdef TEST
58 #define PTE_P (1 << 0) /* Present */
59 #define PTE_RW (1 << 1) /* Read/Write */
60 #define PTE_US (1 << 2) /* User/Supervisor */
61 #define PTE_PS (1 << 7) /* Page Size */
62 #endif
64 /* Programmable Interrupt Contoller (PIC) defines */
65 #define PIC_MASTER 0x20
66 #define PIC_SLAVE 0xA0
68 #define PIC_CMD 0 /* command */
69 #define PIC_ISR 0 /* interrupt status */
70 #define PIC_IMR 1 /* interrupt mask */
73 #ifndef __ASSEMBLY__
75 struct dtr {
76 unsigned short size;
77 unsigned long base __attribute__ ((packed));
78 };
80 struct tss {
81 unsigned short prev_link;
82 unsigned short _1;
83 unsigned long esp0;
84 unsigned short ss0;
85 unsigned short _2;
86 unsigned long esp1;
87 unsigned short ss1;
88 unsigned short _3;
89 unsigned long esp2;
90 unsigned short ss2;
91 unsigned short _4;
92 unsigned long cr3;
93 unsigned long eip;
94 unsigned long eflags;
95 unsigned long eax;
96 unsigned long ecx;
97 unsigned long edx;
98 unsigned long ebx;
99 unsigned long esi;
100 unsigned long edi;
101 unsigned long esp;
102 unsigned long ebp;
103 unsigned long es;
104 unsigned long cs;
105 unsigned long ss;
106 unsigned long ds;
107 unsigned long fs;
108 unsigned long gs;
109 unsigned short ldt_segment;
110 unsigned short _5;
111 unsigned short _6;
112 unsigned short iomap_base;
113 #ifdef ENABLE_VME
114 unsigned long int_redir[8];
115 #endif
116 unsigned char iomap[8192];
117 };
119 static inline void
120 outw(unsigned short addr, unsigned short val)
121 {
122 __asm__ __volatile__ ("outw %%ax, %%dx" :: "d"(addr), "a"(val));
123 }
125 static inline void
126 outb(unsigned short addr, unsigned char val)
127 {
128 __asm__ __volatile__ ("outb %%al, %%dx" :: "d"(addr), "a"(val));
129 }
131 static inline unsigned char
132 inb(unsigned short addr)
133 {
134 unsigned char val;
136 __asm__ __volatile__ ("inb %w1,%0" : "=a" (val) : "Nd" (addr));
137 return val;
138 }
140 static inline unsigned
141 get_cmos(int reg)
142 {
143 outb(0x70, reg);
144 return inb(0x71);
145 }
147 static inline unsigned
148 get_cr0(void)
149 {
150 unsigned rv;
151 __asm__ __volatile__("movl %%cr0, %0" : "=r"(rv));
152 return rv;
153 }
155 static inline void
156 set_cr0(unsigned value)
157 {
158 __asm__ __volatile__(
159 "movl %0, %%cr0\n"
160 "jmp 1f\n"
161 "1: nop\n"
162 : /* no outputs */
163 : "r"(value)
164 );
165 }
167 static inline unsigned
168 get_cr2(void)
169 {
170 unsigned rv;
172 __asm__ __volatile__("movl %%cr2, %0" : "=r"(rv));
173 return rv;
174 }
176 static inline unsigned
177 get_cr4(void)
178 {
179 unsigned rv;
180 __asm__ __volatile__("movl %%cr4, %0" : "=r"(rv));
181 return rv;
182 }
184 static inline void
185 set_cr3(unsigned addr)
186 {
187 __asm__ __volatile__("movl %0, %%cr3" : /* no outputs */ : "r"(addr));
188 }
190 static inline void
191 set_cr4(unsigned value)
192 {
193 __asm__ __volatile__("movl %0, %%cr4" : /* no outputs */ : "r"(value));
194 }
196 #ifdef TEST
197 static inline void
198 breakpoint(void)
199 {
200 outw(0x8A00, 0x8AE0);
201 }
202 #endif /* TEST */
204 #endif /* __ASSEMBLY__ */
206 #endif /* __MACHINE_H__ */