Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/kern/include/vm/page.h
2093 views
1
#ifndef _VM_PAGE_H
2
#define _VM_PAGE_H
3
4
struct lock;
5
6
/**
7
* this struct represents a logical page.
8
* it is the basic object that the vm system manages.
9
*/
10
struct vm_page {
11
volatile paddr_t vmp_paddr; /* the current physical address of this page */
12
off_t vmp_swapaddr; /* offset into the swap partition */
13
struct spinlock vmp_lk; /* spinlock protecting the members */
14
bool vmp_in_transit;
15
};
16
17
#define VM_PAGE_IN_CORE(vmp) (((vmp)->vmp_paddr & PAGE_FRAME) != INVALID_PADDR)
18
#define VM_PAGE_IN_BACKING(vmp) ((vmp)->vmp_swapaddr != INVLALID_SWAPADDR)
19
#define VM_PAGE_IS_LOCKED(vmp) (KASSERT(lock_do_i_hold((vmp)->vmp_lk)))
20
21
#define VM_PAGE_DIRTY 0x01
22
23
struct vm_page *vm_page_create( void );
24
void vm_page_destroy( struct vm_page * );
25
void vm_page_lock( struct vm_page * );
26
void vm_page_unlock( struct vm_page * );
27
void vm_page_wire( struct vm_page * );
28
int vm_page_clone( struct vm_page *, struct vm_page ** );
29
int vm_page_new_blank( struct vm_page ** );
30
int vm_page_fault( struct vm_page *, struct addrspace *, int fault_type, vaddr_t );
31
void vm_page_evict( struct vm_page * );
32
33
extern struct wchan *wc_transit;
34
35
#endif
36
37