2 * Copyright 2007, François Revol, revol@free.fr.
3 * Distributed under the terms of the MIT License.
5 * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de.
6 * Distributed under the terms of the MIT License.
8 * Copyright 2001, Travis Geiselbrecht. All rights reserved.
9 * Distributed under the terms of the NewOS License.
12 #include <KernelExport.h>
15 #include <boot/kernel_args.h>
18 #include <vm/vm_types.h>
19 #include <vm/VMAddressSpace.h>
24 //#define TRACE_ARCH_VM
26 # define TRACE(x) dprintf x
31 #warning M68K: WRITEME
34 arch_vm_init(kernel_args
*args
)
41 arch_vm_init2(kernel_args
*args
)
47 #warning M68K: disable TT0 and TT1, set up pmmu
54 arch_vm_init_post_area(kernel_args
*args
)
61 arch_vm_init_end(kernel_args
*args
)
64 TRACE(("arch_vm_init_end(): %lu virtual ranges to keep:\n",
65 args
->arch_args
.num_virtual_ranges_to_keep
));
67 for (int i
= 0; i
< (int)args
->arch_args
.num_virtual_ranges_to_keep
; i
++) {
68 addr_range
&range
= args
->arch_args
.virtual_ranges_to_keep
[i
];
70 TRACE((" start: %p, size: 0x%lx\n", (void*)range
.start
, range
.size
));
72 // skip ranges outside the kernel address space
73 if (!IS_KERNEL_ADDRESS(range
.start
)) {
74 TRACE((" no kernel address, skipping...\n"));
78 void *address
= (void*)range
.start
;
79 area_id area
= create_area("boot loader reserved area", &address
,
80 B_EXACT_ADDRESS
, range
.size
, B_ALREADY_WIRED
,
81 B_KERNEL_READ_AREA
| B_KERNEL_WRITE_AREA
);
83 panic("arch_vm_init_end(): Failed to create area for boot loader "
84 "reserved area: %p - %p\n", (void*)range
.start
,
85 (void*)(range
.start
+ range
.size
));
89 // Throw away any address space mappings we've inherited from the boot
90 // loader and have not yet turned into an area.
91 vm_free_unused_boot_loader_range(0, 0xffffffff - B_PAGE_SIZE
+ 1);
94 #warning M68K: unset TT0 now
100 arch_vm_init_post_modules(kernel_args
*args
)
107 arch_vm_aspace_swap(struct VMAddressSpace
*from
, struct VMAddressSpace
*to
)
109 // This functions is only invoked when a userland thread is in the process
110 // of dying. It switches to the kernel team and does whatever cleanup is
111 // necessary (in case it is the team's main thread, it will delete the
113 // It is however not necessary to change the page directory. Userland team's
114 // page directories include all kernel mappings as well. Furthermore our
115 // arch specific translation map data objects are ref-counted, so they won't
116 // go away as long as they are still used on any CPU.
121 arch_vm_supports_protection(uint32 protection
)
128 arch_vm_unset_memory_type(VMArea
*area
)
134 arch_vm_set_memory_type(VMArea
*area
, addr_t physicalBase
, uint32 type
)