ncr710init2.n
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:22k
源码类别:

VxWorks

开发平台:

C/C++

  1. ; ncr710init2.n Script code for ncr710Lib2 Driver 
  2. ;
  3. ; Copyright 1989-1999 Wind River Systems, Inc.
  4. ;
  5. ;/*
  6. ;Modification history
  7. ;--------------------
  8. ;04h,03dec98,ihw    Modified to support concatenated IDENTIFY/normal message
  9. ;                   out during activation of a new thread.  See ncr710Lib.c.
  10. ;     (SPR 24089)
  11. ;04g,07nov95,jds    fix for phase mismatch during ncr710InitStart when 
  12. ;     nextPhase is called without enabling mismatchATNIntrEnable,
  13. ;     causing a scsi system hang during a normal phase mismatch.
  14. ;04f,28apr95,jds    worked with Ian in highlighting selection problem with 
  15. ;     wd33c93. Integrated into WRS tree; backwarcd compatability
  16. ;04e,16mar95,ihw    fixed problems highlighted by selection by WD 33C93
  17. ;                   improved message-out handling (minor bugs fixed)
  18. ;04d,03jun94,ihw    corrected problem with NCR_COMPILE macro
  19. ;04c,27may94,ihw    documented prior to release
  20. ;04b,02may94,ihw    modifications to work with new SCSI architecture
  21. ;              supports tagged commands
  22. ;04a,18feb94,ihw    Major modifications to work with enhanced SCSI library
  23. ;                   and to be compatible with standard NCR development tools.
  24. ;03f,20jul92,eve    Added documentation. 
  25. ;03e,20jul92,eve    Rename end label to endTransact.
  26. ;03d,03jul92,eve    Include NCR_COMPILER_BUG in the file.
  27. ;03c,04mar92,eve    Start disconnect implementation.
  28. ;03b,16jan92,eve    Add ackMsg1 ,ackAtnMsg and endAbort, remove 
  29. ;     script test proc.
  30. ;03a,30oct91,eve    Remove int capability in end label,the scsi 
  31. ;     status is process by the ncr710Lib driver.
  32. ;02a,26oct91,eve    Add enable disable timout between selection
  33. ;     step.
  34. ;01a,23oct91,eve    Created and add comments
  35. ;
  36. ;INTERNAL
  37. ;Note: This documentation is not exactly accurate. Will need fixing.
  38. ;
  39. ;NCR710 FEATURE USED
  40. ;This chip has code which performs some action on the scsi bus.
  41. ;The description level of the code is close to an assembly language and 
  42. ;dedicated for scsi bus operations. 
  43. ;The opcode is a pair of 32bit word that allow some basic operations in the 
  44. ;code (jump, tests values) and on the scsi (select ,assert line):
  45. ;
  46. ;block move instruction.
  47. ;  move from <offset> when PHASE_NAME
  48. ;  ........
  49. ;I/O instructions 
  50. ;  set target 
  51. ;  wait DISCONNECT
  52. ;  wait RESELECT
  53. ;  select from <offset>,@jump
  54. ;  .........  
  55. ;read/write register instructions
  56. ;  move REG_NAME to SBFR
  57. ;  .........  
  58. ;transfert control instructions
  59. ;  jump <Label> 
  60. ;  int <value> when PHASE_NAME
  61. ;  ........... 
  62. ;  move memory instruction
  63. ;  never use.  
  64. ;The previous example does not included all of the instruction set, 
  65. ;see the NCR data reference manual.
  66. ;Another key point is the capability of the script to perform some 
  67. ;limited indirect addressing to get information from the cpu memory.
  68. ;This is used to get Target ID to select it, to get data, message pointer
  69. ;and count during transfer phase.  This avoids having to patch the script
  70. ;at the run time to specify count, data pointer and target ID.
  71. ;
  72. ;Script can tranfer directly, with its DMA core, a data block from/to the 
  73. ;scsi bus from/to cpu memory.
  74. ;The instruction involved is :
  75. ;        move from <offset> when PHASE_NAME
  76. ;In this case the offset is hard coded in the ncr710Script.h and indexed the
  77. ;right field in the NCR_CTL structure (see ncr710Script.h). 
  78. ;The field looks like :
  79. ;    aligned 32 bit @->00xxxxxx  24bit count
  80. ;                    ->ZZZZZZZZ  32bit address pointer.
  81. ;The offset is added to the content of the DNAD register, loaded at 
  82. ;the run time with the base address of the structure.
  83. ;In the same way the select instruction uses a field like:
  84. ;        select from <offset> ,<Alternate jump @>
  85. ;
  86. ; where offset + DNAD points to a field like:
  87. ;aligned 32 bit@->0000|0000|xxxx xxxx|xPPP  |SSSS|0000|0000
  88. ;                           Target ID|Period|Offset
  89. ;
  90. ;The Period and offset are used when a target supports the synchronous 
  91. ;transfert.
  92. ;
  93. ;INTERRUPT SOURCE
  94. ;The chip has three main kind of interrupt, scsi, dma interrupt and 
  95. ;script  interrupt.  The scsi interrupts are maskable individually with 
  96. ;the sien register.
  97. ;.CS
  98. ;SIEN
  99. ;  7    M/A Mismatch interrupt(initiator)/ ATN assert (Target)
  100. ;       Used in the driver to detect a phase change during data/msg
  101. ;       transfert.The ncr is never used in target mode.
  102. ;  6    FCMP function complete Not used (masked).
  103. ;  5    STO scsi Bus Time out
  104. ;       Used to get timeout on select.(**)
  105. ;  4    SEL selected or reselected Not used in the driver.(masked).
  106. ;  3    SGE scsi Gross error. Used in the driver.
  107. ;  2    UDC unexpected disconnect.
  108. ;       Used to detect unexpected target disconnection or an expected 
  109. ;       disconnect if the target received a "device reset message".
  110. ;  1    RST scsi reset received (not used).(masked)(***)
  111. ;  0    PAR parity error not used.(masked)(***)
  112. ;
  113. ;(**)    The script disable the timeout capability by setting the bit 7 
  114. ;        in CTEST7 register.  Because the ncr will generate also a timeout
  115. ;        interrupt  if no activity occur on the scsi bus after 250ms,
  116. ;        and not only during a scsi select.
  117. ;
  118. ;(***)  This case should be processed, but not included in the driver today.
  119. ;.CE
  120. ;
  121. ;The Dma interrupts are maskable with the DIEN register:
  122. ;.CS
  123. ;DIEN
  124. ;  7   Reserved
  125. ;  6   Reserved
  126. ;  5   BF bus fault.Memory acces error.
  127. ;  4   Aborted ,means that the abort bit have been set in ISTAT reg
  128. ;      This case never happen (Abort bit not used).
  129. ;  3   SSI single step interrupt.Not used in the operational mode.
  130. ;      This bit is used in single step debug mode in the driver,
  131. ;      allowing to execute script step by step..
  132. ;  2   SIR script interrupt,used to detect a script intruction
  133. ;      <int ...>.
  134. ;  1   WTD Watchdog interrupt.This case never happens because
  135. ;      The watchdog timeout value is set to 0 in DWT register.
  136. ;  0   IID illegal instruction detected.  Recieved in two
  137. ;      cases :1-Bad opcode, 2-count set to 0 in the <move> opcode.
  138. ;.CE
  139. ;
  140. ;The other register involved  in  the  interrupt  process  is ISTAT.
  141. ;This register is the ONLY READABLE/WRITABLE  register during a script 
  142. ;execution.
  143. ;.CS
  144. ; ISTAT
  145. ; 7   ABRT Abort current instruction.Not used
  146. ; 6   RST  software reset used to set the chip to a known state.
  147. ; 5   SIGP signal process bit.This bit is used in the ncr driver to support
  148. ;     the connect disconnect to get an interrupt to start a new scsi 
  149. ;     command.(SEE CONNECT/DISCONNECT ...).
  150. ; 4   Reserved.
  151. ; 3   Connected ,not used.
  152. ; 2   Reserved.
  153. ; 1   SIP scsi interrupt pending.Used at interrupt
  154. ;     level to detect and clear SIEN interrupt.
  155. ; 0   DIP dma interrupt pending.Used at interrupt
  156. ;     level to detect and clear DIEN interrupt.
  157. ;.CE
  158. ;The interrupt are cleared by reading the register source, and by 
  159. ;checking  the DIP and SIP bit in ISTAT.  Because the chip has a stack 
  160. ;interrupt ,the DIEN and SIEN registers are read until the ISTAT bits 
  161. ;are cleared to be sure there is no interrupt pending.
  162. ;
  163. ;The last interrupt source is the script <INT> opcode. 
  164. ;This instruction is  used to interrupt the cpu if the scsi 
  165. ;transaction involves a cpu process.
  166. ;.CS
  167. ;    int <int value> [<condition><value>] (pg 6-10 of the programmers guide).
  168. ;.CE
  169. ;The <int value> is used in the driver code to detect the scsi condition  
  170. ;and takes a decision for the next step of the transaction.  
  171. ;This value is loaded from the opcode and read by the  CPU in the 
  172. ;DSPS register.
  173. ;
  174. ;CONNECT/DISCONNECT AND NEW COMMAND START
  175. ;
  176. ;When connect/disconnect is enabled, the target could reconnect at any time.
  177. ;This is notified to the target by an identify message send by the initiator
  178. ;after a successful selection of the target.
  179. ;The  disconnect is always sent to an initiator by a DISCONNECT message.
  180. ;The reconnect could occur at any arbitration phase.  
  181. ;To be able to detect it at any time the chip has to wait for a reconnect 
  182. ;on the scsi ,which is done with the <wait reconnect> script opcode:
  183. ;  wait RECONNECT,<Alternate @>
  184. ;  <next opcode>
  185. ;.CS
  186. ;  If a reconnect occurs, then the <next opcode>
  187. ;  is executed.If the SIGP bit is set the script
  188. ;  jump to <Alternate @>
  189. ;.CE
  190. ;
  191. ;But a reconnect could also occurs during a  <select>  opcode for  another  
  192. ;device (it looses the arbitration).  The <wait RECONNECT> instruction is 
  193. ;the idle script entry point.  They are two way to abort this instruction:
  194. ;
  195. ;  1-The Sigp bit is set
  196. ;  2-A reconnect,or a select occur ,in this case
  197. ;    select means that the initiator is selected as
  198. ;    a target on the scsi bus
  199. ;
  200. ;The sigp bit is used to detect and start a new command at interrupt level. 
  201. ;It is set at task level each time that a new command has to be run.
  202. ;
  203. ;
  204. ;.CS
  205. ;SCRIPT START FLOW CHART
  206. ;The reselected path is driven by a physical scsi reconnect/select.
  207. ;
  208. ;IDLE ENTRY POINT
  209. ;<waitSelect>
  210. ;Wait for a reselect ,Alternate @-------->
  211. ;and test sigp ?                         | SIGP set or Select to start
  212. ;  |                                     |
  213. ;  |<-reselect                           /
  214. ;  |                       No    <checkNewCmd>
  215. ;  |                     /-------Check if we are connected ?
  216. ;<reselected>            |       clear SIGP
  217. ;save Targ/init ID       |       Wait for reselect,<@select as a target>
  218. ;from LCRC register      |       Jump to <reselected>    |
  219. ;Get identify            |                               |
  220. ;Msg in.                 <startNewCmd>                   |
  221. ;int Cpu <reselected>    test and clear SIGP     int Cpu <SELECT AS A TARGET>
  222. ;                        1) SIGP set
  223. ;                        int Cpu <NEW COMMAND>
  224. ;                        2) SIGP clear
  225. ;                        int Cpu <BAD NEW COMD>
  226. ;.CE
  227. ;a) RESELECT
  228. ;At interrupt level, the target ID from the saved LCRC register (LCRC contain
  229. ;the data bus value that is <the target ID> | <initiator ID>) and the LUN 
  230. ;extracted from the identify message sent by the target are used to index 
  231. ;an array that keep track of each PHYS_DEV nexus (Max = 64) in the  SIOP  
  232. ;structure (driver structure).
  233. ;
  234. ;b) NEW COMMAND
  235. ;A global variable <pNcrCtlCmd> in the SIOP structure  allows the script to be 
  236. ;start at a selected entry point with the script address included in this 
  237. ;current nexus pointer in pNcrCtlCmd.
  238. ;
  239. ;c)SELECT AS A TARGET
  240. ;Some support for target mode is required if the NCR710 is to be used in a
  241. ;multi-initiator system which probes the SCSI bus (e.g. "scsiAutoConfig()"
  242. ;in VxWorks).  This script simply reads 6 command bytes then disconnects,
  243. ;which should cause the initiator to abort the command.
  244. ;
  245. ;d)BAD NEW CMD
  246. ;It's a bogus start command restart script at the IDLE Point.
  247. ;
  248. ;SCRIPT REMARKS
  249. ;This script performs a scsi transaction.  This script is a part of 
  250. ;the usual scsi phase routine.  This code is only compatible with the 
  251. ;ncr710 because it uses an indirect addressing mode to avoid relocation 
  252. ;at run time.
  253. ;All of the external values will be relative to the DSA register.
  254. ;DSA register has to be loaded whith the address of the nexus host memory
  255. ;structure (see ncr710Script.h).
  256. ;SCRATCH0 is used to hold phase requested to be able to process a phase 
  257. ;mismatch during any data or message phase.  Usually that occur before a 
  258. ;legal disconnect from the target (save pointer and disconnect message).
  259. ;SCRATCH1 and SCRATCH2 are used to hold state variables for processing
  260. ;messages in and out.
  261. ;SRATCH3 register is used to save the LCRC register. LCRC is stamped with
  262. ;the initiator ID and target ID when a reconnect (initiator is selected
  263. ;by a target) occurs.
  264. ;*/
  265. #define  NCR_COMPILE
  266. #define INCLUDE_SCSI2
  267. #include "drv/scsi/ncr710Script.h"
  268. ;/*****************************************************************************
  269. ;*
  270. ;* ncr710Wait - wait for re-selection by target, selection by initiator, or
  271. ;*              new command from host
  272. ;*/
  273. PROC ncr710Wait:
  274. call REL(timeoutDisable)
  275. call REL(mismatchATNIntrDisable)
  276. wait reselect REL(checkNewCmd)
  277. ;
  278. ; Have been re-selected by a SCSI target
  279. ;
  280. reselected:
  281. clear target ; required in case SIGP set
  282. move lcrc to sfbr ; save target ID for ISR
  283. move sfbr to TARGET_BUS_ID
  284. ;
  285. ; Check and receive IDENTIFY message in (error if none or incorrect message)
  286. ;
  287. int NCR710_NO_IDENTIFY, when not MSG_IN ; check correct phase
  288. move from OFFSET_IDENT_IN, when MSG_IN ; read message
  289. int NCR710_NO_IDENTIFY if not 0x80 and mask 0x7f ; check for IDENTIFY
  290. move FLAGS_IDENTIFY to HOST_FLAGS
  291. int NCR710_RESELECTED ; all seems OK so far
  292. ;
  293. ; Have been selected as a target by another SCSI device.
  294. ;
  295. selected:
  296. set target ; required in case SIGP set
  297. move lcrc to sfbr ; save initiator ID for ISR
  298. move sfbr to TARGET_BUS_ID
  299. ;
  300. ; Wait for SEL to be de-asserted (see NCR Device Errata Listing 135, item 2)
  301. ;
  302. selAsserted:
  303. move sbcl & SBCL_SEL to sfbr ; get state of SCSI SEL line
  304. jump REL(selAsserted) if not 0 ; loop while SEL is asserted
  305. ;
  306. ; Test whether ATN is asserted during selection
  307. ;
  308. move sbcl & SBCL_ATN to sfbr ; get state of SCSI ATN line
  309. jump REL(atnAsserted) if not 0
  310. ;
  311. ; Selection without ATN, and hence without an identification message
  312. ;
  313. move 0 to HOST_FLAGS
  314. int NCR710_SELECTED
  315. ;
  316. ; Selection with ATN - read IDENTIFY message in
  317. ;
  318. atnAsserted:
  319. move from OFFSET_IDENT_IN, with MSG_OUT ; read [sic] IDENTIFY message
  320. move FLAGS_IDENTIFY to HOST_FLAGS
  321. int NCR710_SELECTED
  322. ;
  323. ; May have a new host command to handle - check the SIGP bit
  324. ;
  325. checkNewCmd:
  326. move scntl1 & SCNTL1_CONNECTED to sfbr ; connected on SCSI bus ?
  327. jump REL(ackCmd) if 0 ; no: must be host command
  328. ; Connected - must have been selected or re-selected
  329. move ctest2 & CTEST2_SIGNAL to sfbr ; clear SIGP bit
  330. wait reselect REL(selected) ; if target -> selected
  331. jump REL(reselected) ; else      -> reselected
  332. ;
  333. ; Should have a new host command to handle
  334. ;
  335. ackCmd:
  336. move ctest2 & CTEST2_SIGNAL to sfbr ; test and clear SIGP bit
  337. int NCR710_SPURIOUS_CMD if 0 ; if clear, spurious command
  338. int NCR710_READY ; else,     ack host command
  339. ;/*****************************************************************************
  340. ;*
  341. ;* ncr710InitStart - start new initiator thread, selecting target and
  342. ;* continuing to transfer command, data, messages as requested.
  343. ;*
  344. ;* At this point the script requires some data in the scratch registers:
  345. ;*
  346. ;* scratch 0: host flags (halt after data in, disable SCSI timeout)
  347. ;* scratch 1: message out status (none, pending, or sent)
  348. ;* scratch 2: message in  status
  349. ;* scratch 3: undefined
  350. ;*
  351. ;* When the script finishes, these registers are updated to contain:
  352. ;*
  353. ;* scratch 0: info transfer phase currently being serviced
  354. ;* scratch 1: message out status (none, pending, or sent)
  355. ;* scratch 2: message in  status
  356. ;* scratch 3: contents of LCRC reg (after a reselection)
  357. ;*/
  358. PROC ncr710InitStart:
  359. move PHASE_NONE to CURRENT_PHASE
  360. call REL(timeoutEnable)
  361. call REL(mismatchATNIntrDisable)
  362. ;
  363. ; If required to identify, select w. ATN and try to transfer IDENTIFY message
  364. ; (if this fails, continue silently).  Otherwise, select without ATN.
  365. ;
  366. move HOST_FLAGS & FLAGS_IDENTIFY to sfbr
  367. jump REL(selNoAtn) if 0
  368. select atn from OFFSET_DEVICE, REL(checkNewCmd)
  369. ; the following now transfers the IDENTIFY message plus any
  370. ; other message concatenated to it.
  371. ;
  372. ; NB this code will not tolerate phase mismatches during the message out
  373. ; transfer.  Therefore, things will go badly wrong if the target rejects
  374. ; either the IDENTIFY or the following message (for example).
  375. jump REL(doneSelect),       when not MSG_OUT
  376. move from OFFSET_IDENT_OUT, when     MSG_OUT
  377. ; if there was a normal message concatenated to the IDENTIFY
  378. ; then we have now sent it.  Handle as per normal completion of MSG OUT phase.
  379. move    MSG_OUT_STATE to sfbr                   ; if (msg out == pending)
  380. jump    REL(doneSelect) if not M_OUT_PENDING
  381. move    M_OUT_SENT to sfbr                      ;     msg out = sent
  382. move    sfbr       to MSG_OUT_STATE
  383. jump REL(doneSelect)
  384. selNoAtn:
  385. select from OFFSET_DEVICE, REL(checkNewCmd)
  386. ; Note: must wait for any info xfer phase to be requested before proceeding
  387. ; to disable timeout.  Otherwise, the "select" appears to always hang up.
  388. jump REL(doneSelect), when not MSG_OUT
  389. ;
  390. ; Interrupt host if requested, else continue to phase-sequencing code
  391. ;
  392. doneSelect:
  393. call REL(timeoutDisable)
  394. jump REL(nextPhase)
  395. ;/*****************************************************************************
  396. ;*
  397. ;* ncr710InitContinue - resume an initiator thread
  398. ;*
  399. ;* At this point the script requires some data in the scratch registers:
  400. ;*
  401. ;* scratch 0: host flags (assert ATN on selection)
  402. ;* scratch 1: message out status (none, pending, or sent)
  403. ;* scratch 2: message in  status
  404. ;* scratch 3: undefined
  405. ;*
  406. ;* When the script finishes, these registers are updated to contain:
  407. ;*
  408. ;* scratch 0: info transfer phase currently being serviced
  409. ;* scratch 1: message out status (none, pending, or sent)
  410. ;* scratch 2: message in  status
  411. ;* scratch 3: contents of LCRC reg (after a reselection)
  412. ;*/ 
  413. PROC ncr710InitContinue:
  414. call REL(timeoutDisable)
  415. nextPhase:
  416. call REL(mismatchATNIntrEnable)
  417. move MSG_OUT_STATE  to sfbr ; if (msg out == pending)
  418. call REL(assertAtn) if M_OUT_PENDING ;     assert ATN
  419. clear ack
  420. ;
  421. ; If a message out has just been sent, and the current phase is no longer
  422. ; message out, the target has accepted the message.  Reset the message out
  423. ; state to NONE, and interrupt the host to handle msg out post-processing.
  424. ;
  425. jump REL(phaseSwitch), when MSG_OUT ; if ((phase != msg out)
  426. move MSG_OUT_STATE     to   sfbr
  427. jump REL(phaseSwitch)  if not M_OUT_SENT ;  && (msg out == sent))
  428. move M_OUT_NONE to sfbr ;     msg out = none
  429. move sfbr       to MSG_OUT_STATE
  430. int NCR710_MESSAGE_OUT_SENT
  431. ;
  432. ; Normal info transfer request processing
  433. ;
  434. phaseSwitch:
  435. jump REL(doDataOut), when DATA_OUT
  436. jump REL(doDataIn)   if   DATA_IN
  437. jump REL(doCommand)  if   COMMAND
  438. jump REL(doStatus)   if   STATUS
  439. jump REL(doMsgOut)   if   MSG_OUT
  440. jump REL(doMsgIn)    if   MSG_IN
  441. int NCR710_ILLEGAL_PHASE
  442. ;/*****************************************************************************
  443. ;*
  444. ;* doDataOut - handle DATA OUT phase
  445. ;*/ 
  446. doDataOut:
  447. move PHASE_DATA_OUT to CURRENT_PHASE
  448. move from OFFSET_DATA, when DATA_OUT
  449. jump REL(nextPhase)
  450. ;/*****************************************************************************
  451. ;*
  452. ;* doDataIn - handle DATA IN phase
  453. ;*/ 
  454. doDataIn:
  455. move PHASE_DATA_IN to CURRENT_PHASE
  456. move from OFFSET_DATA, when DATA_IN
  457. jump REL(nextPhase)
  458. ;/*****************************************************************************
  459. ;*
  460. ;* doCommand - handle COMMAND phase
  461. ;*/ 
  462. doCommand:
  463. move PHASE_COMMAND to CURRENT_PHASE
  464. move from OFFSET_CMD, when CMD
  465. jump REL(nextPhase)
  466. ;/*****************************************************************************
  467. ;*
  468. ;* doStatus - handle STATUS phase
  469. ;*/ 
  470. doStatus:
  471. move PHASE_STATUS to CURRENT_PHASE
  472. move from OFFSET_STATUS, when STATUS
  473. jump REL(nextPhase)
  474. ;/*****************************************************************************
  475. ;*
  476. ;* doMsgOut - handle MSG OUT phase
  477. ;*/ 
  478. doMsgOut:
  479. move PHASE_MSG_OUT to CURRENT_PHASE
  480. move MSG_OUT_STATE     to sfbr ; if msg out == none
  481. int NCR710_NO_MSG_OUT if M_OUT_NONE ;     send NO-OP (host does it)
  482. call REL(assertAtn) if M_OUT_SENT ; assert ATN for retries
  483. move from OFFSET_MSG_OUT, when MSG_OUT
  484. move M_OUT_SENT to sfbr
  485. move sfbr       to MSG_OUT_STATE ; msg out = sent
  486. jump REL(nextPhase)
  487. ;/*****************************************************************************
  488. ;*
  489. ;* doMsgIn - handle MSG IN phase
  490. ;*
  491. ;* Note: there is little point in having the '710 parse the message type
  492. ;* unless it can save the host some work by doing so;  DISCONNECT and
  493. ;* COMMAND COMPLETE are really the only cases in point.  Multi-byte messages
  494. ;* are handled specially - see the comments below.
  495. ;*/ 
  496. doMsgIn:
  497. move PHASE_MSG_IN to CURRENT_PHASE
  498. move MSG_IN_STATE to sfbr
  499. jump REL(contExtMsg) if M_IN_EXT_MSG_DATA
  500. move from OFFSET_MSG_IN, when MSG_IN
  501. jump REL(twobyte)  if 0x20 and mask 0x0f
  502. jump REL(disconn)  if M_DISCONNECT
  503. jump REL(complete) if M_CMD_COMPLETE
  504. jump REL(extended) if M_EXT_MSG
  505. int NCR710_MESSAGE_IN_RECVD ; host handles all others
  506. ;
  507. ; Have received a DISCONNECT message
  508. ;
  509. disconn:
  510. clear ack
  511. call REL(timeoutEnable)
  512. wait disconnect
  513. int NCR710_DISCONNECTED
  514. ;
  515. ; Have received a COMMAND COMPLETE message
  516. ;
  517. complete:
  518. clear ack
  519. call REL(timeoutEnable)
  520. wait disconnect
  521. int NCR710_CMD_COMPLETE
  522. ;
  523. ; Have received the first byte of a two-byte message
  524. ;
  525. ; Read the second byte and then interrupt the host.
  526. ;
  527. twobyte:
  528. clear ack
  529. move from OFFSET_MSG_IN_SECOND, when MSG_IN
  530. int NCR710_MESSAGE_IN_RECVD
  531. ;
  532. ; Have received the first byte of an extended message
  533. ;
  534. ; Get the number of bytes in the message proper, then interrupt the host
  535. ; so it can set up the MSG_IN_REST pointer/count accordingly.  (The 53C710
  536. ; can not dynamically change this itself without having static data which
  537. ; would then need to be relocated at runtime - what a loser !)
  538. ;
  539. ; [ A "quick-and-dirty" alternative might be to set up the pointer for
  540. ; reading the message length so that it puts the byte read into the count
  541. ; field for reading the message itself.  This _should_ work, and would
  542. ; avoid interrupting the host, but seems a bit flakey. ]
  543. ;
  544. extended:
  545. clear ack
  546. move from OFFSET_MSG_IN_SECOND, when MSG_IN
  547. move M_IN_EXT_MSG_DATA to sfbr
  548. move sfbr              to MSG_IN_STATE
  549. int NCR710_EXT_MESSAGE_SIZE
  550. contExtMsg:
  551. clear ack
  552. move from OFFSET_MSG_IN_REST, when MSG_IN
  553. move M_IN_NONE to sfbr
  554. move sfbr      to MSG_IN_STATE
  555. int NCR710_MESSAGE_IN_RECVD ; at last !
  556. /******************************************************************************
  557. *
  558. * ncr710TgtDisconnect - disconnect from SCSI bus
  559. *
  560. */
  561. PROC ncr710TgtDisconnect:
  562. call REL(mismatchATNIntrDisable)
  563. set target
  564. disconnect
  565. clear target
  566. int NCR710_DISCONNECTED
  567. /******************************************************************************
  568. *
  569. * miscellaneous useful subroutines - mainly to improve readability of the
  570. * main script.  Call/return overhead is not an issue (I think).
  571. */
  572. ;
  573. ; assertAtn - assert the SCSI ATN signal
  574. ;
  575. assertAtn:
  576. set atn
  577. return
  578. ;
  579. ; timeoutEnable - enable the SCSI {inter-byte, select, disconnect} timeout
  580. ;
  581. timeoutEnable:
  582. move ctest7 & (~CTEST7_NO_TIMEOUT & 0xff) to ctest7
  583. return
  584. ;
  585. ; timeoutDisable - disable the SCSI {inter-byte, select, disconnect} timeout
  586. ;
  587. timeoutDisable:
  588. move ctest7 | CTEST7_NO_TIMEOUT to ctest7
  589. return
  590. ;
  591. ; mismatchATNIntrEnable - enable the phase mismatch / ATN interrupt
  592. ;
  593. mismatchATNIntrEnable:
  594. move sien | SIEN_MISMATCH_ATN to sfbr
  595. move sfbr to sien
  596. return
  597. ;
  598. ; mismatchATNIntrDisable - disable the phase mismatch / ATN interrupt
  599. ;
  600. mismatchATNIntrDisable:
  601. move sien & (~SIEN_MISMATCH_ATN & 0xff) to sfbr
  602. move sfbr to sien
  603. return
  604. ; End of Script