iPXE
|
EFI block device protocols. More...
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <ipxe/refcnt.h>
#include <ipxe/list.h>
#include <ipxe/uri.h>
#include <ipxe/interface.h>
#include <ipxe/blockdev.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>
#include <ipxe/retry.h>
#include <ipxe/timer.h>
#include <ipxe/process.h>
#include <ipxe/sanboot.h>
#include <ipxe/iso9660.h>
#include <ipxe/acpi.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/BlockIo.h>
#include <ipxe/efi/Protocol/SimpleFileSystem.h>
#include <ipxe/efi/Protocol/AcpiTable.h>
#include <ipxe/efi/Guid/FileSystemInfo.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_strings.h>
#include <ipxe/efi/efi_snp.h>
#include <ipxe/efi/efi_path.h>
#include <ipxe/efi/efi_null.h>
#include <ipxe/efi/efi_block.h>
Go to the source code of this file.
Data Structures | |
struct | efi_block_data |
EFI SAN device private data. More... | |
struct | efi_acpi_table |
An installed ACPI table. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
EFI_REQUEST_PROTOCOL (EFI_ACPI_TABLE_PROTOCOL, &acpi) | |
static int | efi_block_rw (struct san_device *sandev, uint64_t lba, void *data, size_t len, int(*sandev_rw)(struct san_device *sandev, uint64_t lba, unsigned int count, userptr_t buffer)) |
Read from or write to EFI block device. More... | |
static EFI_STATUS EFIAPI | efi_block_io_reset (EFI_BLOCK_IO_PROTOCOL *block_io, BOOLEAN verify __unused) |
Reset EFI block device. More... | |
static EFI_STATUS EFIAPI | efi_block_io_read (EFI_BLOCK_IO_PROTOCOL *block_io, UINT32 media __unused, EFI_LBA lba, UINTN len, VOID *data) |
Read from EFI block device. More... | |
static EFI_STATUS EFIAPI | efi_block_io_write (EFI_BLOCK_IO_PROTOCOL *block_io, UINT32 media __unused, EFI_LBA lba, UINTN len, VOID *data) |
Write to EFI block device. More... | |
static EFI_STATUS EFIAPI | efi_block_io_flush (EFI_BLOCK_IO_PROTOCOL *block_io) |
Flush data to EFI block device. More... | |
static void | efi_block_connect (unsigned int drive, EFI_HANDLE handle) |
Connect all possible drivers to EFI block device. More... | |
static int | efi_block_hook (unsigned int drive, struct uri **uris, unsigned int count, unsigned int flags) |
Hook EFI block device. More... | |
static void | efi_block_unhook (unsigned int drive) |
Unhook EFI block device. More... | |
static | LIST_HEAD (efi_acpi_tables) |
List of installed ACPI tables. More... | |
static int | efi_block_install (struct acpi_header *hdr) |
Install ACPI table. More... | |
static int | efi_block_describe (void) |
Describe EFI block devices. More... | |
static int | efi_block_root (unsigned int drive, EFI_HANDLE handle, EFI_FILE_PROTOCOL **root) |
Open root directory within a filesystem. More... | |
static int | efi_block_filename (unsigned int drive, EFI_HANDLE handle, EFI_FILE_PROTOCOL *root, const char *filename) |
Check for existence of a file within a filesystem. More... | |
static int | efi_block_label (unsigned int drive, EFI_FILE_PROTOCOL *root, const char *label) |
Check for EFI block device filesystem label. More... | |
static int | efi_block_match (unsigned int drive, EFI_HANDLE handle, EFI_DEVICE_PATH_PROTOCOL *path, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath) |
Check EFI block device filesystem match. More... | |
static int | efi_block_scan (unsigned int drive, EFI_HANDLE handle, struct san_boot_config *config, EFI_DEVICE_PATH_PROTOCOL **fspath) |
Scan EFI block device for a matching filesystem. More... | |
static int | efi_block_exec (unsigned int drive, EFI_DEVICE_PATH_PROTOCOL *fspath, const char *filename) |
Boot from EFI block device filesystem boot image. More... | |
static int | efi_block_local (EFI_HANDLE handle) |
Check that EFI block device is eligible for a local virtual drive number. More... | |
static int | efi_block_boot (unsigned int drive, struct san_boot_config *config) |
Boot from EFI block device. More... | |
PROVIDE_SANBOOT (efi, san_hook, efi_block_hook) | |
PROVIDE_SANBOOT (efi, san_unhook, efi_block_unhook) | |
PROVIDE_SANBOOT (efi, san_describe, efi_block_describe) | |
PROVIDE_SANBOOT (efi, san_boot, efi_block_boot) | |
Variables | |
static EFI_ACPI_TABLE_PROTOCOL * | acpi |
ACPI table protocol protocol. More... | |
static wchar_t | efi_block_boot_filename [] = EFI_REMOVABLE_MEDIA_FILE_NAME |
Boot filename. More... | |
EFI block device protocols.
Definition in file efi_block.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
EFI_REQUEST_PROTOCOL | ( | EFI_ACPI_TABLE_PROTOCOL | , |
& | acpi | ||
) |
|
static |
Read from or write to EFI block device.
sandev | SAN device |
lba | Starting LBA |
data | Data buffer |
len | Size of buffer |
sandev_rw | SAN device read/write method |
rc | Return status code |
Definition at line 95 of file efi_block.c.
References block, count, data, DBGC, san_device::drive, EINVAL, lba, len, san_device::priv, rc, efi_block_data::sandev, sandev_rw(), strerror(), and virt_to_user().
Referenced by efi_block_io_read(), and efi_block_io_write().
|
static |
Reset EFI block device.
block_io | Block I/O protocol |
verify | Perform extended verification |
efirc | EFI status code |
Definition at line 130 of file efi_block.c.
References block, efi_block_data::block_io, container_of, DBGC2, san_device::drive, efi_snp_claim(), efi_snp_release(), EFIRC, rc, and sandev_reset().
Referenced by efi_block_hook().
|
static |
Read from EFI block device.
block_io | Block I/O protocol |
media | Media identifier |
lba | Starting LBA |
len | Size of buffer |
data | Data buffer |
efirc | EFI status code |
Definition at line 155 of file efi_block.c.
References block, efi_block_data::block_io, container_of, data, DBGC2, san_device::drive, efi_block_rw(), efi_snp_claim(), efi_snp_release(), EFIRC, lba, len, rc, and sandev_read().
Referenced by efi_block_hook().
|
static |
Write to EFI block device.
block_io | Block I/O protocol |
media | Media identifier |
lba | Starting LBA |
len | Size of buffer |
data | Data buffer |
efirc | EFI status code |
Definition at line 181 of file efi_block.c.
References block, efi_block_data::block_io, container_of, data, DBGC2, san_device::drive, efi_block_rw(), efi_snp_claim(), efi_snp_release(), EFIRC, lba, len, rc, and sandev_write().
Referenced by efi_block_hook().
|
static |
Flush data to EFI block device.
block_io | Block I/O protocol |
efirc | EFI status code |
Definition at line 203 of file efi_block.c.
References block, efi_block_data::block_io, container_of, DBGC2, and san_device::drive.
Referenced by efi_block_hook().
|
static |
Connect all possible drivers to EFI block device.
drive | Drive number |
handle | Block device handle |
Definition at line 220 of file efi_block.c.
References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::ConnectController, DBGC, DBGC2, DBGC2_EFI_PROTOCOLS, drive, EEFI, efi_systab, handle, NULL, rc, strerror(), and TRUE.
Referenced by efi_block_hook(), and efi_block_scan().
|
static |
Hook EFI block device.
drive | Drive number |
uris | List of URIs |
count | Number of URIs |
flags | Flags |
drive | Drive number, or negative error |
Definition at line 246 of file efi_block.c.
References san_device::active, alloc_sandev(), block_device_capacity::blksize, san_device::blksize_shift, block, san_path::block, block_device_capacity::blocks, EFI_SYSTEM_TABLE::BootServices, san_device::capacity, count, DBGC, DBGC2, drive, EEFI, efi_block_connect(), efi_block_io_flush(), efi_block_io_protocol_guid, EFI_BLOCK_IO_PROTOCOL_REVISION3, efi_block_io_read(), efi_block_io_reset(), efi_block_io_write(), efi_describe(), efi_device_path_protocol_guid, efi_devpath_text(), efi_handle_name(), efi_nullify_block(), efi_systab, ENODEV, ENOMEM, ENOTTY, flags, free, EFI_BOOT_SERVICES::InstallMultipleProtocolInterfaces, NULL, san_device::priv, rc, register_sandev(), efi_block_data::sandev, sandev_put(), strerror(), EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, and unregister_sandev().
|
static |
Unhook EFI block device.
drive | Drive number |
Definition at line 360 of file efi_block.c.
References block, EFI_SYSTEM_TABLE::BootServices, DBGC, drive, EEFI, efi_block_io_protocol_guid, efi_device_path_protocol_guid, efi_nullify_block(), efi_shutdown_in_progress, efi_systab, free, NULL, san_device::priv, efi_block_data::sandev, sandev_find(), sandev_put(), strerror(), EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, and unregister_sandev().
|
static |
List of installed ACPI tables.
|
static |
Install ACPI table.
hdr | ACPI description header |
rc | Return status code |
Definition at line 423 of file efi_block.c.
References acpi, acpi_fix_checksum(), acpi_name(), DBGC, DBGC2_HDA, EEFI, ENOMEM, free, hdr, _EFI_ACPI_TABLE_PROTOCOL::InstallAcpiTable, efi_acpi_table::key, le32_to_cpu, len, efi_acpi_table::list, list_add_tail, list_del, rc, strerror(), strncpy(), and zalloc().
Referenced by efi_block_describe().
|
static |
Describe EFI block devices.
rc | Return status code |
Definition at line 474 of file efi_block.c.
References acpi, acpi_install(), DBG, DBGC, EEFI, efi_block_install(), ENOTSUP, free, key, efi_acpi_table::key, efi_acpi_table::list, list_del, list_for_each_entry_safe, rc, strerror(), tmp, and _EFI_ACPI_TABLE_PROTOCOL::UninstallAcpiTable.
|
static |
Open root directory within a filesystem.
drive | Drive number |
handle | Filesystem handle |
root | Root directory file to fill in |
rc | Return status code |
Definition at line 519 of file efi_block.c.
References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, drive, EEFI, efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_simple_file_system_protocol_guid, efi_systab, fs, handle, EFI_BOOT_SERVICES::OpenProtocol, protocol, rc, root, strerror(), and u.
Referenced by efi_block_match().
|
static |
Check for existence of a file within a filesystem.
drive | Drive number |
handle | Filesystem handle |
root | Root directory |
filename | Filename (or NULL to use default) |
rc | Return status code |
Definition at line 566 of file efi_block.c.
References _EFI_FILE_PROTOCOL::Close, DBGC, drive, EEFI, efi_block_boot_filename, EFI_FILE_MODE_READ, efi_handle_name(), efi_snprintf(), handle, rc, root, strerror(), strlen(), and tmp.
Referenced by efi_block_match().
|
static |
Check for EFI block device filesystem label.
drive | Drive number |
root | Root directory |
label | Volume label |
rc | Return status code |
Definition at line 609 of file efi_block.c.
References asprintf(), DBGC, drive, EEFI, efi_file_system_info_id, ENOENT, ENOMEM, free, info, malloc(), NULL, rc, root, size, strcasecmp(), and strerror().
Referenced by efi_block_match().
|
static |
Check EFI block device filesystem match.
drive | Drive number |
handle | Filesystem handle |
path | Block device path |
config | Boot configuration parameters |
fspath | Filesystem device path to fill in |
rc | Return status code |
Definition at line 673 of file efi_block.c.
References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, DBGC2, drive, EEFI, efi_block_filename(), efi_block_label(), efi_block_root(), efi_device_path_protocol_guid, efi_devpath_text(), efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_path_guid(), efi_path_len(), efi_systab, ENOENT, ENOTTY, san_boot_config::extra, san_boot_config::filename, guid, handle, san_boot_config::label, memcmp(), EFI_BOOT_SERVICES::OpenProtocol, protocol, rc, root, strerror(), u, san_boot_config::uuid, and uuid_ntoa().
Referenced by efi_block_scan().
|
static |
Scan EFI block device for a matching filesystem.
drive | Drive number |
handle | Block device handle |
config | Boot configuration parameters |
fspath | Filesystem device path to fill in |
rc | Return status code |
Definition at line 775 of file efi_block.c.
References EFI_SYSTEM_TABLE::BootServices, ByProtocol, EFI_BOOT_SERVICES::CloseProtocol, count, DBGC, drive, EEFI, efi_block_connect(), efi_block_match(), efi_device_path_protocol_guid, efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_simple_file_system_protocol_guid, efi_systab, ENOENT, EFI_BOOT_SERVICES::FreePool, handle, EFI_BOOT_SERVICES::LocateHandleBuffer, NULL, EFI_BOOT_SERVICES::OpenProtocol, protocol, rc, strerror(), and u.
Referenced by efi_block_boot().
|
static |
Boot from EFI block device filesystem boot image.
drive | Drive number |
fspath | Filesystem device path |
filename | Filename (or NULL to use default) |
rc | Return status code |
Definition at line 840 of file efi_block.c.
References EFI_SYSTEM_TABLE::BootServices, DBGC, drive, EEFI, efi_block_boot_filename, efi_devpath_text(), efi_image_handle, efi_path_end(), efi_path_terminate(), EFI_SECURITY_VIOLATION, efi_sprintf, efi_systab, end, ENOMEM, FALSE, free, FILEPATH_DEVICE_PATH::Header, EFI_DEVICE_PATH_PROTOCOL::Length, EFI_BOOT_SERVICES::LoadImage, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, memcpy(), NULL, FILEPATH_DEVICE_PATH::PathName, rc, SIZE_OF_FILEPATH_DEVICE_PATH, EFI_BOOT_SERVICES::StartImage, strerror(), strlen(), EFI_DEVICE_PATH_PROTOCOL::SubType, EFI_DEVICE_PATH_PROTOCOL::Type, EFI_BOOT_SERVICES::UnloadImage, and zalloc().
Referenced by efi_block_boot().
|
static |
Check that EFI block device is eligible for a local virtual drive number.
handle | Block device handle |
rc | Return status code |
We assign virtual drive numbers for local (non-SAN) EFI block devices that represent complete disks, to provide roughly equivalent functionality to BIOS drive numbers.
Definition at line 923 of file efi_block.c.
References block, EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, DBGC2, EEFI, efi_block_io_protocol_guid, efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, ENOTTY, for_each_sandev, handle, EFI_BOOT_SERVICES::OpenProtocol, san_device::priv, protocol, rc, strerror(), and u.
Referenced by efi_block_boot().
|
static |
Boot from EFI block device.
drive | Drive number |
config | Boot configuration parameters |
rc | Return status code |
Definition at line 979 of file efi_block.c.
References block, EFI_SYSTEM_TABLE::BootServices, ByProtocol, count, DBGC, drive, san_device::drive, EEFI, efi_block_exec(), efi_block_io_protocol_guid, efi_block_local(), efi_block_scan(), efi_driver_reconnect_all(), efi_handle_name(), efi_snp_claim(), efi_snp_release(), efi_systab, ENOENT, san_boot_config::filename, EFI_BOOT_SERVICES::FreePool, handle, index, EFI_BOOT_SERVICES::LocateHandleBuffer, NULL, san_device::priv, rc, SAN_DEFAULT_DRIVE, efi_block_data::sandev, sandev_next(), and strerror().
PROVIDE_SANBOOT | ( | efi | , |
san_hook | , | ||
efi_block_hook | |||
) |
PROVIDE_SANBOOT | ( | efi | , |
san_unhook | , | ||
efi_block_unhook | |||
) |
PROVIDE_SANBOOT | ( | efi | , |
san_describe | , | ||
efi_block_describe | |||
) |
PROVIDE_SANBOOT | ( | efi | , |
san_boot | , | ||
efi_block_boot | |||
) |
|
static |
ACPI table protocol protocol.
Definition at line 65 of file efi_block.c.
Referenced by acpi_find_via_rsdt(), acpi_fix_checksum(), acpi_settings_fetch(), acpi_zsdt(), dummy_install(), ecam_find(), efi_block_describe(), efi_block_install(), efipci_discover_one(), ibft_install(), int13_install(), nii_pci_open(), and typeof().
|
static |
Boot filename.
Definition at line 69 of file efi_block.c.
Referenced by efi_block_exec(), and efi_block_filename().