diff --git a/Makefile b/Makefile index 1fde66c..e77d092 100755 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ include $(DEVKITARM)/base_rules ################################################################################ IPL_LOAD_ADDR := 0x40008000 -NYX_STORAGE_ADDR := 0xED000000 IPL_MAGIC := 0x43544349 #"ICTC" BLVERSION_MAJOR := 5 BLVERSION_MINOR := 0 @@ -60,7 +59,7 @@ OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \ ################################################################################ -CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR) -DNYX_STORAGE_ADDR=$(NYX_STORAGE_ADDR) -DBL_MAGIC=$(IPL_MAGIC) +CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR) -DBL_MAGIC=$(IPL_MAGIC) CUSTOMDEFINES += -DBL_VER_MJ=$(BLVERSION_MAJOR) -DBL_VER_MN=$(BLVERSION_MINOR) -DBL_VER_HF=$(BLVERSION_HOTFX) -DBL_RESERVED=$(BL_RESERVED) #CUSTOMDEFINES += -DMENU_LOGO_ENABLE diff --git a/bootloader/frontend/fe_emmc_tools.c b/bootloader/frontend/fe_emmc_tools.c index c80a6e6..bd32137 100644 --- a/bootloader/frontend/fe_emmc_tools.c +++ b/bootloader/frontend/fe_emmc_tools.c @@ -20,6 +20,7 @@ #include #include "fe_emmc_tools.h" +#include "../../common/memory_map.h" #include "../config/config.h" #include "../gfx/gfx.h" #include "../gfx/tui.h" @@ -31,10 +32,6 @@ #include "../utils/btn.h" #include "../utils/util.h" -#define EMMC_BUF_ALIGNED 0xB5000000 -#define SDXC_BUF_ALIGNED 0xB6000000 -#define MIXD_BUF_ALIGNED 0xB7000000 - #define NUM_SECTORS_PER_ITER 8192 // 4MB Cache. #define OUT_FILENAME_SZ 128 #define SHA256_SZ 0x20 diff --git a/bootloader/gfx/di.c b/bootloader/gfx/di.c index 5d84f60..200d412 100644 --- a/bootloader/gfx/di.c +++ b/bootloader/gfx/di.c @@ -254,7 +254,6 @@ void display_color_screen(u32 color) DISPLAY_A(_DIREG(DC_WIN_CD_WIN_OPTIONS)) = 0; DISPLAY_A(_DIREG(DC_DISP_BLEND_BACKGROUND_COLOR)) = color; DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = (DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) & 0xFFFFFFFE) | GENERAL_ACT_REQ; - usleep(35000); display_backlight(true); @@ -263,11 +262,12 @@ void display_color_screen(u32 color) u32 *display_init_framebuffer() { // Sanitize framebuffer area. - memset((u32 *)FB_ADDRESS, 0, 0x3C0000); + memset((u32 *)IPL_FB_ADDRESS, 0, 0x3C0000); + // This configures the framebuffer @ IPL_FB_ADDRESS with a resolution of 1280x720 (line stride 720). exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer, 32); usleep(35000); - return (u32 *)FB_ADDRESS; + return (u32 *)IPL_FB_ADDRESS; } diff --git a/bootloader/gfx/di.h b/bootloader/gfx/di.h index 2d5c54d..ee796a7 100644 --- a/bootloader/gfx/di.h +++ b/bootloader/gfx/di.h @@ -18,10 +18,9 @@ #ifndef _DI_H_ #define _DI_H_ +#include "../../common/memory_map.h" #include "../utils/types.h" -#define FB_ADDRESS 0xC0000000 - /*! Display registers. */ #define _DIREG(reg) ((reg) * 4) diff --git a/bootloader/gfx/di.inl b/bootloader/gfx/di.inl index f8a32df..dd82899 100644 --- a/bootloader/gfx/di.inl +++ b/bootloader/gfx/di.inl @@ -548,7 +548,7 @@ static const cfg_op_t cfg_display_framebuffer[32] = { {DC_WIN_LINE_STRIDE, UV_LINE_STRIDE(720 * 2) | LINE_STRIDE(720 * 4)}, //768*2x768*4 (= 0x600 x 0xC00) bytes, see TRM for alignment requirements. {DC_WIN_BUFFER_CONTROL, 0}, {DC_WINBUF_SURFACE_KIND, 0}, //Regular surface. - {DC_WINBUF_START_ADDR, FB_ADDRESS}, //Framebuffer address. + {DC_WINBUF_START_ADDR, IPL_FB_ADDRESS}, // Framebuffer address. {DC_WINBUF_ADDR_H_OFFSET, 0}, {DC_WINBUF_ADDR_V_OFFSET, 0}, {DC_WIN_WIN_OPTIONS, 0}, diff --git a/bootloader/libs/fatfs/diskio.c b/bootloader/libs/fatfs/diskio.c index c35d39f..803dc91 100644 --- a/bootloader/libs/fatfs/diskio.c +++ b/bootloader/libs/fatfs/diskio.c @@ -8,12 +8,12 @@ /*-----------------------------------------------------------------------*/ #include + +#include "../../../common/memory_map.h" + #include "diskio.h" /* FatFs lower layer API */ #include "../../storage/sdmmc.h" -#define SDMMC_UPPER_BUFFER 0xB8000000 -#define DRAM_START 0x80000000 - extern sdmmc_storage_t sd_storage; /*-----------------------------------------------------------------------*/ diff --git a/bootloader/main.c b/bootloader/main.c index beefffd..4d05bb1 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -19,6 +19,8 @@ #include #include +#include "../common/memory_map.h" + #include "config/config.h" #include "gfx/di.h" #include "gfx/gfx.h" @@ -1232,10 +1234,6 @@ ment_t ment_top[] = { menu_t menu_top = { ment_top, "hekate - CTCaer mod v5.0.2", 0, 0 }; -#define IPL_STACK_TOP 0x90010000 -#define IPL_HEAP_START 0x90020000 -#define IPL_HEAP_END 0xB5000000 - extern void pivot_stack(u32 stack_top); void ipl_main() diff --git a/bootloader/mem/sdram.c b/bootloader/mem/sdram.c index 6126d3b..a9a26d3 100644 --- a/bootloader/mem/sdram.c +++ b/bootloader/mem/sdram.c @@ -19,6 +19,7 @@ #include "mc.h" #include "emc.h" #include "sdram_param_t210.h" +#include "../../common/memory_map.h" #include "../power/max77620.h" #include "../power/max7762x.h" #include "../soc/clock.h" @@ -647,7 +648,7 @@ break_nosleep: sdram_params_t *sdram_get_params() { #ifdef CONFIG_SDRAM_COMPRESS_CFG - u8 *buf = (u8 *)0x40030000; + u8 *buf = (u8 *)SDRAM_PARAMS_ADDR; LZ_Uncompress(_dram_cfg_lz, buf, sizeof(_dram_cfg_lz)); return (sdram_params_t *)&buf[sizeof(sdram_params_t) * _get_sdram_id()]; #else diff --git a/bootloader/soc/bpmp.c b/bootloader/soc/bpmp.c index c68f903..94ce6d5 100644 --- a/bootloader/soc/bpmp.c +++ b/bootloader/soc/bpmp.c @@ -19,6 +19,7 @@ #include "bpmp.h" #include "clock.h" #include "t210.h" +#include "../../common/memory_map.h" #include "../utils/util.h" #define BPMP_CACHE_CONFIG 0x0 @@ -74,8 +75,8 @@ bpmp_mmu_entry_t mmu_entries[] = { - { 0x80000000, 0xFFFFFFFF, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }, - { IPL_LOAD_ADDR, 0x40040000, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true } + { DRAM_START, 0xFFFFFFFF, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }, + { IRAM_BASE, 0x4003FFFF, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true } }; void bpmp_mmu_maintenance(u32 op, bool force) diff --git a/bootloader/storage/sdmmc.c b/bootloader/storage/sdmmc.c index 0eb4e39..d75e609 100644 --- a/bootloader/storage/sdmmc.c +++ b/bootloader/storage/sdmmc.c @@ -19,6 +19,7 @@ #include "sdmmc.h" #include "mmc.h" #include "sd.h" +#include "../../common/memory_map.h" #include "../gfx/gfx.h" #include "../mem/heap.h" #include "../utils/util.h" @@ -1064,6 +1065,7 @@ void sdmmc_storage_init_wait_sd() int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type) { int is_version_1 = 0; + u8 *buf = (u8 *)SDMMC_UPPER_BUFFER; // Some cards (SanDisk U1), do not like a fast power cycle. Wait min 100ms. sdmmc_storage_init_wait_sd(); @@ -1138,13 +1140,9 @@ DPRINTF("[SD] set blocklen to 512\n"); return 0; DPRINTF("[SD] cleared card detect\n"); - u8 *buf = (u8 *)malloc(512); if (!_sd_storage_get_scr(storage, buf)) - { - free(buf); return 0; - } - + //gfx_hexdump(0, storage->raw_scr, 8); DPRINTF("[SD] got scr\n"); @@ -1152,10 +1150,8 @@ DPRINTF("[SD] got scr\n"); if (bus_width == SDMMC_BUS_WIDTH_4 && (storage->scr.bus_widths & 4) && (storage->scr.sda_vsn & 0xF)) { if (!_sd_storage_execute_app_cmd_type1(storage, &tmp, SD_APP_SET_BUS_WIDTH, SD_BUS_WIDTH_4, 0, R1_STATE_TRAN)) - { - free(buf); return 0; - } + sdmmc_set_bus_width(storage->sdmmc, SDMMC_BUS_WIDTH_4); DPRINTF("[SD] switched to wide bus width\n"); } @@ -1167,19 +1163,14 @@ DPRINTF("[SD] SD does not support wide bus width\n"); if (storage->is_low_voltage) { if (!_sd_storage_enable_uhs_low_volt(storage, type, buf)) - { - free(buf); return 0; - } DPRINTF("[SD] enabled UHS\n"); } else if (type != 6 && (storage->scr.sda_vsn & 0xF) != 0) { if (!_sd_storage_enable_hs_high_volt(storage, buf)) - { - free(buf); return 0; - } + DPRINTF("[SD] enabled HS\n"); storage->csd.busspeed = 25; } @@ -1192,7 +1183,6 @@ DPRINTF("[SD] enabled HS\n"); DPRINTF("[SD] got sd status\n"); } - free(buf); return 1; } diff --git a/common/memory_map.h b/common/memory_map.h new file mode 100644 index 0000000..06dd63f --- /dev/null +++ b/common/memory_map.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019 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, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _MEMORY_MAP_H_ +#define _MEMORY_MAP_H_ + +//#define IPL_STACK_TOP 0x4003FF00 +/* --- BIT/BCT: 0x40000000 - 0x40003000 --- */ +/* --- IPL: 0x40008000 - 0x40028000 --- */ +#define IPL_LOAD_ADDR 0x40008000 +#define IPL_SZ_MAX 0x20000 // 128KB. +//#define IRAM_LIB_ADDR 0x4002B000 +#define SDRAM_PARAMS_ADDR 0x40030000 // SDRAM extraction buffer during sdram init. +#define CBFS_DRAM_EN_ADDR 0x4003e000 // u32. + +/* --- DRAM START --- */ +#define DRAM_START 0x80000000 +/* Do not write anything in this area */ +#define NYX_LOAD_ADDR 0x81000000 +#define NYX_SZ_MAX 0x1000000 +/* Stack theoretical max: 220MB */ +#define IPL_STACK_TOP 0x90010000 +#define IPL_HEAP_START 0x90020000 +#define IPL_HEAP_SZ 0x24FE0000 // 592MB. +/* --- Gap: 0xB5000000 - 0xB5FFFFFF --- */ + +// SDMMC DMA buffers +#define SDXC_BUF_ALIGNED 0xB6000000 +#define MIXD_BUF_ALIGNED 0xB7000000 +#define EMMC_BUF_ALIGNED MIXD_BUF_ALIGNED +#define SDMMC_DMA_BUF_SZ 0x1000000 // 16MB (4MB currently used). +#define SDMMC_UPPER_BUFFER 0xB8000000 +#define SDMMC_UP_BUF_SZ 0x8000000 // 128MB. + +// Virtual disk / Chainloader buffers. +#define RAM_DISK_ADDR 0xC1000000 +#define RAM_DISK_SZ 0x20000000 +//#define DRAM_LIB_ADDR 0xE0000000 +/* --- Chnldr: 252MB 0xC03C0000 - 0xCFFFFFFF --- */ //! Only used when chainloading. +/* --- Gap: 464MB 0xD0000000 - 0xECFFFFFF --- */ + +// Nyx buffers. +#define NYX_STORAGE_ADDR 0xED000000 +#define NYX_RES_ADDR 0xEE000000 + +// Framebuffer addresses. +#define IPL_FB_ADDRESS 0xF0000000 +#define IPL_FB_SZ 0x384000 // 720 x 1280 x 4. +#define LOG_FB_ADDRESS 0xF0400000 +#define LOG_FB_SZ 0x334000 // 1280 x 656 x 4. +#define NYX_FB_ADDRESS 0xF0800000 +#define NYX_FB_SZ 0x384000 // 1280 x 720 x 4. + +// Nyx LvGL buffers. +#define NYX_LV_VDB_ADR 0xF0C00000 +#define NYX_FB_SZ 0x384000 // 1280 x 720 x 4. +#define NYX_LV_MEM_ADR 0xF1000000 +#define NYX_LV_MEM_SZ 0x8000000 + +// NX BIS driver sector cache. +#define NX_BIS_CACHE_ADDR 0xF9000000 +#define NX_BIS_CACHE_SZ 0x8800 +/* --- Gap: 111MB 0xF9008800 - 0xFFFFFFFF --- */ + +// #define EXT_PAYLOAD_ADDR 0xC03C0000 +// #define RCM_PAYLOAD_ADDR (EXT_PAYLOAD_ADDR + ALIGN(PATCHED_RELOC_SZ, 0x10)) +// #define COREBOOT_ADDR (0xD0000000 - 0x100000) + +// NYX +// #define EXT_PAYLOAD_ADDR 0xC0000000 +// #define RCM_PAYLOAD_ADDR (EXT_PAYLOAD_ADDR + ALIGN(PATCHED_RELOC_SZ, 0x10)) +// #define COREBOOT_ADDR (0xD0000000 - 0x100000) + +#endif diff --git a/nyx/Makefile b/nyx/Makefile index 0aff055..376b4f9 100644 --- a/nyx/Makefile +++ b/nyx/Makefile @@ -7,8 +7,6 @@ include $(DEVKITARM)/base_rules ################################################################################ NYX_LOAD_ADDR := 0x81000000 -NYX_RES_ADDR := 0xEE000000 -NYX_STORAGE_ADDR := 0xED000000 NYX_MAGIC := 0x43544347 #"GCTC" BLVERSION_MAJOR := 0 BLVERSION_MINOR := 8 @@ -74,7 +72,6 @@ OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \ ################################################################################ -CUSTOMDEFINES := -DNYX_RES_ADDR=$(NYX_RES_ADDR) -DNYX_STORAGE_ADDR=$(NYX_STORAGE_ADDR) CUSTOMDEFINES += -DNYX_LOAD_ADDR=$(NYX_LOAD_ADDR) -DBL_MAGIC=$(NYX_MAGIC) CUSTOMDEFINES += -DBL_VER_MJ=$(BLVERSION_MAJOR) -DBL_VER_MN=$(BLVERSION_MINOR) -DBL_VER_HF=$(BLVERSION_HOTFX) -DBL_RESERVED=$(BL_RESERVED) diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 8a9c2a3..f237a28 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -24,6 +24,7 @@ #include "gui.h" #include "fe_emmc_tools.h" #include "fe_emummc_tools.h" +#include "../../../common/memory_map.h" #include "../config/config.h" #include "../libs/fatfs/ff.h" #include "../mem/heap.h" @@ -35,10 +36,6 @@ #include "../utils/sprintf.h" #include "../utils/util.h" -#define EMMC_BUF_ALIGNED 0xB5000000 -#define SDXC_BUF_ALIGNED 0xB6000000 -#define MIXD_BUF_ALIGNED 0xB7000000 - #define NUM_SECTORS_PER_ITER 8192 // 4MB Cache. #define OUT_FILENAME_SZ 128 #define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums") diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 98834c0..d6a3d6f 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -32,10 +32,6 @@ #include "../utils/sprintf.h" #include "../utils/util.h" -#define EMMC_BUF_ALIGNED 0xB5000000 -#define SDXC_BUF_ALIGNED 0xB6000000 -#define MIXD_BUF_ALIGNED 0xB7000000 - #define NUM_SECTORS_PER_ITER 8192 // 4MB Cache. #define OUT_FILENAME_SZ 128 diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index a613ccc..81e86ab 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -40,6 +40,7 @@ #include "../soc/hw_init.h" #include "../soc/t210.h" #include "../storage/sdmmc.h" +#include "../thermal/fan.h" #include "../thermal/tmp451.h" #include "../utils/dirlist.h" #include "../utils/sprintf.h" @@ -87,7 +88,7 @@ static void _save_fb_to_bmp() const u32 file_size = 0x384000 + 0x36; u8 *bitmap = malloc(file_size); u32 *fb = malloc(0x384000); - u32 *fb_ptr = gfx_ctxt.fb; + u32 *fb_ptr = (u32 *)NYX_FB_ADDRESS; // Reconstruct FB for bottom-top, landscape bmp. for (u32 x = 0; x < 1280; x++) @@ -163,7 +164,7 @@ static void _save_fb_to_bmp() static void _disp_fb_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t *color_p) { // Draw to framebuffer. - gfx_set_rect_land_pitch(gfx_ctxt.fb, (u32 *)color_p, x1, y1, x2, y2); //pitch + gfx_set_rect_land_pitch((u32 *)NYX_FB_ADDRESS, (u32 *)color_p, x1, y1, x2, y2); //pitch // Check if display init was done. If it's the first big draw, init. if (!disp_init_done && ((x2 - x1 + 1) > 600)) diff --git a/nyx/nyx_gui/gfx/di.c b/nyx/nyx_gui/gfx/di.c index 97c4320..f7ccc4d 100644 --- a/nyx/nyx_gui/gfx/di.c +++ b/nyx/nyx_gui/gfx/di.c @@ -262,25 +262,21 @@ void display_color_screen(u32 color) u32 *display_init_framebuffer() { - // Sanitize framebuffer area. - //memset((u32 *)FB_ADDRESS, 0, 0x3C0000); - // This configures the framebuffer @ FB_ADDRESS with a resolution of 1280x720 (line stride 720). + // This configures the framebuffer @ NYX_FB_ADDRESS with a resolution of 1280x720 (line stride 720). exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer, 32); usleep(35000); - return (u32 *)FB_ADDRESS; + return (u32 *)NYX_FB_ADDRESS; } u32 *display_init_framebuffer2() { - // Sanitize framebuffer area. - memset((u32 *)FB_ADDRESS, 0, 0x3C0000); - // This configures the framebuffer @ FB_ADDRESS with a resolution of 1280x720 (line stride 720). + // This configures the framebuffer @ NYX_FB_ADDRESS with a resolution of 1280x720 (line stride 720). exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer2, 32); usleep(35000); - return (u32 *)FB_ADDRESS; + return (u32 *)NYX_FB_ADDRESS; } diff --git a/nyx/nyx_gui/gfx/di.h b/nyx/nyx_gui/gfx/di.h index fe5fe04..10c1e85 100644 --- a/nyx/nyx_gui/gfx/di.h +++ b/nyx/nyx_gui/gfx/di.h @@ -18,10 +18,9 @@ #ifndef _DI_H_ #define _DI_H_ +#include "../../../common/memory_map.h" #include "../utils/types.h" -#define FB_ADDRESS 0xF0800000 - /*! Display registers. */ #define _DIREG(reg) ((reg) * 4) diff --git a/nyx/nyx_gui/gfx/di.inl b/nyx/nyx_gui/gfx/di.inl index d6ad3bf..7ec0115 100644 --- a/nyx/nyx_gui/gfx/di.inl +++ b/nyx/nyx_gui/gfx/di.inl @@ -548,7 +548,7 @@ static const cfg_op_t cfg_display_framebuffer[32] = { {DC_WIN_LINE_STRIDE, UV_LINE_STRIDE(720 * 2) | LINE_STRIDE(720 * 4)}, //768*2x768*4 (= 0x600 x 0xC00) bytes, see TRM for alignment requirements. {DC_WIN_BUFFER_CONTROL, 0}, {DC_WINBUF_SURFACE_KIND, 0}, //Regular surface. - {DC_WINBUF_START_ADDR, FB_ADDRESS}, //Framebuffer address. + {DC_WINBUF_START_ADDR, NYX_FB_ADDRESS}, // Framebuffer address. {DC_WINBUF_ADDR_H_OFFSET, 0}, //Linear: 0x383FFC, Block: 0x3813FC {DC_WINBUF_ADDR_V_OFFSET, 1279}, //Linear: 1279, Block: 0 {DC_WIN_WIN_OPTIONS, 0}, @@ -583,7 +583,7 @@ static const cfg_op_t cfg_display_framebuffer2[32] = { {DC_WIN_LINE_STRIDE, UV_LINE_STRIDE(1280 * 2) | LINE_STRIDE(1280 * 4)}, //768*2x768*4 (= 0x600 x 0xC00) bytes, see TRM for alignment requirements. {DC_WIN_BUFFER_CONTROL, 0}, {DC_WINBUF_SURFACE_KIND, BLOCK_HEIGHT(4) | BLOCK}, //Regular surface. - {DC_WINBUF_START_ADDR, FB_ADDRESS}, //Framebuffer address. + {DC_WINBUF_START_ADDR, NYX_FB_ADDRESS}, // Framebuffer address. {DC_WINBUF_ADDR_H_OFFSET, 0x3813FC}, //Linear: 0x383FFC, Block: 0x3813FC {DC_WINBUF_ADDR_V_OFFSET, 0}, //Linear: 1279, Block: 0 {DC_WIN_WIN_OPTIONS, 0}, diff --git a/nyx/nyx_gui/gfx/logos-gui.h b/nyx/nyx_gui/gfx/logos-gui.h index 9ab2cac..d75f04e 100644 --- a/nyx/nyx_gui/gfx/logos-gui.h +++ b/nyx/nyx_gui/gfx/logos-gui.h @@ -1,6 +1,8 @@ #ifndef _LOGOS_GUI_H_ #define _LOGOS_GUI_H_ +#include "../../../common/memory_map.h" + #include "../libs/lv_conf.h" #include "../libs/lvgl/lv_draw/lv_draw_img.h" #include "../utils/types.h" diff --git a/nyx/nyx_gui/libs/fatfs/diskio.c b/nyx/nyx_gui/libs/fatfs/diskio.c index c35d39f..cdeebf9 100644 --- a/nyx/nyx_gui/libs/fatfs/diskio.c +++ b/nyx/nyx_gui/libs/fatfs/diskio.c @@ -9,11 +9,9 @@ #include #include "diskio.h" /* FatFs lower layer API */ +#include "../../../../common/memory_map.h" #include "../../storage/sdmmc.h" -#define SDMMC_UPPER_BUFFER 0xB8000000 -#define DRAM_START 0x80000000 - extern sdmmc_storage_t sd_storage; /*-----------------------------------------------------------------------*/ diff --git a/nyx/nyx_gui/libs/lv_conf.h b/nyx/nyx_gui/libs/lv_conf.h index 7f812d9..cc52047 100644 --- a/nyx/nyx_gui/libs/lv_conf.h +++ b/nyx/nyx_gui/libs/lv_conf.h @@ -18,6 +18,7 @@ #define LV_CONF_H #include "../utils/types.h" +#include "../../../common/memory_map.h" /*=================== Dynamic memory *===================*/ @@ -26,9 +27,9 @@ * to store the graphical objects and other data */ #define LV_MEM_CUSTOM 0 /*1: use custom malloc/free, 0: use the built-in lv_mem_alloc/lv_mem_free*/ #if LV_MEM_CUSTOM == 0 -# define LV_MEM_SIZE (0x38000U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ +# define LV_MEM_SIZE NYX_LV_MEM_SZ /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ # define LV_MEM_ATTR /*Complier prefix for big array declaration*/ -# define LV_MEM_ADR 0xF1000000 /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/ +# define LV_MEM_ADR NYX_LV_MEM_ADR /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/ # define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/ #else /*LV_MEM_CUSTOM*/ # define LV_MEM_CUSTOM_INCLUDE "../../../mem/heap.h" /*Header for the dynamic memory function*/ @@ -86,7 +87,7 @@ /* Place VDB to a specific address (e.g. in external RAM) * 0: allocate automatically into RAM * LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/ -#define LV_VDB_ADR 0xF0000000 +#define LV_VDB_ADR NYX_LV_VDB_ADR /* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing * The flushing should use DMA to write the frame buffer in the background */ diff --git a/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_120.c b/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_120.c index f99c06e..9a27deb 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_120.c +++ b/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_120.c @@ -16,6 +16,8 @@ #include "../lv_misc/lv_font.h" +#include "../../../../../common/memory_map.h" + #if USE_HEKATE_SYMBOL_120 != 0 /*Can be enabled in lv_conf.h*/ /*********************************************************************************** diff --git a/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_20.c b/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_20.c index 23ade6f..8ded987 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_20.c +++ b/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_20.c @@ -16,6 +16,8 @@ #include "../lv_misc/lv_font.h" +#include "../../../../../common/memory_map.h" + #if USE_HEKATE_SYMBOL_20 != 0 /*Can be enabled in lv_conf.h*/ /*********************************************************************************** diff --git a/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_30.c b/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_30.c index 91b4378..08842d2 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_30.c +++ b/nyx/nyx_gui/libs/lvgl/lv_fonts/hekate_symbol_30.c @@ -16,6 +16,8 @@ #include "../lv_misc/lv_font.h" +#include "../../../../../common/memory_map.h" + #if USE_HEKATE_SYMBOL_30 != 0 /*Can be enabled in lv_conf.h*/ /*********************************************************************************** diff --git a/nyx/nyx_gui/libs/lvgl/lv_fonts/interui_20.c b/nyx/nyx_gui/libs/lvgl/lv_fonts/interui_20.c index f5b6880..db0bbe5 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_fonts/interui_20.c +++ b/nyx/nyx_gui/libs/lvgl/lv_fonts/interui_20.c @@ -16,6 +16,8 @@ #include "../lv_misc/lv_font.h" +#include "../../../../../common/memory_map.h" + #if USE_INTERUI_20 != 0 /*Can be enabled in lv_conf.h*/ /*********************************************************************************** diff --git a/nyx/nyx_gui/libs/lvgl/lv_fonts/interui_30.c b/nyx/nyx_gui/libs/lvgl/lv_fonts/interui_30.c index 61b5530..1f97abf 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_fonts/interui_30.c +++ b/nyx/nyx_gui/libs/lvgl/lv_fonts/interui_30.c @@ -16,6 +16,8 @@ #include "../lv_misc/lv_font.h" +#include "../../../../../common/memory_map.h" + #if USE_INTERUI_30 != 0 /*Can be enabled in lv_conf.h*/ /*********************************************************************************** diff --git a/nyx/nyx_gui/libs/lvgl/lv_fonts/ubuntu_mono.c b/nyx/nyx_gui/libs/lvgl/lv_fonts/ubuntu_mono.c index 23baa97..b88cb2c 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_fonts/ubuntu_mono.c +++ b/nyx/nyx_gui/libs/lvgl/lv_fonts/ubuntu_mono.c @@ -16,6 +16,8 @@ #include "../lv_misc/lv_font.h" +#include "../../../../../common/memory_map.h" + #if USE_UBUNTU_MONO != 0 /*Can be enabled in lv_conf.h*/ /*********************************************************************************** diff --git a/nyx/nyx_gui/mem/sdram.c b/nyx/nyx_gui/mem/sdram.c index 30d76a2..9ca157d 100644 --- a/nyx/nyx_gui/mem/sdram.c +++ b/nyx/nyx_gui/mem/sdram.c @@ -19,6 +19,7 @@ #include "mc.h" #include "emc.h" #include "sdram_param_t210.h" +#include "../../../common/memory_map.h" #include "../power/max77620.h" #include "../power/max7762x.h" #include "../soc/clock.h" @@ -641,7 +642,7 @@ break_nosleep: sdram_params_t *sdram_get_params() { #ifdef CONFIG_SDRAM_COMPRESS_CFG - u8 *buf = (u8 *)0x40030000; + u8 *buf = (u8 *)SDRAM_PARAMS_ADDR; LZ_Uncompress(_dram_cfg_lz, buf, sizeof(_dram_cfg_lz)); return (sdram_params_t *)&buf[sizeof(sdram_params_t) * _get_sdram_id()]; #else diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index 8eaa546..15e4e0f 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -19,6 +19,8 @@ #include #include +#include "../../common/memory_map.h" + #include "config/config.h" #include "gfx/di.h" #include "gfx/gfx.h" @@ -366,7 +368,7 @@ void nyx_init_load_res() // Set bootloader's default configuration. set_default_configuration(); - gfx_init_ctxt((u32 *)FB_ADDRESS, 720, 1280, 720); + gfx_init_ctxt((u32 *)NYX_FB_ADDRESS, 720, 1280, 720); gfx_con_init(); sd_mount(); @@ -391,10 +393,6 @@ void nyx_init_load_res() h_cfg.rcm_patched = fuse_check_patched_rcm(); } -#define IPL_STACK_TOP 0x90010000 -#define IPL_HEAP_START 0x90020000 -#define IPL_HEAP_END 0xB5000000 - extern void pivot_stack(u32 stack_top); #if (LV_LOG_PRINTF == 1) diff --git a/nyx/nyx_gui/soc/bpmp.c b/nyx/nyx_gui/soc/bpmp.c index 05c3f9a..0203a99 100644 --- a/nyx/nyx_gui/soc/bpmp.c +++ b/nyx/nyx_gui/soc/bpmp.c @@ -19,6 +19,7 @@ #include "bpmp.h" #include "clock.h" #include "t210.h" +#include "../../../common/memory_map.h" #include "../utils/util.h" #define BPMP_CACHE_CONFIG 0x0 @@ -74,8 +75,8 @@ bpmp_mmu_entry_t mmu_entries[] = { - { 0x80000000, 0xFFFFFFFF, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }, - { NYX_LOAD_ADDR, 0x40040000, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true } + { DRAM_START, 0xFFFFFFFF, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }, + { IRAM_BASE, 0x4003FFFF, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true } }; void bpmp_mmu_maintenance(u32 op, bool force) diff --git a/nyx/nyx_gui/storage/sdmmc.c b/nyx/nyx_gui/storage/sdmmc.c index 0eb4e39..e823a05 100644 --- a/nyx/nyx_gui/storage/sdmmc.c +++ b/nyx/nyx_gui/storage/sdmmc.c @@ -19,6 +19,7 @@ #include "sdmmc.h" #include "mmc.h" #include "sd.h" +#include "../../../common/memory_map.h" #include "../gfx/gfx.h" #include "../mem/heap.h" #include "../utils/util.h" @@ -1064,6 +1065,7 @@ void sdmmc_storage_init_wait_sd() int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type) { int is_version_1 = 0; + u8 *buf = (u8 *)SDMMC_UPPER_BUFFER; // Some cards (SanDisk U1), do not like a fast power cycle. Wait min 100ms. sdmmc_storage_init_wait_sd(); @@ -1138,13 +1140,9 @@ DPRINTF("[SD] set blocklen to 512\n"); return 0; DPRINTF("[SD] cleared card detect\n"); - u8 *buf = (u8 *)malloc(512); if (!_sd_storage_get_scr(storage, buf)) - { - free(buf); return 0; - } - + //gfx_hexdump(0, storage->raw_scr, 8); DPRINTF("[SD] got scr\n"); @@ -1152,10 +1150,8 @@ DPRINTF("[SD] got scr\n"); if (bus_width == SDMMC_BUS_WIDTH_4 && (storage->scr.bus_widths & 4) && (storage->scr.sda_vsn & 0xF)) { if (!_sd_storage_execute_app_cmd_type1(storage, &tmp, SD_APP_SET_BUS_WIDTH, SD_BUS_WIDTH_4, 0, R1_STATE_TRAN)) - { - free(buf); return 0; - } + sdmmc_set_bus_width(storage->sdmmc, SDMMC_BUS_WIDTH_4); DPRINTF("[SD] switched to wide bus width\n"); } @@ -1167,19 +1163,14 @@ DPRINTF("[SD] SD does not support wide bus width\n"); if (storage->is_low_voltage) { if (!_sd_storage_enable_uhs_low_volt(storage, type, buf)) - { - free(buf); return 0; - } DPRINTF("[SD] enabled UHS\n"); } else if (type != 6 && (storage->scr.sda_vsn & 0xF) != 0) { if (!_sd_storage_enable_hs_high_volt(storage, buf)) - { - free(buf); return 0; - } + DPRINTF("[SD] enabled HS\n"); storage->csd.busspeed = 25; } @@ -1192,7 +1183,6 @@ DPRINTF("[SD] enabled HS\n"); DPRINTF("[SD] got sd status\n"); } - free(buf); return 1; }