1: /* $Header: move.c,v 10.3 86/02/01 15:47:04 tony Rel $ */
   2: /* move.c	Routines to move data into and out of the workstation
   3:  *
   4:  *	MoveObjectDownRom	Use rom version to move an object down
   5:  *	MoveObjectDown		Move data into the workstation
   6:  *	MoveBufferDown		Move buffer into the workstation
   7:  *	MoveBufferUp		Move date out of the workstation
   8:  *	SendToPeripheral	Send data to peripheral
   9:  *
  10:  * MoveObjectDownRom should be used to download the firmware into the
  11:  * workstation; after that MoveObjectDown and MoveBufferDown should be used.
  12:  *
  13:  */
  14: 
  15: /****************************************************************************
  16:  *									    *
  17:  *  Copyright (c) 1983, 1984 by						    *
  18:  *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.		    *
  19:  *  All rights reserved.						    *
  20:  * 									    *
  21:  *  This software is furnished on an as-is basis and may be used and copied *
  22:  *  only with inclusion of the above copyright notice. This software or any *
  23:  *  other copies thereof may be provided or otherwise made available to     *
  24:  *  others only for non-commercial purposes.  No title to or ownership of   *
  25:  *  the software is hereby transferred.					    *
  26:  * 									    *
  27:  *  The information in this software is  subject to change without notice   *
  28:  *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
  29:  *  CORPORATION.							    *
  30:  * 									    *
  31:  *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
  32:  *  software on equipment which is not supplied by DIGITAL.		    *
  33:  * 									    *
  34:  *									    *
  35:  ****************************************************************************/
  36: 
  37: #include "vs100.h"
  38: 
  39: extern int VSReloc;
  40: 
  41: char *AllocateSpace();
  42: 
  43: /* Move size bytes from src to dst.  If rom = 1, use the rom-code version.
  44:  * This only works for objects which are <= MAXSIZE bytes;
  45:  */
  46: 
  47: MoveObjectDownRom (src, dst, size)
  48:     caddr_t src, dst;
  49:     int size;
  50: {
  51:     return (MoveObject(src + VSReloc, dst, size, 1));
  52: }
  53: 
  54: MoveObjectDown (src, dst, size)
  55:     caddr_t src, dst;
  56:     int size;
  57: {
  58:     return (MoveObject(src + VSReloc, dst, size, 0));
  59: }
  60: 
  61: MoveBufferDown (src, dst, size)
  62:     caddr_t src, dst;
  63:     int size;
  64: {
  65:     register int len;
  66:     caddr_t buf;
  67: 
  68:     while (len = size) {
  69:         if (len > VBUFSIZE) len = VBUFSIZE;
  70:         if ((buf = (caddr_t) AllocateSpace (len)) == NULL)
  71:         return (-1);
  72:         bcopy (src, buf, len);
  73:         if (MoveObject(buf + VSReloc, dst, len, 0))
  74:         return (-1);
  75:         src += len;
  76:         dst += len;
  77:         size -= len;
  78:     }
  79:     return (0);
  80: }
  81: 
  82: MoveBufferUp (src, dst, size)
  83:     caddr_t src, dst;
  84:     int size;
  85: {
  86:     register int len;
  87:     caddr_t buf;
  88: 
  89:     while (len = size) {
  90:         if (len > VBUFSIZE) len = VBUFSIZE;
  91:         if ((buf = (caddr_t) AllocateSpace (len)) == NULL ||
  92:         MoveObject(src, buf + VSReloc, len, 0) ||
  93:         SynchWrites())
  94:         return (-1);
  95:         bcopy (buf, dst, len);
  96:         src += len;
  97:         dst += len;
  98:         size -= len;
  99:     }
 100:     return (0);
 101: }
 102: 
 103: MoveObject (src, dst, size, rom)
 104:     caddr_t src, dst;
 105:     int size, rom;
 106: {
 107:     register MoveObjectPacket *mop;
 108: #define h ((PacketHeader *) mop->mop_head)
 109: 
 110:     mop = (MoveObjectPacket *) AllocateSpace (sizeof (MoveObjectPacket));
 111:     if (mop == NULL) return (-1);
 112: 
 113:     /* Make sure size is a multiple of 2 */
 114: 
 115:     if (size & 0x1) size++;
 116: 
 117:     /* Format the packet */
 118: 
 119:     h->ph_modifier.emptymod = 0;
 120:     h->ph_opcode = (rom ? MOVE_OBJECT_ROM : MOVE_OBJECT);
 121:     *(long *) h->ph_next = NULL;
 122: 
 123:     mop->mop_objectType = 1;
 124:     *(caddr_t *) mop->mop_source = src;
 125:     *(caddr_t *) mop->mop_dest = dst;
 126:     *(long *) mop->mop_objectSize = size;
 127: 
 128:     return (WritePacket ((caddr_t) mop));
 129: #undef h
 130: }
 131: 
 132: SendToPeripheral (src, size, device)
 133:     char *src;
 134:     int size, device;
 135: {
 136:     register MoveObjectPacket *mop;
 137: #define h ((PacketHeader *) mop->mop_head)
 138: 
 139:     mop = (MoveObjectPacket *) AllocateSpace (sizeof (MoveObjectPacket));
 140:     if (mop == NULL) return;
 141: 
 142:     /* Make sure size is a multiple of 2 */
 143: 
 144:     if (size & 0x1) size++;
 145: 
 146:     /* Format the packet */
 147: 
 148:     h->ph_modifier.emptymod = 0;
 149:     h->ph_opcode = MOVE_OBJECT;
 150:     *(long *) h->ph_next = NULL;
 151: 
 152:     mop->mop_objectType = 2;
 153:     *(caddr_t *) mop->mop_source = src + VSReloc;
 154:     *(int *) mop->mop_dest = device;
 155:     *(long *) mop->mop_objectSize = size;
 156: 
 157:     WritePacket ((caddr_t) mop);
 158: #undef h
 159: }

Defined functions

MoveBufferUp defined in line 82; used 1 times
MoveObject defined in line 103; used 4 times
MoveObjectDown defined in line 54; used 1 times
MoveObjectDownRom defined in line 47; used 2 times
SendToPeripheral defined in line 132; used 3 times

Defined macros

h defined in line 137; used 8 times
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 985
Valid CSS Valid XHTML 1.0 Strict