#ifndef VM_PAGE_H #define VM_PAGE_H #include #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 */ enum { PAGE_SEGMENT, PAGE_MEMORY_MAPPED_FILE, } type; /* type of page */ union { /* structure needed for lazy loading of data segments */ struct segment { struct file *file; off_t ofs; uint32_t read_bytes; uint32_t zero_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); 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