Hi,Liming and Andrew Fish,
I modified as your description,and move the pcd to [PcdEx] in inf file,but
compile fail,the error is type-Mismatched,I understand now,so this pcd is not
Ex-Pcd.
As Andrew Fish said:"If different binaries that got compiled in different
places need to work together then the Ex form is required."
Does it mean ,for example ,the bios_rom will finally contaion both Ex and
non_Ex PCDs,and PCD_driver will publish the interface to access,so other module
for exameple a efi_application access
Pcds can using PcdGetEx function to access pcds(type must be DynamicEx )?
I can't find a example for PcdGetEx in the EDK2 project,so I think the steps to
using it as follow,right?
1,define a DynamicEx PCD in MdePkg.dec,format as follow,the follow
token-number:0x000000f1 ,just a unique number will work well ,yes?
[PcdsDynamicEx]
gEfiMdePkgTokenSpaceGuid.myExPcdSample| 0xE0000000 |UINT64 | 0x000000f1
2,reference and modify it in Nt32Pkg.dsc as follow:
[PcdsDynamicEx]
gEfiMdePkgTokenSpaceGuid.myExPcdSample| 0xD0000000 # value changed for the
platform.
3,using the pcd in some drivers by PcdGetEx function,the driver can modifiy it
in runtime ,the driver must build in Nt32Pkg.dsc, the driver must build in
bios.fd.
3-1,add follow to driver-inf file:
[Guid]
gEfiMdePkgTokenSpaceGuid
[PcdEx]
gEfiMdePkgTokenSpaceGuid.myExPcdSample
3-2,add pcd-library to the driver-module and write code in source.c as
follow:
#include <Library/PcdLib.h>//pcd need
#include <Guid/MdePkgTokenSpace.h>//PcdToken
...
PcdGetEx64(&gEfiMdePkgTokenSpaceGuid,PcdToken(myExPcdSample));
PcdSetEx64(&gEfiMdePkgTokenSpaceGuid,PcdToken(myExPcdSample),some_value_changed);
4,using the pcd in uefi_Shell_application by PcdGetEx function,to check the
runtime-value.the flow is same as driver.
//steps-end
//last build-error-message:
build...
d:\edk2-vudk2017\Nt32Pkg\Nt32Pkg.dsc(...): error 1002: Mismatched PCD type
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut is defined as
[DynamicEx] in module
d:\edk2-vudk2017\Nt32Pkg\Application\mytestpcd2\mytestpcd2.inf, but as
[DynamicHii] in platform.
Stop.
some edk2 mail has sorted to a wrong group by me,so I haven't see it for a
long time,sorry to reply late.
thank you
by krishna
At 2017-12-14 22:55:00, "Gao, Liming" <[email protected]> wrote:
>PcdGet() is the recommended API to be used. It will be mapped to the matched
>PcdGet usage based on PCD type.
>
>PcdGetEx() is only used when PCD is configured to DynamicEx type. Its first
>parameter is the pointer to the token space guid, the second parameter is the
>token number. The token number can be get by PcdToken() macro. So, the correct
>way is PcdGetEx16(&gEfiMdePkgTokenSpaceGuid, PcdToken
>(PcdPlatformBootTimeOut));. But PcdPlatformBootTimeOut is not configured to
>DynamicEx PCD in NT32 platform. This style can pass build, but can't work.
>
>Thanks
>Liming
>> -----Original Message-----
>> From: edk2-devel [mailto:[email protected]] On Behalf Of
>> Andrew Fish
>> Sent: Thursday, December 14, 2017 6:27 PM
>> To: krishnaLee <[email protected]>
>> Cc: [email protected]
>> Subject: Re: [edk2] How to using PcdGetEx to change a PCD.
>>
>>
>>
>> > On Dec 14, 2017, at 12:59 AM, krishnaLee <[email protected]> wrote:
>> >
>> > Hello,
>> > I am learning and writing a application to change the Nt32pkg-virtual
>> > machine's boot time.follow code is success.
>> > but I think if I using PcdGetEx16 function, it will also work well,but
>> > failed when I compile it.
>> > I had read some Specs about the difference between PcdGetEx and PcdGet,but
>> > I can't understand,maybe I need some practice,
>> > So can anyone modify it to using PcdGetEx to implement the same function
>> > in the application?
>> > //source-code--start
>>
>> Did you add:
>>
>> #include <Guid/MdePkgTokenSpace.h>
>>
>> and list gEfiMdePkgTokenSpaceGuid in the [Guids] section of the INF.
>>
>> In general it is hard to comment on compiler failures in fragments of code.
>> If you post the actual compiler error it is easier to explain.
>>
>>
>>
>> The PCDs are a GUID + token number namespace for config. Since anyone can
>> define a GUID that does not conflict it allows arbitrary
>> extension without conflict.
>>
>> The Ex form of the API includes the GUID + token number. The non Ex form is
>> a size optimization that uses a build generated token
>> space. So generally if everything is built together then you use the non Ex
>> form to save space. If different binaries that got compiled in
>> different places need to work together then the Ex form is required.
>>
>> Thanks,
>>
>> Andrew Fish
>>
>> > EFI_STATUS
>> > EFIAPI
>> > UefiMain (
>> > IN EFI_HANDLE ImageHandle,
>> > IN EFI_SYSTEM_TABLE *SystemTable
>> > )
>> > {
>> > UINTN buffer=0;
>> > UINTN index;
>> > buffer=PcdGet16(PcdPlatformBootTimeOut);
>> > //buffer=PcdGetEx16(&gEfiMdePkgTokenSpaceGuid,PcdPlatformBootTimeOut);//compile
>> > failed.
>> > Print(L"buffer:%d\n",buffer);
>> > PcdSet16(PcdPlatformBootTimeOut,5);
>> > ...
>> >
>> >
>> > //source-code-end.
>> >
>> >
>> > attachment is the full source code.
>> > edk2-vUDK2017's build command:
>> > build -p Nt32Pkg\Nt32Pkg.dsc -m
>> > Nt32Pkg\Application\mytestpcd2\mytestpcd2.inf
>> >
>> >
>> > thank you very much!
>> >
>> > _______________________________________________
>> > edk2-devel mailing list
>> > [email protected] <mailto:[email protected]>
>> > https://lists.01.org/mailman/listinfo/edk2-devel
>> > <https://lists.01.org/mailman/listinfo/edk2-devel>
>> _______________________________________________
>> edk2-devel mailing list
>> [email protected]
>> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel