Add mmap module in vm defining mmap_entry structure and some helper functions

This commit is contained in:
sBubshait
2024-12-04 13:00:16 +00:00
parent 8047c65227
commit acc768e177
3 changed files with 20 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ userprog_SRC += userprog/tss.c # TSS management.
# Virtual memory code. # Virtual memory code.
vm_SRC += vm/frame.c # Frame table manager. vm_SRC += vm/frame.c # Frame table manager.
vm_SRC += vm/page.c # Page 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. vm_SRC += devices/swap.c # Swap block manager.
# Filesystem code. # Filesystem code.

1
src/vm/mmap.c Normal file
View File

@@ -0,0 +1 @@
#include "mmap.h"

18
src/vm/mmap.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef VM_MMAP_H
#define VM_MMAP_H
#include <hash.h>
/* 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 */