2006-04-22 00:54:32 +02:00
|
|
|
/** @file
|
|
|
|
PCD DXE driver
|
|
|
|
|
2007-01-18 07:48:58 +01:00
|
|
|
Copyright (c) 2006 - 2007, Intel Corporation
|
2006-04-22 00:54:32 +02:00
|
|
|
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 "Service.h"
|
|
|
|
|
2007-06-25 10:54:54 +02:00
|
|
|
EFI_LOCK mPcdDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE(TPL_CALLBACK);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
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,
|
|
|
|
|
2006-05-29 03:48:32 +02:00
|
|
|
DxeRegisterCallBackOnSet,
|
|
|
|
DxeUnRegisterCallBackOnSet,
|
2006-07-06 13:42:25 +02:00
|
|
|
DxePcdGetNextToken,
|
|
|
|
DxePcdGetNextTokenSpace
|
2006-04-22 00:54:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Static global to reduce the code size
|
|
|
|
//
|
2006-08-11 20:20:39 +02:00
|
|
|
static EFI_HANDLE mNewHandle = NULL;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PcdDxeInit (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure the Pcd Protocol is not already installed in the system
|
|
|
|
//
|
2006-06-07 17:56:29 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid);
|
2006-06-10 14:03:36 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
BuildPcdDxeDataBase ();
|
|
|
|
|
2006-04-22 00:54:32 +02:00
|
|
|
Status = gBS->InstallProtocolInterface (
|
2006-08-11 20:20:39 +02:00
|
|
|
&mNewHandle,
|
2006-04-22 00:54:32 +02:00
|
|
|
&gPcdProtocolGuid,
|
|
|
|
EFI_NATIVE_INTERFACE,
|
|
|
|
&mPcdInstance
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-26 03:09:00 +02:00
|
|
|
VOID
|
2006-04-22 00:54:32 +02:00
|
|
|
EFIAPI
|
|
|
|
DxePcdSetSku (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN SkuId
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-06-07 14:31:33 +02:00
|
|
|
mPcdDatabase->PeiDb.Init.SystemSkuId = (SKU_ID) SkuId;
|
2006-05-26 03:09:00 +02:00
|
|
|
|
|
|
|
return;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINT8
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGet8 (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINT16
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGet16 (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINT32
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGet32 (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGet64 (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return ReadUnaligned64(GetWorker (TokenNumber, sizeof (UINT64)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID *
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGetPtr (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return GetWorker (TokenNumber, 0);
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGetBool (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGetSize (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
UINTN Size;
|
|
|
|
UINT32 *LocalTokenNumberTable;
|
|
|
|
BOOLEAN IsPeiDb;
|
|
|
|
UINTN MaxSize;
|
|
|
|
UINTN TmpTokenNumber;
|
2006-06-23 06:30:23 +02:00
|
|
|
//
|
|
|
|
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
|
|
|
// We have to decrement TokenNumber by 1 to make it usable
|
|
|
|
// as the array index.
|
|
|
|
//
|
|
|
|
TokenNumber--;
|
2006-07-06 08:10:20 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Backup the TokenNumber passed in as GetPtrTypeSize need the original TokenNumber
|
|
|
|
//
|
|
|
|
TmpTokenNumber = TokenNumber;
|
|
|
|
|
2006-07-08 16:37:30 +02:00
|
|
|
// EBC compiler is very choosy. It may report warning about comparison
|
|
|
|
// between UINTN and 0 . So we add 1 in each size of the
|
|
|
|
// comparison.
|
|
|
|
ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);
|
|
|
|
|
|
|
|
// EBC compiler is very choosy. It may report warning about comparison
|
|
|
|
// between UINTN and 0 . So we add 1 in each size of the
|
|
|
|
// comparison.
|
|
|
|
IsPeiDb = (BOOLEAN) (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);
|
2006-06-23 06:30:23 +02:00
|
|
|
|
2006-07-06 08:10:20 +02:00
|
|
|
TokenNumber = IsPeiDb ? TokenNumber :
|
|
|
|
(TokenNumber - PEI_LOCAL_TOKEN_NUMBER);
|
2006-05-24 10:16:20 +02:00
|
|
|
|
2006-07-06 08:10:20 +02:00
|
|
|
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable
|
|
|
|
: mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
2006-05-24 10:16:20 +02:00
|
|
|
|
2006-07-06 08:10:20 +02:00
|
|
|
Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
|
|
|
|
|
|
|
|
if (Size == 0) {
|
|
|
|
//
|
|
|
|
// For pointer type, we need to scan the SIZE_TABLE to get the current size.
|
|
|
|
//
|
|
|
|
return GetPtrTypeSize (TmpTokenNumber, &MaxSize);
|
|
|
|
} else {
|
|
|
|
return Size;
|
|
|
|
}
|
2006-05-24 10:16:20 +02:00
|
|
|
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINT8
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGet8Ex (
|
2006-05-24 10:16:20 +02:00
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT8)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINT16
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGet16Ex (
|
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINT32
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGet32Ex (
|
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGet64Ex (
|
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-29 14:56:03 +02:00
|
|
|
return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID *
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGetPtrEx (
|
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return ExGetWorker (Guid, ExTokenNumber, 0);
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGetBoolEx (
|
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof(BOOLEAN)));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGetSizeEx (
|
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-06-07 17:56:29 +02:00
|
|
|
return DxePcdGetSize(GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSet8 (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber,
|
2006-05-24 10:16:20 +02:00
|
|
|
IN UINT8 Value
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSet16 (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber,
|
2006-04-22 00:54:32 +02:00
|
|
|
IN UINT16 Value
|
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSet32 (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber,
|
2006-04-22 00:54:32 +02:00
|
|
|
IN UINT32 Value
|
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSet64 (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber,
|
2006-05-24 10:16:20 +02:00
|
|
|
IN UINT64 Value
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSetPtr (
|
2006-07-06 08:10:20 +02:00
|
|
|
IN UINTN TokenNumber,
|
|
|
|
IN OUT UINTN *SizeOfBuffer,
|
|
|
|
IN VOID *Buffer
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-26 03:09:00 +02:00
|
|
|
return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSetBool (
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN TokenNumber,
|
2006-05-24 10:16:20 +02:00
|
|
|
IN BOOLEAN Value
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return SetValueWorker (TokenNumber, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSet8Ex (
|
2006-05-29 03:48:32 +02:00
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber,
|
2006-05-24 10:16:20 +02:00
|
|
|
IN UINT8 Value
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSet16Ex (
|
2006-05-29 03:48:32 +02:00
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber,
|
2006-04-22 00:54:32 +02:00
|
|
|
IN UINT16 Value
|
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSet32Ex (
|
2006-05-29 03:48:32 +02:00
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber,
|
2006-04-22 00:54:32 +02:00
|
|
|
IN UINT32 Value
|
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSet64Ex (
|
2006-05-29 03:48:32 +02:00
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber,
|
2006-04-22 00:54:32 +02:00
|
|
|
IN UINT64 Value
|
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSetPtrEx (
|
2006-07-06 08:10:20 +02:00
|
|
|
IN CONST EFI_GUID *Guid,
|
|
|
|
IN UINTN ExTokenNumber,
|
|
|
|
IN OUT UINTN *SizeOfBuffer,
|
|
|
|
IN VOID *Buffer
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return ExSetWorker(ExTokenNumber, Guid, Buffer, SizeOfBuffer, TRUE);
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdSetBoolEx (
|
2006-05-29 03:48:32 +02:00
|
|
|
IN CONST EFI_GUID *Guid,
|
2006-06-07 14:31:33 +02:00
|
|
|
IN UINTN ExTokenNumber,
|
2006-04-22 00:54:32 +02:00
|
|
|
IN BOOLEAN Value
|
|
|
|
)
|
|
|
|
{
|
2006-07-06 08:10:20 +02:00
|
|
|
return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
2006-05-29 03:48:32 +02:00
|
|
|
DxeRegisterCallBackOnSet (
|
|
|
|
IN CONST EFI_GUID *Guid, OPTIONAL
|
2006-07-19 07:18:47 +02:00
|
|
|
IN UINTN TokenNumber,
|
2006-04-22 00:54:32 +02:00
|
|
|
IN PCD_PROTOCOL_CALLBACK CallBackFunction
|
|
|
|
)
|
|
|
|
{
|
2007-01-18 03:46:28 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2006-05-29 03:48:32 +02:00
|
|
|
ASSERT (CallBackFunction != NULL);
|
|
|
|
|
2007-01-18 03:46:28 +01:00
|
|
|
//
|
|
|
|
// Aquire lock to prevent reentrance from TPL_CALLBACK level
|
|
|
|
//
|
|
|
|
EfiAcquireLock (&mPcdDatabaseLock);
|
|
|
|
|
|
|
|
Status = DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);
|
|
|
|
|
|
|
|
EfiReleaseLock (&mPcdDatabaseLock);
|
|
|
|
|
|
|
|
return Status;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
2006-05-29 03:48:32 +02:00
|
|
|
DxeUnRegisterCallBackOnSet (
|
|
|
|
IN CONST EFI_GUID *Guid, OPTIONAL
|
2006-07-19 07:18:47 +02:00
|
|
|
IN UINTN TokenNumber,
|
2006-04-22 00:54:32 +02:00
|
|
|
IN PCD_PROTOCOL_CALLBACK CallBackFunction
|
|
|
|
)
|
|
|
|
{
|
2007-01-18 03:46:28 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2006-05-29 03:48:32 +02:00
|
|
|
ASSERT (CallBackFunction != NULL);
|
2007-01-18 03:46:28 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Aquire lock to prevent reentrance from TPL_CALLBACK level
|
|
|
|
//
|
|
|
|
EfiAcquireLock (&mPcdDatabaseLock);
|
|
|
|
|
|
|
|
Status = DxeUnRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);
|
|
|
|
|
|
|
|
EfiReleaseLock (&mPcdDatabaseLock);
|
2006-05-29 03:48:32 +02:00
|
|
|
|
2007-01-18 03:46:28 +01:00
|
|
|
return Status;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGetNextToken (
|
2006-05-29 03:48:32 +02:00
|
|
|
IN CONST EFI_GUID *Guid, OPTIONAL
|
2006-06-07 14:31:33 +02:00
|
|
|
IN OUT UINTN *TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-07-06 15:34:25 +02:00
|
|
|
EFI_STATUS Status;
|
2007-01-25 07:15:58 +01:00
|
|
|
BOOLEAN PeiExMapTableEmpty;
|
|
|
|
BOOLEAN DxeExMapTableEmpty;
|
2006-07-06 15:34:25 +02:00
|
|
|
|
2006-07-08 16:37:30 +02:00
|
|
|
if (!FeaturePcdGet (PcdDxePcdDatabaseTraverseEnabled)) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2006-07-06 15:34:25 +02:00
|
|
|
Status = EFI_NOT_FOUND;
|
2007-01-25 07:15:58 +01:00
|
|
|
PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;
|
|
|
|
DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;
|
|
|
|
|
2006-05-29 03:48:32 +02:00
|
|
|
//
|
|
|
|
// Scan the local token space
|
|
|
|
//
|
|
|
|
if (Guid == NULL) {
|
2006-07-08 16:37:30 +02:00
|
|
|
// EBC compiler is very choosy. It may report warning about comparison
|
|
|
|
// between UINTN and 0 . So we add 1 in each size of the
|
|
|
|
// comparison.
|
|
|
|
if (((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) && (*TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1)) ||
|
|
|
|
((*TokenNumber + 1 > (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1)))) {
|
2006-07-06 15:34:25 +02:00
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2006-05-30 18:33:09 +02:00
|
|
|
(*TokenNumber)++;
|
2006-07-08 16:37:30 +02:00
|
|
|
if ((*TokenNumber + 1 > PEI_NEX_TOKEN_NUMBER + 1) &&
|
|
|
|
(*TokenNumber <= PEI_LOCAL_TOKEN_NUMBER)) {
|
2006-07-06 13:42:25 +02:00
|
|
|
//
|
|
|
|
// The first Non-Ex type Token Number for DXE PCD
|
|
|
|
// database is PEI_LOCAL_TOKEN_NUMBER
|
|
|
|
//
|
|
|
|
*TokenNumber = PEI_LOCAL_TOKEN_NUMBER;
|
2006-07-08 16:37:30 +02:00
|
|
|
} else if (*TokenNumber + 1 > DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER + 1) {
|
2006-07-06 13:42:25 +02:00
|
|
|
*TokenNumber = PCD_INVALID_TOKEN_NUMBER;
|
2006-05-29 03:48:32 +02:00
|
|
|
}
|
2006-07-06 13:42:25 +02:00
|
|
|
return EFI_SUCCESS;
|
2006-05-29 03:48:32 +02:00
|
|
|
}
|
|
|
|
|
2007-01-25 07:15:58 +01:00
|
|
|
if (PeiExMapTableEmpty && DxeExMapTableEmpty) {
|
2006-07-06 13:42:25 +02:00
|
|
|
*TokenNumber = PCD_INVALID_TOKEN_NUMBER;
|
2006-05-29 03:48:32 +02:00
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2007-01-25 07:15:58 +01:00
|
|
|
if (!PeiExMapTableEmpty) {
|
2006-07-06 15:34:25 +02:00
|
|
|
Status = ExGetNextTokeNumber (
|
2006-05-29 03:48:32 +02:00
|
|
|
Guid,
|
2006-07-06 15:34:25 +02:00
|
|
|
TokenNumber,
|
2006-05-29 03:48:32 +02:00
|
|
|
mPcdDatabase->PeiDb.Init.GuidTable,
|
|
|
|
sizeof(mPcdDatabase->PeiDb.Init.GuidTable),
|
|
|
|
mPcdDatabase->PeiDb.Init.ExMapTable,
|
|
|
|
sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2006-07-06 15:34:25 +02:00
|
|
|
if (Status == EFI_SUCCESS) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2007-01-25 07:15:58 +01:00
|
|
|
if (!DxeExMapTableEmpty) {
|
2006-07-06 15:34:25 +02:00
|
|
|
Status = ExGetNextTokeNumber (
|
2006-05-29 03:48:32 +02:00
|
|
|
Guid,
|
2006-07-06 15:34:25 +02:00
|
|
|
TokenNumber,
|
2006-07-06 13:42:25 +02:00
|
|
|
mPcdDatabase->DxeDb.Init.GuidTable,
|
|
|
|
sizeof(mPcdDatabase->DxeDb.Init.GuidTable),
|
|
|
|
mPcdDatabase->DxeDb.Init.ExMapTable,
|
|
|
|
sizeof(mPcdDatabase->DxeDb.Init.ExMapTable)
|
2006-05-29 03:48:32 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2006-07-06 15:34:25 +02:00
|
|
|
return Status;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
2007-01-25 07:15:58 +01:00
|
|
|
STATIC
|
2006-06-23 16:41:16 +02:00
|
|
|
EFI_GUID **
|
|
|
|
GetDistinctTokenSpace (
|
|
|
|
IN OUT UINTN *ExMapTableSize,
|
|
|
|
IN DYNAMICEX_MAPPING *ExMapTable,
|
|
|
|
IN EFI_GUID *GuidTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_GUID **DistinctTokenSpace;
|
|
|
|
UINTN OldGuidIndex;
|
|
|
|
UINTN TsIdx;
|
|
|
|
UINTN Idx;
|
|
|
|
|
|
|
|
|
|
|
|
DistinctTokenSpace = AllocateZeroPool (*ExMapTableSize * sizeof (EFI_GUID *));
|
|
|
|
ASSERT (DistinctTokenSpace != NULL);
|
|
|
|
|
|
|
|
TsIdx = 0;
|
|
|
|
OldGuidIndex = ExMapTable[0].ExGuidIndex;
|
|
|
|
DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];
|
2006-07-06 13:42:25 +02:00
|
|
|
for (Idx = 1; Idx < *ExMapTableSize; Idx++) {
|
2006-06-23 16:41:16 +02:00
|
|
|
if (ExMapTable[Idx].ExGuidIndex != OldGuidIndex) {
|
|
|
|
OldGuidIndex = ExMapTable[Idx].ExGuidIndex;
|
|
|
|
DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-06 13:42:25 +02:00
|
|
|
//
|
|
|
|
// The total number of Distinct Token Space
|
|
|
|
// is TsIdx + 1 because we use TsIdx as a index
|
|
|
|
// to the DistinctTokenSpace[]
|
|
|
|
//
|
|
|
|
*ExMapTableSize = TsIdx + 1;
|
2006-06-23 16:41:16 +02:00
|
|
|
return DistinctTokenSpace;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-07-06 13:42:25 +02:00
|
|
|
//
|
|
|
|
// Just pre-allocate a memory buffer that is big enough to
|
|
|
|
// host all distinct TokenSpace guid in both
|
|
|
|
// PEI ExMap and DXE ExMap.
|
|
|
|
//
|
2006-06-23 16:41:16 +02:00
|
|
|
STATIC EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DxePcdGetNextTokenSpace (
|
|
|
|
IN OUT CONST EFI_GUID **Guid
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Idx;
|
|
|
|
UINTN Idx2;
|
|
|
|
UINTN Idx3;
|
|
|
|
UINTN PeiTokenSpaceTableSize;
|
|
|
|
UINTN DxeTokenSpaceTableSize;
|
|
|
|
EFI_GUID **PeiTokenSpaceTable;
|
|
|
|
EFI_GUID **DxeTokenSpaceTable;
|
|
|
|
BOOLEAN Match;
|
2007-01-25 07:15:58 +01:00
|
|
|
BOOLEAN PeiExMapTableEmpty;
|
|
|
|
BOOLEAN DxeExMapTableEmpty;
|
2006-06-23 16:41:16 +02:00
|
|
|
|
2006-07-08 16:37:30 +02:00
|
|
|
if (!FeaturePcdGet (PcdDxePcdDatabaseTraverseEnabled)) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2006-06-23 16:41:16 +02:00
|
|
|
ASSERT (Guid != NULL);
|
|
|
|
|
2007-01-25 07:15:58 +01:00
|
|
|
PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;
|
|
|
|
DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;
|
|
|
|
|
|
|
|
if (PeiExMapTableEmpty && DxeExMapTableEmpty) {
|
2006-06-23 16:41:16 +02:00
|
|
|
if (*Guid != NULL) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
} else {
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-06 13:42:25 +02:00
|
|
|
if (TmpTokenSpaceBuffer[0] == NULL) {
|
2006-06-23 16:41:16 +02:00
|
|
|
PeiTokenSpaceTableSize = 0;
|
|
|
|
|
2007-01-25 07:15:58 +01:00
|
|
|
if (!PeiExMapTableEmpty) {
|
2006-06-23 16:41:16 +02:00
|
|
|
PeiTokenSpaceTableSize = PEI_EXMAPPING_TABLE_SIZE;
|
|
|
|
PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,
|
|
|
|
mPcdDatabase->PeiDb.Init.ExMapTable,
|
|
|
|
mPcdDatabase->PeiDb.Init.GuidTable
|
|
|
|
);
|
|
|
|
CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);
|
|
|
|
}
|
|
|
|
|
2007-01-25 07:15:58 +01:00
|
|
|
if (!DxeExMapTableEmpty) {
|
2006-06-23 16:41:16 +02:00
|
|
|
DxeTokenSpaceTableSize = DXE_EXMAPPING_TABLE_SIZE;
|
|
|
|
DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,
|
|
|
|
mPcdDatabase->DxeDb.Init.ExMapTable,
|
|
|
|
mPcdDatabase->DxeDb.Init.GuidTable
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure EFI_GUID in DxeTokenSpaceTable does not exist in PeiTokenSpaceTable
|
|
|
|
//
|
|
|
|
for (Idx2 = 0, Idx3 = PeiTokenSpaceTableSize; Idx2 < DxeTokenSpaceTableSize; Idx2++) {
|
|
|
|
Match = FALSE;
|
|
|
|
for (Idx = 0; Idx < PeiTokenSpaceTableSize; Idx++) {
|
|
|
|
if (CompareGuid (TmpTokenSpaceBuffer[Idx], DxeTokenSpaceTable[Idx2])) {
|
|
|
|
Match = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Match) {
|
|
|
|
TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*Guid == NULL) {
|
|
|
|
*Guid = TmpTokenSpaceBuffer[0];
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Idx = 0; Idx < (PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE); Idx++) {
|
|
|
|
if(CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {
|
|
|
|
Idx++;
|
|
|
|
*Guid = TmpTokenSpaceBuffer[Idx];
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|