- Update romcc to version 0.27
[coreboot.git] / src / arch / i386 / include / arch / romcc_io.h
1 static void outb(unsigned char value, unsigned short port)
2 {
3         __builtin_outb(value, port);
4 }
5
6 static void outw(unsigned short value, unsigned short port)
7 {
8         __builtin_outw(value, port);
9 }
10
11 static void outl(unsigned int value, unsigned short port)
12 {
13         __builtin_outl(value, port);
14 }
15
16
17 static unsigned char inb(unsigned short port)
18 {
19         return __builtin_inb(port);
20 }
21
22
23 static unsigned char inw(unsigned short port)
24 {
25         return __builtin_inw(port);
26 }
27
28 static unsigned char inl(unsigned short port)
29 {
30         return __builtin_inl(port);
31 }
32
33 static void hlt(void)
34 {
35         __builtin_hlt();
36 }
37
38 typedef __builtin_msr_t msr_t;
39
40 static msr_t rdmsr(unsigned long index)
41 {
42         return __builtin_rdmsr(index);
43 }
44
45 static void wrmsr(unsigned long index, msr_t msr)
46 {
47         __builtin_wrmsr(index, msr.lo, msr.hi);
48 }
49
50 #define PCI_ADDR(BUS, DEV, FN, WHERE) ( \
51         (((BUS) & 0xFF) << 16) | \
52         (((DEV) & 0x1f) << 11) | \
53         (((FN) & 0x07) << 8) | \
54         ((WHERE) & 0xFF))
55
56 static unsigned char pci_read_config8(unsigned addr)
57 {
58         outl(0x80000000 | (addr & ~3), 0xCF8);
59         return inb(0xCFC + (addr & 3));
60 }
61
62 static unsigned short pci_read_config16(unsigned addr)
63 {
64         outl(0x80000000 | (addr & ~3), 0xCF8);
65         return inw(0xCFC + (addr & 2));
66 }
67
68 static unsigned int pci_read_config32(unsigned addr)
69 {
70         outl(0x80000000 | (addr & ~3), 0xCF8);
71         return inl(0xCFC);
72 }
73
74 static void pci_write_config8(unsigned addr, unsigned char value)
75 {
76         outl(0x80000000 | (addr & ~3), 0xCF8);
77         outb(value, 0xCFC + (addr & 3));
78 }
79
80 static void pci_write_config16(unsigned addr, unsigned short value)
81 {
82         outl(0x80000000 | (addr & ~3), 0xCF8);
83         outw(value, 0xCFC + (addr & 2));
84 }
85
86 static void pci_write_config32(unsigned addr, unsigned int value)
87 {
88         outl(0x80000000 | (addr & ~3), 0xCF8);
89         outl(value, 0xCFC);
90 }