Add INI option Main for custom binary.

This commit is contained in:
Sorgelig
2024-03-25 23:36:19 +08:00
parent 4b304b4941
commit e61b111858
6 changed files with 18 additions and 5 deletions

View File

@@ -361,3 +361,6 @@ controller_unique_mapping=0
; code if less than osd_lock_time seconds have passed since the OSD was closed.
; set to 0 for manual lock from OSD
osd_lock_time=5
; use custom main for specific core. This option should be used only inside specific core.
;main=some_binary_file

View File

@@ -130,6 +130,7 @@ static const ini_var_t ini_vars[] =
{ "OSD_LOCK", (void*)(&(cfg.osd_lock)), STRING, 0, sizeof(cfg.osd_lock) - 1 },
{ "OSD_LOCK_TIME", (void*)(&(cfg.osd_lock_time)), UINT16, 0, 60 },
{ "DEBUG", (void *)(&(cfg.debug)), UINT8, 0, 1 },
{ "MAIN", (void*)(&(cfg.main)), STRING, 0, sizeof(cfg.main) - 1 },
};
static const int nvars = (int)(sizeof(ini_vars) / sizeof(ini_var_t));
@@ -555,6 +556,7 @@ void cfg_parse()
cfg.video_saturation = 100;
cfg.video_hue = 0;
strcpy(cfg.video_gain_offset, "1, 0, 1, 0, 1, 0");
strcpy(cfg.main, "MiSTer");
has_video_sections = false;
using_video_section = false;
cfg_error_count = 0;

1
cfg.h
View File

@@ -98,6 +98,7 @@ typedef struct {
char osd_lock[25];
uint16_t osd_lock_time;
char debug;
char main[1024];
} cfg_t;
extern cfg_t cfg;

View File

@@ -610,7 +610,7 @@ char *getappname()
return dest;
}
void app_restart(const char *path, const char *xml)
void app_restart(const char *path, const char *xml, const char *exe)
{
sync();
fpga_core_reset(1);
@@ -620,8 +620,8 @@ void app_restart(const char *path, const char *xml)
offload_stop();
char *appname = getappname();
printf("restarting the %s\n", appname);
const char *appname = exe ? exe : getappname();
printf("restarting to %s\n", appname);
execl(appname, appname, path, xml, NULL);
printf("Something went wrong. Rebooting...\n");

View File

@@ -36,7 +36,7 @@ int fpga_get_io_version();
int fpga_load_rbf(const char *name, const char *cfg = 0, const char *xml = 0);
void reboot(int cold);
void app_restart(const char *path, const char *xml = 0);
void app_restart(const char *path, const char *xml = 0, const char *exe = 0);
char *getappname();
void fpga_wait_to_reset();

View File

@@ -1376,6 +1376,13 @@ void user_io_init(const char *path, const char *xml)
sleep(1);
}
const char *main = getFullPath(cfg.main);
if (strcasecmp(main, getappname()) && FileExists(main))
{
printf("Current exec is %s, core requires exec %s\n", getappname(), main);
app_restart(path, xml, main);
}
uint8_t hotswap[4] = {};
ide_reset(hotswap);
@@ -3119,7 +3126,7 @@ void user_io_poll()
else if (op & 1)
{
uint32_t buf_n = sizeof(buffer[0]) / blksz;
int psx_blksz = 0;
unsigned int psx_blksz = 0;
if (is_psx() && blksz == 2352)
{
//returns 0 if the mounted disk is not a chd, otherwise returns the chd hunksize in bytes