Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bootloader/hos/hos.h
3693 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2026 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _HOS_H_
19
#define _HOS_H_
20
21
#include <bdk.h>
22
23
#include "pkg1.h"
24
#include "pkg2.h"
25
26
#include <assert.h>
27
28
//!TODO: Update on mkey changes.
29
enum {
30
HOS_MKEY_VER_100 = 0,
31
HOS_MKEY_VER_300 = 1,
32
HOS_MKEY_VER_301 = 2,
33
HOS_MKEY_VER_400 = 3,
34
HOS_MKEY_VER_500 = 4,
35
HOS_MKEY_VER_600 = 5,
36
HOS_MKEY_VER_620 = 6,
37
HOS_MKEY_VER_700 = 7,
38
HOS_MKEY_VER_810 = 8,
39
HOS_MKEY_VER_900 = 9,
40
HOS_MKEY_VER_910 = 10,
41
HOS_MKEY_VER_1210 = 11,
42
HOS_MKEY_VER_1300 = 12,
43
HOS_MKEY_VER_1400 = 13,
44
HOS_MKEY_VER_1500 = 14,
45
HOS_MKEY_VER_1600 = 15,
46
HOS_MKEY_VER_1700 = 16,
47
HOS_MKEY_VER_1800 = 17,
48
HOS_MKEY_VER_1900 = 18,
49
HOS_MKEY_VER_2000 = 19,
50
HOS_MKEY_VER_2100 = 20,
51
HOS_MKEY_VER_2200 = 21,
52
HOS_MKEY_VER_MAX = HOS_MKEY_VER_2200
53
};
54
55
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
56
57
#define HOS_PKG11_MAGIC 0x31314B50
58
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
59
#define HOS_EKS_TSEC_VER (HOS_MKEY_VER_700 + HOS_TSEC_VERSION)
60
61
// Use official Mariko secmon when in stock. Needs access to TZRAM.
62
//#define HOS_MARIKO_STOCK_SECMON
63
64
typedef struct _exo_ctxt_t
65
{
66
u32 hos_revision;
67
bool no_user_exceptions;
68
bool user_pmu;
69
bool *force_mem_mode;
70
bool *usb3_force;
71
bool *cal0_blank;
72
bool *cal0_allow_writes_sys;
73
} exo_ctxt_t;
74
75
typedef struct _hos_eks_mbr_t
76
{
77
u32 magic;
78
u32 enabled;
79
u32 lot0;
80
u32 rsvd;
81
u8 tsec[SE_KEY_128_SIZE];
82
u8 troot[SE_KEY_128_SIZE];
83
u8 troot_dev[SE_KEY_128_SIZE];
84
} hos_eks_mbr_t;
85
86
static_assert(sizeof(hos_eks_mbr_t) == 64, "HOS EKS size is wrong!");
87
88
typedef struct _launch_ctxt_t
89
{
90
pkg1_eks_t *eks;
91
92
void *pkg1;
93
const pkg1_id_t *pkg1_id;
94
const pkg2_kernel_id_t *pkg2_kernel_id;
95
96
void *warmboot;
97
u32 warmboot_size;
98
void *secmon;
99
u32 secmon_size;
100
void *exofatal;
101
u32 exofatal_size;
102
103
void *pkg2;
104
u32 pkg2_size;
105
bool new_pkg2;
106
107
void *kernel;
108
u32 kernel_size;
109
110
link_t kip1_list;
111
char *kip1_patches;
112
113
bool svcperm;
114
bool debugmode;
115
bool stock;
116
bool emummc_forced;
117
118
void *pkg3;
119
u32 pkg3_hosver;
120
bool patch_krn_proc_id;
121
122
int ucid;
123
124
exo_ctxt_t exo_ctx;
125
126
ini_sec_t *cfg;
127
} launch_ctxt_t;
128
129
typedef struct _merge_kip_t
130
{
131
void *kip1;
132
link_t link;
133
} merge_kip_t;
134
135
void hos_launch(ini_sec_t *cfg);
136
137
#endif
138
139