summaryrefslogtreecommitdiffstats
path: root/vm/page.h
blob: 29159fb3590a506c130c53267209f84469f1d562 (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
35
36
37
38
39
40
41
#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 *uvaddr;
  bool loaded;
  enum
  {
    PAGE_SEGMENT,
    PAGE_MEMORY_MAPPED_FILE,
  } type;

  union
  {
    struct segment
    {
      struct file *file;
      off_t ofs;
      uint32_t read_bytes;
      uint32_t zero_bytes;
      bool writable;
    } segment;
  };

  struct hash_elem elem;
};

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 *uvaddr);
bool page_table_insert_segment (struct file *file, off_t ofs, uint8_t *upage,
    uint32_t read_bytes, uint32_t zero_bytes, bool writable);
bool page_load (struct page_table_entry *pte);

#endif