summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/include/arch/mmio_conf.h
blob: df91cb561d76e504b9bdc46804db17f1b206c668 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef ARCH_MMIO_H
#define ARCH_MMIO_H 1


//extended read, GS is already set

static inline __attribute__((always_inline)) uint8_t read8x(uint32_t addr)
{
	uint8_t value;
        __asm__ volatile (
                "movb %%gs:(%1), %0\n\t"
                :"=a"(value): "b" (addr)
        );
        return value;
}

static inline __attribute__((always_inline)) uint16_t read16x(uint32_t addr)
{
        uint16_t value;
        __asm__ volatile (
                "movw %%gs:(%1), %0\n\t"
                :"=a"(value): "b" (addr)
        );

        return value;

}

static inline __attribute__((always_inline)) uint32_t read32x(uint32_t addr)
{
        uint32_t value;
        __asm__ volatile (
                "movl %%gs:(%1), %0\n\t"
                :"=a"(value): "b" (addr)
        );

        return value;

}

static inline __attribute__((always_inline)) void write8x(uint32_t addr, uint8_t value)
{
        __asm__ volatile (
                "movb %1, %%gs:(%0)\n\t"
                :: "b" (addr), "a" (value)
        );

}

static inline __attribute__((always_inline)) void write16x(uint32_t addr, uint16_t value)
{
        __asm__ volatile (
                "movw %1, %%gs:(%0)\n\t"
                :: "b" (addr), "a" (value)
        );

}

static inline __attribute__((always_inline)) void write32x(uint32_t addr, uint32_t value)
{
        __asm__ volatile (
                "movl %1, %%gs:(%0)\n\t"
                :: "b" (addr), "a" (value)
        );
}

#endif /* ARCH_MMIO_H */
OpenPOWER on IntegriCloud