Andrew Fish [mailto:af...@apple.com] wrote:
]On Mar 11, 2014, at 6:17 PM, Ben Schroeder <ben...@mellanox.com> wrote: ] ] ] Hi, ] ] Regarding EFIAPI calling convention, the UEFI 2.3.1 specification ] writes: ] All public interfaces of a UEFI module must follow the UEFI calling ] convention. Public interfaces include the image entry point, UEFI ] event handlers, and protocol member functions. The type EFIAPI is ] used to indicate conformance to the calling conventions defined in ] this section. Non public interfaces, such as private functions and ] static library calls, are not required to follow the UEFI calling ] conventions and may be optimized by the compiler ] ] Specifically I am interested in UEFI event handlers. ] I have a function that registered with CreateEvent as a timer, ] and then registered with SetTimer to be polled periodically. ] So I understand this function (call it foo()) must have EFIAPI ] calling convention (because it will be called periodically by the ] uefi system) ] ]That is correct. ] ] ] Do functions that are called by foo() also need to be in EFIAPI convention? ] ]No I believe there is one exception to this rule. For x86 code (I tested x64 only), the VA_START and VA_ARG macros defined by EDK2 work only for the Microsoft x64 calling convention and not for System V calling convention. For example, the sample app Hello.c can be modified to include and call these two functions: static void test1 (char *format, ...) { static char buffer [200]; VA_LIST marker; VA_START (marker, format); AsciiVSPrint (buffer, sizeof buffer, format, marker); VA_END (marker); AsciiPrint (buffer); } static void EFIAPI test2 (char *format, ...) { static char buffer [200]; VA_LIST marker; VA_START (marker, format); AsciiVSPrint (buffer, sizeof buffer, format, marker); VA_END (marker); AsciiPrint (buffer); } When built with Windows tools, both functions work. But when built from Linux using gnu tools, only the second function works properly. In the current edk2 code, the PrintString() function in files DuetPkg/DxeIpl and DuetPkg/EfiLdr fail when built from Linux because of this. Adding EFIAPI to those function declarations fixes the Linux build problem. The EDKII Module Development Environment Library Specification hints at this requirement in the text for VA_START and VA_ARG: "The method for computing the pointer to the next argument in the argument list is CPU specific following the EFIAPI ABI." Thanks, Scott [...] ]Thanks, ] ]Andrew Fish ] ] ]Thanks, ]Ben. ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel