diff options
Diffstat (limited to 'EdkModulePkg/Universal/PCD/Dxe')
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Pcd.c | 472 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Service.c | 491 | ||||
-rw-r--r-- | EdkModulePkg/Universal/PCD/Dxe/Service.h | 399 |
3 files changed, 1362 insertions, 0 deletions
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c new file mode 100644 index 0000000000..4ed7eb0cd0 --- /dev/null +++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c @@ -0,0 +1,472 @@ +/** @file
+PCD DXE driver
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name: Pcd.c
+
+**/
+
+#include "../Common/PcdCommon.h"
+#include "Service.h"
+
+
+PCD_PROTOCOL mPcdInstance = {
+ DxePcdSetSku,
+
+ DxePcdGet8,
+ DxePcdGet16,
+ DxePcdGet32,
+ DxePcdGet64,
+ DxePcdGetPtr,
+ DxePcdGetBool,
+ DxePcdGetSize,
+
+ DxePcdGet8Ex,
+ DxePcdGet16Ex,
+ DxePcdGet32Ex,
+ DxePcdGet64Ex,
+ DxePcdGetPtrEx,
+ DxePcdGetBoolEx,
+ DxePcdGetSizeEx,
+
+ DxePcdSet8,
+ DxePcdSet16,
+ DxePcdSet32,
+ DxePcdSet64,
+ DxePcdSetPtr,
+ DxePcdSetBool,
+
+ DxePcdSet8Ex,
+ DxePcdSet16Ex,
+ DxePcdSet32Ex,
+ DxePcdSet64Ex,
+ DxePcdSetPtrEx,
+ DxePcdSetBoolEx,
+
+ PcdRegisterCallBackOnSet,
+ PcdUnRegisterCallBackOnSet,
+ DxePcdGetNextToken
+};
+
+
+//
+// Static global to reduce the code size
+//
+static EFI_HANDLE NewHandle = NULL;
+
+EFI_STATUS
+EFIAPI
+PcdDxeInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ InitPcdDxeDataBase ();
+
+ Status = gBS->InstallProtocolInterface (
+ &NewHandle,
+ &gPcdProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mPcdInstance
+ );
+
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+
+}
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetSku (
+ IN UINTN SkuId
+ )
+{
+ return DxeSetSku(SkuId);
+}
+
+
+
+UINT8
+EFIAPI
+DxePcdGet8 (
+ IN UINTN TokenNumber
+ )
+{
+ return DxePcdGet8Ex (NULL, TokenNumber);
+}
+
+
+
+UINT16
+EFIAPI
+DxePcdGet16 (
+ IN UINTN TokenNumber
+ )
+{
+ return DxePcdGet16Ex (NULL, TokenNumber);
+}
+
+
+
+UINT32
+EFIAPI
+DxePcdGet32 (
+ IN UINTN TokenNumber
+ )
+{
+ return DxePcdGet32Ex (NULL, TokenNumber);
+}
+
+
+
+UINT64
+EFIAPI
+DxePcdGet64 (
+ IN UINTN TokenNumber
+ )
+{
+ return DxePcdGet32Ex (NULL, TokenNumber);
+}
+
+
+
+VOID *
+EFIAPI
+DxePcdGetPtr (
+ IN UINTN TokenNumber
+ )
+{
+ return DxePcdGetPtrEx (NULL, TokenNumber);
+}
+
+
+
+BOOLEAN
+EFIAPI
+DxePcdGetBool (
+ IN UINTN TokenNumber
+ )
+{
+ return DxePcdGetBoolEx (NULL, TokenNumber);
+}
+
+
+
+UINTN
+EFIAPI
+DxePcdGetSize (
+ IN UINTN TokenNumber
+ )
+{
+ return DxePcdGetSizeEx (NULL, TokenNumber);
+}
+
+
+
+UINT8
+EFIAPI
+DxePcdGet8Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+{
+ UINT8 Data;
+
+ DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte8, &Data);
+
+ return Data;
+}
+
+
+
+UINT16
+EFIAPI
+DxePcdGet16Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+{
+ UINT16 Data;
+
+ DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte16, &Data);
+
+ return Data;
+}
+
+
+
+UINT32
+EFIAPI
+DxePcdGet32Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+{
+ UINT32 Data;
+
+ DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte32, &Data);
+
+ return Data;
+}
+
+
+
+UINT64
+EFIAPI
+DxePcdGet64Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+{
+ UINT64 Data;
+
+ DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte64, &Data);
+
+ return Data;
+}
+
+
+
+VOID *
+EFIAPI
+DxePcdGetPtrEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+{
+ VOID *Data;
+
+ DxeGetPcdEntryWorker (TokenNumber, Guid, PcdPointer, &Data);
+
+ return Data;
+}
+
+
+
+BOOLEAN
+EFIAPI
+DxePcdGetBoolEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+{
+ BOOLEAN Data;
+ DxeGetPcdEntryWorker (TokenNumber, Guid, PcdBoolean, &Data);
+ return Data;
+}
+
+
+
+UINTN
+EFIAPI
+DxePcdGetSizeEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+{
+ return DxeGetPcdEntrySizeWorker (TokenNumber, Guid);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet8 (
+ IN UINTN TokenNumber,
+ IN UINT8 Value
+ )
+{
+ return DxePcdSet8Ex (NULL, TokenNumber, Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet16 (
+ IN UINTN TokenNumber,
+ IN UINT16 Value
+ )
+{
+ return DxePcdSet16Ex (NULL, TokenNumber, Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet32 (
+ IN UINTN TokenNumber,
+ IN UINT32 Value
+ )
+{
+ return DxePcdSet32Ex (NULL, TokenNumber, Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet64 (
+ IN UINTN TokenNumber,
+ IN UINT64 Value
+ )
+{
+ return DxePcdSet64Ex (NULL, TokenNumber, Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetPtr (
+ IN UINTN TokenNumber,
+ IN CONST VOID *Value
+ )
+{
+ return DxePcdSetPtrEx (NULL, TokenNumber, Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetBool (
+ IN UINTN TokenNumber,
+ IN BOOLEAN Value
+ )
+{
+ return DxePcdSetBoolEx (NULL, TokenNumber, Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet8Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT8 Value
+ )
+{
+ return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte8, &Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet16Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT16 Value
+ )
+{
+ return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte16, &Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet32Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT32 Value
+ )
+{
+ return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte32, &Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet64Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT64 Value
+ )
+{
+ return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte64, &Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetPtrEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN CONST VOID *Value
+ )
+{
+ return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdPointer, Value);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetBoolEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN BOOLEAN Value
+ )
+{
+ return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdBoolean, &Value);
+
+}
+
+
+
+
+EFI_STATUS
+EFIAPI
+PcdRegisterCallBackOnSet (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+ )
+{
+ return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction, TRUE);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+PcdUnRegisterCallBackOnSet (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+ )
+{
+ return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction, FALSE);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+DxePcdGetNextToken (
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN OUT UINTN *TokenNumber
+ )
+{
+ return DxeGetNextTokenWorker (TokenNumber, Guid);
+}
+
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.c b/EdkModulePkg/Universal/PCD/Dxe/Service.c new file mode 100644 index 0000000000..280a45ea31 --- /dev/null +++ b/EdkModulePkg/Universal/PCD/Dxe/Service.c @@ -0,0 +1,491 @@ +/** @file
+Private functions used by PCD DXE driver.s
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name: Service.c
+
+**/
+#include "../Common/PcdCommon.h"
+#include "Service.h"
+
+static PCD_DATABASE *PrivatePcdDxeDatabase;
+static LIST_ENTRY mPcdDatabaseListHead = INITIALIZE_LIST_HEAD_VARIABLE(mPcdDatabaseListHead);
+
+LIST_ENTRY *
+GetPcdDatabaseListHead (
+ VOID
+ )
+{
+ return &mPcdDatabaseListHead;
+}
+
+PCD_DATABASE *
+GetPcdDxeDataBaseInstance (
+ VOID
+)
+{
+ return PrivatePcdDxeDatabase;
+}
+
+PCD_DATABASE *
+SetPcdDxeDataBaseInstance (
+ PCD_DATABASE *PcdDatabase
+)
+{
+ return PrivatePcdDxeDatabase = PcdDatabase;
+}
+
+
+VOID
+DxeGetPcdEntryWorker (
+ IN UINTN TokenNumber,
+ IN CONST GUID *Guid, OPTIONAL
+ IN PCD_DATA_TYPE Type,
+ OUT VOID *Data
+ )
+{
+ PCD_DATABASE *Database;
+ Database = GetPcdDxeDataBaseInstance ();
+
+ GetPcdEntryWorker ( &Database->Info,
+ TokenNumber,
+ Guid,
+ Type,
+ Data
+ );
+
+
+ return;
+}
+
+
+
+EFI_STATUS
+DxeSetPcdEntryWorker (
+ IN UINTN TokenNumber,
+ IN CONST GUID *Guid, OPTIONAL
+ IN PCD_DATA_TYPE Type,
+ IN CONST VOID *Data
+ )
+{
+ PCD_DATABASE *Database;
+ PCD_INDEX *PcdIndex;
+ EFI_STATUS Status;
+
+ Database = GetPcdDxeDataBaseInstance ();
+
+
+ ASSERT (Data != NULL);
+
+ PcdIndex = FindPcdIndex (TokenNumber, Guid, &Database->Info, NULL);
+
+ ASSERT (PcdIndex != NULL);
+
+ ASSERT (PcdIndex->StateByte.DataType == Type);
+
+ //
+ // Invoke the callback function.
+ //
+
+ Status = SetPcdData (PcdIndex, &Database->Info, Data);
+
+ return Status;
+
+
+}
+
+
+
+UINTN
+DxeGetPcdEntrySizeWorker (
+ IN UINTN TokenNumber,
+ IN CONST GUID *Guid OPTIONAL
+ )
+{
+ PCD_DATABASE *Database;
+ Database = GetPcdDxeDataBaseInstance ();
+
+ return GetPcdEntrySizeWorker (&Database->Info,
+ TokenNumber,
+ Guid
+ );
+}
+
+
+
+LIST_ENTRY *
+InsertToGuidSpaceListI (
+ IN LIST_ENTRY *GuidSpaceListHead,
+ IN CONST EFI_GUID *Guid
+ )
+{
+ PCD_GUID_SPACE *GuidSpaceEntry;
+
+ GuidSpaceEntry = AllocatePool (sizeof (PCD_GUID_SPACE));
+ ASSERT (GuidSpaceEntry != NULL);
+
+ GuidSpaceEntry->GuidSpace= Guid;
+ InitializeListHead (&GuidSpaceEntry->TokenSpaceHead);
+
+ InsertTailList (GuidSpaceListHead, &GuidSpaceEntry->ListNode);
+
+ return &GuidSpaceEntry->TokenSpaceHead;
+}
+
+
+
+LIST_ENTRY *
+InsertToTokenSpaceListI (
+ IN LIST_ENTRY *TokenSpaceListHead,
+ IN UINTN TokenNumber
+ )
+{
+ PCD_TOKEN_SPACE *TokenSpaceEntry;
+
+ TokenSpaceEntry = AllocatePool (sizeof (PCD_TOKEN_SPACE));
+ ASSERT (TokenSpaceEntry != NULL);
+
+ TokenSpaceEntry->TokeNumber = TokenNumber;
+ InitializeListHead (&TokenSpaceEntry->CallbackListHead);
+
+ InsertTailList (TokenSpaceListHead, &TokenSpaceEntry->ListNode);
+
+ return &TokenSpaceEntry->CallbackListHead;
+}
+
+
+
+VOID
+InsertToCallbackListI (
+ IN LIST_ENTRY *CallbackListHead,
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+ )
+{
+ PCD_CALLBACK_ENTRY *CallbackEntry;
+
+ CallbackEntry = AllocatePool (sizeof (PCD_CALLBACK_ENTRY));
+ ASSERT (CallbackEntry != NULL);
+ CallbackEntry->CallbackFunction = CallBackFunction;
+ InsertTailList (CallbackListHead, &CallbackEntry->ListNode);
+
+ return;
+}
+
+
+
+
+VOID
+InsertToCallbackList (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid,
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+ )
+{
+ LIST_ENTRY *GuidListNode;
+ LIST_ENTRY *GuidListHead;
+ LIST_ENTRY *TokenListNode;
+ LIST_ENTRY *TokenListHead;
+ LIST_ENTRY *CallbackListHead;
+ PCD_GUID_SPACE *GuidSpaceEntry;
+ PCD_TOKEN_SPACE *TokenSpaceEntry;
+
+
+ GuidListHead = GetPcdDatabaseListHead ();
+
+ GuidListNode = GetFirstNode (GuidListHead);
+ while (!IsNull (GuidListNode, GuidListHead)) {
+ GuidSpaceEntry = PCD_GUID_SPACE_FROM_LISTNODE(GuidListNode);
+
+ if (CompareGuid (GuidSpaceEntry->GuidSpace, Guid)) {
+ TokenListHead = &GuidSpaceEntry->TokenSpaceHead;
+ TokenListNode = GetFirstNode (TokenListHead);
+ while (!IsNull (TokenListNode, TokenListHead)) {
+ TokenSpaceEntry = PCD_TOKEN_SPACE_FROM_LISTNODE(TokenListNode);
+ if (TokenSpaceEntry->TokeNumber == TokenNumber) {
+ InsertToCallbackListI (&TokenSpaceEntry->CallbackListHead , CallBackFunction);
+ }
+ }
+
+ //
+ // No TokenNumber match input found in this GuidSpace
+ //
+ CallbackListHead = InsertToTokenSpaceListI (TokenListHead, TokenNumber);
+ InsertToCallbackListI (CallbackListHead , CallBackFunction);
+ }
+
+ GuidListNode = GetNextNode (GuidListHead, GuidListNode);
+ }
+
+ //
+ // No GuidSpace match the input Guid, so build the GuidSpace, TokenNumberSpace and Callback
+ //
+ TokenListHead = InsertToGuidSpaceListI (GuidListHead, Guid);
+ CallbackListHead = InsertToTokenSpaceListI (TokenListHead, TokenNumber);
+ InsertToCallbackListI (CallbackListHead , CallBackFunction);
+
+ return;
+
+}
+
+EFI_STATUS
+RemoveFromCallbackListI (
+ IN LIST_ENTRY *CallbackListHead,
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+ )
+{
+ LIST_ENTRY *ListNode;
+ PCD_CALLBACK_ENTRY *CallbackEntry;
+
+ ListNode = GetFirstNode (CallbackListHead);
+
+ while (!IsNull(CallbackListHead, ListNode)) {
+ CallbackEntry = PCD_CALLBACK_ENTRY_FROM_LISTNODE(ListNode);
+
+ if (CallbackEntry->CallbackFunction == CallBackFunction) {
+ RemoveEntryList (ListNode);
+ FreePool (CallbackEntry);
+ return EFI_SUCCESS;
+ }
+ ListNode = GetNextNode (CallbackListHead, ListNode);
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+
+EFI_STATUS
+RemoveFromCallbackList (
+ IN UINTN TokenNumber,
+ IN CONST GUID *Guid,
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+ )
+{
+ LIST_ENTRY *GuidListNode;
+ LIST_ENTRY *GuidListHead;
+ LIST_ENTRY *TokenListNode;
+ LIST_ENTRY *TokenListHead;
+ PCD_GUID_SPACE *GuidSpaceEntry;
+ PCD_TOKEN_SPACE *TokenSpaceEntry;
+
+
+ GuidListHead = GetPcdDatabaseListHead ();
+
+ GuidListNode = GetFirstNode (GuidListHead);
+ while (!IsNull (GuidListNode, GuidListHead)) {
+
+ GuidSpaceEntry = PCD_GUID_SPACE_FROM_LISTNODE(GuidListNode);
+ if (CompareGuid (GuidSpaceEntry->GuidSpace, Guid)) {
+
+ TokenListHead = &GuidSpaceEntry->TokenSpaceHead;
+ TokenListNode = GetFirstNode (TokenListHead);
+ while (!IsNull (TokenListNode, TokenListHead)) {
+
+ TokenSpaceEntry = PCD_TOKEN_SPACE_FROM_LISTNODE(TokenListNode);
+ if (TokenSpaceEntry->TokeNumber == TokenNumber) {
+ return RemoveFromCallbackListI (&TokenSpaceEntry->CallbackListHead , CallBackFunction);
+ }
+ }
+
+ //
+ // No TokenNumber match input found in this GuidSpace
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ GuidListNode = GetNextNode (GuidListHead, GuidListNode);
+ }
+
+
+ return EFI_NOT_FOUND;
+
+}
+
+
+
+EFI_STATUS
+DxeRegisterCallBackWorker (
+ IN UINTN TokenNumber,
+ IN CONST GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction,
+ IN BOOLEAN Register
+)
+{
+ PCD_DATABASE *Database;
+ PCD_INDEX *PcdIndex;
+
+ Database = GetPcdDxeDataBaseInstance ();
+
+ PcdIndex = FindPcdIndex (TokenNumber, Guid, &Database->Info, NULL);
+
+ if (PcdIndex == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (Register) {
+ InsertToCallbackList (TokenNumber, Guid, CallBackFunction);
+ return EFI_SUCCESS;
+ } else {
+ return RemoveFromCallbackList (TokenNumber, Guid, CallBackFunction);
+ }
+
+ }
+
+
+
+EFI_STATUS
+DxeSetSku (
+ UINTN Id
+)
+{
+ PCD_DATABASE * Database;
+
+ Database = GetPcdDxeDataBaseInstance ();
+
+ return Database->Info.SkuId = Id;
+
+}
+
+
+
+EFI_STATUS
+DxeGetNextTokenWorker (
+ IN OUT UINTN *TokenNumber,
+ IN CONST GUID *Guid OPTIONAL
+ )
+{
+ PCD_DATABASE * Database;
+
+ Database = GetPcdDxeDataBaseInstance ();
+
+ return GetNextTokenWorker (&Database->Info,
+ TokenNumber,
+ Guid
+ );
+}
+
+
+
+VOID
+InitPcdDxeDataBase (
+ VOID
+)
+{
+ PCD_DATABASE *PeiDatabase;
+ PCD_DATABASE *DxeDatabase;
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
+ ASSERT (GuidHob != NULL);
+
+ PeiDatabase = (PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
+
+ DxeDatabase = AllocateCopyPool (PeiDatabase->Info.DatabaseLen, PeiDatabase);
+
+ ASSERT (DxeDatabase != NULL);
+
+ SetPcdDxeDataBaseInstance (DxeDatabase);
+
+ return;
+}
+
+
+
+EFI_STATUS
+GetHiiVariable (
+ IN EFI_GUID *VariableGuid,
+ IN UINT16 *VariableName,
+ OUT VOID ** VariableData,
+ OUT UINTN *VariableSize
+ )
+{
+ UINTN Size;
+ EFI_STATUS Status;
+ VOID *Buffer;
+
+ Status = EfiGetVariable (
+ (UINT16 *)VariableName,
+ VariableGuid,
+ NULL,
+ &Size,
+ NULL
+ );
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+
+ Buffer = AllocatePool (Size);
+
+ ASSERT (Buffer != NULL);
+
+ Status = EfiGetVariable (
+ VariableName,
+ VariableGuid,
+ NULL,
+ &Size,
+ Buffer
+ );
+
+ return Status;
+
+}
+
+
+
+EFI_STATUS
+SetHiiVariable (
+ IN EFI_GUID *VariableGuid,
+ IN UINT16 *VariableName,
+ IN CONST VOID *Data,
+ IN UINTN DataSize,
+ IN UINTN Offset
+ )
+{
+ UINTN Size;
+ VOID *Buffer;
+ EFI_STATUS Status;
+
+ Size = 0;
+
+ Status = EfiGetVariable (
+ (UINT16 *)VariableName,
+ VariableGuid,
+ NULL,
+ &Size,
+ NULL
+ );
+
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+
+ Buffer = AllocatePool (Size);
+
+ ASSERT (Buffer != NULL);
+
+ Status = EfiGetVariable (
+ VariableName,
+ VariableGuid,
+ NULL,
+ &Size,
+ Buffer
+ );
+
+
+ CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
+
+ return EfiSetVariable (
+ VariableName,
+ VariableGuid,
+ 0,
+ Size,
+ Buffer
+ );
+
+}
+
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.h b/EdkModulePkg/Universal/PCD/Dxe/Service.h new file mode 100644 index 0000000000..86e3dfdee3 --- /dev/null +++ b/EdkModulePkg/Universal/PCD/Dxe/Service.h @@ -0,0 +1,399 @@ +/** @file
+Private functions used by PCD DXE driver.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name: Service.h
+
+**/
+
+#ifndef _SERVICE_H
+#define _SERVICE_H
+
+VOID
+DxeGetPcdEntryWorker (
+ IN UINTN Token,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_DATA_TYPE Type,
+ OUT VOID *Data
+ );
+
+EFI_STATUS
+DxeSetPcdEntryWorker (
+ IN UINTN Token,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_DATA_TYPE Type,
+ IN CONST VOID *Data
+ );
+
+UINTN
+DxeGetPcdEntrySizeWorker (
+ IN UINTN Token,
+ IN CONST EFI_GUID *Guid OPTIONAL
+ );
+
+EFI_STATUS
+DxeRegisterCallBackWorker (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction,
+ IN BOOLEAN Reigster
+);
+
+EFI_STATUS
+DxeSetSku (
+ UINTN Id
+);
+
+EFI_STATUS
+DxeGetNextTokenWorker (
+ IN OUT UINTN *Token,
+ IN CONST EFI_GUID *Guid OPTIONAL
+ );
+
+VOID
+InitPcdDxeDataBase (
+ VOID
+);
+
+//
+// Protocol Interface function declaration.
+//
+EFI_STATUS
+EFIAPI
+DxePcdSetSku (
+ IN UINTN SkuId
+ )
+;
+
+
+UINT8
+EFIAPI
+DxePcdGet8 (
+ IN UINTN TokenNumber
+ )
+;
+
+
+UINT16
+EFIAPI
+DxePcdGet16 (
+ IN UINTN TokenNumber
+ )
+;
+
+
+UINT32
+EFIAPI
+DxePcdGet32 (
+ IN UINTN TokenNumber
+ )
+;
+
+
+UINT64
+EFIAPI
+DxePcdGet64 (
+ IN UINTN TokenNumber
+ )
+;
+
+
+VOID *
+EFIAPI
+DxePcdGetPtr (
+ IN UINTN TokenNumber
+ )
+;
+
+
+BOOLEAN
+EFIAPI
+DxePcdGetBool (
+ IN UINTN TokenNumber
+ )
+;
+
+
+UINTN
+EFIAPI
+DxePcdGetSize (
+ IN UINTN TokenNumber
+ )
+;
+
+
+UINT8
+EFIAPI
+DxePcdGet8Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+;
+
+
+UINT16
+EFIAPI
+DxePcdGet16Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+;
+
+
+UINT32
+EFIAPI
+DxePcdGet32Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+;
+
+
+
+UINT64
+EFIAPI
+DxePcdGet64Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+;
+
+
+
+VOID *
+EFIAPI
+DxePcdGetPtrEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+;
+
+
+BOOLEAN
+EFIAPI
+DxePcdGetBoolEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+;
+
+
+UINTN
+EFIAPI
+DxePcdGetSizeEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet8 (
+ IN UINTN TokenNumber,
+ IN UINT8 Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet16 (
+ IN UINTN TokenNumber,
+ IN UINT16 Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet32 (
+ IN UINTN TokenNumber,
+ IN UINT32 Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet64 (
+ IN UINTN TokenNumber,
+ IN UINT64 Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetPtr (
+ IN UINTN TokenNumber,
+ IN CONST VOID *Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetBool (
+ IN UINTN TokenNumber,
+ IN BOOLEAN Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet8Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT8 Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet16Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT16 Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet32Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT32 Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSet64Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT64 Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetPtrEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN CONST VOID *Value
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdSetBoolEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN BOOLEAN Value
+ )
+;
+
+
+
+EFI_STATUS
+EFIAPI
+PcdRegisterCallBackOnSet (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+PcdUnRegisterCallBackOnSet (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PROTOCOL_CALLBACK CallBackFunction
+ )
+;
+
+
+EFI_STATUS
+EFIAPI
+DxePcdGetNextToken (
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN OUT UINTN *TokenNumber
+ )
+;
+
+
+/*
+ This DXE_PCD_DATABASE layout. The difference of DXE_PCD_DATABASE
+ and PEI_PCD_DATABASE is as follows:
+
+ 1) No PCD_CALL_BACK_TABLE; DXE_PCD_DATABASE maintain a LinkList for the
+ callback function registered.
+
+ ---------------------------
+ | LIST_ENTRY GuidSpaceHead|
+ ---------------------------
+ | PCD_DATABASE_HEADER |
+ ---------------------------
+ | GUID_TABLE | Aligned on GUID (128 bits)
+ ---------------------------
+ | PCD_INDEX_TABLE | Aligned on PCD_INDEX (see PCD_INDEX's declaration)
+ ---------------------------
+ | IMAGE_STRING_TABLE | Aligned on 16 Bits
+ ---------------------------
+ | IMAGE_PCD_INDEX | Unaligned
+ ---------------------------
+ | Data Defaults | Unaligned
+ ---------------------------
+ | Data Buffer |
+ | for entries without |
+ | defaults |
+ ---------------------------
+
+*/
+
+
+typedef struct {
+ LIST_ENTRY ListNode;
+ LIST_ENTRY TokenSpaceHead;
+ CONST EFI_GUID *GuidSpace;
+} PCD_GUID_SPACE;
+
+typedef struct {
+ LIST_ENTRY ListNode;
+ LIST_ENTRY CallbackListHead;
+ UINTN TokeNumber;
+} PCD_TOKEN_SPACE;
+
+typedef struct {
+ LIST_ENTRY ListNode;
+ PCD_PROTOCOL_CALLBACK CallbackFunction;
+} PCD_CALLBACK_ENTRY;
+
+#define PCD_GUID_SPACE_FROM_LISTNODE(a) \
+ _CR(a, PCD_GUID_SPACE, ListNode)
+
+#define PCD_TOKEN_SPACE_FROM_LISTNODE(a) \
+ _CR(a, PCD_TOKEN_SPACE, ListNode)
+
+#define PCD_CALLBACK_ENTRY_FROM_LISTNODE(a) \
+ _CR(a, PCD_CALLBACK_ENTRY, ListNode)
+
+#endif
|