]> git.openfabrics.org - ~adrianc/mstflint.git/commitdiff
porting of mft-3.6.0 to mstflint-3.6.0
authorAdrian Chiris <adrianc@mellanox.com>
Mon, 31 Mar 2014 13:38:43 +0000 (16:38 +0300)
committerAdrian Chiris <adrianc@mellanox.com>
Mon, 31 Mar 2014 13:38:43 +0000 (16:38 +0300)
101 files changed:
Makefile.am
README
cmdparser/cmdparser.cpp
cmdparser/my_getopt.c
cmdparser/my_getopt.h
common/bit_slice.h
common/compatibility.h
common/tools_utils.h [new file with mode: 0755]
common/tools_version.h
configure.ac
dev_mgt/tools_dev_types.c
dev_mgt/tools_dev_types.h
flint/Makefile.am
flint/cmd_line_parser.cpp
flint/err_msgs.h
flint/flint.cpp
flint/flint.h
flint/flint_params.cpp
flint/flint_params.h
flint/subcommands.cpp
flint/subcommands.h
gitversion.sh
include/mtcr_ul/mtcr.h
man/mstflint.1
mflash/Makefile.am
mflash/internal_packets.c [deleted file]
mflash/internal_packets.h [deleted file]
mflash/internal_packets_types.h [deleted file]
mflash/mflash.c
mflash/mflash.h
mflash/mflash_access_layer.c
mflash/mflash_access_layer.h
mflash/mflash_common.c [deleted file]
mflash/mflash_common.h [deleted file]
mflash/mflash_common_structs.h [new file with mode: 0644]
mflash/mflash_inband.c [deleted file]
mflash/mflash_inband.h [deleted file]
mflash/mflash_pack_layer.c [new file with mode: 0755]
mflash/mflash_pack_layer.h [new file with mode: 0755]
mflash/mflash_types.h [new file with mode: 0644]
mflash/packets_common.c [deleted file]
mflash/packets_common.h [deleted file]
mft_utils/Makefile.am [new file with mode: 0644]
mft_utils/mft_sig_handler.c [new file with mode: 0644]
mft_utils/mft_sig_handler.h [new file with mode: 0644]
mlxconfig/Makefile.am [new file with mode: 0755]
mlxconfig/log [new file with mode: 0644]
mlxconfig/mlxcfg_lib.cpp [new file with mode: 0644]
mlxconfig/mlxcfg_lib.h [new file with mode: 0644]
mlxconfig/mlxcfg_parser.cpp [new file with mode: 0644]
mlxconfig/mlxcfg_ui.cpp [new file with mode: 0644]
mlxconfig/mlxcfg_ui.h [new file with mode: 0644]
mlxfwops/lib/Makefile.am
mlxfwops/lib/flint_base.cpp
mlxfwops/lib/flint_base.h
mlxfwops/lib/flint_io.cpp
mlxfwops/lib/flint_io.h
mlxfwops/lib/fs2_ops.cpp
mlxfwops/lib/fs2_ops.h
mlxfwops/lib/fs3_ops.cpp
mlxfwops/lib/fs3_ops.h
mlxfwops/lib/fw_ops.cpp
mlxfwops/lib/fw_ops.h
mlxfwops/lib/mlxconfig.cpp [deleted file]
mlxfwops/lib/mlxconfig.h [deleted file]
mlxfwops/lib/mlxconfig_empty.h [deleted file]
mlxfwops/lib/mlxfwops.cpp
mlxfwops/lib/mlxfwops_com.h
mstdump/crd_lib/Makefile.am
mstdump/crd_lib/crdump.c
mstdump/crd_lib/crdump.h
mstdump/crd_main/mstdump.c
mstdump/mstdump_dbs/ConnectX4.csv [new file with mode: 0644]
mstdump/mstdump_dbs/SwitchIB.csv [new file with mode: 0644]
mstflint.spec.in
mtcr_ul/Makefile.am
mtcr_ul/mtcr_ib.h
mtcr_ul/mtcr_ib_ofed.c
mtcr_ul/mtcr_int_defs.h
mtcr_ul/mtcr_tools_cif.c [new file with mode: 0644]
mtcr_ul/mtcr_tools_cif.h [new file with mode: 0644]
mtcr_ul/mtcr_ul.c
mtcr_ul/packets_common.c [new file with mode: 0644]
mtcr_ul/packets_common.h [new file with mode: 0644]
mtcr_ul/packets_layout.c [new file with mode: 0644]
mtcr_ul/packets_layout.h [new file with mode: 0644]
reg_access/Makefile.am [new file with mode: 0644]
reg_access/reg_access.c [new file with mode: 0644]
reg_access/reg_access.h [new file with mode: 0644]
small_utils/mcra.c
small_utils/mtserver.c
small_utils/vpd.c
tools_layouts/Makefile.am
tools_layouts/adb_to_c_utils.c
tools_layouts/adb_to_c_utils.h
tools_layouts/cibfw_layouts.c
tools_layouts/cibfw_layouts.h
tools_layouts/register_access_layouts.c [new file with mode: 0644]
tools_layouts/register_access_layouts.h [new file with mode: 0644]
tools_layouts/tools_layouts.c [new file with mode: 0644]
tools_layouts/tools_layouts.h [new file with mode: 0644]

index 5f968c6770a5894cc26996c9b24b28822c4cb5e7..c269955f6cb48c631872f509cda044c634888864 100644 (file)
@@ -30,7 +30,7 @@
 # SOFTWARE.
 #--
 
-SUBDIRS = mtcr_ul dev_mgt mflash tools_layouts mlxfwops cmdparser flint small_utils mstdump 
+SUBDIRS = mft_utils tools_layouts mtcr_ul reg_access dev_mgt mflash mlxconfig mlxfwops cmdparser flint small_utils mstdump 
 
 man_MANS = man/mstflint.1
 
diff --git a/README b/README
index c984d3dfadbbc7b2d0deafa60f318907a4af15f9..917aa311b422339257579ed69b207aaaef07aede 100644 (file)
--- a/README
+++ b/README
@@ -30,8 +30,10 @@ MSTFLINT Package - Firmware Burning and Diagnostics Tools
        for later analysis by Mellanox.
     e) mstvpd
        This utility dumps the on-card VPD.
-       f) mstmcra
-          This debug utility reads a single word from the device configuration space.
+    f) mstmcra
+       This debug utility reads/writes a to/from the device configuration register space.
+    g) mstconfig
+       This tool sets or queries non-volatile configurable options for Mellanox HCAs.
 
 3) Installation
     a) Build the mstflint utility. This package is built using a standard
@@ -156,7 +158,10 @@ MSTFLINT Package - Firmware Burning and Diagnostics Tools
        PN: MNPH29C-XTR
        ID: Hawk Dual Port
 
-8) Problem Reporting:
+8) Usage (mstconfig):
+    Read mstconfig usage. Enter "mstconfig -h" for a help message.
+
+9) Problem Reporting:
        Please collect the following information when reporting issues:
 
        uname -a
index b873ce0b91c2d4d8fe191e3afe686e88bd14706d..0e38a05ffd88e3b105d3f243eb350a62023e83e5 100644 (file)
@@ -321,10 +321,14 @@ ParseStatus CommandLineParser::ParseOptions(int argc, char **argv,
         bool to_ignore_unknown_options, list_p_command_line_req *p_ignored_requesters_list)
 {
     char **internal_argv;
-    struct option *options_arr;
+    struct option *options_arr = NULL;
     string options_str = "";
     vec_bool returned_option_types_vec;
     ParseStatus rc = PARSE_ERROR;
+    unsigned num_options = 0;
+    int option_type;
+    int option_index = 0;
+    unsigned i = 0;
 
     //allocate internal_argv
     internal_argv = new char *[argc];
@@ -332,21 +336,26 @@ ParseStatus CommandLineParser::ParseOptions(int argc, char **argv,
         this->SetLastError("Fail to allocate internal argv for parsing");
         return PARSE_ERROR;
     }
-    for (int i = 0; i < argc; ++i) {
-        internal_argv[i] = new char[strlen(argv[i]) + 1];
-        if (!internal_argv[i]) {
-            this->SetLastError("Fail to allocate internal argv[%u] for parsing", i);
-            return PARSE_ERROR;
+    for (int j = 0; j < argc; ++j) {
+        internal_argv[j] = NULL;
+    }
+    for (int j = 0; j < argc; ++j) {
+        internal_argv[j] = new char[strlen(argv[j]) + 1];
+        if (!internal_argv[j]) {
+            this->SetLastError("Fail to allocate internal argv[%u] for parsing", j);
+            rc = PARSE_ERROR;
+                       goto argv_err_exit;
         }
-        strcpy(internal_argv[i], argv[i]);
+        strcpy(internal_argv[j], argv[j]);
     }
 
     //allocate long_options_arr
-    unsigned num_options = this->long_opt_to_req_map.size();
+    num_options = this->long_opt_to_req_map.size();
     options_arr = new struct option[num_options + 1];
     if (!options_arr) {
         this->SetLastError("Fail to allocate long_options_arr");
-        return PARSE_ERROR;
+        rc = PARSE_ERROR;
+        goto parse_exit;
     }
     memset(options_arr, 0, sizeof(struct option)*(num_options + 1));
 
@@ -356,7 +365,7 @@ ParseStatus CommandLineParser::ParseOptions(int argc, char **argv,
      * also create vector of possible options type
      * that can be return by getopt_long_only()
      */
-    unsigned i = 0;
+    i = 0;
     for (list_p_command_line_req::iterator it = this->p_requesters_list.begin();
             it != this->p_requesters_list.end(); ++it) {
         for (vec_option_t::iterator it2 = (*it)->GetOptions().begin();
@@ -385,28 +394,7 @@ ParseStatus CommandLineParser::ParseOptions(int argc, char **argv,
         }
     }
 
-
-/*
-    for (unsigned int i = 0; i < num_options + 1; ++i) {
-        printf("name: %s, has_arg:%d, val:%c\n",
-                options_arr[i].name, options_arr[i].has_arg, options_arr[i].val);
-    }
-    printf("%s\n", options_str.c_str());
-    for (unsigned i = 0; i < returned_option_types_vec.size(); ++i) {
-        if (returned_option_types_vec[i] == true) {
-            if (!i)
-                printf("%d ", 0);
-            else
-                printf("%c ", i);
-        }
-    }
-    printf("\n");
-*/
-
-
     //finally parse all options
-    int option_type;
-    int option_index = 0;
     if (to_ignore_unknown_options == true)
         tools_opterr = 0;
     else
@@ -481,5 +469,10 @@ parse_exit:
     delete [] internal_argv;
     delete [] options_arr;
     return rc;
+argv_err_exit:
+       for (int i = 0; i < argc; ++i)
+        delete [] internal_argv[i];
+    delete [] internal_argv;
+    return rc;
 }
 
index 2a2b97d5be01ee75400367efa8978efba1f327d6..be6281d32588e689d39a7e3cc47e0de4e546596a 100755 (executable)
@@ -2,20 +2,20 @@
     NOTE: getopt is now part of the C library, so if you don't know what
     "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
     before changing it!
+
     Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
          Free Software Foundation, Inc.
+
     The GNU C Library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public License as
     published by the Free Software Foundation; either version 2 of the
     License, or (at your option) any later version.
+
     The GNU C Library is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Library General Public License for more details.
+
     You should have received a copy of the GNU Library General Public
     License along with the GNU C Library; see the file COPYING.LIB.  If not,
     write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  #ifndef _NO_PROTO
  #define _NO_PROTO
  #endif
+
  #ifdef HAVE_CONFIG_H
  #include <config.h>
  #endif
+
  #if !defined (__STDC__) || !__STDC__
  /* This is a separate conditional since some stdc systems
     reject `defined (const)'.  */
@@ -38,9 +38,9 @@
  #define const
  #endif
  #endif
+
  #include <stdio.h>
+
  /* Comment out all this code if we are using the GNU C Library, and are not
     actually compiling the library itself.  This code is part of the GNU C
     Library, but also included in many other GNU distributions.  Compiling
@@ -48,7 +48,7 @@
     (especially if it is a shared library).  Rather than having every GNU
     program understand `configure --with-gnu-libc' and omit the object files,
     it is simpler to just do this in the source for each such file.  */
+
  #define GETOPT_INTERFACE_VERSION 2
  #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
  #include <gnu-versions.h>
@@ -56,9 +56,9 @@
  #define ELIDE_CODE
  #endif
  #endif
+
+
+
  /* This needs to come after some library #include
     to get __GNU_LIBRARY__ defined.  */
  #ifdef  __GNU_LIBRARY__
@@ -67,7 +67,7 @@
  #include <stdlib.h>
  #include <unistd.h>
  #endif  /* GNU C library.  */
+
  #ifdef HAVE_STRING_H
  # include <string.h>       /* strstr / strdup */
  #else
  #  include <strings.h>       /* strstr / strdup */
  # endif
  #endif
+
  #ifdef VMS
  #include <unixlib.h>
  #if HAVE_STRING_H - 0
  #include <string.h>
  #endif
  #endif
-#include <string.h> 
+#include <string.h>
  #ifndef _
  /* This is for other GNU distributions with internationalized messages.
     When compiling libc, the _ macro is predefined.  */
  # define _(msgid)       (msgid)
  #endif
  #endif
+
  /* This version of `getopt' appears to the caller like standard Unix `getopt'
     but it behaves differently for the user, since it allows the user
     to intersperse the options with the other arguments.
+
     As `getopt' works, it permutes the elements of ARGV so that,
     when it is done, all the options precede everything else.  Thus
     all application programs are extended to handle flexible argument order.
+
     Setting the environment variable POSIXLY_CORRECT disables permutation.
     Then the behavior is completely standard.
+
     GNU application programs can use a third alternative mode in which
     they can distinguish the relative order of options and other arguments.  */
+
  #include "my_getopt.h"
+
  /* For communication from `getopt' to the caller.
     When `getopt' finds an option that takes an argument,
     the argument value is returned here.
     Also, when `ordering' is RETURN_IN_ORDER,
     each non-option ARGV-element is returned here.  */
+
  char *tools_optarg = NULL;
+
  /* Index in ARGV of the next element to be scanned.
     This is used for communication to and from the caller
     and for communication between successive calls to `getopt'.
+
     On entry to `getopt', zero means this is the first call; initialize.
+
     When `getopt' returns -1, this is the index of the first of the
     non-option elements that the caller should itself scan.
+
     Otherwise, `tools_optind' communicates from one call to the next
     how much of ARGV has been scanned so far.  */
+
  /* 1003.2 says this must be 1 before any call.  */
  int tools_optind = 1;
+
  /* Formerly, initialization of getopt depended on tools_optind==0, which
     causes problems with re-calling getopt as programs generally don't
     know that. */
+
  int __getopt_initialized = 0;
+
  /* The next char to be scanned in the option-element
     in which the last option character we returned was found.
     This allows us to pick up the scan where we left off.
+
     If this is zero, or a null string, it means resume the scan
     by advancing to the next ARGV-element.  */
+
  static char *nextchar;
+
  /* Callers store zero here to inhibit the error message
     for unrecognized options.  */
+
  int tools_opterr = 1;
+
  /* Set to an option character which was unrecognized.
     This must be initialized on some systems to avoid linking in the
     system's own getopt implementation.  */
+
  int tools_optopt = '?';
+
  /* Describe how to deal with options that follow non-option ARGV-elements.
+
     If the caller did not specify anything,
     the default is REQUIRE_ORDER if the environment variable
     POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
     REQUIRE_ORDER means don't recognize them as options;
     stop option processing when the first non-option is seen.
     This is what Unix does.
     This mode of operation is selected by either setting the environment
     variable POSIXLY_CORRECT, or using `+' as the first character
     of the list of option characters.
+
     PERMUTE is the default.  We permute the contents of ARGV as we scan,
     so that eventually all the non-options are at the end.  This allows options
     to be given in any order, even with programs that were not written to
     expect this.
+
     RETURN_IN_ORDER is an option available to programs that were written
     to expect options and other ARGV-elements in any order and that care about
     the ordering of the two.  We describe each non-option ARGV-element
     as if it were the argument of an option with character code 1.
     Using `-' as the first character of the list of option characters
     selects this mode of operation.
+
     The special argument `--' forces an end of option-scanning regardless
     of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
     `--' can cause `getopt' to return -1 with `tools_optind' != ARGC.  */
+
  static enum
  {
    REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
  } ordering;
+
  /* Value of POSIXLY_CORRECT environment variable.  */
  static char *posixly_correct;
  \f
  #include <string.h>
  #define my_index        strchr
  #else
+
  /* Avoid depending on library functions or files
     whose names are inconsistent.  */
+
  char *getenv ();
+
  static char *
  my_index (str, chr)
       const char *str;
      }
    return 0;
  }
+
  /* If using GCC, we can safely declare strlen this way.
     If not using GCC, it is ok not to declare it.  */
  #ifdef __GNUC__
  extern int strlen (const char *);
  #endif /* not __STDC__ */
  #endif /* __GNUC__ */
+
  #endif /* not __GNU_LIBRARY__ */
  \f
  /* Handle permutation of arguments.  */
+
  /* Describe the part of ARGV that contains non-options that have
     been skipped.  `first_nonopt' is the index in ARGV of the first of them;
     `last_nonopt' is the index after the last of them.  */
+
  static int first_nonopt;
  static int last_nonopt;
+
  #ifdef _LIBC
  /* Bash 2.0 gives us an environment variable containing flags
     indicating ARGV elements that should not be considered arguments.  */
+
  /* Defined in getopt_init.c  */
  extern char *__getopt_nonoption_flags;
+
  static int nonoption_flags_max_len;
  static int nonoption_flags_len;
+
  static int original_argc;
  static char *const *original_argv;
+
  /* Make sure the environment variable bash 2.0 puts in the environment
     is valid for the getopt call we must make sure that the ARGV passed
     to getopt is that one passed to the process.  */
  # ifdef text_set_element
  text_set_element (__libc_subinit, store_args_and_env);
  # endif /* text_set_element */
+
  # define SWAP_FLAGS(ch1, ch2) \
    if (nonoption_flags_len > 0)                                                \
      {                                                                         \
  #else   /* !_LIBC */
  # define SWAP_FLAGS(ch1, ch2)
  #endif  /* _LIBC */
+
  /* Exchange two adjacent subsequences of ARGV.
     One subsequence is elements [first_nonopt,last_nonopt)
     which contains all the non-options that have been skipped so far.
     The other is elements [last_nonopt,tools_optind), which contains all
     the options processed since those non-options were skipped.
+
     `first_nonopt' and `last_nonopt' are relocated so that they describe
     the new indices of the non-options in ARGV after they are moved.  */
+
  #if defined (__STDC__) && __STDC__
  static void exchange (char **);
  #endif
+
  static void
  exchange (argv)
       char **argv;
    int middle = last_nonopt;
    int top = tools_optind;
    char *tem;
+
    /* Exchange the shorter segment with the far end of the longer segment.
       That puts the shorter segment into the right place.
       It leaves the longer segment in the right place overall,
       but it consists of two parts that need to be swapped next.  */
+
  #ifdef _LIBC
    /* First make sure the handling of the `__getopt_nonoption_flags'
       string can work normally.  Our top argument must be in the range
          }
      }
  #endif
+
    while (top > middle && middle > bottom)
      {
        if (top - middle > middle - bottom)
            /* Bottom segment is the short one.  */
            int len = middle - bottom;
            register int i;
+
            /* Swap it with the top part of the top segment.  */
            for (i = 0; i < len; i++)
              {
            /* Top segment is the short one.  */
            int len = top - middle;
            register int i;
+
            /* Swap it with the bottom part of the bottom segment.  */
            for (i = 0; i < len; i++)
              {
            bottom += len;
          }
      }
+
    /* Update records for the slots the non-options now occupy.  */
+
    first_nonopt += (tools_optind - last_nonopt);
    last_nonopt = tools_optind;
  }
+
  /* Initialize the internal data when the first call is made.  */
+
  #if defined (__STDC__) && __STDC__
  static const char *_getopt_initialize (int, char *const *, const char *);
  #endif
    /* Start processing options with ARGV-element 1 (since ARGV-element 0
       is the program name); the sequence of previously skipped
       non-option ARGV-elements is empty.  */
-   (void)argc;
-   (void)argv;
-
+   // avoid compiler warnings
+   (void) argc;
+   (void) argv;
    first_nonopt = last_nonopt = tools_optind;
+
    nextchar = NULL;
+
    posixly_correct = getenv ("POSIXLY_CORRECT");
+
    /* Determine how to handle the ordering of options and nonoptions.  */
+
    if (optstring[0] == '-')
      {
        ordering = RETURN_IN_ORDER;
      ordering = REQUIRE_ORDER;
    else
      ordering = PERMUTE;
+
  #ifdef _LIBC
    if (posixly_correct == NULL
        && argc == original_argc && argv == original_argv)
    else
      nonoption_flags_len = 0;
  #endif
+
    return optstring;
  }
  \f
  /* Scan elements of ARGV (whose length is ARGC) for option characters
     given in OPTSTRING.
+
     If an element of ARGV starts with '-', and is not exactly "-" or "--",
     then it is an option element.  The characters of this element
     (aside from the initial '-') are option characters.  If `getopt'
     is called repeatedly, it returns successively each of the option characters
     from each of the option elements.
+
     If `getopt' finds another option character, it returns that character,
     updating `tools_optind' and `nextchar' so that the next call to `getopt' can
     resume the scan with the following option character or ARGV-element.
+
     If there are no more option characters, `getopt' returns -1.
     Then `tools_optind' is the index in ARGV of the first ARGV-element
     that is not an option.  (The ARGV-elements have been permuted
     so that those that are not options now come last.)
+
     OPTSTRING is a string containing the legitimate option characters.
     If an option character is seen that is not listed in OPTSTRING,
     return '?' after printing an error message.  If you set `tools_opterr' to
     zero, the error message is suppressed but we still return '?'.
+
     If a char in OPTSTRING is followed by a colon, that means it wants an arg,
     so the following text in the same ARGV-element, or the text of the following
     ARGV-element, is returned in `tools_optarg'.  Two colons mean an option that
     wants an optional arg; if there is text in the current ARGV-element,
     it is returned in `tools_optarg', otherwise `tools_optarg' is set to zero.
+
     If OPTSTRING starts with `-' or `+', it requests different methods of
     handling the non-option ARGV-elements.
     See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
     Long-named options begin with `--' instead of `-'.
     Their names may be abbreviated as long as the abbreviation is unique
     or is an exact match for some defined option.  If they have an
     When `getopt' finds a long-named option, it returns 0 if that option's
     `flag' field is nonzero, the value of the option's `val' field
     if the `flag' field is zero.
+
     The elements of ARGV aren't really const, because we permute them.
     But we pretend they're const in the prototype to be compatible
     with other systems.
+
     LONGOPTS is a vector of `struct option' terminated by an
     element containing a name which is zero.
+
     LONGIND returns the index in LONGOPT of the long-named option found.
     It is only valid when a long-named option has been found by the most
     recent call.
+
     If LONG_ONLY is nonzero, '-' as well as '--' can introduce
     long-named options.  */
+
  int
  _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
       int argc;
       int long_only;
  {
    tools_optarg = NULL;
+
    if (tools_optind == 0 || !__getopt_initialized)
      {
        if (tools_optind == 0)
        optstring = _getopt_initialize (argc, argv, optstring);
        __getopt_initialized = 1;
      }
+
    /* Test whether ARGV[tools_optind] points to a non-option argument.
       Either it does not have option syntax, or there is an environment flag
       from the shell indicating it is not an option.  The later information
  #else
  #define NONOPTION_P (argv[tools_optind][0] != '-' || argv[tools_optind][1] == '\0')
  #endif
+
    if (nextchar == NULL || *nextchar == '\0')
      {
        /* Advance to the next ARGV-element.  */
+
        /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
           moved back by the user (who may also have changed the arguments).  */
        if (last_nonopt > tools_optind)
          last_nonopt = tools_optind;
        if (first_nonopt > tools_optind)
          first_nonopt = tools_optind;
+
        if (ordering == PERMUTE)
          {
            /* If we have just processed some options following some non-options,
               exchange them so that the options come first.  */
+
            if (first_nonopt != last_nonopt && last_nonopt != tools_optind)
              exchange ((char **) argv);
            else if (last_nonopt != tools_optind)
              first_nonopt = tools_optind;
+
            /* Skip any additional non-options
               and extend the range of non-options previously skipped.  */
+
            while (tools_optind < argc && NONOPTION_P)
              tools_optind++;
            last_nonopt = tools_optind;
          }
+
        /* The special ARGV-element `--' means premature end of options.
           Skip it like a null option,
           then exchange with previous non-options as if it were an option,
           then skip everything else like a non-option.  */
+
        if (tools_optind != argc && !strcmp (argv[tools_optind], "--"))
          {
            tools_optind++;
+
            if (first_nonopt != last_nonopt && last_nonopt != tools_optind)
              exchange ((char **) argv);
            else if (first_nonopt == last_nonopt)
              first_nonopt = tools_optind;
            last_nonopt = argc;
+
            tools_optind = argc;
          }
+
        /* If we have done all the ARGV-elements, stop the scan
           and back over any non-options that we skipped and permuted.  */
+
        if (tools_optind == argc)
          {
            /* Set the next-arg-index to point at the non-options
              tools_optind = first_nonopt;
            return -1;
          }
+
        /* If we have come to a non-option and did not permute it,
           either stop the scan or describe it to the caller and pass it by.  */
+
        if (NONOPTION_P)
          {
            if (ordering == REQUIRE_ORDER)
            tools_optarg = argv[tools_optind++];
            return 1;
          }
+
        /* We have found another option-ARGV-element.
           Skip the initial punctuation.  */
+
        nextchar = (argv[tools_optind] + 1
                    + (longopts != NULL && argv[tools_optind][1] == '-'));
      }
+
    /* Decode the current option-ARGV-element.  */
+
    /* Check whether the ARGV-element is a long option.
+
       If long_only and the ARGV-element has the form "-f", where f is
       a valid short option, don't consider it an abbreviated form of
       a long option that starts with f.  Otherwise there would be no
       way to give the -f short option.
+
       On the other hand, if there's a long option "fubar" and
       the ARGV-element is "-fu", do consider that an abbreviation of
       the long option, just like "--fu", and not "-f" with arg "u".
+
       This distinction seems to be the most useful approach.  */
+
    if (longopts != NULL
        && (argv[tools_optind][1] == '-'
            || (long_only && (argv[tools_optind][2] || !my_index (optstring, argv[tools_optind][1])))))
        int ambig = 0;
        int indfound = -1;
        int option_index;
+
        for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
          /* Do nothing.  */ ;
+
        /* Test all long options for either exact match
           or abbreviated matches.  */
        for (p = longopts, option_index = 0; p->name; p++, option_index++)
                /* Second or later nonexact match found.  */
                ambig = 1;
            }
+
        if (ambig && !exact)
          {
            if (tools_opterr)
            tools_optopt = 0;
            return '?';
          }
+
        if (pfound != NULL)
          {
            option_index = indfound;
                else
                  {
                    if (tools_opterr) {
-                    if (argv[tools_optind - 1][1] == '-')
+                    if (argv[tools_optind - 1][1] == '-') {
                      /* --option */
                      fprintf (stderr,
                       _("%s: option `--%s' doesn't allow an argument\n"),
                       argv[0], pfound->name);
-                    else
+                   } else {
                      /* +option or -option */
                      fprintf (stderr,
                       _("%s: option `%c%s' doesn't allow an argument\n"),
                       argv[0], argv[tools_optind - 1][0], pfound->name);
+                     }
                    }
                    nextchar += strlen (nextchar);
+
                    tools_optopt = pfound->val;
                    return '?';
                  }
              }
            return pfound->val;
          }
+
        /* Can't find it as a long option.  If this is not getopt_long_only,
           or the option starts with '--' or is not a valid short
           option, then it's an error.
            return '?';
          }
      }
+
    /* Look at and handle the next short option-character.  */
+
    {
      char c = *nextchar++;
      char *temp = my_index (optstring, c);
+
      /* Increment `tools_optind' when we start to process its last character.  */
      if (*nextchar == '\0')
        ++tools_optind;
+
      if (temp == NULL || c == ':')
        {
          if (tools_opterr)
          int ambig = 0;
          int indfound = 0;
          int option_index;
+
          /* This is an option that requires an argument.  */
          if (*nextchar != '\0')
            {
            /* We already incremented `tools_optind' once;
               increment it again when taking next ARGV-elt as argument.  */
            tools_optarg = argv[tools_optind++];
+
          /* tools_optarg is now the argument, see if it's in the
             table of longopts.  */
+
          for (nextchar = nameend = tools_optarg; *nameend && *nameend != '='; nameend++)
            /* Do nothing.  */ ;
+
          /* Test all long options for either exact match
             or abbreviated matches.  */
          for (p = longopts, option_index = 0; p->name; p++, option_index++)
                        fprintf (stderr, _("\
  %s: option `-W %s' doesn't allow an argument\n"),
                                 argv[0], pfound->name);
+
                      nextchar += strlen (nextchar);
                      return '?';
                    }
      return c;
    }
  }
+
  int
  tools_getopt (argc, argv, optstring)
       int argc;
                             (int *) 0,
                             0);
  }
+
  int
  tools_getopt_long (argc, argv, optstring, longopts, longindex)
       int argc;
                             longindex,
                             0);
  }
+
+
  int
  tools_getopt_long_only (argc, argv, optstring, longopts, longindex)
       int argc;
                             longindex,
                             1);
  }
+
  \f
  #ifdef TEST
+
  /* Compile with -DTEST to make an executable for use in testing
     the above definition of `getopt'.  */
+
  int
  main (argc, argv)
       int argc;
  {
    int c;
    int digit_optind = 0;
+
    while (1)
      {
        int this_option_optind = tools_optind ? tools_optind : 1;
+
        c = getopt (argc, argv, "abc:d:0123456789");
        if (c == -1)
          break;
+
        switch (c)
          {
          case '0':
            digit_optind = this_option_optind;
            printf ("option %c\n", c);
            break;
+
          case 'a':
            printf ("option a\n");
            break;
+
          case 'b':
            printf ("option b\n");
            break;
+
          case 'c':
            printf ("option c with value `%s'\n", tools_optarg);
            break;
+
          case '?':
            break;
+
          default:
            printf ("?? getopt returned character code 0%o ??\n", c);
          }
      }
+
    if (tools_optind < argc)
      {
        printf ("non-option ARGV-elements: ");
          printf ("%s ", argv[tools_optind++]);
        printf ("\n");
      }
+
    exit (0);
  }
+
  #endif /* TEST */
 
 int hello()
index 96def528d554d9a89ee6b6d3448df67ef80f8a5a..b470f8142111ae3cd32a5bba29e8d730fdd9ff9a 100755 (executable)
@@ -1,81 +1,81 @@
  /* Declarations for getopt.
     Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
+
     The GNU C Library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public License as
     published by the Free Software Foundation; either version 2 of the
     License, or (at your option) any later version.
+
     The GNU C Library is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Library General Public License for more details.
+
     You should have received a copy of the GNU Library General Public
     License along with the GNU C Library; see the file COPYING.LIB.  If not,
     write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.  */
+
  #ifndef _TOOLS_GETOPT_H
  #define _TOOLS_GETOPT_H
+
  #ifdef  __cplusplus
  extern "C" {
  #endif
+
  /* For communication from `getopt' to the caller.
     When `getopt' finds an option that takes an argument,
     the argument value is returned here.
     Also, when `ordering' is RETURN_IN_ORDER,
     each non-option ARGV-element is returned here.  */
+
  extern char *tools_optarg;
+
  /* Index in ARGV of the next element to be scanned.
     This is used for communication to and from the caller
     and for communication between successive calls to `getopt'.
+
     On entry to `getopt', zero means this is the first call; initialize.
+
     When `getopt' returns -1, this is the index of the first of the
     non-option elements that the caller should itself scan.
+
     Otherwise, `optind' communicates from one call to the next
     how much of ARGV has been scanned so far.  */
+
  extern int tools_optind;
+
  /* Callers store zero here to inhibit the error message `getopt' prints
     for unrecognized options.  */
+
  extern int tools_opterr;
+
  /* Set to an option character which was unrecognized.  */
+
  extern int tools_optopt;
+
  /* Describe the long-named options requested by the application.
     The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
     of `struct option' terminated by an element containing a name which is
     zero.
+
     The field `has_arg' is:
     no_argument          (or 0) if the option does not take an argument,
     required_argument    (or 1) if the option requires an argument,
     optional_argument    (or 2) if the option takes an optional argument.
+
     If the field `flag' is not NULL, it points to a variable that is set
     to the value given in the field `val' when the option is found, but
     left unchanged if the option is not found.
+
     To have a long-named option do something other than set an `int' to
     a compiled-in constant, such as set a value from `optarg', set the
     option's `flag' field to zero and its `val' field to a nonzero
     value (the equivalent single-letter option character, if there is
     one).  For long options that have a zero `flag' field, `getopt'
     returns the contents of the `val' field.  */
+
  struct option
  {
  #if defined (__STDC__) && __STDC__
@@ -89,9 +89,9 @@
    int *flag;
    int val;
  };
+
  /* Names for the values of the `has_arg' field of `struct option'.  */
+
  #define tools_no_argument             0
  #define tools_required_argument       1
  #define tools_optional_argument       2
@@ -118,5 +118,5 @@ int tools_getopt_long_only (
  #ifdef  __cplusplus
  }
  #endif
+
  #endif /* _TOOLS_GETOPT_H */
index 514511cca44dd8b912cea71f22536ccd5085cfc1..f257c9b212c2ec76cfa81ff98f78939ab14a9523 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -29,6 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+
 #ifndef BIT_SLICE_H
 #define BIT_SLICE_H
 
index 76323d3e351b5c6d6d998e15e02b0afa35d0ce82..c49745a45497af2c944b68dc3f6975db59cad466 100644 (file)
@@ -1,25 +1,25 @@
 /*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ * Copyright (C) Jan 2006 Mellanox Technologies Ltd. All rights reserved.
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
+ *
+ *  compatibility.h - Miscellaneous systems compatibility issues
+ *
+ *  Version: $Id: compatibility.h 3261 2007-01-28 14:59:53Z orenk $
+ *
  */
+
+#ifndef COMPATIBILITY_H
+#define COMPATIBILITY_H
+
+#include <stdio.h>
+
+#if defined(__ia64__) || defined(__x86_64__) || defined(__PPC64__)
+    #define U64L       "l"
+#else
+    #define U64L       "ll"
+#endif
+
+
+/* define macros to the architecture of the CPU */
+#if defined(__linux) || defined(__FreeBSD__)             /* __linux || __FreeBSD__ */
+#   if defined(__i386__)
+#       define ARCH_x86
+#   elif defined(__x86_64__)
+#       define ARCH_x86_64
+#   elif defined(__ia64__)
+#       define ARCH_ia64
+#   elif defined(__PPC64__)
+#       define ARCH_ppc64
+#   elif defined(__PPC__)
+#       define ARCH_ppc
+#   elif defined(__aarch64__)
+#       define ARCH_arm64
+#   else
+#       error Unknown CPU architecture using the linux OS
+#   endif
+#elif defined(__MINGW32__) || defined(__MINGW64__)              /* Windows MINGW */
+#   if defined(__MINGW32__)
+#       define ARCH_x86
+#   elif defined(__MINGW64__)
+#       define ARCH_x86_64
+#   else
+#       error Unknown CPU architecture using the windows-mingw OS
+#   endif
+#elif defined(_WIN32) || defined(_WIN64)                /* Windows */
+#   if defined(_WIN32)
+#       define ARCH_x86
+#   elif defined(_WIN64)
+#       define ARCH_x86_64
+#   else
+#       error Unknown CPU architecture using the windows OS
+#   endif
+#else                                                   /* Unknown */
+#   error Unknown OS
+#endif
+
+/* define macros for print fields */
+#define U32D_FMT    "%u"
+#define U32H_FMT    "0x%08x"
+#define UH_FMT          "0x%x"
+#define STR_FMT     "%s"
+#define U16H_FMT    "0x%04x"
+#define U8H_FMT     "0x%02x"
+
+#if defined(ARCH_x86) || defined(ARCH_ppc) || defined(UEFI_BUILD)
+#   if defined(__MINGW32__) || defined(__MINGW64__)
+#       include <inttypes.h>
+#       define U64D_FMT    "0x%"PRId64
+#       define U64H_FMT    "0x%"PRIx64
+#       define U64H_FMT_GEN ""PRIx64
+#       define U48H_FMT    "0x%"PRIx64
+#       define U64D_FMT_GEN ""PRId64
+#   else
+#       define U64D_FMT     "%llu"
+#       define U64H_FMT     "0x%016llx"
+#       define U64H_FMT_GEN "llx"
+#       define U48H_FMT     "0x%012llx"
+#       define U64D_FMT_GEN "llu"
+#   endif
+#elif defined (ARCH_ia64) || defined(ARCH_x86_64) || defined(ARCH_ppc64) || defined(ARCH_arm64)
+#    define U64D_FMT     "%lu"
+#    define U64H_FMT     "0x%016lx"
+#    define U48H_FMT     "0x%012lx"
+#    define U64H_FMT_GEN "lx"
+#    define U64D_FMT_GEN "lu"
+#else
+#   error Unknown architecture
+#endif  /* ARCH */
+
+
+/* define msleep(x) - sleeps for x milliseconds */
+#if defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__)
+    #include <Winsock2.h>
+    #include <winsock2.h>
+    #include <windows.h>
+    #define msleep(x)   Sleep(x)
+#else
+    #include <unistd.h>
+    #define msleep(x)   usleep(((unsigned long)x)*1000)
+#endif
+
+/*
+ * Only for architectures which can't do swab by themselves
+ */
+#define ___my_swab16(x) \
+((u_int16_t)( \
+        (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \
+        (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) ))
+#define ___my_swab32(x) \
+((u_int32_t)( \
+        (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \
+        (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) <<  8) | \
+        (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >>  8) | \
+        (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) ))
+#define ___my_swab64(x) \
+((u_int64_t)( \
+        (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \
+        (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \
+        (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \
+        (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) <<  8) | \
+        (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >>  8) | \
+        (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \
+        (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \
+        (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) ))
+
+/*
+ * Linux
+ */
+#if defined(linux) || defined(__FreeBSD__)
+// #include <asm/byteorder.h>
+    #include <unistd.h>
+    #include <sys/types.h>
+
+    #if defined (__FreeBSD__)
+    #include <sys/endian.h>
+    #else
+    #include <endian.h>
+    #endif
+
+    #undef __be64_to_cpu
+    #undef __be32_to_cpu
+    #undef __be16_to_cpu
+    #undef __cpu_to_be64
+    #undef __cpu_to_be32
+    #undef __cpu_to_be16
+    #undef __le64_to_cpu
+    #undef __le32_to_cpu
+    #undef __le16_to_cpu
+    #undef __cpu_to_le64
+    #undef __cpu_to_le32
+    #undef __cpu_to_le16
+
+    #if __BYTE_ORDER == __LITTLE_ENDIAN
+
+        #define __be64_to_cpu(x) ___my_swab64(x)
+        #define __be32_to_cpu(x) ___my_swab32(x)
+        #define __be16_to_cpu(x) ___my_swab16(x)
+        #define __cpu_to_be64(x) ___my_swab64(x)
+        #define __cpu_to_be32(x) ___my_swab32(x)
+        #define __cpu_to_be16(x) ___my_swab16(x)
+        #define __le64_to_cpu(x) (x)
+        #define __le32_to_cpu(x) (x)
+        #define __le16_to_cpu(x) (x)
+        #define __cpu_to_le64(x) (x)
+        #define __cpu_to_le32(x) (x)
+        #define __cpu_to_le16(x) (x)
+
+    #elif __BYTE_ORDER == __BIG_ENDIAN
+
+        #define __be64_to_cpu(x) (x)
+        #define __be32_to_cpu(x) (x)
+        #define __be16_to_cpu(x) (x)
+        #define __cpu_to_be64(x) (x)
+        #define __cpu_to_be32(x) (x)
+        #define __cpu_to_be16(x) (x)
+        #define __le64_to_cpu(x) ___my_swab64(x)
+        #define __le32_to_cpu(x) ___my_swab32(x)
+        #define __le16_to_cpu(x) ___my_swab16(x)
+        #define __cpu_to_le64(x) ___my_swab64(x)
+        #define __cpu_to_le32(x) ___my_swab32(x)
+        #define __cpu_to_le16(x) ___my_swab16(x)
+
+    #endif // __BYTE_ORDER
+
+#endif
+
+/*
+ * Windows (CYGWIN)
+ */
+#if defined(__CYGWIN32__)
+    #include <asm/byteorder.h>
+    #include <unistd.h>
+
+    #define __be64_to_cpu(x) ___my_swab64(x)
+    #define __be32_to_cpu(x) ___my_swab32(x)
+    #define __be16_to_cpu(x) ___my_swab16(x)
+    #define __cpu_to_be64(x) ___my_swab64(x)
+    #define __cpu_to_be32(x) ___my_swab32(x)
+    #define __cpu_to_be16(x) ___my_swab16(x)
+    #define __le64_to_cpu(x) (x)
+    #define __le32_to_cpu(x) (x)
+    #define __le16_to_cpu(x) (x)
+    #define __cpu_to_le64(x) (x)
+    #define __cpu_to_le32(x) (x)
+    #define __cpu_to_le16(x) (x)
+
+#endif
+
+/*
+ * Windows (DDK)
+ */
+#if defined(__WIN__)
+    #include <Winsock2.h>
+    #include <winsock2.h>
+    #include <windows.h>
+    #include <io.h>
+
+    #define __LITTLE_ENDIAN 1234
+    #define __BIG_ENDIAN 4321
+    #define __BYTE_ORDER __LITTLE_ENDIAN
+
+    #define __be64_to_cpu(x) ___my_swab64(x)
+    #define __be32_to_cpu(x) ___my_swab32(x)
+    #define __be16_to_cpu(x) ___my_swab16(x)
+    #define __cpu_to_be64(x) ___my_swab64(x)
+    #define __cpu_to_be32(x) ___my_swab32(x)
+    #define __cpu_to_be16(x) ___my_swab16(x)
+    #define __le64_to_cpu(x) (x)
+    #define __le32_to_cpu(x) (x)
+    #define __le16_to_cpu(x) (x)
+    #define __cpu_to_le64(x) (x)
+    #define __cpu_to_le32(x) (x)
+    #define __cpu_to_le16(x) (x)
+
+
+    #if defined(__MINGW32__) || defined(__MINGW64__)
+        #include <stdint.h>
+        #ifndef   MFT_TOOLS_VARS
+            #define MFT_TOOLS_VARS
+            typedef uint8_t  u_int8_t;
+            typedef uint16_t u_int16_t;
+            typedef uint32_t u_int32_t;
+            typedef uint64_t u_int64_t;
+        #endif
+        #include <string.h>      // Get a define for strcasecmp
+        // #define usleep(x) Sleep((x + 999)/1000)
+
+    #else
+        typedef unsigned __int8  u_int8_t;
+        typedef __int8           int8_t;
+        typedef unsigned __int16 u_int16_t;
+        typedef __int16          int16_t;
+        typedef unsigned __int32 u_int32_t;
+        typedef __int32          int32_t;
+        typedef unsigned __int64 u_int64_t;
+        typedef __int64          int64_t;
+
+        #define strcasecmp    _stricmp
+        #define strtoll       _strtoi64
+        #define strtoull      _strtoui64
+        #define strdup        _strdup
+
+    #endif
+
+    #ifndef __WIN__ // TBD : investigate crash on win
+inline
+    #endif
+
+    #define COMP_CDECL    __cdecl
+    #define COMP_OPEN     ::_open
+    #define COMP_CLOSE    ::_close
+    #define COMP_READ     ::_read
+    #define COMP_FSTAT    ::_fstat
+
+    #ifndef __cplusplus
+        #define close _close
+    #endif
+
+typedef struct _stat  Stat;
+
+    #define PRIx64 "I64x"
+    #define PRIu64 "I64u"
+/*
+    #ifdef __cplusplus
+static inline int pread(int fd, void *buf, int count, u_int64_t offset) {return -1;}
+static inline int pwrite(int fd, const void *buf, int count, u_int64_t offset) {return -1;}
+    #else
+static inline int pread(int fd, void *buf, int count, u_int64_t offset) {return -1;}
+static inline int pwrite(int fd, const void *buf, int count, u_int64_t offset) {return -1;}
+    #endif
+*/
+#else
+
+    #define COMP_CDECL
+    #define COMP_OPEN     ::open
+    #define COMP_CLOSE    ::close
+    #define COMP_READ     ::read
+    #define COMP_FSTAT    ::fstat
+
+typedef struct stat  Stat;
+
+    #include <sys/time.h>
+    #include <strings.h>
+
+#endif
+
+
+
+/*
+ * MAC (Darwin)
+ */
+#if defined(__APPLE_CC__)
+    #include <architecture/byte_order.h>
+
+    #define __swab64(x)      NXSwapLongLong(x)
+    #define __swab32(x)      NXSwapLong(x)
+    #define __swab16(x)      NXSwapShort(x)
+    #define __be64_to_cpu(x) NXSwapBigLongLongToHost(x)
+    #define __be32_to_cpu(x) NXSwapBigLongToHost(x)
+    #define __be16_to_cpu(x) NXSwapBigShortToHost(x)
+    #define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x)
+    #define __le32_to_cpu(x) NXSwapLittleLongToHost(x)
+    #define __le16_to_cpu(x) NXSwapLittleShortToHost(x)
+    #define __cpu_to_be64(x) NXSwapHostLongLongToBig(x)
+    #define __cpu_to_be32(x) NXSwapHostLongToBig(x)
+    #define __cpu_to_be16(x) NXSwapHostShortToBig(x)
+    #define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x)
+    #define __cpu_to_le32(x) NXSwapHostLongToLittle(x)
+    #define __cpu_to_le16(x) NXSwapHostShortToLittle(x)
+
+    #define __LITTLE_ENDIAN 1234
+    #define __BIG_ENDIAN    4321
+    #define __PDP_ENDIAN    3412
+    #define __BYTE_ORDER    __BIG_ENDIAN
+#endif
+
+/*
+ * Solaris
+ * -------
+ */
+#if defined(__sparc__)
+    #include <sys/byteorder.h>
+    #include <sys/types.h>
+    #include <unistd.h>
+
+    #define __be64_to_cpu(x) (x)
+    #define __be32_to_cpu(x) (x)
+    #define __be16_to_cpu(x) (x)
+    #define __cpu_to_be64(x) (x)
+    #define __cpu_to_be32(x) (x)
+    #define __cpu_to_be16(x) (x)
+    #define __le64_to_cpu(x) ___my_swab64(x)
+    #define __le32_to_cpu(x) ___my_swab32(x)
+    #define __le16_to_cpu(x) ___my_swab16(x)
+    #define __cpu_to_le64(x) ___my_swab64(x)
+    #define __cpu_to_le32(x) ___my_swab32(x)
+    #define __cpu_to_le16(x) ___my_swab16(x)
+
+typedef uint64_t u_int64_t;
+typedef uint32_t u_int32_t;
+typedef uint16_t u_int16_t;
+typedef uint8_t  u_int8_t;
+
+#endif
+
+// Convert BYTES - DWORDS with MEMCPY BE
+#define BYTES_TO_DWORD_BE(dw_dest, byte_src) do {   u_int32_t tmp;\
+                                                    memcpy(&tmp, byte_src, 4);\
+                                                    *(dw_dest) = __be32_to_cpu(tmp);\
+                                                } while (0)
+
+#define DWORD_TO_BYTES_BE(bytes_dest, dw_src) do { u_int32_t tmp;\
+                                                   tmp = __cpu_to_be32(*(dw_src));\
+                                                   memcpy(bytes_dest, &tmp, 4);\
+                                                 } while (0)
+
+/*
+ * Old GCC
+ * -------
+ */
+#if !defined(__WIN__) && defined(__cplusplus) && __GNUG__ < 3
+    #include <algo.h>
+#endif
+
+#define __STDC_FORMAT_MACROS
+#if !defined(__WIN__) && !defined(UEFI_BUILD)
+    #include <inttypes.h>
+#endif
+
+#ifdef __VMKERNEL_USER_WORLD__
+    #define ROOT_PATH "/opt/mellanox/"
+#else
+    #define ROOT_PATH "/"
+#endif
+
+#endif
+
diff --git a/common/tools_utils.h b/common/tools_utils.h
new file mode 100755 (executable)
index 0000000..7e34ff8
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TOOLS_UTILS_H
+#define TOOLS_UTILS_H
+
+#include "compatibility.h"
+
+#define CPU_TO_BE32(x)                __cpu_to_be32(x)
+#define CPU_TO_LE32(x)                __cpu_to_le32(x)
+#define BE32_TO_CPU(x)                __be32_to_cpu(x)
+#define LE32_TO_CPU(x)                __le32_to_cpu(x)
+#define CPU_TO_BE16(x)                __cpu_to_be16(x)
+#define CPU_TO_LE16(x)                __cpu_to_le16(x)
+#define BE16_TO_CPU(x)                __be16_to_cpu(x)
+#define LE16_TO_CPU(x)                __le16_to_cpu(x)
+#define CPU_TO_BE64(x)                __cpu_to_be64(x)
+#define CPU_TO_LE64(x)                __cpu_to_le64(x)
+#define BE64_TO_CPU(x)                __be64_to_cpu(x)
+#define LE64_TO_CPU(x)                __le64_to_cpu(x)
+
+#define FIELD_8_OF_BUFF(buf, offset) (*(u_int8_t*)((u_int8_t*)(buf) + (offset)))
+#define FIELD_16_OF_BUFF(buf, offset) (*(u_int16_t*)((u_int8_t*)(buf) + (offset)))
+#define FIELD_32_OF_BUFF(buf, offset) (*(u_int32_t*)((u_int8_t*)(buf) + (offset)))
+#define FIELD_64_OF_BUFF(buf, offset) (*(u_int64_t*)((u_int8_t*)(buf) + (offset)))
+#define BYTE_N(buf, n)  FIELD_8_OF_BUFF((buf), (n))
+#define WORD_N(buf, n)  FIELD_16_OF_BUFF((buf), (n) * 2)
+#define DWORD_N(buf, n) FIELD_32_OF_BUFF((buf), (n) * 4)
+#define QWORD_N(buf, n) FIELD_64_OF_BUFF((buf), (n) * 8)
+#define QWORD_EXTRACT_DWORD_HI(qword) ((u_int64_t)(qword) >> 32)
+#define QWORD_EXTRACT_DWORD_LO(qword) ((u_int64_t)(qword) & (u_int64_t)0xffffffff)
+#define QWORD_INSERT_DWORD_HI(qword, dword) qword = ((qword & (u_int64_t)0xffffffff) | ((u_int64_t)dword << 32))
+#define QWORD_INSERT_DWORD_LO(qword, dword) qword = ((qword & (u_int64_t)0xffffffff00000000) | ((u_int64_t)dword))
+#define U32_TO_U64(dword1, dword2) ((((u_int64_t)(dword1)) << 32) | (((u_int64_t)(dword2)) & 0xffffffff))
+
+
+#define TOOLS_MAX(a,b) ((a) > (b) ? (a) : (b))
+#define TOOLS_MIN(a,b) ((a) < (b) ? (a) : (b))
+
+/**
+ * Suppress compiler warning about unused variable.
+ */
+#define TOOLS_UNUSED(var) ((void)var)
+
+
+#endif // TOOLS_UTILS_H
+
index 8b9f4b08e05ed35a0380bde25a3569bc1fd01d66..e3a242f9bc9071588266c84d5fbee7621a992abd 100644 (file)
@@ -1,6 +1,5 @@
 /*
- *
- * Copyright (c) 2011 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
  */
+
 //
 // Generic version for all tools
 //
+#ifndef TOOLS_VERSION_H
+#define TOOLS_VERSION_H
 
-#ifndef __TOOLS_VERSION_H__
-#define __TOOLS_VERSION_H__
 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 
+// To be replaced by an external script:
 #include "gitversion.h"
+#ifndef TOOLS_GIT_SHA
+    #define TOOLS_GIT_SHA "6469M"
+#endif
 
-#ifndef TOOLS_SVN_VER
-    #define TOOLS_SVN_VER "N/A"
+#ifdef HAVE_CONFIG_H
+    #include <config.h>
+    #ifndef MFT_VERSION_STR
+        #define MFT_VERSION_STR PACKAGE_STRING
+    #endif
 #endif
 
 #ifndef MFT_VERSION_STR
-    #define MFT_VERSION_STR "mft 3.5.0"
+    #define MFT_VERSION_STR "mft V.V.V-R"
 #endif
 
 static inline
@@ -57,20 +63,18 @@ int get_version_string(char* buf, int buf_size, const char* exe_name, const char
     int len = 0;
     // "svn ci" updates the below line
 
-    (void)buf_size; /* TODO: Not checked for now */
-
 
     if (tool_version == NULL || !strcmp(tool_version, "")) {
-        len = sprintf(buf, "%s, ", exe_name);
+        len = snprintf(buf, buf_size, "%s, ", exe_name);
     } else {
-        len = sprintf(buf, "%s %s, ", exe_name, tool_version);
+        len = snprintf(buf, buf_size, "%s %s, ", exe_name, tool_version);
     }
     // cut out first and last "$" from the SVN version string:
-    len += sprintf(buf + len, "%s, built on %s, %s. GIT Version: %s",
+    len += snprintf(buf + len, buf_size - len, "%s, built on %s, %s. Git SHA Hash: %s",
                   MFT_VERSION_STR,
                   __DATE__,
                   __TIME__,
-                  TOOLS_SVN_VER);
+                  TOOLS_GIT_SHA);
     return len;
 }
 
@@ -81,5 +85,4 @@ void print_version_string(const char* exe_name, const char* tool_version) {
     printf("%s\n", buf);
 }
 
-#endif
-
+#endif // TOOLS_VERSION_H
index cf6440c77b0998fb7e77d186bdc299424b20f2d1..b1ca89c39ffa3fa5e208a5ad75abc0f28359ccb2 100644 (file)
@@ -1,16 +1,16 @@
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT(mstflint, 3.5.0, orenk@mellanox.co.il)
+AC_INIT(mstflint, 3.6.0, orenk@mellanox.co.il)
 
 AC_DEFINE_UNQUOTED([PROJECT], ["mstflint"], [Define the project name.])
 AC_SUBST([PROJECT])
 
-AC_DEFINE_UNQUOTED([VERSION], ["3.5.0"], [Define the project version.])
+AC_DEFINE_UNQUOTED([VERSION], ["3.6.0"], [Define the project version.])
 AC_SUBST([VERSION])
 
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_SRCDIR([README])
-AM_INIT_AUTOMAKE(mstflint, 3.5.0)
+AM_INIT_AUTOMAKE(mstflint, 3.6.0)
 
 dnl Checks for programs
 AC_PROG_CC
@@ -30,6 +30,7 @@ if test "$enable_dc" = "yes"; then
 fi
 
 AM_CONDITIONAL(ENABLE_DC, [test  "x$enable_dc" = "xyes"])
+AC_SUBST(ENABLE_DC)
 
 AC_MSG_CHECKING(--enable-inband argument)
 AC_ARG_ENABLE(inband,
@@ -43,7 +44,12 @@ fi
 
 AM_CONDITIONAL(ENABLE_INBAND, [test  "x$enable_inband" = "xyes"])
 
+CFLAGS="$CFLAGS -Werror -DMST_UL"
+CXXFLAGS="$CXXFLAGS -Werror -DMST_UL"
+
 AC_CONFIG_FILES( mstflint.spec )
 
-AC_OUTPUT( Makefile mtcr_ul/Makefile dev_mgt/Makefile mflash/Makefile tools_layouts/Makefile mlxfwops/Makefile mlxfwops/lib/Makefile cmdparser/Makefile flint/Makefile \
+AC_OUTPUT( Makefile mft_utils/Makefile mtcr_ul/Makefile dev_mgt/Makefile tools_layouts/Makefile reg_access/Makefile mlxconfig/Makefile \
+               mflash/Makefile mlxfwops/Makefile mlxfwops/lib/Makefile cmdparser/Makefile flint/Makefile \
                small_utils/Makefile mstdump/Makefile mstdump/crd_lib/Makefile mstdump/crd_main/Makefile  mstdump/mstdump_dbs/Makefile )
+
index beaabd1dd67c4d84a5de479a57393d622a40c012..2d3aa6dff629c3459ab6889b0580e38187988e0a 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * SOFTWARE.
  */
 
+
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <errno.h>
 #include "tools_dev_types.h"
 
 enum dm_dev_type {
@@ -46,7 +49,6 @@ struct dev_info {
     int              hw_rev_id;  /* -1 means all revisions match this record */
     int              sw_dev_id;  /* -1 means all hw ids  match this record */
     const char*      name;
-    const char*      ext_name;
     int              port_num;
     enum dm_dev_type dev_type;
 };
@@ -57,142 +59,146 @@ struct dev_info {
 
 static struct dev_info g_devs_info[] = {
     {
-        .dm_id     = DeviceAnafa,
+        .dm_id     = DeviceInfiniScale,
         .hw_dev_id = 43132,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Anafa",
-        .ext_name  = "InfiniScale",
+        .name      = "InfiniScale",
         .port_num  = 8,
         .dev_type  = DM_SWITCH
     },
     {
-        .dm_id     = DeviceTavor,
+        .dm_id     = DeviceInfiniHost,
         .hw_dev_id = 0x5a44,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Tavor",
-        .ext_name  = "InfiniHost",
+        .name      = "InfiniHost",
         .port_num  = 2,
         .dev_type  = DM_HCA
     },
     {
-        .dm_id     = DeviceArbel,
+        .dm_id     = DeviceInfiniHostIIIEx,
         .hw_dev_id = 0x6278,
         .hw_rev_id = -1,
         .sw_dev_id = 0x6278,
-        .name      = "Arbel",
-        .ext_name  = "InfiniHostIIIEx",
+        .name      = "InfiniHostIIIEx",
         .port_num  = 2,
         .dev_type  = DM_HCA
     },
     {
-        .dm_id     = DeviceArbelMF,
+        .dm_id     = DeviceInfiniHostIIIEx_MF,
         .hw_dev_id = 0x6278,
         .hw_rev_id = -1,
         .sw_dev_id = 0x6282,
-        .name      = "ArbelMF",
-        .ext_name  = "InfiniHostIIIEx_MF",
+        .name      = "InfiniHostIIIEx_MF",
         .port_num  = 2,
         .dev_type  = DM_HCA
     },
     {
-        .dm_id     = DeviceAnafa2,
+        .dm_id     = DeviceInfiniScaleIII,
         .hw_dev_id = 0xb924,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Anafa2",
-        .ext_name  = "InfiniScaleIII",
+        .name      = "InfiniScaleIII",
         .port_num  = 24,
         .dev_type  = DM_SWITCH
     },
     {
-        .dm_id     = DeviceSinai,
+        .dm_id     = DeviceInfiniHostIIILx,
         .hw_dev_id = 0x6274,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Sinai",
-        .ext_name  = "InfiniHostIIILx",
+        .name      = "InfiniHostIIILx",
         .port_num  = 1,
         .dev_type  = DM_HCA
     },
     {
-        .dm_id     = DeviceHermon,
+        .dm_id     = DeviceConnectX,
         .hw_dev_id = 0x190,
         .hw_rev_id = 0xa0,
         .sw_dev_id = -1,
-        .name      = "Hermon",
-        .ext_name  = "ConnectX",
+        .name      = "ConnectX",
         .port_num  = 2,
         .dev_type  = DM_HCA
     },
     {
-        .dm_id     = DeviceHermonB0,
+        .dm_id     = DeviceConnectX2,
         .hw_dev_id = 0x190,
         .hw_rev_id = 0xb0,
         .sw_dev_id = -1,
-        .name      = "HermonB0",
-        .ext_name  = "ConnectX2",
+        .name      = "ConnectX2",
         .port_num  = 2,
         .dev_type  = DM_HCA
     },
     {
-        .dm_id     = DeviceShaldag,
+        .dm_id     = DeviceInfiniScaleIV,
         .hw_dev_id = 0x01b3,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Shaldag",
-        .ext_name  = "InfiniScaleIV",
+        .name      = "InfiniScaleIV",
         .port_num  = 36,
         .dev_type  = DM_SWITCH
     },
     {
-        .dm_id     = DeviceDolev,
+        .dm_id     = DeviceBridgeX,
         .hw_dev_id = 0x17d4,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Dolev",
-        .ext_name  = "BridgeX",
+        .name      = "BridgeX",
         .port_num  = 0, /* TODO */
         .dev_type  = DM_BRIDGE
     },
     {
-        .dm_id     = DeviceBaz,
+        .dm_id     = DeviceSwitchX,
         .hw_dev_id = 0x0245,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Baz",
-        .ext_name  = "SwitchX",
+        .name      = "SwitchX",
         .port_num  = 64,
         .dev_type  = DM_SWITCH
     },
     {
-        .dm_id     = DeviceKfir,
+        .dm_id     = DeviceConnectX3,
         .hw_dev_id = 0x1f5,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Kfir",
-        .ext_name  = "ConnectX3",
+        .name      = "ConnectX3",
         .port_num  = 2,
         .dev_type  = DM_HCA
     },
     {
-        .dm_id     = DeviceGolan,
+        .dm_id     = DeviceConnectIB,
         .hw_dev_id = 0x1ff,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Golan",
-        .ext_name  = "ConnectIB",
+        .name      = "ConnectIB",
         .port_num  = 2,
         .dev_type  = DM_HCA
     },
     {
-        .dm_id     = DeviceBental,
+        .dm_id     = DeviceConnectX3Pro,
         .hw_dev_id = 0x1f7,
         .hw_rev_id = -1,
         .sw_dev_id = -1,
-        .name      = "Bental",
-        .ext_name  = "ConnectX3Pro",
+        .name      = "ConnectX3Pro",
+        .port_num  = 2,
+        .dev_type  = DM_HCA
+    },
+    {
+        .dm_id     = DeviceSwitchIB,
+        .hw_dev_id = 0x247,
+        .hw_rev_id = -1,
+        .sw_dev_id = -1,
+        .name      = "SwitchIB",
+        .port_num  = 2,
+        .dev_type  = DM_SWITCH
+    },
+    {
+        .dm_id     = DeviceConnectX4,
+        .hw_dev_id = 0x209,
+        .hw_rev_id = -1,
+        .sw_dev_id = -1,
+        .name      = "ConnectX4",
         .port_num  = 2,
         .dev_type  = DM_HCA
     },
@@ -223,7 +229,10 @@ int dm_get_device_id(mfile* mf,
     #endif
 
     if (mread4(mf, DEVID_ADDR, &dword) != 4)
+    {
+        //printf("FATAL - crspace read (0x%x) failed: %s\n", DEVID_ADDR, strerror(errno));
         return 1;
+    }
 
     *ptr_hw_dev_id = EXTRACT(dword, 0, 16);
     *ptr_hw_rev    = EXTRACT(dword, 16, 8);
@@ -242,33 +251,37 @@ int dm_get_device_id(mfile* mf,
         /* Special cases - Sinai HW id and Anafa2 devid address. */
         if (*ptr_hw_dev_id == 24204) {
             /* Some old Sinais have hw dev is of 24204 */
-            *ptr_dm_dev_id = DeviceSinai;
+            *ptr_dm_dev_id = DeviceInfiniHostIIILx;
         } else {
             /* Try Anafa2 devid address */
             if (mread4(mf, DEVID_ADDR_ANAFA2, &dword) != 4)
                 return 1;
-            if ((int)EXTRACT(dword, 0, 16) == g_devs_info[DeviceAnafa2].hw_dev_id) {
-                *ptr_dm_dev_id = DeviceAnafa2;
+            if ((int)EXTRACT(dword, 0, 16) == g_devs_info[DeviceInfiniScaleIII].hw_dev_id) {
+                *ptr_dm_dev_id = DeviceInfiniScaleIII;
                 *ptr_hw_dev_id = EXTRACT(dword, 0, 16);
                 *ptr_hw_rev    = EXTRACT(dword, 16, 8);
             } else {
                 /* Dev id not matched in array */
+                //printf("FATAL - Can't find devid id\n");
                 return 1; // TODO - fix return vals.
             }
         }
     }
 
     /* Special cases: For Arbel we need to check the SW id as well */
-    if (*ptr_hw_dev_id == g_devs_info[DeviceArbel].hw_dev_id) {
+    if (*ptr_hw_dev_id == g_devs_info[DeviceInfiniHostIIIEx].hw_dev_id) {
         if (mread4(mf, DM_ARBEL_DEV_VER_ADDR, &dword) != 4)
+        {
+            //printf("FATAL - Can't read arbel dev_ver addr\n");
             return 1;
+        }
 
         if (EXTRACT(dword, 16, 16) == 0x25218 ||
             EXTRACT(dword, 16, 16) == 0x25228 ||
             EXTRACT(dword, 16, 16) == 0x25238) {
-            *ptr_dm_dev_id = DeviceArbelMF;
+            *ptr_dm_dev_id = DeviceInfiniHostIIIEx_MF;
         } else {
-            *ptr_dm_dev_id = DeviceArbel;
+            *ptr_dm_dev_id = DeviceInfiniHostIIIEx;
         }
     }
 
@@ -303,15 +316,6 @@ const char* dm_dev_type2str(dm_dev_id_t type)
     }
 }
 
-const char* dm_dev_type2str_ext(dm_dev_id_t type)
-{
-    if (type < DeviceEndMarker) {
-        return g_devs_info[type].ext_name;
-    } else {
-        return "Unknown Device";
-    }
-}
-
 int dm_get_hw_ports_num(dm_dev_id_t type)
 {
     if (type < DeviceEndMarker) {
index ad219f46c487189ed51bc4bdf4694204a239fdbe..21c587fb18a6a04edd9c3a86f1bb53ddd6f2ef38 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -30,6 +30,7 @@
  * SOFTWARE.
  */
 
+
 #ifndef TOOLS_DEV_TYPE_H
 #define TOOLS_DEV_TYPE_H
 
@@ -46,20 +47,22 @@ enum dm_dev_id
     DeviceStartMarker = 0,    // Dummy Device - Marker for first device
                               // to let user iterate from DeviceStartMarker to DeviceEndMarker
 
-    DeviceAnafa = 0,
-    DeviceTavor,
-    DeviceArbel,
-    DeviceArbelMF,
-    DeviceAnafa2,
-    DeviceSinai,
-    DeviceHermon,
-    DeviceHermonB0,
-    DeviceShaldag,
-    DeviceDolev,
-    DeviceBaz,
-    DeviceKfir,
-    DeviceGolan,
-    DeviceBental,
+    DeviceInfiniScale = 0,
+    DeviceInfiniHost,
+    DeviceInfiniHostIIIEx,
+    DeviceInfiniHostIIIEx_MF,
+    DeviceInfiniScaleIII,
+    DeviceInfiniHostIIILx,
+    DeviceConnectX,
+    DeviceConnectX2,
+    DeviceInfiniScaleIV,
+    DeviceBridgeX,
+    DeviceSwitchX,
+    DeviceConnectX3,
+    DeviceConnectIB,
+    DeviceConnectX3Pro,
+    DeviceSwitchIB,
+    DeviceConnectX4,
 
     DeviceEndMarker           // Dummy Device - Marker for indicating error and end of devices
 };
@@ -82,7 +85,7 @@ int dm_get_device_id_offline(u_int32_t devid,
                              dm_dev_id_t* ptr_dev_type);
 
 /**
- * Returns the device name as a "const char*" (internal name)
+ * Returns the device name as a "const char*"
  */
 const char* dm_dev_type2str(dm_dev_id_t type);
 
@@ -101,12 +104,6 @@ int dm_dev_is_switch(dm_dev_id_t type);
  */
 int dm_dev_is_bridge(dm_dev_id_t type);
 
-
-/**
- * Returns the device name as a "const char*" (external name)
- */
-const char* dm_dev_type2str_ext(dm_dev_id_t type);
-
 /**
  * Returns the max num of ports or -1 on error
  */
index 250e3aecdcee1db0fc11595f1401d7ef35dd402e..e4f42ac43badb2342f929654137304f029108afb 100755 (executable)
@@ -35,9 +35,10 @@ MTCR_DIR    = $(top_srcdir)/mtcr_ul
 MFLASH_DIR  = $(top_srcdir)/mflash
 COMMON_DIR  = $(top_srcdir)/common
 LAYOUTS_DIR = $(top_srcdir)/tools_layouts
+MFT_UTILS_DIR = $(top_srcdir)/mft_utils
 
 INCLUDES = -I$(top_srcdir) -I$(srcdir) -I$(MTCR_DIR) -I$(MFLASH_DIR) -I$(COMMON_DIR) \
-           -I$(LAYOUTS_DIR)
+           -I$(LAYOUTS_DIR) -I$(MFT_UTILS_DIR)
 
 mstflint_CXXFLAGS = -Wall -W -g -MP -MD -pipe -DEXTERNAL
 bin_PROGRAMS = mstflint
@@ -48,9 +49,11 @@ mstflint_SOURCES = flint.cpp flint.h subcommands.cpp subcommands.h\
 mstflint_LDADD =  ../mlxfwops/lib/libmlxfwops.a  \
                   ../cmdparser/libcmdparser.a    \
                  ../mflash/libmflash.a          \
+                 ../reg_access/libreg_access.a  \
                  ../mtcr_ul/libmtcr_ul.a        \
                   ../tools_layouts/libtools_layouts.a \
-                 $(LAYOUTS_LIB) $(LIBSTD_CPP) -ldl
+                 ../mft_utils/libmftutils.a\
+                 $(LIBSTD_CPP) -ldl
 
 
 if ENABLE_DC
@@ -59,3 +62,7 @@ else
 mstflint_CXXFLAGS += -DNO_ZLIB
 endif
 
+#get mst device examples and tool name from makefile
+mstflint_CXXFLAGS+= -DFLINT_NAME=\"mstflint\" -DFLINT_DISPLAY_NAME=\"MstFlint\"
+mstflint_CXXFLAGS += -DMST_DEV_EXAMPLE1=\"/dev/mst/mt4099_pci_cr0\" -DMST_DEV_EXAMPLE2=\"/dev/mst/mt4099_pciconf0\" -DMST_DEV_EXAMPLE3=\"/dev/mst/mt4113_pciconf0\"
+
index 0ca632e737a2f4ce040375dc2887a7ffabb46f14..fd19166ccf43f2c5c7948f439d9de650a055dd5d 100644 (file)
@@ -1,8 +1,7 @@
 /*
- *
  * cmd_line_parser.cpp - FLash INTerface
  *
- * Copyright (c) 2013 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -41,7 +40,7 @@
 // Flint includes
 #include "flint.h"
 #include <common/tools_version.h>
-#include <stdio.h>
+#include "mlxfwops/lib/flint_io.h"
 
 #ifndef FLINT_NAME
     #ifdef __GNUC__
@@ -80,6 +79,7 @@ SubCmdMetaData::SubCmdMetaData() {
     _sCmds.push_back(new SubCmd("q", "query", SC_Query));
     _sCmds.push_back(new SubCmd("v", "verify", SC_Verify));
     _sCmds.push_back(new SubCmd("", "swreset", SC_Swreset));
+    _sCmds.push_back(new SubCmd("r", "reset_cfg", SC_ResetCfg));
     _sCmds.push_back(new SubCmd("", "brom", SC_Brom));
     _sCmds.push_back(new SubCmd("", "drom", SC_Drom));
     _sCmds.push_back(new SubCmd("", "rrom", SC_Rrom));
@@ -105,6 +105,7 @@ SubCmdMetaData::SubCmdMetaData() {
     _sCmds.push_back(new SubCmd("", "wb", SC_Wb));
     _sCmds.push_back(new SubCmd("", "rb", SC_Rb));
     _sCmds.push_back(new SubCmd("", "clear_semaphore", SC_Clear_Sem));
+    _sCmds.push_back(new SubCmd("", "fi", SC_Fix_Img));
 }
 
 SubCmdMetaData::~SubCmdMetaData() {
@@ -408,7 +409,7 @@ bool parseFlashParams(string params, flash_params_t& fp)
  *Parsing part of the Flint class
  ************************************/
 
-
+#define FLASH_LIST_SZ 256
 
 void Flint::initCmdParser() {
     AddDescription("flint is a FW (firmware) burning and flash memory operations tool for\n"
@@ -420,6 +421,36 @@ void Flint::initCmdParser() {
                 "Device flash is connected to.\n"
                 "Commands affected: all");
 
+    AddOptions("image",
+               'i',
+                "<image>",
+                "Binary image file.\n"
+                "Commands affected: burn, verify");
+
+    AddOptions("help",
+               'h',
+                "",
+                "Prints this message and exits");
+
+    AddOptions("hh",
+               ' ',
+                "",
+                "Prints extended command help");
+
+    AddOptions("yes",
+               'y',
+                "",
+                "Non interactive mode - assume answer\n"
+                "\"yes\" to all questions.\n"
+                "Commands affected: all");
+
+    AddOptions("no",
+               ' ',
+                "",
+                "Non interactive mode - assume answer\n"
+                "\"no\" to all questions.\n"
+                "Commands affected: all");
+
     AddOptions("guid",
                ' ',
                 "<GUID>",
@@ -468,7 +499,7 @@ void Flint::initCmdParser() {
     AddOptions("uid",
                ' ',
                 "<UID>",
-                "BridgeX only. Derive and set the device UIDs (GUIDs, MACs, WWNs).\n"
+                "BridgeX/ConnectIB only. Derive and set the device UIDs (GUIDs, MACs, WWNs).\n"
                 "UIDs are derived from the given base UID according to Mellanox Methodology\n"
                 "Commands affected: burn, sg");
 
@@ -506,22 +537,6 @@ void Flint::initCmdParser() {
                 "\tapplication is currently using the flash.\n"
                 "\tExercise caution.\n");
 
-    AddOptions("help",
-               'h',
-                "",
-                "Prints this message and exits");
-
-    AddOptions("hh",
-               ' ',
-                "",
-                "Prints extended command help");
-
-    AddOptions("image",
-               'i',
-                "<image>",
-                "Binary image file.\n"
-                "Commands affected: burn, verify");
-
     AddOptions("qq",
                ' ',
                 "",
@@ -567,20 +582,6 @@ void Flint::initCmdParser() {
                 "Do not print burn progress flyer.\n"
                 "Commands affected: burn");
 
-    AddOptions("yes",
-               'y',
-                "",
-                "Non interactive mode - assume answer\n"
-                "\"yes\" to all questions.\n"
-                "Commands affected: all");
-
-    AddOptions("no",
-               ' ',
-                "",
-                "Non interactive mode - assume answer\n"
-                "\"no\" to all questions.\n"
-                "Commands affected: all");
-
     AddOptions("vsd",
                ' ',
                 "<string>",
@@ -627,14 +628,19 @@ void Flint::initCmdParser() {
                 "<log_file>",
                 "Print the burning status to the specified log file");
 
+    char flashList[FLASH_LIST_SZ];
+    char flashParDesc[FLASH_LIST_SZ*2];
+    Flash::get_flash_list(flashList);
+    snprintf(flashParDesc, FLASH_LIST_SZ*2,"Use the given parameters to access the flash instead of reading them from the flash.\n"\
+                                                                  "Supported parameters:\n"\
+                                                                  "Type: The type of the flash, such as:%s.\n"\
+                                                                  "log2size: The log2 of the flash size."\
+                                                                  "num_of_flashes: the number of the flashes connected to the device.", flashList);
+
+
     AddOptions("flash_params",
                ' ',
-                "<type, log2size, num_of_flashes>",
-                "Use the given parameters to access the flash instead of reading them from the flash.\n"
-                "Supported parameters:\n"
-                "Type: The type of the flash, such as: M25PXxx, M25Pxx, N25Q0XX, SST25VFxx, W25QxxBV, W25Xxx, AT25DFxxx, S25FLXXXP.\n"
-                "log2size: The log2 of the flash size."
-                "num_of_flashes: the number of the flashes connected to the device.");
+                "<type, log2size, num_of_flashes>", flashParDesc);
 
     AddOptions("version",
                'v',
@@ -673,6 +679,10 @@ ParseStatus Flint::HandleOption(string name, string value)
         cout<<"COMMANDS SUMMARY:"<<endl;
         for (map_sub_cmd_t_to_subcommand::iterator it=_subcommands.begin(); it != _subcommands.end(); it++)
         {
+                       if (it->first == SC_ResetCfg) {
+                               // hidden command so "forget" mentioning it
+                               continue;
+                       }
             string str1 = "  "+it->second->getFlagL()+((it->second->getFlagS() == "") ? ("  ") : ("|"))+it->second->getFlagS()\
                     +" "+it->second->getParam();
             string str2 = ": " + it->second->getDesc()+"\n";
@@ -705,6 +715,10 @@ ParseStatus Flint::HandleOption(string name, string value)
         cout<<endl<<endl<<"COMMANDS DESCRIPTION:"<<endl;
         for (map_sub_cmd_t_to_subcommand::iterator it=_subcommands.begin(); it != _subcommands.end(); it++)
                 {
+                               if (it->first == SC_ResetCfg) {
+                                       // hidden command so "forget" mentioning it
+                                       continue;
+                               }
                     cout<<"  Name:"<<endl<<"\t"<<it->second->getName()<<endl\
                             <<"  Description:"<<endl<<"\t"<<it->second->getExtDesc()<<endl\
                             <<"  Command:"<<endl<<"\t"<<it->second->getFlagL()<<\
index 6d2cb6109a05f035ba705181bd877a94bfdc0987..04c6055710848ba3ad17958dad29cbdebb2b5bc7 100644 (file)
@@ -2,7 +2,7 @@
  *
  * err_msgs.h - FLash INTerface
  *
- * Copyright (c) 2013 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -37,8 +37,8 @@
  */
 
 
-#ifndef __ERR_MSGS__
-#define __ERR_MSGS__
+#ifndef __ERR_MSGS_H__
+#define __ERR_MSGS_H__
 
 /**********************
  * Flint Status Code
@@ -77,7 +77,7 @@ typedef enum {
 #define FLINT_BX_BAD_MAC_FORMAT_ERROR         "Bad mac ( %4.4x%8.8x ) %s. Please re-burn with a valid MACs value.\n"
 #define FLINT_INVALID_FLAG_WITH_FLAG_ERROR    "Cannot specify \"%s\" flag with \"%s\" flag.\n"
 #define FLINT_INVALID_FLAG_WITH_CMD_ERROR     "Cannot specify flag: %s with Command: %s\n"
-#define FLINT_CMD_VERIFY_ERROR                "FW image verification failed: %s. AN HCA DEVICE CAN NOT BOOT FROM THIS IMAG.\n"
+#define FLINT_CMD_VERIFY_ERROR                "FW image verification failed: %s. AN HCA DEVICE CAN NOT BOOT FROM THIS IMAGE.\n"
 #define FLINT_FAILED_QUERY_ERROR              "Failed to query %s: %s.%s\n"
 #define FLINT_COMMAND_DEVICE_IMAGE_ERROR      "Command \"%s\" requires both image and device to be specified.\n"
 #define FLINT_COMMAND_DEVICE_ERROR            "Command \"%s\" requires device, but an image file was given.\n"
@@ -114,12 +114,15 @@ typedef enum {
 #define FLINT_VSD_ERROR                       "Failed to set the VSD: %s\n"
 #define FLINT_VPD_ERROR                       "Failed to set VPD: %s\n"
 #define FLINT_SET_KEY_ERROR                   "Failed to set the HW access key: %s\n"
+#define FLINT_RESET_CFG_ERROR                 "Failed to reset Configuration: %s\n"
+#define FLINT_FIX_IMG_ERROR                   "Failed to fix device image: %s\n"
 #define FLINT_DROM_ERROR                      "Remove ROM failed: %s\n"
 #define FLINT_BROM_ERROR                      "Burn ROM failed: %s\n"
 #define FLINT_DUMP_ERROR                      "Failed dumping %s : %s\n"
 #define FLINT_ROM_QUERY_ERROR                 "Image file rom (%s) query failed. %s\n"
 #define FLINT_WB_FILE_ERROR                   "failed to open file: %s. %s\n"
 #define FLINT_WB_ERROR                        "write Block Failed. %s\n"
+#define FLINT_NO_ZLIB_ERROR                                      "Executable was compiled with \"dump files\" option disabled.\n"
 
 /**************************
  * Flint Warning Messages
index 5705a0c662a375a79176d2c714dae3ba4b4ce98f..bc9d2b76a9e32b5cfb14e004668ef5fe81006649 100644 (file)
@@ -2,7 +2,7 @@
  *
  * flint.cpp - FLash INTerface
  *
- * Copyright (c) 2013 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  *
  */
 
+#include <iostream>
+#include <signal.h>
 
 #include "flint.h"
-#include <iostream>
 
 //Globals:
 Flint* gFlint = NULL;
@@ -47,36 +48,31 @@ extern FILE* flint_log_fh;
 
 #define BURN_INTERRUPTED 0x1234
 
-#ifdef _WIN32
-#include <windows.h>
-HANDLE mainThread;
-
-#define GET_MAIN_THREAD() {\
-     int rc = DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(),\
-                              &mainThread, 0, FALSE, DUPLICATE_SAME_ACCESS);\
-     if (rc == 0) {\
-         mainThread = NULL;\
-     }\
-}
-
-#define CHECK_WIN_SIGNAL() {\
-     if (mainThread == NULL) {\
-         printf(FLINT_INTERRUPT_WARRNING);\
-         signal(signum, TerminationHandler);\
-         return;\
-     }\
-}
+void TerminationHandler(int signum);
 
-#define SUSPEND_MAIN_THREAD() {\
-     SuspendThread(mainThread);\
-}
+#ifdef __WIN__
+#include <windows.h>
 
-#else
+static BOOL CtrlHandler( DWORD fdwCtrlType )
+{
+    switch( fdwCtrlType )
+    {
+      // Handle the CTRL-C signal.
+      case CTRL_C_EVENT:
+      // CTRL-CLOSE: confirm that the user wants to exit.
+      case CTRL_CLOSE_EVENT:
+      // Pass other signals to the next handler.
+      case CTRL_BREAK_EVENT:
+      case CTRL_LOGOFF_EVENT:
+      case CTRL_SHUTDOWN_EVENT:
+         TerminationHandler(SIGINT);
+          return TRUE;
+
+      default:
+        return FALSE;
+    }
+ }
 
-#define GET_MAIN_THREAD()
-#define WIN_TERM_THREAD()
-#define CHECK_WIN_SIGNAL()
-#define SUSPEND_MAIN_THREAD()
 #endif
 
 
@@ -84,7 +80,6 @@ void TerminationHandler(int signum)
 {
     static volatile sig_atomic_t fatal_error_in_progress = 0;
 
-    CHECK_WIN_SIGNAL();
     if (fatal_error_in_progress) {
         raise (signum);
     }
@@ -94,10 +89,9 @@ void TerminationHandler(int signum)
     write_result_to_log(BURN_INTERRUPTED, "");
     close_log();
     if (gFlint != NULL) {
-        printf("\n Received signal %d. Cleaning up ...", signum);
+        printf("\n Received signal %d. Cleaning up ...\n", signum);
         fflush(stdout);
-        SUSPEND_MAIN_THREAD();
-        sleep(1); // Legacy from the Old Flint
+        //sleep(1); // Legacy from the Old Flint
         delete gFlint;
         gFlint = NULL;
         printf(" Done.\n");
@@ -111,10 +105,12 @@ void initHandler()
 #ifdef __WIN__
 #define SIGNAL_NUM 3
     int signalList[SIGNAL_NUM] = {SIGINT, SIGTERM, SIGABRT};
+    SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, true );
 #else
 #define SIGNAL_NUM 4
     int signalList[SIGNAL_NUM] = {SIGINT, SIGTERM, SIGPIPE, SIGHUP};
 #endif
+
     //set the signal handler
     for (int i=0; i < SIGNAL_NUM ; i++) {
         void (*prevFunc)(int);
@@ -124,7 +120,6 @@ void initHandler()
             exit(FLINT_FAILED);
         }
     }
-    GET_MAIN_THREAD();
 }
 
 //End of signal handler section.
@@ -137,14 +132,18 @@ map_sub_cmd_t_to_subcommand Flint::initSubcommandMap()
     cmdMap[SC_Query] = new QuerySubCommand();
     cmdMap[SC_Verify] = new VerifySubCommand();
     cmdMap[SC_Swreset] = new SwResetSubCommand();
+    cmdMap[SC_ResetCfg] = new ResetCfgSubCommand();
     cmdMap[SC_Brom] = new BromSubCommand();
     cmdMap[SC_Drom] = new DromSubCommand();
     cmdMap[SC_Rrom] = new RromSubCommand();
     cmdMap[SC_Qrom] = new RomQuerySubCommand();
     cmdMap[SC_Bb] = new BbSubCommand();
     cmdMap[SC_Sg] = new SgSubCommand();
+#ifndef EXTERNAL
     cmdMap[SC_Smg] = new SmgSubCommand();
     cmdMap[SC_Set_Vpd] = new SetVpdSubCommand();
+    cmdMap[SC_Fix_Img] = new FiSubCommand();
+#endif
     cmdMap[SC_Sv] = new SvSubCommand();
     cmdMap[SC_Ri] = new RiSubCommand();
     cmdMap[SC_Dc] = new DcSubCommand();
index c817721f62583725746e68e7048f6948827380ae..8bb86b5ed76acb125b1098bc746c51dfc7217cc1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * flint2.h - FLash INTerface
+ * flint.h - FLash INTerface
  *
  * Copyright (c) 2013 Mellanox Technologies Ltd.  All rights reserved.
  *
@@ -39,8 +39,6 @@
 #ifndef __FLINT_H__
 #define __FLINT_H__
 
-#define FLINT_DISPLAY_NAME "mstflint"
-
 #include <string.h>
 #include "flint_params.h"
 #include "subcommands.h"
index abaf1521ed6cbbf61e036b2f06399c203870b564..9c6b460201f52f684ac07064f5250ce7293dc661 100644 (file)
@@ -2,7 +2,7 @@
  *
  * flint_params.cpp - FLash INTerface
  *
- * Copyright (c) 2013 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -75,6 +75,10 @@ FlintParams::FlintParams()
     flash_params.type_name = (char*)NULL;
     no_devid_check = false;
     cmd = SC_No_Cmd;
+    baseUid.h = 0;
+    baseUid.l = 0;
+    flash_params.num_of_flashes = 0;
+    flash_params.log2size = 0;
 }
 
 FlintParams::~FlintParams()
index 0cffc5062319134777a6f59d4ac27b8a0fb5198b..37dc8e5eca4b2add80087658da322ff69af70121 100644 (file)
@@ -2,7 +2,7 @@
  *
  * flint_params.h - FLash INTerface
  *
- * Copyright (c) 2013 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -52,6 +52,7 @@ typedef enum {
     SC_Query,
     SC_Verify,
     SC_Swreset,
+    SC_ResetCfg,
     SC_Brom,
     SC_Drom,
     SC_Rrom,
@@ -74,6 +75,7 @@ typedef enum {
     SC_Wb,
     SC_Rb,
     SC_Clear_Sem,
+    SC_Fix_Img,
     SC_Qrom
 } sub_cmd_t;
 
index 1f47e6e1a57cd371b4bde1dc8b34259aa01d5c80..167365f3addefc633e92e691e5a091c15b1abeba 100644 (file)
  *
  */
 
-#include "subcommands.h"
-#include <iostream>
+
 #include <stdio.h>
+#include <iostream>
+
+#include <common/compatibility.h>
 
 #ifndef NO_ZLIB
-#include <zlib.h>
+    #include <zlib.h>
 #endif
 
+#include "subcommands.h"
+
 using namespace std;
 
 #define INDENT "\t\t\t\t\t   "
@@ -125,9 +129,9 @@ int write_cmd_to_log(string fullCmd , sub_cmd_t cmd, bool write)
         return 0;
     }
     if (cmd == SC_Brom) {
-        sprintf(pre_str, "ROM");
+        snprintf(pre_str, 50, "ROM");
     } else {
-        sprintf(pre_str, "FW");
+        snprintf(pre_str, 50, "FW");
     }
     print_time_to_log();
     fprintf(flint_log_fh, "Start %s burning: ", pre_str);
@@ -234,13 +238,13 @@ void SubCommand::openLog()
     }
 }
 
-int SubCommand::verifyCbFunc(const char* str)
+int SubCommand::verifyCbFunc(char* str)
 {
     printf("%s", str);
     return 0;
 }
 
-int SubCommand::CbCommon(int completion, const char*preStr, const char* endStr)
+int SubCommand::CbCommon(int completion, char*preStr, char* endStr)
 {
     if (completion < 100) {
             printf("\r%s%%%03d", preStr, completion);
@@ -260,54 +264,62 @@ int SubCommand::CbCommon(int completion, const char*preStr, const char* endStr)
 
 int SubCommand::burnCbFs3Func(int completion)
 {
-    const char* message = "Burning FS3 FW image without signatures - ";
-    const char* endStr = "Restoring signature                     - OK";
+    char* message = (char*)"Burning FS3 FW image without signatures - ";
+    char* endStr =  (char*)"Restoring signature                     - OK";
     return CbCommon(completion, message, endStr);
 }
 
 int SubCommand::burnCbFs2Func(int completion)
 {
-    const char* message = "Burning FS2 FW image without signatures - ";
-    const char* endStr =  "Restoring signature                     - OK";
+    char* message = (char*)"Burning FS2 FW image without signatures - ";
+    char* endStr =  (char*)"Restoring signature                     - OK";
     return CbCommon(completion, message, endStr);
 }
 
 int SubCommand::bromCbFunc(int completion)
 {
-    const char* message = "Burning ROM image    - ";
-    const char* endStr =  "Restoring signature  - OK";
+    char* message = (char*)"Burning ROM image    - ";
+    char* endStr =  (char*)"Restoring signature  - OK";
     return CbCommon(completion, message, endStr);
 }
 
 int SubCommand::dromCbFunc(int completion)
 {
-    const char* message = "Removing ROM image    - ";
-    const char* endStr = "Restoring signature  - OK";
+    char* message = (char*)"Removing ROM image    - ";
+    char* endStr =  (char*)"Restoring signature  - OK";
     return CbCommon(completion, message, endStr);
 }
 
+int SubCommand::resetCfgCbFunc(int completion)
+{
+    char* message = (char*)"Resetting NV configuration - ";
+    char* endStr =  (char*)"Restoring signature        - OK";
+    return CbCommon(completion, message, endStr);
+}
+
+
 int SubCommand::burnBCbFunc(int completion)
 {
-    return CbCommon(completion, "");
+    return CbCommon(completion,(char*)"");
 }
 
 int SubCommand::vsdCbFunc(int completion)
 {
-    const char* message = "Setting the VSD      - ";
-    const char* endStr =  "Restoring signature  - OK";
+    char* message = (char*)"Setting the VSD      - ";
+    char* endStr =  (char*)"Restoring signature  - OK";
     return CbCommon(completion, message, endStr);
 }
 
 int SubCommand::setKeyCbFunc(int completion)
 {
-    const char* message = "Setting the HW Key   - ";
-    const char* endStr = "Restoring signature  - OK";
+    char* message = (char*)"Setting the HW Key   - ";
+    char* endStr =  (char*)"Restoring signature  - OK";
     return CbCommon(completion, message, endStr);
 }
 
 int SubCommand::wbCbFunc(int completion)
 {
-    const char* message = "Writing Block:   - ";
+    char* message = (char*)"Writing Block:   - ";
     return CbCommon(completion, message, NULL);
 }
 
@@ -319,6 +331,7 @@ FlintStatus SubCommand:: openOps()
     if (_flintParams.device_specified) {
         // fillup the fw_ops_params_t struct
         FwOperations::fw_ops_params_t fwParams;
+        memset(&fwParams, 0 , sizeof(FwOperations::fw_ops_params_t));
         fwParams.errBuff = errBuff;
         fwParams.errBuffSize = ERR_BUFF_SIZE;
         fwParams.flashParams =_flintParams.flash_params_specified ? &_flintParams.flash_params : NULL;
@@ -373,7 +386,7 @@ FlintStatus SubCommand:: openIo()
             return FLINT_FAILED;
         }
         // we have successfully opened a Flash Obj
-        // set no_flash_verify if needed
+        //set no flash verify if needed (default =false)
         ((Flash*)_io)->set_no_flash_verify(_flintParams.no_flash_verify);
     } else if (_flintParams.image_specified) {
         _io = new FImage;
@@ -543,7 +556,7 @@ static int mygetch(void)
     return ch;
 }
 
-bool SubCommand::getPasswordFromUser(const char *preStr, char buffer[MAX_PASSWORD_LEN])
+bool SubCommand::getPasswordFromUser(const char *preStr, char buffer[MAX_PASSWORD_LEN+1])
 {
     char c;
     int pos = 0;
@@ -552,7 +565,7 @@ bool SubCommand::getPasswordFromUser(const char *preStr, char buffer[MAX_PASSWOR
     do {
         c = mygetch();
 
-        if( ((pos < MAX_PASSWORD_LEN - 1)) && isprint(c) ) {
+        if( ((pos < MAX_PASSWORD_LEN)) && isprint(c) ) {
             buffer[ pos++ ] = c;
             printf("%c", '*');
         } else if( (c == 8 || c == 127) && pos ) {
@@ -568,11 +581,11 @@ bool SubCommand::getPasswordFromUser(const char *preStr, char buffer[MAX_PASSWOR
 }
 
 #else
-bool SubCommand::getPasswordFromUser(char *preStr, char buffer[MAX_PASSWORD_LEN])
+bool SubCommand::getPasswordFromUser(const char *preStr, char buffer[MAX_PASSWORD_LEN+1])
 {
     //TODO: Buffer Overflow danger use loop with gets() or istream
     printf("%s: ", preStr);
-    scanf("%s", buffer);
+    scanf("%256s", buffer);
     return true;
 }
 
@@ -611,13 +624,13 @@ bool SubCommand::askUser(const char *question, bool printAbrtMsg) {
         }
         */
         fflush(stdout);
-        fgets(ansbuff, 30, stdin);
+        //fgets(ansbuff, 30, stdin);
+        if (!fscanf(stdin, "%30s", ansbuff)) {
+               return false;
+        }
 
-        if (  strcmp(ansbuff, "y\n") &&
-              strcmp(ansbuff, "Y\n") &&
-              strcmp(ansbuff, "yes\n") &&
-              strcmp(ansbuff, "Yes\n") &&
-              strcmp(ansbuff, "YES\n"))  {
+        if (  strcasecmp(ansbuff, "y") &&
+              strcasecmp(ansbuff, "yes"))  {
 
             if (printAbrtMsg) {
             reportErr(true, "Aborted by user\n");
@@ -631,37 +644,16 @@ bool SubCommand::askUser(const char *question, bool printAbrtMsg) {
 
 void SubCommand::displayOneExpRomInfo(const rom_info_t& info) {
 
+       const char* typeStr = FwOperations::expRomType2Str(info.exp_rom_product_id);
     if (info.exp_rom_product_id == 0xf) {// version id in this case is the freeStr that was moved to exp_rom_ver[0] in mlxfwops
-        printf("devid=%d version_id=%d", info.exp_rom_dev_id,info.exp_rom_ver[0]);
+        printf("devid=%d version_id=%d type=%s", info.exp_rom_dev_id,info.exp_rom_ver[0], typeStr);
     } else {
-        printf("type=");
-        switch (info.exp_rom_product_id) {
-        case 1:
-            printf("CLP1 ");
-            break;
-        case 2:
-            printf("CLP2 ");
-            break;
-        case 3:
-            printf("CLP3 ");
-            break;
-        case 4:
-            printf("CLP4 ");
-            break;
-        case 0x10:
-            printf("PXE  ");
-            break;
-        case 0x11:
-            printf("UEFI ");
-            break;
-        case 0x21:
-            printf("FCODE ");
-            break;
-
-        default:
-            printf("0x%x - Unknown ROM product ID\n", info.exp_rom_product_id);
-            return;
-        }
+       if (typeStr) {
+               printf("type=%s", typeStr);
+       } else {
+                printf("0x%x - Unknown ROM product ID\n", info.exp_rom_product_id);
+                return;
+       }
 
         printf("version=%d", info.exp_rom_ver[0]);
         if (info.exp_rom_product_id >= 0x10) {
@@ -675,20 +667,21 @@ void SubCommand::displayOneExpRomInfo(const rom_info_t& info) {
                 // Do not display if 0 - port independent
                 printf(" port=%d", info.exp_rom_port);
             }
-
-            printf(" proto=");
-            switch (info.exp_rom_proto) {
-            case ER_IB:
-                printf("IB");
-                break;
-            case ER_ETH:
-                printf("ETH");
-                break;
-            case ER_VPI:
-                printf("VPI");
-                break;
-            default:
-                printf("0x%x", info.exp_rom_proto);
+            if (info.exp_rom_product_id != 0x12) { // on CLP(0x12) there is no meaning to protocol
+               printf(" proto=");
+               switch (info.exp_rom_proto) {
+               case ER_IB:
+                       printf("IB");
+                       break;
+               case ER_ETH:
+                       printf("ETH");
+                       break;
+               case ER_VPI:
+                       printf("VPI");
+                       break;
+               default:
+                       printf("0x%x", info.exp_rom_proto);
+               }
             }
         }
     }
@@ -733,35 +726,6 @@ void SubCommand::displayExpRomInfo(const roms_info_t& romsInfo, const char *preS
     return;
 }
 
-/*TODO: this function was ported to mlxfwops needs to be removed.
- *
-void SubCommand::setDevFlags(const fw_info_t& info, bool& ib_dev, bool& eth_dev) {
-
-    if (info.fw_info.chip_type == CT_IS4) {
-        ib_dev = true;
-        eth_dev = false;
-    } else if (info.fw_info.chip_type == CT_SWITCHX) {
-        ib_dev = true;
-        eth_dev = true;
-    } else {
-        ib_dev  = (info.fw_type == FIT_FS3) || !_fwOps->CntxEthOnly(info.fw_info.dev_type);
-        eth_dev = (info.fw_type == FIT_FS2)  && info.fw_info.chip_type == CT_CONNECTX;
-    }
-
-    if ((!ib_dev && !eth_dev) || info.fw_info.chip_type == CT_UNKNOWN) {
-        // Unknown device id - for forward compat - assume that ConnectX is MP and
-        // prev HCAs are IB only (these flags are for printing only - no real harm can be done).
-        // TODO: FS2 does not mean ConnectX now.
-        ib_dev = true;
-        if (info.fw_type == FIT_FS2) {
-            eth_dev = true;
-        } else {
-            eth_dev = false;
-        }
-    }
-}
-*/
-
 bool SubCommand::printGuidLine(guid_t* new_guids, guid_t* old_guids, int guid_index)
 {
     printf(GUID_FORMAT GUID_SPACES, new_guids[guid_index].h, new_guids[guid_index].l);
@@ -945,10 +909,11 @@ bool SubCommand::unzipDataFile (std::vector<u_int8_t> data, std::vector<u_int8_t
     newData.resize(destLen + 1);
     return true;
 #else
+    // avoid warnings
     (void) data;
     (void) newData;
     (void) sectionName;
-    reportErr(true, "Executable was compiled with \"dump files\" option disabled.\n");
+    reportErr(true, FLINT_NO_ZLIB_ERROR);
     return false;
 #endif
 }
@@ -1046,6 +1011,10 @@ BurnSubCommand:: BurnSubCommand()
               INDENTEX FLINT_NAME" -d "MST_DEV_EXAMPLE2" -guid 0x2c9000100d050 -i image1.bin b";
     _v = Wtv_Dev_And_Img;
     _cmdType = SC_Burn;
+    _fwType = 0;
+    _devQueryRes = 0;
+    memset(&_devInfo, 0, sizeof(_devInfo));
+    memset(&_imgInfo, 0, sizeof(_imgInfo));
 }
 
 BurnSubCommand:: ~BurnSubCommand()
@@ -1100,7 +1069,7 @@ bool BurnSubCommand::verifyParams()
 void BurnSubCommand::updateBurnParams()
 {
     _burnParams.progressFunc = _flintParams.silent == true ? (ProgressCallBack)NULL :\
-            _devInfo.fw_type == FIT_FS2? &burnCbFs2Func : &burnCbFs3Func;
+               _fwType == FIT_FS2? &burnCbFs2Func : &burnCbFs3Func;
     _burnParams.userGuidsSpecified = _flintParams.guids_specified || _flintParams.guid_specified;
     _burnParams.userMacsSpecified = _flintParams.macs_specified || _flintParams.mac_specified;
     _burnParams.userUidsSpecified = _flintParams.uids_specified || _flintParams.uid_specified;
@@ -1141,19 +1110,19 @@ bool BurnSubCommand::checkFwVersion()
     printf("\n");
     printf("    Current FW version on flash:  ");
     if (_devInfo.fw_info.fw_ver[0] != 0) { // i.e if we have a fw_version we assume this is != 0
-        sprintf(curr_ver, "%d.%d.%d", _devInfo.fw_info.fw_ver[0], _devInfo.fw_info.fw_ver[1], _devInfo.fw_info.fw_ver[2]);
+        snprintf(curr_ver, 124, "%d.%d.%d", _devInfo.fw_info.fw_ver[0], _devInfo.fw_info.fw_ver[1], _devInfo.fw_info.fw_ver[2]);
     } else {
-        sprintf(curr_ver, "N/A");
+        snprintf(curr_ver, 124, "N/A");
     }
-    printf(curr_ver); printf("\n");
+    printf("%s", curr_ver); printf("\n");
 
     printf("    New FW version:               ");
     if (_imgInfo.fw_info.fw_ver[0] != 0) {
-        sprintf(new_ver, "%d.%d.%d", _imgInfo.fw_info.fw_ver[0], _imgInfo.fw_info.fw_ver[1], _imgInfo.fw_info.fw_ver[2]);
+        snprintf(new_ver, 124, "%d.%d.%d", _imgInfo.fw_info.fw_ver[0], _imgInfo.fw_info.fw_ver[1], _imgInfo.fw_info.fw_ver[2]);
     } else {
-        sprintf(new_ver, "N/A");
+        snprintf(new_ver, 124, "N/A");
     }
-    printf(new_ver); printf("\n");
+    printf("%s", new_ver); printf("\n");
 
     if (_flintParams.log_specified) {
         print_line_to_log("Current FW version on flash: %s,  New FW version: %s\n", curr_ver, new_ver);
@@ -1239,7 +1208,8 @@ FlintStatus BurnSubCommand::burnFs3()
         reportErr(true, FLINT_FS3_BURN_ERROR, _fwOps->err());
         return FLINT_FAILED;
     }
-    _burnParams.progressFunc(101);
+    PRINT_PROGRESS(_burnParams.progressFunc, 101);
+
     write_result_to_log(FLINT_SUCCESS, "", _flintParams.log_specified);
     return FLINT_SUCCESS;
 }
@@ -1343,7 +1313,7 @@ FlintStatus BurnSubCommand::burnFs2()
         reportErr(true, FLINT_FS2_BURN_ERROR, _fwOps->err());
         return FLINT_FAILED;
     }
-    _burnParams.progressFunc(101);
+    PRINT_PROGRESS(_burnParams.progressFunc, 101);
     write_result_to_log(FLINT_SUCCESS, "", _flintParams.log_specified);
     return FLINT_SUCCESS;
 }
@@ -1407,7 +1377,7 @@ bool BurnSubCommand::dealWithGuids()
             || _burnParams.userMacsSpecified
             || _burnParams.userUidsSpecified;
     if (is_guids_specified) {
-        if (!checkGuidsFlags((chip_type_t)_imgInfo.fw_info.chip_type, _imgInfo.fw_info.dev_type, _devInfo.fw_type,\
+        if (!checkGuidsFlags((chip_type_t)_imgInfo.fw_info.chip_type, _imgInfo.fw_info.dev_type, _fwType,\
                 _burnParams.userGuidsSpecified, _burnParams.userMacsSpecified, _burnParams.userUidsSpecified)) {
             return false;
         }
@@ -1437,15 +1407,15 @@ void BurnSubCommand::dealWithExpRom()
 {
     bool getRomFromDev = false;
     // Check exp rom:
-    bool fs2Cond = _devInfo.fw_type == FIT_FS2? (_devQueryRes && _devInfo.fw_info.chip_type == CT_CONNECTX && \
+    bool fs2Cond = _fwType == FIT_FS2? (_devQueryRes && _devInfo.fw_info.chip_type == CT_CONNECTX && \
             (FwOperations::IsFwSupportingRomModify(_devInfo.fw_info.fw_ver) || (_imgInfo.fw_info.roms_info.num_of_exp_rom > 0))\
             && !_flintParams.use_image_rom && !strcmp(_devInfo.fw_info.product_ver,"") && !strcmp(_imgInfo.fw_info.product_ver, "")) : false;
 
-    bool fs3Cond = _devInfo.fw_type == FIT_FS3 ? (_devQueryRes && _devInfo.fw_info.chip_type == CT_CONNECT_IB && \
+    bool fs3Cond = _fwType == FIT_FS3 ? (_devQueryRes && (_devInfo.fw_info.chip_type == CT_CONNECT_IB || _devInfo.fw_info.chip_type == CT_CONNECTX) && \
             (FwOperations::IsFwSupportingRomModify(_devInfo.fw_info.fw_ver) || (_imgInfo.fw_info.roms_info.num_of_exp_rom > 0))\
-            && !_flintParams.use_image_rom) : false; //&& !strcmp(_devInfo.fw_info.product_ver,"") && !strcmp(_imgInfo.fw_info.product_ver, "") : false;
+            && !_flintParams.use_image_rom) && !strcmp(_devInfo.fw_info.product_ver,"") && !strcmp(_imgInfo.fw_info.product_ver, "") : false;
 
-    bool cond = _devInfo.fw_type == FIT_FS2 ? fs2Cond : fs3Cond;
+    bool cond = _fwType == FIT_FS2 ? fs2Cond : fs3Cond;
 
     if (cond) {
         // Enter here when:
@@ -1453,7 +1423,7 @@ void BurnSubCommand::dealWithExpRom()
         //                  ( The device is hermon ||  golan    )&&
         //                  The image fw supports modifying ROM OR it contains ROM &&.
         //                  The user didn't ask to burn the image rom. &&
-        //                  The  fw on the flash doesn't contain product version (on golan we dont check this last cond)
+        //                  The  fw on the flash doesn't contain product version
 
         if (_imgInfo.fw_info.roms_info.num_of_exp_rom > 0 && _devInfo.fw_info.roms_info.num_of_exp_rom > 0) {
             printf("\n    Note: Both the image file and the flash contain a ROM image.\n"
@@ -1493,6 +1463,8 @@ FlintStatus BurnSubCommand::executeCommand()
     if (preFwOps() == FLINT_FAILED) {
         return FLINT_FAILED;
     }
+    //set fw type
+    _fwType = _fwOps->FwType();
     // query both image and device (deviceQuery can fail but we save rc)
     _devQueryRes = _fwOps->FwQuery(&_devInfo);
     if (!_imgOps->FwQuery(&_imgInfo))
@@ -1502,9 +1474,9 @@ FlintStatus BurnSubCommand::executeCommand()
         }
     //updateBurnParams with input given by user
     updateBurnParams();
-    if (_devInfo.fw_type == FIT_FS3) {
+    if (_fwType == FIT_FS3) {
         return burnFs3();
-    } else if (_devInfo.fw_type == FIT_FS2) {
+    } else if (_fwType == FIT_FS2) {
     return burnFs2();
     }
     // unknown fw type
@@ -1628,14 +1600,13 @@ bool QuerySubCommand::displayFs2Uids(const fw_info_t& fwInfo)
     // GUIDS:
 
     if (fwInfo.fw_info.chip_type == CT_BRIDGEX) {
-        int i, base;
+        int i;
         if (fwInfo.fs2_info.guid_num != BX_ALL_GUIDS) {
             reportErr(true, FLINT_INVALID_UID_NUM_BX_ERROR, BX_ALL_GUIDS);
             return false;
         }
         printf("Description:     Node             Port1            Port2            Port3            Port4\n");
         for (i = 0; i < BX_SLICES_NUM; i++) {
-            base = i * BX_SLICE_GUIDS;
             reportBxGuidsQuery(fwInfo.fs2_info.guids, BI_GUIDS,  BX_NP_GUIDS, i, "GUIDs:");
             reportBxMacsQuery(fwInfo.fs2_info.guids,  BI_IMACS, BX_IMACS,    i, "IMACs:");
             reportBxMacsQuery(fwInfo.fs2_info.guids,  BI_EMACS, BX_EMACS,    i, "EMACs:");
@@ -1704,9 +1675,9 @@ bool QuerySubCommand::displayFs2Uids(const fw_info_t& fwInfo)
 }
 
 #define BASE_STR "Base"
-#define PRINT_FS3_UID(uid1, str) printf("%-16s %016lx        %d        %d\n", str, uid1.uid, uid1.num_allocated, uid1.step);
+#define PRINT_FS3_UID(uid1, str) printf("%-16s %016"U64H_FMT_GEN"        %d        %d\n", str, uid1.uid, uid1.num_allocated, uid1.step);
 #define PRINT_FS3_UIDS(uid1, uid2, str) {\
-    PRINT_FS3_UID(uid1, BASE_STR" "str":");\
+       PRINT_FS3_UID(uid1, BASE_STR" "str":");\
     if (uid1.uid !=  uid2.uid || uid1.num_allocated != uid2.num_allocated  || uid1.step != uid2.step) {\
         PRINT_FS3_UID(uid2, "Orig " BASE_STR " "str":");\
     } \
@@ -1734,8 +1705,12 @@ FlintStatus QuerySubCommand::printInfo(const fw_info_t& fwInfo, bool fullQuery)
                 fwInfo.fw_info.fw_ver[2]);
     }
 
+    if (fwInfo.fw_info.fw_rel_date[0] || fwInfo.fw_info.fw_rel_date[1] || fwInfo.fw_info.fw_rel_date[2]) {
+        printf("FW Release Date: %x.%x.%x\n", fwInfo.fw_info.fw_rel_date[0], fwInfo.fw_info.fw_rel_date[1],\
+                fwInfo.fw_info.fw_rel_date[2]);
+    }
 
-    if (fullQuery) {
+    if (fullQuery) { // there is no full query atm just quick query
         if (fwInfo.fw_info.min_fit_ver[0] || fwInfo.fw_info.min_fit_ver[1]\
                 || fwInfo.fw_info.min_fit_ver[2]||fwInfo.fw_info.min_fit_ver[3]) {
             printf("Min FIT Version: %d.%d.%d.%d\n", fwInfo.fw_info.min_fit_ver[0],\
@@ -1848,9 +1823,8 @@ FlintStatus QuerySubCommand::executeCommand()
         return FLINT_FAILED;
     }
     //print fw_info nicely to the user
-    if (_flintParams.quick_query) {// we actually dont use "regular" query , just quick
-        printf("\n"FLINT_QQ_WARRNING"\n");
-    }
+    // we actually dont use "regular" query , just quick
+    //ORENK - no use to display quick query message to the user if we dont do it in any other way
     if (_flintParams.cmd_params.size() == 1) {
         fullQuery=true;
     }
@@ -1992,6 +1966,8 @@ BromSubCommand:: BromSubCommand()
     _example = FLINT_NAME" -d "MST_DEV_EXAMPLE1" brom exp-rom.rom";
     _v = Wtv_Dev_Or_Img;
     _cmdType = SC_Brom;
+    memset(&_info, 0, sizeof(_info));
+    memset(&_romsInfo, 0, sizeof(_romsInfo));
 }
 
 BromSubCommand:: ~BromSubCommand()
@@ -2061,7 +2037,7 @@ FlintStatus BromSubCommand::executeCommand()
         getExpRomStrVer(_info.fw_info.roms_info, romVer1);
     } else {
         printf("%s", infoStr);
-        sprintf(romVer1, "N/A");
+        snprintf(romVer1, 50, "N/A");
         printf("%s\n", romVer1);
     }
     displayExpRomInfo(_romsInfo, infoStr2);
@@ -2281,6 +2257,8 @@ SgSubCommand:: SgSubCommand()
     _example = FLINT_NAME" -d "MST_DEV_EXAMPLE1" -guid 0x0002c9000100d050 sg";
     _v = Wtv_Dev_Or_Img;
     _cmdType = SC_Sg;
+    _ops     = NULL;
+    memset(&_info, 0, sizeof(_info));
 }
 
 SgSubCommand:: ~SgSubCommand()
@@ -2463,14 +2441,20 @@ SmgSubCommand:: SmgSubCommand()
     _name = "smg";
     _desc = "Set manufacture GUIDs (For FS3 image only).";
     _extendedDesc = "Set manufacture GUID, Set manufacture GUIDs in the given FS3 image.\n"
-                INDENTEX"Use -uid flag to set the desired GUIDs.";
+                INDENTEX"Use -uid flag to set the desired GUIDs, intended for production use only.";
     _flagLong = "smg";
     _flagShort = "";
     _param = "";
     _paramExp = "None";
-    _example = FLINT_NAME" -i fw_image.bin -uid 0x0002c9000100d050 smg";
+    _example = FLINT_NAME" -i fw_image.bin -uid 0x0002c9000100d050 smg"
+#ifndef __WIN__
+               "\n"INDENTEX FLINT_NAME" -d "MST_DEV_EXAMPLE3" -uid 0x0002c9000100d050 smg (should be used when device is idle)"
+#endif
+               ;
     _v = Wtv_Dev_Or_Img;
     _cmdType = SC_Smg;
+    _baseGuid.h = 0;
+    _baseGuid.l = 0;
 }
 
 SmgSubCommand:: ~SmgSubCommand()
@@ -2509,18 +2493,22 @@ FlintStatus SmgSubCommand::executeCommand()
 
 
 /***********************
- *Class:
+ *Class: Set Vpd Subcommand
  **********************/
 SetVpdSubCommand:: SetVpdSubCommand()
 {
     _name = "set vpd";
     _desc = "Set read-only VPD (For FS3 image only).";
-    _extendedDesc = "Set Read-only VPD, Set VPD in the given FS3 image.";
+    _extendedDesc = "Set Read-only VPD, Set VPD in the given FS3 image, intended for production use only.";
     _flagLong = "set_vpd";
     _flagShort = "";
     _param = "[vpd file]";
     _paramExp = "vpd file: bin file containing the vpd data";
-    _example = FLINT_NAME" -i fw_image.bin set_vpd vpd.bin";
+    _example = FLINT_NAME" -i fw_image.bin set_vpd vpd.bin"
+#ifndef __WIN__
+                       "\n"INDENTEX FLINT_NAME" -d "MST_DEV_EXAMPLE3" -override_cache_replacement set_vpd vpd.bin (should be used when device is idle)"
+#endif
+                       ;
     _v = Wtv_Dev_Or_Img;
     _cmdType = SC_Set_Vpd;
 }
@@ -2565,7 +2553,11 @@ SvSubCommand:: SvSubCommand()
     _flagShort = "";
     _param = "";
     _paramExp = "None";
-    _example = FLINT_NAME" -d "MST_DEV_EXAMPLE1" -vsd VSD_STRING sv";
+    _example = FLINT_NAME" -d "MST_DEV_EXAMPLE1" -vsd VSD_STRING sv"
+#ifndef __WIN__
+               "\n"INDENTEX FLINT_NAME" -d "MST_DEV_EXAMPLE3" -vsd VSD_STRING -override_cache_replacement sv (should be used when device is idle)\n"
+#endif
+               ;
     _v = Wtv_Dev_Or_Img;
     _cmdType = SC_Sv;
 }
@@ -2797,6 +2789,8 @@ SetKeySubCommand:: SetKeySubCommand()
     _example = FLINT_NAME" -d "MST_DEV_EXAMPLE1" set_key 1234deaf5678";
     _v = Wtv_Dev;
     _cmdType = SC_Set_Key;
+    _getKeyInter = false;
+    memset(&_userKey, 0, sizeof(_userKey));
 }
 
 SetKeySubCommand:: ~SetKeySubCommand()
@@ -2816,17 +2810,17 @@ bool SetKeySubCommand::verifyParams()
 
 bool SetKeySubCommand::getKeyInteractively()
 {
-    char keyArr[MAX_PASSWORD_LEN];
+    char keyArr[MAX_PASSWORD_LEN+1];
     getPasswordFromUser("Enter Key ", keyArr );
     if (!getGUIDFromStr(keyArr, _userKey,\
-                       "-E- Invalid Key syntax, it should contain only hexa numbers.")) {
+                       "Invalid Key syntax, it should contain only hexa numbers and of appropriate length.")) {
     return false;
     }
     // verify key
     hw_key_t verKey;
     getPasswordFromUser("Verify Key ", keyArr );
     if (!getGUIDFromStr(keyArr, verKey,\
-                       "-E- Invalid Key syntax, it should contain only hexa numbers.")) {
+                       "Invalid Key syntax, it should contain only hexa numbers and of appropriate length.")) {
     return false;
     }
     if (_userKey.h != verKey.h || _userKey.l != verKey.l) {
@@ -2853,7 +2847,7 @@ FlintStatus SetKeySubCommand::executeCommand ()
         }
     } else {
         if (!getGUIDFromStr(_flintParams.cmd_params[0], _userKey, \
-                "Invalid Key syntax, it should contain only hexa numbers.")) {
+                "Invalid Key syntax, it should contain only hexa numbers and of appropriate length.")) {
             return FLINT_FAILED;
         }
     }
@@ -2862,7 +2856,7 @@ FlintStatus SetKeySubCommand::executeCommand ()
         return FLINT_FAILED;
     }
     setKeyCbFunc(101);
-    printf("\n-I- New key was updated successfully in the flash."\
+    printf("\n-I- New key was updated successfully in the flash. "\
             "In order to activate the new key you should reboot or restart the driver.\n");
 
     return FLINT_SUCCESS;
@@ -2883,7 +2877,8 @@ HwAccessSubCommand:: HwAccessSubCommand()
     _param = "<enable|disable> [key]";
     _paramExp = "<enable/disable>: Specify if you intend to disable or enable the HW access.\n"
                 INDENTEX"                   You will be asked to type a key when you try to enable HW access.\n"
-                INDENTEX"key:               (optional) The key you intend to use for enabling the HW access.";
+                INDENTEX"key:               (optional) The key you intend to use for enabling the HW access.\n"
+                       INDENTEX"                   Key format consists of at most 16 Hexadecimal digits.";
     _example = FLINT_NAME" -d "MST_DEV_EXAMPLE1" hw_access enable";
     _v = Wtv_Dev;
     _cmdType = SC_Hw_Access;
@@ -2933,14 +2928,14 @@ FlintStatus HwAccessSubCommand:: enableHwAccess()
         //now we need to get the key from the user (either given in the parameters or we get it during runtime)
         if (_flintParams.cmd_params.size() == 2) {
              if (!getGUIDFromStr(_flintParams.cmd_params[1], keyStruct,\
-                     "-E- Invalid Key syntax, it should contain only hexa numbers.")) {
+                     "Invalid Key syntax, it should contain only hexa numbers and of appropriate length.")) {
                  return FLINT_FAILED;
              }
         } else {//we need to get the key from user during runtime
-            char keyArr[MAX_PASSWORD_LEN];
+            char keyArr[MAX_PASSWORD_LEN+1];
             getPasswordFromUser("Enter Key ", keyArr );
             if (!getGUIDFromStr(keyArr, keyStruct,\
-                    "-E- Invalid Key syntax, it should contain only hexa numbers.")) {
+                    "Invalid Key syntax, it should contain only hexa numbers and of appropriate length.")) {
                 return FLINT_FAILED;
             }
         }
@@ -2985,6 +2980,7 @@ HwSubCommand:: HwSubCommand()
        INDENTEX"set [ATTR=VAL]: set flash attribure\n"
        INDENTEX"Supported attributes:\n"
        INDENTEX"    QuadEn: can be 0 or 1\n"
+       INDENTEX"    DummyCycles: can be [1..15]\n"
        INDENTEX"    Flash[0|1|2|3].WriteProtected can be:\n"
        INDENTEX"        <Top|Bottom>,<1|2|4|8|16|32|64>-<Sectors|SubSectors>";
     _example = "flint -d /dev/mst/mt4099_pci_cr0 hw query\n"
@@ -3060,7 +3056,7 @@ FlintStatus HwSubCommand::printAttr(const ext_flash_attr_t& attr) {
             case MFE_OK:
                 printf("  "QUAD_EN_PARAM"                %d\n", attr.quad_en);
                 break;
-            case MFE_MISMATCH_QUAD_EN:
+            case MFE_MISMATCH_PARAM:
                 printf("-E- There is a mismatch in the "QUAD_EN_PARAM" attribute between the flashes attached to the device\n");
                 break;
             case MFE_NOT_SUPPORTED_OPERATION:
@@ -3071,6 +3067,23 @@ FlintStatus HwSubCommand::printAttr(const ext_flash_attr_t& attr) {
                 return FLINT_FAILED;
         }
     }
+    // Dummy Cycles query
+    if (attr.dummy_cycles_support) {
+        switch (attr.mf_get_dummy_cycles_rc) {
+            case MFE_OK:
+                printf("  "DUMMY_CYCLES_PARAM"           %d\n", attr.dummy_cycles);
+                break;
+            case MFE_MISMATCH_PARAM:
+                printf("-E- There is a mismatch in the "DUMMY_CYCLES_PARAM" attribute between the flashes attached to the device\n");
+                break;
+            case MFE_NOT_SUPPORTED_OPERATION:
+                break;
+            default:
+                printf("Failed to get "DUMMY_CYCLES_PARAM" attribute: %s (%s)",\
+                        errno == 0 ? "" : strerror(errno), mf_err2str(attr.mf_get_dummy_cycles_rc));
+                return FLINT_FAILED;
+        }
+    }
     // Flash write protected info query
     if (attr.write_protect_support) {
         int bank;
@@ -3490,10 +3503,6 @@ bool WbneSubCommand::writeBlock(u_int32_t addr, std::vector<u_int32_t> dataVec)
                             (unsigned int)(dataVec.size()*4), (unsigned int)addr, (unsigned int)_io->get_size());
        return false;
     }
-    // convert to be32.
-    for(std::vector<u_int32_t>::iterator it = dataVec.begin(); it != dataVec.end(); ++it) {
-        *it = __cpu_to_be32(*it);
-    }
     if (!((Flash*)_io)->write(addr, &dataVec[0], (dataVec.size()*4), true)) {
         reportErr(true, FLINT_FLASH_WRITE_ERROR,_io->err());
         return false;
@@ -3690,15 +3699,16 @@ FlintStatus ClearSemSubCommand::executeCommand()
 RomQuerySubCommand:: RomQuerySubCommand()
 {
     _name = "qrom";
-    _desc = "query rom in a given image.";
-    _extendedDesc = "query rom in a given image.";
+    _desc = "query ROM image.";
+    _extendedDesc = "query ROM image.";
     _flagLong = "qrom";
     _flagShort = "";
     _param = "";
     _paramExp = "";
-    _example = FLINT_NAME" -i fw_image.bin qrom ";
+    _example = FLINT_NAME" -i ROM_image.bin qrom ";
     _v = Wtv_Img;
     _cmdType = SC_Qrom;
+    memset(&_romsInfo, 0, sizeof(_romsInfo));
 }
 
 RomQuerySubCommand:: ~RomQuerySubCommand()
@@ -3722,3 +3732,91 @@ FlintStatus RomQuerySubCommand::executeCommand()
     return FLINT_SUCCESS;
 
 }
+
+/***********************
+ *Class: ResetCfg
+ **********************/
+ResetCfgSubCommand:: ResetCfgSubCommand()
+{
+    _name = "reset_cfg";
+    _desc = "reset non-volatile configuration.";
+    _extendedDesc = "reset non-volatile configuration to their default value.";
+    _flagLong = "reset_cfg";
+    _flagShort = "r";
+    _param = "";
+    _paramExp = "";
+    _example = FLINT_NAME" -d "MST_DEV_EXAMPLE1" reset_cfg";
+    _v = Wtv_Dev;
+    _cmdType = SC_ResetCfg;
+}
+
+ResetCfgSubCommand:: ~ResetCfgSubCommand()
+{
+
+}
+
+
+FlintStatus ResetCfgSubCommand::executeCommand()
+{
+    if (preFwOps() == FLINT_FAILED) {
+        return FLINT_FAILED;
+    }
+
+    if (!askUser("reset non-volatile configuration?")) {
+       return FLINT_FAILED;
+    }
+
+    printf("Resetting...");
+    if (!_fwOps->FwResetNvData(resetCfgCbFunc)){
+       printf(" Failed!\n");
+        reportErr(true, FLINT_RESET_CFG_ERROR, _fwOps->err());
+        return FLINT_FAILED;
+    }
+    printf(" SUCCESS!\n");
+    printf("\n-I- Configuration were successfully reset. reboot or restart the driver is required.\n");
+
+    return FLINT_SUCCESS;
+
+}
+
+/***********************
+ *Class: FixImage
+ **********************/
+FiSubCommand:: FiSubCommand()
+{
+    _name = "fix image";
+    _desc = "fix image on N25Q0XX flash.";
+    _extendedDesc = "fix image on N25Q0XX flash.(shifting all device data sectors)";
+    _flagLong = "fi";
+    _flagShort = "";
+    _param = "";
+    _paramExp = "";
+    _example = FLINT_NAME" -d "MST_DEV_EXAMPLE1" fi";
+    _v = Wtv_Dev;
+    _cmdType = SC_Fix_Img;
+}
+
+FiSubCommand:: ~FiSubCommand()
+{
+
+}
+
+
+FlintStatus FiSubCommand::executeCommand()
+{
+    if (preFwOps() == FLINT_FAILED) {
+        return FLINT_FAILED;
+    }
+
+    if (!askUser("Fix device fw?")) {
+       return FLINT_FAILED;
+    }
+
+    if (!_fwOps->FwShiftDevData(&verifyCbFunc)){
+        reportErr(true, FLINT_FIX_IMG_ERROR, _fwOps->err());
+        return FLINT_FAILED;
+    }
+    printf("\n-I- Fw was successfully fixed. reboot or restart the driver is required.\n");
+    return FLINT_SUCCESS;
+
+}
index 9e7bc50526b9aeca0d2ab91d6df009ac1f8ee7e1..1d42ab506db466490e0331f8bfdf3809fd4f148e 100644 (file)
 #ifndef __SUBCOMMANDS_H__
 #define __SUBCOMMANDS_H__
 
-#define FLINT_NAME "mstflint"
 #define MAX_PASSWORD_LEN 256
-#ifdef __WIN__
-#define MST_DEV_EXAMPLE1 "mt4099_pci_cr0"
-#define MST_DEV_EXAMPLE2 "mt4099_pciconf0"
-#else
-#define MST_DEV_EXAMPLE1 "03:00.0"
-#define MST_DEV_EXAMPLE2 "mlx4_0"
-#endif
 
 #include <string>
 #include "flint_params.h"
@@ -62,7 +54,6 @@ int print_line_to_log(const char* format, ...);
 int write_cmd_to_log(char* av[], int ac, CommandType cmd, bool write=true);
 int write_result_to_log(int is_failed, const char* err_msg, bool write=true);
 
-
 typedef enum what_to_ver {
     Wtv_Img,
     Wtv_Dev,
@@ -109,8 +100,8 @@ protected:
     void displayOneExpRomInfo(const rom_info_t& info);
     void displayExpRomInfo(const roms_info_t& romsInfo, const char *preStr);
 
-    static int verifyCbFunc(const char* str);
-    static int CbCommon(int completion, const char*preStr, const char* endStr=NULL);
+    static int verifyCbFunc(char* str);
+    static int CbCommon(int completion, char*preStr, char* endStr=NULL);
     static int burnCbFs2Func(int completion);
     static int burnCbFs3Func(int completion);
     static int burnBCbFunc(int completion);
@@ -119,6 +110,7 @@ protected:
     static int bromCbFunc(int completion);
     static int dromCbFunc(int completion);
     static int wbCbFunc(int completion);
+    static int resetCfgCbFunc(int completion);
 
     bool printGuidLine(guid_t* new_guids, guid_t* old_guids, int guid_index);
     bool printBxGuids(guid_t* new_guids, guid_t* old_guids, int index,\
@@ -136,7 +128,7 @@ protected:
     void printMissingGuidErr(bool ibDev, bool ethDev, bool bxDev);
 
     bool getGUIDFromStr(string str, guid_t& guid, string prefixErr="");
-    bool  getPasswordFromUser(const char *preStr, char buffer[MAX_PASSWORD_LEN]);
+    bool  getPasswordFromUser(const char *preStr, char buffer[MAX_PASSWORD_LEN+1]);
     bool askUser(const char* question=NULL, bool printAbrtMsg=true);
 
     bool isCmdSupportLog();
@@ -156,7 +148,11 @@ protected:
 
 
 public:
-    SubCommand(): _fwOps(NULL), _imgOps(NULL), _io(NULL), _v(Wtv_Uninitilized){}
+    SubCommand(): _fwOps(NULL), _imgOps(NULL), _io(NULL), _v(Wtv_Uninitilized)
+    {
+        _cmdType = SC_No_Cmd;
+        memset(_errBuff, 0, sizeof(_errBuff));
+    }
     virtual ~SubCommand();
     virtual FlintStatus executeCommand() = 0;
     inline void setParams(const FlintParams& flintParams) {_flintParams = flintParams;}
@@ -173,6 +169,7 @@ public:
 class BurnSubCommand : public SubCommand
 {
 private:
+       u_int8_t _fwType;
     fw_info_t _devInfo;
     fw_info_t _imgInfo;
     FwOperations::ExtBurnParams _burnParams;
@@ -249,8 +246,6 @@ public:
 
 class DromSubCommand : public SubCommand
 {
-private:
-    fw_info_t _info;
 public:
     DromSubCommand();
     ~DromSubCommand();
@@ -494,4 +489,20 @@ public:
     FlintStatus executeCommand();
 };
 
+class ResetCfgSubCommand : public SubCommand
+{
+public:
+    ResetCfgSubCommand();
+    ~ResetCfgSubCommand();
+    FlintStatus executeCommand();
+};
+
+class FiSubCommand : public SubCommand
+{
+public:
+    FiSubCommand();
+    ~FiSubCommand();
+    FlintStatus executeCommand();
+};
+
 #endif
index 594c2a652da7e875de2c622b9d176619c7310775..8fe67a4647ca78e78a34a48f76c339ddb4985e22 100755 (executable)
@@ -2,6 +2,6 @@
 
 if git rev-parse --short HEAD > gitversion.tmp
 then
-    echo "#define TOOLS_SVN_VER \"`tr -d '\n' < gitversion.tmp`\"" > $1 
+    echo "#define TOOLS_GIT_SHA \"`tr -d '\n' < gitversion.tmp`\"" > $1 
 fi
 rm gitversion.tmp
index b68464d0cab6185b65802b15abb6c3505e19b5bd..c8ea8e1dd22382c6b8f2364fe2855f09097d93c3 100644 (file)
@@ -1,10 +1,7 @@
 /*
- *
  *  mtcr.h - Mellanox Software tools (mst) driver definitions
  *
- * Author: Michael S. Tsirkin <mst@mellanox.co.il>
- *
- * Copyright (c) 2006 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -15,7 +12,7 @@
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- *
+ * 
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
@@ -24,7 +21,7 @@
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- *
+ * 
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -45,6 +42,67 @@ extern "C" {
 
 #include <sys/types.h>
 
+typedef enum MError {
+    ME_OK = 0,
+    ME_ERROR,
+    ME_BAD_PARAMS,
+    ME_CR_ERROR,
+    ME_NOT_IMPLEMENTED,
+    ME_SEM_LOCKED,
+    ME_MEM_ERROR,
+
+    ME_MAD_SEND_FAILED,
+    ME_UNKOWN_ACCESS_TYPE,
+    ME_UNSUPPORTED_DEVICE,
+    ME_REG_NOT_SUPPORTED,
+
+    // errors regarding REG_ACCESS
+    ME_REG_ACCESS_OK = 0,
+    ME_REG_ACCESS_BAD_STATUS_ERR = 0x100,
+    ME_REG_ACCESS_BAD_METHOD,
+    ME_REG_ACCESS_NOT_SUPPORTED,
+    ME_REG_ACCESS_DEV_BUSY,
+    ME_REG_ACCESS_VER_NOT_SUPP,
+    ME_REG_ACCESS_UNKNOWN_TLV,
+    ME_REG_ACCESS_REG_NOT_SUPP,
+    ME_REG_ACCESS_CLASS_NOT_SUPP,
+    ME_REG_ACCESS_METHOD_NOT_SUPP,
+    ME_REG_ACCESS_BAD_PARAM,
+    ME_REG_ACCESS_RES_NOT_AVLBL,
+    ME_REG_ACCESS_MSG_RECPT_ACK,
+    ME_REG_ACCESS_UNKNOWN_ERR,
+    ME_REG_ACCESS_SIZE_EXCCEEDS_LIMIT,
+    ME_REG_ACCESS_CONF_CORRUPT,
+    ME_REG_ACCESS_LEN_TOO_SMALL,
+    ME_REG_ACCESS_BAD_CONFIG,
+    ME_REG_ACCESS_ERASE_EXEEDED,
+
+    // errors regarding ICMD
+    ME_ICMD_STATUS_CR_FAIL = 0x200,       // cr-space access failure
+    ME_ICMD_INVALID_OPCODE,
+    ME_ICMD_INVALID_CMD,
+    ME_ICMD_OPERATIONAL_ERROR,
+    ME_ICMD_BAD_PARAM,
+    ME_ICMD_BUSY,
+    ME_ICMD_INIT_FAILED,
+    ME_ICMD_NOT_SUPPORTED,
+    ME_ICMD_STATUS_SEMAPHORE_TO,          // timed out while trying to take semaphore
+    ME_ICMD_STATUS_EXECUTE_TO,            // timed out while waiting for command to execute
+    ME_ICMD_STATUS_IFC_BUSY,
+    ME_ICMD_STATUS_ICMD_NOT_READY,
+    ME_ICMD_UNSUPPORTED_ICMD_VERSION,
+
+    //errors regarding Tools CMDIF
+    ME_CMDIF_BUSY = 0x300,
+    ME_CMDIF_TOUT,
+    ME_CMDIF_BAD_STATUS,
+    ME_CMDIF_BAD_OP,
+    ME_CMDIF_NOT_SUPP,
+    ME_CMDIF_BAD_SYS,
+
+    ME_LAST
+} MError;
+
 typedef enum Mdevs_t {
     MDEVS_GAMLA     = 0x01, /*  Each device that actually is a Gamla */
     MDEVS_I2CM      = 0x02, /*  Each device that can work as I2C master */
@@ -58,12 +116,17 @@ typedef enum Mdevs_t {
     MDEVS_DEV_I2C   = 0x200, /* Generic linux kernel i2c device */
     MDEVS_IB        = 0x400, /* Cr access over IB Mads */
     MDEVS_MLNX_OS   = 0x800, /* access by CmdIf in MlnxOS */
+    MDEVS_FWCTX                = 0x900, /*access by UEFI func/context */
     MDEVS_TAVOR     = (MDEVS_TAVOR_DDR|MDEVS_TAVOR_UAR|MDEVS_TAVOR_CR),
     MDEVS_ALL       = 0xffffffff
 } Mdevs;
-
 typedef struct mfile_t mfile;
 
+typedef enum {
+    MACCESS_REG_METHOD_GET = 1,
+    MACCESS_REG_METHOD_SET = 2
+} maccess_reg_method_t;
+
 typedef struct dev_info_t
 {
     Mdevs         type;
@@ -102,7 +165,18 @@ typedef struct dev_info_t
     };
 } dev_info;
 
-
+typedef enum {
+    RA_MFPA=0x9010,
+    RA_MFBA=0x9011,
+    RA_MFBE=0x9012,
+} reg_access_t;
+
+enum mtcr_access_method {
+    MTCR_ACCESS_ERROR  = 0x0,
+    MTCR_ACCESS_MEMORY = 0x1,
+    MTCR_ACCESS_CONFIG = 0x2,
+    MTCR_ACCESS_INBAND = 0x3
+};
 /*
  * Read 4 bytes, return number of succ. read bytes or -1 on failure
  */
@@ -137,6 +211,9 @@ int mdevices(char *buf, int len, int mask);
 dev_info* mdevices_info(int mask, int* len);
 
 void mdevice_info_destroy(dev_info* dev_info, int len);
+void mdevices_info_destroy(dev_info* dev_info, int len);
+
+int mget_mdevs_type(mfile *mf, u_int32_t *mtype);
 
 /*
  * Open Mellanox Software tools (mst) driver. Device type==TAVOR
@@ -146,6 +223,8 @@ mfile *mopen(const char *name);
 
 mfile *mopend(const char *name, int type);
 
+mfile *mopen_fw_ctx(void* fw_cmd_context, void* fw_cmd_func);
+
 /*
  * Close Mellanox driver
  * req. descriptor
@@ -157,11 +236,34 @@ unsigned char mset_i2c_slave(mfile *mf, unsigned char new_i2c_slave);
 int mget_mdevs_flags(mfile *mf, u_int32_t *devs_flags);
 
 int maccess_reg_mad(mfile *mf, u_int8_t *data);
+
 int mos_reg_access(mfile *mf, int reg_access, void *reg_data, u_int32_t cmd_type);
 
+int maccess_reg_cmdif(mfile *mf, reg_access_t reg_access, void *reg_data, u_int32_t cmd_type);
+
+int maccess_reg(mfile     *mf,
+                u_int16_t  reg_id,
+                maccess_reg_method_t reg_method,
+                void*      reg_data,
+                u_int32_t  reg_size,
+                u_int32_t      r_size_reg, // used when sending via icmd interface (how much data should be read back to the user)
+                u_int32_t      w_size_reg, // used when sending via icmd interface (how much data should be written to the scratchpad)
+                                                   // if you dont know what you are doing then r_size_reg = w_size_reg = your_register_size
+                int       *reg_status);
+
+int icmd_send_command(mfile *mf, int opcode, void* data, int data_size, int skip_write);
+
+int icmd_clear_semaphore(mfile *mf);
+
+int mget_max_reg_size(mfile *mf);
+
+const char* m_err2str(MError status);
+
 int mread_buffer(mfile *mf, unsigned int offset, u_int8_t* data, int byte_len);
 int mwrite_buffer(mfile *mf, unsigned int offset, u_int8_t* data, int byte_len);
 
+int tools_cmdif_query_dev_cap(mfile *mf, u_int32_t offset, u_int64_t* data);
+
 #ifdef __cplusplus
 }
 #endif
index 24a9b735cd8bcf5289f4277e59e4ba65c273cc86..f7289a73c2e0bb3c305e66adf2c4a6f55b4c1546 100644 (file)
@@ -1,5 +1,5 @@
 .\"Text automatically generated by txt2man
-.TH mstflint 3.5.0  "December 2013" "" ""
+.TH mstflint 3.6.0  "December 2013" "" ""
 .SH NAME
 \fBmstflint \fP- Mellanox Technologies Firmware Update Tool
 .SH SYNOPSIS
@@ -120,39 +120,13 @@ be specified here.
 The specified UIDs are assigned to the following 
 fields, repectively:
 .RS
-.TP
-.B
-G0-MAC-PI0
-G0-MAC-PI1      G0-MAC-PI2
-.TP
-.B
-G0-MAC-PE0
-G0-MAC-PE1      G0-MAC-PE2 
-G0-MAC-PE3
-.TP
-.B
-G0-FC-WWPN-P0
-G0-FC-WWPN-P1   G0-FC-WWPN-P2 
-G0-FC-WWPN-P3
-G0-IB-NODE-GUID G0-IB-PORT-GUID 
-G0-FC-WWNN
-.TP
-.B
-G1-MAC-PI0
-G1-MAC-PI1   
-G1-MAC-PI2
-.TP
-.B
-G1-MAC-PE0
-G1-MAC-PE1      G1-MAC-PE2 
-G1-MAC-PE3
-.TP
-.B
-G1-FC-WWPN-P0
-G1-FC-WWPN-P1   G1-FC-WWPN-P2 
-G1-FC-WWPN-P3
-G1-IB-NODE-GUID G1-IB-PORT-GUID 
-G1-FC-WWNN
+G0-MAC-PI0      G0-MAC-PI1      G0-MAC-PI2      G0-MAC-PE0
+G0-MAC-PE1      G0-MAC-PE2      G0-MAC-PE3      G0-FC-WWPN-P0
+G0-FC-WWPN-P1   G0-FC-WWPN-P2   G0-FC-WWPN-P3   G0-IB-NODE-GUID
+G0-IB-PORT-GUID G0-FC-WWNN      G1-MAC-PI0      G1-MAC-PI1
+G1-MAC-PI2      G1-MAC-PE0      G1-MAC-PE1      G1-MAC-PE2
+G1-MAC-PE3      G1-FC-WWPN-P0   G1-FC-WWPN-P1   G1-FC-WWPN-P2
+G1-FC-WWPN-P3   G1-IB-NODE-GUID G1-IB-PORT-GUID G1-FC-WWNN
 IB-SYSTEM-GUID
 Commands affected: 
 burn, sg
@@ -325,17 +299,17 @@ burn|b
 .TP
 .B
 query|q [full]
-: Query misc. flash/firmware characteristics, use "full"
+                                : Query misc. flash/firmware characteristics, use "full"
 to get more information.
 .TP
 .B
 verify|v [showitoc]
-: Verify entire flash, use "showitoc" to see ITOC headers
+                                : Verify entire flash, use "showitoc" to see ITOC headers
 in FS3 image only.
 .TP
 .B
 swreset
-: SW reset the target un-managed switch device. This command
+                                : SW reset the target un-managed switch device. This command
 is supported only in the In-Band access method.
 .TP
 .B
@@ -344,7 +318,7 @@ brom
 .TP
 .B
 drom
-: Remove the ROM section from the flash.
+                                : Remove the ROM section from the flash.
 .TP
 .B
 rrom
@@ -356,7 +330,7 @@ bb
 .TP
 .B
 sg
-[nocrc]                           : Set GUIDs.
+[nocrc]                         : Set GUIDs.
 .TP
 .B
 smg
@@ -364,7 +338,7 @@ smg
 .TP
 .B
 set_vpd
-[vpd file]                   : Set read-only VPD (For FS3 image only).
+[vpd file]                      : Set read-only VPD (For FS3 image only).
 .TP
 .B
 sv
@@ -372,32 +346,32 @@ sv
 .TP
 .B
 ri
-<out-file>                        : Read the fw image on the flash.
+<out-file>                      : Read the fw image on the flash.
 .TP
 .B
 dc
-[out-file]                        : Dump Configuration: print fw configuration file for the given image.
+[out-file]                      : Dump Configuration: print fw configuration file for the given image.
 .TP
 .B
 dh
-[out-file]                        : Dump Hash: dump the hash if it is integrated in the FW image
+[out-file]                      : Dump Hash: dump the hash if it is integrated in the FW image
 .TP
 .B
 set_key
-[key]                        : Set/Update the HW access key which is used to enable/disable access to HW.
+[key]                           : Set/Update the HW access key which is used to enable/disable access to HW.
 The key can be provided in the command line or interactively typed after
 the command is given
 NOTE: The new key is activated only after the device is reset.
 .TP
 .B
 hw_access
-<enable|disable> [key]     : Enable/disable the access to the HW.
+<enable|disable> [key]          : Enable/disable the access to the HW.
 The key can be provided in the command line or interactively typed after
 the command is given
 .TP
 .B
 hw
-<query|set> [ATTR=VAL]            : Set/query HW info and flash attributes.
+query                           : Query HW info and flash attributes.
 .TP
 .B
 erase|e <addr>
@@ -405,11 +379,11 @@ erase|e <addr>
 .TP
 .B
 rw
-<addr>                            : Read one dword from flash
+<addr>                          : Read one dword from flash
 .TP
 .B
 ww
-<addr> <data>                     : Write one dword to flash
+<addr> <data>                   : Write one dword to flash
 .TP
 .B
 wwne
@@ -421,15 +395,15 @@ wbne
 .TP
 .B
 wb
-<data-file> <addr>                : Write a data block to flash.
+<data-file> <addr>              : Write a data block to flash.
 .TP
 .B
 rb
-<addr> <size> [out-file]          : Read  a data block from flash
+<addr> <size> [out-file]        : Read  a data block from flash
 .TP
 .B
 qrom
-: query rom in a given image.
+                                : query rom in a given image.
 .RE
 .PP
 
@@ -770,27 +744,13 @@ mstflint \fB-d\fP 03:00.0 hw_access enable
 .IP
 \fIDescription\fP: Access HW info and flash attributes.
 .IP
-\fICommand\fP: hw <query|set> [ATTR=VAL]
+\fICommand\fP: hw query
 .IP
 \fIParameters\fP: query: query HW info
 .IP
-set [ATTR=VAL]: set flash attribure
-.IP
-Supported attributes:
-.IP
-QuadEn: can be 0 or 1
-.IP
-Flash[0|1|2|3].WriteProtected can be:
-.IP
-<Top|Bottom>,<1|2|4|8|16|32|64>-<Sectors|SubSectors>
-.IP
-\fIExamples\fP:
+\fIExample\fP:
 .IP \(bu 4
 mstflint \fB-d\fP 03:00.0 hw query
-.IP \(bu 4
-mstflint \fB-d\fP 03:00.0 hw set QuadEn=1
-.IP \(bu 4
-mstflint \fB-d\fP 03:00.0 hw set Flash1.WriteProtected=Top,1-SubSectors
 
 ."***************************************************************************************
 
index 86043edbb7e51d134e49ecdf3e94f63d7cd4d2e1..d0d76d9d1d6eb68263001c4e0b09f5b1876e8a07 100644 (file)
 #--
 
 # Makefile.am -- Process this file with automake to produce Makefile.in
-INCLUDES= -I. -I$(top_srcdir)/include/mtcr_ul -I$(top_srcdir)/common -I$(top_srcdir)/tools_layouts
+INCLUDES= -I. -I$(top_srcdir)/include/mtcr_ul -I$(top_srcdir)/common -I$(top_srcdir)/tools_layouts -I$(top_srcdir)/reg_access
 
 AM_CFLAGS = -MD -pipe -Wall -W -DMST_UL -g ${MFLASH_INBAND_FLAG}
+
 noinst_LIBRARIES = libmflash.a
 
 libmflash_a_SOURCES =  mflash.c mflash.h\
-                       mflash_inband.c mflash_inband.h\
-                       packets_common.c packets_common.h\
-                       internal_packets.c internal_packets.h internal_packets_types.h\
-                       mflash_common.c mflash_common.h mflash_access_layer.c mflash_access_layer.h
-
+                       mflash_pack_layer.c mflash_pack_layer.h mflash_access_layer.c mflash_access_layer.h\
+                       mflash_types.h mlash_common_structs.h
diff --git a/mflash/internal_packets.c b/mflash/internal_packets.c
deleted file mode 100755 (executable)
index 120324f..0000000
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- * 
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- * 
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- * 
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-/***
- *** This file was generated at "Mon May 30 15:06:41 2011"
- *** by:
- ***    % csp_pack_unpack.pm ../xml_files/packets_st.csp
- ***/
-
-#include "packets_common.h"
-#include "internal_packets_types.h"
-#include "internal_packets.h"
-#include <stdlib.h>
-
-
-
-/*************************************/
-/* Name: mfpa
- * Size: 288 bits
- * Description: mfpa */
-
-
-u_int32_t mfpa_pack(struct mfpa *data_to_pack, u_int8_t *packed_buffer) {
-    push_to_buff(packed_buffer, 28, 4, data_to_pack->reserved0);
-    push_to_buff(packed_buffer, 26, 2, data_to_pack->fs);
-    push_to_buff(packed_buffer, 24, 2, data_to_pack->reserved1);
-    push_to_buff(packed_buffer, 23, 1, data_to_pack->p);
-    push_to_buff(packed_buffer, 0, 23, data_to_pack->reserved2);
-    push_to_buff(packed_buffer, 40, 24, data_to_pack->boot_address);
-    push_to_buff(packed_buffer, 32, 8, data_to_pack->reserved3);
-    push_to_buff(packed_buffer, 64, 64, data_to_pack->reserved4);
-    push_to_buff(packed_buffer, 156, 4, data_to_pack->flash_num);
-    push_to_buff(packed_buffer, 128, 28, data_to_pack->reserved5);
-    push_to_buff(packed_buffer, 168, 24, data_to_pack->jedec_id);
-    push_to_buff(packed_buffer, 160, 8, data_to_pack->reserved6);
-    push_to_buff(packed_buffer, 214, 10, data_to_pack->sector_size);
-    push_to_buff(packed_buffer, 208, 6, data_to_pack->reserved7);
-    push_to_buff(packed_buffer, 200, 8, data_to_pack->block_allighment);
-    push_to_buff(packed_buffer, 192, 8, data_to_pack->reserved8);
-    push_to_buff_32(packed_buffer, 224, data_to_pack->capability_mask);
-    push_to_buff_32(packed_buffer, 256, data_to_pack->reserved9);
-    return 36;
-}
-
-void mfpa_unpack(struct mfpa *unpacked_data, u_int8_t *buffer_to_unpack) {
-    unpacked_data->reserved0 = pop_from_buff(buffer_to_unpack, 28, 4);
-    unpacked_data->fs = pop_from_buff(buffer_to_unpack, 26, 2);
-    unpacked_data->reserved1 = pop_from_buff(buffer_to_unpack, 24, 2);
-    unpacked_data->p = pop_from_buff(buffer_to_unpack, 23, 1);
-    unpacked_data->reserved2 = pop_from_buff(buffer_to_unpack, 0, 23);
-    unpacked_data->boot_address = pop_from_buff(buffer_to_unpack, 40, 24);
-    unpacked_data->reserved3 = pop_from_buff(buffer_to_unpack, 32, 8);
-    unpacked_data->reserved4 = pop_from_buff(buffer_to_unpack, 64, 64);
-    unpacked_data->flash_num = pop_from_buff(buffer_to_unpack, 156, 4);
-    unpacked_data->reserved5 = pop_from_buff(buffer_to_unpack, 128, 28);
-    unpacked_data->jedec_id = pop_from_buff(buffer_to_unpack, 168, 24);
-    unpacked_data->reserved6 = pop_from_buff(buffer_to_unpack, 160, 8);
-    unpacked_data->sector_size = pop_from_buff(buffer_to_unpack, 214, 10);
-    unpacked_data->reserved7 = pop_from_buff(buffer_to_unpack, 208, 6);
-    unpacked_data->block_allighment = pop_from_buff(buffer_to_unpack, 200, 8);
-    unpacked_data->reserved8 = pop_from_buff(buffer_to_unpack, 192, 8);
-    unpacked_data->capability_mask = pop_from_buff_32(buffer_to_unpack, 224);
-    unpacked_data->reserved9 = pop_from_buff_32(buffer_to_unpack, 256);
-}
-
-void mfpa_dump(struct mfpa *data_to_print, FILE *out_port) {
-    fprintf(out_port, "mfpa::reserved0: "U32D_FMT"\n", data_to_print->reserved0);
-    fprintf(out_port, "mfpa::fs: "U32D_FMT"\n", data_to_print->fs);
-    fprintf(out_port, "mfpa::reserved1: "U32D_FMT"\n", data_to_print->reserved1);
-    fprintf(out_port, "mfpa::p: "U32D_FMT"\n", data_to_print->p);
-    fprintf(out_port, "mfpa::reserved2: "U32D_FMT"\n", data_to_print->reserved2);
-    fprintf(out_port, "mfpa::boot_address: "U32D_FMT"\n", data_to_print->boot_address);
-    fprintf(out_port, "mfpa::reserved3: "U32D_FMT"\n", data_to_print->reserved3);
-    fprintf(out_port, "mfpa::reserved4: "U32D_FMT"\n", data_to_print->reserved4);
-    fprintf(out_port, "mfpa::flash_num: "U32D_FMT"\n", data_to_print->flash_num);
-    fprintf(out_port, "mfpa::reserved5: "U32D_FMT"\n", data_to_print->reserved5);
-    fprintf(out_port, "mfpa::jedec_id: "U32D_FMT"\n", data_to_print->jedec_id);
-    fprintf(out_port, "mfpa::reserved6: "U32D_FMT"\n", data_to_print->reserved6);
-    fprintf(out_port, "mfpa::sector_size: "U32D_FMT"\n", data_to_print->sector_size);
-    fprintf(out_port, "mfpa::reserved7: "U32D_FMT"\n", data_to_print->reserved7);
-    fprintf(out_port, "mfpa::block_allighment: "U32D_FMT"\n", data_to_print->block_allighment);
-    fprintf(out_port, "mfpa::reserved8: "U32D_FMT"\n", data_to_print->reserved8);
-    fprintf(out_port, "mfpa::capability_mask: "U32D_FMT"\n", data_to_print->capability_mask);
-    fprintf(out_port, "mfpa::reserved9: "U32D_FMT"\n", data_to_print->reserved9);
-}
-
-
-/**************************************/
-/* Name: mfbe
- * Size: 96 bits
- * Description: mfbe */
-
-
-u_int32_t mfbe_pack(struct mfbe *data_to_pack, u_int8_t *packed_buffer) {
-    push_to_buff(packed_buffer, 28, 4, data_to_pack->reserved0);
-    push_to_buff(packed_buffer, 26, 2, data_to_pack->fs);
-    push_to_buff(packed_buffer, 24, 2, data_to_pack->reserved1);
-    push_to_buff(packed_buffer, 23, 1, data_to_pack->p);
-    push_to_buff(packed_buffer, 0, 23, data_to_pack->reserved2);
-    push_to_buff_32(packed_buffer, 32, data_to_pack->reserved3);
-    push_to_buff(packed_buffer, 72, 24, data_to_pack->address);
-    push_to_buff(packed_buffer, 64, 8, data_to_pack->reserved4);
-    return 12;
-}
-
-void mfbe_unpack(struct mfbe *unpacked_data, u_int8_t *buffer_to_unpack) {
-    unpacked_data->reserved0 = pop_from_buff(buffer_to_unpack, 28, 4);
-    unpacked_data->fs = pop_from_buff(buffer_to_unpack, 26, 2);
-    unpacked_data->reserved1 = pop_from_buff(buffer_to_unpack, 24, 2);
-    unpacked_data->p = pop_from_buff(buffer_to_unpack, 23, 1);
-    unpacked_data->reserved2 = pop_from_buff(buffer_to_unpack, 0, 23);
-    unpacked_data->reserved3 = pop_from_buff_32(buffer_to_unpack, 32);
-    unpacked_data->address = pop_from_buff(buffer_to_unpack, 72, 24);
-    unpacked_data->reserved4 = pop_from_buff(buffer_to_unpack, 64, 8);
-}
-
-void mfbe_dump(struct mfbe *data_to_print, FILE *out_port) {
-    fprintf(out_port, "mfbe::reserved0: "U32D_FMT"\n", data_to_print->reserved0);
-    fprintf(out_port, "mfbe::fs: "U32D_FMT"\n", data_to_print->fs);
-    fprintf(out_port, "mfbe::reserved1: "U32D_FMT"\n", data_to_print->reserved1);
-    fprintf(out_port, "mfbe::p: "U32D_FMT"\n", data_to_print->p);
-    fprintf(out_port, "mfbe::reserved2: "U32D_FMT"\n", data_to_print->reserved2);
-    fprintf(out_port, "mfbe::reserved3: "U32D_FMT"\n", data_to_print->reserved3);
-    fprintf(out_port, "mfbe::address: "U32D_FMT"\n", data_to_print->address);
-    fprintf(out_port, "mfbe::reserved4: "U32D_FMT"\n", data_to_print->reserved4);
-}
-
-
-
-
-/*************************************/
-/* Name: OperationTlv
- * Size: 128 bits
- * Description:  */
-
-
-u_int32_t OperationTlv_pack(struct OperationTlv *data_to_pack, u_int8_t *packed_buffer) {
-    push_to_buff(packed_buffer, 24, 8, data_to_pack->reserved0);
-    push_to_buff(packed_buffer, 17, 7, data_to_pack->status);
-    push_to_buff(packed_buffer, 16, 1, data_to_pack->dr);
-    push_to_buff(packed_buffer, 5, 11, data_to_pack->len);
-    push_to_buff(packed_buffer, 0, 5, data_to_pack->Type);
-    push_to_buff(packed_buffer, 56, 8, data_to_pack->class);
-    push_to_buff(packed_buffer, 49, 7, data_to_pack->method);
-    push_to_buff(packed_buffer, 48, 1, data_to_pack->r);
-    push_to_buff(packed_buffer, 32, 16, data_to_pack->register_id);
-    push_to_buff_64(packed_buffer, 64, data_to_pack->tid);
-    return 16;
-}
-
-void OperationTlv_unpack(struct OperationTlv *unpacked_data, u_int8_t *buffer_to_unpack) {
-    unpacked_data->reserved0 = pop_from_buff(buffer_to_unpack, 24, 8);
-    unpacked_data->status = pop_from_buff(buffer_to_unpack, 17, 7);
-    unpacked_data->dr = pop_from_buff(buffer_to_unpack, 16, 1);
-    unpacked_data->len = pop_from_buff(buffer_to_unpack, 5, 11);
-    unpacked_data->Type = pop_from_buff(buffer_to_unpack, 0, 5);
-    unpacked_data->class = pop_from_buff(buffer_to_unpack, 56, 8);
-    unpacked_data->method = pop_from_buff(buffer_to_unpack, 49, 7);
-    unpacked_data->r = pop_from_buff(buffer_to_unpack, 48, 1);
-    unpacked_data->register_id = pop_from_buff(buffer_to_unpack, 32, 16);
-    unpacked_data->tid = pop_from_buff_64(buffer_to_unpack, 64);
-}
-
-void OperationTlv_dump(struct OperationTlv *data_to_print, FILE *out_port) {
-    fprintf(out_port, "OperationTlv::reserved0: "U32D_FMT"\n", data_to_print->reserved0);
-    fprintf(out_port, "OperationTlv::status: "U32D_FMT"\n", data_to_print->status);
-    fprintf(out_port, "OperationTlv::dr: "U32D_FMT"\n", data_to_print->dr);
-    fprintf(out_port, "OperationTlv::len: "U32D_FMT"\n", data_to_print->len);
-    fprintf(out_port, "OperationTlv::Type: "U32D_FMT"\n", data_to_print->Type);
-    fprintf(out_port, "OperationTlv::class: "U32D_FMT"\n", data_to_print->class);
-    fprintf(out_port, "OperationTlv::method: "U32D_FMT"\n", data_to_print->method);
-    fprintf(out_port, "OperationTlv::r: "U32D_FMT"\n", data_to_print->r);
-    fprintf(out_port, "OperationTlv::register_id: "U32D_FMT"\n", data_to_print->register_id);
-    fprintf(out_port, "OperationTlv::tid: "U64D_FMT"\n", data_to_print->tid);
-}
-
-/*************************************/
-/* Name: reg_tlv
- * Size: 32 bits
- * Description: reg_tlv */
-
-
-u_int32_t reg_tlv_pack(struct reg_tlv *data_to_pack, u_int8_t *packed_buffer) {
-    push_to_buff(packed_buffer, 16, 16, data_to_pack->reserved0);
-    push_to_buff(packed_buffer, 5, 11, data_to_pack->len);
-    push_to_buff(packed_buffer, 0, 5, data_to_pack->Type);
-    return 4;
-}
-
-void reg_tlv_unpack(struct reg_tlv *unpacked_data, u_int8_t *buffer_to_unpack) {
-    unpacked_data->reserved0 = pop_from_buff(buffer_to_unpack, 16, 16);
-    unpacked_data->len = pop_from_buff(buffer_to_unpack, 5, 11);
-    unpacked_data->Type = pop_from_buff(buffer_to_unpack, 0, 5);
-}
-
-void reg_tlv_dump(struct reg_tlv *data_to_print, FILE *out_port) {
-    fprintf(out_port, "reg_tlv::reserved0: "U32D_FMT"\n", data_to_print->reserved0);
-    fprintf(out_port, "reg_tlv::len: "U32D_FMT"\n", data_to_print->len);
-    fprintf(out_port, "reg_tlv::Type: "U32D_FMT"\n", data_to_print->Type);
-}
-
-/*************************************/
-/* Name: mfba_mad
- * Size: 352 bits
- * Description: mfba_mad */
-/*
-
-u_int32_t mfba_mad_pack(struct mfba_mad *data_to_pack, u_int8_t *packed_buffer) {
-    push_to_buff(packed_buffer, 28, 4, data_to_pack->reserved0);
-    push_to_buff(packed_buffer, 26, 2, data_to_pack->fs);
-    push_to_buff(packed_buffer, 24, 2, data_to_pack->reserved1);
-    push_to_buff(packed_buffer, 23, 1, data_to_pack->p);
-    push_to_buff(packed_buffer, 0, 23, data_to_pack->reserved2);
-    push_to_buff(packed_buffer, 55, 9, data_to_pack->size);
-    push_to_buff(packed_buffer, 32, 23, data_to_pack->reserved3);
-    push_to_buff(packed_buffer, 72, 24, data_to_pack->address);
-    push_to_buff(packed_buffer, 64, 8, data_to_pack->reserved4);
-    push_to_buff_32(packed_buffer, 96, data_to_pack->data[0]);
-    push_to_buff_32(packed_buffer, 128, data_to_pack->data[1]);
-    push_to_buff_32(packed_buffer, 160, data_to_pack->data[2]);
-    push_to_buff_32(packed_buffer, 192, data_to_pack->data[3]);
-    push_to_buff_32(packed_buffer, 224, data_to_pack->data[4]);
-    push_to_buff_32(packed_buffer, 256, data_to_pack->data[5]);
-    push_to_buff_32(packed_buffer, 288, data_to_pack->data[6]);
-    push_to_buff_32(packed_buffer, 320, data_to_pack->data[7]);
-    return 44;
-}
-
-void mfba_mad_unpack(struct mfba_mad *unpacked_data, u_int8_t *buffer_to_unpack) {
-    unpacked_data->reserved0 = pop_from_buff(buffer_to_unpack, 28, 4);
-    unpacked_data->fs = pop_from_buff(buffer_to_unpack, 26, 2);
-    unpacked_data->reserved1 = pop_from_buff(buffer_to_unpack, 24, 2);
-    unpacked_data->p = pop_from_buff(buffer_to_unpack, 23, 1);
-    unpacked_data->reserved2 = pop_from_buff(buffer_to_unpack, 0, 23);
-    unpacked_data->size = pop_from_buff(buffer_to_unpack, 55, 9);
-    unpacked_data->reserved3 = pop_from_buff(buffer_to_unpack, 32, 23);
-    unpacked_data->address = pop_from_buff(buffer_to_unpack, 72, 24);
-    unpacked_data->reserved4 = pop_from_buff(buffer_to_unpack, 64, 8);
-    unpacked_data->data[0] = pop_from_buff_32(buffer_to_unpack, 96);
-    unpacked_data->data[1] = pop_from_buff_32(buffer_to_unpack, 128);
-    unpacked_data->data[2] = pop_from_buff_32(buffer_to_unpack, 160);
-    unpacked_data->data[3] = pop_from_buff_32(buffer_to_unpack, 192);
-    unpacked_data->data[4] = pop_from_buff_32(buffer_to_unpack, 224);
-    unpacked_data->data[5] = pop_from_buff_32(buffer_to_unpack, 256);
-    unpacked_data->data[6] = pop_from_buff_32(buffer_to_unpack, 288);
-    unpacked_data->data[7] = pop_from_buff_32(buffer_to_unpack, 320);
-}
-*/
-
-u_int32_t mfba_mad_pack(struct mfba_mad *data_to_pack, u_int8_t *packed_buffer) {
-    push_to_buff(packed_buffer, 28, 4, data_to_pack->reserved0);
-    push_to_buff(packed_buffer, 26, 2, data_to_pack->fs);
-    push_to_buff(packed_buffer, 24, 2, data_to_pack->reserved1);
-    push_to_buff(packed_buffer, 23, 1, data_to_pack->p);
-    push_to_buff(packed_buffer, 0, 23, data_to_pack->reserved2);
-    push_to_buff(packed_buffer, 55, 9, data_to_pack->size);
-    push_to_buff(packed_buffer, 32, 23, data_to_pack->reserved3);
-    push_to_buff(packed_buffer, 72, 24, data_to_pack->address);
-    push_to_buff(packed_buffer, 64, 8, data_to_pack->reserved4);
-    push_to_buff_32(packed_buffer, 96, data_to_pack->data[0]);
-    push_to_buff_32(packed_buffer, 128, data_to_pack->data[1]);
-    push_to_buff_32(packed_buffer, 160, data_to_pack->data[2]);
-    push_to_buff_32(packed_buffer, 192, data_to_pack->data[3]);
-    push_to_buff_32(packed_buffer, 224, data_to_pack->data[4]);
-    push_to_buff_32(packed_buffer, 256, data_to_pack->data[5]);
-    push_to_buff_32(packed_buffer, 288, data_to_pack->data[6]);
-    push_to_buff_32(packed_buffer, 320, data_to_pack->data[7]);
-    push_to_buff_32(packed_buffer, 352, data_to_pack->data[8]);
-    push_to_buff_32(packed_buffer, 384, data_to_pack->data[9]);
-    push_to_buff_32(packed_buffer, 416 , data_to_pack->data[10]);
-    push_to_buff_32(packed_buffer, 448, data_to_pack->data[11]);
-    push_to_buff_32(packed_buffer, 480, data_to_pack->data[12]);
-    push_to_buff_32(packed_buffer, 512, data_to_pack->data[13]);
-    push_to_buff_32(packed_buffer, 544, data_to_pack->data[14]);
-    push_to_buff_32(packed_buffer, 576, data_to_pack->data[15]);
-    push_to_buff_32(packed_buffer, 608, data_to_pack->data[16]);
-    push_to_buff_32(packed_buffer, 640, data_to_pack->data[17]);
-    push_to_buff_32(packed_buffer, 672, data_to_pack->data[18]);
-    push_to_buff_32(packed_buffer, 704, data_to_pack->data[19]);
-    push_to_buff_32(packed_buffer, 736, data_to_pack->data[20]);
-    push_to_buff_32(packed_buffer, 768, data_to_pack->data[21]);
-    push_to_buff_32(packed_buffer, 800, data_to_pack->data[22]);
-    push_to_buff_32(packed_buffer, 832, data_to_pack->data[23]);
-    push_to_buff_32(packed_buffer, 864, data_to_pack->data[24]);
-    push_to_buff_32(packed_buffer, 896, data_to_pack->data[25]);
-    push_to_buff_32(packed_buffer, 928, data_to_pack->data[26]);
-    push_to_buff_32(packed_buffer, 960, data_to_pack->data[27]);
-    push_to_buff_32(packed_buffer, 992, data_to_pack->data[28]);
-    push_to_buff_32(packed_buffer, 1024, data_to_pack->data[29]);
-    push_to_buff_32(packed_buffer, 1056, data_to_pack->data[30]);
-    push_to_buff_32(packed_buffer, 1088, data_to_pack->data[31]);
-    return 140;
-}
-
-void mfba_mad_unpack(struct mfba_mad *unpacked_data, u_int8_t *buffer_to_unpack) {
-    unpacked_data->reserved0 = pop_from_buff(buffer_to_unpack, 28, 4);
-    unpacked_data->fs = pop_from_buff(buffer_to_unpack, 26, 2);
-    unpacked_data->reserved1 = pop_from_buff(buffer_to_unpack, 24, 2);
-    unpacked_data->p = pop_from_buff(buffer_to_unpack, 23, 1);
-    unpacked_data->reserved2 = pop_from_buff(buffer_to_unpack, 0, 23);
-    unpacked_data->size = pop_from_buff(buffer_to_unpack, 55, 9);
-    unpacked_data->reserved3 = pop_from_buff(buffer_to_unpack, 32, 23);
-    unpacked_data->address = pop_from_buff(buffer_to_unpack, 72, 24);
-    unpacked_data->reserved4 = pop_from_buff(buffer_to_unpack, 64, 8);
-    unpacked_data->data[0] = pop_from_buff_32(buffer_to_unpack, 96);
-    unpacked_data->data[1] = pop_from_buff_32(buffer_to_unpack, 128);
-    unpacked_data->data[2] = pop_from_buff_32(buffer_to_unpack, 160);
-    unpacked_data->data[3] = pop_from_buff_32(buffer_to_unpack, 192);
-    unpacked_data->data[4] = pop_from_buff_32(buffer_to_unpack, 224);
-    unpacked_data->data[5] = pop_from_buff_32(buffer_to_unpack, 256);
-    unpacked_data->data[6] = pop_from_buff_32(buffer_to_unpack, 288);
-    unpacked_data->data[7] = pop_from_buff_32(buffer_to_unpack, 320);
-    unpacked_data->data[8] = pop_from_buff_32(buffer_to_unpack, 352);
-    unpacked_data->data[9] = pop_from_buff_32(buffer_to_unpack, 384);
-    unpacked_data->data[10] = pop_from_buff_32(buffer_to_unpack, 416);
-    unpacked_data->data[11] = pop_from_buff_32(buffer_to_unpack, 448);
-    unpacked_data->data[12] = pop_from_buff_32(buffer_to_unpack, 480);
-    unpacked_data->data[13] = pop_from_buff_32(buffer_to_unpack, 512);
-    unpacked_data->data[14] = pop_from_buff_32(buffer_to_unpack, 544);
-    unpacked_data->data[15] = pop_from_buff_32(buffer_to_unpack, 576);
-    unpacked_data->data[16] = pop_from_buff_32(buffer_to_unpack, 608);
-    unpacked_data->data[17] = pop_from_buff_32(buffer_to_unpack, 640);
-    unpacked_data->data[18] = pop_from_buff_32(buffer_to_unpack, 672);
-    unpacked_data->data[19] = pop_from_buff_32(buffer_to_unpack, 704);
-    unpacked_data->data[20] = pop_from_buff_32(buffer_to_unpack, 736);
-    unpacked_data->data[21] = pop_from_buff_32(buffer_to_unpack, 768);
-    unpacked_data->data[22] = pop_from_buff_32(buffer_to_unpack, 800);
-    unpacked_data->data[23] = pop_from_buff_32(buffer_to_unpack, 832);
-    unpacked_data->data[24] = pop_from_buff_32(buffer_to_unpack, 864);
-    unpacked_data->data[25] = pop_from_buff_32(buffer_to_unpack, 896);
-    unpacked_data->data[26] = pop_from_buff_32(buffer_to_unpack, 928);
-    unpacked_data->data[27] = pop_from_buff_32(buffer_to_unpack, 960);
-    unpacked_data->data[28] = pop_from_buff_32(buffer_to_unpack, 992);
-    unpacked_data->data[29] = pop_from_buff_32(buffer_to_unpack, 1024);
-    unpacked_data->data[30] = pop_from_buff_32(buffer_to_unpack, 1056);
-    unpacked_data->data[31] = pop_from_buff_32(buffer_to_unpack, 1088);
-}
-
-void mfba_mad_dump(struct mfba_mad *data_to_print, FILE *out_port) {
-    fprintf(out_port, "mfba_mad::reserved0: "U32D_FMT"\n", data_to_print->reserved0);
-    fprintf(out_port, "mfba_mad::fs: "U32D_FMT"\n", data_to_print->fs);
-    fprintf(out_port, "mfba_mad::reserved1: "U32D_FMT"\n", data_to_print->reserved1);
-    fprintf(out_port, "mfba_mad::p: "U32D_FMT"\n", data_to_print->p);
-    fprintf(out_port, "mfba_mad::reserved2: "U32D_FMT"\n", data_to_print->reserved2);
-    fprintf(out_port, "mfba_mad::size: "U32D_FMT"\n", data_to_print->size);
-    fprintf(out_port, "mfba_mad::reserved3: "U32D_FMT"\n", data_to_print->reserved3);
-    fprintf(out_port, "mfba_mad::address: "U32H_FMT"\n", data_to_print->address);
-    fprintf(out_port, "mfba_mad::reserved4: "U32D_FMT"\n", data_to_print->reserved4);
-    fprintf(out_port, "mfba_mad::data[0]: "U32H_FMT"\n", data_to_print->data[0]);
-    fprintf(out_port, "mfba_mad::data[1]: "U32H_FMT"\n", data_to_print->data[1]);
-    fprintf(out_port, "mfba_mad::data[2]: "U32H_FMT"\n", data_to_print->data[2]);
-    fprintf(out_port, "mfba_mad::data[3]: "U32H_FMT"\n", data_to_print->data[3]);
-    fprintf(out_port, "mfba_mad::data[4]: "U32H_FMT"\n", data_to_print->data[4]);
-    fprintf(out_port, "mfba_mad::data[5]: "U32H_FMT"\n", data_to_print->data[5]);
-    fprintf(out_port, "mfba_mad::data[6]: "U32H_FMT"\n", data_to_print->data[6]);
-    fprintf(out_port, "mfba_mad::data[7]: "U32H_FMT"\n", data_to_print->data[7]);
-    fprintf(out_port, "mfba_mad::data[8]: "U32H_FMT"\n", data_to_print->data[8]);
-    fprintf(out_port, "mfba_mad::data[9]: "U32H_FMT"\n", data_to_print->data[9]);
-    fprintf(out_port, "mfba_mad::data[10]: "U32H_FMT"\n", data_to_print->data[10]);
-    fprintf(out_port, "mfba_mad::data[11]: "U32H_FMT"\n", data_to_print->data[11]);
-    fprintf(out_port, "mfba_mad::data[12]: "U32H_FMT"\n", data_to_print->data[12]);
-    fprintf(out_port, "mfba_mad::data[13]: "U32H_FMT"\n", data_to_print->data[13]);
-    fprintf(out_port, "mfba_mad::data[14]: "U32H_FMT"\n", data_to_print->data[14]);
-    fprintf(out_port, "mfba_mad::data[15]: "U32H_FMT"\n", data_to_print->data[15]);
-    fprintf(out_port, "mfba_mad::data[16]: "U32H_FMT"\n", data_to_print->data[16]);
-    fprintf(out_port, "mfba_mad::data[17]: "U32H_FMT"\n", data_to_print->data[17]);
-    fprintf(out_port, "mfba_mad::data[18]: "U32H_FMT"\n", data_to_print->data[18]);
-    fprintf(out_port, "mfba_mad::data[19]: "U32H_FMT"\n", data_to_print->data[19]);
-    fprintf(out_port, "mfba_mad::data[20]: "U32H_FMT"\n", data_to_print->data[20]);
-    fprintf(out_port, "mfba_mad::data[21]: "U32H_FMT"\n", data_to_print->data[21]);
-    fprintf(out_port, "mfba_mad::data[22]: "U32H_FMT"\n", data_to_print->data[22]);
-    fprintf(out_port, "mfba_mad::data[23]: "U32H_FMT"\n", data_to_print->data[23]);
-    fprintf(out_port, "mfba_mad::data[24]: "U32H_FMT"\n", data_to_print->data[24]);
-    fprintf(out_port, "mfba_mad::data[25]: "U32H_FMT"\n", data_to_print->data[25]);
-    fprintf(out_port, "mfba_mad::data[26]: "U32H_FMT"\n", data_to_print->data[26]);
-    fprintf(out_port, "mfba_mad::data[27]: "U32H_FMT"\n", data_to_print->data[27]);
-    fprintf(out_port, "mfba_mad::data[28]: "U32H_FMT"\n", data_to_print->data[28]);
-    fprintf(out_port, "mfba_mad::data[29]: "U32H_FMT"\n", data_to_print->data[29]);
-    fprintf(out_port, "mfba_mad::data[30]: "U32H_FMT"\n", data_to_print->data[30]);
-    fprintf(out_port, "mfba_mad::data[31]: "U32H_FMT"\n", data_to_print->data[31]);
-}
diff --git a/mflash/internal_packets.h b/mflash/internal_packets.h
deleted file mode 100755 (executable)
index 48119bb..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- * 
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- * 
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- * 
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-/***
- *** This file was generated at "Mon May 30 15:06:41 2011"
- *** by:
- ***    % csp_pack_unpack.pm ../xml_files/packets_st.csp
- ***/
-
-#ifndef internal_packets_functions_H
-#define internal_packets_functions_H
-
-#include "internal_packets_types.h"
-#include <stdlib.h>
-
-/*************************************/
-/* Name: mfbe
- * Size: 96 bits
- * Description: mfbe */
-
-u_int32_t mfbe_pack(struct mfbe *data_to_pack, u_int8_t *packed_buffer);
-void mfbe_unpack(struct mfbe *unpacked_data, u_int8_t *buffer_to_unpack);
-void mfbe_dump(struct mfbe *data_to_print, FILE *out_port);
-
-
-/*************************************/
-/* Name: mfpa
- * Size: 256 bits
- * Description: mfpa */
-
-u_int32_t mfpa_pack(struct mfpa *data_to_pack, u_int8_t *packed_buffer);
-void mfpa_unpack(struct mfpa *unpacked_data, u_int8_t *buffer_to_unpack);
-void mfpa_dump(struct mfpa *data_to_print, FILE *out_port);
-
-
-/*************************************/
-/* Name: reg_tlv
- * Size: 32 bits
- * Description: reg_tlv */
-
-u_int32_t reg_tlv_pack(struct reg_tlv *data_to_pack, u_int8_t *packed_buffer);
-void reg_tlv_unpack(struct reg_tlv *unpacked_data, u_int8_t *buffer_to_unpack);
-void reg_tlv_dump(struct reg_tlv *data_to_print, FILE *out_port);
-
-/*************************************/
-/* Name: mfba_mad
- * Size: 352 bits
- * Description: mfba_mad */
-
-u_int32_t mfba_mad_pack(struct mfba_mad *data_to_pack, u_int8_t *packed_buffer);
-void mfba_mad_unpack(struct mfba_mad *unpacked_data, u_int8_t *buffer_to_unpack);
-void mfba_mad_dump(struct mfba_mad *data_to_print, FILE *out_port);
-
-
-/*************************************/
-/* Name: OperationTlv
- * Size: 128 bits
- * Description:  */
-
-u_int32_t OperationTlv_pack(struct OperationTlv *data_to_pack, u_int8_t *packed_buffer);
-void OperationTlv_unpack(struct OperationTlv *unpacked_data, u_int8_t *buffer_to_unpack);
-void OperationTlv_dump(struct OperationTlv *data_to_print, FILE *out_port);
-
-
-#endif /* internal_packets_functions_H */
diff --git a/mflash/internal_packets_types.h b/mflash/internal_packets_types.h
deleted file mode 100755 (executable)
index 90b7c51..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- * 
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- * 
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- * 
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-/***
- *** This file was generated at "Mon May 30 15:06:41 2011"
- *** by:
- ***    % csp_pack_unpack.pm ../xml_files/packets_st.csp
- ***/
-
-#ifndef internal_packets_structs_H
-#define internal_packets_structs_H
-
-#include <stdlib.h>
-#include <sys/types.h>
-
-/*************************************/
-/* Name: mfbe
- * Size: 96 bits
- * Description: mfbe */
-
-struct mfbe {
-    u_int8_t    reserved0;    /* bit_offset:0 */    /* element_size: 4 */
-    u_int8_t    fs;    /* bit_offset:4 */    /* element_size: 2 */    /* Flash Select */
-    u_int8_t    reserved1;    /* bit_offset:6 */    /* element_size: 2 */
-    u_int8_t    p;    /* bit_offset:8 */    /* element_size: 1 */    /* Parallel */
-    u_int32_t   reserved2;    /* bit_offset:9 */    /* element_size: 23 */
-    u_int32_t   reserved3;    /* bit_offset:32 */    /* element_size: 32 */
-    u_int32_t   address;    /* bit_offset:64 */    /* element_size: 24 */    /* address in bytes */
-    u_int8_t    reserved4;    /* bit_offset:88 */    /* element_size: 8 */
-};
-
-
-/*************************************/
-/* Name: mfba
- * Size: 2144 bits
- * Description: mfba */
-
-struct mfba {
-    u_int8_t    reserved0;    /* bit_offset:0 */    /* element_size: 4 */
-    u_int8_t    fs;    /* bit_offset:4 */    /* element_size: 2 */    /* Flash Select */
-    u_int8_t    reserved1;    /* bit_offset:6 */    /* element_size: 2 */
-    u_int8_t    p;    /* bit_offset:8 */    /* element_size: 1 */    /* Parallel */
-    u_int32_t   reserved2;    /* bit_offset:9 */    /* element_size: 23 */
-    u_int16_t   size;    /* bit_offset:32 */    /* element_size: 9 */    /* Transaction size */
-    u_int32_t   reserved3;    /* bit_offset:41 */    /* element_size: 23 */
-    u_int32_t   address;    /* bit_offset:64 */    /* element_size: 24 */    /* address in bytes */
-    u_int8_t    reserved4;    /* bit_offset:88 */    /* element_size: 8 */
-    u_int32_t   data[64];    /* bit_offset:96 */    /* element_size: 32 */    /* data */
-};
-
-
-/*************************************/
-/* Name: mfpa
- * Size: 288 bits
- * Description: mfpa */
-
-struct mfpa {
-    u_int8_t    reserved0;    /* bit_offset:0 */    /* element_size: 4 */
-    u_int8_t    fs;    /* bit_offset:4 */    /* element_size: 2 */    /* Flash Select */
-    u_int8_t    reserved1;    /* bit_offset:6 */    /* element_size: 2 */
-    u_int8_t    p;    /* bit_offset:8 */    /* element_size: 1 */    /* Parallel */
-    u_int32_t   reserved2;    /* bit_offset:9 */    /* element_size: 23 */
-    u_int32_t   boot_address;    /* bit_offset:32 */    /* element_size: 24 */    /* address in bytes */
-    u_int8_t    reserved3;    /* bit_offset:56 */    /* element_size: 8 */
-    u_int32_t   reserved4;    /* bit_offset:64 */    /* element_size: 64 */
-    u_int8_t    flash_num;    /* bit_offset:128 */    /* element_size: 4 */    /* number of flash devices connected */
-    u_int32_t   reserved5;    /* bit_offset:132 */    /* element_size: 28 */
-    u_int32_t   jedec_id;    /* bit_offset:160 */    /* element_size: 24 */    /* Flash JEDEC ID */
-    u_int8_t    reserved6;    /* bit_offset:184 */    /* element_size: 8 */
-    u_int16_t   sector_size;    /* bit_offset:192 */    /* element_size: 10 */    /* Flash sectore size */
-    u_int8_t    reserved7;    /* bit_offset:202 */    /* element_size: 6 */
-    u_int8_t    block_allighment;    /* bit_offset:208 */    /* element_size: 8 */
-    u_int8_t    reserved8;    /* bit_offset:216 */    /* element_size: 8 */
-    u_int32_t   capability_mask;    /* bit_offset:224 */    /* element_size: 32 */    /* capability mask ;bit 0:Parallel flash Support;else:Reserved */
-    u_int32_t   reserved9;    /* bit_offset:256 */    /* element_size: 32 */
-};
-
-
-
-/*************************************/
-/* Name: REG_Mfpa
- * Size: 384 bits
- * Description:  */
-
-struct REG_Mfpa {
-    u_int16_t  reserved0;    /* bit_offset:0 */    /* element_size: 16 */
-    u_int16_t  len;    /* bit_offset:16 */    /* element_size: 11 */
-    u_int8_t   type;    /* bit_offset:27 */    /* element_size: 5 */
-    u_int8_t   reserved1;    /* bit_offset:32 */    /* element_size: 4 */
-    u_int8_t   fs;    /* bit_offset:36 */    /* element_size: 2 */    /* Flash Select */
-    u_int8_t   reserved2;    /* bit_offset:38 */    /* element_size: 2 */
-    u_int8_t   p;    /* bit_offset:40 */    /* element_size: 1 */    /* parallel - Index */
-    u_int32_t  reserved3;    /* bit_offset:41 */    /* element_size: 23 */
-    u_int32_t  boot_address;    /* bit_offset:64 */    /* element_size: 24 */    /* Boot address points to the FW image in the flash - R/W */
-    u_int8_t   reserved4;    /* bit_offset:88 */    /* element_size: 8 */
-    u_int32_t  reserved5;    /* bit_offset:96 */    /* element_size: 64 */
-    u_int8_t   flash_num;    /* bit_offset:160 */    /* element_size: 4 */    /* Number of Flash Devices connected */
-    u_int32_t  reserved6;    /* bit_offset:164 */    /* element_size: 28 */
-    u_int32_t  jedec_id;    /* bit_offset:192 */    /* element_size: 24 */    /* Flash JEDEC ID */
-    u_int8_t   reserved7;    /* bit_offset:216 */    /* element_size: 8 */
-    u_int16_t  sector_size;    /* bit_offset:224 */    /* element_size: 10 */    /* Flash Sector Size */
-    u_int8_t   reserved8;    /* bit_offset:234 */    /* element_size: 6 */
-    u_int8_t   block_allignment;    /* bit_offset:240 */    /* element_size: 8 */    /* Required allignment for block access */
-    u_int8_t   reserved9;    /* bit_offset:248 */    /* element_size: 8 */
-    u_int32_t  capcability_mask;    /* bit_offset:256 */    /* element_size: 32 */
-    u_int32_t  reserved10;    /* bit_offset:288 */    /* element_size: 96 */
-};
-
-/*************************************/
-/* Name: reg_tlv
- * Size: 32 bits
- * Description: reg_tlv */
-
-struct reg_tlv {
-    u_int16_t   reserved0;    /* bit_offset:0 */    /* element_size: 16 */
-    u_int16_t   len;    /* bit_offset:16 */    /* element_size: 11 */
-    u_int8_t    Type;    /* bit_offset:27 */    /* element_size: 5 */    /* TX - 0, RX - ignore */
-};
-
-/*************************************/
-/* Name: mfba_mad
- * Size: 352 bits
- * Description: mfba_mad */
-
-struct mfba_mad {
-    u_int8_t    reserved0;    /* bit_offset:0 */    /* element_size: 4 */
-    u_int8_t    fs;    /* bit_offset:4 */    /* element_size: 2 */    /* Flash Select */
-    u_int8_t    reserved1;    /* bit_offset:6 */    /* element_size: 2 */
-    u_int8_t    p;    /* bit_offset:8 */    /* element_size: 1 */    /* Parallel */
-    u_int32_t   reserved2;    /* bit_offset:9 */    /* element_size: 23 */
-    u_int16_t   size;    /* bit_offset:32 */    /* element_size: 9 */    /* Transaction size */
-    u_int32_t   reserved3;    /* bit_offset:41 */    /* element_size: 23 */
-    u_int32_t   address;    /* bit_offset:64 */    /* element_size: 24 */    /* address in bytes */
-    u_int8_t    reserved4;    /* bit_offset:88 */    /* element_size: 8 */
-    u_int32_t   data[64];    /* bit_offset:96 */    /* element_size: 32 */    /* data */
-};
-
-
-/*************************************/
-/* Name: OperationTlv
- * Size: 128 bits
- * Description:  */
-
-struct OperationTlv {
-    u_int8_t   reserved0;    /* bit_offset:0 */    /* element_size: 8 */
-    u_int8_t   status;    /* bit_offset:8 */    /* element_size: 7 */
-    u_int8_t   dr;    /* bit_offset:15 */    /* element_size: 1 */
-    u_int16_t  len;    /* bit_offset:16 */    /* element_size: 11 */
-    u_int8_t   Type;    /* bit_offset:27 */    /* element_size: 5 */    /* TX - 0, RX - ignore */
-    u_int8_t   class;    /* bit_offset:32 */    /* element_size: 8 */
-    u_int8_t   method;    /* bit_offset:40 */    /* element_size: 7 */
-    u_int8_t   r;    /* bit_offset:47 */    /* element_size: 1 */
-    u_int16_t  register_id;    /* bit_offset:48 */    /* element_size: 16 */
-    u_int64_t  tid;    /* bit_offset:64 */    /* element_size: 64 */
-};
-/*************************************/
-/* Name: SMP_RegAccessMfpa
- * Size: 512 bits
- * Description:  */
-
-struct SMP_RegAccessMfpa {
-    struct OperationTlv        OperationTlv;    /* bit_offset:0 */    /* element_size: 128 */
-    struct REG_Mfpa    REG_Mfpa;    /* bit_offset:128 */    /* element_size: 384 */
-};
-
-#endif /* internal_packets_structs_H */
index 9d10bc5b19f9c75a450525b8646dd3c553e6ab0e..05220f862e6d4e59ee66fa9816e475f7ea1552cd 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  */
 
 
-
+// TODO: remove all commented defines and ifdefs of __be32.... or __cpu_to_be32... etc (they are taken from compatibility.h now)
 #ifdef IRISC
 #include <tavor_mac.h>
-#define __cpu_to_be32(val) (val)
+//#define __cpu_to_be32(val) (val)
 #define NULL 0
 
 #else
 
-#include <mtcr.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
-#include <unistd.h>
-
-#define ARR_SIZE(arr) sizeof(arr)/sizeof(arr[0])
 
-// Bit Slicing macros
-#define ONES32(size)                    ((size)?(0xffffffff>>(32-(size))):0)
-#define MASK32(offset,size)             (ONES32(size)<<(offset))
+#include "bit_slice.h"
+#include "mtcr.h"
 
-#define EXTRACT_C(source,offset,size)   ((((unsigned)(source))>>(offset)) & ONES32(size))
-#define EXTRACT(src,start,len)          (((len)==32)?(src):EXTRACT_C(src,start,len))
-
-#define MERGE_C(rsrc1,rsrc2,start,len)  ((((rsrc2)<<(start)) & (MASK32((start),(len)))) | ((rsrc1) & (~MASK32((start),(len)))))
-#define MERGE(rsrc1,rsrc2,start,len)    (((len)==32)?(rsrc2):MERGE_C(rsrc1,rsrc2,start,len))
-
-#define ONES64(size)                    ((size)?(0xffffffffffffffffULL>>(64-(size))):0)
-#define MASK64(offset,size)             (ONES64(size)<<(offset))
-
-#define EXTRACT_C64(source,offset,size)   ((((unsigned long long)(source))>>(offset)) & ONES64(size))
-#define EXTRACT64(src,start,len)          (((len)==64)?(src):EXTRACT_C64(src,start,len))
+#include "mflash_pack_layer.h"
+#include "mflash_access_layer.h"
+#include "mflash.h"
 
-#define MERGE_C64(rsrc1,rsrc2,start,len)  ((((u_int64_t)(rsrc2)<<(start)) & (MASK64((start),(len)))) | ((rsrc1) & (~MASK64((start),(len)))))
-#define MERGE64(rsrc1,rsrc2,start,len)    (((len)==64)?(rsrc2):MERGE_C64(rsrc1,rsrc2,start,len))
+#define ICMD_MAX_BLOCK_WRITE   128
+#define INBAND_MAX_BLOCK_WRITE 32
 
-#include "mflash.h"
+#define ARR_SIZE(arr) sizeof(arr)/sizeof(arr[0])
 
 #ifndef __WIN__
 
@@ -86,6 +72,7 @@
 
 #else
 #ifdef __FreeBSD__
+#include <netinet/in.h>
 #define SWAPL(l) ntohl(l)
 #include <sys/endian.h>
 #else // Linux
 #define SWAPL(l) bswap_32(l)
 #endif
 
-#ifndef __cpu_to_be32
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __cpu_to_be32(val) SWAPL(val)
-#else
-#define __cpu_to_be32(val) (val)
-#endif
-#endif
 #define OP_NOT_SUPPORTED EOPNOTSUPP
 
 #else // __WIN__
 #include <io.h>
 #include <Winsock2.h>
 #define SWAPL(l) ntohl(l)
-#define __cpu_to_be32(val) SWAPL(val) // Win is only run on LE CPUS
 #define inline __inline
-#define __cpu_to_be32(val) SWAPL(val) // Win is only run on LE CPUS
 
 #define OP_NOT_SUPPORTED EINVAL
 #define usleep(x) Sleep(((x + 999)/1000) )
 #endif // __WIN__
 #endif
 
-
-#ifndef __be32_to_cpu
-#define __be32_to_cpu(val)  __cpu_to_be32(val)
-#endif
-
 #ifndef zero
 #define zero 0
 #endif
 */
 
 /* Flash Functions: */
-//typedef struct mflash *mflash;
 
 // This is an interface function when running in IRISC
 int mf_open_fw(mflash* mfl, flash_params_t* flash_params, int num_of_banks);
 int cntx_int_spi_get_status_data(mflash* mfl, u_int8_t op_type, u_int32_t* status, u_int8_t data_num);
 
-//
-// mflash struct
-//
-
-#include "mflash_common.h"
-#include "mflash_access_layer.h"
-
 
 // NOTE: This macro returns ... not nice.
 #define CHECK_RC(rc) do {if (rc) return rc;} while(0)
@@ -214,8 +179,10 @@ int cntx_int_spi_get_status_data(mflash* mfl, u_int8_t op_type, u_int32_t* statu
 #define HERMON_HW_ID  0x190
 #define CX3_PRO_HW_ID 0x1F7
 #define CX3_HW_ID     0x1F5
+#define CX4_HW_ID        0x209
 
 #define CONNECT_IB_HW_ID 0x1FF
+#define SWITCH_IB_HW_ID 0x247
 
 // Write/Erase delays
 // ------------------
@@ -270,13 +237,6 @@ enum IntelFlashStatus {
     FS_BlockError  = 0x3F
 };
 
-enum AccessTypeByMfile{
-    ATBM_NO = 0,
-    ATBM_INBAND,
-    ATBM_MLNXOS_CMDIF,
-    ATBM_ICMD,
-};
-
 
 //static inline
 static u_int32_t log2up (u_int32_t in) {
@@ -289,20 +249,6 @@ static u_int32_t log2up (u_int32_t in) {
     return i;
 }
 
-static inline
-int set_bank(mflash* mfl, u_int32_t addr) {
-    int bank = addr >> mfl->attr.log2_bank_size;
-
-    if (mfl->curr_bank != bank) {
-        mfl->curr_bank = bank;
-        return mfl->f_set_bank(mfl, bank);
-    }
-
-    return MFE_OK;
-}
-
-
-
 // ConnectX SPI interface:
 int cntx_flash_init      (mflash* mfl, flash_params_t* flash_params);
 
@@ -336,7 +282,7 @@ int cntx_st_spi_block_read_ex  (mflash*   mfl,
 
 int cntx_spi_get_type(mflash* mfl, u_int8_t op_type, u_int8_t *vendor, u_int8_t *type, u_int8_t *capacity);
 
-int cntx_spi_write_status_reg(mflash* mfl, u_int32_t status_reg, u_int8_t status_is_double);
+int cntx_spi_write_status_reg(mflash* mfl, u_int32_t status_reg, u_int8_t write_cmd, u_int8_t status_is_double);
 
 int spi_get_num_of_flashes(int prev_num_of_flashes);
 
@@ -508,11 +454,13 @@ enum StFlashCommand {
     SFC_READ  = 0x03,
     SFC_RES   = 0xAB,
     SFC_JEDEC = 0x9F,
+    SFC_RDNVR = 0xB5,
+    SFC_WRNVR = 0xB1,
     SFC_WRSR  = 0x01
 };
 
 typedef struct flash_info {
-    char *name;
+    const char *name;
     u_int8_t vendor;
     u_int8_t type;
     int command_set;
@@ -520,6 +468,8 @@ typedef struct flash_info {
     int sector_size;
     u_int8_t quad_en_support;
     u_int8_t write_protected_support;
+    u_int8_t protect_sub_and_sector;
+    u_int8_t dummy_cycles_support;
 } flash_info_t;
 
 #define SST_FLASH_NAME   "SST25VFxx"
@@ -528,14 +478,15 @@ typedef struct flash_info {
 #define ATMEL_NAME       "AT25DFxxx"
 #define S25FLXXXP_NAME   "S25FLXXXP"
 #define S25FL116K_NAME   "S25FL11xx"
+#define MACRONIX_NAME   "MX25L16xxx"
 
 typedef enum flash_vendor {
     FV_ST      = 0x20,
     FV_SST     = 0xbf,
     FV_WINBOND = 0xef,
     FV_ATMEL   = 0x1f,
-    FV_S25FLXXXP = 0x01,
-    FV_S25FL116K = 0x01,
+    FV_S25FLXXXX = 0x01,
+    FV_MX25K16XXX = 0xc2,
 } flash_vendor_t;
 
 typedef enum flash_memory_type {
@@ -548,19 +499,20 @@ typedef enum flash_memory_type {
     FMT_N25QXXX  = 0xba,
     FMT_S25FLXXXP = 0x02,
     FMT_S25FL116K = 0x40,
-} flash_memory_type;
+} flash_memory_type_t;
 
 flash_info_t g_flash_info_arr[] =
 {
-        {"M25PXxx",      FV_ST,      FMT_ST_M25PX,     MCS_STSPI,  SFC_SSE, 0x1000,  0, 0},
-        {"M25Pxx",       FV_ST,      FMT_ST_M25P,      MCS_STSPI,  SFC_SE,  0x10000, 0, 0},
-        {"N25Q0XX",      FV_ST,      FMT_N25QXXX,      MCS_STSPI,  SFC_SSE, 0x1000, 0, 0},
-        {SST_FLASH_NAME, FV_SST,     FMT_SST_25,       MCS_SSTSPI, SFC_SE,  0x10000, 0, 0},
-        {WINBOND_NAME,   FV_WINBOND, FMT_WINBOND,      MCS_STSPI,  SFC_SSE, 0x1000,  1, 1},
-        {WINBOND_W25X,   FV_WINBOND, FMT_WINBOND_W25X, MCS_STSPI,  SFC_SSE, 0x1000,  0, 0},
-        {ATMEL_NAME,     FV_ATMEL,   FMT_ATMEL,        MCS_STSPI,  SFC_SSE, 0x1000,  0, 0},
-        {S25FLXXXP_NAME, FV_S25FLXXXP, FMT_S25FLXXXP,  MCS_STSPI,  SFC_SE,  0x10000,  0, 0},
-        {S25FL116K_NAME, FV_S25FL116K, FMT_S25FL116K, MCS_STSPI, SFC_SSE, 0x1000, 0, 0}, // this flash actually supports quad and write protect but we dont need it at this moment
+        {"M25PXxx",      FV_ST,      FMT_ST_M25PX,     MCS_STSPI,  SFC_SSE, 0x1000,  0, 0, 0, 0},
+        {"M25Pxx",       FV_ST,      FMT_ST_M25P,      MCS_STSPI,  SFC_SE,  0x10000, 0, 0, 0, 0},
+        {"N25Q0XX",      FV_ST,      FMT_N25QXXX,      MCS_STSPI,  SFC_SSE, 0x1000,  1, 1, 0, 1},
+        {SST_FLASH_NAME, FV_SST,     FMT_SST_25,       MCS_SSTSPI, SFC_SE,  0x10000, 0, 0, 0, 0},
+        {WINBOND_NAME,   FV_WINBOND, FMT_WINBOND,      MCS_STSPI,  SFC_SSE, 0x1000,  1, 1, 1, 0},
+        {WINBOND_W25X,   FV_WINBOND, FMT_WINBOND_W25X, MCS_STSPI,  SFC_SSE, 0x1000,  0, 0, 0, 0},
+        {ATMEL_NAME,     FV_ATMEL,   FMT_ATMEL,        MCS_STSPI,  SFC_SSE, 0x1000,  0, 0, 0, 0},
+        {S25FLXXXP_NAME, FV_S25FLXXXX, FMT_S25FLXXXP,  MCS_STSPI,  SFC_SE,  0x10000, 0, 0, 0, 0},
+        {S25FL116K_NAME, FV_S25FLXXXX, FMT_S25FL116K, MCS_STSPI, SFC_SSE,   0x1000,  0, 0, 0, 0}, // this flash actually supports quad and write protect but we dont need it at this moment
+        {MACRONIX_NAME, FV_MX25K16XXX, FMT_ST_M25P, MCS_STSPI, SFC_SSE,     0x1000,  0, 0, 0, 0}, // this flash actually supports write protection but we dont use it at this time
 };
 
 int cntx_sst_get_log2size(u_int8_t capacity, int* log2spi_size)
@@ -631,7 +583,7 @@ void mf_flash_list(char *flash_arr)
     return;
 }
 
-int get_type_index_by_name(char *type_name, unsigned *type_index)
+int get_type_index_by_name(const char *type_name, unsigned *type_index)
 {
     unsigned i, arr_size;
     arr_size = ARR_SIZE(g_flash_info_arr);
@@ -720,7 +672,7 @@ int cntx_get_flash_info(mflash* mfl, unsigned *type_index, int *log2size, u_int8
     return rc;
 }
 
-int compare_flash_params(flash_params_t *flash_params, int bank_num, char *type_name, int log2size)
+int compare_flash_params(flash_params_t *flash_params, int bank_num, const char *type_name, int log2size)
 {
     if (strcmp(flash_params->type_name, type_name) != 0) {
         printf("-E- SPI flash #%d (type: %s)differs in type from SPI flash #%d(type: %s). "
@@ -758,8 +710,8 @@ int get_flash_params(mflash* mfl, flash_params_t *flash_params, unsigned *type_i
     for (spi_sel = 0 ; spi_sel < num_of_flashes ; spi_sel++) {
             int log2size;
             u_int8_t no_flash = 0;
-            char *type_name;
-            rc = set_bank(mfl, spi_sel);                      CHECK_RC(rc);
+            const char *type_name;
+            rc = set_bank(mfl, spi_sel); CHECK_RC(rc);
             rc = mfl->f_get_info(mfl, type_index, &log2size, &no_flash); CHECK_RC(rc);
             //printf("-D- spi_sel = %d, num_of_flashes = %d, rc = %d, no_flash = %d\n", spi_sel, num_of_flashes, rc, no_flash);
 
@@ -784,9 +736,9 @@ int get_flash_params(mflash* mfl, flash_params_t *flash_params, unsigned *type_i
             // Init SST flash.
             if (mfl->access_type == MFAT_MFILE) {
                 if (flash_info->vendor ==  FV_SST && flash_info->type == FMT_SST_25) {
-                    rc = cntx_spi_write_status_reg(mfl, SST_STATUS_REG_VAL, 0); CHECK_RC(rc);
+                    rc = cntx_spi_write_status_reg(mfl, SST_STATUS_REG_VAL, SFC_WRSR, 0); CHECK_RC(rc);
                 } else if (flash_info->vendor ==  FV_ATMEL && flash_info->type == FMT_ATMEL) {
-                    rc = cntx_spi_write_status_reg(mfl, ATMEL_STATUS_REG_VAL, 0); CHECK_RC(rc);
+                    rc = cntx_spi_write_status_reg(mfl, ATMEL_STATUS_REG_VAL, SFC_WRSR, 0); CHECK_RC(rc);
                 }
             }
 
@@ -813,9 +765,13 @@ int spi_fill_attr_from_params(mflash* mfl, flash_params_t* flash_params, unsigne
     mfl->attr.type_str      = flash_info->name;
 
     mfl->attr.quad_en_support = flash_info->quad_en_support;
+    mfl->attr.dummy_cycles_support = flash_info->dummy_cycles_support;
 
-    mfl->attr.write_protect_support = flash_info->write_protected_support;
-    mfl->attr.banks_num             = flash_params->num_of_flashes;
+    mfl->attr.write_protect_support  = flash_info->write_protected_support;
+    mfl->attr.protect_sub_and_sector = flash_info->protect_sub_and_sector;
+    mfl->attr.banks_num              = flash_params->num_of_flashes;
+    mfl->attr.vendor                 = flash_info->vendor;
+    mfl->attr.type                   = flash_info->type;
     return MFE_OK;
 }
 
@@ -825,9 +781,6 @@ int st_spi_fill_attr(mflash* mfl, flash_params_t* flash_params) {
     int rc;
     flash_params_t *cur_flash_params, tmp_flash_params;
     unsigned type_index;
-    flash_info_t *flash_info;
-
-
 
     // printf("-D- st_spi_fill_attr: ignore_detect = %d, log2size = %#x.\n", mfl->ignore_flash_detect, mfl->user_attr.log2size);
     if (flash_params == NULL) {
@@ -849,7 +802,6 @@ int st_spi_fill_attr(mflash* mfl, flash_params_t* flash_params) {
         rc = get_type_index_by_name(flash_params->type_name, &type_index); CHECK_RC(rc);
         cur_flash_params = flash_params;
     }
-    flash_info = &(g_flash_info_arr[type_index]);
 
     // Init the flash attr according to the flash parameters (which was wither given by the user or read from the flash)
     rc = spi_fill_attr_from_params(mfl, cur_flash_params, type_index); CHECK_RC(rc);
@@ -1004,10 +956,10 @@ enum CrConstans {
     BS_SPI_GPIO     = 4
 };
 
-int gw_wait_ready(mflash* mfl, char* msg) {
+int gw_wait_ready(mflash* mfl, const char* msg) {
     u_int32_t gw_cmd;
     u_int32_t cnt = 0;
-    msg = 0; // NOT USED FOR NOW
+    (void)msg; // NOT USED FOR NOW
     do {
         // Timeout checks
         if (++cnt > FLASH_CMD_CNT) {
@@ -1024,7 +976,7 @@ int gw_wait_ready(mflash* mfl, char* msg) {
 
 
 int empty_reset          (mflash* mfl) {
-    mfl = NULL;
+    (void)mfl; /* avoid compiler warning */
     return MFE_OK;
 }
 
@@ -1078,8 +1030,8 @@ enum CntxCrConstants{
 
 int empty_set_bank(mflash* mfl, u_int32_t bank) {
     // NULL function - No actual work here - in ConnectX the curr_bank is written in the command word.
-    mfl = NULL; // Compiler warning
-    bank = 0;   // Compiler warning
+    (void)mfl; // Avoid Compiler warning
+    (void)bank;   // Avoid Compiler warning
     return MFE_OK;
 }
 
@@ -1099,8 +1051,12 @@ int is_sx(u_int32_t dev_id) {
     }
     return 0;
 }
-
-
+int is_sx_ib(u_int32_t dev_id) {
+    if (dev_id == SWITCH_IB_HW_ID) {
+        return 1;
+    }
+    return 0;
+}
 int is_is4_family(u_int32_t dev_id) {
     if (dev_id == 435  ||  // InfiniScaleIV
         dev_id == 6100) { // BridgeX
@@ -1115,10 +1071,23 @@ int is_connectib(u_int32_t dev_id) {
     }
     return 0;
 }
+
+int is_connectx4(u_int32_t dev_id) {
+       return (dev_id == CX4_HW_ID) ? 1 : 0;
+}
+
+int has_icmd_if(u_int32_t dev_id) {
+       return  (is_connectib(dev_id) ||
+                        is_sx_ib(dev_id) ||
+                        is_connectx4(dev_id));
+
+}
+
 int is_4th_gen_switch_family(u_int32_t dev_id) {
     if (is_is4_family(dev_id) ||
         is_sx(dev_id)         ||
-        is_connectib(dev_id)) {
+        is_connectib(dev_id)  ||
+        is_sx_ib(dev_id)) {
         return 1;
     }
     return 0;
@@ -1236,17 +1205,16 @@ int cntx_spi_get_type(mflash* mfl, u_int8_t op_type, u_int8_t *vendor, u_int8_t*
     // printf("-D- cntx_spi_get_type: vendor = %#x, type = %#x, capacity = %#x\n", *vendor, *type, *capacity);
     return MFE_OK;
 }
-int cntx_spi_write_status_reg(mflash* mfl, u_int32_t status_reg, u_int8_t status_is_double)
+int cntx_spi_write_status_reg(mflash* mfl, u_int32_t status_reg, u_int8_t write_cmd, u_int8_t status_is_double)
 {
     int rc;
     u_int32_t gw_cmd = 0;
 
     rc = cntx_st_spi_write_enable(mfl); CHECK_RC(rc);
-
     gw_cmd = MERGE(gw_cmd,        1, HBO_CMD_PHASE,  1);
     gw_cmd = MERGE(gw_cmd,        1, HBO_DATA_PHASE, 1);
 
-    gw_cmd = MERGE(gw_cmd, SFC_WRSR, HBO_CMD,        HBS_CMD);
+    gw_cmd = MERGE(gw_cmd, write_cmd, HBO_CMD,        HBS_CMD);
 
     if (status_is_double) {
         gw_cmd = MERGE(gw_cmd, 1, HBO_MSIZE,      HBS_MSIZE);
@@ -1339,7 +1307,7 @@ int spi_update_num_of_banks(mflash* mfl, int prev_num_of_flashes)
 
 
 int cntx_st_spi_reset          (mflash* mfl) {
-    mfl = NULL;
+    (void)mfl;
     return MFE_OK;
 }
 
@@ -1380,11 +1348,13 @@ int cntx_st_spi_page_read    (mflash* mfl, u_int32_t addr, u_int32_t size, u_int
     return MFE_OK;
 }
 
+/*
 int get_flash_offset(u_int32_t addr, int log2_bank_size, u_int32_t *flash_addr_p)
 {
     *flash_addr_p = addr & ONES32(log2_bank_size);
     return MFE_OK;
 }
+*/
 
 int cntx_st_spi_block_read_ex  (mflash* mfl, u_int32_t blk_addr, u_int32_t blk_size, u_int8_t* data, u_int8_t is_first, u_int8_t is_last) {
     int rc;
@@ -1705,15 +1675,14 @@ int old_flash_lock(mflash* mfl, int lock_state) {
 int cntx_flash_init(mflash* mfl, flash_params_t* flash_params) {
     int rc;
     u_int32_t tmp;
-    int is_life_fish = 0;
 
     // Without too much details:
     // When the ConnectX boots up without a valid FW , the PCIE link may be unstable.
     // In that case, turn off the auto reset on link down, so we'll be able to burn the device.
     MREAD4(0x41270, &tmp);
     if (tmp > 0xfff00000) {
+       //we are in livefish.
         u_int32_t tmp1;
-        is_life_fish = 1;
         MREAD4(0xf3834, &tmp1);
         tmp1 = MERGE(tmp1, 2, 27, 2);
         MWRITE4(0xf3834, tmp1);
@@ -1764,7 +1733,7 @@ int cntx_flash_init(mflash* mfl, flash_params_t* flash_params) {
 // InfiniScale 4 (IS4) functions:
 
 int is4_init_gpios(mflash* mfl) {
-    mfl = NULL;
+    (void)mfl;
     return MFE_NOT_IMPLEMENTED;
 }
 
@@ -1956,16 +1925,6 @@ int connectib_init_direct_access(mflash* mfl, flash_params_t* flash_params)
     mfl->f_lock           = connectib_flash_lock;
     return gen4_flash_init_com(mfl, flash_params, 0);
 }
-int mfl_get_bank_info(mflash *mfl, u_int32_t addr, u_int32_t *flash_off_p, int *bank_p)
-{
-    int rc;
-    // Get the bank number
-    rc = set_bank(mfl, addr);                                           CHECK_RC(rc);
-    *bank_p = mfl->curr_bank;
-    // Get the offset in the flash
-    rc = get_flash_offset(addr, mfl->attr.log2_bank_size, flash_off_p); CHECK_RC(rc);
-    return MFE_OK;
-}
 
 typedef int (*f_sx_flash_lock)      (mflash* mfl, int lock_state);
 typedef int (*f_sx_erase_sect)      (mflash* mfl, u_int32_t addr);
@@ -2004,13 +1963,25 @@ int sx_erase_sect(mflash* mfl, u_int32_t addr)
 int empty_get_status(mflash* mfl, u_int8_t op_type, u_int8_t* status)
 {
     // Avoid warnings
-    mfl = NULL;
-    op_type = 0;
-    status = NULL;
+    (void)mfl;
+    (void)op_type;
+    (void)status;
 
     return MFE_NOT_SUPPORTED_OPERATION;
 }
 
+static int update_max_write_size(mflash* mfl)
+{
+    u_int32_t max_reg_size = mget_max_reg_size(mfl->mf);
+    if (!max_reg_size) {
+       return MFE_BAD_PARAMS;
+    }
+    max_reg_size = NEAREST_POW2(max_reg_size);
+    mfl->attr.block_write = max_reg_size;
+    mfl->attr.page_write  = max_reg_size;
+    return ME_OK;
+}
+
 int flash_init_inband_access(mflash* mfl, flash_params_t* flash_params)
 {
     int rc;
@@ -2028,19 +1999,11 @@ int flash_init_inband_access(mflash* mfl, flash_params_t* flash_params)
     mfl->f_read_blk   = sx_block_read;
     mfl->f_spi_status = empty_get_status;
 
-
     // Lock the FW semaphore which synchronizes between multiple processes
     rc = mfl_com_lock(mfl); CHECK_RC(rc);
     // Get the flash attribute
     rc = st_spi_fill_attr(mfl, flash_params);   CHECK_RC(rc);
-
-    if ( mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] == ATBM_ICMD) {
-        mfl->attr.block_write = ICMD_MAX_BLOCK_WRITE;
-        mfl->attr.page_write  = ICMD_MAX_BLOCK_WRITE;
-    } else {
-        mfl->attr.block_write = INBAND_MAX_BLOCK_WRITE;
-        mfl->attr.page_write  = INBAND_MAX_BLOCK_WRITE;
-    }
+    update_max_write_size(mfl); CHECK_RC(rc);
     return MFE_OK;
 }
 
@@ -2066,13 +2029,7 @@ int uefi_flash_init(mflash* mfl, flash_params_t* flash_params)
     // Get the flash attribute
 
     rc = st_spi_fill_attr(mfl, flash_params);   CHECK_RC(rc);
-
-    mfl->attr.block_write = 16;
-    mfl->attr.page_write  = 16;
-/*
-    mfl->attr.block_write = INBAND_MAX_BLOCK_WRITE;
-    mfl->attr.page_write  = INBAND_MAX_BLOCK_WRITE;
-*/
+    update_max_write_size(mfl); CHECK_RC(rc);
     return MFE_OK;
 }
 
@@ -2108,17 +2065,12 @@ int sx_flash_init(mflash* mfl, flash_params_t* flash_params)
 #ifndef MST_UL
 int icmd_init(mflash *mfl)
 {
-    mfl->cif_dev = gcif_open(mfl->mf);
-    if (mfl->cif_dev == NULL) {
-        return MFE_ICMD_INIT_FAILED;
-    }
     // Clear  semaphore when asked to by flint or any tool using mflash
     if (mfl->opts[MFO_IGNORE_SEM_LOCK]) {
-        if (gcif_clear_semaphore(mfl->cif_dev) != GCIF_STATUS_SUCCESS) {
+        if (icmd_clear_semaphore(mfl->mf) != ME_OK) {
             return MFE_CR_ERROR;
         }
     }
-    mfl->cmdif_context = mfl->cif_dev;
     return MFE_OK;
 }
 #else
@@ -2214,10 +2166,9 @@ int get_dev_info(mflash* mfl)
          if (dev_flags & MDEVS_IB) {
              mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] = ATBM_INBAND;
          } else {
-             if (is_connectib(mfl->attr.hw_dev_id)) {
+             if (has_icmd_if(mfl->attr.hw_dev_id)) {
                  if (mfl->opts[MFO_IGNORE_CASHE_REP_GUARD] == 0) {
-                     //only inband access is allowed.
-                     mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] = ATBM_INBAND;
+                     mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] = ATBM_ICMD;
                  }
              }
          }
@@ -2239,7 +2190,7 @@ int mf_open_fw(mflash* mfl, flash_params_t* flash_params, int num_of_banks)
         rc = get_dev_info(mfl); CHECK_RC(rc);
 
         mfl->opts[MFO_NUM_OF_BANKS] = spi_get_num_of_flashes(num_of_banks);
-        rc = spi_update_num_of_banks(mfl, num_of_banks); CHECK_RC(rc);
+        rc = spi_update_num_of_banks(mfl, num_of_banks);CHECK_RC(rc);
 
         if (mfl->attr.hw_dev_id == 23108 || mfl->attr.hw_dev_id == 25208 || mfl->attr.hw_dev_id == 24204 || mfl->attr.hw_dev_id == 25204) {
             rc = MFE_OLD_DEVICE_TYPE;
@@ -2249,7 +2200,7 @@ int mf_open_fw(mflash* mfl, flash_params_t* flash_params, int num_of_banks)
             rc = is4_flash_init(mfl, flash_params);
         } else if (is_sx(mfl->attr.hw_dev_id)) {
             rc = sx_flash_init(mfl, flash_params);
-        } else if (is_connectib(mfl->attr.hw_dev_id)) {
+        } else if (has_icmd_if(mfl->attr.hw_dev_id)) {
             rc = connectib_flash_init(mfl, flash_params);
         } else if (mfl->attr.hw_dev_id == 0xffff) {
             printf("-E- Read a corrupted device id (0x%x). Probably HW/PCI access problem\n", mfl->attr.hw_dev_id);
@@ -2285,10 +2236,12 @@ int     mf_opend_int       (mflash** pmfl, void* access_dev, int num_of_banks, f
     if (access_type ==  MFAT_MFILE) {
         (*pmfl)->mf = (mfile*)access_dev;
     } else if (access_type ==  MFAT_UEFI) {
-        (*pmfl)->uefi_dev = (uefi_Dev_t*)access_dev;
-        (*pmfl)->uefi_cmd_func = (f_fw_cmd)access_func;
+       // open mfile as uefi
+       if (!((*pmfl)->mf = mopen_fw_ctx(access_dev, access_func))){
+               free((*pmfl));
+               return MFE_NOMEM;
+       }
     }
-    (*pmfl)->cmdif_context = access_dev;
 
     rc = mf_open_fw(*pmfl, flash_params, num_of_banks);
     return rc;
@@ -2303,7 +2256,8 @@ int     mf_opend       (mflash** pmfl, struct mfile_t* mf, int num_of_banks, fla
 
 int     mf_open_uefi(mflash** pmfl, uefi_Dev_t *uefi_dev, f_fw_cmd fw_cmd_func)
 {
-    return mf_opend_int(pmfl, uefi_dev, 4, NULL, 0, MFAT_UEFI, fw_cmd_func);
+
+    return mf_opend_int(pmfl, (void*)uefi_dev, 4, NULL, 0, MFAT_UEFI, (void*)fw_cmd_func);
 }
 
 
@@ -2329,9 +2283,7 @@ int     mf_open        (mflash** pmfl, const char* dev, int num_of_banks, flash_
     if ((*pmfl)) {
         (*pmfl)->opts[MFO_CLOSE_MF_ON_EXIT] = 1;
     }
-
     CHECK_RC(rc);
-
     return MFE_OK;
 }
 
@@ -2348,13 +2300,6 @@ int     mf_close       (mflash* mfl) {
         return MFE_BAD_PARAMS;
     }
 
-
-#ifndef MST_UL
-    if (mfl->cif_dev) {
-        gcif_close(mfl->cif_dev);
-    }
-#endif
-
     if (mfl->f_reset) {
         mfl->f_reset(mfl);
     }
@@ -2397,7 +2342,7 @@ int     mf_sw_reset     (mflash* mfl) {
 
 
 const char*   mf_err2str (int err_code) {
-    static char* mf_err_str[] = {
+    static const char* mf_err_str[] = {
     "MFE_OK",
     "MFE_GENERAL_ERROR",
     "MFE_BAD_PARAMS",
@@ -2425,26 +2370,38 @@ const char*   mf_err2str (int err_code) {
     "MFE_CMDIF_GO_BIT_BUSY",
     "The given key is incorrect",
     "MFE_UNKNOWN_REG",
-    "MFE_REG_ACCESS_FAILED",
-    "MFE_REG_ACCESS_MAD_BAD_STATUS",
-    "MFE_REG_ACCESS_MAD_NOT_SUPPORTED",
     "MFE_DIRECT_FW_ACCESS_DISABLED",
     "MFE_MANAGED_SWITCH_NOT_SUPPORTED",
     "MFE_NOT_SUPPORTED_OPERATION",
-    "MFE_REG_ACCESS_FW_BAD_STATUS",
     "MFE_FLASH_NOT_EXIST",
-    "MFE_MISMATCH_QUAD_EN",
+    "MFE_MISMATCH_PARAM",
     "MFE_EXCEED_SUBSECTORS_MAX_NUM",
     "MFE_EXCEED_SECTORS_MAX_NUM",
     "MFE_SECTORS_NUM_NOT_POWER_OF_TWO",
-    "MFE_REG_ACCESS_RESOURCE_NOT_AVAILABLE",
     "MFE_UNKOWN_ACCESS_TYPE",
     "MFE_UNSUPPORTED_DEVICE",
     "MFE_OLD_DEVICE_TYPE",
     "MFE_ICMD_INIT_FAILED",
-    "MFE_REG_ACCESS_ICMD_NOT_SUPPPRTOED",
+    "MFE_ICMD_NOT_SUPPORTED",
     "Secure host mode is not enabled in this FW.",
+    "MFE_MAD_SEND_ERR",
     "MFE_ICMD_BAD_PARAM",
+    "MFE_ICMD_INVALID_OPCODE",
+    "MFE_ICMD_INVALID_CMD",
+    "MFE_ICMD_OPERATIONAL_ERROR",
+    "MFE_REG_ACCESS_BAD_METHOD",
+    "MFE_REG_ACCESS_NOT_SUPPORTED",
+    "MFE_REG_ACCESS_DEV_BUSY",
+    "MFE_REG_ACCESS_VER_NOT_SUPP",
+    "MFE_REG_ACCESS_UNKNOWN_TLV",
+    "MFE_REG_ACCESS_REG_NOT_SUPP",
+    "MFE_REG_ACCESS_CLASS_NOT_SUPP",
+    "MFE_REG_ACCESS_METHOD_NOT_SUPP",
+    "MFE_REG_ACCESS_BAD_PARAM",
+    "MFE_REG_ACCESS_RESOURCE_NOT_AVAILABLE",
+    "MFE_REG_ACCESS_MSG_RECPT_ACK",
+    "MFE_REG_ACCESS_UNKNOWN_ERR",
+    "MFE_REG_ACCESS_SIZE_EXCCEEDS_LIMIT",
     };
 
     return err_code < (int)ARRSIZE(mf_err_str) ? mf_err_str[err_code] : NULL;
@@ -2482,77 +2439,157 @@ int     mf_cr_write    (mflash* mfl, u_int32_t cr_addr, u_int32_t  data) {
 
 int    mf_update_boot_addr(mflash* mfl, u_int32_t boot_addr)
 {
+       if (mfl->access_type != MFAT_UEFI && mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] != ATBM_MLNXOS_CMDIF) {
+               // the boot addr will be updated directly via cr-space
+               return mf_cr_write(mfl, BOOT_CR_SPACE_ADDR, ((boot_addr << 8) | 0x06));
+       }
+       // the boot addr will be updated via reg
     return mf_update_boot_addr_by_type(mfl, boot_addr);
 }
 
-int     mf_read_modify_status (mflash *mfl, u_int8_t bank_num, u_int8_t first_byte, u_int8_t param, u_int8_t offset, u_int8_t size)
+int     mf_read_modify_status_winbond (mflash *mfl, u_int8_t bank_num, u_int8_t first_byte, u_int8_t param, u_int8_t offset, u_int8_t size)
 {
-    u_int8_t status1, status2;
-    u_int32_t status;
+    u_int8_t status1 = 0, status2 = 0, use_rdsr2 = 0, is_double = 0;
+    u_int32_t status = 0;
     int rc;
 
 
     mfl->curr_bank = bank_num;
+    if ( mfl->attr.vendor == FV_WINBOND &&  mfl->attr.type == FMT_WINBOND) {
+        use_rdsr2 = 1;
+    }
 
     // Read register status
     rc = mfl->f_spi_status(mfl, SFC_RDSR, &status1); CHECK_RC(rc);
-    rc = mfl->f_spi_status(mfl, SFC_RDSR2, &status2); CHECK_RC(rc);
-
-
-    // printf("-D- BEFORE status1 = %#x, status2 = %#x\n", status1, status2);
-
+    if (use_rdsr2) {
+        rc = mfl->f_spi_status(mfl, SFC_RDSR2, &status2); CHECK_RC(rc);
+        status = MERGE(0, status2, 16, 8);
+        is_double = 1;
+    }
     // Prepare the read status word
-    status = MERGE(0, status2, 16, 8);
     status = MERGE(status, status1, 24, 8);
     // Modify the status according to the function arguments
     status = MERGE(status, param, 16 + offset + first_byte * 8 , size);
-    // printf("-D- status1 = %#x.\n", status);
-
     // Write register status
-    rc = cntx_spi_write_status_reg(mfl, status, 1); CHECK_RC(rc);
-    rc = mfl->f_spi_status(mfl, SFC_RDSR, &status1); CHECK_RC(rc);
-    rc = mfl->f_spi_status(mfl, SFC_RDSR2, &status2); CHECK_RC(rc);
-        // printf("-D- AFTER status1 = %#x, status2 = %#x\n", status1, status2);
+    rc = cntx_spi_write_status_reg(mfl, status, SFC_WRSR, is_double); CHECK_RC(rc);
     return MFE_OK;
 }
 #define QUAD_EN_OFFSET 1
+#define QUAD_EN_OFFSET_ST 3
+#define DUMMY_CYCLES_OFFSET_ST 12
+
+int mf_read_modify_status_new(mflash *mfl, u_int8_t bank_num, u_int8_t read_cmd, u_int8_t write_cmd, u_int8_t val,
+                              u_int8_t offset, u_int8_t size, u_int8_t is_double)
+{
+    int rc;
+    u_int32_t status = 0;
+
+    mfl->curr_bank = bank_num;
+    rc = cntx_int_spi_get_status_data(mfl, read_cmd, &status, is_double); CHECK_RC(rc);
+    // status comes in be32 format (byte0 = MSB) so we switch
+    status = __be32_to_cpu(status);
+    status = MERGE(status, val, offset, size);
+    // and switch back
+    status = __be32_to_cpu(status);
+    rc = cntx_spi_write_status_reg(mfl, status, write_cmd, is_double); CHECK_RC(rc);
+    return MFE_OK;
+}
+
+int mf_get_param_int(mflash* mfl, u_int8_t *param_p, u_int8_t cmd, u_int8_t offset, u_int8_t bit_size,\
+                                                       u_int8_t bytes_num, u_int8_t enabled_val)
+{
+    u_int32_t status = 0, is_first = 1, bank;
+    int rc;
+
+    for (bank = 0; bank < mfl->attr.banks_num; bank++ ) {
+        u_int8_t curr_val;
+        mfl->curr_bank = bank;
+
+        rc = cntx_int_spi_get_status_data(mfl, cmd, &status, bytes_num); CHECK_RC(rc);
+        //if (mfl->attr.vendor == FV_ST) {
+               //value is a word located in the higher bytes and is in be_32 format so we "fix" the bytes
+               status = __be32_to_cpu(status);
+        //}
+        curr_val = EXTRACT(status, offset, bit_size);
+        if (bit_size == 1) {
+               curr_val = (curr_val == enabled_val);
+        }
+
+        if (is_first) {
+            *param_p = curr_val;
+            is_first = 0;
+        } else {
+            if (*param_p != curr_val) {
+                return MFE_MISMATCH_PARAM;
+            }
+        }
+    }
+    return MFE_OK;
+}
+
+int     mf_set_dummy_cycles (mflash *mfl, u_int8_t num_of_cycles)
+{
+       if (!mfl || num_of_cycles < 1 || num_of_cycles > 15) {
+        return MFE_BAD_PARAMS;
+       }
+    int bank, rc;
+    if (!mfl->attr.dummy_cycles_support) {
+        return MFE_NOT_SUPPORTED_OPERATION;
+    }
+    for (bank = 0; bank < mfl->attr.banks_num; bank++) {
+        rc =  mf_read_modify_status_new(mfl, bank, SFC_RDNVR, SFC_WRNVR, num_of_cycles, DUMMY_CYCLES_OFFSET_ST, 4, 1); CHECK_RC(rc);
+    }
+    return MFE_OK;
+}
+
+int mf_get_dummy_cycles(mflash* mfl, u_int8_t *dummy_cycles_p)
+{
+       if (!mfl || !dummy_cycles_p) {
+        return MFE_BAD_PARAMS;
+       }
+    if (!mfl->attr.dummy_cycles_support) {
+        return MFE_NOT_SUPPORTED_OPERATION;
+    }
+    return  mf_get_param_int(mfl, dummy_cycles_p, SFC_RDNVR, DUMMY_CYCLES_OFFSET_ST, 4, 2, 0);
+    return MFE_OK;
+}
+
+
 
 int     mf_set_quad_en (mflash *mfl, u_int8_t quad_en)
 {
+       if (!mfl) {
+               return MFE_BAD_PARAMS;
+       }
     int bank, rc;
     if (!mfl->attr.quad_en_support) {
         return MFE_NOT_SUPPORTED_OPERATION;
     }
     for (bank = 0; bank < mfl->attr.banks_num; bank++) {
-        rc = mf_read_modify_status(mfl, bank, 0, quad_en, QUAD_EN_OFFSET, 1); CHECK_RC(rc);
+        if (mfl->attr.vendor == FV_WINBOND) {
+            rc = mf_read_modify_status_winbond(mfl, bank, 0, quad_en, QUAD_EN_OFFSET, 1); CHECK_RC(rc);
+        } else if (mfl->attr.vendor == FV_ST) {
+            rc = mf_read_modify_status_new(mfl, bank, SFC_RDNVR, SFC_WRNVR, !quad_en, QUAD_EN_OFFSET_ST, 1, 1); CHECK_RC(rc);
+        }
     }
     return MFE_OK;
 }
 
 int mf_get_quad_en(mflash* mfl, u_int8_t *quad_en_p)
 {
-    u_int8_t status, is_first = 1, bank;
-    int rc;
+       if (!mfl || !quad_en_p) {
+               return MFE_BAD_PARAMS;
+       }
     if (!mfl->attr.quad_en_support) {
         return MFE_NOT_SUPPORTED_OPERATION;
     }
 
-    for (bank = 0; bank < mfl->attr.banks_num; bank++ ) {
-        u_int8_t curr_quad_en;
-        mfl->curr_bank = bank;
-
-        rc = mfl->f_spi_status(mfl, SFC_RDSR2, &status); CHECK_RC(rc);
-        curr_quad_en = EXTRACT(status, QUAD_EN_OFFSET, 1);
-        if (is_first) {
-            *quad_en_p = curr_quad_en;
-            is_first = 0;
-        } else {
-            if (*quad_en_p != curr_quad_en) {
-                return MFE_MISMATCH_QUAD_EN;
-            }
-        }
+    if (mfl->attr.vendor == FV_WINBOND) {
+        return  mf_get_param_int(mfl, quad_en_p, SFC_RDSR2, QUAD_EN_OFFSET, 1, 1, 1);
+    } else if (mfl->attr.vendor == FV_ST) {
+        return  mf_get_param_int(mfl, quad_en_p, SFC_RDNVR, QUAD_EN_OFFSET_ST, 1, 2, 0);
     }
-    return MFE_OK;
+    return MFE_NOT_SUPPORTED_OPERATION;
 }
 
 #define REG1_TB_OFFSET  5
@@ -2588,7 +2625,7 @@ int     mf_set_write_protect(mflash *mfl, u_int8_t bank_num, write_protect_info_
         return MFE_EXCEED_SECTORS_MAX_NUM;
     }
 
-    if (protect_info->is_subsector) {
+    if (mfl->attr.protect_sub_and_sector && protect_info->is_subsector) {
         if (protect_info->sectors_num > MAX_SUBSECTOR_NUM) {
             return MFE_EXCEED_SUBSECTORS_MAX_NUM;
         }
@@ -2601,25 +2638,36 @@ int     mf_set_write_protect(mflash *mfl, u_int8_t bank_num, write_protect_info_
         sectors_num >>= 1;
         // printf("-D- sectors_num = %d\n", sectors_num);
     }
+    u_int8_t modify_size = 0;
+
     protect_mask = MERGE(protect_mask, log2_sect_num, 0, REG1_BP_SIZE);
-    protect_mask = MERGE(protect_mask, protect_info->is_bottom, REG1_BP_SIZE, ONE_BIT_SIZE);
-    protect_mask = MERGE(protect_mask, protect_info->is_subsector, REG1_BP_SIZE + ONE_BIT_SIZE, ONE_BIT_SIZE);
+    modify_size += REG1_BP_SIZE;
 
-    // printf("-D- protect mask: %#x\n", protect_mask);
-    return mf_read_modify_status(mfl, bank_num, 1, protect_mask, REG1_BP_OFFSET, REG1_BP_SIZE + 2 * ONE_BIT_SIZE);
+    protect_mask = MERGE(protect_mask, protect_info->is_bottom, REG1_BP_SIZE, ONE_BIT_SIZE);
+    modify_size += ONE_BIT_SIZE;
+    if (mfl->attr.protect_sub_and_sector) {
+        protect_mask = MERGE(protect_mask, protect_info->is_subsector, REG1_BP_SIZE + ONE_BIT_SIZE, ONE_BIT_SIZE);
+        modify_size += ONE_BIT_SIZE;
+    }
+    return mf_read_modify_status_winbond(mfl, bank_num, 1, protect_mask, REG1_BP_OFFSET, modify_size);
 }
 
 int     mf_get_write_protect(mflash *mfl, u_int8_t bank_num, write_protect_info_t *protect_info)
 {
     int rc;
     u_int8_t status;
+
     WRITE_PROTECT_CHECKS(mfl, bank_num);
     mfl->curr_bank = bank_num;
-    // printf("-D- bank _num = %d\n", bank_num);
     rc = mfl->f_spi_status(mfl, SFC_RDSR, &status); CHECK_RC(rc);
-    // printf("-D- status = %#x\n", status);
     protect_info->is_bottom = EXTRACT(status, REG1_TB_OFFSET, 1);
-    protect_info->is_subsector = EXTRACT(status, REG1_SEC_OFFSET, 1);
+
+    if (mfl->attr.protect_sub_and_sector) {
+        protect_info->is_subsector = EXTRACT(status, REG1_SEC_OFFSET, 1);
+    } else {
+        protect_info->is_subsector = 0;
+    }
+
     protect_info->sectors_num = 1 << (EXTRACT(status, REG1_BP_OFFSET, REG1_BP_SIZE) - 1);
 
     return MFE_OK;
index a574af248111dcce1d503be4308bf92f482d1981..eb3c1b73722e5757150e5caa16be776e67983083 100644 (file)
@@ -1,9 +1,5 @@
 /*
- *
- * mflash.h - Mellanox Technilogies LTD. Flash access lib heared file
- * ==================================================================
- *
- * Copyright (c) 2005 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
- *  Version: $Id: $
- *
  */
+
+
 #ifndef MFLASH_H
 #define MFLASH_H
 
-#ifndef __WIN__
-#include <sys/types.h>
-#endif
+#include <compatibility.h>
+#include "mflash_types.h"
+#include "mflash_common_structs.h"
 
 #ifdef __cplusplus
 #define EXTERN_C_START extern "C" {
@@ -62,7 +57,7 @@ typedef enum MfCommandSet {
 } MfCommandSet;
 
 typedef struct flash_params {
-    char *type_name;
+    const char *type_name;
     int log2size;
     int num_of_flashes;
 } flash_params_t;
@@ -73,143 +68,9 @@ typedef struct write_protect_info {
     u_int8_t sectors_num;
 } write_protect_info_t;
 
-typedef enum MfError {
-    MFE_OK = 0,
-    MFE_ERROR,
-    MFE_BAD_PARAMS,
-    MFE_CR_ERROR,
-    MFE_INVAL,
-    MFE_NOT_IMPLEMENTED,
-    MFE_UNSUPPORTED_FLASH_TOPOLOGY,
-    MFE_UNSUPPORTED_FLASH_TYPE,
-    MFE_CFI_FAILED,
-    MFE_TIMEOUT,
-    MFE_ERASE_TIMEOUT,
-    MFE_WRITE_TIMEOUT,
-    MFE_ERASE_ERROR,
-    MFE_WRITE_ERROR,
-    MFE_BAD_ALIGN,
-    MFE_SEM_LOCKED,
-    MFE_VERIFY_ERROR,
-    MFE_NOMEM,
-    MFE_OUT_OF_RANGE,
-    MFE_CMD_SUPPORTED_INBAND_ONLY,
-    MFE_NO_FLASH_DETECTED,
-    MFE_LOCKED_CRSPACE,
-    MFE_CMDIF_BAD_STATUS_ERR,
-    MFE_CMDIF_TIMEOUT_ERR,
-    MFE_CMDIF_GO_BIT_BUSY,
-    MFE_MISMATCH_KEY,
-    MFE_UNKNOWN_REG,
-    MFE_REG_ACCESS_FAILED,
-    MFE_REG_ACCESS_MAD_BAD_STATUS,
-    MFE_REG_ACCESS_MAD_NOT_SUPPORTED,
-    MFE_DIRECT_FW_ACCESS_DISABLED,
-    MFE_MANAGED_SWITCH_NOT_SUPPORTED,
-    MFE_NOT_SUPPORTED_OPERATION,
-    MFE_REG_ACCESS_FW_BAD_STATUS,
-    MFE_FLASH_NOT_EXIST,
-    MFE_MISMATCH_QUAD_EN,
-    MFE_EXCEED_SUBSECTORS_MAX_NUM,
-    MFE_EXCEED_SECTORS_MAX_NUM,
-    MFE_SECTORS_NUM_NOT_POWER_OF_TWO,
-    MFE_REG_ACCESS_RESOURCE_NOT_AVAILABLE,
-    MFE_UNKOWN_ACCESS_TYPE,
-    MFE_UNSUPPORTED_DEVICE,
-    MFE_OLD_DEVICE_TYPE,
-    MFE_ICMD_INIT_FAILED,
-    MFE_REG_ACCESS_ICMD_NOT_SUPPPRTOED,
-    MFE_HW_ACCESS_NOT_SUPP,
-    MFE_ICMD_BAD_PARAM,
-    MFE_LAST
-} MfError;
-
-typedef enum MfOpt {
-    MFO_NO_VERIFY = 0,
-    MFO_AMD_UNLOCK_BYPASS,
-    MFO_AMD_BYTE_MODE,
-    MFO_IGNORE_SEM_LOCK,
-    MFO_CLOSE_MF_ON_EXIT,
-    MFO_NUM_OF_BANKS,
-    MFO_IGNORE_CASHE_REP_GUARD,
-    MFO_USER_BANKS_NUM,
-    MFO_FW_ACCESS_TYPE_BY_MFILE,
-    MFO_SX_TYPE,
-    MFO_NEW_CACHE_REPLACEMENT_EN,
-    MFO_LAST
-} MfOpt;
-
-enum MfAccessType {
-    MFAT_MFILE = 0,
-    MFAT_UEFI,
-};
-
-/////////////////////////////////////////////
-//
-// Flash attributes struct
-//
-/////////////////////////////////////////////
-typedef struct flash_attr {
-    char *type_str;
-    //
-    // hw_dev_id    hw dev id of the HCA.
-    //
-    u_int32_t hw_dev_id;
-    u_int32_t rev_id;
-
-    //
-    // size:        Total size (in bytes) of all flash devices connected to
-    //              the device (forming a contigous address space)
-    //
-    u_int32_t size;
-
-    //
-    // sector_size: Flash sector size (in bytes).
-    //              Assuming a single sector size for the flash.
-    //
-    u_int32_t sector_size;
-
-    int       num_erase_blocks;         // Number of sector defs.
-    struct {
-        unsigned long sector_size;      // Byte size of sector
-        int           num_sectors;      // Num sectors of this size
-        u_int32_t     sector_mask;      // Sector mask
-    } erase_block[8];
-
-    //
-    // bank_size:   Different bank means a different chip sellect or gpio settings is needed when crossing
-    //              this alignment.
-    //              This may indicate a different flash device (for SPI flash in InfiniHostIIILx / ConnectX).
-    //              Or GPIO change for parallel flash (in InfiniHostIII / InfiniHost)
-    //
-    int bank_size;
-    int log2_bank_size;
-
-    //
-    // Command set (taken from CFI terminology)
-    //
-    int command_set;
-
-    u_int8_t erase_command;
-
-    //
-    // block_write - if block write is supported, holds the block size in bytes. 0 otherwise.
-    //               The meaning of "block write" is not the same in parallel and serial flash.
-    //
-    int block_write;
-
-    //
-    // page_write -  if page write is supported, holds the page size in bytes. 0 otherwise.
-    //
-    int page_write;
-
-    u_int8_t banks_num;
-    u_int8_t quad_en_support;
-    u_int8_t write_protect_support;
-
-
-} flash_attr;
-
+// TODO: remove UEFI REMNANTS
+typedef struct _MLX4_DEV uefi_Dev_t;
+typedef int (*f_fw_cmd) (uefi_Dev_t* dev, void* buffer, int* size);
 
 /////////////////////////////////////////////
 //
@@ -221,7 +82,7 @@ typedef struct flash_attr {
 /////////////////////////////////////////////
 
 struct mfile_t;
-typedef struct mflash mflash;
+
 
 //
 // open/close functions:
@@ -248,8 +109,6 @@ int     mf_open        (mflash** pmfl, const char* dev, int num_of_banks, flash_
 int     mf_opend       (mflash** pmfl, struct mfile_t* mf, int num_of_banks,  flash_params_t* flash_params,
         int ignore_cache_rep_guard);
 
-typedef struct _MLX4_DEV uefi_Dev_t;
-typedef int (*f_fw_cmd) (uefi_Dev_t* dev, void* buffer, int* size);
 int     mf_open_uefi(mflash** pmfl, uefi_Dev_t *uefi_dev, f_fw_cmd fw_cmd_func);
 
 int     mf_open_ignore_lock(mflash* mfl);
@@ -283,6 +142,9 @@ int     mf_get_quad_en (mflash *mfl, u_int8_t *quad_en);
 int     mf_set_write_protect(mflash *mfl, u_int8_t bank_num, write_protect_info_t *protect_info);
 int     mf_get_write_protect(mflash *mfl, u_int8_t bank_num, write_protect_info_t *protect_info);
 
+int     mf_set_dummy_cycles (mflash *mfl, u_int8_t num_of_cycles);
+int     mf_get_dummy_cycles (mflash *mfl, u_int8_t *num_of_cycles);
+
 //
 // Set/Get for some options.
 //
index a48cf653178f90e0e13c828fedb5a71534518ac7..f28ed0f859693e904902f215341c045d1bedbc7e 100755 (executable)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  */
 
 
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "mflash.h"
-#include "mflash_common.h"
-#include "mflash_inband.h"
-#include "mflash_access_layer.h"
-
+#include "mtcr.h"
+#include "reg_access.h"
 
-#ifdef NO_INBAND_ACCESS
-
-int sx_get_flash_info_by_type(mflash* mfl, unsigned *type_index, int *log2size, u_int8_t *no_flash)
-{
-    mfl = NULL;
-    type_index = NULL;
-    log2size = NULL;
-    no_flash = NULL;
-    return MFE_NOT_SUPPORTED_OPERATION;
-}
-
-int sx_block_read_by_type(mflash* mfl, u_int32_t blk_addr, u_int32_t blk_size, u_int8_t* data)
-{
-    mfl = NULL;
-    blk_addr = 0;
-    blk_size = 0;
-    data = NULL;
-
-    return MFE_NOT_SUPPORTED_OPERATION;
-}
-
-int sx_block_write_by_type(mflash* mfl, u_int32_t addr, u_int32_t size, u_int8_t* data)
-{
-    mfl = NULL;
-    addr = 0;
-    size = 0;
-    data = NULL;
-    return MFE_NOT_SUPPORTED_OPERATION;
-}
-
-int sx_flash_lock_by_type(mflash* mfl, int lock_state)
-{
-    mfl = NULL;
-    lock_state = 0;
-    return MFE_NOT_SUPPORTED_OPERATION;
-}
+#include "mflash_types.h"
+#include "mflash_pack_layer.h"
+#include "mflash_access_layer.h"
 
-int sx_erase_sect_by_type(mflash* mfl, u_int32_t addr)
+ // On windows we don't support cmdIf access!
+int check_access_type(mflash* mfl)
+//TODO: re-write in a more elegant way.
 {
-    mfl = NULL;
-    addr = 0;
-    return MFE_NOT_SUPPORTED_OPERATION;
+    if (mfl->access_type == MFAT_MFILE) {
+        if ( mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] == ATBM_INBAND) {
+#ifdef NO_INBAND_ACCESS
+               return MFE_NOT_SUPPORTED_OPERATION;
+#endif
+#ifndef _WIN_
+        } else if ( mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] == ATBM_MLNXOS_CMDIF) {
+#endif
+        } else if ( mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] == ATBM_ICMD) {
+        } else {
+            return MFE_UNKOWN_ACCESS_TYPE;
+        }
+       } else if (mfl->access_type == MFAT_UEFI) {
+    } else {
+        return MFE_UNKOWN_ACCESS_TYPE;
+    }
+    return MFE_OK;
 }
 
-#else
 
 int sx_get_flash_info_by_type(mflash* mfl, unsigned *type_index, int *log2size, u_int8_t *no_flash)
 {
@@ -94,12 +72,10 @@ int sx_get_flash_info_by_type(mflash* mfl, unsigned *type_index, int *log2size,
     u_int8_t vendor, type, capacity;
     u_int32_t jedec_id;
 
-    rc = mfi_get_jedec(mfl->cmdif_context, (mfl->curr_bank), &jedec_id);
-    CHECK_RC(rc);
-
+    rc = check_access_type( mfl); CHECK_RC(rc);
+    rc = com_get_jedec(mfl->mf, mfl->curr_bank, &jedec_id); CHECK_RC(rc);
     //printf("-D- jedec_id = %#x\n", jedec_id);
     rc = get_info_from_jededc_id(jedec_id, &vendor, &type, &capacity); CHECK_RC(rc);
-
     // Return there is no flash when all the params are 0xff
     if (vendor == 0xff && type == 0xff && capacity == 0xff) {
         *no_flash = 1;
@@ -121,8 +97,10 @@ int sx_block_read_by_type(mflash* mfl, u_int32_t blk_addr, u_int32_t blk_size, u
     }
     rc = mfl_get_bank_info(mfl, blk_addr, &flash_offset, &bank); CHECK_RC(rc);
     COM_CHECK_ALLIGN(flash_offset, blk_size);
-    rc = mfi_read_block(mfl->cmdif_context, flash_offset, bank, blk_size, data);
-    CHECK_RC(rc);
+
+    rc = check_access_type( mfl); CHECK_RC(rc);
+    rc = sx_st_block_access(mfl->mf, flash_offset, bank, blk_size, data, REG_ACCESS_METHOD_GET);CHECK_RC(rc);
+
     return MFE_OK;
 }
 
@@ -133,19 +111,20 @@ int sx_block_write_by_type(mflash* mfl, u_int32_t addr, u_int32_t size, u_int8_t
 
     WRITE_CHECK_ALLIGN(addr, mfl->attr.block_write, size);
 
+
     rc = mfl_get_bank_info(mfl, addr, &flash_offset, &bank); CHECK_RC(rc);
     COM_CHECK_ALLIGN(flash_offset, size);
-    rc = mfi_write_block(mfl->cmdif_context, flash_offset, bank, size, data);
-    CHECK_RC(rc);
+
+    rc = check_access_type( mfl); CHECK_RC(rc);
+    rc = sx_st_block_access(mfl->mf, flash_offset, bank, size, data, REG_ACCESS_METHOD_SET);CHECK_RC(rc);
     return MFE_OK;
 }
 
 int sx_flash_lock_by_type(mflash* mfl, int lock_state)
 {
-       int rc;
-    rc = mfi_flash_lock(mfl->cmdif_context, lock_state);
-    CHECK_RC(rc);
-
+       //AdrianC: this is not implemented for some reason
+       (void)mfl;
+       (void)lock_state;
     return MFE_OK;
 }
 
@@ -154,46 +133,25 @@ int sx_erase_sect_by_type(mflash* mfl, u_int32_t addr)
     int rc, bank;
     u_int32_t flash_addr;
 
-    rc = mfl_get_bank_info(mfl, addr, &flash_addr, &bank);
-    CHECK_RC(rc);
-    rc = mfi_erase_sector(mfl->cmdif_context, flash_addr, bank);
-    CHECK_RC(rc);
-
+    rc = mfl_get_bank_info(mfl, addr, &flash_addr, &bank); CHECK_RC(rc);
+    rc = check_access_type( mfl); CHECK_RC(rc);
+    rc = common_erase_sector(mfl->mf, flash_addr, bank); CHECK_RC(rc);
     return MFE_OK;
 }
 
-#endif
-
-#define BOOT_CR_SPACE_ADDR 0xf0000
-#define ATBM_MLNXOS_CMDIF 2
 int     mf_update_boot_addr_by_type(mflash* mfl, u_int32_t boot_addr)
 {
     int rc;
     if (mfl->access_type == MFAT_UEFI || mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] == ATBM_MLNXOS_CMDIF) {
-        return MFE_NOT_SUPPORTED_OPERATION;
-    } else {
-        rc = mf_cr_write(mfl, BOOT_CR_SPACE_ADDR, ((boot_addr << 8) | 0x06)); CHECK_RC(rc);
-    }
-    return MFE_OK;
-}
-
-////////////////////////////   Function that sends mads //////////////////////////////////////
-int maccess_reg_mad_wrapper(flash_access_t *facces, u_int8_t *data, int w_cmdif_size, int r_cmdif_size)
-{
-       //avoid warnings
-       w_cmdif_size=0;
-       r_cmdif_size=0;
-       //
-
-    int rc;
-    if (facces->access_type == FWACCESS_INBAND) {
-        rc = maccess_reg_mad(facces->mf, data);
-        if (rc) {
-            //printf("-E- 2. Access reg mad failed with rc = %#x\n", rc);
-            return MFE_REG_ACCESS_FAILED;
-        }
-    } else {
-        return MFE_NOT_IMPLEMENTED;
+       // for inband or cib fwaccess return MFE_NOT_IMPLEMENTED
+       // for cmdIF fwaccess i.e mlnxOS update boot addr via reg access
+       if (mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] == ATBM_INBAND || mfl->opts[MFO_FW_ACCESS_TYPE_BY_MFILE] == ATBM_ICMD) {
+               return MFE_NOT_IMPLEMENTED;
+       }
+       else {
+       // uefi is supported and MLNXOS
+       rc = run_mfpa_command(mfl->mf, REG_ACCESS_METHOD_SET, mfl->curr_bank, boot_addr, NULL); CHECK_RC(rc);
+       }
     }
     return MFE_OK;
 }
index 2170affe4543187871efa0bc265d3b98b330bfc7..2d439735ee5542028d25dc91549e10b77653b1d8 100755 (executable)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- */
-
-
-/*
- * mflash_inband.h
  *
- *  Created on: Jul 6, 2011
- *      Author: mohammad
  */
 
+
 #ifndef MFLASH_ACCESS_LAYER_H_
 #define MFLASH_ACCESS_LAYER_H_
 
-#include <mtcr.h>
-
-#ifndef IRISC
-#define MFLASH_ERR_STR_SIZE 1024
-#else
-#define MFLASH_ERR_STR_SIZE    4
-#endif
-
-
-typedef int (*f_mf_lock)      (mflash* mfl, int lock_state);
-
-typedef int (*f_mf_set_bank)  (mflash* mfl, u_int32_t bank);
-typedef int (*f_mf_read)      (mflash* mfl, u_int32_t addr, u_int32_t len, u_int8_t* data);
-typedef int (*f_mf_write)     (mflash* mfl, u_int32_t addr, u_int32_t len, u_int8_t* data);
-typedef int (*f_mf_erase_sect)(mflash* mfl, u_int32_t addr);
-typedef int (*f_mf_reset)     (mflash* mfl);
-
-typedef int (*f_st_spi_status)(mflash* mfl, u_int8_t op_type, u_int8_t* status);
-typedef int (*f_mf_get_info)  (mflash* mfl, unsigned *type_index, int *log2size, u_int8_t *no_flash);
-
-struct mflash {
-#ifndef IRISC
-    mfile*      mf;
-#endif
-
-    // Functions:
-    f_mf_lock       f_lock;
-
-    f_mf_set_bank   f_set_bank;
-    f_mf_get_info   f_get_info;
-
-    f_mf_read       f_read;
-    f_mf_write      f_write;
-    f_mf_write      f_write_blk;   // write and write_block have the same signateure, but theyr'e not the same func !
-    f_mf_read       f_read_blk;    // read  and read_block have the same signateure, but theyr'e not the same func !
-    f_mf_erase_sect f_erase_sect;
-    f_mf_reset      f_reset;
-
-    // Relevant for SPI flash (InfiniHostIIILx, ConnectX) only.
-    f_st_spi_status f_spi_status;
-
-    int             curr_bank;
-    int             is_locked;
-
-    flash_attr      attr;
-
-    int             opts[MFO_LAST];
-    char            last_err_str[MFLASH_ERR_STR_SIZE];
-
-    u_int8_t   access_type;
-    uefi_Dev_t *uefi_dev;
-    f_fw_cmd   uefi_cmd_func;
-
-    gcif_dev_t *cif_dev;
-    void* cmdif_context;
+#include <compatibility.h>
+//#include "cib_cif.h"
 
-};
+#include "mflash_common_structs.h"
 
+#define BOOT_CR_SPACE_ADDR 0xf0000
 
 int sx_get_flash_info_by_type(mflash* mfl, unsigned *type_index, int *log2size, u_int8_t *no_flash);
 int sx_block_read_by_type(mflash* mfl, u_int32_t blk_addr, u_int32_t blk_size, u_int8_t* data);
@@ -106,7 +48,6 @@ int sx_block_write_by_type(mflash* mfl, u_int32_t addr, u_int32_t size, u_int8_t
 int sx_flash_lock_by_type(mflash* mfl, int lock_state);
 int sx_erase_sect_by_type(mflash* mfl, u_int32_t addr);
 int mf_update_boot_addr_by_type(mflash* mfl, u_int32_t boot_addr);
-int maccess_reg_mad_wrapper(flash_access_t *facces, u_int8_t *data, int w_cmdif_size, int r_cmdif_size);
 
 
 #endif /* MFLASH_ACCESS_LAYER_H_ */
diff --git a/mflash/mflash_common.c b/mflash/mflash_common.c
deleted file mode 100755 (executable)
index 404b665..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "mflash.h"
-#include "mflash_common.h"
-#include "mflash_inband.h"
-
-int init_operation_tlv(struct OperationTlv *operation_tlv, u_int16_t reg_id, u_int8_t method)
-{
-    memset(operation_tlv, 0, sizeof(*operation_tlv));
-
-    operation_tlv->Type        = TLV_OPERATION;
-    operation_tlv->class       = MAD_CLASS_REG_ACCESS;
-    operation_tlv->len         = TLV_OPERATION_SIZE;
-    operation_tlv->method      = method;
-    operation_tlv->register_id = reg_id;
-    return MFE_OK;
-}
-
-int get_reg_info_by_id(u_int16_t reg_id, reg_info_t *reg_info)
-{
-    u_int32_t i;
-    reg_info_t reg_info_arr[] = {
-            {REG_ID_MFPA, RTL_MFPA_LEN, (f_reg_pack)mfpa_pack,     (f_reg_unpack)mfpa_unpack,     (f_reg_dump)mfpa_dump},
-            {REG_ID_MFBA, RTL_MFBA_LEN, (f_reg_pack)mfba_mad_pack, (f_reg_unpack)mfba_mad_unpack, (f_reg_dump)mfba_mad_dump},
-            {REG_ID_MFBE, RTL_MFBE_LEN, (f_reg_pack)mfbe_pack,     (f_reg_unpack)mfbe_unpack,     (f_reg_dump)mfbe_dump},
-    };
-
-    for (i = 0; i < ARR_SIZE(reg_info_arr); i++) {
-        reg_info_t curr_reg = reg_info_arr[i];
-        if (reg_id == curr_reg.id) {
-            *reg_info = curr_reg;
-            return MFE_OK;
-        }
-    }
-    return MFE_UNKNOWN_REG;
-}
-
-
-int sx_st_block_access(flash_access_t *faccess, u_int32_t flash_addr, u_int8_t bank, u_int32_t size, u_int8_t* data,
-        u_int8_t method)
-{
-    struct mfba_mad    mfba;
-    int rc;
-    u_int32_t max_size = CMDIF_MAX_BLOCK_WRITE;
-
-    if (faccess->access_type == FWACCESS_INBAND) {
-        max_size = INBAND_MAX_BLOCK_WRITE;
-    }
-
-    if (size > max_size) {
-        return MFE_BAD_PARAMS;
-    }
-
-    // rc = set_bank(mfl, addr); CHECK_RC(rc);
-    //rc = get_flash_offset(addr, mfl->attr.log2_bank_size, &flash_addr); CHECK_RC(rc);
-
-
-    // Init mfba
-    memset(&mfba, 0, sizeof(mfba));
-    mfba.address = flash_addr;
-    mfba.fs      = bank;
-    mfba.size    = size;
-
-    if (method == MAD_METHOD_WRITE) {
-        u_int32_t i;
-        for (i = 0; i < size/4; i++) {
-            mfba.data[i] = __le32_to_cpu(*((u_int32_t*)&(data[4*i])));
-        }
-    }
-
-    rc = mfi_reg_access_mad(faccess, REG_ID_MFBA, method, &mfba, 0); CHECK_RC(rc);
-
-    // Get data from mfba
-    if (method == MAD_METHOD_QUERY) {
-        u_int32_t i;
-        for (i = 0; i < size/4; i++) {
-            *((u_int32_t*)&(data[i*4]))= __cpu_to_le32(mfba.data[i]);
-        }
-    }
-    return MFE_OK;
-}
-
-
-int common_erase_sector(flash_access_t *faccess, u_int32_t addr, u_int8_t flash_bank)
-{
-    struct mfbe    mfbe;
-
-    memset(&mfbe, 0, sizeof(mfbe));
-    mfbe.address = addr;
-    mfbe.fs      = flash_bank;
-    return mfi_reg_access_mad(faccess, REG_ID_MFBE, MAD_METHOD_WRITE, &mfbe, 0);
-}
-
-
-
-int run_mfpa_command(flash_access_t *faccess, u_int8_t access_cmd, u_int8_t flash_bank, u_int32_t boot_address, u_int32_t *jedec_p)
-{
-    struct mfpa    mfpa;
-    int rc;
-
-    memset(&mfpa, 0, sizeof(mfpa));
-    mfpa.fs = flash_bank;
-
-    if (access_cmd == MAD_METHOD_WRITE) {
-        mfpa.boot_address = boot_address;
-    }
-
-    rc = mfi_reg_access_mad(faccess, REG_ID_MFPA, access_cmd, &mfpa, 0); CHECK_RC(rc);
-
-    if (access_cmd == MAD_METHOD_QUERY && jedec_p != NULL) {
-        *jedec_p = mfpa.jedec_id;
-        // HACK: FW had a bug and returned the same jedec-ID even there was no flash, so when flash doesn't exist jedec will be modified to 0xffffffff
-        if (flash_bank >= mfpa.flash_num) {
-            *jedec_p = 0xffffffff;
-        }
-    }
-    return MFE_OK;
-}
-
-int com_get_jedec(flash_access_t *faccess, u_int8_t flash_bank, u_int32_t *jedec_p)
-{
-    return run_mfpa_command(faccess, MAD_METHOD_QUERY, flash_bank, 0, jedec_p);
-}
diff --git a/mflash/mflash_common.h b/mflash/mflash_common.h
deleted file mode 100755 (executable)
index f948bec..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-
-/*
- * mflash_inband.h
- *
- *  Created on: Jul 6, 2011
- *      Author: mohammad
- */
-
-#ifndef MFLASH_COMMON_H_
-#define MFLASH_COMMON_H_
-
-#include <mtcr.h>
-#include "internal_packets.h"
-
-#ifndef MST_UL
-       #include "cib_cif.h"
-#else
-       typedef void gcif_dev_t;
-#endif
-
-#define CMDIF_MAX_BLOCK_WRITE  128
-#define ICMD_MAX_BLOCK_WRITE   128
-#define INBAND_MAX_BLOCK_WRITE 32
-
-#ifndef CHECK_RC
-    #define CHECK_RC(rc) do {if (rc) return rc;} while(0)
-#endif
-
-#ifndef ARR_SIZE
-    #define ARR_SIZE(arr) sizeof(arr)/sizeof(arr[0])
-#endif
-
-enum {
-    FWACCESS_INBAND = 0,
-    FWACCESS_UEFI,
-    FWACCESS_GCIF,
-    FWACCESS_ALL,
-};
-
-#ifndef __WIN__
-
-#ifdef __FreeBSD__
-#define SWAPL(l) ntohl(l)
-#include <sys/endian.h>
-#else // Linux
-#include <byteswap.h>
-#include <endian.h>
-
-#define SWAPL(l) bswap_32(l)
-#endif
-
-#else
-
-#include <io.h>
-#include <Winsock2.h>
-#define SWAPL(l) ntohl(l)
-#define __BYTE_ORDER __LITTLE_ENDIAN
-/*
-#define __cpu_to_be32(val) SWAPL(val) // Win is only run on LE CPUS
-#define inline __inline
-#define __cpu_to_be32(val) SWAPL(val) // Win is only run on LE CPUS
-*/
-#endif
-
-#ifndef __cpu_to_le32
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-    #define __cpu_to_le32(x) (x)
-#elif __BYTE_ORDER == __BIG_ENDIAN
-    #define __cpu_to_le32(x) SWAPL(x)
-#endif // __BYTE_ORDER
-
-#endif
-
-#ifndef __le32_to_cpu
-    #define __le32_to_cpu(x) __cpu_to_le32(x)
-#endif
-
-#ifndef UEFI_BUILD
-    #define _ENABLE_MFLASH_INBAND_DEBUG 1
-#endif
-
-typedef struct flash_access {
-    mfile *mf;
-    u_int8_t access_type; // 0 = mf, 1 = uefi
-    uefi_Dev_t *uefi_dev;
-    f_fw_cmd fw_cmd_func;
-    gcif_dev_t *gcif_dev;
-} flash_access_t;
-
-enum {
-    MAD_METHOD_QUERY = 1,
-    MAD_METHOD_WRITE = 2,
-};
-enum {
-    MAD_CLASS_REG_ACCESS = 1,
-};
-enum {
-    TLV_END       = 0,
-    TLV_OPERATION = 1,
-    TLV_DR        = 2,
-    TLV_REG       = 3,
-    TLV_USER_DATA = 4,
-};
-enum {
-    REG_ID_MFPA = 0x9010,
-    REG_ID_MFBA = 0x9011,
-    REG_ID_MFBE = 0x9012,
-};
-
-enum {
-    RTL_MFPA_LEN = 9,
-    RTL_INBAND_MFBA_LEN = 12,
-    RTL_MFBA_LEN = 36,
-    RTL_MFBE_LEN = 4,
-};
-
-#define WRITE_CHECK_ALLIGN(addr, block_write, size) {\
-    if (addr & ((u_int32_t)block_write - 1)) {\
-        return MFE_BAD_ALIGN;\
-    }\
-    if (size & ((u_int32_t)block_write - 1)) {\
-         return MFE_BAD_ALIGN;\
-    }\
-}
-
-#define COM_CHECK_ALLIGN(flash_addr, size) {\
-    if (flash_addr & (size - 1 )) {\
-        return MFE_BAD_ALIGN;\
-    }\
-}
-
-#define TLV_OPERATION_SIZE 4
-#define OP_TLV_SIZE        16
-#define REG_RLV_HEADER_LEN 4
-
-//////////////////////////////////// SX FLASH functions ////////////////////////////////////
-
-typedef u_int32_t (*f_reg_pack)   (void *data_to_pack,  u_int8_t *packed_buffer);
-typedef void      (*f_reg_unpack) (void *unpacked_data, u_int8_t *buffer_to_unpack);
-typedef void      (*f_reg_dump)   (void *data_to_print, FILE *out_port);
-
-typedef struct reg_info {
-    u_int16_t    id;
-    u_int16_t    len;
-    f_reg_pack   pack_func;
-    f_reg_unpack unpack_func;
-    f_reg_dump   dump_func;
-} reg_info_t;
-
-
-int init_operation_tlv(struct OperationTlv *operation_tlv, u_int16_t reg_id, u_int8_t method);
-
-int get_reg_info_by_id(u_int16_t reg_id, reg_info_t *reg_info);
-
-int sx_st_block_access(flash_access_t *faccess, u_int32_t flash_addr, u_int8_t bank, u_int32_t size, u_int8_t* data,
-        u_int8_t method);
-
-int common_erase_sector(flash_access_t *faccess, u_int32_t addr, u_int8_t flash_bank);
-
-int run_mfpa_command(flash_access_t *faccess, u_int8_t access_cmd, u_int8_t flash_bank, u_int32_t boot_address, u_int32_t *jedec_p);
-
-int com_get_jedec(flash_access_t *faccess, u_int8_t flash_bank, u_int32_t *jedec_p);
-int get_info_from_jededc_id(u_int32_t jededc_id, u_int8_t *vendor, u_int8_t* type, u_int8_t* capacity);
-int get_type_index_by_vendor_and_type(u_int8_t vendor, u_int8_t type, unsigned *type_index);
-int get_log2size_by_capcity(unsigned type_index, u_int8_t capacity, int *log2size);
-int mfl_get_bank_info(mflash *mfl, u_int32_t addr, u_int32_t *flash_off_p, int *bank_p);
-
-#endif /* MFLASH_COMMON_H_ */
diff --git a/mflash/mflash_common_structs.h b/mflash/mflash_common_structs.h
new file mode 100644 (file)
index 0000000..9b413cf
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * mflash_common_structs.h - Mellanox Technilogies LTD. Flash access lib heared file
+ * 
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef MFLASH_COMMON_STRUCTS_H
+#define MFLASH_COMMON_STRUCTS_H
+
+typedef struct mflash mflash;
+
+typedef enum MfOpt {
+    MFO_NO_VERIFY = 0,
+    MFO_AMD_UNLOCK_BYPASS,
+    MFO_AMD_BYTE_MODE,
+    MFO_IGNORE_SEM_LOCK,
+    MFO_CLOSE_MF_ON_EXIT,
+    MFO_NUM_OF_BANKS,
+    MFO_IGNORE_CASHE_REP_GUARD,
+    MFO_USER_BANKS_NUM,
+    MFO_FW_ACCESS_TYPE_BY_MFILE,
+    MFO_SX_TYPE,
+    MFO_NEW_CACHE_REPLACEMENT_EN,
+    MFO_LAST
+} MfOpt;
+
+enum MfAccessType {
+    MFAT_MFILE = 0,
+    MFAT_UEFI,
+};
+
+/////////////////////////////////////////////
+//
+// Flash attributes struct
+//
+/////////////////////////////////////////////
+typedef struct flash_attr {
+    const char *type_str;
+    //
+    // hw_dev_id    hw dev id of the HCA.
+    //
+    u_int32_t hw_dev_id;
+    u_int32_t rev_id;
+
+    //
+    // size:        Total size (in bytes) of all flash devices connected to
+    //              the device (forming a contigous address space)
+    //
+    u_int32_t size;
+
+    //
+    // sector_size: Flash sector size (in bytes).
+    //              Assuming a single sector size for the flash.
+    //
+    u_int32_t sector_size;
+
+    int       num_erase_blocks;         // Number of sector defs.
+    struct {
+        unsigned long sector_size;      // Byte size of sector
+        int           num_sectors;      // Num sectors of this size
+        u_int32_t     sector_mask;      // Sector mask
+    } erase_block[8];
+
+    //
+    // bank_size:   Different bank means a different chip sellect or gpio settings is needed when crossing
+    //              this alignment.
+    //              This may indicate a different flash device (for SPI flash in InfiniHostIIILx / ConnectX).
+    //              Or GPIO change for parallel flash (in InfiniHostIII / InfiniHost)
+    //
+    int bank_size;
+    int log2_bank_size;
+
+    //
+    // Command set (taken from CFI terminology)
+    //
+    int command_set;
+
+    u_int8_t erase_command;
+
+    //
+    // block_write - if block write is supported, holds the block size in bytes. 0 otherwise.
+    //               The meaning of "block write" is not the same in parallel and serial flash.
+    //
+    int block_write;
+
+    //
+    // page_write -  if page write is supported, holds the page size in bytes. 0 otherwise.
+    //
+    int page_write;
+
+    u_int8_t banks_num;
+    u_int8_t quad_en_support;
+    u_int8_t dummy_cycles_support;
+    u_int8_t write_protect_support;
+    u_int8_t protect_sub_and_sector;
+    u_int8_t vendor;
+    u_int8_t type;
+
+
+} flash_attr;
+
+#endif // MFLASH_COMMON_STRUCTS_H
+
+
+
diff --git a/mflash/mflash_inband.c b/mflash/mflash_inband.c
deleted file mode 100755 (executable)
index cc1666f..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- * 
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- * 
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- * 
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "mflash.h"
-#include "mflash_common.h"
-#include "mflash_access_layer.h"
-#include "mflash_inband.h"
-
-
-int mfi_reg_access_mad(flash_access_t *faccess, u_int16_t reg_id, u_int8_t method, void *reg, u_int8_t debug)
-{
-    int rc, mad_rc, cmdif_size = 0, wcmdif_size, rcmdif_size;
-    struct OperationTlv tlv;
-    struct reg_tlv tlv_info;
-    u_int8_t buffer[1024];
-    reg_info_t reg_info;
-
-    rc = get_reg_info_by_id(reg_id, &reg_info); CHECK_RC(rc);
-
-    init_operation_tlv(&(tlv), reg_id, method);
-    // Fill Reg TLV
-    memset(&tlv_info, 0, sizeof(tlv_info));
-    tlv_info.Type = TLV_REG;
-    tlv_info.len  = reg_info.len;
-
-    // The max MAD buffer size is 64 so max data that can be read is only 32 byte
-    if ((reg_id == REG_ID_MFBA && faccess->access_type == FWACCESS_INBAND )||
-        (reg_id == REG_ID_MFBA && faccess->access_type == FWACCESS_UEFI) ) {
-        tlv_info.len  = RTL_INBAND_MFBA_LEN;
-    }
-
-    // Pack the mad
-
-    cmdif_size += OperationTlv_pack(&tlv, buffer);
-    cmdif_size += reg_tlv_pack(&tlv_info, buffer + OP_TLV_SIZE);
-    cmdif_size += reg_info.pack_func(reg, buffer + OP_TLV_SIZE + REG_RLV_HEADER_LEN);
-#ifdef _ENABLE_MFLASH_INBAND_DEBUG
-    if (debug) {
-        printf("-I- The sent MAD content\n");
-        OperationTlv_dump(&tlv, stdout);
-        reg_tlv_dump(&tlv_info, stdout);
-        reg_info.dump_func(reg, stdout);
-    }
-#endif
-    // printf("-D- reg_info.len = |%d, OP_TLV: %d, REG_TLV= %d, cmdif_size = %d\n", reg_info.len, OP_TLV_SIZE, REG_RLV_HEADER_LEN, cmdif_size);
-    wcmdif_size = cmdif_size;
-    rcmdif_size = cmdif_size;
-
-    // Improve the performance by not writing data in read to icmd buffer or not reading in write command
-
-    if (reg_id == REG_ID_MFBA) {
-        if (method == MAD_METHOD_QUERY) {
-            wcmdif_size = cmdif_size - CMDIF_MAX_BLOCK_WRITE;
-        } else {
-           rcmdif_size = cmdif_size - CMDIF_MAX_BLOCK_WRITE;
-        }
-    }
-
-    mad_rc = maccess_reg_mad_wrapper(faccess, buffer, wcmdif_size, rcmdif_size);
-    // Unpack the mad
-    OperationTlv_unpack(&tlv, buffer);
-    reg_tlv_unpack(&tlv_info, buffer + OP_TLV_SIZE);
-    reg_info.unpack_func(reg, buffer + OP_TLV_SIZE + REG_RLV_HEADER_LEN);
-
-
-#ifdef _ENABLE_MFLASH_INBAND_DEBUG
-    if (debug) {
-        printf("-I- The received MAD content\n");
-        OperationTlv_dump(&tlv, stdout);
-        reg_tlv_dump(&tlv_info, stdout);
-        reg_info.dump_func(reg, stdout);
-    }
-#endif
-    // Check the return value from
-    CHECK_RC(mad_rc);
-    if (tlv.status) {
-
-        // printf("-E- Access reg mad failed with tlv status = %#x\n", tlv.status);
-        switch (tlv.status) {
-        case 0x4:
-            return MFE_REG_ACCESS_MAD_NOT_SUPPORTED;
-        case 0x8:
-            return MFE_REG_ACCESS_RESOURCE_NOT_AVAILABLE;
-        default:
-            // printf("-D- status = %d\n", tlv.status);
-            return MFE_REG_ACCESS_MAD_BAD_STATUS;
-        }
-    }
-    return MFE_OK;
-}
-
-int mfi_erase_sector(mfile *mf, u_int32_t addr, u_int8_t flash_bank)
-{
-    flash_access_t faccess;
-    faccess.mf = mf;
-    faccess.access_type = FWACCESS_INBAND;
-    return common_erase_sector(&faccess, addr, flash_bank);
-}
-
-
-int mfi_get_jedec(mfile *mf, u_int8_t flash_bank, u_int32_t *jedec_p)
-{
-    flash_access_t faccess;
-    faccess.mf = mf;
-    faccess.access_type = FWACCESS_INBAND;
-    return com_get_jedec(&faccess, flash_bank, jedec_p);
-}
-
-int mfi_read_block(mfile *mf, u_int32_t addr, u_int8_t flash_bank, u_int32_t size, u_int8_t* data)
-{
-    flash_access_t faccess;
-    faccess.mf = mf;
-    faccess.access_type = FWACCESS_INBAND;
-    // printf("-D- mfi_read_block: addr = %#x, size = %d\n", addr, size);
-    return sx_st_block_access(&faccess, addr, flash_bank, size, data, MAD_METHOD_QUERY);
-}
-
-int mfi_write_block(mfile *mf, u_int32_t addr, u_int8_t flash_bank, u_int32_t size, u_int8_t* data)
-{
-    flash_access_t faccess;
-    faccess.mf = mf;
-    faccess.access_type = FWACCESS_INBAND;
-    return sx_st_block_access(&faccess, addr, flash_bank, size, data, MAD_METHOD_WRITE);
-}
-
-int mfi_flash_lock(mfile *mf, int lock_state)
-{
-    mf = NULL;
-    lock_state = 0;
-    return MFE_OK;
-}
-
-int mfi_update_boot_addr(mfile *mf, u_int8_t flash_bank, u_int32_t boot_addr)
-{
-    mf = NULL;
-    flash_bank = 0;
-    boot_addr = 0;
-    return MFE_NOT_IMPLEMENTED;
-}
diff --git a/mflash/mflash_inband.h b/mflash/mflash_inband.h
deleted file mode 100755 (executable)
index ed2c104..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- * 
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- * 
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- * 
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-
-/*
- * mflash_inband.h
- *
- *  Created on: Jul 6, 2011
- *      Author: mohammad
- */
-
-#ifndef MFLASH_INBAND_H_
-#define MFLASH_INBAND_H_
-
-#include <mtcr.h>
-#include "mflash_common.h"
-
-int mfi_reg_access_mad(flash_access_t *faccess, u_int16_t reg_id, u_int8_t method, void *reg, u_int8_t debug);
-
-int mfi_erase_sector(mfile *mf, u_int32_t addr, u_int8_t flash_bank);
-
-int mfi_get_jedec(mfile *mf, u_int8_t flash_bank, u_int32_t *jedec_p);
-
-int mfi_read_block(mfile *mf, u_int32_t addr, u_int8_t flash_bank, u_int32_t size, u_int8_t* data);
-
-int mfi_write_block(mfile *mf, u_int32_t blk_addr, u_int8_t flash_bank, u_int32_t size, u_int8_t* data);
-
-int mfi_flash_lock(mfile *mf, int lock_state);
-
-int mfi_update_boot_addr(mfile *mf, u_int8_t flash_bank, u_int32_t boot_addr);
-
-#endif /* MFLASH_INBAND_H_ */
diff --git a/mflash/mflash_pack_layer.c b/mflash/mflash_pack_layer.c
new file mode 100755 (executable)
index 0000000..2fbdd4f
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "compatibility.h"
+#include "bit_slice.h"
+#include "mtcr.h"
+#include "reg_access.h"
+
+#include "mflash_types.h"
+#include "mflash_pack_layer.h"
+
+static MfError MError2MfError(MError rc);
+
+int sx_st_block_access(mfile *mf, u_int32_t flash_addr, u_int8_t bank, u_int32_t size, u_int8_t* data,
+        u_int8_t method)
+{
+    struct register_access_mfba mfba;
+    int rc;
+    int max_size = mget_max_reg_size(mf);
+    if (!max_size) {
+       return MFE_BAD_PARAMS;
+    }
+    // when writing max size is limited to the nearest power of 2 of the max_size
+    // while limiting it to 256 bytes
+    max_size = NEAREST_POW2(max_size);
+
+
+    if (size > (u_int32_t)max_size) {
+        return MFE_BAD_PARAMS;
+    }
+
+    // Init mfba
+    memset(&mfba, 0, sizeof(mfba));
+    mfba.address = flash_addr;
+    mfba.fs      = bank;
+    mfba.size    = size;
+
+    if (method == REG_ACCESS_METHOD_SET) {
+        u_int32_t i;
+        for (i = 0; i < size/4; i++) {
+            mfba.data[i] = __le32_to_cpu(*((u_int32_t*)&(data[4*i])));
+        }
+    }
+    rc = reg_access_mfba (mf, (reg_access_method_t) method, &mfba); CHECK_RC(MError2MfError(rc));
+
+    // Get data from mfba
+    if (method == REG_ACCESS_METHOD_GET) {
+        u_int32_t i;
+        for (i = 0; i < size/4; i++) {
+            *((u_int32_t*)&(data[i*4]))= __cpu_to_le32(mfba.data[i]);
+        }
+    }
+    return MFE_OK;
+}
+
+
+int common_erase_sector(mfile *mf, u_int32_t addr, u_int8_t flash_bank)
+{
+       struct register_access_mfbe    mfbe;
+
+    memset(&mfbe, 0, sizeof(mfbe));
+    mfbe.address = addr;
+    mfbe.fs      = flash_bank;
+    return MError2MfError(reg_access_mfbe (mf, REG_ACCESS_METHOD_SET, &mfbe));
+}
+
+int run_mfpa_command(mfile *mf, u_int8_t access_cmd, u_int8_t flash_bank, u_int32_t boot_address, u_int32_t *jedec_p)
+{
+       struct register_access_mfpa    mfpa;
+    int rc;
+
+    memset(&mfpa, 0, sizeof(mfpa));
+    mfpa.fs = flash_bank;
+
+    if (access_cmd == REG_ACCESS_METHOD_SET) {
+        mfpa.boot_address = boot_address;
+    }
+    rc = reg_access_mfpa (mf, access_cmd, &mfpa); CHECK_RC(MError2MfError(rc));
+
+    if (access_cmd == REG_ACCESS_METHOD_GET && jedec_p != NULL) {
+        *jedec_p = mfpa.jedec_id;
+        // HACK: FW had a bug and returned the same jedec-ID even there was no flash, so when flash doesn't exist jedec will be modified to 0xffffffff
+        if (flash_bank >= mfpa.flash_num) {
+            *jedec_p = 0xffffffff;
+        }
+    }
+    return MFE_OK;
+}
+
+int com_get_jedec(mfile *mf, u_int8_t flash_bank, u_int32_t *jedec_p)
+{
+    return run_mfpa_command(mf, REG_ACCESS_METHOD_GET, flash_bank, 0, jedec_p);
+}
+
+int set_bank(mflash* mfl, u_int32_t addr) {
+    int bank = addr >> mfl->attr.log2_bank_size;
+
+    if (mfl->curr_bank != bank) {
+        mfl->curr_bank = bank;
+        return mfl->f_set_bank(mfl, bank);
+    }
+
+    return MFE_OK;
+}
+
+int get_flash_offset(u_int32_t addr, int log2_bank_size, u_int32_t *flash_addr_p)
+{
+    *flash_addr_p = addr & ONES32(log2_bank_size);
+    return MFE_OK;
+}
+
+int mfl_get_bank_info(mflash *mfl, u_int32_t addr, u_int32_t *flash_off_p, int *bank_p)
+{
+    int rc;
+    // Get the bank number
+    rc = set_bank(mfl, addr);                                           CHECK_RC(rc);
+    *bank_p = mfl->curr_bank;
+    // Get the offset in the flash
+    rc = get_flash_offset(addr, mfl->attr.log2_bank_size, flash_off_p); CHECK_RC(rc);
+    return MFE_OK;
+}
+
+static MfError MError2MfError(MError rc) {
+   switch(rc) {
+   case ME_OK:
+          return MFE_OK;
+   case ME_ERROR:
+          return MFE_ERROR;
+   case ME_BAD_PARAMS:
+          return MFE_BAD_PARAMS;
+   case ME_CR_ERROR:
+          return MFE_CR_ERROR;
+   case ME_NOT_IMPLEMENTED:
+          return MFE_NOT_IMPLEMENTED;
+   case ME_SEM_LOCKED:
+          return MFE_SEM_LOCKED;
+   case ME_MEM_ERROR:
+          return MFE_NOMEM;
+   case ME_MAD_SEND_FAILED:
+          return MFE_MAD_SEND_ERR;
+   case ME_UNKOWN_ACCESS_TYPE:
+          return MFE_UNKOWN_ACCESS_TYPE;
+   case ME_UNSUPPORTED_DEVICE:
+          return MFE_UNSUPPORTED_DEVICE;
+   case ME_ICMD_STATUS_CR_FAIL:
+          return MFE_CR_ERROR;
+   case ME_ICMD_STATUS_SEMAPHORE_TO:
+          return MFE_CMDIF_TIMEOUT_ERR;
+   case ME_ICMD_STATUS_EXECUTE_TO:
+          return MFE_CMDIF_TIMEOUT_ERR;
+   case ME_ICMD_STATUS_IFC_BUSY:
+          return MFE_CMDIF_TIMEOUT_ERR;
+   case ME_ICMD_STATUS_ICMD_NOT_READY:
+          return MFE_CMDIF_GO_BIT_BUSY;
+   case ME_ICMD_UNSUPPORTED_ICMD_VERSION:
+          return MFE_ICMD_NOT_SUPPORTED;
+   case ME_ICMD_NOT_SUPPORTED:
+          return MFE_ICMD_NOT_SUPPORTED;
+   case ME_ICMD_INVALID_OPCODE:
+       return MFE_ICMD_INVALID_OPCODE;
+   case ME_ICMD_INVALID_CMD:
+       return MFE_ICMD_INVALID_CMD;
+   case ME_ICMD_OPERATIONAL_ERROR:
+       return MFE_ICMD_OPERATIONAL_ERROR;
+   case ME_ICMD_BAD_PARAM:
+       return MFE_ICMD_BAD_PARAM;
+   case ME_ICMD_BUSY:
+       return MFE_CMDIF_TIMEOUT_ERR;
+
+   case ME_REG_ACCESS_BAD_METHOD:
+       return MFE_REG_ACCESS_BAD_METHOD;
+   case ME_REG_ACCESS_NOT_SUPPORTED:
+       return MFE_REG_ACCESS_NOT_SUPPORTED;
+   case ME_REG_ACCESS_DEV_BUSY:
+       return MFE_REG_ACCESS_DEV_BUSY;
+   case ME_REG_ACCESS_VER_NOT_SUPP:
+       return MFE_REG_ACCESS_VER_NOT_SUPP;
+   case ME_REG_ACCESS_UNKNOWN_TLV:
+       return MFE_REG_ACCESS_UNKNOWN_TLV;
+   case ME_REG_ACCESS_REG_NOT_SUPP:
+       return MFE_REG_ACCESS_REG_NOT_SUPP;
+   case ME_REG_ACCESS_CLASS_NOT_SUPP:
+       return MFE_REG_ACCESS_CLASS_NOT_SUPP;
+   case ME_REG_ACCESS_METHOD_NOT_SUPP:
+       return MFE_REG_ACCESS_METHOD_NOT_SUPP;
+   case ME_REG_ACCESS_BAD_PARAM:
+       return MFE_REG_ACCESS_BAD_PARAM;
+   case ME_REG_ACCESS_RES_NOT_AVLBL:
+       return MFE_REG_ACCESS_RES_NOT_AVLBL;
+   case ME_REG_ACCESS_MSG_RECPT_ACK:
+       return MFE_REG_ACCESS_MSG_RECPT_ACK;
+   case ME_REG_ACCESS_UNKNOWN_ERR:
+       return MFE_REG_ACCESS_UNKNOWN_ERR;
+   case ME_REG_ACCESS_SIZE_EXCCEEDS_LIMIT:
+       return MFE_REG_ACCESS_SIZE_EXCCEEDS_LIMIT;
+   default:
+          break;
+   }
+   return MFE_INVAL;
+}
diff --git a/mflash/mflash_pack_layer.h b/mflash/mflash_pack_layer.h
new file mode 100755 (executable)
index 0000000..eb54b15
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef MFLASH_COMMON_H_
+#define MFLASH_COMMON_H_
+
+#include "mflash_common_structs.h"
+
+#define NEAREST_POW2(num)\
+       (num) < (256) ? ((num) < (128)? ((num) < (64) ? ((num) < (32) ? (16): (32)): (64)): (128)): (256);
+
+#ifndef CHECK_RC
+    #define CHECK_RC(rc) do {if (rc) return rc;} while(0)
+#endif
+
+#ifndef ARR_SIZE
+    #define ARR_SIZE(arr) sizeof(arr)/sizeof(arr[0])
+#endif
+
+#ifndef IRISC
+#define MFLASH_ERR_STR_SIZE 1024
+#else
+#define MFLASH_ERR_STR_SIZE    4
+#endif
+typedef int (*f_mf_lock)      (mflash* mfl, int lock_state);
+
+typedef int (*f_mf_set_bank)  (mflash* mfl, u_int32_t bank);
+typedef int (*f_mf_read)      (mflash* mfl, u_int32_t addr, u_int32_t len, u_int8_t* data);
+typedef int (*f_mf_write)     (mflash* mfl, u_int32_t addr, u_int32_t len, u_int8_t* data);
+typedef int (*f_mf_erase_sect)(mflash* mfl, u_int32_t addr);
+typedef int (*f_mf_reset)     (mflash* mfl);
+
+typedef int (*f_st_spi_status)(mflash* mfl, u_int8_t op_type, u_int8_t* status);
+typedef int (*f_mf_get_info)  (mflash* mfl, unsigned *type_index, int *log2size, u_int8_t *no_flash);
+/////////////////////////////////////////////
+//
+// MFlash struct
+//
+/////////////////////////////////////////////
+struct mflash {
+#ifndef IRISC
+       mfile*      mf;
+#endif
+
+       // Functions:
+       f_mf_lock       f_lock;
+
+       f_mf_set_bank   f_set_bank;
+       f_mf_get_info   f_get_info;
+
+       f_mf_read       f_read;
+       f_mf_write      f_write;
+       f_mf_write      f_write_blk;   // write and write_block have the same signateure, but theyr'e not the same func !
+       f_mf_read       f_read_blk;    // read  and read_block have the same signateure, but theyr'e not the same func !
+       f_mf_erase_sect f_erase_sect;
+       f_mf_reset      f_reset;
+
+       // Relevant for SPI flash (InfiniHostIIILx, ConnectX) only.
+       f_st_spi_status f_spi_status;
+
+       int             curr_bank;
+       int             is_locked;
+
+       flash_attr      attr;
+
+       int             opts[MFO_LAST];
+       char            last_err_str[MFLASH_ERR_STR_SIZE];
+
+       u_int8_t   access_type; //0 = mfile , 1 = uefi
+
+};
+
+enum AccessTypeByMfile{
+    ATBM_NO = 0,
+    ATBM_INBAND,
+    ATBM_MLNXOS_CMDIF,
+    ATBM_ICMD,
+};
+
+/*
+#ifndef __WIN__
+
+#ifdef __FreeBSD__
+#define SWAPL(l) ntohl(l)
+#include <sys/endian.h>
+#else // Linux
+#include <byteswap.h>
+#include <endian.h>
+
+#define SWAPL(l) bswap_32(l)
+#endif
+
+#else
+
+#include <io.h>
+#include <Winsock2.h>
+#define SWAPL(l) ntohl(l)
+#define __BYTE_ORDER __LITTLE_ENDIAN
+*/
+
+/*
+#define __cpu_to_be32(val) SWAPL(val) // Win is only run on LE CPUS
+#define inline __inline
+#define __cpu_to_be32(val) SWAPL(val) // Win is only run on LE CPUS
+*/
+//#endif
+
+/*
+#ifndef __cpu_to_le32
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+    #define __cpu_to_le32(x) (x)
+#elif __BYTE_ORDER == __BIG_ENDIAN
+    #define __cpu_to_le32(x) SWAPL(x)
+#endif // __BYTE_ORDER
+
+#endif
+
+#ifndef __le32_to_cpu
+    #define __le32_to_cpu(x) __cpu_to_le32(x)
+#endif
+*/
+
+#define WRITE_CHECK_ALLIGN(addr, block_write, size) {\
+    if (addr & ((u_int32_t)block_write - 1)) {\
+        return MFE_BAD_ALIGN;\
+    }\
+    if (size & ((u_int32_t)block_write - 1)) {\
+         return MFE_BAD_ALIGN;\
+    }\
+}
+
+#define COM_CHECK_ALLIGN(flash_addr, size) {\
+    if (flash_addr & (size - 1 )) {\
+        return MFE_BAD_ALIGN;\
+    }\
+}
+
+//////////////////////////////////// SX FLASH functions ////////////////////////////////////
+
+typedef u_int32_t (*f_reg_pack)   (void *data_to_pack,  u_int8_t *packed_buffer);
+typedef void      (*f_reg_unpack) (void *unpacked_data, u_int8_t *buffer_to_unpack);
+typedef void      (*f_reg_dump)   (void *data_to_print, FILE *out_port);
+
+int sx_st_block_access(mfile *mf, u_int32_t flash_addr, u_int8_t bank, u_int32_t size, u_int8_t* data,\
+               u_int8_t method);
+
+
+int common_erase_sector(mfile *mf, u_int32_t addr, u_int8_t flash_bank);
+
+int run_mfpa_command(mfile *mf, u_int8_t access_cmd, u_int8_t flash_bank, u_int32_t boot_address, u_int32_t *jedec_p);
+
+int com_get_jedec(mfile *mf, u_int8_t flash_bank, u_int32_t *jedec_p);
+int get_info_from_jededc_id(u_int32_t jededc_id, u_int8_t *vendor, u_int8_t* type, u_int8_t* capacity);
+int get_type_index_by_vendor_and_type(u_int8_t vendor, u_int8_t type, unsigned *type_index);
+int get_log2size_by_capcity(unsigned type_index, u_int8_t capacity, int *log2size);
+int get_max_reg_size(mfile *mf);
+
+int set_bank(mflash* mfl, u_int32_t addr);
+int get_flash_offset(u_int32_t addr, int log2_bank_size, u_int32_t *flash_addr_p);
+int mfl_get_bank_info(mflash *mfl, u_int32_t addr, u_int32_t *flash_off_p, int *bank_p);
+
+#endif /* MFLASH_COMMON_H_ */
diff --git a/mflash/mflash_types.h b/mflash/mflash_types.h
new file mode 100644 (file)
index 0000000..29e9ebd
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef MFLASH_TYPES_H
+#define MFLASH_TYPES_H
+
+typedef enum MfError {
+    MFE_OK = 0,
+    MFE_ERROR,
+    MFE_BAD_PARAMS,
+    MFE_CR_ERROR,
+    MFE_INVAL,
+    MFE_NOT_IMPLEMENTED,
+    MFE_UNSUPPORTED_FLASH_TOPOLOGY,
+    MFE_UNSUPPORTED_FLASH_TYPE,
+    MFE_CFI_FAILED,
+    MFE_TIMEOUT,
+    MFE_ERASE_TIMEOUT,
+    MFE_WRITE_TIMEOUT,
+    MFE_ERASE_ERROR,
+    MFE_WRITE_ERROR,
+    MFE_BAD_ALIGN,
+    MFE_SEM_LOCKED,
+    MFE_VERIFY_ERROR,
+    MFE_NOMEM,
+    MFE_OUT_OF_RANGE,
+    MFE_CMD_SUPPORTED_INBAND_ONLY,
+    MFE_NO_FLASH_DETECTED,
+    MFE_LOCKED_CRSPACE,
+    MFE_CMDIF_BAD_STATUS_ERR,
+    MFE_CMDIF_TIMEOUT_ERR,
+    MFE_CMDIF_GO_BIT_BUSY,
+    MFE_MISMATCH_KEY,
+    MFE_UNKNOWN_REG,
+    MFE_DIRECT_FW_ACCESS_DISABLED,
+    MFE_MANAGED_SWITCH_NOT_SUPPORTED,
+    MFE_NOT_SUPPORTED_OPERATION,
+    MFE_FLASH_NOT_EXIST,
+    MFE_MISMATCH_PARAM,
+    MFE_EXCEED_SUBSECTORS_MAX_NUM,
+    MFE_EXCEED_SECTORS_MAX_NUM,
+    MFE_SECTORS_NUM_NOT_POWER_OF_TWO,
+    MFE_UNKOWN_ACCESS_TYPE,
+    MFE_UNSUPPORTED_DEVICE,
+    MFE_OLD_DEVICE_TYPE,
+    MFE_ICMD_INIT_FAILED,
+    MFE_ICMD_NOT_SUPPORTED,
+    MFE_HW_ACCESS_NOT_SUPP,
+    MFE_MAD_SEND_ERR,
+    MFE_ICMD_BAD_PARAM,
+    MFE_ICMD_INVALID_OPCODE,
+    MFE_ICMD_INVALID_CMD,
+    MFE_ICMD_OPERATIONAL_ERROR,
+
+    MFE_REG_ACCESS_BAD_METHOD,
+    MFE_REG_ACCESS_NOT_SUPPORTED,
+    MFE_REG_ACCESS_DEV_BUSY,
+    MFE_REG_ACCESS_VER_NOT_SUPP,
+    MFE_REG_ACCESS_UNKNOWN_TLV,
+    MFE_REG_ACCESS_REG_NOT_SUPP,
+    MFE_REG_ACCESS_CLASS_NOT_SUPP,
+    MFE_REG_ACCESS_METHOD_NOT_SUPP,
+    MFE_REG_ACCESS_BAD_PARAM,
+    MFE_REG_ACCESS_RES_NOT_AVLBL,
+    MFE_REG_ACCESS_MSG_RECPT_ACK,
+    MFE_REG_ACCESS_UNKNOWN_ERR,
+    MFE_REG_ACCESS_SIZE_EXCCEEDS_LIMIT,
+
+
+
+
+    MFE_LAST
+} MfError;
+
+#endif // MFLASH_TYPES_H
+
+
+
diff --git a/mflash/packets_common.c b/mflash/packets_common.c
deleted file mode 100755 (executable)
index 78430da..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2004-2010 Mellanox Technologies LTD. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include "packets_common.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#ifdef __WIN__
-    #include <Winsock2.h>   // for htonl
-#endif
-
-
-/************************************/
-void push_to_buff_64(u_int8_t *buff, u_int32_t bit_offset, u_int64_t field_value)
-{
-#if defined(__ia64__)
-    u_int32_t *buffer = PTR_32_OF_BUFF(buff, (bit_offset / 8));
-    u_int64_t value = CPU_TO_BE64(field_value);
-    memcpy(buffer, &value, sizeof(value));
-#else
-    u_int64_t *buffer = PTR_64_OF_BUFF(buff, (bit_offset / 8));
-    memcpy(buffer, &field_value, sizeof(field_value));
-    *buffer = CPU_TO_BE64(*buffer);
-#endif
-}
-
-
-/************************************/
-void push_to_buff_32(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_value)
-{
-    u_int32_t *buffer = PTR_32_OF_BUFF(buff, (bit_offset / 8));
-    memcpy(buffer, &field_value, sizeof(field_value));
-    *buffer = CPU_TO_BE32(*buffer);
-}
-
-
-/************************************/
-//the next function will push the field into the buffer by inserting it's MSB bits first
-//and therefore by doing it we save the CPU_TO_BE operation
-void push_to_buff(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_size, u_int32_t field_value)
-{
-    u_int32_t i                = 0;
-    u_int32_t byte_n   = bit_offset / 8;
-    u_int32_t byte_n_offset    = bit_offset % 8;
-    u_int32_t to_push;
-
-    //going over all bits in field
-    while (i < field_size) {
-        to_push = PCK_MIN(8 - byte_n_offset, field_size - i);
-        i += to_push;
-        //printf("Inserting %u bits(%u) to byte %u to bit %u\n", to_push, EXTRACT8(field_value, field_size - i, to_push), byte_n, 8 - to_push - byte_n_offset);
-        INSERTF_8(BYTE_N(buff, byte_n), 8 - to_push - byte_n_offset, field_value, field_size - i, to_push);
-        byte_n_offset  = 0;    //(byte_n_offset + to_push) % 8;
-        byte_n++;
-    }
-}
-
-
-/************************************/
-u_int64_t pop_from_buff_64(u_int8_t *buff, u_int32_t bit_offset)
-{
-#if defined(__ia64__)
-    u_int64_t value = 0;
-    memcpy(&value, PTR_32_OF_BUFF(buff, (bit_offset / 8)), sizeof(u_int64_t));
-    return (BE64_TO_CPU(value));
-#else
-    return (BE64_TO_CPU(FIELD_64_OF_BUFF(buff, (bit_offset / 8))));
-#endif
-}
-
-
-/************************************/
-u_int32_t pop_from_buff_32(u_int8_t *buff, u_int32_t bit_offset)
-{
-    return (BE32_TO_CPU(FIELD_32_OF_BUFF(buff, (bit_offset / 8))));
-}
-
-
-/************************************/
-//the next function will pop the field into the buffer by removing it's MSB bits first
-//and therefore by doing it we save the BE_TO_CPU operation
-u_int32_t pop_from_buff(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_size)
-{
-    u_int32_t i                = 0;
-    u_int32_t byte_n   = bit_offset / 8;
-    u_int32_t byte_n_offset    = bit_offset % 8;
-    u_int32_t field_32 = 0;
-    u_int32_t to_pop;
-
-    //going over all bits in field
-    while (i < field_size) {
-        to_pop =  PCK_MIN(8 - byte_n_offset, field_size - i);
-        i += to_pop;
-        //printf("Removing %u bits(%u) from byte %u to bit %u\n", to_pop, EXTRACT8(BYTE_N(buff, byte_n), 8 - to_pop - byte_n_offset, to_pop), byte_n, field_size - i);
-        INSERTF_8(field_32, field_size - i, BYTE_N(buff, byte_n), 8 - to_pop - byte_n_offset, to_pop);
-        byte_n_offset  = 0;    //(byte_n_offset + to_pop) % 8;
-        byte_n++;
-    }
-    return field_32;
-}
-
-
diff --git a/mflash/packets_common.h b/mflash/packets_common.h
deleted file mode 100755 (executable)
index d485a36..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2004-2010 Mellanox Technologies LTD. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef packet_common_H
-#define packet_common_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#ifndef __WIN__
-    #include <netinet/in.h>
-/************************************/
-/* Endianess Defines */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-    #ifndef PLATFORM_MEM
-         // #define PLATFORM_MEM "Little Endianess"
-    #endif
-    #define _LITTLE_ENDIANESS
-#endif
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-    //#define PLATFORM_MEM "Big Endianess"
-    #define _BIG_ENDIANESS
-#endif
-
-#else
-    #define __BYTE_ORDER __LITTLE_ENDIAN
-    #ifndef PLATFORM_MEM
-        //#define PLATFORM_MEM "Big Endianess"
-    #endif
-    #define _BIG_ENDIANESS
-    typedef unsigned __int8  u_int8_t;
-    typedef __int8           int8_t;
-    typedef unsigned __int16 u_int16_t;
-    typedef __int16          int16_t;
-    typedef unsigned __int32 u_int32_t;
-    typedef __int32          int32_t;
-    typedef unsigned __int64 u_int64_t;
-    typedef __int64          int64_t;
-#endif
-
-
-
-/************************************/
-/* Bit manipulation macros */
-
-/* MASK generate a bit mask S bits width */
-//#define MASK32(S)     ( ((u_int32_t) ~0L) >> (32-(S)) )
-#define MASK8(S)        ( ((u_int8_t) ~0) >> (8-(S)) )
-
-/* BITS generate a bit mask with bits O+S..O set (assumes 32 / 8 bit integer) */
-//#define BITS32(O,S)   ( MASK32(S) << (O) )
-#define BITS8(O,S)      ( MASK8(S) << (O) )
-
-/* EXTRACT32/8 macro extracts S bits from (u_int32_t/u_int8_t)W with offset O
- * and shifts them O places to the right (right justifies the field extracted) */
-//#define EXTRACT32(W,O,S)  ( ((W)>>(O)) & MASK32(S) )
-#define EXTRACT8(W,O,S)     ( ((W)>>(O)) & MASK8(S) )
-
-#define PCK_MIN(a, b)   ((a) < (b) ? (a) : (b))
-/* INSERT32/8 macro inserts S bits with offset O from field F into word W (u_int32_t/u_int8_t) */
-//#define INSERT32(W,F,O,S)     ((W)= ( ( (W) & (~BITS32(O,S)) ) | (((F) & MASK32(S))<<(O)) ))
-#define INSERT8(W,F,O,S)        ((W)= ( ( (W) & (~BITS8(O,S)) ) | (((F) & MASK8(S))<<(O)) ))
-
-//#define INSERTF_32(W,O1,F,O2,S)   (INSERT32(W, EXTRACT32(F, O2, S), O1, S) )
-#define INSERTF_8(W,O1,F,O2,S)      (INSERT8(W, EXTRACT8(F, O2, S), O1, S) )
-
-
-/************************************/
-#define PTR_64_OF_BUFF(buf, offset)     ((u_int64_t*)((u_int8_t*)(buf) + (offset)))
-#define PTR_32_OF_BUFF(buf, offset)     ((u_int32_t*)((u_int8_t*)(buf) + (offset)))
-#define PTR_8_OF_BUFF(buf, offset)      ((u_int8_t*)((u_int8_t*)(buf) + (offset)))
-#define FIELD_64_OF_BUFF(buf, offset)   (*PTR_64_OF_BUFF(buf, offset))
-#define FIELD_32_OF_BUFF(buf, offset)   (*PTR_32_OF_BUFF(buf, offset))
-#define FIELD_8_OF_BUFF(buf, offset)    (*PTR_8_OF_BUFF(buf, offset))
-#define DWORD_N(buf, n)                 FIELD_32_OF_BUFF((buf), (n) * 4)
-#define BYTE_N(buf, n)                  FIELD_8_OF_BUFF((buf), (n))
-
-
-/************************************/
-// #define MIN(a, b)   ((a) < (b) ? (a) : (b))
-
-
-/************************************/
-#define CPU_TO_BE32(x)  htonl(x)
-#define BE32_TO_CPU(x)  ntohl(x)
-#define CPU_TO_BE16(x)  htons(x)
-#define BE16_TO_CPU(x)  ntohs(x)
-#ifdef _LITTLE_ENDIANESS
-    #define CPU_TO_BE64(x) (((u_int64_t)htonl((u_int32_t)((x) & 0xffffffff)) << 32) | \
-                            ((u_int64_t)htonl((u_int32_t)((x >> 32) & 0xffffffff))))
-
-    #define BE64_TO_CPU(x) (((u_int64_t)ntohl((u_int32_t)((x) & 0xffffffff)) << 32) | \
-                            ((u_int64_t)ntohl((u_int32_t)((x >> 32) & 0xffffffff))))
-#else
-    #define CPU_TO_BE64(x) (x)
-    #define BE64_TO_CPU(x) (x)
-#endif
-
-
-/************************************/
-/* define macros to the architecture of the CPU */
-#if defined(__linux) || defined(__FreeBSD__)
-#   if defined(__i386__)
-#       define ARCH_x86
-#   elif defined(__x86_64__)
-#       define ARCH_x86_64
-#   elif defined(__ia64__)
-#       define ARCH_ia64
-#   elif defined(__PPC64__)
-#       define ARCH_ppc64
-#   elif defined(__PPC__)
-#       define ARCH_ppc
-#   else
-#       error Unknown CPU architecture using the linux OS
-#   endif
-#elif defined(_WIN32)
-
-//#   error Windows OS need to define macros
-#else       /* __linux || __FreeBSD__ */
-#   error Unknown OS
-#endif      /* __linux || __FreeBSD__ */
-
-
-/**********************************/
-/* define macros for print fields */
-//#if defined (ARCH_ia64) || defined(ARCH_x86_64) || defined(ARCH_ppc64) || defined(__MINGW64__)
-
-#if !defined(UEFI_BUILD) && (defined (ARCH_ia64) || defined(ARCH_x86_64) || defined(ARCH_ppc64) || defined(__MINGW64__))
-#   define U64H_FMT "0x%016lx"
-#   define U64D_FMT "%lu"
-#   define U32H_FMT "0x%08x"
-#   define U16H_FMT "0x%04x"
-#   define U8H_FMT  "0x%02x"
-#   define U32D_FMT "%u"
-#   define STR_FMT "%s"
-#elif defined(ARCH_x86) || defined(ARCH_ppc) || defined(__MINGW32__) || defined(UEFI_BUILD)
-#   define U64H_FMT "0x%016llx"
-#   define U64D_FMT "%llu"
-#   define U32H_FMT "0x%08x"
-#   define U16H_FMT "0x%04x"
-#   define U8H_FMT  "0x%02x"
-#   define U32D_FMT "%u"
-#   define STR_FMT "%s"
-#else  /* ARCH */
-#   error Unknown architecture
-#endif /* ARCH */
-
-
-/**********************************/
-void push_to_buff_64(u_int8_t *buff, u_int32_t bit_offset, u_int64_t field_value);
-void push_to_buff_32(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_value);
-void push_to_buff(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_size, u_int32_t field_value);
-u_int64_t pop_from_buff_64(u_int8_t *buff, u_int32_t bit_offset);
-u_int32_t pop_from_buff_32(u_int8_t *buff, u_int32_t bit_offset);
-u_int32_t pop_from_buff(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_size);
-
-
-#endif          /* def packet_common_H */
-
-
diff --git a/mft_utils/Makefile.am b/mft_utils/Makefile.am
new file mode 100644 (file)
index 0000000..8f276bb
--- /dev/null
@@ -0,0 +1,25 @@
+#--
+#                 - Mellanox Confidential and Proprietary -
+# 
+# Copyright (C) Jan 2013, Mellanox Technologies Ltd.  ALL RIGHTS RESERVED.
+# 
+# Except as specifically permitted herein, no portion of the information,
+# including but not limited to object code and source code, may be reproduced,
+# modified, distributed, republished or otherwise exploited in any form or by
+# any means for any purpose without the prior written permission of Mellanox
+# Technologies Ltd. Use of software subject to the terms and conditions
+# detailed in the file "LICENSE.txt".
+#--
+
+# Makefile.am -- Process this file with automake to produce Makefile.in
+USER_DIR = $(top_srcdir)
+INCLUDES = -I. -I$(USER_DIR)/common
+
+AM_CFLAGS = -MD -pipe -Wall -W -Werror
+
+noinst_HEADERS = mft_sig_handler.h
+
+noinst_LIBRARIES = libmftutils.a
+
+libmftutils_a_SOURCES =  mft_sig_handler.c
+
diff --git a/mft_utils/mft_sig_handler.c b/mft_utils/mft_sig_handler.c
new file mode 100644 (file)
index 0000000..b0516a0
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include <stdio.h>
+#include <signal.h>
+
+#include <tools_utils.h>
+
+static int s_is_fired = 0;
+static char* s_interrupt_message = NULL;
+
+//siganls to handle
+#ifdef __WIN__
+    static int signals_array[] =
+    {SIGINT};
+#else
+    static int signals_array[] = {SIGINT, SIGQUIT, SIGTERM};
+#endif
+
+static void (*prev_handlers[sizeof(signals_array)/sizeof(signals_array[0])])(int sig);
+
+
+
+static void my_termination_handler(int sig)
+{
+    s_is_fired = sig; // assuming signals recieved are always different then zero
+    if (s_interrupt_message) {
+        fprintf(stderr, "%s", s_interrupt_message);
+    }
+}
+
+#ifdef __WIN__
+static BOOL CtrlHandler( DWORD fdwCtrlType )
+{
+    switch( fdwCtrlType )
+    {
+      // Handle the CTRL-C signal.
+      case CTRL_C_EVENT:
+      // CTRL-CLOSE: confirm that the user wants to exit.
+      case CTRL_CLOSE_EVENT:
+      // Pass other signals to the next handler.
+      case CTRL_BREAK_EVENT:
+      case CTRL_LOGOFF_EVENT:
+      case CTRL_SHUTDOWN_EVENT:
+          my_termination_handler(SIGINT);
+          return TRUE;
+
+      default:
+        return FALSE;
+    }
+ }
+#endif
+
+int  mft_signal_set_handling(int is_on)
+{
+    unsigned int i;
+
+#ifdef __WIN__
+    SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, is_on );
+#endif
+    static int first_on = 0;
+    static int is_on_counter = 0;
+
+    if (is_on_counter == 0 && is_on == 0) {
+       //if we reach here it means previous handler is already set so there is no need to restore it once more.
+        return 0;
+    }
+    // incr/decr counter
+    if (is_on) {
+       is_on_counter += 1;
+    }else {
+       is_on_counter = is_on_counter > 0 ? is_on_counter -1 : is_on_counter;
+    }
+
+    if (is_on == 1 && first_on == 0) {
+        /* first time we turned thin handler on so we save previous handlers in prev_handlers array */
+        for (i = 0; i < sizeof(signals_array)/sizeof(signals_array[0]); i++)
+        {
+            prev_handlers[i] = signal(signals_array[i], my_termination_handler);
+            if (prev_handlers[i] == SIG_ERR) {
+                return -1;
+            }
+        }
+        first_on = 1;
+        return 0;
+    }
+    /* not the first time we turned on the signals */
+    /* register term/kill signal handler */
+    /* we need to call signal routine only when is_on_counter == 0 or 1 (more precisely when it goes from zero to one or visa versa )*/
+    if ((is_on_counter == 0 && is_on == 0) || (is_on_counter == 1 && is_on == 1 )) {
+       for (i = 0; i < sizeof(signals_array)/sizeof(signals_array[0]); i++)
+       {
+               if (signal(signals_array[i], is_on_counter > 0 ? my_termination_handler : prev_handlers[i]) == SIG_ERR) {
+                       return -1;
+               }
+       }
+    }
+
+    return 0;
+}
+
+int  mft_signal_is_fired() {
+    return s_is_fired;
+}
+
+void mft_signal_set_fired(int is_fired)
+{
+    s_is_fired = is_fired;
+}
+
+void mft_signal_set_msg(char* msg)
+{
+    s_interrupt_message = msg;
+}
+
diff --git a/mft_utils/mft_sig_handler.h b/mft_utils/mft_sig_handler.h
new file mode 100644 (file)
index 0000000..78bc49a
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef MFT_SIG_HANDLER
+#define MFT_SIG_HANDLER
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** @file
+ *  mft_sig_hanndler - Generic signal handling API
+ *  Re place the default sig handlers for user interrupts with a
+ *  'thin' handler that sets a flag and prints message to user
+ *  (to stderr), and returns.
+ *
+ *  This allows application to place this handler in the main
+ *  loop and do a propper exit with cleanup on signal.
+ *
+ *  NOTE: mft_sig_handler saves on first call to
+ *  mft_signal_set_handling(1), the current handlers
+ *  and restores them each time we turn the thin handler off
+ *  thus the main program should not change its default signal
+ *  handlers after their initial initilization.
+ */
+
+/**
+ * @brief Start/Stop the thin handler
+ * @param [in] is_on: 1 - enable thin handler. 0 - restore
+ *       previous handlers
+ * @return 0 on success, 1 otherwise.
+ */
+int  mft_signal_set_handling(int is_on);
+
+/**
+ * @brief signal accepted indication
+ * @return N - signal N was accepted. 0 otherwise...
+ */
+int  mft_signal_is_fired();
+
+/**
+ * @brief set value for signal accepted indication.
+ *        Can be used to clear signal
+ * @param [in] is_fired
+ */
+void mft_signal_set_fired(int is_fired);
+
+/**
+ * @brief Set teh message to be printed on signal
+ * @param [in] msg - the mesage or NULL if no message is to be
+ *        printed.
+ */
+void mft_signal_set_msg(char* msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/mlxconfig/Makefile.am b/mlxconfig/Makefile.am
new file mode 100755 (executable)
index 0000000..36fc293
--- /dev/null
@@ -0,0 +1,59 @@
+#--
+# Copyright (c) 2004-2010 Mellanox Technologies LTD. All rights reserved.
+#
+# This software is available to you under a choice of one of two
+# licenses.  You may choose to be licensed under the terms of the GNU
+# General Public License (GPL) Version 2, available from the file
+# COPYING in the main directory of this source tree, or the
+# OpenIB.org BSD license below:
+#
+#     Redistribution and use in source and binary forms, with or
+#     without modification, are permitted provided that the following
+#     conditions are met:
+#
+#      - Redistributions of source code must retain the above
+#        copyright notice, this list of conditions and the following
+#        disclaimer.
+#
+#      - Redistributions in binary form must reproduce the above
+#        copyright notice, this list of conditions and the following
+#        disclaimer in the documentation and/or other materials
+#        provided with the distribution.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#--
+
+# Makefile.am -- Process this file with automake to produce Makefile.in
+USER_DIR = $(top_srcdir)
+MTCR_DIR = $(top_srcdir)/mtcr_ul
+COMMON_DIR = $(top_srcdir)/common
+LAYOUTS_DIR = $(top_srcdir)/tools_layouts
+UTILS_DIR = $(top_srcdir)/mft_utils
+DEV_MGT_DIR = $(top_srcdir)/dev_mgt
+LAYOUTS_LIB = $(LAYOUTS_DIR)/libtools_layouts.a
+UTILS_LIB = $(USER_DIR)/mft_utils/libmftutils.a
+
+
+INCLUDES = -I. -I$(USER_DIR) -I$(top_srcdir)/include/mtcr_ul -I$(MTCR_DIR) -I$(COMMON_DIR) $(WIN64_INC)\
+           -I$(MFT_EXT_LIBS_INC_DIR) -I $(LAYOUTS_DIR) -I$(MFT_EXT_LIBS_INC_DIR)/zlib -I $(UTILS_DIR) -I$(DEV_MGT_DIR)
+
+AM_CXXFLAGS = -Wall -W -g -MP -MD -pipe
+bin_PROGRAMS = mstconfig
+
+mstconfig_LDADD =  ../reg_access/libreg_access.a $(LAYOUTS_LIB)  $(MTCR_DIR)/libmtcr_ul.a  $(MLNXOS_PPC_LIBS) $(LIBSTD_CPP) $(UTILS_LIB) $(DEV_MGT_DIR)/libdev_mgt.a -ldl
+
+mstconfig_SOURCES = mlxcfg_ui.h mlxcfg_ui.cpp\
+                        mlxcfg_parser.cpp\
+                        mlxcfg_lib.h mlxcfg_lib.cpp
+
+#get mst device examples and tool name from makefile
+AM_CXXFLAGS += -DMLXCFG_NAME=\"mstconfig\"
+AM_CXXFLAGS += -DMST_DEV_EXAMPLE=\"/sys/bus/pci/devices/0000:04:00.0/config\"
+
diff --git a/mlxconfig/log b/mlxconfig/log
new file mode 100644 (file)
index 0000000..268ef4a
--- /dev/null
@@ -0,0 +1,13 @@
+
+Device #1:
+----------
+
+Device type:   ConnectX3
+PCI device:    /sys/bus/pci/devices/0000:03:00.0/config
+
+        Configuration        Value 
+        -------------         -----
+       SRIOV_EN              1 
+       NUM_OF_VFS            16        
+       WOL_MAGIC_EN_P1       1 
+       WOL_MAGIC_EN_P2         
diff --git a/mlxconfig/mlxcfg_lib.cpp b/mlxconfig/mlxcfg_lib.cpp
new file mode 100644 (file)
index 0000000..6e20ddb
--- /dev/null
@@ -0,0 +1,858 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include <set>
+#include <cmath>
+#include <signal.h>
+
+#include <mft_sig_handler.h>
+#include <tools_layouts/tools_layouts.h>
+#include <reg_access/reg_access.h>
+#include <bit_slice.h>
+
+#include "mlxcfg_lib.h"
+
+
+#define SRIOV_MASK 0x1
+#define WOL_P1_MASK 0x2
+#define WOL_P2_MASK 0x4
+#define VPI_P1_MASK 0x8
+#define VPI_P2_MASK 0x10
+#define BAR_SZ_MASK 0x20
+
+#define TOOL_CAP_BITS_ADDR 0xc0
+#define MAX_VFS_ADDR 0x38
+#define MAX_BAR_SZ_ADDR 0xc8
+#define DEFAULT_BAR_SZ_ADDR 0x48
+
+// for debug:
+#ifdef _ENABLE_DEBUG_
+# define DEBUG_PRINT_SEND(data_struct, struct_name)\
+    printf("-I- Data Sent:\n");\
+    tools_##struct_name##_print(data_struct, stdout, 1)
+# define DEBUG_PRINT_RECIEVE(data_struct, struct_name)\
+    printf("-I- Data Recieved:\n");\
+    tools_##struct_name##_print(data_struct, stdout, 1)
+#else
+# define DEBUG_PRINT_SEND(data_struct, struct_name)
+# define DEBUG_PRINT_RECIEVE(data_struct, struct_name)
+#endif
+
+
+using namespace std;
+
+static McStatus translateRc(MError rc);
+static McStatus mnvaCom(mfile* mf, u_int8_t* buff, u_int16_t len, u_int16_t type, reg_access_method_t method, u_int16_t typeMod=0);
+
+/*
+ * MlxCfgOps::SriovParams implementation
+ */
+
+void MlxCfgOps::SriovParams::setParam(mlxCfgParam paramType, u_int32_t val)
+{
+    if (paramType == Mcp_Sriov_En) {
+        _sriovEn = val;
+    } else if (paramType == Mcp_Num_Of_Vfs) {
+        _numOfVfs = val;
+    }
+}
+
+u_int32_t MlxCfgOps::SriovParams::getParam(mlxCfgParam paramType)
+{
+    if (paramType == Mcp_Sriov_En) {
+        return _sriovEn;
+    } else if (paramType == Mcp_Num_Of_Vfs) {
+        return _numOfVfs;
+    }
+    return MLXCFG_UNKNOWN;
+}
+
+
+McStatus MlxCfgOps::SriovParams::getFromDev(mfile* mf)
+{
+    if (_updated) {
+        return MCE_SUCCESS;
+    }
+    McStatus rc;
+    // prep tlv
+    u_int8_t buff[tools_sriov_size()];
+    struct tools_sriov sriovTlv;
+    memset(buff, 0, tools_sriov_size());
+    memset(&sriovTlv, 0, sizeof(struct tools_sriov));
+    // pack it
+    tools_sriov_pack(&sriovTlv, buff);
+    // send it
+    DEBUG_PRINT_SEND(&sriovTlv, sriov);
+    rc = mnvaCom(mf, buff, tools_sriov_size(), tlvType, REG_ACCESS_METHOD_GET, 0);
+    // check rc
+    DEBUG_PRINT_RECIEVE(&sriovTlv, sriov);
+    if (rc) {
+        return rc;
+    }
+    // unpack and update
+    tools_sriov_unpack(&sriovTlv, buff);
+    _sriovEn = _sriovEn == MLXCFG_UNKNOWN ? sriovTlv.sriov_en : _sriovEn ;
+    _numOfVfs = _numOfVfs == MLXCFG_UNKNOWN ? sriovTlv.total_vfs : _numOfVfs ;
+    _updated = true;
+
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::SriovParams::setOnDev(mfile* mf)
+{
+    McStatus rc;
+    if (_sriovEn == MLXCFG_UNKNOWN || _numOfVfs == MLXCFG_UNKNOWN) {
+        rc = getFromDev(mf);
+        if (rc) {
+            if (rc == MCE_RES_NOT_AVAIL) {
+                return MCE_INCOMPLETE_PARAMS;
+            }
+            return rc;
+        }
+    }
+    if (!isLegal(mf)) {
+        return MCE_BAD_PARAM_VAL;
+    }
+    // prep tlv
+    u_int8_t buff[tools_sriov_size()];
+    struct tools_sriov sriovTlv;
+
+    memset(buff, 0, tools_sriov_size());
+    memset(&sriovTlv, 0, sizeof(struct tools_sriov));
+
+    sriovTlv.sriov_en = _sriovEn;
+    sriovTlv.total_vfs = _numOfVfs;
+    // pack it
+    tools_sriov_pack(&sriovTlv, buff);
+    // send it
+    rc = mnvaCom(mf, buff, tools_sriov_size(), tlvType, REG_ACCESS_METHOD_SET, 0);
+    // check rc
+    if (rc) {
+        return rc;
+    }
+    _updated = false;
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::SriovParams::updateMaxVfs(mfile* mf)
+{
+    u_int64_t data = 0;
+    int rc = tools_cmdif_query_dev_cap(mf, MAX_VFS_ADDR, &data);
+    if (rc) {
+        return translateRc((MError)rc);
+    }
+    _maxVfs = (u_int32_t)(data & 0xff);
+    if (_maxVfs == 0) { // defined in CX PRM , if max_func_idx=0 then all functions(128) are operational
+        _maxVfs = 128;
+    }
+    return MCE_SUCCESS;
+}
+
+bool MlxCfgOps::SriovParams::isLegal(mfile* mf)
+{
+    if (!mf) {
+        return false;
+    }
+    u_int64_t data = 0;
+    int rc = tools_cmdif_query_dev_cap(mf, DEFAULT_BAR_SZ_ADDR, &data);
+    if (rc) {
+        return translateRc((MError)rc);
+    }
+    data = EXTRACT64(data,16,6) + 1; // this is the default log2 bar size , we require numOfVfs*(2^log_uar_bar) <= 512 or else the node might not boot
+    //TODO: when bar_size tlv will be supported, we need to change this to the current bar_size (and also check with the current tlv bar size)
+    //printf("-D- num_of_vfs*2^(bar_sz+1) = %d*2^%ld = %d\n", _numOfVfs, data, (int)(_numOfVfs*std::pow((double)2, (int)data)));
+    return ((_sriovEn == 0 || _sriovEn == 1 ) && (_numOfVfs <= _maxVfs) && (_numOfVfs*(std::pow((double)2, (int)data)) <= 512));
+}
+
+/*
+ * MlxCfgOps::WolParams implementation
+ */
+
+void MlxCfgOps::WolParams::setParam(mlxCfgParam paramType, u_int32_t val)
+{
+    if ((paramType == Mcp_Wol_Magic_En_P1 && _port == 1 ) || (paramType == Mcp_Wol_Magic_En_P2 && _port == 2) ) {
+        _wolMagicEn = val;
+    }
+}
+
+u_int32_t MlxCfgOps::WolParams::getParam(mlxCfgParam paramType)
+{
+    if ((paramType == Mcp_Wol_Magic_En_P1 && _port == 1 ) || (paramType == Mcp_Wol_Magic_En_P2 && _port == 2) ) {
+        return _wolMagicEn;
+    }
+    return MLXCFG_UNKNOWN;
+}
+
+McStatus MlxCfgOps::WolParams::getFromDev(mfile* mf)
+{
+    if (_updated) {
+        return MCE_SUCCESS;
+    }
+    McStatus rc;
+    // prep tlv
+    u_int8_t buff[tools_wol_size()];
+    struct tools_wol wolTlv;
+    memset(buff, 0, tools_wol_size());
+    memset(&wolTlv, 0, sizeof(struct tools_wol));
+    // pack it
+    tools_wol_pack(&wolTlv, buff);
+    // send it
+    rc = mnvaCom(mf, buff, tools_wol_size(), tlvType, REG_ACCESS_METHOD_GET, _port);
+    // check rc
+    if (rc) {
+        return rc;
+    }
+    // unpack and update
+    tools_wol_unpack(&wolTlv, buff);
+    _wolMagicEn = _wolMagicEn == MLXCFG_UNKNOWN ? wolTlv.en_wol_magic : _wolMagicEn ;
+    _updated = true;
+
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::WolParams::setOnDev(mfile* mf)
+{
+    McStatus rc;
+    if (_wolMagicEn == MLXCFG_UNKNOWN) {
+        rc = getFromDev(mf);
+        if (rc) {
+            if (rc == MCE_RES_NOT_AVAIL) {
+                return MCE_INCOMPLETE_PARAMS;
+            }
+            return rc;
+        }
+    }
+    if (!isLegal()) {
+        return MCE_BAD_PARAM_VAL;
+    }
+
+    // prep tlv
+    u_int8_t buff[tools_wol_size()];
+    struct tools_wol wolTlv;
+
+    memset(buff, 0, tools_wol_size());
+    memset(&wolTlv, 0, sizeof(struct tools_wol));
+
+    wolTlv.en_wol_magic= _wolMagicEn;
+    // pack it
+    tools_wol_pack(&wolTlv, buff);
+    // send it
+    rc = mnvaCom(mf, buff, tools_wol_size(), tlvType, REG_ACCESS_METHOD_SET, _port);
+    // check rc
+    if (rc) {
+        return rc;
+    }
+    _updated = false;
+    return MCE_SUCCESS;
+}
+
+bool MlxCfgOps::WolParams::isLegal(mfile* mf)
+{
+    (void)mf;
+    return (_wolMagicEn == 0 || _wolMagicEn == 1 );
+}
+
+/*
+ *  BarSzParams Implementation
+ */
+
+void MlxCfgOps::BarSzParams::setParam(mlxCfgParam paramType, u_int32_t val)
+{
+    if ((paramType == Mcp_Log_Bar_Size) ) {
+        _logBarSz = val;
+    }
+}
+
+u_int32_t MlxCfgOps::BarSzParams::getParam(mlxCfgParam paramType)
+{
+    if (paramType == Mcp_Log_Bar_Size) {
+        return _logBarSz;
+    }
+    return MLXCFG_UNKNOWN;
+}
+
+McStatus MlxCfgOps::BarSzParams::getFromDev(mfile* mf)
+{
+    if (_updated) {
+        return MCE_SUCCESS;
+    }
+    McStatus rc;
+    // prep tlv
+    u_int8_t buff[tools_bar_size_size()];
+    struct tools_bar_size barSzTlv;
+    memset(buff, 0, tools_bar_size_size());
+    memset(&barSzTlv, 0, sizeof(struct tools_bar_size));
+    // pack it
+    tools_bar_size_pack(&barSzTlv, buff);
+    // send it
+    rc = mnvaCom(mf, buff, tools_bar_size_size(), tlvType, REG_ACCESS_METHOD_GET, 0);
+    // check rc
+    if (rc) {
+        return rc;
+    }
+    // unpack and update
+    tools_bar_size_unpack(&barSzTlv, buff);
+    _logBarSz = _logBarSz == MLXCFG_UNKNOWN ? barSzTlv.log_uar_bar_size : _logBarSz ;
+    _updated = true;
+
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::BarSzParams::setOnDev(mfile* mf)
+{
+    McStatus rc;
+    if (_logBarSz == MLXCFG_UNKNOWN) {
+        rc = getFromDev(mf);
+        if (rc) {
+            if (rc == MCE_RES_NOT_AVAIL) {
+                return MCE_INCOMPLETE_PARAMS;
+            }
+            return rc;
+        }
+    }
+    if (!isLegal()) {
+        return MCE_BAD_PARAM_VAL;
+    }
+
+    // prep tlv
+    u_int8_t buff[tools_bar_size_size()];
+    struct tools_bar_size barSzTlv;
+
+    memset(buff, 0, tools_bar_size_size());
+    memset(&barSzTlv, 0, sizeof(struct tools_bar_size));
+
+    barSzTlv.log_uar_bar_size= _logBarSz;
+    // pack it
+    tools_bar_size_pack(&barSzTlv, buff);
+    // send it
+    rc = mnvaCom(mf, buff, tools_bar_size_size(), tlvType, REG_ACCESS_METHOD_SET, 0);
+    // check rc
+    if (rc) {
+        return rc;
+    }
+    _updated = false;
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::BarSzParams::updateBarSzInfo(mfile* mf)
+{
+    u_int64_t data = 0;
+    int rc = tools_cmdif_query_dev_cap(mf, MAX_BAR_SZ_ADDR, &data);
+    if (rc) {
+        return translateRc((MError)rc);
+    }
+    _maxLogBarSz = (u_int32_t)(data & 0xffffffff);
+    _currLogBarSz = (u_int32_t)(data >> 32);
+    //printf("-D- vec 0x%lx  max %d  curr %d\n", data, maxBarSz, currBarSz);
+    return MCE_SUCCESS;
+}
+
+bool MlxCfgOps::BarSzParams::isLegal(mfile* mf)
+{
+    (void)mf;
+    return (_logBarSz < _maxLogBarSz );
+}
+
+/*
+ *  VpiParams Implementation
+ */
+
+
+void MlxCfgOps::VpiParams::setParam(mlxCfgParam paramType, u_int32_t val)
+{
+    if ((paramType == Mcp_Link_Type_P1 && _port == 1 ) || (paramType == Mcp_Link_Type_P2 && _port == 2) ) {
+        _linkType = val;
+    }
+}
+
+u_int32_t MlxCfgOps::VpiParams::getParam(mlxCfgParam paramType)
+{
+    if ((paramType == Mcp_Link_Type_P1 && _port == 1 ) || (paramType == Mcp_Link_Type_P2 && _port == 2) ) {
+        return _linkType;
+    }
+    return MLXCFG_UNKNOWN;
+}
+
+McStatus MlxCfgOps::VpiParams::getFromDev(mfile* mf)
+{
+    if (_updated) {
+        return MCE_SUCCESS;
+    }
+    McStatus rc;
+    // prep tlv
+    u_int8_t buff[tools_vpi_settings_size()];
+    struct tools_vpi_settings vpiTlv;
+    memset(buff, 0, tools_vpi_settings_size());
+    memset(&vpiTlv, 0, sizeof(struct tools_vpi_settings));
+    // pack it
+    tools_vpi_settings_pack(&vpiTlv, buff);
+    // send it
+    rc = mnvaCom(mf, buff, tools_vpi_settings_size(), tlvType, REG_ACCESS_METHOD_GET, _port);
+    // check rc
+    if (rc) {
+        return rc;
+    }
+    // unpack and update
+    tools_vpi_settings_unpack(&vpiTlv, buff);
+    _linkType = _linkType == MLXCFG_UNKNOWN ? vpiTlv.network_link_type : _linkType ;
+    _updated = true;
+
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::VpiParams::setOnDev(mfile* mf)
+{
+    McStatus rc;
+    if (_linkType == MLXCFG_UNKNOWN) {
+        rc = getFromDev(mf);
+        if (rc) {
+            if (rc == MCE_RES_NOT_AVAIL) {
+                return MCE_INCOMPLETE_PARAMS;
+            }
+            return rc;
+        }
+    }
+    if (!isLegal()) {
+        return MCE_BAD_PARAM_VAL;
+    }
+
+    // prep tlv
+    u_int8_t buff[tools_vpi_settings_size()];
+    struct tools_vpi_settings vpiTlv;
+
+    memset(buff, 0, tools_vpi_settings_size());
+    memset(&vpiTlv, 0, sizeof(struct tools_vpi_settings));
+
+    vpiTlv.network_link_type= _linkType;
+    // pack it
+    tools_vpi_settings_pack(&vpiTlv, buff);
+    // send it
+    rc = mnvaCom(mf, buff, tools_vpi_settings_size(), tlvType, REG_ACCESS_METHOD_SET, _port);
+    // check rc
+    if (rc) {
+        return rc;
+    }
+    _updated = false;
+    return MCE_SUCCESS;
+}
+
+bool MlxCfgOps::VpiParams::isLegal(mfile* mf)
+{
+    (void)mf;
+    return (_linkType == 1 || _linkType == 2 || _linkType == 3 );
+}
+
+/*
+ * MlxCfgOps implementation
+ */
+
+MlxCfgOps::MlxCfgOps()
+{
+    _mf = NULL;
+    _suppVec = 0;
+    _cfgList.resize(Mct_Last);
+    _cfgList[Mct_Sriov] = new SriovParams();
+    _cfgList[Mct_Wol_P1] = new WolParams(1);
+    _cfgList[Mct_Wol_P2] = new WolParams(2);
+    _cfgList[Mct_Vpi_P1] = new VpiParams(1);
+    _cfgList[Mct_Vpi_P2] = new VpiParams(2);
+    _cfgList[Mct_Bar_Size] = new BarSzParams();
+    return;
+}
+
+MlxCfgOps::~MlxCfgOps()
+{
+    if (_mf) {
+        mclose(_mf);
+    }
+    for(vector<CfgParams*>::iterator it = _cfgList.begin(); it != _cfgList.end(); it++) {
+        delete *it;
+    }
+    return;
+}
+
+#define HW_ID_ADDR 0xf0014
+#define CX3_HW_ID 501
+#define CX3_PRO_HW_ID 503
+
+McStatus MlxCfgOps::supportsToolsHCR()
+{
+    // we also update the support vector
+    u_int32_t devId;
+    u_int32_t type = 0;
+    int rc;
+    mread4(_mf, HW_ID_ADDR, &devId);
+    switch (devId & 0xffff) { // check hw device id
+         case CX3_HW_ID : //Cx3
+         case CX3_PRO_HW_ID : // Cx3-pro
+             // check if device access type is pciconf (thats the only supported method atm)
+            rc = mget_mdevs_type(_mf, &type);
+        #ifndef MST_UL
+            if (type != MST_PCICONF) {
+                return MCE_PCICONF;
+            }
+        #else
+            if (type != MTCR_ACCESS_CONFIG) {
+                return MCE_PCICONF;
+            }
+        #endif
+            // check if we support tools_hcr
+             rc = tools_cmdif_query_dev_cap(_mf, TOOL_CAP_BITS_ADDR, &_suppVec);
+             switch (rc) {
+             case ME_OK:
+                 return MCE_SUCCESS;
+             case ME_CMDIF_BAD_SYS:
+                 return MCE_DRIVER_DOWN;
+             case ME_CMDIF_BAD_OP:
+             case ME_CMDIF_TOUT:
+             case ME_CMDIF_BUSY:
+                 return MCE_TOOLS_HCR_NOT_SUPP;
+             default:
+                 return MCE_UNKNOWN_ERR;
+             }
+             break;
+         default:
+             break;
+         }
+    return MCE_UNSUPPORTED_DEVICE;
+}
+
+McStatus MlxCfgOps::openComChk()
+{
+    McStatus rc;
+    // check if we support Tools HCR
+    rc = supportsToolsHCR();
+    if (rc) {
+        return rc;
+    }
+    // update cfg specific info.
+    // TODO: change all configuration specific to updateInfo() as a virtual function in the base class and call that on all Cfg classes
+    // update max Vfs
+    if (supportsCfg(Mct_Sriov)) {
+        McStatus rc = static_cast<SriovParams*>(_cfgList[Mct_Sriov])->updateMaxVfs(_mf);
+        if (rc) {
+            return rc;
+        }
+    }
+
+    // get max/current bar size
+    if (supportsCfg(Mct_Bar_Size)) {
+        McStatus rc = static_cast<BarSzParams*>(_cfgList[Mct_Bar_Size])->updateBarSzInfo(_mf);
+        if (rc) {
+            return rc;
+        }
+    }
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::open(const char* devStr)
+{
+    _mf = mopen(devStr);
+    if (_mf == NULL) {
+        return MCE_OPEN_DEVICE;
+    }
+
+    return openComChk();
+}
+
+McStatus MlxCfgOps::opend(mfile* mf)
+{
+    if (!mf) {
+        return MCE_BAD_PARAMS;
+    }
+    _mf = mf;
+    return openComChk();
+}
+
+// TODO: implement
+bool MlxCfgOps::supportsCfg(mlxCfgType cfg)
+{
+    if (!isLegal(cfg)) {
+        return false;
+    }
+    if (cfg == Mct_Bar_Size || cfg == Mct_Vpi_P1  || cfg == Mct_Vpi_P2) { // dont enable these just yet, no FW support
+        return false;
+    }
+    return _suppVec & cfgSuppMask[cfg];
+}
+
+bool MlxCfgOps::supportsParam(mlxCfgParam param)
+{
+    if (!isLegal(param)) {
+        return false;
+    }
+    return supportsCfg(cfgParam2Type(param));
+}
+
+McStatus MlxCfgOps::getCfg(mlxCfgParam cfgParam, u_int32_t& val)
+{
+    if (!isLegal(cfgParam)) {
+        return MCE_BAD_PARAMS;
+    }
+    McStatus rc = _cfgList[cfgParam2Type(cfgParam)]->getFromDev(_mf);
+    if (rc) {
+        return rc;
+    }
+    val = (_cfgList[cfgParam2Type(cfgParam)])->getParam(cfgParam);
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::getCfg(std::vector<cfgInfo>& infoVec)
+{
+    for (std::vector<cfgInfo>::iterator it = infoVec.begin() ; it != infoVec.end(); it++) {
+        McStatus rc = getCfg(it->first,it->second);
+        if (rc) {
+            return rc;
+        }
+    }
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::setCfg(mlxCfgParam cfgParam, u_int32_t val)
+{
+    if (!isLegal(cfgParam)) {
+        return MCE_BAD_PARAMS;
+    }
+    _cfgList[cfgParam2Type(cfgParam)]->setParam(cfgParam, val);
+    McStatus rc = _cfgList[cfgParam2Type(cfgParam)]->setOnDev(_mf);
+    if (rc) {
+        return rc;
+    }
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::setCfg(const std::vector<cfgInfo>& infoVec)
+{
+    // set params
+    std::set<CfgParams*> CfgToSet;
+
+    for (std::vector<cfgInfo>::const_iterator it = infoVec.begin() ; it != infoVec.end(); it++) {
+        if (!isLegal(it->first)) {
+            return MCE_BAD_PARAMS;
+        }
+        if (!supportsParam(it->first)) {
+            return MCE_UNSUPPORTED_CFG;
+        }
+        _cfgList[cfgParam2Type(it->first)]->setParam(it->first, it->second);
+        CfgToSet.insert(_cfgList[cfgParam2Type(it->first)]);
+    }
+    //set on device exit on first failure
+    for (std::set<CfgParams*>::iterator it = CfgToSet.begin() ; it != CfgToSet.end(); it++) {
+        McStatus rc = (*it)->setOnDev(_mf);
+        if (rc) {
+            return rc;
+        }
+    }
+    return MCE_SUCCESS;
+}
+
+McStatus MlxCfgOps::invalidateCfgs()
+{
+
+    struct tools_mnvia mnviaTlv;
+    u_int8_t buffer[tools_mnvia_size()];
+    memset(&mnviaTlv, 0, sizeof(struct tools_mnvia));
+    memset(buffer, 0, tools_mnvia_size());
+
+    mnviaTlv.mnv_hdr.length = 0;
+    mnviaTlv.mnv_hdr.type = 0;
+    mnviaTlv.mnv_hdr.type_mod = 0;
+    tools_mnvia_pack(&mnviaTlv, buffer);
+    MError rc;
+    rc = reg_access_mnvia(_mf, REG_ACCESS_METHOD_SET, &mnviaTlv);
+    return translateRc(rc);
+}
+
+bool MlxCfgOps::isLegal(mlxCfgType cfg)
+{
+    return (cfg >= Mct_Sriov && cfg < Mct_Last) ;
+}
+
+bool MlxCfgOps::isLegal(mlxCfgParam cfg)
+{
+    return (cfg >= Mcp_Sriov_En && cfg < Mcp_Last) ;
+}
+
+u_int64_t MlxCfgOps::cfgSuppMask[Mct_Last] = {SRIOV_MASK, WOL_P1_MASK, WOL_P2_MASK , VPI_P1_MASK, VPI_P2_MASK, BAR_SZ_MASK};
+
+mlxCfgType MlxCfgOps::cfgParam2Type(mlxCfgParam param)
+{
+    switch (param) {
+    case Mcp_Sriov_En :
+        return Mct_Sriov;
+    case Mcp_Num_Of_Vfs :
+        return Mct_Sriov;
+    case Mcp_Wol_Magic_En_P1 :
+        return Mct_Wol_P1;
+    case Mcp_Wol_Magic_En_P2 :
+        return Mct_Wol_P2;
+    case Mcp_Link_Type_P1 :
+        return Mct_Vpi_P1;
+    case Mcp_Link_Type_P2 :
+        return Mct_Vpi_P2;
+    case Mcp_Log_Bar_Size :
+        return Mct_Bar_Size;
+    default :
+            return Mct_Last;
+    }
+}
+
+const char* MlxCfgOps::err2str(McStatus rc)
+{
+    switch (rc) {
+    case MCE_TLV_NOT_FOUND:
+        return "Configuration not found.";
+    case MCE_TLV_NOT_SUPP:
+        return "The Configuration Tlv is not supported.";
+    case MCE_NVCFG_NOT_SUPP:
+    case MCE_REG_NOT_SUPP:
+        return "Fw does not support NV access registers.";
+    case MCE_TOOLS_HCR_NOT_SUPP:
+        return "Unsupported FW (version 2.31.5000 or above required for CX3/PRO)";
+    case MCE_UNSUPPORTED_CFG:
+        return "Fw does not support configuration.";
+    case MCE_UNSUPPORTED_DEVICE:
+        return "Device not supported.";
+    case MCE_BAD_PARAMS:
+        return "Bad Parameters.";
+    case MCE_BAD_PARAM_VAL:
+        return "Illegal parameter value.";
+    case MCE_FAILED:
+    case MCE_BAD_STATUS:
+    case MCE_CR_ERROR:
+        return "General Failure";
+    case MCE_NOT_IMPLEMENTED:
+        return "Not implemented.";
+    case MCE_DEV_BUSY:
+        return "Device busy.";
+    case MCE_UNKNOWN_TLV:
+        return "Unknown Tlv.";
+    case MCE_RES_NOT_AVAIL:
+        return "Resource not available";
+    case MCE_CONF_CORRUPT:
+        return "Configuration is corrupted.";
+    case MCE_BAD_CONFIG:
+        return "bad configuration.";
+    case MCE_ERASE_EXEEDED:
+        return "Erase exceeded flash spec.";
+    case MCE_BAD_OP:
+        return "Bad Operation.";
+    case MCE_DRIVER_DOWN:
+        return "Cannot perform operation, Driver might be down.";
+    case MCE_INCOMPLETE_PARAMS: // HACK: atm SRIOV is the only configuration that might recv this error
+        return "Failed to get missing configuration from device, please specify all the needed parameters for SRIOV.";
+    case MCE_OPEN_DEVICE:
+        return "Failed to open device.";
+    case MCE_PCICONF:
+        return "Access to device should be through configuration cycles only.";
+
+    default:
+        return "General Error.";
+    }
+}
+
+McStatus translateRc(MError rc) {
+    switch (rc) {
+    case ME_OK:
+        return MCE_SUCCESS;
+    case ME_REG_ACCESS_DEV_BUSY:
+    case ME_SEM_LOCKED:
+        return MCE_DEV_BUSY;
+    case ME_REG_ACCESS_UNKNOWN_TLV:
+        return MCE_UNKNOWN_TLV;
+    case ME_REG_ACCESS_REG_NOT_SUPP:
+        return MCE_REG_NOT_SUPP;
+    case ME_REG_ACCESS_METHOD_NOT_SUPP:
+        return MCE_METHOD_NOT_SUPP;
+    case ME_REG_ACCESS_BAD_PARAM:
+    case ME_BAD_PARAMS:
+        return MCE_BAD_PARAMS;
+    case ME_REG_ACCESS_RES_NOT_AVLBL:
+        return MCE_RES_NOT_AVAIL;
+    case ME_REG_ACCESS_CONF_CORRUPT:
+        return MCE_CONF_CORRUPT;
+    case ME_REG_ACCESS_LEN_TOO_SMALL:
+        return MCE_TLV_LEN_TOO_SMALL;
+    case ME_REG_ACCESS_BAD_CONFIG:
+        return MCE_BAD_CONFIG;
+    case ME_REG_ACCESS_ERASE_EXEEDED:
+        return MCE_ERASE_EXEEDED;
+    case ME_CMDIF_BAD_OP:
+        return MCE_BAD_OP;
+    case ME_CMDIF_BAD_STATUS:
+        return MCE_BAD_STATUS;
+    case ME_CR_ERROR:
+        return MCE_CR_ERROR;
+
+    default:
+        return MCE_UNKNOWN_ERR;
+    }
+}
+
+static void dealWithSignal()
+{
+    int sig;
+    sig = mft_signal_is_fired();
+    if (sig) {
+        // reset recieved signal
+        mft_signal_set_fired(0);
+        // retore prev handler
+        mft_signal_set_handling(0);
+        //raise signal to let the previous handle deal with it.
+        raise(sig);
+    }
+    mft_signal_set_handling(0);
+    return;
+}
+
+McStatus mnvaCom(mfile* mf, u_int8_t* buff, u_int16_t len, u_int16_t type, reg_access_method_t method, u_int16_t typeMod)
+{
+    struct tools_mnva mnvaTlv;
+    memset(&mnvaTlv, 0, sizeof(struct tools_mnva));
+
+    mnvaTlv.mnv_hdr.length = len >> 2; // length is in dwords
+    mnvaTlv.mnv_hdr.type = type;
+    mnvaTlv.mnv_hdr.type_mod = typeMod;
+    memcpy(mnvaTlv.data, buff, len);
+    MError rc;
+    // "suspend" signals as we are going to take semaphores
+    mft_signal_set_handling(1);
+    rc = reg_access_mnva(mf, method, &mnvaTlv);
+    dealWithSignal();
+    if (rc) {
+        return translateRc(rc);
+    }
+    memcpy(buff, mnvaTlv.data, len);
+    return MCE_SUCCESS;
+}
+
diff --git a/mlxconfig/mlxcfg_lib.h b/mlxconfig/mlxcfg_lib.h
new file mode 100644 (file)
index 0000000..8f2efcb
--- /dev/null
@@ -0,0 +1,250 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef MLXCFG_LIB_H_
+#define MLXCFG_LIB_H_
+
+#include <vector>
+#include <utility>
+
+#include <mtcr.h>
+
+
+#define MLXCFG_UNKNOWN 0xffffffff
+
+#define WOL_TYPE 0x10
+#define SRIOV_TYPE 0x11
+#define VPI_TYPE 0x12
+#define BAR_SIZE_TYPE 0x13
+
+
+
+
+typedef enum {
+    MCE_SUCCESS = 0,
+    MCE_TLV_NOT_FOUND,
+    MCE_TLV_NOT_SUPP,
+    MCE_NVCFG_NOT_SUPP,
+    MCE_TOOLS_HCR_NOT_SUPP,
+    MCE_DRIVER_DOWN,
+    MCE_UNSUPPORTED_DEVICE,
+    MCE_UNSUPPORTED_CFG,
+    MCE_BAD_PARAMS,
+    MCE_BAD_PARAM_VAL,
+    MCE_DEV_BUSY,
+    MCE_UNKNOWN_TLV,
+    MCE_REG_NOT_SUPP,
+    MCE_METHOD_NOT_SUPP,
+    MCE_RES_NOT_AVAIL,
+    MCE_CONF_CORRUPT,
+    MCE_TLV_LEN_TOO_SMALL,
+    MCE_BAD_CONFIG,
+    MCE_ERASE_EXEEDED,
+    MCE_BAD_OP,
+    MCE_BAD_STATUS,
+    MCE_CR_ERROR,
+    MCE_NOT_IMPLEMENTED,
+    MCE_INCOMPLETE_PARAMS,
+    MCE_OPEN_DEVICE,
+    MCE_PCICONF,
+    MCE_UNKNOWN_ERR,
+    MCE_FAILED,
+    MCE_LAST
+
+}McStatus;
+
+typedef enum {
+    Mct_Sriov = 0,
+    Mct_Wol_P1,
+    Mct_Wol_P2,
+    Mct_Vpi_P1,
+    Mct_Vpi_P2,
+    Mct_Bar_Size,
+    Mct_Last
+} mlxCfgType;
+
+typedef enum {
+    Mcp_Sriov_En = 0,
+    Mcp_Num_Of_Vfs,
+    Mcp_Wol_Magic_En_P1,
+    Mcp_Wol_Magic_En_P2,
+    Mcp_Link_Type_P1,
+    Mcp_Link_Type_P2,
+    Mcp_Log_Bar_Size,
+    Mcp_Last
+} mlxCfgParam;
+
+typedef std::pair<mlxCfgParam, u_int32_t> cfgInfo;
+
+class MlxCfgOps {
+public:
+    MlxCfgOps();
+    ~MlxCfgOps();
+    McStatus open(const char* devStr);
+    McStatus opend(mfile* mf);
+
+    // no need to close , this is done  in destructor
+
+    bool supportsCfg(mlxCfgType cfg);
+    bool supportsParam(mlxCfgParam param);
+
+    McStatus getCfg(mlxCfgParam cfgParam, u_int32_t& val);
+    McStatus getCfg(std::vector<cfgInfo>& infoVec);
+
+    McStatus setCfg(mlxCfgParam cfgParam, u_int32_t val);
+    McStatus setCfg(const std::vector<cfgInfo>& infoVec);
+
+    McStatus invalidateCfgs();
+
+    static const char* err2str(McStatus rc);
+
+private:
+
+    class CfgParams
+    {
+    public:
+        CfgParams(mlxCfgType t=Mct_Last, u_int32_t tlvT=0) : type(t), tlvType(tlvT), _updated(false) {}
+        virtual ~CfgParams() {}
+
+        virtual void setParam(mlxCfgParam paramType, u_int32_t val) = 0;
+        virtual u_int32_t getParam(mlxCfgParam paramType) = 0;
+
+        virtual McStatus getFromDev(mfile* mf) = 0;
+        virtual McStatus setOnDev(mfile* mf) = 0;
+
+        mlxCfgType type;
+        u_int32_t tlvType;
+    protected:
+        virtual bool isLegal(mfile* mf=NULL) = 0;
+        bool _updated; // set true on get and false on set
+    };
+
+    class SriovParams : public CfgParams
+    {
+    public:
+        SriovParams() : CfgParams(Mct_Sriov, SRIOV_TYPE) , _sriovEn(MLXCFG_UNKNOWN), _numOfVfs(MLXCFG_UNKNOWN), _maxVfs(1) {}
+        ~SriovParams() {};
+
+        virtual void setParam(mlxCfgParam paramType, u_int32_t val);
+        virtual u_int32_t getParam(mlxCfgParam paramType);
+
+        virtual McStatus getFromDev(mfile* mf);
+        virtual McStatus setOnDev(mfile* mf);
+
+        McStatus updateMaxVfs(mfile* mf);
+
+    private:
+        virtual bool isLegal(mfile* mf);
+
+        u_int32_t _sriovEn;
+        u_int32_t _numOfVfs;
+        u_int32_t _maxVfs;
+    };
+
+    class WolParams : public CfgParams
+    {
+    public:
+        WolParams(int port) : CfgParams(port == 1 ? Mct_Wol_P1 : Mct_Wol_P2, WOL_TYPE), _port(port), _wolMagicEn(MLXCFG_UNKNOWN) {}
+        ~WolParams() {}
+
+        virtual void setParam(mlxCfgParam paramType, u_int32_t val);
+        virtual u_int32_t getParam(mlxCfgParam paramType);
+
+        virtual McStatus getFromDev(mfile* mf);
+        virtual McStatus setOnDev(mfile* mf);
+
+
+    private:
+        virtual bool isLegal(mfile* mf=NULL);
+        // Wake on magic packet (atm this is the only mode which is supported)
+        int _port;
+        u_int32_t _wolMagicEn;
+    };
+
+    class VpiParams : public CfgParams
+    {
+    public:
+        VpiParams(int port) : CfgParams(port == 1 ? Mct_Vpi_P1 : Mct_Vpi_P2, VPI_TYPE), _port(port), _linkType(MLXCFG_UNKNOWN) {}
+        ~VpiParams() {}
+
+        virtual void setParam(mlxCfgParam paramType, u_int32_t val);
+        virtual u_int32_t getParam(mlxCfgParam paramType);
+
+        virtual McStatus getFromDev(mfile* mf);
+        virtual McStatus setOnDev(mfile* mf);
+
+
+    private:
+        virtual bool isLegal(mfile* mf=NULL);
+        int _port;
+        u_int32_t _linkType;
+    };
+
+    class BarSzParams : public CfgParams
+    {
+    public:
+        BarSzParams() : CfgParams(Mct_Bar_Size, BAR_SIZE_TYPE) ,_maxLogBarSz(1), _currLogBarSz(1), _logBarSz(MLXCFG_UNKNOWN) {}
+        ~BarSzParams() {};
+
+        virtual void setParam(mlxCfgParam paramType, u_int32_t val);
+        virtual u_int32_t getParam(mlxCfgParam paramType);
+
+        virtual McStatus getFromDev(mfile* mf);
+        virtual McStatus setOnDev(mfile* mf);
+
+        McStatus updateBarSzInfo(mfile* mf);
+
+    private:
+        virtual bool isLegal(mfile* mf=NULL);
+        u_int32_t _maxLogBarSz;
+        u_int32_t _currLogBarSz;
+        u_int32_t _logBarSz;
+
+    };
+
+
+    McStatus openComChk();
+    McStatus supportsToolsHCR();
+    bool isLegal(mlxCfgType cfg);
+    bool isLegal(mlxCfgParam cfg);
+
+    static mlxCfgType cfgParam2Type(mlxCfgParam param);
+    std::vector<CfgParams*> _cfgList; // needs to be initialized in constructor and freed in destructor, will contain all the  tools supported cfgs
+    static u_int64_t cfgSuppMask[Mct_Last];
+    mfile* _mf;
+    u_int64_t _suppVec;
+};
+
+
+
+#endif /* MLXCFG_LIB_H_ */
diff --git a/mlxconfig/mlxcfg_parser.cpp b/mlxconfig/mlxcfg_parser.cpp
new file mode 100644 (file)
index 0000000..0fa9f9c
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <algorithm>
+#include <errno.h>
+#include <utility>
+
+#include <common/tools_version.h>
+
+#include "mlxcfg_ui.h"
+
+using namespace std;
+
+
+#define IDENT "    "
+#define IDENT2 IDENT IDENT
+#define IDENT3 "\t\t"
+
+
+
+static void printFlagLine(string flag_s, string flag_l,string param, string desc)
+{
+    printf(IDENT2"-%s|--%s", flag_s.c_str(), flag_l.c_str());
+    if (param.length()) {
+        printf(" <%s>", param.c_str());
+    } else {
+        printf("\t");
+    }
+    printf(IDENT3": %s\n", desc.c_str());
+}
+
+void MlxCfg::printHelp()
+{
+    // print opening
+    printf(IDENT"NAME:\n"
+           IDENT2   MLXCFG_NAME"\n"
+           IDENT"SYNOPSIS:\n"
+           IDENT2    MLXCFG_NAME " [-d <device> ] [-y] <s[et]|q[uery]|r[eset]> [parameters to set]\n");
+
+    // print options
+    printf("\n");
+    printf(IDENT"OPTIONS:\n");
+    printFlagLine("d", "dev", "device", "Perform operation for a specified mst device.");
+    printFlagLine("y", "yes", "", "Answer yes in prompt.");
+    printFlagLine("v", "version", "", "Display version info.");
+    printFlagLine("h", "help", "", "Display help message.");
+
+    //print commands
+    printf("\n");
+    printf(IDENT"COMMANDS:\n");
+    printf(IDENT2"q[uery]\t: query current supported configurations.\n");
+    printf(IDENT2"s[et]\t: set configurations to a specific device.\n");
+    printf(IDENT2"r[eset]\t: reset configurations to their default value.\n");
+
+    // print supported commands
+    printf("\n");
+    printf(IDENT"Supported Configurations:\n");
+    printf(IDENT2"SRIOV\t\t\t: SRIOV_EN=<1|0> NUM_OF_VFS=<NUM>\n");
+    printf(IDENT2"WOL_PORT1\t\t: WOL_MAGIC_EN_P1=<1|0>\n");
+    printf(IDENT2"WOL_PORT2\t\t: WOL_MAGIC_EN_P2=<1|0>\n");
+    printf(IDENT2"VPI_SETTINGS_PORT1\t: LINK_TYPE_P1=<1|2|3> , 1=Infiniband 2=Ethernet 3=VPI(auto-sense).\n");
+    printf(IDENT2"VPI_SETTINGS_PORT2\t: LINK_TYPE_P2=<1|2|3>\n");
+    printf(IDENT2"BAR_SIZE\t\t: LOG_BAR_SIZE=<Base_2_log_in_mb> , example: for 8Mb bar size set LOG_BAR_SIZE=3\n");
+    printf("\n");
+    printf(IDENT"Examples:\n");
+    printf(IDENT2"%-35s: %s\n", "To query current Configuration", MLXCFG_NAME" -d "MST_DEV_EXAMPLE" query");
+    printf(IDENT2"%-35s: %s\n", "To set Configuration", MLXCFG_NAME" -d "MST_DEV_EXAMPLE" set SRIOV_EN=1 NUM_OF_VFS=16 WOL_MAGIC_EN_P1=1");
+    printf(IDENT2"%-35s: %s\n", "To reset Configuration", MLXCFG_NAME" -d "MST_DEV_EXAMPLE" reset");
+    printf("\n");
+    printf(IDENT"Supported devices:\n");
+    printf(IDENT2"ConnectX3, ConnectX3-Pro (FW 2.31.5000 and above).\n");
+    printf("\n");
+}
+
+void MlxCfg::printVersion()
+{
+    print_version_string(MLXCFG_NAME, "");
+}
+
+bool MlxCfg::tagExsists(mlxCfgParam tag) {
+    for (std::vector<cfgInfo>::iterator it = _mlxParams.params.begin() ; it != _mlxParams.params.end(); it++) {
+        if (it->first == tag) {
+            return true;
+        }
+    }
+    return false;
+}
+
+mlxCfgStatus MlxCfg::processArg(string tag, u_int32_t val)
+{
+    int i;
+    std::vector<cfgInfo>::iterator it;
+    for ( i = (int)Mcp_Sriov_En ; i < (int)Mcp_Last ; i++) {
+        if (tag == MlxCfgParams::param2str[i]) {
+            if (tagExsists((mlxCfgParam)i)) {
+                return err(true, "Duplicate parameter, %s.", tag.c_str());
+            }
+            _mlxParams.params.push_back(cfgInfo((mlxCfgParam)i, val));
+            break;
+        }
+    }
+    if (i == Mcp_Last) {
+        return err(true, "Unknown Parameter: %s", tag.c_str());
+    }
+    return MLX_CFG_OK;
+}
+
+
+static bool strToNum(string str, u_int16_t& num, int base=0)
+{
+    char *endp;
+    char* numStr = strcpy(new char[str.size()],str.c_str());
+    num = strtoul(numStr, &endp, base);
+    if (*endp) {
+        delete[] numStr;
+        return false;
+    }
+    delete[] numStr;
+    // check errno
+    if (errno == ERANGE) {
+        return false;
+    }
+    return true;
+}
+
+mlxCfgStatus MlxCfg::extractCfgArgs(int argc, char* argv[])
+{
+    int i = 0;
+    string tag;
+    string valstr;
+    u_int16_t val = 0;
+    for (;i < argc;i++) {
+        char* ptr;
+        // get the tag
+        ptr = strtok(argv[i], "=");
+        if (!ptr) {
+            return err(true, "invalid Configuration argument %s", argv[i]);
+        }
+        tag = ptr; // hopefully its calling copy function.
+        // get the val
+        ptr = strtok(NULL, "=");
+        if (!ptr) {
+            return err(true, "invalid Configuration argument %s", argv[i]);
+        }
+        valstr = ptr;
+        if (strtok(NULL, "=")) {
+            return err(true, "Invalid Configuration argument %s", argv[i]);
+        }
+        //printf("-D- %s %s\n", tag.c_str(), valstr.c_str());
+        if (!strToNum(valstr, val)) {
+            return err(true, "Failed to parse %s=%s", tag.c_str(), valstr.c_str());
+        }
+        // store val in the correct place in  mlxconfig Params
+        if (processArg(tag, val)) {
+            return MLX_CFG_ERROR;
+        }
+    }
+    return MLX_CFG_OK;
+}
+
+
+
+mlxCfgStatus MlxCfg::parseArgs(int argc, char* argv[])
+{
+    int i = 1;
+    for (; i<argc; i++) {
+        string arg = argv[i];
+        if (arg == "-v" || arg == "--version") {
+            printVersion();
+            return MLX_CFG_OK_EXIT;
+        } else if (arg == "-h" || arg == "--help"){
+            printHelp();
+            return MLX_CFG_OK_EXIT;
+        }else if (arg == "-d" || arg == "--dev") {
+            if (++i == argc) {
+                return err(true, "missing device name");
+            }
+            _mlxParams.device = argv[i];
+        } else if (arg == "-y" || arg == "--yes") {
+            _mlxParams.yes = true;
+        } else if (arg == "set" || arg == "s") {
+            _mlxParams.cmd = Mc_Set;
+            break;
+
+        } else if (arg == "query" || arg == "q") {
+            _mlxParams.cmd = Mc_Query;
+            break;
+
+        } else if (arg == "reset" || arg == "r") {
+            _mlxParams.cmd = Mc_Reset;
+            break;
+        } else {
+            return err(true, "invalid argument: %s", arg.c_str());
+        }
+    }
+    i++;
+    if (_mlxParams.cmd == Mc_UnknownCmd) {
+        return err(true, "No command found. For more information please run "MLXCFG_NAME" -h|--help.");
+    }
+    // we parsed input until the set/query/reset cmd
+    if (i == argc && _mlxParams.cmd == Mc_Set) {
+        return err(true, "missing configuration arguments. For more information please run "MLXCFG_NAME" -h|--help.");
+    }
+    if (i != argc && (_mlxParams.cmd == Mc_Reset || _mlxParams.cmd == Mc_Query)) {
+        return err(true, "%s command expects no argument but %d argument recieved", (_mlxParams.cmd == Mc_Reset) ? "reset" : "query", argc -i);
+    }
+    if (_mlxParams.cmd == Mc_Set && _mlxParams.device.length() == 0) {
+        return err(true, "set command expects device to be specified.");
+    }
+
+    return extractCfgArgs(argc-i, &(argv[i]));
+}
diff --git a/mlxconfig/mlxcfg_ui.cpp b/mlxconfig/mlxcfg_ui.cpp
new file mode 100644 (file)
index 0000000..0e95cd4
--- /dev/null
@@ -0,0 +1,509 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <signal.h>
+
+#include <tools_dev_types.h>
+
+#include "mlxcfg_ui.h"
+
+// Signal handler section
+void TerminationHandler(int signum);
+
+#ifdef __WIN__
+#include <windows.h>
+
+static BOOL CtrlHandler( DWORD fdwCtrlType )
+{
+    switch( fdwCtrlType )
+    {
+      // Handle the CTRL-C signal.
+      case CTRL_C_EVENT:
+      // CTRL-CLOSE: confirm that the user wants to exit.
+      case CTRL_CLOSE_EVENT:
+      // Pass other signals to the next handler.
+      case CTRL_BREAK_EVENT:
+      case CTRL_LOGOFF_EVENT:
+      case CTRL_SHUTDOWN_EVENT:
+          TerminationHandler(SIGINT);
+          return TRUE;
+
+      default:
+        return FALSE;
+    }
+ }
+
+#endif
+
+void TerminationHandler(int signum)
+{
+    static volatile sig_atomic_t fatal_error_in_progress = 0;
+
+    if (fatal_error_in_progress) {
+        raise (signum);
+    }
+    fatal_error_in_progress = 1;
+
+    signal (signum, SIG_DFL);
+    printf("\n Received signal %d.\n", signum);
+    fflush(stdout);
+    raise(signum);
+}
+
+
+void initHandler()
+{
+#ifdef __WIN__
+#define SIGNAL_NUM 3
+    int signalList[SIGNAL_NUM] = {SIGINT, SIGTERM, SIGABRT};
+    SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, true );
+#else
+#define SIGNAL_NUM 4
+    int signalList[SIGNAL_NUM] = {SIGINT, SIGTERM, SIGPIPE, SIGHUP};
+#endif
+
+    //set the signal handler
+    for (int i=0; i < SIGNAL_NUM ; i++) {
+        void (*prevFunc)(int);
+        prevFunc = signal(signalList[i],TerminationHandler);
+        if (prevFunc == SIG_ERR) {
+            printf("-E- failed to set signal Handler.");
+            exit(MLX_CFG_ERROR);
+        }
+    }
+}
+
+//End of signal handler section.
+
+
+#define MAX_ERR_STR_LEN 1024
+#define MAX_BUF_SIZE 1024
+#define PRE_ERR_MSG "-E-"
+
+#ifdef MST_UL
+    #define NO_DEV_ERR "No devices found."
+#else
+    #define NO_DEV_ERR "No devices found, mst might be stopped. You may need to run 'mst start' to load MST modules. "
+#endif
+
+std::string MlxCfgParams::param2str[Mcp_Last]= {"SRIOV_EN", "NUM_OF_VFS", "WOL_MAGIC_EN_P1", "WOL_MAGIC_EN_P2",\
+                                                "LINK_TYPE_P1", "LINK_TYPE_P2", "LOG_BAR_SIZE"};
+
+u_int32_t MlxCfgParams::getParamVal(mlxCfgParam p)
+{
+    for (std::vector<cfgInfo>::iterator it = params.begin() ; it != params.end() ; it++) {
+        if (it->first == p) {
+            return it->second;
+        }
+    }
+    return MLXCFG_UNKNOWN;
+}
+
+mlxCfgStatus MlxCfg::err(bool report, const char* fmt, ...)
+{
+     va_list  args;
+     va_start(args, fmt);
+     char errBuff[MAX_ERR_STR_LEN] = {0};
+
+     if (vsnprintf(errBuff, MAX_ERR_STR_LEN, fmt, args) >= MAX_ERR_STR_LEN) {
+         strcpy(&errBuff[MAX_ERR_STR_LEN - 5], "...");
+    }
+     _errStr = errBuff;
+     if (report) {
+         fprintf(stdout,PRE_ERR_MSG" %s\n", _errStr.c_str());
+     }
+     va_end(args);
+     return MLX_CFG_ERROR;
+}
+
+void MlxCfg::printErr()
+{
+    fprintf(stdout,PRE_ERR_MSG" %s\n", _errStr.c_str());
+}
+
+
+bool MlxCfg::askUser(const char* question)
+{
+if (question == NULL) {
+     printf("\n Do you want to continue ? (y/n) [n] : ");
+ } else {
+     printf("\n %s ? (y/n) [n] : ", question);
+ }
+
+ if (_mlxParams.yes)
+     printf("y\n");
+ else {
+     char ansbuff[32];
+     ansbuff[0] = '\0';
+     fflush(stdout);
+     //fgets(ansbuff, 30, stdin);
+     fscanf(stdin, "%30s", ansbuff);
+
+     if (  strcasecmp(ansbuff, "y") &&
+           strcasecmp(ansbuff, "yes"))  {
+
+         err(false, "Aborted by user.");
+         return false;
+     }
+ }
+ return true;
+}
+
+mlxCfgStatus MlxCfg::queryDevsCfg()
+{
+    bool shouldFail= false;
+    if (_mlxParams.device.length()) {
+        if (queryDevCfg(_mlxParams.device.c_str())) {
+            printErr();
+            shouldFail= true;
+        }
+    } else {
+        int  numOfDev;
+        dev_info* dev = mdevices_info(MDEVS_TAVOR_CR, &numOfDev);
+
+        if (numOfDev == -1) {
+            return err(true, "Failed to get devices.");
+        }
+        if (numOfDev == 0) {
+            return err(true, NO_DEV_ERR);
+        }
+        //printf("-D- num of dev: %d , 1st dev : %s\n", numOfDev, buf);
+        dev_info  *devPtr = dev;
+        char pcibuf[32]= {0};
+
+        for(int i=0 ; i < numOfDev ; i++) {
+            snprintf(pcibuf,32, "%04x:%02x:%02x.%x", devPtr->pci.domain, devPtr->pci.bus,\
+                    devPtr->pci.dev, devPtr->pci.func);
+            if (queryDevCfg(devPtr->pci.conf_dev, pcibuf, i+1)){
+                printErr();
+                shouldFail = true;
+            }
+            devPtr++;
+        }
+        mdevices_info_destroy(dev, numOfDev);
+    }
+    return shouldFail? MLX_CFG_ERROR : MLX_CFG_OK;
+}
+
+#define IDENT "\t"
+#define IDENT2 "\t\t"
+
+
+static void printParam(u_int32_t param)
+{
+    if (param == MLXCFG_UNKNOWN) {
+            printf("N/A");
+        } else {
+            printf("%d", param);
+        }
+    return;
+}
+
+static void printOneParam(const char* name, u_int32_t currVal, bool printNewCfg=false, u_int32_t newVal= MLXCFG_UNKNOWN)
+{
+    printf(IDENT"%s"IDENT, name);
+    printParam(currVal);
+    printf(IDENT);
+    if (printNewCfg) {
+        if (newVal == MLXCFG_UNKNOWN) {
+            printParam(currVal);
+        } else {
+            printf("%d", newVal);
+        }
+    }
+    printf("\n");
+    return;
+
+}
+const char* MlxCfg::getDeviceName(const char* dev)
+{
+    mfile* mf;
+    dm_dev_id_t dev_type;
+    u_int32_t dev_id;
+    u_int32_t chip_rev;
+
+    mf = mopen(dev);
+    if (!mf) {
+        return "";
+    }
+    if (dm_get_device_id(mf, &dev_type, &dev_id, &chip_rev)) {
+        mclose(mf);
+        return "";
+    }
+    mclose(mf);
+    return dm_dev_type2str(dev_type);
+}
+
+mlxCfgStatus MlxCfg::queryDevCfg(const char* dev,const char* pci, int devIndex, bool printNewCfg)
+{
+    MlxCfgOps ops;
+    McStatus rc;
+    bool failedToGetCfg = false;
+    bool nothingSupported = true;
+    (void) pci;
+    // print opening
+    printf("\nDevice #%d:\n", devIndex);
+    printf("----------\n\n");
+    printf("Device type:"IDENT"%s\n", getDeviceName(dev));
+    printf("PCI device:"IDENT"%s\n", dev);
+    // TODO : get this info
+    //printf("Part Number:"IDENT"%s\n", "123456");
+    //printf("Psid:"IDENT2"%s\n", "78901111");
+    printf("\n");
+
+    rc = ops.open(dev);
+    if (rc) {
+        err(false, "Failed to query device: %s. %s", dev, MlxCfgOps::err2str(rc));
+        return MLX_CFG_ERROR_EXIT;
+    }
+
+    //print configuration Header
+    printf("Configurations:"IDENT2"Current");
+    if (printNewCfg) {
+        printf(IDENT"New");
+    }
+    printf("\n");
+
+    for (int p = (int)Mcp_Sriov_En ; p < (int)Mcp_Last; ++p) {
+        if (!ops.supportsParam((mlxCfgParam)p)) {
+            continue;
+        }
+        nothingSupported= false;
+        u_int32_t currentParam = MLXCFG_UNKNOWN ;
+        u_int32_t newParam = _mlxParams.getParamVal((mlxCfgParam)p);
+        rc = ops.getCfg((mlxCfgParam)p, currentParam);
+        if (rc && rc != MCE_RES_NOT_AVAIL) {
+            failedToGetCfg = true;
+            printf(IDENT"%s"IDENT"failed to get current configuration. %s\n", MlxCfgParams::param2str[p].c_str(),\
+                    MlxCfgOps::err2str(rc));
+        } else {
+            printOneParam(MlxCfgParams::param2str[p].c_str(), currentParam, printNewCfg, newParam);
+        }
+    }
+    if (nothingSupported) {
+        err(false, "Device Doesn't support any configuration changes.");
+        return MLX_CFG_ERROR_EXIT;
+    }
+    return failedToGetCfg ? MLX_CFG_ERROR : MLX_CFG_OK;
+}
+
+mlxCfgStatus MlxCfg::setDevCfg()
+{
+    if (queryDevCfg(_mlxParams.device.c_str(), NULL, 1, true) == MLX_CFG_ERROR_EXIT){
+        printErr();
+        return MLX_CFG_ERROR;
+    }
+    // even if there is problem fetching the current cfg we will attempt to write the new info
+    // if the user agrees
+
+    // ask user
+    if(!askUser("Apply new Configuration?")) {
+        printErr();
+        return MLX_CFG_ABORTED;
+    }
+
+    // write cfgs
+    MlxCfgOps ops;
+    McStatus rc;
+
+    rc = ops.open(_mlxParams.device.c_str());
+    if (rc) {
+        return err(false, "Failed to set configuration on device: %s. %s", _mlxParams.device.c_str(), \
+                MlxCfgOps::err2str(rc));
+    }
+    printf("Applying... ");
+    // set Configuration
+    rc = ops.setCfg(_mlxParams.params);
+    if (rc) {
+        printf("Failed!\n");
+        err(true, "Failed to set configuration: %s", MlxCfgOps::err2str(rc));
+        return MLX_CFG_ERROR;
+    }
+
+    printf("Done!\n");
+    printf("-I- Please reboot machine to load new configurations.\n");
+    return MLX_CFG_OK;
+
+}
+
+mlxCfgStatus MlxCfg::resetDevsCfg()
+{
+    // check if a single device was specified and apply reset for this device only
+    if (_mlxParams.device.length()) {
+        char buff[256] = {0};
+        snprintf(buff,256,"Reset configuration for device %s? ", _mlxParams.device.c_str());
+        if (!askUser(buff)){
+            printErr();
+            return MLX_CFG_ABORTED;
+        }
+
+        printf("Applying... ");
+        if (resetDevCfg(_mlxParams.device.c_str())) {
+            printf("Failed!\n");
+            printErr();
+            return MLX_CFG_ERROR;
+        }
+    } else {
+        // reset all devices.
+        int  numOfDev;
+        dev_info* dev = mdevices_info(MDEVS_TAVOR_CR, &numOfDev);
+
+        if (numOfDev == -1) {
+            return err(true, "Failed to get devices.");
+        }
+        if (numOfDev == 0) {
+            return err(true, NO_DEV_ERR);
+        }
+        if (!askUser("Reset configuration for all devices? ")){
+            printErr();
+            mdevices_info_destroy(dev, numOfDev);
+            return MLX_CFG_ABORTED;
+        }
+        printf("Applying... ");
+
+        dev_info *devPtr = dev;
+        bool shouldFail= false;
+
+        for(int i=0 ; i < numOfDev ; i++) {
+            if (resetDevCfg(devPtr->pci.conf_dev)){
+                shouldFail = true;
+            }
+            devPtr++;
+
+        }
+        mdevices_info_destroy(dev, numOfDev);
+        if (shouldFail) {
+            printf("Failed!\n");
+            return MLX_CFG_ERROR;
+        }
+
+    }
+    // done successfully
+    printf("Done!\n");
+    printf("-I- Please reboot machine to load new configurations.\n");
+    return MLX_CFG_OK;
+}
+
+mlxCfgStatus MlxCfg::resetDevCfg(const char* dev)
+{
+    MlxCfgOps ops;
+    McStatus rc;
+
+    rc = ops.open(dev);
+    if (rc) {
+        return err(false, "Failed to open device: %s. %s", dev, MlxCfgOps::err2str(rc));
+    }
+
+    // reset cfg
+    rc = ops.invalidateCfgs();
+    if (rc) {
+        return err(false, "failed to reset configurations. %s", ops.err2str(rc));
+    }
+
+    return MLX_CFG_OK;
+}
+
+
+mlxCfgStatus MlxCfg::execute(int argc, char* argv[])
+{
+    mlxCfgStatus rc = parseArgs(argc, argv);
+    if (rc) {
+        if (rc == MLX_CFG_OK_EXIT) {
+            rc = MLX_CFG_OK;
+        }
+        return rc;
+    }
+    //return test(_mlxParams.device.c_str());
+    mlxCfgStatus ret;
+    switch (_mlxParams.cmd) {
+
+    case Mc_Query:
+        ret = queryDevsCfg();
+        break;
+    case Mc_Set:
+        ret = setDevCfg();
+        break;
+    case Mc_Reset:
+        ret = resetDevsCfg();
+        break;
+    default:
+        // should not reach here.
+        return err(true, "invalid command.");
+    }
+    return ret;
+}
+
+mlxCfgStatus MlxCfg::test(const char* dev)
+{
+    McStatus rc;
+    MlxCfgOps ops;
+    rc = ops.open(dev);
+    if (rc) {
+        return err(true, "Failed to open device: %s. %s", dev, MlxCfgOps::err2str(rc));
+    }
+    u_int32_t val;
+    rc =ops.invalidateCfgs();
+    printf("after invalidate all : rc = %d\n", rc);
+    rc =ops.getCfg(Mcp_Wol_Magic_En_P1, val);
+    printf("get sriov_en get before set : rc = %d , val = %d\n", rc,val);
+    rc = ops.setCfg(_mlxParams.params);
+    printf("get sriov_en set : rc = %d , val = %d\n", rc,val);
+    rc =ops.getCfg(Mcp_Wol_Magic_En_P1, val);
+    printf("get sriov_en get after set : rc = %d , val = %d\n", rc,val);
+    if (rc) {
+        printf("-D- %s\n",MlxCfgOps::err2str(rc));
+    }
+    return MLX_CFG_OK;
+}
+
+
+int main(int argc, char* argv[])
+{
+    try
+    {
+    initHandler();
+    MlxCfg mc;
+    return mc.execute(argc, argv);
+    }
+    catch (std::exception& e)
+    {
+        printf("-E- %s\n", e.what());
+        return MLX_CFG_ERROR;
+    }
+}
+
+
diff --git a/mlxconfig/mlxcfg_ui.h b/mlxconfig/mlxcfg_ui.h
new file mode 100644 (file)
index 0000000..f750a7e
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef MLXCFG_UI_H_
+#define MLXCFG_UI_H_
+
+#include <string>
+
+#include <compatibility.h>
+#include <mtcr.h>
+
+#include "mlxcfg_lib.h"
+
+typedef enum {
+    Mc_Set,
+    Mc_Query,
+    Mc_Reset,
+    Mc_UnknownCmd
+} mlxCfgCmd;
+
+typedef enum {
+    MLX_CFG_OK,
+    MLX_CFG_OK_EXIT,
+    MLX_CFG_ABORTED,
+    MLX_CFG_ERROR,
+    MLX_CFG_ERROR_EXIT
+} mlxCfgStatus;
+
+
+class MlxCfgParams
+{
+public:
+    MlxCfgParams() : device(),cmd(Mc_UnknownCmd), yes(false) {}
+    ~MlxCfgParams() {}
+
+    std::string device;
+    mlxCfgCmd cmd;
+    bool yes;
+    std::vector<cfgInfo> params;
+    static std::string param2str[Mcp_Last];
+
+    u_int32_t getParamVal(mlxCfgParam p);
+};
+
+
+class MlxCfg
+{
+public:
+    MlxCfg() : _mlxParams(), _errStr(){}
+    ~MlxCfg() {};
+    mlxCfgStatus execute(int argc, char* argv[]);
+private:
+
+    // User interface and parsing methods
+    void printHelp();
+    void printVersion();
+    mlxCfgStatus parseArgs(int argc, char* argv[]);
+    //Helper functions for parse args
+    mlxCfgStatus processArg(std::string tag, u_int32_t val);
+    mlxCfgStatus extractCfgArgs(int argc, char* argv[]);
+    bool tagExsists(mlxCfgParam tag);
+    const char* getDeviceName(const char* dev);
+
+    // Query cmd
+    mlxCfgStatus queryDevsCfg();
+    mlxCfgStatus queryDevCfg(const char* dev, const char* pci=(const char*)NULL, int devIndex=1, bool printNewCfg=false);
+
+    // Set cmd
+    mlxCfgStatus setDevCfg();
+    // reset Cmd
+    mlxCfgStatus resetDevsCfg();
+    mlxCfgStatus resetDevCfg(const char* dev);
+    //
+    mlxCfgStatus test(const char* dev);
+
+    bool askUser(const char* question);
+    mlxCfgStatus err(bool report, const char* errMsg, ...);
+    void printErr();
+    // data members
+    MlxCfgParams _mlxParams;
+    std::string _errStr;
+};
+
+
+
+
+#endif /* MLXCFG_UI_H_ */
index 9f9935282ebfb9838bd7661281d9bd2f48f4de58..4fab8fe80046f7d1022d93239834dd40c00cfe4f 100755 (executable)
 MTCR_DIR = $(top_srcdir)/mtcr_ul
 MFLASH_DIR = $(top_srcdir)/mflash
 MINIXZ_DIR = $(top_srcdir)/ext_libs/minixz
-LIBMFA_DIR = $(top_srcdir)/libmfa
 COMMON_DIR = $(top_srcdir)/common
 LAYOUTS_DIR = $(top_srcdir)/tools_layouts
+UTILS_LIB = $(top_srcdir)/mft_utils
 
-INCLUDES = -I$(srcdir) -I$(MTCR_DIR) -I$(MFLASH_DIR) -I$(LIBMFA_DIR) -I$(USER_DIR)/ext_libs/json -I$(MINIXZ_DIR)\
-           -I$(COMMON_DIR) -I$(MFT_EXT_LIBS_INC_DIR)/zlib -I $(LAYOUTS_DIR) -I$(top_srcdir)/common
+INCLUDES = -I$(srcdir) -I$(MTCR_DIR) -I$(MFLASH_DIR) -I$(top_srcdir)/ext_libs/json -I$(MINIXZ_DIR)\
+           -I$(COMMON_DIR) -I$(MFT_EXT_LIBS_INC_DIR)/zlib -I $(LAYOUTS_DIR) -I$(top_srcdir)/common -I$(UTILS_LIB)
 
 MLXFWOPS_VERSION = 1
 
index 7a077261c1de1caa39e9fc4ed653202cdce36758..df011d90973daf90d420581f9da5cae6ffb158ab 100755 (executable)
@@ -2,7 +2,7 @@
  *
  * flint_base.cpp - FLash INTerface
  *
- * Copyright (c) 2011 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
- *  Version: $Id: flint_base.cpp 7522 2011-11-16 15:37:21Z mohammad $
- *
  */
 
 
 #include "flint_base.h"
 
 
+
 void ErrMsg::err_clear(){
     delete [] _err;
     _err = 0;
@@ -186,6 +184,30 @@ bool ErrMsg::errmsg(const char *format, ...) {
     return false;
 }
 
+bool ErrMsg::errmsgAdv(bool showAdv, const char *normalFmt, const char *AdvFmt, ...) {
+       // args should only apply to advanced format (i.e normalFmt does not contain %<char>)
+    va_list   args;
+    char errFmt[1024];
+
+    char* prev_err = _err;
+
+    va_start(args, AdvFmt);
+
+    if (showAdv) {
+       snprintf(errFmt, 1024, "%s %s", normalFmt, AdvFmt);
+       _err = vprint(errFmt, args);
+    } else {
+       //For functions where the arguments are not available to be checked (such as vprintf),
+       //specify the third parameter as zero. In this case the compiler only checks the format string for consistency
+       errmsg(normalFmt,0);
+    }
+    va_end(args);
+
+    delete[] prev_err;
+
+    return false;
+}
+
 
 ////////////////////////////////////////////////////////////////////////
 void Crc16::add(u_int32_t o)
index 5e010edf11da51a7f10f43abdfcf4f723fb7fc01..f7fd706b10602aecb9971183150e05d45835bdb2 100755 (executable)
@@ -2,7 +2,7 @@
  *
  * flint_base.h - FLash INTerface
  *
- * Copyright (c) 2011 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
- *  Version: $Id: flint_base.h 7522 2011-11-16 15:37:21Z mohammad $
- *
  */
+
+
 #ifndef FLINT_BASE_H
 #define FLINT_BASE_H
 
 #include "compatibility.h"
 #include "mlxfwops_com.h"
 
+static inline void be_guid_to_cpu(guid_t* to, guid_t* from) {
+        to->h=__be32_to_cpu(from->h);
+        to->l=__be32_to_cpu(from->l);
+}
+namespace std {}; using namespace std;
+/*
 #ifndef __be32_to_cpu
     #define __be32_to_cpu(x) ntohl(x)
     #ifndef bswap_32
         #define  __le32_to_cpu(x) __be32_to_cpu(bswap_32(x))
     #endif
 #endif
-
-
-static inline void be_guid_to_cpu(guid_t* to, guid_t* from) {
-        to->h=__be32_to_cpu(from->h);
-        to->l=__be32_to_cpu(from->l);
-}
-namespace std {}; using namespace std;
+*/
 
 
 #define TOCPU1(s) s = __be32_to_cpu((u_int32_t)(s));
@@ -273,7 +272,9 @@ namespace std {}; using namespace std;
 #define FS2_BOOT_START   0x38
 #define FS_DATA_OFF      0x28
 #define SWITCHX_HW_ID    581
+#define SWITCH_IB_HW_ID  583
 
+#define CX4_HW_ID                521
 #define CX3_HW_ID         501
 #define CX3_PRO_HW_ID     503
 #define CX_HW_ID          400
@@ -358,12 +359,14 @@ typedef enum fs3_section {
     FS3_PCIE_LINK_CODE = 0x4,
     FS3_IRON_PREP_CODE = 0x5,
     FS3_POST_IRON_BOOT_CODE = 0x6,
+    FS3_UPGRADE_CODE  = 0x7,
     FS3_HW_BOOT_CFG   = 0x8,
     FS3_HW_MAIN_CFG   = 0x9,
     FS3_IMAGE_INFO    = 0x10,
     FS3_FW_BOOT_CFG   = 0x11,
     FS3_FW_MAIN_CFG   = 0x12,
     FS3_ROM_CODE      = 0x18,
+    FS3_RESET_INFO    = 0x20,
     FS3_DBG_LOG_MAP   = 0x30,
     FS3_DBG_FW_INI    = 0x31,
     FS3_DBG_FW_PARAMS = 0x32,
@@ -551,6 +554,13 @@ protected:
 #endif
     ;
 
+    // this is abit ugly as there are no checks on the normalFmt string
+    bool errmsgAdv(bool showAdv, const char *normalFmt, const char *AdvFmt, ...)
+#ifdef __GNUC__
+    __attribute__ ((format (printf, 4, 5)))
+#endif
+    ;
+
 private:
 
     char       *_err;
@@ -631,6 +641,8 @@ private:
 class Aligner {
 public:
     Aligner(u_int32_t log2_alignment_size) :
+    _curr_addr(0),
+    _curr_size(0),
     _log2_alignment_size(log2_alignment_size),
     _alignment_size(1 << log2_alignment_size),
     _alignment_mask(_alignment_size - 1)
index a266245324d311efb5ffc9c8328def81ab7a35de..5cde277e3358a748f36cc561adb9d23a53bed656 100755 (executable)
@@ -2,7 +2,7 @@
  *
  * flint_io.cpp - FLash INTerface
  *
- * Copyright (c) 2011 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -36,7 +36,6 @@
  *
  */
 
-
 #include "flint_io.h"
 
 
@@ -51,7 +50,7 @@ extern const char* g_sectNames[];
 //
 ////////////////////////////////////////////////////////////////////////
 
-bool FImage::open(const char *fname, bool read_only)
+bool FImage::open(const char *fname, bool read_only, bool advErr)
 {
 
 #ifndef UEFI_BUILD
@@ -60,7 +59,9 @@ bool FImage::open(const char *fname, bool read_only)
     int                r_cnt;
     FILE              *fh;
 
-    read_only = true;  // FImage can be opened only for read
+    (void)read_only;  // FImage can be opened only for read so we ignore compiler warnings
+    _advErrors = advErr;
+
     fh = fopen(fname, "rb");
 
     if (!fh) {
@@ -106,11 +107,12 @@ bool FImage::open(const char *fname, bool read_only)
 #endif
 } // FImage::open
 
-bool FImage::open(u_int32_t *buf, u_int32_t len)
+bool FImage::open(u_int32_t *buf, u_int32_t len, bool advErr)
 {
     _buf = new u_int32_t[len / 4];
     memcpy(_buf, buf, len);
     _len = len;
+    _advErrors = advErr;
     return true;
 }
 ////////////////////////////////////////////////////////////////////////
@@ -197,10 +199,6 @@ u_int32_t FImage::get_sector_size()
 //
 ////////////////////////////////////////////////////////////////////////
 
-
-bool Flash::_byte_mode = false;
-bool Flash::_no_flash_verify = false;
-
 ////////////////////////////////////////////////////////////////////////
 bool Flash::open_com_checks(const char *device, int rc, bool force_lock)
 {
@@ -211,17 +209,17 @@ bool Flash::open_com_checks(const char *device, int rc, bool force_lock)
 
     if (rc != MFE_OK) {
         if (rc == MFE_SEM_LOCKED) {
-            return errmsg("Can not obtain Flash semaphore (63). You can run \"flint -clear_semaphore -d <device>\" to force semaphore unlock. See help for details.");
+            return errmsgAdv(_advErrors, "Can not obtain Flash semaphore (62).", "You can run \"flint -clear_semaphore -d <device>\" to force semaphore unlock. See help for details.");
         }
         if (rc == MFE_LOCKED_CRSPACE) {
             _cr_space_locked = 1;
-            return errmsg("HW access is disabled on the device.\n-E- Run \"flint -d %s hw_access enable\" in order to enable HW access.", device);
+            return errmsgAdv(_advErrors, "HW access is disabled on the device.", "\n-E- Run \"flint -d %s hw_access enable\" in order to enable HW access.", device);
         }
-        if (rc == MFE_REG_ACCESS_MAD_NOT_SUPPORTED) {
-            return errmsg("The target device FW does not support flash access commands.\n-E- Please use the -override_cache_replacement option in order to access the flash directly.");
+        if (rc == MFE_REG_ACCESS_NOT_SUPPORTED) {
+            return errmsgAdv(_advErrors, "The target device FW does not support flash access commands.", "\n-E- Please use the -override_cache_replacement option in order to access the flash directly.");
         }
         if (rc == MFE_DIRECT_FW_ACCESS_DISABLED) {
-            return errmsg(" Flash cache replacement is active.\n-E- Please use the -override_cache_replacement option in order to access the flash directly.");
+            return errmsgAdv(_advErrors, "Flash cache replacement is active.", "\n-E- Please use the -override_cache_replacement option in order to access the flash directly.");
         }
 
         return errmsg("%s %s", errno == 0 ? "" : strerror(errno), mf_err2str(rc));
@@ -232,6 +230,12 @@ bool Flash::open_com_checks(const char *device, int rc, bool force_lock)
         return errmsg("Failed getting flash attributes for device %s: %s", device,  mf_err2str(rc));
     }
 
+    rc = mf_set_opt(_mfl, MFO_NO_VERIFY, _no_flash_verify? 1: 0);
+    if (rc != MFE_OK) {
+        return errmsg("Failed setting no flash verify on device: %s", mf_err2str(rc));
+    }
+
+
     if (_attr.hw_dev_id == 435 || _attr.hw_dev_id == SWITCHX_HW_ID) {
         _port_num = 0;
     } else if (_attr.hw_dev_id == 25204 || _attr.hw_dev_id == 24204) {
@@ -239,28 +243,33 @@ bool Flash::open_com_checks(const char *device, int rc, bool force_lock)
     } else {
         _port_num = 2;
     }
+    return true;
+}
 
-    if (_byte_mode) {
-        rc = mf_set_opt(_mfl, MFO_AMD_BYTE_MODE, 1);
-        if (rc != MFE_OK) {
-            return errmsg("Failed setting byte mode for device %s: %s", device,  mf_err2str(rc));
-        }
-    }
-    if (_no_flash_verify) {
-        rc = mf_set_opt(_mfl, MFO_NO_VERIFY, 1);
-    }
+bool Flash::set_no_flash_verify(bool val) {
 
+       _no_flash_verify = val;
+       int rc;
+       if (_mfl) {
+               rc = mf_set_opt(_mfl, MFO_NO_VERIFY, val? 1: 0);
+               if (rc != MFE_OK) {
+                       return errmsg("Failed setting no flash verify on device: %s", mf_err2str(rc));
+                       }
+       }
     return true;
-} // Flash::open
+}
+
+// Flash::open
 
 
 ////////////////////////////////////////////////////////////////////////
 bool Flash::open(const char *device, bool force_lock, bool read_only, int num_of_banks, flash_params_t *flash_params,
-        int ignore_cashe_replacement)
+        int ignore_cashe_replacement, bool advErr)
 {
     // Open device
     int rc;
-    read_only = false;
+    _advErrors = advErr;
+    (void)read_only; // not used , avoid compiler warnings TODO: remove this var from function def
     rc = mf_open(&_mfl, device, num_of_banks, flash_params, ignore_cashe_replacement);
     //printf("device: %s , forceLock: %s , read only: %s, num of banks: %d, flash params is null: %s, ocr: %d, rc: %d\n",
     //         device, force_lock? "true":"false", read_only?"true":"false", num_of_banks, flash_params? "no":"yes", ignore_cashe_replacement, rc);
@@ -268,9 +277,10 @@ bool Flash::open(const char *device, bool force_lock, bool read_only, int num_of
 }
 
 ////////////////////////////////////////////////////////////////////////
-bool Flash::open(uefi_Dev_t *uefi_dev, f_fw_cmd fw_cmd_func, bool force_lock)
+bool Flash::open(uefi_Dev_t *uefi_dev, f_fw_cmd fw_cmd_func, bool force_lock, bool advErr)
 {
     int rc;
+    _advErrors = advErr;
     rc = mf_open_uefi(&_mfl, uefi_dev, fw_cmd_func);
     return open_com_checks("uefi", rc, force_lock);
 }
@@ -293,7 +303,7 @@ bool Flash::read(u_int32_t addr,
     u_int32_t phys_addr = cont2phys(addr);
     // printf("-D- read1: addr = %#x, phys_addr = %#x\n", addr, phys_addr);
     // here we set a "silent" signal handler and deal with the recieved signal after the read
-    //mft_signal_set_handling(1);
+    mft_signal_set_handling(1);
     rc = mf_read(_mfl, phys_addr, 4, (u_int8_t*)data);
     deal_with_signal();
     if (rc != MFE_OK) {
@@ -331,7 +341,7 @@ bool Flash::read(u_int32_t addr, void *data, int len, bool verbose, const char*
         while (align.GetNextChunk(chunk_addr, chunk_size)) {
             u_int32_t phys_addr = cont2phys(chunk_addr);
             // printf("-D- write: addr = %#x, phys_addr = %#x\n", chunk_addr, phys_addr);
-            //mft_signal_set_handling(1);
+            mft_signal_set_handling(1);
             rc = mf_read(_mfl, phys_addr, chunk_size, ((u_int8_t*)data) + chunk_addr - addr);
             deal_with_signal();
             if (rc != MFE_OK) {
@@ -402,7 +412,7 @@ bool Flash::write_phy(u_int32_t phy_addr, u_int32_t data)
 bool Flash::write_phy(u_int32_t phy_addr, void* data, int cnt, bool noerase)
 {
     // Avoid warning
-    noerase = false;
+    (void)noerase;
     NATIVE_PHY_ADDR_FUNC(write_with_erase, (phy_addr, data, cnt));
 }
 
@@ -412,7 +422,6 @@ bool Flash::erase_sector_phy  (u_int32_t phy_addr)
 }
 
 
-
 ////////////////////////////////////////////////////////////////////////
 bool Flash::write  (u_int32_t addr,
                     void*     data,
@@ -472,16 +481,27 @@ bool Flash::write  (u_int32_t addr,
         // Actual write:
         u_int32_t phys_addr = cont2phys(chunk_addr);
         // printf("-D- write: addr = %#x, phys_addr = %#x\n", chunk_addr, phys_addr);
-        //mft_signal_set_handling(1);
+        mft_signal_set_handling(1);
         rc = mf_write(_mfl, phys_addr, chunk_size, p);
         deal_with_signal();
 
         if (rc != MFE_OK) {
-            return errmsg("Flash write of %d bytes to address %s0x%x failed: %s",
+            if (rc == MFE_ICMD_BAD_PARAM) {
+                return errmsg("Flash write of %d bytes to address %s0x%x failed: %s\n"
+                          "    This may indicate that a FW image was already updated on flash, but not loaded by the device.\n"
+                          "    Please load FW on the device (reset device or reboot machine) before burning a new FW.",
+                          chunk_size,
+                          _log2_chunk_size ? "physical " : "",
+                          chunk_addr,
+                          mf_err2str(rc));
+
+            } else {
+                return errmsg("Flash write of %d bytes to address %s0x%x failed: %s",
                           chunk_size,
                           _log2_chunk_size ? "physical " : "",
                           chunk_addr,
                           mf_err2str(rc));
+            }
         }
 
         // Loop advance
@@ -553,11 +573,11 @@ bool Flash::erase_sector  (u_int32_t addr) {
     int rc;
 
     u_int32_t phys_addr = cont2phys(addr);
-    //mft_signal_set_handling(1);
+    mft_signal_set_handling(1);
     rc = mf_erase_sector(_mfl, phys_addr);
     deal_with_signal();
     if (rc != MFE_OK) {
-        if (rc == MFE_REG_ACCESS_RESOURCE_NOT_AVAILABLE ) {
+        if (rc == MFE_REG_ACCESS_RES_NOT_AVLBL) {
             return errmsg("Flash erase of address 0x%x failed: %s\n"
                           "    This may indicate that a FW image was already updated on flash, but not loaded by the device.\n"
                           "    Please load FW on the device (reset device or restart driver) before burning a new FW.",
@@ -621,10 +641,15 @@ bool Flash::get_attr(ext_flash_attr_t& attr) {
     attr.block_write = _attr.block_write;
     attr.command_set = _attr.command_set;
     attr.quad_en_support = _attr.quad_en_support;
+    attr.dummy_cycles_support = _attr.dummy_cycles_support;
     // Quad EN query
     if (_attr.quad_en_support) {
         attr.mf_get_quad_en_rc = (MfError)mf_get_quad_en(_mfl, &attr.quad_en);
     }
+    // Dummy Cycles query
+    if (_attr.dummy_cycles_support) {
+       attr.mf_get_dummy_cycles_rc = (MfError)mf_get_dummy_cycles(_mfl, &attr.dummy_cycles);
+    }
 
     // Flash write protected info query
     attr.write_protect_support = _attr.write_protect_support;
@@ -637,71 +662,11 @@ bool Flash::get_attr(ext_flash_attr_t& attr) {
     return true;
 }
 
-
-bool Flash::print_attr() {
-    u_int8_t banks_num = _attr.banks_num;
-    int rc;
-    printf("HW Info:\n");
-    printf("  HwDevId               %d\n",     _attr.hw_dev_id);
-    printf("  HwRevId               0x%x\n",   _attr.rev_id);
-
-    printf("Flash Info:\n");
+const char* Flash::getFlashType() {
     if (_attr.type_str != NULL) {
-        // we don't print the flash type in old devices
-        printf("  Type                  %s\n",     _attr.type_str);
-    }
-    printf("  TotalSize             0x%x\n",   _attr.size);
-    printf("  Banks                 0x%x\n",   banks_num);
-    printf("  SectorSize            0x%x\n",   _attr.sector_size );
-    printf("  WriteBlockSize        0x%x\n",   _attr.block_write);
-    printf("  CmdSet                0x%x\n",   _attr.command_set);
-
-    // Quad EN query
-    if (_attr.quad_en_support) {
-        u_int8_t quad_en;
-        rc = mf_get_quad_en(_mfl, &quad_en);
-        switch (rc) {
-            case MFE_OK:
-                printf("  "QUAD_EN_PARAM"                %d\n", quad_en);
-                break;
-            case MFE_MISMATCH_QUAD_EN:
-                printf("-E- There is a mismatch in the "QUAD_EN_PARAM" attribute between the flashes attached to the device\n");
-                break;
-            case MFE_NOT_SUPPORTED_OPERATION:
-                break;
-            default:
-                return errmsg("Failed to get "QUAD_EN_PARAM" attribute: %s (%s)", errno == 0 ? "" : strerror(errno), mf_err2str(rc));
-        }
+       return _attr.type_str;
     }
-
-    // Flash write protected info query
-    if (_attr.write_protect_support) {
-        int bank;
-        for (bank = 0; bank < banks_num; bank++) {
-            write_protect_info_t protect_info;
-            rc = mf_get_write_protect(_mfl, bank, &protect_info);
-            if (rc == MFE_OK) {
-                printf("  "FLASH_NAME"%d."WRITE_PROTECT"   ", bank);
-                if (protect_info.sectors_num != 0) {
-                    printf("%s,", (protect_info.is_bottom ? WP_BOTTOM_STR : WP_TOP_STR));
-                    printf("%d-", protect_info.sectors_num);
-                    printf("%s\n", (protect_info.is_subsector ? WP_SUBSEC_STR : WP_SEC_STR));
-                } else {
-                    printf(WP_DISABLED_STR"\n");
-
-                }
-            } else {
-                if (rc != MFE_NOT_SUPPORTED_OPERATION) { // We ignore the read when operation is not supported!
-                    return errmsg("Failed to get write_protected info: %s (%s)", errno == 0 ? "" : strerror(errno), mf_err2str(rc));
-                }
-            }
-
-       }
-    }
-
-    // TODO: Print new
-
-    return true;
+    return (const char*)NULL;
 }
 
 #define GET_IN_PARAM(param_in, out, first_op, second_op) {\
@@ -716,7 +681,7 @@ bool Flash::print_attr() {
 bool  Flash::set_attr(char *param_name, char *param_val_str)
 {
     int rc;
-
+    //TODO: make generic function that sets params
     if (!strcmp(param_name, QUAD_EN_PARAM)) {
         char* endp;
         u_int8_t quad_en_val;
@@ -728,6 +693,18 @@ bool  Flash::set_attr(char *param_name, char *param_val_str)
         if (rc != MFE_OK) {
             return errmsg("Setting "QUAD_EN_PARAM" failed: (%s)", mf_err2str(rc));
         }
+    } else if (!strcmp(param_name, DUMMY_CYCLES_PARAM)) {
+        char* endp;
+        u_int8_t dummy_cycles_val;
+        dummy_cycles_val = strtoul(param_val_str, &endp, 0);
+        if (*endp != '\0' || dummy_cycles_val < 1 || dummy_cycles_val > 15) {
+               // value is actually [0.15] but val=0 and val=15 indicate default state (thus they are the same so no need for both values to be accepted)
+            return errmsg("Bad "DUMMY_CYCLES_PARAM" value (%s), it can be [1..15]\n", param_val_str);
+        }
+        rc = mf_set_dummy_cycles(_mfl, dummy_cycles_val);
+        if (rc != MFE_OK) {
+            return errmsg("Setting "DUMMY_CYCLES_PARAM" failed: (%s)", mf_err2str(rc));
+        }
     } else if (strstr(param_name, FLASH_NAME) == param_name) {
         char *flash_param, *param_str, *endp, *bank_num_str;
         u_int8_t bank_num;
@@ -777,7 +754,6 @@ bool  Flash::set_attr(char *param_name, char *param_val_str)
 
 void Flash::deal_with_signal()
 {
-    /*
     int sig;
     sig = mft_signal_is_fired();
     if (sig) {
@@ -789,7 +765,6 @@ void Flash::deal_with_signal()
         raise(sig);
     }
     mft_signal_set_handling(0);
-    */
     return;
 }
 
index 94bc4a32e4d8711e14c1fe043d370bec141564c4..df383caa77fb0d8166cf06943fe2494c647bcd48 100755 (executable)
@@ -2,7 +2,7 @@
  *
  * flint_io.h - FLash INTerface
  *
- * Copyright (c) 2011 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -35,6 +35,8 @@
  *  Version: $Id: flint_io.h 7522 2011-11-16 15:37:21Z mohammad $
  *
  */
+
+
 #ifndef FLINT_IO_H
 #define FLINT_IO_H
 
@@ -52,7 +54,7 @@
 
 #include "flint_base.h"
 #include <mflash.h>
-//#include <mft_sig_handler.h>
+#include <mft_sig_handler.h>
 
 // external flash attr struct
 
@@ -68,10 +70,14 @@ typedef struct ext_flash_attr {
     int block_write;
     int command_set;
     u_int8_t quad_en_support;
+    u_int8_t dummy_cycles_support;
 
-    u_int8_t quad_en; 
+    u_int8_t quad_en;
     MfError mf_get_quad_en_rc;
 
+    u_int8_t dummy_cycles;
+    MfError mf_get_dummy_cycles_rc;
+
     u_int8_t write_protect_support;
 
     write_protect_info_t protect_info_array[IO_MAX_BANKS_NUM];
@@ -83,11 +89,13 @@ typedef struct ext_flash_attr {
 class MLXFWOP_API FBase : public ErrMsg {
 public:
     FBase(bool is_flash) :
+    _is_image_in_odd_chunks(false),
     _log2_chunk_size(0),
-    _is_flash(is_flash) {}
+    _is_flash(is_flash),
+    _advErrors(true) {}
     virtual ~FBase()  {}
 
-    virtual bool open(const char *, bool)                  {return false;}
+    virtual bool open(const char *, bool, bool)                  {return false;}
     virtual void close()                                   = 0;
     virtual bool read(u_int32_t addr, u_int32_t *data)     = 0;
     virtual bool read(u_int32_t addr, void *data, int len,
@@ -124,7 +132,6 @@ public:
         MAX_FLASH = 4*1048576
     };
 
-
 protected:
 
     // Address translation functions for ConnectX.
@@ -164,6 +171,8 @@ protected:
     u_int32_t  _log2_chunk_size;
     Crc16      _image_crc;
     const bool _is_flash;
+    // show advanced error msgs
+    bool _advErrors;
 
 };
 
@@ -173,13 +182,17 @@ protected:
 // Flash image (R/W)
 class MLXFWOP_API FImage : public FBase {
 public:
-    FImage() :  FBase(false), _buf(0) {}
+    FImage() :
+    FBase(false),
+    _buf(0),
+    _len(0) {}
     virtual ~FImage() { close();}
 
     u_int32_t    *getBuf()      { return _buf;}
     u_int32_t    getBufLength() { return _len;}
-    virtual bool open(const char *fname, bool read_only = false);
-    bool open(u_int32_t *buf, u_int32_t len);
+    virtual bool open(const char *fname, bool read_only = false, bool advErr = true);
+    using FBase::open;
+    bool open(u_int32_t *buf, u_int32_t len, bool advErr = true);
     virtual void close();
     virtual bool read(u_int32_t addr, u_int32_t *data);
     virtual bool read(u_int32_t addr, void *data, int len, bool verbose=false, const char* message= "");
@@ -207,11 +220,14 @@ class MLXFWOP_API Flash : public FBase {
 public:
     Flash() :
     FBase(true),
-    _mfl(0),
+    _mfl(NULL),
+    _no_flash_verify(false),
     _curr_sector(0xffffffff),
     _port_num(0),
     _cr_space_locked(0)
-    {}
+    {
+        memset(&_attr, 0, sizeof(_attr));
+    }
 
     virtual ~Flash()  { close();};
 
@@ -222,12 +238,14 @@ public:
                                 bool read_only   = false,
                                 int num_of_banks = 4,
                                 flash_params_t *flash_params = (flash_params_t *)NULL,
-                                int ignoe_cache_replacement = 0);
-
+                                int ignoe_cache_replacement = 0,
+                                bool advErr = true);
+    using FBase::open;
 
     bool open          (uefi_Dev_t *uefi_dev,
                         f_fw_cmd fw_cmd_func,
-                        bool force_lock = false);
+                        bool force_lock = false,
+                        bool advErr = true);
 
     virtual void close         ();
 
@@ -259,8 +277,8 @@ public:
 
     bool sw_reset();
 
-    void set_no_flash_verify(bool val) {_no_flash_verify = val; return;}
-    void set_byte_mode(bool val) {_byte_mode = val; return;}
+    bool set_no_flash_verify(bool val);
+    static void get_flash_list(char *flash_list) {return mf_flash_list(flash_list);}
 
     // Write and Erase functions are performed by the Command Set
 
@@ -278,7 +296,7 @@ public:
 
     virtual bool disable_hw_access();
 
-    bool         print_attr();
+    const char* getFlashType();
 
     bool         get_attr(ext_flash_attr_t& attr);
 
@@ -294,9 +312,9 @@ public:
                          int rc,
                          bool force_lock);
 
-
 //needed for printing flash status in flint hw query cmd
 #define QUAD_EN_PARAM "QuadEn"
+#define DUMMY_CYCLES_PARAM "DummyCycles"
 #define FLASH_NAME "Flash"
 #define WRITE_PROTECT "WriteProtected"
 #define WP_TOP_STR "Top"
@@ -311,11 +329,9 @@ protected:
     bool write_sector_with_erase(u_int32_t addr, void *data, int cnt);
     bool write_with_erase(u_int32_t addr, void *data, int cnt);
 
-    static bool _byte_mode;
-    static bool _no_flash_verify;
-
     mflash*    _mfl;
     flash_attr _attr;
+    bool _no_flash_verify;
 
     u_int32_t  _curr_sector;
     u_int32_t  _port_num;
index 4d8beef16d0a9f88456470a2c64eec6362c55ef3..8db0f5c7b5446180aaf2754182a37bf003fce38d 100644 (file)
@@ -100,7 +100,12 @@ bool Fs2Operations::ParseInfoSect(u_int8_t* buff, u_int32_t byteSize) {
             _fwImgInfo.ext_info.fw_ver[1] = tmp >> 16;
             _fwImgInfo.ext_info.fw_ver[2] = tmp & 0xffff;
             break;
-
+        case II_FwBuildTime:
+            tmp = __be32_to_cpu(*(p+2));
+            _fwImgInfo.ext_info.fw_rel_date[0] = (u_int16_t)(tmp & 0xff);
+            _fwImgInfo.ext_info.fw_rel_date[1] = (u_int16_t)((tmp >> 8) & 0xff);
+            _fwImgInfo.ext_info.fw_rel_date[2] = (u_int16_t)((tmp >> 16) & 0xffff);
+            break;
         case II_MinFitVersion:
             tmp = __be32_to_cpu(*(p+1));
             _fwImgInfo.ext_info.min_fit_ver[0] = tmp >> 16;
@@ -165,8 +170,7 @@ bool Fs2Operations::ParseInfoSect(u_int8_t* buff, u_int32_t byteSize) {
             _fwImgInfo.ext_info.product_ver[PRODUCT_VER_LEN] = '\0';
             break;
         case II_HwDevsId:
-           u_int32_t i;
-           for (i = 1; i <= (tagSize / 4); i++) {
+           for (u_int32_t i = 1; i <= (tagSize / 4); i++) {
                _fwImgInfo.supportedHwId[i - 1] = __be32_to_cpu(*(p + i));
            }
            _fwImgInfo.supportedHwIdNum = tagSize / 4;
@@ -343,7 +347,6 @@ bool Fs2Operations::checkGen(u_int32_t beg,u_int32_t offs, u_int32_t& next, cons
 
         CRCn(crc, buff, size/4);
         CRCn(_ioAccess->get_image_crc(), buff, size/4);
-        //printf("-D- GEN: CRC is %#x\n", _ioAccess->get_image_crc().get());
         crc.finish();
 
         u_int32_t crc_act;
@@ -351,10 +354,15 @@ bool Fs2Operations::checkGen(u_int32_t beg,u_int32_t offs, u_int32_t& next, cons
         TOCPU1(crc_act);
         bool blank_crc = false;
 
-
         if (gph.type == H_GUID && crc_act == 0xffff) {
-            blank_crc = true;
-            _fs2ImgInfo.ext_info.blank_guids = true;
+               // in case we get 0xffff as crc BUT the section is not empty (i.e not ffffs)
+               //check the 64 bits of the NGUID (node guid) located at offs + sizeof(gph)
+               u_int64_t nguid;
+               READBUF((*_ioAccess), offs+sizeof(gph), (u_int8_t*)&nguid, 8, pr);
+               if (nguid == 0xffffffffffffffffULL) {
+                       blank_crc = true;
+                       _fs2ImgInfo.ext_info.blank_guids = true;
+               }
         }
 
         if (!CheckAndPrintCrcRes(pr, blank_crc, offs, crc_act, crc.get(), false, verifyCallBackFunc)) {
@@ -416,7 +424,6 @@ bool Fs2Operations::Fs2Verify(VerifyCallBack verifyCallBackFunc, bool is_striped
     u_int32_t cntx_image_start[CNTX_START_POS_SIZE];
     u_int32_t cntx_image_num;
 
-    u_int32_t i;
     bool      ret = true;
     u_int32_t act_crc;
     bool  check_full_crc = false;
@@ -441,7 +448,7 @@ bool Fs2Operations::Fs2Verify(VerifyCallBack verifyCallBackFunc, bool is_striped
 
 
      // Verify the images:
-     for (i = 0; i < cntx_image_num; i++) {
+     for (u_int32_t i = 0; i < cntx_image_num; i++) {
          bool      fs_en;
          u_int32_t log2chunk_size;
          u_int32_t buff[FS2_BOOT_START / 4];
@@ -549,9 +556,9 @@ bool Fs2Operations::Fs2Verify(VerifyCallBack verifyCallBackFunc, bool is_striped
 }
 bool Fs2Operations::FwVerify(VerifyCallBack verifyCallBackFunc, bool isStripedImage, bool showItoc)
 {
-    //dummy assignment to avoid compiler warrning (showItoc is not used in fs2)
-    showItoc = true;
-    // if (!_wasVerified) {
+    // avoid compiler warrning (showItoc is not used in fs2)
+    (void)showItoc;
+
     initSectToRead(FULL_VERIFY);
     if (!Fs2Verify(verifyCallBackFunc, isStripedImage)) {
         // empty the initSectToRead
@@ -583,49 +590,6 @@ bool Fs2Operations::FwReadData(void* image, u_int32_t* image_size)
     return true;
 }
 
-
-bool Fs2Operations::FwTest(u_int32_t *data)
-{
-    _ioAccess->set_address_convertor(0,0);
-
-    if (!_ioAccess->read(0, data)) {
-        return false;
-    }
-
-    if (!_ioAccess->read(0x80000, data)) {
-        return false;
-    }
-
-    if (!_ioAccess->read(0x4, data)) {
-        return false;
-    }
-    if (!_ioAccess->read(0x80004, data)) {
-        return false;
-    }
-    u_int32_t addr = 0x1fffd8;
-    u_int32_t content = 0x32;
-
-
-    if (!_ioAccess->read(addr, data)) {
-        return false;
-    }
-
-    if (!((Flash*)_ioAccess)->write(addr, content)) {
-
-        return false;
-    }
-
-    if (!_ioAccess->read(addr, data)) {
-        return false;
-    }
-    if (*data != content) {
-        return false;
-    }
-
-    return true;
-
-}
-
 bool Fs2Operations::Fs2Query () {
 
     u_int32_t guid_ptr, nguids;
@@ -844,9 +808,9 @@ bool Fs2Operations::Fs2FailSafeBurn(Fs2Operations &imageOps,
                                   bool      allow_nofs,
                                   const char* pre_message,
                                   ProgressCallBack progressFunc) {
-    //we do not use pre_message
-    //setting default val to avoid warrning
-    pre_message = "";
+    //we do not use pre_message, avoid warrning
+       //TODO: remove pre_message from function definition
+    (void)pre_message;
 
     Flash  *f = (Flash*)(this->_ioAccess);
     FImage *fim = (FImage*)(imageOps._ioAccess);
@@ -866,7 +830,7 @@ bool Fs2Operations::Fs2FailSafeBurn(Fs2Operations &imageOps,
     // TODO: Do we need the verify ORENK
     if (!allow_nofs) {
         if (!imageOps._fwImgInfo.ext_info.is_failsafe) {
-            return errmsg("The given image is not a failsae image");
+            return errmsg("The given image is not a failsafe image");
         }
 
         if (_fwImgInfo.cntxLog2ChunkSize != imageOps._fwImgInfo.cntxLog2ChunkSize) {
@@ -934,11 +898,10 @@ bool Fs2Operations::Fs2FailSafeBurn(Fs2Operations &imageOps,
 
             u_int32_t cntx_image_start[CNTX_START_POS_SIZE];
             u_int32_t cntx_image_num;
-            u_int32_t i;
 
             CntxFindAllImageStart(_ioAccess, cntx_image_start, &cntx_image_num);
             // Address convertor is disabled now - use phys addresses
-            for (i = 0; i < cntx_image_num; i++) {
+            for (u_int32_t i = 0; i < cntx_image_num; i++) {
                 if (cntx_image_start[i] != new_image_start) {
                     if (!f->write(cntx_image_start[i], &zeroes, sizeof(zeroes), true)) {
                         //return false;
@@ -973,7 +936,6 @@ bool Fs2Operations::preFS2PatchGUIDs(bool      patch_macs,
         guid_t    **used_guids_p,
         u_int32_t num_of_old_guids)
 {
-    int i;
     guid_t*         used_guids;
     *used_guids_p = old_guids ? old_guids : new_guids;
 
@@ -983,13 +945,13 @@ bool Fs2Operations::preFS2PatchGUIDs(bool      patch_macs,
         // burning IB and ETH FW.
         if (!patch_uids) {
             if (old_guids && !user_guids) {
-                for (i = 0; i < GUIDS; i++) {
+                for (int i = 0; i < GUIDS; i++) {
                     new_guids[i] = old_guids[i];
                 }
             }
 
             if (old_guids && !user_macs) {
-                for (i = GUIDS; i < MAX_GUIDS; i++) {
+                for (int i = GUIDS; i < MAX_GUIDS; i++) {
                     new_guids[i] = old_guids[i];
                 }
             }
@@ -1012,7 +974,7 @@ bool Fs2Operations::preFS2PatchGUIDs(bool      patch_macs,
                                (old_guids[GUIDS  ].l & 0xffffffff) == 0xffffffff &&
                                (old_guids[GUIDS+1].h & 0xffff)     == 0xffff     &&
                                (old_guids[GUIDS+1].l & 0xffffffff) == 0xffffffff))) {
-                for (i = 0 ; i < MACS; i++) {
+                for (int i = 0 ; i < MACS; i++) {
                     u_int64_t mac  =  old_guids[i+1].h >> 8;
                     mac <<= 24;
                     mac |= (old_guids[i+1].l & 0xffffff);
@@ -1025,9 +987,8 @@ bool Fs2Operations::preFS2PatchGUIDs(bool      patch_macs,
             }
 
             guid_t* macs = &used_guids[4];
-            int i;
 
-            for (i = 0 ; i < MACS ; i++) {
+            for (int i = 0 ; i < MACS ; i++) {
                 u_int64_t mac = (((u_int64_t)macs[i].h) << 32) | macs[i].l;
                 if (!_burnBlankGuids && !CheckMac(mac)) {
                     return errmsg("Bad mac (" MAC_FORMAT ") %s: %s. Please re-burn with a valid -mac flag value.", macs[i].h,
@@ -1039,7 +1000,7 @@ bool Fs2Operations::preFS2PatchGUIDs(bool      patch_macs,
         }
     } else {
         if (!_burnBlankGuids) {
-            for (i = 0; i < BX_SLICES_NUM; i++ ) {
+            for (int i = 0; i < BX_SLICES_NUM; i++ ) {
                 if (CheckBxMacsFormat(used_guids, i, user_uids) == false) {
                     return false;
                 }
@@ -1056,9 +1017,9 @@ bool Fs2Operations::preFS2PatchGUIDs(bool      patch_macs,
 
 bool Fs2Operations::CheckBxMacsFormat(guid_t* guids, int index, int user_uids)
 {
-    int i, base;
+    int base;
     base = index * BX_SLICE_GUIDS + BI_IMACS;
-    for (i = base; i < base + BX_MACS; i++) {
+    for (int i = base; i < base + BX_MACS; i++) {
          u_int64_t mac = (((u_int64_t)guids[i].h) << 32) | guids[i].l;
          if (!CheckMac(mac)) {
              return errmsg("Bad mac (" MAC_FORMAT ") %s: %s. Please re-burn with a valid MACs flag value.", guids[i].h,
@@ -1073,17 +1034,16 @@ bool Fs2Operations::CheckBxMacsFormat(guid_t* guids, int index, int user_uids)
 ////////////////////////////////////////////////////////////////////////
 void Fs2Operations::patchGUIDsSection(u_int32_t *buf, u_int32_t ind, guid_t guids[MAX_GUIDS], int nguids)
 {
-    u_int32_t       i;
     u_int32_t       new_buf[MAX_GUIDS*2];
 
     // Form new GUID section
-    for (i=0; i<(u_int32_t)nguids; i++) {
+    for (u_int32_t i=0; i<(u_int32_t)nguids; i++) {
         new_buf[i*2] = guids[i].h;
         new_buf[i*2+1] = guids[i].l;
     }
 
     // Patch GUIDs
-    for (i=0; i<sizeof(new_buf)/sizeof(u_int32_t); ++i) {
+    for (u_int32_t i=0; i<sizeof(new_buf)/sizeof(u_int32_t); ++i) {
         new_buf[i] = _burnBlankGuids ? 0xffffffff : __cpu_to_be32(new_buf[i]);
     }
     memcpy(&buf[ind/4], &new_buf[0], nguids * 2 * sizeof(u_int32_t));
@@ -1152,7 +1112,7 @@ void Fs2Operations::PatchInfoSect(u_int8_t* rawSect, u_int32_t vsdOffs, const ch
 }
 
 
-bool Fs2Operations::patchImageVsd(Fs2Operations &imgFwOps, char* userVsd)
+bool Fs2Operations::patchImageVsd(Fs2Operations &imgFwOps, const char* userVsd)
 {
     u_int32_t *imgBuf = ((FImage*)(imgFwOps._ioAccess))->getBuf();
     u_int8_t *imgInfoSect = (u_int8_t*)imgBuf + imgFwOps._fs2ImgInfo.infoSectPtr - sizeof(GPH);
@@ -1298,8 +1258,7 @@ bool Fs2Operations::UpdateRomInImage(u_int8_t* new_image, u_int8_t* old_image, u
         } else if (gph.type == H_IMG_INFO) {
             u_int32_ba a = last_next;
             u_int32_t check_sum = 0;
-            int i;
-            for (i = 0; i < 3; i++) {
+            for (int i = 0; i < 3; i++) {
                 check_sum += a.range(i * 8 + 7, i * 8);
             }
             check_sum = 0x100 - (check_sum % 0x100);
@@ -1345,7 +1304,7 @@ bool Fs2Operations::IntegrateDevRomInImage(Fs2Operations &imageOps)
     // Compine the image and the rom into new daa
     if(!UpdateRomInImage((u_int8_t*)(&new_data[0]), (u_int8_t*)(fim->getBuf()),
                          (u_int8_t*)(&_romSect[0]), rom_size, &actual_image_size)) {
-        return errmsg(err());
+        return errmsg("%s", err());
     }
 
     // close old image and open new image with the rom.
@@ -1370,7 +1329,7 @@ bool Fs2Operations::Fs2Burn(Fs2Operations &imageOps, ExtBurnParams& burnParams)
     if (!imageOps.Fs2IntQuery()) {
         return false;
     }
-    
+
    bool devIntQueryRes = Fs2IntQuery();
 
    if (!devIntQueryRes && burnParams.burnFailsafe) {
@@ -1506,9 +1465,9 @@ bool Fs2Operations::FwReadRom(std::vector<u_int8_t>& romSect)
 bool Fs2Operations::FwSetMFG(guid_t baseGuid, PrintCallBack callBackFunc)
 {
     // avoid compiler warrnings
-    baseGuid = (guid_t){0,0};
-    callBackFunc = (PrintCallBack)NULL;
-    return errmsg("This command doesn not works Only over FS2 FW image.");
+    (void)baseGuid;
+    (void)callBackFunc;
+    return errmsg("This command is not supported for FS2 FW image.");
 }
 
 bool Fs2Operations::FwGetSection (u_int32_t sectType, std::vector<u_int8_t>& sectInfo)
@@ -1531,8 +1490,9 @@ bool Fs2Operations::FwGetSection (u_int32_t sectType, std::vector<u_int8_t>& sec
     return true;
 }
 
-bool Fs2Operations::ModifyVSDSection(char *vsd, ProgressCallBack callBackFunc)
+bool Fs2Operations::ModifyVSDSection(const char *vsd, ProgressCallBack callBackFunc)
 {
+       (void)callBackFunc; /* avoid compiler warning*/
     u_int32_t length = _fwImgInfo.lastImageAddr;
     vector<u_int8_t> data(length);
 
@@ -1545,10 +1505,10 @@ bool Fs2Operations::ModifyVSDSection(char *vsd, ProgressCallBack callBackFunc)
                   _fs2ImgInfo.infoOffs[II_VSD],
                    vsd);
     // Re-burn the new Image after modifying the VSD
-    return ReburnNewImage((u_int8_t*)(&data[0]), (char*)"VSD", callBackFunc);
+    return ReburnNewImage((u_int8_t*)(&data[0]), "VSD", callBackFunc);
 }
 
-bool Fs2Operations::ReburnNewImage(u_int8_t *data, char *feature_name, ProgressCallBack callBackFunc)
+bool Fs2Operations::ReburnNewImage(u_int8_t *data, const char *feature_name, ProgressCallBack callBackFunc)
 {
     u_int32_t length        = _fwImgInfo.lastImageAddr;
     //char burn_str[100];
@@ -1558,7 +1518,7 @@ bool Fs2Operations::ReburnNewImage(u_int8_t *data, char *feature_name, ProgressC
     // Burn the Image after modifying the VSD.
 
     // Create a fwOperations object of the modified image
-    FwOperations* newOps = FwOperationsCreate((void*)data, (void*)&length, (char*)NULL, FHT_FW_BUFF, (char*)NULL, (int)NULL);
+    FwOperations* newOps = FwOperationsCreate((void*)data, (void*)&length, (char*)NULL, FHT_FW_BUFF);
 
     // Verify the new image and exit if it's not VALID.
     if (!((Fs2Operations*)newOps)->Fs2IntQuery()) {
@@ -1595,11 +1555,10 @@ bool Fs2Operations::packStripedImageData(u_int8_t *striped_data, u_int8_t *norma
     if (needs_repack) {
         u_int32_t chunk_size = 1 << cntxLog2ChunkSize;
         u_int32_t chunk_num = (length / chunk_size) + 1;
-        u_int32_t i;
         striped_length = 0;
 
         // Loop which runs over the chunks
-        for (i = 0; i < chunk_num; i++) {
+        for (u_int32_t i = 0; i < chunk_num; i++) {
             u_int32_t normal_index  = i * chunk_size;
             u_int32_t striped_index = normal_index * 2;
 
@@ -1640,7 +1599,7 @@ bool Fs2Operations::ModifyKeySection(guid_t access_key, ProgressCallBack callBac
                   _fs2ImgInfo.infoOffs[II_HwAccessKey],
                   access_key);
     // Re-burn the new Image after modifying the VSD
-    return ReburnNewImage((u_int8_t*)(&data[0]), (char*)"HW Key", callBackFunc);
+    return ReburnNewImage((u_int8_t*)(&data[0]), "HW Key", callBackFunc);
 }
 
 void Fs2Operations::PatchKeySect(u_int32_t* buff, u_int32_t keyOff, guid_t hw_key)
@@ -1670,7 +1629,7 @@ bool Fs2Operations::ModifyGuidSection(guid_t *user_guids, ProgressCallBack progr
     // Change the GUIDs section according to the user given GUIDs
     patchGUIDsSection ((u_int32_t*)(&data[0]), _fs2ImgInfo.guidPtr, user_guids, _fs2ImgInfo.ext_info.guid_num);
     // Re-burn the new Image after modifying the GUIDs
-    return ReburnNewImage((u_int8_t*)(&data[0]), (char*)"GUIDs", progressFunc);
+    return ReburnNewImage((u_int8_t*)(&data[0]), "GUIDs", progressFunc);
 }
 
 bool Fs2Operations::Fs2SetGuidsForBlank(sg_params_t& sgParam)
@@ -1730,7 +1689,7 @@ bool Fs2Operations::Fs2SetGuidsForBlank(sg_params_t& sgParam)
 bool Fs2Operations::Fs2SetGuids(sg_params_t& sgParam, PrintCallBack callBackFunc, ProgressCallBack progressFunc)
 {
     // avoid compiler warrnings
-    callBackFunc = (PrintCallBack)NULL;
+    (void)callBackFunc;
     //
     bool ib_dev, eth_dev, bx_dev;
     // Get the FW types
@@ -1740,7 +1699,7 @@ bool Fs2Operations::Fs2SetGuids(sg_params_t& sgParam, PrintCallBack callBackFunc
     guid_t* used_guids;
 
     // Patch the GUIDs and prints any needed warnings
-    
+
         //resize our user guids vector to MAX_GUIDS
     sgParam.userGuids.resize(MAX_GUIDS);
 
@@ -1759,6 +1718,10 @@ bool Fs2Operations::Fs2SetGuids(sg_params_t& sgParam, PrintCallBack callBackFunc
 bool Fs2Operations::FwSetGuids(sg_params_t& sgParam, PrintCallBack callBackFunc,
         ProgressCallBack progressFunc)
 {
+       /* avoid annoying mingw warnings*/
+       (void)callBackFunc;
+       (void)progressFunc;
+
     if (!Fs2IntQuery(true, sgParam.stripedImage)) {
         return false;
     }
@@ -1823,7 +1786,7 @@ bool Fs2Operations::FwBurnRom(FImage* romImg, bool ignoreProdIdCheck, bool ignor
         return false;
     }
     // open the image
-    FwOperations* newOps = FwOperationsCreate((void*)&new_data[0], (void*)&new_image_size, (char*)NULL, FHT_FW_BUFF, (char*)NULL, (int)NULL);
+    FwOperations* newOps = FwOperationsCreate((void*)&new_data[0], (void*)&new_image_size, (char*)NULL, FHT_FW_BUFF);
     if (!newOps) {
         return errmsg("Internal error: The prepared image is corrupted.");
     }
@@ -1893,11 +1856,11 @@ bool Fs2Operations::FwDeleteRom(bool ignoreProdIdCheck, ProgressCallBack progres
     int new_image_size;
     if(!UpdateRomInImage((u_int8_t*)(&new_data[0]), (u_int8_t*)(&data[0]),
                              NULL, 0, &new_image_size)) {
-        return errmsg(_ioAccess->err());
+        return errmsg("%s", _ioAccess->err());
     }
 
     // Burn the Image after the ROM was removed.
-    FwOperations* newOps = FwOperationsCreate((void*)&new_data[0], (void*)&new_image_size, (char*)NULL, FHT_FW_BUFF, (char*)NULL, (int)NULL);
+    FwOperations* newOps = FwOperationsCreate((void*)&new_data[0], (void*)&new_image_size, (char*)NULL, FHT_FW_BUFF);
     if (!newOps) {
         return errmsg("Internal error: The prepared image after removing the ROM is corrupted.");
     }
@@ -1918,7 +1881,7 @@ bool Fs2Operations::FwDeleteRom(bool ignoreProdIdCheck, ProgressCallBack progres
 bool Fs2Operations::FwSetVSD(char* vsdStr, ProgressCallBack progressFunc, PrintCallBack printFunc)
 {
     // avoid compiler warrnings
-    printFunc = (PrintCallBack)NULL;
+    (void)printFunc;
     //
     if (!Fs2IntQuery()) {
         return false;
@@ -1932,6 +1895,10 @@ bool Fs2Operations::FwSetVSD(char* vsdStr, ProgressCallBack progressFunc, PrintC
         return errmsg("No info section on the image.");
     }
 
+    if (strlen(vsdStr) > VSD_LEN) {
+       return errmsg("VSD string is too long(%d), max allowed length: %d", (int)strlen(vsdStr), VSD_LEN);
+    }
+
     if (!ModifyVSDSection(vsdStr, progressFunc)) {
         return false;
     }
@@ -1941,13 +1908,15 @@ bool Fs2Operations::FwSetVSD(char* vsdStr, ProgressCallBack progressFunc, PrintC
 bool Fs2Operations::FwSetVPD(char* vpdFileStr, PrintCallBack callBackFunc)
 {
     // avoid compiler warrnings
-    vpdFileStr = (char*)NULL;
-    callBackFunc = (PrintCallBack)NULL;
+    (void)vpdFileStr;
+    (void)callBackFunc;
     return errmsg("Setting VPD is not supported in FS2 image format.");
 }
 
 bool Fs2Operations::FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFunc)
 {
+       /*avoid compiler warning*/
+       (void)progressFunc;
     if (!Fs2IntQuery()) {
         return false;
     }
@@ -1967,4 +1936,60 @@ bool Fs2Operations::FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFu
 
 }
 
+bool Fs2Operations::FwResetNvData(ProgressCallBack progressFunc)
+{
+       (void)progressFunc;
+
+    if (!_ioAccess->is_flash()) {
+       return errmsg("Cannot perform operation on Image");
+    }
 
+    if (!Fs2IntQuery()) {
+        return false;
+    }
+    u_int32_t devId = _ioAccess->get_dev_id();
+    if ( devId != CX3_HW_ID && devId != CX3_PRO_HW_ID ) {
+        // TODO: Indicate the device name.
+        return errmsg("Unsupported device type %d", _fwImgInfo.ext_info.dev_type);
+    }
+
+    // find configuration section base addr = (flash size - (config_sectors + config_pad)*sector_size)
+
+    u_int32_t sectorSize = _ioAccess->get_sector_size();
+    u_int32_t AvailFlashSize = _fwImgInfo.actuallyFailsafe ? (_ioAccess->get_size()/2) : _ioAccess->get_size();
+    u_int32_t configBaseAddr;
+       if (_fwImgInfo.actuallyFailsafe) {
+               configBaseAddr = AvailFlashSize  - ((_fs2ImgInfo.ext_info.config_sectors + _fs2ImgInfo.ext_info.config_pad) * sectorSize);
+       } else {
+               // For non FS image, there's an optional offset + 2 consecutive config areas
+        configBaseAddr = AvailFlashSize - (_fs2ImgInfo.ext_info.config_sectors * 2 + _fs2ImgInfo.ext_info.config_pad) * sectorSize;
+       }
+
+    //printf("-D- config_sectors:0x%x config_pads: 0x%x , sector_size:0x%x, configBaseAddr:0x%x, flashSize:0x%x\n",
+       //              _fs2ImgInfo.ext_info.config_sectors, _fs2ImgInfo.ext_info.config_pad, _ioAccess->get_sector_size(),configBaseAddr, AvailFlashSize);
+
+       //erase addresses : configBaseAddr-AvailFlashSize
+       for (u_int32_t eraseAddr=configBaseAddr; eraseAddr<AvailFlashSize; eraseAddr+=sectorSize ) {
+               if (!((Flash*)_ioAccess)->erase_sector(eraseAddr)) {
+                       return errmsg("failed to erase configuration address: 0x%x. %s", eraseAddr, _ioAccess->err());
+               }
+               if (_fwImgInfo.actuallyFailsafe) { // erase config sectors on the other half aswell
+                       ((Flash*)_ioAccess)->set_address_convertor(_fwImgInfo.cntxLog2ChunkSize, !(_fwImgInfo.imgStart != 0));
+                       if (!((Flash*)_ioAccess)->erase_sector(eraseAddr)) {
+                               ((Flash*)_ioAccess)->set_address_convertor(_fwImgInfo.cntxLog2ChunkSize, (_fwImgInfo.imgStart != 0));;
+                               return errmsg("failed to erase configuration address: 0x%x. %s", eraseAddr, _ioAccess->err());
+                       }
+                       // restore address converter
+                       ((Flash*)_ioAccess)->set_address_convertor(_fwImgInfo.cntxLog2ChunkSize, (_fwImgInfo.imgStart != 0));
+               }
+       }
+    return true;
+
+}
+
+bool Fs2Operations::FwShiftDevData(PrintCallBack progressFunc)
+{
+    // avoid compiler warrnings
+    (void)progressFunc;
+    return errmsg("Shifting device data sections is not supported in FS2 image format.");
+}
index 4717fc09079ff1b10928255ba8a5830de69a8e9f..203869c148ec354d5861b2da9e9c2b6132e8f3b8 100644 (file)
@@ -63,6 +63,8 @@ public:
     virtual bool FwSetVSD(char* vsdStr, ProgressCallBack progressFunc=(ProgressCallBack)NULL, PrintCallBack printFunc=(PrintCallBack)NULL);
     virtual bool FwSetVPD(char* vpdFileStr, PrintCallBack callBackFunc=(PrintCallBack)NULL);
     virtual bool FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFunc=(ProgressCallBack)NULL);
+    virtual bool FwShiftDevData(PrintCallBack progressFunc=(PrintCallBack)NULL);
+    virtual bool FwResetNvData(ProgressCallBack progressFunc=(ProgressCallBack)NULL);
 
     virtual bool FwGetSection (u_int32_t sectType, std::vector<u_int8_t>& sectInfo);
 
@@ -72,7 +74,6 @@ public:
     virtual bool FwInit();
     virtual bool FwReadData(void* image, u_int32_t* image_size);
     virtual bool FwReadRom(std::vector<u_int8_t>& romSect);
-    virtual bool FwTest(u_int32_t *data); // Add callback print
 
 
 private:
@@ -142,7 +143,7 @@ private:
     bool patchGUIDs (Fs2Operations& imageOps, bool patch_macs, bool patch_uids, bool user_guids, bool user_macs, bool user_uids,
                                  guid_t new_guids[MAX_GUIDS], guid_t old_guids[MAX_GUIDS], u_int32_t num_of_old_guids);
     void patchGUIDsSection(u_int32_t *buf, u_int32_t ind, guid_t guids[MAX_GUIDS], int nguids);
-    bool patchImageVsd(Fs2Operations &imgFwOps, char* userVsd=(char*)NULL);
+    bool patchImageVsd(Fs2Operations &imgFwOps, const char* userVsd=(char*)NULL);
     void PatchInfoSect(u_int8_t* rawSect, u_int32_t vsdOffs, const char* vsd);
     void initSectToRead(int imp_index);
     //needed for fs2burn
@@ -158,8 +159,8 @@ private:
     bool Fs2IsMacAvailable();
     bool CheckBxMacsFormat(guid_t* guids, int index, int user_uids);
 
-    bool ModifyVSDSection(char *vsd, ProgressCallBack callBackFunc=(ProgressCallBack)NULL);
-    bool ReburnNewImage(u_int8_t *data, char *feature_name, ProgressCallBack callBackFunc=(ProgressCallBack)NULL);
+    bool ModifyVSDSection(const char *vsd, ProgressCallBack callBackFunc=(ProgressCallBack)NULL);
+    bool ReburnNewImage(u_int8_t *data, const char *feature_name, ProgressCallBack callBackFunc=(ProgressCallBack)NULL);
     bool packStripedImageData(u_int8_t *striped_data, u_int8_t *normal_data, u_int32_t length, u_int32_t &striped_length,
                               bool needs_repack, u_int32_t cntxLog2ChunkSize);
     bool Fs2SetGuids(sg_params_t& sgParam, PrintCallBack callBackFunc=(PrintCallBack)NULL, ProgressCallBack progressFunc=(ProgressCallBack)NULL);
index e92e548abfbe65bf1320bad3883dcafc0b83178e..050db3ebd8aa6987fddd06d210f7dcb0df5da315 100644 (file)
 
 
 #include <stdlib.h>
+#include <algorithm>
 
 #include "fs3_ops.h"
 
 #include <vector>
 
+#define FS3_FLASH_SIZE 0x400000
 
 const u_int32_t Fs3Operations::_itocSignature[4] = {
         ITOC_ASCII,   // Ascii of "MTFW"
@@ -55,12 +57,14 @@ const Fs3Operations::SectionInfo Fs3Operations::_fs3SectionsInfoArr[] = {
     {FS3_PCIE_LINK_CODE, "PCIE_LINK_CODE"},
     {FS3_IRON_PREP_CODE, "IRON_PREP_CODE"},
     {FS3_POST_IRON_BOOT_CODE, "POST_IRON_BOOT_CODE"},
+    {FS3_UPGRADE_CODE, "FS3_UPGRADE_CODE"},
     {FS3_HW_BOOT_CFG,   "HW_BOOT_CFG"},
     {FS3_HW_MAIN_CFG,   "HW_MAIN_CFG"},
     {FS3_IMAGE_INFO,    "IMAGE_INFO"},
     {FS3_FW_BOOT_CFG,   "FW_BOOT_CFG"},
     {FS3_FW_MAIN_CFG,   "FW_MAIN_CFG"},
     {FS3_ROM_CODE,      "ROM_CODE"},
+    {FS3_RESET_INFO,    "FS3_RESET_INFO"},
     {FS3_DBG_LOG_MAP,   "DBG_LOG_MAP"},
     {FS3_DBG_FW_INI,    "DBG_FW_INI"},
     {FS3_DBG_FW_PARAMS, "DBG_FW_PARAMS"},
@@ -76,12 +80,11 @@ bool Fs3Operations::Fs3UpdateImgCache(u_int8_t *buff, u_int32_t addr, u_int32_t
 {
     // vector<u_int8_t>::iterator it;
     u_int32_t min_required_size = addr + size;
-    u_int32_t i;
 
     if (_fs3ImgInfo.imageCache.size() < min_required_size) {
         _fs3ImgInfo.imageCache.resize(min_required_size);
     }
-    for (i = 0; i < size; i++) {
+    for (u_int32_t i = 0; i < size; i++) {
         _fs3ImgInfo.imageCache.at(addr + i) = buff[i];
     }
     return true;
@@ -165,6 +168,9 @@ bool Fs3Operations::GetImageInfo(u_int8_t *buff)
     _fwImgInfo.ext_info.mic_ver[1] = image_info.mic_version.MINOR;
     _fwImgInfo.ext_info.mic_ver[2] = image_info.mic_version.SUBMINOR;
 
+    _fwImgInfo.ext_info.fw_rel_date[0] = (u_int16_t)image_info.FW_VERSION.Day;
+    _fwImgInfo.ext_info.fw_rel_date[1] = (u_int16_t)image_info.FW_VERSION.Month;
+    _fwImgInfo.ext_info.fw_rel_date[2] = (u_int16_t)image_info.FW_VERSION.Year;
 
     strcpy(_fs3ImgInfo.ext_info.image_vsd, image_info.vsd);
     strcpy(_fwImgInfo.ext_info.psid, image_info.psid);
@@ -371,7 +377,7 @@ bool Fs3Operations::VerifyTOC(u_int32_t dtoc_addr, bool& bad_signature, VerifyCa
 
 bool Fs3Operations::FwVerify(VerifyCallBack verifyCallBackFunc, bool isStripedImage, bool showItoc) {
     //dummy assignment to avoid compiler warrning (isStripedImage is not used in fs3)
-    isStripedImage = true;
+    (void)isStripedImage;
 
     struct QueryOptions queryOptions;
     queryOptions.readRom = true;
@@ -466,7 +472,7 @@ bool Fs3Operations::FwQuery(fw_info_t *fwInfo, bool readRom, bool isStripedImage
 {
     //isStripedImage flag is not needed in FS3 image format
     // Avoid warning - no striped image in FS3
-    isStripedImage = false;
+    (void)isStripedImage;
     if (!Fs3IntQuery(readRom)) {
         return false;
     }
@@ -507,8 +513,7 @@ bool Fs3Operations::UpdateDevDataITOC(u_int8_t *image_data, struct toc_info *ima
     return true;
 }
 
-#define FS3_FLASH_SIZE 0x400000
-bool Fs3Operations::CheckFs3ImgSize(Fs3Operations imageOps)
+bool Fs3Operations::CheckFs3ImgSize(Fs3Operations& imageOps)
 {
     u_int32_t flashSize = (_ioAccess->is_flash()) ? _ioAccess->get_size() : FS3_FLASH_SIZE;
     u_int32_t maxFsImgSize = flashSize / 2;
@@ -521,6 +526,23 @@ bool Fs3Operations::CheckFs3ImgSize(Fs3Operations imageOps)
     return true;
 }
 
+bool Fs3Operations::GetMaxImageSize(u_int32_t flash_size, bool image_is_fs, u_int32_t &max_image_size)
+{
+       // max image size is calculated as the following :
+       // for failsafe image :   flash_size/2 - 6*sector_size
+       // for nonfailsafe image: flash_size - 6*sector_size
+       // the 6*sector_size is for the last two sections on the flash (DEV_INFO and MFG_INFO) which are not part of the image burnt.
+
+    u_int32_t sector_size = _ioAccess->get_sector_size();
+    if (image_is_fs) {
+        max_image_size = (flash_size / 2) - (6 * sector_size);
+    } else {
+        // For non FS image,
+        max_image_size = flash_size - (6 * sector_size);
+    }
+
+return true;
+}
 bool Fs3Operations::BurnFs3Image(Fs3Operations &imageOps,
                                   ExtBurnParams& burnParams)
 {
@@ -566,29 +588,11 @@ bool Fs3Operations::BurnFs3Image(Fs3Operations &imageOps,
 
     }
 
-
     // TODO: Check that the dev data is not been overridden
     {
-
-         // TODO : remove these remnants of the old printing system , we use callback func now 
-         char * pre_message = (char*)"Burning FS3 FW image without signatures";
          u_int32_t  zeroes     = 0;
-         char message[128], message1[128], buff[128];
          int allow_nofs = 0;
 
-         if (pre_message == NULL) {
-             sprintf(message, "Burning FW image without signatures");
-         } else {
-             sprintf(message, pre_message);
-         }
-         int str_len = strlen(message), restore_len = strlen(RESTORING_MSG);
-         str_len = (restore_len > str_len) ? restore_len : str_len;
-
-         sprintf(buff, "%%-%ds  - ", str_len);
-
-         sprintf(message1, buff,  message);
-
-
          if (!writeImage(burnParams.progressFunc, 16 , data8 + 16, image_size - 16)) {
              return false;
          }
@@ -613,11 +617,10 @@ bool Fs3Operations::BurnFs3Image(Fs3Operations &imageOps,
 
                  u_int32_t cntx_image_start[CNTX_START_POS_SIZE];
                  u_int32_t cntx_image_num;
-                 u_int32_t i;
 
                  CntxFindAllImageStart(f, cntx_image_start, &cntx_image_num);
                  // Address convertor is disabled now - use phys addresses
-                 for (i = 0; i < cntx_image_num; i++) {
+                 for (u_int32_t i = 0; i < cntx_image_num; i++) {
                      if (cntx_image_start[i] != new_image_start) {
                          if (!f->write(cntx_image_start[i], &zeroes, sizeof(zeroes), true)) {
                              return false;
@@ -647,7 +650,9 @@ bool Fs3Operations::Fs3Burn(Fs3Operations &imageOps, ExtBurnParams& burnParams)
     if (imageOps.FwType() != FIT_FS3) {
         return errmsg("FW image type is not FS3\n");
     }
-    if (!Fs3IntQuery()) {
+    bool devIntQueryRes = Fs3IntQuery();
+
+    if (!devIntQueryRes) {
         return false;
     }
     // for image we execute full verify to bring all the information needed for ROM Patch
@@ -664,37 +669,62 @@ bool Fs3Operations::Fs3Burn(Fs3Operations &imageOps, ExtBurnParams& burnParams)
         return false;
     }
 
+    std::vector<u_int8_t> newImageData(imageOps._fwImgInfo.lastImageAddr);
     Fs3Operations *imgToBurn = &imageOps;
+    bool createNewImg = false;
 
     // ROM patchs
     if (((burnParams.burnRomOptions == ExtBurnParams::BRO_FROM_DEV_IF_EXIST) && (_fwImgInfo.ext_info.roms_info.exp_rom_found)) || // There is ROM in device and user choses to keep it
             ((burnParams.burnRomOptions == ExtBurnParams::BRO_DEFAULT) && (!imageOps._fwImgInfo.ext_info.roms_info.exp_rom_found && _fwImgInfo.ext_info.roms_info.exp_rom_found))) { // No ROM in image and ROM in device
         // here we should take rom from device and insert into the image
         // i.e if we have rom in image remove it and put the rom from the device else just put rom from device.
-
         // 1. use Fs3ModifySection to integrate _romSect buff with the image , newImageData contains the modified image buffer
-        std::vector<u_int8_t> newImageData(imageOps._fwImgInfo.lastImageAddr);
         std::vector<u_int8_t> romSect = _romSect;
         TOCPUn((u_int32_t*)&romSect[0], romSect.size()/4);
         if (!imageOps.Fs3ReplaceSectionInDevImg(FS3_ROM_CODE, FS3_PCI_CODE, true, (u_int8_t*)&newImageData[0], imageOps._fwImgInfo.lastImageAddr,
-            (u_int32_t*)&romSect[0], (u_int32_t)romSect.size())) {
+            (u_int32_t*)&romSect[0], (u_int32_t)romSect.size(), true)) {
             return errmsg("failed to update ROM in image. %s", imageOps.err());
         }
-        // 2. create fs3Operation Obj (handl type BUFF)
-        // open the image buffer
-        FwOperations* imageWithRomOps = FwOperationsCreate((void*)&newImageData[0], (void*)&imageOps._fwImgInfo.lastImageAddr, (char*)NULL, FHT_FW_BUFF, (char*)NULL, (int)NULL);
-        if (!imageWithRomOps) {
-            return errmsg("Internal error: The prepared image is corrupted.");
-        }
-        // 3. verify it
-        if (!((Fs3Operations*)imageWithRomOps)->Fs3IntQuery(true,false)) {
-            errmsg("Internal error: The prepared image is corrupted: %s", imageWithRomOps->err());
-            imageWithRomOps->FwCleanUp();
-            delete imageWithRomOps;
-            return false;
+        createNewImg = true;
+    }
+
+    // image vsd patch
+    if (!burnParams.useImagePs && burnParams.vsdSpecified ) {
+       // get image info section :
+       struct toc_info *imageInfoToc;
+       if (!imageOps.Fs3GetItocInfo(imageOps._fs3ImgInfo.tocArr, imageOps._fs3ImgInfo.numOfItocs, FS3_IMAGE_INFO, imageInfoToc)){
+               return errmsg("failed to get Image Info section.");
+       }
+       // modify it:
+       std::vector<u_int8_t> imageInfoSect = imageInfoToc->section_data;
+       struct cibfw_image_info image_info;
+       cibfw_image_info_unpack(&image_info, &imageInfoSect[0]);
+       strncpy(image_info.vsd, burnParams.userVsd, VSD_LEN);
+       cibfw_image_info_pack(&image_info, &imageInfoSect[0]);
+       // re-insert it into the image:
+        if (!imageOps.Fs3ReplaceSectionInDevImg(FS3_IMAGE_INFO, FS3_FW_ADB, true, (u_int8_t*)&newImageData[0], imageOps._fwImgInfo.lastImageAddr,
+            (u_int32_t*)&imageInfoSect[0], (u_int32_t)imageInfoSect.size(), true)) {
+            return errmsg("failed to update image VSD in image. %s", imageOps.err());
         }
-        // 4. pass it to BurnFs3Image instead of imageOps
-        imgToBurn = (Fs3Operations*)imageWithRomOps;
+        createNewImg = true;
+    }
+
+    // create fs3Operation Obj (handl type BUFF) if NEEDED
+    // open the image buffer
+    if (createNewImg) {
+       FwOperations* newImageOps = FwOperationsCreate((void*)&newImageData[0], (void*)&imageOps._fwImgInfo.lastImageAddr, (char*)NULL, FHT_FW_BUFF);
+       if (!newImageOps) {
+               return errmsg("Internal error: The prepared image is corrupted.");
+       }
+       // 3. verify it
+       if (!((Fs3Operations*)newImageOps)->Fs3IntQuery(true,false)) {
+               errmsg("Internal error: The prepared image is corrupted: %s", newImageOps->err());
+               newImageOps->FwCleanUp();
+               delete newImageOps;
+               return false;
+       }
+       // 4. pass it to BurnFs3Image instead of imageOps
+       imgToBurn = (Fs3Operations*)newImageOps;
     }
 
     bool rc = BurnFs3Image(*imgToBurn, burnParams);
@@ -729,8 +759,8 @@ bool Fs3Operations::FwBurnAdvanced(FwOperations *imageOps, ExtBurnParams& burnPa
 bool Fs3Operations::FwBurnBlock(FwOperations *imageOps, ProgressCallBack progressFunc)
 {
     // Avoid Warning!
-    imageOps = (FwOperations*)NULL;
-    progressFunc = (ProgressCallBack)NULL;
+    (void)imageOps;
+    (void)progressFunc;
     return errmsg("FwBurnBlock is not supported anymore in FS3 image.");
 }
 
@@ -760,26 +790,6 @@ bool Fs3Operations::FwReadData(void* image, u_int32_t* imageSize)
     return true;
 }
 
-
-bool Fs3Operations::FwTest(u_int32_t *data)
-{
-    _ioAccess->set_address_convertor(0,0);
-    if (!_ioAccess->read(0, data)) {
-        return false;
-    }
-    /*
-
-    if (!((Flash*)_ioAccess)->write(0, 0x12345678)) {
-        return false;
-    }
-
-    if (!_ioAccess->read(0x0, data)) {
-        return false;
-    }
-    */
-    return true;
-}
-
 bool Fs3Operations::FwReadRom(std::vector<u_int8_t>& romSect)
 {
     if (!Fs3IntQuery()) {
@@ -828,10 +838,19 @@ bool Fs3Operations::FwSetMFG(guid_t baseGuid, PrintCallBack callBackFunc)
 bool Fs3Operations::FwSetGuids(sg_params_t& sgParam, PrintCallBack callBackFunc, ProgressCallBack progressFunc)
 {
     // Avoid Warning because there is no need for progressFunc
-    progressFunc = (ProgressCallBack)NULL;
+    (void)progressFunc;
     if (sgParam.userGuids.empty()) {
         return errmsg("Base GUID not found.");
     }
+    //query device to get mfg info (for guids override en bit)
+    if (!Fs3IntQuery(false)) {
+        return false;
+    }
+
+    if (!_fs3ImgInfo.ext_info.guids_override_en) {
+       return errmsg("guids override is not set, cannot set device guids");
+    }
+
     if (!Fs3UpdateSection(&sgParam.userGuids[0], FS3_DEV_INFO, true, CMD_SET_GUIDS, callBackFunc)) {
         return false;
     }
@@ -988,7 +1007,7 @@ bool Fs3Operations::UpdateImageAfterInsert(struct toc_info *tocArr, u_int32_t nu
 }
 
 bool Fs3Operations::Fs3ReplaceSectionInDevImg(fs3_section_t sectionType, fs3_section_t nextSectionType, bool toAdd, u_int8_t* newImgData, u_int32_t newImageSize,
-        u_int32_t* newSectData, u_int32_t NewSectSize)
+        u_int32_t* newSectData, u_int32_t NewSectSize, bool UpdateExsistingTocArr)
 {
     u_int32_t newSectAddr;
     u_int32_t numOfItocs;
@@ -1007,6 +1026,13 @@ bool Fs3Operations::Fs3ReplaceSectionInDevImg(fs3_section_t sectionType, fs3_sec
     if (!UpdateImageAfterInsert(tocArr, numOfItocs, newImgData, newImageSize)) {
         return false;
     }
+
+    if (UpdateExsistingTocArr) {
+       _fs3ImgInfo.numOfItocs = numOfItocs;
+       for (u_int32_t i=0;i < numOfItocs;i++) {
+               _fs3ImgInfo.tocArr[i] = tocArr[i];
+       }
+    }
     return true;
 }
 
@@ -1024,7 +1050,6 @@ bool Fs3Operations::Fs3ModifySection(fs3_section_t sectionType, fs3_section_t ne
 
     if (!Fs3ReplaceSectionInDevImg(sectionType, neighbourSection, toAdd, (u_int8_t*)&newImageData[0], _fwImgInfo.lastImageAddr,
             newSectData, newSectSize)) {
-        ///delete[] newImageData;
         return false;
     }
     // Burn the new image into the device.
@@ -1107,7 +1132,7 @@ bool Fs3Operations::Fs3GetItocInfo(struct toc_info *tocArr, int num_of_itocs, fs
     return errmsg("ITOC entry type: %s (%d) not found", GetSectionNameByType(sect_type), sect_type);
 }
 
-bool Fs3Operations::Fs3UpdateMfgUidsSection(struct toc_info *curr_toc, std::vector<u_int8_t>  section_data, guid_t base_uid, 
+bool Fs3Operations::Fs3UpdateMfgUidsSection(struct toc_info *curr_toc, std::vector<u_int8_t>  section_data, guid_t base_uid,
                                             std::vector<u_int8_t>  &newSectionData)
 {
     struct cibfw_mfg_info mfg_info;
@@ -1151,8 +1176,10 @@ bool Fs3Operations::Fs3UpdateVsdSection(struct toc_info *curr_toc, std::vector<u
     struct cibfw_device_info dev_info;
     cibfw_device_info_unpack(&dev_info, (u_int8_t*)&section_data[0]);
     size_t len = strlen(user_vsd);
-    if (len > VSD_LEN-1) {
-        return errmsg("VSD too long: %d", (int)len);
+    // check VSD size before modifying , this check is redundant as it is already check in FwSetVSD
+    // TODO: remove this check
+    if (len > VSD_LEN) {
+        return errmsg("VSD string is too long(%d), max allowed length: %d", (int)len, VSD_LEN);
     }
     strcpy(dev_info.vsd, user_vsd);
     newSectionData = section_data;
@@ -1165,12 +1192,13 @@ bool Fs3Operations::Fs3UpdateVpdSection(struct toc_info *curr_toc, char *vpd,
                                std::vector<u_int8_t>  &newSectionData)
 {
     int vpd_size;
-    u_int8_t *vpd_data;
+    u_int8_t *vpd_data = NULL;
 
     if (!ReadImageFile(vpd, vpd_data, vpd_size)) {
         return false;
     }
     if (vpd_size % 4) {
+        delete[] vpd_data;
         return errmsg("Size of VPD file: %d is not 4-byte alligned!", vpd_size);
     }
     GetSectData(newSectionData, (u_int32_t*)vpd_data, vpd_size);
@@ -1179,21 +1207,31 @@ bool Fs3Operations::Fs3UpdateVpdSection(struct toc_info *curr_toc, char *vpd,
     return true;
 }
 
-bool Fs3Operations::Fs3GetNewSectionAddr(struct toc_info *tocArr, struct toc_info *curr_toc, u_int32_t &NewSectionAddr, bool failsafe_section)
+// DEV_INFO section is failsafe
+#define DEV_INFO_ADDR_1 0x3fd000
+#define DEV_INFO_ADDR_2 0x3fe000
+// all device data section might be shifted by SHIFT_SIZE due to
+// flash with write protect sector 0f 64kb instead of 4kb
+#define SHIFT_SIZE 0xf000 // 60kb
+
+
+bool Fs3Operations::Fs3GetNewSectionAddr(struct toc_info *curr_toc, u_int32_t &NewSectionAddr, bool failsafe_section)
 {
     // printf("-D- addr  = %#x\n", curr_toc->toc_entry.flash_addr);
-    u_int32_t sector_size = (_ioAccess->is_flash()) ? _ioAccess->get_sector_size() : FS3_DEFAULT_SECTOR_SIZE;
+    //u_int32_t sector_size = (_ioAccess->is_flash()) ? _ioAccess->get_sector_size() : FS3_DEFAULT_SECTOR_SIZE;
+
     u_int32_t flash_addr = curr_toc->toc_entry.flash_addr << 2;
     // HACK: THIS IS AN UGLY HACK, SHOULD BE REMOVED ASAP
+    // Possible solution : if a section is failsafe  make its size 2kb thus both section will fit in a 4kb chunk (addr & 0x800 == 0x800 then its in second place, if == 0 its in first place )
     if (failsafe_section) {
-        NewSectionAddr = (flash_addr == 0x3fd000) ? 0x3fe000 : 0x3fd000;
+       if ((flash_addr == DEV_INFO_ADDR_1) || (flash_addr == DEV_INFO_ADDR_2)){
+               NewSectionAddr = (flash_addr == DEV_INFO_ADDR_1) ? DEV_INFO_ADDR_2 : DEV_INFO_ADDR_1;
+       } else {// dev sections are shifted by 60 kb
+               NewSectionAddr = (flash_addr == DEV_INFO_ADDR_1 - SHIFT_SIZE) ? DEV_INFO_ADDR_2 - SHIFT_SIZE: DEV_INFO_ADDR_1 - SHIFT_SIZE;
+       }
     } else {
         NewSectionAddr = flash_addr;
     }
-    // HACK: Avoid warning
-    tocArr = NULL;
-    // fbase = 0;
-    sector_size = 0;
     return true;
 }
 
@@ -1237,68 +1275,25 @@ bool Fs3Operations::Fs3UpdateItocInfo(struct toc_info *curr_toc, u_int32_t newSe
  }
 
 bool Fs3Operations::Fs3ReburnItocSection(u_int32_t newSectionAddr,
-        u_int32_t newSectionSize, std::vector<u_int8_t>  newSectionData, char *msg, PrintCallBack callBackFunc)
+        u_int32_t newSectionSize, std::vector<u_int8_t>  newSectionData, const char *msg, PrintCallBack callBackFunc)
 {
-
-    // HACK SHOULD BE REMOVED ASAP
-    u_int32_t sector_size = (_ioAccess->is_flash()) ? _ioAccess->get_sector_size() : FS3_DEFAULT_SECTOR_SIZE;
-    u_int32_t oldItocAddr = _fs3ImgInfo.itocAddr;
-    u_int32_t newItocAddr = (_fs3ImgInfo.firstItocIsEmpty) ? (_fs3ImgInfo.itocAddr - sector_size) :  (_fs3ImgInfo.itocAddr + sector_size);
     char message[127];
 
     sprintf(message, "Updating %-4s section - ", msg);
     // Burn new Section
     // we pass a null callback and print the progress here as the writes are small (guids/mfg/vpd_str)
     // in the future if we want to pass the cb prints to writeImage , need to change the signature of progressCallBack to recieve and optional string to print
-    if (callBackFunc) {
-        callBackFunc(message);
-    }
-    if (!writeImage((ProgressCallBack)NULL, newSectionAddr , (u_int8_t*)&newSectionData[0], newSectionSize, true)) {
-        if (callBackFunc) {
-            callBackFunc("FAILED\n");
-        }
-        return false;
-    }
-    if (callBackFunc) {
-        callBackFunc("OK\n");
-    }
-    // Update new ITOC
-    std::vector<u_int8_t>  itocEntriesData;
-    u_int32_t itocSize = (_fs3ImgInfo.numOfItocs + 1 ) * CIBFW_ITOC_ENTRY_SIZE + CIBFW_ITOC_HEADER_SIZE;
-    u_int8_t *p = itocEntriesData.get_allocator().allocate(itocSize);
-    memcpy(p, _fs3ImgInfo.itocHeader, CIBFW_ITOC_HEADER_SIZE);
-    for (int i = 0; i < _fs3ImgInfo.numOfItocs; i++) {
-        struct toc_info *curr_itoc = &_fs3ImgInfo.tocArr[i];
-        memcpy(p + CIBFW_ITOC_HEADER_SIZE + i * CIBFW_ITOC_ENTRY_SIZE, curr_itoc->data, CIBFW_ITOC_ENTRY_SIZE);
-    }
-    memset(&p[itocSize] - CIBFW_ITOC_ENTRY_SIZE, FS3_END, CIBFW_ITOC_ENTRY_SIZE);
-
 
-    if (callBackFunc) {
-        callBackFunc("Updating ITOC section - ");
-    }
-    if (!writeImage((ProgressCallBack)NULL, newItocAddr , p, itocSize, false)) {
-        if (callBackFunc) {
-            callBackFunc("FAILED\n");
-        }
-        return false;
-    }
-    if (callBackFunc) {
-        callBackFunc("OK\n");
-    }
-    u_int32_t zeros = 0;
+    PRINT_PROGRESS(callBackFunc, message);
 
-    if (callBackFunc) {
-        callBackFunc("Restoring signature   - ");
-    }
-    if (!writeImage((ProgressCallBack)NULL, oldItocAddr, (u_int8_t*)&zeros, 4, false)) {
-        if (callBackFunc) {
-            callBackFunc("FAILED\n");
-        }
+    if (!writeImage((ProgressCallBack)NULL, newSectionAddr , (u_int8_t*)&newSectionData[0], newSectionSize, true)) {
+       PRINT_PROGRESS(callBackFunc, (char*)"FAILED\n");
         return false;
     }
-    if (callBackFunc) {
-        callBackFunc("OK\n");
+    PRINT_PROGRESS(callBackFunc, (char*)"OK\n");
+    // Update new ITOC section
+    if (!reburnItocSection(callBackFunc)) {
+       return false;
     }
     return true;
 }
@@ -1306,11 +1301,10 @@ bool Fs3Operations::Fs3ReburnItocSection(u_int32_t newSectionAddr,
 //add callback if we want info during section update
 bool  Fs3Operations::Fs3UpdateSection(void *new_info, fs3_section_t sect_type, bool is_sect_failsafe, CommandType cmd_type, PrintCallBack callBackFunc)
 {
-    struct toc_info *newTocArr;
     struct toc_info *curr_toc;
     std::vector<u_int8_t> newUidSection;
     u_int32_t newSectionAddr;
-    char *type_msg;
+    const char *type_msg;
     // init sector to read
     _readSectList.push_back(sect_type);
     if (!Fs3IntQuery()) {
@@ -1320,29 +1314,26 @@ bool  Fs3Operations::Fs3UpdateSection(void *new_info, fs3_section_t sect_type, b
     _readSectList.pop_back();
     // _silent = curr_silent;
 
-    // get newTocArr
-    newTocArr = _fs3ImgInfo.tocArr;
-
     if (!Fs3GetItocInfo(_fs3ImgInfo.tocArr, _fs3ImgInfo.numOfItocs, sect_type, curr_toc)) {
          return false;
      }
 
     if (sect_type == FS3_MFG_INFO) {
         guid_t base_uid = *(guid_t*)new_info;
-        type_msg = (char*)"GUID";
+        type_msg = "GUID";
         if (!Fs3UpdateMfgUidsSection(curr_toc, curr_toc->section_data, base_uid, newUidSection)) {
             return false;
         }
     } else if (sect_type == FS3_DEV_INFO) {
         if (cmd_type == CMD_SET_GUIDS) {
             guid_t base_uid = *(guid_t*)new_info;
-            type_msg = (char*)"GUID";
+            type_msg = "GUID";
             if (!Fs3UpdateUidsSection(curr_toc, curr_toc->section_data, base_uid, newUidSection)) {
                 return false;
             }
         } else if(cmd_type == CMD_SET_VSD) {
             char* user_vsd = (char*)new_info;
-            type_msg = (char*)"VSD";
+            type_msg = "VSD";
             if (!Fs3UpdateVsdSection(curr_toc, curr_toc->section_data, user_vsd, newUidSection)) {
                 return false;
             }
@@ -1352,7 +1343,7 @@ bool  Fs3Operations::Fs3UpdateSection(void *new_info, fs3_section_t sect_type, b
         }
     } else if (sect_type == FS3_VPD_R0) {
         char *vpd_file = (char*)new_info;
-        type_msg = (char*)"VPD";
+        type_msg = "VPD";
         if (!Fs3UpdateVpdSection(curr_toc, vpd_file, newUidSection)) {
             return false;
         }
@@ -1361,7 +1352,7 @@ bool  Fs3Operations::Fs3UpdateSection(void *new_info, fs3_section_t sect_type, b
     }
 
 
-    if (!Fs3GetNewSectionAddr(_fs3ImgInfo.tocArr, curr_toc, newSectionAddr, is_sect_failsafe)) {
+    if (!Fs3GetNewSectionAddr(curr_toc, newSectionAddr, is_sect_failsafe)) {
         return false;
     }
     if (!Fs3UpdateItocInfo(curr_toc, newSectionAddr, curr_toc->toc_entry.size, newUidSection)) {
@@ -1377,10 +1368,15 @@ bool  Fs3Operations::Fs3UpdateSection(void *new_info, fs3_section_t sect_type, b
 bool Fs3Operations::FwSetVSD(char* vsdStr, ProgressCallBack progressFunc, PrintCallBack printFunc)
 {
     // Avoid warning
-    progressFunc = (ProgressCallBack)NULL;
+    (void)progressFunc;
     if (!vsdStr) {
         return errmsg("Please specify a valid VSD string.");
     }
+
+    if (strlen(vsdStr) > VSD_LEN) {
+       return errmsg("VSD string is too long(%d), max allowed length: %d", (int)strlen(vsdStr), (int)VSD_LEN);
+    }
+
     if (!Fs3UpdateSection(vsdStr, FS3_DEV_INFO, true, CMD_SET_VSD, printFunc)) {
         return false;
     }
@@ -1389,7 +1385,225 @@ bool Fs3Operations::FwSetVSD(char* vsdStr, ProgressCallBack progressFunc, PrintC
 
 bool Fs3Operations::FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFunc)
 {
-    userKey = (hw_key_t){0,0};
-    progressFunc = (ProgressCallBack)NULL;
+    (void)userKey;
+    (void)progressFunc;
     return errmsg("Set access key not supported.");
 }
+
+bool Fs3Operations::FwResetNvData(ProgressCallBack progressFunc)
+{
+       (void)progressFunc;
+       return errmsg("Unsupported Device, can only reset configuration on a CX3/3-PRO device.");
+       /*
+       // future support for cx4
+
+       if (!Fs3IntQuery(false)) {
+               return false;
+       }
+       if (_fwImgInfo.ext_info.chip_type != CT_CONNECTX) {
+               // TODO: Indicate the device name.
+                  return errmsg("Unsupported device type %d", _fwImgInfo.ext_info.dev_type);
+       }
+
+       struct toc_info *currToc;
+
+       if (!Fs3GetItocInfo(_fs3ImgInfo.tocArr, _fs3ImgInfo.numOfItocs, FS3_NV_DATA, currToc)) {
+               return false;
+       }
+       // allocate new NvData which will contain only zeroes
+       std::vector<u_int8_t> newNvData(currToc->section_data.size());
+       memset(&newNvData[0], 0, currToc->section_data.size());
+
+       return Fs3AddSection(FS3_NV_DATA, FS3_DEV_INFO, (u_int32_t*)&newNvData[0], newNvData.size()/4, progressFunc);
+       */
+}
+
+u_int32_t Fs3Operations::getAbsAddr(toc_info* toc) {
+       if (toc->toc_entry.relative_addr) {
+               return ((toc ->toc_entry.flash_addr << 2) + _fwImgInfo.imgStart);
+       }
+       return toc ->toc_entry.flash_addr << 2;
+}
+
+//get the last fw section address (i.e the maximal address + size of the fw section)
+bool Fs3Operations::getLastFwSAddr(u_int32_t& lastAddr) {
+       struct toc_info *maxToc= NULL;
+       int i;
+       // find first itoc that isnt device data (assumption: there is at least one)
+       for(i=0 ; i < _fs3ImgInfo.numOfItocs ; i++) {
+               maxToc = &(_fs3ImgInfo.tocArr[i]);
+               if (!maxToc->toc_entry.device_data) {
+                       break;
+               }
+       }
+       // find the last non device data itoc
+       for(; i < _fs3ImgInfo.numOfItocs ; i++) {
+               if ((!_fs3ImgInfo.tocArr[i].toc_entry.device_data) && getAbsAddr(&(_fs3ImgInfo.tocArr[i])) > getAbsAddr(maxToc)) {
+                       maxToc = &_fs3ImgInfo.tocArr[i];
+               }
+       }
+       lastAddr = getAbsAddr(maxToc) + (maxToc->toc_entry.size << 2 );
+       return true;
+}
+
+bool Fs3Operations::getFirstDevDataAddr(u_int32_t& firstAddr) {
+       struct toc_info *minToc = NULL;
+       //find first dev data itoc entry
+       int i;
+       for(i=0 ; i < _fs3ImgInfo.numOfItocs ; i++) {
+               if (_fs3ImgInfo.tocArr[i].toc_entry.device_data) {
+                       minToc = &(_fs3ImgInfo.tocArr[i]);
+                       break;
+               }
+       }
+       if (!minToc) {
+               return errmsg("failed to get device data ITOC.");
+       }
+       i++;
+       // find the minimal one
+       for(; i < _fs3ImgInfo.numOfItocs ; i++) {
+               if (_fs3ImgInfo.tocArr[i].toc_entry.device_data && (getAbsAddr(&(_fs3ImgInfo.tocArr[i])) < getAbsAddr(minToc)) ) {
+                       minToc = &(_fs3ImgInfo.tocArr[i]);
+               }
+       }
+       firstAddr = getAbsAddr(minToc);
+       return true;
+}
+
+bool Fs3Operations::reburnItocSection(PrintCallBack callBackFunc) {
+
+    // HACK SHOULD BE REMOVED ASAP
+    u_int32_t sector_size = (_ioAccess->is_flash()) ? _ioAccess->get_sector_size() : FS3_DEFAULT_SECTOR_SIZE;
+    // Itoc section is failsafe (two sectors after boot section are reserved for itoc entries)
+    u_int32_t oldItocAddr = _fs3ImgInfo.itocAddr;
+    u_int32_t newItocAddr = (_fs3ImgInfo.firstItocIsEmpty) ? (_fs3ImgInfo.itocAddr - sector_size) :  (_fs3ImgInfo.itocAddr + sector_size);
+
+    // Update new ITOC
+    u_int32_t itocSize = (_fs3ImgInfo.numOfItocs + 1 ) * CIBFW_ITOC_ENTRY_SIZE + CIBFW_ITOC_HEADER_SIZE;
+    u_int8_t *p = new u_int8_t[itocSize];
+    memcpy(p, _fs3ImgInfo.itocHeader, CIBFW_ITOC_HEADER_SIZE);
+    for (int i = 0; i < _fs3ImgInfo.numOfItocs; i++) {
+        struct toc_info *curr_itoc = &_fs3ImgInfo.tocArr[i];
+        memcpy(p + CIBFW_ITOC_HEADER_SIZE + i * CIBFW_ITOC_ENTRY_SIZE, curr_itoc->data, CIBFW_ITOC_ENTRY_SIZE);
+    }
+    memset(&p[itocSize] - CIBFW_ITOC_ENTRY_SIZE, FS3_END, CIBFW_ITOC_ENTRY_SIZE);
+
+    PRINT_PROGRESS(callBackFunc, (char*)"Updating ITOC section - ");
+    bool rc = writeImage((ProgressCallBack)NULL, newItocAddr , p, itocSize, false);
+    delete[] p;
+    if (!rc) {
+       PRINT_PROGRESS(callBackFunc,(char*)"FAILED\n");
+        return false;
+    }
+    PRINT_PROGRESS(callBackFunc,(char*)"OK\n");
+    u_int32_t zeros = 0;
+
+    PRINT_PROGRESS(callBackFunc,(char*)"Restoring signature   - ");
+    if (!writeImage((ProgressCallBack)NULL, oldItocAddr, (u_int8_t*)&zeros, 4, false)) {
+        PRINT_PROGRESS(callBackFunc,(char*)"FAILED\n");
+        return false;
+    }
+    PRINT_PROGRESS(callBackFunc,(char*)"OK\n");
+    return true;
+}
+
+#define PUSH_DEV_DATA(vec)\
+        vec.push_back(FS3_MFG_INFO);\
+        vec.push_back(FS3_DEV_INFO);\
+        vec.push_back(FS3_NV_DATA);\
+        vec.push_back(FS3_VPD_R0)
+#define POP_DEV_DATA(vec)\
+        vec.pop_back();\
+        vec.pop_back();\
+        vec.pop_back();\
+        vec.pop_back()
+
+bool Fs3Operations::TocComp::operator() (toc_info* elem1, toc_info* elem2)
+{
+       u_int32_t absAddr1 = elem1->toc_entry.relative_addr ? elem1->toc_entry.flash_addr + _startAdd : elem1->toc_entry.flash_addr;
+       u_int32_t absAddr2 = elem2->toc_entry.relative_addr ? elem2->toc_entry.flash_addr + _startAdd : elem2->toc_entry.flash_addr;
+       if (absAddr1 < absAddr2) {
+               return true;
+       }
+       return false;
+}
+
+bool Fs3Operations::FwShiftDevData(PrintCallBack progressFunc)
+{
+       if (!_ioAccess->is_flash()) {
+               return errmsg("cannot shift device data sections on Image.");
+       }
+       const char* flashType = ((Flash*)_ioAccess)->getFlashType();
+       if (flashType == NULL) {
+               return errmsg("Cannot shift device data on old flash types.");
+       }
+       if (strcasecmp(flashType,"N25Q0XX")!= 0) {
+               return errmsg("Cannot shift device data on flash type %s.", flashType);
+       }
+
+       //query device and get device data sectors.
+       PUSH_DEV_DATA(_readSectList);
+    if (!Fs3IntQuery()) {
+       POP_DEV_DATA(_readSectList);
+        return false;
+    }
+    POP_DEV_DATA(_readSectList);
+
+       u_int32_t lastFwDataAddr;
+       u_int32_t firstDevDataAddr;
+       if (!getLastFwSAddr(lastFwDataAddr) || !getFirstDevDataAddr(firstDevDataAddr)) {
+               return errmsg("Failed to get ITOC information.");
+       }
+
+       // check if we already shifted
+       struct toc_info* mfgToc;
+       if (!Fs3GetItocInfo(_fs3ImgInfo.tocArr, _fs3ImgInfo.numOfItocs, FS3_MFG_INFO, mfgToc)) {
+               return errmsg("Failed to get MFG_INFO ITOC information.");
+       }
+
+       if (getAbsAddr(mfgToc) < _ioAccess->get_size() - _ioAccess->get_sector_size()) {
+               return errmsg("Device data sections already shifted.");
+       }
+
+       //check if we can shift all dev data sections by 60KB
+       if (lastFwDataAddr > (firstDevDataAddr - SHIFT_SIZE)) {
+               return errmsg("Cannot shift device data sections, fw image is too big.");
+       }
+       // for each device data section move it by an offset of 60kb (0xf000)
+
+    PRINT_PROGRESS(progressFunc,(char*)"Shifting dev data section - ");
+
+    // possible problem : if itoc array isnt ordered by ascending flash address and dev data sections are larger that 60kb
+    // there is a chance we runover exsisting device data sections
+    // Fix : preform the section shift by order from the lowest addresss to the highest.
+    std::vector<struct toc_info*> sortedTocs(_fs3ImgInfo.numOfItocs);
+    for (int i=0 ; i< _fs3ImgInfo.numOfItocs ; i++) {
+       sortedTocs[i]= &(_fs3ImgInfo.tocArr[i]);
+    }
+    std::sort(sortedTocs.begin(), sortedTocs.end(), TocComp(_fwImgInfo.imgStart));
+
+    // shift the location of device data sections by SHIFT_SIZE (60kb)
+       for (std::vector<struct toc_info*>::iterator it = sortedTocs.begin() ; it != sortedTocs.end(); it++) {
+               if ((*it)->toc_entry.device_data) {
+                       // update the itoc (basically update the flash_addr and itoc entry crc)
+                       struct toc_info *currToc = *it;
+                       if (!Fs3UpdateItocInfo(currToc, ((currToc->toc_entry.flash_addr << 2) - SHIFT_SIZE))) {
+                           PRINT_PROGRESS(progressFunc,(char*)"FAILED\n");
+                               return false;
+                       }
+                       // write the section to its new place in the flash
+                       if (!writeImage((ProgressCallBack)NULL, getAbsAddr(currToc) , (u_int8_t*)&currToc->section_data[0], (currToc->toc_entry.size << 2), true)) {
+                           PRINT_PROGRESS(progressFunc,(char*)"FAILED\n");
+                           return false;
+                       }
+               }
+       }
+    PRINT_PROGRESS(progressFunc,(char*)"OK\n");
+       // update itoc section
+    if (!reburnItocSection(progressFunc)) {
+       return false;
+    }
+    return true;
+}
+
+
index 466db52927225bb9e81294002f0a8985840f848d..236cd6d5d614f95222bbb5fd3137f4d71b604a14 100644 (file)
@@ -45,7 +45,10 @@ public:
 
 
     Fs3Operations(FBase *ioAccess) :
-        FwOperations(ioAccess) {};
+        FwOperations(ioAccess)
+        {
+            _isFullVerify = false;
+        };
 
     virtual ~Fs3Operations()  {};
     //virtual void print_type() {printf("-D- FS3 type!\n");};
@@ -69,8 +72,8 @@ public:
     virtual bool FwSetVSD(char* vsdStr, ProgressCallBack progressFunc=(ProgressCallBack)NULL, PrintCallBack printFunc=(PrintCallBack)NULL);
     virtual bool FwSetVPD(char* vpdFileStr, PrintCallBack callBackFunc=(PrintCallBack)NULL);
     virtual bool FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFunc=(ProgressCallBack)NULL);
-
-    virtual bool FwTest(u_int32_t *data); // Add callback print
+    virtual bool FwResetNvData(ProgressCallBack progressFunc=(ProgressCallBack)NULL);
+    virtual bool FwShiftDevData(PrintCallBack progressFunc=(PrintCallBack)NULL);
 
 
 private:
@@ -145,7 +148,7 @@ private:
     bool UpdateDevDataITOC(u_int8_t *image_data, struct toc_info *image_toc_entry, struct toc_info *flash_toc_arr, int flash_toc_size);
     bool Fs3UpdateSection(void *new_info, fs3_section_t sect_type=FS3_DEV_INFO, bool is_sect_failsafe=true, CommandType cmd_type=CMD_UNKNOWN, PrintCallBack callBackFunc=(PrintCallBack)NULL );
     bool Fs3GetItocInfo(struct toc_info *tocArr, int num_of_itocs, fs3_section_t sect_type, struct toc_info *&curr_toc);
-    bool Fs3UpdateMfgUidsSection(struct toc_info *curr_toc, std::vector<u_int8_t>  section_data, guid_t base_uid, 
+    bool Fs3UpdateMfgUidsSection(struct toc_info *curr_toc, std::vector<u_int8_t>  section_data, guid_t base_uid,
                                             std::vector<u_int8_t>  &newSectionData);
     bool Fs3ChangeUidsFromBase(guid_t base_uid, struct cibfw_guids *guids);
     bool Fs3UpdateUidsSection(struct toc_info *curr_toc, std::vector<u_int8_t>  section_data, guid_t base_uid,
@@ -153,21 +156,21 @@ private:
     bool Fs3UpdateVsdSection(struct toc_info *curr_toc, std::vector<u_int8_t>  section_data, char* user_vsd,
                                      std::vector<u_int8_t>  &newSectionData);
     bool Fs3UpdateVpdSection(struct toc_info *curr_toc, char *vpd, std::vector<u_int8_t>  &newSectionData);
-    bool Fs3GetNewSectionAddr(struct toc_info *tocArr, struct toc_info *curr_toc, u_int32_t &NewSectionAddr, bool failsafe_section);
+    bool Fs3GetNewSectionAddr(struct toc_info *curr_toc, u_int32_t &NewSectionAddr, bool failsafe_section);
 
     bool Fs3UpdateItocInfo(struct toc_info *curr_toc, u_int32_t newSectionAddr, u_int32_t itocSize, std::vector<u_int8_t>  newSectionData);
     bool Fs3UpdateItocInfo(struct toc_info *curr_toc, u_int32_t newSectionAddr);
     bool Fs3UpdateItocInfo(struct toc_info *newItocInfo, u_int32_t newSectionAddr, fs3_section_t sectionType, u_int32_t* newSectData, u_int32_t NewSectSize);
     bool Fs3UpdateItocData(struct toc_info *currToc);
 
-    bool Fs3ReburnItocSection(u_int32_t newSectionAddr, u_int32_t newSectionSize, std::vector<u_int8_t>  newSectionData, char *msg, PrintCallBack callBackFunc=(PrintCallBack)NULL);
+    bool Fs3ReburnItocSection(u_int32_t newSectionAddr, u_int32_t newSectionSize, std::vector<u_int8_t>  newSectionData, const char *msg, PrintCallBack callBackFunc=(PrintCallBack)NULL);
     bool GetModifiedSectionInfo(fs3_section_t sectionType, fs3_section_t nextSectionType, u_int32_t &newSectAddr,
             fs3_section_t &sectToPut, u_int32_t &oldSectSize);
     bool UpdateItocAfterInsert(fs3_section_t sectionType, u_int32_t newSectAddr, fs3_section_t SectToPut,  bool toAdd, u_int32_t* newSectData, u_int32_t NewSectSize,
             struct toc_info *tocArr, u_int32_t &numOfItocs);
     bool UpdateImageAfterInsert(struct toc_info *tocArr, u_int32_t numOfItocs, u_int8_t* newImgData, u_int32_t newSectSize);
     bool Fs3ReplaceSectionInDevImg(fs3_section_t sectionType, fs3_section_t nextSectionType, bool toAdd, u_int8_t* newImgData,
-            u_int32_t newImageSize, u_int32_t* newSectData, u_int32_t NewSectSize);
+            u_int32_t newImageSize, u_int32_t* newSectData, u_int32_t NewSectSize, bool UpdateExsistingTocArr= false);
     bool CalcItocEntryCRC(struct toc_info *curr_toc);
     bool ShiftItocAddrInEntry(struct toc_info *newItocInfo, struct toc_info *oldItocInfo, int shiftSize);
     bool CopyItocInfo(struct toc_info *newTocInfo, struct toc_info *currToc);
@@ -176,7 +179,23 @@ private:
     bool Fs3RemoveSection(fs3_section_t sectionType, ProgressCallBack progressFunc);
     bool Fs3AddSection(fs3_section_t sectionType, fs3_section_t neighbourSection, u_int32_t* newSectData, u_int32_t newSectSize,
             ProgressCallBack progressFunc);
-    bool CheckFs3ImgSize(Fs3Operations imageOps);
+    bool CheckFs3ImgSize(Fs3Operations& imageOps);
+    bool GetMaxImageSize(u_int32_t flash_size, bool image_is_fs, u_int32_t &max_image_size);
+
+    u_int32_t getAbsAddr(toc_info* toc);
+    bool getLastFwSAddr(u_int32_t& lastAddr);
+    bool getFirstDevDataAddr(u_int32_t& firstAddr);
+    bool reburnItocSection(PrintCallBack callBackFunc);
+
+    // this class is for sorting the itoc array by ascending absolute flash_addr used in FwShiftDevData
+    class TocComp {
+    public:
+       TocComp(u_int32_t startAdd):  _startAdd(startAdd) {};
+       ~TocComp() {};
+       bool operator() (toc_info* elem1, toc_info* elem2);
+    private:
+       u_int32_t _startAdd;
+    };
 
 
 
index b90cbda752b2d794b55000024a9a647cf11f7333..3a2059db0290dd907609a951b16dc5715a1dc4e5 100644 (file)
@@ -109,7 +109,7 @@ int FwOperations::getMfaImg(char* fileName, char *psid, u_int8_t **imgbuf)
     if ((res = mfa_open_file(&mfa_d, fileName))) {
         return -1;
     }
-    
+
     res = mfa_get_image(mfa_d, psid, image_type, (char*)"", imgbuf);
 
     mfa_close(mfa_d);
@@ -129,7 +129,7 @@ int FwOperations::getMfaImg(u_int8_t* mfa_buf, int size, char *psid, u_int8_t **
     if ((res = mfa_open_buf(&mfa_d, mfa_buf, size))) {
         return -1;
     }
-    
+
     res = mfa_get_image(mfa_d, psid, image_type, (char*)"", imgbuf);
 
     mfa_close(mfa_d);
@@ -237,8 +237,7 @@ bool FwOperations::CheckAndPrintCrcRes(char* pr, bool blank_crc, u_int32_t off,
 }
 
 bool FwOperations::FwVerLessThan(u_int16_t r1[3], u_int16_t r2[3]) {
-    int i;
-    for (i = 0; i < 3 ; i++)
+    for (int i = 0; i < 3 ; i++)
         if (r1[i] < r2[i])
             return true;
         else if (r1[i] > r2[i])
@@ -264,11 +263,10 @@ const u_int32_t FwOperations::_cntx_image_start_pos[FwOperations::CNTX_START_POS
 };
 
 bool FwOperations::CntxFindMagicPattern (FBase* ioAccess, u_int32_t addr) {
-    int i;
     if (addr + 16 > ioAccess->get_size()) {
         return false;
     }
-    for (i = 0; i < 4 ; i++) {
+    for (int i = 0; i < 4 ; i++) {
         u_int32_t w;
         READ4_NOERRMSG((*ioAccess), addr + i * 4, &w);
         TOCPU1(w);
@@ -287,7 +285,6 @@ bool FwOperations::CntxFindMagicPattern (FBase* ioAccess, u_int32_t addr) {
 // OUT: start_locations: set to the start addresses of the found image markers (in accending order)
 // OUT: found_images:    Number of found images (and number of valid entries in the start_locations array).
 bool FwOperations::CntxFindAllImageStart (FBase* ioAccess, u_int32_t start_locations[CNTX_START_POS_SIZE], u_int32_t* found_images) {
-    int i;
     int needed_pos_num;
 
     needed_pos_num = CNTX_START_POS_SIZE;
@@ -302,7 +299,7 @@ bool FwOperations::CntxFindAllImageStart (FBase* ioAccess, u_int32_t start_locat
 
     ioAccess->set_address_convertor(0,0);
     *found_images = 0;
-    for (i = 0; i < needed_pos_num; i++) {
+    for (int i = 0; i < needed_pos_num; i++) {
         if (CntxFindMagicPattern(ioAccess, _cntx_image_start_pos[i])) {
             start_locations[*found_images] = _cntx_image_start_pos[i];
             (*found_images)++;
@@ -330,7 +327,6 @@ bool FwOperations::GetSectData(std::vector<u_int8_t>& file_sect, const u_int32_t
 bool FwOperations::FwAccessCreate(fw_ops_params_t& fwParams, FBase **ioAccessP)
 {
     // FBase *ioAccess = *ioAccessP;
-
     if (fwParams.hndlType == FHT_FW_FILE) {
 #ifndef NO_MFA_SUPPORT
         int sig = getFileSignature(fwParams.fileHndl);
@@ -340,7 +336,7 @@ bool FwOperations::FwAccessCreate(fw_ops_params_t& fwParams, FBase **ioAccessP)
         }
         if (sig == IMG_SIG_TYPE_BIN) {
             *ioAccessP = new FImage;
-            if (!(*ioAccessP)->open(fwParams.fileHndl, false)) {
+            if (!(*ioAccessP)->open(fwParams.fileHndl, false, !fwParams.shortErrors)) {
                 WriteToErrBuff(fwParams.errBuff,(*ioAccessP)->err(), fwParams.errBuffSize);
                 delete *ioAccessP;
                 return false;
@@ -353,7 +349,7 @@ bool FwOperations::FwAccessCreate(fw_ops_params_t& fwParams, FBase **ioAccessP)
                 return false;
             }
             *ioAccessP = new FImage;
-            if (!((FImage*)(*ioAccessP))->open((u_int32_t*)imgbuf, (u_int32_t)sz)) {
+            if (!((FImage*)(*ioAccessP))->open((u_int32_t*)imgbuf, (u_int32_t)sz, !fwParams.shortErrors)) {
                 mfa_release_image(imgbuf);
                 WriteToErrBuff(fwParams.errBuff,(*ioAccessP)->err(), fwParams.errBuffSize);
                 delete *ioAccessP;
@@ -366,7 +362,7 @@ bool FwOperations::FwAccessCreate(fw_ops_params_t& fwParams, FBase **ioAccessP)
         }
 #else
         *ioAccessP = new FImage;
-        if (!(*ioAccessP)->open(fwParams.fileHndl, false)) {
+        if (!(*ioAccessP)->open(fwParams.fileHndl, false, !fwParams.shortErrors)) {
             WriteToErrBuff(fwParams.errBuff,(*ioAccessP)->err(), fwParams.errBuffSize);
             delete *ioAccessP;
             return false;
@@ -378,7 +374,7 @@ bool FwOperations::FwAccessCreate(fw_ops_params_t& fwParams, FBase **ioAccessP)
         int sig = getBufferSignature((u_int8_t*)fwParams.buffHndl, numInfo);
         if (sig == IMG_SIG_TYPE_BIN) {
             *ioAccessP = new FImage;
-            if (!((FImage*)*ioAccessP)->open(fwParams.buffHndl, (u_int32_t)numInfo)) {
+            if (!((FImage*)*ioAccessP)->open(fwParams.buffHndl, (u_int32_t)numInfo, !fwParams.shortErrors)) {
                 WriteToErrBuff(fwParams.errBuff,(*ioAccessP)->err(), fwParams.errBuffSize);
                 delete *ioAccessP;
                 return false;
@@ -391,7 +387,7 @@ bool FwOperations::FwAccessCreate(fw_ops_params_t& fwParams, FBase **ioAccessP)
                 return false;
             }
             *ioAccessP = new FImage;
-            if (!((FImage*)*ioAccessP)->open((u_int32_t*)imgbuf, (u_int32_t)sz)) {
+            if (!((FImage*)*ioAccessP)->open((u_int32_t*)imgbuf, (u_int32_t)sz, !fwParams.shortErrors)) {
                 mfa_release_image(imgbuf);
                 WriteToErrBuff(fwParams.errBuff,(*ioAccessP)->err(), fwParams.errBuffSize);
                 delete *ioAccessP;
@@ -404,7 +400,7 @@ bool FwOperations::FwAccessCreate(fw_ops_params_t& fwParams, FBase **ioAccessP)
         }
 #else
         *ioAccessP = new FImage;
-        if (!((FImage*)*ioAccessP)->open(fwParams.buffHndl, numInfo)) {
+        if (!((FImage*)*ioAccessP)->open(fwParams.buffHndl, numInfo, !fwParams.shortErrors)) {
             WriteToErrBuff(fwParams.errBuff,(*ioAccessP)->err(), fwParams.errBuffSize);
             delete *ioAccessP;
             return false;
@@ -412,22 +408,22 @@ bool FwOperations::FwAccessCreate(fw_ops_params_t& fwParams, FBase **ioAccessP)
 #endif
     } else if (fwParams.hndlType == FHT_UEFI_DEV) {
         *ioAccessP = new Flash;
-        if (!((Flash*)*ioAccessP)->open(fwParams.uefiHndl, fwParams.uefiExtra)) {
+        if (!((Flash*)*ioAccessP)->open(fwParams.uefiHndl, fwParams.uefiExtra, false, !fwParams.shortErrors)) {
             WriteToErrBuff(fwParams.errBuff,(*ioAccessP)->err(), fwParams.errBuffSize);
             delete *ioAccessP;
             return false;
         }
     } else if (fwParams.hndlType == FHT_MST_DEV) {
         *ioAccessP = new Flash;
-       //set no flash verify if needed
-       ((Flash*)*ioAccessP)->set_no_flash_verify(fwParams.noFlashVerify);
         if ( !((Flash*)*ioAccessP)->open(fwParams.mstHndl, fwParams.forceLock, fwParams.readOnly, fwParams.numOfBanks,\
-                                          fwParams.flashParams, fwParams.ignoreCacheRep)) {
+                                          fwParams.flashParams, fwParams.ignoreCacheRep, !fwParams.shortErrors)) {
             // TODO: release memory here ?
             WriteToErrBuff(fwParams.errBuff,(*ioAccessP)->err(), fwParams.errBuffSize);
             delete *ioAccessP;
             return false;
         }
+        //set no flash verify if needed (default =false)
+        ((Flash*)*ioAccessP)->set_no_flash_verify(fwParams.noFlashVerify);
      } else {
          WriteToErrBuff(fwParams.errBuff,"Unknown Handle Type.", fwParams.errBuffSize);
          return false;
@@ -444,7 +440,9 @@ u_int8_t FwOperations::CheckFwFormat(FBase& f, bool getFwFormatFromImg) {
                 ( ((Flash*)&f)->get_dev_id() == 6100) ||
                 ( ((Flash*)&f)->get_dev_id() == CX3_PRO_HW_ID)) {
             return FS_FS2_GEN;
-        } else if ( ((Flash*)&f)->get_dev_id() == CONNECT_IB_HW_ID) {
+        } else if ( (((Flash*)&f)->get_dev_id() == CONNECT_IB_HW_ID) ||
+                    (((Flash*)&f)->get_dev_id() == SWITCH_IB_HW_ID) ||
+                   (((Flash*)&f)->get_dev_id() == CX4_HW_ID)) {
             return FS_FS3_GEN;
         }
     } else {
@@ -477,7 +475,7 @@ FwOperations* FwOperations::FwOperationsCreate(void* fwHndl, void *info, char* p
     fwParams.hndlType = hndlType;
     fwParams.errBuff = errBuff;
     fwParams.errBuffSize = buffSize;
-    
+
     if (hndlType == FHT_FW_FILE) {
         fwParams.fileHndl = (char*)fwHndl;
     }else if (hndlType == FHT_FW_BUFF) {
@@ -506,7 +504,6 @@ FwOperations* FwOperations::FwOperationsCreate(fw_ops_params_t& fwParams)
     bool getFwFormatFromImg = false;
 
     if (!FwAccessCreate(fwParams, &ioAccess)) {
-
         return (FwOperations*)NULL;
     }
     if (fwParams.hndlType == FHT_UEFI_DEV) {
@@ -528,6 +525,7 @@ FwOperations* FwOperations::FwOperationsCreate(fw_ops_params_t& fwParams)
             WriteToErrBuff(fwParams.errBuff,"invalid Firmware Format (found FS Gen 1)", fwParams.errBuffSize);
             return (FwOperations*)NULL;
     }
+    fwops->_advErrors = !fwParams.shortErrors;
     fwops->FwInit();
     if (fwParams.hndlType == FHT_FW_FILE) {
         fwops->_fname = strcpy(new char[strlen(fwParams.fileHndl)+ 1], fwParams.fileHndl);
@@ -551,7 +549,6 @@ bool FwOperations::writeImage(ProgressCallBack progressFunc, u_int32_t addr, voi
     u_int8_t   *p = (u_int8_t *)data;
     u_int32_t  curr_addr = addr;
     u_int32_t  towrite = cnt;
-    u_int32_t  perc = 0xffffffff;
     bool rc;
 //    if (!_ioAccess->is_flash()) {
  //       return errmsg("Internal error: writeImage is supported only on flash.");
@@ -586,14 +583,13 @@ bool FwOperations::writeImage(ProgressCallBack progressFunc, u_int32_t addr, voi
                     if (progressFunc((int)new_perc)) {
                         return errmsg("Aborting... recieved interrupt signal");
                     }
-                perc = new_perc;
             }
         }
 
     return true;
 } //  Flash::WriteImage
 
-bool FwOperations::ModifyImageFile(char *fimage, u_int32_t addr, void *data, int cnt)
+bool FwOperations::ModifyImageFile(const char *fimage, u_int32_t addr, void *data, int cnt)
 {
     int file_size;
     u_int8_t * file_data;
@@ -611,7 +607,7 @@ bool FwOperations::ModifyImageFile(char *fimage, u_int32_t addr, void *data, int
     return true;
 }
 
-bool FwOperations::WriteImageToFile(char *file_name, u_int8_t *data, u_int32_t length)
+bool FwOperations::WriteImageToFile(const char *file_name, u_int8_t *data, u_int32_t length)
 {
     FILE* fh;
     if ((fh = fopen(file_name, "wb")) == NULL) {
@@ -640,14 +636,13 @@ bool FwOperations::CheckMac(u_int64_t mac) {
 }
 
 void FwOperations::recalcSectionCrc(u_int8_t *buf, u_int32_t data_size) {
-    Crc16              crc;
-    u_int32_t          i;
 
-    for (i = 0; i < data_size; i += 4) {
+    Crc16              crc;
+    for (u_int32_t i = 0; i < data_size; i += 4) {
         crc << __be32_to_cpu(*(u_int32_t*)(buf + i));
     }
     crc.finish();
-    *(u_int32_t*)(buf + data_size) = __cpu_to_be32(crc.get());
+    *((u_int32_t*)(buf + data_size)) = __cpu_to_be32(crc.get());
 }
 
 chip_type_t FwOperations::getChipType() {
@@ -695,6 +690,8 @@ const FwOperations::HwDevData FwOperations::hwDevData[] = {
     { "InfiniScale IV",   IS4_HW_ID, CT_IS4, 0, {48436, 48437, 48438, 0}},
     { "BridgeX",          BRIDGEX_HW_ID, CT_BRIDGEX, 0, {64102, 64112, 64122, 0}},
     { "SwitchX",          SWITCHX_HW_ID, CT_SWITCHX, 0, {51000, 0}},
+    { "Switch_IB",        SWITCH_IB_HW_ID, CT_SWITCH_IB,0, {52000, 0}},
+    { "ConnectX4",               CX4_HW_ID,     CT_CONNECTX,   0, {4115, 0}},
     { (char*)NULL ,              0, CT_UNKNOWN, 0, {0}},// zero devid terminator
 };
 
@@ -704,6 +701,7 @@ const FwOperations::HwDev2Str FwOperations::hwDev2Str[] = {
         {"ConnectX-2",        CX_HW_ID,         0xB0},
         {"ConnectX-3 A0",     CX3_HW_ID,        0x00},
         {"ConnectX-3 A1",     CX3_HW_ID,        0x01},
+        {"ConnectX-4",        CX4_HW_ID,       0x00},
         {"SwitchX A0",        SWITCHX_HW_ID,    0x00},
         {"SwitchX A1",        SWITCHX_HW_ID,    0x01},
         {"BridgeX",           BRIDGEX_HW_ID,    0xA0},
@@ -713,16 +711,16 @@ const FwOperations::HwDev2Str FwOperations::hwDev2Str[] = {
         {"InfiniHost A1",     TAVOR_HW_ID,      0xA1},
         {"InfiniHost III Lx", SINAI_HW_ID,      0xA0},
         {"InfiniHost III Ex", ARBEL_HW_ID,      0xA0},
-        { (char*)NULL ,              0,                0x00}, // zero device ID terminator
+        {"SwitchIB A0",       SWITCH_IB_HW_ID,  0x00},
+        { (char*)NULL ,       (u_int32_t)0, (u_int8_t)0x00}, // zero device ID terminator
 };
 
 #define ARR_SIZE(arr) sizeof(arr)/sizeof(arr[0])
 #define MAX_HW_NAME_LEN 100
 bool FwOperations::HWIdRevToName(u_int32_t hw_id, u_int8_t rev_id, char *hw_name)
 {
-    int i;
 
-    for (i = 0;  hwDev2Str[i].hwDevId != 0; i++) {
+    for (int i = 0;  hwDev2Str[i].hwDevId != 0; i++) {
         const HwDev2Str *hwDev2StrMem = &(hwDev2Str[i]);
 
         if (hwDev2StrMem->hwDevId == hw_id && hwDev2StrMem->revId == rev_id) {
@@ -747,12 +745,11 @@ bool FwOperations::HWIdRevToName(u_int32_t hw_id, u_int8_t rev_id, char *hw_name
 //
 bool FwOperations::CheckMatchingHwDevId(u_int32_t hwDevId, u_int32_t rev_id, u_int32_t* supportedHwId, u_int32_t supportedHwIdNum) {
 
-    u_int32_t i;
     char supp_hw_id_list[MAX_NUM_SUPP_HW_LIST_STR] = {'\0'};
     char supp_hw_id_list_tmp[MAX_NUM_SUPP_HW_LIST_STR];
     char curr_hw_id_name[MAX_HW_NAME_LEN];
 
-    for (i = 0; i < supportedHwIdNum; i++) {
+    for (u_int32_t i = 0; i < supportedHwIdNum; i++) {
         u_int32_t currSupportedHwId = supportedHwId[i];
         u_int32_t supp_hw_id  = currSupportedHwId & 0xffff;
         u_int32_t supp_rev_id = (currSupportedHwId >> 16) & 0xff;
@@ -797,7 +794,6 @@ bool FwOperations::CheckMatchingHwDevId(u_int32_t hwDevId, u_int32_t rev_id, u_i
 }
 bool FwOperations::CheckMatchingDevId(u_int32_t hwDevId, u_int32_t imageDevId) {
 
-    int i, j;
     const HwDevData* devData = (const HwDevData*)NULL;
     const char* hwDevName = (const char*)NULL;
     // HACK: InfiniHost III LX may have 2 HW device ids. - Map the second devid to the first.
@@ -806,13 +802,13 @@ bool FwOperations::CheckMatchingDevId(u_int32_t hwDevId, u_int32_t imageDevId) {
     }
 
     // First, find the HW device that the SW id matches
-    for (i = 0; hwDevData[i].hwDevId != 0 ; i++) {
+    for (int i = 0; hwDevData[i].hwDevId != 0 ; i++) {
         if (hwDevData[i].hwDevId == hwDevId) {
             hwDevName = hwDevData[i].name; // TODO: Check bug if device not found
         }
 
         if (devData == NULL) {
-            for (j = 0; hwDevData[i].swDevIds[j]; j++) {
+            for (int j = 0; hwDevData[i].swDevIds[j]; j++) {
                 if (hwDevData[i].swDevIds[j] == imageDevId) {
                     devData = &hwDevData[i];
                     break;
@@ -875,7 +871,7 @@ bool FwOperations::FwSwReset() {
         return errmsg("operation supported only for switch devices InfiniScaleIV and SwitchX over an IB interface");
     }
     if (!((Flash*)_ioAccess)->sw_reset()) {
-        return errmsg(_ioAccess->err());
+        return errmsg("%s",  _ioAccess->err());
     }
     return true;
 }
@@ -897,9 +893,9 @@ void FwOperations::WriteToErrBuff(char* errBuff, const char* errStr, int size)
 bool FwOperations::UpdateImgCache(u_int8_t *buff, u_int32_t addr, u_int32_t size)
 {
     //avoid compiler warrnings
-    buff = NULL;
-    addr = 0;
-    size = 0;
+    (void)buff;
+    (void)addr;
+    (void)size;
     //in FS2 we dont have ImgCache, just in FS3 so we define a defult behaviour.
     return true;
 }
@@ -928,6 +924,9 @@ FwOperations::RomInfo::RomInfo(const std::vector<u_int8_t>& romSector, bool resE
     expRomWarning = false;
     expRomErrMsgValid = false;
     noRomChecksum = false;
+    memset(expRomErrMsg, 0, sizeof(expRomErrMsg));
+    memset(expRomWarningMsg, 0, sizeof(expRomWarningMsg));
+    memset(&romsInfo, 0, (sizeof(rom_info_t)*MAX_ROMS_NUM));
 }
 
 
@@ -965,7 +964,7 @@ bool FwOperations::RomInfo::initRomsInfo(roms_info_t *info)
 bool FwOperations::RomInfo::ParseInfo()
 {
     if (!GetExpRomVersion()) {
-        snprintf(expRomErrMsg, MAX_ROM_ERR_MSG_LEN, err());
+        snprintf(expRomErrMsg, MAX_ROM_ERR_MSG_LEN, "%s",  err());
         expRomErrMsgValid = true;
         //printf("-D-expRomErrMsg: %s \n", expRomErrMsg);
     }
@@ -984,7 +983,6 @@ bool FwOperations::RomInfo::GetExpRomVersion()
 {
     char magicString[MAGIC_LEN] = {"mlxsignX"};
     u_int32_t magicLen = strlen(magicString);
-    u_int32_t i;
     bool magicFound = false;
     u_int32_t verOffset;
     u_int32_t romChecksumRange;
@@ -1008,13 +1006,13 @@ bool FwOperations::RomInfo::GetExpRomVersion()
                 (u_int32_t) romSect.size());
     }
 
-    // restore endianess is done in the constructor if needed. 
+    // restore endianess is done in the constructor if needed.
     /*  // FOR WE DON'T CHECKSUM UNTIL WE DECIDED REGARDING THE NEW FORMAT.
      */
     // We will look for the magic string in whole ROM instead of the first part of it.
     romChecksumRange = romSect.size();
 
-    for (i = 0; i < romChecksumRange; i++) {
+    for (u_int32_t i = 0; i < romChecksumRange; i++) {
         for (u_int32_t j = 0; j < magicLen; j++) {
             if (romSect[i + j] != magicString[j]) {
                 break;
@@ -1022,7 +1020,7 @@ bool FwOperations::RomInfo::GetExpRomVersion()
                 magicFound = true;
             }
         }
-        
+
 
         if (magicFound) {
             // Get the ROM info after the mlxsign
@@ -1075,7 +1073,7 @@ bool FwOperations::RomInfo::GetExpRomVersion()
 
     }
 
-    if (noRomChecksum == 0) { // No need for checksum on some ROMs like uEFI
+    if (!noRomChecksum) { // No need for checksum on some ROMs like uEFI
          u_int8_t romChecksum = 0;
          romChecksumRange = romSect[2] * 512;
          if (romChecksumRange > romSect.size()) {
@@ -1087,7 +1085,7 @@ bool FwOperations::RomInfo::GetExpRomVersion()
                      "ROM size field is 0. Unknown ROM format or corrupted ROM.");
          }
 
-         for (i = 0; i < romChecksumRange; i++) {
+         for (u_int32_t i = 0; i < romChecksumRange; i++) {
              romChecksum += romSect[i];
          }
 
@@ -1108,6 +1106,8 @@ bool FwOperations::RomInfo::GetExpRomVerForOneRom(u_int32_t verOffset)
 {
 
     u_int32_t tmp;
+    u_int32_t offs4;
+    u_int32_t offs8;
     rom_info_t *romInfo;
 
     if (numOfExpRom == MAX_ROMS_NUM) {
@@ -1123,16 +1123,23 @@ bool FwOperations::RomInfo::GetExpRomVerForOneRom(u_int32_t verOffset)
     // Following mlxsign:
     // 31:24    0    Compatible with UEFI
     // 23:16    ProductID   Product ID:
-    //                          1 - CLP implementation for Sinai (MT25408)
-    //                          2 - CLP implementation for Hermon DDR (MT25418)
+    //                          0x1 - CLP implementation for Sinai (MT25408)
+    //                          0x2 - CLP implementation for Hermon DDR (MT25418)
+    //                                                 0x3 - CLP implementation for Hermon QDR (MT26428)
+    //                                                 0x4 - CLP implementation for Hermon ETHERNET (MT25448)
     //                          0X10 - PXE
-    // 15:0 Major version   If ProductID < 0x10 this field is subversion
+    //                                                 0x11 - UEFI
+    //                                                 0x12 - CLP with device ID and Version
+    //                                                 0x21 - FCODE - IBM's ROM version format, the same as PXE
+    //                                            (0xf) - extended format(see code or rom version format document)
+    //
+    // 15:0 Major version   If ProductID < 0x10 or == 0x12 this field is subversion
     //                          number, otherwise It's product major version.
     //
     // 31:16    Minor version   Product minor version*. Not valid if
-    //                          roductID < 0x10.
+    //                          roductID < 0x10 or == 0x12.
     // 15:0 SubMinor version    Product sub minor version*. Not valid if
-    //                                  ProductID < 0x10.
+    //                                  ProductID < 0x10 or == 0x12.
     //
     // 31:16    Device ID   The PCI Device ID (ex. 0x634A for Hermon
     //                          DDR). Not valid if ProductID < 0x10.
@@ -1145,7 +1152,7 @@ bool FwOperations::RomInfo::GetExpRomVerForOneRom(u_int32_t verOffset)
     romInfo->exp_rom_product_id = tmp >> 16;
     romInfo->exp_rom_ver[0] = tmp & 0xffff;
 
-    if (romInfo->exp_rom_product_id < 0xF) {
+    if (romInfo->exp_rom_product_id < 0xF || romInfo->exp_rom_product_id == 0x12) {
         romInfo->exp_rom_num_ver_fields = 1;//For CLPs
     } else if (romInfo->exp_rom_product_id == 0xF) {
         romInfo->exp_rom_num_ver_fields = 0;
@@ -1158,14 +1165,17 @@ bool FwOperations::RomInfo::GetExpRomVerForOneRom(u_int32_t verOffset)
     }
 
     if (romInfo->exp_rom_product_id >= 0x10) {
-        tmp = __le32_to_cpu(*((u_int32_t*) &romSect[verOffset + 4]));
-        romInfo->exp_rom_ver[1] = tmp >> 16;
-        romInfo->exp_rom_ver[2] = tmp & 0xffff;
-
-        tmp = __le32_to_cpu(*((u_int32_t*) &romSect[verOffset + 8]));
-        romInfo->exp_rom_dev_id = tmp >> 16;
-        romInfo->exp_rom_port = (tmp >> 12) & 0xf;
-        romInfo->exp_rom_proto = tmp & 0xff;
+        offs8 = __le32_to_cpu(*((u_int32_t*) &romSect[verOffset + 8]));
+        romInfo->exp_rom_dev_id = offs8 >> 16;
+       //0x12 is CLP we have only 1 version field and no porty
+       if (romInfo->exp_rom_product_id != 0x12){
+               offs4 = __le32_to_cpu(*((u_int32_t*) &romSect[verOffset + 4]));
+               romInfo->exp_rom_ver[1] = offs4 >> 16;
+               romInfo->exp_rom_ver[2] = offs4 & 0xffff;
+
+               romInfo->exp_rom_port = (offs8 >> 12) & 0xf;
+               romInfo->exp_rom_proto = offs8 & 0xff;
+        }
     } else if (romInfo->exp_rom_product_id == 0xf) {
         // get string length
         u_int32_ba tmp_ba = *((u_int32_t*) &romSect[verOffset + 0xc]);
@@ -1213,7 +1223,7 @@ bool FwOperations::RomInfo::GetExpRomVerForOneRom(u_int32_t verOffset)
     return true;
 }
 
-bool FwOperations::ReadImageFile(char *fimage, u_int8_t *&file_data, int &file_size, int min_size)
+bool FwOperations::ReadImageFile(const char *fimage, u_int8_t *&file_data, int &file_size, int min_size)
 {
     FILE* fh;
 
@@ -1259,7 +1269,7 @@ void FwOperations::SetDevFlags(chip_type_t chipType, u_int32_t devType, fw_img_t
         ethDev = true;
     } else {
         ibDev  = (fwType == FIT_FS3) || !CntxEthOnly(devType);
-        ethDev = (fwType == FIT_FS2)  && chipType == CT_CONNECTX;
+        ethDev = chipType == CT_CONNECTX;
     }
 
     if ((!ibDev && !ethDev) || chipType == CT_UNKNOWN) {
@@ -1344,12 +1354,13 @@ bool FwOperations::FwBurnData(u_int32_t *data, u_int32_t dataSize, ProgressCallB
 
     newImgOps = FwOperationsCreate(imgOpsParams);
     if (newImgOps == NULL) {
-        return errmsg("FwOperationsCreate: %s", errBuff); // TODO: fix error message
+        return errmsg("Internal error: Failed to create modified image: %s", errBuff);
     }
     if (!newImgOps->FwVerify(NULL)) {
+       errmsg("Internal error: Modified image failed to verify: %s", newImgOps->err());
         newImgOps->FwCleanUp();
         delete newImgOps;
-        return errmsg("Internal error: Modifed image failed in verify");
+        return false;
     }
 
     ExtBurnParams burnParams = ExtBurnParams();
@@ -1384,3 +1395,29 @@ bool FwOperations::getRomsInfo(FBase* io, roms_info_t& romsInfo)
     return true;
 }
 
+const char* FwOperations::expRomType2Str(u_int16_t type)
+{
+       switch (type) {
+               case 0x1:
+                   return "CLP1 ";
+               case 0x2:
+                       return "CLP2 ";
+               case 0x3:
+                       return "CLP3 ";
+               case 0x4:
+                       return "CLP4 ";
+               case 0xf:
+                       return "CLP "; // hack as 0xf isnt always CLP (its type is defined in the free string inside the ROM)
+               case 0x10:
+                       return "PXE  ";
+               case 0x11:
+                       return "UEFI ";
+               case 0x12:
+                       return "CLP ";
+               case 0x21:
+                       return "FCODE ";
+               default:
+                   return (const char*)NULL;
+               }
+       return (const char*)NULL;
+}
index e69069ba2f1ba89ae86df6a5ee2350134a5586cb..df767e9dbdb62856e595269a9baeb43bbd0c32ae 100644 (file)
@@ -59,7 +59,11 @@ public:
 
     FwOperations(FBase *ioAccess) :
         _ioAccess(ioAccess), _isCached(false), _wasVerified(false),
-        _quickQuery(false), _printFunc((PrintCallBack)NULL), _fname(NULL) {};
+        _quickQuery(false), _printFunc((PrintCallBack)NULL), _fname(NULL), _advErrors(true)
+    {
+        memset(_sectionsToRead, 0, sizeof(_sectionsToRead));
+        memset(&_fwImgInfo, 0, sizeof(_fwImgInfo));
+    };
 
 
     virtual ~FwOperations()  {};
@@ -71,11 +75,11 @@ public:
     static void SetDevFlags(chip_type_t chipType, u_int32_t devType, fw_img_type_t fwType, bool &ibDev, bool &ethDev);
     static bool checkMatchingExpRomDevId(const fw_info_t& info);
     static bool checkMatchingExpRomDevId(u_int16_t dev_type, roms_info_t roms_info);
+    static const char* expRomType2Str(u_int16_t type);
 
 
     virtual bool FwQuery(fw_info_t *fwInfo, bool readRom = true, bool isStripedImage = false) = 0;
     virtual bool FwVerify(VerifyCallBack verifyCallBackFunc, bool isStripedImage = false, bool showItoc = false) = 0; // Add callback print
-    virtual bool FwTest(u_int32_t *data) {data = (u_int32_t*)NULL; return false;}; // Add callback print
     //on call of FwReadData with Null image we get image_size
     virtual bool FwReadData(void* image, u_int32_t* image_size) = 0;
 
@@ -96,6 +100,8 @@ public:
     virtual bool FwSetVPD(char* vpdFileStr, PrintCallBack callBackFunc=(PrintCallBack)NULL) = 0;
     virtual bool FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFunc=(ProgressCallBack)NULL) = 0;
     virtual bool FwGetSection (u_int32_t sectType, std::vector<u_int8_t>& sectInfo)= 0;
+    virtual bool FwResetNvData(ProgressCallBack progressFunc=(ProgressCallBack)NULL) = 0;
+    virtual bool FwShiftDevData(PrintCallBack progressFunc=(PrintCallBack)NULL) = 0;
 
     void FwCleanUp();
     virtual bool FwInit() = 0;
@@ -105,7 +111,6 @@ public:
     bool FwSwReset();
 
 
-
     //virtual bool FwBurnBlock(FwOperations &FwImageAccess); // Add call back
     static FwOperations* FwOperationsCreate(void* fwHndl, void *info, char* psid, fw_hndl_type_t hndlType, char* errBuff=(char*)NULL, int buffSize=0);
     static FwOperations* FwOperationsCreate(fw_ops_params_t& fwParams);
@@ -180,7 +185,7 @@ public:
         //data
         char* userVsd;
         std::vector<guid_t> userUids; //contains eiter guids or uids
-        
+
 
         ExtBurnParams():userGuidsSpecified(false), userMacsSpecified(false), userUidsSpecified(false),
                         vsdSpecified(false),blankGuids(false), burnFailsafe(true), allowPsidChange(false),
@@ -211,6 +216,7 @@ public:
             flash_params_t* flashParams; // can be NULL
             int ignoreCacheRep;
             bool noFlashVerify;
+            bool shortErrors; // show short/long error msgs (default shuold be false)
         };
 
         struct sgParams {
@@ -311,9 +317,9 @@ protected:
     chip_type_t getChipType();
     chip_type_t getChipTypeFromHwDevid(u_int32_t hwDevId);
 
-    bool ReadImageFile(char *fimage, u_int8_t *&file_data, int &file_size, int min_size=-1); // min_size=-1 like int flint_ops needed for fs3updateSection
-    bool ModifyImageFile(char *fimage, u_int32_t addr, void *data, int cnt);
-    bool WriteImageToFile(char *file_name, u_int8_t *data, u_int32_t length);
+    bool ReadImageFile(const char *fimage, u_int8_t *&file_data, int &file_size, int min_size=-1); // min_size=-1 like int flint_ops needed for fs3updateSection
+    bool ModifyImageFile(const char *fimage, u_int32_t addr, void *data, int cnt);
+    bool WriteImageToFile(const char *file_name, u_int8_t *data, u_int32_t length);
     bool FwBurnData(u_int32_t *data, u_int32_t dataSize, ProgressCallBack progressFunc);
 
 
@@ -331,7 +337,9 @@ protected:
     bool      _quickQuery;
 
     PrintCallBack _printFunc;
-    char* _fname;
+    const char* _fname;
+    // show advanced error msgs
+    bool _advErrors;
 
 
 
@@ -359,7 +367,7 @@ private:
     // Members
     static const HwDevData hwDevData[];
     static const HwDev2Str hwDev2Str[];
-    fw_hndl_type_t _hndlType;
+    //fw_hndl_type_t _hndlType;  //not used atm
 
 };
 
diff --git a/mlxfwops/lib/mlxconfig.cpp b/mlxfwops/lib/mlxconfig.cpp
deleted file mode 100644 (file)
index 43ae4a3..0000000
+++ /dev/null
@@ -1,1826 +0,0 @@
-/*
- *
- * flint.cpp - FLash INTerface
- *
- * Copyright (c) 2005 Mellanox Technologies Ltd.  All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- *  Version: $Id$
- *
- */
-#include <getopt.h>
-#include <sstream>
-#include <assert.h>
-#include <errno.h>
-#include <json/reader.h>
-#include <common/print_utils.h>
-#include <common/tools_version.h>
-#include <adb_parser/adb_parser.h>
-#include "mlxconfig.h"
-#include "flint_ops.h"
-/**************************** Globals *************************/
-static const char static_profiles [] = {
-#include "profiles.json.dat"
-};
-
-#undef PRINT_DEBUG
-#define PRINT_DEBUG(fmt, ...)
-
-/************************************
- * Function: int2string
- ************************************/
-string int2string(long int number)
-{
-    stringstream ss;//create a stringstream
-    ss << number;//add number to the stream
-    return ss.str();//return a string with the contents of the stream
-}
-
-/************************************
- * Function: print
- ************************************/
-void Pair::print()
-{
-    cout << "\t\t(" << key << ", " << value + ")";
-}
-
-/************************************
- * Function: print
- ************************************/
-void Tlv::print()
-{
-    cout << "\n\tTlv: " << name << ", fields: \n";
-    for (size_t i = 0; i < fields.size(); i++)
-    {
-        fields[i].print();
-        cout << ",\n";
-    }
-}
-
-/************************************
- * Function: print
- ************************************/
-void Profile::print()
-{
-    cout << " Version: " << version << ", id: " << id;
-    for (size_t i = 0; i < tlvs.size(); i++)
-    {
-        tlvs[i].print();
-        cout << ",\n";
-    }
-}
-
-/************************************
- * Function: parseCmdLine
- ************************************/
-bool MlxConfig::parseCmdLine(int argc, const char** argv)
-{
-    this->_cmd = CMD_UNKNOWN;
-
-#define SET_CMD(cmd)\
-    do {\
-        if (this->_cmd != CMD_UNKNOWN) {\
-            printf("config doesn't support multiple commands\n");\
-            return false;\
-        }\
-        else {\
-            this->_cmd = cmd;\
-        }\
-    }\
-    while(0)
-
-    for (int i = 0; i < argc; i++)
-    {
-        if (!strcmp(argv[i], "query") || !strcmp(argv[i], "q"))
-        {
-            SET_CMD(CMD_QUERY);
-        }
-        else if (!strcmp(argv[i], "set") || !strcmp(argv[i],"s"))
-        {
-            SET_CMD(CMD_SET);
-            if (i >= argc - 1)
-            {
-                printf("Missing <profile name> for \"set\" option\n");
-                return false;
-            }
-            this->_cmdProfile = argv[i+1];
-            i++;
-        }
-        else if (!strcmp(argv[i], "restore") || !strcmp(argv[i], "r"))
-        {
-            SET_CMD(CMD_RESTORE);
-        }
-        else if (!strcmp(argv[i], "lp") || !strcmp(argv[i], "l"))
-        {
-            SET_CMD(CMD_LIST_PROFILES);
-        }
-        else if (!strcmp(argv[i], "h") || !strcmp(argv[i], "help"))
-        {
-            SET_CMD(CMD_HELP);
-            return true;
-        }
-        else if (!strcmp(argv[i], "-pf"))
-        {
-            if (i >= argc - 1)
-            {
-                printf("Missing profiles file for \"pf\" option\n");
-                return false;
-            }
-            this->_profilesFile = argv[i+1];
-            i++;
-        }
-        else if (!strcmp(argv[i], "-verbose"))
-        {
-            this->_verbose = true;
-        }
-        else if (!strcmp(argv[i], "reconfig")) // For debug
-        {
-            SET_CMD(CMD_RECONFIG);
-        }
-        else if (!strcmp(argv[i], "config_info"))
-        {
-            SET_CMD(CMD_CONFIG_INFO);
-        }
-        else if (!strcmp(argv[i], "verify") || !strcmp(argv[i], "v"))
-        {
-            SET_CMD(CMT_VERIFY);
-        }
-        else
-        {
-            printf("Unknown config sub-command: %s\n", argv[i]);
-            return false;
-        }
-    }
-
-    return true;
-}
-
-/************************************
- * Function: getHelpMessage
- ************************************/
-const char* MlxConfig::getHelpMessage()
-{
-    return
-           "  config sub-commands:\n"
-           "    s[et] <profile name>      - Burn the given profile and set as the active configuration profile\n"
-           "    q[uery]                   - Query the current profile\n"
-           "    r[estore]                 - Restore to defaults (Erase all configurations)\n"
-           "    l[p]                      - List available and supported profiles\n"
-           "    v[erify]                  - Verify configuration section\n\n"
-           "  config options:\n"
-           "    -verbose                  - Print more details";
-}
-
-/************************************
- * Function: getRunExamples
- ************************************/
-const char* MlxConfig::getRunExamples()
-{
-    return
-    "* Query/Set/Restore mellanox device's nonvolatile configuration section\n"
-    "    Command:\n"
-    "        config\n"
-    "    Parameters:\n"
-    "        s[et] <profile> - to set the reaquired profile\n"
-    "        q[uery]         - to query the current profile\n"
-    "        r[estore]       - to restore to defaults\n"
-    "        l[p]            - to list supported profiles\n"
-    "        v[erify]        - Verify configuration section\n\n"
-    "    config options:\n"
-    "        -verbose        - Print more details\n"
-    "    Example:\n"
-    "        flint -d /dev/mst/mt4099_pci_cr0 config set 8PF_ETH\n"
-    "        flint -d /dev/mst/mt4099_pci_cr0 config query\n"
-    "        flint -d /dev/mst/mt4099_pci_cr0 config restore\n"
-    "        flint -d /dev/mst/mt4099_pci_cr0 config lp\n";
-}
-
-/************************************
- * Function: MlxConfig
- ************************************/
-MlxConfig::MlxConfig():
-        _lastMsg("None"), _cmd(CMD_UNKNOWN), _verbose(false), _adbDB(0), _adbRoot(0)
-{
-}
-
-/************************************
- * Function: ~MlxConfig
- ************************************/
-MlxConfig::~MlxConfig()
-{
-
-}
-
-/************************************
- * Function: loadImageData
- ************************************/
-bool MlxConfig::loadImageData(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo)
-{
-    assert(flash);
-    assert(op);
-
-    if (!flashImageInfo.imageOk)
-    {
-        _lastMsg = "FW image is empty or corrupted";
-        return false;
-    }
-
-    // get cfg section info
-    _cfgSize =  flashImageInfo.configSize;
-    _cfgAddress[0] = flashImageInfo.configAddr1;
-    _cfgAddress[1] = flashImageInfo.configAddr2;
-
-    _isFailSafe = flashImageInfo.isFailsafe;
-    if (!_isFailSafe)
-    {
-        _cfgAddress[0] = _cfgAddress[1];
-    }
-
-    // check current burnt configuration version
-    int activeCfgIdx;
-    if (!getActiveCfgIdx(flash, activeCfgIdx))
-        return false;
-
-    if (activeCfgIdx != -1)
-    {
-        u_int32_t dword;
-        if (!flash->read_phy(_cfgAddress[activeCfgIdx] + 4, &dword, 4))
-        {
-            _lastMsg = flash->err();
-            return false;
-        }
-
-        // Parse the  cfg header
-        u_int32_t version = htonl(dword) & 0xff;
-
-        if (version != MLX_CFG_VERSION)
-        {
-            _lastMsg = "Unsupported configuration section version \"" + int2string(version) + "\" was found"
-                       "\nThe only supported configuration version by this tools is \"" +
-                       int2string(MLX_CFG_VERSION) + "\""+
-                       "\nConsider erasing the configuration section with: \"config r\" flint's command ";
-            return false;
-        }
-    }
-
-    // Get json
-    vector<u_int8_t> jsonData;
-    if (!op->GetProfileList(&flashImageInfo, jsonData))
-    {
-        _lastMsg = op->err();
-        return false;
-    }
-
-    string jsonTxt = string((char*)&jsonData[0]);
-    // Load profiles mapping
-    if (jsonTxt.empty())
-    {
-        _lastMsg = "Image doesn't contain any profiles info";
-        return false;
-    }
-
-    if (!parseProfileDb(jsonTxt))
-        return false;
-
-    // Get Adabe
-    vector<u_int8_t> adabeData;
-    if (!op->GetTlvFormatXML(&flashImageInfo, adabeData))
-    {
-        _lastMsg = op->err();
-        return false;
-    }
-
-    string adabeTxt = string((char*)&adabeData[0]);
-    if (adabeTxt.empty())
-    {
-        _lastMsg = op->err();
-        return false;
-    }
-
-    if (_adbDB)
-    {
-        delete _adbDB;
-        _adbDB = 0;
-    }
-    if (_adbRoot)
-    {
-        delete _adbRoot;
-        _adbDB = 0;
-    }
-
-    _adbDB = new Adb;
-    if (!_adbDB->loadFromString(adabeTxt.c_str()))
-    {
-        _lastMsg = _adbDB->getLastError();
-        return false;
-    }
-
-    // get Root, TlvHeader and CfgHeader nodes
-    _adbRoot = _adbDB->createLayout(_adbDB->rootNode);
-    if (!_adbRoot)
-    {
-        _lastMsg = "Can't get root node of TLVs: " + _adbDB->getLastError();
-        return false;
-    }
-    _adbTlvHeader = _adbRoot->getChildByPath("tlv_header");
-    _adbCfgHeader = _adbRoot->getChildByPath("cfg_section_header");
-    if (!_adbTlvHeader || !_adbCfgHeader)
-    {
-        _lastMsg = "Can't find one of the tlv_header/cfg_section_header definition in TLVs adabe";
-        return false;
-    }
-
-    return true;
-}
-
-/************************************
- * Function: execute
- ************************************/
-bool MlxConfig::execute(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo, int argc, const char** argv)
-{
-    if (!parseCmdLine(argc, argv))
-    {
-        _lastMsg = "Failed to parse command line arguments";
-        return false;
-    }
-
-    // This if handles the ugly old FW that configured using old mlxconfig tool
-    bool cfgPresent;
-    u_int32_t cfgVer;
-    if (!isConfigPresent(flash, op, flashImageInfo, cfgPresent, cfgVer))
-        return false;
-
-    if (_cmd != CMD_RESTORE && cfgPresent && cfgVer == OLD_MLXCONFIG_VERSION)
-    {
-        _lastMsg = "Found old version of FW configuration, please use \"mlxconfig\"";
-        return false;
-    }
-
-    switch (_cmd)
-    {
-    case CMD_SET:
-        return setCfg(flash, op, flashImageInfo, _cmdProfile);
-    case CMD_QUERY:
-        return queryCfg(flash, op, flashImageInfo);
-    case CMD_RESTORE:
-        return eraseCfg(flash, op, flashImageInfo);
-    case CMD_LIST_PROFILES:
-        return listProfilesCfg(flash, op, flashImageInfo);
-    case CMD_RECONFIG:
-        return reconfigureCfg(flash, op, flashImageInfo);
-    case CMD_HELP:
-        printf("%s\n", getHelpMessage());
-        return true;
-    case CMD_CONFIG_INFO:
-        return configInfo(flash, op, flashImageInfo);
-    case CMT_VERIFY:
-        return verifyCfg(flash, op, flashImageInfo);
-    default:
-        _lastMsg = "No command given. See help for details.";
-        return false;
-    }
-}
-
-/************************************
- * Function: setCfg
- ************************************/
-bool MlxConfig::setCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo, string profileName, bool silent)
-{
-    // Pack all tlvs
-    u_int8_t *tlvHeaderBuf, *tlvDataBuf;
-    u_int32_t totalCfgSize = 0;
-    Profile profile;
-    u_int32_t crc16;
-
-    if (!flashImageInfo.isConfigurable)
-    {
-        _lastMsg = "Current FW image isn't configurable";
-        return false;
-    }
-
-    if (!loadImageData(flash, op, flashImageInfo))
-        return false;
-
-    if (!_isFailSafe)
-    {
-        if (!silent)
-        {
-            printf("Burning new configuration in non-fail-safe mode");
-            if (!op->ask_user())
-            {
-                _lastMsg = "Set FW configuration was skipped by user";
-                return false;
-            }
-        }
-    }
-
-    int nextActiveCfgIdx;
-    if (!getActiveCfgIdx(flash, nextActiveCfgIdx))
-    {
-        _lastMsg = "Failed to get the current active configuration: " + _lastMsg;
-        return false;
-    }
-    nextActiveCfgIdx = nextActiveCfgIdx == -1 ? 0 : nextActiveCfgIdx;
-    PRINT_DEBUG("Current active image: %d", nextActiveCfgIdx);
-    nextActiveCfgIdx = 1 - nextActiveCfgIdx;
-    PRINT_DEBUG("Next active image: %d", nextActiveCfgIdx);
-
-    if (!silent)
-    {
-        printf("Burning new Configuration");
-        fflush(stdout);
-    }
-
-    // Check if profile exists
-    if (!_profilesMap.count(profileName))
-    {
-        _lastMsg = "Can't find definition of the given profile: " + profileName;
-        goto failed;
-    }
-    profile = _profilesMap[profileName];
-
-    // Check if profile is supported
-    for (size_t i = 0; i < flashImageInfo.supportedProfList.size(); i++)
-    {
-        if (flashImageInfo.supportedProfList[i] == profile.id)
-            break;
-
-        if (i == flashImageInfo.supportedProfList.size() - 1)
-        {
-            _lastMsg = "Profile " + profileName + " isn't supported";
-            return false;
-        }
-    }
-
-    // Calculate the total required buffer len (in bytes)
-    totalCfgSize = _adbCfgHeader->size/8 + _adbTlvHeader->size/8;
-    for (size_t i = 0; i < profile.tlvs.size(); i++)
-    {
-        AdbInstance* node = _adbRoot->getChildByPath(profile.tlvs[i].name);
-        if (!node)
-        {
-            _lastMsg = "Can't find definition (" + profile.tlvs[i].name + ") - Report a bug";
-            goto failed;
-        }
-
-        totalCfgSize += node->size/8 + _adbTlvHeader->size/8;
-    }
-
-    if (totalCfgSize > _cfgSize)
-    {
-        _lastMsg = "The profile: " + profileName + " size is greater than the configuration section size";
-        goto failed;
-    }
-
-    if (!op->IsConfigAreaAvialable(flash, &flashImageInfo))
-    {
-        _lastMsg = "Configuration area overlaps with FW image, maybe you have too large FW image";
-        goto failed;
-    }
-
-    // Allocate the required amount of memory
-    u_int8_t buf[totalCfgSize];
-    memset(buf, 0, totalCfgSize); // zerofy all reserved fields
-
-    // Pack the configuration section header (TEMPORARY VALID SIGNATURE WITH CRC16)
-    setCfgSectionHeader(buf, CFG_HEADER_SIGNATURE, CFG_SIGNATURE);
-    setCfgSectionHeader(buf, CFG_HEADER_MAX_LEN, _cfgSize/4);
-    setCfgSectionHeader(buf, CFG_HEADER_VERSION, MLX_CFG_VERSION);
-    setCfgSectionHeader(buf, CFG_HEADER_PROFILE_ID, profile.id);
-    setCfgSectionHeader(buf, CFG_HEADER_PROFILE_VER, profile.version);
-    setCfgSectionHeader(buf, CFG_HEADER_CRC, 0xffff);
-    crc16 = calcBECrc16((u_int32_t*)buf, _adbCfgHeader->size/32);
-    // set invalid signature with and the calculated crc
-    setCfgSectionHeader(buf, CFG_HEADER_SIGNATURE, CFG_INVALID_SIGNATURE);
-    setCfgSectionHeader(buf, CFG_HEADER_CRC, crc16);
-
-    // Pack all tlvs
-    tlvHeaderBuf = buf + _adbCfgHeader->size/8;
-    tlvDataBuf = tlvHeaderBuf + _adbTlvHeader->size/8;
-    for (size_t i = 0; i < profile.tlvs.size(); i++)
-    {
-        // Find the node definition
-        string tlvName = profile.tlvs[i].name;
-        AdbInstance* node = _adbRoot->getChildByPath(tlvName);
-        if (!node)
-        {
-            _lastMsg = "Can't find node definition for: " + tlvName;
-            goto failed;
-        }
-
-        int nodeId;
-        if (!getTlvNodeId(node, nodeId))
-        {
-            goto failed;
-        }
-
-        int tlvVer;
-        if (!getTlvVersion(node, tlvVer))
-        {
-            goto failed;
-        }
-
-        // First fill the tlv content and then the tlv header
-        // Go over fields and set their value
-        for (size_t j = 0; j < profile.tlvs[i].fields.size(); j++)
-        {
-            AdbInstance* f;
-            f = node->getChildByPath(profile.tlvs[i].fields[j].key);
-            if (!f)
-            {
-                _lastMsg = "Can't find the field: " + profile.tlvs[i].fields[j].key + " in node: " + tlvName;
-                goto failed;
-            }
-
-            u_int64_t value;
-            if (!getFieldIntValue(profile.tlvs[i].fields[j].value, f, value))
-            {
-                goto failed;
-            }
-
-            f->pushBuf(tlvDataBuf, value);
-        }
-
-        // Set header with invalid crc16
-        setTlvHeader(tlvHeaderBuf, TLV_HEADER_LENGTH, node->size/32);
-        setTlvHeader(tlvHeaderBuf, TLV_HEADER_ID, nodeId);
-        setTlvHeader(tlvHeaderBuf, TLV_HEADER_CRC, 0xffff);
-        setTlvHeader(tlvHeaderBuf, TLV_HEADER_VERSION, tlvVer);
-        // Calc crc16
-        u_int16_t crc16 = calcBECrc16((u_int32_t*)tlvHeaderBuf, _adbTlvHeader->size/32 + node->size/32);
-
-        // Set the header crc16
-        setTlvHeader(tlvHeaderBuf, TLV_HEADER_CRC, crc16);
-
-        // Update next tlvHeader & tlvData buffer pointers
-        tlvHeaderBuf += _adbTlvHeader->size/8 + node->size/8;
-        tlvDataBuf = tlvHeaderBuf + _adbTlvHeader->size/8;
-    }
-
-    // Add last tlv header
-    // CRC16 on all section except of the signature (first dwrod) and last dword (the CRC itself)
-    setTlvHeader(tlvHeaderBuf, TLV_HEADER_LENGTH, 0);
-    setTlvHeader(tlvHeaderBuf, TLV_HEADER_ID, LAST_TLV_ID);
-    setTlvHeader(tlvHeaderBuf, TLV_HEADER_CRC, calcBECrc16(((u_int32_t*)buf)+1, (totalCfgSize-4)/4));
-
-    PRINT_DEBUG("Erasing section: 0x%x", _cfgAddress[nextActiveCfgIdx]);
-    if (!flash->erase_sector_phy(_cfgAddress[nextActiveCfgIdx]))
-    {
-        _lastMsg = flash->err();
-        goto failed;
-    }
-
-    PRINT_DEBUG("Writing %d bytes to cfg section", totalCfgSize);
-    if (!flash->write_phy(_cfgAddress[nextActiveCfgIdx]+4, buf+4, totalCfgSize-4, true))
-    {
-        _lastMsg = flash->err();
-        goto failed;
-    }
-
-    // ACTIVATE IT BY WRITING VALID SIGNATURE
-    // write the signature
-    PRINT_DEBUG("Activating image: %d", nextActiveCfgIdx);
-    setCfgSectionHeader(buf, CFG_HEADER_SIGNATURE, CFG_SIGNATURE);
-    if (!flash->write_phy(_cfgAddress[nextActiveCfgIdx], buf, 4, true))
-    {
-        _lastMsg = flash->err();
-        goto failed;
-    }
-
-    if (_isFailSafe)
-    {
-        // Invalidate current active cfg
-        PRINT_DEBUG("Inactivating image: %d", 1- nextActiveCfgIdx);
-        setCfgSectionHeader(buf, CFG_HEADER_SIGNATURE, CFG_INVALID_SIGNATURE);
-        if (!flash->write_phy(_cfgAddress[1-nextActiveCfgIdx], buf, 4, true))
-        {
-            _lastMsg = string() + "Failed to invalidate configuration: " + flash->err();
-            goto failed;
-        }
-    }
-
-    if (!silent)
-        printf(" - OK\n");
-    return true;
-
-failed:
-    if (!silent)
-        printf(" - FAILED\n");
-    return false;
-}
-
-/************************************
- * Function: queryCfg
- ************************************/
-bool MlxConfig::queryCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo)
-{
-    if (!flashImageInfo.isConfigurable)
-    {
-        _lastMsg = "Current FW image isn't configurable";
-        return false;
-    }
-
-    if (!loadImageData(flash, op, flashImageInfo))
-        return false;
-
-    // Todo - need optimization - verify will call loadImageData again
-    if (!verifyCfg(flash, op, flashImageInfo, true))
-    {
-        return false;
-    }
-
-    int activeCfgIdx;
-    if (!getActiveCfgIdx(flash, activeCfgIdx))
-    {
-        _lastMsg = "Failed to get the current active configuration: " + _lastMsg;
-        return false;
-    }
-
-    if (activeCfgIdx == -1)
-    {
-        printf("There is no valid configuration\n");
-        string profileName = findProfileById(flashImageInfo.defPorfile);
-        printf("Default profile is: %s (0x%x)\n", profileName.empty() ? "Unknown" : profileName.c_str(),
-                                                    flashImageInfo.defPorfile);
-        return true;
-    }
-
-    if (_verbose)
-        printf("Active configuration image at address: %#x\n", _cfgAddress[activeCfgIdx]);
-
-    u_int8_t buf[_adbCfgHeader->size/8];
-    if (!flash->read_phy(_cfgAddress[activeCfgIdx], buf, _adbCfgHeader->size/8))
-    {
-        _lastMsg = flash->err();
-        return false;
-    }
-
-    // Parse the  cfg header
-    u_int32_t signature, crc16, maxLen, version, profileID, profileVer;
-    signature = getCfgSectionHeader(buf, CFG_HEADER_SIGNATURE);
-    maxLen = getCfgSectionHeader(buf, CFG_HEADER_MAX_LEN);
-    version = getCfgSectionHeader(buf, CFG_HEADER_VERSION);
-    profileID = getCfgSectionHeader(buf, CFG_HEADER_PROFILE_ID);
-    profileVer = getCfgSectionHeader(buf, CFG_HEADER_PROFILE_VER);
-    crc16 = getCfgSectionHeader(buf, CFG_HEADER_CRC);
-
-    // Find the appropriate profile
-    string profileName = findProfileById(profileID);
-    if (profileName.empty())
-    {
-        _lastMsg = "Burnt profile ID is: " + int2string(profileID) + ", But can't find it in DB";
-        return false;
-    }
-
-    printf("Active Profile: %s, Profile Version: 0x%x\n", profileName.c_str(), profileVer);
-
-    // Print TLV contents
-    if (_verbose)
-    {
-        printf("Configuration Section Version: 0x%x\n", version);
-        printf("Crc16: 0x%x\n", crc16);
-        printf("Tlv contents:\n");
-        u_int32_t tlvAddr = _cfgAddress[activeCfgIdx] + _adbCfgHeader->size/8;
-        while(1)
-        {
-            u_int8_t tlvHeaderBuf[_adbTlvHeader->size/8];
-            if (!flash->read_phy(tlvAddr, &tlvHeaderBuf, _adbTlvHeader->size/8))
-            {
-                _lastMsg = flash->err();
-                return false;
-            }
-
-            u_int16_t len, id, tlvVer, crc;
-            len = getTlvHeader(tlvHeaderBuf, TLV_HEADER_LENGTH);
-            id = getTlvHeader(tlvHeaderBuf, TLV_HEADER_ID);
-            crc = getTlvHeader(tlvHeaderBuf, TLV_HEADER_CRC);
-            tlvVer = getTlvHeader(tlvHeaderBuf, TLV_HEADER_VERSION);
-            if ((u_int32_t)id == LAST_TLV_ID)
-            {
-                printf("\tTlv: LAST\n");
-                break;
-            }
-
-            tlvAddr += _adbTlvHeader->size/8;
-            len *= 4;
-            u_int8_t buf[len];
-            if (!flash->read_phy(tlvAddr, buf, len))
-            {
-                _lastMsg = flash->err();
-                return false;
-            }
-
-            // Find the layout for this tlv id
-            AdbInstance* node = getTlvById(id);
-            if (!node)
-            {
-                _lastMsg = "Can't find TLV definition for TLV ID: " + int2string(id);
-                return false;
-            }
-
-            printf("\tTlv: %s (0x%x), version(%d), crc16(0x%x)\n", node->name.c_str(), id, tlvVer, crc);
-            vector<AdbInstance*> fields = node->getLeafFields();
-            for (size_t i = 0; i < fields.size(); i++)
-            {
-                AdbInstance* f = fields[i];
-                string name = f->fullName(2);
-                u_int32_t value = f->popBuf(buf);
-
-                string enumName;
-                if (f->intToEnum(value, enumName))
-                {
-                    printf("\t\t%-20s : %s (0x%x)\n", name.c_str(), enumName.c_str(), value);
-                }
-                else
-                {
-                    printf("\t\t%-20s : 0x%x\n", name.c_str(), value);
-                }
-            }
-            tlvAddr += len;
-        }
-    }
-
-    return true;
-}
-
-/************************************
- * Function: eraseCfg
- ************************************/
-bool MlxConfig::eraseCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo)
-{
-    // This method must be minimalist, it's shouldn't depend on any image info or old/new fw image.
-    // It should always work
-    /*if (!flashImageInfo.isConfigurable)
-    {
-        _lastMsg = "Current FW image isn't configurable";
-        return false;
-    }*/
-
-    if (!flashImageInfo.imageOk)
-    {
-     _lastMsg = "FW image is empty or corrupted";
-     return false;
-    }
-
-    // get cfg section info
-    _cfgSize =  flashImageInfo.configSize;
-    _cfgAddress[0] = flashImageInfo.configAddr1;
-    _cfgAddress[1] = flashImageInfo.configAddr2;
-
-    _isFailSafe = flashImageInfo.isFailsafe;
-    if (!_isFailSafe)
-    {
-     _cfgAddress[0] = _cfgAddress[1];
-    }
-
-    if (!op->ask_user("You are trying to restore default configuration, do you want to continue"))
-    {
-        return true;
-    }
-
-    printf("Restoring FW configurations to defaults");
-    fflush(stdout);
-
-    if (!flash->erase_sector_phy(_cfgAddress[0]) ||
-       (_isFailSafe && !flash->erase_sector_phy(_cfgAddress[1])))
-    {
-        _lastMsg = flash->err();
-        printf(" - FAILED\n");
-        return false;
-    }
-
-    printf(" - OK\n");
-    return true;
-}
-
-/************************************
- * Function: listProfilesCfg
- ************************************/
-bool MlxConfig::listProfilesCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo)
-{
-    if (!flashImageInfo.isConfigurable)
-    {
-        _lastMsg = "Current FW image isn't configurable";
-        return false;
-    }
-
-    if (!loadImageData(flash, op, flashImageInfo))
-        return false;
-
-    // Todo - need optimization - verify will call loadImageData again
-    if (!verifyCfg(flash, op, flashImageInfo, true))
-    {
-        return false;
-    }
-
-    printf("Supported profiles by the current FW image:\n");
-    for (size_t i = 0; i < flashImageInfo.supportedProfList.size(); i++)
-    {
-        string profileName = findProfileById(flashImageInfo.supportedProfList[i]);
-        if (profileName.empty())
-        {
-            _lastMsg = "Can't find profile (" + int2string(flashImageInfo.supportedProfList[i]) +
-                       ") definition in current Fw image";
-            return false;
-        }
-        PRINT_COLOR(COLOR_GREEN, "\t%u) %s\n", (unsigned)i, profileName.c_str());
-    }
-
-    return true;
-}
-
-/************************************
- * Function: reconfigureCfg
- ************************************/
-bool MlxConfig::reconfigureCfg(Flash* flash, Operations* op, Operations::ImageInfo &newImageInfo)
-{
-    if (!newImageInfo.isConfigurable)
-    {
-        return true;
-    }
-    if (!loadImageData(flash, op, newImageInfo))
-        return false;
-
-    // Todo - need optimization - verify will call loadImageData again
-    if (!verifyCfg(flash, op, newImageInfo, true))
-    {
-        return false;
-    }
-
-    // get the burnt profile
-    int activeCfgIdx;
-    if (!getActiveCfgIdx(flash, activeCfgIdx))
-    {
-        _lastMsg = "Failed to get the current active configuration: " + _lastMsg;
-        return false;
-    }
-
-    if (activeCfgIdx == -1)
-    {
-        return true;
-    }
-
-    u_int8_t buf[_adbCfgHeader->size/8];
-    if (!flash->read_phy(_cfgAddress[activeCfgIdx], buf, _adbCfgHeader->size/8))
-    {
-        _lastMsg = flash->err();
-        return false;
-    }
-
-    // Parse the cfg header
-    u_int32_t profileID, profileVer;
-    profileID = getCfgSectionHeader(buf, CFG_HEADER_PROFILE_ID);
-    profileVer = getCfgSectionHeader(buf, CFG_HEADER_PROFILE_VER);
-
-    if (profileID == CUSTOM_PROFILE_ID) // No need to reconfigure
-    {
-        return true;
-    }
-
-    // find definition for this profile in the current Fw Image json
-    // Find the appropriate profile
-    string profileName = findProfileById(profileID);
-    if (profileName.empty())
-    {
-        _lastMsg = "Burnt profile ID is: " + int2string(profileID) + ", But can't find it in current Fw Image Profiles";
-        return false;
-    }
-
-    if (_profilesMap[profileName].version ==  profileVer) // No need to reconfigure
-    {
-        return true;
-    }
-
-    printf("Reconfiguring FW configuration section");
-    fflush(stdout);
-    bool rc = setCfg(flash, op, newImageInfo, profileName, true);
-    if (rc)
-        printf(" - OK\n");
-    else
-        printf(" - FAILED\n");
-
-    return rc;
-}
-
-/************************************
- * Function: verifyCfg
- ************************************/
-bool MlxConfig::verifyCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo, bool silent)
-{
-    if (!flashImageInfo.isConfigurable)
-    {
-        _lastMsg = "Current FW image isn't configurable";
-        return false;
-    }
-
-    if (!loadImageData(flash, op, flashImageInfo))
-        return false;
-
-    int activeCfgIdx;
-    if (!getActiveCfgIdx(flash, activeCfgIdx))
-    {
-        _lastMsg = "Failed to get the current active configuration: " + _lastMsg;
-        return false;
-    }
-
-    if (activeCfgIdx == -1)
-        return true;
-
-    // verify the configuration header
-    u_int8_t buf[flashImageInfo.configSize];
-    if (!flash->read_phy(_cfgAddress[activeCfgIdx], buf, _adbCfgHeader->size/8))
-    {
-        _lastMsg = flash->err();
-        return false;
-    }
-
-    // Parse the cfg header
-    u_int32_t cfgCrc, expCfgCrc;
-    cfgCrc = getCfgSectionHeader(buf, CFG_HEADER_CRC);
-
-    // calc expected crc16
-    setCfgSectionHeader(buf, CFG_HEADER_CRC, 0xffff);
-    expCfgCrc = calcBECrc16((u_int32_t*)buf, _adbCfgHeader->size/32);
-    if (!crcVerify(_cfgAddress[activeCfgIdx], _adbCfgHeader->size/8, "FW Configurations Header", cfgCrc, expCfgCrc, silent))
-    {
-        _lastMsg = "Configuration Section Header Data Integrity Error - CRC check failed";
-        return false;
-    }
-
-    u_int32_t tlvAddr = _cfgAddress[activeCfgIdx] + _adbCfgHeader->size/8;
-    int tlvIdx = 0;
-    while(1)
-    {
-        if (!flash->read_phy(tlvAddr, buf, _adbTlvHeader->size/8))
-        {
-            _lastMsg = flash->err();
-            return false;
-        }
-
-        u_int32_t tlvCrc, expTlvCrc, id, len;
-        id = getTlvHeader(buf, TLV_HEADER_ID);
-        tlvCrc = getTlvHeader(buf, TLV_HEADER_CRC);
-        len = getTlvHeader(buf, TLV_HEADER_LENGTH);
-
-        if ((u_int32_t)id == LAST_TLV_ID)
-        {
-            break;
-        }
-
-        if (!flash->read_phy(tlvAddr + _adbTlvHeader->size/8, buf + _adbTlvHeader->size/8, len*4))
-        {
-            _lastMsg = flash->err();
-            return false;
-        }
-
-        setTlvHeader(buf, TLV_HEADER_CRC, 0xffff);
-        expTlvCrc = calcBECrc16((u_int32_t*)buf, len + _adbTlvHeader->size/32);
-        if (!crcVerify(tlvAddr, len*4 + _adbTlvHeader->size/8,
-                       "Tlv[" + int2string(tlvIdx) + "]",
-                       tlvCrc, expTlvCrc, silent))
-        {
-            _lastMsg = "Tlv[" + int2string(tlvIdx) + "] Data Integrity Error - CRC check failed";
-            return false;
-        }
-
-        tlvAddr += _adbTlvHeader->size/8 + len*4;
-        tlvIdx++;
-    }
-
-    return true;
-}
-
-/************************************
- * Function: configInfo
- ************************************/
-bool MlxConfig::configInfo(Flash* /*flash*/, Operations* op, Operations::ImageInfo &flashImageInfo)
-{
-    printf("FW image configuration info:\n");
-    printf("============================\n");
-
-    if (!flashImageInfo.isConfigurable)
-    {
-        printf("Image isn't configurable\n");
-        return false;
-    }
-
-    // Todo - need optimization - verify will call loadImageData again
-    /*if (!verifyCfg(flash, op, flashImageInfo, true))
-    {
-        return false;
-    }*/
-
-    if (!flashImageInfo.isFailsafe)
-    {
-        printf("Configuration Section Address: %#x\n", flashImageInfo.configAddr1);
-    }
-    else
-    {
-        printf("Configuration Section 1 Address: %#x\n", flashImageInfo.configAddr1);
-        printf("Configuration Section 2 Address: %#x\n", flashImageInfo.configAddr2);
-    }
-
-    printf("Configuration Section Size: %#x\n", flashImageInfo.configSize);
-    printf("Default Profile: %#x\n", flashImageInfo.defPorfile);
-
-    printf("Profiles Json Contents:\n");
-    vector<u_int8_t> jsonData;
-    if (!op->GetProfileList(&flashImageInfo, jsonData))
-    {
-        _lastMsg = op->err();
-        return false;
-    }
-
-    string jsonStr = string((char*)&jsonData[0]);
-    if (jsonStr.empty())
-    {
-        _lastMsg = "Image doesn't contain any profiles info";
-        return false;
-    }
-    printf("%s\n", jsonStr.c_str());
-
-
-    printf("Tlv Format Adabe Contents:\n");
-    vector<u_int8_t> adbData;
-    if (!op->GetTlvFormatXML(&flashImageInfo, adbData))
-    {
-        _lastMsg = op->err();
-        return false;
-    }
-
-    string adbStr = string((char*)&adbData[0]);
-    if (adbStr.empty())
-    {
-        _lastMsg = "Image doesn't contain any TLVs format info";
-        return false;
-    }
-    printf("%s\n", adbStr.c_str());
-
-    return true;
-}
-
-/************************************
- * Function: isConfigPresent
- ************************************/
-bool MlxConfig::isConfigPresent(Flash* flash, Operations* /*op*/,
-                                Operations::ImageInfo &flashImageInfo,
-                                bool &presents, u_int32_t &configVer)
-{
-    if (!flashImageInfo.imageOk)
-    {
-     _lastMsg = "FW image is empty or corrupted";
-     return false;
-    }
-
-    // get cfg section info
-    _cfgSize =  flashImageInfo.configSize;
-    _cfgAddress[0] = flashImageInfo.configAddr1;
-    _cfgAddress[1] = flashImageInfo.configAddr2;
-
-    _isFailSafe = flashImageInfo.isFailsafe;
-    if (!_isFailSafe)
-    {
-     _cfgAddress[0] = _cfgAddress[1];
-    }
-
-    int activeIdx;
-    if (!getActiveCfgIdx(flash, activeIdx))
-    {
-        return false;
-    }
-
-    presents = activeIdx != -1;
-    // get config version
-    if (presents)
-    {
-        u_int32_t dword;
-        if (!flash->read_phy(_cfgAddress[activeIdx] + 4, &dword, 4))
-        {
-            _lastMsg = flash->err();
-            return false;
-        }
-
-        // Parse the  cfg header
-        configVer = htonl(dword) & 0xff;
-    }
-    return true;
-}
-
-/************************************
- * Function: setNonFailSafeCfg
- ************************************/
-bool MlxConfig::setNonFailSafeCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo)
-{
-    u_int32_t zeros = 0;
-
-    if (!flashImageInfo.isConfigurable)
-    {
-        PRINT_DEBUG("Fw image isn't configurable");
-        return true;
-    }
-
-    if (!loadImageData(flash, op, flashImageInfo))
-        return false;
-
-    // Todo - need optimization - verify will call loadImageData again
-    if (!verifyCfg(flash, op, flashImageInfo, true))
-    {
-        return false;
-    }
-
-    // get active section index
-    int activeCfgIdx;
-    if (!getActiveCfgIdx(flash, activeCfgIdx))
-    {
-        _lastMsg = "Failed to get the current active configuration: " + _lastMsg;
-        return false;
-    }
-
-    if (activeCfgIdx == -1 || activeCfgIdx == 1)
-    {
-        PRINT_DEBUG("no need to move cfg section");
-        return true;
-    }
-
-    printf("Moving current FW configuration to Non-Fail-Safe sections");
-    fflush(stdout);
-    u_int8_t buf[_cfgSize];
-    // read cfg from section 0
-    PRINT_DEBUG("Reading section: 0x%x", _cfgAddress[0]);
-    if (!flash->read_phy(_cfgAddress[0], buf, _cfgSize))
-    {
-        goto failed;
-    }
-
-    // erase section 1
-    PRINT_DEBUG("Erasing section: 0x%x", _cfgAddress[1]);
-    if (!flash->erase_sector_phy(_cfgAddress[1]))
-    {
-        goto failed;
-
-    }
-
-    // write section 1
-    PRINT_DEBUG("Writing %d bytes to cfg section 1", _cfgSize);
-    if (!flash->write_phy(_cfgAddress[1]+4, buf+4, _cfgSize-4, true))
-    {
-        goto failed;
-    }
-
-    // activate section 1 - write valid signature to first dword
-    if (!flash->write_phy(_cfgAddress[1], buf, 4, true))
-    {
-        goto failed;
-    }
-
-    // invalidate first cfg section
-    if (!flash->write_phy(_cfgAddress[0], &zeros, 4, true))
-    {
-        goto failed;
-    }
-
-    printf(" - OK\n");
-    return true;
-
-failed:
-    _lastMsg = flash->err();
-    printf(" - FAILED\n");
-    return false;
-}
-
-/************************************
- * Function: queryProfile
- ************************************/
-bool MlxConfig::queryProfile(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo,
-                  u_int32_t &profileID, string &profileName)
-{
-    profileName = "NONE";
-
-    if (!flashImageInfo.isConfigurable)
-    {
-        PRINT_DEBUG("Fw image isn't configurable");
-        return false;
-    }
-
-    if (!loadImageData(flash, op, flashImageInfo))
-        return false;
-
-    // Todo - need optimization - verify will call loadImageData again
-    if (!verifyCfg(flash, op, flashImageInfo, true))
-    {
-        return false;
-    }
-
-    // get active section index
-    int activeCfgIdx;
-    if (!getActiveCfgIdx(flash, activeCfgIdx))
-    {
-        _lastMsg = "Failed to get the current active configuration: " + _lastMsg;
-        return false;
-    }
-
-    if (activeCfgIdx == -1)
-    {
-        PRINT_DEBUG("There are no configurations");
-        profileID = 0;
-        profileName = "Unknown";
-        return true;
-    }
-
-    // read the current burnt profile
-    u_int8_t buf[_adbCfgHeader->size/8];
-    if (!flash->read_phy(_cfgAddress[activeCfgIdx], buf, _adbCfgHeader->size/8))
-    {
-        _lastMsg = flash->err();
-        return false;
-    }
-
-    // Parse the cfg header
-    profileID = getCfgSectionHeader(buf, CFG_HEADER_PROFILE_ID);
-
-    if (profileID == CUSTOM_PROFILE_ID) // No need to reconfigure
-    {
-        PRINT_DEBUG("Current profile is custom");
-        profileName = "Custom";
-    }
-    else
-    {
-        profileName = findProfileById(profileID);
-    }
-
-    if (profileName.empty())
-    {
-        _lastMsg = "Can't find profile " + int2string(profileID) + " name";
-        return false;
-    }
-    return true;
-}
-/************************************
- * Function: checkExistProfileCompat
- ************************************/
-bool MlxConfig::checkExistProfileCompat(Flash* flash, Operations* op,
-                             Operations::ImageInfo &flashImageInfo,
-                             Operations::ImageInfo &newImageInfo,
-                             bool& compat)
-{
-    string profileName = "NONE";
-    u_int32_t profileID = 0;
-
-    if (!flashImageInfo.isConfigurable)
-    {
-        PRINT_DEBUG("Old Fw image isn't configurable");
-        goto compatible;
-    }
-
-    if (!loadImageData(flash, op, flashImageInfo))
-        return false;
-
-    // Todo - need optimization - verify will call loadImageData again
-    if (!verifyCfg(flash, op, flashImageInfo, true))
-    {
-        return false;
-    }
-
-    PRINT_DEBUG("Checking new FW image compatibility with existing configurations...");
-    // get active section index
-    int activeCfgIdx;
-    if (!getActiveCfgIdx(flash, activeCfgIdx))
-    {
-        _lastMsg = "Failed to get the current active configuration: " + _lastMsg;
-        return false;
-    }
-
-    if (activeCfgIdx == -1)
-    {
-        PRINT_DEBUG("There are no configurations");
-        goto compatible;
-    }
-
-    // read the current burnt profile
-    u_int8_t buf[_adbCfgHeader->size/8];
-    if (!flash->read_phy(_cfgAddress[activeCfgIdx], buf, _adbCfgHeader->size/8))
-    {
-        _lastMsg = flash->err();
-        return false;
-    }
-
-    // Parse the cfg header
-    profileID = getCfgSectionHeader(buf, CFG_HEADER_PROFILE_ID);
-    if (profileID == CUSTOM_PROFILE_ID) // No need to reconfigure
-    {
-        PRINT_DEBUG("Current profile is custom - it's always compatible");
-        goto compatible;
-    }
-
-    // find definition for this profile in the current Fw Image json
-    // Find the appropriate profile
-    profileName = findProfileById(profileID);
-
-    // if new image isn't configurable then it's not compatible (implicitly)
-    if (!newImageInfo.isConfigurable)
-        goto incompatible;
-
-    // Check whether this profile is supported by new image or not
-    for (size_t i = 0; i < newImageInfo.supportedProfList.size(); i++)
-    {
-        if (newImageInfo.supportedProfList[i] == (u_int32_t)profileID)
-            goto compatible;
-    }
-
-incompatible:
-    PRINT_DEBUG("New FW image is incompatible with existing FW configurations: profile %s (0x%x)!!!",
-                profileName.c_str(), profileID);
-    compat = false;
-    return true;
-
-compatible:
-    PRINT_DEBUG("New FW image is compatible with existing FW configurations");
-    compat = true;
-    return true;
-}
-
-/************************************
- * Function: parseProfileDb
- ************************************/
-bool MlxConfig::parseProfileDb(const string &jsonTxt)
-{
-    Json::Value root;
-    Json::Reader reader;
-    bool  res = reader.parse(jsonTxt, root);
-    if (!res)
-    {
-        _lastMsg = "Failed to parse profiles: " + reader.getFormatedErrorMessages();
-        return false;
-    }
-
-    Json::Value::Members profileNames = root.getMemberNames();
-    for (size_t i = 0; i < profileNames.size(); i++)
-    {
-        Profile profile;
-        string profileName = profileNames[i];
-
-        // Get profile info object
-        Json::Value profileObj = root.get(profileName, Json::nullValue);
-        if (!profileObj.isObject())
-        {
-            _lastMsg = "Expected object value in profile: " + profileName + ", not: " + int2string(profileObj.type());
-            return false;
-        }
-
-        // Get profile version
-        int version = profileObj.get("version", -1).asInt();
-        if (version == -1)
-        {
-            _lastMsg = "Missing version for profile: " + profileName;
-            return false;
-        }
-
-        // Get profile id
-        int id = profileObj.get("profile_id", -1).asInt();
-        if (id == -1)
-        {
-            _lastMsg = "Missing profile_id for profile: " + profileName;
-            return false;
-        }
-
-        // Get tlvs list
-        Json::Value tlvsObj = profileObj.get("tlvs", Json::nullValue);
-        if (!tlvsObj.isArray())
-        {
-            _lastMsg = "Expected object tlv to be array in profile: " + profileName + ", not: " + int2string(tlvsObj.type());
-            return false;
-        }
-
-        // Go over all tlvs
-        for (size_t j = 0; j < tlvsObj.size(); j++)
-        {
-            Tlv tlv;
-
-            Json::Value tlvObj = tlvsObj.get(j, Json::nullValue);
-            if (!tlvObj.isObject())
-            {
-                _lastMsg = "expected object value for tlv[: " + int2string(j) + "] profile: " + profileName + ", not: " + int2string(tlvObj.type());
-                return false;
-            }
-
-            if (!tlvObj.isMember("TLV_NAME"))
-            {
-                _lastMsg = "Missing TLV_NAME in value object for tlv[: " + int2string(j) + "] profile: " + profileName;
-                return false;
-            }
-            tlv.name = tlvObj.get("TLV_NAME", Json::nullValue).asString();
-
-            // Get tlv fields/value object
-            Json::Value::Members fieldsNames = tlvObj.getMemberNames();
-            for (size_t k = 0; k < fieldsNames.size(); k++)
-            {
-                Pair pair;
-                pair.key = fieldsNames[k];
-                if (fieldsNames[k] == "TLV_NAME")
-                    continue;
-
-                Json::Value val = tlvObj.get(fieldsNames[k], Json::nullValue);
-                if (val.isIntegral())
-                {
-                    pair.value = int2string(val.asInt());
-                }
-                else if (val.isString())
-                {
-                    pair.value = val.asString();
-                }
-                else
-                {
-                    _lastMsg = "expected int/string value for field: " + fieldsNames[k] + " tlv[: " +
-                                int2string(j) + "] profile: " + profileName + ", not: " + int2string(tlvObj.type());
-                    return false;
-                }
-                tlv.fields.push_back(pair);
-            }
-
-            profile.tlvs.push_back(tlv);
-        }
-
-        // add the new Profile to the profiles map
-        profile.id = id;
-        profile.version = version;
-
-        _profilesMap[profileName] = profile;
-    }
-
-    return true;
-}
-
-/************************************
- * Function: checkOldFW
- ************************************/
-bool MlxConfig::checkOldFW(Operations::ImageInfo &flashImageInfo)
-{
-    // If this the FW that was sent to HP then we need exit and let user run the old mlxconfig tool
-    // This is because tof he major changes in mlxconfig definitions.
-    Operations::ImageInfo info;
-    if (flashImageInfo.fwVer[0] == 2 &&
-        flashImageInfo.fwVer[1] == 10 &&
-       (flashImageInfo.fwVer[2] == 0 || flashImageInfo.fwVer[2] == 1000))
-    {
-        _lastMsg = "You're FW version: " + int2string(flashImageInfo.fwVer[0]) + "." +\
-                                           int2string(flashImageInfo.fwVer[1]) + "." +\
-                                           int2string(flashImageInfo.fwVer[2]) +
-                   " is too old for this tool, consider updating to newer FW or use the old \"mlxconfig\" instead";
-        return false;
-    }
-
-    return true;
-}
-
-/************************************
- * Function: getActiveCfgIdx
- ************************************/
-bool MlxConfig::getActiveCfgIdx(Flash* flash, int& idx) // -1 means no active configuration
-{
-    u_int32_t data0, data1;
-    // Read first dword from cfg0
-    PRINT_DEBUG("Reading first dword from : 0x%x and 0x%x", _cfgAddress[0], _cfgAddress[1]);
-    if (!flash->read_phy(_cfgAddress[0], &data0) ||
-        !flash->read_phy(_cfgAddress[1], &data1))
-    {
-        _lastMsg = flash->err();
-        return false;
-    }
-    PRINT_DEBUG("0x%x - 0x%x", data0, data1);
-
-    if (ntohl(data0) == CFG_SIGNATURE)
-        idx = 0;
-    else if (ntohl(data1) == CFG_SIGNATURE)
-        idx = 1;
-    else
-        idx = -1;
-    return true;
-}
-
-/************************************
- * Function: setTlvHeader
- ************************************/
-void MlxConfig::setTlvHeader(u_int8_t* buf, enum TlvHeaderField field, u_int32_t value)
-{
-    AdbInstance* f;
-
-    switch (field)
-    {
-    case TLV_HEADER_LENGTH:
-        f = _adbTlvHeader->getChildByPath("length");
-        break;
-    case TLV_HEADER_ID:
-        f = _adbTlvHeader->getChildByPath("id");
-        break;
-    case TLV_HEADER_CRC:
-        f = _adbTlvHeader->getChildByPath("crc16");
-        break;
-    case TLV_HEADER_VERSION:
-        f = _adbTlvHeader->getChildByPath("version");
-        break;
-    default:
-        assert(0);
-    }
-
-    f->pushBuf(buf, value);
-}
-
-/************************************
- * Function: getTlvHeader
- ************************************/
-u_int32_t MlxConfig::getTlvHeader(u_int8_t* buf, enum TlvHeaderField field)
-{
-    AdbInstance* f;
-
-    switch (field)
-    {
-    case TLV_HEADER_LENGTH:
-        f = _adbTlvHeader->getChildByPath("length");
-        break;
-    case TLV_HEADER_ID:
-        f = _adbTlvHeader->getChildByPath("id");
-        break;
-    case TLV_HEADER_CRC:
-        f = _adbTlvHeader->getChildByPath("crc16");
-        break;
-    case TLV_HEADER_VERSION:
-        f = _adbTlvHeader->getChildByPath("version");
-        break;
-    default:
-        assert(0);
-    }
-
-    return f->popBuf(buf);
-}
-
-/************************************
- * Function: setCfgSectionHeader
- ************************************/
-void MlxConfig::setCfgSectionHeader(u_int8_t* buf, enum CfgHeaderField field, u_int32_t value)
-{
-    AdbInstance* f;
-
-    switch (field)
-    {
-    case CFG_HEADER_SIGNATURE:
-        f = _adbCfgHeader->getChildByPath("signature");
-        break;
-    case CFG_HEADER_MAX_LEN:
-        f = _adbCfgHeader->getChildByPath("max_len");
-        break;
-    case CFG_HEADER_VERSION:
-        f = _adbCfgHeader->getChildByPath("version");
-        break;
-    case CFG_HEADER_PROFILE_ID:
-        f = _adbCfgHeader->getChildByPath("profile_id");
-        break;
-    case CFG_HEADER_PROFILE_VER:
-        f = _adbCfgHeader->getChildByPath("profile_ver");
-        break;
-    case CFG_HEADER_CRC:
-        f = _adbCfgHeader->getChildByPath("crc16");
-        break;
-    default:
-        assert(0);
-    }
-
-    f->pushBuf(buf, value);
-}
-
-/************************************
- * Function: getCfgSectionHeader
- ************************************/
-u_int32_t MlxConfig::getCfgSectionHeader(u_int8_t* buf, enum CfgHeaderField field)
-{
-    AdbInstance* f;
-
-    switch (field)
-    {
-    case CFG_HEADER_SIGNATURE:
-        f = _adbCfgHeader->getChildByPath("signature");
-        break;
-    case CFG_HEADER_MAX_LEN:
-        f = _adbCfgHeader->getChildByPath("max_len");
-        break;
-    case CFG_HEADER_VERSION:
-        f = _adbCfgHeader->getChildByPath("version");
-        break;
-    case CFG_HEADER_PROFILE_ID:
-        f = _adbCfgHeader->getChildByPath("profile_id");
-        break;
-    case CFG_HEADER_PROFILE_VER:
-        f = _adbCfgHeader->getChildByPath("profile_ver");
-        break;
-    case CFG_HEADER_CRC:
-        f = _adbCfgHeader->getChildByPath("crc16");
-        break;
-    default:
-        assert(0);
-    }
-
-    return f->popBuf(buf);
-}
-
-/************************************
- * Function: calcBECrc16
- ************************************/
-u_int16_t MlxConfig::calcBECrc16(const u_int32_t* buf, int num_of_dwords)
-{
-    Crc16 crc;
-    for (int i = 0; i < num_of_dwords; i++)
-    {
-        crc << ntohl(buf[i]);
-    }
-    crc.finish();
-
-    return crc.get();
-}
-
-/************************************
- * Function: MlxConfig::getTlvById
- ************************************/
-AdbInstance* MlxConfig::getTlvById(int id)
-{
-    for (size_t i = 0; i < _adbRoot->subItems.size(); i++)
-    {
-        int tlvId;
-        if (!getTlvNodeId(_adbRoot->subItems[i], tlvId))
-            return NULL;
-
-        if (tlvId == id)
-            return _adbRoot->subItems[i];
-    }
-
-    return NULL;
-}
-
-/************************************
- * Function: getTlvNodeId
- ************************************/
-bool MlxConfig::getTlvNodeId(AdbInstance* node, int &tlvId)
-{
-    string tlvIdAttr = node->getAttr("tlv_id");
-    assert(!tlvIdAttr.empty());
-
-    errno = 0;
-    tlvId = strtoul(tlvIdAttr.c_str(), 0, 0);
-    if (tlvId == 0 && errno == ERANGE)
-    {
-       _lastMsg = string("The given tlv id for: ") + node->name + " is invalid";
-       return false;
-    }
-
-    if (tlvId < 0 || tlvId > (int)LAST_TLV_ID)
-    {
-       _lastMsg = string("The given tlv id:") + tlvIdAttr + " for: " + node->name + " is out of range";
-       return false;
-    }
-
-    return true;
-}
-
-/************************************
- * Function: getTlvVersion
- ************************************/
-bool MlxConfig::getTlvVersion(AdbInstance* node, int &version)
-{
-    version = 0;
-
-    // Go over all fields
-    for (size_t i = 0; i < node->subItems.size(); i++)
-    {
-        AdbInstance* field = node->subItems[i];
-        string minVerAttr = field->getAttr("min_ver");
-        int fieldMinVer = 0;
-
-        if (minVerAttr.empty())
-        {
-            fieldMinVer = 0;
-        }
-        else
-        {
-            errno = 0;
-            fieldMinVer = strtoul(minVerAttr.c_str(), 0, 0);
-            if (fieldMinVer == 0 && errno == ERANGE)
-            {
-               _lastMsg = string("The given min_ver for field: ") + field->fullName() +
-                                 " within node: " + node->name + " is invalid";
-               return false;
-            }
-        }
-
-        // set version to the maximum between current version and current field
-        version = version > fieldMinVer ? version : fieldMinVer;
-    }
-
-    return true;
-}
-
-/************************************
- * Function: getFieldIntValue
- ************************************/
-bool MlxConfig::getFieldIntValue(string strVal, AdbInstance* field, u_int64_t &intVal)
-{
-    char* p;
-    intVal = strtoul(strVal.c_str(), &p, 0);
-
-    if (*p != 0) // Enum
-    {
-        if (!field->enumToInt(strVal, intVal))
-        {
-            _lastMsg = "Can't find enum (" + strVal + ") value for field: " + field->fullName();
-            return false;
-        }
-    }
-
-    return true;
-}
-
-/************************************
- * Function: findProfileById
- ************************************/
-string MlxConfig::findProfileById(u_int32_t profileID)
-{
-    map<string, Profile>::iterator it;
-
-    for (it = _profilesMap.begin(); it != _profilesMap.end(); it++)
-    {
-        if (it->second.id == profileID)
-        {
-            return it->first;
-        }
-    }
-    return string();
-}
-
-/************************************
- * Function: printProfileDB
- ************************************/
-void MlxConfig::printProfileDB()
-{
-    map<string, Profile>::iterator iter;
-
-    for (iter = _profilesMap.begin(); iter != _profilesMap.end(); iter++)
-    {
-        cout << "Profile: " << iter->first << ", ";
-        iter->second.print();
-        cout << endl;
-    }
-}
-
-/************************************
- * Function: getLastError
- ************************************/
-std::string MlxConfig::getLastError() const
-{
-    return _lastMsg;
-}
-
-/************************************
- * Function: crcVerify
- ************************************/
-bool MlxConfig::crcVerify(u_int32_t startAddr, u_int32_t size, string title,
-                    u_int32_t crc, u_int32_t expectedCrc, bool silent)
-{
-    if (!silent)
-        printf(CRC_CHECK_OUTPUT, PRE_CRC_OUTPUT, startAddr, startAddr + size - 1, size, title.c_str());
-    if (crc == expectedCrc)
-    {
-        if (!silent)
-            printf(" - OK\n");
-        return true;
-    }
-    else
-    {
-        if (!silent)
-            printf(" - wrong CRC (exp:0x%x, act:0x%x)\n", expectedCrc, crc);
-        return false;
-    }
-}
diff --git a/mlxfwops/lib/mlxconfig.h b/mlxfwops/lib/mlxconfig.h
deleted file mode 100755 (executable)
index 8b0d95c..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- *
- * flint.cpp - FLash INTerface
- *
- * Copyright (c) 2005 Mellanox Technologies Ltd.  All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- *  Version: $Id$
- *
- */
-
-#ifndef MLXCONFIG_H
-#define MLXCONFIG_H
-#include <iostream>
-#include <map>
-#include "flint_ops.h"
-
-using namespace std;
-
-/**************************** Forward Declarations *************************/
-class Flash;
-class Operations;
-struct node_format;
-struct field_format;
-
-#define OLD_MLXCONFIG_VERSION 1
-#define ERASE_CMD             "r"
-/**************************** Tlv/Profile private helper structs *************************/
-typedef struct
-{
-    string key;
-    string value;
-
-    // For debug only
-    void print();
-} Pair;
-
-typedef struct
-{
-    string          name;
-    vector<Pair>    fields;
-
-    // For debug only
-    void print();
-
-} Tlv;
-
-typedef struct
-{
-    u_int32_t       version;
-    u_int32_t       id;
-    vector<Tlv>     tlvs;
-
-    // For debug only
-    void print();
-} Profile;
-
-/**************************** MlxConfig Class *************************/
-class AdbInstance;
-class Adb;
-
-class MlxConfig
-{
-public:
-    enum {CMD_SET = 0, CMD_QUERY, CMD_RESTORE, CMD_LIST_PROFILES,
-          CMD_RECONFIG, CMD_HELP, CMD_CONFIG_INFO, CMT_VERIFY, CMD_UNKNOWN};
-    static const u_int32_t CFG_SIGNATURE = 0x4d544346;
-    static const u_int32_t CFG_INVALID_SIGNATURE = 0;
-    static const u_int32_t MLX_CFG_VERSION = 2;
-    static const u_int32_t LAST_TLV_ID    = 0xffff;
-    static const u_int16_t CUSTOM_PROFILE_ID = 0xffff;
-
-    MlxConfig();
-    ~MlxConfig();
-
-    bool checkFwCfgCompat(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo);
-    bool setCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo, string profileName, bool silent = false);
-    bool queryCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo);
-    bool eraseCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo);
-    bool listProfilesCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo);
-    bool reconfigureCfg(Flash* flash, Operations* op, Operations::ImageInfo &newImageInfo);  // For flint use post-burn
-    bool verifyCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo, bool silent = false);
-    bool setNonFailSafeCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo); // For flint use pre-burn
-    bool queryProfile(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo,
-                      u_int32_t &profileID, string &profileName); // For flint use
-    bool configInfo(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo);
-    bool isConfigPresent(Flash* flash, Operations* op,
-                         Operations::ImageInfo &flashImageInfo,
-                         bool &presents, u_int32_t &configVer); // For flint use
-    bool checkExistProfileCompat(Flash* flash, Operations* op,
-                                 Operations::ImageInfo &flashImageInfo,
-                                 Operations::ImageInfo &newImageInfo,
-                                 bool &compat); // For flint use
-
-    // run one of the "setCfg" "queryCfg" "eraseCfg" "listProfilesCfg" using cmdline API
-    bool execute(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo, int argc, const char** argv);
-
-    string getLastError() const;
-    static const char* getHelpMessage();
-    static const char* getRunExamples();
-
-private:
-    bool parseCmdLine(int argc, const char** argv);
-    bool loadImageData(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo);
-    bool parseProfileDb(const string &jsonTxt);
-    bool checkOldFW(Operations::ImageInfo &flashImageInfo);
-
-    // Helpers
-    bool getActiveCfgIdx(Flash* flash, int& idx); // -1 means no active configuration
-
-    enum TlvHeaderField
-    {
-        TLV_HEADER_LENGTH, TLV_HEADER_ID,
-        TLV_HEADER_CRC, TLV_HEADER_VERSION
-    };
-    void setTlvHeader(u_int8_t* buf, enum TlvHeaderField field, u_int32_t value);
-    u_int32_t getTlvHeader(u_int8_t* buf, enum TlvHeaderField field);
-
-    enum CfgHeaderField
-    {
-        CFG_HEADER_SIGNATURE, CFG_HEADER_MAX_LEN,
-        CFG_HEADER_VERSION, CFG_HEADER_PROFILE_ID,
-        CFG_HEADER_PROFILE_VER, CFG_HEADER_CRC
-    };
-    void setCfgSectionHeader(u_int8_t* buf, enum CfgHeaderField field, u_int32_t value);
-    u_int32_t getCfgSectionHeader(u_int8_t* buf, enum CfgHeaderField);
-
-    u_int16_t calcBECrc16(const u_int32_t* buf, int num_of_dwords);
-    AdbInstance* getTlvById(int id);
-    bool getTlvNodeId(AdbInstance* tlvNode, int &tlvId);
-    bool getTlvVersion(AdbInstance* tlvNode, int &version);
-    bool getFieldIntValue(string strVal, AdbInstance* field, u_int64_t &intVal);
-    string findProfileById(u_int32_t profileID);
-    bool crcVerify(u_int32_t startAddr, u_int32_t size, string title,
-                        u_int32_t crc, u_int32_t expectedCrc, bool silent = false);
-    // For debug only
-    void printProfileDB();
-
-private:
-    string _lastMsg;
-    int         _cmd;
-    string      _cmdProfile;
-    string      _cfgFile;
-    string      _profilesFile;
-    bool        _verbose;
-
-    u_int32_t           _cfgAddress[2]; // index is image index
-    u_int32_t           _cfgSize; // Cfg section size
-    bool                _isFailSafe;
-    string              _profilesJson; // Contents
-    Adb*                _adbDB;
-    AdbInstance*        _adbRoot;
-    AdbInstance*        _adbTlvHeader;
-    AdbInstance*        _adbCfgHeader;
-    map<string, Profile> _profilesMap;
-};
-
-#endif // MLXCONFIG_H
diff --git a/mlxfwops/lib/mlxconfig_empty.h b/mlxfwops/lib/mlxconfig_empty.h
deleted file mode 100755 (executable)
index ec82405..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- * 
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- * 
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- * 
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-
-
-#ifndef MLXCONFIG_EMPTY_H
-#define MLXCONFIG_EMPTY_H
-
-// #include <string>
-#include "flint_ops.h"
-
-#define OLD_MLXCONFIG_VERSION 1
-#define ERASE_CMD             "r"
-
-class string
-{
-public:
-    string();
-    ~string();
-    const char* c_str ( ) const {return (const char*)NULL;}
-};
-
-class MlxConfig
-{
-public:
-
-    MlxConfig();
-    ~MlxConfig();
-    bool setNonFailSafeCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo); // For flint use pre-burn
-    string getLastError() const;
-    bool eraseCfg(Flash* flash, Operations* op, Operations::ImageInfo &flashImageInfo);
-    bool checkExistProfileCompat(Flash* flash, Operations* op,
-                                 Operations::ImageInfo &flashImageInfo,
-                                 Operations::ImageInfo &newImageInfo,
-                                 bool &compat); // For flint use
-    bool isConfigPresent(Flash* flash, Operations* op,
-                         Operations::ImageInfo &flashImageInfo,
-                         bool &presents, u_int32_t &configVer); // For flint use
-    bool reconfigureCfg(Flash* flash, Operations* op, Operations::ImageInfo &newImageInfo);  // For flint use post-burn
-
-};
-
-#endif // MLXCONFIG_EMPTY_H
index b89b68e24b435a301a342b6b02c4db51a4369cbe..dbf5016cb6d406030cb0aab393d65007cd6995b5 100755 (executable)
@@ -100,31 +100,7 @@ MLXFWOP_API int MLXFWOPCALL mlxfw_query(mlxfwops_t* mlxfwops, fw_info_t* fw_info
 
 MLXFWOP_API const char* MLXFWOPCALL mlxfw_exp_rom_type_to_str(u_int16_t type)
 {
-    if (type == 0xf) {
-        return "CLP";
-    } else {
-        switch (type) {
-        case 1:
-        case 2:
-        case 3:
-        case 4:
-            return "CLP";
-            break;
-        case 0x10:
-            return "PXE";
-            break;
-        case 0x11:
-            return "UEFI";
-            break;
-        case 0x21:
-            return "FCODE";
-            break;
-
-        default:
-            return (const char*)NULL;
-        }
-    }
-    return (const char*)NULL;
+       return FwOperations::expRomType2Str(type);
 }
 
 MLXFWOP_API int MLXFWOPCALL mlxfw_verify(mlxfwops_t* mlxfwops)
@@ -132,13 +108,6 @@ MLXFWOP_API int MLXFWOPCALL mlxfw_verify(mlxfwops_t* mlxfwops)
     return !static_cast<FwOperations*>((void*)mlxfwops)->FwVerify((f_prog_func_str)NULL);
 }
 
-
-MLXFWOP_API int MLXFWOPCALL mlxfw_test(mlxfwops_t* mlxfwops, u_int32_t *read_data)
-{
-    return !(static_cast<FwOperations*>((void*)mlxfwops)->FwTest(read_data));
-
-}
-
 MLXFWOP_API int MLXFWOPCALL mlxfw_read_image(mlxfwops_t* mlxfwops, void* image, u_int32_t* image_size)
 {
     return !(static_cast<FwOperations*>((void*)mlxfwops)->FwReadData(image, image_size));
index 27f2ec92ca40325c790e1e3198f09d118419a184..766861d330ede1b0c3bab6cd59eed8e4dc5bf85a 100644 (file)
@@ -35,7 +35,6 @@
 #define MLXFWOP_COM_H
 
 #include <compatibility.h>
-#include <sys/types.h>
 
 #ifdef __WIN__
 
@@ -56,9 +55,9 @@
 #endif
 
 typedef int EFIAPI (*f_prog_func) (int completion);
-typedef int (*f_prog_func_str) (const char* str);
+typedef int (*f_prog_func_str) (char* str);
 
-#define VSD_LEN  128  // orenk: BUG - correct val is 208. Fro where did this come from ?
+#define VSD_LEN  208
 #define PSID_LEN 16
 #define PRODUCT_VER_LEN 16
 
@@ -73,6 +72,14 @@ typedef int (*f_prog_func_str) (const char* str);
 #define MINOR_MOD_ROM_FW    6
 #define SUBMINOR_MOD_ROM_FW 1410
 
+//Macros
+#define PRINT_PROGRESS(printFunc, arg) \
+       do {\
+           if (printFunc) {\
+               printFunc((arg));\
+           }\
+       } while(0)\
+
 enum {
     GUIDS         = 4,
     MACS          = 2,
@@ -110,7 +117,8 @@ typedef enum chip_type {
     CT_SWITCHX,
     CT_BRIDGEX,
     CT_IS4,
-    CT_CONNECT_IB
+    CT_CONNECT_IB,
+    CT_SWITCH_IB
 }chip_type_t;
 
 typedef struct guid {
@@ -180,6 +188,7 @@ typedef struct fw_info_com {
     char         vsd[VSD_LEN + 1];
     char         product_ver[PRODUCT_VER_LEN + 1];
     u_int16_t    fw_ver[3];
+    u_int16_t   fw_rel_date[3];
     u_int16_t    min_fit_ver[4];
     u_int16_t    mic_ver[3];
     u_int32_t    image_size;
@@ -187,8 +196,8 @@ typedef struct fw_info_com {
     u_int8_t     dev_rev;
     u_int16_t    vsd_vendor_id;
     u_int8_t     is_failsafe;
-    chip_type_t     chip_type;
-    roms_info_t  roms_info; 
+    chip_type_t  chip_type;
+    roms_info_t  roms_info;
 } fw_info_com_t;
 
 
index e5009c02ffa735eb4d607d0a333783ee92c24b98..f3e405b1de5fb142b952b62461489c826193f28d 100755 (executable)
@@ -33,7 +33,7 @@
 # Makefile.am -- Process this file with automake to produce Makefile.in
 
 
-INCLUDES =     -I$(top_srcdir) -I$(top_srcdir)/include/mtcr_ul
+INCLUDES =     -I$(top_srcdir) -I$(top_srcdir)/include/mtcr_ul -I$(top_srcdir)/common
 AM_CFLAGS = -Wall -W -g -MP -MD -pipe -Wno-unused-function  $(COMPILER_FPIC) -DMTCR_EXPORT -DMST_UL -DDATA_PATH=\"$(pkgdatadir)\"
 
 noinst_LIBRARIES = libcrdump.a
index b1c74d3e15ef207ae2935741be653663582b28aa..19979d6b312878ba434acef899b9428da3b755a2 100755 (executable)
@@ -1,8 +1,5 @@
 /*
- *
- * mstdump.c - crspace dump for Mellanox Technologies Devices.
- *
- * Copyright (c) 2005 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -22,7 +19,7 @@
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- *
+ * 
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
- *  Alaa Al-barari Abarari@asaltech.com
- *  Version: $Id: crdump.c 20-Feb-2013 $
- *
  */
+
+
+#define _GNU_SOURCE
 #include <crdump.h>
 #include <dev_mgt/tools_dev_types.h>
 #include <common/bit_slice.h>
 #include <ctype.h>
+#include <compatibility.h>
+#include <stdio.h>
+
 #define CRD_SELECT_CSV_PATH(dev_name) \
     do {                              \
             strcat(csv_file_path, dev_name);\
 
 
 #if defined(__WIN__)
-#define strcasecmp    _stricmp
+#    define strcasecmp    _stricmp
+#    define CRD_MTCR_DLL_NAME "libmtcr-1.dll"
 #endif
 
 
 //#define CRD_DEBUG_BUILD
 #ifdef CRD_DEBUG_BUILD
-#define CRD_DEBUG(fmt, ...)printf("%s:%s:%d: "fmt, __FILE__, __FUNCTION__, __LINE__,##__VA_ARGS__);
+#    define CRD_DEBUG(fmt, ...)printf("%s:%s:%d: "fmt, __FILE__, __FUNCTION__, __LINE__,##__VA_ARGS__);
 #else
-#define CRD_DEBUG(fmt, args...)
+#    define CRD_DEBUG(fmt, args...)
 #endif
 
 #define CRD_EMPTY  "EMPTY"
 #define CRD_UNKOWN "UNKNOWN"
 
-#define CRD_MAXLINESIZE 1000
+#define CRD_MAXLINESIZE 1024
 #define CRD_MAXFLDS 3 /* maximum possible number of fields */
 #define CRD_MAXFLDSIZE 32 /* longest possible field + 1 = 31 byte field */
-#define CRD_CSV_PATH_SIZE 300
+#define CRD_CSV_PATH_SIZE 1024
 
-#define CRD_MTCR_DLL_NAME "libmtcr-1.dll"
 typedef struct crd_parsed_csv {
 
     u_int32_t addr;
@@ -92,7 +91,7 @@ struct crd_ctxt {
     int       is_full;
     int       cause_addr;
     int       cause_off;
-    char      csv_path[300];
+    char      csv_path[CRD_CSV_PATH_SIZE];
     u_int32_t block_count;
     crd_parsed_csv_t * blocks;
 };
@@ -107,7 +106,9 @@ static int crd_get_csv_path(IN dm_dev_id_t dev_type, OUT char *csv_file_path);
 /*
 count number of dwords, and store all needed data from csv file at parsed_csv
  */
-static int crd_count_double_word(IN  char *csv_file_path, OUT u_int32_t *number_of_dwords, OUT crd_parsed_csv_t blocks[], IN int is_full);
+static int crd_count_double_word(IN  char *csv_file_path, OUT u_int32_t *number_of_dwords,
+                                 OUT crd_parsed_csv_t blocks[], IN int is_full,
+                                 IN u_int8_t read_single_dword);
 
 /*
 Fill addresses at dword_arr
@@ -127,17 +128,22 @@ static void crd_parse(IN  char *record, IN  char *delim, OUT char arr[][CRD_MAXF
 
 static int crd_update_csv_path(IN OUT char *csv_file_path);
 
-static int crd_count_blocks(IN char *csv_file_path, OUT u_int32_t *block_count);
-
-static int crd_replace(INOUT char *st, IN char *orig, IN char *repl);
-
-static int crd_get_exec_name_from_path(IN char *str, OUT char *exec_name);
+static int crd_count_blocks(IN char *csv_file_path, OUT u_int32_t *block_count, u_int8_t read_single_dword);
 
+#if !defined(__WIN__)
 static char *crd_trim(char *s);
 
 static char *crd_rtrim(char *s);
 
 static char *crd_ltrim(char *s);
+#endif 
+
+
+#if defined(__WIN__)
+    static int crd_replace(INOUT char *st, IN char *orig, IN char *repl);
+
+    static int crd_get_exec_name_from_path(IN char *str, OUT char *exec_name);
+#endif
 
 int crd_init(OUT crd_ctxt_t **context, IN mfile *mf, IN int is_full, IN int cause_addr, IN int cause_off) {
 
@@ -146,6 +152,7 @@ int crd_init(OUT crd_ctxt_t **context, IN mfile *mf, IN int is_full, IN int caus
     u_int32_t   chip_rev;
     u_int32_t   number_of_dwords = 0;
     u_int32_t   block_count;
+    u_int8_t    read_single_dword = 0;
     char        csv_file_path [CRD_CSV_PATH_SIZE] = {0x0};
 
 
@@ -158,6 +165,10 @@ int crd_init(OUT crd_ctxt_t **context, IN mfile *mf, IN int is_full, IN int caus
         CRD_DEBUG("cause_off is negative : %d ", cause_off);
         return CRD_INVALID_PARM;
     }
+
+    if (cause_addr >= 0 && cause_off >= 0) {
+        read_single_dword = 1;
+    }
     CRD_DEBUG("getting device id\n");
     if (dm_get_device_id(mf, &dev_type, &dev_id, &chip_rev)) {
         CRD_DEBUG("Failed to identify device.");
@@ -177,13 +188,13 @@ int crd_init(OUT crd_ctxt_t **context, IN mfile *mf, IN int is_full, IN int caus
         return CRD_MEM_ALLOCATION_ERR;
     }
 
-    rc = crd_count_blocks(csv_file_path, &block_count);
+    rc = crd_count_blocks(csv_file_path, &block_count, read_single_dword);
     if (rc) {
-       free(*context);
-       return rc;
+        free(*context);
+        return rc;
     }
-    CRD_DEBUG("Block count : %d\n", block_count);
 
+    CRD_DEBUG("Block count : %d\n", block_count);
     (*context)->blocks = (crd_parsed_csv_t *) malloc(sizeof(crd_parsed_csv_t) * block_count);
     if ((*context)->blocks == NULL) {
         CRD_DEBUG("Failed to allocate memmory for csv blocks\n");
@@ -192,7 +203,7 @@ int crd_init(OUT crd_ctxt_t **context, IN mfile *mf, IN int is_full, IN int caus
     }
 
 
-    rc = crd_count_double_word(csv_file_path, &number_of_dwords, (*context)->blocks, is_full);
+    rc = crd_count_double_word(csv_file_path, &number_of_dwords, (*context)->blocks, is_full, read_single_dword);
     if (rc) {
         goto Cleanup;
     }
@@ -317,14 +328,14 @@ static int crd_get_csv_path(IN dm_dev_id_t dev_type, OUT char *csv_file_path) {
     char dev_name[100];
     int  rc;
     switch (dev_type) {
-    case DeviceArbel:
-    case DeviceArbelMF:
-    case DeviceTavor:
-    case DeviceAnafa:
-    case DeviceSinai:
+    case DeviceInfiniHostIIIEx:
+    case DeviceInfiniHostIIIEx_MF:
+    case DeviceInfiniHost:
+    case DeviceInfiniScale:
+    case DeviceInfiniHostIIILx:
         return CRD_NOT_SUPPORTED;
     default:
-        strcpy(dev_name, dm_dev_type2str_ext(dev_type));
+        strcpy(dev_name, dm_dev_type2str(dev_type));
     }
     if (!strcmp(dev_name, "Unknown Device")) {
         return CRD_UNKOWN_DEVICE;
@@ -354,9 +365,12 @@ static void crd_parse(IN  char *record, IN  char *delim, OUT char arr[][CRD_MAXF
     *field_count = field;
 }
 
-static int crd_count_blocks(IN char *csv_file_path, OUT u_int32_t *block_count) {
+static int crd_count_blocks(IN char *csv_file_path,
+                            OUT u_int32_t *block_count, u_int8_t read_single_dword) {
 
     char tmp[1024] = {0x0};
+    char arr[CRD_MAXFLDS][CRD_MAXFLDSIZE] ;
+    int field_count = 0;
     *block_count = 0;
 
     CRD_DEBUG("CSV file path : %s\n", csv_file_path);
@@ -370,17 +384,34 @@ static int crd_count_blocks(IN char *csv_file_path, OUT u_int32_t *block_count)
         if (crd_read_line(fd, tmp) == CRD_SKIP) {
             continue;
         }
-        *block_count += 1;
+        crd_parse(tmp, ",", arr, &field_count); /* whack record into fields */
+        if (field_count < 2 ) {
+            CRD_DEBUG("CSV File has bad format, line : %s\n", tmp);
+            sprintf(crd_error, "CSV File has bad format, line : %s", tmp);
+            fclose(fd);
+            return CRD_CSV_BAD_FORMAT;
+        }
+        if (read_single_dword) {
+            *block_count += atoi(arr[1]);
+        } else {
+            *block_count += 1;
+        }
     }
+    fclose(fd);
     return CRD_OK;
 }
 
 static int crd_count_double_word(IN char *csv_file_path, OUT u_int32_t *number_of_dwords,
-                                 OUT crd_parsed_csv_t blocks[], IN int is_full) {
-
-    int field_count = 0;
-    int block_count = 0;
-    char tmp[1024] = {0x0};
+                                 OUT crd_parsed_csv_t blocks[], IN int is_full,
+                                 IN u_int8_t read_single_dword) {
+
+    int field_count       = 0;
+    int block_count       = 0;
+    u_int32_t addr        = 0;
+    u_int32_t len         = 0;
+    u_int32_t i           = 0;
+    char enable_addr[100] = {0};
+    char tmp[1024]  = {0x0};
     char arr[CRD_MAXFLDS][CRD_MAXFLDSIZE] ;
 
     *number_of_dwords = 0;
@@ -404,20 +435,39 @@ static int crd_count_double_word(IN char *csv_file_path, OUT u_int32_t *number_o
             fclose(fd);
             return CRD_CSV_BAD_FORMAT;
         }
-
-        blocks[block_count].addr = (u_int32_t)strtol(arr[0], NULL, 0);
-        blocks[block_count].len  = atoi(arr[1]);
-        if (field_count > 2) {
-            strcpy(blocks[block_count].enable_addr, arr[2]);
-            if(is_full || (!is_full && !strcmp(blocks[block_count].enable_addr, CRD_EMPTY))) {
-                *number_of_dwords += atoi(arr[1]);
+        addr = (u_int32_t)strtol(arr[0], NULL, 0);
+        len  = atoi(arr[1]);
+        if (!read_single_dword) {
+            blocks[block_count].addr = addr;
+            blocks[block_count].len  = len;
+            if (field_count > 2) {
+                strcpy(blocks[block_count].enable_addr, arr[2]);
+                if(is_full || (!is_full && !strcmp(blocks[block_count].enable_addr, CRD_EMPTY))) {
+                    *number_of_dwords += len;
+                }
+            }
+            else {
+                strcpy(blocks[block_count].enable_addr, CRD_EMPTY);
+                *number_of_dwords += len;
+            }
+            block_count += 1;
+        } else {
+            if (field_count > 2) {
+                strcpy(enable_addr, arr[2]);
+            } else {
+                strcpy(enable_addr, CRD_EMPTY);
+            }
+            if(is_full || (!is_full && !strcmp(enable_addr, CRD_EMPTY))) {
+                *number_of_dwords += len;
+            }
+            for (i = 0; i < len; i++) {
+                blocks[block_count].addr = addr;
+                blocks[block_count].len  = 1;
+                strcpy(blocks[block_count].enable_addr, enable_addr);
+                block_count += 1;
+                addr += 4;
             }
         }
-        else {
-            strcpy(blocks[block_count].enable_addr, CRD_EMPTY);
-            *number_of_dwords += atoi(arr[1]);
-        }
-        block_count += 1;
     }
     fclose(fd);
     return CRD_OK;
@@ -484,6 +534,8 @@ static int crd_read_line(IN FILE *fd, OUT char *tmp) {
     return CRD_OK;
 }
 
+#if defined(__WIN__)
+
 static int crd_replace(INOUT char *st, IN char *orig, IN char *repl) {
     char buffer[CRD_CSV_PATH_SIZE];
     char *ch;
@@ -510,7 +562,10 @@ static int crd_get_exec_name_from_path(IN char *str, OUT char *exec_name) {
     }
     return CRD_OK;
 }
+#endif 
 
+
+#if !defined(__WIN__)
 static char *crd_ltrim(char *s) {
     while(isspace(*s)){
         s++;
@@ -529,12 +584,12 @@ static char *crd_rtrim(char *s) {
     while(isspace(*--back));
     *(back+1) = '\0';
     return s;
-}
+       }
 
 static char *crd_trim(char *s){
     return crd_rtrim(crd_ltrim(s));
 }
-
+#endif 
 
 static int crd_update_csv_path(IN OUT char *csv_file_path) {
 
@@ -545,35 +600,51 @@ static int crd_update_csv_path(IN OUT char *csv_file_path) {
     crd_get_exec_name_from_path(csv_file_path, exec_name);
     crd_replace(csv_file_path, exec_name, "mstdump_dbs\\");
     found = 1;
+
 #elif defined MST_UL
     strcat(csv_file_path, DATA_PATH "/");
     found = 1;
+
 #else
-    char      conf_path[256] = "/etc/mft/mft.conf";
-    char      *data_path;
-    char      * line = NULL;
-    size_t    len    = 0;
-    FILE      *fd   = fopen(conf_path, "r");
+    char      conf_path[256] = ROOT_PATH;
+    char      data_path[CRD_CSV_PATH_SIZE] = {0x0};
+    char      prefix[CRD_CSV_PATH_SIZE] = {0x0};
+    char      * tmp_value = NULL;
+    char      line[CRD_MAXLINESIZE] = {0};
+    FILE      *fd;
+    strcat(conf_path, "etc/mft/mft.conf");
+    fd = fopen(conf_path, "r");
     if (fd == NULL) {
         CRD_DEBUG("Failed to open conf file : %s\n", conf_path);
         sprintf(crd_error, "Failed to open conf file : %s", conf_path);
         return CRD_OPEN_FILE_ERROR;
     }
 
-    while ((getline(&line, &len, fd)) != -1) {
+    while ((fgets(line, CRD_MAXLINESIZE, fd))) {
         if(strstr(line, "mstdump_dbs") != NULL) {
-            data_path = strtok(line, "=");
-            if (data_path != NULL) {
-                data_path = strtok(NULL, "=");
-                if (data_path != NULL) {
-                    strcpy(csv_file_path, crd_trim(data_path));
-                    strcat(csv_file_path, "/");
-                    found = 1;
-                    break;
-                }
+            tmp_value = strtok(line, "=");
+            if (tmp_value != NULL) {
+                tmp_value = strtok(NULL, "=");
+                crd_trim(tmp_value);
+                strcpy(data_path, tmp_value);
+            }
+        } else if(strstr(line, "mft_prefix_location") != NULL) {
+            tmp_value = strtok(line, "=");
+            if (tmp_value != NULL) {
+                tmp_value = strtok(NULL, "=");
+                crd_trim(tmp_value);
+                strcpy(prefix, tmp_value);
             }
         }
     }
+    if (strlen(prefix) && strlen(data_path)) {
+        strcpy(csv_file_path, prefix);
+        strcat(csv_file_path, data_path);
+        strcat(csv_file_path, "/");
+        found = 1;
+    }
+
+    fclose(fd);
 #endif
     if (!found) {
         return CRD_CONF_BAD_FORMAT;
index 0df09809723f2caaa02fa07b6f2926c3516ca97e..45d34dead5d354a405d496c0b81a8e0278c97081 100644 (file)
@@ -1,16 +1,16 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
@@ -29,6 +29,8 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+
+
 #ifndef _CRDUMP_H_
 #define _CRDUMP_H_
 
@@ -43,7 +45,7 @@
 extern "C" {
 #endif
 
-enum crd_return_code { 
+enum crd_return_code {
     CRD_OK = 0,
     CRD_MEM_ALLOCATION_ERR,
     CRD_CR_READ_ERR,
@@ -67,20 +69,20 @@ typedef struct crd_dword {
 } crd_dword_t;
 
 
-typedef void (*crd_callback_t) (crd_dword_t *); // call back 
+typedef void (*crd_callback_t) (crd_dword_t *); // call back
 
 
 #ifndef IN
 #define IN
-#endif 
+#endif
 
 #ifndef OUT
 #define OUT
-#endif 
+#endif
 
 #ifndef INOUT
 #define INOUT
-#endif 
+#endif
 
 /*
 
@@ -103,7 +105,7 @@ int crd_get_addr_list(IN crd_ctxt_t *context, OUT crd_dword_t* dword_arr); // ca
 /*
 Store all addresses and data in dword_arr, if func is not null, it will be called on each dword
  */
-int crd_dump_data(IN crd_ctxt_t *context, OUT crd_dword_t* dword_arr, IN crd_callback_t func);// values will be filled. 
+int crd_dump_data(IN crd_ctxt_t *context, OUT crd_dword_t* dword_arr, IN crd_callback_t func);// values will be filled.
 
 /*
 Return string representation of the error code
index 31605013157b352deaf4182b8569f7efc81fa2a3..5188ab952175227dc599baee06e9ed25fce1637a 100755 (executable)
@@ -1,8 +1,5 @@
 /*
- *
- * mstdump.c - crspace dump for Mellanox Technologies Devices.
- *
- * Copyright (c) 2005 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- *
+ * 
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- *
+ * 
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *  updated by Alaa Al-barari abarari@asaltech.com
- *  Version: $Id: mstdump.c,v 1.9 2007-06-25 12:45:33 yoniy Exp $
- *
  */
 
+
 #include <crdump.h>
 #include <dev_mgt/tools_dev_types.h>
 #include <common/tools_version.h>
 #define CAUSE_FLAG "--cause"
 
 // string explaining the cmd-line structure
-char correct_cmdline[] = "[-full] <device> [i2c-slave] [-v[ersion] [-h[elp]]]";
+char correct_cmdline[] = "   Mellanox mstdump utility, dumps device internal configuration data\n\
+   Usage: mstdump [-full] <device> [i2c-slave] [-v[ersion] [-h[elp]]]\n\n\
+   -full              :  Dump more expanded list of addresses\n\
+                         Note : be careful when using this flag, None safe addresses might be read.\n\
+   -v                 :  Display version info\n\
+   -h                 :  Print this help message\n\
+   Example :\n\
+            mstdump /dev/mst/mt4099_pci_cr0\n";
+
 
 void print_dword(crd_dword_t *dword) {
     printf("0x%8.8x 0x%8.8x\n", dword->addr, dword->data);
@@ -59,14 +62,14 @@ int main(int argc, char** argv) {
     int cause_addr = -1, cause_off = -1;
 
     if (argc < 2 || argc > 4) {
-        fprintf(stderr, "Usage: %s %s.\n", argv[0], correct_cmdline);
+        fprintf(stderr, "%s", correct_cmdline);
         return 2;
     }
 
     for (i = 1; i < argc; ++i) {
         /* check position-independent flags */
         if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-help")) {
-            fprintf(stderr, "Usage: %s %s.\n", argv[0], correct_cmdline);
+            fprintf(stderr, "%s", correct_cmdline);
             exit (0);
         }
         else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "-version")) {
diff --git a/mstdump/mstdump_dbs/ConnectX4.csv b/mstdump/mstdump_dbs/ConnectX4.csv
new file mode 100644 (file)
index 0000000..77697d6
--- /dev/null
@@ -0,0 +1,2297 @@
+#Addr, Size, Enable addr
+0x000000,16385,
+0x010010,8,
+0x010104,1,
+0x01010c,4,
+0x010200,1,
+0x010210,4,
+0x010300,4,
+0x010400,3,
+0x010410,1,
+0x010444,1,
+0x01044c,4,
+0x010480,2,
+0x010500,35,
+0x010590,1,
+0x010600,32,
+0x010704,1,
+0x01070c,1,
+0x010804,2,
+0x010814,3,
+0x010824,2,
+0x010834,3,
+0x010844,2,
+0x010854,5,
+0x010a00,6,
+0x011004,1,
+0x01100c,4,
+0x011204,1,
+0x011214,4,
+0x011228,1,
+0x011244,1,
+0x011250,4,
+0x011264,1,
+0x011274,1,
+0x01127c,1,
+0x0112a4,1,
+0x011300,4,
+0x011314,1,
+0x01131c,3,
+0x011404,2,
+0x011430,20,
+0x011484,2,
+0x011498,5,
+0x0114bc,1,
+0x0114c8,1,
+0x0114d4,2,
+0x01150c,3,
+0x011524,3,
+0x011608,3,
+0x011618,4,
+0x011680,16,
+0x011704,2,
+0x011730,20,
+0x011784,3,
+0x011794,3,
+0x0117c0,6,
+0x011800,35,
+0x0118a4,1,
+0x0118ac,1,
+0x0118c4,3,
+0x0118d4,1,
+0x0118dc,2,
+0x011900,35,
+0x011b04,2,
+0x011b14,3,
+0x011b24,2,
+0x011b38,6,
+0x011b60,5,
+0x011c04,1,
+0x011cb8,18,
+0x011d98,1,
+0x011e00,1,
+0x011e08,1,
+0x011e10,1,
+0x012000,32,
+0x012200,32,
+0x012400,32,
+0x012600,32,
+0x012800,20,
+0x012888,22,
+0x012900,18,
+0x012a00,36,
+0x012b00,3,
+0x012b10,1,
+0x012b20,1,
+0x012b30,1,
+0x012b40,1,
+0x012b50,1,
+0x012b60,1,
+0x012c00,1,
+0x012c08,1,
+0x012c10,1,
+0x012c18,1,
+0x012c20,1,
+0x012c28,1,
+0x012c30,1,
+0x012c38,1,
+0x012c50,1,
+0x012c58,1,
+0x012c60,1,
+0x012c68,1,
+0x012c70,1,
+0x012c78,1,
+0x012c80,1,
+0x012c88,1,
+0x012d00,5,
+0x012d20,2,
+0x012e00,6,
+0x012e20,6,
+0x012e80,5,
+0x013000,4,
+0x013084,1,
+0x01308c,2,
+0x013180,5,
+0x01319c,5,
+0x013304,1,
+0x0133bc,52,
+0x013500,35,
+0x013604,1,
+0x01360c,1,
+0x013624,1,
+0x01362c,1,
+0x013644,1,
+0x01364c,3,
+0x013800,1,
+0x013808,2,
+0x013a04,1,
+0x013a0c,4,
+0x015000,32,
+0x015100,2,
+0x015110,3,
+0x015120,2,
+0x015144,3,
+0x015204,1,
+0x01520c,1,
+0x015224,1,
+0x01522c,1,
+0x015234,1,
+0x01523c,1,
+0x015244,1,
+0x01524c,1,
+0x015254,1,
+0x01525c,2,
+0x015270,1,
+0x015280,1,
+0x015290,1,
+0x0152a0,1,
+0x0152b0,1,
+0x0152c0,1,
+0x0152d0,1,
+0x0152e0,1,
+0x0152f0,1,
+0x015300,1,
+0x015310,1,
+0x015320,1,
+0x015330,1,
+0x016800,3,
+0x016820,8,
+0x017800,1,
+0x017818,1,
+0x017834,1,
+0x017904,4,
+0x017934,1,
+0x01794c,1,
+0x017970,2,
+0x017a00,6,
+0x017c00,6,
+0x017c20,6,
+0x017c40,6,
+0x017c60,6,
+0x017c80,6,
+0x017ca0,6,
+0x017cc0,6,
+0x017ce0,6,
+0x017d00,3,
+0x017d10,4,
+0x018400,11,
+0x018430,2,
+0x018440,4,
+0x018604,1,
+0x018618,2,
+0x018640,4,
+0x018800,1,
+0x018810,4,
+0x018c04,1,
+0x018c0c,4,
+0x01a400,7,
+0x01a420,2,
+0x01a444,1,
+0x01a44c,1,
+0x01a800,1,
+0x01a814,3,
+0x01ac04,1,
+0x01ac0c,4,
+0x01c400,7,
+0x01c500,8,
+0x01c544,1,
+0x01c554,3,
+0x01c564,3,
+0x01c574,3,
+0x01c604,1,
+0x01c60c,3,
+0x01c800,1,
+0x01c814,3,
+0x01cc04,1,
+0x01cc0c,4,
+0x01f400,1,
+0x01f408,4,
+0x01f41c,3,
+0x01f500,2,
+0x01f800,1,
+0x01f814,3,
+0x01fc04,1,
+0x01fc0c,4,
+0x020004,1,
+0x02000c,4,
+0x020080,9,
+0x021004,1,
+0x02100c,4,
+0x021400,5,
+0x021418,1,
+0x021480,1,
+0x021704,2,
+0x02173c,17,
+0x021804,1,
+0x02180c,4,
+0x021a00,2,
+0x022000,131,
+0x022220,4,
+0x022408,6,
+0x022444,1,
+0x022454,3,
+0x022504,1,
+0x02250c,4,
+0x022624,1,
+0x02262c,3,
+0x02263c,1,
+0x022804,1,
+0x02280c,4,
+0x022904,4,
+0x022924,4,
+0x024000,5,
+0x024020,1,
+0x024030,8,
+0x024058,1,
+0x024060,1,
+0x024070,9,
+0x0240a0,1,
+0x0240b0,4,
+0x024100,25,
+0x024200,5,
+0x024218,3,
+0x0243a0,6,
+0x0243bc,26,
+0x024428,3,
+0x024440,3,
+0x024464,1,
+0x02446c,1,
+0x024474,3,
+0x024484,1,
+0x02448c,4,
+0x024500,1,
+0x02450c,7,
+0x024530,1,
+0x024544,4,
+0x024560,1,
+0x024570,1,
+0x024580,4,
+0x0245a4,2,
+0x0245b4,3,
+0x0245c4,2,
+0x0245d4,3,
+0x024600,2,
+0x02460c,1,
+0x024624,3,
+0x024674,1,
+0x02467c,1,
+0x024684,1,
+0x02468c,4,
+0x024704,1,
+0x02470c,4,
+0x024780,32,
+0x024824,4,
+0x024864,6,
+0x024888,10,
+0x0248b4,3,
+0x0248c4,1,
+0x0248cc,1,
+0x0248d4,1,
+0x0248dc,7,
+0x024908,6,
+0x024928,6,
+0x024968,6,
+0x024984,3,
+0x024994,1,
+0x02499c,6,
+0x024a00,14,
+0x024a40,8,
+0x025004,6,
+0x025800,2,
+0x026000,99,
+0x028000,2,
+0x028404,1,
+0x02840c,4,
+0x028800,2,
+0x028c04,1,
+0x028c0c,4,
+0x029004,1,
+0x02900c,5,
+0x029b20,2,
+0x029b30,4,
+0x029b50,5,
+0x02a004,1,
+0x02a00c,4,
+0x02a200,1,
+0x02a210,9,
+0x02a3fc,1,
+0x02a484,16,
+0x02a504,16,
+0x02a780,1,
+0x02a790,4,
+0x02a900,1,
+0x02aa04,1,
+0x02aa0c,4,
+0x02ab00,40,
+0x02aba4,1,
+0x02abac,1,
+0x02abb4,1,
+0x02abbc,1,
+0x02abc4,1,
+0x02abcc,9,
+0x02ac00,2,
+0x02ac10,3,
+0x02ac44,3,
+0x02ad00,1,
+0x02ad08,1,
+0x02ad10,1,
+0x02ad18,1,
+0x02ad20,1,
+0x02ad28,1,
+0x02ad30,1,
+0x02ad38,1,
+0x02ad40,1,
+0x02ad48,1,
+0x02ad50,1,
+0x02ad58,1,
+0x02ad60,1,
+0x02ad68,1,
+0x02ad70,1,
+0x02ad78,1,
+0x02ad80,1,
+0x02ad88,1,
+0x02ad90,1,
+0x02ad98,1,
+0x02ada0,1,
+0x02ada8,1,
+0x02adb0,1,
+0x02adb8,1,
+0x02adc0,1,
+0x02adc8,1,
+0x02add0,1,
+0x02add8,1,
+0x02ade0,1,
+0x02ade8,1,
+0x02adf0,1,
+0x02adf8,1,
+0x02c000,6,
+0x02c100,5,
+0x02c204,1,
+0x02c214,3,
+0x02c224,1,
+0x02c22c,4,
+0x02c244,2,
+0x02c400,3,
+0x02c418,3,
+0x02c434,3,
+0x02c504,6,
+0x02c534,3,
+0x02c54c,1,
+0x02c570,3,
+0x02c800,3,
+0x02c820,6,
+0x02c840,6,
+0x02c860,6,
+0x02c880,6,
+0x02c8a0,6,
+0x02c8c0,6,
+0x02c8e0,6,
+0x02c900,6,
+0x02c920,6,
+0x02c940,6,
+0x02c960,6,
+0x02c980,6,
+0x02c9a0,6,
+0x02c9c0,6,
+0x02c9e0,6,
+0x02ca00,6,
+0x02ca20,6,
+0x02ca40,6,
+0x02ca60,6,
+0x02cc00,3,
+0x02cc20,9,
+0x02cc48,4,
+0x030004,2,
+0x030034,19,
+0x030084,2,
+0x0300bc,17,
+0x030104,2,
+0x030138,18,
+0x030300,5,
+0x030340,1,
+0x03034c,1,
+0x030384,1,
+0x0303c0,16,
+0x030404,1,
+0x03040c,4,
+0x030804,1,
+0x03080c,4,
+0x030c04,1,
+0x030c0c,4,
+0x030e00,1,
+0x031000,7,
+0x031100,7,
+0x031200,18,
+0x031304,1,
+0x03130c,3,
+0x031400,6,
+0x031420,1,
+0x031444,2,
+0x031454,3,
+0x031464,2,
+0x031474,3,
+0x031500,14,
+0x031540,8,
+0x034200,19,
+0x034254,21,
+0x0342ac,1,
+0x0342c0,6,
+0x0342f0,4,
+0x034600,19,
+0x034654,21,
+0x0346ac,1,
+0x0346c0,6,
+0x0346f0,4,
+0x034c00,10,
+0x034c40,9,
+0x034c80,9,
+0x034e04,3,
+0x034e44,1,
+0x034e4c,4,
+0x034e80,5,
+0x034f04,1,
+0x034f20,9,
+0x034f80,1,
+0x035000,2,
+0x035010,3,
+0x035044,3,
+0x035100,66,
+0x035210,3,
+0x035244,3,
+0x035300,64,
+0x037000,5,
+0x03702c,7,
+0x037080,4,
+0x037094,1,
+0x037100,2,
+0x037200,2,
+0x037210,3,
+0x037244,3,
+0x037300,69,
+0x03742c,7,
+0x037480,4,
+0x037494,1,
+0x037500,2,
+0x037600,2,
+0x037610,3,
+0x037644,3,
+0x037700,69,
+0x038000,3,
+0x038104,2,
+0x03813c,3,
+0x038400,1,
+0x038418,1,
+0x038434,1,
+0x038504,4,
+0x038534,1,
+0x03854c,1,
+0x038570,2,
+0x038600,6,
+0x038800,3,
+0x038820,6,
+0x038840,6,
+0x038860,6,
+0x038880,6,
+0x038900,20,
+0x038958,1,
+0x038980,3,
+0x0389a0,25,
+0x03c000,3,
+0x03c010,3,
+0x03c020,3,
+0x03c040,9,
+0x03c068,6,
+0x03c090,2,
+0x03c0a0,3,
+0x03c0c0,12,
+0x03c0f4,1,
+0x03c100,2,
+0x03c110,3,
+0x03c120,1,
+0x03c130,11,
+0x03c160,2,
+0x03c180,4,
+0x03c194,3,
+0x03c1a4,2,
+0x03c1b0,4,
+0x03c2e0,5,
+0x03c2f8,2,
+0x03c30c,13,
+0x03c34c,77,
+0x03c48c,18,
+0x03c500,32,
+0x03c800,16,
+0x03c84c,18,
+0x03c8e0,2,
+0x03c8ec,3,
+0x03c900,1,
+0x03c910,5,
+0x03c930,5,
+0x03c950,5,
+0x03c970,5,
+0x03c990,1,
+0x03c9a4,3,
+0x03ca78,34,
+0x03cb3c,18,
+0x03cb94,3,
+0x03cba4,3,
+0x03cbf0,1,
+0x03cbf8,10,
+0x03cc30,1,
+0x03cc44,4,
+0x03cc60,1,
+0x03cc80,1,
+0x03cc90,1,
+0x03d004,6,
+0x03e004,1,
+0x03e00c,4,
+0x03e404,1,
+0x03e40c,4,
+0x03e604,1,
+0x03e60c,4,
+0x03e800,1,
+0x03f034,19,
+0x03f084,2,
+0x03f0c0,16,
+0x03f200,1,
+0x03f210,1,
+0x03f300,6,
+0x03f320,6,
+0x03f340,3,
+0x03f360,8,
+0x050000,1,
+0x050008,2,
+0x051004,8,
+0x052004,1,
+0x052078,34,
+0x052104,1,
+0x05210c,1,
+0x052114,1,
+0x052124,1,
+0x05212c,1,
+0x052134,1,
+0x052144,1,
+0x05214c,1,
+0x052154,1,
+0x052160,4,
+0x05217c,1,
+0x052194,11,
+0x0521c4,3,
+0x0521d4,3,
+0x0521e4,3,
+0x0521f4,1,
+0x0521fc,1,
+0x052204,1,
+0x05220c,1,
+0x052214,1,
+0x05221c,1,
+0x052234,1,
+0x05223c,2,
+0x052260,9,
+0x0522c4,3,
+0x0522d4,3,
+0x0522e4,3,
+0x0522f4,4,
+0x052310,5,
+0x052330,5,
+0x052350,4,
+0x052364,4,
+0x052380,33,
+0x052410,2,
+0x05241c,1,
+0x052424,1,
+0x05242c,23,
+0x052490,16,
+0x0524d4,1,
+0x0524dc,9,
+0x05251c,9,
+0x05255c,9,
+0x0525dc,9,
+0x052604,1,
+0x052654,28,
+0x0526d0,1,
+0x052710,14,
+0x0527ec,1,
+0x0527fc,40,
+0x052c00,3,
+0x052c20,6,
+0x052c40,6,
+0x052c60,6,
+0x052c80,6,
+0x052ca0,6,
+0x052cc0,6,
+0x052ce0,6,
+0x052d00,6,
+0x052d20,6,
+0x052e00,32,
+0x052e84,1,
+0x052e8c,1,
+0x052e94,1,
+0x052e9c,1,
+0x052ea4,1,
+0x052eac,1,
+0x052eb4,4,
+0x052ed0,1,
+0x052ee0,1,
+0x052ef0,1,
+0x052f00,1,
+0x052f10,1,
+0x052f20,1,
+0x052f30,1,
+0x052f40,1,
+0x052f50,1,
+0x052f60,1,
+0x052f70,1,
+0x052f80,1,
+0x052f90,1,
+0x052fa0,1,
+0x052fb0,1,
+0x052fc0,1,
+0x052fd0,1,
+0x052fe0,1,
+0x052ff0,1,
+0x054004,1,
+0x05400c,4,
+0x054204,1,
+0x05420c,1,
+0x054214,1,
+0x054224,1,
+0x05422c,1,
+0x054234,1,
+0x054244,1,
+0x05424c,1,
+0x054800,1,
+0x054810,22,
+0x0548a8,16,
+0x054928,15,
+0x054a00,11,
+0x054b0c,3,
+0x054c00,5,
+0x055000,5,
+0x055020,24,
+0x055100,13,
+0x055140,11,
+0x055400,3,
+0x055420,6,
+0x055440,6,
+0x055460,6,
+0x055480,6,
+0x0554a0,6,
+0x0554c0,6,
+0x0554e0,6,
+0x055500,6,
+0x055520,6,
+0x055540,6,
+0x055560,6,
+0x055580,6,
+0x056000,2,
+0x056404,1,
+0x05640c,4,
+0x056800,2,
+0x056c04,1,
+0x056c0c,4,
+0x057004,1,
+0x05700c,5,
+0x057b20,2,
+0x057b30,4,
+0x057b50,5,
+0x058004,1,
+0x05800c,4,
+0x058800,7,
+0x058820,6,
+0x058844,2,
+0x058850,9,
+0x058880,1,
+0x058890,1,
+0x0588a0,1,
+0x0588b0,1,
+0x0588c0,1,
+0x058904,3,
+0x058978,66,
+0x058a84,1,
+0x058a8c,1,
+0x058a94,1,
+0x058aa0,2,
+0x058ff0,4,
+0x059004,1,
+0x05900c,4,
+0x059080,39,
+0x059120,1,
+0x059130,1,
+0x059140,1,
+0x059150,1,
+0x059800,1,
+0x059810,1,
+0x059820,1,
+0x059830,1,
+0x059840,1,
+0x059850,1,
+0x059860,1,
+0x059870,1,
+0x059880,1,
+0x059890,1,
+0x0598c4,2,
+0x059900,3,
+0x059940,3,
+0x059960,8,
+0x059c00,1,
+0x059c18,1,
+0x059c34,1,
+0x059d04,4,
+0x059d34,1,
+0x059d4c,1,
+0x059d70,2,
+0x059e00,6,
+0x05a000,4,
+0x05a020,2,
+0x05a030,1,
+0x05a040,1,
+0x05a04c,1,
+0x05a080,5,
+0x05a0a0,1,
+0x05a0b0,1,
+0x05a0c0,1,
+0x060004,11,
+0x060120,4,
+0x060144,2,
+0x060154,7,
+0x060174,1,
+0x06017c,3,
+0x06018c,1,
+0x0601a0,4,
+0x0601b8,2,
+0x060204,1,
+0x06020c,4,
+0x060400,2,
+0x060420,3,
+0x060430,1,
+0x060440,1,
+0x060484,2,
+0x0604b8,18,
+0x060504,1,
+0x06050c,1,
+0x060514,1,
+0x060900,1,
+0x060914,1,
+0x06091c,2,
+0x060930,1,
+0x060a00,32,
+0x060a84,1,
+0x060a8c,1,
+0x060a94,1,
+0x060a9c,1,
+0x060bf0,3,
+0x060c00,11,
+0x060c30,3,
+0x061004,1,
+0x061010,1,
+0x061018,1,
+0x061020,2,
+0x061044,2,
+0x061054,3,
+0x061100,32,
+0x061200,1,
+0x061404,1,
+0x06140c,4,
+0x06180c,8,
+0x061904,3,
+0x061914,3,
+0x061934,3,
+0x061a00,4,
+0x062008,5,
+0x062024,3,
+0x062034,1,
+0x06203c,1,
+0x062044,1,
+0x06204c,1,
+0x062054,1,
+0x06205c,3,
+0x06206c,1,
+0x062080,2,
+0x062094,1,
+0x06209c,2,
+0x0620b0,1,
+0x0620c0,1,
+0x0620d0,1,
+0x0620e0,1,
+0x0620f4,4,
+0x062404,1,
+0x06240c,4,
+0x062800,12,
+0x062834,1,
+0x06283c,5,
+0x062854,1,
+0x062900,3,
+0x062914,1,
+0x06291c,1,
+0x062924,1,
+0x06292c,1,
+0x062934,1,
+0x06293c,2,
+0x062950,2,
+0x063000,1,
+0x063010,4,
+0x063024,1,
+0x06302c,1,
+0x063034,1,
+0x063044,1,
+0x06304c,1,
+0x063054,1,
+0x06305c,2,
+0x063070,1,
+0x063080,1,
+0x063090,1,
+0x0630a4,3,
+0x063100,2,
+0x063144,1,
+0x06314c,1,
+0x063154,1,
+0x063164,1,
+0x06316c,1,
+0x063174,1,
+0x063208,1,
+0x063210,1,
+0x063218,1,
+0x063224,3,
+0x063240,10,
+0x063300,8,
+0x064004,1,
+0x06400c,4,
+0x064200,3,
+0x064300,1,
+0x064308,6,
+0x064324,2,
+0x064338,2,
+0x064380,2,
+0x064394,1,
+0x06439c,2,
+0x064400,2,
+0x064420,3,
+0x064430,1,
+0x064440,1,
+0x064484,2,
+0x0644b8,18,
+0x064504,1,
+0x06450c,1,
+0x064514,1,
+0x064804,1,
+0x064884,2,
+0x0648c8,14,
+0x065018,2,
+0x065040,3,
+0x065060,8,
+0x065104,5,
+0x065200,3,
+0x065220,6,
+0x065240,6,
+0x065260,6,
+0x065280,6,
+0x065f00,2,
+0x066000,2,
+0x066018,2,
+0x066034,2,
+0x066104,6,
+0x066134,2,
+0x06614c,1,
+0x066170,3,
+0x066200,6,
+0x066220,6,
+0x0662c0,1,
+0x066400,8,
+0x066500,14,
+0x066550,8,
+0x066574,3,
+0x070004,1,
+0x07000c,4,
+0x070400,7,
+0x070420,11,
+0x070500,5,
+0x070524,1,
+0x07052c,1,
+0x070534,1,
+0x070600,142,
+0x070884,2,
+0x0708c4,15,
+0x070904,1,
+0x070940,16,
+0x071000,1,
+0x071094,1,
+0x071104,2,
+0x071140,16,
+0x071204,1,
+0x07120c,4,
+0x071404,1,
+0x07140c,1,
+0x071414,1,
+0x07141c,1,
+0x071424,1,
+0x07142c,1,
+0x071504,1,
+0x071540,16,
+0x071800,2,
+0x071904,1,
+0x071940,16,
+0x071a04,1,
+0x071a40,16,
+0x071b04,1,
+0x071b40,16,
+0x072000,3,
+0x072804,1,
+0x07280c,4,
+0x072880,1,
+0x072888,3,
+0x073000,1,
+0x073020,1,
+0x073040,1,
+0x073060,1,
+0x073080,1,
+0x0730a0,1,
+0x0730c0,1,
+0x0730e0,1,
+0x073100,1,
+0x073120,1,
+0x073140,1,
+0x073160,1,
+0x073180,1,
+0x0731a0,1,
+0x0731c0,1,
+0x0731e0,1,
+0x073200,1,
+0x073220,1,
+0x073240,1,
+0x073260,1,
+0x073280,1,
+0x0732a0,1,
+0x0732c0,1,
+0x0732e0,1,
+0x073300,1,
+0x073320,1,
+0x073340,1,
+0x073360,1,
+0x073380,1,
+0x0733a0,1,
+0x0733c0,1,
+0x0733e0,1,
+0x074830,7,
+0x074860,8,
+0x074884,2,
+0x074890,4,
+0x074900,6,
+0x074920,6,
+0x074a00,3,
+0x074c00,1,
+0x074c18,1,
+0x074c34,1,
+0x074d04,3,
+0x074d34,1,
+0x074d4c,1,
+0x074d70,2,
+0x074e00,6,
+0x075000,3,
+0x075010,2,
+0x075020,3,
+0x075100,2,
+0x078000,20,
+0x078054,9,
+0x07807c,3,
+0x07808c,2,
+0x078098,4,
+0x078100,5,
+0x078118,4,
+0x078130,2,
+0x078204,2,
+0x078244,15,
+0x078284,2,
+0x0782c4,22,
+0x078320,2,
+0x078340,2,
+0x078360,2,
+0x078380,2,
+0x0783a0,2,
+0x0783d4,1,
+0x0783dc,1,
+0x078404,1,
+0x07840c,4,
+0x078804,18,
+0x078850,4,
+0x078884,1,
+0x07889c,1,
+0x0788ac,21,
+0x079804,2,
+0x079828,6,
+0x079844,2,
+0x079868,6,
+0x079884,2,
+0x0798a8,7,
+0x0798d0,8,
+0x079904,1,
+0x07990c,1,
+0x079914,1,
+0x079a04,2,
+0x079a40,16,
+0x079a84,2,
+0x079a90,2,
+0x079a9c,13,
+0x079b04,2,
+0x079b3c,17,
+0x079c04,2,
+0x079c40,16,
+0x079c84,2,
+0x079c98,2,
+0x079cc4,13,
+0x079cfc,4,
+0x079d10,2,
+0x079d24,1,
+0x079d2c,2,
+0x079d80,2,
+0x079d8c,1,
+0x079f00,6,
+0x079f20,6,
+0x079f40,6,
+0x079f60,6,
+0x079fa0,3,
+0x079fb0,1,
+0x079fc0,3,
+0x079fe0,11,
+0x07a010,3,
+0x07a020,3,
+0x07a040,9,
+0x07a068,6,
+0x07a090,2,
+0x07a0a0,3,
+0x07a0c0,12,
+0x07a0f4,1,
+0x07a100,2,
+0x07a110,3,
+0x07a120,1,
+0x07a130,11,
+0x07a160,2,
+0x07a180,4,
+0x07a194,3,
+0x07a1a4,2,
+0x07a1b0,4,
+0x07a2e0,5,
+0x07a2f8,2,
+0x07a30c,13,
+0x07a34c,77,
+0x07a48c,18,
+0x07a500,32,
+0x07a800,16,
+0x07a84c,18,
+0x07a8e0,2,
+0x07a8ec,3,
+0x07a900,1,
+0x07a910,5,
+0x07a930,5,
+0x07a950,5,
+0x07a970,5,
+0x07a990,1,
+0x07a9a4,3,
+0x07aa78,34,
+0x07ab3c,18,
+0x07ab94,3,
+0x07aba4,3,
+0x07abf0,1,
+0x07abf8,10,
+0x07ac30,1,
+0x07ac44,4,
+0x07ac60,1,
+0x07ac80,1,
+0x07ac90,1,
+0x07b004,6,
+0x080000,29,
+0x080340,14,
+0x08037c,3,
+0x08038c,1,
+0x080404,6,
+0x080804,2,
+0x080874,35,
+0x081000,129,
+0x081210,4,
+0x081224,4,
+0x081240,3,
+0x081264,2,
+0x081274,3,
+0x081284,2,
+0x081298,2,
+0x081300,2,
+0x081310,8,
+0x081344,1,
+0x08134c,1,
+0x081354,1,
+0x081364,2,
+0x081370,4,
+0x081384,2,
+0x081390,4,
+0x081404,2,
+0x081474,35,
+0x081504,2,
+0x081518,12,
+0x082000,29,
+0x082340,14,
+0x08237c,3,
+0x08238c,1,
+0x082404,1,
+0x08240c,4,
+0x082804,2,
+0x082874,35,
+0x082904,2,
+0x082974,35,
+0x083000,129,
+0x083210,7,
+0x083244,2,
+0x083254,7,
+0x083284,1,
+0x08328c,1,
+0x083294,1,
+0x083304,2,
+0x083310,4,
+0x083324,2,
+0x083330,14,
+0x084000,29,
+0x084340,14,
+0x08437c,3,
+0x08438c,1,
+0x084404,1,
+0x08440c,4,
+0x084804,2,
+0x084874,35,
+0x084904,2,
+0x084974,35,
+0x085000,32,
+0x085200,1,
+0x085210,7,
+0x085240,12,
+0x085280,2,
+0x085304,1,
+0x08530c,1,
+0x085314,1,
+0x085324,2,
+0x085334,3,
+0x085344,2,
+0x085358,2,
+0x085364,2,
+0x085378,2,
+0x085384,2,
+0x085398,2,
+0x085400,7,
+0x086000,2,
+0x086020,2,
+0x086040,1,
+0x086400,11,
+0x086800,3,
+0x086820,6,
+0x086840,6,
+0x086860,6,
+0x086880,6,
+0x0868a0,6,
+0x0868c0,6,
+0x0868e0,6,
+0x086980,3,
+0x0869a0,9,
+0x0869c8,1,
+0x0869d0,3,
+0x087000,26,
+0x087100,1,
+0x087108,1,
+0x087110,1,
+0x087118,1,
+0x087120,1,
+0x087128,1,
+0x087130,1,
+0x087138,1,
+0x087140,1,
+0x087148,1,
+0x087150,1,
+0x087158,1,
+0x087160,1,
+0x087168,1,
+0x087170,1,
+0x087178,1,
+0x087180,10,
+0x0871b0,9,
+0x090000,17,
+0x090060,2,
+0x09006c,1,
+0x090104,1,
+0x090110,12,
+0x090180,9,
+0x0901a8,2,
+0x0901c0,9,
+0x0901e8,2,
+0x090204,1,
+0x090220,24,
+0x090300,6,
+0x090320,9,
+0x090348,1,
+0x090400,6,
+0x090420,9,
+0x090448,1,
+0x090500,6,
+0x090520,2,
+0x090540,1,
+0x090564,2,
+0x090578,3,
+0x091004,3,
+0x091800,8,
+0x091824,2,
+0x091830,10,
+0x091860,6,
+0x092000,32,
+0x093000,1,
+0x093020,1,
+0x093040,1,
+0x093060,1,
+0x093080,1,
+0x0930a0,1,
+0x0930c0,1,
+0x0930e0,1,
+0x093100,1,
+0x0931a0,1,
+0x0931c0,1,
+0x093200,3,
+0x093404,1,
+0x093410,12,
+0x093504,1,
+0x09353c,28,
+0x0935b0,2,
+0x0935c0,3,
+0x094040,3,
+0x094080,3,
+0x0940a0,9,
+0x094800,1,
+0x094818,1,
+0x094834,1,
+0x094904,3,
+0x094934,1,
+0x09494c,1,
+0x094970,2,
+0x094a00,6,
+0x096000,1,
+0x096010,4,
+0x096024,4,
+0x096104,1,
+0x09610c,5,
+0x096204,1,
+0x09620c,4,
+0x096488,1,
+0x096498,3,
+0x0964b0,6,
+0x096504,1,
+0x09650c,4,
+0x096584,3,
+0x096600,16,
+0x096644,2,
+0x096658,3,
+0x096684,2,
+0x0966bc,51,
+0x096800,11,
+0x096884,3,
+0x0968a0,12,
+0x097100,6,
+0x097120,1,
+0x0a0000,1,
+0x0a0008,3,
+0x0a0018,4,
+0x0a0030,2,
+0x0a003c,1,
+0x0a0080,1,
+0x0a0090,1,
+0x0a0804,1,
+0x0a080c,4,
+0x0a0c00,2,
+0x0a0c0c,5,
+0x0a0c40,1,
+0x0a0c50,4,
+0x0a0c70,1,
+0x0a0c80,1,
+0x0a0ca0,21,
+0x0a1004,1,
+0x0a100c,4,
+0x0a1400,2,
+0x0a140c,2,
+0x0a1440,1,
+0x0a1450,4,
+0x0a1470,1,
+0x0a1480,4,
+0x0a14f0,1,
+0x0a1804,1,
+0x0a180c,4,
+0x0a1a00,9,
+0x0a1a30,2,
+0x0a1a3c,2,
+0x0a1a48,4,
+0x0a1c00,32,
+0x0a1c84,1,
+0x0a1d04,1,
+0x0a1d18,26,
+0x0a2000,32,
+0x0a2100,3,
+0x0a2110,6,
+0x0a212c,4,
+0x0a2140,1,
+0x0a2200,1,
+0x0a2304,1,
+0x0a231c,9,
+0x0a2804,1,
+0x0a280c,4,
+0x0a2c04,2,
+0x0a2c10,2,
+0x0a2c1c,2,
+0x0a2c28,3,
+0x0a2c38,14,
+0x0a2c78,9,
+0x0a2d04,2,
+0x0a2d40,20,
+0x0a2da4,1,
+0x0a2dac,1,
+0x0a2db4,1,
+0x0a2dc0,1,
+0x0a4000,14,
+0x0a5000,2,
+0x0a5018,2,
+0x0a5034,2,
+0x0a5104,6,
+0x0a5134,2,
+0x0a514c,1,
+0x0a5170,3,
+0x0a5200,6,
+0x0a5220,6,
+0x0a52c0,2,
+0x0a6000,3,
+0x0a6020,6,
+0x0a6040,6,
+0x0a6060,6,
+0x0a6080,6,
+0x0a7000,2,
+0x0a7040,3,
+0x0a7060,10,
+0x0a8000,10,
+0x0a802c,15,
+0x0a806c,5,
+0x0a8408,5,
+0x0a8424,3,
+0x0a8434,6,
+0x0a8450,2,
+0x0a845c,5,
+0x0a8480,1,
+0x0a84c4,1,
+0x0a84cc,4,
+0x0a8604,1,
+0x0a860c,4,
+0x0a8700,17,
+0x0a8750,4,
+0x0a8800,4,
+0x0a8880,1,
+0x0a88a0,1,
+0x0a88c0,1,
+0x0a8900,1,
+0x0a8960,1,
+0x0a8980,4,
+0x0a8994,1,
+0x0a899c,1,
+0x0a89a4,3,
+0x0a89c0,1,
+0x0a8a00,3,
+0x0a8aa4,1,
+0x0a8aac,1,
+0x0a8ab4,1,
+0x0a8ad4,10,
+0x0a8b00,2,
+0x0a8b80,4,
+0x0a8c04,6,
+0x0a9000,3,
+0x0a9010,21,
+0x0a9080,4,
+0x0a9100,10,
+0x0a91f4,3,
+0x0a920c,35,
+0x0a92a8,6,
+0x0a930c,39,
+0x0a940c,35,
+0x0a949c,9,
+0x0a9500,2,
+0x0a950c,3,
+0x0a951c,3,
+0x0a954c,13,
+0x0a9804,1,
+0x0a980c,4,
+0x0a9c00,2,
+0x0a9c0c,3,
+0x0a9c1c,2,
+0x0a9c28,1,
+0x0a9c44,1,
+0x0a9c60,17,
+0x0a9d00,1,
+0x0a9d20,8,
+0x0a9d48,3,
+0x0a9d80,1,
+0x0a9dc4,3,
+0x0a9dd4,3,
+0x0a9de4,3,
+0x0a9df4,4,
+0x0a9e20,8,
+0x0a9e48,3,
+0x0a9e84,1,
+0x0a9e98,1,
+0x0a9ea0,8,
+0x0a9f00,6,
+0x0a9f20,6,
+0x0a9f40,6,
+0x0a9f60,6,
+0x0a9f80,3,
+0x0a9fa0,23,
+0x0aa004,1,
+0x0aa00c,4,
+0x0b0000,2,
+0x0b0010,4,
+0x0b1000,5,
+0x0b1020,10,
+0x0b1080,20,
+0x0b1100,2,
+0x0b1110,2,
+0x0b1120,2,
+0x0b1160,2,
+0x0b116c,1,
+0x0b1180,3,
+0x0b1190,3,
+0x0b11a0,3,
+0x0b11e0,2,
+0x0b11ec,1,
+0x0b1200,2,
+0x0b1210,2,
+0x0b1260,2,
+0x0b126c,1,
+0x0b1280,3,
+0x0b1290,3,
+0x0b12e0,2,
+0x0b12ec,1,
+0x0b1300,2,
+0x0b1310,2,
+0x0b1320,2,
+0x0b1360,2,
+0x0b136c,1,
+0x0b1380,3,
+0x0b1390,3,
+0x0b13e0,2,
+0x0b13ec,1,
+0x0b1400,3,
+0x0b1410,3,
+0x0b1460,2,
+0x0b146c,1,
+0x0b1480,3,
+0x0b1490,7,
+0x0b14b0,4,
+0x0b14e0,2,
+0x0b14ec,1,
+0x0b1500,3,
+0x0b1510,3,
+0x0b1560,2,
+0x0b156c,1,
+0x0b1580,2,
+0x0b1590,2,
+0x0b15e0,2,
+0x0b15ec,1,
+0x0b1600,3,
+0x0b1610,3,
+0x0b1660,2,
+0x0b166c,1,
+0x0b1680,3,
+0x0b1690,3,
+0x0b16e0,2,
+0x0b16ec,1,
+0x0b1700,8,
+0x0b1760,2,
+0x0b176c,1,
+0x0b1780,8,
+0x0b17e0,2,
+0x0b17ec,1,
+0x0b1800,3,
+0x0b1820,8,
+0x0b2000,3,
+0x0b2010,8,
+0x0b2080,3,
+0x0b20a0,8,
+0x0b2100,3,
+0x0b2110,8,
+0x0b2180,3,
+0x0b21a0,8,
+0x0b2200,3,
+0x0b2210,8,
+0x0b2280,3,
+0x0b22a0,8,
+0x0b2300,3,
+0x0b2310,8,
+0x0b2380,3,
+0x0b23a0,8,
+0x0b2400,3,
+0x0b2410,8,
+0x0b2480,3,
+0x0b24a0,8,
+0x0b2500,3,
+0x0b2510,8,
+0x0b2580,3,
+0x0b25a0,8,
+0x0b2600,3,
+0x0b2610,8,
+0x0b2680,3,
+0x0b26a0,8,
+0x0b2700,3,
+0x0b2710,8,
+0x0b2780,3,
+0x0b27a0,8,
+0x0b2900,1,
+0x0b2910,1,
+0x0b3000,38,
+0x0b3100,3,
+0x0b3120,13,
+0x0b3160,4,
+0x0b3184,5,
+0x0b3200,1,
+0x0b3220,12,
+0x0b3404,1,
+0x0b340c,4,
+0x0b3800,64,
+0x0b4004,1,
+0x0b4010,12,
+0x0b4100,3,
+0x0b4120,8,
+0x0b5000,1,
+0x0b5018,1,
+0x0b5034,1,
+0x0b5104,2,
+0x0b5134,1,
+0x0b514c,1,
+0x0b5170,2,
+0x0b5200,6,
+0x0b6800,3,
+0x0b6820,6,
+0x0b6840,6,
+0x0b6860,6,
+0x0b6880,6,
+0x0b68a0,6,
+0x0b68c0,6,
+0x0b68e0,6,
+0x0b6900,6,
+0x0c0000,4,
+0x0c0058,2,
+0x0c0064,1,
+0x0c0120,2,
+0x0c0130,2,
+0x0c0140,1,
+0x0c0184,11,
+0x0c01c4,3,
+0x0c01dc,3,
+0x0c0280,13,
+0x0c02c0,3,
+0x0c0400,16,
+0x0c0500,3,
+0x0c0804,1,
+0x0c080c,4,
+0x0c0a7c,1,
+0x0c0ae8,6,
+0x0c0b20,24,
+0x0c0ba0,28,
+0x0c0c80,20,
+0x0c0d00,3,
+0x0c0d20,6,
+0x0c0d80,4,
+0x0c0da0,1,
+0x0c0da8,12,
+0x0c0e00,17,
+0x0c0e80,4,
+0x0c0ec0,6,
+0x0c0ee0,6,
+0x0c1000,32,
+0x0c1084,5,
+0x0c10f8,3,
+0x0c1108,3,
+0x0c1118,7,
+0x0c1144,2,
+0x0c1160,11,
+0x0c1200,13,
+0x0c1244,2,
+0x0c1268,6,
+0x0c12a0,1,
+0x0c12c8,6,
+0x0c12e8,6,
+0x0c1310,1,
+0x0c1340,4,
+0x0c13e8,8,
+0x0c140c,14,
+0x0c147c,1,
+0x0c1700,2,
+0x0c1720,8,
+0x0c1800,3,
+0x0c1810,3,
+0x0c1820,3,
+0x0c1830,3,
+0x0c1840,3,
+0x0c1850,3,
+0x0c1860,3,
+0x0c1870,3,
+0x0c1880,3,
+0x0c1890,3,
+0x0c18a0,3,
+0x0c18b0,3,
+0x0c18c0,3,
+0x0c18d0,3,
+0x0c18e0,3,
+0x0c18f0,3,
+0x0c1900,68,
+0x0c1c00,34,
+0x0c1d00,3,
+0x0c1d40,4,
+0x0c1d84,1,
+0x0c1d90,4,
+0x0c1e00,3,
+0x0c1e20,6,
+0x0c1e40,6,
+0x0c1e60,6,
+0x0c1f80,3,
+0x0c1fa0,8,
+0x0c2000,1,
+0x0c2018,1,
+0x0c2034,1,
+0x0c2104,1,
+0x0c2134,1,
+0x0c214c,1,
+0x0c2170,2,
+0x0c2200,6,
+0x0c2400,36,
+0x0c24a0,8,
+0x0c2500,1,
+0x0c2584,7,
+0x0c2604,1,
+0x0c26f0,70,
+0x0c8000,25,
+0x0c8068,4,
+0x0c807c,4,
+0x0c80a0,3,
+0x0c80b0,2,
+0x0c80c8,6,
+0x0c8180,6,
+0x0c81a0,6,
+0x0c9000,1,
+0x0c9018,1,
+0x0c9034,1,
+0x0c9104,1,
+0x0c9134,1,
+0x0c914c,1,
+0x0c9170,2,
+0x0c9200,6,
+0x0c9400,3,
+0x0c9500,3,
+0x0c9520,10,
+0x0ca000,3,
+0x0ca010,36,
+0x0ca0a4,2,
+0x0ca0b0,2,
+0x0ca0c0,14,
+0x0ca100,14,
+0x0ca140,5,
+0x0ca160,4,
+0x0ca180,13,
+0x0ca1b8,11,
+0x0ca1e8,3,
+0x0ca1f8,8,
+0x0ca220,6,
+0x0ca240,6,
+0x0ca260,6,
+0x0ca280,6,
+0x0ca2a0,6,
+0x0ca2c0,6,
+0x0ca2e0,6,
+0x0ca300,6,
+0x0ca320,6,
+0x0ca340,6,
+0x0ca360,6,
+0x0ca400,6,
+0x0ca420,6,
+0x0ca440,6,
+0x0ca460,6,
+0x0ca480,6,
+0x0ca4a0,6,
+0x0ca4c0,6,
+0x0ca4e0,6,
+0x0ca500,6,
+0x0ca520,6,
+0x0ca540,6,
+0x0ca560,6,
+0x0ca580,6,
+0x0ca5a0,6,
+0x0ca5c0,6,
+0x0ca5e0,6,
+0x0ca6fc,1,
+0x0ca704,1,
+0x0ca72c,17,
+0x0ca780,16,
+0x0ca800,8,
+0x0ca824,5,
+0x0ca840,8,
+0x0ca864,5,
+0x0ca880,8,
+0x0ca8a4,5,
+0x0ca8c0,8,
+0x0ca8e4,5,
+0x0ca900,8,
+0x0ca924,5,
+0x0ca940,8,
+0x0ca964,5,
+0x0ca980,8,
+0x0ca9a4,5,
+0x0ca9c0,8,
+0x0ca9e4,5,
+0x0caa00,8,
+0x0caa24,5,
+0x0caa40,8,
+0x0caa64,5,
+0x0caa80,8,
+0x0caaa4,5,
+0x0caac0,8,
+0x0caae4,5,
+0x0cab00,8,
+0x0cab24,5,
+0x0cab40,8,
+0x0cab64,5,
+0x0cab80,8,
+0x0caba4,5,
+0x0cabc0,8,
+0x0cabe4,5,
+0x0cac04,6,
+0x0cac20,2,
+0x0cac30,2,
+0x0cac40,2,
+0x0cac50,2,
+0x0cb000,16,
+0x0cb044,1,
+0x0cb04c,1,
+0x0cb100,16,
+0x0cb1f0,6,
+0x0cb210,3,
+0x0cb220,2,
+0x0cb230,3,
+0x0cb240,2,
+0x0cb250,3,
+0x0cb260,2,
+0x0cb270,3,
+0x0cb280,2,
+0x0cb290,3,
+0x0cb2a0,2,
+0x0cb2b0,3,
+0x0cb2c0,2,
+0x0cb2d0,3,
+0x0cb2e0,2,
+0x0cb2f0,3,
+0x0cb300,2,
+0x0cb310,3,
+0x0cb320,2,
+0x0cb330,3,
+0x0cb340,2,
+0x0cb350,3,
+0x0cb360,2,
+0x0cb370,3,
+0x0cb380,2,
+0x0cb390,3,
+0x0cb3a0,2,
+0x0cb3b0,3,
+0x0cb3c0,2,
+0x0cb3d0,3,
+0x0cb3e0,2,
+0x0cb3f0,3,
+0x0cb400,17,
+0x0cb59c,25,
+0x0cb700,11,
+0x0cb74c,2,
+0x0cb760,24,
+0x0cb800,19,
+0x0cb850,16,
+0x0cb89c,1,
+0x0cb8b0,9,
+0x0cb8e0,1,
+0x0cb8f0,3,
+0x0cb900,17,
+0x0cb958,1,
+0x0cb980,1,
+0x0cb994,2,
+0x0cb9ac,11,
+0x0cb9ec,4,
+0x0cba00,19,
+0x0cba50,16,
+0x0cba9c,1,
+0x0cbab0,9,
+0x0cbae0,1,
+0x0cbaf0,3,
+0x0cbb00,17,
+0x0cbb58,1,
+0x0cbb80,1,
+0x0cbb94,2,
+0x0cbbac,11,
+0x0cbbec,4,
+0x0cbc00,19,
+0x0cbc50,16,
+0x0cbc9c,1,
+0x0cbcb0,9,
+0x0cbce0,1,
+0x0cbcf0,3,
+0x0cbd00,17,
+0x0cbd58,1,
+0x0cbd80,1,
+0x0cbd94,2,
+0x0cbdac,11,
+0x0cbdec,4,
+0x0cbe00,19,
+0x0cbe50,16,
+0x0cbe9c,1,
+0x0cbeb0,9,
+0x0cbee0,1,
+0x0cbef0,3,
+0x0cbf00,17,
+0x0cbf58,1,
+0x0cbf80,1,
+0x0cbf94,2,
+0x0cbfac,11,
+0x0cbfec,4,
+0x0d0000,7,
+0x0d002c,18,
+0x0d1000,2,
+0x0d100c,1,
+0x0d1020,13,
+0x0d1058,1,
+0x0d1060,6,
+0x0d1080,1,
+0x0d10a0,6,
+0x0d1100,2,
+0x0d110c,1,
+0x0d1120,13,
+0x0d1158,1,
+0x0d1160,6,
+0x0d1180,1,
+0x0d11a0,6,
+0x0d1200,2,
+0x0d120c,1,
+0x0d1220,13,
+0x0d1258,1,
+0x0d1260,6,
+0x0d1280,1,
+0x0d12a0,6,
+0x0d1300,2,
+0x0d130c,1,
+0x0d1320,13,
+0x0d1358,1,
+0x0d1360,6,
+0x0d1380,1,
+0x0d13a0,6,
+0x0d1400,14,
+0x0d1440,1,
+0x0d1448,1,
+0x0d1450,6,
+0x0d1480,6,
+0x0d1500,26,
+0x0d1600,4,
+0x0d1620,6,
+0x0d1640,3,
+0x0d1660,6,
+0x0d1800,5,
+0x0d1820,3,
+0x0d1830,3,
+0x0d1840,3,
+0x0d1a00,1,
+0x0d1a08,13,
+0x0d1a40,9,
+0x0d1c00,24,
+0x0d1c64,1,
+0x0d1c80,6,
+0x0d1ca0,3,
+0x0d1cb0,2,
+0x0d1d00,6,
+0x0d1d40,13,
+0x0d1d80,8,
+0x0d2000,2,
+0x0d200c,1,
+0x0d2020,13,
+0x0d2058,1,
+0x0d2060,6,
+0x0d2080,1,
+0x0d20a0,6,
+0x0d2100,2,
+0x0d210c,1,
+0x0d2120,13,
+0x0d2158,1,
+0x0d2160,6,
+0x0d2180,1,
+0x0d21a0,6,
+0x0d2200,2,
+0x0d220c,1,
+0x0d2220,13,
+0x0d2258,1,
+0x0d2260,6,
+0x0d2280,1,
+0x0d22a0,6,
+0x0d2300,2,
+0x0d230c,1,
+0x0d2320,13,
+0x0d2358,1,
+0x0d2360,6,
+0x0d2380,1,
+0x0d23a0,6,
+0x0d2400,14,
+0x0d2440,1,
+0x0d2448,1,
+0x0d2450,6,
+0x0d2480,6,
+0x0d2500,26,
+0x0d2600,4,
+0x0d2620,6,
+0x0d2640,3,
+0x0d2660,6,
+0x0d2800,5,
+0x0d2820,3,
+0x0d2830,3,
+0x0d2840,3,
+0x0d2a00,1,
+0x0d2a08,13,
+0x0d2a40,9,
+0x0d2c00,24,
+0x0d2c64,1,
+0x0d2c80,6,
+0x0d2ca0,3,
+0x0d2cb0,2,
+0x0d2d00,6,
+0x0d2d40,13,
+0x0d2d80,8,
+0x0d3000,8,
+0x0d3024,5,
+0x0d3040,8,
+0x0d3064,5,
+0x0d3080,8,
+0x0d30a4,5,
+0x0d30c0,8,
+0x0d30e4,5,
+0x0d3100,8,
+0x0d3124,5,
+0x0d3140,8,
+0x0d3164,5,
+0x0d3180,8,
+0x0d31a4,5,
+0x0d31c0,8,
+0x0d31e4,5,
+0x0d3204,5,
+0x0d3220,2,
+0x0d3230,2,
+0x0d3240,2,
+0x0d3400,1,
+0x0d3418,1,
+0x0d3434,1,
+0x0d3504,1,
+0x0d3534,1,
+0x0d354c,1,
+0x0d3570,2,
+0x0d3600,6,
+0x0d3800,19,
+0x0d3850,16,
+0x0d389c,1,
+0x0d38b0,9,
+0x0d38e0,1,
+0x0d38f0,3,
+0x0d3900,17,
+0x0d3958,1,
+0x0d3980,1,
+0x0d3994,2,
+0x0d39ac,11,
+0x0d39ec,4,
+0x0d3a00,19,
+0x0d3a50,16,
+0x0d3a9c,1,
+0x0d3ab0,9,
+0x0d3ae0,1,
+0x0d3af0,3,
+0x0d3b00,17,
+0x0d3b58,1,
+0x0d3b80,1,
+0x0d3b94,2,
+0x0d3bac,11,
+0x0d3bec,4,
+0x0d3c00,11,
+0x0d3c4c,2,
+0x0d3c60,40,
+0x0d3d04,1,
+0x0d3d2c,17,
+0x0d3d80,16,
+0x0d3e00,6,
+0x0d3e20,6,
+0x0d3e40,3,
+0x0d3e50,1,
+0x0d8000,6,
+0x0d8020,3,
+0x0d8030,3,
+0x0d8040,6,
+0x0d8060,4,
+0x0d8080,6,
+0x0d8100,28,
+0x0d8400,2,
+0x0d8418,2,
+0x0d8434,2,
+0x0d8504,4,
+0x0d8534,2,
+0x0d854c,1,
+0x0d8570,2,
+0x0d8600,6,
+0x0d8620,6,
+0x0d8800,1,
+0x0d8820,13,
+0x0d8858,8,
+0x0d8900,12,
+0x0d8984,1,
+0x0d89bc,18,
+0x0d8a20,13,
+0x0d8a58,8,
+0x0d8b00,12,
+0x0d8b84,1,
+0x0d8bbc,17,
+0x0d9000,6,
+0x0d9020,6,
+0x0d9048,3,
+0x0d9080,6,
+0x0d909c,1,
+0x0d90a4,2,
+0x0d90b8,3,
+0x0d9100,5,
+0x0d9120,5,
+0x0d9190,10,
+0x0d9200,12,
+0x0d9234,15,
+0x0d9280,26,
+0x0d9300,2,
+0x0d9320,1,
+0x0d9404,4,
+0x0d9418,16,
+0x0d9460,3,
+0x0d9600,7,
+0x0d9644,9,
+0x0d9680,6,
+0x0d96a0,2,
+0x0d9800,6,
+0x0d9820,6,
+0x0d9848,3,
+0x0d9880,6,
+0x0d989c,1,
+0x0d98a4,2,
+0x0d98b8,3,
+0x0d9900,5,
+0x0d9920,5,
+0x0d9990,10,
+0x0d9a00,12,
+0x0d9a34,15,
+0x0d9a80,26,
+0x0d9b00,2,
+0x0d9b20,1,
+0x0d9c04,4,
+0x0d9c18,16,
+0x0d9c60,3,
+0x0d9e00,7,
+0x0d9e44,9,
+0x0d9e80,6,
+0x0d9ea0,2,
+0x0db000,4,
+0x0db018,18,
+0x0db100,4,
+0x0db118,18,
+0x0db200,8,
+0x0db300,6,
+0x0db320,5,
+0x0db340,6,
+0x0db360,5,
+0x0db380,6,
+0x0db400,3,
+0x0db420,8,
+0x0db500,10,
+0x0db544,2,
+0x0db55c,9,
+0x0db584,7,
+0x0db5a4,2,
+0x0db5b8,3,
+0x0db600,2,
+0x0dbfc4,13,
+0x0dc000,366,
+0x0dc800,366,
+0x0e0000,3,
+0x0e001c,2,
+0x0e0030,1,
+0x0e0048,2,
+0x0e0058,2,
+0x0e0068,11,
+0x0e009c,2,
+0x0e00ac,14,
+0x0e0180,2,
+0x0e01e0,1,
+0x0e01e8,3,
+0x0e01f8,1,
+0x0e0200,3,
+0x0e021c,2,
+0x0e0230,1,
+0x0e0248,2,
+0x0e0258,2,
+0x0e0268,11,
+0x0e029c,2,
+0x0e02ac,14,
+0x0e0380,2,
+0x0e03e0,1,
+0x0e03e8,3,
+0x0e03f8,1,
+0x0e0400,3,
+0x0e041c,2,
+0x0e0430,1,
+0x0e0448,2,
+0x0e0458,2,
+0x0e0468,11,
+0x0e049c,2,
+0x0e04ac,14,
+0x0e0580,2,
+0x0e05e0,1,
+0x0e05e8,3,
+0x0e05f8,1,
+0x0e0600,3,
+0x0e061c,2,
+0x0e0630,1,
+0x0e0648,2,
+0x0e0658,2,
+0x0e0668,11,
+0x0e069c,2,
+0x0e06ac,14,
+0x0e0780,2,
+0x0e07e0,1,
+0x0e07e8,3,
+0x0e07f8,1,
+0x0e0800,3,
+0x0e081c,2,
+0x0e0830,1,
+0x0e0848,2,
+0x0e0858,2,
+0x0e0868,11,
+0x0e089c,2,
+0x0e08ac,14,
+0x0e0980,2,
+0x0e09e0,1,
+0x0e09e8,3,
+0x0e09f8,1,
+0x0e0a00,3,
+0x0e0a1c,2,
+0x0e0a30,1,
+0x0e0a48,2,
+0x0e0a58,2,
+0x0e0a68,11,
+0x0e0a9c,2,
+0x0e0aac,14,
+0x0e0b80,2,
+0x0e0be0,1,
+0x0e0be8,3,
+0x0e0bf8,1,
+0x0e0c00,3,
+0x0e0c1c,2,
+0x0e0c30,1,
+0x0e0c48,2,
+0x0e0c58,2,
+0x0e0c68,11,
+0x0e0c9c,2,
+0x0e0cac,14,
+0x0e0d80,2,
+0x0e0de0,1,
+0x0e0de8,3,
+0x0e0df8,1,
+0x0e0e00,3,
+0x0e0e1c,2,
+0x0e0e30,1,
+0x0e0e48,2,
+0x0e0e58,2,
+0x0e0e68,11,
+0x0e0e9c,2,
+0x0e0eac,14,
+0x0e0f80,2,
+0x0e0fe0,1,
+0x0e0fe8,3,
+0x0e0ff8,1,
+0x0e1400,8,
+0x0e1450,3,
+0x0e1460,3,
+0x0e1474,5,
+0x0e14a0,8,
+0x0e14e0,7,
+0x0e1504,1,
+0x0e1540,16,
+0x0e15f0,3,
+0x0e1604,1,
+0x0e1640,16,
+0x0e1700,16,
+0x0e1a00,4,
+0x0e2000,1,
+0x0e2018,1,
+0x0e2034,1,
+0x0e2104,1,
+0x0e2134,1,
+0x0e214c,1,
+0x0e2170,2,
+0x0e2200,6,
+0x0e2420,2,
+0x0e2430,10,
+0x0e2460,6,
+0x0e2480,6,
+0x0e24a0,3,
+0x0e2504,4,
+0x0e2600,16,
+0x0e2644,5,
+0x0e2660,6,
+0x0e2804,8,
+0x0e2828,5,
+0x0e2844,3,
+0x0e2854,6,
+0x0e2880,4,
+0x0e28a0,6,
+0x0e2a04,3,
+0x0e2b00,33,
+0x0e2c40,3,
+0x0e2c60,11,
+0x0e8000,9,
+0x0e8050,1,
+0x0e8064,6,
+0x0e8080,1,
+0x0e8088,2,
+0x0f0000,3,
+0x0f0014,8,
+0x0f0040,3,
+0x0f0050,4,
+0x0f0080,12,
+0x0f00f0,2,
+0x0f0100,3,
+0x0f0118,5,
+0x0f0130,6,
+0x0f015c,13,
+0x0f01a0,3,
+0x0f01c0,2,
+0x0f01d0,10,
+0x0f0200,61,
+0x0f0404,8,
+0x0f0440,4,
+0x0f0460,1,
+0x0f0468,3,
+0x0f0480,6,
+0x0f04a0,8,
+0x0f04e0,6,
+0x0f0500,6,
+0x0f0520,8,
+0x0f0560,6,
+0x0f05dc,73,
+0x0f0704,1,
+0x0f0714,10,
+0x0f0800,17,
+0x0f0850,9,
+0x0f0880,4,
+0x0f089c,5,
+0x0f08bc,5,
+0x0f08dc,1,
+0x0f0900,6,
+0x0f0920,6,
+0x0f0940,6,
+0x0f0980,3,
+0x0f0990,1,
+0x0f0ffc,1,
diff --git a/mstdump/mstdump_dbs/SwitchIB.csv b/mstdump/mstdump_dbs/SwitchIB.csv
new file mode 100644 (file)
index 0000000..43b887d
--- /dev/null
@@ -0,0 +1,11176 @@
+#Addr, Size, Enable addr 
+0x000000,1,
+0x000008,14,
+0x000080,1,
+0x000088,18,
+0x000100,9,
+0x000134,2,
+0x00014c,4,
+0x00016c,6,
+0x00018c,8,
+0x0001b0,1,
+0x000200,2,
+0x00020c,1,
+0x000214,13,
+0x000254,5,
+0x00026c,7,
+0x0002a8,3,
+0x0002c0,8,
+0x000300,6,
+0x000380,3,
+0x0003a0,14,
+0x0003e0,9,
+0x000408,14,
+0x000480,1,
+0x000488,18,
+0x000500,9,
+0x000534,2,
+0x00054c,4,
+0x00056c,6,
+0x00058c,8,
+0x0005b0,1,
+0x000600,2,
+0x00060c,1,
+0x000614,13,
+0x000654,5,
+0x00066c,7,
+0x0006a8,3,
+0x0006c0,8,
+0x000700,6,
+0x000780,3,
+0x0007a0,14,
+0x0007e0,9,
+0x000808,14,
+0x000880,1,
+0x000888,18,
+0x000900,9,
+0x000934,2,
+0x00094c,4,
+0x00096c,6,
+0x00098c,8,
+0x0009b0,1,
+0x000a00,2,
+0x000a0c,1,
+0x000a14,13,
+0x000a54,5,
+0x000a6c,7,
+0x000aa8,3,
+0x000ac0,8,
+0x000b00,6,
+0x000b80,3,
+0x000ba0,14,
+0x000be0,9,
+0x000c08,14,
+0x000c80,1,
+0x000c88,18,
+0x000d00,9,
+0x000d34,2,
+0x000d4c,4,
+0x000d6c,6,
+0x000d8c,8,
+0x000db0,1,
+0x000e00,2,
+0x000e0c,1,
+0x000e14,13,
+0x000e54,5,
+0x000e6c,7,
+0x000ea8,3,
+0x000ec0,8,
+0x000f00,6,
+0x000f80,3,
+0x000fa0,14,
+0x000fe0,9,
+0x001008,14,
+0x001080,1,
+0x001088,18,
+0x001100,9,
+0x001134,2,
+0x00114c,4,
+0x00116c,6,
+0x00118c,8,
+0x0011b0,1,
+0x001200,2,
+0x00120c,1,
+0x001214,13,
+0x001254,5,
+0x00126c,7,
+0x0012a8,3,
+0x0012c0,8,
+0x001300,6,
+0x001380,3,
+0x0013a0,14,
+0x0013e0,9,
+0x001408,14,
+0x001480,1,
+0x001488,18,
+0x001500,9,
+0x001534,2,
+0x00154c,4,
+0x00156c,6,
+0x00158c,8,
+0x0015b0,1,
+0x001600,2,
+0x00160c,1,
+0x001614,13,
+0x001654,5,
+0x00166c,7,
+0x0016a8,3,
+0x0016c0,8,
+0x001700,6,
+0x001780,3,
+0x0017a0,14,
+0x0017e0,9,
+0x001808,14,
+0x001880,1,
+0x001888,18,
+0x001900,9,
+0x001934,2,
+0x00194c,4,
+0x00196c,6,
+0x00198c,8,
+0x0019b0,1,
+0x001a00,2,
+0x001a0c,1,
+0x001a14,13,
+0x001a54,5,
+0x001a6c,7,
+0x001aa8,3,
+0x001ac0,8,
+0x001b00,6,
+0x001b80,3,
+0x001ba0,14,
+0x001be0,9,
+0x001c08,14,
+0x001c80,1,
+0x001c88,18,
+0x001d00,9,
+0x001d34,2,
+0x001d4c,4,
+0x001d6c,6,
+0x001d8c,8,
+0x001db0,1,
+0x001e00,2,
+0x001e0c,1,
+0x001e14,13,
+0x001e54,5,
+0x001e6c,7,
+0x001ea8,3,
+0x001ec0,8,
+0x001f00,6,
+0x001f80,3,
+0x001fa0,14,
+0x001fe0,9,
+0x002008,14,
+0x002080,1,
+0x002088,18,
+0x002100,9,
+0x002134,2,
+0x00214c,4,
+0x00216c,6,
+0x00218c,8,
+0x0021b0,1,
+0x002200,2,
+0x00220c,1,
+0x002214,13,
+0x002254,5,
+0x00226c,7,
+0x0022a8,3,
+0x0022c0,8,
+0x002300,6,
+0x002380,3,
+0x0023a0,14,
+0x0023e0,9,
+0x002408,14,
+0x002480,1,
+0x002488,18,
+0x002500,9,
+0x002534,2,
+0x00254c,4,
+0x00256c,6,
+0x00258c,8,
+0x0025b0,1,
+0x002600,2,
+0x00260c,1,
+0x002614,13,
+0x002654,5,
+0x00266c,7,
+0x0026a8,3,
+0x0026c0,8,
+0x002700,6,
+0x002780,3,
+0x0027a0,14,
+0x0027e0,9,
+0x002808,14,
+0x002880,1,
+0x002888,18,
+0x002900,9,
+0x002934,2,
+0x00294c,4,
+0x00296c,6,
+0x00298c,8,
+0x0029b0,1,
+0x002a00,2,
+0x002a0c,1,
+0x002a14,13,
+0x002a54,5,
+0x002a6c,7,
+0x002aa8,3,
+0x002ac0,8,
+0x002b00,6,
+0x002b80,3,
+0x002ba0,14,
+0x002be0,9,
+0x002c08,14,
+0x002c80,1,
+0x002c88,18,
+0x002d00,9,
+0x002d34,2,
+0x002d4c,4,
+0x002d6c,6,
+0x002d8c,8,
+0x002db0,1,
+0x002e00,2,
+0x002e0c,1,
+0x002e14,13,
+0x002e54,5,
+0x002e6c,7,
+0x002ea8,3,
+0x002ec0,8,
+0x002f00,6,
+0x002f80,3,
+0x002fa0,14,
+0x002fe0,9,
+0x003008,14,
+0x003080,1,
+0x003088,18,
+0x003100,9,
+0x003134,2,
+0x00314c,4,
+0x00316c,6,
+0x00318c,8,
+0x0031b0,1,
+0x003200,2,
+0x00320c,1,
+0x003214,13,
+0x003254,5,
+0x00326c,7,
+0x0032a8,3,
+0x0032c0,8,
+0x003300,6,
+0x003380,3,
+0x0033a0,14,
+0x0033e0,9,
+0x003408,14,
+0x003480,1,
+0x003488,18,
+0x003500,9,
+0x003534,2,
+0x00354c,4,
+0x00356c,6,
+0x00358c,8,
+0x0035b0,1,
+0x003600,2,
+0x00360c,1,
+0x003614,13,
+0x003654,5,
+0x00366c,7,
+0x0036a8,3,
+0x0036c0,8,
+0x003700,6,
+0x003780,3,
+0x0037a0,14,
+0x0037e0,9,
+0x003808,14,
+0x003880,1,
+0x003888,18,
+0x003900,9,
+0x003934,2,
+0x00394c,4,
+0x00396c,6,
+0x00398c,8,
+0x0039b0,1,
+0x003a00,2,
+0x003a0c,1,
+0x003a14,13,
+0x003a54,5,
+0x003a6c,7,
+0x003aa8,3,
+0x003ac0,8,
+0x003b00,6,
+0x003b80,3,
+0x003ba0,14,
+0x003be0,9,
+0x003c08,14,
+0x003c80,1,
+0x003c88,18,
+0x003d00,9,
+0x003d34,2,
+0x003d4c,4,
+0x003d6c,6,
+0x003d8c,8,
+0x003db0,1,
+0x003e00,2,
+0x003e0c,1,
+0x003e14,13,
+0x003e54,5,
+0x003e6c,7,
+0x003ea8,3,
+0x003ec0,8,
+0x003f00,6,
+0x003f80,3,
+0x003fa0,14,
+0x003fe0,9,
+0x004008,14,
+0x004080,1,
+0x004088,18,
+0x004100,9,
+0x004134,2,
+0x00414c,4,
+0x00416c,6,
+0x00418c,8,
+0x0041b0,1,
+0x004200,2,
+0x00420c,1,
+0x004214,13,
+0x004254,5,
+0x00426c,7,
+0x0042a8,3,
+0x0042c0,8,
+0x004300,6,
+0x004380,3,
+0x0043a0,14,
+0x0043e0,9,
+0x004408,14,
+0x004480,1,
+0x004488,18,
+0x004500,9,
+0x004534,2,
+0x00454c,4,
+0x00456c,6,
+0x00458c,8,
+0x0045b0,1,
+0x004600,2,
+0x00460c,1,
+0x004614,13,
+0x004654,5,
+0x00466c,7,
+0x0046a8,3,
+0x0046c0,8,
+0x004700,6,
+0x004780,3,
+0x0047a0,14,
+0x0047e0,9,
+0x004808,14,
+0x004880,1,
+0x004888,18,
+0x004900,9,
+0x004934,2,
+0x00494c,4,
+0x00496c,6,
+0x00498c,8,
+0x0049b0,1,
+0x004a00,2,
+0x004a0c,1,
+0x004a14,13,
+0x004a54,5,
+0x004a6c,7,
+0x004aa8,3,
+0x004ac0,8,
+0x004b00,6,
+0x004b80,3,
+0x004ba0,14,
+0x004be0,9,
+0x004c08,14,
+0x004c80,1,
+0x004c88,18,
+0x004d00,9,
+0x004d34,2,
+0x004d4c,4,
+0x004d6c,6,
+0x004d8c,8,
+0x004db0,1,
+0x004e00,2,
+0x004e0c,1,
+0x004e14,13,
+0x004e54,5,
+0x004e6c,7,
+0x004ea8,3,
+0x004ec0,8,
+0x004f00,6,
+0x004f80,3,
+0x004fa0,14,
+0x004fe0,9,
+0x005018,1,
+0x005034,1,
+0x00512c,1,
+0x005190,1,
+0x0051ac,1,
+0x0051d8,4,
+0x005200,8,
+0x005400,13,
+0x005460,3,
+0x005470,2,
+0x005504,2,
+0x005518,1,
+0x005540,1,
+0x008000,1,
+0x008008,14,
+0x008080,1,
+0x008088,18,
+0x008100,9,
+0x008134,2,
+0x00814c,4,
+0x00816c,6,
+0x00818c,8,
+0x0081b0,1,
+0x008200,2,
+0x00820c,1,
+0x008214,13,
+0x008254,5,
+0x00826c,7,
+0x0082a8,3,
+0x0082c0,8,
+0x008300,6,
+0x008380,3,
+0x0083a0,14,
+0x0083e0,9,
+0x008408,14,
+0x008480,1,
+0x008488,18,
+0x008500,9,
+0x008534,2,
+0x00854c,4,
+0x00856c,6,
+0x00858c,8,
+0x0085b0,1,
+0x008600,2,
+0x00860c,1,
+0x008614,13,
+0x008654,5,
+0x00866c,7,
+0x0086a8,3,
+0x0086c0,8,
+0x008700,6,
+0x008780,3,
+0x0087a0,14,
+0x0087e0,9,
+0x008808,14,
+0x008880,1,
+0x008888,18,
+0x008900,9,
+0x008934,2,
+0x00894c,4,
+0x00896c,6,
+0x00898c,8,
+0x0089b0,1,
+0x008a00,2,
+0x008a0c,1,
+0x008a14,13,
+0x008a54,5,
+0x008a6c,7,
+0x008aa8,3,
+0x008ac0,8,
+0x008b00,6,
+0x008b80,3,
+0x008ba0,14,
+0x008be0,9,
+0x008c08,14,
+0x008c80,1,
+0x008c88,18,
+0x008d00,9,
+0x008d34,2,
+0x008d4c,4,
+0x008d6c,6,
+0x008d8c,8,
+0x008db0,1,
+0x008e00,2,
+0x008e0c,1,
+0x008e14,13,
+0x008e54,5,
+0x008e6c,7,
+0x008ea8,3,
+0x008ec0,8,
+0x008f00,6,
+0x008f80,3,
+0x008fa0,14,
+0x008fe0,9,
+0x009008,14,
+0x009080,1,
+0x009088,18,
+0x009100,9,
+0x009134,2,
+0x00914c,4,
+0x00916c,6,
+0x00918c,8,
+0x0091b0,1,
+0x009200,2,
+0x00920c,1,
+0x009214,13,
+0x009254,5,
+0x00926c,7,
+0x0092a8,3,
+0x0092c0,8,
+0x009300,6,
+0x009380,3,
+0x0093a0,14,
+0x0093e0,9,
+0x009408,14,
+0x009480,1,
+0x009488,18,
+0x009500,9,
+0x009534,2,
+0x00954c,4,
+0x00956c,6,
+0x00958c,8,
+0x0095b0,1,
+0x009600,2,
+0x00960c,1,
+0x009614,13,
+0x009654,5,
+0x00966c,7,
+0x0096a8,3,
+0x0096c0,8,
+0x009700,6,
+0x009780,3,
+0x0097a0,14,
+0x0097e0,9,
+0x009808,14,
+0x009880,1,
+0x009888,18,
+0x009900,9,
+0x009934,2,
+0x00994c,4,
+0x00996c,6,
+0x00998c,8,
+0x0099b0,1,
+0x009a00,2,
+0x009a0c,1,
+0x009a14,13,
+0x009a54,5,
+0x009a6c,7,
+0x009aa8,3,
+0x009ac0,8,
+0x009b00,6,
+0x009b80,3,
+0x009ba0,14,
+0x009be0,9,
+0x009c08,14,
+0x009c80,1,
+0x009c88,18,
+0x009d00,9,
+0x009d34,2,
+0x009d4c,4,
+0x009d6c,6,
+0x009d8c,8,
+0x009db0,1,
+0x009e00,2,
+0x009e0c,1,
+0x009e14,13,
+0x009e54,5,
+0x009e6c,7,
+0x009ea8,3,
+0x009ec0,8,
+0x009f00,6,
+0x009f80,3,
+0x009fa0,14,
+0x009fe0,9,
+0x00a008,14,
+0x00a080,1,
+0x00a088,18,
+0x00a100,9,
+0x00a134,2,
+0x00a14c,4,
+0x00a16c,6,
+0x00a18c,8,
+0x00a1b0,1,
+0x00a200,2,
+0x00a20c,1,
+0x00a214,13,
+0x00a254,5,
+0x00a26c,7,
+0x00a2a8,3,
+0x00a2c0,8,
+0x00a300,6,
+0x00a380,3,
+0x00a3a0,14,
+0x00a3e0,9,
+0x00a408,14,
+0x00a480,1,
+0x00a488,18,
+0x00a500,9,
+0x00a534,2,
+0x00a54c,4,
+0x00a56c,6,
+0x00a58c,8,
+0x00a5b0,1,
+0x00a600,2,
+0x00a60c,1,
+0x00a614,13,
+0x00a654,5,
+0x00a66c,7,
+0x00a6a8,3,
+0x00a6c0,8,
+0x00a700,6,
+0x00a780,3,
+0x00a7a0,14,
+0x00a7e0,9,
+0x00a808,14,
+0x00a880,1,
+0x00a888,18,
+0x00a900,9,
+0x00a934,2,
+0x00a94c,4,
+0x00a96c,6,
+0x00a98c,8,
+0x00a9b0,1,
+0x00aa00,2,
+0x00aa0c,1,
+0x00aa14,13,
+0x00aa54,5,
+0x00aa6c,7,
+0x00aaa8,3,
+0x00aac0,8,
+0x00ab00,6,
+0x00ab80,3,
+0x00aba0,14,
+0x00abe0,9,
+0x00ac08,14,
+0x00ac80,1,
+0x00ac88,18,
+0x00ad00,9,
+0x00ad34,2,
+0x00ad4c,4,
+0x00ad6c,6,
+0x00ad8c,8,
+0x00adb0,1,
+0x00ae00,2,
+0x00ae0c,1,
+0x00ae14,13,
+0x00ae54,5,
+0x00ae6c,7,
+0x00aea8,3,
+0x00aec0,8,
+0x00af00,6,
+0x00af80,3,
+0x00afa0,14,
+0x00afe0,9,
+0x00b008,14,
+0x00b080,1,
+0x00b088,18,
+0x00b100,9,
+0x00b134,2,
+0x00b14c,4,
+0x00b16c,6,
+0x00b18c,8,
+0x00b1b0,1,
+0x00b200,2,
+0x00b20c,1,
+0x00b214,13,
+0x00b254,5,
+0x00b26c,7,
+0x00b2a8,3,
+0x00b2c0,8,
+0x00b300,6,
+0x00b380,3,
+0x00b3a0,14,
+0x00b3e0,9,
+0x00b408,14,
+0x00b480,1,
+0x00b488,18,
+0x00b500,9,
+0x00b534,2,
+0x00b54c,4,
+0x00b56c,6,
+0x00b58c,8,
+0x00b5b0,1,
+0x00b600,2,
+0x00b60c,1,
+0x00b614,13,
+0x00b654,5,
+0x00b66c,7,
+0x00b6a8,3,
+0x00b6c0,8,
+0x00b700,6,
+0x00b780,3,
+0x00b7a0,14,
+0x00b7e0,9,
+0x00b808,14,
+0x00b880,1,
+0x00b888,18,
+0x00b900,9,
+0x00b934,2,
+0x00b94c,4,
+0x00b96c,6,
+0x00b98c,8,
+0x00b9b0,1,
+0x00ba00,2,
+0x00ba0c,1,
+0x00ba14,13,
+0x00ba54,5,
+0x00ba6c,7,
+0x00baa8,3,
+0x00bac0,8,
+0x00bb00,6,
+0x00bb80,3,
+0x00bba0,14,
+0x00bbe0,9,
+0x00bc08,14,
+0x00bc80,1,
+0x00bc88,18,
+0x00bd00,9,
+0x00bd34,2,
+0x00bd4c,4,
+0x00bd6c,6,
+0x00bd8c,8,
+0x00bdb0,1,
+0x00be00,2,
+0x00be0c,1,
+0x00be14,13,
+0x00be54,5,
+0x00be6c,7,
+0x00bea8,3,
+0x00bec0,8,
+0x00bf00,6,
+0x00bf80,3,
+0x00bfa0,14,
+0x00bfe0,9,
+0x00c008,14,
+0x00c080,1,
+0x00c088,18,
+0x00c100,9,
+0x00c134,2,
+0x00c14c,4,
+0x00c16c,6,
+0x00c18c,8,
+0x00c1b0,1,
+0x00c200,2,
+0x00c20c,1,
+0x00c214,13,
+0x00c254,5,
+0x00c26c,7,
+0x00c2a8,3,
+0x00c2c0,8,
+0x00c300,6,
+0x00c380,3,
+0x00c3a0,14,
+0x00c3e0,9,
+0x00c408,14,
+0x00c480,1,
+0x00c488,18,
+0x00c500,9,
+0x00c534,2,
+0x00c54c,4,
+0x00c56c,6,
+0x00c58c,8,
+0x00c5b0,1,
+0x00c600,2,
+0x00c60c,1,
+0x00c614,13,
+0x00c654,5,
+0x00c66c,7,
+0x00c6a8,3,
+0x00c6c0,8,
+0x00c700,6,
+0x00c780,3,
+0x00c7a0,14,
+0x00c7e0,9,
+0x00c808,14,
+0x00c880,1,
+0x00c888,18,
+0x00c900,9,
+0x00c934,2,
+0x00c94c,4,
+0x00c96c,6,
+0x00c98c,8,
+0x00c9b0,1,
+0x00ca00,2,
+0x00ca0c,1,
+0x00ca14,13,
+0x00ca54,5,
+0x00ca6c,7,
+0x00caa8,3,
+0x00cac0,8,
+0x00cb00,6,
+0x00cb80,3,
+0x00cba0,14,
+0x00cbe0,9,
+0x00cc08,14,
+0x00cc80,1,
+0x00cc88,18,
+0x00cd00,9,
+0x00cd34,2,
+0x00cd4c,4,
+0x00cd6c,6,
+0x00cd8c,8,
+0x00cdb0,1,
+0x00ce00,2,
+0x00ce0c,1,
+0x00ce14,13,
+0x00ce54,5,
+0x00ce6c,7,
+0x00cea8,3,
+0x00cec0,8,
+0x00cf00,6,
+0x00cf80,3,
+0x00cfa0,14,
+0x00cfe0,9,
+0x00d018,1,
+0x00d034,1,
+0x00d12c,1,
+0x00d190,1,
+0x00d1ac,1,
+0x00d1d8,4,
+0x00d200,8,
+0x00d400,13,
+0x00d460,3,
+0x00d470,2,
+0x00d504,2,
+0x00d518,1,
+0x00d540,1,
+0x010000,1,
+0x010008,10,
+0x010034,16,
+0x010080,37,
+0x010128,2,
+0x010134,1,
+0x01013c,10,
+0x010168,4,
+0x01017c,3,
+0x01018c,10,
+0x0101c0,6,
+0x0101e0,1,
+0x010200,1,
+0x010208,10,
+0x010234,16,
+0x010280,37,
+0x010328,2,
+0x010334,1,
+0x01033c,10,
+0x010368,4,
+0x01037c,3,
+0x01038c,10,
+0x0103c0,6,
+0x0103e0,1,
+0x010400,1,
+0x010408,10,
+0x010434,16,
+0x010480,37,
+0x010528,2,
+0x010534,1,
+0x01053c,10,
+0x010568,4,
+0x01057c,3,
+0x01058c,10,
+0x0105c0,6,
+0x0105e0,1,
+0x010600,1,
+0x010608,10,
+0x010634,16,
+0x010680,37,
+0x010728,2,
+0x010734,1,
+0x01073c,10,
+0x010768,4,
+0x01077c,3,
+0x01078c,10,
+0x0107c0,6,
+0x0107e0,1,
+0x010800,1,
+0x010808,10,
+0x010834,16,
+0x010880,37,
+0x010928,2,
+0x010934,1,
+0x01093c,10,
+0x010968,4,
+0x01097c,3,
+0x01098c,10,
+0x0109c0,6,
+0x0109e0,1,
+0x010a00,1,
+0x010a08,10,
+0x010a34,16,
+0x010a80,37,
+0x010b28,2,
+0x010b34,1,
+0x010b3c,10,
+0x010b68,4,
+0x010b7c,3,
+0x010b8c,10,
+0x010bc0,6,
+0x010be0,1,
+0x010c00,1,
+0x010c08,10,
+0x010c34,16,
+0x010c80,37,
+0x010d28,2,
+0x010d34,1,
+0x010d3c,10,
+0x010d68,4,
+0x010d7c,3,
+0x010d8c,10,
+0x010dc0,6,
+0x010de0,1,
+0x010e00,1,
+0x010e08,10,
+0x010e34,16,
+0x010e80,37,
+0x010f28,2,
+0x010f34,1,
+0x010f3c,10,
+0x010f68,4,
+0x010f7c,3,
+0x010f8c,10,
+0x010fc0,6,
+0x010fe0,1,
+0x011000,1,
+0x011008,10,
+0x011034,16,
+0x011080,37,
+0x011128,2,
+0x011134,1,
+0x01113c,10,
+0x011168,4,
+0x01117c,3,
+0x01118c,10,
+0x0111c0,6,
+0x0111e0,1,
+0x011200,1,
+0x011208,10,
+0x011234,16,
+0x011280,37,
+0x011328,2,
+0x011334,1,
+0x01133c,10,
+0x011368,4,
+0x01137c,3,
+0x01138c,10,
+0x0113c0,6,
+0x0113e0,1,
+0x011400,1,
+0x011408,10,
+0x011434,16,
+0x011480,37,
+0x011528,2,
+0x011534,1,
+0x01153c,10,
+0x011568,4,
+0x01157c,3,
+0x01158c,10,
+0x0115c0,6,
+0x0115e0,1,
+0x011600,1,
+0x011608,10,
+0x011634,16,
+0x011680,37,
+0x011728,2,
+0x011734,1,
+0x01173c,10,
+0x011768,4,
+0x01177c,3,
+0x01178c,10,
+0x0117c0,6,
+0x0117e0,1,
+0x011800,1,
+0x011808,10,
+0x011834,16,
+0x011880,37,
+0x011928,2,
+0x011934,1,
+0x01193c,10,
+0x011968,4,
+0x01197c,3,
+0x01198c,10,
+0x0119c0,6,
+0x0119e0,1,
+0x011a00,1,
+0x011a08,10,
+0x011a34,16,
+0x011a80,37,
+0x011b28,2,
+0x011b34,1,
+0x011b3c,10,
+0x011b68,4,
+0x011b7c,3,
+0x011b8c,10,
+0x011bc0,6,
+0x011be0,1,
+0x011c00,1,
+0x011c08,10,
+0x011c34,16,
+0x011c80,37,
+0x011d28,2,
+0x011d34,1,
+0x011d3c,10,
+0x011d68,4,
+0x011d7c,3,
+0x011d8c,10,
+0x011dc0,6,
+0x011de0,1,
+0x011e00,1,
+0x011e08,10,
+0x011e34,16,
+0x011e80,37,
+0x011f28,2,
+0x011f34,1,
+0x011f3c,10,
+0x011f68,4,
+0x011f7c,3,
+0x011f8c,10,
+0x011fc0,6,
+0x011fe0,1,
+0x012000,1,
+0x012008,10,
+0x012034,16,
+0x012080,37,
+0x012128,2,
+0x012134,1,
+0x01213c,10,
+0x012168,4,
+0x01217c,3,
+0x01218c,10,
+0x0121c0,6,
+0x0121e0,1,
+0x012200,1,
+0x012208,10,
+0x012234,16,
+0x012280,37,
+0x012328,2,
+0x012334,1,
+0x01233c,10,
+0x012368,4,
+0x01237c,3,
+0x01238c,10,
+0x0123c0,6,
+0x0123e0,1,
+0x012800,2,
+0x01280c,37,
+0x0128a4,64,
+0x012a00,52,
+0x012ad4,2,
+0x012ae4,38,
+0x012bac,1,
+0x012bb4,1,
+0x012bbc,4,
+0x012bd0,2,
+0x012bdc,2,
+0x012c00,6,
+0x012c20,6,
+0x012c40,6,
+0x012c60,6,
+0x012c80,3,
+0x012d00,10,
+0x012d30,4,
+0x012e00,57,
+0x012f00,1,
+0x013000,3,
+0x013018,3,
+0x013034,3,
+0x01312c,6,
+0x013190,3,
+0x0131ac,1,
+0x0131d8,4,
+0x013200,24,
+0x013400,6,
+0x013420,3,
+0x013440,2,
+0x013500,13,
+0x013540,1,
+0x013900,1,
+0x014000,1,
+0x014008,10,
+0x014034,16,
+0x014080,37,
+0x014128,2,
+0x014134,1,
+0x01413c,10,
+0x014168,4,
+0x01417c,3,
+0x01418c,10,
+0x0141c0,6,
+0x0141e0,1,
+0x014200,1,
+0x014208,10,
+0x014234,16,
+0x014280,37,
+0x014328,2,
+0x014334,1,
+0x01433c,10,
+0x014368,4,
+0x01437c,3,
+0x01438c,10,
+0x0143c0,6,
+0x0143e0,1,
+0x014400,1,
+0x014408,10,
+0x014434,16,
+0x014480,37,
+0x014528,2,
+0x014534,1,
+0x01453c,10,
+0x014568,4,
+0x01457c,3,
+0x01458c,10,
+0x0145c0,6,
+0x0145e0,1,
+0x014600,1,
+0x014608,10,
+0x014634,16,
+0x014680,37,
+0x014728,2,
+0x014734,1,
+0x01473c,10,
+0x014768,4,
+0x01477c,3,
+0x01478c,10,
+0x0147c0,6,
+0x0147e0,1,
+0x014800,1,
+0x014808,10,
+0x014834,16,
+0x014880,37,
+0x014928,2,
+0x014934,1,
+0x01493c,10,
+0x014968,4,
+0x01497c,3,
+0x01498c,10,
+0x0149c0,6,
+0x0149e0,1,
+0x014a00,1,
+0x014a08,10,
+0x014a34,16,
+0x014a80,37,
+0x014b28,2,
+0x014b34,1,
+0x014b3c,10,
+0x014b68,4,
+0x014b7c,3,
+0x014b8c,10,
+0x014bc0,6,
+0x014be0,1,
+0x014c00,1,
+0x014c08,10,
+0x014c34,16,
+0x014c80,37,
+0x014d28,2,
+0x014d34,1,
+0x014d3c,10,
+0x014d68,4,
+0x014d7c,3,
+0x014d8c,10,
+0x014dc0,6,
+0x014de0,1,
+0x014e00,1,
+0x014e08,10,
+0x014e34,16,
+0x014e80,37,
+0x014f28,2,
+0x014f34,1,
+0x014f3c,10,
+0x014f68,4,
+0x014f7c,3,
+0x014f8c,10,
+0x014fc0,6,
+0x014fe0,1,
+0x015000,1,
+0x015008,10,
+0x015034,16,
+0x015080,37,
+0x015128,2,
+0x015134,1,
+0x01513c,10,
+0x015168,4,
+0x01517c,3,
+0x01518c,10,
+0x0151c0,6,
+0x0151e0,1,
+0x015200,1,
+0x015208,10,
+0x015234,16,
+0x015280,37,
+0x015328,2,
+0x015334,1,
+0x01533c,10,
+0x015368,4,
+0x01537c,3,
+0x01538c,10,
+0x0153c0,6,
+0x0153e0,1,
+0x015400,1,
+0x015408,10,
+0x015434,16,
+0x015480,37,
+0x015528,2,
+0x015534,1,
+0x01553c,10,
+0x015568,4,
+0x01557c,3,
+0x01558c,10,
+0x0155c0,6,
+0x0155e0,1,
+0x015600,1,
+0x015608,10,
+0x015634,16,
+0x015680,37,
+0x015728,2,
+0x015734,1,
+0x01573c,10,
+0x015768,4,
+0x01577c,3,
+0x01578c,10,
+0x0157c0,6,
+0x0157e0,1,
+0x015800,1,
+0x015808,10,
+0x015834,16,
+0x015880,37,
+0x015928,2,
+0x015934,1,
+0x01593c,10,
+0x015968,4,
+0x01597c,3,
+0x01598c,10,
+0x0159c0,6,
+0x0159e0,1,
+0x015a00,1,
+0x015a08,10,
+0x015a34,16,
+0x015a80,37,
+0x015b28,2,
+0x015b34,1,
+0x015b3c,10,
+0x015b68,4,
+0x015b7c,3,
+0x015b8c,10,
+0x015bc0,6,
+0x015be0,1,
+0x015c00,1,
+0x015c08,10,
+0x015c34,16,
+0x015c80,37,
+0x015d28,2,
+0x015d34,1,
+0x015d3c,10,
+0x015d68,4,
+0x015d7c,3,
+0x015d8c,10,
+0x015dc0,6,
+0x015de0,1,
+0x015e00,1,
+0x015e08,10,
+0x015e34,16,
+0x015e80,37,
+0x015f28,2,
+0x015f34,1,
+0x015f3c,10,
+0x015f68,4,
+0x015f7c,3,
+0x015f8c,10,
+0x015fc0,6,
+0x015fe0,1,
+0x016000,1,
+0x016008,10,
+0x016034,16,
+0x016080,37,
+0x016128,2,
+0x016134,1,
+0x01613c,10,
+0x016168,4,
+0x01617c,3,
+0x01618c,10,
+0x0161c0,6,
+0x0161e0,1,
+0x016200,1,
+0x016208,10,
+0x016234,16,
+0x016280,37,
+0x016328,2,
+0x016334,1,
+0x01633c,10,
+0x016368,4,
+0x01637c,3,
+0x01638c,10,
+0x0163c0,6,
+0x0163e0,1,
+0x016800,2,
+0x01680c,37,
+0x0168a4,64,
+0x016a00,52,
+0x016ad4,2,
+0x016ae4,38,
+0x016bac,1,
+0x016bb4,1,
+0x016bbc,4,
+0x016bd0,2,
+0x016bdc,2,
+0x016c00,6,
+0x016c20,6,
+0x016c40,6,
+0x016c60,6,
+0x016c80,3,
+0x016d00,10,
+0x016d30,4,
+0x016e00,57,
+0x016f00,1,
+0x017000,3,
+0x017018,3,
+0x017034,3,
+0x01712c,6,
+0x017190,3,
+0x0171ac,1,
+0x0171d8,4,
+0x017200,24,
+0x017400,6,
+0x017420,3,
+0x017440,2,
+0x017500,13,
+0x017540,1,
+0x017900,1,
+0x018000,6,
+0x018020,4,
+0x018040,6,
+0x018060,4,
+0x018080,6,
+0x0180a0,4,
+0x0180c0,6,
+0x0180e0,4,
+0x018100,6,
+0x018120,4,
+0x018140,6,
+0x018160,4,
+0x018180,6,
+0x0181a0,4,
+0x0181c0,6,
+0x0181e0,4,
+0x018200,6,
+0x018220,4,
+0x018240,6,
+0x018260,4,
+0x018280,6,
+0x0182a0,4,
+0x0182c0,6,
+0x0182e0,4,
+0x018300,6,
+0x018320,4,
+0x018340,6,
+0x018360,4,
+0x018380,6,
+0x0183a0,4,
+0x0183c0,6,
+0x0183e0,4,
+0x018400,6,
+0x018420,4,
+0x018440,6,
+0x018460,4,
+0x018480,6,
+0x0184a0,4,
+0x0184c0,6,
+0x0184e0,4,
+0x018500,6,
+0x018520,4,
+0x018540,6,
+0x018560,4,
+0x018580,6,
+0x0185a0,4,
+0x0185c0,6,
+0x0185e0,4,
+0x018600,6,
+0x018620,4,
+0x018640,6,
+0x018660,4,
+0x018680,6,
+0x0186a0,4,
+0x0186c0,6,
+0x0186e0,4,
+0x018700,6,
+0x018720,4,
+0x018740,6,
+0x018760,4,
+0x018780,6,
+0x0187a0,4,
+0x0187c0,6,
+0x0187e0,4,
+0x018800,6,
+0x018820,4,
+0x018840,6,
+0x018860,4,
+0x018880,6,
+0x0188a0,4,
+0x0188c0,6,
+0x0188e0,4,
+0x018900,6,
+0x018920,4,
+0x018940,6,
+0x018960,4,
+0x018980,6,
+0x0189a0,4,
+0x0189c0,6,
+0x0189e0,4,
+0x019000,7,
+0x019020,1,
+0x019040,7,
+0x019060,1,
+0x019080,7,
+0x0190a0,1,
+0x0190c0,7,
+0x0190e0,1,
+0x019100,7,
+0x019120,1,
+0x019140,7,
+0x019160,1,
+0x019180,7,
+0x0191a0,1,
+0x0191c0,7,
+0x0191e0,1,
+0x019200,7,
+0x019220,1,
+0x019240,7,
+0x019260,1,
+0x019280,7,
+0x0192a0,1,
+0x0192c0,7,
+0x0192e0,1,
+0x019300,7,
+0x019320,1,
+0x019340,7,
+0x019360,1,
+0x019380,7,
+0x0193a0,1,
+0x0193c0,7,
+0x0193e0,1,
+0x019400,7,
+0x019420,1,
+0x019440,7,
+0x019460,1,
+0x019480,7,
+0x0194a0,1,
+0x0194c0,7,
+0x0194e0,1,
+0x019500,7,
+0x019520,1,
+0x019540,7,
+0x019560,1,
+0x019580,7,
+0x0195a0,1,
+0x0195c0,7,
+0x0195e0,1,
+0x019600,7,
+0x019620,1,
+0x019640,7,
+0x019660,1,
+0x019680,7,
+0x0196a0,1,
+0x0196c0,7,
+0x0196e0,1,
+0x019700,7,
+0x019720,1,
+0x019740,7,
+0x019760,1,
+0x019780,7,
+0x0197a0,1,
+0x0197c0,7,
+0x0197e0,1,
+0x019800,7,
+0x019820,1,
+0x019840,7,
+0x019860,1,
+0x019880,7,
+0x0198a0,1,
+0x0198c0,7,
+0x0198e0,1,
+0x019900,6,
+0x019920,3,
+0x019980,3,
+0x0199ac,1,
+0x0199c0,3,
+0x0199d0,3,
+0x0199fc,5,
+0x019ff4,41,
+0x01a100,37,
+0x01a200,18,
+0x01b400,2,
+0x01c000,12,
+0x01c03c,13,
+0x01c07c,13,
+0x01c0bc,13,
+0x01c0fc,13,
+0x01c13c,13,
+0x01c17c,13,
+0x01c1bc,13,
+0x01c1fc,13,
+0x01c23c,13,
+0x01c27c,13,
+0x01c2bc,13,
+0x01c2fc,13,
+0x01c33c,13,
+0x01c37c,13,
+0x01c3bc,13,
+0x01c3fc,13,
+0x01c43c,13,
+0x01c47c,13,
+0x01c4bc,13,
+0x01c4fc,13,
+0x01c53c,13,
+0x01c57c,13,
+0x01c5bc,13,
+0x01c5fc,13,
+0x01c63c,13,
+0x01c67c,13,
+0x01c6bc,13,
+0x01c6fc,13,
+0x01c73c,13,
+0x01c77c,13,
+0x01c7bc,13,
+0x01c7fc,13,
+0x01c83c,13,
+0x01c87c,13,
+0x01c8bc,13,
+0x01c8fc,1,
+0x01ca00,2,
+0x01ca1c,3,
+0x01ca3c,3,
+0x01ca5c,3,
+0x01ca7c,3,
+0x01ca9c,3,
+0x01cabc,3,
+0x01cadc,3,
+0x01cafc,3,
+0x01cb1c,3,
+0x01cb3c,3,
+0x01cb5c,3,
+0x01cb7c,3,
+0x01cb9c,3,
+0x01cbbc,3,
+0x01cbdc,3,
+0x01cbfc,3,
+0x01cc1c,3,
+0x01cc3c,3,
+0x01cc5c,3,
+0x01cc7c,3,
+0x01cc9c,3,
+0x01ccbc,3,
+0x01ccdc,3,
+0x01ccfc,3,
+0x01cd1c,3,
+0x01cd3c,3,
+0x01cd5c,3,
+0x01cd7c,3,
+0x01cd9c,3,
+0x01cdbc,3,
+0x01cddc,3,
+0x01cdfc,3,
+0x01ce1c,3,
+0x01ce3c,3,
+0x01ce5c,3,
+0x01ce7c,14,
+0x01cec0,1,
+0x01f3ec,1,
+0x01f3fc,12,
+0x01f440,2,
+0x01f45c,1,
+0x01f800,4,
+0x01f818,4,
+0x01f834,4,
+0x01f92c,4,
+0x01f990,4,
+0x01f9ac,1,
+0x01f9d8,4,
+0x01fa00,32,
+0x01fc00,1,
+0x049000,7,
+0x049020,2,
+0x049030,20,
+0x0490b8,4,
+0x0490cc,7,
+0x049100,2,
+0x049110,1,
+0x049120,2,
+0x049140,1,
+0x049200,7,
+0x049220,2,
+0x049230,20,
+0x0492b8,4,
+0x0492cc,7,
+0x049300,2,
+0x049310,1,
+0x049320,2,
+0x049340,1,
+0x049400,7,
+0x049420,2,
+0x049430,20,
+0x0494b8,4,
+0x0494cc,7,
+0x049500,2,
+0x049510,1,
+0x049520,2,
+0x049540,1,
+0x049608,2,
+0x049620,1,
+0x049648,2,
+0x049660,1,
+0x049688,2,
+0x0496a0,1,
+0x0496c8,2,
+0x0496e0,1,
+0x049708,2,
+0x049720,1,
+0x049748,2,
+0x049760,1,
+0x049788,2,
+0x0497a0,1,
+0x0497c8,2,
+0x0497e0,1,
+0x049800,2,
+0x049820,1,
+0x049840,20,
+0x049904,7,
+0x049a00,21,
+0x049a60,2,
+0x050200,1,
+0x05020c,16,
+0x050260,1,
+0x0502a0,3,
+0x0502c0,16,
+0x0503bc,1,
+0x051800,162,
+0x051a90,2,
+0x051aa0,2,
+0x051c00,8,
+0x051d00,27,
+0x051d80,2,
+0x051d94,9,
+0x058400,12,
+0x058440,7,
+0x058460,2,
+0x058480,12,
+0x0584c0,7,
+0x0584e0,2,
+0x058500,6,
+0x058520,6,
+0x058540,3,
+0x058580,2,
+0x058590,9,
+0x0585e0,7,
+0x058600,7,
+0x058630,11,
+0x058670,19,
+0x058800,6,
+0x058820,6,
+0x058840,3,
+0x058900,6,
+0x060000,32,
+0x060200,64,
+0x060400,96,
+0x060600,2,
+0x060800,96,
+0x060a00,2,
+0x060c00,4,
+0x060fd8,3,
+0x060ff4,3,
+0x061040,8,
+0x061080,1,
+0x0610c0,39,
+0x061160,3,
+0x061200,1,
+0x061220,8,
+0x061300,3,
+0x061310,2,
+0x061320,2,
+0x061340,4,
+0x062000,17,
+0x062050,15,
+0x062090,1,
+0x062100,2,
+0x06210c,1,
+0x062114,1,
+0x06211c,5,
+0x063600,18,
+0x063650,9,
+0x063680,1,
+0x06368c,3,
+0x06369c,4,
+0x063700,1,
+0x063710,4,
+0x063800,16,
+0x063850,9,
+0x063880,1,
+0x06388c,3,
+0x06389c,4,
+0x06390c,7,
+0x063930,5,
+0x063948,2,
+0x0639fc,1,
+0x064000,5,
+0x064020,1,
+0x064030,1,
+0x064040,1,
+0x064050,1,
+0x064060,1,
+0x064070,1,
+0x064080,1,
+0x064090,1,
+0x0640a0,1,
+0x0640b0,1,
+0x0640c0,1,
+0x0640d0,1,
+0x0640e0,1,
+0x0640f0,1,
+0x064100,1,
+0x064110,1,
+0x064120,1,
+0x064130,1,
+0x064140,1,
+0x064150,1,
+0x064160,1,
+0x064170,1,
+0x064180,1,
+0x064190,1,
+0x0641a0,1,
+0x0641b0,1,
+0x0641c0,1,
+0x0641d0,1,
+0x0641e0,1,
+0x0641f0,1,
+0x064200,1,
+0x064210,1,
+0x064220,1,
+0x064230,1,
+0x064240,1,
+0x064250,1,
+0x064260,1,
+0x064270,1,
+0x064280,1,
+0x064290,1,
+0x0642a0,1,
+0x0642b0,1,
+0x0642c0,1,
+0x0642d0,1,
+0x0642e0,1,
+0x0642f0,1,
+0x064300,1,
+0x064310,1,
+0x064320,1,
+0x064330,1,
+0x064340,1,
+0x064350,1,
+0x064360,1,
+0x064370,1,
+0x064380,1,
+0x064390,1,
+0x0643a0,1,
+0x0643b0,1,
+0x0643c0,1,
+0x0643d0,1,
+0x0643e0,1,
+0x0643f0,1,
+0x064400,1,
+0x064410,1,
+0x064420,1,
+0x064430,1,
+0x064440,1,
+0x064450,1,
+0x064460,1,
+0x064470,1,
+0x064480,1,
+0x064490,1,
+0x0644a0,1,
+0x0644b0,1,
+0x0644c0,1,
+0x0644d0,1,
+0x0644e0,1,
+0x0644f0,1,
+0x064500,1,
+0x064510,1,
+0x064520,1,
+0x064530,1,
+0x064540,1,
+0x064550,1,
+0x064560,1,
+0x064570,1,
+0x064580,1,
+0x064590,1,
+0x0645a0,1,
+0x0645b0,1,
+0x0645c0,1,
+0x0645d0,1,
+0x0645e0,1,
+0x0645f0,1,
+0x064600,1,
+0x064610,1,
+0x064620,1,
+0x064630,1,
+0x064640,1,
+0x064650,1,
+0x064660,1,
+0x064670,1,
+0x064680,1,
+0x064690,1,
+0x0646a0,1,
+0x0646b0,1,
+0x0646c0,1,
+0x0646d0,1,
+0x0646e0,1,
+0x0646f0,1,
+0x064700,1,
+0x064710,1,
+0x064720,1,
+0x064730,1,
+0x064740,1,
+0x064750,1,
+0x064760,1,
+0x064770,1,
+0x064780,1,
+0x064790,1,
+0x0647a0,1,
+0x0647b0,1,
+0x0647c0,1,
+0x0647d0,1,
+0x0647e0,1,
+0x0647f0,1,
+0x064800,1,
+0x064810,1,
+0x064820,1,
+0x064830,1,
+0x064840,1,
+0x064850,1,
+0x064860,1,
+0x064870,1,
+0x064880,1,
+0x064890,1,
+0x0648a0,1,
+0x0648b0,1,
+0x0648c0,1,
+0x0648d0,1,
+0x0648e0,1,
+0x0648f0,1,
+0x064900,1,
+0x064910,1,
+0x064920,1,
+0x064930,1,
+0x064940,1,
+0x064950,1,
+0x064960,1,
+0x064970,1,
+0x064980,1,
+0x064990,1,
+0x0649a0,1,
+0x0649b0,1,
+0x0649c0,1,
+0x0649d0,1,
+0x0649e0,1,
+0x0649f0,1,
+0x064a00,1,
+0x064a10,1,
+0x064a20,1,
+0x064a30,1,
+0x064a40,1,
+0x064a50,1,
+0x064a60,1,
+0x064a70,1,
+0x064a80,1,
+0x064a90,1,
+0x064aa0,1,
+0x064ab0,1,
+0x064ac0,1,
+0x064ad0,1,
+0x064ae0,1,
+0x064af0,1,
+0x064b00,1,
+0x064b10,1,
+0x064b20,1,
+0x064b30,1,
+0x064b40,1,
+0x064b50,1,
+0x064b60,1,
+0x064b70,1,
+0x064b80,1,
+0x064b90,1,
+0x064ba0,1,
+0x064bb0,1,
+0x064bc0,1,
+0x064bd0,1,
+0x064be0,1,
+0x064bf0,1,
+0x064c00,1,
+0x064c10,1,
+0x064c20,1,
+0x064c30,1,
+0x064c40,1,
+0x064c50,1,
+0x064c60,1,
+0x064c70,1,
+0x064c80,1,
+0x064c90,1,
+0x064ca0,1,
+0x064cb0,1,
+0x064cc0,1,
+0x064cd0,1,
+0x064ce0,1,
+0x064cf0,1,
+0x064d00,1,
+0x064d10,1,
+0x064d20,1,
+0x064d30,1,
+0x064d40,1,
+0x064d50,1,
+0x064d60,1,
+0x064d70,1,
+0x064d80,1,
+0x064d90,1,
+0x064da0,1,
+0x064db0,1,
+0x064dc0,1,
+0x064dd0,1,
+0x064de0,1,
+0x064df0,1,
+0x064e00,1,
+0x064e10,1,
+0x064e20,1,
+0x064e30,1,
+0x064e40,1,
+0x064e50,1,
+0x064e60,1,
+0x064e70,1,
+0x064e80,1,
+0x064e90,1,
+0x064ea0,1,
+0x064eb0,1,
+0x064ec0,1,
+0x064ed0,1,
+0x064ee0,1,
+0x064ef0,1,
+0x064f00,1,
+0x064f10,1,
+0x064f20,1,
+0x064f30,1,
+0x064f40,1,
+0x064f50,1,
+0x064f60,1,
+0x064f70,1,
+0x064f80,1,
+0x064f90,1,
+0x064fa0,1,
+0x064fb0,1,
+0x064fc0,1,
+0x064fd0,1,
+0x064fe0,1,
+0x064ff0,1,
+0x065000,1,
+0x066000,5,
+0x066020,1,
+0x066030,1,
+0x066040,1,
+0x066050,1,
+0x066060,1,
+0x066070,1,
+0x066080,1,
+0x066090,1,
+0x0660a0,1,
+0x0660b0,1,
+0x0660c0,1,
+0x0660d0,1,
+0x0660e0,1,
+0x0660f0,1,
+0x066100,1,
+0x066110,1,
+0x066120,1,
+0x066130,1,
+0x066140,1,
+0x066150,1,
+0x066160,1,
+0x066170,1,
+0x066180,1,
+0x066190,1,
+0x0661a0,1,
+0x0661b0,1,
+0x0661c0,1,
+0x0661d0,1,
+0x0661e0,1,
+0x0661f0,1,
+0x066200,1,
+0x066210,1,
+0x066220,1,
+0x066230,1,
+0x066240,1,
+0x066250,1,
+0x066260,1,
+0x066270,1,
+0x066280,1,
+0x066290,1,
+0x0662a0,1,
+0x0662b0,1,
+0x0662c0,1,
+0x0662d0,1,
+0x0662e0,1,
+0x0662f0,1,
+0x066300,1,
+0x066310,1,
+0x066320,1,
+0x066330,1,
+0x066340,1,
+0x066350,1,
+0x066360,1,
+0x066370,1,
+0x066380,1,
+0x066390,1,
+0x0663a0,1,
+0x0663b0,1,
+0x0663c0,1,
+0x0663d0,1,
+0x0663e0,1,
+0x0663f0,1,
+0x066400,1,
+0x066410,1,
+0x066420,1,
+0x066430,1,
+0x066440,1,
+0x066450,1,
+0x066460,1,
+0x066470,1,
+0x066480,1,
+0x066490,1,
+0x0664a0,1,
+0x0664b0,1,
+0x0664c0,1,
+0x0664d0,1,
+0x0664e0,1,
+0x0664f0,1,
+0x066500,1,
+0x066510,1,
+0x066520,1,
+0x066530,1,
+0x066540,1,
+0x066550,1,
+0x066560,1,
+0x066570,1,
+0x066580,1,
+0x066590,1,
+0x0665a0,1,
+0x0665b0,1,
+0x0665c0,1,
+0x0665d0,1,
+0x0665e0,1,
+0x0665f0,1,
+0x066600,1,
+0x066610,1,
+0x066620,1,
+0x066630,1,
+0x066640,1,
+0x066650,1,
+0x066660,1,
+0x066670,1,
+0x066680,1,
+0x066690,1,
+0x0666a0,1,
+0x0666b0,1,
+0x0666c0,1,
+0x0666d0,1,
+0x0666e0,1,
+0x0666f0,1,
+0x066700,1,
+0x066710,1,
+0x066720,1,
+0x066730,1,
+0x066740,1,
+0x066750,1,
+0x066760,1,
+0x066770,1,
+0x066780,1,
+0x066790,1,
+0x0667a0,1,
+0x0667b0,1,
+0x0667c0,1,
+0x0667d0,1,
+0x0667e0,1,
+0x0667f0,1,
+0x066800,1,
+0x066810,1,
+0x066820,1,
+0x066830,1,
+0x066840,1,
+0x066850,1,
+0x066860,1,
+0x066870,1,
+0x066880,1,
+0x066890,1,
+0x0668a0,1,
+0x0668b0,1,
+0x0668c0,1,
+0x0668d0,1,
+0x0668e0,1,
+0x0668f0,1,
+0x066900,1,
+0x066910,1,
+0x066920,1,
+0x066930,1,
+0x066940,1,
+0x066950,1,
+0x066960,1,
+0x066970,1,
+0x066980,1,
+0x066990,1,
+0x0669a0,1,
+0x0669b0,1,
+0x0669c0,1,
+0x0669d0,1,
+0x0669e0,1,
+0x0669f0,1,
+0x066a00,1,
+0x066a10,1,
+0x066a20,1,
+0x066a30,1,
+0x066a40,1,
+0x066a50,1,
+0x066a60,1,
+0x066a70,1,
+0x066a80,1,
+0x066a90,1,
+0x066aa0,1,
+0x066ab0,1,
+0x066ac0,1,
+0x066ad0,1,
+0x066ae0,1,
+0x066af0,1,
+0x066b00,1,
+0x066b10,1,
+0x066b20,1,
+0x066b30,1,
+0x066b40,1,
+0x066b50,1,
+0x066b60,1,
+0x066b70,1,
+0x066b80,1,
+0x066b90,1,
+0x066ba0,1,
+0x066bb0,1,
+0x066bc0,1,
+0x066bd0,1,
+0x066be0,1,
+0x066bf0,1,
+0x066c00,1,
+0x066c10,1,
+0x066c20,1,
+0x066c30,1,
+0x066c40,1,
+0x066c50,1,
+0x066c60,1,
+0x066c70,1,
+0x066c80,1,
+0x066c90,1,
+0x066ca0,1,
+0x066cb0,1,
+0x066cc0,1,
+0x066cd0,1,
+0x066ce0,1,
+0x066cf0,1,
+0x066d00,1,
+0x066d10,1,
+0x066d20,1,
+0x066d30,1,
+0x066d40,1,
+0x066d50,1,
+0x066d60,1,
+0x066d70,1,
+0x066d80,1,
+0x066d90,1,
+0x066da0,1,
+0x066db0,1,
+0x066dc0,1,
+0x066dd0,1,
+0x066de0,1,
+0x066df0,1,
+0x066e00,1,
+0x066e10,1,
+0x066e20,1,
+0x066e30,1,
+0x066e40,1,
+0x066e50,1,
+0x066e60,1,
+0x066e70,1,
+0x066e80,1,
+0x066e90,1,
+0x066ea0,1,
+0x066eb0,1,
+0x066ec0,1,
+0x066ed0,1,
+0x066ee0,1,
+0x066ef0,1,
+0x066f00,1,
+0x066f10,1,
+0x066f20,1,
+0x066f30,1,
+0x066f40,1,
+0x066f50,1,
+0x066f60,1,
+0x066f70,1,
+0x066f80,1,
+0x066f90,1,
+0x066fa0,1,
+0x066fb0,1,
+0x066fc0,1,
+0x066fd0,1,
+0x066fe0,1,
+0x066ff0,1,
+0x067000,1,
+0x067020,1,
+0x067100,1,
+0x067200,3,
+0x0677f8,2,
+0x06f000,4,
+0x06f014,10,
+0x06f040,1,
+0x06f048,3,
+0x06f058,1,
+0x06f060,1,
+0x06f07c,1,
+0x06f500,1,
+0x06f518,2,
+0x06f540,6,
+0x070000,4,
+0x070020,9,
+0x070048,6,
+0x070064,6,
+0x070080,1,
+0x070200,33,
+0x070300,37,
+0x070b00,14,
+0x070b40,14,
+0x070b80,2,
+0x070c00,1,
+0x070c10,3,
+0x070c40,2,
+0x070c50,8,
+0x071000,7,
+0x072000,7,
+0x073000,114,
+0x0731d0,3,
+0x0731e0,3,
+0x0731f0,3,
+0x073200,5,
+0x073230,30,
+0x074000,8,
+0x074040,8,
+0x074800,2,
+0x07f000,2,
+0x07f018,2,
+0x07f034,2,
+0x07f12c,23,
+0x07f190,2,
+0x07f1ac,1,
+0x07f1d8,4,
+0x07f200,16,
+0x07fa00,6,
+0x07fb00,7,
+0x07fb20,7,
+0x07fb40,7,
+0x07fb60,1,
+0x07fc00,1,
+0x080000,32771,
+0x0a0010,7,
+0x0a0030,1,
+0x0a0038,2,
+0x0a0048,2,
+0x0a0058,2,
+0x0a0068,11,
+0x0a009c,2,
+0x0a00ac,14,
+0x0a00f0,1,
+0x0a00fc,35,
+0x0a01e0,1,
+0x0a01e8,5,
+0x0a0200,3,
+0x0a0210,7,
+0x0a0230,1,
+0x0a0238,2,
+0x0a0248,2,
+0x0a0258,2,
+0x0a0268,11,
+0x0a029c,2,
+0x0a02ac,14,
+0x0a02f0,1,
+0x0a02fc,35,
+0x0a03e0,1,
+0x0a03e8,5,
+0x0a0400,3,
+0x0a0410,7,
+0x0a0430,1,
+0x0a0438,2,
+0x0a0448,2,
+0x0a0458,2,
+0x0a0468,11,
+0x0a049c,2,
+0x0a04ac,14,
+0x0a04f0,1,
+0x0a04fc,35,
+0x0a05e0,1,
+0x0a05e8,5,
+0x0a0600,3,
+0x0a0610,7,
+0x0a0630,1,
+0x0a0638,2,
+0x0a0648,2,
+0x0a0658,2,
+0x0a0668,11,
+0x0a069c,2,
+0x0a06ac,14,
+0x0a06f0,1,
+0x0a06fc,35,
+0x0a07e0,1,
+0x0a07e8,5,
+0x0a0800,3,
+0x0a0810,7,
+0x0a0830,1,
+0x0a0838,2,
+0x0a0848,2,
+0x0a0858,2,
+0x0a0868,11,
+0x0a089c,2,
+0x0a08ac,14,
+0x0a08f0,1,
+0x0a08fc,35,
+0x0a09e0,1,
+0x0a09e8,5,
+0x0a0a00,3,
+0x0a0a10,7,
+0x0a0a30,1,
+0x0a0a38,2,
+0x0a0a48,2,
+0x0a0a58,2,
+0x0a0a68,11,
+0x0a0a9c,2,
+0x0a0aac,14,
+0x0a0af0,1,
+0x0a0afc,35,
+0x0a0be0,1,
+0x0a0be8,5,
+0x0a0c00,3,
+0x0a0c10,7,
+0x0a0c30,1,
+0x0a0c38,2,
+0x0a0c48,2,
+0x0a0c58,2,
+0x0a0c68,11,
+0x0a0c9c,2,
+0x0a0cac,14,
+0x0a0cf0,1,
+0x0a0cfc,35,
+0x0a0de0,1,
+0x0a0de8,5,
+0x0a0e00,3,
+0x0a0e10,7,
+0x0a0e30,1,
+0x0a0e38,2,
+0x0a0e48,2,
+0x0a0e58,2,
+0x0a0e68,11,
+0x0a0e9c,2,
+0x0a0eac,14,
+0x0a0ef0,1,
+0x0a0efc,35,
+0x0a0fe0,1,
+0x0a0fe8,5,
+0x0a1000,128,
+0x0a1208,2,
+0x0a1218,2,
+0x0a1404,17,
+0x0a1480,33,
+0x0a1540,16,
+0x0a15e0,8,
+0x0a1604,3,
+0x0a1700,33,
+0x0a1800,6,
+0x0a1820,1,
+0x0a1828,1,
+0x0a1830,4,
+0x0a1870,1,
+0x0a1c00,1,
+0x0a1c18,1,
+0x0a1c34,1,
+0x0a1d04,2,
+0x0a1d34,1,
+0x0a1d4c,1,
+0x0a1d70,2,
+0x0a1e00,8,
+0x0a2010,2,
+0x0a201c,1,
+0x0a2028,2,
+0x0a2040,8,
+0x0a2064,5,
+0x0a20f4,20,
+0x0a2150,20,
+0x0a2210,27,
+0x0a2280,3,
+0x0a2290,2,
+0x0a22a0,4,
+0x0a23fc,129,
+0x0a2800,4,
+0x0a2818,6,
+0x0a2838,6,
+0x0a2858,6,
+0x0a2878,5,
+0x0a2900,4,
+0x0a2918,6,
+0x0a2938,5,
+0x0a2980,4,
+0x0a2998,13,
+0x0a3120,48,
+0x0a3500,41,
+0x0a35c0,2,
+0x0a35d0,4,
+0x0a3604,2,
+0x0a3700,16,
+0x0c1000,1,
+0x0c1018,1,
+0x0c1034,1,
+0x0c112c,9,
+0x0c1190,1,
+0x0c11ac,1,
+0x0c11d8,4,
+0x0c1200,8,
+0x0c1400,6,
+0x0c1420,3,
+0x0c1500,5,
+0x0c1520,11,
+0x0c2000,13,
+0x0c2040,22,
+0x0c20a0,6,
+0x0c20c0,3,
+0x0c2100,9,
+0x0c2400,2,
+0x0c240c,6,
+0x0c2440,13,
+0x0c2480,16,
+0x0c2800,1,
+0x0c2808,3,
+0x0c281c,8,
+0x0c2840,3,
+0x0c2850,3,
+0x0c2880,1,
+0x0c2888,3,
+0x0c289c,8,
+0x0c28c0,3,
+0x0c28d0,3,
+0x0c2900,1,
+0x0c2908,3,
+0x0c291c,8,
+0x0c2940,3,
+0x0c2950,3,
+0x0c2980,1,
+0x0c2988,3,
+0x0c299c,8,
+0x0c29c0,3,
+0x0c29d0,3,
+0x0c2a00,1,
+0x0c2a08,3,
+0x0c2a1c,8,
+0x0c2a40,3,
+0x0c2a50,3,
+0x0c2a80,1,
+0x0c2a88,3,
+0x0c2a9c,8,
+0x0c2ac0,3,
+0x0c2ad0,3,
+0x0c2b00,1,
+0x0c2b08,3,
+0x0c2b1c,8,
+0x0c2b40,3,
+0x0c2b50,3,
+0x0c2b80,1,
+0x0c2b88,3,
+0x0c2b9c,8,
+0x0c2bc0,3,
+0x0c2bd0,3,
+0x0c2c00,1,
+0x0c2c08,3,
+0x0c2c1c,8,
+0x0c2c40,3,
+0x0c2c50,3,
+0x0c2c80,2,
+0x0c2c94,13,
+0x0c3000,4,
+0x0c3014,6,
+0x0c3030,5,
+0x0c3080,4,
+0x0c3094,6,
+0x0c30b0,5,
+0x0c3100,4,
+0x0c3114,6,
+0x0c3130,5,
+0x0c3180,4,
+0x0c3194,6,
+0x0c31b0,5,
+0x0c3200,3,
+0x0c3210,23,
+0x0c3500,3,
+0x0c3510,12,
+0x0c3580,3,
+0x0c3590,12,
+0x0c3600,3,
+0x0c3610,12,
+0x0c3680,3,
+0x0c3690,12,
+0x0c3700,4,
+0x0c3718,13,
+0x0c3800,25,
+0x0c3880,25,
+0x0c3900,25,
+0x0c3980,25,
+0x0c3a00,17,
+0x0c3a50,3,
+0x0c3a60,3,
+0x0c8000,25,
+0x0c8068,4,
+0x0c807c,4,
+0x0c80a0,3,
+0x0c80b0,2,
+0x0c80c8,6,
+0x0c8180,6,
+0x0ca000,3,
+0x0ca010,21,
+0x0ca068,14,
+0x0ca0a4,2,
+0x0ca0b0,2,
+0x0ca0c0,14,
+0x0ca100,16,
+0x0ca160,1,
+0x0ca184,1,
+0x0ca18c,1,
+0x0ca194,2,
+0x0ca1b8,3,
+0x0ca1d0,5,
+0x0ca1e8,3,
+0x0ca1f8,8,
+0x0ca220,6,
+0x0ca240,3,
+0x0ca280,6,
+0x0ca2a0,6,
+0x0ca2c0,3,
+0x0ca300,6,
+0x0ca320,6,
+0x0ca340,6,
+0x0ca360,6,
+0x0ca380,6,
+0x0ca3a0,6,
+0x0ca6fc,1,
+0x0ca800,71,
+0x0cb000,4,
+0x0cb044,1,
+0x0cb04c,1,
+0x0cb100,8,
+0x0cb1f0,6,
+0x0cb210,3,
+0x0cb220,2,
+0x0cb230,3,
+0x0cb240,2,
+0x0cb250,3,
+0x0cb260,2,
+0x0cb270,3,
+0x0cb400,5,
+0x0cb59c,1,
+0x0cb5ac,9,
+0x0d0000,5,
+0x0d0020,4,
+0x0d0034,9,
+0x0d005c,7,
+0x0d0080,1,
+0x0d00a0,6,
+0x0d0100,5,
+0x0d0120,4,
+0x0d0134,9,
+0x0d015c,7,
+0x0d0180,1,
+0x0d01a0,6,
+0x0d0200,5,
+0x0d0220,4,
+0x0d0234,9,
+0x0d025c,7,
+0x0d0280,1,
+0x0d02a0,6,
+0x0d0300,5,
+0x0d0320,4,
+0x0d0334,9,
+0x0d035c,7,
+0x0d0380,1,
+0x0d03a0,6,
+0x0d0400,4,
+0x0d0440,4,
+0x0d0480,3,
+0x0d04c0,3,
+0x0d0500,5,
+0x0d0518,8,
+0x0d0c00,13,
+0x0d0c40,11,
+0x0d0c80,13,
+0x0d0cc0,11,
+0x0d0d00,6,
+0x0d0d20,6,
+0x0d0e00,10,
+0x0d0e40,11,
+0x0d0e80,8,
+0x0d1000,2,
+0x0d1010,5,
+0x0d1040,3,
+0x0d1050,3,
+0x0d1060,7,
+0x0d1080,7,
+0x0d10a0,7,
+0x0d10c0,7,
+0x0d1100,7,
+0x0d1140,7,
+0x0d1180,5,
+0x0d119c,9,
+0x0d1218,9,
+0x0d1240,3,
+0x0d1250,6,
+0x0d1280,1,
+0x0d1288,6,
+0x0d12a4,1,
+0x0d12c0,1,
+0x0d12c8,6,
+0x0d12e4,1,
+0x0d1400,8,
+0x0d1424,2,
+0x0d1500,3,
+0x0d1520,4,
+0x0d1540,3,
+0x0d1560,4,
+0x0d1800,24,
+0x0d1864,2,
+0x0d1880,6,
+0x0d1900,12,
+0x0d1940,6,
+0x0d1960,6,
+0x0d1980,4,
+0x0d19c0,6,
+0x0d19dc,1,
+0x0d1a00,6,
+0x0d1a1c,1,
+0x0d1a40,1,
+0x0d1a68,23,
+0x0d1b00,17,
+0x0d1b80,12,
+0x0d2000,5,
+0x0d2020,4,
+0x0d2034,9,
+0x0d205c,7,
+0x0d2080,1,
+0x0d20a0,6,
+0x0d2100,5,
+0x0d2120,4,
+0x0d2134,9,
+0x0d215c,7,
+0x0d2180,1,
+0x0d21a0,6,
+0x0d2200,5,
+0x0d2220,4,
+0x0d2234,9,
+0x0d225c,7,
+0x0d2280,1,
+0x0d22a0,6,
+0x0d2300,5,
+0x0d2320,4,
+0x0d2334,9,
+0x0d235c,7,
+0x0d2380,1,
+0x0d23a0,6,
+0x0d2400,4,
+0x0d2440,4,
+0x0d2480,3,
+0x0d24c0,3,
+0x0d2500,5,
+0x0d2518,8,
+0x0d2c00,13,
+0x0d2c40,11,
+0x0d2c80,13,
+0x0d2cc0,11,
+0x0d2d00,6,
+0x0d2d20,6,
+0x0d2e00,10,
+0x0d2e40,11,
+0x0d2e80,8,
+0x0d3000,2,
+0x0d3010,5,
+0x0d3040,3,
+0x0d3050,3,
+0x0d3060,7,
+0x0d3080,7,
+0x0d30a0,7,
+0x0d30c0,7,
+0x0d3100,7,
+0x0d3140,7,
+0x0d3180,5,
+0x0d319c,9,
+0x0d3218,9,
+0x0d3240,3,
+0x0d3250,6,
+0x0d3280,1,
+0x0d3288,6,
+0x0d32a4,1,
+0x0d32c0,1,
+0x0d32c8,6,
+0x0d32e4,1,
+0x0d3400,8,
+0x0d3424,2,
+0x0d3500,3,
+0x0d3520,4,
+0x0d3540,3,
+0x0d3560,4,
+0x0d3800,24,
+0x0d3864,2,
+0x0d3880,6,
+0x0d3900,12,
+0x0d3940,6,
+0x0d3960,6,
+0x0d3980,4,
+0x0d39c0,6,
+0x0d39dc,1,
+0x0d3a00,6,
+0x0d3a1c,1,
+0x0d3a40,1,
+0x0d3a68,23,
+0x0d3b00,17,
+0x0d3b80,12,
+0x0d4000,5,
+0x0d4038,1,
+0x0d4044,1,
+0x0d4100,6,
+0x0d8000,6,
+0x0d8020,3,
+0x0d8030,9,
+0x0d8080,6,
+0x0d8100,20,
+0x0d8400,1,
+0x0d8418,1,
+0x0d8434,1,
+0x0d852c,4,
+0x0d8590,1,
+0x0d85ac,1,
+0x0d85d8,4,
+0x0d8600,8,
+0x0d9000,6,
+0x0d9020,6,
+0x0d9040,3,
+0x0d9080,14,
+0x0d90bc,1,
+0x0d90c4,13,
+0x0d90fc,6,
+0x0d9120,5,
+0x0d9190,10,
+0x0d9200,16,
+0x0d9244,32,
+0x0d9300,26,
+0x0d9380,2,
+0x0d93a0,1,
+0x0d93c0,11,
+0x0d9404,4,
+0x0d9418,16,
+0x0d9460,3,
+0x0d9500,6,
+0x0d9540,1,
+0x0d9558,2,
+0x0d9600,17,
+0x0d9800,366,
+0x0da000,6,
+0x0da020,6,
+0x0da040,3,
+0x0da080,14,
+0x0da0bc,1,
+0x0da0c4,13,
+0x0da0fc,6,
+0x0da120,5,
+0x0da190,10,
+0x0da200,16,
+0x0da244,32,
+0x0da300,26,
+0x0da380,2,
+0x0da3a0,1,
+0x0da3c0,11,
+0x0da404,4,
+0x0da418,16,
+0x0da460,3,
+0x0da500,6,
+0x0da540,1,
+0x0da558,2,
+0x0da600,17,
+0x0da800,366,
+0x0db000,4,
+0x0db020,9,
+0x0db048,6,
+0x0db064,6,
+0x0db080,1,
+0x0db100,4,
+0x0db120,9,
+0x0db148,6,
+0x0db164,6,
+0x0db180,1,
+0x0db200,35,
+0x0db290,6,
+0x0db2b4,6,
+0x0db2d0,5,
+0x0db2e8,5,
+0x0db300,37,
+0x0db400,6,
+0x0db420,3,
+0x0db438,4,
+0x0db454,3,
+0x0db478,4,
+0x0db494,3,
+0x0db800,5,
+0x0db818,1,
+0x0db854,6,
+0x0db880,2,
+0x0db8a4,1,
+0x0e8000,4,
+0x0e8058,3,
+0x0e8120,2,
+0x0e8130,2,
+0x0e8140,1,
+0x0e8184,11,
+0x0e81c4,3,
+0x0e81dc,3,
+0x0e8280,13,
+0x0e8400,24,
+0x0e8500,4,
+0x0e8800,2,
+0x0e8824,9,
+0x0e884c,27,
+0x0e88d4,2,
+0x0e8c00,1,
+0x0e8c08,3,
+0x0e8c80,20,
+0x0e8d00,3,
+0x0e8d20,6,
+0x0e8d80,4,
+0x0e8da0,6,
+0x0e8dbc,7,
+0x0e8e00,21,
+0x0e8e80,6,
+0x0e8ea0,6,
+0x0e8ec0,3,
+0x0e9000,35,
+0x0e9090,2,
+0x0e90f0,1,
+0x0e90f8,1,
+0x0e9100,1,
+0x0e9108,5,
+0x0e9138,4,
+0x0e9160,13,
+0x0e91a0,3,
+0x0e9200,2,
+0x0e9214,19,
+0x0e9278,10,
+0x0e9310,1,
+0x0e9340,4,
+0x0e9384,6,
+0x0e9400,14,
+0x0e9440,10,
+0x0e947c,1,
+0x0e9700,2,
+0x0e9720,8,
+0x0e9800,3,
+0x0e9810,3,
+0x0e9820,3,
+0x0e9830,3,
+0x0e9840,3,
+0x0e9850,3,
+0x0e9860,3,
+0x0e9870,3,
+0x0e9880,3,
+0x0e9890,3,
+0x0e98a0,3,
+0x0e98b0,3,
+0x0e98c0,3,
+0x0e98d0,3,
+0x0e98e0,3,
+0x0e98f0,3,
+0x0e9900,68,
+0x0e9c00,36,
+0x0e9d00,3,
+0x0e9d40,2,
+0x0e9d4c,1,
+0x0e9d80,2,
+0x0e9d90,4,
+0x0e9e00,6,
+0x0e9e20,6,
+0x0e9e40,6,
+0x0e9e60,3,
+0x0e9e80,6,
+0x0e9ea0,3,
+0x0e9f80,13,
+0x0e9fc0,2,
+0x0ea000,1,
+0x0ea018,1,
+0x0ea034,1,
+0x0ea12c,3,
+0x0ea190,1,
+0x0ea1ac,1,
+0x0ea1d8,4,
+0x0ea200,8,
+0x0ea400,6,
+0x0ea420,24,
+0x0ea490,24,
+0x0ea520,8,
+0x0ea600,2,
+0x0ea6f0,71,
+0x0f0000,3,
+0x0f0014,8,
+0x0f0044,28,
+0x0f00f0,2,
+0x0f0100,5,
+0x0f0118,1,
+0x0f0130,6,
+0x0f015c,12,
+0x0f0190,3,
+0x0f01a0,3,
+0x0f01c0,2,
+0x0f01d0,10,
+0x0f0200,61,
+0x0f0404,8,
+0x0f0440,12,
+0x0f0480,6,
+0x0f04a0,8,
+0x0f04e0,6,
+0x0f0500,6,
+0x0f0520,8,
+0x0f0560,6,
+0x0f0580,1,
+0x0f0588,3,
+0x0f05dc,9,
+0x0f0800,17,
+0x0f0850,9,
+0x0f0880,9,
+0x0f08b0,9,
+0x0f08e0,9,
+0x0f0920,4,
+0x0f093c,5,
+0x0f095c,5,
+0x0f097c,5,
+0x0f099c,5,
+0x0f09bc,5,
+0x0f09dc,1,
+0x0f0a80,3,
+0x0f0a90,4,
+0x0f0c00,128,
+0x0f0e04,1,
+0x0f0e14,9,
+0x0f0e3c,1,
+0x0f1000,1,
+0x0f1200,6,
+0x0f1220,6,
+0x0f1240,6,
+0x0f1260,6,
+0x0f1280,6,
+0x0f12a0,6,
+0x0f12c0,6,
+0x0f12e0,6,
+0x0f1300,3,
+0x0f4000,7,
+0x0f4100,2,
+0x0f4180,34,
+0x0f4300,2,
+0x0f4380,42,
+0x0f4800,7,
+0x0f4900,2,
+0x0f4980,34,
+0x0f4b00,2,
+0x0f4b80,42,
+0x0f5000,7,
+0x0f5100,2,
+0x0f5180,34,
+0x0f5300,2,
+0x0f5380,42,
+0x0f5800,7,
+0x0f5900,2,
+0x0f5980,34,
+0x0f5b00,2,
+0x0f5b80,42,
+0x0f6000,7,
+0x0f6100,2,
+0x0f6180,34,
+0x0f6300,2,
+0x0f6380,42,
+0x0f6800,7,
+0x0f6900,2,
+0x0f6980,34,
+0x0f6b00,2,
+0x0f6b80,42,
+0x0f8000,9,
+0x0f8044,6,
+0x0f8080,7,
+0x0f80a0,1,
+0x0f80c0,12,
+0x0f8100,9,
+0x0f8144,6,
+0x0f8180,7,
+0x0f81a0,1,
+0x0f81c0,12,
+0x0f8200,9,
+0x0f8244,6,
+0x0f8280,7,
+0x0f82a0,1,
+0x0f82c0,12,
+0x0f8300,9,
+0x0f8344,6,
+0x0f8380,7,
+0x0f83a0,1,
+0x0f83c0,12,
+0x0f8400,9,
+0x0f8444,6,
+0x0f8480,7,
+0x0f84a0,1,
+0x0f84c0,12,
+0x0f8500,9,
+0x0f8544,6,
+0x0f8580,7,
+0x0f85a0,1,
+0x0f85c0,12,
+0x0f8600,9,
+0x0f8644,6,
+0x0f8680,7,
+0x0f86a0,1,
+0x0f86c0,12,
+0x0f8700,9,
+0x0f8744,6,
+0x0f8780,7,
+0x0f87a0,1,
+0x0f87c0,12,
+0x0f8800,9,
+0x0f8844,6,
+0x0f8880,7,
+0x0f88a0,1,
+0x0f88c0,12,
+0x0f8900,9,
+0x0f8944,6,
+0x0f8980,7,
+0x0f89a0,1,
+0x0f89c0,12,
+0x0f8a00,9,
+0x0f8a44,6,
+0x0f8a80,7,
+0x0f8aa0,1,
+0x0f8ac0,12,
+0x0f8b00,9,
+0x0f8b44,6,
+0x0f8b80,7,
+0x0f8ba0,1,
+0x0f8bc0,12,
+0x0f8c00,9,
+0x0f8c44,6,
+0x0f8c80,7,
+0x0f8ca0,1,
+0x0f8cc0,12,
+0x0f8d00,9,
+0x0f8d44,6,
+0x0f8d80,7,
+0x0f8da0,1,
+0x0f8dc0,12,
+0x0f8e00,9,
+0x0f8e44,6,
+0x0f8e80,7,
+0x0f8ea0,1,
+0x0f8ec0,12,
+0x0f8f00,9,
+0x0f8f44,6,
+0x0f8f80,7,
+0x0f8fa0,1,
+0x0f8fc0,12,
+0x0f9000,9,
+0x0f9044,6,
+0x0f9080,7,
+0x0f90a0,1,
+0x0f90c0,12,
+0x0f9100,9,
+0x0f9144,6,
+0x0f9180,7,
+0x0f91a0,1,
+0x0f91c0,12,
+0x0f9200,9,
+0x0f9244,6,
+0x0f9280,7,
+0x0f92a0,1,
+0x0f92c0,12,
+0x0f9300,9,
+0x0f9344,6,
+0x0f9380,7,
+0x0f93a0,1,
+0x0f93c0,12,
+0x0f9400,9,
+0x0f9444,6,
+0x0f9480,7,
+0x0f94a0,1,
+0x0f94c0,12,
+0x0f9500,9,
+0x0f9544,6,
+0x0f9580,7,
+0x0f95a0,1,
+0x0f95c0,12,
+0x0f9600,9,
+0x0f9644,6,
+0x0f9680,7,
+0x0f96a0,1,
+0x0f96c0,12,
+0x0f9700,9,
+0x0f9744,6,
+0x0f9780,7,
+0x0f97a0,1,
+0x0f97c0,12,
+0x100000,6,
+0x100080,9,
+0x100100,6,
+0x100180,9,
+0x100200,9,
+0x100240,24,
+0x100300,2,
+0x101000,6,
+0x101080,9,
+0x101100,6,
+0x101180,9,
+0x101200,9,
+0x101240,24,
+0x101300,2,
+0x102000,6,
+0x102080,9,
+0x102100,6,
+0x102180,9,
+0x102200,9,
+0x102240,24,
+0x102300,2,
+0x103000,6,
+0x103080,9,
+0x103100,6,
+0x103180,9,
+0x103200,9,
+0x103240,24,
+0x103300,2,
+0x104000,6,
+0x104080,9,
+0x104100,6,
+0x104180,9,
+0x104200,9,
+0x104240,24,
+0x104300,2,
+0x105000,6,
+0x105080,9,
+0x105100,6,
+0x105180,9,
+0x105200,9,
+0x105240,24,
+0x105300,2,
+0x106000,6,
+0x106080,9,
+0x106100,6,
+0x106180,9,
+0x106200,9,
+0x106240,24,
+0x106300,2,
+0x107000,6,
+0x107080,9,
+0x107100,6,
+0x107180,9,
+0x107200,9,
+0x107240,24,
+0x107300,2,
+0x108000,6,
+0x108080,9,
+0x108100,6,
+0x108180,9,
+0x108200,9,
+0x108240,24,
+0x108300,2,
+0x109000,6,
+0x109080,9,
+0x109100,6,
+0x109180,9,
+0x109200,9,
+0x109240,24,
+0x109300,2,
+0x114000,5,
+0x114018,3,
+0x114028,3,
+0x114038,3,
+0x114048,3,
+0x114058,3,
+0x114068,3,
+0x114078,3,
+0x114088,12,
+0x1140c8,13,
+0x114100,25,
+0x114180,9,
+0x1141c0,3,
+0x1141d0,3,
+0x114400,5,
+0x114418,5,
+0x114434,5,
+0x11452c,3,
+0x114590,5,
+0x1145ac,1,
+0x1145d8,4,
+0x114600,40,
+0x114900,6,
+0x114920,26,
+0x114c00,20,
+0x114c60,2,
+0x114c70,10,
+0x114d00,9,
+0x114d30,7,
+0x114e00,64,
+0x115000,1,
+0x140000,6,
+0x140080,9,
+0x140100,6,
+0x140180,9,
+0x140200,9,
+0x140240,24,
+0x140300,2,
+0x141000,6,
+0x141080,9,
+0x141100,6,
+0x141180,9,
+0x141200,9,
+0x141240,24,
+0x141300,2,
+0x142000,6,
+0x142080,9,
+0x142100,6,
+0x142180,9,
+0x142200,9,
+0x142240,24,
+0x142300,2,
+0x143000,6,
+0x143080,9,
+0x143100,6,
+0x143180,9,
+0x143200,9,
+0x143240,24,
+0x143300,2,
+0x144000,6,
+0x144080,9,
+0x144100,6,
+0x144180,9,
+0x144200,9,
+0x144240,24,
+0x144300,2,
+0x145000,6,
+0x145080,9,
+0x145100,6,
+0x145180,9,
+0x145200,9,
+0x145240,24,
+0x145300,2,
+0x146000,6,
+0x146080,9,
+0x146100,6,
+0x146180,9,
+0x146200,9,
+0x146240,24,
+0x146300,2,
+0x147000,6,
+0x147080,9,
+0x147100,6,
+0x147180,9,
+0x147200,9,
+0x147240,24,
+0x147300,2,
+0x148000,6,
+0x148080,9,
+0x148100,6,
+0x148180,9,
+0x148200,9,
+0x148240,24,
+0x148300,2,
+0x149000,6,
+0x149080,9,
+0x149100,6,
+0x149180,9,
+0x149200,9,
+0x149240,24,
+0x149300,2,
+0x154000,5,
+0x154018,3,
+0x154028,3,
+0x154038,3,
+0x154048,3,
+0x154058,3,
+0x154068,3,
+0x154078,3,
+0x154088,12,
+0x1540c8,13,
+0x154100,25,
+0x154180,9,
+0x1541c0,3,
+0x1541d0,3,
+0x154400,5,
+0x154418,5,
+0x154434,5,
+0x15452c,3,
+0x154590,5,
+0x1545ac,1,
+0x1545d8,4,
+0x154600,40,
+0x154900,6,
+0x154920,26,
+0x154c00,20,
+0x154c60,2,
+0x154c70,10,
+0x154d00,9,
+0x154d30,7,
+0x154e00,64,
+0x155000,1,
+0x180000,6,
+0x180020,6,
+0x180040,6,
+0x180060,6,
+0x180080,6,
+0x1800a0,6,
+0x1800c0,3,
+0x180100,1,
+0x180110,1,
+0x200000,5,
+0x200020,4,
+0x200034,9,
+0x20005c,7,
+0x200080,1,
+0x2000a0,6,
+0x200100,5,
+0x200120,4,
+0x200134,9,
+0x20015c,7,
+0x200180,1,
+0x2001a0,6,
+0x200200,5,
+0x200220,4,
+0x200234,9,
+0x20025c,7,
+0x200280,1,
+0x2002a0,6,
+0x200300,5,
+0x200320,4,
+0x200334,9,
+0x20035c,7,
+0x200380,1,
+0x2003a0,6,
+0x200400,4,
+0x200440,4,
+0x200480,3,
+0x2004c0,3,
+0x200500,5,
+0x200518,8,
+0x200c00,13,
+0x200c40,11,
+0x200c80,13,
+0x200cc0,11,
+0x200d00,6,
+0x200d20,6,
+0x200e00,10,
+0x200e40,11,
+0x200e80,8,
+0x201000,2,
+0x201010,5,
+0x201040,3,
+0x201050,3,
+0x201060,7,
+0x201080,7,
+0x2010a0,7,
+0x2010c0,7,
+0x201100,7,
+0x201140,7,
+0x201180,5,
+0x20119c,9,
+0x201218,9,
+0x201240,3,
+0x201250,6,
+0x201280,1,
+0x201288,6,
+0x2012a4,1,
+0x2012c0,1,
+0x2012c8,6,
+0x2012e4,1,
+0x201400,8,
+0x201424,2,
+0x201500,3,
+0x201520,4,
+0x201540,3,
+0x201560,4,
+0x201800,24,
+0x201864,2,
+0x201880,6,
+0x201900,12,
+0x201940,6,
+0x201960,6,
+0x201980,4,
+0x2019c0,6,
+0x2019dc,1,
+0x201a00,6,
+0x201a1c,1,
+0x201a40,1,
+0x201a68,23,
+0x201b00,17,
+0x201b80,12,
+0x202000,5,
+0x202020,4,
+0x202034,9,
+0x20205c,7,
+0x202080,1,
+0x2020a0,6,
+0x202100,5,
+0x202120,4,
+0x202134,9,
+0x20215c,7,
+0x202180,1,
+0x2021a0,6,
+0x202200,5,
+0x202220,4,
+0x202234,9,
+0x20225c,7,
+0x202280,1,
+0x2022a0,6,
+0x202300,5,
+0x202320,4,
+0x202334,9,
+0x20235c,7,
+0x202380,1,
+0x2023a0,6,
+0x202400,4,
+0x202440,4,
+0x202480,3,
+0x2024c0,3,
+0x202500,5,
+0x202518,8,
+0x202c00,13,
+0x202c40,11,
+0x202c80,13,
+0x202cc0,11,
+0x202d00,6,
+0x202d20,6,
+0x202e00,10,
+0x202e40,11,
+0x202e80,8,
+0x203000,2,
+0x203010,5,
+0x203040,3,
+0x203050,3,
+0x203060,7,
+0x203080,7,
+0x2030a0,7,
+0x2030c0,7,
+0x203100,7,
+0x203140,7,
+0x203180,5,
+0x20319c,9,
+0x203218,9,
+0x203240,3,
+0x203250,6,
+0x203280,1,
+0x203288,6,
+0x2032a4,1,
+0x2032c0,1,
+0x2032c8,6,
+0x2032e4,1,
+0x203400,8,
+0x203424,2,
+0x203500,3,
+0x203520,4,
+0x203540,3,
+0x203560,4,
+0x203800,24,
+0x203864,2,
+0x203880,6,
+0x203900,12,
+0x203940,6,
+0x203960,6,
+0x203980,4,
+0x2039c0,6,
+0x2039dc,1,
+0x203a00,6,
+0x203a1c,1,
+0x203a40,1,
+0x203a68,23,
+0x203b00,17,
+0x203b80,12,
+0x204000,4,
+0x204014,6,
+0x204030,5,
+0x204080,4,
+0x204094,6,
+0x2040b0,5,
+0x204100,4,
+0x204114,6,
+0x204130,5,
+0x204180,4,
+0x204194,6,
+0x2041b0,5,
+0x204200,3,
+0x204210,23,
+0x204500,3,
+0x204510,12,
+0x204580,3,
+0x204590,12,
+0x204600,3,
+0x204610,12,
+0x204680,3,
+0x204690,12,
+0x204700,4,
+0x204718,13,
+0x204800,25,
+0x204880,25,
+0x204900,25,
+0x204980,25,
+0x204a00,17,
+0x204a50,3,
+0x204a60,3,
+0x205000,4,
+0x205014,6,
+0x205030,5,
+0x205080,4,
+0x205094,6,
+0x2050b0,5,
+0x205100,4,
+0x205114,6,
+0x205130,5,
+0x205180,4,
+0x205194,6,
+0x2051b0,5,
+0x205200,3,
+0x205210,23,
+0x205500,3,
+0x205510,12,
+0x205580,3,
+0x205590,12,
+0x205600,3,
+0x205610,12,
+0x205680,3,
+0x205690,12,
+0x205700,4,
+0x205718,13,
+0x205800,25,
+0x205880,25,
+0x205900,25,
+0x205980,25,
+0x205a00,17,
+0x205a50,3,
+0x205a60,3,
+0x206000,13,
+0x206040,22,
+0x2060a0,6,
+0x2060c0,3,
+0x206100,9,
+0x206400,2,
+0x20640c,6,
+0x206440,13,
+0x206480,16,
+0x206800,1,
+0x206808,3,
+0x20681c,8,
+0x206840,3,
+0x206850,3,
+0x206880,1,
+0x206888,3,
+0x20689c,8,
+0x2068c0,3,
+0x2068d0,3,
+0x206900,1,
+0x206908,3,
+0x20691c,8,
+0x206940,3,
+0x206950,3,
+0x206980,1,
+0x206988,3,
+0x20699c,8,
+0x2069c0,3,
+0x2069d0,3,
+0x206a00,1,
+0x206a08,3,
+0x206a1c,8,
+0x206a40,3,
+0x206a50,3,
+0x206a80,1,
+0x206a88,3,
+0x206a9c,8,
+0x206ac0,3,
+0x206ad0,3,
+0x206b00,1,
+0x206b08,3,
+0x206b1c,8,
+0x206b40,3,
+0x206b50,3,
+0x206b80,1,
+0x206b88,3,
+0x206b9c,8,
+0x206bc0,3,
+0x206bd0,3,
+0x206c00,1,
+0x206c08,3,
+0x206c1c,8,
+0x206c40,3,
+0x206c50,3,
+0x206c80,2,
+0x206c94,13,
+0x207000,6,
+0x207020,3,
+0x207034,1,
+0x207040,7,
+0x207060,6,
+0x207100,5,
+0x207138,1,
+0x207144,1,
+0x207400,1,
+0x207418,1,
+0x207434,1,
+0x20752c,5,
+0x207590,1,
+0x2075ac,1,
+0x2075d8,4,
+0x207600,8,
+0x208000,6,
+0x208020,3,
+0x208030,9,
+0x208080,6,
+0x208100,20,
+0x208400,1,
+0x208418,1,
+0x208434,1,
+0x20852c,4,
+0x208590,1,
+0x2085ac,1,
+0x2085d8,4,
+0x208600,8,
+0x209000,6,
+0x209020,6,
+0x209040,3,
+0x209080,14,
+0x2090bc,1,
+0x2090c4,13,
+0x2090fc,6,
+0x209120,5,
+0x209190,10,
+0x209200,16,
+0x209244,32,
+0x209300,26,
+0x209380,2,
+0x2093a0,1,
+0x2093c0,11,
+0x209404,4,
+0x209418,16,
+0x209460,3,
+0x209500,6,
+0x209540,1,
+0x209558,2,
+0x209600,17,
+0x209800,366,
+0x20a000,6,
+0x20a020,6,
+0x20a040,3,
+0x20a080,14,
+0x20a0bc,1,
+0x20a0c4,13,
+0x20a0fc,6,
+0x20a120,5,
+0x20a190,10,
+0x20a200,16,
+0x20a244,32,
+0x20a300,26,
+0x20a380,2,
+0x20a3a0,1,
+0x20a3c0,11,
+0x20a404,4,
+0x20a418,16,
+0x20a460,3,
+0x20a500,6,
+0x20a540,1,
+0x20a558,2,
+0x20a600,17,
+0x20a800,366,
+0x20b000,4,
+0x20b020,9,
+0x20b048,6,
+0x20b064,6,
+0x20b080,1,
+0x20b100,4,
+0x20b120,9,
+0x20b148,6,
+0x20b164,6,
+0x20b180,1,
+0x20b200,35,
+0x20b290,6,
+0x20b2b4,6,
+0x20b2d0,5,
+0x20b2e8,5,
+0x20b300,37,
+0x20b400,6,
+0x20b420,3,
+0x20b438,4,
+0x20b454,3,
+0x20b478,4,
+0x20b494,3,
+0x20b800,5,
+0x20b818,1,
+0x20b854,6,
+0x20b880,2,
+0x20b8a4,1,
+0x20ba00,28,
+0x20ba7c,5,
+0x20bab0,2,
+0x20babc,10,
+0x20bb00,2,
+0x20bb0c,7,
+0x20bb34,9,
+0x20bb60,6,
+0x20bb80,8,
+0x20bc00,5,
+0x20bc18,1,
+0x20bc54,6,
+0x20bc80,2,
+0x20bca4,1,
+0x20be00,28,
+0x20be7c,5,
+0x20beb0,2,
+0x20bebc,10,
+0x20bf00,2,
+0x20bf0c,7,
+0x20bf34,9,
+0x20bf60,6,
+0x20bf80,8,
+0x20c000,4,
+0x20c014,10,
+0x20c040,1,
+0x20c048,3,
+0x20c058,1,
+0x20c060,1,
+0x20c07c,1,
+0x20c500,1,
+0x20c518,2,
+0x20c540,6,
+0x20c800,4,
+0x20c814,10,
+0x20c840,1,
+0x20c848,3,
+0x20c858,1,
+0x20c860,1,
+0x20c87c,1,
+0x20cd00,1,
+0x20cd18,2,
+0x20cd40,6,
+0x20d800,2,
+0x20d818,2,
+0x20d834,2,
+0x20d92c,6,
+0x20d990,2,
+0x20d9ac,1,
+0x20d9d8,4,
+0x20da00,16,
+0x20dc00,3,
+0x20dc20,2,
+0x20dc40,1,
+0x210000,5,
+0x210020,4,
+0x210034,9,
+0x21005c,7,
+0x210080,1,
+0x2100a0,6,
+0x210100,5,
+0x210120,4,
+0x210134,9,
+0x21015c,7,
+0x210180,1,
+0x2101a0,6,
+0x210200,5,
+0x210220,4,
+0x210234,9,
+0x21025c,7,
+0x210280,1,
+0x2102a0,6,
+0x210300,5,
+0x210320,4,
+0x210334,9,
+0x21035c,7,
+0x210380,1,
+0x2103a0,6,
+0x210400,4,
+0x210440,4,
+0x210480,3,
+0x2104c0,3,
+0x210500,5,
+0x210518,8,
+0x210c00,13,
+0x210c40,11,
+0x210c80,13,
+0x210cc0,11,
+0x210d00,6,
+0x210d20,6,
+0x210e00,10,
+0x210e40,11,
+0x210e80,8,
+0x211000,2,
+0x211010,5,
+0x211040,3,
+0x211050,3,
+0x211060,7,
+0x211080,7,
+0x2110a0,7,
+0x2110c0,7,
+0x211100,7,
+0x211140,7,
+0x211180,5,
+0x21119c,9,
+0x211218,9,
+0x211240,3,
+0x211250,6,
+0x211280,1,
+0x211288,6,
+0x2112a4,1,
+0x2112c0,1,
+0x2112c8,6,
+0x2112e4,1,
+0x211400,8,
+0x211424,2,
+0x211500,3,
+0x211520,4,
+0x211540,3,
+0x211560,4,
+0x211800,24,
+0x211864,2,
+0x211880,6,
+0x211900,12,
+0x211940,6,
+0x211960,6,
+0x211980,4,
+0x2119c0,6,
+0x2119dc,1,
+0x211a00,6,
+0x211a1c,1,
+0x211a40,1,
+0x211a68,23,
+0x211b00,17,
+0x211b80,12,
+0x212000,5,
+0x212020,4,
+0x212034,9,
+0x21205c,7,
+0x212080,1,
+0x2120a0,6,
+0x212100,5,
+0x212120,4,
+0x212134,9,
+0x21215c,7,
+0x212180,1,
+0x2121a0,6,
+0x212200,5,
+0x212220,4,
+0x212234,9,
+0x21225c,7,
+0x212280,1,
+0x2122a0,6,
+0x212300,5,
+0x212320,4,
+0x212334,9,
+0x21235c,7,
+0x212380,1,
+0x2123a0,6,
+0x212400,4,
+0x212440,4,
+0x212480,3,
+0x2124c0,3,
+0x212500,5,
+0x212518,8,
+0x212c00,13,
+0x212c40,11,
+0x212c80,13,
+0x212cc0,11,
+0x212d00,6,
+0x212d20,6,
+0x212e00,10,
+0x212e40,11,
+0x212e80,8,
+0x213000,2,
+0x213010,5,
+0x213040,3,
+0x213050,3,
+0x213060,7,
+0x213080,7,
+0x2130a0,7,
+0x2130c0,7,
+0x213100,7,
+0x213140,7,
+0x213180,5,
+0x21319c,9,
+0x213218,9,
+0x213240,3,
+0x213250,6,
+0x213280,1,
+0x213288,6,
+0x2132a4,1,
+0x2132c0,1,
+0x2132c8,6,
+0x2132e4,1,
+0x213400,8,
+0x213424,2,
+0x213500,3,
+0x213520,4,
+0x213540,3,
+0x213560,4,
+0x213800,24,
+0x213864,2,
+0x213880,6,
+0x213900,12,
+0x213940,6,
+0x213960,6,
+0x213980,4,
+0x2139c0,6,
+0x2139dc,1,
+0x213a00,6,
+0x213a1c,1,
+0x213a40,1,
+0x213a68,23,
+0x213b00,17,
+0x213b80,12,
+0x214000,4,
+0x214014,6,
+0x214030,5,
+0x214080,4,
+0x214094,6,
+0x2140b0,5,
+0x214100,4,
+0x214114,6,
+0x214130,5,
+0x214180,4,
+0x214194,6,
+0x2141b0,5,
+0x214200,3,
+0x214210,23,
+0x214500,3,
+0x214510,12,
+0x214580,3,
+0x214590,12,
+0x214600,3,
+0x214610,12,
+0x214680,3,
+0x214690,12,
+0x214700,4,
+0x214718,13,
+0x214800,25,
+0x214880,25,
+0x214900,25,
+0x214980,25,
+0x214a00,17,
+0x214a50,3,
+0x214a60,3,
+0x215000,4,
+0x215014,6,
+0x215030,5,
+0x215080,4,
+0x215094,6,
+0x2150b0,5,
+0x215100,4,
+0x215114,6,
+0x215130,5,
+0x215180,4,
+0x215194,6,
+0x2151b0,5,
+0x215200,3,
+0x215210,23,
+0x215500,3,
+0x215510,12,
+0x215580,3,
+0x215590,12,
+0x215600,3,
+0x215610,12,
+0x215680,3,
+0x215690,12,
+0x215700,4,
+0x215718,13,
+0x215800,25,
+0x215880,25,
+0x215900,25,
+0x215980,25,
+0x215a00,17,
+0x215a50,3,
+0x215a60,3,
+0x216000,13,
+0x216040,22,
+0x2160a0,6,
+0x2160c0,3,
+0x216100,9,
+0x216400,2,
+0x21640c,6,
+0x216440,13,
+0x216480,16,
+0x216800,1,
+0x216808,3,
+0x21681c,8,
+0x216840,3,
+0x216850,3,
+0x216880,1,
+0x216888,3,
+0x21689c,8,
+0x2168c0,3,
+0x2168d0,3,
+0x216900,1,
+0x216908,3,
+0x21691c,8,
+0x216940,3,
+0x216950,3,
+0x216980,1,
+0x216988,3,
+0x21699c,8,
+0x2169c0,3,
+0x2169d0,3,
+0x216a00,1,
+0x216a08,3,
+0x216a1c,8,
+0x216a40,3,
+0x216a50,3,
+0x216a80,1,
+0x216a88,3,
+0x216a9c,8,
+0x216ac0,3,
+0x216ad0,3,
+0x216b00,1,
+0x216b08,3,
+0x216b1c,8,
+0x216b40,3,
+0x216b50,3,
+0x216b80,1,
+0x216b88,3,
+0x216b9c,8,
+0x216bc0,3,
+0x216bd0,3,
+0x216c00,1,
+0x216c08,3,
+0x216c1c,8,
+0x216c40,3,
+0x216c50,3,
+0x216c80,2,
+0x216c94,13,
+0x217000,6,
+0x217020,3,
+0x217034,1,
+0x217040,7,
+0x217060,6,
+0x217100,5,
+0x217138,1,
+0x217144,1,
+0x217400,1,
+0x217418,1,
+0x217434,1,
+0x21752c,5,
+0x217590,1,
+0x2175ac,1,
+0x2175d8,4,
+0x217600,8,
+0x218000,6,
+0x218020,3,
+0x218030,9,
+0x218080,6,
+0x218100,20,
+0x218400,1,
+0x218418,1,
+0x218434,1,
+0x21852c,4,
+0x218590,1,
+0x2185ac,1,
+0x2185d8,4,
+0x218600,8,
+0x219000,6,
+0x219020,6,
+0x219040,3,
+0x219080,14,
+0x2190bc,1,
+0x2190c4,13,
+0x2190fc,6,
+0x219120,5,
+0x219190,10,
+0x219200,16,
+0x219244,32,
+0x219300,26,
+0x219380,2,
+0x2193a0,1,
+0x2193c0,11,
+0x219404,4,
+0x219418,16,
+0x219460,3,
+0x219500,6,
+0x219540,1,
+0x219558,2,
+0x219600,17,
+0x219800,366,
+0x21a000,6,
+0x21a020,6,
+0x21a040,3,
+0x21a080,14,
+0x21a0bc,1,
+0x21a0c4,13,
+0x21a0fc,6,
+0x21a120,5,
+0x21a190,10,
+0x21a200,16,
+0x21a244,32,
+0x21a300,26,
+0x21a380,2,
+0x21a3a0,1,
+0x21a3c0,11,
+0x21a404,4,
+0x21a418,16,
+0x21a460,3,
+0x21a500,6,
+0x21a540,1,
+0x21a558,2,
+0x21a600,17,
+0x21a800,366,
+0x21b000,4,
+0x21b020,9,
+0x21b048,6,
+0x21b064,6,
+0x21b080,1,
+0x21b100,4,
+0x21b120,9,
+0x21b148,6,
+0x21b164,6,
+0x21b180,1,
+0x21b200,35,
+0x21b290,6,
+0x21b2b4,6,
+0x21b2d0,5,
+0x21b2e8,5,
+0x21b300,37,
+0x21b400,6,
+0x21b420,3,
+0x21b438,4,
+0x21b454,3,
+0x21b478,4,
+0x21b494,3,
+0x21b800,5,
+0x21b818,1,
+0x21b854,6,
+0x21b880,2,
+0x21b8a4,1,
+0x21ba00,28,
+0x21ba7c,5,
+0x21bab0,2,
+0x21babc,10,
+0x21bb00,2,
+0x21bb0c,7,
+0x21bb34,9,
+0x21bb60,6,
+0x21bb80,8,
+0x21bc00,5,
+0x21bc18,1,
+0x21bc54,6,
+0x21bc80,2,
+0x21bca4,1,
+0x21be00,28,
+0x21be7c,5,
+0x21beb0,2,
+0x21bebc,10,
+0x21bf00,2,
+0x21bf0c,7,
+0x21bf34,9,
+0x21bf60,6,
+0x21bf80,8,
+0x21c000,4,
+0x21c014,10,
+0x21c040,1,
+0x21c048,3,
+0x21c058,1,
+0x21c060,1,
+0x21c07c,1,
+0x21c500,1,
+0x21c518,2,
+0x21c540,6,
+0x21c800,4,
+0x21c814,10,
+0x21c840,1,
+0x21c848,3,
+0x21c858,1,
+0x21c860,1,
+0x21c87c,1,
+0x21cd00,1,
+0x21cd18,2,
+0x21cd40,6,
+0x21d800,2,
+0x21d818,2,
+0x21d834,2,
+0x21d92c,6,
+0x21d990,2,
+0x21d9ac,1,
+0x21d9d8,4,
+0x21da00,16,
+0x21dc00,3,
+0x21dc20,2,
+0x21dc40,1,
+0x220000,5,
+0x220020,4,
+0x220034,9,
+0x22005c,7,
+0x220080,1,
+0x2200a0,6,
+0x220100,5,
+0x220120,4,
+0x220134,9,
+0x22015c,7,
+0x220180,1,
+0x2201a0,6,
+0x220200,5,
+0x220220,4,
+0x220234,9,
+0x22025c,7,
+0x220280,1,
+0x2202a0,6,
+0x220300,5,
+0x220320,4,
+0x220334,9,
+0x22035c,7,
+0x220380,1,
+0x2203a0,6,
+0x220400,4,
+0x220440,4,
+0x220480,3,
+0x2204c0,3,
+0x220500,5,
+0x220518,8,
+0x220c00,13,
+0x220c40,11,
+0x220c80,13,
+0x220cc0,11,
+0x220d00,6,
+0x220d20,6,
+0x220e00,10,
+0x220e40,11,
+0x220e80,8,
+0x221000,2,
+0x221010,5,
+0x221040,3,
+0x221050,3,
+0x221060,7,
+0x221080,7,
+0x2210a0,7,
+0x2210c0,7,
+0x221100,7,
+0x221140,7,
+0x221180,5,
+0x22119c,9,
+0x221218,9,
+0x221240,3,
+0x221250,6,
+0x221280,1,
+0x221288,6,
+0x2212a4,1,
+0x2212c0,1,
+0x2212c8,6,
+0x2212e4,1,
+0x221400,8,
+0x221424,2,
+0x221500,3,
+0x221520,4,
+0x221540,3,
+0x221560,4,
+0x221800,24,
+0x221864,2,
+0x221880,6,
+0x221900,12,
+0x221940,6,
+0x221960,6,
+0x221980,4,
+0x2219c0,6,
+0x2219dc,1,
+0x221a00,6,
+0x221a1c,1,
+0x221a40,1,
+0x221a68,23,
+0x221b00,17,
+0x221b80,12,
+0x222000,5,
+0x222020,4,
+0x222034,9,
+0x22205c,7,
+0x222080,1,
+0x2220a0,6,
+0x222100,5,
+0x222120,4,
+0x222134,9,
+0x22215c,7,
+0x222180,1,
+0x2221a0,6,
+0x222200,5,
+0x222220,4,
+0x222234,9,
+0x22225c,7,
+0x222280,1,
+0x2222a0,6,
+0x222300,5,
+0x222320,4,
+0x222334,9,
+0x22235c,7,
+0x222380,1,
+0x2223a0,6,
+0x222400,4,
+0x222440,4,
+0x222480,3,
+0x2224c0,3,
+0x222500,5,
+0x222518,8,
+0x222c00,13,
+0x222c40,11,
+0x222c80,13,
+0x222cc0,11,
+0x222d00,6,
+0x222d20,6,
+0x222e00,10,
+0x222e40,11,
+0x222e80,8,
+0x223000,2,
+0x223010,5,
+0x223040,3,
+0x223050,3,
+0x223060,7,
+0x223080,7,
+0x2230a0,7,
+0x2230c0,7,
+0x223100,7,
+0x223140,7,
+0x223180,5,
+0x22319c,9,
+0x223218,9,
+0x223240,3,
+0x223250,6,
+0x223280,1,
+0x223288,6,
+0x2232a4,1,
+0x2232c0,1,
+0x2232c8,6,
+0x2232e4,1,
+0x223400,8,
+0x223424,2,
+0x223500,3,
+0x223520,4,
+0x223540,3,
+0x223560,4,
+0x223800,24,
+0x223864,2,
+0x223880,6,
+0x223900,12,
+0x223940,6,
+0x223960,6,
+0x223980,4,
+0x2239c0,6,
+0x2239dc,1,
+0x223a00,6,
+0x223a1c,1,
+0x223a40,1,
+0x223a68,23,
+0x223b00,17,
+0x223b80,12,
+0x224000,4,
+0x224014,6,
+0x224030,5,
+0x224080,4,
+0x224094,6,
+0x2240b0,5,
+0x224100,4,
+0x224114,6,
+0x224130,5,
+0x224180,4,
+0x224194,6,
+0x2241b0,5,
+0x224200,3,
+0x224210,23,
+0x224500,3,
+0x224510,12,
+0x224580,3,
+0x224590,12,
+0x224600,3,
+0x224610,12,
+0x224680,3,
+0x224690,12,
+0x224700,4,
+0x224718,13,
+0x224800,25,
+0x224880,25,
+0x224900,25,
+0x224980,25,
+0x224a00,17,
+0x224a50,3,
+0x224a60,3,
+0x225000,4,
+0x225014,6,
+0x225030,5,
+0x225080,4,
+0x225094,6,
+0x2250b0,5,
+0x225100,4,
+0x225114,6,
+0x225130,5,
+0x225180,4,
+0x225194,6,
+0x2251b0,5,
+0x225200,3,
+0x225210,23,
+0x225500,3,
+0x225510,12,
+0x225580,3,
+0x225590,12,
+0x225600,3,
+0x225610,12,
+0x225680,3,
+0x225690,12,
+0x225700,4,
+0x225718,13,
+0x225800,25,
+0x225880,25,
+0x225900,25,
+0x225980,25,
+0x225a00,17,
+0x225a50,3,
+0x225a60,3,
+0x226000,13,
+0x226040,22,
+0x2260a0,6,
+0x2260c0,3,
+0x226100,9,
+0x226400,2,
+0x22640c,6,
+0x226440,13,
+0x226480,16,
+0x226800,1,
+0x226808,3,
+0x22681c,8,
+0x226840,3,
+0x226850,3,
+0x226880,1,
+0x226888,3,
+0x22689c,8,
+0x2268c0,3,
+0x2268d0,3,
+0x226900,1,
+0x226908,3,
+0x22691c,8,
+0x226940,3,
+0x226950,3,
+0x226980,1,
+0x226988,3,
+0x22699c,8,
+0x2269c0,3,
+0x2269d0,3,
+0x226a00,1,
+0x226a08,3,
+0x226a1c,8,
+0x226a40,3,
+0x226a50,3,
+0x226a80,1,
+0x226a88,3,
+0x226a9c,8,
+0x226ac0,3,
+0x226ad0,3,
+0x226b00,1,
+0x226b08,3,
+0x226b1c,8,
+0x226b40,3,
+0x226b50,3,
+0x226b80,1,
+0x226b88,3,
+0x226b9c,8,
+0x226bc0,3,
+0x226bd0,3,
+0x226c00,1,
+0x226c08,3,
+0x226c1c,8,
+0x226c40,3,
+0x226c50,3,
+0x226c80,2,
+0x226c94,13,
+0x227000,6,
+0x227020,3,
+0x227034,1,
+0x227040,7,
+0x227060,6,
+0x227100,5,
+0x227138,1,
+0x227144,1,
+0x227400,1,
+0x227418,1,
+0x227434,1,
+0x22752c,5,
+0x227590,1,
+0x2275ac,1,
+0x2275d8,4,
+0x227600,8,
+0x228000,6,
+0x228020,3,
+0x228030,9,
+0x228080,6,
+0x228100,20,
+0x228400,1,
+0x228418,1,
+0x228434,1,
+0x22852c,4,
+0x228590,1,
+0x2285ac,1,
+0x2285d8,4,
+0x228600,8,
+0x229000,6,
+0x229020,6,
+0x229040,3,
+0x229080,14,
+0x2290bc,1,
+0x2290c4,13,
+0x2290fc,6,
+0x229120,5,
+0x229190,10,
+0x229200,16,
+0x229244,32,
+0x229300,26,
+0x229380,2,
+0x2293a0,1,
+0x2293c0,11,
+0x229404,4,
+0x229418,16,
+0x229460,3,
+0x229500,6,
+0x229540,1,
+0x229558,2,
+0x229600,17,
+0x229800,366,
+0x22a000,6,
+0x22a020,6,
+0x22a040,3,
+0x22a080,14,
+0x22a0bc,1,
+0x22a0c4,13,
+0x22a0fc,6,
+0x22a120,5,
+0x22a190,10,
+0x22a200,16,
+0x22a244,32,
+0x22a300,26,
+0x22a380,2,
+0x22a3a0,1,
+0x22a3c0,11,
+0x22a404,4,
+0x22a418,16,
+0x22a460,3,
+0x22a500,6,
+0x22a540,1,
+0x22a558,2,
+0x22a600,17,
+0x22a800,366,
+0x22b000,4,
+0x22b020,9,
+0x22b048,6,
+0x22b064,6,
+0x22b080,1,
+0x22b100,4,
+0x22b120,9,
+0x22b148,6,
+0x22b164,6,
+0x22b180,1,
+0x22b200,35,
+0x22b290,6,
+0x22b2b4,6,
+0x22b2d0,5,
+0x22b2e8,5,
+0x22b300,37,
+0x22b400,6,
+0x22b420,3,
+0x22b438,4,
+0x22b454,3,
+0x22b478,4,
+0x22b494,3,
+0x22b800,5,
+0x22b818,1,
+0x22b854,6,
+0x22b880,2,
+0x22b8a4,1,
+0x22ba00,28,
+0x22ba7c,5,
+0x22bab0,2,
+0x22babc,10,
+0x22bb00,2,
+0x22bb0c,7,
+0x22bb34,9,
+0x22bb60,6,
+0x22bb80,8,
+0x22bc00,5,
+0x22bc18,1,
+0x22bc54,6,
+0x22bc80,2,
+0x22bca4,1,
+0x22be00,28,
+0x22be7c,5,
+0x22beb0,2,
+0x22bebc,10,
+0x22bf00,2,
+0x22bf0c,7,
+0x22bf34,9,
+0x22bf60,6,
+0x22bf80,8,
+0x22c000,4,
+0x22c014,10,
+0x22c040,1,
+0x22c048,3,
+0x22c058,1,
+0x22c060,1,
+0x22c07c,1,
+0x22c500,1,
+0x22c518,2,
+0x22c540,6,
+0x22c800,4,
+0x22c814,10,
+0x22c840,1,
+0x22c848,3,
+0x22c858,1,
+0x22c860,1,
+0x22c87c,1,
+0x22cd00,1,
+0x22cd18,2,
+0x22cd40,6,
+0x22d800,2,
+0x22d818,2,
+0x22d834,2,
+0x22d92c,6,
+0x22d990,2,
+0x22d9ac,1,
+0x22d9d8,4,
+0x22da00,16,
+0x22dc00,3,
+0x22dc20,2,
+0x22dc40,1,
+0x230000,5,
+0x230020,4,
+0x230034,9,
+0x23005c,7,
+0x230080,1,
+0x2300a0,6,
+0x230100,5,
+0x230120,4,
+0x230134,9,
+0x23015c,7,
+0x230180,1,
+0x2301a0,6,
+0x230200,5,
+0x230220,4,
+0x230234,9,
+0x23025c,7,
+0x230280,1,
+0x2302a0,6,
+0x230300,5,
+0x230320,4,
+0x230334,9,
+0x23035c,7,
+0x230380,1,
+0x2303a0,6,
+0x230400,4,
+0x230440,4,
+0x230480,3,
+0x2304c0,3,
+0x230500,5,
+0x230518,8,
+0x230c00,13,
+0x230c40,11,
+0x230c80,13,
+0x230cc0,11,
+0x230d00,6,
+0x230d20,6,
+0x230e00,10,
+0x230e40,11,
+0x230e80,8,
+0x231000,2,
+0x231010,5,
+0x231040,3,
+0x231050,3,
+0x231060,7,
+0x231080,7,
+0x2310a0,7,
+0x2310c0,7,
+0x231100,7,
+0x231140,7,
+0x231180,5,
+0x23119c,9,
+0x231218,9,
+0x231240,3,
+0x231250,6,
+0x231280,1,
+0x231288,6,
+0x2312a4,1,
+0x2312c0,1,
+0x2312c8,6,
+0x2312e4,1,
+0x231400,8,
+0x231424,2,
+0x231500,3,
+0x231520,4,
+0x231540,3,
+0x231560,4,
+0x231800,24,
+0x231864,2,
+0x231880,6,
+0x231900,12,
+0x231940,6,
+0x231960,6,
+0x231980,4,
+0x2319c0,6,
+0x2319dc,1,
+0x231a00,6,
+0x231a1c,1,
+0x231a40,1,
+0x231a68,23,
+0x231b00,17,
+0x231b80,12,
+0x232000,5,
+0x232020,4,
+0x232034,9,
+0x23205c,7,
+0x232080,1,
+0x2320a0,6,
+0x232100,5,
+0x232120,4,
+0x232134,9,
+0x23215c,7,
+0x232180,1,
+0x2321a0,6,
+0x232200,5,
+0x232220,4,
+0x232234,9,
+0x23225c,7,
+0x232280,1,
+0x2322a0,6,
+0x232300,5,
+0x232320,4,
+0x232334,9,
+0x23235c,7,
+0x232380,1,
+0x2323a0,6,
+0x232400,4,
+0x232440,4,
+0x232480,3,
+0x2324c0,3,
+0x232500,5,
+0x232518,8,
+0x232c00,13,
+0x232c40,11,
+0x232c80,13,
+0x232cc0,11,
+0x232d00,6,
+0x232d20,6,
+0x232e00,10,
+0x232e40,11,
+0x232e80,8,
+0x233000,2,
+0x233010,5,
+0x233040,3,
+0x233050,3,
+0x233060,7,
+0x233080,7,
+0x2330a0,7,
+0x2330c0,7,
+0x233100,7,
+0x233140,7,
+0x233180,5,
+0x23319c,9,
+0x233218,9,
+0x233240,3,
+0x233250,6,
+0x233280,1,
+0x233288,6,
+0x2332a4,1,
+0x2332c0,1,
+0x2332c8,6,
+0x2332e4,1,
+0x233400,8,
+0x233424,2,
+0x233500,3,
+0x233520,4,
+0x233540,3,
+0x233560,4,
+0x233800,24,
+0x233864,2,
+0x233880,6,
+0x233900,12,
+0x233940,6,
+0x233960,6,
+0x233980,4,
+0x2339c0,6,
+0x2339dc,1,
+0x233a00,6,
+0x233a1c,1,
+0x233a40,1,
+0x233a68,23,
+0x233b00,17,
+0x233b80,12,
+0x234000,4,
+0x234014,6,
+0x234030,5,
+0x234080,4,
+0x234094,6,
+0x2340b0,5,
+0x234100,4,
+0x234114,6,
+0x234130,5,
+0x234180,4,
+0x234194,6,
+0x2341b0,5,
+0x234200,3,
+0x234210,23,
+0x234500,3,
+0x234510,12,
+0x234580,3,
+0x234590,12,
+0x234600,3,
+0x234610,12,
+0x234680,3,
+0x234690,12,
+0x234700,4,
+0x234718,13,
+0x234800,25,
+0x234880,25,
+0x234900,25,
+0x234980,25,
+0x234a00,17,
+0x234a50,3,
+0x234a60,3,
+0x235000,4,
+0x235014,6,
+0x235030,5,
+0x235080,4,
+0x235094,6,
+0x2350b0,5,
+0x235100,4,
+0x235114,6,
+0x235130,5,
+0x235180,4,
+0x235194,6,
+0x2351b0,5,
+0x235200,3,
+0x235210,23,
+0x235500,3,
+0x235510,12,
+0x235580,3,
+0x235590,12,
+0x235600,3,
+0x235610,12,
+0x235680,3,
+0x235690,12,
+0x235700,4,
+0x235718,13,
+0x235800,25,
+0x235880,25,
+0x235900,25,
+0x235980,25,
+0x235a00,17,
+0x235a50,3,
+0x235a60,3,
+0x236000,13,
+0x236040,22,
+0x2360a0,6,
+0x2360c0,3,
+0x236100,9,
+0x236400,2,
+0x23640c,6,
+0x236440,13,
+0x236480,16,
+0x236800,1,
+0x236808,3,
+0x23681c,8,
+0x236840,3,
+0x236850,3,
+0x236880,1,
+0x236888,3,
+0x23689c,8,
+0x2368c0,3,
+0x2368d0,3,
+0x236900,1,
+0x236908,3,
+0x23691c,8,
+0x236940,3,
+0x236950,3,
+0x236980,1,
+0x236988,3,
+0x23699c,8,
+0x2369c0,3,
+0x2369d0,3,
+0x236a00,1,
+0x236a08,3,
+0x236a1c,8,
+0x236a40,3,
+0x236a50,3,
+0x236a80,1,
+0x236a88,3,
+0x236a9c,8,
+0x236ac0,3,
+0x236ad0,3,
+0x236b00,1,
+0x236b08,3,
+0x236b1c,8,
+0x236b40,3,
+0x236b50,3,
+0x236b80,1,
+0x236b88,3,
+0x236b9c,8,
+0x236bc0,3,
+0x236bd0,3,
+0x236c00,1,
+0x236c08,3,
+0x236c1c,8,
+0x236c40,3,
+0x236c50,3,
+0x236c80,2,
+0x236c94,13,
+0x237000,6,
+0x237020,3,
+0x237034,1,
+0x237040,7,
+0x237060,6,
+0x237100,5,
+0x237138,1,
+0x237144,1,
+0x237400,1,
+0x237418,1,
+0x237434,1,
+0x23752c,5,
+0x237590,1,
+0x2375ac,1,
+0x2375d8,4,
+0x237600,8,
+0x238000,6,
+0x238020,3,
+0x238030,9,
+0x238080,6,
+0x238100,20,
+0x238400,1,
+0x238418,1,
+0x238434,1,
+0x23852c,4,
+0x238590,1,
+0x2385ac,1,
+0x2385d8,4,
+0x238600,8,
+0x239000,6,
+0x239020,6,
+0x239040,3,
+0x239080,14,
+0x2390bc,1,
+0x2390c4,13,
+0x2390fc,6,
+0x239120,5,
+0x239190,10,
+0x239200,16,
+0x239244,32,
+0x239300,26,
+0x239380,2,
+0x2393a0,1,
+0x2393c0,11,
+0x239404,4,
+0x239418,16,
+0x239460,3,
+0x239500,6,
+0x239540,1,
+0x239558,2,
+0x239600,17,
+0x239800,366,
+0x23a000,6,
+0x23a020,6,
+0x23a040,3,
+0x23a080,14,
+0x23a0bc,1,
+0x23a0c4,13,
+0x23a0fc,6,
+0x23a120,5,
+0x23a190,10,
+0x23a200,16,
+0x23a244,32,
+0x23a300,26,
+0x23a380,2,
+0x23a3a0,1,
+0x23a3c0,11,
+0x23a404,4,
+0x23a418,16,
+0x23a460,3,
+0x23a500,6,
+0x23a540,1,
+0x23a558,2,
+0x23a600,17,
+0x23a800,366,
+0x23b000,4,
+0x23b020,9,
+0x23b048,6,
+0x23b064,6,
+0x23b080,1,
+0x23b100,4,
+0x23b120,9,
+0x23b148,6,
+0x23b164,6,
+0x23b180,1,
+0x23b200,35,
+0x23b290,6,
+0x23b2b4,6,
+0x23b2d0,5,
+0x23b2e8,5,
+0x23b300,37,
+0x23b400,6,
+0x23b420,3,
+0x23b438,4,
+0x23b454,3,
+0x23b478,4,
+0x23b494,3,
+0x23b800,5,
+0x23b818,1,
+0x23b854,6,
+0x23b880,2,
+0x23b8a4,1,
+0x23ba00,28,
+0x23ba7c,5,
+0x23bab0,2,
+0x23babc,10,
+0x23bb00,2,
+0x23bb0c,7,
+0x23bb34,9,
+0x23bb60,6,
+0x23bb80,8,
+0x23bc00,5,
+0x23bc18,1,
+0x23bc54,6,
+0x23bc80,2,
+0x23bca4,1,
+0x23be00,28,
+0x23be7c,5,
+0x23beb0,2,
+0x23bebc,10,
+0x23bf00,2,
+0x23bf0c,7,
+0x23bf34,9,
+0x23bf60,6,
+0x23bf80,8,
+0x23c000,4,
+0x23c014,10,
+0x23c040,1,
+0x23c048,3,
+0x23c058,1,
+0x23c060,1,
+0x23c07c,1,
+0x23c500,1,
+0x23c518,2,
+0x23c540,6,
+0x23c800,4,
+0x23c814,10,
+0x23c840,1,
+0x23c848,3,
+0x23c858,1,
+0x23c860,1,
+0x23c87c,1,
+0x23cd00,1,
+0x23cd18,2,
+0x23cd40,6,
+0x23d800,2,
+0x23d818,2,
+0x23d834,2,
+0x23d92c,6,
+0x23d990,2,
+0x23d9ac,1,
+0x23d9d8,4,
+0x23da00,16,
+0x23dc00,3,
+0x23dc20,2,
+0x23dc40,1,
+0x240000,5,
+0x240020,4,
+0x240034,9,
+0x24005c,7,
+0x240080,1,
+0x2400a0,6,
+0x240100,5,
+0x240120,4,
+0x240134,9,
+0x24015c,7,
+0x240180,1,
+0x2401a0,6,
+0x240200,5,
+0x240220,4,
+0x240234,9,
+0x24025c,7,
+0x240280,1,
+0x2402a0,6,
+0x240300,5,
+0x240320,4,
+0x240334,9,
+0x24035c,7,
+0x240380,1,
+0x2403a0,6,
+0x240400,4,
+0x240440,4,
+0x240480,3,
+0x2404c0,3,
+0x240500,5,
+0x240518,8,
+0x240c00,13,
+0x240c40,11,
+0x240c80,13,
+0x240cc0,11,
+0x240d00,6,
+0x240d20,6,
+0x240e00,10,
+0x240e40,11,
+0x240e80,8,
+0x241000,2,
+0x241010,5,
+0x241040,3,
+0x241050,3,
+0x241060,7,
+0x241080,7,
+0x2410a0,7,
+0x2410c0,7,
+0x241100,7,
+0x241140,7,
+0x241180,5,
+0x24119c,9,
+0x241218,9,
+0x241240,3,
+0x241250,6,
+0x241280,1,
+0x241288,6,
+0x2412a4,1,
+0x2412c0,1,
+0x2412c8,6,
+0x2412e4,1,
+0x241400,8,
+0x241424,2,
+0x241500,3,
+0x241520,4,
+0x241540,3,
+0x241560,4,
+0x241800,24,
+0x241864,2,
+0x241880,6,
+0x241900,12,
+0x241940,6,
+0x241960,6,
+0x241980,4,
+0x2419c0,6,
+0x2419dc,1,
+0x241a00,6,
+0x241a1c,1,
+0x241a40,1,
+0x241a68,23,
+0x241b00,17,
+0x241b80,12,
+0x242000,5,
+0x242020,4,
+0x242034,9,
+0x24205c,7,
+0x242080,1,
+0x2420a0,6,
+0x242100,5,
+0x242120,4,
+0x242134,9,
+0x24215c,7,
+0x242180,1,
+0x2421a0,6,
+0x242200,5,
+0x242220,4,
+0x242234,9,
+0x24225c,7,
+0x242280,1,
+0x2422a0,6,
+0x242300,5,
+0x242320,4,
+0x242334,9,
+0x24235c,7,
+0x242380,1,
+0x2423a0,6,
+0x242400,4,
+0x242440,4,
+0x242480,3,
+0x2424c0,3,
+0x242500,5,
+0x242518,8,
+0x242c00,13,
+0x242c40,11,
+0x242c80,13,
+0x242cc0,11,
+0x242d00,6,
+0x242d20,6,
+0x242e00,10,
+0x242e40,11,
+0x242e80,8,
+0x243000,2,
+0x243010,5,
+0x243040,3,
+0x243050,3,
+0x243060,7,
+0x243080,7,
+0x2430a0,7,
+0x2430c0,7,
+0x243100,7,
+0x243140,7,
+0x243180,5,
+0x24319c,9,
+0x243218,9,
+0x243240,3,
+0x243250,6,
+0x243280,1,
+0x243288,6,
+0x2432a4,1,
+0x2432c0,1,
+0x2432c8,6,
+0x2432e4,1,
+0x243400,8,
+0x243424,2,
+0x243500,3,
+0x243520,4,
+0x243540,3,
+0x243560,4,
+0x243800,24,
+0x243864,2,
+0x243880,6,
+0x243900,12,
+0x243940,6,
+0x243960,6,
+0x243980,4,
+0x2439c0,6,
+0x2439dc,1,
+0x243a00,6,
+0x243a1c,1,
+0x243a40,1,
+0x243a68,23,
+0x243b00,17,
+0x243b80,12,
+0x244000,4,
+0x244014,6,
+0x244030,5,
+0x244080,4,
+0x244094,6,
+0x2440b0,5,
+0x244100,4,
+0x244114,6,
+0x244130,5,
+0x244180,4,
+0x244194,6,
+0x2441b0,5,
+0x244200,3,
+0x244210,23,
+0x244500,3,
+0x244510,12,
+0x244580,3,
+0x244590,12,
+0x244600,3,
+0x244610,12,
+0x244680,3,
+0x244690,12,
+0x244700,4,
+0x244718,13,
+0x244800,25,
+0x244880,25,
+0x244900,25,
+0x244980,25,
+0x244a00,17,
+0x244a50,3,
+0x244a60,3,
+0x245000,4,
+0x245014,6,
+0x245030,5,
+0x245080,4,
+0x245094,6,
+0x2450b0,5,
+0x245100,4,
+0x245114,6,
+0x245130,5,
+0x245180,4,
+0x245194,6,
+0x2451b0,5,
+0x245200,3,
+0x245210,23,
+0x245500,3,
+0x245510,12,
+0x245580,3,
+0x245590,12,
+0x245600,3,
+0x245610,12,
+0x245680,3,
+0x245690,12,
+0x245700,4,
+0x245718,13,
+0x245800,25,
+0x245880,25,
+0x245900,25,
+0x245980,25,
+0x245a00,17,
+0x245a50,3,
+0x245a60,3,
+0x246000,13,
+0x246040,22,
+0x2460a0,6,
+0x2460c0,3,
+0x246100,9,
+0x246400,2,
+0x24640c,6,
+0x246440,13,
+0x246480,16,
+0x246800,1,
+0x246808,3,
+0x24681c,8,
+0x246840,3,
+0x246850,3,
+0x246880,1,
+0x246888,3,
+0x24689c,8,
+0x2468c0,3,
+0x2468d0,3,
+0x246900,1,
+0x246908,3,
+0x24691c,8,
+0x246940,3,
+0x246950,3,
+0x246980,1,
+0x246988,3,
+0x24699c,8,
+0x2469c0,3,
+0x2469d0,3,
+0x246a00,1,
+0x246a08,3,
+0x246a1c,8,
+0x246a40,3,
+0x246a50,3,
+0x246a80,1,
+0x246a88,3,
+0x246a9c,8,
+0x246ac0,3,
+0x246ad0,3,
+0x246b00,1,
+0x246b08,3,
+0x246b1c,8,
+0x246b40,3,
+0x246b50,3,
+0x246b80,1,
+0x246b88,3,
+0x246b9c,8,
+0x246bc0,3,
+0x246bd0,3,
+0x246c00,1,
+0x246c08,3,
+0x246c1c,8,
+0x246c40,3,
+0x246c50,3,
+0x246c80,2,
+0x246c94,13,
+0x247000,6,
+0x247020,3,
+0x247034,1,
+0x247040,7,
+0x247060,6,
+0x247100,5,
+0x247138,1,
+0x247144,1,
+0x247400,1,
+0x247418,1,
+0x247434,1,
+0x24752c,5,
+0x247590,1,
+0x2475ac,1,
+0x2475d8,4,
+0x247600,8,
+0x248000,6,
+0x248020,3,
+0x248030,9,
+0x248080,6,
+0x248100,20,
+0x248400,1,
+0x248418,1,
+0x248434,1,
+0x24852c,4,
+0x248590,1,
+0x2485ac,1,
+0x2485d8,4,
+0x248600,8,
+0x249000,6,
+0x249020,6,
+0x249040,3,
+0x249080,14,
+0x2490bc,1,
+0x2490c4,13,
+0x2490fc,6,
+0x249120,5,
+0x249190,10,
+0x249200,16,
+0x249244,32,
+0x249300,26,
+0x249380,2,
+0x2493a0,1,
+0x2493c0,11,
+0x249404,4,
+0x249418,16,
+0x249460,3,
+0x249500,6,
+0x249540,1,
+0x249558,2,
+0x249600,17,
+0x249800,366,
+0x24a000,6,
+0x24a020,6,
+0x24a040,3,
+0x24a080,14,
+0x24a0bc,1,
+0x24a0c4,13,
+0x24a0fc,6,
+0x24a120,5,
+0x24a190,10,
+0x24a200,16,
+0x24a244,32,
+0x24a300,26,
+0x24a380,2,
+0x24a3a0,1,
+0x24a3c0,11,
+0x24a404,4,
+0x24a418,16,
+0x24a460,3,
+0x24a500,6,
+0x24a540,1,
+0x24a558,2,
+0x24a600,17,
+0x24a800,366,
+0x24b000,4,
+0x24b020,9,
+0x24b048,6,
+0x24b064,6,
+0x24b080,1,
+0x24b100,4,
+0x24b120,9,
+0x24b148,6,
+0x24b164,6,
+0x24b180,1,
+0x24b200,35,
+0x24b290,6,
+0x24b2b4,6,
+0x24b2d0,5,
+0x24b2e8,5,
+0x24b300,37,
+0x24b400,6,
+0x24b420,3,
+0x24b438,4,
+0x24b454,3,
+0x24b478,4,
+0x24b494,3,
+0x24b800,5,
+0x24b818,1,
+0x24b854,6,
+0x24b880,2,
+0x24b8a4,1,
+0x24ba00,28,
+0x24ba7c,5,
+0x24bab0,2,
+0x24babc,10,
+0x24bb00,2,
+0x24bb0c,7,
+0x24bb34,9,
+0x24bb60,6,
+0x24bb80,8,
+0x24bc00,5,
+0x24bc18,1,
+0x24bc54,6,
+0x24bc80,2,
+0x24bca4,1,
+0x24be00,28,
+0x24be7c,5,
+0x24beb0,2,
+0x24bebc,10,
+0x24bf00,2,
+0x24bf0c,7,
+0x24bf34,9,
+0x24bf60,6,
+0x24bf80,8,
+0x24c000,4,
+0x24c014,10,
+0x24c040,1,
+0x24c048,3,
+0x24c058,1,
+0x24c060,1,
+0x24c07c,1,
+0x24c500,1,
+0x24c518,2,
+0x24c540,6,
+0x24c800,4,
+0x24c814,10,
+0x24c840,1,
+0x24c848,3,
+0x24c858,1,
+0x24c860,1,
+0x24c87c,1,
+0x24cd00,1,
+0x24cd18,2,
+0x24cd40,6,
+0x24d800,2,
+0x24d818,2,
+0x24d834,2,
+0x24d92c,6,
+0x24d990,2,
+0x24d9ac,1,
+0x24d9d8,4,
+0x24da00,16,
+0x24dc00,3,
+0x24dc20,2,
+0x24dc40,1,
+0x250000,5,
+0x250020,4,
+0x250034,9,
+0x25005c,7,
+0x250080,1,
+0x2500a0,6,
+0x250100,5,
+0x250120,4,
+0x250134,9,
+0x25015c,7,
+0x250180,1,
+0x2501a0,6,
+0x250200,5,
+0x250220,4,
+0x250234,9,
+0x25025c,7,
+0x250280,1,
+0x2502a0,6,
+0x250300,5,
+0x250320,4,
+0x250334,9,
+0x25035c,7,
+0x250380,1,
+0x2503a0,6,
+0x250400,4,
+0x250440,4,
+0x250480,3,
+0x2504c0,3,
+0x250500,5,
+0x250518,8,
+0x250c00,13,
+0x250c40,11,
+0x250c80,13,
+0x250cc0,11,
+0x250d00,6,
+0x250d20,6,
+0x250e00,10,
+0x250e40,11,
+0x250e80,8,
+0x251000,2,
+0x251010,5,
+0x251040,3,
+0x251050,3,
+0x251060,7,
+0x251080,7,
+0x2510a0,7,
+0x2510c0,7,
+0x251100,7,
+0x251140,7,
+0x251180,5,
+0x25119c,9,
+0x251218,9,
+0x251240,3,
+0x251250,6,
+0x251280,1,
+0x251288,6,
+0x2512a4,1,
+0x2512c0,1,
+0x2512c8,6,
+0x2512e4,1,
+0x251400,8,
+0x251424,2,
+0x251500,3,
+0x251520,4,
+0x251540,3,
+0x251560,4,
+0x251800,24,
+0x251864,2,
+0x251880,6,
+0x251900,12,
+0x251940,6,
+0x251960,6,
+0x251980,4,
+0x2519c0,6,
+0x2519dc,1,
+0x251a00,6,
+0x251a1c,1,
+0x251a40,1,
+0x251a68,23,
+0x251b00,17,
+0x251b80,12,
+0x252000,5,
+0x252020,4,
+0x252034,9,
+0x25205c,7,
+0x252080,1,
+0x2520a0,6,
+0x252100,5,
+0x252120,4,
+0x252134,9,
+0x25215c,7,
+0x252180,1,
+0x2521a0,6,
+0x252200,5,
+0x252220,4,
+0x252234,9,
+0x25225c,7,
+0x252280,1,
+0x2522a0,6,
+0x252300,5,
+0x252320,4,
+0x252334,9,
+0x25235c,7,
+0x252380,1,
+0x2523a0,6,
+0x252400,4,
+0x252440,4,
+0x252480,3,
+0x2524c0,3,
+0x252500,5,
+0x252518,8,
+0x252c00,13,
+0x252c40,11,
+0x252c80,13,
+0x252cc0,11,
+0x252d00,6,
+0x252d20,6,
+0x252e00,10,
+0x252e40,11,
+0x252e80,8,
+0x253000,2,
+0x253010,5,
+0x253040,3,
+0x253050,3,
+0x253060,7,
+0x253080,7,
+0x2530a0,7,
+0x2530c0,7,
+0x253100,7,
+0x253140,7,
+0x253180,5,
+0x25319c,9,
+0x253218,9,
+0x253240,3,
+0x253250,6,
+0x253280,1,
+0x253288,6,
+0x2532a4,1,
+0x2532c0,1,
+0x2532c8,6,
+0x2532e4,1,
+0x253400,8,
+0x253424,2,
+0x253500,3,
+0x253520,4,
+0x253540,3,
+0x253560,4,
+0x253800,24,
+0x253864,2,
+0x253880,6,
+0x253900,12,
+0x253940,6,
+0x253960,6,
+0x253980,4,
+0x2539c0,6,
+0x2539dc,1,
+0x253a00,6,
+0x253a1c,1,
+0x253a40,1,
+0x253a68,23,
+0x253b00,17,
+0x253b80,12,
+0x254000,4,
+0x254014,6,
+0x254030,5,
+0x254080,4,
+0x254094,6,
+0x2540b0,5,
+0x254100,4,
+0x254114,6,
+0x254130,5,
+0x254180,4,
+0x254194,6,
+0x2541b0,5,
+0x254200,3,
+0x254210,23,
+0x254500,3,
+0x254510,12,
+0x254580,3,
+0x254590,12,
+0x254600,3,
+0x254610,12,
+0x254680,3,
+0x254690,12,
+0x254700,4,
+0x254718,13,
+0x254800,25,
+0x254880,25,
+0x254900,25,
+0x254980,25,
+0x254a00,17,
+0x254a50,3,
+0x254a60,3,
+0x255000,4,
+0x255014,6,
+0x255030,5,
+0x255080,4,
+0x255094,6,
+0x2550b0,5,
+0x255100,4,
+0x255114,6,
+0x255130,5,
+0x255180,4,
+0x255194,6,
+0x2551b0,5,
+0x255200,3,
+0x255210,23,
+0x255500,3,
+0x255510,12,
+0x255580,3,
+0x255590,12,
+0x255600,3,
+0x255610,12,
+0x255680,3,
+0x255690,12,
+0x255700,4,
+0x255718,13,
+0x255800,25,
+0x255880,25,
+0x255900,25,
+0x255980,25,
+0x255a00,17,
+0x255a50,3,
+0x255a60,3,
+0x256000,13,
+0x256040,22,
+0x2560a0,6,
+0x2560c0,3,
+0x256100,9,
+0x256400,2,
+0x25640c,6,
+0x256440,13,
+0x256480,16,
+0x256800,1,
+0x256808,3,
+0x25681c,8,
+0x256840,3,
+0x256850,3,
+0x256880,1,
+0x256888,3,
+0x25689c,8,
+0x2568c0,3,
+0x2568d0,3,
+0x256900,1,
+0x256908,3,
+0x25691c,8,
+0x256940,3,
+0x256950,3,
+0x256980,1,
+0x256988,3,
+0x25699c,8,
+0x2569c0,3,
+0x2569d0,3,
+0x256a00,1,
+0x256a08,3,
+0x256a1c,8,
+0x256a40,3,
+0x256a50,3,
+0x256a80,1,
+0x256a88,3,
+0x256a9c,8,
+0x256ac0,3,
+0x256ad0,3,
+0x256b00,1,
+0x256b08,3,
+0x256b1c,8,
+0x256b40,3,
+0x256b50,3,
+0x256b80,1,
+0x256b88,3,
+0x256b9c,8,
+0x256bc0,3,
+0x256bd0,3,
+0x256c00,1,
+0x256c08,3,
+0x256c1c,8,
+0x256c40,3,
+0x256c50,3,
+0x256c80,2,
+0x256c94,13,
+0x257000,6,
+0x257020,3,
+0x257034,1,
+0x257040,7,
+0x257060,6,
+0x257100,5,
+0x257138,1,
+0x257144,1,
+0x257400,1,
+0x257418,1,
+0x257434,1,
+0x25752c,5,
+0x257590,1,
+0x2575ac,1,
+0x2575d8,4,
+0x257600,8,
+0x258000,6,
+0x258020,3,
+0x258030,9,
+0x258080,6,
+0x258100,20,
+0x258400,1,
+0x258418,1,
+0x258434,1,
+0x25852c,4,
+0x258590,1,
+0x2585ac,1,
+0x2585d8,4,
+0x258600,8,
+0x259000,6,
+0x259020,6,
+0x259040,3,
+0x259080,14,
+0x2590bc,1,
+0x2590c4,13,
+0x2590fc,6,
+0x259120,5,
+0x259190,10,
+0x259200,16,
+0x259244,32,
+0x259300,26,
+0x259380,2,
+0x2593a0,1,
+0x2593c0,11,
+0x259404,4,
+0x259418,16,
+0x259460,3,
+0x259500,6,
+0x259540,1,
+0x259558,2,
+0x259600,17,
+0x259800,366,
+0x25a000,6,
+0x25a020,6,
+0x25a040,3,
+0x25a080,14,
+0x25a0bc,1,
+0x25a0c4,13,
+0x25a0fc,6,
+0x25a120,5,
+0x25a190,10,
+0x25a200,16,
+0x25a244,32,
+0x25a300,26,
+0x25a380,2,
+0x25a3a0,1,
+0x25a3c0,11,
+0x25a404,4,
+0x25a418,16,
+0x25a460,3,
+0x25a500,6,
+0x25a540,1,
+0x25a558,2,
+0x25a600,17,
+0x25a800,366,
+0x25b000,4,
+0x25b020,9,
+0x25b048,6,
+0x25b064,6,
+0x25b080,1,
+0x25b100,4,
+0x25b120,9,
+0x25b148,6,
+0x25b164,6,
+0x25b180,1,
+0x25b200,35,
+0x25b290,6,
+0x25b2b4,6,
+0x25b2d0,5,
+0x25b2e8,5,
+0x25b300,37,
+0x25b400,6,
+0x25b420,3,
+0x25b438,4,
+0x25b454,3,
+0x25b478,4,
+0x25b494,3,
+0x25b800,5,
+0x25b818,1,
+0x25b854,6,
+0x25b880,2,
+0x25b8a4,1,
+0x25ba00,28,
+0x25ba7c,5,
+0x25bab0,2,
+0x25babc,10,
+0x25bb00,2,
+0x25bb0c,7,
+0x25bb34,9,
+0x25bb60,6,
+0x25bb80,8,
+0x25bc00,5,
+0x25bc18,1,
+0x25bc54,6,
+0x25bc80,2,
+0x25bca4,1,
+0x25be00,28,
+0x25be7c,5,
+0x25beb0,2,
+0x25bebc,10,
+0x25bf00,2,
+0x25bf0c,7,
+0x25bf34,9,
+0x25bf60,6,
+0x25bf80,8,
+0x25c000,4,
+0x25c014,10,
+0x25c040,1,
+0x25c048,3,
+0x25c058,1,
+0x25c060,1,
+0x25c07c,1,
+0x25c500,1,
+0x25c518,2,
+0x25c540,6,
+0x25c800,4,
+0x25c814,10,
+0x25c840,1,
+0x25c848,3,
+0x25c858,1,
+0x25c860,1,
+0x25c87c,1,
+0x25cd00,1,
+0x25cd18,2,
+0x25cd40,6,
+0x25d800,2,
+0x25d818,2,
+0x25d834,2,
+0x25d92c,6,
+0x25d990,2,
+0x25d9ac,1,
+0x25d9d8,4,
+0x25da00,16,
+0x25dc00,3,
+0x25dc20,2,
+0x25dc40,1,
+0x260000,5,
+0x260020,4,
+0x260034,9,
+0x26005c,7,
+0x260080,1,
+0x2600a0,6,
+0x260100,5,
+0x260120,4,
+0x260134,9,
+0x26015c,7,
+0x260180,1,
+0x2601a0,6,
+0x260200,5,
+0x260220,4,
+0x260234,9,
+0x26025c,7,
+0x260280,1,
+0x2602a0,6,
+0x260300,5,
+0x260320,4,
+0x260334,9,
+0x26035c,7,
+0x260380,1,
+0x2603a0,6,
+0x260400,4,
+0x260440,4,
+0x260480,3,
+0x2604c0,3,
+0x260500,5,
+0x260518,8,
+0x260c00,13,
+0x260c40,11,
+0x260c80,13,
+0x260cc0,11,
+0x260d00,6,
+0x260d20,6,
+0x260e00,10,
+0x260e40,11,
+0x260e80,8,
+0x261000,2,
+0x261010,5,
+0x261040,3,
+0x261050,3,
+0x261060,7,
+0x261080,7,
+0x2610a0,7,
+0x2610c0,7,
+0x261100,7,
+0x261140,7,
+0x261180,5,
+0x26119c,9,
+0x261218,9,
+0x261240,3,
+0x261250,6,
+0x261280,1,
+0x261288,6,
+0x2612a4,1,
+0x2612c0,1,
+0x2612c8,6,
+0x2612e4,1,
+0x261400,8,
+0x261424,2,
+0x261500,3,
+0x261520,4,
+0x261540,3,
+0x261560,4,
+0x261800,24,
+0x261864,2,
+0x261880,6,
+0x261900,12,
+0x261940,6,
+0x261960,6,
+0x261980,4,
+0x2619c0,6,
+0x2619dc,1,
+0x261a00,6,
+0x261a1c,1,
+0x261a40,1,
+0x261a68,23,
+0x261b00,17,
+0x261b80,12,
+0x262000,5,
+0x262020,4,
+0x262034,9,
+0x26205c,7,
+0x262080,1,
+0x2620a0,6,
+0x262100,5,
+0x262120,4,
+0x262134,9,
+0x26215c,7,
+0x262180,1,
+0x2621a0,6,
+0x262200,5,
+0x262220,4,
+0x262234,9,
+0x26225c,7,
+0x262280,1,
+0x2622a0,6,
+0x262300,5,
+0x262320,4,
+0x262334,9,
+0x26235c,7,
+0x262380,1,
+0x2623a0,6,
+0x262400,4,
+0x262440,4,
+0x262480,3,
+0x2624c0,3,
+0x262500,5,
+0x262518,8,
+0x262c00,13,
+0x262c40,11,
+0x262c80,13,
+0x262cc0,11,
+0x262d00,6,
+0x262d20,6,
+0x262e00,10,
+0x262e40,11,
+0x262e80,8,
+0x263000,2,
+0x263010,5,
+0x263040,3,
+0x263050,3,
+0x263060,7,
+0x263080,7,
+0x2630a0,7,
+0x2630c0,7,
+0x263100,7,
+0x263140,7,
+0x263180,5,
+0x26319c,9,
+0x263218,9,
+0x263240,3,
+0x263250,6,
+0x263280,1,
+0x263288,6,
+0x2632a4,1,
+0x2632c0,1,
+0x2632c8,6,
+0x2632e4,1,
+0x263400,8,
+0x263424,2,
+0x263500,3,
+0x263520,4,
+0x263540,3,
+0x263560,4,
+0x263800,24,
+0x263864,2,
+0x263880,6,
+0x263900,12,
+0x263940,6,
+0x263960,6,
+0x263980,4,
+0x2639c0,6,
+0x2639dc,1,
+0x263a00,6,
+0x263a1c,1,
+0x263a40,1,
+0x263a68,23,
+0x263b00,17,
+0x263b80,12,
+0x264000,4,
+0x264014,6,
+0x264030,5,
+0x264080,4,
+0x264094,6,
+0x2640b0,5,
+0x264100,4,
+0x264114,6,
+0x264130,5,
+0x264180,4,
+0x264194,6,
+0x2641b0,5,
+0x264200,3,
+0x264210,23,
+0x264500,3,
+0x264510,12,
+0x264580,3,
+0x264590,12,
+0x264600,3,
+0x264610,12,
+0x264680,3,
+0x264690,12,
+0x264700,4,
+0x264718,13,
+0x264800,25,
+0x264880,25,
+0x264900,25,
+0x264980,25,
+0x264a00,17,
+0x264a50,3,
+0x264a60,3,
+0x265000,4,
+0x265014,6,
+0x265030,5,
+0x265080,4,
+0x265094,6,
+0x2650b0,5,
+0x265100,4,
+0x265114,6,
+0x265130,5,
+0x265180,4,
+0x265194,6,
+0x2651b0,5,
+0x265200,3,
+0x265210,23,
+0x265500,3,
+0x265510,12,
+0x265580,3,
+0x265590,12,
+0x265600,3,
+0x265610,12,
+0x265680,3,
+0x265690,12,
+0x265700,4,
+0x265718,13,
+0x265800,25,
+0x265880,25,
+0x265900,25,
+0x265980,25,
+0x265a00,17,
+0x265a50,3,
+0x265a60,3,
+0x266000,13,
+0x266040,22,
+0x2660a0,6,
+0x2660c0,3,
+0x266100,9,
+0x266400,2,
+0x26640c,6,
+0x266440,13,
+0x266480,16,
+0x266800,1,
+0x266808,3,
+0x26681c,8,
+0x266840,3,
+0x266850,3,
+0x266880,1,
+0x266888,3,
+0x26689c,8,
+0x2668c0,3,
+0x2668d0,3,
+0x266900,1,
+0x266908,3,
+0x26691c,8,
+0x266940,3,
+0x266950,3,
+0x266980,1,
+0x266988,3,
+0x26699c,8,
+0x2669c0,3,
+0x2669d0,3,
+0x266a00,1,
+0x266a08,3,
+0x266a1c,8,
+0x266a40,3,
+0x266a50,3,
+0x266a80,1,
+0x266a88,3,
+0x266a9c,8,
+0x266ac0,3,
+0x266ad0,3,
+0x266b00,1,
+0x266b08,3,
+0x266b1c,8,
+0x266b40,3,
+0x266b50,3,
+0x266b80,1,
+0x266b88,3,
+0x266b9c,8,
+0x266bc0,3,
+0x266bd0,3,
+0x266c00,1,
+0x266c08,3,
+0x266c1c,8,
+0x266c40,3,
+0x266c50,3,
+0x266c80,2,
+0x266c94,13,
+0x267000,6,
+0x267020,3,
+0x267034,1,
+0x267040,7,
+0x267060,6,
+0x267100,5,
+0x267138,1,
+0x267144,1,
+0x267400,1,
+0x267418,1,
+0x267434,1,
+0x26752c,5,
+0x267590,1,
+0x2675ac,1,
+0x2675d8,4,
+0x267600,8,
+0x268000,6,
+0x268020,3,
+0x268030,9,
+0x268080,6,
+0x268100,20,
+0x268400,1,
+0x268418,1,
+0x268434,1,
+0x26852c,4,
+0x268590,1,
+0x2685ac,1,
+0x2685d8,4,
+0x268600,8,
+0x269000,6,
+0x269020,6,
+0x269040,3,
+0x269080,14,
+0x2690bc,1,
+0x2690c4,13,
+0x2690fc,6,
+0x269120,5,
+0x269190,10,
+0x269200,16,
+0x269244,32,
+0x269300,26,
+0x269380,2,
+0x2693a0,1,
+0x2693c0,11,
+0x269404,4,
+0x269418,16,
+0x269460,3,
+0x269500,6,
+0x269540,1,
+0x269558,2,
+0x269600,17,
+0x269800,366,
+0x26a000,6,
+0x26a020,6,
+0x26a040,3,
+0x26a080,14,
+0x26a0bc,1,
+0x26a0c4,13,
+0x26a0fc,6,
+0x26a120,5,
+0x26a190,10,
+0x26a200,16,
+0x26a244,32,
+0x26a300,26,
+0x26a380,2,
+0x26a3a0,1,
+0x26a3c0,11,
+0x26a404,4,
+0x26a418,16,
+0x26a460,3,
+0x26a500,6,
+0x26a540,1,
+0x26a558,2,
+0x26a600,17,
+0x26a800,366,
+0x26b000,4,
+0x26b020,9,
+0x26b048,6,
+0x26b064,6,
+0x26b080,1,
+0x26b100,4,
+0x26b120,9,
+0x26b148,6,
+0x26b164,6,
+0x26b180,1,
+0x26b200,35,
+0x26b290,6,
+0x26b2b4,6,
+0x26b2d0,5,
+0x26b2e8,5,
+0x26b300,37,
+0x26b400,6,
+0x26b420,3,
+0x26b438,4,
+0x26b454,3,
+0x26b478,4,
+0x26b494,3,
+0x26b800,5,
+0x26b818,1,
+0x26b854,6,
+0x26b880,2,
+0x26b8a4,1,
+0x26ba00,28,
+0x26ba7c,5,
+0x26bab0,2,
+0x26babc,10,
+0x26bb00,2,
+0x26bb0c,7,
+0x26bb34,9,
+0x26bb60,6,
+0x26bb80,8,
+0x26bc00,5,
+0x26bc18,1,
+0x26bc54,6,
+0x26bc80,2,
+0x26bca4,1,
+0x26be00,28,
+0x26be7c,5,
+0x26beb0,2,
+0x26bebc,10,
+0x26bf00,2,
+0x26bf0c,7,
+0x26bf34,9,
+0x26bf60,6,
+0x26bf80,8,
+0x26c000,4,
+0x26c014,10,
+0x26c040,1,
+0x26c048,3,
+0x26c058,1,
+0x26c060,1,
+0x26c07c,1,
+0x26c500,1,
+0x26c518,2,
+0x26c540,6,
+0x26c800,4,
+0x26c814,10,
+0x26c840,1,
+0x26c848,3,
+0x26c858,1,
+0x26c860,1,
+0x26c87c,1,
+0x26cd00,1,
+0x26cd18,2,
+0x26cd40,6,
+0x26d800,2,
+0x26d818,2,
+0x26d834,2,
+0x26d92c,6,
+0x26d990,2,
+0x26d9ac,1,
+0x26d9d8,4,
+0x26da00,16,
+0x26dc00,3,
+0x26dc20,2,
+0x26dc40,1,
+0x270000,5,
+0x270020,4,
+0x270034,9,
+0x27005c,7,
+0x270080,1,
+0x2700a0,6,
+0x270100,5,
+0x270120,4,
+0x270134,9,
+0x27015c,7,
+0x270180,1,
+0x2701a0,6,
+0x270200,5,
+0x270220,4,
+0x270234,9,
+0x27025c,7,
+0x270280,1,
+0x2702a0,6,
+0x270300,5,
+0x270320,4,
+0x270334,9,
+0x27035c,7,
+0x270380,1,
+0x2703a0,6,
+0x270400,4,
+0x270440,4,
+0x270480,3,
+0x2704c0,3,
+0x270500,5,
+0x270518,8,
+0x270c00,13,
+0x270c40,11,
+0x270c80,13,
+0x270cc0,11,
+0x270d00,6,
+0x270d20,6,
+0x270e00,10,
+0x270e40,11,
+0x270e80,8,
+0x271000,2,
+0x271010,5,
+0x271040,3,
+0x271050,3,
+0x271060,7,
+0x271080,7,
+0x2710a0,7,
+0x2710c0,7,
+0x271100,7,
+0x271140,7,
+0x271180,5,
+0x27119c,9,
+0x271218,9,
+0x271240,3,
+0x271250,6,
+0x271280,1,
+0x271288,6,
+0x2712a4,1,
+0x2712c0,1,
+0x2712c8,6,
+0x2712e4,1,
+0x271400,8,
+0x271424,2,
+0x271500,3,
+0x271520,4,
+0x271540,3,
+0x271560,4,
+0x271800,24,
+0x271864,2,
+0x271880,6,
+0x271900,12,
+0x271940,6,
+0x271960,6,
+0x271980,4,
+0x2719c0,6,
+0x2719dc,1,
+0x271a00,6,
+0x271a1c,1,
+0x271a40,1,
+0x271a68,23,
+0x271b00,17,
+0x271b80,12,
+0x272000,5,
+0x272020,4,
+0x272034,9,
+0x27205c,7,
+0x272080,1,
+0x2720a0,6,
+0x272100,5,
+0x272120,4,
+0x272134,9,
+0x27215c,7,
+0x272180,1,
+0x2721a0,6,
+0x272200,5,
+0x272220,4,
+0x272234,9,
+0x27225c,7,
+0x272280,1,
+0x2722a0,6,
+0x272300,5,
+0x272320,4,
+0x272334,9,
+0x27235c,7,
+0x272380,1,
+0x2723a0,6,
+0x272400,4,
+0x272440,4,
+0x272480,3,
+0x2724c0,3,
+0x272500,5,
+0x272518,8,
+0x272c00,13,
+0x272c40,11,
+0x272c80,13,
+0x272cc0,11,
+0x272d00,6,
+0x272d20,6,
+0x272e00,10,
+0x272e40,11,
+0x272e80,8,
+0x273000,2,
+0x273010,5,
+0x273040,3,
+0x273050,3,
+0x273060,7,
+0x273080,7,
+0x2730a0,7,
+0x2730c0,7,
+0x273100,7,
+0x273140,7,
+0x273180,5,
+0x27319c,9,
+0x273218,9,
+0x273240,3,
+0x273250,6,
+0x273280,1,
+0x273288,6,
+0x2732a4,1,
+0x2732c0,1,
+0x2732c8,6,
+0x2732e4,1,
+0x273400,8,
+0x273424,2,
+0x273500,3,
+0x273520,4,
+0x273540,3,
+0x273560,4,
+0x273800,24,
+0x273864,2,
+0x273880,6,
+0x273900,12,
+0x273940,6,
+0x273960,6,
+0x273980,4,
+0x2739c0,6,
+0x2739dc,1,
+0x273a00,6,
+0x273a1c,1,
+0x273a40,1,
+0x273a68,23,
+0x273b00,17,
+0x273b80,12,
+0x274000,4,
+0x274014,6,
+0x274030,5,
+0x274080,4,
+0x274094,6,
+0x2740b0,5,
+0x274100,4,
+0x274114,6,
+0x274130,5,
+0x274180,4,
+0x274194,6,
+0x2741b0,5,
+0x274200,3,
+0x274210,23,
+0x274500,3,
+0x274510,12,
+0x274580,3,
+0x274590,12,
+0x274600,3,
+0x274610,12,
+0x274680,3,
+0x274690,12,
+0x274700,4,
+0x274718,13,
+0x274800,25,
+0x274880,25,
+0x274900,25,
+0x274980,25,
+0x274a00,17,
+0x274a50,3,
+0x274a60,3,
+0x275000,4,
+0x275014,6,
+0x275030,5,
+0x275080,4,
+0x275094,6,
+0x2750b0,5,
+0x275100,4,
+0x275114,6,
+0x275130,5,
+0x275180,4,
+0x275194,6,
+0x2751b0,5,
+0x275200,3,
+0x275210,23,
+0x275500,3,
+0x275510,12,
+0x275580,3,
+0x275590,12,
+0x275600,3,
+0x275610,12,
+0x275680,3,
+0x275690,12,
+0x275700,4,
+0x275718,13,
+0x275800,25,
+0x275880,25,
+0x275900,25,
+0x275980,25,
+0x275a00,17,
+0x275a50,3,
+0x275a60,3,
+0x276000,13,
+0x276040,22,
+0x2760a0,6,
+0x2760c0,3,
+0x276100,9,
+0x276400,2,
+0x27640c,6,
+0x276440,13,
+0x276480,16,
+0x276800,1,
+0x276808,3,
+0x27681c,8,
+0x276840,3,
+0x276850,3,
+0x276880,1,
+0x276888,3,
+0x27689c,8,
+0x2768c0,3,
+0x2768d0,3,
+0x276900,1,
+0x276908,3,
+0x27691c,8,
+0x276940,3,
+0x276950,3,
+0x276980,1,
+0x276988,3,
+0x27699c,8,
+0x2769c0,3,
+0x2769d0,3,
+0x276a00,1,
+0x276a08,3,
+0x276a1c,8,
+0x276a40,3,
+0x276a50,3,
+0x276a80,1,
+0x276a88,3,
+0x276a9c,8,
+0x276ac0,3,
+0x276ad0,3,
+0x276b00,1,
+0x276b08,3,
+0x276b1c,8,
+0x276b40,3,
+0x276b50,3,
+0x276b80,1,
+0x276b88,3,
+0x276b9c,8,
+0x276bc0,3,
+0x276bd0,3,
+0x276c00,1,
+0x276c08,3,
+0x276c1c,8,
+0x276c40,3,
+0x276c50,3,
+0x276c80,2,
+0x276c94,13,
+0x277000,6,
+0x277020,3,
+0x277034,1,
+0x277040,7,
+0x277060,6,
+0x277100,5,
+0x277138,1,
+0x277144,1,
+0x277400,1,
+0x277418,1,
+0x277434,1,
+0x27752c,5,
+0x277590,1,
+0x2775ac,1,
+0x2775d8,4,
+0x277600,8,
+0x278000,6,
+0x278020,3,
+0x278030,9,
+0x278080,6,
+0x278100,20,
+0x278400,1,
+0x278418,1,
+0x278434,1,
+0x27852c,4,
+0x278590,1,
+0x2785ac,1,
+0x2785d8,4,
+0x278600,8,
+0x279000,6,
+0x279020,6,
+0x279040,3,
+0x279080,14,
+0x2790bc,1,
+0x2790c4,13,
+0x2790fc,6,
+0x279120,5,
+0x279190,10,
+0x279200,16,
+0x279244,32,
+0x279300,26,
+0x279380,2,
+0x2793a0,1,
+0x2793c0,11,
+0x279404,4,
+0x279418,16,
+0x279460,3,
+0x279500,6,
+0x279540,1,
+0x279558,2,
+0x279600,17,
+0x279800,366,
+0x27a000,6,
+0x27a020,6,
+0x27a040,3,
+0x27a080,14,
+0x27a0bc,1,
+0x27a0c4,13,
+0x27a0fc,6,
+0x27a120,5,
+0x27a190,10,
+0x27a200,16,
+0x27a244,32,
+0x27a300,26,
+0x27a380,2,
+0x27a3a0,1,
+0x27a3c0,11,
+0x27a404,4,
+0x27a418,16,
+0x27a460,3,
+0x27a500,6,
+0x27a540,1,
+0x27a558,2,
+0x27a600,17,
+0x27a800,366,
+0x27b000,4,
+0x27b020,9,
+0x27b048,6,
+0x27b064,6,
+0x27b080,1,
+0x27b100,4,
+0x27b120,9,
+0x27b148,6,
+0x27b164,6,
+0x27b180,1,
+0x27b200,35,
+0x27b290,6,
+0x27b2b4,6,
+0x27b2d0,5,
+0x27b2e8,5,
+0x27b300,37,
+0x27b400,6,
+0x27b420,3,
+0x27b438,4,
+0x27b454,3,
+0x27b478,4,
+0x27b494,3,
+0x27b800,5,
+0x27b818,1,
+0x27b854,6,
+0x27b880,2,
+0x27b8a4,1,
+0x27ba00,28,
+0x27ba7c,5,
+0x27bab0,2,
+0x27babc,10,
+0x27bb00,2,
+0x27bb0c,7,
+0x27bb34,9,
+0x27bb60,6,
+0x27bb80,8,
+0x27bc00,5,
+0x27bc18,1,
+0x27bc54,6,
+0x27bc80,2,
+0x27bca4,1,
+0x27be00,28,
+0x27be7c,5,
+0x27beb0,2,
+0x27bebc,10,
+0x27bf00,2,
+0x27bf0c,7,
+0x27bf34,9,
+0x27bf60,6,
+0x27bf80,8,
+0x27c000,4,
+0x27c014,10,
+0x27c040,1,
+0x27c048,3,
+0x27c058,1,
+0x27c060,1,
+0x27c07c,1,
+0x27c500,1,
+0x27c518,2,
+0x27c540,6,
+0x27c800,4,
+0x27c814,10,
+0x27c840,1,
+0x27c848,3,
+0x27c858,1,
+0x27c860,1,
+0x27c87c,1,
+0x27cd00,1,
+0x27cd18,2,
+0x27cd40,6,
+0x27d800,2,
+0x27d818,2,
+0x27d834,2,
+0x27d92c,6,
+0x27d990,2,
+0x27d9ac,1,
+0x27d9d8,4,
+0x27da00,16,
+0x27dc00,3,
+0x27dc20,2,
+0x27dc40,1,
+0x280000,5,
+0x280020,4,
+0x280034,9,
+0x28005c,7,
+0x280080,1,
+0x2800a0,6,
+0x280100,5,
+0x280120,4,
+0x280134,9,
+0x28015c,7,
+0x280180,1,
+0x2801a0,6,
+0x280200,5,
+0x280220,4,
+0x280234,9,
+0x28025c,7,
+0x280280,1,
+0x2802a0,6,
+0x280300,5,
+0x280320,4,
+0x280334,9,
+0x28035c,7,
+0x280380,1,
+0x2803a0,6,
+0x280400,4,
+0x280440,4,
+0x280480,3,
+0x2804c0,3,
+0x280500,5,
+0x280518,8,
+0x280c00,13,
+0x280c40,11,
+0x280c80,13,
+0x280cc0,11,
+0x280d00,6,
+0x280d20,6,
+0x280e00,10,
+0x280e40,11,
+0x280e80,8,
+0x281000,2,
+0x281010,5,
+0x281040,3,
+0x281050,3,
+0x281060,7,
+0x281080,7,
+0x2810a0,7,
+0x2810c0,7,
+0x281100,7,
+0x281140,7,
+0x281180,5,
+0x28119c,9,
+0x281218,9,
+0x281240,3,
+0x281250,6,
+0x281280,1,
+0x281288,6,
+0x2812a4,1,
+0x2812c0,1,
+0x2812c8,6,
+0x2812e4,1,
+0x281400,8,
+0x281424,2,
+0x281500,3,
+0x281520,4,
+0x281540,3,
+0x281560,4,
+0x281800,24,
+0x281864,2,
+0x281880,6,
+0x281900,12,
+0x281940,6,
+0x281960,6,
+0x281980,4,
+0x2819c0,6,
+0x2819dc,1,
+0x281a00,6,
+0x281a1c,1,
+0x281a40,1,
+0x281a68,23,
+0x281b00,17,
+0x281b80,12,
+0x282000,5,
+0x282020,4,
+0x282034,9,
+0x28205c,7,
+0x282080,1,
+0x2820a0,6,
+0x282100,5,
+0x282120,4,
+0x282134,9,
+0x28215c,7,
+0x282180,1,
+0x2821a0,6,
+0x282200,5,
+0x282220,4,
+0x282234,9,
+0x28225c,7,
+0x282280,1,
+0x2822a0,6,
+0x282300,5,
+0x282320,4,
+0x282334,9,
+0x28235c,7,
+0x282380,1,
+0x2823a0,6,
+0x282400,4,
+0x282440,4,
+0x282480,3,
+0x2824c0,3,
+0x282500,5,
+0x282518,8,
+0x282c00,13,
+0x282c40,11,
+0x282c80,13,
+0x282cc0,11,
+0x282d00,6,
+0x282d20,6,
+0x282e00,10,
+0x282e40,11,
+0x282e80,8,
+0x283000,2,
+0x283010,5,
+0x283040,3,
+0x283050,3,
+0x283060,7,
+0x283080,7,
+0x2830a0,7,
+0x2830c0,7,
+0x283100,7,
+0x283140,7,
+0x283180,5,
+0x28319c,9,
+0x283218,9,
+0x283240,3,
+0x283250,6,
+0x283280,1,
+0x283288,6,
+0x2832a4,1,
+0x2832c0,1,
+0x2832c8,6,
+0x2832e4,1,
+0x283400,8,
+0x283424,2,
+0x283500,3,
+0x283520,4,
+0x283540,3,
+0x283560,4,
+0x283800,24,
+0x283864,2,
+0x283880,6,
+0x283900,12,
+0x283940,6,
+0x283960,6,
+0x283980,4,
+0x2839c0,6,
+0x2839dc,1,
+0x283a00,6,
+0x283a1c,1,
+0x283a40,1,
+0x283a68,23,
+0x283b00,17,
+0x283b80,12,
+0x284000,4,
+0x284014,6,
+0x284030,5,
+0x284080,4,
+0x284094,6,
+0x2840b0,5,
+0x284100,4,
+0x284114,6,
+0x284130,5,
+0x284180,4,
+0x284194,6,
+0x2841b0,5,
+0x284200,3,
+0x284210,23,
+0x284500,3,
+0x284510,12,
+0x284580,3,
+0x284590,12,
+0x284600,3,
+0x284610,12,
+0x284680,3,
+0x284690,12,
+0x284700,4,
+0x284718,13,
+0x284800,25,
+0x284880,25,
+0x284900,25,
+0x284980,25,
+0x284a00,17,
+0x284a50,3,
+0x284a60,3,
+0x285000,4,
+0x285014,6,
+0x285030,5,
+0x285080,4,
+0x285094,6,
+0x2850b0,5,
+0x285100,4,
+0x285114,6,
+0x285130,5,
+0x285180,4,
+0x285194,6,
+0x2851b0,5,
+0x285200,3,
+0x285210,23,
+0x285500,3,
+0x285510,12,
+0x285580,3,
+0x285590,12,
+0x285600,3,
+0x285610,12,
+0x285680,3,
+0x285690,12,
+0x285700,4,
+0x285718,13,
+0x285800,25,
+0x285880,25,
+0x285900,25,
+0x285980,25,
+0x285a00,17,
+0x285a50,3,
+0x285a60,3,
+0x286000,13,
+0x286040,22,
+0x2860a0,6,
+0x2860c0,3,
+0x286100,9,
+0x286400,2,
+0x28640c,6,
+0x286440,13,
+0x286480,16,
+0x286800,1,
+0x286808,3,
+0x28681c,8,
+0x286840,3,
+0x286850,3,
+0x286880,1,
+0x286888,3,
+0x28689c,8,
+0x2868c0,3,
+0x2868d0,3,
+0x286900,1,
+0x286908,3,
+0x28691c,8,
+0x286940,3,
+0x286950,3,
+0x286980,1,
+0x286988,3,
+0x28699c,8,
+0x2869c0,3,
+0x2869d0,3,
+0x286a00,1,
+0x286a08,3,
+0x286a1c,8,
+0x286a40,3,
+0x286a50,3,
+0x286a80,1,
+0x286a88,3,
+0x286a9c,8,
+0x286ac0,3,
+0x286ad0,3,
+0x286b00,1,
+0x286b08,3,
+0x286b1c,8,
+0x286b40,3,
+0x286b50,3,
+0x286b80,1,
+0x286b88,3,
+0x286b9c,8,
+0x286bc0,3,
+0x286bd0,3,
+0x286c00,1,
+0x286c08,3,
+0x286c1c,8,
+0x286c40,3,
+0x286c50,3,
+0x286c80,2,
+0x286c94,13,
+0x287000,6,
+0x287020,3,
+0x287034,1,
+0x287040,7,
+0x287060,6,
+0x287100,5,
+0x287138,1,
+0x287144,1,
+0x287400,1,
+0x287418,1,
+0x287434,1,
+0x28752c,5,
+0x287590,1,
+0x2875ac,1,
+0x2875d8,4,
+0x287600,8,
+0x288000,6,
+0x288020,3,
+0x288030,9,
+0x288080,6,
+0x288100,20,
+0x288400,1,
+0x288418,1,
+0x288434,1,
+0x28852c,4,
+0x288590,1,
+0x2885ac,1,
+0x2885d8,4,
+0x288600,8,
+0x289000,6,
+0x289020,6,
+0x289040,3,
+0x289080,14,
+0x2890bc,1,
+0x2890c4,13,
+0x2890fc,6,
+0x289120,5,
+0x289190,10,
+0x289200,16,
+0x289244,32,
+0x289300,26,
+0x289380,2,
+0x2893a0,1,
+0x2893c0,11,
+0x289404,4,
+0x289418,16,
+0x289460,3,
+0x289500,6,
+0x289540,1,
+0x289558,2,
+0x289600,17,
+0x289800,366,
+0x28a000,6,
+0x28a020,6,
+0x28a040,3,
+0x28a080,14,
+0x28a0bc,1,
+0x28a0c4,13,
+0x28a0fc,6,
+0x28a120,5,
+0x28a190,10,
+0x28a200,16,
+0x28a244,32,
+0x28a300,26,
+0x28a380,2,
+0x28a3a0,1,
+0x28a3c0,11,
+0x28a404,4,
+0x28a418,16,
+0x28a460,3,
+0x28a500,6,
+0x28a540,1,
+0x28a558,2,
+0x28a600,17,
+0x28a800,366,
+0x28b000,4,
+0x28b020,9,
+0x28b048,6,
+0x28b064,6,
+0x28b080,1,
+0x28b100,4,
+0x28b120,9,
+0x28b148,6,
+0x28b164,6,
+0x28b180,1,
+0x28b200,35,
+0x28b290,6,
+0x28b2b4,6,
+0x28b2d0,5,
+0x28b2e8,5,
+0x28b300,37,
+0x28b400,6,
+0x28b420,3,
+0x28b438,4,
+0x28b454,3,
+0x28b478,4,
+0x28b494,3,
+0x28b800,5,
+0x28b818,1,
+0x28b854,6,
+0x28b880,2,
+0x28b8a4,1,
+0x28ba00,28,
+0x28ba7c,5,
+0x28bab0,2,
+0x28babc,10,
+0x28bb00,2,
+0x28bb0c,7,
+0x28bb34,9,
+0x28bb60,6,
+0x28bb80,8,
+0x28bc00,5,
+0x28bc18,1,
+0x28bc54,6,
+0x28bc80,2,
+0x28bca4,1,
+0x28be00,28,
+0x28be7c,5,
+0x28beb0,2,
+0x28bebc,10,
+0x28bf00,2,
+0x28bf0c,7,
+0x28bf34,9,
+0x28bf60,6,
+0x28bf80,8,
+0x28c000,4,
+0x28c014,10,
+0x28c040,1,
+0x28c048,3,
+0x28c058,1,
+0x28c060,1,
+0x28c07c,1,
+0x28c500,1,
+0x28c518,2,
+0x28c540,6,
+0x28c800,4,
+0x28c814,10,
+0x28c840,1,
+0x28c848,3,
+0x28c858,1,
+0x28c860,1,
+0x28c87c,1,
+0x28cd00,1,
+0x28cd18,2,
+0x28cd40,6,
+0x28d800,2,
+0x28d818,2,
+0x28d834,2,
+0x28d92c,6,
+0x28d990,2,
+0x28d9ac,1,
+0x28d9d8,4,
+0x28da00,16,
+0x28dc00,3,
+0x28dc20,2,
+0x28dc40,1,
+0x290000,5,
+0x290020,4,
+0x290034,9,
+0x29005c,7,
+0x290080,1,
+0x2900a0,6,
+0x290100,5,
+0x290120,4,
+0x290134,9,
+0x29015c,7,
+0x290180,1,
+0x2901a0,6,
+0x290200,5,
+0x290220,4,
+0x290234,9,
+0x29025c,7,
+0x290280,1,
+0x2902a0,6,
+0x290300,5,
+0x290320,4,
+0x290334,9,
+0x29035c,7,
+0x290380,1,
+0x2903a0,6,
+0x290400,4,
+0x290440,4,
+0x290480,3,
+0x2904c0,3,
+0x290500,5,
+0x290518,8,
+0x290c00,13,
+0x290c40,11,
+0x290c80,13,
+0x290cc0,11,
+0x290d00,6,
+0x290d20,6,
+0x290e00,10,
+0x290e40,11,
+0x290e80,8,
+0x291000,2,
+0x291010,5,
+0x291040,3,
+0x291050,3,
+0x291060,7,
+0x291080,7,
+0x2910a0,7,
+0x2910c0,7,
+0x291100,7,
+0x291140,7,
+0x291180,5,
+0x29119c,9,
+0x291218,9,
+0x291240,3,
+0x291250,6,
+0x291280,1,
+0x291288,6,
+0x2912a4,1,
+0x2912c0,1,
+0x2912c8,6,
+0x2912e4,1,
+0x291400,8,
+0x291424,2,
+0x291500,3,
+0x291520,4,
+0x291540,3,
+0x291560,4,
+0x291800,24,
+0x291864,2,
+0x291880,6,
+0x291900,12,
+0x291940,6,
+0x291960,6,
+0x291980,4,
+0x2919c0,6,
+0x2919dc,1,
+0x291a00,6,
+0x291a1c,1,
+0x291a40,1,
+0x291a68,23,
+0x291b00,17,
+0x291b80,12,
+0x292000,5,
+0x292020,4,
+0x292034,9,
+0x29205c,7,
+0x292080,1,
+0x2920a0,6,
+0x292100,5,
+0x292120,4,
+0x292134,9,
+0x29215c,7,
+0x292180,1,
+0x2921a0,6,
+0x292200,5,
+0x292220,4,
+0x292234,9,
+0x29225c,7,
+0x292280,1,
+0x2922a0,6,
+0x292300,5,
+0x292320,4,
+0x292334,9,
+0x29235c,7,
+0x292380,1,
+0x2923a0,6,
+0x292400,4,
+0x292440,4,
+0x292480,3,
+0x2924c0,3,
+0x292500,5,
+0x292518,8,
+0x292c00,13,
+0x292c40,11,
+0x292c80,13,
+0x292cc0,11,
+0x292d00,6,
+0x292d20,6,
+0x292e00,10,
+0x292e40,11,
+0x292e80,8,
+0x293000,2,
+0x293010,5,
+0x293040,3,
+0x293050,3,
+0x293060,7,
+0x293080,7,
+0x2930a0,7,
+0x2930c0,7,
+0x293100,7,
+0x293140,7,
+0x293180,5,
+0x29319c,9,
+0x293218,9,
+0x293240,3,
+0x293250,6,
+0x293280,1,
+0x293288,6,
+0x2932a4,1,
+0x2932c0,1,
+0x2932c8,6,
+0x2932e4,1,
+0x293400,8,
+0x293424,2,
+0x293500,3,
+0x293520,4,
+0x293540,3,
+0x293560,4,
+0x293800,24,
+0x293864,2,
+0x293880,6,
+0x293900,12,
+0x293940,6,
+0x293960,6,
+0x293980,4,
+0x2939c0,6,
+0x2939dc,1,
+0x293a00,6,
+0x293a1c,1,
+0x293a40,1,
+0x293a68,23,
+0x293b00,17,
+0x293b80,12,
+0x294000,4,
+0x294014,6,
+0x294030,5,
+0x294080,4,
+0x294094,6,
+0x2940b0,5,
+0x294100,4,
+0x294114,6,
+0x294130,5,
+0x294180,4,
+0x294194,6,
+0x2941b0,5,
+0x294200,3,
+0x294210,23,
+0x294500,3,
+0x294510,12,
+0x294580,3,
+0x294590,12,
+0x294600,3,
+0x294610,12,
+0x294680,3,
+0x294690,12,
+0x294700,4,
+0x294718,13,
+0x294800,25,
+0x294880,25,
+0x294900,25,
+0x294980,25,
+0x294a00,17,
+0x294a50,3,
+0x294a60,3,
+0x295000,4,
+0x295014,6,
+0x295030,5,
+0x295080,4,
+0x295094,6,
+0x2950b0,5,
+0x295100,4,
+0x295114,6,
+0x295130,5,
+0x295180,4,
+0x295194,6,
+0x2951b0,5,
+0x295200,3,
+0x295210,23,
+0x295500,3,
+0x295510,12,
+0x295580,3,
+0x295590,12,
+0x295600,3,
+0x295610,12,
+0x295680,3,
+0x295690,12,
+0x295700,4,
+0x295718,13,
+0x295800,25,
+0x295880,25,
+0x295900,25,
+0x295980,25,
+0x295a00,17,
+0x295a50,3,
+0x295a60,3,
+0x296000,13,
+0x296040,22,
+0x2960a0,6,
+0x2960c0,3,
+0x296100,9,
+0x296400,2,
+0x29640c,6,
+0x296440,13,
+0x296480,16,
+0x296800,1,
+0x296808,3,
+0x29681c,8,
+0x296840,3,
+0x296850,3,
+0x296880,1,
+0x296888,3,
+0x29689c,8,
+0x2968c0,3,
+0x2968d0,3,
+0x296900,1,
+0x296908,3,
+0x29691c,8,
+0x296940,3,
+0x296950,3,
+0x296980,1,
+0x296988,3,
+0x29699c,8,
+0x2969c0,3,
+0x2969d0,3,
+0x296a00,1,
+0x296a08,3,
+0x296a1c,8,
+0x296a40,3,
+0x296a50,3,
+0x296a80,1,
+0x296a88,3,
+0x296a9c,8,
+0x296ac0,3,
+0x296ad0,3,
+0x296b00,1,
+0x296b08,3,
+0x296b1c,8,
+0x296b40,3,
+0x296b50,3,
+0x296b80,1,
+0x296b88,3,
+0x296b9c,8,
+0x296bc0,3,
+0x296bd0,3,
+0x296c00,1,
+0x296c08,3,
+0x296c1c,8,
+0x296c40,3,
+0x296c50,3,
+0x296c80,2,
+0x296c94,13,
+0x297000,6,
+0x297020,3,
+0x297034,1,
+0x297040,7,
+0x297060,6,
+0x297100,5,
+0x297138,1,
+0x297144,1,
+0x297400,1,
+0x297418,1,
+0x297434,1,
+0x29752c,5,
+0x297590,1,
+0x2975ac,1,
+0x2975d8,4,
+0x297600,8,
+0x298000,6,
+0x298020,3,
+0x298030,9,
+0x298080,6,
+0x298100,20,
+0x298400,1,
+0x298418,1,
+0x298434,1,
+0x29852c,4,
+0x298590,1,
+0x2985ac,1,
+0x2985d8,4,
+0x298600,8,
+0x299000,6,
+0x299020,6,
+0x299040,3,
+0x299080,14,
+0x2990bc,1,
+0x2990c4,13,
+0x2990fc,6,
+0x299120,5,
+0x299190,10,
+0x299200,16,
+0x299244,32,
+0x299300,26,
+0x299380,2,
+0x2993a0,1,
+0x2993c0,11,
+0x299404,4,
+0x299418,16,
+0x299460,3,
+0x299500,6,
+0x299540,1,
+0x299558,2,
+0x299600,17,
+0x299800,366,
+0x29a000,6,
+0x29a020,6,
+0x29a040,3,
+0x29a080,14,
+0x29a0bc,1,
+0x29a0c4,13,
+0x29a0fc,6,
+0x29a120,5,
+0x29a190,10,
+0x29a200,16,
+0x29a244,32,
+0x29a300,26,
+0x29a380,2,
+0x29a3a0,1,
+0x29a3c0,11,
+0x29a404,4,
+0x29a418,16,
+0x29a460,3,
+0x29a500,6,
+0x29a540,1,
+0x29a558,2,
+0x29a600,17,
+0x29a800,366,
+0x29b000,4,
+0x29b020,9,
+0x29b048,6,
+0x29b064,6,
+0x29b080,1,
+0x29b100,4,
+0x29b120,9,
+0x29b148,6,
+0x29b164,6,
+0x29b180,1,
+0x29b200,35,
+0x29b290,6,
+0x29b2b4,6,
+0x29b2d0,5,
+0x29b2e8,5,
+0x29b300,37,
+0x29b400,6,
+0x29b420,3,
+0x29b438,4,
+0x29b454,3,
+0x29b478,4,
+0x29b494,3,
+0x29b800,5,
+0x29b818,1,
+0x29b854,6,
+0x29b880,2,
+0x29b8a4,1,
+0x29ba00,28,
+0x29ba7c,5,
+0x29bab0,2,
+0x29babc,10,
+0x29bb00,2,
+0x29bb0c,7,
+0x29bb34,9,
+0x29bb60,6,
+0x29bb80,8,
+0x29bc00,5,
+0x29bc18,1,
+0x29bc54,6,
+0x29bc80,2,
+0x29bca4,1,
+0x29be00,28,
+0x29be7c,5,
+0x29beb0,2,
+0x29bebc,10,
+0x29bf00,2,
+0x29bf0c,7,
+0x29bf34,9,
+0x29bf60,6,
+0x29bf80,8,
+0x29c000,4,
+0x29c014,10,
+0x29c040,1,
+0x29c048,3,
+0x29c058,1,
+0x29c060,1,
+0x29c07c,1,
+0x29c500,1,
+0x29c518,2,
+0x29c540,6,
+0x29c800,4,
+0x29c814,10,
+0x29c840,1,
+0x29c848,3,
+0x29c858,1,
+0x29c860,1,
+0x29c87c,1,
+0x29cd00,1,
+0x29cd18,2,
+0x29cd40,6,
+0x29d800,2,
+0x29d818,2,
+0x29d834,2,
+0x29d92c,6,
+0x29d990,2,
+0x29d9ac,1,
+0x29d9d8,4,
+0x29da00,16,
+0x29dc00,3,
+0x29dc20,2,
+0x29dc40,1,
+0x2a0000,5,
+0x2a0020,4,
+0x2a0034,9,
+0x2a005c,7,
+0x2a0080,1,
+0x2a00a0,6,
+0x2a0100,5,
+0x2a0120,4,
+0x2a0134,9,
+0x2a015c,7,
+0x2a0180,1,
+0x2a01a0,6,
+0x2a0200,5,
+0x2a0220,4,
+0x2a0234,9,
+0x2a025c,7,
+0x2a0280,1,
+0x2a02a0,6,
+0x2a0300,5,
+0x2a0320,4,
+0x2a0334,9,
+0x2a035c,7,
+0x2a0380,1,
+0x2a03a0,6,
+0x2a0400,4,
+0x2a0440,4,
+0x2a0480,3,
+0x2a04c0,3,
+0x2a0500,5,
+0x2a0518,8,
+0x2a0c00,13,
+0x2a0c40,11,
+0x2a0c80,13,
+0x2a0cc0,11,
+0x2a0d00,6,
+0x2a0d20,6,
+0x2a0e00,10,
+0x2a0e40,11,
+0x2a0e80,8,
+0x2a1000,2,
+0x2a1010,5,
+0x2a1040,3,
+0x2a1050,3,
+0x2a1060,7,
+0x2a1080,7,
+0x2a10a0,7,
+0x2a10c0,7,
+0x2a1100,7,
+0x2a1140,7,
+0x2a1180,5,
+0x2a119c,9,
+0x2a1218,9,
+0x2a1240,3,
+0x2a1250,6,
+0x2a1280,1,
+0x2a1288,6,
+0x2a12a4,1,
+0x2a12c0,1,
+0x2a12c8,6,
+0x2a12e4,1,
+0x2a1400,8,
+0x2a1424,2,
+0x2a1500,3,
+0x2a1520,4,
+0x2a1540,3,
+0x2a1560,4,
+0x2a1800,24,
+0x2a1864,2,
+0x2a1880,6,
+0x2a1900,12,
+0x2a1940,6,
+0x2a1960,6,
+0x2a1980,4,
+0x2a19c0,6,
+0x2a19dc,1,
+0x2a1a00,6,
+0x2a1a1c,1,
+0x2a1a40,1,
+0x2a1a68,23,
+0x2a1b00,17,
+0x2a1b80,12,
+0x2a2000,5,
+0x2a2020,4,
+0x2a2034,9,
+0x2a205c,7,
+0x2a2080,1,
+0x2a20a0,6,
+0x2a2100,5,
+0x2a2120,4,
+0x2a2134,9,
+0x2a215c,7,
+0x2a2180,1,
+0x2a21a0,6,
+0x2a2200,5,
+0x2a2220,4,
+0x2a2234,9,
+0x2a225c,7,
+0x2a2280,1,
+0x2a22a0,6,
+0x2a2300,5,
+0x2a2320,4,
+0x2a2334,9,
+0x2a235c,7,
+0x2a2380,1,
+0x2a23a0,6,
+0x2a2400,4,
+0x2a2440,4,
+0x2a2480,3,
+0x2a24c0,3,
+0x2a2500,5,
+0x2a2518,8,
+0x2a2c00,13,
+0x2a2c40,11,
+0x2a2c80,13,
+0x2a2cc0,11,
+0x2a2d00,6,
+0x2a2d20,6,
+0x2a2e00,10,
+0x2a2e40,11,
+0x2a2e80,8,
+0x2a3000,2,
+0x2a3010,5,
+0x2a3040,3,
+0x2a3050,3,
+0x2a3060,7,
+0x2a3080,7,
+0x2a30a0,7,
+0x2a30c0,7,
+0x2a3100,7,
+0x2a3140,7,
+0x2a3180,5,
+0x2a319c,9,
+0x2a3218,9,
+0x2a3240,3,
+0x2a3250,6,
+0x2a3280,1,
+0x2a3288,6,
+0x2a32a4,1,
+0x2a32c0,1,
+0x2a32c8,6,
+0x2a32e4,1,
+0x2a3400,8,
+0x2a3424,2,
+0x2a3500,3,
+0x2a3520,4,
+0x2a3540,3,
+0x2a3560,4,
+0x2a3800,24,
+0x2a3864,2,
+0x2a3880,6,
+0x2a3900,12,
+0x2a3940,6,
+0x2a3960,6,
+0x2a3980,4,
+0x2a39c0,6,
+0x2a39dc,1,
+0x2a3a00,6,
+0x2a3a1c,1,
+0x2a3a40,1,
+0x2a3a68,23,
+0x2a3b00,17,
+0x2a3b80,12,
+0x2a4000,4,
+0x2a4014,6,
+0x2a4030,5,
+0x2a4080,4,
+0x2a4094,6,
+0x2a40b0,5,
+0x2a4100,4,
+0x2a4114,6,
+0x2a4130,5,
+0x2a4180,4,
+0x2a4194,6,
+0x2a41b0,5,
+0x2a4200,3,
+0x2a4210,23,
+0x2a4500,3,
+0x2a4510,12,
+0x2a4580,3,
+0x2a4590,12,
+0x2a4600,3,
+0x2a4610,12,
+0x2a4680,3,
+0x2a4690,12,
+0x2a4700,4,
+0x2a4718,13,
+0x2a4800,25,
+0x2a4880,25,
+0x2a4900,25,
+0x2a4980,25,
+0x2a4a00,17,
+0x2a4a50,3,
+0x2a4a60,3,
+0x2a5000,4,
+0x2a5014,6,
+0x2a5030,5,
+0x2a5080,4,
+0x2a5094,6,
+0x2a50b0,5,
+0x2a5100,4,
+0x2a5114,6,
+0x2a5130,5,
+0x2a5180,4,
+0x2a5194,6,
+0x2a51b0,5,
+0x2a5200,3,
+0x2a5210,23,
+0x2a5500,3,
+0x2a5510,12,
+0x2a5580,3,
+0x2a5590,12,
+0x2a5600,3,
+0x2a5610,12,
+0x2a5680,3,
+0x2a5690,12,
+0x2a5700,4,
+0x2a5718,13,
+0x2a5800,25,
+0x2a5880,25,
+0x2a5900,25,
+0x2a5980,25,
+0x2a5a00,17,
+0x2a5a50,3,
+0x2a5a60,3,
+0x2a6000,13,
+0x2a6040,22,
+0x2a60a0,6,
+0x2a60c0,3,
+0x2a6100,9,
+0x2a6400,2,
+0x2a640c,6,
+0x2a6440,13,
+0x2a6480,16,
+0x2a6800,1,
+0x2a6808,3,
+0x2a681c,8,
+0x2a6840,3,
+0x2a6850,3,
+0x2a6880,1,
+0x2a6888,3,
+0x2a689c,8,
+0x2a68c0,3,
+0x2a68d0,3,
+0x2a6900,1,
+0x2a6908,3,
+0x2a691c,8,
+0x2a6940,3,
+0x2a6950,3,
+0x2a6980,1,
+0x2a6988,3,
+0x2a699c,8,
+0x2a69c0,3,
+0x2a69d0,3,
+0x2a6a00,1,
+0x2a6a08,3,
+0x2a6a1c,8,
+0x2a6a40,3,
+0x2a6a50,3,
+0x2a6a80,1,
+0x2a6a88,3,
+0x2a6a9c,8,
+0x2a6ac0,3,
+0x2a6ad0,3,
+0x2a6b00,1,
+0x2a6b08,3,
+0x2a6b1c,8,
+0x2a6b40,3,
+0x2a6b50,3,
+0x2a6b80,1,
+0x2a6b88,3,
+0x2a6b9c,8,
+0x2a6bc0,3,
+0x2a6bd0,3,
+0x2a6c00,1,
+0x2a6c08,3,
+0x2a6c1c,8,
+0x2a6c40,3,
+0x2a6c50,3,
+0x2a6c80,2,
+0x2a6c94,13,
+0x2a7000,6,
+0x2a7020,3,
+0x2a7034,1,
+0x2a7040,7,
+0x2a7060,6,
+0x2a7100,5,
+0x2a7138,1,
+0x2a7144,1,
+0x2a7400,1,
+0x2a7418,1,
+0x2a7434,1,
+0x2a752c,5,
+0x2a7590,1,
+0x2a75ac,1,
+0x2a75d8,4,
+0x2a7600,8,
+0x2a8000,6,
+0x2a8020,3,
+0x2a8030,9,
+0x2a8080,6,
+0x2a8100,20,
+0x2a8400,1,
+0x2a8418,1,
+0x2a8434,1,
+0x2a852c,4,
+0x2a8590,1,
+0x2a85ac,1,
+0x2a85d8,4,
+0x2a8600,8,
+0x2a9000,6,
+0x2a9020,6,
+0x2a9040,3,
+0x2a9080,14,
+0x2a90bc,1,
+0x2a90c4,13,
+0x2a90fc,6,
+0x2a9120,5,
+0x2a9190,10,
+0x2a9200,16,
+0x2a9244,32,
+0x2a9300,26,
+0x2a9380,2,
+0x2a93a0,1,
+0x2a93c0,11,
+0x2a9404,4,
+0x2a9418,16,
+0x2a9460,3,
+0x2a9500,6,
+0x2a9540,1,
+0x2a9558,2,
+0x2a9600,17,
+0x2a9800,366,
+0x2aa000,6,
+0x2aa020,6,
+0x2aa040,3,
+0x2aa080,14,
+0x2aa0bc,1,
+0x2aa0c4,13,
+0x2aa0fc,6,
+0x2aa120,5,
+0x2aa190,10,
+0x2aa200,16,
+0x2aa244,32,
+0x2aa300,26,
+0x2aa380,2,
+0x2aa3a0,1,
+0x2aa3c0,11,
+0x2aa404,4,
+0x2aa418,16,
+0x2aa460,3,
+0x2aa500,6,
+0x2aa540,1,
+0x2aa558,2,
+0x2aa600,17,
+0x2aa800,366,
+0x2ab000,4,
+0x2ab020,9,
+0x2ab048,6,
+0x2ab064,6,
+0x2ab080,1,
+0x2ab100,4,
+0x2ab120,9,
+0x2ab148,6,
+0x2ab164,6,
+0x2ab180,1,
+0x2ab200,35,
+0x2ab290,6,
+0x2ab2b4,6,
+0x2ab2d0,5,
+0x2ab2e8,5,
+0x2ab300,37,
+0x2ab400,6,
+0x2ab420,3,
+0x2ab438,4,
+0x2ab454,3,
+0x2ab478,4,
+0x2ab494,3,
+0x2ab800,5,
+0x2ab818,1,
+0x2ab854,6,
+0x2ab880,2,
+0x2ab8a4,1,
+0x2aba00,28,
+0x2aba7c,5,
+0x2abab0,2,
+0x2ababc,10,
+0x2abb00,2,
+0x2abb0c,7,
+0x2abb34,9,
+0x2abb60,6,
+0x2abb80,8,
+0x2abc00,5,
+0x2abc18,1,
+0x2abc54,6,
+0x2abc80,2,
+0x2abca4,1,
+0x2abe00,28,
+0x2abe7c,5,
+0x2abeb0,2,
+0x2abebc,10,
+0x2abf00,2,
+0x2abf0c,7,
+0x2abf34,9,
+0x2abf60,6,
+0x2abf80,8,
+0x2ac000,4,
+0x2ac014,10,
+0x2ac040,1,
+0x2ac048,3,
+0x2ac058,1,
+0x2ac060,1,
+0x2ac07c,1,
+0x2ac500,1,
+0x2ac518,2,
+0x2ac540,6,
+0x2ac800,4,
+0x2ac814,10,
+0x2ac840,1,
+0x2ac848,3,
+0x2ac858,1,
+0x2ac860,1,
+0x2ac87c,1,
+0x2acd00,1,
+0x2acd18,2,
+0x2acd40,6,
+0x2ad800,2,
+0x2ad818,2,
+0x2ad834,2,
+0x2ad92c,6,
+0x2ad990,2,
+0x2ad9ac,1,
+0x2ad9d8,4,
+0x2ada00,16,
+0x2adc00,3,
+0x2adc20,2,
+0x2adc40,1,
+0x2b0000,5,
+0x2b0020,4,
+0x2b0034,9,
+0x2b005c,7,
+0x2b0080,1,
+0x2b00a0,6,
+0x2b0100,5,
+0x2b0120,4,
+0x2b0134,9,
+0x2b015c,7,
+0x2b0180,1,
+0x2b01a0,6,
+0x2b0200,5,
+0x2b0220,4,
+0x2b0234,9,
+0x2b025c,7,
+0x2b0280,1,
+0x2b02a0,6,
+0x2b0300,5,
+0x2b0320,4,
+0x2b0334,9,
+0x2b035c,7,
+0x2b0380,1,
+0x2b03a0,6,
+0x2b0400,4,
+0x2b0440,4,
+0x2b0480,3,
+0x2b04c0,3,
+0x2b0500,5,
+0x2b0518,8,
+0x2b0c00,13,
+0x2b0c40,11,
+0x2b0c80,13,
+0x2b0cc0,11,
+0x2b0d00,6,
+0x2b0d20,6,
+0x2b0e00,10,
+0x2b0e40,11,
+0x2b0e80,8,
+0x2b1000,2,
+0x2b1010,5,
+0x2b1040,3,
+0x2b1050,3,
+0x2b1060,7,
+0x2b1080,7,
+0x2b10a0,7,
+0x2b10c0,7,
+0x2b1100,7,
+0x2b1140,7,
+0x2b1180,5,
+0x2b119c,9,
+0x2b1218,9,
+0x2b1240,3,
+0x2b1250,6,
+0x2b1280,1,
+0x2b1288,6,
+0x2b12a4,1,
+0x2b12c0,1,
+0x2b12c8,6,
+0x2b12e4,1,
+0x2b1400,8,
+0x2b1424,2,
+0x2b1500,3,
+0x2b1520,4,
+0x2b1540,3,
+0x2b1560,4,
+0x2b1800,24,
+0x2b1864,2,
+0x2b1880,6,
+0x2b1900,12,
+0x2b1940,6,
+0x2b1960,6,
+0x2b1980,4,
+0x2b19c0,6,
+0x2b19dc,1,
+0x2b1a00,6,
+0x2b1a1c,1,
+0x2b1a40,1,
+0x2b1a68,23,
+0x2b1b00,17,
+0x2b1b80,12,
+0x2b2000,5,
+0x2b2020,4,
+0x2b2034,9,
+0x2b205c,7,
+0x2b2080,1,
+0x2b20a0,6,
+0x2b2100,5,
+0x2b2120,4,
+0x2b2134,9,
+0x2b215c,7,
+0x2b2180,1,
+0x2b21a0,6,
+0x2b2200,5,
+0x2b2220,4,
+0x2b2234,9,
+0x2b225c,7,
+0x2b2280,1,
+0x2b22a0,6,
+0x2b2300,5,
+0x2b2320,4,
+0x2b2334,9,
+0x2b235c,7,
+0x2b2380,1,
+0x2b23a0,6,
+0x2b2400,4,
+0x2b2440,4,
+0x2b2480,3,
+0x2b24c0,3,
+0x2b2500,5,
+0x2b2518,8,
+0x2b2c00,13,
+0x2b2c40,11,
+0x2b2c80,13,
+0x2b2cc0,11,
+0x2b2d00,6,
+0x2b2d20,6,
+0x2b2e00,10,
+0x2b2e40,11,
+0x2b2e80,8,
+0x2b3000,2,
+0x2b3010,5,
+0x2b3040,3,
+0x2b3050,3,
+0x2b3060,7,
+0x2b3080,7,
+0x2b30a0,7,
+0x2b30c0,7,
+0x2b3100,7,
+0x2b3140,7,
+0x2b3180,5,
+0x2b319c,9,
+0x2b3218,9,
+0x2b3240,3,
+0x2b3250,6,
+0x2b3280,1,
+0x2b3288,6,
+0x2b32a4,1,
+0x2b32c0,1,
+0x2b32c8,6,
+0x2b32e4,1,
+0x2b3400,8,
+0x2b3424,2,
+0x2b3500,3,
+0x2b3520,4,
+0x2b3540,3,
+0x2b3560,4,
+0x2b3800,24,
+0x2b3864,2,
+0x2b3880,6,
+0x2b3900,12,
+0x2b3940,6,
+0x2b3960,6,
+0x2b3980,4,
+0x2b39c0,6,
+0x2b39dc,1,
+0x2b3a00,6,
+0x2b3a1c,1,
+0x2b3a40,1,
+0x2b3a68,23,
+0x2b3b00,17,
+0x2b3b80,12,
+0x2b4000,4,
+0x2b4014,6,
+0x2b4030,5,
+0x2b4080,4,
+0x2b4094,6,
+0x2b40b0,5,
+0x2b4100,4,
+0x2b4114,6,
+0x2b4130,5,
+0x2b4180,4,
+0x2b4194,6,
+0x2b41b0,5,
+0x2b4200,3,
+0x2b4210,23,
+0x2b4500,3,
+0x2b4510,12,
+0x2b4580,3,
+0x2b4590,12,
+0x2b4600,3,
+0x2b4610,12,
+0x2b4680,3,
+0x2b4690,12,
+0x2b4700,4,
+0x2b4718,13,
+0x2b4800,25,
+0x2b4880,25,
+0x2b4900,25,
+0x2b4980,25,
+0x2b4a00,17,
+0x2b4a50,3,
+0x2b4a60,3,
+0x2b5000,4,
+0x2b5014,6,
+0x2b5030,5,
+0x2b5080,4,
+0x2b5094,6,
+0x2b50b0,5,
+0x2b5100,4,
+0x2b5114,6,
+0x2b5130,5,
+0x2b5180,4,
+0x2b5194,6,
+0x2b51b0,5,
+0x2b5200,3,
+0x2b5210,23,
+0x2b5500,3,
+0x2b5510,12,
+0x2b5580,3,
+0x2b5590,12,
+0x2b5600,3,
+0x2b5610,12,
+0x2b5680,3,
+0x2b5690,12,
+0x2b5700,4,
+0x2b5718,13,
+0x2b5800,25,
+0x2b5880,25,
+0x2b5900,25,
+0x2b5980,25,
+0x2b5a00,17,
+0x2b5a50,3,
+0x2b5a60,3,
+0x2b6000,13,
+0x2b6040,22,
+0x2b60a0,6,
+0x2b60c0,3,
+0x2b6100,9,
+0x2b6400,2,
+0x2b640c,6,
+0x2b6440,13,
+0x2b6480,16,
+0x2b6800,1,
+0x2b6808,3,
+0x2b681c,8,
+0x2b6840,3,
+0x2b6850,3,
+0x2b6880,1,
+0x2b6888,3,
+0x2b689c,8,
+0x2b68c0,3,
+0x2b68d0,3,
+0x2b6900,1,
+0x2b6908,3,
+0x2b691c,8,
+0x2b6940,3,
+0x2b6950,3,
+0x2b6980,1,
+0x2b6988,3,
+0x2b699c,8,
+0x2b69c0,3,
+0x2b69d0,3,
+0x2b6a00,1,
+0x2b6a08,3,
+0x2b6a1c,8,
+0x2b6a40,3,
+0x2b6a50,3,
+0x2b6a80,1,
+0x2b6a88,3,
+0x2b6a9c,8,
+0x2b6ac0,3,
+0x2b6ad0,3,
+0x2b6b00,1,
+0x2b6b08,3,
+0x2b6b1c,8,
+0x2b6b40,3,
+0x2b6b50,3,
+0x2b6b80,1,
+0x2b6b88,3,
+0x2b6b9c,8,
+0x2b6bc0,3,
+0x2b6bd0,3,
+0x2b6c00,1,
+0x2b6c08,3,
+0x2b6c1c,8,
+0x2b6c40,3,
+0x2b6c50,3,
+0x2b6c80,2,
+0x2b6c94,13,
+0x2b7000,6,
+0x2b7020,3,
+0x2b7034,1,
+0x2b7040,7,
+0x2b7060,6,
+0x2b7100,5,
+0x2b7138,1,
+0x2b7144,1,
+0x2b7400,1,
+0x2b7418,1,
+0x2b7434,1,
+0x2b752c,5,
+0x2b7590,1,
+0x2b75ac,1,
+0x2b75d8,4,
+0x2b7600,8,
+0x2b8000,6,
+0x2b8020,3,
+0x2b8030,9,
+0x2b8080,6,
+0x2b8100,20,
+0x2b8400,1,
+0x2b8418,1,
+0x2b8434,1,
+0x2b852c,4,
+0x2b8590,1,
+0x2b85ac,1,
+0x2b85d8,4,
+0x2b8600,8,
+0x2b9000,6,
+0x2b9020,6,
+0x2b9040,3,
+0x2b9080,14,
+0x2b90bc,1,
+0x2b90c4,13,
+0x2b90fc,6,
+0x2b9120,5,
+0x2b9190,10,
+0x2b9200,16,
+0x2b9244,32,
+0x2b9300,26,
+0x2b9380,2,
+0x2b93a0,1,
+0x2b93c0,11,
+0x2b9404,4,
+0x2b9418,16,
+0x2b9460,3,
+0x2b9500,6,
+0x2b9540,1,
+0x2b9558,2,
+0x2b9600,17,
+0x2b9800,366,
+0x2ba000,6,
+0x2ba020,6,
+0x2ba040,3,
+0x2ba080,14,
+0x2ba0bc,1,
+0x2ba0c4,13,
+0x2ba0fc,6,
+0x2ba120,5,
+0x2ba190,10,
+0x2ba200,16,
+0x2ba244,32,
+0x2ba300,26,
+0x2ba380,2,
+0x2ba3a0,1,
+0x2ba3c0,11,
+0x2ba404,4,
+0x2ba418,16,
+0x2ba460,3,
+0x2ba500,6,
+0x2ba540,1,
+0x2ba558,2,
+0x2ba600,17,
+0x2ba800,366,
+0x2bb000,4,
+0x2bb020,9,
+0x2bb048,6,
+0x2bb064,6,
+0x2bb080,1,
+0x2bb100,4,
+0x2bb120,9,
+0x2bb148,6,
+0x2bb164,6,
+0x2bb180,1,
+0x2bb200,35,
+0x2bb290,6,
+0x2bb2b4,6,
+0x2bb2d0,5,
+0x2bb2e8,5,
+0x2bb300,37,
+0x2bb400,6,
+0x2bb420,3,
+0x2bb438,4,
+0x2bb454,3,
+0x2bb478,4,
+0x2bb494,3,
+0x2bb800,5,
+0x2bb818,1,
+0x2bb854,6,
+0x2bb880,2,
+0x2bb8a4,1,
+0x2bba00,28,
+0x2bba7c,5,
+0x2bbab0,2,
+0x2bbabc,10,
+0x2bbb00,2,
+0x2bbb0c,7,
+0x2bbb34,9,
+0x2bbb60,6,
+0x2bbb80,8,
+0x2bbc00,5,
+0x2bbc18,1,
+0x2bbc54,6,
+0x2bbc80,2,
+0x2bbca4,1,
+0x2bbe00,28,
+0x2bbe7c,5,
+0x2bbeb0,2,
+0x2bbebc,10,
+0x2bbf00,2,
+0x2bbf0c,7,
+0x2bbf34,9,
+0x2bbf60,6,
+0x2bbf80,8,
+0x2bc000,4,
+0x2bc014,10,
+0x2bc040,1,
+0x2bc048,3,
+0x2bc058,1,
+0x2bc060,1,
+0x2bc07c,1,
+0x2bc500,1,
+0x2bc518,2,
+0x2bc540,6,
+0x2bc800,4,
+0x2bc814,10,
+0x2bc840,1,
+0x2bc848,3,
+0x2bc858,1,
+0x2bc860,1,
+0x2bc87c,1,
+0x2bcd00,1,
+0x2bcd18,2,
+0x2bcd40,6,
+0x2bd800,2,
+0x2bd818,2,
+0x2bd834,2,
+0x2bd92c,6,
+0x2bd990,2,
+0x2bd9ac,1,
+0x2bd9d8,4,
+0x2bda00,16,
+0x2bdc00,3,
+0x2bdc20,2,
+0x2bdc40,1,
+0x2c0000,5,
+0x2c0020,4,
+0x2c0034,9,
+0x2c005c,7,
+0x2c0080,1,
+0x2c00a0,6,
+0x2c0100,5,
+0x2c0120,4,
+0x2c0134,9,
+0x2c015c,7,
+0x2c0180,1,
+0x2c01a0,6,
+0x2c0200,5,
+0x2c0220,4,
+0x2c0234,9,
+0x2c025c,7,
+0x2c0280,1,
+0x2c02a0,6,
+0x2c0300,5,
+0x2c0320,4,
+0x2c0334,9,
+0x2c035c,7,
+0x2c0380,1,
+0x2c03a0,6,
+0x2c0400,4,
+0x2c0440,4,
+0x2c0480,3,
+0x2c04c0,3,
+0x2c0500,5,
+0x2c0518,8,
+0x2c0c00,13,
+0x2c0c40,11,
+0x2c0c80,13,
+0x2c0cc0,11,
+0x2c0d00,6,
+0x2c0d20,6,
+0x2c0e00,10,
+0x2c0e40,11,
+0x2c0e80,8,
+0x2c1000,2,
+0x2c1010,5,
+0x2c1040,3,
+0x2c1050,3,
+0x2c1060,7,
+0x2c1080,7,
+0x2c10a0,7,
+0x2c10c0,7,
+0x2c1100,7,
+0x2c1140,7,
+0x2c1180,5,
+0x2c119c,9,
+0x2c1218,9,
+0x2c1240,3,
+0x2c1250,6,
+0x2c1280,1,
+0x2c1288,6,
+0x2c12a4,1,
+0x2c12c0,1,
+0x2c12c8,6,
+0x2c12e4,1,
+0x2c1400,8,
+0x2c1424,2,
+0x2c1500,3,
+0x2c1520,4,
+0x2c1540,3,
+0x2c1560,4,
+0x2c1800,24,
+0x2c1864,2,
+0x2c1880,6,
+0x2c1900,12,
+0x2c1940,6,
+0x2c1960,6,
+0x2c1980,4,
+0x2c19c0,6,
+0x2c19dc,1,
+0x2c1a00,6,
+0x2c1a1c,1,
+0x2c1a40,1,
+0x2c1a68,23,
+0x2c1b00,17,
+0x2c1b80,12,
+0x2c2000,5,
+0x2c2020,4,
+0x2c2034,9,
+0x2c205c,7,
+0x2c2080,1,
+0x2c20a0,6,
+0x2c2100,5,
+0x2c2120,4,
+0x2c2134,9,
+0x2c215c,7,
+0x2c2180,1,
+0x2c21a0,6,
+0x2c2200,5,
+0x2c2220,4,
+0x2c2234,9,
+0x2c225c,7,
+0x2c2280,1,
+0x2c22a0,6,
+0x2c2300,5,
+0x2c2320,4,
+0x2c2334,9,
+0x2c235c,7,
+0x2c2380,1,
+0x2c23a0,6,
+0x2c2400,4,
+0x2c2440,4,
+0x2c2480,3,
+0x2c24c0,3,
+0x2c2500,5,
+0x2c2518,8,
+0x2c2c00,13,
+0x2c2c40,11,
+0x2c2c80,13,
+0x2c2cc0,11,
+0x2c2d00,6,
+0x2c2d20,6,
+0x2c2e00,10,
+0x2c2e40,11,
+0x2c2e80,8,
+0x2c3000,2,
+0x2c3010,5,
+0x2c3040,3,
+0x2c3050,3,
+0x2c3060,7,
+0x2c3080,7,
+0x2c30a0,7,
+0x2c30c0,7,
+0x2c3100,7,
+0x2c3140,7,
+0x2c3180,5,
+0x2c319c,9,
+0x2c3218,9,
+0x2c3240,3,
+0x2c3250,6,
+0x2c3280,1,
+0x2c3288,6,
+0x2c32a4,1,
+0x2c32c0,1,
+0x2c32c8,6,
+0x2c32e4,1,
+0x2c3400,8,
+0x2c3424,2,
+0x2c3500,3,
+0x2c3520,4,
+0x2c3540,3,
+0x2c3560,4,
+0x2c3800,24,
+0x2c3864,2,
+0x2c3880,6,
+0x2c3900,12,
+0x2c3940,6,
+0x2c3960,6,
+0x2c3980,4,
+0x2c39c0,6,
+0x2c39dc,1,
+0x2c3a00,6,
+0x2c3a1c,1,
+0x2c3a40,1,
+0x2c3a68,23,
+0x2c3b00,17,
+0x2c3b80,12,
+0x2c4000,4,
+0x2c4014,6,
+0x2c4030,5,
+0x2c4080,4,
+0x2c4094,6,
+0x2c40b0,5,
+0x2c4100,4,
+0x2c4114,6,
+0x2c4130,5,
+0x2c4180,4,
+0x2c4194,6,
+0x2c41b0,5,
+0x2c4200,3,
+0x2c4210,23,
+0x2c4500,3,
+0x2c4510,12,
+0x2c4580,3,
+0x2c4590,12,
+0x2c4600,3,
+0x2c4610,12,
+0x2c4680,3,
+0x2c4690,12,
+0x2c4700,4,
+0x2c4718,13,
+0x2c4800,25,
+0x2c4880,25,
+0x2c4900,25,
+0x2c4980,25,
+0x2c4a00,17,
+0x2c4a50,3,
+0x2c4a60,3,
+0x2c5000,4,
+0x2c5014,6,
+0x2c5030,5,
+0x2c5080,4,
+0x2c5094,6,
+0x2c50b0,5,
+0x2c5100,4,
+0x2c5114,6,
+0x2c5130,5,
+0x2c5180,4,
+0x2c5194,6,
+0x2c51b0,5,
+0x2c5200,3,
+0x2c5210,23,
+0x2c5500,3,
+0x2c5510,12,
+0x2c5580,3,
+0x2c5590,12,
+0x2c5600,3,
+0x2c5610,12,
+0x2c5680,3,
+0x2c5690,12,
+0x2c5700,4,
+0x2c5718,13,
+0x2c5800,25,
+0x2c5880,25,
+0x2c5900,25,
+0x2c5980,25,
+0x2c5a00,17,
+0x2c5a50,3,
+0x2c5a60,3,
+0x2c6000,13,
+0x2c6040,22,
+0x2c60a0,6,
+0x2c60c0,3,
+0x2c6100,9,
+0x2c6400,2,
+0x2c640c,6,
+0x2c6440,13,
+0x2c6480,16,
+0x2c6800,1,
+0x2c6808,3,
+0x2c681c,8,
+0x2c6840,3,
+0x2c6850,3,
+0x2c6880,1,
+0x2c6888,3,
+0x2c689c,8,
+0x2c68c0,3,
+0x2c68d0,3,
+0x2c6900,1,
+0x2c6908,3,
+0x2c691c,8,
+0x2c6940,3,
+0x2c6950,3,
+0x2c6980,1,
+0x2c6988,3,
+0x2c699c,8,
+0x2c69c0,3,
+0x2c69d0,3,
+0x2c6a00,1,
+0x2c6a08,3,
+0x2c6a1c,8,
+0x2c6a40,3,
+0x2c6a50,3,
+0x2c6a80,1,
+0x2c6a88,3,
+0x2c6a9c,8,
+0x2c6ac0,3,
+0x2c6ad0,3,
+0x2c6b00,1,
+0x2c6b08,3,
+0x2c6b1c,8,
+0x2c6b40,3,
+0x2c6b50,3,
+0x2c6b80,1,
+0x2c6b88,3,
+0x2c6b9c,8,
+0x2c6bc0,3,
+0x2c6bd0,3,
+0x2c6c00,1,
+0x2c6c08,3,
+0x2c6c1c,8,
+0x2c6c40,3,
+0x2c6c50,3,
+0x2c6c80,2,
+0x2c6c94,13,
+0x2c7000,6,
+0x2c7020,3,
+0x2c7034,1,
+0x2c7040,7,
+0x2c7060,6,
+0x2c7100,5,
+0x2c7138,1,
+0x2c7144,1,
+0x2c7400,1,
+0x2c7418,1,
+0x2c7434,1,
+0x2c752c,5,
+0x2c7590,1,
+0x2c75ac,1,
+0x2c75d8,4,
+0x2c7600,8,
+0x2c8000,6,
+0x2c8020,3,
+0x2c8030,9,
+0x2c8080,6,
+0x2c8100,20,
+0x2c8400,1,
+0x2c8418,1,
+0x2c8434,1,
+0x2c852c,4,
+0x2c8590,1,
+0x2c85ac,1,
+0x2c85d8,4,
+0x2c8600,8,
+0x2c9000,6,
+0x2c9020,6,
+0x2c9040,3,
+0x2c9080,14,
+0x2c90bc,1,
+0x2c90c4,13,
+0x2c90fc,6,
+0x2c9120,5,
+0x2c9190,10,
+0x2c9200,16,
+0x2c9244,32,
+0x2c9300,26,
+0x2c9380,2,
+0x2c93a0,1,
+0x2c93c0,11,
+0x2c9404,4,
+0x2c9418,16,
+0x2c9460,3,
+0x2c9500,6,
+0x2c9540,1,
+0x2c9558,2,
+0x2c9600,17,
+0x2c9800,366,
+0x2ca000,6,
+0x2ca020,6,
+0x2ca040,3,
+0x2ca080,14,
+0x2ca0bc,1,
+0x2ca0c4,13,
+0x2ca0fc,6,
+0x2ca120,5,
+0x2ca190,10,
+0x2ca200,16,
+0x2ca244,32,
+0x2ca300,26,
+0x2ca380,2,
+0x2ca3a0,1,
+0x2ca3c0,11,
+0x2ca404,4,
+0x2ca418,16,
+0x2ca460,3,
+0x2ca500,6,
+0x2ca540,1,
+0x2ca558,2,
+0x2ca600,17,
+0x2ca800,366,
+0x2cb000,4,
+0x2cb020,9,
+0x2cb048,6,
+0x2cb064,6,
+0x2cb080,1,
+0x2cb100,4,
+0x2cb120,9,
+0x2cb148,6,
+0x2cb164,6,
+0x2cb180,1,
+0x2cb200,35,
+0x2cb290,6,
+0x2cb2b4,6,
+0x2cb2d0,5,
+0x2cb2e8,5,
+0x2cb300,37,
+0x2cb400,6,
+0x2cb420,3,
+0x2cb438,4,
+0x2cb454,3,
+0x2cb478,4,
+0x2cb494,3,
+0x2cb800,5,
+0x2cb818,1,
+0x2cb854,6,
+0x2cb880,2,
+0x2cb8a4,1,
+0x2cba00,28,
+0x2cba7c,5,
+0x2cbab0,2,
+0x2cbabc,10,
+0x2cbb00,2,
+0x2cbb0c,7,
+0x2cbb34,9,
+0x2cbb60,6,
+0x2cbb80,8,
+0x2cbc00,5,
+0x2cbc18,1,
+0x2cbc54,6,
+0x2cbc80,2,
+0x2cbca4,1,
+0x2cbe00,28,
+0x2cbe7c,5,
+0x2cbeb0,2,
+0x2cbebc,10,
+0x2cbf00,2,
+0x2cbf0c,7,
+0x2cbf34,9,
+0x2cbf60,6,
+0x2cbf80,8,
+0x2cc000,4,
+0x2cc014,10,
+0x2cc040,1,
+0x2cc048,3,
+0x2cc058,1,
+0x2cc060,1,
+0x2cc07c,1,
+0x2cc500,1,
+0x2cc518,2,
+0x2cc540,6,
+0x2cc800,4,
+0x2cc814,10,
+0x2cc840,1,
+0x2cc848,3,
+0x2cc858,1,
+0x2cc860,1,
+0x2cc87c,1,
+0x2ccd00,1,
+0x2ccd18,2,
+0x2ccd40,6,
+0x2cd800,2,
+0x2cd818,2,
+0x2cd834,2,
+0x2cd92c,6,
+0x2cd990,2,
+0x2cd9ac,1,
+0x2cd9d8,4,
+0x2cda00,16,
+0x2cdc00,3,
+0x2cdc20,2,
+0x2cdc40,1,
+0x2d0000,5,
+0x2d0020,4,
+0x2d0034,9,
+0x2d005c,7,
+0x2d0080,1,
+0x2d00a0,6,
+0x2d0100,5,
+0x2d0120,4,
+0x2d0134,9,
+0x2d015c,7,
+0x2d0180,1,
+0x2d01a0,6,
+0x2d0200,5,
+0x2d0220,4,
+0x2d0234,9,
+0x2d025c,7,
+0x2d0280,1,
+0x2d02a0,6,
+0x2d0300,5,
+0x2d0320,4,
+0x2d0334,9,
+0x2d035c,7,
+0x2d0380,1,
+0x2d03a0,6,
+0x2d0400,4,
+0x2d0440,4,
+0x2d0480,3,
+0x2d04c0,3,
+0x2d0500,5,
+0x2d0518,8,
+0x2d0c00,13,
+0x2d0c40,11,
+0x2d0c80,13,
+0x2d0cc0,11,
+0x2d0d00,6,
+0x2d0d20,6,
+0x2d0e00,10,
+0x2d0e40,11,
+0x2d0e80,8,
+0x2d1000,2,
+0x2d1010,5,
+0x2d1040,3,
+0x2d1050,3,
+0x2d1060,7,
+0x2d1080,7,
+0x2d10a0,7,
+0x2d10c0,7,
+0x2d1100,7,
+0x2d1140,7,
+0x2d1180,5,
+0x2d119c,9,
+0x2d1218,9,
+0x2d1240,3,
+0x2d1250,6,
+0x2d1280,1,
+0x2d1288,6,
+0x2d12a4,1,
+0x2d12c0,1,
+0x2d12c8,6,
+0x2d12e4,1,
+0x2d1400,8,
+0x2d1424,2,
+0x2d1500,3,
+0x2d1520,4,
+0x2d1540,3,
+0x2d1560,4,
+0x2d1800,24,
+0x2d1864,2,
+0x2d1880,6,
+0x2d1900,12,
+0x2d1940,6,
+0x2d1960,6,
+0x2d1980,4,
+0x2d19c0,6,
+0x2d19dc,1,
+0x2d1a00,6,
+0x2d1a1c,1,
+0x2d1a40,1,
+0x2d1a68,23,
+0x2d1b00,17,
+0x2d1b80,12,
+0x2d2000,5,
+0x2d2020,4,
+0x2d2034,9,
+0x2d205c,7,
+0x2d2080,1,
+0x2d20a0,6,
+0x2d2100,5,
+0x2d2120,4,
+0x2d2134,9,
+0x2d215c,7,
+0x2d2180,1,
+0x2d21a0,6,
+0x2d2200,5,
+0x2d2220,4,
+0x2d2234,9,
+0x2d225c,7,
+0x2d2280,1,
+0x2d22a0,6,
+0x2d2300,5,
+0x2d2320,4,
+0x2d2334,9,
+0x2d235c,7,
+0x2d2380,1,
+0x2d23a0,6,
+0x2d2400,4,
+0x2d2440,4,
+0x2d2480,3,
+0x2d24c0,3,
+0x2d2500,5,
+0x2d2518,8,
+0x2d2c00,13,
+0x2d2c40,11,
+0x2d2c80,13,
+0x2d2cc0,11,
+0x2d2d00,6,
+0x2d2d20,6,
+0x2d2e00,10,
+0x2d2e40,11,
+0x2d2e80,8,
+0x2d3000,2,
+0x2d3010,5,
+0x2d3040,3,
+0x2d3050,3,
+0x2d3060,7,
+0x2d3080,7,
+0x2d30a0,7,
+0x2d30c0,7,
+0x2d3100,7,
+0x2d3140,7,
+0x2d3180,5,
+0x2d319c,9,
+0x2d3218,9,
+0x2d3240,3,
+0x2d3250,6,
+0x2d3280,1,
+0x2d3288,6,
+0x2d32a4,1,
+0x2d32c0,1,
+0x2d32c8,6,
+0x2d32e4,1,
+0x2d3400,8,
+0x2d3424,2,
+0x2d3500,3,
+0x2d3520,4,
+0x2d3540,3,
+0x2d3560,4,
+0x2d3800,24,
+0x2d3864,2,
+0x2d3880,6,
+0x2d3900,12,
+0x2d3940,6,
+0x2d3960,6,
+0x2d3980,4,
+0x2d39c0,6,
+0x2d39dc,1,
+0x2d3a00,6,
+0x2d3a1c,1,
+0x2d3a40,1,
+0x2d3a68,23,
+0x2d3b00,17,
+0x2d3b80,12,
+0x2d4000,4,
+0x2d4014,6,
+0x2d4030,5,
+0x2d4080,4,
+0x2d4094,6,
+0x2d40b0,5,
+0x2d4100,4,
+0x2d4114,6,
+0x2d4130,5,
+0x2d4180,4,
+0x2d4194,6,
+0x2d41b0,5,
+0x2d4200,3,
+0x2d4210,23,
+0x2d4500,3,
+0x2d4510,12,
+0x2d4580,3,
+0x2d4590,12,
+0x2d4600,3,
+0x2d4610,12,
+0x2d4680,3,
+0x2d4690,12,
+0x2d4700,4,
+0x2d4718,13,
+0x2d4800,25,
+0x2d4880,25,
+0x2d4900,25,
+0x2d4980,25,
+0x2d4a00,17,
+0x2d4a50,3,
+0x2d4a60,3,
+0x2d5000,4,
+0x2d5014,6,
+0x2d5030,5,
+0x2d5080,4,
+0x2d5094,6,
+0x2d50b0,5,
+0x2d5100,4,
+0x2d5114,6,
+0x2d5130,5,
+0x2d5180,4,
+0x2d5194,6,
+0x2d51b0,5,
+0x2d5200,3,
+0x2d5210,23,
+0x2d5500,3,
+0x2d5510,12,
+0x2d5580,3,
+0x2d5590,12,
+0x2d5600,3,
+0x2d5610,12,
+0x2d5680,3,
+0x2d5690,12,
+0x2d5700,4,
+0x2d5718,13,
+0x2d5800,25,
+0x2d5880,25,
+0x2d5900,25,
+0x2d5980,25,
+0x2d5a00,17,
+0x2d5a50,3,
+0x2d5a60,3,
+0x2d6000,13,
+0x2d6040,22,
+0x2d60a0,6,
+0x2d60c0,3,
+0x2d6100,9,
+0x2d6400,2,
+0x2d640c,6,
+0x2d6440,13,
+0x2d6480,16,
+0x2d6800,1,
+0x2d6808,3,
+0x2d681c,8,
+0x2d6840,3,
+0x2d6850,3,
+0x2d6880,1,
+0x2d6888,3,
+0x2d689c,8,
+0x2d68c0,3,
+0x2d68d0,3,
+0x2d6900,1,
+0x2d6908,3,
+0x2d691c,8,
+0x2d6940,3,
+0x2d6950,3,
+0x2d6980,1,
+0x2d6988,3,
+0x2d699c,8,
+0x2d69c0,3,
+0x2d69d0,3,
+0x2d6a00,1,
+0x2d6a08,3,
+0x2d6a1c,8,
+0x2d6a40,3,
+0x2d6a50,3,
+0x2d6a80,1,
+0x2d6a88,3,
+0x2d6a9c,8,
+0x2d6ac0,3,
+0x2d6ad0,3,
+0x2d6b00,1,
+0x2d6b08,3,
+0x2d6b1c,8,
+0x2d6b40,3,
+0x2d6b50,3,
+0x2d6b80,1,
+0x2d6b88,3,
+0x2d6b9c,8,
+0x2d6bc0,3,
+0x2d6bd0,3,
+0x2d6c00,1,
+0x2d6c08,3,
+0x2d6c1c,8,
+0x2d6c40,3,
+0x2d6c50,3,
+0x2d6c80,2,
+0x2d6c94,13,
+0x2d7000,6,
+0x2d7020,3,
+0x2d7034,1,
+0x2d7040,7,
+0x2d7060,6,
+0x2d7100,5,
+0x2d7138,1,
+0x2d7144,1,
+0x2d7400,1,
+0x2d7418,1,
+0x2d7434,1,
+0x2d752c,5,
+0x2d7590,1,
+0x2d75ac,1,
+0x2d75d8,4,
+0x2d7600,8,
+0x2d8000,6,
+0x2d8020,3,
+0x2d8030,9,
+0x2d8080,6,
+0x2d8100,20,
+0x2d8400,1,
+0x2d8418,1,
+0x2d8434,1,
+0x2d852c,4,
+0x2d8590,1,
+0x2d85ac,1,
+0x2d85d8,4,
+0x2d8600,8,
+0x2d9000,6,
+0x2d9020,6,
+0x2d9040,3,
+0x2d9080,14,
+0x2d90bc,1,
+0x2d90c4,13,
+0x2d90fc,6,
+0x2d9120,5,
+0x2d9190,10,
+0x2d9200,16,
+0x2d9244,32,
+0x2d9300,26,
+0x2d9380,2,
+0x2d93a0,1,
+0x2d93c0,11,
+0x2d9404,4,
+0x2d9418,16,
+0x2d9460,3,
+0x2d9500,6,
+0x2d9540,1,
+0x2d9558,2,
+0x2d9600,17,
+0x2d9800,366,
+0x2da000,6,
+0x2da020,6,
+0x2da040,3,
+0x2da080,14,
+0x2da0bc,1,
+0x2da0c4,13,
+0x2da0fc,6,
+0x2da120,5,
+0x2da190,10,
+0x2da200,16,
+0x2da244,32,
+0x2da300,26,
+0x2da380,2,
+0x2da3a0,1,
+0x2da3c0,11,
+0x2da404,4,
+0x2da418,16,
+0x2da460,3,
+0x2da500,6,
+0x2da540,1,
+0x2da558,2,
+0x2da600,17,
+0x2da800,366,
+0x2db000,4,
+0x2db020,9,
+0x2db048,6,
+0x2db064,6,
+0x2db080,1,
+0x2db100,4,
+0x2db120,9,
+0x2db148,6,
+0x2db164,6,
+0x2db180,1,
+0x2db200,35,
+0x2db290,6,
+0x2db2b4,6,
+0x2db2d0,5,
+0x2db2e8,5,
+0x2db300,37,
+0x2db400,6,
+0x2db420,3,
+0x2db438,4,
+0x2db454,3,
+0x2db478,4,
+0x2db494,3,
+0x2db800,5,
+0x2db818,1,
+0x2db854,6,
+0x2db880,2,
+0x2db8a4,1,
+0x2dba00,28,
+0x2dba7c,5,
+0x2dbab0,2,
+0x2dbabc,10,
+0x2dbb00,2,
+0x2dbb0c,7,
+0x2dbb34,9,
+0x2dbb60,6,
+0x2dbb80,8,
+0x2dbc00,5,
+0x2dbc18,1,
+0x2dbc54,6,
+0x2dbc80,2,
+0x2dbca4,1,
+0x2dbe00,28,
+0x2dbe7c,5,
+0x2dbeb0,2,
+0x2dbebc,10,
+0x2dbf00,2,
+0x2dbf0c,7,
+0x2dbf34,9,
+0x2dbf60,6,
+0x2dbf80,8,
+0x2dc000,4,
+0x2dc014,10,
+0x2dc040,1,
+0x2dc048,3,
+0x2dc058,1,
+0x2dc060,1,
+0x2dc07c,1,
+0x2dc500,1,
+0x2dc518,2,
+0x2dc540,6,
+0x2dc800,4,
+0x2dc814,10,
+0x2dc840,1,
+0x2dc848,3,
+0x2dc858,1,
+0x2dc860,1,
+0x2dc87c,1,
+0x2dcd00,1,
+0x2dcd18,2,
+0x2dcd40,6,
+0x2dd800,2,
+0x2dd818,2,
+0x2dd834,2,
+0x2dd92c,6,
+0x2dd990,2,
+0x2dd9ac,1,
+0x2dd9d8,4,
+0x2dda00,16,
+0x2ddc00,3,
+0x2ddc20,2,
+0x2ddc40,1,
+0x2e0000,5,
+0x2e0020,4,
+0x2e0034,9,
+0x2e005c,7,
+0x2e0080,1,
+0x2e00a0,6,
+0x2e0100,5,
+0x2e0120,4,
+0x2e0134,9,
+0x2e015c,7,
+0x2e0180,1,
+0x2e01a0,6,
+0x2e0200,5,
+0x2e0220,4,
+0x2e0234,9,
+0x2e025c,7,
+0x2e0280,1,
+0x2e02a0,6,
+0x2e0300,5,
+0x2e0320,4,
+0x2e0334,9,
+0x2e035c,7,
+0x2e0380,1,
+0x2e03a0,6,
+0x2e0400,4,
+0x2e0440,4,
+0x2e0480,3,
+0x2e04c0,3,
+0x2e0500,5,
+0x2e0518,8,
+0x2e0c00,13,
+0x2e0c40,11,
+0x2e0c80,13,
+0x2e0cc0,11,
+0x2e0d00,6,
+0x2e0d20,6,
+0x2e0e00,10,
+0x2e0e40,11,
+0x2e0e80,8,
+0x2e1000,2,
+0x2e1010,5,
+0x2e1040,3,
+0x2e1050,3,
+0x2e1060,7,
+0x2e1080,7,
+0x2e10a0,7,
+0x2e10c0,7,
+0x2e1100,7,
+0x2e1140,7,
+0x2e1180,5,
+0x2e119c,9,
+0x2e1218,9,
+0x2e1240,3,
+0x2e1250,6,
+0x2e1280,1,
+0x2e1288,6,
+0x2e12a4,1,
+0x2e12c0,1,
+0x2e12c8,6,
+0x2e12e4,1,
+0x2e1400,8,
+0x2e1424,2,
+0x2e1500,3,
+0x2e1520,4,
+0x2e1540,3,
+0x2e1560,4,
+0x2e1800,24,
+0x2e1864,2,
+0x2e1880,6,
+0x2e1900,12,
+0x2e1940,6,
+0x2e1960,6,
+0x2e1980,4,
+0x2e19c0,6,
+0x2e19dc,1,
+0x2e1a00,6,
+0x2e1a1c,1,
+0x2e1a40,1,
+0x2e1a68,23,
+0x2e1b00,17,
+0x2e1b80,12,
+0x2e2000,5,
+0x2e2020,4,
+0x2e2034,9,
+0x2e205c,7,
+0x2e2080,1,
+0x2e20a0,6,
+0x2e2100,5,
+0x2e2120,4,
+0x2e2134,9,
+0x2e215c,7,
+0x2e2180,1,
+0x2e21a0,6,
+0x2e2200,5,
+0x2e2220,4,
+0x2e2234,9,
+0x2e225c,7,
+0x2e2280,1,
+0x2e22a0,6,
+0x2e2300,5,
+0x2e2320,4,
+0x2e2334,9,
+0x2e235c,7,
+0x2e2380,1,
+0x2e23a0,6,
+0x2e2400,4,
+0x2e2440,4,
+0x2e2480,3,
+0x2e24c0,3,
+0x2e2500,5,
+0x2e2518,8,
+0x2e2c00,13,
+0x2e2c40,11,
+0x2e2c80,13,
+0x2e2cc0,11,
+0x2e2d00,6,
+0x2e2d20,6,
+0x2e2e00,10,
+0x2e2e40,11,
+0x2e2e80,8,
+0x2e3000,2,
+0x2e3010,5,
+0x2e3040,3,
+0x2e3050,3,
+0x2e3060,7,
+0x2e3080,7,
+0x2e30a0,7,
+0x2e30c0,7,
+0x2e3100,7,
+0x2e3140,7,
+0x2e3180,5,
+0x2e319c,9,
+0x2e3218,9,
+0x2e3240,3,
+0x2e3250,6,
+0x2e3280,1,
+0x2e3288,6,
+0x2e32a4,1,
+0x2e32c0,1,
+0x2e32c8,6,
+0x2e32e4,1,
+0x2e3400,8,
+0x2e3424,2,
+0x2e3500,3,
+0x2e3520,4,
+0x2e3540,3,
+0x2e3560,4,
+0x2e3800,24,
+0x2e3864,2,
+0x2e3880,6,
+0x2e3900,12,
+0x2e3940,6,
+0x2e3960,6,
+0x2e3980,4,
+0x2e39c0,6,
+0x2e39dc,1,
+0x2e3a00,6,
+0x2e3a1c,1,
+0x2e3a40,1,
+0x2e3a68,23,
+0x2e3b00,17,
+0x2e3b80,12,
+0x2e4000,4,
+0x2e4014,6,
+0x2e4030,5,
+0x2e4080,4,
+0x2e4094,6,
+0x2e40b0,5,
+0x2e4100,4,
+0x2e4114,6,
+0x2e4130,5,
+0x2e4180,4,
+0x2e4194,6,
+0x2e41b0,5,
+0x2e4200,3,
+0x2e4210,23,
+0x2e4500,3,
+0x2e4510,12,
+0x2e4580,3,
+0x2e4590,12,
+0x2e4600,3,
+0x2e4610,12,
+0x2e4680,3,
+0x2e4690,12,
+0x2e4700,4,
+0x2e4718,13,
+0x2e4800,25,
+0x2e4880,25,
+0x2e4900,25,
+0x2e4980,25,
+0x2e4a00,17,
+0x2e4a50,3,
+0x2e4a60,3,
+0x2e5000,4,
+0x2e5014,6,
+0x2e5030,5,
+0x2e5080,4,
+0x2e5094,6,
+0x2e50b0,5,
+0x2e5100,4,
+0x2e5114,6,
+0x2e5130,5,
+0x2e5180,4,
+0x2e5194,6,
+0x2e51b0,5,
+0x2e5200,3,
+0x2e5210,23,
+0x2e5500,3,
+0x2e5510,12,
+0x2e5580,3,
+0x2e5590,12,
+0x2e5600,3,
+0x2e5610,12,
+0x2e5680,3,
+0x2e5690,12,
+0x2e5700,4,
+0x2e5718,13,
+0x2e5800,25,
+0x2e5880,25,
+0x2e5900,25,
+0x2e5980,25,
+0x2e5a00,17,
+0x2e5a50,3,
+0x2e5a60,3,
+0x2e6000,13,
+0x2e6040,22,
+0x2e60a0,6,
+0x2e60c0,3,
+0x2e6100,9,
+0x2e6400,2,
+0x2e640c,6,
+0x2e6440,13,
+0x2e6480,16,
+0x2e6800,1,
+0x2e6808,3,
+0x2e681c,8,
+0x2e6840,3,
+0x2e6850,3,
+0x2e6880,1,
+0x2e6888,3,
+0x2e689c,8,
+0x2e68c0,3,
+0x2e68d0,3,
+0x2e6900,1,
+0x2e6908,3,
+0x2e691c,8,
+0x2e6940,3,
+0x2e6950,3,
+0x2e6980,1,
+0x2e6988,3,
+0x2e699c,8,
+0x2e69c0,3,
+0x2e69d0,3,
+0x2e6a00,1,
+0x2e6a08,3,
+0x2e6a1c,8,
+0x2e6a40,3,
+0x2e6a50,3,
+0x2e6a80,1,
+0x2e6a88,3,
+0x2e6a9c,8,
+0x2e6ac0,3,
+0x2e6ad0,3,
+0x2e6b00,1,
+0x2e6b08,3,
+0x2e6b1c,8,
+0x2e6b40,3,
+0x2e6b50,3,
+0x2e6b80,1,
+0x2e6b88,3,
+0x2e6b9c,8,
+0x2e6bc0,3,
+0x2e6bd0,3,
+0x2e6c00,1,
+0x2e6c08,3,
+0x2e6c1c,8,
+0x2e6c40,3,
+0x2e6c50,3,
+0x2e6c80,2,
+0x2e6c94,13,
+0x2e7000,6,
+0x2e7020,3,
+0x2e7034,1,
+0x2e7040,7,
+0x2e7060,6,
+0x2e7100,5,
+0x2e7138,1,
+0x2e7144,1,
+0x2e7400,1,
+0x2e7418,1,
+0x2e7434,1,
+0x2e752c,5,
+0x2e7590,1,
+0x2e75ac,1,
+0x2e75d8,4,
+0x2e7600,8,
+0x2e8000,6,
+0x2e8020,3,
+0x2e8030,9,
+0x2e8080,6,
+0x2e8100,20,
+0x2e8400,1,
+0x2e8418,1,
+0x2e8434,1,
+0x2e852c,4,
+0x2e8590,1,
+0x2e85ac,1,
+0x2e85d8,4,
+0x2e8600,8,
+0x2e9000,6,
+0x2e9020,6,
+0x2e9040,3,
+0x2e9080,14,
+0x2e90bc,1,
+0x2e90c4,13,
+0x2e90fc,6,
+0x2e9120,5,
+0x2e9190,10,
+0x2e9200,16,
+0x2e9244,32,
+0x2e9300,26,
+0x2e9380,2,
+0x2e93a0,1,
+0x2e93c0,11,
+0x2e9404,4,
+0x2e9418,16,
+0x2e9460,3,
+0x2e9500,6,
+0x2e9540,1,
+0x2e9558,2,
+0x2e9600,17,
+0x2e9800,366,
+0x2ea000,6,
+0x2ea020,6,
+0x2ea040,3,
+0x2ea080,14,
+0x2ea0bc,1,
+0x2ea0c4,13,
+0x2ea0fc,6,
+0x2ea120,5,
+0x2ea190,10,
+0x2ea200,16,
+0x2ea244,32,
+0x2ea300,26,
+0x2ea380,2,
+0x2ea3a0,1,
+0x2ea3c0,11,
+0x2ea404,4,
+0x2ea418,16,
+0x2ea460,3,
+0x2ea500,6,
+0x2ea540,1,
+0x2ea558,2,
+0x2ea600,17,
+0x2ea800,366,
+0x2eb000,4,
+0x2eb020,9,
+0x2eb048,6,
+0x2eb064,6,
+0x2eb080,1,
+0x2eb100,4,
+0x2eb120,9,
+0x2eb148,6,
+0x2eb164,6,
+0x2eb180,1,
+0x2eb200,35,
+0x2eb290,6,
+0x2eb2b4,6,
+0x2eb2d0,5,
+0x2eb2e8,5,
+0x2eb300,37,
+0x2eb400,6,
+0x2eb420,3,
+0x2eb438,4,
+0x2eb454,3,
+0x2eb478,4,
+0x2eb494,3,
+0x2eb800,5,
+0x2eb818,1,
+0x2eb854,6,
+0x2eb880,2,
+0x2eb8a4,1,
+0x2eba00,28,
+0x2eba7c,5,
+0x2ebab0,2,
+0x2ebabc,10,
+0x2ebb00,2,
+0x2ebb0c,7,
+0x2ebb34,9,
+0x2ebb60,6,
+0x2ebb80,8,
+0x2ebc00,5,
+0x2ebc18,1,
+0x2ebc54,6,
+0x2ebc80,2,
+0x2ebca4,1,
+0x2ebe00,28,
+0x2ebe7c,5,
+0x2ebeb0,2,
+0x2ebebc,10,
+0x2ebf00,2,
+0x2ebf0c,7,
+0x2ebf34,9,
+0x2ebf60,6,
+0x2ebf80,8,
+0x2ec000,4,
+0x2ec014,10,
+0x2ec040,1,
+0x2ec048,3,
+0x2ec058,1,
+0x2ec060,1,
+0x2ec07c,1,
+0x2ec500,1,
+0x2ec518,2,
+0x2ec540,6,
+0x2ec800,4,
+0x2ec814,10,
+0x2ec840,1,
+0x2ec848,3,
+0x2ec858,1,
+0x2ec860,1,
+0x2ec87c,1,
+0x2ecd00,1,
+0x2ecd18,2,
+0x2ecd40,6,
+0x2ed800,2,
+0x2ed818,2,
+0x2ed834,2,
+0x2ed92c,6,
+0x2ed990,2,
+0x2ed9ac,1,
+0x2ed9d8,4,
+0x2eda00,16,
+0x2edc00,3,
+0x2edc20,2,
+0x2edc40,1,
+0x2f0000,5,
+0x2f0020,4,
+0x2f0034,9,
+0x2f005c,7,
+0x2f0080,1,
+0x2f00a0,6,
+0x2f0100,5,
+0x2f0120,4,
+0x2f0134,9,
+0x2f015c,7,
+0x2f0180,1,
+0x2f01a0,6,
+0x2f0200,5,
+0x2f0220,4,
+0x2f0234,9,
+0x2f025c,7,
+0x2f0280,1,
+0x2f02a0,6,
+0x2f0300,5,
+0x2f0320,4,
+0x2f0334,9,
+0x2f035c,7,
+0x2f0380,1,
+0x2f03a0,6,
+0x2f0400,4,
+0x2f0440,4,
+0x2f0480,3,
+0x2f04c0,3,
+0x2f0500,5,
+0x2f0518,8,
+0x2f0c00,13,
+0x2f0c40,11,
+0x2f0c80,13,
+0x2f0cc0,11,
+0x2f0d00,6,
+0x2f0d20,6,
+0x2f0e00,10,
+0x2f0e40,11,
+0x2f0e80,8,
+0x2f1000,2,
+0x2f1010,5,
+0x2f1040,3,
+0x2f1050,3,
+0x2f1060,7,
+0x2f1080,7,
+0x2f10a0,7,
+0x2f10c0,7,
+0x2f1100,7,
+0x2f1140,7,
+0x2f1180,5,
+0x2f119c,9,
+0x2f1218,9,
+0x2f1240,3,
+0x2f1250,6,
+0x2f1280,1,
+0x2f1288,6,
+0x2f12a4,1,
+0x2f12c0,1,
+0x2f12c8,6,
+0x2f12e4,1,
+0x2f1400,8,
+0x2f1424,2,
+0x2f1500,3,
+0x2f1520,4,
+0x2f1540,3,
+0x2f1560,4,
+0x2f1800,24,
+0x2f1864,2,
+0x2f1880,6,
+0x2f1900,12,
+0x2f1940,6,
+0x2f1960,6,
+0x2f1980,4,
+0x2f19c0,6,
+0x2f19dc,1,
+0x2f1a00,6,
+0x2f1a1c,1,
+0x2f1a40,1,
+0x2f1a68,23,
+0x2f1b00,17,
+0x2f1b80,12,
+0x2f2000,5,
+0x2f2020,4,
+0x2f2034,9,
+0x2f205c,7,
+0x2f2080,1,
+0x2f20a0,6,
+0x2f2100,5,
+0x2f2120,4,
+0x2f2134,9,
+0x2f215c,7,
+0x2f2180,1,
+0x2f21a0,6,
+0x2f2200,5,
+0x2f2220,4,
+0x2f2234,9,
+0x2f225c,7,
+0x2f2280,1,
+0x2f22a0,6,
+0x2f2300,5,
+0x2f2320,4,
+0x2f2334,9,
+0x2f235c,7,
+0x2f2380,1,
+0x2f23a0,6,
+0x2f2400,4,
+0x2f2440,4,
+0x2f2480,3,
+0x2f24c0,3,
+0x2f2500,5,
+0x2f2518,8,
+0x2f2c00,13,
+0x2f2c40,11,
+0x2f2c80,13,
+0x2f2cc0,11,
+0x2f2d00,6,
+0x2f2d20,6,
+0x2f2e00,10,
+0x2f2e40,11,
+0x2f2e80,8,
+0x2f3000,2,
+0x2f3010,5,
+0x2f3040,3,
+0x2f3050,3,
+0x2f3060,7,
+0x2f3080,7,
+0x2f30a0,7,
+0x2f30c0,7,
+0x2f3100,7,
+0x2f3140,7,
+0x2f3180,5,
+0x2f319c,9,
+0x2f3218,9,
+0x2f3240,3,
+0x2f3250,6,
+0x2f3280,1,
+0x2f3288,6,
+0x2f32a4,1,
+0x2f32c0,1,
+0x2f32c8,6,
+0x2f32e4,1,
+0x2f3400,8,
+0x2f3424,2,
+0x2f3500,3,
+0x2f3520,4,
+0x2f3540,3,
+0x2f3560,4,
+0x2f3800,24,
+0x2f3864,2,
+0x2f3880,6,
+0x2f3900,12,
+0x2f3940,6,
+0x2f3960,6,
+0x2f3980,4,
+0x2f39c0,6,
+0x2f39dc,1,
+0x2f3a00,6,
+0x2f3a1c,1,
+0x2f3a40,1,
+0x2f3a68,23,
+0x2f3b00,17,
+0x2f3b80,12,
+0x2f4000,4,
+0x2f4014,6,
+0x2f4030,5,
+0x2f4080,4,
+0x2f4094,6,
+0x2f40b0,5,
+0x2f4100,4,
+0x2f4114,6,
+0x2f4130,5,
+0x2f4180,4,
+0x2f4194,6,
+0x2f41b0,5,
+0x2f4200,3,
+0x2f4210,23,
+0x2f4500,3,
+0x2f4510,12,
+0x2f4580,3,
+0x2f4590,12,
+0x2f4600,3,
+0x2f4610,12,
+0x2f4680,3,
+0x2f4690,12,
+0x2f4700,4,
+0x2f4718,13,
+0x2f4800,25,
+0x2f4880,25,
+0x2f4900,25,
+0x2f4980,25,
+0x2f4a00,17,
+0x2f4a50,3,
+0x2f4a60,3,
+0x2f5000,4,
+0x2f5014,6,
+0x2f5030,5,
+0x2f5080,4,
+0x2f5094,6,
+0x2f50b0,5,
+0x2f5100,4,
+0x2f5114,6,
+0x2f5130,5,
+0x2f5180,4,
+0x2f5194,6,
+0x2f51b0,5,
+0x2f5200,3,
+0x2f5210,23,
+0x2f5500,3,
+0x2f5510,12,
+0x2f5580,3,
+0x2f5590,12,
+0x2f5600,3,
+0x2f5610,12,
+0x2f5680,3,
+0x2f5690,12,
+0x2f5700,4,
+0x2f5718,13,
+0x2f5800,25,
+0x2f5880,25,
+0x2f5900,25,
+0x2f5980,25,
+0x2f5a00,17,
+0x2f5a50,3,
+0x2f5a60,3,
+0x2f6000,13,
+0x2f6040,22,
+0x2f60a0,6,
+0x2f60c0,3,
+0x2f6100,9,
+0x2f6400,2,
+0x2f640c,6,
+0x2f6440,13,
+0x2f6480,16,
+0x2f6800,1,
+0x2f6808,3,
+0x2f681c,8,
+0x2f6840,3,
+0x2f6850,3,
+0x2f6880,1,
+0x2f6888,3,
+0x2f689c,8,
+0x2f68c0,3,
+0x2f68d0,3,
+0x2f6900,1,
+0x2f6908,3,
+0x2f691c,8,
+0x2f6940,3,
+0x2f6950,3,
+0x2f6980,1,
+0x2f6988,3,
+0x2f699c,8,
+0x2f69c0,3,
+0x2f69d0,3,
+0x2f6a00,1,
+0x2f6a08,3,
+0x2f6a1c,8,
+0x2f6a40,3,
+0x2f6a50,3,
+0x2f6a80,1,
+0x2f6a88,3,
+0x2f6a9c,8,
+0x2f6ac0,3,
+0x2f6ad0,3,
+0x2f6b00,1,
+0x2f6b08,3,
+0x2f6b1c,8,
+0x2f6b40,3,
+0x2f6b50,3,
+0x2f6b80,1,
+0x2f6b88,3,
+0x2f6b9c,8,
+0x2f6bc0,3,
+0x2f6bd0,3,
+0x2f6c00,1,
+0x2f6c08,3,
+0x2f6c1c,8,
+0x2f6c40,3,
+0x2f6c50,3,
+0x2f6c80,2,
+0x2f6c94,13,
+0x2f7000,6,
+0x2f7020,3,
+0x2f7034,1,
+0x2f7040,7,
+0x2f7060,6,
+0x2f7100,5,
+0x2f7138,1,
+0x2f7144,1,
+0x2f7400,1,
+0x2f7418,1,
+0x2f7434,1,
+0x2f752c,5,
+0x2f7590,1,
+0x2f75ac,1,
+0x2f75d8,4,
+0x2f7600,8,
+0x2f8000,6,
+0x2f8020,3,
+0x2f8030,9,
+0x2f8080,6,
+0x2f8100,20,
+0x2f8400,1,
+0x2f8418,1,
+0x2f8434,1,
+0x2f852c,4,
+0x2f8590,1,
+0x2f85ac,1,
+0x2f85d8,4,
+0x2f8600,8,
+0x2f9000,6,
+0x2f9020,6,
+0x2f9040,3,
+0x2f9080,14,
+0x2f90bc,1,
+0x2f90c4,13,
+0x2f90fc,6,
+0x2f9120,5,
+0x2f9190,10,
+0x2f9200,16,
+0x2f9244,32,
+0x2f9300,26,
+0x2f9380,2,
+0x2f93a0,1,
+0x2f93c0,11,
+0x2f9404,4,
+0x2f9418,16,
+0x2f9460,3,
+0x2f9500,6,
+0x2f9540,1,
+0x2f9558,2,
+0x2f9600,17,
+0x2f9800,366,
+0x2fa000,6,
+0x2fa020,6,
+0x2fa040,3,
+0x2fa080,14,
+0x2fa0bc,1,
+0x2fa0c4,13,
+0x2fa0fc,6,
+0x2fa120,5,
+0x2fa190,10,
+0x2fa200,16,
+0x2fa244,32,
+0x2fa300,26,
+0x2fa380,2,
+0x2fa3a0,1,
+0x2fa3c0,11,
+0x2fa404,4,
+0x2fa418,16,
+0x2fa460,3,
+0x2fa500,6,
+0x2fa540,1,
+0x2fa558,2,
+0x2fa600,17,
+0x2fa800,366,
+0x2fb000,4,
+0x2fb020,9,
+0x2fb048,6,
+0x2fb064,6,
+0x2fb080,1,
+0x2fb100,4,
+0x2fb120,9,
+0x2fb148,6,
+0x2fb164,6,
+0x2fb180,1,
+0x2fb200,35,
+0x2fb290,6,
+0x2fb2b4,6,
+0x2fb2d0,5,
+0x2fb2e8,5,
+0x2fb300,37,
+0x2fb400,6,
+0x2fb420,3,
+0x2fb438,4,
+0x2fb454,3,
+0x2fb478,4,
+0x2fb494,3,
+0x2fb800,5,
+0x2fb818,1,
+0x2fb854,6,
+0x2fb880,2,
+0x2fb8a4,1,
+0x2fba00,28,
+0x2fba7c,5,
+0x2fbab0,2,
+0x2fbabc,10,
+0x2fbb00,2,
+0x2fbb0c,7,
+0x2fbb34,9,
+0x2fbb60,6,
+0x2fbb80,8,
+0x2fbc00,5,
+0x2fbc18,1,
+0x2fbc54,6,
+0x2fbc80,2,
+0x2fbca4,1,
+0x2fbe00,28,
+0x2fbe7c,5,
+0x2fbeb0,2,
+0x2fbebc,10,
+0x2fbf00,2,
+0x2fbf0c,7,
+0x2fbf34,9,
+0x2fbf60,6,
+0x2fbf80,8,
+0x2fc000,4,
+0x2fc014,10,
+0x2fc040,1,
+0x2fc048,3,
+0x2fc058,1,
+0x2fc060,1,
+0x2fc07c,1,
+0x2fc500,1,
+0x2fc518,2,
+0x2fc540,6,
+0x2fc800,4,
+0x2fc814,10,
+0x2fc840,1,
+0x2fc848,3,
+0x2fc858,1,
+0x2fc860,1,
+0x2fc87c,1,
+0x2fcd00,1,
+0x2fcd18,2,
+0x2fcd40,6,
+0x2fd800,2,
+0x2fd818,2,
+0x2fd834,2,
+0x2fd92c,6,
+0x2fd990,2,
+0x2fd9ac,1,
+0x2fd9d8,4,
+0x2fda00,16,
+0x2fdc00,3,
+0x2fdc20,2,
+0x2fdc40,1,
+0x300000,5,
+0x300020,4,
+0x300034,9,
+0x30005c,7,
+0x300080,1,
+0x3000a0,6,
+0x300100,5,
+0x300120,4,
+0x300134,9,
+0x30015c,7,
+0x300180,1,
+0x3001a0,6,
+0x300200,5,
+0x300220,4,
+0x300234,9,
+0x30025c,7,
+0x300280,1,
+0x3002a0,6,
+0x300300,5,
+0x300320,4,
+0x300334,9,
+0x30035c,7,
+0x300380,1,
+0x3003a0,6,
+0x300400,4,
+0x300440,4,
+0x300480,3,
+0x3004c0,3,
+0x300500,5,
+0x300518,8,
+0x300c00,13,
+0x300c40,11,
+0x300c80,13,
+0x300cc0,11,
+0x300d00,6,
+0x300d20,6,
+0x300e00,10,
+0x300e40,11,
+0x300e80,8,
+0x301000,2,
+0x301010,5,
+0x301040,3,
+0x301050,3,
+0x301060,7,
+0x301080,7,
+0x3010a0,7,
+0x3010c0,7,
+0x301100,7,
+0x301140,7,
+0x301180,5,
+0x30119c,9,
+0x301218,9,
+0x301240,3,
+0x301250,6,
+0x301280,1,
+0x301288,6,
+0x3012a4,1,
+0x3012c0,1,
+0x3012c8,6,
+0x3012e4,1,
+0x301400,8,
+0x301424,2,
+0x301500,3,
+0x301520,4,
+0x301540,3,
+0x301560,4,
+0x301800,24,
+0x301864,2,
+0x301880,6,
+0x301900,12,
+0x301940,6,
+0x301960,6,
+0x301980,4,
+0x3019c0,6,
+0x3019dc,1,
+0x301a00,6,
+0x301a1c,1,
+0x301a40,1,
+0x301a68,23,
+0x301b00,17,
+0x301b80,12,
+0x302000,5,
+0x302020,4,
+0x302034,9,
+0x30205c,7,
+0x302080,1,
+0x3020a0,6,
+0x302100,5,
+0x302120,4,
+0x302134,9,
+0x30215c,7,
+0x302180,1,
+0x3021a0,6,
+0x302200,5,
+0x302220,4,
+0x302234,9,
+0x30225c,7,
+0x302280,1,
+0x3022a0,6,
+0x302300,5,
+0x302320,4,
+0x302334,9,
+0x30235c,7,
+0x302380,1,
+0x3023a0,6,
+0x302400,4,
+0x302440,4,
+0x302480,3,
+0x3024c0,3,
+0x302500,5,
+0x302518,8,
+0x302c00,13,
+0x302c40,11,
+0x302c80,13,
+0x302cc0,11,
+0x302d00,6,
+0x302d20,6,
+0x302e00,10,
+0x302e40,11,
+0x302e80,8,
+0x303000,2,
+0x303010,5,
+0x303040,3,
+0x303050,3,
+0x303060,7,
+0x303080,7,
+0x3030a0,7,
+0x3030c0,7,
+0x303100,7,
+0x303140,7,
+0x303180,5,
+0x30319c,9,
+0x303218,9,
+0x303240,3,
+0x303250,6,
+0x303280,1,
+0x303288,6,
+0x3032a4,1,
+0x3032c0,1,
+0x3032c8,6,
+0x3032e4,1,
+0x303400,8,
+0x303424,2,
+0x303500,3,
+0x303520,4,
+0x303540,3,
+0x303560,4,
+0x303800,24,
+0x303864,2,
+0x303880,6,
+0x303900,12,
+0x303940,6,
+0x303960,6,
+0x303980,4,
+0x3039c0,6,
+0x3039dc,1,
+0x303a00,6,
+0x303a1c,1,
+0x303a40,1,
+0x303a68,23,
+0x303b00,17,
+0x303b80,12,
+0x304000,4,
+0x304014,6,
+0x304030,5,
+0x304080,4,
+0x304094,6,
+0x3040b0,5,
+0x304100,4,
+0x304114,6,
+0x304130,5,
+0x304180,4,
+0x304194,6,
+0x3041b0,5,
+0x304200,3,
+0x304210,23,
+0x304500,3,
+0x304510,12,
+0x304580,3,
+0x304590,12,
+0x304600,3,
+0x304610,12,
+0x304680,3,
+0x304690,12,
+0x304700,4,
+0x304718,13,
+0x304800,25,
+0x304880,25,
+0x304900,25,
+0x304980,25,
+0x304a00,17,
+0x304a50,3,
+0x304a60,3,
+0x305000,4,
+0x305014,6,
+0x305030,5,
+0x305080,4,
+0x305094,6,
+0x3050b0,5,
+0x305100,4,
+0x305114,6,
+0x305130,5,
+0x305180,4,
+0x305194,6,
+0x3051b0,5,
+0x305200,3,
+0x305210,23,
+0x305500,3,
+0x305510,12,
+0x305580,3,
+0x305590,12,
+0x305600,3,
+0x305610,12,
+0x305680,3,
+0x305690,12,
+0x305700,4,
+0x305718,13,
+0x305800,25,
+0x305880,25,
+0x305900,25,
+0x305980,25,
+0x305a00,17,
+0x305a50,3,
+0x305a60,3,
+0x306000,13,
+0x306040,22,
+0x3060a0,6,
+0x3060c0,3,
+0x306100,9,
+0x306400,2,
+0x30640c,6,
+0x306440,13,
+0x306480,16,
+0x306800,1,
+0x306808,3,
+0x30681c,8,
+0x306840,3,
+0x306850,3,
+0x306880,1,
+0x306888,3,
+0x30689c,8,
+0x3068c0,3,
+0x3068d0,3,
+0x306900,1,
+0x306908,3,
+0x30691c,8,
+0x306940,3,
+0x306950,3,
+0x306980,1,
+0x306988,3,
+0x30699c,8,
+0x3069c0,3,
+0x3069d0,3,
+0x306a00,1,
+0x306a08,3,
+0x306a1c,8,
+0x306a40,3,
+0x306a50,3,
+0x306a80,1,
+0x306a88,3,
+0x306a9c,8,
+0x306ac0,3,
+0x306ad0,3,
+0x306b00,1,
+0x306b08,3,
+0x306b1c,8,
+0x306b40,3,
+0x306b50,3,
+0x306b80,1,
+0x306b88,3,
+0x306b9c,8,
+0x306bc0,3,
+0x306bd0,3,
+0x306c00,1,
+0x306c08,3,
+0x306c1c,8,
+0x306c40,3,
+0x306c50,3,
+0x306c80,2,
+0x306c94,13,
+0x307000,6,
+0x307020,3,
+0x307034,1,
+0x307040,7,
+0x307060,6,
+0x307100,5,
+0x307138,1,
+0x307144,1,
+0x307400,1,
+0x307418,1,
+0x307434,1,
+0x30752c,5,
+0x307590,1,
+0x3075ac,1,
+0x3075d8,4,
+0x307600,8,
+0x308000,6,
+0x308020,3,
+0x308030,9,
+0x308080,6,
+0x308100,20,
+0x308400,1,
+0x308418,1,
+0x308434,1,
+0x30852c,4,
+0x308590,1,
+0x3085ac,1,
+0x3085d8,4,
+0x308600,8,
+0x309000,6,
+0x309020,6,
+0x309040,3,
+0x309080,14,
+0x3090bc,1,
+0x3090c4,13,
+0x3090fc,6,
+0x309120,5,
+0x309190,10,
+0x309200,16,
+0x309244,32,
+0x309300,26,
+0x309380,2,
+0x3093a0,1,
+0x3093c0,11,
+0x309404,4,
+0x309418,16,
+0x309460,3,
+0x309500,6,
+0x309540,1,
+0x309558,2,
+0x309600,17,
+0x309800,366,
+0x30a000,6,
+0x30a020,6,
+0x30a040,3,
+0x30a080,14,
+0x30a0bc,1,
+0x30a0c4,13,
+0x30a0fc,6,
+0x30a120,5,
+0x30a190,10,
+0x30a200,16,
+0x30a244,32,
+0x30a300,26,
+0x30a380,2,
+0x30a3a0,1,
+0x30a3c0,11,
+0x30a404,4,
+0x30a418,16,
+0x30a460,3,
+0x30a500,6,
+0x30a540,1,
+0x30a558,2,
+0x30a600,17,
+0x30a800,366,
+0x30b000,4,
+0x30b020,9,
+0x30b048,6,
+0x30b064,6,
+0x30b080,1,
+0x30b100,4,
+0x30b120,9,
+0x30b148,6,
+0x30b164,6,
+0x30b180,1,
+0x30b200,35,
+0x30b290,6,
+0x30b2b4,6,
+0x30b2d0,5,
+0x30b2e8,5,
+0x30b300,37,
+0x30b400,6,
+0x30b420,3,
+0x30b438,4,
+0x30b454,3,
+0x30b478,4,
+0x30b494,3,
+0x30b800,5,
+0x30b818,1,
+0x30b854,6,
+0x30b880,2,
+0x30b8a4,1,
+0x30ba00,28,
+0x30ba7c,5,
+0x30bab0,2,
+0x30babc,10,
+0x30bb00,2,
+0x30bb0c,7,
+0x30bb34,9,
+0x30bb60,6,
+0x30bb80,8,
+0x30bc00,5,
+0x30bc18,1,
+0x30bc54,6,
+0x30bc80,2,
+0x30bca4,1,
+0x30be00,28,
+0x30be7c,5,
+0x30beb0,2,
+0x30bebc,10,
+0x30bf00,2,
+0x30bf0c,7,
+0x30bf34,9,
+0x30bf60,6,
+0x30bf80,8,
+0x30c000,4,
+0x30c014,10,
+0x30c040,1,
+0x30c048,3,
+0x30c058,1,
+0x30c060,1,
+0x30c07c,1,
+0x30c500,1,
+0x30c518,2,
+0x30c540,6,
+0x30c800,4,
+0x30c814,10,
+0x30c840,1,
+0x30c848,3,
+0x30c858,1,
+0x30c860,1,
+0x30c87c,1,
+0x30cd00,1,
+0x30cd18,2,
+0x30cd40,6,
+0x30d800,2,
+0x30d818,2,
+0x30d834,2,
+0x30d92c,6,
+0x30d990,2,
+0x30d9ac,1,
+0x30d9d8,4,
+0x30da00,16,
+0x30dc00,3,
+0x30dc20,2,
+0x30dc40,1,
+0x310000,5,
+0x310020,4,
+0x310034,9,
+0x31005c,7,
+0x310080,1,
+0x3100a0,6,
+0x310100,5,
+0x310120,4,
+0x310134,9,
+0x31015c,7,
+0x310180,1,
+0x3101a0,6,
+0x310200,5,
+0x310220,4,
+0x310234,9,
+0x31025c,7,
+0x310280,1,
+0x3102a0,6,
+0x310300,5,
+0x310320,4,
+0x310334,9,
+0x31035c,7,
+0x310380,1,
+0x3103a0,6,
+0x310400,4,
+0x310440,4,
+0x310480,3,
+0x3104c0,3,
+0x310500,5,
+0x310518,8,
+0x310c00,13,
+0x310c40,11,
+0x310c80,13,
+0x310cc0,11,
+0x310d00,6,
+0x310d20,6,
+0x310e00,10,
+0x310e40,11,
+0x310e80,8,
+0x311000,2,
+0x311010,5,
+0x311040,3,
+0x311050,3,
+0x311060,7,
+0x311080,7,
+0x3110a0,7,
+0x3110c0,7,
+0x311100,7,
+0x311140,7,
+0x311180,5,
+0x31119c,9,
+0x311218,9,
+0x311240,3,
+0x311250,6,
+0x311280,1,
+0x311288,6,
+0x3112a4,1,
+0x3112c0,1,
+0x3112c8,6,
+0x3112e4,1,
+0x311400,8,
+0x311424,2,
+0x311500,3,
+0x311520,4,
+0x311540,3,
+0x311560,4,
+0x311800,24,
+0x311864,2,
+0x311880,6,
+0x311900,12,
+0x311940,6,
+0x311960,6,
+0x311980,4,
+0x3119c0,6,
+0x3119dc,1,
+0x311a00,6,
+0x311a1c,1,
+0x311a40,1,
+0x311a68,23,
+0x311b00,17,
+0x311b80,12,
+0x312000,5,
+0x312020,4,
+0x312034,9,
+0x31205c,7,
+0x312080,1,
+0x3120a0,6,
+0x312100,5,
+0x312120,4,
+0x312134,9,
+0x31215c,7,
+0x312180,1,
+0x3121a0,6,
+0x312200,5,
+0x312220,4,
+0x312234,9,
+0x31225c,7,
+0x312280,1,
+0x3122a0,6,
+0x312300,5,
+0x312320,4,
+0x312334,9,
+0x31235c,7,
+0x312380,1,
+0x3123a0,6,
+0x312400,4,
+0x312440,4,
+0x312480,3,
+0x3124c0,3,
+0x312500,5,
+0x312518,8,
+0x312c00,13,
+0x312c40,11,
+0x312c80,13,
+0x312cc0,11,
+0x312d00,6,
+0x312d20,6,
+0x312e00,10,
+0x312e40,11,
+0x312e80,8,
+0x313000,2,
+0x313010,5,
+0x313040,3,
+0x313050,3,
+0x313060,7,
+0x313080,7,
+0x3130a0,7,
+0x3130c0,7,
+0x313100,7,
+0x313140,7,
+0x313180,5,
+0x31319c,9,
+0x313218,9,
+0x313240,3,
+0x313250,6,
+0x313280,1,
+0x313288,6,
+0x3132a4,1,
+0x3132c0,1,
+0x3132c8,6,
+0x3132e4,1,
+0x313400,8,
+0x313424,2,
+0x313500,3,
+0x313520,4,
+0x313540,3,
+0x313560,4,
+0x313800,24,
+0x313864,2,
+0x313880,6,
+0x313900,12,
+0x313940,6,
+0x313960,6,
+0x313980,4,
+0x3139c0,6,
+0x3139dc,1,
+0x313a00,6,
+0x313a1c,1,
+0x313a40,1,
+0x313a68,23,
+0x313b00,17,
+0x313b80,12,
+0x314000,4,
+0x314014,6,
+0x314030,5,
+0x314080,4,
+0x314094,6,
+0x3140b0,5,
+0x314100,4,
+0x314114,6,
+0x314130,5,
+0x314180,4,
+0x314194,6,
+0x3141b0,5,
+0x314200,3,
+0x314210,23,
+0x314500,3,
+0x314510,12,
+0x314580,3,
+0x314590,12,
+0x314600,3,
+0x314610,12,
+0x314680,3,
+0x314690,12,
+0x314700,4,
+0x314718,13,
+0x314800,25,
+0x314880,25,
+0x314900,25,
+0x314980,25,
+0x314a00,17,
+0x314a50,3,
+0x314a60,3,
+0x315000,4,
+0x315014,6,
+0x315030,5,
+0x315080,4,
+0x315094,6,
+0x3150b0,5,
+0x315100,4,
+0x315114,6,
+0x315130,5,
+0x315180,4,
+0x315194,6,
+0x3151b0,5,
+0x315200,3,
+0x315210,23,
+0x315500,3,
+0x315510,12,
+0x315580,3,
+0x315590,12,
+0x315600,3,
+0x315610,12,
+0x315680,3,
+0x315690,12,
+0x315700,4,
+0x315718,13,
+0x315800,25,
+0x315880,25,
+0x315900,25,
+0x315980,25,
+0x315a00,17,
+0x315a50,3,
+0x315a60,3,
+0x316000,13,
+0x316040,22,
+0x3160a0,6,
+0x3160c0,3,
+0x316100,9,
+0x316400,2,
+0x31640c,6,
+0x316440,13,
+0x316480,16,
+0x316800,1,
+0x316808,3,
+0x31681c,8,
+0x316840,3,
+0x316850,3,
+0x316880,1,
+0x316888,3,
+0x31689c,8,
+0x3168c0,3,
+0x3168d0,3,
+0x316900,1,
+0x316908,3,
+0x31691c,8,
+0x316940,3,
+0x316950,3,
+0x316980,1,
+0x316988,3,
+0x31699c,8,
+0x3169c0,3,
+0x3169d0,3,
+0x316a00,1,
+0x316a08,3,
+0x316a1c,8,
+0x316a40,3,
+0x316a50,3,
+0x316a80,1,
+0x316a88,3,
+0x316a9c,8,
+0x316ac0,3,
+0x316ad0,3,
+0x316b00,1,
+0x316b08,3,
+0x316b1c,8,
+0x316b40,3,
+0x316b50,3,
+0x316b80,1,
+0x316b88,3,
+0x316b9c,8,
+0x316bc0,3,
+0x316bd0,3,
+0x316c00,1,
+0x316c08,3,
+0x316c1c,8,
+0x316c40,3,
+0x316c50,3,
+0x316c80,2,
+0x316c94,13,
+0x317000,6,
+0x317020,3,
+0x317034,1,
+0x317040,7,
+0x317060,6,
+0x317100,5,
+0x317138,1,
+0x317144,1,
+0x317400,1,
+0x317418,1,
+0x317434,1,
+0x31752c,5,
+0x317590,1,
+0x3175ac,1,
+0x3175d8,4,
+0x317600,8,
+0x318000,6,
+0x318020,3,
+0x318030,9,
+0x318080,6,
+0x318100,20,
+0x318400,1,
+0x318418,1,
+0x318434,1,
+0x31852c,4,
+0x318590,1,
+0x3185ac,1,
+0x3185d8,4,
+0x318600,8,
+0x319000,6,
+0x319020,6,
+0x319040,3,
+0x319080,14,
+0x3190bc,1,
+0x3190c4,13,
+0x3190fc,6,
+0x319120,5,
+0x319190,10,
+0x319200,16,
+0x319244,32,
+0x319300,26,
+0x319380,2,
+0x3193a0,1,
+0x3193c0,11,
+0x319404,4,
+0x319418,16,
+0x319460,3,
+0x319500,6,
+0x319540,1,
+0x319558,2,
+0x319600,17,
+0x319800,366,
+0x31a000,6,
+0x31a020,6,
+0x31a040,3,
+0x31a080,14,
+0x31a0bc,1,
+0x31a0c4,13,
+0x31a0fc,6,
+0x31a120,5,
+0x31a190,10,
+0x31a200,16,
+0x31a244,32,
+0x31a300,26,
+0x31a380,2,
+0x31a3a0,1,
+0x31a3c0,11,
+0x31a404,4,
+0x31a418,16,
+0x31a460,3,
+0x31a500,6,
+0x31a540,1,
+0x31a558,2,
+0x31a600,17,
+0x31a800,366,
+0x31b000,4,
+0x31b020,9,
+0x31b048,6,
+0x31b064,6,
+0x31b080,1,
+0x31b100,4,
+0x31b120,9,
+0x31b148,6,
+0x31b164,6,
+0x31b180,1,
+0x31b200,35,
+0x31b290,6,
+0x31b2b4,6,
+0x31b2d0,5,
+0x31b2e8,5,
+0x31b300,37,
+0x31b400,6,
+0x31b420,3,
+0x31b438,4,
+0x31b454,3,
+0x31b478,4,
+0x31b494,3,
+0x31b800,5,
+0x31b818,1,
+0x31b854,6,
+0x31b880,2,
+0x31b8a4,1,
+0x31ba00,28,
+0x31ba7c,5,
+0x31bab0,2,
+0x31babc,10,
+0x31bb00,2,
+0x31bb0c,7,
+0x31bb34,9,
+0x31bb60,6,
+0x31bb80,8,
+0x31bc00,5,
+0x31bc18,1,
+0x31bc54,6,
+0x31bc80,2,
+0x31bca4,1,
+0x31be00,28,
+0x31be7c,5,
+0x31beb0,2,
+0x31bebc,10,
+0x31bf00,2,
+0x31bf0c,7,
+0x31bf34,9,
+0x31bf60,6,
+0x31bf80,8,
+0x31c000,4,
+0x31c014,10,
+0x31c040,1,
+0x31c048,3,
+0x31c058,1,
+0x31c060,1,
+0x31c07c,1,
+0x31c500,1,
+0x31c518,2,
+0x31c540,6,
+0x31c800,4,
+0x31c814,10,
+0x31c840,1,
+0x31c848,3,
+0x31c858,1,
+0x31c860,1,
+0x31c87c,1,
+0x31cd00,1,
+0x31cd18,2,
+0x31cd40,6,
+0x31d800,2,
+0x31d818,2,
+0x31d834,2,
+0x31d92c,6,
+0x31d990,2,
+0x31d9ac,1,
+0x31d9d8,4,
+0x31da00,16,
+0x31dc00,3,
+0x31dc20,2,
+0x31dc40,1,
index 4391871e2de87be0fabc26619c2be9bc287603d2..399c5e4db228e81c951f589d11465c772172ac83 100644 (file)
@@ -1,14 +1,19 @@
+%{!?ibmadlib: %define ibmadlib libibmad-devel}
+%{!?name: %define name mstflint}
+%{!?version: %define version @VERSION@}
+%{!?release: %define release 1}
+
 Summary: Mellanox firmware burning application
-Name: mstflint
-Version: @VERSION@
-Release: 1
+Name: %{name}
+Version: %{version}
+Release: %{release}
 License: GPL/BSD
 Url: http://openfabrics.org
 Group: System Environment/Base
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
-Source: mstflint-@VERSION@.tar.gz
+Source: %{name}-%{version}.tar.gz
 ExclusiveArch: i386 i486 i586 i686 x86_64 ia64 ppc ppc64
-BuildRequires: zlib-devel
+BuildRequires: zlib-devel %{ibmadlib}
 
 %description
 This package contains firmware update tool, vpd dump and register dump tools
@@ -18,7 +23,17 @@ for network adapters based on Mellanox Technologies chips.
 %setup -q
 
 %build
-%configure
+
+%if %{ppcbuild}
+    config_flags="$config_flags -host=ppc-linux MST_CPU=ppc MST_EMBEDDED=1 --without-pythontools"
+%endif
+
+%if %{ppc64build}
+    config_flags="$config_flags -host=ppc64-linux MST_CPU=ppc64 --without-pythontools"
+%endif
+
+%configure ${config_flags}
+
 make
 
 %install
@@ -39,6 +54,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/mstmtserver
 %{_bindir}/mstvpd
 %{_bindir}/mstmcra
+%{_bindir}/mstconfig
 %{_bindir}/hca_self_test.ofed
 %{_includedir}/mtcr_ul/mtcr.h
 %{_libdir}/libmtcr_ul.a
@@ -46,6 +62,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/*
 
 %changelog
+* Mon Mar 31 2014 Oren Kladnitsky <orenk@dev.mellanox.co.il>
+   MFT 3.6.0 Updates
+
 * Tue Dec 24 2013 Oren Kladnitsky <orenk@dev.mellanox.co.il>
    MFT 3.5.0 Updates
 
index 3d039d5908927c4ef477cd7449a3c3754272fa3f..de6cdea43a8cdd07ddba4f92e6b55922c0ffdcbc 100644 (file)
 #--
 
 # Makefile.am -- Process this file with automake to produce Makefile.in
-INCLUDES = -I$(top_srcdir)/include/mtcr_ul
+INCLUDES = -I$(top_srcdir)/include/mtcr_ul -I$(top_srcdir)/common
 
 lib_LIBRARIES = libmtcr_ul.a
 
-libmtcr_ul_a_SOURCES = mtcr_ul.c mtcr_ib.h  mtcr_int_defs.h
+libmtcr_ul_a_SOURCES = mtcr_ul.c mtcr_ib.h  mtcr_int_defs.h\
+                       mtcr_tools_cif.c mtcr_tools_cif.h\
+                       packets_common.c packets_common.h\
+                       packets_layout.c packets_layout.h
 libmtcr_ul_a_CFLAGS = -W -Wall -g -MP -MD -fPIC -DMTCR_API="" -DMST_UL
 
 if ENABLE_INBAND
index 991369fbcb523dc50b246fa37028cbae1759855d..96298c288f5f0191b42bbf751d73b0069bab1b9c 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -30,7 +30,6 @@
  * SOFTWARE.
  */
 
-
 /*
  *
  *  mtcr_ib.h - Mellanox Software tools (mst) IB related driver definitions
 #ifndef _MTCR_IB_H
 #define _MTCR_IB_H
 
-MTCR_API int mib_open(const char *name, mfile *mf, int mad_init);
-MTCR_API int mib_close(mfile *mf);
-MTCR_API int mib_read4(mfile *mf, unsigned int offset, u_int32_t *value);
-MTCR_API int mib_write4(mfile *mf, unsigned int offset, u_int32_t value);
-MTCR_API int mib_read64(mfile *mf, unsigned int offset, void *data, int length);
-MTCR_API int mib_write64(mfile *mf, unsigned int offset, void *data, int length);
-
-MTCR_API int mib_readblock(mfile *mf, unsigned int offset, u_int32_t *data, int length);
-MTCR_API int mib_writeblock(mfile *mf, unsigned int offset, u_int32_t *data, int length);
+#ifdef __WIN__
+    #include <mtcr.h>
+#endif
 
-MTCR_API int mib_swreset(mfile *mf);
-MTCR_API int mib_get_chunk_size(mfile *mf);
-MTCR_API int mib_acces_reg_mad(mfile *mf, u_int8_t *data);
+int mib_open(const char *name, mfile *mf, int mad_init);
+int mib_close(mfile *mf);
+int mib_read4(mfile *mf, unsigned int offset, u_int32_t *value);
+int mib_write4(mfile *mf, unsigned int offset, u_int32_t value);
+int mib_read64(mfile *mf, unsigned int offset, void *data, int length);
+int mib_write64(mfile *mf, unsigned int offset, void *data, int length);
+
+int mib_readblock(mfile *mf, unsigned int offset, u_int32_t *data, int length);
+int mib_writeblock(mfile *mf, unsigned int offset, u_int32_t *data, int length);
+int mib_swreset(mfile *mf);
+int mib_get_chunk_size(mfile *mf);
+int mib_acces_reg_mad(mfile *mf, u_int8_t *data);
 
 
 #endif
index d8206cd52ae9513ab8c58b82f82745f8746560f0..df06209aa351eb31c8daf4561e57980c33493727 100644 (file)
@@ -30,7 +30,6 @@
  * SOFTWARE.
  */
 
-
 /********************************************************
 **
 *   ibvsmad.c
 #define SWITCHX_DEV_ID    0xc738
 #define CONNECTIB_DEV_ID  0x1011
 
+// Convert BYTES - DWORDS with MEMCPY BE
+#define BYTES_TO_DWORD_BE(dw_dest, byte_src) do {   u_int32_t tmp;\
+                                                    memcpy(&tmp, byte_src, 4);\
+                                                    *(dw_dest) = __be32_to_cpu(tmp);\
+                                                } while (0)
+
+#define DWORD_TO_BYTES_BE(bytes_dest, dw_src) do { u_int32_t tmp;\
+                                                   tmp = __cpu_to_be32(*(dw_src));\
+                                                   memcpy(bytes_dest, &tmp, 4);\
+                                                 } while (0)
+
 
 typedef struct ibmad_port* IBMAD_CALL_CONV (*f_mad_rpc_open_port)(char *dev_name, int dev_port,
                                                 int *mgmt_classes,
@@ -246,6 +256,7 @@ ibvsmad_craccess_rw_smp(ibvs_mad *h, u_int32_t memory_address, int method, u_int
     int i;
     u_int32_t att_mod = 0;
     u_int8_t* p;
+    u_int64_t vkey;
 
     if (num_of_dwords > MAX_IB_SMP_DATA_DW_NUM) {
         IBERROR(("size is too big, maximum number of dwords is %d", MAX_IB_SMP_DATA_DW_NUM));
@@ -259,7 +270,8 @@ ibvsmad_craccess_rw_smp(ibvs_mad *h, u_int32_t memory_address, int method, u_int
     att_mod = MERGE(att_mod, EXTRACT(memory_address, 16, 8), 24, 8);
 
     // Set the vkey
-    *((u_int64_t*)&(mad_data[0])) = __cpu_to_be64(h->vkey);
+    vkey = __cpu_to_be64(h->vkey);
+    memcpy(&mad_data[0], &vkey, 8);
 
     // DW Size:
     att_mod = MERGE(att_mod, num_of_dwords, 16, 6);
@@ -270,13 +282,13 @@ ibvsmad_craccess_rw_smp(ibvs_mad *h, u_int32_t memory_address, int method, u_int
         if (!p) {
             return BAD_RET_VAL;
         }
-        for (i = 0; i < num_of_dwords; i++) {
-            data[i] = __be32_to_cpu(*((u_int32_t*)&(mad_data[IB_DATA_INDEX + i * 4])));
 
+        for (i = 0; i < num_of_dwords; i++) {
+            BYTES_TO_DWORD_BE(data + i, mad_data + IB_DATA_INDEX + i * 4);
         }
     } else {
         for (i = 0; i < num_of_dwords; i++) {
-            *((u_int32_t*)&(mad_data[IB_DATA_INDEX + i * 4])) = __cpu_to_be32(data[i]);
+            DWORD_TO_BYTES_BE(mad_data + IB_DATA_INDEX + i * 4, data + i);
         }
         p = h->smp_set_via(mad_data, &h->portid, IB_SMP_ATTR_CR_ACCESS, att_mod, 0, h->srcport);
         if (!p) {
@@ -298,6 +310,7 @@ ibvsmad_craccess_rw_vs(ibvs_mad *h, u_int32_t memory_address, int method, u_int8
     ib_vendor_call_t call;
     int i;
     u_int8_t* p;
+    u_int64_t vkey;
 
     call.method     = method;
     call.mgmt_class = IB_VENDOR_SPECIFIC_CLASS_0x9;
@@ -331,11 +344,12 @@ ibvsmad_craccess_rw_vs(ibvs_mad *h, u_int32_t memory_address, int method, u_int8
     // building one record:
 
     // Set the Vkey.
-    *((u_int64_t*)&(vsmad_data[0])) = __cpu_to_be64(h->vkey);
+    vkey = __cpu_to_be64(h->vkey);
+    memcpy(vsmad_data, &vkey, 8);
 
     if (method == IB_MAD_METHOD_SET)  {
         for (i = 0; i < num_of_dwords; i++) {
-            *((u_int32_t*)&(vsmad_data[IB_DATA_INDEX + i * 4])) = __cpu_to_be32(data[i]);
+            DWORD_TO_BYTES_BE(vsmad_data + IB_DATA_INDEX + i * 4, data + i);
         }
     }
 
@@ -345,7 +359,7 @@ ibvsmad_craccess_rw_vs(ibvs_mad *h, u_int32_t memory_address, int method, u_int8
     }
 
     for (i = 0; i < num_of_dwords; i++) {
-        data[i] = __be32_to_cpu(*((u_int32_t*)&(vsmad_data[IB_DATA_INDEX + i * 4])));
+        BYTES_TO_DWORD_BE(data + i, vsmad_data + IB_DATA_INDEX + i * 4);
     }
 
     return 0;
@@ -367,8 +381,6 @@ ibvsmad_craccess_rw(ibvs_mad *h, u_int32_t memory_address, int method, u_int8_t
 
 int process_dynamic_linking(ibvs_mad *ivm, int mad_init)
 {
-    int i;
-
 
     ivm->dl_handle = LoadLibrary(TEXT(LIB_IBMAD));
 
@@ -388,7 +400,7 @@ int process_dynamic_linking(ibvs_mad *ivm, int mad_init)
 
     } else {
 
-        IBERROR(("Failed to load "LIB_IBMAD".dll library %#x", GetLastError()));
+        IBERROR(("Failed to load "LIB_IBMAD".dll library %#x", (unsigned int)GetLastError()));
         errno = ENOENT;
         return -1;
     }
@@ -403,10 +415,11 @@ int free_dll_handle(mfile *mf) {
 
 int process_dynamic_linking(ibvs_mad *ivm, int mad_init)
 {
-    (void)mad_init;
+
     char* libs[] = {"libibmad.so.5"};
 
     u_int32_t i;
+    (void)mad_init;
     for (i = 0; i < sizeof(libs)/sizeof(libs[0]) ; i++) {
         ivm->dl_handle = dlopen (libs[i], RTLD_LAZY);
         if (ivm->dl_handle) {
@@ -538,7 +551,7 @@ int mib_open(const char *name, mfile *mf, int mad_init)
     int          dest_type       = IB_DEST_LID;
     ibvs_mad    *ivm;
     char        *nbuf            = NULL;
-    char        *path_str;
+    char        *path_str, *p;
     int          rc              = -1;
     char        *sl_str;
 
@@ -567,14 +580,15 @@ int mib_open(const char *name, mfile *mf, int mad_init)
         ivm->use_smp = 1;
         dest_type = IB_DEST_LID;
         path_str  = nbuf + 6;
-    } else if (strncmp("lid-", nbuf, 4) == 0) {
+    } else if ((p = strstr(nbuf, "lid-")) != 0) {
         dest_type = IB_DEST_LID;
-        if (strncmp("lid_noinit-", nbuf, 11) == 0) {
-            path_str  = nbuf + 11;
-            mad_init = 0;
-        } else {
-            path_str  = nbuf + 4;
-        }
+               path_str  = p + 4;
+
+    } else if ((p = strstr(nbuf, "lid_noinit-")) != 0) {
+       dest_type = IB_DEST_LID;
+        path_str  = p + 11;
+        mad_init = 0;
+
     } else {
         IBERROR(("Bad device argument for inband access"));
         errno = EINVAL;
index c022157d1b3e5e24308826174651b0df3f55704f..3efe2daed32446b89ba1856603bc11125a143752 100644 (file)
@@ -1,6 +1,5 @@
 /*
- *
- * Copyright (c) 2013 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- *
+ * 
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- *
+ * 
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -29,9 +28,6 @@
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
- *  mtcr_int_defs.c - Mellanox Hardware Access lib internal definitions
- *
  */
 
 #ifndef MTCR_INT_DEFS
@@ -47,6 +43,13 @@ typedef int (*f_maccess_reg)   (mfile *mf, u_int8_t *data);
 typedef int (*f_mclose)        (mfile* mf);
 
 
+typedef struct icmd_params_t {
+       int icmd_opened;
+       int took_semaphore;
+       int ctrl_addr;
+       int cmd_addr;
+}icmd_params;
+
 struct mfile_t {
     char*            dev_name;
     void            *ctx; // Access method context
@@ -58,6 +61,9 @@ struct mfile_t {
     f_mwrite4_block  mwrite4_block;
     f_maccess_reg    maccess_reg;
     f_mclose         mclose;
+
+    //for ICMD access
+    icmd_params icmd;
 };
 #endif
 
diff --git a/mtcr_ul/mtcr_tools_cif.c b/mtcr_ul/mtcr_tools_cif.c
new file mode 100644 (file)
index 0000000..b6f83c4
--- /dev/null
@@ -0,0 +1,453 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <bit_slice.h>
+#include <common/tools_utils.h>
+#include "mtcr_tools_cif.h"
+
+#define TOOLS_HCR_ADDR      0x80780
+#define CMD_IF_SIZE         28
+#define CMD_IF_WAIT_GO         2000
+
+#define TOOLS_HCR_SEM          0xf03bc // sem47
+#define TOOLS_SEM_TRIES                1024     // Number of tries to obtain a TOOLS sem.
+
+#define QUERY_DEV_CAP_OP       0x3
+#define MBOX_WRITE_OP          0x70
+#define MBOX_READ_OP           0x71
+#define REG_ACCESS_OP          0x3b
+
+#ifdef ESS
+#define MREAD4(offs, val)  do {*val=READ_WORD(offs);} while (0)
+#define MWRITE4(offs, val) do {WRITE_WORD(offs, val);} while (0)
+#else
+#define MREAD4(offs, val)  do { if (mread4 (mf, offs, val) != 4) { \
+                                  /*fprintf(stderr, "-E- Cr read (0x%08x) failed: %s(%d)\n", (u_int32_t)(offs), strerror(errno), (u_int32_t)errno);*/ \
+                  return 2; } /*printf("-D- %s:%d mread4: offs = %#x, val = %#x\n", __FUNCTION__, __LINE__, offs, val);*/\
+                                  } while (0)
+
+#define MWRITE4(offs, val) do { if (mwrite4(mf, offs, val) != 4) { \
+                                  /*fprintf(stderr, "-E- Cr write (0x%08x, 0x%08x) failed: %s(%d)\n", (u_int32_t)(offs), (u_int32_t)(val), strerror(errno), (u_int32_t)errno);*/ \
+                  return 2; } /*printf("-D- %s:%d mwrite4: offs = %#x, val = %#x\n",   __FUNCTION__, __LINE__, offs, val);*/ \
+                                  } while (0)
+#endif
+
+#define TOCPUn(s, n) do {                                          \
+       u_int32_t ii;                                                                                                   \
+    u_int32_t *p = (u_int32_t *)(s);                               \
+    for (ii=0; ii<(n); ii++,p++)                         \
+        *p = __be32_to_cpu(*p);                                    \
+    } while(0)
+
+typedef struct tools_cmdif_t {
+    u_int64_t in_param;
+    u_int64_t out_param;
+    u_int32_t input_modifier;
+    u_int16_t token;
+    u_int16_t opcode;
+    u_int8_t  opcode_modifier;
+    u_int8_t  t;
+    u_int8_t  e;
+    u_int8_t  go;
+    u_int8_t  status;
+} tools_cmdif;
+
+static void tools_cmdif_pack(tools_cmdif* cmd, u_int32_t* buf) {
+    memset((char*)buf, 0, CMD_IF_SIZE);
+    buf[0] = EXTRACT64(cmd->in_param, 32, 32);
+    buf[1] = EXTRACT64(cmd->in_param,  0, 32);
+    buf[2] = cmd->input_modifier;
+    // out h
+    // out l
+    buf[5] = MERGE(buf[5], cmd->token,               16, 16);
+    buf[6] = MERGE(buf[6], cmd->opcode,               0, 12);
+    buf[6] = MERGE(buf[6], cmd->opcode_modifier,     12,  4);
+    buf[6] = MERGE(buf[6], cmd->e,                   22,  1);
+}
+
+static void tools_cmdif_unpack(tools_cmdif* cmd, u_int32_t* buf) {
+    memset(cmd, 0, sizeof(tools_cmdif));
+
+    cmd->in_param       = MERGE64(cmd->in_param, buf[0], 32, 32);
+    cmd->in_param       = MERGE64(cmd->in_param, buf[1],  0, 32);
+    cmd->input_modifier = buf[2];
+    cmd->out_param      = MERGE64(cmd->out_param, buf[3], 32, 32);
+    cmd->out_param      = MERGE64(cmd->out_param, buf[4],  0, 32);
+    cmd->opcode         = EXTRACT(buf[6], 0, 12);
+    cmd->opcode_modifier= EXTRACT(buf[6], 12, 4);
+
+    cmd->status         = EXTRACT(buf[6], 24, 8);
+}
+
+static int tools_cmdif_flash_lock(mfile* mf, int lock_state) {
+    // Obtain Semaphore
+    u_int32_t cnt=0;
+    u_int32_t word;
+    if (lock_state) {
+        do {
+            if (++cnt > TOOLS_SEM_TRIES) {
+                //printf("-E- Can not obtain Flash semaphore");
+                return ME_SEM_LOCKED;
+            }
+            MREAD4(TOOLS_HCR_SEM, &word);
+        } while (word);
+    } else {
+        MWRITE4(TOOLS_HCR_SEM, 0);
+    }
+
+    return ME_OK;
+}
+
+static int tools_cmdif_wait_go(mfile* mf, int* retries)
+{
+    int i;
+    u_int8_t go_bit;
+    int wait=1;
+
+    for (i = 0; i < CMD_IF_WAIT_GO; i++) {
+        u_int32_t word;
+        MREAD4(TOOLS_HCR_ADDR + CMD_IF_SIZE - 4, &word);
+        go_bit = EXTRACT(word, 23, 1);
+        if (!go_bit) {
+            if (retries) {
+                *retries = i;
+            }
+            return 0;
+        }
+        if (i > 5) { // after some iteration put sleeps bwtween busy-wait
+               msleep(wait);  // don't hog the cpu with busy-wait
+               if (wait < 8) {
+                       wait *= 2;    // exponential backoff - up-to 8ms between polls
+               }
+        }
+    }
+    return ME_CMDIF_BUSY;
+}
+
+static int tools_cmdif_send_cmd_int(mfile* mf, tools_cmdif* cmd)
+{
+    u_int32_t raw_cmd[CMD_IF_SIZE/4];
+    int act_retries;
+    int rc;
+
+
+    // Check if the go BIT is ready
+    rc = tools_cmdif_wait_go(mf, NULL);
+    if (rc) {
+        //printf("tools_cmdif_send: GO bit set before command issued (rc=%d)\n", rc);
+        return ME_CMDIF_BUSY;
+    }
+    // Prepare the date of the command we're gonna execute
+    tools_cmdif_pack(cmd, raw_cmd);
+
+    if (mwrite4_block(mf, TOOLS_HCR_ADDR, raw_cmd, CMD_IF_SIZE) != CMD_IF_SIZE) {
+        return ME_CR_ERROR;
+    }
+
+    raw_cmd[6] = MERGE(raw_cmd[6],      1,                   23,  1); // go
+    MWRITE4(TOOLS_HCR_ADDR + 24, raw_cmd[6]);
+
+    rc = tools_cmdif_wait_go(mf, &act_retries);
+
+    if (rc) {
+        return ME_CMDIF_TOUT;
+    }
+
+    if (mread4_block(mf, TOOLS_HCR_ADDR, raw_cmd, CMD_IF_SIZE) != CMD_IF_SIZE) {
+        return ME_CR_ERROR;
+    }
+
+    tools_cmdif_unpack(cmd, raw_cmd);
+
+    if (cmd->status) {
+        //printf("-E- CMD IF Bad status. Op: 0x%x Status: 0x%x\n", cmd->opcode, cmd->status);
+        return ME_CMDIF_BAD_STATUS; // TODO - Special return code here - needs a specific attention
+    }
+    return ME_OK;
+}
+
+int tools_cmdif_send_cmd(mfile* mf,
+                                        u_int64_t in_param,
+                                        u_int64_t* out_param,
+                                        u_int32_t input_modifier,
+                                        u_int16_t opcode,
+                                        u_int8_t  opcode_modifier,
+                                        u_int8_t*  status)
+{
+       if (!mf || !out_param || !status) {
+               return ME_BAD_PARAMS;
+       }
+       tools_cmdif cmdif;
+       memset(&cmdif, 0, sizeof(tools_cmdif));
+       cmdif.in_param = in_param;
+       cmdif.input_modifier = input_modifier;
+       cmdif.opcode = opcode;
+       cmdif.opcode_modifier = opcode_modifier;
+
+       //take semaphore
+       if (tools_cmdif_flash_lock(mf, 1)) {
+               return ME_SEM_LOCKED;
+       }
+       int rc = tools_cmdif_send_cmd_int(mf, &cmdif);
+       // release it
+       tools_cmdif_flash_lock(mf, 0);
+       *out_param = cmdif.out_param;
+       *status = cmdif.status;
+       return rc;
+}
+
+static int translate_status(int status) {
+       switch (status) {
+       case 0x0:
+               return ME_OK;
+       case 0x2:
+               return ME_CMDIF_BAD_OP;
+       case 0x4:
+               return ME_CMDIF_BAD_SYS;
+       default:
+               return ME_CR_ERROR;
+       }
+}
+
+static int tools_cmdif_mbox_read(mfile* mf, u_int32_t offset, u_int64_t* output)
+{
+       if (!mf || (offset & 0x1) != 0 || !output) {// offset should be quad word alligned (i.e only even dwords)
+               return ME_BAD_PARAMS;
+       }
+       tools_cmdif cmdif;
+       memset(&cmdif, 0, sizeof(tools_cmdif));
+       //printf("-D- offset: 0x%x\n", offset>>2);
+       cmdif.input_modifier = offset; // offset is in dwords
+       cmdif.opcode = MBOX_READ_OP;
+
+       int rc = tools_cmdif_send_cmd_int(mf, &cmdif);
+       *output = cmdif.out_param;
+       //printf("-D- outparam: 0x%lx\n", cmdif.out_param);
+       if (rc || cmdif.status) {
+               return ME_CR_ERROR;
+       }
+       //printf("-D- mbox read OK\n");
+       return ME_OK;
+}
+
+static int tools_cmdif_mbox_write(mfile* mf, u_int32_t offset, u_int64_t input)
+{
+       if (!mf || (offset & 0x1) != 0) {// offset should be quad word alligned (i.e only even dwords)
+               return ME_BAD_PARAMS;
+       }
+       tools_cmdif cmdif;
+       memset(&cmdif, 0, sizeof(tools_cmdif));
+       cmdif.in_param = input;
+       cmdif.input_modifier = offset; // offset is in dwords
+       cmdif.opcode = MBOX_WRITE_OP;
+
+       int rc = tools_cmdif_send_cmd_int(mf, &cmdif);
+
+       if (rc || cmdif.status) {
+               return ME_CR_ERROR;
+       }
+       return ME_OK;
+}
+
+int tools_cmdif_query_dev_cap(mfile *mf, u_int32_t offset, u_int64_t* data)
+{
+       if (!mf || offset > (TOOLS_HCR_MAX_MBOX - 8)) {
+               return ME_BAD_PARAMS;
+       }
+       // take semaphore
+       if (tools_cmdif_flash_lock(mf, 1)) {
+               return ME_SEM_LOCKED;
+       }
+       // run query_dev_cap cmd
+       tools_cmdif cmdif;
+       memset(&cmdif, 0, sizeof(tools_cmdif));
+       cmdif.opcode = QUERY_DEV_CAP_OP;
+
+       int rc = tools_cmdif_send_cmd_int(mf, &cmdif);
+
+       if (rc || cmdif.status) {
+               tools_cmdif_flash_lock(mf, 0);
+               if (rc == ME_CMDIF_BAD_STATUS) {
+                       return translate_status(cmdif.status);
+               }
+               return rc;
+       }
+       // read offset from Mbox
+
+       if (!data) { // if data is null we just check capability of the Tools HCR (i.e if its capable to execute query_dev_cap op)
+               tools_cmdif_flash_lock(mf, 0);
+               return ME_OK;
+       }
+       // offset needs to be in even dwords
+       if (((offset >> 2) & 0x1) != 0) {
+               return ME_BAD_PARAMS;
+       }
+       rc = tools_cmdif_mbox_read(mf, offset>>2, data);
+       // free semaphore
+       tools_cmdif_flash_lock(mf, 0);
+       return rc;
+}
+
+/*
+static void read_entire_mbox(mfile* mf)
+{
+       int i;
+       int rc;
+       u_int64_t val= 0;
+
+       printf("-D- reading entire mailbox\n");
+
+       for(i=0; i<256 ; i+=8) {
+               rc = tools_cmdif_mbox_read(mf, i/4, &val);
+               if (rc) {
+                       printf("-D- rc:%d\n", rc);
+               }
+               printf("-D- 0x%x\n", (u_int32_t)val);
+               printf("-D- 0x%x\n", (u_int32_t)(val>>32));
+       }
+}
+
+
+static void print_buffer(u_int8_t buffer[TOOLS_HCR_MAX_MBOX], const char* pre)
+{
+       int i;
+       u_int32_t *ptr = (u_int32_t*)buffer;
+       printf("-I- %s\n", pre);
+       for (i=0; i< 16; i++) {
+               printf("0x%x\n", ptr[i]);
+       }
+       return;
+}
+*/
+
+int tools_cmdif_reg_access(mfile *mf, void* data, int write_data_size, int read_data_size)
+{
+       //printf("-D- write data sz: %d, read data sz: %d \n", write_data_size, read_data_size);
+       if (!mf || !data || write_data_size > TOOLS_HCR_MAX_MBOX || read_data_size > TOOLS_HCR_MAX_MBOX) {
+               return ME_BAD_PARAMS;
+       }
+       //take semaphore
+       if (tools_cmdif_flash_lock(mf, 1)) {
+               return ME_SEM_LOCKED;
+       }
+       int rc;
+       // place the data inside 256 bytes buffer (init with zeroes) and write the entire buffer to mbox
+       // it is required in the TOOLS_HCR HLD to write the ENTIRE MBOX
+       u_int8_t buffer[TOOLS_HCR_MAX_MBOX] = {0};
+       memcpy(buffer, data, write_data_size);
+       // switch endianess as fw expects output in big endian
+       TOCPUn(buffer, TOOLS_HCR_MAX_MBOX/4);
+       int i;
+       //print_buffer(buffer, "before sending sending");
+       for (i=0 ; i< TOOLS_HCR_MAX_MBOX; i+=8) { // it is required to write in quad word chunks (64bits each time)
+               u_int64_t* ptr = (u_int64_t*)(&buffer[i]);
+               rc = tools_cmdif_mbox_write(mf, i/4, *ptr);
+               if (rc) {
+                       goto cleanup;
+               }
+       }
+       // send access reg cmd
+       tools_cmdif cmdif;
+       memset(&cmdif, 0, sizeof(tools_cmdif));
+       cmdif.opcode = REG_ACCESS_OP;
+       rc = tools_cmdif_send_cmd_int(mf, &cmdif);
+
+       if (rc || cmdif.status) {
+               if (rc == ME_CMDIF_BAD_STATUS) {
+                       rc = translate_status(cmdif.status); // means that driver is down or we dont support the extended version of tools hcr.
+               }
+               goto cleanup;
+       }
+       // read read_data_size bytes from mbox and update our data
+       for (i=0 ; i< read_data_size; i+=8) { // it is required to write in quad word chunks (64bits each time)
+               rc = tools_cmdif_mbox_read(mf, i/4, (u_int64_t*)&(buffer[i]));
+               if (rc) {
+                       goto cleanup;
+               }
+       }
+
+       //print_buffer(buffer, "after sending");
+       // switch endianness back
+       TOCPUn(buffer, TOOLS_HCR_MAX_MBOX/4);
+       // copy data back to user
+       memcpy(data, buffer, read_data_size);
+       rc = ME_OK;
+cleanup:
+       tools_cmdif_flash_lock(mf, 0);
+       //printf("-D- rc in cmdif: 0x%x\n", rc);
+       return rc;
+}
+
+/*
+int test_mbox(mfile* mf)
+{
+       u_int32_t data_w[8] = {1,2,3,4,5,6,7,8};
+       u_int32_t data_r[8] = {0};
+       //take semaphore
+       if (tools_cmdif_flash_lock(mf, 1)) {
+               return ME_SEM_LOCKED;
+       }
+       // write data to mbox
+       printf("-D- writing data to Mbox.\n");
+       int i;
+       for(i = 0 ; i < 8/2 ; i++) {
+               u_int64_t input = *(u_int64_t*)(&data_w[i*2]);
+               printf("-D- attempting to write 0x%lx\n", input);
+               int rc = tools_cmdif_mbox_write(mf, i*2,input);
+               if (rc){
+                       tools_cmdif_flash_lock(mf, 0);
+                       return ME_CR_ERROR;
+               }
+       }
+       // read data from mbox
+       printf("-D- reading data from Mbox.\n");
+       for (i = 0; i < 8/2 ; i++) {
+               if (tools_cmdif_mbox_read(mf, i*2,(u_int64_t*)&data_r[i*2])) {
+                       tools_cmdif_flash_lock(mf, 0);
+                       return ME_CR_ERROR;
+               }
+       }
+       // print what have been read
+       for (i=0 ; i<8 ; i++) {
+               printf("-D- 0x%x\n", data_r[i]);
+       }
+
+       tools_cmdif_flash_lock(mf, 0);
+       return ME_OK;
+
+}
+*/
diff --git a/mtcr_ul/mtcr_tools_cif.h b/mtcr_ul/mtcr_tools_cif.h
new file mode 100644 (file)
index 0000000..704d5e6
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef _MTCR_TOOLS_CIF     /* guard */
+#define _MTCR_TOOLS_CIF
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <compatibility.h>
+#ifdef MST_UL_ICMD
+#include <mtcr_int_defs.h>
+#endif
+#include <mtcr.h>
+
+#define FLASH_REG_ACCESS       0x9001
+
+#define TOOLS_HCR_MAX_MBOX 256
+
+// tools flash semaphore (62) will be taken at the begining of each command specified here
+// and released at the end of the command.
+
+
+/*
+ * send a command to the tools HCR
+ * limitations:
+ * command should not use mailbox (not supported atm)
+ */
+int tools_cmdif_send_cmd(mfile* mf,
+                                        u_int64_t in_param,
+                                        u_int64_t* out_param,
+                                        u_int32_t input_modifier,
+                                        u_int16_t opcode,
+                                        u_int8_t  opcode_modifier,
+                                        u_int8_t*  status);
+
+
+/*
+ * register access tools HCR
+ *
+ * data:                       the raw register data
+ * write_data_size:    amount of data to write to the mailbox (rest assumed to be zero)
+ * read_data_size:     amount of data to be read from the mailbox
+ *
+ * data will contain the updated register.
+ */
+
+int tools_cmdif_reg_access(mfile *mf, void* data,int write_data_size, int read_data_size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* _MTCR_TOOLS_CIF guard */
index 5c4f6f23b0d668ae1bf853ae6b1ee120779673a8..1c101d44ecb4a0e2d7399bb9064b2300acbc2bb4 100644 (file)
 #endif
 
 #include <mtcr.h>
+#include "tools_utils.h"
 #include "mtcr_int_defs.h"
 #include "mtcr_ib.h"
+#include "packets_layout.h"
+#include "mtcr_tools_cif.h"
+
+#ifdef MST_UL_ICMD
+#include "mtcr_icmd_cif.h"
+#endif
 
 #ifndef __be32_to_cpu
 #define __be32_to_cpu(x) ntohl(x)
@@ -181,15 +188,6 @@ mwrite_chunk_as_multi_mwrite4(mfile *mf, unsigned int offset, u_int32_t* data, i
     return length;
 }
 
-
-enum mtcr_access_method {
-    MTCR_ACCESS_ERROR  = 0x0,
-    MTCR_ACCESS_MEMORY = 0x1,
-    MTCR_ACCESS_CONFIG = 0x2,
-    MTCR_ACCESS_INBAND = 0x3
-};
-
-
 /*
 * Return values:
 * 0:  OK
@@ -691,8 +689,9 @@ enum mtcr_access_method mtcr_parse_name(const char* name, int *force,
         return MTCR_ACCESS_CONFIG;
     }
 
-    if (sscanf(name, "lid-%x", &tmp) == 1 ||
-        sscanf(name, "ibdr-%x", &tmp) == 1) {
+    if (sscanf(name, "lid-%x", &tmp) == 1  ||
+        sscanf(name, "ibdr-%x", &tmp) == 1 ||
+        strstr(name, "lid-") != 0 || strstr(name, "ibdr-") != 0) {
         *force = 1;
         return MTCR_ACCESS_INBAND;
     }
@@ -918,8 +917,6 @@ next:
     return dev_info_arr;
 }
 
-dev_info* mdevices_info(int mask, int* len);
-
 void mdevice_info_destroy(dev_info* dev_info, int len)
 {
     (void)len;
@@ -927,6 +924,12 @@ void mdevice_info_destroy(dev_info* dev_info, int len)
         free(dev_info);
 }
 
+void mdevices_info_destroy(dev_info* dev_info, int len)
+{
+    (void)len;
+    if (dev_info)
+        free(dev_info);
+}
 
 mfile *mopen(const char *name)
 {
@@ -943,6 +946,10 @@ mfile *mopen(const char *name)
     int err;
     int rc;
 
+    if (geteuid() != 0) {
+       errno = EACCES;
+       return NULL;
+    }
     mf = (mfile *)malloc(sizeof(mfile));
     if (!mf)
         return NULL;
@@ -1077,6 +1084,12 @@ mfile *mopend(const char *name, int type)
 int mclose(mfile *mf)
 {
     if (mf->mclose != NULL && mf->ctx != NULL) {
+               #ifdef MST_UL_ICMD
+        // close icmd if if needed
+        if (mf->icmd.icmd_opened) {
+               icmd_close(mf);
+        }
+               #endif
         mf->mclose(mf);
     }
     if (mf->dev_name) {
@@ -1086,6 +1099,14 @@ int mclose(mfile *mf)
     return 0;
 }
 
+mfile *mopen_fw_ctx(void* fw_cmd_context, void* fw_cmd_func)
+{
+       // not implemented
+    TOOLS_UNUSED(fw_cmd_context);
+    TOOLS_UNUSED(fw_cmd_func);
+       return NULL;
+}
+
 unsigned char mset_i2c_slave(mfile *mf, unsigned char new_i2c_slave)
 {
     (void)mf;
@@ -1106,6 +1127,19 @@ int mget_mdevs_flags(mfile *mf, u_int32_t *devs_flags)
     }
     return 0;
 }
+
+int mget_mdevs_type(mfile *mf, u_int32_t *mtype)
+{
+    if (mf == NULL || mtype == NULL) {
+        errno = EINVAL;
+        return 1;
+    }
+
+    *mtype = mf->access_type;
+    return 0;
+}
+
+
 #define IBDR_MAX_NAME_SIZE 128
 
 
@@ -1173,12 +1207,17 @@ int reopen_pci_as_inband(mfile* mf)
 int maccess_reg_mad(mfile *mf, u_int8_t *data)
 {
     int rc;
+
+    if (mf == NULL || data == NULL) {
+        return ME_BAD_PARAMS;
+    }
+
     if (mf->access_type != MTCR_ACCESS_INBAND) {
         // Close current device and re-open as inband
         rc = reopen_pci_as_inband(mf);
         if (rc) {
-            errno = ENODEV;
-            return -1;
+            errno = ENODEV; // for compatibility untill we change mtcr to use error code
+            return ME_REG_ACCESS_UNKNOWN_ERR;
         }
     }
 
@@ -1191,8 +1230,18 @@ int mos_reg_access(mfile *mf, int reg_access, void *reg_data, u_int32_t cmd_type
     (void)reg_data; /* compiler warning */
     (void)cmd_type; /* compiler warning */
     (void)reg_access; /* compiler warning */
-    fprintf(stderr, "Warning: libmtcr: maccess_reg_mad() is not implemented and has no effect.\n");
-    return -1;
+    fprintf(stderr, "Warning: libmtcr: mos_reg_access() is not implemented and has no effect.\n");
+    return ME_NOT_IMPLEMENTED;
+}
+
+int maccess_reg_cmdif(mfile *mf, reg_access_t reg_access, void *reg_data, u_int32_t cmd_type)
+{
+    (void)mf;
+    (void)reg_data; /* compiler warning */
+    (void)cmd_type; /* compiler warning */
+    (void)reg_access; /* compiler warning */
+    fprintf(stderr, "Warning: libmtcr: maccess_reg_cmdif() is not implemented and has no effect.\n");
+    return ME_NOT_IMPLEMENTED;
 }
 
 static void mtcr_fix_endianness(u_int32_t *buf, int len)
@@ -1218,3 +1267,406 @@ int mwrite_buffer(mfile *mf, unsigned int offset, u_int8_t* data, int byte_len)
     mtcr_fix_endianness((u_int32_t*)data, byte_len);
     return mwrite4_block(mf, offset, (u_int32_t*)data, byte_len);
 }
+
+/*
+ * Reg Access Section
+ */
+
+#ifndef MST_UL_ICMD
+int icmd_send_command(mfile *mf, int opcode, void* data, int data_size, int skip_write) {
+    (void)mf;
+    (void)opcode; /* compiler warning */
+    (void)data; /* compiler warning */
+    (void)data_size; /* compiler warning */
+    (void)skip_write; /* compiler warning */
+    fprintf(stderr, "Warning: libmtcr: icmd_send_command() is not implemented and has no effect.\n");
+    return ME_NOT_IMPLEMENTED;
+}
+
+static int icmd_send_command_int(mfile *mf, int opcode, void* data, int w_data_size, int r_data_size, int skip_write) {
+    (void)mf;
+    (void)opcode; /* compiler warning */
+    (void)data; /* compiler warning */
+    (void)w_data_size; /* compiler warning */
+    (void)r_data_size; /* compiler warning */
+    (void)skip_write; /* compiler warning */
+    fprintf(stderr, "Warning: libmtcr: icmd_send_command_int() is not implemented and has no effect.\n");
+    return ME_NOT_IMPLEMENTED;
+}
+
+int icmd_clear_semaphore(mfile *mf) {
+    (void)mf; /* compiler warning */
+    fprintf(stderr, "Warning: libmtcr: icmd_clear_semaphore() is not implemented and has no effect.\n");
+    return ME_NOT_IMPLEMENTED;
+}
+#endif
+
+#define TLV_OPERATION_SIZE 4
+#define OP_TLV_SIZE        16
+#define REG_TLV_HEADER_LEN 4
+
+enum {
+    MAD_CLASS_REG_ACCESS = 1,
+};
+enum {
+    TLV_END       = 0,
+    TLV_OPERATION = 1,
+    TLV_DR        = 2,
+    TLV_REG       = 3,
+    TLV_USER_DATA = 4,
+};
+
+#define INBAND_MAX_REG_SIZE 44
+#define ICMD_MAX_REG_SIZE 236
+
+static int supports_icmd(mfile* mf);
+static int supports_tools_cmdif_reg(mfile* mf);
+static int init_operation_tlv(struct OperationTlv *operation_tlv, u_int16_t reg_id, u_int8_t method);
+static int mreg_send_wrapper(mfile* mf, u_int8_t *data, int r_icmd_size, int w_icmd_size);
+static int mreg_send_raw(mfile *mf, u_int16_t reg_id, maccess_reg_method_t method, void *reg_data, u_int32_t  reg_size, u_int32_t r_size_reg, u_int32_t        w_size_reg, int *reg_status);
+int mget_max_reg_size(mfile *mf);
+
+// maccess_reg: Do a reg_access for the mf device.
+// - reg_data is both in and out
+// TODO: When the reg operation succeeds but the reg status is != 0,
+//       a specific
+
+int maccess_reg(mfile     *mf,
+                u_int16_t  reg_id,
+                maccess_reg_method_t reg_method,
+                void*      reg_data,
+                u_int32_t  reg_size,
+                u_int32_t      r_size_reg,
+                u_int32_t      w_size_reg,
+                int       *reg_status)
+{
+    int rc;
+    if (mf == NULL || reg_data == NULL || reg_status == NULL || reg_size <= 0) {
+        return ME_BAD_PARAMS;
+    }
+    // check register size
+    int max_size = mget_max_reg_size(mf);
+    if ( max_size != -1 && reg_size > (unsigned int)max_size) {
+       //reg too big
+       return ME_REG_ACCESS_SIZE_EXCCEEDS_LIMIT;
+    }
+#ifndef MST_UL
+    // TODO: add specific checks for each FW access method where needed
+    if (mf->flags & MDEVS_MLNX_OS){
+       rc = mos_reg_access_raw(mf, reg_id, reg_method, reg_data, reg_size, reg_status);
+    } else if ((mf->flags & (MDEVS_IB | MDEVS_FWCTX)) || (mf->flags != MDEVS_IB && (supports_icmd(mf) || supports_tools_cmdif_reg(mf)))) {
+       rc = mreg_send_raw(mf, reg_id, reg_method, reg_data, reg_size, r_size_reg, w_size_reg, reg_status);
+    }else {
+        return ME_REG_ACCESS_NOT_SUPPORTED;
+    }
+#else
+    if (mf->access_type == MTCR_ACCESS_INBAND || (supports_icmd(mf) || supports_tools_cmdif_reg(mf)) ) {
+               rc = mreg_send_raw(mf, reg_id, reg_method, reg_data, reg_size, r_size_reg, w_size_reg, reg_status);
+        }else {
+            return ME_REG_ACCESS_NOT_SUPPORTED;
+        }
+#endif
+
+    if (rc ) {
+         return rc;
+    } else if (*reg_status) {
+        switch (*reg_status) {
+        case 1:
+            return ME_REG_ACCESS_DEV_BUSY;
+        case 2:
+            return ME_REG_ACCESS_VER_NOT_SUPP;
+        case 3:
+            return ME_REG_ACCESS_UNKNOWN_TLV;
+        case 4:
+            return ME_REG_ACCESS_REG_NOT_SUPP;
+        case 5:
+            return ME_REG_ACCESS_CLASS_NOT_SUPP;
+        case 6:
+            return ME_REG_ACCESS_METHOD_NOT_SUPP;
+        case 7:
+            return ME_REG_ACCESS_BAD_PARAM;
+        case 8:
+            return ME_REG_ACCESS_RES_NOT_AVLBL;
+        case 9:
+            return ME_REG_ACCESS_MSG_RECPT_ACK;
+        case 0x22:
+               return ME_REG_ACCESS_CONF_CORRUPT;
+        case 0x24:
+               return ME_REG_ACCESS_LEN_TOO_SMALL;
+        case 0x20:
+               return ME_REG_ACCESS_BAD_CONFIG;
+        case 0x21:
+               return ME_REG_ACCESS_ERASE_EXEEDED;
+        default:
+            return ME_REG_ACCESS_UNKNOWN_ERR;
+        }
+    }
+
+    return ME_OK;
+}
+
+
+static int init_operation_tlv(struct OperationTlv *operation_tlv, u_int16_t reg_id, u_int8_t method)
+{
+    memset(operation_tlv, 0, sizeof(*operation_tlv));
+
+    operation_tlv->Type        = TLV_OPERATION;
+    operation_tlv->class       = MAD_CLASS_REG_ACCESS;
+    operation_tlv->len         = TLV_OPERATION_SIZE;
+    operation_tlv->method      = method;
+    operation_tlv->register_id = reg_id;
+    return 0;
+}
+
+///////////////////  Function that sends the register via the correct interface ///////////////////////////
+
+static int mreg_send_wrapper(mfile* mf, u_int8_t *data, int r_icmd_size, int w_icmd_size)
+{
+    int rc;
+    if (mf->access_type == MTCR_ACCESS_INBAND) {//inband access
+            rc = maccess_reg_mad(mf, data);
+            if (rc) {
+                //printf("-E- 2. Access reg mad failed with rc = %#x\n", rc);
+                return ME_MAD_SEND_FAILED;
+            }
+    } else if (supports_icmd(mf)) {
+       //printf("-D- w size: %d , r size: %d\n",w_icmd_size,r_icmd_size);
+        rc = icmd_send_command_int(mf, FLASH_REG_ACCESS, data, w_icmd_size, r_icmd_size, 0);
+        if (rc) {
+               return rc;
+        }
+    } else if (supports_tools_cmdif_reg(mf)) {
+       rc = tools_cmdif_reg_access(mf, data, w_icmd_size, r_icmd_size);
+       if (rc) {
+               return rc;
+       }
+    }else{
+        return ME_NOT_IMPLEMENTED;
+    }
+    return ME_OK;
+}
+
+
+static int mreg_send_raw(mfile *mf, u_int16_t reg_id, maccess_reg_method_t method, void *reg_data, u_int32_t  reg_size,\
+                                                       u_int32_t r_size_reg, u_int32_t w_size_reg, int *reg_status)
+{
+       //printf("-D- reg_id = %d, reg_size = %d, r_size_reg = %d , w_size_reg = %d \n",reg_id,reg_size,r_size_reg,w_size_reg);
+    int mad_rc, cmdif_size = 0;
+    struct OperationTlv tlv;
+    struct reg_tlv tlv_info;
+    u_int8_t buffer[1024];
+
+    init_operation_tlv(&(tlv), reg_id, method);
+    // Fill Reg TLV
+    memset(&tlv_info, 0, sizeof(tlv_info));
+    tlv_info.Type = TLV_REG;
+    tlv_info.len  = (reg_size + REG_TLV_HEADER_LEN) >> 2; // length is in dwords
+
+    // Pack the mad
+
+    cmdif_size += OperationTlv_pack(&tlv, buffer);
+    cmdif_size += reg_tlv_pack(&tlv_info, buffer + OP_TLV_SIZE);
+    //put the reg itself into the buffer
+    memcpy(buffer + OP_TLV_SIZE + REG_TLV_HEADER_LEN, reg_data, reg_size);
+    cmdif_size += reg_size;
+
+#ifdef _ENABLE_DEBUG_
+       fprintf(stdout, "-I-Tlv's of Data Sent:\n");
+        fprintf(stdout, "\tOperation Tlv\n");
+        OperationTlv_dump(&tlv, stdout);
+       fprintf(stdout, "\tReg Tlv\n");
+        reg_tlv_dump(&tlv_info, stdout);
+#endif
+    // printf("-D- reg_info.len = |%d, OP_TLV: %d, REG_TLV= %d, cmdif_size = %d\n", reg_info.len, OP_TLV_SIZE, REG_RLV_HEADER_LEN, cmdif_size);
+    // update r/w_size_reg with the size of op tlv and reg tlv as we need to read/write them as well
+    r_size_reg += OP_TLV_SIZE + REG_TLV_HEADER_LEN;
+    w_size_reg += OP_TLV_SIZE + REG_TLV_HEADER_LEN;
+       //printf("-D- reg_size = %d, r_size_reg = %d , w_size_reg = %d \n",reg_size,r_size_reg,w_size_reg);
+
+    mad_rc = mreg_send_wrapper(mf, buffer, r_size_reg, w_size_reg);
+    // Unpack the mad
+    OperationTlv_unpack(&tlv, buffer);
+    reg_tlv_unpack(&tlv_info, buffer + OP_TLV_SIZE);
+    // copy register back from the buffer
+    memcpy(reg_data, buffer + OP_TLV_SIZE + REG_TLV_HEADER_LEN, reg_size);
+
+#ifdef _ENABLE_DEBUG_
+       fprintf(stdout, "-I-Tlv's of Data Recieved:\n");
+       fprintf(stdout, "\tOperation Tlv\n");
+        OperationTlv_dump(&tlv, stdout);
+       fprintf(stdout, "\tReg Tlv\n");
+        reg_tlv_dump(&tlv_info, stdout);
+#endif
+    // Check the return value
+    *reg_status = tlv.status;
+    if (mad_rc) {
+       return mad_rc;
+    }
+    return ME_OK;
+}
+
+
+#define GOLAN_HW_ID 511
+#define SHOMRON_HW_ID 521
+#define PELICAN_HW_ID 583
+#define CX3_PRO_HW_ID 0x1F7
+#define CX3_HW_ID_REV 0x1f5
+
+#define HW_ID_ADDR 0xf0014
+
+static int supports_icmd(mfile* mf) {
+#ifndef MST_UL_ICMD
+       (void)mf; // avoid warnings
+       return 0;
+#endif
+       u_int32_t dev_id;
+       mread4(mf,HW_ID_ADDR, &dev_id); // cr might be locked and retured 0xbad0cafe but we dont care we search for device that supports icmd
+       switch (dev_id & 0xffff) { // that the hw device id
+               case GOLAN_HW_ID : //golan
+               case SHOMRON_HW_ID : // shomron
+               case PELICAN_HW_ID : // pelican
+                       return 1;
+               default:
+                       break;
+       }
+   return 0;
+}
+
+static int supports_tools_cmdif_reg(mfile* mf) {
+       u_int32_t dev_id;
+       mread4(mf,HW_ID_ADDR, &dev_id); // cr might be locked and retured 0xbad0cafe but we dont care we search for device that supports tools cmdif
+       switch (dev_id & 0xffff) { // that the hw device id
+               case CX3_HW_ID_REV : //Cx3
+               case CX3_PRO_HW_ID : // Cx3-pro
+                       if (tools_cmdif_query_dev_cap(mf, 0, NULL) == ME_OK) {
+                               return 1;
+                       }
+                       break;
+               default:
+                       break;
+                }
+   return 0;
+}
+
+
+int mget_max_reg_size(mfile *mf) {
+       if (mf->access_type == MTCR_ACCESS_INBAND) {
+               return INBAND_MAX_REG_SIZE;
+       }
+       if (supports_icmd(mf)){ // we support icmd and we dont use IB interface -> we use icmd for reg access
+               return ICMD_MAX_REG_SIZE;
+       }
+       if (supports_tools_cmdif_reg(mf)) {
+               return TOOLS_HCR_MAX_MBOX;
+       }
+       return 0;
+}
+
+/************************************
+ * Function: m_err2str
+ ************************************/
+const char* m_err2str(MError status)
+{
+   switch(status) {
+   case ME_OK:
+       return "ME_OK";
+   case ME_ERROR:
+       return "General error";
+   case ME_BAD_PARAMS:
+       return "ME_BAD_PARAMS";
+   case ME_CR_ERROR:
+       return "ME_CR_ERROR";
+   case ME_NOT_IMPLEMENTED:
+       return "ME_NOT_IMPLEMENTED";
+   case ME_SEM_LOCKED:
+       return "Semaphore locked";
+   case ME_MEM_ERROR:
+       return "ME_MEM_ERROR";
+
+   case ME_MAD_SEND_FAILED:
+       return "ME_MAD_SEND_FAILED";
+   case ME_UNKOWN_ACCESS_TYPE:
+       return "ME_UNKOWN_ACCESS_TYPE";
+   case ME_UNSUPPORTED_DEVICE:
+       return "ME_UNSUPPORTED_DEVICE";
+
+   // Reg access errors
+   case ME_REG_ACCESS_BAD_STATUS_ERR:
+       return "ME_REG_ACCESS_BAD_STATUS_ERR";
+   case ME_REG_ACCESS_BAD_METHOD:
+       return "Bad method";
+   case ME_REG_ACCESS_NOT_SUPPORTED:
+       return "Register access isn't supported by device";
+   case ME_REG_ACCESS_DEV_BUSY:
+       return "Device is busy";
+   case ME_REG_ACCESS_VER_NOT_SUPP:
+       return "Version not supported";
+   case ME_REG_ACCESS_UNKNOWN_TLV:
+       return "Unknown TLV";
+   case ME_REG_ACCESS_REG_NOT_SUPP:
+       return "Register not supported";
+   case ME_REG_ACCESS_CLASS_NOT_SUPP:
+       return "Class not supported";
+   case ME_REG_ACCESS_METHOD_NOT_SUPP:
+       return "Method not supported";
+   case ME_REG_ACCESS_BAD_PARAM:
+       return "Bad parameter";
+   case ME_REG_ACCESS_RES_NOT_AVLBL:
+       return "Resource not available";
+   case ME_REG_ACCESS_MSG_RECPT_ACK:
+       return "Message receipt ack";
+   case ME_REG_ACCESS_UNKNOWN_ERR:
+       return "Unknown register error";
+   case ME_REG_ACCESS_SIZE_EXCCEEDS_LIMIT:
+       return "Register is too large";
+   case ME_REG_ACCESS_CONF_CORRUPT:
+          return "Config Section Corrupted";
+   case ME_REG_ACCESS_LEN_TOO_SMALL:
+          return "given register length too small for Tlv";
+   case ME_REG_ACCESS_BAD_CONFIG:
+          return "configuration refused";
+   case ME_REG_ACCESS_ERASE_EXEEDED:
+          return       "erase count exceeds limit";
+
+   // ICMD access errors
+   case ME_ICMD_STATUS_CR_FAIL:
+       return "ME_ICMD_STATUS_CR_FAIL";
+   case ME_ICMD_STATUS_SEMAPHORE_TO:
+       return "ME_ICMD_STATUS_SEMAPHORE_TO";
+   case ME_ICMD_STATUS_EXECUTE_TO:
+       return "ME_ICMD_STATUS_EXECUTE_TO";
+   case ME_ICMD_STATUS_IFC_BUSY:
+       return "ME_ICMD_STATUS_IFC_BUSY";
+   case ME_ICMD_STATUS_ICMD_NOT_READY:
+       return "ME_ICMD_STATUS_ICMD_NOT_READY";
+   case ME_ICMD_UNSUPPORTED_ICMD_VERSION:
+       return "ME_ICMD_UNSUPPORTED_ICMD_VERSION";
+   case ME_ICMD_NOT_SUPPORTED:
+       return "ME_REG_ACCESS_ICMD_NOT_SUPPORTED";
+   case ME_ICMD_INVALID_OPCODE:
+       return "ME_ICMD_INVALID_OPCODE";
+   case ME_ICMD_INVALID_CMD:
+       return "ME_ICMD_INVALID_CMD";
+   case ME_ICMD_OPERATIONAL_ERROR:
+       return "ME_ICMD_OPERATIONAL_ERROR";
+   case ME_ICMD_BAD_PARAM:
+       return "ME_ICMD_BAD_PARAM";
+   case ME_ICMD_BUSY:
+       return "ME_ICMD_BUSY";
+
+       // TOOLS HCR access errors
+   case ME_CMDIF_BUSY:
+          return "Tools HCR busy.";
+   case ME_CMDIF_TOUT:
+          return "Tools HCR time out.";
+   case ME_CMDIF_BAD_OP:
+          return "Operation not supported";
+   case ME_CMDIF_NOT_SUPP:
+          return "Tools HCR not supported.";
+   case ME_CMDIF_BAD_SYS:
+          return "bad system status (driver may be down or Fw does not support this operation).";
+   default:
+       return "Unknown error code";
+   }
+}
+
diff --git a/mtcr_ul/packets_common.c b/mtcr_ul/packets_common.c
new file mode 100644 (file)
index 0000000..14c3d31
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include "packets_common.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#ifdef __WIN__
+    #include <Winsock2.h>   // for htonl
+#endif
+
+
+/************************************/
+void push_to_buff_64(u_int8_t *buff, u_int32_t bit_offset, u_int64_t field_value)
+{
+#if defined(__ia64__)
+    u_int32_t *buffer = PTR_32_OF_BUFF(buff, (bit_offset / 8));
+    u_int64_t value = CPU_TO_BE64(field_value);
+    memcpy(buffer, &value, sizeof(value));
+#else
+    u_int64_t *buffer = PTR_64_OF_BUFF(buff, (bit_offset / 8));
+    memcpy(buffer, &field_value, sizeof(field_value));
+    *buffer = CPU_TO_BE64(*buffer);
+#endif
+}
+
+
+/************************************/
+void push_to_buff_32(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_value)
+{
+    u_int32_t *buffer = PTR_32_OF_BUFF(buff, (bit_offset / 8));
+    memcpy(buffer, &field_value, sizeof(field_value));
+    *buffer = CPU_TO_BE32(*buffer);
+}
+
+
+/************************************/
+//the next function will push the field into the buffer by inserting it's MSB bits first
+//and therefore by doing it we save the CPU_TO_BE operation
+void push_to_buff(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_size, u_int32_t field_value)
+{
+    u_int32_t i                = 0;
+    u_int32_t byte_n   = bit_offset / 8;
+    u_int32_t byte_n_offset    = bit_offset % 8;
+    u_int32_t to_push;
+
+    //going over all bits in field
+    while (i < field_size) {
+        to_push = PCK_MIN(8 - byte_n_offset, field_size - i);
+        i += to_push;
+        //printf("Inserting %u bits(%u) to byte %u to bit %u\n", to_push, EXTRACT8(field_value, field_size - i, to_push), byte_n, 8 - to_push - byte_n_offset);
+        INSERTF_8(BYTE_N(buff, byte_n), 8 - to_push - byte_n_offset, field_value, field_size - i, to_push);
+        byte_n_offset  = 0;    //(byte_n_offset + to_push) % 8;
+        byte_n++;
+    }
+}
+
+
+/************************************/
+u_int64_t pop_from_buff_64(u_int8_t *buff, u_int32_t bit_offset)
+{
+#if defined(__ia64__)
+    u_int64_t value = 0;
+    memcpy(&value, PTR_32_OF_BUFF(buff, (bit_offset / 8)), sizeof(u_int64_t));
+    return (BE64_TO_CPU(value));
+#else
+    return (BE64_TO_CPU(FIELD_64_OF_BUFF(buff, (bit_offset / 8))));
+#endif
+}
+
+
+/************************************/
+u_int32_t pop_from_buff_32(u_int8_t *buff, u_int32_t bit_offset)
+{
+    return (BE32_TO_CPU(FIELD_32_OF_BUFF(buff, (bit_offset / 8))));
+}
+
+
+/************************************/
+//the next function will pop the field into the buffer by removing it's MSB bits first
+//and therefore by doing it we save the BE_TO_CPU operation
+u_int32_t pop_from_buff(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_size)
+{
+    u_int32_t i                = 0;
+    u_int32_t byte_n   = bit_offset / 8;
+    u_int32_t byte_n_offset    = bit_offset % 8;
+    u_int32_t field_32 = 0;
+    u_int32_t to_pop;
+
+    //going over all bits in field
+    while (i < field_size) {
+        to_pop =  PCK_MIN(8 - byte_n_offset, field_size - i);
+        i += to_pop;
+        //printf("Removing %u bits(%u) from byte %u to bit %u\n", to_pop, EXTRACT8(BYTE_N(buff, byte_n), 8 - to_pop - byte_n_offset, to_pop), byte_n, field_size - i);
+        INSERTF_8(field_32, field_size - i, BYTE_N(buff, byte_n), 8 - to_pop - byte_n_offset, to_pop);
+        byte_n_offset  = 0;    //(byte_n_offset + to_pop) % 8;
+        byte_n++;
+    }
+    return field_32;
+}
+
+
diff --git a/mtcr_ul/packets_common.h b/mtcr_ul/packets_common.h
new file mode 100644 (file)
index 0000000..e67bd06
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ * 
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef packet_common_H
+#define packet_common_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include "compatibility.h"
+
+#ifndef __WIN__
+    #include <netinet/in.h>
+/************************************/
+/* Endianess Defines */
+/*
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+    #ifndef PLATFORM_MEM
+         // #define PLATFORM_MEM "Little Endianess"
+    #endif
+    #define _LITTLE_ENDIANESS
+#endif
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+    //#define PLATFORM_MEM "Big Endianess"
+    #define _BIG_ENDIANESS
+#endif
+
+#else
+    #define __BYTE_ORDER __LITTLE_ENDIAN
+    #ifndef PLATFORM_MEM
+        //#define PLATFORM_MEM "Big Endianess"
+    #endif
+    #define _BIG_ENDIANESS
+    typedef unsigned __int8  u_int8_t;
+    typedef __int8           int8_t;
+    typedef unsigned __int16 u_int16_t;
+    typedef __int16          int16_t;
+    typedef unsigned __int32 u_int32_t;
+    typedef __int32          int32_t;
+    typedef unsigned __int64 u_int64_t;
+    typedef __int64          int64_t;
+    */
+#endif
+
+
+
+/************************************/
+/* Bit manipulation macros */
+
+/* MASK generate a bit mask S bits width */
+//#define MASK32(S)     ( ((u_int32_t) ~0L) >> (32-(S)) )
+#define MASK8(S)        ( ((u_int8_t) ~0) >> (8-(S)) )
+
+/* BITS generate a bit mask with bits O+S..O set (assumes 32 / 8 bit integer) */
+//#define BITS32(O,S)   ( MASK32(S) << (O) )
+#define BITS8(O,S)      ( MASK8(S) << (O) )
+
+/* EXTRACT32/8 macro extracts S bits from (u_int32_t/u_int8_t)W with offset O
+ * and shifts them O places to the right (right justifies the field extracted) */
+//#define EXTRACT32(W,O,S)  ( ((W)>>(O)) & MASK32(S) )
+#define EXTRACT8(W,O,S)     ( ((W)>>(O)) & MASK8(S) )
+
+#define PCK_MIN(a, b)   ((a) < (b) ? (a) : (b))
+/* INSERT32/8 macro inserts S bits with offset O from field F into word W (u_int32_t/u_int8_t) */
+//#define INSERT32(W,F,O,S)     ((W)= ( ( (W) & (~BITS32(O,S)) ) | (((F) & MASK32(S))<<(O)) ))
+#define INSERT8(W,F,O,S)        ((W)= ( ( (W) & (~BITS8(O,S)) ) | (((F) & MASK8(S))<<(O)) ))
+
+//#define INSERTF_32(W,O1,F,O2,S)   (INSERT32(W, EXTRACT32(F, O2, S), O1, S) )
+#define INSERTF_8(W,O1,F,O2,S)      (INSERT8(W, EXTRACT8(F, O2, S), O1, S) )
+
+
+/************************************/
+#define PTR_64_OF_BUFF(buf, offset)     ((u_int64_t*)((u_int8_t*)(buf) + (offset)))
+#define PTR_32_OF_BUFF(buf, offset)     ((u_int32_t*)((u_int8_t*)(buf) + (offset)))
+#define PTR_8_OF_BUFF(buf, offset)      ((u_int8_t*)((u_int8_t*)(buf) + (offset)))
+#define FIELD_64_OF_BUFF(buf, offset)   (*PTR_64_OF_BUFF(buf, offset))
+#define FIELD_32_OF_BUFF(buf, offset)   (*PTR_32_OF_BUFF(buf, offset))
+#define FIELD_8_OF_BUFF(buf, offset)    (*PTR_8_OF_BUFF(buf, offset))
+#define DWORD_N(buf, n)                 FIELD_32_OF_BUFF((buf), (n) * 4)
+#define BYTE_N(buf, n)                  FIELD_8_OF_BUFF((buf), (n))
+
+
+/************************************/
+// #define MIN(a, b)   ((a) < (b) ? (a) : (b))
+
+
+/************************************/
+#define CPU_TO_BE32(x)  htonl(x)
+#define BE32_TO_CPU(x)  ntohl(x)
+#define CPU_TO_BE16(x)  htons(x)
+#define BE16_TO_CPU(x)  ntohs(x)
+#ifdef _LITTLE_ENDIANESS
+    #define CPU_TO_BE64(x) (((u_int64_t)htonl((u_int32_t)((x) & 0xffffffff)) << 32) | \
+                            ((u_int64_t)htonl((u_int32_t)((x >> 32) & 0xffffffff))))
+
+    #define BE64_TO_CPU(x) (((u_int64_t)ntohl((u_int32_t)((x) & 0xffffffff)) << 32) | \
+                            ((u_int64_t)ntohl((u_int32_t)((x >> 32) & 0xffffffff))))
+#else
+    #define CPU_TO_BE64(x) (x)
+    #define BE64_TO_CPU(x) (x)
+#endif
+
+
+/************************************/
+/* define macros to the architecture of the CPU */
+#if defined(__linux) || defined(__FreeBSD__)
+#   if defined(__i386__)
+#       define ARCH_x86
+#   elif defined(__x86_64__)
+#       define ARCH_x86_64
+#   elif defined(__ia64__)
+#       define ARCH_ia64
+#   elif defined(__PPC64__)
+#       define ARCH_ppc64
+#   elif defined(__PPC__)
+#       define ARCH_ppc
+#   elif defined(__aarch64__)
+#       define ARCH_arm64
+#   else
+#       error Unknown CPU architecture using the linux OS
+#   endif
+#elif defined(_WIN32)
+
+//#   error Windows OS need to define macros
+#else       /* __linux || __FreeBSD__ */
+#   error Unknown OS
+#endif      /* __linux || __FreeBSD__ */
+
+
+/**********************************/
+/* define macros for print fields */
+//#if defined (ARCH_ia64) || defined(ARCH_x86_64) || defined(ARCH_ppc64) || defined(__MINGW64__)
+/*
+#if !defined(UEFI_BUILD) && (defined (ARCH_ia64) || defined(ARCH_x86_64) || defined(ARCH_ppc64) || defined(__MINGW64__))
+#   define U64H_FMT "0x%016lx"
+#   define U64D_FMT "%lu"
+#   define U32H_FMT "0x%08x"
+#   define U16H_FMT "0x%04x"
+#   define U8H_FMT  "0x%02x"
+#   define U32D_FMT "%u"
+#   define STR_FMT "%s"
+#elif defined(ARCH_x86) || defined(ARCH_ppc) || defined(__MINGW32__) || defined(UEFI_BUILD)
+#   define U64H_FMT "0x%016llx"
+#   define U64D_FMT "%llu"
+#   define U32H_FMT "0x%08x"
+#   define U16H_FMT "0x%04x"
+#   define U8H_FMT  "0x%02x"
+#   define U32D_FMT "%u"
+#   define STR_FMT "%s"
+#else  // ARCH
+#   error Unknown architecture
+#endif // ARCH
+*/
+
+/**********************************/
+void push_to_buff_64(u_int8_t *buff, u_int32_t bit_offset, u_int64_t field_value);
+void push_to_buff_32(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_value);
+void push_to_buff(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_size, u_int32_t field_value);
+u_int64_t pop_from_buff_64(u_int8_t *buff, u_int32_t bit_offset);
+u_int32_t pop_from_buff_32(u_int8_t *buff, u_int32_t bit_offset);
+u_int32_t pop_from_buff(u_int8_t *buff, u_int32_t bit_offset, u_int32_t field_size);
+
+#endif          /* def packet_common_H */
+
+
diff --git a/mtcr_ul/packets_layout.c b/mtcr_ul/packets_layout.c
new file mode 100644 (file)
index 0000000..6520aa8
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+/***
+ *** This file was generated at "Mon May 30 15:06:41 2011"
+ *** by:
+ ***    % csp_pack_unpack.pm ../xml_files/packets_st.csp
+ ***    and modified to fit the needs of mtcr
+ ***/
+
+#include <stdlib.h>
+#include "packets_layout.h"
+#include "packets_common.h"
+
+/*************************************/
+/* Name: OperationTlv
+ * Size: 128 bits
+ * Description:  */
+
+
+u_int32_t OperationTlv_pack(struct OperationTlv *data_to_pack, u_int8_t *packed_buffer) {
+    push_to_buff(packed_buffer, 24, 8, data_to_pack->reserved0);
+    push_to_buff(packed_buffer, 17, 7, data_to_pack->status);
+    push_to_buff(packed_buffer, 16, 1, data_to_pack->dr);
+    push_to_buff(packed_buffer, 5, 11, data_to_pack->len);
+    push_to_buff(packed_buffer, 0, 5, data_to_pack->Type);
+    push_to_buff(packed_buffer, 56, 8, data_to_pack->class);
+    push_to_buff(packed_buffer, 49, 7, data_to_pack->method);
+    push_to_buff(packed_buffer, 48, 1, data_to_pack->r);
+    push_to_buff(packed_buffer, 32, 16, data_to_pack->register_id);
+    push_to_buff_64(packed_buffer, 64, data_to_pack->tid);
+    return 16;
+}
+
+void OperationTlv_unpack(struct OperationTlv *unpacked_data, u_int8_t *buffer_to_unpack) {
+    unpacked_data->reserved0 = pop_from_buff(buffer_to_unpack, 24, 8);
+    unpacked_data->status = pop_from_buff(buffer_to_unpack, 17, 7);
+    unpacked_data->dr = pop_from_buff(buffer_to_unpack, 16, 1);
+    unpacked_data->len = pop_from_buff(buffer_to_unpack, 5, 11);
+    unpacked_data->Type = pop_from_buff(buffer_to_unpack, 0, 5);
+    unpacked_data->class = pop_from_buff(buffer_to_unpack, 56, 8);
+    unpacked_data->method = pop_from_buff(buffer_to_unpack, 49, 7);
+    unpacked_data->r = pop_from_buff(buffer_to_unpack, 48, 1);
+    unpacked_data->register_id = pop_from_buff(buffer_to_unpack, 32, 16);
+    unpacked_data->tid = pop_from_buff_64(buffer_to_unpack, 64);
+}
+
+void OperationTlv_dump(struct OperationTlv *data_to_print, FILE *out_port) {
+    fprintf(out_port, "OperationTlv::reserved0: "U32D_FMT"\n", data_to_print->reserved0);
+    fprintf(out_port, "OperationTlv::status: "U32D_FMT"\n", data_to_print->status);
+    fprintf(out_port, "OperationTlv::dr: "U32D_FMT"\n", data_to_print->dr);
+    fprintf(out_port, "OperationTlv::len: "U32D_FMT"\n", data_to_print->len);
+    fprintf(out_port, "OperationTlv::Type: "U32D_FMT"\n", data_to_print->Type);
+    fprintf(out_port, "OperationTlv::class: "U32D_FMT"\n", data_to_print->class);
+    fprintf(out_port, "OperationTlv::method: "U32D_FMT"\n", data_to_print->method);
+    fprintf(out_port, "OperationTlv::r: "U32D_FMT"\n", data_to_print->r);
+    fprintf(out_port, "OperationTlv::register_id: "U32D_FMT"\n", data_to_print->register_id);
+    fprintf(out_port, "OperationTlv::tid: "U64D_FMT"\n", data_to_print->tid);
+}
+
+/*************************************/
+/* Name: reg_tlv
+ * Size: 32 bits
+ * Description: reg_tlv */
+
+
+u_int32_t reg_tlv_pack(struct reg_tlv *data_to_pack, u_int8_t *packed_buffer) {
+    push_to_buff(packed_buffer, 16, 16, data_to_pack->reserved0);
+    push_to_buff(packed_buffer, 5, 11, data_to_pack->len);
+    push_to_buff(packed_buffer, 0, 5, data_to_pack->Type);
+    return 4;
+}
+
+void reg_tlv_unpack(struct reg_tlv *unpacked_data, u_int8_t *buffer_to_unpack) {
+    unpacked_data->reserved0 = pop_from_buff(buffer_to_unpack, 16, 16);
+    unpacked_data->len = pop_from_buff(buffer_to_unpack, 5, 11);
+    unpacked_data->Type = pop_from_buff(buffer_to_unpack, 0, 5);
+}
+
+void reg_tlv_dump(struct reg_tlv *data_to_print, FILE *out_port) {
+    fprintf(out_port, "reg_tlv::reserved0: "U32D_FMT"\n", data_to_print->reserved0);
+    fprintf(out_port, "reg_tlv::len: "U32D_FMT"\n", data_to_print->len);
+    fprintf(out_port, "reg_tlv::Type: "U32D_FMT"\n", data_to_print->Type);
+}
diff --git a/mtcr_ul/packets_layout.h b/mtcr_ul/packets_layout.h
new file mode 100644 (file)
index 0000000..a6528ad
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+/***
+ *** This file was generated at "Mon May 30 15:06:41 2011"
+ *** by:
+ ***    % csp_pack_unpack.pm ../xml_files/packets_st.csp
+ ***    and modified to fit mtcr needs
+ ***/
+
+#ifndef PACKETS_LAYOUT_H
+#define PACKETS_LAYOUT_H
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "compatibility.h"
+
+/*************************************/
+/* Name: reg_tlv
+ * Size: 32 bits
+ * Description: reg_tlv */
+
+struct reg_tlv {
+    u_int16_t   reserved0;    /* bit_offset:0 */    /* element_size: 16 */
+    u_int16_t   len;    /* bit_offset:16 */    /* element_size: 11 */
+    u_int8_t    Type;    /* bit_offset:27 */    /* element_size: 5 */    /* TX - 0, RX - ignore */
+};
+
+/*************************************/
+/* Name: OperationTlv
+ * Size: 128 bits
+ * Description:  */
+
+struct OperationTlv {
+    u_int8_t   reserved0;    /* bit_offset:0 */    /* element_size: 8 */
+    u_int8_t   status;    /* bit_offset:8 */    /* element_size: 7 */
+    u_int8_t   dr;    /* bit_offset:15 */    /* element_size: 1 */
+    u_int16_t  len;    /* bit_offset:16 */    /* element_size: 11 */
+    u_int8_t   Type;    /* bit_offset:27 */    /* element_size: 5 */    /* TX - 0, RX - ignore */
+    u_int8_t   class;    /* bit_offset:32 */    /* element_size: 8 */
+    u_int8_t   method;    /* bit_offset:40 */    /* element_size: 7 */
+    u_int8_t   r;    /* bit_offset:47 */    /* element_size: 1 */
+    u_int16_t  register_id;    /* bit_offset:48 */    /* element_size: 16 */
+    u_int64_t  tid;    /* bit_offset:64 */    /* element_size: 64 */
+};
+
+/*************************************/
+/* Name: reg_tlv
+ * Size: 32 bits
+ * Description: reg_tlv */
+
+u_int32_t reg_tlv_pack(struct reg_tlv *data_to_pack, u_int8_t *packed_buffer);
+void reg_tlv_unpack(struct reg_tlv *unpacked_data, u_int8_t *buffer_to_unpack);
+void reg_tlv_dump(struct reg_tlv *data_to_print, FILE *out_port);
+
+
+
+/*************************************/
+/* Name: OperationTlv
+ * Size: 128 bits
+ * Description:  */
+
+u_int32_t OperationTlv_pack(struct OperationTlv *data_to_pack, u_int8_t *packed_buffer);
+void OperationTlv_unpack(struct OperationTlv *unpacked_data, u_int8_t *buffer_to_unpack);
+void OperationTlv_dump(struct OperationTlv *data_to_print, FILE *out_port);
+
+
+#endif /* internal_packets_functions_H */
diff --git a/reg_access/Makefile.am b/reg_access/Makefile.am
new file mode 100644 (file)
index 0000000..ebc798b
--- /dev/null
@@ -0,0 +1,33 @@
+#--
+#                 - Mellanox Confidential and Proprietary -
+# 
+# Copyright (C) Jan 2013, Mellanox Technologies Ltd.  ALL RIGHTS RESERVED.
+# 
+# Except as specifically permitted herein, no portion of the information,
+# including but not limited to object code and source code, may be reproduced,
+# modified, distributed, republished or otherwise exploited in any form or by
+# any means for any purpose without the prior written permission of Mellanox
+# Technologies Ltd. Use of software subject to the terms and conditions
+# detailed in the file "LICENSE.txt".
+#--
+
+# Makefile.am -- Process this file with automake to produce Makefile.in
+MTCR_DIR = $(top_srcdir)/mtcr_ul
+COMMON_DIR = $(top_srcdir)/common
+LAYOUTS_DIR = $(top_srcdir)/tools_layouts
+USER_DIR = $(top_srcdir)
+
+INCLUDES = -I. -I$(USER_DIR) -I$(srcdir) -I$(LAYOUTS_DIR) -I$(USER_DIR)/include/mtcr_ul
+
+AM_CFLAGS = -W -Wall -Werror -g -MP -MD $(COMPILER_FPIC)
+
+noinst_LIBRARIES = libreg_access.a
+
+reg_accessincludedir=$(includedir)/mft/reg_access
+
+reg_accessinclude_HEADERS = reg_access.h
+
+libreg_access_a_SOURCES = reg_access.c
+libreg_access_a_DEPENDENCIES = $(USER_DIR)/tools_layouts/libtools_layouts.a
+libreg_access_a_LIBADD = $(libreg_access_a_DEPENDENCIES)
+
diff --git a/reg_access/reg_access.c b/reg_access/reg_access.c
new file mode 100644 (file)
index 0000000..337170a
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include "reg_access.h"
+
+#define REG_ID_PPTCS 0x5801
+#define REG_ID_PGMP  0x5802
+#define REG_ID_PPTS  0x5803
+#define REG_ID_PLTS  0x5804
+#define REG_ID_PLSRP 0x5805
+#define REG_ID_PGPS  0x5806
+#define REG_ID_PAOS  0x5006
+#define REG_ID_PTYS  0x5004
+#define REG_ID_MCIA  0x9014
+#define REG_ID_MTMP  0x900a
+#define REG_ID_PMLP  0x5002
+#define REG_ID_MFPA  0x9010
+#define REG_ID_MFBA  0x9011
+#define REG_ID_MFBE  0x9012
+#define REG_ID_MNVA  0x9024
+#define REG_ID_MNVI  0x9025
+#define REG_ID_MNVIA 0x9029
+
+// for debug:
+#ifdef _ENABLE_DEBUG_
+# define DEBUG_PRINT_SEND(data_struct, struct_name)\
+       printf("-I- Data Sent:\n");\
+       register_access_##struct_name##_print(data_struct, stdout, 1)
+# define DEBUG_PRINT_RECIEVE(data_struct, struct_name)\
+       printf("-I- Data Recieved:\n");\
+       register_access_##struct_name##_print(data_struct, stdout, 1)
+#else
+# define DEBUG_PRINT_SEND(data_struct, struct_name)
+# define DEBUG_PRINT_RECIEVE(data_struct, struct_name)
+#endif
+
+// for debug:
+#ifdef _ENABLE_DEBUG_
+# define DEBUG_PRINT_SEND2(data_struct, struct_name)\
+       printf("-I- Data Sent:\n");\
+       tools_##struct_name##_print(data_struct, stdout, 1)
+# define DEBUG_PRINT_RECIEVE2(data_struct, struct_name)\
+       printf("-I- Data Recieved:\n");\
+       tools_##struct_name##_print(data_struct, stdout, 1)
+#else
+# define DEBUG_PRINT_SEND2(data_struct, struct_name)
+# define DEBUG_PRINT_RECIEVE2(data_struct, struct_name)
+#endif
+
+/***************************************************/
+
+// register access for variable size registers (like mfba)
+
+#define REG_ACCCESS_VAR(mf, methdod, reg_id, data_struct, struct_name, reg_size , r_reg_size, w_reg_size)\
+    int status = 0, rc;\
+    int max_data_size = register_access_##struct_name##_size();\
+    u_int8_t data[max_data_size];\
+    register_access_##struct_name##_pack(data_struct, data);\
+    if (method != REG_ACCESS_METHOD_GET && method != REG_ACCESS_METHOD_SET) {\
+        return ME_REG_ACCESS_BAD_METHOD;\
+    }\
+    DEBUG_PRINT_SEND(data_struct, struct_name);\
+    rc = maccess_reg(mf, reg_id, (maccess_reg_method_t)method, data, reg_size, r_reg_size, w_reg_size, &status);\
+    register_access_##struct_name##_unpack(data_struct, data);\
+    DEBUG_PRINT_RECIEVE(data_struct, struct_name);\
+    if (rc || status) {\
+        return (reg_access_status_t)rc;\
+    }\
+    return ME_OK
+
+// register access for static sized registers
+#define REG_ACCCESS(mf, methdod, reg_id, data_struct, struct_name)\
+       int data_size = register_access_##struct_name##_size();\
+       REG_ACCCESS_VAR(mf, methdod, reg_id, data_struct, struct_name, data_size, data_size, data_size)\
+
+
+// register access for registers defined in tools.adb  (this is why I DONT like MACROS!!!)
+
+#define REG_ACCESS_TOOLS(mf, methdod, reg_id, data_struct, struct_name, reg_size , r_reg_size, w_reg_size)\
+    int status = 0, rc;\
+    int max_data_size = tools_##struct_name##_size();\
+    u_int8_t data[max_data_size];\
+    tools_##struct_name##_pack(data_struct, data);\
+    if (method != REG_ACCESS_METHOD_GET && method != REG_ACCESS_METHOD_SET) {\
+        return ME_REG_ACCESS_BAD_METHOD;\
+    }\
+    DEBUG_PRINT_SEND2(data_struct, struct_name);\
+    rc = maccess_reg(mf, reg_id, (maccess_reg_method_t)method, data, reg_size, r_reg_size, w_reg_size, &status);\
+    tools_##struct_name##_unpack(data_struct, data);\
+    DEBUG_PRINT_RECIEVE2(data_struct, struct_name);\
+    if (rc || status) {\
+        return (reg_access_status_t)rc;\
+    }\
+    return ME_OK
+
+
+/************************************
+ * Function: reg_access_mfba
+ ************************************/
+reg_access_status_t reg_access_mfba(mfile* mf, reg_access_method_t method, struct register_access_mfba* mfba)
+{
+       u_int32_t reg_size = mfba->size + REG_ACCESS_MFBA_HEADER_LEN;
+       // the r/w_size_reg is for improved performance for when we send the register
+       // via icmd , since its relatively slow si no need to write the data array from mfba struct to the device when reading from the device
+       // and no need for reading the data array from the device when writing to the device (we just care about the status)
+       u_int32_t r_size_reg = reg_size;
+       u_int32_t w_size_reg= reg_size;
+       if (method == REG_ACCESS_METHOD_GET) {
+               w_size_reg -= mfba->size;
+       } else {
+               r_size_reg -= mfba->size;
+       }
+       //printf("-D- MFBA: data size: %d, reg_size: %d, r_size_reg: %d, w_size_reg: %d\n",mfba->size,reg_size,r_size_reg,w_size_reg);
+    REG_ACCCESS_VAR(mf, method, REG_ID_MFBA, mfba, mfba, reg_size, r_size_reg, w_size_reg);
+}
+
+/************************************
+ * Function: reg_access_mfbe
+ ************************************/
+reg_access_status_t reg_access_mfbe(mfile* mf, reg_access_method_t method, struct register_access_mfbe* mfbe)
+{
+    REG_ACCCESS(mf, method, REG_ID_MFBE, mfbe, mfbe);
+}
+
+/************************************
+ * Function: reg_access_mfpa
+ ************************************/
+reg_access_status_t reg_access_mfpa(mfile* mf, reg_access_method_t method, struct register_access_mfpa* mfpa)
+{
+    REG_ACCCESS(mf, method, REG_ID_MFPA, mfpa, mfpa);
+}
+
+/************************************
+ * Function: reg_access_mnva
+ ************************************/
+reg_access_status_t reg_access_mnva (mfile* mf, reg_access_method_t method, struct tools_mnva* mnva)
+{
+       // reg_size is in bytes
+       u_int32_t reg_size = (mnva->mnv_hdr.length << 2) + tools_mnv_hdr_size();
+       u_int32_t r_size_reg = reg_size;
+       u_int32_t w_size_reg= reg_size;
+       if (method == REG_ACCESS_METHOD_GET) {
+               w_size_reg -= mnva->mnv_hdr.length << 2;
+       } else {
+               r_size_reg -= mnva->mnv_hdr.length << 2;
+       }
+       REG_ACCESS_TOOLS(mf, method, REG_ID_MNVA, mnva, mnva, reg_size , r_size_reg, w_size_reg);
+}
+
+/************************************
+ * Function: reg_access_mnvi
+ ************************************/
+reg_access_status_t reg_access_mnvi (mfile* mf, reg_access_method_t method, struct tools_mnvi* mnvi)
+{
+       if (method != REG_ACCESS_METHOD_SET ) { // this register supports only set method
+               return ME_REG_ACCESS_BAD_METHOD;
+       }
+       u_int32_t reg_size = tools_mnvi_size();
+       REG_ACCESS_TOOLS(mf, method, REG_ID_MNVI, mnvi, mnvi, reg_size , reg_size, reg_size);
+}
+
+/************************************
+ * Function: reg_access_mnvia
+ ************************************/
+reg_access_status_t reg_access_mnvia (mfile* mf, reg_access_method_t method, struct tools_mnvia* mnvia)
+{
+       if (method != REG_ACCESS_METHOD_SET ) { // this register supports only set method
+               return ME_REG_ACCESS_BAD_METHOD;
+       }
+       u_int32_t reg_size = tools_mnvia_size();
+       REG_ACCESS_TOOLS(mf, method, REG_ID_MNVIA, mnvia, mnvia, reg_size , reg_size, reg_size);
+}
+
+/************************************
+ * Function: reg_access_err2str
+ ************************************/
+
+const char* reg_access_err2str(reg_access_status_t status)
+{
+       return m_err2str(status);
+}
diff --git a/reg_access/reg_access.h b/reg_access/reg_access.h
new file mode 100644 (file)
index 0000000..6176dfe
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef REG_ACCESS_H
+#define REG_ACCESS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mtcr.h>
+#include <tools_layouts/register_access_layouts.h>
+
+// Hack, we include this for the MNV registers as they are not officialy a part of register_access so we defined them in tools.adb
+#include <tools_layouts/tools_layouts.h>
+
+enum { // header lengths in bytes
+    REG_ACCESS_MFBA_HEADER_LEN = 12,
+};
+
+typedef enum {
+    REG_ACCESS_METHOD_GET = MACCESS_REG_METHOD_GET,
+    REG_ACCESS_METHOD_SET = MACCESS_REG_METHOD_SET
+} reg_access_method_t;
+
+// we use the same error messages as mtcr
+typedef MError reg_access_status_t;
+
+const char* reg_access_err2str(reg_access_status_t status);
+reg_access_status_t reg_access_mfba (mfile* mf, reg_access_method_t method, struct register_access_mfba* mfba);
+reg_access_status_t reg_access_mfbe (mfile* mf, reg_access_method_t method, struct register_access_mfbe* mfbe);
+reg_access_status_t reg_access_mfpa (mfile* mf, reg_access_method_t method, struct register_access_mfpa* mfpa);
+reg_access_status_t reg_access_mnva (mfile* mf, reg_access_method_t method, struct tools_mnva* mnva);
+reg_access_status_t reg_access_mnvi (mfile* mf, reg_access_method_t method, struct tools_mnvi* mnvi);
+reg_access_status_t reg_access_mnvia (mfile* mf, reg_access_method_t method, struct tools_mnvia* mnvia);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // REG_ACCESS_H
index 5bdbf4743d3367259474448fb21cb70026473488..7297f55f8cd0aebdd5f7dd59f811086b83cd1b0f 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 void usage(const char *n, int with_exit)
 {
     printf("  Mellanox Configuration Registers Access tool\n");
-    printf("  Usage: %s [-s <i2c-slave>] [-a <adb dump>] [-v] [-h] <device> <addr[.<bit offset>:<bit size>]> [data]\n", n);
+    printf("  Usage: %s [-s <i2c-slave>] [-a <adb dump>] [-v] [-h] <device>\n", n);
+    printf("         <addr[.<bit offset>:<bit size>]|[,<bytes number>]> [data]\n");
     printf("         If data is given, operation is write. Otherwise it is read.\n");
-    printf("         If a bit range is given in the address (E.G.: 0xf0014.16:8):.\n");
+    printf("         If a bit range is given in the address (E.G.: 0xf0014.16:8):\n");
     printf("              For read  - Only the requested bits are printed.\n");
-    printf("              For write - Read-Modify-Write. Only the requested bits are changed.\n\n");
+    printf("              For write - Read-Modify-Write. Only the requested bits are changed.\n");
+    printf("         If 'bytes number' is given in the address (E.G.: 0xf0014,16):\n");
+    printf("              For read  - Will read a block (its size is the given bytes number).\n");
+    printf("              For write - User need to give list of dwrods to write, \n"
+           "                          number of dwords should be (bytes number/4).\n\n");
     printf("  -s <i2c-slave> : I2C slave address.\n");
     printf("  -a <dump file> : adb dump file, used for access by path.\n");
     printf("  -h             : Print this help message.\n");
@@ -94,7 +99,7 @@ int main(int argc, char *argv[])
     int           bit_size = 32;
     int           byte_size = 0;
     int           read_block = 0;       /* if 0 then read field according to "addr.bit:size", else read block of size "byte_size" */
-    char*         op_name = "cr write";
+    const char*   op_name = "cr write";
 
 #if 0
     int  i, rc1;
@@ -106,7 +111,7 @@ int main(int argc, char *argv[])
     }
     exit(0);
 #endif
-
+    (void)rc; // avoid warnings (we dont use it just assign)
     // Parse cmd line:
     if (argc < 2) {
         usage(argv[0], 1);
index 8d2ff9800fb0aa0a8a3f19d3d4cc53ce4c91fe41..4436058390614f1f2ebb02bb3db03418535264d5 100644 (file)
@@ -326,7 +326,7 @@ void usage(const char *s)
     printf("Switches may be:\n");
     printf("\t-p[ort] <port> - Listen to specify port (default is %d).\n", port);
     printf("\t-d[ebug]       - Print all socket traffic (for debuging only).\n");
-    printf(sim_str);
+    printf("%s", sim_str);
     printf("\t-h[elp]        - Print help message.\n");
     exit (1);
 }
index 65575358555f6d2ff0dfe0f441f9ed9d997fc05a..54620e81ed59b0dfe3fc694dcaa7919152dfd965 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Author: Michael S. Tsirkin <mst@mellanox.co.il>
  *
- * Copyright (c) 2010 Mellanox Technologies Ltd.  All rights reserved.
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
index 64c171fbfd060b26966303edef3b97b87bd4ce75..0717143c11eab150fd092f0fd0bf30410874847c 100644 (file)
@@ -35,5 +35,7 @@ INCLUDES = -I$(top_srcdir)/mtcr_ul -I$(top_srcdir)/common
 AM_CFLAGS = -Wall -W -g -MP -MD -pipe $(COMPILER_FPIC)
 noinst_LIBRARIES = libtools_layouts.a
 
-libtools_layouts_a_SOURCES = cibfw_layouts.c adb_to_c_utils.c adb_to_c_utils.h cibfw_layouts.h
+libtools_layouts_a_SOURCES = cibfw_layouts.c adb_to_c_utils.c adb_to_c_utils.h cibfw_layouts.h \
+                                                               register_access_layouts.c register_access_layouts.c \
+                                                               tools_layouts.c tools_layouts.h
 
index 6bbec885ec274add12e34a418b779396ff92c93b..e25389557ae2e67fa6e06e2d1e4fe7cd1a40716d 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * SOFTWARE.
  */
 
-
 /***
- *** This file was generated at "2013-12-03 16:31:51"
+ *** This file was generated at "2014-03-23 17:16:25"
  *** by:
  ***    > /mswg/release/eat_me/last_release/adabe_plugins/adb2c/adb2pack.py --input adb/golan/golan.adb --file-prefix golan --prefix golan_
  ***/
index 424c78dc5a3109a50f18a9d27724d2ad8ee846e9..a0cc9d3e50a3931ed8c1e97ae24885ce00f4cf2a 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * SOFTWARE.
  */
 
-
 /***
- *** This file was generated at "2013-12-03 16:31:51"
+ *** This file was generated at "2014-03-23 17:16:25"
  *** by:
  ***    > /mswg/release/eat_me/last_release/adabe_plugins/adb2c/adb2pack.py --input adb/golan/golan.adb --file-prefix golan --prefix golan_
  ***/
@@ -133,6 +131,8 @@ extern "C" {
 #       define ARCH_ppc64
 #   elif defined(__PPC__)
 #       define ARCH_ppc
+#   elif defined(__aarch64__)
+#       define ARCH_arm64
 #   else
 #       error Unknown CPU architecture using the linux OS
 #   endif
@@ -176,7 +176,7 @@ extern "C" {
 #       define U64H_FMT    "0x%016llx"
 #       define U48H_FMT    "0x%012llx"
 #   endif
-#elif defined (ARCH_ia64) || defined(ARCH_x86_64) || defined(ARCH_ppc64)
+#elif defined (ARCH_ia64) || defined(ARCH_x86_64) || defined(ARCH_ppc64) || defined(ARCH_arm64)
 #    define U64D_FMT    "%lu"
 #    define U64H_FMT    "0x%016lx"
 #       define U48H_FMT        "0x%012lx" 
index 64e5b22771c9fe315eb9070dda4ede1b0c6b05df..6eccab11cc034f463218dfbd59472cddf5cb08e3 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * SOFTWARE.
  */
 
-
 /***
- *** This file was generated at "2013-12-03 16:31:41"
+ *** This file was generated at "2014-03-23 17:16:21"
  *** by:
  ***    > /mswg/release/eat_me/last_release/adabe_plugins/adb2c/adb2pack.py --input adb/cibfw/cibfw.adb --file-prefix cibfw --prefix cibfw_
  ***/
 void cibfw_uint64_pack(const struct cibfw_uint64 *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        adb2c_push_integer_to_buff(ptr_buff, offset, 4, (u_int64_t)ptr_struct->hi);
@@ -55,7 +56,10 @@ void cibfw_uint64_pack(const struct cibfw_uint64 *ptr_struct, u_int8_t* ptr_buff
 void cibfw_uint64_unpack(struct cibfw_uint64 *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        ptr_struct->hi = (u_int32_t)adb2c_pop_integer_from_buff(ptr_buff, offset, 4);
@@ -69,7 +73,9 @@ void cibfw_uint64_print(const struct cibfw_uint64 *ptr_struct, FILE* file, int i
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== uint64 ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "hi                   : "U32H_FMT"\n", ptr_struct->hi);
@@ -90,7 +96,10 @@ void cibfw_uint64_dump(const struct cibfw_uint64 *ptr_struct, FILE* file) {
 void cibfw_uid_entry_pack(const struct cibfw_uid_entry *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=24;
        adb2c_push_bits_to_buff(ptr_buff, offset, 8, (u_int32_t)ptr_struct->num_allocated);
@@ -106,7 +115,10 @@ void cibfw_uid_entry_pack(const struct cibfw_uid_entry *ptr_struct, u_int8_t* pt
 void cibfw_uid_entry_unpack(struct cibfw_uid_entry *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=24;
        ptr_struct->num_allocated = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 8);
@@ -123,7 +135,9 @@ void cibfw_uid_entry_print(const struct cibfw_uid_entry *ptr_struct, FILE* file,
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== uid_entry ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "num_allocated        : "UH_FMT"\n", ptr_struct->num_allocated);
@@ -147,7 +161,10 @@ void cibfw_uid_entry_dump(const struct cibfw_uid_entry *ptr_struct, FILE* file)
 void cibfw_TRIPPLE_VERSION_pack(const struct cibfw_TRIPPLE_VERSION *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        adb2c_push_bits_to_buff(ptr_buff, offset, 16, (u_int32_t)ptr_struct->MAJOR);
@@ -163,7 +180,10 @@ void cibfw_TRIPPLE_VERSION_pack(const struct cibfw_TRIPPLE_VERSION *ptr_struct,
 void cibfw_TRIPPLE_VERSION_unpack(struct cibfw_TRIPPLE_VERSION *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        ptr_struct->MAJOR = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 16);
@@ -180,7 +200,9 @@ void cibfw_TRIPPLE_VERSION_print(const struct cibfw_TRIPPLE_VERSION *ptr_struct,
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== TRIPPLE_VERSION ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "MAJOR                : "UH_FMT"\n", ptr_struct->MAJOR);
@@ -204,7 +226,10 @@ void cibfw_TRIPPLE_VERSION_dump(const struct cibfw_TRIPPLE_VERSION *ptr_struct,
 void cibfw_FW_VERSION_pack(const struct cibfw_FW_VERSION *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        adb2c_push_bits_to_buff(ptr_buff, offset, 16, (u_int32_t)ptr_struct->MAJOR);
@@ -238,7 +263,10 @@ void cibfw_FW_VERSION_pack(const struct cibfw_FW_VERSION *ptr_struct, u_int8_t*
 void cibfw_FW_VERSION_unpack(struct cibfw_FW_VERSION *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        ptr_struct->MAJOR = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 16);
@@ -273,7 +301,9 @@ void cibfw_FW_VERSION_print(const struct cibfw_FW_VERSION *ptr_struct, FILE* fil
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== FW_VERSION ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "MAJOR                : "UH_FMT"\n", ptr_struct->MAJOR);
@@ -315,7 +345,10 @@ void cibfw_FW_VERSION_dump(const struct cibfw_FW_VERSION *ptr_struct, FILE* file
 void cibfw_guids_pack(const struct cibfw_guids *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        for (i=0; i < 2; i++) {
        offset=adb2c_calc_array_field_address(0, 128, i, 512, 1);
@@ -332,7 +365,10 @@ void cibfw_guids_pack(const struct cibfw_guids *ptr_struct, u_int8_t* ptr_buff){
 void cibfw_guids_unpack(struct cibfw_guids *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        for (i=0; i < 2; i++) {
        offset=adb2c_calc_array_field_address(0, 128, i, 512, 1);
@@ -350,7 +386,9 @@ void cibfw_guids_print(const struct cibfw_guids *ptr_struct, FILE* file, int ind
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== guids ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        for (i=0; i < 2; i++) {
        adb2c_add_indentation(file, indent_level);
@@ -377,7 +415,10 @@ void cibfw_guids_dump(const struct cibfw_guids *ptr_struct, FILE* file) {
 void cibfw_operation_key_pack(const struct cibfw_operation_key *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=16;
        adb2c_push_bits_to_buff(ptr_buff, offset, 16, (u_int32_t)ptr_struct->key_modifier);
@@ -390,7 +431,10 @@ void cibfw_operation_key_pack(const struct cibfw_operation_key *ptr_struct, u_in
 void cibfw_operation_key_unpack(struct cibfw_operation_key *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=16;
        ptr_struct->key_modifier = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 16);
@@ -404,7 +448,9 @@ void cibfw_operation_key_print(const struct cibfw_operation_key *ptr_struct, FIL
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== operation_key ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "key_modifier         : "UH_FMT"\n", ptr_struct->key_modifier);
@@ -425,7 +471,10 @@ void cibfw_operation_key_dump(const struct cibfw_operation_key *ptr_struct, FILE
 void cibfw_image_info_pack(const struct cibfw_image_info *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=32;
        cibfw_FW_VERSION_pack(&(ptr_struct->FW_VERSION), ptr_buff + offset/8);
@@ -464,7 +513,10 @@ void cibfw_image_info_pack(const struct cibfw_image_info *ptr_struct, u_int8_t*
 void cibfw_image_info_unpack(struct cibfw_image_info *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=32;
        cibfw_FW_VERSION_unpack(&(ptr_struct->FW_VERSION), ptr_buff + offset/8);
@@ -507,7 +559,9 @@ void cibfw_image_info_print(const struct cibfw_image_info *ptr_struct, FILE* fil
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== image_info ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "FW_VERSION:\n");
@@ -544,7 +598,10 @@ void cibfw_image_info_dump(const struct cibfw_image_info *ptr_struct, FILE* file
 void cibfw_mfg_info_pack(const struct cibfw_mfg_info *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        for (i=0; i < 16; i++) {
        offset=adb2c_calc_array_field_address(24, 8, i, 2560, 1);
@@ -562,7 +619,10 @@ void cibfw_mfg_info_pack(const struct cibfw_mfg_info *ptr_struct, u_int8_t* ptr_
 void cibfw_mfg_info_unpack(struct cibfw_mfg_info *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        for (i=0; i < 16; i++) {
        offset=adb2c_calc_array_field_address(24, 8, i, 2560, 1);
@@ -582,7 +642,9 @@ void cibfw_mfg_info_print(const struct cibfw_mfg_info *ptr_struct, FILE* file, i
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== mfg_info ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        fprintf(file, "psid                 : \"%s\"\n", ptr_struct->psid);
        adb2c_add_indentation(file, indent_level);
@@ -605,7 +667,10 @@ void cibfw_mfg_info_dump(const struct cibfw_mfg_info *ptr_struct, FILE* file) {
 void cibfw_device_info_pack(const struct cibfw_device_info *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        adb2c_push_integer_to_buff(ptr_buff, offset, 4, (u_int64_t)ptr_struct->signature0);
@@ -646,7 +711,10 @@ void cibfw_device_info_pack(const struct cibfw_device_info *ptr_struct, u_int8_t
 void cibfw_device_info_unpack(struct cibfw_device_info *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        ptr_struct->signature0 = (u_int32_t)adb2c_pop_integer_from_buff(ptr_buff, offset, 4);
@@ -689,7 +757,9 @@ void cibfw_device_info_print(const struct cibfw_device_info *ptr_struct, FILE* f
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== device_info ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "signature0           : "U32H_FMT"\n", ptr_struct->signature0);
@@ -736,7 +806,10 @@ void cibfw_device_info_dump(const struct cibfw_device_info *ptr_struct, FILE* fi
 void cibfw_itoc_header_pack(const struct cibfw_itoc_header *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        adb2c_push_integer_to_buff(ptr_buff, offset, 4, (u_int64_t)ptr_struct->signature0);
@@ -761,7 +834,10 @@ void cibfw_itoc_header_pack(const struct cibfw_itoc_header *ptr_struct, u_int8_t
 void cibfw_itoc_header_unpack(struct cibfw_itoc_header *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=0;
        ptr_struct->signature0 = (u_int32_t)adb2c_pop_integer_from_buff(ptr_buff, offset, 4);
@@ -787,7 +863,9 @@ void cibfw_itoc_header_print(const struct cibfw_itoc_header *ptr_struct, FILE* f
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== itoc_header ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "signature0           : "U32H_FMT"\n", ptr_struct->signature0);
@@ -820,7 +898,10 @@ void cibfw_itoc_header_dump(const struct cibfw_itoc_header *ptr_struct, FILE* fi
 void cibfw_itoc_entry_pack(const struct cibfw_itoc_entry *ptr_struct, u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=8;
        adb2c_push_bits_to_buff(ptr_buff, offset, 22, (u_int32_t)ptr_struct->size);
@@ -828,8 +909,14 @@ void cibfw_itoc_entry_pack(const struct cibfw_itoc_entry *ptr_struct, u_int8_t*
        offset=0;
        adb2c_push_bits_to_buff(ptr_buff, offset, 8, (u_int32_t)ptr_struct->type);
 
+       offset=34;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 30, (u_int32_t)ptr_struct->param0);
+
+       offset=33;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->cache_line_crc);
+
        offset=32;
-       adb2c_push_integer_to_buff(ptr_buff, offset, 4, (u_int64_t)ptr_struct->param0);
+       adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->zipped_image);
 
        offset=64;
        adb2c_push_integer_to_buff(ptr_buff, offset, 4, (u_int64_t)ptr_struct->param1);
@@ -849,9 +936,6 @@ void cibfw_itoc_entry_pack(const struct cibfw_itoc_entry *ptr_struct, u_int8_t*
        offset=206;
        adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->device_data);
 
-       offset=205;
-       adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->cache_line_crc);
-
        offset=240;
        adb2c_push_bits_to_buff(ptr_buff, offset, 16, (u_int32_t)ptr_struct->itoc_entry_crc);
 
@@ -860,7 +944,10 @@ void cibfw_itoc_entry_pack(const struct cibfw_itoc_entry *ptr_struct, u_int8_t*
 void cibfw_itoc_entry_unpack(struct cibfw_itoc_entry *ptr_struct, const u_int8_t* ptr_buff){
        u_int32_t offset;
        int i=0;
-       i=i;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
 
        offset=8;
        ptr_struct->size = (u_int32_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 22);
@@ -868,8 +955,14 @@ void cibfw_itoc_entry_unpack(struct cibfw_itoc_entry *ptr_struct, const u_int8_t
        offset=0;
        ptr_struct->type = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 8);
 
+       offset=34;
+       ptr_struct->param0 = (u_int32_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 30);
+
+       offset=33;
+       ptr_struct->cache_line_crc = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
        offset=32;
-       ptr_struct->param0 = (u_int32_t)adb2c_pop_integer_from_buff(ptr_buff, offset, 4);
+       ptr_struct->zipped_image = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
 
        offset=64;
        ptr_struct->param1 = (u_int32_t)adb2c_pop_integer_from_buff(ptr_buff, offset, 4);
@@ -889,9 +982,6 @@ void cibfw_itoc_entry_unpack(struct cibfw_itoc_entry *ptr_struct, const u_int8_t
        offset=206;
        ptr_struct->device_data = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
 
-       offset=205;
-       ptr_struct->cache_line_crc = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
-
        offset=240;
        ptr_struct->itoc_entry_crc = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 16);
 
@@ -901,7 +991,9 @@ void cibfw_itoc_entry_print(const struct cibfw_itoc_entry *ptr_struct, FILE* fil
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== itoc_entry ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "size                 : "UH_FMT"\n", ptr_struct->size);
@@ -910,7 +1002,13 @@ void cibfw_itoc_entry_print(const struct cibfw_itoc_entry *ptr_struct, FILE* fil
        fprintf(file, "type                 : "UH_FMT"\n", ptr_struct->type);
 
        adb2c_add_indentation(file, indent_level);
-       fprintf(file, "param0               : "U32H_FMT"\n", ptr_struct->param0);
+       fprintf(file, "param0               : "UH_FMT"\n", ptr_struct->param0);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "cache_line_crc       : "UH_FMT"\n", ptr_struct->cache_line_crc);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "zipped_image         : "UH_FMT"\n", ptr_struct->zipped_image);
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "param1               : "U32H_FMT"\n", ptr_struct->param1);
@@ -930,9 +1028,6 @@ void cibfw_itoc_entry_print(const struct cibfw_itoc_entry *ptr_struct, FILE* fil
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "device_data          : "UH_FMT"\n", ptr_struct->device_data);
 
-       adb2c_add_indentation(file, indent_level);
-       fprintf(file, "cache_line_crc       : "UH_FMT"\n", ptr_struct->cache_line_crc);
-
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "itoc_entry_crc       : "UH_FMT"\n", ptr_struct->itoc_entry_crc);
 
@@ -960,7 +1055,9 @@ void cibfw_Nodes_print(const union cibfw_Nodes *ptr_struct, FILE* file, int inde
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "======== Nodes ========\n");
        int i=0;
-       i=i;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
 
        adb2c_add_indentation(file, indent_level);
        fprintf(file, "itoc_entry:\n");
index 9b612ee53a9773cda1f0ede2cb55a3e5987b4241..31f710819529fe17f1a6e0057dccefde8c1f3439 100644 (file)
@@ -1,25 +1,25 @@
 /*
  * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
- * 
+ *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
  * General Public License (GPL) Version 2, available from the file
  * COPYING in the main directory of this source tree, or the
  * OpenIB.org BSD license below:
- * 
+ *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
  *     conditions are met:
- * 
+ *
  *      - Redistributions of source code must retain the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer.
- * 
+ *
  *      - Redistributions in binary form must reproduce the above
  *        copyright notice, this list of conditions and the following
  *        disclaimer in the documentation and/or other materials
  *        provided with the distribution.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * SOFTWARE.
  */
 
-
 /***
- *** This file was generated at "2013-12-03 16:31:41"
+ *** This file was generated at "2014-03-23 17:16:21"
  *** by:
  ***    > /mswg/release/eat_me/last_release/adabe_plugins/adb2c/adb2pack.py --input adb/cibfw/cibfw.adb --file-prefix cibfw --prefix cibfw_
  ***/
@@ -333,8 +331,14 @@ All other values Reserved
         u_int8_t type;
 /*---------------- DWORD[1] (Offset 0x4) ----------------*/
        /* Description - if partition type is code or ini then the load address is in here */
-       /* 4.0 - 8.31 */
+       /* 4.0 - 4.29 */
         u_int32_t param0;
+       /* Description - When this bit is set, Data within the section is protected by per-line crc. See yu.flash.replacement.crc_en */
+       /* 4.30 - 4.30 */
+        u_int8_t cache_line_crc;
+       /* Description - When this bit is set, image is zipped */
+       /* 4.31 - 8.31 */
+        u_int8_t zipped_image;
 /*---------------- DWORD[2] (Offset 0x8) ----------------*/
        /* Description - if partition type is code then the jump address is in here */
        /* 8.0 - 12.31 */
@@ -358,9 +362,6 @@ A device_data section should not be updated in a regular FW update.
 Example for device_data section: VPD_R, GUIDs. */
        /* 24.17 - 24.17 */
         u_int8_t device_data;
-       /* Description - When this bit is set, Data within the section is protected by per-line crc. See yu.flash.replacement.crc_en */
-       /* 24.18 - 24.18 */
-        u_int8_t cache_line_crc;
 /*---------------- DWORD[7] (Offset 0x1c) ----------------*/
        /* Description -  */
        /* 28.0 - 28.15 */
diff --git a/tools_layouts/register_access_layouts.c b/tools_layouts/register_access_layouts.c
new file mode 100644 (file)
index 0000000..8120255
--- /dev/null
@@ -0,0 +1,350 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/***
+ *** This file was generated at "2014-03-11 10:09:59"
+ *** by:
+ ***    > /mswg/release/eat_me/last_release/adabe_plugins/adb2c/adb2pack.py --input adb/register_access/register_access.adb --file-prefix register_access --prefix register_access_
+ ***    and modified to fit the needs of mstflint.
+ ***/
+#include "register_access_layouts.h"
+
+void register_access_Byte_pack(const struct register_access_Byte *ptr_struct, u_int8_t* ptr_buff){
+       u_int32_t offset;
+       int i=0;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
+
+       offset=0;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 8, (u_int32_t)ptr_struct->val);
+
+}
+
+void register_access_Byte_unpack(struct register_access_Byte *ptr_struct, const u_int8_t* ptr_buff){
+       u_int32_t offset;
+       int i=0;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
+
+       offset=0;
+       ptr_struct->val = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 8);
+
+}
+
+void register_access_Byte_print(const struct register_access_Byte *ptr_struct, FILE* file, int indent_level){
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "======== Byte ========\n");
+       int i=0;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "val                  : "UH_FMT"\n", ptr_struct->val);
+
+}
+
+int register_access_Byte_size(){
+        return 1;
+}
+
+void register_access_Byte_dump(const struct register_access_Byte *ptr_struct, FILE* file) {
+       register_access_Byte_print(ptr_struct, file, 0);
+}
+
+void register_access_mfpa_pack(const struct register_access_mfpa *ptr_struct, u_int8_t* ptr_buff){
+       u_int32_t offset;
+       int i=0;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
+
+       offset=26;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 2, (u_int32_t)ptr_struct->fs);
+
+       offset=23;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->p);
+
+       offset=40;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 24, (u_int32_t)ptr_struct->boot_address);
+
+       offset=156;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 4, (u_int32_t)ptr_struct->flash_num);
+
+       offset=168;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 24, (u_int32_t)ptr_struct->jedec_id);
+
+       offset=214;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 10, (u_int32_t)ptr_struct->sector_size);
+
+       offset=200;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 8, (u_int32_t)ptr_struct->block_allignment);
+
+       offset=224;
+       adb2c_push_integer_to_buff(ptr_buff, offset, 4, (u_int64_t)ptr_struct->capability_mask);
+
+}
+
+void register_access_mfpa_unpack(struct register_access_mfpa *ptr_struct, const u_int8_t* ptr_buff){
+       u_int32_t offset;
+       int i=0;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
+
+       offset=26;
+       ptr_struct->fs = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 2);
+
+       offset=23;
+       ptr_struct->p = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+       offset=40;
+       ptr_struct->boot_address = (u_int32_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 24);
+
+       offset=156;
+       ptr_struct->flash_num = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 4);
+
+       offset=168;
+       ptr_struct->jedec_id = (u_int32_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 24);
+
+       offset=214;
+       ptr_struct->sector_size = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 10);
+
+       offset=200;
+       ptr_struct->block_allignment = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 8);
+
+       offset=224;
+       ptr_struct->capability_mask = (u_int32_t)adb2c_pop_integer_from_buff(ptr_buff, offset, 4);
+
+}
+
+void register_access_mfpa_print(const struct register_access_mfpa *ptr_struct, FILE* file, int indent_level){
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "======== mfpa ========\n");
+       int i=0;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "fs                   : "UH_FMT"\n", ptr_struct->fs);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "p                    : "UH_FMT"\n", ptr_struct->p);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "boot_address         : "UH_FMT"\n", ptr_struct->boot_address);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "flash_num            : "UH_FMT"\n", ptr_struct->flash_num);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "jedec_id             : "UH_FMT"\n", ptr_struct->jedec_id);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "sector_size          : "UH_FMT"\n", ptr_struct->sector_size);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "block_allignment     : "UH_FMT"\n", ptr_struct->block_allignment);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "capability_mask      : "U32H_FMT"\n", ptr_struct->capability_mask);
+
+}
+
+int register_access_mfpa_size(){
+        return 36;
+}
+
+void register_access_mfpa_dump(const struct register_access_mfpa *ptr_struct, FILE* file) {
+       register_access_mfpa_print(ptr_struct, file, 0);
+}
+
+void register_access_mfba_pack(const struct register_access_mfba *ptr_struct, u_int8_t* ptr_buff){
+       u_int32_t offset;
+       int i=0;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
+
+       offset=26;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 2, (u_int32_t)ptr_struct->fs);
+
+       offset=23;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->p);
+
+       offset=55;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 9, (u_int32_t)ptr_struct->size);
+
+       offset=72;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 24, (u_int32_t)ptr_struct->address);
+
+       for (i=0; i < 64; i++) {
+       offset=adb2c_calc_array_field_address(96, 32, i, 2144, 0);
+       adb2c_push_integer_to_buff(ptr_buff, offset, 4, (u_int64_t)ptr_struct->data[i]);
+       }
+
+}
+
+void register_access_mfba_unpack(struct register_access_mfba *ptr_struct, const u_int8_t* ptr_buff){
+       u_int32_t offset;
+       int i=0;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
+
+       offset=26;
+       ptr_struct->fs = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 2);
+
+       offset=23;
+       ptr_struct->p = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+       offset=55;
+       ptr_struct->size = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 9);
+
+       offset=72;
+       ptr_struct->address = (u_int32_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 24);
+
+       for (i=0; i < 64; i++) {
+       offset=adb2c_calc_array_field_address(96, 32, i, 2144, 0);
+       ptr_struct->data[i] = (u_int32_t)adb2c_pop_integer_from_buff(ptr_buff, offset, 4);
+       }
+
+}
+
+void register_access_mfba_print(const struct register_access_mfba *ptr_struct, FILE* file, int indent_level){
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "======== mfba ========\n");
+       int i=0;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "fs                   : "UH_FMT"\n", ptr_struct->fs);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "p                    : "UH_FMT"\n", ptr_struct->p);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "size                 : "UH_FMT"\n", ptr_struct->size);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "address              : "UH_FMT"\n", ptr_struct->address);
+
+       for (i=0; i < 64; i++) {
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "data[%3d]            : "U32H_FMT"\n", i, ptr_struct->data[i]);
+       }
+
+}
+
+int register_access_mfba_size(){
+        return 268;
+}
+
+void register_access_mfba_dump(const struct register_access_mfba *ptr_struct, FILE* file) {
+       register_access_mfba_print(ptr_struct, file, 0);
+}
+
+void register_access_mfbe_pack(const struct register_access_mfbe *ptr_struct, u_int8_t* ptr_buff){
+       u_int32_t offset;
+       int i=0;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
+
+       offset=26;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 2, (u_int32_t)ptr_struct->fs);
+
+       offset=23;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->p);
+
+       offset=72;
+       adb2c_push_bits_to_buff(ptr_buff, offset, 24, (u_int32_t)ptr_struct->address);
+
+}
+
+void register_access_mfbe_unpack(struct register_access_mfbe *ptr_struct, const u_int8_t* ptr_buff){
+       u_int32_t offset;
+       int i=0;
+       (void)offset;
+       (void)i;
+       (void)ptr_struct;
+       (void)ptr_buff;
+
+       offset=26;
+       ptr_struct->fs = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 2);
+
+       offset=23;
+       ptr_struct->p = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+       offset=72;
+       ptr_struct->address = (u_int32_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 24);
+
+}
+
+void register_access_mfbe_print(const struct register_access_mfbe *ptr_struct, FILE* file, int indent_level){
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "======== mfbe ========\n");
+       int i=0;
+       (void)i;(void)ptr_struct;
+       (void)file;
+       (void)indent_level;
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "fs                   : "UH_FMT"\n", ptr_struct->fs);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "p                    : "UH_FMT"\n", ptr_struct->p);
+
+       adb2c_add_indentation(file, indent_level);
+       fprintf(file, "address              : "UH_FMT"\n", ptr_struct->address);
+
+}
+
+int register_access_mfbe_size(){
+        return 12;
+}
+
+void register_access_mfbe_dump(const struct register_access_mfbe *ptr_struct, FILE* file) {
+       register_access_mfbe_print(ptr_struct, file, 0);
+}
diff --git a/tools_layouts/register_access_layouts.h b/tools_layouts/register_access_layouts.h
new file mode 100644 (file)
index 0000000..dda2ab3
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/***
+ *** This file was generated at "2014-03-11 10:09:59"
+ *** by:
+ ***    > /mswg/release/eat_me/last_release/adabe_plugins/adb2c/adb2pack.py --input adb/register_access/register_access.adb --file-prefix register_access --prefix register_access_
+ ***    and modified to fit the needs of mstflint.
+ ***/
+#ifndef REGISTER_ACCESS_LAYOUTS_H
+#define REGISTER_ACCESS_LAYOUTS_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "adb_to_c_utils.h"/* Description -   */
+/* Size in bytes - 1 */
+struct register_access_Byte {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+       /* Description -  */
+       /* 0.0 - 0.7 */
+        u_int8_t val;
+};
+
+/* Description -   */
+/* Size in bytes - 36 */
+struct register_access_mfpa {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+       /* Description - Flash Select */
+       /* 0.4 - 0.5 */
+        u_int8_t fs;
+       /* Description - Parallel */
+       /* 0.8 - 0.8 */
+        u_int8_t p;
+/*---------------- DWORD[1] (Offset 0x4) ----------------*/
+       /* Description - address in bytes */
+       /* 4.0 - 4.23 */
+        u_int32_t boot_address;
+/*---------------- DWORD[4] (Offset 0x10) ----------------*/
+       /* Description - number of flash devices connected */
+       /* 16.0 - 16.3 */
+        u_int8_t flash_num;
+/*---------------- DWORD[5] (Offset 0x14) ----------------*/
+       /* Description - Flash JEDEC ID */
+       /* 20.0 - 20.23 */
+        u_int32_t jedec_id;
+/*---------------- DWORD[6] (Offset 0x18) ----------------*/
+       /* Description - Flash sectore size */
+       /* 24.0 - 24.9 */
+        u_int16_t sector_size;
+       /* Description -  */
+       /* 24.16 - 24.23 */
+        u_int8_t block_allignment;
+/*---------------- DWORD[7] (Offset 0x1c) ----------------*/
+       /* Description - capability mask ;bit 0:Parallel flash Support;else:Reserved  */
+       /* 28.0 - 32.31 */
+        u_int32_t capability_mask;
+};
+
+/* Description -   */
+/* Size in bytes - 268 */
+struct register_access_mfba {/* Nodes */
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+       /* Description - Flash Select */
+       /* 0.4 - 0.5 */
+        u_int8_t fs;
+       /* Description - Parallel */
+       /* 0.8 - 0.8 */
+        u_int8_t p;
+/*---------------- DWORD[1] (Offset 0x4) ----------------*/
+       /* Description - Transaction size */
+       /* 4.0 - 4.8 */
+        u_int16_t size;
+/*---------------- DWORD[2] (Offset 0x8) ----------------*/
+       /* Description - address in bytes */
+       /* 8.0 - 8.23 */
+        u_int32_t address;
+/*---------------- DWORD[3] (Offset 0xc) ----------------*/
+       /* Description - data */
+       /* 12.0 - 268.31 */
+        u_int32_t data[64];
+};
+
+/* Description -   */
+/* Size in bytes - 12 */
+struct register_access_mfbe {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+       /* Description - Flash Select */
+       /* 0.4 - 0.5 */
+        u_int8_t fs;
+       /* Description - Parallel */
+       /* 0.8 - 0.8 */
+        u_int8_t p;
+/*---------------- DWORD[2] (Offset 0x8) ----------------*/
+       /* Description - address in bytes */
+       /* 8.0 - 8.23 */
+        u_int32_t address;
+};
+
+/*================= PACK/UNPACK/PRINT FUNCTIONS ======================*/
+/* Byte */
+void register_access_Byte_pack(const struct register_access_Byte *ptr_struct, u_int8_t* ptr_buff);
+void register_access_Byte_unpack(struct register_access_Byte *ptr_struct, const u_int8_t* ptr_buff);
+void register_access_Byte_print(const struct register_access_Byte *ptr_struct, FILE* file, int indent_level);
+int register_access_Byte_size();
+#define REGISTER_ACCESS_BYTE_SIZE    (0x1)
+void register_access_Byte_dump(const struct register_access_Byte *ptr_struct, FILE* file);
+/* mfpa */
+void register_access_mfpa_pack(const struct register_access_mfpa *ptr_struct, u_int8_t* ptr_buff);
+void register_access_mfpa_unpack(struct register_access_mfpa *ptr_struct, const u_int8_t* ptr_buff);
+void register_access_mfpa_print(const struct register_access_mfpa *ptr_struct, FILE* file, int indent_level);
+int register_access_mfpa_size();
+#define REGISTER_ACCESS_MFPA_SIZE    (0x24)
+void register_access_mfpa_dump(const struct register_access_mfpa *ptr_struct, FILE* file);
+/* mfba */
+void register_access_mfba_pack(const struct register_access_mfba *ptr_struct, u_int8_t* ptr_buff);
+void register_access_mfba_unpack(struct register_access_mfba *ptr_struct, const u_int8_t* ptr_buff);
+void register_access_mfba_print(const struct register_access_mfba *ptr_struct, FILE* file, int indent_level);
+int register_access_mfba_size();
+#define REGISTER_ACCESS_MFBA_SIZE    (0x10c)
+void register_access_mfba_dump(const struct register_access_mfba *ptr_struct, FILE* file);
+/* mfbe */
+void register_access_mfbe_pack(const struct register_access_mfbe *ptr_struct, u_int8_t* ptr_buff);
+void register_access_mfbe_unpack(struct register_access_mfbe *ptr_struct, const u_int8_t* ptr_buff);
+void register_access_mfbe_print(const struct register_access_mfbe *ptr_struct, FILE* file, int indent_level);
+int register_access_mfbe_size();
+#define REGISTER_ACCESS_MFBE_SIZE    (0xc)
+void register_access_mfbe_dump(const struct register_access_mfbe *ptr_struct, FILE* file);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // REGISTER_ACCESS_LAYOUTS_H
diff --git a/tools_layouts/tools_layouts.c b/tools_layouts/tools_layouts.c
new file mode 100644 (file)
index 0000000..39ae8e5
--- /dev/null
@@ -0,0 +1,542 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/***
+ *** This file was generated at "2014-03-11 10:10:14"
+ *** by:
+ ***    > /mswg/release/eat_me/last_release/adabe_plugins/adb2c/adb2pack.py --input adb/tools/tools.adb --file-prefix tools --prefix tools_
+ ***    and modified to fit the needs of mstflint.
+ ***/
+#include "tools_layouts.h"
+
+void tools_mnv_hdr_pack(const struct tools_mnv_hdr *ptr_struct, u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=16;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 16, (u_int32_t)ptr_struct->type);
+
+    offset=2;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 12, (u_int32_t)ptr_struct->length);
+
+    offset=40;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 8, (u_int32_t)ptr_struct->type_mod);
+
+    offset=39;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->shadow);
+
+    offset=37;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 2, (u_int32_t)ptr_struct->pad_cnt);
+
+    offset=32;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 4, (u_int32_t)ptr_struct->version);
+
+}
+
+void tools_mnv_hdr_unpack(struct tools_mnv_hdr *ptr_struct, const u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=16;
+    ptr_struct->type = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 16);
+
+    offset=2;
+    ptr_struct->length = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 12);
+
+    offset=40;
+    ptr_struct->type_mod = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 8);
+
+    offset=39;
+    ptr_struct->shadow = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+    offset=37;
+    ptr_struct->pad_cnt = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 2);
+
+    offset=32;
+    ptr_struct->version = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 4);
+
+}
+
+void tools_mnv_hdr_print(const struct tools_mnv_hdr *ptr_struct, FILE* file, int indent_level){
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "======== mnv_hdr ========\n");
+    int i=0;
+    (void)i;(void)ptr_struct;
+    (void)file;
+    (void)indent_level;
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "type                 : "UH_FMT"\n", ptr_struct->type);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "length               : "UH_FMT"\n", ptr_struct->length);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "type_mod             : "UH_FMT"\n", ptr_struct->type_mod);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "shadow               : "UH_FMT"\n", ptr_struct->shadow);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "pad_cnt              : "UH_FMT"\n", ptr_struct->pad_cnt);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "version              : "UH_FMT"\n", ptr_struct->version);
+
+}
+
+int tools_mnv_hdr_size(){
+     return 8;
+}
+
+void tools_mnv_hdr_dump(const struct tools_mnv_hdr *ptr_struct, FILE* file) {
+    tools_mnv_hdr_print(ptr_struct, file, 0);
+}
+
+void tools_mnvia_pack(const struct tools_mnvia *ptr_struct, u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=0;
+    tools_mnv_hdr_pack(&(ptr_struct->mnv_hdr), ptr_buff + offset/8);
+
+}
+
+void tools_mnvia_unpack(struct tools_mnvia *ptr_struct, const u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=0;
+    tools_mnv_hdr_unpack(&(ptr_struct->mnv_hdr), ptr_buff + offset/8);
+
+}
+
+void tools_mnvia_print(const struct tools_mnvia *ptr_struct, FILE* file, int indent_level){
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "======== mnvia ========\n");
+    int i=0;
+    (void)i;(void)ptr_struct;
+    (void)file;
+    (void)indent_level;
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "mnv_hdr:\n");
+    tools_mnv_hdr_print(&(ptr_struct->mnv_hdr), file, indent_level + 1);
+
+}
+
+int tools_mnvia_size(){
+     return 8;
+}
+
+void tools_mnvia_dump(const struct tools_mnvia *ptr_struct, FILE* file) {
+    tools_mnvia_print(ptr_struct, file, 0);
+}
+
+void tools_mnvi_pack(const struct tools_mnvi *ptr_struct, u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=0;
+    tools_mnv_hdr_pack(&(ptr_struct->mnv_hdr), ptr_buff + offset/8);
+
+}
+
+void tools_mnvi_unpack(struct tools_mnvi *ptr_struct, const u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=0;
+    tools_mnv_hdr_unpack(&(ptr_struct->mnv_hdr), ptr_buff + offset/8);
+
+}
+
+void tools_mnvi_print(const struct tools_mnvi *ptr_struct, FILE* file, int indent_level){
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "======== mnvi ========\n");
+    int i=0;
+    (void)i;(void)ptr_struct;
+    (void)file;
+    (void)indent_level;
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "mnv_hdr:\n");
+    tools_mnv_hdr_print(&(ptr_struct->mnv_hdr), file, indent_level + 1);
+
+}
+
+int tools_mnvi_size(){
+     return 8;
+}
+
+void tools_mnvi_dump(const struct tools_mnvi *ptr_struct, FILE* file) {
+    tools_mnvi_print(ptr_struct, file, 0);
+}
+
+void tools_mnva_pack(const struct tools_mnva *ptr_struct, u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=0;
+    tools_mnv_hdr_pack(&(ptr_struct->mnv_hdr), ptr_buff + offset/8);
+
+    for (i=0; i < 128; i++) {
+    offset=adb2c_calc_array_field_address(88, 8, i, 2048, 1);
+    adb2c_push_bits_to_buff(ptr_buff, offset, 8, (u_int32_t)ptr_struct->data[i]);
+    }
+
+}
+
+void tools_mnva_unpack(struct tools_mnva *ptr_struct, const u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=0;
+    tools_mnv_hdr_unpack(&(ptr_struct->mnv_hdr), ptr_buff + offset/8);
+
+    for (i=0; i < 128; i++) {
+    offset=adb2c_calc_array_field_address(88, 8, i, 2048, 1);
+    ptr_struct->data[i] = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 8);
+    }
+
+}
+
+void tools_mnva_print(const struct tools_mnva *ptr_struct, FILE* file, int indent_level){
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "======== mnva ========\n");
+    int i=0;
+    (void)i;(void)ptr_struct;
+    (void)file;
+    (void)indent_level;
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "mnv_hdr:\n");
+    tools_mnv_hdr_print(&(ptr_struct->mnv_hdr), file, indent_level + 1);
+
+    for (i=0; i < 128; i++) {
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "data[%3d]            : "UH_FMT"\n", i, ptr_struct->data[i]);
+    }
+
+}
+
+int tools_mnva_size(){
+     return 256;
+}
+
+void tools_mnva_dump(const struct tools_mnva *ptr_struct, FILE* file) {
+    tools_mnva_print(ptr_struct, file, 0);
+}
+
+void tools_sriov_pack(const struct tools_sriov *ptr_struct, u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=16;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 16, (u_int32_t)ptr_struct->total_vfs);
+
+    offset=0;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->sriov_en);
+
+}
+
+void tools_sriov_unpack(struct tools_sriov *ptr_struct, const u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=16;
+    ptr_struct->total_vfs = (u_int16_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 16);
+
+    offset=0;
+    ptr_struct->sriov_en = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+}
+
+void tools_sriov_print(const struct tools_sriov *ptr_struct, FILE* file, int indent_level){
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "======== sriov ========\n");
+    int i=0;
+    (void)i;(void)ptr_struct;
+    (void)file;
+    (void)indent_level;
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "total_vfs            : "UH_FMT"\n", ptr_struct->total_vfs);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "sriov_en             : "UH_FMT"\n", ptr_struct->sriov_en);
+
+}
+
+int tools_sriov_size(){
+     return 4;
+}
+
+void tools_sriov_dump(const struct tools_sriov *ptr_struct, FILE* file) {
+    tools_sriov_print(ptr_struct, file, 0);
+}
+
+void tools_bar_size_pack(const struct tools_bar_size *ptr_struct, u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=0;
+    adb2c_push_integer_to_buff(ptr_buff, offset, 4, (u_int64_t)ptr_struct->log_uar_bar_size);
+
+}
+
+void tools_bar_size_unpack(struct tools_bar_size *ptr_struct, const u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=0;
+    ptr_struct->log_uar_bar_size = (u_int32_t)adb2c_pop_integer_from_buff(ptr_buff, offset, 4);
+
+}
+
+void tools_bar_size_print(const struct tools_bar_size *ptr_struct, FILE* file, int indent_level){
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "======== bar_size ========\n");
+    int i=0;
+    (void)i;(void)ptr_struct;
+    (void)file;
+    (void)indent_level;
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "log_uar_bar_size     : "U32H_FMT"\n", ptr_struct->log_uar_bar_size);
+
+}
+
+int tools_bar_size_size(){
+     return 4;
+}
+
+void tools_bar_size_dump(const struct tools_bar_size *ptr_struct, FILE* file) {
+    tools_bar_size_print(ptr_struct, file, 0);
+}
+
+void tools_vpi_settings_pack(const struct tools_vpi_settings *ptr_struct, u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=30;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 2, (u_int32_t)ptr_struct->network_link_type);
+
+}
+
+void tools_vpi_settings_unpack(struct tools_vpi_settings *ptr_struct, const u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=30;
+    ptr_struct->network_link_type = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 2);
+
+}
+
+void tools_vpi_settings_print(const struct tools_vpi_settings *ptr_struct, FILE* file, int indent_level){
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "======== vpi_settings ========\n");
+    int i=0;
+    (void)i;(void)ptr_struct;
+    (void)file;
+    (void)indent_level;
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "network_link_type    : "UH_FMT"\n", ptr_struct->network_link_type);
+
+}
+
+int tools_vpi_settings_size(){
+     return 4;
+}
+
+void tools_vpi_settings_dump(const struct tools_vpi_settings *ptr_struct, FILE* file) {
+    tools_vpi_settings_print(ptr_struct, file, 0);
+}
+
+void tools_wol_pack(const struct tools_wol *ptr_struct, u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=22;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->reserved0);
+
+    offset=21;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->en_wol_magic);
+
+    offset=20;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->reserved1);
+
+    offset=19;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->reserved2);
+
+    offset=18;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->reserved3);
+
+    offset=17;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->reserved4);
+
+    offset=16;
+    adb2c_push_bits_to_buff(ptr_buff, offset, 1, (u_int32_t)ptr_struct->reserved5);
+
+}
+
+void tools_wol_unpack(struct tools_wol *ptr_struct, const u_int8_t* ptr_buff){
+    u_int32_t offset;
+    int i=0;
+    (void)offset;
+    (void)i;
+    (void)ptr_struct;
+    (void)ptr_buff;
+
+    offset=22;
+    ptr_struct->reserved0 = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+    offset=21;
+    ptr_struct->en_wol_magic = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+    offset=20;
+    ptr_struct->reserved1 = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+    offset=19;
+    ptr_struct->reserved2 = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+    offset=18;
+    ptr_struct->reserved3 = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+    offset=17;
+    ptr_struct->reserved4 = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+    offset=16;
+    ptr_struct->reserved5 = (u_int8_t)adb2c_pop_bits_from_buff(ptr_buff, offset, 1);
+
+}
+
+void tools_wol_print(const struct tools_wol *ptr_struct, FILE* file, int indent_level){
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "======== wol ========\n");
+    int i=0;
+    (void)i;(void)ptr_struct;
+    (void)file;
+    (void)indent_level;
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "reserved0   : "UH_FMT"\n", ptr_struct->reserved0);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "en_wol_magic         : "UH_FMT"\n", ptr_struct->en_wol_magic);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "reserved1           : "UH_FMT"\n", ptr_struct->reserved1);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "reserved2            : "UH_FMT"\n", ptr_struct->reserved2);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "reserved3            : "UH_FMT"\n", ptr_struct->reserved3);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "reserved4            : "UH_FMT"\n", ptr_struct->reserved4);
+
+    adb2c_add_indentation(file, indent_level);
+    fprintf(file, "reserved5           : "UH_FMT"\n", ptr_struct->reserved5);
+
+}
+
+int tools_wol_size(){
+     return 8;
+}
+
+void tools_wol_dump(const struct tools_wol *ptr_struct, FILE* file) {
+    tools_wol_print(ptr_struct, file, 0);
+}
+
diff --git a/tools_layouts/tools_layouts.h b/tools_layouts/tools_layouts.h
new file mode 100644 (file)
index 0000000..e1d3ced
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/***
+ *** This file was generated at "2014-03-11 10:10:14"
+ *** by:
+ ***    > /mswg/release/eat_me/last_release/adabe_plugins/adb2c/adb2pack.py --input adb/tools/tools.adb --file-prefix tools --prefix tools_
+ ***    and modified to fit the needs of mstflint.
+ ***/
+#ifndef TOOLS_LAYOUTS_H
+#define TOOLS_LAYOUTS_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "adb_to_c_utils.h"
+
+/* Description -   */
+/* Size in bytes - 8 */
+struct tools_mnv_hdr {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+    /* Description - Tlv type */
+    /* 0.0 - 0.15 */
+     u_int16_t type;
+    /* Description - size of tlv data in dwords (not including header) */
+    /* 0.18 - 0.29 */
+     u_int16_t length;
+/*---------------- DWORD[1] (Offset 0x4) ----------------*/
+    /* Description - Type Modifier. E.G.: Port number when the config is port related */
+    /* 4.16 - 4.23 */
+     u_int8_t type_mod;
+    /* Description - Shadow: i.e if set the Fw will not update the tlv immediately but wait for a command */
+    /* 4.24 - 4.24 */
+     u_int8_t shadow;
+    /* Description - Pad count: for non dword alligned tlvs */
+    /* 4.25 - 4.26 */
+     u_int8_t pad_cnt;
+    /* Description - Data version can be set by caller or left as 0. */
+    /* 4.28 - 8.31 */
+     u_int8_t version;
+};
+
+/* Description -   */
+/* Size in bytes - 8 */
+struct tools_mnvia {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+    /* Description -  */
+    /* 0.0 - 8.31 */
+     struct tools_mnv_hdr mnv_hdr;
+};
+
+/* Description -   */
+/* Size in bytes - 8 */
+struct tools_mnvi {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+    /* Description -  */
+    /* 0.0 - 8.31 */
+     struct tools_mnv_hdr mnv_hdr;
+};
+
+/* Description -   */
+/* Size in bytes - 256 */
+struct tools_mnva {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+    /* Description -  */
+    /* 0.0 - 8.31 */
+     struct tools_mnv_hdr mnv_hdr;
+/*---------------- DWORD[2] (Offset 0x8) ----------------*/
+    /* Description -  */
+    /* 8.24 - 136.23 */
+     u_int8_t data[128];
+};
+
+/* Description -   */
+/* Size in bytes - 4 */
+struct tools_sriov {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+    /* Description - The total number of VFs that can be supported. */
+    /* 0.0 - 0.15 */
+     u_int16_t total_vfs;
+    /* Description - 1 when SRIOV is enabled: SRIOV capability will appear on the PCI configuration header. */
+    /* 0.31 - 4.31 */
+     u_int8_t sriov_en;
+};
+
+/* Description -   */
+/* Size in bytes - 4 */
+struct tools_bar_size {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+    /* Description - Base 2 log of the size of the physical function\92s first BAR, in MBs. E.g. for 8MB the value is 3. */
+    /* 0.0 - 4.31 */
+     u_int32_t log_uar_bar_size;
+};
+
+/* Description -   */
+/* Size in bytes - 4 */
+struct tools_vpi_settings {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+    /* Description - Default link type:
+0  InfiniBand
+1  Ethernet
+ */
+    /* 0.0 - 0.1 */
+     u_int8_t network_link_type;
+};
+
+/* Description -   */
+/* Size in bytes - 8 */
+struct tools_wol {
+/*---------------- DWORD[0] (Offset 0x0) ----------------*/
+    /* 0.9 - 0.9 */
+     u_int8_t reserved0;
+    /* Description - Enable Wake on magic packet */
+    /* 0.10 - 0.10 */
+     u_int8_t en_wol_magic;
+    /* 0.11 - 0.11 */
+     u_int8_t reserved1;
+    /* 0.12 - 0.12 */
+     u_int8_t reserved2;
+    /* 0.13 - 0.13 */
+     u_int8_t reserved3;
+    /* 0.14 - 0.14 */
+     u_int8_t reserved4;
+    /* 0.15 - 0.15 */
+     u_int8_t reserved5;
+};
+/*---------------- DWORD[8] (Offset 0x20) ----------------*/
+/*================= PACK/UNPACK/PRINT FUNCTIONS ======================*/
+
+/* mnv_hdr */
+void tools_mnv_hdr_pack(const struct tools_mnv_hdr *ptr_struct, u_int8_t* ptr_buff);
+void tools_mnv_hdr_unpack(struct tools_mnv_hdr *ptr_struct, const u_int8_t* ptr_buff);
+void tools_mnv_hdr_print(const struct tools_mnv_hdr *ptr_struct, FILE* file, int indent_level);
+int tools_mnv_hdr_size();
+#define TOOLS_MNV_HDR_SIZE    (0x8)
+void tools_mnv_hdr_dump(const struct tools_mnv_hdr *ptr_struct, FILE* file);
+/* mnvia */
+void tools_mnvia_pack(const struct tools_mnvia *ptr_struct, u_int8_t* ptr_buff);
+void tools_mnvia_unpack(struct tools_mnvia *ptr_struct, const u_int8_t* ptr_buff);
+void tools_mnvia_print(const struct tools_mnvia *ptr_struct, FILE* file, int indent_level);
+int tools_mnvia_size();
+#define TOOLS_MNVIA_SIZE    (0x8)
+void tools_mnvia_dump(const struct tools_mnvia *ptr_struct, FILE* file);
+/* mnvi */
+void tools_mnvi_pack(const struct tools_mnvi *ptr_struct, u_int8_t* ptr_buff);
+void tools_mnvi_unpack(struct tools_mnvi *ptr_struct, const u_int8_t* ptr_buff);
+void tools_mnvi_print(const struct tools_mnvi *ptr_struct, FILE* file, int indent_level);
+int tools_mnvi_size();
+#define TOOLS_MNVI_SIZE    (0x8)
+void tools_mnvi_dump(const struct tools_mnvi *ptr_struct, FILE* file);
+/* mnva */
+void tools_mnva_pack(const struct tools_mnva *ptr_struct, u_int8_t* ptr_buff);
+void tools_mnva_unpack(struct tools_mnva *ptr_struct, const u_int8_t* ptr_buff);
+void tools_mnva_print(const struct tools_mnva *ptr_struct, FILE* file, int indent_level);
+int tools_mnva_size();
+#define TOOLS_MNVA_SIZE    (0x100)
+void tools_mnva_dump(const struct tools_mnva *ptr_struct, FILE* file);
+/* sriov */
+void tools_sriov_pack(const struct tools_sriov *ptr_struct, u_int8_t* ptr_buff);
+void tools_sriov_unpack(struct tools_sriov *ptr_struct, const u_int8_t* ptr_buff);
+void tools_sriov_print(const struct tools_sriov *ptr_struct, FILE* file, int indent_level);
+int tools_sriov_size();
+#define TOOLS_SRIOV_SIZE    (0x4)
+void tools_sriov_dump(const struct tools_sriov *ptr_struct, FILE* file);
+/* bar_size */
+void tools_bar_size_pack(const struct tools_bar_size *ptr_struct, u_int8_t* ptr_buff);
+void tools_bar_size_unpack(struct tools_bar_size *ptr_struct, const u_int8_t* ptr_buff);
+void tools_bar_size_print(const struct tools_bar_size *ptr_struct, FILE* file, int indent_level);
+int tools_bar_size_size();
+#define TOOLS_BAR_SIZE_SIZE    (0x4)
+void tools_bar_size_dump(const struct tools_bar_size *ptr_struct, FILE* file);
+/* vpi_settings */
+void tools_vpi_settings_pack(const struct tools_vpi_settings *ptr_struct, u_int8_t* ptr_buff);
+void tools_vpi_settings_unpack(struct tools_vpi_settings *ptr_struct, const u_int8_t* ptr_buff);
+void tools_vpi_settings_print(const struct tools_vpi_settings *ptr_struct, FILE* file, int indent_level);
+int tools_vpi_settings_size();
+#define TOOLS_VPI_SETTINGS_SIZE    (0x4)
+void tools_vpi_settings_dump(const struct tools_vpi_settings *ptr_struct, FILE* file);
+/* wol */
+void tools_wol_pack(const struct tools_wol *ptr_struct, u_int8_t* ptr_buff);
+void tools_wol_unpack(struct tools_wol *ptr_struct, const u_int8_t* ptr_buff);
+void tools_wol_print(const struct tools_wol *ptr_struct, FILE* file, int indent_level);
+int tools_wol_size();
+#define TOOLS_WOL_SIZE    (0x8)
+void tools_wol_dump(const struct tools_wol *ptr_struct, FILE* file);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TOOLS_LAYOUTS_H