From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.9276.1639042381947593976 for ; Thu, 09 Dec 2021 01:33:02 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A1B1611FB; Thu, 9 Dec 2021 01:33:01 -0800 (PST) Received: from e126645.nice.arm.com (unknown [10.34.129.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B01BB3F73B; Thu, 9 Dec 2021 01:33:00 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [PATCH v3 2/5] DynamicTablesPkg: DynamicPlatRepo: Add TokenGenerator Date: Thu, 9 Dec 2021 10:32:48 +0100 Message-Id: <20211209093251.1249368-3-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211209093251.1249368-1-Pierre.Gondois@arm.com> References: <20211209093251.1249368-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pierre Gondois The DynamicPlatRepo library allows to handle dynamically created CmObj. The dynamic platform repository can be in the following states: 1 - Non-initialised 2 - Transient: Possibility to add CmObj to the platform, but not to query them. 3 - Finalised: Possibility to query CmObj, but not to add new. A token is allocated to each CmObj added to the dynamic platform repository (except for reference tokens CmObj). This allows to retrieve dynamic CmObjs among all CmObj (static CmObj for instance). This patch add the TokenGenerator files. Signed-off-by: Pierre Gondois --- .../DynamicPlatRepoLib/TokenGenerator.c | 29 +++++++++++++++++++ .../DynamicPlatRepoLib/TokenGenerator.h | 26 +++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/To= kenGenerator.c create mode 100644 DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/To= kenGenerator.h diff --git a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGene= rator.c b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerat= or.c new file mode 100644 index 000000000000..7033b5f1b5dd --- /dev/null +++ b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c @@ -0,0 +1,29 @@ +/** @file + Token Generator + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Cm or CM - Configuration Manager + - Obj or OBJ - Object +**/ + +#include + +/** Generate a token. + + @return A token. +**/ +CM_OBJECT_TOKEN +EFIAPI +GenerateToken ( + VOID + ) +{ + // Start Tokens at 1 to avoid collisions with CM_NULL_TOKEN. + STATIC UINTN CurrentToken =3D 1; + + return (CM_OBJECT_TOKEN)(CurrentToken++); +} diff --git a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGene= rator.h b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerat= or.h new file mode 100644 index 000000000000..44d32e5b41a1 --- /dev/null +++ b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.h @@ -0,0 +1,26 @@ +/** @file + Token Generator + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Cm or CM - Configuration Manager + - Obj or OBJ - Object +**/ + +#ifndef TOKEN_GENERATOR_H_ +#define TOKEN_GENERATOR_H_ + +/** Generate a token. + + @return A token. +**/ +CM_OBJECT_TOKEN +EFIAPI +GenerateToken ( + VOID + ); + +#endif // TOKEN_GENERATOR_H_ --=20 2.25.1