当前位置: 首页>>代码示例>>C++>>正文


C++ DevicePathToStr函数代码示例

本文整理汇总了C++中DevicePathToStr函数的典型用法代码示例。如果您正苦于以下问题:C++ DevicePathToStr函数的具体用法?C++ DevicePathToStr怎么用?C++ DevicePathToStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DevicePathToStr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: efi_main

EFI_STATUS
efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	EFI_LOADED_IMAGE *loaded_image = NULL;
#if 0
	EFI_DEVICE_PATH *dev_path;
#endif
	EFI_STATUS status;

	InitializeLib(image, systab);
	status = uefi_call_wrapper(systab->BootServices->HandleProtocol,
				3,
				image, 
				&LoadedImageProtocol, 
				(void **) &loaded_image);
	if (EFI_ERROR(status)) {
		Print(L"handleprotocol: %r\n", status);
	}

#if 0
	BS->HandleProtocol(loaded_image->DeviceHandle, &DevicePathProtocol, (void **) &dev_path);

	Print(L"Image device      : %s\n", DevicePathToStr(dev_path));
	Print(L"Image file        : %s\n", DevicePathToStr(loaded_image->FilePath));
#endif
	Print(L"Image base        : %lx\n", loaded_image->ImageBase);
	Print(L"Image size        : %lx\n", loaded_image->ImageSize);
	Print(L"Load options size : %lx\n", loaded_image->LoadOptionsSize);
	Print(L"Load options      : %s\n", loaded_image->LoadOptions);

	return EFI_SUCCESS;
}
开发者ID:Celelibi,项目名称:gnu-efi,代码行数:32,代码来源:t6.c

示例2: DisplayEntries

VOID DisplayEntries(EFI_DEVICE_PATH *ldr, UINTN slice, UINTN index, VOID *ctx) {
    EFI_DEVICE_PATH *pDevice = GetParentDevice(ldr);
    CHAR16 *pszDevice = DevicePathToStr(GetLastDevicePath(pDevice));
    Print(L"[%d] %s\n", index - slice + 1, pszDevice);
    FreePool(pszDevice);
    FreePool(pDevice);
}
开发者ID:linnaea,项目名称:uefi-ntfs-multiboot,代码行数:7,代码来源:boot.c

示例3: DisconnectBlockingDrivers

/*
* Some UEFI firmwares (like HPQ EFI from HP notebooks) have DiskIo protocols
* opened BY_DRIVER (by Partition driver in HP case) even when no file system
* is produced from this DiskIo. This then blocks our FS driver from connecting
* and producing file systems.
* To fix it we disconnect drivers that connected to DiskIo BY_DRIVER if this
* is a partition volume and if those drivers did not produce file system.
*/
static VOID DisconnectBlockingDrivers(VOID) {
    EFI_STATUS Status;
    UINTN HandleCount = 0, Index, OpenInfoIndex, OpenInfoCount;
    EFI_HANDLE *Handles = NULL;
    CHAR16 *DevicePathString;
    EFI_FILE_IO_INTERFACE *Volume;
    EFI_BLOCK_IO *BlockIo;
    EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;

    // Get all DiskIo handles
    Status = BS->LocateHandleBuffer(ByProtocol, &DiskIoProtocol, NULL, &HandleCount, &Handles);
    if (EFI_ERROR(Status) || (HandleCount == 0))
        return;

    // Check every DiskIo handle
    for (Index = 0; Index < HandleCount; Index++) {
        // If this is not partition - skip it.
        // This is then whole disk and DiskIo
        // should be opened here BY_DRIVER by Partition driver
        // to produce partition volumes.
        Status = BS->HandleProtocol(Handles[Index], &BlockIoProtocol, (VOID **)&BlockIo);
        if (EFI_ERROR(Status))
            continue;
        if ((BlockIo->Media == NULL) || (!BlockIo->Media->LogicalPartition))
            continue;

        // If SimpleFileSystem is already produced - skip it, this is ok
        Status = BS->HandleProtocol(Handles[Index], &FileSystemProtocol, (VOID **)&Volume);
        if (Status == EFI_SUCCESS)
            continue;

        DevicePathString = DevicePathToStr(DevicePathFromHandle(Handles[Index]));
        Print(L"%N\r[ INFO ] Probing %d devices... [%d] %s", HandleCount, Index + 1, DevicePathString);
        FreePool(DevicePathString);

        // If no SimpleFileSystem on this handle but DiskIo is opened BY_DRIVER
        // then disconnect this connection
        Status = BS->OpenProtocolInformation(Handles[Index], &DiskIoProtocol, &OpenInfo, &OpenInfoCount);
        if (EFI_ERROR(Status)) {
            Print(L"%H\n[ WARN ] Could not get DiskIo protocol: %r\n", Status);
            FreePool(DevicePathString);
            continue;
        }

        if (OpenInfoCount > 0)
            Print(L"%N\n[ INFO ] Disconnecting %d drivers...", OpenInfoCount);

        for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
            if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) {
                Print(L"%N\r[ INFO ] Disconnecting %d drivers... [%d] %s", OpenInfoCount, OpenInfoIndex+1, GetDriverName(OpenInfo[OpenInfoIndex].AgentHandle));
                Status = BS->DisconnectController(Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, NULL);
                if (EFI_ERROR(Status)) {
                    Print(L"%H\n[ WARN ] Could not disconnect driver: %r\n", Status);
                }
            }
        }
        FreePool(OpenInfo);
    }
    FreePool(Handles);
}
开发者ID:linnaea,项目名称:uefi-ntfs-multiboot,代码行数:68,代码来源:boot.c

示例4: LibGetUiString

CHAR16 *
LibGetUiString (
    IN  EFI_HANDLE      Handle,
    IN  UI_STRING_TYPE  StringType,
    IN  ISO_639_2       *LangCode,
    IN  BOOLEAN         ReturnDevicePathStrOnMismatch
    )
{
    UI_INTERFACE    *Ui;
    UI_STRING_TYPE  Index;
    UI_STRING_ENTRY *Array;
    EFI_STATUS      Status;
    
    Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handle, &UiProtocol, (VOID *)&Ui);
    if (EFI_ERROR(Status)) {
        return (ReturnDevicePathStrOnMismatch) ? DevicePathToStr(DevicePathFromHandle(Handle)) : NULL;
    }

    //
    // Skip the first strings
    //
    for (Index = UiDeviceString, Array = Ui->Entry; Index < StringType; Index++, Array++) {
        while (Array->LangCode) {
            Array++;
        }
    }

    //
    // Search for the match
    //
    while (Array->LangCode) {
        if (strcmpa (Array->LangCode, LangCode) == 0) {
            return Array->UiString; 
        }
    }
    return (ReturnDevicePathStrOnMismatch) ? DevicePathToStr(DevicePathFromHandle(Handle)) : NULL;
}
开发者ID:michas2,项目名称:l4re-snapshot,代码行数:37,代码来源:misc.c

示例5: generate_path

EFI_STATUS
generate_path(CHAR16* name, EFI_LOADED_IMAGE *li, EFI_DEVICE_PATH **path, CHAR16 **PathName)
{
	unsigned int pathlen;
	EFI_STATUS efi_status = EFI_SUCCESS;
	CHAR16 *devpathstr = DevicePathToStr(li->FilePath),
		*found = NULL;
	unsigned int i;

	for (i = 0; i < StrLen(devpathstr); i++) {
		if (devpathstr[i] == '/')
			devpathstr[i] = '\\';
		if (devpathstr[i] == '\\')
			found = &devpathstr[i];
	}
	if (!found) {
		pathlen = 0;
	} else {
		while (*(found - 1) == '\\')
			--found;
		*found = '\0';
		pathlen = StrLen(devpathstr);
	}

	if (name[0] != '\\')
		pathlen++;

	*PathName = AllocatePool((pathlen + 1 + StrLen(name))*sizeof(CHAR16));

	if (!*PathName) {
		Print(L"Failed to allocate path buffer\n");
		efi_status = EFI_OUT_OF_RESOURCES;
		goto error;
	}

	StrCpy(*PathName, devpathstr);

	if (name[0] != '\\')
		StrCat(*PathName, L"\\");
	StrCat(*PathName, name);
	
	*path = FileDevicePath(li->DeviceHandle, *PathName);

error:
	FreePool(devpathstr);

	return efi_status;
}
开发者ID:Acidburn0zzz,项目名称:shim,代码行数:48,代码来源:execute.c

示例6: DevicePathStrFromProtocol

UINT16 *
DevicePathStrFromProtocol (
  IN VOID        *Protocol,
  IN EFI_GUID    *Guid
  )
{
  EFI_STATUS                          Status;
  UINTN                                HandleNum;
  EFI_HANDLE                          *HandleBuffer;
  EFI_DEVICE_PATH_PROTOCOL            *DevicePath;
  UINTN                               Index;
  UINT16                              *Str;
  VOID                                *Interface;
  //BOOLEAN                             Found;

  //Found = FALSE;
  Str = NULL;
  HandleNum    = 0;
  Status      = LibLocateHandle(
                  ByProtocol,
                  Guid,
                  NULL,
                  &HandleNum,
                  &HandleBuffer
                  );
  if (EFI_ERROR(Status) || HandleNum == 0) {
    return NULL;
  }

  for ( Index = 0 ; Index < HandleNum ; Index ++ ) {
    Status = tBS->HandleProtocol (HandleBuffer[Index], Guid, &Interface);
    if (EFI_ERROR(Status)) {
      continue;
    }

    if (Interface == Protocol) {
      Status = tBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, &DevicePath);
      if (!EFI_ERROR(Status)) {
        //Found = TRUE;
        Str = DevicePathToStr(DevicePath);
      }
      break;
    }
  }

  return Str;
}
开发者ID:jljusten,项目名称:efi-sct,代码行数:47,代码来源:dpath.c

示例7: ConnectRecursivelyIfPciMassStorage

EFI_STATUS
EFIAPI
ConnectRecursivelyIfPciMassStorage (
  IN EFI_HANDLE           Handle,
  IN EFI_PCI_IO_PROTOCOL  *Instance,
  IN PCI_TYPE00           *PciHeader
  )
{
  EFI_STATUS                Status;
  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
  CHAR16                    *DevPathStr;

  if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
    DevicePath = NULL;
    Status = gBS->HandleProtocol (
                    Handle,
                    &gEfiDevicePathProtocolGuid,
                    (VOID*)&DevicePath
                    );
    if (EFI_ERROR (Status)) {
      return Status;
    }

    //
    // Print Device Path
    //
    DevPathStr = DevicePathToStr (DevicePath);
    if (DevPathStr != NULL) {
      DEBUG((
        EFI_D_INFO,
        "Found Mass Storage device: %s\n",
        DevPathStr
        ));
      FreePool(DevPathStr);
    }

    Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
    if (EFI_ERROR (Status)) {
      return Status;
    }

  }

  return EFI_SUCCESS;
}
开发者ID:jeppeter,项目名称:vbox,代码行数:45,代码来源:BdsPlatform.c

示例8: try_start_first_option

static EFI_STATUS
try_start_first_option(EFI_HANDLE parent_image_handle)
{
	EFI_STATUS rc;
	EFI_HANDLE image_handle;

	if (!first_new_option) {
		return EFI_SUCCESS;
	}

	rc = uefi_call_wrapper(BS->LoadImage, 6, 0, parent_image_handle,
			       first_new_option, NULL, 0,
			       &image_handle);
	if (EFI_ERROR(rc)) {
		CHAR16 *dps = DevicePathToStr(first_new_option);
		UINTN s = DevicePathSize(first_new_option);
		unsigned int i;
		UINT8 *dpv = (void *)first_new_option;
		Print(L"LoadImage failed: %d\nDevice path: \"%s\"\n", rc, dps);
		for (i = 0; i < s; i++) {
			if (i > 0 && i % 16 == 0)
				Print(L"\n");
			Print(L"%02x ", dpv[i]);
		}
		Print(L"\n");

		uefi_call_wrapper(BS->Stall, 1, 500000000);
		return rc;
	}

	EFI_LOADED_IMAGE *image;
	rc = uefi_call_wrapper(BS->HandleProtocol, 3, image_handle, &LoadedImageProtocol, (void *)&image);
	if (!EFI_ERROR(rc)) {
		image->LoadOptions = first_new_option_args;
		image->LoadOptionsSize = first_new_option_size;
	}

	rc = uefi_call_wrapper(BS->StartImage, 3, image_handle, NULL, NULL);
	if (EFI_ERROR(rc)) {
		Print(L"StartImage failed: %d\n", rc);
		uefi_call_wrapper(BS->Stall, 1, 500000000);
	}
	return rc;
}
开发者ID:Acidburn0zzz,项目名称:shim,代码行数:44,代码来源:fallback.c

示例9: get_path

static inline BOOLEAN
get_path(EFI_LOADED_IMAGE *image, CHAR16 *path, UINTN len)
{
	CHAR16 *buf, *p, *q;
	int i, dev;

	dev = handle_to_dev(image->DeviceHandle);
	if (dev == -1) {
		error(L"Couldn't find boot device handle\n");
		return FALSE;
	}

	/* Find the path of the efilinux executable*/
	p = DevicePathToStr(image->FilePath);
	if (!p) {
		error(L"Failed to get string from device path\n");
		return FALSE;
	}

	q = p + StrLen(p);

	i = StrLen(p);
	while (*q != '\\' && *q != '/') {
		q--;
		i--;
	}

	buf = malloc((i + 1) * sizeof(CHAR16));
	if (!buf) {
		error(L"Failed to allocate buf\n");
		FreePool(p);
		return FALSE;
	}

	memcpy((CHAR8 *)buf, (CHAR8 *)p, i * sizeof(CHAR16));
	FreePool(p);

	buf[i] = '\0';
	SPrint(path, len, L"%d:%s\\%s", dev, buf, EFILINUX_CONFIG);

	return TRUE;
}
开发者ID:TheTypoMaster,项目名称:x86-android-5.0,代码行数:42,代码来源:entry.c

示例10: LocateSerialIo

EFI_STATUS
LocateSerialIo (
    VOID
)
/*++

Routine Description:
  Build a list containing all serial devices

Arguments:

Returns:

--*/
{
    UINT8                     *Ptr;
    UINTN                     Index;
    UINTN                     Index2;
    UINTN                     NoHandles;
    EFI_HANDLE                *Handles;
    EFI_STATUS                Status;
    ACPI_HID_DEVICE_PATH      *Acpi;
    EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
    UINT32                    Match;
    EFI_SERIAL_IO_PROTOCOL    *SerialIo;
    EFI_DEVICE_PATH_PROTOCOL  *OutDevicePath;
    EFI_DEVICE_PATH_PROTOCOL  *InpDevicePath;
    EFI_DEVICE_PATH_PROTOCOL  *ErrDevicePath;
    BM_MENU_ENTRY             *NewMenuEntry;
    BM_TERMINAL_CONTEXT       *NewTerminalContext;
    EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;
    VENDOR_DEVICE_PATH        Vendor;
    //
    // Get all handles that have SerialIo protocol installed
    //
    InitializeListHead (&TerminalMenu.Head);
    TerminalMenu.MenuNumber = 0;
    Status = gBS->LocateHandleBuffer (
                 ByProtocol,
                 &gEfiSerialIoProtocolGuid,
                 NULL,
                 &NoHandles,
                 &Handles
             );
    if (EFI_ERROR (Status)) {
        //
        // No serial ports present
        //
        return EFI_UNSUPPORTED;
    }

    //
    // Sort Uart handles array with Acpi->UID from low to high
    // then Terminal menu can be built from low Acpi->UID to high Acpi->UID
    //
    SortedUartHandle (Handles, NoHandles);

    for (Index = 0; Index < NoHandles; Index++) {
        //
        // Check to see whether the handle has DevicePath Protocol installed
        //
        gBS->HandleProtocol (
            Handles[Index],
            &gEfiDevicePathProtocolGuid,
            &DevicePath
        );
        Ptr = (UINT8 *) DevicePath;
        while (*Ptr != END_DEVICE_PATH_TYPE) {
            Ptr++;
        }

        Ptr   = Ptr - sizeof (UART_DEVICE_PATH) - sizeof (ACPI_HID_DEVICE_PATH);
        Acpi  = (ACPI_HID_DEVICE_PATH *) Ptr;
        Match = EISA_PNP_ID (0x0501);

        if (EfiCompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {
            NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);
            if (!NewMenuEntry) {
                SafeFreePool (Handles);
                return EFI_OUT_OF_RESOURCES;
            }

            NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
            EfiCopyMem (&NewMenuEntry->OptionNumber, &Acpi->UID, sizeof (UINT32));
            NewTerminalContext->DevicePath = DevicePathInstanceDup (DevicePath);
            //
            // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!
            // coz' the misc data for each platform is not correct, actually it's the device path stored in
            // datahub which is not completed, so a searching for end of device path will enter a
            // dead-loop.
            //
            NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath);
            if (NULL == NewMenuEntry->DisplayString) {
                NewMenuEntry->DisplayString = DevicePathToStr (DevicePath);
            }

            NewMenuEntry->HelpString = NULL;

            gBS->HandleProtocol (
                Handles[Index],
//.........这里部分代码省略.........
开发者ID:Kohrara,项目名称:edk,代码行数:101,代码来源:ConsoleOption.c

示例11: GetConsoleMenu

EFI_STATUS
GetConsoleMenu (
    IN UINTN              ConsoleMenuType
)
{
    EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
    EFI_DEVICE_PATH_PROTOCOL  *AllDevicePath;
    EFI_DEVICE_PATH_PROTOCOL  *MultiDevicePath;
    EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;
    UINTN                     Size;
    UINTN                     AllCount;
    UINTN                     Index;
    UINTN                     Index2;
    BM_MENU_ENTRY             *NewMenuEntry;
    BM_CONSOLE_CONTEXT        *NewConsoleContext;
    BM_TERMINAL_CONTEXT       *NewTerminalContext;
    TYPE_OF_TERMINAL          Terminal;
    BM_MENU_ENTRY             *NewTerminalMenuEntry;
    UINTN                     Com;
    BM_MENU_OPTION            *ConsoleMenu;

    DevicePath    = NULL;
    AllDevicePath = NULL;
    AllCount      = 0;
    switch (ConsoleMenuType) {
    case BM_CONSOLE_IN_CONTEXT_SELECT:
        ConsoleMenu = &ConsoleInpMenu;
        DevicePath = EfiLibGetVariable (
                         L"ConIn",
                         &gEfiGlobalVariableGuid
                     );

        AllDevicePath = EfiLibGetVariable (
                            L"ConInDev",
                            &gEfiGlobalVariableGuid
                        );
        break;

    case BM_CONSOLE_OUT_CONTEXT_SELECT:
        ConsoleMenu = &ConsoleOutMenu;
        DevicePath = EfiLibGetVariable (
                         L"ConOut",
                         &gEfiGlobalVariableGuid
                     );

        AllDevicePath = EfiLibGetVariable (
                            L"ConOutDev",
                            &gEfiGlobalVariableGuid
                        );
        break;

    case BM_CONSOLE_ERR_CONTEXT_SELECT:
        ConsoleMenu = &ConsoleErrMenu;
        DevicePath = EfiLibGetVariable (
                         L"ErrOut",
                         &gEfiGlobalVariableGuid
                     );

        AllDevicePath = EfiLibGetVariable (
                            L"ErrOutDev",
                            &gEfiGlobalVariableGuid
                        );
        break;

    default:
        return EFI_UNSUPPORTED;
    }

    if (NULL == AllDevicePath) {
        return EFI_NOT_FOUND;
    }

    InitializeListHead (&ConsoleMenu->Head);

    AllCount                = EfiDevicePathInstanceCount (AllDevicePath);
    ConsoleMenu->MenuNumber = 0;
    //
    // Following is menu building up for Console Out Devices
    //
    MultiDevicePath = AllDevicePath;
    Index2          = 0;
    for (Index = 0; Index < AllCount; Index++) {
        DevicePathInst  = EfiDevicePathInstance (&MultiDevicePath, &Size);

        NewMenuEntry    = BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT);
        if (NULL == NewMenuEntry) {
            return EFI_OUT_OF_RESOURCES;
        }

        NewConsoleContext             = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
        NewMenuEntry->OptionNumber    = Index2;

        NewConsoleContext->DevicePath = DevicePathInstanceDup (DevicePathInst);
        NewMenuEntry->DisplayString   = EfiLibStrFromDatahub (NewConsoleContext->DevicePath);
        if (NULL == NewMenuEntry->DisplayString) {
            NewMenuEntry->DisplayString = DevicePathToStr (NewConsoleContext->DevicePath);
        }

        NewConsoleContext->IsTerminal = IsTerminalDevicePath (
                                            NewConsoleContext->DevicePath,
//.........这里部分代码省略.........
开发者ID:Kohrara,项目名称:edk,代码行数:101,代码来源:ConsoleOption.c

示例12: efi_main

EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
        EFI_LOADED_IMAGE *loaded_image;
        EFI_FILE *root_dir;
        CHAR16 *loaded_image_path;
        CHAR8 *b;
        UINTN size;
        BOOLEAN secure = FALSE;
        CHAR8 *sections[] = {
                (UINT8 *)".cmdline",
                (UINT8 *)".linux",
                (UINT8 *)".initrd",
                (UINT8 *)".splash",
                NULL
        };
        UINTN addrs[ELEMENTSOF(sections)-1] = {};
        UINTN offs[ELEMENTSOF(sections)-1] = {};
        UINTN szs[ELEMENTSOF(sections)-1] = {};
        CHAR8 *cmdline = NULL;
        UINTN cmdline_len;
        CHAR16 uuid[37];
        EFI_STATUS err;

        InitializeLib(image, sys_table);

        err = uefi_call_wrapper(BS->OpenProtocol, 6, image, &LoadedImageProtocol, (VOID **)&loaded_image,
                                image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
        if (EFI_ERROR(err)) {
                Print(L"Error getting a LoadedImageProtocol handle: %r ", err);
                uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
                return err;
        }

        root_dir = LibOpenRoot(loaded_image->DeviceHandle);
        if (!root_dir) {
                Print(L"Unable to open root directory: %r ", err);
                uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
                return EFI_LOAD_ERROR;
        }

        loaded_image_path = DevicePathToStr(loaded_image->FilePath);

        if (efivar_get_raw(&global_guid, L"SecureBoot", &b, &size) == EFI_SUCCESS) {
                if (*b > 0)
                        secure = TRUE;
                FreePool(b);
        }

        err = pefile_locate_sections(root_dir, loaded_image_path, sections, addrs, offs, szs);
        if (EFI_ERROR(err)) {
                Print(L"Unable to locate embedded .linux section: %r ", err);
                uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
                return err;
        }

        if (szs[0] > 0)
                cmdline = (CHAR8 *)(loaded_image->ImageBase + addrs[0]);

        cmdline_len = szs[0];

        /* if we are not in secure boot mode, accept a custom command line and replace the built-in one */
        if (!secure && loaded_image->LoadOptionsSize > 0) {
                CHAR16 *options;
                CHAR8 *line;
                UINTN i;

                options = (CHAR16 *)loaded_image->LoadOptions;
                cmdline_len = (loaded_image->LoadOptionsSize / sizeof(CHAR16)) * sizeof(CHAR8);
                line = AllocatePool(cmdline_len);
                for (i = 0; i < cmdline_len; i++)
                        line[i] = options[i];
                cmdline = line;

#ifdef SD_BOOT_LOG_TPM
                /* Try to log any options to the TPM, escpecially manually edited options */
                err = tpm_log_event(SD_TPM_PCR,
                                    (EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions,
                                    loaded_image->LoadOptionsSize, loaded_image->LoadOptions);
                if (EFI_ERROR(err)) {
                        Print(L"Unable to add image options measurement: %r", err);
                        uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
                        return err;
                }
#endif
        }

        /* export the device path this image is started from */
        if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS)
                efivar_set(L"LoaderDevicePartUUID", uuid, FALSE);

        if (szs[3] > 0)
                graphics_splash((UINT8 *)((UINTN)loaded_image->ImageBase + addrs[3]), szs[3], NULL);

        err = linux_exec(image, cmdline, cmdline_len,
                         (UINTN)loaded_image->ImageBase + addrs[1],
                         (UINTN)loaded_image->ImageBase + addrs[2], szs[2]);

        graphics_mode(FALSE);
        Print(L"Execution of embedded linux image failed: %r\n", err);
        uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
        return err;
//.........这里部分代码省略.........
开发者ID:AOSC-Dev,项目名称:systemd,代码行数:101,代码来源:stub.c

示例13: InitTestEnv


//.........这里部分代码省略.........
                      (*StandardLib),
                      EFI_TEST_ASSERTION_FAILED,
                      gTestGenericFailureGuid,
                      L"BS.LocateHandle - LocateHandle",
                      L"%a:%d:Device Error",
                      __FILE__,
                      (UINTN)__LINE__
                      );
    return EFI_DEVICE_ERROR;
  }
  //
  // Find the exact handle that GraphicsOutput bound to
  //
  for (Index = 0; Index < NoHandles; Index++) {
    Status = gtBS->HandleProtocol (
                     HandleBuffer[Index],
                     &gEfiGraphicsOutputProtocolGuid,
                     &OtherGraphicsOutput
                     );
    if (EFI_ERROR (Status)) {
      (*StandardLib)->RecordAssertion (
                        (*StandardLib),
                        EFI_TEST_ASSERTION_FAILED,
                        gTestGenericFailureGuid,
                        L"BS.HandleProtocol - HandleProtocol",
                        L"%a:%d:Status - %r",
                        __FILE__,
                        (UINTN)__LINE__,
                        Status
                        );

      gtBS->FreePool (HandleBuffer);
      return Status;
    }

    if (OtherGraphicsOutput == GraphicsOutput) {
      break;
    }
  }
  //
  // Locate the DevicePath Protocol bound to GraphicsOutput Protocol
  //
  if (Index >= NoHandles) {
    //
    // No Handle Found!!
    //
    gtBS->FreePool (HandleBuffer);

    return EFI_DEVICE_ERROR;
  }

  Status = gtBS->HandleProtocol (
                   HandleBuffer[Index],
                   &gEfiDevicePathProtocolGuid,
                   &DevicePath
                   );

  gtBS->FreePool (HandleBuffer);

  if (Status == EFI_SUCCESS) {
    DevicePathStr = DevicePathToStr (DevicePath);
    if (DevicePathStr != NULL) {
      (*StandardLib)->RecordMessage (
                        (*StandardLib),
                        EFI_VERBOSE_LEVEL_DEFAULT,
                        L"\r\nCurrent Device: %s",
                        DevicePathStr
                        );
      Status = gtBS->FreePool (DevicePathStr);
      if (EFI_ERROR (Status)) {
        (*StandardLib)->RecordAssertion (
                          (*StandardLib),
                          EFI_TEST_ASSERTION_FAILED,
                          gTestGenericFailureGuid,
                          L"BS.FreePool - Free pool",
                          L"%a:%d:Status - %r",
                          __FILE__,
                          (UINTN)__LINE__,
                          Status
                          );
        return Status;
      }

      DevicePathStr = NULL;
    }
  } else {
    //
    // Console Splitter/GraphicsOutput, must add to continue run the rest of the test case
    //
    (*StandardLib)->RecordMessage (
                      (*StandardLib),
                      EFI_VERBOSE_LEVEL_DEFAULT,
                      L"\r\nCurrent Device: ConsoleSplitter/GraphicsOutput"
                      );

    return EFI_SUCCESS;
  }

  return Status;
}
开发者ID:JackNine,项目名称:2ndProject,代码行数:101,代码来源:GraphicsOutputBBTestSupport.c

示例14: Attributes_Stress

//
//TDS 4.3.1
//
EFI_STATUS
Attributes_Stress (
  IN EFI_BB_TEST_PROTOCOL       *This,
  IN VOID                       *ClientInterface,
  IN EFI_TEST_LEVEL             TestLevel,
  IN EFI_HANDLE                 SupportHandle
  )
{
  EFI_STATUS                            Status;
  EFI_STATUS                            Status1;
  PCI_IO_PROTOCOL_DEVICE                *PciIoDevice;
  EFI_PCI_IO_PROTOCOL                   *PciIo;
  EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib;
  EFI_TEST_ASSERTION                    AssertionType;
  UINT64                                SupportedAttributes;
  UINT64                                CurrentAttributes;
  UINT64                                OriginalAttributes;
  UINT64                                CommonAttributes;
  UINTN                                 Index;
  UINTN                                 PciIoAttributesNumber;
  UINT64                                ThisAttribute;
  CHAR16                               *DevicePathStr;



  //
  //get tested interface.
  //
  PciIo = (EFI_PCI_IO_PROTOCOL *)ClientInterface;

  //
  // Get the Standard Library Interface
  //
  Status = gtBS->HandleProtocol (
                   SupportHandle,
                   &gEfiStandardTestLibraryGuid,
                   &StandardLib
                   );

  if (EFI_ERROR(Status)) {
    return Status;
  }

  InitializeCaseEnvironment ();

  //
  //get PciIoDevice struct pointer.
  //
  PciIoDevice = NULL;
  PciIoDevice = GetPciIoDevice (PciIo);
  if (PciIoDevice == NULL) {
    return EFI_ABORTED;
  }
  //
  //print the device path of pci device.
  //
//  Status = PrintPciIoDevice (PciIoDevice->DevicePath);
//  if (EFI_ERROR(Status)) {
//    return Status;
//  }


  DevicePathStr = DevicePathToStr (PciIoDevice->DevicePath);
  if (DevicePathStr == NULL) {
    StandardLib->RecordMessage (
                   StandardLib,
                   EFI_VERBOSE_LEVEL_DEFAULT,
                   L"\r\nCannot get DevicePath"
                   );
  } else {
    StandardLib->RecordMessage (
                   StandardLib,
                   EFI_VERBOSE_LEVEL_DEFAULT,
                   L"\r\nCurrent Device: %s",
                   DevicePathStr
                   );
    gtBS->FreePool (DevicePathStr);
  }
  //
  //call Attributes with operation EfiPciIoAttributeOperationGet to
  //get current attributes.
  //
  PciIo->Attributes (
           PciIo,
           EfiPciIoAttributeOperationGet,
           0,
           &OriginalAttributes
           );

  //
  //call Attribtes with operation EfiPciIoAttributeOperationSupported to
  //get the supported attributes of the pci controller.
  //

  PciIo->Attributes (
           PciIo,
           EfiPciIoAttributeOperationSupported,
//.........这里部分代码省略.........
开发者ID:jljusten,项目名称:efi-sct,代码行数:101,代码来源:PciIoBBTestStress.c

示例15: PrepareLpcBridgeDevicePath

EFI_STATUS
PrepareLpcBridgeDevicePath (
  IN EFI_HANDLE                DeviceHandle
  )
/*++

Routine Description:

  Add IsaKeyboard to ConIn,
  add IsaSerial to ConOut, ConIn, ErrOut.
  LPC Bridge: 06 01 00

Arguments:

  DeviceHandle            - Handle of PCIIO protocol.

Returns:

  EFI_SUCCESS             - LPC bridge is added to ConOut, ConIn, and ErrOut.
  EFI_STATUS              - No LPC bridge is added.

--*/
{
  EFI_STATUS                Status;
  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;
  CHAR16                    *DevPathStr;

  DevicePath = NULL;
  Status = gBS->HandleProtocol (
                  DeviceHandle,
                  &gEfiDevicePathProtocolGuid,
                  (VOID*)&DevicePath
                  );
  if (EFI_ERROR (Status)) {
    return Status;
  }
  TempDevicePath = DevicePath;

  //
  // Register Keyboard
  //
  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);

  BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);

  //
  // Register COM1
  //
  DevicePath = TempDevicePath;
  gPnp16550ComPortDeviceNode.UID = 0;

  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);

  //
  // Print Device Path
  //
  DevPathStr = DevicePathToStr(DevicePath);
  if (DevPathStr != NULL) {
    DEBUG((
      EFI_D_INFO,
      "BdsPlatform.c+%d: COM%d DevPath: %s\n",
      __LINE__,
      gPnp16550ComPortDeviceNode.UID + 1,
      DevPathStr
      ));
    FreePool(DevPathStr);
  }

  BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
  BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
  BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);

  //
  // Register COM2
  //
  DevicePath = TempDevicePath;
  gPnp16550ComPortDeviceNode.UID = 1;

  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);

  //
  // Print Device Path
  //
  DevPathStr = DevicePathToStr(DevicePath);
  if (DevPathStr != NULL) {
    DEBUG((
      EFI_D_INFO,
      "BdsPlatform.c+%d: COM%d DevPath: %s\n",
      __LINE__,
      gPnp16550ComPortDeviceNode.UID + 1,
      DevPathStr
      ));
    FreePool(DevPathStr);
  }

//.........这里部分代码省略.........
开发者ID:jeppeter,项目名称:vbox,代码行数:101,代码来源:BdsPlatform.c


注:本文中的DevicePathToStr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。