2014-05-16 20:37 GMT+02:00 Laszlo Ersek <ler...@redhat.com>: > 2. The error is in Ludovic's program; I can reproduce it and also fix > it. Quote: > > EFI_STATUS > EFIAPI > efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) > { > ... > > The problem is "EFIAPI". You *must not* add EFIAPI to efi_main() *in > gnu-efi*. The compiling/linking magic that gnu-efi does for applications > automatically takes care of it, and it is thrown off if you specify > EFIAPI manually for efi_main(). Don't do that.
Not all my sample codes were using EFIAPI. Examples from [1] are wrong. Examples from [2] are correct. Roderick, maybe you should fix your examples at [1]. > This is in fact documented. See README.gnuefi: > >> The GNU EFI build environment allows to write EFI applications as >> described in Intel's EFI documentation, except for two differences: >> >> - The EFI application's entry point is always called "efi_main". The >> declaration of this routine is: >> >> EFI_STATUS efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab); >> >> [...] > > No EFIAPI. If you check the rest of the applications in apps/ -- no > EFIAPI on efi_main(), ever. > > After removing EFIAPI from Ludovic's app, it works as expected for me > (invoked from UEFI shell on fresh OVMF). > > One strange point is that the D_ERROR output (via DEBUG()) seems to > overwrite the Print(L"c\n") output on the serial console, except when it > happens at the bottom of the screen. Not sure why that happens, but it > doesn't crash. My debug1.c code is now: #include <efi.h> #include <efilib.h> EFI_STATUS efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { InitializeLib(ImageHandle, SystemTable); Print(L"a\n"); DEBUG(( D_INFO, (CHAR8 *)"D_INFO\r\n")); Print(L"b\n"); DEBUG(( D_ERROR, (CHAR8 *)"D_ERROR\r\n")); Print(L"c\n"); return EFI_SUCCESS; } On the serial console I get: FS0:\> debug1.efi a b !!!! X64 Exception Type - 000000000000000E CPU Apic ID - 00000000 !!!! RIP - 0000000006BA58DE, CS - 0000000000000028, RFLAGS - 0000000000000287 ExceptionData - 0000000000000000 RAX - FFFFFFFFFFFFFFF0, RCX - 0000000000000000, RDX - 0000000000000007 RBX - 0000000080000000, RSP - 0000000007F6A4F0, RBP - 0000000007F6A530 RSI - 000000000000000E, RDI - 0000000006BAA790 R8 - 0000000000000000, R9 - 0000000007F69EA7, R10 - 00000000069A169D R11 - 0000000000000040, R12 - 0000000000000005, R13 - 0000000000000000 R14 - 0000000000000000, R15 - 0000000000000000 DS - 0000000000000008, ES - 0000000000000008, FS - 0000000000000008 GS - 0000000000000008, SS - 0000000000000008 CR0 - 0000000080000033, CR2 - FFFFFFFFFFFFFFF0, CR3 - 0000000007F09000 CR4 - 0000000000000668, CR8 - 0000000000000000 DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000 DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400 GDTR - 0000000007EF2D98 000000000000003F, LDTR - 0000000000000000 IDTR - 0000000007C1E018 0000000000000FFF, TR - 0000000000000000 FXSAVE_STATE - 0000000007F6A150 !!!! Find PE image /home/lroussea/Documents/UEFI/edk2/Build/OvmfX64/DEBUG_GCC47/X64/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe/DEBUG/ConSplitterDxe.dll (ImageBase=0000000006B9F000, EntryPoint=0000000006B9F2AF) !!!! I get this crash before the debug message is displayed. This is with OVMF I rebuild myself using edk2 SVN revision 15536 If I use OVMF from OVMF-X64-r15214/OVMF.fd I get on the serial console: FS0:\> debug1.efi a b D_ERROR And on the terminal used to start qemu: qemu: fatal: Trying to execute code outside RAM or ROM at 0x00000000000b0000 RAX=0000000000000000 RBX=0000000080000000 RCX=0000000000000000 RDX=0000000000000018 RSI=0000000000000005 RDI=0000000007dd0c30 RBP=0000000007f94560 RSP=0000000007f94518 R8 =0000000000000000 R9 =0000000007f93f5c R10=00000000000003f8 R11=0000000000000040 R12=0000000000000005 R13=0000000000000000 R14=0000000000000000 R15=0000000000000000 RIP=00000000000affae RFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0 ES =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA] CS =0028 0000000000000000 ffffffff 00af9b00 DPL=0 CS64 [-RA] SS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA] DS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA] FS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA] GS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA] LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy GDT= 0000000007f1ed98 0000003f IDT= 000000000747f018 00000fff CR0=80000033 CR2=0000000000000000 CR3=0000000007f33000 CR4=00000668 DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000 DR6=00000000ffff0ff0 DR7=0000000000000400 CCS=0000000000000000 CCD=0000000000000000 CCO=ADDB EFER=0000000000000500 FCW=037f FSW=0000 [ST=0] FTW=00 MXCSR=00001f80 FPR0=0000000000000000 0000 FPR1=0000000000000000 0000 FPR2=0000000000000000 0000 FPR3=0000000000000000 0000 FPR4=0000000000000000 0000 FPR5=0000000000000000 0000 FPR6=0000000000000000 0000 FPR7=0000000000000000 0000 XMM00=00000000000000000000000000000000 XMM01=00000000000000000000000000000000 XMM02=00000000000000000000000000000000 XMM03=00000000000000000000000000000000 XMM04=00000000000000000000000000000000 XMM05=00000000000000000000000000000000 XMM06=00000000000000000000000000000000 XMM07=00000000000000000000000000000000 XMM08=00000000000000000000000000000000 XMM09=00000000000000000000000000000000 XMM10=00000000000000000000000000000000 XMM11=00000000000000000000000000000000 XMM12=00000000000000000000000000000000 XMM13=00000000000000000000000000000000 XMM14=00000000000000000000000000000000 XMM15=00000000000000000000000000000000 So I think there is a problem between OVMF and gnu-efi for DEBUG() call. Since I can use DEBUG() with a code built with edk2 I will continue with that. I can do more testing and debug if needed. Just tell me. Thanks a lot [1] http://www.rodsbooks.com/efi-programming/hello.html [2] http://mjg59.dreamwidth.org/18773.html -- Dr. Ludovic Rousseau ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel