Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev satafis:



details:   https://anonhg.NetBSD.org/src/rev/8e019dd73939
branches:  trunk
changeset: 753713:8e019dd73939
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Wed Apr 07 17:51:16 2010 +0000

description:
satafis:
- Add function to parse RDH FIS for use in implementing AT_READREG.
- Correct and clean up some structure definitions.
- Sprinkle a bit of const.
- Remove dependency on <dev/ic/wdcreg.h>, WDCTL_4BIT doesn't seem
  to be specified by any recent ATA standard, and it seems to make
  no difference in practice.
- Stop using WDSD_IBM, these bits have been obsolete since before SATA.

siisata:
- Implement AT_READREG.
- Reap now-unneeded <dev/ic/wdcreg.h>.
- Whitespace and slight debug code cleanup.
- Some possibly-uncessary code reordering.

ahcisata:
- Implement AT_READREG.
- Reap now-unneeded <dev/ic/wdcreg.h>.

diffstat:

 sys/dev/ata/satafis_subr.c |  37 +++++++++++++----------------
 sys/dev/ata/satafisreg.h   |  20 ++++++++-------
 sys/dev/ata/satafisvar.h   |  10 ++++---
 sys/dev/ic/ahcisata_core.c |  29 +++++++++++------------
 sys/dev/ic/siisata.c       |  57 +++++++++++++++++++++------------------------
 sys/dev/ic/siisatareg.h    |  11 ++++++--
 6 files changed, 83 insertions(+), 81 deletions(-)

diffs (truncated from 438 to 300 lines):

diff -r d1b57e3d8f8c -r 8e019dd73939 sys/dev/ata/satafis_subr.c
--- a/sys/dev/ata/satafis_subr.c        Wed Apr 07 17:51:15 2010 +0000
+++ b/sys/dev/ata/satafis_subr.c        Wed Apr 07 17:51:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: satafis_subr.c,v 1.4 2009/10/19 18:41:12 bouyer Exp $ */
+/* $NetBSD: satafis_subr.c,v 1.5 2010/04/07 17:51:16 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2009 Jonathan A. Kollasch.
@@ -51,7 +51,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.4 2009/10/19 18:41:12 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.5 2010/04/07 17:51:16 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -64,8 +64,6 @@
 #include <dev/ata/satafisreg.h>
 #include <dev/ata/satafisvar.h>
 
-#include <dev/ic/wdcreg.h> /* for WDCTL_4BIT */
-
 #include "atapibus.h"
 
 void
@@ -74,7 +72,7 @@
        memset(fis, 0, RHD_FISLEN);
 
        fis[fis_type] = RHD_FISTYPE;
-       fis[rhd_cdpmp] = 0x80; /* xxx magic */
+       fis[rhd_c] = RHD_C;
        fis[rhd_command] = ata_c->r_command;
        fis[rhd_features] = ata_c->r_features;
        fis[rhd_sector] = ata_c->r_sector;
@@ -82,9 +80,6 @@
        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
@@ -98,7 +93,7 @@
        memset(fis, 0, RHD_FISLEN);
 
        fis[fis_type] = RHD_FISTYPE;
-       fis[rhd_cdpmp] = 0x80; /* xxx magic */
+       fis[rhd_c] = RHD_C;
        if (ata_bio->flags & ATA_LBA48) {
                fis[rhd_command] = (ata_bio->flags & ATA_READ) ?
                    WDCC_READDMA_EXT : WDCC_WRITEDMA_EXT;
@@ -120,8 +115,6 @@
        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
@@ -131,26 +124,30 @@
        memset(fis, 0, RHD_FISLEN);
 
        fis[fis_type] = RHD_FISTYPE;
-       fis[rhd_cdpmp] = 0x80; /* xxx magic */
+       fis[rhd_c] = RHD_C;
        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_rdh_parse(struct ata_channel *chp, uint8_t *fis)
+satafis_rdh_parse(struct ata_channel *chp, const uint8_t *fis)
 {
-#if 0
-       /* siisata doesn't do enough for this to work */
-       KASSERT(fis[fis_type] == RDH_FISTYPE);
-#endif
        chp->ch_status = fis[rdh_status];
        chp->ch_error = fis[rdh_error];
+}
 
-       return;
+void
+satafis_rdh_cmd_readreg(struct ata_command *ata_c, const uint8_t *fis)
+{
+       ata_c->r_command = fis[rdh_status];
+       ata_c->r_features = fis[rdh_error];
+       ata_c->r_error = fis[rdh_error];
+       ata_c->r_sector = fis[rdh_sector];
+       ata_c->r_cyl = fis[rdh_cyl_hi] << 8 | fis[rdh_cyl_lo];
+       ata_c->r_head = fis[rdh_dh];
+       ata_c->r_count = fis[rdh_seccnt];
 }
diff -r d1b57e3d8f8c -r 8e019dd73939 sys/dev/ata/satafisreg.h
--- a/sys/dev/ata/satafisreg.h  Wed Apr 07 17:51:15 2010 +0000
+++ b/sys/dev/ata/satafisreg.h  Wed Apr 07 17:51:16 2010 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: satafisreg.h,v 1.1 2009/06/17 03:07:51 jakllsch Exp $ */
+/* $NetBSD: satafisreg.h,v 1.2 2010/04/07 17:51:16 jakllsch Exp $ */
 
-/*-
- * Copyright (c) 2009 Jonathan A. Kollasch.
+/*
+ * Copyright (c) 2009, 2010 Jonathan A. Kollasch.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,8 @@
 
 #define RHD_FISTYPE 0x27
 #define RHD_FISLEN 20
-#define rhd_cdpmp 1 /* Command bit and PM port */
+#define rhd_c 1 /* Command bit and PM port */
+#define RHD_C 0x80
 #define rhd_command 2 /* wd_command */
 #define rhd_features 3 /* wd_precomp */
 #define rhd_sector 4 /* wd_sector */
@@ -50,17 +51,18 @@
 #define RDH_FISTYPE 0x34
 #define RDH_FISLEN 20
 #define rdh_i 1
+#define RDH_I 0x40
 #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 rdh_sector_exp 8
+#define rdh_cyl_lo_exp 9
+#define rdh_cyl_hi_exp 10
+#define rdh_seccnt 12
+#define rdh_seccnt_exp 13
 
 #define SDB_FISTYPE 0xA1
 #define SDB_FISLEN 8
diff -r d1b57e3d8f8c -r 8e019dd73939 sys/dev/ata/satafisvar.h
--- a/sys/dev/ata/satafisvar.h  Wed Apr 07 17:51:15 2010 +0000
+++ b/sys/dev/ata/satafisvar.h  Wed Apr 07 17:51:16 2010 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: satafisvar.h,v 1.2 2009/07/04 20:57:15 jakllsch Exp $ */
+/* $NetBSD: satafisvar.h,v 1.3 2010/04/07 17:51:16 jakllsch Exp $ */
 
-/*-
- * Copyright (c) 2009 Jonathan A. Kollasch.
+/*
+ * Copyright (c) 2009, 2010 Jonathan A. Kollasch.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@
 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_rdh_parse(struct ata_channel *, uint8_t *);
+
+void satafis_rdh_parse(struct ata_channel *, const uint8_t *);
+void satafis_rdh_cmd_readreg(struct ata_command *, const uint8_t *);
 
 #endif /* _DEV_ATA_FISVAR_H_ */
diff -r d1b57e3d8f8c -r 8e019dd73939 sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Wed Apr 07 17:51:15 2010 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Wed Apr 07 17:51:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.25 2010/03/12 19:03:14 jakllsch Exp $      */
+/*     $NetBSD: ahcisata_core.c,v 1.26 2010/04/07 17:51:16 jakllsch Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.25 2010/03/12 19:03:14 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.26 2010/04/07 17:51:16 jakllsch Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -39,12 +39,11 @@
 
 #include <uvm/uvm_extern.h>
 
-#include <dev/ic/wdcreg.h>
 #include <dev/ata/atareg.h>
 #include <dev/ata/satavar.h>
 #include <dev/ata/satareg.h>
+#include <dev/ata/satafisvar.h>
 #include <dev/ata/satafisreg.h>
-#include <dev/ata/satafisvar.h>
 #include <dev/ic/ahcisatavar.h>
 
 #include <dev/scsipi/scsi_all.h> /* for SCSI status */
@@ -790,6 +789,7 @@
        int slot = 0; /* XXX slot */
        struct ata_command *ata_c = xfer->c_cmd;
        struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
+       struct ahci_channel *achp = (struct ahci_channel *)chp;
 
        AHCIDEBUG_PRINT(("ahci_cmd_complete channel %d CMD 0x%x CI 0x%x\n",
            chp->ch_channel, AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)),
@@ -809,18 +809,17 @@
                wakeup(&chp->ch_queue->active_xfer);
                return 0;
        }
-       if (is) {
-               ata_c->r_head = 0;
-               ata_c->r_count = 0;
-               ata_c->r_sector = 0;
-               ata_c->r_cyl = 0;
-               if (chp->ch_status & WDCS_BSY) {
-                       ata_c->flags |= AT_TIMEOU;
-               } else if (chp->ch_status & WDCS_ERR) {
-                       ata_c->r_error = chp->ch_error;
-                       ata_c->flags |= AT_ERROR;
-               }
+
+       if (chp->ch_status & WDCS_BSY) {
+               ata_c->flags |= AT_TIMEOU;
+       } else if (chp->ch_status & WDCS_ERR) {
+               ata_c->r_error = chp->ch_error;
+               ata_c->flags |= AT_ERROR;
        }
+
+       if (ata_c->flags & AT_READREG)
+               satafis_rdh_cmd_readreg(ata_c, achp->ahcic_rfis->rfis_rfis);
+
        ahci_cmd_done(chp, xfer, slot);
        return 0;
 }
diff -r d1b57e3d8f8c -r 8e019dd73939 sys/dev/ic/siisata.c
--- a/sys/dev/ic/siisata.c      Wed Apr 07 17:51:15 2010 +0000
+++ b/sys/dev/ic/siisata.c      Wed Apr 07 17:51:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.9 2010/01/30 16:16:35 jakllsch Exp $ */
+/* $NetBSD: siisata.c,v 1.10 2010/04/07 17:51:16 jakllsch Exp $ */
 
 /* from ahcisata_core.c */
 
@@ -54,7 +54,7 @@
  */
 
 /*
- * Copyright (c) 2007, 2008, 2009 Jonathan A. Kollasch.
+ * Copyright (c) 2007, 2008, 2009, 2010 Jonathan A. Kollasch.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.9 2010/01/30 16:16:35 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.10 2010/04/07 17:51:16 jakllsch Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -96,20 +96,17 @@
 #include <dev/ata/satavar.h>
 #include <dev/ata/satareg.h>
 #include <dev/ata/satafisvar.h>
+#include <dev/ata/satafisreg.h>
 #include <dev/ic/siisatavar.h>
-#include <dev/ic/wdcreg.h>
+#include <dev/ic/siisatareg.h>
 
 #include <dev/scsipi/scsi_all.h> /* for SCSI status */
 
 #include "atapibus.h"
 
 #ifdef SIISATA_DEBUG
-#if 0
-int siisata_debug_mask = 0xffff;
-#else
 int siisata_debug_mask = 0;
 #endif
-#endif
 
 #define ATA_DELAY 10000                /* 10s for a drive I/O */
 
@@ -851,7 +848,7 @@
 #ifdef SIISATA_DEBUG
        struct siisata_softc *sc = (struct siisata_softc *)chp->ch_atac;
 #endif
-       



Home | Main Index | Thread Index | Old Index