Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/kern/arch/mips/include/coremap.h
2093 views
1
#ifndef _MIPS_VM_COREMAP_
2
#define _MIPS_VM_COREMAP_
3
4
#define INVALID_PADDR ((paddr_t)0x0)
5
#define INVALID_TLB_IX -1
6
7
#define COREMAP_TO_PADDR(ix) (((paddr_t)PAGE_SIZE)*((ix)+cm_stats.cms_base))
8
#define PADDR_TO_COREMAP(addr)(((addr)/PAGE_SIZE) - cm_stats.cms_base)
9
10
#define LOCK_COREMAP() (spinlock_acquire(&slk_coremap))
11
#define UNLOCK_COREMAP() (spinlock_release( &slk_coremap))
12
13
#define COREMAP_IS_LOCKED() (KASSERT(spinlock_do_i_hold( &slk_coremap )))
14
#define COREMAP_NO_VMP_LOCKS() (KASSERT( curthread->t_vmp_count == 0 ))
15
16
struct coremap_stats {
17
uint32_t cms_total_frames; /* what we physically manage */
18
uint32_t cms_kpages; /* kernel pages */
19
uint32_t cms_upages; /* user pages */
20
uint32_t cms_free; /* free pages */
21
uint32_t cms_wired; /* wired pages */
22
uint32_t cms_base; /* base frame */
23
};
24
25
struct coremap_entry {
26
struct vm_page *cme_page; /* who currently resides here? */
27
int cme_tlb_ix : 7; /* index in the tlb */
28
29
unsigned cme_kernel : 1, /* is it a kernel page? */
30
cme_last : 1, /* is this the last of a multi-page allocation? */
31
cme_alloc: 1, /* are we allocated? */
32
cme_wired: 1, /* are we wired? */
33
cme_cpu : 5;
34
};
35
36
void coremap_bootstrap( void );
37
void coremap_wire( paddr_t );
38
void coremap_unwire( paddr_t );
39
void coremap_zero( paddr_t );
40
void coremap_clone( paddr_t, paddr_t );
41
paddr_t coremap_alloc( struct vm_page *, bool );
42
void coremap_free( paddr_t, bool );
43
void mark_pages_as_allocated( int, int, bool, bool);
44
bool coremap_is_wired( paddr_t );
45
46
extern struct coremap_entry *coremap;
47
extern struct spinlock slk_coremap;
48
extern struct wchan *wc_wire;
49
extern struct coremap_stats cm_stats;
50
extern struct wchan *wc_shootdown;
51
52
#endif
53
54