Skip to content

Commit 28a5c39

Browse files
committed
renesas-ra/pendsv: Remove preemptive keyboard interrupt feature.
Following the same change to the stm32 port. Signed-off-by: Damien George <damien@micropython.org>
1 parent f2f80c2 commit 28a5c39

File tree

3 files changed

+2
-54
lines changed

3 files changed

+2
-54
lines changed

ports/renesas-ra/pendsv.c

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
#include "pendsv.h"
3232
#include "irq.h"
3333

34-
// This variable is used to save the exception object between a ctrl-C and the
35-
// PENDSV call that actually raises the exception. It must be non-static
36-
// otherwise gcc-5 optimises it away. It can point to the heap but is not
37-
// traced by GC. This is okay because we only ever set it to
38-
// mp_kbd_exception which is in the root-pointer set.
39-
void *pendsv_object;
40-
4134
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
4235
uint32_t pendsv_dispatch_active;
4336
pendsv_dispatch_t pendsv_dispatch_table[PENDSV_DISPATCH_NUM_SLOTS];
@@ -51,24 +44,6 @@ void pendsv_init(void) {
5144
NVIC_SetPriority(PendSV_IRQn, IRQ_PRI_PENDSV);
5245
}
5346

54-
// Call this function to raise a pending exception during an interrupt.
55-
// It will first try to raise the exception "softly" by setting the
56-
// mp_pending_exception variable and hoping that the VM will notice it.
57-
// If this function is called a second time (ie with the mp_pending_exception
58-
// variable already set) then it will force the exception by using the hardware
59-
// PENDSV feature. This will wait until all interrupts are finished then raise
60-
// the given exception object using nlr_jump in the context of the top-level
61-
// thread.
62-
void pendsv_kbd_intr(void) {
63-
if (MP_STATE_MAIN_THREAD(mp_pending_exception) == MP_OBJ_NULL) {
64-
mp_sched_keyboard_interrupt();
65-
} else {
66-
MP_STATE_MAIN_THREAD(mp_pending_exception) = MP_OBJ_NULL;
67-
pendsv_object = &MP_STATE_VM(mp_kbd_exception);
68-
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
69-
}
70-
}
71-
7247
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
7348
void pendsv_schedule_dispatch(size_t slot, pendsv_dispatch_t f) {
7449
pendsv_dispatch_table[slot] = f;
@@ -90,10 +65,7 @@ void pendsv_dispatch_handler(void) {
9065
__attribute__((naked)) void PendSV_Handler(void) {
9166
// Handle a PendSV interrupt
9267
//
93-
// For the case of an asynchronous exception, re-jig the
94-
// stack so that when we return from this interrupt handler
95-
// it returns instead to nlr_jump with argument pendsv_object
96-
// note that stack has a different layout if DEBUG is enabled
68+
// Calls any pending functions in pendsv_dispatch_table.
9769
//
9870
// For the case of a thread switch, swap stacks.
9971
//
@@ -132,27 +104,6 @@ __attribute__((naked)) void PendSV_Handler(void) {
132104
".no_dispatch:\n"
133105
#endif
134106

135-
// Check if there is an active object to throw via nlr_jump
136-
"ldr r1, pendsv_object_ptr\n"
137-
"ldr r0, [r1]\n"
138-
"cmp r0, #0\n"
139-
"beq .no_obj\n"
140-
#if defined(PENDSV_DEBUG)
141-
"str r0, [sp, #8]\n" // store to r0 on stack
142-
#else
143-
"str r0, [sp, #0]\n" // store to r0 on stack
144-
#endif
145-
"mov r0, #0\n"
146-
"str r0, [r1]\n" // clear pendsv_object
147-
"ldr r0, nlr_jump_ptr\n"
148-
#if defined(PENDSV_DEBUG)
149-
"str r0, [sp, #32]\n" // store to pc on stack
150-
#else
151-
"str r0, [sp, #24]\n" // store to pc on stack
152-
#endif
153-
"bx lr\n" // return from interrupt; will return to nlr_jump
154-
".no_obj:\n" // pendsv_object==NULL
155-
156107
#if MICROPY_PY_THREAD
157108
// Do a thread context switch
158109
"push {r4-r11, lr}\n"
@@ -178,7 +129,5 @@ __attribute__((naked)) void PendSV_Handler(void) {
178129
#if defined(PENDSV_DISPATCH_NUM_SLOTS)
179130
"pendsv_dispatch_active_ptr: .word pendsv_dispatch_active\n"
180131
#endif
181-
"pendsv_object_ptr: .word pendsv_object\n"
182-
"nlr_jump_ptr: .word nlr_jump\n"
183132
);
184133
}

ports/renesas-ra/pendsv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ enum {
4848
typedef void (*pendsv_dispatch_t)(void);
4949

5050
void pendsv_init(void);
51-
void pendsv_kbd_intr(void);
5251
void pendsv_schedule_dispatch(size_t slot, pendsv_dispatch_t f);
5352

5453
#endif // MICROPY_INCLUDED_RENESAS_RA_PENDSV_H

ports/renesas-ra/uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static KEYEX_CB keyex_cb[MICROPY_HW_MAX_UART] = {(KEYEX_CB)NULL};
4949

5050
static int chk_kbd_interrupt(int d) {
5151
if (d == mp_interrupt_char) {
52-
pendsv_kbd_intr();
52+
mp_sched_keyboard_interrupt();
5353
return 1;
5454
} else {
5555
return 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy