Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jul 2012 12:42:37 GMT
From:      Steven Hartland <steven.hartland@multiplay.co.uk>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/169764: Patch which adds defines for ATA device values
Message-ID:  <201207101242.q6ACgbOH043645@red.freebsd.org>
Resent-Message-ID: <201207101250.q6ACo7X5009826@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         169764
>Category:       misc
>Synopsis:       Patch which adds defines for ATA device values
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 10 12:50:06 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Steven Hartland
>Release:        8.3-RELEASE
>Organization:
Multiplay
>Environment:
FreeBSD build 8.3-RELEASE-p3 FreeBSD 8.3-RELEASE-p3 #3: Tue Jul  3 13:16:31 UTC 2012     root@build:/usr/obj/usr/src/sys/MULTIPLAY  amd64
>Description:
Simple patch which adds the defines for the "magic" ATA values in the code in order to ensure its easy to know what the values mean
>How-To-Repeat:
N/A
>Fix:
Apply the attached patch

Patch attached with submission follows:

Adds ATA device register defines so that its clear what the various values
are in the code instead of having "magic" 0x40's in the code
--- sys/sys/ata.h.orig	2012-03-03 06:15:13.000000000 +0000
+++ sys/sys/ata.h	2012-07-10 00:23:09.558799761 +0000
@@ -261,6 +269,21 @@
 /*255*/ u_int16_t       integrity;
 } __packed;
 
+/*
+ * ATA Device Register
+ *
+ * bit 7 Obsolete in LBA mode, should be set to 1 in CHS mode
+ * bit 6 Sets LBA/CHS mode. 1=LBA, 0=CHS 
+ * bit 5 Obsolete in LBA mode, should be set to 1 in CHS mode
+ * bit 4 1 = Slave Drive, 0 = Master Drive
+ * bit 3-0 In LBA mode, 27-24 of address. In CHS mode, head number
+*/
+
+#define ATA_DEV_MASTER		0x00
+#define ATA_DEV_SLAVE		0x10
+#define ATA_DEV_CHS		0x00
+#define ATA_DEV_LBA		0x40
+
 
 /* ATA transfer modes */
 #define ATA_MODE_MASK           0x0f
--- sys/cam/ata/ata_all.c.orig	2012-06-20 01:26:17.664685074 +0000
+++ sys/cam/ata/ata_all.c	2012-06-20 01:27:03.929604041 +0000
@@ -333,7 +333,7 @@
 	ataio->cmd.lba_low = lba;
 	ataio->cmd.lba_mid = lba >> 8;
 	ataio->cmd.lba_high = lba >> 16;
-	ataio->cmd.device = 0x40 | ((lba >> 24) & 0x0f);
+	ataio->cmd.device = ATA_DEV_LBA | ((lba >> 24) & 0x0f);
 	ataio->cmd.sector_count = sector_count;
 }
 
@@ -358,7 +358,7 @@
 	ataio->cmd.lba_low = lba;
 	ataio->cmd.lba_mid = lba >> 8;
 	ataio->cmd.lba_high = lba >> 16;
-	ataio->cmd.device = 0x40;
+	ataio->cmd.device = ATA_DEV_LBA;
 	ataio->cmd.lba_low_exp = lba >> 24;
 	ataio->cmd.lba_mid_exp = lba >> 32;
 	ataio->cmd.lba_high_exp = lba >> 40;
@@ -378,7 +378,7 @@
 	ataio->cmd.lba_low = lba;
 	ataio->cmd.lba_mid = lba >> 8;
 	ataio->cmd.lba_high = lba >> 16;
-	ataio->cmd.device = 0x40;
+	ataio->cmd.device = ATA_DEV_LBA;
 	ataio->cmd.lba_low_exp = lba >> 24;
 	ataio->cmd.lba_mid_exp = lba >> 32;
 	ataio->cmd.lba_high_exp = lba >> 40;


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207101242.q6ACgbOH043645>