Support for miltiple configs per RBF.

This commit is contained in:
sorgelig
2018-04-01 06:17:08 +08:00
parent 9f48518615
commit 96e3d58b31
6 changed files with 92 additions and 39 deletions

View File

@@ -543,7 +543,7 @@ void AdjustDirectory(char *path)
}
}
int ScanDirectory(const char* path, int mode, const char *extension, int options)
int ScanDirectory(const char* path, int mode, const char *extension, int options, const char *prefix)
{
int has_trd = 0;
const char *ext = extension;
@@ -600,6 +600,9 @@ int ScanDirectory(const char* path, int mode, const char *extension, int options
if (!strcasecmp(de->d_name, "boot.rom")) continue;
if (!strcasecmp(de->d_name, "boot.vhd")) continue;
//check the prefix if given
if (prefix && strncasecmp(prefix, de->d_name, strlen(prefix))) continue;
if (extlen > 0)
{
int len = strlen(de->d_name);
@@ -646,6 +649,7 @@ int ScanDirectory(const char* path, int mode, const char *extension, int options
if (!nDirEntries) return 0;
qsort(DirItem, nDirEntries, sizeof(struct dirent), de_cmp);
return nDirEntries;
}
else
{

View File

@@ -33,6 +33,8 @@ extern int iFirstEntry;
#define SCAN_DIR 1 // include subdirectories
#define SCAN_UMOUNT 2 // include subdirectories
#define SCAN_SDIR 4 // include subdirectories
#define SCAN_ROOT 8
#define SCAN_HERE 16
void FindStorage();
int getStorage(int from_setting);
@@ -69,7 +71,7 @@ int FileSaveConfig(const char *name, void *pBuffer, int size);
int FileLoadConfig(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
void AdjustDirectory(char *path);
int ScanDirectory(const char* path, int mode, const char *extension, int options);
int ScanDirectory(const char* path, int mode, const char *extension, int options, const char *prefix = NULL);
const char *getStorageDir(int dev);
const char *getRootDir();

View File

@@ -405,7 +405,7 @@ static void do_bridge(uint32_t enable)
}
}
static int make_env(const char *name, char *cfg)
static int make_env(const char *name, const char *cfg)
{
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) return -1;
@@ -443,21 +443,16 @@ static int make_env(const char *name, char *cfg)
return 0;
}
int fpga_load_rbf(const char *name)
int fpga_load_rbf(const char *name, const char *cfg)
{
static char path[1024];
int ret = 0;
if (!getStorage(0)) // multiboot is only on SD card.
if(cfg)
{
strcpy(path, name);
strcpy(path + strlen(path) - 3, "txt");
if (FileLoad(path, 0, 0))
{
make_env(name, path);
do_bridge(0);
reboot(0);
}
make_env(name, cfg);
do_bridge(0);
reboot(0);
}
printf("Loading RBF: %s\n", name);

View File

@@ -28,7 +28,7 @@ int is_fpga_ready(int quick);
int fpga_get_fio_size();
int fpga_get_io_version();
int fpga_load_rbf(const char *name);
int fpga_load_rbf(const char *name, const char *cfg = NULL);
void reboot(int cold);
void app_restart();

View File

@@ -98,7 +98,9 @@ enum MENU
MENU_SAVECONFIG_2,
MENU_FIRMWARE1,
MENU_FIRMWARE2,
MENU_FIRMWARE_CORE_FILE_SELECTED,
MENU_FIRMWARE_CORE_FILE_SELECTED1,
MENU_FIRMWARE_CORE_FILE_SELECTED2,
MENU_FIRMWARE_CORE_FILE_CANCELED,
MENU_ERROR,
MENU_INFO,
MENU_STORAGE,
@@ -218,7 +220,10 @@ char* GetExt(char *ext)
return extlist + 1;
}
char SelectedPath[1024] = { 0 };
static char SelectedRBF[1024] = { 0 };
static char SelectedDir[1024] = { 0 };
static char SelectedPath[1024] = { 0 };
int changeDir(char *dir)
{
char curdir[128];
@@ -265,18 +270,18 @@ int changeDir(char *dir)
return 1;
}
static void SelectFile(const char* pFileExt, unsigned char Options, unsigned char MenuSelect, unsigned char MenuCancel, char chdir)
static void SelectFile(const char* pFileExt, unsigned char Options, unsigned char MenuSelect, unsigned char MenuCancel, char chdir, char *prefix = NULL)
{
// this function displays file selection menu
printf("%s - %s\n", pFileExt, fs_pFileExt);
AdjustDirectory(SelectedPath);
if (strncmp(pFileExt, fs_pFileExt, 12) != 0 || !strlen(SelectedPath)) // check desired file extension
if (strncmp(pFileExt, fs_pFileExt, 12) != 0 || !strlen(SelectedPath) || (Options & (SCAN_ROOT|SCAN_HERE))) // check desired file extension
{ // if different from the current one go to the root directory and init entry buffer
SelectedPath[0] = 0;
if(!(Options & SCAN_HERE)) SelectedPath[0] = 0;
if(((user_io_core_type() == CORE_TYPE_8BIT) || (user_io_core_type() == CORE_TYPE_MINIMIG2) || (user_io_core_type() == CORE_TYPE_ARCHIE)) && chdir)
if(((user_io_core_type() == CORE_TYPE_8BIT) || (user_io_core_type() == CORE_TYPE_MINIMIG2) || (user_io_core_type() == CORE_TYPE_ARCHIE)) && chdir && !(Options & (SCAN_ROOT|SCAN_HERE)))
{
strcpy(SelectedPath, (user_io_core_type() == CORE_TYPE_MINIMIG2) ? "Amiga" : is_archie() ? "Archie" : user_io_get_core_name());
ScanDirectory(SelectedPath, SCAN_INIT, pFileExt, Options);
@@ -289,6 +294,7 @@ static void SelectFile(const char* pFileExt, unsigned char Options, unsigned cha
else
{
ScanDirectory(SelectedPath, SCAN_INIT, pFileExt, Options);
Options &= ~(SCAN_ROOT|SCAN_HERE);
}
}
@@ -661,6 +667,8 @@ void HandleUI(void)
char usb_id[64];
static char cp_MenuCancel;
// get user control codes
uint32_t c = menu_key_get();
@@ -801,7 +809,7 @@ void HandleUI(void)
if (menu)
{
if (get_key_mod() & (LALT|RALT)) //Alt+Menu
SelectFile("RBF", SCAN_SDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_NONE1, 0);
SelectFile("RBF", SCAN_SDIR | SCAN_ROOT, MENU_FIRMWARE_CORE_FILE_SELECTED1, MENU_NONE1, 0);
else if (user_io_core_type() == CORE_TYPE_MINIMIG2)
menustate = MENU_MAIN1;
else if (user_io_core_type() == CORE_TYPE_MIST)
@@ -813,7 +821,7 @@ void HandleUI(void)
if (is_menu_core())
{
OsdCoreNameSet("");
SelectFile("RBF", SCAN_SDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0);
SelectFile("RBF", SCAN_SDIR | SCAN_ROOT, MENU_FIRMWARE_CORE_FILE_SELECTED1, MENU_FIRMWARE1, 0);
}
else
{
@@ -1264,7 +1272,7 @@ void HandleUI(void)
switch (menusub)
{
case 0:
SelectFile("RBF", SCAN_SDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_8BIT_SYSTEM1, 0);
SelectFile("RBF", SCAN_SDIR | SCAN_ROOT, MENU_FIRMWARE_CORE_FILE_SELECTED1, MENU_8BIT_SYSTEM1, 0);
menusub = 0;
break;
case 1:
@@ -2249,7 +2257,12 @@ void HandleUI(void)
{
if (nDirEntries)
{
if(strlen(SelectedPath)) strcat(SelectedPath, "/");
SelectedDir[0] = 0;
if (strlen(SelectedPath))
{
strcpy(SelectedDir, SelectedPath);
strcat(SelectedPath, "/");
}
strcat(SelectedPath, DirItem[iSelectedEntry].d_name);
menustate = fs_MenuSelect;
@@ -3255,7 +3268,7 @@ void HandleUI(void)
}
else if (select) {
if (menusub == 0) {
SelectFile("RBF", SCAN_SDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0);
SelectFile("RBF", SCAN_SDIR | SCAN_ROOT, MENU_FIRMWARE_CORE_FILE_SELECTED1, MENU_FIRMWARE1, 0);
}
else if (menusub == 1) {
switch (user_io_core_type()) {
@@ -3276,15 +3289,54 @@ void HandleUI(void)
}
break;
case MENU_FIRMWARE_CORE_FILE_SELECTED:
case MENU_FIRMWARE_CORE_FILE_SELECTED1:
menustate = MENU_NONE1;
strcpy(SelectedRBF, SelectedPath);
if (!getStorage(0)) // multiboot is only on SD card.
{
SelectedPath[strlen(SelectedPath) - 4] = 0;
int off = strlen(SelectedDir);
if (off) off++;
int fnum = ScanDirectory(SelectedDir, SCAN_INIT, "TXT", 0, SelectedPath + off);
if (fnum)
{
if (fnum == 1)
{
//Check if the only choice is <core>.txt
strcat(SelectedPath, ".txt");
if (FileLoad(SelectedPath, 0, 0))
{
menustate = MENU_FIRMWARE_CORE_FILE_SELECTED2;
break;
}
}
strcpy(SelectedPath, SelectedRBF);
AdjustDirectory(SelectedPath);
cp_MenuCancel = fs_MenuCancel;
fs_Options = 0;
fs_MenuSelect = MENU_FIRMWARE_CORE_FILE_SELECTED2;
fs_MenuCancel = MENU_FIRMWARE_CORE_FILE_CANCELED;
menustate = MENU_FILE_SELECT1;
break;
}
}
// close OSD now as the new core may not even have one
OsdDisable();
fpga_load_rbf(SelectedRBF);
break;
fpga_load_rbf(SelectedPath);
case MENU_FIRMWARE_CORE_FILE_SELECTED2:
OsdDisable();
fpga_load_rbf(SelectedRBF, SelectedPath);
menustate = MENU_NONE1;
break;
case MENU_FIRMWARE_CORE_FILE_CANCELED:
SelectFile("RBF", SCAN_SDIR | SCAN_HERE, MENU_FIRMWARE_CORE_FILE_SELECTED1, cp_MenuCancel, 0);
break;
/******************************************************************/
/* we should never come here */
/******************************************************************/

View File

@@ -1956,17 +1956,17 @@ struct vmode_t
vmode_t vmodes[] =
{
{ { 1280, 110, 40, 220, 720, 5, 5, 20 }, 74.25 },
{ { 1024, 24, 136, 160, 768, 3, 6, 29 }, 65 },
{ { 720, 16, 62, 60, 480, 9, 6, 30 }, 27 },
{ { 720, 12, 64, 68, 576, 5, 5, 39 }, 27 },
{ { 1280, 48, 112, 248, 1024, 1, 3, 38 }, 108 },
{ { 800, 40, 128, 88, 600, 1, 4, 23 }, 40 },
{ { 640, 16, 96, 48, 480, 10, 2, 33 }, 25.175 },
{ { 1280, 440, 40, 220, 720, 5, 5, 20 }, 74.25 },
{ { 1920, 88, 44, 148, 1080, 4, 5, 36 }, 148.5 },
{ { 1920, 528, 44, 148, 1080, 4, 5, 36 }, 148.5 },
{ { 1366, 70, 143, 213, 768, 3, 3, 24 }, 85.5 },
{ { 1280, 110, 40, 220, 720, 5, 5, 20 }, 74.25 }, //0
{ { 1024, 24, 136, 160, 768, 3, 6, 29 }, 65 }, //1
{ { 720, 16, 62, 60, 480, 9, 6, 30 }, 27 }, //2
{ { 720, 12, 64, 68, 576, 5, 5, 39 }, 27 }, //3
{ { 1280, 48, 112, 248, 1024, 1, 3, 38 }, 108 }, //4
{ { 800, 40, 128, 88, 600, 1, 4, 23 }, 40 }, //5
{ { 640, 16, 96, 48, 480, 10, 2, 33 }, 25.175 }, //6
{ { 1280, 440, 40, 220, 720, 5, 5, 20 }, 74.25 }, //7
{ { 1920, 88, 44, 148, 1080, 4, 5, 36 }, 148.5 }, //8
{ { 1920, 528, 44, 148, 1080, 4, 5, 36 }, 148.5 }, //9
{ { 1366, 70, 143, 213, 768, 3, 3, 24 }, 85.5 }, //10
};
#define VMODES_NUM (sizeof(vmodes) / sizeof(vmodes[0]))