Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Rework version printout to be more future proof.



details:   https://anonhg.NetBSD.org/src/rev/098f49db559f
branches:  trunk
changeset: 768557:098f49db559f
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat Aug 20 16:03:48 2011 +0000

description:
Rework version printout to be more future proof.
Rework features printout using snprintb.

diffstat:

 sys/dev/ic/ahcisata_core.c |  53 ++++++++++++++++++++++++++++-----------------
 sys/dev/ic/ahcisatareg.h   |  12 ++++++---
 2 files changed, 41 insertions(+), 24 deletions(-)

diffs (108 lines):

diff -r 6be33f253959 -r 098f49db559f sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Sat Aug 20 14:38:09 2011 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Sat Aug 20 16:03:48 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.31 2011/01/10 11:18:14 tsutsui Exp $       */
+/*     $NetBSD: ahcisata_core.c,v 1.32 2011/08/20 16:03:48 jakllsch Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.31 2011/01/10 11:18:14 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.32 2011/08/20 16:03:48 jakllsch Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -211,6 +211,7 @@
        struct ata_channel *chp;
        int error;
        int dmasize;
+       char buf[128];
        void *cmdhp;
        void *cmdtblp;
 
@@ -221,25 +222,37 @@
        sc->sc_atac.atac_nchannels = (ahci_cap & AHCI_CAP_NPMASK) + 1;
        sc->sc_ncmds = ((ahci_cap & AHCI_CAP_NCS) >> 8) + 1;
        ahci_rev = AHCI_READ(sc, AHCI_VS);
-       aprint_normal("%s: AHCI revision ", AHCINAME(sc));
-       switch(ahci_rev) {
-       case AHCI_VS_10:
-               aprint_normal("1.0");
-               break;
-       case AHCI_VS_11:
-               aprint_normal("1.1");
-               break;
-       case AHCI_VS_12:
-               aprint_normal("1.2");
-               break;
-       default:
-               aprint_normal("0x%x", ahci_rev);
-               break;
-       }
+       snprintb(buf, sizeof(buf), "\177\020"
+                       /* "f\000\005NP\0" */
+                       "b\005SXS\0"
+                       "b\006EMS\0"
+                       "b\007CCCS\0"
+                       /* "f\010\005NCS\0" */
+                       "b\015PSC\0"
+                       "b\016SSC\0"
+                       "b\017PMD\0"
+                       "b\020FBSS\0"
+                       "b\021SPM\0"
+                       "b\022SAM\0"
+                       "b\023SNZO\0"
+                       "f\024\003ISS\0"
+                       "=\001Gen1\0"
+                       "=\002Gen2\0"
+                       "=\003Gen3\0"
+                       "b\030SCLO\0"
+                       "b\031SAL\0"
+                       "b\032SALP\0"
+                       "b\033SSS\0"
+                       "b\034SMPS\0"
+                       "b\035SSNTF\0"
+                       "b\036SNCQ\0"
+                       "b\037S64A\0"
+                       "\0", ahci_cap);
+       aprint_normal_dev(sc->sc_atac.atac_dev, "AHCI revision %u.%u"
+           ", %d ports, %d slots, CAP %s\n",
+           AHCI_VS_MJR(ahci_rev), AHCI_VS_MNR(ahci_rev),
+           sc->sc_atac.atac_nchannels, sc->sc_ncmds, buf);
 
-       aprint_normal(", %d ports, %d command slots, features 0x%x\n",
-           sc->sc_atac.atac_nchannels, sc->sc_ncmds,
-           ahci_cap & ~(AHCI_CAP_NPMASK|AHCI_CAP_NCS));
        sc->sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DMA | ATAC_CAP_UDMA;
        sc->sc_atac.atac_cap |= sc->sc_atac_capflags;
        sc->sc_atac.atac_pio_cap = 4;
diff -r 6be33f253959 -r 098f49db559f sys/dev/ic/ahcisatareg.h
--- a/sys/dev/ic/ahcisatareg.h  Sat Aug 20 14:38:09 2011 +0000
+++ b/sys/dev/ic/ahcisatareg.h  Sat Aug 20 16:03:48 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisatareg.h,v 1.7 2010/07/20 19:24:11 jakllsch Exp $ */
+/*     $NetBSD: ahcisatareg.h,v 1.8 2011/08/20 16:03:48 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -137,9 +137,13 @@
 #define AHCI_PI                0x0c /* Port implemented: one bit per port */
 
 #define AHCI_VS                0x10 /* AHCI version */
-#define        AHCI_VS_10      0x00010000 /* AHCI spec 1.0 */
-#define        AHCI_VS_11      0x00010100 /* AHCI spec 1.1 */
-#define        AHCI_VS_12      0x00010200 /* AHCI spec 1.2 */
+#define                AHCI_VS_095     0x00000905 /* AHCI spec 0.95 */
+#define                AHCI_VS_100     0x00010000 /* AHCI spec 1.0 */
+#define                AHCI_VS_110     0x00010100 /* AHCI spec 1.1 */
+#define                AHCI_VS_120     0x00010200 /* AHCI spec 1.2 */
+#define                AHCI_VS_130     0x00010300 /* AHCI spec 1.3 */
+#define AHCI_VS_MJR(v) ((unsigned int)__SHIFTOUT(v, __BITS(31, 16)))
+#define AHCI_VS_MNR(v) ((unsigned int)__SHIFTOUT(v, __BITS(15, 8)) * 10 + (unsigned int)__SHIFTOUT(v, __BITS(7, 0) * 1))
 
 #define AHCI_CC_CTL    0x14 /* command completion coalescing control */
 #define        AHCI_CC_TV_MASK 0xffff0000 /* timeout value */



Home | Main Index | Thread Index | Old Index