📄 ide-cd.h
字号:
#ifndef _IDE_CD_H#define _IDE_CD_H/* * linux/drivers/block/ide_modes.h * * Copyright (C) 1996 Erik Andersen * Copyright (C) 1998, 1999 Jens Axboe */#include <asm/byteorder.h>/* Turn this on to have the driver print out the meanings of the ATAPI error codes. This will use up additional kernel-space memory, though. */#ifndef VERBOSE_IDE_CD_ERRORS#define VERBOSE_IDE_CD_ERRORS 1#endif/* Turning this on will remove code to work around various nonstandard ATAPI implementations. If you know your drive follows the standard, this will give you a slightly smaller kernel. */#ifndef STANDARD_ATAPI#define STANDARD_ATAPI 0#endif/* Turning this on will disable the door-locking functionality. This is apparently needed for supermount. */#ifndef NO_DOOR_LOCKING#define NO_DOOR_LOCKING 0#endif/* Size of buffer to allocate, in blocks, for audio reads. */#ifndef CDROM_NBLOCKS_BUFFER#define CDROM_NBLOCKS_BUFFER 8#endif/************************************************************************/#define SECTOR_SIZE 512#define SECTOR_BITS 9#define SECTORS_PER_FRAME (CD_FRAMESIZE / SECTOR_SIZE)#define MIN(a,b) ((a) < (b) ? (a) : (b))/* special command codes for strategy routine. */#define PACKET_COMMAND 4315#define REQUEST_SENSE_COMMAND 4316#define RESET_DRIVE_COMMAND 4317/* * For controlling drive spindown time. */#define CDROMGETSPINDOWN 0x531d#define CDROMSETSPINDOWN 0x531e /* Some ATAPI command opcodes (just like SCSI). (Some other cdrom-specific codes are in cdrom.h.) */#define TEST_UNIT_READY 0x00#define REQUEST_SENSE 0x03#define INQUIRY 0x12#define START_STOP 0x1b#define ALLOW_MEDIUM_REMOVAL 0x1e#define READ_CAPACITY 0x25#define READ_10 0x28#define SEEK 0x2b#define READ_HEADER 0x44#define STOP_PLAY_SCAN 0x4e#define MODE_SELECT_10 0x55#define MODE_SENSE_10 0x5a#define LOAD_UNLOAD 0xa6#define READ_12 0xa8#define READ_CD_MSF 0xb9#define SCAN 0xba#define SET_CD_SPEED 0xbb#define PLAY_CD 0xbc#define MECHANISM_STATUS 0xbd#define READ_CD 0xbe/* DVD Opcodes */#define DVD_GET_PERFORMANCE 0xac/* Page codes for mode sense/set */#define PAGE_READERR 0x01#define PAGE_CDROM 0x0d#define PAGE_AUDIO 0x0e#define PAGE_CAPABILITIES 0x2a#define PAGE_ALL 0x3f/* ATAPI sense keys (from table 140 of ATAPI 2.6) */#define NO_SENSE 0x00#define RECOVERED_ERROR 0x01#define NOT_READY 0x02#define MEDIUM_ERROR 0x03#define HARDWARE_ERROR 0x04#define ILLEGAL_REQUEST 0x05#define UNIT_ATTENTION 0x06#define DATA_PROTECT 0x07#define ABORTED_COMMAND 0x0b#define MISCOMPARE 0x0e/* We want some additional flags for CDROM drives. To save space in the ide_drive_t struct, use some fields which doesn't make sense for CDROMs -- `bios_cyl' and `bios_head'. *//* Configuration flags. These describe the capabilities of the drive. They generally do not change after initialization, unless we learn more about the drive from stuff failing. */struct ide_cd_config_flags { __u8 drq_interrupt : 1; /* Device sends an interrupt when ready for a packet command. */ __u8 no_doorlock : 1; /* Drive cannot lock the door. */ __u8 no_eject : 1; /* Drive cannot eject the disc. */ __u8 nec260 : 1; /* Drive is a pre-1.2 NEC 260 drive. */ __u8 playmsf_as_bcd : 1; /* PLAYMSF command takes BCD args. */ __u8 tocaddr_as_bcd : 1; /* TOC addresses are in BCD. */ __u8 toctracks_as_bcd : 1; /* TOC track numbers are in BCD. */ __u8 subchan_as_bcd : 1; /* Subchannel info is in BCD. */ __u8 is_changer : 1; /* Drive is a changer. */ __u8 cd_r : 1; /* Drive can write to CD-R media . */ __u8 cd_rw : 1; /* Drive can write to CD-R/W media . */ __u8 dvd : 1; /* Drive is a DVD-ROM */ __u8 dvd_r : 1; /* Drive can write DVD-RAM */ __u8 dvd_rw : 1; /* Drive can write DVD-R/W */ __u8 test_write : 1; /* Drive can fake writes */ __u8 supp_disc_present: 1; /* Changer can report exact contents of slots. */ __u8 limit_nframes : 1; /* Drive does not provide data in multiples of SECTOR_SIZE when more than one interrupt is needed. */ __u8 seeking : 1; /* Seeking in progress */ __u8 reserved : 6; byte max_speed; /* Max speed of the drive */};#define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags)) /* State flags. These give information about the current state of the drive, and will change during normal operation. */struct ide_cd_state_flags { __u8 media_changed : 1; /* Driver has noticed a media change. */ __u8 toc_valid : 1; /* Saved TOC information is current. */ __u8 door_locked : 1; /* We think that the drive door is locked. */ __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */ __u8 reserved : 3; byte current_speed; /* Current speed of the drive */};#define CDROM_STATE_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->state_flags))struct atapi_request_sense {#if defined(__BIG_ENDIAN_BITFIELD) unsigned char valid : 1; unsigned char error_code : 7;#elif defined(__LITTLE_ENDIAN_BITFIELD) unsigned char error_code : 7; unsigned char valid : 1;#else#error "Please fix <asm/byteorder.h>"#endif byte reserved1;#if defined(__BIG_ENDIAN_BITFIELD) unsigned char reserved3 : 2; unsigned char ili : 1; unsigned char reserved2 : 1; unsigned char sense_key : 4;#elif defined(__LITTLE_ENDIAN_BITFIELD) unsigned char sense_key : 4; unsigned char reserved2 : 1; unsigned char ili : 1; unsigned char reserved3 : 2;#else#error "Please fix <asm/byteorder.h>"#endif byte info[4]; byte sense_len; byte command_info[4]; byte asc; byte ascq; byte fru; byte sense_key_specific[3];};struct packet_command { char *buffer; int buflen; int stat; struct atapi_request_sense *sense_data; unsigned char c[12];};/* Structure of a MSF cdrom address. */struct atapi_msf { byte reserved; byte minute; byte second; byte frame;};/* Space to hold the disk TOC. */#define MAX_TRACKS 99struct atapi_toc_header { unsigned short toc_length; byte first_track; byte last_track;};struct atapi_toc_entry { byte reserved1;#if defined(__BIG_ENDIAN_BITFIELD) __u8 adr : 4; __u8 control : 4;#elif defined(__LITTLE_ENDIAN_BITFIELD) __u8 control : 4; __u8 adr : 4;#else#error "Please fix <asm/byteorder.h>"#endif byte track; byte reserved2; union { unsigned lba; struct atapi_msf msf; } addr;};struct atapi_toc { int last_session_lba; int xa_flag; unsigned capacity; struct atapi_toc_header hdr; struct atapi_toc_entry ent[MAX_TRACKS+1]; /* One extra for the leadout. */};/* This structure is annoyingly close to, but not identical with, the cdrom_subchnl structure from cdrom.h. */struct atapi_cdrom_subchnl { u_char acdsc_reserved; u_char acdsc_audiostatus; u_short acdsc_length; u_char acdsc_format;#if defined(__BIG_ENDIAN_BITFIELD) u_char acdsc_ctrl: 4; u_char acdsc_adr: 4;#elif defined(__LITTLE_ENDIAN_BITFIELD) u_char acdsc_adr: 4; u_char acdsc_ctrl: 4;#else#error "Please fix <asm/byteorder.h>"#endif u_char acdsc_trk; u_char acdsc_ind; union { struct atapi_msf msf; int lba; } acdsc_absaddr; union { struct atapi_msf msf; int lba; } acdsc_reladdr;};typedef enum { mechtype_caddy = 0, mechtype_tray = 1, mechtype_popup = 2, mechtype_individual_changer = 4, mechtype_cartridge_changer = 5} mechtype_t;struct atapi_capabilities_page {#if defined(__BIG_ENDIAN_BITFIELD) __u8 parameters_saveable : 1; __u8 reserved1 : 1; __u8 page_code : 6;#elif defined(__LITTLE_ENDIAN_BITFIELD) __u8 page_code : 6; __u8 reserved1 : 1; __u8 parameters_saveable : 1;#else#error "Please fix <asm/byteorder.h>"#endif byte page_length;#if defined(__BIG_ENDIAN_BITFIELD) __u8 reserved2 : 2; /* Drive supports reading of DVD-RAM discs */ __u8 dvd_ram_read : 1; /* Drive supports reading of DVD-R discs */ __u8 dvd_r_read : 1; /* Drive supports reading of DVD-ROM discs */ __u8 dvd_rom : 1; /* Drive supports reading CD-R discs with addressing method 2 */ __u8 method2 : 1; /* reserved in 1.2 */ /* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */ __u8 cd_rw_read : 1; /* reserved in 1.2 */ /* Drive supports read from CD-R discs (orange book, part II) */ __u8 cd_r_read : 1; /* reserved in 1.2 */#elif defined(__LITTLE_ENDIAN_BITFIELD) /* Drive supports read from CD-R discs (orange book, part II) */ __u8 cd_r_read : 1; /* reserved in 1.2 */ /* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */ __u8 cd_rw_read : 1; /* reserved in 1.2 */ /* Drive supports reading CD-R discs with addressing method 2 */ __u8 method2 : 1; /* Drive supports reading of DVD-ROM discs */ __u8 dvd_rom : 1; /* Drive supports reading of DVD-R discs */ __u8 dvd_r_read : 1; /* Drive supports reading of DVD-RAM discs */ __u8 dvd_ram_read : 1; __u8 reserved2 : 2;#else#error "Please fix <asm/byteorder.h>"#endif#if defined(__BIG_ENDIAN_BITFIELD) __u8 reserved3 : 2; /* Drive can write DVD-RAM discs */ __u8 dvd_ram_write : 1; /* Drive can write DVD-R discs */ __u8 dvd_r_write : 1; __u8 reserved3a : 1; /* Drive can fake writes */ __u8 test_write : 1; /* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */ __u8 cd_rw_write : 1; /* reserved in 1.2 */ /* Drive supports write to CD-R discs (orange book, part II) */ __u8 cd_r_write : 1; /* reserved in 1.2 */#elif defined(__LITTLE_ENDIAN_BITFIELD) /* Drive can write to CD-R discs (orange book, part II) */ __u8 cd_r_write : 1; /* reserved in 1.2 */ /* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */ __u8 cd_rw_write : 1; /* reserved in 1.2 */ /* Drive can fake writes */ __u8 test_write : 1; __u8 reserved3a : 1; /* Drive can write DVD-R discs */ __u8 dvd_r_write : 1; /* Drive can write DVD-RAM discs */ __u8 dvd_ram_write : 1; __u8 reserved3 : 2;#else#error "Please fix <asm/byteorder.h>"#endif#if defined(__BIG_ENDIAN_BITFIELD) __u8 reserved4 : 1; /* Drive can read multisession discs. */ __u8 multisession : 1; /* Drive can read mode 2, form 2 data. */ __u8 mode2_form2 : 1; /* Drive can read mode 2, form 1 (XA) data. */ __u8 mode2_form1 : 1; /* Drive supports digital output on port 2. */ __u8 digport2 : 1; /* Drive supports digital output on port 1. */ __u8 digport1 : 1; /* Drive can deliver a composite audio/video data stream. */ __u8 composite : 1; /* Drive supports audio play operations. */ __u8 audio_play : 1;#elif defined(__LITTLE_ENDIAN_BITFIELD) /* Drive supports audio play operations. */ __u8 audio_play : 1; /* Drive can deliver a composite audio/video data stream. */ __u8 composite : 1; /* Drive supports digital output on port 1. */ __u8 digport1 : 1; /* Drive supports digital output on port 2. */ __u8 digport2 : 1; /* Drive can read mode 2, form 1 (XA) data. */ __u8 mode2_form1 : 1; /* Drive can read mode 2, form 2 data. */ __u8 mode2_form2 : 1; /* Drive can read multisession discs. */ __u8 multisession : 1; __u8 reserved4 : 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -