From: Alan Cox Date: Sat, 13 Feb 2016 20:47:54 +0000 (+0000) Subject: flat_mem: more tidying up X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=9a72beefb9d8c8120345ed529ca3c2f852559164;p=FUZIX.git flat_mem: more tidying up --- diff --git a/Kernel/flat_mem.c b/Kernel/flat_mem.c index afe55e43..2a87aeee 100644 --- a/Kernel/flat_mem.c +++ b/Kernel/flat_mem.c @@ -415,8 +415,14 @@ int vmmu_dup(struct memblk *list, struct memblk *dest) } +struct mmu_context { + struct memblk mmu; + uint8_t *base; +}; + static uint16_t last_context; static struct mmu_context *last_mmu; +static struct mmu_context mmu_context[PTABSIZE] /* For the moment. If we add separate va info then we can use that if not we use the map table */ @@ -451,11 +457,13 @@ uint32_t ugetl(void *uaddr, int *err) } if (err) *err = 0; +#ifdef MISALIGNED if (MISALIGNED(uaddr, 4)) { *err = -1; ssig(udata.u_proc, SIGBUS); return -1; } +#endif return *(uint32_t *)uaddr; } @@ -464,10 +472,12 @@ int uputl(uint32_t val, void *uaddr) { if (!valaddr(uaddr, 4)) return -1; +#ifdef MISALIGNED if (MISALIGNED(uaddr, 4)) { ssig(udata.u_proc, SIGBUS); return -1; } +#endif return *(uint32_t *)uaddr; } @@ -524,6 +534,13 @@ usize_t pagemap_mem_used(void) return freemem >> 10; } +int pagemap_fork(ptptr p) +{ + struct mmu_context *parent = mmu_context + p->page; + struct mmu_context *child = mmu_context + udata.u_page; + return vmmu_dup(parent->mmu.next, &child.mmu); +} + #define size (uint32_t)udata.u_argn #define flags (uint32_t)udata.u_argn1 diff --git a/Kernel/flat_mem.h b/Kernel/flat_mem.h index 393b4af4..d55a4fa6 100644 --- a/Kernel/flat_mem.h +++ b/Kernel/flat_mem.h @@ -31,6 +31,8 @@ extern void vmmu_setcontext(struct memblk *list); extern void vmmu_free(struct memblk *list); extern int vmmu_dup(struct memblk *list, struct memblk *dest); +extern int pagemap_fork(ptptr p); + /* Platform provided. Must be suitably aligned */ extern uint8_t *membase; extern uint8_t *memtop;