Skip to content

Commit

Permalink
utils: report IsT flag at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkMatterCore committed May 26, 2024
1 parent 503ce4c commit d64c4de
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
3 changes: 3 additions & 0 deletions include/core/nxdt_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ bool utilsIsMarikoUnit(void);
/// Returns true if the application is running under a development unit.
bool utilsIsDevelopmentUnit(void);

/// Returns true if the application is running under a unit with the Terra platform flag set.
bool utilsIsTerraUnit(void);

/// Returns true if the application is running under applet mode.
bool utilsIsAppletMode(void);

Expand Down
40 changes: 35 additions & 5 deletions source/core/nxdt_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static u8 g_customFirmwareType = UtilsCustomFirmwareType_Unknown;

static u8 g_productModel = SetSysProductModel_Invalid;

static bool g_isDevUnit = false;
static bool g_isTerraUnit = false, g_isDevUnit = false;

static AppletType g_programAppletType = AppletType_None;

Expand Down Expand Up @@ -103,7 +103,9 @@ static void _utilsGetCustomFirmwareType(void);

static bool _utilsGetProductModel(void);

static bool _utilsIsDevelopmentUnit(void);
static bool utilsGetDevelopmentUnitFlag(void);

static bool utilsGetTerraUnitFlag(void);

static bool utilsMountEmmcBisSystemPartitionStorage(void);
static void utilsUnmountEmmcBisSystemPartitionStorage(void);
Expand Down Expand Up @@ -185,12 +187,16 @@ bool utilsInitializeResources(void)
if (!_utilsGetProductModel()) break;

/* Get development unit flag. */
if (!_utilsIsDevelopmentUnit()) break;
if (!utilsGetDevelopmentUnitFlag()) break;

/* Get Terra unit flag. */
if (!utilsGetTerraUnitFlag()) break;

/* Get applet type. */
g_programAppletType = appletGetAppletType();

LOG_MSG_INFO("Running under %s %s unit in %s mode.", g_isDevUnit ? "development" : "retail", utilsIsMarikoUnit() ? "Mariko" : "Erista", utilsIsAppletMode() ? "applet" : "title override");
LOG_MSG_INFO("Running under %s %s unit %s Terra flag in %s mode.", g_isDevUnit ? "development" : "retail", utilsIsMarikoUnit() ? "Mariko" : "Erista", \
g_isTerraUnit ? "with" : "without", utilsIsAppletMode() ? "applet" : "title override");

if (g_appLaunchPath)
{
Expand Down Expand Up @@ -432,6 +438,11 @@ bool utilsIsDevelopmentUnit(void)
return g_isDevUnit;
}

bool utilsIsTerraUnit(void)
{
return g_isTerraUnit;
}

bool utilsIsAppletMode(void)
{
return (g_programAppletType > AppletType_Application && g_programAppletType < AppletType_SystemApplication);
Expand Down Expand Up @@ -1313,7 +1324,7 @@ static bool _utilsGetProductModel(void)
return ret;
}

static bool _utilsIsDevelopmentUnit(void)
static bool utilsGetDevelopmentUnitFlag(void)
{
Result rc = 0;
bool tmp = false;
Expand All @@ -1329,6 +1340,25 @@ static bool _utilsIsDevelopmentUnit(void)
return R_SUCCEEDED(rc);
}

static bool utilsGetTerraUnitFlag(void)
{
/* Return right away if we're running under a HOS version that's too low. */
if (hosversionBefore(8, 0, 0)) return true;

Result rc = 0;
bool tmp = false;

rc = setsysGetT(&tmp);
if (R_SUCCEEDED(rc))
{
g_isTerraUnit = tmp;
} else {
LOG_MSG_ERROR("setsysGetT failed! (0x%X).", rc);
}

return R_SUCCEEDED(rc);
}

static bool utilsMountEmmcBisSystemPartitionStorage(void)
{
Result rc = 0;
Expand Down

0 comments on commit d64c4de

Please sign in to comment.