summaryrefslogtreecommitdiffstats
path: root/vm/mmap.h
blob: 159e61afbae9150513ebd3374c09b4cf1f6899e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef VM_MMAP_H
#define VM_MMAP_H

#include <debug.h>
#include "filesys/off_t.h"
#include "lib/user/syscall.h"

/* we use the same structure as fd_table thus the capacity is fixed to
   1024 (PGSIZE/4) */
struct mmap_table
{
  struct mmap_table_entry **ids;
  int id_free;        /* lowest-index free */
  int id_max;         /* highest-index used */
  int id_cap;         /* mmap table capacity */
};

/* a single entry in the mmap table */
struct mmap_table_entry
{
  void *upage;        /* virtual address of first page of mmapped file */
  struct file *file;  /* file handle */
  int pages;          /* number of pages the mapping needs */
};

bool mmap_table_init (struct mmap_table *table);
void mmap_table_free (struct mmap_table *table);
mapid_t mmap_table_insert (struct mmap_table *table, void *upage,
    struct file *file, off_t len);
bool mmap_table_remove (struct mmap_table *table, mapid_t mapping);

#endif