⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ide-tape.c

📁 Linux环境下java编程的经典书籍
💻 C
📖 第 1 页 / 共 5 页
字号:
#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/* *	The ATAPI Status Register. */typedef union {	unsigned all			:8;	struct {		unsigned check		:1;	/* Error occurred */		unsigned idx		:1;	/* Reserved */		unsigned corr		:1;	/* Correctable error occurred */		unsigned drq		:1;	/* Data is request by the device */		unsigned dsc		:1;	/* Buffer availability / Media access command finished */		unsigned reserved5	:1;	/* Reserved */		unsigned drdy		:1;	/* Ignored for ATAPI commands (ready to accept ATA command) */		unsigned bsy		:1;	/* The device has access to the command block */	} b;} idetape_status_reg_t;/* *	The ATAPI error register. */typedef union {	unsigned all			:8;	struct {		unsigned ili		:1;	/* Illegal Length Indication */		unsigned eom		:1;	/* End Of Media Detected */		unsigned abrt		:1;	/* Aborted command - As defined by ATA */		unsigned mcr		:1;	/* Media Change Requested - As defined by ATA */		unsigned sense_key	:4;	/* Sense key of the last failed packet command */	} b;} idetape_error_reg_t;/* *	ATAPI Feature Register */typedef union {	unsigned all			:8;	struct {		unsigned dma		:1;	/* Using DMA or PIO */		unsigned reserved321	:3;	/* Reserved */		unsigned reserved654	:3;	/* Reserved (Tag Type) */		unsigned reserved7	:1;	/* Reserved */	} b;} idetape_feature_reg_t;/* *	ATAPI Byte Count Register. */typedef union {	unsigned all			:16;	struct {		unsigned low		:8;	/* LSB */		unsigned high		:8;	/* MSB */	} b;} idetape_bcount_reg_t;/* *	ATAPI Interrupt Reason Register. */typedef union {	unsigned all			:8;	struct {		unsigned cod		:1;	/* Information transferred is command (1) or data (0) */		unsigned io		:1;	/* The device requests us to read (1) or write (0) */		unsigned reserved	:6;	/* Reserved */	} b;} idetape_ireason_reg_t;/* *	ATAPI Drive Select Register */typedef union {		unsigned all			:8;	struct {		unsigned sam_lun	:4;	/* Should be zero with ATAPI (not used) */		unsigned drv		:1;	/* The responding drive will be drive 0 (0) or drive 1 (1) */		unsigned one5		:1;	/* Should be set to 1 */		unsigned reserved6	:1;	/* Reserved */		unsigned one7		:1;	/* Should be set to 1 */	} b;} idetape_drivesel_reg_t;/* *	ATAPI Device Control Register */typedef union {				unsigned all			:8;	struct {		unsigned zero0		:1;	/* Should be set to zero */		unsigned nien		:1;	/* Device interrupt is disabled (1) or enabled (0) */		unsigned srst		:1;	/* ATA software reset. ATAPI devices should use the new ATAPI srst. */		unsigned one3		:1;	/* Should be set to 1 */		unsigned reserved4567	:4;	/* Reserved */	} b;} idetape_control_reg_t;/* *	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 (byte 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 (byte idetape_command_key){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -