9000: #
9001: /*
9002:  */
9003: 
9004: /*
9005:  *      Memory special file
9006:  *      minor device 0 is physical memory
9007:  *      minor device 1 is kernel memory
9008:  *      minor device 2 is EOF/RATHOLE
9009:  */
9010: 
9011: #include "../param.h"
9012: #include "../user.h"
9013: #include "../conf.h"
9014: #include "../seg.h"
9015: 
9016: mmread(dev)
9017: {
9018:         register c, bn, on;
9019:         int a, d;
9020: 
9021:         if(dev.d_minor == 2)
9022:                 return;
9023:         do {
9024:                 bn = lshift(u.u_offset, -6);
9025:                 on = u.u_offset[1] & 077;
9026:                 a = UISA->r[0];
9027:                 d = UISD->r[0];
9028:                 spl7();
9029:                 UISA->r[0] = bn;
9030:                 UISD->r[0] = 077406;
9031:                 if(dev.d_minor == 1)
9032:                         UISA->r[0] = (ka6-6)->r[(bn>>7)&07] + (bn & 0177);
9033: 
9034:                 c = fuibyte(on);
9035:                 UISA->r[0] = a;
9036:                 UISD->r[0] = d;
9037:                 spl0();
9038:         } while(u.u_error==0 && passc(c)>=0);
9039: }
9040: /* ---------------------------       */
9041: 
9042: mmwrite(dev)
9043: {
9044:         register c, bn, on;
9045:         int a, d;
9046: 
9047:         if(dev.d_minor == 2) {
9048:                 c = u.u_count;
9049:                 u.u_count = 0;
9050:                 u.u_base =+ c;
9051:                 dpadd(u.u_offset, c);
9052:                 return;
9053:         }
9054:         for(;;) {
9055:                 bn = lshift(u.u_offset, -6);
9056:                 on = u.u_offset[1] & 077;
9057:                 if ((c=cpass())<0 || u.u_error!=0)
9058:                         break;
9059:                 a = UISA->r[0];
9060:                 d = UISD->r[0];
9061:                 spl7();
9062:                 UISA->r[0] = bn;
9063:                 UISD->r[0] = 077406;
9064:                 if(dev.d_minor == 1)
9065:                         UISA->r[0] = (ka6-6)->r[(bn>>7)&07] + (bn & 0177);
9066: 
9067:                 suibyte(on, c);
9068:                 UISA->r[0] = a;
9069:                 UISD->r[0] = d;
9070:                 spl0();
9071:         }
9072: }
9073: /* ---------------------------       */