Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
add 8.0 kern patches
  • Loading branch information
Reisyukaku committed Apr 20, 2019
1 parent bd4ba9f commit 9186c4bf31cdfbc8a0a63160f9e966535e453e3c
Showing with 35 additions and 4 deletions.
  1. +1 −1 src/firmware.c
  2. +1 −0 src/hwinit/sdmmc_driver.c
  3. +10 −2 src/package.c
  4. +23 −1 src/package.h
@@ -144,7 +144,7 @@ u8 loadFirm() {
patchKernelExtensions(&kip1_info);

// Build Package2.
buildFirmwarePackage(dec_pkg2->data, dec_pkg2->sec_size[PKG2_SEC_KERNEL], &kip1_info);
buildFirmwarePackage(dec_pkg2->data, dec_pkg2->sec_size[PKG2_SEC_KERNEL], &kip1_info, pk11Offs);
}

static void SE_lock() {
@@ -1027,6 +1027,7 @@ void sdmmc_end(sdmmc_t *sdmmc)
{
gpio_output_enable(GPIO_PORT_E, GPIO_PIN_4, GPIO_OUTPUT_DISABLE);
musleep(1); // To power cycle min 1ms without power is needed.
max77620_regulator_enable(REGULATOR_LDO2, 0);
}

_sdmmc_get_clkcon(sdmmc);
@@ -177,7 +177,7 @@ bool hasCustomKern() {
return customKernel;
}

void buildFirmwarePackage(u8 *kernel, u32 kernel_size, link_t *kips_info) {
void buildFirmwarePackage(u8 *kernel, u32 kernel_size, link_t *kips_info, pk11_offs *pk11Offs) {
u8 *pdst = (u8 *)0xA9800000;
bool hasCustSecmon = hasCustomSecmon();

@@ -199,6 +199,7 @@ void buildFirmwarePackage(u8 *kernel, u32 kernel_size, link_t *kips_info) {
memcpy(pdst, extKern == NULL ? kernel : extKern, extKern == NULL ? kernel_size : extSize);
hdr->sec_size[PKG2_SEC_KERNEL] = kernel_size;
hdr->sec_off[PKG2_SEC_KERNEL] = 0x10000000;

if(!hasCustSecmon)
se_aes_crypt_ctr(8, pdst, kernel_size, pdst, kernel_size, &hdr->sec_ctr[PKG2_SEC_KERNEL * 0x10]);
pdst += kernel_size;
@@ -221,7 +222,6 @@ void buildFirmwarePackage(u8 *kernel, u32 kernel_size, link_t *kips_info) {
hdr->sec_off[PKG2_SEC_INI1] = 0x14080000;
if (!hasCustSecmon)
se_aes_crypt_ctr(8, ini1, ini1_size, ini1, ini1_size, &hdr->sec_ctr[PKG2_SEC_INI1 * 0x10]);

// Encrypt header.
*(u32 *)hdr->ctr = 0x100 + sizeof(pkg2_hdr_t) + kernel_size + ini1_size;
if (!hasCustSecmon)
@@ -357,6 +357,10 @@ u32 *getSndPayload(u32 id, size_t *size) {
*size = sizeof(PRC_ID_SND_700);
ret = PRC_ID_SND_700;
break;
case 8:
*size = sizeof(PRC_ID_SND_800);
ret = PRC_ID_SND_800;
break;
}
return ret;
}
@@ -396,6 +400,10 @@ u32 *getRcvPayload(u32 id, size_t *size) {
*size = sizeof(PRC_ID_RCV_700);
ret = PRC_ID_RCV_700;
break;
case 8:
*size = sizeof(PRC_ID_RCV_800);
ret = PRC_ID_RCV_800;
break;
}
return ret;
}
@@ -216,6 +216,17 @@ static u32 PRC_ID_RCV_700[] =
0xA9BF2FEA, 0xF9404FEB, 0x2A1603EA, 0xD37EF54A, 0xF86A696A, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000100, 0xA9BF27E8, 0xF9400368, 0xF9401D08, 0xAA1B03E0, 0xD63F0100, 0xA8C127E8, 0xAA0003E8, 0xA8C12FEA, 0xAA0803E0
};

static u32 PRC_ID_SND_800[] =
{
0xA9BF2FEA, 0xF9403BEB, 0x2A1903EA, 0xD37EF54A, 0xF86A696A, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000100, 0xA9BF27E8, 0xF94002A8, 0xF9401D08, 0xAA1503E0, 0xD63F0100, 0xA8C127E8, 0xAA0003E8, 0xA8C12FEA, 0xAA0803E0
};

static u32 PRC_ID_RCV_800[] =
{
0xA9BF2FEA, 0xF9404FEB, 0x2A1603EA, 0xD37EF54A, 0xF86A696A, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000100, 0xA9BF27E8, 0xF9400368, 0xF9401D08, 0xAA1B03E0, 0xD63F0100, 0xA8C127E8, 0xAA0003E8, 0xA8C12FEA, 0xAA0803E0
};


extern kippatchset_t kip_patches[];

typedef struct {
@@ -318,6 +329,17 @@ static const KernelMeta kernelInfo[] = {
0x10,
0x10
},
{ //8.0.0
{0x24, 0x2A, 0x50, 0x42, 0xFC, 0x6C, 0x0A, 0x64, 0xE7, 0xC2, 0x16, 0x0F, 0xD8, 0x53, 0x1E, 0xFC,
0x5C, 0x25, 0xCA, 0xC0, 0x5A, 0xED, 0x01, 0xA7, 0xE3, 0x11, 0x78, 0x6C, 0x07, 0x10, 0x32, 0xA1},
0x4D15C,
0x5BFAC,
0x2F1FC,
0x2D424,
0x3FAD0,
0x10,
0x10
},
};

u8 *ReadBoot0(sdmmc_storage_t *storage);
@@ -328,7 +350,7 @@ int kippatch_apply_set(u8 *kipdata, u64 kipdata_len, kippatchset_t *patchset);
kippatchset_t *kippatch_find_set(u8 *kiphash, kippatchset_t *patchsets);
pkg2_hdr_t *unpackFirmwarePackage(u8 *data);
void pkg1_unpack(pk11_offs *offs, u32 pkg1Off);
void buildFirmwarePackage(u8 *kernel, u32 kernel_size, link_t *kips_info);
void buildFirmwarePackage(u8 *kernel, u32 kernel_size, link_t *kips_info, pk11_offs *pk11Offs);
size_t calcKipSize(pkg2_kip1_t *kip1);
void pkg2_parse_kips(link_t *info, pkg2_hdr_t *pkg2);
bool hasCustomKern();

1 comment on commit 9186c4b

@lavaJockey

This comment has been minimized.

Copy link

@lavaJockey lavaJockey commented on 9186c4b Apr 20, 2019

Can't wait for 8.0 Support!

Please sign in to comment.