Xen Test Framework
io-apic.h
Go to the documentation of this file.
1
10#ifndef XTF_X86_IO_APIC_H
11#define XTF_X86_IO_APIC_H
12
13#include <xtf/numbers.h>
14#include <xtf/types.h>
15
16/* MMIO window registers. */
17#define IOAPIC_REGSEL 0x00
18#define IOAPIC_IOWIN 0x10
19
20/* IO-APIC registers. */
21#define IOAPIC_ID 0x0
22
23#define IOAPIC_VERSION 0x1
24#define IOAPIC_MAXREDIR_MASK 0xff0000
25
26#define IOAPIC_REDIR_ENTRY(e) (0x10 + (e) * 2)
27#define IOAPIC_REDIR_MASK_SHIFT 16
28
29#define IOAPIC_DEFAULT_BASE 0xfec00000
30
34int ioapic_init(void);
35
36static inline uint32_t ioapic_read32(unsigned int reg)
37{
38 *(volatile uint32_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_REGSEL) = reg;
39
40 return *(volatile uint32_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_IOWIN);
41}
42
43static inline uint64_t ioapic_read64(unsigned int reg)
44{
45 return ioapic_read32(reg) | (uint64_t)ioapic_read32(reg + 1) << 32;
46}
47
48static inline void ioapic_write32(unsigned int reg, uint32_t val)
49{
50 *(volatile uint32_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_REGSEL) = reg;
51 *(volatile uint32_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_IOWIN) = val;
52}
53
54static inline void ioapic_write64(unsigned int reg, uint64_t val)
55{
56 ioapic_write32(reg, val);
57 ioapic_write32(reg + 1, val >> 32);
58}
59
63int ioapic_set_mask(unsigned int entry, bool mask);
64
65#endif /* !XTF_X86_IO_APIC_H */
66
67/*
68 * Local variables:
69 * mode: C
70 * c-file-style: "BSD"
71 * c-basic-offset: 4
72 * tab-width: 4
73 * indent-tabs-mode: nil
74 * End:
75 */
int ioapic_set_mask(unsigned int entry, bool mask)
Set the mask bit on a redirection entry.
Definition: io-apic.c:29
#define IOAPIC_REGSEL
Definition: io-apic.h:17
static void ioapic_write32(unsigned int reg, uint32_t val)
Definition: io-apic.h:48
static uint64_t ioapic_read64(unsigned int reg)
Definition: io-apic.h:43
int ioapic_init(void)
Discover and initialise the IO-APIC.
Definition: io-apic.c:15
static uint32_t ioapic_read32(unsigned int reg)
Definition: io-apic.h:36
#define IOAPIC_IOWIN
Definition: io-apic.h:18
static void ioapic_write64(unsigned int reg, uint64_t val)
Definition: io-apic.h:54
#define IOAPIC_DEFAULT_BASE
Definition: io-apic.h:29
Primatives for number manipulation.
#define _p(v)
Express an abitrary integer v as void *.
Definition: numbers.h:48
__UINT32_TYPE__ uint32_t
Definition: stdint.h:16
__UINT64_TYPE__ uint64_t
Definition: stdint.h:17
Common declarations for all tests.