From d619a185a33f958b083d21022cd6ee586f848817 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 25 Oct 2016 21:40:26 +0100 Subject: [PATCH] v68: more fixing --- Kernel/platform-v68/config.h | 6 ++--- Kernel/platform-v68/main.c | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/Kernel/platform-v68/config.h b/Kernel/platform-v68/config.h index 6e36c61c..acc54e15 100644 --- a/Kernel/platform-v68/config.h +++ b/Kernel/platform-v68/config.h @@ -11,7 +11,7 @@ #define CONFIG_SWAP_ONLY #define CONFIG_USERMEM_DIRECT #define CONFIG_BANKS 1 -#define PROC_SIZE 128 +#define PROC_SIZE 128 /* 64K, 128 * 512 */ #define CONFIG_SPLIT_UDATA #define UDATA_SIZE 1024 @@ -19,10 +19,10 @@ #define PROGBASE 0x20000UL #define PROGTOP 0x30000UL -#define SWAP_SIZE (256 + 2) /* 2 for the udata */ +#define SWAP_SIZE (130 + 2) /* 2 for the udata */ #define SWAPBASE PROGBASE #define SWAPTOP 0x30000UL -#define MAX_SWAPS PTABSIZE +#define MAX_SWAPS PTABSIZE /* Mandatory for swap only */ #define swap_map(x) ((uint8_t *)(x)) #define SWAPDEV (1) diff --git a/Kernel/platform-v68/main.c b/Kernel/platform-v68/main.c index 32dd9bcf..000f3cc1 100644 --- a/Kernel/platform-v68/main.c +++ b/Kernel/platform-v68/main.c @@ -68,3 +68,47 @@ void install_vdso(void) /* Should be uput etc */ memcpy((void *)udata.u_codebase, &vdso, 0x40); } + +extern void *get_usp(void); +extern void set_usp(void *p); + +void signal_frame(uint8_t *trapframe, uint32_t d0, uint32_t d1, uint32_t a0, + uint32_t a1) +{ + extern void *udata_shadow; + uint8_t *usp = get_usp(); + udata_ptr = udata_shadow; + uint16_t ccr = *(uint16_t *)trapframe; + uint32_t addr = *(uint32_t *)(trapframe + 2); + int err = 0; + + /* Build the user stack frame */ + + /* FIXME: eventually we should put the trap frame details and trap + info into the frame */ + usp -= 4; + err |= uputl(addr, usp); + usp -= 4; + err |= uputw(ccr, usp); + usp -= 2; + err |=uputl(a1, usp); + usp -= 4; + err |= uputl(a0, usp); + usp -= 4; + err |= uputl(d1, usp); + usp -= 4; + err |= uputl(d0, usp); + usp -= 4; + err |= uputl(udata.u_codebase + 4, usp); + set_usp(usp); + + if (err) { + kprintf("%d: stack fault\n", udata.u_ptab->p_pid); + doexit(dump_core(SIGKILL)); + } + /* Now patch up the kernel frame */ + *(uint16_t *)trapframe = 0; + *(uint32_t *)(trapframe + 2) = (uint32_t)udata.u_sigvec[udata.u_cursig]; + udata.u_sigvec[udata.u_cursig] = SIG_DFL; + udata.u_cursig = 0; +} -- 2.34.1