From nobody Tue Nov 25 18:17:29 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dG9s52Nmsz6HZJq for ; Tue, 25 Nov 2025 18:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dG9s50z1Hz40vG for ; Tue, 25 Nov 2025 18:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764094649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dTzIJfAgAm0mtb739551C5pNO4ig9UP45t7WVhQ2nqg=; b=t+7urvFYWS7ekABtqBLPUbjtAQIPt6PIu2NM6rbVzCKHh5VU5iHcNGX0z+R07Hy5fdk1LA mIo49nY1vD8rNg+z7bKd790I/Z8Lc2OI8gBCjZq2uDacu+SyVGbbyXiKE8SC3PsJKwxpKf vDAB/a705bTMTsltw+ZH/bL4cu4FRKWsM5tvSsKzj04x3POMKjVETrcEOTf3TchHZVv8v/ WJR3DqY+R+xanyIrcBy53prqLocFIHNHta0LweMaAhuZaiNPWANc71PQxTqgZ8uFigW6bC PzCtMXP18xkfO7CtKyh9b6SrOuoevIkpKNE8oWkgPOE9daEY4sa0pkt6W/nQiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764094649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dTzIJfAgAm0mtb739551C5pNO4ig9UP45t7WVhQ2nqg=; b=QrSXTjXNVKIp777qhTt0lqHMN3m9WSmnvTzhagLnvxZwyQ8GdHhL3ARV4v562mcKYn4CDQ YC9LrQUU4rxnnnXhJV3M3ai0Xf7/VJkwq2EOBls24uilA105PV7XwxrRLdAKhJafTd8NM6 /egTMtePLEwiicjSpunByOOjp7IMPu5FDJGQXKY8RJ0dqr2MagPp1EDl7wDTASBKDgQMM6 Kt3Ob+1a7xZfT9LftdMCIw02X93nuMOctEfzor0BRVri1vIJHm4xcchuChG3GPdULlKmwx hAOm4iyKCUr61zo+HD1i14/Y1Kaua4jfBmTe/Ou3cS+td35xD6TRnO6xIMLeAg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764094649; a=rsa-sha256; cv=none; b=Embb7OnTHIXhcq6GXFzzKIMQWmxq2WyUn+2fSTThm8LKsYNU/pNsGPzL913fSoaEAClDsB Y3sc+4cHNh7nn3oCN1Yjo7ppHWFHeSnQ54sTeYWnngeJXYbvG3DC3+xqVtbmQmJiiYPBtN Fq1/JH7x8eou/kKwZOof9nEhGXaxcKQFNfK6c98jvKM8lA6d7bG46r3r4mfsc+Ki7fNYuA ahxekn7Uiph6OkFgWeWXvsWOC8tJVXygROfAghRZ+liH05z9hZ63Ww7hU9nY1NmWHlk49f HUDhrjBefOtBH2T7l8c18nA4CQx9exs1omFDOpaIJmWH6c5a5W2/f+Yny7EFbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dG9s50MPrz19PM for ; Tue, 25 Nov 2025 18:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id b9fc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 25 Nov 2025 18:17:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Jose Luis Duran From: Warner Losh Subject: git: ef191142dc2c - main - libefivar: Move functions to match reference file List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ef191142dc2c51e51209090daf7e938222174ecf Auto-Submitted: auto-generated Date: Tue, 25 Nov 2025 18:17:29 +0000 Message-Id: <6925f2b9.b9fc.74b9b2cc@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ef191142dc2c51e51209090daf7e938222174ecf commit ef191142dc2c51e51209090daf7e938222174ecf Author: Jose Luis Duran AuthorDate: 2025-11-13 20:54:15 +0000 Commit: Warner Losh CommitDate: 2025-11-25 18:17:24 +0000 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 --- lib/libefivar/uefi-dputil.c | 200 ++++++++++++++++++++++---------------------- 1 file changed, 99 insertions(+), 101 deletions(-) diff --git a/lib/libefivar/uefi-dputil.c b/lib/libefivar/uefi-dputil.c index 1f6a051ce600..f7d5d3ba6c8e 100644 --- a/lib/libefivar/uefi-dputil.c +++ b/lib/libefivar/uefi-dputil.c @@ -75,50 +75,6 @@ static CONST EFI_DEVICE_PATH_PROTOCOL mUefiDevicePathLibEndDevicePath = { } }; - -/** - Returns the size of a device path in bytes. - - This function returns the size, in bytes, of the device path data structure - specified by DevicePath including the end of device path node. - If DevicePath is NULL or invalid, then 0 is returned. - - @param DevicePath A pointer to a device path data structure. - - @retval 0 If DevicePath is NULL or invalid. - @retval Others The size of a device path in bytes. - -**/ -UINTN -EFIAPI -GetDevicePathSize ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -{ - CONST EFI_DEVICE_PATH_PROTOCOL *Start; - - if (DevicePath == NULL) { - return 0; - } - - if (!IsDevicePathValid (DevicePath, 0)) { - return 0; - } - - // - // Search for the end of the device path structure - // - Start = DevicePath; - while (!IsDevicePathEnd (DevicePath)) { - DevicePath = NextDevicePathNode (DevicePath); - } - - // - // Compute the size and add back in the size of the end device path structure - // - return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath); -} - /** Determine whether a given device path is valid. If DevicePath is NULL, then ASSERT(). @@ -212,7 +168,6 @@ DevicePathType ( return ((const EFI_DEVICE_PATH_PROTOCOL *)(Node))->Type; } - /** Returns the SubType field of a device path node. @@ -342,32 +297,6 @@ IsDevicePathEnd ( return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE); } -/** - Fills in all the fields of a device path node that is the end of an entire device path. - - Fills in all the fields of a device path node specified by Node so Node represents - the end of an entire device path. The Type field of Node is set to - END_DEVICE_PATH_TYPE, the SubType field of Node is set to - END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to - END_DEVICE_PATH_LENGTH. Node is not required to be aligned on a 16-bit boundary, - so it is recommended that a function such as WriteUnaligned16() be used to set - the contents of the Length field. - - If Node is NULL, then ASSERT(). - - @param Node A pointer to a device path node data structure. - -**/ -VOID -EFIAPI -SetDevicePathEndNode ( - OUT VOID *Node - ) -{ - ASSERT (Node != NULL); - memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath)); -} - /** Sets the length, in bytes, of a device path node. @@ -401,49 +330,72 @@ SetDevicePathNodeLength ( } /** - Creates a device node. + Fills in all the fields of a device path node that is the end of an entire device path. - This function creates a new device node in a newly allocated buffer of size - NodeLength and initializes the device path node header with NodeType and NodeSubType. - The new device path node is returned. - If NodeLength is smaller than a device path header, then NULL is returned. - If there is not enough memory to allocate space for the new device path, then - NULL is returned. - The memory is allocated from EFI boot services memory. It is the responsibility - of the caller to free the memory allocated. + Fills in all the fields of a device path node specified by Node so Node represents + the end of an entire device path. The Type field of Node is set to + END_DEVICE_PATH_TYPE, the SubType field of Node is set to + END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to + END_DEVICE_PATH_LENGTH. Node is not required to be aligned on a 16-bit boundary, + so it is recommended that a function such as WriteUnaligned16() be used to set + the contents of the Length field. - @param NodeType The device node type for the new device node. - @param NodeSubType The device node sub-type for the new device node. - @param NodeLength The length of the new device node. + If Node is NULL, then ASSERT(). - @return The new device path. + @param Node A pointer to a device path node data structure. **/ -EFI_DEVICE_PATH_PROTOCOL * +VOID EFIAPI -CreateDeviceNode ( - IN UINT8 NodeType, - IN UINT8 NodeSubType, - IN UINT16 NodeLength +SetDevicePathEndNode ( + OUT VOID *Node ) { - EFI_DEVICE_PATH_PROTOCOL *DevicePath; + ASSERT (Node != NULL); + memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath)); +} - if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { - // - // NodeLength is less than the size of the header. - // - return NULL; +/** + Returns the size of a device path in bytes. + + This function returns the size, in bytes, of the device path data structure + specified by DevicePath including the end of device path node. + If DevicePath is NULL or invalid, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. + + @retval 0 If DevicePath is NULL or invalid. + @retval Others The size of a device path in bytes. + +**/ +UINTN +EFIAPI +GetDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Start; + + if (DevicePath == NULL) { + return 0; } - DevicePath = AllocateZeroPool (NodeLength); - if (DevicePath != NULL) { - DevicePath->Type = NodeType; - DevicePath->SubType = NodeSubType; - SetDevicePathNodeLength (DevicePath, NodeLength); + if (!IsDevicePathValid (DevicePath, 0)) { + return 0; } - return DevicePath; + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!IsDevicePathEnd (DevicePath)) { + DevicePath = NextDevicePathNode (DevicePath); + } + + // + // Compute the size and add back in the size of the end device path structure + // + return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath); } /** @@ -627,3 +579,49 @@ AppendDevicePathNode ( return NewDevicePath; } + +/** + Creates a device node. + + This function creates a new device node in a newly allocated buffer of size + NodeLength and initializes the device path node header with NodeType and NodeSubType. + The new device path node is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then + NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility + of the caller to free the memory allocated. + + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. + + @return The new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +CreateDeviceNode ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { + // + // NodeLength is less than the size of the header. + // + return NULL; + } + + DevicePath = AllocateZeroPool (NodeLength); + if (DevicePath != NULL) { + DevicePath->Type = NodeType; + DevicePath->SubType = NodeSubType; + SetDevicePathNodeLength (DevicePath, NodeLength); + } + + return DevicePath; +}