xref: /haiku/src/system/kernel/arch/m68k/arch_vm.cpp (revision 3be9edf8da228afd9fec0390f408c964766122aa)
1 /*
2  * Copyright 2007, François Revol, revol@free.fr.
3  * Distributed under the terms of the MIT License.
4  *
5  * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de.
6  * Distributed under the terms of the MIT License.
7  *
8  * Copyright 2001, Travis Geiselbrecht. All rights reserved.
9  * Distributed under the terms of the NewOS License.
10  */
11 
12 #include <KernelExport.h>
13 
14 #include <kernel.h>
15 #include <boot/kernel_args.h>
16 
17 #include <vm.h>
18 #include <vm_types.h>
19 #include <arch/vm.h>
20 #include <arch_mmu.h>
21 
22 
23 //#define TRACE_ARCH_VM
24 #ifdef TRACE_ARCH_VM
25 #	define TRACE(x) dprintf x
26 #else
27 #	define TRACE(x) ;
28 #endif
29 
30 #warning M68K: WRITEME
31 
32 status_t
33 arch_vm_init(kernel_args *args)
34 {
35 	return B_OK;
36 }
37 
38 
39 status_t
40 arch_vm_init2(kernel_args *args)
41 {
42 //	int bats[8];
43 //	int i;
44 
45 	/**/
46 #warning M68K: disable TT0 and TT1, set up pmmu
47 
48 	return B_OK;
49 }
50 
51 
52 status_t
53 arch_vm_init_post_area(kernel_args *args)
54 {
55 	return B_OK;
56 }
57 
58 
59 status_t
60 arch_vm_init_end(kernel_args *args)
61 {
62 #if 0
63 	TRACE(("arch_vm_init_end(): %lu virtual ranges to keep:\n",
64 		args->arch_args.num_virtual_ranges_to_keep));
65 
66 	for (int i = 0; i < (int)args->arch_args.num_virtual_ranges_to_keep; i++) {
67 		addr_range &range = args->arch_args.virtual_ranges_to_keep[i];
68 
69 		TRACE(("  start: %p, size: 0x%lx\n", (void*)range.start, range.size));
70 
71 		// skip ranges outside the kernel address space
72 		if (!IS_KERNEL_ADDRESS(range.start)) {
73 			TRACE(("    no kernel address, skipping...\n"));
74 			continue;
75 		}
76 
77 		void *address = (void*)range.start;
78 		area_id area = create_area("boot loader reserved area", &address,
79 			B_EXACT_ADDRESS, range.size, B_ALREADY_WIRED,
80 			B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
81 		if (area < 0) {
82 			panic("arch_vm_init_end(): Failed to create area for boot loader "
83 				"reserved area: %p - %p\n", (void*)range.start,
84 				(void*)(range.start + range.size));
85 		}
86 	}
87 
88 	// Throw away any address space mappings we've inherited from the boot
89 	// loader and have not yet turned into an area.
90 	vm_free_unused_boot_loader_range(0, 0xffffffff - B_PAGE_SIZE + 1);
91 #endif
92 
93 #warning M68K: unset TT0 now
94 	return B_OK;
95 }
96 
97 
98 status_t
99 arch_vm_init_post_modules(kernel_args *args)
100 {
101 	return B_OK;
102 }
103 
104 
105 void
106 arch_vm_aspace_swap(struct vm_address_space *from, struct vm_address_space *to)
107 {
108 	m68k_set_pgdir(m68k_translation_map_get_pgdir(&to->translation_map));
109 }
110 
111 
112 bool
113 arch_vm_supports_protection(uint32 protection)
114 {
115 	return true;
116 }
117 
118 
119 void
120 arch_vm_unset_memory_type(vm_area *area)
121 {
122 }
123 
124 
125 status_t
126 arch_vm_set_memory_type(vm_area *area, addr_t physicalBase, uint32 type)
127 {
128 	if (type == 0)
129 		return B_OK;
130 
131 	return B_ERROR;
132 }
133