From 25c9d021a505f4862ad6cea7d19c45c1f33f73c9 Mon Sep 17 00:00:00 2001 From: Dirk Brandewie Date: Tue, 15 Sep 2015 09:17:38 -0700 Subject: [PATCH] x86: move IOAPIC driver to device model/init system Change the IOAPIC driver to be initialized directly from the init system. The function signature of _ioapic_init() function is updated accordingly. Change-Id: I2f824ac745926966eebb23f60445a41e1df9eb8f Signed-off-by: Dirk Brandewie --- arch/x86/platforms/ia32/system.c | 19 ++++++------------- arch/x86/platforms/ia32_pci/system.c | 19 ++++++------------- drivers/interrupt_controller/ioapic_intr.c | 4 +++- include/drivers/ioapic.h | 2 +- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/arch/x86/platforms/ia32/system.c b/arch/x86/platforms/ia32/system.c index bafb2e9232b..d80f9da4a3d 100644 --- a/arch/x86/platforms/ia32/system.c +++ b/arch/x86/platforms/ia32/system.c @@ -43,19 +43,7 @@ for the ia32 platform. #include #include #include - - -#ifdef CONFIG_IOAPIC #include -static inline void ioapic_init(void) -{ - _ioapic_init(); -} -#else -#define ioapic_init(mask) \ - do {/* nothing */ \ - } while ((0)) -#endif /* CONFIG_IOAPIC */ #ifdef CONFIG_HPET_TIMER #include @@ -97,12 +85,17 @@ static int ia32_init(struct device *arg) { ARG_UNUSED(arg); - ioapic_init(); /* NOP if not needed */ hpet_irq_set(); /* NOP if not needed */ console_irq_set(); /* NOP if not needed */ return 0; } +#ifdef CONFIG_IOAPIC +DECLARE_DEVICE_INIT_CONFIG(ioapic_0, "", _ioapic_init, NULL); +pure_early_init(ioapic_0, NULL); + +#endif /* CONFIG_IOAPIC */ + #ifdef CONFIG_LOAPIC DECLARE_DEVICE_INIT_CONFIG(loapic_0, "", _loapic_init, NULL); pure_early_init(loapic_0, NULL); diff --git a/arch/x86/platforms/ia32_pci/system.c b/arch/x86/platforms/ia32_pci/system.c index 7e28f37cbb5..d7b5bd23b69 100644 --- a/arch/x86/platforms/ia32_pci/system.c +++ b/arch/x86/platforms/ia32_pci/system.c @@ -51,19 +51,7 @@ Handlers for the secondary serial port have not been added. #include #include #include - - -#ifdef CONFIG_IOAPIC #include -static inline void ioapic_init(void) -{ - _ioapic_init(); -} -#else -#define ioapic_init() \ - do { /* nothing */ \ - } while ((0)) -#endif #ifdef CONFIG_HPET_TIMER #include @@ -132,7 +120,6 @@ static int ia32_pci_init(struct device *arg) { ARG_UNUSED(arg); - ioapic_init(); /* NOP if not needed */ hpet_irq_set(); /* NOP if not needed */ console_irq_set(); /* NOP if not needed */ gpio_irq_set(); /* NOP if not needed */ @@ -160,6 +147,12 @@ static int ia32_pci_init(struct device *arg) return 0; } +#ifdef CONFIG_IOAPIC +DECLARE_DEVICE_INIT_CONFIG(ioapic_0, "", _ioapic_init, NULL); +pure_early_init(ioapic_0, NULL); + +#endif /* CONFIG_IOAPIC */ + #ifdef CONFIG_LOAPIC DECLARE_DEVICE_INIT_CONFIG(loapic_0, "", _loapic_init, NULL); pure_early_init(loapic_0, NULL); diff --git a/drivers/interrupt_controller/ioapic_intr.c b/drivers/interrupt_controller/ioapic_intr.c index d2f41240dd0..777471c1565 100644 --- a/drivers/interrupt_controller/ioapic_intr.c +++ b/drivers/interrupt_controller/ioapic_intr.c @@ -216,8 +216,9 @@ static void _IoApicRedUpdateLo(unsigned int irq, uint32_t value, * * @return N/A */ -void _ioapic_init(void) +int _ioapic_init(struct device *unused) { + ARG_UNUSED(unused); int32_t ix; /* redirection table index */ uint32_t rteValue; /* value to copy into redirection table entry */ @@ -250,6 +251,7 @@ void _ioapic_init(void) ioApicRedSetHi(ix, 0); ioApicRedSetLo(ix, rteValue); } + return 0; } /** diff --git a/include/drivers/ioapic.h b/include/drivers/ioapic.h index 6c30a8d912a..9f071bee868 100644 --- a/include/drivers/ioapic.h +++ b/include/drivers/ioapic.h @@ -73,7 +73,7 @@ SECTION_FUNC(TEXT, _\()\device\()_\()\isr\()_stub) jmp _IntExit /* Inform kernel interrupt is done */ .endm #else /* _ASMLANGUAGE */ -void _ioapic_init(void); +int _ioapic_init(struct device *unused); void _ioapic_eoi(unsigned int irq); void *_ioapic_eoi_get(unsigned int irq, char *argRequired, void **arg); void _ioapic_irq_enable(unsigned int irq);