Skip to content
Snippets Groups Projects
Commit 98a6f49d authored by Federico's avatar Federico
Browse files

Simplify interrupt table generation metaprogram

parent 394650fb
No related branches found
No related tags found
No related merge requests found
...@@ -134,19 +134,14 @@ template<unsigned N, fnptr... args> ...@@ -134,19 +134,14 @@ template<unsigned N, fnptr... args>
struct TableGenerator struct TableGenerator
{ {
typedef typename TableGenerator<N-1, &irqProxy<N-1>, args...>::type type; typedef typename TableGenerator<N-1, &irqProxy<N-1>, args...>::type type;
static const type table;
}; };
template<fnptr... args> template<fnptr... args>
struct TableGenerator<0, args...> struct TableGenerator<0, args...>
{ {
typedef InterruptProxyTable<args...> type; typedef InterruptProxyTable<args...> type;
static const type table;
}; };
template<unsigned N, fnptr... args>
const typename TableGenerator<N, args...>::type TableGenerator<N, args...>::table;
/** /**
* \internal * \internal
* This struct is the type whose memory layout corresponds to the ARM Cortex * This struct is the type whose memory layout corresponds to the ARM Cortex
...@@ -157,11 +152,9 @@ struct InterruptTable ...@@ -157,11 +152,9 @@ struct InterruptTable
constexpr InterruptTable(char* stackptr, fnptr i1, fnptr i2, fnptr i3, constexpr InterruptTable(char* stackptr, fnptr i1, fnptr i2, fnptr i3,
fnptr i4, fnptr i5, fnptr i6, fnptr i7, fnptr i4, fnptr i5, fnptr i6, fnptr i7,
fnptr i8, fnptr i9, fnptr i10, fnptr i11, fnptr i8, fnptr i9, fnptr i10, fnptr i11,
fnptr i12, fnptr i13, fnptr i14, fnptr i15, fnptr i12, fnptr i13, fnptr i14, fnptr i15)
TableGenerator<numInterrupts>::type interruptProxyTable)
: stackptr(stackptr), i1(i1), i2(i2), i3(i3), i4(i4), i5(i5), i6(i6), i7(i7), : stackptr(stackptr), i1(i1), i2(i2), i3(i3), i4(i4), i5(i5), i6(i6), i7(i7),
i8(i8), i9(i9), i10(i10), i11(i11), i12(i12), i13(i13), i14(i14), i15(i15), i8(i8), i9(i9), i10(i10), i11(i11), i12(i12), i13(i13), i14(i14), i15(i15) {}
interruptProxyTable(interruptProxyTable) {}
// The first entries of the interrupt table are the stack pointer, reset // The first entries of the interrupt table are the stack pointer, reset
// vector and "system" interrupt entries. We don't make these run-time // vector and "system" interrupt entries. We don't make these run-time
...@@ -196,7 +189,7 @@ __attribute__((section(".isr_vector"))) extern const InterruptTable hardwareInte ...@@ -196,7 +189,7 @@ __attribute__((section(".isr_vector"))) extern const InterruptTable hardwareInte
DebugMon_Handler, // Debug Monitor Handler DebugMon_Handler, // Debug Monitor Handler
nullptr, // Reserved nullptr, // Reserved
PendSV_Handler, // PendSV Handler PendSV_Handler, // PendSV Handler
nullptr, // SysTick Handler (Miosix does not use it) nullptr // SysTick Handler (Miosix does not use it)
#else //__CORTEX_M != 0 #else //__CORTEX_M != 0
&_main_stack_top, // Stack pointer &_main_stack_top, // Stack pointer
Reset_Handler, // Reset Handler Reset_Handler, // Reset Handler
...@@ -213,12 +206,8 @@ __attribute__((section(".isr_vector"))) extern const InterruptTable hardwareInte ...@@ -213,12 +206,8 @@ __attribute__((section(".isr_vector"))) extern const InterruptTable hardwareInte
nullptr, // Reserved nullptr, // Reserved
nullptr, // Reserved nullptr, // Reserved
PendSV_Handler, // PendSV Handler PendSV_Handler, // PendSV Handler
nullptr, // SysTick Handler (Miosix does not use it) nullptr // SysTick Handler (Miosix does not use it)
#endif //__CORTEX_M != 0 #endif //__CORTEX_M != 0
// The rest of the interrupt table, the one for peripheral interrupts is
// generated programmatically using template metaprogramming to produce the
// proxy functions that allow dynamically registering interrupts.
TableGenerator<numInterrupts>::table
); );
// //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment