summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg
diff options
context:
space:
mode:
authorPierre Gondois <Pierre.Gondois@arm.com>2021-12-09 10:32:48 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-14 18:45:19 +0000
commit2e2db65e39cbd011468b3ebd23d6e645277c2409 (patch)
treec3412bd36d1b02aa9bbcbc128ad87c24019fa50a /DynamicTablesPkg
parentb2d0ed20fd50ebad2cafaf2c39c2c20c6083b690 (diff)
downloadedk2-2e2db65e39cbd011468b3ebd23d6e645277c2409.tar.gz
edk2-2e2db65e39cbd011468b3ebd23d6e645277c2409.tar.bz2
edk2-2e2db65e39cbd011468b3ebd23d6e645277c2409.zip
DynamicTablesPkg: DynamicPlatRepo: Add TokenGenerator
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 <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'DynamicTablesPkg')
-rw-r--r--DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c29
-rw-r--r--DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.h26
2 files changed, 55 insertions, 0 deletions
diff --git a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c
new file mode 100644
index 0000000000..7033b5f1b5
--- /dev/null
+++ b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c
@@ -0,0 +1,29 @@
+/** @file
+ Token Generator
+
+ Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Glossary:
+ - Cm or CM - Configuration Manager
+ - Obj or OBJ - Object
+**/
+
+#include <Protocol/ConfigurationManagerProtocol.h>
+
+/** 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 = 1;
+
+ return (CM_OBJECT_TOKEN)(CurrentToken++);
+}
diff --git a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.h b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.h
new file mode 100644
index 0000000000..44d32e5b41
--- /dev/null
+++ b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.h
@@ -0,0 +1,26 @@
+/** @file
+ Token Generator
+
+ Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
+
+ 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_