kernel: use uintptr_t for syscall arguments
We need to pass system call args using a register-width data type and not hard-code this to u32_t. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
e108898270
commit
800b35f598
8 changed files with 107 additions and 77 deletions
|
@ -149,7 +149,7 @@ Inside this header is the body of :c:func:`k_sem_init()`::
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
if (z_syscall_trap()) {
|
if (z_syscall_trap()) {
|
||||||
z_arch_syscall_invoke3(*(u32_t *)&sem, *(u32_t *)&initial_count, *(u32_t *)&limit, K_SYSCALL_K_SEM_INIT);
|
z_arch_syscall_invoke3(*(uintptr_t *)&sem, *(uintptr_t *)&initial_count, *(uintptr_t *)&limit, K_SYSCALL_K_SEM_INIT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
compiler_barrier();
|
compiler_barrier();
|
||||||
|
|
|
@ -38,9 +38,10 @@ extern "C" {
|
||||||
* just for enabling CONFIG_USERSPACE on arc w/o errors.
|
* just for enabling CONFIG_USERSPACE on arc w/o errors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke6(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6,
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
u32_t call_id)
|
uintptr_t arg5, uintptr_t arg6,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -62,8 +63,10 @@ static inline u32_t z_arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke5(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t call_id)
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t arg5,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -84,8 +87,9 @@ static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke4(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t call_id)
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -105,8 +109,9 @@ static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke3(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t call_id)
|
uintptr_t arg3,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -124,7 +129,8 @@ static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2, u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke2(uintptr_t arg1, uintptr_t arg2,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -141,7 +147,7 @@ static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2, u32_t call_id
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke1(uintptr_t arg1, uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r6 __asm__("r6") = call_id;
|
register u32_t r6 __asm__("r6") = call_id;
|
||||||
|
@ -157,7 +163,7 @@ static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke0(u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke0(uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0");
|
register u32_t ret __asm__("r0");
|
||||||
register u32_t r6 __asm__("r6") = call_id;
|
register u32_t r6 __asm__("r6") = call_id;
|
||||||
|
|
|
@ -36,9 +36,10 @@ extern "C" {
|
||||||
/* Syscall invocation macros. arm-specific machine constraints used to ensure
|
/* Syscall invocation macros. arm-specific machine constraints used to ensure
|
||||||
* args land in the proper registers.
|
* args land in the proper registers.
|
||||||
*/
|
*/
|
||||||
static inline u32_t z_arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke6(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6,
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
u32_t call_id)
|
uintptr_t arg5, uintptr_t arg6,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -58,8 +59,10 @@ static inline u32_t z_arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke5(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t call_id)
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t arg5,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -78,8 +81,9 @@ static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke4(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t call_id)
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -97,8 +101,9 @@ static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke3(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t call_id)
|
uintptr_t arg3,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -114,7 +119,8 @@ static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2, u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke2(uintptr_t arg1, uintptr_t arg2,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r1 __asm__("r1") = arg2;
|
register u32_t r1 __asm__("r1") = arg2;
|
||||||
|
@ -129,7 +135,8 @@ static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2, u32_t call_id
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke1(uintptr_t arg1,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0") = arg1;
|
register u32_t ret __asm__("r0") = arg1;
|
||||||
register u32_t r6 __asm__("r6") = call_id;
|
register u32_t r6 __asm__("r6") = call_id;
|
||||||
|
@ -142,7 +149,7 @@ static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke0(u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke0(uintptr_t call_id)
|
||||||
{
|
{
|
||||||
register u32_t ret __asm__("r0");
|
register u32_t ret __asm__("r0");
|
||||||
register u32_t r6 __asm__("r6") = call_id;
|
register u32_t r6 __asm__("r6") = call_id;
|
||||||
|
|
|
@ -34,9 +34,10 @@ extern "C" {
|
||||||
* z_x86_syscall_entry_stub in userspace.S
|
* z_x86_syscall_entry_stub in userspace.S
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke6(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6,
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
u32_t call_id)
|
uintptr_t arg5, uintptr_t arg6,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
u32_t ret;
|
u32_t ret;
|
||||||
|
|
||||||
|
@ -52,8 +53,10 @@ static inline u32_t z_arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke5(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t call_id)
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t arg5,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
u32_t ret;
|
u32_t ret;
|
||||||
|
|
||||||
|
@ -65,8 +68,9 @@ static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke4(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t call_id)
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
u32_t ret;
|
u32_t ret;
|
||||||
|
|
||||||
|
@ -78,8 +82,9 @@ static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke3(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t call_id)
|
uintptr_t arg3,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
u32_t ret;
|
u32_t ret;
|
||||||
|
|
||||||
|
@ -90,7 +95,8 @@ static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2, u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke2(uintptr_t arg1, uintptr_t arg2,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
u32_t ret;
|
u32_t ret;
|
||||||
|
|
||||||
|
@ -102,7 +108,8 @@ static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2, u32_t call_id
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke1(uintptr_t arg1,
|
||||||
|
uintptr_t call_id)
|
||||||
{
|
{
|
||||||
u32_t ret;
|
u32_t ret;
|
||||||
|
|
||||||
|
@ -114,7 +121,7 @@ static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32_t z_arch_syscall_invoke0(u32_t call_id)
|
static inline uintptr_t z_arch_syscall_invoke0(uintptr_t call_id)
|
||||||
{
|
{
|
||||||
u32_t ret;
|
u32_t ret;
|
||||||
|
|
||||||
|
|
|
@ -350,7 +350,7 @@ void z_arch_irq_offload(irq_offload_routine_t routine, void *parameter);
|
||||||
* @param call_id System call ID
|
* @param call_id System call ID
|
||||||
* @return Return value of the system call. Void system calls return 0 here.
|
* @return Return value of the system call. Void system calls return 0 here.
|
||||||
*/
|
*/
|
||||||
static inline u32_t z_arch_syscall_invoke0(u32_t call_id);
|
static inline uintptr_t z_arch_syscall_invoke0(uintptr_t call_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke a system call with 1 argument.
|
* Invoke a system call with 1 argument.
|
||||||
|
@ -362,7 +362,8 @@ static inline u32_t z_arch_syscall_invoke0(u32_t call_id);
|
||||||
* kernel-side dispatch table
|
* kernel-side dispatch table
|
||||||
* @return Return value of the system call. Void system calls return 0 here.
|
* @return Return value of the system call. Void system calls return 0 here.
|
||||||
*/
|
*/
|
||||||
static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id);
|
static inline uintptr_t z_arch_syscall_invoke1(uintptr_t arg1,
|
||||||
|
uintptr_t call_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke a system call with 2 arguments.
|
* Invoke a system call with 2 arguments.
|
||||||
|
@ -375,8 +376,8 @@ static inline u32_t z_arch_syscall_invoke1(u32_t arg1, u32_t call_id);
|
||||||
* kernel-side dispatch table
|
* kernel-side dispatch table
|
||||||
* @return Return value of the system call. Void system calls return 0 here.
|
* @return Return value of the system call. Void system calls return 0 here.
|
||||||
*/
|
*/
|
||||||
static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2,
|
static inline uintptr_t z_arch_syscall_invoke2(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t call_id);
|
uintptr_t call_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke a system call with 3 arguments.
|
* Invoke a system call with 3 arguments.
|
||||||
|
@ -390,8 +391,9 @@ static inline u32_t z_arch_syscall_invoke2(u32_t arg1, u32_t arg2,
|
||||||
* kernel-side dispatch table
|
* kernel-side dispatch table
|
||||||
* @return Return value of the system call. Void system calls return 0 here.
|
* @return Return value of the system call. Void system calls return 0 here.
|
||||||
*/
|
*/
|
||||||
static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke3(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t call_id);
|
uintptr_t arg3,
|
||||||
|
uintptr_t call_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke a system call with 4 arguments.
|
* Invoke a system call with 4 arguments.
|
||||||
|
@ -406,8 +408,9 @@ static inline u32_t z_arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
* kernel-side dispatch table
|
* kernel-side dispatch table
|
||||||
* @return Return value of the system call. Void system calls return 0 here.
|
* @return Return value of the system call. Void system calls return 0 here.
|
||||||
*/
|
*/
|
||||||
static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke4(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t call_id);
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t call_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke a system call with 5 arguments.
|
* Invoke a system call with 5 arguments.
|
||||||
|
@ -423,9 +426,10 @@ static inline u32_t z_arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
* kernel-side dispatch table
|
* kernel-side dispatch table
|
||||||
* @return Return value of the system call. Void system calls return 0 here.
|
* @return Return value of the system call. Void system calls return 0 here.
|
||||||
*/
|
*/
|
||||||
static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke5(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5,
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
u32_t call_id);
|
uintptr_t arg5,
|
||||||
|
uintptr_t call_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke a system call with 6 arguments.
|
* Invoke a system call with 6 arguments.
|
||||||
|
@ -442,9 +446,10 @@ static inline u32_t z_arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||||
* kernel-side dispatch table
|
* kernel-side dispatch table
|
||||||
* @return Return value of the system call. Void system calls return 0 here.
|
* @return Return value of the system call. Void system calls return 0 here.
|
||||||
*/
|
*/
|
||||||
static inline u32_t z_arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
|
static inline uintptr_t z_arch_syscall_invoke6(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6,
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
u32_t call_id);
|
uintptr_t arg5, uintptr_t arg6,
|
||||||
|
uintptr_t call_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicate whether we are currently running in user mode
|
* Indicate whether we are currently running in user mode
|
||||||
|
|
|
@ -83,8 +83,9 @@ extern "C" {
|
||||||
* return void
|
* return void
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef u32_t (*_k_syscall_handler_t)(u32_t arg1, u32_t arg2, u32_t arg3,
|
typedef uintptr_t (*_k_syscall_handler_t)(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6,
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t arg5, uintptr_t arg6,
|
||||||
void *ssf);
|
void *ssf);
|
||||||
|
|
||||||
/* True if a syscall function must trap to the kernel, usually a
|
/* True if a syscall function must trap to the kernel, usually a
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <app_memory/app_memdomain.h>
|
#include <app_memory/app_memdomain.h>
|
||||||
#include <sys/libc-hooks.h>
|
#include <sys/libc-hooks.h>
|
||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#ifdef Z_LIBC_PARTITION_EXISTS
|
#ifdef Z_LIBC_PARTITION_EXISTS
|
||||||
K_APPMEM_PARTITION_DEFINE(z_libc_partition);
|
K_APPMEM_PARTITION_DEFINE(z_libc_partition);
|
||||||
|
@ -753,16 +754,19 @@ void z_app_shmem_bss_zero(void)
|
||||||
* Default handlers if otherwise unimplemented
|
* Default handlers if otherwise unimplemented
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static u32_t handler_bad_syscall(u32_t bad_id, u32_t arg2, u32_t arg3,
|
static uintptr_t handler_bad_syscall(uintptr_t bad_id, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6, void *ssf)
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t arg5, uintptr_t arg6,
|
||||||
|
void *ssf)
|
||||||
{
|
{
|
||||||
LOG_ERR("Bad system call id %u invoked", bad_id);
|
LOG_ERR("Bad system call id %" PRIuPTR " invoked", bad_id);
|
||||||
z_arch_syscall_oops(_current_cpu->syscall_frame);
|
z_arch_syscall_oops(_current_cpu->syscall_frame);
|
||||||
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
|
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32_t handler_no_syscall(u32_t arg1, u32_t arg2, u32_t arg3,
|
static uintptr_t handler_no_syscall(uintptr_t arg1, uintptr_t arg2,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6, void *ssf)
|
uintptr_t arg3, uintptr_t arg4,
|
||||||
|
uintptr_t arg5, uintptr_t arg6, void *ssf)
|
||||||
{
|
{
|
||||||
LOG_ERR("Unimplemented system call");
|
LOG_ERR("Unimplemented system call");
|
||||||
z_arch_syscall_oops(_current_cpu->syscall_frame);
|
z_arch_syscall_oops(_current_cpu->syscall_frame);
|
||||||
|
|
|
@ -64,7 +64,7 @@ list_template = """
|
||||||
|
|
||||||
#ifndef _ASMLANGUAGE
|
#ifndef _ASMLANGUAGE
|
||||||
|
|
||||||
#include <zephyr/types.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#endif /* _ASMLANGUAGE */
|
#endif /* _ASMLANGUAGE */
|
||||||
|
|
||||||
|
@ -107,14 +107,14 @@ extern "C" {
|
||||||
"""
|
"""
|
||||||
|
|
||||||
handler_template = """
|
handler_template = """
|
||||||
extern u32_t z_hdlr_%s(u32_t arg1, u32_t arg2, u32_t arg3,
|
extern uintptr_t z_hdlr_%s(uintptr_t arg1, uintptr_t arg2, uintptr_t arg3,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6, void *ssf);
|
uintptr_t arg4, uintptr_t arg5, uintptr_t arg6, void *ssf);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
weak_template = """
|
weak_template = """
|
||||||
__weak ALIAS_OF(handler_no_syscall)
|
__weak ALIAS_OF(handler_no_syscall)
|
||||||
u32_t %s(u32_t arg1, u32_t arg2, u32_t arg3,
|
uintptr_t %s(uintptr_t arg1, uintptr_t arg2, uintptr_t arg3,
|
||||||
u32_t arg4, u32_t arg5, u32_t arg6, void *ssf);
|
uintptr_t arg4, uintptr_t arg5, uintptr_t arg6, void *ssf);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ def need_split(argtype):
|
||||||
# but it doesn't matter as long as they are consistently
|
# but it doesn't matter as long as they are consistently
|
||||||
# generated.
|
# generated.
|
||||||
def union_decl(type):
|
def union_decl(type):
|
||||||
return "union { struct { u32_t lo, hi; } split; %s val; }" % type
|
return "union { struct { uintptr_t lo, hi; } split; %s val; }" % type
|
||||||
|
|
||||||
def wrapper_defs(func_name, func_type, args):
|
def wrapper_defs(func_name, func_type, args):
|
||||||
ret64 = func_type in types64
|
ret64 = func_type in types64
|
||||||
|
@ -163,10 +163,10 @@ def wrapper_defs(func_name, func_type, args):
|
||||||
mrsh_args.append("parm%d.split.hi" % nsplit)
|
mrsh_args.append("parm%d.split.hi" % nsplit)
|
||||||
nsplit += 1
|
nsplit += 1
|
||||||
else:
|
else:
|
||||||
mrsh_args.append("*(u32_t *)&" + argname)
|
mrsh_args.append("*(uintptr_t *)&" + argname)
|
||||||
|
|
||||||
if ret64:
|
if ret64:
|
||||||
mrsh_args.append("(u32_t)&ret64")
|
mrsh_args.append("(uintptr_t)&ret64")
|
||||||
|
|
||||||
decl_arglist = ", ".join([" ".join(argrec) for argrec in args])
|
decl_arglist = ", ".join([" ".join(argrec) for argrec in args])
|
||||||
|
|
||||||
|
@ -183,10 +183,10 @@ def wrapper_defs(func_name, func_type, args):
|
||||||
wrap += "\t\t" + "parm%d.val = %s;\n" % (parmnum, argname)
|
wrap += "\t\t" + "parm%d.val = %s;\n" % (parmnum, argname)
|
||||||
|
|
||||||
if len(mrsh_args) > 6:
|
if len(mrsh_args) > 6:
|
||||||
wrap += "\t\t" + "u32_t more[] = {\n"
|
wrap += "\t\t" + "uintptr_t more[] = {\n"
|
||||||
wrap += "\t\t\t" + (",\n\t\t\t".join(mrsh_args[5:])) + "\n"
|
wrap += "\t\t\t" + (",\n\t\t\t".join(mrsh_args[5:])) + "\n"
|
||||||
wrap += "\t\t" + "};\n"
|
wrap += "\t\t" + "};\n"
|
||||||
mrsh_args[5:] = ["(u32_t) &more"]
|
mrsh_args[5:] = ["(uintptr_t) &more"]
|
||||||
|
|
||||||
syscall_id = "K_SYSCALL_" + func_name.upper()
|
syscall_id = "K_SYSCALL_" + func_name.upper()
|
||||||
invoke = ("z_arch_syscall_invoke%d(%s)"
|
invoke = ("z_arch_syscall_invoke%d(%s)"
|
||||||
|
@ -225,12 +225,12 @@ def mrsh_rval(mrsh_num, total):
|
||||||
if mrsh_num < 5 or total <= 6:
|
if mrsh_num < 5 or total <= 6:
|
||||||
return "arg%d" % mrsh_num
|
return "arg%d" % mrsh_num
|
||||||
else:
|
else:
|
||||||
return "(((u32_t *)more)[%d])" % (mrsh_num - 5)
|
return "(((uintptr_t *)more)[%d])" % (mrsh_num - 5)
|
||||||
|
|
||||||
def marshall_defs(func_name, func_type, args):
|
def marshall_defs(func_name, func_type, args):
|
||||||
mrsh_name = "z_mrsh_" + func_name
|
mrsh_name = "z_mrsh_" + func_name
|
||||||
|
|
||||||
nmrsh = 0 # number of marshalled u32_t parameter
|
nmrsh = 0 # number of marshalled uintptr_t parameter
|
||||||
vrfy_parms = [] # list of (arg_num, mrsh_or_parm_num, bool_is_split)
|
vrfy_parms = [] # list of (arg_num, mrsh_or_parm_num, bool_is_split)
|
||||||
split_parms = [] # list of a (arg_num, mrsh_num) for each split
|
split_parms = [] # list of a (arg_num, mrsh_num) for each split
|
||||||
for i, (argtype, _) in enumerate(args):
|
for i, (argtype, _) in enumerate(args):
|
||||||
|
@ -249,11 +249,11 @@ def marshall_defs(func_name, func_type, args):
|
||||||
decl_arglist = ", ".join([" ".join(argrec) for argrec in args])
|
decl_arglist = ", ".join([" ".join(argrec) for argrec in args])
|
||||||
mrsh = "extern %s z_vrfy_%s(%s);\n" % (func_type, func_name, decl_arglist)
|
mrsh = "extern %s z_vrfy_%s(%s);\n" % (func_type, func_name, decl_arglist)
|
||||||
|
|
||||||
mrsh += "u32_t %s(u32_t arg0, u32_t arg1, u32_t arg2,\n" % mrsh_name
|
mrsh += "uintptr_t %s(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,\n" % mrsh_name
|
||||||
if nmrsh <= 6:
|
if nmrsh <= 6:
|
||||||
mrsh += "\t\t" + "u32_t arg3, u32_t arg4, u32_t arg5, void *ssf)\n"
|
mrsh += "\t\t" + "uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, void *ssf)\n"
|
||||||
else:
|
else:
|
||||||
mrsh += "\t\t" + "u32_t arg3, u32_t arg4, void *more, void *ssf)\n"
|
mrsh += "\t\t" + "uintptr_t arg3, uintptr_t arg4, void *more, void *ssf)\n"
|
||||||
mrsh += "{\n"
|
mrsh += "{\n"
|
||||||
mrsh += "\t" + "_current_cpu->syscall_frame = ssf;\n"
|
mrsh += "\t" + "_current_cpu->syscall_frame = ssf;\n"
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ def marshall_defs(func_name, func_type, args):
|
||||||
|
|
||||||
if nmrsh > 6:
|
if nmrsh > 6:
|
||||||
mrsh += ("\tZ_OOPS(Z_SYSCALL_MEMORY_READ(more, "
|
mrsh += ("\tZ_OOPS(Z_SYSCALL_MEMORY_READ(more, "
|
||||||
+ str(nmrsh - 6) + " * sizeof(u32_t)));\n")
|
+ str(nmrsh - 6) + " * sizeof(uintptr_t)));\n")
|
||||||
|
|
||||||
for i, split_rec in enumerate(split_parms):
|
for i, split_rec in enumerate(split_parms):
|
||||||
arg_num, mrsh_num = split_rec
|
arg_num, mrsh_num = split_rec
|
||||||
|
@ -293,7 +293,7 @@ def marshall_defs(func_name, func_type, args):
|
||||||
mrsh += "\t" + "*%s = ret;\n" % ptr
|
mrsh += "\t" + "*%s = ret;\n" % ptr
|
||||||
mrsh += "\t" + "return 0;\n"
|
mrsh += "\t" + "return 0;\n"
|
||||||
else:
|
else:
|
||||||
mrsh += "\t" + "return (u32_t) ret;\n"
|
mrsh += "\t" + "return (uintptr_t) ret;\n"
|
||||||
|
|
||||||
mrsh += "}\n"
|
mrsh += "}\n"
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ def main():
|
||||||
if not name in noweak])
|
if not name in noweak])
|
||||||
|
|
||||||
# The "noweak" ones just get a regular declaration
|
# The "noweak" ones just get a regular declaration
|
||||||
weak_defines += "\n".join(["extern u32_t %s(u32_t arg1, u32_t arg2, u32_t arg3, u32_t arg4, u32_t arg5, u32_t arg6, void *ssf);"
|
weak_defines += "\n".join(["extern uintptr_t %s(uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, uintptr_t arg6, void *ssf);"
|
||||||
% s for s in noweak])
|
% s for s in noweak])
|
||||||
|
|
||||||
fp.write(table_template % (weak_defines,
|
fp.write(table_template % (weak_defines,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue