📄 ide.h
字号:
* This routine busy-waits for the drive status to be not "busy". * It then checks the status for all of the "good" bits and none * of the "bad" bits, and if all is okay it returns 0. All other * cases return 1 after doing "*startstop = ide_error()", and the * caller should return the updated value of "startstop" in this case. * "startstop" is unchanged when the function returns 0; * (startstop, drive, good, bad, timeout) */extern int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);/* * Return the current idea about the total capacity of this drive. */extern sector_t current_capacity (ide_drive_t *drive);/* * Start a reset operation for an IDE interface. * The caller should return immediately after invoking this. */extern ide_startstop_t ide_do_reset (ide_drive_t *);/* * This function is intended to be used prior to invoking ide_do_drive_cmd(). */extern void ide_init_drive_cmd (struct request *rq);/* * this function returns error location sector offset in case of a write error */extern u64 ide_get_error_location(ide_drive_t *, char *);/* * "action" parameter type for ide_do_drive_cmd() below. */typedef enum { ide_wait, /* insert rq at end of list, and wait for it */ ide_next, /* insert rq immediately after current request */ ide_preempt, /* insert rq in front of current request */ ide_head_wait, /* insert rq in front of current request and wait for it */ ide_end /* insert rq at end of list, but don't wait for it */} ide_action_t;/* * This function issues a special IDE device request * onto the request queue. * * If action is ide_wait, then the rq is queued at the end of the * request queue, and the function sleeps until it has been processed. * This is for use when invoked from an ioctl handler. * * If action is ide_preempt, then the rq is queued at the head of * the request queue, displacing the currently-being-processed * request and this function returns immediately without waiting * for the new rq to be completed. This is VERY DANGEROUS, and is * intended for careful use by the ATAPI tape/cdrom driver code. * * If action is ide_next, then the rq is queued immediately after * the currently-being-processed-request (if any), and the function * returns without waiting for the new rq to be completed. As above, * This is VERY DANGEROUS, and is intended for careful use by the * ATAPI tape/cdrom driver code. * * If action is ide_end, then the rq is queued at the end of the * request queue, and the function returns immediately without waiting * for the new rq to be completed. This is again intended for careful * use by the ATAPI tape/cdrom driver code. */extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);/* * Clean up after success/failure of an explicit drive cmd. * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD). * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASK_MASK). * * (ide_drive_t *drive, u8 stat, u8 err) */extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);extern void try_to_flush_leftover_data(ide_drive_t *);/* * Issue ATA command and wait for completion. * Use for implementing commands in kernel * * (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf) */extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *);/* (ide_drive_t *drive, u8 *buf) */extern int ide_wait_cmd_task(ide_drive_t *, u8 *);typedef struct ide_task_s {/* * struct hd_drive_task_hdr tf; * task_struct_t tf; * struct hd_drive_hob_hdr hobf; * hob_struct_t hobf; */ task_ioreg_t tfRegister[8]; task_ioreg_t hobRegister[8]; ide_reg_valid_t tf_out_flags; ide_reg_valid_t tf_in_flags; int data_phase; int command_type; ide_pre_handler_t *prehandler; ide_handler_t *handler; struct request *rq; /* copy of request */ void *special; /* valid_t generally */} ide_task_t;typedef struct pkt_task_s {/* * struct hd_drive_task_hdr pktf; * task_struct_t pktf; * u8 pkcdb[12]; */ task_ioreg_t tfRegister[8]; int data_phase; int command_type; ide_handler_t *handler; struct request *rq; /* copy of request */ void *special;} pkt_task_t;extern u32 ide_read_24(ide_drive_t *);extern void SELECT_DRIVE(ide_drive_t *);extern void SELECT_INTERRUPT(ide_drive_t *);extern void SELECT_MASK(ide_drive_t *, int);extern void QUIRK_LIST(ide_drive_t *);extern void ata_input_data(ide_drive_t *, void *, u32);extern void ata_output_data(ide_drive_t *, void *, u32);extern void atapi_input_bytes(ide_drive_t *, void *, u32);extern void atapi_output_bytes(ide_drive_t *, void *, u32);extern void taskfile_input_data(ide_drive_t *, void *, u32);extern void taskfile_output_data(ide_drive_t *, void *, u32);#define IDE_PIO_IN 0#define IDE_PIO_OUT 1static inline void __task_sectors(ide_drive_t *drive, char *buf, unsigned nsect, unsigned rw){ /* * IRQ can happen instantly after reading/writing * last sector of the datablock. */ if (rw == IDE_PIO_OUT) taskfile_output_data(drive, buf, nsect * SECTOR_WORDS); else taskfile_input_data(drive, buf, nsect * SECTOR_WORDS);}#ifdef CONFIG_IDE_TASKFILE_IOstatic inline void task_bio_sectors(ide_drive_t *drive, struct request *rq, unsigned nsect, unsigned rw){ unsigned long flags; char *buf = rq_map_buffer(rq, &flags); process_that_request_first(rq, nsect); __task_sectors(drive, buf, nsect, rw); rq_unmap_buffer(buf, &flags);}#endif /* CONFIG_IDE_TASKFILE_IO */extern int drive_is_ready(ide_drive_t *);extern int wait_for_ready(ide_drive_t *, int /* timeout */);/* * taskfile io for disks for now...and builds request from ide_ioctl */extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);/* * Special Flagged Register Validation Caller */extern ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *);extern ide_startstop_t set_multmode_intr(ide_drive_t *);extern ide_startstop_t set_geometry_intr(ide_drive_t *);extern ide_startstop_t recal_intr(ide_drive_t *);extern ide_startstop_t task_no_data_intr(ide_drive_t *);extern ide_startstop_t task_in_intr(ide_drive_t *);extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);extern ide_startstop_t task_out_intr(ide_drive_t *);extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *);int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);extern int system_bus_clock(void);extern u8 ide_auto_reduce_xfer(ide_drive_t *);extern int ide_driveid_update(ide_drive_t *);extern int ide_ata66_check(ide_drive_t *, ide_task_t *);extern int ide_config_drive_speed(ide_drive_t *, u8);extern u8 eighty_ninty_three (ide_drive_t *);extern int set_transfer(ide_drive_t *, ide_task_t *);extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *);extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout);ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, sector_t block);/* * ide_system_bus_speed() returns what we think is the system VESA/PCI * bus speed (in MHz). This is used for calculating interface PIO timings. * The default is 40 for known PCI systems, 50 otherwise. * The "idebus=xx" parameter can be used to override this value. */extern int ide_system_bus_speed(void);/* * ide_stall_queue() can be used by a drive to give excess bandwidth back * to the hwgroup by sleeping for timeout jiffies. */extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout);extern int ide_spin_wait_hwgroup(ide_drive_t *);extern void ide_timer_expiry(unsigned long);extern irqreturn_t ide_intr(int irq, void *dev_id, struct pt_regs *regs);extern void do_ide_request(request_queue_t *);extern void ide_init_subdrivers(void);extern struct block_device_operations ide_fops[];extern ide_proc_entry_t generic_subdriver_entries[];extern int ata_attach(ide_drive_t *);extern int ideprobe_init(void);extern void ide_scan_pcibus(int scan_direction) __init;extern int ide_pci_register_driver(struct pci_driver *driver);extern void ide_pci_unregister_driver(struct pci_driver *driver);extern void ide_pci_setup_ports(struct pci_dev *dev, struct ide_pci_device_s *d, int autodma, int pciirq, ata_index_t *index);extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d);extern void default_hwif_iops(ide_hwif_t *);extern void default_hwif_mmiops(ide_hwif_t *);extern void default_hwif_transport(ide_hwif_t *);int ide_register_driver(ide_driver_t *driver);void ide_unregister_driver(ide_driver_t *driver);int ide_register_subdriver(ide_drive_t *, ide_driver_t *);int ide_unregister_subdriver (ide_drive_t *drive);int ide_replace_subdriver(ide_drive_t *drive, const char *driver);#define ON_BOARD 1#define NEVER_BOARD 0#ifdef CONFIG_BLK_DEV_OFFBOARD# define OFF_BOARD ON_BOARD#else /* CONFIG_BLK_DEV_OFFBOARD */# define OFF_BOARD NEVER_BOARD#endif /* CONFIG_BLK_DEV_OFFBOARD */#define NODMA 0#define NOAUTODMA 1#define AUTODMA 2typedef struct ide_pci_enablebit_s { u8 reg; /* byte pci reg holding the enable-bit */ u8 mask; /* mask to isolate the enable-bit */ u8 val; /* value of masked reg when "enabled" */} ide_pci_enablebit_t;enum { /* Uses ISA control ports not PCI ones. */ IDEPCI_FLAG_ISA_PORTS = (1 << 0), IDEPCI_FLAG_FORCE_MASTER = (1 << 1), IDEPCI_FLAG_FORCE_PDC = (1 << 2),};typedef struct ide_pci_device_s { char *name; void (*init_setup)(struct pci_dev *, struct ide_pci_device_s *); void (*init_setup_dma)(struct pci_dev *, struct ide_pci_device_s *, ide_hwif_t *); unsigned int (*init_chipset)(struct pci_dev *, const char *); void (*init_iops)(ide_hwif_t *); void (*init_hwif)(ide_hwif_t *); void (*init_dma)(ide_hwif_t *, unsigned long); u8 channels; u8 autodma; ide_pci_enablebit_t enablebits[2]; u8 bootable; unsigned int extra; struct ide_pci_device_s *next; u8 flags;} ide_pci_device_t;extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);extern void ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, ide_pci_device_t *);#define BAD_DMA_DRIVE 0#define GOOD_DMA_DRIVE 1#ifdef CONFIG_BLK_DEV_IDEDMAint __ide_dma_bad_drive(ide_drive_t *);int __ide_dma_good_drive(ide_drive_t *);int __ide_dma_off(ide_drive_t *);#ifdef CONFIG_BLK_DEV_IDEDMA_PCIextern int ide_build_sglist(ide_drive_t *, struct request *);extern int ide_raw_build_sglist(ide_drive_t *, struct request *);extern int ide_build_dmatable(ide_drive_t *, struct request *);extern void ide_destroy_dmatable(ide_drive_t *);extern ide_startstop_t ide_dma_intr(ide_drive_t *);extern int ide_release_dma(ide_hwif_t *);extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int);extern int ide_start_dma(ide_hwif_t *, ide_drive_t *, int);extern int __ide_dma_host_off(ide_drive_t *);extern int __ide_dma_off_quietly(ide_drive_t *);extern int __ide_dma_host_on(ide_drive_t *);extern int __ide_dma_on(ide_drive_t *);extern int __ide_dma_check(ide_drive_t *);extern int __ide_dma_read(ide_drive_t *);extern int __ide_dma_write(ide_drive_t *);extern int __ide_dma_begin(ide_drive_t *);extern int __ide_dma_end(ide_drive_t *);extern int __ide_dma_test_irq(ide_drive_t *);extern int __ide_dma_verbose(ide_drive_t *);extern int __ide_dma_lostirq(ide_drive_t *);extern int __ide_dma_timeout(ide_drive_t *);#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */#elsestatic inline int __ide_dma_off(ide_drive_t *drive) { return 0; }#endif /* CONFIG_BLK_DEV_IDEDMA */#ifndef CONFIG_BLK_DEV_IDEDMA_PCIstatic inline void ide_release_dma(ide_hwif_t *drive) {;}#endifextern int ide_hwif_request_regions(ide_hwif_t *hwif);extern void ide_hwif_release_regions(ide_hwif_t* hwif);extern void ide_unregister (unsigned int index);extern int probe_hwif_init(ide_hwif_t *);static inline void *ide_get_hwifdata (ide_hwif_t * hwif){ return hwif->hwif_data;}static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data){ hwif->hwif_data = data;}/* ide-lib.c */extern u8 ide_dma_speed(ide_drive_t *drive, u8 mode);extern u8 ide_rate_filter(u8 mode, u8 speed); extern int ide_dma_enable(ide_drive_t *drive);extern char *ide_xfer_verbose(u8 xfer_rate);extern void ide_toggle_bounce(ide_drive_t *drive, int on);extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);extern byte ide_dump_atapi_status(ide_drive_t *drive, const char *msg, byte stat);typedef struct ide_pio_timings_s { int setup_time; /* Address setup (ns) minimum */ int active_time; /* Active pulse (ns) minimum */ int cycle_time; /* Cycle time (ns) minimum = (setup + active + recovery) */} ide_pio_timings_t;typedef struct ide_pio_data_s { u8 pio_mode; u8 use_iordy; u8 overridden; u8 blacklisted; unsigned int cycle_time;} ide_pio_data_t;extern u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d);extern const ide_pio_timings_t ide_pio_timings[6];extern spinlock_t ide_lock;extern struct semaphore ide_cfg_sem;/* * Structure locking: * * ide_cfg_sem and ide_lock together protect changes to * ide_hwif_t->{next,hwgroup} * ide_drive_t->next * * ide_hwgroup_t->busy: ide_lock * ide_hwgroup_t->hwif: ide_lock * ide_hwif_t->mate: constant, no locking * ide_drive_t->hwif: constant, no locking */#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable(); } while (0)extern struct bus_type ide_bus_type;/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */#define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000)/* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */#define ide_id_has_flush_cache_ext(id) \ (((id)->cfs_enable_2 & 0x2400) == 0x2400)#endif /* _IDE_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -