1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-22 18:06:40 +00:00

Move all I/DRAM addresses into a memory map

Many addresses were moved around to pack the memory usage!
This commit is contained in:
CTCaer 2019-12-08 02:23:03 +02:00
parent 0290892b23
commit f256bd5909
31 changed files with 152 additions and 91 deletions

View file

@ -7,7 +7,6 @@ include $(DEVKITARM)/base_rules
################################################################################ ################################################################################
IPL_LOAD_ADDR := 0x40008000 IPL_LOAD_ADDR := 0x40008000
NYX_STORAGE_ADDR := 0xED000000
IPL_MAGIC := 0x43544349 #"ICTC" IPL_MAGIC := 0x43544349 #"ICTC"
BLVERSION_MAJOR := 5 BLVERSION_MAJOR := 5
BLVERSION_MINOR := 0 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 += -DBL_VER_MJ=$(BLVERSION_MAJOR) -DBL_VER_MN=$(BLVERSION_MINOR) -DBL_VER_HF=$(BLVERSION_HOTFX) -DBL_RESERVED=$(BL_RESERVED)
#CUSTOMDEFINES += -DMENU_LOGO_ENABLE #CUSTOMDEFINES += -DMENU_LOGO_ENABLE

View file

@ -20,6 +20,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "fe_emmc_tools.h" #include "fe_emmc_tools.h"
#include "../../common/memory_map.h"
#include "../config/config.h" #include "../config/config.h"
#include "../gfx/gfx.h" #include "../gfx/gfx.h"
#include "../gfx/tui.h" #include "../gfx/tui.h"
@ -31,10 +32,6 @@
#include "../utils/btn.h" #include "../utils/btn.h"
#include "../utils/util.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 NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
#define OUT_FILENAME_SZ 128 #define OUT_FILENAME_SZ 128
#define SHA256_SZ 0x20 #define SHA256_SZ 0x20

View file

@ -254,7 +254,6 @@ void display_color_screen(u32 color)
DISPLAY_A(_DIREG(DC_WIN_CD_WIN_OPTIONS)) = 0; DISPLAY_A(_DIREG(DC_WIN_CD_WIN_OPTIONS)) = 0;
DISPLAY_A(_DIREG(DC_DISP_BLEND_BACKGROUND_COLOR)) = color; 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; DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) = (DISPLAY_A(_DIREG(DC_CMD_STATE_CONTROL)) & 0xFFFFFFFE) | GENERAL_ACT_REQ;
usleep(35000); usleep(35000);
display_backlight(true); display_backlight(true);
@ -263,11 +262,12 @@ void display_color_screen(u32 color)
u32 *display_init_framebuffer() u32 *display_init_framebuffer()
{ {
// Sanitize framebuffer area. // 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). // 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); exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer, 32);
usleep(35000); usleep(35000);
return (u32 *)FB_ADDRESS; return (u32 *)IPL_FB_ADDRESS;
} }

View file

@ -18,10 +18,9 @@
#ifndef _DI_H_ #ifndef _DI_H_
#define _DI_H_ #define _DI_H_
#include "../../common/memory_map.h"
#include "../utils/types.h" #include "../utils/types.h"
#define FB_ADDRESS 0xC0000000
/*! Display registers. */ /*! Display registers. */
#define _DIREG(reg) ((reg) * 4) #define _DIREG(reg) ((reg) * 4)

View file

@ -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_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_WIN_BUFFER_CONTROL, 0},
{DC_WINBUF_SURFACE_KIND, 0}, //Regular surface. {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_H_OFFSET, 0},
{DC_WINBUF_ADDR_V_OFFSET, 0}, {DC_WINBUF_ADDR_V_OFFSET, 0},
{DC_WIN_WIN_OPTIONS, 0}, {DC_WIN_WIN_OPTIONS, 0},

View file

@ -8,12 +8,12 @@
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
#include <string.h> #include <string.h>
#include "../../../common/memory_map.h"
#include "diskio.h" /* FatFs lower layer API */ #include "diskio.h" /* FatFs lower layer API */
#include "../../storage/sdmmc.h" #include "../../storage/sdmmc.h"
#define SDMMC_UPPER_BUFFER 0xB8000000
#define DRAM_START 0x80000000
extern sdmmc_storage_t sd_storage; extern sdmmc_storage_t sd_storage;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/

View file

@ -19,6 +19,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "../common/memory_map.h"
#include "config/config.h" #include "config/config.h"
#include "gfx/di.h" #include "gfx/di.h"
#include "gfx/gfx.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 }; 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); extern void pivot_stack(u32 stack_top);
void ipl_main() void ipl_main()

View file

@ -19,6 +19,7 @@
#include "mc.h" #include "mc.h"
#include "emc.h" #include "emc.h"
#include "sdram_param_t210.h" #include "sdram_param_t210.h"
#include "../../common/memory_map.h"
#include "../power/max77620.h" #include "../power/max77620.h"
#include "../power/max7762x.h" #include "../power/max7762x.h"
#include "../soc/clock.h" #include "../soc/clock.h"
@ -647,7 +648,7 @@ break_nosleep:
sdram_params_t *sdram_get_params() sdram_params_t *sdram_get_params()
{ {
#ifdef CONFIG_SDRAM_COMPRESS_CFG #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)); LZ_Uncompress(_dram_cfg_lz, buf, sizeof(_dram_cfg_lz));
return (sdram_params_t *)&buf[sizeof(sdram_params_t) * _get_sdram_id()]; return (sdram_params_t *)&buf[sizeof(sdram_params_t) * _get_sdram_id()];
#else #else

View file

@ -19,6 +19,7 @@
#include "bpmp.h" #include "bpmp.h"
#include "clock.h" #include "clock.h"
#include "t210.h" #include "t210.h"
#include "../../common/memory_map.h"
#include "../utils/util.h" #include "../utils/util.h"
#define BPMP_CACHE_CONFIG 0x0 #define BPMP_CACHE_CONFIG 0x0
@ -74,8 +75,8 @@
bpmp_mmu_entry_t mmu_entries[] = bpmp_mmu_entry_t mmu_entries[] =
{ {
{ 0x80000000, 0xFFFFFFFF, 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 },
{ IPL_LOAD_ADDR, 0x40040000, 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) void bpmp_mmu_maintenance(u32 op, bool force)

View file

@ -19,6 +19,7 @@
#include "sdmmc.h" #include "sdmmc.h"
#include "mmc.h" #include "mmc.h"
#include "sd.h" #include "sd.h"
#include "../../common/memory_map.h"
#include "../gfx/gfx.h" #include "../gfx/gfx.h"
#include "../mem/heap.h" #include "../mem/heap.h"
#include "../utils/util.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 sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type)
{ {
int is_version_1 = 0; 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. // Some cards (SanDisk U1), do not like a fast power cycle. Wait min 100ms.
sdmmc_storage_init_wait_sd(); sdmmc_storage_init_wait_sd();
@ -1138,13 +1140,9 @@ DPRINTF("[SD] set blocklen to 512\n");
return 0; return 0;
DPRINTF("[SD] cleared card detect\n"); DPRINTF("[SD] cleared card detect\n");
u8 *buf = (u8 *)malloc(512);
if (!_sd_storage_get_scr(storage, buf)) if (!_sd_storage_get_scr(storage, buf))
{
free(buf);
return 0; return 0;
}
//gfx_hexdump(0, storage->raw_scr, 8); //gfx_hexdump(0, storage->raw_scr, 8);
DPRINTF("[SD] got scr\n"); 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 (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)) 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; return 0;
}
sdmmc_set_bus_width(storage->sdmmc, SDMMC_BUS_WIDTH_4); sdmmc_set_bus_width(storage->sdmmc, SDMMC_BUS_WIDTH_4);
DPRINTF("[SD] switched to wide bus width\n"); 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 (storage->is_low_voltage)
{ {
if (!_sd_storage_enable_uhs_low_volt(storage, type, buf)) if (!_sd_storage_enable_uhs_low_volt(storage, type, buf))
{
free(buf);
return 0; return 0;
}
DPRINTF("[SD] enabled UHS\n"); DPRINTF("[SD] enabled UHS\n");
} }
else if (type != 6 && (storage->scr.sda_vsn & 0xF) != 0) else if (type != 6 && (storage->scr.sda_vsn & 0xF) != 0)
{ {
if (!_sd_storage_enable_hs_high_volt(storage, buf)) if (!_sd_storage_enable_hs_high_volt(storage, buf))
{
free(buf);
return 0; return 0;
}
DPRINTF("[SD] enabled HS\n"); DPRINTF("[SD] enabled HS\n");
storage->csd.busspeed = 25; storage->csd.busspeed = 25;
} }
@ -1192,7 +1183,6 @@ DPRINTF("[SD] enabled HS\n");
DPRINTF("[SD] got sd status\n"); DPRINTF("[SD] got sd status\n");
} }
free(buf);
return 1; return 1;
} }

87
common/memory_map.h Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View file

@ -7,8 +7,6 @@ include $(DEVKITARM)/base_rules
################################################################################ ################################################################################
NYX_LOAD_ADDR := 0x81000000 NYX_LOAD_ADDR := 0x81000000
NYX_RES_ADDR := 0xEE000000
NYX_STORAGE_ADDR := 0xED000000
NYX_MAGIC := 0x43544347 #"GCTC" NYX_MAGIC := 0x43544347 #"GCTC"
BLVERSION_MAJOR := 0 BLVERSION_MAJOR := 0
BLVERSION_MINOR := 8 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 += -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) CUSTOMDEFINES += -DBL_VER_MJ=$(BLVERSION_MAJOR) -DBL_VER_MN=$(BLVERSION_MINOR) -DBL_VER_HF=$(BLVERSION_HOTFX) -DBL_RESERVED=$(BL_RESERVED)

View file

@ -24,6 +24,7 @@
#include "gui.h" #include "gui.h"
#include "fe_emmc_tools.h" #include "fe_emmc_tools.h"
#include "fe_emummc_tools.h" #include "fe_emummc_tools.h"
#include "../../../common/memory_map.h"
#include "../config/config.h" #include "../config/config.h"
#include "../libs/fatfs/ff.h" #include "../libs/fatfs/ff.h"
#include "../mem/heap.h" #include "../mem/heap.h"
@ -35,10 +36,6 @@
#include "../utils/sprintf.h" #include "../utils/sprintf.h"
#include "../utils/util.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 NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
#define OUT_FILENAME_SZ 128 #define OUT_FILENAME_SZ 128
#define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums") #define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums")

View file

@ -32,10 +32,6 @@
#include "../utils/sprintf.h" #include "../utils/sprintf.h"
#include "../utils/util.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 NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
#define OUT_FILENAME_SZ 128 #define OUT_FILENAME_SZ 128

View file

@ -40,6 +40,7 @@
#include "../soc/hw_init.h" #include "../soc/hw_init.h"
#include "../soc/t210.h" #include "../soc/t210.h"
#include "../storage/sdmmc.h" #include "../storage/sdmmc.h"
#include "../thermal/fan.h"
#include "../thermal/tmp451.h" #include "../thermal/tmp451.h"
#include "../utils/dirlist.h" #include "../utils/dirlist.h"
#include "../utils/sprintf.h" #include "../utils/sprintf.h"
@ -87,7 +88,7 @@ static void _save_fb_to_bmp()
const u32 file_size = 0x384000 + 0x36; const u32 file_size = 0x384000 + 0x36;
u8 *bitmap = malloc(file_size); u8 *bitmap = malloc(file_size);
u32 *fb = malloc(0x384000); u32 *fb = malloc(0x384000);
u32 *fb_ptr = gfx_ctxt.fb; u32 *fb_ptr = (u32 *)NYX_FB_ADDRESS;
// Reconstruct FB for bottom-top, landscape bmp. // Reconstruct FB for bottom-top, landscape bmp.
for (u32 x = 0; x < 1280; x++) 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) 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. // 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. // Check if display init was done. If it's the first big draw, init.
if (!disp_init_done && ((x2 - x1 + 1) > 600)) if (!disp_init_done && ((x2 - x1 + 1) > 600))

View file

@ -262,25 +262,21 @@ void display_color_screen(u32 color)
u32 *display_init_framebuffer() u32 *display_init_framebuffer()
{ {
// Sanitize framebuffer area. // This configures the framebuffer @ NYX_FB_ADDRESS with a resolution of 1280x720 (line stride 720).
//memset((u32 *)FB_ADDRESS, 0, 0x3C0000);
// This configures the framebuffer @ FB_ADDRESS with a resolution of 1280x720 (line stride 720).
exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer, 32); exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer, 32);
usleep(35000); usleep(35000);
return (u32 *)FB_ADDRESS; return (u32 *)NYX_FB_ADDRESS;
} }
u32 *display_init_framebuffer2() u32 *display_init_framebuffer2()
{ {
// Sanitize framebuffer area. // This configures the framebuffer @ NYX_FB_ADDRESS with a resolution of 1280x720 (line stride 720).
memset((u32 *)FB_ADDRESS, 0, 0x3C0000);
// This configures the framebuffer @ FB_ADDRESS with a resolution of 1280x720 (line stride 720).
exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer2, 32); exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer2, 32);
usleep(35000); usleep(35000);
return (u32 *)FB_ADDRESS; return (u32 *)NYX_FB_ADDRESS;
} }

View file

@ -18,10 +18,9 @@
#ifndef _DI_H_ #ifndef _DI_H_
#define _DI_H_ #define _DI_H_
#include "../../../common/memory_map.h"
#include "../utils/types.h" #include "../utils/types.h"
#define FB_ADDRESS 0xF0800000
/*! Display registers. */ /*! Display registers. */
#define _DIREG(reg) ((reg) * 4) #define _DIREG(reg) ((reg) * 4)

View file

@ -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_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_WIN_BUFFER_CONTROL, 0},
{DC_WINBUF_SURFACE_KIND, 0}, //Regular surface. {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_H_OFFSET, 0}, //Linear: 0x383FFC, Block: 0x3813FC
{DC_WINBUF_ADDR_V_OFFSET, 1279}, //Linear: 1279, Block: 0 {DC_WINBUF_ADDR_V_OFFSET, 1279}, //Linear: 1279, Block: 0
{DC_WIN_WIN_OPTIONS, 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_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_WIN_BUFFER_CONTROL, 0},
{DC_WINBUF_SURFACE_KIND, BLOCK_HEIGHT(4) | BLOCK}, //Regular surface. {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_H_OFFSET, 0x3813FC}, //Linear: 0x383FFC, Block: 0x3813FC
{DC_WINBUF_ADDR_V_OFFSET, 0}, //Linear: 1279, Block: 0 {DC_WINBUF_ADDR_V_OFFSET, 0}, //Linear: 1279, Block: 0
{DC_WIN_WIN_OPTIONS, 0}, {DC_WIN_WIN_OPTIONS, 0},

View file

@ -1,6 +1,8 @@
#ifndef _LOGOS_GUI_H_ #ifndef _LOGOS_GUI_H_
#define _LOGOS_GUI_H_ #define _LOGOS_GUI_H_
#include "../../../common/memory_map.h"
#include "../libs/lv_conf.h" #include "../libs/lv_conf.h"
#include "../libs/lvgl/lv_draw/lv_draw_img.h" #include "../libs/lvgl/lv_draw/lv_draw_img.h"
#include "../utils/types.h" #include "../utils/types.h"

View file

@ -9,11 +9,9 @@
#include <string.h> #include <string.h>
#include "diskio.h" /* FatFs lower layer API */ #include "diskio.h" /* FatFs lower layer API */
#include "../../../../common/memory_map.h"
#include "../../storage/sdmmc.h" #include "../../storage/sdmmc.h"
#define SDMMC_UPPER_BUFFER 0xB8000000
#define DRAM_START 0x80000000
extern sdmmc_storage_t sd_storage; extern sdmmc_storage_t sd_storage;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/

View file

@ -18,6 +18,7 @@
#define LV_CONF_H #define LV_CONF_H
#include "../utils/types.h" #include "../utils/types.h"
#include "../../../common/memory_map.h"
/*=================== /*===================
Dynamic memory Dynamic memory
*===================*/ *===================*/
@ -26,9 +27,9 @@
* to store the graphical objects and other data */ * 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*/ #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 #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_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*/ # define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
#else /*LV_MEM_CUSTOM*/ #else /*LV_MEM_CUSTOM*/
# define LV_MEM_CUSTOM_INCLUDE "../../../mem/heap.h" /*Header for the dynamic memory function*/ # 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) /* Place VDB to a specific address (e.g. in external RAM)
* 0: allocate automatically into RAM * 0: allocate automatically into RAM
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/ * 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 /* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing
* The flushing should use DMA to write the frame buffer in the background */ * The flushing should use DMA to write the frame buffer in the background */

View file

@ -16,6 +16,8 @@
#include "../lv_misc/lv_font.h" #include "../lv_misc/lv_font.h"
#include "../../../../../common/memory_map.h"
#if USE_HEKATE_SYMBOL_120 != 0 /*Can be enabled in lv_conf.h*/ #if USE_HEKATE_SYMBOL_120 != 0 /*Can be enabled in lv_conf.h*/
/*********************************************************************************** /***********************************************************************************

View file

@ -16,6 +16,8 @@
#include "../lv_misc/lv_font.h" #include "../lv_misc/lv_font.h"
#include "../../../../../common/memory_map.h"
#if USE_HEKATE_SYMBOL_20 != 0 /*Can be enabled in lv_conf.h*/ #if USE_HEKATE_SYMBOL_20 != 0 /*Can be enabled in lv_conf.h*/
/*********************************************************************************** /***********************************************************************************

View file

@ -16,6 +16,8 @@
#include "../lv_misc/lv_font.h" #include "../lv_misc/lv_font.h"
#include "../../../../../common/memory_map.h"
#if USE_HEKATE_SYMBOL_30 != 0 /*Can be enabled in lv_conf.h*/ #if USE_HEKATE_SYMBOL_30 != 0 /*Can be enabled in lv_conf.h*/
/*********************************************************************************** /***********************************************************************************

View file

@ -16,6 +16,8 @@
#include "../lv_misc/lv_font.h" #include "../lv_misc/lv_font.h"
#include "../../../../../common/memory_map.h"
#if USE_INTERUI_20 != 0 /*Can be enabled in lv_conf.h*/ #if USE_INTERUI_20 != 0 /*Can be enabled in lv_conf.h*/
/*********************************************************************************** /***********************************************************************************

View file

@ -16,6 +16,8 @@
#include "../lv_misc/lv_font.h" #include "../lv_misc/lv_font.h"
#include "../../../../../common/memory_map.h"
#if USE_INTERUI_30 != 0 /*Can be enabled in lv_conf.h*/ #if USE_INTERUI_30 != 0 /*Can be enabled in lv_conf.h*/
/*********************************************************************************** /***********************************************************************************

View file

@ -16,6 +16,8 @@
#include "../lv_misc/lv_font.h" #include "../lv_misc/lv_font.h"
#include "../../../../../common/memory_map.h"
#if USE_UBUNTU_MONO != 0 /*Can be enabled in lv_conf.h*/ #if USE_UBUNTU_MONO != 0 /*Can be enabled in lv_conf.h*/
/*********************************************************************************** /***********************************************************************************

View file

@ -19,6 +19,7 @@
#include "mc.h" #include "mc.h"
#include "emc.h" #include "emc.h"
#include "sdram_param_t210.h" #include "sdram_param_t210.h"
#include "../../../common/memory_map.h"
#include "../power/max77620.h" #include "../power/max77620.h"
#include "../power/max7762x.h" #include "../power/max7762x.h"
#include "../soc/clock.h" #include "../soc/clock.h"
@ -641,7 +642,7 @@ break_nosleep:
sdram_params_t *sdram_get_params() sdram_params_t *sdram_get_params()
{ {
#ifdef CONFIG_SDRAM_COMPRESS_CFG #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)); LZ_Uncompress(_dram_cfg_lz, buf, sizeof(_dram_cfg_lz));
return (sdram_params_t *)&buf[sizeof(sdram_params_t) * _get_sdram_id()]; return (sdram_params_t *)&buf[sizeof(sdram_params_t) * _get_sdram_id()];
#else #else

View file

@ -19,6 +19,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "../../common/memory_map.h"
#include "config/config.h" #include "config/config.h"
#include "gfx/di.h" #include "gfx/di.h"
#include "gfx/gfx.h" #include "gfx/gfx.h"
@ -366,7 +368,7 @@ void nyx_init_load_res()
// Set bootloader's default configuration. // Set bootloader's default configuration.
set_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(); gfx_con_init();
sd_mount(); sd_mount();
@ -391,10 +393,6 @@ void nyx_init_load_res()
h_cfg.rcm_patched = fuse_check_patched_rcm(); 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); extern void pivot_stack(u32 stack_top);
#if (LV_LOG_PRINTF == 1) #if (LV_LOG_PRINTF == 1)

View file

@ -19,6 +19,7 @@
#include "bpmp.h" #include "bpmp.h"
#include "clock.h" #include "clock.h"
#include "t210.h" #include "t210.h"
#include "../../../common/memory_map.h"
#include "../utils/util.h" #include "../utils/util.h"
#define BPMP_CACHE_CONFIG 0x0 #define BPMP_CACHE_CONFIG 0x0
@ -74,8 +75,8 @@
bpmp_mmu_entry_t mmu_entries[] = bpmp_mmu_entry_t mmu_entries[] =
{ {
{ 0x80000000, 0xFFFFFFFF, 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 },
{ NYX_LOAD_ADDR, 0x40040000, 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) void bpmp_mmu_maintenance(u32 op, bool force)

View file

@ -19,6 +19,7 @@
#include "sdmmc.h" #include "sdmmc.h"
#include "mmc.h" #include "mmc.h"
#include "sd.h" #include "sd.h"
#include "../../../common/memory_map.h"
#include "../gfx/gfx.h" #include "../gfx/gfx.h"
#include "../mem/heap.h" #include "../mem/heap.h"
#include "../utils/util.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 sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type)
{ {
int is_version_1 = 0; 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. // Some cards (SanDisk U1), do not like a fast power cycle. Wait min 100ms.
sdmmc_storage_init_wait_sd(); sdmmc_storage_init_wait_sd();
@ -1138,13 +1140,9 @@ DPRINTF("[SD] set blocklen to 512\n");
return 0; return 0;
DPRINTF("[SD] cleared card detect\n"); DPRINTF("[SD] cleared card detect\n");
u8 *buf = (u8 *)malloc(512);
if (!_sd_storage_get_scr(storage, buf)) if (!_sd_storage_get_scr(storage, buf))
{
free(buf);
return 0; return 0;
}
//gfx_hexdump(0, storage->raw_scr, 8); //gfx_hexdump(0, storage->raw_scr, 8);
DPRINTF("[SD] got scr\n"); 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 (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)) 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; return 0;
}
sdmmc_set_bus_width(storage->sdmmc, SDMMC_BUS_WIDTH_4); sdmmc_set_bus_width(storage->sdmmc, SDMMC_BUS_WIDTH_4);
DPRINTF("[SD] switched to wide bus width\n"); 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 (storage->is_low_voltage)
{ {
if (!_sd_storage_enable_uhs_low_volt(storage, type, buf)) if (!_sd_storage_enable_uhs_low_volt(storage, type, buf))
{
free(buf);
return 0; return 0;
}
DPRINTF("[SD] enabled UHS\n"); DPRINTF("[SD] enabled UHS\n");
} }
else if (type != 6 && (storage->scr.sda_vsn & 0xF) != 0) else if (type != 6 && (storage->scr.sda_vsn & 0xF) != 0)
{ {
if (!_sd_storage_enable_hs_high_volt(storage, buf)) if (!_sd_storage_enable_hs_high_volt(storage, buf))
{
free(buf);
return 0; return 0;
}
DPRINTF("[SD] enabled HS\n"); DPRINTF("[SD] enabled HS\n");
storage->csd.busspeed = 25; storage->csd.busspeed = 25;
} }
@ -1192,7 +1183,6 @@ DPRINTF("[SD] enabled HS\n");
DPRINTF("[SD] got sd status\n"); DPRINTF("[SD] got sd status\n");
} }
free(buf);
return 1; return 1;
} }