Mon Sep 28 00:13:52 2009 UTC ()
Pull up following revision(s) (requested by jakllsch in ticket #1023):
	sys/dev/ata/satafis_subr.c: revision 1.2
Have the FIS code pre-zero the FIS.


(snj)
diff -r1.3.2.2 -r1.3.2.3 src/sys/dev/ata/satafis_subr.c

cvs diff -r1.3.2.2 -r1.3.2.3 src/sys/dev/ata/satafis_subr.c (expand / switch to unified diff)

--- src/sys/dev/ata/satafis_subr.c 2009/09/28 00:13:02 1.3.2.2
+++ src/sys/dev/ata/satafis_subr.c 2009/09/28 00:13:52 1.3.2.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: satafis_subr.c,v 1.3.2.2 2009/09/28 00:13:02 snj Exp $ */ 1/* $NetBSD: satafis_subr.c,v 1.3.2.3 2009/09/28 00:13:52 snj Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2009 Jonathan A. Kollasch. 4 * Copyright (c) 2009 Jonathan A. Kollasch.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -46,67 +46,72 @@ @@ -46,67 +46,72 @@
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 * 55 *
56 */ 56 */
57 57
58#include <sys/cdefs.h> 58#include <sys/cdefs.h>
59__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.3.2.2 2009/09/28 00:13:02 snj Exp $"); 59__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.3.2.3 2009/09/28 00:13:52 snj Exp $");
60 60
61#include <sys/param.h> 61#include <sys/param.h>
 62#include <sys/systm.h>
62 63
63#include <sys/disklabel.h> 64#include <sys/disklabel.h>
64 65
65#include <dev/ata/atareg.h> 66#include <dev/ata/atareg.h>
66#include <dev/ata/atavar.h> 67#include <dev/ata/atavar.h>
67 68
68#include <dev/ata/satafisreg.h> 69#include <dev/ata/satafisreg.h>
69#include <dev/ata/satafisvar.h> 70#include <dev/ata/satafisvar.h>
70 71
71#include <dev/ic/wdcreg.h> /* for WDCTL_4BIT */ 72#include <dev/ic/wdcreg.h> /* for WDCTL_4BIT */
72 73
73#include "atapibus.h" 74#include "atapibus.h"
74 75
75void 76void
76satafis_rhd_construct_cmd(struct ata_command *ata_c, uint8_t *fis) 77satafis_rhd_construct_cmd(struct ata_command *ata_c, uint8_t *fis)
77{ 78{
 79 memset(fis, 0, RHD_FISLEN);
 80
78 fis[fis_type] = RHD_FISTYPE; 81 fis[fis_type] = RHD_FISTYPE;
79 fis[rhd_cdpmp] = 0x80; /* xxx magic */ 82 fis[rhd_cdpmp] = 0x80; /* xxx magic */
80 fis[rhd_command] = ata_c->r_command; 83 fis[rhd_command] = ata_c->r_command;
81 fis[rhd_features] = ata_c->r_features; 84 fis[rhd_features] = ata_c->r_features;
82 fis[rhd_sector] = ata_c->r_sector; 85 fis[rhd_sector] = ata_c->r_sector;
83 fis[rhd_cyl_lo] = ata_c->r_cyl & 0xff; 86 fis[rhd_cyl_lo] = ata_c->r_cyl & 0xff;
84 fis[rhd_cyl_hi] = (ata_c->r_cyl >> 8) & 0xff; 87 fis[rhd_cyl_hi] = (ata_c->r_cyl >> 8) & 0xff;
85 fis[rhd_dh] = ata_c->r_head & 0x0f; 88 fis[rhd_dh] = ata_c->r_head & 0x0f;
86 fis[rhd_seccnt] = ata_c->r_count; 89 fis[rhd_seccnt] = ata_c->r_count;
87 fis[rhd_control] = WDCTL_4BIT; 90 fis[rhd_control] = WDCTL_4BIT;
88 91
89 return; 92 return;
90} 93}
91 94
92void 95void
93satafis_rhd_construct_bio(struct ata_xfer *xfer, uint8_t *fis) 96satafis_rhd_construct_bio(struct ata_xfer *xfer, uint8_t *fis)
94{ 97{
95 struct ata_bio *ata_bio = xfer->c_cmd; 98 struct ata_bio *ata_bio = xfer->c_cmd;
96 int nblks; 99 int nblks;
97 100
98 nblks = xfer->c_bcount / ata_bio->lp->d_secsize; 101 nblks = xfer->c_bcount / ata_bio->lp->d_secsize;
99 102
 103 memset(fis, 0, RHD_FISLEN);
 104
100 fis[fis_type] = RHD_FISTYPE; 105 fis[fis_type] = RHD_FISTYPE;
101 fis[rhd_cdpmp] = 0x80; /* xxx magic */ 106 fis[rhd_cdpmp] = 0x80; /* xxx magic */
102 if (ata_bio->flags & ATA_LBA48) { 107 if (ata_bio->flags & ATA_LBA48) {
103 fis[rhd_command] = (ata_bio->flags & ATA_READ) ? 108 fis[rhd_command] = (ata_bio->flags & ATA_READ) ?
104 WDCC_READDMA_EXT : WDCC_WRITEDMA_EXT; 109 WDCC_READDMA_EXT : WDCC_WRITEDMA_EXT;
105 } else { 110 } else {
106 fis[rhd_command] = 111 fis[rhd_command] =
107 (ata_bio->flags & ATA_READ) ? WDCC_READDMA : WDCC_WRITEDMA; 112 (ata_bio->flags & ATA_READ) ? WDCC_READDMA : WDCC_WRITEDMA;
108 } 113 }
109 fis[rhd_sector] = ata_bio->blkno & 0xff; 114 fis[rhd_sector] = ata_bio->blkno & 0xff;
110 fis[rhd_cyl_lo] = (ata_bio->blkno >> 8) & 0xff; 115 fis[rhd_cyl_lo] = (ata_bio->blkno >> 8) & 0xff;
111 fis[rhd_cyl_hi] = (ata_bio->blkno >> 16) & 0xff; 116 fis[rhd_cyl_hi] = (ata_bio->blkno >> 16) & 0xff;
112 if (ata_bio->flags & ATA_LBA48) { 117 if (ata_bio->flags & ATA_LBA48) {
@@ -118,26 +123,28 @@ satafis_rhd_construct_bio(struct ata_xfe @@ -118,26 +123,28 @@ satafis_rhd_construct_bio(struct ata_xfe
118 fis[rhd_dh] = ((ata_bio->blkno >> 24) & 0x0f) | WDSD_LBA; 123 fis[rhd_dh] = ((ata_bio->blkno >> 24) & 0x0f) | WDSD_LBA;
119 } 124 }
120 fis[rhd_seccnt] = nblks & 0xff; 125 fis[rhd_seccnt] = nblks & 0xff;
121 fis[rhd_seccnt_exp] = (ata_bio->flags & ATA_LBA48) ? 126 fis[rhd_seccnt_exp] = (ata_bio->flags & ATA_LBA48) ?
122 ((nblks >> 8) & 0xff) : 0; 127 ((nblks >> 8) & 0xff) : 0;
123 fis[rhd_control] = WDCTL_4BIT; 128 fis[rhd_control] = WDCTL_4BIT;
124 return; 129 return;
125} 130}
126 131
127#if NATAPIBUS > 0 132#if NATAPIBUS > 0
128void 133void
129satafis_rhd_construct_atapi(struct ata_xfer *xfer, uint8_t *fis) 134satafis_rhd_construct_atapi(struct ata_xfer *xfer, uint8_t *fis)
130{ 135{
 136 memset(fis, 0, RHD_FISLEN);
 137
131 fis[fis_type] = RHD_FISTYPE; 138 fis[fis_type] = RHD_FISTYPE;
132 fis[rhd_cdpmp] = 0x80; /* xxx magic */ 139 fis[rhd_cdpmp] = 0x80; /* xxx magic */
133 fis[rhd_command] = ATAPI_PKT_CMD; 140 fis[rhd_command] = ATAPI_PKT_CMD;
134 fis[rhd_features] = (xfer->c_flags & C_DMA) ? 141 fis[rhd_features] = (xfer->c_flags & C_DMA) ?
135 ATAPI_PKT_CMD_FTRE_DMA : 0; 142 ATAPI_PKT_CMD_FTRE_DMA : 0;
136 fis[rhd_dh] = WDSD_IBM; /* XXX or WDSD_LBA? */ 143 fis[rhd_dh] = WDSD_IBM; /* XXX or WDSD_LBA? */
137 fis[rhd_control] = WDCTL_4BIT; 144 fis[rhd_control] = WDCTL_4BIT;
138 145
139 return; 146 return;
140} 147}
141#endif /* NATAPIBUS */ 148#endif /* NATAPIBUS */
142 149
143void 150void