;Copyright (C) 1984, 1985 by Xerox Corporation. All rights reserved.

;-- IORegion locations for the boot handler.
;-- stored as [Iris]<WMicro>Dove>ROMDefs.asm
;
;-- last edited by:


;--	RDH			17-Sep-85 12:08:50	;Change maintPanelBkGrdRightPad and maintPanelBkGrdHeight for prettier mp codes.
;--	RDH			14-Sep-85 10:08:50	;Change timeoutInterval to seconds instead of millisecs.
;--	RDH			14-Sep-85  9:04:37	;Add oneSecond.
;--	RDH			13-Sep-85 19:21:18	;Add constants for cursor visibility:  maintPanelBkGrdRightPad, maintPanelBkGrdHeight.
;--	RDH			13-Sep-85 17:12:16	;Changed timeout interval to 35000 (thirty five seconds).
;--	RDH			12-Sep-85 14:37:06	;Made icondatastructure smaller since there is no more mouse tracking and ICON segment was never used.
;--	RDH			12-Sep-85 14:14:25	;Add hideCursorDisplayOn.
;--	RDH			12-Sep-85 12:02:22	;Add timeOutDisab and timeOutEnab.
;--	RDH			12-Sep-85 11:34:41	;Add backToUI and bootSystem.
;--	RDH			11-Sep-85 16:32:29	;Add timeoutInterval.
;--	kek			 5-Sep-85 19:40:32	;mp code definitions
;--	RDH			17-Aug-85 17:39:22	;Add niceCursorDisplayOn.
;--	RDH			14-Aug-85 11:49:32	;Fold in UI stuff.
;--	JPM			15-Jul-85 17:04:07	;Added constants from ROMEthBt.asm.
;--	JPM			11-Jul-85 10:03:32	;Took fields out of floppy context (will use floppy IOCB def), added CallHandlerInitProc.
;--	JMM			19-Jun-85 15:19:54	;Added macro.
;--	JPM			21-May-85 12:54:14	;Diagnostic boot changes.
;--	JMM			 4-Apr-85 15:01:14	;
;--	JMM			 6-Feb-85  9:21:27	;Add boot error constants section.
;--	JMM			28-Jan-85 18:25:43	;Add macro section.
;--	JMM			25-Nov-84 16:04:38	;Added floppy changes.
;--	JPM			 3-Nov-84 11:21:53	;Remove EthIOFce from INCLUDEs, add Floppy IOCB skeletal structure.

;--	BKI/JMM			24-Oct-84 16:14:15	;First release.

;NAME			ROMBDefs
;--------------------------------------------------------------------------------
; 


;---------------------------------------------------------

;Constants for STRUC definitions.
;--------------------------------

BootJumpTable		STRUC

startRAMOpie		DW	?	;An IOP Start block will result in an IOP
startRAMOpieCS		DW	?	;address being saved here for later entry.
iopEntry		DW	?
iopEntryCS		DW	?
processBootBlock	DW	?

BootJumpTable		ENDS

;-----------------------

;BootTimeVariables	STRUC		


;device			DW	?	;1-Disk, 2-Ethernet, 3-Floppy, 4-RS232C.
;mode			DW	?	;0-Normal, 1-Fast boot 
;showUserInterface	DW	?	;0-yes, #0-no.
;bootRetryCount		DW	?	;initially 0, incremented per failure

;reincarnationFlag	DW	?	;For task reinitialization - 0 => tasks
					;to use local RAM otherwise main memory.

;emulatorID		DW	3 DUP(?) ;Initially 0, updated by boot executive.
;loaderID		DW	3 DUP(?) ;Initially 0, updated by boot executive.

;diagnosticsType		DW	?	;Initialized at boot-time. 0 => short
					;diagnostics - user has set EEPROM to
					;indicate desire for a diagnostics boot.
					;#0=> long diagnostics boot - user has
					;manually requested diagnostics at boot
					;time!

;BootTimeVariables	ENDS
			
;-----------------------
;Device types:
;-------------

disk			EQU	1
floppy			EQU	2
ethernet		EQU	3
experimental		EQU	4
rs232C			EQU	4
;-----------------------
;Boot types:
;-----------

normal			EQU	0
diagnostic		EQU	1

;-----------------------
;Boot ICON STRUC's and constants:
;--------------------------------

ICONDataStructure	STRUC

ICONLeftImagePtr	DW	?	;Pointer to image of ICON symbols 0 => no symbol.
ICONRightImagePtr	DW	?	;Pointer to image of ICON symbols 0 => no symbol.
ICONOffset		DW	?	;This is this ICONs offset in display memory.
;ICONSegment		DW	?	;This is this ICON's segment in display memory.
;leftBoundary		DW	?	;Left icon edge from the left of the screen in bits.
;rightBoundary		DW	?	;Right icon edge from the left of the screen in bits.
bootingProcedure	DW	?	;Offset to procedure that does selected boot.
invertedICON		DB	?	;0 => not inverted else inverted.
bootDevice		DB	?	;0 => no device present here.
typeOfBoot		DB	?	;0 => normal boot, otherwise diag. boot.
previousICON		DW	?	;0 => this is the first icon.
nextICON		DW	?	;0 => this is the last icon.

ICONDataStructure	ENDS


cursorPosition		STRUC

x			DW	?
y			DW	?

cursorPosition		ENDS

totalLengthOfICON	EQU	672		;In bits.
lengthOfICON		EQU	64		;
widthOfICON		EQU	24		;Lines.
ICONVerticalDiplacement	EQU	10		;Trial and error for visual appeal.
ICONHorizontalDiplacement EQU	5+lengthOfICON	;Trial and error for visual appeal.
displayON		EQU	11101010B	;Bit 3 set enables the display.
niceCursorDisplayOn	EQU	10001010B	;High nibble makes cursor AND with bitmap. Bit 3 set enables the display.
hideCursorDisplayOn	EQU	0CAH
niceMPDisplayOn		EQU	04AH
;----------------
;Misc. constants:
;----------------

numberOfSoftKeys	EQU	10
crossOver64KbBank	EQU	01000H
distanceFromBottom	EQU	30		;Number of scan lines from bottom of icons to bottom of display.
ICONBottomEdge		EQU	10		;???jmm:85-03-27
ICONInnerDepth		EQU	24		;scan lines in icon button
ICONByteLength		EQU	8		;length and width are the same thing here.
ICONBitWidth		EQU	64		;Depth is up and down.
vertIconOffsetInButton	EQU	4		;scan lines
leftIconOffsetInButton	EQU	1		;bytes
rightIconOffsetInButton	EQU	5		;bytes

threeSeconds		EQU	3000
timeoutInterval		EQU	35	;Number of seconds to wait before starting default booting  This is 10 seconds plus the 25 where 25 is the approx time it takes for the daybreak display to be clearly visible from a cold start.
maintPanelBkGrdRightPad	EQU	0F0H 	;High 4 bits of byte quantity are set.
maintPanelBkGrdHeight	EQU	20 	;mpcodeCursorXPos + Cursor height + mpcodeCursorXPos.
mpcodeCursorXPos	EQU	2 	;Leave space between mpcode and border.
mpcodeCursorYPos	EQU	2 	;Leave space between mpcode and border.
backToUI		EQU	1 	;For communication with diagnostics in finishMode.
bootSystem		EQU	0 	;For communication with diagnostics  
timeOutEnab		EQU	1	;Allow timeouts in boot device selection.
timeOutDisab		EQU	0 	;Wait indefinitely for user.

inverted		EQU	-1
notInverted		EQU	0

numberOfICONs		EQU	4
wordBitSize		EQU	16
byteLength		EQU	8
wordLength		EQU	16

fatDaisy		EQU	0
fatDaybreak		EQU	0

doveDisplayBasePage		EQU	0	;In decimal page numbers.
fatDaybreakDisplayBasePage	EQU	0	;In decimal page numbers.
fatDaisyDisplayBasePage		EQU	0	
;slimDaybreakDisplayBasePage	EQU	768				
slimDaybreakDisplayBasePage	EQU	0	;jmm:84-12-04:UntilGAPmoves.				
slimDaisyDisplayBasePage	EQU	512			

						
;fatDaybreakDisplayMemSize	EQU	1024	;In decimal page numbers.
daisyDisplayMemSize		EQU	256				
fatDaybreakDisplayMemSize	EQU	256				
slimDaybreakDisplayMemSize	EQU	256				


byteWordAlignMask	EQU	0FEH
wordWordAlignMask	EQU	0FFFEH

dontCare		EQU	0
setAtRunTime		EQU	0
status			EQU	0
nullOffset		EQU	0

pageSizeInBytes		EQU	0200H

;-----------------------
;Disk ROM boot constants and STRUC's:
;------------------------------------

DiskBootContext		STRUC

diskIOCBDone		DB	(SIZE Condition) DUP (?)
diskBootIOCB		DB	156 DUP (?)	;SIZE DiskIOCBRecord in DskIOFce.def

DiskBootContext		ENDS


;-----------------------
;Ethernet ROM boot constants and STRUC's:
;----------------------------------------

srcOffset	EQU	6
typeFieldOffset	EQU	12
checksumOffset	EQU	14
lengthOffset	EQU	16
srcHostOffset	EQU	36
bfnOffset	EQU	46
seqNumberOffset	EQU	52
bootDataOffset	EQU	54
maximumBootBufferSize	EQU	bootDataOffset+pageSizeInBytes

bfnSize		EQU	6			;bytes
encapsulation	EQU	checksumOffset

tenSeconds	EQU	10000			;(in milliseconds)
oneSecond	EQU	1000			;(in milliseconds)

EtherBootContext	STRUC

etherIOCB	DB	40 DUP (?)		;jpm 84-11-2 >= SIZE(ethernetIOCB)
etherIOCBDone	DB	(SIZE Condition) DUP (?)
noResponseTimer	DW	?
retryCount	DW	?
romRetryEntry	DD	?
initialBufPtr	DW	?			;place to load next piece of EtherInitialDove.db

EtherBootContext	ENDS


;-----------------------
;Floppy ROM boot constants and STRUC's:
;--------------------------------------

FloppyBootContext	STRUC

floppyIOCBDone		DB	(SIZE Condition) DUP (?)
floppyIOCB		DB	152 DUP (?)

FloppyBootContext	ENDS


;--------------------------------------------------------------------------------
; 
;
;--------------------------------------------------------------------------------
;Convenience macros:
;------------------- 
;
%*Define (MultiplyByTwo	(register))
	(ROL	%register, 1)

%*Define (DivideBy2	(register))
	(SHR	%register, 1)

%*Define (DivideBy4	(register))
	(SHR	%register, 2)

%*Define (ByteSwap	(wordToSwap))
	(%wordToSwap SHL 8 OR %wordToSwap SHR 8)

%*Define (CallHandlerInitProc	(handlerID))	(
		MOV	DI, %handlerID
		SHL	DI, 2
		PUSH	DS
		PUSH	ES
		CALL	DWORD PTR HandlerInitProcTable[DI]
		POP	ES
		POP	DS
)

;--------------------------------------------------------------------------------
;Booting error numbers:
;------------------- 
;
bootingError	EQU	-1
noBufferSpace	EQU	0101H
noLoadSpace	EQU	0202H
unKnownBootBlock EQU	0303H
noRAMStartAddress EQU	0404H
diskROMBootError EQU	0405H

;--------------------------------------------------------------------------------
;Maintenance Panel Codes:
;------------------- 
;
mpStartBooting	EQU	0100D
mpDeviceUnknown	EQU	0113D
mpFetchInitial	EQU	0149D
mpRunInitial	EQU	0150D
mpInitialError	EQU	0151D
mpFetchMesaDove	EQU	0199D
mpRunMesaDove	EQU	0200D
mpMesaDoveError	EQU	0201D
mpRunGerm	EQU	0501D
mpFloppyCleaning	EQU	0077D