From: John Powell <john.pow...@arm.com>

Tests that SMBIOS3 table is properly accessible from UEFI and
that it is in the correct memory region.

Change-Id: I113ead8183f02886e0facded0ed2ad4e213677d8
Signed-off-by: John Powell <john.pow...@arm.com>
---
 uefi-sct/SctPkg/CommonGenFramework.sh              |   3 +
 uefi-sct/SctPkg/Config/Data/Category.ini           |   7 +
 .../EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.c     |  61 ++++++
 .../EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.h     |  66 ++++++
 .../SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTest.inf   |  84 ++++++++
 .../BlackBoxTest/SbbrSmbiosBBTestFunction.c        | 222 +++++++++++++++++++++
 .../BlackBoxTest/SbbrSmbiosBBTestFunction.h        |  69 +++++++
 .../SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.c | 181 +++++++++++++++++
 .../SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.h |  90 +++++++++
 uefi-sct/SctPkg/UEFI/SBBR_SCT.dsc                  |   5 +
 10 files changed, 788 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestFunction.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestFunction.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.h

diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh 
b/uefi-sct/SctPkg/CommonGenFramework.sh
index 7058111..8e7c7ca 100755
--- a/uefi-sct/SctPkg/CommonGenFramework.sh
+++ b/uefi-sct/SctPkg/CommonGenFramework.sh
@@ -370,6 +370,9 @@ then
     # Check if EFI Specification Version is 2.5 or greater
     cp $ProcessorType/EfiSpecVerLvlBBTest.efi                  
$Framework/Test/ > NUL
 
+    # SMBIOS Requirements on UEFI - SBBR v1.0 5.1.1
+    cp $ProcessorType/SbbrSmbiosBBTest.efi                     
$Framework/Test/ > NUL
+
     # Runtime Services Tests - SBBR v1.0 Appendix B
     cp $ProcessorType/VariableServicesBBTest.efi               
$Framework/Test/ > NUL
     cp $ProcessorType/TimeServicesBBTest.efi                   
$Framework/Test/ > NUL
diff --git a/uefi-sct/SctPkg/Config/Data/Category.ini 
b/uefi-sct/SctPkg/Config/Data/Category.ini
index 17ca639..66b2112 100644
--- a/uefi-sct/SctPkg/Config/Data/Category.ini
+++ b/uefi-sct/SctPkg/Config/Data/Category.ini
@@ -96,6 +96,13 @@ Description   = Checks that UEFI protocols required by ARM 
SBBR are present.
 
 [Category Data]
 Revision      = 0x00010000
+CategoryGuid  = 852e92eb-d7aa-4d61-84ef-d32dc5d545ec
+InterfaceGuid = 71652D04-BF38-434A-BCB8-6547D7FD8384
+Name          = GenericTest\SbbrSmbios
+Description   = Checks that SMBIOS on UEFI is implemented correctly.
+
+[Category Data]
+Revision      = 0x00010000
 CategoryGuid  = D84A6430-99F5-4660-8454-6E4C896A7E51
 InterfaceGuid = 71652D04-BF38-434a-BCB8-6547D7FD8384
 Name          = GenericTest\SbbrSysEnvConfig
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.c 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.c
new file mode 100644
index 0000000..5a685f6
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.c
@@ -0,0 +1,61 @@
+/*++
+  The material contained herein is not a license, either
+  expressly or impliedly, to any intellectual property owned
+  or controlled by any of the authors or developers of this
+  material or to any contribution thereto. The material
+  contained herein is provided on an "AS IS" basis and, to the
+  maximum extent permitted by applicable law, this information
+  is provided AS IS AND WITH ALL FAULTS, and the authors and
+  developers of this material hereby disclaim all other
+  warranties and conditions, either express, implied or
+  statutory, including, but not limited to, any (if any)
+  implied warranties, duties or conditions of merchantability,
+  of fitness for a particular purpose, of accuracy or
+  completeness of responses, of results, of workmanlike
+  effort, of lack of viruses and of lack of negligence, all
+  with regard to this material and any contribution thereto.
+  Designers must not rely on the absence or characteristics of
+  any features or instructions marked "reserved" or
+  "undefined." The Unified EFI Forum, Inc. reserves any
+  features or instructions so marked for future definition and
+  shall have no responsibility whatsoever for conflicts or
+  incompatibilities arising from future changes to them. ALSO,
+  THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
+  QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR
+  NON-INFRINGEMENT WITH REGARD TO THE TEST SUITE AND ANY
+  CONTRIBUTION THERETO.
+
+  IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THIS MATERIAL OR
+  ANY CONTRIBUTION THERETO BE LIABLE TO ANY OTHER PARTY FOR
+  THE COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST
+  PROFITS, LOSS OF USE, LOSS OF DATA, OR ANY INCIDENTAL,
+  CONSEQUENTIAL, DIRECT, INDIRECT, OR SPECIAL DAMAGES WHETHER
+  UNDER CONTRACT, TORT, WARRANTY, OR OTHERWISE, ARISING IN ANY
+  WAY OUT OF THIS OR ANY OTHER AGREEMENT RELATING TO THIS
+  DOCUMENT, WHETHER OR NOT SUCH PARTY HAD ADVANCE NOTICE OF
+  THE POSSIBILITY OF SUCH DAMAGES.
+
+  Copyright 2006 - 2016 Unified EFI, Inc. All
+  Rights Reserved, subject to all existing rights in all
+  matters included within this Test Suite, to which United
+  EFI, Inc. makes no claim of right.
+
+  Copyright (c) 2016, ARM LTD. All rights reserved.
+
+--*/
+/*++
+
+Module Name:
+
+  Guid.c
+
+Abstract:
+
+  Global variable assignments for GUIDs used in test assertions.
+
+--*/
+
+#include "Efi.h"
+#include "Guid.h"
+
+EFI_GUID gSbbrSmbiosAssertion001Guid = SBBRSMBIOS_ASSERTION_001_GUID;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.h
new file mode 100644
index 0000000..967be4d
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/Guid.h
@@ -0,0 +1,66 @@
+/*++
+  The material contained herein is not a license, either
+  expressly or impliedly, to any intellectual property owned
+  or controlled by any of the authors or developers of this
+  material or to any contribution thereto. The material
+  contained herein is provided on an "AS IS" basis and, to the
+  maximum extent permitted by applicable law, this information
+  is provided AS IS AND WITH ALL FAULTS, and the authors and
+  developers of this material hereby disclaim all other
+  warranties and conditions, either express, implied or
+  statutory, including, but not limited to, any (if any)
+  implied warranties, duties or conditions of merchantability,
+  of fitness for a particular purpose, of accuracy or
+  completeness of responses, of results, of workmanlike
+  effort, of lack of viruses and of lack of negligence, all
+  with regard to this material and any contribution thereto.
+  Designers must not rely on the absence or characteristics of
+  any features or instructions marked "reserved" or
+  "undefined." The Unified EFI Forum, Inc. reserves any
+  features or instructions so marked for future definition and
+  shall have no responsibility whatsoever for conflicts or
+  incompatibilities arising from future changes to them. ALSO,
+  THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
+  QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR
+  NON-INFRINGEMENT WITH REGARD TO THE TEST SUITE AND ANY
+  CONTRIBUTION THERETO.
+
+  IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THIS MATERIAL OR
+  ANY CONTRIBUTION THERETO BE LIABLE TO ANY OTHER PARTY FOR
+  THE COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST
+  PROFITS, LOSS OF USE, LOSS OF DATA, OR ANY INCIDENTAL,
+  CONSEQUENTIAL, DIRECT, INDIRECT, OR SPECIAL DAMAGES WHETHER
+  UNDER CONTRACT, TORT, WARRANTY, OR OTHERWISE, ARISING IN ANY
+  WAY OUT OF THIS OR ANY OTHER AGREEMENT RELATING TO THIS
+  DOCUMENT, WHETHER OR NOT SUCH PARTY HAD ADVANCE NOTICE OF
+  THE POSSIBILITY OF SUCH DAMAGES.
+
+  Copyright 2006 - 2016 Unified EFI, Inc. All
+  Rights Reserved, subject to all existing rights in all
+  matters included within this Test Suite, to which United
+  EFI, Inc. makes no claim of right.
+
+  Copyright (c) 2016, ARM LTD. All rights reserved.
+
+--*/
+/*++
+
+Module Name:
+
+  Guid.h
+
+Abstract:
+
+  Definitions for GUIDs used in test assertions.
+
+--*/
+
+#ifndef _SBBRSMBIOS_GUID_H_
+#define _SBBRSMBIOS_GUID_H_
+
+#define SBBRSMBIOS_ASSERTION_001_GUID \
+  { 0xed2399ae, 0x416e, 0x46c6, {0xac, 0xa2, 0xd9, 0xb1, 0xcf, 0x99, 0x75, 
0xcd }}
+
+extern EFI_GUID gSbbrSmbiosAssertion001Guid;
+
+#endif /* _SBBRSMBIOS_GUID_H_ */
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTest.inf
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTest.inf
new file mode 100644
index 0000000..91c013f
--- /dev/null
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTest.inf
@@ -0,0 +1,84 @@
+#
+# The material contained herein is not a license, either
+# expressly or impliedly, to any intellectual property owned
+# or controlled by any of the authors or developers of this
+# material or to any contribution thereto. The material
+# contained herein is provided on an "AS IS" basis and, to the
+# maximum extent permitted by applicable law, this information
+# is provided AS IS AND WITH ALL FAULTS, and the authors and
+# developers of this material hereby disclaim all other
+# warranties and conditions, either express, implied or
+# statutory, including, but not limited to, any (if any)
+# implied warranties, duties or conditions of merchantability,
+# of fitness for a particular purpose, of accuracy or
+# completeness of responses, of results, of workmanlike
+# effort, of lack of viruses and of lack of negligence, all
+# with regard to this material and any contribution thereto.
+# Designers must not rely on the absence or characteristics of
+# any features or instructions marked "reserved" or
+# "undefined." The Unified EFI Forum, Inc. reserves any
+# features or instructions so marked for future definition and
+# shall have no responsibility whatsoever for conflicts or
+# incompatibilities arising from future changes to them. ALSO,
+# THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
+# QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR
+# NON-INFRINGEMENT WITH REGARD TO THE TEST SUITE AND ANY
+# CONTRIBUTION THERETO.
+#
+# IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THIS MATERIAL OR
+# ANY CONTRIBUTION THERETO BE LIABLE TO ANY OTHER PARTY FOR
+# THE COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST
+# PROFITS, LOSS OF USE, LOSS OF DATA, OR ANY INCIDENTAL,
+# CONSEQUENTIAL, DIRECT, INDIRECT, OR SPECIAL DAMAGES WHETHER
+# UNDER CONTRACT, TORT, WARRANTY, OR OTHERWISE, ARISING IN ANY
+# WAY OUT OF THIS OR ANY OTHER AGREEMENT RELATING TO THIS
+# DOCUMENT, WHETHER OR NOT SUCH PARTY HAD ADVANCE NOTICE OF
+# THE POSSIBILITY OF SUCH DAMAGES.
+#
+# Copyright 2006 - 2016 Unified EFI, Inc. All
+# Rights Reserved, subject to all existing rights in all
+# matters included within this Test Suite, to which United
+# EFI, Inc. makes no claim of right.
+#
+# Copyright (c) 2016, ARM LTD. All rights reserved.
+#
+#
+#/*++
+#
+# Module Name:
+#
+#   SbbrSmbiosBBTest.inf
+#
+# Abstract:
+#
+#   Component description file for SbbrSmbios tests.
+#
+#--*/
+
+[Defines]
+  INF_VERSION          = 0x00010019
+  BASE_NAME            = SbbrSmbiosBBTest
+  FILE_GUID            = 04a5d449-9c54-4937-8b83-142103adb759
+  MODULE_TYPE          = UEFI_DRIVER
+  VERSION_STRING       = 1.0
+  ENTRY_POINT          = InitializeBBTestSbbrSmbios
+
+[Sources.common]
+  Guid.c
+  SbbrSmbiosBBTestFunction.c
+  SbbrSmbiosBBTestMain.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  SctPkg/SctPkg.dec
+  SctPkg/UEFI/UEFI.dec
+
+[LibraryClasses]
+  EfiTestLib
+  SctLib
+  UefiDriverEntryPoint
+
+[Protocols]
+
+[Guids]
+  gEfiSmbios3TableGuid
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestFunction.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestFunction.c
new file mode 100644
index 0000000..7dca5ef
--- /dev/null
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestFunction.c
@@ -0,0 +1,222 @@
+/*++
+  The material contained herein is not a license, either
+  expressly or impliedly, to any intellectual property owned
+  or controlled by any of the authors or developers of this
+  material or to any contribution thereto. The material
+  contained herein is provided on an "AS IS" basis and, to the
+  maximum extent permitted by applicable law, this information
+  is provided AS IS AND WITH ALL FAULTS, and the authors and
+  developers of this material hereby disclaim all other
+  warranties and conditions, either express, implied or
+  statutory, including, but not limited to, any (if any)
+  implied warranties, duties or conditions of merchantability,
+  of fitness for a particular purpose, of accuracy or
+  completeness of responses, of results, of workmanlike
+  effort, of lack of viruses and of lack of negligence, all
+  with regard to this material and any contribution thereto.
+  Designers must not rely on the absence or characteristics of
+  any features or instructions marked "reserved" or
+  "undefined." The Unified EFI Forum, Inc. reserves any
+  features or instructions so marked for future definition and
+  shall have no responsibility whatsoever for conflicts or
+  incompatibilities arising from future changes to them. ALSO,
+  THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
+  QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR
+  NON-INFRINGEMENT WITH REGARD TO THE TEST SUITE AND ANY
+  CONTRIBUTION THERETO.
+
+  IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THIS MATERIAL OR
+  ANY CONTRIBUTION THERETO BE LIABLE TO ANY OTHER PARTY FOR
+  THE COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST
+  PROFITS, LOSS OF USE, LOSS OF DATA, OR ANY INCIDENTAL,
+  CONSEQUENTIAL, DIRECT, INDIRECT, OR SPECIAL DAMAGES WHETHER
+  UNDER CONTRACT, TORT, WARRANTY, OR OTHERWISE, ARISING IN ANY
+  WAY OUT OF THIS OR ANY OTHER AGREEMENT RELATING TO THIS
+  DOCUMENT, WHETHER OR NOT SUCH PARTY HAD ADVANCE NOTICE OF
+  THE POSSIBILITY OF SUCH DAMAGES.
+
+  Copyright 2006 - 2016 Unified EFI, Inc. All
+  Rights Reserved, subject to all existing rights in all
+  matters included within this Test Suite, to which United
+  EFI, Inc. makes no claim of right.
+
+  Copyright (c) 2016, ARM LTD. All rights reserved.
+
+--*/
+/*++
+
+Module Name:
+
+  SbbrSmbiosBBTestFunction.c
+
+Abstract:
+
+  Test case function definitions for SbbrSmbios.
+
+--*/
+
+#include "SbbrSmbiosBBTestMain.h"
+#include "SbbrSmbiosBBTestFunction.h"
+#include "SctLib.h"
+#include "Guid.h"
+#include <IndustryStandard/SmBios.h>
+#include <Library/EfiTestLib.h>
+
+/**
+ *  Entrypoint for UefiSmbios Test.
+ *  @param This a pointer of EFI_BB_TEST_PROTOCOL.
+ *  @param ClientInterface a pointer to the interface to be tested.
+ *  @param TestLevel test "thoroughness" control.
+ *  @param SupportHandle a handle containing protocols required.
+ *  @return EFI_SUCCESS Finish the test successfully.
+ */
+
+EFI_STATUS
+BBTestUefiSmbiosTest (
+  IN EFI_BB_TEST_PROTOCOL       *This,
+  IN VOID                       *ClientInterface,
+  IN EFI_TEST_LEVEL             TestLevel,
+  IN EFI_HANDLE                 SupportHandle
+  )
+{
+  EFI_STANDARD_TEST_LIBRARY_PROTOCOL  *StandardLib;
+  EFI_STATUS                          Status;
+  SMBIOS_TABLE_3_0_ENTRY_POINT        *SmbiosTable;
+  UINTN                               MemoryMapSize;
+  VOID                                *MemoryMap;
+  EFI_MEMORY_DESCRIPTOR               *MemoryMapDescriptor;
+  UINTN                               MapKey;
+  UINTN                               DescriptorSize;
+  UINT32                              DescriptorVersion;
+  UINT32                              i;
+  UINT64                              EndAddress;
+
+  //
+  // Get the Standard Library Interface
+  //
+  Status = gtBS->HandleProtocol (
+                   SupportHandle,
+                   &gEfiStandardTestLibraryGuid,
+                   (VOID **) &StandardLib
+                   );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Looking for SMBIOS table
+  //
+  Status = SctGetSystemConfigurationTable (
+              &gEfiSmbios3TableGuid,
+              (VOID **)&SmbiosTable
+              );
+  if (EFI_ERROR(Status)) {
+    StandardLib->RecordAssertion (
+                StandardLib,
+                EFI_TEST_ASSERTION_FAILED,
+                gSbbrSmbiosAssertion001Guid,
+                L"UefiSmbios",
+                L"%a:%d - SMBIOS30 Table Not Found",
+                __FILE__,
+                __LINE__
+                );
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Checking SMBIOS table version
+  //
+  if (SmbiosTable->MajorVersion != SBBRSMBIOS_MAJOR_VERSION) {
+    StandardLib->RecordAssertion (
+                StandardLib,
+                EFI_TEST_ASSERTION_FAILED,
+                gSbbrSmbiosAssertion001Guid,
+                L"UefiSmbios",
+                L"%a:%d - SMBIOS30 table invalid version. %d",
+                __FILE__,
+                __LINE__,
+                SmbiosTable->MajorVersion
+                );
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Getting Memory Map
+  //
+  Status = SbbrAllocAndGetMemoryMap (
+              &MemoryMapSize,
+              &MemoryMap,
+              &MapKey,
+              &DescriptorSize,
+              &DescriptorVersion
+              );
+  if (EFI_ERROR (Status)) {
+    StandardLib->RecordAssertion (
+                StandardLib,
+                EFI_TEST_ASSERTION_FAILED,
+                gTestGenericFailureGuid,
+                L"MemoryMap",
+                L"%a:%d - Could not retrieve memory map. 0x%X",
+                __FILE__,
+                __LINE__,
+                Status
+                );
+    return EFI_NOT_FOUND;
+  }
+
+  //
+  // Looping through memory map descriptors to find the one containing SMBIOS 
table
+  //
+  for (i = 0; i < MemoryMapSize / DescriptorSize; i++) {
+    MemoryMapDescriptor = (EFI_MEMORY_DESCRIPTOR *)(MemoryMap + (i * 
DescriptorSize));
+    EndAddress = MemoryMapDescriptor->PhysicalStart + 
(MemoryMapDescriptor->NumberOfPages * EFI_PAGE_SIZE);
+    if ( (SmbiosTable->TableAddress >= MemoryMapDescriptor->PhysicalStart) &&
+         ((SmbiosTable->TableAddress + SmbiosTable->TableMaximumSize) < 
EndAddress))
+    {
+      //
+      // Memory region containing SMBIOS table found
+      //
+      if (MemoryMapDescriptor->Type != EfiRuntimeServicesData) {
+        StandardLib->RecordAssertion (
+                    StandardLib,
+                    EFI_TEST_ASSERTION_FAILED,
+                    gSbbrSmbiosAssertion001Guid,
+                    L"UefiSmbios",
+                    L"%a:%d - Wrong SMBIOS30 Memory Type. 0x%X",
+                    __FILE__,
+                    __LINE__,
+                    MemoryMapDescriptor->Type
+                    );
+      } else {
+        StandardLib->RecordAssertion (
+                    StandardLib,
+                    EFI_TEST_ASSERTION_PASSED,
+                    gSbbrSmbiosAssertion001Guid,
+                    L"UefiSmbios",
+                    L"%a:%d",
+                    __FILE__,
+                    __LINE__
+                    );
+      }
+
+      SctFreePool(MemoryMap);
+      return EFI_SUCCESS;
+    }
+
+  }
+
+  //
+  // Memory region not found.
+  //
+  StandardLib->RecordAssertion (
+              StandardLib,
+              EFI_TEST_ASSERTION_FAILED,
+              gSbbrSmbiosAssertion001Guid,
+              L"UefiSmbios",
+              L"%a:%d - Memory region not found in map.",
+              __FILE__,
+              __LINE__
+              );
+  SctFreePool(MemoryMap);
+  return EFI_SUCCESS;
+}
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestFunction.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestFunction.h
new file mode 100644
index 0000000..1de882c
--- /dev/null
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestFunction.h
@@ -0,0 +1,69 @@
+/*++
+  The material contained herein is not a license, either
+  expressly or impliedly, to any intellectual property owned
+  or controlled by any of the authors or developers of this
+  material or to any contribution thereto. The material
+  contained herein is provided on an "AS IS" basis and, to the
+  maximum extent permitted by applicable law, this information
+  is provided AS IS AND WITH ALL FAULTS, and the authors and
+  developers of this material hereby disclaim all other
+  warranties and conditions, either express, implied or
+  statutory, including, but not limited to, any (if any)
+  implied warranties, duties or conditions of merchantability,
+  of fitness for a particular purpose, of accuracy or
+  completeness of responses, of results, of workmanlike
+  effort, of lack of viruses and of lack of negligence, all
+  with regard to this material and any contribution thereto.
+  Designers must not rely on the absence or characteristics of
+  any features or instructions marked "reserved" or
+  "undefined." The Unified EFI Forum, Inc. reserves any
+  features or instructions so marked for future definition and
+  shall have no responsibility whatsoever for conflicts or
+  incompatibilities arising from future changes to them. ALSO,
+  THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
+  QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR
+  NON-INFRINGEMENT WITH REGARD TO THE TEST SUITE AND ANY
+  CONTRIBUTION THERETO.
+
+  IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THIS MATERIAL OR
+  ANY CONTRIBUTION THERETO BE LIABLE TO ANY OTHER PARTY FOR
+  THE COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST
+  PROFITS, LOSS OF USE, LOSS OF DATA, OR ANY INCIDENTAL,
+  CONSEQUENTIAL, DIRECT, INDIRECT, OR SPECIAL DAMAGES WHETHER
+  UNDER CONTRACT, TORT, WARRANTY, OR OTHERWISE, ARISING IN ANY
+  WAY OUT OF THIS OR ANY OTHER AGREEMENT RELATING TO THIS
+  DOCUMENT, WHETHER OR NOT SUCH PARTY HAD ADVANCE NOTICE OF
+  THE POSSIBILITY OF SUCH DAMAGES.
+
+  Copyright 2006 - 2016 Unified EFI, Inc. All
+  Rights Reserved, subject to all existing rights in all
+  matters included within this Test Suite, to which United
+  EFI, Inc. makes no claim of right.
+
+  Copyright (c) 2016, ARM LTD. All rights reserved.
+
+--*/
+/*++
+
+Module Name:
+
+  SbbrSmbiosBBTestFunction.h
+
+Abstract:
+
+  Contains definitions and prototypes for test case functions.
+
+--*/
+
+#ifndef _SBBRSMBIOS_BB_TEST_FUNCTION_H_
+#define _SBBRSMBIOS_BB_TEST_FUNCTION_H_
+
+EFI_STATUS
+BBTestUefiSmbiosTest (
+  IN EFI_BB_TEST_PROTOCOL       *This,
+  IN VOID                       *ClientInterface,
+  IN EFI_TEST_LEVEL             TestLevel,
+  IN EFI_HANDLE                 SupportHandle
+  );
+
+#endif /* _SBBRSMBIOS_BB_TEST_FUNCTION_H_ */
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.c
new file mode 100644
index 0000000..d6ff5a0
--- /dev/null
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.c
@@ -0,0 +1,181 @@
+/*++
+  The material contained herein is not a license, either
+  expressly or impliedly, to any intellectual property owned
+  or controlled by any of the authors or developers of this
+  material or to any contribution thereto. The material
+  contained herein is provided on an "AS IS" basis and, to the
+  maximum extent permitted by applicable law, this information
+  is provided AS IS AND WITH ALL FAULTS, and the authors and
+  developers of this material hereby disclaim all other
+  warranties and conditions, either express, implied or
+  statutory, including, but not limited to, any (if any)
+  implied warranties, duties or conditions of merchantability,
+  of fitness for a particular purpose, of accuracy or
+  completeness of responses, of results, of workmanlike
+  effort, of lack of viruses and of lack of negligence, all
+  with regard to this material and any contribution thereto.
+  Designers must not rely on the absence or characteristics of
+  any features or instructions marked "reserved" or
+  "undefined." The Unified EFI Forum, Inc. reserves any
+  features or instructions so marked for future definition and
+  shall have no responsibility whatsoever for conflicts or
+  incompatibilities arising from future changes to them. ALSO,
+  THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
+  QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR
+  NON-INFRINGEMENT WITH REGARD TO THE TEST SUITE AND ANY
+  CONTRIBUTION THERETO.
+
+  IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THIS MATERIAL OR
+  ANY CONTRIBUTION THERETO BE LIABLE TO ANY OTHER PARTY FOR
+  THE COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST
+  PROFITS, LOSS OF USE, LOSS OF DATA, OR ANY INCIDENTAL,
+  CONSEQUENTIAL, DIRECT, INDIRECT, OR SPECIAL DAMAGES WHETHER
+  UNDER CONTRACT, TORT, WARRANTY, OR OTHERWISE, ARISING IN ANY
+  WAY OUT OF THIS OR ANY OTHER AGREEMENT RELATING TO THIS
+  DOCUMENT, WHETHER OR NOT SUCH PARTY HAD ADVANCE NOTICE OF
+  THE POSSIBILITY OF SUCH DAMAGES.
+
+  Copyright 2006 - 2016 Unified EFI, Inc. All
+  Rights Reserved, subject to all existing rights in all
+  matters included within this Test Suite, to which United
+  EFI, Inc. makes no claim of right.
+
+  Copyright (c) 2016, ARM LTD. All rights reserved.
+
+--*/
+/*++
+
+Module Name:
+
+  SbbrSmbiosBBTestMain.c
+
+Abstract:
+
+  Test driver for SbbrSmbios tests.
+
+--*/
+
+#include "SctLib.h"
+#include "SbbrSmbiosBBTestMain.h"
+#include "SbbrSmbiosBBTestFunction.h"
+
+EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = {
+  SBBRSMBIOS_TEST_REVISION,
+  SBBRSMBIOS_TEST_GUID,
+  L"SbbrSmbios Tests",
+  L"Checks that SMBIOS on UEFI is implemented correctly."
+};
+
+EFI_GUID gSupportProtocolGuid1[2] = {
+  EFI_STANDARD_TEST_LIBRARY_GUID,
+  EFI_NULL_GUID
+};
+
+EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
+  {
+    SBBRSMBIOS_UEFISMBIOS_GUID,
+    L"UefiSmbios",
+    L"Checks that the SMBIOS3 table is accessible though its GUID and that it 
has the correct memory region settings.",
+    EFI_TEST_LEVEL_DEFAULT,
+    gSupportProtocolGuid1,
+    EFI_TEST_CASE_AUTO,
+    BBTestUefiSmbiosTest
+  },
+  EFI_NULL_GUID
+};
+
+EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;
+
+/**
+ *  The driver's Unload function
+ *  @param  ImageHandle The test driver image handle
+ *  @return EFI_SUCCESS Indicates the interface was Uninstalled
+*/
+EFI_STATUS
+BBTestSbbrSmbiosUnload (
+  IN EFI_HANDLE       ImageHandle
+  )
+{
+  return EfiUninstallAndFreeBBTestInterface (
+              ImageHandle,
+              gBBTestProtocolInterface
+           );
+}
+
+/**
+ *  Creates/installs the BlackBox Interface and eminating Entry Point
+ *  node list.
+ *  @param  ImageHandle The test driver image handle
+ *  @param  SystemTable Pointer to System Table
+ *  @return EFI_SUCCESS Indicates the interface was installed
+ *  @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not 
be allocated
+ *  @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value.
+ */
+EFI_STATUS
+InitializeBBTestSbbrSmbios (
+  IN EFI_HANDLE           ImageHandle,
+  IN EFI_SYSTEM_TABLE     *SystemTable
+  )
+{
+
+  EfiInitializeTestLib (ImageHandle, SystemTable);
+  SctInitializeLib (ImageHandle, SystemTable);
+
+  return EfiInitAndInstallBBTestInterface (
+              &ImageHandle,
+              &gBBTestProtocolField,
+              gBBTestEntryField,
+              BBTestSbbrSmbiosUnload,
+              &gBBTestProtocolInterface
+              );
+}
+
+/**
+ * SbbrGetMemoryMap function used by test cases.
+ */
+EFI_STATUS
+SbbrAllocAndGetMemoryMap (
+  UINTN                               *MemoryMapSize,
+  VOID                                **MemoryMap,
+  UINTN                               *MapKey,
+  UINTN                               *DescriptorSize,
+  UINT32                              *DescriptorVersion
+  )
+{
+  EFI_STATUS                          Status;
+
+  //
+  // Getting memory map
+  //
+  do {
+    *MemoryMapSize = 0;
+    // First call with a size of 0 so we can find out how big the memory map 
is.
+    Status = gtBS->GetMemoryMap (
+                MemoryMapSize,
+                *MemoryMap,
+                MapKey,
+                DescriptorSize,
+                DescriptorVersion
+                );
+    if (Status != EFI_BUFFER_TOO_SMALL){
+      return EFI_NOT_FOUND;
+    }
+    *MemoryMap = SctAllocatePool(*MemoryMapSize);
+    if (*MemoryMap == NULL) {
+      return EFI_OUT_OF_RESOURCES;
+    }
+    // Second call with our newly allocated buffer should work properly.
+    Status = gtBS->GetMemoryMap (
+                MemoryMapSize,
+                *MemoryMap,
+                MapKey,
+                DescriptorSize,
+                DescriptorVersion
+                );
+    if (EFI_ERROR (Status)) {
+      SctFreePool(*MemoryMap);
+    }
+  } while (EFI_ERROR (Status));
+
+  return EFI_SUCCESS;
+}
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.h
new file mode 100644
index 0000000..8884bdd
--- /dev/null
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTestMain.h
@@ -0,0 +1,90 @@
+/*++
+  The material contained herein is not a license, either
+  expressly or impliedly, to any intellectual property owned
+  or controlled by any of the authors or developers of this
+  material or to any contribution thereto. The material
+  contained herein is provided on an "AS IS" basis and, to the
+  maximum extent permitted by applicable law, this information
+  is provided AS IS AND WITH ALL FAULTS, and the authors and
+  developers of this material hereby disclaim all other
+  warranties and conditions, either express, implied or
+  statutory, including, but not limited to, any (if any)
+  implied warranties, duties or conditions of merchantability,
+  of fitness for a particular purpose, of accuracy or
+  completeness of responses, of results, of workmanlike
+  effort, of lack of viruses and of lack of negligence, all
+  with regard to this material and any contribution thereto.
+  Designers must not rely on the absence or characteristics of
+  any features or instructions marked "reserved" or
+  "undefined." The Unified EFI Forum, Inc. reserves any
+  features or instructions so marked for future definition and
+  shall have no responsibility whatsoever for conflicts or
+  incompatibilities arising from future changes to them. ALSO,
+  THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
+  QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR
+  NON-INFRINGEMENT WITH REGARD TO THE TEST SUITE AND ANY
+  CONTRIBUTION THERETO.
+
+  IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THIS MATERIAL OR
+  ANY CONTRIBUTION THERETO BE LIABLE TO ANY OTHER PARTY FOR
+  THE COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST
+  PROFITS, LOSS OF USE, LOSS OF DATA, OR ANY INCIDENTAL,
+  CONSEQUENTIAL, DIRECT, INDIRECT, OR SPECIAL DAMAGES WHETHER
+  UNDER CONTRACT, TORT, WARRANTY, OR OTHERWISE, ARISING IN ANY
+  WAY OUT OF THIS OR ANY OTHER AGREEMENT RELATING TO THIS
+  DOCUMENT, WHETHER OR NOT SUCH PARTY HAD ADVANCE NOTICE OF
+  THE POSSIBILITY OF SUCH DAMAGES.
+
+  Copyright 2006 - 2016 Unified EFI, Inc. All
+  Rights Reserved, subject to all existing rights in all
+  matters included within this Test Suite, to which United
+  EFI, Inc. makes no claim of right.
+
+  Copyright (c) 2016, ARM LTD. All rights reserved.
+
+--*/
+/*++
+
+Module Name:
+
+  SbbrSmbiosBBTestMain.h
+
+Abstract:
+
+  Contains definitions for test information and test GUIDs.
+
+--*/
+
+#ifndef _SBBRSMBIOS_TEST_MAIN_H_
+#define _SBBRSMBIOS_TEST_MAIN_H_
+
+#include "Efi.h"
+#include "Guid.h"
+#include <Library/EfiTestLib.h>
+
+#define SBBRSMBIOS_TEST_REVISION 0x00010000
+
+#define SBBRSMBIOS_TEST_GUID     \
+  { 0x852e92eb, 0xd7aa, 0x4d61, {0x84, 0xef, 0xd3, 0x2d, 0xc5, 0xd5, 0x45, 
0xec }}
+
+#define SBBRSMBIOS_MAJOR_VERSION 3
+
+EFI_STATUS
+InitializeBBTestSbbrSmbios (
+  IN EFI_HANDLE           ImageHandle,
+  IN EFI_SYSTEM_TABLE     *SystemTable
+  );
+
+EFI_STATUS
+BBTestSbbrSmbiosUnload (
+  IN EFI_HANDLE       ImageHandle
+  );
+
+//
+// Entry GUIDs
+//
+
+#define SBBRSMBIOS_UEFISMBIOS_GUID \
+  { 0x71b32221, 0x8b9d, 0x4b41, {0x8b, 0x04, 0xee, 0x6d, 0x18, 0xa6, 0xe5, 
0x25 }}
+
+#endif /* _SBBRSMBIOS_TEST_MAIN_H_ */
diff --git a/uefi-sct/SctPkg/UEFI/SBBR_SCT.dsc 
b/uefi-sct/SctPkg/UEFI/SBBR_SCT.dsc
index 931b8da..bf010c9 100644
--- a/uefi-sct/SctPkg/UEFI/SBBR_SCT.dsc
+++ b/uefi-sct/SctPkg/UEFI/SBBR_SCT.dsc
@@ -258,6 +258,11 @@ 
SctPkg/TestCase/UEFI/EFI/BootServices/SbbrBootServices/BlackBoxTest/SbbrBootServ
 # End of UEFI Boot Services - SBBR v1.0 3.4
 
 #
+# SMBIOS Requirements on UEFI - SBBR v1.0 5.1.1
+#
+SctPkg/TestCase/UEFI/EFI/Generic/SbbrSmbios/BlackBoxTest/SbbrSmbiosBBTest.inf
+
+#
 # Required UEFI Runtime Services Tests - SBBR v1.0 Appendix B
 #
 ##  1. EFI_GET_TIME
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to