ReactOS  0.4.13-dev-100-gc8611ae
util.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING.ARM in the top level directory
3  * PROJECT: ReactOS UEFI Boot Library
4  * FILE: boot/environ/lib/misc/util.c
5  * PURPOSE: Boot Library Utility Functions
6  * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include "bl.h"
12 
13 /* DATA VARIABLES ************************************************************/
14 
17 
21 
30 
31 /* FUNCTIONS *****************************************************************/
32 
35  _Out_ PVOID* TableAddress,
37  )
38 {
39  ULONG i, TableCount, HeaderLength;
41  PRSDT Rsdt;
42  PXSDT Xsdt;
45 
46  Header = 0;
47 
48  /* Make sure there's an output parameter */
49  if (!TableAddress)
50  {
52  }
53 
54  /* Get the currently known RSDT and XSDT */
55  Rsdt = (PRSDT)UtlRsdt;
56  Xsdt = (PXSDT)UtlXsdt;
57 
58  /* Is there an RSDT? */
59  if (!Rsdt)
60  {
61  /* No -- is there an XSDT? */
62  if (!Xsdt)
63  {
64  /* No. Look up the RSDT */
66  if (!NT_SUCCESS(Status))
67  {
68  EfiPrintf(L"no rsdp found\r\n");
69  return Status;
70  }
71 
72  /* Map the header */
74  0,
75  sizeof(*Header),
77  if (!NT_SUCCESS(Status))
78  {
79  return Status;
80  }
81 
82  /* Unmap the header */
84 
85  /* Map the whole table */
87  0,
88  Header->Length,
90  if (!NT_SUCCESS(Status))
91  {
92  return Status;
93  }
94 
95  /* Check if its an XSDT or an RSDT */
96  if (Header->Signature == XSDT_SIGNATURE)
97  {
98  /* It's an XSDT */
99  Xsdt = (PXSDT)Header;
100  UtlXsdt = Xsdt;
101  }
102  else
103  {
104  /* It's an RSDT */
105  Rsdt = (PRSDT)Header;
106  UtlRsdt = Rsdt;
107  }
108  }
109  }
110 
111  /* OK, so do we have an XSDT after all? */
112  if (Xsdt)
113  {
114  /* Yes... how big is it? */
115  HeaderLength = Xsdt->Header.Length;
116  if (HeaderLength >= sizeof(*Header))
117  {
118  HeaderLength = sizeof(*Header);
119  }
120 
121  /* Based on that, how many tables are there? */
122  TableCount = (Xsdt->Header.Length - HeaderLength) / sizeof(PHYSICAL_ADDRESS);
123  }
124  else
125  {
126  /* Nope, we have an RSDT. How big is it? */
127  HeaderLength = Rsdt->Header.Length;
128  if (HeaderLength >= sizeof(*Header))
129  {
130  HeaderLength = sizeof(*Header);
131  }
132 
133  /* Based on that, how many tables are there? */
134  TableCount = (Rsdt->Header.Length - HeaderLength) / sizeof(ULONG);
135  }
136 
137  /* Loop through the ACPI tables */
138  for (i = 0; i < TableCount; i++)
139  {
140  /* For an XSDT, read the 64-bit address directly */
141  if (Xsdt)
142  {
143  PhysicalAddress = Xsdt->Tables[i];
144  }
145  else
146  {
147  /* For RSDT, cast it */
148  PhysicalAddress.QuadPart = Rsdt->Tables[i];
149  }
150 
151  /* Map the header */
153  0,
154  sizeof(*Header),
156  if (!NT_SUCCESS(Status))
157  {
158  return Status;
159  }
160 
161  /* Is it the right one? */
162  if (Header->Signature == Signature)
163  {
164  /* Unmap the header */
166 
167  /* Map the whole table */
168  return BlMmMapPhysicalAddressEx(TableAddress,
169  0,
170  Header->Length,
172  }
173  }
174 
175  /* Requested table does not exist */
176  return STATUS_NOT_FOUND;
177 }
178 
179 
180 VOID
182  _In_ ULONG Percentage,
183  _Out_opt_ PBOOLEAN Completed
184  )
185 {
186  if (UtlProgressRoutine)
187  {
188  EfiPrintf(L"Unimplemented\r\n");
189  }
190  else if (*Completed)
191  {
192  *Completed = TRUE;
193  }
194 }
195 
196 NTSTATUS
198  VOID
199  )
200 {
201  UtlRsdt = 0;
202  UtlXsdt = 0;
203 
204  UtlMcContext = 0;
207 
208  UtlProgressRoutine = 0;
209  UtlProgressContext = 0;
215  UtlProgressInfo = 0;
216 
217  return STATUS_SUCCESS;
218 }
219 
220 VOID
223  _In_ PWCHAR ProgressInfo
224  )
225 {
226  EfiPrintf(L"Progress Info: %s\r\n", ProgressInfo);
227 }
228 
229 VOID
232  _In_ ULONG Percent,
233  _Out_ PBOOLEAN Completed
234  )
235 {
236  EfiPrintf(L"Progress: %d\r\n", Percent);
237  if (Completed)
238  {
239  *Completed = TRUE;
240  }
241 }
242 
243 NTSTATUS
245  VOID
246  )
247 {
248  /* One shouldn't already exist */
249  if (UtlProgressRoutine)
250  {
251  return STATUS_UNSUCCESSFUL;
252  }
253 
254  /* Set the routine, and no context */
257 
258  /* Progress increases by one */
260 
261  /* Set progress to zero for now */
264 
265  /* Set the info routine if there is one */
267 
268  /* All good */
269  return STATUS_SUCCESS;
270 }
271 
272 PVOID
274  _In_ PVOID *Table,
275  _In_ ULONG Count,
276  _Out_ PULONG EntryIndex,
280  _In_ PVOID Argument3,
281  _In_ PVOID Argument4
282  )
283 {
284  PVOID Entry = NULL;
285  ULONG Index;
286  BOOLEAN Result;
287 
288  /* Check for invalid parameters */
289  if (!(Table) || !(EntryIndex))
290  {
291  return Entry;
292  }
293 
294  /* Loop each entry in the table */
295  for (Index = 0; Index < Count; Index++)
296  {
297  /* Check if this entry is filled out */
298  if (Table[Index])
299  {
300  /* Call the comparison function */
302  Argument1,
303  Argument2,
304  Argument3,
305  Argument4);
306  if (Result)
307  {
308  /* Entry found return it */
309  *EntryIndex = Index;
310  Entry = Table[Index];
311  break;
312  }
313  }
314  }
315 
316  /* Return the entry that was (or wasn't) found */
317  return Entry;
318 }
319 
320 NTSTATUS
322  _Inout_ PVOID** Table,
324  _In_ PVOID Entry,
325  _Out_ PULONG EntryIndex,
327  )
328 {
329  ULONG NewCount;
331  ULONG Index = 0;
332  PVOID* NewTable;
333 
334  /* Make sure all the parameters were specified */
335  if (!(Table) || !(*Table) || !(Count) || !(Callback))
336  {
338  }
339 
340  /* Read the current table */
341  NewTable = *Table;
342  NewCount = *Count;
343 
344  /* Iterate over it */
345  while (Index < NewCount)
346  {
347  /* Look for a free index */
348  if (!NewTable[Index])
349  {
350  goto SetIndex;
351  }
352 
353  /* No free index yet, keep going */
354  ++Index;
355  }
356 
357  /* No free index was found, try to purge some entries */
358  Index = 0;
359  while (Index < NewCount)
360  {
361  /* Call each purge callback, trying to make space */
362  Status = Callback(NewTable[Index]);
363  if (NT_SUCCESS(Status))
364  {
365  /* We should have this slot available now */
366  goto SetIndex;
367  }
368 
369  /* Keep trying to purge more */
370  ++Index;
371  }
372 
373  /* Double the table */
374  NewTable = BlMmAllocateHeap(2 * sizeof(PVOID) * NewCount);
375  if (!NewTable)
376  {
377  return STATUS_NO_MEMORY;
378  }
379 
380  /* Clear the new table, and copy the old entries */
381  RtlZeroMemory(&NewTable[NewCount], sizeof(PVOID) * NewCount);
382  RtlCopyMemory(NewTable, *Table, sizeof(PVOID) * NewCount);
383 
384  /* Free the old table */
386 
387  /* Return the new table and count */
388  *Count = 2 * NewCount;
389  *Table = NewTable;
390 
391 SetIndex:
392  /* Set the index and return */
393  NewTable[Index] = Entry;
394  *EntryIndex = Index;
395  return Status;
396 }
397 
398 NTSTATUS
400  _In_ PVOID *Table,
401  _In_ ULONG Count,
402  _In_ PBL_TBL_MAP_ROUTINE MapCallback
403  )
404 {
405  NTSTATUS Status, LocalStatus;
406  PVOID Entry;
407  ULONG Index;
408 
409  /* Bail out if there's no table */
410  if (!Table)
411  {
413  }
414 
415  /* Assume success and loop each index */
417  for (Index = 0; Index < Count; Index++)
418  {
419  /* See if an entry exists at this index */
420  Entry = Table[Index];
421  if (Entry)
422  {
423  /* Call the map routine for this entry */
424  LocalStatus = MapCallback(Entry, Index);
425  if (!NT_SUCCESS(LocalStatus))
426  {
427  /* Propagate failure only */
428  Status = LocalStatus;
429  }
430  }
431  }
432 
433  /* Return status to caller */
434  return Status;
435 }
436 
440 
441 ULONG
445  )
446 {
447  PUCHAR Value;
448  ULONG KeyHash, i;
449 
450  /* Check if the value is a pointer, or embedded inline */
451  Value = (Entry->Flags & BL_HT_VALUE_IS_INLINE) ? Entry->Value : (PUCHAR)&Entry->Value;
452 
453  /* Iterate over each byte, and sum it */
454  for (i = 0, KeyHash = 0; i < Entry->Size; i++)
455  {
456  KeyHash += Value[i++];
457  }
458 
459  /* Modulo the number of buckets */
460  return KeyHash % TableSize;
461 }
462 
463 BOOLEAN
465  _In_ PBL_HASH_ENTRY Entry1,
466  _In_ PBL_HASH_ENTRY Entry2
467  )
468 {
469  ULONG Flags;
470  BOOLEAN ValueMatch;
471 
472  /* Check if the flags or sizes are not matching */
473  Flags = Entry1->Flags;
474  if ((Entry1->Size != Entry2->Size) || (Flags != Entry2->Flags))
475  {
476  ValueMatch = FALSE;
477  }
478  else if (Flags & BL_HT_VALUE_IS_INLINE)
479  {
480  /* Check if this is an in-line value, compare it */
481  ValueMatch = Entry1->Value == Entry2->Value;
482  }
483  else
484  {
485  /* This is a pointer value, compare it */
486  ValueMatch = (RtlCompareMemory(Entry1->Value, Entry2->Value, Entry1->Size) ==
487  Entry1->Size);
488  }
489 
490  /* Return if it matched */
491  return ValueMatch;
492 }
493 
494 NTSTATUS
497  )
498 {
499  /* Never purge this entry */
500  return STATUS_UNSUCCESSFUL;
501 }
502 
503 NTSTATUS
505  _In_ ULONG Size,
506  _In_ PBL_HASH_TABLE_HASH_FUNCTION HashFunction,
507  _In_ PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction,
508  _Out_ PULONG Id
509  )
510 {
513  ULONG i;
514 
515  /* Assume failure */
516  HashTable = NULL;
517 
518  /* Can't create a table with no ID */
519  if (!Id)
520  {
522  }
523 
524  /* Check if we don't already have a hash table table */
525  if (!HtTableSize)
526  {
527  /* Allocate it and zero it out */
528  HtTableSize = 4;
530  if (!HtTableArray)
531  {
533  goto Quickie;
534  }
536  HtTableEntries = 0;
537  }
538 
539  /* Allocate the hash table */
541  if (!HashTable)
542  {
544  goto Quickie;
545  }
546 
547  /* Fill it out */
548  HashTable->HashFunction = HashFunction ? HashFunction : DefaultHashFunction;
549  HashTable->CompareFunction = CompareFunction ? CompareFunction : HtpCompareKeys;
550  HashTable->Size = Size ? Size : 13;
551 
552  /* Allocate the hash links, one for each bucket */
553  HashTable->HashLinks = BlMmAllocateHeap(sizeof(LIST_ENTRY) * HashTable->Size);
554  if (!HashTable->HashLinks)
555  {
557  goto Quickie;
558  }
559 
560  /* Initialize the hash links */
561  for (i = 0; i < HashTable->Size; i++)
562  {
563  InitializeListHead(&HashTable->HashLinks[i]);
564  }
565 
566  /* Save us in the table of hash tables */
568  &Size,
569  HashTable,
570  Id,
572  if (NT_SUCCESS(Status))
573  {
574  /* One more -- we're done */
575  ++HtTableEntries;
576  return Status;
577  }
578 
579 Quickie:
580  /* Check if we just allocated the table array now */
581  if (!(HtTableEntries) && (HtTableArray))
582  {
583  /* Free it */
585  HtTableArray = NULL;
586  HtTableSize = 0;
587  }
588 
589  /* Check if we allocated a hash table*/
590  if (HashTable)
591  {
592  /* With links? */
593  if (HashTable->HashLinks)
594  {
595  /* Free them */
596  BlMmFreeHeap(HashTable->HashLinks);
597  }
598 
599  /* Free the table*/
601  }
602 
603  /* We're done */
604  return Status;
605 }
606 
607 NTSTATUS
609  _In_ ULONG TableId,
612  )
613 {
617  PLIST_ENTRY HashLinkHead, HashLink;
618  PBL_HASH_NODE HashNode;
619 
620  /* Check if the table ID is invalid, or we have no entry, or it's malformed */
621  if ((HtTableSize <= TableId) ||
622  !(Entry) ||
623  ((Entry->Flags & BL_HT_VALUE_IS_INLINE) && (Entry->Size != sizeof(ULONG))))
624  {
625  /* Fail */
627  }
628  else
629  {
630  /* Otherwise, get the hash table for this index */
631  HashTable = HtTableArray[TableId];
632 
633  /* Get the hash bucket */
634  HashValue = HashTable->HashFunction(Entry, HashTable->Size);
635 
636  /* Start iterating each entry in the bucket, assuming failure */
638  HashLinkHead = &HashTable->HashLinks[HashValue];
639  HashLink = HashLinkHead->Flink;
640  while (HashLink != HashLinkHead)
641  {
642  /* Get a node in this bucket, and compare the value */
643  HashNode = CONTAINING_RECORD(HashLink, BL_HASH_NODE, ListEntry);
644  if (HashTable->CompareFunction(&HashNode->Entry, Entry))
645  {
646  /* Does the caller want the value? */
647  if (Value)
648  {
649  /* Return it */
650  *Value = &HashNode->Value;
651  }
652 
653  /* Return success and stop scanning */
655  break;
656  }
657 
658  /* Try the next node */
659  HashLink = HashLink->Flink;
660  }
661  }
662 
663  /* Return back to the caller */
664  return Status;
665 }
666 
667 NTSTATUS
669  _In_ ULONG TableId,
671  _In_ PVOID Data,
673  )
674 {
675  PBL_HASH_NODE HashNode;
677  PLIST_ENTRY HashLinkHead;
679 
680  /* Check for invalid table ID, missing arguments, or malformed entry */
681  if ((HtTableSize <= TableId) ||
682  !(Entry) ||
683  !(Data) ||
684  !(Entry->Size) ||
685  !(Entry->Value) ||
686  !(DataSize) ||
687  ((Entry->Flags & BL_HT_VALUE_IS_INLINE) && (Entry->Size != sizeof(ULONG))))
688  {
689  /* Fail the call */
691  goto Quickie;
692  }
693 
694  /* Get the hash table for this ID */
695  HashTable = HtTableArray[TableId];
696 
697  /* Allocate a hash node */
698  HashNode = BlMmAllocateHeap(sizeof(*HashNode));
699  if (!HashNode)
700  {
702  goto Quickie;
703  }
704 
705  /* Capture all the data*/
706  HashNode->Entry.Size = Entry->Size;
707  HashNode->Entry.Flags = Entry->Flags;
708  HashNode->Entry.Value = Entry->Value;
709  HashNode->Value.DataSize = DataSize;
710  HashNode->Value.Data = Data;
711 
712  /* Insert it into the bucket list and return success */
713  HashLinkHead = &HashTable->HashLinks[HashTable->HashFunction(Entry, HashTable->Size)];
714  InsertTailList(HashLinkHead, &HashNode->ListEntry);
716 
717 Quickie:
718  return Status;
719 }
720 
721 NTSTATUS
723  _In_ ULONG TableId,
725  )
726 {
730  PLIST_ENTRY HashLinkHead, HashLink;
731  PBL_HASH_NODE HashNode;
732 
733  /* Check if the table ID is invalid, or we have no entry, or it's malformed */
734  if ((HtTableSize <= TableId) ||
735  !(Entry) ||
736  !(Entry->Size) ||
737  !(Entry->Value) ||
738  ((Entry->Flags & BL_HT_VALUE_IS_INLINE) && (Entry->Size != sizeof(ULONG))))
739  {
740  /* Fail */
742  }
743  else
744  {
745  /* Otherwise, get the hash table for this index */
746  HashTable = HtTableArray[TableId];
747 
748  /* Get the hash bucket */
749  HashValue = HashTable->HashFunction(Entry, HashTable->Size);
750 
751  /* Start iterating each entry in the bucket, assuming failure */
753  HashLinkHead = &HashTable->HashLinks[HashValue];
754  HashLink = HashLinkHead->Flink;
755  while (HashLink != HashLinkHead)
756  {
757  /* Get a node in this bucket, and compare the value */
758  HashNode = CONTAINING_RECORD(HashLink, BL_HASH_NODE, ListEntry);
759  if (HashTable->CompareFunction(&HashNode->Entry, Entry))
760  {
761  /* Remove it from the list and free it */
762  RemoveEntryList(&HashNode->ListEntry);
763  BlMmFreeHeap(HashNode);
764  return STATUS_SUCCESS;
765  }
766 
767  /* Try the next node */
768  HashLink = HashLink->Flink;
769  }
770  }
771 
772  /* Return back to the caller */
773  return Status;
774 }
775 
776 ULONG
778  _In_ ULONG PartialSum,
780  _In_ ULONG Length,
782  )
783 {
784  ULONG i;
785 
787  {
788  EfiPrintf(L"Not supported\r\n");
789  return 0;
790  }
792  {
793  PartialSum = (unsigned __int16)PartialSum;
794  Length &= ~1;
795 
796  for (i = 0; i < Length; i += 2)
797  {
798  PartialSum += *(unsigned __int16 *)&Buffer[i];
800  {
801  PartialSum = (unsigned __int16)((PartialSum >> 16) + PartialSum);
802  }
803  }
804 
805  if (i != Length)
806  {
807  PartialSum += (unsigned __int8)Buffer[Length];
809  {
810  PartialSum = (unsigned __int16)((PartialSum >> 16) + PartialSum);
811  }
812  }
813 
815  {
816  return ~PartialSum;
817  }
818 
819  PartialSum = (unsigned __int16)PartialSum;
820  }
821  else
822  {
823  /* Invalid mode */
824  return 0;
825  }
826 
828  {
829  return ~PartialSum;
830  }
831 
832  return PartialSum;
833 }
834 
835 #if defined(_M_IX86) || defined(_M_X64)
836 BOOLEAN
837 Archx86IsCpuidSupported (
838  VOID
839  )
840 {
841  ULONG CallerFlags, Flags;
842 
843  /* Read the original flags, and add the CPUID bit */
844  CallerFlags = __readeflags() ^ 0x200000;
845  __writeeflags(CallerFlags);
846 
847  /* Read our flags now */
848  Flags = __readeflags();
849 
850  /* Check if the bit stuck */
851  return (((CallerFlags ^ Flags) >> 21) & 1) ^ 1;
852 }
853 #endif
854 
855 BOOLEAN
858  )
859 {
860 #if defined(_M_IX86) || defined(_M_X64)
861  BOOLEAN Supported;
862  INT CpuInfo[4];
863 
864  /* Check if the CPU supports this instruction */
865  Supported = Archx86IsCpuidSupported();
866  if (!Supported)
867  {
868  return FALSE;
869  }
870 
871  /* Check if it's the extended function */
872  if (Function >= 0x80000000)
873  {
874  /* Check if extended functions are supported */
875  __cpuid(CpuInfo, 0x80000000);
876  if ((CpuInfo[0] & 0xFFFFFF00) != 0x80000000)
877  {
878  /* Nope */
879  return FALSE;
880  }
881  }
882  else
883  {
884  /* It's a regular function, get the maximum one supported */
885  __cpuid(CpuInfo, 0);
886  }
887 
888  /* Check if our function is within bounds */
889  if (Function <= CpuInfo[0])
890  {
891  return TRUE;
892  }
893 #else
894  EfiPrintf(L"BlArchIsCpuIdFunctionSupported not implemented for this platform.\r\n");
895 #endif
896 
897  /* Nope */
898  return FALSE;
899 }
900 
901 ULONGLONG
903  VOID
904  )
905 {
906 #if defined(_M_IX86) || defined(_M_X64)
907  CPU_INFO CpuInfo;
908 
909  /* Serialize with CPUID, if it exists */
910  if (Archx86IsCpuidSupported())
911  {
912  BlArchCpuId(0, 0, &CpuInfo);
913  }
914 
915  /* Read the TSC */
916  return __rdtsc();
917 #else
918  EfiPrintf(L"BlArchGetPerformanceCounter not implemented for this platform.\r\n");
919  return 0;
920 #endif
921 }
922 
923 VOID
926  _In_ ULONG SubFunction,
928  )
929 {
930 #if defined(_M_IX86) || defined(_M_X64)
931  /* Use the intrinsic */
932  __cpuidex((INT*)Result->AsUINT32, Function, SubFunction);
933 #endif
934 }
935 
938  VOID
939  )
940 {
941  CPU_INFO CpuInfo;
942  INT Temp;
943 
944  /* Get the CPU Vendor */
945  BlArchCpuId(0, 0, &CpuInfo);
946  Temp = CpuInfo.Ecx;
947  CpuInfo.Ecx = CpuInfo.Edx;
948  CpuInfo.Edx = Temp;
949 
950  /* Check against supported values */
951  if (!strncmp((PCHAR)&CpuInfo.Ebx, "GenuineIntel", 12))
952  {
953  return CPU_INTEL;
954  }
955  if (!strncmp((PCHAR)&CpuInfo.Ebx, "AuthenticAMD", 12))
956  {
957  return CPU_AMD;
958  }
959  if (!strncmp((PCHAR)&CpuInfo.Ebx, "CentaurHauls", 12))
960  {
961  return CPU_VIA;
962  }
963 #ifdef _M_IX86
964  if (!strncmp((PCHAR)&CpuInfo.Ebx, "CyrixInstead", 12))
965  {
966  return CPU_CYRIX;
967  }
968  if (!strncmp((PCHAR)&CpuInfo.Ebx, "GenuineTMx86", 12))
969  {
970  return CPU_TRANSMETA;
971  }
972  if (!strncmp((PCHAR)&CpuInfo.Ebx, "RiseRiseRise", 12))
973  {
974  return CPU_RISE;
975  }
976 #endif // _M_IX86
977  /* Other */
978  return CPU_UNKNOWN;
979 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
signed char * PCHAR
Definition: retypes.h:7
#define XSDT_SIGNATURE
Definition: acpi.h:39
VOID BmUpdateProgressInfo(_In_ PVOID Unknown, _In_ PWCHAR ProgressInfo)
Definition: util.c:221
NTSTATUS BlHtDelete(_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry)
Definition: util.c:722
LIST_ENTRY ListEntry
Definition: bl.h:1192
Definition: acpi.h:193
ASMGENDATA Table[]
Definition: genincdata.c:61
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
Definition: hash.c:67
NTSTATUS BlMmMapPhysicalAddressEx(_In_ PVOID *VirtualAddress, _In_ ULONG Attributes, _In_ ULONGLONG Size, _In_ PHYSICAL_ADDRESS PhysicalAddress)
Definition: mm.c:192
ULONG Size
Definition: bl.h:1179
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:694
struct _Entry Entry
Definition: kefuncs.h:640
BOOLEAN(* PBL_TBL_LOOKUP_ROUTINE)(_In_ PVOID Entry, _In_ PVOID Argument1, _In_ PVOID Argument2, _In_ PVOID Argument3, _In_ PVOID Argument4)
Definition: bl.h:566
BL_HASH_VALUE Value
Definition: bl.h:1194
NTSTATUS(* PBL_TBL_SET_ROUTINE)(_In_ PVOID Entry)
Definition: bl.h:583
BL_HASH_ENTRY Entry
Definition: bl.h:1193
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PVOID UtlMcUpdateMessageRoutine
Definition: util.c:20
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG Tables[ANYSIZE_ARRAY]
Definition: acpi.h:189
NTSTATUS BlHtStore(_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry, _In_ PVOID Data, _In_ ULONG DataSize)
Definition: util.c:668
LONG NTSTATUS
Definition: precomp.h:26
PBL_HASH_TABLE * HtTableArray
Definition: util.c:438
_In_ BOOLEAN _In_ ULONG _Out_ PULONG HashValue
Definition: rtlfuncs.h:2039
VOID BlUtlUpdateProgress(_In_ ULONG Percentage, _Out_opt_ PBOOLEAN Completed)
Definition: util.c:181
PPC_QUAL unsigned long long __rdtsc(void)
Definition: intrin_ppc.h:688
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
PVOID Value
Definition: bl.h:1181
PVOID UtlProgressInfoRoutine
Definition: util.c:24
#define BL_UTL_CHECKSUM_NEGATE
Definition: bl.h:190
uint16_t * PWCHAR
Definition: typedefs.h:54
#define InsertTailList(ListHead, Entry)
ULONG HtTableSize
Definition: util.c:437
NTSTATUS BlHtLookup(_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry, _Out_opt_ PBL_HASH_VALUE *Value)
Definition: util.c:608
ULONG DefaultHashFunction(_In_ PBL_HASH_ENTRY Entry, _In_ ULONG TableSize)
Definition: util.c:442
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
int32_t INT
Definition: typedefs.h:56
NTSTATUS TblDoNotPurgeEntry(_In_ PVOID Entry)
Definition: util.c:495
PVOID Data
Definition: bl.h:1187
DWORD Id
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
PVOID UtlProgressContext
Definition: util.c:23
NTSTATUS(* PBL_TBL_MAP_ROUTINE)(_In_ PVOID Entry, _In_ ULONG EntryIndex)
Definition: bl.h:576
PXSDT UtlXsdt
Definition: util.c:16
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PHYSICAL_ADDRESS Tables[ANYSIZE_ARRAY]
Definition: acpi.h:196
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1555
PVOID BlTblFindEntry(_In_ PVOID *Table, _In_ ULONG Count, _Out_ PULONG EntryIndex, _In_ PBL_TBL_LOOKUP_ROUTINE Callback, _In_ PVOID Argument1, _In_ PVOID Argument2, _In_ PVOID Argument3, _In_ PVOID Argument4)
Definition: util.c:273
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:684
Definition: Header.h:8
CPU_VENDORS
Definition: ketypes.h:41
ULONG HtTableEntries
Definition: util.c:439
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define _Out_
Definition: no_sal2.h:323
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
DESCRIPTION_HEADER Header
Definition: acpi.h:195
Definition: bufpool.h:45
NTSTATUS BlUtlRegisterProgressRoutine(VOID)
Definition: util.c:244
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_ PVOID Argument2
Definition: classpnp.h:680
PVOID UtlMcDisplayMessageRoutine
Definition: util.c:19
NTSTATUS BlTblSetEntry(_Inout_ PVOID **Table, _Inout_ PULONG Count, _In_ PVOID Entry, _Out_ PULONG EntryIndex, _In_ PBL_TBL_SET_ROUTINE Callback)
Definition: util.c:321
ULONG UtlCurrentPercentComplete
Definition: util.c:26
#define _Out_opt_
Definition: no_sal2.h:339
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define STATUS_NOT_FOUND
Definition: shellext.h:67
NTSTATUS BlHtCreate(_In_ ULONG Size, _In_ PBL_HASH_TABLE_HASH_FUNCTION HashFunction, _In_ PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction, _Out_ PULONG Id)
Definition: util.c:504
ULONG(* PBL_HASH_TABLE_HASH_FUNCTION)(_In_ struct _BL_HASH_ENTRY *Entry, _In_ ULONG TableSize)
Definition: bl.h:603
BOOLEAN HtpCompareKeys(_In_ PBL_HASH_ENTRY Entry1, _In_ PBL_HASH_ENTRY Entry2)
Definition: util.c:464
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
ULONG Ebx
Definition: ketypes.h:297
ULONG Ecx
Definition: ketypes.h:298
#define BL_UTL_CHECKSUM_UCHAR_BUFFER
Definition: bl.h:191
ULONG DataSize
Definition: bl.h:1186
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static const UCHAR Index[8]
Definition: usbohci.c:18
#define _Inout_
Definition: no_sal2.h:244
NTSTATUS BlMmUnmapVirtualAddressEx(_In_ PVOID VirtualAddress, _In_ ULONGLONG Size)
Definition: mm.c:487
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS EfipGetRsdt(_Out_ PPHYSICAL_ADDRESS FoundRsdt)
Definition: firmware.c:1635
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1060
char * PBOOLEAN
Definition: retypes.h:11
CPU_VENDORS BlArchGetCpuVendor(VOID)
Definition: util.c:937
static const WCHAR L[]
Definition: oid.c:1250
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
Definition: intrin_x86.h:1550
NTSTATUS BlUtlInitialize(VOID)
Definition: util.c:197
Definition: typedefs.h:117
ULONG Flags
Definition: bl.h:1180
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
RSDT * PRSDT
Definition: acpi.h:191
BOOLEAN(* PBL_HASH_TABLE_COMPARE_FUNCTION)(_In_ struct _BL_HASH_ENTRY *Entry1, _In_ struct _BL_HASH_ENTRY *Entry2)
Definition: bl.h:596
Definition: bl.h:1177
NTSTATUS BlTblMap(_In_ PVOID *Table, _In_ ULONG Count, _In_ PBL_TBL_MAP_ROUTINE MapCallback)
Definition: util.c:399
Status
Definition: gdiplustypes.h:24
ULONG Length
Definition: acpi.h:97
BOOLEAN UtlProgressNeedsInfoUpdate
Definition: util.c:28
#define _In_
Definition: no_sal2.h:204
BOOLEAN BlArchIsCpuIdFunctionSupported(_In_ ULONG Function)
Definition: util.c:856
__INTRIN_INLINE void __cpuidex(int CPUInfo[4], int InfoType, int ECXValue)
Definition: intrin_x86.h:1530
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682
PVOID UtlProgressInfo
Definition: util.c:29
#define BL_UTL_CHECKSUM_USHORT_BUFFER
Definition: bl.h:192
PVOID UtlMcContext
Definition: util.c:18
ULONG UtlProgressGranularity
Definition: util.c:25
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
Definition: acpi.h:186
#define BL_UTL_CHECKSUM_COMPLEMENT
Definition: bl.h:188
ULONG UtlNextUpdatePercentage
Definition: util.c:27
unsigned int * PULONG
Definition: retypes.h:1
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
ULONG BlUtlCheckSum(_In_ ULONG PartialSum, _In_ PUCHAR Buffer, _In_ ULONG Length, _In_ ULONG Flags)
Definition: util.c:777
#define __int8
Definition: basetyps.h:25
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:3970
unsigned int ULONG
Definition: retypes.h:1
VOID BmUpdateProgress(_In_ PVOID Unknown, _In_ ULONG Percent, _Out_ PBOOLEAN Completed)
Definition: util.c:230
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID BlArchCpuId(_In_ ULONG Function, _In_ ULONG SubFunction, _Out_ PCPU_INFO Result)
Definition: util.c:924
XSDT * PXSDT
Definition: acpi.h:198
ULONG Edx
Definition: ketypes.h:299
ULONGLONG BlArchGetPerformanceCounter(VOID)
Definition: util.c:902
NTSTATUS BlUtlGetAcpiTable(_Out_ PVOID *TableAddress, _In_ ULONG Signature)
Definition: util.c:34
return STATUS_SUCCESS
Definition: btrfs.c:2725
static const WCHAR Signature[]
Definition: parser.c:141
LPFNPSPCALLBACK Callback
Definition: desk.c:111
#define BL_HT_VALUE_IS_INLINE
Definition: bl.h:138
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4733
PRSDT UtlRsdt
Definition: util.c:15
PVOID UtlProgressRoutine
Definition: util.c:22
base of all file and directory entries
Definition: entries.h:82
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
DESCRIPTION_HEADER Header
Definition: acpi.h:188
LONGLONG QuadPart
Definition: typedefs.h:112
#define __int16
Definition: basetyps.h:22