Improve headers and add sys/mman.h

This commit is contained in:
Mathieu Maret 2024-02-10 21:26:01 +01:00
parent b352eab798
commit 88b9c3160b
5 changed files with 19 additions and 10 deletions

View File

@ -8,7 +8,7 @@
#define SYSCALL_ID_PUTC 3 #define SYSCALL_ID_PUTC 3
#define SYSCALL_ID_READ 4 #define SYSCALL_ID_READ 4
#define SYSCALL_ID_TEST 5 #define SYSCALL_ID_TEST 5
#define SYSCALL_ID_BRK 6 #define SYSCALL_ID_BRK 6
#define SYSCALL_ID_MMAP 7 #define SYSCALL_ID_MMAP 7
#ifdef __KERNEL__ #ifdef __KERNEL__

View File

@ -8,7 +8,9 @@ struct uAddrSpace;
struct uAddrVirtualReg; struct uAddrVirtualReg;
#define UA_MAP_SHARED (1 << 0) #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 // TODO : move this struct to .c and add accessors
struct uAddrVirtualReg { struct uAddrVirtualReg {
uaddr_t addr; uaddr_t addr;
@ -38,10 +40,9 @@ struct mappedRessource {
int (*onResMapped)(struct uAddrVirtualReg *reg); // Callabck for when the ressourced get mapped 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); 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 uAddrSpaceSetHeap(struct uAddrSpace *as, uaddr_t addr, size_t size);
int uAddrSpaceHeapCheckNAlloc(struct uAddrSpace *as, vaddr_t addr); int uAddrSpaceHeapCheckNAlloc(struct uAddrSpace *as, vaddr_t addr);
uaddr_t sysBrk(struct uAddrSpace *as, uaddr_t newHeapTop); uaddr_t sysBrk(struct uAddrSpace *as, uaddr_t newHeapTop);

View File

@ -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 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 vprintf(const char *format, va_list ap) __attribute__ ((__format__ (printf, 1, 0)));
int printf(const char *format, ...) __attribute__ ((__format__ (printf, 1, 2))); 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); 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))); int asprintf(char **strp, const char *fmt, ...) __attribute__ ((__format__ (printf, 2, 3)));

View File

@ -1,5 +1,6 @@
#include "libc.h" #include "libc.h"
#include "stdarg.h" #include "stdarg.h"
#include "sys/mman.h"
#include "tiny.h" #include "tiny.h"
int func_help() int func_help()

11
userspace/sys/mman.h Normal file
View File

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