xref: /haiku/headers/private/kernel/arch/m68k/arch_mmu.h (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the OpenBeOS License.
4 */
5 #ifndef _KERNEL_ARCH_M68K_MMU_H
6 #define _KERNEL_ARCH_M68K_MMU_H
7 
8 
9 #include <SupportDefs.h>
10 #include <string.h>
11 
12 
13 /*
14  * cf.
15  * "mc68030 Enhanced 32-bit Microprocessor User's Manual"
16  * (3rd edition), Section 9
17  * "mc68040 Enhanced 32-bit Microprocessor User's Manual"
18  * Section 9
19  *
20  * The 030 pmmu can support up to 6-level translation tree,
21  * each level using an size-selectable index from the
22  * virtual address, short (4-bit) and long (8-bit) page table
23  * and page entry descriptors, early tree termination, and selectable
24  * page size from 256 bytes to 32K.
25  * There is optionally a separate Supervisor Root Pointer to separate
26  * the user and kernel trees.
27  *
28  * The 040 pmmu however is way more limited in its abilities.
29  * It has a fixed 3-level page tree, with 7/7/6 bit splitting for
30  * 4K pages. The opcodes are also different so we will need specific
31  * routines. Both supervisor and root pointers must be used so we can't
32  * reuse one of them.
33  *
34  *
35  * We settle to:
36  * - 1 bit index for the first level to easily split kernel and user
37  * part of the tree, with the possibility to force supervisor only for
38  * the kernel tree. The use of SRP to point to a 2nd tree is avoided as
39  * it is not available on 68060, plus that makes a spare 64bit reg to
40  * stuff things in.
41  * - 9 bit page directory
42  * - 10 bit page tables
43  * - 12 bit page index (4K pages, a common value).
44  */
45 
46 
47 
48 enum descriptor_types {
49 	DT_INVALID = 0,			// invalid entry
50 	DT_PAGE,				// page descriptor
51 	DT_VALID_4,				// short page table descriptor
52 	DT_VALID_8,				// long page table descriptor
53 };
54 
55 #if 0
56 /* This is the normal layout of the descriptors, as per documentation.
57  * When page size > 256, several bits are unused in the LSB of page
58  * addresses, which we can use in addition of other unused bits.
59  * the structs dedlared later reflect this for 4K pages.
60  */
61 
62 struct short_page_directory_entry {
63 	// upper 32 bits
64 	uint32 type : 2;
65 	uint32 write_protect : 1;
66 	uint32 used : 1;
67 	uint32 address : 28;
68 };
69 
70 struct long_page_directory_entry {
71 	// upper 32 bits
72 	uint32 type : 2;
73 	uint32 write_protect : 1;
74 	uint32 used : 1;
75 	uint32 _zero1 : 4;
76 	uint32 supervisor : 1;
77 	uint32 _zero2 : 1;
78 	uint32 _ones : 6;
79 	uint32 limit : 15;
80 	uint32 low_up : 1;						// limit is lower(1)/upper(0)
81 	// lower 32 bits
82 	uint32 unused : 4;						//
83 	uint32 address : 28;
84 };
85 
86 struct short_page_table_entry {
87 	uint32 type : 2;
88 	uint32 write_protect : 1;
89 	uint32 used : 1;
90 	uint32 modified : 1;
91 	uint32 _zero1 : 1;
92 	uint32 cache_inhibit : 1;
93 	uint32 _zero2 : 1;
94 	uint32 address : 24;
95 };
96 
97 struct long_page_table_entry {
98 	// upper 32 bits
99 	uint32 type : 2;
100 	uint32 write_protect : 1;
101 	uint32 used : 1;
102 	uint32 modified : 1;
103 	uint32 _zero1 : 1;
104 	uint32 cache_inhibit : 1;
105 	uint32 _zero2 : 1;
106 	uint32 supervisor : 1;
107 	uint32 _zero3 : 1;
108 	uint32 _ones : 6;
109 	// limit only used on early table terminators, else unused
110 	uint32 limit : 15;
111 	uint32 low_up : 1;						// limit is lower(1)/upper(0)
112 	// lower 32 bits
113 	uint32 unused : 8;						//
114 	uint32 address : 24;
115 };
116 #endif
117 
118 /* ppc
119 extern void m68k_get_page_table(page_table_entry_group **_pageTable, size_t *_size);
120 extern void m68k_set_page_table(page_table_entry_group *pageTable, size_t size);
121 */
122 
123 #endif	/* _KERNEL_ARCH_M68K_MMU_H */
124