summaryrefslogtreecommitdiffstats
path: root/vm/page.h
blob: b7997fe5b5258fa73b3c783891ac0cd10f9279a2 (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
33
34
#ifndef VM_PAGE_H
#define VM_PAGE_H

#include <debug.h>
#include "hash.h"
#include "filesys/off_t.h"

/* supplemental page table entry */
struct page_table_entry
{
  void *upage;            /* virtual address of page */
  bool loaded;            /* indicates if page is loaded */

  /* structure needed for lazy loading of data segments and mmapped files */
  struct segment
    {
      struct file *file;
      off_t ofs;
      uint32_t read_bytes;
      bool writable;
    } segment;

  struct hash_elem elem;  /* Hash element. */
};

void page_table_init (struct hash *ht);
void page_table_free (struct hash *ht);
struct page_table_entry *page_table_fetch (struct hash *ht, void *upage);
struct page_table_entry *page_table_remove (struct hash *ht, void *upage);
bool page_table_insert_segment (struct hash *ht, struct file *file, off_t ofs,
    void *upage, uint32_t read_bytes, bool writable);
bool page_load (struct page_table_entry *pte);

#endif