/trunk/boot/arch/ia64/loader/gefi/lib/runtime/rtlock.c |
---|
0,0 → 1,98 |
/*++ |
Copyright (c) 1998 Intel Corporation |
Module Name: |
lock.c |
Abstract: |
Implements FLOCK |
Revision History |
--*/ |
#include "lib.h" |
#pragma RUNTIME_CODE(RtAcquireLock) |
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 = BS->RaiseTPL(Lock->Tpl); |
} |
} |
else { |
if (LibRuntimeRaiseTPL != NULL) { |
Lock->OwnerTpl = LibRuntimeRaiseTPL(Lock->Tpl); |
} |
} |
Lock->Lock += 1; |
ASSERT (Lock->Lock == 1); |
} |
#pragma RUNTIME_CODE(RtAcquireLock) |
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) { |
BS->RestoreTPL (Tpl); |
} |
} |
else { |
if (LibRuntimeRestoreTPL != NULL) { |
LibRuntimeRestoreTPL(Tpl); |
} |
} |
} |
/trunk/boot/arch/ia64/loader/gefi/lib/runtime/rtstr.c |
---|
0,0 → 1,126 |
/*++ |
Copyright (c) 1998 Intel Corporation |
Module Name: |
str.c |
Abstract: |
String runtime functions |
Revision History |
--*/ |
#include "lib.h" |
#pragma RUNTIME_CODE(RtAcquireLock) |
INTN |
RUNTIMEFUNCTION |
RtStrCmp ( |
IN CHAR16 *s1, |
IN CHAR16 *s2 |
) |
// compare strings |
{ |
while (*s1) { |
if (*s1 != *s2) { |
break; |
} |
s1 += 1; |
s2 += 1; |
} |
return *s1 - *s2; |
} |
#pragma RUNTIME_CODE(RtStrCpy) |
VOID |
RUNTIMEFUNCTION |
RtStrCpy ( |
IN CHAR16 *Dest, |
IN CHAR16 *Src |
) |
// copy strings |
{ |
while (*Src) { |
*(Dest++) = *(Src++); |
} |
*Dest = 0; |
} |
#pragma RUNTIME_CODE(RtStrCat) |
VOID |
RUNTIMEFUNCTION |
RtStrCat ( |
IN CHAR16 *Dest, |
IN CHAR16 *Src |
) |
{ |
RtStrCpy(Dest+StrLen(Dest), Src); |
} |
#pragma RUNTIME_CODE(RtStrLen) |
UINTN |
RUNTIMEFUNCTION |
RtStrLen ( |
IN CHAR16 *s1 |
) |
// string length |
{ |
UINTN len; |
for (len=0; *s1; s1+=1, len+=1) ; |
return len; |
} |
#pragma RUNTIME_CODE(RtStrSize) |
UINTN |
RUNTIMEFUNCTION |
RtStrSize ( |
IN CHAR16 *s1 |
) |
// string size |
{ |
UINTN len; |
for (len=0; *s1; s1+=1, len+=1) ; |
return (len + 1) * sizeof(CHAR16); |
} |
#pragma RUNTIME_CODE(RtBCDtoDecimal) |
UINT8 |
RUNTIMEFUNCTION |
RtBCDtoDecimal( |
IN UINT8 BcdValue |
) |
{ |
UINTN High, Low; |
High = BcdValue >> 4; |
Low = BcdValue - (High << 4); |
return ((UINT8)(Low + (High * 10))); |
} |
#pragma RUNTIME_CODE(RtDecimaltoBCD) |
UINT8 |
RUNTIMEFUNCTION |
RtDecimaltoBCD ( |
IN UINT8 DecValue |
) |
{ |
UINTN High, Low; |
High = DecValue / 10; |
Low = DecValue - (High * 10); |
return ((UINT8)(Low + (High << 4))); |
} |
/trunk/boot/arch/ia64/loader/gefi/lib/runtime/rtdata.c |
---|
0,0 → 1,63 |
/*++ |
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.. |
// |
#pragma BEGIN_RUNTIME_DATA() |
// |
// 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; |
/trunk/boot/arch/ia64/loader/gefi/lib/runtime/efirtlib.c |
---|
0,0 → 1,139 |
/*++ |
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" |
#pragma RUNTIME_CODE(RtZeroMem) |
VOID |
RUNTIMEFUNCTION |
RtZeroMem ( |
IN VOID *Buffer, |
IN UINTN Size |
) |
{ |
INT8 *pt; |
pt = Buffer; |
while (Size--) { |
*(pt++) = 0; |
} |
} |
#pragma RUNTIME_CODE(RtSetMem) |
VOID |
RUNTIMEFUNCTION |
RtSetMem ( |
IN VOID *Buffer, |
IN UINTN Size, |
IN UINT8 Value |
) |
{ |
INT8 *pt; |
pt = Buffer; |
while (Size--) { |
*(pt++) = Value; |
} |
} |
#pragma RUNTIME_CODE(RtCopyMem) |
VOID |
RUNTIMEFUNCTION |
RtCopyMem ( |
IN VOID *Dest, |
IN VOID *Src, |
IN UINTN len |
) |
{ |
CHAR8 *d, *s; |
d = Dest; |
s = Src; |
while (len--) { |
*(d++) = *(s++); |
} |
} |
#pragma RUNTIME_CODE(RtCompareMem) |
INTN |
RUNTIMEFUNCTION |
RtCompareMem ( |
IN VOID *Dest, |
IN VOID *Src, |
IN UINTN len |
) |
{ |
CHAR8 *d, *s; |
d = Dest; |
s = Src; |
while (len--) { |
if (*d != *s) { |
return *d - *s; |
} |
d += 1; |
s += 1; |
} |
return 0; |
} |
#pragma RUNTIME_CODE(RtCompareGuid) |
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; |
} |
/trunk/boot/arch/ia64/loader/gefi/lib/runtime/vm.c |
---|
0,0 → 1,101 |
/*++ |
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" |
#pragma RUNTIME_CODE(RtLibEnableVirtualMappings) |
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 :^) |
} |
} |
#pragma RUNTIME_CODE(RtConvertList) |
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); |
} |