2018-09-07 16:00:13 +01:00
|
|
|
/*
|
2019-04-08 03:00:49 +01:00
|
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
2018-09-07 16:00:13 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-06-19 07:23:31 +01:00
|
|
|
|
2018-03-25 22:05:08 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
#include "exocfg.h"
|
|
|
|
#include "mmu.h"
|
|
|
|
#include "memory_map.h"
|
|
|
|
|
2019-01-30 21:53:16 +00:00
|
|
|
static exosphere_config_t g_exosphere_cfg = {MAGIC_EXOSPHERE_CONFIG, ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG, EXOSPHERE_FLAGS_DEFAULT};
|
2018-03-25 22:05:08 +01:00
|
|
|
static bool g_has_loaded_config = false;
|
|
|
|
|
2018-11-26 00:06:46 +00:00
|
|
|
#define EXOSPHERE_CHECK_FLAG(flag) ((g_exosphere_cfg.flags & flag) != 0)
|
|
|
|
|
|
|
|
|
2018-03-25 22:05:08 +01:00
|
|
|
/* Read config out of IRAM, return target firmware version. */
|
|
|
|
unsigned int exosphere_load_config(void) {
|
|
|
|
if (g_has_loaded_config) {
|
|
|
|
generic_panic();
|
|
|
|
}
|
|
|
|
g_has_loaded_config = true;
|
2019-06-19 07:23:31 +01:00
|
|
|
|
2018-11-26 00:06:46 +00:00
|
|
|
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG.magic;
|
2019-06-19 07:23:31 +01:00
|
|
|
|
2019-01-30 21:53:16 +00:00
|
|
|
if (magic == MAGIC_EXOSPHERE_CONFIG) {
|
2018-11-26 00:06:46 +00:00
|
|
|
g_exosphere_cfg = MAILBOX_EXOSPHERE_CONFIG;
|
2018-03-25 22:05:08 +01:00
|
|
|
}
|
2019-06-19 07:23:31 +01:00
|
|
|
|
2018-03-25 22:05:08 +01:00
|
|
|
return g_exosphere_cfg.target_firmware;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int exosphere_get_target_firmware(void) {
|
|
|
|
if (!g_has_loaded_config) {
|
|
|
|
generic_panic();
|
|
|
|
}
|
2019-06-19 07:23:31 +01:00
|
|
|
|
2018-03-25 22:05:08 +01:00
|
|
|
return g_exosphere_cfg.target_firmware;
|
2018-11-26 00:06:46 +00:00
|
|
|
}
|
|
|
|
|
2018-11-26 01:11:21 +00:00
|
|
|
unsigned int exosphere_should_perform_620_keygen(void) {
|
2018-11-26 00:06:46 +00:00
|
|
|
if (!g_has_loaded_config) {
|
|
|
|
generic_panic();
|
|
|
|
}
|
2019-06-19 07:23:31 +01:00
|
|
|
|
|
|
|
return false;
|
2018-11-26 00:06:46 +00:00
|
|
|
}
|
2018-11-30 11:10:27 +00:00
|
|
|
|
|
|
|
unsigned int exosphere_should_override_debugmode_priv(void) {
|
|
|
|
if (!g_has_loaded_config) {
|
|
|
|
generic_panic();
|
|
|
|
}
|
2019-06-19 07:23:31 +01:00
|
|
|
|
2018-11-30 11:10:27 +00:00
|
|
|
return EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int exosphere_should_override_debugmode_user(void) {
|
|
|
|
if (!g_has_loaded_config) {
|
|
|
|
generic_panic();
|
|
|
|
}
|
2019-06-19 07:23:31 +01:00
|
|
|
|
2018-11-30 11:10:27 +00:00
|
|
|
return EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_IS_DEBUGMODE_USER);
|
|
|
|
}
|
2019-05-10 11:50:25 +01:00
|
|
|
|
|
|
|
unsigned int exosphere_should_disable_usermode_exception_handlers(void) {
|
|
|
|
if (!g_has_loaded_config) {
|
|
|
|
generic_panic();
|
|
|
|
}
|
2019-06-19 07:23:31 +01:00
|
|
|
|
2019-05-10 11:50:25 +01:00
|
|
|
return EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS);
|
|
|
|
}
|
2019-05-27 20:07:51 +01:00
|
|
|
|
2019-12-07 23:35:34 +00:00
|
|
|
unsigned int exosphere_should_enable_usermode_pmu_access(void) {
|
|
|
|
if (!g_has_loaded_config) {
|
|
|
|
generic_panic();
|
|
|
|
}
|
|
|
|
|
|
|
|
return EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_ENABLE_USERMODE_PMU_ACCESS);
|
|
|
|
}
|
|
|
|
|
2019-06-04 20:31:23 +01:00
|
|
|
const exo_emummc_config_t *exosphere_get_emummc_config(void) {
|
2019-05-27 20:07:51 +01:00
|
|
|
if (!g_has_loaded_config) {
|
|
|
|
generic_panic();
|
|
|
|
}
|
|
|
|
|
2019-06-04 20:31:23 +01:00
|
|
|
return &g_exosphere_cfg.emummc_cfg;
|
2019-05-27 20:07:51 +01:00
|
|
|
}
|