moved everything to chookspace
This commit is contained in:
93
gnu-efi/lib/Makefile
Normal file
93
gnu-efi/lib/Makefile
Normal file
@@ -0,0 +1,93 @@
|
||||
#
|
||||
# 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 exit 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)/setjmp
|
||||
|
||||
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)/uldiv $(ARCH)/ldivmod $(ARCH)/div $(ARCH)/llsl $(ARCH)/llsr \
|
||||
$(ARCH)/mullu
|
||||
endif
|
||||
|
||||
OBJS = $(FILES:%=%.o)
|
||||
|
||||
SUBDIRS = ia32 x86_64 ia64 aarch64 arm mips64el runtime
|
||||
|
||||
LIBDIRINSTALL = $(INSTALLROOT)$(LIBDIR)
|
||||
|
||||
all: libsubdirs libefi.a
|
||||
|
||||
.PHONY: libsubdirs
|
||||
libsubdirs:
|
||||
for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
|
||||
|
||||
libefi.a: $(OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
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
|
||||
91
gnu-efi/lib/Makefile.orig
Normal file
91
gnu-efi/lib/Makefile.orig
Normal file
@@ -0,0 +1,91 @@
|
||||
#
|
||||
# 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
|
||||
1
gnu-efi/lib/aarch64/efi_stub.S
Normal file
1
gnu-efi/lib/aarch64/efi_stub.S
Normal file
@@ -0,0 +1 @@
|
||||
/* This stub is a stub to make the build happy */
|
||||
26
gnu-efi/lib/aarch64/initplat.c
Normal file
26
gnu-efi/lib/aarch64/initplat.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copright (C) 2014 Linaro Ltd.
|
||||
* Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice and this list of conditions, without modification.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
InitializeLibPlatform (
|
||||
IN EFI_HANDLE ImageHandle EFI_UNUSED,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
|
||||
)
|
||||
{
|
||||
}
|
||||
63
gnu-efi/lib/aarch64/math.c
Normal file
63
gnu-efi/lib/aarch64/math.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copright (C) 2014 Linaro Ltd.
|
||||
* Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice and this list of conditions, without modification.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
UINT64
|
||||
LShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Left shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Operand << Count;
|
||||
}
|
||||
|
||||
UINT64
|
||||
RShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Right shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Operand >> Count;
|
||||
}
|
||||
|
||||
|
||||
UINT64
|
||||
MultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINTN Multiplier
|
||||
)
|
||||
// Multiple 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Multiplicand * Multiplier;
|
||||
}
|
||||
|
||||
UINT64
|
||||
DivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINTN Divisor,
|
||||
OUT UINTN *Remainder OPTIONAL
|
||||
)
|
||||
// divide 64bit by 32bit and get a 64bit result
|
||||
// N.B. only works for 31bit divisors!!
|
||||
{
|
||||
if (Remainder)
|
||||
*Remainder = Dividend % Divisor;
|
||||
return Dividend / Divisor;
|
||||
}
|
||||
60
gnu-efi/lib/aarch64/setjmp.S
Normal file
60
gnu-efi/lib/aarch64/setjmp.S
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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
|
||||
155
gnu-efi/lib/arm/div.S
Normal file
155
gnu-efi/lib/arm/div.S
Normal file
@@ -0,0 +1,155 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2011, ARM. All rights reserved.<BR>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#include "edk2asm.h"
|
||||
|
||||
.text
|
||||
.align 2
|
||||
GCC_ASM_EXPORT(__aeabi_uidiv)
|
||||
GCC_ASM_EXPORT(__aeabi_uidivmod)
|
||||
GCC_ASM_EXPORT(__aeabi_idiv)
|
||||
GCC_ASM_EXPORT(__aeabi_idivmod)
|
||||
|
||||
# AREA Math, CODE, READONLY
|
||||
|
||||
#
|
||||
#UINT32
|
||||
#EFIAPI
|
||||
#__aeabi_uidivmode (
|
||||
# IN UINT32 Dividen
|
||||
# IN UINT32 Divisor
|
||||
# );
|
||||
#
|
||||
|
||||
ASM_PFX(__aeabi_uidiv):
|
||||
ASM_PFX(__aeabi_uidivmod):
|
||||
rsbs r12, r1, r0, LSR #4
|
||||
mov r2, #0
|
||||
bcc ASM_PFX(__arm_div4)
|
||||
rsbs r12, r1, r0, LSR #8
|
||||
bcc ASM_PFX(__arm_div8)
|
||||
mov r3, #0
|
||||
b ASM_PFX(__arm_div_large)
|
||||
|
||||
#
|
||||
#INT32
|
||||
#EFIAPI
|
||||
#__aeabi_idivmode (
|
||||
# IN INT32 Dividen
|
||||
# IN INT32 Divisor
|
||||
# );
|
||||
#
|
||||
ASM_PFX(__aeabi_idiv):
|
||||
ASM_PFX(__aeabi_idivmod):
|
||||
orrs r12, r0, r1
|
||||
bmi ASM_PFX(__arm_div_negative)
|
||||
rsbs r12, r1, r0, LSR #1
|
||||
mov r2, #0
|
||||
bcc ASM_PFX(__arm_div1)
|
||||
rsbs r12, r1, r0, LSR #4
|
||||
bcc ASM_PFX(__arm_div4)
|
||||
rsbs r12, r1, r0, LSR #8
|
||||
bcc ASM_PFX(__arm_div8)
|
||||
mov r3, #0
|
||||
b ASM_PFX(__arm_div_large)
|
||||
ASM_PFX(__arm_div8):
|
||||
rsbs r12, r1, r0, LSR #7
|
||||
subcs r0, r0, r1, LSL #7
|
||||
adc r2, r2, r2
|
||||
rsbs r12, r1, r0,LSR #6
|
||||
subcs r0, r0, r1, LSL #6
|
||||
adc r2, r2, r2
|
||||
rsbs r12, r1, r0, LSR #5
|
||||
subcs r0, r0, r1, LSL #5
|
||||
adc r2, r2, r2
|
||||
rsbs r12, r1, r0, LSR #4
|
||||
subcs r0, r0, r1, LSL #4
|
||||
adc r2, r2, r2
|
||||
ASM_PFX(__arm_div4):
|
||||
rsbs r12, r1, r0, LSR #3
|
||||
subcs r0, r0, r1, LSL #3
|
||||
adc r2, r2, r2
|
||||
rsbs r12, r1, r0, LSR #2
|
||||
subcs r0, r0, r1, LSL #2
|
||||
adcs r2, r2, r2
|
||||
rsbs r12, r1, r0, LSR #1
|
||||
subcs r0, r0, r1, LSL #1
|
||||
adc r2, r2, r2
|
||||
ASM_PFX(__arm_div1):
|
||||
subs r1, r0, r1
|
||||
movcc r1, r0
|
||||
adc r0, r2, r2
|
||||
bx r14
|
||||
ASM_PFX(__arm_div_negative):
|
||||
ands r2, r1, #0x80000000
|
||||
rsbmi r1, r1, #0
|
||||
eors r3, r2, r0, ASR #32
|
||||
rsbcs r0, r0, #0
|
||||
rsbs r12, r1, r0, LSR #4
|
||||
bcc label1
|
||||
rsbs r12, r1, r0, LSR #8
|
||||
bcc label2
|
||||
ASM_PFX(__arm_div_large):
|
||||
lsl r1, r1, #6
|
||||
rsbs r12, r1, r0, LSR #8
|
||||
orr r2, r2, #0xfc000000
|
||||
bcc label2
|
||||
lsl r1, r1, #6
|
||||
rsbs r12, r1, r0, LSR #8
|
||||
orr r2, r2, #0x3f00000
|
||||
bcc label2
|
||||
lsl r1, r1, #6
|
||||
rsbs r12, r1, r0, LSR #8
|
||||
orr r2, r2, #0xfc000
|
||||
orrcs r2, r2, #0x3f00
|
||||
lslcs r1, r1, #6
|
||||
rsbs r12, r1, #0
|
||||
bcs ASM_PFX(__aeabi_idiv0)
|
||||
label3:
|
||||
lsrcs r1, r1, #6
|
||||
label2:
|
||||
rsbs r12, r1, r0, LSR #7
|
||||
subcs r0, r0, r1, LSL #7
|
||||
adc r2, r2, r2
|
||||
rsbs r12, r1, r0, LSR #6
|
||||
subcs r0, r0, r1, LSL #6
|
||||
adc r2, r2, r2
|
||||
rsbs r12, r1, r0, LSR #5
|
||||
subcs r0, r0, r1, LSL #5
|
||||
adc r2, r2, r2
|
||||
rsbs r12, r1, r0, LSR #4
|
||||
subcs r0, r0, r1, LSL #4
|
||||
adc r2, r2, r2
|
||||
label1:
|
||||
rsbs r12, r1, r0, LSR #3
|
||||
subcs r0, r0, r1, LSL #3
|
||||
adc r2, r2, r2
|
||||
rsbs r12, r1, r0, LSR #2
|
||||
subcs r0, r0, r1, LSL #2
|
||||
adcs r2, r2, r2
|
||||
bcs label3
|
||||
rsbs r12, r1, r0, LSR #1
|
||||
subcs r0, r0, r1, LSL #1
|
||||
adc r2, r2, r2
|
||||
subs r1, r0, r1
|
||||
movcc r1, r0
|
||||
adc r0, r2, r2
|
||||
asrs r3, r3, #31
|
||||
rsbmi r0, r0, #0
|
||||
rsbcs r1, r1, #0
|
||||
bx r14
|
||||
|
||||
@ What to do about division by zero? For now, just return.
|
||||
ASM_PFX(__aeabi_idiv0):
|
||||
bx r14
|
||||
6
gnu-efi/lib/arm/edk2asm.h
Normal file
6
gnu-efi/lib/arm/edk2asm.h
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
#define ASM_PFX(x) x
|
||||
#define GCC_ASM_EXPORT(x) \
|
||||
.globl x ; \
|
||||
.type x, %function
|
||||
|
||||
1
gnu-efi/lib/arm/efi_stub.S
Normal file
1
gnu-efi/lib/arm/efi_stub.S
Normal file
@@ -0,0 +1 @@
|
||||
/* This stub is a stub to make the build happy */
|
||||
34
gnu-efi/lib/arm/initplat.c
Normal file
34
gnu-efi/lib/arm/initplat.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copright (C) 2014 Linaro Ltd.
|
||||
* Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice and this list of conditions, without modification.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
InitializeLibPlatform (
|
||||
IN EFI_HANDLE ImageHandle EFI_UNUSED,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
void __div0(void)
|
||||
{
|
||||
// TODO handle divide by zero fault
|
||||
while (1);
|
||||
}
|
||||
#endif
|
||||
61
gnu-efi/lib/arm/ldivmod.S
Normal file
61
gnu-efi/lib/arm/ldivmod.S
Normal file
@@ -0,0 +1,61 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include "edk2asm.h"
|
||||
|
||||
.text
|
||||
.align 2
|
||||
GCC_ASM_EXPORT(__aeabi_ldivmod)
|
||||
|
||||
//
|
||||
// A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}},
|
||||
// the quotient in {r0, r1}, and the remainder in {r2, r3}.
|
||||
//
|
||||
//__value_in_regs lldiv_t
|
||||
//EFIAPI
|
||||
//__aeabi_ldivmod (
|
||||
// IN UINT64 Dividen
|
||||
// IN UINT64 Divisor
|
||||
// )//
|
||||
//
|
||||
|
||||
ASM_PFX(__aeabi_ldivmod):
|
||||
push {r4,lr}
|
||||
asrs r4,r1,#1
|
||||
eor r4,r4,r3,LSR #1
|
||||
bpl L_Test1
|
||||
rsbs r0,r0,#0
|
||||
rsc r1,r1,#0
|
||||
L_Test1:
|
||||
tst r3,r3
|
||||
bpl L_Test2
|
||||
rsbs r2,r2,#0
|
||||
rsc r3,r3,#0
|
||||
L_Test2:
|
||||
bl ASM_PFX(__aeabi_uldivmod)
|
||||
tst r4,#0x40000000
|
||||
beq L_Test3
|
||||
rsbs r0,r0,#0
|
||||
rsc r1,r1,#0
|
||||
L_Test3:
|
||||
tst r4,#0x80000000
|
||||
beq L_Exit
|
||||
rsbs r2,r2,#0
|
||||
rsc r3,r3,#0
|
||||
L_Exit:
|
||||
pop {r4,pc}
|
||||
|
||||
|
||||
|
||||
41
gnu-efi/lib/arm/llsl.S
Normal file
41
gnu-efi/lib/arm/llsl.S
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2013, ARM. All rights reserved.<BR>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#include "edk2asm.h"
|
||||
|
||||
.text
|
||||
.align 2
|
||||
GCC_ASM_EXPORT(__aeabi_llsl)
|
||||
|
||||
#
|
||||
#VOID
|
||||
#EFIAPI
|
||||
#__aeabi_llsl (
|
||||
# IN VOID *Destination,
|
||||
# IN VOID *Source,
|
||||
# IN UINT32 Size
|
||||
# );
|
||||
#
|
||||
ASM_PFX(__aeabi_llsl):
|
||||
subs r3,r2,#0x20
|
||||
bpl 1f
|
||||
rsb r3,r2,#0x20
|
||||
lsl r1,r1,r2
|
||||
orr r1,r1,r0,lsr r3
|
||||
lsl r0,r0,r2
|
||||
bx lr
|
||||
1:
|
||||
lsl r1,r0,r3
|
||||
mov r0,#0
|
||||
bx lr
|
||||
41
gnu-efi/lib/arm/llsr.S
Normal file
41
gnu-efi/lib/arm/llsr.S
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2013, ARM. All rights reserved.<BR>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#include "edk2asm.h"
|
||||
|
||||
.text
|
||||
.align 2
|
||||
GCC_ASM_EXPORT(__aeabi_llsr)
|
||||
|
||||
#
|
||||
#VOID
|
||||
#EFIAPI
|
||||
#__aeabi_llsr (
|
||||
# IN VOID *Destination,
|
||||
# IN VOID *Source,
|
||||
# IN UINT32 Size
|
||||
# );
|
||||
#
|
||||
ASM_PFX(__aeabi_llsr):
|
||||
subs r3,r2,#0x20
|
||||
bpl 1f
|
||||
rsb r3,r2,#0x20
|
||||
lsr r0,r0,r2
|
||||
orr r0,r0,r1,lsl r3
|
||||
lsr r1,r1,r2
|
||||
bx lr
|
||||
1:
|
||||
lsr r0,r1,r3
|
||||
mov r1,#0
|
||||
bx lr
|
||||
67
gnu-efi/lib/arm/math.c
Normal file
67
gnu-efi/lib/arm/math.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copright (C) 2014 Linaro Ltd.
|
||||
* Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice and this list of conditions, without modification.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
UINT64
|
||||
LShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Left shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Operand << Count;
|
||||
}
|
||||
|
||||
UINT64
|
||||
RShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Right shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Operand >> Count;
|
||||
}
|
||||
|
||||
|
||||
UINT64
|
||||
MultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINTN Multiplier
|
||||
)
|
||||
// Multiply 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Multiplicand * Multiplier;
|
||||
}
|
||||
|
||||
UINT64
|
||||
DivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINTN Divisor,
|
||||
OUT UINTN *Remainder OPTIONAL
|
||||
)
|
||||
{
|
||||
/*
|
||||
* GCC turns a division into a multiplication and shift with precalculated
|
||||
* constants if the divisor is constant and the dividend fits into a 32 bit
|
||||
* variable. Otherwise, it will turn this into calls into the 32-bit div
|
||||
* library functions.
|
||||
*/
|
||||
if (Remainder)
|
||||
*Remainder = Dividend % Divisor;
|
||||
return Dividend / Divisor;
|
||||
}
|
||||
33
gnu-efi/lib/arm/mullu.S
Normal file
33
gnu-efi/lib/arm/mullu.S
Normal file
@@ -0,0 +1,33 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#include "edk2asm.h"
|
||||
|
||||
.text
|
||||
GCC_ASM_EXPORT(__aeabi_lmul)
|
||||
#
|
||||
#INT64
|
||||
#EFIAPI
|
||||
#__aeabi_lmul (
|
||||
# IN INT64 Multiplicand
|
||||
# IN INT64 Multiplier
|
||||
# );
|
||||
#
|
||||
ASM_PFX(__aeabi_lmul):
|
||||
stmdb sp!, {lr}
|
||||
mov lr, r0
|
||||
umull r0, ip, r2, lr
|
||||
mla r1, r2, r1, ip
|
||||
mla r1, r3, lr, r1
|
||||
ldmia sp!, {pc}
|
||||
25
gnu-efi/lib/arm/setjmp.S
Normal file
25
gnu-efi/lib/arm/setjmp.S
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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}
|
||||
267
gnu-efi/lib/arm/uldiv.S
Normal file
267
gnu-efi/lib/arm/uldiv.S
Normal file
@@ -0,0 +1,267 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "edk2asm.h"
|
||||
|
||||
.text
|
||||
.align 2
|
||||
GCC_ASM_EXPORT(__aeabi_uldivmod)
|
||||
|
||||
//
|
||||
//UINT64
|
||||
//EFIAPI
|
||||
//__aeabi_uldivmod (
|
||||
// IN UINT64 Dividend
|
||||
// IN UINT64 Divisor
|
||||
// )
|
||||
//
|
||||
ASM_PFX(__aeabi_uldivmod):
|
||||
stmdb sp!, {r4, r5, r6, lr}
|
||||
mov r4, r1
|
||||
mov r5, r0
|
||||
mov r6, #0 // 0x0
|
||||
orrs ip, r3, r2, lsr #31
|
||||
bne ASM_PFX(__aeabi_uldivmod_label1)
|
||||
tst r2, r2
|
||||
beq ASM_PFX(_ll_div0)
|
||||
movs ip, r2, lsr #15
|
||||
addeq r6, r6, #16 // 0x10
|
||||
mov ip, r2, lsl r6
|
||||
movs lr, ip, lsr #23
|
||||
moveq ip, ip, lsl #8
|
||||
addeq r6, r6, #8 // 0x8
|
||||
movs lr, ip, lsr #27
|
||||
moveq ip, ip, lsl #4
|
||||
addeq r6, r6, #4 // 0x4
|
||||
movs lr, ip, lsr #29
|
||||
moveq ip, ip, lsl #2
|
||||
addeq r6, r6, #2 // 0x2
|
||||
movs lr, ip, lsr #30
|
||||
moveq ip, ip, lsl #1
|
||||
addeq r6, r6, #1 // 0x1
|
||||
b ASM_PFX(_ll_udiv_small)
|
||||
ASM_PFX(__aeabi_uldivmod_label1):
|
||||
tst r3, #-2147483648 // 0x80000000
|
||||
bne ASM_PFX(__aeabi_uldivmod_label2)
|
||||
movs ip, r3, lsr #15
|
||||
addeq r6, r6, #16 // 0x10
|
||||
mov ip, r3, lsl r6
|
||||
movs lr, ip, lsr #23
|
||||
moveq ip, ip, lsl #8
|
||||
addeq r6, r6, #8 // 0x8
|
||||
movs lr, ip, lsr #27
|
||||
moveq ip, ip, lsl #4
|
||||
addeq r6, r6, #4 // 0x4
|
||||
movs lr, ip, lsr #29
|
||||
moveq ip, ip, lsl #2
|
||||
addeq r6, r6, #2 // 0x2
|
||||
movs lr, ip, lsr #30
|
||||
addeq r6, r6, #1 // 0x1
|
||||
rsb r3, r6, #32 // 0x20
|
||||
moveq ip, ip, lsl #1
|
||||
orr ip, ip, r2, lsr r3
|
||||
mov lr, r2, lsl r6
|
||||
b ASM_PFX(_ll_udiv_big)
|
||||
ASM_PFX(__aeabi_uldivmod_label2):
|
||||
mov ip, r3
|
||||
mov lr, r2
|
||||
b ASM_PFX(_ll_udiv_ginormous)
|
||||
|
||||
ASM_PFX(_ll_udiv_small):
|
||||
cmp r4, ip, lsl #1
|
||||
mov r3, #0 // 0x0
|
||||
subcs r4, r4, ip, lsl #1
|
||||
addcs r3, r3, #2 // 0x2
|
||||
cmp r4, ip
|
||||
subcs r4, r4, ip
|
||||
adcs r3, r3, #0 // 0x0
|
||||
add r2, r6, #32 // 0x20
|
||||
cmp r2, #32 // 0x20
|
||||
rsb ip, ip, #0 // 0x0
|
||||
bcc ASM_PFX(_ll_udiv_small_label1)
|
||||
orrs r0, r4, r5, lsr #30
|
||||
moveq r4, r5
|
||||
moveq r5, #0 // 0x0
|
||||
subeq r2, r2, #32 // 0x20
|
||||
ASM_PFX(_ll_udiv_small_label1):
|
||||
mov r1, #0 // 0x0
|
||||
cmp r2, #16 // 0x10
|
||||
bcc ASM_PFX(_ll_udiv_small_label2)
|
||||
movs r0, r4, lsr #14
|
||||
moveq r4, r4, lsl #16
|
||||
addeq r1, r1, #16 // 0x10
|
||||
ASM_PFX(_ll_udiv_small_label2):
|
||||
sub lr, r2, r1
|
||||
cmp lr, #8 // 0x8
|
||||
bcc ASM_PFX(_ll_udiv_small_label3)
|
||||
movs r0, r4, lsr #22
|
||||
moveq r4, r4, lsl #8
|
||||
addeq r1, r1, #8 // 0x8
|
||||
ASM_PFX(_ll_udiv_small_label3):
|
||||
rsb r0, r1, #32 // 0x20
|
||||
sub r2, r2, r1
|
||||
orr r4, r4, r5, lsr r0
|
||||
mov r5, r5, lsl r1
|
||||
cmp r2, #1 // 0x1
|
||||
bcc ASM_PFX(_ll_udiv_small_label5)
|
||||
sub r2, r2, #1 // 0x1
|
||||
and r0, r2, #7 // 0x7
|
||||
eor r0, r0, #7 // 0x7
|
||||
adds r0, r0, r0, lsl #1
|
||||
add pc, pc, r0, lsl #2
|
||||
nop // (mov r0,r0)
|
||||
ASM_PFX(_ll_udiv_small_label4):
|
||||
adcs r5, r5, r5
|
||||
adcs r4, ip, r4, lsl #1
|
||||
rsbcc r4, ip, r4
|
||||
adcs r5, r5, r5
|
||||
adcs r4, ip, r4, lsl #1
|
||||
rsbcc r4, ip, r4
|
||||
adcs r5, r5, r5
|
||||
adcs r4, ip, r4, lsl #1
|
||||
rsbcc r4, ip, r4
|
||||
adcs r5, r5, r5
|
||||
adcs r4, ip, r4, lsl #1
|
||||
rsbcc r4, ip, r4
|
||||
adcs r5, r5, r5
|
||||
adcs r4, ip, r4, lsl #1
|
||||
rsbcc r4, ip, r4
|
||||
adcs r5, r5, r5
|
||||
adcs r4, ip, r4, lsl #1
|
||||
rsbcc r4, ip, r4
|
||||
adcs r5, r5, r5
|
||||
adcs r4, ip, r4, lsl #1
|
||||
rsbcc r4, ip, r4
|
||||
adcs r5, r5, r5
|
||||
adcs r4, ip, r4, lsl #1
|
||||
sub r2, r2, #8 // 0x8
|
||||
tst r2, r2
|
||||
rsbcc r4, ip, r4
|
||||
bpl ASM_PFX(_ll_udiv_small_label4)
|
||||
ASM_PFX(_ll_udiv_small_label5):
|
||||
mov r2, r4, lsr r6
|
||||
bic r4, r4, r2, lsl r6
|
||||
adcs r0, r5, r5
|
||||
adc r1, r4, r4
|
||||
add r1, r1, r3, lsl r6
|
||||
mov r3, #0 // 0x0
|
||||
ldmia sp!, {r4, r5, r6, pc}
|
||||
|
||||
ASM_PFX(_ll_udiv_big):
|
||||
subs r0, r5, lr
|
||||
mov r3, #0 // 0x0
|
||||
sbcs r1, r4, ip
|
||||
movcs r5, r0
|
||||
movcs r4, r1
|
||||
adcs r3, r3, #0 // 0x0
|
||||
subs r0, r5, lr
|
||||
sbcs r1, r4, ip
|
||||
movcs r5, r0
|
||||
movcs r4, r1
|
||||
adcs r3, r3, #0 // 0x0
|
||||
subs r0, r5, lr
|
||||
sbcs r1, r4, ip
|
||||
movcs r5, r0
|
||||
movcs r4, r1
|
||||
adcs r3, r3, #0 // 0x0
|
||||
mov r1, #0 // 0x0
|
||||
rsbs lr, lr, #0 // 0x0
|
||||
rsc ip, ip, #0 // 0x0
|
||||
cmp r6, #16 // 0x10
|
||||
bcc ASM_PFX(_ll_udiv_big_label1)
|
||||
movs r0, r4, lsr #14
|
||||
moveq r4, r4, lsl #16
|
||||
addeq r1, r1, #16 // 0x10
|
||||
ASM_PFX(_ll_udiv_big_label1):
|
||||
sub r2, r6, r1
|
||||
cmp r2, #8 // 0x8
|
||||
bcc ASM_PFX(_ll_udiv_big_label2)
|
||||
movs r0, r4, lsr #22
|
||||
moveq r4, r4, lsl #8
|
||||
addeq r1, r1, #8 // 0x8
|
||||
ASM_PFX(_ll_udiv_big_label2):
|
||||
rsb r0, r1, #32 // 0x20
|
||||
sub r2, r6, r1
|
||||
orr r4, r4, r5, lsr r0
|
||||
mov r5, r5, lsl r1
|
||||
cmp r2, #1 // 0x1
|
||||
bcc ASM_PFX(_ll_udiv_big_label4)
|
||||
sub r2, r2, #1 // 0x1
|
||||
and r0, r2, #3 // 0x3
|
||||
rsb r0, r0, #3 // 0x3
|
||||
adds r0, r0, r0, lsl #1
|
||||
add pc, pc, r0, lsl #3
|
||||
nop // (mov r0,r0)
|
||||
ASM_PFX(_ll_udiv_big_label3):
|
||||
adcs r5, r5, r5
|
||||
adcs r4, r4, r4
|
||||
adcs r0, lr, r5
|
||||
adcs r1, ip, r4
|
||||
movcs r5, r0
|
||||
movcs r4, r1
|
||||
adcs r5, r5, r5
|
||||
adcs r4, r4, r4
|
||||
adcs r0, lr, r5
|
||||
adcs r1, ip, r4
|
||||
movcs r5, r0
|
||||
movcs r4, r1
|
||||
adcs r5, r5, r5
|
||||
adcs r4, r4, r4
|
||||
adcs r0, lr, r5
|
||||
adcs r1, ip, r4
|
||||
movcs r5, r0
|
||||
movcs r4, r1
|
||||
sub r2, r2, #4 // 0x4
|
||||
adcs r5, r5, r5
|
||||
adcs r4, r4, r4
|
||||
adcs r0, lr, r5
|
||||
adcs r1, ip, r4
|
||||
tst r2, r2
|
||||
movcs r5, r0
|
||||
movcs r4, r1
|
||||
bpl ASM_PFX(_ll_udiv_big_label3)
|
||||
ASM_PFX(_ll_udiv_big_label4):
|
||||
mov r1, #0 // 0x0
|
||||
mov r2, r5, lsr r6
|
||||
bic r5, r5, r2, lsl r6
|
||||
adcs r0, r5, r5
|
||||
adc r1, r1, #0 // 0x0
|
||||
movs lr, r3, lsl r6
|
||||
mov r3, r4, lsr r6
|
||||
bic r4, r4, r3, lsl r6
|
||||
adc r1, r1, #0 // 0x0
|
||||
adds r0, r0, lr
|
||||
orr r2, r2, r4, ror r6
|
||||
adc r1, r1, #0 // 0x0
|
||||
ldmia sp!, {r4, r5, r6, pc}
|
||||
|
||||
ASM_PFX(_ll_udiv_ginormous):
|
||||
subs r2, r5, lr
|
||||
mov r1, #0 // 0x0
|
||||
sbcs r3, r4, ip
|
||||
adc r0, r1, r1
|
||||
movcc r2, r5
|
||||
movcc r3, r4
|
||||
ldmia sp!, {r4, r5, r6, pc}
|
||||
|
||||
ASM_PFX(_ll_div0):
|
||||
ldmia sp!, {r4, r5, r6, lr}
|
||||
mov r0, #0 // 0x0
|
||||
mov r1, #0 // 0x0
|
||||
b ASM_PFX(__aeabi_ldiv0)
|
||||
|
||||
ASM_PFX(__aeabi_ldiv0):
|
||||
bx r14
|
||||
|
||||
|
||||
173
gnu-efi/lib/boxdraw.c
Normal file
173
gnu-efi/lib/boxdraw.c
Normal file
@@ -0,0 +1,173 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
BoxDraw.c
|
||||
|
||||
Abstract:
|
||||
Lib functions to support Box Draw Unicode code pages.
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
typedef struct {
|
||||
CHAR16 Unicode;
|
||||
CHAR8 PcAnsi;
|
||||
CHAR8 Ascii;
|
||||
} UNICODE_TO_CHAR;
|
||||
|
||||
|
||||
//
|
||||
// This list is used to define the valid extend chars.
|
||||
// It also provides a mapping from Unicode to PCANSI or
|
||||
// ASCII. The ASCII mapping we just made up.
|
||||
//
|
||||
//
|
||||
|
||||
STATIC UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {
|
||||
{ BOXDRAW_HORIZONTAL, 0xc4, L'-'},
|
||||
{ BOXDRAW_VERTICAL, 0xb3, L'|'},
|
||||
{ BOXDRAW_DOWN_RIGHT, 0xda, L'/'},
|
||||
{ BOXDRAW_DOWN_LEFT, 0xbf, L'\\'},
|
||||
{ BOXDRAW_UP_RIGHT, 0xc0, L'\\'},
|
||||
{ BOXDRAW_UP_LEFT, 0xd9, L'/'},
|
||||
{ BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|'},
|
||||
{ BOXDRAW_VERTICAL_LEFT, 0xb4, L'|'},
|
||||
{ BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+'},
|
||||
{ BOXDRAW_UP_HORIZONTAL, 0xc1, L'+'},
|
||||
{ BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+'},
|
||||
{ BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-'},
|
||||
{ BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|'},
|
||||
{ BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/'},
|
||||
{ BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/'},
|
||||
{ BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/'},
|
||||
{ BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\'},
|
||||
{ BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\'},
|
||||
{ BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\'},
|
||||
{ BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\'},
|
||||
{ BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\'},
|
||||
{ BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\'},
|
||||
{ BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/'},
|
||||
{ BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/'},
|
||||
{ BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/'},
|
||||
{ BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|'},
|
||||
{ BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|'},
|
||||
{ BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|'},
|
||||
{ BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|'},
|
||||
{ BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|'},
|
||||
{ BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|'},
|
||||
{ BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+'},
|
||||
{ BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+'},
|
||||
{ BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+'},
|
||||
{ BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+'},
|
||||
{ BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+'},
|
||||
{ BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+'},
|
||||
{ BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+'},
|
||||
{ BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+'},
|
||||
{ BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+'},
|
||||
|
||||
{ BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*'},
|
||||
{ BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+'},
|
||||
|
||||
{ GEOMETRICSHAPE_UP_TRIANGLE, 0x1e, L'^'},
|
||||
{ GEOMETRICSHAPE_RIGHT_TRIANGLE, 0x10, L'>'},
|
||||
{ GEOMETRICSHAPE_DOWN_TRIANGLE, 0x1f, L'v'},
|
||||
{ GEOMETRICSHAPE_LEFT_TRIANGLE, 0x11, L'<'},
|
||||
|
||||
/* BugBug: Left Arrow is an ESC. We can not make it print
|
||||
on a PCANSI terminal. If we can make left arrow
|
||||
come out on PC ANSI we can add it back.
|
||||
|
||||
{ ARROW_LEFT, 0x1b, L'<'},
|
||||
*/
|
||||
|
||||
{ ARROW_UP, 0x18, L'^'},
|
||||
|
||||
/* BugBut: Took out left arrow so right has to go too.
|
||||
{ ARROW_RIGHT, 0x1a, L'>'},
|
||||
*/
|
||||
{ ARROW_DOWN, 0x19, L'v'},
|
||||
|
||||
{ 0x0000, 0x00, L'\0' }
|
||||
};
|
||||
|
||||
|
||||
BOOLEAN
|
||||
LibIsValidTextGraphics (
|
||||
IN CHAR16 Graphic,
|
||||
OUT CHAR8 *PcAnsi, OPTIONAL
|
||||
OUT CHAR8 *Ascii OPTIONAL
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Detects if a Unicode char is for Box Drawing text graphics.
|
||||
|
||||
Arguments:
|
||||
|
||||
Grphic - Unicode char to test.
|
||||
|
||||
PcAnsi - Optional pointer to return PCANSI equivalent of Graphic.
|
||||
|
||||
Asci - Optional pointer to return Ascii equivalent of Graphic.
|
||||
|
||||
Returns:
|
||||
|
||||
TRUE if Gpaphic is a supported Unicode Box Drawing character.
|
||||
|
||||
--*/{
|
||||
UNICODE_TO_CHAR *Table;
|
||||
|
||||
if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {
|
||||
|
||||
//
|
||||
// Unicode drawing code charts are all in the 0x25xx range,
|
||||
// arrows are 0x21xx
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {
|
||||
if (Graphic == Table->Unicode) {
|
||||
if (PcAnsi) {
|
||||
*PcAnsi = Table->PcAnsi;
|
||||
}
|
||||
if (Ascii) {
|
||||
*Ascii = Table->Ascii;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
IsValidAscii (
|
||||
IN CHAR16 Ascii
|
||||
)
|
||||
{
|
||||
if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
IsValidEfiCntlChar (
|
||||
IN CHAR16 c
|
||||
)
|
||||
{
|
||||
if (c == CHAR_NULL || c == CHAR_BACKSPACE || c == CHAR_LINEFEED || c == CHAR_CARRIAGE_RETURN) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
121
gnu-efi/lib/cmdline.c
Normal file
121
gnu-efi/lib/cmdline.c
Normal file
@@ -0,0 +1,121 @@
|
||||
#include "lib.h"
|
||||
|
||||
#include "efiprot.h"
|
||||
#include "efishellintf.h"
|
||||
#include "efishellparm.h"
|
||||
|
||||
#ifndef MAX_ARGV_CONTENTS_SIZE
|
||||
# define MAX_CMDLINE_SIZE 1024
|
||||
#endif
|
||||
#ifndef MAX_ARGC
|
||||
# define MAX_CMDLINE_ARGC 32
|
||||
#endif
|
||||
|
||||
/*
|
||||
Parse LoadedImage options area, called only in case the regular
|
||||
shell protos are not available.
|
||||
|
||||
Format of LoadedImage->LoadOptions appears to be a
|
||||
single-space-separated list of args (looks like the shell already
|
||||
pre-parses the input, it apparently folds several consecutive spaces
|
||||
into one):
|
||||
argv[0] space argv[1] (etc.) argv[N] space \0 cwd \0 other data
|
||||
For safety, we support the trailing \0 without a space before, as
|
||||
well as several consecutive spaces (-> several args).
|
||||
*/
|
||||
static
|
||||
INTN
|
||||
GetShellArgcArgvFromLoadedImage(
|
||||
EFI_HANDLE ImageHandle,
|
||||
CHAR16 **ResultArgv[]
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
void *LoadedImage = NULL;
|
||||
static CHAR16 ArgvContents[MAX_CMDLINE_SIZE];
|
||||
static CHAR16 *Argv[MAX_CMDLINE_ARGC], *ArgStart, *c;
|
||||
UINTN Argc = 0, BufLen;
|
||||
|
||||
Status = uefi_call_wrapper(BS->OpenProtocol, 6,
|
||||
ImageHandle,
|
||||
&LoadedImageProtocol,
|
||||
&LoadedImage,
|
||||
ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR(Status))
|
||||
return -1;
|
||||
|
||||
BufLen = ((EFI_LOADED_IMAGE *)LoadedImage)->LoadOptionsSize;
|
||||
if (BufLen < 2) /* We are expecting at least a \0 */
|
||||
return -1;
|
||||
else if (BufLen > sizeof(ArgvContents))
|
||||
BufLen = sizeof(ArgvContents);
|
||||
|
||||
CopyMem(ArgvContents, ((EFI_LOADED_IMAGE *)LoadedImage)->LoadOptions, BufLen);
|
||||
ArgvContents[MAX_CMDLINE_SIZE - 1] = L'\0';
|
||||
|
||||
for (c = ArgStart = ArgvContents ; *c != L'\0' ; ++c) {
|
||||
if (*c == L' ') {
|
||||
*c = L'\0';
|
||||
if (Argc < MAX_CMDLINE_ARGC) Argv[Argc++] = ArgStart;
|
||||
ArgStart = c + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*ArgStart != L'\0') && (Argc < MAX_CMDLINE_ARGC))
|
||||
Argv[Argc++] = ArgStart;
|
||||
|
||||
// Print(L"Got argc/argv from loaded image proto\n");
|
||||
*ResultArgv = Argv;
|
||||
return Argc;
|
||||
}
|
||||
|
||||
INTN GetShellArgcArgv(EFI_HANDLE ImageHandle, CHAR16 **Argv[])
|
||||
{
|
||||
// Code inspired from EDK2's
|
||||
// ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c (BSD)
|
||||
EFI_STATUS Status;
|
||||
static const EFI_GUID EfiShellParametersProtocolGuid
|
||||
= EFI_SHELL_PARAMETERS_PROTOCOL_GUID;
|
||||
static const EFI_GUID ShellInterfaceProtocolGuid
|
||||
= SHELL_INTERFACE_PROTOCOL_GUID;
|
||||
EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol = NULL;
|
||||
EFI_SHELL_INTERFACE *EfiShellInterfaceProtocol = NULL;
|
||||
|
||||
Status = uefi_call_wrapper(BS->OpenProtocol, 6,
|
||||
ImageHandle,
|
||||
(EFI_GUID*)&EfiShellParametersProtocolGuid,
|
||||
(VOID **)&EfiShellParametersProtocol,
|
||||
ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
// use shell 2.0 interface
|
||||
// Print(L"Got argc/argv from shell intf proto\n");
|
||||
*Argv = EfiShellParametersProtocol->Argv;
|
||||
return EfiShellParametersProtocol->Argc;
|
||||
}
|
||||
|
||||
// try to get shell 1.0 interface instead.
|
||||
Status = uefi_call_wrapper(BS->OpenProtocol, 6,
|
||||
ImageHandle,
|
||||
(EFI_GUID*)&ShellInterfaceProtocolGuid,
|
||||
(VOID **)&EfiShellInterfaceProtocol,
|
||||
ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
// Print(L"Got argc/argv from shell params proto\n");
|
||||
*Argv = EfiShellInterfaceProtocol->Argv;
|
||||
return EfiShellInterfaceProtocol->Argc;
|
||||
}
|
||||
|
||||
// shell 1.0 and 2.0 interfaces failed
|
||||
return GetShellArgcArgvFromLoadedImage(ImageHandle, Argv);
|
||||
}
|
||||
104
gnu-efi/lib/console.c
Normal file
104
gnu-efi/lib/console.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
console.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
Output (
|
||||
IN CHAR16 *Str
|
||||
)
|
||||
// Write a string to the console at the current cursor location
|
||||
{
|
||||
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, Str);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
Input (
|
||||
IN CHAR16 *Prompt OPTIONAL,
|
||||
OUT CHAR16 *InStr,
|
||||
IN UINTN StrLen
|
||||
)
|
||||
// Input a string at the current cursor location, for StrLen
|
||||
{
|
||||
IInput (
|
||||
ST->ConOut,
|
||||
ST->ConIn,
|
||||
Prompt,
|
||||
InStr,
|
||||
StrLen
|
||||
);
|
||||
}
|
||||
|
||||
VOID
|
||||
IInput (
|
||||
IN SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut,
|
||||
IN SIMPLE_INPUT_INTERFACE *ConIn,
|
||||
IN CHAR16 *Prompt OPTIONAL,
|
||||
OUT CHAR16 *InStr,
|
||||
IN UINTN StrLen
|
||||
)
|
||||
// Input a string at the current cursor location, for StrLen
|
||||
{
|
||||
EFI_INPUT_KEY Key;
|
||||
EFI_STATUS Status;
|
||||
UINTN Len;
|
||||
|
||||
if (Prompt) {
|
||||
ConOut->OutputString (ConOut, Prompt);
|
||||
}
|
||||
|
||||
Len = 0;
|
||||
for (; ;) {
|
||||
WaitForSingleEvent (ConIn->WaitForKey, 0);
|
||||
|
||||
Status = uefi_call_wrapper(ConIn->ReadKeyStroke, 2, ConIn, &Key);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((D_ERROR, "Input: error return from ReadKey %x\n", Status));
|
||||
break;
|
||||
}
|
||||
|
||||
if (Key.UnicodeChar == '\n' ||
|
||||
Key.UnicodeChar == '\r') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Key.UnicodeChar == '\b') {
|
||||
if (Len) {
|
||||
uefi_call_wrapper(ConOut->OutputString, 2, ConOut, L"\b \b");
|
||||
Len -= 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Key.UnicodeChar >= ' ') {
|
||||
if (Len < StrLen-1) {
|
||||
InStr[Len] = Key.UnicodeChar;
|
||||
|
||||
InStr[Len+1] = 0;
|
||||
uefi_call_wrapper(ConOut->OutputString, 2, ConOut, &InStr[Len]);
|
||||
|
||||
Len += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
InStr[Len] = 0;
|
||||
}
|
||||
218
gnu-efi/lib/crc.c
Normal file
218
gnu-efi/lib/crc.c
Normal file
@@ -0,0 +1,218 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
crc.c
|
||||
|
||||
Abstract:
|
||||
|
||||
CRC32 functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
UINT32 CRCTable[256] = {
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
|
||||
0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
|
||||
0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
|
||||
0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
||||
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
|
||||
0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
|
||||
0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106,
|
||||
0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
|
||||
0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
||||
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
|
||||
0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
|
||||
0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
||||
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA,
|
||||
0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
|
||||
0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
||||
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84,
|
||||
0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
|
||||
0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
||||
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E,
|
||||
0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
|
||||
0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28,
|
||||
0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
|
||||
0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
||||
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
|
||||
0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
|
||||
0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
||||
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
|
||||
0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
|
||||
0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
};
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
SetCrc (
|
||||
IN OUT EFI_TABLE_HEADER *Hdr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Updates the CRC32 value in the table header
|
||||
|
||||
Arguments:
|
||||
|
||||
Hdr - The table to update
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
SetCrcAltSize (Hdr->HeaderSize, Hdr);
|
||||
}
|
||||
|
||||
VOID
|
||||
SetCrcAltSize (
|
||||
IN UINTN Size,
|
||||
IN OUT EFI_TABLE_HEADER *Hdr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Updates the CRC32 value in the table header
|
||||
|
||||
Arguments:
|
||||
|
||||
Hdr - The table to update
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
Hdr->CRC32 = 0;
|
||||
Hdr->CRC32 = CalculateCrc((UINT8 *)Hdr, Size);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
CheckCrc (
|
||||
IN UINTN MaxSize,
|
||||
IN OUT EFI_TABLE_HEADER *Hdr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Checks the CRC32 value in the table header
|
||||
|
||||
Arguments:
|
||||
|
||||
Hdr - The table to check
|
||||
|
||||
Returns:
|
||||
|
||||
TRUE if the CRC is OK in the table
|
||||
|
||||
--*/
|
||||
{
|
||||
return CheckCrcAltSize (MaxSize, Hdr->HeaderSize, Hdr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOLEAN
|
||||
CheckCrcAltSize (
|
||||
IN UINTN MaxSize,
|
||||
IN UINTN Size,
|
||||
IN OUT EFI_TABLE_HEADER *Hdr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Checks the CRC32 value in the table header
|
||||
|
||||
Arguments:
|
||||
|
||||
Hdr - The table to check
|
||||
|
||||
Returns:
|
||||
|
||||
TRUE if the CRC is OK in the table
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT32 Crc;
|
||||
UINT32 OrgCrc;
|
||||
BOOLEAN f;
|
||||
|
||||
if (Size == 0) {
|
||||
//
|
||||
// If header size is 0 CRC will pass so return FALSE here
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
if (MaxSize && Size > MaxSize) {
|
||||
DEBUG((D_ERROR, "CheckCrc32: Size > MaxSize\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// clear old crc from header
|
||||
OrgCrc = Hdr->CRC32;
|
||||
Hdr->CRC32 = 0;
|
||||
Crc = CalculateCrc((UINT8 *)Hdr, Size);
|
||||
|
||||
// set restults
|
||||
Hdr->CRC32 = OrgCrc;
|
||||
|
||||
// return status
|
||||
f = OrgCrc == (UINT32) Crc;
|
||||
if (!f) {
|
||||
DEBUG((D_ERROR, "CheckCrc32: Crc check failed\n"));
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
UINT32
|
||||
CalculateCrc (
|
||||
UINT8 *pt,
|
||||
UINTN Size
|
||||
)
|
||||
{
|
||||
UINTN Crc;
|
||||
|
||||
// compute crc
|
||||
Crc = 0xffffffff;
|
||||
while (Size) {
|
||||
Crc = (Crc >> 8) ^ CRCTable[(UINT8) Crc ^ *pt];
|
||||
pt += 1;
|
||||
Size -= 1;
|
||||
}
|
||||
Crc = Crc ^ 0xffffffff;
|
||||
return (UINT32)Crc;
|
||||
}
|
||||
204
gnu-efi/lib/data.c
Normal file
204
gnu-efi/lib/data.c
Normal file
@@ -0,0 +1,204 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
data.c
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI library global data
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
//
|
||||
// LibInitialized - TRUE once InitializeLib() is called for the first time
|
||||
//
|
||||
|
||||
BOOLEAN LibInitialized = FALSE;
|
||||
|
||||
//
|
||||
// ImageHandle - Current ImageHandle, as passed to InitializeLib
|
||||
//
|
||||
EFI_HANDLE LibImageHandle;
|
||||
|
||||
//
|
||||
// ST - pointer to the EFI system table
|
||||
//
|
||||
|
||||
EFI_SYSTEM_TABLE *ST;
|
||||
|
||||
//
|
||||
// BS - pointer to the boot services table
|
||||
//
|
||||
|
||||
EFI_BOOT_SERVICES *BS;
|
||||
|
||||
|
||||
//
|
||||
// Default pool allocation type
|
||||
//
|
||||
|
||||
EFI_MEMORY_TYPE PoolAllocationType = EfiBootServicesData;
|
||||
|
||||
//
|
||||
// Unicode collation functions that are in use
|
||||
//
|
||||
|
||||
EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface = {
|
||||
LibStubStriCmp,
|
||||
LibStubMetaiMatch,
|
||||
LibStubStrLwrUpr,
|
||||
LibStubStrLwrUpr,
|
||||
NULL, // FatToStr
|
||||
NULL, // StrToFat
|
||||
NULL // SupportedLanguages
|
||||
};
|
||||
|
||||
EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface = &LibStubUnicodeInterface;
|
||||
|
||||
//
|
||||
// Root device path
|
||||
//
|
||||
|
||||
EFI_DEVICE_PATH RootDevicePath[] = {
|
||||
{END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH,0}}
|
||||
};
|
||||
|
||||
EFI_DEVICE_PATH EndDevicePath[] = {
|
||||
{END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH, 0}}
|
||||
};
|
||||
|
||||
EFI_DEVICE_PATH EndInstanceDevicePath[] = {
|
||||
{END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH, 0}}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// EFI IDs
|
||||
//
|
||||
|
||||
EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE;
|
||||
EFI_GUID NullGuid = { 0,0,0,{0,0,0,0,0,0,0,0} };
|
||||
|
||||
//
|
||||
// Protocol IDs
|
||||
//
|
||||
|
||||
EFI_GUID gEfiDevicePathProtocolGuid = EFI_DEVICE_PATH_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDevicePathToTextProtocolGuid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDevicePathFromTextProtocolGuid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiLoadedImageProtocolGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSimpleTextInProtocolGuid = EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSimpleTextOutProtocolGuid = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiBlockIo2ProtocolGuid = EFI_BLOCK_IO2_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDiskIoProtocolGuid = EFI_DISK_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDiskIo2ProtocolGuid = EFI_DISK_IO2_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSimpleFileSystemProtocolGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiLoadFileProtocolGuid = EFI_LOAD_FILE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDeviceIoProtocolGuid = EFI_DEVICE_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiUnicodeCollationProtocolGuid = EFI_UNICODE_COLLATION_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSerialIoProtocolGuid = EFI_SERIAL_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiSimpleNetworkProtocolGuid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPxeBaseCodeProtocolGuid = EFI_PXE_BASE_CODE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid = EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID;
|
||||
EFI_GUID gEFiUiInterfaceProtocolGuid = EFI_UI_INTERFACE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPciIoProtocolGuid = EFI_PCI_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPciRootBridgeIoProtocolGuid = EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDriverBindingProtocolGuid = EFI_DRIVER_BINDING_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiComponentNameProtocolGuid = EFI_COMPONENT_NAME_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiComponentName2ProtocolGuid = EFI_COMPONENT_NAME2_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiHashProtocolGuid = EFI_HASH_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiPlatformDriverOverrideProtocolGuid = EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid = EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiDriverFamilyOverrideProtocolGuid = EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiEbcProtocolGuid = EFI_EBC_PROTOCOL_GUID;
|
||||
|
||||
//
|
||||
// File system information IDs
|
||||
//
|
||||
|
||||
EFI_GUID gEfiFileInfoGuid = EFI_FILE_INFO_ID;
|
||||
EFI_GUID gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID;
|
||||
EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID;
|
||||
|
||||
//
|
||||
// Reference implementation public protocol IDs
|
||||
//
|
||||
|
||||
EFI_GUID InternalShellProtocol = INTERNAL_SHELL_GUID;
|
||||
EFI_GUID VariableStoreProtocol = VARIABLE_STORE_PROTOCOL;
|
||||
EFI_GUID LegacyBootProtocol = LEGACY_BOOT_PROTOCOL;
|
||||
EFI_GUID VgaClassProtocol = VGA_CLASS_DRIVER_PROTOCOL;
|
||||
|
||||
EFI_GUID TextOutSpliterProtocol = TEXT_OUT_SPLITER_PROTOCOL;
|
||||
EFI_GUID ErrorOutSpliterProtocol = ERROR_OUT_SPLITER_PROTOCOL;
|
||||
EFI_GUID TextInSpliterProtocol = TEXT_IN_SPLITER_PROTOCOL;
|
||||
/* Added for GOP support */
|
||||
EFI_GUID gEfiGraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiEdidDiscoveredProtocolGuid = EFI_EDID_DISCOVERED_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiEdidActiveProtocolGuid = EFI_EDID_ACTIVE_PROTOCOL_GUID;
|
||||
EFI_GUID gEfiEdidOverrideProtocolGuid = EFI_EDID_OVERRIDE_PROTOCOL_GUID;
|
||||
|
||||
EFI_GUID AdapterDebugProtocol = ADAPTER_DEBUG_PROTOCOL;
|
||||
|
||||
//
|
||||
// Device path media protocol IDs
|
||||
//
|
||||
EFI_GUID gEfiPcAnsiGuid = EFI_PC_ANSI_GUID;
|
||||
EFI_GUID gEfiVT100Guid = EFI_VT_100_GUID;
|
||||
EFI_GUID gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID;
|
||||
EFI_GUID gEfiVTUTF8Guid = EFI_VT_UTF8_GUID;
|
||||
|
||||
//
|
||||
// EFI GPT Partition Type GUIDs
|
||||
//
|
||||
EFI_GUID EfiPartTypeSystemPartitionGuid = EFI_PART_TYPE_EFI_SYSTEM_PART_GUID;
|
||||
EFI_GUID EfiPartTypeLegacyMbrGuid = EFI_PART_TYPE_LEGACY_MBR_GUID;
|
||||
|
||||
|
||||
//
|
||||
// Reference implementation Vendor Device Path Guids
|
||||
//
|
||||
EFI_GUID UnknownDevice = UNKNOWN_DEVICE_GUID;
|
||||
|
||||
//
|
||||
// Configuration Table GUIDs
|
||||
//
|
||||
|
||||
EFI_GUID MpsTableGuid = MPS_TABLE_GUID;
|
||||
EFI_GUID AcpiTableGuid = ACPI_TABLE_GUID;
|
||||
EFI_GUID SMBIOSTableGuid = SMBIOS_TABLE_GUID;
|
||||
EFI_GUID SMBIOS3TableGuid = SMBIOS3_TABLE_GUID;
|
||||
EFI_GUID SalSystemTableGuid = SAL_SYSTEM_TABLE_GUID;
|
||||
|
||||
//
|
||||
// Network protocol GUIDs
|
||||
//
|
||||
EFI_GUID Ip4ServiceBindingProtocol = EFI_IP4_SERVICE_BINDING_PROTOCOL;
|
||||
EFI_GUID Ip4Protocol = EFI_IP4_PROTOCOL;
|
||||
EFI_GUID Udp4ServiceBindingProtocol = EFI_UDP4_SERVICE_BINDING_PROTOCOL;
|
||||
EFI_GUID Udp4Protocol = EFI_UDP4_PROTOCOL;
|
||||
EFI_GUID Tcp4ServiceBindingProtocol = EFI_TCP4_SERVICE_BINDING_PROTOCOL;
|
||||
EFI_GUID Tcp4Protocol = EFI_TCP4_PROTOCOL;
|
||||
|
||||
//
|
||||
// Pointer protocol GUIDs
|
||||
//
|
||||
EFI_GUID SimplePointerProtocol = EFI_SIMPLE_POINTER_PROTOCOL_GUID;
|
||||
EFI_GUID AbsolutePointerProtocol = EFI_ABSOLUTE_POINTER_PROTOCOL_GUID;
|
||||
|
||||
//
|
||||
// Debugger protocol GUIDs
|
||||
//
|
||||
EFI_GUID gEfiDebugImageInfoTableGuid = EFI_DEBUG_IMAGE_INFO_TABLE_GUID;
|
||||
EFI_GUID gEfiDebugSupportProtocolGuid = EFI_DEBUG_SUPPORT_PROTOCOL_GUID;
|
||||
43
gnu-efi/lib/debug.c
Normal file
43
gnu-efi/lib/debug.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
debug.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Debug library functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
INTN
|
||||
DbgAssert (
|
||||
IN CONST CHAR8 *FileName,
|
||||
IN INTN LineNo,
|
||||
IN CONST CHAR8 *Description
|
||||
)
|
||||
{
|
||||
DbgPrint (D_ERROR, (CHAR8 *)"%EASSERT FAILED: %a(%d): %a%N\n", FileName, LineNo, Description);
|
||||
|
||||
BREAKPOINT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
1262
gnu-efi/lib/dpath.c
Normal file
1262
gnu-efi/lib/dpath.c
Normal file
File diff suppressed because it is too large
Load Diff
83
gnu-efi/lib/error.c
Normal file
83
gnu-efi/lib/error.c
Normal file
@@ -0,0 +1,83 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
error.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
struct {
|
||||
EFI_STATUS Code;
|
||||
WCHAR *Desc;
|
||||
} ErrorCodeTable[] = {
|
||||
{ EFI_SUCCESS, L"Success"},
|
||||
{ EFI_LOAD_ERROR, L"Load Error"},
|
||||
{ EFI_INVALID_PARAMETER, L"Invalid Parameter"},
|
||||
{ EFI_UNSUPPORTED, L"Unsupported"},
|
||||
{ EFI_BAD_BUFFER_SIZE, L"Bad Buffer Size"},
|
||||
{ EFI_BUFFER_TOO_SMALL, L"Buffer Too Small"},
|
||||
{ EFI_NOT_READY, L"Not Ready"},
|
||||
{ EFI_DEVICE_ERROR, L"Device Error"},
|
||||
{ EFI_WRITE_PROTECTED, L"Write Protected"},
|
||||
{ EFI_OUT_OF_RESOURCES, L"Out of Resources"},
|
||||
{ EFI_VOLUME_CORRUPTED, L"Volume Corrupt"},
|
||||
{ EFI_VOLUME_FULL, L"Volume Full"},
|
||||
{ EFI_NO_MEDIA, L"No Media"},
|
||||
{ EFI_MEDIA_CHANGED, L"Media changed"},
|
||||
{ EFI_NOT_FOUND, L"Not Found"},
|
||||
{ EFI_ACCESS_DENIED, L"Access Denied"},
|
||||
{ EFI_NO_RESPONSE, L"No Response"},
|
||||
{ EFI_NO_MAPPING, L"No mapping"},
|
||||
{ EFI_TIMEOUT, L"Time out"},
|
||||
{ EFI_NOT_STARTED, L"Not started"},
|
||||
{ EFI_ALREADY_STARTED, L"Already started"},
|
||||
{ EFI_ABORTED, L"Aborted"},
|
||||
{ EFI_ICMP_ERROR, L"ICMP Error"},
|
||||
{ EFI_TFTP_ERROR, L"TFTP Error"},
|
||||
{ EFI_PROTOCOL_ERROR, L"Protocol Error"},
|
||||
{ EFI_INCOMPATIBLE_VERSION, L"Incompatible Version"},
|
||||
{ EFI_SECURITY_VIOLATION, L"Security Policy Violation"},
|
||||
{ EFI_CRC_ERROR, L"CRC Error"},
|
||||
{ EFI_END_OF_MEDIA, L"End of Media"},
|
||||
{ EFI_END_OF_FILE, L"End of File"},
|
||||
{ EFI_INVALID_LANGUAGE, L"Invalid Languages"},
|
||||
{ EFI_COMPROMISED_DATA, L"Compromised Data"},
|
||||
|
||||
// warnings
|
||||
{ EFI_WARN_UNKNOWN_GLYPH, L"Warning Unknown Glyph"},
|
||||
{ EFI_WARN_DELETE_FAILURE, L"Warning Delete Failure"},
|
||||
{ EFI_WARN_WRITE_FAILURE, L"Warning Write Failure"},
|
||||
{ EFI_WARN_BUFFER_TOO_SMALL, L"Warning Buffer Too Small"},
|
||||
{ 0, NULL}
|
||||
} ;
|
||||
|
||||
|
||||
VOID
|
||||
StatusToString (
|
||||
OUT CHAR16 *Buffer,
|
||||
IN EFI_STATUS Status
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; ErrorCodeTable[Index].Desc; Index +=1) {
|
||||
if (ErrorCodeTable[Index].Code == Status) {
|
||||
StrCpy (Buffer, ErrorCodeTable[Index].Desc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SPrint (Buffer, 0, L"%X", Status);
|
||||
}
|
||||
154
gnu-efi/lib/event.c
Normal file
154
gnu-efi/lib/event.c
Normal file
@@ -0,0 +1,154 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
event.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
EFI_EVENT
|
||||
LibCreateProtocolNotifyEvent (
|
||||
IN EFI_GUID *ProtocolGuid,
|
||||
IN EFI_TPL NotifyTpl,
|
||||
IN EFI_EVENT_NOTIFY NotifyFunction,
|
||||
IN VOID *NotifyContext,
|
||||
OUT VOID *Registration
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT Event;
|
||||
|
||||
//
|
||||
// Create the event
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->CreateEvent,
|
||||
5,
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
NotifyTpl,
|
||||
NotifyFunction,
|
||||
NotifyContext,
|
||||
&Event
|
||||
);
|
||||
if ( EFI_ERROR( Status ) ) return NULL ;
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
|
||||
//
|
||||
// Register for protocol notifactions on this event
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->RegisterProtocolNotify,
|
||||
3,
|
||||
ProtocolGuid,
|
||||
Event,
|
||||
Registration
|
||||
);
|
||||
if ( EFI_ERROR( Status ) ) return NULL ;
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
|
||||
//
|
||||
// Kick the event so we will perform an initial pass of
|
||||
// current installed drivers
|
||||
//
|
||||
|
||||
uefi_call_wrapper(BS->SignalEvent, 1, Event);
|
||||
return Event;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
WaitForSingleEvent (
|
||||
IN EFI_EVENT Event,
|
||||
IN UINT64 Timeout OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
EFI_EVENT TimerEvent;
|
||||
EFI_EVENT WaitList[2];
|
||||
|
||||
if (Timeout) {
|
||||
//
|
||||
// Create a timer event
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->CreateEvent, 5, EVT_TIMER, 0, NULL, NULL, &TimerEvent);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
|
||||
//
|
||||
// Set the timer event
|
||||
//
|
||||
|
||||
uefi_call_wrapper(BS->SetTimer, 3, TimerEvent, TimerRelative, Timeout);
|
||||
|
||||
//
|
||||
// Wait for the original event or the timer
|
||||
//
|
||||
|
||||
WaitList[0] = Event;
|
||||
WaitList[1] = TimerEvent;
|
||||
Status = uefi_call_wrapper(BS->WaitForEvent, 3, 2, WaitList, &Index);
|
||||
uefi_call_wrapper(BS->CloseEvent, 1, TimerEvent);
|
||||
|
||||
//
|
||||
// If the timer expired, change the return to timed out
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status) && Index == 1) {
|
||||
Status = EFI_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
//
|
||||
// No timeout... just wait on the event
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->WaitForEvent, 3, 1, &Event, &Index);
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
ASSERT (Index == 0);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID
|
||||
WaitForEventWithTimeout (
|
||||
IN EFI_EVENT Event,
|
||||
IN UINTN Timeout,
|
||||
IN UINTN Row,
|
||||
IN UINTN Column,
|
||||
IN CHAR16 *String,
|
||||
IN EFI_INPUT_KEY TimeoutKey,
|
||||
OUT EFI_INPUT_KEY *Key
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
do {
|
||||
PrintAt (Column, Row, String, Timeout);
|
||||
Status = WaitForSingleEvent (Event, 10000000);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
if (!EFI_ERROR(uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, Key))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} while (Timeout > 0);
|
||||
CopyMem(Key, &TimeoutKey, sizeof(EFI_INPUT_KEY));
|
||||
}
|
||||
|
||||
19
gnu-efi/lib/exit.c
Normal file
19
gnu-efi/lib/exit.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
Exit(
|
||||
IN EFI_STATUS ExitStatus,
|
||||
IN UINTN ExitDataSize,
|
||||
IN CHAR16 *ExitData OPTIONAL
|
||||
)
|
||||
{
|
||||
uefi_call_wrapper(BS->Exit,
|
||||
4,
|
||||
LibImageHandle,
|
||||
ExitStatus,
|
||||
ExitDataSize,
|
||||
ExitData);
|
||||
|
||||
// Uh oh, Exit() returned?!
|
||||
for (;;) { }
|
||||
}
|
||||
179
gnu-efi/lib/guid.c
Normal file
179
gnu-efi/lib/guid.c
Normal file
@@ -0,0 +1,179 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
misc.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Misc EFI support functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
// Additional Known guids
|
||||
//
|
||||
|
||||
#define SHELL_INTERFACE_PROTOCOL \
|
||||
{ 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define ENVIRONMENT_VARIABLE_ID \
|
||||
{ 0x47c7b224, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define DEVICE_PATH_MAPPING_ID \
|
||||
{ 0x47c7b225, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define PROTOCOL_ID_ID \
|
||||
{ 0x47c7b226, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
#define ALIAS_ID \
|
||||
{ 0x47c7b227, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
|
||||
|
||||
static EFI_GUID ShellInterfaceProtocol = SHELL_INTERFACE_PROTOCOL;
|
||||
static EFI_GUID SEnvId = ENVIRONMENT_VARIABLE_ID;
|
||||
static EFI_GUID SMapId = DEVICE_PATH_MAPPING_ID;
|
||||
static EFI_GUID SProtId = PROTOCOL_ID_ID;
|
||||
static EFI_GUID SAliasId = ALIAS_ID;
|
||||
|
||||
static struct {
|
||||
EFI_GUID *Guid;
|
||||
WCHAR *GuidName;
|
||||
} KnownGuids[] = {
|
||||
{ &NullGuid, L"G0" },
|
||||
{ &gEfiGlobalVariableGuid, L"EfiVar" },
|
||||
|
||||
{ &VariableStoreProtocol, L"VarStore" },
|
||||
{ &gEfiDevicePathProtocolGuid, L"DevPath" },
|
||||
{ &gEfiLoadedImageProtocolGuid, L"LdImg" },
|
||||
{ &gEfiSimpleTextInProtocolGuid, L"TxtIn" },
|
||||
{ &gEfiSimpleTextOutProtocolGuid, L"TxtOut" },
|
||||
{ &gEfiBlockIoProtocolGuid, L"BlkIo" },
|
||||
{ &gEfiBlockIo2ProtocolGuid, L"BlkIo2" },
|
||||
{ &gEfiDiskIoProtocolGuid, L"DskIo" },
|
||||
{ &gEfiDiskIo2ProtocolGuid, L"DskIo2" },
|
||||
{ &gEfiSimpleFileSystemProtocolGuid, L"Fs" },
|
||||
{ &gEfiLoadFileProtocolGuid, L"LdFile" },
|
||||
{ &gEfiDeviceIoProtocolGuid, L"DevIo" },
|
||||
{ &gEfiComponentNameProtocolGuid, L"CName" },
|
||||
{ &gEfiComponentName2ProtocolGuid, L"CName2" },
|
||||
|
||||
{ &gEfiFileInfoGuid, L"FileInfo" },
|
||||
{ &gEfiFileSystemInfoGuid, L"FsInfo" },
|
||||
{ &gEfiFileSystemVolumeLabelInfoIdGuid, L"FsVolInfo" },
|
||||
|
||||
{ &gEfiUnicodeCollationProtocolGuid, L"Unicode" },
|
||||
{ &LegacyBootProtocol, L"LegacyBoot" },
|
||||
{ &gEfiSerialIoProtocolGuid, L"SerIo" },
|
||||
{ &VgaClassProtocol, L"VgaClass"},
|
||||
{ &gEfiSimpleNetworkProtocolGuid, L"Net" },
|
||||
{ &gEfiNetworkInterfaceIdentifierProtocolGuid, L"Nii" },
|
||||
{ &gEfiPxeBaseCodeProtocolGuid, L"Pxe" },
|
||||
{ &gEfiPxeBaseCodeCallbackProtocolGuid, L"PxeCb" },
|
||||
|
||||
{ &TextOutSpliterProtocol, L"TxtOutSplit" },
|
||||
{ &ErrorOutSpliterProtocol, L"ErrOutSplit" },
|
||||
{ &TextInSpliterProtocol, L"TxtInSplit" },
|
||||
{ &gEfiPcAnsiGuid, L"PcAnsi" },
|
||||
{ &gEfiVT100Guid, L"Vt100" },
|
||||
{ &gEfiVT100PlusGuid, L"Vt100Plus" },
|
||||
{ &gEfiVTUTF8Guid, L"VtUtf8" },
|
||||
{ &UnknownDevice, L"UnknownDev" },
|
||||
|
||||
{ &EfiPartTypeSystemPartitionGuid, L"ESP" },
|
||||
{ &EfiPartTypeLegacyMbrGuid, L"GPT MBR" },
|
||||
|
||||
{ &ShellInterfaceProtocol, L"ShellInt" },
|
||||
{ &SEnvId, L"SEnv" },
|
||||
{ &SProtId, L"ShellProtId" },
|
||||
{ &SMapId, L"ShellDevPathMap" },
|
||||
{ &SAliasId, L"ShellAlias" },
|
||||
|
||||
{ NULL, L"" }
|
||||
};
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
LIST_ENTRY GuidList;
|
||||
|
||||
|
||||
VOID
|
||||
InitializeGuid (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
INTN
|
||||
CompareGuid(
|
||||
IN EFI_GUID *Guid1,
|
||||
IN EFI_GUID *Guid2
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Compares to GUIDs
|
||||
|
||||
Arguments:
|
||||
|
||||
Guid1 - guid to compare
|
||||
Guid2 - guid to compare
|
||||
|
||||
Returns:
|
||||
= 0 if Guid1 == Guid2
|
||||
|
||||
--*/
|
||||
{
|
||||
return RtCompareGuid (Guid1, Guid2);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
GuidToString (
|
||||
OUT CHAR16 *Buffer,
|
||||
IN EFI_GUID *Guid
|
||||
)
|
||||
{
|
||||
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Else, (for now) use additional internal function for mapping guids
|
||||
//
|
||||
|
||||
for (Index=0; KnownGuids[Index].Guid; Index++) {
|
||||
if (CompareGuid(Guid, KnownGuids[Index].Guid) == 0) {
|
||||
SPrint (Buffer, 0, KnownGuids[Index].GuidName);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Else dump it
|
||||
//
|
||||
|
||||
SPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
Guid->Data1,
|
||||
Guid->Data2,
|
||||
Guid->Data3,
|
||||
Guid->Data4[0],
|
||||
Guid->Data4[1],
|
||||
Guid->Data4[2],
|
||||
Guid->Data4[3],
|
||||
Guid->Data4[4],
|
||||
Guid->Data4[5],
|
||||
Guid->Data4[6],
|
||||
Guid->Data4[7]
|
||||
);
|
||||
}
|
||||
636
gnu-efi/lib/hand.c
Normal file
636
gnu-efi/lib/hand.c
Normal file
@@ -0,0 +1,636 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
hand.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
#include "efistdarg.h" // !!!
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
LibLocateProtocol (
|
||||
IN EFI_GUID *ProtocolGuid,
|
||||
OUT VOID **Interface
|
||||
)
|
||||
//
|
||||
// Find the first instance of this Protocol in the system and return it's interface
|
||||
//
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN NumberHandles, Index;
|
||||
EFI_HANDLE *Handles;
|
||||
|
||||
|
||||
*Interface = NULL;
|
||||
Status = LibLocateHandle (ByProtocol, ProtocolGuid, NULL, &NumberHandles, &Handles);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((D_INFO, "LibLocateProtocol: Handle not found\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
for (Index=0; Index < NumberHandles; Index++) {
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handles[Index], ProtocolGuid, Interface);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Handles) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibLocateHandle (
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *NoHandles,
|
||||
OUT EFI_HANDLE **Buffer
|
||||
)
|
||||
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
*Buffer = NULL;
|
||||
BufferSize = 50 * sizeof(EFI_HANDLE);
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) Buffer, BufferSize)) {
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->LocateHandle,
|
||||
5,
|
||||
SearchType,
|
||||
Protocol,
|
||||
SearchKey,
|
||||
&BufferSize,
|
||||
*Buffer
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
*NoHandles = BufferSize / sizeof (EFI_HANDLE);
|
||||
if (EFI_ERROR(Status)) {
|
||||
*NoHandles = 0;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibLocateHandleByDiskSignature (
|
||||
IN UINT8 MBRType,
|
||||
IN UINT8 SignatureType,
|
||||
IN VOID *Signature,
|
||||
IN OUT UINTN *NoHandles,
|
||||
OUT EFI_HANDLE **Buffer
|
||||
)
|
||||
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
UINTN NoBlockIoHandles;
|
||||
EFI_HANDLE *BlockIoBuffer;
|
||||
EFI_DEVICE_PATH *DevicePath;
|
||||
UINTN Index;
|
||||
EFI_DEVICE_PATH *Next, *DevPath;
|
||||
HARDDRIVE_DEVICE_PATH *HardDriveDevicePath;
|
||||
BOOLEAN Match;
|
||||
BOOLEAN PreviousNodeIsHardDriveDevicePath;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
BlockIoBuffer = NULL;
|
||||
BufferSize = 50 * sizeof(EFI_HANDLE);
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **)&BlockIoBuffer, BufferSize)) {
|
||||
|
||||
//
|
||||
// Get list of device handles that support the BLOCK_IO Protocol.
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->LocateHandle,
|
||||
5,
|
||||
ByProtocol,
|
||||
&BlockIoProtocol,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
BlockIoBuffer
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
NoBlockIoHandles = BufferSize / sizeof (EFI_HANDLE);
|
||||
if (EFI_ERROR(Status)) {
|
||||
NoBlockIoHandles = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// If there was an error or there are no device handles that support
|
||||
// the BLOCK_IO Protocol, then return.
|
||||
//
|
||||
|
||||
if (NoBlockIoHandles == 0) {
|
||||
FreePool(BlockIoBuffer);
|
||||
*NoHandles = 0;
|
||||
*Buffer = NULL;
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop through all the device handles that support the BLOCK_IO Protocol
|
||||
//
|
||||
|
||||
*NoHandles = 0;
|
||||
|
||||
for(Index=0;Index<NoBlockIoHandles;Index++) {
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
BS->HandleProtocol,
|
||||
3,
|
||||
BlockIoBuffer[Index],
|
||||
&DevicePathProtocol,
|
||||
(VOID*)&DevicePath
|
||||
);
|
||||
|
||||
//
|
||||
// Search DevicePath for a Hard Drive Media Device Path node.
|
||||
// If one is found, then see if it matches the signature that was
|
||||
// passed in. If it does match, and the next node is the End of the
|
||||
// device path, and the previous node is not a Hard Drive Media Device
|
||||
// Path, then we have found a match.
|
||||
//
|
||||
|
||||
Match = FALSE;
|
||||
|
||||
if (DevicePath != NULL) {
|
||||
|
||||
PreviousNodeIsHardDriveDevicePath = FALSE;
|
||||
|
||||
DevPath = DevicePath;
|
||||
|
||||
//
|
||||
// Check for end of device path type
|
||||
//
|
||||
|
||||
for (; ;) {
|
||||
|
||||
if ((DevicePathType(DevPath) == MEDIA_DEVICE_PATH) &&
|
||||
(DevicePathSubType(DevPath) == MEDIA_HARDDRIVE_DP)) {
|
||||
|
||||
HardDriveDevicePath = (HARDDRIVE_DEVICE_PATH *)(DevPath);
|
||||
|
||||
if (PreviousNodeIsHardDriveDevicePath == FALSE) {
|
||||
|
||||
Next = NextDevicePathNode(DevPath);
|
||||
if (IsDevicePathEndType(Next)) {
|
||||
if ((HardDriveDevicePath->MBRType == MBRType) &&
|
||||
(HardDriveDevicePath->SignatureType == SignatureType)) {
|
||||
switch(SignatureType) {
|
||||
case SIGNATURE_TYPE_MBR:
|
||||
if (*((UINT32 *)(Signature)) == *(UINT32 *)(&(HardDriveDevicePath->Signature[0]))) {
|
||||
Match = TRUE;
|
||||
}
|
||||
break;
|
||||
case SIGNATURE_TYPE_GUID:
|
||||
if (CompareGuid((EFI_GUID *)Signature,(EFI_GUID *)(&(HardDriveDevicePath->Signature[0]))) == 0) {
|
||||
Match = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PreviousNodeIsHardDriveDevicePath = TRUE;
|
||||
} else {
|
||||
PreviousNodeIsHardDriveDevicePath = FALSE;
|
||||
}
|
||||
|
||||
if (IsDevicePathEnd(DevPath)) {
|
||||
break;
|
||||
}
|
||||
|
||||
DevPath = NextDevicePathNode(DevPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Match == FALSE) {
|
||||
BlockIoBuffer[Index] = NULL;
|
||||
} else {
|
||||
*NoHandles = *NoHandles + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If there are no matches, then return
|
||||
//
|
||||
|
||||
if (*NoHandles == 0) {
|
||||
FreePool(BlockIoBuffer);
|
||||
*NoHandles = 0;
|
||||
*Buffer = NULL;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate space for the return buffer of device handles.
|
||||
//
|
||||
|
||||
*Buffer = AllocatePool(*NoHandles * sizeof(EFI_HANDLE));
|
||||
|
||||
if (*Buffer == NULL) {
|
||||
FreePool(BlockIoBuffer);
|
||||
*NoHandles = 0;
|
||||
*Buffer = NULL;
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Build list of matching device handles.
|
||||
//
|
||||
|
||||
*NoHandles = 0;
|
||||
for(Index=0;Index<NoBlockIoHandles;Index++) {
|
||||
if (BlockIoBuffer[Index] != NULL) {
|
||||
(*Buffer)[*NoHandles] = BlockIoBuffer[Index];
|
||||
*NoHandles = *NoHandles + 1;
|
||||
}
|
||||
}
|
||||
|
||||
FreePool(BlockIoBuffer);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_FILE_HANDLE
|
||||
LibOpenRoot (
|
||||
IN EFI_HANDLE DeviceHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE_IO_INTERFACE *Volume;
|
||||
EFI_FILE_HANDLE File;
|
||||
|
||||
|
||||
//
|
||||
// File the file system interface to the device
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, DeviceHandle, &FileSystemProtocol, (VOID*)&Volume);
|
||||
|
||||
//
|
||||
// Open the root directory of the volume
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = uefi_call_wrapper(Volume->OpenVolume, 2, Volume, &File);
|
||||
}
|
||||
|
||||
//
|
||||
// Done
|
||||
//
|
||||
|
||||
return EFI_ERROR(Status) ? NULL : File;
|
||||
}
|
||||
|
||||
EFI_FILE_INFO *
|
||||
LibFileInfo (
|
||||
IN EFI_FILE_HANDLE FHand
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE_INFO *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Buffer = NULL;
|
||||
BufferSize = SIZE_OF_EFI_FILE_INFO + 200;
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(
|
||||
FHand->GetInfo,
|
||||
4,
|
||||
FHand,
|
||||
&GenericFileInfo,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
|
||||
EFI_FILE_SYSTEM_INFO *
|
||||
LibFileSystemInfo (
|
||||
IN EFI_FILE_HANDLE FHand
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE_SYSTEM_INFO *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Buffer = NULL;
|
||||
BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + 200;
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(
|
||||
FHand->GetInfo,
|
||||
4,
|
||||
FHand,
|
||||
&FileSystemInfo,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *
|
||||
LibFileSystemVolumeLabelInfo (
|
||||
IN EFI_FILE_HANDLE FHand
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Buffer = NULL;
|
||||
BufferSize = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO + 200;
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(
|
||||
FHand->GetInfo,
|
||||
4,
|
||||
FHand,
|
||||
&FileSystemVolumeLabelInfo,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
LibInstallProtocolInterfaces (
|
||||
IN OUT EFI_HANDLE *Handle,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list args;
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *Protocol;
|
||||
VOID *Interface;
|
||||
EFI_TPL OldTpl;
|
||||
UINTN Index;
|
||||
EFI_HANDLE OldHandle;
|
||||
|
||||
//
|
||||
// Syncronize with notifcations
|
||||
//
|
||||
|
||||
OldTpl = uefi_call_wrapper(BS->RaiseTPL, 1, TPL_NOTIFY);
|
||||
OldHandle = *Handle;
|
||||
|
||||
//
|
||||
// Install the protocol interfaces
|
||||
//
|
||||
|
||||
Index = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
va_start (args, Handle);
|
||||
|
||||
while (!EFI_ERROR(Status)) {
|
||||
|
||||
//
|
||||
// If protocol is NULL, then it's the end of the list
|
||||
//
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
if (!Protocol) {
|
||||
break;
|
||||
}
|
||||
|
||||
Interface = va_arg(args, VOID *);
|
||||
|
||||
//
|
||||
// Install it
|
||||
//
|
||||
|
||||
DEBUG((D_INFO, "LibInstallProtocolInterface: %d %x\n", Protocol, Interface));
|
||||
Status = uefi_call_wrapper(BS->InstallProtocolInterface, 4, Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);
|
||||
if (EFI_ERROR(Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Index += 1;
|
||||
}
|
||||
|
||||
//
|
||||
// If there was an error, remove all the interfaces that were
|
||||
// installed without any errors
|
||||
//
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
va_start (args, Handle);
|
||||
while (Index) {
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
Interface = va_arg(args, VOID *);
|
||||
uefi_call_wrapper(BS->UninstallProtocolInterface, 3, *Handle, Protocol, Interface);
|
||||
|
||||
Index -= 1;
|
||||
}
|
||||
|
||||
*Handle = OldHandle;
|
||||
}
|
||||
|
||||
//
|
||||
// Done
|
||||
//
|
||||
|
||||
uefi_call_wrapper(BS->RestoreTPL, 1, OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
LibUninstallProtocolInterfaces (
|
||||
IN EFI_HANDLE Handle,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list args;
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *Protocol;
|
||||
VOID *Interface;
|
||||
|
||||
|
||||
va_start (args, Handle);
|
||||
for (; ;) {
|
||||
|
||||
//
|
||||
// If protocol is NULL, then it's the end of the list
|
||||
//
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
if (!Protocol) {
|
||||
break;
|
||||
}
|
||||
|
||||
Interface = va_arg(args, VOID *);
|
||||
|
||||
//
|
||||
// Uninstall it
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->UninstallProtocolInterface, 3, Handle, Protocol, Interface);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((D_ERROR, "LibUninstallProtocolInterfaces: failed %g, %r\n", Protocol, Handle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
LibReinstallProtocolInterfaces (
|
||||
IN OUT EFI_HANDLE *Handle,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list args;
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *Protocol;
|
||||
VOID *OldInterface, *NewInterface;
|
||||
EFI_TPL OldTpl;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Syncronize with notifcations
|
||||
//
|
||||
|
||||
OldTpl = uefi_call_wrapper(BS->RaiseTPL, 1, TPL_NOTIFY);
|
||||
|
||||
//
|
||||
// Install the protocol interfaces
|
||||
//
|
||||
|
||||
Index = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
va_start (args, Handle);
|
||||
|
||||
while (!EFI_ERROR(Status)) {
|
||||
|
||||
//
|
||||
// If protocol is NULL, then it's the end of the list
|
||||
//
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
if (!Protocol) {
|
||||
break;
|
||||
}
|
||||
|
||||
OldInterface = va_arg(args, VOID *);
|
||||
NewInterface = va_arg(args, VOID *);
|
||||
|
||||
//
|
||||
// Reinstall it
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(BS->ReinstallProtocolInterface, 4, Handle, Protocol, OldInterface, NewInterface);
|
||||
if (EFI_ERROR(Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Index += 1;
|
||||
}
|
||||
|
||||
//
|
||||
// If there was an error, undo all the interfaces that were
|
||||
// reinstalled without any errors
|
||||
//
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
va_start (args, Handle);
|
||||
while (Index) {
|
||||
|
||||
Protocol = va_arg(args, EFI_GUID *);
|
||||
OldInterface = va_arg(args, VOID *);
|
||||
NewInterface = va_arg(args, VOID *);
|
||||
|
||||
uefi_call_wrapper(BS->ReinstallProtocolInterface, 4, Handle, Protocol, NewInterface, OldInterface);
|
||||
|
||||
Index -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Done
|
||||
//
|
||||
|
||||
uefi_call_wrapper(BS->RestoreTPL, 1, OldTpl);
|
||||
return Status;
|
||||
}
|
||||
132
gnu-efi/lib/hw.c
Normal file
132
gnu-efi/lib/hw.c
Normal file
@@ -0,0 +1,132 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
hw.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Debug library functions for Hardware IO access
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
InitializeGlobalIoDevice (
|
||||
IN EFI_DEVICE_PATH *DevicePath,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN CHAR8 *ErrorStr EFI_UNUSED,
|
||||
OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Check to see if DevicePath exists for a given Protocol. Return Error if it
|
||||
exists. Return GlobalIoFuncs set match the DevicePath
|
||||
|
||||
Arguments:
|
||||
|
||||
DevicePath - to operate on
|
||||
Protocol - to check the DevicePath against
|
||||
ErrorStr - ASCII string to display on error
|
||||
GlobalIoFncs - Returned with DeviceIoProtocol for the DevicePath
|
||||
|
||||
Returns:
|
||||
|
||||
Pass or Fail based on wether GlobalIoFncs where found
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE Handle;
|
||||
|
||||
//
|
||||
// Check to see if this device path already has Protocol on it.
|
||||
// if so we are loading recursivly and should exit with an error
|
||||
//
|
||||
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, Protocol, &DevicePath, &Handle);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
DEBUG ((D_INIT, "Device Already Loaded for %a device\n", ErrorStr));
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &DeviceIoProtocol, &DevicePath, &Handle);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handle, &DeviceIoProtocol, (VOID*)GlobalIoFncs);
|
||||
}
|
||||
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
UINT32
|
||||
ReadPort (
|
||||
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
|
||||
IN EFI_IO_WIDTH Width,
|
||||
IN UINTN Port
|
||||
)
|
||||
{
|
||||
UINT32 Data;
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
Status = uefi_call_wrapper(GlobalIoFncs->Io.Read, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
return Data;
|
||||
}
|
||||
|
||||
UINT32
|
||||
WritePort (
|
||||
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
|
||||
IN EFI_IO_WIDTH Width,
|
||||
IN UINTN Port,
|
||||
IN UINTN Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
Status = uefi_call_wrapper(GlobalIoFncs->Io.Write, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
return (UINT32)Data;
|
||||
}
|
||||
|
||||
UINT32
|
||||
ReadPciConfig (
|
||||
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
|
||||
IN EFI_IO_WIDTH Width,
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
UINT32 Data;
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
Status = uefi_call_wrapper(GlobalIoFncs->Pci.Read, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
return Data;
|
||||
}
|
||||
|
||||
UINT32
|
||||
WritePciConfig (
|
||||
IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs,
|
||||
IN EFI_IO_WIDTH Width,
|
||||
IN UINTN Address,
|
||||
IN UINTN Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status EFI_UNUSED;
|
||||
|
||||
Status = uefi_call_wrapper(GlobalIoFncs->Pci.Write, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data);
|
||||
ASSERT(!EFI_ERROR(Status));
|
||||
return (UINT32)Data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1
gnu-efi/lib/ia32/efi_stub.S
Normal file
1
gnu-efi/lib/ia32/efi_stub.S
Normal file
@@ -0,0 +1 @@
|
||||
/* This stub is a stub to make the build happy */
|
||||
27
gnu-efi/lib/ia32/initplat.c
Normal file
27
gnu-efi/lib/ia32/initplat.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
initplat.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
InitializeLibPlatform (
|
||||
IN EFI_HANDLE ImageHandle EFI_UNUSED,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
199
gnu-efi/lib/ia32/math.c
Normal file
199
gnu-efi/lib/ia32/math.c
Normal file
@@ -0,0 +1,199 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
math.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
#ifdef RUNTIME_CODE
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(LShiftU64)
|
||||
#pragma RUNTIME_CODE(RShiftU64)
|
||||
#pragma RUNTIME_CODE(MultU64x32)
|
||||
#pragma RUNTIME_CODE(DivU64x32)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
UINT64
|
||||
LShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Left shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return Operand << Count;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Operand[0]
|
||||
mov edx, dword ptr Operand[4]
|
||||
mov ecx, Count
|
||||
and ecx, 63
|
||||
|
||||
shld edx, eax, cl
|
||||
shl eax, cl
|
||||
|
||||
cmp ecx, 32
|
||||
jc short ls10
|
||||
|
||||
mov edx, eax
|
||||
xor eax, eax
|
||||
|
||||
ls10:
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT64
|
||||
RShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Right shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return Operand >> Count;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Operand[0]
|
||||
mov edx, dword ptr Operand[4]
|
||||
mov ecx, Count
|
||||
and ecx, 63
|
||||
|
||||
shrd eax, edx, cl
|
||||
shr edx, cl
|
||||
|
||||
cmp ecx, 32
|
||||
jc short rs10
|
||||
|
||||
mov eax, edx
|
||||
xor edx, edx
|
||||
|
||||
rs10:
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
UINT64
|
||||
MultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINTN Multiplier
|
||||
)
|
||||
// Multiple 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return Multiplicand * Multiplier;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Multiplicand[0]
|
||||
mul Multiplier
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
mov eax, dword ptr Multiplicand[4]
|
||||
mul Multiplier
|
||||
add dword ptr Result[4], eax
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT64
|
||||
DivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINTN Divisor,
|
||||
OUT UINTN *Remainder OPTIONAL
|
||||
)
|
||||
// divide 64bit by 32bit and get a 64bit result
|
||||
// N.B. only works for 31bit divisors!!
|
||||
{
|
||||
#if 0 && defined(__GNUC__) && !defined(__MINGW32__)
|
||||
if (Remainder)
|
||||
*Remainder = Dividend % Divisor;
|
||||
return Dividend / Divisor;
|
||||
#else
|
||||
UINT32 Rem;
|
||||
UINT32 bit;
|
||||
|
||||
ASSERT (Divisor != 0);
|
||||
ASSERT ((Divisor >> 31) == 0);
|
||||
|
||||
//
|
||||
// For each bit in the dividend
|
||||
//
|
||||
|
||||
Rem = 0;
|
||||
for (bit=0; bit < 64; bit++) {
|
||||
#if defined(__GNUC__) || defined(__MINGW32__)
|
||||
asm (
|
||||
"shll $1, %0\n\t"
|
||||
"rcll $1, 4%0\n\t"
|
||||
"rcll $1, %2\n\t"
|
||||
"mov %2, %%eax\n\t"
|
||||
"cmp %1, %%eax\n\t"
|
||||
"cmc\n\t"
|
||||
"sbb %%eax, %%eax\n\t"
|
||||
"sub %%eax, %0\n\t"
|
||||
"and %1, %%eax\n\t"
|
||||
"sub %%eax, %2"
|
||||
: /* no outputs */
|
||||
: "m"(Dividend), "m"(Divisor), "m"(Rem)
|
||||
: "cc","memory","%eax"
|
||||
);
|
||||
#else
|
||||
_asm {
|
||||
shl dword ptr Dividend[0], 1 ; shift rem:dividend left one
|
||||
rcl dword ptr Dividend[4], 1
|
||||
rcl dword ptr Rem, 1
|
||||
|
||||
mov eax, Rem
|
||||
cmp eax, Divisor ; Is Rem >= Divisor?
|
||||
cmc ; No - do nothing
|
||||
sbb eax, eax ; Else,
|
||||
sub dword ptr Dividend[0], eax ; set low bit in dividen
|
||||
and eax, Divisor ; and
|
||||
sub Rem, eax ; subtract divisor
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Remainder) {
|
||||
*Remainder = Rem;
|
||||
}
|
||||
|
||||
return Dividend;
|
||||
#endif
|
||||
}
|
||||
45
gnu-efi/lib/ia32/setjmp.S
Normal file
45
gnu-efi/lib/ia32/setjmp.S
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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
|
||||
.globl setjmp
|
||||
#ifndef __MINGW32__
|
||||
.type setjmp, @function
|
||||
#else
|
||||
.def setjmp; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
setjmp:
|
||||
pop %ecx
|
||||
movl (%esp), %edx
|
||||
movl %ebx, (%edx)
|
||||
movl %esi, 4(%edx)
|
||||
movl %edi, 8(%edx)
|
||||
movl %ebp, 12(%edx)
|
||||
movl %esp, 16(%edx)
|
||||
xorl %eax, %eax
|
||||
jmp *%ecx
|
||||
|
||||
.globl longjmp
|
||||
#ifndef __MINGW32__
|
||||
.type longjmp, @function
|
||||
#else
|
||||
.def longjmp; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
longjmp:
|
||||
pop %eax
|
||||
pop %edx
|
||||
pop %eax
|
||||
movl (%edx), %ebx
|
||||
movl 4(%edx), %esi
|
||||
movl 8(%edx), %edi
|
||||
30
gnu-efi/lib/ia64/initplat.c
Normal file
30
gnu-efi/lib/ia64/initplat.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
initplat.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Functions to make SAL and PAL proc calls
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
#include "lib.h"
|
||||
|
||||
//#include "palproc.h"
|
||||
|
||||
VOID
|
||||
InitializeLibPlatform (
|
||||
IN EFI_HANDLE ImageHandle EFI_UNUSED,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
|
||||
)
|
||||
{
|
||||
PLABEL SalPlabel;
|
||||
UINT64 PalEntry;
|
||||
|
||||
LibInitSalAndPalProc (&SalPlabel, &PalEntry);
|
||||
}
|
||||
88
gnu-efi/lib/ia64/math.c
Normal file
88
gnu-efi/lib/ia64/math.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
math.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
#ifdef RUNTIME_CODE
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(LShiftU64)
|
||||
#pragma RUNTIME_CODE(RShiftU64)
|
||||
#pragma RUNTIME_CODE(MultU64x32)
|
||||
#pragma RUNTIME_CODE(DivU64x32)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
UINT64
|
||||
LShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Left shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Operand << Count;
|
||||
}
|
||||
|
||||
UINT64
|
||||
RShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Right shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Operand >> Count;
|
||||
}
|
||||
|
||||
|
||||
UINT64
|
||||
MultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINTN Multiplier
|
||||
)
|
||||
// Multiple 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Multiplicand * Multiplier;
|
||||
}
|
||||
|
||||
UINT64
|
||||
DivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINTN Divisor,
|
||||
OUT UINTN *Remainder OPTIONAL
|
||||
)
|
||||
// divide 64bit by 32bit and get a 64bit result
|
||||
// N.B. only works for 31bit divisors!!
|
||||
{
|
||||
ASSERT (Divisor != 0);
|
||||
|
||||
if (Remainder) {
|
||||
*Remainder = Dividend % Divisor;
|
||||
}
|
||||
|
||||
return Dividend / Divisor;
|
||||
}
|
||||
161
gnu-efi/lib/ia64/palproc.S
Normal file
161
gnu-efi/lib/ia64/palproc.S
Normal file
@@ -0,0 +1,161 @@
|
||||
//++
|
||||
// Copyright (c) 1996-99 Intel Corp.
|
||||
//
|
||||
//
|
||||
// Module Name:
|
||||
//
|
||||
// palproc.s
|
||||
//
|
||||
// Abstract:
|
||||
//
|
||||
// Contains an implementation for making PAL PROC calls on
|
||||
// IA-64 architecture.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Revision History:
|
||||
//
|
||||
//--
|
||||
|
||||
.file "palproc.s"
|
||||
|
||||
#include "palproc.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//++
|
||||
// MakeStaticPALCall
|
||||
//
|
||||
// This routine is called whenever an architected static calling convention
|
||||
// based PAL call is to be made. This call does use RSE actually, but our policy
|
||||
// in making static PAL calls before memory is available is to make sure that
|
||||
// we do not nest too deep and allocate beyond 96 banked registers. In other
|
||||
// words we carefully code calls and control flow before memory is available.
|
||||
//
|
||||
// Arguments : All parameters set up to do static PAL call.
|
||||
//
|
||||
// On Entry :
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// As per static calling conventions.
|
||||
//
|
||||
//--
|
||||
//---------------------------------------------------------------------------
|
||||
PROCEDURE_ENTRY(MakeStaticPALCall)
|
||||
|
||||
NESTED_SETUP (5,8,0,0)
|
||||
mov loc3 = b5
|
||||
mov loc4 = r2
|
||||
mov loc7 = r1;;
|
||||
|
||||
movl loc6 = PAL_MC_CLEAR_LOG
|
||||
mov r2 = psr;;
|
||||
mov loc5 = r2
|
||||
|
||||
cmp.eq p6,p7 = r28,loc6;;
|
||||
(p7)movl loc6 = PAL_MC_DYNAMIC_STATE;;
|
||||
(p7)cmp.eq p6,p7 = r28,loc6;;
|
||||
|
||||
(p7)movl loc6 = PAL_MC_ERROR_INFO;;
|
||||
(p7)cmp.eq p6,p7 = r28,loc6;;
|
||||
|
||||
(p7)movl loc6 = PAL_MC_RESUME;;
|
||||
(p7)cmp.eq p6,p7 = r28,loc6
|
||||
|
||||
mov loc6 = 0x1;;
|
||||
(p7)dep r2 = loc6,r2,13,1;; // psr.ic = 1
|
||||
|
||||
// p6 will be true, if it is one of the MCHK calls. There has been lots of debate
|
||||
// on psr.ic for these values. For now, do not do any thing to psr.ic
|
||||
|
||||
// (p6)dep r2 = r0,r2,13,1;; // psr.ic = 0
|
||||
dep r2 = r0,r2,14,1;; // psr.i = 0
|
||||
|
||||
mov psr.l = r2
|
||||
srlz.d;; // Needs data serailization.
|
||||
srlz.i;; // Needs instruction serailization.
|
||||
|
||||
StaticGetPALLocalIP:
|
||||
mov loc2 = ip;;
|
||||
add loc2 = StaticComeBackFromPALCall - StaticGetPALLocalIP,loc2;;
|
||||
mov b0 = loc2 // return address after Pal call
|
||||
mov r28 = in1 // get the input parameters to PAL call
|
||||
mov r29 = in2
|
||||
mov r30 = in3;;
|
||||
mov r31 = in4
|
||||
mov b5 = in0;; // get the PalProcEntrypt from input
|
||||
br.sptk b5 // Take the plunge.
|
||||
|
||||
StaticComeBackFromPALCall:
|
||||
|
||||
mov psr.l = loc5;;
|
||||
srlz.d;; // Needs data serailization.
|
||||
srlz.i;; // Needs instruction serailization.
|
||||
|
||||
mov b5 = loc3
|
||||
mov r2 = loc4
|
||||
mov r1 = loc7
|
||||
|
||||
NESTED_RETURN
|
||||
|
||||
PROCEDURE_EXIT(MakeStaticPALCall)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//++
|
||||
// MakeStackedPALCall
|
||||
//
|
||||
// This routine is called whenever an architected stacked calling convention
|
||||
// based PAL call is to be made. This call is made after memory is available.
|
||||
// Although stacked calls could be made directly from 'C', there is a PAL
|
||||
// requirement which forces the index to be in GR28 and hence this stub is
|
||||
// needed
|
||||
//
|
||||
// Arguments : All parameters set up to do stacted PAL call.
|
||||
//
|
||||
// On Entry :
|
||||
// in0: PAL_PROC entrypoint
|
||||
// in1-in4 : PAL_PROC arguments
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// As per stacked calling conventions.
|
||||
//
|
||||
//--
|
||||
//---------------------------------------------------------------------------
|
||||
PROCEDURE_ENTRY(MakeStackedPALCall)
|
||||
|
||||
NESTED_SETUP (5,8,4,0)
|
||||
mov loc3 = b5
|
||||
mov loc4 = r2
|
||||
mov loc7 = r1
|
||||
mov r2 = psr;;
|
||||
mov loc5 = r2;;
|
||||
dep r2 = r0,r2,14,1;; // psr.i = 0
|
||||
mov psr.l = r2
|
||||
srlz.d;; // Needs data serailization.
|
||||
srlz.i;; // Needs instruction serailization.
|
||||
|
||||
StackedGetPALLocalIP:
|
||||
mov r28 = in1 // get the input parameters to PAL call
|
||||
mov out0 = in1
|
||||
mov out1 = in2;;
|
||||
mov out2 = in3
|
||||
mov out3 = in4
|
||||
mov b5 = in0;; // get the PalProcEntrypt from input
|
||||
br.call.dpnt b0=b5;; // Take the plunge.
|
||||
|
||||
StackedComeBackFromPALCall:
|
||||
|
||||
mov psr.l = loc5;;
|
||||
srlz.d;; // Needs data serailization.
|
||||
srlz.i;; // Needs instruction serailization.
|
||||
mov b5 = loc3
|
||||
mov r2 = loc4
|
||||
mov r1 = loc7
|
||||
|
||||
NESTED_RETURN
|
||||
|
||||
PROCEDURE_EXIT(MakeStackedPALCall)
|
||||
|
||||
51
gnu-efi/lib/ia64/palproc.h
Normal file
51
gnu-efi/lib/ia64/palproc.h
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1996-99 Intel Corp.
|
||||
//
|
||||
//
|
||||
//Module Name:
|
||||
//
|
||||
// palproc.h
|
||||
//
|
||||
//Abstract:
|
||||
//
|
||||
// This module contains generic macros for an IA64 assembly writer.
|
||||
//
|
||||
//
|
||||
//Revision History
|
||||
//
|
||||
|
||||
#ifndef _PALPROC_H
|
||||
#define _PALPROC_H
|
||||
|
||||
#define PROCEDURE_ENTRY(name) .##text; \
|
||||
.##type name, @function; \
|
||||
.##global name; \
|
||||
.##proc name; \
|
||||
name:
|
||||
|
||||
#define PROCEDURE_EXIT(name) .##endp name
|
||||
|
||||
// Note: use of NESTED_SETUP requires number of locals (l) >= 3
|
||||
|
||||
#define NESTED_SETUP(i,l,o,r) \
|
||||
alloc loc1=ar##.##pfs,i,l,o,r ;\
|
||||
mov loc0=b0
|
||||
|
||||
#define NESTED_RETURN \
|
||||
mov b0=loc0 ;\
|
||||
mov ar##.##pfs=loc1 ;;\
|
||||
br##.##ret##.##dpnt b0;;
|
||||
|
||||
|
||||
// defines needed in palproc.s
|
||||
|
||||
#define PAL_MC_CLEAR_LOG 0x0015
|
||||
#define PAL_MC_DRAIN 0x0016
|
||||
#define PAL_MC_EXPECTED 0x0017
|
||||
#define PAL_MC_DYNAMIC_STATE 0x0018
|
||||
#define PAL_MC_ERROR_INFO 0x0019
|
||||
#define PAL_MC_RESUME 0x001a
|
||||
#define PAL_MC_REGISTER_MEM 0x001b
|
||||
|
||||
#endif // _PALPROC_H
|
||||
335
gnu-efi/lib/ia64/salpal.c
Normal file
335
gnu-efi/lib/ia64/salpal.c
Normal file
@@ -0,0 +1,335 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
salpal.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Functions to make SAL and PAL proc calls
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
#include "lib.h"
|
||||
#include "palproc.h"
|
||||
#include "salproc.h"
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
EfiRtLib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI Runtime library functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "efi.h"
|
||||
#include "efilib.h"
|
||||
|
||||
rArg
|
||||
MakeStaticPALCall (
|
||||
IN UINT64 PALPROCPtr,
|
||||
IN UINT64 Arg1,
|
||||
IN UINT64 Arg2,
|
||||
IN UINT64 Arg3,
|
||||
IN UINT64 Arg4
|
||||
);
|
||||
|
||||
rArg
|
||||
MakeStackedPALCall (
|
||||
IN UINT64 PALPROCPtr,
|
||||
IN UINT64 Arg1,
|
||||
IN UINT64 Arg2,
|
||||
IN UINT64 Arg3,
|
||||
IN UINT64 Arg4
|
||||
);
|
||||
|
||||
|
||||
PLABEL SalProcPlabel;
|
||||
PLABEL PalProcPlabel;
|
||||
CALL_SAL_PROC GlobalSalProc;
|
||||
CALL_PAL_PROC GlobalPalProc;
|
||||
|
||||
VOID
|
||||
LibInitSalAndPalProc (
|
||||
OUT PLABEL *SalPlabel,
|
||||
OUT UINT64 *PalEntry
|
||||
)
|
||||
{
|
||||
SAL_SYSTEM_TABLE_ASCENDING_ORDER *SalSystemTable;
|
||||
EFI_STATUS Status;
|
||||
|
||||
GlobalSalProc = NULL;
|
||||
GlobalPalProc = NULL;
|
||||
|
||||
Status = LibGetSystemConfigurationTable(&SalSystemTableGuid, (VOID **)&SalSystemTable);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// BugBug: Add code to test checksum on the Sal System Table
|
||||
//
|
||||
if (SalSystemTable->Entry0.Type != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SalProcPlabel.ProcEntryPoint = SalSystemTable->Entry0.SalProcEntry;
|
||||
SalProcPlabel.GP = SalSystemTable->Entry0.GlobalDataPointer;
|
||||
GlobalSalProc = (CALL_SAL_PROC)&SalProcPlabel.ProcEntryPoint;
|
||||
|
||||
//
|
||||
// Need to check the PAL spec to make sure I'm not responsible for
|
||||
// storing more state.
|
||||
// We are passing in a Plabel that should be ignorred by the PAL. Call
|
||||
// this way will cause use to retore our gp after the PAL returns.
|
||||
//
|
||||
PalProcPlabel.ProcEntryPoint = SalSystemTable->Entry0.PalProcEntry;
|
||||
PalProcPlabel.GP = SalSystemTable->Entry0.GlobalDataPointer;
|
||||
GlobalPalProc = (CALL_PAL_PROC)PalProcPlabel.ProcEntryPoint;
|
||||
|
||||
*PalEntry = PalProcPlabel.ProcEntryPoint;
|
||||
*SalPlabel = SalProcPlabel;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibGetSalIoPortMapping (
|
||||
OUT UINT64 *IoPortMapping
|
||||
)
|
||||
/*++
|
||||
|
||||
Get the IO Port Map from the SAL System Table.
|
||||
DO NOT USE THIS TO DO YOU OWN IO's!!!!!!!!!!!!
|
||||
Only use this for getting info, or initing the built in EFI IO abstraction.
|
||||
Always use the EFI Device IO protoocl to access IO space.
|
||||
|
||||
--*/
|
||||
{
|
||||
SAL_SYSTEM_TABLE_ASCENDING_ORDER *SalSystemTable;
|
||||
SAL_ST_MEMORY_DESCRIPTOR_ENTRY *SalMemDesc;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = LibGetSystemConfigurationTable(&SalSystemTableGuid, (VOID **)&SalSystemTable);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// BugBug: Add code to test checksum on the Sal System Table
|
||||
//
|
||||
if (SalSystemTable->Entry0.Type != 0) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// The SalSystemTable pointer includes the Type 0 entry.
|
||||
// The SalMemDesc is Type 1 so it comes next.
|
||||
//
|
||||
SalMemDesc = (SAL_ST_MEMORY_DESCRIPTOR_ENTRY *)(SalSystemTable + 1);
|
||||
while (SalMemDesc->Type == SAL_ST_MEMORY_DESCRIPTOR) {
|
||||
if (SalMemDesc->MemoryType == SAL_IO_PORT_MAPPING) {
|
||||
*IoPortMapping = SalMemDesc->PhysicalMemoryAddress;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
SalMemDesc++;
|
||||
}
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibGetSalIpiBlock (
|
||||
OUT UINT64 *IpiBlock
|
||||
)
|
||||
/*++
|
||||
|
||||
Get the IPI block from the SAL system table
|
||||
|
||||
--*/
|
||||
{
|
||||
SAL_SYSTEM_TABLE_ASCENDING_ORDER *SalSystemTable;
|
||||
SAL_ST_MEMORY_DESCRIPTOR_ENTRY *SalMemDesc;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = LibGetSystemConfigurationTable(&SalSystemTableGuid, (VOID*)&SalSystemTable);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// BugBug: Add code to test checksum on the Sal System Table
|
||||
//
|
||||
if (SalSystemTable->Entry0.Type != 0) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// The SalSystemTable pointer includes the Type 0 entry.
|
||||
// The SalMemDesc is Type 1 so it comes next.
|
||||
//
|
||||
SalMemDesc = (SAL_ST_MEMORY_DESCRIPTOR_ENTRY *)(SalSystemTable + 1);
|
||||
while (SalMemDesc->Type == SAL_ST_MEMORY_DESCRIPTOR) {
|
||||
if (SalMemDesc->MemoryType == SAL_SAPIC_IPI_BLOCK ) {
|
||||
*IpiBlock = SalMemDesc->PhysicalMemoryAddress;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
SalMemDesc++;
|
||||
}
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibGetSalWakeupVector (
|
||||
OUT UINT64 *WakeVector
|
||||
)
|
||||
/*++
|
||||
|
||||
Get the wakeup vector from the SAL system table
|
||||
|
||||
--*/
|
||||
{
|
||||
SAL_ST_AP_WAKEUP_DECRIPTOR *ApWakeUp;
|
||||
|
||||
ApWakeUp = LibSearchSalSystemTable (SAL_ST_AP_WAKEUP);
|
||||
if (!ApWakeUp) {
|
||||
*WakeVector = -1;
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
*WakeVector = ApWakeUp->ExternalInterruptVector;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
VOID *
|
||||
LibSearchSalSystemTable (
|
||||
IN UINT8 EntryType
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 *SalTableHack;
|
||||
SAL_SYSTEM_TABLE_ASCENDING_ORDER *SalSystemTable;
|
||||
UINT16 EntryCount;
|
||||
UINT16 Count;
|
||||
|
||||
Status = LibGetSystemConfigurationTable(&SalSystemTableGuid, (VOID*)&SalSystemTable);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EntryCount = SalSystemTable->Header.EntryCount;
|
||||
if (EntryCount == 0) {
|
||||
return NULL;
|
||||
}
|
||||
//
|
||||
// BugBug: Add code to test checksum on the Sal System Table
|
||||
//
|
||||
|
||||
SalTableHack = (UINT8 *)&SalSystemTable->Entry0;
|
||||
for (Count = 0; Count < EntryCount ;Count++) {
|
||||
if (*SalTableHack == EntryType) {
|
||||
return (VOID *)SalTableHack;
|
||||
}
|
||||
switch (*SalTableHack) {
|
||||
case SAL_ST_ENTRY_POINT:
|
||||
SalTableHack += 48;
|
||||
break;
|
||||
case SAL_ST_MEMORY_DESCRIPTOR:
|
||||
SalTableHack += 32;
|
||||
break;
|
||||
case SAL_ST_PLATFORM_FEATURES:
|
||||
SalTableHack += 16;
|
||||
break;
|
||||
case SAL_ST_TR_USAGE:
|
||||
SalTableHack += 32;
|
||||
break;
|
||||
case SAL_ST_PTC:
|
||||
SalTableHack += 16;
|
||||
break;
|
||||
case SAL_ST_AP_WAKEUP:
|
||||
SalTableHack += 16;
|
||||
break;
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID
|
||||
LibSalProc (
|
||||
IN UINT64 Arg1,
|
||||
IN UINT64 Arg2,
|
||||
IN UINT64 Arg3,
|
||||
IN UINT64 Arg4,
|
||||
IN UINT64 Arg5,
|
||||
IN UINT64 Arg6,
|
||||
IN UINT64 Arg7,
|
||||
IN UINT64 Arg8,
|
||||
OUT rArg *Results OPTIONAL
|
||||
)
|
||||
{
|
||||
rArg ReturnValue;
|
||||
|
||||
ReturnValue.p0 = -3; // SAL status return completed with error
|
||||
if (GlobalSalProc) {
|
||||
ReturnValue = GlobalSalProc(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8);
|
||||
}
|
||||
|
||||
if (Results) {
|
||||
CopyMem (Results, &ReturnValue, sizeof(rArg));
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
LibPalProc (
|
||||
IN UINT64 Arg1, // Pal Proc index
|
||||
IN UINT64 Arg2,
|
||||
IN UINT64 Arg3,
|
||||
IN UINT64 Arg4,
|
||||
OUT rArg *Results OPTIONAL
|
||||
)
|
||||
{
|
||||
|
||||
rArg ReturnValue;
|
||||
|
||||
ReturnValue.p0 = -3; // PAL status return completed with error
|
||||
|
||||
//
|
||||
// check for valid PalProc entry point
|
||||
//
|
||||
|
||||
if (!GlobalPalProc) {
|
||||
if (Results)
|
||||
CopyMem (Results, &ReturnValue, sizeof(rArg));
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// check if index falls within stacked or static register calling conventions
|
||||
// and call appropriate Pal stub call
|
||||
//
|
||||
|
||||
if (((Arg1 >=255) && (Arg1 <=511)) ||
|
||||
((Arg1 >=768) && (Arg1 <=1023))) {
|
||||
ReturnValue = MakeStackedPALCall((UINT64)GlobalPalProc,Arg1,Arg2,Arg3,Arg4);
|
||||
}
|
||||
else {
|
||||
ReturnValue = MakeStaticPALCall((UINT64)GlobalPalProc,Arg1,Arg2,Arg3,Arg4);
|
||||
}
|
||||
|
||||
if (Results)
|
||||
CopyMem (Results, &ReturnValue, sizeof(rArg));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
199
gnu-efi/lib/ia64/setjmp.S
Normal file
199
gnu-efi/lib/ia64/setjmp.S
Normal file
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* 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
|
||||
.globl setjmp
|
||||
.type setjmp, @function
|
||||
setjmp:
|
||||
alloc loc0 = ar.pfs, 1, 2, 1, 0
|
||||
;;
|
||||
mov r14 = ar.unat
|
||||
mov r15 = ar.bsp
|
||||
add r10 = 0x10*20, in0
|
||||
;;
|
||||
stf.spill.nta [in0] = f2, 0x10
|
||||
st8.spill.nta [r10] = r4, 8
|
||||
mov r21 = b1
|
||||
;;
|
||||
stf.spill.nta [in0] = f3, 0x10
|
||||
st8.spill.nta [r10] = r5, 8
|
||||
mov r22 = b2
|
||||
;;
|
||||
stf.spill.nta [in0] = f4, 0x10
|
||||
st8.spill.nta [r10] = r6, 8
|
||||
mov r23 = b3
|
||||
;;
|
||||
stf.spill.nta [in0] = f5, 0x10
|
||||
st8.spill.nta [r10] = r7, 8
|
||||
mov r24 = b4
|
||||
;;
|
||||
stf.spill.nta [in0] = f16, 0x10
|
||||
st8.spill.nta [r10] = sp, 8
|
||||
mov r25 = b5
|
||||
;;
|
||||
stf.spill.nta [in0] = f17, 0x10
|
||||
st8.nta [r10] = loc1, 8
|
||||
mov r16 = pr
|
||||
;;
|
||||
stf.spill.nta [in0] = f18, 0x10
|
||||
st8.nta [r10] = r21, 8
|
||||
mov r17 = ar.lc
|
||||
;;
|
||||
stf.spill.nta [in0] = f19, 0x10
|
||||
st8.nta [r10] = r22, 8
|
||||
;;
|
||||
stf.spill.nta [in0] = f20, 0x10
|
||||
st8.nta [r10] = r23, 8
|
||||
;;
|
||||
stf.spill.nta [in0] = f21, 0x10
|
||||
st8.nta [r10] = r24, 8
|
||||
;;
|
||||
stf.spill.nta [in0] = f22, 0x10
|
||||
st8.nta [r10] = r25, 8
|
||||
;;
|
||||
stf.spill.nta [in0] = f23, 0x10
|
||||
mov r18 = ar.unat
|
||||
;;
|
||||
stf.spill.nta [in0] = f24, 0x10
|
||||
st8.nta [r10] = r14, 8
|
||||
;;
|
||||
stf.spill.nta [in0] = f25, 0x10
|
||||
st8.nta [r10] = r18, 8
|
||||
;;
|
||||
stf.spill.nta [in0] = f26, 0x10
|
||||
st8.nta [r10] = loc0, 8
|
||||
;;
|
||||
stf.spill.nta [in0] = f27, 0x10
|
||||
st8.nta [r10] = r15, 8
|
||||
mov r8 = 0
|
||||
;;
|
||||
stf.spill.nta [in0] = f28, 0x10
|
||||
mov r19 = ar.fpsr
|
||||
;;
|
||||
stf.spill.nta [in0] = f29, 0x10
|
||||
st8.nta [r10] = r16, 8
|
||||
mov ar.pfs = loc0
|
||||
;;
|
||||
stf.spill.nta [in0] = f30, 0x10
|
||||
st8.nta [r10] = r17, 8
|
||||
mov b0 = loc1
|
||||
;;
|
||||
stf.spill.nta [in0] = f31, 0x10
|
||||
st8.nta [r10] = r19
|
||||
;;
|
||||
mov ar.unat = r14
|
||||
br.ret.sptk b0
|
||||
;;
|
||||
|
||||
.globl longjmp
|
||||
.type longjmp, @function
|
||||
.regstk 2, 0, 0, 0
|
||||
longjmp:
|
||||
add r10 = 0x10*20 + 8*14, in0
|
||||
movl r2 = ~((((1<<14) - 1) << 16) | 3)
|
||||
;;
|
||||
ld8.nt1 r14 = [r10], -8*2
|
||||
mov r15 = ar.bspstore
|
||||
;;
|
||||
ld8.nt1 r17 = [r10], -8
|
||||
mov r16 = ar.rsc
|
||||
cmp.leu p6 = r14, r15
|
||||
;;
|
||||
ld8.nt1 r18 = [r10], -8
|
||||
ld8.nt1 r25 = [r10], -8
|
||||
and r2 = r16, r2
|
||||
;;
|
||||
ldf.fill.nt1 f2 = [in0], 0x10
|
||||
ld8.nt1 r24 = [r10], -8
|
||||
mov b5 = r25
|
||||
;;
|
||||
mov ar.rsc = r2
|
||||
ld8.nt1 r23 = [r10], -8
|
||||
mov b4 = r24
|
||||
;;
|
||||
ldf.fill.nt1 f3 = [in0], 0x10
|
||||
mov ar.unat = r17
|
||||
(p6) br.spnt.many _skip_flushrs
|
||||
;;
|
||||
flushrs
|
||||
mov r15 = ar.bsp
|
||||
;;
|
||||
_skip_flushrs:
|
||||
mov r31 = ar.rnat
|
||||
loadrs
|
||||
;;
|
||||
ldf.fill.nt1 f4 = [in0], 0x10
|
||||
ld8.nt1 r22 = [r10], -8
|
||||
dep r2 = -1, r14, 3, 6
|
||||
;;
|
||||
ldf.fill.nt1 f5 = [in0], 0x10
|
||||
ld8.nt1 r21 = [r10], -8
|
||||
cmp.ltu p6 = r2, r15
|
||||
;;
|
||||
ld8.nt1 r20 = [r10], -0x10
|
||||
(p6) ld8.nta r31 = [r2]
|
||||
mov b3 = r23
|
||||
;;
|
||||
ldf.fill.nt1 f16 = [in0], 0x10
|
||||
ld8.fill.nt1 r7 = [r10], -8
|
||||
mov b2 = r22
|
||||
;;
|
||||
ldf.fill.nt1 f17 = [in0], 0x10
|
||||
ld8.fill.nt1 r6 = [r10], -8
|
||||
mov b1 = r21
|
||||
;;
|
||||
ldf.fill.nt1 f18 = [in0], 0x10
|
||||
ld8.fill.nt1 r5 = [r10], -8
|
||||
mov b0 = r20
|
||||
;;
|
||||
ldf.fill.nt1 f19 = [in0], 0x10
|
||||
ld8.fill.nt1 r4 = [r10], 8*13
|
||||
;;
|
||||
ldf.fill.nt1 f20 = [in0], 0x10
|
||||
ld8.nt1 r19 = [r10], 0x10
|
||||
;;
|
||||
ldf.fill.nt1 f21 = [in0], 0x10
|
||||
ld8.nt1 r26 = [r10], 8
|
||||
mov ar.pfs = r19
|
||||
;;
|
||||
ldf.fill.nt1 f22 = [in0], 0x10
|
||||
ld8.nt1 r27 = [r10], 8
|
||||
mov pr = r26, -1
|
||||
;;
|
||||
ldf.fill.nt1 f23 = [in0], 0x10
|
||||
ld8.nt1 r28 = [r10], -17*8 - 0x10
|
||||
mov ar.lc = r27
|
||||
;;
|
||||
ldf.fill.nt1 f24 = [in0], 0x10
|
||||
ldf.fill.nt1 f25 = [in0], 0x10
|
||||
mov r8 = in1
|
||||
;;
|
||||
ldf.fill.nt1 f26 = [in0], 0x10
|
||||
ldf.fill.nt1 f31 = [r10], -0x10
|
||||
;;
|
||||
ldf.fill.nt1 f27 = [in0], 0x10
|
||||
ldf.fill.nt1 f30 = [r10], -0x10
|
||||
;;
|
||||
ldf.fill.nt1 f28 = [in0]
|
||||
ldf.fill.nt1 f29 = [r10], 0x10*3 + 8*4
|
||||
;;
|
||||
ld8.fill.nt1 sp = [r10]
|
||||
mov ar.unat = r18
|
||||
;;
|
||||
mov ar.bspstore = r14
|
||||
mov ar.rnat = r31
|
||||
;;
|
||||
invala
|
||||
mov ar.rsc = r16
|
||||
br.ret.sptk b0
|
||||
214
gnu-efi/lib/init.c
Normal file
214
gnu-efi/lib/init.c
Normal file
@@ -0,0 +1,214 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
EFIDebugVariable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
InitializeLib (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Initializes EFI library for use
|
||||
|
||||
Arguments:
|
||||
|
||||
Firmware's EFI system table
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_LOADED_IMAGE *LoadedImage;
|
||||
EFI_STATUS Status;
|
||||
CHAR8 *LangCode;
|
||||
|
||||
if (!LibInitialized) {
|
||||
LibInitialized = TRUE;
|
||||
LibFwInstance = FALSE;
|
||||
LibImageHandle = ImageHandle;
|
||||
|
||||
|
||||
//
|
||||
// Set up global pointer to the system table, boot services table,
|
||||
// and runtime services table
|
||||
//
|
||||
|
||||
ST = SystemTable;
|
||||
BS = SystemTable->BootServices;
|
||||
RT = SystemTable->RuntimeServices;
|
||||
// ASSERT (CheckCrc(0, &ST->Hdr));
|
||||
// ASSERT (CheckCrc(0, &BS->Hdr));
|
||||
// ASSERT (CheckCrc(0, &RT->Hdr));
|
||||
|
||||
|
||||
//
|
||||
// Initialize pool allocation type
|
||||
//
|
||||
|
||||
if (ImageHandle) {
|
||||
Status = uefi_call_wrapper(
|
||||
BS->HandleProtocol,
|
||||
3,
|
||||
ImageHandle,
|
||||
&LoadedImageProtocol,
|
||||
(VOID*)&LoadedImage
|
||||
);
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
PoolAllocationType = LoadedImage->ImageDataType;
|
||||
}
|
||||
EFIDebugVariable ();
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Guid table
|
||||
//
|
||||
|
||||
InitializeGuid();
|
||||
|
||||
InitializeLibPlatform(ImageHandle,SystemTable);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
if (ImageHandle && UnicodeInterface == &LibStubUnicodeInterface) {
|
||||
LangCode = LibGetVariable (VarLanguage, &EfiGlobalVariable);
|
||||
InitializeUnicodeSupport (LangCode);
|
||||
if (LangCode) {
|
||||
FreePool (LangCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
InitializeUnicodeSupport (
|
||||
CHAR8 *LangCode
|
||||
)
|
||||
{
|
||||
EFI_UNICODE_COLLATION_INTERFACE *Ui;
|
||||
EFI_STATUS Status;
|
||||
CHAR8 *Languages;
|
||||
UINTN Index, Position, Length;
|
||||
UINTN NoHandles;
|
||||
EFI_HANDLE *Handles;
|
||||
|
||||
//
|
||||
// If we don't know it, lookup the current language code
|
||||
//
|
||||
|
||||
LibLocateHandle (ByProtocol, &UnicodeCollationProtocol, NULL, &NoHandles, &Handles);
|
||||
if (!LangCode || !NoHandles) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Check all driver's for a matching language code
|
||||
//
|
||||
|
||||
for (Index=0; Index < NoHandles; Index++) {
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handles[Index], &UnicodeCollationProtocol, (VOID*)&Ui);
|
||||
if (EFI_ERROR(Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check for a matching language code
|
||||
//
|
||||
|
||||
Languages = Ui->SupportedLanguages;
|
||||
Length = strlena(Languages);
|
||||
for (Position=0; Position < Length; Position += ISO_639_2_ENTRY_SIZE) {
|
||||
|
||||
//
|
||||
// If this code matches, use this driver
|
||||
//
|
||||
|
||||
if (CompareMem (Languages+Position, LangCode, ISO_639_2_ENTRY_SIZE) == 0) {
|
||||
UnicodeInterface = Ui;
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Done:
|
||||
//
|
||||
// Cleanup
|
||||
//
|
||||
|
||||
if (Handles) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIDebugVariable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 Attributes;
|
||||
UINTN DataSize;
|
||||
UINTN NewEFIDebug;
|
||||
|
||||
DataSize = sizeof(EFIDebug);
|
||||
Status = uefi_call_wrapper(RT->GetVariable, 5, L"EFIDebug", &EfiGlobalVariable, &Attributes, &DataSize, &NewEFIDebug);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
EFIDebug = NewEFIDebug;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Calls to memset/memcpy may be emitted implicitly by GCC or MSVC
|
||||
* even when -ffreestanding or /NODEFAULTLIB are in effect.
|
||||
*/
|
||||
|
||||
#ifndef __SIZE_TYPE__
|
||||
#define __SIZE_TYPE__ UINTN
|
||||
#endif
|
||||
|
||||
void *memset(void *s, int c, __SIZE_TYPE__ n)
|
||||
{
|
||||
unsigned char *p = s;
|
||||
|
||||
while (n--)
|
||||
*p++ = c;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n)
|
||||
{
|
||||
const unsigned char *q = src;
|
||||
unsigned char *p = dest;
|
||||
|
||||
while (n--)
|
||||
*p++ = *q++;
|
||||
|
||||
return dest;
|
||||
}
|
||||
92
gnu-efi/lib/lib.h
Normal file
92
gnu-efi/lib/lib.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
lib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI library header files
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
#include "efi.h"
|
||||
#include "efilib.h"
|
||||
#include "efirtlib.h"
|
||||
|
||||
//
|
||||
// Include non architectural protocols
|
||||
//
|
||||
#include "efivar.h"
|
||||
#include "legacyboot.h"
|
||||
#include "intload.h"
|
||||
#include "vgaclass.h"
|
||||
#include "eficonsplit.h"
|
||||
#include "adapterdebug.h"
|
||||
#include "intload.h"
|
||||
|
||||
#include "efigpt.h"
|
||||
#include "libsmbios.h"
|
||||
|
||||
//
|
||||
// Prototypes
|
||||
//
|
||||
|
||||
VOID
|
||||
InitializeGuid (
|
||||
VOID
|
||||
);
|
||||
|
||||
INTN EFIAPI
|
||||
LibStubStriCmp (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This,
|
||||
IN CHAR16 *S1,
|
||||
IN CHAR16 *S2
|
||||
);
|
||||
|
||||
BOOLEAN EFIAPI
|
||||
LibStubMetaiMatch (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This,
|
||||
IN CHAR16 *String,
|
||||
IN CHAR16 *Pattern
|
||||
);
|
||||
|
||||
VOID EFIAPI
|
||||
LibStubStrLwrUpr (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This,
|
||||
IN CHAR16 *Str
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
LibMatchDevicePaths (
|
||||
IN EFI_DEVICE_PATH *Multi,
|
||||
IN EFI_DEVICE_PATH *Single
|
||||
);
|
||||
|
||||
EFI_DEVICE_PATH *
|
||||
LibDuplicateDevicePathInstance (
|
||||
IN EFI_DEVICE_PATH *DevPath
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
extern BOOLEAN LibInitialized;
|
||||
extern BOOLEAN LibFwInstance;
|
||||
extern EFI_HANDLE LibImageHandle;
|
||||
extern SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut;
|
||||
extern EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface;
|
||||
extern EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface;
|
||||
extern EFI_RAISE_TPL LibRuntimeRaiseTPL;
|
||||
extern EFI_RESTORE_TPL LibRuntimeRestoreTPL;
|
||||
107
gnu-efi/lib/lock.c
Normal file
107
gnu-efi/lib/lock.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
lock.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Implements FLOCK
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
VOID
|
||||
InitializeLock (
|
||||
IN OUT FLOCK *Lock,
|
||||
IN EFI_TPL Priority
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Initialize a basic mutual exclusion lock. Each lock
|
||||
provides mutual exclusion access at it's task priority
|
||||
level. Since there is no-premption (at any TPL) or
|
||||
multiprocessor support, acquiring the lock only consists
|
||||
of raising to the locks TPL.
|
||||
|
||||
Note on a debug build the lock is acquired and released
|
||||
to help ensure proper usage.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The FLOCK structure to initialize
|
||||
|
||||
Priority - The task priority level of the lock
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
An initialized F Lock structure.
|
||||
|
||||
--*/
|
||||
{
|
||||
Lock->Tpl = Priority;
|
||||
Lock->OwnerTpl = 0;
|
||||
Lock->Lock = 0;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
AcquireLock (
|
||||
IN FLOCK *Lock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Raising to the task priority level of the mutual exclusion
|
||||
lock, and then acquires ownership of the lock.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The lock to acquire
|
||||
|
||||
Returns:
|
||||
|
||||
Lock owned
|
||||
|
||||
--*/
|
||||
{
|
||||
RtAcquireLock (Lock);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
ReleaseLock (
|
||||
IN FLOCK *Lock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Releases ownership of the mutual exclusion lock, and
|
||||
restores the previous task priority level.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The lock to release
|
||||
|
||||
Returns:
|
||||
|
||||
Lock unowned
|
||||
|
||||
--*/
|
||||
{
|
||||
RtReleaseLock (Lock);
|
||||
}
|
||||
1
gnu-efi/lib/mips64el/efi_stub.S
Normal file
1
gnu-efi/lib/mips64el/efi_stub.S
Normal file
@@ -0,0 +1 @@
|
||||
/* This stub is a stub to make the build happy */
|
||||
26
gnu-efi/lib/mips64el/initplat.c
Normal file
26
gnu-efi/lib/mips64el/initplat.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copright (C) 2014 Linaro Ltd.
|
||||
* Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice and this list of conditions, without modification.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
InitializeLibPlatform (
|
||||
IN EFI_HANDLE ImageHandle EFI_UNUSED,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
|
||||
)
|
||||
{
|
||||
}
|
||||
63
gnu-efi/lib/mips64el/math.c
Normal file
63
gnu-efi/lib/mips64el/math.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copright (C) 2014 Linaro Ltd.
|
||||
* Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice and this list of conditions, without modification.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation;
|
||||
* either version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
UINT64
|
||||
LShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Left shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Operand << Count;
|
||||
}
|
||||
|
||||
UINT64
|
||||
RShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Right shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Operand >> Count;
|
||||
}
|
||||
|
||||
|
||||
UINT64
|
||||
MultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINTN Multiplier
|
||||
)
|
||||
// Multiple 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
return Multiplicand * Multiplier;
|
||||
}
|
||||
|
||||
UINT64
|
||||
DivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINTN Divisor,
|
||||
OUT UINTN *Remainder OPTIONAL
|
||||
)
|
||||
// divide 64bit by 32bit and get a 64bit result
|
||||
// N.B. only works for 31bit divisors!!
|
||||
{
|
||||
if (Remainder)
|
||||
*Remainder = Dividend % Divisor;
|
||||
return Dividend / Divisor;
|
||||
}
|
||||
92
gnu-efi/lib/mips64el/setjmp.S
Normal file
92
gnu-efi/lib/mips64el/setjmp.S
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
|
||||
* Copright (c) 2017 Lemote Co.
|
||||
* Author: Heiher <r@hev.cc>
|
||||
*
|
||||
* 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
|
||||
|
||||
.globl setjmp
|
||||
.type setjmp, @function
|
||||
setjmp:
|
||||
sd $ra, 0x00($a0)
|
||||
sd $sp, 0x08($a0)
|
||||
sd $fp, 0x10($a0)
|
||||
sd $gp, 0x18($a0)
|
||||
|
||||
sd $s0, 0x20($a0)
|
||||
sd $s1, 0x28($a0)
|
||||
sd $s2, 0x30($a0)
|
||||
sd $s3, 0x38($a0)
|
||||
sd $s4, 0x40($a0)
|
||||
sd $s5, 0x48($a0)
|
||||
sd $s6, 0x50($a0)
|
||||
sd $s7, 0x58($a0)
|
||||
|
||||
#ifdef __mips_hard_float
|
||||
mfc0 $v0, $12
|
||||
ext $v0, $v0, 29, 1
|
||||
beqz $v0, 1f
|
||||
|
||||
s.d $f24, 0x60($a0)
|
||||
s.d $f25, 0x68($a0)
|
||||
s.d $f26, 0x70($a0)
|
||||
s.d $f27, 0x78($a0)
|
||||
s.d $f28, 0x80($a0)
|
||||
s.d $f29, 0x88($a0)
|
||||
s.d $f30, 0x90($a0)
|
||||
s.d $f31, 0x98($a0)
|
||||
|
||||
1:
|
||||
#endif
|
||||
move $v0, $zero
|
||||
jr $ra
|
||||
|
||||
.globl longjmp
|
||||
.type longjmp, @function
|
||||
longjmp:
|
||||
ld $ra, 0x00($a0)
|
||||
ld $sp, 0x08($a0)
|
||||
ld $fp, 0x10($a0)
|
||||
ld $gp, 0x18($a0)
|
||||
|
||||
ld $s0, 0x20($a0)
|
||||
ld $s1, 0x28($a0)
|
||||
ld $s2, 0x30($a0)
|
||||
ld $s3, 0x38($a0)
|
||||
ld $s4, 0x40($a0)
|
||||
ld $s5, 0x48($a0)
|
||||
ld $s6, 0x50($a0)
|
||||
ld $s7, 0x58($a0)
|
||||
|
||||
#ifdef __mips_hard_float
|
||||
mfc0 $v0, $12
|
||||
ext $v0, $v0, 29, 1
|
||||
beqz $v0, 1f
|
||||
|
||||
l.d $f24, 0x60($a0)
|
||||
l.d $f25, 0x68($a0)
|
||||
l.d $f26, 0x70($a0)
|
||||
l.d $f27, 0x78($a0)
|
||||
l.d $f28, 0x80($a0)
|
||||
l.d $f29, 0x88($a0)
|
||||
l.d $f30, 0x90($a0)
|
||||
l.d $f31, 0x98($a0)
|
||||
|
||||
1:
|
||||
#endif
|
||||
li $v0, 1
|
||||
movn $v0, $a1, $a1
|
||||
jr $ra
|
||||
563
gnu-efi/lib/misc.c
Normal file
563
gnu-efi/lib/misc.c
Normal file
@@ -0,0 +1,563 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
misc.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
VOID *
|
||||
AllocatePool (
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *p;
|
||||
|
||||
Status = uefi_call_wrapper(BS->AllocatePool, 3, PoolAllocationType, Size, &p);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((D_ERROR, "AllocatePool: out of pool %x\n", Status));
|
||||
p = NULL;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
VOID *
|
||||
AllocateZeroPool (
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
VOID *p;
|
||||
|
||||
p = AllocatePool (Size);
|
||||
if (p) {
|
||||
ZeroMem (p, Size);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
VOID *
|
||||
ReallocatePool (
|
||||
IN VOID *OldPool,
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize
|
||||
)
|
||||
{
|
||||
VOID *NewPool;
|
||||
|
||||
NewPool = NULL;
|
||||
if (NewSize) {
|
||||
NewPool = AllocatePool (NewSize);
|
||||
}
|
||||
|
||||
if (OldPool) {
|
||||
if (NewPool) {
|
||||
CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
|
||||
}
|
||||
|
||||
FreePool (OldPool);
|
||||
}
|
||||
|
||||
return NewPool;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
FreePool (
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
uefi_call_wrapper(BS->FreePool, 1, Buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
ZeroMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
RtZeroMem (Buffer, Size);
|
||||
}
|
||||
|
||||
VOID
|
||||
SetMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
RtSetMem (Buffer, Size, Value);
|
||||
}
|
||||
|
||||
VOID
|
||||
CopyMem (
|
||||
IN VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
RtCopyMem (Dest, Src, len);
|
||||
}
|
||||
|
||||
INTN
|
||||
CompareMem (
|
||||
IN CONST VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
return RtCompareMem (Dest, Src, len);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
GrowBuffer(
|
||||
IN OUT EFI_STATUS *Status,
|
||||
IN OUT VOID **Buffer,
|
||||
IN UINTN BufferSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Helper function called as part of the code needed
|
||||
to allocate the proper sized buffer for various
|
||||
EFI interfaces.
|
||||
|
||||
Arguments:
|
||||
|
||||
Status - Current status
|
||||
|
||||
Buffer - Current allocated buffer, or NULL
|
||||
|
||||
BufferSize - Current buffer size needed
|
||||
|
||||
Returns:
|
||||
|
||||
TRUE - if the buffer was reallocated and the caller
|
||||
should try the API again.
|
||||
|
||||
--*/
|
||||
{
|
||||
BOOLEAN TryAgain;
|
||||
|
||||
//
|
||||
// If this is an initial request, buffer will be null with a new buffer size
|
||||
//
|
||||
|
||||
if (!*Buffer && BufferSize) {
|
||||
*Status = EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
//
|
||||
// If the status code is "buffer too small", resize the buffer
|
||||
//
|
||||
|
||||
TryAgain = FALSE;
|
||||
if (*Status == EFI_BUFFER_TOO_SMALL) {
|
||||
|
||||
if (*Buffer) {
|
||||
FreePool (*Buffer);
|
||||
}
|
||||
|
||||
*Buffer = AllocatePool (BufferSize);
|
||||
|
||||
if (*Buffer) {
|
||||
TryAgain = TRUE;
|
||||
} else {
|
||||
*Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If there's an error, free the buffer
|
||||
//
|
||||
|
||||
if (!TryAgain && EFI_ERROR(*Status) && *Buffer) {
|
||||
FreePool (*Buffer);
|
||||
*Buffer = NULL;
|
||||
}
|
||||
|
||||
return TryAgain;
|
||||
}
|
||||
|
||||
|
||||
EFI_MEMORY_DESCRIPTOR *
|
||||
LibMemoryMap (
|
||||
OUT UINTN *NoEntries,
|
||||
OUT UINTN *MapKey,
|
||||
OUT UINTN *DescriptorSize,
|
||||
OUT UINT32 *DescriptorVersion
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_MEMORY_DESCRIPTOR *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Buffer = NULL;
|
||||
BufferSize = sizeof(EFI_MEMORY_DESCRIPTOR);
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(BS->GetMemoryMap, 5, &BufferSize, Buffer, MapKey, DescriptorSize, DescriptorVersion);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert buffer size to NoEntries
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
*NoEntries = BufferSize / *DescriptorSize;
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
VOID *
|
||||
LibGetVariableAndSize (
|
||||
IN CHAR16 *Name,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
OUT UINTN *VarSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *Buffer;
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// Initialize for GrowBuffer loop
|
||||
//
|
||||
|
||||
Buffer = NULL;
|
||||
BufferSize = 100;
|
||||
|
||||
//
|
||||
// Call the real function
|
||||
//
|
||||
|
||||
while (GrowBuffer (&Status, &Buffer, BufferSize)) {
|
||||
Status = uefi_call_wrapper(
|
||||
RT->GetVariable,
|
||||
5,
|
||||
Name,
|
||||
VendorGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
}
|
||||
if (Buffer) {
|
||||
*VarSize = BufferSize;
|
||||
} else {
|
||||
*VarSize = 0;
|
||||
}
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
VOID *
|
||||
LibGetVariable (
|
||||
IN CHAR16 *Name,
|
||||
IN EFI_GUID *VendorGuid
|
||||
)
|
||||
{
|
||||
UINTN VarSize;
|
||||
|
||||
return LibGetVariableAndSize (Name, VendorGuid, &VarSize);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibDeleteVariable (
|
||||
IN CHAR16 *VarName,
|
||||
IN EFI_GUID *VarGuid
|
||||
)
|
||||
{
|
||||
VOID *VarBuf;
|
||||
EFI_STATUS Status;
|
||||
|
||||
VarBuf = LibGetVariable(VarName,VarGuid);
|
||||
|
||||
Status = EFI_NOT_FOUND;
|
||||
|
||||
if (VarBuf) {
|
||||
//
|
||||
// Delete variable from Storage
|
||||
//
|
||||
Status = uefi_call_wrapper(
|
||||
RT->SetVariable,
|
||||
5,
|
||||
VarName, VarGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
0, NULL
|
||||
);
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
FreePool(VarBuf);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibSetNVVariable (
|
||||
IN CHAR16 *VarName,
|
||||
IN EFI_GUID *VarGuid,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
RT->SetVariable,
|
||||
5,
|
||||
VarName, VarGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
DataSize, Data
|
||||
);
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
return (Status);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibSetVariable (
|
||||
IN CHAR16 *VarName,
|
||||
IN EFI_GUID *VarGuid,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
RT->SetVariable,
|
||||
5,
|
||||
VarName, VarGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
DataSize, Data
|
||||
);
|
||||
ASSERT (!EFI_ERROR(Status));
|
||||
return (Status);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibInsertToTailOfBootOrder (
|
||||
IN UINT16 BootOption,
|
||||
IN BOOLEAN OnlyInsertIfEmpty
|
||||
)
|
||||
{
|
||||
UINT16 *BootOptionArray;
|
||||
UINT16 *NewBootOptionArray;
|
||||
UINTN VarSize;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
|
||||
BootOptionArray = LibGetVariableAndSize (VarBootOrder, &EfiGlobalVariable, &VarSize);
|
||||
if (VarSize != 0 && OnlyInsertIfEmpty) {
|
||||
if (BootOptionArray) {
|
||||
FreePool (BootOptionArray);
|
||||
}
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
VarSize += sizeof(UINT16);
|
||||
NewBootOptionArray = AllocatePool (VarSize);
|
||||
|
||||
for (Index = 0; Index < ((VarSize/sizeof(UINT16)) - 1); Index++) {
|
||||
NewBootOptionArray[Index] = BootOptionArray[Index];
|
||||
}
|
||||
//
|
||||
// Insert in the tail of the array
|
||||
//
|
||||
NewBootOptionArray[Index] = BootOption;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
RT->SetVariable,
|
||||
5,
|
||||
VarBootOrder, &EfiGlobalVariable,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
VarSize, (VOID*) NewBootOptionArray
|
||||
);
|
||||
|
||||
if (NewBootOptionArray) {
|
||||
FreePool (NewBootOptionArray);
|
||||
}
|
||||
if (BootOptionArray) {
|
||||
FreePool (BootOptionArray);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
ValidMBR(
|
||||
IN MASTER_BOOT_RECORD *Mbr,
|
||||
IN EFI_BLOCK_IO *BlkIo
|
||||
)
|
||||
{
|
||||
UINT32 StartingLBA, EndingLBA;
|
||||
UINT32 NewEndingLBA;
|
||||
INTN i, j;
|
||||
BOOLEAN ValidMbr;
|
||||
|
||||
if (Mbr->Signature != MBR_SIGNATURE) {
|
||||
//
|
||||
// The BPB also has this signature, so it can not be used alone.
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ValidMbr = FALSE;
|
||||
for (i=0; i<MAX_MBR_PARTITIONS; i++) {
|
||||
if ( Mbr->Partition[i].OSIndicator == 0x00 || EXTRACT_UINT32(Mbr->Partition[i].SizeInLBA) == 0 ) {
|
||||
continue;
|
||||
}
|
||||
ValidMbr = TRUE;
|
||||
StartingLBA = EXTRACT_UINT32(Mbr->Partition[i].StartingLBA);
|
||||
EndingLBA = StartingLBA + EXTRACT_UINT32(Mbr->Partition[i].SizeInLBA) - 1;
|
||||
if (EndingLBA > BlkIo->Media->LastBlock) {
|
||||
//
|
||||
// Compatability Errata:
|
||||
// Some systems try to hide drive space with thier INT 13h driver
|
||||
// This does not hide space from the OS driver. This means the MBR
|
||||
// that gets created from DOS is smaller than the MBR created from
|
||||
// a real OS (NT & Win98). This leads to BlkIo->LastBlock being
|
||||
// wrong on some systems FDISKed by the OS.
|
||||
//
|
||||
//
|
||||
if (BlkIo->Media->LastBlock < MIN_MBR_DEVICE_SIZE) {
|
||||
//
|
||||
// If this is a very small device then trust the BlkIo->LastBlock
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (EndingLBA > (BlkIo->Media->LastBlock + MBR_ERRATA_PAD)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
for (j=i+1; j<MAX_MBR_PARTITIONS; j++) {
|
||||
if (Mbr->Partition[j].OSIndicator == 0x00 || EXTRACT_UINT32(Mbr->Partition[j].SizeInLBA) == 0) {
|
||||
continue;
|
||||
}
|
||||
if ( EXTRACT_UINT32(Mbr->Partition[j].StartingLBA) >= StartingLBA &&
|
||||
EXTRACT_UINT32(Mbr->Partition[j].StartingLBA) <= EndingLBA ) {
|
||||
//
|
||||
// The Start of this region overlaps with the i'th region
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
NewEndingLBA = EXTRACT_UINT32(Mbr->Partition[j].StartingLBA) + EXTRACT_UINT32(Mbr->Partition[j].SizeInLBA) - 1;
|
||||
if ( NewEndingLBA >= StartingLBA && NewEndingLBA <= EndingLBA ) {
|
||||
//
|
||||
// The End of this region overlaps with the i'th region
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Non of the regions overlapped so MBR is O.K.
|
||||
//
|
||||
return ValidMbr;
|
||||
}
|
||||
|
||||
|
||||
UINT8
|
||||
DecimaltoBCD(
|
||||
IN UINT8 DecValue
|
||||
)
|
||||
{
|
||||
return RtDecimaltoBCD (DecValue);
|
||||
}
|
||||
|
||||
|
||||
UINT8
|
||||
BCDtoDecimal(
|
||||
IN UINT8 BcdValue
|
||||
)
|
||||
{
|
||||
return RtBCDtoDecimal (BcdValue);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
LibGetSystemConfigurationTable(
|
||||
IN EFI_GUID *TableGuid,
|
||||
IN OUT VOID **Table
|
||||
)
|
||||
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for(Index=0;Index<ST->NumberOfTableEntries;Index++) {
|
||||
if (CompareGuid(TableGuid,&(ST->ConfigurationTable[Index].VendorGuid))==0) {
|
||||
*Table = ST->ConfigurationTable[Index].VendorTable;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
CHAR16 *
|
||||
LibGetUiString (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN UI_STRING_TYPE StringType,
|
||||
IN ISO_639_2 *LangCode,
|
||||
IN BOOLEAN ReturnDevicePathStrOnMismatch
|
||||
)
|
||||
{
|
||||
UI_INTERFACE *Ui;
|
||||
UI_STRING_TYPE Index;
|
||||
UI_STRING_ENTRY *Array;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handle, &UiProtocol, (VOID *)&Ui);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return (ReturnDevicePathStrOnMismatch) ? DevicePathToStr(DevicePathFromHandle(Handle)) : NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip the first strings
|
||||
//
|
||||
for (Index = UiDeviceString, Array = Ui->Entry; Index < StringType; Index++, Array++) {
|
||||
while (Array->LangCode) {
|
||||
Array++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Search for the match
|
||||
//
|
||||
while (Array->LangCode) {
|
||||
if (strcmpa (Array->LangCode, LangCode) == 0) {
|
||||
return Array->UiString;
|
||||
}
|
||||
}
|
||||
return (ReturnDevicePathStrOnMismatch) ? DevicePathToStr(DevicePathFromHandle(Handle)) : NULL;
|
||||
}
|
||||
1482
gnu-efi/lib/print.c
Normal file
1482
gnu-efi/lib/print.c
Normal file
File diff suppressed because it is too large
Load Diff
145
gnu-efi/lib/runtime/efirtlib.c
Normal file
145
gnu-efi/lib/runtime/efirtlib.c
Normal file
@@ -0,0 +1,145 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
EfiRtLib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI Runtime library functions
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "efi.h"
|
||||
#include "efilib.h"
|
||||
#include "efirtlib.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtZeroMem)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtZeroMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
INT8 *pt;
|
||||
|
||||
pt = Buffer;
|
||||
while (Size--) {
|
||||
*(pt++) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtSetMem)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtSetMem (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Size,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
INT8 *pt;
|
||||
|
||||
pt = Buffer;
|
||||
while (Size--) {
|
||||
*(pt++) = Value;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtCopyMem)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtCopyMem (
|
||||
IN VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
CHAR8 *d;
|
||||
CONST CHAR8 *s = Src;
|
||||
d = Dest;
|
||||
while (len--) {
|
||||
*(d++) = *(s++);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtCompareMem)
|
||||
#endif
|
||||
INTN
|
||||
RUNTIMEFUNCTION
|
||||
RtCompareMem (
|
||||
IN CONST VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
)
|
||||
{
|
||||
CONST CHAR8 *d = Dest, *s = Src;
|
||||
while (len--) {
|
||||
if (*d != *s) {
|
||||
return *d - *s;
|
||||
}
|
||||
|
||||
d += 1;
|
||||
s += 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtCompareGuid)
|
||||
#endif
|
||||
INTN
|
||||
RUNTIMEFUNCTION
|
||||
RtCompareGuid (
|
||||
IN EFI_GUID *Guid1,
|
||||
IN EFI_GUID *Guid2
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Compares to GUIDs
|
||||
|
||||
Arguments:
|
||||
|
||||
Guid1 - guid to compare
|
||||
Guid2 - guid to compare
|
||||
|
||||
Returns:
|
||||
= 0 if Guid1 == Guid2
|
||||
|
||||
--*/
|
||||
{
|
||||
INT32 *g1, *g2, r;
|
||||
|
||||
//
|
||||
// Compare 32 bits at a time
|
||||
//
|
||||
|
||||
g1 = (INT32 *) Guid1;
|
||||
g2 = (INT32 *) Guid2;
|
||||
|
||||
r = g1[0] - g2[0];
|
||||
r |= g1[1] - g2[1];
|
||||
r |= g1[2] - g2[2];
|
||||
r |= g1[3] - g2[3];
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
65
gnu-efi/lib/runtime/rtdata.c
Normal file
65
gnu-efi/lib/runtime/rtdata.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
data.c
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI library global data
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
// These globals are runtime globals
|
||||
//
|
||||
// N.B. The Microsoft C compiler will only put the data in the
|
||||
// right data section if it is explicitly initialized..
|
||||
//
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma BEGIN_RUNTIME_DATA()
|
||||
#endif
|
||||
|
||||
//
|
||||
// RT - pointer to the runtime table
|
||||
//
|
||||
|
||||
EFI_RUNTIME_SERVICES *RT;
|
||||
|
||||
//
|
||||
// LibStandalone - TRUE if lib is linked in as part of the firmware.
|
||||
// N.B. The EFI fw sets this value directly
|
||||
//
|
||||
|
||||
BOOLEAN LibFwInstance;
|
||||
|
||||
//
|
||||
// EFIDebug - Debug mask
|
||||
//
|
||||
|
||||
UINTN EFIDebug = EFI_DBUG_MASK;
|
||||
|
||||
//
|
||||
// LibRuntimeDebugOut - Runtime Debug Output device
|
||||
//
|
||||
|
||||
SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut;
|
||||
|
||||
//
|
||||
// LibRuntimeRaiseTPL, LibRuntimeRestoreTPL - pointers to Runtime functions from the
|
||||
// Boot Services Table
|
||||
//
|
||||
|
||||
EFI_RAISE_TPL LibRuntimeRaiseTPL = NULL;
|
||||
EFI_RESTORE_TPL LibRuntimeRestoreTPL = NULL;
|
||||
|
||||
102
gnu-efi/lib/runtime/rtlock.c
Normal file
102
gnu-efi/lib/runtime/rtlock.c
Normal file
@@ -0,0 +1,102 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
lock.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Implements FLOCK
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtAcquireLock)
|
||||
#endif
|
||||
VOID
|
||||
RtAcquireLock (
|
||||
IN FLOCK *Lock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Raising to the task priority level of the mutual exclusion
|
||||
lock, and then acquires ownership of the lock.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The lock to acquire
|
||||
|
||||
Returns:
|
||||
|
||||
Lock owned
|
||||
|
||||
--*/
|
||||
{
|
||||
if (BS) {
|
||||
if (BS->RaiseTPL != NULL) {
|
||||
Lock->OwnerTpl = uefi_call_wrapper(BS->RaiseTPL, 1, Lock->Tpl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (LibRuntimeRaiseTPL != NULL) {
|
||||
Lock->OwnerTpl = LibRuntimeRaiseTPL(Lock->Tpl);
|
||||
}
|
||||
}
|
||||
Lock->Lock += 1;
|
||||
ASSERT (Lock->Lock == 1);
|
||||
}
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtAcquireLock)
|
||||
#endif
|
||||
VOID
|
||||
RtReleaseLock (
|
||||
IN FLOCK *Lock
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Releases ownership of the mutual exclusion lock, and
|
||||
restores the previous task priority level.
|
||||
|
||||
Arguments:
|
||||
|
||||
Lock - The lock to release
|
||||
|
||||
Returns:
|
||||
|
||||
Lock unowned
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_TPL Tpl;
|
||||
|
||||
Tpl = Lock->OwnerTpl;
|
||||
ASSERT(Lock->Lock == 1);
|
||||
Lock->Lock -= 1;
|
||||
if (BS) {
|
||||
if (BS->RestoreTPL != NULL) {
|
||||
uefi_call_wrapper(BS->RestoreTPL, 1, Tpl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (LibRuntimeRestoreTPL != NULL) {
|
||||
LibRuntimeRestoreTPL(Tpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
231
gnu-efi/lib/runtime/rtstr.c
Normal file
231
gnu-efi/lib/runtime/rtstr.c
Normal file
@@ -0,0 +1,231 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
str.c
|
||||
|
||||
Abstract:
|
||||
|
||||
String runtime functions
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrCmp)
|
||||
#endif
|
||||
INTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
while (*s1) {
|
||||
if (*s1 != *s2) {
|
||||
break;
|
||||
}
|
||||
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
}
|
||||
|
||||
return *s1 - *s2;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrCpy)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
while (*Src) {
|
||||
*(Dest++) = *(Src++);
|
||||
}
|
||||
*Dest = 0;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrnCpy)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
UINTN Size = RtStrnLen(Src, Len);
|
||||
if (Size != Len)
|
||||
RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0');
|
||||
RtCopyMem(Dest, Src, Size * sizeof(CHAR16));
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStpCpy)
|
||||
#endif
|
||||
CHAR16 *
|
||||
RUNTIMEFUNCTION
|
||||
RtStpCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
while (*Src) {
|
||||
*(Dest++) = *(Src++);
|
||||
}
|
||||
*Dest = 0;
|
||||
return Dest;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStpnCpy)
|
||||
#endif
|
||||
CHAR16 *
|
||||
RUNTIMEFUNCTION
|
||||
RtStpnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
UINTN Size = RtStrnLen(Src, Len);
|
||||
if (Size != Len)
|
||||
RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0');
|
||||
RtCopyMem(Dest, Src, Size * sizeof(CHAR16));
|
||||
return Dest + Size;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrCat)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
{
|
||||
RtStrCpy(Dest+RtStrLen(Dest), Src);
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrnCat)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
{
|
||||
UINTN DestSize, Size;
|
||||
|
||||
DestSize = RtStrLen(Dest);
|
||||
Size = RtStrnLen(Src, Len);
|
||||
RtCopyMem(Dest + DestSize, Src, Size * sizeof(CHAR16));
|
||||
Dest[DestSize + Size] = '\0';
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrLen)
|
||||
#endif
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrLen (
|
||||
IN CONST CHAR16 *s1
|
||||
)
|
||||
// string length
|
||||
{
|
||||
UINTN len;
|
||||
|
||||
for (len=0; *s1; s1+=1, len+=1) ;
|
||||
return len;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrnLen)
|
||||
#endif
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrnLen (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN UINTN Len
|
||||
)
|
||||
// string length
|
||||
{
|
||||
UINTN i;
|
||||
for (i = 0; *s1 && i < Len; i++)
|
||||
s1++;
|
||||
return i;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtStrSize)
|
||||
#endif
|
||||
UINTN
|
||||
RUNTIMEFUNCTION
|
||||
RtStrSize (
|
||||
IN CONST CHAR16 *s1
|
||||
)
|
||||
// string size
|
||||
{
|
||||
UINTN len;
|
||||
|
||||
for (len=0; *s1; s1+=1, len+=1) ;
|
||||
return (len + 1) * sizeof(CHAR16);
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtBCDtoDecimal)
|
||||
#endif
|
||||
UINT8
|
||||
RUNTIMEFUNCTION
|
||||
RtBCDtoDecimal(
|
||||
IN UINT8 BcdValue
|
||||
)
|
||||
{
|
||||
UINTN High, Low;
|
||||
|
||||
High = BcdValue >> 4;
|
||||
Low = BcdValue - (High << 4);
|
||||
|
||||
return ((UINT8)(Low + (High * 10)));
|
||||
}
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtDecimaltoBCD)
|
||||
#endif
|
||||
UINT8
|
||||
RUNTIMEFUNCTION
|
||||
RtDecimaltoBCD (
|
||||
IN UINT8 DecValue
|
||||
)
|
||||
{
|
||||
UINTN High, Low;
|
||||
|
||||
High = DecValue / 10;
|
||||
Low = DecValue - (High * 10);
|
||||
|
||||
return ((UINT8)(Low + (High << 4)));
|
||||
}
|
||||
|
||||
|
||||
105
gnu-efi/lib/runtime/vm.c
Normal file
105
gnu-efi/lib/runtime/vm.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
vm.c
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI Hell to remap runtime address into the new virual address space
|
||||
that was registered by the OS for RT calls.
|
||||
|
||||
So the code image needs to be relocated. All pointers need to be
|
||||
manually fixed up since the address map changes.
|
||||
|
||||
GOOD LUCK NOT HAVING BUGS IN YOUR CODE! PLEASE TEST A LOT. MAKE SURE
|
||||
EXIT BOOTSERVICES OVER WRITES ALL BOOTSERVICE MEMORY & DATA SPACES WHEN
|
||||
YOU TEST.
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtLibEnableVirtualMappings)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtLibEnableVirtualMappings (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_CONVERT_POINTER ConvertPointer;
|
||||
|
||||
//
|
||||
// If this copy of the lib is linked into the firmware, then
|
||||
// do not update the pointers yet.
|
||||
//
|
||||
|
||||
if (!LibFwInstance) {
|
||||
|
||||
//
|
||||
// Different components are updating to the new virtual
|
||||
// mappings at differnt times. The only function that
|
||||
// is safe to call at this notification is ConvertAddress
|
||||
//
|
||||
|
||||
ConvertPointer = RT->ConvertPointer;
|
||||
|
||||
//
|
||||
// Fix any pointers that the lib created, that may be needed
|
||||
// during runtime.
|
||||
//
|
||||
|
||||
ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&RT);
|
||||
ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&LibRuntimeDebugOut);
|
||||
|
||||
ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRaiseTPL);
|
||||
ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRestoreTPL);
|
||||
|
||||
// that was it :^)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(RtConvertList)
|
||||
#endif
|
||||
VOID
|
||||
RUNTIMEFUNCTION
|
||||
RtConvertList (
|
||||
IN UINTN DebugDisposition,
|
||||
IN OUT LIST_ENTRY *ListHead
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
LIST_ENTRY *NextLink;
|
||||
EFI_CONVERT_POINTER ConvertPointer;
|
||||
|
||||
ConvertPointer = RT->ConvertPointer;
|
||||
|
||||
//
|
||||
// Convert all the Flink & Blink pointers in the list
|
||||
//
|
||||
|
||||
Link = ListHead;
|
||||
do {
|
||||
NextLink = Link->Flink;
|
||||
|
||||
ConvertPointer (
|
||||
Link->Flink == ListHead ? DebugDisposition : 0,
|
||||
(VOID **)&Link->Flink
|
||||
);
|
||||
|
||||
ConvertPointer (
|
||||
Link->Blink == ListHead ? DebugDisposition : 0,
|
||||
(VOID **)&Link->Blink
|
||||
);
|
||||
|
||||
Link = NextLink;
|
||||
} while (Link != ListHead);
|
||||
}
|
||||
135
gnu-efi/lib/smbios.c
Normal file
135
gnu-efi/lib/smbios.c
Normal file
@@ -0,0 +1,135 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2000 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Smbios.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Lib fucntions for SMBIOS. Used to get system serial number and GUID
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
/*
|
||||
* We convert 32 bit values to pointers. In 64 bit mode the compiler will issue a
|
||||
* warning stating that the value is too small for the pointer:
|
||||
* "warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]"
|
||||
* we can safely ignore them here.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||
#endif
|
||||
|
||||
EFI_STATUS
|
||||
LibGetSmbiosSystemGuidAndSerialNumber (
|
||||
IN EFI_GUID *SystemGuid,
|
||||
OUT CHAR8 **SystemSerialNumber
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
SMBIOS_STRUCTURE_TABLE *SmbiosTable;
|
||||
SMBIOS_STRUCTURE_POINTER Smbios;
|
||||
SMBIOS_STRUCTURE_POINTER SmbiosEnd;
|
||||
UINT16 Index;
|
||||
|
||||
Status = LibGetSystemConfigurationTable(&SMBIOSTableGuid, (VOID**)&SmbiosTable);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
Smbios.Hdr = (SMBIOS_HEADER *)SmbiosTable->TableAddress;
|
||||
SmbiosEnd.Raw = (UINT8 *)(SmbiosTable->TableAddress + SmbiosTable->TableLength);
|
||||
for (Index = 0; Index < SmbiosTable->TableLength ; Index++) {
|
||||
if (Smbios.Hdr->Type == 1) {
|
||||
if (Smbios.Hdr->Length < 0x19) {
|
||||
//
|
||||
// Older version did not support Guid and Serial number
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// SMBIOS tables are byte packed so we need to do a byte copy to
|
||||
// prevend alignment faults on IA-64.
|
||||
|
||||
CopyMem (SystemGuid, &Smbios.Type1->Uuid, sizeof(EFI_GUID));
|
||||
*SystemSerialNumber = LibGetSmbiosString(&Smbios, Smbios.Type1->SerialNumber);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Make Smbios point to the next record
|
||||
//
|
||||
LibGetSmbiosString (&Smbios, -1);
|
||||
|
||||
if (Smbios.Raw >= SmbiosEnd.Raw) {
|
||||
//
|
||||
// SMBIOS 2.1 incorrectly stated the length of SmbiosTable as 0x1e.
|
||||
// given this we must double check against the lenght of
|
||||
/// the structure. My home PC has this bug.ruthard
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
CHAR8*
|
||||
LibGetSmbiosString (
|
||||
IN SMBIOS_STRUCTURE_POINTER *Smbios,
|
||||
IN UINT16 StringNumber
|
||||
)
|
||||
/*++
|
||||
|
||||
Return SMBIOS string given the string number.
|
||||
|
||||
Arguments:
|
||||
Smbios - Pointer to SMBIOS structure
|
||||
StringNumber - String number to return. -1 is used to skip all strings and
|
||||
point to the next SMBIOS structure.
|
||||
|
||||
Returns:
|
||||
Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
|
||||
--*/
|
||||
{
|
||||
UINT16 Index;
|
||||
CHAR8 *String;
|
||||
|
||||
//
|
||||
// Skip over formatted section
|
||||
//
|
||||
String = (CHAR8 *)(Smbios->Raw + Smbios->Hdr->Length);
|
||||
|
||||
//
|
||||
// Look through unformated section
|
||||
//
|
||||
for (Index = 1; Index <= StringNumber; Index++) {
|
||||
if (StringNumber == Index) {
|
||||
return String;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip string
|
||||
//
|
||||
for (; *String != 0; String++);
|
||||
String++;
|
||||
|
||||
if (*String == 0) {
|
||||
//
|
||||
// If double NULL then we are done.
|
||||
// Retrun pointer to next structure in Smbios.
|
||||
// if you pass in a -1 you will always get here
|
||||
//
|
||||
Smbios->Raw = (UINT8 *)++String;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
358
gnu-efi/lib/sread.c
Normal file
358
gnu-efi/lib/sread.c
Normal file
@@ -0,0 +1,358 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
sread.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Simple read file access
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
#define SIMPLE_READ_SIGNATURE EFI_SIGNATURE_32('s','r','d','r')
|
||||
typedef struct _SIMPLE_READ_FILE {
|
||||
UINTN Signature;
|
||||
BOOLEAN FreeBuffer;
|
||||
VOID *Source;
|
||||
UINTN SourceSize;
|
||||
EFI_FILE_HANDLE FileHandle;
|
||||
} SIMPLE_READ_HANDLE;
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
OpenSimpleReadFile (
|
||||
IN BOOLEAN BootPolicy,
|
||||
IN VOID *SourceBuffer OPTIONAL,
|
||||
IN UINTN SourceSize,
|
||||
IN OUT EFI_DEVICE_PATH **FilePath,
|
||||
OUT EFI_HANDLE *DeviceHandle,
|
||||
OUT SIMPLE_READ_FILE *SimpleReadHandle
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Opens a file for (simple) reading. The simple read abstraction
|
||||
will access the file either from a memory copy, from a file
|
||||
system interface, or from the load file interface.
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
A handle to access the file
|
||||
|
||||
--*/
|
||||
{
|
||||
SIMPLE_READ_HANDLE *FHand;
|
||||
EFI_DEVICE_PATH *UserFilePath;
|
||||
EFI_DEVICE_PATH *TempFilePath;
|
||||
EFI_DEVICE_PATH *TempFilePathPtr;
|
||||
FILEPATH_DEVICE_PATH *FilePathNode;
|
||||
EFI_FILE_HANDLE FileHandle, LastHandle;
|
||||
EFI_STATUS Status;
|
||||
EFI_LOAD_FILE_INTERFACE *LoadFile;
|
||||
|
||||
FHand = NULL;
|
||||
UserFilePath = *FilePath;
|
||||
|
||||
//
|
||||
// Allocate a new simple read handle structure
|
||||
//
|
||||
|
||||
FHand = AllocateZeroPool (sizeof(SIMPLE_READ_HANDLE));
|
||||
if (!FHand) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
*SimpleReadHandle = (SIMPLE_READ_FILE) FHand;
|
||||
FHand->Signature = SIMPLE_READ_SIGNATURE;
|
||||
|
||||
//
|
||||
// If the caller passed a copy of the file, then just use it
|
||||
//
|
||||
|
||||
if (SourceBuffer) {
|
||||
FHand->Source = SourceBuffer;
|
||||
FHand->SourceSize = SourceSize;
|
||||
*DeviceHandle = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Attempt to access the file via a file system interface
|
||||
//
|
||||
|
||||
FileHandle = NULL;
|
||||
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &FileSystemProtocol, FilePath, DeviceHandle);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
FileHandle = LibOpenRoot (*DeviceHandle);
|
||||
}
|
||||
|
||||
Status = FileHandle ? EFI_SUCCESS : EFI_UNSUPPORTED;
|
||||
|
||||
//
|
||||
// To access as a filesystem, the filepath should only
|
||||
// contain filepath components. Follow the filepath nodes
|
||||
// and find the target file
|
||||
//
|
||||
|
||||
FilePathNode = (FILEPATH_DEVICE_PATH *) *FilePath;
|
||||
while (!IsDevicePathEnd(&FilePathNode->Header)) {
|
||||
|
||||
//
|
||||
// For filesystem access each node should be a filepath component
|
||||
//
|
||||
|
||||
if (DevicePathType(&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
|
||||
DevicePathSubType(&FilePathNode->Header) != MEDIA_FILEPATH_DP) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// If there's been an error, stop
|
||||
//
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Open this file path node
|
||||
//
|
||||
|
||||
LastHandle = FileHandle;
|
||||
FileHandle = NULL;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
LastHandle->Open,
|
||||
5,
|
||||
LastHandle,
|
||||
&FileHandle,
|
||||
FilePathNode->PathName,
|
||||
EFI_FILE_MODE_READ,
|
||||
0
|
||||
);
|
||||
|
||||
//
|
||||
// Close the last node
|
||||
//
|
||||
|
||||
uefi_call_wrapper(LastHandle->Close, 1, LastHandle);
|
||||
|
||||
//
|
||||
// Get the next node
|
||||
//
|
||||
|
||||
FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode(&FilePathNode->Header);
|
||||
}
|
||||
|
||||
//
|
||||
// If success, return the FHand
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
ASSERT(FileHandle);
|
||||
FHand->FileHandle = FileHandle;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup from filesystem access
|
||||
//
|
||||
|
||||
if (FileHandle) {
|
||||
uefi_call_wrapper(FileHandle->Close, 1, FileHandle);
|
||||
FileHandle = NULL;
|
||||
*FilePath = UserFilePath;
|
||||
}
|
||||
|
||||
//
|
||||
// If the error is something other then unsupported, return it
|
||||
//
|
||||
|
||||
if (Status != EFI_UNSUPPORTED) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Attempt to access the file via the load file protocol
|
||||
//
|
||||
|
||||
Status = LibDevicePathToInterface (&LoadFileProtocol, *FilePath, (VOID*)&LoadFile);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
|
||||
TempFilePath = DuplicateDevicePath (*FilePath);
|
||||
|
||||
TempFilePathPtr = TempFilePath;
|
||||
|
||||
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &LoadFileProtocol, &TempFilePath, DeviceHandle);
|
||||
|
||||
FreePool (TempFilePathPtr);
|
||||
|
||||
//
|
||||
// Determine the size of buffer needed to hold the file
|
||||
//
|
||||
|
||||
SourceSize = 0;
|
||||
Status = uefi_call_wrapper(
|
||||
LoadFile->LoadFile,
|
||||
5,
|
||||
LoadFile,
|
||||
*FilePath,
|
||||
BootPolicy,
|
||||
&SourceSize,
|
||||
NULL
|
||||
);
|
||||
|
||||
//
|
||||
// We expect a buffer too small error to inform us
|
||||
// of the buffer size needed
|
||||
//
|
||||
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
SourceBuffer = AllocatePool (SourceSize);
|
||||
|
||||
if (SourceBuffer) {
|
||||
FHand->FreeBuffer = TRUE;
|
||||
FHand->Source = SourceBuffer;
|
||||
FHand->SourceSize = SourceSize;
|
||||
|
||||
Status = uefi_call_wrapper(
|
||||
LoadFile->LoadFile,
|
||||
5,
|
||||
LoadFile,
|
||||
*FilePath,
|
||||
BootPolicy,
|
||||
&SourceSize,
|
||||
SourceBuffer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If success, return FHand
|
||||
//
|
||||
|
||||
if (!EFI_ERROR(Status) || Status == EFI_ALREADY_STARTED) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Nothing else to try
|
||||
//
|
||||
|
||||
DEBUG ((D_LOAD|D_WARN, "OpenSimpleReadFile: Device did not support a known load protocol\n"));
|
||||
Status = EFI_UNSUPPORTED;
|
||||
|
||||
Done:
|
||||
|
||||
//
|
||||
// If the file was not accessed, clean up
|
||||
//
|
||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
if (FHand) {
|
||||
if (FHand->FreeBuffer) {
|
||||
FreePool (FHand->Source);
|
||||
}
|
||||
|
||||
FreePool (FHand);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ReadSimpleReadFile (
|
||||
IN SIMPLE_READ_FILE UserHandle,
|
||||
IN UINTN Offset,
|
||||
IN OUT UINTN *ReadSize,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
UINTN EndPos;
|
||||
SIMPLE_READ_HANDLE *FHand;
|
||||
EFI_STATUS Status;
|
||||
|
||||
FHand = UserHandle;
|
||||
ASSERT (FHand->Signature == SIMPLE_READ_SIGNATURE);
|
||||
if (FHand->Source) {
|
||||
|
||||
//
|
||||
// Move data from our local copy of the file
|
||||
//
|
||||
|
||||
EndPos = Offset + *ReadSize;
|
||||
if (EndPos > FHand->SourceSize) {
|
||||
*ReadSize = FHand->SourceSize - Offset;
|
||||
if (Offset >= FHand->SourceSize) {
|
||||
*ReadSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CopyMem (Buffer, (CHAR8 *) FHand->Source + Offset, *ReadSize);
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
} else {
|
||||
|
||||
//
|
||||
// Read data from the file
|
||||
//
|
||||
|
||||
Status = uefi_call_wrapper(FHand->FileHandle->SetPosition, 2, FHand->FileHandle, Offset);
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = uefi_call_wrapper(FHand->FileHandle->Read, 3, FHand->FileHandle, ReadSize, Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
CloseSimpleReadFile (
|
||||
IN SIMPLE_READ_FILE UserHandle
|
||||
)
|
||||
{
|
||||
SIMPLE_READ_HANDLE *FHand;
|
||||
|
||||
FHand = UserHandle;
|
||||
ASSERT (FHand->Signature == SIMPLE_READ_SIGNATURE);
|
||||
|
||||
//
|
||||
// Free any file handle we opened
|
||||
//
|
||||
|
||||
if (FHand->FileHandle) {
|
||||
uefi_call_wrapper(FHand->FileHandle->Close, 1, FHand->FileHandle);
|
||||
}
|
||||
|
||||
//
|
||||
// If we allocated the Source buffer, free it
|
||||
//
|
||||
|
||||
if (FHand->FreeBuffer) {
|
||||
FreePool (FHand->Source);
|
||||
}
|
||||
|
||||
//
|
||||
// Done with this simple read file handle
|
||||
//
|
||||
|
||||
FreePool (FHand);
|
||||
}
|
||||
432
gnu-efi/lib/str.c
Normal file
432
gnu-efi/lib/str.c
Normal file
@@ -0,0 +1,432 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
str.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
INTN
|
||||
StrCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
return RtStrCmp(s1, s2);
|
||||
}
|
||||
|
||||
INTN
|
||||
StrnCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2,
|
||||
IN UINTN len
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
while (*s1 && len) {
|
||||
if (*s1 != *s2) {
|
||||
break;
|
||||
}
|
||||
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
return len ? *s1 - *s2 : 0;
|
||||
}
|
||||
|
||||
|
||||
INTN EFIAPI
|
||||
LibStubStriCmp (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
|
||||
IN CHAR16 *s1,
|
||||
IN CHAR16 *s2
|
||||
)
|
||||
{
|
||||
return StrCmp (s1, s2);
|
||||
}
|
||||
|
||||
VOID EFIAPI
|
||||
LibStubStrLwrUpr (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
|
||||
IN CHAR16 *Str EFI_UNUSED
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
INTN
|
||||
StriCmp (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN CONST CHAR16 *s2
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
if (UnicodeInterface == &LibStubUnicodeInterface)
|
||||
return UnicodeInterface->StriColl(UnicodeInterface, (CHAR16 *)s1, (CHAR16 *)s2);
|
||||
else
|
||||
return uefi_call_wrapper(UnicodeInterface->StriColl, 3, UnicodeInterface, (CHAR16 *)s1, (CHAR16 *)s2);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrLwr (
|
||||
IN CHAR16 *Str
|
||||
)
|
||||
// lwoer case string
|
||||
{
|
||||
if (UnicodeInterface == &LibStubUnicodeInterface)
|
||||
UnicodeInterface->StrLwr(UnicodeInterface, Str);
|
||||
else uefi_call_wrapper(UnicodeInterface->StrLwr, 2, UnicodeInterface, Str);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrUpr (
|
||||
IN CHAR16 *Str
|
||||
)
|
||||
// upper case string
|
||||
{
|
||||
if (UnicodeInterface == &LibStubUnicodeInterface)
|
||||
UnicodeInterface->StrUpr(UnicodeInterface, Str);
|
||||
else uefi_call_wrapper(UnicodeInterface->StrUpr, 2, UnicodeInterface, Str);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
RtStrCpy (Dest, Src);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
RtStrnCpy (Dest, Src, Len);
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
StpCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
return RtStpCpy (Dest, Src);
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
StpnCpy (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
// copy strings
|
||||
{
|
||||
return RtStpnCpy (Dest, Src, Len);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
{
|
||||
RtStrCat(Dest, Src);
|
||||
}
|
||||
|
||||
VOID
|
||||
StrnCat (
|
||||
IN CHAR16 *Dest,
|
||||
IN CONST CHAR16 *Src,
|
||||
IN UINTN Len
|
||||
)
|
||||
{
|
||||
RtStrnCat(Dest, Src, Len);
|
||||
}
|
||||
|
||||
|
||||
UINTN
|
||||
StrnLen (
|
||||
IN CONST CHAR16 *s1,
|
||||
IN UINTN Len
|
||||
)
|
||||
// string length
|
||||
{
|
||||
return RtStrnLen(s1, Len);
|
||||
}
|
||||
|
||||
UINTN
|
||||
StrLen (
|
||||
IN CONST CHAR16 *s1
|
||||
)
|
||||
// string length
|
||||
{
|
||||
return RtStrLen(s1);
|
||||
}
|
||||
|
||||
UINTN
|
||||
StrSize (
|
||||
IN CONST CHAR16 *s1
|
||||
)
|
||||
// string size
|
||||
{
|
||||
return RtStrSize(s1);
|
||||
}
|
||||
|
||||
CHAR16 *
|
||||
StrDuplicate (
|
||||
IN CONST CHAR16 *Src
|
||||
)
|
||||
// duplicate a string
|
||||
{
|
||||
CHAR16 *Dest;
|
||||
UINTN Size;
|
||||
|
||||
Size = StrSize(Src);
|
||||
Dest = AllocatePool (Size);
|
||||
if (Dest) {
|
||||
CopyMem (Dest, Src, Size);
|
||||
}
|
||||
return Dest;
|
||||
}
|
||||
|
||||
UINTN
|
||||
strlena (
|
||||
IN CONST CHAR8 *s1
|
||||
)
|
||||
// string length
|
||||
{
|
||||
UINTN len;
|
||||
|
||||
for (len=0; *s1; s1+=1, len+=1) ;
|
||||
return len;
|
||||
}
|
||||
|
||||
UINTN
|
||||
strcmpa (
|
||||
IN CONST CHAR8 *s1,
|
||||
IN CONST CHAR8 *s2
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
while (*s1) {
|
||||
if (*s1 != *s2) {
|
||||
break;
|
||||
}
|
||||
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
}
|
||||
|
||||
return *s1 - *s2;
|
||||
}
|
||||
|
||||
UINTN
|
||||
strncmpa (
|
||||
IN CONST CHAR8 *s1,
|
||||
IN CONST CHAR8 *s2,
|
||||
IN UINTN len
|
||||
)
|
||||
// compare strings
|
||||
{
|
||||
while (*s1 && len) {
|
||||
if (*s1 != *s2) {
|
||||
break;
|
||||
}
|
||||
|
||||
s1 += 1;
|
||||
s2 += 1;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
return len ? *s1 - *s2 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
UINTN
|
||||
xtoi (
|
||||
CONST CHAR16 *str
|
||||
)
|
||||
// convert hex string to uint
|
||||
{
|
||||
UINTN u;
|
||||
CHAR16 c;
|
||||
|
||||
// skip preceeding white space
|
||||
while (*str && *str == ' ') {
|
||||
str += 1;
|
||||
}
|
||||
|
||||
// convert hex digits
|
||||
u = 0;
|
||||
while ((c = *(str++))) {
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
c -= 'a' - 'A';
|
||||
}
|
||||
|
||||
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {
|
||||
u = (u << 4) | (c - (c >= 'A' ? 'A'-10 : '0'));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
UINTN
|
||||
Atoi (
|
||||
CONST CHAR16 *str
|
||||
)
|
||||
// convert hex string to uint
|
||||
{
|
||||
UINTN u;
|
||||
CHAR16 c;
|
||||
|
||||
// skip preceeding white space
|
||||
while (*str && *str == ' ') {
|
||||
str += 1;
|
||||
}
|
||||
|
||||
// convert digits
|
||||
u = 0;
|
||||
while ((c = *(str++))) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
u = (u * 10) + c - '0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
MetaMatch (
|
||||
IN CHAR16 *String,
|
||||
IN CHAR16 *Pattern
|
||||
)
|
||||
{
|
||||
CHAR16 c, p, l;
|
||||
|
||||
for (; ;) {
|
||||
p = *Pattern;
|
||||
Pattern += 1;
|
||||
|
||||
switch (p) {
|
||||
case 0:
|
||||
// End of pattern. If end of string, TRUE match
|
||||
return *String ? FALSE : TRUE;
|
||||
|
||||
case '*':
|
||||
// Match zero or more chars
|
||||
while (*String) {
|
||||
if (MetaMatch (String, Pattern)) {
|
||||
return TRUE;
|
||||
}
|
||||
String += 1;
|
||||
}
|
||||
return MetaMatch (String, Pattern);
|
||||
|
||||
case '?':
|
||||
// Match any one char
|
||||
if (!*String) {
|
||||
return FALSE;
|
||||
}
|
||||
String += 1;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
// Match char set
|
||||
c = *String;
|
||||
if (!c) {
|
||||
return FALSE; // syntax problem
|
||||
}
|
||||
|
||||
l = 0;
|
||||
while ((p = *Pattern++)) {
|
||||
if (p == ']') {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (p == '-') { // if range of chars,
|
||||
p = *Pattern; // get high range
|
||||
if (p == 0 || p == ']') {
|
||||
return FALSE; // syntax problem
|
||||
}
|
||||
|
||||
if (c >= l && c <= p) { // if in range,
|
||||
break; // it's a match
|
||||
}
|
||||
}
|
||||
|
||||
l = p;
|
||||
if (c == p) { // if char matches
|
||||
break; // move on
|
||||
}
|
||||
}
|
||||
|
||||
// skip to end of match char set
|
||||
while (p && p != ']') {
|
||||
p = *Pattern;
|
||||
Pattern += 1;
|
||||
}
|
||||
|
||||
String += 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
c = *String;
|
||||
if (c != p) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
String += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN EFIAPI
|
||||
LibStubMetaiMatch (
|
||||
IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED,
|
||||
IN CHAR16 *String,
|
||||
IN CHAR16 *Pattern
|
||||
)
|
||||
{
|
||||
return MetaMatch (String, Pattern);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
MetaiMatch (
|
||||
IN CHAR16 *String,
|
||||
IN CHAR16 *Pattern
|
||||
)
|
||||
{
|
||||
if (UnicodeInterface == &LibStubUnicodeInterface)
|
||||
return UnicodeInterface->MetaiMatch(UnicodeInterface, String, Pattern);
|
||||
else return uefi_call_wrapper(UnicodeInterface->MetaiMatch, 3, UnicodeInterface, String, Pattern);
|
||||
}
|
||||
40
gnu-efi/lib/x86_64/callwrap.c
Normal file
40
gnu-efi/lib/x86_64/callwrap.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Convert SysV calling convention to EFI x86_64 calling convention
|
||||
*
|
||||
* Copyright (C) 2007-2010 Intel Corp
|
||||
* Bibo Mao <bibo.mao@intel.com>
|
||||
* Chandramouli Narayanan<mouli@linux.intel.com>
|
||||
* Huang Ying <ying.huang@intel.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.
|
||||
*/
|
||||
|
||||
/* uefi_call_wrapper() is a macro in efibind.h */
|
||||
189
gnu-efi/lib/x86_64/efi_stub.S
Normal file
189
gnu-efi/lib/x86_64/efi_stub.S
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Function calling ABI conversion from Linux to EFI for x86_64
|
||||
*
|
||||
* Copyright (C) 2007 Intel Corp
|
||||
* Bibo Mao <bibo.mao@intel.com>
|
||||
* Huang Ying <ying.huang@intel.com>
|
||||
* Copyright (C) 2012 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
*/
|
||||
|
||||
#if !defined(HAVE_USE_MS_ABI)
|
||||
/*
|
||||
* EFI calling conventions are documented at:
|
||||
* http://msdn.microsoft.com/en-us/library/ms235286%28v=vs.80%29.aspx
|
||||
* ELF calling conventions are documented at:
|
||||
* http://www.x86-64.org/documentation/abi.pdf
|
||||
*
|
||||
* Basically here are the conversion rules:
|
||||
* a) our function pointer is in %rdi
|
||||
* b) rsi through r8 (elf) aka rcx through r9 (ms) require stack space
|
||||
* on the MS side even though it's not getting used at all.
|
||||
* c) 8(%rsp) is always aligned to 16 in ELF, so %rsp is shifted 8 bytes extra
|
||||
* d) arguments are as follows: (elf -> ms)
|
||||
* 1) rdi -> rcx (32 saved)
|
||||
* 2) rsi -> rdx (32 saved)
|
||||
* 3) rdx -> r8 (32 saved)
|
||||
* 4) rcx -> r9 (32 saved)
|
||||
* 5) r8 -> 32(%rsp) (32 saved)
|
||||
* 6) r9 -> 40(%rsp) (48 saved)
|
||||
* 7) 8(%rsp) -> 48(%rsp) (48 saved)
|
||||
* 8) 16(%rsp) -> 56(%rsp) (64 saved)
|
||||
* 9) 24(%rsp) -> 64(%rsp) (64 saved)
|
||||
* 10) 32(%rsp) -> 72(%rsp) (80 saved)
|
||||
* e) because the first argument we recieve in a thunker is actually the
|
||||
* function to be called, arguments are offset as such:
|
||||
* 0) rdi -> caller
|
||||
* 1) rsi -> rcx (32 saved)
|
||||
* 2) rdx -> rdx (32 saved)
|
||||
* 3) rcx -> r8 (32 saved)
|
||||
* 4) r8 -> r9 (32 saved)
|
||||
* 5) r9 -> 32(%rsp) (32 saved)
|
||||
* 6) 8(%rsp) -> 40(%rsp) (48 saved)
|
||||
* 7) 16(%rsp) -> 48(%rsp) (48 saved)
|
||||
* 8) 24(%rsp) -> 56(%rsp) (64 saved)
|
||||
* 9) 32(%rsp) -> 64(%rsp) (64 saved)
|
||||
* 10) 40(%rsp) -> 72(%rsp) (80 saved)
|
||||
* f) arguments need to be moved in opposite order to avoid clobbering
|
||||
*/
|
||||
|
||||
#define ENTRY(name) \
|
||||
.globl name; \
|
||||
name:
|
||||
|
||||
ENTRY(efi_call0)
|
||||
subq $40, %rsp
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call1)
|
||||
subq $40, %rsp
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call2)
|
||||
subq $40, %rsp
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call3)
|
||||
subq $40, %rsp
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call4)
|
||||
subq $40, %rsp
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call5)
|
||||
subq $40, %rsp
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $40, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call6)
|
||||
subq $56, %rsp
|
||||
mov 56+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $56, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call7)
|
||||
subq $56, %rsp
|
||||
mov 56+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 56+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $56, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call8)
|
||||
subq $72, %rsp
|
||||
mov 72+24(%rsp), %rax
|
||||
mov %rax, 56(%rsp)
|
||||
mov 72+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 72+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $72, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call9)
|
||||
subq $72, %rsp
|
||||
mov 72+32(%rsp), %rax
|
||||
mov %rax, 64(%rsp)
|
||||
mov 72+24(%rsp), %rax
|
||||
mov %rax, 56(%rsp)
|
||||
mov 72+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 72+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $72, %rsp
|
||||
ret
|
||||
|
||||
ENTRY(efi_call10)
|
||||
subq $88, %rsp
|
||||
mov 88+40(%rsp), %rax
|
||||
mov %rax, 72(%rsp)
|
||||
mov 88+32(%rsp), %rax
|
||||
mov %rax, 64(%rsp)
|
||||
mov 88+24(%rsp), %rax
|
||||
mov %rax, 56(%rsp)
|
||||
mov 88+16(%rsp), %rax
|
||||
mov %rax, 48(%rsp)
|
||||
mov 88+8(%rsp), %rax
|
||||
mov %rax, 40(%rsp)
|
||||
mov %r9, 32(%rsp)
|
||||
mov %r8, %r9
|
||||
mov %rcx, %r8
|
||||
/* mov %rdx, %rdx */
|
||||
mov %rsi, %rcx
|
||||
call *%rdi
|
||||
addq $88, %rsp
|
||||
ret
|
||||
|
||||
#endif
|
||||
27
gnu-efi/lib/x86_64/initplat.c
Normal file
27
gnu-efi/lib/x86_64/initplat.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
initplat.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
VOID
|
||||
InitializeLibPlatform (
|
||||
IN EFI_HANDLE ImageHandle EFI_UNUSED,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
181
gnu-efi/lib/x86_64/math.c
Normal file
181
gnu-efi/lib/x86_64/math.c
Normal file
@@ -0,0 +1,181 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1998 Intel Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
math.c
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
//
|
||||
// Declare runtime functions
|
||||
//
|
||||
|
||||
#ifdef RUNTIME_CODE
|
||||
#ifndef __GNUC__
|
||||
#pragma RUNTIME_CODE(LShiftU64)
|
||||
#pragma RUNTIME_CODE(RShiftU64)
|
||||
#pragma RUNTIME_CODE(MultU64x32)
|
||||
#pragma RUNTIME_CODE(DivU64x32)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
UINT64
|
||||
LShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Left shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
return Operand << Count;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Operand[0]
|
||||
mov edx, dword ptr Operand[4]
|
||||
mov ecx, Count
|
||||
and ecx, 63
|
||||
|
||||
shld edx, eax, cl
|
||||
shl eax, cl
|
||||
|
||||
cmp ecx, 32
|
||||
jc short ls10
|
||||
|
||||
mov edx, eax
|
||||
xor eax, eax
|
||||
|
||||
ls10:
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT64
|
||||
RShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
// Right shift 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
return Operand >> Count;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Operand[0]
|
||||
mov edx, dword ptr Operand[4]
|
||||
mov ecx, Count
|
||||
and ecx, 63
|
||||
|
||||
shrd eax, edx, cl
|
||||
shr edx, cl
|
||||
|
||||
cmp ecx, 32
|
||||
jc short rs10
|
||||
|
||||
mov eax, edx
|
||||
xor edx, edx
|
||||
|
||||
rs10:
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
UINT64
|
||||
MultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINTN Multiplier
|
||||
)
|
||||
// Multiple 64bit by 32bit and get a 64bit result
|
||||
{
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
return Multiplicand * Multiplier;
|
||||
#else
|
||||
UINT64 Result;
|
||||
_asm {
|
||||
mov eax, dword ptr Multiplicand[0]
|
||||
mul Multiplier
|
||||
mov dword ptr Result[0], eax
|
||||
mov dword ptr Result[4], edx
|
||||
mov eax, dword ptr Multiplicand[4]
|
||||
mul Multiplier
|
||||
add dword ptr Result[4], eax
|
||||
}
|
||||
|
||||
return Result;
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT64
|
||||
DivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINTN Divisor,
|
||||
OUT UINTN *Remainder OPTIONAL
|
||||
)
|
||||
// divide 64bit by 32bit and get a 64bit result
|
||||
// N.B. only works for 31bit divisors!!
|
||||
{
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
if (Remainder)
|
||||
*Remainder = Dividend % Divisor;
|
||||
return Dividend / Divisor;
|
||||
#else
|
||||
UINT32 Rem;
|
||||
UINT32 bit;
|
||||
|
||||
ASSERT (Divisor != 0);
|
||||
ASSERT ((Divisor >> 31) == 0);
|
||||
|
||||
//
|
||||
// For each bit in the dividend
|
||||
//
|
||||
|
||||
Rem = 0;
|
||||
for (bit=0; bit < 64; bit++) {
|
||||
_asm {
|
||||
shl dword ptr Dividend[0], 1 ; shift rem:dividend left one
|
||||
rcl dword ptr Dividend[4], 1
|
||||
rcl dword ptr Rem, 1
|
||||
|
||||
mov eax, Rem
|
||||
cmp eax, Divisor ; Is Rem >= Divisor?
|
||||
cmc ; No - do nothing
|
||||
sbb eax, eax ; Else,
|
||||
sub dword ptr Dividend[0], eax ; set low bit in dividen
|
||||
and eax, Divisor ; and
|
||||
sub Rem, eax ; subtract divisor
|
||||
}
|
||||
}
|
||||
|
||||
if (Remainder) {
|
||||
*Remainder = Rem;
|
||||
}
|
||||
|
||||
return Dividend;
|
||||
#endif
|
||||
}
|
||||
41
gnu-efi/lib/x86_64/setjmp.S
Normal file
41
gnu-efi/lib/x86_64/setjmp.S
Normal file
@@ -0,0 +1,41 @@
|
||||
.text
|
||||
.globl setjmp
|
||||
#ifndef __MINGW32__
|
||||
.type setjmp, @function
|
||||
#else
|
||||
.def setjmp; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
setjmp:
|
||||
pop %rsi
|
||||
movq %rbx,0x00(%rdi)
|
||||
movq %rsp,0x08(%rdi)
|
||||
push %rsi
|
||||
movq %rbp,0x10(%rdi)
|
||||
movq %r12,0x18(%rdi)
|
||||
movq %r13,0x20(%rdi)
|
||||
movq %r14,0x28(%rdi)
|
||||
movq %r15,0x30(%rdi)
|
||||
movq %rsi,0x38(%rdi)
|
||||
xor %rax,%rax
|
||||
ret
|
||||
|
||||
.globl longjmp
|
||||
#ifndef __MINGW32__
|
||||
.type longjmp, @function
|
||||
#else
|
||||
.def longjmp; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
longjmp:
|
||||
movl %esi, %eax
|
||||
movq 0x00(%rdi), %rbx
|
||||
movq 0x08(%rdi), %rsp
|
||||
movq 0x10(%rdi), %rbp
|
||||
movq 0x18(%rdi), %r12
|
||||
movq 0x20(%rdi), %r13
|
||||
movq 0x28(%rdi), %r14
|
||||
movq 0x30(%rdi), %r15
|
||||
xor %rdx,%rdx
|
||||
mov $1,%rcx
|
||||
cmp %rax,%rdx
|
||||
cmove %rcx,%rax
|
||||
jmp *0x38(%rdi)
|
||||
Reference in New Issue
Block a user