From nobody Sat May 13 12:20:22 2023 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 4QJPpt2mTfz4BKPr; Sat, 13 May 2023 12:20:22 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QJPpt2BTQz3y5j; Sat, 13 May 2023 12:20:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683980422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gAIKgdfS2doFb6YJNFvhRjR7//dK4vLLBLZrpgOqEnI=; b=dqHAMeavBKCg63AnTNioMVySzdwIdYSCctclBNDEGHfEzv0wCq9WVT6r0YxA4g6t8qiLOm UEV7KDT+DQJCTK1cbH97RBCDIFA7BX2HOO3aB/0+z1bzcQ35DX2AYq4ZPO37IVcZrDScW/ 7VVwVRsYEtonczOapGl9I0+ls3nAhV0ZlCycARxRGefn6CPqS/Igk+HtRghSJf5i+v6nel f2wOuLbwB3T+noCDWutkTtHjAHXHIdn+e6Ype3L9//2U18EBbVtvkN+OM3mBD3LqesuRyz BpmOmduBZGpr03+jl+KHYrboVZx5QEdi7RJ6VF3fr7u4VmQ9c0vdZAlRrUybow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683980422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gAIKgdfS2doFb6YJNFvhRjR7//dK4vLLBLZrpgOqEnI=; b=e4Tcv4Se+L4Lk0NTvBqvDyfrqJLwkf9eCvFe2cEmyTrwCMmT6Empg6lxCK8BTP6wf0c61f R19QiB0Ji3x+L0cK8pKa37Fhwpul4lRYr2LIuECoEFVK4NpDEcdcDzQWZdcfTCXjrcvGQH CN0N/gm1LSpHc3bRpnCjjYXAew60NJy8IiR+JMa/oKXjF1nvIjuLJw9dnUi/aFTTMhCmVR I5JN3RzxRZ+eZxTcKXB1IHeXRY+uvM/kBoa54Zh1KhqCKa8GOwyPutcgVcs79iMKiiw6DJ rC9rN1Mz0J/9+lvBv5iIqu8Lk7hlyPhOSulz0ouvLLjfOxIQHruML4XmlfDk4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683980422; a=rsa-sha256; cv=none; b=hD+SP5BOb+0CzaX9HJ37EXFi0ZfN+MablA0Bmo4AGk/ESpY4sY2dt8WkfK7eQcuOYv6XJr EtLqwCFr7ifDPQUc0/ROTq+AW+SODmih28ek78PSX1xvcbwBCrt8HfgyRI7skSezXrx8SD P+ObASgOmSkaK0sNmtq5oQhRxR2HCsydd+QCIWvml9C9sDUE/Owru5RJN9T1AQFyhmz4e0 Y488nAGAIvCtLdHJ9tXxisRYlRJS0wpjmRCNrAqIcPlTNEZ+7tiOM2VkvBupq6TNV0w34V CcROPPLC8ixYVZ6/soU60cLpPj9apuIG5df9BBBE6JPDI57rGcMqvq+Q4pFbzQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QJPpt0xntzGqn; Sat, 13 May 2023 12:20:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34DCKMjF097030; Sat, 13 May 2023 12:20:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34DCKM9V097029; Sat, 13 May 2023 12:20:22 GMT (envelope-from git) Date: Sat, 13 May 2023 12:20:22 GMT Message-Id: <202305131220.34DCKM9V097029@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: f2b3bf5c4d4a - main - libefi: add efi_devpath_next_instance() 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f2b3bf5c4d4a391648e5b2740e81bccb85752ae5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=f2b3bf5c4d4a391648e5b2740e81bccb85752ae5 commit f2b3bf5c4d4a391648e5b2740e81bccb85752ae5 Author: Toomas Soome AuthorDate: 2023-05-12 15:41:14 +0000 Commit: Toomas Soome CommitDate: 2023-05-13 12:16:10 +0000 libefi: add efi_devpath_next_instance() UEFI device path may be path to one device, or concatenated list of instances to different devices (textually represented as comma separated list). Provide generic function to get next instance from device path. Returns next instance or end node. The use case is like: EFI_DEVICE_PATH *node = (EFI_DEVICE_PATH *)buf; while (!IsDevicePathEnd(node)) { process(node); node = efi_devpath_next_instance(node); } Where buf is pointing to either single device path or concatenated list of device paths (such as from ConIn or ConOut). Reviewers: imp Differential Revision: https://reviews.freebsd.org/D40081 --- stand/efi/include/efilib.h | 1 + stand/efi/libefi/devpath.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/stand/efi/include/efilib.h b/stand/efi/include/efilib.h index 1673ac97fdf2..df4ae6503760 100644 --- a/stand/efi/include/efilib.h +++ b/stand/efi/include/efilib.h @@ -97,6 +97,7 @@ void efi_close_devpath(EFI_HANDLE); EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_last_node(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_trim(EFI_DEVICE_PATH *); +EFI_DEVICE_PATH *efi_devpath_next_instance(EFI_DEVICE_PATH *); bool efi_devpath_match(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); bool efi_devpath_match_node(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); diff --git a/stand/efi/libefi/devpath.c b/stand/efi/libefi/devpath.c index c25ae73e463c..94bb07540376 100644 --- a/stand/efi/libefi/devpath.c +++ b/stand/efi/libefi/devpath.c @@ -575,6 +575,23 @@ efi_devpath_last_node(EFI_DEVICE_PATH *devpath) return (devpath); } +/* + * Walk device path nodes, return next instance or end node. + */ +EFI_DEVICE_PATH * +efi_devpath_next_instance(EFI_DEVICE_PATH *devpath) +{ + while (!IsDevicePathEnd(devpath)) { + devpath = NextDevicePathNode(devpath); + if (IsDevicePathEndType(devpath) && + devpath->SubType == END_INSTANCE_DEVICE_PATH_SUBTYPE) { + devpath = NextDevicePathNode(devpath); + break; + } + } + return (devpath); +} + EFI_DEVICE_PATH * efi_devpath_trim(EFI_DEVICE_PATH *devpath) {