53c700.scr
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:11k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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 preceeded 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. ABSOLUTE RESELECTED_DURING_SELECTION = 0x1000
  90. ABSOLUTE COMPLETED_SELECTION_AS_TARGET = 0x1001
  91. ABSOLUTE RESELECTION_IDENTIFIED = 0x1003
  92. ;
  93. ; Fatal interrupt conditions.  If you add to this, also add to the
  94. ; array of corresponding messages
  95. ;
  96. ABSOLUTE FATAL = 0x2000
  97. ABSOLUTE FATAL_UNEXPECTED_RESELECTION_MSG = 0x2000
  98. ABSOLUTE FATAL_SEND_MSG = 0x2001
  99. ABSOLUTE FATAL_NOT_MSG_IN_AFTER_SELECTION = 0x2002
  100. ABSOLUTE FATAL_ILLEGAL_MSG_LENGTH = 0x2003
  101. ABSOLUTE DEBUG_INTERRUPT = 0x3000
  102. ABSOLUTE DEBUG_INTERRUPT1 = 0x3001
  103. ABSOLUTE DEBUG_INTERRUPT2 = 0x3002
  104. ABSOLUTE DEBUG_INTERRUPT3 = 0x3003
  105. ABSOLUTE DEBUG_INTERRUPT4 = 0x3004
  106. ABSOLUTE DEBUG_INTERRUPT5 = 0x3005
  107. ABSOLUTE DEBUG_INTERRUPT6 = 0x3006
  108. ;
  109. ; SCSI Messages we interpret in the script
  110. ;
  111. ABSOLUTE COMMAND_COMPLETE_MSG = 0x00
  112. ABSOLUTE EXTENDED_MSG = 0x01
  113. ABSOLUTE SDTR_MSG = 0x01
  114. ABSOLUTE SAVE_DATA_PTRS_MSG = 0x02
  115. ABSOLUTE RESTORE_DATA_PTRS_MSG = 0x03
  116. ABSOLUTE WDTR_MSG = 0x03
  117. ABSOLUTE DISCONNECT_MSG = 0x04
  118. ABSOLUTE REJECT_MSG = 0x07
  119. ABSOLUTE PARITY_ERROR_MSG = 0x09
  120. ABSOLUTE SIMPLE_TAG_MSG = 0x20
  121. ABSOLUTE IDENTIFY_MSG = 0x80
  122. ABSOLUTE IDENTIFY_MSG_MASK = 0x7F
  123. ABSOLUTE TWO_BYTE_MSG = 0x20
  124. ABSOLUTE TWO_BYTE_MSG_MASK = 0x0F
  125. ; This is where the script begins
  126. ENTRY StartUp
  127. StartUp:
  128. SELECT ATN Device_ID, Reselect
  129. JUMP Finish, WHEN STATUS
  130. JUMP SendIdentifyMsg, IF MSG_OUT
  131. INT NOT_MSG_OUT_AFTER_SELECTION
  132. Reselect:
  133. WAIT RESELECT SelectedAsTarget
  134. INT RESELECTED_DURING_SELECTION, WHEN MSG_IN
  135. INT FATAL_NOT_MSG_IN_AFTER_SELECTION
  136. ENTRY GetReselectionData
  137. GetReselectionData:
  138. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  139. INT RESELECTION_IDENTIFIED
  140. ENTRY GetReselectionWithTag
  141. GetReselectionWithTag:
  142. MOVE 3, ReceiveMsgAddress, WHEN MSG_IN
  143. INT RESELECTION_IDENTIFIED
  144. ENTRY SelectedAsTarget
  145. SelectedAsTarget:
  146. ; Basically tell the selecting device that there's nothing here
  147. SET TARGET
  148. DISCONNECT
  149. CLEAR TARGET
  150. INT COMPLETED_SELECTION_AS_TARGET
  151. ;
  152. ; These are the messaging entries
  153. ;
  154. ; Send a message.  Message count should be correctly patched
  155. ENTRY SendMessage
  156. SendMessage:
  157. MOVE MessageCount, MessageLocation, WHEN MSG_OUT
  158. ResumeSendMessage:
  159. RETURN, WHEN NOT MSG_OUT
  160. INT FATAL_SEND_MSG
  161. ENTRY SendMessagePhaseMismatch
  162. SendMessagePhaseMismatch:
  163. CLEAR ACK
  164. JUMP ResumeSendMessage
  165. ;
  166. ; Receive a message.  Need to identify the message to
  167. ; receive it correctly
  168. ENTRY ReceiveMessage
  169. ReceiveMessage:
  170. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  171. ;
  172. ; Use this entry if we've just tried to look at the first byte
  173. ; of the message and want to process it further
  174. ProcessReceiveMessage:
  175. JUMP ReceiveExtendedMessage, IF EXTENDED_MSG
  176. RETURN, IF NOT TWO_BYTE_MSG, AND MASK TWO_BYTE_MSG_MASK
  177. CLEAR ACK
  178. MOVE 1, ReceiveMsgAddress + 1, WHEN MSG_IN
  179. RETURN
  180. ReceiveExtendedMessage:
  181. CLEAR ACK
  182. MOVE 1, ReceiveMsgAddress + 1, WHEN MSG_IN
  183. JUMP Receive1Byte, IF 0x01
  184. JUMP Receive2Byte, IF 0x02
  185. JUMP Receive3Byte, IF 0x03
  186. JUMP Receive4Byte, IF 0x04
  187. JUMP Receive5Byte, IF 0x05
  188. INT FATAL_ILLEGAL_MSG_LENGTH
  189. Receive1Byte:
  190. CLEAR ACK
  191. MOVE 1, ReceiveMsgAddress + 2, WHEN MSG_IN
  192. RETURN
  193. Receive2Byte:
  194. CLEAR ACK
  195. MOVE 2, ReceiveMsgAddress + 2, WHEN MSG_IN
  196. RETURN
  197. Receive3Byte:
  198. CLEAR ACK
  199. MOVE 3, ReceiveMsgAddress + 2, WHEN MSG_IN
  200. RETURN
  201. Receive4Byte:
  202. CLEAR ACK
  203. MOVE 4, ReceiveMsgAddress + 2, WHEN MSG_IN
  204. RETURN
  205. Receive5Byte:
  206. CLEAR ACK
  207. MOVE 5, ReceiveMsgAddress + 2, WHEN MSG_IN
  208. RETURN
  209. ;
  210. ; Come here from the message processor to ignore the message
  211. ;
  212. ENTRY IgnoreMessage
  213. IgnoreMessage:
  214. CLEAR ACK
  215. RETURN
  216. ;
  217. ; Come here to send a reply to a message
  218. ;
  219. ENTRY SendMessageWithATN
  220. SendMessageWithATN:
  221. SET ATN
  222. CLEAR ACK
  223. JUMP SendMessage
  224. SendIdentifyMsg:
  225. CALL SendMessage
  226. CLEAR ATN
  227. IgnoreMsgBeforeCommand:
  228. CLEAR ACK
  229. ENTRY SendCommand
  230. SendCommand:
  231. JUMP Finish, WHEN STATUS
  232. JUMP MsgInBeforeCommand, IF MSG_IN
  233. INT UNEXPECTED_PHASE_BEFORE_CMD, IF NOT CMD
  234. MOVE CommandCount, CommandAddress, WHEN CMD
  235. ResumeSendCommand:
  236. JUMP Finish, WHEN STATUS
  237. JUMP MsgInAfterCmd, IF MSG_IN
  238. JUMP DataIn, IF DATA_IN
  239. JUMP DataOut, IF DATA_OUT
  240. INT UNEXPECTED_PHASE_AFTER_CMD
  241. IgnoreMsgDuringData:
  242. CLEAR ACK
  243. ; fall through to MsgInDuringData
  244. Entry MsgInDuringData
  245. MsgInDuringData:
  246. ;
  247. ; Could be we have nothing more to transfer
  248. ;
  249. JUMP Finish, WHEN STATUS
  250. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  251. JUMP DisconnectDuringDataIn, IF DISCONNECT_MSG
  252. JUMP IgnoreMsgDuringData, IF SAVE_DATA_PTRS_MSG
  253. JUMP IgnoreMsgDuringData, IF RESTORE_DATA_PTRS_MSG
  254. INT MSG_IN_DURING_DATA_IN
  255. MsgInAfterCmd:
  256. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  257. JUMP DisconnectAfterCmd, IF DISCONNECT_MSG
  258. JUMP IgnoreMsgInAfterCmd, IF SAVE_DATA_PTRS_MSG
  259. JUMP IgnoreMsgInAfterCmd, IF RESTORE_DATA_PTRS_MSG
  260. CALL ProcessReceiveMessage
  261. INT MSG_IN_AFTER_CMD
  262. CLEAR ACK
  263. JUMP ResumeSendCommand
  264. IgnoreMsgInAfterCmd:
  265. CLEAR ACK
  266. JUMP ResumeSendCommand
  267. DisconnectAfterCmd:
  268. CLEAR ACK
  269. WAIT DISCONNECT
  270. ENTRY Disconnect1
  271. Disconnect1:
  272. INT DISCONNECT_AFTER_CMD
  273. ENTRY Disconnect2
  274. Disconnect2:
  275. ; We return here after a reselection
  276. CLEAR ACK
  277. JUMP ResumeSendCommand
  278. MsgInBeforeCommand:
  279. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  280. JUMP IgnoreMsgBeforeCommand, IF SAVE_DATA_PTRS_MSG
  281. JUMP IgnoreMsgBeforeCommand, IF RESTORE_DATA_PTRS_MSG
  282. CALL ProcessReceiveMessage
  283. INT MSG_IN_BEFORE_CMD
  284. CLEAR ACK
  285. JUMP SendCommand
  286. DataIn:
  287. CALL SGScriptStartAddress
  288. ResumeDataIn:
  289. JUMP Finish, WHEN STATUS
  290. JUMP MsgInAfterDataIn, IF MSG_IN
  291. JUMP DataInAfterDataIn, if DATA_IN
  292. INT MSG_OUT_AFTER_DATA_IN, if MSG_OUT
  293. INT UNEXPECTED_PHASE_AFTER_DATA_IN
  294. DataInAfterDataIn:
  295. INT DATA_IN_AFTER_DATA_IN
  296. JUMP ResumeDataIn
  297. DataOut:
  298. CALL SGScriptStartAddress
  299. ResumeDataOut:
  300. JUMP Finish, WHEN STATUS
  301. JUMP MsgInAfterDataOut, IF MSG_IN
  302. INT UNEXPECTED_PHASE_AFTER_DATA_OUT
  303. MsgInAfterDataIn:
  304. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  305. JUMP DisconnectAfterDataIn, IF DISCONNECT_MSG
  306. JUMP IgnoreMsgAfterData, IF SAVE_DATA_PTRS_MSG
  307. JUMP IgnoreMsgAfterData, IF RESTORE_DATA_PTRS_MSG
  308. CALL ProcessReceiveMessage
  309. INT MSG_IN_AFTER_DATA_IN
  310. CLEAR ACK
  311. JUMP ResumeDataIn
  312. DisconnectDuringDataIn:
  313. CLEAR ACK
  314. WAIT DISCONNECT
  315. ENTRY Disconnect3
  316. Disconnect3:
  317. INT DISCONNECT_DURING_DATA
  318. ENTRY Disconnect4
  319. Disconnect4:
  320. ; we return here after a reselection
  321. CLEAR ACK
  322. JUMP ResumeSendCommand
  323. DisconnectAfterDataIn:
  324. CLEAR ACK
  325. WAIT DISCONNECT
  326. ENTRY Disconnect5
  327. Disconnect5:
  328. INT DISCONNECT_AFTER_DATA
  329. ENTRY Disconnect6
  330. Disconnect6:
  331. ; we return here after a reselection
  332. CLEAR ACK
  333. JUMP ResumeDataIn
  334. MsgInAfterDataOut:
  335. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  336. JUMP DisconnectAfterDataOut, if DISCONNECT_MSG
  337. JUMP IgnoreMsgAfterData, IF SAVE_DATA_PTRS_MSG
  338. JUMP IgnoreMsgAfterData, IF RESTORE_DATA_PTRS_MSG
  339. CALL ProcessReceiveMessage
  340. INT MSG_IN_AFTER_DATA_OUT
  341. CLEAR ACK
  342. JUMP ResumeDataOut
  343. IgnoreMsgAfterData:
  344. CLEAR ACK
  345. ; Data in and out do the same thing on resume, so pick one
  346. JUMP ResumeDataIn
  347. DisconnectAfterDataOut:
  348. CLEAR ACK
  349. WAIT DISCONNECT
  350. ENTRY Disconnect7
  351. Disconnect7:
  352. INT DISCONNECT_AFTER_DATA
  353. ENTRY Disconnect8
  354. Disconnect8:
  355. ; we return here after a reselection
  356. CLEAR ACK
  357. JUMP ResumeDataOut
  358. Finish:
  359. MOVE 1, StatusAddress, WHEN STATUS
  360. INT NOT_MSG_IN_AFTER_STATUS, WHEN NOT MSG_IN
  361. MOVE 1, ReceiveMsgAddress, WHEN MSG_IN
  362. JUMP FinishCommandComplete, IF COMMAND_COMPLETE_MSG
  363. CALL ProcessReceiveMessage
  364. INT MSG_IN_AFTER_STATUS
  365. ENTRY FinishCommandComplete
  366. FinishCommandComplete:
  367. CLEAR ACK
  368. WAIT DISCONNECT
  369. ENTRY Finish1
  370. Finish1:
  371. INT GOOD_STATUS_AFTER_STATUS
  372. ENTRY Finish2
  373. Finish2: