[PATCH 16/26] efi: loader: disk: report block device size in Block I/O
Ahmad Fatoum
a.fatoum at barebox.org
Fri Jun 26 01:42:27 PDT 2026
So far we hardcoded 512 byte block sizes in what we report. This didn't
matter much as we didn't support other block sizes, but when we do soon,
we either need to do block size translation or pass devices as-is.
We will go with the second option, so drop the hardcoded 512-byte sector
sizes.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
efi/loader/protocols/disk.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/efi/loader/protocols/disk.c b/efi/loader/protocols/disk.c
index 5494f9197cb4..5c5447acca20 100644
--- a/efi/loader/protocols/disk.c
+++ b/efi/loader/protocols/disk.c
@@ -22,6 +22,7 @@
#include <malloc.h>
#include <bootsource.h>
#include <block.h>
+#include <disks.h>
#include <fs.h>
const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID;
@@ -194,6 +195,7 @@ static efi_status_t efi_disk_add_cdev(efi_handle_t parent,
struct efi_disk_obj *diskobj;
struct efi_object *handle;
const efi_guid_t *esp_guid = NULL;
+ unsigned int blockbits = cdev_blockbits(cdev);
int score = 0;
efi_status_t ret;
@@ -251,9 +253,9 @@ static efi_status_t efi_disk_add_cdev(efi_handle_t parent,
diskobj->media.removable_media = removable;
diskobj->media.media_present = true;
diskobj->media.read_only = cdev->flags & DEVFS_PARTITION_READONLY;
- diskobj->media.block_size = 512;
- diskobj->media.io_align = 512;
- diskobj->media.last_block = cdev->size / diskobj->media.block_size - 1;
+ diskobj->media.block_size = diskobj->media.io_align = 1u << blockbits;
+ diskobj->media.last_block = (cdev->size >> blockbits) - 1;
+ diskobj->blockbits = blockbits;
diskobj->ops = block_io_disk_template;
diskobj->ops.media = &diskobj->media;
@@ -380,7 +382,6 @@ static efi_status_t efi_disk_register(void *data)
return ret;
}
- disk->blockbits = bdev->blockbits;
ndisks++;
/* Partitions show up as block devices in EFI */
--
2.47.3
More information about the barebox
mailing list