Mon Sep 28 00:13:02 2009 UTC ()
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.


(snj)
diff -r1.924.4.2 -r1.924.4.3 src/sys/conf/files
diff -r1.20 -r1.20.4.1 src/sys/dev/ata/files.ata
diff -r0 -r1.3.2.2 src/sys/dev/ata/satafis_subr.c
diff -r0 -r1.1.4.2 src/sys/dev/ata/satafisreg.h
diff -r0 -r1.2.2.2 src/sys/dev/ata/satafisvar.h

cvs diff -r1.924.4.2 -r1.924.4.3 src/sys/conf/files (expand / switch to unified diff)

--- src/sys/conf/files 2009/08/07 06:43:27 1.924.4.2
+++ src/sys/conf/files 2009/09/28 00:13:02 1.924.4.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files,v 1.924.4.2 2009/08/07 06:43:27 snj Exp $ 1# $NetBSD: files,v 1.924.4.3 2009/09/28 00:13:02 snj Exp $
2 2
3# @(#)files.newconf 7.5 (Berkeley) 5/10/93 3# @(#)files.newconf 7.5 (Berkeley) 5/10/93
4 4
5version 20080610 5version 20080610
6 6
7# 7#
8# device classes 8# device classes
9# 9#
10devclass disk 10devclass disk
11devclass tape 11devclass tape
12devclass ifnet 12devclass ifnet
13devclass tty 13devclass tty
14devclass audiodev 14devclass audiodev
@@ -259,26 +259,27 @@ defflag opt_tftproot.h TFTPROOT TFTPROO @@ -259,26 +259,27 @@ defflag opt_tftproot.h TFTPROOT TFTPROO
259defflag opt_perfctrs.h PERFCTRS 259defflag opt_perfctrs.h PERFCTRS
260 260
261# Machine-independent device majors assignements 261# Machine-independent device majors assignements
262include "conf/majors" 262include "conf/majors"
263 263
264# generic attributes 264# generic attributes
265# 265#
266define audiobus { } 266define audiobus { }
267define midibus { } 267define midibus { }
268define midisyn 268define midisyn
269define videobus { } 269define videobus { }
270define ata {[channel = -1]} 270define ata {[channel = -1]}
271define sata 271define sata
 272define sata_fis
272define scsi_core 273define scsi_core
273define scsi {[channel = -1]}: scsi_core 274define scsi {[channel = -1]}: scsi_core
274define ata_hl {[drive = -1]} 275define ata_hl {[drive = -1]}
275define atapi { } 276define atapi { }
276define radiodev { } 277define radiodev { }
277define gpibdev {[address = -1]} 278define gpibdev {[address = -1]}
278define gpiobus { } 279define gpiobus { }
279define onewirebus { } 280define onewirebus { }
280define pckbport {[slot = -1]} 281define pckbport {[slot = -1]}
281define pckbport_machdep_cnattach 282define pckbport_machdep_cnattach
282define firmload 283define firmload
283 284
284# audio device attributes 285# audio device attributes

cvs diff -r1.20 -r1.20.4.1 src/sys/dev/ata/files.ata (expand / switch to unified diff)

--- src/sys/dev/ata/files.ata 2008/09/16 11:45:30 1.20
+++ src/sys/dev/ata/files.ata 2009/09/28 00:13:02 1.20.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files.ata,v 1.20 2008/09/16 11:45:30 tron Exp $ 1# $NetBSD: files.ata,v 1.20.4.1 2009/09/28 00:13:02 snj Exp $
2# 2#
3# Config file and device description for machine-independent devices 3# Config file and device description for machine-independent devices
4# which attach to ATA busses. Included by ports that need it. Ports 4# which attach to ATA busses. Included by ports that need it. Ports
5# that use it must provide their own "major" declarations for the 5# that use it must provide their own "major" declarations for the
6# appropriate devices. 6# appropriate devices.
7 7
8# ATA disks 8# ATA disks
9device wd: disk 9device wd: disk
10attach wd at ata_hl 10attach wd at ata_hl
11file dev/ata/wd.c wd needs-flag 11file dev/ata/wd.c wd needs-flag
12file dev/ata/ata_wdc.c wd & atabus & wdc_common 12file dev/ata/ata_wdc.c wd & atabus & wdc_common
13 13
14defflag WD_SOFTBADSECT 14defflag WD_SOFTBADSECT
@@ -21,13 +21,16 @@ file dev/ata/ata_raid.c ataraid needs @@ -21,13 +21,16 @@ file dev/ata/ata_raid.c ataraid needs
21file dev/ata/ata_raid_subr.c ataraid 21file dev/ata/ata_raid_subr.c ataraid
22file dev/ata/ata_raid_promise.c ataraid 22file dev/ata/ata_raid_promise.c ataraid
23file dev/ata/ata_raid_adaptec.c ataraid 23file dev/ata/ata_raid_adaptec.c ataraid
24file dev/ata/ata_raid_nvidia.c ataraid 24file dev/ata/ata_raid_nvidia.c ataraid
25file dev/ata/ata_raid_via.c ataraid 25file dev/ata/ata_raid_via.c ataraid
26file dev/ata/ata_raid_jmicron.c ataraid 26file dev/ata/ata_raid_jmicron.c ataraid
27file dev/ata/ata_raid_intel.c ataraid 27file dev/ata/ata_raid_intel.c ataraid
28 28
29attach ld at ataraid with ld_ataraid 29attach ld at ataraid with ld_ataraid
30file dev/ata/ld_ataraid.c ld_ataraid 30file dev/ata/ld_ataraid.c ld_ataraid
31 31
32# Common SATA subroutines 32# Common SATA subroutines
33file dev/ata/sata_subr.c sata needs-flag 33file dev/ata/sata_subr.c sata needs-flag
 34
 35# Common SATA FIS subroutines
 36file dev/ata/satafis_subr.c sata_fis

File Added: src/sys/dev/ata/satafis_subr.c
/* $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;
}

File Added: src/sys/dev/ata/satafisreg.h
/* $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_ */

File Added: src/sys/dev/ata/satafisvar.h
/* $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_ */