📄 ide-tape.c
字号:
ide_startstop_t (*callback) (ide_drive_t *); /* Called when this packet command is completed */ u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE]; /* Temporary buffer */ unsigned long flags; /* Status/Action bit flags: long for set_bit */} idetape_pc_t;/* * Packet command flag bits. *//* Set when an error is considered normal - We won't retry */#define PC_ABORT 0/* 1 When polling for DSC on a media access command */#define PC_WAIT_FOR_DSC 1/* 1 when we prefer to use DMA if possible */#define PC_DMA_RECOMMENDED 2/* 1 while DMA in progress */#define PC_DMA_IN_PROGRESS 3/* 1 when encountered problem during DMA */#define PC_DMA_ERROR 4/* Data direction */#define PC_WRITING 5/* * Capabilities and Mechanical Status Page */typedef struct { unsigned page_code :6; /* Page code - Should be 0x2a */ __u8 reserved0_6 :1; __u8 ps :1; /* parameters saveable */ __u8 page_length; /* Page Length - Should be 0x12 */ __u8 reserved2, reserved3; unsigned ro :1; /* Read Only Mode */ unsigned reserved4_1234 :4; unsigned sprev :1; /* Supports SPACE in the reverse direction */ unsigned reserved4_67 :2; unsigned reserved5_012 :3; unsigned efmt :1; /* Supports ERASE command initiated formatting */ unsigned reserved5_4 :1; unsigned qfa :1; /* Supports the QFA two partition formats */ unsigned reserved5_67 :2; unsigned lock :1; /* Supports locking the volume */ unsigned locked :1; /* The volume is locked */ unsigned prevent :1; /* The device defaults in the prevent state after power up */ unsigned eject :1; /* The device can eject the volume */ __u8 disconnect :1; /* The device can break request > ctl */ __u8 reserved6_5 :1; unsigned ecc :1; /* Supports error correction */ unsigned cmprs :1; /* Supports data compression */ unsigned reserved7_0 :1; unsigned blk512 :1; /* Supports 512 bytes block size */ unsigned blk1024 :1; /* Supports 1024 bytes block size */ unsigned reserved7_3_6 :4; unsigned blk32768 :1; /* slowb - the device restricts the byte count for PIO */ /* transfers for slow buffer memory ??? */ /* Also 32768 block size in some cases */ __u16 max_speed; /* Maximum speed supported in KBps */ __u8 reserved10, reserved11; __u16 ctl; /* Continuous Transfer Limit in blocks */ __u16 speed; /* Current Speed, in KBps */ __u16 buffer_size; /* Buffer Size, in 512 bytes */ __u8 reserved18, reserved19;} idetape_capabilities_page_t;/* * Block Size Page */typedef struct { unsigned page_code :6; /* Page code - Should be 0x30 */ unsigned reserved1_6 :1; unsigned ps :1; __u8 page_length; /* Page Length - Should be 2 */ __u8 reserved2; unsigned play32 :1; unsigned play32_5 :1; unsigned reserved2_23 :2; unsigned record32 :1; unsigned record32_5 :1; unsigned reserved2_6 :1; unsigned one :1;} idetape_block_size_page_t;/* * A pipeline stage. */typedef struct idetape_stage_s { struct request rq; /* The corresponding request */ struct buffer_head *bh; /* The data buffers */ struct idetape_stage_s *next; /* Pointer to the next stage */ os_aux_t *aux; /* OnStream aux ptr */} idetape_stage_t;/* * REQUEST SENSE packet command result - Data Format. */typedef struct {#if defined(__LITTLE_ENDIAN_BITFIELD) unsigned error_code :7; /* Current of deferred errors */ unsigned valid :1; /* The information field conforms to QIC-157C */ __u8 reserved1 :8; /* Segment Number - Reserved */ unsigned sense_key :4; /* Sense Key */ unsigned reserved2_4 :1; /* Reserved */ unsigned ili :1; /* Incorrect Length Indicator */ unsigned eom :1; /* End Of Medium */ unsigned filemark :1; /* Filemark */#elif defined(__BIG_ENDIAN_BITFIELD) unsigned valid :1; unsigned error_code :7; __u8 reserved1 :8; unsigned filemark :1; unsigned eom :1; unsigned ili :1; unsigned reserved2_4 :1; unsigned sense_key :4;#else#error "Please fix <asm/byteorder.h>"#endif __u32 information __attribute__ ((packed)); __u8 asl; /* Additional sense length (n-7) */ __u32 command_specific; /* Additional command specific information */ __u8 asc; /* Additional Sense Code */ __u8 ascq; /* Additional Sense Code Qualifier */ __u8 replaceable_unit_code; /* Field Replaceable Unit Code */ unsigned sk_specific1 :7; /* Sense Key Specific */ unsigned sksv :1; /* Sense Key Specific information is valid */ __u8 sk_specific2; /* Sense Key Specific */ __u8 sk_specific3; /* Sense Key Specific */ __u8 pad[2]; /* Padding to 20 bytes */} idetape_request_sense_result_t;/* * Most of our global data which we need to save even as we leave the * driver due to an interrupt or a timer event is stored in a variable * of type idetape_tape_t, defined below. */typedef struct { ide_drive_t *drive; devfs_handle_t de_r, de_n; /* * Since a typical character device operation requires more * than one packet command, we provide here enough memory * for the maximum of interconnected packet commands. * The packet commands are stored in the circular array pc_stack. * pc_stack_index points to the last used entry, and warps around * to the start when we get to the last array entry. * * pc points to the current processed packet command. * * failed_pc points to the last failed packet command, or contains * NULL if we do not need to retry any packet command. This is * required since an additional packet command is needed before the * retry, to get detailed information on what went wrong. */ /* Current packet command */ idetape_pc_t *pc; /* Last failed packet command */ idetape_pc_t *failed_pc; /* Packet command stack */ idetape_pc_t pc_stack[IDETAPE_PC_STACK]; /* Next free packet command storage space */ int pc_stack_index; struct request rq_stack[IDETAPE_PC_STACK]; /* We implement a circular array */ int rq_stack_index; /* * DSC polling variables. * * While polling for DSC we use postponed_rq to postpone the * current request so that ide.c will be able to service * pending requests on the other device. Note that at most * we will have only one DSC (usually data transfer) request * in the device request queue. Additional requests can be * queued in our internal pipeline, but they will be visible * to ide.c only one at a time. */ struct request *postponed_rq; /* The time in which we started polling for DSC */ unsigned long dsc_polling_start; /* Timer used to poll for dsc */ struct timer_list dsc_timer; /* Read/Write dsc polling frequency */ unsigned long best_dsc_rw_frequency; /* The current polling frequency */ unsigned long dsc_polling_frequency; /* Maximum waiting time */ unsigned long dsc_timeout; /* * Read position information */ u8 partition; /* Current block */ unsigned int first_frame_position; unsigned int last_frame_position; unsigned int blocks_in_buffer; /* * Last error information */ u8 sense_key, asc, ascq; /* * Character device operation */ unsigned int minor; /* device name */ char name[4]; /* Current character device data transfer direction */ idetape_chrdev_direction_t chrdev_direction; /* * Device information */ /* Usually 512 or 1024 bytes */ unsigned short tape_block_size; int user_bs_factor; /* Copy of the tape's Capabilities and Mechanical Page */ idetape_capabilities_page_t capabilities; /* * Active data transfer request parameters. * * At most, there is only one ide-tape originated data transfer * request in the device request queue. This allows ide.c to * easily service requests from the other device when we * postpone our active request. In the pipelined operation * mode, we use our internal pipeline structure to hold * more data requests. * * The data buffer size is chosen based on the tape's * recommendation. */ /* Pointer to the request, waiting in the device request queue */ struct request *active_data_request; /* Data buffer size (chosen based on the tape's recommendation */ int stage_size; idetape_stage_t *merge_stage; int merge_stage_size; struct buffer_head *bh; char *b_data; int b_count; /* * Pipeline parameters. * * To accomplish non-pipelined mode, we simply set the following * variables to zero (or NULL, where appropriate). */ /* Number of currently used stages */ int nr_stages; /* Number of pending stages */ int nr_pending_stages; /* We will not allocate more than this number of stages */ int max_stages, min_pipeline, max_pipeline; /* The first stage which will be removed from the pipeline */ idetape_stage_t *first_stage; /* The currently active stage */ idetape_stage_t *active_stage; /* Will be serviced after the currently active request */ idetape_stage_t *next_stage; /* New requests will be added to the pipeline here */ idetape_stage_t *last_stage; /* Optional free stage which we can use */ idetape_stage_t *cache_stage; int pages_per_stage; /* Wasted space in each stage */ int excess_bh_size; /* Status/Action flags: long for set_bit */ unsigned long flags; /* protects the ide-tape queue */ spinlock_t spinlock; /* * Measures average tape speed */ unsigned long avg_time; int avg_size; int avg_speed; /* last sense information */ idetape_request_sense_result_t sense; char vendor_id[10]; char product_id[18]; char firmware_revision[6]; int firmware_revision_num; /* the door is currently locked */ int door_locked; /* * OnStream flags */ /* the tape is an OnStream tape */ int onstream; /* OnStream raw access (32.5KB block size) */ int raw; /* current number of frames in internal buffer */ int cur_frames; /* max number of frames in internal buffer */ int max_frames; /* logical block number */ int logical_blk_num; /* write pass counter */ __u16 wrt_pass_cntr; /* update frame counter */ __u32 update_frame_cntr; struct completion *waiting; /* write error recovery active */ int onstream_write_error; /* header frame verified ok */ int header_ok; /* reading linux-specifc media */ int linux_media; int linux_media_version; /* application signature */ char application_sig[5]; int filemark_cnt; int first_mark_addr; int last_mark_addr; int eod_frame_addr; unsigned long cmd_start_time; unsigned long max_cmd_time; unsigned capacity; /* * Optimize the number of "buffer filling" * mode sense commands. */ /* last time in which we issued fill cmd */ unsigned long last_buffer_fill; /* buffer fill command requested */ int req_buffer_fill; int writes_since_buffer_fill; int reads_since_buffer_fill; /* * Limit the number of times a request can * be postponed, to avoid an infinite postpone * deadlock. */ /* request postpone count limit */ int postpone_cnt; /* * Measures number of frames: * * 1. written/read to/from the driver pipeline (pipeline_head). * 2. written/read to/from the tape buffers (buffer_head). * 3. written/read by the tape to/from the media (tape_head). */ int pipeline_head; int buffer_head; int tape_head; int last_tape_head; /* * Speed control at the tape buffers input/output */ unsigned long insert_time; int insert_size; int insert_speed; int max_insert_speed; int measure_insert_time; /* * Measure tape still time, in milliseconds */ unsigned long tape_still_time_begin; int tape_still_time; /*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -