Commit 13cbb194 authored by Julian Andres Klode's avatar Julian Andres Klode

Imported Upstream version 3.0.3

parent 8e41301e
*.efi
*.efi.debug
*.o
*.a
*.tar.*
......
This diff is collapsed.
......@@ -140,13 +140,14 @@ INCDIR += -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) \
-I$(TOPDIR)/inc/protocol
ifeq (FreeBSD, $(findstring FreeBSD, $(OS)))
CFLAGS += $(ARCH3264) -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing \
CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing \
-ffreestanding -fno-stack-protector
else
CFLAGS += $(ARCH3264) -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing \
CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing \
-fno-merge-constants -ffreestanding -fno-stack-protector \
-fno-stack-check
endif
ASFLAGS += $(ARCH3264)
LDFLAGS += -nostdlib --warn-common --no-undefined --fatal-warnings
LDFLAGS += -nostdlib --warn-common --no-undefined --fatal-warnings \
--build-id=sha1
......@@ -39,6 +39,12 @@
-j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \
-j .reloc $(FORMAT) $*.so $@
%.efi.debug: %.so
$(OBJCOPY) -j .debug_info -j .debug_abbrev -j .debug_aranges \
-j .debug_line -j .debug_str -j .debug_ranges \
-j .note.gnu.build-id \
$(FORMAT) $*.so $@
%.so: %.o
$(LD) $(LDFLAGS) $^ -o $@ $(LOADLIBES)
......
......@@ -34,7 +34,7 @@
# SUCH DAMAGE.
#
VERSION = 3.0.2
VERSION = 3.0.3
SRCDIR = $(shell pwd)
......
......@@ -61,7 +61,7 @@ LOADLIBES += -T $(LDSCRIPT)
TARGET_APPS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi \
printenv.efi t7.efi t8.efi tcc.efi modelist.efi \
route80h.efi drv0_use.efi AllocPages.efi \
FreePages.efi
FreePages.efi setjmp.efi debughook.efi debughook.efi.debug
TARGET_BSDRIVERS = drv0.efi
TARGET_RTDRIVERS =
......
#include <efi.h>
#include <efilib.h>
EFI_STATUS
GetVariableAttr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner,
UINT32 *attributes)
{
EFI_STATUS efi_status;
*len = 0;
efi_status = uefi_call_wrapper(RT->GetVariable, 5, var, &owner,
NULL, len, NULL);
if (efi_status != EFI_BUFFER_TOO_SMALL)
return efi_status;
*data = AllocateZeroPool(*len);
if (!*data)
return EFI_OUT_OF_RESOURCES;
efi_status = uefi_call_wrapper(RT->GetVariable, 5, var, &owner,
attributes, len, *data);
if (efi_status != EFI_SUCCESS) {
FreePool(*data);
*data = NULL;
}
return efi_status;
}
EFI_STATUS
GetVariable(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner)
{
return GetVariableAttr(var, data, len, owner, NULL);
}
EFI_GUID DUMMY_GUID =
{0x55aad538, 0x8f82, 0x4e2a, {0xa4,0xf0,0xbe, 0x59, 0x13, 0xb6, 0x5f, 0x1e}};
static void
__attribute__((__optimize__("0")))
DebugHook(void)
{
EFI_GUID guid = DUMMY_GUID;
UINT8 *data = NULL;
UINTN dataSize = 0;
EFI_STATUS efi_status;
volatile register UINTN x = 0;
extern char _text, _data;
if (x)
return;
efi_status = GetVariable(L"DUMMY_DEBUG", &data, &dataSize, guid);
if (EFI_ERROR(efi_status)) {
return;
}
Print(L"add-symbol-file /usr/lib/debug/boot/efi/debughook.debug "
L"0x%08x -s .data 0x%08x\n", &_text, &_data);
Print(L"Pausing for debugger attachment.\n");
Print(L"To disable this, remove the EFI variable DUMMY_DEBUG-%g .\n",
&guid);
x = 1;
while (x++) {
/* Make this so it can't /totally/ DoS us. */
#if defined(__x86_64__) || defined(__i386__) || defined(__i686__)
if (x > 4294967294)
break;
__asm__ __volatile__("pause");
#elif defined(__aarch64__)
if (x > 1000)
break;
__asm__ __volatile__("wfi");
#else
if (x > 12000)
break;
uefi_call_wrapper(BS->Stall, 1, 5000);
#endif
}
x = 1;
}
EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
InitializeLib(image, systab);
DebugHook();
return EFI_SUCCESS;
}
#include <efi.h>
#include <efilib.h>
EFI_STATUS
efi_main(
EFI_HANDLE image_handle,
EFI_SYSTEM_TABLE *systab
)
{
jmp_buf env;
int rc;
InitializeLib(image_handle, systab);
rc = setjmp(&env);
Print(L"setjmp() = %d\n", rc);
if (rc == 3) {
Print(L"3 worked\n");
longjmp(&env, 0);
return 0;
}
if (rc == 1) {
Print(L"0 got to be one yay\n");
return 0;
}
longjmp(&env, 3);
return 0;
}
......@@ -4,6 +4,7 @@ ENTRY(_start)
SECTIONS
{
.text 0x0 : {
_text = .;
*(.text.head)
*(.text)
*(.text.*)
......@@ -11,11 +12,13 @@ SECTIONS
*(.srodata)
*(.rodata*)
. = ALIGN(16);
_etext = .;
}
_etext = .;
_text_size = . - _text;
.dynamic : { *(.dynamic) }
.data :
{
_data = .;
*(.sdata)
*(.data)
*(.data1)
......
......@@ -4,6 +4,7 @@ ENTRY(_start)
SECTIONS
{
.text 0x0 : {
_text = .;
*(.text.head)
*(.text)
*(.text.*)
......@@ -11,11 +12,13 @@ SECTIONS
*(.srodata)
*(.rodata*)
. = ALIGN(16);
_etext = .;
}
_etext = .;
_text_size = . - _text;
.dynamic : { *(.dynamic) }
.data :
{
_data = .;
*(.sdata)
*(.data)
*(.data1)
......
......@@ -9,13 +9,18 @@ SECTIONS
. = ALIGN(4096);
.text :
{
_text = .;
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
. = ALIGN(16);
}
_etext = .;
_text_size = . - _text;
. = ALIGN(4096);
.sdata :
{
_data = .;
*(.got.plt)
*(.got)
*(.srodata)
......@@ -55,6 +60,8 @@ SECTIONS
*(.data.rel.ro)
*(.data.rel*)
}
_edata = .;
_data_size = . - _etext;
. = ALIGN(4096);
.reloc : /* This is the PECOFF .reloc section! */
{
......
......@@ -9,13 +9,18 @@ SECTIONS
. = ALIGN(4096);
.text :
{
_text = .;
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
. = ALIGN(16);
}
_etext = .;
_text_size = . - _text;
. = ALIGN(4096);
.sdata :
{
_data = .;
*(.got.plt)
*(.got)
*(.srodata)
......@@ -55,6 +60,8 @@ SECTIONS
*(.data.rel.ro)
*(.data.rel*)
}
_edata = .;
_data_size = . - _etext;
. = ALIGN(4096);
.reloc : /* This is the PECOFF .reloc section! */
{
......
......@@ -9,14 +9,19 @@ SECTIONS
. = ALIGN(4096);
.text :
{
_text = .;
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
. = ALIGN(16);
}
_etext = .;
_text_size = . - _text;
. = ALIGN(4096);
__gp = ALIGN (8) + 0x200000;
.sdata :
{
_data = .;
*(.got.plt)
*(.got)
*(.srodata)
......@@ -51,6 +56,8 @@ SECTIONS
*(.rela.stab)
*(.rela.ctors)
}
_edata = .;
_data_size = . - _etext;
. = ALIGN(4096);
.reloc : /* This is the PECOFF .reloc section! */
{
......
......@@ -15,10 +15,14 @@ SECTIONS
. = ALIGN(4096);
.text :
{
_text = .;
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
. = ALIGN(16);
}
_etext = .;
_text_size = . - _text;
. = ALIGN(4096);
.reloc :
{
......@@ -27,6 +31,7 @@ SECTIONS
. = ALIGN(4096);
.data :
{
_data = .;
*(.rodata*)
*(.got.plt)
*(.got)
......@@ -41,6 +46,8 @@ SECTIONS
*(COMMON)
*(.rel.local)
}
_edata = .;
_data_size = . - _etext;
. = ALIGN(4096);
.dynamic : { *(.dynamic) }
. = ALIGN(4096);
......
......@@ -15,8 +15,12 @@ SECTIONS
. = ALIGN(4096);
.text :
{
_text = .;
*(.text)
. = ALIGN(16);
}
_etext = .;
_text_size = . - _text;
.reloc :
{
*(.reloc)
......@@ -24,6 +28,7 @@ SECTIONS
. = ALIGN(4096);
.data :
{
_data = .;
*(.rodata*)
*(.got.plt)
*(.got)
......@@ -47,6 +52,8 @@ SECTIONS
*(.rela.got)
*(.rela.stab)
}
_edata = .;
_data_size = . - _etext;
. = ALIGN(4096);
.dynsym : { *(.dynsym) }
. = ALIGN(4096);
......
#ifndef GNU_EFI_AARCH64_SETJMP_H
#define GNU_EFI_AARCH64_SETJMP_H
typedef struct {
/* GP regs */
UINT64 X19;
UINT64 X20;
UINT64 X21;
UINT64 X22;
UINT64 X23;
UINT64 X24;
UINT64 X25;
UINT64 X26;
UINT64 X27;
UINT64 X28;
UINT64 FP;
UINT64 LR;
UINT64 IP0;
/* FP regs */
UINT64 D8;
UINT64 D9;
UINT64 D10;
UINT64 D11;
UINT64 D12;
UINT64 D13;
UINT64 D14;
UINT64 D15;
} __attribute__((__aligned__(8))) jmp_buf;
#endif /* GNU_EFI_AARCH64_SETJMP_H */
#ifndef GNU_EFI_ARM_SETJMP_H
#define GNU_EFI_ARM_SETJMP_H
typedef struct {
UINT32 R3; // A copy of R13
UINT32 R4;
UINT32 R5;
UINT32 R6;
UINT32 R7;
UINT32 R8;
UINT32 R9;
UINT32 R10;
UINT32 R11;
UINT32 R12;
UINT32 R13;
UINT32 R14;
} __attribute__((__aligned__(4))) jmp_buf;
#endif /* GNU_EFI_ARM_SETJMP_H */
......@@ -50,5 +50,6 @@ Revision History
#include "efiudp.h"
#include "efitcp.h"
#include "efipoint.h"
#include "efisetjmp.h"
#endif
......@@ -298,6 +298,17 @@ typedef struct _IPv6_DEVICE_PATH {
EFI_IPv6_ADDRESS GatewayIpAddress ;
} IPv6_DEVICE_PATH;
/**
* Uniform Resource Identifiers SubType.
* UEFI 2.0 specification version 2.4C § 9.3.5.23.
*/
#define MSG_URI_DP 24
typedef struct _URI_DEVICE_PATH {
EFI_DEVICE_PATH Header;
CHAR8 Uri[1];
} URI_DEVICE_PATH;
/**
* Device Logical Unit SubType.
* UEFI 2.0 specification version 2.4 § 9.3.5.8.
......
#ifndef GNU_EFI_SETJMP_H
#define GNU_EFI_SETJMP_H
#include "efisetjmp_arch.h"
extern UINTN setjmp(jmp_buf *env);
extern VOID longjmp(jmp_buf *env, UINTN value);
#endif /* GNU_EFI_SETJMP_H */
#ifndef GNU_EFI_IA32_SETJMP_H
#define GNU_EFI_IA32_SETJMP_H
typedef struct {
UINT32 Ebx;
UINT32 Esi;
UINT32 Edi;
UINT32 Ebp;
UINT32 Esp;
UINT32 Eip;
} __attribute__((__aligned__(4))) jmp_buf;
#define JMPBUF_ALIGN 4
#endif /* GNU_EFI_IA32_SETJMP_H */
#ifndef GNU_EFI_IA64_SETJMP_H
#define GNU_EFI_IA64_SETJMP_H
typedef struct {
UINT64 F2[2];
UINT64 F3[2];
UINT64 F4[2];
UINT64 F5[2];
UINT64 F16[2];
UINT64 F17[2];
UINT64 F18[2];
UINT64 F19[2];
UINT64 F20[2];
UINT64 F21[2];
UINT64 F22[2];
UINT64 F23[2];
UINT64 F24[2];
UINT64 F25[2];
UINT64 F26[2];
UINT64 F27[2];
UINT64 F28[2];
UINT64 F29[2];
UINT64 F30[2];
UINT64 F31[2];
UINT64 R4;
UINT64 R5;
UINT64 R6;
UINT64 R7;
UINT64 SP;
UINT64 BR0;
UINT64 BR1;
UINT64 BR2;
UINT64 BR3;
UINT64 BR4;
UINT64 BR5;
UINT64 InitialUNAT;
UINT64 AfterSpillUNAT;
UINT64 PFS;
UINT64 BSP;
UINT64 Predicates;
UINT64 LoopCount;
UINT64 FPSR;
} __attribute__((__aligned__(0x10))) jmp_buf;
#endif /* GNU_EFI_IA64_SETJMP_H */
#ifndef GNU_EFI_X86_64_SETJMP_H
#define GNU_EFI_X86_64_SETJMP_H
typedef struct {
UINT64 Rbx;
UINT64 Rsp;
UINT64 Rbp;
UINT64 Rdi;
UINT64 Rsi;
UINT64 R12;
UINT64 R13;
UINT64 R14;
UINT64 R15;
UINT64 Rip;
UINT64 MxCsr;
UINT8 XmmBuffer[160]; // XMM6 - XMM15
} __attribute__((__aligned__(8))) jmp_buf;
#endif /* GNU_EFI_X86_64_SETJMP_H */
......@@ -47,7 +47,7 @@ FILES = boxdraw smbios console crc data debug dpath \
error event guid hand hw init lock \
misc print sread str cmdline \
runtime/rtlock runtime/efirtlib runtime/rtstr runtime/vm runtime/rtdata \
$(ARCH)/initplat $(ARCH)/math
$(ARCH)/initplat $(ARCH)/math $(ARCH)/setjmp
ifeq ($(ARCH),ia64)
FILES += $(ARCH)/salpal $(ARCH)/palproc
......
#
# Copyright (C) 1999-2001 Hewlett-Packard Co.
# Contributed by David Mosberger <davidm@hpl.hp.com>
# Contributed by Stephane Eranian <eranian@hpl.hp.com>
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
# * Neither the name of Hewlett-Packard Co. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
# BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
SRCDIR = .
VPATH = $(SRCDIR)
include $(SRCDIR)/../Make.defaults
TOPDIR = $(SRCDIR)/..
CDIR = $(TOPDIR)/..
FILES = boxdraw smbios console crc data debug dpath \
error event guid hand hw init lock \
misc print sread str cmdline \
runtime/rtlock runtime/efirtlib runtime/rtstr runtime/vm runtime/rtdata \
$(ARCH)/initplat $(ARCH)/math
ifeq ($(ARCH),ia64)
FILES += $(ARCH)/salpal $(ARCH)/palproc
endif
ifeq ($(ARCH),x86_64)
FILES += $(ARCH)/callwrap $(ARCH)/efi_stub
endif
ifeq ($(ARCH),arm)
FILES += $(ARCH)/lib1funcs $(ARCH)/div64
endif
OBJS = $(FILES:%=%.o)
SUBDIRS = ia32 x86_64 ia64 aarch64 arm runtime
LIBDIRINSTALL = $(INSTALLROOT)$(LIBDIR)
all: libsubdirs libefi.a
.PHONY: libsubdirs
libsubdirs:
for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
libefi.a: $(patsubst %,libefi.a(%),$(OBJS))
clean:
rm -f libefi.a *~ $(OBJS) */*.o
$(LIBDIRINSTALL):
mkdir -p $@
$(LIBDIRINSTALL)/libefi.a: libefi.a | $(LIBDIRINSTALL)
$(INSTALL) -m 644 $< $(dir $@)
install: $(LIBDIRINSTALL)/libefi.a
include $(SRCDIR)/../Make.rules
.PHONY: libsubdirs
/*
* Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
* This program and the accompanying materials are licensed and made
available
* under the terms and conditions of the BSD License which accompanies
this
* distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php.
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
* IMPLIED.
*/
.text
.p2align 3
#define GPR_LAYOUT \
REG_PAIR (x19, x20, 0); \
REG_PAIR (x21, x22, 16); \
REG_PAIR (x23, x24, 32); \
REG_PAIR (x25, x26, 48); \
REG_PAIR (x27, x28, 64); \
REG_PAIR (x29, x30, 80); \
REG_ONE (x16, 96)
#define FPR_LAYOUT \
REG_PAIR(d8, d9, 112); \
REG_PAIR(d10, d11, 128); \
REG_PAIR(d12, d13, 144); \
REG_PAIR(d14, d15, 160);
#define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]
.globl setjmp
.type setjmp, @function
setjmp:
mov x16, sp
GPR_LAYOUT
FPR_LAYOUT
mov w0, #0
ret
#undef REG_PAIR
#undef REG_ONE
#define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]
.globl longjmp
.type longjmp, @function
longjmp:
GPR_LAYOUT
FPR_LAYOUT
mov sp, x16
cmp w1, #0
mov w0, #1
csel w0, w1, w0, ne
br x30
/*
* Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
* This program and the accompanying materials are licensed and made
available
* under the terms and conditions of the BSD License which accompanies
this
* distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php.
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
* IMPLIED.
*/
.text
.arm
.globl setjmp
.type setjmp, @function
setjmp:
mov r3, r13
stmia r0, {r3-r12,r14}
eor r0, r0, r0
bx lr
.globl longjmp
.type longjmp, @function
longjmp:
ldmia r0, {r3-r12,r14}
......@@ -841,6 +841,19 @@ _DevPathIPv6 (
CatPrint( Str , L")") ;
}
static VOID
_DevPathUri (
IN OUT POOL_PRINT *Str,
IN VOID *DevPath
)
{
URI_DEVICE_PATH *Uri;
Uri = DevPath;
CatPrint( Str, L"Uri(%a)", Uri->Uri );
}
static VOID
_DevPathInfiniBand (
IN OUT POOL_PRINT *Str,
......@@ -1088,6 +1101,7 @@ struct {
{ MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, _DevPathMacAddr},
{ MESSAGING_DEVICE_PATH, MSG_IPv4_DP, _DevPathIPv4},
{ MESSAGING_DEVICE_PATH, MSG_IPv6_DP, _DevPathIPv6},
{ MESSAGING_DEVICE_PATH, MSG_URI_DP, _DevPathUri},
{ MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, _DevPathInfiniBand},
{ MESSAGING_DEVICE_PATH, MSG_UART_DP, _DevPathUart},
{ MESSAGING_DEVICE_PATH , MSG_SATA_DP , _DevPathSata } ,
......
......@@ -47,6 +47,13 @@ struct {