Sun Dec 13 12:32:46 2009 UTC ()
- update some comments
- use unsigned constant for shift op


(tsutsui)
diff -r1.27 -r1.28 src/sys/arch/m68k/include/pmap_motorola.h

cvs diff -r1.27 -r1.28 src/sys/arch/m68k/include/pmap_motorola.h (expand / switch to unified diff)

--- src/sys/arch/m68k/include/pmap_motorola.h 2009/12/11 18:57:44 1.27
+++ src/sys/arch/m68k/include/pmap_motorola.h 2009/12/13 12:32:46 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap_motorola.h,v 1.27 2009/12/11 18:57:44 tsutsui Exp $ */ 1/* $NetBSD: pmap_motorola.h,v 1.28 2009/12/13 12:32:46 tsutsui Exp $ */
2 2
3/*  3/*
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer 8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department. 9 * Science Department.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -91,28 +91,28 @@ struct pmap { @@ -91,28 +91,28 @@ struct pmap {
91 uint16_t pm_sref; /* segment table ref count */ 91 uint16_t pm_sref; /* segment table ref count */
92 uint16_t pm_count; /* pmap reference count */ 92 uint16_t pm_count; /* pmap reference count */
93 struct simplelock pm_lock; /* lock on pmap */ 93 struct simplelock pm_lock; /* lock on pmap */
94 struct pmap_statistics pm_stats; /* pmap statistics */ 94 struct pmap_statistics pm_stats; /* pmap statistics */
95 int pm_ptpages; /* more stats: PT pages */ 95 int pm_ptpages; /* more stats: PT pages */
96}; 96};
97 97
98/* 98/*
99 * MMU specific segment values 99 * MMU specific segment values
100 * 100 *
101 * We are using following segment layout in m68k pmap_motorola.c: 101 * We are using following segment layout in m68k pmap_motorola.c:
102 * 68020/030 4KB/page: l1,l2,page == 10,10,12 (%tc = 0x82c0aa00) 102 * 68020/030 4KB/page: l1,l2,page == 10,10,12 (%tc = 0x82c0aa00)
103 * 68020/030 8KB/page: l1,l2,page == 8,11,13 (%tc = 0x82d08b00) 103 * 68020/030 8KB/page: l1,l2,page == 8,11,13 (%tc = 0x82d08b00)
104 * 68040/060 4KB/page: l1,l2,l3,page == 7,7,6,12 104 * 68040/060 4KB/page: l1,l2,l3,page == 7,7,6,12 (%tc = 0x8000)
105 * 68040/060 8KB/page: l1,l2,l3,page == 7,7,5,13 105 * 68040/060 8KB/page: l1,l2,l3,page == 7,7,5,13 (%tc = 0xc000)
106 * 106 *
107 * 68020/030 l2 size is chosen per NPTEPG, a number of page table entries 107 * 68020/030 l2 size is chosen per NPTEPG, a number of page table entries
108 * per page, to use one whole page for PTEs per one segment table entry, 108 * per page, to use one whole page for PTEs per one segment table entry,
109 * and maybe also because 68020 HP MMU machines use simlar structures. 109 * and maybe also because 68020 HP MMU machines use simlar structures.
110 * 110 *
111 * 68040/060 layout is defined by hardware design and not configurable, 111 * 68040/060 layout is defined by hardware design and not configurable,
112 * as defined in <m68k/pte_motorola.h>. 112 * as defined in <m68k/pte_motorola.h>.
113 * 113 *
114 * Even on 68040/060, we still appropriate 2-level ste-pte pmap structures 114 * Even on 68040/060, we still appropriate 2-level ste-pte pmap structures
115 * for 68020/030 (derived from 4.4BSD/hp300) to handle 040's 3-level MMU. 115 * for 68020/030 (derived from 4.4BSD/hp300) to handle 040's 3-level MMU.
116 * TIA_SIZE and TIB_SIZE are used to represent such pmap structures and 116 * TIA_SIZE and TIB_SIZE are used to represent such pmap structures and
117 * they are also refered on 040/060. 117 * they are also refered on 040/060.
118 * 118 *
@@ -142,38 +142,40 @@ struct pmap { @@ -142,38 +142,40 @@ struct pmap {
142 142
143#define SEGOFSET (NBSEG - 1) /* byte offset into segment */  143#define SEGOFSET (NBSEG - 1) /* byte offset into segment */
144 144
145#define m68k_round_seg(x) ((((vaddr_t)(x)) + SEGOFSET) & ~SEGOFSET) 145#define m68k_round_seg(x) ((((vaddr_t)(x)) + SEGOFSET) & ~SEGOFSET)
146#define m68k_trunc_seg(x) ((vaddr_t)(x) & ~SEGOFSET) 146#define m68k_trunc_seg(x) ((vaddr_t)(x) & ~SEGOFSET)
147#define m68k_seg_offset(x) ((vaddr_t)(x) & SEGOFSET) 147#define m68k_seg_offset(x) ((vaddr_t)(x) & SEGOFSET)
148 148
149/* 149/*
150 * On the 040, we keep track of which level 2 blocks are already in use 150 * On the 040, we keep track of which level 2 blocks are already in use
151 * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB 151 * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB
152 * (block 31). For convenience, the level 1 table is considered to be 152 * (block 31). For convenience, the level 1 table is considered to be
153 * block 0. 153 * block 0.
154 * 154 *
155 * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed. 155 * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed
156 * for the kernel and users. 8 implies only the initial "segment table" 156 * for the kernel and users.
157 * page is used. WARNING: don't change MAXUL2SIZE unless you can allocate 157 * 16 or 8 implies only the initial "segment table" page is used,
158 * physically contiguous pages for the ST in pmap.c! 158 * i.e. it means PAGE_SIZE / (SG4_LEV1SIZE * sizeof(st_entry_t)).
 159 * WARNING: don't change MAXUL2SIZE unless you can allocate
 160 * physically contiguous pages for the ST in pmap_motorola.c!
159 */ 161 */
160#define MAXKL2SIZE 32 162#define MAXKL2SIZE 32
161#if PAGE_SIZE == 8192 163#if PAGE_SIZE == 8192 /* NBPG / (SG4_LEV1SIZE * sizeof(st_entry_t)) */
162#define MAXUL2SIZE 16 164#define MAXUL2SIZE 16
163#else 165#else
164#define MAXUL2SIZE 8 166#define MAXUL2SIZE 8
165#endif 167#endif
166#define l2tobm(n) (1 << (n)) 168#define l2tobm(n) (1U << (n))
167#define bmtol2(n) (ffs(n) - 1) 169#define bmtol2(n) (ffs(n) - 1)
168 170
169/* 171/*
170 * Macros for speed 172 * Macros for speed
171 */ 173 */
172#define PMAP_ACTIVATE(pmap, loadhw) \ 174#define PMAP_ACTIVATE(pmap, loadhw) \
173{ \ 175{ \
174 if ((loadhw)) \ 176 if ((loadhw)) \
175 loadustp(m68k_btop((paddr_t)(pmap)->pm_stpa)); \ 177 loadustp(m68k_btop((paddr_t)(pmap)->pm_stpa)); \
176} 178}
177 179
178/* 180/*
179 * For each struct vm_page, there is a list of all currently valid virtual 181 * For each struct vm_page, there is a list of all currently valid virtual