1: /*
   2:  * Copyright (c) 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)mem.c	1.3 (2.11BSD GTE) 1996/5/15
   7:  */
   8: 
   9: #include "param.h"
  10: #include "../machine/seg.h"
  11: #include "user.h"
  12: #include "conf.h"
  13: #include "uio.h"
  14: 
  15: /*
  16:  * This routine is callable only from the high
  17:  * kernel as it assumes normal mapping and doesn't
  18:  * bother to save 'seg5'.
  19:  */
  20: 
  21: mmrw(dev, uio, flag)
  22:     dev_t dev;
  23:     register struct uio *uio;
  24:     int flag;
  25: {
  26:     register struct iovec *iov;
  27:     int error = 0;
  28: register u_int c;
  29:     u_int on;
  30:     char    zero[1024];
  31: 
  32:     if  (minor(dev) == 3)
  33:         bzero(zero, sizeof (zero));
  34:     while (uio->uio_resid && error == 0) {
  35:         iov = uio->uio_iov;
  36:         if (iov->iov_len == 0) {
  37:             uio->uio_iov++;
  38:             uio->uio_iovcnt--;
  39:             if (uio->uio_iovcnt < 0)
  40:                 panic("mmrw");
  41:             continue;
  42:         }
  43:         switch (minor(dev)) {
  44: 
  45: /* minor device 0 is physical memory (/dev/mem) */
  46:         case 0:
  47:             mapseg5((memaddr)(uio->uio_offset>>6),
  48:                    ((btoc(8192)-1)<<8)|RW);
  49:             on = uio->uio_offset & 077L;
  50:             c = MIN(iov->iov_len, 8192 - on);
  51:             error = uiomove(SEG5+on, c, uio);
  52:             normalseg5();
  53:             break;
  54: /* minor device 1 is kernel memory (/dev/kmem) */
  55:         case 1:
  56:             error = uiomove((caddr_t)uio->uio_offset, iov->iov_len, uio);
  57:             break;
  58: /* minor device 2 is EOF/RATHOLE (/dev/null) */
  59:         case 2:
  60:             if (uio->uio_rw == UIO_READ)
  61:                 return(0);
  62:             c = iov->iov_len;
  63:             iov->iov_base += c;
  64:             iov->iov_len -= c;
  65:             uio->uio_offset += c;
  66:             uio->uio_resid -= c;
  67:             break;
  68: /* minor device 3 is ZERO (/dev/zero) */
  69:         case 3:
  70:             if  (uio->uio_rw == UIO_WRITE)
  71:                 return(EIO);
  72:             c = MIN(iov->iov_len, sizeof (zero));
  73:             error = uiomove(zero, c, uio);
  74:             break;
  75:         default:
  76:             return(EINVAL);
  77:         } /* switch */
  78:     } /* while */
  79:     return(error);
  80: }
  81: 
  82: /*
  83:  * Internal versions of mmread(), mmwrite()
  84:  * used by disk driver ecc routines.
  85:  */
  86: getmemc(addr)
  87:     long addr;
  88: {
  89:     register int a, c, d;
  90: 
  91:     /*
  92: 	 * bn = addr >> 6
  93: 	 * on = addr & 077
  94: 	 */
  95:     a = UISA[0];
  96:     d = UISD[0];
  97:     UISA[0] = addr >> 6;
  98:     UISD[0] = RO;           /* one click, read only */
  99:     c = fuibyte((caddr_t)(addr & 077));
 100:     UISA[0] = a;
 101:     UISD[0] = d;
 102:     return(c);
 103: }
 104: 
 105: putmemc(addr,contents)
 106:     long addr;
 107:     int contents;
 108: {
 109:     register int a, d;
 110: 
 111:     /*
 112: 	 * bn = addr >> 6
 113: 	 * on = addr & 077
 114: 	 */
 115:     a = UISA[0];
 116:     d = UISD[0];
 117:     UISA[0] = addr >> 6;
 118:     UISD[0] = RW;           /* one click, read/write */
 119:     suibyte((caddr_t)(addr & 077), contents);
 120:     UISA[0] = a;
 121:     UISD[0] = d;
 122: }

Defined functions

getmemc defined in line 86; used 2 times
mmrw defined in line 21; used 3 times
putmemc defined in line 105; used 2 times
Last modified: 1996-05-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2676
Valid CSS Valid XHTML 1.0 Strict