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