public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: Andrew Fish <afish@apple.com>, krishnaLee <sssky307@163.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: How to using PcdGetEx to change a PCD.
Date: Thu, 14 Dec 2017 14:55:00 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1923CC@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <CF5431A2-92BF-4BA7-83A4-87B759240B8F@apple.com>

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:edk2-devel-bounces@lists.01.org] On Behalf Of Andrew Fish
> Sent: Thursday, December 14, 2017 6:27 PM
> To: krishnaLee <sssky307@163.com>
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] How to using PcdGetEx to change a PCD.
> 
> 
> 
> > On Dec 14, 2017, at 12:59 AM, krishnaLee <sssky307@163.com> 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
> > edk2-devel@lists.01.org <mailto:edk2-devel@lists.01.org>
> > https://lists.01.org/mailman/listinfo/edk2-devel <https://lists.01.org/mailman/listinfo/edk2-devel>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2017-12-14 14:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14  8:59 How to using PcdGetEx to change a PCD krishnaLee
2017-12-14 10:27 ` Andrew Fish
2017-12-14 14:55   ` Gao, Liming [this message]
2017-12-28  9:41     ` krishnaLee
2017-12-29 15:26       ` Gao, Liming
2017-12-31  8:47         ` krishnaLee

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=4A89E2EF3DFEDB4C8BFDE51014F606A14E1923CC@SHSMSX104.ccr.corp.intel.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