1303233Sdim/*
2303233Sdim * Copyright 2007, Fran��ois Revol, revol@free.fr.
3303233Sdim * Distributed under the terms of the MIT License.
4303233Sdim *
5303233Sdim * Copyright 2003-2005, Axel D��rfler, axeld@pinc-software.de.
6303233Sdim * Distributed under the terms of the MIT License.
7303233Sdim *
8303233Sdim * Copyright 2001, Travis Geiselbrecht. All rights reserved.
9303233Sdim * Distributed under the terms of the NewOS License.
10303233Sdim */
11303233Sdim
12303233Sdim#include <KernelExport.h>
13303233Sdim
14303233Sdim#include <kernel.h>
15303233Sdim#include <boot/kernel_args.h>
16303233Sdim
17303233Sdim#include <vm/vm.h>
18303233Sdim#include <vm/vm_types.h>
19303233Sdim#include <vm/VMAddressSpace.h>
20303233Sdim#include <arch/vm.h>
21303233Sdim#include <arch_mmu.h>
22303233Sdim
23303233Sdim
24303233Sdim//#define TRACE_ARCH_VM
25303233Sdim#ifdef TRACE_ARCH_VM
26303233Sdim#	define TRACE(x) dprintf x
27303233Sdim#else
28303233Sdim#	define TRACE(x) ;
29303233Sdim#endif
30303233Sdim
31303233Sdim#warning M68K: WRITEME
32303233Sdim
33303233Sdimstatus_t
34303233Sdimarch_vm_init(kernel_args *args)
35303233Sdim{
36303233Sdim	return B_OK;
37303233Sdim}
38303233Sdim
39303233Sdim
40303233Sdimstatus_t
41303233Sdimarch_vm_init2(kernel_args *args)
42303233Sdim{
43316423Sdim//	int bats[8];
44303233Sdim//	int i;
45331838Sdim
46303233Sdim	/**/
47331838Sdim#warning M68K: disable TT0 and TT1, set up pmmu
48331838Sdim
49303233Sdim	return B_OK;
50303233Sdim}
51303233Sdim
52324023Sdim
53324023Sdimstatus_t
54324023Sdimarch_vm_init_post_area(kernel_args *args)
55324023Sdim{
56324023Sdim	return B_OK;
57324023Sdim}
58324023Sdim
59324023Sdim
60324023Sdimstatus_t
61324023Sdimarch_vm_init_end(kernel_args *args)
62324023Sdim{
63324023Sdim#if 0
64324023Sdim	TRACE(("arch_vm_init_end(): %lu virtual ranges to keep:\n",
65324023Sdim		args->arch_args.num_virtual_ranges_to_keep));
66324023Sdim
67324023Sdim	for (int i = 0; i < (int)args->arch_args.num_virtual_ranges_to_keep; i++) {
68324023Sdim		addr_range &range = args->arch_args.virtual_ranges_to_keep[i];
69324023Sdim
70324023Sdim		TRACE(("  start: %p, size: 0x%lx\n", (void*)range.start, range.size));
71324023Sdim
72324023Sdim		// skip ranges outside the kernel address space
73324023Sdim		if (!IS_KERNEL_ADDRESS(range.start)) {
74324023Sdim			TRACE(("    no kernel address, skipping...\n"));
75324023Sdim			continue;
76324023Sdim		}
77324023Sdim
78324023Sdim		void *address = (void*)range.start;
79324023Sdim		area_id area = create_area("boot loader reserved area", &address,
80324023Sdim			B_EXACT_ADDRESS, range.size, B_ALREADY_WIRED,
81324023Sdim			B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
82324023Sdim		if (area < 0) {
83324023Sdim			panic("arch_vm_init_end(): Failed to create area for boot loader "
84324023Sdim				"reserved area: %p - %p\n", (void*)range.start,
85324023Sdim				(void*)(range.start + range.size));
86324023Sdim		}
87303233Sdim	}
88303233Sdim
89303233Sdim	// Throw away any address space mappings we've inherited from the boot
90303233Sdim	// loader and have not yet turned into an area.
91316423Sdim	vm_free_unused_boot_loader_range(0, 0xffffffff - B_PAGE_SIZE + 1);
92316423Sdim#endif
93303233Sdim
94303233Sdim#warning M68K: unset TT0 now
95