home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / oslib / oslib_1 / OSLib / Computer / h / scsi < prev    next >
Encoding:
Text File  |  1995-06-27  |  17.8 KB  |  550 lines

  1. #ifndef scsi_H
  2. #define scsi_H
  3.  
  4. /* C header file for SCSI
  5.  * written by DefMod (Jun 20 1995) on Tue Jun 27 17:06:29 1995
  6.  * Jonathan Coxhead, Acorn Computers Ltd
  7.  */
  8.  
  9. #ifndef types_H
  10. #include "types.h"
  11. #endif
  12.  
  13. #ifndef os_H
  14. #include "os.h"
  15. #endif
  16.  
  17. /**********************************
  18.  * SWI names and SWI reason codes *
  19.  **********************************/
  20. #undef  SCSI_Version
  21. #define SCSI_Version                            0x403C0
  22. #undef  XSCSI_Version
  23. #define XSCSI_Version                           0x603C0
  24. #undef  SCSI_Initialise
  25. #define SCSI_Initialise                         0x403C1
  26. #undef  XSCSI_Initialise
  27. #define XSCSI_Initialise                        0x603C1
  28. #undef  SCSIInitialise_ResetBus
  29. #define SCSIInitialise_ResetBus                 0x0
  30. #undef  SCSIInitialise_ResetDevice
  31. #define SCSIInitialise_ResetDevice              0x1
  32. #undef  SCSIInitialise_DetermineDevice
  33. #define SCSIInitialise_DetermineDevice          0x2
  34. #undef  SCSIInitialise_EnumerateDevice
  35. #define SCSIInitialise_EnumerateDevice          0x3
  36. #undef  SCSI_Control
  37. #define SCSI_Control                            0x403C2
  38. #undef  XSCSI_Control
  39. #define XSCSI_Control                           0x603C2
  40. #undef  SCSIControl_AbortDevice
  41. #define SCSIControl_AbortDevice                 0x0
  42. #undef  SCSIControl_AbortOp
  43. #define SCSIControl_AbortOp                     0x1
  44. #undef  SCSIControl_SetTimeout
  45. #define SCSIControl_SetTimeout                  0x3
  46. #undef  SCSIControl_SetErrorResponse
  47. #define SCSIControl_SetErrorResponse            0x4
  48. #undef  SCSIControl_SetQueueBehaviour
  49. #define SCSIControl_SetQueueBehaviour           0x5
  50. #undef  SCSIControl_Disconnect
  51. #define SCSIControl_Disconnect                  0x6
  52. #undef  SCSI_Op
  53. #define SCSI_Op                                 0x403C3
  54. #undef  XSCSI_Op
  55. #define XSCSI_Op                                0x603C3
  56. #undef  SCSI_Status
  57. #define SCSI_Status                             0x403C4
  58. #undef  XSCSI_Status
  59. #define XSCSI_Status                            0x603C4
  60. #undef  SCSIStatus_CheckDevice
  61. #define SCSIStatus_CheckDevice                  0x0
  62. #undef  SCSI_Reserve
  63. #define SCSI_Reserve                            0x403C7
  64. #undef  XSCSI_Reserve
  65. #define XSCSI_Reserve                           0x603C7
  66. #undef  SCSIReserve_Claim
  67. #define SCSIReserve_Claim                       0x0
  68. #undef  SCSIReserve_ForceClaim
  69. #define SCSIReserve_ForceClaim                  0x1
  70. #undef  SCSIReserve_Release
  71. #define SCSIReserve_Release                     0x2
  72. #undef  SCSI_List
  73. #define SCSI_List                               0x403C8
  74. #undef  XSCSI_List
  75. #define XSCSI_List                              0x603C8
  76.  
  77. /************************************
  78.  * Structure and union declarations *
  79.  ************************************/
  80. typedef struct scsi_device_description          scsi_device_description;
  81. typedef struct scsi_op_block                    scsi_op_block;
  82. typedef struct scsi_card_address_list           scsi_card_address_list;
  83.  
  84. /********************
  85.  * Type definitions *
  86.  ********************/
  87. typedef bits scsi_software_features;
  88.  
  89. typedef bits scsi_hardware_features;
  90.  
  91. typedef byte scsi_device_type;
  92.  
  93. typedef byte scsi_device_flags;
  94.  
  95. typedef byte scsi_device_version;
  96.  
  97. struct scsi_device_description
  98.    {  scsi_device_type type;
  99.       scsi_device_flags flags;
  100.       scsi_device_version version;
  101.       byte reserved0;
  102.       byte length;
  103.       byte reserved1;
  104.       byte reserved2;
  105.       byte reserved3;
  106.       int block_count;
  107.       int block_size;
  108.    };
  109.  
  110. typedef int scsi_error_response_level;
  111.  
  112. typedef int scsi_queue_behaviour;
  113.  
  114. typedef int scsi_disconnection;
  115.  
  116. struct scsi_op_block
  117.    {  int o [UNKNOWN];
  118.    };
  119.  
  120. #define scsi_OP_BLOCK(N) \
  121.    struct \
  122.       {  int o [N]; \
  123.       }
  124.  
  125. #define scsi_SIZEOF_OP_BLOCK(N) \
  126.    ((N)*sizeof ((scsi_op_block *) NULL)->o)
  127.  
  128. typedef int scsi_device_status;
  129.  
  130. struct scsi_card_address_list
  131.    {  byte *addr [UNKNOWN];
  132.    };
  133.  
  134. #define scsi_CARD_ADDRESS_LIST(N) \
  135.    struct \
  136.       {  byte *addr [N]; \
  137.       }
  138.  
  139. #define scsi_SIZEOF_CARD_ADDRESS_LIST(N) \
  140.    ((N)*sizeof ((scsi_card_address_list *) NULL)->addr)
  141.  
  142. /************************
  143.  * Constant definitions *
  144.  ************************/
  145. #define scsi_CHECK_NO_CHANGE                    ((scsi_error_response_level) 0xFFFFFFFFu)
  146.       /*No action, return previous setting*/
  147. #define scsi_CHECK_ERROR                        ((scsi_error_response_level) 0x0u)
  148.       /*If device returns check condition, return that as an error message. This is for badly-behaved devices with non-standard request-sense return blocks*/
  149. #define scsi_CHECK_SENSE                        ((scsi_error_response_level) 0x1u)
  150.       /*If device returns check condition, do the request sense automatically, report the error*/
  151. #define scsi_CHECK_RETRY                        ((scsi_error_response_level) 0x2u)
  152.       /*If device returns check condition, do a request sense automatically, if unit attention, ignore it and reissue the command, else report the error*/
  153. #define scsi_BEHAVIOUR_NO_CHANGE                ((scsi_queue_behaviour_level) 0xFFFFFFFFu)
  154.       /*No action, return previous setting*/
  155. #define scsi_BEHAVIOUR_WAIT                     ((scsi_queue_behaviour_level) 0x0u)
  156.       /*Queue the command, waiting until a slot becomes free if necessary*/
  157. #define scsi_BEHAVIOUR_AWAIT_QUEUE              ((scsi_queue_behaviour_level) 0x1u)
  158.       /*Queue the command if there is room in the queue*/
  159. #define scsi_BEHAVIOUR_AWAIT_DEVICE             ((scsi_queue_behaviour_level) 0x2u)
  160.       /*Perform the command if the device is ready*/
  161. #define scsi_BEHAVIOUR_AWAIT_CARD               ((scsi_queue_behaviour_level) 0x3u)
  162.       /*Perform the command if the card is ready*/
  163. #define scsi_DISCONNECT_NO_CHANGE               ((scsi_disconnection) 0xFFFFFFFFu)
  164. #define scsi_DISCONNECT_ALLOWED                 ((scsi_disconnection) 0x0u)
  165. #define scsi_DISCONNECT_INHIBITED_BY_BLOCKING   ((scsi_disconnection) 0x1u)
  166. #define scsi_DISCONNECT_INHIBITED               ((scsicontrol_disconnection) 0x2u)
  167. #define scsi_DEVICE_STATUS_IDLE                 ((scsi_device_status) 0x1u)
  168. #define scsi_DEVICE_STATUS_BUSY                 ((scsi_device_status) 0x2u)
  169.  
  170. /*************************
  171.  * Function declarations *
  172.  *************************/
  173.  
  174. #ifdef __cplusplus
  175.    extern "C" {
  176. #endif
  177.  
  178. /* ------------------------------------------------------------------------
  179.  * Function:      scsi_version()
  180.  *
  181.  * Description:   Determines the version number of the drivers
  182.  *
  183.  * Output:        software_version - value of R0 on exit
  184.  *                software_features - value of R1 on exit
  185.  *                hardware_version - value of R2 on exit
  186.  *                hardware_features - value of R3 on exit
  187.  *
  188.  * Other notes:   Calls SWI 0x403C0.
  189.  */
  190.  
  191. extern os_error *xscsi_version (bits *software_version,
  192.       scsi_software_features *software_features,
  193.       bits *hardware_version,
  194.       scsi_hardware_features *hardware_features);
  195. extern void scsi_version (bits *software_version,
  196.       scsi_software_features *software_features,
  197.       bits *hardware_version,
  198.       scsi_hardware_features *hardware_features);
  199.  
  200. /* ------------------------------------------------------------------------
  201.  * Function:      scsiinitialise_reset_bus()
  202.  *
  203.  * Description:   Resets all options set by SCSI_Control to their default
  204.  *                states and removes device reservations
  205.  *
  206.  * Input:         host_id - value of R1 on entry
  207.  *
  208.  * Other notes:   Calls SWI 0x403C1 with R0 = 0x0.
  209.  */
  210.  
  211. extern os_error *xscsiinitialise_reset_bus (int host_id);
  212. extern void scsiinitialise_reset_bus (int host_id);
  213.  
  214. /* ------------------------------------------------------------------------
  215.  * Function:      scsiinitialise_reset_device()
  216.  *
  217.  * Description:   Initiates the reset operation for a device and returns
  218.  *                immediately
  219.  *
  220.  * Input:         device_id - value of R1 on entry
  221.  *                access_key - value of R8 on entry
  222.  *
  223.  * Other notes:   Calls SWI 0x403C1 with R0 = 0x1.
  224.  */
  225.  
  226. extern os_error *xscsiinitialise_reset_device (int device_id,
  227.       int access_key);
  228. extern void scsiinitialise_reset_device (int device_id,
  229.       int access_key);
  230.  
  231. /* ------------------------------------------------------------------------
  232.  * Function:      scsiinitialise_determine_device()
  233.  *
  234.  * Description:   Sees what type the device is and then performs the
  235.  *                appropriate read-capacity commands
  236.  *
  237.  * Input:         device_id - value of R1 on entry
  238.  *                description - value of R2 on entry
  239.  *
  240.  * Other notes:   Calls SWI 0x403C1 with R0 = 0x2.
  241.  */
  242.  
  243. extern os_error *xscsiinitialise_determine_device (int device_id,
  244.       scsi_device_description *description);
  245. extern void scsiinitialise_determine_device (int device_id,
  246.       scsi_device_description *description);
  247.  
  248. /* ------------------------------------------------------------------------
  249.  * Function:      scsiinitialise_enumerate_device()
  250.  *
  251.  * Description:   Sees what type the device is and then performs the
  252.  *                appropriate read-capacity commands, formatting the result
  253.  *                as text
  254.  *
  255.  * Input:         device_id - value of R1 on entry
  256.  *                description - value of R2 on entry
  257.  *                size - value of R3 on entry
  258.  *
  259.  * Other notes:   Calls SWI 0x403C1 with R0 = 0x3.
  260.  */
  261.  
  262. extern os_error *xscsiinitialise_enumerate_device (int device_id,
  263.       char *description,
  264.       int size);
  265. extern void scsiinitialise_enumerate_device (int device_id,
  266.       char *description,
  267.       int size);
  268.  
  269. /* ------------------------------------------------------------------------
  270.  * Function:      scsicontrol_abort_device()
  271.  *
  272.  * Description:   Cancels any outstanding operation on a device
  273.  *
  274.  * Input:         device_id - value of R1 on entry
  275.  *                access_key - value of R8 on entry
  276.  *
  277.  * Other notes:   Calls SWI 0x403C2 with R0 = 0x0.
  278.  */
  279.  
  280. extern os_error *xscsicontrol_abort_device (int device_id,
  281.       int access_key);
  282. extern void scsicontrol_abort_device (int device_id,
  283.       int access_key);
  284.  
  285. /* ------------------------------------------------------------------------
  286.  * Function:      scsicontrol_abort_op()
  287.  *
  288.  * Description:   Cancels a particular operation on a device
  289.  *
  290.  * Input:         device_id - value of R1 on entry
  291.  *                op_id - value of R2 on entry
  292.  *                access_key - value of R8 on entry
  293.  *
  294.  * Other notes:   Calls SWI 0x403C2 with R0 = 0x1.
  295.  */
  296.  
  297. extern os_error *xscsicontrol_abort_op (int device_id,
  298.       int op_id,
  299.       int access_key);
  300. extern void scsicontrol_abort_op (int device_id,
  301.       int op_id,
  302.       int access_key);
  303.  
  304. /* ------------------------------------------------------------------------
  305.  * Function:      scsicontrol_set_timeout()
  306.  *
  307.  * Description:   Sets the default timeout for a device
  308.  *
  309.  * Input:         device_id - value of R1 on entry
  310.  *                timeout - value of R2 on entry
  311.  *                access_key - value of R8 on entry
  312.  *
  313.  * Output:        old_timeout - value of R2 on exit (X version only)
  314.  *
  315.  * Returns:       R2 (non-X version only)
  316.  *
  317.  * Other notes:   Calls SWI 0x403C2 with R0 = 0x3.
  318.  */
  319.  
  320. extern os_error *xscsicontrol_set_timeout (int device_id,
  321.       int timeout,
  322.       int access_key,
  323.       int *old_timeout);
  324. extern int scsicontrol_set_timeout (int device_id,
  325.       int timeout,
  326.       int access_key);
  327.  
  328. /* ------------------------------------------------------------------------
  329.  * Function:      scsicontrol_set_error_response()
  330.  *
  331.  * Description:   Controls the behaviour of the device on receipt of a
  332.  *                check condition status
  333.  *
  334.  * Input:         device_id - value of R1 on entry
  335.  *                level - value of R2 on entry
  336.  *                access_key - value of R8 on entry
  337.  *
  338.  * Output:        old_level - value of R2 on exit (X version only)
  339.  *
  340.  * Returns:       R2 (non-X version only)
  341.  *
  342.  * Other notes:   Calls SWI 0x403C2 with R0 = 0x4.
  343.  */
  344.  
  345. extern os_error *xscsicontrol_set_error_response (int device_id,
  346.       scsi_error_response_level level,
  347.       int access_key,
  348.       int *old_level);
  349. extern int scsicontrol_set_error_response (int device_id,
  350.       scsi_error_response_level level,
  351.       int access_key);
  352.  
  353. /* ------------------------------------------------------------------------
  354.  * Function:      scsicontrol_set_queue_behaviour()
  355.  *
  356.  * Description:   Sets queue behaviour
  357.  *
  358.  * Input:         device_id - value of R1 on entry
  359.  *                behaviour - value of R2 on entry
  360.  *                access_key - value of R8 on entry
  361.  *
  362.  * Output:        old_level - value of R2 on exit (X version only)
  363.  *
  364.  * Returns:       R2 (non-X version only)
  365.  *
  366.  * Other notes:   Calls SWI 0x403C2 with R0 = 0x5.
  367.  */
  368.  
  369. extern os_error *xscsicontrol_set_queue_behaviour (int device_id,
  370.       scsi_queue_behaviour behaviour,
  371.       int access_key,
  372.       int *old_level);
  373. extern int scsicontrol_set_queue_behaviour (int device_id,
  374.       scsi_queue_behaviour behaviour,
  375.       int access_key);
  376.  
  377. /* ------------------------------------------------------------------------
  378.  * Function:      scsicontrol_disconnect()
  379.  *
  380.  * Description:   Allows/inhibits disconnection/reselection. Device must be
  381.  *                idle
  382.  *
  383.  * Input:         device_id - value of R1 on entry
  384.  *                disconnection - value of R2 on entry
  385.  *
  386.  * Output:        old_disconnection - value of R2 on exit (X version only)
  387.  *                access_key - value of R8 on exit
  388.  *
  389.  * Returns:       R2 (non-X version only)
  390.  *
  391.  * Other notes:   Calls SWI 0x403C2 with R0 = 0x6.
  392.  */
  393.  
  394. extern os_error *xscsicontrol_disconnect (int device_id,
  395.       scsi_disconnection disconnection,
  396.       int *old_disconnection,
  397.       int *access_key);
  398. extern int scsicontrol_disconnect (int device_id,
  399.       scsi_disconnection disconnection,
  400.       int *access_key);
  401.  
  402. /* ------------------------------------------------------------------------
  403.  * Function:      scsi_op()
  404.  *
  405.  * Description:   Issues a SCSI command to a device and can be called in
  406.  *                the background
  407.  *
  408.  * Input:         op - value of R0 on entry
  409.  *                block_size - value of R1 on entry
  410.  *                block - value of R2 on entry
  411.  *                start_addr - value of R3 on entry
  412.  *                length - value of R4 on entry
  413.  *                timeout - value of R5 on entry
  414.  *                callback_code - value of R6 on entry
  415.  *                workspace - value of R7 on entry
  416.  *                access_key - value of R8 on entry
  417.  *
  418.  * Output:        op_id - value of R0 on exit
  419.  *                next_addr - value of R3 on exit
  420.  *                undone - value of R4 on exit (X version only)
  421.  *
  422.  * Returns:       R4 (non-X version only)
  423.  *
  424.  * Other notes:   Calls SWI 0x403C3.
  425.  */
  426.  
  427. extern os_error *xscsi_op (bits op,
  428.       int block_size,
  429.       scsi_op_block const *block,
  430.       byte *start_addr,
  431.       int length,
  432.       int timeout,
  433.       void const *callback_code,
  434.       void *workspace,
  435.       int access_key,
  436.       int *op_id,
  437.       byte **next_addr,
  438.       int *undone);
  439. extern int scsi_op (bits op,
  440.       int block_size,
  441.       scsi_op_block const *block,
  442.       byte *start_addr,
  443.       int length,
  444.       int timeout,
  445.       void const *callback_code,
  446.       void *workspace,
  447.       int access_key,
  448.       int *op_id,
  449.       byte **next_addr);
  450.  
  451. /* ------------------------------------------------------------------------
  452.  * Function:      scsistatus_check_device()
  453.  *
  454.  * Description:   Returns the status of the selected device
  455.  *
  456.  * Input:         device_id - value of R1 on entry
  457.  *
  458.  * Output:        status - value of R0 on exit (X version only)
  459.  *
  460.  * Returns:       R0 (non-X version only)
  461.  *
  462.  * Other notes:   Calls SWI 0x403C4 with R0 = 0x0.
  463.  */
  464.  
  465. extern os_error *xscsistatus_check_device (int device_id,
  466.       scsi_device_status *status);
  467. extern scsi_device_status scsistatus_check_device (int device_id);
  468.  
  469. /* ------------------------------------------------------------------------
  470.  * Function:      scsireserve_claim()
  471.  *
  472.  * Description:   Claims exclusive use of a device
  473.  *
  474.  * Input:         device_id - value of R1 on entry
  475.  *                release_code - value of R2 on entry
  476.  *                workspace - value of R3 on entry
  477.  *                access_key - value of R8 on entry
  478.  *
  479.  * Other notes:   Calls SWI 0x403C7 with R0 = 0x0.
  480.  */
  481.  
  482. extern os_error *xscsireserve_claim (int device_id,
  483.       void const *release_code,
  484.       void *workspace,
  485.       int access_key);
  486. extern void scsireserve_claim (int device_id,
  487.       void const *release_code,
  488.       void *workspace,
  489.       int access_key);
  490.  
  491. /* ------------------------------------------------------------------------
  492.  * Function:      scsireserve_force_claim()
  493.  *
  494.  * Description:   Claims exclusive use of a device, and if the device is
  495.  *                already claimed, calls the release code for the current
  496.  *                claimant
  497.  *
  498.  * Input:         device_id - value of R1 on entry
  499.  *                release_code - value of R2 on entry
  500.  *                workspace - value of R3 on entry
  501.  *                access_key - value of R8 on entry
  502.  *
  503.  * Other notes:   Calls SWI 0x403C7 with R0 = 0x1.
  504.  */
  505.  
  506. extern os_error *xscsireserve_force_claim (int device_id,
  507.       void const *release_code,
  508.       void *workspace,
  509.       int access_key);
  510. extern void scsireserve_force_claim (int device_id,
  511.       void const *release_code,
  512.       void *workspace,
  513.       int access_key);
  514.  
  515. /* ------------------------------------------------------------------------
  516.  * Function:      scsireserve_release()
  517.  *
  518.  * Description:   Removes the claim to a device
  519.  *
  520.  * Input:         device_id - value of R1 on entry
  521.  *                access_key - value of R8 on entry
  522.  *
  523.  * Other notes:   Calls SWI 0x403C7 with R0 = 0x2.
  524.  */
  525.  
  526. extern os_error *xscsireserve_release (int device_id,
  527.       int access_key);
  528. extern void scsireserve_release (int device_id,
  529.       int access_key);
  530.  
  531. /* ------------------------------------------------------------------------
  532.  * Function:      scsi_list()
  533.  *
  534.  * Description:   Used by SCSILog as part of the multiple SCSI-card
  535.  *                initialisation sequence
  536.  *
  537.  * Input:         list - value of R0 on entry
  538.  *
  539.  * Other notes:   Calls SWI 0x403C8.
  540.  */
  541.  
  542. extern os_error *xscsi_list (scsi_card_address_list const *list);
  543. __swi (0x403C8) void scsi_list (scsi_card_address_list const *list);
  544.  
  545. #ifdef __cplusplus
  546.    }
  547. #endif
  548.  
  549. #endif
  550.