1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17: 18: 19:
20:
21: #include "../cmdsvc.h"
22:
23: LOCAL UW validLA;
24: LOCAL UW validSz;
25: LOCAL UW mmuStat;
26:
27: 28: 29:
30: EXPORT void initChkAddr(void)
31: {
32: validLA = validSz = 0;
33: mmuStat = getCP15(1, 0);
34: }
35: 36: 37: 38: 39:
40: EXPORT W chkMemAddr(UW addr, UW *pa, W len, W rw)
41: {
42: const MEMSEG *mp;
43: UW n;
44:
45: if (mmuStat & 0x1) {
46:
47:
48: if (addr < validLA || addr >= validLA + validSz) {
49: UW pte, *ppte;
50:
51:
52:
53: pte = 0xfe000000 << (7 - (getCP15(2, 2) & 0x07));
54:
55: ppte = (addr & pte) ? TopPageTable :
56: (UW *)(getCP15(2, 0) & ~0x7f);
57: pte = ppte[addr >> 20];
58:
59: validSz = 0;
60: switch(pte & 0x3) {
61: case 0x2:
62: pte &= 0xFFF00000;
63: if (rw && AddrMatchMemArea(pte,
64: MSA_ROM|MSA_FROM) != NULL)
65: errinfo = E_ROM;
66: else validSz = 0x100000;
67: break;
68: case 0x1:
69: pte &= 0xFFFFFC00;
70: pte = *((UW*)(pte + ((addr >>(12-2))& 0x3FC)));
71: switch(pte & 0x3) {
72: case 0x1:
73: validSz = 0x10000;
74: break;
75: case 0x2:
76: case 0x3:
77: validSz = 0x1000;
78: break;
79: }
80: break;
81: case 0x3:
82: break;
83: }
84: validLA = (validSz) ? (addr & ~(validSz - 1)) : 0;
85: }
86:
87: n = (validSz) ? (validLA + validSz - addr) : 0;
88:
89: } else {
90: mp = AddrMatchMemArea(addr, MSA_HW);
91: if ( mp != NULL ) {
92: if ( rw && (mp->attr & (MSA_ROM|MSA_FROM)) != 0 ) {
93: n = 0;
94: errinfo = E_ROM;
95: } else {
96: n = mp->end - addr;
97: }
98: } else {
99: n = 0;
100: }
101: }
102: *pa = addr;
103: return (len > n) ? n : len;
104: }
105: 106: 107: 108: 109:
110: EXPORT W chkIOAddr(UW addr, UW *pa, W len)
111: {
112: const MEMSEG *mp;
113: UW n;
114:
115: mp = AddrMatchMemArea(addr, MSA_IO);
116: n = ( mp != NULL )? mp->end - addr: 0;
117:
118: *pa = addr;
119: return (len > n) ? n : len;
120: }
121: 122: 123: 124:
125: EXPORT W invalidPC(UW addr)
126: {
127:
128:
129: return 0;
130: }
131: EXPORT W invalidPC2(UW addr)
132: {
133:
134:
135: return (addr & 0x03) ? -1 : 0;
136: }