2 * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de.
3 * Based on code written by Travis Geiselbrecht for NewOS.
5 * Distributed under the terms of the MIT License.
11 #include <boot/platform.h>
12 #include <boot/stdio.h>
13 #include <boot/kernel_args.h>
14 #include <boot/stage2.h>
16 #include <arch_kernel.h>
23 #include "arch_030_mmu.h"
28 # define TRACE(x) dprintf x
34 extern page_root_entry
*gPageRoot
;
40 TRACE(("mmu_030:initialize\n"));
45 set_tt(int which
, addr_t pa
, size_t len
, uint32 perms
)
47 TRACE(("mmu_030:set_tt(%d, 0x%lx, 0x%lx, 0x%08lx)\n", which
, pa
, len
, perms
));
52 len
= (len
>> 24) & 0x00ff;
55 // enable, cachable(?), r/w
57 // mc68030 user's manual, page 9-57
59 ttr
|= (pa
& 0xff000000);
60 ttr
|= (mask
& 0x00ff0000);
62 TRACE(("mmu_030:set_tt: 0x%08lx\n", ttr
));
64 /* as seen in linux and BSD code,
65 * we need to use .chip pseudo op here as -m68030 doesn't seem to help gas grok it.
71 "pmove %%tt0,(%0)\n\t" \
78 "pmove (%0),%%tt1\n" \
92 TRACE(("mmu_030:load_rp(0x%lx)\n", pa
));
93 long_page_directory_entry entry
;
94 *(uint64
*)&entry
= DFL_PAGEENT_VAL
;
96 entry
.addr
= TA_TO_PREA(((addr_t
)pa
));
99 "pmove (%0),%%srp\n" \
100 "pmove (%0),%%crp\n" \
101 : : "a"((uint64
*)&entry
));
107 allocate_kernel_pgdirs(void)
109 page_root_entry
*pr
= gPageRoot
;
110 page_directory_entry
*pd
;
114 // we'll fill in the 2nd half with ready made page dirs
115 for (i
= NUM_ROOTENT_PER_TBL
/2; i
< NUM_ROOTENT_PER_TBL
; i
++) {
116 if (i
% NUM_DIRTBL_PER_PAGE
)
119 tbl
= mmu_get_next_page_tables();
120 pr
[i
].addr
= TA_TO_PREA(tbl
);
121 pr
[i
].type
= DT_ROOT
;
122 pd
= (page_directory_entry
*)tbl
;
123 for (int32 j
= 0; j
< NUM_DIRENT_PER_TBL
; j
++)
124 *(page_directory_entry_scalar
*)(&pd
[j
]) = DFL_DIRENT_VAL
;
133 TRACE(("mmu_030:enable_paging\n"));
138 const struct boot_mmu_ops k030MMUOps
= {
142 &allocate_kernel_pgdirs
,