1 /* 2 ** Copyright 2002, Thomas Kurschel. All rights reserved. 3 ** Distributed under the terms of the OpenBeOS License. 4 */ 5 6 #ifndef __SCSI_PERIPH_INT_H__ 7 #define __SCSI_PERIPH_INT_H__ 8 9 #include <stddef.h> 10 #include <bus/scsi/scsi_periph.h> 11 #include <blkman.h> 12 #include <device_manager.h> 13 #include "wrapper.h" 14 15 16 typedef struct scsi_periph_device_info { 17 struct scsi_periph_handle_info *handles; 18 19 scsi_device scsi_device; 20 scsi_device_interface *scsi; 21 periph_device_cookie periph_device; 22 pnp_node_handle node; 23 24 bool removal_requested; 25 26 bool removable; // true, if device is removable 27 28 int32 rw10_enabled; // 10 byte r/w commands supported; access must be atomic 29 int32 next_tag_action; // queuing flag for next r/w command; access must be atomic 30 31 benaphore mutex; 32 int std_timeout; 33 34 scsi_periph_callbacks *callbacks; 35 } scsi_periph_device_info; 36 37 typedef struct scsi_periph_handle_info { 38 scsi_periph_device_info *device; 39 struct scsi_periph_handle_info *next, *prev; 40 41 int pending_error; // error to be reported on all accesses 42 // (used to block access after medium change until 43 // B_GET_MEDIA_STATUS is called) 44 periph_handle_cookie periph_handle; 45 } scsi_periph_handle_info; 46 47 extern device_manager_info *pnp; 48 49 50 // removable.c 51 52 void periph_media_changed(scsi_periph_device_info *device, scsi_ccb *ccb); 53 void periph_media_changed_public(scsi_periph_device_info *device); 54 status_t periph_get_media_status(scsi_periph_handle_info *handle); 55 err_res periph_send_start_stop(scsi_periph_device_info *device, scsi_ccb *request, 56 bool start, bool with_LoEj); 57 58 59 // error_handling.c 60 61 err_res periph_check_error(scsi_periph_device_info *device, scsi_ccb *request); 62 63 64 // handle.c 65 66 status_t periph_handle_open(scsi_periph_device_info *device, periph_handle_cookie periph_handle, 67 scsi_periph_handle_info **res_handle); 68 status_t periph_handle_close(scsi_periph_handle_info *handle); 69 status_t periph_handle_free(scsi_periph_handle_info *handle); 70 71 72 // block.c 73 74 status_t periph_check_capacity(scsi_periph_device_info *device, scsi_ccb *ccb); 75 76 77 // device.c 78 79 status_t periph_register_device(periph_device_cookie periph_device, 80 scsi_periph_callbacks *callbacks, scsi_device scsi_device, scsi_device_interface *scsi, 81 pnp_node_handle node, bool removable, scsi_periph_device *driver); 82 status_t periph_unregister_device(scsi_periph_device_info *driver); 83 char *periph_compose_device_name(pnp_node_handle device_node, const char *prefix); 84 85 86 // io.c 87 88 status_t periph_read(scsi_periph_handle_info *handle, const phys_vecs *vecs, 89 off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred, 90 int preferred_ccb_size); 91 status_t periph_write(scsi_periph_handle_info *handle, const phys_vecs *vecs, 92 off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred, 93 int preferred_ccb_size); 94 status_t periph_ioctl(scsi_periph_handle_info *handle, int op, 95 void *buf, size_t len); 96 void periph_sync_queue_daemon(void *arg, int iteration); 97 98 99 // scsi_periph.c 100 101 status_t periph_safe_exec(scsi_periph_device_info *device, scsi_ccb *request); 102 status_t periph_simple_exec(scsi_periph_device_info *device, void *cdb, 103 uchar cdb_len, void *data, size_t data_len, int ccb_flags); 104 105 106 // device_icons.c 107 108 status_t periph_get_icon(icon_type type, device_icon *data); 109 110 #endif 111