public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: pierre.gondois@arm.com, devel@edk2.groups.io
Cc: Sami Mujawar <sami.mujawar@arm.com>,
	Alexei Fedorov <Alexei.Fedorov@arm.com>
Subject: [PATCH v2 2/5] DynamicTablesPkg: DynamicPlatRepo: Add TokenGenerator
Date: Tue, 23 Nov 2021 12:10:07 +0100	[thread overview]
Message-ID: <20211123111010.72679-3-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20211123111010.72679-1-Pierre.Gondois@arm.com>

From: Pierre Gondois <Pierre.Gondois@arm.com>

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>
---
 .../DynamicPlatRepoLib/TokenGenerator.c       | 28 +++++++++++++++++++
 .../DynamicPlatRepoLib/TokenGenerator.h       | 26 +++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c
 create mode 100644 DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.h

diff --git a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c
new file mode 100644
index 000000000000..637e784bd284
--- /dev/null
+++ b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/TokenGenerator.c
@@ -0,0 +1,28 @@
+/** @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 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.<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_
-- 
2.25.1


  parent reply	other threads:[~2021-11-23 11:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 11:10 [PATCH v2 0/5] Add DynamicPlatRepoLib PierreGondois
2021-11-23 11:10 ` [PATCH v2 1/5] DynamicTablesPkg: Definition for DynamicPlatRepoLib interface PierreGondois
2021-11-23 11:10 ` PierreGondois [this message]
2021-11-23 11:10 ` [PATCH v2 3/5] DynamicTablesPkg: DynamicPlatRepo: Add TokenFixer PierreGondois
2021-11-23 11:10 ` [PATCH v2 4/5] DynamicTablesPkg: DynamicPlatRepo: Add TokenMapper PierreGondois
2021-11-23 11:10 ` [PATCH v2 5/5] DynamicTablesPkg: Add DynamicPlatRepo library PierreGondois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211123111010.72679-3-Pierre.Gondois@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox