> On Nov 27, 2014, at 3:13 AM, David Cox <david....@autologic.com> wrote:
>
> Hi,
>
> Are library constructors invoked once as part of image initialise? And if so
> are they always invoked on every boot warm/cold etc.?
>
Yes the library constructors are invoked as part of the image initialization.
The entry point of the image is a symbols called _ModuleEntryPoint. The
_ModuleEntryPoint is part of a special library that calls the library
constructors and then the entry point for the driver.
Here is the entry point library used for UEFI drivers:
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Library/UefiDriverEntryPoint/
<https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Library/UefiDriverEntryPoint/>
it calls routines that are auto generated by the build system and end up in
the AutoGen.c file.
Thanks,
Andrew Fish
> Or are library constructors invoked every time a user component starts using
> the library? Like C++ constructors, an instance?
>
> Example Inf:
>
> [Defines]
> …
> CONSTRUCTOR = CustomizedDisplayLibConstructor
>
> …
>
> I am looking to initialise a variable once per boot to N and right now N will
> be 0. Since I want that variable used by everyone using the library I
> created a static global. If I leave it as a static in my library - Is this
> enough? Assuming I want 0.
>
> static UINT32 gFlag=0;
>
> Or should I initialise it in constructor?
>
> EFI_STATUS
> EFIAPI
> CustomizedDisplayLibConstructor (
> IN EFI_HANDLE ImageHandle,
> IN EFI_SYSTEM_TABLE *SystemTable
> ) {
> // …
> gFlag=0;
> // …
> }
>
> Alternative, perhaps I could use event OnReadyToBoot via
> EfiCreateEventReadyToBootEx(…). However I am unsure when in boot time this
> event is signalled.
>
> Right now I am counting function invokes as part of debugging.
>
> Regards,
>
> Dave Cox
>
> David Cox
> Senior Software Engineer
> Autologic Diagnostics Ltd
> Tel: +44 1865 870050
> Mobile:
> Fax: +44 1865 870051
> Email: david....@autologic.com <mailto:david....@autologic.com>
> Website: www.autologic.com <http://www.autologic.com/>
> This message contains information which may be confidential and is intended
> for the named addressee only. Unless you are the named addressee, or
> authorised to receive it on behalf of the addressee you may not copy or use
> it, or disclose it to anyone else. Any views or opinions expressed in this
> message are those of the author and not necessarily representative of those
> of Autologic Diagnostics Ltd. Whilst every endeavour is taken to ensure that
> e-mails are free from viruses, no liability can be accepted and the recipient
> is requested to use their own virus checking software. If you have received
> this email in error please accept our apology and contact the sender. All
> work carried out on any vehicle using Autologic diagnostic equipment must be
> carried out in strict accordance with the instructions contained within the
> relevant manufacturer's workshop manuals. Autologic Diagnostics limited
> accepts no responsibility or liability for any damage or claim arising from
> any work carried out by operatives using equipment supplied by Autologic
> Diagnostics limited. Registered Office: Autologic House, London Road,
> Wheatley, Oxon, OX33 1JH, England, UK Registered in England & Wales No.
> 06814180
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________
>
> <http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________>
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net <mailto:edk2-devel@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> <https://lists.sourceforge.net/lists/listinfo/edk2-devel>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel