diff --git a/demos/STM32/RT-STM32G474RE-NUCLEO64-SB_HOST_STATIC/readme_debug.txt b/demos/STM32/RT-STM32G474RE-NUCLEO64-SB_HOST_STATIC/readme_debug.txt index 4536bbd50..1be276057 100644 --- a/demos/STM32/RT-STM32G474RE-NUCLEO64-SB_HOST_STATIC/readme_debug.txt +++ b/demos/STM32/RT-STM32G474RE-NUCLEO64-SB_HOST_STATIC/readme_debug.txt @@ -4,9 +4,10 @@ The launch configurations under: Contain hardcoded paths prefixed like: - /home/giovanni/Projects/ChibiStudio/chibios_trunk/demos/various/SB-CLIENT-32k-08070000-4k-2001E000/build/sb.elf + /home/giovanni/Projects/ChibiStudio/chibios_trunk/demos/various/SB-CLIENT-128k-08040000-4k-2001E000/build/sb.elf Replace the initial part up to "chibios_trunk" with the path of your ChibiOS directory before attempting a debug session using Eclipse. In addition, you -need also to compile the "SB-CLIENT-32k-08070000-4k-2001E000" project, its -image (sb.elf) is loaded inside the demo sandbox. +need also to compile the "SB-CLIENT-128k-08040000-16k-20018000" and +"SB-CLIENT-128k-08060000-16k-2001C000" projects, their image (sb.elf) is + loaded inside the demo sandboxes. diff --git a/os/common/ports/ARMv7-M-ALT/chcore.c b/os/common/ports/ARMv7-M-ALT/chcore.c index cc26279a9..e4ed1fe27 100644 --- a/os/common/ports/ARMv7-M-ALT/chcore.c +++ b/os/common/ports/ARMv7-M-ALT/chcore.c @@ -68,38 +68,18 @@ CC_NO_INLINE uint32_t port_get_s_psp(void) { return (uint32_t)__port_syscall_get_s_psp(__sch_get_currthread()); } -CC_WEAK void port_syscall(struct port_extctx *ctxp, uint32_t n) { +CC_WEAK void __port_do_fastcall_entry(uint32_t n) { - (void)ctxp; (void)n; - chSysHalt("unimplemented syscall"); + chSysHalt("unimplemented fastcall"); } CC_WEAK void __port_do_syscall_entry(uint32_t n) { - thread_t *tp = __sch_get_currthread(); - struct port_extctx *ectxp, *newctxp; - uint32_t u_psp; - /* Caller context in unprivileged memory.*/ - u_psp = __get_PSP(); - ectxp = (struct port_extctx *)u_psp; - __port_syscall_set_u_psp(tp, u_psp); + (void)n; - /* Return context for change in privileged mode.*/ - newctxp = ((struct port_extctx *)__port_syscall_get_s_psp(tp)) - 1; - - /* Creating context for return in privileged mode.*/ - newctxp->r0 = (uint32_t)ectxp; - newctxp->r1 = n; - newctxp->pc = (uint32_t)port_syscall; - newctxp->xpsr = 0x01000000U; -#if CORTEX_USE_FPU == TRUE - newctxp->fpscr = FPU->FPDSCR; -#endif - - /* Switching PSP to the privileged mode PSP.*/ - __set_PSP((uint32_t)newctxp); + chSysHalt("unimplemented syscall"); } CC_WEAK void __port_do_syscall_return(void) { diff --git a/os/common/ports/ARMv7-M-ALT/compilers/GCC/chcoreasm.S b/os/common/ports/ARMv7-M-ALT/compilers/GCC/chcoreasm.S index 4d8f40452..0d325b6eb 100644 --- a/os/common/ports/ARMv7-M-ALT/compilers/GCC/chcoreasm.S +++ b/os/common/ports/ARMv7-M-ALT/compilers/GCC/chcoreasm.S @@ -230,6 +230,8 @@ SVC_Handler: ldr r3, [r2, #24] /* PC position. */ ldrh r0, [r3, #-2] /* SVC opcode. */ and r0, #255 +// cmp r0, #0xF0 +// bge __port_do_fastcall_entry b __port_do_syscall_entry frompriv: diff --git a/os/sb/host/compilers/GCC/sbexc.S b/os/sb/host/compilers/GCC/sbexc.S index f38bfdfc9..4abc55cda 100644 --- a/os/sb/host/compilers/GCC/sbexc.S +++ b/os/sb/host/compilers/GCC/sbexc.S @@ -49,8 +49,8 @@ .align 2 .thumb_func - .global port_syscall -port_syscall: + .global __sb_dispatch_syscall +__sb_dispatch_syscall: ldr r3, =sb_syscalls ldr.w r3, [r3, r1, lsl #2] blx r3 diff --git a/os/sb/host/sbapi.c b/os/sb/host/sbapi.c index bb0b56798..f6b065127 100644 --- a/os/sb/host/sbapi.c +++ b/os/sb/host/sbapi.c @@ -1232,4 +1232,31 @@ void __sb_abort(msg_t msg) { chSysHalt("zombies"); } +void __port_do_syscall_entry(uint32_t n) { + extern void __sb_dispatch_syscall(struct port_extctx *ctxp, uint32_t n); + thread_t *tp = __sch_get_currthread(); + struct port_extctx *ectxp, *newctxp; + uint32_t u_psp; + + /* Caller context in unprivileged memory.*/ + u_psp = __get_PSP(); + ectxp = (struct port_extctx *)u_psp; + __port_syscall_set_u_psp(tp, u_psp); + + /* Return context for change in privileged mode.*/ + newctxp = ((struct port_extctx *)__port_syscall_get_s_psp(tp)) - 1; + + /* Creating context for return in privileged mode.*/ + newctxp->r0 = (uint32_t)ectxp; + newctxp->r1 = n; + newctxp->pc = (uint32_t)__sb_dispatch_syscall; + newctxp->xpsr = 0x01000000U; +#if CORTEX_USE_FPU == TRUE + newctxp->fpscr = FPU->FPDSCR; +#endif + + /* Switching PSP to the privileged mode PSP.*/ + __set_PSP((uint32_t)newctxp); +} + /** @} */ diff --git a/os/sb/host/sbhost.h b/os/sb/host/sbhost.h index ca34974f6..d6a99ff78 100644 --- a/os/sb/host/sbhost.h +++ b/os/sb/host/sbhost.h @@ -57,7 +57,6 @@ extern sb_t sb; #ifdef __cplusplus extern "C" { #endif - void port_syscall(struct port_extctx *ctxp, uint32_t n); size_t sb_strv_getsize(const char *v[], int *np); void sb_strv_copy(const char *sp[], void *dp, int n); bool sb_is_valid_read_range(sb_class_t *sbp, const void *start, size_t size);