Module Name:    src
Committed By:   snj
Date:           Mon Sep 28 00:13:02 UTC 2009

Modified Files:
        src/sys/conf [netbsd-5]: files
        src/sys/dev/ata [netbsd-5]: files.ata
Added Files:
        src/sys/dev/ata [netbsd-5]: satafis_subr.c satafisreg.h satafisvar.h

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1023):
        sys/conf/files: revision 1.947
        sys/dev/ata/files.ata: revision 1.21
        sys/dev/ata/satafis_subr.c: revision 1.1
        sys/dev/ata/satafisreg.h: revision 1.1
        sys/dev/ata/satafisvar.h: revision 1.1
ahcisata(4) and siisata(4) use similar SATA FIS functions, share them.


To generate a diff of this commit:
cvs rdiff -u -r1.924.4.2 -r1.924.4.3 src/sys/conf/files
cvs rdiff -u -r1.20 -r1.20.4.1 src/sys/dev/ata/files.ata
cvs rdiff -u -r0 -r1.3.2.2 src/sys/dev/ata/satafis_subr.c
cvs rdiff -u -r0 -r1.1.4.2 src/sys/dev/ata/satafisreg.h
cvs rdiff -u -r0 -r1.2.2.2 src/sys/dev/ata/satafisvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.924.4.2 src/sys/conf/files:1.924.4.3
--- src/sys/conf/files:1.924.4.2	Fri Aug  7 06:43:27 2009
+++ src/sys/conf/files	Mon Sep 28 00:13:02 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.924.4.2 2009/08/07 06:43:27 snj Exp $
+#	$NetBSD: files,v 1.924.4.3 2009/09/28 00:13:02 snj Exp $
 
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
@@ -269,6 +269,7 @@
 define	videobus	{ }
 define	ata	        {[channel = -1]}
 define	sata
+define	sata_fis
 define	scsi_core
 define	scsi		{[channel = -1]}: scsi_core
 define	ata_hl		{[drive = -1]}

Index: src/sys/dev/ata/files.ata
diff -u src/sys/dev/ata/files.ata:1.20 src/sys/dev/ata/files.ata:1.20.4.1
--- src/sys/dev/ata/files.ata:1.20	Tue Sep 16 11:45:30 2008
+++ src/sys/dev/ata/files.ata	Mon Sep 28 00:13:02 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ata,v 1.20 2008/09/16 11:45:30 tron Exp $
+#	$NetBSD: files.ata,v 1.20.4.1 2009/09/28 00:13:02 snj Exp $
 #
 # Config file and device description for machine-independent devices
 # which attach to ATA busses.  Included by ports that need it.  Ports
@@ -31,3 +31,6 @@
 
 # Common SATA subroutines
 file	dev/ata/sata_subr.c		sata			needs-flag
+
+# Common SATA FIS subroutines
+file	dev/ata/satafis_subr.c		sata_fis

Added files:

Index: src/sys/dev/ata/satafis_subr.c
diff -u /dev/null src/sys/dev/ata/satafis_subr.c:1.3.2.2
--- /dev/null	Mon Sep 28 00:13:02 2009
+++ src/sys/dev/ata/satafis_subr.c	Mon Sep 28 00:13:02 2009
@@ -0,0 +1,151 @@
+/* $NetBSD: satafis_subr.c,v 1.3.2.2 2009/09/28 00:13:02 snj Exp $ */
+
+/*-
+ * Copyright (c) 2009 Jonathan A. Kollasch.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 2006 Manuel Bouyer.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Manuel Bouyer.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.3.2.2 2009/09/28 00:13:02 snj Exp $");
+
+#include <sys/param.h>
+
+#include <sys/disklabel.h>
+
+#include <dev/ata/atareg.h>
+#include <dev/ata/atavar.h>
+
+#include <dev/ata/satafisreg.h>
+#include <dev/ata/satafisvar.h>
+
+#include <dev/ic/wdcreg.h> /* for WDCTL_4BIT */
+
+#include "atapibus.h"
+
+void
+satafis_rhd_construct_cmd(struct ata_command *ata_c, uint8_t *fis)
+{
+	fis[fis_type] = RHD_FISTYPE;
+	fis[rhd_cdpmp] = 0x80; /* xxx magic */
+	fis[rhd_command] = ata_c->r_command;
+	fis[rhd_features] = ata_c->r_features;
+	fis[rhd_sector] = ata_c->r_sector;
+	fis[rhd_cyl_lo] = ata_c->r_cyl & 0xff;
+	fis[rhd_cyl_hi] = (ata_c->r_cyl >> 8) & 0xff;
+	fis[rhd_dh] = ata_c->r_head & 0x0f;
+	fis[rhd_seccnt] = ata_c->r_count;
+	fis[rhd_control] = WDCTL_4BIT;
+
+	return;
+}
+
+void
+satafis_rhd_construct_bio(struct ata_xfer *xfer, uint8_t *fis)
+{
+	struct ata_bio *ata_bio = xfer->c_cmd;
+	int nblks;
+
+	nblks = xfer->c_bcount / ata_bio->lp->d_secsize;
+
+	fis[fis_type] = RHD_FISTYPE;
+	fis[rhd_cdpmp] = 0x80; /* xxx magic */
+	if (ata_bio->flags & ATA_LBA48) {
+		fis[rhd_command] = (ata_bio->flags & ATA_READ) ?
+		    WDCC_READDMA_EXT : WDCC_WRITEDMA_EXT;
+	} else {
+		fis[rhd_command] =
+		    (ata_bio->flags & ATA_READ) ? WDCC_READDMA : WDCC_WRITEDMA;
+	}
+	fis[rhd_sector] = ata_bio->blkno & 0xff;
+	fis[rhd_cyl_lo] = (ata_bio->blkno >> 8) & 0xff;
+	fis[rhd_cyl_hi] = (ata_bio->blkno >> 16) & 0xff;
+	if (ata_bio->flags & ATA_LBA48) {
+		fis[rhd_dh] = WDSD_LBA;
+		fis[rhd_sector_exp] = (ata_bio->blkno >> 24) & 0xff;
+		fis[rhd_cyl_lo_exp] = (ata_bio->blkno >> 32) & 0xff;
+		fis[rhd_cyl_hi_exp] = (ata_bio->blkno >> 40) & 0xff;
+	} else {
+		fis[rhd_dh] = ((ata_bio->blkno >> 24) & 0x0f) | WDSD_LBA;
+	}
+	fis[rhd_seccnt] = nblks & 0xff;
+	fis[rhd_seccnt_exp] = (ata_bio->flags & ATA_LBA48) ?
+	    ((nblks >> 8) & 0xff) : 0;
+	fis[rhd_control] = WDCTL_4BIT;
+	return;
+}
+
+#if NATAPIBUS > 0
+void
+satafis_rhd_construct_atapi(struct ata_xfer *xfer, uint8_t *fis)
+{
+	fis[fis_type] = RHD_FISTYPE;
+	fis[rhd_cdpmp] = 0x80; /* xxx magic */
+	fis[rhd_command] = ATAPI_PKT_CMD;
+	fis[rhd_features] = (xfer->c_flags & C_DMA) ?
+	    ATAPI_PKT_CMD_FTRE_DMA : 0;
+	fis[rhd_dh] = WDSD_IBM; /* XXX or WDSD_LBA? */
+	fis[rhd_control] = WDCTL_4BIT;
+
+	return;
+}
+#endif /* NATAPIBUS */
+
+void
+satafis_sdb_parse(struct ata_channel *chp, uint8_t *fis)
+{
+	KASSERT(fis[fis_type] != SDB_FISTYPE);
+	chp->ch_status = fis[sdb_status];
+	chp->ch_error = fis[sdb_error];
+
+	return;
+}

Index: src/sys/dev/ata/satafisreg.h
diff -u /dev/null src/sys/dev/ata/satafisreg.h:1.1.4.2
--- /dev/null	Mon Sep 28 00:13:02 2009
+++ src/sys/dev/ata/satafisreg.h	Mon Sep 28 00:13:02 2009
@@ -0,0 +1,71 @@
+/* $NetBSD: satafisreg.h,v 1.1.4.2 2009/09/28 00:13:02 snj Exp $ */
+
+/*-
+ * Copyright (c) 2009 Jonathan A. Kollasch.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_ATA_FISREG_H_
+#define _DEV_ATA_FISREG_H_
+
+#define fis_type 0
+
+#define RHD_FISTYPE 0x27
+#define RHD_FISLEN 20
+#define rhd_cdpmp 1 /* Command bit and PM port */
+#define rhd_command 2 /* wd_command */
+#define rhd_features 3 /* wd_precomp */
+#define rhd_sector 4 /* wd_sector */
+#define rhd_cyl_lo 5 /* wd_cyl_lo */
+#define rhd_cyl_hi 6 /* wd_cyl_hi */
+#define rhd_dh 7 /* wd_sdh */
+#define rhd_sector_exp 8 
+#define rhd_cyl_lo_exp 9
+#define rhd_cyl_hi_exp 10
+#define rhd_features_exp 11
+#define rhd_seccnt 12
+#define rhd_seccnt_exp 13
+#define rhd_control 15
+
+#define RDH_FISTYPE 0x34
+#define RDH_FISLEN 20
+#define rdh_i 1
+#define rdh_status 2
+#define rdh_error 3
+#define rdh_sector 4 /* wd_sector */
+#define rdh_cyl_lo 5 /* wd_cyl_lo */
+#define rdh_cyl_hi 6 /* wd_cyl_hi */
+#define rdh_dh 7 /* wd_sdh */
+#define rhd_sector_exp 8
+#define rhd_cyl_lo_exp 9
+#define rhd_cyl_hi_exp 10
+#define rhd_seccnt 12
+#define rhd_seccnt_exp 13
+
+#define SDB_FISTYPE 0xA1
+#define SDB_FISLEN 8
+#define sdb_i 1
+#define sdb_status 2
+#define sdb_error 3
+
+#endif /* _DEV_ATA_FISREG_H_ */

Index: src/sys/dev/ata/satafisvar.h
diff -u /dev/null src/sys/dev/ata/satafisvar.h:1.2.2.2
--- /dev/null	Mon Sep 28 00:13:02 2009
+++ src/sys/dev/ata/satafisvar.h	Mon Sep 28 00:13:02 2009
@@ -0,0 +1,38 @@
+/* $NetBSD: satafisvar.h,v 1.2.2.2 2009/09/28 00:13:02 snj Exp $ */
+
+/*-
+ * Copyright (c) 2009 Jonathan A. Kollasch.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_ATA_FISVAR_H_
+#define _DEV_ATA_FISVAR_H_
+
+#include <dev/ata/atavar.h>
+
+void satafis_rhd_construct_cmd(struct ata_command *, uint8_t *);
+void satafis_rhd_construct_bio(struct ata_xfer *, uint8_t *);
+void satafis_rhd_construct_atapi(struct ata_xfer *, uint8_t *);
+void satafis_sdb_parse(struct ata_channel *, uint8_t *);
+
+#endif /* _DEV_ATA_FISVAR_H_ */

Reply via email to