Skip to contentSkip to conversation

x86: Refactor interrupt_init()

PATCH New Bin Meng 2 participants 3 messages Nov 20, 2014 – Nov 25, 2014 x86

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 3/4 x86: Refactor interrupt_init()

Rename interrupt_init() in arch/x86/lib/pcat_interrupts.c to i8259_init() and create a new interrupt_init() in arch/x86/cpu/interrupt.c to call i8259_init() followed by a call to cpu_init_interrupts().

---
 arch/x86/cpu/interrupts.c      | 26 ++++++++++++++++++++------
 arch/x86/include/asm/i8259.h   |  2 ++
 arch/x86/lib/pcat_interrupts.c |  9 +--------
 3 files changed, 23 insertions(+), 14 deletions(-)
arch/x86/cpu/interrupts.c +20 -6
index 51e2c59..ea03724 100644
@@ -20,6 +20,7 @@
 #include <linux/compiler.h>
 #include <asm/msr.h>
 #include <asm/u-boot-x86.h>
+#include <asm/i8259.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -128,9 +129,6 @@ int cpu_init_interrupts(void)
 	int irq_entry_size = irq_1 - irq_0;
 	void *irq_entry = (void *)irq_0;
 
-	/* Just in case... */
-	disable_interrupts();
-
 	/* Setup the IDT */
 	for (i = 0; i < 256; i++) {
 		idt[i].access = 0x8e;
@@ -146,9 +144,6 @@ int cpu_init_interrupts(void)
 
 	load_idt(&idt_ptr);
 
-	/* It is now safe to enable interrupts */
-	enable_interrupts();
-
 	return 0;
 }
 
@@ -172,6 +167,25 @@ int disable_interrupts(void)
 	return flags & X86_EFLAGS_IF;
 }
 
+int interrupt_init(void)
+{
+	/* Just in case... */
+	disable_interrupts();
+
+#ifdef CONFIG_SYS_PCAT_INTERRUPTS
+	/* Initialize the master/slave i8259 pic */
+	i8259_init();
+#endif
+
+	/* Initialize core interrupt and exception functionality of CPU */
+	cpu_init_interrupts();
+
+	/* It is now safe to enable interrupts */
+	enable_interrupts();
+
+	return 0;
+}
+
 /* IRQ Low-Level Service Routine */
 void irq_llsr(struct irq_regs *regs)
 {
arch/x86/include/asm/i8259.h +2 -0
index 73113f9..bc4033b 100644
@@ -69,4 +69,6 @@
 #define	ICW4_AEOI	0x02	/* Automatic EOI Mode */
 #define ICW4_PM		0x01	/* Microprocessor Mode */
 
+int i8259_init(void);
+
 #endif
arch/x86/lib/pcat_interrupts.c +1 -8
index 2ce371e..27c7f08 100644
@@ -24,12 +24,10 @@
 #error "CONFIG_SYS_NUM_IRQS must equal 16 if CONFIG_SYS_NUM_IRQS is defined"
 #endif
 
-int interrupt_init(void)
+int i8259_init(void)
 {
 	u8 i;
 
-	disable_interrupts();
-
 	/* Mask all interrupts */
 	outb(0xff, MASTER_PIC + IMR);
 	outb(0xff, SLAVE_PIC + IMR);
@@ -62,11 +60,6 @@ int interrupt_init(void)
 	 */
 	unmask_irq(2);
 
-	/* Initialize core interrupt and exception functionality of CPU */
-	cpu_init_interrupts();
-
-	enable_interrupts();
-
 	return 0;
 }
 
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 3/4 x86: Refactor interrupt_init()

Quoted 11 lines · Bin Meng

Rename interrupt_init() in arch/x86/lib/pcat_interrupts.c to i8259_init() and create a new interrupt_init() in arch/x86/cpu/interrupt.c to call i8259_init() followed by a call to cpu_init_interrupts().

---
 arch/x86/cpu/interrupts.c      | 26 ++++++++++++++++++++------
 arch/x86/include/asm/i8259.h   |  2 ++
 arch/x86/lib/pcat_interrupts.c |  9 +--------
 3 files changed, 23 insertions(+), 14 deletions(-)

Tested on chromebook_link:

#2 lore raw

PATCH 3/4 x86: Refactor interrupt_init()

Quoted 13 lines · Simon Glass
Quoted 11 lines · Bin Meng

Rename interrupt_init() in arch/x86/lib/pcat_interrupts.c to i8259_init() and create a new interrupt_init() in arch/x86/cpu/interrupt.c to call i8259_init() followed by a call to cpu_init_interrupts().

---
 arch/x86/cpu/interrupts.c      | 26 ++++++++++++++++++++------
 arch/x86/include/asm/i8259.h   |  2 ++
 arch/x86/lib/pcat_interrupts.c |  9 +--------
 3 files changed, 23 insertions(+), 14 deletions(-)
Quoted 4 lines

Tested on chromebook_link:

Applied to u-boot-x86, thanks!