From acc768e17790936d8235964b11adc7fbda5cbce9 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Wed, 4 Dec 2024 13:00:16 +0000 Subject: [PATCH] Add mmap module in vm defining mmap_entry structure and some helper functions --- src/Makefile.build | 1 + src/vm/mmap.c | 1 + src/vm/mmap.h | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 src/vm/mmap.c create mode 100644 src/vm/mmap.h diff --git a/src/Makefile.build b/src/Makefile.build index 7778f57..fea3a67 100644 --- a/src/Makefile.build +++ b/src/Makefile.build @@ -64,6 +64,7 @@ userprog_SRC += userprog/tss.c # TSS management. # Virtual memory code. vm_SRC += vm/frame.c # Frame table manager. vm_SRC += vm/page.c # Page table manager. +vm_SRC += vm/mmap.c # Memory-mapped files. vm_SRC += devices/swap.c # Swap block manager. # Filesystem code. diff --git a/src/vm/mmap.c b/src/vm/mmap.c new file mode 100644 index 0000000..328f37b --- /dev/null +++ b/src/vm/mmap.c @@ -0,0 +1 @@ +#include "mmap.h" \ No newline at end of file diff --git a/src/vm/mmap.h b/src/vm/mmap.h new file mode 100644 index 0000000..8fd64ee --- /dev/null +++ b/src/vm/mmap.h @@ -0,0 +1,18 @@ +#ifndef VM_MMAP_H +#define VM_MMAP_H + +#include + +/* A mapping identifier type. */ +typedef unsigned mapid_t; + +/* A structure to represent a memory mapped file. */ +struct mmap_entry { + mapid_t mapping; /* The mapping identifier of the mapped file. */ + struct file *file; /* A pointer to the file that is being mapped. */ + void *upage; /* The start address of the file data in the user VM. */ + + struct hash_elem elem; /* An elem for the hash table. */ +}; + +#endif /* vm/mmap.h */