nyx: part mgr: add eMMC partition manager

The eMMC partition manager allows user the following:
- Resize HOS USER partition
- Add and flash Linux partitions
- Add and flash Android partitions

It is hidden and is accessible by holding the `Partition SD Card` button for
5 seconds.
This commit is contained in:
CTCaer
2025-06-22 14:44:43 +03:00
committed by NaGa
parent a2d35fb90e
commit dd3b7d3ceb
4 changed files with 433 additions and 24 deletions

View File

@@ -1,7 +1,7 @@
/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs */
/* (C) ChaN, 2016 */
/* (C) CTCaer, 2018-2020 */
/* (C) CTCaer, 2018-2025 */
/*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be */
/* attached to the FatFs via a glue function rather than modifying it. */
@@ -21,8 +21,11 @@
static u32 sd_rsvd_sectors = 0;
static u32 ramdisk_sectors = 0;
static u32 emummc_sectors = 0;
static u32 bis_sectors = 0;
static u32 sfd_sectors = 0;
static bool bis_write_allowed = false;
static u32 cur_partition;
static void save_cur_partition(BYTE pdrv){
@@ -219,7 +222,11 @@ DRESULT disk_write (
res = sdmmc_storage_write(&emmc_storage, sector, count, (void*)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_BIS:
res = RES_WRPRT;
if (!bis_write_allowed){
res = RES_WRPRT;
break;
}
res = nx_emmc_bis_write(sector, count, (void *)buff) ? RES_OK : RES_ERROR;
break;
case DRIVE_EMU:
res = nx_emmc_bis_write(sector, count, (void *)buff) ? RES_OK : RES_ERROR;
@@ -252,8 +259,9 @@ DRESULT disk_ioctl (
{
DWORD *buf = (DWORD *)buff;
if (pdrv == DRIVE_SD)
switch (pdrv)
{
case DRIVE_SD:
switch (cmd)
{
case GET_SECTOR_COUNT:
@@ -263,9 +271,9 @@ DRESULT disk_ioctl (
*buf = 32768; // Align to 16MB.
break;
}
}
else if (pdrv == DRIVE_RAM)
{
break;
case DRIVE_RAM:
switch (cmd)
{
case GET_SECTOR_COUNT:
@@ -275,19 +283,33 @@ DRESULT disk_ioctl (
*buf = 2048; // Align to 1MB.
break;
}
}
else if (pdrv == DRIVE_EMU)
{
break;
case DRIVE_BIS:
switch (cmd)
{
case GET_SECTOR_COUNT:
*buf = bis_sectors;
break;
case GET_BLOCK_SIZE:
*buf = 32768; // Align to 16MB.
break;
}
break;
case DRIVE_EMU:
switch (cmd)
{
case GET_SECTOR_COUNT:
*buf = emummc_sectors;
break;
case GET_BLOCK_SIZE:
*buf = 32768; // Align to 16MB.
*buf = 16384; // Align to 8MB (With BOOT0/1 data will be at 16MB BU).
break;
}
}else if(pdrv == DRIVE_SFD){
break;
case DRIVE_SFD:
switch(cmd){
case GET_SECTOR_COUNT:
*buf = sfd_sectors;
@@ -296,8 +318,9 @@ DRESULT disk_ioctl (
*buf = 32768;
break;
}
}else // Catch all for unknown devices.
{
break;
default: // Catch all for unknown devices.
switch (cmd)
{
case CTRL_SYNC:
@@ -307,6 +330,7 @@ DRESULT disk_ioctl (
*buf = 0; // Zero value to force default or abort.
break;
}
break;
}
return RES_OK;
@@ -327,9 +351,15 @@ DRESULT disk_set_info (
case DRIVE_SD:
sd_rsvd_sectors = *buf;
break;
case DRIVE_RAM:
ramdisk_sectors = *buf;
break;
case DRIVE_BIS:
bis_sectors = *buf;
break;
case DRIVE_EMU:
emummc_sectors = *buf;
break;
@@ -338,6 +368,8 @@ DRESULT disk_set_info (
break;
}
}
else if (cmd == SET_WRITE_PROTECT && pdrv == DRIVE_BIS)
bis_write_allowed = *(bool *)buff;
return RES_OK;
}