On Jun 11, 2014, at 2:02 AM, Thomas Letan <thomas.le...@supelec.fr> wrote:
> Hello everyone. > > I am currently working on UEFI and more precisely on SMM with UEFI. > To handle correctly #SMI, I have to load some piece of code in RAM. In > order to do some tests, I wrote my assembly code, compile it with nasm, > get the binary content thanks to objdump and save it in a char[] > variable. Not very clean way to do it, IMHO. > All EFI applications and drivers are relocatable PE/COFF images that get “loaded into memory” and relocated from their linked address to the load address. So compiling the code as a PE/COFF executable is the way to do it. The *.EFI images from the build output are PE/COFF images. What do you need to do that is different? EFI supports loading/relocating PE/COFF images into memory via gBS->LoadImage()/gBS->StartImage(). You can write an EFI Application/Driver in assembly if you want in the edk2 build system. Not sure why you would. The entry point would be the C function name _ModuleEntryPoint (some compilers add an extra _ in the front of C names). > Is there an “EDKII way” to do it? For what I saw, the C files of EDKII > do not contain a single line of asm, which are written in a separate file. > As there is no C standard for inline assembly. So doing that makes code non portable. Not to mention the assembly is not portable between different CPU architectures. In the EDKII you can use the BaseLib to access CPU registers: https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Library/BaseLib.h Thus you generally don’t need assembly. You generally only need assembly code for x86 mode changes, interrupt/exception handling, and SMM init/handling. Thanks, Andrew Fish > Thank you for your time > Thomas > > ------------------------------------------------------------------------------ > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > Find What Matters Most in Your Big Data with HPCC Systems > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > http://p.sf.net/sfu/hpccsystems_______________________________________________ > edk2-devel mailing list > edk2-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/edk2-devel ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel