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
--- 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 | |
5 | version 20080610 | | 5 | version 20080610 |
6 | | | 6 | |
7 | # | | 7 | # |
8 | # device classes | | 8 | # device classes |
9 | # | | 9 | # |
10 | devclass disk | | 10 | devclass disk |
11 | devclass tape | | 11 | devclass tape |
12 | devclass ifnet | | 12 | devclass ifnet |
13 | devclass tty | | 13 | devclass tty |
14 | devclass audiodev | | 14 | devclass audiodev |
| @@ -259,26 +259,27 @@ defflag opt_tftproot.h TFTPROOT TFTPROO | | | @@ -259,26 +259,27 @@ defflag opt_tftproot.h TFTPROOT TFTPROO |
259 | defflag opt_perfctrs.h PERFCTRS | | 259 | defflag opt_perfctrs.h PERFCTRS |
260 | | | 260 | |
261 | # Machine-independent device majors assignements | | 261 | # Machine-independent device majors assignements |
262 | include "conf/majors" | | 262 | include "conf/majors" |
263 | | | 263 | |
264 | # generic attributes | | 264 | # generic attributes |
265 | # | | 265 | # |
266 | define audiobus { } | | 266 | define audiobus { } |
267 | define midibus { } | | 267 | define midibus { } |
268 | define midisyn | | 268 | define midisyn |
269 | define videobus { } | | 269 | define videobus { } |
270 | define ata {[channel = -1]} | | 270 | define ata {[channel = -1]} |
271 | define sata | | 271 | define sata |
| | | 272 | define sata_fis |
272 | define scsi_core | | 273 | define scsi_core |
273 | define scsi {[channel = -1]}: scsi_core | | 274 | define scsi {[channel = -1]}: scsi_core |
274 | define ata_hl {[drive = -1]} | | 275 | define ata_hl {[drive = -1]} |
275 | define atapi { } | | 276 | define atapi { } |
276 | define radiodev { } | | 277 | define radiodev { } |
277 | define gpibdev {[address = -1]} | | 278 | define gpibdev {[address = -1]} |
278 | define gpiobus { } | | 279 | define gpiobus { } |
279 | define onewirebus { } | | 280 | define onewirebus { } |
280 | define pckbport {[slot = -1]} | | 281 | define pckbport {[slot = -1]} |
281 | define pckbport_machdep_cnattach | | 282 | define pckbport_machdep_cnattach |
282 | define firmload | | 283 | define firmload |
283 | | | 284 | |
284 | # audio device attributes | | 285 | # audio device attributes |
--- 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 |
9 | device wd: disk | | 9 | device wd: disk |
10 | attach wd at ata_hl | | 10 | attach wd at ata_hl |
11 | file dev/ata/wd.c wd needs-flag | | 11 | file dev/ata/wd.c wd needs-flag |
12 | file dev/ata/ata_wdc.c wd & atabus & wdc_common | | 12 | file dev/ata/ata_wdc.c wd & atabus & wdc_common |
13 | | | 13 | |
14 | defflag WD_SOFTBADSECT | | 14 | defflag 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 |
21 | file dev/ata/ata_raid_subr.c ataraid | | 21 | file dev/ata/ata_raid_subr.c ataraid |
22 | file dev/ata/ata_raid_promise.c ataraid | | 22 | file dev/ata/ata_raid_promise.c ataraid |
23 | file dev/ata/ata_raid_adaptec.c ataraid | | 23 | file dev/ata/ata_raid_adaptec.c ataraid |
24 | file dev/ata/ata_raid_nvidia.c ataraid | | 24 | file dev/ata/ata_raid_nvidia.c ataraid |
25 | file dev/ata/ata_raid_via.c ataraid | | 25 | file dev/ata/ata_raid_via.c ataraid |
26 | file dev/ata/ata_raid_jmicron.c ataraid | | 26 | file dev/ata/ata_raid_jmicron.c ataraid |
27 | file dev/ata/ata_raid_intel.c ataraid | | 27 | file dev/ata/ata_raid_intel.c ataraid |
28 | | | 28 | |
29 | attach ld at ataraid with ld_ataraid | | 29 | attach ld at ataraid with ld_ataraid |
30 | file dev/ata/ld_ataraid.c ld_ataraid | | 30 | file dev/ata/ld_ataraid.c ld_ataraid |
31 | | | 31 | |
32 | # Common SATA subroutines | | 32 | # Common SATA subroutines |
33 | file dev/ata/sata_subr.c sata needs-flag | | 33 | file dev/ata/sata_subr.c sata needs-flag |
| | | 34 | |
| | | 35 | # Common SATA FIS subroutines |
| | | 36 | file dev/ata/satafis_subr.c sata_fis |
/* $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;
}
/* $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_ */
/* $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_ */