2018-03-26 23:04:16 +00:00
|
|
|
/*
|
2018-08-05 11:40:32 +00:00
|
|
|
* Copyright (c) 2018 naehrwert
|
2023-02-22 11:45:46 +00:00
|
|
|
* Copyright (c) 2018-2023 CTCaer
|
2018-08-05 11:40:32 +00: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-26 23:04:16 +00:00
|
|
|
|
2018-05-01 05:15:48 +00:00
|
|
|
#ifndef _HOS_H_
|
|
|
|
#define _HOS_H_
|
2018-03-14 23:26:19 +00:00
|
|
|
|
2022-01-15 22:04:34 +00:00
|
|
|
#include <bdk.h>
|
|
|
|
|
2018-11-28 19:26:16 +00:00
|
|
|
#include "pkg1.h"
|
|
|
|
#include "pkg2.h"
|
2018-11-30 21:20:15 +00:00
|
|
|
|
2020-04-30 00:43:29 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
2021-07-06 07:05:37 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_100 0
|
|
|
|
#define KB_FIRMWARE_VERSION_300 1
|
|
|
|
#define KB_FIRMWARE_VERSION_301 2
|
|
|
|
#define KB_FIRMWARE_VERSION_400 3
|
|
|
|
#define KB_FIRMWARE_VERSION_500 4
|
|
|
|
#define KB_FIRMWARE_VERSION_600 5
|
|
|
|
#define KB_FIRMWARE_VERSION_620 6
|
|
|
|
#define KB_FIRMWARE_VERSION_700 7
|
|
|
|
#define KB_FIRMWARE_VERSION_810 8
|
|
|
|
#define KB_FIRMWARE_VERSION_900 9
|
|
|
|
#define KB_FIRMWARE_VERSION_910 10
|
2021-07-06 07:02:52 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_1210 11
|
2021-09-17 20:32:13 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_1300 12
|
2022-03-23 00:21:59 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_1400 13
|
2022-10-11 07:29:41 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_1500 14
|
2023-02-22 11:45:46 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_1600 15
|
|
|
|
#define KB_FIRMWARE_VERSION_MAX KB_FIRMWARE_VERSION_1600 //!TODO: Update on mkey changes.
|
2018-03-14 23:26:19 +00:00
|
|
|
|
2021-09-17 20:32:13 +00:00
|
|
|
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
|
|
|
|
|
|
|
|
#define HOS_PKG11_MAGIC 0x31314B50
|
|
|
|
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
|
|
|
|
#define HOS_EKS_TSEC_VER (KB_FIRMWARE_VERSION_700 + HOS_TSEC_VERSION)
|
2020-04-30 00:43:29 +00:00
|
|
|
|
2021-08-28 14:53:14 +00:00
|
|
|
// Use official Mariko secmon when in stock. Needs access to TZRAM.
|
2020-12-01 23:56:29 +00:00
|
|
|
//#define HOS_MARIKO_STOCK_SECMON
|
|
|
|
|
2020-04-30 00:43:29 +00:00
|
|
|
typedef struct _exo_ctxt_t
|
|
|
|
{
|
2021-08-28 14:55:03 +00:00
|
|
|
u32 hos_revision;
|
2020-04-30 00:43:29 +00:00
|
|
|
bool no_user_exceptions;
|
|
|
|
bool user_pmu;
|
2021-03-17 07:31:06 +00:00
|
|
|
bool *usb3_force;
|
2020-04-30 00:43:29 +00:00
|
|
|
bool *cal0_blank;
|
|
|
|
bool *cal0_allow_writes_sys;
|
|
|
|
} exo_ctxt_t;
|
|
|
|
|
|
|
|
typedef struct _hos_eks_mbr_t
|
|
|
|
{
|
|
|
|
u32 magic;
|
2021-08-28 14:53:14 +00:00
|
|
|
u32 enabled;
|
2020-11-15 11:43:22 +00:00
|
|
|
u32 lot0;
|
2021-08-28 14:53:14 +00:00
|
|
|
u32 rsvd;
|
|
|
|
u8 tsec[SE_KEY_128_SIZE];
|
|
|
|
u8 troot[SE_KEY_128_SIZE];
|
|
|
|
u8 troot_dev[SE_KEY_128_SIZE];
|
2020-04-30 00:43:29 +00:00
|
|
|
} hos_eks_mbr_t;
|
|
|
|
|
2021-08-28 14:53:14 +00:00
|
|
|
static_assert(sizeof(hos_eks_mbr_t) == 64, "HOS EKS size is wrong!");
|
2018-12-16 14:55:56 +00:00
|
|
|
|
2018-11-28 19:26:16 +00:00
|
|
|
typedef struct _launch_ctxt_t
|
|
|
|
{
|
|
|
|
void *keyblob;
|
|
|
|
|
|
|
|
void *pkg1;
|
|
|
|
const pkg1_id_t *pkg1_id;
|
|
|
|
const pkg2_kernel_id_t *pkg2_kernel_id;
|
|
|
|
|
|
|
|
void *warmboot;
|
|
|
|
u32 warmboot_size;
|
|
|
|
void *secmon;
|
|
|
|
u32 secmon_size;
|
2020-12-01 23:53:00 +00:00
|
|
|
void *exofatal;
|
|
|
|
u32 exofatal_size;
|
2018-11-28 19:26:16 +00:00
|
|
|
|
|
|
|
void *pkg2;
|
|
|
|
u32 pkg2_size;
|
2020-01-19 13:22:59 +00:00
|
|
|
bool new_pkg2;
|
2018-11-28 19:26:16 +00:00
|
|
|
|
2023-07-28 00:06:20 +00:00
|
|
|
void *kernel;
|
|
|
|
u32 kernel_size;
|
2020-10-17 20:16:16 +00:00
|
|
|
|
2018-11-28 19:26:16 +00:00
|
|
|
link_t kip1_list;
|
|
|
|
char* kip1_patches;
|
|
|
|
|
|
|
|
bool svcperm;
|
|
|
|
bool debugmode;
|
2019-03-09 18:49:00 +00:00
|
|
|
bool stock;
|
2020-04-30 01:25:51 +00:00
|
|
|
bool emummc_forced;
|
2019-03-09 18:49:00 +00:00
|
|
|
|
2021-03-17 07:31:06 +00:00
|
|
|
char *fss0_main_path;
|
|
|
|
u32 fss0_hosver;
|
|
|
|
bool atmosphere;
|
|
|
|
|
2023-07-28 00:06:20 +00:00
|
|
|
int ucid;
|
|
|
|
|
2020-06-13 22:29:41 +00:00
|
|
|
exo_ctxt_t exo_ctx;
|
2020-04-30 13:21:38 +00:00
|
|
|
|
2019-03-09 18:49:00 +00:00
|
|
|
ini_sec_t *cfg;
|
2018-11-28 19:26:16 +00:00
|
|
|
} launch_ctxt_t;
|
|
|
|
|
|
|
|
typedef struct _merge_kip_t
|
|
|
|
{
|
|
|
|
void *kip1;
|
|
|
|
link_t link;
|
|
|
|
} merge_kip_t;
|
|
|
|
|
2020-04-30 00:43:29 +00:00
|
|
|
void hos_eks_clear(u32 kb);
|
|
|
|
int hos_launch(ini_sec_t *cfg);
|
2021-08-28 14:53:14 +00:00
|
|
|
int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool is_exo);
|
2018-03-14 23:26:19 +00:00
|
|
|
|
|
|
|
#endif
|