]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/common: Migrate the APIC implementation to the xPIC driver
authorMichalis Pappas <michalis@unikraft.io>
Mon, 11 Sep 2023 18:10:02 +0000 (20:10 +0200)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:35:55 +0000 (19:35 +0300)
Introduce `arch/x86/x86_64/include/uk/asm/arch.h` for architectural
definitions of x86_64 and migrate APIC definitions into arch.

Migrate the driver implementation into `drivers/ukintctlr/xpic/`
The APIC ops are still accessible via the `apic` global.

Update the include guards of `apic.h`.

Update `plat/` to include `uk/intctlr/apic.h`. Update the KVM config
to enable `UKINTCTLR_XPIC` when compiling for x86_64.

Notice: Picking individual commits in this PR will break the build.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1103

arch/x86/x86_64/include/uk/asm/apic.h [new file with mode: 0644]
arch/x86/x86_64/include/uk/asm/arch.h
drivers/ukintctlr/xpic/Config.uk
drivers/ukintctlr/xpic/include/uk/intctlr/apic.h [new file with mode: 0644]
plat/common/include/x86/apic.h [deleted file]
plat/common/include/x86/apic_defs.h [deleted file]
plat/common/lcpu.c
plat/common/x86/lcpu.c

diff --git a/arch/x86/x86_64/include/uk/asm/apic.h b/arch/x86/x86_64/include/uk/asm/apic.h
new file mode 100644 (file)
index 0000000..379528c
--- /dev/null
@@ -0,0 +1,111 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Marc Rittinghaus <marc.rittinghaus@kit.edu>
+ *          Cristian Vijelie <cristianvijelie@gmail.com>
+ *
+ * Copyright (c) 2022, Karlsruhe Institute of Technology (KIT)
+ *                     All rights reserved.
+ * Copyright (c) 2022, University POLITEHNICA of Bucharest.
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __UK_ARCH_APIC_H__
+#define __UK_ARCH_APIC_H__
+
+/* APIC MSR registers */
+#define APIC_MSR_BASE                  0x01b
+
+/* The following MSRs are only accessible in x2APIC mode */
+#define APIC_MSR_ID                    0x802
+#define APIC_MSR_VER                   0x803
+#define APIC_MSR_TPR                   0x808
+#define APIC_MSR_PPR                   0x80a
+#define APIC_MSR_EOI                   0x80b
+#define APIC_MSR_LDR                   0x80d
+#define APIC_MSR_SVR                   0x80f
+#define APIC_MSR_ISR(x)                        (0x810 + (x))
+#define APIC_MSR_TMR(x)                        (0x818 + (x))
+#define APIC_MSR_IRR(x)                        (0x820 + (x))
+#define APIC_MSR_ESR                   0x828
+#define APIC_MSR_LVT_CMCI              0x82f
+#define APIC_MSR_ICR                   0x830
+#define APIC_MSR_LVT_TIMER             0x832
+#define APIC_MSR_LVT_THERMAL           0x833
+#define APIC_MSR_LVT_PERF              0x834
+#define APIC_MSR_LVT_LINT0             0x835
+#define APIC_MSR_LVT_LINT1             0x836
+#define APIC_MSR_LVT_ERROR             0x837
+#define APIC_MSR_TIMER_IC              0x838
+#define APIC_MSR_TIMER_CC              0x839
+#define APIC_MSR_TIMER_DCR             0x83e
+#define APIC_MSR_SELF_IPI              0x83f
+
+/* APIC BASE register */
+#define APIC_BASE_BSP                  (1 << 8)
+#define APIC_BASE_EXTD                 (1 << 10)
+#define APIC_BASE_EN                   (1 << 11)
+#define APIC_BASE_ADDR_SHIFT           12
+#define APIC_BASE_ADDR_MASK            0x0000000ffffff000UL
+
+/* APIC spurious interrupt vector register (SVR) */
+#define APIC_SVR_EN                    (1 << 8)
+#define APIC_SVR_VECTOR_MASK           0x00000000000000ffUL
+#define APIC_SVR_EOI_BROADCAST         (1 << 12)
+
+/* APIC error status registers (ESR) */
+#define APIC_ESR_SEND_CHECKSUM         (1 << 0) /* only Pentium and P6 */
+#define APIC_ESR_RECV_CHECKSUM         (1 << 1) /* only Pentium and P6 */
+#define APIC_ESR_SEND_ACCEPT           (1 << 2) /* only Pentium and P6 */
+#define APIC_ESR_RECV_ACCEPT           (1 << 3) /* only Pentium and P6 */
+#define APIC_ESR_REDIRECTABLE_IPI      (1 << 4)
+#define APIC_ESR_SEND_ILLEGAL_VECTOR   (1 << 5)
+#define APIC_ESR_RECV_ILLEGAL_VECTOR   (1 << 6)
+#define APIC_ESR_ILLEGAL_REGISTER      (1 << 7)
+
+/* APIC interrupt command register (ICR) */
+#define APIC_ICR_VECTOR_MASK           0x000000ff
+
+#define APIC_ICR_DMODE_FIXED           (0 << 8)
+#define APIC_ICR_DMODE_SMI             (2 << 8)
+#define APIC_ICR_DMODE_NMI             (4 << 8)
+#define APIC_ICR_DMODE_INIT            (5 << 8)
+#define APIC_ICR_DMODE_SUP             (6 << 8)
+
+#define APIC_ICR_DESTMODE_PHYSICAL     0
+#define APIC_ICR_DESTMODE_LOGICAL      (1 << 11)
+#define APIC_ICR_LEVEL_DEASSERT                0
+#define APIC_ICR_LEVEL_ASSERT          (1 << 14)
+#define APIC_ICR_TRIGGER_EDGE          0
+#define APIC_ICR_TRIGGER_LEVEL         (1 << 15)
+
+#define APIC_ICR_DSTSH_NO              (0 << 18)
+#define APIC_ICR_DSTSH_SELF            (1 << 18)
+#define APIC_ICR_DSTSH_ALL_INCL_SELF   (2 << 18)
+#define APIC_ICR_DSTSH_ALL_EXCL_SELF   (3 << 18)
+
+#endif /* __UK_ARCH_APIC_H__ */
index c54f1c095c6eb5e0a69183f8eef2c40352bc5efa..81c0001f4cf20dfeffadfce79544309e4832f7e2 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef __UK_ARCH_X86_64_H__
 #define __UK_ARCHX86_64__H__
 
+#include <uk/asm/apic.h>
 #include <uk/asm/pic.h>
 
 #endif /* __UK_ARCH_X86_64_H__ */
index 7da580843615aae7bee5d4bfb326d57f12ecdaea..94143af3e0865e384a6d330e41bbe0bbad2560b3 100644 (file)
@@ -1,5 +1,13 @@
+config HAVE_APIC
+       bool
+
 config LIBUKINTCTLR_XPIC
        bool "Intel PIC"
        depends on ARCH_X86_64
        select LIBUKINTCTLR
 
+config LIBUKINTCTLR_APIC
+       bool "Intel APIC"
+       depends on HAVE_APIC
+       select LIBUKINTCTLR_PIC
+       depends on ARCH_X86_64
diff --git a/drivers/ukintctlr/xpic/include/uk/intctlr/apic.h b/drivers/ukintctlr/xpic/include/uk/intctlr/apic.h
new file mode 100644 (file)
index 0000000..d7ecaaa
--- /dev/null
@@ -0,0 +1,161 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Marc Rittinghaus <marc.rittinghaus@kit.edu>
+ *          Cristian Vijelie <cristianvijelie@gmail.com>
+ *
+ * Copyright (c) 2022, Karlsruhe Institute of Technology (KIT)
+ *                     All rights reserved.
+ * Copyright (c) 2022, University POLITEHNICA of Bucharest.
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __PLAT_CMN_X86_APIC_H__
+#define __PLAT_CMN_X86_APIC_H__
+
+#include <uk/assert.h>
+#include <uk/arch/limits.h>
+#include <x86/cpu.h>
+#include <uk/asm/arch.h>
+
+#include <errno.h>
+
+static inline int x2apic_enable(void)
+{
+       __u32 eax, ebx, ecx, edx;
+
+       /* Check for x2APIC support */
+       cpuid(1, 0, &eax, &ebx, &ecx, &edx);
+       if (!(ecx & X86_CPUID1_ECX_x2APIC))
+               return -ENOTSUP;
+
+       /* Check if APIC is active */
+       rdmsr(APIC_MSR_BASE, &eax, &edx);
+       if (!(eax & APIC_BASE_EN))
+               return -ENOTSUP;
+
+       /* Switch to x2APIC mode */
+       eax |= APIC_BASE_EXTD;
+       wrmsr(APIC_MSR_BASE, eax, edx);
+
+       /* Set APIC software enable flag if necessary */
+       rdmsr(APIC_MSR_SVR, &eax, &edx);
+       if ((eax & APIC_SVR_EN) == 0) {
+               eax |= APIC_SVR_EN;
+               wrmsr(APIC_MSR_SVR, eax, edx);
+       }
+
+       /*
+        * TODO: Configure spurious interrupt vector number
+        * After power-up or reset this is 0xff, which might not be
+        * configured in the trap table
+        */
+
+       return 0;
+}
+
+static inline void x2apic_send_ipi(int irqno, int dest)
+{
+       __u32 eax;
+
+       UK_ASSERT(((32 + irqno) & 0xff) == (32 + irqno));
+
+       eax = APIC_ICR_TRIGGER_LEVEL | APIC_ICR_LEVEL_ASSERT
+             | APIC_ICR_DESTMODE_PHYSICAL | APIC_ICR_DMODE_FIXED
+             | (32 + irqno);
+
+       wrmsr(APIC_MSR_ICR, eax, dest);
+}
+
+static inline void x2apic_send_self_ipi(int irqno)
+{
+       __u32 eax;
+
+       UK_ASSERT(((32 + irqno) & 0xff) == (32 + irqno));
+
+       eax = (32 + irqno);
+
+       wrmsr(APIC_MSR_SELF_IPI, eax, 0);
+}
+
+static inline void x2apic_send_nmi(int dest)
+{
+       __u32 eax;
+
+       eax = APIC_ICR_TRIGGER_LEVEL | APIC_ICR_LEVEL_ASSERT
+             | APIC_ICR_DESTMODE_PHYSICAL | APIC_ICR_DMODE_NMI;
+
+       wrmsr(APIC_MSR_ICR, eax, dest);
+}
+
+static inline void x2apic_send_sipi(__vaddr_t addr, int dest)
+{
+       __u32 eax;
+
+       UK_ASSERT((addr & (APIC_ICR_VECTOR_MASK << __PAGE_SHIFT)) == addr);
+
+       eax = APIC_ICR_TRIGGER_LEVEL | APIC_ICR_LEVEL_ASSERT
+             | APIC_ICR_DESTMODE_PHYSICAL | APIC_ICR_DMODE_SUP
+             | (addr >> __PAGE_SHIFT);
+
+       wrmsr(APIC_MSR_ICR, eax, dest);
+}
+
+static inline void x2apic_send_iipi(int dest)
+{
+       __u32 eax;
+
+       eax = APIC_ICR_TRIGGER_LEVEL | APIC_ICR_LEVEL_ASSERT
+             | APIC_ICR_DESTMODE_PHYSICAL | APIC_ICR_DMODE_INIT;
+
+       wrmsr(APIC_MSR_ICR, eax, dest);
+}
+
+/* Deassert only supported on Pentium and P6 familiy processors */
+#define x2apic_send_iipi_deassert() {}
+
+static inline void x2apic_clear_errors(void)
+{
+       wrmsr(APIC_MSR_ESR, 0, 0);
+}
+
+static inline void x2apic_ack_interrupt(void)
+{
+       wrmsr(APIC_MSR_EOI, 0, 0);
+}
+
+/* We only support x2APIC at the moment */
+#define apic_enable            x2apic_enable
+#define apic_send_ipi          x2apic_send_ipi
+#define apic_send_nmi          x2apic_send_nmi
+#define apic_send_sipi         x2apic_send_sipi
+#define apic_send_iipi         x2apic_send_iipi
+#define apic_send_iipi_deassert x2apic_send_iipi_deassert
+#define apic_clear_errors      x2apic_clear_errors
+#define apic_ack_interrupt     x2apic_ack_interrupt
+
+#endif /* __PLAT_CMN_X86_APIC_H__ */
diff --git a/plat/common/include/x86/apic.h b/plat/common/include/x86/apic.h
deleted file mode 100644 (file)
index b88b740..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Marc Rittinghaus <marc.rittinghaus@kit.edu>
- *          Cristian Vijelie <cristianvijelie@gmail.com>
- *
- * Copyright (c) 2022, Karlsruhe Institute of Technology (KIT)
- *                     All rights reserved.
- * Copyright (c) 2022, University POLITEHNICA of Bucharest.
- *                     All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __PLAT_CMN_X86_APIC_H__
-#define __PLAT_CMN_X86_APIC_H__
-
-#include <uk/assert.h>
-#include <uk/arch/limits.h>
-#include <x86/cpu.h>
-#include <x86/apic_defs.h>
-
-#include <errno.h>
-
-static inline int x2apic_enable(void)
-{
-       __u32 eax, ebx, ecx, edx;
-
-       /* Check for x2APIC support */
-       cpuid(1, 0, &eax, &ebx, &ecx, &edx);
-       if (!(ecx & X86_CPUID1_ECX_x2APIC))
-               return -ENOTSUP;
-
-       /* Check if APIC is active */
-       rdmsr(APIC_MSR_BASE, &eax, &edx);
-       if (!(eax & APIC_BASE_EN))
-               return -ENOTSUP;
-
-       /* Switch to x2APIC mode */
-       eax |= APIC_BASE_EXTD;
-       wrmsr(APIC_MSR_BASE, eax, edx);
-
-       /* Set APIC software enable flag if necessary */
-       rdmsr(APIC_MSR_SVR, &eax, &edx);
-       if ((eax & APIC_SVR_EN) == 0) {
-               eax |= APIC_SVR_EN;
-               wrmsr(APIC_MSR_SVR, eax, edx);
-       }
-
-       /*
-        * TODO: Configure spurious interrupt vector number
-        * After power-up or reset this is 0xff, which might not be
-        * configured in the trap table
-        */
-
-       return 0;
-}
-
-static inline void x2apic_send_ipi(int irqno, int dest)
-{
-       __u32 eax;
-
-       UK_ASSERT(((32 + irqno) & 0xff) == (32 + irqno));
-
-       eax = APIC_ICR_TRIGGER_LEVEL | APIC_ICR_LEVEL_ASSERT
-             | APIC_ICR_DESTMODE_PHYSICAL | APIC_ICR_DMODE_FIXED
-             | (32 + irqno);
-
-       wrmsr(APIC_MSR_ICR, eax, dest);
-}
-
-static inline void x2apic_send_self_ipi(int irqno)
-{
-       __u32 eax;
-
-       UK_ASSERT(((32 + irqno) & 0xff) == (32 + irqno));
-
-       eax = (32 + irqno);
-
-       wrmsr(APIC_MSR_SELF_IPI, eax, 0);
-}
-
-static inline void x2apic_send_nmi(int dest)
-{
-       __u32 eax;
-
-       eax = APIC_ICR_TRIGGER_LEVEL | APIC_ICR_LEVEL_ASSERT
-             | APIC_ICR_DESTMODE_PHYSICAL | APIC_ICR_DMODE_NMI;
-
-       wrmsr(APIC_MSR_ICR, eax, dest);
-}
-
-static inline void x2apic_send_sipi(__vaddr_t addr, int dest)
-{
-       __u32 eax;
-
-       UK_ASSERT((addr & (APIC_ICR_VECTOR_MASK << __PAGE_SHIFT)) == addr);
-
-       eax = APIC_ICR_TRIGGER_LEVEL | APIC_ICR_LEVEL_ASSERT
-             | APIC_ICR_DESTMODE_PHYSICAL | APIC_ICR_DMODE_SUP
-             | (addr >> __PAGE_SHIFT);
-
-       wrmsr(APIC_MSR_ICR, eax, dest);
-}
-
-static inline void x2apic_send_iipi(int dest)
-{
-       __u32 eax;
-
-       eax = APIC_ICR_TRIGGER_LEVEL | APIC_ICR_LEVEL_ASSERT
-             | APIC_ICR_DESTMODE_PHYSICAL | APIC_ICR_DMODE_INIT;
-
-       wrmsr(APIC_MSR_ICR, eax, dest);
-}
-
-/* Deassert only supported on Pentium and P6 familiy processors */
-#define x2apic_send_iipi_deassert() {}
-
-static inline void x2apic_clear_errors(void)
-{
-       wrmsr(APIC_MSR_ESR, 0, 0);
-}
-
-static inline void x2apic_ack_interrupt(void)
-{
-       wrmsr(APIC_MSR_EOI, 0, 0);
-}
-
-/* We only support x2APIC at the moment */
-#define apic_enable            x2apic_enable
-#define apic_send_ipi          x2apic_send_ipi
-#define apic_send_nmi          x2apic_send_nmi
-#define apic_send_sipi         x2apic_send_sipi
-#define apic_send_iipi         x2apic_send_iipi
-#define apic_send_iipi_deassert x2apic_send_iipi_deassert
-#define apic_clear_errors      x2apic_clear_errors
-#define apic_ack_interrupt     x2apic_ack_interrupt
-
-#endif /* __PLAT_CMN_X86_APIC_H__ */
diff --git a/plat/common/include/x86/apic_defs.h b/plat/common/include/x86/apic_defs.h
deleted file mode 100644 (file)
index d10dbaf..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Marc Rittinghaus <marc.rittinghaus@kit.edu>
- *          Cristian Vijelie <cristianvijelie@gmail.com>
- *
- * Copyright (c) 2022, Karlsruhe Institute of Technology (KIT)
- *                     All rights reserved.
- * Copyright (c) 2022, University POLITEHNICA of Bucharest.
- *                     All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __PLAT_CMN_X86_APIC_DEFS_H__
-#define __PLAT_CMN_X86_APIC_DEFS_H__
-
-/* APIC MSR registers */
-#define APIC_MSR_BASE                  0x01b
-
-/* The following MSRs are only accessible in x2APIC mode */
-#define APIC_MSR_ID                    0x802
-#define APIC_MSR_VER                   0x803
-#define APIC_MSR_TPR                   0x808
-#define APIC_MSR_PPR                   0x80a
-#define APIC_MSR_EOI                   0x80b
-#define APIC_MSR_LDR                   0x80d
-#define APIC_MSR_SVR                   0x80f
-#define APIC_MSR_ISR(x)                        (0x810 + (x))
-#define APIC_MSR_TMR(x)                        (0x818 + (x))
-#define APIC_MSR_IRR(x)                        (0x820 + (x))
-#define APIC_MSR_ESR                   0x828
-#define APIC_MSR_LVT_CMCI              0x82f
-#define APIC_MSR_ICR                   0x830
-#define APIC_MSR_LVT_TIMER             0x832
-#define APIC_MSR_LVT_THERMAL           0x833
-#define APIC_MSR_LVT_PERF              0x834
-#define APIC_MSR_LVT_LINT0             0x835
-#define APIC_MSR_LVT_LINT1             0x836
-#define APIC_MSR_LVT_ERROR             0x837
-#define APIC_MSR_TIMER_IC              0x838
-#define APIC_MSR_TIMER_CC              0x839
-#define APIC_MSR_TIMER_DCR             0x83e
-#define APIC_MSR_SELF_IPI              0x83f
-
-/* APIC BASE register */
-#define APIC_BASE_BSP                  (1 << 8)
-#define APIC_BASE_EXTD                 (1 << 10)
-#define APIC_BASE_EN                   (1 << 11)
-#define APIC_BASE_ADDR_SHIFT           12
-#define APIC_BASE_ADDR_MASK            0x0000000ffffff000UL
-
-/* APIC spurious interrupt vector register (SVR) */
-#define APIC_SVR_EN                    (1 << 8)
-#define APIC_SVR_VECTOR_MASK           0x00000000000000ffUL
-#define APIC_SVR_EOI_BROADCAST         (1 << 12)
-
-/* APIC error status registers (ESR) */
-#define APIC_ESR_SEND_CHECKSUM         (1 << 0) /* only Pentium and P6 */
-#define APIC_ESR_RECV_CHECKSUM         (1 << 1) /* only Pentium and P6 */
-#define APIC_ESR_SEND_ACCEPT           (1 << 2) /* only Pentium and P6 */
-#define APIC_ESR_RECV_ACCEPT           (1 << 3) /* only Pentium and P6 */
-#define APIC_ESR_REDIRECTABLE_IPI      (1 << 4)
-#define APIC_ESR_SEND_ILLEGAL_VECTOR   (1 << 5)
-#define APIC_ESR_RECV_ILLEGAL_VECTOR   (1 << 6)
-#define APIC_ESR_ILLEGAL_REGISTER      (1 << 7)
-
-/* APIC interrupt command register (ICR) */
-#define APIC_ICR_VECTOR_MASK           0x000000ff
-
-#define APIC_ICR_DMODE_FIXED           (0 << 8)
-#define APIC_ICR_DMODE_SMI             (2 << 8)
-#define APIC_ICR_DMODE_NMI             (4 << 8)
-#define APIC_ICR_DMODE_INIT            (5 << 8)
-#define APIC_ICR_DMODE_SUP             (6 << 8)
-
-#define APIC_ICR_DESTMODE_PHYSICAL     0
-#define APIC_ICR_DESTMODE_LOGICAL      (1 << 11)
-#define APIC_ICR_LEVEL_DEASSERT                0
-#define APIC_ICR_LEVEL_ASSERT          (1 << 14)
-#define APIC_ICR_TRIGGER_EDGE          0
-#define APIC_ICR_TRIGGER_LEVEL         (1 << 15)
-
-#define APIC_ICR_DSTSH_NO              (0 << 18)
-#define APIC_ICR_DSTSH_SELF            (1 << 18)
-#define APIC_ICR_DSTSH_ALL_INCL_SELF   (2 << 18)
-#define APIC_ICR_DSTSH_ALL_EXCL_SELF   (3 << 18)
-
-#endif /* __PLAT_CMN_X86_APIC_DEFS_H__ */
index 7b31f35dfe8e3f7f498e1b2b6e045c1ebe361a31..88e3c32c54b53e6331118c3c91f85e5402b03975 100644 (file)
@@ -52,7 +52,7 @@
 
 #ifdef CONFIG_ARCH_X86_64
 /* TODO: Remove when we have unified IRQ handling */
-#include <x86/apic.h>
+#include <uk/intctlr/apic.h>
 #endif /* CONFIG_ARCH_X86_64 */
 
 /**
index 7f5473ff9f87cc8fc94696abaa299018cdfa14df..f988da7ef0347924946fdc08e5f1d098049cd7d9 100644 (file)
@@ -38,7 +38,7 @@
 #include <uk/assert.h>
 #include <uk/print.h>
 #include <x86/irq.h>
-#include <x86/apic.h>
+#include <uk/intctlr/apic.h>
 #include <x86/cpu.h>
 #include <x86/traps.h>
 #include <x86/delay.h>