	SUBTTL	DOUBLE D SYSTEM CONFIGURATION DEFINITIONS
;****************************************************************************
;
;	THIS INCLUDE MODULE DEFINES THE SYSTEM TO BOARD LEVEL
;  PARAMETERS FOR THE JADE DOUBLE D DISK CONTROLLER. IT SHOULD BE
;  INCLUDED AS DEFINITIONS WHENEVER THE BOARD IS DIRECTLY INTERFACED
;  TO BY A SOFTWARE MODULE.
;
;****************************************************************************
;
;	REVISIONS:
;
;  1.0	19 JUL 82
;	RELEASE
;
;  1.1	14 FEB 83
;	CHANGED TO REFLECT REV C BOARD HARDWARE CHANGES:
;	  MA10 IN STATUS PORT BIT 1 & DELETION OF MEMORY ACKNOWLEDGE BIT 0
;	  IN STATUS PORT & MOVE OF HALT FLAG FROM BIT 1 TO BIT 0 OF STATUS
;	  PORT.
; 1.2 -	23 OCT 83   GRH
;	CLEANED UP, ADDED HEADER GRAPHICS
;
; 1.3 - 7 JUN 85   GRH
;	Added Jade format disk descriptor sector definitions.
;
; 1.4 -	29 OCT 85   GRH
;	Changed disk descriptor sector format to new format.
;	Clarified communication block commands.
;	Added hook for log-on return of valid disk descriptor boolean.
;	Removed disk format data & command block data definitions to JDDDISK
;
;****************************************************************************


;======================================
;
;	HOST MEMORY AREAS
;
;======================================
;
;   PAGE 0 LOCATIONS COMPATIBLE WITH CP/M
;
DADDR:	EQU	0040H		;DISK WINDOW PTR IN PAGE 0
DMASK	EQU	DADDR + 2	;STATUS HALT BIT MASK FOR BIOS
DTEMP	EQU	DMASK + 1	;NOT IMPLEMENTED, BUT RESERVED
;
DDBASE:	EQU	0E000H		;DD WINDOW BASE ADDR (ADDED TO STATUS BITS)


;=======================================================
;
;   SYSTEM TO CONTROLLER COMMUNICATION BLOCK (IOPB)
;
;=======================================================
DDCBO	EQU	370H		;DCM COMMAND BLOCK OFFSET
	STRUCT	0
DDCMDO	DS	1	;COMMAND BYTE (SEE BELOW)
DDDRVO	DS	1	;DRIVE
DDTRKO	DS	1	;TRACK
DDSECO	DS	1	;SECTOR (FORMAT FLAGS)
DDFFGO	DS	1	;FLAGS
DDSPRO	DS	1	;SPARE
DDMODO	DS	1	;ERROR CODE:
;			 0: NONE
;			 -1= COMMAND ERROR
;			 -2= FDC ERROR (DDSTS= FDC STATUS)
;				THE FOLLOWING ERRORS ON BOOT ONLY:
;			  1= HOME ERR
;			  2= READ ERR A
;			  4= READ ERR B
;			  80H= DRIVE NOT READY
DDSTSO	DS	1	;DISK CONTROLLER STATUS (SEE 179X MAN'L)
DDADRO	DS	2	;LOAD & JUMP ADDR
;			 FORMAT= # OF PADDING BYTES UNTIL INDEX
;			 BOOT= START OF BOOT MODULE IN MAIN MEMORY
DDBSZO	DS	2	;DCM BLOCK LOAD SIZE (SIZE OF BOOT MODULE)
	ENDM
;
;   COMMANDS (DDCMD OF COMMUNICATION BLOCK)
;
;   LOGON COMMAND, READS DESCRIPTOR SECTOR & SETS DISK FORMAT PARAMETERS
;
DDLOG	EQU	0		;LOG ON DISK
;DDCMD	BYTE	0
;DDDRV	BYTE	DRIVE NUMBER {0..3}
;DDTRK	BYTE	WILL BE SET TO 0 BY COMMAND
;DDSEC	BYTE	WILL BE SET TO 1 BY COMMAND
;DDFFG	BYTE	RETURNED DISK DESCRIPTOR SECTOR STATUS
;		 0: NOT FOUND
;		!0: BUFFER CONTAINS VALID DISK DESCRIPTOR SECTOR DATA
;DDSPR	BYTE	X
;DDMOD	BYTE	RETURNED ERROR CODE (0: NONE)
;DDSTS:	BYTE	FDC STATUS IF DDMOD <> 0
;DDADR:	WORD	X
;DDBSZ:	WORD	X
;
;   READ SECTOR COMMAND
;
DDRDS	EQU	1		;READ SECTOR INTO DDBUF
;DDCMD	BYTE	1
;DDDRV	BYTE	DRIVE NUMBER {0..3}
;DDTRK	BYTE	TRACK NUMBER {0..76}
;DDSEC	BYTE	SECTOR NUMBER {1..26}
;DDFFG	BYTE	80H FOR NO RETRYS
;DDSPR	BYTE	X
;DDMOD	BYTE	RETURNED ERROR CODE (0: NONE)
;DDSTS:	BYTE	FDC STATUS IF DDMOD <> 0
;DDADR:	WORD	X
;DDBSZ:	WORD	X
;
;   WRITE SECTOR COMMAND
;
DDWRS	EQU	2		;WRITE SECTOR FROM DDBUF
;DDCMD	BYTE	2
;DDDRV	BYTE	DRIVE NUMBER {0..3}
;DDTRK	BYTE	TRACK NUMBER {0..76}
;DDSEC	BYTE	SECTOR NUMBER {1..26}
;DDFFG	BYTE	80H FOR NO RETRYS
;DDSPR	BYTE	X
;DDMOD	BYTE	RETURNED ERROR CODE (0: NONE)
;DDSTS:	BYTE	FDC STATUS IF DDMOD <> 0
;DDADR:	WORD	X
;DDBSZ:	WORD	X
;
;   FORMAT TRACK COMMAND
;
DDFMT	EQU	3		;FORMAT TRACK (EXECUTE DDMB1 + 8)
;DDCMD	BYTE	3
;DDDRV	BYTE	DRIVE NUMBER {0..3}
;DDTRK	BYTE	TRACK NUMBER {0..76}
;DDSEC	BYTE	DISK FLAGS TO STORE INTO (DRIVE_TABLE[DVFLG])
;DDFFG	BYTE	X
;DDSPR	BYTE	X
;DDMOD	BYTE	RETURNED ERROR CODE (0: NONE)
;DDSTS:	BYTE	FDC STATUS IF DDMOD <> 0
;DDADR:	WORD	X
;DDBSZ:	WORD	RETURNED NUMBER OF BYTES FROM LAST SECTOR TO INDEX
DDFBFO	EQU	300H		;DD FORMAT BUFFER OFFSET (BANK 1)
;
;   READ ADDRESS COMMAND (NOT IMPLEMENTED)
;
DDRDA	EQU	4		;READ ADDRESS
;
;   EIA OUTPUT COMMAND (NOT IMPLEMENTED)
;
DDSP1	EQU	5		;SPARE
;
;   EIA STATUS COMMAND (NOT IMPLEMENTED)
;
DDSP2	EQU	6		;SPARE
;
;   IDLE COMMAND (NOT IMPLEMENTED)
;
DDIDL	EQU	7		;IDLE- WAIT FOR HOST INT., THEN HALT
;DDCMD	BYTE	4..255
;DDDRV	BYTE	X
;DDTRK	BYTE	X
;DDSEC	BYTE	X
;DDFFG	BYTE	X
;DDSPR	BYTE	X
;DDMOD	BYTE	CMDERR	;NOT IMPLEMENTED, COMMAND ERROR
;DDSTS	BYTE	X
;DDADR	WORD	X
;DDBSZ	WORD	X
;
;   COMMAND ERROR CODES (DDMODO OF COMMAND BLOCK ON RETURN)
;
NOERR	EQU	0	;NO ERROR AFTER FUNCTION
CMDERR	EQU	20H	;INVALID COMMAND FROM HOST
FDCERR	EQU	1FH	;CONTROLLER ERROR (DDSTSO= FDC ERROR CODE)
SELERR	EQU	21H	;ILLEGAL DRIVE REQUESTED
SEEKERR	EQU	15H	;SEEK ERROR

;
;   TRANSFER BUFFER OFFSET TO DDBASE
;
DDBUFO	EQU	380H		;DD SECTOR BUFFER OFFSET


;============================
;
;   DOUBLE D COMMAND PORT
;
;============================
DDPORT:	EQU	43H		;DOUBLE D PORT ADDR
;
;	 D7			      D0
;	|BGN| X | X | X | X | X |MB1|MB0|
;	  ^			  ^   ^_____ 0: REMOVE MEMORY BANK FROM HOST
;	  |			  |	     1: ENABLE MEMORY BANK TO HOST &
;	  |			  |		GENERATE PROCESSOR INTERRUPT
;	  |			  |_________ 0: SELECT 1K MEMORY BANK 0
;	  |				     1: SELECT 1K MEMORY BANK 1
;	  |_________________________________ RESET BOARD PROCESSOR (1)
;
;
;   COMMANDS (OUTPUT TO DDPORT)
;
DDOUT:	EQU	0		;REMOVE DD WINDOW FROM SYSTEM
DDBGN:	EQU	10000000B	;RESET DD Z80A
DDMRQ:	EQU	00000001B	;REQUEST MEMORY BANK 0 WINDOW
DDMRT:	EQU	00000000B	;RELEASE MEMORY WINDOW
DDMB0:	EQU	00000001B	;SELECT MEMORY BANK 0
DDMB1:	EQU	00000011B	;SELECT MEMORY BANK 1
DDEXC:	EQU	00000010B	;ISSUE DD INTERRUPT (START)


;===========================================
;
;   STATUS PORT (SAME ADDRESS AS DDPORT)
;
;===========================================
;
;	 D7			      D0
;	| X | X | X | X |S12|S11|S10|HLT|
;			 \_________/  ^_____ PROCESSOR HALT FLAG (0)
;			      |_____________ BOARD MEMORY ADDR SWITCH POS.
;
DDSHLT:	EQU	00000001B	;STATUS PORT HALT FLAG, 0= HALT, 1= BUSY
DDSASW:	EQU	00001110B	;STATUS PORT ADDR SW MASK
