diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/binman.c | 2 | ||||
-rw-r--r-- | lib/efi_loader/efi_disk.c | 10 | ||||
-rw-r--r-- | lib/efi_loader/efi_setup.c | 4 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_block_device.c | 21 |
4 files changed, 28 insertions, 9 deletions
diff --git a/lib/binman.c b/lib/binman.c index f415df3054..6040ec8924 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -145,6 +145,8 @@ int binman_init(void) if (ret) return log_msg_ret("node", -ENOENT); binman_set_rom_offset(ROM_OFFSET_NONE); + log_debug("binman: Selected image node '%s'\n", + ofnode_get_name(binman->image)); return 0; } diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index c0804effde..d0aad0252a 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -142,8 +142,9 @@ static efi_status_t EFIAPI efi_disk_read_blocks(struct efi_block_io *this, return EFI_MEDIA_CHANGED; if (!this->media->media_present) return EFI_NO_MEDIA; - /* media->io_align is a power of 2 */ - if ((uintptr_t)buffer & (this->media->io_align - 1)) + /* media->io_align is a power of 2 or 0 */ + if (this->media->io_align && + (uintptr_t)buffer & (this->media->io_align - 1)) return EFI_INVALID_PARAMETER; if (lba * this->media->block_size + buffer_size > this->media->last_block * this->media->block_size) @@ -209,8 +210,9 @@ static efi_status_t EFIAPI efi_disk_write_blocks(struct efi_block_io *this, return EFI_MEDIA_CHANGED; if (!this->media->media_present) return EFI_NO_MEDIA; - /* media->io_align is a power of 2 */ - if ((uintptr_t)buffer & (this->media->io_align - 1)) + /* media->io_align is a power of 2 or 0 */ + if (this->media->io_align && + (uintptr_t)buffer & (this->media->io_align - 1)) return EFI_INVALID_PARAMETER; if (lba * this->media->block_size + buffer_size > this->media->last_block * this->media->block_size) diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index 5800cbf6d4..b1c5125032 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -6,7 +6,6 @@ */ #include <common.h> -#include <bootm.h> #include <efi_loader.h> #include <efi_variable.h> @@ -188,9 +187,6 @@ efi_status_t efi_init_obj_list(void) /* Allow unaligned memory access */ allow_unaligned(); - /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ - switch_to_non_secure_mode(); - /* Initialize root node */ ret = efi_root_node_register(); if (ret != EFI_SUCCESS) diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c index 5eb297d285..15f03751ac 100644 --- a/lib/efi_selftest/efi_selftest_block_device.c +++ b/lib/efi_selftest/efi_selftest_block_device.c @@ -194,7 +194,7 @@ static int setup(const efi_handle_t handle, decompress(&image); block_io.media->block_size = 1 << LB_BLOCK_SIZE; - block_io.media->last_block = img.length >> LB_BLOCK_SIZE; + block_io.media->last_block = (img.length >> LB_BLOCK_SIZE) - 1; ret = boottime->install_protocol_interface( &disk_handle, &block_io_protocol_guid, @@ -301,6 +301,7 @@ static int execute(void) efi_handle_t *handles; efi_handle_t handle_partition = NULL; struct efi_device_path *dp_partition; + struct efi_block_io *block_io_protocol; struct efi_simple_file_system_protocol *file_system; struct efi_file_handle *root, *file; struct { @@ -309,6 +310,7 @@ static int execute(void) } system_info; efi_uintn_t buf_size; char buf[16] __aligned(ARCH_DMA_MINALIGN); + u32 part1_size; u64 pos; /* Connect controller to virtual disk */ @@ -353,6 +355,23 @@ static int execute(void) return EFI_ST_FAILURE; } + /* Open the block_io_protocol */ + ret = boottime->open_protocol(handle_partition, + &block_io_protocol_guid, + (void **)&block_io_protocol, NULL, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to open block IO protocol\n"); + return EFI_ST_FAILURE; + } + /* Get size of first MBR partition */ + memcpy(&part1_size, image + 0x1ca, sizeof(u32)); + if (block_io_protocol->media->last_block != part1_size - 1) { + efi_st_error("Last LBA of partition %x, expected %x\n", + (unsigned int)block_io_protocol->media->last_block, + part1_size - 1); + return EFI_ST_FAILURE; + } /* Open the simple file system protocol */ ret = boottime->open_protocol(handle_partition, &guid_simple_file_system_protocol, |