-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvm.h
More file actions
60 lines (48 loc) · 1.41 KB
/
vm.h
File metadata and controls
60 lines (48 loc) · 1.41 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**********************************************************************
* Copyright (c) 2019-2021
* Sang-Hoon Kim <sanghoonkim@ajou.ac.kr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTIABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
**********************************************************************/
#ifndef __VM_H__
#define __VM_H__
#include "types.h"
/* The number of physical page frames of the system */
#define NR_PAGEFRAMES 128
/* The number of PTEs in a page */
#define PTES_PER_PAGE_SHIFT 4
#define NR_PTES_PER_PAGE (1 << PTES_PER_PAGE_SHIFT)
#define RW_READ 0x01
#define RW_WRITE 0x02
/**
* 2-level page table abstraction
*/
struct pte {
bool valid;
bool writable;
unsigned int pfn;
unsigned int private; /* May use to backup something ;-) */
};
struct pte_directory {
struct pte ptes[NR_PTES_PER_PAGE];
};
struct pagetable {
struct pte_directory *outer_ptes[NR_PTES_PER_PAGE];
};
/**
* Simplified PCB
*/
struct process {
unsigned int pid;
struct pagetable pagetable;
struct list_head list; /* List head to chain processes on the system */
};
#endif