bdk: ums: allow real sizes for boot partitions

Since that's eMMC, do not clamp the size to 4MB.
That doesn't affect anything other than allowing the host to see the whole
physical partition .
This commit is contained in:
CTCaer 2024-05-19 10:57:20 +03:00
parent 927489d2da
commit a070d2e394

View file

@ -4,7 +4,7 @@
* Copyright (c) 2003-2008 Alan Stern * Copyright (c) 2003-2008 Alan Stern
* Copyright (c) 2009 Samsung Electronics * Copyright (c) 2009 Samsung Electronics
* Author: Michal Nazarewicz <m.nazarewicz@samsung.com> * Author: Michal Nazarewicz <m.nazarewicz@samsung.com>
* Copyright (c) 2019-2023 CTCaer * Copyright (c) 2019-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -1845,6 +1845,7 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
ums.lun.ro = usbs->ro; ums.lun.ro = usbs->ro;
ums.lun.type = usbs->type; ums.lun.type = usbs->type;
ums.lun.partition = usbs->partition; ums.lun.partition = usbs->partition;
ums.lun.num_sectors = usbs->sectors;
ums.lun.offset = usbs->offset; ums.lun.offset = usbs->offset;
ums.lun.removable = 1; // Always removable to force OSes to use prevent media removal. ums.lun.removable = 1; // Always removable to force OSes to use prevent media removal.
ums.lun.unit_attention_data = SS_RESET_OCCURRED; ums.lun.unit_attention_data = SS_RESET_OCCURRED;
@ -1898,10 +1899,14 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
ums.set_text(ums.label, "#C7EA46 Status:# Started UMS"); ums.set_text(ums.label, "#C7EA46 Status:# Started UMS");
if (usbs->sectors) // If partition sectors are not set get them from hardware.
ums.lun.num_sectors = usbs->sectors; if (!ums.lun.num_sectors)
{
if (usbs->type == MMC_EMMC && (ums.lun.partition - 1)) // eMMC BOOT0/1.
ums.lun.num_sectors = emmc_storage.ext_csd.boot_mult << 8;
else else
ums.lun.num_sectors = ums.lun.storage->sec_cnt; ums.lun.num_sectors = ums.lun.storage->sec_cnt; // eMMC GPP or SD.
}
do do
{ {