Blame SOURCES/add-nfit-subtable7.patch

896836
Upstream commit a42a086b8d682ab8dfbc4666cf6b9c8a5ee23a77
896836
Author: Robert Moore <Robert.Moore@intel.com>
896836
Date: Mon, 16 Oct 2017 10:42:49 -0700
896836
Subject: [PATCH] ACPI 6.0A: Changes to the NFIT ACPI table
896836
896836
Adds a new subtable.
896836
---
896836
 source/common/dmtable.c        |  1 +
896836
 source/common/dmtbdump.c       |  5 +++
896836
 source/common/dmtbinfo.c       | 14 +++++++
896836
 source/compiler/dttable2.c     |  7 +++-
896836
 source/compiler/dttemplate.h   | 10 +++--
896836
 source/include/acdisasm.h      |  1 +
896836
 source/include/actbl1.h        | 72 +++++++++++++++++++++++++++++++++-
896836
 source/tools/acpisrc/astable.c |  2 +
896836
 8 files changed, 105 insertions(+), 7 deletions(-)
896836
896836
diff --git a/source/common/dmtable.c b/source/common/dmtable.c
896836
index 07d27faf7..60951732b 100644
896836
--- a/source/common/dmtable.c
896836
+++ b/source/common/dmtable.c
896836
@@ -239,6 +239,7 @@ static const char           *AcpiDmNfitSubnames[] =
896836
     "NVDIMM Control Region",            /* ACPI_NFIT_TYPE_CONTROL_REGION */
896836
     "NVDIMM Block Data Window Region",  /* ACPI_NFIT_TYPE_DATA_REGION */
896836
     "Flush Hint Address",               /* ACPI_NFIT_TYPE_FLUSH_ADDRESS */
896836
+    "Platform Capabilities",            /* ACPI_NFIT_TYPE_CAPABILITIES */
896836
     "Unknown Subtable Type"             /* Reserved */
896836
 };
896836
 
896836
diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c
896836
index 0f0697e3d..1ef91c2df 100644
896836
--- a/source/common/dmtbdump.c
896836
+++ b/source/common/dmtbdump.c
896836
@@ -2748,6 +2748,11 @@ AcpiDmDumpNfit (
896836
             FieldOffset = sizeof (ACPI_NFIT_FLUSH_ADDRESS) - sizeof (UINT64);
896836
             break;
896836
 
896836
+        case ACPI_NFIT_TYPE_CAPABILITIES:    /* ACPI 6.0A */
896836
+
896836
+            InfoTable = AcpiDmTableInfoNfit7;
896836
+            break;
896836
+
896836
         default:
896836
             AcpiOsPrintf ("\n**** Unknown NFIT subtable type 0x%X\n",
896836
                 SubTable->Type);
896836
diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c
896836
index 97de36067..bccb986fb 100644
896836
--- a/source/common/dmtbinfo.c
896836
+++ b/source/common/dmtbinfo.c
896836
@@ -216,6 +216,7 @@
896836
 #define ACPI_NFIT4_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_NFIT_CONTROL_REGION,f)
896836
 #define ACPI_NFIT5_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_NFIT_DATA_REGION,f)
896836
 #define ACPI_NFIT6_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_NFIT_FLUSH_ADDRESS,f)
896836
+#define ACPI_NFIT7_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_NFIT_CAPABILITIES,f)
896836
 #define ACPI_PCCT0_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_PCCT_SUBSPACE,f)
896836
 #define ACPI_PCCT1_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_PCCT_HW_REDUCED,f)
896836
 #define ACPI_PCCT2_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_PCCT_HW_REDUCED_TYPE2,f)
896836
@@ -278,6 +279,7 @@
896836
 #define ACPI_NFIT0_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_NFIT_SYSTEM_ADDRESS,f,o)
896836
 #define ACPI_NFIT1_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_NFIT_MEMORY_MAP,f,o)
896836
 #define ACPI_NFIT4_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_NFIT_CONTROL_REGION,f,o)
896836
+#define ACPI_NFIT7_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_NFIT_CAPABILITIES,f,o)
896836
 #define ACPI_PCCT_FLAG_OFFSET(f,o)      ACPI_FLAG_OFFSET (ACPI_TABLE_PCCT,f,o)
896836
 #define ACPI_PCCT1_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_PCCT_HW_REDUCED,f,o)
896836
 #define ACPI_PCCT2_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_PCCT_HW_REDUCED_TYPE2,f,o)
896836
@@ -2281,6 +2283,18 @@ ACPI_DMTABLE_INFO           AcpiDmTableInfoNfit6a[] =
896836
     ACPI_DMT_TERMINATOR
896836
 };
896836
 
896836
+ACPI_DMTABLE_INFO           AcpiDmTableInfoNfit7[] =
896836
+{
896836
+    {ACPI_DMT_UINT8,    ACPI_NFIT7_OFFSET (HighestCapability),      "Highest Capability", 0},
896836
+    {ACPI_DMT_UINT24,   ACPI_NFIT7_OFFSET (Reserved[0]),            "Reserved", 0},
896836
+    {ACPI_DMT_UINT32,   ACPI_NFIT7_OFFSET (Capabilities),           "Capabilities (decoded below)", DT_FLAG},
896836
+    {ACPI_DMT_FLAG0,    ACPI_NFIT7_FLAG_OFFSET (Capabilities,0),    "Cache Flush to NVDIMM", 0},
896836
+    {ACPI_DMT_FLAG1,    ACPI_NFIT7_FLAG_OFFSET (Capabilities,0),    "Memory Flush to MVDIMM", 0},
896836
+    {ACPI_DMT_FLAG2,    ACPI_NFIT7_FLAG_OFFSET (Capabilities,0),    "Memory Mirroring", 0},
896836
+    {ACPI_DMT_UINT32,   ACPI_NFIT7_OFFSET (Reserved2),              "Reserved", 0},
896836
+    ACPI_DMT_TERMINATOR
896836
+};
896836
+
896836
 
896836
 /*******************************************************************************
896836
  *
896836
diff --git a/source/compiler/dttable2.c b/source/compiler/dttable2.c
896836
index 172354cde..db79bac7a 100644
896836
--- a/source/compiler/dttable2.c
896836
+++ b/source/compiler/dttable2.c
896836
@@ -590,6 +590,11 @@ DtCompileNfit (
896836
             InfoTable = AcpiDmTableInfoNfit6;
896836
             break;
896836
 
896836
+        case ACPI_NFIT_TYPE_CAPABILITIES:
896836
+
896836
+            InfoTable = AcpiDmTableInfoNfit7;
896836
+            break;
896836
+
896836
         default:
896836
 
896836
             DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT");
896836
@@ -633,7 +638,6 @@ DtCompileNfit (
896836
             }
896836
 
896836
             Interleave->LineCount = Count;
896836
-            DtPopSubtable ();
896836
             break;
896836
 
896836
         case ACPI_NFIT_TYPE_SMBIOS:
896836
@@ -679,7 +684,6 @@ DtCompileNfit (
896836
             }
896836
 
896836
             Hint->HintCount = (UINT16) Count;
896836
-            DtPopSubtable ();
896836
             break;
896836
 
896836
         default:
896836
diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h
896836
index d541154bb..4c77afc16 100644
896836
--- a/source/compiler/dttemplate.h
896836
+++ b/source/compiler/dttemplate.h
896836
@@ -780,11 +780,11 @@ const unsigned char TemplateMsct[] =
896836
 
896836
 const unsigned char TemplateNfit[] =
896836
 {
896836
-    0x4E,0x46,0x49,0x54,0x70,0x01,0x00,0x00,  /* 00000000    "NFITp..." */
896836
-    0x01,0x53,0x49,0x4E,0x54,0x45,0x4C,0x20,  /* 00000008    ".SINTEL " */
896836
+    0x4E,0x46,0x49,0x54,0x80,0x01,0x00,0x00,  /* 00000000    "NFIT...." */
896836
+    0x01,0x07,0x49,0x4E,0x54,0x45,0x4C,0x20,  /* 00000008    "..INTEL " */
896836
     0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65,  /* 00000010    "Template" */
896836
     0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
896836
-    0x10,0x04,0x15,0x20,0x00,0x00,0x00,0x00,  /* 00000020    "... ...." */
896836
+    0x29,0x09,0x17,0x20,0x00,0x00,0x00,0x00,  /* 00000020    ").. ...." */
896836
     0x00,0x00,0x38,0x00,0x01,0x00,0x00,0x00,  /* 00000028    "..8....." */
896836
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000030    "........" */
896836
     0x30,0x05,0xAF,0x91,0x86,0x5D,0x0E,0x47,  /* 00000038    "0....].G" */
896836
@@ -825,7 +825,9 @@ const unsigned char TemplateNfit[] =
896836
     0x06,0x00,0x20,0x00,0x01,0x00,0x00,0x00,  /* 00000150    ".. ....." */
896836
     0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000158    "........" */
896836
     0x00,0x00,0x00,0x18,0x04,0x00,0x00,0x00,  /* 00000160    "........" */
896836
-    0x00,0x00,0x00,0x18,0x06,0x00,0x00,0x00   /* 00000168    "........" */
896836
+    0x00,0x00,0x00,0x18,0x06,0x00,0x00,0x00,  /* 00000168    "........" */
896836
+    0x07,0x00,0x10,0x00,0x00,0x00,0x00,0x00,  /* 00000170    "........" */
896836
+    0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00   /* 00000178    "........" */
896836
 };
896836
 
896836
 const unsigned char TemplateMtmr[] =
896836
diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h
896836
index 0c465602d..d8ed7168d 100644
896836
--- a/source/include/acdisasm.h
896836
+++ b/source/include/acdisasm.h
896836
@@ -375,6 +375,7 @@ extern ACPI_DMTABLE_INFO        AcpiDmTableInfoNfit4[];
896836
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoNfit5[];
896836
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoNfit6[];
896836
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoNfit6a[];
896836
+extern ACPI_DMTABLE_INFO        AcpiDmTableInfoNfit7[];
896836
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoPmtt[];
896836
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoPmtt0[];
896836
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoPmtt1[];
896836
diff --git a/source/include/actbl1.h b/source/include/actbl1.h
896836
index db409bb79..0ca869909 100644
896836
--- a/source/include/actbl1.h
896836
+++ b/source/include/actbl1.h
896836
@@ -1185,7 +1185,8 @@ enum AcpiNfitType
896836
     ACPI_NFIT_TYPE_CONTROL_REGION       = 4,
896836
     ACPI_NFIT_TYPE_DATA_REGION          = 5,
896836
     ACPI_NFIT_TYPE_FLUSH_ADDRESS        = 6,
896836
-    ACPI_NFIT_TYPE_RESERVED             = 7     /* 7 and greater are reserved */
896836
+    ACPI_NFIT_TYPE_CAPABILITIES         = 7,
896836
+    ACPI_NFIT_TYPE_RESERVED             = 8     /* 8 and greater are reserved */
896836
 };
896836
 
896836
 /*
896836
@@ -1338,6 +1339,75 @@ typedef struct acpi_nfit_flush_address
896836
 } ACPI_NFIT_FLUSH_ADDRESS;
896836
 
896836
 
896836
+/* 7: Platform Capabilities Structure */
896836
+
896836
+typedef struct acpi_nfit_capabilities
896836
+{
896836
+    ACPI_NFIT_HEADER        Header;
896836
+    UINT8                   HighestCapability;
896836
+    UINT8                   Reserved[3];       /* Reserved, must be zero */
896836
+    UINT32                  Capabilities;
896836
+    UINT32                  Reserved2;
896836
+
896836
+} ACPI_NFIT_CAPABILITIES;
896836
+
896836
+/* Capabilities Flags */
896836
+
896836
+#define ACPI_NFIT_CAPABILITY_CACHE_FLUSH       (1)     /* 00: Cache Flush to NVDIMM capable */
896836
+#define ACPI_NFIT_CAPABILITY_MEM_FLUSH         (1<<1)  /* 01: Memory Flush to NVDIMM capable */
896836
+#define ACPI_NFIT_CAPABILITY_MEM_MIRRORING     (1<<2)  /* 02: Memory Mirroring capable */
896836
+
896836
+
896836
+/*
896836
+ * NFIT/DVDIMM device handle support - used as the _ADR for each NVDIMM
896836
+ */
896836
+typedef struct nfit_device_handle
896836
+{
896836
+    UINT32                  Handle;
896836
+
896836
+} NFIT_DEVICE_HANDLE;
896836
+
896836
+/* Device handle construction and extraction macros */
896836
+
896836
+#define ACPI_NFIT_DIMM_NUMBER_MASK              0x0000000F
896836
+#define ACPI_NFIT_CHANNEL_NUMBER_MASK           0x000000F0
896836
+#define ACPI_NFIT_MEMORY_ID_MASK                0x00000F00
896836
+#define ACPI_NFIT_SOCKET_ID_MASK                0x0000F000
896836
+#define ACPI_NFIT_NODE_ID_MASK                  0x0FFF0000
896836
+
896836
+#define ACPI_NFIT_DIMM_NUMBER_OFFSET            0
896836
+#define ACPI_NFIT_CHANNEL_NUMBER_OFFSET         4
896836
+#define ACPI_NFIT_MEMORY_ID_OFFSET              8
896836
+#define ACPI_NFIT_SOCKET_ID_OFFSET              12
896836
+#define ACPI_NFIT_NODE_ID_OFFSET                16
896836
+
896836
+/* Macro to construct a NFIT/NVDIMM device handle */
896836
+
896836
+#define ACPI_NFIT_BUILD_DEVICE_HANDLE(dimm, channel, memory, socket, node) \
896836
+    ((dimm)                                         | \
896836
+    ((channel) << ACPI_NFIT_CHANNEL_NUMBER_OFFSET)  | \
896836
+    ((memory)  << ACPI_NFIT_MEMORY_ID_OFFSET)       | \
896836
+    ((socket)  << ACPI_NFIT_SOCKET_ID_OFFSET)       | \
896836
+    ((node)    << ACPI_NFIT_NODE_ID_OFFSET))
896836
+
896836
+/* Macros to extract individual fields from a NFIT/NVDIMM device handle */
896836
+
896836
+#define ACPI_NFIT_GET_DIMM_NUMBER(handle) \
896836
+    ((handle) & ACPI_NFIT_DIMM_NUMBER_MASK)
896836
+
896836
+#define ACPI_NFIT_GET_CHANNEL_NUMBER(handle) \
896836
+    (((handle) & ACPI_NFIT_CHANNEL_NUMBER_MASK) >> ACPI_NFIT_CHANNEL_NUMBER_OFFSET)
896836
+
896836
+#define ACPI_NFIT_GET_MEMORY_ID(handle) \
896836
+    (((handle) & ACPI_NFIT_MEMORY_ID_MASK)      >> ACPI_NFIT_MEMORY_ID_OFFSET)
896836
+
896836
+#define ACPI_NFIT_GET_SOCKET_ID(handle) \
896836
+    (((handle) & ACPI_NFIT_SOCKET_ID_MASK)      >> ACPI_NFIT_SOCKET_ID_OFFSET)
896836
+
896836
+#define ACPI_NFIT_GET_NODE_ID(handle) \
896836
+    (((handle) & ACPI_NFIT_NODE_ID_MASK)        >> ACPI_NFIT_NODE_ID_OFFSET)
896836
+
896836
+
896836
 /*******************************************************************************
896836
  *
896836
  * SBST - Smart Battery Specification Table
896836
diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c
896836
index c4b023d81..51840dd90 100644
896836
--- a/source/tools/acpisrc/astable.c
896836
+++ b/source/tools/acpisrc/astable.c
896836
@@ -658,6 +658,8 @@ ACPI_TYPED_IDENTIFIER_TABLE           AcpiIdentifiers[] = {
896836
     {"ACPI_MPST_POWER_STATE",               SRC_TYPE_STRUCT},
896836
     {"ACPI_MCFG_ALLOCATION",                SRC_TYPE_STRUCT},
896836
     {"ACPI_MSCT_PROXIMITY",                 SRC_TYPE_STRUCT},
896836
+    {"ACPI_NFIT_CAPABILITIES",              SRC_TYPE_STRUCT},
896836
+    {"ACPI_NFIT_DEVICE_HANDLE",             SRC_TYPE_STRUCT},
896836
     {"ACPI_NFIT_HEADER",                    SRC_TYPE_STRUCT},
896836
     {"ACPI_NFIT_SYSTEM_ADDRESS",            SRC_TYPE_STRUCT},
896836
     {"ACPI_NFIT_MEMORY_MAP",                SRC_TYPE_STRUCT},
896836
-- 
896836
2.17.1
896836