summaryrefslogtreecommitdiff
path: root/sys/dev/ata
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2007-03-12 00:33:10 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2007-03-12 00:33:10 +0000
commit569a51d364f71abf2a1d3788c0ae086c9662a836 (patch)
treec9473c92acde8ebdbaeb5b26d2cad6a6401d7a25 /sys/dev/ata
parent1b4671f1d10d98c6882b21ebb6d804e44a351535 (diff)
parse the ata_identify to get a more correct value for the capacity of the
disk.
Diffstat (limited to 'sys/dev/ata')
-rw-r--r--sys/dev/ata/atascsi.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/dev/ata/atascsi.c b/sys/dev/ata/atascsi.c
index a49dcab59ff..e3f3ee3d4ef 100644
--- a/sys/dev/ata/atascsi.c
+++ b/sys/dev/ata/atascsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atascsi.c,v 1.12 2007/03/12 00:31:17 dlg Exp $ */
+/* $OpenBSD: atascsi.c,v 1.13 2007/03/12 00:33:09 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -484,11 +484,24 @@ atascsi_disk_capacity_done(struct ata_xfer *xa)
struct scsi_xfer *xs = xa->atascsi_private;
struct ata_identify id;
struct scsi_read_cap_data rcd;
+ u_int32_t capacity;
+ int i;
ata_complete_identify(xa, &id);
bzero(&rcd, sizeof(rcd));
- _lto4b(1024 * 1024 * 1024, rcd.addr);
+ if (id.cmdset83 & 0x0400) {
+ for (i = 3; i >= 0; --i) {
+ capacity <<= 16;
+ capacity += id.addrsecxt[i];
+ }
+ } else {
+ capacity = id.addrsec[1];
+ capacity <<= 16;
+ capacity += id.addrsec[0];
+ }
+
+ _lto4b(capacity, rcd.addr);
_lto4b(512, rcd.length);
bcopy(&rcd, xs->data, MIN(sizeof(rcd), xs->datalen));