From 4ae42c3a9d14e577b5bdecdbabb7bf94db074ce6 Mon Sep 17 00:00:00 2001 From: Kostas Missos Date: Tue, 12 Feb 2019 00:34:35 +0200 Subject: [PATCH] Small fixes and whitespace Additionally make info functions smaller and show available fuses. --- bootloader/frontend/fe_info.c | 8 +++++++- bootloader/frontend/fe_tools.c | 11 ++++++++--- bootloader/frontend/fe_tools.h | 1 + bootloader/gfx/di.h | 4 ++++ bootloader/gfx/tui.c | 3 +-- bootloader/hos/hos.c | 4 +++- bootloader/hos/pkg2.c | 30 +++++++++++++++--------------- bootloader/ianos/ianos.c | 2 +- bootloader/mem/sdram.c | 2 +- bootloader/soc/clock.c | 10 +++++----- 10 files changed, 46 insertions(+), 29 deletions(-) diff --git a/bootloader/frontend/fe_info.c b/bootloader/frontend/fe_info.c index 68866c8..6ef12b8 100644 --- a/bootloader/frontend/fe_info.c +++ b/bootloader/frontend/fe_info.c @@ -54,6 +54,9 @@ extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_st #define WPRINTF(text) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC) #define WPRINTFARGS(text, args...) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC) +#pragma GCC push_options +#pragma GCC optimize ("Os") + void print_fuseinfo() { gfx_clear_partial_grey(&gfx_ctxt, 0x1B, 0, 1256); @@ -77,7 +80,7 @@ void print_fuseinfo() break; } gfx_printf(&gfx_con, "Sdram ID: %d\n", (fuse_read_odm(4) >> 3) & 0x1F); - gfx_printf(&gfx_con, "Burnt fuses: %d\n", burntFuses); + gfx_printf(&gfx_con, "Burnt fuses: %d / 64\n", burntFuses); gfx_printf(&gfx_con, "Secure key: %08X%08X%08X%08X\n\n\n", byte_swap_32(FUSE(FUSE_PRIVATE_KEY0)), byte_swap_32(FUSE(FUSE_PRIVATE_KEY1)), byte_swap_32(FUSE(FUSE_PRIVATE_KEY2)), byte_swap_32(FUSE(FUSE_PRIVATE_KEY3))); @@ -704,3 +707,6 @@ void bootrom_ipatches_info() btn_wait(); } } + +#pragma GCC pop_options + diff --git a/bootloader/frontend/fe_tools.c b/bootloader/frontend/fe_tools.c index 079a1f5..014c20f 100644 --- a/bootloader/frontend/fe_tools.c +++ b/bootloader/frontend/fe_tools.c @@ -553,8 +553,10 @@ void fix_battery_desync() }*/ /* -//#include "../modules/hekate_libsys_minerva/mtc.h" -//mtc_config_t mtc_cfg; +#include "../modules/hekate_libsys_minerva/mtc.h" +#include "../ianos/ianos.h" +#include "../soc/fuse.h" +mtc_config_t mtc_cfg; void minerva() { @@ -582,6 +584,9 @@ void minerva() break; } + // Change DRAM voltage. + //i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_SD1, 42); //40 = (1000 * 1100 - 600000) / 12500 -> 1.1V + mtc_cfg.rate_from = mtc_cfg.mtc_table[curr_ram_idx].rate_khz; mtc_cfg.rate_to = 800000; mtc_cfg.train_mode = OP_TRAIN_SWITCH; @@ -590,7 +595,7 @@ void minerva() // Thefollowing frequency needs periodic training every 100ms. //msleep(200); - + //mtc_cfg.rate_to = 1600000; //gfx_printf(&gfx_con, "Training and switching %7d -> %7d\n\n", mtc_cfg.current_emc_table->rate_khz, 1600000); //ianos_loader(false, "bootloader/sys/libsys_minerva.bso", DRAM_LIB, (void *)&mtc_cfg); diff --git a/bootloader/frontend/fe_tools.h b/bootloader/frontend/fe_tools.h index 5311cbd..c7035b8 100644 --- a/bootloader/frontend/fe_tools.h +++ b/bootloader/frontend/fe_tools.h @@ -23,5 +23,6 @@ void fix_sd_all_attr(); void fix_sd_nin_attr(); void fix_battery_desync(); void menu_autorcm(); +//void minerva(); #endif diff --git a/bootloader/gfx/di.h b/bootloader/gfx/di.h index f750c12..ec4bd23 100644 --- a/bootloader/gfx/di.h +++ b/bootloader/gfx/di.h @@ -238,6 +238,10 @@ #define DC_WINBUF_ADDR_H_OFFSET 0x806 #define DC_WINBUF_ADDR_V_OFFSET 0x808 #define DC_WINBUF_SURFACE_KIND 0x80B +#define PITCH (0 << 0) +#define TILED (1 << 0) +#define BLOCK (2 << 0) +#define BLOCK_HEIGHT(x) (((x) & 0x7) << 4) /*! Display serial interface registers. */ #define _DSIREG(reg) ((reg) * 4) diff --git a/bootloader/gfx/tui.c b/bootloader/gfx/tui.c index 01b9304..eba06db 100644 --- a/bootloader/gfx/tui.c +++ b/bootloader/gfx/tui.c @@ -15,13 +15,12 @@ * along with this program. If not, see . */ +#include "di.h" #include "tui.h" #include "../utils/btn.h" #include "../config/config.h" #include "../power/max17050.h" #include "../utils/util.h" -#include "../config/config.h" -#include "di.h" #ifdef MENU_LOGO_ENABLE extern u8 *Kc_MENU_LOGO; diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 3009ccf..028afae 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -503,7 +503,9 @@ int hos_launch(ini_sec_t *cfg) { gfx_printf(&gfx_con, "%kREQUESTED PATCH '%s' NOT APPLIED!%k\n", 0xFFFF0000, unappliedPatch, 0xFFCCCCCC); sd_unmount(); // Just exiting is not enough until pkg2_patch_kips stops modifying the string passed into it. - while(1) {} // MUST stop here, because if user requests 'nogc' but it's not applied, their GC controller gets updated! + + _free_launch_components(&ctxt); + return 0; // MUST stop here, because if user requests 'nogc' but it's not applied, their GC controller gets updated! } // Rebuild and encrypt package2. diff --git a/bootloader/hos/pkg2.c b/bootloader/hos/pkg2.c index fdf4647..724fa52 100644 --- a/bootloader/hos/pkg2.c +++ b/bootloader/hos/pkg2.c @@ -571,7 +571,7 @@ int pkg2_decompress_kip(pkg2_kip1_info_t* ki, u32 sectsToDecomp) memcpy(&hdr, ki->kip1, sizeof(hdr)); unsigned int newKipSize = sizeof(hdr); - for (u32 sectIdx=0; sectIdxdata; const unsigned char* srcDataPtr = ki->kip1->data; - for (u32 sectIdx=0; sectIdx= MAX_NUM_PATCHES_REQUESTED) return "too_many_patches"; } @@ -656,10 +656,10 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames) } u32 patchesApplied = 0; // Bitset over patches. - for (u32 i=0; i=0; chIdx--) + for (int chIdx=valueLen - 1; chIdx >= 0; chIdx--) { const char* p = patches[i] + chIdx; if (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') @@ -684,11 +684,11 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames) DPRINTF("Requested patch: '%s'\n", patches[i]); } - u32 shaBuf[32/sizeof(u32)]; + u32 shaBuf[32 / sizeof(u32)]; LIST_FOREACH_ENTRY(pkg2_kip1_info_t, ki, info, link) { shaBuf[0] = 0; // sha256 for this kip not yet calculated. - for (u32 currKipIdx=0; currKipIdx<(sizeof(_kip_ids)/sizeof(_kip_ids[0])); currKipIdx++) + for (u32 currKipIdx = 0; currKipIdx < (sizeof(_kip_ids) / sizeof(_kip_ids[0])); currKipIdx++) { if (strncmp((const char*)ki->kip1->name, _kip_ids[currKipIdx].name, sizeof(ki->kip1->name)) != 0) continue; @@ -697,7 +697,7 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames) kip1_patchset_t* currPatchset = _kip_ids[currKipIdx].patchset; while (currPatchset != NULL && currPatchset->name != NULL) { - for (u32 i=0; iname, patches[i]) != 0) { @@ -728,7 +728,7 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames) { if (currPatchset->patches != NULL) { - for (u32 currEnabIdx=0; currEnabIdxname, patches[currEnabIdx])) continue; @@ -752,13 +752,13 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames) if (!se_calc_sha256(shaBuf, ki->kip1, ki->size)) memset(shaBuf, 0, sizeof(shaBuf)); - DPRINTF("%dms %s KIP1 size %d hash %08X\n", (postDecompTime-preDecompTime)/1000, ki->kip1->name, (int)ki->size, __builtin_bswap32(shaBuf[0])); + DPRINTF("%dms %s KIP1 size %d hash %08X\n", (postDecompTime-preDecompTime) / 1000, ki->kip1->name, (int)ki->size, __builtin_bswap32(shaBuf[0])); #endif currPatchset = _kip_ids[currKipIdx].patchset; while (currPatchset != NULL && currPatchset->name != NULL) { - for (u32 currEnabIdx=0; currEnabIdxname, patches[currEnabIdx])) continue; @@ -772,7 +772,7 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames) } unsigned char* kipSectData = ki->kip1->data; - for (u32 currSectIdx=0; currSectIdx