Commit Graph

172 Commits

Author SHA1 Message Date
Peter Jones
25cebcee2a Fix a sign error in the debughook example app
On ISO C90 on i386 4294967294 is a signed integer, and so x can't be
greater (or equal) to that.  Make it an unsigned and choose a better type
for the variable.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:23 -04:00
Peter Jones
e861bb3861 Work around -Werror=maybe-uninitialized not being very bright.
The compiler doesn't believe the loop always executes at least once,
even though the data in the first array entry doesn't satisfy the exit
condition.  So just initialize the thing to shut it up.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:23 -04:00
Peter Jones
5fa13d4609 Fix arm build paths in the makefile
Previous work was apparently done with arm-linux-gnueabi-gcc as a
cross-builder, but our armv7 builders have native gcc with the target as
armv7hl-linux-gnueabi, so we need to munge the arch there to get our arm
path.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:22 -04:00
Peter Jones
a46a62b12b Fix some types gcc doesn't like
Most of these come from building on i386 with -Wextra, but they're still
incorrect everywhere else; they just happen to have identical typedefs
at other places, so the compiler doesn't care.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-03-14 14:50:22 -04:00
Nigel Croxon
3b523e30f3 Merge /u/trofi/gnu-efi/ branch fix-64-build into master
https://sourceforge.net/p/gnu-efi/code/merge-requests/2/
2018-01-29 18:18:20 +00:00
Sergei Trofimovich
0e6995a96b gnu-efi: fix lib/ia64/setjmp.S IA-64 build failure
The build failed as:
  lib/ia64/setjmp.S:171: Error: Unknown opcode `ldf.nt1 f26=[r10],8'
  lib/ia64/setjmp.S:178: Error: Operand 1 of `ldf.fill.nt1' should be a floating-point register

The change syncs longjmp definition with
    edk2/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/setjmp.s
pulling in:
- branch in the end of function
- registers used wrong instruction for float restore

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2018-01-28 16:44:21 +00:00
Sergei Trofimovich
2cc0b085fb gnuefi: preserve .gnu.hash sections (unbreaks elilo on IA-64)
Gentoo has slightly modified linker defaults: --hash-style=gnu
This means all ELF files in system have '.gnu.hash' section
but no '.hash' section.

gnuefi's ldscript did not account for it and as a result
one symbol 'ImageBase' did not resolve locally for elilo.so
and caused 'elilo' to fail to load by ia64 EFI:
  Loading.: Gentoo (try new elilo)
  ImageAddress: pointer is outside of image
  ImageAddress: pointer is outside of image

Those two relocations come from crt0-efi-ia64.S PE32 entry point
fdescr:

```
    #define IMAGE_REL_BASED_DIR64<->10
    .section .reloc, "a"
    data4   _start_plabel // Page RVA
    data4   12            // Block Size (2*4+2*2)
    data2   (IMAGE_REL_BASED_DIR64<<12) +  0 // reloc for plabel's entry point
    data2   (IMAGE_REL_BASED_DIR64<<12) +  8 // reloc for plabel's global pointer
```

These refer ImageBase.

The change adds '.gnu.hash' collection (follows existing '.hash'
collection).

Tested on IA-64 by successfully booting elilo-3.16.

Bug: https://bugs.gentoo.org/575300
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2018-01-27 20:29:05 +00:00
Nigel Croxon
d039cd620b Currently we have DivU64x32 on ia32, but it tries to call
__umoddi3 and __udivdi3 from libgcc, which we don't have.
This fixes it to use our implementation in that case.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2018-01-10 10:28:36 -05:00
Nigel Croxon
f99001cd7d Bump revision from VERSION = 3.0.6 to VERSION = 3.0.7
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-11-06 09:44:21 -05:00
Nigel Croxon
b1d426ce67 Move memcpy/memset definition to global init.c
Following up on previous patch, I think we should move
memcpy/memset definitions to the global init.c, since MSVC does
also inserts calls to memset/memcpy for the x86_32 platform,
even when disabling standard libraries and intrinsics.

All in all, it looks like, for all platforms, we should assume
that a compiler may still insert these calls regardless.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-11-06 09:38:38 -05:00
Nigel Croxon
787b53a66c Add EFI_DRIVER_ENTRY_POINT support for MSVC/ARM64
Similar to what we do for other MSVC architectures.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-11-06 09:34:14 -05:00
Nigel Croxon
39ce220cb6 Make sure stdint.h is always used with MSVC on ARM/ARM64, since all
the versions of Visual Studio that support ARM or ARM64 have that
header. Without this, uint64_t would be defined to unsigned long,
which is 32-bits in the Microsoft world.

Also fix aarch64/initplat.c so that memset/memcpy only apply
to gcc. Otherwise MSVC throws an error for __SIZE_TYPE__.

Updating this patch to v2, since it turns out MSVC will also emit
memset and memcpy intrinsics that we can use an implementation for.
This is true for both ARM and ARM64.
To make this work, I'm defining __SIZE_TYPE__ to UINTN if not
already defined.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-11-06 09:26:05 -05:00
Nigel Croxon
15bcddc996 Stripped diff for makefile
This patch allows one to run make outside the source tree
with make -f <makefile>.

Signed-off-by: wolfra <wolfra@users.sf.net>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-11-06 09:06:31 -05:00
Nigel Croxon
08a46615c7 Use ARFLAGS when invoking ar.
The use of ARFLAGS makes these flags overridable.
The '-U' option is already added to ARFLAGS in Make.defaults.

Signed-off-by: Janosch Hildebrand <jnosh+git@jnosh.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-08-07 13:32:54 -04:00
Nigel Croxon
99d94682de [PATCH] Disable AVX instruction set on IA32 and x86_64 platforms
If gnu-efi is compiled with "-march=native" on a host that supports AVX, both
gcc and clang will use AVX instructions freely which is currently not supported
and will result in a non-functional gnu-efi build (e.g. black screen, hangs).

For now, disable AVX on IA32 and x86_64 by checking first if the compiler does
actually support the appropriate flag (-mno-avx) and use it if possible.

Credit for the compiler command line to check if a flag is supported goes to
Gentoo's awesome flag-o-matic eclass, where it is taken from. Thanks.

Signed-off-by: Matthias Dahl <matthias.dahl@binary-island.eu>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-07-13 08:43:16 -04:00
Nigel Croxon
af5d1494a9 -VERSION = 3.0.5
+VERSION = 3.0.6

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-06-20 10:12:22 -04:00
Nigel Croxon
bf07e81417 Declare EFI_PXE_BASE_CODE correctly
EFI_PXE_BASE_CODE was redefined in the early commit(*) to match the
definition in EDK2. However, EFI_PXE_BASE_CODE wasn't declared
correctly. Since EFI_PXE_BASE_CODE_PROTOCOL is already an alias of
"struct _EFI_PXE_BASE_CODE_PROTOCOL", the additional struct in front of
EFI_PXE_BASE_CODE_PROTOCOL actually confused the compiler and caused
build fail. Remove the redundant struct to avoid confusion.

*751cbce3f640c7 Update global protocol GUIDs definitions to match EDK2

Signed-off-by: Gary Lin <glin@suse.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-06-14 08:05:45 -04:00
Nigel Croxon
61859152d8 This commit inserts the libefi.a objects in a stable order.
When building libefi.a with "make -jN", the object files in libefi.a
will be inserted in a random order. Although it won't hurt the functionality,
it could make the EFI image irreproducible and invalidate the detached
signature after rebuilding libefi.a without any change in the source
code.

Signed-off-by: Gary Lin <glin@suse.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-06-01 07:47:37 -04:00
Nigel Croxon
8d8a3b5dff Add the fallthrough attribute to notify gcc7 that it's on purpose.
Signed-off-by: Gary Lin <glin@suse.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-05-31 06:53:49 -04:00
Nigel Croxon
08b72e8d99 This typedef is already defined with the structure and can
generate an error ("typedef redefinition is only available
in C11") with Clang.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-05-30 19:36:55 -04:00
Nigel Croxon
72a19c3a00 On x86_64, newish gcc will use relocation types R_X86_64_GOTPCREL,
R_X86_64_GOTPCREL64, R_X86_64_GOTPCRELX, and R_X86_64_REX_GOTPCRELX,
which our _relocate() does not support, for extern declarations visible
to things linking against a DSO.  Since we're really just building a .a
here, and *nothing* needs to be exported in the .so sense, we don't need
any of that optimization at all, there's no point in making _relocate()
know how to handle these.

Instead, this patch simply removes the visibility from everything in the
.a, which gets us back to fairly normal relative relocations that wind
up being R_X86_64_RELATIVE in the final binary, which we can handle.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-04-07 13:16:58 -04:00
Nigel Croxon
574b48d8e4 This is mere refactoring of the code and is not linked to any
specific issue.

I think ARM's DivU64x32() would be better located along MultU64x32()
and other calls in ARM's math.c, as having it in a header seems weird,
even with the goal of inlining it. I doubt there's much performance
to be lost from having it non-inline in math.c and it should make the
code breakdown more logical.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-03-30 18:04:42 -04:00
Nigel Croxon
d3e46ee9cb x86-64/efibind: sanitize ms-abi cpp conditionals
Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-03-10 16:03:59 -05:00
Nigel Croxon
9d0d941591 apps/tcc: tcc marcked ok for non x86-64 archs
Tested on qemu (x86-64 and arm64).

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-03-10 16:02:03 -05:00
Nigel Croxon
0e808e122a apps/tcc: remove unneeded includes
Signed-off-by: David Decotigny <<ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-03-10 16:00:06 -05:00
Nigel Croxon
79f4f38d15 Version checks in inc/x86_64/efibind.h for ms_abi support gives
false negative for clang.

Signed-off-by: toazzz < toal193@users.sf.net>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-20 14:29:53 -05:00
Nigel Croxon
049a863e14 Fixed build issue with apps/exit.c
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:31:39 -05:00
Nigel Croxon
3f8935c3d0 add-Exit - Add Exit() library function which calls BS->Exit()
Signed-off-by: Jonathon Reinhart <jonathon.reinhart@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:30:28 -05:00
Nigel Croxon
787cb7fcd8 fix clang support.
Tested:
  make all apps + tests apps/ on x86_64
  make CC=clang all apps + tests apps/ on x86_64

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:24:26 -05:00
Nigel Croxon
bdb6182f0a don't expect non-x86 compilers to compile x86 asm.
also remove what looks like garbage inside an #if 0 block.

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:22:44 -05:00
Nigel Croxon
7b0521df53 remove dead code
Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-17 16:19:16 -05:00
Nigel Croxon
8581a58e5b For compatibility with an upcoming EDK2 feature that maps UEFI apps
using strict permissions, emit the code as split .text/.data with
R-X/RW- permissions, respectively.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
2017-02-15 19:54:32 -05:00
Nigel Croxon
f164fd6785 -VERSION = 3.0.4
+VERSION = 3.0.5
2017-01-09 10:12:04 -05:00
Nigel Croxon
4d326eae7d Allow gcc to emit warnings for unsafe usage of setjmp/longjmp
Patch to allow gcc to emit warnings for unsafe usage of setjmp/long

Signed-off-by: David Decotigny <gdaviddecotigny@users.sf.net>
Signed-off-by: Nigel Croxon <noxorc@mac.com>
2017-01-08 07:11:24 -05:00
Nigel Croxon
3f234f5b6f Add support for 64 bit MIPS
This is a patch to add support for 64-bit MIPS.

Signed-off-by: Hev heiher <heiher@users.sf.net>
Signed-off-by: Nigel Croxon <noxorc@mac.com>
2017-01-08 07:04:52 -05:00
Nigel Croxon
87484730de Restore correct operation of BS driver test
Attaching a patch to fix apps/drv0.efi and apps/drv0_use.efi,
which are both currently not working.

Signed-off-by: David Decotigny <gdaviddecotigny@users.sf.net>
Signed-off-by: Nigel Croxon <noxorc@mac.com>
2017-01-08 06:58:30 -05:00
Nigel Croxon
fa1b977962 GCC 4.8 (and others) const warnings
Calling the various Print functions picked up some warnings in my
project (using GCC 4.8 and 4.9 at the moment):
warning: passing argument 1 of Print discards const qualifier from
pointer target type [enabled by default]

Signed-off-by: Nigel Croxon <noxorc@mac.com>
Signed-off-by: Justinian <justinian@users.sf.net>
2017-01-08 06:52:33 -05:00
Nigel Croxon
bd38ba4b6b GNU ar warning about deterministic mode
GNU ar currently produces the following string of warnings:
Warning: Archive 'libefi.a' seems to have been created in
deterministic mode.
'<file>.o' will always be updated. Please consider passing
the U flag to ar to avoid the problem. This patch fixes the issue.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <noxorc@users.sf.net>
2016-11-21 10:59:13 -05:00
Nigel Croxon
8071303f52 AARCH64 gcc error with const qualifiers
aarch64-linux-gnu-gcc on Debian/Sid fails lib compilation with:
lib/aarch64/initplat.c:44:35: error: initialization discards
‘const’ qualifier from pointer target type
[-Werror=discarded-qualifiers].  This patch fixes it.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <noxorc@users.sf.net>
2016-11-21 10:55:10 -05:00
Nigel Croxon
b14cc9cb4f Add Debugger protocol support.
Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-09-15 14:38:51 -04:00
Nigel Croxon
447ad9aa3a Add EBC (EFI Byte Code) protocol support.
Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-09-15 14:34:56 -04:00
Nigel Croxon
c108e118da Add support for PCI Root Bridge I/O protocol.
PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform
PCI Memory, PCI I/O, and PCI Configuration cycles on a
PCI Root Bridge. It also provides services to perform different
types of bus mastering DMA.

V2 - Scratch that - there already exists an efipciio.h with most
of these definitions. Let me remove this patch and propose a new
one that will amend what's already there.
OK, here's a better version that adds the required definition in
efipciio.h. Note that EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL and
EFI_PCI_IO_PROTOCOL are two different protocols.

V3 - Pete, There are now two defines of EFI_PCI_ADDRESS.
Please repost with your define removed.
Nigel, Sorry about that. Here's v3.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-09-15 12:50:48 -04:00
Nigel Croxon
9cdd67da85 Bridge more gaps between EDK and gnu-efi
This patch adds a few more items to facilitate porting
from EDK to gnu-efi.
It also adds updated PE machine types and fixes a discrepancy
for EVT_EFI_SIGNAL_MAX.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-09-15 11:41:45 -04:00
Nigel Croxon
751cbce3f6 Update global protocol GUIDs definitions to match EDK2
This patch introduces the use of the EDK2 names for the global GUID
variables, to allow for easier code conversion between EDK2 and
gnu-efi. All the existing GUID global variables have also been
aliased for backwards compatibility.

The patch also completes some of the earlier work with regards to
protocol struct definitions to also match the EDK2, with the
following caveat:
Because some of gnu-efi GUID macro definitions were declared with
the name that the EDK2 uses for the protocol struct itself, we have
to immediately deprecate the following GUID data aliases:
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
EFI_SIMPLE_NETWORK_PROTOCOL
EFI_PCI_IO_PROTOCOL
EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL
This means that existing code using one of the above will break
on compilation. To mitigate this, explicit warnings have been
placed at the location where a developer will look for breakage,
detailing how they should amend their code.

The KnownGuids short labels in guid.c were also updated/amended
in a manner that should be a bit more consistent (though I have
no idea what the EDK2 does here, since I haven't looked at the
actual EDK2 source).

Finally, besides clean up (typo, whitespaces, duplicate removal),
we introduce the _GNU_EFI macro, in efi.h, to allow for conditional
selection of specific gnu-efi API calls, in code that may be
compiled with either EDK2 or gnu-efi.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-08-18 08:42:11 -04:00
Nigel Croxon
7993cbcc72 Add support for some UEFI 2.0 protocols
* DevicePath[To|From]Text
* BlockIo2
* DiskIo2
* Ex calls for Simple File System

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-08-16 10:18:58 -04:00
Nigel Croxon
1b10394e06 This patch is a follow up to 8118d08727
and completes the renaming of structs, defines, and typedefs to match
the naming convention from the latest UEFI specifications.

This should make it easier for people to switch between EDK2 and
gnu-efi compilation.

The original names are #defined or typedef'd to the new names for
backwards compatibility. Also some whitespace cleanup was applied.

Note 1: From what I could see of the EDK API documentation,
structs are being aliased to their old names using typedef rather
than #define, so that's what I used. I altered some of the #define
from 8118d0 accordingly

Note 2: I also think it might be more helpful for users to keep
the backwards compatibility defs close to their declaration
(e.g. old GUID def right after current GUID declaration), rather
than in a separate section as was done in 8118d0, so that's what
I did in this patch.

Signed-off-by: Pete Batard <pbatard@users.sf.net>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-08-15 10:41:40 -04:00
Nigel Croxon
ef81c051c9 Add GUID for SMBIOS 3 entry point structure.
64 bit entry point structure has a different GUID
from the existing 32 bit version.

Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-08-12 10:43:25 -04:00
Nigel Croxon
93ef26559c The latest gnu-efi produces the following warning when
compiled with MSVC: lib\print.c(1345): warning C4244:
'initializing': conversion from 'double' to 'float',
possible loss of data

Signed-off-by: Pete Batard <pbatard@users.sf.net>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-07-08 11:01:40 -04:00
Nigel Croxon
cae022d6e4 This patch adds definitions to efiprot.h for
EFI_EDID_ACTIVE_PROTOCOL
     EFI_EDID_DISCOVERED_PROTOCOL
     EFI_EDID_OVERRIDE_PROTOCOL
It also adds the matching global variables to libefi.

Signed-off-by: Nathan Blythe <nblythe@lgsinnovations.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-07-08 10:56:31 -04:00
Nigel Croxon
44d9ae1929 I did not submit the right file on my last submission.
This patch corrects the printing of leading fractional
part 0s in Print("%f").

Signed-off-by: Nathan Blythe <nblythe@lgsinnovations.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
2016-06-17 13:08:56 -04:00