104 Commits
Author SHA1 Message Date
Stéphane Rochoy 48363f39f1 efivar: Move dump functions into libefivar
To allow their use by efibootmgr.

Signed-off-by:	[email protected]
Reviewed by:	imp
Sponsored by:	Stormshield
Pull-Request:	https://github.com/freebsd/freebsd-src/pull/2167
2026-04-29 00:28:54 +03:30
Jose Luis Duran 8494a3de2c libefivar: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the MdePkg package

Note that the link above no longer exists.  The commit message was kept
verbatim.  An original copy of the bug report can be found at:
https://web.archive.org/web/20241008121707/https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Obtained from:	https://github.com/tianocore/edk2/commit/2f88bd3a1296c522317f1c21377876de63de5be7

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:25 -07:00
Jose Luis Duran ca6fef2d4b libefivar: Change OPTIONAL keyword usage style
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3760

Update all use of ', OPTIONAL' to ' OPTIONAL,' for function params.

Note that the link above no longer exists.  The commit message was kept
verbatim.  An archive of the bug report can be found at:
https://web.archive.org/web/20240714185609/https://bugzilla.tianocore.org/show_bug.cgi?id=3760

Obtained from:	https://github.com/tianocore/edk2/commit/d0e2f8232a26453fc0191629ed44ff2a46ea073e

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:25 -07:00
Jose Luis Duran 6fa0057f89 libefivar: Support UefiDevicePathLib under StandaloneMm
This change added an instance of UefiDevicePathLib for StandaloneMm. It
abstracts DevicePathFromHandle function into different files for
Standalone MM and other instances to avoid linking gBS into MM_STANDALONE
drivers.

No functional change intended, as this function and its invocation are ifdefd
out.

Obtained from:	https://github.com/tianocore/edk2/commit/14a746bb6a92d59669c67a970479558734cf2383

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:25 -07:00
Jose Luis Duran 136ff605bf libefivar: Replace BSD License with BSD+Patent License
https://bugzilla.tianocore.org/show_bug.cgi?id=1373

Replace BSD 2-Clause License with BSD+Patent License.  This change is
based on the following emails:

  https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html
  https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html

RFCs with detailed process for the license change:

  V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html
  V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html
  V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html

Note that the link above no longer exists.  The commit message was kept
verbatim.  An archive of the bug report can be found at:
https://web.archive.org/web/20240714192319/https://bugzilla.tianocore.org/show_bug.cgi?id=1373

Obtained from:	https://github.com/tianocore/edk2/commit/9344f0921518309295da89c221d10cbead8531aa

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:25 -07:00
Jose Luis Duran 5c2ae0a209 libefivar: Add sanity check for FilePath device path
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497

Current implementation of IsDevicePathValid() is not enough for type
of MEDIA_FILEPATH_DP, which has NULL-terminated string in the device
path. This patch add a simple NULL character check at Length position.

Note that the link above no longer exists.  The commit message was kept
verbatim.  An archived version of the bug report can be found at:
https://web.archive.org/web/20240714191428/https://bugzilla.tianocore.org/show_bug.cgi?id=1497

Add the const keyword to avoid errors/warnings about dropping a const
qualifier.

Obtained from:	https://github.com/tianocore/edk2/commit/2f7a96d6ec13b292d6f31295f3195913921173e1

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:24 -07:00
Jose Luis Duran fd606b629f libefivar: Add a checking step
Add a checking step in DevicePathUtilities.c to verify DevicePath.
https://bugzilla.tianocore.org/show_bug.cgi?id=1372

v2: Remove ASSERT() and the redundant checking step. Update related
    description.

Note that the link above no longer exists.  The commit message was kept
verbatim.  An archived version of the bug report can be found at:
https://web.archive.org/web/20240714192353/bugzilla.tianocore.org/show_bug.cgi?id=1372

Obtained from:	https://github.com/tianocore/edk2/commit/fd02394228ee1dc2378cccfde6098c461f96dd42

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:24 -07:00
Jose Luis Duran 9677ae7864 libefivar: MdePkg: Clean up source files
1. Do not use tab characters
2. No trailing white space in one line
3. All files must end with CRLF

No functional change.

Obtained from:	https://github.com/tianocore/edk2/commit/9095d37b8fe5bfc3d02adad6ba7fd7359ebc0107

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:24 -07:00
Jose Luis Duran 5b7b60af7b libefivar: Add and comment out unused functions
This commit introduces gratuitous white space and unused functions.
This functionality is guarded/commented out.  This change is necessary
to reduce the differences with the reference file in subsequent commits.

No functional change intended.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:24 -07:00
Jose Luis Duran ef191142dc libefivar: Move functions to match reference file
Move a few functions to match their locations in the reference file.
No functional change intended.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:24 -07:00
Jose Luis Duran b38f48d336 libefivar: Standardize #ifndef __FreeBSD__
Standardize preprocessor directives that comment out unused functions
(essentially #if 0).

No functional change intended.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:23 -07:00
Jose Luis Duran 0e614a4afe libefivar: Fix (some) typos
Fix typos in the files that are owned by the project.

Bring back a "duplicate word" removal (node node), which should have
been "node Node", the second "node" is not capitalized in the reference
file (yet).  We'll bring it back capitalized to avoid it from triggering
automated checking scripts and possibly reverting this change again.  A
few other typos were not fixed, as we strive to keep as close to the
reference files as possible, these fixes should be submitted to the
reference project (tianocore/edk2) in the not so distant future.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1894
2025-11-25 11:17:23 -07:00
Warner Losh 67c7e94315 edk2: Move ProcessorBind.h to contrib/edk2
Have our own ProcessorBind.h. It just includes sys/efi-edk2.h, but
undefines TRUE, FALSE and MAC. The first two are from acpica and are
redefined to something almost the same. MAC is a global option that,
well, interferes with using EDK2, dangit. I suppose I should redefine it
after, but I don't think you can save the value of a pre-processor
variable.

This breaks a little with the tradition of having this in a seprate
directory and using build magic. However, the build is already magical
enough and having this here makes things less magical. Also, EDK2 puts
this in a processor specific directory, so we won't have conflicts (they
need it there since they run on more processors than we do: we can just
include sys/efi-edk2.h which covers the smallar variance we have in
processors).

Sponsored by:		Netflix
2025-11-16 11:29:03 -07:00
Warner Losh ce1342883e efi: Move edk2 compat defines to sys/efi-edk2.h
Create efi-freebsd.h, which is safe to include from the FreeBSD context
(all of userland, except the small bits we share with edk2 and the
kernel). This defines anything that we need. At the moment, it just
includes NULL definitions.

Create efi-edk2.h, which is approximately ProcessorBind.h from edk2 that
we can include in FreeBSD compontents that are re-using edk2 components
(bits of the boot laoder, and libefi*). Update the efi_gid definitions
to match edk2 better. Add this file to badfiles.inc, since we can't
write it in a way that's compatible. This is copied from the old
efi-osdep.h.

This has to be done in one commit that's bigger than I like since we
can't easily move things piecemeal around they are so inter-related.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D53651
2025-11-16 11:29:02 -07:00
Warner Losh 259eac0149 efivar: Kill needless sys/cdefs.h
Sponsored by:		Netflix
2025-05-25 07:49:32 -06:00
Warner Losh 8d136fb027 efivar: Use struct guid_table instead of uuid_table
uuid_table was the linux name. When libefivar was started, I tried to
make it compatible with Linux. However, that's no longer relevant: (a)
little to no Linux code was subsequently ported and (b) Linux compat has
eroded. This erodes it a bit more to cope with the uuid_t -> efi_guid_t
changes. This also moves a couple of functions around to reduce copying and
updates consumers for the visible parts of this change.

Sponsored by:		Netflix
Reviewed by:		tsoome, kib
Differential Revision:	https://reviews.freebsd.org/D50060
2025-05-01 11:55:14 -06:00
Warner Losh daeb975ff5 efivar: Use bool instead of int
Sponsored by:		Netflix
Reviewed by:		tsoome, kib
Differential Revision:	https://reviews.freebsd.org/D50059
2025-05-01 11:55:14 -06:00
Warner Losh 4c317815f1 efivar: Move to new ioctl struct
Move to the newer ioctl 'struct efi_var_ioctl' which uses efi_guid_t
instead of struct uuid. This allows for direct assignment agaain.

Sponsored by:		Netflix
Reviewed by:		tsoome, kib
Differential Revision:	https://reviews.freebsd.org/D50058
2025-05-01 11:55:05 -06:00
Warner Losh 915b2336b1 libefi: Update to use the efi_guid_t from sys/efi.h
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D50038
2025-05-01 11:53:36 -06:00
Warner Losh 20c5e4b393 efivar: Allow uuid_t and efi_guid_t to be different types.
While they are binarily the same, the API are different. To use EDK2
more effectively, we need to transition to using EDK@'s API rather than
the uuid_t API. This change makes the code neutral on the subject.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D50035
2025-05-01 11:53:12 -06:00
Warner Losh 5f2dd25a9e efivar: Test uuid against zero
Test the passed in GuID against a guid of all 0's. This removes another
place that has to worry about the difference between uuit_t and
EFI_GUID.

Sponsored by:		Netflix
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D50034
2025-05-01 11:53:05 -06:00
Warner Losh 3eb80ef831 efivar: Use memcmp instead of uuid_ functions to compare
In these cases, memcmp is a perfectly fine substitute for the uuid
functions. We don't need checking to make sure the uuids are good, we
know the pointers are non-ULL, etc. memcmp will reduce the number of
places we need to know these are actually UUIDs, or similar.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D50033
2025-05-01 11:52:59 -06:00
Warner Losh cdfaf4e984 efivar: Add some explicit casts to uuid_t
Since we know we're type-punning the EFI_GUID to a uuid_t, add some
explicit casts even though, at the moment, we typedef one to the other.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D50032
2025-05-01 11:52:54 -06:00
Warner Losh 5e9af2b96b libefivar: Simplify Z / zero define
This really onl needs to be one zero long for the entire structure to be
initialized. Use this form instead.

Sponsored by:		Netflix
2025-04-23 17:06:00 -06:00
Warner Losh 828e0ee79f libefivar: Prefer EFI_GUID to GUID
There's more references to EFI_GUID than to GUID, so prefer using
that. The EFI_GUID is closely relate to UUID, but not quite identical to
it and those slight differences matter sometimes as well (which is how I
found these). Since nearly all the EFI code (ours and EDK2) prefers
EGI_GUID, use that proactively here.

Sponsored by:		Netflix
2025-04-23 15:33:31 -06:00
Jose Luis Duran 39d58c8160 libefivar: Add Display Only format for Hard Drive
Ref: UEFI Specification Version 2.1 (Errata D) (released October 2008)

Reviewed by:	imp, emaste
Approved by:	emaste (mentor)
Obtained from:	https://github.com/tianocore/edk2/commit/9e6537469d4700d9d793ee21e9c2f2e7ddbb2176
Differential Revision:	https://reviews.freebsd.org/D49060
2025-02-20 20:14:26 +00:00
Jose Luis Duran 05653fc774 libefivar: CodeQL Fixes
These libefivar files correspond to the following EDK2 Tianocore
routines:

efivar-dp-format.c -> MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
efivar-dp-parse.c  -> MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c

The following changes were apparently applied upstream to appease their
CodeQL workflows on GitHub.  Note that some of these changes are
logically contradictory, however avoiding differences between the two
code bases is a priority, as noted in the review.

Commit message from upstream:

Includes changes across the repo for the following CodeQL rules:
- cpp/comparison-with-wider-type
- cpp/overflow-buffer
- cpp/redundant-null-check-param
- cpp/uselesstest

Reviewed by:	imp
Approved by:	emaste (mentor)
Obtained from:	https://github.com/tianocore/edk2/commit/b7735a087afce6a5157b61e5450b6848ed535a14
Differential Revision:	https://reviews.freebsd.org/D49059
2025-02-20 20:11:52 +00:00
Jose Luis Duran b5f60442a0 libefivar: Fix sed pattern
Add a 'g' flag to allow the replacement to occur more than once on the
same line.

Reviewed by:	imp, emaste
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D49058
2025-02-20 20:10:06 +00:00
Jose Luis Duran 3f0efe0543 libefivar: Fix AcpiEx print logic
Add logic that checks if the code doesn't overflow
ACPI_EXTENDED_HID_DEVICE_PATH node when searching for optional
strings. If the string is not provided in the device path node
default value of "\0" is used.

Upstream PR:	https://bugzilla.tianocore.org/show_bug.cgi?id=4555
Obtained from:	https://github.com/tianocore/edk2/commit/96ed60dfd7d4818a532216d64ee87b13fae5c726

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1388
2024-09-06 12:34:33 -06:00
Warner Losh a2f733abcf lib: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:23:59 -07:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
John Baldwin ccfd87fe2a libefivar: Use a void cast in unimplemented stubs.
This "consumes" an otherwise unused argument.

Differential Revision:	https://reviews.freebsd.org/D40650
2023-06-27 10:19:31 -07:00
Warner Losh 2b46091032 efivar: Really look for labels for the provider with right efimedia
The prior code mistakently thought that the g_consumer that hung off the
provider we found were the right thing to use to find all the glabel
aliases for this node. However, the only way to find that is to iterate
through all the geoms that belong to the glabel geom class, looking for
those geoms with the same name as the provider with the right efimedia.
Do this in a way that caches glabel class, and allows for it to be
absent. Tighten the filter for mounted filesystems to only look
for the ones that are mounted on /dev/.. since the rest of the code
assumes that.

MFC After:		3 days
Sponsored by:		Netflix
Reviewed by:		corvink, asomers
Differential Revision:	https://reviews.freebsd.org/D38619
2023-02-16 08:54:39 -07:00
Warner Losh 57d5ca4eeb efivar: support device paths as well as mounted paths in path_to_dp
In path_to_dp, allow passing in either the actual device path "eg
/dev/foo/bar" or the path where the device is mounted (say
/mnt/baz/bing). In the former case we'll assume the path within the
device is nothing (the relpath). In the latter, we'll take from the
mount point on down as the relpath.

Sponsored by:		Netflix
Reviewed by:		corvink, manu, asomers
Differential Revision:	https://reviews.freebsd.org/D38616
2023-02-16 08:54:39 -07:00
Warner Losh 49fd6affdb efivar: Allow NULL paths in build_dp
Allow there to be NULL paths in buildp. This lets us return the device
path to the partition, as well as to files on the partition.

Sponsored by:		Netflix
Reviewed by:		corvink, manu, asomers
Differential Revision:	https://reviews.freebsd.org/D38615
2023-02-16 08:54:39 -07:00
Warner Losh ccf2121d59 efivar: Try harder to find label's efimedia
If there's no efimedia attribute on the provider, and the provider's a
glabel, then find the 'parent' geom. In this case, the provider's name
is label-type/name, but the geom's label will that of the underlying
device (eg ada0p1). If it is, recurisvely call find_geom_efimedia with
the geom's name, which shuold have the efimedia attribute.

Sponsored by:		Netflix
Reviewed by:		corvink, manu, asomers
Differential Revision:	https://reviews.freebsd.org/D38614
2023-02-16 08:54:39 -07:00
Warner Losh 942815c548 libefivar: Add note about extra compiler flags
Add a note about why we need these extra compiler flags to suppress
warnings. EDK2 upstream code is being used verbatim and as of the last
update these issuse persist, but are benign.

Sponsored by:		Netflix
Reviewed by:		asomers
Differential Revision:	https://reviews.freebsd.org/D38613
2023-02-15 16:03:54 -07:00
John Baldwin d30a1689f5 libefivar: Fix a buffer overread.
DevPathToTextUsbWWID allocates a separate copy of the SerialNumber
string to append a null terminator if the original string is not
null terminated.  However, by using AllocateCopyPool, it tries to
copy 'Length + 1' words from the existing string containing 'Length'
characters into the target string.  Split the copy out to only
copy 'Length' characters instead.

Reviewed by:	imp, emaste
Reported by:	GCC 12 -Wstringop-overread
Differential Revision:	https://reviews.freebsd.org/D36826
2022-10-03 16:10:44 -07:00
Gordon Bergling b1c5f60ce8 libefivar(3): Fix a typo in a source code comment
- s/partiton/partition/

MFC after:	3 days
2022-03-28 19:27:58 +02:00
Jose Luis Duran 5754f5823b libefivar: Apply uncrustify changes
Apply uncrustify changes to .c/.h files.

Reduce the diffs with EDK2 to aid with future merges.  The
unconventional way we've imported this code makes using a vendor branch
to manage it at the very least tricky. Update FreeBSD-update to reflect
the slight shift in advise.

Reviewed by:	imp
Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=3737
Obtained from:	https://github.com/tianocore/edk2/commit/2f88bd3a1296c522317f1c21377876de63de5be7
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:45:34 -07:00
Jose Luis Duran 60de142cfc libefivar: Change OPTIONAL keyword usage style
Update all use of ', OPTIONAL' to ' OPTIONAL,' for function params.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=3760
Obtained from:	https://github.com/tianocore/edk2/commit/d0e2f8232a26453fc0191629ed44ff2a46ea073e
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:47 -07:00
Jose Luis Duran 11a9ff5bc1 libefivar: Replace BSD License with BSD+Patent License
Replace BSD 2-Clause License with BSD+Patent License.  This change is
based on the following emails:

  https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html
  https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html

RFCs with detailed process for the license change:

  V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html
  V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html
  V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1373
Obtained from:	https://github.com/tianocore/edk2/commit/9344f0921518309295da89c221d10cbead8531aa
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:43 -07:00
Jose Luis Duran e871598ad4 libefivar: Check Length para before use in DevPathToTextUsbWWID
In function DevPathToTextUsbWWID, the Length parameter is used
without check. This patch is to add check before using it.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1336
Obtained from:	https://github.com/tianocore/edk2/commit/d8e702693a8c292220131dc4234a36e2c9fff614
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:40 -07:00
Jose Luis Duran c1fa6f4c5d libefivar: Fix incorrect check for DisplayOnly text format in AcpiEx
Text format for AcpiEx device path in UEFI Spec:
AcpiEx(HID,CID,UID,HIDSTR,CIDSTR,UIDSTR)
AcpiEx(HID|HIDSTR,(CID|CIDSTR,UID|UIDSTR))(Display Only)

When convert device path to text for AcpiEx device path,
current code check AllowShortcuts parameter to convert
the device path to DisplayOnly text format(shorter text
representation) by mistake.
It should check DisplayOnly parameter.

This commit is to fix this issue.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1312
Obtained from:	https://github.com/tianocore/edk2/commit/e9ab1635a2cfa1cb588996dcd5cc157fb44decb1
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:35 -07:00
Jose Luis Duran 492d9953fa libefivar: Handle AcpiExp device path when optional para is not specified
AcpiExp text device path: AcpiExp(HID,CID,UIDSTR)
And according to UEFI spec, the CID parameter is optional
and has a default value of 0. But current implementation
miss to check following cases for the AcpiExp.
FromText: when text device is AcpiExp(HID,,UIDSTR)/AcpiExp(HID,0,UIDSTR)
ToText: when the CID is 0 in the node structure

This commit is to do the enhancement.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1243
Obtained from:	https://github.com/tianocore/edk2/commit/a8b5750901faa63ff5570634851e648b8e335e5a
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:31 -07:00
Jose Luis Duran 965f85271c libefivar: Handle USBxxx device path when optional para is not specified
According to UEFI spec,
for the Messaging Device Path with USB Class SubType, some paras
are optional in the text device path.
Take UsbClass(VID,PID,Class,SubClass,Protocol) for example,
The VID is an integer between 0 and 65535 and is optional. The
default value is 0xFFFF.
The PID is an integer between 0 and 65535 and is optional. The
default value is 0xFFFF.
The Class is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The SubClass is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The Protocol is an integer between 0 and 255 and is optional. The
default value is 0xFF.
So if any the optional para is not specified in the text device,
we should set related para in the node structure to default value.

This commit is to do the enhancement for USB Class device path
when optional para is not specified.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1243
Obtained from:	https://github.com/tianocore/edk2/commit/3874108034eb3f1d5d5180df33a5dfdd5fab5d25
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:24 -07:00