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/>.
|
|
|
|
*/
|
|
|
|
|
2018-03-25 22:05:08 +01:00
|
|
|
#ifndef EXOSPHERE_EXOSPHERE_CONFIG_H
|
|
|
|
#define EXOSPHERE_EXOSPHERE_CONFIG_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2018-12-17 20:39:35 +00:00
|
|
|
#include <atmosphere.h>
|
2018-03-25 22:05:08 +01:00
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "memory_map.h"
|
|
|
|
|
|
|
|
/* This serves to set configuration for *exosphere itself*, separate from the SecMon Exosphere mimics. */
|
|
|
|
|
2019-01-30 21:53:16 +00:00
|
|
|
/* "EXO0" */
|
|
|
|
#define MAGIC_EXOSPHERE_CONFIG (0x304F5845)
|
2018-03-25 22:05:08 +01:00
|
|
|
|
2018-05-21 11:30:32 +01:00
|
|
|
#define EXOSPHERE_LOOSEN_PACKAGE2_RESTRICTIONS_FOR_DEBUG 1
|
2018-03-25 22:05:08 +01:00
|
|
|
|
2019-01-30 21:53:16 +00:00
|
|
|
#define MAILBOX_EXOSPHERE_CONFIG (*((volatile exosphere_config_t *)(0x8000F000ull)))
|
2018-03-25 22:05:08 +01:00
|
|
|
|
2019-01-30 21:53:16 +00:00
|
|
|
/* Exosphere config in DRAM shares physical/virtual mapping. */
|
|
|
|
#define MAILBOX_EXOSPHERE_CONFIG_PHYS MAILBOX_EXOSPHERE_CONFIG
|
2018-03-25 22:05:08 +01:00
|
|
|
|
2018-11-26 00:06:46 +00:00
|
|
|
#define EXOSPHERE_FLAGS_DEFAULT 0x00000000
|
|
|
|
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN (1 << 0u)
|
2018-11-30 11:10:27 +00:00
|
|
|
#define EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV (1 << 1u)
|
|
|
|
#define EXOSPHERE_FLAG_IS_DEBUGMODE_USER (1 << 2u)
|
2018-03-25 22:05:08 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned int magic;
|
|
|
|
unsigned int target_firmware;
|
2018-11-26 00:06:46 +00:00
|
|
|
unsigned int flags;
|
2019-01-30 21:53:16 +00:00
|
|
|
unsigned int reserved;
|
2018-03-25 22:05:08 +01:00
|
|
|
} exosphere_config_t;
|
|
|
|
|
|
|
|
unsigned int exosphere_load_config(void);
|
|
|
|
unsigned int exosphere_get_target_firmware(void);
|
2018-11-26 01:11:21 +00:00
|
|
|
unsigned int exosphere_should_perform_620_keygen(void);
|
2018-11-30 11:10:27 +00:00
|
|
|
unsigned int exosphere_should_override_debugmode_priv(void);
|
|
|
|
unsigned int exosphere_should_override_debugmode_user(void);
|
2018-03-25 22:05:08 +01:00
|
|
|
|
2018-05-11 13:07:37 +01:00
|
|
|
static inline unsigned int exosphere_get_target_firmware_for_init(void) {
|
2018-11-26 00:06:46 +00:00
|
|
|
const unsigned int magic = MAILBOX_EXOSPHERE_CONFIG_PHYS.magic;
|
2019-01-30 21:53:16 +00:00
|
|
|
if (magic == MAGIC_EXOSPHERE_CONFIG) {
|
2018-11-26 00:06:46 +00:00
|
|
|
return MAILBOX_EXOSPHERE_CONFIG_PHYS.target_firmware;
|
|
|
|
} else {
|
2018-12-17 20:39:35 +00:00
|
|
|
return ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG;
|
2018-11-26 00:06:46 +00:00
|
|
|
}
|
2018-03-25 22:05:08 +01:00
|
|
|
}
|
|
|
|
|
2018-05-11 13:07:37 +01:00
|
|
|
#endif
|