|
|
1.1 ! root 1: #include "u.h" ! 2: #include "../port/lib.h" ! 3: #include "mem.h" ! 4: #include "dat.h" ! 5: #include "fns.h" ! 6: #include "io.h" ! 7: ! 8: enum ! 9: { ! 10: Pindex= 0x198, ! 11: Pdata= 0x199, ! 12: }; ! 13: ! 14: static Lock pmulock; ! 15: static int ! 16: pmuwrbit(int index, int bit, int pos) ! 17: { ! 18: uchar x; ! 19: ! 20: lock(&pmulock); ! 21: outb(Pindex, index); ! 22: x = inb(Pdata); ! 23: if(bit) ! 24: x |= 1<<pos; ! 25: else ! 26: x &= ~(1<<pos); ! 27: outb(Pindex, index); ! 28: outb(Pdata, x); ! 29: unlock(&pmulock); ! 30: return 0; ! 31: } ! 32: ! 33: static void ! 34: pmuwr(int index, int val) ! 35: { ! 36: lock(&pmulock); ! 37: outb(Pindex, index); ! 38: outb(Pdata, val); ! 39: unlock(&pmulock); ! 40: } ! 41: ! 42: static uchar ! 43: pmurd(int index) ! 44: { ! 45: uchar x; ! 46: ! 47: lock(&pmulock); ! 48: outb(Pindex, index); ! 49: x = inb(Pdata); ! 50: unlock(&pmulock); ! 51: return x; ! 52: } ! 53: ! 54: static int ! 55: ncr3170serialpower(int onoff) ! 56: { ! 57: return pmuwrbit(0x85, 1^onoff, 4); ! 58: } ! 59: ! 60: static int ! 61: ncr3170snooze(ulong lastop, int wakeup) ! 62: { ! 63: ulong diff; ! 64: ! 65: /* any system call or non-clock interrupt turns the clock back on */ ! 66: if(wakeup){ ! 67: /* set time from real time clock */ ! 68: diff = rtctime() - seconds(); ! 69: m->ticks += SEC2TK(diff); ! 70: ! 71: /* enable clock interrupts */ ! 72: int0mask &= ~(1<<(Clockvec&7)); ! 73: outb(Int0aux, int0mask); ! 74: return 0; ! 75: } ! 76: ! 77: if(TK2SEC(m->ticks - lastop) < 8) ! 78: return 0; ! 79: ! 80: if((pmurd(0x80) & (1<<4)) == 0) ! 81: return 0; ! 82: ! 83: /* mask out clock interrupts to allow the stuff above */ ! 84: int0mask |= 1<<(Clockvec&7); ! 85: outb(Int0aux, int0mask); ! 86: ! 87: /* speed reduction after another 2 seconds */ ! 88: /* screen shutdown + 0MHz CPU after another minute */ ! 89: pmuwr(0x83, 0xf); ! 90: pmuwr(0x84, 0x1); ! 91: pmuwrbit(0x82, 1, 0); ! 92: pmuwrbit(0x82, 1, 1); ! 93: ! 94: return 1; ! 95: } ! 96: ! 97: PCArch ncr3170 = ! 98: { ! 99: "NCRD.0", ! 100: i8042reset, ! 101: 0, ! 102: 0, ! 103: 0, ! 104: ncr3170serialpower, ! 105: 0, ! 106: 0, ! 107: ncr3170snooze, ! 108: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.