]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Conf/Migration/R8Lib.c
Add a far maker
[mirror_edk2.git] / Tools / Conf / Migration / R8Lib.c
index 6a838869051100d89642d43e1f727bda0c587659..c705187219aed3aaf23c9c2d48bb9a21bfe1710f 100644 (file)
@@ -1,5 +1,8 @@
 /** @file\r
-  Obsolete library.\r
+  Obsolete library interfaces.\r
+\r
+  This file contains part of obsolete library interfaces in EDK.\r
+  User is recommended to follow the porting Guide in R8Lib.c to elimante them.\r
 \r
   Copyright (c) 2006, Intel Corporation\r
   All rights reserved. This program and the accompanying materials\r
@@ -12,7 +15,7 @@
 \r
 **/\r
 \r
-////\r
+////#UefiBootServicesTableLib\r
 EFI_STATUS\r
 R8_EfiLibInstallDriverBinding (\r
   IN EFI_HANDLE                   ImageHandle,\r
@@ -32,27 +35,23 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  ImageHandle         - The image handle of the driver\r
-\r
+  ImageHandle         - The image handle of the driver.\r
   SystemTable         - The EFI System Table that was passed to the driver's entry point\r
-\r
   DriverBinding       - A Driver Binding Protocol instance that this driver is producing\r
-\r
   DriverBindingHandle - The handle that DriverBinding is to be installe onto.  If this\r
                         parameter is NULL, then a new handle is created.\r
 \r
 Returns: \r
 \r
-  EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle\r
-\r
-  Otherwise, then return status from gBS->InstallProtocolInterface()\r
+  EFI_SUCCESS         - DriverBinding is installed onto DriverBindingHandle\r
+  Others              - Some error occurs when executing gBS->InstallProtocolInterface()\r
 \r
 --*/\r
 {\r
   //\r
   // Porting Guide:\r
   // This obsolete Edk library interface installs driver binding protocol.\r
-  // If the entry point of that module only invoke this function, it can\r
+  // If the entry point of that module ONLY invokes this function, it can\r
   // use UefiDriverModuleLib in MdePkg and expose "DriverBinding" protocol interface\r
   // at the <Externs> tag, build tool will auto generate code to handle it.\r
   // For example:\r
@@ -63,7 +62,6 @@ Returns:
   // </Externs>\r
   //\r
   DriverBinding->ImageHandle          = ImageHandle;\r
-\r
   DriverBinding->DriverBindingHandle  = DriverBindingHandle;\r
 \r
   return gBS->InstallProtocolInterface (\r
@@ -75,16 +73,16 @@ Returns:
 }\r
 ////~\r
 \r
-////\r
+////#UefiBootServicesTableLib\r
 EFI_STATUS\r
 R8_EfiLibInstallAllDriverProtocols (\r
   IN EFI_HANDLE                         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                   * SystemTable,\r
-  IN EFI_DRIVER_BINDING_PROTOCOL        * DriverBinding,\r
+  IN EFI_SYSTEM_TABLE                   *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL        *DriverBinding,\r
   IN EFI_HANDLE                         DriverBindingHandle,\r
-  IN EFI_COMPONENT_NAME_PROTOCOL        * ComponentName, OPTIONAL\r
-  IN EFI_DRIVER_CONFIGURATION_PROTOCOL  * DriverConfiguration, OPTIONAL\r
-  IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL    * DriverDiagnostics OPTIONAL\r
+  IN EFI_COMPONENT_NAME_PROTOCOL        *ComponentName, OPTIONAL\r
+  IN EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration, OPTIONAL\r
+  IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics OPTIONAL\r
   )\r
 /*++\r
 \r
@@ -99,25 +97,18 @@ Routine Description:
 Arguments:\r
 \r
   ImageHandle         - The image handle of the driver\r
-\r
   SystemTable         - The EFI System Table that was passed to the driver's entry point\r
-\r
   DriverBinding       - A Driver Binding Protocol instance that this driver is producing\r
-\r
   DriverBindingHandle - The handle that DriverBinding is to be installe onto.  If this\r
                         parameter is NULL, then a new handle is created.\r
-\r
   ComponentName       - A Component Name Protocol instance that this driver is producing\r
-\r
   DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing\r
-  \r
   DriverDiagnostics   - A Driver Diagnostics Protocol instance that this driver is producing\r
 \r
 Returns: \r
 \r
-  EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
-\r
-  Otherwise, then return status from gBS->InstallProtocolInterface()\r
+  EFI_SUCCESS         - DriverBinding is installed onto DriverBindingHandle\r
+  Others              - Some error occurs when executing gBS->InstallProtocolInterface()\r
 \r
 --*/\r
 {\r
@@ -125,7 +116,7 @@ Returns:
   // Porting Guide:\r
   // This obsolete Edk library interface installs driver binding protocol\r
   // with optional component name, driver configuration & driver diagnotics protocols.\r
-  // If the entry point of that module only invoke this function, it can\r
+  // If the entry point of that module ONLY invokes this function, it can\r
   // use UefiDriverModuleLib in MdePkg and expose "DriverBinding", "ComponentName",\r
   // "DriverConfiguration" and "DriverDiagnostics" protocol interfaces.\r
   // at the <Externs> tag, build tool will auto generate code to handle it.\r
@@ -141,7 +132,15 @@ Returns:
   //\r
   EFI_STATUS  Status;\r
 \r
-  Status = R8_EfiLibInstallDriverBinding (ImageHandle, SystemTable, DriverBinding, DriverBindingHandle);\r
+  DriverBinding->ImageHandle          = ImageHandle;\r
+  DriverBinding->DriverBindingHandle  = DriverBindingHandle;\r
+\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &DriverBinding->DriverBindingHandle,\r
+                  &gEfiDriverBindingProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  DriverBinding\r
+                  );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -242,16 +241,16 @@ R8_BufToHexString (
     At a minimum, any blob of data could be represented as a hex string.\r
 \r
   Arguments:\r
-    Str - Pointer to the string.\r
+    Str                   - Pointer to the string.\r
     HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.\r
-                                        If routine return with EFI_SUCCESS, containing length of hex string buffer.\r
-                                        If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.\r
-    Buf - Buffer to be converted from.\r
-    Len - Length in bytes of the buffer to be converted.\r
+                            If routine return with EFI_SUCCESS, containing length of hex string buffer.\r
+                            If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.\r
+    Buf                   - Buffer to be converted from.\r
+    Len                   - Length in bytes of the buffer to be converted.\r
 \r
   Returns:\r
-    EFI_SUCCESS: Routine success.\r
-    EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.\r
+    EFI_SUCCESS             - Routine success.\r
+    EFI_BUFFER_TOO_SMALL    - The hex string buffer is too small.\r
 \r
 --*/\r
 {\r
@@ -308,10 +307,8 @@ Arguments:
   \r
   str     - Pointer to the null-terminated string to be trimmed. On return, \r
             str will hold the trimmed string. \r
-  CharC       - Character will be trimmed from str.\r
+  CharC   - Character will be trimmed from str.\r
   \r
-Returns:\r
-\r
 --*/\r
 {\r
   //\r
@@ -375,11 +372,8 @@ Routine Description:
 Arguments:\r
 \r
   Buffer - Location to place ascii hex string of Value.\r
-\r
   Value  - Hex value to convert to a string in Buffer.\r
-\r
   Flags  - Flags to use in printing Hex string, see file header for details.\r
-\r
   Width  - Width of hex value.\r
 \r
 Returns: \r
@@ -482,9 +476,8 @@ R8_HexStringToBuf (
     ConvertedStrLen - Length of the Hex String consumed.\r
 \r
   Returns:\r
-    EFI_SUCCESS: Routine Success.\r
-    EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.\r
-    EFI_\r
+    EFI_SUCCESS           - Routine Success.\r
+    EFI_BUFFER_TOO_SMALL  - The buffer is too small to hold converted data.\r
 \r
 --*/\r
 {\r
@@ -645,13 +638,13 @@ Routine Description:
   \r
 Arguments:\r
 \r
-  Type          The HOB type to return.\r
-  HobStart      The first HOB in the HOB list.\r
+  Type          The HOB type to return.\r
+  HobStart      The first HOB in the HOB list.\r
     \r
 Returns:\r
 \r
-  HobStart      There were no HOBs found with the requested type.\r
-  else          Returns the first HOB with the matching type.\r
+  HobStart      There were no HOBs found with the requested type.\r
+  Other         - The first HOB with the matching type.\r
 \r
 --*/\r
 {\r
@@ -771,13 +764,11 @@ Routine Description:
 Arguments:\r
 \r
   HobStart      - Start pointer of hob list\r
-  \r
   BootMode      - Current boot mode recorded in PHIT hob\r
 \r
 Returns:\r
 \r
   EFI_NOT_FOUND     - Invalid hob header\r
-  \r
   EFI_SUCCESS       - Boot mode found\r
 \r
 --*/\r
@@ -792,7 +783,7 @@ Returns:
   // EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;\r
   //\r
   // HandOffHob = GetHobList ();  \r
-  // ASSERT (HandOffHob->Header.HobType = EFI_HOB_TYPE_HANDOFF);\r
+  // ASSERT (HandOffHob->Header.HobType == EFI_HOB_TYPE_HANDOFF);\r
   // \r
   // BootMode = HandOffHob->BootMode;\r
   //\r
@@ -825,15 +816,12 @@ Routine Description:
 Arguments:\r
 \r
   HobStart            - Start pointer of hob list\r
-  \r
   SizeOfMemorySpace   - Size of memory size\r
-  \r
   SizeOfIoSpace       - Size of IO size\r
 \r
 Returns:\r
 \r
   EFI_NOT_FOUND     - CPU hob not found\r
-  \r
   EFI_SUCCESS       - CPU hob found and information got.\r
 \r
 --*/\r
@@ -936,15 +924,12 @@ Routine Description:
 Arguments:\r
 \r
   HobStart        - Start pointer of hob list\r
-  \r
   BaseAddress     - Start address of next firmware volume\r
-  \r
   Length          - Length of next firmware volume\r
 \r
 Returns:\r
 \r
   EFI_NOT_FOUND   - Next firmware volume not found\r
-  \r
   EFI_SUCCESS     - Next firmware volume found with address information\r
 \r
 --*/\r
@@ -998,18 +983,14 @@ Routine Description:
   Get the next guid hob.\r
   \r
 Arguments:\r
-  HobStart        A pointer to the start hob.\r
-  Guid            A pointer to a guid.\r
-  Buffer          A pointer to the buffer.\r
-  BufferSize      Buffer size.\r
+  HobStart        A pointer to the start hob.\r
+  Guid            A pointer to a guid.\r
+  Buffer          A pointer to the buffer.\r
+  BufferSize      Buffer size.\r
   \r
 Returns:\r
-  Status code.\r
-\r
   EFI_NOT_FOUND          - Next Guid hob not found\r
-  \r
   EFI_SUCCESS            - Next Guid hob found and data for this Guid got\r
-  \r
   EFI_INVALID_PARAMETER  - invalid parameter\r
 \r
 --*/\r
@@ -1032,7 +1013,7 @@ Returns:
   }\r
 \r
   GuidHob.Raw = GetNextGuidHob (Guid, *HobStart);\r
-  if (GuidHob == NULL) {\r
+  if (GuidHob.Raw == NULL) {\r
     return EFI_NOT_FOUND;\r
   }\r
   \r
@@ -1062,7 +1043,6 @@ Routine Description:
 Arguments:\r
 \r
   HobStart      - Start pointer of hob list\r
-  \r
   PalEntry      - Pointer to PAL entry\r
 \r
 Returns:\r
@@ -1099,7 +1079,6 @@ Routine Description:
 Arguments:\r
 \r
   HobStart              - Start pointer of hob list\r
-  \r
   IoPortSpaceAddress    - IO port space address\r
 \r
 Returns:\r
@@ -1126,3 +1105,46 @@ Returns:
 }\r
 ////~\r
 \r
+////#HobLib\r
+EFI_STATUS\r
+R8_PeiBuildHobGuid (\r
+  IN  EFI_GUID          *Guid,\r
+  IN  UINTN             DataLength,\r
+  OUT VOID              **Hob\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a custom HOB that is tagged with a GUID for identification\r
+\r
+Arguments:\r
+\r
+  Guid        - The GUID of the custome HOB type\r
+  DataLength  - The size of the data payload for the GUIDed HOB\r
+  Hob         - Pointer to pointer to the created Hob\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Hob is successfully built.\r
+  Others      - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  //\r
+  // Porting Guide: Apply the new interface of BuildGuidHob in R9 HobLib.\r
+  // Pay attention that the return value has been changed to the start address of\r
+  // GUID HOB data so that caller can fill the customized data. \r
+  // For BuildGuidHob (), the HOB Header and Name field is already stripped..\r
+  //\r
+  VOID   *HobData; \r
+\r
+  HobData = BuildGuidHob (Guid, DataLength);\r
+  //\r
+  // This step is necessary to be compatible with R8 interface!\r
+  //\r
+  *Hob    = (VOID *) ((UINT8 *) HobData - sizeof (EFI_HOB_GUID_TYPE)); \r
+\r
+  return EFI_SUCCESS; \r
+}\r
+////~\r