Date   

Re: [edk2-platforms: PATCH v2 1/1] Platform/RPi3: Add Debian 10 installation in Systems.md

Leif Lindholm
 

Hi Pete,

On Wed, Aug 07, 2019 at 03:24:10PM +0100, Pete Batard wrote:
+Below are steps you can follow to install Debian 10 onto an SD card:
+* Partition the media as MBR and create a ~300 MB partition on it with MBR type `0x0e`.
+ __Note:__ Make sure that the partition scheme is MBR (not GPT) and the type `0x0e` (not
+ `0xef` for instance), as the ondie Broadcom bootloader supports neither the GPT scheme nor
ondie -> on-die (or on-SoC may be even more clear to civilians).
I think I'll use "on-CPU" then, as this should be even more explicit.
Works for me.

+ the ESP MBR type.
+* Set the partition as active/bootable. This is needed as the Debian partition manager can
+ not detect it as ESP otherwise, which we need for GRUB installation. If using `fdisk` on
+ Linux, you can use the `a` command to set a partition as active. On Windows, you can use
+ `DISKPART` and then type `active` after selecting the relevant disk and partition.
+* Format the partition as FAT. Here again you should make sure that you use FAT rather than
+ FAT32 else the Debian partition manager will not detect the partition as ESP. If you
+ are using Windows `DISKPART` then `format fs=fat quick` should do it. On Linux, `mkfs.vfat`
+ with the default options should do the same as long as the partition isn't too large.
It would be preferable if we could have an actual number here - the
12-bit, 16-bit and 32-bit fat size switchover points are known. I
assume it is the 32-bit breakpoint (2 or 4Gb?) we want to avoid?
The switchover point actually depends of the utility, since there is overlap
between 12, 16 and 32. But that's not actually a problem with diskpart on
Windows as 'fs=fat' does force FAT16 so you'll get an error if the partition
is too large and can only accommodate FAT32 (which should usually occur past
the 2 GB point).

In other words, the only potential issue here is with Linux' mkfs.vfat. But
there too we can add a switch (-F 16) to force FAT16, so I'll alter the
documentation to have that, plus a note that mentions that the partition
should be under 2 GB.
Sure, this is fine.

I'll also take this opportunity to stress out that the only reason we are
trying to force FAT16 here is because the Debian installer's partition
manager is very temperamental with regards to its detection of an ESP that
doesn't have either the relevant GUID for GPT or type 0xef for MBR, none of
which can be used on a Pi. There are actually cases where I have seen that
utility also detect a FAT32 MBR partition without type 0xef as an ESP.
Yeah, well. This is pretty much stacking ice cubes next to a furnace,
trying to create an ABI where there is none. Which is fine, because we
do need to provide documentation for non-experts - but this is also why
it needs to be precise, so we don't mislead experts.

However, I have found out that, in most cases, the presence of FAT32 vs
FAT16 acts as a switch to demote the partition from ESP, which is the reason
why the notes promote the use of FAT16 over FAT32. But as mentioned in the
additional notes however, it's still relatively easy to fix the ESP issue if
you use FAT32 and/or if the Debian partition manager fails to detect it as
ESP.
Sure. May be worth adding a forward-pointer to the additional notes
from here then?

Now, one can only wish that Broadcom had anticipated UEFI usage for their
hardcoded boot loader, as they'd only needed to have added 0xef, alongside
the other FAT based MBR partition types they recognize for this whole
annoyance to be avoided...
In my most optimistic hours, I sometimes dare to hope that the EBBR
explicitly stating these requirements will at some point in the future
start to make a difference.

I'll send a v3 when I get a chance.
Thanks!

Regards.

Leif


Re: [PATCH v4 12/35] OvmfPkg/XenPlatformPei: Grab RSDP from PVH guest start of day struct

Roger Pau Monné
 

On Mon, Jul 29, 2019 at 04:39:21PM +0100, Anthony PERARD wrote:
Check if there's a start of the day struct provided to PVH guest, save
the ACPI RSDP address for later.

This patch import import arch-x86/hvm/start_info.h from xen.git.
You seem to change the types when importing start_info.h, is that
absolutely necessary?

From my experience working with different projects when importing such
headers it's better to keep them verbatim, this makes importing future
versions from upstream easier.

I have a comment below, but it's more like a question.

diff --git a/OvmfPkg/XenPlatformPei/Xen.c b/OvmfPkg/XenPlatformPei/Xen.c
index 5c7d7ddc1c..b366139a0a 100644
--- a/OvmfPkg/XenPlatformPei/Xen.c
+++ b/OvmfPkg/XenPlatformPei/Xen.c
@@ -25,6 +25,7 @@
#include <IndustryStandard/E820.h>
#include <Library/ResourcePublicationLib.h>
#include <Library/MtrrLib.h>
+#include <IndustryStandard/Xen/arch-x86/hvm/start_info.h>

#include "Platform.h"
#include "Xen.h"
@@ -86,6 +87,7 @@ XenConnect (
UINT32 XenVersion;
EFI_XEN_OVMF_INFO *Info;
CHAR8 Sig[sizeof (Info->Signature) + 1];
+ UINT32 *PVHResetVectorData;

AsmCpuid (XenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL);
mXenInfo.HyperPages = AllocatePages (TransferPages);
@@ -121,6 +123,29 @@ XenConnect (
mXenHvmloaderInfo = NULL;
}

+ mXenInfo.RsdpPvh = NULL;
+
+ //
+ // Locate and use information from the start of day structure if we have
+ // booted via the PVH entry point.
+ //
+
+ PVHResetVectorData = (VOID *)(UINTN) PcdGet32 (PcdXenPvhStartOfDayStructPtr);
+ //
+ // That magic value is written in XenResetVector/Ia32/XenPVHMain.asm
+ //
+ if (PVHResetVectorData[1] == SIGNATURE_32 ('X', 'P', 'V', 'H')) {
+ struct hvm_start_info *HVMStartInfo;
+
+ HVMStartInfo = (VOID *)(UINTN) PVHResetVectorData[0];
+ if (HVMStartInfo->magic == XEN_HVM_START_MAGIC_VALUE) {
+ ASSERT (HVMStartInfo->rsdp_paddr != 0);
+ if (HVMStartInfo->rsdp_paddr != 0) {
+ mXenInfo.RsdpPvh = (VOID *)(UINTN)HVMStartInfo->rsdp_paddr;
I guess you can do this because OVMF has an identity map of virtual
addresses to physical addresses?

I wonder the size of such identity map, and whether you need to check
that the rsdp address is indeed inside of that region before
converting it to a pointer. The same would apply to
PcdXenPvhStartOfDayStructPtr, but that's likely safe because it's
always < 4GB, which I assume OVMF always has identity mapped?

Thanks, Roger.


Re: [PATCH v4 09/35] OvmfPkg/OvmfXen: use a TimerLib instance that depends only on the CPU

Roger Pau Monné
 

On Mon, Jul 29, 2019 at 04:39:18PM +0100, Anthony PERARD wrote:
The ACPI Timer isn't present in a PVH guest, but local APIC works on
both PVH and HVM.

Note that the use of SecPeiDxeTimerLibCpu might be an issue with a
driver of type DXE_RUNTIME_DRIVER. I've attempted to find out which of
the DXE_RUNTIME_DRIVER uses the TimerLib at runtime. I've done that by
replacing the TimerLib evaluation in
[LibraryClasses.common.DXE_RUNTIME_DRIVER] by a different one and
checking every module that uses it (with the --report-file=report
build option).

ResetSystemRuntimeDxe is calling the TimerLib API at runtime to do the
operation "EfiResetCold", so this may never complete if the OS have
disabled the Local APIC Timer.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
Signed-off-by: Anthony PERARD <anthony.perard@...>
Acked-by: Laszlo Ersek <lersek@...>
---

Notes:
v4:
- reworded the first sentence, use "not present" instead of "don't work".
Thanks, I'm afraid I cannot comment on the change itself, but the
comment message is accurate now :).

Roger.


Re: [edk2-platforms: PATCH v2 1/1] Platform/RPi3: Add Debian 10 installation in Systems.md

Pete Batard
 

Hi Leif,

On 2019.08.06 18:25, Leif Lindholm wrote:
Minor suggestions inline:
On Thu, Jul 25, 2019 at 04:22:48PM +0100, Pete Batard wrote:
This documents the installation of vanilla Debian 10.0 ARM64 (netinst),
which we validated for both Model B and Model B+.
Also fix an erroneous reference in an RPi3.fdf comment.

Signed-off-by: Pete Batard <@pbatard>
---
Platform/RaspberryPi/RPi3/RPi3.fdf | 2 +-
Platform/RaspberryPi/RPi3/Readme.md | 4 +-
Platform/RaspberryPi/RPi3/Systems.md | 124 +++++++++++++++++++-
3 files changed, 123 insertions(+), 7 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf b/Platform/RaspberryPi/RPi3/RPi3.fdf
index c7c3f7a2ab8c..c62d649834c7 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -300,7 +300,7 @@ [FV.FvMain]
INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/LogoDxe/LogoDxe.inf
#
- # FDT (GUID matches mRaspberryPiFfsFileGuid in RaspberryPiPlatformDxe)
+ # FDT (GUID matches gRaspberryPiFdtFileGuid in FdtDxe)
#
FILE FREEFORM = DF5DA223-1D27-47C3-8D1B-9A41B55A18BC {
SECTION RAW = Platform/RaspberryPi/$(PLATFORM_NAME)/DeviceTree/bcm2710-rpi-3-b.dtb
diff --git a/Platform/RaspberryPi/RPi3/Readme.md b/Platform/RaspberryPi/RPi3/Readme.md
index 624f3a8d287a..797da1bab4a9 100644
--- a/Platform/RaspberryPi/RPi3/Readme.md
+++ b/Platform/RaspberryPi/RPi3/Readme.md
@@ -18,8 +18,8 @@ Raspberry Pi is a trademark of the [Raspberry Pi Foundation](http://www.raspberr
This firmware, that has been validated to compile against the current
[edk2](https://github.com/tianocore/edk2)/[edk2-platforms](https://github.com/tianocore/edk2-platforms),
-should be able to boot Linux (SUSE, Ubuntu), NetBSD, FreeBSD as well as Windows 10 ARM64
-(full GUI version).
+should be able to boot Linux (Debian, Ubuntu, SUSE), NetBSD, FreeBSD as well as Windows
+10 ARM64 (full GUI version).
It also provides support for ATF ([Arm Trusted Platform](https://github.com/ARM-software/arm-trusted-firmware)).
diff --git a/Platform/RaspberryPi/RPi3/Systems.md b/Platform/RaspberryPi/RPi3/Systems.md
index f6410eb25f0d..4a0c6f3e4de3 100644
--- a/Platform/RaspberryPi/RPi3/Systems.md
+++ b/Platform/RaspberryPi/RPi3/Systems.md
@@ -1,5 +1,125 @@
# Tested Operating Systems
+## Debian
+
+[Debian 10](https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/) netinst has been
+tested and confirmed to work, both on the Model B and Model B+, including installation in
+either wired or wireless mode.
+
+Below are steps you can follow to install Debian 10 onto an SD card:
+* Partition the media as MBR and create a ~300 MB partition on it with MBR type `0x0e`.
+ __Note:__ Make sure that the partition scheme is MBR (not GPT) and the type `0x0e` (not
+ `0xef` for instance), as the ondie Broadcom bootloader supports neither the GPT scheme nor
ondie -> on-die (or on-SoC may be even more clear to civilians).
I think I'll use "on-CPU" then, as this should be even more explicit.

+ the ESP MBR type.
+* Set the partition as active/bootable. This is needed as the Debian partition manager can
+ not detect it as ESP otherwise, which we need for GRUB installation. If using `fdisk` on
+ Linux, you can use the `a` command to set a partition as active. On Windows, you can use
+ `DISKPART` and then type `active` after selecting the relevant disk and partition.
+* Format the partition as FAT. Here again you should make sure that you use FAT rather than
+ FAT32 else the Debian partition manager will not detect the partition as ESP. If you
+ are using Windows `DISKPART` then `format fs=fat quick` should do it. On Linux, `mkfs.vfat`
+ with the default options should do the same as long as the partition isn't too large.
It would be preferable if we could have an actual number here - the
12-bit, 16-bit and 32-bit fat size switchover points are known. I
assume it is the 32-bit breakpoint (2 or 4Gb?) we want to avoid?
The switchover point actually depends of the utility, since there is overlap between 12, 16 and 32. But that's not actually a problem with diskpart on Windows as 'fs=fat' does force FAT16 so you'll get an error if the partition is too large and can only accommodate FAT32 (which should usually occur past the 2 GB point).

In other words, the only potential issue here is with Linux' mkfs.vfat. But there too we can add a switch (-F 16) to force FAT16, so I'll alter the documentation to have that, plus a note that mentions that the partition should be under 2 GB.

I'll also take this opportunity to stress out that the only reason we are trying to force FAT16 here is because the Debian installer's partition manager is very temperamental with regards to its detection of an ESP that doesn't have either the relevant GUID for GPT or type 0xef for MBR, none of which can be used on a Pi. There are actually cases where I have seen that utility also detect a FAT32 MBR partition without type 0xef as an ESP. However, I have found out that, in most cases, the presence of FAT32 vs FAT16 acts as a switch to demote the partition from ESP, which is the reason why the notes promote the use of FAT16 over FAT32. But as mentioned in the additional notes however, it's still relatively easy to fix the ESP issue if you use FAT32 and/or if the Debian partition manager fails to detect it as ESP.

Now, one can only wish that Broadcom had anticipated UEFI usage for their hardcoded boot loader, as they'd only needed to have added 0xef, alongside the other FAT based MBR partition types they recognize for this whole annoyance to be avoided...

I'll send a v3 when I get a chance.

Regards,

/Pete

/
Leif

+* Copy the UEFI firmware files (`RPI_EFI.fd`, `bootcode.bin`, `fixup.dat` and `start.elf`)
+ as well as an appropriate `config.txt` onto the FAT partition. If needed you can download
+ the non UEFI binary files from https://github.com/raspberrypi/firmware/tree/master/boot.
+* (Optional) If you plan to install through WiFi, you will need to download relevant non-free
+ WLAN firmware binaries from your WLAN interface (`brcmfmac43430-sdio.txt` and
+ `brcmfmac43430-sdio.bin` for a Raspberry Pi 3 Model B, `brcmfmac43455-sdio.txt` and
+ `brcmfmac43455-sdio.bin` for a Raspberry Pi 3 Model B+). You may also want to obtain the
+ relevant `.clm_blob` (`brcmfmac43430-sdio.clm_blob` or `brcmfmac43455-sdio.clm_blob`),
+ though wireless networking should work even if you do not provide these files. Copy these
+ files either at the root of your FAT partition or into a `firmware/` directory there.
+* Download the latest `debian-##.#.#-arm64-netinst.iso` from
+ https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/
+* Extract the full content of the ISO onto the FAT partition you created.
+* Insert the media and power up the Raspberry Pi device.
+* On the GRUB menu select `Install` and let the Debian Installer process start.
+ __Note:__ In case anything goes wrong during the install process, you can use
+ <kbd>Alt</kbd>-<kbd>F4</kbd> to check the installation log.
+* Select your Language, Country and Keyboard and let the installer proceed until it reports
+ that `No Common CD-ROM drive was detected.`
+* On `Load CD-ROM drivers from removable media` select `No`.
+* On `Manually select a CD-ROM module and device` select `Yes`.
+* On `Module needed for accessing the CD-ROM` select `none`.
+* On `Device file for accessing the CD-ROM` type the following exactly:
+ ```
+ -t vfat -o rw /dev/mmcblk0p1
+ ```
+* (Optional) If you have copied the non-free WLAN firmware binaries, and plan to install
+ through wireless, you can let the installer select the firmware files. Please be mindful
+ that you may be asked multiple times as there are multiple files to provide.
+* If requested by the installer, set up your network by choosing the network interface you
+ want to use for installation and (optionally) your access point and credentials.
+* Go through the hostname, user/password set up and customize those as you see fit.
+* Let the installer continue until you get to the `Partition disks` screen. There, for
+ `Partitioning method` select `Manual`. You __should__ see something like this:
+ ```
+ MMC/SD card #1 (mmcblk0) - 16.0 GB SD 2WCGO
+ #1 primary 314.6 MB B K ESP
+ pri/log FREE SPACE
+ ```
+ In other words, the partition manager should already detect your existing partition as
+ `ESP`, with the `B` (bootable) and `K` (keep data) flags. If that is not the case, (e.g.
+ if it says `fat16` or `fat32` instead of `ESP`) then it probably means you either didn't
+ format the partition to FAT or you forgot to set the bootable flag. If that is the case,
+ refer to the _Additional Notes:_ below.
+* Select `FREE SPACE` &rarr; `Create a new partition` and create a `1 GB` primary `swap`
+ partition.
+* Select `FREE SPACE` &rarr; `Create a new partition` and allocate the rest to a primary
+ `ext4` root partition (mountpoint = `/`)
+* After doing the above, your partition report should look like this:
+ ```
+ MMC/SD card #1 (mmcblk0) - 16.0 GB SD 2WCGO
+ #1 primary 314.6 MB B K ESP
+ #2 primary 1.0 GB f swap swap
+ #3 primary 14.7 GB f ext4 /
+ ```
+* Select `Finish partitioning and write changes to disk` and then `Yes` and let the
+ installer continue with the base system installation.
+* After a while, the installer should produce a message that states:
+ ```
+ [!!] Configure the package manager
+
+ apt-configuration problem
+ An attempt to configure apt to install additional packages from the CD failed.
+ ```
+ This is a __benign__ message that you can safely ignore by selecting `Continue` (The
+ reason it is benign is we are running a net install and won't need to access the "CD-ROM"
+ files post install).
+* Once you have dimissed the message above, pick the mirror closest to your geographical
+ location and let the installer proceed with some more software installation.
+* Finally, at the `Software selection` screen, choose any additional software package you
+ wish to install. `Debian desktop environment` should work out of the box if you choose to
+ install it.
+* Let the process finalize the software and GRUB bootloader installation and, provided you
+ didn't run into the partition manager issue described above (installation partition not
+ seen as `ESP`) you can reboot your machine when prompted, which, once completed, should
+ bring you to your newly installed Debian environment.
+
+### Additional Notes for Debian
+
+The reason we use `-t vfat -o rw /dev/mmcblk0p1` for the source media (i.e. "CD-ROM" device)
+is because, whereas the first partition on the SD card is indeed `/dev/mmcblk0p1`, we also
+need to provide additional parameters for the `mount` command that the installer invokes
+behind the scenes. For instance, if we don't use `-t vfat`, then ISO-9660 is forced as the
+file system, and if we don't use `-o rw` then the partition will be mounted as read-only
+which then prevents the same partition from being remounted when locating the non-free
+firmware files or when setting up `/efi/boot`.
+
+With regards to fixing the partitioning if you don't see `B K ESP` when entering the
+partition manager, what you need to do is:
+* Before you create the additional partitions, select the first partition and change its
+ type to `ESP`. Note however that doing this will change the type of the partition to `0xef`
+ which is precisely what we're trying to avoid by having the partition manager already
+ detect it as ESP, as type `0xef` is __unbootable__ by the Broadcom CPU.
+* To fix this then, before you choose `Continue` on the `Installation complete` prompt you
+ need to open a new console (<kbd>Alt</kbd>-<kbd>F2</kbd>) and then type:
+ ```
+ chroot /target fdisk /dev/mmcblk0
+ ```
+ Then press <kbd>t</kbd>, <kbd>1</kbd>, <kbd>e</kbd> <kbd>w</kbd>, to reset the partition
+ to type `0x0e` (FAT16 LBA).
+
## Ubuntu
[Ubuntu 18.04 LTS](http://releases.ubuntu.com/18.04/) has been tested and confirmed to work,
@@ -35,10 +155,6 @@ Then, to have your changes applied run `update-grub` and reboot.
## Other Linux distributions
-* Debian ARM64 does not currently work, most likely due to missing required module support
- in its kernel. However its installation process works, so it may be possible to get it
- running with a custom kernel.
-
* OpenSUSE Leap 42.3 has been reported to work on Raspberry 3 Model B.
* Other ARM64 Linux releases, that support UEFI boot and have the required hardware support
--
2.21.0.windows.1


Re: [Patch 3/3] BaseTools/PatchCheck: Disable text conversion in 'git show'

Laszlo Ersek
 

On 08/06/19 00:01, Kinney, Michael D wrote:
Laszlo,

The context of this change is only to the PatchCheck.py tool.
and how that tool uses git show.

I agree with the summary of very flexible capabilities in git
to help developers review different types of files. All of
those settings that were added to support UNI files in UTF-16
file format were very valuable when we had to review the
text changes to those binary files. We should be using UTF-8
now, and we can even extend PatchCheck.py to flag an error if
a UNI file is in UTF-16 format.

I still prefer we make this change only to PatchCheck.py to
prevent false positives and print lines of text that can
not be found in a developer's working directory. I prefer
this one time change to PatchCheck.py instead of having to
update .gitattributes whenever the git show features are
extended to convert more binary files to text files.
More precisely, that would mean that you prefer this one time change to
having to update .gitattributes every time a new type of binary file is
introduced to edk2.

I can see merits in both approaches. From my side, I don't intend to
block this patch.

Acked-by: Laszlo Ersek <lersek@...>

Thanks
Laszlo

My expectation is that EDK II Maintainers need to review
if a binary file is ok or not for a repo. I would also be
ok with adding general rules to PatchCheck.py to generate
an error if a binary file is added/updated in one of the
text only repos (edk2, edk2-platforms) and not generate
an error if a binary file is added/updated in a repo that
supports binaries (edk-non-osi).

Best regards,

Mike


-----Original Message-----
From: devel@edk2.groups.io
[mailto:devel@edk2.groups.io] On Behalf Of Laszlo Ersek
Sent: Friday, August 2, 2019 4:58 PM
To: Justen, Jordan L <jordan.l.justen@...>;
Kinney, Michael D <michael.d.kinney@...>;
devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@...>; Gao, Liming
<liming.gao@...>
Subject: Re: [edk2-devel] [Patch 3/3]
BaseTools/PatchCheck: Disable text conversion in 'git
show'

On 08/02/19 20:29, Jordan Justen wrote:
First, I hope we don't add lots of large .pdf files
into the source
tree. I see two duplicated > 200k .pdf files in edk2,
which seems like
a waste of space in the edk2 tree.

BaseTools/Source/C/BrotliCompress/docs/brotli-
comparison-study-2015-09
-22.pdf
MdeModulePkg/Library/BrotliCustomDecompressLib/docs/bro
tli-comparison-
study-2015-09-22.pdf

Second, I'm not too sure about this change. It seems
like it might
have unintended consequences.

One thought I had is that it might break UTF-16
unicode files diffs,
but luckily I think we've pretty much gotten rid of
UTF-16 files at
this point.

I also wonder if adding a .pdf attribute like Laszlo
recommends for
.efi might be an alternative solution.

https://github.com/tianocore/tianocore.github.io/wiki/L
aszlo's-unkempt
-git-guide-for-edk2-contributors-and-
maintainers#contrib-09

We could actually add these setting in the git tree
in a
.gitattributes file, right? Has this been suggested?
I think Laszlo
documented this before we had converted edk2 to git.
This is a complex question.

There are files which are binary for all intents and
purposes, so you never want to see a "textualized"
version of them. Git can attempt recognizing these
files, but it can take hints too.

For these files, once they are safely classified as
"binary", it is a separate question whether you want a
changeset shown (or
email-formatted) for these files to contain base64-like
binary patches, or just a statement that "binary files
differ".

Then there are files that are binary, but can be
"textualized" for the purposes of diffing and even
merging. Automated UCS2<->UTF8 conversion is an
example, and I used that while edk2 still had UCS2-
encoded UNI files.

Some examples (not claiming this is going to be an
exhaustive list -- for that, see gitattributes(5)), to
be placed in .git/info/attributes (local clone only) or
.gitattributes (tracked in the repo):

*.efi -diff

This classifies *.efi as binary (turns off the
heuristics).

Consider gitattributes(5) -- excerpt:

diff
Unset
A path to which the diff attribute is
unset will
generate Binary files differ (or a
binary patch, if
binary patches are enabled).
Unspecified
A path to which the diff attribute is
unspecified first
gets its contents inspected, and if it
looks like text
and is smaller than
core.bigFileThreshold, it is
treated as text. Otherwise it would
generate Binary
files differ.

git-show will only report "binary files differ", unless
we pass --binary to it; in which case it will offer a
base64-like binary patch.
git-format-patch will produce that binary patch by
default, unless we pass --no-binary to it.


Another example, in .git/info/attributes or
.gitattributes:

*.uni diff=uni merge=uni

The manual says:

diff
String
Diff is shown using the specified diff
driver. Each
driver may specify one or more options,
as described in
the following section. The options for
the diff driver
"foo" are defined by the configuration
variables in the
"diff.foo" section of the Git config
file.

merge
String
3-way merge is performed using the
specified custom
merge driver. The built-in 3-way merge
driver can be
explicitly specified by asking for
"text" driver; the
built-in "take the current branch"
driver can be
requested with "binary".

Accordingly, from .git/config:

[diff "uni"]
textconv = iconv -f UCS-2 -t UTF-8
binary = true

[merge "uni"]
name = merge driver for UCS-2 encoded text files
driver = uni-merge %O %A %B

And my uni-merge script:

---------
#!/bin/bash

# Merge UCS-2 encoded text files.
# This is a git-merge driver. It will overwrite
"$MINE".
#
# Exit status:
# 0 -- no conflicts
# 1 -- conflicts
# 2 -- trouble

OLD="$1"
MINE="$2"
YOURS="$3"

# Set safe defaults for the trap handler.
OLD_UTF8=
MY_UTF8=
YOUR_UTF8=
NEW_UTF8=
EX=2

trap 'rm -f -- "$OLD_UTF8" "$MY_UTF8" "$YOUR_UTF8"
"$NEW_UTF8"; exit $EX' EXIT set -e -u -C

OLD_UTF8=$(mktemp)
iconv --from UCS-2 --to UTF-8 <"$OLD" >>"$OLD_UTF8"

MY_UTF8=$(mktemp)
iconv --from UCS-2 --to UTF-8 <"$MINE" >>"$MY_UTF8"

YOUR_UTF8=$(mktemp)
iconv --from UCS-2 --to UTF-8 <"$YOURS" >>"$YOUR_UTF8"

NEW_UTF8=$(mktemp)
set +e
diff3 --merge --label=mine --label=old --label=yours --
\
"$MY_UTF8" "$OLD_UTF8" "$YOUR_UTF8" >>"$NEW_UTF8"
DIFFRET=$?
set -e

if [ 0 -ne "$DIFFRET" ] && [ 1 -ne "$DIFFRET" ]; then
exit
fi

iconv --from UTF-8 --to UCS-2 <"$NEW_UTF8" >|"$MINE"
EX=$DIFFRET
---------

My understanding is that the "--no-textconv" option
would undo the "textconv" that I set under [diff
"uni"].

In other words, it tells git that, even if the
heuristics suggested
*some* conversion to text (I can't say what that would
be, in the general case), git should still treat the
file as binary. (At which point the --no-binary / --
binary options decide whether we get a base64-like
encoding, or just a message saying "binary files
differ").
Therefore I think (= agree with Jordan) that the effect
is the same as marking the affected file types in
.gitattributes as "-diff".

I guess the relevant question is scope. "--no-textconv"
doesn't require us to assign "-diff" to specific file
suffixes, such as *.pdf, *.efi, and so on. But, it also
doesn't allow us to specify *some* text conversions,
even if we wanted to (it would override & disable them,
such as my "iconv" conversion when diffing UCS2 encoded
UNI files).

Adding a .gitattributes file to the root of the
repository, and updating it whenever necessary (for
example when we add the first .pdf file, the first .efi
file...), is likely the best.

(

My recommendation at
<https://github.com/tianocore/tianocore.github.io/wiki/
Laszlo's-unkempt-git-guide-for-edk2-contributors-and-
maintainers#contrib-09>
may have targeted the local ".git/info/attributes" file
because people can have quite different opinions on how
git should act on various files. In theory, someone
having simplistic PDF files might even want:

In the attributes:

*.pdf diff=pdf

In the config:

[diff "pdf"]
textconv = sh -c 'pdftotext -- "$1" -' pdftotext-
wrapper
binary = true

("pdftotext" converts PDF to text, but its command line
is awkward -- the hyphen marking stdout must be
explicit, and must come as second operand. Hence the
wrapping into "sh" -- and then we need to spell out
$0 as well, for which I picked "pdftotext-wrapper". The
"--" separator is a safety measure against filenames
starting with "-", which could be mis-interpreted as
options. "--" terminates the option list and starts the
operand list.)

)

Thanks
Laszlo


On 2019-08-01 17:13:14, Michael D Kinney wrote:
https://bugzilla.tianocore.org/show_bug.cgi?id=2044

'git show' is used to extrat the patch contents for
analysis.
Add the flag '--no-textconv' to the 'git show'
command to disable the
conversion from some binary file types to text
content.

Without this change, binary files such as .pdf files
are converted to
text in the show command and PatchCheck complains
that the wrong line
endings are used in the patch.

Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <liming.gao@...>
Cc: Jordan Justen <jordan.l.justen@...>
Signed-off-by: Michael D Kinney
<michael.d.kinney@...>
---
BaseTools/Scripts/PatchCheck.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Scripts/PatchCheck.py
b/BaseTools/Scripts/PatchCheck.py index
6b07241bfe..2a4e6f603e 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -543,7 +543,7 @@ class CheckGitCommits:

def read_patch_from_git(self, commit):
# Run git to get the commit patch
- return self.run_git('show', '--
pretty=email', commit)
+ return self.run_git('show', '--
pretty=email',
+ '--no-textconv', commit)

def run_git(self, *args):
cmd = [ 'git' ]
--
2.21.0.windows.1


Re: Cancelled Event: TianoCore Design / Bug Triage - EMEA - Wednesday, 7 August 2019 #cal-cancelled

Stephano Cetola
 

No topics for discussion this week.

We will triage bugs in tomorrow's APAC meeting.

--S

On Wed, Aug 7, 2019 at 6:14 AM devel@edk2.groups.io Calendar
<devel@edk2.groups.io> wrote:

Cancelled: TianoCore Design / Bug Triage - EMEA

This event has been cancelled.

When:
Wednesday, 7 August 2019
8:00am to 9:00am
(UTC-07:00) America/Los Angeles

Where:
https://zoom.us/j/695893389

Organizer:
@intelstephano

Description:

Join Zoom Meeting

https://zoom.us/j/695893389



One tap mobile

+17207072699,,695893389# US

+16465588656,,695893389# US (New York)



Dial by your location

+1 720 707 2699 US

+1 646 558 8656 US (New York)

Meeting ID: 695 893 389

Find your local number: https://zoom.us/u/abOtdJckxL




Cancelled Event: TianoCore Design / Bug Triage - EMEA - Wednesday, 7 August 2019 #cal-cancelled

devel@edk2.groups.io Calendar <devel@...>
 

Cancelled: TianoCore Design / Bug Triage - EMEA

This event has been cancelled.

When:
Wednesday, 7 August 2019
8:00am to 9:00am
(UTC-07:00) America/Los Angeles

Where:
https://zoom.us/j/695893389

Organizer:
stephano.cetola@...

Description:

Join Zoom Meeting

https://zoom.us/j/695893389

 

One tap mobile

+17207072699,,695893389# US

+16465588656,,695893389# US (New York)

 

Dial by your location

        +1 720 707 2699 US

        +1 646 558 8656 US (New York)

Meeting ID: 695 893 389

Find your local number: https://zoom.us/u/abOtdJckxL

 


Re: [PATCH 0/3] Enhance ESRT to support multiple controllers

Laszlo Ersek
 

On 08/05/19 08:19, Wu, Hao A wrote:
-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Eric Jin
Sent: Wednesday, July 31, 2019 10:59 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [PATCH 0/3] Enhance ESRT to support multiple
controllers

Multiple Controllers Support solution

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525

The patch set is to makes enhancement to the ESRT when multiple
same controllers exist in one system.

Eric Jin (3):
MdeModulePkg/EsrtFmpDxe: Merge multiple FMP into ESRT
MdeModulePkg/EsrtFmpDxe: Correct LastAttemptVersion algorithm in ESRT
MdeModulePkg/EsrtFmpDxe: Detect duplicate GUID/HardwareInstance

Hello Eric,

After looking into the series, I found that patches 2/3 & 3/3 are actually
addressing issues introduced by the 1/3 patch. It looks to me that these
3 patches should be squashed into 1 commit, since they all focus on adding
a feature for ESRT to support multiple controllers.

However, originally, the 3 separate commits come from the edk2-staging
repository, so I am not very sure what approach should be adopted when
merging them back to the edk2 repo master branch.

(Includes the stewards here for suggestions.)

My personal preference is to merge them together as one patch.
Sorry about the late response.

I certainly agree that a single patch series should avoid introducing a
bug or esp. regression, just for another patch in the same series to fix
it up. In that case, both halves indeed belong to a single patch.

However, speaking generally (not knowing any specifics here), that
doesn't mean that everything should be squashed into a single patch. The
series (speaking generally) should still have a fine-grained structure;
each patch should do as little, and as well isolated, as reasonably
possible.

Thanks
Laszlo


Re: [PATCH V2] BaseTools:Add the Judgment Method of "--exclude"

Liming Gao
 

Sorry for the missing. Reviewed-by: Liming Gao <liming.gao@...>

-----Original Message-----
From: Fan, ZhijuX
Sent: Friday, June 28, 2019 3:01 PM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@...>; Feng, Bob C <bob.c.feng@...>
Subject: [PATCH V2] BaseTools:Add the Judgment Method of "--exclude"

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1944

--exclude cannot be used under certain circumstances
1.The value of the parameter USES an absolute path
2.The value of Exclude parameters is based on the value
of the Path parameter
Neither of these approaches currently works

This patch is going to fix that issue.

Cc: Liming Gao <liming.gao@...>
Cc: Bob Feng <bob.c.feng@...>
Signed-off-by: Zhiju.Fan <zhijux.fan@...>
---
keep original behavior on
--exclude for the directory name or file name.

BaseTools/Scripts/FormatDosFiles.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Scripts/FormatDosFiles.py
b/BaseTools/Scripts/FormatDosFiles.py
index d9a880f299..3150bef3c2 100644
--- a/BaseTools/Scripts/FormatDosFiles.py
+++ b/BaseTools/Scripts/FormatDosFiles.py
@@ -20,7 +20,7 @@ import copy

__prog__ = 'FormatDosFiles'
__version__ = '%s Version %s' % (__prog__, '0.10 ')
-__copyright__ = 'Copyright (c) 2018, Intel Corporation. All rights reserved.'
+__copyright__ = 'Copyright (c) 2018-2019, Intel Corporation. All rights
reserved.'
__description__ = 'Convert source files to meet the EDKII C Coding Standards
Specification.\n'
DEFAULT_EXT_LIST = ['.h', '.c', '.nasm', '.nasmb', '.asm', '.S', '.inf', '.dec', '.dsc',
'.fdf', '.uni', '.asl', '.aslc', '.vfr', '.idf', '.txt', '.bat', '.py']

@@ -46,10 +46,26 @@ def FormatFile(FilePath, Args):
def FormatFilesInDir(DirPath, ExtList, Args):

FileList = []
+ ExcludeDir = DirPath
for DirPath, DirNames, FileNames in os.walk(DirPath):
if Args.Exclude:
DirNames[:] = [d for d in DirNames if d not in Args.Exclude]
FileNames[:] = [f for f in FileNames if f not in Args.Exclude]
+ Continue = False
+ for Path in Args.Exclude:
+ if not os.path.isdir(Path) and not os.path.isfile(Path):
+ Path = os.path.join(ExcludeDir, Path)
+ if os.path.isdir(Path) and Path.endswith(DirPath):
+ DirNames[:] = []
+ Continue = True
+ elif os.path.isfile(Path):
+ FilePaths = FileNames
+ for ItemPath in FilePaths:
+ FilePath = os.path.join(DirPath, ItemPath)
+ if Path.endswith(FilePath):
+ FileNames.remove(ItemPath)
+ if Continue:
+ continue
for FileName in [f for f in FileNames if any(f.endswith(ext) for ext in
ExtList)]:
FileList.append(os.path.join(DirPath, FileName))
for File in FileList:
--
2.14.1.windows.1


Re: [Patch 0/3] BaseTools/PatchCheck: Fix false positives

Liming Gao
 

Mike:
For this patch set, I am OK for those changes. Reviewed-by: Liming Gao <liming.gao@...>

But, I see there are some discussion on patch 3. After we make the conclusion, you can push it.

Thanks
Liming

-----Original Message-----
From: Kinney, Michael D
Sent: Friday, August 02, 2019 8:13 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@...>; Gao, Liming
<liming.gao@...>; Justen, Jordan L <jordan.l.justen@...>
Subject: [Patch 0/3] BaseTools/PatchCheck: Fix false positives

https://bugzilla.tianocore.org/show_bug.cgi?id=2044

* Add '--no-textconv' to 'git show' command to disable binary->text
conversion.
* Ignore blank lines in patch
* Ignore lines with 'copy from ' and 'copy to ' prefixes

Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <liming.gao@...>
Cc: Jordan Justen <jordan.l.justen@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>

Michael D Kinney (3):
BaseTools/PatchCheck: Ignore blank lines in diff
BaseTools/PatchCheck: Add copy from/to keywords
BaseTools/PatchCheck: Disable text conversion in 'git show'

BaseTools/Scripts/PatchCheck.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

--
2.21.0.windows.1


Re: [Patch 4/4] MdePkg/X64/ProcessorBind.h: Fix EmulatorPkg X64 XCODE5

Liming Gao
 

Reviewed-by: Liming Gao <liming.gao@...>

-----Original Message-----
From: Kinney, Michael D
Sent: Friday, August 02, 2019 11:23 AM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@...>; Justen, Jordan L
<jordan.l.justen@...>; Andrew Fish <afish@...>; Ni, Ray
<ray.ni@...>
Subject: [Patch 4/4] MdePkg/X64/ProcessorBind.h: Fix EmulatorPkg X64
XCODE5

https://bugzilla.tianocore.org/show_bug.cgi?id=2046

Make sure all libs that should be dynamically linked
are dynamically linked when XCODE5 compiler is used.
A previous change introduced the following pragma:

#pragma GCC visibility push (hidden)

When the EmulatorPkg is built using XCODE5 toolchain
for X64, this pragma is included and it generates a
linker error when building the Unix Host module. This
change uses !defined(__APPLE__) to prevent the use of
this pragma when building EmulatorPkg/Unix/Host.

Cc: Liming Gao <liming.gao@...>
Cc: Jordan Justen <jordan.l.justen@...>
Cc: Andrew Fish <afish@...>
Cc: Ray Ni <ray.ni@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
MdePkg/Include/X64/ProcessorBind.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/X64/ProcessorBind.h
b/MdePkg/Include/X64/ProcessorBind.h
index b22cb226b0..6f65acd609 100644
--- a/MdePkg/Include/X64/ProcessorBind.h
+++ b/MdePkg/Include/X64/ProcessorBind.h
@@ -1,7 +1,7 @@
/** @file
Processor or Compiler specific defines and types x64 (Intel 64, AMD64).

- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -21,7 +21,7 @@
#pragma pack()
#endif

-#if defined(__GNUC__) && defined(__pic__) && !defined(USING_LTO)
+#if defined(__GNUC__) && defined(__pic__) && !defined(USING_LTO)
&& !defined(__APPLE__)
//
// Mark all symbol declarations and references as hidden, meaning they will
// not be subject to symbol preemption. This allows the compiler to refer to
--
2.21.0.windows.1


Re: [PATCH v4 06/35] OvmfPkg/XenResetVector: Add new entry point for Xen PVH

Roger Pau Monné
 

On Mon, Jul 29, 2019 at 04:39:15PM +0100, Anthony PERARD wrote:
Add a new entry point for Xen PVH that enter directly in 32bits.

Information on the expected state of the machine when this entry point
is used can be found at:
https://xenbits.xenproject.org/docs/unstable/misc/pvh.html

Also, compare to the original file [1], the two `nop' of the "resetVector"
entry point are removed. There were introduced by 8332983e2e33
("UefiCpuPkg: Replace the un-necessary WBINVD instruction at the reset
vector with two NOPs in VTF0.", 2011-08-04), but don't seems to be
useful. This is the entry point used by HVM guest (hvmloader).

[1] UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
Signed-off-by: Anthony PERARD <anthony.perard@...>
Acked-by: Laszlo Ersek <lersek@...>
---

Notes:
v4:
- remove the two nop in the HVM entry point

v3:
- rebased, SPDX
- remove `cli' as via PVH the interrupts are guaranteed to be off
- rewrite some comments

.../XenResetVector/Ia16/ResetVectorVtf0.asm | 79 +++++++++++++++++++
OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm | 49 ++++++++++++
OvmfPkg/XenResetVector/XenResetVector.nasmb | 1 +
3 files changed, 129 insertions(+)
create mode 100644 OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
create mode 100644 OvmfPkg/XenResetVector/Ia32/XenPVHMain.asm

diff --git a/OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm b/OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
new file mode 100644
index 0000000000..56749bdbc9
--- /dev/null
+++ b/OvmfPkg/XenResetVector/Ia16/ResetVectorVtf0.asm
@@ -0,0 +1,79 @@
+;------------------------------------------------------------------------------
+; @file
+; First code executed by processor after resetting.
+;
+; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019, Citrix Systems, Inc.
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;------------------------------------------------------------------------------
+
+BITS 16
+
+ALIGN 16
+
+;
+; Pad the image size to 4k when page tables are in VTF0
+;
+; If the VTF0 image has page tables built in, then we need to make
+; sure the end of VTF0 is 4k above where the page tables end.
+;
+; This is required so the page tables will be 4k aligned when VTF0 is
+; located just below 0x100000000 (4GB) in the firmware device.
+;
+%ifdef ALIGN_TOP_TO_4K_FOR_PAGING
+ TIMES (0x1000 - ($ - EndOfPageTables) - (fourGigabytes - xenPVHEntryPoint)) DB 0
+%endif
+
+BITS 32
I think you likely want an ALIGN 32 here in case
ALIGN_TOP_TO_4K_FOR_PAGING is not defined, so that xenPVHEntryPoint is
aligned to a double word boundary?

(not that it's mandatory for this to work)

The rest LGTM.

Thanks, Roger.


Re: Microsoft imports - was Re: [edk2-devel] [PATCH V2] BaseTools:Add extra debugging message

Liming Gao
 

Leif:

-----Original Message-----
From: Leif Lindholm [mailto:leif.lindholm@...]
Sent: Friday, August 02, 2019 5:55 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@...>; Fan, ZhijuX <zhijux.fan@...>;
Max Knutsen <@maknutse>; Philippe Mathieu-Daude
<philmd@...>; Andrew Fish <afish@...>; Laszlo Ersek
<lersek@...>; Kinney, Michael D <michael.d.kinney@...>;
Gao, Liming <liming.gao@...>
Subject: Microsoft imports - was Re: [edk2-devel] [PATCH V2] BaseTools:Add
extra debugging message

So, I'm not going to give any of the reviewers a hard time about this
- the patch *looks* right and we've all occasionally given R-b on
things we haven't actually tested because we don't always have the
time. And by the time I hit it, it had already been fixed upstream.

But what worries me is that not only was this an error that would have
been caught by a simple build test - it was imported from an external
project where the same would have applied.
I double check the code. Original code is good. This is a patch sync issue.


Chucking patched over the wall from another open source project is no
improvement over chucking internal patches over the wall without
proper (contributor) review or testing.
Yes. The developer unit test is important.


Or was it modified on the way across?

One change I would like to see enacted *immediately* is that *any*
imports from other open source projects state the repository and the
commit hash that it originated from. In the commit message - and where
BZs are referenced in the message, also copied into the BZ.
Good suggestion. I will update BZ to include those information.

Thanks
Liming
/
Leif

On Thu, Aug 01, 2019 at 12:57:36PM +0000, Liming Gao wrote:
Good catch. I have pushed this patch. Can you send one new patch to fix it?

-----Original Message-----
From: Feng, Bob C
Sent: Thursday, August 1, 2019 8:20 PM
To: devel@edk2.groups.io; Fan, ZhijuX <zhijux.fan@...>
Cc: Max Knutsen <@maknutse>; Gao, Liming
<liming.gao@...>
Subject: RE: [edk2-devel] [PATCH V2] BaseTools:Add extra debugging
message

Hi Zhiju,

There is a typo in this patch. See it inline.

Thanks,
Bob

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Fan, ZhijuX
Sent: Thursday, July 25, 2019 11:02 AM
To: devel@edk2.groups.io
Cc: Max Knutsen <@maknutse>; Feng, Bob C
<bob.c.feng@...>; Gao, Liming <liming.gao@...>; Fan, ZhijuX
<zhijux.fan@...>
Subject: [edk2-devel] [PATCH V2] BaseTools:Add extra debugging
message

From: Max Knutsen <@maknutse>

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2014

Add extra debugging to improve error identification.
Error while processing file if the file is read incorrectly

This patch is going to fix that issue.

Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <liming.gao@...>
Signed-off-by: Zhiju.Fan <zhijux.fan@...>
---
BaseTools/Source/Python/AutoGen/StrGather.py | 16 ++++++++++------
BaseTools/Source/Python/Trim/Trim.py | 4 +++-
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py
b/BaseTools/Source/Python/AutoGen/StrGather.py
index 2e4671a433..eed30388be 100644
--- a/BaseTools/Source/Python/AutoGen/StrGather.py
+++ b/BaseTools/Source/Python/AutoGen/StrGather.py
@@ -526,12 +526,16 @@ def SearchString(UniObjectClass, FileList,
IsCompatibleMode):
return UniObjectClass

for File in FileList:
- if os.path.isfile(File):
- Lines = open(File, 'r')
- for Line in Lines:
- for StrName in STRING_TOKEN.findall(Line):
- EdkLogger.debug(EdkLogger.DEBUG_5, "Found string identifier:
" + StrName)
- UniObjectClass.SetStringReferenced(StrName)
+ try:
+ if os.path.isfile(File):
+ Lines = open(File, 'r')
+ for Line in Lines:
+ for StrName in STRING_TOKEN.findall(Line):
+ EdkLogger.debug(EdkLogger.DEBUG_5, "Found string
identifier: " + StrName)
+ UniObjectClass.SetStringReferenced(StrName)
+ except:
+ EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR,
"SearchString: Error while processing file", File=File,
RaiseError=False)
+ raise

UniObjectClass.ReToken()

diff --git a/BaseTools/Source/Python/Trim/Trim.py
b/BaseTools/Source/Python/Trim/Trim.py
index 43119bd7ff..8767b67f7e 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -73,8 +73,10 @@ def TrimPreprocessedFile(Source, Target,
ConvertHex, TrimLong):
try:
with open(Source, "r") as File:
Lines = File.readlines()
- except:
+ except IOError:
EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=Source)
+ expect:

Typo here. expect should except

+ EdkLogger.error("Trim", AUTOGEN_ERROR, "TrimPreprocessedFile:
Error while processing file", File=Source)

PreprocessedFile = ""
InjectedFile = ""
--
2.14.1.windows.1





[edk2-test][PATCH V3 1/3] Adding FMP to IHVSCT.

shrishail
 

From: Shrishail Patil <Shrishail.Patil@...>

Adding Firmware Management Protocol to IHVSCT.
This patch contains source code which is copied from
UEFISCT and added into IHVSCT.
Addressed the review comments relating to commented code.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shrishail patil <shrishail.patil@...>
---
.../FirmwareManagementBBTestConformance.c | 3613 +++++++++++++++++
.../FirmwareManagementBBTestFunction.c | 872 ++++
.../FirmwareManagementBBTestMain.c | 168 +
.../FirmwareManagementBBTestMain.h | 205 +
.../FirmwareManagement/BlackBoxTest/Guid.c | 83 +
.../FirmwareManagement/BlackBoxTest/Guid.h | 153 +
.../IhvFirmwareManagementBBTest.inf | 52 +
7 files changed, 5146 insertions(+)
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestConformance.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestFunction.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.h
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
FirmwareManagement/BlackBoxTest/Guid.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
FirmwareManagement/BlackBoxTest/Guid.h
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
FirmwareManagement/BlackBoxTest/IhvFirmwareManagementBBTest.inf

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestConformance.c
new file mode 100644
index 00000000..c4bf5d7d
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestConformance.c
@@ -0,0 +1,3613 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2016, Dell Inc. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ FirmwareManagementBBTestConformance.c
+
+Abstract:
+ Firmware Management Protocol's conformance tests.
+
+--*/
+
+#define DEBUG_ALL 0
+#define DEBUG_GET_IMAGE_INFO 0
+#define DEBUG_GET_IMAGE 0
+#define DEBUG_SET_IMAGE 0
+#define DEBUG_CHECK_IMAGE 0
+#define DEBUG_SET_PACKAGE_INFO 0
+
+#include "SctLib.h"
+#include "FirmwareManagementBBTestMain.h"
+
+// ****************************************************************************
+// Support Routines
+// ****************************************************************************
+
+EFI_STATUS
+CheckForSupportGetImage (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+CheckForSupportSetImage (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+
+EFI_STATUS
+CheckForSupportCheckImage (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+CheckForSupportSetPackageInfo (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+// ****************************************************************************
+// Check Points
+// ****************************************************************************
+
+EFI_STATUS
+BBTestGetImageInfoConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestGetImageInfoConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestGetImageConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestGetImageConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestGetImageConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestGetImageConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestSetImageConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestSetImageConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestSetImageConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestSetImageConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestCheckImageConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestCheckImageConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+// ****************************************************************************
+// Support Routines
+//
+//
+// ****************************************************************************
+
+// ****************************************************************************
+// Support Routine: Progress
+// ****************************************************************************
+
+EFI_STATUS
+Progress (
+ IN UINTN Completion
+)
+{
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Support Routine: CheckForSupportGetImage
+// ****************************************************************************
+
+EFI_STATUS
+CheckForSupportGetImage (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+)
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINT8 ImageIndex;
+ VOID *Image;
+ UINTN ImageSize;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceSupportGuid001;
+ ResultMessageLabel = L"GetImage, function support check";
+
+ ImageIndex = 0;
+ Image = NULL;
+ ImageSize = 0;
+
+ //
+ // Check if function is supported
+ //
+
+ Status = FirmwareManagement->GetImage (
+ FirmwareManagement,
+ ImageIndex,
+ Image,
+ &ImageSize
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ if (Status == EFI_UNSUPPORTED) {
+ ResultMessageData = L"function is NOT supported";
+ } else {
+ ResultMessageData = L"function is supported.";
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (Image != NULL) {
+ gtBS->FreePool (Image);
+ }
+
+ if (Status == EFI_UNSUPPORTED) {
+ return EFI_UNSUPPORTED;
+ } else {
+ return EFI_SUCCESS;
+ }
+}
+
+// ****************************************************************************
+// Support Routine: CheckForSupportSetImage
+// ****************************************************************************
+
+EFI_STATUS
+CheckForSupportSetImage (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+)
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINT8 ImageIndex;
+ VOID *Image;
+ UINTN ImageSize;
+ CHAR16 *AbortReason;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceSupportGuid002;
+ ResultMessageLabel = L"SetImage, function support check";
+
+ ImageIndex = 0;
+ Image = NULL;
+ ImageSize = 0;
+ AbortReason = NULL;
+
+ //
+ // Check if function is supported
+ //
+
+ Status = FirmwareManagement->SetImage (
+ FirmwareManagement,
+ ImageIndex,
+ Image,
+ ImageSize,
+ NULL, // VendorCode
+ Progress,
+ &AbortReason
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ if (Status == EFI_UNSUPPORTED) {
+ ResultMessageData = L"function is NOT supported";
+ } else {
+ ResultMessageData = L"function is supported.";
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (AbortReason != NULL) {
+ gtBS->FreePool (AbortReason);
+ }
+
+ if (Status == EFI_UNSUPPORTED) {
+ return EFI_UNSUPPORTED;
+ } else {
+ return EFI_SUCCESS;
+ }
+}
+
+// ****************************************************************************
+// Support Routine: CheckForSupportCheckImage
+// ****************************************************************************
+
+EFI_STATUS
+CheckForSupportCheckImage (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+)
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINT8 ImageIndex;
+ VOID *Image;
+ UINTN ImageSize;
+ UINT32 ImageUpdatable;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceSupportGuid003;
+ ResultMessageLabel = L"CheckImage, function support check";
+
+ ImageIndex = 0;
+ Image = NULL;
+ ImageSize = 0;
+
+ //
+ // Check if function is supported
+ //
+
+ Status = FirmwareManagement->CheckImage (
+ FirmwareManagement,
+ ImageIndex,
+ Image,
+ ImageSize,
+ &ImageUpdatable
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ if (Status == EFI_UNSUPPORTED) {
+ ResultMessageData = L"function is NOT supported";
+ } else {
+ ResultMessageData = L"function is supported.";
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (Status == EFI_UNSUPPORTED) {
+ return EFI_UNSUPPORTED;
+ } else {
+ return EFI_SUCCESS;
+ }
+}
+
+// ****************************************************************************
+// Support Routine: CheckForSupportSetPackageInfo
+// ****************************************************************************
+
+EFI_STATUS
+CheckForSupportSetPackageInfo (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+)
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ VOID *Image;
+ UINTN ImageSize;
+ VOID *VendorCode;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceSupportGuid004;
+ ResultMessageLabel = L"SetPackageInfo, function support check";
+
+ Image = NULL;
+ ImageSize = 0;
+ VendorCode = NULL;
+ PackageVersion = 0;
+ PackageVersionName = NULL;
+
+ //
+ // Check if function is supported
+ //
+
+ Status = FirmwareManagement->SetPackageInfo (
+ FirmwareManagement,
+ Image,
+ ImageSize,
+ VendorCode,
+ PackageVersion,
+ PackageVersionName
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ if (Status == EFI_UNSUPPORTED) {
+ ResultMessageData = L"function is NOT supported";
+ } else {
+ ResultMessageData = L"function is supported.";
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (Status == EFI_UNSUPPORTED) {
+ return EFI_UNSUPPORTED;
+ } else {
+ return EFI_SUCCESS;
+ }
+}
+
+// ****************************************************************************
+// Test Case: GetImageInfo
+// ****************************************************************************
+
+EFI_STATUS
+BBTestGetImageInfoConformanceTest (
+ 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;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement;
+
+ //
+ // Init
+ //
+
+ FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface;
+
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Call check point(s)
+ //
+
+ BBTestGetImageInfoConformanceTestCheckpoint1 (StandardLib, FirmwareManagement);
+ BBTestGetImageInfoConformanceTestCheckpoint2 (StandardLib, FirmwareManagement);
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Test Case: GetImage
+// ****************************************************************************
+
+EFI_STATUS
+BBTestGetImageConformanceTest (
+ 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;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement;
+
+ //
+ // Init
+ //
+
+ FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface;
+
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Check if function is supported
+ //
+
+ Status = CheckForSupportGetImage (StandardLib, FirmwareManagement);
+ if (Status == EFI_UNSUPPORTED) {
+ return Status;
+ }
+
+ //
+ // Call check point(s)
+ //
+
+ BBTestGetImageConformanceTestCheckpoint1 (StandardLib, FirmwareManagement);
+ BBTestGetImageConformanceTestCheckpoint2 (StandardLib, FirmwareManagement);
+ BBTestGetImageConformanceTestCheckpoint3 (StandardLib, FirmwareManagement);
+ BBTestGetImageConformanceTestCheckpoint4 (StandardLib, FirmwareManagement);
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Test Case: SetImage
+// ****************************************************************************
+
+EFI_STATUS
+BBTestSetImageConformanceTest (
+ 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;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement;
+
+ //
+ // Init
+ //
+
+ FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface;
+
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Check if function is supported
+ //
+
+ Status = CheckForSupportSetImage (StandardLib, FirmwareManagement);
+ if (Status == EFI_UNSUPPORTED) {
+ return Status;
+ }
+
+ //
+ // Call check point(s)
+ //
+
+ BBTestSetImageConformanceTestCheckpoint1 (StandardLib, FirmwareManagement);
+ //BBTestSetImageConformanceTestCheckpoint2 (StandardLib, FirmwareManagement);
+ BBTestSetImageConformanceTestCheckpoint3 (StandardLib, FirmwareManagement);
+ BBTestSetImageConformanceTestCheckpoint4 (StandardLib, FirmwareManagement);
+
+ return Status;
+}
+
+// ****************************************************************************
+// Test Case: CheckImage
+// ****************************************************************************
+
+EFI_STATUS
+BBTestCheckImageConformanceTest (
+ 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;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement;
+
+ //
+ // Init
+ //
+
+ FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface;
+
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Check if function is supported
+ //
+
+ Status = CheckForSupportCheckImage (StandardLib, FirmwareManagement);
+ if (Status == EFI_UNSUPPORTED) {
+ return Status;
+ }
+
+ //
+ // Call check point(s)
+ //
+
+ BBTestCheckImageConformanceTestCheckpoint1 (StandardLib, FirmwareManagement);
+ BBTestCheckImageConformanceTestCheckpoint2 (StandardLib, FirmwareManagement);
+
+ return Status;
+}
+
+// ****************************************************************************
+// Test Case: SetPackageInfo
+// ****************************************************************************
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTest (
+ 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;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement;
+
+ //
+ // Init
+ //
+
+ FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface;
+
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Check if function is supported
+ //
+
+ Status = CheckForSupportSetPackageInfo (StandardLib, FirmwareManagement);
+ if (Status == EFI_UNSUPPORTED) {
+ return Status;
+ }
+
+ //
+ // Call check point(s)
+ //
+
+ BBTestSetPackageInfoConformanceTestCheckpoint1 (StandardLib, FirmwareManagement);
+ BBTestSetPackageInfoConformanceTestCheckpoint2 (StandardLib, FirmwareManagement);
+ BBTestSetPackageInfoConformanceTestCheckpoint3 (StandardLib, FirmwareManagement);
+ BBTestSetPackageInfoConformanceTestCheckpoint4 (StandardLib, FirmwareManagement);
+
+ return Status;
+}
+
+// ****************************************************************************
+// Check Points
+//
+//
+// ****************************************************************************
+
+// ****************************************************************************
+// Checkpoint: GetImageInfo, 1
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except ImageInfoSize = 1.
+ The function should return EFI_BUFFER_TOO_SMALL and ImageInfoSize > 1.
+**/
+
+EFI_STATUS
+BBTestGetImageInfoConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid001;
+ ResultMessageLabel = L"GetImageInfo, conformance checkpoint #1";
+ ResultMessageData = L"correctly returned EFI_BUFFER_TOO_SMALL.";
+
+ ImageInfo = NULL;
+ PackageVersionName = NULL;
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ ImageInfoSize = 1;
+
+ //
+ // Check the data returned by the function
+ //
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_BUFFER_TOO_SMALL.";
+ goto Exit;
+ }
+ if (ImageInfoSize <= 1) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to update *ImageInfoSize.";
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (ImageInfo != NULL) {
+ gtBS->FreePool (ImageInfo);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: GetImageInfo, 2
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except &ImageInfoSize = NULL.
+ The function should return EFI_INVALID_PARAMETER.
+**/
+
+EFI_STATUS
+BBTestGetImageInfoConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid002;
+ ResultMessageLabel = L"GetImageInfo, conformance checkpoint #2";
+ ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER.";
+
+ ImageInfo = NULL;
+ PackageVersionName = NULL;
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ NULL, // &ImageInfoSize
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+
+ if (Status != EFI_INVALID_PARAMETER) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_INVALID_PARAMETER.";
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (ImageInfo != NULL) {
+ gtBS->FreePool (ImageInfo);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: GetImage, 1
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except ImageSize = 1.
+ The function should return EFI_BUFFER_TOO_SMALL and ImageSize > 1.
+**/
+
+EFI_STATUS
+BBTestGetImageConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+ VOID *BufferImage;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid003;
+ ResultMessageLabel = L"GetImage, conformance checkpoint #1";
+
+ BufferImageInfo = NULL;
+ BufferImage = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) &&
+ ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ ImageSize = p->Size;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ BufferImage = Image;
+
+ ImageSize = 1;
+ FunctionTested++;
+ Status = FirmwareManagement->GetImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ &ImageSize
+ );
+ gtBS->FreePool (BufferImage);
+ BufferImage = NULL;
+ Image = NULL;
+
+ //
+ // Report the checkpoint result
+ //
+
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_BUFFER_TOO_SMALL.";
+ goto Exit;
+ }
+ if (ImageInfoSize <= 1) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to update *ImageSize.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_BUFFER_TOO_SMALL.";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (BufferImage != NULL) {
+ gtBS->FreePool (BufferImage);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: GetImage, 2
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except Image = NULL.
+ The function should return EFI_INVALID_PARAMETER.
+**/
+
+EFI_STATUS
+BBTestGetImageConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid004;
+ ResultMessageLabel = L"GetImage, conformance checkpoint #2";
+
+ BufferImageInfo = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) &&
+ ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ // Use a sufficiently large buffer size to avoid EFI_BUFFER_TOO_SMALL.
+ ImageSize = p->Size * 2;
+ Image = NULL;
+ FunctionTested++;
+ Status = FirmwareManagement->GetImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ &ImageSize
+ );
+
+ //
+ // Report the checkpoint result
+ //
+
+ if (Status != EFI_INVALID_PARAMETER) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_INVALID_PARAMETER.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER.";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: GetImage, 3
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except ImageIndex = 0 or
+ ImageIndex = DescriptorCount + 1.
+ The function should return EFI_INVALID_PARAMETER or EFI_NOT_FOUND.
+**/
+
+EFI_STATUS
+BBTestGetImageConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+ VOID *BufferImage;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ VOID *Image;
+ UINTN ImageSize;
+ UINT8 ImageIndex;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid005;
+ ResultMessageLabel = L"GetImage, conformance checkpoint #3";
+
+ BufferImageInfo = NULL;
+ BufferImage = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ // Dummy image so as to fail on Image = NULL
+ // Any size since the function should check for index before size
+ ImageSize = 64;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ BufferImage = Image;
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_INVALID_PARAMETER or EFI_NOT_FOUND.";
+
+ ImageIndex = 0;
+ Status = FirmwareManagement->GetImage (
+ FirmwareManagement,
+ ImageIndex,
+ Image,
+ &ImageSize
+ );
+ if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_NOT_FOUND)) {
+ goto Exit;
+ }
+
+ if ((DescriptorCount + 1) != 0) {
+ ImageIndex = DescriptorCount + 1;
+ Status = FirmwareManagement->GetImage (
+ FirmwareManagement,
+ ImageIndex,
+ Image,
+ &ImageSize
+ );
+ if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_NOT_FOUND)) {
+ goto Exit;
+ }
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER or EFI_NOT_FOUND.";
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (BufferImage != NULL) {
+ gtBS->FreePool (BufferImage);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: GetImage, 4
+// ****************************************************************************
+
+/**
+ This routine:
+ - The function requires authentication.
+ - Calls function with valid parameters, except Image has dummy
+ authentication data.
+ The function should return EFI_SECURITY_VIOLATION.
+**/
+
+EFI_STATUS
+BBTestGetImageConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+ VOID *BufferImage;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid006;
+ ResultMessageLabel = L"GetImage, conformance checkpoint #4";
+
+ BufferImageInfo = NULL;
+ BufferImage = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ // Use a sufficiently large buffer size to avoid EFI_BUFFER_TOO_SMALL.
+ ImageSize = p->Size * 2;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ BufferImage = Image;
+
+ FunctionTested++;
+
+ Status = FirmwareManagement->GetImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ &ImageSize
+ );
+ gtBS->FreePool (BufferImage);
+ BufferImage = NULL;
+ Image = NULL;
+
+ //
+ // Report the checkpoint result
+ //
+
+ if (Status != EFI_SECURITY_VIOLATION) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (BufferImage != NULL) {
+ gtBS->FreePool (BufferImage);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: SetImage, 1
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except Image = NULL.
+ The function should return EFI_INVALID_PARAMETER.
+**/
+
+EFI_STATUS
+BBTestSetImageConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ CHAR16 *AbortReason;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid007;
+ ResultMessageLabel = L"SetImage, conformance checkpoint #1";
+
+ BufferImageInfo = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ AbortReason = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) &&
+ ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ ImageSize = p->Size;
+ Image = NULL;
+ FunctionTested++;
+ Status = FirmwareManagement->SetImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ ImageSize,
+ NULL, // VendorCode
+ Progress,
+ &AbortReason
+ );
+
+ //
+ // Report the checkpoint result
+ //
+
+ if (Status != EFI_INVALID_PARAMETER) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_INVALID_PARAMETER.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER.";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (AbortReason != NULL) {
+ gtBS->FreePool (AbortReason);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: SetImage, 2
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except Image is a dummy image.
+ The function should return EFI_INVALID_PARAMETER or EFI_ABORTED.
+**/
+
+EFI_STATUS
+BBTestSetImageConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+ VOID *BufferImage;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ CHAR16 *AbortReason;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid008;
+ ResultMessageLabel = L"SetImage, conformance checkpoint #2";
+
+ BufferImageInfo = NULL;
+ BufferImage = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ AbortReason = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) &&
+ ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ ImageSize = p->Size;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ BufferImage = Image;
+ FunctionTested++;
+ Status = FirmwareManagement->SetImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ ImageSize,
+ NULL, // VendorCode
+ Progress,
+ &AbortReason
+ );
+ gtBS->FreePool (BufferImage);
+ BufferImage = NULL;
+ Image = NULL;
+
+ //
+ // Report the checkpoint result
+ //
+
+ if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_ABORTED)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_INVALID_PARAMETER or EFI_ABORTED.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER or EFI_ABORTED.";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (BufferImage != NULL) {
+ gtBS->FreePool (BufferImage);
+ }
+ if (AbortReason != NULL) {
+ gtBS->FreePool (AbortReason);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: SetImage, 3
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except ImageIndex = 0 or
+ ImageIndex = DescriptorCount + 1.
+ The function should return EFI_INVALID_PARAMETER or EFI_ABORTED.
+**/
+
+EFI_STATUS
+BBTestSetImageConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+ VOID *BufferImage;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ CHAR16 *AbortReason;
+
+ VOID *Image;
+ UINTN ImageSize;
+ UINT8 ImageIndex;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid009;
+ ResultMessageLabel = L"SetImage, conformance checkpoint #3";
+
+ BufferImageInfo = NULL;
+ BufferImage=NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ AbortReason = NULL;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ // Dummy image so as to fail on Image = NULL
+ // Any size since the function should check for index before size
+ ImageSize = 64;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ BufferImage = Image;
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_INVALID_PARAMETER or EFI_ABORTED.";
+
+ ImageIndex = 0;
+ Status = FirmwareManagement->SetImage (
+ FirmwareManagement,
+ ImageIndex,
+ Image,
+ ImageSize,
+ NULL, // VendorCode
+ Progress,
+ &AbortReason
+ );
+ if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_ABORTED)) {
+ goto Exit;
+ }
+
+ if ((DescriptorCount + 1) != 0) {
+ ImageIndex = DescriptorCount + 1;
+ Status = FirmwareManagement->SetImage (
+ FirmwareManagement,
+ ImageIndex,
+ Image,
+ ImageSize,
+ NULL, // Vendorcode
+ Progress,
+ &AbortReason
+ );
+ if ((Status != EFI_INVALID_PARAMETER) && (Status != EFI_ABORTED)) {
+ goto Exit;
+ }
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER or EFI_ABORTED.";
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (BufferImage != NULL) {
+ gtBS->FreePool (BufferImage);
+ }
+ if (AbortReason != NULL) {
+ gtBS->FreePool (AbortReason);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: SetImage, 4
+// ****************************************************************************
+
+/**
+ This routine:
+ - The function requires authentication.
+ - Calls function with valid parameters, except Image has dummy
+ authentication data.
+ The function should return EFI_SECURITY_VIOLATION.
+**/
+
+EFI_STATUS
+BBTestSetImageConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+ VOID *BufferImage;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ CHAR16 *AbortReason;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid010;
+ ResultMessageLabel = L"SetImage, conformance checkpoint #4";
+
+ BufferImageInfo = NULL;
+ BufferImage = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ AbortReason = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ ImageSize = p->Size;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ BufferImage = Image;
+ FunctionTested++;
+ Status = FirmwareManagement->SetImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ ImageSize,
+ NULL, // VendorCode
+ Progress,
+ &AbortReason
+ );
+ gtBS->FreePool (BufferImage);
+ BufferImage = NULL;
+ Image = NULL;
+
+ //
+ // Report the checkpoint result
+ //
+
+ if (Status != EFI_SECURITY_VIOLATION) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (BufferImage != NULL) {
+ gtBS->FreePool (BufferImage);
+ }
+ if (AbortReason != NULL) {
+ gtBS->FreePool (AbortReason);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: CheckImage, 1
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with valid parameters, except Image = NULL.
+ The function should return EFI_INVALID_PARAMETER.
+**/
+
+EFI_STATUS
+BBTestCheckImageConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ UINT32 ImageUpdatable;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid011;
+ ResultMessageLabel = L"CheckImage, conformance checkpoint #1";
+
+ BufferImageInfo = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) &&
+ ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ ImageSize = p->Size;
+ Image = NULL;
+ FunctionTested++;
+ Status = FirmwareManagement->CheckImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ ImageSize,
+ &ImageUpdatable
+ );
+
+ //
+ // Report the checkpoint result
+ //
+
+ if (Status != EFI_INVALID_PARAMETER) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_INVALID_PARAMETER.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER.";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: CheckImage, 2
+// ****************************************************************************
+
+/**
+ This routine:
+ - The function requires authentication.
+ - Calls function with valid parameters, except Image has dummy
+ authentication data.
+ The function should return EFI_SECURITY_VIOLATION.
+**/
+
+EFI_STATUS
+BBTestCheckImageConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+ VOID *BufferImage;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ UINT32 ImageUpdatable;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid012;
+ ResultMessageLabel = L"CheckImage, conformance checkpoint #2";
+
+ BufferImageInfo = NULL;
+ BufferImage = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ ImageSize = p->Size;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ BufferImage = Image;
+ FunctionTested++;
+ Status = FirmwareManagement->CheckImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ ImageSize,
+ &ImageUpdatable
+ );
+ gtBS->FreePool (BufferImage);
+ BufferImage = NULL;
+ Image = NULL;
+
+ //
+ // Report the checkpoint result
+ //
+
+ if (Status != EFI_SECURITY_VIOLATION) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (BufferImage != NULL) {
+ gtBS->FreePool (BufferImage);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: SetPackageInfo, 1
+// ****************************************************************************
+
+/**
+ This routine:
+ - Gets PackageVersionNameMaxLen.
+ - Calls function with valid parameters, except PackageVersionName is longer
+ than the value returned in PackageVersionNameLen.
+ The function should return EFI_INVALID_PARAMETER.
+**/
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+ UINT32 PackageVersionNameMaxLen;
+ UINT64 AttributesSupported;
+ UINT64 AttributesSetting;
+
+ CHAR16 *TestName;
+ UINT32 TestNameLength;
+
+ UINTN i;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid013;
+ ResultMessageLabel = L"SetPackageInfo, function checkpoint #1";
+
+ PackageVersionName = NULL;
+ TestName = NULL;
+
+ //
+ // Get PackageVersionNameMaxLen
+ //
+
+ Status = FirmwareManagement->GetPackageInfo (
+ FirmwareManagement,
+ &PackageVersion,
+ &PackageVersionName,
+ &PackageVersionNameMaxLen,
+ &AttributesSupported,
+ &AttributesSetting
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ if (PackageVersionNameMaxLen == 0) {
+ goto Exit;
+ }
+ if (((AttributesSupported & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) &&
+ ((AttributesSetting & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) {
+ goto Exit;
+ }
+ if ((AttributesSupported & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) !=
+ PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) {
+ goto Exit;
+ }
+ if ((AttributesSetting & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) !=
+ PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) {
+ goto Exit;
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ gtBS->FreePool (PackageVersionName);
+ PackageVersionName = NULL;
+ TestNameLength = PackageVersionNameMaxLen + 1;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ TestNameLength * 2, // Unicode
+ (VOID **) &TestName
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ for (i = 0; i < (TestNameLength - 1); i++) {
+ TestName[i] = L' ';
+ }
+ TestName[i] = L'\0';
+ Status = FirmwareManagement->SetPackageInfo (
+ FirmwareManagement,
+ NULL, // Image
+ 0, // ImageSize
+ NULL, // VendorCode
+ 0x01010101, // Dummy PackageVersion
+ TestName
+ );
+
+ if (Status == EFI_INVALID_PARAMETER) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_INVALID_PARAMETER.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_INVALID_PARAMETER.";
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (TestName != NULL) {
+ gtBS->FreePool (TestName);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: SetPackageInfo, 2
+// ****************************************************************************
+
+/**
+ This routine:
+ - The function requires authentication.
+ - Calls function with valid parameters, except Image is NULL.
+ The function should return EFI_SECURITY_VIOLATION.
+**/
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+ UINT32 PackageVersionNameMaxLen;
+ UINT64 AttributesSupported;
+ UINT64 AttributesSetting;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid014;
+ ResultMessageLabel = L"SetPackageInfo, function checkpoint #2";
+
+ PackageVersionName = NULL;
+
+ //
+ // Get PackageVersionNameMaxLen
+ //
+
+ Status = FirmwareManagement->GetPackageInfo (
+ FirmwareManagement,
+ &PackageVersion,
+ &PackageVersionName,
+ &PackageVersionNameMaxLen,
+ &AttributesSupported,
+ &AttributesSetting
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ if ((AttributesSupported & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ goto Exit;
+ }
+ if ((AttributesSetting & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ goto Exit;
+ }
+ if ((AttributesSupported & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) !=
+ PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) {
+ goto Exit;
+ }
+ if ((AttributesSetting & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) !=
+ PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) {
+ goto Exit;
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ Image = NULL;
+ ImageSize = 64; // Dummy
+ Status = FirmwareManagement->SetPackageInfo (
+ FirmwareManagement,
+ Image,
+ ImageSize,
+ NULL, // VendorCode
+ PackageVersion,
+ PackageVersionName
+ );
+
+ if (Status == EFI_SECURITY_VIOLATION) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION.";
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: SetPackageInfo, 3
+// ****************************************************************************
+
+/**
+ This routine:
+ - The function requires authentication.
+ - Calls function with valid parameters, except ImageSize is 0.
+ The function should return EFI_SECURITY_VIOLATION.
+**/
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+ UINT32 PackageVersionNameMaxLen;
+ UINT64 AttributesSupported;
+ UINT64 AttributesSetting;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid015;
+ ResultMessageLabel = L"SetPackageInfo, function checkpoint #3";
+
+ PackageVersionName = NULL;
+ Image = NULL;
+
+ //
+ // Get PackageVersionNameMaxLen
+ //
+
+ Status = FirmwareManagement->GetPackageInfo (
+ FirmwareManagement,
+ &PackageVersion,
+ &PackageVersionName,
+ &PackageVersionNameMaxLen,
+ &AttributesSupported,
+ &AttributesSetting
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ if ((AttributesSupported & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ goto Exit;
+ }
+ if ((AttributesSetting & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ goto Exit;
+ }
+ if ((AttributesSupported & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) !=
+ PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) {
+ goto Exit;
+ }
+ if ((AttributesSetting & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) !=
+ PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) {
+ goto Exit;
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ 64, // Dummy
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ ImageSize = 0;
+ Status = FirmwareManagement->SetPackageInfo (
+ FirmwareManagement,
+ Image,
+ ImageSize,
+ NULL, // VendorCode
+ PackageVersion,
+ PackageVersionName
+ );
+
+ if (Status == EFI_SECURITY_VIOLATION) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION.";
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (Image != NULL) {
+ gtBS->FreePool (Image);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: SetPackageInfo, 4
+// ****************************************************************************
+
+/**
+ This routine:
+ - The function requires authentication.
+ - Calls function with valid parameters, except Image has a dummy
+ authentication data.
+ The function should return EFI_SECURITY_VIOLATION.
+**/
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+ UINT32 PackageVersionNameMaxLen;
+ UINT64 AttributesSupported;
+ UINT64 AttributesSetting;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestConformanceAssertionGuid016;
+ ResultMessageLabel = L"SetPackageInfo, function checkpoint #4";
+
+ PackageVersionName = NULL;
+ Image = NULL;
+ ImageSize = 64;
+
+ //
+ // Get PackageVersionNameMaxLen
+ //
+
+ Status = FirmwareManagement->GetPackageInfo (
+ FirmwareManagement,
+ &PackageVersion,
+ &PackageVersionName,
+ &PackageVersionNameMaxLen,
+ &AttributesSupported,
+ &AttributesSetting
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ if ((AttributesSupported & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ goto Exit;
+ }
+ if ((AttributesSetting & PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) {
+ goto Exit;
+ }
+ if ((AttributesSupported & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) !=
+ PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) {
+ goto Exit;
+ }
+ if ((AttributesSetting & PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) !=
+ PACKAGE_ATTRIBUTE_VERSION_UPDATABLE) {
+ goto Exit;
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->SetPackageInfo (
+ FirmwareManagement,
+ Image,
+ ImageSize,
+ NULL, // VendorCode
+ PackageVersion,
+ PackageVersionName
+ );
+
+ if (Status == EFI_SECURITY_VIOLATION) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SECURITY_VIOLATION.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SECURITY_VIOLATION.";
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (Image != NULL) {
+ gtBS->FreePool (Image);
+ }
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestFunction.c
new file mode 100644
index 00000000..5b739c95
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestFunction.c
@@ -0,0 +1,872 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2016, Dell Inc. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ FirmwareManagementBBTestFunction.c
+
+Abstract:
+ Firmware Management Protocol's function tests.
+
+--*/
+
+#define DEBUG_ALL 0
+#define DEBUG_GET_IMAGE_INFO 1
+#define DEBUG_GET_IMAGE 0
+#define DEBUG_GET_PACKAGE_INFO 1
+
+
+#include "SctLib.h"
+#include "FirmwareManagementBBTestMain.h"
+
+// ****************************************************************************
+// Check Points
+// ****************************************************************************
+
+EFI_STATUS
+BBTestGetImageInfoFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestGetImageFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+EFI_STATUS
+BBTestGetPackageInfoFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ );
+
+// ****************************************************************************
+// Test Case: GetImageInfo
+// ****************************************************************************
+
+EFI_STATUS
+BBTestGetImageInfoFunctionTest (
+ 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;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement;
+
+ //
+ // Init
+ //
+
+ FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface;
+
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Call check point(s)
+ //
+
+ BBTestGetImageInfoFunctionTestCheckpoint1 (StandardLib, FirmwareManagement);
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Test Case: GetImage
+// ****************************************************************************
+
+EFI_STATUS
+BBTestGetImageFunctionTest (
+ 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;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement;
+
+ //
+ // Init
+ //
+
+ FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface;
+
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Call check point(s)
+ //
+
+ BBTestGetImageFunctionTestCheckpoint1 (StandardLib, FirmwareManagement);
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Test Case: GetPackageInfo
+// ****************************************************************************
+
+EFI_STATUS
+BBTestGetPackageInfoFunctionTest (
+ 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;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement;
+
+ //
+ // Init
+ //
+
+ FirmwareManagement = (EFI_FIRMWARE_MANAGEMENT_PROTOCOL*)ClientInterface;
+
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Call check point(s)
+ //
+
+ BBTestGetPackageInfoFunctionTestCheckpoint1 (StandardLib, FirmwareManagement);
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Check Points
+//
+//
+// ****************************************************************************
+
+// ****************************************************************************
+// Checkpoint: GetImageInfo, 1
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with all valid parameters.
+ The function should return EFI_SUCCESS.
+ - Checks DescriptorSize is 0.
+ - Checks (DescriptorCount * DescriptorSize) is <= ImageInfoSize.
+ - Checks DescriptorVersion is == 1.
+ - Checks ImageIndex is between 1 and DescriptorCount.
+ - Checks AttributesSupported has no bits set beyond bit3.
+ - Checks AttribtuesSetting has no bits set beyond bit3.
+ - Checks Compatibilities bit1 thru bit15 are 0s.
+**/
+
+EFI_STATUS
+BBTestGetImageInfoFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ CHAR16* Attribute[4];
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+
+#if (DEBUG_ALL || DEBUG_GET_IMAGE_INFO)
+
+ CHAR16 *BitField;
+ CHAR16 *BitSetting;
+
+ UINT64 j;
+ UINTN k;
+
+#endif
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestFunctionAssertionGuid001;
+ ResultMessageLabel = L"GetImageInfo, function checkpoint #1";
+
+ BufferImageInfo = NULL;
+ ImageInfo = NULL;
+ PackageVersionName = NULL;
+
+ Attribute[0] = L"Image Updatable";
+ Attribute[1] = L"Reset Required";
+ Attribute[2] = L"Authentication Required";
+ Attribute[3] = L"In Use";
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ BufferImageInfo = ImageInfo;
+
+ if (Status == EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SUCCESS.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SUCCESS.";
+ goto Exit;
+ }
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ if (DescriptorVersion != 1) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ ResultMessageData = L"*DescriptorVersion != 1.";
+ goto Exit;
+ }
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if (p->ImageIndex > DescriptorCount) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ ResultMessageData = L"ImageIndex is beyond DescriptorCount.";
+ goto Exit;
+ }
+
+ if ((p->AttributesSupported & 0xFFFFFFFFFFFFFFF0) != 0) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ ResultMessageData = L"AttributesSupported has bit(s) set beyond bit3.";
+ goto Exit;
+ }
+
+ if ((p->AttributesSetting & 0xFFFFFFFFFFFFFFF0) != 0) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ ResultMessageData = L"AttributesSetting has bit(s) set beyond bit3.";
+ goto Exit;
+ }
+
+ if ((p->Compatibilities & 0x000000000000FFFE) !=0) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ ResultMessageData = L"Compatibilities have bit(s) set between bit1 and bit15.";
+ goto Exit;
+ }
+ }
+
+#if (DEBUG_ALL || DEBUG_GET_IMAGE_INFO)
+
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L"Firmware Image Info Header: \n"
+ L" - *ImageInfoSize = %x\n"
+ L" - *DescriptorVersion = %x\n"
+ L" - *DescriptorCount = %x\n"
+ L" - *DescriptorSzie = %x\n"
+ L" - *PackageVersion = %08x\n"
+ L" - **PackageVersionName = %s\n",
+ ImageInfoSize,
+ DescriptorVersion,
+ DescriptorCount,
+ DescriptorSize,
+ PackageVersion,
+ PackageVersionName
+ );
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L"Descriptor Index = %x:\n"
+ L" - ImageTypeId = %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x",
+ p->ImageIndex,
+ p->ImageTypeId.Data1,
+ p->ImageTypeId.Data2,
+ p->ImageTypeId.Data3,
+ p->ImageTypeId.Data4[0],
+ p->ImageTypeId.Data4[1],
+ p->ImageTypeId.Data4[2],
+ p->ImageTypeId.Data4[3],
+ p->ImageTypeId.Data4[4],
+ p->ImageTypeId.Data4[5],
+ p->ImageTypeId.Data4[6],
+ p->ImageTypeId.Data4[7]
+ );
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L" - ImageId = %016X\n"
+ L" - *ImageIdName = %s\n"
+ L" - Version = %08x\n"
+ L" - *VersionName = %s\n"
+ L" - Size = %x",
+ p->ImageId,
+ p->ImageIdName,
+ p->Version,
+ p->VersionName,
+ p->Size
+ );
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L" - AttributesSupported = %016x\n"
+ L" - AttributesSetting = %016x",
+ p->AttributesSupported,
+ p->AttributesSetting
+ );
+ for (j = 1, k = 0; j <= IMAGE_ATTRIBUTE_IN_USE; j = SctLShiftU64(j, 1), k++) {
+ BitField = Attribute[k];
+ if ((p->AttributesSupported & j) != j) {
+ BitSetting = L"Not Supported";
+ } else if ((p->AttributesSetting & j) == j) {
+ BitSetting = L"Yes";
+ } else {
+ BitSetting = L"No";
+ }
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L" - %s = %s",
+ BitField,
+ BitSetting
+ );
+ }
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L" - Compatibilities = %016x\n",
+ p->Compatibilities
+ );
+ }
+
+#endif
+
+ //
+ // Report the checkpoint result
+ //
+
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: GetImage, 1
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with all valid parameters.
+ The function should return EFI_SUCCESS or EFI_UNSUPPORTED.
+**/
+
+EFI_STATUS
+BBTestGetImageFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *BufferImageInfo;
+ VOID *BufferImage;
+
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo;
+ UINT32 DescriptorVersion;
+ UINT8 DescriptorCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ VOID *Image;
+ UINTN ImageSize;
+
+ UINTN i;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *p;
+ UINTN FunctionTested;
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestFunctionAssertionGuid002;
+ ResultMessageLabel = L"GetImage, function checkpoint #1";
+
+ BufferImageInfo = NULL;
+ BufferImage = NULL;
+ ImageInfo = NULL;
+ Image = NULL;
+ PackageVersionName = NULL;
+ FunctionTested = 0;
+
+ // Use a sufficiently large buffer to obtain EFI_SUCCESS,
+ // since some implementation does NOT correctly return EFI_BUFFER_TOO_SMALL.
+ // Check for EFI_BUFFER_TOO_SMALL in another conformance test.
+
+ ImageInfoSize = (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR)) * 20;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (ImageInfo);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageInfoSize,
+ (VOID **) &ImageInfo
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ Status = FirmwareManagement->GetImageInfo (
+ FirmwareManagement,
+ &ImageInfoSize,
+ ImageInfo,
+ &DescriptorVersion,
+ &DescriptorCount,
+ &DescriptorSize,
+ &PackageVersion,
+ &PackageVersionName
+ );
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ BufferImageInfo = ImageInfo;
+ goto Exit;
+ }
+ }
+ BufferImageInfo = ImageInfo;
+
+ if (DescriptorSize == 0) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"*DescriptorSize is 0.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+ if ((DescriptorCount * DescriptorSize) > ImageInfoSize) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"((*DescriptorCount) * (*DescriptorSize)) > *ImageInfoSize.";
+ goto Exit; // Note the Status = EFI_SUCCESS
+ }
+
+ //
+ // Check the data returned by the function
+ //
+
+ for (i = 0; i < DescriptorCount; i++) {
+ p = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) (((UINT8 *) ImageInfo) + (i * DescriptorSize));
+
+ if (((p->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) &&
+ ((p->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) ==
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED)) {
+ continue;
+ }
+ if (p->Size == 0) {
+ continue;
+ }
+ if ((p->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+ if ((p->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) {
+ continue;
+ }
+
+ ImageSize = p->Size;
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ BufferImage = Image;
+
+ FunctionTested++;
+ Status = FirmwareManagement->GetImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ &ImageSize
+ );
+
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gtBS->FreePool (Image);
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ ImageSize,
+ (VOID **) &Image
+ );
+ if (EFI_ERROR (Status)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"test case initialization failure.";
+ goto Exit;
+ }
+ }
+ BufferImage = Image;
+
+ Status = FirmwareManagement->GetImage (
+ FirmwareManagement,
+ p->ImageIndex,
+ Image,
+ &ImageSize
+ );
+ gtBS->FreePool (BufferImage);
+ BufferImage = NULL;
+ Image = NULL;
+
+ //
+ // Report the checkpoint result
+ //
+
+ if ((Status != EFI_SUCCESS) && (Status != EFI_UNSUPPORTED)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SUCCESS or EFI_UNSUPPORTED.";
+ goto Exit;
+ }
+ }
+
+ if (FunctionTested == 0) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"test skipped - test case does not apply.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SUCCESS or EFI_UNSUPPORTED.";
+ }
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+ if (BufferImageInfo != NULL) {
+ gtBS->FreePool (BufferImageInfo);
+ }
+ if (BufferImage != NULL) {
+ gtBS->FreePool (BufferImage);
+ }
+
+ return EFI_SUCCESS;
+}
+
+// ****************************************************************************
+// Checkpoint: GetPackageInfo, 1
+// ****************************************************************************
+
+/**
+ This routine:
+ - Calls function with all valid parameters.
+ The function should return EFI_SUCCESS or EFI_UNSUPPORTED.
+ - Checks AttributesSupported has no bits set beyond bit2.
+ - Checks AttributesSetting has no bits set beyond bit2.
+**/
+
+EFI_STATUS
+BBTestGetPackageInfoFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *FirmwareManagement
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_GUID TestGuid;
+ CHAR16 *ResultMessageLabel;
+ CHAR16 *ResultMessageData;
+
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+ UINT32 PackageVersionNameMaxLen;
+ UINT64 AttributesSupported;
+ UINT64 AttributesSetting;
+
+ CHAR16* Attribute[3];
+
+#if (DEBUG_ALL || DEBUG_GET_PACKAGE_INFO)
+
+ CHAR16 *BitField;
+ CHAR16 *BitSetting;
+
+ UINT64 j;
+ UINTN k;
+
+#endif
+
+ //
+ // Init
+ //
+
+ Status = EFI_SUCCESS;
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ TestGuid = gFirmwareManagementBBTestFunctionAssertionGuid003;
+ ResultMessageLabel = L"GetPackageInfo, function checkpoint #1";
+
+ PackageVersionName = NULL;
+
+ Attribute[0] = L"Version Updatable";
+ Attribute[1] = L"Reset Required";
+ Attribute[2] = L"Authentication Required";
+
+ //
+ // Check the data returned by the function
+ //
+
+ Status = FirmwareManagement->GetPackageInfo (
+ FirmwareManagement,
+ &PackageVersion,
+ &PackageVersionName,
+ &PackageVersionNameMaxLen,
+ &AttributesSupported,
+ &AttributesSetting
+ );
+
+ if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ ResultMessageData = L"correctly returned EFI_SUCCESS or EFI_UNSUPPORTED.";
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ ResultMessageData = L"failed to return EFI_SUCCESS or EFI_UNSUPPORTED.";
+ goto Exit;
+ }
+
+#if (DEBUG_ALL || DEBUG_GET_PACKAGE_INFO)
+
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L"Firmware Package Info: \n"
+ L" - *PackageVersion = %08x\n"
+ L" - **PackageVersionName = %s\n"
+ L" - *PackageVersionNameMaxLen = %08x",
+ PackageVersion,
+ PackageVersionName,
+ PackageVersionNameMaxLen
+ );
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L" - *AttributesSupported = %016x\n"
+ L" - *AttributesSetting = %016x",
+ AttributesSupported,
+ AttributesSetting
+ );
+ for (j = 1, k = 0; j <= PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED; j = SctLShiftU64(j, 1), k++) {
+ BitField = Attribute[k];
+ if ((AttributesSupported & j) != j) {
+ BitSetting = L"Not Supported";
+ } else if ((AttributesSetting & j) == j) {
+ BitSetting = L"Yes";
+ } else {
+ BitSetting = L"No";
+ }
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_QUIET,
+ L" - %s = %s",
+ BitField,
+ BitSetting
+ );
+ }
+
+#endif
+
+ if ((AttributesSupported & 0xFFFFFFFFFFFFFFF8) != 0) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ ResultMessageData = L"*AttributesSupported has bit(s) set beyond bit2.";
+ goto Exit;
+ }
+
+ if ((AttributesSetting & 0xFFFFFFFFFFFFFFF8) != 0) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ ResultMessageData = L"*AttributesSetting has bit(s) set beyond bit2.";
+ goto Exit;
+ }
+
+ //
+ // Report the checkpoint result
+ //
+
+Exit:
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ TestGuid,
+ ResultMessageLabel,
+ L"Result - %s\n%a:%d: Status - %r",
+ ResultMessageData,
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ if (PackageVersionName != NULL) {
+ gtBS->FreePool (PackageVersionName);
+ }
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.c
new file mode 100644
index 00000000..3ec928be
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.c
@@ -0,0 +1,168 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2017, Dell Inc. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ FirmwareManagementBBTestMain.c
+
+Abstract:
+
+ Firmware Management Protocol test driver.
+
+--*/
+
+#include "SctLib.h"
+#include "FirmwareManagementBBTestMain.h"
+
+// ****************************************************************************
+// Variables
+// ****************************************************************************
+
+EFI_HANDLE mImageHandle;
+
+EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;
+
+EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_REVISION,
+ IHV_EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID,
+ L"Firmware Management Protocol Test",
+ L"UEFI 2.3 Firmware Management Protocol Black-Box Test"
+};
+
+EFI_GUID gSupportProtocolGuid[] = {
+ EFI_STANDARD_TEST_LIBRARY_GUID,
+ EFI_NULL_GUID
+};
+
+EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
+ {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0101,
+ L"Function_Test-GetImageInfo",
+ L"Function auto test for Firmware Management Protocol GetImageInfo().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetImageInfoFunctionTest
+ },
+ {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0102,
+ L"Function_Test-GetImage",
+ L"Function auto test for Firmware Management Protocol GetImage().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetImageFunctionTest
+ },
+ {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0105,
+ L"Function_Test-GetPackageInfo",
+ L"Function auto test for Firmware Management Protocol GetPackageInfo().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetPackageInfoFunctionTest
+ },
+ {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0201,
+ L"Conformance_Test-GetImageInfo",
+ L"Conformance auto test for Firmware Management Protocol GetImageInfo().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetImageInfoConformanceTest
+ },
+ {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0202,
+ L"Conformance_Test-GetImage",
+ L"Conformance auto test for Firmware Management Protocol GetImage().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetImageConformanceTest
+ },
+ {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0203,
+ L"Conformance_Test-SetImage",
+ L"Conformance auto test for Firmware Management Protocol SetImage().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestSetImageConformanceTest
+ },
+ {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0204,
+ L"Conformance_Test-CheckImage",
+ L"Conformance auto test for Firmware Management Protocol CheckImage().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestCheckImageConformanceTest
+ },
+ {
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0206,
+ L"Conformance_Test-SetPackageInfo",
+ L"Conformance auto test for Firmware Management Protocol SetPackageInfo().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestSetPackageInfoConformanceTest
+ },
+ 0
+};
+
+// ****************************************************************************
+// Initialization and Unload functions
+// ****************************************************************************
+
+
+EFI_STATUS
+EFIAPI
+InitializeFirmwareManagementBBTest (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EfiInitializeTestLib (ImageHandle, SystemTable);
+
+ //
+ // initialize test utility lib
+ //
+
+ SctInitializeLib (ImageHandle, SystemTable);
+
+ mImageHandle = ImageHandle;
+
+ return EfiInitAndInstallIHVBBTestInterface (
+ &ImageHandle,
+ &gBBTestProtocolField,
+ gBBTestEntryField,
+ UnloadFirmwareManagementBBTest,
+ &gBBTestProtocolInterface
+ );
+}
+
+EFI_STATUS
+EFIAPI
+UnloadFirmwareManagementBBTest (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ return EfiUninstallAndFreeIHVBBTestInterface (
+ ImageHandle,
+ gBBTestProtocolInterface
+ );
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.h
new file mode 100644
index 00000000..d21a5f9f
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/FirmwareManagementBBTestMain.h
@@ -0,0 +1,205 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2017, Dell Inc. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ FirmwareManagementBBTestMain.h
+
+Abstract:
+
+ Header file for Firmware Management Protocol test driver.
+
+--*/
+
+#ifndef _FIRMWARE_MANAGEMENT_BB_TEST_MAIN
+#define _FIRMWARE_MANAGEMENT_BB_TEST_MAIN
+
+#include "Efi.h"
+#include "Guid.h"
+#include <Library/EfiTestLib.h>
+
+#include <UEFI/Protocol/FirmwareManagement.h>
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_REVISION 0x00010000
+
+#define IHV_EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID \
+{ 0x941d02a8, 0x49ad, 0x4bda, { 0x9f, 0xae, 0x0a, 0x69, 0x24, 0x54, 0x1c, 0x88 } }
+// ****************************************************************************
+// Entry GUIDs for Function Test
+// ****************************************************************************
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0101 \
+{ 0x7ddddd57, 0x68ff, 0x460e, { 0x90, 0xad, 0xa9, 0xd5, 0xf1, 0xf0, 0xa0, 0x87 } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0102 \
+{ 0x5b4c24b2, 0x852d, 0x418a, { 0x82, 0x34, 0xc2, 0xc8, 0x63, 0x5e, 0x9a, 0x2a } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0103 \
+{ 0x84062e44, 0xdaee, 0x41a5, { 0x94, 0xf8, 0x6d, 0xe0, 0x72, 0x9b, 0xfa, 0xb4 } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0104 \
+{ 0xdeb26021, 0xca4e, 0x4876, { 0x90, 0x99, 0xca, 0x7d, 0x77, 0x2c, 0x90, 0x1d } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0105 \
+{ 0xaa160ecc, 0xfc2f, 0x4f05, { 0xac, 0x20, 0x4c, 0xed, 0x45, 0xde, 0xda, 0xab } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0106 \
+{ 0x7a9a2714, 0xf32b, 0x4083, { 0x90, 0xf2, 0x12, 0x51, 0x1a, 0x87, 0x48, 0x1a } }
+
+// ****************************************************************************
+// Entry GUIDs for Conformance Test
+// ****************************************************************************
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0201 \
+{ 0x54ee347c, 0x10a3, 0x4311, { 0x94, 0x27, 0xa8, 0x97, 0xbf, 0xdc, 0x98, 0x8 } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0202 \
+{ 0x68aba93c, 0x1d0c, 0x412f, { 0xb1, 0xe, 0xe3, 0xa4, 0x6, 0xbc, 0x42, 0xcf } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0203 \
+{ 0x12834a23, 0x6cef, 0x478e, { 0xaf, 0x48, 0x44, 0xe5, 0x93, 0x40, 0xab, 0xe8 } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0204 \
+{ 0xc6dc94b1, 0xb81b, 0x4b85, { 0x8b, 0x7d, 0x8f, 0xbf, 0xa6, 0x8e, 0xf3, 0xe5 } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0205 \
+{ 0x3d13f23d, 0x8306, 0x49d4, { 0xa0, 0xe0, 0x9a, 0x9b, 0xf6, 0x89, 0x40, 0x3c } }
+
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_TEST_ENTRY_GUID0206 \
+{ 0x24cf9ac2, 0x9abc, 0x4f5c, { 0x9c, 0x7a, 0xbc, 0x22, 0x29, 0xc3, 0x2, 0x7f } }
+
+// ****************************************************************************
+// Initializaiton and Unload functions
+// ****************************************************************************
+
+EFI_STATUS
+EFIAPI
+InitializeFirmwareManagementBBTest (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+EFI_STATUS
+EFIAPI
+UnloadFirmwareManagementBBTest (
+ IN EFI_HANDLE ImageHandle
+ );
+
+//
+// Test Cases - Function
+//
+
+EFI_STATUS
+BBTestGetImageInfoFunctionTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestGetImageFunctionTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestSetImageFunctionTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestCheckImageFunctionTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestGetPackageInfoFunctionTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestSetPackageInfoFunctionTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+//
+// Test Cases - Conformance
+//
+
+EFI_STATUS
+BBTestGetImageInfoConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestGetImageConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestSetImageConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestCheckImageConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestGetPackageInfoConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestSetPackageInfoConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+#endif
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.c
new file mode 100644
index 00000000..ce045f23
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.c
@@ -0,0 +1,83 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2012, Dell Inc. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+ Module Name:
+
+ Guid.c
+
+ Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+#include "Efi.h"
+#include "Guid.h"
+
+// ****************************************************************************
+// Function
+// ****************************************************************************
+
+EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid001=EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_001_GUID;
+
+EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid002=EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_002_GUID;
+
+EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid003=EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_003_GUID;
+
+// ****************************************************************************
+// Conformance
+// ****************************************************************************
+
+EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid001=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_001_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid002=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_002_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid003=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_003_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid004=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_004_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid001=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_001_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid002=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_002_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid003=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_003_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid004=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_004_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid005=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_005_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid006=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_006_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid007=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_007_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid008=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_008_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid009=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_009_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid010=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_010_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid011=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_011_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid012=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_012_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid013=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_013_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid014=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_014_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid015=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_015_GUID;
+
+EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid016=EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_016_GUID;
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.h
new file mode 100644
index 00000000..e26cf7dd
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/Guid.h
@@ -0,0 +1,153 @@
+/** @file
+
+ Copyright 2006 - 2010 Unified EFI, Inc.<BR>
+ Copyright (c) 2010, Dell Inc. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+ Module Name:
+
+ Guid.h
+
+ Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+// ****************************************************************************
+// Function
+// ****************************************************************************
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_001_GUID \
+{ 0xd02b40ae, 0x62f, 0x4155, { 0xbb, 0xdd, 0x4, 0x29, 0x18, 0x94, 0xea, 0x31 } }
+
+extern EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid001;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_002_GUID \
+{ 0xff704c46, 0x3999, 0x4a28, { 0xa3, 0x6e, 0x76, 0x8a, 0xb6, 0xad, 0x89, 0xd8 } }
+
+extern EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid002;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTFUNCTION_ASSERTION_003_GUID \
+{ 0x70884539, 0x9a34, 0x4146, { 0x83, 0x3a, 0x4d, 0x89, 0x8b, 0x9c, 0x7e, 0xa4 } }
+
+extern EFI_GUID gFirmwareManagementBBTestFunctionAssertionGuid003;
+
+// ****************************************************************************
+// Conformance - Function Support Check
+// ****************************************************************************
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_001_GUID \
+{ 0xd9c7d018, 0x60ba, 0x448d, { 0xb1, 0x3b, 0x88, 0x8b, 0x41, 0xd9, 0xdc, 0x9 } };
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid001;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_002_GUID \
+{ 0x28310f16, 0x690e, 0x44a5, { 0x93, 0x98, 0xe1, 0xcd, 0x6a, 0xb3, 0xe1, 0x61 } };
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid002;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_003_GUID \
+{ 0x92cc940a, 0xdcf8, 0x42a0, { 0x81, 0xa1, 0xd7, 0xdd, 0x43, 0x87, 0xbf, 0x6d } };
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid003;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_SUPPORT_004_GUID \
+{ 0x3f910041, 0xcd4d, 0x4b36, { 0xb2, 0x23, 0xfb, 0x16, 0x4e, 0x7e, 0x6a, 0x8c } };
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceSupportGuid004;
+
+// ****************************************************************************
+// Conformance - Assertion
+// ****************************************************************************
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_001_GUID \
+{ 0x3789b80e, 0xab70, 0x4dc9, { 0xbb, 0xbd, 0x70, 0x63, 0x76, 0x36, 0xab, 0x52 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid001;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_002_GUID \
+{ 0xca1d7706, 0x256b, 0x464e, { 0xb6, 0xee, 0x50, 0x34, 0x1e, 0xec, 0x3c, 0x83 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid002;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_003_GUID \
+{ 0x3c8d87b2, 0x6a89, 0x4a6c, { 0xbc, 0x75, 0xe6, 0x86, 0xa1, 0x49, 0x13, 0xf0 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid003;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_004_GUID \
+{ 0x88031c96, 0x99bf, 0x4d2c, { 0x9f, 0x57, 0xa7, 0x2, 0x6a, 0xbc, 0xd3, 0x51 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid004;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_005_GUID \
+{ 0x7a386361, 0x3a5d, 0x4e58, { 0x8a, 0x51, 0x4d, 0x93, 0xb6, 0x55, 0x95, 0xf4 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid005;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_006_GUID \
+{ 0xd6a77629, 0x5afd, 0x4854, { 0x87, 0xc8, 0xee, 0x9f, 0xc5, 0x3d, 0xbe, 0x3d } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid006;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_007_GUID \
+{ 0x4ea24764, 0xa6b1, 0x43b5, { 0xb8, 0xa0, 0xd3, 0x3f, 0xdc, 0x8b, 0xc6, 0xe4 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid007;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_008_GUID \
+{ 0x712ce1e9, 0x80d1, 0x4168, { 0xb8, 0xd0, 0x74, 0xd1, 0x72, 0x7a, 0x2f, 0x25 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid008;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_009_GUID \
+{ 0xc82d1373, 0x1f87, 0x45f4, { 0xaf, 0xfc, 0x10, 0xa7, 0xf7, 0xb0, 0x9c, 0xb0 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid009;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_010_GUID \
+{ 0x2410a859, 0xdf6f, 0x4857, { 0x92, 0x4a, 0x26, 0x37, 0x7, 0x11, 0xf, 0x1c } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid010;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_011_GUID \
+{ 0x3987172c, 0xe6a0, 0x4099, { 0xb1, 0x2b, 0xd8, 0xef, 0xf2, 0x62, 0x75, 0x93 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid011;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_012_GUID \
+{ 0xd6dad28e, 0x7f0f, 0x4f56, { 0x9a, 0x93, 0x14, 0x7d, 0xb3, 0x74, 0x0, 0xc9 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid012;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_013_GUID \
+{ 0xb5288fc3, 0xe906, 0x4468, { 0x83, 0x3d, 0xd4, 0xa6, 0x58, 0xa5, 0x4f, 0xbd } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid013;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_014_GUID \
+{ 0x57355301, 0x1343, 0x497f, { 0xbe, 0xe0, 0x8e, 0x5c, 0x27, 0xd2, 0x40, 0x25 } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid014;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_015_GUID \
+{ 0xadeab82d, 0x7592, 0x40fe, { 0x87, 0xa8, 0x93, 0x2b, 0xad, 0x97, 0xff, 0x5e } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid015;
+
+#define EFI_TEST_FIRMWAREMANAGEMENTBBTESTCONFORMANCE_ASSERTION_016_GUID \
+{ 0x9be658d2, 0x1312, 0x4254, { 0x91, 0x10, 0x59, 0x0, 0xd5, 0xfd, 0x6c, 0x6c } }
+
+extern EFI_GUID gFirmwareManagementBBTestConformanceAssertionGuid016;
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/IhvFirmwareManagementBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/IhvFirmwareManagementBBTest.inf
new file mode 100644
index 00000000..f2de4cea
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/FirmwareManagement/BlackBoxTest/IhvFirmwareManagementBBTest.inf
@@ -0,0 +1,52 @@
+## @file
+#
+# Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+# Copyright (c) 2010 - 2012, Dell Inc. All rights reserved.<BR>
+# Copyright (c) 2019,Microchip Technology Inc.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+#/*++
+#
+# Module Name:
+#
+# FirmwareManagementBBTest.inf
+#
+# Abstract:
+#
+# Component description file for IHV Firmware Management Protocol Black-Box Test.
+#
+#--*/
+
+[defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = IhvFirmwareManagementBBTest
+ FILE_GUID = DB0E842F-201B-4D47-BA74-88602A41C9D2
+ MODULE_TYPE = UEFI_DRIVER
+ COMPONENT_TYPE = BS_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeFirmwareManagementBBTest
+
+[sources.common]
+ FirmwareManagementBBTestConformance.c
+ FirmwareManagementBBTestFunction.c
+ FirmwareManagementBBTestMain.c
+ Guid.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SctPkg/SctPkg.dec
+ SctPkg/UEFI/UEFI.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ SctLib
+ EfiTestLib
+
+[Protocols]
--
2.22.0.windows.1


[edk2-test][PATCH V3 1/3] Adding HII Config Access Protocol

shrishail
 

From: Shrishail Patil <Shrishail.Patil@...>

Adding HII Config Access Protocol to IHVSCT
This patch contains source code which is copied from
UEFISCT and added into IHVSCT.
Addressed the review comments relating to commented code removal.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shrishail patil <shrishail.patil@...>
---
.../HIIConfigAccess/BlackBoxTest/Guid.c | 49 ++
.../HIIConfigAccess/BlackBoxTest/Guid.h | 82 +++
.../HIIConfigAccessBBTestConformance.c | 619 +++++++++++++++++
.../HIIConfigAccessBBTestFunction.c | 447 +++++++++++++
.../BlackBoxTest/HIIConfigAccessBBTestMain.c | 621 ++++++++++++++++++
.../BlackBoxTest/HIIConfigAccessBBTestMain.h | 144 ++++
.../BlackBoxTest/IhvHIIConfigAccessBBTest.inf | 55 ++
7 files changed, 2017 insertions(+)
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
HIIConfigAccess/BlackBoxTest/Guid.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
HIIConfigAccess/BlackBoxTest/Guid.h
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestFunction.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/
HIIConfigAccess/BlackBoxTest/IhvHIIConfigAccessBBTest.inf

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/Guid.c
new file mode 100644
index 00000000..6ebdd442
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/Guid.c
@@ -0,0 +1,49 @@
+/** @file
+
+ Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+ Module Name:
+
+ Guid.c
+
+ Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+#include "HIIConfigAccessBBTestMain.h"
+
+EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid001=EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_001_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid002=EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_002_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid003=EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_003_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid004=EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_004_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid005=EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_005_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid006=EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_006_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid007=EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_007_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestFunctionAssertionGuid001=EFI_TEST_HIICONFIGACCESSBBTESTFUNCTION_ASSERTION_001_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestFunctionAssertionGuid002=EFI_TEST_HIICONFIGACCESSBBTESTFUNCTION_ASSERTION_002_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestFunctionAssertionGuid003=EFI_TEST_HIICONFIGACCESSBBTESTFUNCTION_ASSERTION_003_GUID;
+
+EFI_GUID gHIIConfigAccessBBTestFunctionAssertionGuid004=EFI_TEST_HIICONFIGACCESSBBTESTFUNCTION_ASSERTION_004_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/Guid.h
new file mode 100644
index 00000000..0e29f08d
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/Guid.h
@@ -0,0 +1,82 @@
+/** @file
+
+ Copyright 2006 - 2011 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+ Module Name:
+
+ Guid.h
+
+ Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_001_GUID \
+{ 0xa7173eb5, 0xf76a, 0x4ea1, { 0x95, 0xd, 0x14, 0x91, 0x1e, 0x49, 0x86, 0xc1 } }
+
+extern EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid001;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_002_GUID \
+{ 0xfa5973e2, 0xd05, 0x44c2, { 0xaf, 0x2d, 0x1b, 0x68, 0x33, 0x42, 0x6d, 0x76 } }
+
+extern EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid002;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_003_GUID \
+{ 0x6f6d1dd, 0x49b8, 0x488a, { 0xa7, 0x75, 0xde, 0xbc, 0xc7, 0x60, 0xfd, 0x28 } }
+
+extern EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid003;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_004_GUID \
+{ 0x28652613, 0x6bf4, 0x4f42, { 0xab, 0xe2, 0x84, 0x4f, 0x2f, 0x77, 0xec, 0x2f } }
+
+extern EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid004;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_005_GUID \
+{ 0xebba197a, 0x467f, 0x4736, { 0x92, 0xf2, 0x11, 0xb1, 0x91, 0x2e, 0xe9, 0x90 } }
+
+
+extern EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid005;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_006_GUID \
+{ 0x341fe3e0, 0xf688, 0x45f2, { 0x91, 0x56, 0xc7, 0xae, 0x9f, 0x2c, 0xcb, 0xb0 } }
+
+extern EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid006;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTCONFORMANCE_ASSERTION_007_GUID \
+{ 0x1f99ebc8, 0x253, 0x455f, { 0x88, 0xac, 0x9e, 0x2b, 0xa6, 0xdc, 0xd7, 0x29 } }
+
+extern EFI_GUID gHIIConfigAccessBBTestConformanceAssertionGuid007;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTFUNCTION_ASSERTION_001_GUID \
+{ 0x24dcf8bf, 0xbfbf, 0x4588, { 0xba, 0xf, 0x77, 0x1e, 0x24, 0x4e, 0x3e, 0x8 } }
+
+extern EFI_GUID gHIIConfigAccessBBTestFunctionAssertionGuid001;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTFUNCTION_ASSERTION_002_GUID \
+{ 0x961a5268, 0x1998, 0x4a7e, { 0x9d, 0x9d, 0xce, 0xdc, 0x67, 0xfb, 0xcc, 0x77 } }
+
+extern EFI_GUID gHIIConfigAccessBBTestFunctionAssertionGuid002;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTFUNCTION_ASSERTION_003_GUID \
+{ 0x603e52f0, 0x2ce3, 0x4e7a, { 0xa7, 0x2e, 0xdf, 0x8c, 0xa3, 0xfd, 0xb2, 0xd } }
+
+extern EFI_GUID gHIIConfigAccessBBTestFunctionAssertionGuid003;
+
+#define EFI_TEST_HIICONFIGACCESSBBTESTFUNCTION_ASSERTION_004_GUID \
+{ 0xab163674, 0x6c27, 0x4169, { 0xa6, 0xa9, 0xe1, 0x9c, 0x88, 0x14, 0x94, 0x96 } }
+
+extern EFI_GUID gHIIConfigAccessBBTestFunctionAssertionGuid004;
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c
new file mode 100644
index 00000000..12712be3
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c
@@ -0,0 +1,619 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ HIIConfigAccessBBTestConformance.c
+
+Abstract:
+ for EFI Driver HII Configuration Access Protocol's conformance Test
+
+--*/
+
+#include "HIIConfigAccessBBTestMain.h"
+
+EFI_BROWSER_ACTION EFI_BROWSER_ACTION_UNSUPPORTED = 2;
+
+EFI_STATUS
+BBTestExtractConfigConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestExtractConfigConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestExtractConfigConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestExtractConfigConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestRouteConfigConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestRouteConfigConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestRouteConfigConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestExtractConfigConformanceTest (
+ 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;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting;
+
+ //
+ // init
+ //
+ HIIConfigAccess = (EFI_HII_CONFIG_ACCESS_PROTOCOL*)ClientInterface;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Get the Config Routing Protocol Interface
+ //
+ Status = GetHIIConfigRoutingInterface( &HIIConfigRouting );
+ if ( EFI_ERROR(Status) ) {
+ return Status;
+ }
+
+ //
+ //Call check points
+ //
+ BBTestExtractConfigConformanceTestCheckpoint1( StandardLib, HIIConfigAccess );
+ BBTestExtractConfigConformanceTestCheckpoint2( StandardLib, HIIConfigRouting, HIIConfigAccess );
+ BBTestExtractConfigConformanceTestCheckpoint3( StandardLib, HIIConfigRouting, HIIConfigAccess );
+ BBTestExtractConfigConformanceTestCheckpoint4( StandardLib, HIIConfigAccess );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestRouteConfigConformanceTest (
+ 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;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting;
+
+ //
+ // init
+ //
+ HIIConfigAccess = (EFI_HII_CONFIG_ACCESS_PROTOCOL*)ClientInterface;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Get the Config Routing Protocol Interface
+ //
+ Status = GetHIIConfigRoutingInterface( &HIIConfigRouting );
+ if ( EFI_ERROR(Status) ) {
+ return Status;
+ }
+
+ //
+ //Call check points
+ //
+ BBTestRouteConfigConformanceTestCheckpoint1( StandardLib, HIIConfigAccess );
+ BBTestRouteConfigConformanceTestCheckpoint2( StandardLib, HIIConfigRouting, HIIConfigAccess );
+ BBTestRouteConfigConformanceTestCheckpoint3( StandardLib, HIIConfigAccess );
+
+ return EFI_SUCCESS;
+}
+
+//
+//Check Points
+//
+
+EFI_STATUS
+BBTestExtractConfigConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Progress = NULL;
+ EFI_STRING Results = NULL;
+ EFI_STRING ResultsPtr = NULL;
+ UINTN Len = 0;
+ CHAR16* Pointer = NULL;
+ UINT8 IfMulti = 0;
+
+ EFI_STRING Request = NULL;
+ //
+ // Call ExtractConfig with Request been <MultiConfigRequest>
+ //
+ Status = HIIConfigAccess->ExtractConfig (
+ HIIConfigAccess,
+ NULL,
+ &Progress,
+ &Results
+ );
+
+ if ( Status == EFI_SUCCESS ) {
+ Len = SctStrLen (Results);
+ //
+ // Make sure the size of Request is enough to hold <MultiConfigRequest>
+ // if original Results is not Multi
+ //
+ Request = (EFI_STRING) SctAllocateZeroPool ( 2 * Len + 2 + 256);
+ if (Request == NULL) {
+ SctFreePool (Results);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ } else {
+ return Status;
+ }
+
+ Status = MultiAltRespToMultiReq (Results, Request);
+ ResultsPtr = Request;
+
+ SctFreePool (Results);
+ Results = NULL;
+
+ if ( SctStrStr (Request, L"GUID=") != NULL ) {
+ Pointer = SctStrStr (Request, L"GUID=");
+ Pointer++;
+ if ( SctStrStr (Pointer, L"GUID=") != NULL )
+ IfMulti = 1;
+ }
+
+ if ( IfMulti == 0 ) {
+ SctStrCat ( Request, L"&GUID=970eb94aa0d449f7b980bdaa47d42527&NAME=006a0069006e0039&PATH=000acf&grag&star");
+ }
+
+ Status = HIIConfigAccess->ExtractConfig (
+ HIIConfigAccess,
+ Request,
+ &Progress,
+ &Results
+ );
+
+ if ( (EFI_INVALID_PARAMETER != Status) || (SctStrnCmp (Progress, L"&GUID=", 6) != 0) ) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestConformanceAssertionGuid001,
+ L"HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig - ExtractConfig() returns EFI_INVALID_PARAMETER with Request been <MultiConfigRequest>.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ SctFreePool (Request);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestExtractConfigConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Request = NULL;
+ EFI_STRING Results = NULL;
+ EFI_STRING MultiConfigAltResp = NULL;
+ EFI_STRING DevicePath = NULL;
+
+ //init the Request
+ Status = HIIConfigRouting->ExportConfig(
+ HIIConfigRouting,
+ &MultiConfigAltResp
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ Status = GetDevicePath ( HIIConfigAccess, &DevicePath );
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ return Status;
+ }
+
+ Request = (EFI_STRING) SctAllocateZeroPool ( 2 * SctStrLen (MultiConfigAltResp) + 2 );
+ if (Request == NULL) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = GetCorrespondingRequest (MultiConfigAltResp, DevicePath, Request);
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Request);
+ return Status;
+ }
+
+ //
+ // Call ExtractConfig with Progress been NULL
+ //
+ Status = HIIConfigAccess->ExtractConfig (
+ HIIConfigAccess,
+ Request,
+ NULL,
+ &Results
+ );
+
+ if ( EFI_INVALID_PARAMETER != Status ) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestConformanceAssertionGuid002,
+ L"HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig - ExtractConfig() returns EFI_INVALID_PARAMETER with Progress been NULL.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Request);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestExtractConfigConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Request = NULL;
+ EFI_STRING Progress = NULL;
+ EFI_STRING MultiConfigAltResp = NULL;
+ EFI_STRING DevicePath = NULL;
+
+ //init the Request
+ Status = HIIConfigRouting->ExportConfig(
+ HIIConfigRouting,
+ &MultiConfigAltResp
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ Status = GetDevicePath ( HIIConfigAccess, &DevicePath );
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ return Status;
+ }
+
+ Request = (EFI_STRING) SctAllocateZeroPool ( 2 * SctStrLen (MultiConfigAltResp) + 2 );
+ if (Request == NULL) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = GetCorrespondingRequest (MultiConfigAltResp, DevicePath, Request);
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Request);
+ return Status;
+ }
+ //
+ // Call ExtractConfig with Results been NULL
+ //
+ Status = HIIConfigAccess->ExtractConfig (
+ HIIConfigAccess,
+ Request,
+ &Progress,
+ NULL
+ );
+
+ if ( EFI_INVALID_PARAMETER != Status ) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestConformanceAssertionGuid003,
+ L"HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig - ExtractConfig() returns EFI_INVALID_PARAMETER with Results been NULL.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Request);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestExtractConfigConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Request;
+ EFI_STRING Progress = NULL;
+ EFI_STRING Results = NULL;
+
+ //init the Request
+ Request = L"GUID=71e430fb2e8849779d7a33ef1139e7ed&NAME=006a0069006e0039&PATH=000acf&Jack&Rons&Nash&Mary";
+
+ //
+ // Call ExtractConfig with unknown name
+ //
+ Status = HIIConfigAccess->ExtractConfig (
+ HIIConfigAccess,
+ Request,
+ &Progress,
+ &Results
+ );
+
+ if ( ((EFI_INVALID_PARAMETER == Status) && (SctStrnCmp (Progress, L"&Jack&Rons&Nash&Mary", 20) == 0)) ||
+ ((EFI_NOT_FOUND == Status) && (Progress == Request)) ) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestConformanceAssertionGuid004,
+ L"HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig - ExtractConfig() returns EFI_INVALID_PARAMETER/EFI_NOT_FOUND with invalid input.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ return EFI_SUCCESS;
+ }
+
+
+EFI_STATUS
+BBTestRouteConfigConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Progress = NULL;
+
+
+ //
+ // Call RouteConfig with Configuration been NULL
+ //
+ Status = HIIConfigAccess->RouteConfig (
+ HIIConfigAccess,
+ NULL,
+ &Progress
+ );
+
+ if ( EFI_INVALID_PARAMETER != Status ) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestConformanceAssertionGuid005,
+ L"HII_CONFIG_ACCESS_PROTOCOL.RouteConfig - RouteConfig() returns EFI_INVALID_PARAMETER with Configuration been NULL.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ return EFI_SUCCESS;
+ }
+
+EFI_STATUS
+BBTestRouteConfigConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Config = NULL;
+ EFI_STRING MultiConfigAltResp = NULL;
+ EFI_STRING DevicePath = NULL;
+
+ //init the Request
+ Status = HIIConfigRouting->ExportConfig(
+ HIIConfigRouting,
+ &MultiConfigAltResp
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ Status = GetDevicePath ( HIIConfigAccess, &DevicePath );
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ return Status;
+ }
+
+ Config = (EFI_STRING) SctAllocateZeroPool ( 2 * SctStrLen (MultiConfigAltResp) + 2 );
+ if (Config == NULL) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = GetCorrespondingResp (MultiConfigAltResp, DevicePath, Config);
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Config);
+ return Status;
+ }
+
+ //
+ // Call RouteConfig with Progress been NULL
+ //
+ Status = HIIConfigAccess->RouteConfig (
+ HIIConfigAccess,
+ Config,
+ NULL
+ );
+
+ if ( EFI_INVALID_PARAMETER != Status ) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestConformanceAssertionGuid006,
+ L"HII_CONFIG_ACCESS_PROTOCOL.RouteConfig - RouteConfig() returns EFI_INVALID_PARAMETER with Progress been NULL.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Config);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestRouteConfigConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Configuration;
+ EFI_STRING Progress = NULL;
+
+ //init the Configuration
+ Configuration=L"GUID=71e430fb2e8849779d7a33ef1139e7ed&NAME=006a0069006e0039&PATH=0acf&OFFSET=2&WIDTH=3VALUE=45AF";
+
+ //
+ // Call RouteConfig with no found target for the routing data
+ //
+ Status = HIIConfigAccess->RouteConfig (
+ HIIConfigAccess,
+ Configuration,
+ &Progress
+ );
+
+ if ( EFI_NOT_FOUND != Status ) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestConformanceAssertionGuid007,
+ L"HII_CONFIG_ACCESS_PROTOCOL.RouteConfig - RouteConfig() returns EFI_NOT_FOUND with no found target for the routing data.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestFunction.c
new file mode 100644
index 00000000..29109f40
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestFunction.c
@@ -0,0 +1,447 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ HIIConfigAccessBBTestFunction.c
+
+Abstract:
+ for EFI Driver HII Configuration Access Protocol's function Test
+
+--*/
+
+#include "HIIConfigAccessBBTestMain.h"
+
+
+EFI_STATUS
+BBTestExtractConfigFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestExtractConfigFunctionTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestRouteConfigFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ );
+
+EFI_STATUS
+BBTestExtractConfigFunctionTest (
+ 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;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting;
+
+ //
+ // init
+ //
+ HIIConfigAccess = (EFI_HII_CONFIG_ACCESS_PROTOCOL*)ClientInterface;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Get the Config Routing Protocol Interface
+ //
+ Status = GetHIIConfigRoutingInterface( &HIIConfigRouting );
+ if ( EFI_ERROR(Status) ) {
+ return Status;
+ }
+
+ //
+ //Call check points
+ //
+ BBTestExtractConfigFunctionTestCheckpoint1( StandardLib, HIIConfigRouting, HIIConfigAccess );
+ BBTestExtractConfigFunctionTestCheckpoint2( StandardLib, HIIConfigRouting, HIIConfigAccess );
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestRouteConfigFunctionTest (
+ 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;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting;
+
+ //
+ // init
+ //
+ HIIConfigAccess = (EFI_HII_CONFIG_ACCESS_PROTOCOL*)ClientInterface;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Get the Config Routing Protocol Interface
+ //
+ Status = GetHIIConfigRoutingInterface( &HIIConfigRouting );
+ if ( EFI_ERROR(Status) ) {
+ return Status;
+ }
+
+ //
+ //Call check points
+ //
+ BBTestRouteConfigFunctionTestCheckpoint1( StandardLib, HIIConfigRouting, HIIConfigAccess );
+
+ return EFI_SUCCESS;
+}
+
+//
+//Check Points
+//
+EFI_STATUS
+BBTestExtractConfigFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Request = NULL;
+ EFI_STRING ConfigHdr = NULL;
+ EFI_STRING Progress = NULL;
+ EFI_STRING Results = NULL;
+ EFI_STRING MultiConfigAltResp = NULL;
+ EFI_STRING DevicePath = NULL;
+
+
+ //init the Request
+ Status = HIIConfigRouting->ExportConfig(
+ HIIConfigRouting,
+ &MultiConfigAltResp
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ Status = GetDevicePath ( HIIConfigAccess, &DevicePath );
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ return Status;
+ }
+
+ Request = (EFI_STRING) SctAllocateZeroPool ( 2 * SctStrLen (MultiConfigAltResp) + 2 );
+ if (Request == NULL) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = GetCorrespondingRequest (MultiConfigAltResp, DevicePath, Request);
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Request);
+ return Status;
+ }
+
+ //
+ // Call ExtractConfig with valid parameters
+ //
+ Status = HIIConfigAccess->ExtractConfig(
+ HIIConfigAccess,
+ Request,
+ &Progress,
+ &Results
+ );
+
+ if ( (EFI_SUCCESS == Status) && (Progress == (Request + SctStrLen (Request))) ) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ if (Results == NULL) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ gtBS->FreePool (Results);
+ }
+ } else if (EFI_OUT_OF_RESOURCES == Status) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ }else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestFunctionAssertionGuid001,
+ L"HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig- ExtractConfig() returns EFI_SUCCESS and vaild Results with valid parameters .",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Change the Request to ConfigHdr
+ //
+ ConfigHdr = Request;
+ while (*Request) {
+ if (*Request == L'&') {
+ if (SctStrnCmp (Request, L"&NAME=", 6) == 0) {
+ Request = Request + 6;
+ } else if (SctStrnCmp (Request, L"&PATH=", 6) == 0) {
+ Request = Request + 6;
+ } else {
+ *Request = 0;
+ }
+ } else {
+ Request++;
+ }
+ }
+ Request = ConfigHdr;
+
+ //
+ // Call ExtractConfig when Request is ConfigHdr
+ //
+ Progress = NULL;
+ Results = NULL;
+ Status = HIIConfigAccess->ExtractConfig(
+ HIIConfigAccess,
+ Request,
+ &Progress,
+ &Results
+ );
+
+ if ( (EFI_SUCCESS == Status) && (Progress == (Request + SctStrLen (Request))) ) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ if (Results == NULL) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ if (NULL == SctStrStr (Results, Request)) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+ gtBS->FreePool (Results);
+ }
+ } else if (EFI_OUT_OF_RESOURCES == Status) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ }else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestFunctionAssertionGuid002,
+ L"HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig- ExtractConfig() returns EFI_SUCCESS and vaild Results with valid parameters .",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Request);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestExtractConfigFunctionTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Request = NULL;
+ EFI_STRING Progress = NULL;
+ EFI_STRING Results = NULL;
+ EFI_STRING MultiConfigAltResp = NULL;
+
+
+ //init the Request
+ Status = HIIConfigRouting->ExportConfig(
+ HIIConfigRouting,
+ &MultiConfigAltResp
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Call ExtractConfig with valid parameters
+ //
+ Status = HIIConfigAccess->ExtractConfig(
+ HIIConfigAccess,
+ NULL,
+ &Progress,
+ &Results
+ );
+
+ if (EFI_OUT_OF_RESOURCES == Status) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ } else if ((EFI_NOT_FOUND == Status) && (Progress == NULL) && (Results == NULL)) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else if ( EFI_SUCCESS != Status ) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ if (Results != NULL) {
+ gtBS->FreePool (Results);
+ }
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ if (Results == NULL) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestFunctionAssertionGuid003,
+ L"HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig- ExtractConfig() returns EFI_SUCCESS or EFI_NOT_FOUND with Request been NULL .",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+
+ if ( NULL != MultiConfigAltResp ){
+ gtBS->FreePool (MultiConfigAltResp);
+ }
+
+ if ( NULL !=Results ) {
+ gtBS->FreePool (Results);
+ }
+
+ if (NULL != Request) {
+ gtBS->FreePool (Request);
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestRouteConfigFunctionTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting,
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION AssertionType;
+
+ EFI_STRING Resp = NULL;
+ EFI_STRING Progress = NULL;
+ EFI_STRING MultiConfigAltResp = NULL;
+ EFI_STRING DevicePath = NULL;
+
+ //init the Request
+ Status = HIIConfigRouting->ExportConfig(
+ HIIConfigRouting,
+ &MultiConfigAltResp
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ Status = GetDevicePath ( HIIConfigAccess, &DevicePath );
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ return Status;
+ }
+
+ Resp = (EFI_STRING) SctAllocateZeroPool ( 2 * SctStrLen (MultiConfigAltResp) + 2 );
+ if (Resp == NULL) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = GetCorrespondingResp (MultiConfigAltResp, DevicePath, Resp);
+ if (EFI_ERROR(Status)) {
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Resp);
+ return Status;
+ }
+
+ //
+ // Call RouteConfig with valid parameters
+ //
+ Status = HIIConfigAccess->RouteConfig(
+ HIIConfigAccess,
+ Resp,
+ &Progress
+ );
+ if ( (EFI_SUCCESS == Status) && (Progress == Resp + SctStrLen (Resp)) ) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else if ( EFI_OUT_OF_RESOURCES == Status ) {
+ AssertionType = EFI_TEST_ASSERTION_WARNING;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gHIIConfigAccessBBTestFunctionAssertionGuid003,
+ L"HII_CONFIG_ACCESS_PROTOCOL.RouteConfig- RouteConfig() returns EFI_SUCCESS with valid parameters .",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ gtBS->FreePool (MultiConfigAltResp);
+ gtBS->FreePool (DevicePath);
+ gtBS->FreePool (Resp);
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c
new file mode 100644
index 00000000..470f51ee
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c
@@ -0,0 +1,621 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ HIIConfigAccessBBTestMain.c
+
+Abstract:
+
+ Test Driver of HII Configuration Access Protocol
+
+--*/
+
+#include "HIIConfigAccessBBTestMain.h"
+
+//
+// Global variables
+//
+EFI_HANDLE mImageHandle;
+
+EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;
+
+EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = {
+ EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_REVISION,
+ IHV_EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID,
+ L"HII Configuration Access Protocol Test",
+ L"UEFI HII Configuration Access Protocol Black-Box Test"
+};
+
+EFI_GUID gSupportProtocolGuid[] = {
+ EFI_STANDARD_TEST_LIBRARY_GUID,
+ EFI_NULL_GUID
+};
+
+EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
+ {
+ EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_ENTRY_GUID0101,
+ L"ExtractConfigFunction",
+ L"Function auto test for HII Configuration Access Protocol ExtractConfig().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestExtractConfigFunctionTest
+ },
+
+ {
+ EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_ENTRY_GUID0102,
+ L"RouteConfigFunction",
+ L"Function auto test for HII Configuration Access Protocol RouteConfig().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestRouteConfigFunctionTest
+ },
+ {
+ EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_ENTRY_GUID0201,
+ L"ExtractConfigConformance",
+ L"Conformance auto test for HII Configuration Access Protocol ExtractConfig().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestExtractConfigConformanceTest
+ },
+ {
+ EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_ENTRY_GUID0202,
+ L"RouteConfigConformance",
+ L"Conformance auto test for HII Configuration Access Protocol RouteConfig().",
+ EFI_TEST_LEVEL_MINIMAL,
+ gSupportProtocolGuid,
+ EFI_TEST_CASE_AUTO,
+ BBTestRouteConfigConformanceTest
+ },
+ 0
+};
+
+
+
+
+EFI_STATUS
+InitializeHIIConfigAccessBBTest (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EfiInitializeTestLib (ImageHandle, SystemTable);
+
+ //
+ // initialize test utility lib
+ //
+
+ SctInitializeLib (ImageHandle, SystemTable);
+
+ mImageHandle = ImageHandle;
+
+ return EfiInitAndInstallIHVBBTestInterface (
+ &ImageHandle,
+ &gBBTestProtocolField,
+ gBBTestEntryField,
+ UnloadHIIConfigAccessBBTest,
+ &gBBTestProtocolInterface
+ );
+}
+
+
+EFI_STATUS
+UnloadHIIConfigAccessBBTest (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ return EfiUninstallAndFreeIHVBBTestInterface (
+ ImageHandle,
+ gBBTestProtocolInterface
+ );
+}
+
+
+// Assistance Function
+UINTN
+EfiDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Calculate the space size of a device path.
+
+Arguments:
+
+ DevicePath - A specified device path
+
+Returns:
+
+ The size.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Start;
+
+ if (DevicePath == NULL) {
+ return 0;
+ }
+
+ //
+ // Search for the end of the device path structure
+ //
+ Start = DevicePath;
+ while (!SctIsDevicePathEnd (DevicePath)) {
+ DevicePath = SctNextDevicePathNode (DevicePath);
+ }
+
+ //
+ // Compute the size and add back in the size of the end device path structure
+ //
+ return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+}
+
+
+STATIC
+CHAR16
+NibbleToHexCharPrivate (
+ IN UINT8 Nibble
+ )
+/*++
+
+ Routine Description:
+ Converts the low nibble of a byte to hex unicode character.
+
+ Arguments:
+ Nibble - lower nibble of a byte.
+
+ Returns:
+ Hex unicode character between L'0' to L'f'.
+
+--*/
+{
+ Nibble &= 0x0F;
+
+ if (Nibble <= 0x9) {
+ return (CHAR16)(Nibble + L'0');
+ }
+
+ return (CHAR16)(Nibble - 0xA + L'a');
+}
+
+
+STATIC
+EFI_STATUS
+BufToHexStringPrivate (
+ IN OUT CHAR16 *Str,
+ IN OUT UINTN *HexStringBufferLength,
+ IN UINT8 *Buf,
+ IN UINTN Len,
+ IN BOOLEAN Flag
+ )
+/*++
+
+ Routine Description:
+ Converts binary buffer to Unicode string.
+ At a minimum, any blob of data could be represented as a hex string.
+
+ Arguments:
+ Str - Pointer to the string.
+ HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
+ If routine return with EFI_SUCCESS, containing length of hex string buffer.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
+ Buf - Buffer to be converted from.
+ Len - Length in bytes of the buffer to be converted.
+ Flag - If TRUE, encode the data in the same order as the it
+ resides in the Buf. Else encode it in the reverse direction.
+
+ Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The hex string buffer is too small.
+
+--*/
+{
+ UINTN Idx;
+ UINT8 Byte;
+ UINTN StrLen;
+
+ //
+ // Make sure string is either passed or allocate enough.
+ // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
+ // Plus the Unicode termination character.
+ //
+ StrLen = Len * 2;
+ if ((*HexStringBufferLength) < (StrLen + 1) * sizeof (CHAR16)) {
+ *HexStringBufferLength = (StrLen + 1) * sizeof (CHAR16);
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *HexStringBufferLength = (StrLen + 1) * sizeof (CHAR16);
+
+ //
+ // Ends the string.
+ //
+ Str[StrLen] = 0;
+
+ for (Idx = 0; Idx < Len; Idx++) {
+
+ Byte = Buf[Idx];
+ if (Flag) {
+ Str[Idx * 2] = NibbleToHexCharPrivate ((UINT8)(Byte >> 4));
+ Str[Idx * 2 + 1] = NibbleToHexCharPrivate (Byte);
+ } else {
+ Str[StrLen - 1 - Idx * 2] = NibbleToHexCharPrivate (Byte);
+ Str[StrLen - 2 - Idx * 2] = NibbleToHexCharPrivate ((UINT8)(Byte >> 4));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetDevicePath (
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,
+ OUT EFI_STRING *DevicePathStr
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN NoHandles;
+ EFI_HANDLE *HandleBuffer;
+ EFI_HANDLE ConfigAccessHandle = NULL;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *TestedConfigAccess;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN Length;
+ UINTN PathHdrSize;
+
+ //
+ // locate all Hii Configuration Access Protocol Instances
+ //
+ Status = gtBS->LocateHandleBuffer (
+ ByProtocol,
+ &gBlackBoxEfiHIIConfigAccessProtocolGuid,
+ NULL,
+ &NoHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR(Status) || (NoHandles == 0)) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // scan for the handle that matched with the Hii Configuration Access Protocol that
+ // passed in by the test framework
+ //
+ for (Index = 0; Index < NoHandles; Index++) {
+ Status = gtBS->HandleProtocol (
+ HandleBuffer[Index],
+ &gBlackBoxEfiHIIConfigAccessProtocolGuid,
+ (VOID **) &TestedConfigAccess
+ );
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+
+ if (TestedConfigAccess == ConfigAccess) {
+ ConfigAccessHandle = HandleBuffer[Index];
+ break;
+ }
+ }
+
+ gtBS->FreePool (HandleBuffer);
+
+ if (ConfigAccessHandle == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // find controller handles managed by the component name handle.
+ //
+ Status = gtBS->HandleProtocol (
+ ConfigAccessHandle,
+ &gBlackBoxEfiDevicePathProtocolGuid,
+ (void **)&DevicePath
+ );
+
+ //
+ // Convert the device path binary to hex UNICODE %02x bytes in the same order
+ // as the device path resides in RAM memory.
+ //
+ Length = EfiDevicePathSize (DevicePath);
+ PathHdrSize = (Length * 2 + 1) * sizeof (CHAR16);
+ *DevicePathStr = (EFI_STRING) SctAllocateZeroPool (PathHdrSize);
+ if (*DevicePathStr == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ Status = BufToHexStringPrivate (*DevicePathStr, &PathHdrSize, (UINT8 *) DevicePath, Length, TRUE);
+
+ return Status;
+}
+
+
+EFI_STATUS
+GetCorrespondingRequest (
+ IN EFI_STRING MultiConfigAltResp,
+ IN EFI_STRING DevicePath,
+ IN OUT EFI_STRING Request
+ )
+{
+ EFI_STRING RespPtr;
+ EFI_STRING ReqPtr;
+ EFI_STRING SingleResp;
+ EFI_STRING SingleRespPtr;
+ UINTN Len;
+
+ ReqPtr = Request;
+ RespPtr = MultiConfigAltResp;
+
+ Len = SctStrLen (MultiConfigAltResp);
+
+ if (SctStrnCmp (MultiConfigAltResp, L"GUID=", 5) != 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (SctStrStr (MultiConfigAltResp, DevicePath) == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ SingleResp = (EFI_STRING) SctAllocateZeroPool ( 2 * SctStrLen (MultiConfigAltResp) + 2 );
+ if (SingleResp == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ SingleRespPtr = SingleResp;
+
+ while (*MultiConfigAltResp != 0) {
+ while ((*MultiConfigAltResp != 0) && (SctStrnCmp (MultiConfigAltResp, L"&GUID=", 6) != 0)) {
+ *(SingleResp++) = *(MultiConfigAltResp++);
+ }
+ SingleResp = SingleRespPtr;
+ if (SctStrStr (SingleResp, DevicePath) != NULL)
+ break;
+ SctZeroMem (SingleRespPtr, 2 * Len + 2);
+ if (*MultiConfigAltResp != 0)
+ MultiConfigAltResp++;
+ }
+
+ if (SctStrStr (SingleResp, DevicePath) == NULL)
+ return EFI_NOT_FOUND;
+
+ if (SctStrStr (SingleResp, L"VALUE=") == NULL){
+ while (*SingleResp != 0) {
+ while ((*SingleResp != 0) && (SctStrnCmp (SingleResp, L"&PATH=", 6) != 0)) {
+ *(Request++) = *(SingleResp++);
+ }
+ *(Request++) = *(SingleResp++);
+ while ((*SingleResp != 0) && (*SingleResp != L'&')) {
+ *(Request++) = *(SingleResp++);
+ }
+ while (*SingleResp != 0){
+ if (*SingleResp != L'=') {
+ *(Request++) = *(SingleResp++);
+ } else {
+ while ((*SingleResp != 0) && (*SingleResp != L'&')) {
+ SingleResp++;
+ }
+ }
+ }
+ }
+ } else {
+ while (*SingleResp != 0) {
+ while ((*SingleResp != 0) && (SctStrnCmp (SingleResp, L"&VALUE=", 7)) != 0) {
+ *(Request++) = *(SingleResp++);
+ }
+ SingleResp++;
+ while ((*SingleResp != 0) && (*SingleResp != L'&'))
+ SingleResp++;
+ }
+
+ }
+
+ *Request = 0;
+
+ gtBS->FreePool (SingleRespPtr);
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+GetCorrespondingResp (
+ IN EFI_STRING MultiConfigAltResp,
+ IN EFI_STRING DevicePath,
+ IN OUT EFI_STRING Resp
+ )
+{
+ EFI_STRING RespPtr;
+ EFI_STRING ReqPtr;
+ UINTN Len;
+
+ ReqPtr = Resp;
+ RespPtr = MultiConfigAltResp;
+
+ Len = SctStrLen (MultiConfigAltResp);
+
+ if (SctStrnCmp (MultiConfigAltResp, L"GUID=", 5) != 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (SctStrStr (MultiConfigAltResp, DevicePath) == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ while (*MultiConfigAltResp != 0) {
+ while ((*MultiConfigAltResp != 0) && (SctStrnCmp (MultiConfigAltResp, L"&GUID=", 6) != 0)) {
+ *(Resp++) = *(MultiConfigAltResp++);
+ }
+ Resp = ReqPtr;
+ if (SctStrStr (Resp, DevicePath) != NULL)
+ break;
+ SctZeroMem (ReqPtr, 2 * Len + 2);
+ if (*MultiConfigAltResp != 0)
+ MultiConfigAltResp++;
+ }
+
+ if (SctStrStr (Resp, DevicePath) == NULL)
+ return EFI_NOT_FOUND;
+
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+GetHIIConfigRoutingInterface (
+ OUT EFI_HII_CONFIG_ROUTING_PROTOCOL **HIIConfigRouting
+ )
+{
+ UINTN NoHandles;
+ EFI_HANDLE *HandleBuffer;
+ EFI_STATUS Status;
+
+ //
+ // Get the HII Database Protocol interface
+ //
+ Status = gtBS->LocateHandleBuffer (
+ ByProtocol,
+ &gBlackBoxEfiHIIConfigRoutingProtocolGuid,
+ NULL,
+ &NoHandles,
+ &HandleBuffer
+ );
+ if ( EFI_ERROR(Status) ) {
+ return Status;
+ }
+
+ if ( NoHandles <= 0 ) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Status = gtBS->HandleProtocol (
+ HandleBuffer[0],
+ &gBlackBoxEfiHIIConfigRoutingProtocolGuid,
+ (VOID **) HIIConfigRouting
+ );
+ if ( EFI_ERROR(Status) ) {
+ gtBS->FreePool ( HandleBuffer );
+ return Status;
+ }
+
+ gtBS->FreePool ( HandleBuffer );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+MultiAltRespToMultiReq (
+ IN EFI_STRING Resp,
+ IN OUT EFI_STRING Req
+ )
+{
+ EFI_STRING Pointer1 = Resp;
+ EFI_STRING Pointer2 = NULL;
+ EFI_STRING Pointer3 = Req;
+ EFI_STRING CfgHdr = NULL;
+ EFI_STRING FreePtr = NULL;
+ CHAR8 Flag = 0;
+
+ if (SctStrnCmp (Pointer1, L"GUID=", 5) != 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Pointer2 = (EFI_STRING) SctAllocateZeroPool (2 * SctStrLen (Resp) + 2);
+ if (Pointer2 == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ FreePtr = Pointer2;
+
+ while (*Pointer1) {
+ if (SctStrnCmp (Pointer1, L"GUID=", 5) == 0) {
+ CfgHdr = Pointer2;
+ *(Pointer2++) = *(Pointer1++);
+ while (*Pointer1 != L'&') {
+ *(Pointer2++) = *(Pointer1++);
+ }
+ }
+ if (SctStrnCmp (Pointer1, L"&GUID=", 6) == 0) {
+ *(Pointer2++) = *(Pointer1++);
+ CfgHdr = Pointer2;
+ while (*Pointer1 != L'&') {
+ *(Pointer2++) = *(Pointer1++);
+ }
+ }
+ if (SctStrnCmp (Pointer1, L"&NAME=", 6) == 0) {
+ *(Pointer2++) = *(Pointer1++);
+ while (*Pointer1 != L'&') {
+ *(Pointer2++) = *(Pointer1++);
+ }
+ }
+ if (SctStrnCmp (Pointer1, L"&PATH=", 6) == 0) {
+ *(Pointer2++) = *(Pointer1++);
+ while (*Pointer1 != L'&') {
+ *(Pointer2++) = *(Pointer1++);
+ }
+ if (NULL == SctStrStr (Req, CfgHdr)){
+ if (*Req == L'G')
+ *(Pointer3++) = L'&';
+ SctStrCat (Req, CfgHdr);
+ Pointer3 += SctStrLen (CfgHdr);
+ Flag = 1;
+ } else {
+ Flag = 0;
+ }
+ }
+ while ((Flag == 1) && (SctStrnCmp (Pointer1, L"&GUID=", 6) != 0) && *Pointer1) {
+ if (SctStrnCmp (Pointer1, L"&OFFSET=", 8) == 0) {
+ *(Pointer3++) = *(Pointer1++);
+ while (*Pointer1 != L'&') {
+ *(Pointer3++) = *(Pointer1++);
+ }
+ }
+ if (SctStrnCmp (Pointer1, L"&WIDTH=", 7) == 0) {
+ *(Pointer3++) = *(Pointer1++);
+ while (*Pointer1 != L'&') {
+ *(Pointer3++) = *(Pointer1++);
+ }
+ }
+ if (SctStrnCmp (Pointer1, L"&VALUE=", 7) == 0) {
+ Pointer1 += 7;
+ while (*Pointer1 != L'&' && *Pointer1) {
+ Pointer1++;
+ }
+ }
+ if (SctStrnCmp (Pointer1, L"&ALTCFG=", 8) == 0) {
+ Pointer1 += 8;
+ while (*Pointer1 != L'&' && *Pointer1) {
+ Pointer1++;
+ }
+ }
+ if ((*Pointer1 == L'&') && (SctStrnCmp (Pointer1, L"&GUID=", 6) != 0) &&
+ (SctStrnCmp (Pointer1, L"&OFFSET=", 8) != 0) && (SctStrnCmp (Pointer1, L"&WIDTH=", 7) != 0)) {
+ *(Pointer3++) = *(Pointer1++);
+ while (*Pointer1 != L'=') {
+ *(Pointer3++) = *(Pointer1++);
+ }
+ while (*Pointer1 != L'&' && *Pointer1) {
+ Pointer1++;
+ }
+ }
+ }
+ Pointer1++;
+ }
+
+ SctFreePool (FreePtr);
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h
new file mode 100644
index 00000000..e2080a27
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h
@@ -0,0 +1,144 @@
+/** @file
+
+ Copyright 2006 - 2013 Unified EFI, Inc.<BR>
+ Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2019,Microchip Technology Inc.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ HIIConfigAccessBBTestMain.h
+
+Abstract:
+
+ Test Driver of HII Configuration Access Protocol header file
+
+--*/
+
+#ifndef _HII_CONFIG_ACCESS_BB_TEST_MAIN
+#define _HII_CONFIG_ACCESS_BB_TEST_MAIN
+
+#define __UEFI_INTERNAL_FORMREPRESENTATION_H__
+#include <Base.h>
+#include "SctLib.h"
+#include "Guid.h"
+#include <Library/EfiTestLib.h>
+#include <UEFI/Protocol/Hii.h>
+#include <UEFI/Protocol/HIIConfigAccess.h>
+#include <UEFI/Protocol/HIIConfigRouting.h>
+
+
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_REVISION 0x00010000
+#define IHV_EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID \
+{ 0x68820884, 0x4be3, 0x4ca9, { 0x83, 0x81, 0x9e, 0x98, 0xf3, 0xf4, 0x8d, 0xaf } }
+//
+// Entry GUIDs for Func Test
+//
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_ENTRY_GUID0101 \
+{ 0x2a85387e, 0xdcf9, 0x45e9, { 0xb3, 0x8f, 0x5d, 0xa1, 0x75, 0x41, 0xcf, 0x1a } }
+
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_ENTRY_GUID0102 \
+{ 0x1a15df85, 0x6cc1, 0x43f2, { 0x9b, 0x86, 0x21, 0x8b, 0xd5, 0xfd, 0xf4, 0xa0 } }
+
+
+//
+// Entry GUIDs for Conf Test
+//
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_ENTRY_GUID0201 \
+{ 0xe2c3b0fe, 0xfbe9, 0x46a9, { 0xa3, 0x1b, 0xa3, 0xf3, 0x82, 0xd, 0xcf, 0x4 } }
+
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_TEST_ENTRY_GUID0202 \
+{ 0x495c99f3, 0x231, 0x45a5, { 0xaf, 0xfa, 0xd2, 0x5c, 0x6f, 0x9a, 0x19, 0x1c } }
+
+
+
+EFI_STATUS
+InitializeHIIConfigAccessBBTest (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+
+EFI_STATUS
+UnloadHIIConfigAccessBBTest (
+ IN EFI_HANDLE ImageHandle
+ );
+
+
+//
+//Test Cases
+//
+
+EFI_STATUS
+BBTestExtractConfigConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestRouteConfigConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestExtractConfigFunctionTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+BBTestRouteConfigFunctionTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
+EFI_STATUS
+GetDevicePath (
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,
+ OUT EFI_STRING *DevicePathStr
+ );
+
+EFI_STATUS
+GetCorrespondingRequest (
+ IN EFI_STRING MultiConfigAltResp,
+ IN EFI_STRING DevicePath,
+ IN OUT EFI_STRING Request
+ );
+
+EFI_STATUS
+GetCorrespondingResp (
+ IN EFI_STRING MultiConfigAltResp,
+ IN EFI_STRING DevicePath,
+ IN OUT EFI_STRING Resp
+ );
+
+EFI_STATUS
+GetHIIConfigRoutingInterface (
+ OUT EFI_HII_CONFIG_ROUTING_PROTOCOL **HIIConfigRouting
+ );
+
+EFI_STATUS
+MultiAltRespToMultiReq (
+ IN EFI_STRING Resp,
+ IN OUT EFI_STRING Req
+ );
+
+#endif
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/IhvHIIConfigAccessBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/IhvHIIConfigAccessBBTest.inf
new file mode 100644
index 00000000..e781b4df
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/HIIConfigAccess/BlackBoxTest/IhvHIIConfigAccessBBTest.inf
@@ -0,0 +1,55 @@
+## @file
+#
+# Copyright 2006 - 2012 Unified EFI, Inc.<BR>
+# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2019,Microchip Technology Inc.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+#/*++
+#
+# Module Name:
+#
+# HIIConfigAccessBBTest.inf
+#
+# Abstract:
+#
+# Component description file for IHV HII Config Access Protocol Black-Box Test.
+#
+#--*/
+
+[defines]
+INF_VERSION = 0x00010005
+BASE_NAME = IhvHIIConfigAccessBBTest
+FILE_GUID = D39F2A3B-72BF-40F5-86BF-2E1E96D15EA3
+MODULE_TYPE = UEFI_DRIVER
+VERSION_STRING = 1.0
+ENTRY_POINT = InitializeHIIConfigAccessBBTest
+
+[sources.common]
+ HIIConfigAccessBBTestConformance.c
+ HIIConfigAccessBBTestFunction.c
+ HIIConfigAccessBBTestMain.c
+ Guid.c
+
+[Packages]
+ SctPkg/SctPkg.dec
+ SctPkg/UEFI/UEFI.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ SctLib
+ EfiTestLib
+
+[Protocols]
+ gBlackBoxEfiHIIConfigAccessProtocolGuid
+ gBlackBoxEfiHIIConfigRoutingProtocolGuid
+ gBlackBoxEfiDevicePathProtocolGuid
--
2.22.0.windows.1


[PATCH 2/2] BaseTools/Capsule: Tool to generate Windows Firmware Update Driver

Eric Jin
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1837

The tool is designed to generate Windows Firmware Update Drivers,
the input is one drivername.cap with related parameters, the output
Windows Driver package are composed by drivername.cap, drivername.inf
and drivername.cat to update the single payload in device.

usage:
GenerateWindowsDriver [-h] [--output-folder OUTPUTFOLDER]
[--product-fmp-guid PRODUCTFMPGUID]
[--capsuleversion-dotstring CAPSULEVERSION_DOTSTRING]
[--capsuleversion-hexstring CAPSULEVERSION_HEXSTRING]
[--product-fw-provider PRODUCTFWPROVIDER]
[--product-fw-mfg-name PRODUCTFWMFGNAME]
[--product-fw-desc PRODUCTFWDESC]
[--capsule-file-name CAPSULEFILENAME]
[--pfx-file PFXFILE] [--arch ARCH]
[--operating-system-string OPERATINGSYSTEMSTRING]

Cc: Sean Brogan <sean.brogan@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <liming.gao@...>
Cc: Kinney Michael D <michael.d.kinney@...>
Signed-off-by: Eric Jin <eric.jin@...>
---
.../Python/Capsule/GenerateWindowsDriver.py | 120 ++++++++++++++++++
.../Capsule/WindowsCapsuleSupportHelper.py | 16 ++-
2 files changed, 129 insertions(+), 7 deletions(-)
create mode 100644 BaseTools/Source/Python/Capsule/GenerateWindowsDriver.py

diff --git a/BaseTools/Source/Python/Capsule/GenerateWindowsDriver.py b/BaseTools/Source/Python/Capsule/GenerateWindowsDriver.py
new file mode 100644
index 0000000000..bea7a0df38
--- /dev/null
+++ b/BaseTools/Source/Python/Capsule/GenerateWindowsDriver.py
@@ -0,0 +1,120 @@
+## @file
+# Generate a capsule windows driver.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+'''
+GenerateWindowsDriver
+'''
+
+import sys
+import argparse
+import uuid
+import struct
+import subprocess
+import os
+import tempfile
+import shutil
+import platform
+import re
+import logging
+from WindowsCapsuleSupportHelper import WindowsCapsuleSupportHelper
+from Common.Uefi.Capsule.FmpCapsuleHeader import FmpCapsuleHeaderClass
+from Common.Uefi.Capsule.UefiCapsuleHeader import UefiCapsuleHeaderClass
+
+#
+# Globals for help information
+#
+__prog__ = 'GenerateWindowsDriver'
+__version__ = '0.0'
+__copyright__ = 'Copyright (c) 2019, Intel Corporation. All rights reserved.'
+__description__ = 'Generate Capsule Windows Driver.\n'
+
+def GetCapGuid (InputFile):
+ with open(InputFile, 'rb') as File:
+ Buffer = File.read()
+ try:
+ Result = UefiCapsuleHeader.Decode (Buffer)
+ if len (Result) > 0:
+ FmpCapsuleHeader.Decode (Result)
+ for index in range (0, FmpCapsuleHeader.PayloadItemCount):
+ Guid = FmpCapsuleHeader.GetFmpCapsuleImageHeader (index).UpdateImageTypeId
+ return Guid
+ except:
+ print ('GenerateCapsule: error: can not decode capsule')
+ sys.exit (1)
+
+def ArgCheck(args):
+ Version = args.CapsuleVersion_DotString.split('.')
+
+ if len(Version) != 4:
+ logging.critical("Name invalid: '%s'", args.CapsuleVersion_DotString)
+ raise ValueError("Name invalid.")
+ for sub in Version:
+ if int(sub, 16) > 65536:
+ logging.critical("Name invalid: '%s'", args.CapsuleVersion_DotString)
+ raise ValueError("Name exceed limit 65536.")
+
+ if not (re.compile(r'[\a-fA-F0-9]*$')).match(args.CapsuleVersion_DotString):
+ logging.critical("Name invalid: '%s'", args.CapsuleVersion_DotString)
+ raise ValueError("Name has invalid chars.")
+
+def CapsuleGuidCheck(InputFile, Guid):
+ CapGuid = GetCapGuid(InputFile)
+ if (str(Guid).lower() != str(CapGuid)):
+ print('GenerateWindowsDriver error: Different Guid from Capsule')
+ sys.exit(1)
+
+if __name__ == '__main__':
+ def convert_arg_line_to_args(arg_line):
+ for arg in arg_line.split():
+ if not arg.strip():
+ continue
+ yield arg
+
+ parser = argparse.ArgumentParser (
+ prog = __prog__,
+ description = __description__ + __copyright__,
+ conflict_handler = 'resolve',
+ fromfile_prefix_chars = '@'
+ )
+ parser.convert_arg_line_to_args = convert_arg_line_to_args
+ parser.add_argument("--output-folder", dest = 'OutputFolder', help = "firmware resource update driver package output folder.")
+ parser.add_argument("--product-fmp-guid", dest = 'ProductFmpGuid', help = "firmware GUID of resource update driver package")
+ parser.add_argument("--capsuleversion-dotstring", dest = 'CapsuleVersion_DotString', help = "firmware version with date on which update driver package is authored")
+ parser.add_argument("--capsuleversion-hexstring", dest = 'CapsuleVersion_HexString', help = "firmware version in Hex of update driver package")
+ parser.add_argument("--product-fw-provider", dest = 'ProductFwProvider', help = "vendor/provider of entire firmware resource update driver package")
+ parser.add_argument("--product-fw-mfg-name", dest = 'ProductFwMfgName', help = "manufacturer/vendor of firmware resource update driver package")
+ parser.add_argument("--product-fw-desc", dest = "ProductFwDesc", help = "description about resource update driver")
+ parser.add_argument("--capsule-file-name", dest = 'CapsuleFileName', help ="firmware resource image file")
+ parser.add_argument("--pfx-file", dest = 'PfxFile', help = "pfx file path used to sign resource update driver")
+ parser.add_argument("--arch", dest = 'Arch', help = "supported architecture:arm/x64/amd64/arm64/aarch64", default = 'amd64')
+ parser.add_argument("--operating-system-string", dest = 'OperatingSystemString', help = "supported operating system:win10/10/10_au/10_rs2/10_rs3/10_rs4/server10/server2016/serverrs2/serverrs3/serverrs4", default = "win10")
+
+ args = parser.parse_args()
+ InputFile = os.path.join(args.OutputFolder, '') + args.CapsuleFileName
+ UefiCapsuleHeader = UefiCapsuleHeaderClass ()
+ FmpCapsuleHeader = FmpCapsuleHeaderClass ()
+ CapsuleGuidCheck(InputFile, args.ProductFmpGuid)
+ ArgCheck(args)
+ ProductName = os.path.splitext(args.CapsuleFileName)[0]
+ WindowsDriver = WindowsCapsuleSupportHelper ()
+
+ WindowsDriver.PackageWindowsCapsuleFiles (
+ args.OutputFolder,
+ ProductName,
+ args.ProductFmpGuid,
+ args.CapsuleVersion_DotString,
+ args.CapsuleVersion_HexString,
+ args.ProductFwProvider,
+ args.ProductFwMfgName,
+ args.ProductFwDesc,
+ args.CapsuleFileName,
+ args.PfxFile,
+ None,
+ None,
+ args.Arch,
+ args.OperatingSystemString
+ )
diff --git a/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py b/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py
index 166af58d81..a29ac21ae8 100644
--- a/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py
+++ b/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py
@@ -3,7 +3,11 @@
# Windows Firmware Update Platform spec.
# Creates INF, Cat, and then signs it
#
+# To install run pip install --upgrade edk2-pytool-library
+# edk2-pytool-library-0.9.1 is required.
+#
# Copyright (c) Microsoft Corporation. All rights reserved.
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

@@ -12,14 +16,12 @@ import re
import datetime
import os
import logging
-from MuEnvironment import PluginManager
-from MuPythonLibrary.Uefi.Capsule.CatGenerator import *
-from MuPythonLibrary.Uefi.Capsule.InfGenerator import *
-from MuPythonLibrary.UtilityFunctions import CatalogSignWithSignTool
-from MuPythonLibrary.Windows.VsWhereUtilities import FindToolInWinSdk
-
+from edk2toollib.windows.capsule.cat_generator import CatGenerator
+from edk2toollib.windows.capsule.inf_generator import InfGenerator
+from edk2toollib.utility_functions import CatalogSignWithSignTool
+from edk2toollib.windows.locate_tools import FindToolInWinSdk

-class WindowsCapsuleSupportHelper(PluginManager.IUefiHelperPlugin):
+class WindowsCapsuleSupportHelper(object):

def RegisterHelpers(self, obj):
fp = os.path.abspath(__file__)
--
2.20.1.windows.1


[PATCH 1/2] BaseTools/Capsule: Add WindowsCapsuleSupportHelper

Eric Jin
 

Add initial version WindowsCapsuleSupportHelper.py
original source comes from
https://github.com/microsoft/mu_basecore/blob/dev/201905/BaseTools/Plugin/WindowsCapsuleSupportHelper/WindowsCapsuleSupportHelper.py
commit ebd9aad90dee3a3094b575928670cf81b8c685b5
Convert EOL to CRLF

Cc: Sean Brogan <sean.brogan@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <liming.gao@...>
Cc: Bob Feng <bob.c.feng@...>
Signed-off-by: Eric Jin <eric.jin@...>
---
.../Capsule/WindowsCapsuleSupportHelper.py | 62 +++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py

diff --git a/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py b/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py
new file mode 100644
index 0000000000..166af58d81
--- /dev/null
+++ b/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py
@@ -0,0 +1,62 @@
+##
+# UefiBuild Plugin that supports Window Capsule files based on the
+# Windows Firmware Update Platform spec.
+# Creates INF, Cat, and then signs it
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+import sys
+import re
+import datetime
+import os
+import logging
+from MuEnvironment import PluginManager
+from MuPythonLibrary.Uefi.Capsule.CatGenerator import *
+from MuPythonLibrary.Uefi.Capsule.InfGenerator import *
+from MuPythonLibrary.UtilityFunctions import CatalogSignWithSignTool
+from MuPythonLibrary.Windows.VsWhereUtilities import FindToolInWinSdk
+
+
+class WindowsCapsuleSupportHelper(PluginManager.IUefiHelperPlugin):
+
+ def RegisterHelpers(self, obj):
+ fp = os.path.abspath(__file__)
+ obj.Register("PackageWindowsCapsuleFiles", WindowsCapsuleSupportHelper.PackageWindowsCapsuleFiles, fp)
+
+
+ @staticmethod
+ def PackageWindowsCapsuleFiles(OutputFolder, ProductName, ProductFmpGuid, CapsuleVersion_DotString,
+ CapsuleVersion_HexString, ProductFwProvider, ProductFwMfgName, ProductFwDesc, CapsuleFileName, PfxFile=None, PfxPass=None,
+ Rollback=False, Arch='amd64', OperatingSystem_String='Win10'):
+
+ logging.debug("CapsulePackage: Create Windows Capsule Files")
+
+ #Make INF
+ InfFilePath = os.path.join(OutputFolder, ProductName + ".inf")
+ InfTool = InfGenerator(ProductName, ProductFwProvider, ProductFmpGuid, Arch, ProductFwDesc, CapsuleVersion_DotString, CapsuleVersion_HexString)
+ InfTool.Manufacturer = ProductFwMfgName #optional
+ ret = InfTool.MakeInf(InfFilePath, CapsuleFileName, Rollback)
+ if(ret != 0):
+ raise Exception("CreateWindowsInf Failed with errorcode %d" % ret)
+
+ #Make CAT
+ CatFilePath = os.path.realpath(os.path.join(OutputFolder, ProductName + ".cat"))
+ CatTool = CatGenerator(Arch, OperatingSystem_String)
+ ret = CatTool.MakeCat(CatFilePath)
+
+ if(ret != 0):
+ raise Exception("Creating Cat file Failed with errorcode %d" % ret)
+
+ if(PfxFile is not None):
+ #Find Signtool
+ SignToolPath = FindToolInWinSdk("signtool.exe")
+ if not os.path.exists(SignToolPath):
+ raise Exception("Can't find signtool on this machine.")
+ #dev sign the cat file
+ ret = CatalogSignWithSignTool(SignToolPath, CatFilePath, PfxFile, PfxPass)
+ if(ret != 0):
+ raise Exception("Signing Cat file Failed with errorcode %d" % ret)
+
+ return ret
--
2.20.1.windows.1


[PATCH 0/2] Enable Windows Firmware Update Driver Tool

Eric Jin
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1837

The tool makes driver capsule as input, leverage edk2-pytool-library
to creates INF, Cat, and signs it. The generated Windows Driver package
is composed by drivername.cap, drivername.inf and drivername.cat files.

Eric Jin (2):
BaseTools/Capsule: Add WindowsCapsuleSupportHelper
BaseTools/Capsule: Tool to generate Windows Firmware Update Driver

.../Python/Capsule/GenerateWindowsDriver.py | 120 ++++++++++++++++++
.../Capsule/WindowsCapsuleSupportHelper.py | 64 ++++++++++
2 files changed, 184 insertions(+)
create mode 100644 BaseTools/Source/Python/Capsule/GenerateWindowsDriver.py
create mode 100644 BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py

--
2.20.1.windows.1


Re: [PATCH v1 0/6] Prevent buffer overruns in acpiview table parsers

Sami Mujawar
 

For this patch series.

Reviewed-by: Sami Mujawar <sami.mujawar@...>

Regards,

Sami Mujawar

-----Original Message-----
From: Krzysztof Koch <krzysztof.koch@...>
Sent: 01 August 2019 09:44 AM
To: devel@edk2.groups.io
Cc: jaben.carsey@...; ray.ni@...; zhichao.gao@...; Sami Mujawar <Sami.Mujawar@...>; Matteo Carlini <Matteo.Carlini@...>; nd <nd@...>
Subject: [PATCH v1 0/6] Prevent buffer overruns in acpiview table parsers

This patch series makes minor modifications to a number of ACPI table parsers with a goal to minimize the risk of buffer overruns. Some of these overruns can be caused by invalid ACPI table data.

Changes can be seet at: https://github.com/KrzysztofKoch1/edk2/tree/612_prevent_buffer_overruns_v1

Krzysztof Koch (6):
ShellPkg: acpiview: DBG2: Prevent buffer overruns
ShellPkg: acpiview: GTDT: Prevent buffer overruns
ShellPkg: acpiview: IORT: Prevent buffer overruns
ShellPkg: acpiview: MADT: Prevent buffer overruns
ShellPkg: acpiview: PPTT: Prevent buffer overruns
ShellPkg: acpiview: SRAT: Prevent buffer overruns

ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c | 141 ++++++++++----- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c | 147 +++++++-------- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c | 191 +++++++++++---------
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c | 2 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 38 ++-- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 14 +-
6 files changed, 314 insertions(+), 219 deletions(-)

--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


Re: [PATCH] MdeModulePkg/DxeCapsuleLibFmp: Add missing description for parameter

Wu, Hao A
 

-----Original Message-----
From: Zhang, Shenglei
Sent: Tuesday, August 06, 2019 10:18 AM
To: devel@edk2.groups.io
Cc: Wang, Jian J; Wu, Hao A
Subject: [PATCH] MdeModulePkg/DxeCapsuleLibFmp: Add missing
description for parameter

The description of parameter CapFileName is missing in comments.
So add the description.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>

Hello,

One comment that is not related with the patch itself.

In the future, please help to run the 'GetMaintainer.py' script under
BaseTools/Scripts/ to get the CC list when proposing a patch in the
MdeModulePkg.

For the patch:
Reviewed-by: Hao A Wu <hao.a.wu@...>
And the pushed via commit 111bbcf876.

Best Regards,
Hao Wu


Signed-off-by: Shenglei Zhang <shenglei.zhang@...>
---
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c | 1 +
1 file changed, 1 insertion(+)

diff --git
a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
index 2cecc87385b3..f2cd0ad3e816 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
@@ -136,6 +136,7 @@ UINT32 mCapsuleTotalNumber;
Caution: This function may receive untrusted input.

@param[in] CapsuleHeader Points to a capsule header.
+ @param[in] CapFileName Capsule file name.
@param[out] ResetRequired Indicates whether reset is required or not.

@retval EFI_SUCESS Process Capsule Image successfully.
--
2.18.0.windows.1