kern
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/vm.h Sat Mar 26 21:39:14 2011 +0200 1.3 @@ -0,0 +1,42 @@ 1.4 +#ifndef VM_H_ 1.5 +#define VM_H_ 1.6 + 1.7 +#include <stdlib.h> 1.8 +#include "mboot.h" 1.9 + 1.10 +/* page mapping flags */ 1.11 +#define PG_PRESENT (1 << 0) 1.12 +#define PG_WRITABLE (1 << 1) 1.13 +#define PG_USER (1 << 2) 1.14 +#define PG_WRITE_THROUGH (1 << 3) 1.15 +#define PG_NOCACHE (1 << 4) 1.16 +#define PG_ACCESSED (1 << 5) 1.17 +#define PG_DIRTY (1 << 6) 1.18 +#define PG_TYPE (1 << 7) 1.19 +/* PG_GLOBAL mappings won't flush from TLB */ 1.20 +#define PG_GLOBAL (1 << 8) 1.21 + 1.22 + 1.23 +#define PGSIZE 4096 1.24 +#define PGOFFS_MASK 0xfff 1.25 +#define PGNUM_MASK 0xfffff000 1.26 + 1.27 +#define ADDR_TO_PAGE(x) ((uint32_t)(x) >> 12) 1.28 +#define PAGE_TO_ADDR(x) ((uint32_t)(x) << 12) 1.29 + 1.30 +#define ADDR_TO_PGTBL(x) ((uint32_t)(x) >> 22) 1.31 +#define ADDR_TO_PGTBL_PG(x) (((uint32_t)(x) >> 12) & 0x3ff) 1.32 +#define ADDR_TO_PGOFFS(x) ((uint32_t)(x) & PGOFFS_MASK) 1.33 + 1.34 +#define PAGE_TO_PGTBL(x) ((uint32_t)(x) >> 10) 1.35 +#define PAGE_TO_PGTBL_PG(x) ((uint32_t)(x) & 0x3ff) 1.36 + 1.37 + 1.38 +void init_vm(struct mboot_info *mb); 1.39 + 1.40 +void map_page(int vpage, int ppage, unsigned int attr); 1.41 +void map_page_range(int vpg_start, int pgcount, int ppg_start, unsigned int attr); 1.42 + 1.43 +void map_mem_range(uint32_t vaddr, size_t sz, uint32_t paddr, unsigned int attr); 1.44 + 1.45 +#endif /* VM_H_ */