2018-09-07 16:00:13 +01:00
|
|
|
/*
|
2020-01-24 02:10:40 -08:00
|
|
|
* Copyright (c) 2018-2020 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-18 23:23:31 -07:00
|
|
|
|
2018-03-25 15:05:08 -06:00
|
|
|
#ifndef EXOSPHERE_EXOSPHERE_CONFIG_H
|
|
|
|
#define EXOSPHERE_EXOSPHERE_CONFIG_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2019-12-09 03:58:48 -08:00
|
|
|
#include <vapours/ams_version.h>
|
2018-03-25 15:05:08 -06:00
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "memory_map.h"
|
2019-06-04 12:31:23 -07:00
|
|
|
#include "emummc_cfg.h"
|
2018-03-25 15:05:08 -06:00
|
|
|
|
|
|
|
/* This serves to set configuration for *exosphere itself*, separate from the SecMon Exosphere mimics. */
|
|
|
|
|
2019-01-30 13:53:16 -08:00
|
|
|
/* "EXO0" */
|
|
|
|
#define MAGIC_EXOSPHERE_CONFIG (0x304F5845)
|
2018-03-25 15:05:08 -06:00
|
|
|
|
2018-05-21 04:30:32 -06:00
|
|
|
#define EXOSPHERE_LOOSEN_PACKAGE2_RESTRICTIONS_FOR_DEBUG 1
|
2018-03-25 15:05:08 -06:00
|
|
|
|
2019-01-30 13:53:16 -08:00
|
|
|
#define MAILBOX_EXOSPHERE_CONFIG (*((volatile exosphere_config_t *)(0x8000F000ull)))
|
2018-03-25 15:05:08 -06:00
|
|
|
|
2019-01-30 13:53:16 -08:00
|
|
|
/* Exosphere config in DRAM shares physical/virtual mapping. */
|
|
|
|
#define MAILBOX_EXOSPHERE_CONFIG_PHYS MAILBOX_EXOSPHERE_CONFIG
|
2018-03-25 15:05:08 -06:00
|
|
|
|
2019-06-18 23:23:31 -07:00
|
|
|
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN_DEPRECATED (1 << 0u)
|
2019-05-10 03:50:25 -07:00
|
|
|
#define EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV (1 << 1u)
|
|
|
|
#define EXOSPHERE_FLAG_IS_DEBUGMODE_USER (1 << 2u)
|
|
|
|
#define EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS (1 << 3u)
|
2019-12-07 15:35:34 -08:00
|
|
|
#define EXOSPHERE_FLAG_ENABLE_USERMODE_PMU_ACCESS (1 << 4u)
|
2020-04-22 16:22:14 -07:00
|
|
|
#define EXOSPHERE_FLAG_BLANK_PRODINFO (1 << 5u)
|
|
|
|
#define EXOSPHERE_FLAG_ALLOW_WRITING_TO_CAL_SYSMMC (1 << 6u)
|
2019-05-10 03:50:25 -07:00
|
|
|
#define EXOSPHERE_FLAGS_DEFAULT (EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV)
|
2018-03-25 15:05:08 -06:00
|
|
|
|
|
|
|
typedef struct {
|
2019-05-27 12:07:51 -07:00
|
|
|
uint32_t magic;
|
|
|
|
uint32_t target_firmware;
|
|
|
|
uint32_t flags;
|
2019-06-04 12:31:23 -07:00
|
|
|
uint32_t reserved[5];
|
|
|
|
exo_emummc_config_t emummc_cfg;
|
2018-03-25 15:05:08 -06:00
|
|
|
} exosphere_config_t;
|
|
|
|
|
2019-06-04 12:31:23 -07:00
|
|
|
_Static_assert(sizeof(exosphere_config_t) == 0x20 + sizeof(exo_emummc_config_t), "exosphere config definition");
|
2019-05-27 12:07:51 -07:00
|
|
|
|
2018-03-25 15:05:08 -06:00
|
|
|
unsigned int exosphere_load_config(void);
|
|
|
|
unsigned int exosphere_get_target_firmware(void);
|
2018-11-25 17:11:21 -08:00
|
|
|
unsigned int exosphere_should_perform_620_keygen(void);
|
2018-11-30 03:10:27 -08:00
|
|
|
unsigned int exosphere_should_override_debugmode_priv(void);
|
|
|
|
unsigned int exosphere_should_override_debugmode_user(void);
|
2019-05-10 03:50:25 -07:00
|
|
|
unsigned int exosphere_should_disable_usermode_exception_handlers(void);
|
2019-12-07 15:35:34 -08:00
|
|
|
unsigned int exosphere_should_enable_usermode_pmu_access(void);
|
2020-04-22 16:22:14 -07:00
|
|
|
unsigned int exosphere_should_blank_prodinfo(void);
|
|
|
|
unsigned int exosphere_should_allow_writing_to_cal(void);
|
2018-03-25 15:05:08 -06:00
|
|
|
|
2019-06-04 12:31:23 -07:00
|
|
|
const exo_emummc_config_t *exosphere_get_emummc_config(void);
|
2019-05-27 12:07:51 -07:00
|
|
|
|
2018-05-11 14:07:37 +02:00
|
|
|
static inline unsigned int exosphere_get_target_firmware_for_init(void) {
|
2018-11-25 16:06:46 -08:00
|
|
|
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG_PHYS.magic;
|
2019-01-30 13:53:16 -08:00
|
|
|
if (magic == MAGIC_EXOSPHERE_CONFIG) {
|
2018-11-25 16:06:46 -08:00
|
|
|
return MAILBOX_EXOSPHERE_CONFIG_PHYS.target_firmware;
|
|
|
|
} else {
|
2019-12-09 03:58:48 -08:00
|
|
|
return ATMOSPHERE_TARGET_FIRMWARE_CURRENT;
|
2018-11-25 16:06:46 -08:00
|
|
|
}
|
2018-03-25 15:05:08 -06:00
|
|
|
}
|
|
|
|
|
2018-05-11 14:07:37 +02:00
|
|
|
#endif
|