diff --git a/bdk/libs/fatfs/diskio.h b/bdk/libs/fatfs/diskio.h index b5299c65..72c9fb55 100644 --- a/bdk/libs/fatfs/diskio.h +++ b/bdk/libs/fatfs/diskio.h @@ -10,6 +10,7 @@ extern "C" { #endif #include +#include /* Status of Disk Functions */ typedef BYTE DSTATUS; @@ -23,14 +24,6 @@ typedef enum { RES_PARERR /* 4: Invalid Parameter */ } DRESULT; -typedef enum { - DRIVE_SD = 0, - DRIVE_RAM = 1, - DRIVE_EMMC = 2, - DRIVE_BIS = 3, - DRIVE_EMU = 4 -} DDRIVE; - /*---------------------------------------*/ /* Prototypes for disk control functions */ diff --git a/bootloader/libs/fatfs/diskio.c b/bootloader/libs/fatfs/diskio.c index 01738e89..d4e84537 100644 --- a/bootloader/libs/fatfs/diskio.c +++ b/bootloader/libs/fatfs/diskio.c @@ -14,18 +14,18 @@ #include #include /* FatFs lower layer API */ -#include "ffconf.h" +#include static bool ensure_partition(BYTE pdrv){ u8 part; switch(pdrv){ - case FF_DEV_SD: + case DRIVE_SD: return true; - case FF_DEV_BOOT1: - case FF_DEV_BOOT1_1MB: + case DRIVE_BOOT1: + case DRIVE_BOOT1_1MB: part = EMMC_BOOT1; break; - case FF_DEV_GPP: + case DRIVE_EMMC: part = EMMC_GPP; break; default: @@ -72,13 +72,13 @@ DRESULT disk_read ( sdmmc_storage_t *storage = &sd_storage; u32 actual_sector = sector; switch(pdrv){ - case FF_DEV_SD: + case DRIVE_SD: break; - case FF_DEV_BOOT1: - case FF_DEV_GPP: + case DRIVE_BOOT1: + case DRIVE_EMMC: storage = &emmc_storage; break; - case FF_DEV_BOOT1_1MB: + case DRIVE_BOOT1_1MB: storage = &emmc_storage; actual_sector = sector + (0x100000 / 512); break; @@ -105,13 +105,13 @@ DRESULT disk_write ( sdmmc_storage_t *storage = &sd_storage; u32 actual_sector = sector; switch(pdrv){ - case FF_DEV_SD: + case DRIVE_SD: break; - case FF_DEV_BOOT1: - case FF_DEV_GPP: + case DRIVE_BOOT1: + case DRIVE_EMMC: storage = &emmc_storage; break; - case FF_DEV_BOOT1_1MB: + case DRIVE_BOOT1_1MB: storage = &emmc_storage; actual_sector = sector + (0x100000 / 512); break; diff --git a/bootloader/libs/fatfs/ffconf.h b/bootloader/libs/fatfs/ffconf.h index 3efdad30..4d8c3ad9 100644 --- a/bootloader/libs/fatfs/ffconf.h +++ b/bootloader/libs/fatfs/ffconf.h @@ -300,9 +300,12 @@ / SemaphoreHandle_t and etc. A header file for O/S definitions needs to be / included somewhere in the scope of ff.h. */ -#define FF_DEV_BOOT1 1 -#define FF_DEV_BOOT1_1MB 2 -#define FF_DEV_SD 0 -#define FF_DEV_GPP 3 + +typedef enum { + DRIVE_SD = 0, + DRIVE_BOOT1 = 1, + DRIVE_BOOT1_1MB = 2, + DRIVE_EMMC = 3, +} DDRIVE; /*--- End of configuration options ---*/ diff --git a/bootloader/storage/boot_storage.c b/bootloader/storage/boot_storage.c index 6c67524f..4e065fdd 100644 --- a/bootloader/storage/boot_storage.c +++ b/bootloader/storage/boot_storage.c @@ -1,6 +1,6 @@ #include "boot_storage.h" #include -#include "../libs/fatfs/ffconf.h" +#include #include #include #include @@ -11,10 +11,10 @@ static FATFS boot_storage_fs; static BYTE drive = -1; static const char* drive_base_paths[] = { - [FF_DEV_SD] = XSTR(FF_DEV_SD) ":", - [FF_DEV_BOOT1] = XSTR(FF_DEV_BOOT1) ":", - [FF_DEV_BOOT1_1MB] = XSTR(FF_DEV_BOOT1_1MB) ":", - [FF_DEV_GPP] = XSTR(FF_DEV_GPP) ":", + [DRIVE_SD] = XSTR(DRIVE_SD) ":", + [DRIVE_BOOT1] = XSTR(DRIVE_BOOT1) ":", + [DRIVE_BOOT1_1MB] = XSTR(DRIVE_BOOT1_1MB) ":", + [DRIVE_EMMC] = XSTR(DRIVE_EMMC) ":", }; static bool _is_eligible(){ @@ -30,11 +30,11 @@ bool boot_storage_get_mounted(){ bool boot_storage_get_initialized(){ switch(drive){ - case FF_DEV_BOOT1: - case FF_DEV_GPP: - case FF_DEV_BOOT1_1MB: + case DRIVE_BOOT1: + case DRIVE_EMMC: + case DRIVE_BOOT1_1MB: return emmc_get_initialized(); - case FF_DEV_SD: + case DRIVE_SD: return sd_get_card_initialized(); } return false; @@ -42,11 +42,11 @@ bool boot_storage_get_initialized(){ static bool _boot_storage_initialize(){ switch(drive){ - case FF_DEV_BOOT1: - case FF_DEV_GPP: - case FF_DEV_BOOT1_1MB: + case DRIVE_BOOT1: + case DRIVE_EMMC: + case DRIVE_BOOT1_1MB: return emmc_initialize(false); - case FF_DEV_SD: + case DRIVE_SD: return sd_initialize(false); } return false; @@ -54,7 +54,7 @@ static bool _boot_storage_initialize(){ static void _boot_storage_end(bool deinit){ if(boot_storage_get_mounted()){ - if(drive == FF_DEV_SD){ + if(drive == DRIVE_SD){ sd_unmount(); }else{ f_mount(NULL, drive_base_paths[drive], false); @@ -62,7 +62,7 @@ static void _boot_storage_end(bool deinit){ drive = DEV_INVALID; } if(deinit){ - if(drive == FF_DEV_SD){ + if(drive == DRIVE_SD){ sd_end(); }else{ emmc_end(); @@ -87,7 +87,7 @@ static bool _boot_storage_mount(){ goto emmc_init_fail; } - static const BYTE emmc_drives[] = {FF_DEV_BOOT1_1MB, FF_DEV_BOOT1, FF_DEV_GPP}; + static const BYTE emmc_drives[] = {DRIVE_BOOT1_1MB, DRIVE_BOOT1, DRIVE_EMMC}; for(BYTE i = 0; i < ARRAY_SIZE(emmc_drives); i++){ res = f_mount(&boot_storage_fs, drive_base_paths[i], true); @@ -121,10 +121,10 @@ emmc_init_fail: goto out; } - res = f_chdrive(drive_base_paths[FF_DEV_SD]); + res = f_chdrive(drive_base_paths[DRIVE_SD]); if(res == FR_OK && _is_eligible()){ - drive = FF_DEV_SD; + drive = DRIVE_SD; return true; }