Thanks for the reply Andrew! I admit there are but a few reasons to program without "C". I can think of two. For example, educators might want to offer a course in assembly language programming to their students. An other reason would be to build an embedded OS without using the EDK2. No offense, but the EDK2 is a configuration mess and way too complicated for a college freshman. It would be way easier to give them one header file "uefi.inc" with some structures and a template block of code.
Anyhow, I guess I'll take a look at the Linux UEFI Stub. Somehow, they figured out how to boot linux in UEFI without using the EDK2 build environment. Regards, Stephen Andrew Fish wrote: > > On Feb 19, 2014, at 8:36 AM, Stephen Polkowski <step...@centtech.com > <mailto:step...@centtech.com>> wrote: > >> Hi all, >> >> Does the EDK2 have a assembler only example of doing >> a simple "Hello World" app? I would like a GNU GAS example, >> but any would do. >> > > No. The BaseLib has assembler (and inline assembler) > examples: > https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Library/BaseLib/ > >> If there isn't an example, shouldn't the EDK2 have one? >> I need to write an embedded OS that isn't tied to he EDK2 >> build environment. >> > > The point of the BaseLib is to write code in C. So no there is not an > assembly example. It is trivial. > > // typedef > // EFI_STATUS > // (EFIAPI *EFI_IMAGE_ENTRY_POINT) ( > // IN EFI_HANDLE ImageHandle, // RCX > // IN EFI_SYSTEM_TABLE *SystemTable // RDX > // ); > // > // VOID > // SetupEfi ( > // IN EFI_HANDLE ImageHandle, > // IN EFI_SYSTEM_TABLE *SystemTable > // ); > // > > .globl __ModuleEntryPoint: > __ModuleEntryPoint: > pushq %rbp > movq %rsp, %rbp // Not required, but it makes debuggers happy > callq _SetupEfi // Call C library constructor for EFI. > // Do your thing > movabsq $0, %rax // return EFI_SUCCESS > popq %rbp > ret > > So in this example you write all things EFI in C, like a sensible > person. SetupEfi() can set globals like gBS, gRT, and gST, and you can > call C code to do things EFI. > > Assuming you are generating the correct calling conventions 'clang -S > -Os’ is your friend (works with gcc too). > > You could write the entry point in C and call the assembly too. Don’t > know why you would write it all in assembly, especially since doing the > pointer math on C structures is not going to be fun. > > Well I guess you could be using a different calling convention. > > Thanks, > > Andrew Fish > > PS If you are using a different calling convention look > at: > https://svn.code.sf.net/p/edk2/code/trunk/edk2/EmulatorPkg/Unix/Host/X64/Gasket.S > > The emulator application uses Unix calling conventions while the EFI > modules use EFI ABI: > ReverseGasket* == Unix ABI code calling EFI ABI code > Gasket* == EFI ABI Code calling Unix ABI code > > >> Thanks, >> >> Stephen >> >> >> >> >> -- >> Stephen Polkowski >> Centaur Technology >> Austin, TX >> (512) 418-5730 >> >> ------------------------------------------------------------------------------ >> Managing the Performance of Cloud-Based Applications >> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. >> Read the Whitepaper. >> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk >> <http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk> >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/edk2-devel > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Managing the Performance of Cloud-Based Applications > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. > Read the Whitepaper. > http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk > > > ------------------------------------------------------------------------ > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/edk2-devel -- Stephen Polkowski Centaur Technology Austin, TX (512) 418-5730 ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel