summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2019-06-06 16:06:21 -0600
committerCommit Bot <commit-bot@chromium.org>2019-06-11 19:51:17 +0000
commitb662af8066a01502429b84879c4e3a885ec10e1b (patch)
tree3b066c18b9ea1402e162de007d367c2018bf598d /core
parent59d060ebfe68082f4ea87214ffcda976c55176af (diff)
downloadchrome-ec-b662af8066a01502429b84879c4e3a885ec10e1b.tar.gz
minute-ia: move IRQ definitions to common files
By moving the __irq_data extern declaration into link_defs.h, the struct can be used in more than just interrupts.c. In addition, this provides a common struct definiton for IRQ definitions consisting of an IRQ number, the assigned routine, and a handler function, which is a fairly common way to store IRQ definitions. BUG=none BRANCH=none TEST=arcada ISH functions as normal Change-Id: Idbb5780ae965faeade74cfe319364f61dd933d9e Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1649375 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/minute-ia/interrupts.c15
-rw-r--r--core/minute-ia/irq_handler.h31
2 files changed, 21 insertions, 25 deletions
diff --git a/core/minute-ia/interrupts.c b/core/minute-ia/interrupts.c
index 3ce0e2a2a4..275dba1e9d 100644
--- a/core/minute-ia/interrupts.c
+++ b/core/minute-ia/interrupts.c
@@ -11,9 +11,10 @@
#include "ia_structs.h"
#include "interrupts.h"
#include "irq_handler.h"
+#include "link_defs.h"
#include "registers.h"
-#include "task_defs.h"
#include "task.h"
+#include "task_defs.h"
#include "util.h"
/* Console output macros */
@@ -385,9 +386,6 @@ void unhandled_vector(void)
asm("" : : "a" (vec));
}
-/* This needs to be moved to link_defs.h */
-extern const struct irq_data __irq_data[], __irq_data_end[];
-
/**
* Called from SOFTIRQ_VECTOR when software is trigger an IRQ manually
*
@@ -395,7 +393,7 @@ extern const struct irq_data __irq_data[], __irq_data_end[];
*/
void call_irq_service_routine(uint32_t irq)
{
- const struct irq_data *p = __irq_data;
+ const struct irq_def *p = __irq_data;
/* If just rescheduling a task, we won't have a routine to call */
if (irq >= CONFIG_IRQ_COUNT)
@@ -415,13 +413,14 @@ void call_irq_service_routine(uint32_t irq)
void init_interrupts(void)
{
unsigned entry;
- const struct irq_data *p = __irq_data;
+ const struct irq_def *p;
unsigned num_system_irqs = ARRAY_SIZE(system_irqs);
unsigned max_entries = (read_ioapic_reg(IOAPIC_VERSION) >> 16) & 0xff;
/* Setup gates for IRQs declared by drivers using DECLARE_IRQ */
- for (; p < __irq_data_end; p++)
- set_interrupt_gate(IRQ_TO_VEC(p->irq), p->ioapic_routine,
+ for (p = __irq_data; p < __irq_data_end; p++)
+ set_interrupt_gate(IRQ_TO_VEC(p->irq),
+ p->handler,
IDT_DESC_FLAGS);
/* Software generated IRQ */
diff --git a/core/minute-ia/irq_handler.h b/core/minute-ia/irq_handler.h
index 3b33fbb073..eec0ffddb4 100644
--- a/core/minute-ia/irq_handler.h
+++ b/core/minute-ia/irq_handler.h
@@ -9,16 +9,11 @@
#define __CROS_EC_IRQ_HANDLER_H
#include "registers.h"
+#include "task.h"
#include "task_defs.h"
asm (".include \"core/minute-ia/irq_handler_common.S\"");
-struct irq_data {
- void (*routine)(void);
- void (*ioapic_routine)(void);
- int irq;
-};
-
/* Helper macros to build the IRQ handler and priority struct names */
#define IRQ_HANDLER(irqname) CONCAT3(_irq_, irqname, _handler)
#define IRQ_PRIORITY(irqname) CONCAT2(prio_, irqname)
@@ -35,24 +30,26 @@ struct irq_data {
* Each irq has a irq_data structure placed in .rodata.irqs section,
* to be used for dynamically setting up interrupt gates
*/
-#define DECLARE_IRQ_(irq, routine, vector) \
- void __keep routine(void); \
- void IRQ_HANDLER(irq)(void); \
+#define DECLARE_IRQ_(irq_, routine_, vector) \
+ void __keep routine_(void); \
+ void IRQ_HANDLER(irq_)(void); \
__asm__ (".section .rodata.irqs\n"); \
- const struct irq_data __keep CONCAT4(__irq_, irq, _, routine) \
- __attribute__((section(".rodata.irqs"))) = { routine, \
- IRQ_HANDLER(irq), \
- irq}; \
+ const struct irq_def __keep CONCAT4(__irq_, irq_, _, routine_) \
+ __attribute__((section(".rodata.irqs"))) = { \
+ .irq = irq_, \
+ .routine = routine_, \
+ .handler = IRQ_HANDLER(irq_) \
+ }; \
__asm__ ( \
- ".section .text._irq_"#irq"_handler\n" \
- "_irq_"#irq"_handler:\n" \
+ ".section .text._irq_" #irq_ "_handler\n" \
+ "_irq_" #irq_ "_handler:\n" \
"pusha\n" \
ASM_LOCK_PREFIX "addl $1, __in_isr\n" \
- "irq_handler_common $0 $0 $"#irq"\n" \
+ "irq_handler_common $0 $0 $" #irq_ "\n" \
"movl $"#vector ", " STRINGIFY(IOAPIC_EOI_REG_ADDR) "\n" \
"movl $0x00, " STRINGIFY(LAPIC_EOI_REG_ADDR) "\n" \
ASM_LOCK_PREFIX "subl $1, __in_isr\n" \
"popa\n" \
"iret\n" \
- );
+ )
#endif /* __CROS_EC_IRQ_HANDLER_H */