]> code.delx.au - refind/commitdiff
TianoCore build support; new use_graphics_for refind.conf token
authorsrs5694 <srs5694@users.sourceforge.net>
Thu, 21 Jun 2012 18:38:37 +0000 (14:38 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Thu, 21 Jun 2012 18:38:37 +0000 (14:38 -0400)
37 files changed:
EfiLib/BdsConnect.c [new file with mode: 0644]
EfiLib/BmLib.c [new file with mode: 0644]
EfiLib/Console.c [new file with mode: 0644]
EfiLib/DevicePath.c [new file with mode: 0644]
EfiLib/GenericBdsLib.h [new file with mode: 0644]
EfiLib/Make.tiano [new file with mode: 0644]
EfiLib/Platform.h [new file with mode: 0644]
Make.common
Make.tiano [new file with mode: 0644]
Makefile
NEWS.txt
docs/refind/configfile.html
filesystems/Make.common
include/refit_call_wrapper.h
libeg/Make.tiano [new file with mode: 0644]
libeg/image.c
libeg/libeg.h
libeg/libegint.h
libeg/load_bmp.c
libeg/screen.c
refind.conf-sample
refind/AutoGen.c [new file with mode: 0644]
refind/AutoGen.h [new file with mode: 0644]
refind/Make.tiano [new file with mode: 0644]
refind/config.c
refind/config.h
refind/driver_support.c
refind/driver_support.h
refind/global.h
refind/icns.c
refind/lib.c
refind/lib.h
refind/main.c
refind/menu.c
refind/menu.h
refind/screen.c
refind/screen.h

diff --git a/EfiLib/BdsConnect.c b/EfiLib/BdsConnect.c
new file mode 100644 (file)
index 0000000..d168462
--- /dev/null
@@ -0,0 +1,641 @@
+/** @file\r
+  BDS Lib functions which relate with connect the device\r
+\r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "Platform.h"\r
+\r
+\r
+/**\r
+  This function will connect all the system driver to controller\r
+  first, and then special connect the default console, this make\r
+  sure all the system controller available and the platform default\r
+  console connected.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibConnectAll (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Connect the platform console first\r
+  //\r
+  BdsLibConnectAllDefaultConsoles ();\r
+\r
+  //\r
+  // Generic way to connect all the drivers\r
+  //\r
+  BdsLibConnectAllDriversToAllControllers ();\r
+\r
+  //\r
+  // Here we have the assumption that we have already had\r
+  // platform default console\r
+  //\r
+  BdsLibConnectAllDefaultConsoles ();\r
+}\r
+\r
+\r
+/**\r
+  This function will connect all the system drivers to all controllers\r
+  first, and then connect all the console devices the system current\r
+  have. After this we should get all the device work and console available\r
+  if the system have console device.\r
+\r
+**/\r
+VOID\r
+BdsLibGenericConnectAll (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Most generic way to connect all the drivers\r
+  //\r
+  BdsLibConnectAllDriversToAllControllers ();\r
+  BdsLibConnectAllConsoles ();\r
+}\r
+\r
+\r
+/**\r
+  This function will create all handles associate with every device\r
+  path node. If the handle associate with one device path node can not\r
+  be created success, then still give one chance to do the dispatch,\r
+  which load the missing drivers if possible.\r
+\r
+  @param  DevicePathToConnect   The device path which will be connected, it can be\r
+                                a multi-instance device path\r
+\r
+  @retval EFI_SUCCESS           All handles associate with every device path  node\r
+                                have been created\r
+  @retval EFI_OUT_OF_RESOURCES  There is no resource to create new handles\r
+  @retval EFI_NOT_FOUND         Create the handle associate with one device  path\r
+                                node failed\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
+  EFI_DEVICE_PATH_PROTOCOL  *RemainingDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Next;\r
+  EFI_HANDLE                Handle;\r
+  EFI_HANDLE                PreviousHandle;\r
+  UINTN                     Size;\r
+\r
+  if (DevicePathToConnect == NULL) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  DevicePath        = DuplicateDevicePath (DevicePathToConnect);\r
+  if (DevicePath == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  CopyOfDevicePath  = DevicePath;\r
+  \r
+  do {\r
+    //\r
+    // The outer loop handles multi instance device paths.\r
+    // Only console variables contain multiple instance device paths.\r
+    //\r
+    // After this call DevicePath points to the next Instance\r
+    //\r
+    Instance  = GetNextDevicePathInstance (&DevicePath, &Size);\r
+    if (Instance == NULL) {\r
+      FreePool (CopyOfDevicePath);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    \r
+    Next      = Instance;\r
+    while (!IsDevicePathEndType (Next)) {\r
+      Next = NextDevicePathNode (Next);\r
+    }\r
+\r
+    SetDevicePathEndNode (Next);\r
+\r
+    //\r
+    // Start the real work of connect with RemainingDevicePath\r
+    //\r
+    PreviousHandle = NULL;\r
+    do {\r
+      //\r
+      // Find the handle that best matches the Device Path. If it is only a\r
+      // partial match the remaining part of the device path is returned in\r
+      // RemainingDevicePath.\r
+      //\r
+      RemainingDevicePath = Instance;\r
+      Status              = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);\r
+\r
+      if (!EFI_ERROR (Status)) {\r
+        if (Handle == PreviousHandle) {\r
+          //\r
+          // If no forward progress is made try invoking the Dispatcher.\r
+          // A new FV may have been added to the system an new drivers\r
+          // may now be found.\r
+          // Status == EFI_SUCCESS means a driver was dispatched\r
+          // Status == EFI_NOT_FOUND means no new drivers were dispatched\r
+          //\r
+          Status = gDS->Dispatch ();\r
+        }\r
+\r
+        if (!EFI_ERROR (Status)) {\r
+          PreviousHandle = Handle;\r
+          //\r
+          // Connect all drivers that apply to Handle and RemainingDevicePath,\r
+          // the Recursive flag is FALSE so only one level will be expanded.\r
+          //\r
+          // Do not check the connect status here, if the connect controller fail,\r
+          // then still give the chance to do dispatch, because partial\r
+          // RemainingDevicepath may be in the new FV\r
+          //\r
+          // 1. If the connect fail, RemainingDevicepath and handle will not\r
+          //    change, so next time will do the dispatch, then dispatch's status\r
+          //    will take effect\r
+          // 2. If the connect success, the RemainingDevicepath and handle will\r
+          //    change, then avoid the dispatch, we have chance to continue the\r
+          //    next connection\r
+          //\r
+          gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);\r
+        }\r
+      }\r
+      //\r
+      // Loop until RemainingDevicePath is an empty device path\r
+      //\r
+    } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));\r
+\r
+  } while (DevicePath != NULL);\r
+\r
+  if (CopyOfDevicePath != NULL) {\r
+    FreePool (CopyOfDevicePath);\r
+  }\r
+  //\r
+  // All handle with DevicePath exists in the handle database\r
+  //\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  This function will connect all current system handles recursively. \r
+  \r
+  gBS->ConnectController() service is invoked for each handle exist in system handler buffer.\r
+  If the handle is bus type handler, all childrens also will be connected recursively\r
+  by gBS->ConnectController().\r
+\r
+  @retval EFI_SUCCESS           All handles and it's child handle have been connected\r
+  @retval EFI_STATUS            Error status returned by of gBS->LocateHandleBuffer().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectAllEfi (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       HandleCount;\r
+  EFI_HANDLE  *HandleBuffer;\r
+  UINTN       Index;\r
+\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  NULL,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
+  }\r
+\r
+  if (HandleBuffer != NULL) {\r
+    FreePool (HandleBuffer);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  This function will disconnect all current system handles. \r
+  \r
+  gBS->DisconnectController() is invoked for each handle exists in system handle buffer.\r
+  If handle is a bus type handle, all childrens also are disconnected recursively by\r
+  gBS->DisconnectController().\r
+\r
+  @retval EFI_SUCCESS           All handles have been disconnected\r
+  @retval EFI_STATUS            Error status returned by of gBS->LocateHandleBuffer().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibDisconnectAllEfi (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       HandleCount;\r
+  EFI_HANDLE  *HandleBuffer;\r
+  UINTN       Index;\r
+\r
+  //\r
+  // Disconnect all\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  NULL,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
+  }\r
+\r
+  if (HandleBuffer != NULL) {\r
+    FreePool (HandleBuffer);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS ScanDeviceHandles(EFI_HANDLE ControllerHandle,\r
+                             UINTN *HandleCount,\r
+                             EFI_HANDLE **HandleBuffer,\r
+                             UINT32 **HandleType)\r
+{\r
+  EFI_STATUS                          Status;\r
+  UINTN                               HandleIndex;\r
+  EFI_GUID                            **ProtocolGuidArray;\r
+  UINTN                               ArrayCount;\r
+  UINTN                               ProtocolIndex;\r
+  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;\r
+  UINTN                               OpenInfoCount;\r
+  UINTN                               OpenInfoIndex;\r
+  UINTN                               ChildIndex;\r
+  \r
+  *HandleCount  = 0;\r
+  *HandleBuffer = NULL;\r
+  *HandleType   = NULL;\r
+  \r
+  //\r
+  // Retrieve the list of all handles from the handle database\r
+  //\r
+  Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, HandleCount, HandleBuffer);\r
+  if (EFI_ERROR (Status)) goto Error;\r
+  \r
+  *HandleType = AllocatePool (*HandleCount * sizeof (UINT32));\r
+  if (*HandleType == NULL) goto Error;\r
+    \r
+  for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {\r
+    (*HandleType)[HandleIndex] = EFI_HANDLE_TYPE_UNKNOWN;\r
+    //\r
+    // Retrieve the list of all the protocols on each handle\r
+    //\r
+    Status = gBS->ProtocolsPerHandle (\r
+                  (*HandleBuffer)[HandleIndex],\r
+                  &ProtocolGuidArray,\r
+                  &ArrayCount\r
+                  );\r
+    if (!EFI_ERROR (Status)) {      \r
+      for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) \r
+      {\r
+        \r
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid))\r
+        {\r
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_IMAGE_HANDLE;\r
+        }\r
+        \r
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid))\r
+        {\r
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE;\r
+        }\r
+        \r
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid)) \r
+        {\r
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE;\r
+        }\r
+        \r
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid)) \r
+        {\r
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE;\r
+        }\r
+        \r
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid)) \r
+        {\r
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_COMPONENT_NAME_HANDLE;\r
+        }\r
+        \r
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) \r
+        {\r
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_COMPONENT_NAME_HANDLE;\r
+        }\r
+        \r
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid)) \r
+        {\r
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DEVICE_HANDLE;\r
+        }\r
+        \r
+        //\r
+        // Retrieve the list of agents that have opened each protocol\r
+        //\r
+        Status = gBS->OpenProtocolInformation (\r
+                                               (*HandleBuffer)[HandleIndex],\r
+                                               ProtocolGuidArray[ProtocolIndex],\r
+                                               &OpenInfo,\r
+                                               &OpenInfoCount\r
+                                               );\r
+        if (!EFI_ERROR (Status)) {\r
+          \r
+          for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
+            \r
+            if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle)\r
+            {\r
+              if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) \r
+              {\r
+                for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) \r
+                {\r
+                  if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) \r
+                  {\r
+                    (*HandleType)[ChildIndex] |= EFI_HANDLE_TYPE_DEVICE_DRIVER;\r
+                  }\r
+                }\r
+              }\r
+              \r
+              if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER)\r
+              {\r
+                (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_PARENT_HANDLE;\r
+                for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) \r
+                {\r
+                  if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) \r
+                  {\r
+                    (*HandleType)[ChildIndex] |= EFI_HANDLE_TYPE_BUS_DRIVER;\r
+                  }\r
+                }\r
+              }\r
+            }\r
+          }\r
+          \r
+          FreePool (OpenInfo);\r
+        }\r
+      }\r
+      \r
+      FreePool (ProtocolGuidArray);\r
+    }\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
+  \r
+Error:\r
+  if (*HandleType != NULL) {\r
+    FreePool (*HandleType);\r
+  }\r
+  \r
+  if (*HandleBuffer != NULL) {\r
+    FreePool (*HandleBuffer);\r
+  }\r
+  \r
+  *HandleCount  = 0;\r
+  *HandleBuffer = NULL;\r
+  *HandleType   = NULL;\r
+  \r
+  return Status;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS BdsLibConnectMostlyAllEfi()\r
+{\r
+       EFI_STATUS                              Status;\r
+       UINTN             AllHandleCount;\r
+       EFI_HANDLE                              *AllHandleBuffer;\r
+       UINTN             Index;\r
+       UINTN             HandleCount;\r
+       EFI_HANDLE                              *HandleBuffer;\r
+       UINT32            *HandleType;\r
+       UINTN             HandleIndex;\r
+       BOOLEAN           Parent;\r
+       BOOLEAN           Device;\r
+       EFI_PCI_IO_PROTOCOL*    PciIo;\r
+       PCI_TYPE00                              Pci;\r
+  \r
+  \r
+       Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &AllHandleCount, &AllHandleBuffer);\r
+       if (CheckError(Status, L"locating handle buffer")) \r
+               return Status;\r
+  \r
+       for (Index = 0; Index < AllHandleCount; Index++) \r
+       {\r
+               Status = ScanDeviceHandles(AllHandleBuffer[Index], &HandleCount, &HandleBuffer, &HandleType);\r
+    \r
+               if (EFI_ERROR (Status))\r
+                       goto Done;\r
+    \r
+               Device = TRUE;\r
+               \r
+               if (HandleType[Index] & EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE)\r
+                       Device = FALSE;\r
+               if (HandleType[Index] & EFI_HANDLE_TYPE_IMAGE_HANDLE)\r
+                       Device = FALSE;\r
+    \r
+               if (Device) \r
+               {                                       \r
+                       Parent = FALSE;\r
+                       for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) \r
+                       {\r
+                               if (HandleType[HandleIndex] & EFI_HANDLE_TYPE_PARENT_HANDLE)\r
+                                       Parent = TRUE;\r
+                       }\r
+      \r
+                       if (!Parent) \r
+                       {\r
+                               if (HandleType[Index] & EFI_HANDLE_TYPE_DEVICE_HANDLE) \r
+                               {\r
+                                       Status = gBS->HandleProtocol (AllHandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID*)&PciIo);\r
+                                       if (!EFI_ERROR (Status)) \r
+                                       {\r
+                                               Status = PciIo->Pci.Read (PciIo,EfiPciIoWidthUint32, 0, sizeof (Pci) / sizeof (UINT32), &Pci);\r
+                                               if (!EFI_ERROR (Status))\r
+                                               {\r
+                                                       if(IS_PCI_VGA(&Pci)==TRUE)\r
+                                                       {\r
+                                                               gBS->DisconnectController(AllHandleBuffer[Index], NULL, NULL);\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                                       Status = gBS->ConnectController(AllHandleBuffer[Index], NULL, NULL, TRUE);\r
+                               }\r
+                       }\r
+               }\r
+    \r
+               FreePool (HandleBuffer);\r
+               FreePool (HandleType);\r
+       }\r
+  \r
+Done:\r
+       FreePool (AllHandleBuffer);\r
+       return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Connects all drivers to all controllers.\r
+  This function make sure all the current system driver will manage\r
+  the correspoinding controllers if have. And at the same time, make\r
+  sure all the system controllers have driver to manage it if have.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibConnectAllDriversToAllControllers (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  do {\r
+    //\r
+    // Connect All EFI 1.10 drivers following EFI 1.10 algorithm\r
+    //\r
+    //BdsLibConnectAllEfi ();\r
+    BdsLibConnectMostlyAllEfi ();\r
+\r
+    //\r
+    // Check to see if it's possible to dispatch an more DXE drivers.\r
+    // The BdsLibConnectAllEfi () may have made new DXE drivers show up.\r
+    // If anything is Dispatched Status == EFI_SUCCESS and we will try\r
+    // the connect again.\r
+    //\r
+    Status = gDS->Dispatch ();\r
+\r
+  } while (!EFI_ERROR (Status));\r
+\r
+}\r
+\r
+\r
+/**\r
+  Connect the specific Usb device which match the short form device path,\r
+  and whose bus is determined by Host Controller (Uhci or Ehci).\r
+\r
+  @param  HostControllerPI      Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
+                                (0xFF)\r
+  @param  RemainingDevicePath   a short-form device path that starts with the first\r
+                                element  being a USB WWID or a USB Class device\r
+                                path\r
+\r
+  @return EFI_INVALID_PARAMETER  RemainingDevicePath is NULL pointer.\r
+                                 RemainingDevicePath is not a USB device path.\r
+                                 Invalid HostControllerPI type.\r
+  @return EFI_SUCCESS            Success to connect USB device\r
+  @return EFI_NOT_FOUND          Fail to find handle for USB controller to connect.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectUsbDevByShortFormDP(\r
+  IN UINT8                      HostControllerPI,\r
+  IN EFI_DEVICE_PATH_PROTOCOL   *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_HANDLE                            *HandleArray;\r
+  UINTN                                 HandleArrayCount;\r
+  UINTN                                 Index;\r
+  EFI_PCI_IO_PROTOCOL                   *PciIo;\r
+  UINT8                                 Class[3];\r
+  BOOLEAN                               AtLeastOneConnected;\r
+\r
+  //\r
+  // Check the passed in parameters\r
+  //\r
+  if (RemainingDevicePath == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if ((DevicePathType (RemainingDevicePath) != MESSAGING_DEVICE_PATH) ||\r
+      ((DevicePathSubType (RemainingDevicePath) != MSG_USB_CLASS_DP)\r
+      && (DevicePathSubType (RemainingDevicePath) != MSG_USB_WWID_DP)\r
+      )) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (HostControllerPI != 0xFF &&\r
+      HostControllerPI != 0x00 &&\r
+      HostControllerPI != 0x10 &&\r
+      HostControllerPI != 0x20 &&\r
+      HostControllerPI != 0x30) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Find the usb host controller firstly, then connect with the remaining device path\r
+  //\r
+  AtLeastOneConnected = FALSE;\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiPciIoProtocolGuid,\r
+                  NULL,\r
+                  &HandleArrayCount,\r
+                  &HandleArray\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    for (Index = 0; Index < HandleArrayCount; Index++) {\r
+      Status = gBS->HandleProtocol (\r
+                      HandleArray[Index],\r
+                      &gEfiPciIoProtocolGuid,\r
+                      (VOID **)&PciIo\r
+                      );\r
+      if (!EFI_ERROR (Status)) {\r
+        //\r
+        // Check whether the Pci device is the wanted usb host controller\r
+        //\r
+        Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);\r
+        if (!EFI_ERROR (Status)) {\r
+          if ((PCI_CLASS_SERIAL == Class[2]) &&\r
+              (PCI_CLASS_SERIAL_USB == Class[1])) {\r
+            if (HostControllerPI == Class[0] || HostControllerPI == 0xFF) {\r
+              Status = gBS->ConnectController (\r
+                              HandleArray[Index],\r
+                              NULL,\r
+                              RemainingDevicePath,\r
+                              FALSE\r
+                              );\r
+              if (!EFI_ERROR(Status)) {\r
+                AtLeastOneConnected = TRUE;\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
+    if (AtLeastOneConnected) {\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
diff --git a/EfiLib/BmLib.c b/EfiLib/BmLib.c
new file mode 100644 (file)
index 0000000..a8b4dc5
--- /dev/null
@@ -0,0 +1,325 @@
+/** @file\r
+  Utility routines used by boot maintenance modules.\r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "Platform.h"\r
+/**\r
+\r
+  Find the first instance of this Protocol\r
+  in the system and return it's interface.\r
+\r
+\r
+  @param ProtocolGuid    Provides the protocol to search for\r
+  @param Interface       On return, a pointer to the first interface\r
+                         that matches ProtocolGuid\r
+\r
+  @retval  EFI_SUCCESS      A protocol instance matching ProtocolGuid was found\r
+  @retval  EFI_NOT_FOUND    No protocol instances were found that match ProtocolGuid\r
+\r
+**/\r
+EFI_STATUS\r
+EfiLibLocateProtocol (\r
+  IN  EFI_GUID    *ProtocolGuid,\r
+  OUT VOID        **Interface\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  ProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) Interface\r
+                  );\r
+  return Status;\r
+}\r
+\r
+/**\r
+\r
+  Function opens and returns a file handle to the root directory of a volume.\r
+\r
+  @param DeviceHandle    A handle for a device\r
+\r
+  @return A valid file handle or NULL is returned\r
+\r
+**/\r
+EFI_FILE_HANDLE\r
+EfiLibOpenRoot (\r
+  IN EFI_HANDLE                   DeviceHandle\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;\r
+  EFI_FILE_HANDLE                 File;\r
+\r
+  File = NULL;\r
+\r
+  //\r
+  // File the file system interface to the device\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  DeviceHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  (VOID **) &Volume\r
+                  );\r
+\r
+  //\r
+  // Open the root directory of the volume\r
+  //\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = Volume->OpenVolume (\r
+                      Volume,\r
+                      &File\r
+                      );\r
+  }\r
+  //\r
+  // Done\r
+  //\r
+  return EFI_ERROR (Status) ? NULL : File;\r
+}\r
+\r
+/**\r
+\r
+  Function gets the file system information from an open file descriptor,\r
+  and stores it in a buffer allocated from pool.\r
+\r
+\r
+  @param FHand           The file handle.\r
+\r
+  @return                A pointer to a buffer with file information.\r
+  @retval                NULL is returned if failed to get Volume Label Info.\r
+\r
+**/\r
+EFI_FILE_SYSTEM_VOLUME_LABEL *\r
+EfiLibFileSystemVolumeLabelInfo (\r
+  IN EFI_FILE_HANDLE      FHand\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_FILE_SYSTEM_VOLUME_LABEL *VolumeInfo = NULL;\r
+  UINTN         Size = 0;\r
+  \r
+  Status = FHand->GetInfo (FHand, &gEfiFileSystemVolumeLabelInfoIdGuid, &Size, VolumeInfo);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    VolumeInfo = AllocateZeroPool (Size);\r
+    Status = FHand->GetInfo (FHand, &gEfiFileSystemVolumeLabelInfoIdGuid, &Size, VolumeInfo);\r
+  }\r
+  \r
+  return EFI_ERROR(Status)?NULL:VolumeInfo;  \r
+}\r
+\r
+/**\r
+  Duplicate a string.\r
+\r
+  @param Src             The source.\r
+\r
+  @return A new string which is duplicated copy of the source.\r
+  @retval NULL If there is not enough memory.\r
+\r
+**/\r
+CHAR16 *\r
+EfiStrDuplicate (\r
+  IN CHAR16   *Src\r
+                                )\r
+{\r
+  CHAR16  *Dest;\r
+  UINTN   Size;\r
+\r
+  Size  = StrSize (Src); //at least 2bytes\r
+  Dest  = AllocateZeroPool (Size);\r
+//  ASSERT (Dest != NULL);\r
+  if (Dest != NULL) {\r
+    CopyMem (Dest, Src, Size);\r
+  }\r
+\r
+  return Dest;\r
+}\r
+//Compare strings case insensitive\r
+INTN\r
+EFIAPI\r
+StriCmp (\r
+               IN      CONST CHAR16              *FirstString,\r
+               IN      CONST CHAR16              *SecondString\r
+               )\r
+{\r
+       \r
+       while ((*FirstString != L'\0') && ((*FirstString & ~0x20) == (*SecondString & ~0x20))) {\r
+               FirstString++;\r
+               SecondString++;\r
+       }\r
+       return *FirstString - *SecondString;\r
+}\r
+\r
+\r
+/**\r
+\r
+  Function gets the file information from an open file descriptor, and stores it\r
+  in a buffer allocated from pool.\r
+\r
+  @param FHand           File Handle.\r
+\r
+  @return                A pointer to a buffer with file information or NULL is returned\r
+\r
+**/\r
+EFI_FILE_INFO *\r
+EfiLibFileInfo (\r
+  IN EFI_FILE_HANDLE      FHand\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_FILE_INFO *FileInfo = NULL;\r
+  UINTN         Size = 0;\r
+  \r
+  Status = FHand->GetInfo (FHand, &gEfiFileInfoGuid, &Size, FileInfo);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    FileInfo = AllocateZeroPool (Size);\r
+    Status = FHand->GetInfo (FHand, &gEfiFileInfoGuid, &Size, FileInfo);\r
+  }\r
+  \r
+  return EFI_ERROR(Status)?NULL:FileInfo;\r
+}\r
+\r
+EFI_FILE_SYSTEM_INFO *\r
+EfiLibFileSystemInfo (\r
+                IN EFI_FILE_HANDLE      FHand\r
+                )\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_FILE_SYSTEM_INFO *FileSystemInfo = NULL;\r
+  UINTN         Size = 0;\r
+  \r
+  Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    FileSystemInfo = AllocateZeroPool (Size);\r
+    Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo);\r
+  }\r
+  \r
+  return EFI_ERROR(Status)?NULL:FileSystemInfo;\r
+}\r
+\r
+/**\r
+  Function is used to determine the number of device path instances\r
+  that exist in a device path.\r
+\r
+\r
+  @param DevicePath      A pointer to a device path data structure.\r
+\r
+  @return This function counts and returns the number of device path instances\r
+          in DevicePath.\r
+\r
+**/\r
+UINTN\r
+EfiDevicePathInstanceCount (\r
+  IN EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
+  )\r
+{\r
+  UINTN Count;\r
+  UINTN Size;\r
+\r
+  Count = 0;\r
+  while (GetNextDevicePathInstance (&DevicePath, &Size) != NULL) {\r
+    Count += 1;\r
+  }\r
+\r
+  return Count;\r
+}\r
+\r
+/**\r
+  Adjusts the size of a previously allocated buffer.\r
+\r
+\r
+  @param OldPool         - A pointer to the buffer whose size is being adjusted.\r
+  @param OldSize         - The size of the current buffer.\r
+  @param NewSize         - The size of the new buffer.\r
+\r
+  @return   The newly allocated buffer.\r
+  @retval   NULL  Allocation failed.\r
+\r
+**/\r
+VOID *\r
+EfiReallocatePool (\r
+  IN VOID                 *OldPool,\r
+  IN UINTN                OldSize,\r
+  IN UINTN                NewSize\r
+  )\r
+{\r
+  VOID  *NewPool;\r
+\r
+  NewPool = NULL;\r
+  if (NewSize != 0) {\r
+    NewPool = AllocateZeroPool (NewSize);\r
+  }\r
+\r
+  if (OldPool != NULL) {\r
+    if (NewPool != NULL) {\r
+      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
+    }\r
+\r
+    FreePool (OldPool);\r
+  }\r
+\r
+  return NewPool;\r
+}\r
+\r
+/**\r
+  Compare two EFI_TIME data.\r
+\r
+\r
+  @param FirstTime       - A pointer to the first EFI_TIME data.\r
+  @param SecondTime      - A pointer to the second EFI_TIME data.\r
+\r
+  @retval  TRUE              The FirstTime is not later than the SecondTime.\r
+  @retval  FALSE             The FirstTime is later than the SecondTime.\r
+\r
+**/\r
+BOOLEAN\r
+TimeCompare (\r
+  IN EFI_TIME               *FirstTime,\r
+  IN EFI_TIME               *SecondTime\r
+  )\r
+{\r
+  if (FirstTime->Year != SecondTime->Year) {\r
+    return (BOOLEAN) (FirstTime->Year < SecondTime->Year);\r
+  } else if (FirstTime->Month != SecondTime->Month) {\r
+    return (BOOLEAN) (FirstTime->Month < SecondTime->Month);\r
+  } else if (FirstTime->Day != SecondTime->Day) {\r
+    return (BOOLEAN) (FirstTime->Day < SecondTime->Day);\r
+  } else if (FirstTime->Hour != SecondTime->Hour) {\r
+    return (BOOLEAN) (FirstTime->Hour < SecondTime->Hour);\r
+  } else if (FirstTime->Minute != SecondTime->Minute) {\r
+    return (BOOLEAN) (FirstTime->Minute < FirstTime->Minute);\r
+  } else if (FirstTime->Second != SecondTime->Second) {\r
+    return (BOOLEAN) (FirstTime->Second < SecondTime->Second);\r
+  }\r
+\r
+  return (BOOLEAN) (FirstTime->Nanosecond <= SecondTime->Nanosecond);\r
+}\r
+\r
+/**\r
+  Get a string from the Data Hub record based on \r
+  a device path.\r
+\r
+  @param DevPath         The device Path.\r
+\r
+  @return A string located from the Data Hub records based on\r
+          the device path.\r
+  @retval NULL  If failed to get the String from Data Hub.\r
+\r
+**/\r
+/*\r
+UINT16 *\r
+EfiLibStrFromDatahub (\r
+  IN EFI_DEVICE_PATH_PROTOCOL                 *DevPath\r
+  )\r
+{\r
+  return NULL;\r
+}*/\r
diff --git a/EfiLib/Console.c b/EfiLib/Console.c
new file mode 100644 (file)
index 0000000..b5cf03f
--- /dev/null
@@ -0,0 +1,99 @@
+/* $Id: Console.c $ */
+/** @file
+ * Console.c - VirtualBox Console control emulation
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "Platform.h"
+extern EFI_RUNTIME_SERVICES*  gRS;
+static EFI_CONSOLE_CONTROL_SCREEN_MODE CurrentMode = EfiConsoleControlScreenText;
+
+EFI_STATUS EFIAPI
+GetModeImpl(
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  OUT EFI_CONSOLE_CONTROL_SCREEN_MODE   *Mode,
+  OUT BOOLEAN                           *GopUgaExists,  OPTIONAL
+  OUT BOOLEAN                           *StdInLocked    OPTIONAL
+  )
+{
+  *Mode = CurrentMode; 
+  // EfiConsoleControlScreenText;
+  // EfiConsoleControlScreenGraphics;
+
+    if (GopUgaExists)
+        *GopUgaExists = TRUE;
+    if (StdInLocked)
+        *StdInLocked = FALSE;
+    return EFI_SUCCESS;
+}
+
+EFI_STATUS EFIAPI
+SetModeImpl(
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  IN  EFI_CONSOLE_CONTROL_SCREEN_MODE   Mode
+  )
+{
+  CurrentMode = Mode;
+    return EFI_SUCCESS;
+}
+
+EFI_STATUS EFIAPI
+LockStdInImpl(
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,
+  IN CHAR16                             *Password
+  )
+{
+    return EFI_SUCCESS;
+}
+
+
+EFI_CONSOLE_CONTROL_PROTOCOL gConsoleController =
+{
+    GetModeImpl,
+    SetModeImpl,
+    LockStdInImpl
+};
+
+EFI_GUID gEfiConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
+
+EFI_STATUS
+EFIAPI
+InitializeConsoleSim ()
+{
+  EFI_STATUS              Status;
+//  EG_PIXEL           BackgroundClear = {0, 0, 0, 0};
+//     CHAR16*                 bgc = L"BackgroundClear";
+//     UINTN                   dataSize = sizeof(BackgroundClear);
+  
+  
+  Status = gBS->InstallMultipleProtocolInterfaces (
+      &gImageHandle,
+      &gEfiConsoleControlProtocolGuid,
+      &gConsoleController,
+      NULL
+                                                   );
+  
+  // get background clear
+//     Status = gRS->GetVariable(bgc, &gEfiAppleNvramGuid, 0, &dataSize, &BackgroundClear);
+//     if(!EFI_ERROR(Status))
+//             return Status;
+  
+//     Status = gRS->SetVariable(bgc, &gEfiAppleBootGuid,
+//                            EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+//                            sizeof(BackgroundClear), &BackgroundClear);
+  
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
diff --git a/EfiLib/DevicePath.c b/EfiLib/DevicePath.c
new file mode 100644 (file)
index 0000000..75c666e
--- /dev/null
@@ -0,0 +1,1575 @@
+/** @file\r
+  BDS internal function define the default device path string, it can be\r
+  replaced by platform device path.\r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "Platform.h"\r
+\r
+/**\r
+  Concatenates a formatted unicode string to allocated pool.\r
+  The caller must free the resulting buffer.\r
+\r
+  @param  Str      Tracks the allocated pool, size in use, and amount of pool allocated.\r
+  @param  Fmt      The format string\r
+  @param  ...      The data will be printed.\r
+\r
+  @return Allocated buffer with the formatted string printed in it.\r
+          The caller must free the allocated buffer.\r
+          The buffer allocation is not packed.\r
+\r
+**/\r
+\r
+CHAR16 *\r
+EFIAPI\r
+CatPrint (\r
+  IN OUT POOL_PRINT   *Str,\r
+  IN CHAR16           *Fmt,\r
+  ...\r
+  )\r
+{\r
+  UINT16  *AppendStr;\r
+  VA_LIST Args;\r
+  UINTN   StringSize;\r
+\r
+  AppendStr = AllocateZeroPool (0x1000);\r
+  if (AppendStr == NULL) {\r
+    return Str->Str;\r
+  }\r
+\r
+  VA_START (Args, Fmt);\r
+  UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
+  VA_END (Args);\r
+  if (NULL == Str->Str) {\r
+        StringSize   = StrSize (AppendStr);\r
+    Str->Str  = AllocateZeroPool (StringSize);\r
+    ASSERT (Str->Str != NULL);\r
+  } else {\r
+        StringSize = StrSize (AppendStr);\r
+        StringSize += (StrSize (Str->Str) - sizeof (UINT16));\r
+\r
+    Str->Str = EfiReallocatePool (\r
+                                       Str->Str,                  \r
+                                   StrSize (Str->Str),\r
+                                       StringSize                \r
+                );\r
+    ASSERT (Str->Str != NULL);\r
+  }\r
+\r
+  Str->Maxlen = MAX_CHAR * sizeof (UINT16);\r
+  if (StringSize < Str->Maxlen) {\r
+    StrCat (Str->Str, AppendStr);\r
+    Str->Len = StringSize - sizeof (UINT16);\r
+  }\r
+\r
+  FreePool (AppendStr);\r
+  return Str->Str;\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathPci (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  PCI_DEVICE_PATH *Pci;\r
+\r
+  Pci = DevPath;\r
+  CatPrint (Str, L"Pci(%x|%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathPccard (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  PCCARD_DEVICE_PATH  *Pccard;\r
+\r
+  Pccard = DevPath;\r
+  CatPrint (Str, L"Pcmcia(Function%x)", (UINTN) Pccard->FunctionNumber);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathMemMap (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEMMAP_DEVICE_PATH  *MemMap;\r
+\r
+  MemMap = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"MemMap(%d:%lx-%lx)",\r
+    (UINTN) MemMap->MemoryType,\r
+    MemMap->StartingAddress,\r
+    MemMap->EndingAddress\r
+    );\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathController (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CONTROLLER_DEVICE_PATH  *Controller;\r
+\r
+  Controller = DevPath;\r
+  CatPrint (Str, L"Ctrl(%d)", (UINTN) Controller->ControllerNumber);\r
+}\r
+\r
+\r
+/**\r
+  Convert Vendor device path to device name.\r
+\r
+  @param  Str      The buffer store device name\r
+  @param  DevPath  Pointer to vendor device path\r
+\r
+**/\r
+VOID\r
+DevPathVendor (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+  CHAR16              *Type;\r
+  UINTN               DataLength;\r
+  UINTN               Index;\r
+//  UINT32              FlowControlMap;\r
+\r
+  UINT16              Info;\r
+\r
+  Vendor  = DevPath;\r
+\r
+  switch (DevicePathType (&Vendor->Header)) {\r
+  case HARDWARE_DEVICE_PATH:\r
+    Type = L"Hw";\r
+    break;\r
+\r
+  case MESSAGING_DEVICE_PATH:\r
+    Type = L"Msg";\r
+/*               \r
+    if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
+      CatPrint (Str, L"VenPcAnsi()");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
+      CatPrint (Str, L"VenVt100()");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
+      CatPrint (Str, L"VenVt100Plus()");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
+      CatPrint (Str, L"VenUft8()");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid     )) {\r
+      FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
+      switch (FlowControlMap & 0x00000003) {\r
+      case 0:\r
+        CatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
+        break;\r
+\r
+      case 1:\r
+        CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
+        break;\r
+\r
+      case 2:\r
+        CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
+        break;\r
+\r
+      default:\r
+        break;\r
+      }\r
+\r
+      return ;\r
+\r
+    } else\r
+ */\r
+    if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
+      CatPrint (\r
+        Str,\r
+        L"SAS(%lx,%lx,%x,",\r
+        ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
+        ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
+        (UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
+        );\r
+      Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
+      if ((Info & 0x0f) == 0) {\r
+        CatPrint (Str, L"NoTopology,0,0,0,");\r
+      } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {\r
+        CatPrint (\r
+          Str,\r
+          L"%s,%s,%s,",\r
+          ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",\r
+          ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal",\r
+          ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"\r
+          );\r
+        if ((Info & 0x0f) == 1) {\r
+          CatPrint (Str, L"0,");\r
+        } else {\r
+          CatPrint (Str, L"%x,", (UINTN) ((Info >> 8) & 0xff));\r
+        }\r
+      } else {\r
+        CatPrint (Str, L"0,0,0,0,");\r
+      }\r
+\r
+      CatPrint (Str, L"%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
+      return ;\r
+\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
+      CatPrint (Str, L"DebugPort()");\r
+      return ;\r
+    }\r
+    break;\r
+\r
+  case MEDIA_DEVICE_PATH:\r
+    Type = L"Media";\r
+    break;\r
+\r
+  default:\r
+    Type = L"?";\r
+    break;\r
+  }\r
+\r
+  CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);\r
+  DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);\r
+  if (DataLength > 0) {\r
+    CatPrint (Str, L",");\r
+    for (Index = 0; Index < DataLength; Index++) {\r
+      CatPrint (Str, L"%02x", (UINTN) ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
+    }\r
+  }\r
+  CatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathAcpi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ACPI_HID_DEVICE_PATH  *Acpi;\r
+\r
+  Acpi = DevPath;\r
+  if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+    CatPrint (Str, L"Acpi(PNP%04x,%x)", (UINTN)  EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID);\r
+  } else {\r
+    CatPrint (Str, L"Acpi(%08x,%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID);\r
+  }\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathExtendedAcpi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ACPI_EXTENDED_HID_DEVICE_PATH   *ExtendedAcpi;\r
+  \r
+  //\r
+  // Index for HID, UID and CID strings, 0 for non-exist\r
+  //\r
+  UINT16                          HIDSTRIdx;\r
+  UINT16                          UIDSTRIdx;\r
+  UINT16                          CIDSTRIdx;\r
+  UINT16                          Index;\r
+  UINT16                          Length;\r
+  UINT16                          Anchor;\r
+  CHAR8                           *AsChar8Array;\r
+\r
+  HIDSTRIdx    = 0;\r
+  UIDSTRIdx    = 0;\r
+  CIDSTRIdx    = 0;\r
+  ExtendedAcpi = DevPath;\r
+  Length       = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) ExtendedAcpi);\r
+\r
+  AsChar8Array = (CHAR8 *) ExtendedAcpi;\r
+\r
+  //\r
+  // find HIDSTR\r
+  //\r
+  Anchor = 16;\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
+    ;\r
+  }\r
+  if (Index > Anchor) {\r
+    HIDSTRIdx = Anchor;\r
+  }\r
+  //\r
+  // find UIDSTR\r
+  //\r
+  Anchor = (UINT16) (Index + 1);\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
+    ;\r
+  }\r
+  if (Index > Anchor) {\r
+    UIDSTRIdx = Anchor;\r
+  }\r
+  //\r
+  // find CIDSTR\r
+  //\r
+  Anchor = (UINT16) (Index + 1);\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
+    ;\r
+  }\r
+  if (Index > Anchor) {\r
+    CIDSTRIdx = Anchor;\r
+  }\r
+\r
+  if (HIDSTRIdx == 0 && CIDSTRIdx == 0 && ExtendedAcpi->UID == 0) {\r
+    CatPrint (Str, L"AcpiExp(");\r
+    if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+      CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID));\r
+    } else {\r
+      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);\r
+    }\r
+    if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+      CatPrint (Str, L"PNP%04x,", (UINTN)  EISA_ID_TO_NUM (ExtendedAcpi->CID));\r
+    } else {\r
+      CatPrint (Str, L"%08x,", (UINTN)  ExtendedAcpi->CID);\r
+    }\r
+    if (UIDSTRIdx != 0) {\r
+      CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);\r
+    } else {\r
+      CatPrint (Str, L"\"\")");\r
+    }\r
+  } else {\r
+    CatPrint (Str, L"AcpiEx(");\r
+    if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+      CatPrint (Str, L"PNP%04x,", (UINTN)  EISA_ID_TO_NUM (ExtendedAcpi->HID));\r
+    } else {\r
+      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);\r
+    }\r
+    if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+      CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID));\r
+    } else {\r
+      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID);\r
+    }\r
+    CatPrint (Str, L"%x,", (UINTN) ExtendedAcpi->UID);\r
+\r
+    if (HIDSTRIdx != 0) {\r
+      CatPrint (Str, L"%a,", AsChar8Array + HIDSTRIdx);\r
+    } else {\r
+      CatPrint (Str, L"\"\",");\r
+    }\r
+    if (CIDSTRIdx != 0) {\r
+      CatPrint (Str, L"%a,", AsChar8Array + CIDSTRIdx);\r
+    } else {\r
+      CatPrint (Str, L"\"\",");\r
+    }\r
+    if (UIDSTRIdx != 0) {\r
+      CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);\r
+    } else {\r
+      CatPrint (Str, L"\"\")");\r
+    }\r
+  }\r
+\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathAdrAcpi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ACPI_ADR_DEVICE_PATH    *AcpiAdr;\r
+  UINT16                  Index;\r
+  UINT16                  Length;\r
+  UINT16                  AdditionalAdrCount;\r
+\r
+  AcpiAdr            = DevPath;\r
+  Length             = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
+  AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
+\r
+  CatPrint (Str, L"AcpiAdr(%x", (UINTN) AcpiAdr->ADR);\r
+  for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
+    CatPrint (Str, L",%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
+  }\r
+  CatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathAtapi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ATAPI_DEVICE_PATH *Atapi;\r
+\r
+  Atapi = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Ata(%s,%s)",\r
+    (Atapi->PrimarySecondary != 0)? L"Secondary" : L"Primary",\r
+    (Atapi->SlaveMaster != 0)? L"Slave" : L"Master"\r
+    );\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathScsi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  SCSI_DEVICE_PATH  *Scsi;\r
+\r
+  Scsi = DevPath;\r
+  CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathFibre (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  FIBRECHANNEL_DEVICE_PATH  *Fibre;\r
+\r
+  Fibre = DevPath;\r
+  CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPath1394 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  F1394_DEVICE_PATH *F1394Path;\r
+\r
+  F1394Path = DevPath;\r
+  CatPrint (Str, L"1394(%lx)", &F1394Path->Guid);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathUsb (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  USB_DEVICE_PATH *Usb;\r
+\r
+  Usb = DevPath;\r
+  CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathUsbWWID (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  USB_WWID_DEVICE_PATH  *UsbWWId;\r
+\r
+  UsbWWId = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"UsbWwid(%x,%x,%x,\"WWID\")",\r
+    (UINTN) UsbWWId->VendorId,\r
+    (UINTN) UsbWWId->ProductId,\r
+    (UINTN) UsbWWId->InterfaceNumber\r
+    );\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathLogicalUnit (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
+\r
+  LogicalUnit = DevPath;\r
+  CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathUsbClass (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  USB_CLASS_DEVICE_PATH *UsbClass;\r
+\r
+  UsbClass = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Usb Class(%x,%x,%x,%x,%x)",\r
+    (UINTN) UsbClass->VendorId,\r
+    (UINTN) UsbClass->ProductId,\r
+    (UINTN) UsbClass->DeviceClass,\r
+    (UINTN) UsbClass->DeviceSubClass,\r
+    (UINTN) UsbClass->DeviceProtocol\r
+    );\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathSata (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  SATA_DEVICE_PATH *Sata;\r
+\r
+  Sata = DevPath;\r
+  if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) {\r
+    CatPrint (\r
+      Str,\r
+      L"Sata(%x,%x)",\r
+      (UINTN) Sata->HBAPortNumber,\r
+      (UINTN) Sata->Lun\r
+      );\r
+  } else {\r
+    CatPrint (\r
+      Str,\r
+      L"Sata(%x,%x,%x)",\r
+      (UINTN) Sata->HBAPortNumber,\r
+      (UINTN) Sata->PortMultiplierPortNumber,\r
+      (UINTN) Sata->Lun\r
+      );\r
+  }\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathI2O (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  I2O_DEVICE_PATH *I2OPath;\r
+\r
+  I2OPath = DevPath;\r
+  CatPrint (Str, L"I2O(%x)", (UINTN) I2OPath->Tid);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathMacAddr (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MAC_ADDR_DEVICE_PATH  *MACDevPath;\r
+  UINTN                 HwAddressSize;\r
+  UINTN                 Index;\r
+\r
+  MACDevPath           = DevPath;\r
+\r
+  HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
+  if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {\r
+    HwAddressSize = 6;\r
+  }\r
+\r
+  CatPrint (Str, L"Mac(");\r
+\r
+  for (Index = 0; Index < HwAddressSize; Index++) {\r
+    CatPrint (Str, L"%02x", (UINTN) MACDevPath->MacAddress.Addr[Index]);\r
+  }\r
+\r
+  CatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathIPv4 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  IPv4_DEVICE_PATH  *IPDevPath;\r
+\r
+  IPDevPath = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"IPv4(%d.%d.%d.%d:%d)",\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
+    (UINTN) IPDevPath->RemotePort\r
+    );\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathIPv6 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  IPv6_DEVICE_PATH  *IPv6DevPath;\r
+\r
+  IPv6DevPath = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[0],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[1],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[2],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[3],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[4],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[5],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[6],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[7],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[8],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[9],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[10],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[11],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[12],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[13],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[14],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[15]\r
+    );\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathInfiniBand (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  INFINIBAND_DEVICE_PATH  *InfiniBand;\r
+\r
+  InfiniBand = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Infiniband(%x,%g,%lx,%lx,%lx)",\r
+    (UINTN) InfiniBand->ResourceFlags,\r
+    InfiniBand->PortGid,\r
+    InfiniBand->ServiceId,\r
+    InfiniBand->TargetPortId,\r
+    InfiniBand->DeviceId\r
+    );\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathUart (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  UART_DEVICE_PATH  *Uart;\r
+  CHAR8             Parity;\r
+\r
+  Uart = DevPath;\r
+  switch (Uart->Parity) {\r
+  case 0:\r
+    Parity = 'D';\r
+    break;\r
+\r
+  case 1:\r
+    Parity = 'N';\r
+    break;\r
+\r
+  case 2:\r
+    Parity = 'E';\r
+    break;\r
+\r
+  case 3:\r
+    Parity = 'O';\r
+    break;\r
+\r
+  case 4:\r
+    Parity = 'M';\r
+    break;\r
+\r
+  case 5:\r
+    Parity = 'S';\r
+    break;\r
+\r
+  default:\r
+    Parity = 'x';\r
+    break;\r
+  }\r
+\r
+  if (Uart->BaudRate == 0) {\r
+    CatPrint (Str, L"Uart(DEFAULT,%c,", Parity);\r
+  } else {\r
+    CatPrint (Str, L"Uart(%ld,%c,", Uart->BaudRate, Parity);\r
+  }\r
+\r
+  if (Uart->DataBits == 0) {\r
+    CatPrint (Str, L"D,");\r
+  } else {\r
+    CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);\r
+  }\r
+\r
+  switch (Uart->StopBits) {\r
+  case 0:\r
+    CatPrint (Str, L"D)");\r
+    break;\r
+\r
+  case 1:\r
+    CatPrint (Str, L"1)");\r
+    break;\r
+\r
+  case 2:\r
+    CatPrint (Str, L"1.5)");\r
+    break;\r
+\r
+  case 3:\r
+    CatPrint (Str, L"2)");\r
+    break;\r
+\r
+  default:\r
+    CatPrint (Str, L"x)");\r
+    break;\r
+  }\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathiSCSI (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ISCSI_DEVICE_PATH_WITH_NAME *IScsi;\r
+  UINT16                      Options;\r
+\r
+  IScsi = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"iSCSI(%a,%x,%lx,",\r
+    IScsi->TargetName,\r
+    (UINTN) IScsi->TargetPortalGroupTag,\r
+    IScsi->Lun\r
+    );\r
+\r
+  Options = IScsi->LoginOption;\r
+  CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+  CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+  if (((Options >> 11) & 0x0001) != 0) {\r
+    CatPrint (Str, L"%s,", L"None");\r
+  } else if (((Options >> 12) & 0x0001) != 0) {\r
+    CatPrint (Str, L"%s,", L"CHAP_UNI");\r
+  } else {\r
+    CatPrint (Str, L"%s,", L"CHAP_BI");\r
+\r
+  }\r
+\r
+  CatPrint (Str, L"%s)", (IScsi->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathVlan (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  VLAN_DEVICE_PATH  *Vlan;\r
+\r
+  Vlan = DevPath;\r
+  CatPrint (Str, L"Vlan(%d)", (UINTN) Vlan->VlanId);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathHardDrive (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  HARDDRIVE_DEVICE_PATH *Hd;\r
+\r
+  Hd = DevPath;\r
+  switch (Hd->SignatureType) {\r
+  case SIGNATURE_TYPE_MBR:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,Sig%08x)",\r
+      (UINTN) Hd->PartitionNumber,\r
+      (UINTN) *((UINT32 *) (&(Hd->Signature[0])))\r
+      );\r
+    break;\r
+\r
+  case SIGNATURE_TYPE_GUID:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,Sig%g)",\r
+      (UINTN) Hd->PartitionNumber,\r
+      (EFI_GUID *) &(Hd->Signature[0])\r
+      );\r
+    break;\r
+\r
+  default:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,MBRType=%02x,SigType=%02x)",\r
+      (UINTN) Hd->PartitionNumber,\r
+      (UINTN) Hd->MBRType,\r
+      (UINTN) Hd->SignatureType\r
+      );\r
+    break;\r
+  }\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathCDROM (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CDROM_DEVICE_PATH *Cd;\r
+\r
+  Cd = DevPath;\r
+  CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathFilePath (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  FILEPATH_DEVICE_PATH  *Fp;\r
+\r
+  Fp = DevPath;\r
+  CatPrint (Str, L"%s", Fp->PathName);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathMediaProtocol (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEDIA_PROTOCOL_DEVICE_PATH  *MediaProt;\r
+\r
+  MediaProt = DevPath;\r
+  CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathFvFilePath (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;\r
+\r
+  FvFilePath = DevPath;\r
+  CatPrint (Str, L"%g", &FvFilePath->FvFileName);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathRelativeOffsetRange (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
+\r
+  Offset = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Offset(%lx,%lx)",\r
+    Offset->StartingOffset,\r
+    Offset->EndingOffset\r
+    );\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathBssBss (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  BBS_BBS_DEVICE_PATH *Bbs;\r
+  CHAR16              *Type;\r
+\r
+  Bbs = DevPath;\r
+  switch (Bbs->DeviceType) {\r
+  case BBS_TYPE_FLOPPY:\r
+    Type = L"Floppy";\r
+    break;\r
+\r
+  case BBS_TYPE_HARDDRIVE:\r
+    Type = L"Harddrive";\r
+    break;\r
+\r
+  case BBS_TYPE_CDROM:\r
+    Type = L"CDROM";\r
+    break;\r
+\r
+  case BBS_TYPE_PCMCIA:\r
+    Type = L"PCMCIA";\r
+    break;\r
+\r
+  case BBS_TYPE_USB:\r
+    Type = L"Usb";\r
+    break;\r
+\r
+  case BBS_TYPE_EMBEDDED_NETWORK:\r
+    Type = L"Net";\r
+    break;\r
+\r
+  case BBS_TYPE_BEV:\r
+    Type = L"BEV";\r
+    break;\r
+\r
+  default:\r
+    Type = L"?";\r
+    break;\r
+  }\r
+  CatPrint (Str, L"Legacy-%s", Type);\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathEndInstance (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CatPrint (Str, L",");\r
+}\r
+\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathNodeUnknown (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CatPrint (Str, L"?");\r
+}\r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maximum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
+VOID\r
+DevPathFvPath (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEDIA_FW_VOL_DEVICE_PATH *FvPath;\r
+\r
+  FvPath = DevPath;\r
+  CatPrint (Str, L"Fv(%g)", &FvPath->FvName);\r
+}\r
+\r
+DEVICE_PATH_STRING_TABLE  DevPathTable[] = {\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_PCI_DP,\r
+    DevPathPci\r
+  },\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_PCCARD_DP,\r
+    DevPathPccard\r
+  },\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_MEMMAP_DP,\r
+    DevPathMemMap\r
+  },\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    DevPathVendor\r
+  },\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_CONTROLLER_DP,\r
+    DevPathController\r
+  },\r
+  {\r
+    ACPI_DEVICE_PATH,\r
+    ACPI_DP,\r
+    DevPathAcpi\r
+  },\r
+  {\r
+    ACPI_DEVICE_PATH,\r
+    ACPI_EXTENDED_DP,\r
+    DevPathExtendedAcpi\r
+  },\r
+  {\r
+    ACPI_DEVICE_PATH,\r
+    ACPI_ADR_DP,\r
+    DevPathAdrAcpi\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_ATAPI_DP,\r
+    DevPathAtapi\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_SCSI_DP,\r
+    DevPathScsi\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_FIBRECHANNEL_DP,\r
+    DevPathFibre\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_1394_DP,\r
+    DevPath1394\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_USB_DP,\r
+    DevPathUsb\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_USB_WWID_DP,\r
+    DevPathUsbWWID\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_DEVICE_LOGICAL_UNIT_DP,\r
+    DevPathLogicalUnit\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_USB_CLASS_DP,\r
+    DevPathUsbClass\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_SATA_DP,\r
+    DevPathSata\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_I2O_DP,\r
+    DevPathI2O\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_MAC_ADDR_DP,\r
+    DevPathMacAddr\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_IPv4_DP,\r
+    DevPathIPv4\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_IPv6_DP,\r
+    DevPathIPv6\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_INFINIBAND_DP,\r
+    DevPathInfiniBand\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_UART_DP,\r
+    DevPathUart\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_VENDOR_DP,\r
+    DevPathVendor\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_ISCSI_DP,\r
+    DevPathiSCSI\r
+  },\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_VLAN_DP,\r
+    DevPathVlan\r
+  },\r
+  {\r
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_HARDDRIVE_DP,\r
+    DevPathHardDrive\r
+  },\r
+  {\r
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_CDROM_DP,\r
+    DevPathCDROM\r
+  },\r
+  {\r
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_VENDOR_DP,\r
+    DevPathVendor\r
+  },\r
+  {\r
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_FILEPATH_DP,\r
+    DevPathFilePath\r
+  },\r
+  {\r
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_PROTOCOL_DP,\r
+    DevPathMediaProtocol\r
+  },\r
+  {\r
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_PIWG_FW_VOL_DP,\r
+    DevPathFvPath,\r
+  },\r
+  {\r
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_PIWG_FW_FILE_DP,\r
+    DevPathFvFilePath\r
+  },\r
+  {\r
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_RELATIVE_OFFSET_RANGE_DP,\r
+    DevPathRelativeOffsetRange,\r
+  },\r
+  {\r
+    BBS_DEVICE_PATH,\r
+    BBS_BBS_DP,\r
+    DevPathBssBss\r
+  },\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+    END_INSTANCE_DEVICE_PATH_SUBTYPE,\r
+    DevPathEndInstance\r
+  },\r
+  {\r
+    0,\r
+    0,\r
+    NULL\r
+  }\r
+};\r
+\r
+\r
+/**\r
+  This function converts an input device structure to a Unicode string.\r
+\r
+  @param DevPath                  A pointer to the device path structure.\r
+\r
+  @return A new allocated Unicode string that represents the device path.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+DevicePathToStr (\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
+  )\r
+{\r
+  POOL_PRINT                Str;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;\r
+  VOID (*DumpNode) (POOL_PRINT *, VOID *);\r
+\r
+  UINTN Index;\r
+  UINTN NewSize;\r
+\r
+  EFI_STATUS                       Status;\r
+  CHAR16                           *ToText;\r
+  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;\r
+\r
+  ZeroMem (&Str, sizeof (Str));\r
+\r
+  if (DevPath == NULL) {\r
+    goto Done;\r
+  }\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiDevicePathToTextProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) &DevPathToText\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    ToText = DevPathToText->ConvertDevicePathToText (\r
+                              DevPath,\r
+                              FALSE,\r
+                              TRUE\r
+                              );\r
+    ASSERT (ToText != NULL);\r
+    return ToText;\r
+  }\r
+\r
+  //\r
+  // Process each device path node\r
+  //\r
+  DevPathNode = DevPath;\r
+  while (!IsDevicePathEnd (DevPathNode)) {\r
+    //\r
+    // Find the handler to dump this device path node\r
+    //\r
+    DumpNode = NULL;\r
+    for (Index = 0; DevPathTable[Index].Function != NULL; Index += 1) {\r
+\r
+      if (DevicePathType (DevPathNode) == DevPathTable[Index].Type &&\r
+          DevicePathSubType (DevPathNode) == DevPathTable[Index].SubType\r
+          ) {\r
+        DumpNode = DevPathTable[Index].Function;\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // If not found, use a generic function\r
+    //\r
+    if (!DumpNode) {\r
+      DumpNode = DevPathNodeUnknown;\r
+    }\r
+    //\r
+    //  Put a path seperator in if needed\r
+    //\r
+    if ((Str.Len != 0) && (DumpNode != DevPathEndInstance)) {\r
+      CatPrint (&Str, L"/");\r
+    }\r
+    //\r
+    // Print this node of the device path\r
+    //\r
+    DumpNode (&Str, DevPathNode);\r
+\r
+    //\r
+    // Next device path node\r
+    //\r
+    DevPathNode = NextDevicePathNode (DevPathNode);\r
+  }\r
+\r
+Done:\r
+  NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
+  Str.Str = EfiReallocatePool (Str.Str, NewSize, NewSize);\r
+  ASSERT (Str.Str != NULL);\r
+  Str.Str[Str.Len] = 0;\r
+  return Str.Str;\r
+}\r
diff --git a/EfiLib/GenericBdsLib.h b/EfiLib/GenericBdsLib.h
new file mode 100644 (file)
index 0000000..e0e6af5
--- /dev/null
@@ -0,0 +1,1093 @@
+/** @file\r
+  Generic BDS library defines general interfaces for a BDS driver, including:\r
+    1) BDS boot policy interface.\r
+    2) BDS boot device connect interface.\r
+    3) BDS Misc interfaces for mainting boot variable, ouput string.\r
+\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution.  \r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.                                          \r
+    \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _GENERIC_BDS_LIB_H_\r
+#define _GENERIC_BDS_LIB_H_\r
+\r
+#include <Protocol/UserManager.h>\r
+\r
+///\r
+/// Constants which are variable names used to access variables.\r
+///\r
+#define VAR_LEGACY_DEV_ORDER L"LegacyDevOrder"\r
+\r
+///\r
+/// Data structures and defines.\r
+///\r
+#define FRONT_PAGE_QUESTION_ID  0x0000\r
+#define FRONT_PAGE_DATA_WIDTH   0x01\r
+\r
+///\r
+/// ConnectType\r
+///\r
+#define CONSOLE_OUT 0x00000001\r
+#define STD_ERROR   0x00000002\r
+#define CONSOLE_IN  0x00000004\r
+#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
+\r
+///\r
+/// Load Option Attributes\r
+///\r
+#define LOAD_OPTION_ACTIVE              0x00000001\r
+#define LOAD_OPTION_FORCE_RECONNECT     0x00000002\r
+\r
+#define LOAD_OPTION_HIDDEN              0x00000008\r
+#define LOAD_OPTION_CATEGORY            0x00001F00\r
+\r
+#define LOAD_OPTION_CATEGORY_BOOT       0x00000000\r
+#define LOAD_OPTION_CATEGORY_APP        0x00000100\r
+\r
+#define EFI_BOOT_OPTION_SUPPORT_KEY     0x00000001\r
+#define EFI_BOOT_OPTION_SUPPORT_APP     0x00000002\r
+\r
+#define IS_LOAD_OPTION_TYPE(_c, _Mask)  (BOOLEAN) (((_c) & (_Mask)) != 0)\r
+\r
+///\r
+/// Define the maximum characters that will be accepted.\r
+///\r
+#define MAX_CHAR            480\r
+#define MAX_CHAR_SIZE       (MAX_CHAR * 2)\r
+\r
+///\r
+/// Define maximum characters for boot option variable "BootXXXX".\r
+///\r
+#define BOOT_OPTION_MAX_CHAR 10\r
+\r
+//\r
+// This data structure is the part of BDS_CONNECT_ENTRY\r
+//\r
+#define BDS_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'C', 'O')\r
+\r
+typedef struct {\r
+\r
+  UINTN                     Signature;\r
+  LIST_ENTRY                Link;\r
+\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  CHAR16                    *OptionName;\r
+  UINTN                     OptionNumber;\r
+  UINT16                    BootCurrent;\r
+  UINT32                    Attribute;\r
+  CHAR16                    *Description;\r
+  VOID                      *LoadOptions;\r
+  UINT32                    LoadOptionsSize;\r
+  CHAR16                    *StatusString;\r
+\r
+} BDS_COMMON_OPTION;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINTN                     ConnectType;\r
+} BDS_CONSOLE_CONNECT_ENTRY;\r
+\r
+//\r
+// Bds boot related lib functions\r
+//\r
+/**\r
+  Boot from the UEFI spec defined "BootNext" variable.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibBootNext (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Process the boot option according to the UEFI specification. The legacy boot option device path includes BBS_DEVICE_PATH.\r
+\r
+  @param  Option                 The boot option to be processed.\r
+  @param  DevicePath             The device path describing where to load the\r
+                                 boot image or the legcy BBS device path to boot\r
+                                 the legacy OS.\r
+  @param  ExitDataSize           The size of exit data.\r
+  @param  ExitData               Data returned when Boot image failed.\r
+\r
+  @retval EFI_SUCCESS            Boot from the input boot option succeeded.\r
+  @retval EFI_NOT_FOUND          The Device Path is not found in the system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibBootViaBootOption (\r
+  IN  BDS_COMMON_OPTION             * Option,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      * DevicePath,\r
+  OUT UINTN                         *ExitDataSize,\r
+  OUT CHAR16                        **ExitData OPTIONAL\r
+  );\r
+\r
+\r
+/**\r
+  This function will enumerate all possible boot devices in the system, and\r
+  automatically create boot options for Network, Shell, Removable BlockIo, \r
+  and Non-BlockIo Simplefile devices. \r
+  \r
+  BDS separates EFI boot options into six types:\r
+  1. Network - The boot option points to the SimpleNetworkProtocol device. \r
+               Bds will try to automatically create this type of boot option during enumeration.\r
+  2. Shell   - The boot option points to internal flash shell. \r
+               Bds will try to automatically create this type of boot option during enumeration.\r
+  3. Removable BlockIo      - The boot option points to a removable media\r
+                              device, such as a USB flash drive or DVD drive.\r
+                              These devices should contain a *removable* blockIo\r
+                              protocol in their device handle.\r
+                              Bds will try to automatically create this type boot option \r
+                              when enumerate.\r
+  4. Fixed BlockIo          - The boot option points to a Fixed blockIo device, \r
+                              such as a hard disk.\r
+                              These devices should contain a *fixed* blockIo\r
+                              protocol in their device handle.\r
+                              BDS will skip fixed blockIo devices, and not\r
+                              automatically create boot option for them. But BDS \r
+                              will help to delete those fixed blockIo boot options, \r
+                              whose description rules conflict with other auto-created\r
+                              boot options.\r
+  5. Non-BlockIo Simplefile - The boot option points to a device whose handle \r
+                              has SimpleFileSystem Protocol, but has no blockio\r
+                              protocol. These devices do not offer blockIo\r
+                              protocol, but BDS still can get the \r
+                              \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem\r
+                              Protocol.\r
+  6. File    - The boot option points to a file. These boot options are usually \r
+               created by the user, either manually or with an OS loader. BDS will not delete or modify\r
+               these boot options.        \r
+    \r
+  This function will enumerate all possible boot devices in the system, and\r
+  automatically create boot options for Network, Shell, Removable BlockIo, \r
+  and Non-BlockIo Simplefile devices.\r
+  It will excute once every boot.\r
+  \r
+  @param  BdsBootOptionList      The header of the linked list that indexed all\r
+                                 current boot options.\r
+\r
+  @retval EFI_SUCCESS            Finished all the boot device enumerations and \r
+                                 created the boot option based on the boot device.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to enumerate the boot device and create \r
+                                 the boot option list.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibEnumerateAllBootOption (\r
+  IN OUT LIST_ENTRY          *BdsBootOptionList\r
+  );\r
+\r
+/**\r
+  Build the boot option with the handle parsed in.\r
+\r
+  @param  Handle                 The handle representing the device path for which \r
+                                 to create a boot option.\r
+  @param  BdsBootOptionList      The header of the link list that indexed all\r
+                                 current boot options.\r
+  @param  String                 The description of the boot option.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibBuildOptionFromHandle (\r
+  IN  EFI_HANDLE                 Handle,\r
+  IN  LIST_ENTRY                 *BdsBootOptionList,\r
+  IN  CHAR16                     *String\r
+  );\r
+\r
+\r
+/**\r
+  Build the on flash shell boot option with the handle parsed in.\r
+\r
+  @param  Handle                 The handle which present the device path to create\r
+                                 the on flash shell boot option.\r
+  @param  BdsBootOptionList      The header of the link list that indexed all\r
+                                 current boot options.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibBuildOptionFromShell (\r
+  IN EFI_HANDLE                  Handle,\r
+  IN OUT LIST_ENTRY              *BdsBootOptionList\r
+  );\r
+\r
+//\r
+// Bds misc lib functions\r
+//\r
+/**\r
+  Get boot mode by looking up the configuration table and parsing the HOB list.\r
+\r
+  @param  BootMode              The boot mode from PEI handoff HOB.\r
+\r
+  @retval EFI_SUCCESS           Successfully got boot mode.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibGetBootMode (\r
+  OUT EFI_BOOT_MODE       *BootMode\r
+  );\r
+\r
+\r
+/**\r
+  The function will go through the driver option link list, and then load and start\r
+  every driver to which the driver option device path points.\r
+\r
+  @param  BdsDriverLists        The header of the current driver option link list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibLoadDrivers (\r
+  IN LIST_ENTRY                   *BdsDriverLists\r
+  );\r
+\r
+\r
+/**\r
+  This function processes BootOrder or DriverOrder variables, by calling\r
+\r
+  BdsLibVariableToOption () for each UINT16 in the variables.\r
+\r
+  @param  BdsCommonOptionList   The header of the option list base on the variable\r
+                                VariableName.\r
+  @param  VariableName          An EFI Variable name indicate the BootOrder or\r
+                                DriverOrder.\r
+\r
+  @retval EFI_SUCCESS           Successfully created the boot option or driver option\r
+                                list.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to get the boot option or the driver option list.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibBuildOptionFromVar (\r
+  IN  LIST_ENTRY                      *BdsCommonOptionList,\r
+  IN  CHAR16                          *VariableName\r
+  );\r
+\r
+/**\r
+  This function reads the EFI variable (VendorGuid/Name) and returns a dynamically allocated\r
+  buffer and the size of the buffer. If it fails, return NULL.\r
+\r
+  @param  Name                  The string part of the  EFI variable name.\r
+  @param  VendorGuid            The GUID part of the EFI variable name.\r
+  @param  VariableSize          Returns the size of the EFI variable that was read.\r
+\r
+  @return                       Dynamically allocated memory that contains a copy \r
+                                of the EFI variable. The caller is responsible for \r
+                                freeing the buffer.\r
+  @retval NULL                  The variable was not read.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+BdsLibGetVariableAndSize (\r
+  IN  CHAR16              *Name,\r
+  IN  EFI_GUID            *VendorGuid,\r
+  OUT UINTN               *VariableSize\r
+  );\r
+\r
+\r
+/**\r
+  This function prints a series of strings.\r
+\r
+  @param  ConOut                A pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.\r
+  @param  ...                   A variable argument list containing a series of\r
+                                strings, the last string must be NULL.\r
+\r
+  @retval EFI_SUCCESS           Successfully printed out the string using ConOut.\r
+  @retval EFI_STATUS            Return the status of the ConOut->OutputString ().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibOutputStrings (\r
+  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *ConOut,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Build the boot#### or driver#### option from the VariableName. The\r
+  build boot#### or driver#### will also be linked to BdsCommonOptionList.\r
+\r
+  @param  BdsCommonOptionList   The header of the boot#### or driver#### option\r
+                                link list.\r
+  @param  VariableName          EFI Variable name, indicates if it is boot#### or\r
+                                driver####.\r
+\r
+  @retval BDS_COMMON_OPTION     The option that was created.\r
+  @retval NULL                  Failed to get the new option.\r
+\r
+**/\r
+BDS_COMMON_OPTION *\r
+EFIAPI\r
+BdsLibVariableToOption (\r
+  IN OUT LIST_ENTRY                   *BdsCommonOptionList,\r
+  IN  CHAR16                          *VariableName\r
+  );\r
+\r
+/**\r
+  This function registers the new boot#### or driver#### option based on\r
+  the VariableName. The new registered boot#### or driver#### will be linked\r
+  to BdsOptionList and also update to the VariableName. After the boot#### or\r
+  driver#### updated, the BootOrder or DriverOrder will also be updated.\r
+\r
+  @param  BdsOptionList         The header of the boot#### or driver#### link list.\r
+  @param  DevicePath            The device path that the boot#### or driver####\r
+                                option present.\r
+  @param  String                The description of the boot#### or driver####.\r
+  @param  VariableName          Indicate if the boot#### or driver#### option.\r
+\r
+  @retval EFI_SUCCESS           The boot#### or driver#### have been successfully\r
+                                registered.\r
+  @retval EFI_STATUS            Return the status of gRS->SetVariable ().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibRegisterNewOption (\r
+  IN  LIST_ENTRY                     *BdsOptionList,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL       *DevicePath,\r
+  IN  CHAR16                         *String,\r
+  IN  CHAR16                         *VariableName\r
+  );\r
+\r
+//\r
+// Bds connect and disconnect driver lib funcions\r
+//\r
+/**\r
+  This function connects all system drivers with the corresponding controllers. \r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibConnectAllDriversToAllControllers (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function connects all system drivers to controllers.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibConnectAll (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function creates all handles associated with the given device\r
+  path node. If the handle associated with one device path node cannot\r
+  be created, then it tries to execute the dispatch to load the missing drivers.  \r
+\r
+  @param  DevicePathToConnect   The device path to be connected. Can be\r
+                                a multi-instance device path.\r
+\r
+  @retval EFI_SUCCESS           All handles associates with every device path node\r
+                                were created.\r
+  @retval EFI_OUT_OF_RESOURCES  Not enough resources to create new handles.\r
+  @retval EFI_NOT_FOUND         At least one handle could not be created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
+  );\r
+\r
+/**\r
+  This function will connect all current system handles recursively.     \r
+  gBS->ConnectController() service is invoked for each handle exist in system handler buffer.  \r
+  If the handle is bus type handler, all childrens also will be connected recursively  by gBS->ConnectController().\r
+  \r
+  @retval EFI_SUCCESS           All handles and child handles have been\r
+                                connected.  \r
+  @retval EFI_STATUS            Return the status of gBS->LocateHandleBuffer().\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectAllEfi (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function will disconnect all current system handles.     \r
+  gBS->DisconnectController() is invoked for each handle exists in system handle buffer.  \r
+  If handle is a bus type handle, all childrens also are disconnected recursively by  gBS->DisconnectController().\r
+  \r
+  @retval EFI_SUCCESS           All handles have been disconnected.\r
+  @retval EFI_STATUS            Error status returned by of gBS->LocateHandleBuffer().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibDisconnectAllEfi (\r
+  VOID\r
+  );\r
+\r
+//\r
+// Bds console related lib functions\r
+//\r
+/**\r
+  This function will search every simpletxt device in the current system,\r
+  and make every simpletxt device a potential console device.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibConnectAllConsoles (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  This function will connect console device based on the console\r
+  device variable ConIn, ConOut and ErrOut.\r
+\r
+  @retval EFI_SUCCESS              At least one of the ConIn and ConOut devices have\r
+                                   been connected.\r
+  @retval EFI_STATUS               Return the status of BdsLibConnectConsoleVariable ().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectAllDefaultConsoles (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function updates the console variable based on ConVarName. It can\r
+  add or remove one specific console device path from the variable\r
+\r
+  @param  ConVarName               The console-related variable name: ConIn, ConOut,\r
+                                   ErrOut.\r
+  @param  CustomizedConDevicePath  The console device path to be added to\r
+                                   the console variable ConVarName. Cannot be multi-instance.\r
+  @param  ExclusiveDevicePath      The console device path to be removed\r
+                                   from the console variable ConVarName. Cannot be multi-instance.\r
+\r
+  @retval EFI_UNSUPPORTED          The added device path is the same as a removed one.\r
+  @retval EFI_SUCCESS              Successfully added or removed the device path from the\r
+                                   console variable.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibUpdateConsoleVariable (\r
+  IN  CHAR16                    *ConVarName,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *CustomizedConDevicePath,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *ExclusiveDevicePath\r
+  );\r
+\r
+/**\r
+  Connect the console device base on the variable ConVarName. If\r
+  ConVarName is a multi-instance device path, and at least one\r
+  instance connects successfully, then this function\r
+  will return success.\r
+\r
+  @param  ConVarName               The console related variable name: ConIn, ConOut,\r
+                                   ErrOut.\r
+\r
+  @retval EFI_NOT_FOUND            No console devices were connected successfully\r
+  @retval EFI_SUCCESS              Connected at least one instance of the console\r
+                                   device path based on the variable ConVarName.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectConsoleVariable (\r
+  IN  CHAR16                 *ConVarName\r
+  );\r
+\r
+//\r
+// Bds device path related lib functions\r
+//\r
+/**\r
+  Delete the instance in Multi that overlaps with Single. \r
+\r
+  @param  Multi                 A pointer to a multi-instance device path data\r
+                                structure.\r
+  @param  Single                A pointer to a single-instance device path data\r
+                                structure.\r
+\r
+  @return This function removes the device path instances in Multi that overlap\r
+          Single, and returns the resulting device path. If there is no\r
+          remaining device path as a result, this function will return NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+BdsLibDelPartMatchInstance (\r
+  IN     EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
+  IN     EFI_DEVICE_PATH_PROTOCOL  *Single\r
+  );\r
+\r
+/**\r
+  This function compares a device path data structure to that of all the nodes of a\r
+  second device path instance.\r
+\r
+  @param  Multi                 A pointer to a multi-instance device path data\r
+                                structure.\r
+  @param  Single                A pointer to a single-instance device path data\r
+                                structure.\r
+\r
+  @retval TRUE                  If the Single device path is contained within a \r
+                                Multi device path.\r
+  @retval FALSE                 The Single device path is not contained within a \r
+                                Multi device path.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+BdsLibMatchDevicePaths (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *Single\r
+  );\r
+\r
+/**\r
+  This function converts an input device structure to a Unicode string.\r
+\r
+  @param DevPath                  A pointer to the device path structure.\r
+\r
+  @return A newly allocated Unicode string that represents the device path.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+DevicePathToStr (\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
+  );\r
+\r
+//\r
+// Internal definitions\r
+//\r
+typedef struct {\r
+  CHAR16  *Str;\r
+  UINTN   Len;\r
+  UINTN   Maxlen;\r
+} POOL_PRINT;\r
+\r
+typedef\r
+VOID\r
+(*DEV_PATH_FUNCTION) (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  );\r
+\r
+typedef struct {\r
+  UINT8             Type;\r
+  UINT8             SubType;\r
+  DEV_PATH_FUNCTION Function;\r
+} DEVICE_PATH_STRING_TABLE;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  Guid;\r
+  UINT8                     VendorDefinedData[1];\r
+} VENDOR_DEVICE_PATH_WITH_DATA;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  UINT16                    NetworkProtocol;\r
+  UINT16                    LoginOption;\r
+  UINT64                    Lun;\r
+  UINT16                    TargetPortalGroupTag;\r
+  CHAR16                    TargetName[1];\r
+} ISCSI_DEVICE_PATH_WITH_NAME;\r
+\r
+//\r
+// BBS support macros and functions\r
+//\r
+\r
+#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)\r
+#define REFRESH_LEGACY_BOOT_OPTIONS \\r
+        BdsDeleteAllInvalidLegacyBootOptions ();\\r
+        BdsAddNonExistingLegacyBootOptions (); \\r
+        BdsUpdateLegacyDevOrder ()\r
+#else\r
+#define REFRESH_LEGACY_BOOT_OPTIONS\r
+#endif\r
+\r
+/**\r
+  Delete all the invalid legacy boot options.\r
+\r
+  @retval EFI_SUCCESS             All invalid legacy boot options are deleted.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate necessary memory.\r
+  @retval EFI_NOT_FOUND           Failed to retrieve variable of boot order.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsDeleteAllInvalidLegacyBootOptions (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Add the legacy boot options from BBS table if they do not exist.\r
+\r
+  @retval EFI_SUCCESS          The boot options were added successfully, \r
+                               or they are already in boot options.\r
+  @retval EFI_NOT_FOUND        No legacy boot options is found.\r
+  @retval EFI_OUT_OF_RESOURCE  No enough memory.\r
+  @return Other value          LegacyBoot options are not added.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsAddNonExistingLegacyBootOptions (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Add the legacy boot devices from BBS table into \r
+  the legacy device boot order.\r
+\r
+  @retval EFI_SUCCESS           The boot devices were added successfully.\r
+  @retval EFI_NOT_FOUND         The legacy boot devices are not found.\r
+  @retval EFI_OUT_OF_RESOURCES  Memory or storage is not enough.\r
+  @retval EFI_DEVICE_ERROR      Failed to add the legacy device boot order into EFI variable\r
+                                because of a hardware error.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsUpdateLegacyDevOrder (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Refresh the boot priority for BBS entries based on boot option entry and boot order.\r
+\r
+  @param  Entry             The boot option is to be checked for a refreshed BBS table.\r
+  \r
+  @retval EFI_SUCCESS           The boot priority for BBS entries refreshed successfully.\r
+  @retval EFI_NOT_FOUND         BBS entries can't be found.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to get the legacy device boot order.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsRefreshBbsTableForBoot (\r
+  IN BDS_COMMON_OPTION        *Entry\r
+  );\r
+\r
+/**\r
+  Delete the Boot Option from EFI Variable. The Boot Order Arrray\r
+  is also updated.\r
+\r
+  @param OptionNumber    The number of Boot options wanting to be deleted.\r
+  @param BootOrder       The Boot Order array.\r
+  @param BootOrderSize   The size of the Boot Order Array.\r
+\r
+  @retval  EFI_SUCCESS           The Boot Option Variable was found and removed.\r
+  @retval  EFI_UNSUPPORTED       The Boot Option Variable store was inaccessible.\r
+  @retval  EFI_NOT_FOUND         The Boot Option Variable was not found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsDeleteBootOption (\r
+  IN UINTN                       OptionNumber,\r
+  IN OUT UINT16                  *BootOrder,\r
+  IN OUT UINTN                   *BootOrderSize\r
+  );\r
+\r
+//\r
+//The interface functions related to the Setup Browser Reset Reminder feature\r
+//\r
+/**\r
+  Enable the setup browser reset reminder feature.\r
+  This routine is used in a platform tip. If the platform policy needs the feature, use the routine to enable it.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableResetReminderFeature (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Disable the setup browser reset reminder feature.\r
+  This routine is used in a platform tip. If the platform policy does not want the feature, use the routine to disable it.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DisableResetReminderFeature (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Record the info that a reset is required.\r
+  A module boolean variable is used to record whether a reset is required.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableResetRequired (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Record the info that no reset is required.\r
+  A module boolean variable is used to record whether a reset is required.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DisableResetRequired (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Check whether platform policy enables the reset reminder feature. The default is enabled.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsResetReminderFeatureEnable (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Check if the user changed any option setting that needs a system reset to be effective.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsResetRequired (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Check whether a reset is needed, and finish the reset reminder feature.\r
+  If a reset is needed, pop up a menu to notice user, and finish the feature\r
+  according to the user selection.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SetupResetReminder (\r
+  VOID\r
+  );\r
+\r
+\r
+///\r
+/// Define the boot type with which to classify the boot option type.\r
+/// Different boot option types could have different boot behaviors.\r
+/// Use their device path node (Type + SubType) as the type value.\r
+/// The boot type here can be added according to requirements.\r
+///\r
+\r
+///\r
+/// ACPI boot type. For ACPI devices, using sub-types to distinguish devices is not allowed, so hardcode their values.\r
+///\r
+#define  BDS_EFI_ACPI_FLOPPY_BOOT         0x0201\r
+///\r
+/// Message boot type\r
+/// If a device path of boot option only points to a message node, the boot option is a message boot type.\r
+///\r
+#define  BDS_EFI_MESSAGE_ATAPI_BOOT       0x0301 // Type 03; Sub-Type 01\r
+#define  BDS_EFI_MESSAGE_SCSI_BOOT        0x0302 // Type 03; Sub-Type 02\r
+#define  BDS_EFI_MESSAGE_USB_DEVICE_BOOT  0x0305 // Type 03; Sub-Type 05\r
+#define  BDS_EFI_MESSAGE_SATA_BOOT        0x0312 // Type 03; Sub-Type 18\r
+#define  BDS_EFI_MESSAGE_MAC_BOOT         0x030b // Type 03; Sub-Type 11\r
+#define  BDS_EFI_MESSAGE_MISC_BOOT        0x03FF\r
+\r
+///\r
+/// Media boot type\r
+/// If a device path of boot option contains a media node, the boot option is media boot type.\r
+///\r
+#define  BDS_EFI_MEDIA_HD_BOOT            0x0401 // Type 04; Sub-Type 01\r
+#define  BDS_EFI_MEDIA_CDROM_BOOT         0x0402 // Type 04; Sub-Type 02\r
+///\r
+/// BBS boot type\r
+/// If a device path of boot option contains a BBS node, the boot option is BBS boot type.\r
+///\r
+#define  BDS_LEGACY_BBS_BOOT              0x0501 //  Type 05; Sub-Type 01\r
+\r
+#define  BDS_EFI_UNSUPPORT                0xFFFF\r
+\r
+/**\r
+  Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path.\r
+\r
+  @param  BlockIoDevicePath      Multi device path instances to check.\r
+  @param  HardDriveDevicePath    A device path starting with a hard drive media\r
+                                 device path.\r
+\r
+  @retval TRUE                   There is a matched device path instance.\r
+  @retval FALSE                  There is no matched device path instance.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MatchPartitionDevicePathNode (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL   *BlockIoDevicePath,\r
+  IN  HARDDRIVE_DEVICE_PATH      *HardDriveDevicePath\r
+  );\r
+\r
+\r
+/**\r
+  Expand a device path that starts with a hard drive media device path node to be a\r
+  full device path that includes the full hardware path to the device. This function enables the device to boot. \r
+  To avoid requiring a connect on every boot, the front match is saved in a variable (the part point\r
+  to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ).\r
+  All successful history device paths\r
+  that point to the front part of the partition node will be saved.\r
+\r
+  @param  HardDriveDevicePath    EFI Device Path to boot, if it starts with a hard\r
+                                 drive media device path.\r
+  @return A Pointer to the full device path, or NULL if a valid Hard Drive devic path\r
+          cannot be found.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+BdsExpandPartitionPartialDevicePathToFull (\r
+  IN  HARDDRIVE_DEVICE_PATH      *HardDriveDevicePath\r
+  );\r
+  \r
+/**\r
+  Return the bootable media handle.\r
+  First, check whether the device is connected.\r
+  Second, check whether the device path points to a device that supports SimpleFileSystemProtocol.\r
+  Third, detect the the default boot file in the Media, and return the removable Media handle.\r
+\r
+  @param  DevicePath             The Device Path to a  bootable device.\r
+\r
+  @return  The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.\r
+\r
+**/\r
+EFI_HANDLE\r
+EFIAPI\r
+BdsLibGetBootableHandle (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
+  );\r
+  \r
+\r
+/**\r
+  Checks whether the Device path in a boot option points to a valid bootable device, and if the device\r
+  is ready to boot now.\r
+\r
+  @param  DevPath     The Device path in a boot option.\r
+  @param  CheckMedia  If TRUE, check whether the device is ready to boot now.\r
+\r
+  @retval TRUE        The Device path is valid.\r
+  @retval FALSE       The Device path is invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+BdsLibIsValidEFIBootOptDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath,\r
+  IN BOOLEAN                      CheckMedia\r
+  );\r
+\r
+/**\r
+  Checks whether the Device path in a boot option points to a valid bootable device, and if the device\r
+  is ready to boot now.\r
+  If Description is not NULL and the device path points to a fixed BlockIo\r
+  device, this function checks whether the description conflicts with other auto-created\r
+  boot options.\r
+\r
+  @param  DevPath     The Device path in a boot option.\r
+  @param  CheckMedia  If TRUE, checks if the device is ready to boot now.\r
+  @param  Description The description of a boot option.\r
+\r
+  @retval TRUE        The Device path is valid.\r
+  @retval FALSE       The Device path is invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+BdsLibIsValidEFIBootOptDevicePathExt (\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath,\r
+  IN BOOLEAN                      CheckMedia,\r
+  IN CHAR16                       *Description\r
+  );\r
+\r
+/**\r
+  For a bootable Device path, return its boot type.\r
+\r
+  @param  DevicePath                      The bootable device Path to check.\r
+\r
+  @retval BDS_EFI_MEDIA_HD_BOOT           The given device path contains MEDIA_DEVICE_PATH type device path node,\r
+                                          whose subtype is MEDIA_HARDDRIVE_DP.  \r
+  @retval BDS_EFI_MEDIA_CDROM_BOOT        If given device path contains MEDIA_DEVICE_PATH type device path node, \r
+                                          whose subtype is MEDIA_CDROM_DP.  \r
+  @retval BDS_EFI_ACPI_FLOPPY_BOOT        A given device path contains ACPI_DEVICE_PATH type device path node,                                          \r
+                                          whose HID is floppy device.  \r
+  @retval BDS_EFI_MESSAGE_ATAPI_BOOT      A given device path contains MESSAGING_DEVICE_PATH type device path node, \r
+                                          and its last device path node's subtype is MSG_ATAPI_DP.  \r
+  @retval BDS_EFI_MESSAGE_SCSI_BOOT       A given device path contains MESSAGING_DEVICE_PATH type device path node,\r
+                                          and its last device path node's subtype is MSG_SCSI_DP. \r
+  @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node, \r
+                                          and its last device path node's subtype is MSG_USB_DP.\r
+  @retval BDS_EFI_MESSAGE_MISC_BOOT       The device path does not contain any media device path node, and  \r
+                                          its last device path node points to a message device path node.  \r
+  @retval BDS_LEGACY_BBS_BOOT             A given device path contains BBS_DEVICE_PATH type device path node. \r
+  @retval BDS_EFI_UNSUPPORT               An EFI Removable BlockIO device path does not point to a media and message device.   \r
+\r
+  **/\r
+UINT32\r
+EFIAPI\r
+BdsGetBootTypeFromDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
+  );\r
+\r
+\r
+/**\r
+  This routine registers a function to adjust the different types of memory page numbers\r
+  just before booting, and saves the updated info into the variable for the next boot to use.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BdsLibSaveMemoryTypeInformation (\r
+  VOID\r
+  );\r
+  \r
+/**\r
+  Identify a user and, if authenticated, returns the current user profile handle.\r
+\r
+  @param[out]  User           Points to the user profile handle.\r
+  \r
+  @retval EFI_SUCCESS         The user is successfully identified, or user identification\r
+                              is not supported.\r
+  @retval EFI_ACCESS_DENIED   The user was not successfully identified.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibUserIdentify (\r
+  OUT EFI_USER_PROFILE_HANDLE         *User\r
+  );  \r
+\r
+/**\r
+  This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,\r
+  it tries to return the valid device path.\r
+  FV address maybe changes for memory layout adjust from time to time, use this funciton\r
+  could promise the Fv file device path is right.\r
+\r
+  @param  DevicePath             On input, the Fv file device path to check. On\r
+                                 output, the updated valid Fv file device path\r
+  @param  FileGuid               the Fv file GUID.\r
+\r
+  @retval EFI_INVALID_PARAMETER  The input DevicePath or FileGuid is invalid.\r
+  @retval EFI_UNSUPPORTED        The input DevicePath does not contain an Fv file\r
+                                 GUID at all.\r
+  @retval EFI_ALREADY_STARTED    The input DevicePath has pointed to the Fv file and is\r
+                                 valid.\r
+  @retval EFI_SUCCESS            Successfully updated the invalid DevicePath\r
+                                 and returned the updated device path in DevicePath.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibUpdateFvFileDevicePath (\r
+  IN  OUT EFI_DEVICE_PATH_PROTOCOL      ** DevicePath,\r
+  IN  EFI_GUID                          *FileGuid\r
+  );\r
+\r
+\r
+/**\r
+  Connect the specific USB device that matches the RemainingDevicePath,\r
+  and whose bus is determined by Host Controller (Uhci or Ehci).\r
+\r
+  @param  HostControllerPI      Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
+                                (0xFF).\r
+  @param  RemainingDevicePath   A short-form device path that starts with the first\r
+                                element being a USB WWID or a USB Class device\r
+                                path.\r
+\r
+  @retval EFI_SUCCESS           The specific Usb device is connected successfully.\r
+  @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF) \r
+                                or RemainingDevicePath is not the USB class device path.\r
+  @retval EFI_NOT_FOUND         The device specified by device path is not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectUsbDevByShortFormDP(\r
+  IN UINT8                      HostControllerPI,\r
+  IN EFI_DEVICE_PATH_PROTOCOL   *RemainingDevicePath\r
+  );\r
+  \r
+\r
+//\r
+// The implementation of this function is provided by Platform code.\r
+//\r
+/**\r
+  Convert Vendor device path to a device name.\r
+\r
+  @param  Str      The buffer storing device name.\r
+  @param  DevPath  The pointer to vendor device path.\r
+\r
+**/\r
+VOID\r
+DevPathVendor (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  );\r
+\r
+/**\r
+  Concatenates a formatted unicode string to an allocated pool.\r
+  The caller must free the resulting buffer.\r
+\r
+  @param  Str      Tracks the allocated pool, size in use, and amount of pool allocated.\r
+  @param  Fmt      The format string.\r
+  @param  ...      The data will be printed.\r
+\r
+  @return Allocated buffer with the formatted string printed in it.\r
+          The caller must free the allocated buffer.\r
+          The buffer allocation is not packed.\r
+\r
+**/\r
+\r
+CHAR16 *\r
+EFIAPI\r
+CatPrint (\r
+  IN OUT POOL_PRINT   *Str,\r
+  IN CHAR16           *Fmt,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Use SystemTable ConOut to stop video based Simple Text Out consoles from going\r
+  to the video device. Put up LogoFile on every video device that is a console.\r
+\r
+  @param[in]  LogoFile   The file name of logo to display on the center of the screen.\r
+\r
+  @retval EFI_SUCCESS     ConsoleControl has been flipped to graphics and logo displayed.\r
+  @retval EFI_UNSUPPORTED Logo not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EnableQuietBoot (\r
+  IN  EFI_GUID  *LogoFile\r
+  );\r
+\r
+\r
+/**\r
+  Use SystemTable ConOut to turn on video based Simple Text Out consoles. The \r
+  Simple Text Out screens will now be synced up with all non-video output devices.\r
+\r
+  @retval EFI_SUCCESS     UGA devices are back in text mode and synced up.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DisableQuietBoot (\r
+  VOID\r
+  );\r
+\r
+#endif\r
+\r
diff --git a/EfiLib/Make.tiano b/EfiLib/Make.tiano
new file mode 100644 (file)
index 0000000..2e2e5b3
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# EfiLib/Make.tiano
+# Build control file for EfiLib components of rEFInd, using TianoCore EDK2
+#
+
+include ../Make.tiano
+
+SOURCE_NAMES     = BdsConnect BmLib Console DevicePath 
+OBJS             = $(SOURCE_NAMES:=.obj)
+#DRIVERNAME      = ext2
+#BUILDME          = $(DRIVERNAME)_$(FILENAME_CODE).efi
+
+all: $(AR_TARGET)
+
+$(AR_TARGET): $(OBJS)
+       $(AR) -cr $(AR_TARGET).lib $(OBJS)
+
+clean:
+       rm -f $(OBJS) *~ *.lib
diff --git a/EfiLib/Platform.h b/EfiLib/Platform.h
new file mode 100644 (file)
index 0000000..2d89822
--- /dev/null
@@ -0,0 +1,792 @@
+/*
+Headers collection for procedures
+*/
+
+#ifndef __REFIT_PLATFORM_H__
+#define __REFIT_PLATFORM_H__
+
+
+#include <Uefi.h>
+
+#include <Guid/Acpi.h>
+#include <Guid/EventGroup.h>
+#include <Guid/SmBios.h>
+#include <Guid/Mps.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/HiiLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PerformanceLib.h>
+#include <Library/PeCoffGetEntryPointLib.h>
+#include <Library/TimerLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/UefiRuntimeLib.h>
+
+#include <Framework/FrameworkInternalFormRepresentation.h>
+
+#include <IndustryStandard/Acpi10.h>
+#include <IndustryStandard/Acpi20.h>
+
+#include <Protocol/Cpu.h>
+#include <Protocol/CpuIo.h>
+#include <Protocol/DataHub.h>
+#include <Protocol/DevicePathToText.h>
+#include <Protocol/FrameworkHii.h>
+#include <Protocol/Smbios.h>
+#include <Protocol/VariableWrite.h>
+#include <Protocol/Variable.h>
+
+//#include <Protocol/FSInjectProtocol.h>
+//#include <Protocol/MsgLog.h>
+
+#include "lib.h"
+//#include "boot.h"
+//#include "BiosVideo.h"
+#include "../include/Bmp.h"
+#include "efiConsoleControl.h"
+//#include "SmBios.h"
+#include "EfiLib/GenericBdsLib.h"
+//#include "device_inject.h"
+//#include "UsbMass.h"
+
+#include "../refind/global.h"
+
+/* Decimal powers: */
+// #define kilo (1000ULL)
+// #define Mega (kilo * kilo)
+// #define Giga (kilo * Mega)
+// #define Tera (kilo * Giga)
+// #define Peta (kilo * Tera)
+
+// #define IS_COMMA(a)                ((a) == L',')
+// #define IS_HYPHEN(a)               ((a) == L'-')
+// #define IS_DOT(a)                  ((a) == L'.')
+// #define IS_LEFT_PARENTH(a)         ((a) == L'(')
+// #define IS_RIGHT_PARENTH(a)        ((a) == L')')
+// #define IS_SLASH(a)                ((a) == L'/')
+// #define IS_NULL(a)                 ((a) == L'\0')
+// #define IS_DIGIT(a)            (((a) >= '0') && ((a) <= '9'))
+// #define IS_HEX(a)            (((a) >= 'a') && ((a) <= 'f'))
+// #define IS_UPPER(a)          (((a) >= 'A') && ((a) <= 'Z'))
+// #define IS_ALFA(x) (((x >= 'a') && (x <='z')) || ((x >= 'A') && (x <='Z')))
+// #define IS_ASCII(x) ((x>=0x20) && (x<=0x7F))
+// #define IS_PUNCT(x) ((x == '.') || (x == '-'))
+
+
+// #define EBDA_BASE_ADDRESS 0x40E
+// #define EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF
+// #define ROUND_PAGE(x)  ((((unsigned)(x)) + EFI_PAGE_SIZE - 1) & ~(EFI_PAGE_SIZE - 1))
+
+//
+// Max bytes needed to represent ID of a SCSI device
+//
+//#define EFI_SCSI_TARGET_MAX_BYTES (0x10)
+
+//
+// bit5..7 are for Logical unit number
+// 11100000b (0xe0)
+//
+//#define EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK 0xe0
+
+//
+// Scsi Command Length
+//
+//#define EFI_SCSI_OP_LENGTH_SIX      0x6
+//#define EFI_SCSI_OP_LENGTH_TEN      0xa
+//#define EFI_SCSI_OP_LENGTH_SIXTEEN  0x10
+
+// #define SAFE_LOG_SIZE       80
+// 
+// #define MSG_LOG_SIZE        (64 * 1024)
+// #define MsgLog(x...) {AsciiSPrint(msgCursor, MSG_LOG_SIZE, x); while(*msgCursor){msgCursor++;}}
+// 
+// #define CPU_MODEL_DOTHAN        0x0D
+// #define CPU_MODEL_YONAH         0x0E
+// #define CPU_MODEL_MEROM         0x0F  /* same as CONROE but mobile */
+// #define CPU_MODEL_CONROE        0x0F  
+// #define CPU_MODEL_CELERON       0x16  /* ever see? */
+// #define CPU_MODEL_PENRYN        0x17  
+// #define CPU_MODEL_WOLFDALE      0x17  
+// #define CPU_MODEL_NEHALEM       0x1A
+// #define CPU_MODEL_ATOM          0x1C
+// #define CPU_MODEL_XEON_MP       0x1D  /* ever see? */
+// #define CPU_MODEL_FIELDS        0x1E
+// #define CPU_MODEL_DALES         0x1F
+// #define CPU_MODEL_CLARKDALE     0x25
+// #define CPU_MODEL_LINCROFT      0x27
+// #define CPU_MODEL_SANDY_BRIDGE      0x2A
+// #define CPU_MODEL_WESTMERE      0x2C
+// #define CPU_MODEL_JAKETOWN      0x2D  /* ever see? */
+// #define CPU_MODEL_NEHALEM_EX    0x2E
+// #define CPU_MODEL_WESTMERE_EX   0x2F
+// 
+// #define CPU_VENDOR_INTEL  0x756E6547
+// #define CPU_VENDOR_AMD    0x68747541
+// /* Unknown CPU */
+// #define CPU_STRING_UNKNOWN  "Unknown CPU Type"
+
+//definitions from Apple XNU
+
+/* CPU defines */
+// #define bit(n)                      (1UL << (n))
+// #define _Bit(n)                     (1ULL << n)
+// #define _HBit(n)            (1ULL << ((n)+32))
+// 
+// #define bitmask(h,l)        ((bit(h)|(bit(h)-1)) & ~(bit(l)-1))
+// #define bitfield(x,h,l)     (((x) & bitmask(h,l)) >> l)
+// #define quad(hi,lo)     (((UINT64)(hi)) << 32 | (lo))
+
+/*
+ * The CPUID_FEATURE_XXX values define 64-bit values
+ * returned in %ecx:%edx to a CPUID request with %eax of 1: 
+ */
+// #define     CPUID_FEATURE_FPU     _Bit(0)   /* Floating point unit on-chip */
+// #define     CPUID_FEATURE_VME     _Bit(1)   /* Virtual Mode Extension */
+// #define     CPUID_FEATURE_DE      _Bit(2)   /* Debugging Extension */
+// #define     CPUID_FEATURE_PSE     _Bit(3)   /* Page Size Extension */
+// #define     CPUID_FEATURE_TSC     _Bit(4)   /* Time Stamp Counter */
+// #define     CPUID_FEATURE_MSR     _Bit(5)   /* Model Specific Registers */
+// #define CPUID_FEATURE_PAE     _Bit(6)       /* Physical Address Extension */
+// #define     CPUID_FEATURE_MCE     _Bit(7)   /* Machine Check Exception */
+// #define     CPUID_FEATURE_CX8     _Bit(8)   /* CMPXCHG8B */
+// #define     CPUID_FEATURE_APIC    _Bit(9)   /* On-chip APIC */
+// #define CPUID_FEATURE_SEP     _Bit(11)      /* Fast System Call */
+// #define     CPUID_FEATURE_MTRR    _Bit(12)  /* Memory Type Range Register */
+// #define     CPUID_FEATURE_PGE     _Bit(13)  /* Page Global Enable */
+// #define     CPUID_FEATURE_MCA     _Bit(14)  /* Machine Check Architecture */
+// #define     CPUID_FEATURE_CMOV    _Bit(15)  /* Conditional Move Instruction */
+// #define CPUID_FEATURE_PAT     _Bit(16)      /* Page Attribute Table */
+// #define CPUID_FEATURE_PSE36   _Bit(17)      /* 36-bit Page Size Extension */
+// #define CPUID_FEATURE_PSN     _Bit(18)      /* Processor Serial Number */
+// #define CPUID_FEATURE_CLFSH   _Bit(19)      /* CLFLUSH Instruction supported */
+// #define CPUID_FEATURE_DS      _Bit(21)      /* Debug Store */
+// #define CPUID_FEATURE_ACPI    _Bit(22)      /* Thermal monitor and Clock Ctrl */
+// #define CPUID_FEATURE_MMX     _Bit(23)      /* MMX supported */
+// #define CPUID_FEATURE_FXSR    _Bit(24)      /* Fast floating pt save/restore */
+// #define CPUID_FEATURE_SSE     _Bit(25)      /* Streaming SIMD extensions */
+// #define CPUID_FEATURE_SSE2    _Bit(26)      /* Streaming SIMD extensions 2 */
+// #define CPUID_FEATURE_SS      _Bit(27)      /* Self-Snoop */
+// #define CPUID_FEATURE_HTT     _Bit(28)      /* Hyper-Threading Technology */
+// #define CPUID_FEATURE_TM      _Bit(29)      /* Thermal Monitor (TM1) */
+// #define CPUID_FEATURE_PBE     _Bit(31)      /* Pend Break Enable */
+// 
+// #define CPUID_FEATURE_SSE3    _HBit(0)      /* Streaming SIMD extensions 3 */
+// #define CPUID_FEATURE_PCLMULQDQ _HBit(1) /* PCLMULQDQ Instruction */
+// 
+// #define CPUID_FEATURE_MONITOR _HBit(3)      /* Monitor/mwait */
+// #define CPUID_FEATURE_DSCPL   _HBit(4)      /* Debug Store CPL */
+// #define CPUID_FEATURE_VMX     _HBit(5)      /* VMX */
+// #define CPUID_FEATURE_SMX     _HBit(6)      /* SMX */
+// #define CPUID_FEATURE_EST     _HBit(7)      /* Enhanced SpeedsTep (GV3) */
+// #define CPUID_FEATURE_TM2     _HBit(8)      /* Thermal Monitor 2 */
+// #define CPUID_FEATURE_SSSE3   _HBit(9)      /* Supplemental SSE3 instructions */
+// #define CPUID_FEATURE_CID     _HBit(10)     /* L1 Context ID */
+// 
+// #define CPUID_FEATURE_CX16    _HBit(13)     /* CmpXchg16b instruction */
+// #define CPUID_FEATURE_xTPR    _HBit(14)     /* Send Task PRiority msgs */
+// #define CPUID_FEATURE_PDCM    _HBit(15)     /* Perf/Debug Capability MSR */
+// 
+// #define CPUID_FEATURE_DCA     _HBit(18)     /* Direct Cache Access */
+// #define CPUID_FEATURE_SSE4_1  _HBit(19)     /* Streaming SIMD extensions 4.1 */
+// #define CPUID_FEATURE_SSE4_2  _HBit(20)     /* Streaming SIMD extensions 4.2 */
+// #define CPUID_FEATURE_xAPIC   _HBit(21)     /* Extended APIC Mode */
+// #define CPUID_FEATURE_POPCNT  _HBit(23)     /* POPCNT instruction */
+// #define CPUID_FEATURE_AES     _HBit(25)     /* AES instructions */
+// #define CPUID_FEATURE_VMM     _HBit(31)     /* VMM (Hypervisor) present */
+
+// /*
+//  * The CPUID_EXTFEATURE_XXX values define 64-bit values
+//  * returned in %ecx:%edx to a CPUID request with %eax of 0x80000001: 
+//  */
+// #define CPUID_EXTFEATURE_SYSCALL   _Bit(11) /* SYSCALL/sysret */
+// #define CPUID_EXTFEATURE_XD            _Bit(20)     /* eXecute Disable */
+// #define CPUID_EXTFEATURE_1GBPAGE   _Bit(26)     /* 1G-Byte Page support */
+// #define CPUID_EXTFEATURE_RDTSCP        _Bit(27)     /* RDTSCP */
+// #define CPUID_EXTFEATURE_EM64T         _Bit(29)     /* Extended Mem 64 Technology */
+// 
+// //#define CPUID_EXTFEATURE_LAHF        _HBit(20)    /* LAFH/SAHF instructions */
+// // New definition with Snow kernel
+// #define CPUID_EXTFEATURE_LAHF          _HBit(0)     /* LAHF/SAHF instructions */
+// /*
+//  * The CPUID_EXTFEATURE_XXX values define 64-bit values
+//  * returned in %ecx:%edx to a CPUID request with %eax of 0x80000007: 
+//  */
+// #define CPUID_EXTFEATURE_TSCI      _Bit(8)  /* TSC Invariant */
+// 
+// #define     CPUID_CACHE_SIZE        16      /* Number of descriptor values */
+// 
+// #define CPUID_MWAIT_EXTENSION       _Bit(0) /* enumeration of WMAIT extensions */
+// #define CPUID_MWAIT_BREAK   _Bit(1) /* interrupts are break events     */
+
+// /* Known MSR registers */
+// #define MSR_IA32_PLATFORM_ID        0x0017   
+// #define MSR_CORE_THREAD_COUNT       0x0035   /* limited use - not for Penryn or older       */
+// #define MSR_IA32_BIOS_SIGN_ID       0x008B   /* microcode version */
+// #define MSR_FSB_FREQ                0x00CD   /* limited use - not for i7                                            */
+// #define     MSR_PLATFORM_INFO           0x00CE   /* limited use - MinRatio for i7 but Max for Yonah */
+// /* turbo for penryn */
+// #define MSR_IA32_EXT_CONFIG         0x00EE   /* limited use - not for i7                                            */
+// #define MSR_FLEX_RATIO              0x0194   /* limited use - not for Penryn or older                       */
+// //see no value on most CPUs
+// #define     MSR_IA32_PERF_STATUS        0x0198
+// #define MSR_IA32_PERF_CONTROL       0x0199
+// #define MSR_IA32_CLOCK_MODULATION   0x019A
+// #define MSR_THERMAL_STATUS          0x019C
+// #define MSR_IA32_MISC_ENABLE        0x01A0
+// #define MSR_THERMAL_TARGET          0x01A2   /* limited use - not for Penryn or older                       */
+// #define MSR_TURBO_RATIO_LIMIT       0x01AD   /* limited use - not for Penryn or older                       */
+// 
+// 
+// //Copied from revogirl
+// #define IA32_ENERGY_PERF_BIAS               0x01B0
+// //MSR 000001B0                                      0000-0000-0000-0005
+// //MSR 000001B1                                      0000-0000-8838-0000
+// #define IA32_PLATFORM_DCA_CAP               0x01F8
+// //MSR 000001FC                                      0000-0000-0004-005F
+// 
+// 
+// // Sandy Bridge & JakeTown specific 'Running Average Power Limit' MSR's.
+// #define MSR_RAPL_POWER_UNIT                 0x606
+// //MSR 00000606                                      0000-0000-000A-1003
+// //MSR 0000060B                                      0000-0000-0000-8854
+// //MSR 0000060C                                      0000-0000-0000-8854
+
+// #define MSR_PKG_RAPL_POWER_LIMIT    0x610
+// //MSR 00000610                                      0000-A580-0000-8960
+// #define MSR_PKG_ENERGY_STATUS               0x611
+// //MSR 00000611                                      0000-0000-3212-A857
+// #define MSR_PKG_PERF_STATUS                 0x613
+// #define MSR_PKG_POWER_INFO                  0x614
+// //MSR 00000614                                      0000-0000-01E0-02F8
+// // Sandy Bridge IA (Core) domain MSR's.
+// #define MSR_PP0_POWER_LIMIT                 0x638
+// #define MSR_PP0_ENERGY_STATUS               0x639
+// #define MSR_PP0_POLICY          0x63A
+// #define MSR_PP0_PERF_STATUS                 0x63B
+// 
+// // Sandy Bridge Uncore (IGPU) domain MSR's (Not on JakeTown).
+// #define MSR_PP1_POWER_LIMIT                 0x640
+// #define MSR_PP1_ENERGY_STATUS               0x641
+// //MSR 00000641                                      0000-0000-0000-0000
+// #define MSR_PP1_POLICY          0x642
+// 
+// // JakeTown only Memory MSR's.
+// #define MSR_DRAM_POWER_LIMIT                0x618
+// #define MSR_DRAM_ENERGY_STATUS      0x619
+// #define MSR_DRAM_PERF_STATUS                0x61B
+// #define MSR_DRAM_POWER_INFO                 0x61C
+// 
+// 
+// //AMD
+// #define K8_FIDVID_STATUS        0xC0010042
+// #define K10_COFVID_STATUS       0xC0010071
+// #define DEFAULT_FSB             100000          /* for now, hardcoding 100MHz for old CPUs */
+
+
+// /* CPUID Index */
+// #define CPUID_0             0
+// #define CPUID_1             1
+// #define CPUID_2             2
+// #define CPUID_3             3
+// #define CPUID_4             4
+// #define CPUID_80    5
+// #define CPUID_81    6
+// #define CPUID_87  7
+// #define CPUID_MAX   8
+// 
+// #define EAX 0
+// #define EBX 1
+// #define ECX 2
+// #define EDX 3
+// 
+// /* CPU Cache */
+// #define MAX_CACHE_COUNT  4
+// #define CPU_CACHE_LEVEL  3
+// 
+// /* PCI */
+// #define PCI_BASE_ADDRESS_0                                  0x10            /* 32 bits */
+// #define PCI_BASE_ADDRESS_1                                  0x14            /* 32 bits [htype 0,1 only] */
+// #define PCI_BASE_ADDRESS_2                                  0x18            /* 32 bits [htype 0 only] */
+// #define PCI_BASE_ADDRESS_3                                  0x1c            /* 32 bits */
+// #define PCI_BASE_ADDRESS_4                                  0x20            /* 32 bits */
+// #define PCI_BASE_ADDRESS_5                                  0x24            /* 32 bits */
+// 
+// #define PCI_CLASS_MEDIA_HDA         0x03
+// 
+// #define GEN_PMCON_1                 0xA0
+// 
+// #define PCIADDR(bus, dev, func) ((1 << 31) | (bus << 16) | (dev << 11) | (func << 8))
+// #define REG8(base, reg)  ((volatile UINT8 *)(UINTN)base)[(reg)]
+// #define REG16(base, reg)  ((volatile UINT16 *)(UINTN)base)[(reg) >> 1]
+// #define REG32(base, reg)  ((volatile UINT32 *)(UINTN)base)[(reg) >> 2]
+// #define WRITEREG32(base, reg, value) REG32(base, reg) = value
+
+#define EFI_HANDLE_TYPE_UNKNOWN                     0x000
+#define EFI_HANDLE_TYPE_IMAGE_HANDLE                0x001
+#define EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE       0x002
+#define EFI_HANDLE_TYPE_DEVICE_DRIVER               0x004
+#define EFI_HANDLE_TYPE_BUS_DRIVER                  0x008
+#define EFI_HANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE 0x010
+#define EFI_HANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE   0x020
+#define EFI_HANDLE_TYPE_COMPONENT_NAME_HANDLE       0x040
+#define EFI_HANDLE_TYPE_DEVICE_HANDLE               0x080
+#define EFI_HANDLE_TYPE_PARENT_HANDLE               0x100
+#define EFI_HANDLE_TYPE_CONTROLLER_HANDLE           0x200
+#define EFI_HANDLE_TYPE_CHILD_HANDLE                0x400
+
+// #define     AML_CHUNK_NONE          0xff
+// #define     AML_CHUNK_ZERO          0x00
+// #define     AML_CHUNK_ONE     0x01
+// #define     AML_CHUNK_ALIAS         0x06
+// #define     AML_CHUNK_NAME          0x08
+// #define     AML_CHUNK_BYTE          0x0A
+// #define     AML_CHUNK_WORD          0x0B
+// #define     AML_CHUNK_DWORD         0x0C
+// #define     AML_CHUNK_STRING        0x0D
+// #define     AML_CHUNK_QWORD         0x0E
+// #define     AML_CHUNK_SCOPE         0x10
+// #define     AML_CHUNK_PACKAGE       0x12
+// #define     AML_CHUNK_METHOD        0x14
+// #define AML_CHUNK_RETURN  0xA4
+// #define AML_LOCAL0        0x60
+// #define AML_STORE_OP      0x70
+
+// struct aml_chunk 
+// {
+//     UINT8     Type;
+//     UINT16          Length;
+//     CHAR8*          Buffer;
+//     
+//     UINT16          Size;
+//     
+//     struct aml_chunk*       Next;
+//     struct aml_chunk*       First;
+//     struct aml_chunk*       Last;
+// };
+// 
+// typedef struct aml_chunk AML_CHUNK;
+// 
+// struct p_state 
+// {
+//     union 
+//     {
+//             UINT16 Control;
+//             struct 
+//             {
+//                     UINT8 VID;      // Voltage ID
+//                     UINT8 FID;      // Frequency ID
+//             };
+//     };
+//     
+//     UINT32          CID;            // Compare ID
+//     UINT32  Frequency;
+// };
+// 
+// typedef struct p_state P_STATE;
+
+// typedef enum {
+//     kTagTypeNone,
+//     kTagTypeDict,
+//     kTagTypeKey,
+//     kTagTypeString,
+//     kTagTypeInteger,
+//     kTagTypeData,
+//     kTagTypeDate,
+//     kTagTypeFalse,
+//     kTagTypeTrue,
+//     kTagTypeArray
+// } TAG_TYPE;
+
+#pragma pack(1)
+
+// struct Symbol {
+//     UINT32        refCount;
+//     struct Symbol *next;
+//     CHAR8         string[1];
+// };
+// 
+// typedef struct Symbol Symbol, *SymbolPtr;
+
+// typedef struct {
+//   
+//   UINT32            type;
+//   CHAR8     *string;
+//   UINT32            offset;
+//   VOID      *tag;
+//   VOID      *tagNext;
+//   
+// }Tag, *TagPtr;
+// 
+// typedef struct {
+//   
+//   EFI_ACPI_DESCRIPTION_HEADER   Header;
+//   UINT32                                            Entry;
+//   
+// } RSDT_TABLE;
+// 
+// typedef struct {
+//   
+//   EFI_ACPI_DESCRIPTION_HEADER   Header;
+//   UINT64                                            Entry;
+//   
+// } XSDT_TABLE;
+
+// typedef struct {
+//   
+//     // SMBIOS TYPE0
+//     CHAR8   VendorName[64];
+//     CHAR8   RomVersion[64];
+//     CHAR8   ReleaseDate[64];
+//     // SMBIOS TYPE1
+//     CHAR8   ManufactureName[64];
+//     CHAR8   ProductName[64];
+//     CHAR8   VersionNr[64];
+//     CHAR8   SerialNr[64];
+// //  CHAR8   Uuid[64];
+// //  CHAR8   SKUNumber[64];
+//     CHAR8   FamilyName[64];
+//   CHAR8 OEMProduct[64];
+//     // SMBIOS TYPE2
+//     CHAR8   BoardManufactureName[64];
+//     CHAR8   BoardSerialNumber[64];
+//     CHAR8   BoardNumber[64]; //Board-ID
+//     CHAR8   LocationInChassis[64];
+//   CHAR8 BoardVersion[64];
+//   CHAR8 OEMBoard[64];
+//     // SMBIOS TYPE3
+//   BOOLEAN Mobile;
+//     CHAR8   ChassisManufacturer[64];
+//     CHAR8   ChassisAssetTag[64]; 
+//     // SMBIOS TYPE4
+//     UINT16  CpuFreqMHz;
+//     UINT32  BusSpeed; //in kHz
+//   BOOLEAN Turbo;
+//   
+//     // SMBIOS TYPE17
+//     CHAR8   MemoryManufacturer[64];
+//     CHAR8   MemorySerialNumber[64];
+//     CHAR8   MemoryPartNumber[64];
+//     CHAR8   MemorySpeed[64];
+//     // SMBIOS TYPE131
+//     UINT16  CpuType;
+//   // SMBIOS TYPE132
+//   UINT16    QPI;
+//   
+//     // OS parameters
+//     CHAR8   Language[16];
+//     CHAR8   BootArgs[256];
+//     CHAR16  CustomUuid[40];
+//   CHAR16  DefaultBoot[40];
+//     
+//     // GUI parameters
+//     BOOLEAN Debug;
+//   
+//     //ACPI
+//     UINT64  ResetAddr;
+//     UINT8   ResetVal;
+//     BOOLEAN UseDSDTmini;  
+//     BOOLEAN DropSSDT;
+//     BOOLEAN GeneratePStates;
+//   BOOLEAN   GenerateCStates;
+//   UINT8   PLimitDict;
+//   UINT8   UnderVoltStep;
+//   BOOLEAN LpcTune;
+//   BOOLEAN EnableC2;
+//   BOOLEAN EnableC4;
+//   BOOLEAN EnableC6;
+//   BOOLEAN EnableISS;
+//     BOOLEAN smartUPS;
+//   BOOLEAN PatchNMI;
+//     CHAR16  DsdtName[60];
+//   
+//   //Injections
+//   BOOLEAN StringInjector;
+//   BOOLEAN InjectSystemID;
+//   //Graphics
+//   UINT16  PCIRootUID;
+//   BOOLEAN GraphicsInjector;
+//   BOOLEAN LoadVBios;
+//   BOOLEAN PatchVBios;
+//   CHAR16  FBName[16];
+//   UINT16  VideoPorts;
+//   UINT64  VRAM;
+//   UINT8   Dcfg[8];
+//   UINT8   NVCAP[20];
+//     
+//     // HDA
+//     BOOLEAN HDAInjection;
+//     UINTN   HDALayoutId;
+//   
+// } SETTINGS_DATA;
+
+// typedef struct {
+//  //values from CPUID 
+//     UINT32  CPUID[CPUID_MAX][4];
+//     UINT32  Vendor;
+//     UINT32  Signature;
+//     UINT32  Family;
+//     UINT32  Model;
+//     UINT32  Stepping;
+//     UINT32  Type;
+//     UINT32  Extmodel;
+//     UINT32  Extfamily;
+//     UINT64  Features;
+//     UINT64  ExtFeatures;
+//     UINT32  CoresPerPackage;
+//     UINT32  LogicalPerPackage;  
+//     CHAR8   BrandString[48];
+//   
+//   //values from BIOS
+//     UINT32  ExternalClock; //keep this values as kHz
+//     UINT32  MaxSpeed;       //MHz
+//     UINT32  CurrentSpeed;   //MHz
+//   UINT32  Pad;
+//   
+//   //calculated from MSR
+//   UINT64  MicroCode;
+//   UINT64  ProcessorFlag;
+//     UINT32  MaxRatio;
+//   UINT32  SubDivider;
+//     UINT32  MinRatio;
+//   UINT32  DynFSB;
+//     UINT64  ProcessorInterconnectSpeed;
+//     UINT64  FSBFrequency; //Hz
+//     UINT64  CPUFrequency;
+//     UINT64  TSCFrequency;
+//     UINT8   Cores;
+//   UINT8   EnabledCores;
+//     UINT8   Threads;
+//     UINT8   Mobile;  //not for i3-i7
+//   
+//     /* Core i7,5,3 */
+//     UINT16  Turbo1; //1 Core
+//     UINT16  Turbo2; //2 Core
+//     UINT16  Turbo3; //3 Core
+//     UINT16  Turbo4; //4 Core
+//     
+// } CPU_STRUCTURE;
+
+// typedef enum {
+//   
+//     MacBook11,
+//     MacBook21,
+//     MacBook41,
+//     MacBook52,
+//     MacBookPro51,
+//     MacBookPro81,
+//     MacBookPro83,
+//     MacBookAir31,
+//     MacMini21,
+//     iMac81,
+//     iMac101,
+//     iMac112,
+//     iMac121,
+//   iMac122,
+//     MacPro31,
+//     MacPro41,
+//     MacPro51
+//   
+// } MACHINE_TYPES;
+
+// typedef struct {
+//     UINT8   Type;
+//     UINT8   BankConnections;
+//     UINT8   BankConnectionCount;
+//     UINT32  ModuleSize;
+//     UINT32  Frequency;
+//     CHAR8*  Vendor;
+//     CHAR8*  PartNo;
+//     CHAR8*  SerialNo;
+//     UINT8   *spd;
+//     BOOLEAN InUse;
+// } RAM_SLOT_INFO; 
+// 
+// #define MAX_SLOT_COUNT      8
+// #define MAX_RAM_SLOTS       16
+// 
+// typedef struct {
+//   
+//     UINT64          Frequency;
+//     UINT32          Divider;
+//     UINT8                   TRC;
+//     UINT8                   TRP;
+//     UINT8                   RAS;
+//     UINT8                   Channels;
+//     UINT8                   Slots;
+//     UINT8                   Type;
+//   
+//     RAM_SLOT_INFO   DIMM[MAX_RAM_SLOTS];
+//   
+// } MEM_STRUCTURE;
+//unused
+// typedef struct {
+//     UINT8     MaxMemorySlots;                       // number of memory slots polulated by SMBIOS
+//     UINT8     CntMemorySlots;                       // number of memory slots counted
+//     UINT16          MemoryModules;                  // number of memory modules installed
+//     UINT32          DIMM[MAX_RAM_SLOTS];    // Information and SPD mapping for each slot
+// } DMI;
+
+// typedef enum {
+//   english,  //en
+//   russian,  //ru
+//   chinese   //cn
+//   //something else? add, please
+// } LANGUAGES;
+// 
+// typedef enum {
+//   Unknown,
+//     Ati,
+//     Intel,
+//     Nvidia
+//   
+// } GFX_MANUFACTERER;
+
+// typedef struct {
+//   GFX_MANUFACTERER  Vendor;
+//   UINT8             Ports;  
+//   UINT16            DeviceID;
+//   UINT16            Width;
+//   UINT16            Height;
+//   CHAR8             Model[64];
+//   CHAR8             Config[64];
+//   BOOLEAN           LoadVBios;
+// } GFX_PROPERTIES;
+#pragma pack(0)
+//extern CHAR8                    *msgbuf;
+//extern CHAR8                    *msgCursor;
+//extern SMBIOS_STRUCTURE_POINTER      SmbiosTable;
+//extern GFX_PROPERTIES           gGraphics[];
+//extern UINTN                    NGFX;
+//extern BOOLEAN                  gMobile;
+//extern UINT32                   gCpuSpeed;  //kHz
+//extern UINT16                   gCPUtype;
+//extern UINT64                   TurboMsr;
+//extern CHAR8*                   BiosVendor;
+/*extern UINT32                   mPropSize;
+extern UINT8*                   mProperties;
+extern CHAR8                    gSelectedUUID[];
+extern CHAR8*                   AppleSystemVersion[];
+extern CHAR8*                    AppleFirmwareVersion[];
+extern CHAR8*                    AppleReleaseDate[];
+extern CHAR8*                    AppleManufacturer;
+extern CHAR8*                    AppleProductName[];
+extern CHAR8*                    AppleSystemVersion[];
+extern CHAR8*                    AppleSerialNumber[];
+extern CHAR8*                    AppleFamilies[];
+extern CHAR8*                    AppleBoardID[];
+extern CHAR8*                    AppleChassisAsset[];
+extern CHAR8*                    AppleBoardSN;
+extern CHAR8*                    AppleBoardLocation; */
+// extern EFI_SYSTEM_TABLE*        gST;
+// extern EFI_BOOT_SERVICES*       gBS; 
+// extern SETTINGS_DATA            gSettings;
+// extern LANGUAGES                gLanguage;
+// //extern BOOLEAN                  gFirmwareClover;
+// extern CPU_STRUCTURE            gCPUStructure;
+//extern EFI_GUID                 gUuid;
+//extern EFI_EDID_DISCOVERED_PROTOCOL*            EdidDiscovered;
+//extern UINT8                                    *gEDID;
+//extern CHAR8*                   gDeviceProperties;
+//extern CHAR8*                   cDeviceProperties;
+//extern INPUT_ITEM               *InputItems;
+/*
+extern EFI_GUID        gEfiAppleBootGuid;
+extern EFI_GUID        gEfiAppleNvramGuid;
+extern EFI_GUID AppleSystemInfoProducerName;
+extern EFI_GUID AppleDevicePropertyProtocolGuid;
+extern EFI_GUID gEfiAppleScreenInfoGuid;
+extern EFI_GUID gEfiAppleVendorGuid;
+extern EFI_GUID gEfiPartTypeSystemPartGuid;
+extern EFI_GUID gMsgLogProtocolGuid;
+extern EFI_GUID gEfiLegacy8259ProtocolGuid;
+
+extern EFI_EVENT  mVirtualAddressChangeEvent;
+extern EFI_EVENT  OnReadyToBootEvent;
+extern EFI_EVENT  ExitBootServiceEvent;
+extern EFI_EVENT  mSimpleFileSystemChangeEvent;
+extern UINTN      gEvent;
+
+VOID        WaitForSts(VOID);
+
+VOID        InitBooterLog(VOID);
+EFI_STATUS  SetupBooterLog(VOID);
+VOID        GetDefaultSettings(VOID);
+VOID        FillInputs(VOID);
+VOID        ApplyInputs(VOID);
+*/
+// EFI_STATUS  StrToGuid (IN  CHAR16   *Str, OUT EFI_GUID *Guid);
+// EFI_STATUS  StrToGuidLE (IN  CHAR16   *Str, OUT EFI_GUID *Guid);
+// BOOLEAN     hex2bin(IN CHAR8 *hex, OUT UINT8 *bin, INT32 len);
+// UINT8       hexstrtouint8 (CHAR8* buf); //one or two hex letters to one byte
+
+EFI_STATUS  EFIAPI InitializeConsoleSim (VOID);
+//EFI_STATUS  GuiEventsInitialize (VOID);
+//Settings.c
+// UINT32          GetCrc32(UINT8 *Buffer, UINTN Size);
+// VOID            GetCPUProperties (VOID);
+// VOID            GetDevices(VOID);
+// MACHINE_TYPES   GetDefaultModel(VOID);
+// UINT16          GetAdvancedCpuType(VOID);
+// //EFI_STATUS      GetOSVersion(IN REFIT_VOLUME *Volume);
+// EFI_STATUS      GetUserSettings(IN EFI_FILE *RootDir);
+// EFI_STATUS      GetNVRAMSettings(IN EFI_FILE *RootDir, CHAR16* NVRAMPlistPath);
+// EFI_STATUS      GetEdid(VOID);
+// //EFI_STATUS      SetFSInjection(IN LOADER_ENTRY *Entry);
+
+// EFI_STATUS
+// LogDataHub(
+//            EFI_GUID                                 *TypeGuid,
+//            CHAR16           *Name,
+//            VOID             *Data,
+//            UINT32           DataSize);
+// 
+// EFI_STATUS SetVariablesForOSX();
+// VOID       SetupDataForOSX();
+// EFI_STATUS SetPrivateVarProto(VOID);
+// VOID       SetDevices(VOID);
+// VOID       ScanSPD();
+//BOOLEAN setup_ati_devprop(pci_dt_t *ati_dev);
+//BOOLEAN setup_gma_devprop(pci_dt_t *gma_dev);
+//CHAR8*  get_gma_model(IN UINT16 DeviceID);
+//BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev);
+//CHAR8*  get_nvidia_model(IN UINT16 DeviceID);
+
+
+//EG_IMAGE * egDecodePNG(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
+
+//EFI_STATUS  PatchACPI(IN REFIT_VOLUME *Volume);
+//EFI_STATUS  PatchACPI_OtherOS(CHAR16* OsSubdir, BOOLEAN DropSSDT);
+//UINT8       Checksum8(VOID * startPtr, UINT32 len);
+//BOOLEAN     tableSign(CHAR8 *table, CONST CHAR8 *sgn);
+//VOID        SaveOemDsdt(VOID);
+
+//EFI_STATUS  EventsInitialize(VOID);
+//EFI_STATUS  EjectVolume(IN REFIT_VOLUME *Volume);
+
+//EFI_STATUS  bootElTorito(IN REFIT_VOLUME*    volume);
+//EFI_STATUS  bootMBR(IN REFIT_VOLUME* volume);
+//EFI_STATUS  bootPBR(IN REFIT_VOLUME* volume);
+
+//CHAR8*      XMLDecode(const CHAR8* src);
+//EFI_STATUS  ParseXML(const CHAR8* buffer, TagPtr * dict);
+//TagPtr      GetProperty( TagPtr dict, const CHAR8* key );
+//EFI_STATUS  XMLParseNextTag(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr);
+//VOID        FreeTag( TagPtr tag );
+//EFI_STATUS  GetNextTag( UINT8* buffer, CHAR8** tag, UINT32* start,UINT32* length);
+
+//EFI_STATUS  SaveSettings(VOID);
+
+// UINTN       iStrLen(CHAR8* String, UINTN MaxLen);
+// EFI_STATUS  PrepatchSmbios(VOID);
+// VOID        PatchSmbios(VOID);
+// VOID        FinalizeSmbios(VOID);
+// 
+// EFI_STATUS  DisableUsbLegacySupport(VOID);
+
+#endif
index d098e2e2d0f3b02f672d96a2c642bbdf420e343c..469bf6468abf1bead4d6af22c000768677d62fce 100644 (file)
@@ -11,7 +11,7 @@ EFICRT0         = /usr/local/lib
 HOSTARCH        = $(shell uname -m | sed s,i[3456789]86,ia32,)
 ARCH            := $(HOSTARCH)
 OS             = $(shell uname -s)
 HOSTARCH        = $(shell uname -m | sed s,i[3456789]86,ia32,)
 ARCH            := $(HOSTARCH)
 OS             = $(shell uname -s)
-CPPFLAGS        = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -DCONFIG_$(ARCH)
+CPPFLAGS        = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -DCONFIG_$(ARCH) -D__MAKEWITH_GNUEFI
 
 OPTIMFLAGS      = -O2 -fno-strict-aliasing
 DEBUGFLAGS      = -Wall
 
 OPTIMFLAGS      = -O2 -fno-strict-aliasing
 DEBUGFLAGS      = -Wall
@@ -109,6 +109,6 @@ endif
 # utility rules
 
 clean:
 # utility rules
 
 clean:
-       rm -f $(TARGET) *~ *.so $(OBJS) *.efi
+       rm -f $(TARGET) *~ *.so $(OBJS) *.efi *.obj refind_*.txt refind_*.dll *.lib
 
 # EOF
 
 # EOF
diff --git a/Make.tiano b/Make.tiano
new file mode 100644 (file)
index 0000000..5eb99fc
--- /dev/null
@@ -0,0 +1,64 @@
+#
+# Make.tiano
+# Common Makefile options for rEFInd using TianoCore EDK2
+#
+
+HOSTARCH        = $(shell uname -m | sed s,i[3456789]86,ia32,)
+ARCH            := $(HOSTARCH)
+
+# Note: IA64 options are untested; taken from Debian's rEFIt package.
+ifeq ($(ARCH),ia64)
+  # EFI specs allows only lower floating point partition to be used
+  ARCH_C_CFLAGS  = -frename-registers -mfixed-range=f32-f127
+  # TODO: Add ARCHDIR and FILENAME_CODE as appropriate
+endif
+
+ifeq ($(ARCH),ia32)
+  ARCH_C_FLAGS = -m32 -DEFI32
+  ARCHDIR = Ia32
+  FILENAME_CODE = ia32
+endif
+
+ifeq ($(ARCH),x86_64)
+  ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -DEFIX64 -mcmodel=large -m64
+  ARCHDIR = X64
+  FILENAME_CODE = x64
+endif
+
+EDK2BASE = /usr/local/UDK2010/MyWorkSpace
+
+# Below file defines TARGET (RELEASE or DEBUG), TARGET_ARCH (X64 or IA32), and TOOL_CHAIN_TAG (GCC44, GCC45, GCC46, or GCC47)
+include $(EDK2BASE)/Conf/target.txt
+
+INCLUDE_DIRS    = -I $(EDK2BASE)/MdePkg \
+                  -I $(EDK2BASE)/MdePkg/Include \
+                  -I $(EDK2BASE)/MdeModulePkg/Include \
+                  -I $(EDK2BASE)/IntelFrameworkPkg/Include \
+                  -I $(EDK2BASE)/MdePkg/Include/$(ARCHDIR) \
+                 -I .. \
+                 -I ../refind \
+                 -I ../libeg
+
+OPTIMFLAGS      = -fno-strict-aliasing -mno-red-zone -Wno-address -Os
+DEBUGFLAGS      = -Wall -Wno-missing-braces -Wno-array-bounds -ffunction-sections -fdata-sections
+CFLAGS          = $(OPTIMFLAGS) -g -fshort-wchar -fno-stack-protector $(DEBUGFLAGS) -c
+
+prefix          = /usr/bin/
+CC              = $(prefix)gcc
+AS              = $(prefix)as
+LD              = $(prefix)ld
+AR              = $(prefix)ar
+RANLIB          = $(prefix)ranlib
+OBJCOPY         = $(prefix)objcopy
+GENFW           = $(EDK2BASE)/BaseTools/Source/C/bin/GenFw
+
+
+LDSCRIPT = $(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script
+
+LDFLAGS         = -nostdlib -n -q --gc-sections --script=$(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script \
+                  --entry efi_main -u efi_main
+
+%.obj: %.c
+       $(CC) $(ARCH_C_FLAGS) $(CFLAGS) $(INCLUDE_DIRS) -DNO_BUILTIN_VA_FUNCS -D__MAKEWITH_TIANO -c $< -o $@
+
+
index c21f2a86f8353a62149cf6cfee15b83958e592c3..d81ce19dbf640987870f58281826344dbdfe43f6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,21 +8,29 @@ OBJS=$(NAMES:=.o)
 HEADERS=$(NAMES:=.h)
 LOADER_DIR=refind
 FS_DIR=filesystems
 HEADERS=$(NAMES:=.h)
 LOADER_DIR=refind
 FS_DIR=filesystems
-LIB_DIR=libeg
+LIBEG_DIR=libeg
+EFILIB_DIR=EfiLib
 
 # Build rEFInd, including libeg
 all:
 
 # Build rEFInd, including libeg
 all:
-       make -C $(LIB_DIR)
+       make -C $(LIBEG_DIR)
        make -C $(LOADER_DIR)
 #      make -C $(FS_DIR)
 
 fs:
        make -C $(FS_DIR)
 
        make -C $(LOADER_DIR)
 #      make -C $(FS_DIR)
 
 fs:
        make -C $(FS_DIR)
 
+tiano:
+       make AR_TARGET=EfiLib -C $(EFILIB_DIR) -f Make.tiano
+       make AR_TARGET=libeg -C $(LIBEG_DIR) -f Make.tiano
+       make BUILDME=refind DLL_TARGET=refind -C $(LOADER_DIR) -f Make.tiano
+
 clean:
 clean:
-       make -C $(LIB_DIR) clean
+       make -C $(LIBEG_DIR) clean
        make -C $(LOADER_DIR) clean
        make -C $(LOADER_DIR) clean
+       make -C $(EFILIB_DIR) clean -f Make.tiano
        make -C $(FS_DIR) clean
        make -C $(FS_DIR) clean
+       rm -f include/*~
 
 # NOTE TO DISTRIBUTION MAINTAINERS:
 # The "install" target installs the program directly to the ESP
 
 # NOTE TO DISTRIBUTION MAINTAINERS:
 # The "install" target installs the program directly to the ESP
index b9ac7a7a8ad9ba8f2dca749470252a4b1caf43e3..254a9b7882744f21415ef14364df8606f20387ac 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,8 +1,20 @@
 0.4.3 (?/??/2012):
 ------------------
 
 0.4.3 (?/??/2012):
 ------------------
 
+- rEFInd now supports compilation using the TianoCore UDK2010/EDK2
+  development kit in addition to GNU-EFI.
+
+- Added new "use_graphics_for" option to control which OSes to boot in
+  graphics mode. (This effect lasts for a fraction of a second on most
+  systems, since the boot loader that rEFInd launches is likely to set
+  graphics or text mode itself.)
+
 - Filesystem drivers now work on EFI 1.x systems, such as Macs.
 
 - Filesystem drivers now work on EFI 1.x systems, such as Macs.
 
+- Removed "linux.conf" as a valid alternative name for "refind_linux.conf"
+  for holding Linux kernel options. The kernel developers plan to use
+  "linux.conf" themselves.
+
 0.4.2 (6/3/2012):
 -----------------
 
 0.4.2 (6/3/2012):
 -----------------
 
index 55aa2ba2ca2f9ff6e287b1340957d2914a741629..e7eaf51d6297f5300e2338fe16ecd2396b3afe42 100644 (file)
@@ -182,6 +182,11 @@ timeout 20
    <td>Two integer values</td>
    <td>Sets the video resolution used by rEFInd; takes a width and a height as options. For instance, <tt>resolution 1024 768</tt> sets the resolution to 1024x768. If you set a resolution that doesn't work on a UEFI-based system, rEFInd displays a message along with a list of valid modes. On an system built around EFI 1.<i>x</i> (such as a Mac), setting an incorrect resolution fails silently; you'll get the system's default resolution. You'll also get the system's default resolution if you set either resolution value to <tt>0</tt> or if you pass anything but two numbers. (Note that passing a resolution with an <tt>x</tt>, as in <tt>1024x768</tt>, will be interpreted as <i>one</i> option and so will cause the default resolution to be used.) Also, be aware that it is possible to set a valid resolution for your video card that's invalid for your monitor. If you do this, your monitor will go blank until you've booted an OS that resets the video mode.</td>
 </tr>
    <td>Two integer values</td>
    <td>Sets the video resolution used by rEFInd; takes a width and a height as options. For instance, <tt>resolution 1024 768</tt> sets the resolution to 1024x768. If you set a resolution that doesn't work on a UEFI-based system, rEFInd displays a message along with a list of valid modes. On an system built around EFI 1.<i>x</i> (such as a Mac), setting an incorrect resolution fails silently; you'll get the system's default resolution. You'll also get the system's default resolution if you set either resolution value to <tt>0</tt> or if you pass anything but two numbers. (Note that passing a resolution with an <tt>x</tt>, as in <tt>1024x768</tt>, will be interpreted as <i>one</i> option and so will cause the default resolution to be used.) Also, be aware that it is possible to set a valid resolution for your video card that's invalid for your monitor. If you do this, your monitor will go blank until you've booted an OS that resets the video mode.</td>
 </tr>
+<tr>
+   <td><tt>use_graphics_for</tt></td>
+   <td><tt>osx</tt>, <tt>linux</tt>, <tt>elilo</tt>, <tt>grub</tt>, and <tt>windows</tt></td>
+   <td>Ordinarily, rEFInd clears the screen and displays basic boot information when launching any OS but Mac OS X. For OS X, the default behavior is to clear the screen to the default background color and display no information. You can specify the simpler Mac-style behavior by specifying the OSes or boot loaders you want to work this way with this option. (OSes that should use text-mode displays should be omitted from this list.) Note that this option doesn't affect what the boot loader does; it may display graphics, text, or nothing at all. Thus, the effect of this option is likely to last for just a fraction of a second. On at least one firmware (used on some Gigabyte boards), setting <tt>use_graphics_for linux</tt> is required to avoid a system hang when launching Linux via its EFI stub loader.</td>
+</tr>
 <tr>
    <td><tt>scan_driver_dirs</tt></td>
    <td>directory path(s)</td>
 <tr>
    <td><tt>scan_driver_dirs</tt></td>
    <td>directory path(s)</td>
index 1c5872b6da309936afd0428b54abacd118f43d82..7a5de978c0cc5c8ee26f97db7991898d424f4a04 100644 (file)
@@ -27,7 +27,7 @@ endif
 
 EDK2BASE = /usr/local/UDK2010/MyWorkSpace
 
 
 EDK2BASE = /usr/local/UDK2010/MyWorkSpace
 
-# Below file defines TARGET (RELEASE or DEBUG), TARGET_ARCH (X64 or IA32), and TOOL_CHAIN_TAG (GCC44, GCC45, GCC46, or GCC47)
+# Below file defines TARGET (RELEASE or DEBUG), TARGET_ARCH (X64 or IA32), and TOOL_CHAIN_TAG (GCC44, GCC45, or GCC46)
 include $(EDK2BASE)/Conf/target.txt
 
 EFILIB          = $(EDK2BASE)/Build/MdeModule/$(TARGET)_$(TOOL_CHAIN_TAG)/$(TARGET_ARCH)/MdePkg/Library
 include $(EDK2BASE)/Conf/target.txt
 
 EFILIB          = $(EDK2BASE)/Build/MdeModule/$(TARGET)_$(TOOL_CHAIN_TAG)/$(TARGET_ARCH)/MdePkg/Library
index 9b1f5c131a32c5ffeda0edada57e352fad65f26f..49b0b7fa4e21e9127e94edaa0fff0b6c2241f600 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __REFIT_CALL_WRAPPER_H__
 #define __REFIT_CALL_WRAPPER_H__
 
 #ifndef __REFIT_CALL_WRAPPER_H__
 #define __REFIT_CALL_WRAPPER_H__
 
+#ifdef __MAKEWITH_GNUEFI
+
 #ifdef EFIX64
 # define refit_call1_wrapper(f, a1) \
   uefi_call_wrapper(f, 1, (UINT64)(a1))
 #ifdef EFIX64
 # define refit_call1_wrapper(f, a1) \
   uefi_call_wrapper(f, 1, (UINT64)(a1))
   uefi_call_wrapper(f, 10, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
 #endif
 
   uefi_call_wrapper(f, 10, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
 #endif
 
+#else /* not GNU EFI -- TianoCore EDK2 */
+
+#define refit_call1_wrapper(f, a1) \
+        f(a1)
+#define refit_call2_wrapper(f, a1, a2) \
+        f(a1, a2)
+#define refit_call3_wrapper(f, a1, a2, a3) \
+        f(a1, a2, a3)
+#define refit_call4_wrapper(f, a1, a2, a3, a4) \
+        f(a1, a2, a3, a4)
+#define refit_call5_wrapper(f, a1, a2, a3, a4, a5) \
+        f(a1, a2, a3, a4, a5)
+#define refit_call6_wrapper(f, a1, a2, a3, a4, a5, a6) \
+        f(a1, a2, a3, a4, a5, a6)
+#define refit_call7_wrapper(f, a1, a2, a3, a4, a5, a6, a7) \
+        f(a1, a2, a3, a4, a5, a6, a7)
+#define refit_call8_wrapper(f, a1, a2, a3, a4, a5, a6, a7, a8) \
+        f(a1, a2, a3, a4, a5, a6, a7, a8)
+#define refit_call9_wrapper(f, a1, a2, a3, a4, a5, a6, a7, a8, a9) \
+        f(a1, a2, a3, a4, a5, a6, a7, a8, a9)
+#define refit_call10_wrapper(f, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
+        f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
+
+#endif /* not GNU EFI -- TianoCore EDK2 */
+
 #endif /* !__REFIT_CALL_WRAPPER_H__ */
 
 #endif /* !__REFIT_CALL_WRAPPER_H__ */
 
diff --git a/libeg/Make.tiano b/libeg/Make.tiano
new file mode 100644 (file)
index 0000000..9b196c7
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# libeg/Make.tiano
+# Build control file for libeg components of rEFInd, using TianoCore EDK2
+#
+
+include ../Make.tiano
+
+SOURCE_NAMES     = image load_bmp load_icns screen text
+OBJS             = $(SOURCE_NAMES:=.obj)
+#DRIVERNAME      = ext2
+#BUILDME          = $(DRIVERNAME)_$(FILENAME_CODE).efi
+
+all: $(AR_TARGET)
+
+$(AR_TARGET): $(OBJS)
+       $(AR) -cr $(AR_TARGET).lib $(OBJS)
+
+clean:
+       make clean
index 271141fbcc99f1a8a4abbbad00e435d3bb9d2ec5..28d2472a40d0334c92d7732f2449b7b281d152d2 100644 (file)
 #include "libegint.h"
 #include "../refind/global.h"
 #include "../refind/lib.h"
 #include "libegint.h"
 #include "../refind/global.h"
 #include "../refind/lib.h"
-#include "refit_call_wrapper.h"
+#include "../refind/screen.h"
+#include "../include/refit_call_wrapper.h"
 
 #define MAX_FILE_SIZE (1024*1024*1024)
 
 
 #define MAX_FILE_SIZE (1024*1024*1024)
 
+#ifndef __MAKEWITH_GNUEFI
+#define LibLocateHandle gBS->LocateHandleBuffer
+#define LibOpenRoot EfiLibOpenRoot
+#endif
+
 //
 // Basic image handling
 //
 //
 // Basic image handling
 //
index 498db619b4f899d78cc5f8ba4af1ad17b3729e2d..89ddb740cdfda2d18c412428b17df98d9047f9b8 100644 (file)
@@ -37,6 +37,9 @@
 #ifndef __LIBEG_LIBEG_H__
 #define __LIBEG_LIBEG_H__
 
 #ifndef __LIBEG_LIBEG_H__
 #define __LIBEG_LIBEG_H__
 
+#ifndef __MAKEWITH_GNUEFI
+#include "../include/tiano_includes.h"
+#endif
 
 /* types */
 
 
 /* types */
 
index 1b2cff82f5ae9c08f55f1fc148cb2835196d8ec4..8c7f1e1a5825a902890c6ff71fe181109d0aa62a 100644 (file)
 #ifndef __LIBEG_LIBEGINT_H__
 #define __LIBEG_LIBEGINT_H__
 
 #ifndef __LIBEG_LIBEGINT_H__
 #define __LIBEG_LIBEGINT_H__
 
-
+#ifdef __MAKEWITH_GNUEFI
 #include <efi.h>
 #include <efilib.h>
 #include <efi.h>
 #include <efilib.h>
+#else
+#include "../include/tiano_includes.h"
+#endif
 
 #include "libeg.h"
 
 
 #include "libeg.h"
 
index d0092e5406949573b01a535ffaf02a7fcf7dc76b..9d29af66fc694a4e574f615bca43792e48eadf44 100644 (file)
@@ -38,6 +38,7 @@
 
 // BMP structures
 
 
 // BMP structures
 
+#ifdef __MAKEWITH_GNUEFI
 #pragma pack(1)
 
 typedef struct {
 #pragma pack(1)
 
 typedef struct {
@@ -67,6 +68,7 @@ typedef struct {
 } BMP_IMAGE_HEADER;
 
 #pragma pack()
 } BMP_IMAGE_HEADER;
 
 #pragma pack()
+#endif
 
 //
 // Load BMP image
 
 //
 // Load BMP image
index fd441febe9e5821d439a9f473786b31c167b9694..b3327042c013ff8e25f7cc52a36e865d676ca52e 100644 (file)
 
 #include "libegint.h"
 #include "../refind/screen.h"
 
 #include "libegint.h"
 #include "../refind/screen.h"
-#include "refit_call_wrapper.h"
+#include "../include/refit_call_wrapper.h"
 
 #include <efiUgaDraw.h>
 #include <efiConsoleControl.h>
 
 
 #include <efiUgaDraw.h>
 #include <efiConsoleControl.h>
 
+#ifndef __MAKEWITH_GNUEFI
+#define LibLocateProtocol EfiLibLocateProtocol
+#endif
+
 // Console defines and variables
 
 static EFI_GUID ConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
 // Console defines and variables
 
 static EFI_GUID ConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
@@ -168,13 +172,17 @@ VOID egGetScreenSize(OUT UINTN *ScreenWidth, OUT UINTN *ScreenHeight)
 
 CHAR16 * egScreenDescription(VOID)
 {
 
 CHAR16 * egScreenDescription(VOID)
 {
+    CHAR16 *Temp;
+
     if (egHasGraphics) {
         if (GraphicsOutput != NULL) {
     if (egHasGraphics) {
         if (GraphicsOutput != NULL) {
-            return PoolPrint(L"Graphics Output (UEFI), %dx%d",
-                             egScreenWidth, egScreenHeight);
+            Temp = AllocateZeroPool(256 * sizeof(CHAR16));
+            SPrint(Temp, 255, L"Graphics Output (UEFI), %dx%d", egScreenWidth, egScreenHeight);
+            return Temp;
         } else if (UgaDraw != NULL) {
         } else if (UgaDraw != NULL) {
-            return PoolPrint(L"UGA Draw (EFI 1.10), %dx%d",
-                             egScreenWidth, egScreenHeight);
+            Temp = AllocateZeroPool(256 * sizeof(CHAR16));
+            SPrint(Temp, 255, L"UGA Draw (EFI 1.10), %dx%d", egScreenWidth, egScreenHeight);
+            return Temp;
         } else {
             return L"Internal Error";
         }
         } else {
             return L"Internal Error";
         }
index bfdeaa110b24f1eaa29b508e4dd5877ae60fc1e3..bfe36846cea93a96def5b15bb044141db22897bd 100644 (file)
@@ -67,6 +67,24 @@ timeout 20
 #
 #resolution 1024 768
 
 #
 #resolution 1024 768
 
+# Launch specified OSes in graphics mode. By default, rEFInd switches
+# to text mode and displays basic pre-launch information when launching
+# all OSes except OS X. Using graphics mode can produce a more seamless
+# transition, but displays no information, which can make matters
+# difficult if you must debug a problem. Also, on at least one known
+# computer, using graphics mode prevents a crash when using the Linux
+# kernel's EFI stub loader. You can specify an empty list to boot all
+# OSes in text mode.
+# Valid options:
+#   osx     - Mac OS X
+#   linux   - A Linux kernel with EFI stub loader
+#   elilo   - The ELILO boot loader
+#   grub    - The GRUB (Legacy or 2) boot loader
+#   windows - Microsoft Windows
+# Default value: osx
+#
+#use_graphics_for osx,linux
+
 # Which non-bootloader tools to show on the tools line, and in what
 # order to display them:
 #  shell     - the EFI shell
 # Which non-bootloader tools to show on the tools line, and in what
 # order to display them:
 #  shell     - the EFI shell
diff --git a/refind/AutoGen.c b/refind/AutoGen.c
new file mode 100644 (file)
index 0000000..6f83c03
--- /dev/null
@@ -0,0 +1,282 @@
+/**
+  DO NOT EDIT
+  FILE auto-generated
+  Module name:
+    AutoGen.c
+  Abstract:       Auto-generated AutoGen.c for building module or library.
+**/
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiApplicationEntryPoint.h>
+#include "AutoGen.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = {0xB8448DD1, 0xB146, 0x41B7, {0x9D, 0x66, 0x98, 0xB3, 0xA0, 0xA4, 0x04, 0xD3}};
+
+// Guids
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAcpiTableGuid = { 0x8868E871, 0xE4F1, 0x11D3, { 0xBC, 0x22, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAcpi10TableGuid = { 0xEB9D2D30, 0x2D88, 0x11D3, { 0x9A, 0x16, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAcpi20TableGuid = { 0x8868E871, 0xE4F1, 0x11D3, { 0xBC, 0x22, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDxeServicesTableGuid = { 0x05AD34BA, 0x6F02, 0x4214, { 0x95, 0x2E, 0x4D, 0xA0, 0x39, 0x8E, 0x2B, 0xB9 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiEventReadyToBootGuid = { 0x7CE88FB3, 0x4BD7, 0x4679, { 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, 0x0D, 0x2B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiEventVirtualAddressChangeGuid = { 0x13FA7698, 0xC831, 0x49C7, { 0x87, 0xEA, 0x8F, 0x43, 0xFC, 0xC2, 0x51, 0x96 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiEventExitBootServicesGuid = { 0x27ABF055, 0xB1B8, 0x4C26, { 0x80, 0x48, 0x74, 0x8F, 0x37, 0xBA, 0xA2, 0xDF }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiFileInfoGuid = { 0x09576E92, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiFileSystemInfoGuid = { 0x09576E93, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = { 0xDB47D7D3, 0xFE81, 0x11D3, { 0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiGlobalVariableGuid = { 0x8BE4DF61, 0x93CA, 0x11D2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiPartTypeLegacyMbrGuid = { 0x024DEE41, 0x33E7, 0x11D3, { 0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiPartTypeSystemPartGuid = { 0xC12A7328, 0xF81F, 0x11D2, { 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSmbiosTableGuid = { 0xEB9D2D31, 0x2D88, 0x11D3, { 0x9A, 0x16, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSasDevicePathGuid = { 0xd487ddb4, 0x008b, 0x11d9, { 0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMdePkgTokenSpaceGuid = { 0x914AEBE7, 0x4635, 0x459b, { 0xAA, 0x1C, 0x11, 0xE2, 0x19, 0xB0, 0x3A, 0x10 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiEventLegacyBootGuid = { 0x2A571201, 0x4966, 0x47F6, { 0x8B, 0x86, 0xF3, 0x1E, 0x41, 0xF3, 0x2F, 0x10 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobListGuid = { 0x7739F24C, 0x93D7, 0x11D4, { 0x9A, 0x3A, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+
+// Protocols
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiComponentName2ProtocolGuid = { 0x6A7A5CFF, 0xE8D9, 0x4F70, { 0xBA, 0xDA, 0x75, 0xAB, 0x30, 0x25, 0xCE, 0x14 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8B843E20, 0x8132, 0x4852, { 0x90, 0xCC, 0x55, 0x1A, 0x4E, 0x4A, 0x7F, 0x1C }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSimpleFileSystemProtocolGuid = { 0x964E5B22, 0x6459, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSimpleTextInProtocolGuid = { 0x387477C1, 0x69C7, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSimpleTextInputExProtocolGuid = {0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSimpleTextOutProtocolGuid = { 0x387477C2, 0x69C7, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUnicodeCollationProtocolGuid = { 0x1D85CD7F, 0xF43D, 0x11D2, { 0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUnicodeCollation2ProtocolGuid = {0xa4c751fc, 0x23ae, 0x4c3e, { 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAcpiS3SaveProtocolGuid = { 0x125F2DE1, 0xFB85, 0x440C, { 0xA5, 0x4C, 0x4D, 0x99, 0x35, 0x8A, 0x8D, 0x38 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiBlockIoProtocolGuid = { 0x964E5B21, 0x6459, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCpuArchProtocolGuid = { 0x26BACCB1, 0x6F42, 0x11D4, { 0xBC, 0xE7, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDebugPortProtocolGuid = { 0xEBA4E8D2, 0x3858, 0x41EC, { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathProtocolGuid = { 0x09576E91, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDiskIoProtocolGuid = { 0xCE345171, 0xBA0B, 0x11D2, { 0x8E, 0x4F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x143b7632, 0xb81b, 0x4cb7, {0xab, 0xd3, 0xb6, 0x25, 0xa5, 0xb9, 0xbf, 0xfe }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiFirmwareVolume2ProtocolGuid = { 0x220e73b6, 0x6bdb, 0x4413, { 0x84, 0x5, 0xb9, 0x74, 0xb1, 0x8, 0x61, 0x9a } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiGraphicsOutputProtocolGuid = { 0x9042A9DE, 0x23DC, 0x4A38, { 0x96, 0xFB, 0x7A, 0xDE, 0xD0, 0x80, 0x51, 0x6A }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHiiFontProtocolGuid = {0xe9ca4775, 0x8657, 0x47fc, {0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x08, 0x43, 0x24}};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiLegacy8259ProtocolGuid = { 0x38321dba, 0x4fe0, 0x4e17, { 0x8a, 0xec, 0x41, 0x30, 0x55, 0xea, 0xed, 0xc1 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiLoadedImageProtocolGuid = { 0x5B1B31A1, 0x9562, 0x11D2, { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiOEMBadgingProtocolGuid = { 0x170E13C0, 0xBF1B, 0x4218, { 0x87, 0x1D, 0x2A, 0xBD, 0xC6, 0xF8, 0x87, 0xBC }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiPciIoProtocolGuid = { 0x4CF5B200, 0x68B8, 0x4CA5, { 0x9E, 0xEC, 0xB2, 0x3E, 0x3F, 0x50, 0x02, 0x9A }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiScsiIoProtocolGuid = { 0x932F47e6, 0x2362, 0x4002, { 0x80, 0x3E, 0x3C, 0xD5, 0x4B, 0x13, 0x8F, 0x85 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiScsiPassThruProtocolGuid = { 0xA59E8FCF, 0xBDA0, 0x43BB, { 0x90, 0xB1, 0xD3, 0x73, 0x2E, 0xCA, 0xA8, 0x77 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSimpleNetworkProtocolGuid = { 0xA19832B9, 0xAC25, 0x11D3, { 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUgaDrawProtocolGuid = { 0x982C298B, 0xF4FA, 0x41CB, { 0xB8, 0x38, 0x77, 0xAA, 0x68, 0x8F, 0xB8, 0x39 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAbsolutePointerProtocolGuid = { 0x8D59D32B, 0xC655, 0x4AE9, { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAcpiTableProtocolGuid = { 0xFFE06BDD, 0x6107, 0x46A6, { 0x7B, 0xB2, 0x5A, 0x9C, 0x7E, 0xC5, 0x27, 0x5C }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiEdidActiveProtocolGuid = { 0xBD8C1056, 0x9F36, 0x44EC, { 0x92, 0xA8, 0xA6, 0x33, 0x7F, 0x81, 0x79, 0x86 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiEdidDiscoveredProtocolGuid = { 0x1C0C34F6, 0xD380, 0x41FA, { 0xA0, 0x49, 0x8A, 0xD0, 0x6C, 0x1A, 0x66, 0xAA }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHiiDatabaseProtocolGuid = {0xef9fc172, 0xa1b2, 0x4693, {0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42}};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHiiImageProtocolGuid = {0x31a6406a, 0x6bdf, 0x4e46, {0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x09, 0x20}};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHiiProtocolGuid = { 0xd7ad636e, 0xb997, 0x459b, { 0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 0xe1 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSimplePointerProtocolGuid = { 0x31878C87, 0x0B75, 0x11D5, { 0x9A, 0x4F, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSmbiosProtocolGuid = {0x3583ff6, 0xcb36, 0x4940, { 0x94, 0x7e, 0xb9, 0xb3, 0x9f, 0x4a, 0xfa, 0xf7}};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiSecurityArchProtocolGuid = { 0xA46423E3, 0x4617, 0x49F1, { 0xB9, 0xFF, 0xD1, 0xBF, 0xA9, 0x11, 0x58, 0x39 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDriverBindingProtocolGuid = { 0x18A031AB, 0xB443, 0x4D1A, { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiComponentNameProtocolGuid = { 0x107A772C, 0xD5E1, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDriverConfigurationProtocolGuid = { 0x107A772B, 0xD5E1, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDriverConfiguration2ProtocolGuid = { 0xBFD7DC1D, 0x24F1, 0x40D9, { 0x82, 0xE7, 0x2E, 0x09, 0xBB, 0x6B, 0x4E, 0xBE }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDriverDiagnosticsProtocolGuid = { 0x0784924F, 0xE296, 0x11D4, { 0x9A, 0x49, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDriverDiagnostics2ProtocolGuid = { 0x4D330321, 0x025F, 0x4AAC, { 0x90, 0xD8, 0x5E, 0xD9, 0x00, 0x17, 0x3B, 0x63 }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiLoadFileProtocolGuid = { 0x56EC3091, 0x954C, 0x11D2, { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiLoadFile2ProtocolGuid = { 0x4006c0c1, 0xfcb3, 0x403e, {0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d }};
+
+// Definition of PCDs used in this module
+GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdUgaConsumeSupport = _PCD_VALUE_PcdUgaConsumeSupport;
+
+// Definition of PCDs used in libraries
+
+#define _PCD_TOKEN_PcdDebugPrintErrorLevel  5U
+#define _PCD_VALUE_PcdDebugPrintErrorLevel  0x80000000U
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPcd_FixedAtBuild_PcdDebugPrintErrorLevel = _PCD_VALUE_PcdDebugPrintErrorLevel;
+extern const  UINT32  _gPcd_FixedAtBuild_PcdDebugPrintErrorLevel;
+#define _PCD_GET_MODE_32_PcdDebugPrintErrorLevel  _gPcd_FixedAtBuild_PcdDebugPrintErrorLevel
+//#define _PCD_SET_MODE_32_PcdDebugPrintErrorLevel  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdDebugClearMemoryValue  10U
+#define _PCD_VALUE_PcdDebugClearMemoryValue  0xAFU
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdDebugClearMemoryValue = _PCD_VALUE_PcdDebugClearMemoryValue;
+extern const  UINT8  _gPcd_FixedAtBuild_PcdDebugClearMemoryValue;
+#define _PCD_GET_MODE_8_PcdDebugClearMemoryValue  _gPcd_FixedAtBuild_PcdDebugClearMemoryValue
+//#define _PCD_SET_MODE_8_PcdDebugClearMemoryValue  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdDebugPropertyMask  11U
+#define _PCD_VALUE_PcdDebugPropertyMask  0x0fU
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdDebugPropertyMask = _PCD_VALUE_PcdDebugPropertyMask;
+extern const  UINT8  _gPcd_FixedAtBuild_PcdDebugPropertyMask;
+#define _PCD_GET_MODE_8_PcdDebugPropertyMask  _gPcd_FixedAtBuild_PcdDebugPropertyMask
+//#define _PCD_SET_MODE_8_PcdDebugPropertyMask  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdMaximumLinkedListLength  6U
+#define _PCD_VALUE_PcdMaximumLinkedListLength  1000000U
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPcd_FixedAtBuild_PcdMaximumLinkedListLength = _PCD_VALUE_PcdMaximumLinkedListLength;
+extern const  UINT32  _gPcd_FixedAtBuild_PcdMaximumLinkedListLength;
+#define _PCD_GET_MODE_32_PcdMaximumLinkedListLength  _gPcd_FixedAtBuild_PcdMaximumLinkedListLength
+//#define _PCD_SET_MODE_32_PcdMaximumLinkedListLength  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdMaximumAsciiStringLength  7U
+#define _PCD_VALUE_PcdMaximumAsciiStringLength  1000000U
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength = _PCD_VALUE_PcdMaximumAsciiStringLength;
+extern const  UINT32  _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength;
+#define _PCD_GET_MODE_32_PcdMaximumAsciiStringLength  _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength
+//#define _PCD_SET_MODE_32_PcdMaximumAsciiStringLength  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdMaximumUnicodeStringLength  8U
+#define _PCD_VALUE_PcdMaximumUnicodeStringLength  1000000U
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength = _PCD_VALUE_PcdMaximumUnicodeStringLength;
+extern const  UINT32  _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength;
+#define _PCD_GET_MODE_32_PcdMaximumUnicodeStringLength  _gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength
+//#define _PCD_SET_MODE_32_PcdMaximumUnicodeStringLength  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdVerifyNodeInList  9U
+#define _PCD_VALUE_PcdVerifyNodeInList  ((BOOLEAN)0U)
+GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdVerifyNodeInList = _PCD_VALUE_PcdVerifyNodeInList;
+extern const  BOOLEAN  _gPcd_FixedAtBuild_PcdVerifyNodeInList;
+#define _PCD_GET_MODE_BOOL_PcdVerifyNodeInList  _gPcd_FixedAtBuild_PcdVerifyNodeInList
+//#define _PCD_SET_MODE_BOOL_PcdVerifyNodeInList  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdDriverDiagnosticsDisable  12U
+#define _PCD_VALUE_PcdDriverDiagnosticsDisable  ((BOOLEAN)0U)
+GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdDriverDiagnosticsDisable = _PCD_VALUE_PcdDriverDiagnosticsDisable;
+extern const  BOOLEAN  _gPcd_FixedAtBuild_PcdDriverDiagnosticsDisable;
+#define _PCD_GET_MODE_BOOL_PcdDriverDiagnosticsDisable  _gPcd_FixedAtBuild_PcdDriverDiagnosticsDisable
+//#define _PCD_SET_MODE_BOOL_PcdDriverDiagnosticsDisable  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdComponentNameDisable  13U
+#define _PCD_VALUE_PcdComponentNameDisable  ((BOOLEAN)0U)
+GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdComponentNameDisable = _PCD_VALUE_PcdComponentNameDisable;
+extern const  BOOLEAN  _gPcd_FixedAtBuild_PcdComponentNameDisable;
+#define _PCD_GET_MODE_BOOL_PcdComponentNameDisable  _gPcd_FixedAtBuild_PcdComponentNameDisable
+//#define _PCD_SET_MODE_BOOL_PcdComponentNameDisable  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdDriverDiagnostics2Disable  14U
+#define _PCD_VALUE_PcdDriverDiagnostics2Disable  ((BOOLEAN)1U)
+GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdDriverDiagnostics2Disable = _PCD_VALUE_PcdDriverDiagnostics2Disable;
+extern const  BOOLEAN  _gPcd_FixedAtBuild_PcdDriverDiagnostics2Disable;
+#define _PCD_GET_MODE_BOOL_PcdDriverDiagnostics2Disable  _gPcd_FixedAtBuild_PcdDriverDiagnostics2Disable
+//#define _PCD_SET_MODE_BOOL_PcdDriverDiagnostics2Disable  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdComponentName2Disable  15U
+#define _PCD_VALUE_PcdComponentName2Disable  ((BOOLEAN)1U)
+GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdComponentName2Disable = _PCD_VALUE_PcdComponentName2Disable;
+extern const  BOOLEAN  _gPcd_FixedAtBuild_PcdComponentName2Disable;
+#define _PCD_GET_MODE_BOOL_PcdComponentName2Disable  _gPcd_FixedAtBuild_PcdComponentName2Disable
+//#define _PCD_SET_MODE_BOOL_PcdComponentName2Disable  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+#define _PCD_TOKEN_PcdUefiLibMaxPrintBufferSize  17U
+#define _PCD_VALUE_PcdUefiLibMaxPrintBufferSize  320U
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPcd_FixedAtBuild_PcdUefiLibMaxPrintBufferSize = _PCD_VALUE_PcdUefiLibMaxPrintBufferSize;
+extern const  UINT32  _gPcd_FixedAtBuild_PcdUefiLibMaxPrintBufferSize;
+#define _PCD_GET_MODE_32_PcdUefiLibMaxPrintBufferSize  _gPcd_FixedAtBuild_PcdUefiLibMaxPrintBufferSize
+//#define _PCD_SET_MODE_32_PcdUefiLibMaxPrintBufferSize  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+
+EFI_STATUS
+EFIAPI
+UefiBootServicesTableLibConstructor (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  );
+
+EFI_STATUS
+EFIAPI
+UefiRuntimeServicesTableLibConstructor (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  );
+
+EFI_STATUS
+EFIAPI
+UefiLibConstructor (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  );
+
+EFI_STATUS
+EFIAPI
+DxeServicesTableLibConstructor (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  );
+
+EFI_STATUS
+EFIAPI
+HobLibConstructor (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  );
+
+
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = UefiLibConstructor (ImageHandle, SystemTable);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = HobLibConstructor (ImageHandle, SystemTable);
+  ASSERT_EFI_ERROR (Status);
+
+}
+
+
+
+VOID
+EFIAPI
+ProcessLibraryDestructorList (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+
+}
+
+const UINT32 _gUefiDriverRevision = 0x00010000U;
+
+
+EFI_STATUS
+EFIAPI
+ProcessModuleEntryPointList (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+
+{
+  return efi_main (ImageHandle, SystemTable);
+}
+
+VOID
+EFIAPI
+ExitDriver (
+  IN EFI_STATUS  Status
+  )
+{
+  if (EFI_ERROR (Status)) {
+    ProcessLibraryDestructorList (gImageHandle, gST);
+  }
+  gBS->Exit (gImageHandle, Status, 0, NULL);
+}
+
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = 0U;
+
+EFI_STATUS
+EFIAPI
+ProcessModuleUnloadList (
+  IN EFI_HANDLE        ImageHandle
+  )
+{
+  return EFI_SUCCESS;
+}
diff --git a/refind/AutoGen.h b/refind/AutoGen.h
new file mode 100644 (file)
index 0000000..a07912e
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+  DO NOT EDIT
+  FILE auto-generated
+  Module name:
+    AutoGen.h
+  Abstract:       Auto-generated AutoGen.h for building module or library.
+**/
+
+#ifndef _AUTOGENH_B8448DD1_B146_41B7_9D66_98B3A0A404D3
+#define _AUTOGENH_B8448DD1_B146_41B7_9D66_98B3A0A404D3
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <Base.h>
+#include <Uefi.h>
+#include <Library/PcdLib.h>
+
+extern GUID  gEfiCallerIdGuid;
+
+#define EFI_CALLER_ID_GUID \
+  {0xB8448DD1, 0xB146, 0x41B7, {0x9D, 0x66, 0x98, 0xB3, 0xA0, 0xA4, 0x04, 0xD3}}
+
+// Definition of PCDs used in this module
+
+#define _PCD_TOKEN_PcdUgaConsumeSupport  16U
+#define _PCD_VALUE_PcdUgaConsumeSupport  ((BOOLEAN)1U)
+extern const  BOOLEAN  _gPcd_FixedAtBuild_PcdUgaConsumeSupport;
+#define _PCD_GET_MODE_BOOL_PcdUgaConsumeSupport  _gPcd_FixedAtBuild_PcdUgaConsumeSupport
+//#define _PCD_SET_MODE_BOOL_PcdUgaConsumeSupport  ASSERT(FALSE)  // It is not allowed to set value for a FIXED_AT_BUILD PCD
+
+// Definition of PCDs used in libraries is in AutoGen.c
+
+
+EFI_STATUS
+EFIAPI
+efi_main (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  );
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/refind/Make.tiano b/refind/Make.tiano
new file mode 100644 (file)
index 0000000..fd9f444
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# refind/Make.tiano
+# Build control file for rEFInd, using TianoCore EDK2
+# Requires that EfiLib and libeg subdirectories be built before this
+# file is used.
+#
+
+include ../Make.tiano
+
+EFILIB          = $(EDK2BASE)/Build/MdeModule/$(TARGET)_$(TOOL_CHAIN_TAG)/$(TARGET_ARCH)/MdePkg/Library
+ALL_EFILIBS     = $(EFILIB)/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib/OUTPUT/BaseDebugPrintErrorLevelLib.lib \
+                  $(EFILIB)/BasePrintLib/BasePrintLib/OUTPUT/BasePrintLib.lib \
+                  $(EFILIB)/BasePcdLibNull/BasePcdLibNull/OUTPUT/BasePcdLibNull.lib \
+                  $(EFILIB)/UefiDebugLibStdErr/UefiDebugLibStdErr/OUTPUT/UefiDebugLibStdErr.lib \
+                  $(EFILIB)/BaseLib/BaseLib/OUTPUT/BaseLib.lib \
+                  $(EFILIB)/BaseMemoryLib/BaseMemoryLib/OUTPUT/BaseMemoryLib.lib \
+                  $(EFILIB)/UefiBootServicesTableLib/UefiBootServicesTableLib/OUTPUT/UefiBootServicesTableLib.lib \
+                  $(EFILIB)/UefiMemoryAllocationLib/UefiMemoryAllocationLib/OUTPUT/UefiMemoryAllocationLib.lib \
+                  $(EFILIB)/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib/OUTPUT/UefiRuntimeServicesTableLib.lib \
+                  $(EFILIB)/UefiDevicePathLib/UefiDevicePathLib/OUTPUT/UefiDevicePathLib.lib \
+                  $(EFILIB)/UefiLib/UefiLib/OUTPUT/UefiLib.lib \
+                  $(EFILIB)/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull/OUTPUT/PeCoffExtraActionLibNull.lib \
+                  $(EFILIB)/UefiApplicationEntryPoint/UefiApplicationEntryPoint/OUTPUT/UefiApplicationEntryPoint.lib \
+                  $(EFILIB)/DxeServicesLib/DxeServicesLib/OUTPUT/DxeServicesLib.lib \
+                  $(EFILIB)/DxeServicesTableLib/DxeServicesTableLib/OUTPUT/DxeServicesTableLib.lib \
+                  $(EFILIB)/DxeHobLib/DxeHobLib/OUTPUT/DxeHobLib.lib \
+                  $(EFILIB)/BaseIoLibIntrinsic/BaseIoLibIntrinsic/OUTPUT/BaseIoLibIntrinsic.lib \
+                  $(EFILIB)/BasePeCoffLib/BasePeCoffLib/OUTPUT/BasePeCoffLib.lib
+
+
+SOURCE_NAMES     = config driver_support icns lib main menu screen AutoGen
+OBJS             = $(SOURCE_NAMES:=.obj)
+
+all: $(BUILDME)
+
+$(AR_TARGET): $(OBJS)
+       $(AR) -cr $(AR_TARGET).lib $(OBJS)
+
+$(DLL_TARGET)_$(FILENAME_CODE).dll: $(OBJS) ../libeg/libeg.lib ../EfiLib/EfiLib.lib 
+       $(LD) -o $(DLL_TARGET)_$(FILENAME_CODE).dll $(LDFLAGS) --start-group $(ALL_EFILIBS) $(OBJS) ../libeg/libeg.lib ../EfiLib/EfiLib.lib --end-group
+
+$(BUILDME): $(DLL_TARGET)_$(FILENAME_CODE).dll
+       $(OBJCOPY) --strip-unneeded $(DLL_TARGET)_$(FILENAME_CODE).dll
+       $(GENFW) -e UEFI_APPLICATION -o $(BUILDME)_$(FILENAME_CODE).efi $(DLL_TARGET)_$(FILENAME_CODE).dll
+
+clean:
+       make clean
index 63b0a22734937a2041505a44cd7ff54c1e9620f0..eb5040c5b59085db4b5eb61f1983d635f5c451ea 100644 (file)
 #include "menu.h"
 #include "config.h"
 #include "screen.h"
 #include "menu.h"
 #include "config.h"
 #include "screen.h"
-#include "refit_call_wrapper.h"
+#include "../include/refit_call_wrapper.h"
 
 // constants
 
 #define CONFIG_FILE_NAME         L"refind.conf"
 
 // constants
 
 #define CONFIG_FILE_NAME         L"refind.conf"
-#define LINUX_OPTIONS_FILENAMES  L"refind_linux.conf,refind-linux.conf,linux.conf"
+#define LINUX_OPTIONS_FILENAMES  L"refind_linux.conf,refind-linux.conf"
 #define MAXCONFIGFILESIZE        (128*1024)
 
 #define ENCODING_ISO8859_1  (0)
 #define MAXCONFIGFILESIZE        (128*1024)
 
 #define ENCODING_ISO8859_1  (0)
@@ -405,6 +405,22 @@ VOID ReadConfig(VOID)
            GlobalConfig.RequestedScreenWidth = Atoi(TokenList[1]);
            GlobalConfig.RequestedScreenHeight = Atoi(TokenList[2]);
 
            GlobalConfig.RequestedScreenWidth = Atoi(TokenList[1]);
            GlobalConfig.RequestedScreenHeight = Atoi(TokenList[2]);
 
+        } else if (StriCmp(TokenList[0], L"use_graphics_for") == 0) {
+           GlobalConfig.GraphicsFor = 0;
+           for (i = 1; i < TokenCount; i++) {
+              if (StriCmp(TokenList[i], L"osx")) {
+                 GlobalConfig.GraphicsFor |= GRAPHICS_FOR_OSX;
+              } else if (StriCmp(TokenList[i], L"linux")) {
+                 GlobalConfig.GraphicsFor |= GRAPHICS_FOR_LINUX;
+              } else if (StriCmp(TokenList[i], L"elilo")) {
+                 GlobalConfig.GraphicsFor |= GRAPHICS_FOR_ELILO;
+              } else if (StriCmp(TokenList[i], L"grub")) {
+                 GlobalConfig.GraphicsFor |= GRAPHICS_FOR_GRUB;
+              } else if (StriCmp(TokenList[i], L"windows")) {
+                 GlobalConfig.GraphicsFor |= GRAPHICS_FOR_WINDOWS;
+              }
+           } // for (graphics_on tokens)
+
         } else if (StriCmp(TokenList[0], L"scan_all_linux_kernels") == 0) {
            GlobalConfig.ScanAllLinux = TRUE;
 
         } else if (StriCmp(TokenList[0], L"scan_all_linux_kernels") == 0) {
            GlobalConfig.ScanAllLinux = TRUE;
 
@@ -433,11 +449,13 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu
    SubEntry->me.Title        = StrDuplicate(Title);
 
    while (((TokenCount = ReadTokenLine(File, &TokenList)) > 0) && (StriCmp(TokenList[0], L"}") != 0)) {
    SubEntry->me.Title        = StrDuplicate(Title);
 
    while (((TokenCount = ReadTokenLine(File, &TokenList)) > 0) && (StriCmp(TokenList[0], L"}") != 0)) {
+
       if ((StriCmp(TokenList[0], L"loader") == 0) && (TokenCount > 1)) { // set the boot loader filename
          if (SubEntry->LoaderPath != NULL)
             FreePool(SubEntry->LoaderPath);
          SubEntry->LoaderPath = StrDuplicate(TokenList[1]);
          SubEntry->DevicePath = FileDevicePath(Volume->DeviceHandle, SubEntry->LoaderPath);
       if ((StriCmp(TokenList[0], L"loader") == 0) && (TokenCount > 1)) { // set the boot loader filename
          if (SubEntry->LoaderPath != NULL)
             FreePool(SubEntry->LoaderPath);
          SubEntry->LoaderPath = StrDuplicate(TokenList[1]);
          SubEntry->DevicePath = FileDevicePath(Volume->DeviceHandle, SubEntry->LoaderPath);
+
       } else if (StriCmp(TokenList[0], L"initrd") == 0) {
          if (SubEntry->InitrdPath != NULL)
             FreePool(SubEntry->InitrdPath);
       } else if (StriCmp(TokenList[0], L"initrd") == 0) {
          if (SubEntry->InitrdPath != NULL)
             FreePool(SubEntry->InitrdPath);
@@ -445,6 +463,7 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu
          if (TokenCount > 1) {
             SubEntry->InitrdPath = StrDuplicate(TokenList[1]);
          }
          if (TokenCount > 1) {
             SubEntry->InitrdPath = StrDuplicate(TokenList[1]);
          }
+
       } else if (StriCmp(TokenList[0], L"options") == 0) {
          if (SubEntry->LoadOptions != NULL)
             FreePool(SubEntry->LoadOptions);
       } else if (StriCmp(TokenList[0], L"options") == 0) {
          if (SubEntry->LoadOptions != NULL)
             FreePool(SubEntry->LoadOptions);
@@ -452,15 +471,20 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu
          if (TokenCount > 1) {
             SubEntry->LoadOptions = StrDuplicate(TokenList[1]);
          } // if/else
          if (TokenCount > 1) {
             SubEntry->LoadOptions = StrDuplicate(TokenList[1]);
          } // if/else
+
       } else if ((StriCmp(TokenList[0], L"add_options") == 0) && (TokenCount > 1)) {
          MergeStrings(&SubEntry->LoadOptions, TokenList[1], L' ');
       } else if ((StriCmp(TokenList[0], L"add_options") == 0) && (TokenCount > 1)) {
          MergeStrings(&SubEntry->LoadOptions, TokenList[1], L' ');
+
       } else if ((StriCmp(TokenList[0], L"graphics") == 0) && (TokenCount > 1)) {
          SubEntry->UseGraphicsMode = (StriCmp(TokenList[1], L"on") == 0);
       } else if ((StriCmp(TokenList[0], L"graphics") == 0) && (TokenCount > 1)) {
          SubEntry->UseGraphicsMode = (StriCmp(TokenList[1], L"on") == 0);
+
       } else if (StriCmp(TokenList[0], L"disabled") == 0) {
          SubEntry->Enabled = FALSE;
       } // ief/elseif
       } else if (StriCmp(TokenList[0], L"disabled") == 0) {
          SubEntry->Enabled = FALSE;
       } // ief/elseif
+
       FreeTokenLine(&TokenList, &TokenCount);
    } // while()
       FreeTokenLine(&TokenList, &TokenCount);
    } // while()
+
    if (SubEntry->InitrdPath != NULL) {
       MergeStrings(&SubEntry->LoadOptions, L"initrd=", L' ');
       MergeStrings(&SubEntry->LoadOptions, SubEntry->InitrdPath, 0);
    if (SubEntry->InitrdPath != NULL) {
       MergeStrings(&SubEntry->LoadOptions, L"initrd=", L' ');
       MergeStrings(&SubEntry->LoadOptions, SubEntry->InitrdPath, 0);
@@ -522,7 +546,8 @@ static LOADER_ENTRY * AddStanzaEntries(REFIT_FILE *File, REFIT_VOLUME *Volume, C
       return NULL;
 
    Entry->Title           = StrDuplicate(Title);
       return NULL;
 
    Entry->Title           = StrDuplicate(Title);
-   Entry->me.Title        = PoolPrint(L"Boot %s from %s", (Title != NULL) ? Title : L"Unknown", CurrentVolume->VolName);
+   Entry->me.Title        = AllocateZeroPool(256 * sizeof(CHAR16));
+   SPrint(Entry->me.Title, 255, L"Boot %s from %s", (Title != NULL) ? Title : L"Unknown", CurrentVolume->VolName);
    Entry->me.Row          = 0;
    Entry->me.BadgeImage   = CurrentVolume->VolBadgeImage;
    Entry->VolName         = CurrentVolume->VolName;
    Entry->me.Row          = 0;
    Entry->me.BadgeImage   = CurrentVolume->VolBadgeImage;
    Entry->VolName         = CurrentVolume->VolName;
@@ -540,7 +565,8 @@ static LOADER_ENTRY * AddStanzaEntries(REFIT_FILE *File, REFIT_VOLUME *Volume, C
       } else if ((StriCmp(TokenList[0], L"volume") == 0) && (TokenCount > 1)) {
          if (FindVolume(&CurrentVolume, TokenList[1])) {
             FreePool(Entry->me.Title);
       } else if ((StriCmp(TokenList[0], L"volume") == 0) && (TokenCount > 1)) {
          if (FindVolume(&CurrentVolume, TokenList[1])) {
             FreePool(Entry->me.Title);
-            Entry->me.Title        = PoolPrint(L"Boot %s from %s", (Title != NULL) ? Title : L"Unknown", CurrentVolume->VolName);
+            Entry->me.Title        = AllocateZeroPool(256 * sizeof(CHAR16));
+            SPrint(Entry->me.Title, 255, L"Boot %s from %s", (Title != NULL) ? Title : L"Unknown", CurrentVolume->VolName);
             Entry->me.BadgeImage   = CurrentVolume->VolBadgeImage;
             Entry->VolName         = CurrentVolume->VolName;
          } // if match found
             Entry->me.BadgeImage   = CurrentVolume->VolBadgeImage;
             Entry->VolName         = CurrentVolume->VolName;
          } // if match found
index f1d4059c613f3a99736e9e11cc028ef9fa32b8f6..6da24192cc795cc5b6b86daa80825bba67ffc097 100644 (file)
 #ifndef __CONFIG_H_
 #define __CONFIG_H_
 
 #ifndef __CONFIG_H_
 #define __CONFIG_H_
 
+#ifdef __MAKEWITH_GNUEFI
 #include "efi.h"
 #include "efi.h"
+#else
+#include "../include/tiano_includes.h"
+#endif
 #include "global.h"
 
 //
 #include "global.h"
 
 //
index e04dd9d28db644afe0a2f90f6ae01b7a48ace3e0..000b410a8a28651c80e505dd9172b156f03b3c26 100644 (file)
@@ -19,8 +19,9 @@
  */
 
 #include "driver_support.h"
  */
 
 #include "driver_support.h"
-#include "refit_call_wrapper.h"
+#include "../include/refit_call_wrapper.h"
 
 
+#ifdef __MAKEWITH_GNUEFI
 // Following "global" constants are from EDK2's AutoGen.c....
 EFI_GUID gEfiLoadedImageProtocolGuid = { 0x5B1B31A1, 0x9562, 0x11D2, { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
 EFI_GUID gEfiDriverBindingProtocolGuid = { 0x18A031AB, 0xB443, 0x4D1A, { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71 }};
 // Following "global" constants are from EDK2's AutoGen.c....
 EFI_GUID gEfiLoadedImageProtocolGuid = { 0x5B1B31A1, 0x9562, 0x11D2, { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
 EFI_GUID gEfiDriverBindingProtocolGuid = { 0x18A031AB, 0xB443, 0x4D1A, { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71 }};
@@ -31,6 +32,7 @@ EFI_GUID gEfiDriverDiagnostics2ProtocolGuid = { 0x4D330321, 0x025F, 0x4AAC, { 0x
 EFI_GUID gEfiComponentNameProtocolGuid = { 0x107A772C, 0xD5E1, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
 EFI_GUID gEfiComponentName2ProtocolGuid = { 0x6A7A5CFF, 0xE8D9, 0x4F70, { 0xBA, 0xDA, 0x75, 0xAB, 0x30, 0x25, 0xCE, 0x14 }};
 EFI_GUID gEfiDevicePathProtocolGuid = { 0x09576E91, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
 EFI_GUID gEfiComponentNameProtocolGuid = { 0x107A772C, 0xD5E1, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }};
 EFI_GUID gEfiComponentName2ProtocolGuid = { 0x6A7A5CFF, 0xE8D9, 0x4F70, { 0xBA, 0xDA, 0x75, 0xAB, 0x30, 0x25, 0xCE, 0x14 }};
 EFI_GUID gEfiDevicePathProtocolGuid = { 0x09576E91, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+#endif
 
 // Below is from http://git.etherboot.org/?p=mirror/efi/shell/.git;a=commitdiff;h=b1b0c63423cac54dc964c2930e04aebb46a946ec;
 // Seems to have been replaced by ParseHandleDatabaseByRelationshipWithType(), but the latter isn't working for me....
 
 // Below is from http://git.etherboot.org/?p=mirror/efi/shell/.git;a=commitdiff;h=b1b0c63423cac54dc964c2930e04aebb46a946ec;
 // Seems to have been replaced by ParseHandleDatabaseByRelationshipWithType(), but the latter isn't working for me....
index 0c64f5e4d0d96b01d5dd00b508a52c03d91d7976..08405ebdb2f4c56b0fc708cb4003458e563d8046 100644 (file)
  *
  */
 
  *
  */
 
-#include <efi/efi.h>
+#ifdef __MAKEWITH_GNUEFI
+#include <efi.h>
 #include <efi/efilib.h>
 #include <efi/efilib.h>
+#else
+#include "../include/tiano_includes.h"
+#endif
+#include "global.h"
 
 #ifndef _DRIVER_SUPPORT
 #define _DRIVER_SUPPORT
 
 #ifndef _DRIVER_SUPPORT
 #define _DRIVER_SUPPORT
index b2b38b81c9f28d06ee73a3e5c6d4d889296edb30..905f79adf1e2019079b6deacfaaba51c90476b0b 100644 (file)
 #ifndef __GLOBAL_H_
 #define __GLOBAL_H_
 
 #ifndef __GLOBAL_H_
 #define __GLOBAL_H_
 
-#include "efi.h"
-#include "efilib.h"
+#ifdef __MAKEWITH_GNUEFI
+#include <efi.h>
+#include <efilib.h>
+#else
+#include "../include/tiano_includes.h"
+#endif
 
 #include "libeg.h"
 
 
 #include "libeg.h"
 
 
 #define DEFAULT_ICONS_DIR L"icons"
 
 
 #define DEFAULT_ICONS_DIR L"icons"
 
+// OS bit codes; used in GlobalConfig.GraphicsOn
+#define GRAPHICS_FOR_OSX        1
+#define GRAPHICS_FOR_LINUX      2
+#define GRAPHICS_FOR_ELILO      4
+#define GRAPHICS_FOR_GRUB       8
+#define GRAPHICS_FOR_WINDOWS   16
+
 //
 // global definitions
 //
 //
 // global definitions
 //
@@ -159,6 +170,7 @@ typedef struct {
    UINTN       Timeout;
    UINTN       HideUIFlags;
    UINTN       MaxTags;     // max. number of OS entries to show simultaneously in graphics mode
    UINTN       Timeout;
    UINTN       HideUIFlags;
    UINTN       MaxTags;     // max. number of OS entries to show simultaneously in graphics mode
+   UINTN       GraphicsFor;
    CHAR16      *BannerFileName;
    CHAR16      *SelectionSmallFileName;
    CHAR16      *SelectionBigFileName;
    CHAR16      *BannerFileName;
    CHAR16      *SelectionSmallFileName;
    CHAR16      *SelectionBigFileName;
index e4738e26486e3d5c807041928f956fda9b62dac4..f9be58be75f0a75adaf67db0df3118c7629390fe 100644 (file)
@@ -38,6 +38,7 @@
 #include "lib.h"
 #include "icns.h"
 #include "config.h"
 #include "lib.h"
 #include "icns.h"
 #include "config.h"
+#include "../refind/screen.h"
 
 //
 // well-known icons
 
 //
 // well-known icons
@@ -100,8 +101,10 @@ EG_IMAGE * LoadOSIcon(IN CHAR16 *OSIconName OPTIONAL, IN CHAR16 *FallbackIconNam
 
         // try to load it
         Image = egLoadIcon(SelfDir, FileName, 128);
 
         // try to load it
         Image = egLoadIcon(SelfDir, FileName, 128);
-        if (Image != NULL)
+        if (Image != NULL) {
+            FreePool(CutoutName);
             return Image;
             return Image;
+        }
         FreePool(CutoutName);
     } // while
 
         FreePool(CutoutName);
     } // while
 
index 71f76c57b9294ab41c53aa5c5017c78bed1bf844..85a1de2fbc6979494ec2aaec34234047826e59a1 100644 (file)
 #include "lib.h"
 #include "icns.h"
 #include "screen.h"
 #include "lib.h"
 #include "icns.h"
 #include "screen.h"
-#include "refit_call_wrapper.h"
-#include "RemovableMedia.h"
+#include "../include/refit_call_wrapper.h"
+#include "../include/RemovableMedia.h"
+
+#ifdef __MAKEWITH_GNUEFI
+#define EfiReallocatePool ReallocatePool
+#else
+#define LibLocateHandle gBS->LocateHandleBuffer
+#define DevicePathProtocol gEfiDevicePathProtocolGuid
+#define BlockIoProtocol gEfiBlockIoProtocolGuid
+#define LibFileSystemInfo EfiLibFileSystemInfo
+#define LibOpenRoot EfiLibOpenRoot
+EFI_DEVICE_PATH EndDevicePath[] = {
+   {END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH, 0}}
+};
+
+//#define EndDevicePath DevicePath
+#endif
 
 // variables
 
 
 // variables
 
@@ -128,10 +143,13 @@ EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle)
 
     // find the current directory
     DevicePathAsString = DevicePathToStr(SelfLoadedImage->FilePath);
 
     // find the current directory
     DevicePathAsString = DevicePathToStr(SelfLoadedImage->FilePath);
+//    Print(L"DevicePathAsString is '%s'\n", DevicePathAsString);
     CleanUpPathNameSlashes(DevicePathAsString);
     if (SelfDirPath != NULL)
        FreePool(SelfDirPath);
     SelfDirPath = FindPath(DevicePathAsString);
     CleanUpPathNameSlashes(DevicePathAsString);
     if (SelfDirPath != NULL)
        FreePool(SelfDirPath);
     SelfDirPath = FindPath(DevicePathAsString);
+//    Print(L"SelfDirPath is '%s'\n", SelfDirPath);
+//    PauseForKey();
     FreePool(DevicePathAsString);
 
     return FinishInitRefitLib();
     FreePool(DevicePathAsString);
 
     return FinishInitRefitLib();
@@ -224,7 +242,7 @@ VOID AddListElement(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount, IN VOID
         if (*ElementCount == 0)
             *ListPtr = AllocatePool(sizeof(VOID *) * AllocateCount);
         else
         if (*ElementCount == 0)
             *ListPtr = AllocatePool(sizeof(VOID *) * AllocateCount);
         else
-            *ListPtr = ReallocatePool(*ListPtr, sizeof(VOID *) * (*ElementCount), sizeof(VOID *) * AllocateCount);
+            *ListPtr = EfiReallocatePool(*ListPtr, sizeof(VOID *) * (*ElementCount), sizeof(VOID *) * AllocateCount);
     }
     (*ListPtr)[*ElementCount] = NewElement;
     (*ElementCount)++;
     }
     (*ListPtr)[*ElementCount] = NewElement;
     (*ElementCount)++;
@@ -270,8 +288,7 @@ VOID ExtractLegacyLoaderPaths(EFI_DEVICE_PATH **PathList, UINTN MaxPaths, EFI_DE
     MaxPaths--;  // leave space for the terminating NULL pointer
 
     // get all LoadedImage handles
     MaxPaths--;  // leave space for the terminating NULL pointer
 
     // get all LoadedImage handles
-    Status = LibLocateHandle(ByProtocol, &LoadedImageProtocol, NULL,
-                             &HandleCount, &Handles);
+    Status = LibLocateHandle(ByProtocol, &LoadedImageProtocol, NULL, &HandleCount, &Handles);
     if (CheckError(Status, L"while listing LoadedImage handles")) {
         if (HardcodedPathList) {
             for (HardcodedIndex = 0; HardcodedPathList[HardcodedIndex] && PathCount < MaxPaths; HardcodedIndex++)
     if (CheckError(Status, L"while listing LoadedImage handles")) {
         if (HardcodedPathList) {
             for (HardcodedIndex = 0; HardcodedPathList[HardcodedIndex] && PathCount < MaxPaths; HardcodedIndex++)
@@ -639,7 +656,7 @@ static VOID ScanVolume(IN OUT REFIT_VOLUME *Volume)
     if (FileExists(Volume->RootDir, VOLUME_ICON_NAME)) {
        Volume->VolIconImage = LoadIcns(Volume->RootDir, VOLUME_ICON_NAME, 128);
     }
     if (FileExists(Volume->RootDir, VOLUME_ICON_NAME)) {
        Volume->VolIconImage = LoadIcns(Volume->RootDir, VOLUME_ICON_NAME, 128);
     }
-}
+} // ScanVolume()
 
 static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_INFO *MbrEntry)
 {
 
 static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_INFO *MbrEntry)
 {
@@ -683,7 +700,9 @@ static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_I
                 Volume->DiskKind = WholeDiskVolume->DiskKind;
                 Volume->IsMbrPartition = TRUE;
                 Volume->MbrPartitionIndex = LogicalPartitionIndex++;
                 Volume->DiskKind = WholeDiskVolume->DiskKind;
                 Volume->IsMbrPartition = TRUE;
                 Volume->MbrPartitionIndex = LogicalPartitionIndex++;
-                Volume->VolName = PoolPrint(L"Partition %d", Volume->MbrPartitionIndex + 1);
+                Volume->VolName = AllocateZeroPool(256 * sizeof(UINT16));
+                SPrint(Volume->VolName, 255, L"Partition %d", Volume->MbrPartitionIndex + 1);
+//                Volume->VolName = PoolPrint(L"Partition %d", Volume->MbrPartitionIndex + 1);
                 Volume->BlockIO = WholeDiskVolume->BlockIO;
                 Volume->BlockIOOffset = ExtCurrent + EMbrTable[i].StartLBA;
                 Volume->WholeDiskBlockIO = WholeDiskVolume->BlockIO;
                 Volume->BlockIO = WholeDiskVolume->BlockIO;
                 Volume->BlockIOOffset = ExtCurrent + EMbrTable[i].StartLBA;
                 Volume->WholeDiskBlockIO = WholeDiskVolume->BlockIO;
@@ -722,8 +741,9 @@ VOID ScanVolumes(VOID)
     // get all filesystem handles
     Status = LibLocateHandle(ByProtocol, &BlockIoProtocol, NULL, &HandleCount, &Handles);
     // was: &FileSystemProtocol
     // get all filesystem handles
     Status = LibLocateHandle(ByProtocol, &BlockIoProtocol, NULL, &HandleCount, &Handles);
     // was: &FileSystemProtocol
-    if (Status == EFI_NOT_FOUND)
+    if (Status == EFI_NOT_FOUND) {
         return;  // no filesystems. strange, but true...
         return;  // no filesystems. strange, but true...
+    }
     if (CheckError(Status, L"while listing all file systems"))
         return;
 
     if (CheckError(Status, L"while listing all file systems"))
         return;
 
@@ -803,8 +823,10 @@ VOID ScanVolumes(VOID)
                 // now we're reasonably sure the association is correct...
                 Volume->IsMbrPartition = TRUE;
                 Volume->MbrPartitionIndex = PartitionIndex;
                 // now we're reasonably sure the association is correct...
                 Volume->IsMbrPartition = TRUE;
                 Volume->MbrPartitionIndex = PartitionIndex;
-                if (Volume->VolName == NULL)
-                    Volume->VolName = PoolPrint(L"Partition %d", PartitionIndex + 1);
+                if (Volume->VolName == NULL) {
+                    Volume->VolName = AllocateZeroPool(sizeof(CHAR16) * 256);
+                    SPrint(Volume->VolName, 255, L"Partition %d", PartitionIndex + 1);
+                }
                 break;
             }
 
                 break;
             }
 
@@ -925,7 +947,7 @@ EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry,
                 Print(L"Reallocating buffer from %d to %d\n", LastBufferSize, BufferSize);
 #endif
             }
                 Print(L"Reallocating buffer from %d to %d\n", LastBufferSize, BufferSize);
 #endif
             }
-            Buffer = ReallocatePool(Buffer, LastBufferSize, BufferSize);
+            Buffer = EfiReallocatePool(Buffer, LastBufferSize, BufferSize);
             LastBufferSize = BufferSize;
         }
         if (EFI_ERROR(Status)) {
             LastBufferSize = BufferSize;
         }
         if (EFI_ERROR(Status)) {
@@ -969,6 +991,60 @@ VOID DirIterOpen(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath OPTIONAL, OUT REF
     DirIter->LastFileInfo = NULL;
 }
 
     DirIter->LastFileInfo = NULL;
 }
 
+#ifndef __MAKEWITH_GNUEFI
+EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation = NULL;
+
+static EFI_STATUS
+InitializeUnicodeCollationProtocol (VOID)
+{
+   EFI_STATUS  Status;
+
+   if (mUnicodeCollation != NULL) {
+      return EFI_SUCCESS;
+   }
+
+   //
+   // BUGBUG: Proper impelmentation is to locate all Unicode Collation Protocol
+   // instances first and then select one which support English language.
+   // Current implementation just pick the first instance.
+   //
+   Status = gBS->LocateProtocol (
+                          &gEfiUnicodeCollation2ProtocolGuid,
+                          NULL,
+                          (VOID **) &mUnicodeCollation
+                          );
+  if (EFI_ERROR(Status)) {
+    Status = gBS->LocateProtocol (
+                  &gEfiUnicodeCollationProtocolGuid,
+                  NULL,
+                  (VOID **) &mUnicodeCollation
+                  );
+
+  }
+   return Status;
+}
+
+static BOOLEAN
+MetaiMatch (IN CHAR16 *String, IN CHAR16 *Pattern)
+{
+   if (!mUnicodeCollation) {
+      InitializeUnicodeCollationProtocol();
+   }
+   if (mUnicodeCollation)
+      return mUnicodeCollation->MetaiMatch (mUnicodeCollation, String, Pattern);
+   return FALSE; // Shouldn't happen
+}
+
+static VOID StrLwr (IN OUT CHAR16 *Str) {
+   if (!mUnicodeCollation) {
+      InitializeUnicodeCollationProtocol();
+   }
+   if (mUnicodeCollation)
+      mUnicodeCollation->StrLwr (mUnicodeCollation, Str);
+}
+
+#endif
+
 BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR16 *FilePattern OPTIONAL,
                     OUT EFI_FILE_INFO **DirEntry)
 {
 BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR16 *FilePattern OPTIONAL,
                     OUT EFI_FILE_INFO **DirEntry)
 {
@@ -1322,3 +1398,4 @@ BOOLEAN EjectMedia(VOID) {
    FreePool(Handles);
    return (Ejected > 0);
 } // VOID EjectMedia()
    FreePool(Handles);
    return (Ejected > 0);
 } // VOID EjectMedia()
+
index 17af8bd21e0fa7addcf156ebcf64d2cb40db68ce..f96315cc81a6bacaafd5a2676a65061db43d31b5 100644 (file)
 #ifndef __LIB_H_
 #define __LIB_H_
 
 #ifndef __LIB_H_
 #define __LIB_H_
 
+#ifdef __MAKEWITH_GNUEFI
 #include "efi.h"
 #include "efilib.h"
 #include "efi.h"
 #include "efilib.h"
+#else
+#include "../include/tiano_includes.h"
+#endif
+#include "global.h"
 
 #include "libeg.h"
 
 
 #include "libeg.h"
 
index 312b12631bc23040e2057b5724e76b2f61a09bb0..ffb22fdc7a91485a685638dcaefdf838702ef7eb 100644 (file)
@@ -48,7 +48,8 @@
 #include "lib.h"
 #include "icns.h"
 #include "menu.h"
 #include "lib.h"
 #include "icns.h"
 #include "menu.h"
-#include "refit_call_wrapper.h"
+#include "../include/Handle.h"
+#include "../include/refit_call_wrapper.h"
 #include "driver_support.h"
 #include "../include/syslinux_mbr.h"
 
 #include "driver_support.h"
 #include "../include/syslinux_mbr.h"
 
@@ -64,6 +65,7 @@
 #define DRIVER_DIRS             L"drivers,drivers_ia32"
 #else
 #define SHELL_NAMES             L"\\EFI\\tools\\shell.efi"
 #define DRIVER_DIRS             L"drivers,drivers_ia32"
 #else
 #define SHELL_NAMES             L"\\EFI\\tools\\shell.efi"
+#define DRIVER_DIRS             L"drivers"
 #endif
 
 // Filename patterns that identify EFI boot loaders. Note that a single case (either L"*.efi" or
 #endif
 
 // Filename patterns that identify EFI boot loaders. Note that a single case (either L"*.efi" or
@@ -87,7 +89,7 @@ static REFIT_MENU_ENTRY MenuEntryExit     = { L"Exit rEFInd", TAG_EXIT, 1, 0, 0,
 static REFIT_MENU_SCREEN MainMenu       = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot" };
 static REFIT_MENU_SCREEN AboutMenu      = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL };
 
 static REFIT_MENU_SCREEN MainMenu       = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot" };
 static REFIT_MENU_SCREEN AboutMenu      = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL };
 
-REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 20, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 20, 0, 0, GRAPHICS_FOR_OSX, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                               {TAG_SHELL, TAG_ABOUT, TAG_SHUTDOWN, TAG_REBOOT, 0, 0, 0, 0, 0 }};
 
 // Structure used to hold boot loader filenames and time stamps in
                               {TAG_SHELL, TAG_ABOUT, TAG_SHUTDOWN, TAG_REBOOT, 0, 0, 0, 0, 0 }};
 
 // Structure used to hold boot loader filenames and time stamps in
@@ -104,9 +106,11 @@ struct LOADER_LIST {
 
 static VOID AboutrEFInd(VOID)
 {
 
 static VOID AboutrEFInd(VOID)
 {
+    CHAR16 *TempStr; // Note: Don't deallocate; moved to menu structure
+
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.2");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.2.1");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
@@ -114,8 +118,9 @@ static VOID AboutrEFInd(VOID)
         AddMenuInfoLine(&AboutMenu, L"Distributed under the terms of the GNU GPLv3 license");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Running on:");
         AddMenuInfoLine(&AboutMenu, L"Distributed under the terms of the GNU GPLv3 license");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Running on:");
-        AddMenuInfoLine(&AboutMenu, PoolPrint(L" EFI Revision %d.%02d",
-                        ST->Hdr.Revision >> 16, ST->Hdr.Revision & ((1 << 16) - 1)));
+        TempStr = AllocateZeroPool(255 * sizeof(CHAR16));
+        SPrint(TempStr, 255, L" EFI Revision %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & ((1 << 16) - 1));
+        AddMenuInfoLine(&AboutMenu, TempStr);
 #if defined(EFI32)
         AddMenuInfoLine(&AboutMenu, L" Platform: x86 (32 bit)");
 #elif defined(EFIX64)
 #if defined(EFI32)
         AddMenuInfoLine(&AboutMenu, L" Platform: x86 (32 bit)");
 #elif defined(EFIX64)
@@ -123,9 +128,19 @@ static VOID AboutrEFInd(VOID)
 #else
         AddMenuInfoLine(&AboutMenu, L" Platform: unknown");
 #endif
 #else
         AddMenuInfoLine(&AboutMenu, L" Platform: unknown");
 #endif
-        AddMenuInfoLine(&AboutMenu, PoolPrint(L" Firmware: %s %d.%02d",
-            ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & ((1 << 16) - 1)));
-        AddMenuInfoLine(&AboutMenu, PoolPrint(L" Screen Output: %s", egScreenDescription()));
+        TempStr = AllocateZeroPool(255 * sizeof(CHAR16));
+        SPrint(TempStr, 255, L" Firmware: %s %d.%02d",
+               ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & ((1 << 16) - 1));
+        AddMenuInfoLine(&AboutMenu, TempStr);
+        TempStr = AllocateZeroPool(255 * sizeof(CHAR16));
+        SPrint(TempStr, 255, L" Screen Output: %s", egScreenDescription());
+        AddMenuInfoLine(&AboutMenu, TempStr);
+        AddMenuInfoLine(&AboutMenu, L"");
+#if defined(__MAKEWITH_GNUEFI)
+        AddMenuInfoLine(&AboutMenu, L"Built with GNU-EFI");
+#else
+        AddMenuInfoLine(&AboutMenu, L"Built with TianoCore EDK2");
+#endif
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"For more information, see the rEFInd Web site:");
         AddMenuInfoLine(&AboutMenu, L"http://www.rodsbooks.com/refind/");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"For more information, see the rEFInd Web site:");
         AddMenuInfoLine(&AboutMenu, L"http://www.rodsbooks.com/refind/");
@@ -157,8 +172,9 @@ static EFI_STATUS StartEFIImageList(IN EFI_DEVICE_PATH **DevicePaths,
     ReturnStatus = Status = EFI_NOT_FOUND;  // in case the list is empty
     for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; DevicePathIndex++) {
         ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex], NULL, 0, &ChildImageHandle);
     ReturnStatus = Status = EFI_NOT_FOUND;  // in case the list is empty
     for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; DevicePathIndex++) {
         ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex], NULL, 0, &ChildImageHandle);
-        if (ReturnStatus != EFI_NOT_FOUND)
+        if (ReturnStatus != EFI_NOT_FOUND) {
             break;
             break;
+        }
     }
     SPrint(ErrorInfo, 255, L"while loading %s", ImageTitle);
     if (CheckError(Status, ErrorInfo)) {
     }
     SPrint(ErrorInfo, 255, L"while loading %s", ImageTitle);
     if (CheckError(Status, ErrorInfo)) {
@@ -177,16 +193,17 @@ static EFI_STATUS StartEFIImageList(IN EFI_DEVICE_PATH **DevicePaths,
         }
 
         if (LoadOptionsPrefix != NULL) {
         }
 
         if (LoadOptionsPrefix != NULL) {
-            FullLoadOptions = PoolPrint(L"%s %s ", LoadOptionsPrefix, LoadOptions);
+            MergeStrings(&FullLoadOptions, LoadOptionsPrefix, 0);
+            MergeStrings(&FullLoadOptions, LoadOptions, L' ');
+            MergeStrings(&FullLoadOptions, L" ", 0);
             // NOTE: That last space is also added by the EFI shell and seems to be significant
             //  when passing options to Apple's boot.efi...
             // NOTE: That last space is also added by the EFI shell and seems to be significant
             //  when passing options to Apple's boot.efi...
-            LoadOptions = FullLoadOptions;
         }
         // NOTE: We also include the terminating null in the length for safety.
         }
         // NOTE: We also include the terminating null in the length for safety.
-        ChildLoadedImage->LoadOptions = (VOID *)LoadOptions;
-        ChildLoadedImage->LoadOptionsSize = ((UINT32)StrLen(LoadOptions) + 1) * sizeof(CHAR16);
+        ChildLoadedImage->LoadOptions = (VOID *)FullLoadOptions;
+        ChildLoadedImage->LoadOptionsSize = ((UINT32)StrLen(FullLoadOptions) + 1) * sizeof(CHAR16);
         if (Verbose)
         if (Verbose)
-            Print(L"Using load options '%s'\n", LoadOptions);
+            Print(L"Using load options '%s'\n", FullLoadOptions);
     }
 
     // close open file handles
     }
 
     // close open file handles
@@ -237,7 +254,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
 
     BeginExternalScreen(Entry->UseGraphicsMode, L"Booting OS");
     StartEFIImage(Entry->DevicePath, Entry->LoadOptions,
 
     BeginExternalScreen(Entry->UseGraphicsMode, L"Booting OS");
     StartEFIImage(Entry->DevicePath, Entry->LoadOptions,
-                  Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), &ErrorInStep, TRUE);
+                  Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), &ErrorInStep, !Entry->UseGraphicsMode);
     FinishExternalScreen();
 }
 
     FinishExternalScreen();
 }
 
@@ -275,11 +292,15 @@ static CHAR16 * FindInitrd(IN CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume) {
    while ((DirIterNext(&DirIter, 2, L"init*", &DirEntry)) && (InitrdName == NULL)) {
       InitrdVersion = FindNumbers(DirEntry->FileName);
       if (KernelVersion != NULL) {
    while ((DirIterNext(&DirIter, 2, L"init*", &DirEntry)) && (InitrdName == NULL)) {
       InitrdVersion = FindNumbers(DirEntry->FileName);
       if (KernelVersion != NULL) {
-         if (StriCmp(InitrdVersion, KernelVersion) == 0)
-            InitrdName = PoolPrint(L"%s%s", Path, DirEntry->FileName);
+         if (StriCmp(InitrdVersion, KernelVersion) == 0) {
+            MergeStrings(&InitrdName, Path, 0);
+            MergeStrings(&InitrdName, DirEntry->FileName, 0);
+         } // if
       } else {
       } else {
-         if (InitrdVersion == NULL)
-            InitrdName = PoolPrint(L"%s%s", Path, DirEntry->FileName);
+         if (InitrdVersion == NULL) {
+            MergeStrings(&InitrdName, Path, 0);
+            MergeStrings(&InitrdName, DirEntry->FileName, 0);
+         } // if
       } // if/else
       if (InitrdVersion != NULL)
          FreePool(InitrdVersion);
       } // if/else
       if (InitrdVersion != NULL)
          FreePool(InitrdVersion);
@@ -390,7 +411,7 @@ LOADER_ENTRY *InitializeLoaderEntry(IN LOADER_ENTRY *Entry) {
 // Returns a pointer to the new subscreen data structure, or NULL if there
 // were problems allocating memory.
 REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry) {
 // Returns a pointer to the new subscreen data structure, or NULL if there
 // were problems allocating memory.
 REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry) {
-   CHAR16              *FileName, *Temp;
+   CHAR16              *FileName, *Temp = NULL, *TitleStr;
    REFIT_MENU_SCREEN   *SubScreen = NULL;
    LOADER_ENTRY        *SubEntry;
 
    REFIT_MENU_SCREEN   *SubScreen = NULL;
    LOADER_ENTRY        *SubEntry;
 
@@ -398,14 +419,17 @@ REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry) {
    if (Entry->me.SubScreen == NULL) { // No subscreen yet; initialize default entry....
       SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
       if (SubScreen != NULL) {
    if (Entry->me.SubScreen == NULL) { // No subscreen yet; initialize default entry....
       SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
       if (SubScreen != NULL) {
-         SubScreen->Title = PoolPrint(L"Boot Options for %s on %s", (Entry->Title != NULL) ? Entry->Title : FileName, Entry->VolName);
+         TitleStr = AllocateZeroPool(sizeof(CHAR16) * 256);
+         SPrint(TitleStr, 255, L"Boot Options for %s on %s", (Entry->Title != NULL) ? Entry->Title : FileName, Entry->VolName);
+         SubScreen->Title = TitleStr;
          SubScreen->TitleImage = Entry->me.Image;
          // default entry
          SubEntry = InitializeLoaderEntry(Entry);
          if (SubEntry != NULL) {
             SubEntry->me.Title = L"Boot using default options";
             if ((SubEntry->InitrdPath != NULL) && (StrLen(SubEntry->InitrdPath) > 0) && (!StriSubCmp(L"initrd", SubEntry->LoadOptions))) {
          SubScreen->TitleImage = Entry->me.Image;
          // default entry
          SubEntry = InitializeLoaderEntry(Entry);
          if (SubEntry != NULL) {
             SubEntry->me.Title = L"Boot using default options";
             if ((SubEntry->InitrdPath != NULL) && (StrLen(SubEntry->InitrdPath) > 0) && (!StriSubCmp(L"initrd", SubEntry->LoadOptions))) {
-               Temp = PoolPrint(L"initrd=%s", SubEntry->InitrdPath);
+               MergeStrings(&Temp, L"initrd=", 0);
+               MergeStrings(&Temp, SubEntry->InitrdPath, 0);
                MergeStrings(&SubEntry->LoadOptions, Temp, L' ');
                FreePool(Temp);
             } // if
                MergeStrings(&SubEntry->LoadOptions, Temp, L' ');
                FreePool(Temp);
             } // if
@@ -421,13 +445,12 @@ REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry) {
 VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
    REFIT_MENU_SCREEN  *SubScreen;
    LOADER_ENTRY       *SubEntry;
 VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
    REFIT_MENU_SCREEN  *SubScreen;
    LOADER_ENTRY       *SubEntry;
-   CHAR16             *FileName, *InitrdOption = NULL, *Temp;
+   CHAR16             *InitrdOption = NULL, *Temp;
    CHAR16             DiagsFileName[256];
    REFIT_FILE         *File;
    UINTN              TokenCount;
    CHAR16             **TokenList;
 
    CHAR16             DiagsFileName[256];
    REFIT_FILE         *File;
    UINTN              TokenCount;
    CHAR16             **TokenList;
 
-   FileName = Basename(Entry->LoaderPath);
    // create the submenu
    if (StrLen(Entry->Title) == 0) {
       FreePool(Entry->Title);
    // create the submenu
    if (StrLen(Entry->Title) == 0) {
       FreePool(Entry->Title);
@@ -442,6 +465,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
       if (SubEntry != NULL) {
          SubEntry->me.Title        = L"Boot Mac OS X with a 64-bit kernel";
          SubEntry->LoadOptions     = L"arch=x86_64";
       if (SubEntry != NULL) {
          SubEntry->me.Title        = L"Boot Mac OS X with a 64-bit kernel";
          SubEntry->LoadOptions     = L"arch=x86_64";
+         SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX;
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       } // if
 
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       } // if
 
@@ -449,6 +473,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
       if (SubEntry != NULL) {
          SubEntry->me.Title        = L"Boot Mac OS X with a 32-bit kernel";
          SubEntry->LoadOptions     = L"arch=i386";
       if (SubEntry != NULL) {
          SubEntry->me.Title        = L"Boot Mac OS X with a 32-bit kernel";
          SubEntry->LoadOptions     = L"arch=i386";
+         SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX;
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       } // if
 #endif
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       } // if
 #endif
@@ -498,7 +523,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
             FreePool(SubEntry->LoaderPath);
             SubEntry->LoaderPath      = StrDuplicate(DiagsFileName);
             SubEntry->DevicePath      = FileDevicePath(Volume->DeviceHandle, SubEntry->LoaderPath);
             FreePool(SubEntry->LoaderPath);
             SubEntry->LoaderPath      = StrDuplicate(DiagsFileName);
             SubEntry->DevicePath      = FileDevicePath(Volume->DeviceHandle, SubEntry->LoaderPath);
-            SubEntry->UseGraphicsMode = TRUE;
+            SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX;
             AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
          } // if
       } // if diagnostics entry found
             AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
          } // if
       } // if diagnostics entry found
@@ -506,8 +531,10 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
    } else if (Entry->OSType == 'L') {   // entries for Linux kernels with EFI stub loaders
       File = ReadLinuxOptionsFile(Entry->LoaderPath, Volume);
       if (File != NULL) {
    } else if (Entry->OSType == 'L') {   // entries for Linux kernels with EFI stub loaders
       File = ReadLinuxOptionsFile(Entry->LoaderPath, Volume);
       if (File != NULL) {
-         if ((Temp = FindInitrd(Entry->LoaderPath, Volume)) != NULL)
-            InitrdOption = PoolPrint(L"initrd=%s", Temp);
+         if ((Temp = FindInitrd(Entry->LoaderPath, Volume)) != NULL) {
+            MergeStrings(&InitrdOption, L"initrd=", 0);
+            MergeStrings(&InitrdOption, Temp, 0);
+         }
          TokenCount = ReadTokenLine(File, &TokenList); // read and discard first entry, since it's
          FreeTokenLine(&TokenList, &TokenCount);       // set up by InitializeSubScreen(), earlier....
          while ((TokenCount = ReadTokenLine(File, &TokenList)) > 1) {
          TokenCount = ReadTokenLine(File, &TokenList); // read and discard first entry, since it's
          FreeTokenLine(&TokenList, &TokenCount);       // set up by InitializeSubScreen(), earlier....
          while ((TokenCount = ReadTokenLine(File, &TokenList)) > 1) {
@@ -518,6 +545,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
             SubEntry->LoadOptions = StrDuplicate(TokenList[1]);
             MergeStrings(&SubEntry->LoadOptions, InitrdOption, L' ');
             FreeTokenLine(&TokenList, &TokenCount);
             SubEntry->LoadOptions = StrDuplicate(TokenList[1]);
             MergeStrings(&SubEntry->LoadOptions, InitrdOption, L' ');
             FreeTokenLine(&TokenList, &TokenCount);
+            SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_LINUX;
             AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
          } // while
          if (InitrdOption)
             AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
          } // while
          if (InitrdOption)
@@ -530,8 +558,9 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
    } else if (Entry->OSType == 'E') {   // entries for ELILO
       SubEntry = InitializeLoaderEntry(Entry);
       if (SubEntry != NULL) {
    } else if (Entry->OSType == 'E') {   // entries for ELILO
       SubEntry = InitializeLoaderEntry(Entry);
       if (SubEntry != NULL) {
-         SubEntry->me.Title        = PoolPrint(L"Run %s in interactive mode", FileName);
+         SubEntry->me.Title        = L"Run ELILO in interactive mode";
          SubEntry->LoadOptions     = L"-p";
          SubEntry->LoadOptions     = L"-p";
+         SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO;
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       }
 
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       }
 
@@ -540,6 +569,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
          SubEntry->me.Title        = L"Boot Linux for a 17\" iMac or a 15\" MacBook Pro (*)";
          SubEntry->UseGraphicsMode = TRUE;
          SubEntry->LoadOptions     = L"-d 0 i17";
          SubEntry->me.Title        = L"Boot Linux for a 17\" iMac or a 15\" MacBook Pro (*)";
          SubEntry->UseGraphicsMode = TRUE;
          SubEntry->LoadOptions     = L"-d 0 i17";
+         SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO;
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       }
 
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       }
 
@@ -548,6 +578,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
          SubEntry->me.Title        = L"Boot Linux for a 20\" iMac (*)";
          SubEntry->UseGraphicsMode = TRUE;
          SubEntry->LoadOptions     = L"-d 0 i20";
          SubEntry->me.Title        = L"Boot Linux for a 20\" iMac (*)";
          SubEntry->UseGraphicsMode = TRUE;
          SubEntry->LoadOptions     = L"-d 0 i20";
+         SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO;
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       }
 
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       }
 
@@ -556,6 +587,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
          SubEntry->me.Title        = L"Boot Linux for a Mac Mini (*)";
          SubEntry->UseGraphicsMode = TRUE;
          SubEntry->LoadOptions     = L"-d 0 mini";
          SubEntry->me.Title        = L"Boot Linux for a Mac Mini (*)";
          SubEntry->UseGraphicsMode = TRUE;
          SubEntry->LoadOptions     = L"-d 0 mini";
+         SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO;
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       }
 
          AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
       }
 
@@ -570,6 +602,7 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
         if (SubEntry != NULL) {
            SubEntry->me.Title        = L"Boot Windows from Hard Disk";
            SubEntry->LoadOptions     = L"-s -h";
         if (SubEntry != NULL) {
            SubEntry->me.Title        = L"Boot Windows from Hard Disk";
            SubEntry->LoadOptions     = L"-s -h";
+           SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
            AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
         }
 
            AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
         }
 
@@ -577,14 +610,16 @@ VOID GenerateSubScreen(LOADER_ENTRY *Entry, IN REFIT_VOLUME *Volume) {
         if (SubEntry != NULL) {
            SubEntry->me.Title        = L"Boot Windows from CD-ROM";
            SubEntry->LoadOptions     = L"-s -c";
         if (SubEntry != NULL) {
            SubEntry->me.Title        = L"Boot Windows from CD-ROM";
            SubEntry->LoadOptions     = L"-s -c";
+           SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
            AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
         }
 
         SubEntry = InitializeLoaderEntry(Entry);
         if (SubEntry != NULL) {
            AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
         }
 
         SubEntry = InitializeLoaderEntry(Entry);
         if (SubEntry != NULL) {
-           SubEntry->me.Title        = PoolPrint(L"Run %s in text mode", FileName);
+           SubEntry->me.Title        = L"Run XOM in text mode";
            SubEntry->UseGraphicsMode = FALSE;
            SubEntry->LoadOptions     = L"-v";
            SubEntry->UseGraphicsMode = FALSE;
            SubEntry->LoadOptions     = L"-v";
+           SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
            AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
         }
    } // entries for xom.efi
            AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
         }
    } // entries for xom.efi
@@ -600,8 +635,10 @@ static CHAR16 * GetMainLinuxOptions(IN CHAR16 * LoaderPath, IN REFIT_VOLUME *Vol
 
    Options = GetFirstOptionsFromFile(LoaderPath, Volume);
    InitrdName = FindInitrd(LoaderPath, Volume);
 
    Options = GetFirstOptionsFromFile(LoaderPath, Volume);
    InitrdName = FindInitrd(LoaderPath, Volume);
-   if (InitrdName != NULL)
-      InitrdOption = PoolPrint(L"initrd=%s", InitrdName);
+   if (InitrdName != NULL) {
+      MergeStrings(&InitrdOption, L"initrd=", 0);
+      MergeStrings(&InitrdOption, InitrdName, 0);
+   } // if
    MergeStrings(&Options, InitrdOption, ' ');
    if (InitrdOption != NULL)
       FreePool(InitrdOption);
    MergeStrings(&Options, InitrdOption, ' ');
    if (InitrdOption != NULL)
       FreePool(InitrdOption);
@@ -644,6 +681,7 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME
       if (ShortcutLetter == 0)
          ShortcutLetter = 'L';
       Entry->LoadOptions = GetMainLinuxOptions(LoaderPath, Volume);
       if (ShortcutLetter == 0)
          ShortcutLetter = 'L';
       Entry->LoadOptions = GetMainLinuxOptions(LoaderPath, Volume);
+      Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_LINUX;
    } else if (StriSubCmp(L"refit", LoaderPath)) {
       MergeStrings(&OSIconName, L"refit", L',');
       Entry->OSType = 'R';
    } else if (StriSubCmp(L"refit", LoaderPath)) {
       MergeStrings(&OSIconName, L"refit", L',');
       Entry->OSType = 'R';
@@ -653,9 +691,9 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME
          Entry->me.Image = Volume->VolIconImage;
       }
       MergeStrings(&OSIconName, L"mac", L',');
          Entry->me.Image = Volume->VolIconImage;
       }
       MergeStrings(&OSIconName, L"mac", L',');
-      Entry->UseGraphicsMode = TRUE;
       Entry->OSType = 'M';
       ShortcutLetter = 'M';
       Entry->OSType = 'M';
       ShortcutLetter = 'M';
+      Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX;
    } else if (StriCmp(FileName, L"diags.efi") == 0) {
       MergeStrings(&OSIconName, L"hwtest", L',');
    } else if (StriCmp(FileName, L"e.efi") == 0 || StriCmp(FileName, L"elilo.efi") == 0) {
    } else if (StriCmp(FileName, L"diags.efi") == 0) {
       MergeStrings(&OSIconName, L"hwtest", L',');
    } else if (StriCmp(FileName, L"e.efi") == 0 || StriCmp(FileName, L"elilo.efi") == 0) {
@@ -663,20 +701,24 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME
       Entry->OSType = 'E';
       if (ShortcutLetter == 0)
          ShortcutLetter = 'L';
       Entry->OSType = 'E';
       if (ShortcutLetter == 0)
          ShortcutLetter = 'L';
+      Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO;
    } else if (StriSubCmp(L"grub", FileName)) {
       Entry->OSType = 'G';
       ShortcutLetter = 'G';
    } else if (StriSubCmp(L"grub", FileName)) {
       Entry->OSType = 'G';
       ShortcutLetter = 'G';
+      Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_GRUB;
    } else if (StriCmp(FileName, L"cdboot.efi") == 0 ||
               StriCmp(FileName, L"bootmgr.efi") == 0 ||
               StriCmp(FileName, L"Bootmgfw.efi") == 0) {
       MergeStrings(&OSIconName, L"win", L',');
       Entry->OSType = 'W';
       ShortcutLetter = 'W';
    } else if (StriCmp(FileName, L"cdboot.efi") == 0 ||
               StriCmp(FileName, L"bootmgr.efi") == 0 ||
               StriCmp(FileName, L"Bootmgfw.efi") == 0) {
       MergeStrings(&OSIconName, L"win", L',');
       Entry->OSType = 'W';
       ShortcutLetter = 'W';
+      Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
    } else if (StriCmp(FileName, L"xom.efi") == 0) {
       MergeStrings(&OSIconName, L"xom,win", L',');
       Entry->UseGraphicsMode = TRUE;
       Entry->OSType = 'X';
       ShortcutLetter = 'W';
    } else if (StriCmp(FileName, L"xom.efi") == 0) {
       MergeStrings(&OSIconName, L"xom,win", L',');
       Entry->UseGraphicsMode = TRUE;
       Entry->OSType = 'X';
       ShortcutLetter = 'W';
+      Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
    }
 
    if ((ShortcutLetter >= 'a') && (ShortcutLetter <= 'z'))
    }
 
    if ((ShortcutLetter >= 'a') && (ShortcutLetter <= 'z'))
@@ -692,12 +734,15 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME
 // for icons, options, etc.
 LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume) {
    LOADER_ENTRY      *Entry;
 // for icons, options, etc.
 LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume) {
    LOADER_ENTRY      *Entry;
+   CHAR16            *PoolStr;
 
    CleanUpPathNameSlashes(LoaderPath);
    Entry = InitializeLoaderEntry(NULL);
    if (Entry != NULL) {
       Entry->Title = StrDuplicate((LoaderTitle != NULL) ? LoaderTitle : LoaderPath);
 
    CleanUpPathNameSlashes(LoaderPath);
    Entry = InitializeLoaderEntry(NULL);
    if (Entry != NULL) {
       Entry->Title = StrDuplicate((LoaderTitle != NULL) ? LoaderTitle : LoaderPath);
-      Entry->me.Title = PoolPrint(L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : LoaderPath, Volume->VolName);
+      PoolStr = AllocateZeroPool(sizeof(CHAR16) * 256);
+      SPrint(PoolStr, 255, L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : LoaderPath, Volume->VolName);
+      Entry->me.Title = PoolStr;
       Entry->me.Row = 0;
       Entry->me.BadgeImage = Volume->VolBadgeImage;
       if ((LoaderPath != NULL) && (LoaderPath[0] != L'\\')) {
       Entry->me.Row = 0;
       Entry->me.BadgeImage = Volume->VolBadgeImage;
       if ((LoaderPath != NULL) && (LoaderPath[0] != L'\\')) {
@@ -706,7 +751,6 @@ LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN
          Entry->LoaderPath = NULL;
       }
       MergeStrings(&(Entry->LoaderPath), LoaderPath, 0);
          Entry->LoaderPath = NULL;
       }
       MergeStrings(&(Entry->LoaderPath), LoaderPath, 0);
-//      Entry->LoaderPath = StrDuplicate(LoaderPath);
       Entry->VolName = Volume->VolName;
       Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
       SetLoaderDefaults(Entry, LoaderPath, Volume);
       Entry->VolName = Volume->VolName;
       Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
       SetLoaderDefaults(Entry, LoaderPath, Volume);
@@ -1118,6 +1162,7 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Vo
     REFIT_MENU_SCREEN       *SubScreen;
     CHAR16                  *VolDesc;
     CHAR16                  ShortcutLetter = 0;
     REFIT_MENU_SCREEN       *SubScreen;
     CHAR16                  *VolDesc;
     CHAR16                  ShortcutLetter = 0;
+    CHAR16                  *PoolStr;
 
     if (LoaderTitle == NULL) {
         if (Volume->OSName != NULL) {
 
     if (LoaderTitle == NULL) {
         if (Volume->OSName != NULL) {
@@ -1134,7 +1179,9 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Vo
 
     // prepare the menu entry
     Entry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
 
     // prepare the menu entry
     Entry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
-    Entry->me.Title        = PoolPrint(L"Boot %s from %s", LoaderTitle, VolDesc);
+    PoolStr = AllocateZeroPool(256 * sizeof(CHAR16));
+    SPrint(PoolStr, 255, L"Boot %s from %s", LoaderTitle, VolDesc);
+    Entry->me.Title        = PoolStr;
     Entry->me.Tag          = TAG_LEGACY;
     Entry->me.Row          = 0;
     Entry->me.ShortcutLetter = ShortcutLetter;
     Entry->me.Tag          = TAG_LEGACY;
     Entry->me.Row          = 0;
     Entry->me.ShortcutLetter = ShortcutLetter;
@@ -1147,12 +1194,16 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Vo
 
     // create the submenu
     SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
 
     // create the submenu
     SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
-    SubScreen->Title = PoolPrint(L"Boot Options for %s on %s", LoaderTitle, VolDesc);
+    PoolStr = AllocateZeroPool(256 * sizeof(CHAR16));
+    SPrint(PoolStr, 255, L"Boot Options for %s on %s", LoaderTitle, VolDesc);
+    SubScreen->Title = PoolStr;
     SubScreen->TitleImage = Entry->me.Image;
 
     // default entry
     SubEntry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
     SubScreen->TitleImage = Entry->me.Image;
 
     // default entry
     SubEntry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
-    SubEntry->me.Title        = PoolPrint(L"Boot %s", LoaderTitle);
+    PoolStr = AllocateZeroPool(256 * sizeof(CHAR16));
+    SPrint(PoolStr, 255, L"Boot %s", LoaderTitle);
+    SubEntry->me.Title        = PoolStr;
     SubEntry->me.Tag          = TAG_LEGACY;
     SubEntry->Volume          = Entry->Volume;
     SubEntry->LoadOptions     = Entry->LoadOptions;
     SubEntry->me.Tag          = TAG_LEGACY;
     SubEntry->Volume          = Entry->Volume;
     SubEntry->LoadOptions     = Entry->LoadOptions;
@@ -1252,10 +1303,13 @@ static LOADER_ENTRY * AddToolEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle
                                    IN CHAR16 ShortcutLetter, IN BOOLEAN UseGraphicsMode)
 {
     LOADER_ENTRY *Entry;
                                    IN CHAR16 ShortcutLetter, IN BOOLEAN UseGraphicsMode)
 {
     LOADER_ENTRY *Entry;
+    CHAR16       *TitleStr = NULL;
 
     Entry = AllocateZeroPool(sizeof(LOADER_ENTRY));
 
 
     Entry = AllocateZeroPool(sizeof(LOADER_ENTRY));
 
-    Entry->me.Title = PoolPrint(L"Start %s", LoaderTitle);
+    MergeStrings(&TitleStr, L"Start ", 0);
+    MergeStrings(&TitleStr, LoaderTitle, 0);
+    Entry->me.Title = TitleStr;
     Entry->me.Tag = TAG_TOOL;
     Entry->me.Row = 1;
     Entry->me.ShortcutLetter = ShortcutLetter;
     Entry->me.Tag = TAG_TOOL;
     Entry->me.Row = 1;
     Entry->me.ShortcutLetter = ShortcutLetter;
@@ -1300,6 +1354,7 @@ static UINTN ScanDriverDir(IN CHAR16 *Path)
     return (NumFound);
 }
 
     return (NumFound);
 }
 
+#ifdef __MAKEWITH_GNUEFI
 static EFI_STATUS ConnectAllDriversToAllControllers(VOID)
 {
     EFI_STATUS           Status;
 static EFI_STATUS ConnectAllDriversToAllControllers(VOID)
 {
     EFI_STATUS           Status;
@@ -1367,6 +1422,12 @@ Done:
     FreePool (AllHandleBuffer);
     return Status;
 } /* EFI_STATUS ConnectAllDriversToAllControllers() */
     FreePool (AllHandleBuffer);
     return Status;
 } /* EFI_STATUS ConnectAllDriversToAllControllers() */
+#else
+static EFI_STATUS ConnectAllDriversToAllControllers(VOID) {
+   BdsLibConnectAllDriversToAllControllers();
+   return 0;
+}
+#endif
 
 // Load all EFI drivers from rEFInd's "drivers" subdirectory and from the
 // directories specified by the user in the "scan_driver_dirs" configuration
 
 // Load all EFI drivers from rEFInd's "drivers" subdirectory and from the
 // directories specified by the user in the "scan_driver_dirs" configuration
@@ -1512,6 +1573,21 @@ VOID RescanAll(VOID) {
    SetupScreen();
 } // VOID RescanAll()
 
    SetupScreen();
 } // VOID RescanAll()
 
+#ifndef __MAKEWITH_GNUEFI
+
+// Minimal initialization function
+static VOID InitializeLib(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) {
+   gST            = SystemTable;
+   //    gImageHandle   = ImageHandle;
+   gBS            = SystemTable->BootServices;
+   //    gRS            = SystemTable->RuntimeServices;
+   EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
+
+   InitializeConsoleSim();
+}
+
+#endif
+
 //
 // main entry point
 //
 //
 // main entry point
 //
index d35cd11c4ab46d71a18007cab2f874f7f83c4818..1beb3e76098953f54cc8cfd409b6bb803c08937e 100644 (file)
 #include "menu.h"
 #include "config.h"
 #include "libeg.h"
 #include "menu.h"
 #include "config.h"
 #include "libeg.h"
-#include "refit_call_wrapper.h"
+#include "../include/refit_call_wrapper.h"
 
 
-#include "egemb_back_selected_small.h"
-#include "egemb_arrow_left.h"
-#include "egemb_arrow_right.h"
+#include "../include/egemb_back_selected_small.h"
+#include "../include/egemb_arrow_left.h"
+#include "../include/egemb_arrow_right.h"
 
 // other menu definitions
 
 
 // other menu definitions
 
@@ -371,7 +371,7 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
     INTN ShortcutEntry;
     BOOLEAN HaveTimeout = FALSE;
     UINTN TimeoutCountdown = 0;
     INTN ShortcutEntry;
     BOOLEAN HaveTimeout = FALSE;
     UINTN TimeoutCountdown = 0;
-    CHAR16 *TimeoutMessage;
+    CHAR16 TimeoutMessage[256];
     CHAR16 KeyAsString[2];
     UINTN MenuExit;
 
     CHAR16 KeyAsString[2];
     UINTN MenuExit;
 
@@ -400,9 +400,8 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
         }
 
         if (HaveTimeout) {
         }
 
         if (HaveTimeout) {
-            TimeoutMessage = PoolPrint(L"%s in %d seconds", Screen->TimeoutText, (TimeoutCountdown + 5) / 10);
+            SPrint(TimeoutMessage, 255, L"%s in %d seconds", Screen->TimeoutText, (TimeoutCountdown + 5) / 10);
             StyleFunc(Screen, &State, MENU_FUNCTION_PAINT_TIMEOUT, TimeoutMessage);
             StyleFunc(Screen, &State, MENU_FUNCTION_PAINT_TIMEOUT, TimeoutMessage);
-            FreePool(TimeoutMessage);
         }
 
         // read key press (and wait for it if applicable)
         }
 
         // read key press (and wait for it if applicable)
@@ -504,7 +503,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
     UINTN MenuWidth, ItemWidth, MenuHeight;
     static UINTN MenuPosY;
     static CHAR16 **DisplayStrings;
     UINTN MenuWidth, ItemWidth, MenuHeight;
     static UINTN MenuPosY;
     static CHAR16 **DisplayStrings;
-    CHAR16 *TimeoutMessage;
+    CHAR16 TimeoutMessage[256];
 
     State->ScrollMode = SCROLL_MODE_TEXT;
     switch (Function) {
 
     State->ScrollMode = SCROLL_MODE_TEXT;
     switch (Function) {
@@ -532,8 +531,8 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             // prepare strings for display
             DisplayStrings = AllocatePool(sizeof(CHAR16 *) * Screen->EntryCount);
             for (i = 0; i <= State->MaxIndex; i++)
             // prepare strings for display
             DisplayStrings = AllocatePool(sizeof(CHAR16 *) * Screen->EntryCount);
             for (i = 0; i <= State->MaxIndex; i++)
-                DisplayStrings[i] = PoolPrint(L" %-.*s ", MenuWidth, Screen->Entries[i]->Title);
-            // TODO: shorten strings that are too long (PoolPrint doesn't do that...)
+                SPrint(DisplayStrings[i], Screen->EntryCount, L" %-.*s ", MenuWidth, Screen->Entries[i]->Title);
+//                DisplayStrings[i] = PoolPrint(L" %-.*s ", MenuWidth, Screen->Entries[i]->Title);
             // TODO: use more elaborate techniques for shortening too long strings (ellipses in the middle)
             // TODO: account for double-width characters
 
             // TODO: use more elaborate techniques for shortening too long strings (ellipses in the middle)
             // TODO: account for double-width characters
 
@@ -602,9 +601,8 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
                 // paint or update message
                 refit_call2_wrapper(ST->ConOut->SetAttribute, ST->ConOut, ATTR_ERROR);
                 refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 3, ConHeight - 1);
                 // paint or update message
                 refit_call2_wrapper(ST->ConOut->SetAttribute, ST->ConOut, ATTR_ERROR);
                 refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 3, ConHeight - 1);
-                TimeoutMessage = PoolPrint(L"%s  ", ParamText);
+                SPrint(TimeoutMessage, 255, L"%s  ", ParamText);
                 refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, TimeoutMessage);
                 refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, TimeoutMessage);
-                FreePool(TimeoutMessage);
             }
             break;
 
             }
             break;
 
index f9052d17d7ab331bec30ceac03a4629651f88cfb..6e4170b99874d9c544cc4d8622373ba8c1623163 100644 (file)
 #ifndef __REFIND_MENU_H_
 #define __REFIND_MENU_H_
 
 #ifndef __REFIND_MENU_H_
 #define __REFIND_MENU_H_
 
+#ifdef __MAKEWITH_GNUEFI
 #include "efi.h"
 #include "efilib.h"
 #include "efi.h"
 #include "efilib.h"
+#else
+#include "../include/tiano_includes.h"
+#endif
+#include "global.h"
 
 #include "libeg.h"
 
 
 #include "libeg.h"
 
index 0ad950fd5f07f3b56808598cf152e2195cedf64d..3b98586b5c41e706e4b5a279a145e74d4cbbfffd 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * refit/screen.c
+ * refind/screen.c
  * Screen handling functions
  *
  * Copyright (c) 2006 Christoph Pfisterer
  * Screen handling functions
  *
  * Copyright (c) 2006 Christoph Pfisterer
@@ -38,9 +38,9 @@
 #include "screen.h"
 #include "config.h"
 #include "libegint.h"
 #include "screen.h"
 #include "config.h"
 #include "libegint.h"
-#include "refit_call_wrapper.h"
+#include "../include/refit_call_wrapper.h"
 
 
-#include "egemb_refind_banner.h"
+#include "../include/egemb_refind_banner.h"
 
 // Console defines and variables
 
 
 // Console defines and variables
 
@@ -177,10 +177,11 @@ VOID BeginExternalScreen(IN BOOLEAN UseGraphicsMode, IN CHAR16 *Title)
         BltClearScreen(FALSE);
     } else {
        egClearScreen(&DarkBackgroundPixel);
         BltClearScreen(FALSE);
     } else {
        egClearScreen(&DarkBackgroundPixel);
+       DrawScreenHeader(Title);
     } // if/else
 
     // show the header
     } // if/else
 
     // show the header
-    DrawScreenHeader(Title);
+//    DrawScreenHeader(Title);
 
     if (!UseGraphicsMode)
         SwitchToText(TRUE);
 
     if (!UseGraphicsMode)
         SwitchToText(TRUE);
@@ -302,6 +303,7 @@ VOID EndlessIdleLoop(VOID)
 // Error handling
 //
 
 // Error handling
 //
 
+#ifdef __MAKEWITH_GNUEFI
 BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CHAR16 *where)
 {
     CHAR16 ErrorName[64];
 BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CHAR16 *where)
 {
     CHAR16 ErrorName[64];
@@ -335,6 +337,41 @@ BOOLEAN CheckError(IN EFI_STATUS Status, IN CHAR16 *where)
 
     return TRUE;
 }
 
     return TRUE;
 }
+#else
+BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CHAR16 *where)
+{
+//    CHAR16 ErrorName[64];
+
+    if (!EFI_ERROR(Status))
+        return FALSE;
+
+//    StatusToString(ErrorName, Status);
+    gST->ConOut->SetAttribute (gST->ConOut, ATTR_ERROR);
+    Print(L"Fatal Error: %r %s\n", Status, where);
+    gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC);
+    haveError = TRUE;
+
+    //gBS->Exit(ImageHandle, ExitStatus, ExitDataSize, ExitData);
+
+    return TRUE;
+}
+
+BOOLEAN CheckError(IN EFI_STATUS Status, IN CHAR16 *where)
+{
+//    CHAR16 ErrorName[64];
+
+    if (!EFI_ERROR(Status))
+        return FALSE;
+
+//    StatusToString(ErrorName, Status);
+    gST->ConOut->SetAttribute (gST->ConOut, ATTR_ERROR);
+    Print(L"Error: %r %s\n", Status, where);
+    gST->ConOut->SetAttribute (gST->ConOut, ATTR_BASIC);
+    haveError = TRUE;
+
+    return TRUE;
+}
+#endif
 
 //
 // Graphics functions
 
 //
 // Graphics functions
@@ -425,7 +462,7 @@ VOID BltImageAlpha(IN EG_IMAGE *Image, IN UINTN XPos, IN UINTN YPos, IN EG_PIXEL
 
 VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG_IMAGE *BadgeImage, IN UINTN XPos, IN UINTN YPos)
 {
 
 VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG_IMAGE *BadgeImage, IN UINTN XPos, IN UINTN YPos)
 {
-     UINTN TotalWidth, TotalHeight, CompWidth = 0, CompHeight = 0, OffsetX = 0, OffsetY = 0;
+     UINTN TotalWidth = 0, TotalHeight = 0, CompWidth = 0, CompHeight = 0, OffsetX = 0, OffsetY = 0;
      EG_IMAGE *CompImage = NULL;
 
      // initialize buffer with base image
      EG_IMAGE *CompImage = NULL;
 
      // initialize buffer with base image
index 1b2dfa641faa75c8dada94d906ed2237c4f19538..d0ffa29121b0695e318682dbb489139ed4c8c7e4 100644 (file)
 #ifndef __SCREEN_H_
 #define __SCREEN_H_
 
 #ifndef __SCREEN_H_
 #define __SCREEN_H_
 
+#ifdef __MAKEWITH_GNUEFI
 #include "efi.h"
 #include "efilib.h"
 #include "efi.h"
 #include "efilib.h"
+#else
+#include "../include/tiano_includes.h"
+#endif
 
 #include "libeg.h"
 
 
 #include "libeg.h"