Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bootloader/hos/hos.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2025 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_KB_VERSION_100 = 0,
31
HOS_KB_VERSION_300 = 1,
32
HOS_KB_VERSION_301 = 2,
33
HOS_KB_VERSION_400 = 3,
34
HOS_KB_VERSION_500 = 4,
35
HOS_KB_VERSION_600 = 5,
36
HOS_KB_VERSION_620 = 6,
37
HOS_KB_VERSION_700 = 7,
38
HOS_KB_VERSION_810 = 8,
39
HOS_KB_VERSION_900 = 9,
40
HOS_KB_VERSION_910 = 10,
41
HOS_KB_VERSION_1210 = 11,
42
HOS_KB_VERSION_1300 = 12,
43
HOS_KB_VERSION_1400 = 13,
44
HOS_KB_VERSION_1500 = 14,
45
HOS_KB_VERSION_1600 = 15,
46
HOS_KB_VERSION_1700 = 16,
47
HOS_KB_VERSION_1800 = 17,
48
HOS_KB_VERSION_1900 = 18,
49
HOS_KB_VERSION_2000 = 19,
50
HOS_KB_VERSION_MAX = HOS_KB_VERSION_2000
51
};
52
53
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
54
55
#define HOS_PKG11_MAGIC 0x31314B50
56
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
57
#define HOS_EKS_TSEC_VER (HOS_KB_VERSION_700 + HOS_TSEC_VERSION)
58
59
// Use official Mariko secmon when in stock. Needs access to TZRAM.
60
//#define HOS_MARIKO_STOCK_SECMON
61
62
typedef struct _exo_ctxt_t
63
{
64
u32 hos_revision;
65
bool no_user_exceptions;
66
bool user_pmu;
67
bool *usb3_force;
68
bool *cal0_blank;
69
bool *cal0_allow_writes_sys;
70
} exo_ctxt_t;
71
72
typedef struct _hos_eks_mbr_t
73
{
74
u32 magic;
75
u32 enabled;
76
u32 lot0;
77
u32 rsvd;
78
u8 tsec[SE_KEY_128_SIZE];
79
u8 troot[SE_KEY_128_SIZE];
80
u8 troot_dev[SE_KEY_128_SIZE];
81
} hos_eks_mbr_t;
82
83
static_assert(sizeof(hos_eks_mbr_t) == 64, "HOS EKS size is wrong!");
84
85
typedef struct _launch_ctxt_t
86
{
87
void *keyblob;
88
89
void *pkg1;
90
const pkg1_id_t *pkg1_id;
91
const pkg2_kernel_id_t *pkg2_kernel_id;
92
93
void *warmboot;
94
u32 warmboot_size;
95
void *secmon;
96
u32 secmon_size;
97
void *exofatal;
98
u32 exofatal_size;
99
100
void *pkg2;
101
u32 pkg2_size;
102
bool new_pkg2;
103
104
void *kernel;
105
u32 kernel_size;
106
107
link_t kip1_list;
108
char *kip1_patches;
109
110
bool svcperm;
111
bool debugmode;
112
bool stock;
113
bool emummc_forced;
114
115
void *pkg3;
116
u32 pkg3_hosver;
117
bool patch_krn_proc_id;
118
119
int ucid;
120
121
exo_ctxt_t exo_ctx;
122
123
ini_sec_t *cfg;
124
} launch_ctxt_t;
125
126
typedef struct _merge_kip_t
127
{
128
void *kip1;
129
link_t link;
130
} merge_kip_t;
131
132
void hos_launch(ini_sec_t *cfg);
133
134
#endif
135
136