Print this page
    
9482 Want cxgbetool
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@joyent.com>
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/io/cxgbe/t4nex/t4_ioctl.c
          +++ new/usr/src/uts/common/io/cxgbe/t4nex/t4_ioctl.c
   1    1  /*
   2    2   * This file and its contents are supplied under the terms of the
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source. A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13   13   * This file is part of the Chelsio T4 support code.
  14   14   *
  15   15   * Copyright (C) 2011-2013 Chelsio Communications.  All rights reserved.
  16   16   *
  17   17   * This program is distributed in the hope that it will be useful, but WITHOUT
  18   18   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  19   19   * FITNESS FOR A PARTICULAR PURPOSE.  See the LICENSE file included in this
  20   20   * release for licensing terms and conditions.
  21   21   */
  22   22  
  23   23  #include <sys/ddi.h>
  24   24  #include <sys/sunddi.h>
  25   25  #include <sys/queue.h>
  26   26  
  27   27  #include "t4nex.h"
  28   28  #include "common/common.h"
  29   29  #include "common/t4_regs.h"
  30   30  
  31   31  /* helpers */
  32   32  static int pci_rw(struct adapter *sc, void *data, int flags, int write);
  33   33  static int reg_rw(struct adapter *sc, void *data, int flags, int write);
  34   34  static void reg_block_dump(struct adapter *sc, uint8_t *buf, unsigned int start,
  35   35      unsigned int end);
  36   36  static int regdump(struct adapter *sc, void *data, int flags);
  
    | 
      ↓ open down ↓ | 
    36 lines elided | 
    
      ↑ open up ↑ | 
  
  37   37  static int get_sge_context(struct adapter *sc, void *data, int flags);
  38   38  static int get_devlog(struct adapter *sc, void *data, int flags);
  39   39  static int validate_mem_range(struct adapter *, uint32_t, int);
  40   40  static int read_card_mem(struct adapter *sc, void *data, int flags);
  41   41  static int read_tid_tab(struct adapter *sc, void *data, int flags);
  42   42  static int read_mbox(struct adapter *sc, void *data, int flags);
  43   43  static int read_cim_la(struct adapter *sc, void *data, int flags);
  44   44  static int read_cim_qcfg(struct adapter *sc, void *data, int flags);
  45   45  static int read_cim_ibq(struct adapter *sc, void *data, int flags);
  46   46  static int read_edc(struct adapter *sc, void *data, int flags);
       47 +static int flash_fw(struct adapter *, void *, int);
  47   48  
  48   49  int
  49   50  t4_ioctl(struct adapter *sc, int cmd, void *data, int mode)
  50   51  {
  51   52          int rc = ENOTSUP;
  52   53  
  53   54          switch (cmd) {
  54   55          case T4_IOCTL_PCIGET32:
  55   56          case T4_IOCTL_PCIPUT32:
  56   57                  rc = pci_rw(sc, data, mode, cmd == T4_IOCTL_PCIPUT32);
  57   58                  break;
  58   59          case T4_IOCTL_GET32:
  59   60          case T4_IOCTL_PUT32:
  60   61                  rc = reg_rw(sc, data, mode, cmd == T4_IOCTL_PUT32);
  61   62                  break;
  62   63          case T4_IOCTL_REGDUMP:
  63   64                  rc = regdump(sc, data, mode);
  64   65                  break;
  65   66          case T4_IOCTL_SGE_CONTEXT:
  66   67                  rc = get_sge_context(sc, data, mode);
  67   68                  break;
  68   69          case T4_IOCTL_DEVLOG:
  69   70                  rc = get_devlog(sc, data, mode);
  70   71                  break;
  71   72          case T4_IOCTL_GET_MEM:
  72   73                  rc = read_card_mem(sc, data, mode);
  73   74                  break;
  74   75          case T4_IOCTL_GET_TID_TAB:
  75   76                  rc = read_tid_tab(sc, data, mode);
  76   77                  break;
  77   78          case T4_IOCTL_GET_MBOX:
  78   79                  rc = read_mbox(sc, data, mode);
  79   80                  break;
  80   81          case T4_IOCTL_GET_CIM_LA:
  81   82                  rc = read_cim_la(sc, data, mode);
  
    | 
      ↓ open down ↓ | 
    25 lines elided | 
    
      ↑ open up ↑ | 
  
  82   83                  break;
  83   84          case T4_IOCTL_GET_CIM_QCFG:
  84   85                  rc = read_cim_qcfg(sc, data, mode);
  85   86                  break;
  86   87          case T4_IOCTL_GET_CIM_IBQ:
  87   88                  rc = read_cim_ibq(sc, data, mode);
  88   89                  break;
  89   90          case T4_IOCTL_GET_EDC:
  90   91                  rc = read_edc(sc, data, mode);
  91   92                  break;
       93 +        case T4_IOCTL_LOAD_FW:
       94 +                rc = flash_fw(sc, data, mode);
       95 +                break;
  92   96          default:
  93   97                  return (EINVAL);
  94   98          }
  95   99  
  96  100          return (rc);
  97  101  }
  98  102  
  99  103  static int
 100  104  pci_rw(struct adapter *sc, void *data, int flags, int write)
 101  105  {
 102  106          struct t4_reg32_cmd r;
 103  107  
 104  108          if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
 105  109                  return (EFAULT);
 106  110  
 107  111          /* address must be 32 bit aligned */
 108  112          r.reg &= ~0x3;
 109  113  
 110  114          if (write != 0)
 111  115                  t4_os_pci_write_cfg4(sc, r.reg, r.value);
 112  116          else {
 113  117                  t4_os_pci_read_cfg4(sc, r.reg, &r.value);
 114  118                  if (ddi_copyout(&r, data, sizeof (r), flags) < 0)
 115  119                          return (EFAULT);
 116  120          }
 117  121  
 118  122          return (0);
 119  123  }
 120  124  
 121  125  static int
 122  126  reg_rw(struct adapter *sc, void *data, int flags, int write)
 123  127  {
 124  128          struct t4_reg32_cmd r;
 125  129  
 126  130          if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
 127  131                  return (EFAULT);
 128  132  
 129  133          /* Register address must be 32 bit aligned */
 130  134          r.reg &= ~0x3;
 131  135  
 132  136          if (write != 0)
 133  137                  t4_write_reg(sc, r.reg, r.value);
 134  138          else {
 135  139                  r.value = t4_read_reg(sc, r.reg);
 136  140                  if (ddi_copyout(&r, data, sizeof (r), flags) < 0)
 137  141                          return (EFAULT);
 138  142          }
 139  143  
 140  144          return (0);
 141  145  }
 142  146  
 143  147  static void
 144  148  reg_block_dump(struct adapter *sc, uint8_t *buf, unsigned int start,
 145  149      unsigned int end)
 146  150  {
 147  151          /* LINTED: E_BAD_PTR_CAST_ALIGN */
 148  152          uint32_t *p = (uint32_t *)(buf + start);
 149  153  
 150  154          for (/* */; start <= end; start += sizeof (uint32_t))
 151  155                  *p++ = t4_read_reg(sc, start);
 152  156  }
 153  157  
 154  158  /*
 155  159   * Return a version number to identify the type of adapter.  The scheme is:
 156  160   * - bits 0..9: chip version
 157  161   * - bits 10..15: chip revision
 158  162   * - bits 16..23: register dump version
 159  163   */
 160  164  static inline
 161  165  unsigned int mk_adap_vers(const struct adapter *sc)
 162  166  {
 163  167          return CHELSIO_CHIP_VERSION(sc->params.chip) |
 164  168                  (CHELSIO_CHIP_RELEASE(sc->params.chip) << 10) | (1 << 16);
 165  169  }
 166  170  
 167  171  static int
 168  172  regdump(struct adapter *sc, void *data, int flags)
 169  173  {
 170  174          struct t4_regdump r;
 171  175          uint8_t *buf;
 172  176          static const unsigned int *reg_ranges;
 173  177          int rc = 0, arr_size = 0, buf_size = 0, i;
 174  178          static const unsigned int t4_reg_ranges[] = {
 175  179                  0x1008, 0x1108,
 176  180                  0x1180, 0x11b4,
 177  181                  0x11fc, 0x123c,
 178  182                  0x1300, 0x173c,
 179  183                  0x1800, 0x18fc,
 180  184                  0x3000, 0x30d8,
 181  185                  0x30e0, 0x5924,
 182  186                  0x5960, 0x59d4,
 183  187                  0x5a00, 0x5af8,
 184  188                  0x6000, 0x6098,
 185  189                  0x6100, 0x6150,
 186  190                  0x6200, 0x6208,
 187  191                  0x6240, 0x6248,
 188  192                  0x6280, 0x6338,
 189  193                  0x6370, 0x638c,
 190  194                  0x6400, 0x643c,
 191  195                  0x6500, 0x6524,
 192  196                  0x6a00, 0x6a38,
 193  197                  0x6a60, 0x6a78,
 194  198                  0x6b00, 0x6b84,
 195  199                  0x6bf0, 0x6c84,
 196  200                  0x6cf0, 0x6d84,
 197  201                  0x6df0, 0x6e84,
 198  202                  0x6ef0, 0x6f84,
 199  203                  0x6ff0, 0x7084,
 200  204                  0x70f0, 0x7184,
 201  205                  0x71f0, 0x7284,
 202  206                  0x72f0, 0x7384,
 203  207                  0x73f0, 0x7450,
 204  208                  0x7500, 0x7530,
 205  209                  0x7600, 0x761c,
 206  210                  0x7680, 0x76cc,
 207  211                  0x7700, 0x7798,
 208  212                  0x77c0, 0x77fc,
 209  213                  0x7900, 0x79fc,
 210  214                  0x7b00, 0x7c38,
 211  215                  0x7d00, 0x7efc,
 212  216                  0x8dc0, 0x8e1c,
 213  217                  0x8e30, 0x8e78,
 214  218                  0x8ea0, 0x8f6c,
 215  219                  0x8fc0, 0x9074,
 216  220                  0x90fc, 0x90fc,
 217  221                  0x9400, 0x9458,
 218  222                  0x9600, 0x96bc,
 219  223                  0x9800, 0x9808,
 220  224                  0x9820, 0x983c,
 221  225                  0x9850, 0x9864,
 222  226                  0x9c00, 0x9c6c,
 223  227                  0x9c80, 0x9cec,
 224  228                  0x9d00, 0x9d6c,
 225  229                  0x9d80, 0x9dec,
 226  230                  0x9e00, 0x9e6c,
 227  231                  0x9e80, 0x9eec,
 228  232                  0x9f00, 0x9f6c,
 229  233                  0x9f80, 0x9fec,
 230  234                  0xd004, 0xd03c,
 231  235                  0xdfc0, 0xdfe0,
 232  236                  0xe000, 0xea7c,
 233  237                  0xf000, 0x11190,
 234  238                  0x19040, 0x19124,
 235  239                  0x19150, 0x191b0,
 236  240                  0x191d0, 0x191e8,
 237  241                  0x19238, 0x1924c,
 238  242                  0x193f8, 0x19474,
 239  243                  0x19490, 0x194f8,
 240  244                  0x19800, 0x19f30,
 241  245                  0x1a000, 0x1a06c,
 242  246                  0x1a0b0, 0x1a120,
 243  247                  0x1a128, 0x1a138,
 244  248                  0x1a190, 0x1a1c4,
 245  249                  0x1a1fc, 0x1a1fc,
 246  250                  0x1e040, 0x1e04c,
 247  251                  0x1e240, 0x1e28c,
 248  252                  0x1e2c0, 0x1e2c0,
 249  253                  0x1e2e0, 0x1e2e0,
 250  254                  0x1e300, 0x1e384,
 251  255                  0x1e3c0, 0x1e3c8,
 252  256                  0x1e440, 0x1e44c,
 253  257                  0x1e640, 0x1e68c,
 254  258                  0x1e6c0, 0x1e6c0,
 255  259                  0x1e6e0, 0x1e6e0,
 256  260                  0x1e700, 0x1e784,
 257  261                  0x1e7c0, 0x1e7c8,
 258  262                  0x1e840, 0x1e84c,
 259  263                  0x1ea40, 0x1ea8c,
 260  264                  0x1eac0, 0x1eac0,
 261  265                  0x1eae0, 0x1eae0,
 262  266                  0x1eb00, 0x1eb84,
 263  267                  0x1ebc0, 0x1ebc8,
 264  268                  0x1ec40, 0x1ec4c,
 265  269                  0x1ee40, 0x1ee8c,
 266  270                  0x1eec0, 0x1eec0,
 267  271                  0x1eee0, 0x1eee0,
 268  272                  0x1ef00, 0x1ef84,
 269  273                  0x1efc0, 0x1efc8,
 270  274                  0x1f040, 0x1f04c,
 271  275                  0x1f240, 0x1f28c,
 272  276                  0x1f2c0, 0x1f2c0,
 273  277                  0x1f2e0, 0x1f2e0,
 274  278                  0x1f300, 0x1f384,
 275  279                  0x1f3c0, 0x1f3c8,
 276  280                  0x1f440, 0x1f44c,
 277  281                  0x1f640, 0x1f68c,
 278  282                  0x1f6c0, 0x1f6c0,
 279  283                  0x1f6e0, 0x1f6e0,
 280  284                  0x1f700, 0x1f784,
 281  285                  0x1f7c0, 0x1f7c8,
 282  286                  0x1f840, 0x1f84c,
 283  287                  0x1fa40, 0x1fa8c,
 284  288                  0x1fac0, 0x1fac0,
 285  289                  0x1fae0, 0x1fae0,
 286  290                  0x1fb00, 0x1fb84,
 287  291                  0x1fbc0, 0x1fbc8,
 288  292                  0x1fc40, 0x1fc4c,
 289  293                  0x1fe40, 0x1fe8c,
 290  294                  0x1fec0, 0x1fec0,
 291  295                  0x1fee0, 0x1fee0,
 292  296                  0x1ff00, 0x1ff84,
 293  297                  0x1ffc0, 0x1ffc8,
 294  298                  0x20000, 0x2002c,
 295  299                  0x20100, 0x2013c,
 296  300                  0x20190, 0x201c8,
 297  301                  0x20200, 0x20318,
 298  302                  0x20400, 0x20528,
 299  303                  0x20540, 0x20614,
 300  304                  0x21000, 0x21040,
 301  305                  0x2104c, 0x21060,
 302  306                  0x210c0, 0x210ec,
 303  307                  0x21200, 0x21268,
 304  308                  0x21270, 0x21284,
 305  309                  0x212fc, 0x21388,
 306  310                  0x21400, 0x21404,
 307  311                  0x21500, 0x21518,
 308  312                  0x2152c, 0x2153c,
 309  313                  0x21550, 0x21554,
 310  314                  0x21600, 0x21600,
 311  315                  0x21608, 0x21628,
 312  316                  0x21630, 0x2163c,
 313  317                  0x21700, 0x2171c,
 314  318                  0x21780, 0x2178c,
 315  319                  0x21800, 0x21c38,
 316  320                  0x21c80, 0x21d7c,
 317  321                  0x21e00, 0x21e04,
 318  322                  0x22000, 0x2202c,
 319  323                  0x22100, 0x2213c,
 320  324                  0x22190, 0x221c8,
 321  325                  0x22200, 0x22318,
 322  326                  0x22400, 0x22528,
 323  327                  0x22540, 0x22614,
 324  328                  0x23000, 0x23040,
 325  329                  0x2304c, 0x23060,
 326  330                  0x230c0, 0x230ec,
 327  331                  0x23200, 0x23268,
 328  332                  0x23270, 0x23284,
 329  333                  0x232fc, 0x23388,
 330  334                  0x23400, 0x23404,
 331  335                  0x23500, 0x23518,
 332  336                  0x2352c, 0x2353c,
 333  337                  0x23550, 0x23554,
 334  338                  0x23600, 0x23600,
 335  339                  0x23608, 0x23628,
 336  340                  0x23630, 0x2363c,
 337  341                  0x23700, 0x2371c,
 338  342                  0x23780, 0x2378c,
 339  343                  0x23800, 0x23c38,
 340  344                  0x23c80, 0x23d7c,
 341  345                  0x23e00, 0x23e04,
 342  346                  0x24000, 0x2402c,
 343  347                  0x24100, 0x2413c,
 344  348                  0x24190, 0x241c8,
 345  349                  0x24200, 0x24318,
 346  350                  0x24400, 0x24528,
 347  351                  0x24540, 0x24614,
 348  352                  0x25000, 0x25040,
 349  353                  0x2504c, 0x25060,
 350  354                  0x250c0, 0x250ec,
 351  355                  0x25200, 0x25268,
 352  356                  0x25270, 0x25284,
 353  357                  0x252fc, 0x25388,
 354  358                  0x25400, 0x25404,
 355  359                  0x25500, 0x25518,
 356  360                  0x2552c, 0x2553c,
 357  361                  0x25550, 0x25554,
 358  362                  0x25600, 0x25600,
 359  363                  0x25608, 0x25628,
 360  364                  0x25630, 0x2563c,
 361  365                  0x25700, 0x2571c,
 362  366                  0x25780, 0x2578c,
 363  367                  0x25800, 0x25c38,
 364  368                  0x25c80, 0x25d7c,
 365  369                  0x25e00, 0x25e04,
 366  370                  0x26000, 0x2602c,
 367  371                  0x26100, 0x2613c,
 368  372                  0x26190, 0x261c8,
 369  373                  0x26200, 0x26318,
 370  374                  0x26400, 0x26528,
 371  375                  0x26540, 0x26614,
 372  376                  0x27000, 0x27040,
 373  377                  0x2704c, 0x27060,
 374  378                  0x270c0, 0x270ec,
 375  379                  0x27200, 0x27268,
 376  380                  0x27270, 0x27284,
 377  381                  0x272fc, 0x27388,
 378  382                  0x27400, 0x27404,
 379  383                  0x27500, 0x27518,
 380  384                  0x2752c, 0x2753c,
 381  385                  0x27550, 0x27554,
 382  386                  0x27600, 0x27600,
 383  387                  0x27608, 0x27628,
 384  388                  0x27630, 0x2763c,
 385  389                  0x27700, 0x2771c,
 386  390                  0x27780, 0x2778c,
 387  391                  0x27800, 0x27c38,
 388  392                  0x27c80, 0x27d7c,
 389  393                  0x27e00, 0x27e04
 390  394          };
 391  395  
 392  396          static const unsigned int t5_reg_ranges[] = {
 393  397                  0x1008, 0x10c0,
 394  398                  0x10cc, 0x10f8,
 395  399                  0x1100, 0x1100,
 396  400                  0x110c, 0x1148,
 397  401                  0x1180, 0x1184,
 398  402                  0x1190, 0x1194,
 399  403                  0x11a0, 0x11a4,
 400  404                  0x11b0, 0x11b4,
 401  405                  0x11fc, 0x123c,
 402  406                  0x1280, 0x173c,
 403  407                  0x1800, 0x18fc,
 404  408                  0x3000, 0x3028,
 405  409                  0x3060, 0x30b0,
 406  410                  0x30b8, 0x30d8,
 407  411                  0x30e0, 0x30fc,
 408  412                  0x3140, 0x357c,
 409  413                  0x35a8, 0x35cc,
 410  414                  0x35ec, 0x35ec,
 411  415                  0x3600, 0x5624,
 412  416                  0x56cc, 0x56ec,
 413  417                  0x56f4, 0x5720,
 414  418                  0x5728, 0x575c,
 415  419                  0x580c, 0x5814,
 416  420                  0x5890, 0x589c,
 417  421                  0x58a4, 0x58ac,
 418  422                  0x58b8, 0x58bc,
 419  423                  0x5940, 0x59c8,
 420  424                  0x59d0, 0x59dc,
 421  425                  0x59fc, 0x5a18,
 422  426                  0x5a60, 0x5a70,
 423  427                  0x5a80, 0x5a9c,
 424  428                  0x5b94, 0x5bfc,
 425  429                  0x6000, 0x6020,
 426  430                  0x6028, 0x6040,
 427  431                  0x6058, 0x609c,
 428  432                  0x60a8, 0x614c,
 429  433                  0x7700, 0x7798,
 430  434                  0x77c0, 0x78fc,
 431  435                  0x7b00, 0x7b58,
 432  436                  0x7b60, 0x7b84,
 433  437                  0x7b8c, 0x7c54,
 434  438                  0x7d00, 0x7d38,
 435  439                  0x7d40, 0x7d80,
 436  440                  0x7d8c, 0x7ddc,
 437  441                  0x7de4, 0x7e04,
 438  442                  0x7e10, 0x7e1c,
 439  443                  0x7e24, 0x7e38,
 440  444                  0x7e40, 0x7e44,
 441  445                  0x7e4c, 0x7e78,
 442  446                  0x7e80, 0x7edc,
 443  447                  0x7ee8, 0x7efc,
 444  448                  0x8dc0, 0x8de0,
 445  449                  0x8df8, 0x8e04,
 446  450                  0x8e10, 0x8e84,
 447  451                  0x8ea0, 0x8f84,
 448  452                  0x8fc0, 0x9058,
 449  453                  0x9060, 0x9060,
 450  454                  0x9068, 0x90f8,
 451  455                  0x9400, 0x9408,
 452  456                  0x9410, 0x9470,
 453  457                  0x9600, 0x9600,
 454  458                  0x9608, 0x9638,
 455  459                  0x9640, 0x96f4,
 456  460                  0x9800, 0x9808,
 457  461                  0x9820, 0x983c,
 458  462                  0x9850, 0x9864,
 459  463                  0x9c00, 0x9c6c,
 460  464                  0x9c80, 0x9cec,
 461  465                  0x9d00, 0x9d6c,
 462  466                  0x9d80, 0x9dec,
 463  467                  0x9e00, 0x9e6c,
 464  468                  0x9e80, 0x9eec,
 465  469                  0x9f00, 0x9f6c,
 466  470                  0x9f80, 0xa020,
 467  471                  0xd004, 0xd004,
 468  472                  0xd010, 0xd03c,
 469  473                  0xdfc0, 0xdfe0,
 470  474                  0xe000, 0x1106c,
 471  475                  0x11074, 0x11088,
 472  476                  0x1109c, 0x1117c,
 473  477                  0x11190, 0x11204,
 474  478                  0x19040, 0x1906c,
 475  479                  0x19078, 0x19080,
 476  480                  0x1908c, 0x190e8,
 477  481                  0x190f0, 0x190f8,
 478  482                  0x19100, 0x19110,
 479  483                  0x19120, 0x19124,
 480  484                  0x19150, 0x19194,
 481  485                  0x1919c, 0x191b0,
 482  486                  0x191d0, 0x191e8,
 483  487                  0x19238, 0x19290,
 484  488                  0x193f8, 0x19428,
 485  489                  0x19430, 0x19444,
 486  490                  0x1944c, 0x1946c,
 487  491                  0x19474, 0x19474,
 488  492                  0x19490, 0x194cc,
 489  493                  0x194f0, 0x194f8,
 490  494                  0x19c00, 0x19c08,
 491  495                  0x19c10, 0x19c60,
 492  496                  0x19c94, 0x19ce4,
 493  497                  0x19cf0, 0x19d40,
 494  498                  0x19d50, 0x19d94,
 495  499                  0x19da0, 0x19de8,
 496  500                  0x19df0, 0x19e10,
 497  501                  0x19e50, 0x19e90,
 498  502                  0x19ea0, 0x19f24,
 499  503                  0x19f34, 0x19f34,
 500  504                  0x19f40, 0x19f50,
 501  505                  0x19f90, 0x19fb4,
 502  506                  0x19fc4, 0x19fe4,
 503  507                  0x1a000, 0x1a004,
 504  508                  0x1a010, 0x1a06c,
 505  509                  0x1a0b0, 0x1a0e4,
 506  510                  0x1a0ec, 0x1a0f8,
 507  511                  0x1a100, 0x1a108,
 508  512                  0x1a114, 0x1a120,
 509  513                  0x1a128, 0x1a130,
 510  514                  0x1a138, 0x1a138,
 511  515                  0x1a190, 0x1a1c4,
 512  516                  0x1a1fc, 0x1a1fc,
 513  517                  0x1e008, 0x1e00c,
 514  518                  0x1e040, 0x1e044,
 515  519                  0x1e04c, 0x1e04c,
 516  520                  0x1e284, 0x1e290,
 517  521                  0x1e2c0, 0x1e2c0,
 518  522                  0x1e2e0, 0x1e2e0,
 519  523                  0x1e300, 0x1e384,
 520  524                  0x1e3c0, 0x1e3c8,
 521  525                  0x1e408, 0x1e40c,
 522  526                  0x1e440, 0x1e444,
 523  527                  0x1e44c, 0x1e44c,
 524  528                  0x1e684, 0x1e690,
 525  529                  0x1e6c0, 0x1e6c0,
 526  530                  0x1e6e0, 0x1e6e0,
 527  531                  0x1e700, 0x1e784,
 528  532                  0x1e7c0, 0x1e7c8,
 529  533                  0x1e808, 0x1e80c,
 530  534                  0x1e840, 0x1e844,
 531  535                  0x1e84c, 0x1e84c,
 532  536                  0x1ea84, 0x1ea90,
 533  537                  0x1eac0, 0x1eac0,
 534  538                  0x1eae0, 0x1eae0,
 535  539                  0x1eb00, 0x1eb84,
 536  540                  0x1ebc0, 0x1ebc8,
 537  541                  0x1ec08, 0x1ec0c,
 538  542                  0x1ec40, 0x1ec44,
 539  543                  0x1ec4c, 0x1ec4c,
 540  544                  0x1ee84, 0x1ee90,
 541  545                  0x1eec0, 0x1eec0,
 542  546                  0x1eee0, 0x1eee0,
 543  547                  0x1ef00, 0x1ef84,
 544  548                  0x1efc0, 0x1efc8,
 545  549                  0x1f008, 0x1f00c,
 546  550                  0x1f040, 0x1f044,
 547  551                  0x1f04c, 0x1f04c,
 548  552                  0x1f284, 0x1f290,
 549  553                  0x1f2c0, 0x1f2c0,
 550  554                  0x1f2e0, 0x1f2e0,
 551  555                  0x1f300, 0x1f384,
 552  556                  0x1f3c0, 0x1f3c8,
 553  557                  0x1f408, 0x1f40c,
 554  558                  0x1f440, 0x1f444,
 555  559                  0x1f44c, 0x1f44c,
 556  560                  0x1f684, 0x1f690,
 557  561                  0x1f6c0, 0x1f6c0,
 558  562                  0x1f6e0, 0x1f6e0,
 559  563                  0x1f700, 0x1f784,
 560  564                  0x1f7c0, 0x1f7c8,
 561  565                  0x1f808, 0x1f80c,
 562  566                  0x1f840, 0x1f844,
 563  567                  0x1f84c, 0x1f84c,
 564  568                  0x1fa84, 0x1fa90,
 565  569                  0x1fac0, 0x1fac0,
 566  570                  0x1fae0, 0x1fae0,
 567  571                  0x1fb00, 0x1fb84,
 568  572                  0x1fbc0, 0x1fbc8,
 569  573                  0x1fc08, 0x1fc0c,
 570  574                  0x1fc40, 0x1fc44,
 571  575                  0x1fc4c, 0x1fc4c,
 572  576                  0x1fe84, 0x1fe90,
 573  577                  0x1fec0, 0x1fec0,
 574  578                  0x1fee0, 0x1fee0,
 575  579                  0x1ff00, 0x1ff84,
 576  580                  0x1ffc0, 0x1ffc8,
 577  581                  0x30000, 0x30030,
 578  582                  0x30038, 0x30038,
 579  583                  0x30040, 0x30040,
 580  584                  0x30100, 0x30144,
 581  585                  0x30190, 0x301a0,
 582  586                  0x301a8, 0x301b8,
 583  587                  0x301c4, 0x301c8,
 584  588                  0x301d0, 0x301d0,
 585  589                  0x30200, 0x30318,
 586  590                  0x30400, 0x304b4,
 587  591                  0x304c0, 0x3052c,
 588  592                  0x30540, 0x3061c,
 589  593                  0x30800, 0x30828,
 590  594                  0x30834, 0x30834,
 591  595                  0x308c0, 0x30908,
 592  596                  0x30910, 0x309ac,
 593  597                  0x30a00, 0x30a14,
 594  598                  0x30a1c, 0x30a2c,
 595  599                  0x30a44, 0x30a50,
 596  600                  0x30a74, 0x30a74,
 597  601                  0x30a7c, 0x30afc,
 598  602                  0x30b08, 0x30c24,
 599  603                  0x30d00, 0x30d00,
 600  604                  0x30d08, 0x30d14,
 601  605                  0x30d1c, 0x30d20,
 602  606                  0x30d3c, 0x30d3c,
 603  607                  0x30d48, 0x30d50,
 604  608                  0x31200, 0x3120c,
 605  609                  0x31220, 0x31220,
 606  610                  0x31240, 0x31240,
 607  611                  0x31600, 0x3160c,
 608  612                  0x31a00, 0x31a1c,
 609  613                  0x31e00, 0x31e20,
 610  614                  0x31e38, 0x31e3c,
 611  615                  0x31e80, 0x31e80,
 612  616                  0x31e88, 0x31ea8,
 613  617                  0x31eb0, 0x31eb4,
 614  618                  0x31ec8, 0x31ed4,
 615  619                  0x31fb8, 0x32004,
 616  620                  0x32200, 0x32200,
 617  621                  0x32208, 0x32240,
 618  622                  0x32248, 0x32280,
 619  623                  0x32288, 0x322c0,
 620  624                  0x322c8, 0x322fc,
 621  625                  0x32600, 0x32630,
 622  626                  0x32a00, 0x32abc,
 623  627                  0x32b00, 0x32b10,
 624  628                  0x32b20, 0x32b30,
 625  629                  0x32b40, 0x32b50,
 626  630                  0x32b60, 0x32b70,
 627  631                  0x33000, 0x33028,
 628  632                  0x33030, 0x33048,
 629  633                  0x33060, 0x33068,
 630  634                  0x33070, 0x3309c,
 631  635                  0x330f0, 0x33128,
 632  636                  0x33130, 0x33148,
 633  637                  0x33160, 0x33168,
 634  638                  0x33170, 0x3319c,
 635  639                  0x331f0, 0x33238,
 636  640                  0x33240, 0x33240,
 637  641                  0x33248, 0x33250,
 638  642                  0x3325c, 0x33264,
 639  643                  0x33270, 0x332b8,
 640  644                  0x332c0, 0x332e4,
 641  645                  0x332f8, 0x33338,
 642  646                  0x33340, 0x33340,
 643  647                  0x33348, 0x33350,
 644  648                  0x3335c, 0x33364,
 645  649                  0x33370, 0x333b8,
 646  650                  0x333c0, 0x333e4,
 647  651                  0x333f8, 0x33428,
 648  652                  0x33430, 0x33448,
 649  653                  0x33460, 0x33468,
 650  654                  0x33470, 0x3349c,
 651  655                  0x334f0, 0x33528,
 652  656                  0x33530, 0x33548,
 653  657                  0x33560, 0x33568,
 654  658                  0x33570, 0x3359c,
 655  659                  0x335f0, 0x33638,
 656  660                  0x33640, 0x33640,
 657  661                  0x33648, 0x33650,
 658  662                  0x3365c, 0x33664,
 659  663                  0x33670, 0x336b8,
 660  664                  0x336c0, 0x336e4,
 661  665                  0x336f8, 0x33738,
 662  666                  0x33740, 0x33740,
 663  667                  0x33748, 0x33750,
 664  668                  0x3375c, 0x33764,
 665  669                  0x33770, 0x337b8,
 666  670                  0x337c0, 0x337e4,
 667  671                  0x337f8, 0x337fc,
 668  672                  0x33814, 0x33814,
 669  673                  0x3382c, 0x3382c,
 670  674                  0x33880, 0x3388c,
 671  675                  0x338e8, 0x338ec,
 672  676                  0x33900, 0x33928,
 673  677                  0x33930, 0x33948,
 674  678                  0x33960, 0x33968,
 675  679                  0x33970, 0x3399c,
 676  680                  0x339f0, 0x33a38,
 677  681                  0x33a40, 0x33a40,
 678  682                  0x33a48, 0x33a50,
 679  683                  0x33a5c, 0x33a64,
 680  684                  0x33a70, 0x33ab8,
 681  685                  0x33ac0, 0x33ae4,
 682  686                  0x33af8, 0x33b10,
 683  687                  0x33b28, 0x33b28,
 684  688                  0x33b3c, 0x33b50,
 685  689                  0x33bf0, 0x33c10,
 686  690                  0x33c28, 0x33c28,
 687  691                  0x33c3c, 0x33c50,
 688  692                  0x33cf0, 0x33cfc,
 689  693                  0x34000, 0x34030,
 690  694                  0x34038, 0x34038,
 691  695                  0x34040, 0x34040,
 692  696                  0x34100, 0x34144,
 693  697                  0x34190, 0x341a0,
 694  698                  0x341a8, 0x341b8,
 695  699                  0x341c4, 0x341c8,
 696  700                  0x341d0, 0x341d0,
 697  701                  0x34200, 0x34318,
 698  702                  0x34400, 0x344b4,
 699  703                  0x344c0, 0x3452c,
 700  704                  0x34540, 0x3461c,
 701  705                  0x34800, 0x34828,
 702  706                  0x34834, 0x34834,
 703  707                  0x348c0, 0x34908,
 704  708                  0x34910, 0x349ac,
 705  709                  0x34a00, 0x34a14,
 706  710                  0x34a1c, 0x34a2c,
 707  711                  0x34a44, 0x34a50,
 708  712                  0x34a74, 0x34a74,
 709  713                  0x34a7c, 0x34afc,
 710  714                  0x34b08, 0x34c24,
 711  715                  0x34d00, 0x34d00,
 712  716                  0x34d08, 0x34d14,
 713  717                  0x34d1c, 0x34d20,
 714  718                  0x34d3c, 0x34d3c,
 715  719                  0x34d48, 0x34d50,
 716  720                  0x35200, 0x3520c,
 717  721                  0x35220, 0x35220,
 718  722                  0x35240, 0x35240,
 719  723                  0x35600, 0x3560c,
 720  724                  0x35a00, 0x35a1c,
 721  725                  0x35e00, 0x35e20,
 722  726                  0x35e38, 0x35e3c,
 723  727                  0x35e80, 0x35e80,
 724  728                  0x35e88, 0x35ea8,
 725  729                  0x35eb0, 0x35eb4,
 726  730                  0x35ec8, 0x35ed4,
 727  731                  0x35fb8, 0x36004,
 728  732                  0x36200, 0x36200,
 729  733                  0x36208, 0x36240,
 730  734                  0x36248, 0x36280,
 731  735                  0x36288, 0x362c0,
 732  736                  0x362c8, 0x362fc,
 733  737                  0x36600, 0x36630,
 734  738                  0x36a00, 0x36abc,
 735  739                  0x36b00, 0x36b10,
 736  740                  0x36b20, 0x36b30,
 737  741                  0x36b40, 0x36b50,
 738  742                  0x36b60, 0x36b70,
 739  743                  0x37000, 0x37028,
 740  744                  0x37030, 0x37048,
 741  745                  0x37060, 0x37068,
 742  746                  0x37070, 0x3709c,
 743  747                  0x370f0, 0x37128,
 744  748                  0x37130, 0x37148,
 745  749                  0x37160, 0x37168,
 746  750                  0x37170, 0x3719c,
 747  751                  0x371f0, 0x37238,
 748  752                  0x37240, 0x37240,
 749  753                  0x37248, 0x37250,
 750  754                  0x3725c, 0x37264,
 751  755                  0x37270, 0x372b8,
 752  756                  0x372c0, 0x372e4,
 753  757                  0x372f8, 0x37338,
 754  758                  0x37340, 0x37340,
 755  759                  0x37348, 0x37350,
 756  760                  0x3735c, 0x37364,
 757  761                  0x37370, 0x373b8,
 758  762                  0x373c0, 0x373e4,
 759  763                  0x373f8, 0x37428,
 760  764                  0x37430, 0x37448,
 761  765                  0x37460, 0x37468,
 762  766                  0x37470, 0x3749c,
 763  767                  0x374f0, 0x37528,
 764  768                  0x37530, 0x37548,
 765  769                  0x37560, 0x37568,
 766  770                  0x37570, 0x3759c,
 767  771                  0x375f0, 0x37638,
 768  772                  0x37640, 0x37640,
 769  773                  0x37648, 0x37650,
 770  774                  0x3765c, 0x37664,
 771  775                  0x37670, 0x376b8,
 772  776                  0x376c0, 0x376e4,
 773  777                  0x376f8, 0x37738,
 774  778                  0x37740, 0x37740,
 775  779                  0x37748, 0x37750,
 776  780                  0x3775c, 0x37764,
 777  781                  0x37770, 0x377b8,
 778  782                  0x377c0, 0x377e4,
 779  783                  0x377f8, 0x377fc,
 780  784                  0x37814, 0x37814,
 781  785                  0x3782c, 0x3782c,
 782  786                  0x37880, 0x3788c,
 783  787                  0x378e8, 0x378ec,
 784  788                  0x37900, 0x37928,
 785  789                  0x37930, 0x37948,
 786  790                  0x37960, 0x37968,
 787  791                  0x37970, 0x3799c,
 788  792                  0x379f0, 0x37a38,
 789  793                  0x37a40, 0x37a40,
 790  794                  0x37a48, 0x37a50,
 791  795                  0x37a5c, 0x37a64,
 792  796                  0x37a70, 0x37ab8,
 793  797                  0x37ac0, 0x37ae4,
 794  798                  0x37af8, 0x37b10,
 795  799                  0x37b28, 0x37b28,
 796  800                  0x37b3c, 0x37b50,
 797  801                  0x37bf0, 0x37c10,
 798  802                  0x37c28, 0x37c28,
 799  803                  0x37c3c, 0x37c50,
 800  804                  0x37cf0, 0x37cfc,
 801  805                  0x38000, 0x38030,
 802  806                  0x38038, 0x38038,
 803  807                  0x38040, 0x38040,
 804  808                  0x38100, 0x38144,
 805  809                  0x38190, 0x381a0,
 806  810                  0x381a8, 0x381b8,
 807  811                  0x381c4, 0x381c8,
 808  812                  0x381d0, 0x381d0,
 809  813                  0x38200, 0x38318,
 810  814                  0x38400, 0x384b4,
 811  815                  0x384c0, 0x3852c,
 812  816                  0x38540, 0x3861c,
 813  817                  0x38800, 0x38828,
 814  818                  0x38834, 0x38834,
 815  819                  0x388c0, 0x38908,
 816  820                  0x38910, 0x389ac,
 817  821                  0x38a00, 0x38a14,
 818  822                  0x38a1c, 0x38a2c,
 819  823                  0x38a44, 0x38a50,
 820  824                  0x38a74, 0x38a74,
 821  825                  0x38a7c, 0x38afc,
 822  826                  0x38b08, 0x38c24,
 823  827                  0x38d00, 0x38d00,
 824  828                  0x38d08, 0x38d14,
 825  829                  0x38d1c, 0x38d20,
 826  830                  0x38d3c, 0x38d3c,
 827  831                  0x38d48, 0x38d50,
 828  832                  0x39200, 0x3920c,
 829  833                  0x39220, 0x39220,
 830  834                  0x39240, 0x39240,
 831  835                  0x39600, 0x3960c,
 832  836                  0x39a00, 0x39a1c,
 833  837                  0x39e00, 0x39e20,
 834  838                  0x39e38, 0x39e3c,
 835  839                  0x39e80, 0x39e80,
 836  840                  0x39e88, 0x39ea8,
 837  841                  0x39eb0, 0x39eb4,
 838  842                  0x39ec8, 0x39ed4,
 839  843                  0x39fb8, 0x3a004,
 840  844                  0x3a200, 0x3a200,
 841  845                  0x3a208, 0x3a240,
 842  846                  0x3a248, 0x3a280,
 843  847                  0x3a288, 0x3a2c0,
 844  848                  0x3a2c8, 0x3a2fc,
 845  849                  0x3a600, 0x3a630,
 846  850                  0x3aa00, 0x3aabc,
 847  851                  0x3ab00, 0x3ab10,
 848  852                  0x3ab20, 0x3ab30,
 849  853                  0x3ab40, 0x3ab50,
 850  854                  0x3ab60, 0x3ab70,
 851  855                  0x3b000, 0x3b028,
 852  856                  0x3b030, 0x3b048,
 853  857                  0x3b060, 0x3b068,
 854  858                  0x3b070, 0x3b09c,
 855  859                  0x3b0f0, 0x3b128,
 856  860                  0x3b130, 0x3b148,
 857  861                  0x3b160, 0x3b168,
 858  862                  0x3b170, 0x3b19c,
 859  863                  0x3b1f0, 0x3b238,
 860  864                  0x3b240, 0x3b240,
 861  865                  0x3b248, 0x3b250,
 862  866                  0x3b25c, 0x3b264,
 863  867                  0x3b270, 0x3b2b8,
 864  868                  0x3b2c0, 0x3b2e4,
 865  869                  0x3b2f8, 0x3b338,
 866  870                  0x3b340, 0x3b340,
 867  871                  0x3b348, 0x3b350,
 868  872                  0x3b35c, 0x3b364,
 869  873                  0x3b370, 0x3b3b8,
 870  874                  0x3b3c0, 0x3b3e4,
 871  875                  0x3b3f8, 0x3b428,
 872  876                  0x3b430, 0x3b448,
 873  877                  0x3b460, 0x3b468,
 874  878                  0x3b470, 0x3b49c,
 875  879                  0x3b4f0, 0x3b528,
 876  880                  0x3b530, 0x3b548,
 877  881                  0x3b560, 0x3b568,
 878  882                  0x3b570, 0x3b59c,
 879  883                  0x3b5f0, 0x3b638,
 880  884                  0x3b640, 0x3b640,
 881  885                  0x3b648, 0x3b650,
 882  886                  0x3b65c, 0x3b664,
 883  887                  0x3b670, 0x3b6b8,
 884  888                  0x3b6c0, 0x3b6e4,
 885  889                  0x3b6f8, 0x3b738,
 886  890                  0x3b740, 0x3b740,
 887  891                  0x3b748, 0x3b750,
 888  892                  0x3b75c, 0x3b764,
 889  893                  0x3b770, 0x3b7b8,
 890  894                  0x3b7c0, 0x3b7e4,
 891  895                  0x3b7f8, 0x3b7fc,
 892  896                  0x3b814, 0x3b814,
 893  897                  0x3b82c, 0x3b82c,
 894  898                  0x3b880, 0x3b88c,
 895  899                  0x3b8e8, 0x3b8ec,
 896  900                  0x3b900, 0x3b928,
 897  901                  0x3b930, 0x3b948,
 898  902                  0x3b960, 0x3b968,
 899  903                  0x3b970, 0x3b99c,
 900  904                  0x3b9f0, 0x3ba38,
 901  905                  0x3ba40, 0x3ba40,
 902  906                  0x3ba48, 0x3ba50,
 903  907                  0x3ba5c, 0x3ba64,
 904  908                  0x3ba70, 0x3bab8,
 905  909                  0x3bac0, 0x3bae4,
 906  910                  0x3baf8, 0x3bb10,
 907  911                  0x3bb28, 0x3bb28,
 908  912                  0x3bb3c, 0x3bb50,
 909  913                  0x3bbf0, 0x3bc10,
 910  914                  0x3bc28, 0x3bc28,
 911  915                  0x3bc3c, 0x3bc50,
 912  916                  0x3bcf0, 0x3bcfc,
 913  917                  0x3c000, 0x3c030,
 914  918                  0x3c038, 0x3c038,
 915  919                  0x3c040, 0x3c040,
 916  920                  0x3c100, 0x3c144,
 917  921                  0x3c190, 0x3c1a0,
 918  922                  0x3c1a8, 0x3c1b8,
 919  923                  0x3c1c4, 0x3c1c8,
 920  924                  0x3c1d0, 0x3c1d0,
 921  925                  0x3c200, 0x3c318,
 922  926                  0x3c400, 0x3c4b4,
 923  927                  0x3c4c0, 0x3c52c,
 924  928                  0x3c540, 0x3c61c,
 925  929                  0x3c800, 0x3c828,
 926  930                  0x3c834, 0x3c834,
 927  931                  0x3c8c0, 0x3c908,
 928  932                  0x3c910, 0x3c9ac,
 929  933                  0x3ca00, 0x3ca14,
 930  934                  0x3ca1c, 0x3ca2c,
 931  935                  0x3ca44, 0x3ca50,
 932  936                  0x3ca74, 0x3ca74,
 933  937                  0x3ca7c, 0x3cafc,
 934  938                  0x3cb08, 0x3cc24,
 935  939                  0x3cd00, 0x3cd00,
 936  940                  0x3cd08, 0x3cd14,
 937  941                  0x3cd1c, 0x3cd20,
 938  942                  0x3cd3c, 0x3cd3c,
 939  943                  0x3cd48, 0x3cd50,
 940  944                  0x3d200, 0x3d20c,
 941  945                  0x3d220, 0x3d220,
 942  946                  0x3d240, 0x3d240,
 943  947                  0x3d600, 0x3d60c,
 944  948                  0x3da00, 0x3da1c,
 945  949                  0x3de00, 0x3de20,
 946  950                  0x3de38, 0x3de3c,
 947  951                  0x3de80, 0x3de80,
 948  952                  0x3de88, 0x3dea8,
 949  953                  0x3deb0, 0x3deb4,
 950  954                  0x3dec8, 0x3ded4,
 951  955                  0x3dfb8, 0x3e004,
 952  956                  0x3e200, 0x3e200,
 953  957                  0x3e208, 0x3e240,
 954  958                  0x3e248, 0x3e280,
 955  959                  0x3e288, 0x3e2c0,
 956  960                  0x3e2c8, 0x3e2fc,
 957  961                  0x3e600, 0x3e630,
 958  962                  0x3ea00, 0x3eabc,
 959  963                  0x3eb00, 0x3eb10,
 960  964                  0x3eb20, 0x3eb30,
 961  965                  0x3eb40, 0x3eb50,
 962  966                  0x3eb60, 0x3eb70,
 963  967                  0x3f000, 0x3f028,
 964  968                  0x3f030, 0x3f048,
 965  969                  0x3f060, 0x3f068,
 966  970                  0x3f070, 0x3f09c,
 967  971                  0x3f0f0, 0x3f128,
 968  972                  0x3f130, 0x3f148,
 969  973                  0x3f160, 0x3f168,
 970  974                  0x3f170, 0x3f19c,
 971  975                  0x3f1f0, 0x3f238,
 972  976                  0x3f240, 0x3f240,
 973  977                  0x3f248, 0x3f250,
 974  978                  0x3f25c, 0x3f264,
 975  979                  0x3f270, 0x3f2b8,
 976  980                  0x3f2c0, 0x3f2e4,
 977  981                  0x3f2f8, 0x3f338,
 978  982                  0x3f340, 0x3f340,
 979  983                  0x3f348, 0x3f350,
 980  984                  0x3f35c, 0x3f364,
 981  985                  0x3f370, 0x3f3b8,
 982  986                  0x3f3c0, 0x3f3e4,
 983  987                  0x3f3f8, 0x3f428,
 984  988                  0x3f430, 0x3f448,
 985  989                  0x3f460, 0x3f468,
 986  990                  0x3f470, 0x3f49c,
 987  991                  0x3f4f0, 0x3f528,
 988  992                  0x3f530, 0x3f548,
 989  993                  0x3f560, 0x3f568,
 990  994                  0x3f570, 0x3f59c,
 991  995                  0x3f5f0, 0x3f638,
 992  996                  0x3f640, 0x3f640,
 993  997                  0x3f648, 0x3f650,
 994  998                  0x3f65c, 0x3f664,
 995  999                  0x3f670, 0x3f6b8,
 996 1000                  0x3f6c0, 0x3f6e4,
 997 1001                  0x3f6f8, 0x3f738,
 998 1002                  0x3f740, 0x3f740,
 999 1003                  0x3f748, 0x3f750,
1000 1004                  0x3f75c, 0x3f764,
1001 1005                  0x3f770, 0x3f7b8,
1002 1006                  0x3f7c0, 0x3f7e4,
1003 1007                  0x3f7f8, 0x3f7fc,
1004 1008                  0x3f814, 0x3f814,
1005 1009                  0x3f82c, 0x3f82c,
1006 1010                  0x3f880, 0x3f88c,
1007 1011                  0x3f8e8, 0x3f8ec,
1008 1012                  0x3f900, 0x3f928,
1009 1013                  0x3f930, 0x3f948,
1010 1014                  0x3f960, 0x3f968,
1011 1015                  0x3f970, 0x3f99c,
1012 1016                  0x3f9f0, 0x3fa38,
1013 1017                  0x3fa40, 0x3fa40,
1014 1018                  0x3fa48, 0x3fa50,
1015 1019                  0x3fa5c, 0x3fa64,
1016 1020                  0x3fa70, 0x3fab8,
1017 1021                  0x3fac0, 0x3fae4,
1018 1022                  0x3faf8, 0x3fb10,
1019 1023                  0x3fb28, 0x3fb28,
1020 1024                  0x3fb3c, 0x3fb50,
1021 1025                  0x3fbf0, 0x3fc10,
1022 1026                  0x3fc28, 0x3fc28,
1023 1027                  0x3fc3c, 0x3fc50,
1024 1028                  0x3fcf0, 0x3fcfc,
1025 1029                  0x40000, 0x4000c,
1026 1030                  0x40040, 0x40050,
1027 1031                  0x40060, 0x40068,
1028 1032                  0x4007c, 0x4008c,
1029 1033                  0x40094, 0x400b0,
1030 1034                  0x400c0, 0x40144,
1031 1035                  0x40180, 0x4018c,
1032 1036                  0x40200, 0x40254,
1033 1037                  0x40260, 0x40264,
1034 1038                  0x40270, 0x40288,
1035 1039                  0x40290, 0x40298,
1036 1040                  0x402ac, 0x402c8,
1037 1041                  0x402d0, 0x402e0,
1038 1042                  0x402f0, 0x402f0,
1039 1043                  0x40300, 0x4033c,
1040 1044                  0x403f8, 0x403fc,
1041 1045                  0x41304, 0x413c4,
1042 1046                  0x41400, 0x4140c,
1043 1047                  0x41414, 0x4141c,
1044 1048                  0x41480, 0x414d0,
1045 1049                  0x44000, 0x44054,
1046 1050                  0x4405c, 0x44078,
1047 1051                  0x440c0, 0x44174,
1048 1052                  0x44180, 0x441ac,
1049 1053                  0x441b4, 0x441b8,
1050 1054                  0x441c0, 0x44254,
1051 1055                  0x4425c, 0x44278,
1052 1056                  0x442c0, 0x44374,
1053 1057                  0x44380, 0x443ac,
1054 1058                  0x443b4, 0x443b8,
1055 1059                  0x443c0, 0x44454,
1056 1060                  0x4445c, 0x44478,
1057 1061                  0x444c0, 0x44574,
1058 1062                  0x44580, 0x445ac,
1059 1063                  0x445b4, 0x445b8,
1060 1064                  0x445c0, 0x44654,
1061 1065                  0x4465c, 0x44678,
1062 1066                  0x446c0, 0x44774,
1063 1067                  0x44780, 0x447ac,
1064 1068                  0x447b4, 0x447b8,
1065 1069                  0x447c0, 0x44854,
1066 1070                  0x4485c, 0x44878,
1067 1071                  0x448c0, 0x44974,
1068 1072                  0x44980, 0x449ac,
1069 1073                  0x449b4, 0x449b8,
1070 1074                  0x449c0, 0x449fc,
1071 1075                  0x45000, 0x45004,
1072 1076                  0x45010, 0x45030,
1073 1077                  0x45040, 0x45060,
1074 1078                  0x45068, 0x45068,
1075 1079                  0x45080, 0x45084,
1076 1080                  0x450a0, 0x450b0,
1077 1081                  0x45200, 0x45204,
1078 1082                  0x45210, 0x45230,
1079 1083                  0x45240, 0x45260,
1080 1084                  0x45268, 0x45268,
1081 1085                  0x45280, 0x45284,
1082 1086                  0x452a0, 0x452b0,
1083 1087                  0x460c0, 0x460e4,
1084 1088                  0x47000, 0x4703c,
1085 1089                  0x47044, 0x4708c,
1086 1090                  0x47200, 0x47250,
1087 1091                  0x47400, 0x47408,
1088 1092                  0x47414, 0x47420,
1089 1093                  0x47600, 0x47618,
1090 1094                  0x47800, 0x47814,
1091 1095                  0x48000, 0x4800c,
1092 1096                  0x48040, 0x48050,
1093 1097                  0x48060, 0x48068,
1094 1098                  0x4807c, 0x4808c,
1095 1099                  0x48094, 0x480b0,
1096 1100                  0x480c0, 0x48144,
1097 1101                  0x48180, 0x4818c,
1098 1102                  0x48200, 0x48254,
1099 1103                  0x48260, 0x48264,
1100 1104                  0x48270, 0x48288,
1101 1105                  0x48290, 0x48298,
1102 1106                  0x482ac, 0x482c8,
1103 1107                  0x482d0, 0x482e0,
1104 1108                  0x482f0, 0x482f0,
1105 1109                  0x48300, 0x4833c,
1106 1110                  0x483f8, 0x483fc,
1107 1111                  0x49304, 0x493c4,
1108 1112                  0x49400, 0x4940c,
1109 1113                  0x49414, 0x4941c,
1110 1114                  0x49480, 0x494d0,
1111 1115                  0x4c000, 0x4c054,
1112 1116                  0x4c05c, 0x4c078,
1113 1117                  0x4c0c0, 0x4c174,
1114 1118                  0x4c180, 0x4c1ac,
1115 1119                  0x4c1b4, 0x4c1b8,
1116 1120                  0x4c1c0, 0x4c254,
1117 1121                  0x4c25c, 0x4c278,
1118 1122                  0x4c2c0, 0x4c374,
1119 1123                  0x4c380, 0x4c3ac,
1120 1124                  0x4c3b4, 0x4c3b8,
1121 1125                  0x4c3c0, 0x4c454,
1122 1126                  0x4c45c, 0x4c478,
1123 1127                  0x4c4c0, 0x4c574,
1124 1128                  0x4c580, 0x4c5ac,
1125 1129                  0x4c5b4, 0x4c5b8,
1126 1130                  0x4c5c0, 0x4c654,
1127 1131                  0x4c65c, 0x4c678,
1128 1132                  0x4c6c0, 0x4c774,
1129 1133                  0x4c780, 0x4c7ac,
1130 1134                  0x4c7b4, 0x4c7b8,
1131 1135                  0x4c7c0, 0x4c854,
1132 1136                  0x4c85c, 0x4c878,
1133 1137                  0x4c8c0, 0x4c974,
1134 1138                  0x4c980, 0x4c9ac,
1135 1139                  0x4c9b4, 0x4c9b8,
1136 1140                  0x4c9c0, 0x4c9fc,
1137 1141                  0x4d000, 0x4d004,
1138 1142                  0x4d010, 0x4d030,
1139 1143                  0x4d040, 0x4d060,
1140 1144                  0x4d068, 0x4d068,
1141 1145                  0x4d080, 0x4d084,
1142 1146                  0x4d0a0, 0x4d0b0,
1143 1147                  0x4d200, 0x4d204,
1144 1148                  0x4d210, 0x4d230,
1145 1149                  0x4d240, 0x4d260,
1146 1150                  0x4d268, 0x4d268,
1147 1151                  0x4d280, 0x4d284,
1148 1152                  0x4d2a0, 0x4d2b0,
1149 1153                  0x4e0c0, 0x4e0e4,
1150 1154                  0x4f000, 0x4f03c,
1151 1155                  0x4f044, 0x4f08c,
1152 1156                  0x4f200, 0x4f250,
1153 1157                  0x4f400, 0x4f408,
1154 1158                  0x4f414, 0x4f420,
1155 1159                  0x4f600, 0x4f618,
1156 1160                  0x4f800, 0x4f814,
1157 1161                  0x50000, 0x50084,
1158 1162                  0x50090, 0x500cc,
1159 1163                  0x50400, 0x50400,
1160 1164                  0x50800, 0x50884,
1161 1165                  0x50890, 0x508cc,
1162 1166                  0x50c00, 0x50c00,
1163 1167                  0x51000, 0x5101c,
1164 1168                  0x51300, 0x51308,
1165 1169          };
1166 1170  
1167 1171          if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
1168 1172                  return (EFAULT);
1169 1173  
1170 1174          if (r.len > T4_REGDUMP_SIZE)
1171 1175                  r.len = T4_REGDUMP_SIZE;
1172 1176          else if (r.len < T4_REGDUMP_SIZE)
1173 1177                  return (E2BIG);
1174 1178  
1175 1179          r.version = mk_adap_vers(sc);
1176 1180  
1177 1181          if (is_t4(sc->params.chip)) {
1178 1182                  reg_ranges = &t4_reg_ranges[0];
1179 1183                  arr_size = ARRAY_SIZE(t4_reg_ranges);
1180 1184                  buf_size = T4_REGDUMP_SIZE;
1181 1185          } else {
1182 1186                  reg_ranges = &t5_reg_ranges[0];
1183 1187                  arr_size = ARRAY_SIZE(t5_reg_ranges);
1184 1188                  buf_size = T5_REGDUMP_SIZE;
1185 1189          }
1186 1190  
1187 1191          buf = kmem_zalloc(buf_size, KM_SLEEP);
1188 1192          if (buf == NULL)
1189 1193                  return (ENOMEM);
1190 1194   
1191 1195          for (i = 0; i < arr_size; i += 2)
1192 1196                  reg_block_dump(sc, buf, reg_ranges[i], reg_ranges[i + 1]);
1193 1197  
1194 1198          if (ddi_copyout(buf, r.data, r.len, flags) < 0)
1195 1199                  rc = EFAULT;
1196 1200  
1197 1201          if (rc == 0 && ddi_copyout(&r, data, sizeof (r), flags) < 0)
1198 1202                  rc = EFAULT;
1199 1203  
1200 1204          kmem_free(buf, buf_size);
1201 1205          return (rc);
1202 1206  }
1203 1207  
1204 1208  static int
1205 1209  get_sge_context(struct adapter *sc, void *data, int flags)
1206 1210  {
1207 1211          struct t4_sge_context sgec;
1208 1212          uint32_t buff[SGE_CTXT_SIZE / 4];
1209 1213          int rc = 0;
1210 1214  
1211 1215          if (ddi_copyin(data, &sgec, sizeof (sgec), flags) < 0) {
1212 1216                  rc = EFAULT;
1213 1217                  goto _exit;
1214 1218          }
1215 1219  
1216 1220          if (sgec.len < SGE_CTXT_SIZE || sgec.addr > M_CTXTQID) {
1217 1221                  rc = EINVAL;
1218 1222                  goto _exit;
1219 1223          }
1220 1224  
1221 1225          if ((sgec.mem_id != T4_CTXT_EGRESS) && (sgec.mem_id != T4_CTXT_FLM) &&
1222 1226              (sgec.mem_id != T4_CTXT_INGRESS)) {
1223 1227                  rc = EINVAL;
1224 1228                  goto _exit;
1225 1229          }
1226 1230  
1227 1231          rc = (sc->flags & FW_OK) ?
1228 1232              -t4_sge_ctxt_rd(sc, sc->mbox, sgec.addr, sgec.mem_id, buff) :
1229 1233              -t4_sge_ctxt_rd_bd(sc, sgec.addr, sgec.mem_id, buff);
1230 1234          if (rc != 0)
1231 1235                  goto _exit;
1232 1236  
1233 1237          sgec.version = 4 | (sc->params.chip << 10);
1234 1238  
1235 1239          /* copyout data and then t4_sge_context */
1236 1240          rc = ddi_copyout(buff, sgec.data, sgec.len, flags);
1237 1241          if (rc == 0)
1238 1242                  rc = ddi_copyout(&sgec, data, sizeof (sgec), flags);
1239 1243          /* if ddi_copyout fails, return EFAULT - for either of the two */
1240 1244          if (rc != 0)
1241 1245                  rc = EFAULT;
1242 1246  
1243 1247  _exit:
1244 1248          return (rc);
1245 1249  }
1246 1250  
1247 1251  static int
1248 1252  read_tid_tab(struct adapter *sc, void *data, int flags)
1249 1253  {
1250 1254          struct t4_tid_info t4tid;
1251 1255          uint32_t *buf, *b;
1252 1256          struct tid_info *t = &sc->tids;
1253 1257          int rc = 0;
1254 1258  
1255 1259          if (ddi_copyin(data, &t4tid, sizeof (t4tid), flags) < 0) {
1256 1260                  rc = EFAULT;
1257 1261                  goto _exit;
1258 1262          }
1259 1263  
1260 1264          buf = b = kmem_zalloc(t4tid.len, KM_NOSLEEP);
1261 1265          if (buf == NULL) {
1262 1266                  rc = ENOMEM;
1263 1267                  goto _exit;
1264 1268          }
1265 1269  
1266 1270          *b++ = t->tids_in_use;
1267 1271          *b++ = t->atids_in_use;
1268 1272          *b = t->stids_in_use;
1269 1273  
1270 1274          if (ddi_copyout(buf, t4tid.data, t4tid.len, flags) < 0)
1271 1275                  rc = EFAULT;
1272 1276  
1273 1277          kmem_free(buf, t4tid.len);
1274 1278  
1275 1279  _exit:
1276 1280          return (rc);
1277 1281  }
1278 1282  
1279 1283  /*
1280 1284   * Verify that the memory range specified by the addr/len pair is valid and lies
1281 1285   * entirely within a single region (EDCx or MCx).
1282 1286   */
1283 1287  static int
1284 1288  validate_mem_range(struct adapter *sc, uint32_t addr, int len)
1285 1289  {
1286 1290          uint32_t em, addr_len, maddr, mlen;
1287 1291  
1288 1292          /* Memory can only be accessed in naturally aligned 4 byte units */
1289 1293          if (addr & 3 || len & 3 || len == 0)
1290 1294                  return (EINVAL);
1291 1295  
1292 1296          /* Enabled memories */
1293 1297          em = t4_read_reg(sc, A_MA_TARGET_MEM_ENABLE);
1294 1298          if (em & F_EDRAM0_ENABLE) {
1295 1299                  addr_len = t4_read_reg(sc, A_MA_EDRAM0_BAR);
1296 1300                  maddr = G_EDRAM0_BASE(addr_len) << 20;
1297 1301                  mlen = G_EDRAM0_SIZE(addr_len) << 20;
1298 1302                  if (mlen > 0 && addr >= maddr && addr < maddr + mlen &&
1299 1303                                  addr + len <= maddr + mlen)
1300 1304                          return (0);
1301 1305          }
1302 1306          if (em & F_EDRAM1_ENABLE) {
1303 1307                  addr_len = t4_read_reg(sc, A_MA_EDRAM1_BAR);
1304 1308                  maddr = G_EDRAM1_BASE(addr_len) << 20;
1305 1309                  mlen = G_EDRAM1_SIZE(addr_len) << 20;
1306 1310                  if (mlen > 0 && addr >= maddr && addr < maddr + mlen &&
1307 1311                                  addr + len <= maddr + mlen)
1308 1312                          return (0);
1309 1313          }
1310 1314          if (em & F_EXT_MEM_ENABLE) {
1311 1315                  addr_len = t4_read_reg(sc, A_MA_EXT_MEMORY_BAR);
1312 1316                  maddr = G_EXT_MEM_BASE(addr_len) << 20;
1313 1317                  mlen = G_EXT_MEM_SIZE(addr_len) << 20;
1314 1318                  if (mlen > 0 && addr >= maddr && addr < maddr + mlen &&
1315 1319                                  addr + len <= maddr + mlen)
1316 1320                          return (0);
1317 1321          }
1318 1322          if (!is_t4(sc->params.chip) && em & F_EXT_MEM1_ENABLE) {
1319 1323                  addr_len = t4_read_reg(sc, A_MA_EXT_MEMORY1_BAR);
1320 1324                  maddr = G_EXT_MEM1_BASE(addr_len) << 20;
1321 1325                  mlen = G_EXT_MEM1_SIZE(addr_len) << 20;
1322 1326                  if (mlen > 0 && addr >= maddr && addr < maddr + mlen &&
1323 1327                                  addr + len <= maddr + mlen)
1324 1328                          return (0);
1325 1329          }
1326 1330  
1327 1331          return (EFAULT);
1328 1332  }
1329 1333  
1330 1334  static int
1331 1335  read_card_mem(struct adapter *sc, void *data, int flags)
1332 1336  {
1333 1337          struct t4_mem_range mr;
1334 1338          uint32_t addr, off, remaining, i, n;
1335 1339          uint32_t *buf, *b;
1336 1340          int rc = 0;
1337 1341          uint32_t mw_base, mw_aperture;
1338 1342          uint8_t *dst;
1339 1343  
1340 1344          if (ddi_copyin(data, &mr, sizeof (mr), flags) < 0) {
1341 1345                  rc = EFAULT;
1342 1346                  goto _exit;
1343 1347          }
1344 1348  
1345 1349          rc = validate_mem_range(sc, mr.addr, mr.len);
1346 1350          if (rc != 0)
1347 1351                  return (rc);
1348 1352  
1349 1353          memwin_info(sc, 2, &mw_base, &mw_aperture);
1350 1354          buf = b = kmem_zalloc(min(mr.len, mw_aperture), KM_NOSLEEP);
1351 1355          if (buf == NULL) {
1352 1356                  rc = ENOMEM;
1353 1357                  goto _exit;
1354 1358          }
1355 1359  
1356 1360          addr = mr.addr;
1357 1361          remaining = mr.len;
1358 1362          dst = (void *)mr.data;
1359 1363  
1360 1364          while (remaining) {
1361 1365                  off = position_memwin(sc, 2, addr);
1362 1366  
1363 1367                  /* number of bytes that we'll copy in the inner loop */
1364 1368                  n = min(remaining, mw_aperture - off);
1365 1369  
1366 1370                  for (i = 0; i < n; i += 4)
1367 1371                          *b++ = t4_read_reg(sc, mw_base + off + i);
1368 1372                  rc = ddi_copyout(buf, dst, n, flags);
1369 1373                  if (rc != 0) {
1370 1374                          rc = EFAULT;
1371 1375                          break;
1372 1376                  }
1373 1377  
1374 1378                  b = buf;
1375 1379                  dst += n;
1376 1380                  remaining -= n;
1377 1381                  addr += n;
1378 1382          }
1379 1383  
1380 1384          kmem_free(buf, min(mr.len, mw_aperture));
1381 1385  _exit:
1382 1386          return (rc);
1383 1387  }
1384 1388  
1385 1389  static int
1386 1390  get_devlog(struct adapter *sc, void *data, int flags)
1387 1391  {
1388 1392          struct devlog_params *dparams = &sc->params.devlog;
1389 1393          struct fw_devlog_e *buf;
1390 1394          struct t4_devlog dl;
1391 1395          int rc = 0;
1392 1396  
1393 1397          if (ddi_copyin(data, &dl, sizeof (dl), flags) < 0) {
1394 1398                  rc = EFAULT;
1395 1399                  goto done;
1396 1400          }
1397 1401  
1398 1402          if (dparams->start == 0) {
1399 1403                  dparams->memtype = 0;
1400 1404                  dparams->start = 0x84000;
1401 1405                  dparams->size = 32768;
1402 1406          }
1403 1407  
1404 1408          if (dl.len < dparams->size) {
1405 1409                  dl.len = dparams->size;
1406 1410                  rc = ddi_copyout(&dl, data, sizeof (dl), flags);
1407 1411                  /*
1408 1412                   * rc = 0 indicates copyout was successful, then return ENOBUFS
1409 1413                   * to indicate that the buffer size was not enough. Return of
1410 1414                   * EFAULT indicates that the copyout was not successful.
1411 1415                   */
1412 1416                  rc = (rc == 0) ? ENOBUFS : EFAULT;
1413 1417                  goto done;
1414 1418          }
1415 1419  
1416 1420          buf = kmem_zalloc(dparams->size, KM_NOSLEEP);
1417 1421          if (buf == NULL) {
1418 1422                  rc = ENOMEM;
  
    | 
      ↓ open down ↓ | 
    1317 lines elided | 
    
      ↑ open up ↑ | 
  
1419 1423                  goto done;
1420 1424          }
1421 1425  
1422 1426          rc = -t4_memory_rw(sc, sc->params.drv_memwin, dparams->memtype,
1423 1427                             dparams->start, dparams->size, (void *)buf,
1424 1428                             T4_MEMORY_READ);
1425 1429          if (rc != 0)
1426 1430                  goto done1;
1427 1431  
1428 1432          /* Copyout device log buffer and then carrier buffer */
1429      -        if (ddi_copyout(buf, dl.data, dl.len, flags) < 0)
     1433 +        if (ddi_copyout(buf, (void *)((uintptr_t)data + sizeof(dl)), dl.len,
     1434 +            flags) < 0)
1430 1435                  rc = EFAULT;
1431      -        else if (ddi_copyout(&dl, data, sizeof (dl), flags) < 0)
     1436 +
     1437 +        if (ddi_copyout(&dl, data, sizeof(dl), flags) < 0)
1432 1438                  rc = EFAULT;
1433 1439  
1434 1440  done1:
1435 1441          kmem_free(buf, dparams->size);
1436 1442  
1437 1443  done:
1438 1444          return (rc);
1439 1445  }
1440 1446  
1441 1447  static int
1442 1448  read_cim_qcfg(struct adapter *sc, void *data, int flags)
1443 1449  {
1444 1450          struct t4_cim_qcfg t4cimqcfg;
1445 1451          int rc = 0;
1446 1452          unsigned int ibq_rdaddr, obq_rdaddr, nq;
1447 1453  
1448 1454          if (ddi_copyin(data, &t4cimqcfg, sizeof (t4cimqcfg), flags) < 0) {
1449 1455                  rc = EFAULT;
1450 1456                  goto _exit;
1451 1457          }
1452 1458  
1453 1459          if (is_t4(sc->params.chip)) {
1454 1460                  t4cimqcfg.num_obq = CIM_NUM_OBQ;
1455 1461                  ibq_rdaddr = A_UP_IBQ_0_RDADDR;
1456 1462                  obq_rdaddr = A_UP_OBQ_0_REALADDR;
1457 1463          } else {
1458 1464                  t4cimqcfg.num_obq = CIM_NUM_OBQ_T5;
1459 1465                  ibq_rdaddr = A_UP_IBQ_0_SHADOW_RDADDR;
1460 1466                  obq_rdaddr = A_UP_OBQ_0_SHADOW_REALADDR;
1461 1467          }
1462 1468          nq = CIM_NUM_IBQ + t4cimqcfg.num_obq;
1463 1469   
1464 1470          rc = -t4_cim_read(sc, ibq_rdaddr, 4 * nq, t4cimqcfg.stat);
1465 1471          if (rc == 0)
1466 1472                  rc = -t4_cim_read(sc, obq_rdaddr, 2 * t4cimqcfg.num_obq,
1467 1473                      t4cimqcfg.obq_wr);
1468 1474          if (rc != 0)
1469 1475                  return (rc);
1470 1476  
1471 1477          t4_read_cimq_cfg(sc, t4cimqcfg.base, t4cimqcfg.size, t4cimqcfg.thres);
1472 1478  
1473 1479          if (ddi_copyout(&t4cimqcfg, data, sizeof (t4cimqcfg), flags) < 0)
1474 1480                  rc = EFAULT;
1475 1481  
1476 1482  _exit:
1477 1483          return (rc);
1478 1484  }
1479 1485  
1480 1486  static int
1481 1487  read_edc(struct adapter *sc, void *data, int flags)
1482 1488  {
1483 1489          struct t4_edc t4edc;
1484 1490          int rc = 0;
1485 1491          u32 count, pos = 0;
1486 1492          u32 memoffset;
1487 1493          __be32 *edc = NULL;
1488 1494  
1489 1495          if (ddi_copyin(data, &t4edc, sizeof (t4edc), flags) < 0) {
1490 1496                  rc = EFAULT;
1491 1497                  goto _exit;
1492 1498          }
1493 1499  
1494 1500          if (t4edc.mem > 2)
1495 1501                  goto _exit;
1496 1502  
1497 1503          edc = kmem_zalloc(t4edc.len, KM_NOSLEEP);
1498 1504          if (edc == NULL) {
1499 1505                  rc = ENOMEM;
1500 1506                  goto _exit;
1501 1507          }
1502 1508          /*
1503 1509           * Offset into the region of memory which is being accessed
1504 1510           * MEM_EDC0 = 0
1505 1511           * MEM_EDC1 = 1
1506 1512           * MEM_MC   = 2
1507 1513           */
1508 1514          memoffset = (t4edc.mem * (5 * 1024 * 1024));
1509 1515          count = t4edc.len;
1510 1516          pos = t4edc.pos;
1511 1517  
1512 1518          while (count) {
1513 1519                  u32 len;
1514 1520  
1515 1521                  rc = t4_memory_rw(sc, sc->params.drv_memwin, memoffset, pos,
1516 1522                                    count, edc, T4_MEMORY_READ);
1517 1523                  if (rc != 0) {
1518 1524                          kmem_free(edc, t4edc.len);
1519 1525                          goto _exit;
1520 1526                  }
1521 1527  
1522 1528                  len = MEMWIN0_APERTURE;
1523 1529                  pos += len;
1524 1530                  count -= len;
1525 1531          }
1526 1532  
1527 1533          if (ddi_copyout(edc, t4edc.data, t4edc.len, flags) < 0)
1528 1534                  rc = EFAULT;
1529 1535  
1530 1536          kmem_free(edc, t4edc.len);
1531 1537  _exit:
1532 1538          return (rc);
1533 1539  }
1534 1540  
1535 1541  static int
1536 1542  read_cim_ibq(struct adapter *sc, void *data, int flags)
1537 1543  {
1538 1544          struct t4_ibq t4ibq;
1539 1545          int rc = 0;
1540 1546          __be64 *buf;
1541 1547  
1542 1548          if (ddi_copyin(data, &t4ibq, sizeof (t4ibq), flags) < 0) {
1543 1549                  rc = EFAULT;
1544 1550                  goto _exit;
1545 1551          }
1546 1552  
1547 1553          buf = kmem_zalloc(t4ibq.len, KM_NOSLEEP);
1548 1554          if (buf == NULL) {
1549 1555                  rc = ENOMEM;
1550 1556                  goto _exit;
1551 1557          }
1552 1558  
1553 1559          rc = t4_read_cim_ibq(sc, 3, (u32 *)buf, CIM_IBQ_SIZE * 4);
1554 1560          if (rc < 0) {
1555 1561                  kmem_free(buf, t4ibq.len);
1556 1562                  return (rc);
1557 1563          } else
1558 1564                  rc = 0;
1559 1565  
1560 1566          if (ddi_copyout(buf, t4ibq.data, t4ibq.len, flags) < 0)
1561 1567                  rc = EFAULT;
1562 1568  
1563 1569          kmem_free(buf, t4ibq.len);
1564 1570  
1565 1571  _exit:
1566 1572          return (rc);
1567 1573  }
1568 1574  
1569 1575  static int
1570 1576  read_cim_la(struct adapter *sc, void *data, int flags)
1571 1577  {
1572 1578          struct t4_cim_la t4cimla;
1573 1579          int rc = 0;
1574 1580          unsigned int cfg;
1575 1581          __be64 *buf;
1576 1582  
1577 1583          rc = t4_cim_read(sc, A_UP_UP_DBG_LA_CFG, 1, &cfg);
1578 1584          if (rc != 0)
1579 1585                  return (rc);
1580 1586  
1581 1587          if (ddi_copyin(data, &t4cimla, sizeof (t4cimla), flags) < 0) {
1582 1588                  rc = EFAULT;
1583 1589                  goto _exit;
1584 1590          }
1585 1591  
1586 1592          buf = kmem_zalloc(t4cimla.len, KM_NOSLEEP);
1587 1593          if (buf == NULL) {
1588 1594                  rc = ENOMEM;
1589 1595                  goto _exit;
1590 1596          }
1591 1597  
1592 1598          rc = t4_cim_read_la(sc, (u32 *)buf, NULL);
1593 1599          if (rc != 0) {
1594 1600                  kmem_free(buf, t4cimla.len);
1595 1601                  return (rc);
1596 1602          }
1597 1603  
1598 1604          if (ddi_copyout(buf, t4cimla.data, t4cimla.len, flags) < 0)
1599 1605                  rc = EFAULT;
1600 1606  
1601 1607          kmem_free(buf, t4cimla.len);
1602 1608  
1603 1609  _exit:
1604 1610          return (rc);
1605 1611  }
1606 1612  
1607 1613  static int
1608 1614  read_mbox(struct adapter *sc, void *data, int flags)
1609 1615  {
1610 1616          struct t4_mbox t4mbox;
1611 1617          int rc = 0, i;
1612 1618          __be64 *p, *buf;
1613 1619  
1614 1620          u32 data_reg = PF_REG(4, A_CIM_PF_MAILBOX_DATA);
1615 1621  
1616 1622          if (ddi_copyin(data, &t4mbox, sizeof (t4mbox), flags) < 0) {
1617 1623                  rc = EFAULT;
1618 1624                  goto _exit;
1619 1625          }
1620 1626  
1621 1627          buf = p = kmem_zalloc(t4mbox.len, KM_NOSLEEP);
1622 1628          if (buf == NULL) {
1623 1629                  rc = ENOMEM;
1624 1630                  goto _exit;
1625 1631          }
1626 1632  
1627 1633          for (i = 0; i < t4mbox.len; i += 8, p++)
  
    | 
      ↓ open down ↓ | 
    186 lines elided | 
    
      ↑ open up ↑ | 
  
1628 1634                  *p =  t4_read_reg64(sc, data_reg + i);
1629 1635  
1630 1636          if (ddi_copyout(buf, t4mbox.data, t4mbox.len, flags) < 0)
1631 1637                  rc = EFAULT;
1632 1638  
1633 1639          kmem_free(buf, t4mbox.len);
1634 1640  
1635 1641  _exit:
1636 1642          return (rc);
1637 1643  }
     1644 +
     1645 +static int
     1646 +flash_fw(struct adapter *sc, void *data, int flags)
     1647 +{
     1648 +        unsigned int mbox = M_PCIE_FW_MASTER + 1;
     1649 +        struct t4_ldfw fw;
     1650 +        u8 *ptr = NULL;
     1651 +        int rc = 0;
     1652 +
     1653 +        if (ddi_copyin(data, &fw, sizeof(struct t4_ldfw), flags) < 0)
     1654 +                return EFAULT;
     1655 +
     1656 +        if (!fw.len)
     1657 +                return EINVAL;
     1658 +
     1659 +        ptr = (u8 *)kmem_zalloc(fw.len, KM_NOSLEEP);
     1660 +        if (ptr == NULL)
     1661 +                return ENOMEM;
     1662 +
     1663 +        if (ddi_copyin((void *)((uintptr_t)data + sizeof(fw)), ptr, fw.len,
     1664 +            flags) < 0) {
     1665 +                kmem_free(ptr, fw.len);
     1666 +                return EFAULT;
     1667 +        }
     1668 +
     1669 +        if (sc->flags & FULL_INIT_DONE)
     1670 +                mbox = sc->mbox;
     1671 +
     1672 +        rc = -t4_fw_upgrade(sc, mbox, ptr, fw.len, true);
     1673 +
     1674 +        kmem_free(ptr, fw.len);
     1675 +
     1676 +        return (rc);
     1677 +}
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX