記一次中斷註冊

lethe1203發表於2024-03-17
中斷註冊函式:
 1 #define IRQ_REGISTER(__isrName, __isrFn, __para, __description, __attr)          \
 2         __attribute__((section(".irq_table"))) struct isr_struct       \
 3                 _section_item_##__isrName##_isr = {                            \
 4                         .isrFn = __isrFn,                                      \
 5                         .para = __para,                                        \
 6                         .attr = __attr,                                        \
 7                         .isrName = __isrName,                                  \
 8                         .description = __description,                          \
 9                 }
10 
11 #define FIQ_REGISTER(__isrName, __isrFn, __para, __description, __attr)          \
12         __attribute__((section(".fiq_table"))) struct isr_struct       \
13                 _section_item_##__isrName##_isr = {                            \
14                         .isrFn = __isrFn,                                      \
15                         .para = __para,                                        \
16                         .attr = __attr,                                        \
17                         .isrName = __isrName,                                  \
18                         .description = __description,                          \
19                 }

連結指令碼vmimage.lds.S
 1 ENTRY(_start)
 2 SECTIONS
 3 {
 4 
 5         . = 0x800000000;
 6 
 7         . = ALIGN(8);
 8         .text :
 9         {
10                 *(.__image_copy_start)
11                 HEADDIR/start.o (.text*)
12         }
13 
14         .text_rest :
15         {
16                 *(.text*)
17         }
18 
19         . = ALIGN(8);
20         .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
21 
22         . = ALIGN(8);
23         .data : {
24                 *(.data*)
25         }
26         . = ALIGN(8);
27 
28 
29 
30         . = ALIGN(8);
31         .irq_table : {
32                 __section_irq_table_start = .;
33                 KEEP(*(SORT(.irq_table*)));        // 連結時將中斷處理函式註冊到此處
34                 __section_irq_table_end = .;
35         }
36 
37          ...
38 }

相關文章