Compare commits

..

7 Commits
v1.6 ... v1.5

Author SHA1 Message Date
Kostas Missos
867977e416 Add v1.5 color changes and logo 2018-05-21 13:28:02 +03:00
Kostas Missos
5f39808923 Update to version 1.5 + add jsaowji's 3.0.0 support 2018-05-21 13:26:03 +03:00
Kostas Missos
b842342790 [Tools] Dump in 1GB parts if sd <=8GB + tui tweak
Tui tweak:
Support auto scroll.
2018-05-21 11:43:56 +03:00
Kostas Missos
5ec3efbff6 [Main] Remove redundant
And change some divisions into bitshifting
2018-05-21 11:35:55 +03:00
Kostas Missos
8cf3b62443 [Tools+Info] Utilize sd_save_to_file 2018-05-19 02:05:28 +03:00
Kostas Missos
7c90abcb06 [Main] Use printf macros to reduce clutter 2018-05-19 02:04:05 +03:00
Kostas Missos
5ae9f5655a [FatFS] Add error printing for important functions
So much needed
2018-05-19 02:01:39 +03:00
8 changed files with 90 additions and 197 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
.vs
.vscode
build_ipl/*
/ipl.bin

View File

@@ -34,24 +34,9 @@ u32 btn_read()
u32 btn_wait()
{
u32 res = 0, btn = btn_read();
int pwr = 0;
// Power button down, raise a filter.
if (btn & BTN_POWER)
{
pwr = 1;
btn &= 0xFFFFFFFE;
}
do
{
res = btn_read();
// Power button up, remove filter.
if (!(res & BTN_POWER) && pwr)
pwr = 0;
// Power button still down.
else if (pwr)
res &= 0xFFFFFFFE;
} while (btn == res);
return res;
}

View File

@@ -1,5 +1,7 @@
#define SZ_HEKATE_LOGO 36024
const unsigned char Kc_HEKATE_LOGO[SZ_HEKATE_LOGO] =
#define SZ_CTC_LOGO 36024
const u16 LOGO_WIDTH = 158;
const u16 LOGO_HEIGHT = 76;
const unsigned char CTC_LOGO[SZ_CTC_LOGO] =
{
0x1B,0x1B,0x1B,0x1B, 0x1B,0x1B,0x1B,0x1B, 0x1B,0x1B,0x1B,0x1B, 0x1B,0x1B,0x1B,0x1B,
0x1B,0x1B,0x1B,0x1B, 0x1B,0x1B,0x1B,0x1B, 0x1B,0x1B,0x1B,0x1B, 0x1B,0x1B,0x1B,0x1B,

View File

@@ -87,7 +87,7 @@ void gfx_con_init(gfx_con_t *con, gfx_ctxt_t *ctxt)
con->gfx_ctxt = ctxt;
con->x = 0;
con->y = 0;
con->fgcol = 0xFFCCCCCC;
con->fgcol = 0xFFFFFFFF;
con->fillbg = 0;
con->bgcol = 0xFF1B1B1B;
}
@@ -308,12 +308,13 @@ void gfx_line(gfx_ctxt_t *ctxt, int x0, int y0, int x1, int y1, u32 color)
}
}
void gfx_set_logo(gfx_ctxt_t *ctxt, const u8 *buf)
void gfx_set_logo(gfx_ctxt_t *ctxt, u16 pos_x, u16 pos_y,
const u16 size_x, const u16 size_y, const u8 *buf)
{
u32 pos = 0;
for (u32 y = 1180; y < 1256; y++)
for (u32 y = pos_y; y < pos_y + size_y; y++)
{
for (u32 x = 538; x < 696; x++)
for (u32 x = pos_x; x < pos_x + size_x; x++)
{
ctxt->fb[x + y*ctxt->stride] = (0xFF << 24) | buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16);
pos+=3;

View File

@@ -50,6 +50,6 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len);
void gfx_set_pixel(gfx_ctxt_t *ctxt, u32 x, u32 y, u32 color);
void gfx_line(gfx_ctxt_t *ctxt, int x0, int y0, int x1, int y1, u32 color);
void gfx_set_logo(gfx_ctxt_t *ctxt, const u8 *buf);
void gfx_set_logo(gfx_ctxt_t *ctxt, u16 pos_x, u16 pos_y, const u16 size_x, const u16 size_y, const u8 *buf);
#endif

View File

@@ -53,8 +53,8 @@ gfx_ctxt_t gfx_ctxt;
gfx_con_t gfx_con;
//TODO: Create more macros (info, header, debug, etc) with different colors and utilize them for consistency.
#define EPRINTF(text) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFF0000FF, 0xFFCCCCCC)
#define EPRINTFARGS(text, args...) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFF0000FF, args, 0xFFCCCCCC)
#define EPRINTF(text) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFF0000FF, 0xFFFFFFFF)
#define EPRINTFARGS(text, args...) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFF0000FF, args, 0xFFFFFFFF)
//TODO: ugly.
sdmmc_t sd_sdmmc;
@@ -339,16 +339,19 @@ void print_fuseinfo()
gfx_clear(&gfx_ctxt, 0xFF1B1B1B);
gfx_con_setpos(&gfx_con, 0, 0);
gfx_printf(&gfx_con, "%k(Unlocked) fuse cache:\n\n%k", 0xFFFF9955, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%k(Unlocked) fuse cache:\n\n%k", 0xFFFF9955, 0xFFFFFFFF);
gfx_hexdump(&gfx_con, 0x7000F900, (u8 *)0x7000F900, 0x2FC);
gfx_puts(&gfx_con, "\nPress POWER to dump them to SD Card.\nPress VOL to go to the menu.\n");
sleep(1000000);
u32 btn = btn_wait();
if (btn & BTN_POWER)
{
if (sd_mount())
{
FIL fuseFp;
char fuseFilename[9];
memcpy(fuseFilename, "fuse.bin", 8);
fuseFilename[8] = 0;
@@ -358,7 +361,7 @@ void print_fuseinfo()
else
gfx_puts(&gfx_con, "\nDone!\n");
}
sleep(2000000);
btn_wait();
}
}
@@ -368,7 +371,7 @@ void print_kfuseinfo()
gfx_clear(&gfx_ctxt, 0xFF1B1B1B);
gfx_con_setpos(&gfx_con, 0, 0);
gfx_printf(&gfx_con, "%kKFuse contents:\n\n%k", 0xFFFF9955, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kKFuse contents:\n\n%k", 0xFFFF9955, 0xFFFFFFFF);
u32 buf[KFUSE_NUM_WORDS];
if (!kfuse_read(buf))
EPRINTF("CRC fail.");
@@ -377,11 +380,14 @@ void print_kfuseinfo()
gfx_puts(&gfx_con, "\nPress POWER to dump them to SD Card.\nPress VOL to go to the menu.\n");
sleep(1000000);
u32 btn = btn_wait();
if (btn & BTN_POWER)
{
if (sd_mount())
{
FIL kfuseFp;
char kfuseFilename[10];
memcpy(kfuseFilename, "kfuse.bin", 9);
kfuseFilename[9] = 0;
@@ -391,7 +397,7 @@ void print_kfuseinfo()
else
gfx_puts(&gfx_con, "\nDone!\n");
}
sleep(2000000);
btn_wait();
}
}
@@ -416,7 +422,7 @@ void print_mmc_info()
u16 card_type;
u32 speed;
gfx_printf(&gfx_con, "%kCard IDentification:%k\n", 0xFFFFDD00, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kCard IDentification:%k\n", 0xFFFFDD00, 0xFFFFFFFF);
switch (storage.csd.mmca_vsn)
{
case 0: /* MMC v1.0 - v1.2 */
@@ -460,7 +466,7 @@ void print_mmc_info()
else
{
gfx_printf(&gfx_con, "%kExtended Card-Specific Data V1.%d:%k\n",
0xFFFFDD00, storage.ext_csd.ext_struct, 0xFFCCCCCC);
0xFFFFDD00, storage.ext_csd.ext_struct, 0xFFFFFFFF);
card_type = storage.ext_csd.card_type;
u8 card_type_support[96];
u8 pos_type = 0;
@@ -509,16 +515,16 @@ void print_mmc_info()
u32 boot_size = storage.ext_csd.boot_mult << 17;
u32 rpmb_size = storage.ext_csd.rpmb_mult << 17;
gfx_printf(&gfx_con, "%keMMC Partitions:%k\n", 0xFFFFDD00, 0xFFCCCCCC);
gfx_printf(&gfx_con, " 1: %kBOOT0 %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF00FF96, 0xFFCCCCCC,
gfx_printf(&gfx_con, "%keMMC Partitions:%k\n", 0xFFFFDD00, 0xFFFFFFFF);
gfx_printf(&gfx_con, " 1: %kBOOT0 %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF00FF96, 0xFFFFFFFF,
boot_size / 1024, boot_size / 1024 / 512);
gfx_printf(&gfx_con, " 2: %kBOOT1 %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF00FF96, 0xFFCCCCCC,
gfx_printf(&gfx_con, " 2: %kBOOT1 %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF00FF96, 0xFFFFFFFF,
boot_size / 1024, boot_size / 1024 / 512);
gfx_printf(&gfx_con, " 3: %kRPMB %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF00FF96, 0xFFCCCCCC,
gfx_printf(&gfx_con, " 3: %kRPMB %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF00FF96, 0xFFFFFFFF,
rpmb_size / 1024, rpmb_size / 1024 / 512);
gfx_printf(&gfx_con, " 0: %kGPP (USER) %kSize: %05d MiB (LBA Sectors: 0x%07X)\n\n", 0xFF00FF96, 0xFFCCCCCC,
gfx_printf(&gfx_con, " 0: %kGPP (USER) %kSize: %05d MiB (LBA Sectors: 0x%07X)\n\n", 0xFF00FF96, 0xFFFFFFFF,
storage.sec_cnt >> SECTORS_TO_MIB_COEFF, storage.sec_cnt);
gfx_printf(&gfx_con, "%kGPP (eMMC USER) partition table:%k\n", 0xFFFFDD00, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kGPP (eMMC USER) partition table:%k\n", 0xFFFFDD00, 0xFFFFFFFF);
sdmmc_storage_set_mmc_partition(&storage, 0);
LIST_INIT(gpt);
@@ -526,15 +532,15 @@ void print_mmc_info()
int gpp_idx = 0;
LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link)
{
gfx_printf(&gfx_con, " %02d: %k%s%k\n Size: % 5d MiB (LBA Sectors 0x%07X, LBA Range: %08X-%08X)\n",
gpp_idx++, 0xFF14FDAE, part->name, 0xFFCCCCCC, (part->lba_end - part->lba_start + 1) >> SECTORS_TO_MIB_COEFF,
part->lba_end - part->lba_start + 1, part->lba_start, part->lba_end);
gfx_printf(&gfx_con, " %02d: %k%s%k\n Size: % 5d MiB (LBA Sectors 0x%07X, LBA Range: %08X-%08X)%k\n",
gpp_idx++, 0xFF14FDAE, part->name, 0xFFFFFFFF, (part->lba_end - part->lba_start + 1) >> SECTORS_TO_MIB_COEFF,
part->lba_end - part->lba_start + 1, part->lba_start, part->lba_end, 0xFFFFFFFF);
}
}
}
out:
sdmmc_storage_end(&storage);
sleep(1000000);
btn_wait();
}
@@ -550,7 +556,7 @@ void print_sdcard_info()
{
u32 capacity;
gfx_printf(&gfx_con, "%kCard IDentification:%k\n", 0xFFFFDD00, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kCard IDentification:%k\n", 0xFFFFDD00, 0xFFFFFFFF);
gfx_printf(&gfx_con,
" Vendor ID: %02x\n\
OEM ID: %c%c\n\
@@ -565,7 +571,7 @@ void print_sdcard_info()
sd_storage.cid.hwrev, sd_storage.cid.fwrev, sd_storage.cid.serial,
sd_storage.cid.month, sd_storage.cid.year);
gfx_printf(&gfx_con, "%kCard-Specific Data V%d.0:%k\n", 0xFFFFDD00, sd_storage.csd.structure + 1, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kCard-Specific Data V%d.0:%k\n", 0xFFFFDD00, sd_storage.csd.structure + 1, 0xFFFFFFFF);
capacity = sd_storage.csd.capacity >> (20 - sd_storage.csd.read_blkbits);
gfx_printf(&gfx_con,
" Cmd Classes: %02X\n\
@@ -582,11 +588,13 @@ void print_sdcard_info()
gfx_puts(&gfx_con, "Acquiring FAT volume info...\n\n");
f_getfree("", &sd_fs.free_clst, NULL);
gfx_printf(&gfx_con, "%kFound %s volume:%k\n Free: %d MiB\n Cluster: %d KiB\n",
0xFFFFDD00, sd_fs.fs_type == FS_EXFAT ? "exFAT" : "FAT32", 0xFFCCCCCC,
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, (sd_fs.csize > 1) ? (sd_fs.csize >> 1) : 512);
gfx_printf(&gfx_con, "%kFound %s volume:%k\n Free: %d MiB\n Cluster: %d B\n",
0xFFFFDD00, sd_fs.fs_type == FS_EXFAT ? "exFAT" : "FAT32", 0xFFFFFFFF,
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, sd_fs.csize * 512);
}
sleep(1000000);
btn_wait();
}
@@ -617,7 +625,7 @@ void print_tsec_key()
u8 key[0x10];
int res = tsec_query(key, i, pkg1 + pkg1_id->tsec_off);
gfx_printf(&gfx_con, "%kTSEC key %d: %k", 0xFFFF9955, i, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kTSEC key %d: %k", 0xFFFF9955, i, 0xFFFFFFFF);
if (res >= 0)
{
for (u32 i = 0; i < 0x10; i++)
@@ -631,8 +639,7 @@ void print_tsec_key()
out:;
free(pkg1);
sdmmc_storage_end(&storage);
gfx_puts(&gfx_con, "\nPress any key...\n");
sleep(1000000);
btn_wait();
}
@@ -694,7 +701,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
{
isSmallSdCard = 1;
gfx_printf(&gfx_con, "%k\nSD card free space is smaller than dump total size.%k\n", 0xFF00BAFF, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%k\nSD card free space is smaller than dump total size.%k\n", 0xFF00BAFF, 0xFFFFFFFF);
if (!maxSplitParts)
{
@@ -706,7 +713,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
// Check if we continuing a previous raw eMMC dump in progress.
if (f_open(&partialIdxFp, partialIdxFilename, FA_READ) == FR_OK)
{
gfx_printf(&gfx_con, "%kFound partial dump in progress. Continuing...%k\n\n", 0xFF14FDAE, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kFound partial dump in progress. Continuing...%k\n\n", 0xFF14FDAE, 0xFFFFFFFF);
partialDumpInProgress = 1;
// Force partial dumping, even if the card is larger.
@@ -725,8 +732,8 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
// Increase maxSplitParts to accommodate previously dumped parts
maxSplitParts += currPartIdx;
}
else if (isSmallSdCard)
gfx_printf(&gfx_con, "%kPartial dumping enabled (with %d MiB parts)...%k\n\n", 0xFF00BAFF, multipartSplitSize >> 20, 0xFFCCCCCC);
else
gfx_printf(&gfx_con, "%kPartial dumping enabled (with %d MiB parts)...%k\n\n", 0xFF00BAFF, multipartSplitSize >> 20, 0xFFFFFFFF);
// Check if filesystem is FAT32 or the free space is smaller and dump in parts
if (((sd_fs.fs_type != FS_EXFAT) && totalSectors > (FAT32_FILESIZE_LIMIT / NX_EMMC_BLOCKSIZE)) | isSmallSdCard)
@@ -847,7 +854,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
u32 num = MIN(totalSectors, NUM_SECTORS_PER_ITER);
while(!sdmmc_storage_read(storage, lba_curr, num, buf))
{
EPRINTFARGS("Error reading %d blocks @ LBA %08X from eMMC (try %d), retrying...",
EPRINTFARGS("Error reading %d blocks @ LBA %08X from eMMC (try %d)",
num, lba_curr, ++retryCount);
sleep(500000);
@@ -952,7 +959,7 @@ static void dump_emmc_selected(dumpType_t dumpType)
bootPart.name[5] = 0;
gfx_printf(&gfx_con, "%k%02d: %s (%08X-%08X)%k\n", 0xFFFFDD00, i,
bootPart.name, bootPart.lba_start, bootPart.lba_end, 0xFFCCCCCC);
bootPart.name, bootPart.lba_start, bootPart.lba_end, 0xFFFFFFFF);
sdmmc_storage_set_mmc_partition(&storage, i+1);
res = dump_emmc_part(bootPart.name, &storage, &bootPart);
@@ -975,7 +982,7 @@ static void dump_emmc_selected(dumpType_t dumpType)
continue;
gfx_printf(&gfx_con, "%k%02d: %s (%08X-%08X)%k\n", 0xFFFFDD00, i++,
part->name, part->lba_start, part->lba_end, 0xFFCCCCCC);
part->name, part->lba_start, part->lba_end, 0xFFFFFFFF);
res = dump_emmc_part(part->name, &storage, part);
}
@@ -992,7 +999,7 @@ static void dump_emmc_selected(dumpType_t dumpType)
strcpy(rawPart.name, "rawnand.bin");
{
gfx_printf(&gfx_con, "%k%02d: %s (%08X-%08X)%k\n", 0xFFFFDD00, i++,
rawPart.name, rawPart.lba_start, rawPart.lba_end, 0xFFCCCCCC);
rawPart.name, rawPart.lba_start, rawPart.lba_end, 0xFFFFFFFF);
res = dump_emmc_part(rawPart.name, &storage, &rawPart);
}
@@ -1000,12 +1007,13 @@ static void dump_emmc_selected(dumpType_t dumpType)
}
gfx_putc(&gfx_con, '\n');
gfx_printf(&gfx_con, "%kTime taken: %d seconds.%k\n", 0xFF00FF96, (get_tmr() - timer) / 1000000, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kTime taken: %d seconds.%k\n", 0xFF00FF96, (get_tmr() - timer) / 1000000, 0xFFFFFFFF);
sdmmc_storage_end(&storage);
if (res)
gfx_puts(&gfx_con, "\nDone. Press any key.\n");
out:;
sleep(1000000);
btn_wait();
}
@@ -1057,40 +1065,40 @@ void dump_package1()
pkg1_unpack(warmboot, secmon, pkg1_id, pkg1);
// display info
gfx_printf(&gfx_con, "%kSecure monitor addr: %k%08X\n", 0xFF46EAC7, 0xFFCCCCCC, pkg1_id->secmon_base);
gfx_printf(&gfx_con, "%kSecure monitor size: %k%08X\n", 0xFF46EAC7, 0xFFCCCCCC, hdr->sm_size);
gfx_printf(&gfx_con, "%kSecure monitor ofst: %k%08X\n", 0xFF46EAC7, 0xFFCCCCCC, hdr->sm_off);
gfx_printf(&gfx_con, "%kSecure monitor addr: %08X\n", 0xFF00FFA8, pkg1_id->secmon_base);
gfx_printf(&gfx_con, "%kSecure monitor size: %08X\n", 0xFF00FFA8, hdr->sm_size);
gfx_printf(&gfx_con, "%kSecure monitor off: %08X\n", 0xFF00FFA8, hdr->sm_off);
// dump package1
if (sd_save_to_file(pkg1, 0x40000, "pkg_decr.bin")) {
EPRINTF("\nFailed to create pkg_decr.bin");
gfx_printf(&gfx_con, "Failed to create pkg_decr.bin\n");
goto out;
}
gfx_puts(&gfx_con, "\npackage1 dumped to pkg_decr.bin\n");
gfx_puts(&gfx_con, "%kpackage1 dumped to pkg_decr.bin\n");
// dump sm
if (sd_save_to_file(secmon, 0x40000, "sm.bin")) {
EPRINTF("\nFailed to create sm.bin");
gfx_puts(&gfx_con, "Failed to create sm.bin\n");
goto out;
}
gfx_puts(&gfx_con, "Secure Monitor dumped to sm.bin\n");
// dump warmboot
if (sd_save_to_file(warmboot, 0x40000, "warmboot.bin")) {
EPRINTF("\nFailed to create warmboot.bin");
gfx_puts(&gfx_con, "Failed to create warmboot.bin\n");
goto out;
}
gfx_puts(&gfx_con, "Warmboot dumped to warmboot.bin\n");
sdmmc_storage_end(&storage);
gfx_puts(&gfx_con, "\nDone. Press any key.\n");
gfx_puts(&gfx_con, "Done. Press any key.\n");
out:;
free(pkg1);
free(secmon);
free(warmboot);
sleep(1000000);
btn_wait();
}
@@ -1135,14 +1143,11 @@ void launch_firmware()
free(ments);
}
else
EPRINTF("Could not find or open 'hekate_ipl.ini' from SD Card!\nMake sure it exists.");
EPRINTF("Failed to load 'hekate_ipl.ini'.");
}
if (!cfg_sec)
{
sleep(3000000);
gfx_printf(&gfx_con, "Using default launch configuration...\n");
}
gfx_printf(&gfx_con, "Using default launch configuration.\n");
if (!hos_launch(cfg_sec))
EPRINTF("Failed to launch firmware.");
@@ -1150,36 +1155,7 @@ void launch_firmware()
//TODO: free ini.
out:;
btn_wait();
}
void toggle_autorcm(){
sdmmc_storage_t storage;
sdmmc_t sdmmc;
if(!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
{
EPRINTF("Failed to init eMMC.");
goto out;
}
u8 *tempbuf = (u8 *)malloc(0x200);
sdmmc_storage_set_mmc_partition(&storage, 1);
int i, sect = 0;
for (i = 0; i < 4; i++)
{
sect = (0x200 + (0x4000 * i)) / NX_EMMC_BLOCKSIZE;
sdmmc_storage_read(&storage, sect, 1, tempbuf);
tempbuf[0x10] ^= 0x77; //xor by arbitrary number to corrupt
sdmmc_storage_write(&storage, sect, 1, tempbuf);
}
free(tempbuf);
sdmmc_storage_end(&storage);
gfx_printf(&gfx_con, "%kAutoRCM mode toggled!%k\n", 0xFF00EE2C, 0xFFCCCCCC);
out:;
sleep(200000);
btn_wait();
}
@@ -1214,21 +1190,18 @@ void about()
gfx_clear(&gfx_ctxt, 0xFF1B1B1B);
gfx_con_setpos(&gfx_con, 0, 0);
gfx_printf(&gfx_con, octopus, 0xFFFFCC00, 0xFFCCCCCC,
0xFFFFCC00, 0xFFCCFF00, 0xFFFFCC00, 0xFFCCCCCC);
gfx_printf(&gfx_con, octopus, 0xFFFFCC00, 0xFFFFFFFF,
0xFFFFCC00, 0xFFCCFF00, 0xFFFFCC00, 0xFFFFFFFF);
sleep(1000000);
btn_wait();
}
ment_t ment_cinfo[] = {
MDEF_BACK(),
MDEF_CHGLINE(),
MDEF_CAPTION("---- SoC Info ----", 0xFFE6B90A),
MDEF_HANDLER("Print fuse info", print_fuseinfo),
MDEF_HANDLER("Print kfuse info", print_kfuseinfo),
MDEF_HANDLER("Print TSEC keys", print_tsec_key),
MDEF_CHGLINE(),
MDEF_CAPTION("-- Storage Info --", 0xFFE6B90A),
MDEF_HANDLER("Print eMMC info", print_mmc_info),
MDEF_HANDLER("Print SD Card info", print_sdcard_info),
MDEF_END()
@@ -1238,44 +1211,15 @@ menu_t menu_cinfo = {
"Console info", 0, 0
};
ment_t ment_autorcm[] = {
MDEF_CAPTION("WARNING: This corrupts your BOOT0 partition!", 0xFF00FFE6),
MDEF_BACK(),
MDEF_BACK(),
MDEF_BACK(),
MDEF_BACK(),
MDEF_HANDLER("Toggle AutoRCM", toggle_autorcm),
MDEF_BACK(),
MDEF_BACK(),
MDEF_BACK(),
MDEF_BACK(),
MDEF_END()
};
menu_t menu_autorcm = {
ment_autorcm,
"AutoRCM", 0, 0
};
ment_t ment_tools[] = {
MDEF_BACK(),
MDEF_CHGLINE(),
MDEF_CAPTION("------ Full --------", 0xFFE6B90A),
MDEF_HANDLER("Dump RAW eMMC", dump_emmc_rawnand),
MDEF_HANDLER("Dump eMMC BOOT", dump_emmc_boot),
MDEF_CHGLINE(),
MDEF_CAPTION("-- GP Partitions --", 0xFFE6B90A),
MDEF_HANDLER("Dump eMMC SYS", dump_emmc_system),
MDEF_HANDLER("Dump eMMC USER", dump_emmc_user),
MDEF_CHGLINE(),
MDEF_CAPTION("------ Misc -------", 0xFFE6B90A),
MDEF_HANDLER("Dump eMMC BOOT", dump_emmc_boot),
MDEF_HANDLER("Dump package1", dump_package1),
MDEF_CHGLINE(),
MDEF_CAPTION("---- Dangerous ----", 0xFF0000FF),
MDEF_MENU("AutoRCM", &menu_autorcm),
MDEF_END()
};
menu_t menu_tools = {
ment_tools,
"Tools", 0, 0
@@ -1283,20 +1227,17 @@ menu_t menu_tools = {
ment_t ment_top[] = {
MDEF_HANDLER("Launch firmware", launch_firmware),
MDEF_CAPTION("---------------", 0xFF444444),
MDEF_MENU("Tools", &menu_tools),
MDEF_MENU("Console info", &menu_cinfo),
MDEF_CAPTION("---------------", 0xFF444444),
MDEF_HANDLER("Reboot (Normal)", reboot_normal),
MDEF_HANDLER("Reboot (RCM)", reboot_rcm),
MDEF_HANDLER("Reboot (normal)", reboot_normal),
MDEF_HANDLER("Reboot (rcm)", reboot_rcm),
MDEF_HANDLER("Power off", power_off),
MDEF_CAPTION("---------------", 0xFF444444),
MDEF_HANDLER("About", about),
MDEF_END()
};
menu_t menu_top = {
ment_top,
"hekate - ipl (CTCaer mod v1.6)", 0, 0
"hekate - ipl (CTCaer mod v1.5)", 0, 0
};
extern void pivot_stack(u32 stack_top);

View File

@@ -16,7 +16,7 @@
#include "tui.h"
#include "btn.h"
#include "ctc_logo2.h"
#include "ctc_logo.h"
void tui_pbar(gfx_con_t *con, int x, int y, u32 val)
{
@@ -42,58 +42,30 @@ void tui_pbar(gfx_con_t *con, int x, int y, u32 val)
void *tui_do_menu(gfx_con_t *con, menu_t *menu)
{
int idx = 0, cnt;
int prev_idx = 0;
gfx_clear(con->gfx_ctxt, 0xFF1B1B1B);
gfx_set_logo(con->gfx_ctxt, Kc_HEKATE_LOGO);
gfx_set_logo(con->gfx_ctxt, 538, 1180, LOGO_WIDTH, LOGO_HEIGHT, CTC_LOGO);
while (1)
{
gfx_con_setcol(con, 0xFFCCCCCC, 1, 0xFF1B1B1B);
gfx_con_setcol(con, 0xFFFFFFFF, 1, 0xFF1B1B1B);
gfx_con_setpos(con, menu->x, menu->y);
gfx_printf(con, "[%s]\n\n", menu->caption);
// Skip caption or seperator lines selection
while (menu->ents[idx].type == MENT_CAPTION ||
menu->ents[idx].type == MENT_CHGLINE)
{
if (prev_idx <= idx || (!idx && prev_idx == cnt - 1))
{
idx++;
if (idx > (cnt - 1))
{
idx = 0;
prev_idx = 0;
}
}
else
{
idx--;
if (idx < 0)
{
idx = cnt - 1;
prev_idx = cnt;
}
}
}
prev_idx = idx;
// Draw the menu
for (cnt = 0; menu->ents[cnt].type != MENT_END; cnt++)
{
if (cnt == idx)
gfx_con_setcol(con, 0xFF1B1B1B, 1, 0xFFCCCCCC);
gfx_con_setcol(con, 0xFF000000, 1, 0xFFCCCCCC);
else
gfx_con_setcol(con, 0xFFCCCCCC, 1, 0xFF1B1B1B);
if (cnt != idx && menu->ents[cnt].type == MENT_CAPTION)
gfx_printf(con, "%k %s", menu->ents[cnt].color, menu->ents[cnt].caption);
else
gfx_printf(con, " %s", menu->ents[cnt].caption);
gfx_con_setcol(con, 0xFFFFFFFF, 1, 0xFF1B1B1B);
con->x += 8;
gfx_printf(con, "%s", menu->ents[cnt].caption);
if(menu->ents[cnt].type == MENT_MENU)
gfx_printf(con, "%k...", 0xFFEE9900);
gfx_printf(con, " \n");
gfx_putc(con, '\n');
}
gfx_con_setcol(con, 0xFFCCCCCC, 1, 0xFF1B1B1B);
gfx_con_setcol(con, 0xFFFFFFFF, 1, 0xFF1B1B1B);
gfx_putc(con, '\n');
u32 btn = btn_wait();
@@ -123,11 +95,9 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
case MENT_BACK:
return NULL;
break;
default:
break;
}
gfx_clear(con->gfx_ctxt, 0xFF1B1B1B);
gfx_set_logo(con->gfx_ctxt, Kc_HEKATE_LOGO);
gfx_set_logo(con->gfx_ctxt, 538, 1180, LOGO_WIDTH, LOGO_HEIGHT, CTC_LOGO);
}
}

View File

@@ -20,19 +20,16 @@
#include "types.h"
#include "gfx.h"
#define MENT_END 0
#define MENT_END 0
#define MENT_HANDLER 1
#define MENT_MENU 2
#define MENT_CHOICE 3
#define MENT_BACK 4
#define MENT_CAPTION 5
#define MENT_CHGLINE 6
#define MENT_MENU 2
#define MENT_CHOICE 3
#define MENT_BACK 4
typedef struct _ment_t
{
u32 type;
const char *caption;
u32 color;
void *data;
union
{
@@ -50,12 +47,10 @@ typedef struct _menu_t
} menu_t;
#define MDEF_END() {MENT_END}
#define MDEF_HANDLER(caption, _handler) { MENT_HANDLER, caption, 0, NULL, { .handler = _handler } }
#define MDEF_HANDLER_EX(caption, data, _handler) { MENT_HANDLER, caption, 0, data, { .handler = _handler } }
#define MDEF_MENU(caption, _menu) { MENT_MENU, caption, 0, NULL, { .menu = _menu } }
#define MDEF_HANDLER(caption, _handler) { MENT_HANDLER, caption, NULL, { .handler = _handler } }
#define MDEF_HANDLER_EX(caption, data, _handler) { MENT_HANDLER, caption, data, { .handler = _handler } }
#define MDEF_MENU(caption, _menu) { MENT_MENU, caption, NULL, { .menu = _menu } }
#define MDEF_BACK() { MENT_BACK, "Back" }
#define MDEF_CAPTION(caption, color) { MENT_CAPTION, caption, color }
#define MDEF_CHGLINE() {MENT_CHGLINE}
void tui_pbar(gfx_con_t *con, int x, int y, u32 val);
void *tui_do_menu(gfx_con_t *con, menu_t *menu);