moved everything to chookspace
This commit is contained in:
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);
|
||||
}
|
||||
Reference in New Issue
Block a user