diff --git a/core/syscall.h b/core/syscall.h index 6ac00c4..40d6a8e 100644 --- a/core/syscall.h +++ b/core/syscall.h @@ -1,6 +1,6 @@ #pragma once #ifdef __KERNEL__ -#include "cpu_context.h" +#include "cpu_context.h" #endif #define SYSCALL_ID_EXIT 1 @@ -8,7 +8,7 @@ #define SYSCALL_ID_PUTC 3 #define SYSCALL_ID_READ 4 #define SYSCALL_ID_TEST 5 -#define SYSCALL_ID_BRK 6 +#define SYSCALL_ID_BRK 6 #define SYSCALL_ID_MMAP 7 #ifdef __KERNEL__ diff --git a/core/uaddrspace.h b/core/uaddrspace.h index fa34190..9cf8cac 100644 --- a/core/uaddrspace.h +++ b/core/uaddrspace.h @@ -8,7 +8,9 @@ struct uAddrSpace; struct uAddrVirtualReg; #define UA_MAP_SHARED (1 << 0) -#define UA_MAP_FIXED (1 << 1) +#define UA_MAP_PRIVATE (1 << 1) +#define UA_MAP_FIXED (1 << 2) + // TODO : move this struct to .c and add accessors struct uAddrVirtualReg { uaddr_t addr; @@ -38,10 +40,9 @@ struct mappedRessource { int (*onResMapped)(struct uAddrVirtualReg *reg); // Callabck for when the ressourced get mapped }; - -struct uAddrSpace * uAddrSpaceCreate(struct process *proc); +struct uAddrSpace *uAddrSpaceCreate(struct process *proc); int uAddrSpaceDelete(struct uAddrSpace *addr); -struct mmu_context * uAddrSpaceGetMMUContext(struct uAddrSpace *addr); +struct mmu_context *uAddrSpaceGetMMUContext(struct uAddrSpace *addr); int uAddrSpaceSetHeap(struct uAddrSpace *as, uaddr_t addr, size_t size); int uAddrSpaceHeapCheckNAlloc(struct uAddrSpace *as, vaddr_t addr); uaddr_t sysBrk(struct uAddrSpace *as, uaddr_t newHeapTop); diff --git a/userspace/libc.h b/userspace/libc.h index 9ef9596..166e51c 100644 --- a/userspace/libc.h +++ b/userspace/libc.h @@ -36,10 +36,6 @@ int putc(const int c); int vsnprintf(char *str, size_t size, const char *format, va_list ap) __attribute__ ((__format__ (printf, 3, 0))); int vprintf(const char *format, va_list ap) __attribute__ ((__format__ (printf, 1, 0))); int printf(const char *format, ...) __attribute__ ((__format__ (printf, 1, 2))); -/* To keep in sync with PAGING_MEM_* */ -#define PROT_EXEC (1<<3) -#define PROT_READ (1<<1) -#define PROT_WRITE (1<<2) void *mmap(void *addr, size_t len, int prot, int flags, char *path); int asprintf(char **strp, const char *fmt, ...) __attribute__ ((__format__ (printf, 2, 3))); diff --git a/userspace/main_user.c b/userspace/main_user.c index 9502c75..b45750c 100644 --- a/userspace/main_user.c +++ b/userspace/main_user.c @@ -1,5 +1,6 @@ #include "libc.h" #include "stdarg.h" +#include "sys/mman.h" #include "tiny.h" int func_help() diff --git a/userspace/sys/mman.h b/userspace/sys/mman.h new file mode 100644 index 0000000..c9c46cc --- /dev/null +++ b/userspace/sys/mman.h @@ -0,0 +1,11 @@ +#pragma once + +/* To keep in sync with PAGING_MEM_* */ +#define PROT_EXEC (1<<3) +#define PROT_READ (1<<1) +#define PROT_WRITE (1<<2) + +#define MAP_SHARED (1 << 0) +#define MAP_PRIVATE (1 << 1) +#define MAP_FIXED (1 << 2) +