]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Conf/Migration/R8Lib.c
Add Migration Tool Database files
[mirror_edk2.git] / Tools / Conf / Migration / R8Lib.c
CommitLineData
c8b59d23 1/** @file\r
2 Obsolete library.\r
3\r
4 Copyright (c) 2006, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15////\r
16EFI_STATUS\r
17R8_EfiLibInstallDriverBinding (\r
18 IN EFI_HANDLE ImageHandle,\r
19 IN EFI_SYSTEM_TABLE *SystemTable,\r
20 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
21 IN EFI_HANDLE DriverBindingHandle\r
22 )\r
23/*++\r
24\r
25Routine Description:\r
26\r
27 Intialize a driver by installing the Driver Binding Protocol onto the \r
28 driver's DriverBindingHandle. This is typically the same as the driver's\r
29 ImageHandle, but it can be different if the driver produces multiple\r
30 DriverBinding Protocols. This function also initializes the EFI Driver\r
31 Library that initializes the global variables gST, gBS, gRT.\r
32\r
33Arguments:\r
34\r
35 ImageHandle - The image handle of the driver\r
36\r
37 SystemTable - The EFI System Table that was passed to the driver's entry point\r
38\r
39 DriverBinding - A Driver Binding Protocol instance that this driver is producing\r
40\r
41 DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this\r
42 parameter is NULL, then a new handle is created.\r
43\r
44Returns: \r
45\r
46 EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle\r
47\r
48 Otherwise, then return status from gBS->InstallProtocolInterface()\r
49\r
50--*/\r
51{\r
52 //EfiInitializeDriverLib (ImageHandle, SystemTable);\r
53\r
54 DriverBinding->ImageHandle = ImageHandle;\r
55\r
56 DriverBinding->DriverBindingHandle = DriverBindingHandle;\r
57\r
58 return gBS->InstallProtocolInterface (\r
59 &DriverBinding->DriverBindingHandle,\r
60 &gEfiDriverBindingProtocolGuid,\r
61 EFI_NATIVE_INTERFACE,\r
62 DriverBinding\r
63 );\r
64}\r
65////~\r
66\r
67////\r
68EFI_STATUS\r
69R8_EfiLibInstallAllDriverProtocols (\r
70 IN EFI_HANDLE ImageHandle,\r
71 IN EFI_SYSTEM_TABLE * SystemTable,\r
72 IN EFI_DRIVER_BINDING_PROTOCOL * DriverBinding,\r
73 IN EFI_HANDLE DriverBindingHandle,\r
74 IN EFI_COMPONENT_NAME_PROTOCOL * ComponentName, OPTIONAL\r
75 IN EFI_DRIVER_CONFIGURATION_PROTOCOL * DriverConfiguration, OPTIONAL\r
76 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL * DriverDiagnostics OPTIONAL\r
77 )\r
78/*++\r
79\r
80Routine Description:\r
81\r
82 Intialize a driver by installing the Driver Binding Protocol onto the \r
83 driver's DriverBindingHandle. This is typically the same as the driver's\r
84 ImageHandle, but it can be different if the driver produces multiple\r
85 DriverBinding Protocols. This function also initializes the EFI Driver\r
86 Library that initializes the global variables gST, gBS, gRT.\r
87\r
88Arguments:\r
89\r
90 ImageHandle - The image handle of the driver\r
91\r
92 SystemTable - The EFI System Table that was passed to the driver's entry point\r
93\r
94 DriverBinding - A Driver Binding Protocol instance that this driver is producing\r
95\r
96 DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this\r
97 parameter is NULL, then a new handle is created.\r
98\r
99 ComponentName - A Component Name Protocol instance that this driver is producing\r
100\r
101 DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing\r
102 \r
103 DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing\r
104\r
105Returns: \r
106\r
107 EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
108\r
109 Otherwise, then return status from gBS->InstallProtocolInterface()\r
110\r
111--*/\r
112{\r
113 EFI_STATUS Status;\r
114\r
115 Status = R8_EfiLibInstallDriverBinding (ImageHandle, SystemTable, DriverBinding, DriverBindingHandle);\r
116 if (EFI_ERROR (Status)) {\r
117 return Status;\r
118 }\r
119\r
120 if (ComponentName != NULL) {\r
121 Status = gBS->InstallProtocolInterface (\r
122 &DriverBinding->DriverBindingHandle,\r
123 &gEfiComponentNameProtocolGuid,\r
124 EFI_NATIVE_INTERFACE,\r
125 ComponentName\r
126 );\r
127 if (EFI_ERROR (Status)) {\r
128 return Status;\r
129 }\r
130 }\r
131\r
132 if (DriverConfiguration != NULL) {\r
133 Status = gBS->InstallProtocolInterface (\r
134 &DriverBinding->DriverBindingHandle,\r
135 &gEfiDriverConfigurationProtocolGuid,\r
136 EFI_NATIVE_INTERFACE,\r
137 DriverConfiguration\r
138 );\r
139 if (EFI_ERROR (Status)) {\r
140 return Status;\r
141 }\r
142 }\r
143\r
144 if (DriverDiagnostics != NULL) {\r
145 Status = gBS->InstallProtocolInterface (\r
146 &DriverBinding->DriverBindingHandle,\r
147 &gEfiDriverDiagnosticsProtocolGuid,\r
148 EFI_NATIVE_INTERFACE,\r
149 DriverDiagnostics\r
150 );\r
151 if (EFI_ERROR (Status)) {\r
152 return Status;\r
153 }\r
154 }\r
155\r
156 return EFI_SUCCESS;\r
157}\r
158////~\r
159\r
160////\r
161BOOLEAN\r
162R8_EfiLibCompareLanguage (\r
163 IN CHAR8 *Language1,\r
164 IN CHAR8 *Language2\r
165 )\r
166/*++\r
167\r
168Routine Description:\r
169\r
170 Compare whether two names of languages are identical.\r
171\r
172Arguments:\r
173\r
174 Language1 - Name of language 1\r
175 Language2 - Name of language 2\r
176\r
177Returns:\r
178\r
179 TRUE - same\r
180 FALSE - not same\r
181\r
182--*/\r
183{\r
184 UINTN Index;\r
185\r
186 for (Index = 0; Index < 3; Index++) {\r
187 if (Language1[Index] != Language2[Index]) {\r
188 return FALSE;\r
189 }\r
190 }\r
191\r
192 return TRUE;\r
193}\r
194////~\r
195\r
196////#BaseLib\r
197EFI_STATUS\r
198R8_BufToHexString (\r
199 IN OUT CHAR16 *Str,\r
200 IN OUT UINTN *HexStringBufferLength,\r
201 IN UINT8 *Buf,\r
202 IN UINTN Len\r
203 )\r
204/*++\r
205\r
206 Routine Description:\r
207 Converts binary buffer to Unicode string.\r
208 At a minimum, any blob of data could be represented as a hex string.\r
209\r
210 Arguments:\r
211 Str - Pointer to the string.\r
212 HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.\r
213 If routine return with EFI_SUCCESS, containing length of hex string buffer.\r
214 If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.\r
215 Buf - Buffer to be converted from.\r
216 Len - Length in bytes of the buffer to be converted.\r
217\r
218 Returns:\r
219 EFI_SUCCESS: Routine success.\r
220 EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.\r
221\r
222--*/\r
223{\r
224 UINTN Idx;\r
225 UINT8 Byte;\r
226 UINTN StrLen;\r
227\r
228 //\r
229 // Make sure string is either passed or allocate enough.\r
230 // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.\r
231 // Plus the Unicode termination character.\r
232 //\r
233 StrLen = Len * 2;\r
234 if (StrLen > ((*HexStringBufferLength) - 1)) {\r
235 *HexStringBufferLength = StrLen + 1;\r
236 return EFI_BUFFER_TOO_SMALL;\r
237 }\r
238\r
239 *HexStringBufferLength = StrLen + 1;\r
240 //\r
241 // Ends the string.\r
242 //\r
243 Str[StrLen] = L'\0'; \r
244\r
245 for (Idx = 0; Idx < Len; Idx++) {\r
246\r
247 Byte = Buf[Idx];\r
248 Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);\r
249 Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));\r
250 }\r
251\r
252 return EFI_SUCCESS;\r
253}\r
254////~\r
255\r
256////\r
257VOID\r
258R8_EfiStrTrim (\r
259 IN OUT CHAR16 *str,\r
260 IN CHAR16 CharC\r
261 )\r
262/*++\r
263\r
264Routine Description:\r
265 \r
266 Removes (trims) specified leading and trailing characters from a string.\r
267 \r
268Arguments: \r
269 \r
270 str - Pointer to the null-terminated string to be trimmed. On return, \r
271 str will hold the trimmed string. \r
272 CharC - Character will be trimmed from str.\r
273 \r
274Returns:\r
275\r
276--*/\r
277{\r
278 CHAR16 *p1;\r
279 CHAR16 *p2;\r
280 \r
281 if (*str == 0) {\r
282 return;\r
283 }\r
284 \r
285 //\r
286 // Trim off the leading and trailing characters c\r
287 //\r
288 for (p1 = str; *p1 && *p1 == CharC; p1++) {\r
289 ;\r
290 }\r
291 \r
292 p2 = str;\r
293 if (p2 == p1) {\r
294 while (*p1) {\r
295 p2++;\r
296 p1++;\r
297 }\r
298 } else {\r
299 while (*p1) { \r
300 *p2 = *p1; \r
301 p1++;\r
302 p2++;\r
303 }\r
304 *p2 = 0;\r
305 }\r
306 \r
307 \r
308 for (p1 = str + StrLen(str) - 1; p1 >= str && *p1 == CharC; p1--) {\r
309 ;\r
310 }\r
311 if (p1 != str + StrLen(str) - 1) { \r
312 *(p1 + 1) = 0;\r
313 }\r
314}\r
315////~\r
316\r
317////#PrintLib\r
318UINTN\r
319R8_EfiValueToHexStr (\r
320 IN OUT CHAR16 *Buffer, \r
321 IN UINT64 Value, \r
322 IN UINTN Flags, \r
323 IN UINTN Width\r
324 )\r
325/*++\r
326\r
327Routine Description:\r
328\r
329 VSPrint worker function that prints a Value as a hex number in Buffer\r
330\r
331Arguments:\r
332\r
333 Buffer - Location to place ascii hex string of Value.\r
334\r
335 Value - Hex value to convert to a string in Buffer.\r
336\r
337 Flags - Flags to use in printing Hex string, see file header for details.\r
338\r
339 Width - Width of hex value.\r
340\r
341Returns: \r
342\r
343 Number of characters printed. \r
344\r
345--*/\r
346{\r
347 CHAR16 TempBuffer[MAXIMUM_VALUE_CHARACTERS];\r
348 CHAR16 *TempStr;\r
349 CHAR16 Prefix;\r
350 CHAR16 *BufferPtr;\r
351 UINTN Count;\r
352 UINTN Index;\r
353\r
354 TempStr = TempBuffer;\r
355 BufferPtr = Buffer;\r
356\r
357 //\r
358 // Count starts at one since we will null terminate. Each iteration of the\r
359 // loop picks off one nibble. Oh yea TempStr ends up backwards\r
360 //\r
361 Count = 0;\r
362 \r
363 if (Width > MAXIMUM_VALUE_CHARACTERS - 1) {\r
364 Width = MAXIMUM_VALUE_CHARACTERS - 1;\r
365 }\r
366\r
367 do {\r
368 //\r
369 // If Width == 0, it means no limit.\r
370 //\r
371 if ((Width != 0) && (Count >= Width)) {\r
372 break;\r
373 }\r
374\r
375 Index = ((UINTN)Value & 0xf);\r
376 *(TempStr++) = mHexStr[Index];\r
377 Value = RShiftU64 (Value, 4);\r
378 Count++;\r
379 } while (Value != 0);\r
380\r
381 if (Flags & PREFIX_ZERO) {\r
382 Prefix = '0';\r
383 } else { \r
384 Prefix = ' ';\r
385 }\r
386\r
387 Index = Count;\r
388 if (!(Flags & LEFT_JUSTIFY)) {\r
389 for (; Index < Width; Index++) {\r
390 *(TempStr++) = Prefix;\r
391 }\r
392 }\r
393\r
394 //\r
395 // Reverse temp string into Buffer.\r
396 //\r
397 while (TempStr != TempBuffer) {\r
398 *(BufferPtr++) = *(--TempStr);\r
399 } \r
400 \r
401 *BufferPtr = 0;\r
402 return Index;\r
403}\r
404////~\r
405\r
406\r
407\r
408////\r
409EFI_STATUS\r
410R8_HexStringToBuf (\r
411 IN OUT UINT8 *Buf, \r
412 IN OUT UINTN *Len,\r
413 IN CHAR16 *Str,\r
414 OUT UINTN *ConvertedStrLen OPTIONAL\r
415 )\r
416/*++\r
417\r
418 Routine Description:\r
419 Converts Unicode string to binary buffer.\r
420 The conversion may be partial.\r
421 The first character in the string that is not hex digit stops the conversion.\r
422 At a minimum, any blob of data could be represented as a hex string.\r
423\r
424 Arguments:\r
425 Buf - Pointer to buffer that receives the data.\r
426 Len - Length in bytes of the buffer to hold converted data.\r
427 If routine return with EFI_SUCCESS, containing length of converted data.\r
428 If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.\r
429 Str - String to be converted from.\r
430 ConvertedStrLen - Length of the Hex String consumed.\r
431\r
432 Returns:\r
433 EFI_SUCCESS: Routine Success.\r
434 EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.\r
435 EFI_\r
436\r
437--*/\r
438{\r
439 UINTN HexCnt;\r
440 UINTN Idx;\r
441 UINTN BufferLength;\r
442 UINT8 Digit;\r
443 UINT8 Byte;\r
444\r
445 //\r
446 // Find out how many hex characters the string has.\r
447 //\r
448 for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);\r
449\r
450 if (HexCnt == 0) {\r
451 *Len = 0;\r
452 return EFI_SUCCESS;\r
453 }\r
454 //\r
455 // Two Unicode characters make up 1 buffer byte. Round up.\r
456 //\r
457 BufferLength = (HexCnt + 1) / 2; \r
458\r
459 //\r
460 // Test if buffer is passed enough.\r
461 //\r
462 if (BufferLength > (*Len)) {\r
463 *Len = BufferLength;\r
464 return EFI_BUFFER_TOO_SMALL;\r
465 }\r
466\r
467 *Len = BufferLength;\r
468\r
469 for (Idx = 0; Idx < HexCnt; Idx++) {\r
470\r
471 IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);\r
472\r
473 //\r
474 // For odd charaters, write the lower nibble for each buffer byte,\r
475 // and for even characters, the upper nibble.\r
476 //\r
477 if ((Idx & 1) == 0) {\r
478 Byte = Digit;\r
479 } else {\r
480 Byte = Buf[Idx / 2];\r
481 Byte &= 0x0F;\r
482 Byte |= Digit << 4;\r
483 }\r
484\r
485 Buf[Idx / 2] = Byte;\r
486 }\r
487\r
488 if (ConvertedStrLen != NULL) {\r
489 *ConvertedStrLen = HexCnt;\r
490 }\r
491\r
492 return EFI_SUCCESS;\r
493}\r
494////~\r
495\r
496////\r
497BOOLEAN\r
498R8_IsHexDigit (\r
499 OUT UINT8 *Digit,\r
500 IN CHAR16 Char\r
501 )\r
502/*++\r
503\r
504 Routine Description:\r
505 Determines if a Unicode character is a hexadecimal digit.\r
506 The test is case insensitive.\r
507\r
508 Arguments:\r
509 Digit - Pointer to byte that receives the value of the hex character.\r
510 Char - Unicode character to test.\r
511\r
512 Returns:\r
513 TRUE - If the character is a hexadecimal digit.\r
514 FALSE - Otherwise.\r
515\r
516--*/\r
517{\r
518 if ((Char >= L'0') && (Char <= L'9')) {\r
519 *Digit = (UINT8) (Char - L'0');\r
520 return TRUE;\r
521 }\r
522\r
523 if ((Char >= L'A') && (Char <= L'F')) {\r
524 *Digit = (UINT8) (Char - L'A' + 0x0A);\r
525 return TRUE;\r
526 }\r
527\r
528 if ((Char >= L'a') && (Char <= L'f')) {\r
529 *Digit = (UINT8) (Char - L'a' + 0x0A);\r
530 return TRUE;\r
531 }\r
532\r
533 return FALSE;\r
534}\r
535////~\r
536\r
537////\r
538CHAR16\r
539R8_NibbleToHexChar (\r
540 IN UINT8 Nibble\r
541 )\r
542/*++\r
543\r
544 Routine Description:\r
545 Converts the low nibble of a byte to hex unicode character.\r
546\r
547 Arguments:\r
548 Nibble - lower nibble of a byte.\r
549\r
550 Returns:\r
551 Hex unicode character.\r
552\r
553--*/\r
554{\r
555 Nibble &= 0x0F;\r
556 if (Nibble <= 0x9) {\r
557 return (CHAR16)(Nibble + L'0');\r
558 }\r
559\r
560 return (CHAR16)(Nibble - 0xA + L'A');\r
561}\r
562////~\r
563\r
564////#HobLib\r
565VOID *\r
566R8_GetHob (\r
567 IN UINT16 Type,\r
568 IN VOID *HobStart\r
569 )\r
570/*++\r
571\r
572Routine Description:\r
573\r
574 This function returns the first instance of a HOB type in a HOB list.\r
575 \r
576Arguments:\r
577\r
578 Type The HOB type to return.\r
579 HobStart The first HOB in the HOB list.\r
580 \r
581Returns:\r
582\r
583 HobStart There were no HOBs found with the requested type.\r
584 else Returns the first HOB with the matching type.\r
585\r
586--*/\r
587{\r
588 VOID *Hob;\r
589 //\r
590 // Return input if not found\r
591 //\r
592 if (HobStart == NULL) {\r
593 return HobStart;\r
594 }\r
595 Hob = GetNextHob (Type, HobStart);\r
596 if (Hob == NULL) {\r
597 return HobStart;\r
598 }\r
599 \r
600 return Hob;\r
601}\r
602////~\r
603\r
604////\r
605UINTN\r
606R8_GetHobListSize (\r
607 IN VOID *HobStart\r
608 )\r
609/*++\r
610\r
611Routine Description:\r
612\r
613 Get size of hob list.\r
614\r
615Arguments:\r
616\r
617 HobStart - Start pointer of hob list\r
618\r
619Returns:\r
620\r
621 Size of hob list.\r
622\r
623--*/\r
624{\r
625 EFI_PEI_HOB_POINTERS Hob;\r
626 UINTN Size;\r
627\r
628 Hob.Raw = HobStart;\r
629 Size = 0;\r
630\r
631 while (Hob.Header->HobType != EFI_HOB_TYPE_END_OF_HOB_LIST) {\r
632 Size += Hob.Header->HobLength;\r
633 Hob.Raw += Hob.Header->HobLength;\r
634 }\r
635\r
636 Size += Hob.Header->HobLength;\r
637\r
638 return Size;\r
639}\r
640////~\r
641\r
642////\r
643UINT32\r
644R8_GetHobVersion (\r
645 IN VOID *HobStart\r
646 )\r
647/*++\r
648\r
649Routine Description:\r
650\r
651 Get hob version.\r
652\r
653Arguments:\r
654\r
655 HobStart - Start pointer of hob list\r
656\r
657Returns:\r
658\r
659 Hob version.\r
660\r
661--*/\r
662{\r
663 EFI_PEI_HOB_POINTERS Hob;\r
664\r
665 Hob.Raw = HobStart;\r
666 return Hob.HandoffInformationTable->Version;\r
667}\r
668////~\r
669\r
670////\r
671EFI_STATUS\r
672R8_GetHobBootMode (\r
673 IN VOID *HobStart,\r
674 OUT EFI_BOOT_MODE *BootMode\r
675 )\r
676/*++\r
677\r
678Routine Description:\r
679\r
680 Get current boot mode.\r
681\r
682Arguments:\r
683\r
684 HobStart - Start pointer of hob list\r
685 \r
686 BootMode - Current boot mode recorded in PHIT hob\r
687\r
688Returns:\r
689\r
690 EFI_NOT_FOUND - Invalid hob header\r
691 \r
692 EFI_SUCCESS - Boot mode found\r
693\r
694--*/\r
695{\r
696 EFI_PEI_HOB_POINTERS Hob;\r
697\r
698 Hob.Raw = HobStart;\r
699 if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {\r
700 return EFI_NOT_FOUND;\r
701 }\r
702\r
703 *BootMode = Hob.HandoffInformationTable->BootMode;\r
704 return EFI_SUCCESS;\r
705}\r
706////~\r
707\r
708\r
709////#HobLib\r
710EFI_STATUS\r
711R8_GetCpuHobInfo (\r
712 IN VOID *HobStart,\r
713 OUT UINT8 *SizeOfMemorySpace,\r
714 OUT UINT8 *SizeOfIoSpace\r
715 )\r
716/*++\r
717\r
718Routine Description:\r
719\r
720 Get information recorded in CPU hob (Memory space size, Io space size)\r
721\r
722Arguments:\r
723\r
724 HobStart - Start pointer of hob list\r
725 \r
726 SizeOfMemorySpace - Size of memory size\r
727 \r
728 SizeOfIoSpace - Size of IO size\r
729\r
730Returns:\r
731\r
732 EFI_NOT_FOUND - CPU hob not found\r
733 \r
734 EFI_SUCCESS - CPU hob found and information got.\r
735\r
736--*/\r
737{\r
738 EFI_HOB_CPU *CpuHob;\r
739\r
740 CpuHob = GetHob (EFI_HOB_TYPE_CPU, HobStart);\r
741 if (CpuHob == NULL) {\r
742 return EFI_NOT_FOUND;\r
743 }\r
744\r
745 *SizeOfMemorySpace = CpuHob->SizeOfMemorySpace;\r
746 *SizeOfIoSpace = CpuHob->SizeOfIoSpace;\r
747 return EFI_SUCCESS;\r
748}\r
749////~\r
750\r
751////#HobLib\r
752EFI_STATUS\r
753R8_GetDxeCoreHobInfo (\r
754 IN VOID *HobStart,\r
755 OUT EFI_PHYSICAL_ADDRESS *BaseAddress,\r
756 OUT UINT64 *Length,\r
757 OUT VOID **EntryPoint,\r
758 OUT EFI_GUID **FileName\r
759 )\r
760/*++\r
761\r
762Routine Description:\r
763\r
764 Get memory allocation hob created for DXE core and extract its information\r
765\r
766Arguments:\r
767\r
768 HobStart - Start pointer of the hob list\r
769 BaseAddress - Start address of memory allocated for DXE core\r
770 Length - Length of memory allocated for DXE core\r
771 EntryPoint - DXE core file name\r
772 FileName - File Name\r
773\r
774Returns:\r
775\r
776 EFI_NOT_FOUND - DxeCoreHob not found \r
777 EFI_SUCCESS - DxeCoreHob found and information got\r
778\r
779--*/\r
780{\r
781 EFI_PEI_HOB_POINTERS DxeCoreHob;\r
782 \r
783 DxeCoreHob.Raw = HobStart;\r
784 DxeCoreHob.Raw = GetHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw);\r
785 while (DxeCoreHob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION && \r
786 !EfiCompareGuid (&DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.Name, \r
787 &gEfiHobMemeryAllocModuleGuid)) {\r
788\r
789 DxeCoreHob.Raw = GET_NEXT_HOB (DxeCoreHob);\r
790 DxeCoreHob.Raw = GetHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw);\r
791\r
792 }\r
793\r
794 if (DxeCoreHob.Header->HobType != EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
795 return EFI_NOT_FOUND;\r
796 }\r
797\r
798 *BaseAddress = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress;\r
799 *Length = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength;\r
800 *EntryPoint = (VOID *) (UINTN) DxeCoreHob.MemoryAllocationModule->EntryPoint;\r
801 *FileName = &DxeCoreHob.MemoryAllocationModule->ModuleName;\r
802\r
803 return EFI_SUCCESS;\r
804}\r
805////~\r
806\r
807////#HobLib\r
808EFI_STATUS\r
809R8_GetNextFirmwareVolumeHob (\r
810 IN OUT VOID **HobStart,\r
811 OUT EFI_PHYSICAL_ADDRESS *BaseAddress,\r
812 OUT UINT64 *Length\r
813 )\r
814/*++\r
815\r
816Routine Description:\r
817\r
818 Get next firmware volume hob from HobStart\r
819\r
820Arguments:\r
821\r
822 HobStart - Start pointer of hob list\r
823 \r
824 BaseAddress - Start address of next firmware volume\r
825 \r
826 Length - Length of next firmware volume\r
827\r
828Returns:\r
829\r
830 EFI_NOT_FOUND - Next firmware volume not found\r
831 \r
832 EFI_SUCCESS - Next firmware volume found with address information\r
833\r
834--*/\r
835{\r
836 EFI_PEI_HOB_POINTERS FirmwareVolumeHob;\r
837\r
838 FirmwareVolumeHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, *HobStart);\r
839 if (FirmwareVolumeHob.Raw != NULL) {\r
840 return EFI_NOT_FOUND;\r
841 }\r
842\r
843 *BaseAddress = FirmwareVolumeHob.FirmwareVolume->BaseAddress;\r
844 *Length = FirmwareVolumeHob.FirmwareVolume->Length;\r
845\r
846 *HobStart = GET_NEXT_HOB (FirmwareVolumeHob);\r
847\r
848 return EFI_SUCCESS;\r
849}\r
850////~\r
851\r
852////#HobLib\r
853EFI_STATUS\r
854R8_GetNextGuidHob (\r
855 IN OUT VOID **HobStart,\r
856 IN EFI_GUID * Guid,\r
857 OUT VOID **Buffer,\r
858 OUT UINTN *BufferSize OPTIONAL\r
859 )\r
860/*++\r
861\r
862Routine Description:\r
863 Get the next guid hob.\r
864 \r
865Arguments:\r
866 HobStart A pointer to the start hob.\r
867 Guid A pointer to a guid.\r
868 Buffer A pointer to the buffer.\r
869 BufferSize Buffer size.\r
870 \r
871Returns:\r
872 Status code.\r
873\r
874 EFI_NOT_FOUND - Next Guid hob not found\r
875 \r
876 EFI_SUCCESS - Next Guid hob found and data for this Guid got\r
877 \r
878 EFI_INVALID_PARAMETER - invalid parameter\r
879\r
880--*/\r
881{\r
882 EFI_PEI_HOB_POINTERS GuidHob;\r
883\r
884 if (Buffer == NULL) {\r
885 return EFI_INVALID_PARAMETER;\r
886 }\r
887\r
888 GuidHob.Raw = GetNextGuidHob (Guid, *HobStart);\r
889 if (GuidHob == NULL) {\r
890 return EFI_NOT_FOUND;\r
891 }\r
892 \r
893 *Buffer = GET_GUID_HOB_DATA (GuidHob.Guid);\r
894 if (BufferSize != NULL) {\r
895 *BufferSize = GET_GUID_HOB_DATA_SIZE (GuidHob.Guid);\r
896 }\r
897\r
898 *HobStart = GET_NEXT_HOB (GuidHob);\r
899\r
900 return EFI_SUCCESS;\r
901}\r
902////~\r
903\r
904////#HobLib\r
905EFI_STATUS\r
906R8_GetPalEntryHobInfo (\r
907 IN VOID *HobStart,\r
908 OUT EFI_PHYSICAL_ADDRESS *PalEntry\r
909 )\r
910/*++\r
911\r
912Routine Description:\r
913\r
914 Get PAL entry from PalEntryHob\r
915\r
916Arguments:\r
917\r
918 HobStart - Start pointer of hob list\r
919 \r
920 PalEntry - Pointer to PAL entry\r
921\r
922Returns:\r
923\r
924 Status code.\r
925\r
926--*/\r
927{\r
928 EFI_HOB_GUID_TYPE *GuidHob;\r
929\r
930 GuidHob = GetNextGuidHob (&gPalEntryHob, HobStart);\r
931\r
932 if (GuidHob == NULL) {\r
933 return EFI_NOT_FOUND;\r
934 }\r
935\r
936 *PalEntry = *((EFI_PHYSICAL_ADDRESS *) GET_GUID_HOB_DATA (GuidHob));\r
937 return EFI_SUCCESS;\r
938}\r
939////~\r
940\r
941////#HobLib\r
942EFI_STATUS\r
943R8_GetIoPortSpaceAddressHobInfo (\r
944 IN VOID *HobStart,\r
945 OUT EFI_PHYSICAL_ADDRESS *IoPortSpaceAddress\r
946 )\r
947/*++\r
948\r
949Routine Description:\r
950\r
951 Get IO port space address from IoBaseHob.\r
952\r
953Arguments:\r
954\r
955 HobStart - Start pointer of hob list\r
956 \r
957 IoPortSpaceAddress - IO port space address\r
958\r
959Returns:\r
960\r
961 Status code\r
962\r
963--*/\r
964{\r
965 EFI_HOB_GUID_TYPE *GuidHob;\r
966\r
967 GuidHob = GetNextGuidHob (&gEfiIoBaseHobGuid, HobStart);\r
968\r
969 if (GuidHob == NULL) {\r
970 return EFI_NOT_FOUND;\r
971 }\r
972\r
973 *IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) GET_GUID_HOB_DATA (GuidHob));\r
974 return EFI_SUCCESS;\r
975}\r
976////~\r
977\r