Commit e07a6a66 authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.7 IDE 25

- Replace the task_io_reg_t with the simple u8. There is no need to obfuscate
   the code more then necessary.

- kill some unnecessary type definitions out from hdreg.h.

- Add proper attributes to register files in hdreg.h.

- Don't use raw arrays for tfRegister and hobRegister in ide_task_s.  Use out
   nice global structures describing the fields in them.  This allows to kill
   the following defines:

     IDE_DATA_OFFSET
     IDE_FEATURE_OFFSET
     IDE_NSECTOR_OFFSET
     IDE_SECTOR_OFFSET
     IDE_LCYL_OFFSET
     IDE_HCYL_OFFSET
     IDE_SELECT_OFFSET
     IDE_COMMAND_OFFSET

   and many many others.

- Please have a look at the following in pdc4030.c. It couldn't have worked!
   This has been fixed in one go with the above change:

   memcpy(args.hobRegister, NULL, sizeof(struct hd_drive_hob_hdr));

- Kill the redundant *_REG_HOB definitions. They don't help readability in any
   way.
parent 4772b236
...@@ -106,7 +106,7 @@ static int lba_capacity_is_ok (struct hd_driveid *id) ...@@ -106,7 +106,7 @@ static int lba_capacity_is_ok (struct hd_driveid *id)
return 0; /* lba_capacity value may be bad */ return 0; /* lba_capacity value may be bad */
} }
static task_ioreg_t get_command(ide_drive_t *drive, int cmd) static u8 get_command(ide_drive_t *drive, int cmd)
{ {
int lba48bit = (drive->id->cfs_enable_2 & 0x0400) ? 1 : 0; int lba48bit = (drive->id->cfs_enable_2 & 0x0400) ? 1 : 0;
...@@ -162,17 +162,19 @@ static ide_startstop_t chs_do_request(ide_drive_t *drive, struct request *rq, un ...@@ -162,17 +162,19 @@ static ide_startstop_t chs_do_request(ide_drive_t *drive, struct request *rq, un
unsigned int head = (track % drive->head); unsigned int head = (track % drive->head);
unsigned int cyl = (track / drive->head); unsigned int cyl = (track / drive->head);
memset(&taskfile, 0, sizeof(task_struct_t)); memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr));
memset(&hobfile, 0, sizeof(hob_struct_t)); memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr));
sectors = rq->nr_sectors; sectors = rq->nr_sectors;
if (sectors == 256) if (sectors == 256)
sectors = 0; sectors = 0;
taskfile.sector_count = sectors; taskfile.sector_count = sectors;
taskfile.sector_number = sect; taskfile.sector_number = sect;
taskfile.low_cylinder = cyl; taskfile.low_cylinder = cyl;
taskfile.high_cylinder = (cyl>>8); taskfile.high_cylinder = (cyl>>8);
taskfile.device_head = head; taskfile.device_head = head;
taskfile.device_head |= drive->select.all; taskfile.device_head |= drive->select.all;
taskfile.command = get_command(drive, rq_data_dir(rq)); taskfile.command = get_command(drive, rq_data_dir(rq));
...@@ -186,14 +188,14 @@ static ide_startstop_t chs_do_request(ide_drive_t *drive, struct request *rq, un ...@@ -186,14 +188,14 @@ static ide_startstop_t chs_do_request(ide_drive_t *drive, struct request *rq, un
printk("buffer=0x%08lx\n", (unsigned long) rq->buffer); printk("buffer=0x%08lx\n", (unsigned long) rq->buffer);
#endif #endif
memcpy(args.tfRegister, &taskfile, sizeof(struct hd_drive_task_hdr)); args.taskfile = taskfile;
memcpy(args.hobRegister, &hobfile, sizeof(struct hd_drive_hob_hdr)); args.hobfile = hobfile;
ide_cmd_type_parser(&args); ide_cmd_type_parser(&args);
rq->special = &args; rq->special = &args;
return ata_taskfile(drive, return ata_taskfile(drive,
(struct hd_drive_task_hdr *) &args.tfRegister, &args.taskfile,
(struct hd_drive_hob_hdr *) &args.hobRegister, &args.hobfile,
args.handler, args.handler,
args.prehandler, args.prehandler,
rq); rq);
...@@ -210,14 +212,16 @@ static ide_startstop_t lba28_do_request(ide_drive_t *drive, struct request *rq, ...@@ -210,14 +212,16 @@ static ide_startstop_t lba28_do_request(ide_drive_t *drive, struct request *rq,
if (sectors == 256) if (sectors == 256)
sectors = 0; sectors = 0;
memset(&taskfile, 0, sizeof(task_struct_t)); memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr));
memset(&hobfile, 0, sizeof(hob_struct_t)); memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr));
taskfile.sector_count = sectors; taskfile.sector_count = sectors;
taskfile.sector_number = block; taskfile.sector_number = block;
taskfile.low_cylinder = (block>>=8); taskfile.low_cylinder = (block >>= 8);
taskfile.high_cylinder = (block>>=8);
taskfile.device_head = ((block>>8)&0x0f); taskfile.high_cylinder = (block >>= 8);
taskfile.device_head = ((block >> 8) & 0x0f);
taskfile.device_head |= drive->select.all; taskfile.device_head |= drive->select.all;
taskfile.command = get_command(drive, rq_data_dir(rq)); taskfile.command = get_command(drive, rq_data_dir(rq));
...@@ -230,14 +234,14 @@ static ide_startstop_t lba28_do_request(ide_drive_t *drive, struct request *rq, ...@@ -230,14 +234,14 @@ static ide_startstop_t lba28_do_request(ide_drive_t *drive, struct request *rq,
printk("buffer=0x%08lx\n", (unsigned long) rq->buffer); printk("buffer=0x%08lx\n", (unsigned long) rq->buffer);
#endif #endif
memcpy(args.tfRegister, &taskfile, sizeof(struct hd_drive_task_hdr)); args.taskfile = taskfile;
memcpy(args.hobRegister, &hobfile, sizeof(struct hd_drive_hob_hdr)); args.hobfile = hobfile;
ide_cmd_type_parser(&args); ide_cmd_type_parser(&args);
rq->special = &args; rq->special = &args;
return ata_taskfile(drive, return ata_taskfile(drive,
(struct hd_drive_task_hdr *) &args.tfRegister, &args.taskfile,
(struct hd_drive_hob_hdr *) &args.hobRegister, &args.hobfile,
args.handler, args.handler,
args.prehandler, args.prehandler,
rq); rq);
...@@ -256,8 +260,8 @@ static ide_startstop_t lba48_do_request(ide_drive_t *drive, struct request *rq, ...@@ -256,8 +260,8 @@ static ide_startstop_t lba48_do_request(ide_drive_t *drive, struct request *rq,
ide_task_t args; ide_task_t args;
int sectors; int sectors;
memset(&taskfile, 0, sizeof(task_struct_t)); memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr));
memset(&hobfile, 0, sizeof(hob_struct_t)); memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr));
sectors = rq->nr_sectors; sectors = rq->nr_sectors;
if (sectors == 65536) if (sectors == 65536)
...@@ -272,11 +276,13 @@ static ide_startstop_t lba48_do_request(ide_drive_t *drive, struct request *rq, ...@@ -272,11 +276,13 @@ static ide_startstop_t lba48_do_request(ide_drive_t *drive, struct request *rq,
} }
taskfile.sector_number = block; /* low lba */ taskfile.sector_number = block; /* low lba */
taskfile.low_cylinder = (block>>=8); /* mid lba */ taskfile.low_cylinder = (block >>= 8); /* mid lba */
taskfile.high_cylinder = (block>>=8); /* hi lba */ taskfile.high_cylinder = (block >>= 8); /* hi lba */
hobfile.sector_number = (block>>=8); /* low lba */
hobfile.low_cylinder = (block>>=8); /* mid lba */ hobfile.sector_number = (block >>= 8); /* low lba */
hobfile.high_cylinder = (block>>=8); /* hi lba */ hobfile.low_cylinder = (block >>= 8); /* mid lba */
hobfile.high_cylinder = (block >>= 8); /* hi lba */
taskfile.device_head = drive->select.all; taskfile.device_head = drive->select.all;
hobfile.device_head = taskfile.device_head; hobfile.device_head = taskfile.device_head;
hobfile.control = (drive->ctl|0x80); hobfile.control = (drive->ctl|0x80);
...@@ -291,14 +297,14 @@ static ide_startstop_t lba48_do_request(ide_drive_t *drive, struct request *rq, ...@@ -291,14 +297,14 @@ static ide_startstop_t lba48_do_request(ide_drive_t *drive, struct request *rq,
printk("buffer=0x%08lx\n", (unsigned long) rq->buffer); printk("buffer=0x%08lx\n", (unsigned long) rq->buffer);
#endif #endif
memcpy(args.tfRegister, &taskfile, sizeof(struct hd_drive_task_hdr)); args.taskfile = taskfile;
memcpy(args.hobRegister, &hobfile, sizeof(struct hd_drive_hob_hdr)); args.hobfile = hobfile;
ide_cmd_type_parser(&args); ide_cmd_type_parser(&args);
rq->special = &args; rq->special = &args;
return ata_taskfile(drive, return ata_taskfile(drive,
(struct hd_drive_task_hdr *) &args.tfRegister, &args.taskfile,
(struct hd_drive_hob_hdr *) &args.hobRegister, &args.hobfile,
args.handler, args.handler,
args.prehandler, args.prehandler,
rq); rq);
...@@ -355,6 +361,7 @@ static int idedisk_open (struct inode *inode, struct file *filp, ide_drive_t *dr ...@@ -355,6 +361,7 @@ static int idedisk_open (struct inode *inode, struct file *filp, ide_drive_t *dr
memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr)); memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr));
check_disk_change(inode->i_rdev); check_disk_change(inode->i_rdev);
taskfile.command = WIN_DOORLOCK; taskfile.command = WIN_DOORLOCK;
/* /*
...@@ -387,9 +394,12 @@ static void idedisk_release (struct inode *inode, struct file *filp, ide_drive_t ...@@ -387,9 +394,12 @@ static void idedisk_release (struct inode *inode, struct file *filp, ide_drive_t
if (drive->removable && !drive->usage) { if (drive->removable && !drive->usage) {
struct hd_drive_task_hdr taskfile; struct hd_drive_task_hdr taskfile;
struct hd_drive_hob_hdr hobfile; struct hd_drive_hob_hdr hobfile;
memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr)); memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr));
memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr)); memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr));
invalidate_bdev(inode->i_bdev, 0); invalidate_bdev(inode->i_bdev, 0);
taskfile.command = WIN_DOORUNLOCK; taskfile.command = WIN_DOORUNLOCK;
if (drive->doorlocking && if (drive->doorlocking &&
ide_wait_taskfile(drive, &taskfile, &hobfile, NULL)) ide_wait_taskfile(drive, &taskfile, &hobfile, NULL))
...@@ -423,21 +433,23 @@ static unsigned long idedisk_read_native_max_address(ide_drive_t *drive) ...@@ -423,21 +433,23 @@ static unsigned long idedisk_read_native_max_address(ide_drive_t *drive)
/* Create IDE/ATA command request structure */ /* Create IDE/ATA command request structure */
memset(&args, 0, sizeof(ide_task_t)); memset(&args, 0, sizeof(ide_task_t));
args.tfRegister[IDE_SELECT_OFFSET] = 0x40; args.taskfile.device_head = 0x40;
args.tfRegister[IDE_COMMAND_OFFSET] = WIN_READ_NATIVE_MAX; args.taskfile.command = WIN_READ_NATIVE_MAX;
args.handler = task_no_data_intr; args.handler = task_no_data_intr;
/* submit command request */ /* submit command request */
ide_raw_taskfile(drive, &args, NULL); ide_raw_taskfile(drive, &args, NULL);
/* if OK, compute maximum address value */ /* if OK, compute maximum address value */
if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { if ((args.taskfile.command & 0x01) == 0) {
addr = ((args.tfRegister[IDE_SELECT_OFFSET] & 0x0f) << 24) addr = ((args.taskfile.device_head & 0x0f) << 24)
| ((args.tfRegister[ IDE_HCYL_OFFSET] ) << 16) | (args.taskfile.high_cylinder << 16)
| ((args.tfRegister[ IDE_LCYL_OFFSET] ) << 8) | (args.taskfile.low_cylinder << 8)
| ((args.tfRegister[IDE_SECTOR_OFFSET] )); | args.taskfile.sector_number;
} }
addr++; /* since the return value is (maxlba - 1), we add 1 */ addr++; /* since the return value is (maxlba - 1), we add 1 */
return addr; return addr;
} }
...@@ -449,24 +461,26 @@ static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive ...@@ -449,24 +461,26 @@ static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive
/* Create IDE/ATA command request structure */ /* Create IDE/ATA command request structure */
memset(&args, 0, sizeof(ide_task_t)); memset(&args, 0, sizeof(ide_task_t));
args.tfRegister[IDE_SELECT_OFFSET] = 0x40; args.taskfile.device_head = 0x40;
args.tfRegister[IDE_COMMAND_OFFSET] = WIN_READ_NATIVE_MAX_EXT; args.taskfile.command = WIN_READ_NATIVE_MAX_EXT;
args.handler = task_no_data_intr; args.handler = task_no_data_intr;
/* submit command request */ /* submit command request */
ide_raw_taskfile(drive, &args, NULL); ide_raw_taskfile(drive, &args, NULL);
/* if OK, compute maximum address value */ /* if OK, compute maximum address value */
if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { if ((args.taskfile.command & 0x01) == 0) {
u32 high = ((args.hobRegister[IDE_HCYL_OFFSET_HOB])<<16) | u32 high = (args.hobfile.high_cylinder << 16) |
((args.hobRegister[IDE_LCYL_OFFSET_HOB])<<8) | (args.hobfile.low_cylinder << 8) |
(args.hobRegister[IDE_SECTOR_OFFSET_HOB]); args.hobfile.sector_number;
u32 low = ((args.tfRegister[IDE_HCYL_OFFSET])<<16) | u32 low = (args.taskfile.high_cylinder << 16) |
((args.tfRegister[IDE_LCYL_OFFSET])<<8) | (args.taskfile.low_cylinder << 8) |
(args.tfRegister[IDE_SECTOR_OFFSET]); args.taskfile.sector_number;
addr = ((__u64)high << 24) | low; addr = ((__u64)high << 24) | low;
} }
addr++; /* since the return value is (maxlba - 1), we add 1 */ addr++; /* since the return value is (maxlba - 1), we add 1 */
return addr; return addr;
} }
...@@ -483,20 +497,22 @@ static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long a ...@@ -483,20 +497,22 @@ static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long a
addr_req--; addr_req--;
/* Create IDE/ATA command request structure */ /* Create IDE/ATA command request structure */
memset(&args, 0, sizeof(ide_task_t)); memset(&args, 0, sizeof(ide_task_t));
args.tfRegister[IDE_SECTOR_OFFSET] = ((addr_req >> 0) & 0xff);
args.tfRegister[IDE_LCYL_OFFSET] = ((addr_req >> 8) & 0xff); args.taskfile.sector_number = (addr_req >> 0);
args.tfRegister[IDE_HCYL_OFFSET] = ((addr_req >> 16) & 0xff); args.taskfile.low_cylinder = (addr_req >> 8);
args.tfRegister[IDE_SELECT_OFFSET] = ((addr_req >> 24) & 0x0f) | 0x40; args.taskfile.high_cylinder = (addr_req >> 16);
args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SET_MAX;
args.taskfile.device_head = ((addr_req >> 24) & 0x0f) | 0x40;
args.taskfile.command = WIN_SET_MAX;
args.handler = task_no_data_intr; args.handler = task_no_data_intr;
/* submit command request */ /* submit command request */
ide_raw_taskfile(drive, &args, NULL); ide_raw_taskfile(drive, &args, NULL);
/* if OK, read new maximum address value */ /* if OK, read new maximum address value */
if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { if ((args.taskfile.command & 0x01) == 0) {
addr_set = ((args.tfRegister[IDE_SELECT_OFFSET] & 0x0f) << 24) addr_set = ((args.taskfile.device_head & 0x0f) << 24)
| ((args.tfRegister[ IDE_HCYL_OFFSET] ) << 16) | (args.taskfile.high_cylinder << 16)
| ((args.tfRegister[ IDE_LCYL_OFFSET] ) << 8) | (args.taskfile.low_cylinder << 8)
| ((args.tfRegister[IDE_SECTOR_OFFSET] )); | args.taskfile.sector_number;
} }
addr_set++; addr_set++;
return addr_set; return addr_set;
...@@ -510,27 +526,31 @@ static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsign ...@@ -510,27 +526,31 @@ static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsign
addr_req--; addr_req--;
/* Create IDE/ATA command request structure */ /* Create IDE/ATA command request structure */
memset(&args, 0, sizeof(ide_task_t)); memset(&args, 0, sizeof(ide_task_t));
args.tfRegister[IDE_SECTOR_OFFSET] = ((addr_req >> 0) & 0xff);
args.tfRegister[IDE_LCYL_OFFSET] = ((addr_req >>= 8) & 0xff); args.taskfile.sector_number = (addr_req >> 0);
args.tfRegister[IDE_HCYL_OFFSET] = ((addr_req >>= 8) & 0xff); args.taskfile.low_cylinder = (addr_req >>= 8);
args.tfRegister[IDE_SELECT_OFFSET] = 0x40; args.taskfile.high_cylinder = (addr_req >>= 8);
args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SET_MAX_EXT; args.taskfile.device_head = 0x40;
args.hobRegister[IDE_SECTOR_OFFSET_HOB] = ((addr_req >>= 8) & 0xff); args.taskfile.command = WIN_SET_MAX_EXT;
args.hobRegister[IDE_LCYL_OFFSET_HOB] = ((addr_req >>= 8) & 0xff);
args.hobRegister[IDE_HCYL_OFFSET_HOB] = ((addr_req >>= 8) & 0xff); args.hobfile.sector_number = (addr_req >>= 8);
args.hobRegister[IDE_SELECT_OFFSET_HOB] = 0x40; args.hobfile.low_cylinder = (addr_req >>= 8);
args.hobRegister[IDE_CONTROL_OFFSET_HOB]= (drive->ctl|0x80); args.hobfile.high_cylinder = (addr_req >>= 8);
args.hobfile.device_head = 0x40;
args.hobfile.control = (drive->ctl | 0x80);
args.handler = task_no_data_intr; args.handler = task_no_data_intr;
/* submit command request */ /* submit command request */
ide_raw_taskfile(drive, &args, NULL); ide_raw_taskfile(drive, &args, NULL);
/* if OK, compute maximum address value */ /* if OK, compute maximum address value */
if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) { if ((args.taskfile.command & 0x01) == 0) {
u32 high = ((args.hobRegister[IDE_HCYL_OFFSET_HOB])<<16) | u32 high = (args.hobfile.high_cylinder << 16) |
((args.hobRegister[IDE_LCYL_OFFSET_HOB])<<8) | (args.hobfile.low_cylinder << 8) |
(args.hobRegister[IDE_SECTOR_OFFSET_HOB]); args.hobfile.sector_number;
u32 low = ((args.tfRegister[IDE_HCYL_OFFSET])<<16) | u32 low = (args.taskfile.high_cylinder << 16) |
((args.tfRegister[IDE_LCYL_OFFSET])<<8) | (args.taskfile.low_cylinder << 8) |
(args.tfRegister[IDE_SECTOR_OFFSET]); args.taskfile.sector_number;
addr_set = ((__u64)high << 24) | low; addr_set = ((__u64)high << 24) | low;
} }
return addr_set; return addr_set;
......
...@@ -592,7 +592,7 @@ int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive) ...@@ -592,7 +592,7 @@ int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
if ((HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) && if ((HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) &&
(drive->addressing == 1)) { (drive->addressing == 1)) {
ide_task_t *args = HWGROUP(drive)->rq->special; ide_task_t *args = HWGROUP(drive)->rq->special;
OUT_BYTE(args->tfRegister[IDE_COMMAND_OFFSET], IDE_COMMAND_REG); OUT_BYTE(args->taskfile.command, IDE_COMMAND_REG);
} else if (drive->addressing) { } else if (drive->addressing) {
OUT_BYTE(reading ? WIN_READDMA_EXT : WIN_WRITEDMA_EXT, IDE_COMMAND_REG); OUT_BYTE(reading ? WIN_READDMA_EXT : WIN_WRITEDMA_EXT, IDE_COMMAND_REG);
} else { } else {
......
...@@ -186,9 +186,9 @@ int ide_driveid_update (ide_drive_t *drive) ...@@ -186,9 +186,9 @@ int ide_driveid_update (ide_drive_t *drive)
*/ */
int ide_ata66_check (ide_drive_t *drive, ide_task_t *args) int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
{ {
if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) && if ((args->taskfile.command == WIN_SETFEATURES) &&
(args->tfRegister[IDE_SECTOR_OFFSET] > XFER_UDMA_2) && (args->taskfile.sector_number > XFER_UDMA_2) &&
(args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER)) { (args->taskfile.feature == SETFEATURES_XFER)) {
if (!HWIF(drive)->udma_four) { if (!HWIF(drive)->udma_four) {
printk("%s: Speed warnings UDMA 3/4/5 is not functional.\n", HWIF(drive)->name); printk("%s: Speed warnings UDMA 3/4/5 is not functional.\n", HWIF(drive)->name);
return 1; return 1;
...@@ -213,9 +213,9 @@ int ide_ata66_check (ide_drive_t *drive, ide_task_t *args) ...@@ -213,9 +213,9 @@ int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
*/ */
int set_transfer (ide_drive_t *drive, ide_task_t *args) int set_transfer (ide_drive_t *drive, ide_task_t *args)
{ {
if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) && if ((args->taskfile.command == WIN_SETFEATURES) &&
(args->tfRegister[IDE_SECTOR_OFFSET] >= XFER_SW_DMA_0) && (args->taskfile.sector_number >= XFER_SW_DMA_0) &&
(args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER) && (args->taskfile.feature == SETFEATURES_XFER) &&
(drive->id->dma_ultra || (drive->id->dma_ultra ||
drive->id->dma_mword || drive->id->dma_mword ||
drive->id->dma_1word)) drive->id->dma_1word))
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/types.h>
#include <linux/ide.h> #include <linux/ide.h>
#include <linux/mc146818rtc.h> #include <linux/mc146818rtc.h>
#include <asm/io.h> #include <asm/io.h>
......
...@@ -534,8 +534,8 @@ static ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq ...@@ -534,8 +534,8 @@ static ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq
} }
/* (ks/hs): Fixed Multi Write */ /* (ks/hs): Fixed Multi Write */
if ((args->tfRegister[IDE_COMMAND_OFFSET] != WIN_MULTWRITE) && if ((args->taskfile.command != WIN_MULTWRITE) &&
(args->tfRegister[IDE_COMMAND_OFFSET] != WIN_MULTWRITE_EXT)) { (args->taskfile.command != WIN_MULTWRITE_EXT)) {
unsigned long flags; unsigned long flags;
char *buf = ide_map_rq(rq, &flags); char *buf = ide_map_rq(rq, &flags);
/* For Write_sectors we need to stuff the first sector */ /* For Write_sectors we need to stuff the first sector */
...@@ -741,12 +741,12 @@ static ide_startstop_t task_mulin_intr(ide_drive_t *drive) ...@@ -741,12 +741,12 @@ static ide_startstop_t task_mulin_intr(ide_drive_t *drive)
/* Called by ioctl to feature out type of command being called */ /* Called by ioctl to feature out type of command being called */
void ide_cmd_type_parser(ide_task_t *args) void ide_cmd_type_parser(ide_task_t *args)
{ {
struct hd_drive_task_hdr *taskfile = (struct hd_drive_task_hdr *) args->tfRegister; struct hd_drive_task_hdr *taskfile = &args->taskfile;
args->prehandler = NULL; args->prehandler = NULL;
args->handler = NULL; args->handler = NULL;
switch(args->tfRegister[IDE_COMMAND_OFFSET]) { switch(args->taskfile.command) {
case WIN_IDENTIFY: case WIN_IDENTIFY:
case WIN_PIDENTIFY: case WIN_PIDENTIFY:
args->handler = task_in_intr; args->handler = task_in_intr;
...@@ -797,9 +797,11 @@ void ide_cmd_type_parser(ide_task_t *args) ...@@ -797,9 +797,11 @@ void ide_cmd_type_parser(ide_task_t *args)
case WIN_SMART: case WIN_SMART:
if (taskfile->feature == SMART_WRITE_LOG_SECTOR) if (taskfile->feature == SMART_WRITE_LOG_SECTOR)
args->prehandler = pre_task_out_intr; args->prehandler = pre_task_out_intr;
args->tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS;
args->tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; args->taskfile.low_cylinder = SMART_LCYL_PASS;
switch(args->tfRegister[IDE_FEATURE_OFFSET]) { args->taskfile.high_cylinder = SMART_HCYL_PASS;
switch(args->taskfile.feature) {
case SMART_READ_VALUES: case SMART_READ_VALUES:
case SMART_READ_THRESHOLDS: case SMART_READ_THRESHOLDS:
case SMART_READ_LOG_SECTOR: case SMART_READ_LOG_SECTOR:
...@@ -837,7 +839,7 @@ void ide_cmd_type_parser(ide_task_t *args) ...@@ -837,7 +839,7 @@ void ide_cmd_type_parser(ide_task_t *args)
#endif #endif
case WIN_SETFEATURES: case WIN_SETFEATURES:
args->handler = task_no_data_intr; args->handler = task_no_data_intr;
switch(args->tfRegister[IDE_FEATURE_OFFSET]) { switch(args->taskfile.feature) {
case SETFEATURES_XFER: case SETFEATURES_XFER:
args->command_type = IDE_DRIVE_TASK_SET_XFER; args->command_type = IDE_DRIVE_TASK_SET_XFER;
return; return;
...@@ -944,27 +946,13 @@ static void init_taskfile_request(struct request *rq) ...@@ -944,27 +946,13 @@ static void init_taskfile_request(struct request *rq)
int ide_wait_taskfile(ide_drive_t *drive, struct hd_drive_task_hdr *taskfile, struct hd_drive_hob_hdr *hobfile, byte *buf) int ide_wait_taskfile(ide_drive_t *drive, struct hd_drive_task_hdr *taskfile, struct hd_drive_hob_hdr *hobfile, byte *buf)
{ {
struct request rq; struct request rq;
/* FIXME: This is on stack! */
ide_task_t args; ide_task_t args;
memset(&args, 0, sizeof(ide_task_t)); memset(&args, 0, sizeof(ide_task_t));
args.tfRegister[IDE_DATA_OFFSET] = taskfile->data; args.taskfile = *taskfile;
args.tfRegister[IDE_FEATURE_OFFSET] = taskfile->feature; args.hobfile = *hobfile;
args.tfRegister[IDE_NSECTOR_OFFSET] = taskfile->sector_count;
args.tfRegister[IDE_SECTOR_OFFSET] = taskfile->sector_number;
args.tfRegister[IDE_LCYL_OFFSET] = taskfile->low_cylinder;
args.tfRegister[IDE_HCYL_OFFSET] = taskfile->high_cylinder;
args.tfRegister[IDE_SELECT_OFFSET] = taskfile->device_head;
args.tfRegister[IDE_COMMAND_OFFSET] = taskfile->command;
args.hobRegister[IDE_DATA_OFFSET_HOB] = hobfile->data;
args.hobRegister[IDE_FEATURE_OFFSET_HOB] = hobfile->feature;
args.hobRegister[IDE_NSECTOR_OFFSET_HOB] = hobfile->sector_count;
args.hobRegister[IDE_SECTOR_OFFSET_HOB] = hobfile->sector_number;
args.hobRegister[IDE_LCYL_OFFSET_HOB] = hobfile->low_cylinder;
args.hobRegister[IDE_HCYL_OFFSET_HOB] = hobfile->high_cylinder;
args.hobRegister[IDE_SELECT_OFFSET_HOB] = hobfile->device_head;
args.hobRegister[IDE_CONTROL_OFFSET_HOB] = hobfile->control;
init_taskfile_request(&rq); init_taskfile_request(&rq);
...@@ -986,7 +974,9 @@ int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *args, byte *buf) ...@@ -986,7 +974,9 @@ int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *args, byte *buf)
rq.buffer = buf; rq.buffer = buf;
if (args->command_type != IDE_DRIVE_TASK_NO_DATA) if (args->command_type != IDE_DRIVE_TASK_NO_DATA)
rq.current_nr_sectors = rq.nr_sectors = (args->hobRegister[IDE_NSECTOR_OFFSET_HOB] << 8) | args->tfRegister[IDE_NSECTOR_OFFSET]; rq.current_nr_sectors = rq.nr_sectors
= (args->hobfile.sector_count << 8)
| args->taskfile.sector_count;
rq.special = args; rq.special = args;
...@@ -1032,13 +1022,13 @@ int ide_cmd_ioctl(ide_drive_t *drive, struct inode *inode, struct file *file, un ...@@ -1032,13 +1022,13 @@ int ide_cmd_ioctl(ide_drive_t *drive, struct inode *inode, struct file *file, un
if (copy_from_user(args, (void *)arg, 4)) if (copy_from_user(args, (void *)arg, 4))
return -EFAULT; return -EFAULT;
tfargs.tfRegister[IDE_FEATURE_OFFSET] = args[2]; tfargs.taskfile.feature = args[2];
tfargs.tfRegister[IDE_NSECTOR_OFFSET] = args[3]; tfargs.taskfile.sector_count = args[3];
tfargs.tfRegister[IDE_SECTOR_OFFSET] = args[1]; tfargs.taskfile.sector_number = args[1];
tfargs.tfRegister[IDE_LCYL_OFFSET] = 0x00; tfargs.taskfile.low_cylinder = 0x00;
tfargs.tfRegister[IDE_HCYL_OFFSET] = 0x00; tfargs.taskfile.high_cylinder = 0x00;
tfargs.tfRegister[IDE_SELECT_OFFSET] = 0x00; tfargs.taskfile.device_head = 0x00;
tfargs.tfRegister[IDE_COMMAND_OFFSET] = args[0]; tfargs.taskfile.command = args[0];
if (args[3]) { if (args[3]) {
argsize = 4 + (SECTOR_WORDS * 4 * args[3]); argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
......
...@@ -737,22 +737,25 @@ void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err) ...@@ -737,22 +737,25 @@ void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err)
ide_task_t *args = (ide_task_t *) rq->special; ide_task_t *args = (ide_task_t *) rq->special;
rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT); rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT);
if (args) { if (args) {
args->tfRegister[IDE_ERROR_OFFSET] = err; args->taskfile.feature = err;
args->tfRegister[IDE_NSECTOR_OFFSET] = IN_BYTE(IDE_NSECTOR_REG); args->taskfile.sector_count = IN_BYTE(IDE_NSECTOR_REG);
args->tfRegister[IDE_SECTOR_OFFSET] = IN_BYTE(IDE_SECTOR_REG); args->taskfile.sector_number = IN_BYTE(IDE_SECTOR_REG);
args->tfRegister[IDE_LCYL_OFFSET] = IN_BYTE(IDE_LCYL_REG); args->taskfile.low_cylinder = IN_BYTE(IDE_LCYL_REG);
args->tfRegister[IDE_HCYL_OFFSET] = IN_BYTE(IDE_HCYL_REG); args->taskfile.high_cylinder = IN_BYTE(IDE_HCYL_REG);
args->tfRegister[IDE_SELECT_OFFSET] = IN_BYTE(IDE_SELECT_REG); args->taskfile.device_head = IN_BYTE(IDE_SELECT_REG);
args->tfRegister[IDE_STATUS_OFFSET] = stat; args->taskfile.command = stat;
if ((drive->id->command_set_2 & 0x0400) && if ((drive->id->command_set_2 & 0x0400) &&
(drive->id->cfs_enable_2 & 0x0400) && (drive->id->cfs_enable_2 & 0x0400) &&
(drive->addressing == 1)) { (drive->addressing == 1)) {
OUT_BYTE(drive->ctl|0x80, IDE_CONTROL_REG_HOB); /* The following command goes to the hob file! */
args->hobRegister[IDE_FEATURE_OFFSET_HOB] = IN_BYTE(IDE_FEATURE_REG);
args->hobRegister[IDE_NSECTOR_OFFSET_HOB] = IN_BYTE(IDE_NSECTOR_REG); OUT_BYTE(drive->ctl|0x80, IDE_CONTROL_REG);
args->hobRegister[IDE_SECTOR_OFFSET_HOB] = IN_BYTE(IDE_SECTOR_REG); args->hobfile.feature = IN_BYTE(IDE_FEATURE_REG);
args->hobRegister[IDE_LCYL_OFFSET_HOB] = IN_BYTE(IDE_LCYL_REG); args->hobfile.sector_count = IN_BYTE(IDE_NSECTOR_REG);
args->hobRegister[IDE_HCYL_OFFSET_HOB] = IN_BYTE(IDE_HCYL_REG);
args->hobfile.sector_number = IN_BYTE(IDE_SECTOR_REG);
args->hobfile.low_cylinder = IN_BYTE(IDE_LCYL_REG);
args->hobfile.high_cylinder = IN_BYTE(IDE_HCYL_REG);
} }
} }
} }
...@@ -1081,8 +1084,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) ...@@ -1081,8 +1084,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
goto args_error; goto args_error;
ata_taskfile(drive, ata_taskfile(drive,
(struct hd_drive_task_hdr *)&args->tfRegister, &args->taskfile,
(struct hd_drive_hob_hdr *)&args->hobRegister, &args->hobfile,
args->handler, NULL, NULL); args->handler, NULL, NULL);
if (((args->command_type == IDE_DRIVE_TASK_RAW_WRITE) || if (((args->command_type == IDE_DRIVE_TASK_RAW_WRITE) ||
......
...@@ -550,7 +550,7 @@ static ide_startstop_t promise_write (ide_drive_t *drive) ...@@ -550,7 +550,7 @@ static ide_startstop_t promise_write (ide_drive_t *drive)
ide_startstop_t do_pdc4030_io (ide_drive_t *drive, ide_task_t *task) ide_startstop_t do_pdc4030_io (ide_drive_t *drive, ide_task_t *task)
{ {
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
task_struct_t *taskfile = (task_struct_t *) task->tfRegister; struct hd_drive_task_hdr *taskfile = &task->taskfile;
unsigned long timeout; unsigned long timeout;
byte stat; byte stat;
...@@ -652,8 +652,9 @@ ide_startstop_t promise_rw_disk (ide_drive_t *drive, struct request *rq, unsigne ...@@ -652,8 +652,9 @@ ide_startstop_t promise_rw_disk (ide_drive_t *drive, struct request *rq, unsigne
taskfile.device_head = ((block>>8)&0x0f)|drive->select.all; taskfile.device_head = ((block>>8)&0x0f)|drive->select.all;
taskfile.command = (rq_data_dir(rq)==READ)?PROMISE_READ:PROMISE_WRITE; taskfile.command = (rq_data_dir(rq)==READ)?PROMISE_READ:PROMISE_WRITE;
memcpy(args.tfRegister, &taskfile, sizeof(struct hd_drive_task_hdr)); args.taskfile = taskfile;
memcpy(args.hobRegister, NULL, sizeof(struct hd_drive_hob_hdr)); memset(&args.hobfile, 0, sizeof(struct hd_drive_hob_hdr));
ide_cmd_type_parser(&args); ide_cmd_type_parser(&args);
/* We don't use the generic inerrupt handlers here? */ /* We don't use the generic inerrupt handlers here? */
args.prehandler = NULL; args.prehandler = NULL;
......
...@@ -54,16 +54,9 @@ ...@@ -54,16 +54,9 @@
* HDIO_DRIVE_CMD and HDIO_DRIVE_TASK * HDIO_DRIVE_CMD and HDIO_DRIVE_TASK
*/ */
#if 0 #define HDIO_DRIVE_CMD_HDR_SIZE (4 * sizeof(u8))
#include <asm/hdreg.h> #define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(u8))
typedef ide_ioreg_t task_ioreg_t; #define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(u8))
#else
typedef unsigned char task_ioreg_t;
#endif
#define HDIO_DRIVE_CMD_HDR_SIZE 4*sizeof(task_ioreg_t)
#define HDIO_DRIVE_TASK_HDR_SIZE 8*sizeof(task_ioreg_t)
#define HDIO_DRIVE_HOB_HDR_SIZE 8*sizeof(task_ioreg_t)
#define IDE_DRIVE_TASK_INVALID -1 #define IDE_DRIVE_TASK_INVALID -1
#define IDE_DRIVE_TASK_NO_DATA 0 #define IDE_DRIVE_TASK_NO_DATA 0
...@@ -74,57 +67,27 @@ typedef unsigned char task_ioreg_t; ...@@ -74,57 +67,27 @@ typedef unsigned char task_ioreg_t;
#define IDE_DRIVE_TASK_OUT 3 #define IDE_DRIVE_TASK_OUT 3
#define IDE_DRIVE_TASK_RAW_WRITE 4 #define IDE_DRIVE_TASK_RAW_WRITE 4
struct hd_drive_cmd_hdr { struct hd_drive_task_hdr {
task_ioreg_t command; u8 data;
task_ioreg_t sector_number; u8 feature;
task_ioreg_t feature; u8 sector_count;
task_ioreg_t sector_count; u8 sector_number;
}; u8 low_cylinder;
u8 high_cylinder;
typedef struct hd_drive_task_hdr { u8 device_head;
task_ioreg_t data; u8 command;
task_ioreg_t feature; } __attribute__((packed));
task_ioreg_t sector_count;
task_ioreg_t sector_number; struct hd_drive_hob_hdr {
task_ioreg_t low_cylinder; u8 data;
task_ioreg_t high_cylinder; u8 feature;
task_ioreg_t device_head; u8 sector_count;
task_ioreg_t command; u8 sector_number;
} task_struct_t; u8 low_cylinder;
u8 high_cylinder;
typedef struct hd_drive_hob_hdr { u8 device_head;
task_ioreg_t data; u8 control;
task_ioreg_t feature; } __attribute__((packed));
task_ioreg_t sector_count;
task_ioreg_t sector_number;
task_ioreg_t low_cylinder;
task_ioreg_t high_cylinder;
task_ioreg_t device_head;
task_ioreg_t control;
} hob_struct_t;
typedef union ide_reg_valid_s {
unsigned all : 16;
struct {
unsigned data : 1;
unsigned error_feature : 1;
unsigned sector : 1;
unsigned nsector : 1;
unsigned lcyl : 1;
unsigned hcyl : 1;
unsigned select : 1;
unsigned status_command : 1;
unsigned data_hob : 1;
unsigned error_feature_hob : 1;
unsigned sector_hob : 1;
unsigned nsector_hob : 1;
unsigned lcyl_hob : 1;
unsigned hcyl_hob : 1;
unsigned select_hob : 1;
unsigned control_hob : 1;
} b;
} ide_reg_valid_t;
/* /*
* Define standard taskfile in/out register * Define standard taskfile in/out register
...@@ -134,23 +97,6 @@ typedef union ide_reg_valid_s { ...@@ -134,23 +97,6 @@ typedef union ide_reg_valid_s {
#define IDE_HOB_STD_OUT_FLAGS 0xC0 #define IDE_HOB_STD_OUT_FLAGS 0xC0
#define IDE_HOB_STD_IN_FLAGS 0xC0 #define IDE_HOB_STD_IN_FLAGS 0xC0
typedef struct ide_task_request_s {
task_ioreg_t io_ports[8];
task_ioreg_t hob_ports[8];
ide_reg_valid_t out_flags;
ide_reg_valid_t in_flags;
int data_phase;
int req_cmd;
unsigned long out_size;
unsigned long in_size;
} ide_task_request_t;
typedef struct ide_ioctl_request_s {
ide_task_request_t *task_request;
unsigned char *out_buffer;
unsigned char *in_buffer;
} ide_ioctl_request_t;
#define TASKFILE_INVALID 0x7fff #define TASKFILE_INVALID 0x7fff
#define TASKFILE_48 0x8000 #define TASKFILE_48 0x8000
......
...@@ -90,17 +90,6 @@ typedef unsigned char byte; /* used everywhere */ ...@@ -90,17 +90,6 @@ typedef unsigned char byte; /* used everywhere */
#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET #define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET #define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
#define IDE_DATA_OFFSET_HOB (0)
#define IDE_ERROR_OFFSET_HOB (1)
#define IDE_NSECTOR_OFFSET_HOB (2)
#define IDE_SECTOR_OFFSET_HOB (3)
#define IDE_LCYL_OFFSET_HOB (4)
#define IDE_HCYL_OFFSET_HOB (5)
#define IDE_SELECT_OFFSET_HOB (6)
#define IDE_CONTROL_OFFSET_HOB (7)
#define IDE_FEATURE_OFFSET_HOB IDE_ERROR_OFFSET_HOB
#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET]) #define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET]) #define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET]) #define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
...@@ -112,16 +101,6 @@ typedef unsigned char byte; /* used everywhere */ ...@@ -112,16 +101,6 @@ typedef unsigned char byte; /* used everywhere */
#define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET]) #define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
#define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET]) #define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
#define IDE_DATA_REG_HOB (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
#define IDE_ERROR_REG_HOB (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
#define IDE_NSECTOR_REG_HOB (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
#define IDE_SECTOR_REG_HOB (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
#define IDE_LCYL_REG_HOB (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
#define IDE_HCYL_REG_HOB (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
#define IDE_SELECT_REG_HOB (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
#define IDE_STATUS_REG_HOB (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
#define IDE_CONTROL_REG_HOB (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
#define IDE_FEATURE_REG IDE_ERROR_REG #define IDE_FEATURE_REG IDE_ERROR_REG
#define IDE_COMMAND_REG IDE_STATUS_REG #define IDE_COMMAND_REG IDE_STATUS_REG
#define IDE_ALTSTATUS_REG IDE_CONTROL_REG #define IDE_ALTSTATUS_REG IDE_CONTROL_REG
...@@ -785,8 +764,8 @@ extern int ide_do_drive_cmd(ide_drive_t *drive, struct request *rq, ide_action_t ...@@ -785,8 +764,8 @@ extern int ide_do_drive_cmd(ide_drive_t *drive, struct request *rq, ide_action_t
void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err); void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err);
typedef struct ide_task_s { typedef struct ide_task_s {
task_ioreg_t tfRegister[8]; struct hd_drive_task_hdr taskfile;
task_ioreg_t hobRegister[8]; struct hd_drive_hob_hdr hobfile;
int command_type; int command_type;
ide_pre_handler_t *prehandler; ide_pre_handler_t *prehandler;
ide_handler_t *handler; ide_handler_t *handler;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment