2 * machine.h: Intel CPU specific definitions
4 * Leendert van Doorn, leendert@watson.ibm.com
5 * Copyright (c) 2005, International Business Machines Corporation.
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.
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
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.
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)
39 #define CR4_PAE (1 << 5)
41 #define EFLAGS_CF (1 << 0)
42 #define EFLAGS_PF (1 << 2)
43 #define EFLAGS_AF (1 << 4)
44 #define EFLAGS_ZF (1 << 6)
45 #define EFLAGS_SF (1 << 7)
46 #define EFLAGS_TF (1 << 8)
47 #define EFLAGS_IF (1 << 9)
48 #define EFLAGS_DF (1 << 10)
49 #define EFLAGS_OF (1 << 11)
50 #define EFLAGS_IOPL (3 << 12)
51 #define EFLAGS_VM ((1 << 17) | EFLAGS_IOPL)
52 #define EFLAGS_VIF (1 << 19)
53 #define EFLAGS_VIP (1 << 20)
55 #define LOG_PGSIZE 12 /* log2(page size) */
56 #define LOG_PDSIZE 22 /* log2(page directory size) */
58 /* Derived constants */
59 #define PGSIZE (1 << LOG_PGSIZE) /* page size */
60 #define PGMASK (~(PGSIZE - 1)) /* page mask */
61 #define LPGSIZE (1 << LOG_PDSIZE) /* large page size */
62 #define LPGMASK (~(LPGSIZE - 1)) /* large page mask */
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 */
77 unsigned long base __attribute__ ((packed));
81 unsigned short prev_link;
109 unsigned short ldt_segment;
112 unsigned short iomap_base;
114 unsigned long int_redir[8];
116 unsigned char iomap[8193];
120 outw(unsigned short addr, unsigned short val)
122 __asm__ __volatile__ ("outw %%ax, %%dx" :: "d"(addr), "a"(val));
126 outb(unsigned short addr, unsigned char val)
128 __asm__ __volatile__ ("outb %%al, %%dx" :: "d"(addr), "a"(val));
131 static inline unsigned char
132 inb(unsigned short addr)
136 __asm__ __volatile__ ("inb %w1,%0" : "=a" (val) : "Nd" (addr));
140 static inline unsigned
147 static inline unsigned
151 __asm__ __volatile__("movl %%cr0, %0" : "=r"(rv));
156 set_cr0(unsigned value)
158 __asm__ __volatile__(
167 static inline unsigned
172 __asm__ __volatile__("movl %%cr2, %0" : "=r"(rv));
176 static inline unsigned
180 __asm__ __volatile__("movl %%cr4, %0" : "=r"(rv));
185 set_cr3(unsigned addr)
187 __asm__ __volatile__("movl %0, %%cr3" : /* no outputs */ : "r"(addr));
191 set_cr4(unsigned value)
193 __asm__ __volatile__("movl %0, %%cr4" : /* no outputs */ : "r"(value));
196 #endif /* __ASSEMBLY__ */
198 #endif /* __MACHINE_H__ */