Two hda_verb.h files: Add more comments.
[coreboot.git] / src / arch / i386 / include / arch / mmio_conf.h
1 #ifndef ARCH_MMIO_H
2 #define ARCH_MMIO_H 1
3
4
5 // Extended read, constrain to use registers as mandated by AMD MMCONFIG mechanism.
6
7 static inline __attribute__((always_inline)) uint8_t read8x(uint32_t addr)
8 {
9         uint8_t value;
10         __asm__ volatile (
11                 "movb (%1), %%al\n\t"
12                 :"=a"(value): "b" (addr)
13         );
14         return value;
15 }
16
17 static inline __attribute__((always_inline)) uint16_t read16x(uint32_t addr)
18 {
19         uint16_t value;
20         __asm__ volatile (
21                 "movw (%1), %%ax\n\t"
22                 :"=a"(value): "b" (addr)
23         );
24
25         return value;
26
27 }
28
29 static inline __attribute__((always_inline)) uint32_t read32x(uint32_t addr)
30 {
31         uint32_t value;
32         __asm__ volatile (
33                 "movl (%1), %%eax\n\t"
34                 :"=a"(value): "b" (addr)
35         );
36
37         return value;
38
39 }
40
41 static inline __attribute__((always_inline)) void write8x(uint32_t addr, uint8_t value)
42 {
43         __asm__ volatile (
44                 "movb %%al, (%0)\n\t"
45                 :: "b" (addr), "a" (value)
46         );
47
48 }
49
50 static inline __attribute__((always_inline)) void write16x(uint32_t addr, uint16_t value)
51 {
52         __asm__ volatile (
53                 "movw %%ax, (%0)\n\t"
54                 :: "b" (addr), "a" (value)
55         );
56
57 }
58
59 static inline __attribute__((always_inline)) void write32x(uint32_t addr, uint32_t value)
60 {
61         __asm__ volatile (
62                 "movl %%eax, (%0)\n\t"
63                 :: "b" (addr), "a" (value)
64         );
65 }
66
67 #endif /* ARCH_MMIO_H */