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