File tree Expand file tree Collapse file tree 3 files changed +102
-0
lines changed Expand file tree Collapse file tree 3 files changed +102
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3
+ * Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+
9
+
10
+ #include <zephyr/toolchain.h>
11
+ #include <microblaze/microblaze_regs.h>
12
+ #include <microblaze/microblaze_asm.h>
13
+
14
+
15
+ .extern _interrupt_handler
16
+ .globl microblaze_emulate_isr
17
+
18
+ /* void microblaze_emulate_isr(void)
19
+ * Must be called with irqs unlocked!
20
+ * Must be called via inline asm with r14 as link register
21
+ */
22
+ SECTION_FUNC(exception.other, microblaze_emulate_isr)
23
+ .ent microblaze_emulate_isr
24
+ /* Set the interrupt return address to after the
25
+ * call to microblaze_emulate_isr */
26
+ ADD_IMM(r14, 4 )
27
+ brai _interrupt_handler
28
+ .end microblaze_emulate_isr
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3
+ * Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+
9
+
10
+ #include <zephyr/irq_offload.h>
11
+ #include <zephyr/kernel.h>
12
+ #include <zephyr/kernel_structs.h>
13
+
14
+ #include <microblaze/emulate_isr.h>
15
+
16
+ #pragma message "MicroBlaze irq_offload is experimental"
17
+
18
+ volatile irq_offload_routine_t _offload_routine ;
19
+ static volatile const void * offload_param ;
20
+
21
+ /* Called by _enter_irq if regardless of pending irqs.
22
+ * Just in case the offload routine itself reenables & generates
23
+ * an interrupt, clear the offload_routine global before executing.
24
+ */
25
+ void z_irq_do_offload (void )
26
+ {
27
+ irq_offload_routine_t tmp ;
28
+
29
+ if (!_offload_routine ) {
30
+ return ;
31
+ }
32
+
33
+ tmp = _offload_routine ;
34
+ _offload_routine = NULL ;
35
+
36
+ tmp ((const void * )offload_param );
37
+ }
38
+
39
+ void arch_irq_offload (irq_offload_routine_t routine , const void * parameter )
40
+ {
41
+ microblaze_disable_interrupts ();
42
+
43
+ _offload_routine = routine ;
44
+ offload_param = parameter ;
45
+
46
+ EMULATE_ISR ();
47
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3
+ * Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+
9
+ #ifndef ZEPHYR_ARCH_MICROBLAZE_INCLUDE_MICROBLAZE_EMULATE_ISR_H_
10
+ #define ZEPHYR_ARCH_MICROBLAZE_INCLUDE_MICROBLAZE_EMULATE_ISR_H_
11
+
12
+ #include <zephyr/arch/microblaze/arch.h>
13
+
14
+ #include <microblaze/mb_interface.h>
15
+
16
+ extern void microblaze_emulate_isr (void );
17
+
18
+ #define EMULATE_ISR () __asm__ volatile("\tbralid r14, microblaze_emulate_isr\n\tnop\n")
19
+
20
+ #define EMULATE_IRQ (irq ) \
21
+ do { \
22
+ microblaze_disable_interrupts(); \
23
+ arch_irq_set_emulated_pending(irq); \
24
+ __asm__ volatile("\tbralid r14, microblaze_emulate_isr\n\tnop\n"); \
25
+ } while (0)
26
+
27
+ #endif /* ZEPHYR_ARCH_MICROBLAZE_INCLUDE_MICROBLAZE_EMULATE_ISR_H_ */
You can’t perform that action at this time.
0 commit comments