diff mbox

[2/7] x86: lib: Expose IOAPIC/APIC globals and utils to lib

Message ID 1521674594-12085-3-git-send-email-liran.alon@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liran Alon March 21, 2018, 11:23 p.m. UTC
From: Arbel Moshe <arbel.moshe@oracle.com>

Signed-off-by: Arbel Moshe <arbel.moshe@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 lib/x86/apic.c | 21 +++++++++++++++++++--
 lib/x86/apic.h |  8 ++++++++
 x86/ioapic.c   | 17 -----------------
 3 files changed, 27 insertions(+), 19 deletions(-)
diff mbox

Patch

diff --git a/lib/x86/apic.c b/lib/x86/apic.c
index 6b5b06806923..df01e026215e 100644
--- a/lib/x86/apic.c
+++ b/lib/x86/apic.c
@@ -3,8 +3,8 @@ 
 #include "msr.h"
 #include "processor.h"
 
-static void *g_apic = (void *)0xfee00000;
-static void *g_ioapic = (void *)0xfec00000;
+void *g_apic = (void *)0xfee00000;
+void *g_ioapic = (void *)0xfec00000;
 
 struct apic_ops {
     u32 (*reg_read)(unsigned reg);
@@ -187,6 +187,18 @@  ioapic_redir_entry_t ioapic_read_redir(unsigned line)
 
 }
 
+void set_ioapic_redir(unsigned line, unsigned vec,
+			     trigger_mode_t trig_mode)
+{
+	ioapic_redir_entry_t e = {
+		.vector = vec,
+		.delivery_mode = 0,
+		.trig_mode = trig_mode,
+	};
+
+	ioapic_write_redir(line, e);
+}
+
 void set_mask(unsigned line, int mask)
 {
     ioapic_redir_entry_t e = ioapic_read_redir(line);
@@ -195,6 +207,11 @@  void set_mask(unsigned line, int mask)
     ioapic_write_redir(line, e);
 }
 
+void set_irq_line(unsigned line, int val)
+{
+	asm volatile("out %0, %1" : : "a"((u8)val), "d"((u16)(0x2000 + line)));
+}
+
 void enable_apic(void)
 {
     printf("enabling apic\n");
diff --git a/lib/x86/apic.h b/lib/x86/apic.h
index 699102cb51b5..a7aca689c87a 100644
--- a/lib/x86/apic.h
+++ b/lib/x86/apic.h
@@ -4,6 +4,9 @@ 
 #include <stdint.h>
 #include "apic-defs.h"
 
+extern void *g_apic;
+extern void *g_ioapic;
+
 typedef struct {
     uint8_t vector;
     uint8_t delivery_mode:3;
@@ -35,8 +38,13 @@  void ioapic_write_reg(unsigned reg, uint32_t value);
 ioapic_redir_entry_t ioapic_read_redir(unsigned line);
 uint32_t ioapic_read_reg(unsigned reg);
 
+void set_ioapic_redir(unsigned line, unsigned vec,
+		trigger_mode_t trig_mode);
+
 void set_mask(unsigned line, int mask);
 
+void set_irq_line(unsigned line, int val);
+
 void enable_apic(void);
 uint32_t apic_read(unsigned reg);
 bool apic_read_bit(unsigned reg, int n);
diff --git a/x86/ioapic.c b/x86/ioapic.c
index 849add4384ed..0cab58f431bc 100644
--- a/x86/ioapic.c
+++ b/x86/ioapic.c
@@ -5,23 +5,6 @@ 
 #include "desc.h"
 #include "isr.h"
 
-static void set_ioapic_redir(unsigned line, unsigned vec,
-			     trigger_mode_t trig_mode)
-{
-	ioapic_redir_entry_t e = {
-		.vector = vec,
-		.delivery_mode = 0,
-		.trig_mode = trig_mode,
-	};
-
-	ioapic_write_redir(line, e);
-}
-
-static void set_irq_line(unsigned line, int val)
-{
-	asm volatile("out %0, %1" : : "a"((u8)val), "d"((u16)(0x2000 + line)));
-}
-
 static void toggle_irq_line(unsigned line)
 {
 	set_irq_line(line, 1);