From nobody@FreeBSD.org  Tue Jul 10 12:42:38 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2339D106567A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Jul 2012 12:42:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id E8A6F8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Jul 2012 12:42:37 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q6ACgbaX043646
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Jul 2012 12:42:37 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q6ACgbOH043645;
	Tue, 10 Jul 2012 12:42:37 GMT
	(envelope-from nobody)
Message-Id: <201207101242.q6ACgbOH043645@red.freebsd.org>
Date: Tue, 10 Jul 2012 12:42:37 GMT
From: Steven Hartland <steven.hartland@multiplay.co.uk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Patch which adds defines for ATA device values
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169764
>Category:       kern
>Synopsis:       Patch which adds defines for ATA device values
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brueffer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 10 12:50:06 UTC 2012
>Closed-Date:    Thu Jul 26 11:27:31 CEST 2012
>Last-Modified:  Thu Jul 26 11:27:31 CEST 2012
>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:
State-Changed-From-To: open->feedback 
State-Changed-By: brueffer 
State-Changed-When: Wed Jul 11 13:47:29 CEST 2012 
State-Changed-Why:  
Steven, shouldn't it be 0x80 for ATA_DEV_CHS according to the comment 
included in the patch? 


Responsible-Changed-From-To: freebsd-bugs->brueffer 
Responsible-Changed-By: brueffer 
Responsible-Changed-When: Wed Jul 11 13:47:29 CEST 2012 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169764 

From: "Steven Hartland" <steven.hartland@multiplay.co.uk>
To: <bug-followup@freebsd.org>
Cc:  
Subject: Re: misc/169764: Patch which adds defines for ATA device values
Date: Wed, 11 Jul 2012 13:42:15 +0100

 My original intention was for ATA_DEV_CHS to signify that
 bit 6 should be 0 as apposed to 1 in LBA mode, hence 0x00
 
 However revisiting it based on your comment, I think 0xA0
 is the most appropriate value because in CHS mode:
 bit 7 = 1
 bit 6 = 0
 bit 5 = 1
 
 This means a simple ataio->cmd.device = ATA_DEV_CHS would
 set all the relevant bits for CHS mode operation if
 required.
 
     Regards
     Steve
 
 ================================================
 This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. 
 
 In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337
 or return the E.mail to postmaster@multiplay.co.uk.
 
State-Changed-From-To: feedback->patched 
State-Changed-By: brueffer 
State-Changed-When: Thu Jul 12 12:09:50 CEST 2012 
State-Changed-Why:  
Committed a modified patch discussed with the submitter and mav. 

Thanks for the submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169764 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/169764: commit references a PR
Date: Thu, 12 Jul 2012 10:09:51 +0000 (UTC)

 Author: brueffer
 Date: Thu Jul 12 10:09:34 2012
 New Revision: 238393
 URL: http://svn.freebsd.org/changeset/base/238393
 
 Log:
   Add and utilize defines for the ATA device register.
   
   PR:		169764
   Submitted by:	Steven Hartland <steven.hartland@multiplay.co.uk>
   Reviewed by:	mav
   MFC after:	2 weeks
 
 Modified:
   head/sys/cam/ata/ata_all.c
   head/sys/sys/ata.h
 
 Modified: head/sys/cam/ata/ata_all.c
 ==============================================================================
 --- head/sys/cam/ata/ata_all.c	Thu Jul 12 07:34:09 2012	(r238392)
 +++ head/sys/cam/ata/ata_all.c	Thu Jul 12 10:09:34 2012	(r238393)
 @@ -359,7 +359,7 @@ ata_28bit_cmd(struct ccb_ataio *ataio, u
  	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;
  }
  
 @@ -384,7 +384,7 @@ ata_48bit_cmd(struct ccb_ataio *ataio, u
  	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;
 @@ -404,7 +404,7 @@ ata_ncq_cmd(struct ccb_ataio *ataio, uin
  	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;
 
 Modified: head/sys/sys/ata.h
 ==============================================================================
 --- head/sys/sys/ata.h	Thu Jul 12 07:34:09 2012	(r238392)
 +++ head/sys/sys/ata.h	Thu Jul 12 10:09:34 2012	(r238393)
 @@ -261,6 +261,20 @@ struct ata_params {
  /*255*/ u_int16_t       integrity;
  } __packed;
  
 +/*
 + * ATA Device Register
 + *
 + * bit 7 Obsolete (was 1 in early ATA specs)
 + * bit 6 Sets LBA/CHS mode. 1=LBA, 0=CHS 
 + * bit 5 Obsolete (was 1 in early ATA specs)
 + * 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_LBA		0x40
 +
  
  /* ATA transfer modes */
  #define ATA_MODE_MASK           0x0f
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: brueffer 
State-Changed-When: Thu Jul 26 11:27:15 CEST 2012 
State-Changed-Why:  
MFCs done. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169764 
>Unformatted:
