Compare commits

..

7 Commits
v2.0 ... 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
12 changed files with 139 additions and 324 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

@@ -26,7 +26,7 @@
#include "gfx.h"
extern gfx_ctxt_t gfx_ctxt;
extern gfx_con_t gfx_con;
#define EFSPRINTF(text, ...) gfx_printf(&gfx_con, "\n\n\n%k[FatFS] "text"%k\n", 0xFF00FFFF, 0xFFFFFFFF)
#define EFSPRINTF(text, ...) gfx_printf(&gfx_con, "\n\n%k[FatFS] "text"%k\n", 0xFF00FFFF, 0xFFFFFFFF)
//#define EFSPRINTF(...)
/*--------------------------------------------------------------------------

View File

@@ -82,21 +82,14 @@ void gfx_clear(gfx_ctxt_t *ctxt, u32 color)
ctxt->fb[i] = color;
}
void gfx_con_setfontsz(gfx_con_t *con, u8 font_size)
{
con->fntsz = font_size;
con->fontmult = font_size / 8;
}
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;
gfx_con_setfontsz(con, 16);
}
void gfx_con_setcol(gfx_con_t *con, u32 fgcol, int fillbg, u32 bgcol)
@@ -124,45 +117,27 @@ void gfx_putc(gfx_con_t *con, char c)
{
u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)];
u32 *fb = con->gfx_ctxt->fb + con->x + con->y * con->gfx_ctxt->stride;
for (u32 i = 0; i < con->fntsz; i+=con->fontmult)
for (u32 i = 0; i < 8; i++)
{
u8 v = *cbuf++;
for (u32 k = 0; k < con->fontmult; k++)
for (u32 j = 0; j < 8; j++)
{
for (u32 j = 0; j < con->fntsz; j+=con->fontmult)
{
if (v & 1)
{
*fb = con->fgcol;
for(u32 l = 0; l < con->fontmult - 1; l++)
{
fb++;
*fb = con->fgcol;
}
}
else if (con->fillbg)
{
*fb = con->bgcol;
for(u32 l = 0; l < con->fontmult - 1; l++)
{
fb++;
*fb = con->bgcol;
}
}
v >>= 1;
fb++;
}
fb += con->gfx_ctxt->stride - con->fntsz;
v = *cbuf;
if (v & 1)
*fb = con->fgcol;
else if (con->fillbg)
*fb = con->bgcol;
v >>= 1;
fb++;
}
fb += con->gfx_ctxt->stride - 8;
}
con->x += con->fntsz;
con->x += 8;
}
else if (c == '\n')
{
con->x = 0;
con->y += con->fntsz;
if (con->y > con->gfx_ctxt->height - con->fntsz)
con->y += 8;
if (con->y > con->gfx_ctxt->height - 8)
con->y = 0;
}
}
@@ -207,13 +182,6 @@ static void _gfx_putn(gfx_con_t *con, u32 v, int base, char fill, int fcnt)
gfx_puts(con, p);
}
void gfx_putsep(gfx_con_t *con)
{
gfx_con_setfontsz(con, 8);
gfx_putc(con, '\n');
gfx_con_setfontsz(con, 16);
}
void gfx_printf(gfx_con_t *con, const char *fmt, ...)
{
va_list ap;
@@ -287,8 +255,6 @@ void gfx_printf(gfx_con_t *con, const char *fmt, ...)
void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len)
{
u8 prevFontSize = con->fntsz;
gfx_con_setfontsz(con, 8);
for(u32 i = 0; i < len; i++)
{
if(i % 0x10 == 0)
@@ -311,7 +277,6 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len)
gfx_printf(con, "%02x ", buf[i]);
}
gfx_putc(con, '\n');
gfx_con_setfontsz(con, prevFontSize);
}
static int abs(int x)
@@ -343,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

@@ -35,8 +35,6 @@ typedef struct _gfx_con_t
u32 fgcol;
int fillbg;
u32 bgcol;
u32 fntsz;
u32 fontmult;
} gfx_con_t;
void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride);
@@ -45,7 +43,6 @@ void gfx_con_init(gfx_con_t *con, gfx_ctxt_t *ctxt);
void gfx_con_setcol(gfx_con_t *con, u32 fgcol, int fillbg, u32 bgcol);
void gfx_con_getpos(gfx_con_t *con, u32 *x, u32 *y);
void gfx_con_setpos(gfx_con_t *con, u32 x, u32 y);
void gfx_con_setfontsz(gfx_con_t *con, u8 font_size);
void gfx_putc(gfx_con_t *con, char c);
void gfx_puts(gfx_con_t *con, const char *s);
void gfx_printf(gfx_con_t *con, const char *fmt, ...);
@@ -53,7 +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_putsep(gfx_con_t *con);
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

@@ -145,7 +145,6 @@ int keygen(u8 *keyblob, u32 kb, void *tsec_fw)
switch (kb) {
case KB_FIRMWARE_VERSION_100_200:
case KB_FIRMWARE_VERSION_300:
case KB_FIRMWARE_VERSION_301:
se_aes_unwrap_key(0x0D, 0x0F, console_keyseed);
se_aes_unwrap_key(0x0C, 0x0C, master_keyseed_retail);
break;
@@ -213,10 +212,10 @@ static int _read_emmc_pkg1(launch_ctxt_t *ctxt)
ctxt->pkg1_id = pkg1_identify(ctxt->pkg1);
if (!ctxt->pkg1_id)
{
DPRINTF("%kCould not identify package1,\nversion (= '%s').%k\n", 0xFF0000FF, (char *)ctxt->pkg1 + 0x10, 0xFFFFFFFF);
DPRINTF("%kCould not identify package 1 version (= '%s').%k\n", 0xFF0000FF, (char *)ctxt->pkg1 + 0x10, 0xFFFFFFFF);
goto out;
}
DPRINTF("Identified package1 ('%s'),\nkeyblob version %d\n", (char *)(ctxt->pkg1 + 0x10), ctxt->pkg1_id->kb);
DPRINTF("Identified package1 ('%s'), keyblob version %d\n", (char *)(ctxt->pkg1 + 0x10), ctxt->pkg1_id->kb);
//Read the correct keyblob.
ctxt->keyblob = (u8 *)malloc(NX_EMMC_BLOCKSIZE);
@@ -432,24 +431,22 @@ DPRINTF("decrypted and unpacked pkg1\n");
}
}
se_aes_key_clear(0x8);
se_aes_key_clear(0xB);
se_aes_key_clear(8);
se_aes_key_clear(11);
switch (ctxt.pkg1_id->kb) {
case KB_FIRMWARE_VERSION_100_200:
case KB_FIRMWARE_VERSION_300:
case KB_FIRMWARE_VERSION_301:
se_key_acc_ctrl(0xC, 0xFF);
se_key_acc_ctrl(0xD, 0xFF);
break;
se_key_acc_ctrl(12, 0xFF);
se_key_acc_ctrl(13, 0xFF);
break;
default:
case KB_FIRMWARE_VERSION_400:
case KB_FIRMWARE_VERSION_500:
se_key_acc_ctrl(0xC, 0xFF);
//se_key_acc_ctrl(0xD, 0xFF);
//se_key_acc_ctrl(0xE, 0xFF);
se_key_acc_ctrl(0xF, 0xFF);
break;
se_key_acc_ctrl(12, 0xFF);
se_key_acc_ctrl(15, 0xFF);
break;
}
//Clear 'BootConfig'.

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;
@@ -69,7 +69,7 @@ int sd_mount()
if (!sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11))
{
EPRINTF("Failed to init SD card.\nMake sure that it is inserted.");
EPRINTF("Failed to init SD card (make sure that it is inserted).");
}
else
{
@@ -82,7 +82,7 @@ int sd_mount()
}
else
{
EPRINTFARGS("Failed to mount SD card (FatFS Error %d).\n(make sure that a FAT type partition exists)", res);
EPRINTFARGS("Failed to mount SD card (FatFS Error %d).\n(make sure that a FAT32/exFAT partition exists)", res);
}
}
@@ -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", 0xFFFFDD00, 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", 0xFFFFDD00, 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;
@@ -503,30 +509,22 @@ void print_mmc_info()
Cmd Classes: %02X\n\
Capacity: %s\n\
Max Speed: %d MB/s (%d MHz)\n\
Type Support: ",
Type Support: %s\n\n",
storage.csd.mmca_vsn, storage.ext_csd.rev, storage.ext_csd.dev_version, storage.csd.cmdclass,
storage.csd.capacity == (4096 * 512) ? "High" : "Low", speed & 0xFFFF, (speed >> 16) & 0xFFFF);
gfx_con_setfontsz(&gfx_con, 8);
gfx_printf(&gfx_con, "%s", card_type_support);
gfx_con_setfontsz(&gfx_con, 16);
gfx_printf(&gfx_con, "\n\n", card_type_support);
storage.csd.capacity == (4096 * 512) ? "High" : "Low", speed & 0xFFFF, (speed >> 16) & 0xFFFF, card_type_support);
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 %k\n Size: %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_putsep(&gfx_con);
gfx_printf(&gfx_con, " 2: %kBOOT1 %k\n Size: %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_putsep(&gfx_con);
gfx_printf(&gfx_con, " 3: %kRPMB %k\n Size: %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_putsep(&gfx_con);
gfx_printf(&gfx_con, " 0: %kGPP (USER) %k\n Size: %5d 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_putsep(&gfx_con);
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);
@@ -534,16 +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)\n 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_putsep(&gfx_con);
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();
}
@@ -559,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\
@@ -574,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\
@@ -591,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();
}
@@ -616,7 +615,6 @@ void print_tsec_key()
const pkg1_id_t *pkg1_id = pkg1_identify(pkg1);
if (!pkg1_id)
{
gfx_con_setfontsz(&gfx_con, 8);
EPRINTFARGS("Could not identify package1 version to read TSEC firmware (= '%s').",
(char *)pkg1 + 0x10);
goto out;
@@ -627,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", 0xFFFFDD00, i, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%kTSEC key %d: %k", 0xFFFF9955, i, 0xFFFFFFFF);
if (res >= 0)
{
for (u32 i = 0; i < 0x10; i++)
@@ -641,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();
}
@@ -689,8 +686,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
memcpy(partialIdxFilename, "partial.idx", 11);
partialIdxFilename[11] = 0;
gfx_con_setfontsz(&gfx_con, 8);
gfx_printf(&gfx_con, "\nSD Card free space: %d MiB, Total dump size %d MiB\n\n",
gfx_printf(&gfx_con, "SD Card free space: %d MiB, Total dump size %d MiB\n",
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF,
totalSectors >> SECTORS_TO_MIB_COEFF);
@@ -705,11 +701,10 @@ 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)
{
gfx_con_setfontsz(&gfx_con, 16);
EPRINTF("Not enough free space for partial dumping.");
return 0;
@@ -718,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.
@@ -729,7 +724,6 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
if (!maxSplitParts)
{
gfx_con_setfontsz(&gfx_con, 16);
EPRINTF("Not enough free space for partial dumping.");
return 0;
@@ -738,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)
@@ -778,8 +772,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
FIL fp;
if (f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
gfx_con_setfontsz(&gfx_con, 16);
EPRINTFARGS("Error creating file %s.\n", outFilename);
EPRINTFARGS("Error creating file %s.", outFilename);
return 0;
}
@@ -826,8 +819,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
}
else
{
gfx_con_setfontsz(&gfx_con, 16);
EPRINTF("\nError creating partial.idx file.\n");
EPRINTF("\nError creating partial.idx file.");
free(buf);
return 0;
@@ -841,7 +833,6 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
Don\'t move the partial.idx file!\n\
3. Unplug and re-plug USB while pressing Vol+.\n\
4. Run hekate - ipl again and press Dump RAW eMMC or eMMC USER to continue\n");
gfx_con_setfontsz(&gfx_con, 16);
free(buf);
return 1;
@@ -851,8 +842,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
// Create next part
if (f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
gfx_con_setfontsz(&gfx_con, 16);
EPRINTFARGS("Error creating file %s.\n", outFilename);
EPRINTFARGS("Error creating file %s.", outFilename);
free(buf);
return 0;
@@ -864,16 +854,14 @@ 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(150000);
if (retryCount >= 3)
sleep(500000);
if (retryCount >= 10)
{
gfx_con_setfontsz(&gfx_con, 16);
EPRINTFARGS("\nFailed to read %d blocks @ LBA %08X\nfrom eMMC. Aborting..\n",
EPRINTFARGS("\nFailed to read %d blocks @ LBA %08X from eMMC. Aborting..",
num, lba_curr);
EPRINTF("\nPress any key and try again.\n");
free(buf);
f_close(&fp);
@@ -883,9 +871,8 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
res = f_write(&fp, buf, NX_EMMC_BLOCKSIZE * num, NULL);
if (res)
{
gfx_con_setfontsz(&gfx_con, 16);
EPRINTFARGS("\nFatal error (%d) when writing to SD Card", res);
EPRINTF("\nPress any key and try again.\n");
EPRINTF("\nPress any key and try again.");
free(buf);
f_close(&fp);
@@ -914,14 +901,13 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
out:;
free(buf);
f_close(&fp);
gfx_con_setfontsz(&gfx_con, 16);
// Remove partial dump index file if no fatal errors occurred.
if(isSmallSdCard)
{
f_unlink(partialIdxFilename);
gfx_printf(&gfx_con, "\n\nYou can now join the files\nand get the complete raw eMMC dump.");
gfx_printf(&gfx_con, "\n\nYou can now join the files and get the complete raw eMMC dump.");
}
gfx_puts(&gfx_con, "\n\n");
gfx_putc(&gfx_con, '\n');
return 1;
}
@@ -972,8 +958,8 @@ static void dump_emmc_selected(dumpType_t dumpType)
bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0;
gfx_printf(&gfx_con, "%k%02d: %s (%07X-%07X)%k\n", 0xFFFFDD00, i,
bootPart.name, bootPart.lba_start, bootPart.lba_end, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%k%02d: %s (%08X-%08X)%k\n", 0xFFFFDD00, i,
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);
@@ -995,8 +981,8 @@ static void dump_emmc_selected(dumpType_t dumpType)
if ((dumpType & DUMP_SYSTEM) == 0 && strcmp(part->name, "USER"))
continue;
gfx_printf(&gfx_con, "%k%02d: %s (%07X-%07X)%k\n", 0xFFFFDD00, i++,
part->name, part->lba_start, part->lba_end, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%k%02d: %s (%08X-%08X)%k\n", 0xFFFFDD00, i++,
part->name, part->lba_start, part->lba_end, 0xFFFFFFFF);
res = dump_emmc_part(part->name, &storage, part);
}
@@ -1012,8 +998,8 @@ static void dump_emmc_selected(dumpType_t dumpType)
rawPart.lba_end = RAW_AREA_NUM_SECTORS-1;
strcpy(rawPart.name, "rawnand.bin");
{
gfx_printf(&gfx_con, "%k%02d: %s (%07X-%07X)%k\n", 0xFFFFDD00, i++,
rawPart.name, rawPart.lba_start, rawPart.lba_end, 0xFFCCCCCC);
gfx_printf(&gfx_con, "%k%02d: %s (%08X-%08X)%k\n", 0xFFFFDD00, i++,
rawPart.name, rawPart.lba_start, rawPart.lba_end, 0xFFFFFFFF);
res = dump_emmc_part(rawPart.name, &storage, &rawPart);
}
@@ -1021,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();
}
@@ -1062,7 +1049,6 @@ void dump_package1()
const pk11_hdr_t *hdr = (pk11_hdr_t *)(pkg1 + pkg1_id->pkg11_off + 0x20);
if (!pkg1_id)
{
gfx_con_setfontsz(&gfx_con, 8);
EPRINTFARGS("Could not identify package1 version to read TSEC firmware (= '%s').", (char *)pkg1 + 0x10);
goto out;
}
@@ -1079,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();
}
@@ -1157,14 +1143,11 @@ void launch_firmware()
free(ments);
}
else
EPRINTF("Could not find or open 'hekate_ipl.ini'.\nMake sure it exists in SD Card!.");
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.");
@@ -1172,42 +1155,12 @@ 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();
}
void about()
{
gfx_con_setfontsz(&gfx_con, 8);
static const char octopus[] =
"hekate (c) 2018 naehrwert, st4rk\n\n"
"Thanks to: %kderrek, nedwill, plutoo, shuffle2, smea, thexyz, yellows8%k\n\n"
@@ -1237,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()
@@ -1261,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
@@ -1306,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 v2.0)", 0, 0
"hekate - ipl (CTCaer mod v1.5)", 0, 0
};
extern void pivot_stack(u32 stack_top);

View File

@@ -80,7 +80,7 @@ static const pkg1_id_t _pkg1_ids[] = {
{ "20161121183008", 0, 0x1900, 0x3FE0, { 2, 1, 0 }, 0x40014020, _secmon_1_patchset }, //1.0.0
{ "20170210155124", 0, 0x1900, 0x3FE0, { 0, 1, 2 }, 0x4002D000, _secmon_2_patchset }, //2.0.0
{ "20170519101410", 1, 0x1A00, 0x3FE0, { 0, 1, 2 }, 0x4002D000, _secmon_3_patchset }, //3.0.0
{ "20170710161758", 2, 0x1A00, 0x3FE0, { 0, 1, 2 }, 0x4002D000, _secmon_3_patchset }, //3.0.1
{ "20170710161758", 2, 0x1A00, 0x3FE0, { 0, 1, 2 }, 0x4002D000, NULL }, //3.0.1
{ "20170921172629", 3, 0x1800, 0x3FE0, { 1, 2, 0 }, 0x4002B000, _secmon_5_patchset }, //4.0.0
{ "20180220163747", 4, 0x1900, 0x3FE0, { 1, 2, 0 }, 0x4002B000, _secmon_6_patchset }, //5.0.0
{ NULL, 0, 0, 0, 0 } //End.

View File

@@ -165,27 +165,15 @@ static int _sdmmc_storage_readwrite(sdmmc_storage_t *storage, u32 sector, u32 nu
while (num_sectors)
{
u32 blkcnt = 0;
//Retry 9 times on error.
u32 retries = 10;
do
{
if (_sdmmc_storage_readwrite_ex(storage, &blkcnt, sector, MIN(num_sectors, 0xFFFF), bbuf, is_write))
goto out;
else
retries--;
sleep(500000);
} while (retries);
return 0;
out:;
//Retry once on error.
if (!_sdmmc_storage_readwrite_ex(storage, &blkcnt, sector, MIN(num_sectors, 0xFFFF), bbuf, is_write))
if (!_sdmmc_storage_readwrite_ex(storage, &blkcnt, sector, MIN(num_sectors, 0xFFFF), bbuf, is_write))
return 0;
DPRINTF("readwrite: %08X\n", blkcnt);
sector += blkcnt;
num_sectors -= blkcnt;
bbuf += 512 * blkcnt;
}
return 1;
}
int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf)

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)
{
@@ -28,12 +28,12 @@ void tui_pbar(gfx_con_t *con, int x, int y, u32 val)
gfx_printf(con, "[%3d%%]", val);
x += 7 * con->fntsz;
x += 7 * 8;
for (int i = 0; i < con->fontmult * 6; i++)
for (int i = 0; i < 6; i++)
{
gfx_line(con->gfx_ctxt, x, y + i + 1, x + 3 * val, y + i + 1, 0xFFCCCCCC);
gfx_line(con->gfx_ctxt, x + 3 * val, y + i + 1, x + 3 * 100, y + i + 1, 0xFF555555);
gfx_line(con->gfx_ctxt, x, y + i + 1, x + 3 * val, y + i + 1, 0xFFFFFFFF);
gfx_line(con->gfx_ctxt, x + 3 * val, y + i + 1, x + 3 * 100, y + i + 1, 0xFF888888);
}
gfx_con_setpos(con, cx, cy);
@@ -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,12 +95,9 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
case MENT_BACK:
return NULL;
break;
default:
break;
}
gfx_con_setfontsz(con, 16);
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);