mini_ipc.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00019 #ifndef __MINI_IPC_H__
00020 #define __MINI_IPC_H__
00021
00022 #define SDHC_ENOCARD -0x1001
00023 #define SDHC_ESTRANGE -0x1002
00024 #define SDHC_EOVERFLOW -0x1003
00025 #define SDHC_ETIMEDOUT -0x1004
00026 #define SDHC_EINVAL -0x1005
00027 #define SDHC_EIO -0x1006
00029 #define SDMMC_NO_CARD 1
00030 #define SDMMC_NEW_CARD 2
00031 #define SDMMC_INSERTED 3
00033 #define NAND_ECC_OK 0
00034 #define NAND_ECC_CORRECTED 1
00035 #define NAND_ECC_UNCORRECTABLE -1
00037 int sd_get_state(void);
00038 int sd_protected(void);
00039 int sd_mount(void);
00040 int sd_select(void);
00041 int sd_read(u32 start_block, u32 blk_cnt, void *buffer);
00042 int sd_write(u32 start_block, u32 blk_cnt, const void *buffer);
00043 u32 sd_getsize(void);
00044
00051 int ipc_powerpc_boot(const void *addr, u32 len);
00057 int ipc_powerpc_boot_file(const char *file);
00058
00059 #define TMD_BM_MARK(x) ((u16*)&(x->reserved[4]))
00060
00061 #define TMD_BM_MAGIC 0x424d
00062
00063 typedef struct sig_rsa2048_t sig_rsa2048_t;
00064 struct sig_rsa2048_t {
00065 u32 type;
00066 u8 sig[256];
00067 u8 fill[60];
00068 } __attribute__((packed));
00069
00070 typedef struct tmd_content_t tmd_content_t;
00071 struct tmd_content_t {
00072 u32 cid;
00073 u16 index;
00074 u16 type;
00075 u64 size;
00076 u8 hash[20];
00077 } __attribute__((packed));
00078
00079 typedef struct tmd_t tmd_t;
00080 struct tmd_t {
00081 sig_rsa2048_t signature;
00082 char issuer[0x40];
00083 u8 version;
00084 u8 ca_crl_version;
00085 u8 signer_crl_version;
00086 u8 fill2;
00087 u64 sys_version;
00088 u64 title_id;
00089 u32 title_type;
00090 u16 group_id;
00091 u16 zero;
00092 u16 region;
00093 u8 ratings[16];
00094 u8 reserved[42];
00095 u32 access_rights;
00096 u16 title_version;
00097 u16 num_contents;
00098 u16 boot_index;
00099 u16 fill3;
00100 tmd_content_t boot_content;
00101 } __attribute__((packed));
00102
00109 u32 boot2_run(u32 hi, u32 lo);
00114 tmd_t *boot2_tmd(void);
00115
00116 typedef struct otp_t otp_t;
00117 struct otp_t {
00118 u8 boot1_hash[20];
00119 u8 common_key[16];
00120 u32 ng_id;
00121 union {
00122 struct {
00123 u8 ng_priv[30];
00124 u8 _wtf1[18];
00125 };
00126 struct {
00127 u8 _wtf2[28];
00128 u8 nand_hmac[20];
00129 };
00130 };
00131 u8 nand_key[16];
00132 u8 rng_key[16];
00133 u32 unk1;
00134 u32 unk2;
00135 } __attribute__((packed));
00136
00137 typedef struct eep_ctr_t eep_ctr_t;
00138 struct eep_ctr_t {
00139 u8 boot2version;
00140 u8 unknown1;
00141 u8 unknown2;
00142 u8 pad;
00143 u32 update_tag;
00144 u16 checksum;
00145 } __attribute__((packed));
00146
00147 typedef struct seeprom_t seeprom_t;
00148 struct seeprom_t {
00149 union {
00150 struct {
00151 u32 ms_key_id;
00152 u32 ca_key_id;
00153 u32 ng_key_id;
00154 u8 ng_sig[60];
00155 eep_ctr_t counters[2];
00156 u8 fill[0x18];
00157 u8 korean_key[16];
00158 };
00159 u8 data[256];
00160 };
00161 } __attribute__((packed));
00162
00167 void getotp(otp_t *otp);
00172 void getseeprom(seeprom_t *seeprom);
00178 void getMiniGitVer(char *buf, u16 len);
00179
00182 void aes_reset(void);
00187 void aes_set_key(u8 *key);
00192 void aes_set_iv(u8 *iv);
00200 void aes_decrypt(u8 *src, u8 *dst, u32 blocks, u8 keep_iv);
00201
00202 void nand_reset(void);
00203 u32 nand_getid(void);
00204 u8 nand_status(void);
00205 int nand_read(u32 pageno, void *data, void *ecc);
00206 void nand_write(u32 pageno, void *data, void *ecc);
00207 void nand_erase(u32 pageno);
00208
00215 int slave_load(void* code, u32 size);
00218 void slave_execute(void);
00224 void slave_params(void* data, u32 size);
00229 void* slave_results(void);
00234 int slave_executing(void);
00235
00236
00237 #endif
00238