|
|
1.1 root 1: /*
2: * system-mode mapping
3: * vax version
4: */
5:
6: #include "defs.h"
7: #include "space.h"
8: #include <sys/param.h>
9: #include <sys/pte.h>
10: #include <sys/pcb.h>
11: #include "machine.h"
12:
13: static struct pte *sbr;
14: static WORD svpcbb;
15: static struct pcb pcb;
16: #define HWPAGE 512
17:
18: printkm()
19: {
20:
21: if (sbr)
22: printf("%R$k\n", (WORD)sbr);
23: if (svpcbb)
24: printf("%R$p\np0 %R %R; p1 %R %R\n", svpcbb,
25: (WORD)pcb.pcb_p0br, (WORD)pcb.pcb_p0lr,
26: (WORD)pcb.pcb_p1br, (WORD)pcb.pcb_p1lr);
27: }
28:
29: kmsys()
30: {
31:
32: if (adrflg)
33: sbr = (struct pte *)adrval;
34: else
35: printkm();
36: }
37:
38: kmproc()
39: {
40: struct pte pte;
41:
42: if (adrflg == 0) {
43: printkm();
44: return;
45: }
46: if (adrval == -1) {
47: svpcbb = 0;
48: return;
49: }
50: if (sbr == 0)
51: error("map the kernel first");
52: if (INKERNEL(adrval)) {
53: *(long *)&pte = lget((ADDR)adrval, CORF|DATASP);
54: if (pte.pg_v == 0)
55: error("pcb address not found");
56: adrval = pte.pg_pfnum * HWPAGE;
57: }
58: if (fget((ADDR)adrval, CORF|DATASP|RAWADDR, (char *)&pcb, sizeof(pcb)) == 0) {
59: svpcbb = 0;
60: chkerr();
61: }
62: svpcbb = adrval;
63: }
64:
65: /*
66: * map a kernel address to a physical address
67: * arg is a pointer to be filled in
68: * returns nonzero if address is valid
69: */
70:
71: int
72: kmap(paddr, sp)
73: ADDR *paddr;
74: {
75: long a;
76: long pte;
77: #define Ppte (*(struct pte *)&pte)
78: register int off, pfn;
79:
80: if (sbr == 0)
81: return (1);
82: sp &=~ RAWADDR;
83: a = (long)*paddr & ~0xc0000000;
84: off = a % HWPAGE;
85: pfn = (a / HWPAGE);
86: switch ((int)*paddr & 0xc0000000) {
87: case 0xc0000000: /* really illegal, but who cares? */
88: case 0x80000000: /* system space */
89: pte = (long)lget((ADDR)(sbr + pfn), sp | RAWADDR);
90: break;
91:
92: case 0x40000000: /* p1 */
93: if (svpcbb == 0)
94: return (1);
95: if (pfn <= pcb.pcb_p1lr)
96: return (0);
97: pte = lget((ADDR)(pcb.pcb_p1br + pfn), sp);
98: if (errflg)
99: return (0);
100: break;
101:
102: case 0x00000000: /* p0 */
103: if (svpcbb == 0)
104: return (1);
105: if (pfn > pcb.pcb_p0lr)
106: return (0);
107: pte = lget((ADDR)(pcb.pcb_p0br + pfn), sp);
108: if (errflg)
109: return (0);
110: break;
111: }
112: if (Ppte.pg_v == 0)
113: return (0);
114: *paddr = (ADDR)(Ppte.pg_pfnum * HWPAGE + off);
115: return (1);
116: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.