// CopyDisk.decl
// Copyright Xerox Corporation 1979, 1980, 1981
// Last modified December 12, 1981  6:12 PM by Boggs

//----------------------------------------------------------------------------
manifest
//----------------------------------------------------------------------------
[
// ss types
ssDisk = 1
ssNetPhys = 2
ssNetLog = 3

// controlLock values
server = 1
idle = 0
user = -1

// GetString modes
editEcho = 1
editReplace = 2
editAppend = 0

// command/response types
version = 1			// + a code and a BCPL string
sendDiskParamsR = 2		// + a BCPL string
sendDiskParamsW = 16b		// + a BCPL string
hereAreDiskParams = 3		// + a DP (semi-private format)
storeDisk = 4			// + a TP (private format)
retrieveDisk = 5		// + a TP (private format)
hereIsDiskPage = 6		// + a page (private format)
endOfTransfer = 7		// no data
sendErrors = 10b		// no data
hereAreErrors = 11b		// + Errors (private format)
no = 12b			// + a code and a BCPL string
yes = 13b			// + a code and a BCPL string
comment = 14b			// + a BCPL string
login = 15b			// + 4 BCPL strings
]

//----------------------------------------------------------------------------
structure CDCtx:		// process private storage
//----------------------------------------------------------------------------
[
blank word 3			// standard preamble
ss word				// -> SS
]
manifest extraCtx = (size CDCtx-offset CDCtx.ss)/16

//----------------------------------------------------------------------------
structure CD:			// command
//----------------------------------------------------------------------------
[
length word			// block length in WORDS including this word
type word
codeString:			// version, yes, no
   [
   code word
   string word
   ] =
string:				// login, comment, sendDiskParams(R,W)
   [
   string word
   // 3 more strings if login
   ] =
diskParams:			// hereAreDiskParams
   [
   diskType word		// 0 if unknown
   params word			// disk params (private format)
   ] =
xferParams:			// storeDisk, retrieveDisk
   [
   params word			// transfer params (private format)
   ] =
errors:				// hereAreErrors
   [
   diskType word		// 0 if unknown
   errors word			// error block (private format)
   ]
]

manifest
[
// block lengths
lenCodeString = offset CD.codeString.string/16  // + length of string
lenDiskParams = offset CD.diskParams.params/16  // + length of params
lenXferParams = offset CD.xferParams.params/16  // + length of params
lenErrors = offset CD.errors.errors/16  // + length of errors
lenString = offset CD.string.string/16  // + length of string
]

//----------------------------------------------------------------------------
structure Buffer:
//----------------------------------------------------------------------------
[
link word
ss word				// owner (to whom it is charged)
length word
type word
]
manifest lenBuffer = size Buffer/16

//----------------------------------------------------------------------------
structure SS:			// Source/Sink
//----------------------------------------------------------------------------
[
read word			// ctx Proc
write word			// ctx Proc
destroy word			// Destroy(ss) = 0
printDA word			// PrintDA(ss) = true|false
compatible word			// Compatible(ss, ss) = tp|0
compare word			// Compare(buf1,buf2) = true|false
printBlock word			// PrintBlock(ss, cd)

dp word				// -> diskParams block
tp word				// -> xferParams block
errors word			// -> Error block
device word			// -> String
otherSS word			// -> SS

doneFlag word
fatalFlag word
lenBuffer word			// in words
numBuffers byte
maxBuffers byte
type word			// ssDisk, ssNetPhys, ssNetLog

inputQ word			// -> queue
tempQ word			// -> queue
outputQ word			// -> queue
]