From 09ba9112386d5d59d7f2a31c469768c582acb939 Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Mon, 19 Feb 2024 21:51:26 +0800 Subject: lab mmap: finish --- kernel/defs.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'kernel/defs.h') diff --git a/kernel/defs.h b/kernel/defs.h index 541c97e..6257437 100644 --- a/kernel/defs.h +++ b/kernel/defs.h @@ -45,6 +45,9 @@ void fileinit(void); int fileread(struct file*, uint64, int n); int filestat(struct file*, uint64 addr); int filewrite(struct file*, uint64, int n); +int fileperm(struct file*); +int mmap_read(struct file*, uint64, uint64, int); +int munmap_write(struct file*, uint64, uint64, int); // fs.c void fsinit(int); @@ -124,6 +127,8 @@ int either_copyin(void *dst, int user_src, uint64 src, uint64 len); void procdump(void); int get_nproc(void); int pgaccess(uint64 base, int len, uint64 mask); +uint64 mmap(uint64 addr, uint64 len, int prot, int flags, int fd, struct file* file, uint64 offset); +int munmap(uint64 addr, uint64 len); // swtch.S void swtch(struct context*, struct context*); @@ -163,6 +168,9 @@ int fetchstr(uint64, char*, int); int fetchaddr(uint64, uint64*); void syscall(); +// sysfile.c +int argfd(int n, int *pfd, struct file **pf); + // sysinfo.c int sys_info(uint64); @@ -189,7 +197,7 @@ pagetable_t uvmcreate(void); void uvmfirst(pagetable_t, uchar *, uint); uint64 uvmalloc(pagetable_t, uint64, uint64, int); uint64 uvmdealloc(pagetable_t, uint64, uint64); -int uvmcopy(pagetable_t, pagetable_t, uint64); +int uvmcopy(pagetable_t, pagetable_t, uint64, uint64); void uvmfree(pagetable_t, uint64); void uvmunmap(pagetable_t, uint64, uint64, int); void uvmclear(pagetable_t, uint64); -- cgit v1.2.3