Changeset View
Changeset View
Standalone View
Standalone View
head/stand/efi/gptboot/proto.c
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | |||||
probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath) | probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath) | ||||
{ | { | ||||
dev_info_t *devinfo; | dev_info_t *devinfo; | ||||
EFI_BLOCK_IO *blkio; | EFI_BLOCK_IO *blkio; | ||||
EFI_DEVICE_PATH *devpath, *trimmed = NULL; | EFI_DEVICE_PATH *devpath, *trimmed = NULL; | ||||
EFI_STATUS status; | EFI_STATUS status; | ||||
/* Figure out if we're dealing with an actual partition. */ | /* Figure out if we're dealing with an actual partition. */ | ||||
status = BS->HandleProtocol(h, &DevicePathGUID, (void **)&devpath); | status = OpenProtocolByHandle(h, &DevicePathGUID, (void **)&devpath); | ||||
if (status != EFI_SUCCESS) | if (status != EFI_SUCCESS) | ||||
return; | return; | ||||
#ifdef EFI_DEBUG | #ifdef EFI_DEBUG | ||||
{ | { | ||||
CHAR16 *text = efi_devpath_name(devpath); | CHAR16 *text = efi_devpath_name(devpath); | ||||
DPRINTF("probing: %S ", text); | DPRINTF("probing: %S ", text); | ||||
efi_free_devpath_name(text); | efi_free_devpath_name(text); | ||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* The RAW device is the same as the imgpath with the last | * The RAW device is the same as the imgpath with the last | ||||
* MEDIA_DEVICE bit trimmed off. imgpath will end with the | * MEDIA_DEVICE bit trimmed off. imgpath will end with the | ||||
* MEDIA_DEVICE for the ESP we booted off of. | * MEDIA_DEVICE for the ESP we booted off of. | ||||
*/ | */ | ||||
if (!efi_devpath_same_disk(imgpath, devpath)) { | if (!efi_devpath_same_disk(imgpath, devpath)) { | ||||
trimmed = efi_devpath_trim(imgpath); | trimmed = efi_devpath_trim(imgpath); | ||||
if (!efi_devpath_match(trimmed, devpath)) { | if (!efi_devpath_match(trimmed, devpath)) { | ||||
free(trimmed); | free(trimmed); | ||||
DPRINTF("Not the same disk\n"); | DPRINTF("Not the same disk\n"); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
status = BS->HandleProtocol(h, &BlockIoProtocolGUID, (void **)&blkio); | status = OpenProtocolByHandle(h, &BlockIoProtocolGUID, (void **)&blkio); | ||||
if (status != EFI_SUCCESS) { | if (status != EFI_SUCCESS) { | ||||
DPRINTF("Can't get the block I/O protocol block\n"); | DPRINTF("Can't get the block I/O protocol block\n"); | ||||
return; | return; | ||||
} | } | ||||
devinfo = malloc(sizeof(*devinfo)); | devinfo = malloc(sizeof(*devinfo)); | ||||
if (devinfo == NULL) { | if (devinfo == NULL) { | ||||
DPRINTF("Failed to allocate devinfo\n"); | DPRINTF("Failed to allocate devinfo\n"); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |