diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-01-23 19:08:04 +0100 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-01-29 20:22:40 +0100 |
commit | 74a614d70ab3c8fe6bea24ad913c8b6eff609680 (patch) | |
tree | 0aaad7177930b4b0c3345f3ed638818e35956f88 /lib | |
parent | 472a716b8fdfd88a27cb675e4ea8e12cb4f79fc3 (diff) | |
download | u-boot-74a614d70ab3c8fe6bea24ad913c8b6eff609680.zip u-boot-74a614d70ab3c8fe6bea24ad913c8b6eff609680.tar.gz u-boot-74a614d70ab3c8fe6bea24ad913c8b6eff609680.tar.bz2 |
efi_selftest: test EFI_BLOCK_IO_PROTOCOL.Media->LastBlock
The field Media->LastBlock of the EFI_BLOCK_IO_PROTOCOL must be filled
with the index of the last logical block (LBA) for the block device that
our test driver provides.
After calling ConnectController() U-Boot exposes the block IO protocol for
the partition check that the value of Media->LastBlock equals the partition
size minus one.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/efi_selftest/efi_selftest_block_device.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c index 5eb297d..15f0375 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, |