aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-03-13 19:09:49 -0400
committerKevin O'Connor <kevin@koconnor.net>2008-03-13 19:09:49 -0400
commit049d5a237dcc05431829e2afe2bb8fb46cfb33b0 (patch)
tree7c73221bd3a6ccd538e440f34972551511c4d7c8
parent2018eff2cf3f4caced677a7c3bc0b0b9af5bc8d7 (diff)
downloadseabios-hppa-049d5a237dcc05431829e2afe2bb8fb46cfb33b0.zip
seabios-hppa-049d5a237dcc05431829e2afe2bb8fb46cfb33b0.tar.gz
seabios-hppa-049d5a237dcc05431829e2afe2bb8fb46cfb33b0.tar.bz2
Use LBA disk access methods always; don't use CHS methods.
Using CHS is dependent on the drive type, not the request type. So, old code was not correct. It is simpler to just always use LBA.
-rw-r--r--src/ata.c12
-rw-r--r--src/ata.h20
-rw-r--r--src/disk.c23
3 files changed, 11 insertions, 44 deletions
diff --git a/src/ata.c b/src/ata.c
index cbd61d9..95cf1a5 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -546,9 +546,9 @@ ata_detect()
SET_EBDA(ata.devices[device].device,ATA_DEVICE_HD);
SET_EBDA(ata.devices[device].mode, ATA_MODE_PIO16);
- u16 ret = ata_cmd_data_chs(device, ATA_CMD_IDENTIFY_DEVICE
- , 0, 0, 1, 1
- , MAKE_32_PTR(GET_SEG(SS), (u32)buffer));
+ u16 ret = ata_cmd_data(device, ATA_CMD_IDENTIFY_DEVICE
+ , 1, 1
+ , MAKE_32_PTR(GET_SEG(SS), (u32)buffer));
if (ret)
BX_PANIC("ata-detect: Failed to detect ATA device\n");
@@ -650,9 +650,9 @@ ata_detect()
SET_EBDA(ata.devices[device].device,ATA_DEVICE_CDROM);
SET_EBDA(ata.devices[device].mode, ATA_MODE_PIO16);
- u16 ret = ata_cmd_data_chs(device, ATA_CMD_IDENTIFY_DEVICE_PACKET
- , 0, 0, 1, 1
- , MAKE_32_PTR(GET_SEG(SS), (u32)buffer));
+ u16 ret = ata_cmd_data(device, ATA_CMD_IDENTIFY_DEVICE_PACKET
+ , 1, 1
+ , MAKE_32_PTR(GET_SEG(SS), (u32)buffer));
if (ret != 0)
BX_PANIC("ata-detect: Failed to detect ATAPI device\n");
diff --git a/src/ata.h b/src/ata.h
index 8d7c508..af64e1a 100644
--- a/src/ata.h
+++ b/src/ata.h
@@ -68,24 +68,4 @@ ata_cmd_data(u16 biosid, u16 command, u32 lba, u16 count, void *far_buffer)
return ata_transfer(&cmd);
}
-static inline int
-ata_cmd_data_chs(u16 biosid, u16 command, u16 cyl, u16 head, u16 sect, u16 count
- , void *far_buffer)
-{
- u8 slave = biosid % 2;
-
- struct ata_pio_command cmd;
- cmd.far_buffer = far_buffer;
- cmd.biosid = biosid;
-
- cmd.sector_count = count & 0xff;
- cmd.feature = 0;
- cmd.lba_low = sect;
- cmd.lba_mid = cyl;
- cmd.lba_high = cyl >> 8;
- cmd.device = (slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0) | (head & 0xff);
- cmd.command = command;
- return ata_transfer(&cmd);
-}
-
#endif /* __ATA_H */
diff --git a/src/disk.c b/src/disk.c
index 0ccbe42..3cf0ced 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -54,8 +54,6 @@ basic_access(struct bregs *regs, u8 device, u16 command)
u16 nlc = GET_EBDA(ata.devices[device].lchs.cylinders);
u16 nlh = GET_EBDA(ata.devices[device].lchs.heads);
u16 nlspt = GET_EBDA(ata.devices[device].lchs.spt);
- u16 nph = GET_EBDA(ata.devices[device].pchs.heads);
- u16 npspt = GET_EBDA(ata.devices[device].pchs.spt);
// sanity check on cyl heads, sec
if (cylinder >= nlc || head >= nlh || sector > nlspt) {
@@ -75,23 +73,12 @@ basic_access(struct bregs *regs, u8 device, u16 command)
u16 segment = regs->es;
u16 offset = regs->bx;
- irq_enable();
-
- u8 status;
- u32 lba;
- if (nph != nlh || npspt != nlspt) {
- // translate lchs to lba
- lba = (((((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nlspt)
+ // translate lchs to lba
+ u32 lba = (((((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nlspt)
+ (u32)sector - 1);
- status = ata_cmd_data(device, command, lba, count
- , MAKE_32_PTR(segment, offset));
- } else {
- // XXX - see if lba access can always be used.
- status = ata_cmd_data_chs(device, command
- , cylinder, head, sector, count
- , MAKE_32_PTR(segment, offset));
- }
-
+ irq_enable();
+ u8 status = ata_cmd_data(device, command, lba, count
+ , MAKE_32_PTR(segment, offset));
irq_disable();
// Set nb of sector transferred