xref: /haiku/src/system/boot/platform/riscv/mmu.h (revision 46b7da1f4f40f7157d74fc7fb26ff9ec7f2416f2)
1a182bd6eSX512 /*
2a182bd6eSX512  * Copyright 2021, Haiku, Inc.
3a182bd6eSX512  * Distributed under the terms of the MIT License.
4a182bd6eSX512  */
5a182bd6eSX512 
6a182bd6eSX512 
7a182bd6eSX512 #ifndef MMU_H
8a182bd6eSX512 #define MMU_H
9a182bd6eSX512 
10a182bd6eSX512 
11a182bd6eSX512 #include <SupportDefs.h>
12a182bd6eSX512 
13*71530401SX512 #include <boot/platform.h>
14*71530401SX512 #include <util/FixedWidthPointer.h>
15*71530401SX512 
16a182bd6eSX512 
17a182bd6eSX512 extern uint8* gMemBase;
18a182bd6eSX512 extern size_t gTotalMem;
19a182bd6eSX512 
20a182bd6eSX512 
21a182bd6eSX512 void mmu_init();
22*71530401SX512 void mmu_init_for_kernel(addr_t& satp);
23*71530401SX512 
24*71530401SX512 
25*71530401SX512 inline addr_t
fix_address(addr_t address)26*71530401SX512 fix_address(addr_t address)
27*71530401SX512 {
28*71530401SX512 	addr_t result;
29*71530401SX512 	if (platform_bootloader_address_to_kernel_address((void *)address, &result)
30*71530401SX512 		!= B_OK)
31*71530401SX512 		return address;
32*71530401SX512 
33*71530401SX512 	return result;
34*71530401SX512 }
35*71530401SX512 
36*71530401SX512 
37*71530401SX512 template<typename Type>
38*71530401SX512 inline void
fix_address(FixedWidthPointer<Type> & p)39*71530401SX512 fix_address(FixedWidthPointer<Type>& p)
40*71530401SX512 {
41*71530401SX512 	if (p != NULL)
42*71530401SX512 		p.SetTo(fix_address(p.Get()));
43*71530401SX512 }
44a182bd6eSX512 
45a182bd6eSX512 
46a182bd6eSX512 #endif	/* MMU_H */
47