Print this page
2601 kctl_isadep.c should support four serial consoles

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/intel/kmdb/kctl/kctl_isadep.c
          +++ new/usr/src/cmd/mdb/intel/kmdb/kctl/kctl_isadep.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
       23 + * Copyright (c) 2012 Gary Mills
       24 + *
  23   25   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   26   * Use is subject to license terms.
  25   27   */
  26   28  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   29  #include <kmdb/kmdb_auxv.h>
  30   30  #include <kmdb/kctl/kctl.h>
  31   31  
  32   32  #include <sys/bootconf.h>
  33   33  #include <sys/kobj.h>
  34   34  #include <sys/kobj_impl.h>
  35   35  #include <sys/cpuvar.h>
  36   36  #include <sys/kdi_impl.h>
  37   37  #include <sys/x86_archext.h>
  38   38  #include <sys/controlregs.h>
↓ open down ↓ 32 lines elided ↑ open up ↑
  71   71  
  72   72          ddi_prop_free(val);
  73   73          return (ret);
  74   74  }
  75   75  
  76   76  /*
  77   77   * We don't have any property-walking routines, so we have to specifically
  78   78   * query and thus have guilty knowledge of the properties that the
  79   79   * debugger wants to see.
  80   80   *
  81      - * Here actually we only support four console properties:
  82      - *     input-device, output-device, ttya-mode, ttyb-mode.
       81 + * Here actually we only support six console properties:
       82 + *     input-device, output-device, tty[a-d]-mode.
  83   83   */
  84      -#define KCTL_PROPNV_NENT                4
       84 +#define KCTL_PROPNV_NIODEV      2
       85 +#define KCTL_PROPNV_NTTYMD      4
       86 +#define KCTL_PROPNV_NENT        (KCTL_PROPNV_NIODEV + KCTL_PROPNV_NTTYMD)
  85   87  
  86   88  static kmdb_auxv_nv_t *
  87   89  kctl_pcache_create(int *nprops)
  88   90  {
  89   91          int (*preader)(char *, char *, int);
  90   92          kmdb_auxv_nv_t *pnv;
  91   93          size_t psz = sizeof (kmdb_auxv_nv_t) * KCTL_PROPNV_NENT;
       94 +        char *inputdev, *outputdev;
       95 +        int i;
       96 +        char ttymode[] = "ttyX-mode";
  92   97  
  93   98          if (kctl.kctl_boot_loaded) {
  94   99                  preader = kctl_boot_prop_read;
  95  100          } else {
  96  101                  preader = kctl_ddi_prop_read;
  97  102          }
  98  103  
  99  104          pnv = kobj_alloc(psz, KM_WAIT);
      105 +        inputdev = (&pnv[0])->kanv_val;
      106 +        outputdev = (&pnv[1])->kanv_val;
 100  107  
      108 +        /* Set the property names. */
 101  109          (void) strcpy((&pnv[0])->kanv_name, "input-device");
 102  110          (void) strcpy((&pnv[1])->kanv_name, "output-device");
 103      -        (void) strcpy((&pnv[2])->kanv_name, "ttya-mode");
 104      -        (void) strcpy((&pnv[3])->kanv_name, "ttyb-mode");
      111 +        for (i = 0; i < KCTL_PROPNV_NTTYMD; i++) {
      112 +                ttymode[3] = 'a' + i;
      113 +                (void) strcpy((&pnv[i + KCTL_PROPNV_NIODEV])->kanv_name,
      114 +                    ttymode);
      115 +        }
 105  116  
 106  117          /*
 107  118           * console is defined by "console" property, with
 108  119           * fallback on the old "input-device" property.
 109  120           */
 110      -        (void) strcpy((&pnv[0])->kanv_val, "text");     /* default to screen */
 111      -        if (!preader("console", (&pnv[0])->kanv_val,
 112      -            sizeof ((&pnv[0])->kanv_val)))
 113      -                (void) preader("input-device", (&pnv[0])->kanv_val,
      121 +        (void) strcpy(inputdev, "text");        /* default to screen */
      122 +        if (!preader("console", inputdev, sizeof ((&pnv[0])->kanv_val)))
      123 +                (void) preader("input-device", inputdev,
 114  124                      sizeof ((&pnv[0])->kanv_val));
 115  125  
 116      -        if (strcmp((&pnv[0])->kanv_val, "ttya") == 0 ||
 117      -            strcmp((&pnv[0])->kanv_val, "ttyb") == 0) {
 118      -                (void) strcpy((&pnv[1])->kanv_val, (&pnv[0])->kanv_val);
      126 +        if (strncmp(inputdev, "tty", 3) == 0 &&
      127 +            inputdev[4] == '\0' &&
      128 +            inputdev[3] >= 'a' &&
      129 +            inputdev[3] < 'a' + KCTL_PROPNV_NTTYMD) {
      130 +                (void) strcpy(outputdev, inputdev);
 119  131          } else {
 120      -                (void) strcpy((&pnv[0])->kanv_val, "keyboard");
 121      -                (void) strcpy((&pnv[1])->kanv_val, "screen");
      132 +                (void) strcpy(inputdev, "keyboard");
      133 +                (void) strcpy(outputdev, "screen");
 122  134          }
 123  135  
 124      -        if (!preader((&pnv[2])->kanv_name, (&pnv[2])->kanv_val,
 125      -            sizeof ((&pnv[2])->kanv_val)))
 126      -                (void) strcpy((&pnv[2])->kanv_val, "9600,8,n,1,-");
      136 +        /* Set tty modes or defaults. */
      137 +        for (i = KCTL_PROPNV_NIODEV; i < KCTL_PROPNV_NENT; i++) {
      138 +                if (!preader((&pnv[i])->kanv_name, (&pnv[i])->kanv_val,
      139 +                    sizeof ((&pnv[0])->kanv_val)))
      140 +                        (void) strcpy((&pnv[i])->kanv_val, "9600,8,n,1,-");
      141 +        }
 127  142  
 128      -        if (!preader((&pnv[3])->kanv_name, (&pnv[3])->kanv_val,
 129      -            sizeof ((&pnv[3])->kanv_val)))
 130      -                (void) strcpy((&pnv[3])->kanv_val, "9600,8,n,1,-");
 131      -
 132  143          *nprops = KCTL_PROPNV_NENT;
 133  144          return (pnv);
 134  145  }
 135  146  
 136  147  static void
 137  148  kctl_pcache_destroy(kmdb_auxv_nv_t *pnv)
 138  149  {
 139  150          kobj_free(pnv, sizeof (kmdb_auxv_nv_t) * KCTL_PROPNV_NENT);
 140  151  }
 141  152  
↓ open down ↓ 52 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX