1 /* 2 * Copyright 2008-2010, François Revol, revol@free.fr. All rights reserved. 3 * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef MMU_H 7 #define MMU_H 8 9 10 #include <SupportDefs.h> 11 12 13 // For use with mmu_map_physical_memory() 14 static const uint32 kDefaultPageFlags = 0x3; // present, R/W 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 extern void mmu_init(void); 21 extern void mmu_init_for_kernel(void); 22 extern addr_t mmu_map_physical_memory(addr_t physicalAddress, size_t size, uint32 flags); 23 extern void *mmu_allocate(void *virtualAddress, size_t size); 24 extern void mmu_free(void *virtualAddress, size_t size); 25 26 extern addr_t mmu_get_next_page_tables(); 27 28 29 struct boot_mmu_ops { 30 void (*initialize)(void); 31 /* len=0 to disable */ 32 status_t (*set_tt)(int which, addr_t pa, size_t len, uint32 perms); 33 /* load root pointers */ 34 status_t (*load_rp)(addr_t pa); 35 status_t (*allocate_kernel_pgdirs)(void); 36 status_t (*enable_paging)(void); 37 status_t (*add_page_table)(addr_t virtualAddress); 38 void (*unmap_page)(addr_t virtualAddress); 39 void (*map_page)(addr_t virtualAddress, addr_t pa, uint32 flags); 40 }; 41 42 extern const struct boot_mmu_ops k030MMUOps; 43 extern const struct boot_mmu_ops k040MMUOps; 44 extern const struct boot_mmu_ops k060MMUOps; 45 46 47 48 49 #ifdef __cplusplus 50 } 51 #endif 52 53 #endif /* MMU_H */ 54