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