BOOLEAN UtlProgressNeedsInfoUpdate;
PVOID UtlProgressInfo;
-
-
/* FUNCTIONS *****************************************************************/
NTSTATUS
VOID
BmUpdateProgressInfo (
- _In_ PVOID Uknown,
+ _In_ PVOID Unknown,
_In_ PWCHAR ProgressInfo
)
{
Argument4);
if (Result)
{
- /* Entry fouund return it */
+ /* Entry found return it */
*EntryIndex = Index;
Entry = Table[Index];
break;
PLIST_ENTRY HashLinkHead;
PBL_HASH_TABLE HashTable;
- /* Check for invalid tablle ID, missing arguments, or malformed entry */
+ /* Check for invalid table ID, missing arguments, or malformed entry */
if ((HtTableSize <= TableId) ||
!(Entry) ||
!(Data) ||
return Status;
}
+NTSTATUS
+BlHtDelete (
+ _In_ ULONG TableId,
+ _In_ PBL_HASH_ENTRY Entry
+ )
+{
+ PBL_HASH_TABLE HashTable;
+ ULONG HashValue;
+ NTSTATUS Status;
+ PLIST_ENTRY HashLinkHead, HashLink;
+ PBL_HASH_NODE HashNode;
+
+ /* Check if the table ID is invalid, or we have no entry, or it's malformed */
+ if ((HtTableSize <= TableId) ||
+ !(Entry) ||
+ !(Entry->Size) ||
+ !(Entry->Value) ||
+ ((Entry->Flags & BL_HT_VALUE_IS_INLINE) && (Entry->Size != sizeof(ULONG))))
+ {
+ /* Fail */
+ Status = STATUS_INVALID_PARAMETER;
+ }
+ else
+ {
+ /* Otherwise, get the hash table for this index */
+ HashTable = HtTableArray[TableId];
+
+ /* Get the hash bucket */
+ HashValue = HashTable->HashFunction(Entry, HashTable->Size);
+
+ /* Start iterating each entry in the bucket, assuming failure */
+ Status = STATUS_NOT_FOUND;
+ HashLinkHead = &HashTable->HashLinks[HashValue];
+ HashLink = HashLinkHead->Flink;
+ while (HashLink != HashLinkHead)
+ {
+ /* Get a node in this bucket, and compare the value */
+ HashNode = CONTAINING_RECORD(HashLink, BL_HASH_NODE, ListEntry);
+ if (HashTable->CompareFunction(&HashNode->Entry, Entry))
+ {
+ /* Remove it from the list and free it */
+ RemoveEntryList(&HashNode->ListEntry);
+ BlMmFreeHeap(HashNode);
+ return STATUS_SUCCESS;
+ }
+
+ /* Try the next node */
+ HashLink = HashLink->Flink;
+ }
+ }
+
+ /* Return back to the caller */
+ return Status;
+}
+
ULONG
BlUtlCheckSum (
_In_ ULONG PartialSum,
}
}
- if (Length != Length)
+ if (i != Length)
{
PartialSum += (unsigned __int8)Buffer[Length];
if (Flags & BL_UTL_CHECKSUM_COMPLEMENT)
return PartialSum;
}
+
+#if defined(_M_IX86) || defined(_M_X64)
+BOOLEAN
+Archx86IsCpuidSupported (
+ VOID
+ )
+{
+ ULONG CallerFlags, Flags;
+
+ /* Read the original flags, and add the CPUID bit */
+ CallerFlags = __readeflags() ^ 0x200000;
+ __writeeflags(CallerFlags);
+
+ /* Read our flags now */
+ Flags = __readeflags();
+
+ /* Check if the bit stuck */
+ return (((CallerFlags ^ Flags) >> 21) & 1) ^ 1;
+}
+#endif
+
+BOOLEAN
+BlArchIsCpuIdFunctionSupported (
+ _In_ ULONG Function
+ )
+{
+#if defined(_M_IX86) || defined(_M_X64)
+ BOOLEAN Supported;
+ INT CpuInfo[4];
+
+ /* Check if the CPU supports this instruction */
+ Supported = Archx86IsCpuidSupported();
+ if (!Supported)
+ {
+ return FALSE;
+ }
+
+ /* Check if it's the extended function */
+ if (Function >= 0x80000000)
+ {
+ /* Check if extended functions are supported */
+ __cpuid(CpuInfo, 0x80000000);
+ if ((CpuInfo[0] & 0xFFFFFF00) != 0x80000000)
+ {
+ /* Nope */
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* It's a regular function, get the maximum one supported */
+ __cpuid(CpuInfo, 0);
+ }
+
+ /* Check if our function is within bounds */
+ if (Function <= CpuInfo[0])
+ {
+ return TRUE;
+ }
+#else
+ EfiPrintf(L"BlArchIsCpuIdFunctionSupported not implemented for this platform.\r\n");
+#endif
+
+ /* Nope */
+ return FALSE;
+}
+
+ULONGLONG
+BlArchGetPerformanceCounter (
+ VOID
+ )
+{
+#if defined(_M_IX86) || defined(_M_X64)
+ CPU_INFO CpuInfo;
+
+ /* Serialize with CPUID, if it exists */
+ if (Archx86IsCpuidSupported())
+ {
+ BlArchCpuId(0, 0, &CpuInfo);
+ }
+
+ /* Read the TSC */
+ return __rdtsc();
+#else
+ EfiPrintf(L"BlArchGetPerformanceCounter not implemented for this platform.\r\n");
+ return 0;
+#endif
+}
+
+VOID
+BlArchCpuId (
+ _In_ ULONG Function,
+ _In_ ULONG SubFunction,
+ _Out_ PCPU_INFO Result
+ )
+{
+#if defined(_M_IX86) || defined(_M_X64)
+ /* Use the intrinsic */
+ __cpuidex((INT*)Result->AsUINT32, Function, SubFunction);
+#endif
+}
+
+CPU_VENDORS
+BlArchGetCpuVendor (
+ VOID
+ )
+{
+ CPU_INFO CpuInfo;
+ INT Temp;
+
+ /* Get the CPU Vendor */
+ BlArchCpuId(0, 0, &CpuInfo);
+#if defined(_M_IX86) || defined(_M_X64)
+ Temp = CpuInfo.Ecx;
+ CpuInfo.Ecx = CpuInfo.Edx;
+ CpuInfo.Edx = Temp;
+
+ /* Check against supported values */
+ if (!strncmp((PCHAR)&CpuInfo.Ebx, "GenuineIntel", 12))
+ {
+ return CPU_INTEL;
+ }
+ if (!strncmp((PCHAR)&CpuInfo.Ebx, "AuthenticAMD", 12))
+ {
+ return CPU_AMD;
+ }
+ if (!strncmp((PCHAR)&CpuInfo.Ebx, "CentaurHauls", 12))
+ {
+ return CPU_VIA;
+ }
+#ifdef _M_IX86
+ if (!strncmp((PCHAR)&CpuInfo.Ebx, "CyrixInstead", 12))
+ {
+ return CPU_CYRIX;
+ }
+ if (!strncmp((PCHAR)&CpuInfo.Ebx, "GenuineTMx86", 12))
+ {
+ return CPU_TRANSMETA;
+ }
+ if (!strncmp((PCHAR)&CpuInfo.Ebx, "RiseRiseRise", 12))
+ {
+ return CPU_RISE;
+ }
+#endif // _M_IX86
+#else // defined(_M_IX86) || defined(_M_X64)
+ EfiPrintf(L"BlArchGetCpuVendor not implemented for this platform.\r\n");
+#endif
+ /* Other */
+ return CPU_UNKNOWN;
+}