@@ -5,6 +5,7 @@
#include <stdint.h>
#include "apic-defs.h"
+#include "processor.h"
#include "smp.h"
extern u8 id_map[MAX_TEST_CPUS];
@@ -67,6 +68,26 @@ void apic_setup_timer(int vector, u32 mode);
void apic_start_timer(u32 counter);
void apic_stop_timer(void);
+static inline bool is_apic_hw_enabled(void)
+{
+ return rdmsr(MSR_IA32_APICBASE) & APIC_EN;
+}
+
+static inline bool is_apic_sw_enabled(void)
+{
+ return apic_read(APIC_SPIV) & APIC_SPIV_APIC_ENABLED;
+}
+
+static inline bool is_x2apic_enabled(void)
+{
+ return (rdmsr(MSR_IA32_APICBASE) & (APIC_EN | APIC_EXTD)) == (APIC_EN | APIC_EXTD);
+}
+
+static inline bool is_xapic_enabled(void)
+{
+ return (rdmsr(MSR_IA32_APICBASE) & (APIC_EN | APIC_EXTD)) == APIC_EN;
+}
+
/* Converts byte-addressable APIC register offset to 4-byte offset. */
static inline u32 apic_reg_index(u32 reg)
{
@@ -10,26 +10,6 @@
#define MAX_TPR 0xf
-static bool is_apic_hw_enabled(void)
-{
- return rdmsr(MSR_IA32_APICBASE) & APIC_EN;
-}
-
-static bool is_apic_sw_enabled(void)
-{
- return apic_read(APIC_SPIV) & APIC_SPIV_APIC_ENABLED;
-}
-
-static bool is_x2apic_enabled(void)
-{
- return (rdmsr(MSR_IA32_APICBASE) & (APIC_EN | APIC_EXTD)) == (APIC_EN | APIC_EXTD);
-}
-
-static bool is_xapic_enabled(void)
-{
- return (rdmsr(MSR_IA32_APICBASE) & (APIC_EN | APIC_EXTD)) == APIC_EN;
-}
-
static void test_lapic_existence(void)
{
u8 version;
Expose the helpers to query if an APIC is enabled, and in xAPIC vs. x2APIC mode, to library code so that the helpers can be used by all tests. No funtional change intended. Signed-off-by: Sean Christopherson <seanjc@google.com> --- lib/x86/apic.h | 21 +++++++++++++++++++++ x86/apic.c | 20 -------------------- 2 files changed, 21 insertions(+), 20 deletions(-)