📄 ide-tape.c
字号:
* Speed regulation negative feedback loop */ int speed_control; int pipeline_head_speed; int controlled_pipeline_head_speed; int uncontrolled_pipeline_head_speed; int controlled_last_pipeline_head; int uncontrolled_last_pipeline_head; unsigned long uncontrolled_pipeline_head_time; unsigned long controlled_pipeline_head_time; int controlled_previous_pipeline_head; int uncontrolled_previous_pipeline_head; unsigned long controlled_previous_head_time; unsigned long uncontrolled_previous_head_time; int restart_speed_control_req; /* * Debug_level determines amount of debugging output; * can be changed using /proc/ide/hdx/settings * 0 : almost no debugging output * 1 : 0+output errors only * 2 : 1+output all sensekey/asc * 3 : 2+follow all chrdev related procedures * 4 : 3+follow all procedures * 5 : 4+include pc_stack rq_stack info * 6 : 5+USE_COUNT updates */ int debug_level; } idetape_tape_t;/* * Tape door status */#define DOOR_UNLOCKED 0#define DOOR_LOCKED 1#define DOOR_EXPLICITLY_LOCKED 2/* * Tape flag bits values. */#define IDETAPE_IGNORE_DSC 0#define IDETAPE_ADDRESS_VALID 1 /* 0 When the tape position is unknown */#define IDETAPE_BUSY 2 /* Device already opened */#define IDETAPE_PIPELINE_ERROR 3 /* Error detected in a pipeline stage */#define IDETAPE_DETECT_BS 4 /* Attempt to auto-detect the current user block size */#define IDETAPE_FILEMARK 5 /* Currently on a filemark */#define IDETAPE_DRQ_INTERRUPT 6 /* DRQ interrupt device */#define IDETAPE_READ_ERROR 7#define IDETAPE_PIPELINE_ACTIVE 8 /* pipeline active *//* * Supported ATAPI tape drives packet commands */#define IDETAPE_TEST_UNIT_READY_CMD 0x00#define IDETAPE_REWIND_CMD 0x01#define IDETAPE_REQUEST_SENSE_CMD 0x03#define IDETAPE_READ_CMD 0x08#define IDETAPE_WRITE_CMD 0x0a#define IDETAPE_WRITE_FILEMARK_CMD 0x10#define IDETAPE_SPACE_CMD 0x11#define IDETAPE_INQUIRY_CMD 0x12#define IDETAPE_ERASE_CMD 0x19#define IDETAPE_MODE_SENSE_CMD 0x1a#define IDETAPE_MODE_SELECT_CMD 0x15#define IDETAPE_LOAD_UNLOAD_CMD 0x1b#define IDETAPE_PREVENT_CMD 0x1e#define IDETAPE_LOCATE_CMD 0x2b#define IDETAPE_READ_POSITION_CMD 0x34#define IDETAPE_READ_BUFFER_CMD 0x3c#define IDETAPE_SET_SPEED_CMD 0xbb/* * Some defines for the READ BUFFER command */#define IDETAPE_RETRIEVE_FAULTY_BLOCK 6/* * Some defines for the SPACE command */#define IDETAPE_SPACE_OVER_FILEMARK 1#define IDETAPE_SPACE_TO_EOD 3/* * Some defines for the LOAD UNLOAD command */#define IDETAPE_LU_LOAD_MASK 1#define IDETAPE_LU_RETENSION_MASK 2#define IDETAPE_LU_EOT_MASK 4/* * Special requests for our block device strategy routine. * * In order to service a character device command, we add special * requests to the tail of our block device request queue and wait * for their completion. * */#define IDETAPE_FIRST_RQ 90/* * IDETAPE_PC_RQ is used to queue a packet command in the request queue. */#define IDETAPE_PC_RQ1 90#define IDETAPE_PC_RQ2 91/* * IDETAPE_READ_RQ and IDETAPE_WRITE_RQ are used by our * character device interface to request read/write operations from * our block device interface. */#define IDETAPE_READ_RQ 92#define IDETAPE_WRITE_RQ 93#define IDETAPE_ABORTED_WRITE_RQ 94#define IDETAPE_ABORTED_READ_RQ 95#define IDETAPE_READ_BUFFER_RQ 96#define IDETAPE_LAST_RQ 96/* * A macro which can be used to check if a we support a given * request command. */#define IDETAPE_RQ_CMD(cmd) ((cmd >= IDETAPE_FIRST_RQ) && (cmd <= IDETAPE_LAST_RQ))/* * Error codes which are returned in rq->errors to the higher part * of the driver. */#define IDETAPE_ERROR_GENERAL 101#define IDETAPE_ERROR_FILEMARK 102#define IDETAPE_ERROR_EOD 103/* * idetape_chrdev_t provides the link between out character device * interface and our block device interface and the corresponding * ide_drive_t structure. */typedef struct { ide_drive_t *drive;} idetape_chrdev_t;/* * The following is used to format the general configuration word of * the ATAPI IDENTIFY DEVICE command. */struct idetape_id_gcw { unsigned packet_size :2; /* Packet Size */ unsigned reserved234 :3; /* Reserved */ unsigned drq_type :2; /* Command packet DRQ type */ unsigned removable :1; /* Removable media */ unsigned device_type :5; /* Device type */ unsigned reserved13 :1; /* Reserved */ unsigned protocol :2; /* Protocol type */};/* * INQUIRY packet command - Data Format (From Table 6-8 of QIC-157C) */typedef struct { unsigned device_type :5; /* Peripheral Device Type */ unsigned reserved0_765 :3; /* Peripheral Qualifier - Reserved */ unsigned reserved1_6t0 :7; /* Reserved */ unsigned rmb :1; /* Removable Medium Bit */ unsigned ansi_version :3; /* ANSI Version */ unsigned ecma_version :3; /* ECMA Version */ unsigned iso_version :2; /* ISO Version */ unsigned response_format :4; /* Response Data Format */ unsigned reserved3_45 :2; /* Reserved */ unsigned reserved3_6 :1; /* TrmIOP - Reserved */ unsigned reserved3_7 :1; /* AENC - Reserved */ __u8 additional_length; /* Additional Length (total_length-4) */ __u8 rsv5, rsv6, rsv7; /* Reserved */ __u8 vendor_id[8]; /* Vendor Identification */ __u8 product_id[16]; /* Product Identification */ __u8 revision_level[4]; /* Revision Level */ __u8 vendor_specific[20]; /* Vendor Specific - Optional */ __u8 reserved56t95[40]; /* Reserved - Optional */ /* Additional information may be returned */} idetape_inquiry_result_t;/* * READ POSITION packet command - Data Format (From Table 6-57) */typedef struct { unsigned reserved0_10 :2; /* Reserved */ unsigned bpu :1; /* Block Position Unknown */ unsigned reserved0_543 :3; /* Reserved */ unsigned eop :1; /* End Of Partition */ unsigned bop :1; /* Beginning Of Partition */ u8 partition; /* Partition Number */ u8 reserved2, reserved3; /* Reserved */ u32 first_block; /* First Block Location */ u32 last_block; /* Last Block Location (Optional) */ u8 reserved12; /* Reserved */ u8 blocks_in_buffer[3]; /* Blocks In Buffer - (Optional) */ u32 bytes_in_buffer; /* Bytes In Buffer (Optional) */} idetape_read_position_result_t;/* * Follows structures which are related to the SELECT SENSE / MODE SENSE * packet commands. Those packet commands are still not supported * by ide-tape. */#define IDETAPE_BLOCK_DESCRIPTOR 0#define IDETAPE_CAPABILITIES_PAGE 0x2a#define IDETAPE_PARAMTR_PAGE 0x2b /* Onstream DI-x0 only */#define IDETAPE_BLOCK_SIZE_PAGE 0x30#define IDETAPE_BUFFER_FILLING_PAGE 0x33/* * Mode Parameter Header for the MODE SENSE packet command */typedef struct { __u8 mode_data_length; /* Length of the following data transfer */ __u8 medium_type; /* Medium Type */ __u8 dsp; /* Device Specific Parameter */ __u8 bdl; /* Block Descriptor Length */#if 0 /* data transfer page */ __u8 page_code :6; __u8 reserved0_6 :1; __u8 ps :1; /* parameters saveable */ __u8 page_length; /* page Length == 0x02 */ __u8 reserved2; __u8 read32k :1; /* 32k blk size (data only) */ __u8 read32k5 :1; /* 32.5k blk size (data&AUX) */ __u8 reserved3_23 :2; __u8 write32k :1; /* 32k blk size (data only) */ __u8 write32k5 :1; /* 32.5k blk size (data&AUX) */ __u8 reserved3_6 :1; __u8 streaming :1; /* streaming mode enable */#endif} idetape_mode_parameter_header_t;/* * Mode Parameter Block Descriptor the MODE SENSE packet command * * Support for block descriptors is optional. */typedef struct { __u8 density_code; /* Medium density code */ __u8 blocks[3]; /* Number of blocks */ __u8 reserved4; /* Reserved */ __u8 length[3]; /* Block Length */} idetape_parameter_block_descriptor_t;/* * The Data Compression Page, as returned by the MODE SENSE packet command. */typedef struct { unsigned page_code :6; /* Page Code - Should be 0xf */ unsigned reserved0 :1; /* Reserved */ unsigned ps :1; __u8 page_length; /* Page Length - Should be 14 */ unsigned reserved2 :6; /* Reserved */ unsigned dcc :1; /* Data Compression Capable */ unsigned dce :1; /* Data Compression Enable */ unsigned reserved3 :5; /* Reserved */ unsigned red :2; /* Report Exception on Decompression */ unsigned dde :1; /* Data Decompression Enable */ __u32 ca; /* Compression Algorithm */ __u32 da; /* Decompression Algorithm */ __u8 reserved[4]; /* Reserved */} idetape_data_compression_page_t;/* * The Medium Partition Page, as returned by the MODE SENSE packet command. */typedef struct { unsigned page_code :6; /* Page Code - Should be 0x11 */ unsigned reserved1_6 :1; /* Reserved */ unsigned ps :1; __u8 page_length; /* Page Length - Should be 6 */ __u8 map; /* Maximum Additional Partitions - Should be 0 */ __u8 apd; /* Additional Partitions Defined - Should be 0 */ unsigned reserved4_012 :3; /* Reserved */ unsigned psum :2; /* Should be 0 */ unsigned idp :1; /* Should be 0 */ unsigned sdp :1; /* Should be 0 */ unsigned fdp :1; /* Fixed Data Partitions */ __u8 mfr; /* Medium Format Recognition */ __u8 reserved[2]; /* Reserved */} idetape_medium_partition_page_t;/* * Run time configurable parameters. */typedef struct { int dsc_rw_frequency; int dsc_media_access_frequency; int nr_stages;} idetape_config_t;/* * The variables below are used for the character device interface. * Additional state variables are defined in our ide_drive_t structure. */static idetape_chrdev_t idetape_chrdevs[MAX_HWIFS * MAX_DRIVES];static int idetape_chrdev_present = 0;#if IDETAPE_DEBUG_LOG_VERBOSE/* * DO NOT REMOVE, BUILDING A VERBOSE DEBUG SCHEME FOR ATAPI */char *idetape_sense_key_verbose (u8 idetape_sense_key){ switch (idetape_sense_key) { default: { char buf[22]; sprintf(buf, "IDETAPE_SENSE (0x%02x)", idetape_sense_key); return(buf); } }}char *idetape_command_key_verbose (u8 idetape_command_key){ switch (idetape_command_key) { case IDETAPE_TEST_UNIT_READY_CMD: return("TEST_UNIT_READY_CMD"); case IDETAPE_REWIND_CMD: return("REWIND_CMD"); case IDETAPE_REQUEST_SENSE_CMD: return("REQUEST_SENSE_CMD"); case IDETAPE_READ_CMD: return("READ_CMD"); case IDETAPE_WRITE_CMD: return("WRITE_CMD"); case IDETAPE_WRITE_FILEMARK_CMD: return("WRITE_FILEMARK_CMD"); case IDETAPE_SPACE_CMD: return("SPACE_CMD"); case IDETAPE_INQUIRY_CMD: return("INQUIRY_CMD"); case IDETAPE_ERASE_CMD: return("ERASE_CMD"); case IDETAPE_MODE_SENSE_CMD: return("MODE_SENSE_CMD"); case IDETAPE_MODE_SELECT_CMD: return("MODE_SELECT_CMD"); case IDETAPE_LOAD_UNLOAD_CMD: return("LOAD_UNLOAD_CMD"); case IDETAPE_PREVENT_CMD: return("PREVENT_CMD"); case IDETAPE_LOCATE_CMD: return("LOCATE_CMD"); case IDETAPE_READ_POSITION_CMD: return("READ_POSITION_CMD"); case IDETAPE_READ_BUFFER_CMD: return("READ_BUFFER_CMD"); case IDETAPE_SET_SPEED_CMD: return("SET_SPEED_CMD"); default: { char buf[20]; sprintf(buf, "CMD (0x%02x)", idetape_command_key); return(buf); } }}#endif /* IDETAPE_DEBUG_LOG_VERBOSE *//* * Function declarations * */static void idetape_onstream_mode_sense_tape_parameter_page(ide_drive_t *drive, int debug);static int idetape_chrdev_release (struct inode *inode, struct file *filp);static void idetape_write_release (struct inode *inode);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -