SB fastcalls support, not complete.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15766 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2022-09-06 13:12:32 +00:00
parent de74d1f890
commit 629e810f65
6 changed files with 39 additions and 30 deletions

View File

@ -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.

View File

@ -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) {

View File

@ -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:

View File

@ -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

View File

@ -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);
}
/** @} */

View File

@ -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);