kern

view src/vm.h @ 17:098b1cb5eeaa

forgot to add a shitload of files
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 26 Mar 2011 21:39:14 +0200
parents
children 096807345aa2
line source
1 #ifndef VM_H_
2 #define VM_H_
4 #include <stdlib.h>
5 #include "mboot.h"
7 /* page mapping flags */
8 #define PG_PRESENT (1 << 0)
9 #define PG_WRITABLE (1 << 1)
10 #define PG_USER (1 << 2)
11 #define PG_WRITE_THROUGH (1 << 3)
12 #define PG_NOCACHE (1 << 4)
13 #define PG_ACCESSED (1 << 5)
14 #define PG_DIRTY (1 << 6)
15 #define PG_TYPE (1 << 7)
16 /* PG_GLOBAL mappings won't flush from TLB */
17 #define PG_GLOBAL (1 << 8)
20 #define PGSIZE 4096
21 #define PGOFFS_MASK 0xfff
22 #define PGNUM_MASK 0xfffff000
24 #define ADDR_TO_PAGE(x) ((uint32_t)(x) >> 12)
25 #define PAGE_TO_ADDR(x) ((uint32_t)(x) << 12)
27 #define ADDR_TO_PGTBL(x) ((uint32_t)(x) >> 22)
28 #define ADDR_TO_PGTBL_PG(x) (((uint32_t)(x) >> 12) & 0x3ff)
29 #define ADDR_TO_PGOFFS(x) ((uint32_t)(x) & PGOFFS_MASK)
31 #define PAGE_TO_PGTBL(x) ((uint32_t)(x) >> 10)
32 #define PAGE_TO_PGTBL_PG(x) ((uint32_t)(x) & 0x3ff)
35 void init_vm(struct mboot_info *mb);
37 void map_page(int vpage, int ppage, unsigned int attr);
38 void map_page_range(int vpg_start, int pgcount, int ppg_start, unsigned int attr);
40 void map_mem_range(uint32_t vaddr, size_t sz, uint32_t paddr, unsigned int attr);
42 #endif /* VM_H_ */