Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ide-cd.c File Reference

#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/timer.h>
#include <linux/malloc.h>
#include <linux/interrupt.h>
#include <linux/errno.h>
#include <linux/cdrom.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/byteorder.h>
#include <asm/uaccess.h>
#include <asm/unaligned.h>
#include "ide.h"
#include "ide-cd.h"

Include dependency graph for ide-cd.c:

Go to the source code of this file.

Defines

#define IDECD_VERSION   "4.58"
#define IDECD_SEEK_THRESHOLD   (1000)
#define IDECD_SEEK_TIMER   (5 * WAIT_MIN_SLEEP)
#define IDECD_SEEK_TIMEOUT   WAIT_CMD

Functions

static void cdrom_saw_media_change (ide_drive_t *drive)
static int cdrom_log_sense (ide_drive_t *drive, struct packet_command *pc, struct request_sense *sense)
static void cdrom_analyze_sense_data (ide_drive_t *drive, struct packet_command *failed_command, struct request_sense *sense)
static void cdrom_queue_request_sense (ide_drive_t *drive, struct semaphore *sem, struct request_sense *sense, struct packet_command *failed_command)
static void cdrom_end_request (int uptodate, ide_drive_t *drive)
static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive, int good_stat, int *stat_ret)
static int cdrom_timer_expiry (ide_drive_t *drive)
static ide_startstop_t cdrom_start_packet_command (ide_drive_t *drive, int xferlen, ide_handler_t *handler)
static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, unsigned char *cmd_buf, int cmd_len, ide_handler_t *handler)
static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector, int sectors_to_transfer)
static int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
static int cdrom_read_from_buffer (ide_drive_t *drive)
static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive)
static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive)
static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
static void restore_request (struct request *rq)
static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block)
static int cdrom_lockdoor (ide_drive_t *drive, int lockflag, struct request_sense *sense)
static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive)
static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
static void cdrom_sleep (int time)
static int cdrom_queue_packet_command (ide_drive_t *drive, struct packet_command *pc)
static ide_startstop_t ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, unsigned long block)
static int bin2bcd (int x)
static int bcd2bin (int x)
static void msf_from_bcd (struct atapi_msf *msf)
static void lba_to_msf (int lba, byte *m, byte *s, byte *f)
static int msf_to_lba (byte m, byte s, byte f)
static int cdrom_check_status (ide_drive_t *drive, struct request_sense *sense)
static int cdrom_eject (ide_drive_t *drive, int ejectflag, struct request_sense *sense)
static int cdrom_read_capacity (ide_drive_t *drive, unsigned *capacity, struct request_sense *sense)
static int cdrom_read_tocentry (ide_drive_t *drive, int trackno, int msf_flag, int format, char *buf, int buflen, struct request_sense *sense)
static int cdrom_read_toc (ide_drive_t *drive, struct request_sense *sense)
static int cdrom_read_subchannel (ide_drive_t *drive, int format, char *buf, int buflen, struct request_sense *sense)
static int cdrom_select_speed (ide_drive_t *drive, int speed, struct request_sense *sense)
static int cdrom_play_audio (ide_drive_t *drive, int lba_start, int lba_end)
static int cdrom_get_toc_entry (ide_drive_t *drive, int track, struct atapi_toc_entry **ent)
static int ide_cdrom_packet (struct cdrom_device_info *cdi, struct cdrom_generic_command *cgc)
static int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi, unsigned int cmd, unsigned long arg)
static int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
static int ide_cdrom_reset (struct cdrom_device_info *cdi)
static int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position)
static int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock)
static int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed)
static int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr)
static int ide_cdrom_get_last_session (struct cdrom_device_info *cdi, struct cdrom_multisession *ms_info)
static int ide_cdrom_get_mcn (struct cdrom_device_info *cdi, struct cdrom_mcn *mcn_info)
static int ide_cdrom_check_media_change_real (struct cdrom_device_info *cdi, int slot_nr)
static int ide_cdrom_open_real (struct cdrom_device_info *cdi, int purpose)
static void ide_cdrom_release_real (struct cdrom_device_info *cdi)
static int ide_cdrom_register (ide_drive_t *drive, int nslots)
static int ide_cdrom_get_capabilities (ide_drive_t *drive, struct atapi_capabilities_page *cap)
static int ide_cdrom_probe_capabilities (ide_drive_t *drive)
static void ide_cdrom_add_settings (ide_drive_t *drive)
static int ide_cdrom_setup (ide_drive_t *drive)
static int ide_cdrom_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
static int ide_cdrom_open (struct inode *ip, struct file *fp, ide_drive_t *drive)
static void ide_cdrom_release (struct inode *inode, struct file *file, ide_drive_t *drive)
static int ide_cdrom_check_media_change (ide_drive_t *drive)
static unsigned long ide_cdrom_capacity (ide_drive_t *drive)
static int ide_cdrom_cleanup (ide_drive_t *drive)
int ide_cdrom_init (void)

Variables

static struct cdrom_device_ops ide_cdrom_dops
static ide_driver_t ide_cdrom_driver
static ide_module_t ide_cdrom_module
char * ignore = NULL


Define Documentation

#define IDECD_SEEK_THRESHOLD   (1000)
 

Definition at line 1100 of file ide-cd.c.

Referenced by ide_do_rw_cdrom().

#define IDECD_SEEK_TIMEOUT   WAIT_CMD
 

Definition at line 1102 of file ide-cd.c.

Referenced by ide_do_rw_cdrom().

#define IDECD_SEEK_TIMER   (5 * WAIT_MIN_SLEEP)
 

Definition at line 1101 of file ide-cd.c.

Referenced by cdrom_seek_intr(), and ide_do_rw_cdrom().

#define IDECD_VERSION   "4.58"
 

Definition at line 290 of file ide-cd.c.


Function Documentation

static int bcd2bin int  x  )  [inline, static]
 

Definition at line 1474 of file ide-cd.c.

static int bin2bcd int  x  )  [inline, static]
 

Definition at line 1467 of file ide-cd.c.

static void cdrom_analyze_sense_data ide_drive_t drive,
struct packet_command failed_command,
struct request_sense sense
[static]
 

Definition at line 364 of file ide-cd.c.

References ARY_LEN, request_sense::asc, asc_ascq, request_sense::ascq, buf, c, packet_command::c, cdrom_log_sense(), hi, i, ILLEGAL_REQUEST, lo, ide_drive_s::name, NOT_READY, NULL, packet_command_texts, printk, s, sense_data_texts, sense_key_texts, request_sense::sks, sprintf(), UNIT_ATTENTION, x07, x40, x70, x7f, x80, and xffff.

Referenced by cdrom_end_request().

Here is the call graph for this function:

static void cdrom_buffer_sectors ide_drive_t drive,
unsigned long  sector,
int  sectors_to_transfer
[static]
 

Definition at line 772 of file ide-cd.c.

References atapi_input_bytes(), cdrom_info::buffer, dest, ide_drive_s::driver_data, MIN, cdrom_info::nsectors_buffered, NULL, SECTOR_BITS, SECTOR_BUFFER_SIZE, cdrom_info::sector_buffered, and SECTOR_SIZE.

Referenced by cdrom_read_intr().

Here is the call graph for this function:

static int cdrom_check_status ide_drive_t drive,
struct request_sense sense
[static]
 

Definition at line 1508 of file ide-cd.c.

References cdrom_queue_packet_command(), cdrom_info::devinfo, GPCMD_TEST_UNIT_READY, and memset.

Referenced by cdrom_read_toc(), ide_cdrom_check_media_change_real(), and ide_cdrom_drive_status().

Here is the call graph for this function:

static int cdrom_decode_status ide_startstop_t startstop,
ide_drive_t drive,
int  good_stat,
int *  stat_ret
[static]
 

Definition at line 545 of file ide-cd.c.

References ABRT_ERR, BAD_R_STAT, request::buffer, cdrom_end_request(), cdrom_queue_request_sense(), cdrom_saw_media_change(), request::cmd, DATA_PROTECT, ERR_STAT, ERROR_MAX, request::errors, GET_ERR, GET_STAT, HWGROUP, ide_dump_status(), ide_error(), ide_stopped, ILLEGAL_REQUEST, ide_drive_s::name, NOT_READY, NULL, OK_STAT, PACKET_COMMAND, pc, printk, REQUEST_SENSE_COMMAND, request::sem, packet_command::sense, packet_command::stat, and UNIT_ATTENTION.

Referenced by cdrom_pc_intr(), cdrom_read_intr(), cdrom_seek_intr(), and cdrom_transfer_packet_command().

Here is the call graph for this function:

static ide_startstop_t cdrom_do_packet_command ide_drive_t drive  )  [static]
 

Definition at line 1326 of file ide-cd.c.

References request::buffer, packet_command::buflen, cdrom_do_pc_continuation(), cdrom_start_packet_command(), cdrom_info::dma, ide_drive_s::driver_data, HWGROUP, len, pc, and packet_command::stat.

Referenced by ide_do_rw_cdrom().

Here is the call graph for this function:

static ide_startstop_t cdrom_do_pc_continuation ide_drive_t drive  )  [static]
 

Definition at line 1315 of file ide-cd.c.

References request::buffer, packet_command::c, cdrom_pc_intr(), cdrom_transfer_packet_command(), HWGROUP, and pc.

Referenced by cdrom_do_packet_command().

Here is the call graph for this function:

static int cdrom_eject ide_drive_t drive,
int  ejectflag,
struct request_sense sense
[static]
 

Definition at line 1576 of file ide-cd.c.

References CDROM_CONFIG_FLAGS, cdrom_queue_packet_command(), CDROM_STATE_FLAGS, EDRIVE_CANT_DO_THIS, GPCMD_START_STOP_UNIT, and memset.

Referenced by ide_cdrom_tray_move().

Here is the call graph for this function:

static void cdrom_end_request int  uptodate,
ide_drive_t drive
[static]
 

Definition at line 526 of file ide-cd.c.

References packet_command::buffer, request::buffer, packet_command::c, cdrom_analyze_sense_data(), request::cmd, request::current_nr_sectors, HWGROUP, ide_end_request(), pc, READ, REQUEST_SENSE_COMMAND, and packet_command::sense.

Referenced by cdrom_decode_status(), cdrom_pc_intr(), cdrom_read_check_ireason(), cdrom_read_from_buffer(), cdrom_read_intr(), cdrom_start_read_continuation(), and ide_do_rw_cdrom().

Here is the call graph for this function:

static int cdrom_get_toc_entry ide_drive_t drive,
int  track,
struct atapi_toc_entry **  ent
[static]
 

Definition at line 1864 of file ide-cd.c.

References CDROM_LEADOUT, CDROM_STATE_FLAGS, ide_drive_s::driver_data, EINVAL, atapi_toc::ent, atapi_toc_header::first_track, atapi_toc::hdr, atapi_toc_header::last_track, cdrom_info::toc, toc, and toc_valid.

Referenced by ide_cdrom_audio_ioctl().

static int cdrom_lockdoor ide_drive_t drive,
int  lockflag,
struct request_sense sense
[static]
 

Definition at line 1532 of file ide-cd.c.

References request_sense::asc, CDROM_CONFIG_FLAGS, cdrom_queue_packet_command(), CDROM_STATE_FLAGS, GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, ILLEGAL_REQUEST, memset, NOT_READY, NULL, printk, and x20.

Referenced by ide_cdrom_lock_door(), ide_cdrom_reset(), and ide_cdrom_tray_move().

Here is the call graph for this function:

static int cdrom_log_sense ide_drive_t drive,
struct packet_command pc,
struct request_sense sense
[static]
 

Definition at line 327 of file ide-cd.c.

References request_sense::asc, cdrom_saw_media_change(), log(), NO_SENSE, NOT_READY, NULL, RECOVERED_ERROR, UNIT_ATTENTION, and x04.

Referenced by cdrom_analyze_sense_data().

Here is the call graph for this function:

static ide_startstop_t cdrom_pc_intr ide_drive_t drive  )  [static]
 

Definition at line 1218 of file ide-cd.c.

References atapi_input_bytes(), atapi_output_bytes(), packet_command::buffer, request::buffer, packet_command::buflen, packet_command::c, cdrom_decode_status(), cdrom_end_request(), cdrom_timer_expiry(), DRQ_STAT, GPCMD_REQUEST_SENSE, HWGROUP, IDE_HCYL_REG, IDE_LCYL_REG, IDE_NSECTOR_REG, ide_set_handler(), ide_started, ide_stopped, IN_BYTE, len, ide_drive_s::name, pc, printk, packet_command::stat, and WAIT_CMD.

Referenced by cdrom_do_pc_continuation().

Here is the call graph for this function:

static int cdrom_play_audio ide_drive_t drive,
int  lba_start,
int  lba_end
[static]
 

Definition at line 1849 of file ide-cd.c.

References cdrom_queue_packet_command(), GPCMD_PLAY_AUDIO_MSF, lba_to_msf(), and memset.

Referenced by ide_cdrom_audio_ioctl().

Here is the call graph for this function:

static int cdrom_queue_packet_command ide_drive_t drive,
struct packet_command pc
[static]
 

Definition at line 1356 of file ide-cd.c.

References request_sense::asc, request_sense::ascq, cdrom_saw_media_change(), cdrom_sleep(), EIO, HZ, ide_do_drive_cmd(), ide_init_drive_cmd(), ide_wait, NOT_READY, NULL, PACKET_COMMAND, printk, retries, packet_command::sense, packet_command::stat, and UNIT_ATTENTION.

Referenced by cdrom_check_status(), cdrom_eject(), cdrom_lockdoor(), cdrom_play_audio(), cdrom_read_capacity(), cdrom_read_subchannel(), cdrom_read_tocentry(), cdrom_select_speed(), and ide_cdrom_packet().

Here is the call graph for this function:

static void cdrom_queue_request_sense ide_drive_t drive,
struct semaphore sem,
struct request_sense sense,
struct packet_command failed_command
[static]
 

Definition at line 498 of file ide-cd.c.

References request::buffer, request::cmd, ide_drive_s::driver_data, GPCMD_REQUEST_SENSE, ide_do_drive_cmd(), ide_init_drive_cmd(), ide_preempt, memset, NULL, pc, REQUEST_SENSE_COMMAND, cdrom_info::request_sense_pc, cdrom_info::request_sense_request, request::sem, and cdrom_info::sense_data.

Referenced by cdrom_decode_status().

Here is the call graph for this function:

static int cdrom_read_capacity ide_drive_t drive,
unsigned *  capacity,
struct request_sense sense
[static]
 

Definition at line 1596 of file ide-cd.c.

References be32_to_cpu, cdrom_queue_packet_command(), GPCMD_READ_CDVD_CAPACITY, and memset.

Referenced by cdrom_read_toc(), and ide_cdrom_capacity().

Here is the call graph for this function:

static int cdrom_read_check_ireason ide_drive_t drive,
int  len,
int  ireason
[inline, static]
 

Definition at line 816 of file ide-cd.c.

References atapi_output_bytes(), cdrom_end_request(), GET_STAT, ide_drive_s::name, and printk.

Referenced by cdrom_read_intr().

Here is the call graph for this function:

static int cdrom_read_from_buffer ide_drive_t drive  )  [static]
 

Definition at line 985 of file ide-cd.c.

References request::bh, request::buffer, cdrom_info::buffer, cdrom_end_request(), request::current_nr_sectors, ide_drive_s::driver_data, HWGROUP, memcpy, ide_drive_s::name, request::nr_sectors, cdrom_info::nsectors_buffered, NULL, printk, request::sector, SECTOR_BITS, cdrom_info::sector_buffered, SECTOR_SIZE, and SECTORS_PER_FRAME.

Referenced by cdrom_start_read().

Here is the call graph for this function:

static ide_startstop_t cdrom_read_intr ide_drive_t drive  )  [static]
 

Definition at line 853 of file ide-cd.c.

References atapi_input_bytes(), request::bh, request::buffer, cdrom_buffer_sectors(), CDROM_CONFIG_FLAGS, cdrom_decode_status(), cdrom_end_request(), cdrom_read_check_ireason(), request::current_nr_sectors, cdrom_info::dma, dma, ide_drive_s::driver_data, DRQ_STAT, HWGROUP, HWIF, i, ide_dma_end, ide_dma_off, ide_end_request(), ide_error(), IDE_HCYL_REG, IDE_LCYL_REG, IDE_NSECTOR_REG, ide_set_handler(), ide_started, ide_stopped, IN_BYTE, len, MIN, ide_drive_s::name, request::nr_sectors, NULL, printk, request::sector, SECTOR_BITS, SECTOR_SIZE, and WAIT_CMD.

Referenced by cdrom_start_read_continuation().

Here is the call graph for this function:

static int cdrom_read_subchannel ide_drive_t drive,
int  format,
char *  buf,
int  buflen,
struct request_sense sense
[static]
 

Definition at line 1800 of file ide-cd.c.

References cdrom_queue_packet_command(), GPCMD_READ_SUBCHANNEL, and memset.

Referenced by ide_cdrom_get_mcn(), and mmc_ioctl().

Here is the call graph for this function:

static int cdrom_read_toc ide_drive_t drive,
struct request_sense sense
[static]
 

Definition at line 1646 of file ide-cd.c.

References atapi_toc_entry::addr, bcd2bin(), bin2bcd(), BLOCK_SIZE_BITS, atapi_toc::capacity, cdrom_check_status(), CDROM_CONFIG_FLAGS, cdrom_get_last_written(), CDROM_LEADOUT, cdrom_read_capacity(), cdrom_read_tocentry(), CDROM_STATE_FLAGS, dev, ide_drive_s::driver_data, EIO, ENOMEM, atapi_toc::ent, atapi_toc_header::first_track, atapi_toc::hdr, HWIF, i, kmalloc(), atapi_toc::last_session_lba, atapi_toc_header::last_track, major, MAX_TRACKS, minor, MKDEV, msf_from_bcd(), msf_to_lba(), ide_drive_s::name, ntohs(), NULL, PARTN_BITS, printk, SECTORS_PER_FRAME, cdrom_info::toc, toc, atapi_toc_header::toc_length, toc_valid, atapi_toc_entry::track, and atapi_toc::xa_flag.

Referenced by ide_cdrom_audio_ioctl(), and ide_cdrom_get_last_session().

Here is the call graph for this function:

static int cdrom_read_tocentry ide_drive_t drive,
int  trackno,
int  msf_flag,
int  format,
char *  buf,
int  buflen,
struct request_sense sense
[static]
 

Definition at line 1621 of file ide-cd.c.

References cdrom_queue_packet_command(), GPCMD_READ_TOC_PMA_ATIP, and memset.

Referenced by cdrom_read_toc().

Here is the call graph for this function:

static void cdrom_saw_media_change ide_drive_t drive  )  [static]
 

Definition at line 318 of file ide-cd.c.

References CDROM_STATE_FLAGS, ide_drive_s::driver_data, and cdrom_info::nsectors_buffered.

Referenced by cdrom_decode_status(), cdrom_log_sense(), and cdrom_queue_packet_command().

static ide_startstop_t cdrom_seek_intr ide_drive_t drive  )  [static]
 

Definition at line 1104 of file ide-cd.c.

References CDROM_CONFIG_FLAGS, cdrom_decode_status(), ide_drive_s::driver_data, ide_stopped, IDECD_SEEK_TIMER, jiffies, printk, retry, and cdrom_info::start_seek.

Referenced by cdrom_start_seek_continuation().

Here is the call graph for this function:

static int cdrom_select_speed ide_drive_t drive,
int  speed,
struct request_sense sense
[static]
 

Definition at line 1821 of file ide-cd.c.

References CDROM_CONFIG_FLAGS, cdrom_queue_packet_command(), GPCMD_SET_SPEED, and memset.

Referenced by ide_cdrom_select_speed().

Here is the call graph for this function:

static void cdrom_sleep int  time  )  [static]
 

Definition at line 1345 of file ide-cd.c.

References schedule_timeout, set_current_state, sleep(), and TASK_INTERRUPTIBLE.

Referenced by cdrom_queue_packet_command().

Here is the call graph for this function:

static ide_startstop_t cdrom_start_packet_command ide_drive_t drive,
int  xferlen,
ide_handler_t handler
[static]
 

Definition at line 689 of file ide-cd.c.

References BUSY_STAT, CDROM_CONFIG_FLAGS, cdrom_timer_expiry(), cdrom_info::dma, HWIF, IDE_COMMAND_REG, IDE_CONTROL_REG, ide_dma_begin, ide_dma_read, IDE_FEATURE_REG, IDE_HCYL_REG, IDE_LCYL_REG, IDE_NSECTOR_REG, IDE_SECTOR_REG, ide_set_handler(), ide_started, ide_wait_stat(), OUT_BYTE, WAIT_CMD, WAIT_READY, WIN_PACKETCMD, and xff.

Referenced by cdrom_do_packet_command(), cdrom_start_read(), and cdrom_start_seek().

Here is the call graph for this function:

static ide_startstop_t cdrom_start_read ide_drive_t drive,
unsigned int  block
[static]
 

Definition at line 1173 of file ide-cd.c.

References cdrom_read_from_buffer(), cdrom_start_packet_command(), cdrom