21 #ifndef ARM_CORTEX_COMMON_VECTOR_TABLE_HPP_INCLUDED 22 #define ARM_CORTEX_COMMON_VECTOR_TABLE_HPP_INCLUDED 24 #include <arch/nvic.hpp> 27 #include <type_traits> 32 #ifndef OPENMPTL_SIMULATION 33 static_assert(
sizeof(
isr_t) == 4,
"wrong size for isr function pointer");
34 static_assert(
alignof(
isr_t) == 4,
"wrong alignment for isr function pointer table");
35 static_assert(
sizeof(uint32_t *) == 4,
"wrong size for top-of-stack pointer");
36 static_assert(
alignof(uint32_t *) == 4,
"wrong alignment for top-of-stack pointer");
39 template<std::
size_t vt_size>
58 template<
const uint32_t *
stack_top,
typename... Tp>
59 struct vector_table_impl {
60 static constexpr std::size_t vt_size =
sizeof...(Tp);
61 static constexpr std::size_t size = vt_size + 1;
64 #ifdef OPENMPTL_SIMULATION 66 static void dump_types(
void) {
67 std::cout <<
"*** irq handler types:" << std::endl;
68 dump_irq_types<Tp...>()();
90 template<
const uint32_t *
stack_top,
typename... Tp>
98 template<
unsigned int N,
100 typename irq_handler_list,
104 struct make_vector_table
106 static constexpr
int irqn = (N - 1) + irqn_offset;
107 using irq_handler_resource = mpl::unique_irq_handler<irq_handler_list, irqn>;
113 using irq_handler_type =
typename std::conditional<
115 std::is_void< irq_handler_resource >::value ),
117 irq_handler_resource >::type;
120 using type =
typename make_vector_table<
132 template<
int irqn_offset,
133 typename irq_handler_list,
137 struct make_vector_table< 0, irqn_offset, irq_handler_list, default_isr, stack_top, Tp... > {
138 using type = vector_table_impl<
stack_top, Tp...>;
168 template<const u
int32_t *stack_top,
typename irq_handler_list, isr_t default_isr =
nullptr >
170 : mpl::make_vector_table<
171 irq::numof_interrupt_channels - irq::reset::irqn,
184 static_assert(
irq::reset::irqn < 0,
"irq::reset::irqn must be a negative value");
185 static_assert(irq::numof_interrupt_channels >= 0,
"invalid irq::numof_interrupt_channels");
186 static_assert(
sizeof(type::value) ==
sizeof(
isr_t) * (1 + irq::numof_interrupt_channels + numof_core_exceptions),
187 "IRQ vector table size error");
189 #ifdef OPENMPTL_SIMULATION 190 static void dump_size(
void) {
192 std::cout <<
"*** vector table size:" << std::endl;
193 std::cout <<
"stack_top pointer: " << std::setw(w) << 1 << std::endl;
194 std::cout <<
"cortex core exceptions: " << std::setw(w) << numof_core_exceptions << std::endl;
195 std::cout <<
"irq channels: " << std::setw(w) << irq::numof_interrupt_channels << std::endl;
196 std::cout <<
"total size: " << std::setw(w) << type::size << std::endl;
205 static void dump_vector(
void) {
206 int vt_size = type::vt_size;
207 auto vt = type::value;
209 std::cout <<
"*** vector table dump:" << std::endl;
210 std::cout << std::dec <<
" 0 (TOS) : 0x" << std::hex << (
unsigned long)vt.stack_top << std::endl;
211 for(
int i = 0; i < vt_size; i++) {
212 std::cout << std::dec << std::setw(3) << (1 + i) <<
" " <<
213 "(" << std::setw(3) << (i - irq_channel_offset) <<
")" <<
214 " : 0x" << std::hex << (
unsigned long)vt.isr_vector[i] << std::endl;
217 #endif // OPENMPTL_SIMULATION 222 #endif // ARM_CORTEX_COMMON_VECTOR_TABLE_HPP_INCLUDED
Definition: vector_table.hpp:40
static constexpr bool reserved_irqn(int irqn)
Definition: nvic.hpp:134
Provides a static vector table (value[], see vector_table_impl above), to be initialized in section "...
Definition: vector_table.hpp:169
const uint32_t * stack_top
Definition: vector_table.hpp:41
static constexpr int irqn
Definition: nvic.hpp:36
isr_t isr_vector[vt_size]
Definition: vector_table.hpp:42