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