hekate/nyx: remove coreboot support
Everything external is finally updated and beyond parity with old things that needed it.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* L4T Loader for Tegra X1
|
||||
*
|
||||
* Copyright (c) 2020-2025 CTCaer
|
||||
* Copyright (c) 2020-2026 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -271,7 +271,7 @@ typedef struct _l4t_ctxt_t
|
||||
int ram_oc_opt;
|
||||
|
||||
u32 serial_port;
|
||||
u32 sld_type;
|
||||
bool sld_type;
|
||||
|
||||
u32 sc7entry_size;
|
||||
|
||||
@@ -863,7 +863,7 @@ static void _l4t_set_config(l4t_ctxt_t *ctxt, const ini_sec_t *ini_sec, int entr
|
||||
char val[4] = {0};
|
||||
|
||||
// Set default SLD type.
|
||||
ctxt->sld_type = BL_MAGIC_L4TLDR_SLD;
|
||||
ctxt->sld_type = true;
|
||||
|
||||
// Parse ini section and prepare BL33 env.
|
||||
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
|
||||
@@ -899,7 +899,7 @@ static void _l4t_set_config(l4t_ctxt_t *ctxt, const ini_sec_t *ini_sec, int entr
|
||||
else if (!strcmp("uart_port", kv->key))
|
||||
ctxt->serial_port = atoi(kv->val);
|
||||
else if (!strcmp("sld_type", kv->key))
|
||||
ctxt->sld_type = strtol(kv->val, NULL, 16);
|
||||
ctxt->sld_type = atoi(kv->val);
|
||||
|
||||
// Set key/val to BL33 env.
|
||||
_l4t_bl33_cfg_set_key(bl33_env, kv->key, kv->val);
|
||||
@@ -1166,7 +1166,7 @@ void launch_l4t(const ini_sec_t *ini_sec, int entry_idx, int is_list, bool t210b
|
||||
_l4t_mc_config_carveout(t210b01);
|
||||
|
||||
// Deinit any unneeded HW.
|
||||
hw_deinit(false, ctxt->sld_type);
|
||||
hw_deinit(ctxt->sld_type);
|
||||
|
||||
// Do late hardware config.
|
||||
_l4t_late_hw_config(t210b01);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2018 naehrwert
|
||||
*
|
||||
* Copyright (c) 2018-2025 CTCaer
|
||||
* Copyright (c) 2018-2026 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -97,29 +97,17 @@ static void _check_power_off_from_hos()
|
||||
#define PATCHED_RELOC_ENTRY 0x40010000
|
||||
#define EXT_PAYLOAD_ADDR 0xC0000000
|
||||
#define RCM_PAYLOAD_ADDR (EXT_PAYLOAD_ADDR + ALIGN(PATCHED_RELOC_SZ, 0x10))
|
||||
#define COREBOOT_END_ADDR 0xD0000000
|
||||
#define COREBOOT_VER_OFF 0x41
|
||||
#define CBFS_DRAM_EN_ADDR 0x4003E000
|
||||
#define CBFS_DRAM_MAGIC 0x4452414D // "DRAM"
|
||||
|
||||
static void *coreboot_addr;
|
||||
|
||||
static void _reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size)
|
||||
static void _reloc_append(u32 payload_dst, u32 payload_src, u32 payload_size)
|
||||
{
|
||||
memcpy((u8 *)payload_src, (u8 *)IPL_LOAD_ADDR, PATCHED_RELOC_SZ);
|
||||
|
||||
reloc_meta_t *relocator = (reloc_meta_t *)(payload_src + RELOC_META_OFF);
|
||||
volatile reloc_meta_t *relocator = (reloc_meta_t *)(payload_src + RELOC_META_OFF);
|
||||
|
||||
relocator->start = payload_dst - ALIGN(PATCHED_RELOC_SZ, 0x10);
|
||||
relocator->stack = PATCHED_RELOC_STACK;
|
||||
relocator->end = payload_dst + payload_size;
|
||||
relocator->ep = payload_dst;
|
||||
|
||||
if (payload_size == 0x7000)
|
||||
{
|
||||
memcpy((u8 *)(payload_src + ALIGN(PATCHED_RELOC_SZ, 0x10)), coreboot_addr, 0x7000); // Bootblock.
|
||||
*(vu32 *)CBFS_DRAM_EN_ADDR = CBFS_DRAM_MAGIC;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_ipl_updated(void *buf, u32 size, const char *path, bool force)
|
||||
@@ -183,67 +171,43 @@ static void _launch_payload(char *path, bool update, bool clear_screen)
|
||||
if (update && is_ipl_updated(buf, size, path, false))
|
||||
goto out;
|
||||
|
||||
|
||||
// Set payload address.
|
||||
void *payload;
|
||||
if (size < 0x30000)
|
||||
payload = (void *)RCM_PAYLOAD_ADDR;
|
||||
else
|
||||
// Check if it safely fits IRAM.
|
||||
if (size > 0x30000)
|
||||
{
|
||||
coreboot_addr = (void *)(COREBOOT_END_ADDR - size);
|
||||
payload = coreboot_addr;
|
||||
if (h_cfg.t210b01)
|
||||
{
|
||||
gfx_con.mute = false;
|
||||
EPRINTF("Coreboot not allowed on Mariko!");
|
||||
gfx_con.mute = false;
|
||||
EPRINTF("Payload is too big!");
|
||||
|
||||
goto out;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
sd_end();
|
||||
|
||||
// Copy the payload to our chosen address.
|
||||
memcpy(payload, buf, size);
|
||||
memcpy((void *)RCM_PAYLOAD_ADDR, buf, size);
|
||||
|
||||
if (size < 0x30000)
|
||||
{
|
||||
if (update)
|
||||
memcpy((u8 *)(RCM_PAYLOAD_ADDR + PATCHED_RELOC_SZ), &b_cfg, sizeof(boot_cfg_t)); // Transfer boot cfg.
|
||||
else
|
||||
_reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
|
||||
|
||||
hw_deinit(false, byte_swap_32(*(u32 *)(payload + size - sizeof(u32))));
|
||||
}
|
||||
else
|
||||
{
|
||||
_reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, 0x7000);
|
||||
|
||||
// Get coreboot seamless display magic.
|
||||
u32 magic = 0;
|
||||
char *magic_ptr = payload + COREBOOT_VER_OFF;
|
||||
memcpy(&magic, magic_ptr + strlen(magic_ptr) - 4, 4);
|
||||
hw_deinit(true, magic);
|
||||
}
|
||||
|
||||
void (*update_ptr)() = (void *)RCM_PAYLOAD_ADDR;
|
||||
void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR;
|
||||
|
||||
// Launch our payload.
|
||||
// Append relocator or set config.
|
||||
void (*payload_ptr)();
|
||||
if (!update)
|
||||
{
|
||||
// Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms.
|
||||
sdmmc_storage_init_wait_sd();
|
||||
_reloc_append(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
|
||||
|
||||
(*ext_payload_ptr)();
|
||||
payload_ptr = (void *)EXT_PAYLOAD_ADDR;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy((u8 *)(RCM_PAYLOAD_ADDR + PATCHED_RELOC_SZ), &b_cfg, sizeof(boot_cfg_t)); // Transfer boot cfg.
|
||||
|
||||
// Set updated flag to skip check on launch.
|
||||
EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD;
|
||||
(*update_ptr)();
|
||||
|
||||
payload_ptr = (void *)RCM_PAYLOAD_ADDR;
|
||||
}
|
||||
|
||||
hw_deinit(false);
|
||||
|
||||
// Launch our payload.
|
||||
(*payload_ptr)();
|
||||
|
||||
out:
|
||||
free(buf);
|
||||
if (!update)
|
||||
@@ -1354,7 +1318,7 @@ static void _r2c_get_config_t210b01()
|
||||
|
||||
static void _ipl_reload()
|
||||
{
|
||||
hw_deinit(false, 0);
|
||||
hw_deinit(false);
|
||||
|
||||
// Reload hekate.
|
||||
void (*ipl_ptr)() = (void *)IPL_LOAD_ADDR;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025 CTCaer
|
||||
* Copyright (c) 2018-2026 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -935,7 +935,7 @@ static void _launch_hos(u8 autoboot, u8 autoboot_list)
|
||||
|
||||
sd_end();
|
||||
|
||||
hw_deinit(false, 0);
|
||||
hw_deinit(false);
|
||||
|
||||
(*main_ptr)();
|
||||
}
|
||||
@@ -970,7 +970,7 @@ void reload_nyx(lv_obj_t *obj, bool force)
|
||||
|
||||
sd_end();
|
||||
|
||||
hw_deinit(false, 0);
|
||||
hw_deinit(false);
|
||||
|
||||
(*main_ptr)();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2025 CTCaer
|
||||
* Copyright (c) 2019-2026 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -1174,7 +1174,7 @@ static lv_res_t _action_reboot_recovery(lv_obj_t * btns, const char * txt)
|
||||
|
||||
// Deinit hardware.
|
||||
sd_end();
|
||||
hw_deinit(false, 0);
|
||||
hw_deinit(false);
|
||||
|
||||
// Chainload to hekate main.
|
||||
(*main_ptr)();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2018 naehrwert
|
||||
*
|
||||
* Copyright (c) 2018-2025 CTCaer
|
||||
* Copyright (c) 2018-2026 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -96,13 +96,8 @@ create_dir:
|
||||
#define PATCHED_RELOC_ENTRY 0x40010000
|
||||
#define EXT_PAYLOAD_ADDR 0xC0000000
|
||||
#define RCM_PAYLOAD_ADDR (EXT_PAYLOAD_ADDR + ALIGN(PATCHED_RELOC_SZ, 0x10))
|
||||
#define COREBOOT_END_ADDR 0xD0000000
|
||||
#define CBFS_DRAM_EN_ADDR 0x4003E000
|
||||
#define CBFS_DRAM_MAGIC 0x4452414D // "DRAM"
|
||||
|
||||
static void *coreboot_addr;
|
||||
|
||||
void reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size)
|
||||
static void _reloc_append(u32 payload_dst, u32 payload_src, u32 payload_size)
|
||||
{
|
||||
memcpy((u8 *)payload_src, (u8 *)nyx_str->hekate, PATCHED_RELOC_SZ);
|
||||
|
||||
@@ -112,12 +107,6 @@ void reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size)
|
||||
relocator->stack = PATCHED_RELOC_STACK;
|
||||
relocator->end = payload_dst + payload_size;
|
||||
relocator->ep = payload_dst;
|
||||
|
||||
if (payload_size == 0x7000)
|
||||
{
|
||||
memcpy((u8 *)(payload_src + ALIGN(PATCHED_RELOC_SZ, 0x10)), coreboot_addr, 0x7000); // Bootblock.
|
||||
*(vu32 *)CBFS_DRAM_EN_ADDR = CBFS_DRAM_MAGIC;
|
||||
}
|
||||
}
|
||||
|
||||
lv_res_t launch_payload(lv_obj_t *list)
|
||||
@@ -135,63 +124,37 @@ lv_res_t launch_payload(lv_obj_t *list)
|
||||
if (!sd_mount())
|
||||
goto out;
|
||||
|
||||
FIL fp;
|
||||
if (f_open(&fp, path, FA_READ))
|
||||
// Read payload.
|
||||
u32 size = 0;
|
||||
void *buf = sd_file_read(path, &size);
|
||||
if (!buf)
|
||||
{
|
||||
EPRINTFARGS("Payload file is missing!\n(%s)", path);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
// Read and copy the payload to our chosen address
|
||||
void *buf;
|
||||
u32 size = f_size(&fp);
|
||||
|
||||
if (size < 0x30000)
|
||||
buf = (void *)RCM_PAYLOAD_ADDR;
|
||||
else
|
||||
// Check if it safely fits IRAM.
|
||||
if (size > 0x30000)
|
||||
{
|
||||
coreboot_addr = (void *)(COREBOOT_END_ADDR - size);
|
||||
buf = coreboot_addr;
|
||||
if (h_cfg.t210b01)
|
||||
{
|
||||
f_close(&fp);
|
||||
|
||||
EPRINTF("Coreboot not allowed on Mariko!");
|
||||
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (f_read(&fp, buf, size, NULL))
|
||||
{
|
||||
f_close(&fp);
|
||||
EPRINTF("Payload is too big!");
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
f_close(&fp);
|
||||
|
||||
sd_end();
|
||||
|
||||
if (size < 0x30000)
|
||||
{
|
||||
reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
|
||||
hw_deinit(false, byte_swap_32(*(u32 *)(buf + size - sizeof(u32))));
|
||||
}
|
||||
else
|
||||
{
|
||||
reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, 0x7000);
|
||||
hw_deinit(true, 0);
|
||||
}
|
||||
// Copy the payload to our chosen address.
|
||||
memcpy((void *)RCM_PAYLOAD_ADDR, buf, size);
|
||||
|
||||
void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR;
|
||||
// Append relocator.
|
||||
_reloc_append(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
|
||||
|
||||
// Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms.
|
||||
sdmmc_storage_init_wait_sd();
|
||||
hw_deinit(false);
|
||||
|
||||
// Launch our payload.
|
||||
(*ext_payload_ptr)();
|
||||
void (*payload_ptr)() = (void *)EXT_PAYLOAD_ADDR;
|
||||
(*payload_ptr)();
|
||||
|
||||
out:
|
||||
sd_unmount();
|
||||
|
||||
Reference in New Issue
Block a user