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