53c700.scr 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. ; Script for the NCR (or symbios) 53c700 and 53c700-66 chip
  2. ;
  3. ; Copyright (C) 2001 James.Bottomley@HansenPartnership.com
  4. ;;-----------------------------------------------------------------------------
  5. ;;
  6. ;; This program is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 2 of the License, or
  9. ;; (at your option) any later version.
  10. ;;
  11. ;; This program is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;;
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with this program; if not, write to the Free Software
  18. ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. ;;
  20. ;;-----------------------------------------------------------------------------
  21. ;
  22. ; This script is designed to be modified for the particular command in
  23. ; operation. The particular variables pertaining to the commands are:
  24. ;
  25. ABSOLUTE Device_ID = 0 ; ID of target for command
  26. ABSOLUTE MessageCount = 0 ; Number of bytes in message
  27. ABSOLUTE MessageLocation = 0 ; Addr of message
  28. ABSOLUTE CommandCount = 0 ; Number of bytes in command
  29. ABSOLUTE CommandAddress = 0 ; Addr of Command
  30. ABSOLUTE StatusAddress = 0 ; Addr to receive status return
  31. ABSOLUTE ReceiveMsgAddress = 0 ; Addr to receive msg
  32. ;
  33. ; This is the magic component for handling scatter-gather. Each of the
  34. ; SG components is preceded by a script fragment which moves the
  35. ; necessary amount of data and jumps to the next SG segment. The final
  36. ; SG segment jumps back to . However, this address is the first SG script
  37. ; segment.
  38. ;
  39. ABSOLUTE SGScriptStartAddress = 0
  40. ; The following represent status interrupts we use 3 hex digits for
  41. ; this: 0xPRS where
  42. ; P:
  43. ABSOLUTE AFTER_SELECTION = 0x100
  44. ABSOLUTE BEFORE_CMD = 0x200
  45. ABSOLUTE AFTER_CMD = 0x300
  46. ABSOLUTE AFTER_STATUS = 0x400
  47. ABSOLUTE AFTER_DATA_IN = 0x500
  48. ABSOLUTE AFTER_DATA_OUT = 0x600
  49. ABSOLUTE DURING_DATA_IN = 0x700
  50. ; R:
  51. ABSOLUTE NOT_MSG_OUT = 0x10
  52. ABSOLUTE UNEXPECTED_PHASE = 0x20
  53. ABSOLUTE NOT_MSG_IN = 0x30
  54. ABSOLUTE UNEXPECTED_MSG = 0x40
  55. ABSOLUTE MSG_IN = 0x50
  56. ABSOLUTE SDTR_MSG_R = 0x60
  57. ABSOLUTE REJECT_MSG_R = 0x70
  58. ABSOLUTE DISCONNECT = 0x80
  59. ABSOLUTE MSG_OUT = 0x90
  60. ABSOLUTE WDTR_MSG_R = 0xA0
  61. ; S:
  62. ABSOLUTE GOOD_STATUS = 0x1
  63. ; Combinations, since the script assembler can't process |
  64. ABSOLUTE NOT_MSG_OUT_AFTER_SELECTION = 0x110
  65. ABSOLUTE UNEXPECTED_PHASE_BEFORE_CMD = 0x220
  66. ABSOLUTE UNEXPECTED_PHASE_AFTER_CMD = 0x320
  67. ABSOLUTE NOT_MSG_IN_AFTER_STATUS = 0x430
  68. ABSOLUTE GOOD_STATUS_AFTER_STATUS = 0x401
  69. ABSOLUTE UNEXPECTED_PHASE_AFTER_DATA_IN = 0x520
  70. ABSOLUTE UNEXPECTED_PHASE_AFTER_DATA_OUT = 0x620
  71. ABSOLUTE UNEXPECTED_MSG_BEFORE_CMD = 0x240
  72. ABSOLUTE MSG_IN_BEFORE_CMD = 0x250
  73. ABSOLUTE MSG_IN_AFTER_CMD = 0x350
  74. ABSOLUTE SDTR_MSG_BEFORE_CMD = 0x260
  75. ABSOLUTE REJECT_MSG_BEFORE_CMD = 0x270
  76. ABSOLUTE DISCONNECT_AFTER_CMD = 0x380
  77. ABSOLUTE SDTR_MSG_AFTER_CMD = 0x360
  78. ABSOLUTE WDTR_MSG_AFTER_CMD = 0x3A0
  79. ABSOLUTE MSG_IN_AFTER_STATUS = 0x440
  80. ABSOLUTE DISCONNECT_AFTER_DATA = 0x580
  81. ABSOLUTE MSG_IN_AFTER_DATA_IN = 0x550
  82. ABSOLUTE MSG_IN_AFTER_DATA_OUT = 0x650
  83. ABSOLUTE MSG_OUT_AFTER_DATA_IN = 0x590
  84. ABSOLUTE DATA_IN_AFTER_DATA_IN = 0x5a0
  85. ABSOLUTE MSG_IN_DURING_DATA_IN = 0x750
  86. ABSOLUTE DISCONNECT_DURING_DATA = 0x780
  87. ;
  88. ; Other interrupt conditions
  89. ;
  90. ABSOLUTE RESELECTED_DURING_SELECTION = 0x1000
  91. ABSOLUTE COMPLETED_SELECTION_AS_TARGET = 0x1001
  92. ABSOLUTE RESELECTION_IDENTIFIED = 0x1003
  93. ;
  94. ; Fatal interrupt conditions. If you add to this, also add to the
  95. ; array of corresponding messages
  96. ;
  97. ABSOLUTE FATAL = 0x2000
  98. ABSOLUTE FATAL_UNEXPECTED_RESELECTION_MSG = 0x2000
  99. ABSOLUTE FATAL_SEND_MSG = 0x2001
  100. ABSOLUTE FATAL_NOT_MSG_IN_AFTER_SELECTION = 0x2002
  101. ABSOLUTE FATAL_ILLEGAL_MSG_LENGTH = 0x2003
  102. ABSOLUTE DEBUG_INTERRUPT = 0x3000
  103. ABSOLUTE DEBUG_INTERRUPT1 = 0x3001
  104. ABSOLUTE DEBUG_INTERRUPT2 = 0x3002
  105. ABSOLUTE DEBUG_INTERRUPT3 = 0x3003
  106. ABSOLUTE DEBUG_INTERRUPT4 = 0x3004
  107. ABSOLUTE DEBUG_INTERRUPT5 = 0x3005
  108. ABSOLUTE DEBUG_INTERRUPT6 = 0x3006
  109. ;
  110. ; SCSI Messages we interpret in the script
  111. ;
  112. ABSOLUTE COMMAND_COMPLETE_MSG = 0x00
  113. ABSOLUTE EXTENDED_MSG = 0x01
  114. ABSOLUTE SDTR_MSG = 0x01
  115. ABSOLUTE SAVE_DATA_PTRS_MSG = 0x02
  116. ABSOLUTE RESTORE_DATA_PTRS_MSG = 0x03
  117. ABSOLUTE WDTR_MSG = 0x03
  118. ABSOLUTE DISCONNECT_MSG = 0x04
  119. ABSOLUTE REJECT_MSG = 0x07
  120. ABSOLUTE PARITY_ERROR_MSG = 0x09
  121. ABSOLUTE SIMPLE_TAG_MSG = 0x20
  122. ABSOLUTE IDENTIFY_MSG = 0x80
  123. ABSOLUTE IDENTIFY_MSG_MASK = 0x7F
  124. ABSOLUTE TWO_BYTE_MSG = 0x20
  125. ABSOLUTE TWO_BYTE_MSG_MASK = 0x0F
  126. ; This is where the script begins
  127. ENTRY StartUp
  128. StartUp:
  129. SELECT ATN Device_ID, Reselect
  130. JUMP Finish, WHEN STATUS
  131. JUMP SendIdentifyMsg, IF MSG_OUT
  132. INT NOT_MSG_OUT_AFTER_SELECTION
  133. Reselect:
  134. WAIT RESELECT SelectedAsTarget
  135. INT RESELECTED_DURING_SELECTION, WHEN MSG_IN
  136. INT FATAL_NOT_MSG_IN_AFTER_SELECTION
  137. ENTRY GetReselectionData
  138. GetReselectionData:
  139. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  140. INT RESELECTION_IDENTIFIED
  141. ENTRY GetReselectionWithTag
  142. GetReselectionWithTag:
  143. MOVE 3, ReceiveMsgAddress, WHEN MSG_IN
  144. INT RESELECTION_IDENTIFIED
  145. ENTRY SelectedAsTarget
  146. SelectedAsTarget:
  147. ; Basically tell the selecting device that there's nothing here
  148. SET TARGET
  149. DISCONNECT
  150. CLEAR TARGET
  151. INT COMPLETED_SELECTION_AS_TARGET
  152. ;
  153. ; These are the messaging entries
  154. ;
  155. ; Send a message. Message count should be correctly patched
  156. ENTRY SendMessage
  157. SendMessage:
  158. MOVE MessageCount, MessageLocation, WHEN MSG_OUT
  159. ResumeSendMessage:
  160. RETURN, WHEN NOT MSG_OUT
  161. INT FATAL_SEND_MSG
  162. ENTRY SendMessagePhaseMismatch
  163. SendMessagePhaseMismatch:
  164. CLEAR ACK
  165. JUMP ResumeSendMessage
  166. ;
  167. ; Receive a message. Need to identify the message to
  168. ; receive it correctly
  169. ENTRY ReceiveMessage
  170. ReceiveMessage:
  171. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  172. ;
  173. ; Use this entry if we've just tried to look at the first byte
  174. ; of the message and want to process it further
  175. ProcessReceiveMessage:
  176. JUMP ReceiveExtendedMessage, IF EXTENDED_MSG
  177. RETURN, IF NOT TWO_BYTE_MSG, AND MASK TWO_BYTE_MSG_MASK
  178. CLEAR ACK
  179. MOVE 1, ReceiveMsgAddress + 1, WHEN MSG_IN
  180. RETURN
  181. ReceiveExtendedMessage:
  182. CLEAR ACK
  183. MOVE 1, ReceiveMsgAddress + 1, WHEN MSG_IN
  184. JUMP Receive1Byte, IF 0x01
  185. JUMP Receive2Byte, IF 0x02
  186. JUMP Receive3Byte, IF 0x03
  187. JUMP Receive4Byte, IF 0x04
  188. JUMP Receive5Byte, IF 0x05
  189. INT FATAL_ILLEGAL_MSG_LENGTH
  190. Receive1Byte:
  191. CLEAR ACK
  192. MOVE 1, ReceiveMsgAddress + 2, WHEN MSG_IN
  193. RETURN
  194. Receive2Byte:
  195. CLEAR ACK
  196. MOVE 2, ReceiveMsgAddress + 2, WHEN MSG_IN
  197. RETURN
  198. Receive3Byte:
  199. CLEAR ACK
  200. MOVE 3, ReceiveMsgAddress + 2, WHEN MSG_IN
  201. RETURN
  202. Receive4Byte:
  203. CLEAR ACK
  204. MOVE 4, ReceiveMsgAddress + 2, WHEN MSG_IN
  205. RETURN
  206. Receive5Byte:
  207. CLEAR ACK
  208. MOVE 5, ReceiveMsgAddress + 2, WHEN MSG_IN
  209. RETURN
  210. ;
  211. ; Come here from the message processor to ignore the message
  212. ;
  213. ENTRY IgnoreMessage
  214. IgnoreMessage:
  215. CLEAR ACK
  216. RETURN
  217. ;
  218. ; Come here to send a reply to a message
  219. ;
  220. ENTRY SendMessageWithATN
  221. SendMessageWithATN:
  222. SET ATN
  223. CLEAR ACK
  224. JUMP SendMessage
  225. SendIdentifyMsg:
  226. CALL SendMessage
  227. CLEAR ATN
  228. IgnoreMsgBeforeCommand:
  229. CLEAR ACK
  230. ENTRY SendCommand
  231. SendCommand:
  232. JUMP Finish, WHEN STATUS
  233. JUMP MsgInBeforeCommand, IF MSG_IN
  234. INT UNEXPECTED_PHASE_BEFORE_CMD, IF NOT CMD
  235. MOVE CommandCount, CommandAddress, WHEN CMD
  236. ResumeSendCommand:
  237. JUMP Finish, WHEN STATUS
  238. JUMP MsgInAfterCmd, IF MSG_IN
  239. JUMP DataIn, IF DATA_IN
  240. JUMP DataOut, IF DATA_OUT
  241. INT UNEXPECTED_PHASE_AFTER_CMD
  242. IgnoreMsgDuringData:
  243. CLEAR ACK
  244. ; fall through to MsgInDuringData
  245. Entry MsgInDuringData
  246. MsgInDuringData:
  247. ;
  248. ; Could be we have nothing more to transfer
  249. ;
  250. JUMP Finish, WHEN STATUS
  251. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  252. JUMP DisconnectDuringDataIn, IF DISCONNECT_MSG
  253. JUMP IgnoreMsgDuringData, IF SAVE_DATA_PTRS_MSG
  254. JUMP IgnoreMsgDuringData, IF RESTORE_DATA_PTRS_MSG
  255. INT MSG_IN_DURING_DATA_IN
  256. MsgInAfterCmd:
  257. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  258. JUMP DisconnectAfterCmd, IF DISCONNECT_MSG
  259. JUMP IgnoreMsgInAfterCmd, IF SAVE_DATA_PTRS_MSG
  260. JUMP IgnoreMsgInAfterCmd, IF RESTORE_DATA_PTRS_MSG
  261. CALL ProcessReceiveMessage
  262. INT MSG_IN_AFTER_CMD
  263. CLEAR ACK
  264. JUMP ResumeSendCommand
  265. IgnoreMsgInAfterCmd:
  266. CLEAR ACK
  267. JUMP ResumeSendCommand
  268. DisconnectAfterCmd:
  269. CLEAR ACK
  270. WAIT DISCONNECT
  271. ENTRY Disconnect1
  272. Disconnect1:
  273. INT DISCONNECT_AFTER_CMD
  274. ENTRY Disconnect2
  275. Disconnect2:
  276. ; We return here after a reselection
  277. CLEAR ACK
  278. JUMP ResumeSendCommand
  279. MsgInBeforeCommand:
  280. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  281. JUMP IgnoreMsgBeforeCommand, IF SAVE_DATA_PTRS_MSG
  282. JUMP IgnoreMsgBeforeCommand, IF RESTORE_DATA_PTRS_MSG
  283. CALL ProcessReceiveMessage
  284. INT MSG_IN_BEFORE_CMD
  285. CLEAR ACK
  286. JUMP SendCommand
  287. DataIn:
  288. CALL SGScriptStartAddress
  289. ResumeDataIn:
  290. JUMP Finish, WHEN STATUS
  291. JUMP MsgInAfterDataIn, IF MSG_IN
  292. JUMP DataInAfterDataIn, if DATA_IN
  293. INT MSG_OUT_AFTER_DATA_IN, if MSG_OUT
  294. INT UNEXPECTED_PHASE_AFTER_DATA_IN
  295. DataInAfterDataIn:
  296. INT DATA_IN_AFTER_DATA_IN
  297. JUMP ResumeDataIn
  298. DataOut:
  299. CALL SGScriptStartAddress
  300. ResumeDataOut:
  301. JUMP Finish, WHEN STATUS
  302. JUMP MsgInAfterDataOut, IF MSG_IN
  303. INT UNEXPECTED_PHASE_AFTER_DATA_OUT
  304. MsgInAfterDataIn:
  305. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  306. JUMP DisconnectAfterDataIn, IF DISCONNECT_MSG
  307. JUMP IgnoreMsgAfterData, IF SAVE_DATA_PTRS_MSG
  308. JUMP IgnoreMsgAfterData, IF RESTORE_DATA_PTRS_MSG
  309. CALL ProcessReceiveMessage
  310. INT MSG_IN_AFTER_DATA_IN
  311. CLEAR ACK
  312. JUMP ResumeDataIn
  313. DisconnectDuringDataIn:
  314. CLEAR ACK
  315. WAIT DISCONNECT
  316. ENTRY Disconnect3
  317. Disconnect3:
  318. INT DISCONNECT_DURING_DATA
  319. ENTRY Disconnect4
  320. Disconnect4:
  321. ; we return here after a reselection
  322. CLEAR ACK
  323. JUMP ResumeSendCommand
  324. DisconnectAfterDataIn:
  325. CLEAR ACK
  326. WAIT DISCONNECT
  327. ENTRY Disconnect5
  328. Disconnect5:
  329. INT DISCONNECT_AFTER_DATA
  330. ENTRY Disconnect6
  331. Disconnect6:
  332. ; we return here after a reselection
  333. CLEAR ACK
  334. JUMP ResumeDataIn
  335. MsgInAfterDataOut:
  336. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  337. JUMP DisconnectAfterDataOut, if DISCONNECT_MSG
  338. JUMP IgnoreMsgAfterData, IF SAVE_DATA_PTRS_MSG
  339. JUMP IgnoreMsgAfterData, IF RESTORE_DATA_PTRS_MSG
  340. CALL ProcessReceiveMessage
  341. INT MSG_IN_AFTER_DATA_OUT
  342. CLEAR ACK
  343. JUMP ResumeDataOut
  344. IgnoreMsgAfterData:
  345. CLEAR ACK
  346. ; Data in and out do the same thing on resume, so pick one
  347. JUMP ResumeDataIn
  348. DisconnectAfterDataOut:
  349. CLEAR ACK
  350. WAIT DISCONNECT
  351. ENTRY Disconnect7
  352. Disconnect7:
  353. INT DISCONNECT_AFTER_DATA
  354. ENTRY Disconnect8
  355. Disconnect8:
  356. ; we return here after a reselection
  357. CLEAR ACK
  358. JUMP ResumeDataOut
  359. Finish:
  360. MOVE 1, StatusAddress, WHEN STATUS
  361. INT NOT_MSG_IN_AFTER_STATUS, WHEN NOT MSG_IN
  362. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  363. JUMP FinishCommandComplete, IF COMMAND_COMPLETE_MSG
  364. CALL ProcessReceiveMessage
  365. INT MSG_IN_AFTER_STATUS
  366. ENTRY FinishCommandComplete
  367. FinishCommandComplete:
  368. CLEAR ACK
  369. WAIT DISCONNECT
  370. ENTRY Finish1
  371. Finish1:
  372. INT GOOD_STATUS_AFTER_STATUS
  373. ENTRY Finish2
  374. Finish2: