Blob Blame History Raw
Upstream commit a42a086b8d682ab8dfbc4666cf6b9c8a5ee23a77
Author: Robert Moore <Robert.Moore@intel.com>
Date: Mon, 16 Oct 2017 10:42:49 -0700
Subject: [PATCH] ACPI 6.0A: Changes to the NFIT ACPI table

Adds a new subtable.
---
 source/common/dmtable.c        |  1 +
 source/common/dmtbdump.c       |  5 +++
 source/common/dmtbinfo.c       | 14 +++++++
 source/compiler/dttable2.c     |  7 +++-
 source/compiler/dttemplate.h   | 10 +++--
 source/include/acdisasm.h      |  1 +
 source/include/actbl1.h        | 72 +++++++++++++++++++++++++++++++++-
 source/tools/acpisrc/astable.c |  2 +
 8 files changed, 105 insertions(+), 7 deletions(-)

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