       1                                	.title	M9312 'DK/DT' BOOT prom for RK03/05 and TU55/56 controllers
       2                                
       3                                	; This source code is an exact copy of the DEC M9312 23-756A9 boot PROM.
       4                                	;
       5                                	; This boot PROM is for the RK03/05 DECdisk and TU55/56 DECtape controllers.
       6                                	;
       7                                	; Multiple units and/or CSR addresses are supported via different entry points.
       8                                	;
       9                                	; Standard devices are 82S131, Am27S13, 74S571 or other compatible bipolar
      10                                	; PROMs with a 512x4 TriState 16pin DIP architecture. This code resides in
      11                                	; the low half of the device; the top half is blank and unused.
      12                                	;
      13                                	; Alternatively, 82S129 compatible 256x4 TriState 16pin DIP devices can be
      14                                	; used, as the uppermost address line (hardwired low) is an active low chip
      15                                	; select (and will be correctly asserted low).
      16                                
      17 177400                         rkcsr	=177400				; std RK03/05 DECdisk csrbase
      18                                
      19 000002                         rkwc	=+6-4				; word count
      20 000006                         rkda	=+12-4				; disk address
      21                                
      22 177340                         tccsr	=177340				; std TU55/56 DECtape csrbase
      23                                
      24 177776                         tccs	=+0-2				; control/status
      25 000002                         tcwc	=+4-2				; word count
      26                                
      27 000002                         xxwc	=rkwc				; common word count offset
      28                                
      29 165564                         diags	=165564				; console diags phase2 entry
      30                                
      31                                	.asect
      32 173000                         	.=173000
      33                                
      34                                	; --------------------------------------------------
      35                                
      36 173000    113     104          start:	.ascii	"KD"			; device code (reversed)
      37                                
      38 173002 000026                  	.word	next-.			; offset to next boot header
      39                                
      40 173004 000261                  dk0n:	sec				; boot std csr, unit zero, no diags
      41 173006 012700  000000          dk0d:	mov	#0,r0			; boot std csr, unit zero, with diags
      42 173012 012701  177404          dkNr:	mov	#rkcsr+4,r1		; boot std csr, unit <R0>
      43 173016 010704                  dkNb:	mov	pc,r4			; boot csr <R1>, unit <R0>
      44 173020 103057                  	bcc	diag			; br if diags requested
      45 173022 000426                  	br	disk			; return to (R4)+2 from diags
      46                                					; then skip over pseudo reboot vector
      47                                
      48                                	; --------------------------------------------------
      49                                
      50 173024 173000                  	.word	173000			; prom start addess @ 24
      51 173026 000340                  	.word	340			; and priority level @ 26
      52                                
      53                                	; --------------------------------------------------
      54                                
      55 173030    124     104          next:	.ascii	"TD"			; device code (reversed)
      56                                
      57 173032 000146                  	.word	last-.			; offset to next boot header
      58                                
      59 173034 000261                  dt0n:	sec				; boot std csr, unit zero, no diags
      60 173036 012700  000000          dt0d:	mov	#0,r0			; boot std csr, unit zero, with diags
      61 173042 012701  177342          dtNr:	mov	#tccsr+2,r1		; boot std csr, unit <R0>
      62 173046 010704                  dtNb:	mov	pc,r4			; boot csr <R1>, unit <R0>
      63 173050 103043                  	bcc	diag			; br if diags requested
      64                                					; return to (R4)+2 from diags
      65                                					; then skip over pseudo reboot vector
      66                                
      67 173052 010003                  tape:	mov	r0,r3			; get unit number
      68 173054 000303                  	swab	r3			; into high byte
      69 173056 010311                  	mov	r3,(r1)			; store in controller
      70 173060 052711  004003          	bis	#4003,(r1)		; set REVERSE and RNUM+GO
      71 173064 005711                  1$:	tst	(r1)			; test error bit
      72 173066 100376                  	bpl	1$			; loop until error set (at BOT)
      73                                
      74 173070 005761  177776          	tst	tccs(r1)		; read control/status
      75 173074 010311                  	mov	r3,(r1)			; set unit number in controller
      76 173076 000410                  	br	common			; continue
      77                                
      78 173100 010003                  disk:	mov	r0,r3			; get unit number
      79 173102 000241                  	clc				; C=0 for ror
      80 173104 006003                  	ror	r3			; shift into 15:12
      81 173106 006003                  	ror	r3			;
      82 173110 006003                  	ror	r3			;
      83 173112 006003                  	ror	r3			;
      84 173114 010361  000006          	mov	r3,rkda(r1)		; unit number, sector 0 to disk addr
      85                                
      86 173120 012761  177000  000002  common:	mov	#-512.,xxwc(r1)		; set word count
      87 173126 052703  000005          	bis	#5,r3			; command READ+GO
      88 173132 010311                  	mov	r3,(r1)			; execute
      89 173134 105711                  2$:	tstb	(r1)			; test ready
      90 173136 100376                  	bpl	2$			; loop
      91                                
      92 173140 005711                  	tst	(r1)			; check error
      93 173142 100003                  	bpl	3$			; br if no error
      94                                
      95 173144 000005                  	reset				; reset the world
      96 173146 000164  000002          	jmp	2(r4)			; and retry
      97                                
      98 173152 042711  000377          3$:	bic	#377,(r1)		; nop command
      99 173156 005007                  	clr	pc			; jump to loaded boot sector
     100                                
     101                                	; --------------------------------------------------
     102                                
     103 173160 000137  165564          diag:	jmp	@#diags			; jump to console diags
     104                                
     105                                	; --------------------------------------------------
     106                                
     107 173164 000261                  dk2n:	sec				; boot std csr, unit two, no diags
     108 173166 012700  000002          dk2d:	mov	#2,r0			; boot std csr, unit two, with diags
     109 173172 000707                  	br	dkNr			; continue
     110                                
     111                                	; --------------------------------------------------
     112                                
     113 173174 000000                  	.word	0			; unused
     114                                
     115                                	; --------------------------------------------------
     116                                
     117 173176                         	.=start+176
     118 173176 124650                  crc16:	.word	<124650>		; CRC-16 will go here
     119                                
     120                                last:	; next boot prom starts here
     121                                
     122                                	.end
     122                                
