From: srs5694 Date: Thu, 21 Jun 2012 18:38:37 +0000 (-0400) Subject: TianoCore build support; new use_graphics_for refind.conf token X-Git-Url: https://code.delx.au/refind/commitdiff_plain/4c9f41e161bd197922912efbcf4cc676077d5c00 TianoCore build support; new use_graphics_for refind.conf token --- diff --git a/EfiLib/BdsConnect.c b/EfiLib/BdsConnect.c new file mode 100644 index 0000000..d168462 --- /dev/null +++ b/EfiLib/BdsConnect.c @@ -0,0 +1,641 @@ +/** @file + BDS Lib functions which relate with connect the device + +Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "Platform.h" + + +/** + This function will connect all the system driver to controller + first, and then special connect the default console, this make + sure all the system controller available and the platform default + console connected. + +**/ +VOID +EFIAPI +BdsLibConnectAll ( + VOID + ) +{ + // + // Connect the platform console first + // + BdsLibConnectAllDefaultConsoles (); + + // + // Generic way to connect all the drivers + // + BdsLibConnectAllDriversToAllControllers (); + + // + // Here we have the assumption that we have already had + // platform default console + // + BdsLibConnectAllDefaultConsoles (); +} + + +/** + This function will connect all the system drivers to all controllers + first, and then connect all the console devices the system current + have. After this we should get all the device work and console available + if the system have console device. + +**/ +VOID +BdsLibGenericConnectAll ( + VOID + ) +{ + // + // Most generic way to connect all the drivers + // + BdsLibConnectAllDriversToAllControllers (); + BdsLibConnectAllConsoles (); +} + + +/** + This function will create all handles associate with every device + path node. If the handle associate with one device path node can not + be created success, then still give one chance to do the dispatch, + which load the missing drivers if possible. + + @param DevicePathToConnect The device path which will be connected, it can be + a multi-instance device path + + @retval EFI_SUCCESS All handles associate with every device path node + have been created + @retval EFI_OUT_OF_RESOURCES There is no resource to create new handles + @retval EFI_NOT_FOUND Create the handle associate with one device path + node failed + +**/ +EFI_STATUS +EFIAPI +BdsLibConnectDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath; + EFI_DEVICE_PATH_PROTOCOL *Instance; + EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath; + EFI_DEVICE_PATH_PROTOCOL *Next; + EFI_HANDLE Handle; + EFI_HANDLE PreviousHandle; + UINTN Size; + + if (DevicePathToConnect == NULL) { + return EFI_SUCCESS; + } + + DevicePath = DuplicateDevicePath (DevicePathToConnect); + if (DevicePath == NULL) { + return EFI_OUT_OF_RESOURCES; + } + CopyOfDevicePath = DevicePath; + + do { + // + // The outer loop handles multi instance device paths. + // Only console variables contain multiple instance device paths. + // + // After this call DevicePath points to the next Instance + // + Instance = GetNextDevicePathInstance (&DevicePath, &Size); + if (Instance == NULL) { + FreePool (CopyOfDevicePath); + return EFI_OUT_OF_RESOURCES; + } + + Next = Instance; + while (!IsDevicePathEndType (Next)) { + Next = NextDevicePathNode (Next); + } + + SetDevicePathEndNode (Next); + + // + // Start the real work of connect with RemainingDevicePath + // + PreviousHandle = NULL; + do { + // + // Find the handle that best matches the Device Path. If it is only a + // partial match the remaining part of the device path is returned in + // RemainingDevicePath. + // + RemainingDevicePath = Instance; + Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle); + + if (!EFI_ERROR (Status)) { + if (Handle == PreviousHandle) { + // + // If no forward progress is made try invoking the Dispatcher. + // A new FV may have been added to the system an new drivers + // may now be found. + // Status == EFI_SUCCESS means a driver was dispatched + // Status == EFI_NOT_FOUND means no new drivers were dispatched + // + Status = gDS->Dispatch (); + } + + if (!EFI_ERROR (Status)) { + PreviousHandle = Handle; + // + // Connect all drivers that apply to Handle and RemainingDevicePath, + // the Recursive flag is FALSE so only one level will be expanded. + // + // Do not check the connect status here, if the connect controller fail, + // then still give the chance to do dispatch, because partial + // RemainingDevicepath may be in the new FV + // + // 1. If the connect fail, RemainingDevicepath and handle will not + // change, so next time will do the dispatch, then dispatch's status + // will take effect + // 2. If the connect success, the RemainingDevicepath and handle will + // change, then avoid the dispatch, we have chance to continue the + // next connection + // + gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE); + } + } + // + // Loop until RemainingDevicePath is an empty device path + // + } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath)); + + } while (DevicePath != NULL); + + if (CopyOfDevicePath != NULL) { + FreePool (CopyOfDevicePath); + } + // + // All handle with DevicePath exists in the handle database + // + return Status; +} + + +/** + This function will connect all current system handles recursively. + + gBS->ConnectController() service is invoked for each handle exist in system handler buffer. + If the handle is bus type handler, all childrens also will be connected recursively + by gBS->ConnectController(). + + @retval EFI_SUCCESS All handles and it's child handle have been connected + @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer(). + +**/ +EFI_STATUS +EFIAPI +BdsLibConnectAllEfi ( + VOID + ) +{ + EFI_STATUS Status; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + UINTN Index; + + Status = gBS->LocateHandleBuffer ( + AllHandles, + NULL, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE); + } + + if (HandleBuffer != NULL) { + FreePool (HandleBuffer); + } + + return EFI_SUCCESS; +} + +/** + This function will disconnect all current system handles. + + gBS->DisconnectController() is invoked for each handle exists in system handle buffer. + If handle is a bus type handle, all childrens also are disconnected recursively by + gBS->DisconnectController(). + + @retval EFI_SUCCESS All handles have been disconnected + @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer(). + +**/ +EFI_STATUS +EFIAPI +BdsLibDisconnectAllEfi ( + VOID + ) +{ + EFI_STATUS Status; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + UINTN Index; + + // + // Disconnect all + // + Status = gBS->LocateHandleBuffer ( + AllHandles, + NULL, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL); + } + + if (HandleBuffer != NULL) { + FreePool (HandleBuffer); + } + + return EFI_SUCCESS; +} + +EFI_STATUS ScanDeviceHandles(EFI_HANDLE ControllerHandle, + UINTN *HandleCount, + EFI_HANDLE **HandleBuffer, + UINT32 **HandleType) +{ + EFI_STATUS Status; + UINTN HandleIndex; + EFI_GUID **ProtocolGuidArray; + UINTN ArrayCount; + UINTN ProtocolIndex; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo; + UINTN OpenInfoCount; + UINTN OpenInfoIndex; + UINTN ChildIndex; + + *HandleCount = 0; + *HandleBuffer = NULL; + *HandleType = NULL; + + // + // Retrieve the list of all handles from the handle database + // + Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, HandleCount, HandleBuffer); + if (EFI_ERROR (Status)) goto Error; + + *HandleType = AllocatePool (*HandleCount * sizeof (UINT32)); + if (*HandleType == NULL) goto Error; + + for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) { + (*HandleType)[HandleIndex] = EFI_HANDLE_TYPE_UNKNOWN; + // + // Retrieve the list of all the protocols on each handle + // + Status = gBS->ProtocolsPerHandle ( + (*HandleBuffer)[HandleIndex], + &ProtocolGuidArray, + &ArrayCount + ); + if (!EFI_ERROR (Status)) { + for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) + { + + if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid)) + { + (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_IMAGE_HANDLE; + } + + if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid)) + { + (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE; + } + + if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid)) + { + (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE; + } + + if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid)) + { + (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE; + } + + if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid)) + { + (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_COMPONENT_NAME_HANDLE; + } + + if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) + { + (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_COMPONENT_NAME_HANDLE; + } + + if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid)) + { + (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DEVICE_HANDLE; + } + + // + // Retrieve the list of agents that have opened each protocol + // + Status = gBS->OpenProtocolInformation ( + (*HandleBuffer)[HandleIndex], + ProtocolGuidArray[ProtocolIndex], + &OpenInfo, + &OpenInfoCount + ); + if (!EFI_ERROR (Status)) { + + for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) { + + if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) + { + if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) + { + for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) + { + if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) + { + (*HandleType)[ChildIndex] |= EFI_HANDLE_TYPE_DEVICE_DRIVER; + } + } + } + + if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) + { + (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_PARENT_HANDLE; + for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) + { + if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) + { + (*HandleType)[ChildIndex] |= EFI_HANDLE_TYPE_BUS_DRIVER; + } + } + } + } + } + + FreePool (OpenInfo); + } + } + + FreePool (ProtocolGuidArray); + } + } + + return EFI_SUCCESS; + +Error: + if (*HandleType != NULL) { + FreePool (*HandleType); + } + + if (*HandleBuffer != NULL) { + FreePool (*HandleBuffer); + } + + *HandleCount = 0; + *HandleBuffer = NULL; + *HandleType = NULL; + + return Status; +} + + + +EFI_STATUS BdsLibConnectMostlyAllEfi() +{ + EFI_STATUS Status; + UINTN AllHandleCount; + EFI_HANDLE *AllHandleBuffer; + UINTN Index; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + UINT32 *HandleType; + UINTN HandleIndex; + BOOLEAN Parent; + BOOLEAN Device; + EFI_PCI_IO_PROTOCOL* PciIo; + PCI_TYPE00 Pci; + + + Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &AllHandleCount, &AllHandleBuffer); + if (CheckError(Status, L"locating handle buffer")) + return Status; + + for (Index = 0; Index < AllHandleCount; Index++) + { + Status = ScanDeviceHandles(AllHandleBuffer[Index], &HandleCount, &HandleBuffer, &HandleType); + + if (EFI_ERROR (Status)) + goto Done; + + Device = TRUE; + + if (HandleType[Index] & EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE) + Device = FALSE; + if (HandleType[Index] & EFI_HANDLE_TYPE_IMAGE_HANDLE) + Device = FALSE; + + if (Device) + { + Parent = FALSE; + for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) + { + if (HandleType[HandleIndex] & EFI_HANDLE_TYPE_PARENT_HANDLE) + Parent = TRUE; + } + + if (!Parent) + { + if (HandleType[Index] & EFI_HANDLE_TYPE_DEVICE_HANDLE) + { + Status = gBS->HandleProtocol (AllHandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID*)&PciIo); + if (!EFI_ERROR (Status)) + { + Status = PciIo->Pci.Read (PciIo,EfiPciIoWidthUint32, 0, sizeof (Pci) / sizeof (UINT32), &Pci); + if (!EFI_ERROR (Status)) + { + if(IS_PCI_VGA(&Pci)==TRUE) + { + gBS->DisconnectController(AllHandleBuffer[Index], NULL, NULL); + } + } + } + Status = gBS->ConnectController(AllHandleBuffer[Index], NULL, NULL, TRUE); + } + } + } + + FreePool (HandleBuffer); + FreePool (HandleType); + } + +Done: + FreePool (AllHandleBuffer); + return Status; +} + + + +/** + Connects all drivers to all controllers. + This function make sure all the current system driver will manage + the correspoinding controllers if have. And at the same time, make + sure all the system controllers have driver to manage it if have. + +**/ +VOID +EFIAPI +BdsLibConnectAllDriversToAllControllers ( + VOID + ) +{ + EFI_STATUS Status; + + do { + // + // Connect All EFI 1.10 drivers following EFI 1.10 algorithm + // + //BdsLibConnectAllEfi (); + BdsLibConnectMostlyAllEfi (); + + // + // Check to see if it's possible to dispatch an more DXE drivers. + // The BdsLibConnectAllEfi () may have made new DXE drivers show up. + // If anything is Dispatched Status == EFI_SUCCESS and we will try + // the connect again. + // + Status = gDS->Dispatch (); + + } while (!EFI_ERROR (Status)); + +} + + +/** + Connect the specific Usb device which match the short form device path, + and whose bus is determined by Host Controller (Uhci or Ehci). + + @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci + (0xFF) + @param RemainingDevicePath a short-form device path that starts with the first + element being a USB WWID or a USB Class device + path + + @return EFI_INVALID_PARAMETER RemainingDevicePath is NULL pointer. + RemainingDevicePath is not a USB device path. + Invalid HostControllerPI type. + @return EFI_SUCCESS Success to connect USB device + @return EFI_NOT_FOUND Fail to find handle for USB controller to connect. + +**/ +EFI_STATUS +EFIAPI +BdsLibConnectUsbDevByShortFormDP( + IN UINT8 HostControllerPI, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleArray; + UINTN HandleArrayCount; + UINTN Index; + EFI_PCI_IO_PROTOCOL *PciIo; + UINT8 Class[3]; + BOOLEAN AtLeastOneConnected; + + // + // Check the passed in parameters + // + if (RemainingDevicePath == NULL) { + return EFI_INVALID_PARAMETER; + } + + if ((DevicePathType (RemainingDevicePath) != MESSAGING_DEVICE_PATH) || + ((DevicePathSubType (RemainingDevicePath) != MSG_USB_CLASS_DP) + && (DevicePathSubType (RemainingDevicePath) != MSG_USB_WWID_DP) + )) { + return EFI_INVALID_PARAMETER; + } + + if (HostControllerPI != 0xFF && + HostControllerPI != 0x00 && + HostControllerPI != 0x10 && + HostControllerPI != 0x20 && + HostControllerPI != 0x30) { + return EFI_INVALID_PARAMETER; + } + + // + // Find the usb host controller firstly, then connect with the remaining device path + // + AtLeastOneConnected = FALSE; + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiPciIoProtocolGuid, + NULL, + &HandleArrayCount, + &HandleArray + ); + if (!EFI_ERROR (Status)) { + for (Index = 0; Index < HandleArrayCount; Index++) { + Status = gBS->HandleProtocol ( + HandleArray[Index], + &gEfiPciIoProtocolGuid, + (VOID **)&PciIo + ); + if (!EFI_ERROR (Status)) { + // + // Check whether the Pci device is the wanted usb host controller + // + Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class); + if (!EFI_ERROR (Status)) { + if ((PCI_CLASS_SERIAL == Class[2]) && + (PCI_CLASS_SERIAL_USB == Class[1])) { + if (HostControllerPI == Class[0] || HostControllerPI == 0xFF) { + Status = gBS->ConnectController ( + HandleArray[Index], + NULL, + RemainingDevicePath, + FALSE + ); + if (!EFI_ERROR(Status)) { + AtLeastOneConnected = TRUE; + } + } + } + } + } + } + + if (AtLeastOneConnected) { + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} diff --git a/EfiLib/BmLib.c b/EfiLib/BmLib.c new file mode 100644 index 0000000..a8b4dc5 --- /dev/null +++ b/EfiLib/BmLib.c @@ -0,0 +1,325 @@ +/** @file + Utility routines used by boot maintenance modules. + +Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "Platform.h" +/** + + Find the first instance of this Protocol + in the system and return it's interface. + + + @param ProtocolGuid Provides the protocol to search for + @param Interface On return, a pointer to the first interface + that matches ProtocolGuid + + @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found + @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid + +**/ +EFI_STATUS +EfiLibLocateProtocol ( + IN EFI_GUID *ProtocolGuid, + OUT VOID **Interface + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol ( + ProtocolGuid, + NULL, + (VOID **) Interface + ); + return Status; +} + +/** + + Function opens and returns a file handle to the root directory of a volume. + + @param DeviceHandle A handle for a device + + @return A valid file handle or NULL is returned + +**/ +EFI_FILE_HANDLE +EfiLibOpenRoot ( + IN EFI_HANDLE DeviceHandle + ) +{ + EFI_STATUS Status; + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume; + EFI_FILE_HANDLE File; + + File = NULL; + + // + // File the file system interface to the device + // + Status = gBS->HandleProtocol ( + DeviceHandle, + &gEfiSimpleFileSystemProtocolGuid, + (VOID **) &Volume + ); + + // + // Open the root directory of the volume + // + if (!EFI_ERROR (Status)) { + Status = Volume->OpenVolume ( + Volume, + &File + ); + } + // + // Done + // + return EFI_ERROR (Status) ? NULL : File; +} + +/** + + Function gets the file system information from an open file descriptor, + and stores it in a buffer allocated from pool. + + + @param FHand The file handle. + + @return A pointer to a buffer with file information. + @retval NULL is returned if failed to get Volume Label Info. + +**/ +EFI_FILE_SYSTEM_VOLUME_LABEL * +EfiLibFileSystemVolumeLabelInfo ( + IN EFI_FILE_HANDLE FHand + ) +{ + EFI_STATUS Status; + EFI_FILE_SYSTEM_VOLUME_LABEL *VolumeInfo = NULL; + UINTN Size = 0; + + Status = FHand->GetInfo (FHand, &gEfiFileSystemVolumeLabelInfoIdGuid, &Size, VolumeInfo); + if (Status == EFI_BUFFER_TOO_SMALL) { + VolumeInfo = AllocateZeroPool (Size); + Status = FHand->GetInfo (FHand, &gEfiFileSystemVolumeLabelInfoIdGuid, &Size, VolumeInfo); + } + + return EFI_ERROR(Status)?NULL:VolumeInfo; +} + +/** + Duplicate a string. + + @param Src The source. + + @return A new string which is duplicated copy of the source. + @retval NULL If there is not enough memory. + +**/ +CHAR16 * +EfiStrDuplicate ( + IN CHAR16 *Src + ) +{ + CHAR16 *Dest; + UINTN Size; + + Size = StrSize (Src); //at least 2bytes + Dest = AllocateZeroPool (Size); +// ASSERT (Dest != NULL); + if (Dest != NULL) { + CopyMem (Dest, Src, Size); + } + + return Dest; +} +//Compare strings case insensitive +INTN +EFIAPI +StriCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString + ) +{ + + while ((*FirstString != L'\0') && ((*FirstString & ~0x20) == (*SecondString & ~0x20))) { + FirstString++; + SecondString++; + } + return *FirstString - *SecondString; +} + + +/** + + Function gets the file information from an open file descriptor, and stores it + in a buffer allocated from pool. + + @param FHand File Handle. + + @return A pointer to a buffer with file information or NULL is returned + +**/ +EFI_FILE_INFO * +EfiLibFileInfo ( + IN EFI_FILE_HANDLE FHand + ) +{ + EFI_STATUS Status; + EFI_FILE_INFO *FileInfo = NULL; + UINTN Size = 0; + + Status = FHand->GetInfo (FHand, &gEfiFileInfoGuid, &Size, FileInfo); + if (Status == EFI_BUFFER_TOO_SMALL) { + FileInfo = AllocateZeroPool (Size); + Status = FHand->GetInfo (FHand, &gEfiFileInfoGuid, &Size, FileInfo); + } + + return EFI_ERROR(Status)?NULL:FileInfo; +} + +EFI_FILE_SYSTEM_INFO * +EfiLibFileSystemInfo ( + IN EFI_FILE_HANDLE FHand + ) +{ + EFI_STATUS Status; + EFI_FILE_SYSTEM_INFO *FileSystemInfo = NULL; + UINTN Size = 0; + + Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo); + if (Status == EFI_BUFFER_TOO_SMALL) { + FileSystemInfo = AllocateZeroPool (Size); + Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo); + } + + return EFI_ERROR(Status)?NULL:FileSystemInfo; +} + +/** + Function is used to determine the number of device path instances + that exist in a device path. + + + @param DevicePath A pointer to a device path data structure. + + @return This function counts and returns the number of device path instances + in DevicePath. + +**/ +UINTN +EfiDevicePathInstanceCount ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + UINTN Count; + UINTN Size; + + Count = 0; + while (GetNextDevicePathInstance (&DevicePath, &Size) != NULL) { + Count += 1; + } + + return Count; +} + +/** + Adjusts the size of a previously allocated buffer. + + + @param OldPool - A pointer to the buffer whose size is being adjusted. + @param OldSize - The size of the current buffer. + @param NewSize - The size of the new buffer. + + @return The newly allocated buffer. + @retval NULL Allocation failed. + +**/ +VOID * +EfiReallocatePool ( + IN VOID *OldPool, + IN UINTN OldSize, + IN UINTN NewSize + ) +{ + VOID *NewPool; + + NewPool = NULL; + if (NewSize != 0) { + NewPool = AllocateZeroPool (NewSize); + } + + if (OldPool != NULL) { + if (NewPool != NULL) { + CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize); + } + + FreePool (OldPool); + } + + return NewPool; +} + +/** + Compare two EFI_TIME data. + + + @param FirstTime - A pointer to the first EFI_TIME data. + @param SecondTime - A pointer to the second EFI_TIME data. + + @retval TRUE The FirstTime is not later than the SecondTime. + @retval FALSE The FirstTime is later than the SecondTime. + +**/ +BOOLEAN +TimeCompare ( + IN EFI_TIME *FirstTime, + IN EFI_TIME *SecondTime + ) +{ + if (FirstTime->Year != SecondTime->Year) { + return (BOOLEAN) (FirstTime->Year < SecondTime->Year); + } else if (FirstTime->Month != SecondTime->Month) { + return (BOOLEAN) (FirstTime->Month < SecondTime->Month); + } else if (FirstTime->Day != SecondTime->Day) { + return (BOOLEAN) (FirstTime->Day < SecondTime->Day); + } else if (FirstTime->Hour != SecondTime->Hour) { + return (BOOLEAN) (FirstTime->Hour < SecondTime->Hour); + } else if (FirstTime->Minute != SecondTime->Minute) { + return (BOOLEAN) (FirstTime->Minute < FirstTime->Minute); + } else if (FirstTime->Second != SecondTime->Second) { + return (BOOLEAN) (FirstTime->Second < SecondTime->Second); + } + + return (BOOLEAN) (FirstTime->Nanosecond <= SecondTime->Nanosecond); +} + +/** + Get a string from the Data Hub record based on + a device path. + + @param DevPath The device Path. + + @return A string located from the Data Hub records based on + the device path. + @retval NULL If failed to get the String from Data Hub. + +**/ +/* +UINT16 * +EfiLibStrFromDatahub ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +{ + return NULL; +}*/ diff --git a/EfiLib/Console.c b/EfiLib/Console.c new file mode 100644 index 0000000..b5cf03f --- /dev/null +++ b/EfiLib/Console.c @@ -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 index 0000000..75c666e --- /dev/null +++ b/EfiLib/DevicePath.c @@ -0,0 +1,1575 @@ +/** @file + BDS internal function define the default device path string, it can be + replaced by platform device path. + +Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "Platform.h" + +/** + Concatenates a formatted unicode string to allocated pool. + The caller must free the resulting buffer. + + @param Str Tracks the allocated pool, size in use, and amount of pool allocated. + @param Fmt The format string + @param ... The data will be printed. + + @return Allocated buffer with the formatted string printed in it. + The caller must free the allocated buffer. + The buffer allocation is not packed. + +**/ + +CHAR16 * +EFIAPI +CatPrint ( + IN OUT POOL_PRINT *Str, + IN CHAR16 *Fmt, + ... + ) +{ + UINT16 *AppendStr; + VA_LIST Args; + UINTN StringSize; + + AppendStr = AllocateZeroPool (0x1000); + if (AppendStr == NULL) { + return Str->Str; + } + + VA_START (Args, Fmt); + UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args); + VA_END (Args); + if (NULL == Str->Str) { + StringSize = StrSize (AppendStr); + Str->Str = AllocateZeroPool (StringSize); + ASSERT (Str->Str != NULL); + } else { + StringSize = StrSize (AppendStr); + StringSize += (StrSize (Str->Str) - sizeof (UINT16)); + + Str->Str = EfiReallocatePool ( + Str->Str, + StrSize (Str->Str), + StringSize + ); + ASSERT (Str->Str != NULL); + } + + Str->Maxlen = MAX_CHAR * sizeof (UINT16); + if (StringSize < Str->Maxlen) { + StrCat (Str->Str, AppendStr); + Str->Len = StringSize - sizeof (UINT16); + } + + FreePool (AppendStr); + return Str->Str; +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathPci ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + PCI_DEVICE_PATH *Pci; + + Pci = DevPath; + CatPrint (Str, L"Pci(%x|%x)", (UINTN) Pci->Device, (UINTN) Pci->Function); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathPccard ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + PCCARD_DEVICE_PATH *Pccard; + + Pccard = DevPath; + CatPrint (Str, L"Pcmcia(Function%x)", (UINTN) Pccard->FunctionNumber); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathMemMap ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + MEMMAP_DEVICE_PATH *MemMap; + + MemMap = DevPath; + CatPrint ( + Str, + L"MemMap(%d:%lx-%lx)", + (UINTN) MemMap->MemoryType, + MemMap->StartingAddress, + MemMap->EndingAddress + ); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathController ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + CONTROLLER_DEVICE_PATH *Controller; + + Controller = DevPath; + CatPrint (Str, L"Ctrl(%d)", (UINTN) Controller->ControllerNumber); +} + + +/** + Convert Vendor device path to device name. + + @param Str The buffer store device name + @param DevPath Pointer to vendor device path + +**/ +VOID +DevPathVendor ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + VENDOR_DEVICE_PATH *Vendor; + CHAR16 *Type; + UINTN DataLength; + UINTN Index; +// UINT32 FlowControlMap; + + UINT16 Info; + + Vendor = DevPath; + + switch (DevicePathType (&Vendor->Header)) { + case HARDWARE_DEVICE_PATH: + Type = L"Hw"; + break; + + case MESSAGING_DEVICE_PATH: + Type = L"Msg"; +/* + if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) { + CatPrint (Str, L"VenPcAnsi()"); + return ; + } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) { + CatPrint (Str, L"VenVt100()"); + return ; + } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) { + CatPrint (Str, L"VenVt100Plus()"); + return ; + } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) { + CatPrint (Str, L"VenUft8()"); + return ; + } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid )) { + FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap); + switch (FlowControlMap & 0x00000003) { + case 0: + CatPrint (Str, L"UartFlowCtrl(%s)", L"None"); + break; + + case 1: + CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware"); + break; + + case 2: + CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff"); + break; + + default: + break; + } + + return ; + + } else + */ + if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) { + CatPrint ( + Str, + L"SAS(%lx,%lx,%x,", + ((SAS_DEVICE_PATH *) Vendor)->SasAddress, + ((SAS_DEVICE_PATH *) Vendor)->Lun, + (UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort + ); + Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology); + if ((Info & 0x0f) == 0) { + CatPrint (Str, L"NoTopology,0,0,0,"); + } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) { + CatPrint ( + Str, + L"%s,%s,%s,", + ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS", + ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal", + ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct" + ); + if ((Info & 0x0f) == 1) { + CatPrint (Str, L"0,"); + } else { + CatPrint (Str, L"%x,", (UINTN) ((Info >> 8) & 0xff)); + } + } else { + CatPrint (Str, L"0,0,0,0,"); + } + + CatPrint (Str, L"%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved); + return ; + + } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) { + CatPrint (Str, L"DebugPort()"); + return ; + } + break; + + case MEDIA_DEVICE_PATH: + Type = L"Media"; + break; + + default: + Type = L"?"; + break; + } + + CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid); + DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH); + if (DataLength > 0) { + CatPrint (Str, L","); + for (Index = 0; Index < DataLength; Index++) { + CatPrint (Str, L"%02x", (UINTN) ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]); + } + } + CatPrint (Str, L")"); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathAcpi ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + ACPI_HID_DEVICE_PATH *Acpi; + + Acpi = DevPath; + if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { + CatPrint (Str, L"Acpi(PNP%04x,%x)", (UINTN) EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID); + } else { + CatPrint (Str, L"Acpi(%08x,%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID); + } +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathExtendedAcpi ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi; + + // + // Index for HID, UID and CID strings, 0 for non-exist + // + UINT16 HIDSTRIdx; + UINT16 UIDSTRIdx; + UINT16 CIDSTRIdx; + UINT16 Index; + UINT16 Length; + UINT16 Anchor; + CHAR8 *AsChar8Array; + + HIDSTRIdx = 0; + UIDSTRIdx = 0; + CIDSTRIdx = 0; + ExtendedAcpi = DevPath; + Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) ExtendedAcpi); + + AsChar8Array = (CHAR8 *) ExtendedAcpi; + + // + // find HIDSTR + // + Anchor = 16; + for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) { + ; + } + if (Index > Anchor) { + HIDSTRIdx = Anchor; + } + // + // find UIDSTR + // + Anchor = (UINT16) (Index + 1); + for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) { + ; + } + if (Index > Anchor) { + UIDSTRIdx = Anchor; + } + // + // find CIDSTR + // + Anchor = (UINT16) (Index + 1); + for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) { + ; + } + if (Index > Anchor) { + CIDSTRIdx = Anchor; + } + + if (HIDSTRIdx == 0 && CIDSTRIdx == 0 && ExtendedAcpi->UID == 0) { + CatPrint (Str, L"AcpiExp("); + if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { + CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID)); + } else { + CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID); + } + if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { + CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID)); + } else { + CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID); + } + if (UIDSTRIdx != 0) { + CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx); + } else { + CatPrint (Str, L"\"\")"); + } + } else { + CatPrint (Str, L"AcpiEx("); + if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { + CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID)); + } else { + CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID); + } + if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { + CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID)); + } else { + CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID); + } + CatPrint (Str, L"%x,", (UINTN) ExtendedAcpi->UID); + + if (HIDSTRIdx != 0) { + CatPrint (Str, L"%a,", AsChar8Array + HIDSTRIdx); + } else { + CatPrint (Str, L"\"\","); + } + if (CIDSTRIdx != 0) { + CatPrint (Str, L"%a,", AsChar8Array + CIDSTRIdx); + } else { + CatPrint (Str, L"\"\","); + } + if (UIDSTRIdx != 0) { + CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx); + } else { + CatPrint (Str, L"\"\")"); + } + } + +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathAdrAcpi ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + ACPI_ADR_DEVICE_PATH *AcpiAdr; + UINT16 Index; + UINT16 Length; + UINT16 AdditionalAdrCount; + + AcpiAdr = DevPath; + Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr); + AdditionalAdrCount = (UINT16) ((Length - 8) / 4); + + CatPrint (Str, L"AcpiAdr(%x", (UINTN) AcpiAdr->ADR); + for (Index = 0; Index < AdditionalAdrCount; Index++) { + CatPrint (Str, L",%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4)); + } + CatPrint (Str, L")"); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathAtapi ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + ATAPI_DEVICE_PATH *Atapi; + + Atapi = DevPath; + CatPrint ( + Str, + L"Ata(%s,%s)", + (Atapi->PrimarySecondary != 0)? L"Secondary" : L"Primary", + (Atapi->SlaveMaster != 0)? L"Slave" : L"Master" + ); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathScsi ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + SCSI_DEVICE_PATH *Scsi; + + Scsi = DevPath; + CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathFibre ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + FIBRECHANNEL_DEVICE_PATH *Fibre; + + Fibre = DevPath; + CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPath1394 ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + F1394_DEVICE_PATH *F1394Path; + + F1394Path = DevPath; + CatPrint (Str, L"1394(%lx)", &F1394Path->Guid); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathUsb ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + USB_DEVICE_PATH *Usb; + + Usb = DevPath; + CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathUsbWWID ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + USB_WWID_DEVICE_PATH *UsbWWId; + + UsbWWId = DevPath; + CatPrint ( + Str, + L"UsbWwid(%x,%x,%x,\"WWID\")", + (UINTN) UsbWWId->VendorId, + (UINTN) UsbWWId->ProductId, + (UINTN) UsbWWId->InterfaceNumber + ); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathLogicalUnit ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit; + + LogicalUnit = DevPath; + CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathUsbClass ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + USB_CLASS_DEVICE_PATH *UsbClass; + + UsbClass = DevPath; + CatPrint ( + Str, + L"Usb Class(%x,%x,%x,%x,%x)", + (UINTN) UsbClass->VendorId, + (UINTN) UsbClass->ProductId, + (UINTN) UsbClass->DeviceClass, + (UINTN) UsbClass->DeviceSubClass, + (UINTN) UsbClass->DeviceProtocol + ); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathSata ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + SATA_DEVICE_PATH *Sata; + + Sata = DevPath; + if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) { + CatPrint ( + Str, + L"Sata(%x,%x)", + (UINTN) Sata->HBAPortNumber, + (UINTN) Sata->Lun + ); + } else { + CatPrint ( + Str, + L"Sata(%x,%x,%x)", + (UINTN) Sata->HBAPortNumber, + (UINTN) Sata->PortMultiplierPortNumber, + (UINTN) Sata->Lun + ); + } +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathI2O ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + I2O_DEVICE_PATH *I2OPath; + + I2OPath = DevPath; + CatPrint (Str, L"I2O(%x)", (UINTN) I2OPath->Tid); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathMacAddr ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + MAC_ADDR_DEVICE_PATH *MACDevPath; + UINTN HwAddressSize; + UINTN Index; + + MACDevPath = DevPath; + + HwAddressSize = sizeof (EFI_MAC_ADDRESS); + if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) { + HwAddressSize = 6; + } + + CatPrint (Str, L"Mac("); + + for (Index = 0; Index < HwAddressSize; Index++) { + CatPrint (Str, L"%02x", (UINTN) MACDevPath->MacAddress.Addr[Index]); + } + + CatPrint (Str, L")"); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathIPv4 ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + IPv4_DEVICE_PATH *IPDevPath; + + IPDevPath = DevPath; + CatPrint ( + Str, + L"IPv4(%d.%d.%d.%d:%d)", + (UINTN) IPDevPath->RemoteIpAddress.Addr[0], + (UINTN) IPDevPath->RemoteIpAddress.Addr[1], + (UINTN) IPDevPath->RemoteIpAddress.Addr[2], + (UINTN) IPDevPath->RemoteIpAddress.Addr[3], + (UINTN) IPDevPath->RemotePort + ); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathIPv6 ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + IPv6_DEVICE_PATH *IPv6DevPath; + + IPv6DevPath = DevPath; + CatPrint ( + Str, + L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[0], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[1], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[2], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[3], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[4], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[5], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[6], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[7], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[8], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[9], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[10], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[11], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[12], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[13], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[14], + (UINTN) IPv6DevPath->RemoteIpAddress.Addr[15] + ); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathInfiniBand ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + INFINIBAND_DEVICE_PATH *InfiniBand; + + InfiniBand = DevPath; + CatPrint ( + Str, + L"Infiniband(%x,%g,%lx,%lx,%lx)", + (UINTN) InfiniBand->ResourceFlags, + InfiniBand->PortGid, + InfiniBand->ServiceId, + InfiniBand->TargetPortId, + InfiniBand->DeviceId + ); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathUart ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + UART_DEVICE_PATH *Uart; + CHAR8 Parity; + + Uart = DevPath; + switch (Uart->Parity) { + case 0: + Parity = 'D'; + break; + + case 1: + Parity = 'N'; + break; + + case 2: + Parity = 'E'; + break; + + case 3: + Parity = 'O'; + break; + + case 4: + Parity = 'M'; + break; + + case 5: + Parity = 'S'; + break; + + default: + Parity = 'x'; + break; + } + + if (Uart->BaudRate == 0) { + CatPrint (Str, L"Uart(DEFAULT,%c,", Parity); + } else { + CatPrint (Str, L"Uart(%ld,%c,", Uart->BaudRate, Parity); + } + + if (Uart->DataBits == 0) { + CatPrint (Str, L"D,"); + } else { + CatPrint (Str, L"%d,", (UINTN) Uart->DataBits); + } + + switch (Uart->StopBits) { + case 0: + CatPrint (Str, L"D)"); + break; + + case 1: + CatPrint (Str, L"1)"); + break; + + case 2: + CatPrint (Str, L"1.5)"); + break; + + case 3: + CatPrint (Str, L"2)"); + break; + + default: + CatPrint (Str, L"x)"); + break; + } +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathiSCSI ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + ISCSI_DEVICE_PATH_WITH_NAME *IScsi; + UINT16 Options; + + IScsi = DevPath; + CatPrint ( + Str, + L"iSCSI(%a,%x,%lx,", + IScsi->TargetName, + (UINTN) IScsi->TargetPortalGroupTag, + IScsi->Lun + ); + + Options = IScsi->LoginOption; + CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None"); + CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None"); + if (((Options >> 11) & 0x0001) != 0) { + CatPrint (Str, L"%s,", L"None"); + } else if (((Options >> 12) & 0x0001) != 0) { + CatPrint (Str, L"%s,", L"CHAP_UNI"); + } else { + CatPrint (Str, L"%s,", L"CHAP_BI"); + + } + + CatPrint (Str, L"%s)", (IScsi->NetworkProtocol == 0) ? L"TCP" : L"reserved"); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathVlan ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + VLAN_DEVICE_PATH *Vlan; + + Vlan = DevPath; + CatPrint (Str, L"Vlan(%d)", (UINTN) Vlan->VlanId); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathHardDrive ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + HARDDRIVE_DEVICE_PATH *Hd; + + Hd = DevPath; + switch (Hd->SignatureType) { + case SIGNATURE_TYPE_MBR: + CatPrint ( + Str, + L"HD(Part%d,Sig%08x)", + (UINTN) Hd->PartitionNumber, + (UINTN) *((UINT32 *) (&(Hd->Signature[0]))) + ); + break; + + case SIGNATURE_TYPE_GUID: + CatPrint ( + Str, + L"HD(Part%d,Sig%g)", + (UINTN) Hd->PartitionNumber, + (EFI_GUID *) &(Hd->Signature[0]) + ); + break; + + default: + CatPrint ( + Str, + L"HD(Part%d,MBRType=%02x,SigType=%02x)", + (UINTN) Hd->PartitionNumber, + (UINTN) Hd->MBRType, + (UINTN) Hd->SignatureType + ); + break; + } +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathCDROM ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + CDROM_DEVICE_PATH *Cd; + + Cd = DevPath; + CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathFilePath ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + FILEPATH_DEVICE_PATH *Fp; + + Fp = DevPath; + CatPrint (Str, L"%s", Fp->PathName); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathMediaProtocol ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + MEDIA_PROTOCOL_DEVICE_PATH *MediaProt; + + MediaProt = DevPath; + CatPrint (Str, L"Media(%g)", &MediaProt->Protocol); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathFvFilePath ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath; + + FvFilePath = DevPath; + CatPrint (Str, L"%g", &FvFilePath->FvFileName); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathRelativeOffsetRange ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset; + + Offset = DevPath; + CatPrint ( + Str, + L"Offset(%lx,%lx)", + Offset->StartingOffset, + Offset->EndingOffset + ); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathBssBss ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + BBS_BBS_DEVICE_PATH *Bbs; + CHAR16 *Type; + + Bbs = DevPath; + switch (Bbs->DeviceType) { + case BBS_TYPE_FLOPPY: + Type = L"Floppy"; + break; + + case BBS_TYPE_HARDDRIVE: + Type = L"Harddrive"; + break; + + case BBS_TYPE_CDROM: + Type = L"CDROM"; + break; + + case BBS_TYPE_PCMCIA: + Type = L"PCMCIA"; + break; + + case BBS_TYPE_USB: + Type = L"Usb"; + break; + + case BBS_TYPE_EMBEDDED_NETWORK: + Type = L"Net"; + break; + + case BBS_TYPE_BEV: + Type = L"BEV"; + break; + + default: + Type = L"?"; + break; + } + CatPrint (Str, L"Legacy-%s", Type); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathEndInstance ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + CatPrint (Str, L","); +} + +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathNodeUnknown ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + CatPrint (Str, L"?"); +} +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maximum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathFvPath ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + MEDIA_FW_VOL_DEVICE_PATH *FvPath; + + FvPath = DevPath; + CatPrint (Str, L"Fv(%g)", &FvPath->FvName); +} + +DEVICE_PATH_STRING_TABLE DevPathTable[] = { + { + HARDWARE_DEVICE_PATH, + HW_PCI_DP, + DevPathPci + }, + { + HARDWARE_DEVICE_PATH, + HW_PCCARD_DP, + DevPathPccard + }, + { + HARDWARE_DEVICE_PATH, + HW_MEMMAP_DP, + DevPathMemMap + }, + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + DevPathVendor + }, + { + HARDWARE_DEVICE_PATH, + HW_CONTROLLER_DP, + DevPathController + }, + { + ACPI_DEVICE_PATH, + ACPI_DP, + DevPathAcpi + }, + { + ACPI_DEVICE_PATH, + ACPI_EXTENDED_DP, + DevPathExtendedAcpi + }, + { + ACPI_DEVICE_PATH, + ACPI_ADR_DP, + DevPathAdrAcpi + }, + { + MESSAGING_DEVICE_PATH, + MSG_ATAPI_DP, + DevPathAtapi + }, + { + MESSAGING_DEVICE_PATH, + MSG_SCSI_DP, + DevPathScsi + }, + { + MESSAGING_DEVICE_PATH, + MSG_FIBRECHANNEL_DP, + DevPathFibre + }, + { + MESSAGING_DEVICE_PATH, + MSG_1394_DP, + DevPath1394 + }, + { + MESSAGING_DEVICE_PATH, + MSG_USB_DP, + DevPathUsb + }, + { + MESSAGING_DEVICE_PATH, + MSG_USB_WWID_DP, + DevPathUsbWWID + }, + { + MESSAGING_DEVICE_PATH, + MSG_DEVICE_LOGICAL_UNIT_DP, + DevPathLogicalUnit + }, + { + MESSAGING_DEVICE_PATH, + MSG_USB_CLASS_DP, + DevPathUsbClass + }, + { + MESSAGING_DEVICE_PATH, + MSG_SATA_DP, + DevPathSata + }, + { + MESSAGING_DEVICE_PATH, + MSG_I2O_DP, + DevPathI2O + }, + { + MESSAGING_DEVICE_PATH, + MSG_MAC_ADDR_DP, + DevPathMacAddr + }, + { + MESSAGING_DEVICE_PATH, + MSG_IPv4_DP, + DevPathIPv4 + }, + { + MESSAGING_DEVICE_PATH, + MSG_IPv6_DP, + DevPathIPv6 + }, + { + MESSAGING_DEVICE_PATH, + MSG_INFINIBAND_DP, + DevPathInfiniBand + }, + { + MESSAGING_DEVICE_PATH, + MSG_UART_DP, + DevPathUart + }, + { + MESSAGING_DEVICE_PATH, + MSG_VENDOR_DP, + DevPathVendor + }, + { + MESSAGING_DEVICE_PATH, + MSG_ISCSI_DP, + DevPathiSCSI + }, + { + MESSAGING_DEVICE_PATH, + MSG_VLAN_DP, + DevPathVlan + }, + { + MEDIA_DEVICE_PATH, + MEDIA_HARDDRIVE_DP, + DevPathHardDrive + }, + { + MEDIA_DEVICE_PATH, + MEDIA_CDROM_DP, + DevPathCDROM + }, + { + MEDIA_DEVICE_PATH, + MEDIA_VENDOR_DP, + DevPathVendor + }, + { + MEDIA_DEVICE_PATH, + MEDIA_FILEPATH_DP, + DevPathFilePath + }, + { + MEDIA_DEVICE_PATH, + MEDIA_PROTOCOL_DP, + DevPathMediaProtocol + }, + { + MEDIA_DEVICE_PATH, + MEDIA_PIWG_FW_VOL_DP, + DevPathFvPath, + }, + { + MEDIA_DEVICE_PATH, + MEDIA_PIWG_FW_FILE_DP, + DevPathFvFilePath + }, + { + MEDIA_DEVICE_PATH, + MEDIA_RELATIVE_OFFSET_RANGE_DP, + DevPathRelativeOffsetRange, + }, + { + BBS_DEVICE_PATH, + BBS_BBS_DP, + DevPathBssBss + }, + { + END_DEVICE_PATH_TYPE, + END_INSTANCE_DEVICE_PATH_SUBTYPE, + DevPathEndInstance + }, + { + 0, + 0, + NULL + } +}; + + +/** + This function converts an input device structure to a Unicode string. + + @param DevPath A pointer to the device path structure. + + @return A new allocated Unicode string that represents the device path. + +**/ +CHAR16 * +EFIAPI +DevicePathToStr ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +{ + POOL_PRINT Str; + EFI_DEVICE_PATH_PROTOCOL *DevPathNode; + VOID (*DumpNode) (POOL_PRINT *, VOID *); + + UINTN Index; + UINTN NewSize; + + EFI_STATUS Status; + CHAR16 *ToText; + EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText; + + ZeroMem (&Str, sizeof (Str)); + + if (DevPath == NULL) { + goto Done; + } + + Status = gBS->LocateProtocol ( + &gEfiDevicePathToTextProtocolGuid, + NULL, + (VOID **) &DevPathToText + ); + if (!EFI_ERROR (Status)) { + ToText = DevPathToText->ConvertDevicePathToText ( + DevPath, + FALSE, + TRUE + ); + ASSERT (ToText != NULL); + return ToText; + } + + // + // Process each device path node + // + DevPathNode = DevPath; + while (!IsDevicePathEnd (DevPathNode)) { + // + // Find the handler to dump this device path node + // + DumpNode = NULL; + for (Index = 0; DevPathTable[Index].Function != NULL; Index += 1) { + + if (DevicePathType (DevPathNode) == DevPathTable[Index].Type && + DevicePathSubType (DevPathNode) == DevPathTable[Index].SubType + ) { + DumpNode = DevPathTable[Index].Function; + break; + } + } + // + // If not found, use a generic function + // + if (!DumpNode) { + DumpNode = DevPathNodeUnknown; + } + // + // Put a path seperator in if needed + // + if ((Str.Len != 0) && (DumpNode != DevPathEndInstance)) { + CatPrint (&Str, L"/"); + } + // + // Print this node of the device path + // + DumpNode (&Str, DevPathNode); + + // + // Next device path node + // + DevPathNode = NextDevicePathNode (DevPathNode); + } + +Done: + NewSize = (Str.Len + 1) * sizeof (CHAR16); + Str.Str = EfiReallocatePool (Str.Str, NewSize, NewSize); + ASSERT (Str.Str != NULL); + Str.Str[Str.Len] = 0; + return Str.Str; +} diff --git a/EfiLib/GenericBdsLib.h b/EfiLib/GenericBdsLib.h new file mode 100644 index 0000000..e0e6af5 --- /dev/null +++ b/EfiLib/GenericBdsLib.h @@ -0,0 +1,1093 @@ +/** @file + Generic BDS library defines general interfaces for a BDS driver, including: + 1) BDS boot policy interface. + 2) BDS boot device connect interface. + 3) BDS Misc interfaces for mainting boot variable, ouput string. + +Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under +the terms and conditions of the BSD License that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _GENERIC_BDS_LIB_H_ +#define _GENERIC_BDS_LIB_H_ + +#include + +/// +/// Constants which are variable names used to access variables. +/// +#define VAR_LEGACY_DEV_ORDER L"LegacyDevOrder" + +/// +/// Data structures and defines. +/// +#define FRONT_PAGE_QUESTION_ID 0x0000 +#define FRONT_PAGE_DATA_WIDTH 0x01 + +/// +/// ConnectType +/// +#define CONSOLE_OUT 0x00000001 +#define STD_ERROR 0x00000002 +#define CONSOLE_IN 0x00000004 +#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR) + +/// +/// Load Option Attributes +/// +#define LOAD_OPTION_ACTIVE 0x00000001 +#define LOAD_OPTION_FORCE_RECONNECT 0x00000002 + +#define LOAD_OPTION_HIDDEN 0x00000008 +#define LOAD_OPTION_CATEGORY 0x00001F00 + +#define LOAD_OPTION_CATEGORY_BOOT 0x00000000 +#define LOAD_OPTION_CATEGORY_APP 0x00000100 + +#define EFI_BOOT_OPTION_SUPPORT_KEY 0x00000001 +#define EFI_BOOT_OPTION_SUPPORT_APP 0x00000002 + +#define IS_LOAD_OPTION_TYPE(_c, _Mask) (BOOLEAN) (((_c) & (_Mask)) != 0) + +/// +/// Define the maximum characters that will be accepted. +/// +#define MAX_CHAR 480 +#define MAX_CHAR_SIZE (MAX_CHAR * 2) + +/// +/// Define maximum characters for boot option variable "BootXXXX". +/// +#define BOOT_OPTION_MAX_CHAR 10 + +// +// This data structure is the part of BDS_CONNECT_ENTRY +// +#define BDS_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'C', 'O') + +typedef struct { + + UINTN Signature; + LIST_ENTRY Link; + + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + CHAR16 *OptionName; + UINTN OptionNumber; + UINT16 BootCurrent; + UINT32 Attribute; + CHAR16 *Description; + VOID *LoadOptions; + UINT32 LoadOptionsSize; + CHAR16 *StatusString; + +} BDS_COMMON_OPTION; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + UINTN ConnectType; +} BDS_CONSOLE_CONNECT_ENTRY; + +// +// Bds boot related lib functions +// +/** + Boot from the UEFI spec defined "BootNext" variable. + +**/ +VOID +EFIAPI +BdsLibBootNext ( + VOID + ); + +/** + Process the boot option according to the UEFI specification. The legacy boot option device path includes BBS_DEVICE_PATH. + + @param Option The boot option to be processed. + @param DevicePath The device path describing where to load the + boot image or the legcy BBS device path to boot + the legacy OS. + @param ExitDataSize The size of exit data. + @param ExitData Data returned when Boot image failed. + + @retval EFI_SUCCESS Boot from the input boot option succeeded. + @retval EFI_NOT_FOUND The Device Path is not found in the system. + +**/ +EFI_STATUS +EFIAPI +BdsLibBootViaBootOption ( + IN BDS_COMMON_OPTION * Option, + IN EFI_DEVICE_PATH_PROTOCOL * DevicePath, + OUT UINTN *ExitDataSize, + OUT CHAR16 **ExitData OPTIONAL + ); + + +/** + This function will enumerate all possible boot devices in the system, and + automatically create boot options for Network, Shell, Removable BlockIo, + and Non-BlockIo Simplefile devices. + + BDS separates EFI boot options into six types: + 1. Network - The boot option points to the SimpleNetworkProtocol device. + Bds will try to automatically create this type of boot option during enumeration. + 2. Shell - The boot option points to internal flash shell. + Bds will try to automatically create this type of boot option during enumeration. + 3. Removable BlockIo - The boot option points to a removable media + device, such as a USB flash drive or DVD drive. + These devices should contain a *removable* blockIo + protocol in their device handle. + Bds will try to automatically create this type boot option + when enumerate. + 4. Fixed BlockIo - The boot option points to a Fixed blockIo device, + such as a hard disk. + These devices should contain a *fixed* blockIo + protocol in their device handle. + BDS will skip fixed blockIo devices, and not + automatically create boot option for them. But BDS + will help to delete those fixed blockIo boot options, + whose description rules conflict with other auto-created + boot options. + 5. Non-BlockIo Simplefile - The boot option points to a device whose handle + has SimpleFileSystem Protocol, but has no blockio + protocol. These devices do not offer blockIo + protocol, but BDS still can get the + \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem + Protocol. + 6. File - The boot option points to a file. These boot options are usually + created by the user, either manually or with an OS loader. BDS will not delete or modify + these boot options. + + This function will enumerate all possible boot devices in the system, and + automatically create boot options for Network, Shell, Removable BlockIo, + and Non-BlockIo Simplefile devices. + It will excute once every boot. + + @param BdsBootOptionList The header of the linked list that indexed all + current boot options. + + @retval EFI_SUCCESS Finished all the boot device enumerations and + created the boot option based on the boot device. + + @retval EFI_OUT_OF_RESOURCES Failed to enumerate the boot device and create + the boot option list. +**/ +EFI_STATUS +EFIAPI +BdsLibEnumerateAllBootOption ( + IN OUT LIST_ENTRY *BdsBootOptionList + ); + +/** + Build the boot option with the handle parsed in. + + @param Handle The handle representing the device path for which + to create a boot option. + @param BdsBootOptionList The header of the link list that indexed all + current boot options. + @param String The description of the boot option. + +**/ +VOID +EFIAPI +BdsLibBuildOptionFromHandle ( + IN EFI_HANDLE Handle, + IN LIST_ENTRY *BdsBootOptionList, + IN CHAR16 *String + ); + + +/** + Build the on flash shell boot option with the handle parsed in. + + @param Handle The handle which present the device path to create + the on flash shell boot option. + @param BdsBootOptionList The header of the link list that indexed all + current boot options. + +**/ +VOID +EFIAPI +BdsLibBuildOptionFromShell ( + IN EFI_HANDLE Handle, + IN OUT LIST_ENTRY *BdsBootOptionList + ); + +// +// Bds misc lib functions +// +/** + Get boot mode by looking up the configuration table and parsing the HOB list. + + @param BootMode The boot mode from PEI handoff HOB. + + @retval EFI_SUCCESS Successfully got boot mode. + +**/ +EFI_STATUS +EFIAPI +BdsLibGetBootMode ( + OUT EFI_BOOT_MODE *BootMode + ); + + +/** + The function will go through the driver option link list, and then load and start + every driver to which the driver option device path points. + + @param BdsDriverLists The header of the current driver option link list. + +**/ +VOID +EFIAPI +BdsLibLoadDrivers ( + IN LIST_ENTRY *BdsDriverLists + ); + + +/** + This function processes BootOrder or DriverOrder variables, by calling + + BdsLibVariableToOption () for each UINT16 in the variables. + + @param BdsCommonOptionList The header of the option list base on the variable + VariableName. + @param VariableName An EFI Variable name indicate the BootOrder or + DriverOrder. + + @retval EFI_SUCCESS Successfully created the boot option or driver option + list. + @retval EFI_OUT_OF_RESOURCES Failed to get the boot option or the driver option list. +**/ +EFI_STATUS +EFIAPI +BdsLibBuildOptionFromVar ( + IN LIST_ENTRY *BdsCommonOptionList, + IN CHAR16 *VariableName + ); + +/** + This function reads the EFI variable (VendorGuid/Name) and returns a dynamically allocated + buffer and the size of the buffer. If it fails, return NULL. + + @param Name The string part of the EFI variable name. + @param VendorGuid The GUID part of the EFI variable name. + @param VariableSize Returns the size of the EFI variable that was read. + + @return Dynamically allocated memory that contains a copy + of the EFI variable. The caller is responsible for + freeing the buffer. + @retval NULL The variable was not read. + +**/ +VOID * +EFIAPI +BdsLibGetVariableAndSize ( + IN CHAR16 *Name, + IN EFI_GUID *VendorGuid, + OUT UINTN *VariableSize + ); + + +/** + This function prints a series of strings. + + @param ConOut A pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. + @param ... A variable argument list containing a series of + strings, the last string must be NULL. + + @retval EFI_SUCCESS Successfully printed out the string using ConOut. + @retval EFI_STATUS Return the status of the ConOut->OutputString (). + +**/ +EFI_STATUS +EFIAPI +BdsLibOutputStrings ( + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut, + ... + ); + +/** + Build the boot#### or driver#### option from the VariableName. The + build boot#### or driver#### will also be linked to BdsCommonOptionList. + + @param BdsCommonOptionList The header of the boot#### or driver#### option + link list. + @param VariableName EFI Variable name, indicates if it is boot#### or + driver####. + + @retval BDS_COMMON_OPTION The option that was created. + @retval NULL Failed to get the new option. + +**/ +BDS_COMMON_OPTION * +EFIAPI +BdsLibVariableToOption ( + IN OUT LIST_ENTRY *BdsCommonOptionList, + IN CHAR16 *VariableName + ); + +/** + This function registers the new boot#### or driver#### option based on + the VariableName. The new registered boot#### or driver#### will be linked + to BdsOptionList and also update to the VariableName. After the boot#### or + driver#### updated, the BootOrder or DriverOrder will also be updated. + + @param BdsOptionList The header of the boot#### or driver#### link list. + @param DevicePath The device path that the boot#### or driver#### + option present. + @param String The description of the boot#### or driver####. + @param VariableName Indicate if the boot#### or driver#### option. + + @retval EFI_SUCCESS The boot#### or driver#### have been successfully + registered. + @retval EFI_STATUS Return the status of gRS->SetVariable (). + +**/ +EFI_STATUS +EFIAPI +BdsLibRegisterNewOption ( + IN LIST_ENTRY *BdsOptionList, + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN CHAR16 *String, + IN CHAR16 *VariableName + ); + +// +// Bds connect and disconnect driver lib funcions +// +/** + This function connects all system drivers with the corresponding controllers. + +**/ +VOID +EFIAPI +BdsLibConnectAllDriversToAllControllers ( + VOID + ); + +/** + This function connects all system drivers to controllers. + +**/ +VOID +EFIAPI +BdsLibConnectAll ( + VOID + ); + +/** + This function creates all handles associated with the given device + path node. If the handle associated with one device path node cannot + be created, then it tries to execute the dispatch to load the missing drivers. + + @param DevicePathToConnect The device path to be connected. Can be + a multi-instance device path. + + @retval EFI_SUCCESS All handles associates with every device path node + were created. + @retval EFI_OUT_OF_RESOURCES Not enough resources to create new handles. + @retval EFI_NOT_FOUND At least one handle could not be created. + +**/ +EFI_STATUS +EFIAPI +BdsLibConnectDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect + ); + +/** + This function will connect all current system handles recursively. + gBS->ConnectController() service is invoked for each handle exist in system handler buffer. + If the handle is bus type handler, all childrens also will be connected recursively by gBS->ConnectController(). + + @retval EFI_SUCCESS All handles and child handles have been + connected. + @retval EFI_STATUS Return the status of gBS->LocateHandleBuffer(). +**/ +EFI_STATUS +EFIAPI +BdsLibConnectAllEfi ( + VOID + ); + +/** + This function will disconnect all current system handles. + gBS->DisconnectController() is invoked for each handle exists in system handle buffer. + If handle is a bus type handle, all childrens also are disconnected recursively by gBS->DisconnectController(). + + @retval EFI_SUCCESS All handles have been disconnected. + @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer(). + +**/ +EFI_STATUS +EFIAPI +BdsLibDisconnectAllEfi ( + VOID + ); + +// +// Bds console related lib functions +// +/** + This function will search every simpletxt device in the current system, + and make every simpletxt device a potential console device. + +**/ +VOID +EFIAPI +BdsLibConnectAllConsoles ( + VOID + ); + + +/** + This function will connect console device based on the console + device variable ConIn, ConOut and ErrOut. + + @retval EFI_SUCCESS At least one of the ConIn and ConOut devices have + been connected. + @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable (). + +**/ +EFI_STATUS +EFIAPI +BdsLibConnectAllDefaultConsoles ( + VOID + ); + +/** + This function updates the console variable based on ConVarName. It can + add or remove one specific console device path from the variable + + @param ConVarName The console-related variable name: ConIn, ConOut, + ErrOut. + @param CustomizedConDevicePath The console device path to be added to + the console variable ConVarName. Cannot be multi-instance. + @param ExclusiveDevicePath The console device path to be removed + from the console variable ConVarName. Cannot be multi-instance. + + @retval EFI_UNSUPPORTED The added device path is the same as a removed one. + @retval EFI_SUCCESS Successfully added or removed the device path from the + console variable. + +**/ +EFI_STATUS +EFIAPI +BdsLibUpdateConsoleVariable ( + IN CHAR16 *ConVarName, + IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath, + IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath + ); + +/** + Connect the console device base on the variable ConVarName. If + ConVarName is a multi-instance device path, and at least one + instance connects successfully, then this function + will return success. + + @param ConVarName The console related variable name: ConIn, ConOut, + ErrOut. + + @retval EFI_NOT_FOUND No console devices were connected successfully + @retval EFI_SUCCESS Connected at least one instance of the console + device path based on the variable ConVarName. + +**/ +EFI_STATUS +EFIAPI +BdsLibConnectConsoleVariable ( + IN CHAR16 *ConVarName + ); + +// +// Bds device path related lib functions +// +/** + Delete the instance in Multi that overlaps with Single. + + @param Multi A pointer to a multi-instance device path data + structure. + @param Single A pointer to a single-instance device path data + structure. + + @return This function removes the device path instances in Multi that overlap + Single, and returns the resulting device path. If there is no + remaining device path as a result, this function will return NULL. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +BdsLibDelPartMatchInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *Multi, + IN EFI_DEVICE_PATH_PROTOCOL *Single + ); + +/** + This function compares a device path data structure to that of all the nodes of a + second device path instance. + + @param Multi A pointer to a multi-instance device path data + structure. + @param Single A pointer to a single-instance device path data + structure. + + @retval TRUE If the Single device path is contained within a + Multi device path. + @retval FALSE The Single device path is not contained within a + Multi device path. + +**/ +BOOLEAN +EFIAPI +BdsLibMatchDevicePaths ( + IN EFI_DEVICE_PATH_PROTOCOL *Multi, + IN EFI_DEVICE_PATH_PROTOCOL *Single + ); + +/** + This function converts an input device structure to a Unicode string. + + @param DevPath A pointer to the device path structure. + + @return A newly allocated Unicode string that represents the device path. + +**/ +CHAR16 * +EFIAPI +DevicePathToStr ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ); + +// +// Internal definitions +// +typedef struct { + CHAR16 *Str; + UINTN Len; + UINTN Maxlen; +} POOL_PRINT; + +typedef +VOID +(*DEV_PATH_FUNCTION) ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ); + +typedef struct { + UINT8 Type; + UINT8 SubType; + DEV_PATH_FUNCTION Function; +} DEVICE_PATH_STRING_TABLE; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID Guid; + UINT8 VendorDefinedData[1]; +} VENDOR_DEVICE_PATH_WITH_DATA; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 NetworkProtocol; + UINT16 LoginOption; + UINT64 Lun; + UINT16 TargetPortalGroupTag; + CHAR16 TargetName[1]; +} ISCSI_DEVICE_PATH_WITH_NAME; + +// +// BBS support macros and functions +// + +#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64) +#define REFRESH_LEGACY_BOOT_OPTIONS \ + BdsDeleteAllInvalidLegacyBootOptions ();\ + BdsAddNonExistingLegacyBootOptions (); \ + BdsUpdateLegacyDevOrder () +#else +#define REFRESH_LEGACY_BOOT_OPTIONS +#endif + +/** + Delete all the invalid legacy boot options. + + @retval EFI_SUCCESS All invalid legacy boot options are deleted. + @retval EFI_OUT_OF_RESOURCES Failed to allocate necessary memory. + @retval EFI_NOT_FOUND Failed to retrieve variable of boot order. + +**/ +EFI_STATUS +EFIAPI +BdsDeleteAllInvalidLegacyBootOptions ( + VOID + ); + +/** + Add the legacy boot options from BBS table if they do not exist. + + @retval EFI_SUCCESS The boot options were added successfully, + or they are already in boot options. + @retval EFI_NOT_FOUND No legacy boot options is found. + @retval EFI_OUT_OF_RESOURCE No enough memory. + @return Other value LegacyBoot options are not added. +**/ +EFI_STATUS +EFIAPI +BdsAddNonExistingLegacyBootOptions ( + VOID + ); + +/** + Add the legacy boot devices from BBS table into + the legacy device boot order. + + @retval EFI_SUCCESS The boot devices were added successfully. + @retval EFI_NOT_FOUND The legacy boot devices are not found. + @retval EFI_OUT_OF_RESOURCES Memory or storage is not enough. + @retval EFI_DEVICE_ERROR Failed to add the legacy device boot order into EFI variable + because of a hardware error. +**/ +EFI_STATUS +EFIAPI +BdsUpdateLegacyDevOrder ( + VOID + ); + +/** + Refresh the boot priority for BBS entries based on boot option entry and boot order. + + @param Entry The boot option is to be checked for a refreshed BBS table. + + @retval EFI_SUCCESS The boot priority for BBS entries refreshed successfully. + @retval EFI_NOT_FOUND BBS entries can't be found. + @retval EFI_OUT_OF_RESOURCES Failed to get the legacy device boot order. +**/ +EFI_STATUS +EFIAPI +BdsRefreshBbsTableForBoot ( + IN BDS_COMMON_OPTION *Entry + ); + +/** + Delete the Boot Option from EFI Variable. The Boot Order Arrray + is also updated. + + @param OptionNumber The number of Boot options wanting to be deleted. + @param BootOrder The Boot Order array. + @param BootOrderSize The size of the Boot Order Array. + + @retval EFI_SUCCESS The Boot Option Variable was found and removed. + @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible. + @retval EFI_NOT_FOUND The Boot Option Variable was not found. +**/ +EFI_STATUS +EFIAPI +BdsDeleteBootOption ( + IN UINTN OptionNumber, + IN OUT UINT16 *BootOrder, + IN OUT UINTN *BootOrderSize + ); + +// +//The interface functions related to the Setup Browser Reset Reminder feature +// +/** + Enable the setup browser reset reminder feature. + This routine is used in a platform tip. If the platform policy needs the feature, use the routine to enable it. + +**/ +VOID +EFIAPI +EnableResetReminderFeature ( + VOID + ); + +/** + Disable the setup browser reset reminder feature. + This routine is used in a platform tip. If the platform policy does not want the feature, use the routine to disable it. + +**/ +VOID +EFIAPI +DisableResetReminderFeature ( + VOID + ); + +/** + Record the info that a reset is required. + A module boolean variable is used to record whether a reset is required. + +**/ +VOID +EFIAPI +EnableResetRequired ( + VOID + ); + + +/** + Record the info that no reset is required. + A module boolean variable is used to record whether a reset is required. + +**/ +VOID +EFIAPI +DisableResetRequired ( + VOID + ); + +/** + Check whether platform policy enables the reset reminder feature. The default is enabled. + +**/ +BOOLEAN +EFIAPI +IsResetReminderFeatureEnable ( + VOID + ); + +/** + Check if the user changed any option setting that needs a system reset to be effective. + +**/ +BOOLEAN +EFIAPI +IsResetRequired ( + VOID + ); + +/** + Check whether a reset is needed, and finish the reset reminder feature. + If a reset is needed, pop up a menu to notice user, and finish the feature + according to the user selection. + +**/ +VOID +EFIAPI +SetupResetReminder ( + VOID + ); + + +/// +/// Define the boot type with which to classify the boot option type. +/// Different boot option types could have different boot behaviors. +/// Use their device path node (Type + SubType) as the type value. +/// The boot type here can be added according to requirements. +/// + +/// +/// ACPI boot type. For ACPI devices, using sub-types to distinguish devices is not allowed, so hardcode their values. +/// +#define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201 +/// +/// Message boot type +/// If a device path of boot option only points to a message node, the boot option is a message boot type. +/// +#define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01 +#define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02 +#define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05 +#define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18 +#define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11 +#define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF + +/// +/// Media boot type +/// If a device path of boot option contains a media node, the boot option is media boot type. +/// +#define BDS_EFI_MEDIA_HD_BOOT 0x0401 // Type 04; Sub-Type 01 +#define BDS_EFI_MEDIA_CDROM_BOOT 0x0402 // Type 04; Sub-Type 02 +/// +/// BBS boot type +/// If a device path of boot option contains a BBS node, the boot option is BBS boot type. +/// +#define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01 + +#define BDS_EFI_UNSUPPORT 0xFFFF + +/** + Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path. + + @param BlockIoDevicePath Multi device path instances to check. + @param HardDriveDevicePath A device path starting with a hard drive media + device path. + + @retval TRUE There is a matched device path instance. + @retval FALSE There is no matched device path instance. + +**/ +BOOLEAN +EFIAPI +MatchPartitionDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath, + IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath + ); + + +/** + Expand a device path that starts with a hard drive media device path node to be a + full device path that includes the full hardware path to the device. This function enables the device to boot. + To avoid requiring a connect on every boot, the front match is saved in a variable (the part point + to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ). + All successful history device paths + that point to the front part of the partition node will be saved. + + @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard + drive media device path. + @return A Pointer to the full device path, or NULL if a valid Hard Drive devic path + cannot be found. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +BdsExpandPartitionPartialDevicePathToFull ( + IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath + ); + +/** + Return the bootable media handle. + First, check whether the device is connected. + Second, check whether the device path points to a device that supports SimpleFileSystemProtocol. + Third, detect the the default boot file in the Media, and return the removable Media handle. + + @param DevicePath The Device Path to a bootable device. + + @return The bootable media handle. If the media on the DevicePath is not bootable, NULL will return. + +**/ +EFI_HANDLE +EFIAPI +BdsLibGetBootableHandle ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + + +/** + Checks whether the Device path in a boot option points to a valid bootable device, and if the device + is ready to boot now. + + @param DevPath The Device path in a boot option. + @param CheckMedia If TRUE, check whether the device is ready to boot now. + + @retval TRUE The Device path is valid. + @retval FALSE The Device path is invalid. + +**/ +BOOLEAN +EFIAPI +BdsLibIsValidEFIBootOptDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath, + IN BOOLEAN CheckMedia + ); + +/** + Checks whether the Device path in a boot option points to a valid bootable device, and if the device + is ready to boot now. + If Description is not NULL and the device path points to a fixed BlockIo + device, this function checks whether the description conflicts with other auto-created + boot options. + + @param DevPath The Device path in a boot option. + @param CheckMedia If TRUE, checks if the device is ready to boot now. + @param Description The description of a boot option. + + @retval TRUE The Device path is valid. + @retval FALSE The Device path is invalid. + +**/ +BOOLEAN +EFIAPI +BdsLibIsValidEFIBootOptDevicePathExt ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath, + IN BOOLEAN CheckMedia, + IN CHAR16 *Description + ); + +/** + For a bootable Device path, return its boot type. + + @param DevicePath The bootable device Path to check. + + @retval BDS_EFI_MEDIA_HD_BOOT The given device path contains MEDIA_DEVICE_PATH type device path node, + whose subtype is MEDIA_HARDDRIVE_DP. + @retval BDS_EFI_MEDIA_CDROM_BOOT If given device path contains MEDIA_DEVICE_PATH type device path node, + whose subtype is MEDIA_CDROM_DP. + @retval BDS_EFI_ACPI_FLOPPY_BOOT A given device path contains ACPI_DEVICE_PATH type device path node, + whose HID is floppy device. + @retval BDS_EFI_MESSAGE_ATAPI_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node, + and its last device path node's subtype is MSG_ATAPI_DP. + @retval BDS_EFI_MESSAGE_SCSI_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node, + and its last device path node's subtype is MSG_SCSI_DP. + @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node, + and its last device path node's subtype is MSG_USB_DP. + @retval BDS_EFI_MESSAGE_MISC_BOOT The device path does not contain any media device path node, and + its last device path node points to a message device path node. + @retval BDS_LEGACY_BBS_BOOT A given device path contains BBS_DEVICE_PATH type device path node. + @retval BDS_EFI_UNSUPPORT An EFI Removable BlockIO device path does not point to a media and message device. + + **/ +UINT32 +EFIAPI +BdsGetBootTypeFromDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + + +/** + This routine registers a function to adjust the different types of memory page numbers + just before booting, and saves the updated info into the variable for the next boot to use. + +**/ +VOID +EFIAPI +BdsLibSaveMemoryTypeInformation ( + VOID + ); + +/** + Identify a user and, if authenticated, returns the current user profile handle. + + @param[out] User Points to the user profile handle. + + @retval EFI_SUCCESS The user is successfully identified, or user identification + is not supported. + @retval EFI_ACCESS_DENIED The user was not successfully identified. + +**/ +EFI_STATUS +EFIAPI +BdsLibUserIdentify ( + OUT EFI_USER_PROFILE_HANDLE *User + ); + +/** + This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid, + it tries to return the valid device path. + FV address maybe changes for memory layout adjust from time to time, use this funciton + could promise the Fv file device path is right. + + @param DevicePath On input, the Fv file device path to check. On + output, the updated valid Fv file device path + @param FileGuid the Fv file GUID. + + @retval EFI_INVALID_PARAMETER The input DevicePath or FileGuid is invalid. + @retval EFI_UNSUPPORTED The input DevicePath does not contain an Fv file + GUID at all. + @retval EFI_ALREADY_STARTED The input DevicePath has pointed to the Fv file and is + valid. + @retval EFI_SUCCESS Successfully updated the invalid DevicePath + and returned the updated device path in DevicePath. + +**/ +EFI_STATUS +EFIAPI +BdsLibUpdateFvFileDevicePath ( + IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath, + IN EFI_GUID *FileGuid + ); + + +/** + Connect the specific USB device that matches the RemainingDevicePath, + and whose bus is determined by Host Controller (Uhci or Ehci). + + @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci + (0xFF). + @param RemainingDevicePath A short-form device path that starts with the first + element being a USB WWID or a USB Class device + path. + + @retval EFI_SUCCESS The specific Usb device is connected successfully. + @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF) + or RemainingDevicePath is not the USB class device path. + @retval EFI_NOT_FOUND The device specified by device path is not found. + +**/ +EFI_STATUS +EFIAPI +BdsLibConnectUsbDevByShortFormDP( + IN UINT8 HostControllerPI, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + ); + + +// +// The implementation of this function is provided by Platform code. +// +/** + Convert Vendor device path to a device name. + + @param Str The buffer storing device name. + @param DevPath The pointer to vendor device path. + +**/ +VOID +DevPathVendor ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ); + +/** + Concatenates a formatted unicode string to an allocated pool. + The caller must free the resulting buffer. + + @param Str Tracks the allocated pool, size in use, and amount of pool allocated. + @param Fmt The format string. + @param ... The data will be printed. + + @return Allocated buffer with the formatted string printed in it. + The caller must free the allocated buffer. + The buffer allocation is not packed. + +**/ + +CHAR16 * +EFIAPI +CatPrint ( + IN OUT POOL_PRINT *Str, + IN CHAR16 *Fmt, + ... + ); + +/** + Use SystemTable ConOut to stop video based Simple Text Out consoles from going + to the video device. Put up LogoFile on every video device that is a console. + + @param[in] LogoFile The file name of logo to display on the center of the screen. + + @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed. + @retval EFI_UNSUPPORTED Logo not found. + +**/ +EFI_STATUS +EFIAPI +EnableQuietBoot ( + IN EFI_GUID *LogoFile + ); + + +/** + Use SystemTable ConOut to turn on video based Simple Text Out consoles. The + Simple Text Out screens will now be synced up with all non-video output devices. + + @retval EFI_SUCCESS UGA devices are back in text mode and synced up. + +**/ +EFI_STATUS +EFIAPI +DisableQuietBoot ( + VOID + ); + +#endif + diff --git a/EfiLib/Make.tiano b/EfiLib/Make.tiano new file mode 100644 index 0000000..2e2e5b3 --- /dev/null +++ b/EfiLib/Make.tiano @@ -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 index 0000000..2d89822 --- /dev/null +++ b/EfiLib/Platform.h @@ -0,0 +1,792 @@ +/* +Headers collection for procedures +*/ + +#ifndef __REFIT_PLATFORM_H__ +#define __REFIT_PLATFORM_H__ + + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +//#include +//#include + +#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 diff --git a/Make.common b/Make.common index d098e2e..469bf64 100644 --- a/Make.common +++ b/Make.common @@ -11,7 +11,7 @@ EFICRT0 = /usr/local/lib 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 @@ -109,6 +109,6 @@ endif # utility rules clean: - rm -f $(TARGET) *~ *.so $(OBJS) *.efi + rm -f $(TARGET) *~ *.so $(OBJS) *.efi *.obj refind_*.txt refind_*.dll *.lib # EOF diff --git a/Make.tiano b/Make.tiano new file mode 100644 index 0000000..5eb99fc --- /dev/null +++ b/Make.tiano @@ -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 $@ + + diff --git a/Makefile b/Makefile index c21f2a8..d81ce19 100644 --- a/Makefile +++ b/Makefile @@ -8,21 +8,29 @@ OBJS=$(NAMES:=.o) HEADERS=$(NAMES:=.h) LOADER_DIR=refind FS_DIR=filesystems -LIB_DIR=libeg +LIBEG_DIR=libeg +EFILIB_DIR=EfiLib # 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) +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: - make -C $(LIB_DIR) clean + make -C $(LIBEG_DIR) clean make -C $(LOADER_DIR) clean + make -C $(EFILIB_DIR) clean -f Make.tiano make -C $(FS_DIR) clean + rm -f include/*~ # NOTE TO DISTRIBUTION MAINTAINERS: # The "install" target installs the program directly to the ESP diff --git a/NEWS.txt b/NEWS.txt index b9ac7a7..254a9b7 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,8 +1,20 @@ 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. +- 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): ----------------- diff --git a/docs/refind/configfile.html b/docs/refind/configfile.html index 55aa2ba..e7eaf51 100644 --- a/docs/refind/configfile.html +++ b/docs/refind/configfile.html @@ -182,6 +182,11 @@ timeout 20 Two integer values Sets the video resolution used by rEFInd; takes a width and a height as options. For instance, resolution 1024 768 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.x (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 0 or if you pass anything but two numbers. (Note that passing a resolution with an x, as in 1024x768, will be interpreted as one 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. + + use_graphics_for + osx, linux, elilo, grub, and windows + 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 use_graphics_for linux is required to avoid a system hang when launching Linux via its EFI stub loader. + scan_driver_dirs directory path(s) diff --git a/filesystems/Make.common b/filesystems/Make.common index 1c5872b..7a5de97 100644 --- a/filesystems/Make.common +++ b/filesystems/Make.common @@ -27,7 +27,7 @@ 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) +# 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 diff --git a/include/refit_call_wrapper.h b/include/refit_call_wrapper.h index 9b1f5c1..49b0b7f 100644 --- a/include/refit_call_wrapper.h +++ b/include/refit_call_wrapper.h @@ -1,6 +1,8 @@ #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)) @@ -33,5 +35,30 @@ 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__ */ diff --git a/libeg/Make.tiano b/libeg/Make.tiano new file mode 100644 index 0000000..9b196c7 --- /dev/null +++ b/libeg/Make.tiano @@ -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 diff --git a/libeg/image.c b/libeg/image.c index 271141f..28d2472 100644 --- a/libeg/image.c +++ b/libeg/image.c @@ -37,10 +37,16 @@ #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) +#ifndef __MAKEWITH_GNUEFI +#define LibLocateHandle gBS->LocateHandleBuffer +#define LibOpenRoot EfiLibOpenRoot +#endif + // // Basic image handling // diff --git a/libeg/libeg.h b/libeg/libeg.h index 498db61..89ddb74 100644 --- a/libeg/libeg.h +++ b/libeg/libeg.h @@ -37,6 +37,9 @@ #ifndef __LIBEG_LIBEG_H__ #define __LIBEG_LIBEG_H__ +#ifndef __MAKEWITH_GNUEFI +#include "../include/tiano_includes.h" +#endif /* types */ diff --git a/libeg/libegint.h b/libeg/libegint.h index 1b2cff8..8c7f1e1 100644 --- a/libeg/libegint.h +++ b/libeg/libegint.h @@ -37,9 +37,12 @@ #ifndef __LIBEG_LIBEGINT_H__ #define __LIBEG_LIBEGINT_H__ - +#ifdef __MAKEWITH_GNUEFI #include #include +#else +#include "../include/tiano_includes.h" +#endif #include "libeg.h" diff --git a/libeg/load_bmp.c b/libeg/load_bmp.c index d0092e5..9d29af6 100644 --- a/libeg/load_bmp.c +++ b/libeg/load_bmp.c @@ -38,6 +38,7 @@ // BMP structures +#ifdef __MAKEWITH_GNUEFI #pragma pack(1) typedef struct { @@ -67,6 +68,7 @@ typedef struct { } BMP_IMAGE_HEADER; #pragma pack() +#endif // // Load BMP image diff --git a/libeg/screen.c b/libeg/screen.c index fd441fe..b332704 100644 --- a/libeg/screen.c +++ b/libeg/screen.c @@ -36,11 +36,15 @@ #include "libegint.h" #include "../refind/screen.h" -#include "refit_call_wrapper.h" +#include "../include/refit_call_wrapper.h" #include #include +#ifndef __MAKEWITH_GNUEFI +#define LibLocateProtocol EfiLibLocateProtocol +#endif + // 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 *Temp; + 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) { - 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"; } diff --git a/refind.conf-sample b/refind.conf-sample index bfdeaa1..bfe3684 100644 --- a/refind.conf-sample +++ b/refind.conf-sample @@ -67,6 +67,24 @@ timeout 20 # #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 diff --git a/refind/AutoGen.c b/refind/AutoGen.c new file mode 100644 index 0000000..6f83c03 --- /dev/null +++ b/refind/AutoGen.c @@ -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 +#include +#include +#include +#include +#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 index 0000000..a07912e --- /dev/null +++ b/refind/AutoGen.h @@ -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 +#include +#include + +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 index 0000000..fd9f444 --- /dev/null +++ b/refind/Make.tiano @@ -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 diff --git a/refind/config.c b/refind/config.c index 63b0a22..eb5040c 100644 --- a/refind/config.c +++ b/refind/config.c @@ -49,12 +49,12 @@ #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" -#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) @@ -405,6 +405,22 @@ VOID ReadConfig(VOID) 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; @@ -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)) { + 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); @@ -445,6 +463,7 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu if (TokenCount > 1) { SubEntry->InitrdPath = StrDuplicate(TokenList[1]); } + } 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 + } 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"disabled") == 0) { SubEntry->Enabled = FALSE; } // ief/elseif + FreeTokenLine(&TokenList, &TokenCount); } // while() + 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); - 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; @@ -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); - 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 diff --git a/refind/config.h b/refind/config.h index f1d4059..6da2419 100644 --- a/refind/config.h +++ b/refind/config.h @@ -46,7 +46,11 @@ #ifndef __CONFIG_H_ #define __CONFIG_H_ +#ifdef __MAKEWITH_GNUEFI #include "efi.h" +#else +#include "../include/tiano_includes.h" +#endif #include "global.h" // diff --git a/refind/driver_support.c b/refind/driver_support.c index e04dd9d..000b410 100644 --- a/refind/driver_support.c +++ b/refind/driver_support.c @@ -19,8 +19,9 @@ */ #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 }}; @@ -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 }}; +#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.... diff --git a/refind/driver_support.h b/refind/driver_support.h index 0c64f5e..08405eb 100644 --- a/refind/driver_support.h +++ b/refind/driver_support.h @@ -17,8 +17,13 @@ * */ -#include +#ifdef __MAKEWITH_GNUEFI +#include #include +#else +#include "../include/tiano_includes.h" +#endif +#include "global.h" #ifndef _DRIVER_SUPPORT #define _DRIVER_SUPPORT diff --git a/refind/global.h b/refind/global.h index b2b38b8..905f79a 100644 --- a/refind/global.h +++ b/refind/global.h @@ -45,8 +45,12 @@ #ifndef __GLOBAL_H_ #define __GLOBAL_H_ -#include "efi.h" -#include "efilib.h" +#ifdef __MAKEWITH_GNUEFI +#include +#include +#else +#include "../include/tiano_includes.h" +#endif #include "libeg.h" @@ -68,6 +72,13 @@ #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 // @@ -159,6 +170,7 @@ typedef struct { 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; diff --git a/refind/icns.c b/refind/icns.c index e4738e2..f9be58b 100644 --- a/refind/icns.c +++ b/refind/icns.c @@ -38,6 +38,7 @@ #include "lib.h" #include "icns.h" #include "config.h" +#include "../refind/screen.h" // // 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); - if (Image != NULL) + if (Image != NULL) { + FreePool(CutoutName); return Image; + } FreePool(CutoutName); } // while diff --git a/refind/lib.c b/refind/lib.c index 71f76c5..85a1de2 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -46,8 +46,23 @@ #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 @@ -128,10 +143,13 @@ EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle) // 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); +// Print(L"SelfDirPath is '%s'\n", SelfDirPath); +// PauseForKey(); 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 - *ListPtr = ReallocatePool(*ListPtr, sizeof(VOID *) * (*ElementCount), sizeof(VOID *) * AllocateCount); + *ListPtr = EfiReallocatePool(*ListPtr, sizeof(VOID *) * (*ElementCount), sizeof(VOID *) * AllocateCount); } (*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 - 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++) @@ -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); } -} +} // ScanVolume() 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->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; @@ -722,8 +741,9 @@ VOID ScanVolumes(VOID) // 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... + } 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; - 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; } @@ -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 } - Buffer = ReallocatePool(Buffer, LastBufferSize, BufferSize); + Buffer = EfiReallocatePool(Buffer, LastBufferSize, BufferSize); 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; } +#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) { @@ -1322,3 +1398,4 @@ BOOLEAN EjectMedia(VOID) { FreePool(Handles); return (Ejected > 0); } // VOID EjectMedia() + diff --git a/refind/lib.h b/refind/lib.h index 17af8bd..f96315c 100644 --- a/refind/lib.h +++ b/refind/lib.h @@ -45,8 +45,13 @@ #ifndef __LIB_H_ #define __LIB_H_ +#ifdef __MAKEWITH_GNUEFI #include "efi.h" #include "efilib.h" +#else +#include "../include/tiano_includes.h" +#endif +#include "global.h" #include "libeg.h" diff --git a/refind/main.c b/refind/main.c index 312b126..ffb22fd 100644 --- a/refind/main.c +++ b/refind/main.c @@ -48,7 +48,8 @@ #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" @@ -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" #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 }; -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 @@ -104,9 +106,11 @@ struct LOADER_LIST { 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); - 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"); @@ -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, 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) @@ -123,9 +128,19 @@ static VOID AboutrEFInd(VOID) #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/"); @@ -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); - if (ReturnStatus != EFI_NOT_FOUND) + if (ReturnStatus != EFI_NOT_FOUND) { break; + } } 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) { - 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... - LoadOptions = FullLoadOptions; } // 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) - Print(L"Using load options '%s'\n", LoadOptions); + Print(L"Using load options '%s'\n", FullLoadOptions); } // 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, - Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), &ErrorInStep, TRUE); + Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), &ErrorInStep, !Entry->UseGraphicsMode); 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) { - 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 { - 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); @@ -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) { - CHAR16 *FileName, *Temp; + CHAR16 *FileName, *Temp = NULL, *TitleStr; 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) { - 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))) { - 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 @@ -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; - CHAR16 *FileName, *InitrdOption = NULL, *Temp; + CHAR16 *InitrdOption = NULL, *Temp; 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); @@ -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"; + SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX; 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"; + SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX; 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); - SubEntry->UseGraphicsMode = TRUE; + SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX; 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) { - 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) { @@ -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->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_LINUX; 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) { - 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->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO; 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->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO; 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->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO; 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->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO; 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"; + SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS; 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"; + SubEntry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS; 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 = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS; 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); - 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); @@ -644,6 +681,7 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_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'; @@ -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->UseGraphicsMode = TRUE; 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) { @@ -663,20 +701,24 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME 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'; + 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'; + 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'; + Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS; } 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; + CHAR16 *PoolStr; 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'\\')) { @@ -706,7 +751,6 @@ LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN 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); @@ -1118,6 +1162,7 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Vo REFIT_MENU_SCREEN *SubScreen; CHAR16 *VolDesc; CHAR16 ShortcutLetter = 0; + CHAR16 *PoolStr; 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)); - 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; @@ -1147,12 +1194,16 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Vo // 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)); - 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; @@ -1252,10 +1303,13 @@ static LOADER_ENTRY * AddToolEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle IN CHAR16 ShortcutLetter, IN BOOLEAN UseGraphicsMode) { LOADER_ENTRY *Entry; + CHAR16 *TitleStr = NULL; 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; @@ -1300,6 +1354,7 @@ static UINTN ScanDriverDir(IN CHAR16 *Path) return (NumFound); } +#ifdef __MAKEWITH_GNUEFI static EFI_STATUS ConnectAllDriversToAllControllers(VOID) { EFI_STATUS Status; @@ -1367,6 +1422,12 @@ Done: 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 @@ -1512,6 +1573,21 @@ VOID RescanAll(VOID) { 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 // diff --git a/refind/menu.c b/refind/menu.c index d35cd11..1beb3e7 100644 --- a/refind/menu.c +++ b/refind/menu.c @@ -48,11 +48,11 @@ #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 @@ -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; - CHAR16 *TimeoutMessage; + CHAR16 TimeoutMessage[256]; CHAR16 KeyAsString[2]; UINTN MenuExit; @@ -400,9 +400,8 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty } 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); - FreePool(TimeoutMessage); } // 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; - CHAR16 *TimeoutMessage; + CHAR16 TimeoutMessage[256]; 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++) - 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 @@ -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); - TimeoutMessage = PoolPrint(L"%s ", ParamText); + SPrint(TimeoutMessage, 255, L"%s ", ParamText); refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, TimeoutMessage); - FreePool(TimeoutMessage); } break; diff --git a/refind/menu.h b/refind/menu.h index f9052d1..6e4170b 100644 --- a/refind/menu.h +++ b/refind/menu.h @@ -45,8 +45,13 @@ #ifndef __REFIND_MENU_H_ #define __REFIND_MENU_H_ +#ifdef __MAKEWITH_GNUEFI #include "efi.h" #include "efilib.h" +#else +#include "../include/tiano_includes.h" +#endif +#include "global.h" #include "libeg.h" diff --git a/refind/screen.c b/refind/screen.c index 0ad950f..3b98586 100644 --- a/refind/screen.c +++ b/refind/screen.c @@ -1,5 +1,5 @@ /* - * refit/screen.c + * refind/screen.c * Screen handling functions * * Copyright (c) 2006 Christoph Pfisterer @@ -38,9 +38,9 @@ #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 @@ -177,10 +177,11 @@ VOID BeginExternalScreen(IN BOOLEAN UseGraphicsMode, IN CHAR16 *Title) BltClearScreen(FALSE); } else { egClearScreen(&DarkBackgroundPixel); + DrawScreenHeader(Title); } // if/else // show the header - DrawScreenHeader(Title); +// DrawScreenHeader(Title); if (!UseGraphicsMode) SwitchToText(TRUE); @@ -302,6 +303,7 @@ VOID EndlessIdleLoop(VOID) // Error handling // +#ifdef __MAKEWITH_GNUEFI 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; } +#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 @@ -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) { - 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 diff --git a/refind/screen.h b/refind/screen.h index 1b2dfa6..d0ffa29 100644 --- a/refind/screen.h +++ b/refind/screen.h @@ -37,8 +37,12 @@ #ifndef __SCREEN_H_ #define __SCREEN_H_ +#ifdef __MAKEWITH_GNUEFI #include "efi.h" #include "efilib.h" +#else +#include "../include/tiano_includes.h" +#endif #include "libeg.h"