;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;
;	D O R A D O   C o n t r o l   P r o g r a m
;
;
;		M u f f l e r / M a n i f o l d   a n d
;
;		M i c r o i n s t r u c t i o n   C o n s t a n t s
;
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

;	filed on DoradoMufMan.masm
;	E. McCreight
;	last modified September 28, 1982  11:55 AM

	.EXPORT	PowerUpMinus5And12,PowerDownMinus2
	.EXPORT	PowerUpDisk,PowerUpAllSupplies,PowerDownDisk
	.EXPORT	LoadDiskHeads,UnloadDiskHeads
	.EXPORT	PowerDownEverything,DoIOReset,DisconnectMufMan
	.EXPORT	StdClockSet,StdClockSpeedH,StdClockSpeedL
	.EXPORT	ClearDMManifold,AllowCBHolds
	.EXPORT	MufflerTable,InitManifolds
	.EXPORT	MaxInitManifold
	.EXPORT	ClockSpeedMufField
	.EXPORT	DiskHeadsLoadedMuf
	.EXPORT	ThermomMufAddr,MaxThermom
	.EXPORT	EclUpMuffler,TurnOnPwrMuf

	.PREDEFINE "MCS6502PREDEFS.SR"
	.RDX	16

	.LOC	MufflerData

MufflerTable:

;	BaseBoard manifold values

;	This first batch is for controlling the power sequencing
;	of the Dorado, and is arranged more or less in the order
;	in which they are normally used.

PowerManifold = 2300o
RunMinus5And12 = 8
RunDisk = 4
LoadHeads = 2
RunMinus2 = 1

PowerUpDisk = .-MufflerTable
	.ADR	(PowerManifold+RunDisk)↑4
		; supplies off, disk on, heads not loaded
LoadDiskHeads = .-MufflerTable
	.ADR	(PowerManifold+RunDisk+LoadHeads)↑4
		; supplies off, disk on, heads loaded
PowerUpMinus5And12 = .-MufflerTable
	.ADR	(PowerManifold+RunMinus5And12+RunDisk+LoadHeads)↑4
		; some supplies on, disk on, heads loaded
PowerUpAllSupplies = .-MufflerTable
	.ADR	(PowerManifold+RunMinus5And12+RunMinus2+RunDisk+LoadHeads)↑4	
		; all supplies on, disk on, heads loaded
UnloadDiskHeads = .-MufflerTable
	.ADR	(PowerManifold+RunMinus5And12+RunMinus2+RunDisk)↑4
		; supplies on, disk on, heads not loaded
PowerDownDisk = .-MufflerTable
	.ADR	(PowerManifold+RunMinus5And12+RunMinus2)↑4
		; disk off, supplies on
PowerDownMinus2 = .-MufflerTable
	.ADR	(PowerManifold+RunMinus5And12)↑4
		; some supplies and disk off
PowerDownEverything = .-MufflerTable
	.ADR	(PowerManifold+0)↑4
		; all supplies and disk off

DisconnectMufMan = .-MufflerTable
	.ADR	(2240o+RunRfsh)↑4		; Ecl down, refreshes on, IO reset


;	This next pair sets the clock speed to standard. Religion
;	asserts that every Dorado will run every instruction
;	flawlessly without exception at this speed.

; StdClockSpeed = 32. ; ns per half clock
; StdClockSet = ((((2*2000.)/StdClockSpeed)+1)/2)-1
;    The above equation is the correct one.  Midas
;    (at least up through September 28, 1982) uses a different
;    (and incorrect) one.  The color DispM board
;    requires a half-cycle time (said to Midas)
;    of at most 32 ns. Midas computes the clock
;    setting for this as 63 (decimal).
;    We do likewise for compatability, if not for correctness.
StdClockSet = 63.

StdClockSpeedH = .-MufflerTable
	.ADR	(2200o+(StdClockSet↑(-4)))↑4
StdClockSpeedL = .-MufflerTable
	.ADR	(2220o+(StdClockSet&0f))↑4

;	This next group is used during the bootstrap operation
;	just before the Dorado begins running for real.

ClearDMManifold = .-MufflerTable
	.ADR	(2260o+0)↑4		; clears Dorado-to-micro register to 0
AllowCBHolds = .-MufflerTable
	.ADR	(MidasCBFlags+0)↑4	


;	This next group is invoked as a group just after the power
;	supplies are up and stable.

FirstInitManifold:
InitManifolds = .-MufflerTable

;	BaseBoard Initialization

EclUp = 8
RunRfsh = 1
DoIOReset = .-MufflerTable
	.ADR	(2240o+EclUp+RunRfsh)↑4	; IO reset still asserted


;	Control B Initialization

ControlBManifold = 0
ControlBMufAdr = 200o

ParityEnables = ControlBManifold+(0↑6)
MidasCBFlags = ControlBManifold+(1↑6)
MidasRBMux[0~5] = ControlBManifold+(2↑6)
MidasRBMux[6~11] = ControlBManifold+(3↑6)
MidasRBMux[12~15] = ControlBManifold+(4↑6)
MidasBNPC[0~5] = ControlBManifold+(5↑6)
MidasBNPC[6~11] = ControlBManifold+(6↑6)
MidasStopMIRClk = ControlBManifold+(7↑6)

InhibitCBHold = 10

DisableDoradoErrors = .-MufflerTable
	.ADR	(ParityEnables+030)↑4	; all except IM parity errors disabled
ClearMidasCBFlags = .-MufflerTable
	.ADR	(MidasCBFlags+InhibitCBHold)↑4
ClearMidasRBMux[0~5] = .-MufflerTable
	.ADR	(MidasRBMux[0~5]+0)↑4
ClearMidasRBMux[6~11] = .-MufflerTable
	.ADR	(MidasRBMux[6~11]+0)↑4
ClearMidasRBMux[12~15] = .-MufflerTable
	.ADR	(MidasRBMux[12~15]+0)↑4
ClearMidasBNPC[0~5]  = .-MufflerTable
	.ADR	(MidasBNPC[0~5]+0)↑4
ClearMidasBNPC[6~11] = .-MufflerTable
	.ADR	(MidasBNPC[6~11]+0)↑4
SetMidasStopMIRClk = .-MufflerTable
	.ADR	(MidasStopMIRClk+20)↑4	; turn on MIR debug feature

;	Control A Initialization

ControlAMufAdr = 0

;	Processor L Initialization

ProcLMufAdr = 410o

;	Processor H Initialization

ProcHMufAdr = 400o

MaxInitManifold = (.-FirstInitManifold-2)/2


;		M u f f l e r   A d d r e s s e s

;	Muffler addresses used by the base board for status.

DiskHeadsLoadedMuf=.-MufflerTable
	.ADR	(2232o)↑4	; Sequence0' signal
EclUpMuffler=.-MufflerTable
	.ADR	(2210o)↑4	; EclUp signal
TurnOnPwrMuf=.-MufflerTable
	.ADR	(2230o)↑4	; Power-on signal to power supply relays
ClockSpeedMufField=.-MufflerTable
	.ADR	(2200o)↑4
	.ADR	(1o)↑4

;	Table of thermometer muffler addresses

;	Note: these are also used as board detects. Infinity
;	means board missing. Absolute zero means board present but
;	no thermometer chip.

ThermomMufAddr:
	.ADR	(2215o)↑4	; on the base board
	.ADR	(160o)↑4	; on the control B board, Rev C
	.ADR (302o)↑4	; on the control A board (= Stop)
	.ADR	(610o)↑4	; on the processor L board
	.ADR	(600o)↑4	; on the processor H board
	.ADR	(2552o)↑4	; on the IFU board
	.ADR	(1001o)↑4	; on the memory C board
	.ADR	(1707o)↑4	; on the memory X board
	.ADR	(1207o)↑4	; on the memory D board
	.ADR	(2000o)↑4	; on the disk/Ethernet board
	.ADR	(0o)↑4	; on the display control board

MaxThermom = (.-ThermomMufAddr-2)/2
	.END