Add BSF and BSR instruction wrappers
This commit is contained in:
@@ -617,6 +617,56 @@ AR::CpuFunctions::ReadWriteBarrier(VOID)
|
|||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a Bit Scan Forward instruction to locate the most significant set bit.
|
||||||
|
*
|
||||||
|
* @param Index
|
||||||
|
* Receives the zero-based index of the highest set bit when one is found.
|
||||||
|
*
|
||||||
|
* @param Mask
|
||||||
|
* Supplies the bitmap to scan.
|
||||||
|
*
|
||||||
|
* @return This routine returns TRUE when a set bit was found, otherwise FALSE.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
BOOLEAN
|
||||||
|
AR::CpuFunctions::ScanForwardBit(OUT PULONG Index,
|
||||||
|
IN ULONG Mask)
|
||||||
|
{
|
||||||
|
/* Defer to the BSF instruction */
|
||||||
|
__asm__("bsfl %[Mask], %[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask));
|
||||||
|
|
||||||
|
/* Report whether the input had any bit set */
|
||||||
|
return Mask ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a Bit Scan Reverse instruction to locate the most significant set bit.
|
||||||
|
*
|
||||||
|
* @param Index
|
||||||
|
* Receives the zero-based index of the highest set bit when one is found.
|
||||||
|
*
|
||||||
|
* @param Mask
|
||||||
|
* Supplies the bitmap to scan.
|
||||||
|
*
|
||||||
|
* @return This routine returns TRUE when a set bit was found, otherwise FALSE.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
BOOLEAN
|
||||||
|
AR::CpuFunctions::ScanReverseBit(OUT PULONG Index,
|
||||||
|
IN ULONG Mask)
|
||||||
|
{
|
||||||
|
/* Defer to the BSR instruction */
|
||||||
|
__asm__("bsrl %[Mask], %[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask));
|
||||||
|
|
||||||
|
/* Report whether the input had any bit set */
|
||||||
|
return Mask ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instructs the processor to set the interrupt flag.
|
* Instructs the processor to set the interrupt flag.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -587,6 +587,56 @@ AR::CpuFunctions::ReadWriteBarrier(VOID)
|
|||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a Bit Scan Forward instruction to locate the most significant set bit.
|
||||||
|
*
|
||||||
|
* @param Index
|
||||||
|
* Receives the zero-based index of the highest set bit when one is found.
|
||||||
|
*
|
||||||
|
* @param Mask
|
||||||
|
* Supplies the bitmap to scan.
|
||||||
|
*
|
||||||
|
* @return This routine returns TRUE when a set bit was found, otherwise FALSE.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
BOOLEAN
|
||||||
|
AR::CpuFunctions::ScanForwardBit(OUT PULONG Index,
|
||||||
|
IN ULONG Mask)
|
||||||
|
{
|
||||||
|
/* Defer to the BSF instruction */
|
||||||
|
__asm__("bsfl %[Mask], %[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask));
|
||||||
|
|
||||||
|
/* Report whether the input had any bit set */
|
||||||
|
return Mask ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a Bit Scan Reverse instruction to locate the most significant set bit.
|
||||||
|
*
|
||||||
|
* @param Index
|
||||||
|
* Receives the zero-based index of the highest set bit when one is found.
|
||||||
|
*
|
||||||
|
* @param Mask
|
||||||
|
* Supplies the bitmap to scan.
|
||||||
|
*
|
||||||
|
* @return This routine returns TRUE when a set bit was found, otherwise FALSE.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
BOOLEAN
|
||||||
|
AR::CpuFunctions::ScanReverseBit(OUT PULONG Index,
|
||||||
|
IN ULONG Mask)
|
||||||
|
{
|
||||||
|
/* Defer to the BSR instruction */
|
||||||
|
__asm__("bsrl %[Mask], %[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask));
|
||||||
|
|
||||||
|
/* Report whether the input had any bit set */
|
||||||
|
return Mask ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instructs the processor to set the interrupt flag.
|
* Instructs the processor to set the interrupt flag.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ namespace AR
|
|||||||
STATIC XTCDECL ULONGLONG ReadTimeStampCounter(VOID);
|
STATIC XTCDECL ULONGLONG ReadTimeStampCounter(VOID);
|
||||||
STATIC XTCDECL ULONGLONG ReadTimeStampCounterProcessor(OUT PULONG TscAux);
|
STATIC XTCDECL ULONGLONG ReadTimeStampCounterProcessor(OUT PULONG TscAux);
|
||||||
STATIC XTCDECL VOID ReadWriteBarrier(VOID);
|
STATIC XTCDECL VOID ReadWriteBarrier(VOID);
|
||||||
|
STATIC XTCDECL BOOLEAN ScanForwardBit(OUT PULONG Index,
|
||||||
|
IN ULONG Mask);
|
||||||
|
STATIC XTCDECL BOOLEAN ScanReverseBit(OUT PULONG Index,
|
||||||
|
IN ULONG Mask);
|
||||||
STATIC XTCDECL VOID SetInterruptFlag(VOID);
|
STATIC XTCDECL VOID SetInterruptFlag(VOID);
|
||||||
STATIC XTCDECL VOID StoreGlobalDescriptorTable(OUT PVOID Destination);
|
STATIC XTCDECL VOID StoreGlobalDescriptorTable(OUT PVOID Destination);
|
||||||
STATIC XTCDECL VOID StoreInterruptDescriptorTable(OUT PVOID Destination);
|
STATIC XTCDECL VOID StoreInterruptDescriptorTable(OUT PVOID Destination);
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ namespace AR
|
|||||||
STATIC XTCDECL ULONGLONG ReadTimeStampCounter(VOID);
|
STATIC XTCDECL ULONGLONG ReadTimeStampCounter(VOID);
|
||||||
STATIC XTCDECL ULONGLONG ReadTimeStampCounterProcessor(OUT PULONG TscAux);
|
STATIC XTCDECL ULONGLONG ReadTimeStampCounterProcessor(OUT PULONG TscAux);
|
||||||
STATIC XTCDECL VOID ReadWriteBarrier(VOID);
|
STATIC XTCDECL VOID ReadWriteBarrier(VOID);
|
||||||
|
STATIC XTCDECL BOOLEAN ScanForwardBit(OUT PULONG Index,
|
||||||
|
IN ULONG Mask);
|
||||||
|
STATIC XTCDECL BOOLEAN ScanReverseBit(OUT PULONG Index,
|
||||||
|
IN ULONG Mask);
|
||||||
STATIC XTCDECL VOID SetInterruptFlag(VOID);
|
STATIC XTCDECL VOID SetInterruptFlag(VOID);
|
||||||
STATIC XTCDECL VOID StoreGlobalDescriptorTable(OUT PVOID Destination);
|
STATIC XTCDECL VOID StoreGlobalDescriptorTable(OUT PVOID Destination);
|
||||||
STATIC XTCDECL VOID StoreInterruptDescriptorTable(OUT PVOID Destination);
|
STATIC XTCDECL VOID StoreInterruptDescriptorTable(OUT PVOID Destination);
|
||||||
|
|||||||
Reference in New Issue
Block a user