Initial import.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
41
MdePkg/Library/BaseLib/ARShiftU64.c
Normal file
41
MdePkg/Library/BaseLib/ARShiftU64.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
|
||||
with original integer's bit 63. The shifted value is returned.
|
||||
|
||||
This function shifts the 64-bit value Operand to the right by Count bits. The
|
||||
high Count bits are set to bit 63 of Operand. The shifted value is returned.
|
||||
|
||||
If Count is greater than 63, then ASSERT().
|
||||
|
||||
@param Operand The 64-bit operand to shift right.
|
||||
@param Count The number of bits to shift right.
|
||||
|
||||
@return Operand arithmetically shifted right by Count
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
ARShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
ASSERT (Count < sizeof (Operand) * 8);
|
||||
return InternalMathARShiftU64 (Operand, Count);
|
||||
}
|
30
MdePkg/Library/BaseLib/BaseLib.mbd
Normal file
30
MdePkg/Library/BaseLib/BaseLib.mbd
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 2006, 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.
|
||||
-->
|
||||
<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
|
||||
<MbdLibHeader>
|
||||
<BaseName>BaseLib</BaseName>
|
||||
<Guid>27d67720-ea68-48ae-93da-a3a074c90e30</Guid>
|
||||
<Version>0</Version>
|
||||
<Description>FIX ME!</Description>
|
||||
<Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
|
||||
<License>
|
||||
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.
|
||||
</License>
|
||||
<Created>2006-03-09 23:16</Created>
|
||||
<Modified>2006-03-22 18:15</Modified>
|
||||
</MbdLibHeader>
|
||||
</LibraryModuleBuildDescription>
|
309
MdePkg/Library/BaseLib/BaseLib.msa
Normal file
309
MdePkg/Library/BaseLib/BaseLib.msa
Normal file
@@ -0,0 +1,309 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 2006, 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.
|
||||
-->
|
||||
<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
|
||||
<MsaLibHeader>
|
||||
<BaseName>BaseLib</BaseName>
|
||||
<ModuleType>BASE</ModuleType>
|
||||
<ComponentType>LIBRARY</ComponentType>
|
||||
<Guid>27d67720-ea68-48ae-93da-a3a074c90e30</Guid>
|
||||
<Version>0</Version>
|
||||
<Abstract>Memory-only library functions with no library constructordestructor</Abstract>
|
||||
<Description>FIX ME!</Description>
|
||||
<Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
|
||||
<License>
|
||||
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.
|
||||
</License>
|
||||
<Specification>0</Specification>
|
||||
<Created>2006-03-09 23:16</Created>
|
||||
<Updated>2006-03-22 18:15</Updated>
|
||||
</MsaLibHeader>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_PRODUCED">BaseLib</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">TimerLib</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>String.c</Filename>
|
||||
<Filename>LinkedList.c</Filename>
|
||||
<Filename>Synchronization.c</Filename>
|
||||
<Filename>Cpu.c</Filename>
|
||||
<Filename>CpuDeadLoop.c</Filename>
|
||||
<Filename>BitField.c</Filename>
|
||||
<Filename>ARShiftU64.c</Filename>
|
||||
<Filename>DivS64x64Remainder.c</Filename>
|
||||
<Filename>DivU64x32.c</Filename>
|
||||
<Filename>DivU64x32Remainder.c</Filename>
|
||||
<Filename>DivU64x64Remainder.c</Filename>
|
||||
<Filename>GetPowerOfTwo32.c</Filename>
|
||||
<Filename>GetPowerOfTwo64.c</Filename>
|
||||
<Filename>HighBitSet32.c</Filename>
|
||||
<Filename>HighBitSet64.c</Filename>
|
||||
<Filename>LowBitSet32.c</Filename>
|
||||
<Filename>LowBitSet64.c</Filename>
|
||||
<Filename>LRotU32.c</Filename>
|
||||
<Filename>LRotU64.c</Filename>
|
||||
<Filename>LShiftU64.c</Filename>
|
||||
<Filename>ModU64x32.c</Filename>
|
||||
<Filename>MultS64x64.c</Filename>
|
||||
<Filename>MultU64x32.c</Filename>
|
||||
<Filename>MultU64x64.c</Filename>
|
||||
<Filename>RRotU32.c</Filename>
|
||||
<Filename>RRotU64.c</Filename>
|
||||
<Filename>RShiftU64.c</Filename>
|
||||
<Filename>SwapBytes16.c</Filename>
|
||||
<Filename>SwapBytes32.c</Filename>
|
||||
<Filename>SwapBytes64.c</Filename>
|
||||
<Arch ArchType="IA32">
|
||||
<Filename>x86LowLevel.c</Filename>
|
||||
<Filename>x86Thunk.c</Filename>
|
||||
<Filename>Unaligned.c</Filename>
|
||||
<Filename>Ia32\Non-existing.c</Filename>
|
||||
<Filename>Ia32\LShiftU64.asm</Filename>
|
||||
<Filename>Ia32\RShiftU64.asm</Filename>
|
||||
<Filename>Ia32\ARShiftU64.asm</Filename>
|
||||
<Filename>Ia32\LRotU64.asm</Filename>
|
||||
<Filename>Ia32\RRotU64.asm</Filename>
|
||||
<Filename>Ia32\MultU64x32.asm</Filename>
|
||||
<Filename>Ia32\MultU64x64.asm</Filename>
|
||||
<Filename>Ia32\DivU64x32.asm</Filename>
|
||||
<Filename>Ia32\ModU64x32.asm</Filename>
|
||||
<Filename>Ia32\DivU64x32Remainder.asm</Filename>
|
||||
<Filename>Ia32\DivU64x64Remainder.asm</Filename>
|
||||
<Filename>Ia32\DivS64x64Remainder.c</Filename>
|
||||
<Filename>Ia32\SwapBytes64.asm</Filename>
|
||||
<Filename>Ia32\SetJump.asm</Filename>
|
||||
<Filename>Ia32\LongJump.asm</Filename>
|
||||
<Filename>Ia32\SwitchStack.c</Filename>
|
||||
<Filename>Ia32\CpuId.asm</Filename>
|
||||
<Filename>Ia32\ReadEflags.asm</Filename>
|
||||
<Filename>Ia32\ReadMsr64.asm</Filename>
|
||||
<Filename>Ia32\WriteMsr32.asm</Filename>
|
||||
<Filename>Ia32\WriteMsr64.asm</Filename>
|
||||
<Filename>Ia32\ReadCr0.asm</Filename>
|
||||
<Filename>Ia32\ReadCr2.asm</Filename>
|
||||
<Filename>Ia32\ReadCr3.asm</Filename>
|
||||
<Filename>Ia32\ReadCr4.asm</Filename>
|
||||
<Filename>Ia32\WriteCr0.asm</Filename>
|
||||
<Filename>Ia32\WriteCr2.asm</Filename>
|
||||
<Filename>Ia32\WriteCr3.asm</Filename>
|
||||
<Filename>Ia32\WriteCr4.asm</Filename>
|
||||
<Filename>Ia32\ReadDr0.asm</Filename>
|
||||
<Filename>Ia32\ReadDr1.asm</Filename>
|
||||
<Filename>Ia32\ReadDr2.asm</Filename>
|
||||
<Filename>Ia32\ReadDr3.asm</Filename>
|
||||
<Filename>Ia32\ReadDr4.asm</Filename>
|
||||
<Filename>Ia32\ReadDr5.asm</Filename>
|
||||
<Filename>Ia32\ReadDr6.asm</Filename>
|
||||
<Filename>Ia32\ReadDr7.asm</Filename>
|
||||
<Filename>Ia32\WriteDr0.asm</Filename>
|
||||
<Filename>Ia32\WriteDr1.asm</Filename>
|
||||
<Filename>Ia32\WriteDr2.asm</Filename>
|
||||
<Filename>Ia32\WriteDr3.asm</Filename>
|
||||
<Filename>Ia32\WriteDr4.asm</Filename>
|
||||
<Filename>Ia32\WriteDr5.asm</Filename>
|
||||
<Filename>Ia32\WriteDr6.asm</Filename>
|
||||
<Filename>Ia32\WriteDr7.asm</Filename>
|
||||
<Filename>Ia32\ReadCs.asm</Filename>
|
||||
<Filename>Ia32\ReadDs.asm</Filename>
|
||||
<Filename>Ia32\ReadEs.asm</Filename>
|
||||
<Filename>Ia32\ReadFs.asm</Filename>
|
||||
<Filename>Ia32\ReadGs.asm</Filename>
|
||||
<Filename>Ia32\ReadSs.asm</Filename>
|
||||
<Filename>Ia32\ReadTr.asm</Filename>
|
||||
<Filename>Ia32\ReadGdtr.asm</Filename>
|
||||
<Filename>Ia32\WriteGdtr.asm</Filename>
|
||||
<Filename>Ia32\ReadIdtr.asm</Filename>
|
||||
<Filename>Ia32\WriteIdtr.asm</Filename>
|
||||
<Filename>Ia32\ReadLdtr.asm</Filename>
|
||||
<Filename>Ia32\WriteLdtr.asm</Filename>
|
||||
<Filename>Ia32\FxSave.asm</Filename>
|
||||
<Filename>Ia32\FxRestore.asm</Filename>
|
||||
<Filename>Ia32\ReadMm0.asm</Filename>
|
||||
<Filename>Ia32\ReadMm1.asm</Filename>
|
||||
<Filename>Ia32\ReadMm2.asm</Filename>
|
||||
<Filename>Ia32\ReadMm3.asm</Filename>
|
||||
<Filename>Ia32\ReadMm4.asm</Filename>
|
||||
<Filename>Ia32\ReadMm5.asm</Filename>
|
||||
<Filename>Ia32\ReadMm6.asm</Filename>
|
||||
<Filename>Ia32\ReadMm7.asm</Filename>
|
||||
<Filename>Ia32\WriteMm0.asm</Filename>
|
||||
<Filename>Ia32\WriteMm1.asm</Filename>
|
||||
<Filename>Ia32\WriteMm2.asm</Filename>
|
||||
<Filename>Ia32\WriteMm3.asm</Filename>
|
||||
<Filename>Ia32\WriteMm4.asm</Filename>
|
||||
<Filename>Ia32\WriteMm5.asm</Filename>
|
||||
<Filename>Ia32\WriteMm6.asm</Filename>
|
||||
<Filename>Ia32\WriteMm7.asm</Filename>
|
||||
<Filename>Ia32\ReadTsc.asm</Filename>
|
||||
<Filename>Ia32\ReadPmc.asm</Filename>
|
||||
<Filename>Ia32\Monitor.asm</Filename>
|
||||
<Filename>Ia32\Mwait.asm</Filename>
|
||||
<Filename>Ia32\EnablePaging32.asm</Filename>
|
||||
<Filename>Ia32\DisablePaging32.asm</Filename>
|
||||
<Filename>Ia32\EnablePaging64.asm</Filename>
|
||||
<Filename>Ia32\Wbinvd.asm</Filename>
|
||||
<Filename>Ia32\Invd.asm</Filename>
|
||||
<Filename>Ia32\FlushCacheLine.asm</Filename>
|
||||
<Filename>Ia32\InterlockedIncrement.asm</Filename>
|
||||
<Filename>Ia32\InterlockedDecrement.asm</Filename>
|
||||
<Filename>Ia32\InterlockedCompareExchange32.asm</Filename>
|
||||
<Filename>Ia32\InterlockedCompareExchange64.asm</Filename>
|
||||
<Filename>Ia32\EnableInterrupts.asm</Filename>
|
||||
<Filename>Ia32\DisableInterrupts.asm</Filename>
|
||||
<Filename>Ia32\EnableDisableInterrupts.asm</Filename>
|
||||
<Filename>Ia32\CpuSleep.asm</Filename>
|
||||
<Filename>Ia32\CpuPause.asm</Filename>
|
||||
<Filename>Ia32\CpuBreakpoint.asm</Filename>
|
||||
<Filename>Ia32\CpuFlushTlb.asm</Filename>
|
||||
<Filename>Ia32\Thunk16.asm</Filename>
|
||||
</Arch>
|
||||
<Arch ArchType="X64">
|
||||
<Filename>x86LowLevel.c</Filename>
|
||||
<Filename>x86Thunk.c</Filename>
|
||||
<Filename>Unaligned.c</Filename>
|
||||
<Filename>Math64.c</Filename>
|
||||
<Filename>x64\Non-existing.c</Filename>
|
||||
<Filename>x64\SwitchStack.asm</Filename>
|
||||
<Filename>x64\SetJump.asm</Filename>
|
||||
<Filename>x64\LongJump.asm</Filename>
|
||||
<Filename>x64\CpuId.asm</Filename>
|
||||
<Filename>x64\ReadEflags.asm</Filename>
|
||||
<Filename>x64\ReadMsr32.asm</Filename>
|
||||
<Filename>x64\ReadMsr64.asm</Filename>
|
||||
<Filename>x64\WriteMsr32.asm</Filename>
|
||||
<Filename>x64\WriteMsr64.asm</Filename>
|
||||
<Filename>x64\ReadCr0.asm</Filename>
|
||||
<Filename>x64\ReadCr2.asm</Filename>
|
||||
<Filename>x64\ReadCr3.asm</Filename>
|
||||
<Filename>x64\ReadCr4.asm</Filename>
|
||||
<Filename>x64\WriteCr0.asm</Filename>
|
||||
<Filename>x64\WriteCr2.asm</Filename>
|
||||
<Filename>x64\WriteCr3.asm</Filename>
|
||||
<Filename>x64\WriteCr4.asm</Filename>
|
||||
<Filename>x64\ReadDr0.asm</Filename>
|
||||
<Filename>x64\ReadDr1.asm</Filename>
|
||||
<Filename>x64\ReadDr2.asm</Filename>
|
||||
<Filename>x64\ReadDr3.asm</Filename>
|
||||
<Filename>x64\ReadDr4.asm</Filename>
|
||||
<Filename>x64\ReadDr5.asm</Filename>
|
||||
<Filename>x64\ReadDr6.asm</Filename>
|
||||
<Filename>x64\ReadDr7.asm</Filename>
|
||||
<Filename>x64\WriteDr0.asm</Filename>
|
||||
<Filename>x64\WriteDr1.asm</Filename>
|
||||
<Filename>x64\WriteDr2.asm</Filename>
|
||||
<Filename>x64\WriteDr3.asm</Filename>
|
||||
<Filename>x64\WriteDr4.asm</Filename>
|
||||
<Filename>x64\WriteDr5.asm</Filename>
|
||||
<Filename>x64\WriteDr6.asm</Filename>
|
||||
<Filename>x64\WriteDr7.asm</Filename>
|
||||
<Filename>x64\ReadCs.asm</Filename>
|
||||
<Filename>x64\ReadDs.asm</Filename>
|
||||
<Filename>x64\ReadEs.asm</Filename>
|
||||
<Filename>x64\ReadFs.asm</Filename>
|
||||
<Filename>x64\ReadGs.asm</Filename>
|
||||
<Filename>x64\ReadSs.asm</Filename>
|
||||
<Filename>x64\ReadTr.asm</Filename>
|
||||
<Filename>x64\ReadGdtr.asm</Filename>
|
||||
<Filename>x64\WriteGdtr.asm</Filename>
|
||||
<Filename>x64\ReadIdtr.asm</Filename>
|
||||
<Filename>x64\WriteIdtr.asm</Filename>
|
||||
<Filename>x64\ReadLdtr.asm</Filename>
|
||||
<Filename>x64\WriteLdtr.asm</Filename>
|
||||
<Filename>x64\FxSave.asm</Filename>
|
||||
<Filename>x64\FxRestore.asm</Filename>
|
||||
<Filename>x64\ReadMm0.asm</Filename>
|
||||
<Filename>x64\ReadMm1.asm</Filename>
|
||||
<Filename>x64\ReadMm2.asm</Filename>
|
||||
<Filename>x64\ReadMm3.asm</Filename>
|
||||
<Filename>x64\ReadMm4.asm</Filename>
|
||||
<Filename>x64\ReadMm5.asm</Filename>
|
||||
<Filename>x64\ReadMm6.asm</Filename>
|
||||
<Filename>x64\ReadMm7.asm</Filename>
|
||||
<Filename>x64\WriteMm0.asm</Filename>
|
||||
<Filename>x64\WriteMm1.asm</Filename>
|
||||
<Filename>x64\WriteMm2.asm</Filename>
|
||||
<Filename>x64\WriteMm3.asm</Filename>
|
||||
<Filename>x64\WriteMm4.asm</Filename>
|
||||
<Filename>x64\WriteMm5.asm</Filename>
|
||||
<Filename>x64\WriteMm6.asm</Filename>
|
||||
<Filename>x64\WriteMm7.asm</Filename>
|
||||
<Filename>x64\ReadTsc.asm</Filename>
|
||||
<Filename>x64\ReadPmc.asm</Filename>
|
||||
<Filename>x64\Monitor.asm</Filename>
|
||||
<Filename>x64\Mwait.asm</Filename>
|
||||
<Filename>x64\DisablePaging64.asm</Filename>
|
||||
<Filename>x64\Wbinvd.asm</Filename>
|
||||
<Filename>x64\Invd.asm</Filename>
|
||||
<Filename>x64\FlushCacheLine.asm</Filename>
|
||||
<Filename>x64\InterlockedIncrement.asm</Filename>
|
||||
<Filename>x64\InterlockedDecrement.asm</Filename>
|
||||
<Filename>x64\InterlockedCompareExchange32.asm</Filename>
|
||||
<Filename>x64\InterlockedCompareExchange64.asm</Filename>
|
||||
<Filename>x64\EnableInterrupts.asm</Filename>
|
||||
<Filename>x64\DisableInterrupts.asm</Filename>
|
||||
<Filename>x64\EnableDisableInterrupts.asm</Filename>
|
||||
<Filename>x64\CpuSleep.asm</Filename>
|
||||
<Filename>x64\CpuPause.asm</Filename>
|
||||
<Filename>x64\CpuBreakpoint.asm</Filename>
|
||||
<Filename>x64\CpuFlushTlb.asm</Filename>
|
||||
<Filename>x64\Thunk16.asm</Filename>
|
||||
</Arch>
|
||||
<Arch ArchType="IPF">
|
||||
<Filename>Math64.c</Filename>
|
||||
<Filename>Ipf\setjmp.s</Filename>
|
||||
<Filename>Ipf\SwitchStack.s</Filename>
|
||||
<Filename>Ipf\Unaligned.c</Filename>
|
||||
<Filename>Ipf\CpuBreakpoint.c</Filename>
|
||||
<Filename>Ipf\InterlockedCompareExchange32.s</Filename>
|
||||
<Filename>Ipf\InterlockedCompareExchange64.s</Filename>
|
||||
<Filename>Ipf\Synchronization.c</Filename>
|
||||
</Arch>
|
||||
<Arch ArchType="EBC">
|
||||
<Filename>Math64.c</Filename>
|
||||
<Filename>SwitchStack.c</Filename>
|
||||
<Filename>SetJumpLongJump.c</Filename>
|
||||
<Filename>Unaligned.c</Filename>
|
||||
<Filename>Ebc\CpuBreakpoint.c</Filename>
|
||||
</Arch>
|
||||
</SourceFiles>
|
||||
<Includes>
|
||||
<PackageName>MdePkg</PackageName>
|
||||
</Includes>
|
||||
<PCDs>
|
||||
<PcdData ItemType="FIXED_AT_BUILD">
|
||||
<C_Name>PcdMaximumUnicodeStringLength</C_Name>
|
||||
<Token>0x00000001</Token>
|
||||
<DatumType>UINT32</DatumType>
|
||||
</PcdData>
|
||||
<PcdData ItemType="FIXED_AT_BUILD">
|
||||
<C_Name>PcdMaximumAsciiStringLength</C_Name>
|
||||
<Token>0x00000002</Token>
|
||||
<DatumType>UINT32</DatumType>
|
||||
</PcdData>
|
||||
<PcdData ItemType="FIXED_AT_BUILD">
|
||||
<C_Name>PcdMaximumLinkedListLength</C_Name>
|
||||
<Token>0x00000003</Token>
|
||||
<DatumType>UINT32</DatumType>
|
||||
</PcdData>
|
||||
<PcdData ItemType="FIXED_AT_BUILD">
|
||||
<C_Name>PcdSpinLockTimeout</C_Name>
|
||||
<Token>0x00000004</Token>
|
||||
<DatumType>UINT32</DatumType>
|
||||
</PcdData>
|
||||
</PCDs>
|
||||
</LibraryModuleSurfaceArea>
|
195
MdePkg/Library/BaseLib/BaseLibInternals.h
Normal file
195
MdePkg/Library/BaseLib/BaseLibInternals.h
Normal file
@@ -0,0 +1,195 @@
|
||||
/** @file
|
||||
Declaration of internal functions in BaseLib.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: BaseLibInternals.h
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __BASE_LIB_INTERNALS__
|
||||
#define __BASE_LIB_INTERNALS__
|
||||
|
||||
//
|
||||
// Math functions
|
||||
//
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathLShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathRShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathARShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathLRotU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathRRotU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathSwapBytes64 (
|
||||
IN UINT64 Operand
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathMultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINT32 Multiplier
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathMultU64x64 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINT64 Multiplier
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathDivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor
|
||||
);
|
||||
|
||||
UINT32
|
||||
EFIAPI
|
||||
InternalMathModU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathDivRemU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor,
|
||||
OUT UINT32 *Remainder
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathDivRemU64x64 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT64 Divisor,
|
||||
OUT UINT64 *Remainder
|
||||
);
|
||||
|
||||
INT64
|
||||
EFIAPI
|
||||
InternalMathDivRemS64x64 (
|
||||
IN INT64 Dividend,
|
||||
IN INT64 Divisor,
|
||||
OUT INT64 *Remainder
|
||||
);
|
||||
|
||||
//
|
||||
// Ia32 and x64 specific functions
|
||||
//
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86ReadGdtr (
|
||||
OUT IA32_DESCRIPTOR *Gdtr
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86WriteGdtr (
|
||||
IN CONST IA32_DESCRIPTOR *Gdtr
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86ReadIdtr (
|
||||
OUT IA32_DESCRIPTOR *Idtr
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86WriteIdtr (
|
||||
IN CONST IA32_DESCRIPTOR *Idtr
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86FxSave (
|
||||
OUT IA32_FX_BUFFER *Buffer
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86FxRestore (
|
||||
IN CONST IA32_FX_BUFFER *Buffer
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86EnablePaging32 (
|
||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||
IN VOID *Context1, OPTIONAL
|
||||
IN VOID *Context2, OPTIONAL
|
||||
IN VOID *NewStack
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86DisablePaging32 (
|
||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||
IN VOID *Context1, OPTIONAL
|
||||
IN VOID *Context2, OPTIONAL
|
||||
IN VOID *NewStack
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86EnablePaging64 (
|
||||
IN UINT16 Cs,
|
||||
IN UINT64 EntryPoint,
|
||||
IN UINT64 Context1, OPTIONAL
|
||||
IN UINT64 Context2, OPTIONAL
|
||||
IN UINT64 NewStack
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
InternalX86DisablePaging64 (
|
||||
IN UINT16 Cs,
|
||||
IN UINT32 EntryPoint,
|
||||
IN UINT32 Context1, OPTIONAL
|
||||
IN UINT32 Context2, OPTIONAL
|
||||
IN UINT32 NewStack
|
||||
);
|
||||
|
||||
#endif
|
812
MdePkg/Library/BaseLib/BitField.c
Normal file
812
MdePkg/Library/BaseLib/BitField.c
Normal file
@@ -0,0 +1,812 @@
|
||||
/** @file
|
||||
Bit field functions of BaseLib.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: BitField.c
|
||||
|
||||
**/
|
||||
|
||||
unsigned int
|
||||
EFIAPI
|
||||
BitFieldReadUint (
|
||||
IN unsigned int Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit
|
||||
)
|
||||
{
|
||||
//
|
||||
// ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
|
||||
// are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
|
||||
//
|
||||
return (Operand & ~((unsigned int)-2 << EndBit)) >> StartBit;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
EFIAPI
|
||||
BitFieldOrUint (
|
||||
IN unsigned int Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN unsigned int OrData
|
||||
)
|
||||
{
|
||||
//
|
||||
// ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
|
||||
// are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
|
||||
//
|
||||
return Operand | ((OrData << StartBit) & ~((unsigned int)-2 << EndBit));
|
||||
}
|
||||
|
||||
unsigned int
|
||||
EFIAPI
|
||||
BitFieldAndUint (
|
||||
IN unsigned int Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN unsigned int AndData
|
||||
)
|
||||
{
|
||||
//
|
||||
// ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
|
||||
// are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
|
||||
//
|
||||
return Operand & ~((~AndData << StartBit) & ~((unsigned int)-2 << EndBit));
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a bit field from an 8-bit value.
|
||||
|
||||
Returns the bitfield specified by the StartBit and the EndBit from Operand.
|
||||
|
||||
If 8-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 7, then ASSERT().
|
||||
If EndBit is greater than 7, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..7.
|
||||
|
||||
@return The bit field read.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
BitFieldRead8 (
|
||||
IN UINT8 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT8)BitFieldReadUint (Operand, StartBit, EndBit);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a bit field to an 8-bit value, and returns the result.
|
||||
|
||||
Writes Value to the bit field specified by the StartBit and the EndBit in
|
||||
Operand. All other bits in Operand are preserved. The new 8-bit value is
|
||||
returned.
|
||||
|
||||
If 8-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 7, then ASSERT().
|
||||
If EndBit is greater than 7, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param Value New value of the bit field.
|
||||
|
||||
@return The new 8-bit value.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
BitFieldWrite8 (
|
||||
IN UINT8 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return BitFieldAndThenOr8 (Operand, StartBit, EndBit, 0, Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
|
||||
result.
|
||||
|
||||
Performs a bitwise inclusive OR between the bit field specified by StartBit
|
||||
and EndBit in Operand and the value specified by OrData. All other bits in
|
||||
Operand are preserved. The new 8-bit value is returned.
|
||||
|
||||
If 8-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 7, then ASSERT().
|
||||
If EndBit is greater than 7, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param OrData The value to OR with the read value from the value
|
||||
|
||||
@return The new 8-bit value.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
BitFieldOr8 (
|
||||
IN UINT8 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT8 OrData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT8)BitFieldOrUint (Operand, StartBit, EndBit, OrData);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
|
||||
the result.
|
||||
|
||||
Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
||||
in Operand and the value specified by AndData. All other bits in Operand are
|
||||
preserved. The new 8-bit value is returned.
|
||||
|
||||
If 8-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 7, then ASSERT().
|
||||
If EndBit is greater than 7, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param AndData The value to AND with the read value from the value.
|
||||
|
||||
@return The new 8-bit value.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
BitFieldAnd8 (
|
||||
IN UINT8 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT8 AndData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT8)BitFieldAndUint (Operand, StartBit, EndBit, AndData);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
|
||||
bitwise OR, and returns the result.
|
||||
|
||||
Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
||||
in Operand and the value specified by AndData, followed by a bitwise
|
||||
inclusive OR with value specified by OrData. All other bits in Operand are
|
||||
preserved. The new 8-bit value is returned.
|
||||
|
||||
If 8-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 7, then ASSERT().
|
||||
If EndBit is greater than 7, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..7.
|
||||
@param AndData The value to AND with the read value from the value.
|
||||
@param OrData The value to OR with the result of the AND operation.
|
||||
|
||||
@return The new 8-bit value.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
BitFieldAndThenOr8 (
|
||||
IN UINT8 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT8 AndData,
|
||||
IN UINT8 OrData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return BitFieldOr8 (
|
||||
BitFieldAnd8 (Operand, StartBit, EndBit, AndData),
|
||||
StartBit,
|
||||
EndBit,
|
||||
OrData
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a bit field from a 16-bit value.
|
||||
|
||||
Returns the bitfield specified by the StartBit and the EndBit from Operand.
|
||||
|
||||
If 16-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 15, then ASSERT().
|
||||
If EndBit is greater than 15, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..15.
|
||||
|
||||
@return The bit field read.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
BitFieldRead16 (
|
||||
IN UINT16 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT16)BitFieldReadUint (Operand, StartBit, EndBit);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a bit field to a 16-bit value, and returns the result.
|
||||
|
||||
Writes Value to the bit field specified by the StartBit and the EndBit in
|
||||
Operand. All other bits in Operand are preserved. The new 16-bit value is
|
||||
returned.
|
||||
|
||||
If 16-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 15, then ASSERT().
|
||||
If EndBit is greater than 15, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param Value New value of the bit field.
|
||||
|
||||
@return The new 16-bit value.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
BitFieldWrite16 (
|
||||
IN UINT16 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT16 Value
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return BitFieldAndThenOr16 (Operand, StartBit, EndBit, 0, Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
|
||||
result.
|
||||
|
||||
Performs a bitwise inclusive OR between the bit field specified by StartBit
|
||||
and EndBit in Operand and the value specified by OrData. All other bits in
|
||||
Operand are preserved. The new 16-bit value is returned.
|
||||
|
||||
If 16-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 15, then ASSERT().
|
||||
If EndBit is greater than 15, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param OrData The value to OR with the read value from the value
|
||||
|
||||
@return The new 16-bit value.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
BitFieldOr16 (
|
||||
IN UINT16 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT16 OrData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT16)BitFieldOrUint (Operand, StartBit, EndBit, OrData);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
|
||||
the result.
|
||||
|
||||
Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
||||
in Operand and the value specified by AndData. All other bits in Operand are
|
||||
preserved. The new 16-bit value is returned.
|
||||
|
||||
If 16-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 15, then ASSERT().
|
||||
If EndBit is greater than 15, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param AndData The value to AND with the read value from the value
|
||||
|
||||
@return The new 16-bit value.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
BitFieldAnd16 (
|
||||
IN UINT16 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT16 AndData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT16)BitFieldAndUint (Operand, StartBit, EndBit, AndData);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
|
||||
bitwise OR, and returns the result.
|
||||
|
||||
Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
||||
in Operand and the value specified by AndData, followed by a bitwise
|
||||
inclusive OR with value specified by OrData. All other bits in Operand are
|
||||
preserved. The new 16-bit value is returned.
|
||||
|
||||
If 16-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 15, then ASSERT().
|
||||
If EndBit is greater than 15, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..15.
|
||||
@param AndData The value to AND with the read value from the value.
|
||||
@param OrData The value to OR with the result of the AND operation.
|
||||
|
||||
@return The new 16-bit value.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
BitFieldAndThenOr16 (
|
||||
IN UINT16 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT16 AndData,
|
||||
IN UINT16 OrData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return BitFieldOr16 (
|
||||
BitFieldAnd16 (Operand, StartBit, EndBit, AndData),
|
||||
StartBit,
|
||||
EndBit,
|
||||
OrData
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a bit field from a 32-bit value.
|
||||
|
||||
Returns the bitfield specified by the StartBit and the EndBit from Operand.
|
||||
|
||||
If 32-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 31, then ASSERT().
|
||||
If EndBit is greater than 31, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..31.
|
||||
|
||||
@return The bit field read.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
BitFieldRead32 (
|
||||
IN UINT32 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT32)BitFieldReadUint (Operand, StartBit, EndBit);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a bit field to a 32-bit value, and returns the result.
|
||||
|
||||
Writes Value to the bit field specified by the StartBit and the EndBit in
|
||||
Operand. All other bits in Operand are preserved. The new 32-bit value is
|
||||
returned.
|
||||
|
||||
If 32-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 31, then ASSERT().
|
||||
If EndBit is greater than 31, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param Value New value of the bit field.
|
||||
|
||||
@return The new 32-bit value.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
BitFieldWrite32 (
|
||||
IN UINT32 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT32 Value
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return BitFieldAndThenOr32 (Operand, StartBit, EndBit, 0, Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
|
||||
result.
|
||||
|
||||
Performs a bitwise inclusive OR between the bit field specified by StartBit
|
||||
and EndBit in Operand and the value specified by OrData. All other bits in
|
||||
Operand are preserved. The new 32-bit value is returned.
|
||||
|
||||
If 32-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 31, then ASSERT().
|
||||
If EndBit is greater than 31, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param OrData The value to OR with the read value from the value
|
||||
|
||||
@return The new 32-bit value.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
BitFieldOr32 (
|
||||
IN UINT32 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT32 OrData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT32)BitFieldOrUint (Operand, StartBit, EndBit, OrData);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
|
||||
the result.
|
||||
|
||||
Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
||||
in Operand and the value specified by AndData. All other bits in Operand are
|
||||
preserved. The new 32-bit value is returned.
|
||||
|
||||
If 32-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 31, then ASSERT().
|
||||
If EndBit is greater than 31, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param AndData The value to AND with the read value from the value
|
||||
|
||||
@return The new 32-bit value.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
BitFieldAnd32 (
|
||||
IN UINT32 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT32 AndData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return (UINT32)BitFieldAndUint (Operand, StartBit, EndBit, AndData);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
|
||||
bitwise OR, and returns the result.
|
||||
|
||||
Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
||||
in Operand and the value specified by AndData, followed by a bitwise
|
||||
inclusive OR with value specified by OrData. All other bits in Operand are
|
||||
preserved. The new 32-bit value is returned.
|
||||
|
||||
If 32-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 31, then ASSERT().
|
||||
If EndBit is greater than 31, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..31.
|
||||
@param AndData The value to AND with the read value from the value.
|
||||
@param OrData The value to OR with the result of the AND operation.
|
||||
|
||||
@return The new 32-bit value.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
BitFieldAndThenOr32 (
|
||||
IN UINT32 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT32 AndData,
|
||||
IN UINT32 OrData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return BitFieldOr32 (
|
||||
BitFieldAnd32 (Operand, StartBit, EndBit, AndData),
|
||||
StartBit,
|
||||
EndBit,
|
||||
OrData
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a bit field from a 64-bit value.
|
||||
|
||||
Returns the bitfield specified by the StartBit and the EndBit from Operand.
|
||||
|
||||
If 64-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 63, then ASSERT().
|
||||
If EndBit is greater than 63, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..63.
|
||||
|
||||
@return The bit field read.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
BitFieldRead64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return RShiftU64 (Operand & ~LShiftU64 ((UINT64)-2, EndBit), StartBit);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a bit field to a 64-bit value, and returns the result.
|
||||
|
||||
Writes Value to the bit field specified by the StartBit and the EndBit in
|
||||
Operand. All other bits in Operand are preserved. The new 64-bit value is
|
||||
returned.
|
||||
|
||||
If 64-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 63, then ASSERT().
|
||||
If EndBit is greater than 63, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param Value New value of the bit field.
|
||||
|
||||
@return The new 64-bit value.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
BitFieldWrite64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT64 Value
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return BitFieldAndThenOr64 (Operand, StartBit, EndBit, 0, Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
|
||||
result.
|
||||
|
||||
Performs a bitwise inclusive OR between the bit field specified by StartBit
|
||||
and EndBit in Operand and the value specified by OrData. All other bits in
|
||||
Operand are preserved. The new 64-bit value is returned.
|
||||
|
||||
If 64-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 63, then ASSERT().
|
||||
If EndBit is greater than 63, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param OrData The value to OR with the read value from the value
|
||||
|
||||
@return The new 64-bit value.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
BitFieldOr64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT64 OrData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return Operand |
|
||||
(LShiftU64 (OrData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
|
||||
the result.
|
||||
|
||||
Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
||||
in Operand and the value specified by AndData. All other bits in Operand are
|
||||
preserved. The new 64-bit value is returned.
|
||||
|
||||
If 64-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 63, then ASSERT().
|
||||
If EndBit is greater than 63, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param AndData The value to AND with the read value from the value
|
||||
|
||||
@return The new 64-bit value.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
BitFieldAnd64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT64 AndData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return Operand &
|
||||
~(LShiftU64 (~AndData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
|
||||
bitwise OR, and returns the result.
|
||||
|
||||
Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
||||
in Operand and the value specified by AndData, followed by a bitwise
|
||||
inclusive OR with value specified by OrData. All other bits in Operand are
|
||||
preserved. The new 64-bit value is returned.
|
||||
|
||||
If 64-bit operations are not supported, then ASSERT().
|
||||
If StartBit is greater than 63, then ASSERT().
|
||||
If EndBit is greater than 63, then ASSERT().
|
||||
If EndBit is less than or equal to StartBit, then ASSERT().
|
||||
|
||||
@param Operand Operand on which to perform the bitfield operation.
|
||||
@param StartBit The ordinal of the least significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param EndBit The ordinal of the most significant bit in the bit field.
|
||||
Range 0..63.
|
||||
@param AndData The value to AND with the read value from the value.
|
||||
@param OrData The value to OR with the result of the AND operation.
|
||||
|
||||
@return The new 64-bit value.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
BitFieldAndThenOr64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN StartBit,
|
||||
IN UINTN EndBit,
|
||||
IN UINT64 AndData,
|
||||
IN UINT64 OrData
|
||||
)
|
||||
{
|
||||
ASSERT (EndBit < sizeof (Operand) * 8);
|
||||
ASSERT (StartBit <= EndBit);
|
||||
return BitFieldOr64 (
|
||||
BitFieldAnd64 (Operand, StartBit, EndBit, AndData),
|
||||
StartBit,
|
||||
EndBit,
|
||||
OrData
|
||||
);
|
||||
}
|
67
MdePkg/Library/BaseLib/Cpu.c
Normal file
67
MdePkg/Library/BaseLib/Cpu.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/** @file
|
||||
Base Library CPU Functions for all architectures.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: Cpu.c
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
Disables CPU interrupts and returns the interrupt state prior to the disable
|
||||
operation.
|
||||
|
||||
Disables CPU interrupts and returns the interrupt state prior to the disable
|
||||
operation.
|
||||
|
||||
@retval TRUE CPU interrupts were enabled on entry to this call.
|
||||
@retval FALSE CPU interrupts were disabled on entry to this call.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
SaveAndDisableInterrupts (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
BOOLEAN InterruptState;
|
||||
|
||||
InterruptState = GetInterruptState ();
|
||||
DisableInterrupts ();
|
||||
return InterruptState;
|
||||
}
|
||||
|
||||
/**
|
||||
Set the current CPU interrupt state.
|
||||
|
||||
Sets the current CPU interrupt state to the state specified by
|
||||
InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
|
||||
InterruptState is FALSE, then interrupts are disabled. InterruptState is
|
||||
returned.
|
||||
|
||||
@param InterruptState TRUE if interrupts should enabled. FALSE if
|
||||
interrupts should be disabled.
|
||||
|
||||
@return InterruptState
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
SetInterruptState (
|
||||
IN BOOLEAN InterruptState
|
||||
)
|
||||
{
|
||||
if (InterruptState) {
|
||||
EnableInterrupts ();
|
||||
} else {
|
||||
DisableInterrupts ();
|
||||
}
|
||||
return InterruptState;
|
||||
}
|
33
MdePkg/Library/BaseLib/CpuDeadLoop.c
Normal file
33
MdePkg/Library/BaseLib/CpuDeadLoop.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/** @file
|
||||
Base Library CPU Functions for all architectures.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
Executes an infinite loop.
|
||||
|
||||
Forces the CPU to execute an infinite loop. A debugger may be used to skip
|
||||
past the loop and the code that follows the loop must execute properly. This
|
||||
implies that the infinite loop must not cause the code that follow it to be
|
||||
optimized away.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
CpuDeadLoop (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
volatile UINTN Index;
|
||||
|
||||
for (Index = 0; Index == 0;);
|
||||
}
|
46
MdePkg/Library/BaseLib/DivS64x64Remainder.c
Normal file
46
MdePkg/Library/BaseLib/DivS64x64Remainder.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Divides a 64-bit signed integer by a 64-bit signed integer and generates a
|
||||
64-bit signed result and a optional 64-bit signed remainder.
|
||||
|
||||
This function divides the 64-bit signed value Dividend by the 64-bit signed
|
||||
value Divisor and generates a 64-bit signed quotient. If Remainder is not
|
||||
NULL, then the 64-bit signed remainder is returned in Remainder. This
|
||||
function returns the 64-bit signed quotient.
|
||||
|
||||
If Divisor is 0, then ASSERT().
|
||||
|
||||
@param Dividend A 64-bit signed value.
|
||||
@param Divisor A 64-bit signed value.
|
||||
@param Remainder A pointer to a 64-bit signed value. This parameter is
|
||||
optional and may be NULL.
|
||||
|
||||
@return Dividend / Divisor
|
||||
|
||||
**/
|
||||
INT64
|
||||
EFIAPI
|
||||
DivS64x64Remainder (
|
||||
IN INT64 Dividend,
|
||||
IN INT64 Divisor,
|
||||
OUT INT64 *Remainder
|
||||
)
|
||||
{
|
||||
ASSERT (Divisor != 0);
|
||||
return InternalMathDivRemS64x64 (Dividend, Divisor, Remainder);
|
||||
}
|
42
MdePkg/Library/BaseLib/DivU64x32.c
Normal file
42
MdePkg/Library/BaseLib/DivU64x32.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
|
||||
a 64-bit unsigned result.
|
||||
|
||||
This function divides the 64-bit unsigned value Dividend by the 32-bit
|
||||
unsigned value Divisor and generates a 64-bit unsigned quotient. This
|
||||
function returns the 64-bit unsigned quotient.
|
||||
|
||||
If Divisor is 0, then ASSERT().
|
||||
|
||||
@param Dividend A 64-bit unsigned value.
|
||||
@param Divisor A 32-bit unsigned value.
|
||||
|
||||
@return Dividend / Divisor
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
DivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor
|
||||
)
|
||||
{
|
||||
ASSERT (Divisor != 0);
|
||||
return InternalMathDivU64x32 (Dividend, Divisor);
|
||||
}
|
46
MdePkg/Library/BaseLib/DivU64x32Remainder.c
Normal file
46
MdePkg/Library/BaseLib/DivU64x32Remainder.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
|
||||
a 64-bit unsigned result and an optional 32-bit unsigned remainder.
|
||||
|
||||
This function divides the 64-bit unsigned value Dividend by the 32-bit
|
||||
unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
|
||||
is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
|
||||
This function returns the 64-bit unsigned quotient.
|
||||
|
||||
If Divisor is 0, then ASSERT().
|
||||
|
||||
@param Dividend A 64-bit unsigned value.
|
||||
@param Divisor A 32-bit unsigned value.
|
||||
@param Remainder A pointer to a 32-bit unsigned value. This parameter is
|
||||
optional and may be NULL.
|
||||
|
||||
@return Dividend / Divisor
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
DivU64x32Remainder (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor,
|
||||
OUT UINT32 *Remainder
|
||||
)
|
||||
{
|
||||
ASSERT (Divisor != 0);
|
||||
return InternalMathDivRemU64x32 (Dividend, Divisor, Remainder);
|
||||
}
|
46
MdePkg/Library/BaseLib/DivU64x64Remainder.c
Normal file
46
MdePkg/Library/BaseLib/DivU64x64Remainder.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
|
||||
a 64-bit unsigned result and an optional 64-bit unsigned remainder.
|
||||
|
||||
This function divides the 64-bit unsigned value Dividend by the 64-bit
|
||||
unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
|
||||
is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
|
||||
This function returns the 64-bit unsigned quotient.
|
||||
|
||||
If Divisor is 0, then ASSERT().
|
||||
|
||||
@param Dividend A 64-bit unsigned value.
|
||||
@param Divisor A 64-bit unsigned value.
|
||||
@param Remainder A pointer to a 64-bit unsigned value. This parameter is
|
||||
optional and may be NULL.
|
||||
|
||||
@return Dividend / Divisor
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
DivU64x64Remainder (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT64 Divisor,
|
||||
OUT UINT64 *Remainder
|
||||
)
|
||||
{
|
||||
ASSERT (Divisor != 0);
|
||||
return InternalMathDivRemU64x64 (Dividend, Divisor, Remainder);
|
||||
}
|
100
MdePkg/Library/BaseLib/Ebc/CpuBreakpoint.c
Normal file
100
MdePkg/Library/BaseLib/Ebc/CpuBreakpoint.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/** @file
|
||||
Base Library CPU Functions for EBC
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
extern
|
||||
UINT64
|
||||
_break (
|
||||
CHAR8 BreakCode
|
||||
);
|
||||
|
||||
/**
|
||||
Generates a breakpoint on the CPU.
|
||||
|
||||
Generates a breakpoint on the CPU. The breakpoint must be implemented such
|
||||
that code can resume normal execution after the breakpoint.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
CpuBreakpoint (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
_break (3);
|
||||
}
|
||||
|
||||
/**
|
||||
Used to serialize load and store operations.
|
||||
|
||||
All loads and stores that proceed calls to this function are guaranteed to be
|
||||
globally visible when this function returns.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
MemoryFence (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
Disables CPU interrupts.
|
||||
|
||||
Disables CPU interrupts.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
DisableInterrupts (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
Enables CPU interrupts.
|
||||
|
||||
Enables CPU interrupts.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
EnableInterrupts (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the current CPU interrupt state.
|
||||
|
||||
Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
|
||||
currently enabled. Otherwise returns FALSE.
|
||||
|
||||
@retval TRUE CPU interrupts are enabled.
|
||||
@retval FALSE CPU interrupts are disabled.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
GetInterruptState (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return FALSE;
|
||||
}
|
39
MdePkg/Library/BaseLib/GetPowerOfTwo32.c
Normal file
39
MdePkg/Library/BaseLib/GetPowerOfTwo32.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Returns the value of the highest bit set in a 32-bit value. Equivalent to
|
||||
1 << HighBitSet32(x).
|
||||
|
||||
This function computes the value of the highest bit set in the 32-bit value
|
||||
specified by Operand. If Operand is zero, then zero is returned.
|
||||
|
||||
@param Operand The 32-bit operand to evaluate.
|
||||
|
||||
@return 1 << HighBitSet32(Operand)
|
||||
@retval 0 Operand is zero.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
GetPowerOfTwo32 (
|
||||
IN UINT32 Operand
|
||||
)
|
||||
{
|
||||
INTN BitPos;
|
||||
|
||||
return (BitPos = HighBitSet32 (Operand)) > 0 ? 1ul << BitPos : 0;
|
||||
}
|
39
MdePkg/Library/BaseLib/GetPowerOfTwo64.c
Normal file
39
MdePkg/Library/BaseLib/GetPowerOfTwo64.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Returns the value of the highest bit set in a 64-bit value. Equivalent to
|
||||
1 << HighBitSet64(x).
|
||||
|
||||
This function computes the value of the highest bit set in the 64-bit value
|
||||
specified by Operand. If Operand is zero, then zero is returned.
|
||||
|
||||
@param Operand The 64-bit operand to evaluate.
|
||||
|
||||
@return 1 << HighBitSet64(Operand)
|
||||
@retval 0 Operand is zero.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPowerOfTwo64 (
|
||||
IN UINT64 Operand
|
||||
)
|
||||
{
|
||||
INTN BitPos;
|
||||
|
||||
return (BitPos = HighBitSet64 (Operand)) > 0 ? LShiftU64 (1, BitPos) : 0;
|
||||
}
|
41
MdePkg/Library/BaseLib/HighBitSet32.c
Normal file
41
MdePkg/Library/BaseLib/HighBitSet32.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Returns the bit position of the highest bit set in a 32-bit value. Equivalent
|
||||
to log2(x).
|
||||
|
||||
This function computes the bit position of the highest bit set in the 32-bit
|
||||
value specified by Operand. If Operand is zero, then -1 is returned.
|
||||
Otherwise, a value between 0 and 31 is returned.
|
||||
|
||||
@param Operand The 32-bit operand to evaluate.
|
||||
|
||||
@return Position of the highest bit set in Operand if found.
|
||||
@retval -1 Operand is zero.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
HighBitSet32 (
|
||||
IN UINT32 Operand
|
||||
)
|
||||
{
|
||||
INTN BitIndex;
|
||||
|
||||
for (BitIndex = -1; Operand != 0; BitIndex++, Operand >>= 1);
|
||||
return BitIndex;
|
||||
}
|
43
MdePkg/Library/BaseLib/HighBitSet64.c
Normal file
43
MdePkg/Library/BaseLib/HighBitSet64.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Returns the bit position of the highest bit set in a 64-bit value. Equivalent
|
||||
to log2(x).
|
||||
|
||||
This function computes the bit position of the highest bit set in the 64-bit
|
||||
value specified by Operand. If Operand is zero, then -1 is returned.
|
||||
Otherwise, a value between 0 and 63 is returned.
|
||||
|
||||
@param Operand The 64-bit operand to evaluate.
|
||||
|
||||
@return Position of the highest bit set in Operand if found.
|
||||
@retval -1 Operand is zero.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
HighBitSet64 (
|
||||
IN UINT64 Operand
|
||||
)
|
||||
{
|
||||
INTN BitIndex;
|
||||
|
||||
for (BitIndex = -1;
|
||||
Operand != 0;
|
||||
BitIndex++, Operand = RShiftU64 (Operand, 1));
|
||||
return BitIndex;
|
||||
}
|
101
MdePkg/Library/BaseLib/Ipf/CpuBreakpoint.c
Normal file
101
MdePkg/Library/BaseLib/Ipf/CpuBreakpoint.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/** @file
|
||||
Base Library CPU functions for Itanium
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
//void __mfa (void);
|
||||
|
||||
#pragma intrinsic (_enable)
|
||||
#pragma intrinsic (_disable)
|
||||
#pragma intrinsic (__break)
|
||||
#pragma intrinsic (__mfa)
|
||||
|
||||
/**
|
||||
Generates a breakpoint on the CPU.
|
||||
|
||||
Generates a breakpoint on the CPU. The breakpoint must be implemented such
|
||||
that code can resume normal execution after the breakpoint.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
CpuBreakpoint (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
__break (0);
|
||||
}
|
||||
|
||||
/**
|
||||
Used to serialize load and store operations.
|
||||
|
||||
All loads and stores that proceed calls to this function are guaranteed to be
|
||||
globally visible when this function returns.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
MemoryFence (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
__mfa ();
|
||||
}
|
||||
|
||||
/**
|
||||
Disables CPU interrupts.
|
||||
|
||||
Disables CPU interrupts.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
DisableInterrupts (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
_disable ();
|
||||
}
|
||||
|
||||
/**
|
||||
Enables CPU interrupts.
|
||||
|
||||
Enables CPU interrupts.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
EnableInterrupts (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
_enable ();
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the current CPU interrupt state.
|
||||
|
||||
Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
|
||||
currently enabled. Otherwise returns FALSE.
|
||||
|
||||
@retval TRUE CPU interrupts are enabled.
|
||||
@retval FALSE CPU interrupts are disabled.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
GetInterruptState (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
29
MdePkg/Library/BaseLib/Ipf/InterlockedCompareExchange32.s
Normal file
29
MdePkg/Library/BaseLib/Ipf/InterlockedCompareExchange32.s
Normal file
@@ -0,0 +1,29 @@
|
||||
/// @file
|
||||
/// Contains an implementation of InterlockedCompareExchange32 on Itanium-
|
||||
/// based architecture.
|
||||
///
|
||||
/// Copyright (c) 2006, 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.
|
||||
///
|
||||
/// Module Name: InterlockedCompareExchange32.s
|
||||
///
|
||||
///
|
||||
|
||||
.auto
|
||||
.text
|
||||
|
||||
.proc InternalSyncCompareExchange32
|
||||
.type InternalSyncCompareExchange32, @function
|
||||
InternalSyncCompareExchange32::
|
||||
zxt4 r33 = r33
|
||||
mov ar.ccv = r33
|
||||
cmpxchg4.rel r8 = [r32], r34
|
||||
mf
|
||||
br.ret.sptk.many b0
|
||||
.endp InternalSyncCompareExchange32
|
28
MdePkg/Library/BaseLib/Ipf/InterlockedCompareExchange64.s
Normal file
28
MdePkg/Library/BaseLib/Ipf/InterlockedCompareExchange64.s
Normal file
@@ -0,0 +1,28 @@
|
||||
/// @file
|
||||
/// Contains an implementation of InterlockedCompareExchange64 on Itanium-
|
||||
/// based architecture.
|
||||
///
|
||||
/// Copyright (c) 2006, 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.
|
||||
///
|
||||
/// Module Name: InterlockedCompareExchange64.s
|
||||
///
|
||||
///
|
||||
|
||||
.auto
|
||||
.text
|
||||
|
||||
.proc InternalSyncCompareExchange64
|
||||
.type InternalSyncCompareExchange64, @function
|
||||
InternalSyncCompareExchange64::
|
||||
mov ar.ccv = r33
|
||||
cmpxchg8.rel r8 = [r64], r34
|
||||
mf
|
||||
br.ret.sptk.many b0
|
||||
.endp InternalSyncCompareExchange64
|
122
MdePkg/Library/BaseLib/Ipf/SwitchStack.s
Normal file
122
MdePkg/Library/BaseLib/Ipf/SwitchStack.s
Normal file
@@ -0,0 +1,122 @@
|
||||
//++
|
||||
// Copyright (c) 2006, 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.
|
||||
//
|
||||
// Module Name:
|
||||
//
|
||||
// SwitchStack.s
|
||||
//
|
||||
// Abstract:
|
||||
//
|
||||
// Contains an implementation of a stack switch for the Itanium-based architecture.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Revision History:
|
||||
//
|
||||
//--
|
||||
|
||||
.file "SwitchStack.s"
|
||||
|
||||
#include "asm.h"
|
||||
#include "ia_64gen.h"
|
||||
|
||||
// Define hardware RSE Configuration Register
|
||||
//
|
||||
// RS Configuration (RSC) bit field positions
|
||||
|
||||
#define RSC_MODE 0
|
||||
#define RSC_PL 2
|
||||
#define RSC_BE 4
|
||||
// RSC bits 5-15 reserved
|
||||
#define RSC_MBZ0 5
|
||||
#define RSC_MBZ0_V 0x3ff
|
||||
#define RSC_LOADRS 16
|
||||
#define RSC_LOADRS_LEN 14
|
||||
// RSC bits 30-63 reserved
|
||||
#define RSC_MBZ1 30
|
||||
#define RSC_MBZ1_V 0x3ffffffffULL
|
||||
|
||||
// RSC modes
|
||||
// Lazy
|
||||
#define RSC_MODE_LY (0x0)
|
||||
// Store intensive
|
||||
#define RSC_MODE_SI (0x1)
|
||||
// Load intensive
|
||||
#define RSC_MODE_LI (0x2)
|
||||
// Eager
|
||||
#define RSC_MODE_EA (0x3)
|
||||
|
||||
// RSC Endian bit values
|
||||
#define RSC_BE_LITTLE 0
|
||||
#define RSC_BE_BIG 1
|
||||
|
||||
// RSC while in kernel: enabled, little endian, pl = 0, eager mode
|
||||
#define RSC_KERNEL ((RSC_MODE_EA<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
|
||||
// Lazy RSC in kernel: enabled, little endian, pl = 0, lazy mode
|
||||
#define RSC_KERNEL_LAZ ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
|
||||
// RSE disabled: disabled, pl = 0, little endian, eager mode
|
||||
#define RSC_KERNEL_DISABLED ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
|
||||
|
||||
|
||||
//VOID
|
||||
//SwitchStack (
|
||||
// VOID *ContinuationFunction,
|
||||
// UINTN Parameter,
|
||||
// UINTN NewTopOfStack,
|
||||
// UINTN NewBSPStore OPTIONAL
|
||||
//)
|
||||
///*++
|
||||
//
|
||||
//Input Arguments
|
||||
//
|
||||
// ContinuationFunction - This is a pointer to the PLABEL of the function that should be called once the
|
||||
// new stack has been created.
|
||||
// Parameter - The parameter to pass to the continuation function
|
||||
// NewTopOfStack - This is the new top of the memory stack for ensuing code. This is mandatory and
|
||||
// should be non-zero
|
||||
// NewBSPStore - This is the new BSP store for the ensuing code. It is optional on IA-32 and mandatory on Itanium-based platform.
|
||||
//
|
||||
//--*/
|
||||
|
||||
PROCEDURE_ENTRY(SwitchStack)
|
||||
|
||||
mov r16 = -0x10;;
|
||||
and r16 = r34, r16;; // get new stack value in R16, 0 the last nibble.
|
||||
mov r15 = r35;; // Get new BspStore into R15
|
||||
mov r13 = r32;; // this is a pointer to the PLABEL of the continuation function.
|
||||
mov r17 = r33;; // this is the parameter to pass to the continuation function
|
||||
|
||||
alloc r11=0,0,0,0 // Set 0-size frame
|
||||
;;
|
||||
flushrs;;
|
||||
|
||||
mov r21 = RSC_KERNEL_DISABLED // for rse disable
|
||||
;;
|
||||
mov ar.rsc = r21 // turn off RSE
|
||||
|
||||
add sp = r0, r16;; // transfer to the EFI stack
|
||||
mov ar.bspstore = r15 // switch to EFI BSP
|
||||
invala // change of ar.bspstore needs invala.
|
||||
|
||||
mov r18 = RSC_KERNEL_LAZ // RSC enabled, Lazy mode
|
||||
;;
|
||||
mov ar.rsc = r18 // turn rse on, in kernel mode
|
||||
;;
|
||||
alloc r11=0,0,1,0;; // alloc 0 outs going to ensuing DXE IPL service
|
||||
mov out0 = r17
|
||||
ld8 r16 = [r13],8;; // r16 = address of continuation function from the PLABEL
|
||||
ld8 gp = [r13] // gp = gp of continuation function from the PLABEL
|
||||
mov b6 = r16
|
||||
;;
|
||||
br.call.sptk.few b0=b6;; // Call the continuation function
|
||||
;;
|
||||
PROCEDURE_EXIT(SwitchStack)
|
||||
|
||||
|
59
MdePkg/Library/BaseLib/Ipf/Synchronization.c
Normal file
59
MdePkg/Library/BaseLib/Ipf/Synchronization.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/** @file
|
||||
Implementation of synchronization functions on Itanium.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: Synchronization.c
|
||||
|
||||
**/
|
||||
|
||||
UINT32
|
||||
EFIAPI
|
||||
InternalSyncCompareExchange32 (
|
||||
IN volatile UINT32 *Value,
|
||||
IN UINT32 CompareValue,
|
||||
IN UINT32 ExchangeValue
|
||||
);
|
||||
|
||||
UINT32
|
||||
EFIAPI
|
||||
InternalSyncIncrement (
|
||||
IN volatile UINT32 *Value
|
||||
)
|
||||
{
|
||||
UINT32 OriginalValue;
|
||||
|
||||
do {
|
||||
OriginalValue = *Value;
|
||||
} while (OriginalValue == InternalSyncCompareExchange32 (
|
||||
Value,
|
||||
OriginalValue,
|
||||
OriginalValue + 1
|
||||
));
|
||||
return OriginalValue + 1;
|
||||
}
|
||||
|
||||
UINT32
|
||||
EFIAPI
|
||||
InternalSyncDecrement (
|
||||
IN volatile UINT32 *Value
|
||||
)
|
||||
{
|
||||
UINT32 OriginalValue;
|
||||
|
||||
do {
|
||||
OriginalValue = *Value;
|
||||
} while (OriginalValue == InternalSyncCompareExchange32 (
|
||||
Value,
|
||||
OriginalValue,
|
||||
OriginalValue - 1
|
||||
));
|
||||
return OriginalValue - 1;
|
||||
}
|
220
MdePkg/Library/BaseLib/Ipf/Unaligned.c
Normal file
220
MdePkg/Library/BaseLib/Ipf/Unaligned.c
Normal file
@@ -0,0 +1,220 @@
|
||||
/** @file
|
||||
Unaligned access functions of BaseLib for IPF.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: Unaligned.c
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
Reads a 16-bit value from memory that may be unaligned.
|
||||
|
||||
This function returns the 16-bit value pointed to by Buffer. The function
|
||||
guarantees that the read operation does not produce an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 16-bit value that may be unaligned.
|
||||
|
||||
@return *Uint16
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
ReadUnaligned16 (
|
||||
IN CONST UINT16 *Buffer
|
||||
)
|
||||
{
|
||||
return (UINT16)(((UINT8*)Buffer)[0] | (((UINT8*)Buffer)[1] << 8));
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 16-bit value to memory that may be unaligned.
|
||||
|
||||
This function writes the 16-bit value specified by Value to Buffer. Value is
|
||||
returned. The function guarantees that the write operation does not produce
|
||||
an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 16-bit value that may be unaligned.
|
||||
@param Value 16-bit value to write to Buffer.
|
||||
|
||||
@return Value
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
WriteUnaligned16 (
|
||||
OUT UINT16 *Buffer,
|
||||
IN UINT16 Value
|
||||
)
|
||||
{
|
||||
((UINT8*)Buffer)[0] = (UINT8)Value;
|
||||
((UINT8*)Buffer)[1] = (UINT8)(Value >> 8);
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 24-bit value from memory that may be unaligned.
|
||||
|
||||
This function returns the 24-bit value pointed to by Buffer. The function
|
||||
guarantees that the read operation does not produce an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 24-bit value that may be unaligned.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
ReadUnaligned24 (
|
||||
IN CONST UINT32 *Buffer
|
||||
)
|
||||
{
|
||||
return (UINT32)(
|
||||
ReadUnaligned16 ((UINT16*)Buffer) |
|
||||
(((UINT8*)Buffer)[2] << 16)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 24-bit value to memory that may be unaligned.
|
||||
|
||||
This function writes the 24-bit value specified by Value to Buffer. Value is
|
||||
returned. The function guarantees that the write operation does not produce
|
||||
an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 24-bit value that may be unaligned.
|
||||
@param Value 24-bit value to write to Buffer.
|
||||
|
||||
@return The value written.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
WriteUnaligned24 (
|
||||
OUT UINT32 *Buffer,
|
||||
IN UINT32 Value
|
||||
)
|
||||
{
|
||||
WriteUnaligned16 ((UINT16*)Buffer, (UINT16)Value);
|
||||
*(UINT8*)((UINT16*)Buffer + 1) = (UINT8)(Value >> 16);
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 32-bit value from memory that may be unaligned.
|
||||
|
||||
This function returns the 32-bit value pointed to by Buffer. The function
|
||||
guarantees that the read operation does not produce an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 32-bit value that may be unaligned.
|
||||
|
||||
@return *Uint32
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
ReadUnaligned32 (
|
||||
IN CONST UINT32 *Buffer
|
||||
)
|
||||
{
|
||||
return (UINT32)(
|
||||
ReadUnaligned16 ((UINT16*)Buffer) |
|
||||
(ReadUnaligned16 ((UINT16*)Buffer + 1) << 16)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 32-bit value to memory that may be unaligned.
|
||||
|
||||
This function writes the 32-bit value specified by Value to Buffer. Value is
|
||||
returned. The function guarantees that the write operation does not produce
|
||||
an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 32-bit value that may be unaligned.
|
||||
@param Value 32-bit value to write to Buffer.
|
||||
|
||||
@return Value
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
WriteUnaligned32 (
|
||||
OUT UINT32 *Buffer,
|
||||
IN UINT32 Value
|
||||
)
|
||||
{
|
||||
WriteUnaligned16 ((UINT16*)Buffer, (UINT16)Value);
|
||||
WriteUnaligned16 ((UINT16*)Buffer + 1, (UINT16)(Value >> 16));
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 64-bit value from memory that may be unaligned.
|
||||
|
||||
This function returns the 64-bit value pointed to by Buffer. The function
|
||||
guarantees that the read operation does not produce an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 64-bit value that may be unaligned.
|
||||
|
||||
@return *Uint64
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
ReadUnaligned64 (
|
||||
IN CONST UINT64 *Buffer
|
||||
)
|
||||
{
|
||||
return (UINT64)(
|
||||
ReadUnaligned32 ((UINT32*)Buffer) |
|
||||
LShiftU64 (ReadUnaligned32 ((UINT32*)Buffer + 1), 32)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 64-bit value to memory that may be unaligned.
|
||||
|
||||
This function writes the 64-bit value specified by Value to Buffer. Value is
|
||||
returned. The function guarantees that the write operation does not produce
|
||||
an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 64-bit value that may be unaligned.
|
||||
@param Value 64-bit value to write to Buffer.
|
||||
|
||||
@return Value
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
WriteUnaligned64 (
|
||||
OUT UINT64 *Buffer,
|
||||
IN UINT64 Value
|
||||
)
|
||||
{
|
||||
WriteUnaligned32 ((UINT32*)Buffer, (UINT32)Value);
|
||||
WriteUnaligned32 ((UINT32*)Buffer + 1, (UINT32)RShiftU64 (Value, 32));
|
||||
return Value;
|
||||
}
|
27
MdePkg/Library/BaseLib/Ipf/asm.h
Normal file
27
MdePkg/Library/BaseLib/Ipf/asm.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/// @file
|
||||
/// This module contains generic macros for an assembly writer.
|
||||
///
|
||||
/// Copyright (c) 2006, Intel Corporation<BR>
|
||||
/// 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.
|
||||
///
|
||||
/// Module Name: asm.h
|
||||
///
|
||||
#ifndef _ASM_H
|
||||
#define _ASM_H
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define PROCEDURE_ENTRY(name) .##text; \
|
||||
.##type name, @function; \
|
||||
.##proc name; \
|
||||
name::
|
||||
|
||||
#define PROCEDURE_EXIT(name) .##endp name
|
||||
|
||||
#endif // _ASM_H
|
205
MdePkg/Library/BaseLib/Ipf/ia_64gen.h
Normal file
205
MdePkg/Library/BaseLib/Ipf/ia_64gen.h
Normal file
@@ -0,0 +1,205 @@
|
||||
/// @file
|
||||
///
|
||||
///
|
||||
/// Copyright (c) 2006, Intel Corporation<BR>
|
||||
/// 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.
|
||||
///
|
||||
/// Module Name: ia_64gen.h
|
||||
///
|
||||
#ifndef _IA64GEN_H
|
||||
#define _IA64GEN_H
|
||||
|
||||
#define TT_UNAT 0
|
||||
#define C_PSR 0
|
||||
#define J_UNAT 0
|
||||
#define T_TYPE 0
|
||||
#define T_IPSR 0x8
|
||||
#define T_ISR 0x10
|
||||
#define T_IIP 0x18
|
||||
#define T_IFA 0x20
|
||||
#define T_IIPA 0x28
|
||||
#define T_IFS 0x30
|
||||
#define T_IIM 0x38
|
||||
#define T_RSC 0x40
|
||||
#define T_BSP 0x48
|
||||
#define T_BSPSTORE 0x50
|
||||
#define T_RNAT 0x58
|
||||
#define T_PFS 0x60
|
||||
#define T_KBSPSTORE 0x68
|
||||
#define T_UNAT 0x70
|
||||
#define T_CCV 0x78
|
||||
#define T_DCR 0x80
|
||||
#define T_PREDS 0x88
|
||||
#define T_NATS 0x90
|
||||
#define T_R1 0x98
|
||||
#define T_GP 0x98
|
||||
#define T_R2 0xa0
|
||||
#define T_R3 0xa8
|
||||
#define T_R4 0xb0
|
||||
#define T_R5 0xb8
|
||||
#define T_R6 0xc0
|
||||
#define T_R7 0xc8
|
||||
#define T_R8 0xd0
|
||||
#define T_R9 0xd8
|
||||
#define T_R10 0xe0
|
||||
#define T_R11 0xe8
|
||||
#define T_R12 0xf0
|
||||
#define T_SP 0xf0
|
||||
#define T_R13 0xf8
|
||||
#define T_R14 0x100
|
||||
#define T_R15 0x108
|
||||
#define T_R16 0x110
|
||||
#define T_R17 0x118
|
||||
#define T_R18 0x120
|
||||
#define T_R19 0x128
|
||||
#define T_R20 0x130
|
||||
#define T_R21 0x138
|
||||
#define T_R22 0x140
|
||||
#define T_R23 0x148
|
||||
#define T_R24 0x150
|
||||
#define T_R25 0x158
|
||||
#define T_R26 0x160
|
||||
#define T_R27 0x168
|
||||
#define T_R28 0x170
|
||||
#define T_R29 0x178
|
||||
#define T_R30 0x180
|
||||
#define T_R31 0x188
|
||||
#define T_F2 0x1f0
|
||||
#define T_F3 0x200
|
||||
#define T_F4 0x210
|
||||
#define T_F5 0x220
|
||||
#define T_F6 0x230
|
||||
#define T_F7 0x240
|
||||
#define T_F8 0x250
|
||||
#define T_F9 0x260
|
||||
#define T_F10 0x270
|
||||
#define T_F11 0x280
|
||||
#define T_F12 0x290
|
||||
#define T_F13 0x2a0
|
||||
#define T_F14 0x2b0
|
||||
#define T_F15 0x2c0
|
||||
#define T_F16 0x2d0
|
||||
#define T_F17 0x2e0
|
||||
#define T_F18 0x2f0
|
||||
#define T_F19 0x300
|
||||
#define T_F20 0x310
|
||||
#define T_F21 0x320
|
||||
#define T_F22 0x330
|
||||
#define T_F23 0x340
|
||||
#define T_F24 0x350
|
||||
#define T_F25 0x360
|
||||
#define T_F26 0x370
|
||||
#define T_F27 0x380
|
||||
#define T_F28 0x390
|
||||
#define T_F29 0x3a0
|
||||
#define T_F30 0x3b0
|
||||
#define T_F31 0x3c0
|
||||
#define T_FPSR 0x1e0
|
||||
#define T_B0 0x190
|
||||
#define T_B1 0x198
|
||||
#define T_B2 0x1a0
|
||||
#define T_B3 0x1a8
|
||||
#define T_B4 0x1b0
|
||||
#define T_B5 0x1b8
|
||||
#define T_B6 0x1c0
|
||||
#define T_B7 0x1c8
|
||||
#define T_EC 0x1d0
|
||||
#define T_LC 0x1d8
|
||||
#define J_NATS 0x8
|
||||
#define J_PFS 0x10
|
||||
#define J_BSP 0x18
|
||||
#define J_RNAT 0x20
|
||||
#define J_PREDS 0x28
|
||||
#define J_LC 0x30
|
||||
#define J_R4 0x38
|
||||
#define J_R5 0x40
|
||||
#define J_R6 0x48
|
||||
#define J_R7 0x50
|
||||
#define J_SP 0x58
|
||||
#define J_F2 0x60
|
||||
#define J_F3 0x70
|
||||
#define J_F4 0x80
|
||||
#define J_F5 0x90
|
||||
#define J_F16 0xa0
|
||||
#define J_F17 0xb0
|
||||
#define J_F18 0xc0
|
||||
#define J_F19 0xd0
|
||||
#define J_F20 0xe0
|
||||
#define J_F21 0xf0
|
||||
#define J_F22 0x100
|
||||
#define J_F23 0x110
|
||||
#define J_F24 0x120
|
||||
#define J_F25 0x130
|
||||
#define J_F26 0x140
|
||||
#define J_F27 0x150
|
||||
#define J_F28 0x160
|
||||
#define J_F29 0x170
|
||||
#define J_F30 0x180
|
||||
#define J_F31 0x190
|
||||
#define J_FPSR 0x1a0
|
||||
#define J_B0 0x1a8
|
||||
#define J_B1 0x1b0
|
||||
#define J_B2 0x1b8
|
||||
#define J_B3 0x1c0
|
||||
#define J_B4 0x1c8
|
||||
#define J_B5 0x1d0
|
||||
#define TRAP_FRAME_LENGTH 0x3d0
|
||||
#define C_UNAT 0x28
|
||||
#define C_NATS 0x30
|
||||
#define C_PFS 0x8
|
||||
#define C_BSPSTORE 0x10
|
||||
#define C_RNAT 0x18
|
||||
#define C_RSC 0x20
|
||||
#define C_PREDS 0x38
|
||||
#define C_LC 0x40
|
||||
#define C_DCR 0x48
|
||||
#define C_R1 0x50
|
||||
#define C_GP 0x50
|
||||
#define C_R4 0x58
|
||||
#define C_R5 0x60
|
||||
#define C_R6 0x68
|
||||
#define C_R7 0x70
|
||||
#define C_SP 0x78
|
||||
#define C_R13 0x80
|
||||
#define C_F2 0x90
|
||||
#define C_F3 0xa0
|
||||
#define C_F4 0xb0
|
||||
#define C_F5 0xc0
|
||||
#define C_F16 0xd0
|
||||
#define C_F17 0xe0
|
||||
#define C_F18 0xf0
|
||||
#define C_F19 0x100
|
||||
#define C_F20 0x110
|
||||
#define C_F21 0x120
|
||||
#define C_F22 0x130
|
||||
#define C_F23 0x140
|
||||
#define C_F24 0x150
|
||||
#define C_F25 0x160
|
||||
#define C_F26 0x170
|
||||
#define C_F27 0x180
|
||||
#define C_F28 0x190
|
||||
#define C_F29 0x1a0
|
||||
#define C_F30 0x1b0
|
||||
#define C_F31 0x1c0
|
||||
#define C_FPSR 0x1d0
|
||||
#define C_B0 0x1d8
|
||||
#define C_B1 0x1e0
|
||||
#define C_B2 0x1e8
|
||||
#define C_B3 0x1f0
|
||||
#define C_B4 0x1f8
|
||||
#define C_B5 0x200
|
||||
#define TT_R2 0x8
|
||||
#define TT_R3 0x10
|
||||
#define TT_R8 0x18
|
||||
#define TT_R9 0x20
|
||||
#define TT_R10 0x28
|
||||
#define TT_R11 0x30
|
||||
#define TT_R14 0x38
|
||||
|
||||
#endif _IA64GEN_H
|
317
MdePkg/Library/BaseLib/Ipf/setjmp.s
Normal file
317
MdePkg/Library/BaseLib/Ipf/setjmp.s
Normal file
@@ -0,0 +1,317 @@
|
||||
/// @file
|
||||
/// Contains an implementation of setjmp and longjmp for the
|
||||
/// Itanium-based architecture.
|
||||
///
|
||||
/// Copyright (c) 2006, 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.
|
||||
///
|
||||
/// Module Name: setjmp.s
|
||||
///
|
||||
///
|
||||
|
||||
.file "setjmp.s"
|
||||
|
||||
#include "asm.h"
|
||||
#include "ia_64gen.h"
|
||||
|
||||
/// int SetJump(struct jmp_buffer save)
|
||||
///
|
||||
/// Setup a non-local goto.
|
||||
///
|
||||
/// Description:
|
||||
///
|
||||
/// SetJump stores the current register set in the area pointed to
|
||||
/// by "save". It returns zero. Subsequent calls to "LongJump" will
|
||||
/// restore the registers and return non-zero to the same location.
|
||||
///
|
||||
/// On entry, r32 contains the pointer to the jmp_buffer
|
||||
///
|
||||
|
||||
PROCEDURE_ENTRY(SetJump)
|
||||
//
|
||||
// Make sure buffer is aligned at 16byte boundary
|
||||
//
|
||||
mov r32 = r33
|
||||
|
||||
add r10 = -0x10,r0 ;; // mask the lower 4 bits
|
||||
and r32 = r32, r10;;
|
||||
add r32 = 0x10, r32;; // move to next 16 byte boundary
|
||||
|
||||
add r10 = J_PREDS, r32 // skip Unats & pfs save area
|
||||
add r11 = J_BSP, r32
|
||||
//
|
||||
// save immediate context
|
||||
//
|
||||
mov r2 = ar.bsp // save backing store pointer
|
||||
mov r3 = pr // save predicates
|
||||
;;
|
||||
//
|
||||
// save user Unat register
|
||||
//
|
||||
mov r16 = ar.lc // save loop count register
|
||||
mov r14 = ar.unat // save user Unat register
|
||||
|
||||
st8 [r10] = r3, J_LC-J_PREDS
|
||||
st8 [r11] = r2, J_R4-J_BSP
|
||||
;;
|
||||
st8 [r10] = r16, J_R5-J_LC
|
||||
st8 [r32] = r14, J_NATS // Note: Unat at the
|
||||
// beginning of the save area
|
||||
mov r15 = ar.pfs
|
||||
;;
|
||||
//
|
||||
// save preserved general registers & NaT's
|
||||
//
|
||||
st8.spill [r11] = r4, J_R6-J_R4
|
||||
;;
|
||||
st8.spill [r10] = r5, J_R7-J_R5
|
||||
;;
|
||||
st8.spill [r11] = r6, J_SP-J_R6
|
||||
;;
|
||||
st8.spill [r10] = r7, J_F3-J_R7
|
||||
;;
|
||||
st8.spill [r11] = sp, J_F2-J_SP
|
||||
;;
|
||||
//
|
||||
// save spilled Unat and pfs registers
|
||||
//
|
||||
mov r2 = ar.unat // save Unat register after spill
|
||||
;;
|
||||
st8 [r32] = r2, J_PFS-J_NATS // save unat for spilled regs
|
||||
;;
|
||||
st8 [r32] = r15 // save pfs
|
||||
//
|
||||
// save floating registers
|
||||
//
|
||||
stf.spill [r11] = f2, J_F4-J_F2
|
||||
stf.spill [r10] = f3, J_F5-J_F3
|
||||
;;
|
||||
stf.spill [r11] = f4, J_F16-J_F4
|
||||
stf.spill [r10] = f5, J_F17-J_F5
|
||||
;;
|
||||
stf.spill [r11] = f16, J_F18-J_F16
|
||||
stf.spill [r10] = f17, J_F19-J_F17
|
||||
;;
|
||||
stf.spill [r11] = f18, J_F20-J_F18
|
||||
stf.spill [r10] = f19, J_F21-J_F19
|
||||
;;
|
||||
stf.spill [r11] = f20, J_F22-J_F20
|
||||
stf.spill [r10] = f21, J_F23-J_F21
|
||||
;;
|
||||
stf.spill [r11] = f22, J_F24-J_F22
|
||||
stf.spill [r10] = f23, J_F25-J_F23
|
||||
;;
|
||||
stf.spill [r11] = f24, J_F26-J_F24
|
||||
stf.spill [r10] = f25, J_F27-J_F25
|
||||
;;
|
||||
stf.spill [r11] = f26, J_F28-J_F26
|
||||
stf.spill [r10] = f27, J_F29-J_F27
|
||||
;;
|
||||
stf.spill [r11] = f28, J_F30-J_F28
|
||||
stf.spill [r10] = f29, J_F31-J_F29
|
||||
;;
|
||||
stf.spill [r11] = f30, J_FPSR-J_F30
|
||||
stf.spill [r10] = f31, J_B0-J_F31 // size of f31 + fpsr
|
||||
//
|
||||
// save FPSR register & branch registers
|
||||
//
|
||||
mov r2 = ar.fpsr // save fpsr register
|
||||
mov r3 = b0
|
||||
;;
|
||||
st8 [r11] = r2, J_B1-J_FPSR
|
||||
st8 [r10] = r3, J_B2-J_B0
|
||||
mov r2 = b1
|
||||
mov r3 = b2
|
||||
;;
|
||||
st8 [r11] = r2, J_B3-J_B1
|
||||
st8 [r10] = r3, J_B4-J_B2
|
||||
mov r2 = b3
|
||||
mov r3 = b4
|
||||
;;
|
||||
st8 [r11] = r2, J_B5-J_B3
|
||||
st8 [r10] = r3
|
||||
mov r2 = b5
|
||||
;;
|
||||
st8 [r11] = r2
|
||||
;;
|
||||
//
|
||||
// return
|
||||
//
|
||||
mov r8 = r0 // return 0 from setjmp
|
||||
mov ar.unat = r14 // restore unat
|
||||
br.ret.sptk b0
|
||||
|
||||
PROCEDURE_EXIT(SetJump)
|
||||
|
||||
|
||||
//
|
||||
// void LongJump(struct jmp_buffer *)
|
||||
//
|
||||
// Perform a non-local goto.
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// LongJump initializes the register set to the values saved by a
|
||||
// previous 'SetJump' and jumps to the return location saved by that
|
||||
// 'SetJump'. This has the effect of unwinding the stack and returning
|
||||
// for a second time to the 'SetJump'.
|
||||
//
|
||||
|
||||
PROCEDURE_ENTRY(LongJump)
|
||||
//
|
||||
// Make sure buffer is aligned at 16byte boundary
|
||||
//
|
||||
mov r32 = r33
|
||||
|
||||
add r10 = -0x10,r0 ;; // mask the lower 4 bits
|
||||
and r32 = r32, r10;;
|
||||
add r32 = 0x10, r32;; // move to next 16 byte boundary
|
||||
|
||||
//
|
||||
// caching the return value as we do invala in the end
|
||||
//
|
||||
/// mov r8 = r33 // return value
|
||||
mov r8 = 1 // For now return hard coded 1
|
||||
|
||||
//
|
||||
// get immediate context
|
||||
//
|
||||
mov r14 = ar.rsc // get user RSC conf
|
||||
add r10 = J_PFS, r32 // get address of pfs
|
||||
add r11 = J_NATS, r32
|
||||
;;
|
||||
ld8 r15 = [r10], J_BSP-J_PFS // get pfs
|
||||
ld8 r2 = [r11], J_LC-J_NATS // get unat for spilled regs
|
||||
;;
|
||||
mov ar.unat = r2
|
||||
;;
|
||||
ld8 r16 = [r10], J_PREDS-J_BSP // get backing store pointer
|
||||
mov ar.rsc = r0 // put RSE in enforced lazy
|
||||
mov ar.pfs = r15
|
||||
;;
|
||||
|
||||
//
|
||||
// while returning from longjmp the BSPSTORE and BSP needs to be
|
||||
// same and discard all the registers allocated after we did
|
||||
// setjmp. Also, we need to generate the RNAT register since we
|
||||
// did not flushed the RSE on setjmp.
|
||||
//
|
||||
mov r17 = ar.bspstore // get current BSPSTORE
|
||||
;;
|
||||
cmp.ltu p6,p7 = r17, r16 // is it less than BSP of
|
||||
(p6) br.spnt.few .flush_rse
|
||||
mov r19 = ar.rnat // get current RNAT
|
||||
;;
|
||||
loadrs // invalidate dirty regs
|
||||
br.sptk.many .restore_rnat // restore RNAT
|
||||
|
||||
.flush_rse:
|
||||
flushrs
|
||||
;;
|
||||
mov r19 = ar.rnat // get current RNAT
|
||||
mov r17 = r16 // current BSPSTORE
|
||||
;;
|
||||
.restore_rnat:
|
||||
//
|
||||
// check if RNAT is saved between saved BSP and curr BSPSTORE
|
||||
//
|
||||
dep r18 = 1,r16,3,6 // get RNAT address
|
||||
;;
|
||||
cmp.ltu p8,p9 = r18, r17 // RNAT saved on RSE
|
||||
;;
|
||||
(p8) ld8 r19 = [r18] // get RNAT from RSE
|
||||
;;
|
||||
mov ar.bspstore = r16 // set new BSPSTORE
|
||||
;;
|
||||
mov ar.rnat = r19 // restore RNAT
|
||||
mov ar.rsc = r14 // restore RSC conf
|
||||
|
||||
|
||||
ld8 r3 = [r11], J_R4-J_LC // get lc register
|
||||
ld8 r2 = [r10], J_R5-J_PREDS // get predicates
|
||||
;;
|
||||
mov pr = r2, -1
|
||||
mov ar.lc = r3
|
||||
//
|
||||
// restore preserved general registers & NaT's
|
||||
//
|
||||
ld8.fill r4 = [r11], J_R6-J_R4
|
||||
;;
|
||||
ld8.fill r5 = [r10], J_R7-J_R5
|
||||
ld8.fill r6 = [r11], J_SP-J_R6
|
||||
;;
|
||||
ld8.fill r7 = [r10], J_F2-J_R7
|
||||
ld8.fill sp = [r11], J_F3-J_SP
|
||||
;;
|
||||
//
|
||||
// restore floating registers
|
||||
//
|
||||
ldf.fill f2 = [r10], J_F4-J_F2
|
||||
ldf.fill f3 = [r11], J_F5-J_F3
|
||||
;;
|
||||
ldf.fill f4 = [r10], J_F16-J_F4
|
||||
ldf.fill f5 = [r11], J_F17-J_F5
|
||||
;;
|
||||
ldf.fill f16 = [r10], J_F18-J_F16
|
||||
ldf.fill f17 = [r11], J_F19-J_F17
|
||||
;;
|
||||
ldf.fill f18 = [r10], J_F20-J_F18
|
||||
ldf.fill f19 = [r11], J_F21-J_F19
|
||||
;;
|
||||
ldf.fill f20 = [r10], J_F22-J_F20
|
||||
ldf.fill f21 = [r11], J_F23-J_F21
|
||||
;;
|
||||
ldf.fill f22 = [r10], J_F24-J_F22
|
||||
ldf.fill f23 = [r11], J_F25-J_F23
|
||||
;;
|
||||
ldf.fill f24 = [r10], J_F26-J_F24
|
||||
ldf.fill f25 = [r11], J_F27-J_F25
|
||||
;;
|
||||
ldf.fill f26 = [r10], J_F28-J_F26
|
||||
ldf.fill f27 = [r11], J_F29-J_F27
|
||||
;;
|
||||
ldf.fill f28 = [r10], J_F30-J_F28
|
||||
ldf.fill f29 = [r11], J_F31-J_F29
|
||||
;;
|
||||
ldf.fill f30 = [r10], J_FPSR-J_F30
|
||||
ldf.fill f31 = [r11], J_B0-J_F31 ;;
|
||||
|
||||
//
|
||||
// restore branch registers and fpsr
|
||||
//
|
||||
ld8 r16 = [r10], J_B1-J_FPSR // get fpsr
|
||||
ld8 r17 = [r11], J_B2-J_B0 // get return pointer
|
||||
;;
|
||||
mov ar.fpsr = r16
|
||||
mov b0 = r17
|
||||
ld8 r2 = [r10], J_B3-J_B1
|
||||
ld8 r3 = [r11], J_B4-J_B2
|
||||
;;
|
||||
mov b1 = r2
|
||||
mov b2 = r3
|
||||
ld8 r2 = [r10], J_B5-J_B3
|
||||
ld8 r3 = [r11]
|
||||
;;
|
||||
mov b3 = r2
|
||||
mov b4 = r3
|
||||
ld8 r2 = [r10]
|
||||
ld8 r21 = [r32] // get user unat
|
||||
;;
|
||||
mov b5 = r2
|
||||
mov ar.unat = r21
|
||||
|
||||
//
|
||||
// invalidate ALAT
|
||||
//
|
||||
invala ;;
|
||||
|
||||
br.ret.sptk b0
|
||||
PROCEDURE_EXIT(LongJump)
|
||||
|
||||
|
42
MdePkg/Library/BaseLib/LRotU32.c
Normal file
42
MdePkg/Library/BaseLib/LRotU32.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
|
||||
with the high bits that were rotated.
|
||||
|
||||
This function rotates the 32-bit value Operand to the left by Count bits. The
|
||||
low Count bits are fill with the high Count bits of Operand. The rotated
|
||||
value is returned.
|
||||
|
||||
If Count is greater than 31, then ASSERT().
|
||||
|
||||
@param Operand The 32-bit operand to rotate left.
|
||||
@param Count The number of bits to rotate left.
|
||||
|
||||
@return Operand <<< Count
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
LRotU32 (
|
||||
IN UINT32 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
ASSERT (Count < sizeof (Operand) * 8);
|
||||
return (Operand << Count) | (Operand >> (32 - Count));
|
||||
}
|
42
MdePkg/Library/BaseLib/LRotU64.c
Normal file
42
MdePkg/Library/BaseLib/LRotU64.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
|
||||
with the high bits that were rotated.
|
||||
|
||||
This function rotates the 64-bit value Operand to the left by Count bits. The
|
||||
low Count bits are fill with the high Count bits of Operand. The rotated
|
||||
value is returned.
|
||||
|
||||
If Count is greater than 63, then ASSERT().
|
||||
|
||||
@param Operand The 64-bit operand to rotate left.
|
||||
@param Count The number of bits to rotate left.
|
||||
|
||||
@return Operand <<< Count
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
LRotU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
ASSERT (Count < sizeof (Operand) * 8);
|
||||
return InternalMathLRotU64 (Operand, Count);
|
||||
}
|
41
MdePkg/Library/BaseLib/LShiftU64.c
Normal file
41
MdePkg/Library/BaseLib/LShiftU64.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
|
||||
with zeros. The shifted value is returned.
|
||||
|
||||
This function shifts the 64-bit value Operand to the left by Count bits. The
|
||||
low Count bits are set to zero. The shifted value is returned.
|
||||
|
||||
If Count is greater than 63, then ASSERT().
|
||||
|
||||
@param Operand The 64-bit operand to shift left.
|
||||
@param Count The number of bits to shift left.
|
||||
|
||||
@return Operand << Count
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
LShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
ASSERT (Count < sizeof (Operand) * 8);
|
||||
return InternalMathLShiftU64 (Operand, Count);
|
||||
}
|
433
MdePkg/Library/BaseLib/LinkedList.c
Normal file
433
MdePkg/Library/BaseLib/LinkedList.c
Normal file
@@ -0,0 +1,433 @@
|
||||
/** @file
|
||||
Linked List Library Functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: LinkedList.c
|
||||
|
||||
**/
|
||||
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsNodeInList (
|
||||
IN CONST LIST_ENTRY *List,
|
||||
IN CONST LIST_ENTRY *Node
|
||||
)
|
||||
{
|
||||
UINTN Count;
|
||||
CONST LIST_ENTRY *Ptr;
|
||||
BOOLEAN Found;
|
||||
|
||||
//
|
||||
// Test the validity of List and Node
|
||||
//
|
||||
ASSERT (List != NULL);
|
||||
ASSERT (List->ForwardLink != NULL);
|
||||
ASSERT (List->BackLink != NULL);
|
||||
ASSERT (Node != NULL);
|
||||
|
||||
Count = FixedPcdGet32 (PcdMaximumLinkedListLength);
|
||||
Ptr = List;
|
||||
do {
|
||||
Ptr = Ptr->ForwardLink;
|
||||
Count--;
|
||||
} while ((Ptr != List) && (Ptr != Node) && (Count > 0));
|
||||
Found = (BOOLEAN)(Ptr == Node);
|
||||
|
||||
if (FixedPcdGet32 (PcdMaximumLinkedListLength) > 0) {
|
||||
while ((Count > 0) && (Ptr != List)) {
|
||||
Ptr = Ptr->ForwardLink;
|
||||
}
|
||||
ASSERT (Count > 0);
|
||||
}
|
||||
|
||||
return Found;
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes the head node of a doubly linked list, and returns the pointer to
|
||||
the head node of the doubly linked list.
|
||||
|
||||
Initializes the forward and backward links of a new linked list. After
|
||||
initializing a linked list with this function, the other linked list
|
||||
functions may be used to add and remove nodes from the linked list. It is up
|
||||
to the caller of this function to allocate the memory for ListHead.
|
||||
|
||||
If ListHead is NULL, then ASSERT().
|
||||
|
||||
@param ListHead A pointer to the head node of a new doubly linked list.
|
||||
|
||||
@return ListHead
|
||||
|
||||
**/
|
||||
LIST_ENTRY *
|
||||
EFIAPI
|
||||
InitializeListHead (
|
||||
IN OUT LIST_ENTRY *List
|
||||
)
|
||||
|
||||
{
|
||||
ASSERT (List != NULL);
|
||||
|
||||
List->ForwardLink = List;
|
||||
List->BackLink = List;
|
||||
return List;
|
||||
}
|
||||
|
||||
/**
|
||||
Adds a node to the beginning of a doubly linked list, and returns the pointer
|
||||
to the head node of the doubly linked list.
|
||||
|
||||
Adds the node Entry at the beginning of the doubly linked list denoted by
|
||||
ListHead, and returns ListHead.
|
||||
|
||||
If ListHead is NULL, then ASSERT().
|
||||
If Entry is NULL, then ASSERT().
|
||||
If ListHead was not initialized with InitializeListHead(), then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
|
||||
PcdMaximumLinkedListLenth nodes, then ASSERT().
|
||||
|
||||
@param ListHead A pointer to the head node of a doubly linked list.
|
||||
@param Entry A pointer to a node that is to be inserted at the beginning
|
||||
of a doubly linked list.
|
||||
|
||||
@return ListHead
|
||||
|
||||
**/
|
||||
LIST_ENTRY *
|
||||
EFIAPI
|
||||
InsertHeadList (
|
||||
IN OUT LIST_ENTRY *List,
|
||||
IN OUT LIST_ENTRY *Entry
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT List not too long and Entry is not one of the nodes of List
|
||||
//
|
||||
ASSERT (!IsNodeInList (List, Entry));
|
||||
|
||||
Entry->ForwardLink = List->ForwardLink;
|
||||
Entry->BackLink = List;
|
||||
Entry->ForwardLink->BackLink = Entry;
|
||||
List->ForwardLink = Entry;
|
||||
return List;
|
||||
}
|
||||
|
||||
/**
|
||||
Adds a node to the end of a doubly linked list, and returns the pointer to
|
||||
the head node of the doubly linked list.
|
||||
|
||||
Adds the node Entry to the end of the doubly linked list denoted by ListHead,
|
||||
and returns ListHead.
|
||||
|
||||
If ListHead is NULL, then ASSERT().
|
||||
If Entry is NULL, then ASSERT().
|
||||
If ListHead was not initialized with InitializeListHead(), then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
|
||||
PcdMaximumLinkedListLenth nodes, then ASSERT().
|
||||
|
||||
@param ListHead A pointer to the head node of a doubly linked list.
|
||||
@param Entry A pointer to a node that is to be added at the end of the
|
||||
doubly linked list.
|
||||
|
||||
@return ListHead
|
||||
|
||||
**/
|
||||
LIST_ENTRY *
|
||||
EFIAPI
|
||||
InsertTailList (
|
||||
IN OUT LIST_ENTRY *List,
|
||||
IN OUT LIST_ENTRY *Entry
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT List not too long and Entry is not one of the nodes of List
|
||||
//
|
||||
ASSERT (!IsNodeInList (List, Entry));
|
||||
|
||||
Entry->ForwardLink = List;
|
||||
Entry->BackLink = List->BackLink;
|
||||
Entry->BackLink->ForwardLink = Entry;
|
||||
List->BackLink = Entry;
|
||||
return List;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the first node of a doubly linked list.
|
||||
|
||||
Returns the first node of a doubly linked list. List must have been
|
||||
initialized with InitializeListHead(). If List is empty, then NULL is
|
||||
returned.
|
||||
|
||||
If List is NULL, then ASSERT().
|
||||
If List was not initialized with InitializeListHead(), then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and List contains more than
|
||||
PcdMaximumLinkedListLenth nodes, then ASSERT().
|
||||
|
||||
@param List A pointer to the head node of a doubly linked list.
|
||||
|
||||
@return The first node of a doubly linked list.
|
||||
@retval NULL The list is empty.
|
||||
|
||||
**/
|
||||
LIST_ENTRY *
|
||||
EFIAPI
|
||||
GetFirstNode (
|
||||
IN CONST LIST_ENTRY *List
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT List not too long
|
||||
//
|
||||
ASSERT (IsNodeInList (List, List));
|
||||
|
||||
return List->ForwardLink;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the next node of a doubly linked list.
|
||||
|
||||
Returns the node of a doubly linked list that follows Node. List must have
|
||||
been initialized with InitializeListHead(). If List is empty, then List is
|
||||
returned.
|
||||
|
||||
If List is NULL, then ASSERT().
|
||||
If Node is NULL, then ASSERT().
|
||||
If List was not initialized with InitializeListHead(), then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and List contains more than
|
||||
PcdMaximumLinkedListLenth nodes, then ASSERT().
|
||||
If Node is not a node in List, then ASSERT().
|
||||
|
||||
@param List A pointer to the head node of a doubly linked list.
|
||||
@param Node A pointer to a node in the doubly linked list.
|
||||
|
||||
@return Pointer to the next node if one exists. Otherwise a null value which
|
||||
is actually List is returned.
|
||||
|
||||
**/
|
||||
LIST_ENTRY *
|
||||
EFIAPI
|
||||
GetNextNode (
|
||||
IN CONST LIST_ENTRY *List,
|
||||
IN CONST LIST_ENTRY *Node
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT List not too long and Node is one of the nodes of List
|
||||
//
|
||||
ASSERT (IsNodeInList (List, Node));
|
||||
|
||||
return Node->ForwardLink;
|
||||
}
|
||||
|
||||
/**
|
||||
Checks to see if a doubly linked list is empty or not.
|
||||
|
||||
Checks to see if the doubly linked list is empty. If the linked list contains
|
||||
zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
|
||||
|
||||
If ListHead is NULL, then ASSERT().
|
||||
If ListHead was not initialized with InitializeListHead(), then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and List contains more than
|
||||
PcdMaximumLinkedListLenth nodes, then ASSERT().
|
||||
|
||||
@param ListHead A pointer to the head node of a doubly linked list.
|
||||
|
||||
@retval TRUE The linked list is empty.
|
||||
@retval FALSE The linked list is not empty.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsListEmpty (
|
||||
IN CONST LIST_ENTRY *List
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT List not too long
|
||||
//
|
||||
ASSERT (IsNodeInList (List, List));
|
||||
|
||||
return (BOOLEAN)(List->ForwardLink == List);
|
||||
}
|
||||
|
||||
/**
|
||||
Determines if a node in a doubly linked list is null.
|
||||
|
||||
Returns FALSE if Node is one of the nodes in the doubly linked list specified
|
||||
by List. Otherwise, TRUE is returned. List must have been initialized with
|
||||
InitializeListHead().
|
||||
|
||||
If List is NULL, then ASSERT().
|
||||
If Node is NULL, then ASSERT().
|
||||
If List was not initialized with InitializeListHead(), then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and List contains more than
|
||||
PcdMaximumLinkedListLenth nodes, then ASSERT().
|
||||
If Node is not a node in List and Node is not equal to List, then ASSERT().
|
||||
|
||||
@param List A pointer to the head node of a doubly linked list.
|
||||
@param Node A pointer to a node in the doubly linked list.
|
||||
|
||||
@retval TRUE Node is one of the nodes in the doubly linked list.
|
||||
@retval FALSE Node is not one of the nodes in the doubly linked list.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsNull (
|
||||
IN CONST LIST_ENTRY *List,
|
||||
IN CONST LIST_ENTRY *Node
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT List not too long and Node is one of the nodes of List
|
||||
//
|
||||
ASSERT (IsNodeInList (List, Node));
|
||||
|
||||
return (BOOLEAN)(Node == List);
|
||||
}
|
||||
|
||||
/**
|
||||
Determines if a node the last node in a doubly linked list.
|
||||
|
||||
Returns TRUE if Node is the last node in the doubly linked list specified by
|
||||
List. Otherwise, FALSE is returned. List must have been initialized with
|
||||
InitializeListHead().
|
||||
|
||||
If List is NULL, then ASSERT().
|
||||
If Node is NULL, then ASSERT().
|
||||
If List was not initialized with InitializeListHead(), then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and List contains more than
|
||||
PcdMaximumLinkedListLenth nodes, then ASSERT().
|
||||
If Node is not a node in List, then ASSERT().
|
||||
|
||||
@param List A pointer to the head node of a doubly linked list.
|
||||
@param Node A pointer to a node in the doubly linked list.
|
||||
|
||||
@retval TRUE Node is the last node in the linked list.
|
||||
@retval FALSE Node is not the last node in the linked list.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsNodeAtEnd (
|
||||
IN CONST LIST_ENTRY *List,
|
||||
IN CONST LIST_ENTRY *Node
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT List not too long and Node is one of the nodes of List
|
||||
//
|
||||
ASSERT (IsNodeInList (List, Node));
|
||||
|
||||
return (BOOLEAN)(!IsNull (List, Node) && List->BackLink == Node);
|
||||
}
|
||||
|
||||
/**
|
||||
Swaps the location of two nodes in a doubly linked list, and returns the
|
||||
first node after the swap.
|
||||
|
||||
If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
|
||||
Otherwise, the location of the FirstEntry node is swapped with the location
|
||||
of the SecondEntry node in a doubly linked list. SecondEntry must be in the
|
||||
same double linked list as FirstEntry and that double linked list must have
|
||||
been initialized with InitializeListHead(). SecondEntry is returned after the
|
||||
nodes are swapped.
|
||||
|
||||
If FirstEntry is NULL, then ASSERT().
|
||||
If SecondEntry is NULL, then ASSERT().
|
||||
If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and the linked list containing
|
||||
FirstEntry and SecondEntry contains more than PcdMaximumLinkedListLenth
|
||||
nodes, then ASSERT().
|
||||
|
||||
@param FirstEntry A pointer to a node in a linked list.
|
||||
@param SecondEntry A pointer to another node in the same linked list.
|
||||
|
||||
**/
|
||||
LIST_ENTRY *
|
||||
EFIAPI
|
||||
SwapListEntries (
|
||||
IN OUT LIST_ENTRY *FirstEntry,
|
||||
IN OUT LIST_ENTRY *SecondEntry
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Ptr;
|
||||
|
||||
if (FirstEntry == SecondEntry) {
|
||||
return SecondEntry;
|
||||
}
|
||||
|
||||
//
|
||||
// ASSERT Entry1 and Entry2 are in the same linked list
|
||||
//
|
||||
ASSERT (IsNodeInList (FirstEntry, SecondEntry));
|
||||
|
||||
//
|
||||
// Ptr is the node pointed to by FirstEntry->ForwardLink
|
||||
//
|
||||
Ptr = RemoveEntryList (FirstEntry);
|
||||
|
||||
//
|
||||
// If FirstEntry immediately follows SecondEntry, FirstEntry willl be placed
|
||||
// immediately in front of SecondEntry
|
||||
//
|
||||
if (Ptr->BackLink == SecondEntry) {
|
||||
return InsertTailList (SecondEntry, FirstEntry);
|
||||
}
|
||||
|
||||
//
|
||||
// Ptr == SecondEntry means SecondEntry immediately follows FirstEntry,
|
||||
// then there are no further steps necessary
|
||||
//
|
||||
if (Ptr == InsertHeadList (SecondEntry, FirstEntry)) {
|
||||
return Ptr;
|
||||
}
|
||||
|
||||
//
|
||||
// Move SecondEntry to the front of Ptr
|
||||
//
|
||||
RemoveEntryList (SecondEntry);
|
||||
InsertTailList (Ptr, SecondEntry);
|
||||
return SecondEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
Removes a node from a doubly linked list, and returns the node that follows
|
||||
the removed node.
|
||||
|
||||
Removes the node Entry from a doubly linked list. It is up to the caller of
|
||||
this function to release the memory used by this node if that is required. On
|
||||
exit, the node following Entry in the doubly linked list is returned. If
|
||||
Entry is the only node in the linked list, then the head node of the linked
|
||||
list is returned.
|
||||
|
||||
If Entry is NULL, then ASSERT().
|
||||
If Entry is the head node of an empty list, then ASSERT().
|
||||
If PcdMaximumLinkedListLenth is not zero, and the linked list containing
|
||||
Entry contains more than PcdMaximumLinkedListLenth nodes, then ASSERT().
|
||||
|
||||
@param Entry A pointer to a node in a linked list
|
||||
|
||||
@return Entry
|
||||
|
||||
**/
|
||||
LIST_ENTRY *
|
||||
EFIAPI
|
||||
RemoveEntryList (
|
||||
IN CONST LIST_ENTRY *Entry
|
||||
)
|
||||
{
|
||||
ASSERT (!IsListEmpty (Entry));
|
||||
|
||||
Entry->ForwardLink->BackLink = Entry->BackLink;
|
||||
Entry->BackLink->ForwardLink = Entry->ForwardLink;
|
||||
return Entry->ForwardLink;
|
||||
}
|
44
MdePkg/Library/BaseLib/LowBitSet32.c
Normal file
44
MdePkg/Library/BaseLib/LowBitSet32.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Returns the bit position of the lowest bit set in a 32-bit value.
|
||||
|
||||
This function computes the bit position of the lowest bit set in the 32-bit
|
||||
value specified by Operand. If Operand is zero, then -1 is returned.
|
||||
Otherwise, a value between 0 and 31 is returned.
|
||||
|
||||
@param Operand The 32-bit operand to evaluate.
|
||||
|
||||
@return Position of the lowest bit set in Operand if found.
|
||||
@retval -1 Operand is zero.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
LowBitSet32 (
|
||||
IN UINT32 Operand
|
||||
)
|
||||
{
|
||||
INTN BitIndex;
|
||||
|
||||
if (Operand == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (BitIndex = 0; (Operand & 1) == 0; BitIndex++, Operand >>= 1);
|
||||
return BitIndex;
|
||||
}
|
46
MdePkg/Library/BaseLib/LowBitSet64.c
Normal file
46
MdePkg/Library/BaseLib/LowBitSet64.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Returns the bit position of the lowest bit set in a 64-bit value.
|
||||
|
||||
This function computes the bit position of the lowest bit set in the 64-bit
|
||||
value specified by Operand. If Operand is zero, then -1 is returned.
|
||||
Otherwise, a value between 0 and 63 is returned.
|
||||
|
||||
@param Operand The 64-bit operand to evaluate.
|
||||
|
||||
@return Position of the lowest bit set in Operand if found.
|
||||
@retval -1 Operand is zero.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
LowBitSet64 (
|
||||
IN UINT64 Operand
|
||||
)
|
||||
{
|
||||
INTN BitIndex;
|
||||
|
||||
if (Operand == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (BitIndex = 0;
|
||||
(Operand & 1) == 0;
|
||||
BitIndex++, Operand = RShiftU64 (Operand, 1));
|
||||
return BitIndex;
|
||||
}
|
174
MdePkg/Library/BaseLib/Math64.c
Normal file
174
MdePkg/Library/BaseLib/Math64.c
Normal file
@@ -0,0 +1,174 @@
|
||||
/** @file
|
||||
Leaf math worker functions that require 64-bit arithmetic support from the
|
||||
compiler.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: Math64.c
|
||||
|
||||
**/
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathLShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
return Operand << Count;
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathRShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
return Operand >> Count;
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathARShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
//
|
||||
// Test if this compiler supports arithmetic shift
|
||||
//
|
||||
if ((((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1)) == -1) {
|
||||
//
|
||||
// Arithmetic shift is supported
|
||||
//
|
||||
return (UINT64)((INT64)Operand >> Count);
|
||||
}
|
||||
|
||||
//
|
||||
// Arithmetic is not supported
|
||||
//
|
||||
return (Operand >> Count) |
|
||||
((INTN)Operand < 0 ? ~((UINTN)-1 >> Count) : 0);
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathLRotU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
return (Operand << Count) | (Operand >> (64 - Count));
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathRRotU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
return (Operand >> Count) | (Operand << (64 - Count));
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathSwapBytes64 (
|
||||
IN UINT64 Operand
|
||||
)
|
||||
{
|
||||
return (UINT64)(
|
||||
((UINT64)SwapBytes32 ((UINT32)Operand) << 32) |
|
||||
((UINT64)SwapBytes32 ((UINT32)(Operand >> 32)))
|
||||
);
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathMultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINT32 Multiplier
|
||||
)
|
||||
{
|
||||
return Multiplicand * Multiplier;
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathMultU64x64 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINT64 Multiplier
|
||||
)
|
||||
{
|
||||
return Multiplicand * Multiplier;
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathDivU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor
|
||||
)
|
||||
{
|
||||
return Dividend / Divisor;
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathModU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor
|
||||
)
|
||||
{
|
||||
return Dividend % Divisor;
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathDivRemU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor,
|
||||
OUT UINT32 *Remainder
|
||||
)
|
||||
{
|
||||
if (Remainder != NULL) {
|
||||
*Remainder = (UINT32)(Dividend % Divisor);
|
||||
}
|
||||
return Dividend / Divisor;
|
||||
}
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalMathDivRemU64x64 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT64 Divisor,
|
||||
OUT UINT64 *Remainder
|
||||
)
|
||||
{
|
||||
if (Remainder != NULL) {
|
||||
*Remainder = Dividend % Divisor;
|
||||
}
|
||||
return Dividend / Divisor;
|
||||
}
|
||||
|
||||
INT64
|
||||
EFIAPI
|
||||
InternalMathDivRemS64x64 (
|
||||
IN INT64 Dividend,
|
||||
IN INT64 Divisor,
|
||||
OUT INT64 *Remainder
|
||||
)
|
||||
{
|
||||
if (Remainder != NULL) {
|
||||
*Remainder = Dividend % Divisor;
|
||||
}
|
||||
return Dividend / Divisor;
|
||||
}
|
42
MdePkg/Library/BaseLib/ModU64x32.c
Normal file
42
MdePkg/Library/BaseLib/ModU64x32.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
|
||||
a 32-bit unsigned remainder.
|
||||
|
||||
This function divides the 64-bit unsigned value Dividend by the 32-bit
|
||||
unsigned value Divisor and generates a 32-bit remainder. This function
|
||||
returns the 32-bit unsigned remainder.
|
||||
|
||||
If Divisor is 0, then ASSERT().
|
||||
|
||||
@param Dividend A 64-bit unsigned value.
|
||||
@param Divisor A 32-bit unsigned value.
|
||||
|
||||
@return Dividend % Divisor
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
ModU64x32 (
|
||||
IN UINT64 Dividend,
|
||||
IN UINT32 Divisor
|
||||
)
|
||||
{
|
||||
ASSERT (Divisor != 0);
|
||||
return InternalMathModU64x32 (Dividend, Divisor);
|
||||
}
|
41
MdePkg/Library/BaseLib/MultS64x64.c
Normal file
41
MdePkg/Library/BaseLib/MultS64x64.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
|
||||
64-bit signed result.
|
||||
|
||||
This function multiples the 64-bit signed value Multiplicand by the 64-bit
|
||||
signed value Multiplier and generates a 64-bit signed result. This 64-bit
|
||||
signed result is returned.
|
||||
|
||||
If the result overflows, then ASSERT().
|
||||
|
||||
@param Multiplicand A 64-bit signed value.
|
||||
@param Multiplier A 64-bit signed value.
|
||||
|
||||
@return Multiplicand * Multiplier
|
||||
|
||||
**/
|
||||
INT64
|
||||
EFIAPI
|
||||
MultS64x64 (
|
||||
IN INT64 Multiplicand,
|
||||
IN INT64 Multiplier
|
||||
)
|
||||
{
|
||||
return (INT64)MultU64x64 (Multiplicand, Multiplier);
|
||||
}
|
45
MdePkg/Library/BaseLib/MultU64x32.c
Normal file
45
MdePkg/Library/BaseLib/MultU64x32.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
|
||||
generates a 64-bit unsigned result.
|
||||
|
||||
This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
|
||||
unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
|
||||
bit unsigned result is returned.
|
||||
|
||||
If the result overflows, then ASSERT().
|
||||
|
||||
@param Multiplicand A 64-bit unsigned value.
|
||||
@param Multiplier A 32-bit unsigned value.
|
||||
|
||||
@return Multiplicand * Multiplier
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
MultU64x32 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINT32 Multiplier
|
||||
)
|
||||
{
|
||||
UINT64 Result;
|
||||
|
||||
Result = InternalMathMultU64x32 (Multiplicand, Multiplier);
|
||||
// TODO: ASSERT (Result not overflow);
|
||||
return Result;
|
||||
}
|
45
MdePkg/Library/BaseLib/MultU64x64.c
Normal file
45
MdePkg/Library/BaseLib/MultU64x64.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
|
||||
generates a 64-bit unsigned result.
|
||||
|
||||
This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
|
||||
unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
|
||||
bit unsigned result is returned.
|
||||
|
||||
If the result overflows, then ASSERT().
|
||||
|
||||
@param Multiplicand A 64-bit unsigned value.
|
||||
@param Multiplier A 64-bit unsigned value.
|
||||
|
||||
@return Multiplicand * Multiplier
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
MultU64x64 (
|
||||
IN UINT64 Multiplicand,
|
||||
IN UINT64 Multiplier
|
||||
)
|
||||
{
|
||||
UINT64 Result;
|
||||
|
||||
Result = InternalMathMultU64x64 (Multiplicand, Multiplier);
|
||||
// TODO: ASSERT (Result not overflow);
|
||||
return Result;
|
||||
}
|
42
MdePkg/Library/BaseLib/RRotU32.c
Normal file
42
MdePkg/Library/BaseLib/RRotU32.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
|
||||
with the low bits that were rotated.
|
||||
|
||||
This function rotates the 32-bit value Operand to the right by Count bits.
|
||||
The high Count bits are fill with the low Count bits of Operand. The rotated
|
||||
value is returned.
|
||||
|
||||
If Count is greater than 31, then ASSERT().
|
||||
|
||||
@param Operand The 32-bit operand to rotate right.
|
||||
@param Count The number of bits to rotate right.
|
||||
|
||||
@return Operand >>> Count
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
RRotU32 (
|
||||
IN UINT32 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
ASSERT (Count < sizeof (Operand) * 8);
|
||||
return (Operand >> Count) | (Operand << (32 - Count));
|
||||
}
|
42
MdePkg/Library/BaseLib/RRotU64.c
Normal file
42
MdePkg/Library/BaseLib/RRotU64.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
|
||||
with the high low bits that were rotated.
|
||||
|
||||
This function rotates the 64-bit value Operand to the right by Count bits.
|
||||
The high Count bits are fill with the low Count bits of Operand. The rotated
|
||||
value is returned.
|
||||
|
||||
If Count is greater than 63, then ASSERT().
|
||||
|
||||
@param Operand The 64-bit operand to rotate right.
|
||||
@param Count The number of bits to rotate right.
|
||||
|
||||
@return Operand >>> Count
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
RRotU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
ASSERT (Count < sizeof (Operand) * 8);
|
||||
return InternalMathRRotU64 (Operand, Count);
|
||||
}
|
41
MdePkg/Library/BaseLib/RShiftU64.c
Normal file
41
MdePkg/Library/BaseLib/RShiftU64.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
|
||||
filled with zeros. The shifted value is returned.
|
||||
|
||||
This function shifts the 64-bit value Operand to the right by Count bits. The
|
||||
high Count bits are set to zero. The shifted value is returned.
|
||||
|
||||
If Count is greater than 63, then ASSERT().
|
||||
|
||||
@param Operand The 64-bit operand to shift right.
|
||||
@param Count The number of bits to shift right.
|
||||
|
||||
@return Operand >> Count
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
RShiftU64 (
|
||||
IN UINT64 Operand,
|
||||
IN UINTN Count
|
||||
)
|
||||
{
|
||||
ASSERT (Count < sizeof (Operand) * 8);
|
||||
return InternalMathRShiftU64 (Operand, Count);
|
||||
}
|
40
MdePkg/Library/BaseLib/SetJumpLongJump.c
Normal file
40
MdePkg/Library/BaseLib/SetJumpLongJump.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/** @file
|
||||
Switch Stack functions.
|
||||
|
||||
Copyright (c) 2006, 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.
|
||||
|
||||
Module Name: SetJumpLongJump.c
|
||||
|
||||
**/
|
||||
|
||||
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
SetJump (
|
||||
IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
|
||||
)
|
||||
{
|
||||
ASSERT (JumpBuffer != NULL);
|
||||
ASSERT (FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
LongJump (
|
||||
IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
|
||||
IN UINTN Value
|
||||
)
|
||||
{
|
||||
ASSERT (JumpBuffer != NULL);
|
||||
ASSERT (Value != 0);
|
||||
ASSERT (FALSE);
|
||||
}
|
798
MdePkg/Library/BaseLib/String.c
Normal file
798
MdePkg/Library/BaseLib/String.c
Normal file
@@ -0,0 +1,798 @@
|
||||
/** @file
|
||||
Unicode string primatives.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: String.c
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
Copies one Null-terminated Unicode string to another Null-terminated Unicode
|
||||
string and returns the new Unicode string.
|
||||
|
||||
This function copies the contents of the Unicode string Source to the Unicode
|
||||
string Destination, and returns Destination. If Source and Destination
|
||||
overlap, then the results are undefined.
|
||||
|
||||
If Destination is NULL, then ASSERT().
|
||||
If Source is NULL, then ASSERT().
|
||||
If Source and Destination overlap, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
|
||||
PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
|
||||
@param Destination Pointer to a Null-terminated Unicode string.
|
||||
@param Source Pointer to a Null-terminated Unicode string.
|
||||
|
||||
@return Destiantion
|
||||
|
||||
**/
|
||||
CHAR16 *
|
||||
EFIAPI
|
||||
StrCpy (
|
||||
OUT CHAR16 *Destination,
|
||||
IN CONST CHAR16 *Source
|
||||
)
|
||||
{
|
||||
CHAR16 *ReturnValue;
|
||||
|
||||
//
|
||||
// Destination cannot be NULL
|
||||
//
|
||||
ASSERT (Destination != NULL);
|
||||
|
||||
//
|
||||
// Destination and source cannot overlap
|
||||
//
|
||||
ASSERT ((UINTN)(Destination - Source) > StrLen (Source));
|
||||
ASSERT ((UINTN)(Source - Destination) > StrLen (Source));
|
||||
|
||||
ReturnValue = Destination;
|
||||
while (*Source) {
|
||||
*(Destination++) = *(Source++);
|
||||
}
|
||||
*Destination = 0;
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
Copies one Null-terminated Unicode string with a maximum length to another
|
||||
Null-terminated Unicode string with a maximum length and returns the new
|
||||
Unicode string.
|
||||
|
||||
This function copies the contents of the Unicode string Source to the Unicode
|
||||
string Destination, and returns Destination. At most, Length Unicode
|
||||
characters are copied from Source to Destination. If Length is 0, then
|
||||
Destination is returned unmodified. If Length is greater that the number of
|
||||
Unicode characters in Source, then Destination is padded with Null Unicode
|
||||
characters. If Source and Destination overlap, then the results are
|
||||
undefined.
|
||||
|
||||
If Destination is NULL, then ASSERT().
|
||||
If Source is NULL, then ASSERT().
|
||||
If Source and Destination overlap, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
|
||||
PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
|
||||
@param Destination Pointer to a Null-terminated Unicode string.
|
||||
@param Source Pointer to a Null-terminated Unicode string.
|
||||
@param Length Maximum number of Unicode characters to copy.
|
||||
|
||||
@return Destination
|
||||
|
||||
**/
|
||||
CHAR16 *
|
||||
EFIAPI
|
||||
StrnCpy (
|
||||
OUT CHAR16 *Destination,
|
||||
IN CONST CHAR16 *Source,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
CHAR16 *ReturnValue;
|
||||
|
||||
if (Length == 0) {
|
||||
return Destination;
|
||||
}
|
||||
|
||||
//
|
||||
// Destination cannot be NULL if Length is not zero
|
||||
//
|
||||
ASSERT (Destination != NULL);
|
||||
|
||||
//
|
||||
// Destination and source cannot overlap
|
||||
// Q: Does Source have to be NULL-terminated?
|
||||
//
|
||||
ASSERT ((UINTN)(Destination - Source) > StrLen (Source));
|
||||
ASSERT ((UINTN)(Source - Destination) >= Length);
|
||||
|
||||
ReturnValue = Destination;
|
||||
|
||||
while ((*Source != L'\0') && (Length > 1)) {
|
||||
*(Destination++) = *(Source++);
|
||||
Length--;
|
||||
}
|
||||
|
||||
ZeroMem (Destination, Length * sizeof (*Destination));
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the length of a Null-terminated Unicode string.
|
||||
|
||||
This function returns the number of Unicode characters in the Null-terminated
|
||||
Unicode string specified by String.
|
||||
|
||||
If String is NULL, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and String contains more than
|
||||
PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
|
||||
@param String Pointer to a Null-terminated Unicode string.
|
||||
|
||||
@return The length of String.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
StrLen (
|
||||
IN CONST CHAR16 *String
|
||||
)
|
||||
{
|
||||
UINTN Length;
|
||||
|
||||
ASSERT (String != NULL);
|
||||
|
||||
for (Length = 0; *String != L'\0'; String++, Length++) {
|
||||
//
|
||||
// If PcdMaximumUnicodeStringLength is not zero,
|
||||
// length should not more than PcdMaximumUnicodeStringLength
|
||||
//
|
||||
if (FixedPcdGet32 (PcdMaximumUnicodeStringLength) != 0) {
|
||||
ASSERT (Length < FixedPcdGet32 (PcdMaximumUnicodeStringLength));
|
||||
}
|
||||
}
|
||||
return Length;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the size of a Null-terminated Unicode string in bytes, including the
|
||||
Null terminator.
|
||||
|
||||
This function returns the size, in bytes, of the Null-terminated Unicode
|
||||
string specified by String.
|
||||
|
||||
If String is NULL, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and String contains more than
|
||||
PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
|
||||
@param String Pointer to a Null-terminated Unicode string.
|
||||
|
||||
@return The size of String.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
StrSize (
|
||||
IN CONST CHAR16 *String
|
||||
)
|
||||
{
|
||||
return (StrLen (String) + 1) * sizeof (*String);
|
||||
}
|
||||
|
||||
/**
|
||||
Compares two Null-terminated Unicode strings, and returns the difference
|
||||
between the first mismatched Unicode characters.
|
||||
|
||||
This function compares the Null-terminated Unicode string FirstString to the
|
||||
Null-terminated Unicode string SecondString. If FirstString is identical to
|
||||
SecondString, then 0 is returned. Otherwise, the value returned is the first
|
||||
mismatched Unicode character in SecondString subtracted from the first
|
||||
mismatched Unicode character in FirstString.
|
||||
|
||||
If FirstString is NULL, then ASSERT().
|
||||
If SecondString is NULL, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
|
||||
than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
|
||||
than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
|
||||
@param FirstString Pointer to a Null-terminated Unicode string.
|
||||
@param SecondString Pointer to a Null-terminated Unicode string.
|
||||
|
||||
@retval 0 FirstString is identical to SecondString.
|
||||
@retval !=0 FirstString is not identical to SecondString.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
StrCmp (
|
||||
IN CONST CHAR16 *FirstString,
|
||||
IN CONST CHAR16 *SecondString
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT both strings are less long than PcdMaximumUnicodeStringLength
|
||||
//
|
||||
ASSERT (StrSize (FirstString) != 0);
|
||||
ASSERT (StrSize (SecondString) != 0);
|
||||
|
||||
while ((*FirstString != L'\0') && (*FirstString == *SecondString)) {
|
||||
FirstString++;
|
||||
SecondString++;
|
||||
}
|
||||
return *FirstString - *SecondString;
|
||||
}
|
||||
|
||||
/**
|
||||
Compares two Null-terminated Unicode strings with maximum lengths, and
|
||||
returns the difference between the first mismatched Unicode characters.
|
||||
|
||||
This function compares the Null-terminated Unicode string FirstString to the
|
||||
Null-terminated Unicode string SecondString. At most, Length Unicode
|
||||
characters will be compared. If Length is 0, then 0 is returned. If
|
||||
FirstString is identical to SecondString, then 0 is returned. Otherwise, the
|
||||
value returned is the first mismatched Unicode character in SecondString
|
||||
subtracted from the first mismatched Unicode character in FirstString.
|
||||
|
||||
If FirstString is NULL, then ASSERT().
|
||||
If SecondString is NULL, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
|
||||
than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
|
||||
than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
|
||||
@param FirstString Pointer to a Null-terminated Unicode string.
|
||||
@param SecondString Pointer to a Null-terminated Unicode string.
|
||||
@param Length Maximum number of Unicode characters to compare.
|
||||
|
||||
@retval 0 FirstString is identical to SecondString.
|
||||
@retval !=0 FirstString is not identical to SecondString.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
StrnCmp (
|
||||
IN CONST CHAR16 *FirstString,
|
||||
IN CONST CHAR16 *SecondString,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
if (Length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// ASSERT both strings are less long than PcdMaximumUnicodeStringLength.
|
||||
// Length tests are performed inside StrLen().
|
||||
//
|
||||
ASSERT (StrSize (FirstString) != 0);
|
||||
ASSERT (StrSize (SecondString) != 0);
|
||||
|
||||
while ((*FirstString != L'\0') &&
|
||||
(*FirstString != *SecondString) &&
|
||||
(Length > 1)) {
|
||||
FirstString++;
|
||||
SecondString++;
|
||||
Length--;
|
||||
}
|
||||
|
||||
return *FirstString - *SecondString;
|
||||
}
|
||||
|
||||
/**
|
||||
Concatenates one Null-terminated Unicode string to another Null-terminated
|
||||
Unicode string, and returns the concatenated Unicode string.
|
||||
|
||||
This function concatenates two Null-terminated Unicode strings. The contents
|
||||
of Null-terminated Unicode string Source are concatenated to the end of
|
||||
Null-terminated Unicode string Destination. The Null-terminated concatenated
|
||||
Unicode String is returned. If Source and Destination overlap, then the
|
||||
results are undefined.
|
||||
|
||||
If Destination is NULL, then ASSERT().
|
||||
If Source is NULL, then ASSERT().
|
||||
If Source and Destination overlap, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
|
||||
than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
|
||||
PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
|
||||
and Source results in a Unicode string with more than
|
||||
PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
|
||||
@param Destination Pointer to a Null-terminated Unicode string.
|
||||
@param Source Pointer to a Null-terminated Unicode string.
|
||||
|
||||
@return Destination
|
||||
|
||||
**/
|
||||
CHAR16 *
|
||||
EFIAPI
|
||||
StrCat (
|
||||
IN OUT CHAR16 *Destination,
|
||||
IN CONST CHAR16 *Source
|
||||
)
|
||||
{
|
||||
StrCpy (Destination + StrLen (Destination), Source);
|
||||
|
||||
//
|
||||
// Size of the resulting string should never be zero.
|
||||
// PcdMaximumUnicodeStringLength is tested inside StrLen().
|
||||
//
|
||||
ASSERT (StrSize (Destination) != 0);
|
||||
return Destination;
|
||||
}
|
||||
|
||||
/**
|
||||
Concatenates one Null-terminated Unicode string with a maximum length to the
|
||||
end of another Null-terminated Unicode string, and returns the concatenated
|
||||
Unicode string.
|
||||
|
||||
This function concatenates two Null-terminated Unicode strings. The contents
|
||||
of Null-terminated Unicode string Source are concatenated to the end of
|
||||
Null-terminated Unicode string Destination, and Destination is returned. At
|
||||
most, Length Unicode characters are concatenated from Source to the end of
|
||||
Destination, and Destination is always Null-terminated. If Length is 0, then
|
||||
Destination is returned unmodified. If Source and Destination overlap, then
|
||||
the results are undefined.
|
||||
|
||||
If Destination is NULL, then ASSERT().
|
||||
If Source is NULL, then ASSERT().
|
||||
If Source and Destination overlap, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
|
||||
than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
|
||||
PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
|
||||
and Source results in a Unicode string with more than
|
||||
PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
|
||||
|
||||
@param Destination Pointer to a Null-terminated Unicode string.
|
||||
@param Source Pointer to a Null-terminated Unicode string.
|
||||
@param Length Maximum number of Unicode characters to concatenate from
|
||||
Source.
|
||||
|
||||
@return Destination
|
||||
|
||||
**/
|
||||
CHAR16 *
|
||||
EFIAPI
|
||||
StrnCat (
|
||||
IN OUT CHAR16 *Destination,
|
||||
IN CONST CHAR16 *Source,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
StrnCpy (Destination + StrLen (Destination), Source, Length);
|
||||
|
||||
//
|
||||
// Size of the resulting string should never be zero.
|
||||
// PcdMaximumUnicodeStringLength is tested inside StrLen().
|
||||
//
|
||||
ASSERT (StrSize (Destination) != 0);
|
||||
return Destination;
|
||||
}
|
||||
|
||||
/**
|
||||
Copies one Null-terminated ASCII string to another Null-terminated ASCII
|
||||
string and returns the new ASCII string.
|
||||
|
||||
This function copies the contents of the ASCII string Source to the ASCII
|
||||
string Destination, and returns Destination. If Source and Destination
|
||||
overlap, then the results are undefined.
|
||||
|
||||
If Destination is NULL, then ASSERT().
|
||||
If Source is NULL, then ASSERT().
|
||||
If Source and Destination overlap, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and Source contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
|
||||
@param Destination Pointer to a Null-terminated ASCII string.
|
||||
@param Source Pointer to a Null-terminated ASCII string.
|
||||
|
||||
@return Destination
|
||||
|
||||
**/
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
AsciiStrCpy (
|
||||
OUT CHAR8 *Destination,
|
||||
IN CONST CHAR8 *Source
|
||||
)
|
||||
{
|
||||
CHAR8 *ReturnValue;
|
||||
|
||||
//
|
||||
// Destination cannot be NULL
|
||||
//
|
||||
ASSERT (Destination != NULL);
|
||||
|
||||
//
|
||||
// Destination and source cannot overlap
|
||||
//
|
||||
ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));
|
||||
ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source));
|
||||
|
||||
ReturnValue = Destination;
|
||||
while (*Source) {
|
||||
*(Destination++) = *(Source++);
|
||||
}
|
||||
*Destination = 0;
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
Copies one Null-terminated ASCII string with a maximum length to another
|
||||
Null-terminated ASCII string with a maximum length and returns the new ASCII
|
||||
string.
|
||||
|
||||
This function copies the contents of the ASCII string Source to the ASCII
|
||||
string Destination, and returns Destination. At most, Length ASCII characters
|
||||
are copied from Source to Destination. If Length is 0, then Destination is
|
||||
returned unmodified. If Length is greater that the number of ASCII characters
|
||||
in Source, then Destination is padded with Null ASCII characters. If Source
|
||||
and Destination overlap, then the results are undefined.
|
||||
|
||||
If Destination is NULL, then ASSERT().
|
||||
If Source is NULL, then ASSERT().
|
||||
If Source and Destination overlap, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero, and Source contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
|
||||
@param Destination Pointer to a Null-terminated ASCII string.
|
||||
@param Source Pointer to a Null-terminated ASCII string.
|
||||
@param Length Maximum number of ASCII characters to copy.
|
||||
|
||||
@return Destination
|
||||
|
||||
**/
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
AsciiStrnCpy (
|
||||
OUT CHAR8 *Destination,
|
||||
IN CONST CHAR8 *Source,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
CHAR8 *ReturnValue;
|
||||
|
||||
if (Length == 0) {
|
||||
return Destination;
|
||||
}
|
||||
|
||||
//
|
||||
// Destination cannot be NULL
|
||||
//
|
||||
ASSERT (Destination != NULL);
|
||||
|
||||
//
|
||||
// Destination and source cannot overlap
|
||||
//
|
||||
ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));
|
||||
ASSERT ((UINTN)(Source - Destination) >= Length);
|
||||
|
||||
ReturnValue = Destination;
|
||||
|
||||
while (*Source && Length > 1) {
|
||||
*(Destination++) = *(Source++);
|
||||
Length--;
|
||||
}
|
||||
|
||||
ZeroMem (Destination, Length * sizeof (*Destination));
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the length of a Null-terminated ASCII string.
|
||||
|
||||
This function returns the number of ASCII characters in the Null-terminated
|
||||
ASCII string specified by String.
|
||||
|
||||
If String is NULL, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and String contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
|
||||
@param String Pointer to a Null-terminated ASCII string.
|
||||
|
||||
@return The length of String.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
AsciiStrLen (
|
||||
IN CONST CHAR8 *String
|
||||
)
|
||||
{
|
||||
UINTN Length;
|
||||
|
||||
ASSERT (String != NULL);
|
||||
|
||||
for (Length = 0; *String != '\0'; String++, Length++) {
|
||||
//
|
||||
// If PcdMaximumUnicodeStringLength is not zero,
|
||||
// length should not more than PcdMaximumUnicodeStringLength
|
||||
//
|
||||
if (FixedPcdGet32 (PcdMaximumAsciiStringLength) != 0) {
|
||||
ASSERT (Length < FixedPcdGet32 (PcdMaximumAsciiStringLength));
|
||||
}
|
||||
}
|
||||
return Length;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the size of a Null-terminated ASCII string in bytes, including the
|
||||
Null terminator.
|
||||
|
||||
This function returns the size, in bytes, of the Null-terminated ASCII string
|
||||
specified by String.
|
||||
|
||||
If String is NULL, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and String contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
|
||||
@param String Pointer to a Null-terminated ASCII string.
|
||||
|
||||
@return The size of String.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
AsciiStrSize (
|
||||
IN CONST CHAR8 *String
|
||||
)
|
||||
{
|
||||
return (AsciiStrLen (String) + 1) * sizeof (*String);
|
||||
}
|
||||
|
||||
/**
|
||||
Compares two Null-terminated ASCII strings, and returns the difference
|
||||
between the first mismatched ASCII characters.
|
||||
|
||||
This function compares the Null-terminated ASCII string FirstString to the
|
||||
Null-terminated ASCII string SecondString. If FirstString is identical to
|
||||
SecondString, then 0 is returned. Otherwise, the value returned is the first
|
||||
mismatched ASCII character in SecondString subtracted from the first
|
||||
mismatched ASCII character in FirstString.
|
||||
|
||||
If FirstString is NULL, then ASSERT().
|
||||
If SecondString is NULL, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and SecondString contains more
|
||||
than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
|
||||
@param FirstString Pointer to a Null-terminated ASCII string.
|
||||
@param SecondString Pointer to a Null-terminated ASCII string.
|
||||
|
||||
@retval 0 FirstString is identical to SecondString.
|
||||
@retval !=0 FirstString is not identical to SecondString.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
AsciiStrCmp (
|
||||
IN CONST CHAR8 *FirstString,
|
||||
IN CONST CHAR8 *SecondString
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT both strings are less long than PcdMaximumAsciiStringLength
|
||||
//
|
||||
ASSERT (AsciiStrSize (FirstString));
|
||||
ASSERT (AsciiStrSize (SecondString));
|
||||
|
||||
while ((*FirstString != '\0') && (*FirstString == *SecondString)) {
|
||||
FirstString++;
|
||||
SecondString++;
|
||||
}
|
||||
|
||||
return *FirstString - *SecondString;
|
||||
}
|
||||
|
||||
STATIC
|
||||
CHAR8
|
||||
EFIAPI
|
||||
AsciiToUpper (
|
||||
IN CHAR8 Chr
|
||||
)
|
||||
{
|
||||
return (Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr;
|
||||
}
|
||||
|
||||
/**
|
||||
Performs a case insensitive comparison of two Null-terminated ASCII strings,
|
||||
and returns the difference between the first mismatched ASCII characters.
|
||||
|
||||
This function performs a case insensitive comparison of the Null-terminated
|
||||
ASCII string FirstString to the Null-terminated ASCII string SecondString. If
|
||||
FirstString is identical to SecondString, then 0 is returned. Otherwise, the
|
||||
value returned is the first mismatched lower case ASCII character in
|
||||
SecondString subtracted from the first mismatched lower case ASCII character
|
||||
in FirstString.
|
||||
|
||||
If FirstString is NULL, then ASSERT().
|
||||
If SecondString is NULL, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and SecondString contains more
|
||||
than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
|
||||
@param FirstString Pointer to a Null-terminated ASCII string.
|
||||
@param SecondString Pointer to a Null-terminated ASCII string.
|
||||
|
||||
@retval 0 FirstString is identical to SecondString using case insensitive
|
||||
comparisons.
|
||||
@retval !=0 FirstString is not identical to SecondString using case
|
||||
insensitive comparisons.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
AsciiStriCmp (
|
||||
IN CONST CHAR8 *FirstString,
|
||||
IN CONST CHAR8 *SecondString
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT both strings are less long than PcdMaximumAsciiStringLength
|
||||
//
|
||||
ASSERT (AsciiStrSize (FirstString));
|
||||
ASSERT (AsciiStrSize (SecondString));
|
||||
|
||||
while ((*FirstString != '\0') &&
|
||||
(AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString))) {
|
||||
FirstString++;
|
||||
SecondString++;
|
||||
}
|
||||
|
||||
return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);
|
||||
}
|
||||
|
||||
/**
|
||||
Compares two Null-terminated ASCII strings with maximum lengths, and returns
|
||||
the difference between the first mismatched ASCII characters.
|
||||
|
||||
This function compares the Null-terminated ASCII string FirstString to the
|
||||
Null-terminated ASCII string SecondString. At most, Length ASCII characters
|
||||
will be compared. If Length is 0, then 0 is returned. If FirstString is
|
||||
identical to SecondString, then 0 is returned. Otherwise, the value returned
|
||||
is the first mismatched ASCII character in SecondString subtracted from the
|
||||
first mismatched ASCII character in FirstString.
|
||||
|
||||
If FirstString is NULL, then ASSERT().
|
||||
If SecondString is NULL, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and SecondString contains more
|
||||
than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
|
||||
@param FirstString Pointer to a Null-terminated ASCII string.
|
||||
@param SecondString Pointer to a Null-terminated ASCII string.
|
||||
|
||||
@retval 0 FirstString is identical to SecondString.
|
||||
@retval !=0 FirstString is not identical to SecondString.
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
AsciiStrnCmp (
|
||||
IN CONST CHAR8 *FirstString,
|
||||
IN CONST CHAR8 *SecondString,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
//
|
||||
// ASSERT both strings are less long than PcdMaximumAsciiStringLength
|
||||
//
|
||||
ASSERT (AsciiStrSize (FirstString));
|
||||
ASSERT (AsciiStrSize (SecondString));
|
||||
|
||||
while ((*FirstString != '\0') &&
|
||||
(*FirstString != *SecondString) &&
|
||||
(Length > 1)) {
|
||||
FirstString++;
|
||||
SecondString++;
|
||||
Length--;
|
||||
}
|
||||
return *FirstString - *SecondString;
|
||||
}
|
||||
|
||||
/**
|
||||
Concatenates one Null-terminated ASCII string to another Null-terminated
|
||||
ASCII string, and returns the concatenated ASCII string.
|
||||
|
||||
This function concatenates two Null-terminated ASCII strings. The contents of
|
||||
Null-terminated ASCII string Source are concatenated to the end of Null-
|
||||
terminated ASCII string Destination. The Null-terminated concatenated ASCII
|
||||
String is returned.
|
||||
|
||||
If Destination is NULL, then ASSERT().
|
||||
If Source is NULL, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and Destination contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and Source contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
|
||||
Source results in a ASCII string with more than PcdMaximumAsciiStringLength
|
||||
ASCII characters, then ASSERT().
|
||||
|
||||
@param Destination Pointer to a Null-terminated ASCII string.
|
||||
@param Source Pointer to a Null-terminated ASCII string.
|
||||
|
||||
@return Destination
|
||||
|
||||
**/
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
AsciiStrCat (
|
||||
IN OUT CHAR8 *Destination,
|
||||
IN CONST CHAR8 *Source
|
||||
)
|
||||
{
|
||||
AsciiStrCpy (Destination + AsciiStrLen (Destination), Source);
|
||||
|
||||
//
|
||||
// Size of the resulting string should never be zero.
|
||||
// PcdMaximumUnicodeStringLength is tested inside StrLen().
|
||||
//
|
||||
ASSERT (AsciiStrSize (Destination) != 0);
|
||||
return Destination;
|
||||
}
|
||||
|
||||
/**
|
||||
Concatenates one Null-terminated ASCII string with a maximum length to the
|
||||
end of another Null-terminated ASCII string, and returns the concatenated
|
||||
ASCII string.
|
||||
|
||||
This function concatenates two Null-terminated ASCII strings. The contents
|
||||
of Null-terminated ASCII string Source are concatenated to the end of Null-
|
||||
terminated ASCII string Destination, and Destination is returned. At most,
|
||||
Length ASCII characters are concatenated from Source to the end of
|
||||
Destination, and Destination is always Null-terminated. If Length is 0, then
|
||||
Destination is returned unmodified. If Source and Destination overlap, then
|
||||
the results are undefined.
|
||||
|
||||
If Destination is NULL, then ASSERT().
|
||||
If Source is NULL, then ASSERT().
|
||||
If Source and Destination overlap, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero, and Destination contains more
|
||||
than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero, and Source contains more than
|
||||
PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
|
||||
If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
|
||||
Source results in a ASCII string with more than PcdMaximumAsciiStringLength
|
||||
ASCII characters, then ASSERT().
|
||||
|
||||
@param Destination Pointer to a Null-terminated ASCII string.
|
||||
@param Source Pointer to a Null-terminated ASCII string.
|
||||
@param Length Maximum number of ASCII characters to concatenate from
|
||||
Source.
|
||||
|
||||
@return Destination
|
||||
|
||||
**/
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
AsciiStrnCat (
|
||||
IN OUT CHAR8 *Destination,
|
||||
IN CONST CHAR8 *Source,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length);
|
||||
|
||||
//
|
||||
// Size of the resulting string should never be zero.
|
||||
// PcdMaximumUnicodeStringLength is tested inside StrLen().
|
||||
//
|
||||
ASSERT (AsciiStrSize (Destination) != 0);
|
||||
return Destination;
|
||||
}
|
36
MdePkg/Library/BaseLib/SwapBytes16.c
Normal file
36
MdePkg/Library/BaseLib/SwapBytes16.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Switches the endianess of a 16-bit integer.
|
||||
|
||||
This function swaps the bytes in a 16-bit unsigned value to switch the value
|
||||
from little endian to big endian or vice versa. The byte swapped value is
|
||||
returned.
|
||||
|
||||
@param Operand A 16-bit unsigned value.
|
||||
|
||||
@return The byte swaped Operand.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
SwapBytes16 (
|
||||
IN UINT16 Operand
|
||||
)
|
||||
{
|
||||
return (Operand << 8) | (Operand >> 8);
|
||||
}
|
39
MdePkg/Library/BaseLib/SwapBytes32.c
Normal file
39
MdePkg/Library/BaseLib/SwapBytes32.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Switches the endianess of a 32-bit integer.
|
||||
|
||||
This function swaps the bytes in a 32-bit unsigned value to switch the value
|
||||
from little endian to big endian or vice versa. The byte swapped value is
|
||||
returned.
|
||||
|
||||
@param Operand A 32-bit unsigned value.
|
||||
|
||||
@return The byte swaped Operand.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
SwapBytes32 (
|
||||
IN UINT32 Operand
|
||||
)
|
||||
{
|
||||
return (UINT32)(
|
||||
((UINT32)SwapBytes16 ((UINT16)Operand) << 16) |
|
||||
((UINT32)SwapBytes16 ((UINT16)(Operand >> 16)))
|
||||
);
|
||||
}
|
36
MdePkg/Library/BaseLib/SwapBytes64.c
Normal file
36
MdePkg/Library/BaseLib/SwapBytes64.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/** @file
|
||||
Math worker functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "BaseLibInternals.h"
|
||||
|
||||
/**
|
||||
Switches the endianess of a 64-bit integer.
|
||||
|
||||
This function swaps the bytes in a 64-bit unsigned value to switch the value
|
||||
from little endian to big endian or vice versa. The byte swapped value is
|
||||
returned.
|
||||
|
||||
@param Operand A 64-bit unsigned value.
|
||||
|
||||
@return The byte swaped Operand.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
SwapBytes64 (
|
||||
IN UINT64 Operand
|
||||
)
|
||||
{
|
||||
return InternalMathSwapBytes64 (Operand);
|
||||
}
|
52
MdePkg/Library/BaseLib/SwitchStack.c
Normal file
52
MdePkg/Library/BaseLib/SwitchStack.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/** @file
|
||||
Switch Stack functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: SwitchStack.c
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
Transfers control to a function starting with a new stack.
|
||||
|
||||
Transfers control to the function specified by EntryPoint using the new stack
|
||||
specified by NewStack and passing in the parameters specified by Context1 and
|
||||
Context2. Context1 and Context2 are optional and may be NULL. The function
|
||||
EntryPoint must never return.
|
||||
|
||||
If EntryPoint is NULL, then ASSERT().
|
||||
If NewStack is NULL, then ASSERT().
|
||||
|
||||
@param EntryPoint A pointer to function to call with the new stack.
|
||||
@param Context1 A pointer to the context to pass into the EntryPoint
|
||||
function.
|
||||
@param Context2 A pointer to the context to pass into the EntryPoint
|
||||
function.
|
||||
@param NewStack A pointer to the new stack to use for the EntryPoint
|
||||
function.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SwitchStack (
|
||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||
IN VOID *Context1, OPTIONAL
|
||||
IN VOID *Context2, OPTIONAL
|
||||
IN VOID *NewStack
|
||||
)
|
||||
{
|
||||
//
|
||||
// This version of this function does not actually change the stack pointer
|
||||
// This is to support compilation of CPU types that do not support assemblers
|
||||
// such as EBC
|
||||
//
|
||||
EntryPoint (Context1, Context2);
|
||||
}
|
353
MdePkg/Library/BaseLib/Synchronization.c
Normal file
353
MdePkg/Library/BaseLib/Synchronization.c
Normal file
@@ -0,0 +1,353 @@
|
||||
/** @file
|
||||
Implementation of synchronization functions.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: Synchronization.c
|
||||
|
||||
**/
|
||||
|
||||
#define SPIN_LOCK_RELEASED ((SPIN_LOCK)0)
|
||||
#define SPIN_LOCK_ACQUIRED ((SPIN_LOCK)-1)
|
||||
|
||||
UINT32
|
||||
EFIAPI
|
||||
InternalSyncIncrement (
|
||||
IN volatile UINT32 *Value
|
||||
);
|
||||
|
||||
UINT32
|
||||
EFIAPI
|
||||
InternalSyncDecrement (
|
||||
IN volatile UINT32 *Value
|
||||
);
|
||||
|
||||
UINT32
|
||||
EFIAPI
|
||||
InternalSyncCompareExchange32 (
|
||||
IN volatile UINT32 *Value,
|
||||
IN UINT32 CompareValue,
|
||||
IN UINT32 ExchangeValue
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
InternalSyncCompareExchange64 (
|
||||
IN volatile UINT64 *Value,
|
||||
IN UINT64 CompareValue,
|
||||
IN UINT64 ExchangeValue
|
||||
);
|
||||
|
||||
/**
|
||||
Retrieves the architecture specific spin lock alignment requirements for
|
||||
optimal spin lock performance.
|
||||
|
||||
This function retrieves the spin lock alignment requirements for optimal
|
||||
performance on a given CPU architecture. The spin lock alignment must be a
|
||||
power of two and is returned by this function. If there are no alignment
|
||||
requirements, then 1 must be returned. The spin lock synchronization
|
||||
functions must function correctly if the spin lock size and alignment values
|
||||
returned by this function are not used at all. These values are hints to the
|
||||
consumers of the spin lock synchronization functions to obtain optimal spin
|
||||
lock performance.
|
||||
|
||||
@return The architecture specific spin lock alignment.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
GetSpinLockProperties (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
// @bug May use a PCD entry to determine this alignment.
|
||||
return 32;
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a spin lock to the released state and returns the spin lock.
|
||||
|
||||
This function initializes the spin lock specified by SpinLock to the released
|
||||
state, and returns SpinLock. Optimal performance can be achieved by calling
|
||||
GetSpinLockProperties() to determine the size and alignment requirements for
|
||||
SpinLock.
|
||||
|
||||
If SpinLock is NULL, then ASSERT().
|
||||
|
||||
@param SpinLock A pointer to the spin lock to initialize to the released
|
||||
state.
|
||||
|
||||
@return SpinLock
|
||||
|
||||
**/
|
||||
SPIN_LOCK *
|
||||
EFIAPI
|
||||
InitializeSpinLock (
|
||||
OUT SPIN_LOCK *SpinLock
|
||||
)
|
||||
{
|
||||
ASSERT (SpinLock != NULL);
|
||||
*SpinLock = 0;
|
||||
return SpinLock;
|
||||
}
|
||||
|
||||
/**
|
||||
Waits until a spin lock can be placed in the acquired state.
|
||||
|
||||
This function checks the state of the spin lock specified by SpinLock. If
|
||||
SpinLock is in the released state, then this function places SpinLock in the
|
||||
acquired state and returns SpinLock. Otherwise, this function waits
|
||||
indefinitely for the spin lock to be released, and then places it in the
|
||||
acquired state and returns SpinLock. All state transitions of SpinLock must
|
||||
be performed using MP safe mechanisms.
|
||||
|
||||
If SpinLock is NULL, then ASSERT().
|
||||
If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
|
||||
If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
|
||||
PcdSpinLockTimeout microseconds, then ASSERT().
|
||||
|
||||
@param SpinLock A pointer to the spin lock to place in the acquired state.
|
||||
|
||||
@return SpinLock
|
||||
|
||||
**/
|
||||
SPIN_LOCK *
|
||||
EFIAPI
|
||||
AcquireSpinLock (
|
||||
IN OUT SPIN_LOCK *SpinLock
|
||||
)
|
||||
{
|
||||
UINT64 Tick;
|
||||
UINT64 Start, End;
|
||||
UINT64 Timeout;
|
||||
|
||||
Tick = 0;
|
||||
Start = 0;
|
||||
End = 0;
|
||||
if (FixedPcdGet32 (PcdSpinLockTimeout) > 0) {
|
||||
Tick = GetPerformanceCounter ();
|
||||
Timeout = DivU64x32 (
|
||||
MultU64x32 (
|
||||
GetPerformanceCounterProperties (&Start, &End),
|
||||
FixedPcdGet32 (PcdSpinLockTimeout)
|
||||
),
|
||||
1000000
|
||||
);
|
||||
if (Start < End) {
|
||||
Tick += Timeout;
|
||||
} else {
|
||||
Tick -= Timeout;
|
||||
}
|
||||
}
|
||||
|
||||
while (!AcquireSpinLockOrFail (SpinLock)) {
|
||||
CpuPause ();
|
||||
ASSERT ((Start < End) ^ (Tick <= GetPerformanceCounter ()));
|
||||
}
|
||||
return SpinLock;
|
||||
}
|
||||
|
||||
/**
|
||||
Attempts to place a spin lock in the acquired state.
|
||||
|
||||
This function checks the state of the spin lock specified by SpinLock. If
|
||||
SpinLock is in the released state, then this function places SpinLock in the
|
||||
acquired state and returns TRUE. Otherwise, FALSE is returned. All state
|
||||
transitions of SpinLock must be performed using MP safe mechanisms.
|
||||
|
||||
If SpinLock is NULL, then ASSERT().
|
||||
If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
|
||||
|
||||
@param SpinLock A pointer to the spin lock to place in the acquired state.
|
||||
|
||||
@retval TRUE SpinLock was placed in the acquired state.
|
||||
@retval FALSE SpinLock could not be acquired.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
AcquireSpinLockOrFail (
|
||||
IN OUT SPIN_LOCK *SpinLock
|
||||
)
|
||||
{
|
||||
ASSERT (SpinLock != NULL);
|
||||
return (BOOLEAN)(
|
||||
InterlockedCompareExchangePointer (
|
||||
(VOID**)SpinLock,
|
||||
(VOID*)SPIN_LOCK_RELEASED,
|
||||
(VOID*)SPIN_LOCK_ACQUIRED
|
||||
) == (VOID*)SPIN_LOCK_RELEASED
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Releases a spin lock.
|
||||
|
||||
This function places the spin lock specified by SpinLock in the release state
|
||||
and returns SpinLock.
|
||||
|
||||
If SpinLock is NULL, then ASSERT().
|
||||
If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
|
||||
|
||||
@param SpinLock A pointer to the spin lock to release.
|
||||
|
||||
@return SpinLock
|
||||
|
||||
**/
|
||||
SPIN_LOCK *
|
||||
EFIAPI
|
||||
ReleaseSpinLock (
|
||||
IN OUT SPIN_LOCK *SpinLock
|
||||
)
|
||||
{
|
||||
ASSERT (SpinLock != NULL);
|
||||
*SpinLock = 0;
|
||||
return SpinLock;
|
||||
}
|
||||
|
||||
/**
|
||||
Performs an atomic increment of an 32-bit unsigned integer.
|
||||
|
||||
Performs an atomic increment of the 32-bit unsigned integer specified by
|
||||
Value and returns the incremented value. The increment operation must be
|
||||
performed using MP safe mechanisms. The state of the return value is not
|
||||
guaranteed to be MP safe.
|
||||
|
||||
If Value is NULL, then ASSERT().
|
||||
|
||||
@param Value A pointer to the 32-bit value to increment.
|
||||
|
||||
@return The incremented value.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
InterlockedIncrement (
|
||||
IN UINT32 *Value
|
||||
)
|
||||
{
|
||||
ASSERT (Value != NULL);
|
||||
return InternalSyncIncrement (Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Performs an atomic decrement of an 32-bit unsigned integer.
|
||||
|
||||
Performs an atomic decrement of the 32-bit unsigned integer specified by
|
||||
Value and returns the decremented value. The decrement operation must be
|
||||
performed using MP safe mechanisms. The state of the return value is not
|
||||
guaranteed to be MP safe.
|
||||
|
||||
If Value is NULL, then ASSERT().
|
||||
|
||||
@param Value A pointer to the 32-bit value to decrement.
|
||||
|
||||
@return The decremented value.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
InterlockedDecrement (
|
||||
IN UINT32 *Value
|
||||
)
|
||||
{
|
||||
ASSERT (Value != NULL);
|
||||
return InternalSyncDecrement (Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Performs an atomic compare exchange operation on a 32-bit unsigned integer.
|
||||
|
||||
@param Value A pointer to the 32-bit value for the compare exchange
|
||||
operation.
|
||||
@param CompareValue 32-bit value used in compare operation.
|
||||
@param ExchangeValue 32-bit value used in exchange operation.
|
||||
|
||||
@return The original *Value before exchange.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
InterlockedCompareExchange32 (
|
||||
IN UINT32 *Value,
|
||||
IN UINT32 CompareValue,
|
||||
IN UINT32 ExchangeValue
|
||||
)
|
||||
{
|
||||
ASSERT (Value != NULL);
|
||||
return InternalSyncCompareExchange32 (Value, CompareValue, ExchangeValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Performs an atomic compare exchange operation on a 64-bit unsigned integer.
|
||||
|
||||
@param Value A pointer to the 64-bit value for the compare exchange
|
||||
operation.
|
||||
@param CompareValue 64-bit value used in compare operation.
|
||||
@param ExchangeValue 64-bit value used in exchange operation.
|
||||
|
||||
@return The original *Value before exchange.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
InterlockedCompareExchange64 (
|
||||
IN UINT64 *Value,
|
||||
IN UINT64 CompareValue,
|
||||
IN UINT64 ExchangeValue
|
||||
)
|
||||
{
|
||||
ASSERT (Value != NULL);
|
||||
return InternalSyncCompareExchange64 (Value, CompareValue, ExchangeValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Performs an atomic compare exchange operation on a pointer value.
|
||||
|
||||
Performs an atomic compare exchange operation on the pointer value specified
|
||||
by Value. If Value is equal to CompareValue, then Value is set to
|
||||
ExchangeValue and CompareValue is returned. If Value is not equal to
|
||||
CompareValue, then Value is returned. The compare exchange operation must be
|
||||
performed using MP safe mechanisms.
|
||||
|
||||
If Value is NULL, then ASSERT().
|
||||
|
||||
@param Value A pointer to the pointer value for the compare exchange
|
||||
operation.
|
||||
@param CompareValue Pointer value used in compare operation.
|
||||
@param ExchangeValue Pointer value used in exchange operation.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
InterlockedCompareExchangePointer (
|
||||
IN VOID **Value,
|
||||
IN VOID *CompareValue,
|
||||
IN VOID *ExchangeValue
|
||||
)
|
||||
{
|
||||
switch (sizeof (*Value)) {
|
||||
case sizeof (UINT32):
|
||||
return (VOID*)(UINTN)InterlockedCompareExchange32 (
|
||||
(UINT32*)Value,
|
||||
(UINT32)(UINTN)CompareValue,
|
||||
(UINT32)(UINTN)ExchangeValue
|
||||
);
|
||||
case sizeof (UINT64):
|
||||
return (VOID*)(UINTN)InterlockedCompareExchange64 (
|
||||
(UINT64*)Value,
|
||||
(UINT64)(UINTN)CompareValue,
|
||||
(UINT64)(UINTN)ExchangeValue
|
||||
);
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
return NULL;
|
||||
}
|
||||
}
|
203
MdePkg/Library/BaseLib/Unaligned.c
Normal file
203
MdePkg/Library/BaseLib/Unaligned.c
Normal file
@@ -0,0 +1,203 @@
|
||||
/** @file
|
||||
Unaligned access functions of BaseLib.
|
||||
|
||||
Copyright (c) 2006, 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.
|
||||
|
||||
Module Name: Unaligned.c
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
Reads a 16-bit value from memory that may be unaligned.
|
||||
|
||||
This function returns the 16-bit value pointed to by Buffer. The function
|
||||
guarantees that the read operation does not produce an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 16-bit value that may be unaligned.
|
||||
|
||||
@return *Uint16
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
ReadUnaligned16 (
|
||||
IN CONST UINT16 *Buffer
|
||||
)
|
||||
{
|
||||
return *Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 16-bit value to memory that may be unaligned.
|
||||
|
||||
This function writes the 16-bit value specified by Value to Buffer. Value is
|
||||
returned. The function guarantees that the write operation does not produce
|
||||
an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 16-bit value that may be unaligned.
|
||||
@param Value 16-bit value to write to Buffer.
|
||||
|
||||
@return Value
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
WriteUnaligned16 (
|
||||
OUT UINT16 *Buffer,
|
||||
IN UINT16 Value
|
||||
)
|
||||
{
|
||||
return *Buffer = Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 24-bit value from memory that may be unaligned.
|
||||
|
||||
This function returns the 24-bit value pointed to by Buffer. The function
|
||||
guarantees that the read operation does not produce an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 24-bit value that may be unaligned.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
ReadUnaligned24 (
|
||||
IN CONST UINT32 *Buffer
|
||||
)
|
||||
{
|
||||
return *Buffer & 0xffffff;
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 24-bit value to memory that may be unaligned.
|
||||
|
||||
This function writes the 24-bit value specified by Value to Buffer. Value is
|
||||
returned. The function guarantees that the write operation does not produce
|
||||
an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 24-bit value that may be unaligned.
|
||||
@param Value 24-bit value to write to Buffer.
|
||||
|
||||
@return The value written.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
WriteUnaligned24 (
|
||||
OUT UINT32 *Buffer,
|
||||
IN UINT32 Value
|
||||
)
|
||||
{
|
||||
return *Buffer = BitFieldWrite32 (*Buffer, 0, 23, Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 32-bit value from memory that may be unaligned.
|
||||
|
||||
This function returns the 32-bit value pointed to by Buffer. The function
|
||||
guarantees that the read operation does not produce an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 32-bit value that may be unaligned.
|
||||
|
||||
@return *Uint32
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
ReadUnaligned32 (
|
||||
IN CONST UINT32 *Buffer
|
||||
)
|
||||
{
|
||||
return *Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 32-bit value to memory that may be unaligned.
|
||||
|
||||
This function writes the 32-bit value specified by Value to Buffer. Value is
|
||||
returned. The function guarantees that the write operation does not produce
|
||||
an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 32-bit value that may be unaligned.
|
||||
@param Value 32-bit value to write to Buffer.
|
||||
|
||||
@return Value
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
WriteUnaligned32 (
|
||||
OUT UINT32 *Buffer,
|
||||
IN UINT32 Value
|
||||
)
|
||||
{
|
||||
return *Buffer = Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 64-bit value from memory that may be unaligned.
|
||||
|
||||
This function returns the 64-bit value pointed to by Buffer. The function
|
||||
guarantees that the read operation does not produce an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 64-bit value that may be unaligned.
|
||||
|
||||
@return *Uint64
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
ReadUnaligned64 (
|
||||
IN CONST UINT64 *Buffer
|
||||
)
|
||||
{
|
||||
return *Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 64-bit value to memory that may be unaligned.
|
||||
|
||||
This function writes the 64-bit value specified by Value to Buffer. Value is
|
||||
returned. The function guarantees that the write operation does not produce
|
||||
an alignment fault.
|
||||
|
||||
If the Buffer is NULL, then ASSERT().
|
||||
|
||||
@param Buffer Pointer to a 64-bit value that may be unaligned.
|
||||
@param Value 64-bit value to write to Buffer.
|
||||
|
||||
@return Value
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
WriteUnaligned64 (
|
||||
OUT UINT64 *Buffer,
|
||||
IN UINT64 Value
|
||||
)
|
||||
{
|
||||
return *Buffer = Value;
|
||||
}
|
47
MdePkg/Library/BaseLib/build.xml
Normal file
47
MdePkg/Library/BaseLib/build.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!-- Copyright (c) 2006, 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.-->
|
||||
<project basedir="." default="BaseLib"><!--Apply external ANT tasks-->
|
||||
<taskdef resource="GenBuild.tasks"/>
|
||||
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
|
||||
<property environment="env"/>
|
||||
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
|
||||
<import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
|
||||
<property name="MODULE_RELATIVE_PATH" value="Library\BaseLib"/>
|
||||
<property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
|
||||
<property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
|
||||
<target name="BaseLib">
|
||||
<GenBuild baseName="BaseLib" mbdFilename="${MODULE_DIR}\BaseLib.mbd" msaFilename="${MODULE_DIR}\BaseLib.msa"/>
|
||||
</target>
|
||||
<target depends="BaseLib_clean" name="clean"/>
|
||||
<target depends="BaseLib_cleanall" name="cleanall"/>
|
||||
<target name="BaseLib_clean">
|
||||
<OutputDirSetup baseName="BaseLib" mbdFilename="${MODULE_DIR}\BaseLib.mbd" msaFilename="${MODULE_DIR}\BaseLib.msa"/>
|
||||
<if>
|
||||
<available file="${DEST_DIR_OUTPUT}\BaseLib_build.xml"/>
|
||||
<then>
|
||||
<ant antfile="${DEST_DIR_OUTPUT}\BaseLib_build.xml" target="clean"/>
|
||||
</then>
|
||||
</if>
|
||||
<delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
|
||||
</target>
|
||||
<target name="BaseLib_cleanall">
|
||||
<OutputDirSetup baseName="BaseLib" mbdFilename="${MODULE_DIR}\BaseLib.mbd" msaFilename="${MODULE_DIR}\BaseLib.msa"/>
|
||||
<if>
|
||||
<available file="${DEST_DIR_OUTPUT}\BaseLib_build.xml"/>
|
||||
<then>
|
||||
<ant antfile="${DEST_DIR_OUTPUT}\BaseLib_build.xml" target="cleanall"/>
|
||||
</then>
|
||||
</if>
|
||||
<delete dir="${DEST_DIR_OUTPUT}"/>
|
||||
<delete dir="${DEST_DIR_DEBUG}"/>
|
||||
<delete>
|
||||
<fileset dir="${BIN_DIR}" includes="**BaseLib*"/>
|
||||
</delete>
|
||||
</target>
|
||||
</project>
|
38
MdePkg/Library/BaseLib/ia32/ARShiftU64.asm
Normal file
38
MdePkg/Library/BaseLib/ia32/ARShiftU64.asm
Normal file
@@ -0,0 +1,38 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; ARShiftU64.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; 64-bit arithmetic right shift function for IA-32
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
InternalMathARShiftU64 PROC
|
||||
mov cl, [esp + 12]
|
||||
mov eax, [esp + 8]
|
||||
cdq
|
||||
test cl, 32
|
||||
cmovz edx, eax
|
||||
cmovz eax, [esp + 4]
|
||||
shrd eax, edx, cl
|
||||
sar edx, cl
|
||||
ret
|
||||
InternalMathARShiftU64 ENDP
|
||||
|
||||
END
|
41
MdePkg/Library/BaseLib/ia32/ARShiftU64.s
Normal file
41
MdePkg/Library/BaseLib/ia32/ARShiftU64.s
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# ARShiftU64.asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# 64-bit arithmetic right shift function for IA-32
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.global _ARShiftU64
|
||||
_ARShiftU64:
|
||||
movb 12(%esp),%cl
|
||||
movl 8(%esp),%eax
|
||||
cltd
|
||||
testb $32,%cl
|
||||
# MISMATCH: " cmovz edx, eax"
|
||||
cmovz %eax, %edx
|
||||
# MISMATCH: " cmovz eax, [esp + 4]"
|
||||
cmovz 4(%esp), %eax
|
||||
shrdl %cl,%edx,%eax
|
||||
sar %cl,%edx
|
||||
ret
|
||||
|
||||
|
||||
|
40
MdePkg/Library/BaseLib/ia32/CpuBreakpoint.asm
Normal file
40
MdePkg/Library/BaseLib/ia32/CpuBreakpoint.asm
Normal file
@@ -0,0 +1,40 @@
|
||||
;------------------------------------------------------------------------------ ;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; CpuBreakpoint.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; CpuBreakpoint function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686
|
||||
.model flat
|
||||
.xmm
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; CpuBreakpoint (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_CpuBreakpoint PROC
|
||||
int 3
|
||||
ret
|
||||
_CpuBreakpoint ENDP
|
||||
|
||||
END
|
41
MdePkg/Library/BaseLib/ia32/CpuBreakpoint.s
Normal file
41
MdePkg/Library/BaseLib/ia32/CpuBreakpoint.s
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------ ;
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# CpuBreakpoint.s
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# CpuBreakpoint function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# CpuBreakpoint (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _CpuBreakpoint
|
||||
_CpuBreakpoint:
|
||||
int 3
|
||||
ret
|
||||
|
||||
|
||||
|
40
MdePkg/Library/BaseLib/ia32/CpuFlushTlb.asm
Normal file
40
MdePkg/Library/BaseLib/ia32/CpuFlushTlb.asm
Normal file
@@ -0,0 +1,40 @@
|
||||
;------------------------------------------------------------------------------ ;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; CpuFlushTlb.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; CpuFlushTlb function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386p
|
||||
.model flat
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; CpuFlushTlb (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_CpuFlushTlb PROC
|
||||
mov eax, cr3
|
||||
mov cr3, eax
|
||||
ret
|
||||
_CpuFlushTlb ENDP
|
||||
|
||||
END
|
41
MdePkg/Library/BaseLib/ia32/CpuFlushTlb.s
Normal file
41
MdePkg/Library/BaseLib/ia32/CpuFlushTlb.s
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------ ;
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# CpuFlushTlb.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# CpuFlushTlb function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# CpuFlushTlb (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _CpuFlushTlb
|
||||
_CpuFlushTlb:
|
||||
movl %cr3, %eax
|
||||
movl %eax, %cr3
|
||||
ret
|
||||
|
||||
|
||||
|
66
MdePkg/Library/BaseLib/ia32/CpuId.asm
Normal file
66
MdePkg/Library/BaseLib/ia32/CpuId.asm
Normal file
@@ -0,0 +1,66 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; CpuId.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; AsmCpuid function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.586P
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; AsmCpuid (
|
||||
; IN UINT32 RegisterInEax,
|
||||
; OUT UINT32 *RegisterOutEax OPTIONAL,
|
||||
; OUT UINT32 *RegisterOutEbx OPTIONAL,
|
||||
; OUT UINT32 *RegisterOutEcx OPTIONAL,
|
||||
; OUT UINT32 *RegisterOutEdx OPTIONAL
|
||||
; )
|
||||
;------------------------------------------------------------------------------
|
||||
AsmCpuid PROC USES ebx
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
mov eax, [ebp + 12]
|
||||
cpuid
|
||||
push ecx
|
||||
mov ecx, [ebp + 16]
|
||||
jecxz @F
|
||||
mov [ecx], eax
|
||||
@@:
|
||||
mov ecx, [ebp + 20]
|
||||
jecxz @F
|
||||
mov [ecx], ebx
|
||||
@@:
|
||||
mov ecx, [ebp + 24]
|
||||
jecxz @F
|
||||
pop [ecx]
|
||||
@@:
|
||||
mov ecx, [ebp + 28]
|
||||
jecxz @F
|
||||
mov [ecx], edx
|
||||
@@:
|
||||
mov eax, [ebp + 12]
|
||||
leave
|
||||
ret
|
||||
AsmCpuid ENDP
|
||||
|
||||
END
|
63
MdePkg/Library/BaseLib/ia32/CpuId.s
Normal file
63
MdePkg/Library/BaseLib/ia32/CpuId.s
Normal file
@@ -0,0 +1,63 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# CpuId.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# AsmCpuid function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# AsmCpuid (
|
||||
# IN UINT32 RegisterInEax,
|
||||
# OUT UINT32 *RegisterOutEax OPTIONAL,
|
||||
# OUT UINT32 *RegisterOutEbx OPTIONAL,
|
||||
# OUT UINT32 *RegisterOutEcx OPTIONAL,
|
||||
# OUT UINT32 *RegisterOutEdx OPTIONAL
|
||||
# )
|
||||
#------------------------------------------------------------------------------
|
||||
.globl _AsmCpuid
|
||||
_AsmCpuid:
|
||||
push %ebx
|
||||
push %edi
|
||||
movl 12(%esp),%eax
|
||||
cpuid
|
||||
movl %ecx,%edi
|
||||
movl 16(%esp),%ecx
|
||||
jecxz L1
|
||||
movl %eax,(%ecx)
|
||||
L1:
|
||||
movl 20(%esp),%ecx
|
||||
jecxz L2
|
||||
movl %ebx,(%ecx)
|
||||
L2:
|
||||
movl 24(%esp),%ecx
|
||||
jecxz L3
|
||||
movl %edi,(%ecx)
|
||||
L3:
|
||||
movl 28(%esp),%ecx
|
||||
jecxz L4
|
||||
movl %edx,(%ecx)
|
||||
L4:
|
||||
pop %edi
|
||||
pop %ebx
|
||||
ret
|
40
MdePkg/Library/BaseLib/ia32/CpuPause.asm
Normal file
40
MdePkg/Library/BaseLib/ia32/CpuPause.asm
Normal file
@@ -0,0 +1,40 @@
|
||||
;------------------------------------------------------------------------------ ;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; CpuPause.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; CpuPause function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686
|
||||
.model flat
|
||||
.xmm
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; CpuPause (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_CpuPause PROC
|
||||
pause
|
||||
ret
|
||||
_CpuPause ENDP
|
||||
|
||||
END
|
41
MdePkg/Library/BaseLib/ia32/CpuPause.s
Normal file
41
MdePkg/Library/BaseLib/ia32/CpuPause.s
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------ ;
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# CpuPause.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# CpuPause function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# CpuPause (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _CpuPause
|
||||
_CpuPause:
|
||||
pause
|
||||
ret
|
||||
|
||||
|
||||
|
39
MdePkg/Library/BaseLib/ia32/CpuSleep.asm
Normal file
39
MdePkg/Library/BaseLib/ia32/CpuSleep.asm
Normal file
@@ -0,0 +1,39 @@
|
||||
;------------------------------------------------------------------------------ ;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; CpuSleep.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; CpuSleep function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; CpuSleep (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_CpuSleep PROC
|
||||
hlt
|
||||
ret
|
||||
_CpuSleep ENDP
|
||||
|
||||
END
|
40
MdePkg/Library/BaseLib/ia32/CpuSleep.s
Normal file
40
MdePkg/Library/BaseLib/ia32/CpuSleep.s
Normal file
@@ -0,0 +1,40 @@
|
||||
#------------------------------------------------------------------------------ ;
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# CpuSleep.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# CpuSleep function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# CpuSleep (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _CpuSleep
|
||||
_CpuSleep:
|
||||
hlt
|
||||
ret
|
||||
|
||||
|
||||
|
40
MdePkg/Library/BaseLib/ia32/DisableInterrupts.asm
Normal file
40
MdePkg/Library/BaseLib/ia32/DisableInterrupts.asm
Normal file
@@ -0,0 +1,40 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; DisableInterrupts.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; DisableInterrupts function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386p
|
||||
.model flat
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; DisableInterrupts (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_DisableInterrupts PROC
|
||||
cli
|
||||
ret
|
||||
_DisableInterrupts ENDP
|
||||
|
||||
END
|
41
MdePkg/Library/BaseLib/ia32/DisableInterrupts.s
Normal file
41
MdePkg/Library/BaseLib/ia32/DisableInterrupts.s
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# DisableInterrupts.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# DisableInterrupts function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# DisableInterrupts (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _DisableInterrupts
|
||||
_DisableInterrupts:
|
||||
cli
|
||||
ret
|
||||
|
||||
|
||||
|
57
MdePkg/Library/BaseLib/ia32/DisablePaging32.asm
Normal file
57
MdePkg/Library/BaseLib/ia32/DisablePaging32.asm
Normal file
@@ -0,0 +1,57 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; DisablePaging32.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; AsmDisablePaging32 function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; InternalX86DisablePaging32 (
|
||||
; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||
; IN VOID *Context1, OPTIONAL
|
||||
; IN VOID *Context2, OPTIONAL
|
||||
; IN VOID *NewStack
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalX86DisablePaging32 PROC
|
||||
mov ebx, [esp + 4]
|
||||
mov ecx, [esp + 8]
|
||||
mov edx, [esp + 12]
|
||||
pushfd
|
||||
pop edi
|
||||
cli
|
||||
mov eax, cr0
|
||||
btr eax, 31
|
||||
mov esp, [esp + 16]
|
||||
mov cr0, eax
|
||||
push edi
|
||||
popfd
|
||||
push edx
|
||||
push ecx
|
||||
call ebx
|
||||
jmp $
|
||||
InternalX86DisablePaging32 ENDP
|
||||
|
||||
END
|
58
MdePkg/Library/BaseLib/ia32/DisablePaging32.s
Normal file
58
MdePkg/Library/BaseLib/ia32/DisablePaging32.s
Normal file
@@ -0,0 +1,58 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# DisablePaging32.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# AsmDisablePaging32 function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# AsmDisablePaging32 (
|
||||
# IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||
# IN VOID *Context1, OPTIONAL
|
||||
# IN VOID *Context2, OPTIONAL
|
||||
# IN VOID *NewStack
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _AsmDisablePaging32
|
||||
_AsmDisablePaging32:
|
||||
movl 4(%esp),%ebx
|
||||
movl 8(%esp),%ecx
|
||||
movl 12(%esp),%edx
|
||||
pushfl
|
||||
popl %edi
|
||||
cli
|
||||
movl %cr0, %eax
|
||||
btrl $31,%eax
|
||||
movl 16(%esp),%esp
|
||||
movl %eax, %cr0
|
||||
pushl %edi
|
||||
popfl
|
||||
pushl %edx
|
||||
pushl %ecx
|
||||
call *%ebx
|
||||
jmp .
|
||||
|
||||
|
||||
|
38
MdePkg/Library/BaseLib/ia32/DivS64x64Remainder.c
Normal file
38
MdePkg/Library/BaseLib/ia32/DivS64x64Remainder.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/** @file
|
||||
Integer division worker functions for Ia32.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation<BR>
|
||||
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.
|
||||
|
||||
Module Name: DivS64x64Remainder.c
|
||||
|
||||
**/
|
||||
|
||||
#include "../BaseLibInternals.h"
|
||||
|
||||
INT64
|
||||
EFIAPI
|
||||
InternalMathDivRemS64x64 (
|
||||
IN INT64 Dividend,
|
||||
IN INT64 Divisor,
|
||||
OUT INT64 *Remainder
|
||||
)
|
||||
{
|
||||
INT64 Quot;
|
||||
|
||||
Quot = InternalMathDivRemU64x64 (
|
||||
Dividend >= 0 ? Dividend : -Dividend,
|
||||
Divisor >= 0 ? Divisor : -Divisor,
|
||||
(UINT64 *) Remainder
|
||||
);
|
||||
if (Remainder != NULL && Dividend < 0) {
|
||||
*Remainder = -*Remainder;
|
||||
}
|
||||
return (Dividend ^ Divisor) >= 0 ? Quot : -Quot;
|
||||
}
|
38
MdePkg/Library/BaseLib/ia32/DivU64x32.asm
Normal file
38
MdePkg/Library/BaseLib/ia32/DivU64x32.asm
Normal file
@@ -0,0 +1,38 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; DivU64x32.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Calculate the quotient of a 64-bit integer by a 32-bit integer
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
InternalMathDivU64x32 PROC
|
||||
mov eax, [esp + 8]
|
||||
mov ecx, [esp + 12]
|
||||
xor edx, edx
|
||||
div ecx
|
||||
push eax
|
||||
mov eax, [esp + 8]
|
||||
div ecx
|
||||
pop edx
|
||||
ret
|
||||
InternalMathDivU64x32 ENDP
|
||||
|
||||
END
|
39
MdePkg/Library/BaseLib/ia32/DivU64x32.s
Normal file
39
MdePkg/Library/BaseLib/ia32/DivU64x32.s
Normal file
@@ -0,0 +1,39 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# DivU64x32.asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# Calculate the quotient of a 64-bit integer by a 32-bit integer
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.global _DivU64x32
|
||||
_DivU64x32:
|
||||
movl 8(%esp),%eax
|
||||
movl 12(%esp),%ecx
|
||||
xorl %edx,%edx
|
||||
divl %ecx
|
||||
pushl %eax
|
||||
movl 8(%esp),%eax
|
||||
divl %ecx
|
||||
popl %edx
|
||||
ret
|
||||
|
||||
|
||||
|
42
MdePkg/Library/BaseLib/ia32/DivU64x32Remainder.asm
Normal file
42
MdePkg/Library/BaseLib/ia32/DivU64x32Remainder.asm
Normal file
@@ -0,0 +1,42 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; DivError.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Set error flag for all division functions
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
InternalMathDivRemU64x32 PROC
|
||||
mov ecx, [esp + 12]
|
||||
mov eax, [esp + 8]
|
||||
xor edx, edx
|
||||
div ecx
|
||||
push eax
|
||||
mov eax, [esp + 8]
|
||||
div ecx
|
||||
mov ecx, [esp + 20]
|
||||
jecxz @F
|
||||
mov [ecx], edx
|
||||
@@:
|
||||
pop edx
|
||||
ret
|
||||
InternalMathDivRemU64x32 ENDP
|
||||
|
||||
END
|
43
MdePkg/Library/BaseLib/ia32/DivU64x32Remainder.s
Normal file
43
MdePkg/Library/BaseLib/ia32/DivU64x32Remainder.s
Normal file
@@ -0,0 +1,43 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# DivError.asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# Set error flag for all division functions
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.global _InternalMathDivRemU64x32
|
||||
_InternalMathDivRemU64x32:
|
||||
movl 12(%esp),%ecx
|
||||
movl 8(%esp),%eax
|
||||
xorl %edx,%edx
|
||||
divl %ecx
|
||||
pushl %eax
|
||||
movl 8(%esp),%eax
|
||||
divl %ecx
|
||||
movl 20(%esp),%ecx
|
||||
jecxz L1
|
||||
movl %edx,(%ecx)
|
||||
L1:
|
||||
popl %edx
|
||||
ret
|
||||
|
||||
|
||||
|
83
MdePkg/Library/BaseLib/ia32/DivU64x64Remainder.asm
Normal file
83
MdePkg/Library/BaseLib/ia32/DivU64x64Remainder.asm
Normal file
@@ -0,0 +1,83 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; DivU64x64Remainder.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Calculate the quotient of a 64-bit integer by a 64-bit integer and returns
|
||||
; both the quotient and the remainder
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
EXTERN InternalMathDivRemU64x32:PROC
|
||||
|
||||
InternalMathDivRemU64x64 PROC
|
||||
mov ecx, [esp + 16]
|
||||
test ecx, ecx
|
||||
jnz _@DivRemU64x64
|
||||
mov ecx, [esp + 20]
|
||||
jecxz @F
|
||||
and dword ptr [ecx + 4], 0
|
||||
mov [esp + 16], ecx
|
||||
@@:
|
||||
jmp InternalMathDivRemU64x32
|
||||
InternalMathDivRemU64x64 ENDP
|
||||
|
||||
_@DivRemU64x64 PROC USES ebx esi edi
|
||||
mov edx, dword ptr [esp + 20]
|
||||
mov eax, dword ptr [esp + 16]
|
||||
mov edi, edx
|
||||
mov esi, eax
|
||||
mov ebx, dword ptr [esp + 24]
|
||||
@@:
|
||||
shr edx, 1
|
||||
rcr eax, 1
|
||||
shrd ebx, ecx, 1
|
||||
shr ecx, 1
|
||||
jnz @B
|
||||
div ebx
|
||||
mov ebx, eax
|
||||
mov ecx, [esp + 28]
|
||||
mul dword ptr [esp + 24]
|
||||
imul ecx, ebx
|
||||
add edx, ecx
|
||||
mov ecx, dword ptr [esp + 32]
|
||||
jc @TooLarge
|
||||
cmp edi, edx
|
||||
ja @Correct
|
||||
jb @TooLarge
|
||||
cmp esi, eax
|
||||
jae @Correct
|
||||
@TooLarge:
|
||||
dec ebx
|
||||
jecxz @Return
|
||||
sub eax, dword ptr [esp + 24]
|
||||
sbb edx, dword ptr [esp + 28]
|
||||
@Correct:
|
||||
jecxz @Return
|
||||
sub esi, eax
|
||||
sbb edi, edx
|
||||
mov [ecx], esi
|
||||
mov [ecx + 4], edi
|
||||
@Return:
|
||||
mov eax, ebx
|
||||
xor edx, edx
|
||||
ret
|
||||
_@DivRemU64x64 ENDP
|
||||
|
||||
END
|
89
MdePkg/Library/BaseLib/ia32/DivU64x64Remainder.s
Normal file
89
MdePkg/Library/BaseLib/ia32/DivU64x64Remainder.s
Normal file
@@ -0,0 +1,89 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# DivU64x64Remainder.asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# Calculate the quotient of a 64-bit integer by a 64-bit integer and returns
|
||||
# both the quotient and the remainder
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.extern _InternalMathDivRemU64x32
|
||||
|
||||
.global _InternalMathDivRemU64x64
|
||||
_InternalMathDivRemU64x64:
|
||||
movl 16(%esp),%ecx
|
||||
testl %ecx,%ecx
|
||||
jnz _DivRemU64x64
|
||||
movl 20(%esp),%ecx
|
||||
jecxz L1
|
||||
and $0,4(%ecx)
|
||||
movl %ecx,16(%esp)
|
||||
L1:
|
||||
jmp _InternalMathDivRemU64x32
|
||||
|
||||
|
||||
.global DivRemU64x64
|
||||
DivRemU64x64:
|
||||
# MISMATCH: "DivRemU64x64: USES ebx esi edi"
|
||||
push %ebx
|
||||
push %esi
|
||||
push %edi
|
||||
mov 20(%esp), %edx
|
||||
mov 16(%esp), %eax
|
||||
movl %edx,%edi
|
||||
movl %eax,%esi
|
||||
mov 24(%esp), %ebx
|
||||
L2:
|
||||
shrl %edx
|
||||
rcrl $1,%eax
|
||||
shrdl $1,%ecx,%ebx
|
||||
shrl %ecx
|
||||
jnz L2
|
||||
divl %ebx
|
||||
movl %eax,%ebx
|
||||
movl 28(%esp),%ecx
|
||||
mull 24(%esp)
|
||||
imull %ebx,%ecx
|
||||
addl %ecx,%edx
|
||||
mov 32(%esp), %ecx
|
||||
jc TooLarge
|
||||
cmpl %edx,%edi
|
||||
ja Correct
|
||||
jb TooLarge
|
||||
cmpl %eax,%esi
|
||||
jae Correct
|
||||
TooLarge:
|
||||
decl %ebx
|
||||
jecxz Return
|
||||
sub 24(%esp), %eax
|
||||
sbb 28(%esp), %edx
|
||||
Correct:
|
||||
jecxz Return
|
||||
subl %eax,%esi
|
||||
sbbl %edx,%edi
|
||||
movl %esi,(%ecx)
|
||||
movl %edi,4(%ecx)
|
||||
Return:
|
||||
movl %ebx,%eax
|
||||
xorl %edx,%edx
|
||||
push %edi
|
||||
push %esi
|
||||
push %ebx
|
||||
ret
|
41
MdePkg/Library/BaseLib/ia32/EnableDisableInterrupts.asm
Normal file
41
MdePkg/Library/BaseLib/ia32/EnableDisableInterrupts.asm
Normal file
@@ -0,0 +1,41 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; EnableDisableInterrupts.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; EnableDisableInterrupts function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386p
|
||||
.model flat
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; EnableDisableInterrupts (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_EnableDisableInterrupts PROC
|
||||
sti
|
||||
cli
|
||||
ret
|
||||
_EnableDisableInterrupts ENDP
|
||||
|
||||
END
|
42
MdePkg/Library/BaseLib/ia32/EnableDisableInterrupts.s
Normal file
42
MdePkg/Library/BaseLib/ia32/EnableDisableInterrupts.s
Normal file
@@ -0,0 +1,42 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# EnableDisableInterrupts.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# EnableDisableInterrupts function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# EnableDisableInterrupts (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _EnableDisableInterrupts
|
||||
_EnableDisableInterrupts:
|
||||
sti
|
||||
cli
|
||||
ret
|
||||
|
||||
|
||||
|
40
MdePkg/Library/BaseLib/ia32/EnableInterrupts.asm
Normal file
40
MdePkg/Library/BaseLib/ia32/EnableInterrupts.asm
Normal file
@@ -0,0 +1,40 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; EnableInterrupts.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; EnableInterrupts function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386p
|
||||
.model flat
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; EnableInterrupts (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_EnableInterrupts PROC
|
||||
sti
|
||||
ret
|
||||
_EnableInterrupts ENDP
|
||||
|
||||
END
|
41
MdePkg/Library/BaseLib/ia32/EnableInterrupts.s
Normal file
41
MdePkg/Library/BaseLib/ia32/EnableInterrupts.s
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# EnableInterrupts.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# EnableInterrupts function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# EnableInterrupts (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _EnableInterrupts
|
||||
_EnableInterrupts:
|
||||
sti
|
||||
ret
|
||||
|
||||
|
||||
|
57
MdePkg/Library/BaseLib/ia32/EnablePaging32.asm
Normal file
57
MdePkg/Library/BaseLib/ia32/EnablePaging32.asm
Normal file
@@ -0,0 +1,57 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; EnablePaging32.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; AsmEnablePaging32 function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; InternalX86EnablePaging32 (
|
||||
; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||
; IN VOID *Context1, OPTIONAL
|
||||
; IN VOID *Context2, OPTIONAL
|
||||
; IN VOID *NewStack
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalX86EnablePaging32 PROC
|
||||
mov ebx, [esp + 4]
|
||||
mov ecx, [esp + 8]
|
||||
mov edx, [esp + 12]
|
||||
pushfd
|
||||
pop edi
|
||||
cli
|
||||
mov eax, cr0
|
||||
bts eax, 31
|
||||
mov esp, [esp + 16]
|
||||
mov cr0, eax
|
||||
push edi
|
||||
popfd
|
||||
push edx
|
||||
push ecx
|
||||
call ebx
|
||||
jmp $
|
||||
InternalX86EnablePaging32 ENDP
|
||||
|
||||
END
|
58
MdePkg/Library/BaseLib/ia32/EnablePaging32.s
Normal file
58
MdePkg/Library/BaseLib/ia32/EnablePaging32.s
Normal file
@@ -0,0 +1,58 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# EnablePaging32.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# AsmEnablePaging32 function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# AsmEnablePaging32 (
|
||||
# IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||
# IN VOID *Context1, OPTIONAL
|
||||
# IN VOID *Context2, OPTIONAL
|
||||
# IN VOID *NewStack
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _AsmEnablePaging32
|
||||
_AsmEnablePaging32:
|
||||
movl 4(%esp),%ebx
|
||||
movl 8(%esp),%ecx
|
||||
movl 12(%esp),%edx
|
||||
pushfl
|
||||
popl %edi
|
||||
cli
|
||||
movl %cr0, %eax
|
||||
btsl $31,%eax
|
||||
movl 16(%esp),%esp
|
||||
movl %eax, %cr0
|
||||
pushl %edi
|
||||
popfl
|
||||
pushl %edx
|
||||
pushl %ecx
|
||||
call *%ebx
|
||||
jmp .
|
||||
|
||||
|
||||
|
57
MdePkg/Library/BaseLib/ia32/EnablePaging64.asm
Normal file
57
MdePkg/Library/BaseLib/ia32/EnablePaging64.asm
Normal file
@@ -0,0 +1,57 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; EnablePaging64.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; AsmEnablePaging64 function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686p
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
InternalX86EnablePaging64 PROC
|
||||
cli
|
||||
mov [esp], @F ; offset for far retf
|
||||
mov eax, cr4
|
||||
or al, (1 SHL 5)
|
||||
mov cr4, eax ; enable PAE
|
||||
mov ecx, 0c0000080h
|
||||
rdmsr
|
||||
or ah, 1 ; set LME
|
||||
wrmsr
|
||||
mov eax, cr0
|
||||
bts eax, 31
|
||||
mov cr0, eax ; enable paging
|
||||
retf
|
||||
@@: ; long mode starts here
|
||||
DB 67h, 48h
|
||||
mov ebx, [esp] ; mov rbx, [esp]
|
||||
DB 67h, 48h
|
||||
mov ecx, [esp + 8] ; mov rcx, [esp + 8]
|
||||
DB 67h, 48h
|
||||
mov edx, [esp + 10h] ; mov rdx, [esp + 10h]
|
||||
DB 67h, 48h
|
||||
mov esp, [esp + 18h] ; mov rsp, [esp + 18h]
|
||||
DB 48h
|
||||
add esp, -20h ; add rsp, -20h
|
||||
call ebx ; call rbx
|
||||
jmp $
|
||||
InternalX86EnablePaging64 ENDP
|
||||
|
||||
END
|
66
MdePkg/Library/BaseLib/ia32/EnablePaging64.s
Normal file
66
MdePkg/Library/BaseLib/ia32/EnablePaging64.s
Normal file
@@ -0,0 +1,66 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# EnablePaging64.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# AsmEnablePaging64 function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#.MODEL flat
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# AsmEnablePaging64 (
|
||||
# IN UINT16 CodeSelector,
|
||||
# IN UINT64 EntryPoint,
|
||||
# IN UINT64 Context1, OPTIONAL
|
||||
# IN UINT64 Context2, OPTIONAL
|
||||
# IN UINT64 NewStack
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _AsmEnablePaging64
|
||||
_AsmEnablePaging64:
|
||||
cli
|
||||
movl $$LongStart, (%esp)
|
||||
movl %cr4, %eax
|
||||
orb $0x20, %al
|
||||
movl %eax, %cr4 # enable PAE
|
||||
movl $0xc0000080, %ecx
|
||||
rdmsr
|
||||
orb $1, %ah # set LME
|
||||
wrmsr
|
||||
movl %cr0, %eax
|
||||
btsl $31, %eax
|
||||
movl %eax, %cr0 # enable paging
|
||||
lret
|
||||
LongStart: # long mode starts here
|
||||
.byte 0x67,0x48
|
||||
movl (%esp), %ebx # mov rbx, [esp]
|
||||
.byte 0x67,0x48
|
||||
movl 8(%esp), %ecx # mov rcx, [esp + 8]
|
||||
.byte 0x67,0x48
|
||||
movl 0x10(%esp), %edx # mov rdx, [esp + 10h]
|
||||
.byte 0x67,0x48
|
||||
movl 0x18(%esp), %esp # mov rsp, [esp + 18h]
|
||||
.byte 0x48
|
||||
addl $0x-20, %esp # add rsp, -20h
|
||||
call *%ebx # call rbx
|
||||
jmp .
|
42
MdePkg/Library/BaseLib/ia32/FlushCacheLine.asm
Normal file
42
MdePkg/Library/BaseLib/ia32/FlushCacheLine.asm
Normal file
@@ -0,0 +1,42 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; FlushCacheLine.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; AsmFlushCacheLine function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.586P
|
||||
.model flat
|
||||
.xmm
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; AsmFlushCacheLine (
|
||||
; IN VOID *LinearAddress
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_AsmFlushCacheLine PROC
|
||||
mov eax, [esp + 4]
|
||||
clflush [eax]
|
||||
ret
|
||||
_AsmFlushCacheLine ENDP
|
||||
|
||||
END
|
43
MdePkg/Library/BaseLib/ia32/FlushCacheLine.s
Normal file
43
MdePkg/Library/BaseLib/ia32/FlushCacheLine.s
Normal file
@@ -0,0 +1,43 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# FlushCacheLine.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# AsmFlushCacheLine function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# AsmFlushCacheLine (
|
||||
# IN VOID *LinearAddress
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _AsmFlushCacheLine
|
||||
_AsmFlushCacheLine:
|
||||
movl 4(%esp),%eax
|
||||
clflush (%eax)
|
||||
ret
|
||||
|
||||
|
||||
|
42
MdePkg/Library/BaseLib/ia32/FxRestore.asm
Normal file
42
MdePkg/Library/BaseLib/ia32/FxRestore.asm
Normal file
@@ -0,0 +1,42 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; FxRestore.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; AsmFxRestore function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.586P
|
||||
.model flat,C
|
||||
.xmm
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; InternalX86FxRestore (
|
||||
; IN CONST IA32_FX_BUFFER *Buffer
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalX86FxRestore PROC
|
||||
mov eax, [esp + 4]
|
||||
fxrstor [eax]
|
||||
ret
|
||||
InternalX86FxRestore ENDP
|
||||
|
||||
END
|
43
MdePkg/Library/BaseLib/ia32/FxRestore.s
Normal file
43
MdePkg/Library/BaseLib/ia32/FxRestore.s
Normal file
@@ -0,0 +1,43 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# FxRestore.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# AsmFxRestore function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# AsmFxRestore (
|
||||
# IN CONST IA32_FX_BUFFER *Buffer
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _AsmFxRestore
|
||||
_AsmFxRestore:
|
||||
movl 4(%esp),%eax
|
||||
fxrstor (%eax)
|
||||
ret
|
||||
|
||||
|
||||
|
42
MdePkg/Library/BaseLib/ia32/FxSave.asm
Normal file
42
MdePkg/Library/BaseLib/ia32/FxSave.asm
Normal file
@@ -0,0 +1,42 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; FxSave.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; AsmFxSave function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.586P
|
||||
.model flat,C
|
||||
.xmm
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; InternalX86FxSave (
|
||||
; OUT IA32_FX_BUFFER *Buffer
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalX86FxSave PROC
|
||||
mov eax, [esp + 4]
|
||||
fxsave [eax]
|
||||
ret
|
||||
InternalX86FxSave ENDP
|
||||
|
||||
END
|
43
MdePkg/Library/BaseLib/ia32/FxSave.s
Normal file
43
MdePkg/Library/BaseLib/ia32/FxSave.s
Normal file
@@ -0,0 +1,43 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# FxSave.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# AsmFxSave function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# AsmFxSave (
|
||||
# OUT IA32_FX_BUFFER *Buffer
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _AsmFxSave
|
||||
_AsmFxSave:
|
||||
movl 4(%esp),%eax
|
||||
fxsave (%eax)
|
||||
ret
|
||||
|
||||
|
||||
|
45
MdePkg/Library/BaseLib/ia32/InterlockedCompareExchange32.asm
Normal file
45
MdePkg/Library/BaseLib/ia32/InterlockedCompareExchange32.asm
Normal file
@@ -0,0 +1,45 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; InterlockedCompareExchange32.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; InterlockedCompareExchange32 function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.486
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; UINT32
|
||||
; EFIAPI
|
||||
; InterlockedCompareExchange32 (
|
||||
; IN UINT32 *Value,
|
||||
; IN UINT32 CompareValue,
|
||||
; IN UINT32 ExchangeValue
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalSyncCompareExchange32 PROC
|
||||
mov ecx, [esp + 4]
|
||||
mov eax, [esp + 8]
|
||||
mov edx, [esp + 12]
|
||||
lock cmpxchg [ecx], edx
|
||||
ret
|
||||
InternalSyncCompareExchange32 ENDP
|
||||
|
||||
END
|
64
MdePkg/Library/BaseLib/ia32/InterlockedCompareExchange32.s
Normal file
64
MdePkg/Library/BaseLib/ia32/InterlockedCompareExchange32.s
Normal file
@@ -0,0 +1,64 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# InterlockedCompareExchange32.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# InterlockedCompareExchange32 function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID *
|
||||
# EFIAPI
|
||||
# InterlockedCompareExchangePointer (
|
||||
# IN VOID **Value,
|
||||
# IN VOID *CompareValue,
|
||||
# IN VOID *ExchangeValue
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _InterlockedCompareExchangePointer
|
||||
_InterlockedCompareExchangePointer:
|
||||
#
|
||||
# InterlockedCompareExchangePointer() shares the same code as
|
||||
# InterlockedCompareExchange32() on IA32 and thus no code inside this
|
||||
# function
|
||||
#
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# UINT32
|
||||
# EFIAPI
|
||||
# InterlockedCompareExchange32 (
|
||||
# IN UINT32 *Value,
|
||||
# IN UINT32 CompareValue,
|
||||
# IN UINT32 ExchangeValue
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _InterlockedCompareExchange32
|
||||
_InterlockedCompareExchange32:
|
||||
movl 4(%esp),%ecx
|
||||
movl 8(%esp),%eax
|
||||
movl 12(%esp),%edx
|
||||
lock cmpxchgl %edx,(%ecx)
|
||||
ret
|
||||
|
||||
|
||||
|
47
MdePkg/Library/BaseLib/ia32/InterlockedCompareExchange64.asm
Normal file
47
MdePkg/Library/BaseLib/ia32/InterlockedCompareExchange64.asm
Normal file
@@ -0,0 +1,47 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; InterlockedCompareExchange64.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; InterlockedCompareExchange64 function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.586P
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; UINT64
|
||||
; EFIAPI
|
||||
; InterlockedCompareExchange64 (
|
||||
; IN UINT64 *Value,
|
||||
; IN UINT64 CompareValue,
|
||||
; IN UINT64 ExchangeValue
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalSyncCompareExchange64 PROC USES esi ebx
|
||||
mov esi, [esp + 12]
|
||||
mov eax, [esp + 16]
|
||||
mov edx, [esp + 20]
|
||||
mov ebx, [esp + 24]
|
||||
mov ecx, [esp + 28]
|
||||
lock cmpxchg8b qword ptr [esi]
|
||||
ret
|
||||
InternalSyncCompareExchange64 ENDP
|
||||
|
||||
END
|
52
MdePkg/Library/BaseLib/ia32/InterlockedCompareExchange64.s
Normal file
52
MdePkg/Library/BaseLib/ia32/InterlockedCompareExchange64.s
Normal file
@@ -0,0 +1,52 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# InterlockedCompareExchange64.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# InterlockedCompareExchange64 function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# UINT64
|
||||
# EFIAPI
|
||||
# InterlockedCompareExchange64 (
|
||||
# IN UINT64 *Value,
|
||||
# IN UINT64 CompareValue,
|
||||
# IN UINT64 ExchangeValue
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _InterlockedCompareExchange64
|
||||
push %esi
|
||||
push %ebx
|
||||
movl 12(%esp),%esi
|
||||
movl 16(%esp),%eax
|
||||
movl 20(%esp),%edx
|
||||
movl 24(%esp),%ebx
|
||||
movl 28(%esp),%ecx
|
||||
lock
|
||||
cmpxchg8b (%esi)
|
||||
pop %ebx
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
|
||||
|
42
MdePkg/Library/BaseLib/ia32/InterlockedDecrement.asm
Normal file
42
MdePkg/Library/BaseLib/ia32/InterlockedDecrement.asm
Normal file
@@ -0,0 +1,42 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; InterlockedDecrement.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; InterlockedDecrement function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; UINT32
|
||||
; EFIAPI
|
||||
; InterlockedDecrement (
|
||||
; IN UINT32 *Value
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalSyncDecrement PROC
|
||||
mov eax, [esp + 4]
|
||||
lock dec dword ptr [eax]
|
||||
mov eax, [eax]
|
||||
ret
|
||||
InternalSyncDecrement ENDP
|
||||
|
||||
END
|
44
MdePkg/Library/BaseLib/ia32/InterlockedDecrement.s
Normal file
44
MdePkg/Library/BaseLib/ia32/InterlockedDecrement.s
Normal file
@@ -0,0 +1,44 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# InterlockedDecrement.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# InterlockedDecrement function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# UINT32
|
||||
# EFIAPI
|
||||
# InterlockedDecrement (
|
||||
# IN UINT32 *Value
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _InterlockedDecrement
|
||||
_InterlockedDecrement:
|
||||
movl 4(%esp),%eax
|
||||
lock
|
||||
decl (%eax)
|
||||
movl (%eax),%eax
|
||||
ret
|
||||
|
||||
|
||||
|
42
MdePkg/Library/BaseLib/ia32/InterlockedIncrement.asm
Normal file
42
MdePkg/Library/BaseLib/ia32/InterlockedIncrement.asm
Normal file
@@ -0,0 +1,42 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; InterlockedIncrement.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; InterlockedIncrement function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; UINT32
|
||||
; EFIAPI
|
||||
; InterlockedIncrement (
|
||||
; IN UINT32 *Value
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalSyncIncrement PROC
|
||||
mov eax, [esp + 4]
|
||||
lock inc dword ptr [eax]
|
||||
mov eax, [eax]
|
||||
ret
|
||||
InternalSyncIncrement ENDP
|
||||
|
||||
END
|
44
MdePkg/Library/BaseLib/ia32/InterlockedIncrement.s
Normal file
44
MdePkg/Library/BaseLib/ia32/InterlockedIncrement.s
Normal file
@@ -0,0 +1,44 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# InterlockedIncrement.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# InterlockedIncrement function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# UINT32
|
||||
# EFIAPI
|
||||
# InterlockedIncrement (
|
||||
# IN UINT32 *Value
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _InterlockedIncrement
|
||||
_InterlockedIncrement:
|
||||
movl 4(%esp),%eax
|
||||
lock
|
||||
incl (%eax)
|
||||
movl (%eax),%eax
|
||||
ret
|
||||
|
||||
|
||||
|
40
MdePkg/Library/BaseLib/ia32/Invd.asm
Normal file
40
MdePkg/Library/BaseLib/ia32/Invd.asm
Normal file
@@ -0,0 +1,40 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; Invd.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; AsmInvd function
|
||||
;
|
||||
; Notes:
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.486p
|
||||
.model flat
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; EFIAPI
|
||||
; AsmInvd (
|
||||
; VOID
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
_AsmInvd PROC
|
||||
invd
|
||||
ret
|
||||
_AsmInvd ENDP
|
||||
|
||||
END
|
41
MdePkg/Library/BaseLib/ia32/Invd.s
Normal file
41
MdePkg/Library/BaseLib/ia32/Invd.s
Normal file
@@ -0,0 +1,41 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# Invd.Asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# AsmInvd function
|
||||
#
|
||||
# Notes:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# AsmInvd (
|
||||
# VOID
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
.global _AsmInvd
|
||||
_AsmInvd:
|
||||
invd
|
||||
ret
|
||||
|
||||
|
||||
|
41
MdePkg/Library/BaseLib/ia32/LRotU64.asm
Normal file
41
MdePkg/Library/BaseLib/ia32/LRotU64.asm
Normal file
@@ -0,0 +1,41 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; LRotU64.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; 64-bit left rotation for Ia32
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
InternalMathLRotU64 PROC USES ebx
|
||||
mov cl, [esp + 16]
|
||||
mov edx, [esp + 12]
|
||||
mov eax, [esp + 8]
|
||||
shld ebx, edx, cl
|
||||
shld edx, eax, cl
|
||||
ror ebx, cl
|
||||
shld eax, ebx, cl
|
||||
test cl, 32
|
||||
cmovnz ecx, eax
|
||||
cmovnz eax, edx
|
||||
cmovnz edx, ecx
|
||||
ret
|
||||
InternalMathLRotU64 ENDP
|
||||
|
||||
END
|
43
MdePkg/Library/BaseLib/ia32/LRotU64.s
Normal file
43
MdePkg/Library/BaseLib/ia32/LRotU64.s
Normal file
@@ -0,0 +1,43 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# LRotU64.asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# 64-bit left rotation for Ia32
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.global _LRotU64
|
||||
push %ebx
|
||||
movb 16(%esp),%cl
|
||||
movl 12(%esp),%edx
|
||||
movl 8(%esp),%eax
|
||||
shldl %cl,%edx,%ebx
|
||||
shldl %cl,%eax,%edx
|
||||
rorl %cl,%ebx
|
||||
shldl %cl,%ebx,%eax
|
||||
testb $32,%cl
|
||||
cmovnz %eax, %ecx
|
||||
cmovnz %edx, %eax
|
||||
cmovnz %ecx, %edx
|
||||
pop %ebx
|
||||
ret
|
||||
|
||||
|
||||
|
38
MdePkg/Library/BaseLib/ia32/LShiftU64.asm
Normal file
38
MdePkg/Library/BaseLib/ia32/LShiftU64.asm
Normal file
@@ -0,0 +1,38 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; LShiftU64.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; 64-bit left shift function for IA-32
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
InternalMathLShiftU64 PROC
|
||||
mov cl, [esp + 12]
|
||||
xor eax, eax
|
||||
mov edx, [esp + 4]
|
||||
test cl, 32
|
||||
cmovz eax, edx
|
||||
cmovz edx, [esp + 8]
|
||||
shld edx, eax, cl
|
||||
shl eax, cl
|
||||
ret
|
||||
InternalMathLShiftU64 ENDP
|
||||
|
||||
END
|
39
MdePkg/Library/BaseLib/ia32/LShiftU64.s
Normal file
39
MdePkg/Library/BaseLib/ia32/LShiftU64.s
Normal file
@@ -0,0 +1,39 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# LShiftU64.asm
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# 64-bit left shift function for IA-32
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.global _LShiftU64
|
||||
_LShiftU64:
|
||||
movb 12(%esp),%cl
|
||||
xorl %eax,%eax
|
||||
movl 4(%esp),%edx
|
||||
testb $32,%cl
|
||||
cmovz %edx, %eax
|
||||
cmovz 8(%esp), %edx
|
||||
shldl %cl,%eax,%edx
|
||||
shll %cl,%eax
|
||||
ret
|
||||
|
||||
|
||||
|
38
MdePkg/Library/BaseLib/ia32/LongJump.asm
Normal file
38
MdePkg/Library/BaseLib/ia32/LongJump.asm
Normal file
@@ -0,0 +1,38 @@
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2006, 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; LongJump.Asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Implementation of LongJump() on IA-32.
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.386
|
||||
.model flat
|
||||
.code
|
||||
|
||||
_LongJump PROC
|
||||
pop eax
|
||||
pop edx
|
||||
pop eax
|
||||
mov ebx, [edx]
|
||||
mov esi, [edx + 4]
|
||||
mov edi, [edx + 8]
|
||||
mov ebp, [edx + 12]
|
||||
mov esp, [edx + 16]
|
||||
jmp dword ptr [edx + 20]
|
||||
_LongJump ENDP
|
||||
|
||||
END
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user