boot cfg: Allow Launching UMS from boot.

By using `BOOT_CFG_AUTOBOOT_EN` in `boot_cfg` and `EXTRA_CFG_NYX_UMS` in `extra_cfg` you can launch UMS from boot.

The `ums` variable must be populated with one of the following:

```
NYX_UMS_SD_CARD      0
NYX_UMS_EMMC_BOOT0   1
NYX_UMS_EMMC_BOOT1   2
NYX_UMS_EMMC_GPP     3
NYX_UMS_EMUMMC_BOOT0 4
NYX_UMS_EMUMMC_BOOT1 5
NYX_UMS_EMUMMC_GPP   6
```
This commit is contained in:
CTCaer 2020-04-30 14:44:27 +03:00
parent ac4bf9cf2c
commit abcb1dec46
8 changed files with 90 additions and 7 deletions

View file

@ -696,10 +696,19 @@ void nyx_load_run()
nyx_str->info.errors = h_cfg.errors;
nyx_str->cfg = 0;
if (b_cfg.extra_cfg & EXTRA_CFG_NYX_DUMP)
if (b_cfg.extra_cfg)
{
b_cfg.extra_cfg &= ~(EXTRA_CFG_NYX_DUMP);
nyx_str->cfg |= NYX_CFG_DUMP;
if (b_cfg.extra_cfg & EXTRA_CFG_NYX_DUMP)
{
b_cfg.extra_cfg &= ~(EXTRA_CFG_NYX_DUMP);
nyx_str->cfg |= NYX_CFG_DUMP;
}
if (b_cfg.extra_cfg & EXTRA_CFG_NYX_UMS)
{
b_cfg.extra_cfg &= ~(EXTRA_CFG_NYX_UMS);
nyx_str->cfg |= NYX_CFG_UMS;
nyx_str->cfg |= b_cfg.ums << 24;
}
}
nyx_str->version = ipl_ver.version - 0x303030; // Convert ASCII to numbers.
@ -758,6 +767,8 @@ static void _auto_launch_firmware()
EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD;
check_sept(NULL);
}
else if (b_cfg.extra_cfg & EXTRA_CFG_NYX_UMS)
EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD;
if (!h_cfg.sept_run)
auto_launch_update();

View file

@ -62,9 +62,21 @@ typedef int bool;
#define EXTRA_CFG_PAYLOAD (1 << 1)
#define EXTRA_CFG_MODULE (1 << 2)
#define EXTRA_CFG_NYX_UMS (1 << 5)
#define EXTRA_CFG_NYX_RELOAD (1 << 6)
#define EXTRA_CFG_NYX_DUMP (1 << 7)
typedef enum _nyx_ums_type
{
NYX_UMS_SD_CARD = 0,
NYX_UMS_EMMC_BOOT0,
NYX_UMS_EMMC_BOOT1,
NYX_UMS_EMMC_GPP,
NYX_UMS_EMUMMC_BOOT0,
NYX_UMS_EMUMMC_BOOT1,
NYX_UMS_EMUMMC_GPP
} nyx_ums_type;
typedef struct __attribute__((__packed__)) _boot_cfg_t
{
u8 boot_cfg;
@ -75,9 +87,10 @@ typedef struct __attribute__((__packed__)) _boot_cfg_t
{
struct
{
char id[8];
char emummc_path[0x78];
char id[8]; // 7 char ASCII null teminated.
char emummc_path[0x78]; // emuMMC/XXX, ASCII null teminated.
};
u8 ums; // nyx_ums_type.
u8 xt_str[0x80];
};
} boot_cfg_t;

View file

@ -23,6 +23,7 @@
typedef enum
{
NYX_CFG_UMS = (1 << 6),
NYX_CFG_DUMP = (1 << 7),
} nyx_cfg_t;

View file

@ -1978,6 +1978,12 @@ static void _nyx_main_menu(lv_theme_t * th)
lv_task_t *task_run_dump = lv_task_create(sept_run_dump, LV_TASK_ONESHOT, LV_TASK_PRIO_MID, NULL);
lv_task_once(task_run_dump);
}
else if (nyx_str->cfg & NYX_CFG_UMS)
{
nyx_str->cfg &= ~(NYX_CFG_UMS);
lv_task_t *task_run_ums = lv_task_create(nyx_run_ums, LV_TASK_ONESHOT, LV_TASK_PRIO_MID, (void *)&nyx_str->cfg);
lv_task_once(task_run_ums);
}
}
void nyx_load_and_run()

View file

@ -592,6 +592,43 @@ static lv_res_t _action_ums_emuemmc_gpp(lv_obj_t *btn)
return LV_RES_OK;
}
void nyx_run_ums(void *param)
{
u32 *cfg = (u32 *)param;
u8 type = (*cfg) >> 24;
*cfg = *cfg & 0xFFFFFF;
// Disable read only flag.
usb_msc_emmc_read_only = false;
switch (type)
{
case NYX_UMS_SD_CARD:
action_ums_sd(NULL);
break;
case NYX_UMS_EMMC_BOOT0:
_action_ums_emmc_boot0(NULL);
break;
case NYX_UMS_EMMC_BOOT1:
_action_ums_emmc_boot1(NULL);
break;
case NYX_UMS_EMMC_GPP:
_action_ums_emmc_gpp(NULL);
break;
case NYX_UMS_EMUMMC_BOOT0:
_action_ums_emuemmc_boot0(NULL);
break;
case NYX_UMS_EMUMMC_BOOT1:
_action_ums_emuemmc_boot1(NULL);
break;
case NYX_UMS_EMUMMC_GPP:
_action_ums_emuemmc_gpp(NULL);
break;
}
}
static lv_res_t _emmc_read_only_toggle(lv_obj_t *btn)
{
nyx_generic_onoff_toggle(btn);

View file

@ -22,6 +22,7 @@
lv_obj_t *ums_mbox;
void create_tab_tools(lv_theme_t *th, lv_obj_t *parent);
void nyx_run_ums(void *param);
void sept_run_dump(void *param);
bool get_autorcm_status(bool change);
lv_res_t action_ums_sd(lv_obj_t *btn);

View file

@ -62,9 +62,21 @@ typedef int bool;
#define EXTRA_CFG_PAYLOAD (1 << 1)
#define EXTRA_CFG_MODULE (1 << 2)
#define EXTRA_CFG_NYX_UMS (1 << 5)
#define EXTRA_CFG_NYX_RELOAD (1 << 6)
#define EXTRA_CFG_NYX_DUMP (1 << 7)
typedef enum _nyx_ums_type
{
NYX_UMS_SD_CARD = 0,
NYX_UMS_EMMC_BOOT0,
NYX_UMS_EMMC_BOOT1,
NYX_UMS_EMMC_GPP,
NYX_UMS_EMUMMC_BOOT0,
NYX_UMS_EMUMMC_BOOT1,
NYX_UMS_EMUMMC_GPP
} nyx_ums_type;
typedef struct __attribute__((__packed__)) _boot_cfg_t
{
u8 boot_cfg;
@ -75,9 +87,10 @@ typedef struct __attribute__((__packed__)) _boot_cfg_t
{
struct
{
char id[8];
char emummc_path[0x78];
char id[8]; // 7 char ASCII null teminated.
char emummc_path[0x78]; // emuMMC/XXX, ASCII null teminated.
};
u8 ums; // nyx_ums_type.
u8 xt_str[0x80];
};
} boot_cfg_t;

View file

@ -23,6 +23,7 @@
typedef enum
{
NYX_CFG_UMS = (1 << 6),
NYX_CFG_DUMP = (1 << 7),
} nyx_cfg_t;