diff --git a/Makefile b/Makefile index 284239b..971dd7e 100755 --- a/Makefile +++ b/Makefile @@ -16,7 +16,10 @@ TARGET := hekate BUILDDIR := build OUTPUTDIR := output SOURCEDIR = bootloader +BDKDIR := bdk +BDKINC := -I./$(BDKDIR) VPATH = $(dir ./$(SOURCEDIR)/) $(dir $(wildcard ./$(SOURCEDIR)/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/)) +VPATH += $(dir $(wildcard ./$(BDKDIR)/*/)) $(dir $(wildcard ./$(BDKDIR)/*/*/)) # Main and graphics. OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \ @@ -54,11 +57,15 @@ OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \ elfload.o elfreloc_arm.o \ ) +GFX_INC := '"../$(SOURCEDIR)/gfx/gfx.h"' +FFCFG_INC := '"../$(SOURCEDIR)/libs/fatfs/ffconf.h"' + ################################################################################ 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=$(BLVERSION_RSVD) CUSTOMDEFINES += -DNYX_VER_MJ=$(NYXVERSION_MAJOR) -DNYX_VER_MN=$(NYXVERSION_MINOR) -DNYX_VER_HF=$(NYXVERSION_HOTFX) -DNYX_RESERVED=$(NYXVERSION_RSVD) +CUSTOMDEFINES += -DGFX_INC=$(GFX_INC) -DFFCFG_INC=$(FFCFG_INC) # 0: UART_A, 1: UART_B. #CUSTOMDEFINES += -DDEBUG_UART_PORT=0 @@ -104,7 +111,7 @@ $(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS) $(BUILDDIR)/$(TARGET)/%.o: %.c @echo Building $@ - @$(CC) $(CFLAGS) -c $< -o $@ + @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ $(BUILDDIR)/$(TARGET)/%.o: %.S @echo Building $@ diff --git a/common/common_heap.h b/bdk/fatfs_cfg.h similarity index 59% rename from common/common_heap.h rename to bdk/fatfs_cfg.h index 110f013..a12585f 100644 --- a/common/common_heap.h +++ b/bdk/fatfs_cfg.h @@ -1,6 +1,5 @@ /* - * Copyright (c) 2018 naehrwert - * Copyright (c) 2018 M4xw + * Copyright (c) 2020 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, @@ -13,29 +12,13 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . -*/ + */ -#pragma once -//TODO: Move it to BDK -#include "../bootloader/utils/types.h" +#ifndef _FATFS_CFG_H_ +#define _FATFS_CFG_H_ -typedef struct _hnode -{ - int used; - u32 size; - struct _hnode *prev; - struct _hnode *next; - u32 align[4]; // Align to arch cache line size. -} hnode_t; +#ifdef FFCFG_INC +#include FFCFG_INC +#endif -typedef struct _heap -{ - u32 start; - hnode_t *first; -} heap_t; - -typedef struct -{ - u32 total; - u32 used; -} heap_monitor_t; +#endif diff --git a/bdk/gfx/di.c b/bdk/gfx/di.c index 015df23..1549e7b 100644 --- a/bdk/gfx/di.c +++ b/bdk/gfx/di.c @@ -18,16 +18,15 @@ #include #include "di.h" -#include "../gfx/gfx.h" -#include "../power/max77620.h" -#include "../power/max7762x.h" -#include "../soc/clock.h" -#include "../soc/gpio.h" -#include "../soc/i2c.h" -#include "../soc/pinmux.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "di.inl" diff --git a/bdk/gfx/di.h b/bdk/gfx/di.h index 2b4e579..2723de0 100644 --- a/bdk/gfx/di.h +++ b/bdk/gfx/di.h @@ -18,8 +18,8 @@ #ifndef _DI_H_ #define _DI_H_ -#include "../../common/memory_map.h" -#include "../utils/types.h" +#include +#include /*! Display registers. */ #define _DIREG(reg) ((reg) * 4) diff --git a/common/common_gfx.h b/bdk/gfx_utils.h similarity index 57% rename from common/common_gfx.h rename to bdk/gfx_utils.h index b6dbdab..ca81a7f 100644 --- a/common/common_gfx.h +++ b/bdk/gfx_utils.h @@ -1,8 +1,5 @@ /* - * Common Gfx Header - * Copyright (c) 2018 naehrwert - * Copyright (c) 2018 CTCaer - * Copyright (c) 2018 M4xw + * Copyright (c) 2020 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, @@ -15,30 +12,13 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . -*/ + */ -#pragma once -//TODO: Move it to BDK -#include "../bootloader/utils/types.h" +#ifndef _GFX_UTILS_H_ +#define _GFX_UTILS_H_ -typedef struct _gfx_ctxt_t -{ - u32 *fb; - u32 width; - u32 height; - u32 stride; -} gfx_ctxt_t; +#ifdef GFX_INC +#include GFX_INC +#endif -typedef struct _gfx_con_t -{ - gfx_ctxt_t *gfx_ctxt; - u32 fntsz; - u32 x; - u32 y; - u32 savedx; - u32 savedy; - u32 fgcol; - int fillbg; - u32 bgcol; - bool mute; -} gfx_con_t; +#endif diff --git a/bdk/ianos/elfload/elfload.h b/bdk/ianos/elfload/elfload.h index 3a15dc2..2b9bb67 100644 --- a/bdk/ianos/elfload/elfload.h +++ b/bdk/ianos/elfload/elfload.h @@ -22,10 +22,10 @@ #include "elfarch.h" #include "elf.h" -#include "../../utils/types.h" +#include #ifdef DEBUG -#include "../../gfx/gfx.h" +#include #define EL_DEBUG(format, ...) \ gfx_printf(format __VA_OPT__(, ) __VA_ARGS__) #else diff --git a/bdk/ianos/ianos.c b/bdk/ianos/ianos.c index 15f3c30..5eca1b6 100644 --- a/bdk/ianos/ianos.c +++ b/bdk/ianos/ianos.c @@ -18,12 +18,13 @@ #include #include "ianos.h" -#include "../../common/common_module.h" -#include "../gfx/gfx.h" -#include "../libs/elfload/elfload.h" -#include "../mem/heap.h" -#include "../storage/nx_sd.h" -#include "../utils/types.h" +#include "elfload/elfload.h" +#include +#include +#include +#include + +#include #define IRAM_LIB_ADDR 0x4002B000 #define DRAM_LIB_ADDR 0xE0000000 @@ -36,8 +37,8 @@ void *fileBuf = NULL; static void _ianos_call_ep(moduleEntrypoint_t entrypoint, void *moduleConfig) { bdkParams_t bdkParameters = (bdkParams_t)malloc(sizeof(struct _bdkParams_t)); - bdkParameters->gfxCon = &gfx_con; - bdkParameters->gfxCtx = &gfx_ctxt; + bdkParameters->gfxCon = (void *)&gfx_con; + bdkParameters->gfxCtx = (void *)&gfx_ctxt; bdkParameters->memcpy = (memcpy_t)&memcpy; bdkParameters->memset = (memset_t)&memset; bdkParameters->sharedHeap = &_heap; diff --git a/bdk/ianos/ianos.h b/bdk/ianos/ianos.h index d64b329..5ebec64 100644 --- a/bdk/ianos/ianos.h +++ b/bdk/ianos/ianos.h @@ -18,7 +18,7 @@ #ifndef IANOS_H #define IANOS_H -#include "../utils/types.h" +#include typedef enum { diff --git a/bdk/input/als.c b/bdk/input/als.c index ef9a4c8..3f59657 100644 --- a/bdk/input/als.c +++ b/bdk/input/als.c @@ -17,11 +17,11 @@ */ #include "als.h" -#include "../power/max77620.h" -#include "../soc/clock.h" -#include "../soc/i2c.h" -#include "../soc/pinmux.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include #define HOS_GAIN BH1730_GAIN_64X #define HOS_ITIME 38 diff --git a/bdk/input/als.h b/bdk/input/als.h index 11f1e5e..ad31e42 100644 --- a/bdk/input/als.h +++ b/bdk/input/als.h @@ -19,7 +19,7 @@ #ifndef __ALS_H_ #define __ALS_H_ -#include "../utils/types.h" +#include #define BH1730_I2C_ADDR 0x29 diff --git a/bdk/input/joycon.c b/bdk/input/joycon.c index 8cc74aa..2db1aa6 100644 --- a/bdk/input/joycon.c +++ b/bdk/input/joycon.c @@ -19,19 +19,19 @@ #include #include "joycon.h" -#include "../gfx/gfx.h" -#include "../power/max17050.h" -#include "../power/regulator_5v.h" -#include "../soc/bpmp.h" -#include "../soc/clock.h" -#include "../soc/gpio.h" -#include "../soc/pinmux.h" -#include "../soc/uart.h" -#include "../soc/t210.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // For disabling driver when logging is enabled. -#include "../libs/lvgl/lvgl.h" +#include #define JC_WIRED_CMD 0x91 #define JC_WIRED_HID 0x92 diff --git a/bdk/input/joycon.h b/bdk/input/joycon.h index 187ccb7..932c836 100644 --- a/bdk/input/joycon.h +++ b/bdk/input/joycon.h @@ -19,7 +19,7 @@ #ifndef __JOYCON_H_ #define __JOYCON_H_ -#include "../utils/types.h" +#include #define JC_BTNS_DIRECTION_PAD 0xF0000 #define JC_BTNS_PREV_NEXT 0x800080 diff --git a/bdk/input/touch.c b/bdk/input/touch.c index 9887e6f..eef61ec 100644 --- a/bdk/input/touch.c +++ b/bdk/input/touch.c @@ -19,19 +19,19 @@ #include -#include "../soc/clock.h" -#include "../soc/i2c.h" -#include "../soc/pinmux.h" -#include "../power/max7762x.h" -#include "../power/max77620.h" -#include "../soc/gpio.h" -#include "../soc/t210.h" -#include "../utils/btn.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "touch.h" -#include "../gfx/gfx.h" +#include #define DPRINTF(...) gfx_printf(__VA_ARGS__) static int touch_command(u8 cmd, u8 *buf, u8 size) diff --git a/bdk/input/touch.h b/bdk/input/touch.h index 87b6fb2..9245be3 100644 --- a/bdk/input/touch.h +++ b/bdk/input/touch.h @@ -20,7 +20,7 @@ #ifndef __TOUCH_H_ #define __TOUCH_H_ -#include "../utils/types.h" +#include #define STMFTS_I2C_ADDR 0x49 diff --git a/bdk/libs/compr/blz.h b/bdk/libs/compr/blz.h index 4171049..a1cce37 100644 --- a/bdk/libs/compr/blz.h +++ b/bdk/libs/compr/blz.h @@ -17,7 +17,7 @@ #ifndef _BLZ_H_ #define _BLZ_H_ -#include "../../utils/types.h" +#include typedef struct _blz_footer { diff --git a/bdk/libs/fatfs/diskio.h b/bdk/libs/fatfs/diskio.h index 31b855d..6959fb4 100644 --- a/bdk/libs/fatfs/diskio.h +++ b/bdk/libs/fatfs/diskio.h @@ -9,7 +9,7 @@ extern "C" { #endif -#include "../../utils/types.h" +#include /* Status of Disk Functions */ typedef BYTE DSTATUS; diff --git a/bdk/libs/fatfs/ff.c b/bdk/libs/fatfs/ff.c index c6c4d75..9035f35 100644 --- a/bdk/libs/fatfs/ff.c +++ b/bdk/libs/fatfs/ff.c @@ -38,7 +38,7 @@ #include "ff.h" /* Declarations of FatFs API */ #include "diskio.h" /* Declarations of device I/O functions */ -#include "../../gfx/gfx.h" +#include #define EFSPRINTF(text, ...) print_error(); gfx_printf("%k"text"%k\n", 0xFFFFFF00, 0xFFFFFFFF); //#define EFSPRINTF(...) diff --git a/bdk/libs/fatfs/ff.h b/bdk/libs/fatfs/ff.h index af1151f..a83cf63 100644 --- a/bdk/libs/fatfs/ff.h +++ b/bdk/libs/fatfs/ff.h @@ -26,8 +26,8 @@ extern "C" { #endif -#include "../../utils/types.h" /* Basic integer types */ -#include "ffconf.h" /* FatFs configuration options */ +#include /* Basic integer types */ +#include /* FatFs configuration options */ #if FF_DEFINED != FFCONF_DEF #error Wrong configuration file (ffconf.h). diff --git a/bdk/libs/lv_conf.h b/bdk/libs/lv_conf.h index 797d1f9..ab7f311 100644 --- a/bdk/libs/lv_conf.h +++ b/bdk/libs/lv_conf.h @@ -17,8 +17,8 @@ #ifndef LV_CONF_H #define LV_CONF_H -#include "../utils/types.h" -#include "../../../common/memory_map.h" +#include +#include /*=================== Dynamic memory *===================*/ @@ -32,7 +32,7 @@ # 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*/ +# define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ # define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/ # define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/ #endif /*LV_MEM_CUSTOM*/ @@ -149,7 +149,7 @@ /*HAL settings*/ #define LV_TICK_CUSTOM 1 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */ #if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE "../../../utils/util.h" /*Header for the sys time function*/ +#define LV_TICK_CUSTOM_INCLUDE /*Header for the sys time function*/ #define LV_TICK_CUSTOM_SYS_TIME_EXPR (get_tmr_ms()) /*Expression evaluating to current systime in ms*/ #endif /*LV_TICK_CUSTOM*/ diff --git a/bdk/libs/lvgl/lv_fonts/hekate_symbol_120.c b/bdk/libs/lvgl/lv_fonts/hekate_symbol_120.c index 9a27deb..c97eda6 100644 --- a/bdk/libs/lvgl/lv_fonts/hekate_symbol_120.c +++ b/bdk/libs/lvgl/lv_fonts/hekate_symbol_120.c @@ -16,7 +16,7 @@ #include "../lv_misc/lv_font.h" -#include "../../../../../common/memory_map.h" +#include #if USE_HEKATE_SYMBOL_120 != 0 /*Can be enabled in lv_conf.h*/ diff --git a/bdk/libs/lvgl/lv_fonts/hekate_symbol_20.c b/bdk/libs/lvgl/lv_fonts/hekate_symbol_20.c index 8ded987..426bde8 100644 --- a/bdk/libs/lvgl/lv_fonts/hekate_symbol_20.c +++ b/bdk/libs/lvgl/lv_fonts/hekate_symbol_20.c @@ -16,7 +16,7 @@ #include "../lv_misc/lv_font.h" -#include "../../../../../common/memory_map.h" +#include #if USE_HEKATE_SYMBOL_20 != 0 /*Can be enabled in lv_conf.h*/ diff --git a/bdk/libs/lvgl/lv_fonts/hekate_symbol_30.c b/bdk/libs/lvgl/lv_fonts/hekate_symbol_30.c index 08842d2..4e0da47 100644 --- a/bdk/libs/lvgl/lv_fonts/hekate_symbol_30.c +++ b/bdk/libs/lvgl/lv_fonts/hekate_symbol_30.c @@ -16,7 +16,7 @@ #include "../lv_misc/lv_font.h" -#include "../../../../../common/memory_map.h" +#include #if USE_HEKATE_SYMBOL_30 != 0 /*Can be enabled in lv_conf.h*/ diff --git a/bdk/libs/lvgl/lv_fonts/interui_20.c b/bdk/libs/lvgl/lv_fonts/interui_20.c index db0bbe5..5f50c6c 100644 --- a/bdk/libs/lvgl/lv_fonts/interui_20.c +++ b/bdk/libs/lvgl/lv_fonts/interui_20.c @@ -16,7 +16,7 @@ #include "../lv_misc/lv_font.h" -#include "../../../../../common/memory_map.h" +#include #if USE_INTERUI_20 != 0 /*Can be enabled in lv_conf.h*/ diff --git a/bdk/libs/lvgl/lv_fonts/interui_30.c b/bdk/libs/lvgl/lv_fonts/interui_30.c index 1f97abf..238bcb1 100644 --- a/bdk/libs/lvgl/lv_fonts/interui_30.c +++ b/bdk/libs/lvgl/lv_fonts/interui_30.c @@ -16,7 +16,7 @@ #include "../lv_misc/lv_font.h" -#include "../../../../../common/memory_map.h" +#include #if USE_INTERUI_30 != 0 /*Can be enabled in lv_conf.h*/ diff --git a/bdk/libs/lvgl/lv_fonts/ubuntu_mono.c b/bdk/libs/lvgl/lv_fonts/ubuntu_mono.c index b88cb2c..4c988fc 100644 --- a/bdk/libs/lvgl/lv_fonts/ubuntu_mono.c +++ b/bdk/libs/lvgl/lv_fonts/ubuntu_mono.c @@ -16,7 +16,7 @@ #include "../lv_misc/lv_font.h" -#include "../../../../../common/memory_map.h" +#include #if USE_UBUNTU_MONO != 0 /*Can be enabled in lv_conf.h*/ diff --git a/bdk/libs/lvgl/lv_hal/lv_hal_indev.h b/bdk/libs/lvgl/lv_hal/lv_hal_indev.h index b9d4255..2355baa 100644 --- a/bdk/libs/lvgl/lv_hal/lv_hal_indev.h +++ b/bdk/libs/lvgl/lv_hal/lv_hal_indev.h @@ -17,7 +17,7 @@ extern "C" { *********************/ #include #include "lv_hal.h" -#include "../../../utils/types.h" +#include #include "../lv_misc/lv_area.h" #include "../lv_core/lv_obj.h" diff --git a/bdk/libs/lvgl/lv_misc/lv_area.h b/bdk/libs/lvgl/lv_misc/lv_area.h index bae0753..63ea059 100644 --- a/bdk/libs/lvgl/lv_misc/lv_area.h +++ b/bdk/libs/lvgl/lv_misc/lv_area.h @@ -15,7 +15,7 @@ extern "C" { * INCLUDES *********************/ #include -#include "../../../utils/types.h" +#include /********************* * DEFINES diff --git a/bdk/libs/lvgl/lv_misc/lv_circ.h b/bdk/libs/lvgl/lv_misc/lv_circ.h index f0fbb3f..bc1c1dd 100644 --- a/bdk/libs/lvgl/lv_misc/lv_circ.h +++ b/bdk/libs/lvgl/lv_misc/lv_circ.h @@ -16,7 +16,7 @@ extern "C" { *********************/ #include #include "lv_area.h" -#include "../../../utils/types.h" +#include /********************* * DEFINES diff --git a/bdk/libs/lvgl/lv_misc/lv_log.c b/bdk/libs/lvgl/lv_misc/lv_log.c index 79f8113..bd59cf3 100644 --- a/bdk/libs/lvgl/lv_misc/lv_log.c +++ b/bdk/libs/lvgl/lv_misc/lv_log.c @@ -11,9 +11,9 @@ #if LV_LOG_PRINTF #include -#include "../../../mem/heap.h" -#include "../../../soc/uart.h" -#include "../../../utils/sprintf.h" +#include +#include +#include #endif /********************* * DEFINES diff --git a/bdk/mem/heap.c b/bdk/mem/heap.c index cafd806..d249140 100644 --- a/bdk/mem/heap.c +++ b/bdk/mem/heap.c @@ -1,7 +1,6 @@ /* * Copyright (c) 2018 naehrwert * Copyright (c) 2018-2020 CTCaer - * Copyright (c) 2018 M4xw * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -18,8 +17,7 @@ #include #include "heap.h" -#include "../gfx/gfx.h" -#include "../../common/common_heap.h" +#include static void _heap_create(heap_t *heap, u32 start) { diff --git a/bdk/mem/heap.h b/bdk/mem/heap.h index 05faee2..811f13d 100644 --- a/bdk/mem/heap.h +++ b/bdk/mem/heap.h @@ -18,8 +18,28 @@ #ifndef _HEAP_H_ #define _HEAP_H_ -#include "../utils/types.h" -#include "../../common/common_heap.h" +#include + +typedef struct _hnode +{ + int used; + u32 size; + struct _hnode *prev; + struct _hnode *next; + u32 align[4]; // Align to arch cache line size. +} hnode_t; + +typedef struct _heap +{ + u32 start; + hnode_t *first; +} heap_t; + +typedef struct +{ + u32 total; + u32 used; +} heap_monitor_t; void heap_init(u32 base); void heap_copy(heap_t *heap); diff --git a/bdk/mem/mc.c b/bdk/mem/mc.c index dd508e2..8a0da1a 100644 --- a/bdk/mem/mc.c +++ b/bdk/mem/mc.c @@ -1,7 +1,24 @@ -#include "../mem/mc.h" -#include "../soc/t210.h" -#include "../soc/clock.h" -#include "../utils/util.h" +/* + * Copyright (c) 2018 naehrwert + * Copyright (c) 2018 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 . + */ + +#include +#include +#include +#include void mc_config_tsec_carveout(u32 bom, u32 size1mb, bool lock) { diff --git a/bdk/mem/mc.h b/bdk/mem/mc.h index 6a28bde..1a9bc83 100644 --- a/bdk/mem/mc.h +++ b/bdk/mem/mc.h @@ -1,8 +1,24 @@ +/* + * Copyright (c) 2018 naehrwert + * + * 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 _MC_H_ #define _MC_H_ -#include "../utils/types.h" -#include "../mem/mc_t210.h" +#include +#include void mc_config_tsec_carveout(u32 bom, u32 size1mb, bool lock); void mc_config_carveout(); diff --git a/bdk/mem/minerva.c b/bdk/mem/minerva.c index e30fa56..259c63a 100644 --- a/bdk/mem/minerva.c +++ b/bdk/mem/minerva.c @@ -18,13 +18,13 @@ #include #include "minerva.h" -#include "../soc/fuse.h" -#include "../utils/util.h" -#include "../soc/clock.h" -#include "../ianos/ianos.h" -#include "../soc/fuse.h" -#include "../soc/t210.h" +#include +#include +#include +#include +#include +#include extern volatile nyx_storage_t *nyx_str; diff --git a/bdk/mem/minerva.h b/bdk/mem/minerva.h index 9be55c9..ed80b95 100644 --- a/bdk/mem/minerva.h +++ b/bdk/mem/minerva.h @@ -18,7 +18,7 @@ #define _FE_MINERVA_H_ #include "mtc_table.h" -#include "../utils/types.h" +#include #define MTC_INIT_MAGIC 0x3043544D #define MTC_NEW_MAGIC 0x5243544D diff --git a/bdk/mem/mtc_table.h b/bdk/mem/mtc_table.h index 38a3e2f..e24fa81 100644 --- a/bdk/mem/mtc_table.h +++ b/bdk/mem/mtc_table.h @@ -20,7 +20,7 @@ #ifndef _MTC_TABLE_H_ #define _MTC_TABLE_H_ -#include "../utils/types.h" +#include typedef struct { diff --git a/bdk/mem/sdram.c b/bdk/mem/sdram.c index 9990848..e58a1eb 100644 --- a/bdk/mem/sdram.c +++ b/bdk/mem/sdram.c @@ -18,23 +18,23 @@ #include -#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" -#include "../soc/fuse.h" -#include "../soc/i2c.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define CONFIG_SDRAM_KEEP_ALIVE #ifdef CONFIG_SDRAM_COMPRESS_CFG -#include "../libs/compr/lz.h" +#include #include "sdram_config_lz.inl" #else #include "sdram_config.inl" diff --git a/bdk/mem/sdram.h b/bdk/mem/sdram.h index 059bc9c..620c078 100644 --- a/bdk/mem/sdram.h +++ b/bdk/mem/sdram.h @@ -17,8 +17,8 @@ #ifndef _SDRAM_H_ #define _SDRAM_H_ -#include "emc.h" -#include "sdram_param_t210.h" +#include +#include void sdram_init(); sdram_params_t *sdram_get_params(); diff --git a/bdk/mem/sdram_lp0.c b/bdk/mem/sdram_lp0.c index 869e85a..2a83c27 100644 --- a/bdk/mem/sdram_lp0.c +++ b/bdk/mem/sdram_lp0.c @@ -14,9 +14,9 @@ * more details. */ -#include "../soc/t210.h" -#include "../soc/pmc_lp0_t210.h" -#include "sdram_lp0_param_t210.h" +#include +#include +#include /* * This function reads SDRAM parameters from the common BCT format and diff --git a/bdk/mem/sdram_lp0_param_t210.h b/bdk/mem/sdram_lp0_param_t210.h index 9028990..1422ed3 100644 --- a/bdk/mem/sdram_lp0_param_t210.h +++ b/bdk/mem/sdram_lp0_param_t210.h @@ -23,7 +23,7 @@ #ifndef __SOC_NVIDIA_TEGRA210_SDRAM_PARAM_H__ #define __SOC_NVIDIA_TEGRA210_SDRAM_PARAM_H__ -#include "../utils/types.h" +#include enum { diff --git a/bdk/mem/smmu.c b/bdk/mem/smmu.c index ef4f9bb..6ee99b9 100644 --- a/bdk/mem/smmu.c +++ b/bdk/mem/smmu.c @@ -17,12 +17,12 @@ #include -#include "smmu.h" -#include "../soc/ccplex.h" -#include "../soc/t210.h" -#include "../mem/mc_t210.h" -#include "../utils/util.h" -#include "../utils/aarch64_util.h" +#include +#include +#include +#include +#include +#include bool smmu_used = false; u8 *_pageheap = (u8 *)SMMU_HEAP_ADDR; diff --git a/bdk/mem/smmu.h b/bdk/mem/smmu.h index 827d58b..7846253 100644 --- a/bdk/mem/smmu.h +++ b/bdk/mem/smmu.h @@ -14,7 +14,7 @@ * along with this program. If not, see . */ -#include "../utils/types.h" +#include #define SMMU_HEAP_ADDR 0xA0000000 diff --git a/bdk/module.h b/bdk/module.h index 93a1541..6ec303f 100644 --- a/bdk/module.h +++ b/bdk/module.h @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -#pragma once +#ifndef _MODULE_H_ +#define _MODULE_H_ + #include -//TODO: Move it to BDK -#include "common_gfx.h" -#include "common_heap.h" +#include // Module Callback typedef void (*cbMainModule_t)(const char *s); @@ -28,8 +28,8 @@ typedef void (*memset_t)(void *, int, size_t); typedef struct _bdkParams_t { - gfx_con_t *gfxCon; - gfx_ctxt_t *gfxCtx; + void *gfxCon; + void *gfxCtx; heap_t *sharedHeap; memcpy_t memcpy; memset_t memset; @@ -37,3 +37,5 @@ typedef struct _bdkParams_t // Module Entrypoint typedef void (*moduleEntrypoint_t)(void *, bdkParams_t); + +#endif diff --git a/bdk/power/bq24193.c b/bdk/power/bq24193.c index 0ade8da..2b2e744 100644 --- a/bdk/power/bq24193.c +++ b/bdk/power/bq24193.c @@ -17,8 +17,8 @@ */ #include "bq24193.h" -#include "../soc/i2c.h" -#include "../utils/util.h" +#include +#include static u8 bq24193_get_reg(u8 reg) { diff --git a/bdk/power/max17050.c b/bdk/power/max17050.c index f70cfec..2491466 100644 --- a/bdk/power/max17050.c +++ b/bdk/power/max17050.c @@ -23,8 +23,8 @@ */ #include "max17050.h" -#include "../soc/i2c.h" -#include "../utils/util.h" +#include +#include /* Status register bits */ #define STATUS_POR_BIT (1 << 1) diff --git a/bdk/power/max17050.h b/bdk/power/max17050.h index eb55e65..254aca3 100644 --- a/bdk/power/max17050.h +++ b/bdk/power/max17050.h @@ -24,7 +24,7 @@ #ifndef __MAX17050_H_ #define __MAX17050_H_ -#include "../utils/types.h" +#include #define MAX17050_STATUS_BattAbsent (1 << 3) #define MAX17050_DEFAULT_SNS_RESISTOR 10000 diff --git a/bdk/power/max7762x.c b/bdk/power/max7762x.c index ce07cbe..425ce1f 100644 --- a/bdk/power/max7762x.c +++ b/bdk/power/max7762x.c @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -#include "max7762x.h" -#include "max77620.h" -#include "../soc/i2c.h" -#include "../utils/util.h" +#include +#include +#include +#include #define REGULATOR_SD 0 #define REGULATOR_LDO 1 diff --git a/bdk/power/max7762x.h b/bdk/power/max7762x.h index aefe892..f60c3b2 100644 --- a/bdk/power/max7762x.h +++ b/bdk/power/max7762x.h @@ -18,7 +18,7 @@ #ifndef _MAX7762X_H_ #define _MAX7762X_H_ -#include "../utils/types.h" +#include /* * Switch Power domains (max77620): diff --git a/bdk/power/regulator_5v.c b/bdk/power/regulator_5v.c index 7705490..c61db64 100644 --- a/bdk/power/regulator_5v.c +++ b/bdk/power/regulator_5v.c @@ -14,11 +14,11 @@ * along with this program. If not, see . */ -#include "../soc/gpio.h" -#include "../soc/pinmux.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" -#include "../utils/types.h" +#include +#include +#include +#include +#include static u8 reg_5v_dev = 0; diff --git a/bdk/power/regulator_5v.h b/bdk/power/regulator_5v.h index 7608881..e916fbd 100644 --- a/bdk/power/regulator_5v.h +++ b/bdk/power/regulator_5v.h @@ -17,7 +17,7 @@ #ifndef _REGULATOR_5V_H_ #define _REGULATOR_5V_H_ -#include "../utils/types.h" +#include enum { diff --git a/bdk/rtc/max77620-rtc.c b/bdk/rtc/max77620-rtc.c index 04c6937..164df75 100644 --- a/bdk/rtc/max77620-rtc.c +++ b/bdk/rtc/max77620-rtc.c @@ -17,9 +17,9 @@ * along with this program. If not, see . */ -#include "max77620-rtc.h" -#include "../soc/i2c.h" -#include "../utils/util.h" +#include +#include +#include void max77620_rtc_get_time(rtc_time_t *time) { diff --git a/bdk/rtc/max77620-rtc.h b/bdk/rtc/max77620-rtc.h index 8c3231e..d9e216a 100644 --- a/bdk/rtc/max77620-rtc.h +++ b/bdk/rtc/max77620-rtc.h @@ -19,7 +19,7 @@ #ifndef _MFD_MAX77620_RTC_H_ #define _MFD_MAX77620_RTC_H_ -#include "../utils/types.h" +#include #define MAX77620_RTC_I2C_ADDR 0x68 diff --git a/bdk/sec/se.c b/bdk/sec/se.c index 021d1f5..bc6fa44 100644 --- a/bdk/sec/se.c +++ b/bdk/sec/se.c @@ -17,12 +17,12 @@ #include -#include "../sec/se.h" -#include "../mem/heap.h" -#include "../soc/bpmp.h" -#include "../soc/t210.h" -#include "../sec/se_t210.h" -#include "../utils/util.h" +#include "se.h" +#include "se_t210.h" +#include +#include +#include +#include typedef struct _se_ll_t { diff --git a/bdk/sec/se.h b/bdk/sec/se.h index 2baedbb..ba35088 100644 --- a/bdk/sec/se.h +++ b/bdk/sec/se.h @@ -17,7 +17,7 @@ #ifndef _SE_H_ #define _SE_H_ -#include "../utils/types.h" +#include void se_rsa_acc_ctrl(u32 rs, u32 flags); void se_key_acc_ctrl(u32 ks, u32 flags); diff --git a/bdk/sec/se_t210.h b/bdk/sec/se_t210.h index 01828c7..83557f7 100644 --- a/bdk/sec/se_t210.h +++ b/bdk/sec/se_t210.h @@ -21,7 +21,7 @@ #ifndef _CRYPTO_TEGRA_SE_H #define _CRYPTO_TEGRA_SE_H -#include "../utils/types.h" +#include #define TEGRA_SE_CRA_PRIORITY 300 #define TEGRA_SE_COMPOSITE_PRIORITY 400 diff --git a/bdk/sec/tsec.c b/bdk/sec/tsec.c index 9f0ce58..b4485b1 100644 --- a/bdk/sec/tsec.c +++ b/bdk/sec/tsec.c @@ -18,19 +18,19 @@ #include -#include "../sec/tsec.h" -#include "../sec/tsec_t210.h" -#include "../sec/se_t210.h" -#include "../soc/bpmp.h" -#include "../soc/clock.h" -#include "../soc/kfuse.h" -#include "../soc/smmu.h" -#include "../soc/t210.h" -#include "../mem/heap.h" -#include "../mem/mc.h" -#include "../utils/util.h" +#include "tsec.h" +#include "tsec_t210.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include -// #include "../gfx/gfx.h" +// #include #define PKG11_MAGIC 0x31314B50 #define KB_TSEC_FW_EMU_COMPAT 6 // KB ID for HOS 6.2.0. diff --git a/bdk/sec/tsec.h b/bdk/sec/tsec.h index 45d994c..6206034 100644 --- a/bdk/sec/tsec.h +++ b/bdk/sec/tsec.h @@ -18,7 +18,7 @@ #ifndef _TSEC_H_ #define _TSEC_H_ -#include "../utils/types.h" +#include typedef struct _tsec_ctxt_t { diff --git a/bdk/soc/bpmp.c b/bdk/soc/bpmp.c index eea0de5..1a8a205 100644 --- a/bdk/soc/bpmp.c +++ b/bdk/soc/bpmp.c @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -#include "bpmp.h" -#include "clock.h" -#include "t210.h" -#include "../../common/memory_map.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include #define BPMP_MMU_CACHE_LINE_SIZE 0x20 diff --git a/bdk/soc/bpmp.h b/bdk/soc/bpmp.h index aad901a..81f000b 100644 --- a/bdk/soc/bpmp.h +++ b/bdk/soc/bpmp.h @@ -19,7 +19,7 @@ #ifndef _BPMP_H_ #define _BPMP_H_ -#include "../utils/types.h" +#include typedef enum { diff --git a/bdk/soc/ccplex.c b/bdk/soc/ccplex.c index 0d46b1c..24a4787 100644 --- a/bdk/soc/ccplex.c +++ b/bdk/soc/ccplex.c @@ -14,14 +14,14 @@ * along with this program. If not, see . */ -#include "../soc/ccplex.h" -#include "../soc/i2c.h" -#include "../soc/clock.h" -#include "../utils/util.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" -#include "../power/max77620.h" -#include "../power/max7762x.h" +#include +#include +#include +#include +#include +#include +#include +#include void _ccplex_enable_power() { diff --git a/bdk/soc/ccplex.h b/bdk/soc/ccplex.h index 91430c7..fb5be92 100644 --- a/bdk/soc/ccplex.h +++ b/bdk/soc/ccplex.h @@ -17,7 +17,7 @@ #ifndef _CCPLEX_H_ #define _CCPLEX_H_ -#include "../utils/types.h" +#include void ccplex_boot_cpu0(u32 entry); diff --git a/bdk/soc/clock.c b/bdk/soc/clock.c index e19c993..41e69a2 100644 --- a/bdk/soc/clock.c +++ b/bdk/soc/clock.c @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -#include "../soc/clock.h" -#include "../soc/t210.h" -#include "../utils/util.h" -#include "../storage/sdmmc.h" +#include +#include +#include +#include /* * CLOCK Peripherals: diff --git a/bdk/soc/clock.h b/bdk/soc/clock.h index a9b9f9a..bbcd482 100644 --- a/bdk/soc/clock.h +++ b/bdk/soc/clock.h @@ -18,7 +18,7 @@ #ifndef _CLOCK_H_ #define _CLOCK_H_ -#include "../utils/types.h" +#include /*! Clock registers. */ #define CLK_RST_CONTROLLER_RST_SOURCE 0x0 diff --git a/bdk/soc/fuse.c b/bdk/soc/fuse.c index 8b30a74..84c366d 100644 --- a/bdk/soc/fuse.c +++ b/bdk/soc/fuse.c @@ -19,8 +19,8 @@ #include -#include "../soc/fuse.h" -#include "../soc/t210.h" +#include +#include #define ARRAYSIZE(x) (sizeof(x) / sizeof(*x)) diff --git a/bdk/soc/fuse.h b/bdk/soc/fuse.h index 5e59609..e5ca2fb 100644 --- a/bdk/soc/fuse.h +++ b/bdk/soc/fuse.h @@ -19,7 +19,7 @@ #ifndef _FUSE_H_ #define _FUSE_H_ -#include "../utils/types.h" +#include /*! Fuse registers. */ #define FUSE_CTRL 0x0 diff --git a/bdk/soc/gpio.c b/bdk/soc/gpio.c index 3371947..281e867 100644 --- a/bdk/soc/gpio.c +++ b/bdk/soc/gpio.c @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -#include "gpio.h" -#include "t210.h" +#include +#include #define GPIO_BANK_IDX(port) (port >> 2) diff --git a/bdk/soc/gpio.h b/bdk/soc/gpio.h index a7f999d..99aed88 100644 --- a/bdk/soc/gpio.h +++ b/bdk/soc/gpio.h @@ -18,7 +18,7 @@ #ifndef _GPIO_H_ #define _GPIO_H_ -#include "../utils/types.h" +#include #define GPIO_MODE_SPIO 0 #define GPIO_MODE_GPIO 1 diff --git a/bdk/soc/hw_init.c b/bdk/soc/hw_init.c index 53f8c08..faaa044 100644 --- a/bdk/soc/hw_init.c +++ b/bdk/soc/hw_init.c @@ -17,32 +17,32 @@ #include -#include "hw_init.h" -#include "bpmp.h" -#include "clock.h" -#include "fuse.h" -#include "gpio.h" -#include "i2c.h" -#include "pinmux.h" -#include "pmc.h" -#include "uart.h" -#include "t210.h" -#include "../input/joycon.h" -#include "../input/touch.h" -#include "../gfx/di.h" -#include "../mem/mc.h" -#include "../mem/minerva.h" -#include "../mem/sdram.h" -#include "../sec/se.h" -#include "../sec/se_t210.h" -#include "../power/max77620.h" -#include "../power/max7762x.h" -#include "../gfx/di.h" -#include "../power/regulator_5v.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../thermal/fan.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include extern boot_cfg_t b_cfg; extern volatile nyx_storage_t *nyx_str; diff --git a/bdk/soc/hw_init.h b/bdk/soc/hw_init.h index b92814b..d19f271 100644 --- a/bdk/soc/hw_init.h +++ b/bdk/soc/hw_init.h @@ -18,7 +18,7 @@ #ifndef _HW_INIT_H_ #define _HW_INIT_H_ -#include "../utils/types.h" +#include void config_hw(); void reconfig_hw_workaround(bool extra_reconfig, u32 magic); diff --git a/bdk/soc/i2c.c b/bdk/soc/i2c.c index 40ab097..d3f31e7 100644 --- a/bdk/soc/i2c.c +++ b/bdk/soc/i2c.c @@ -17,8 +17,8 @@ #include -#include "i2c.h" -#include "../utils/util.h" +#include +#include static const u32 i2c_addrs[] = { 0x7000C000, 0x7000C400, 0x7000C500, diff --git a/bdk/soc/i2c.h b/bdk/soc/i2c.h index 4f04bac..a630b15 100644 --- a/bdk/soc/i2c.h +++ b/bdk/soc/i2c.h @@ -18,7 +18,7 @@ #ifndef _I2C_H_ #define _I2C_H_ -#include "../utils/types.h" +#include #define I2C_1 0 #define I2C_2 1 diff --git a/bdk/soc/irq.c b/bdk/soc/irq.c index 627976d..cb34d12 100644 --- a/bdk/soc/irq.c +++ b/bdk/soc/irq.c @@ -19,9 +19,9 @@ #include #include "irq.h" -#include "t210.h" -#include "../gfx/gfx.h" -#include "../mem/heap.h" +#include +#include +#include //#define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DPRINTF(...) diff --git a/bdk/soc/irq.h b/bdk/soc/irq.h index c77d980..d33ffbe 100644 --- a/bdk/soc/irq.h +++ b/bdk/soc/irq.h @@ -19,7 +19,7 @@ #ifndef IRQ_H #define IRQ_H -#include "../utils/types.h" +#include #define IRQ_MAX_HANDLERS 16 diff --git a/bdk/soc/kfuse.c b/bdk/soc/kfuse.c index cdfba53..2da9593 100644 --- a/bdk/soc/kfuse.c +++ b/bdk/soc/kfuse.c @@ -14,9 +14,9 @@ * along with this program. If not, see . */ -#include "../soc/kfuse.h" -#include "../soc/clock.h" -#include "../soc/t210.h" +#include +#include +#include int kfuse_wait_ready() { diff --git a/bdk/soc/kfuse.h b/bdk/soc/kfuse.h index a535803..099dcac 100644 --- a/bdk/soc/kfuse.h +++ b/bdk/soc/kfuse.h @@ -17,7 +17,7 @@ #ifndef _KFUSE_H_ #define _KFUSE_H_ -#include "../utils/types.h" +#include #define KFUSE_STATE_SOFTRESET (1 << 31) #define KFUSE_STATE_STOP (1 << 25) diff --git a/bdk/soc/pinmux.c b/bdk/soc/pinmux.c index 582ab29..2601cdf 100644 --- a/bdk/soc/pinmux.c +++ b/bdk/soc/pinmux.c @@ -14,8 +14,8 @@ * along with this program. If not, see . */ -#include "../soc/pinmux.h" -#include "../soc/t210.h" +#include +#include void pinmux_config_uart(u32 idx) { diff --git a/bdk/soc/pinmux.h b/bdk/soc/pinmux.h index ca57584..9a3ed5c 100644 --- a/bdk/soc/pinmux.h +++ b/bdk/soc/pinmux.h @@ -17,7 +17,7 @@ #ifndef _PINMUX_H_ #define _PINMUX_H_ -#include "../utils/types.h" +#include /*! APB MISC registers. */ #define APB_MISC_GP_SDMMC1_CLK_LPBK_CONTROL 0x8D4 diff --git a/bdk/soc/pmc_lp0_t210.h b/bdk/soc/pmc_lp0_t210.h index 641d9f7..5b87d5a 100644 --- a/bdk/soc/pmc_lp0_t210.h +++ b/bdk/soc/pmc_lp0_t210.h @@ -14,7 +14,7 @@ #ifndef _TEGRA210_PMC_H_ #define _TEGRA210_PMC_H_ -#include "../utils/types.h" +#include struct tegra_pmc_regs { diff --git a/bdk/soc/t210.h b/bdk/soc/t210.h index b45ef2a..78432c1 100644 --- a/bdk/soc/t210.h +++ b/bdk/soc/t210.h @@ -17,7 +17,7 @@ #ifndef _T210_H_ #define _T210_H_ -#include "../utils/types.h" +#include #define BOOTROM_BASE 0x100000 #define IRAM_BASE 0x40000000 @@ -162,6 +162,8 @@ #define APB_MISC_PP_STRAPPING_OPT_A 0x08 #define APB_MISC_PP_PINMUX_GLOBAL 0x40 #define APB_MISC_GP_HIDREV 0x804 +#define GP_HIDREV_MAJOR_T210 0x1 +#define GP_HIDREV_MAJOR_T210B01 0x2 #define APB_MISC_GP_AUD_MCLK_CFGPADCTRL 0x8F4 #define APB_MISC_GP_LCD_BL_PWM_CFGPADCTRL 0xA34 #define APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL 0xA98 diff --git a/bdk/soc/uart.c b/bdk/soc/uart.c index 92c22a1..75e18b8 100644 --- a/bdk/soc/uart.c +++ b/bdk/soc/uart.c @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -#include "../soc/uart.h" -#include "../soc/clock.h" -#include "../soc/t210.h" -#include "../utils/util.h" +#include +#include +#include +#include /* UART A, B, C, D and E. */ static const u32 uart_baseoff[5] = { 0, 0x40, 0x200, 0x300, 0x400 }; diff --git a/bdk/soc/uart.h b/bdk/soc/uart.h index ef22108..809192a 100644 --- a/bdk/soc/uart.h +++ b/bdk/soc/uart.h @@ -18,7 +18,7 @@ #ifndef _UART_H_ #define _UART_H_ -#include "../utils/types.h" +#include #define UART_A 0 #define UART_B 1 diff --git a/bdk/storage/mbr_gpt.h b/bdk/storage/mbr_gpt.h index 923b6d2..9e0e97d 100644 --- a/bdk/storage/mbr_gpt.h +++ b/bdk/storage/mbr_gpt.h @@ -18,7 +18,7 @@ #ifndef MBR_GPT_H #define MBR_GPT_H -#include "../utils/types.h" +#include typedef struct _mbr_chs_t { diff --git a/bdk/storage/nx_sd.h b/bdk/storage/nx_sd.h index fc1ad18..bc4c2d4 100644 --- a/bdk/storage/nx_sd.h +++ b/bdk/storage/nx_sd.h @@ -18,9 +18,9 @@ #ifndef NX_SD_H #define NX_SD_H -#include "sdmmc.h" -#include "sdmmc_driver.h" -#include "../libs/fatfs/ff.h" +#include +#include +#include enum { diff --git a/bdk/storage/ramdisk.c b/bdk/storage/ramdisk.c index 5143b3b..e7b7c01 100644 --- a/bdk/storage/ramdisk.c +++ b/bdk/storage/ramdisk.c @@ -19,10 +19,10 @@ #include #include "ramdisk.h" -#include "../mem/heap.h" -#include "../utils/types.h" +#include +#include -#include "../../../common/memory_map.h" +#include int ram_disk_init(FATFS *ram_fs) { diff --git a/bdk/storage/ramdisk.h b/bdk/storage/ramdisk.h index 12c8ffb..ef43bb5 100644 --- a/bdk/storage/ramdisk.h +++ b/bdk/storage/ramdisk.h @@ -19,7 +19,7 @@ #ifndef RAM_DISK_H #define RAM_DISK_H -#include "../libs/fatfs/ff.h" +#include #define RAMDISK_CLUSTER_SZ 32768 diff --git a/bdk/storage/sdmmc.c b/bdk/storage/sdmmc.c index 5becc4f..fc41458 100644 --- a/bdk/storage/sdmmc.c +++ b/bdk/storage/sdmmc.c @@ -16,14 +16,14 @@ */ #include -#include "sdmmc.h" -#include "mmc.h" -#include "nx_sd.h" -#include "sd.h" -#include "../../common/memory_map.h" -#include "../gfx/gfx.h" -#include "../mem/heap.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include //#define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DPRINTF(...) diff --git a/bdk/storage/sdmmc.h b/bdk/storage/sdmmc.h index aacc26a..6bfad77 100644 --- a/bdk/storage/sdmmc.h +++ b/bdk/storage/sdmmc.h @@ -18,8 +18,8 @@ #ifndef _SDMMC_H_ #define _SDMMC_H_ -#include "../utils/types.h" -#include "sdmmc_driver.h" +#include +#include extern u32 sd_power_cycle_time_start; diff --git a/bdk/storage/sdmmc_driver.c b/bdk/storage/sdmmc_driver.c index 957a0bc..557fe8d 100644 --- a/bdk/storage/sdmmc_driver.c +++ b/bdk/storage/sdmmc_driver.c @@ -17,17 +17,17 @@ #include -#include "mmc.h" -#include "sdmmc.h" -#include "../gfx/gfx.h" -#include "../power/max7762x.h" -#include "../soc/bpmp.h" -#include "../soc/clock.h" -#include "../soc/gpio.h" -#include "../soc/pinmux.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include //#define DPRINTF(...) gfx_printf(__VA_ARGS__) //#define ERROR_EXTRA_PRINTING diff --git a/bdk/storage/sdmmc_driver.h b/bdk/storage/sdmmc_driver.h index 736faa8..2937d93 100644 --- a/bdk/storage/sdmmc_driver.h +++ b/bdk/storage/sdmmc_driver.h @@ -18,8 +18,8 @@ #ifndef _SDMMC_DRIVER_H_ #define _SDMMC_DRIVER_H_ -#include "../utils/types.h" -#include "sdmmc_t210.h" +#include +#include /*! SDMMC controller IDs. */ #define SDMMC_1 0 diff --git a/bdk/storage/sdmmc_t210.h b/bdk/storage/sdmmc_t210.h index eb17714..c5ecf11 100644 --- a/bdk/storage/sdmmc_t210.h +++ b/bdk/storage/sdmmc_t210.h @@ -18,7 +18,7 @@ #ifndef _SDMMC_T210_H_ #define _SDMMC_T210_H_ -#include "../utils/types.h" +#include #define TEGRA_MMC_VNDR_TUN_CTRL0_TAP_VAL_UPDATED_BY_HW 0x20000 #define TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE 0x80000000 diff --git a/bdk/thermal/fan.c b/bdk/thermal/fan.c index e2cfdcb..686f9e8 100644 --- a/bdk/thermal/fan.c +++ b/bdk/thermal/fan.c @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -#include "fan.h" -#include "../power/regulator_5v.h" -#include "../soc/gpio.h" -#include "../soc/pinmux.h" -#include "../soc/t210.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include void set_fan_duty(u32 duty) { diff --git a/bdk/thermal/fan.h b/bdk/thermal/fan.h index d5b9946..e827975 100644 --- a/bdk/thermal/fan.h +++ b/bdk/thermal/fan.h @@ -19,7 +19,7 @@ #ifndef __FAN_H_ #define __FAN_H_ -#include "../utils/types.h" +#include // Disable: 0 (0 RPM), min duty: 1 (960 RPM), max duty 235 (11000 RPM). void set_fan_duty(u32 duty); diff --git a/bdk/thermal/tmp451.c b/bdk/thermal/tmp451.c index 018cf6f..fb9f9fa 100644 --- a/bdk/thermal/tmp451.c +++ b/bdk/thermal/tmp451.c @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#include "tmp451.h" -#include "../soc/i2c.h" +#include +#include u16 tmp451_get_soc_temp(bool intenger) { diff --git a/bdk/thermal/tmp451.h b/bdk/thermal/tmp451.h index 00a0816..9549ffa 100644 --- a/bdk/thermal/tmp451.h +++ b/bdk/thermal/tmp451.h @@ -19,7 +19,7 @@ #ifndef __TMP451_H_ #define __TMP451_H_ -#include "../utils/types.h" +#include #define TMP451_I2C_ADDR 0x4C diff --git a/bdk/usb/usb_descriptors.h b/bdk/usb/usb_descriptors.h index caca4a0..74556f8 100644 --- a/bdk/usb/usb_descriptors.h +++ b/bdk/usb/usb_descriptors.h @@ -19,7 +19,7 @@ #ifndef _USB_DESCRIPTORS_H_ #define _USB_DESCRIPTORS_H_ -#include "../utils/types.h" +#include typedef enum { USB_DESCRIPTOR_DEVICE = 1, diff --git a/bdk/usb/usb_gadget_hid.c b/bdk/usb/usb_gadget_hid.c index cbf71b0..e26dd9a 100644 --- a/bdk/usb/usb_gadget_hid.c +++ b/bdk/usb/usb_gadget_hid.c @@ -18,13 +18,13 @@ #include -#include "usbd.h" -#include "../gfx/gfx.h" -#include "../input/joycon.h" -#include "../input/touch.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include -#include "../../../common/memory_map.h" +#include //#define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DPRINTF(...) diff --git a/bdk/usb/usb_gadget_ums.c b/bdk/usb/usb_gadget_ums.c index 6372d9a..7b16624 100644 --- a/bdk/usb/usb_gadget_ums.c +++ b/bdk/usb/usb_gadget_ums.c @@ -21,16 +21,16 @@ #include -#include "usbd.h" -#include "../gfx/gfx.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../storage/sdmmc_driver.h" -#include "../utils/btn.h" -#include "../utils/sprintf.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include -#include "../../../common/memory_map.h" +#include //#define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DPRINTF(...) diff --git a/bdk/usb/usb_t210.h b/bdk/usb/usb_t210.h index f36900e..d670317 100644 --- a/bdk/usb/usb_t210.h +++ b/bdk/usb/usb_t210.h @@ -19,7 +19,7 @@ #ifndef _USB_T210_H_ #define _USB_T210_H_ -#include "../utils/types.h" +#include /* General USB registers */ #define USB1_IF_USB_SUSP_CTRL 0x400 diff --git a/bdk/usb/usbd.c b/bdk/usb/usbd.c index fad7cef..712629a 100644 --- a/bdk/usb/usbd.c +++ b/bdk/usb/usbd.c @@ -19,22 +19,22 @@ #include #include -#include "usbd.h" -#include "usb_descriptors.h" -#include "usb_t210.h" +#include +#include +#include -#include "../gfx/gfx.h" -#include "../soc/bpmp.h" -#include "../soc/clock.h" -#include "../soc/fuse.h" -#include "../soc/gpio.h" -#include "../soc/pinmux.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" -#include "../utils/btn.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "../../../common/memory_map.h" +#include typedef enum { diff --git a/bdk/usb/usbd.h b/bdk/usb/usbd.h index a505898..82a73e2 100644 --- a/bdk/usb/usbd.h +++ b/bdk/usb/usbd.h @@ -19,7 +19,7 @@ #ifndef _USB_H_ #define _USB_H_ -#include "../utils/types.h" +#include #define USB_TD_BUFFER_PAGE_SIZE 0x1000 #define USB_TD_BUFFER_MAX_SIZE (USB_TD_BUFFER_PAGE_SIZE * 4) diff --git a/bdk/utils/aarch64_util.h b/bdk/utils/aarch64_util.h index a5002c0..456bfc8 100644 --- a/bdk/utils/aarch64_util.h +++ b/bdk/utils/aarch64_util.h @@ -18,7 +18,7 @@ #ifndef _ARM64_H_ #define _ARM64_H_ -#include "types.h" +#include #define LSL0 0 #define LSL16 16 diff --git a/bdk/utils/btn.c b/bdk/utils/btn.c index b6e5db3..9ffe275 100644 --- a/bdk/utils/btn.c +++ b/bdk/utils/btn.c @@ -16,11 +16,11 @@ */ #include "btn.h" -#include "../soc/i2c.h" -#include "../soc/gpio.h" -#include "../soc/t210.h" -#include "util.h" -#include "../power/max77620.h" +#include +#include +#include +#include +#include u8 btn_read() { diff --git a/bdk/utils/btn.h b/bdk/utils/btn.h index 1c42cc2..f284748 100644 --- a/bdk/utils/btn.h +++ b/bdk/utils/btn.h @@ -18,7 +18,7 @@ #ifndef _BTN_H_ #define _BTN_H_ -#include "types.h" +#include #define BTN_POWER (1 << 0) #define BTN_VOL_DOWN (1 << 1) diff --git a/bdk/utils/dirlist.c b/bdk/utils/dirlist.c index a895c2c..5732683 100644 --- a/bdk/utils/dirlist.c +++ b/bdk/utils/dirlist.c @@ -17,9 +17,9 @@ #include #include -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../utils/types.h" +#include +#include +#include char *dirlist(const char *directory, const char *pattern, bool includeHiddenFiles, bool parse_dirs) { diff --git a/bdk/utils/dirlist.h b/bdk/utils/dirlist.h index 9ad3c38..32197f3 100644 --- a/bdk/utils/dirlist.h +++ b/bdk/utils/dirlist.h @@ -14,6 +14,6 @@ * along with this program. If not, see . */ -#include "../utils/types.h" +#include char *dirlist(const char *directory, const char *pattern, bool includeHiddenFiles, bool parse_dirs); diff --git a/bdk/utils/ini.c b/bdk/utils/ini.c index b83160c..538435e 100644 --- a/bdk/utils/ini.c +++ b/bdk/utils/ini.c @@ -18,9 +18,9 @@ #include #include "ini.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../utils/dirlist.h" +#include +#include +#include static char *_strdup(char *str) { diff --git a/bdk/utils/ini.h b/bdk/utils/ini.h index dffbe86..571d19d 100644 --- a/bdk/utils/ini.h +++ b/bdk/utils/ini.h @@ -18,8 +18,8 @@ #ifndef _INI_H_ #define _INI_H_ -#include "../utils/types.h" -#include "../utils/list.h" +#include +#include #define INI_CHOICE 3 #define INI_CAPTION 5 diff --git a/bdk/utils/list.h b/bdk/utils/list.h index 80e4498..ece5402 100644 --- a/bdk/utils/list.h +++ b/bdk/utils/list.h @@ -18,7 +18,7 @@ #ifndef _LIST_H_ #define _LIST_H_ -#include "types.h" +#include /*! Initialize list. */ #define LIST_INIT(name) link_t name = {&name, &name} diff --git a/bdk/utils/sprintf.c b/bdk/utils/sprintf.c index db98466..a35234b 100644 --- a/bdk/utils/sprintf.c +++ b/bdk/utils/sprintf.c @@ -18,7 +18,7 @@ #include #include -#include "types.h" +#include char **sout_buf; diff --git a/bdk/utils/sprintf.h b/bdk/utils/sprintf.h index 96aeea8..845f9b7 100644 --- a/bdk/utils/sprintf.h +++ b/bdk/utils/sprintf.h @@ -17,7 +17,7 @@ #ifndef _SPRINTF_H_ #define _SPRINTF_H_ -#include "types.h" +#include void s_printf(char *out_buf, const char *fmt, ...); diff --git a/bdk/utils/util.c b/bdk/utils/util.c index b1a7eec..dd10781 100644 --- a/bdk/utils/util.c +++ b/bdk/utils/util.c @@ -15,18 +15,16 @@ * along with this program. If not, see . */ -#include "util.h" -#include "../gfx/di.h" -#include "../mem/heap.h" -#include "../mem/minerva.h" -#include "../power/max77620.h" -#include "../rtc/max77620-rtc.h" -#include "../soc/bpmp.h" -#include "../soc/hw_init.h" -#include "../soc/i2c.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" -#include "../storage/nx_sd.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define USE_RTC_TIMER diff --git a/bdk/utils/util.h b/bdk/utils/util.h index d918194..2c59b61 100644 --- a/bdk/utils/util.h +++ b/bdk/utils/util.h @@ -18,8 +18,8 @@ #ifndef _UTIL_H_ #define _UTIL_H_ -#include "types.h" -#include "../mem/minerva.h" +#include +#include typedef enum { diff --git a/bootloader/config.c b/bootloader/config.c index d60b4b5..17e74c8 100644 --- a/bootloader/config.c +++ b/bootloader/config.c @@ -18,17 +18,17 @@ #include #include "config.h" -#include "ini.h" -#include "../gfx/gfx.h" -#include "../gfx/tui.h" -#include "../libs/fatfs/ff.h" -#include "../soc/fuse.h" -#include "../soc/t210.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/list.h" -#include "../utils/util.h" +#include +#include +#include "gfx/tui.h" +#include +#include +#include +#include +#include +#include +#include +#include extern hekate_config h_cfg; diff --git a/bootloader/config.h b/bootloader/config.h index b8a8821..873cf70 100644 --- a/bootloader/config.h +++ b/bootloader/config.h @@ -17,8 +17,8 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ -#include "../hos/hos.h" -#include "../utils/types.h" +#include "hos/hos.h" +#include typedef struct _hekate_config { diff --git a/bootloader/frontend/fe_emmc_tools.c b/bootloader/frontend/fe_emmc_tools.c index 943693f..44ca406 100644 --- a/bootloader/frontend/fe_emmc_tools.c +++ b/bootloader/frontend/fe_emmc_tools.c @@ -20,18 +20,18 @@ #include #include "fe_emmc_tools.h" -#include "../../common/memory_map.h" -#include "../config/config.h" -#include "../gfx/gfx.h" +#include +#include "../config.h" +#include #include "../gfx/tui.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../sec/se.h" +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/util.h" +#include +#include +#include +#include #define NUM_SECTORS_PER_ITER 8192 // 4MB Cache. #define OUT_FILENAME_SZ 128 diff --git a/bootloader/frontend/fe_info.c b/bootloader/frontend/fe_info.c index a787c18..59cd9fd 100644 --- a/bootloader/frontend/fe_info.c +++ b/bootloader/frontend/fe_info.c @@ -19,25 +19,25 @@ #include #include "fe_info.h" -#include "../gfx/gfx.h" +#include #include "../hos/hos.h" #include "../hos/pkg1.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../power/bq24193.h" -#include "../power/max17050.h" -#include "../sec/tsec.h" -#include "../soc/fuse.h" -#include "../soc/i2c.h" -#include "../soc/kfuse.h" -#include "../soc/smmu.h" -#include "../soc/t210.h" -#include "../storage/mmc.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/util.h" +#include +#include +#include +#include extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage); diff --git a/bootloader/frontend/fe_tools.c b/bootloader/frontend/fe_tools.c index 0c360c2..24dab72 100644 --- a/bootloader/frontend/fe_tools.c +++ b/bootloader/frontend/fe_tools.c @@ -20,23 +20,23 @@ #include #include "fe_tools.h" -#include "../config/config.h" -#include "../gfx/gfx.h" +#include "../config.h" +#include #include "../gfx/tui.h" #include "../hos/hos.h" #include "../hos/pkg1.h" #include "../hos/pkg2.h" #include "../hos/sept.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../power/max7762x.h" -#include "../sec/se.h" +#include +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../soc/fuse.h" -#include "../utils/btn.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include extern boot_cfg_t b_cfg; extern hekate_config h_cfg; diff --git a/bootloader/gfx/gfx.h b/bootloader/gfx/gfx.h index 564b085..ddcfd74 100644 --- a/bootloader/gfx/gfx.h +++ b/bootloader/gfx/gfx.h @@ -19,13 +19,39 @@ #ifndef _GFX_H_ #define _GFX_H_ -#include "../../common/common_gfx.h" +#include #define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC) #define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC) #define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC) #define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC) +typedef struct _gfx_ctxt_t +{ + u32 *fb; + u32 width; + u32 height; + u32 stride; +} gfx_ctxt_t; + +typedef struct _gfx_con_t +{ + gfx_ctxt_t *gfx_ctxt; + u32 fntsz; + u32 x; + u32 y; + u32 savedx; + u32 savedy; + u32 fgcol; + int fillbg; + u32 bgcol; + bool mute; +} gfx_con_t; + +// Global gfx console and context. +extern gfx_ctxt_t gfx_ctxt; +extern gfx_con_t gfx_con; + void gfx_init_ctxt(u32 *fb, u32 width, u32 height, u32 stride); void gfx_clear_grey(u8 color); void gfx_clear_partial_grey(u8 color, u32 pos_x, u32 height); @@ -48,8 +74,4 @@ void gfx_set_rect_rgb(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_ void gfx_set_rect_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); void gfx_render_bmp_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); -// Global gfx console and context. -extern gfx_ctxt_t gfx_ctxt; -extern gfx_con_t gfx_con; - #endif diff --git a/bootloader/gfx/tui.c b/bootloader/gfx/tui.c index 8a778b8..266b3bb 100644 --- a/bootloader/gfx/tui.c +++ b/bootloader/gfx/tui.c @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -#include "di.h" +#include #include "tui.h" -#include "../utils/btn.h" -#include "../config/config.h" -#include "../power/max17050.h" -#include "../utils/util.h" +#include "../config.h" +#include +#include +#include extern hekate_config h_cfg; diff --git a/bootloader/gfx/tui.h b/bootloader/gfx/tui.h index abb8746..14537f6 100644 --- a/bootloader/gfx/tui.h +++ b/bootloader/gfx/tui.h @@ -18,8 +18,8 @@ #ifndef _TUI_H_ #define _TUI_H_ -#include "../utils/types.h" -#include "gfx.h" +#include +#include #define MENT_END 0 #define MENT_HANDLER 1 diff --git a/bootloader/hos/fss.c b/bootloader/hos/fss.c index eb17b39..a024f87 100644 --- a/bootloader/hos/fss.c +++ b/bootloader/hos/fss.c @@ -20,13 +20,13 @@ #include "fss.h" #include "hos.h" -#include "../config/config.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" +#include "../config.h" +#include +#include #include "../storage/emummc.h" -#include "../storage/nx_sd.h" +#include -#include "../gfx/gfx.h" +#include #define DPRINTF(...) extern hekate_config h_cfg; diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 91c1f6e..ea6a5b9 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -24,28 +24,28 @@ #include "hos_config.h" #include "sept.h" #include "secmon_exo.h" -#include "../config/config.h" -#include "../gfx/di.h" -#include "../mem/heap.h" -#include "../mem/mc.h" -#include "../mem/minerva.h" -#include "../sec/se.h" -#include "../sec/se_t210.h" -#include "../sec/tsec.h" -#include "../soc/bpmp.h" -#include "../soc/ccplex.h" -#include "../soc/fuse.h" -#include "../soc/pmc.h" -#include "../soc/smmu.h" -#include "../soc/t210.h" +#include "../config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "../storage/emummc.h" -#include "../storage/mbr_gpt.h" +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/util.h" -#include "../gfx/gfx.h" +#include +#include +#include +#include extern hekate_config h_cfg; diff --git a/bootloader/hos/hos.h b/bootloader/hos/hos.h index 250a57c..d620cb0 100644 --- a/bootloader/hos/hos.h +++ b/bootloader/hos/hos.h @@ -20,9 +20,9 @@ #include "pkg1.h" #include "pkg2.h" -#include "../utils/types.h" -#include "../config/ini.h" -#include "../sec/tsec.h" +#include +#include +#include #include diff --git a/bootloader/hos/hos_config.c b/bootloader/hos/hos_config.c index be6ddcf..568cb5a 100644 --- a/bootloader/hos/hos_config.c +++ b/bootloader/hos/hos_config.c @@ -20,12 +20,12 @@ #include "hos.h" #include "hos_config.h" #include "fss.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../storage/nx_sd.h" -#include "../utils/dirlist.h" +#include +#include +#include +#include -#include "../gfx/gfx.h" +#include //#define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DPRINTF(...) diff --git a/bootloader/hos/pkg1.c b/bootloader/hos/pkg1.c index f1b0088..e827718 100644 --- a/bootloader/hos/pkg1.c +++ b/bootloader/hos/pkg1.c @@ -20,10 +20,10 @@ #include #include "pkg1.h" -#include "../gfx/gfx.h" -#include "../mem/heap.h" -#include "../sec/se.h" -#include "../utils/aarch64_util.h" +#include +#include +#include +#include #define _NOPv7() 0xE320F000 diff --git a/bootloader/hos/pkg1.h b/bootloader/hos/pkg1.h index 957eef0..ac5bac0 100644 --- a/bootloader/hos/pkg1.h +++ b/bootloader/hos/pkg1.h @@ -17,7 +17,7 @@ #ifndef _PKG1_H_ #define _PKG1_H_ -#include "../utils/types.h" +#include typedef struct _patch_t { diff --git a/bootloader/hos/pkg2.c b/bootloader/hos/pkg2.c index df2b3b5..2b47aa3 100644 --- a/bootloader/hos/pkg2.c +++ b/bootloader/hos/pkg2.c @@ -22,16 +22,16 @@ #include "pkg2.h" #include "pkg2_ini_kippatch.h" -#include "../config/config.h" -#include "../libs/compr/blz.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../sec/se.h" +#include "../config.h" +#include +#include +#include +#include #include "../storage/emummc.h" -#include "../storage/nx_sd.h" -#include "../utils/aarch64_util.h" +#include +#include -#include "../gfx/gfx.h" +#include extern hekate_config h_cfg; extern const u8 package2_keyseed[]; @@ -41,7 +41,7 @@ u32 pkg2_newkern_ini1_start; u32 pkg2_newkern_ini1_end; #ifdef KIP1_PATCH_DEBUG - #include "../utils/util.h" + #include #define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DEBUG_PRINTING #else diff --git a/bootloader/hos/pkg2.h b/bootloader/hos/pkg2.h index ab1ba3c..eb1e054 100644 --- a/bootloader/hos/pkg2.h +++ b/bootloader/hos/pkg2.h @@ -18,8 +18,8 @@ #ifndef _PKG2_H_ #define _PKG2_H_ -#include "../utils/types.h" -#include "../utils/list.h" +#include +#include #define PKG2_MAGIC 0x31324B50 #define PKG2_SEC_BASE 0x80000000 diff --git a/bootloader/hos/pkg2_ini_kippatch.c b/bootloader/hos/pkg2_ini_kippatch.c index fba2635..130ccda 100644 --- a/bootloader/hos/pkg2_ini_kippatch.c +++ b/bootloader/hos/pkg2_ini_kippatch.c @@ -2,8 +2,8 @@ #include #include "pkg2_ini_kippatch.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" +#include +#include #define KPS(x) ((u32)(x) << 29) diff --git a/bootloader/hos/pkg2_ini_kippatch.h b/bootloader/hos/pkg2_ini_kippatch.h index f459c3c..039adaf 100644 --- a/bootloader/hos/pkg2_ini_kippatch.h +++ b/bootloader/hos/pkg2_ini_kippatch.h @@ -17,8 +17,8 @@ #ifndef _INIPATCH_H_ #define _INIPATCH_H_ -#include "../utils/types.h" -#include "../utils/list.h" +#include +#include typedef struct _ini_patchset_t { diff --git a/bootloader/hos/secmon_exo.c b/bootloader/hos/secmon_exo.c index 4571d99..d69f9e2 100644 --- a/bootloader/hos/secmon_exo.c +++ b/bootloader/hos/secmon_exo.c @@ -19,19 +19,19 @@ #include #include "hos.h" -#include "../config/config.h" -#include "../gfx/di.h" -#include "../gfx/gfx.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../soc/fuse.h" +#include "../config.h" +#include +#include +#include +#include +#include #include "../storage/emummc.h" #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/util.h" -#include "../utils/types.h" +#include +#include +#include +#include +#include extern hekate_config h_cfg; diff --git a/bootloader/hos/secmon_exo.h b/bootloader/hos/secmon_exo.h index c5ef600..f814f1a 100644 --- a/bootloader/hos/secmon_exo.h +++ b/bootloader/hos/secmon_exo.h @@ -17,7 +17,7 @@ #ifndef _SECMON_EXO_H_ #define _SECMON_EXO_H_ -#include "../utils/types.h" +#include void config_exosphere(launch_ctxt_t *ctxt, u32 warmboot_base); void secmon_exo_check_panic(); diff --git a/bootloader/hos/sept.c b/bootloader/hos/sept.c index 949fd08..3ee6dd3 100644 --- a/bootloader/hos/sept.c +++ b/bootloader/hos/sept.c @@ -19,22 +19,22 @@ #include "hos.h" #include "fss.h" #include "sept.h" -#include "../config/config.h" -#include "../gfx/di.h" -#include "../ianos/ianos.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../soc/hw_init.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" +#include "../config.h" +#include +#include +#include +#include +#include +#include +#include #include "../storage/emummc.h" #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/types.h" +#include +#include +#include +#include -#include "../gfx/gfx.h" +#include #define RELOC_META_OFF 0x7C #define PATCHED_RELOC_SZ 0x94 diff --git a/bootloader/hos/sept.h b/bootloader/hos/sept.h index 8cfc8af..af00f73 100644 --- a/bootloader/hos/sept.h +++ b/bootloader/hos/sept.h @@ -17,7 +17,7 @@ #ifndef _SEPT_H_ #define _SEPT_H_ -#include "../utils/types.h" +#include void check_sept(ini_sec_t *cfg_sec); int reboot_to_sept(const u8 *tsec_fw, u32 kb, ini_sec_t *cfg_sec); diff --git a/bootloader/libs/fatfs/diskio.c b/bootloader/libs/fatfs/diskio.c index 2edfdf7..0f87131 100644 --- a/bootloader/libs/fatfs/diskio.c +++ b/bootloader/libs/fatfs/diskio.c @@ -9,11 +9,10 @@ #include -#include "../../../common/memory_map.h" - -#include "diskio.h" /* FatFs lower layer API */ -#include "../../storage/nx_sd.h" -#include "../../storage/sdmmc.h" +#include /* FatFs lower layer API */ +#include +#include +#include /*-----------------------------------------------------------------------*/ /* Get Drive Status */ diff --git a/bootloader/libs/fatfs/ffsystem.c b/bootloader/libs/fatfs/ffsystem.c index fa44f8e..6f5f435 100644 --- a/bootloader/libs/fatfs/ffsystem.c +++ b/bootloader/libs/fatfs/ffsystem.c @@ -5,8 +5,8 @@ /*------------------------------------------------------------------------*/ -#include "ff.h" -#include "../../mem/heap.h" +#include +#include diff --git a/bootloader/main.c b/bootloader/main.c index 5d81ee6..618948f 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -19,41 +19,41 @@ #include #include -#include "../common/memory_map.h" +#include -#include "config/config.h" -#include "gfx/di.h" -#include "gfx/gfx.h" +#include "config.h" +#include +#include #include "gfx/logos.h" #include "gfx/tui.h" #include "hos/hos.h" #include "hos/secmon_exo.h" #include "hos/sept.h" -#include "ianos/ianos.h" -#include "libs/compr/blz.h" -#include "libs/fatfs/ff.h" -#include "mem/heap.h" -#include "mem/minerva.h" -#include "mem/sdram.h" -#include "power/bq24193.h" -#include "power/max17050.h" -#include "power/max77620.h" -#include "power/max7762x.h" -#include "rtc/max77620-rtc.h" -#include "soc/bpmp.h" -#include "soc/fuse.h" -#include "soc/hw_init.h" -#include "soc/i2c.h" -#include "soc/t210.h" -#include "soc/uart.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "storage/emummc.h" #include "storage/nx_emmc.h" -#include "storage/nx_sd.h" -#include "storage/sdmmc.h" -#include "utils/btn.h" -#include "utils/dirlist.h" -#include "utils/list.h" -#include "utils/util.h" +#include +#include +#include +#include +#include +#include #include "frontend/fe_emmc_tools.h" #include "frontend/fe_tools.h" @@ -1084,7 +1084,9 @@ static void _patched_rcm_protection() sdmmc_storage_t storage; sdmmc_t sdmmc; - if (!h_cfg.rcm_patched) + u32 chip_id = (APB_MISC(APB_MISC_GP_HIDREV) >> 4) & 0xF; + + if (!h_cfg.rcm_patched || chip_id != GP_HIDREV_MAJOR_T210) return; // Check if AutoRCM is enabled and protect from a permanent brick. diff --git a/bootloader/storage/emummc.c b/bootloader/storage/emummc.c index 2d9da61..71d62b8 100644 --- a/bootloader/storage/emummc.c +++ b/bootloader/storage/emummc.c @@ -18,15 +18,16 @@ #include #include "emummc.h" -#include "sdmmc.h" -#include "../config/config.h" -#include "../config/ini.h" -#include "../gfx/gfx.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../storage/nx_sd.h" -#include "../utils/list.h" -#include "../utils/types.h" +#include +#include "../config.h" +#include +#include +#include +#include +#include "../storage/nx_emmc.h" +#include +#include +#include extern hekate_config h_cfg; emummc_cfg_t emu_cfg = { 0 }; diff --git a/bootloader/storage/emummc.h b/bootloader/storage/emummc.h index 6175623..81ad123 100644 --- a/bootloader/storage/emummc.h +++ b/bootloader/storage/emummc.h @@ -17,8 +17,8 @@ #ifndef EMUMMC_H #define EMUMMC_H -#include "sdmmc.h" -#include "../utils/types.h" +#include +#include typedef enum { diff --git a/bootloader/storage/nx_emmc.c b/bootloader/storage/nx_emmc.c index 897a7e3..be7aa4b 100644 --- a/bootloader/storage/nx_emmc.c +++ b/bootloader/storage/nx_emmc.c @@ -16,11 +16,11 @@ #include -#include "mbr_gpt.h" #include "nx_emmc.h" #include "emummc.h" -#include "../mem/heap.h" -#include "../utils/list.h" +#include +#include +#include sdmmc_t emmc_sdmmc; sdmmc_storage_t emmc_storage; diff --git a/bootloader/storage/nx_emmc.h b/bootloader/storage/nx_emmc.h index 380b7a0..5db6a1f 100644 --- a/bootloader/storage/nx_emmc.h +++ b/bootloader/storage/nx_emmc.h @@ -17,10 +17,10 @@ #ifndef _NX_EMMC_H_ #define _NX_EMMC_H_ -#include "sdmmc.h" -#include "../libs/fatfs/ff.h" -#include "../utils/types.h" -#include "../utils/list.h" +#include +#include +#include +#include #define NX_GPT_FIRST_LBA 1 #define NX_GPT_NUM_BLOCKS 33 diff --git a/bootloader/storage/nx_sd.c b/bootloader/storage/nx_sd.c index a93c8e0..fa284fa 100644 --- a/bootloader/storage/nx_sd.c +++ b/bootloader/storage/nx_sd.c @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -#include "nx_sd.h" -#include "sdmmc.h" -#include "sdmmc_driver.h" -#include "../gfx/gfx.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" +#include +#include +#include +#include +#include +#include static bool sd_mounted = false; static u16 sd_errors[3] = { 0 }; // Init and Read/Write errors. diff --git a/modules/hekate_libsys_lp0/Makefile b/modules/hekate_libsys_lp0/Makefile index 3f573c0..6dcd5e0 100644 --- a/modules/hekate_libsys_lp0/Makefile +++ b/modules/hekate_libsys_lp0/Makefile @@ -7,6 +7,8 @@ include $(DEVKITARM)/base_rules TARGET := libsys_lp0 BUILD := ../../build/$(TARGET) OUTPUT := ../../output +BDKDIR := bdk +BDKINC := -I../../$(BDKDIR) OBJS = $(addprefix $(BUILD)/,\ sys_sdramlp0.o \ @@ -21,7 +23,7 @@ LDFLAGS = $(ARCH) -fpie -pie -nostartfiles -lgcc all: $(TARGET).bso $(BUILD)/%.o: ./%.c @mkdir -p "$(BUILD)" - @$(CC) $(CFLAGS) -c $< -o $@ + @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ $(TARGET).bso: $(OBJS) @$(CC) $(LDFLAGS) -e _modInit $^ -o $(OUTPUT)/$(TARGET).bso diff --git a/modules/hekate_libsys_lp0/sys_sdramlp0.c b/modules/hekate_libsys_lp0/sys_sdramlp0.c index 44dffd4..a91c228 100644 --- a/modules/hekate_libsys_lp0/sys_sdramlp0.c +++ b/modules/hekate_libsys_lp0/sys_sdramlp0.c @@ -17,7 +17,7 @@ #include "t210.h" #include "pmc_lp0_t210.h" #include "sdram_lp0_param_t210.h" -#include "../../common/common_module.h" +#include /* * This function reads SDRAM parameters from the common BCT format and diff --git a/modules/hekate_libsys_minerva/Makefile b/modules/hekate_libsys_minerva/Makefile index a98ec4d..f0b849f 100644 --- a/modules/hekate_libsys_minerva/Makefile +++ b/modules/hekate_libsys_minerva/Makefile @@ -7,6 +7,8 @@ include $(DEVKITARM)/base_rules TARGET := libsys_minerva BUILD := ../../build/$(TARGET) OUTPUT := ../../output +BDKDIR := bdk +BDKINC := -I../../$(BDKDIR) OBJS = $(addprefix $(BUILD)/,\ sys_sdrammtc.o \ @@ -21,7 +23,7 @@ LDFLAGS = $(ARCH) -fpie -pie -nostartfiles -lgcc all: $(TARGET).bso $(BUILD)/%.o: ./%.c @mkdir -p "$(BUILD)" - @$(CC) $(CFLAGS) -c $< -o $@ + @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ $(TARGET).bso: $(OBJS) @$(CC) $(LDFLAGS) -e _minerva_init $^ -o $(OUTPUT)/$(TARGET).bso diff --git a/modules/hekate_libsys_minerva/sys_sdrammtc.c b/modules/hekate_libsys_minerva/sys_sdrammtc.c index 9b83b27..5c5e831 100644 --- a/modules/hekate_libsys_minerva/sys_sdrammtc.c +++ b/modules/hekate_libsys_minerva/sys_sdrammtc.c @@ -23,7 +23,7 @@ #include "mtc_mc_emc_regs.h" #include "mtc_switch_tables.h" #include "types.h" -#include "../../common/common_module.h" +#include #define EPRINTF(...) #define EPRINTFARGS(...) diff --git a/modules/simple_sample/Makefile b/modules/simple_sample/Makefile index 924c5fe..6178be7 100644 --- a/modules/simple_sample/Makefile +++ b/modules/simple_sample/Makefile @@ -7,6 +7,9 @@ include $(DEVKITARM)/base_rules TARGET := module_sample BUILD := ../../build/$(TARGET) OUTPUT := ../../output +SOURCEDIR = simple_sample +BDKDIR := bdk +BDKINC := -I../../$(BDKDIR) VPATH = $(dir ./) $(dir $(wildcard ./*/)) OBJS = $(addprefix $(BUILD)/,\ @@ -14,6 +17,10 @@ OBJS = $(addprefix $(BUILD)/,\ gfx.o \ ) +GFX_INC := '"../modules/$(SOURCEDIR)/gfx/gfx.h"' + +CUSTOMDEFINES := -DGFX_INC=$(GFX_INC) + ARCH := -march=armv4t -mtune=arm7tdmi -mthumb-interwork CFLAGS = $(ARCH) -O2 -nostdlib -fpie -ffunction-sections -fdata-sections -fomit-frame-pointer -std=gnu11 -Wall $(CUSTOMDEFINES) LDFLAGS = $(ARCH) -fpie -pie -nostartfiles -lgcc @@ -23,7 +30,7 @@ LDFLAGS = $(ARCH) -fpie -pie -nostartfiles -lgcc all: $(TARGET).bso $(BUILD)/%.o: ./%.c @mkdir -p "$(BUILD)" - @$(CC) $(CFLAGS) -c $< -o $@ + @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ $(TARGET).bso: $(OBJS) @$(CC) $(LDFLAGS) -e _modInit $^ -o $(OUTPUT)/$(TARGET).bso diff --git a/modules/simple_sample/gfx/gfx.c b/modules/simple_sample/gfx/gfx.c index 9a154bc..5c30ba7 100644 --- a/modules/simple_sample/gfx/gfx.c +++ b/modules/simple_sample/gfx/gfx.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018 CTCaer + * Copyright (c) 2018-2020 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, @@ -19,6 +19,10 @@ #include #include "gfx.h" +// Global gfx console and context. +gfx_ctxt_t gfx_ctxt; +gfx_con_t gfx_con; + static const u8 _gfx_font[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char 032 ( ) 0x00, 0x30, 0x30, 0x18, 0x18, 0x00, 0x0C, 0x00, // Char 033 (!) @@ -117,110 +121,111 @@ static const u8 _gfx_font[] = { 0x00, 0x00, 0x00, 0x4C, 0x32, 0x00, 0x00, 0x00 // Char 126 (~) }; -void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride) +void gfx_clear_grey(u8 color) { - ctxt->fb = fb; - ctxt->width = width; - ctxt->height = height; - ctxt->stride = stride; + memset(gfx_ctxt.fb, color, gfx_ctxt.width * gfx_ctxt.height * 4); } -void gfx_clear_grey(gfx_ctxt_t *ctxt, u8 color) +void gfx_clear_partial_grey(u8 color, u32 pos_x, u32 height) { - memset(ctxt->fb, color, 0x3C0000); + memset(gfx_ctxt.fb + pos_x * gfx_ctxt.stride, color, height * 4 * gfx_ctxt.stride); } -void gfx_clear_color(gfx_ctxt_t *ctxt, u32 color) +void gfx_clear_color(u32 color) { - for (u32 i = 0; i < ctxt->height * ctxt->stride; i++) - ctxt->fb[i] = color; + for (u32 i = 0; i < gfx_ctxt.width * gfx_ctxt.height; i++) + gfx_ctxt.fb[i] = color; } -void gfx_clear_partial_grey(gfx_ctxt_t *ctxt, u8 color, u32 pos_x, u32 height) +void gfx_init_ctxt(u32 *fb, u32 width, u32 height, u32 stride) { - memset(ctxt->fb + pos_x * ctxt->stride, color, height * 4 * ctxt->stride); + gfx_ctxt.fb = fb; + gfx_ctxt.width = width; + gfx_ctxt.height = height; + gfx_ctxt.stride = stride; } -void gfx_con_init(gfx_con_t *con, gfx_ctxt_t *ctxt) +void gfx_con_init() { - con->gfx_ctxt = ctxt; - con->fntsz = 16; - con->x = 0; - con->y = 0; - con->savedx = 0; - con->savedy = 0; - con->fgcol = 0xFFCCCCCC; - con->fillbg = 0; - con->bgcol = 0xFF1B1B1B; - con->mute = 0; + gfx_con.gfx_ctxt = &gfx_ctxt; + gfx_con.fntsz = 16; + gfx_con.x = 0; + gfx_con.y = 0; + gfx_con.savedx = 0; + gfx_con.savedy = 0; + gfx_con.fgcol = 0xFFCCCCCC; + gfx_con.fillbg = 1; + gfx_con.bgcol = 0xFF1B1B1B; + gfx_con.mute = 0; } -void gfx_con_setcol(gfx_con_t *con, u32 fgcol, int fillbg, u32 bgcol) +void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol) { - con->fgcol = fgcol; - con->fillbg = fillbg; - con->bgcol = bgcol; + gfx_con.fgcol = fgcol; + gfx_con.fillbg = fillbg; + gfx_con.bgcol = bgcol; } -void gfx_con_getpos(gfx_con_t *con, u32 *x, u32 *y) +void gfx_con_getpos(u32 *x, u32 *y) { - *x = con->x; - *y = con->y; + *x = gfx_con.x; + *y = gfx_con.y; } -void gfx_con_setpos(gfx_con_t *con, u32 x, u32 y) +void gfx_con_setpos(u32 x, u32 y) { - con->x = x; - con->y = y; + gfx_con.x = x; + gfx_con.y = y; } -void gfx_putc(gfx_con_t *con, char c) +void gfx_putc(char c) { // Duplicate code for performance reasons. - switch (con->fntsz) + switch (gfx_con.fntsz) { case 16: if (c >= 32 && c <= 126) { u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)]; - u32 *fb = con->gfx_ctxt->fb + con->x + con->y * con->gfx_ctxt->stride; + u32 *fb = gfx_ctxt.fb + gfx_con.x + gfx_con.y * gfx_ctxt.stride; - for (u32 i = 0; i < 16; i+=2) + for (u32 i = 0; i < 16; i += 2) { - u8 v = *cbuf++; + u8 v = *cbuf; for (u32 k = 0; k < 2; k++) { for (u32 j = 0; j < 8; j++) { if (v & 1) { - *fb = con->fgcol; + *fb = gfx_con.fgcol; fb++; - *fb = con->fgcol; + *fb = gfx_con.fgcol; } - else if (con->fillbg) + else if (gfx_con.fillbg) { - *fb = con->bgcol; + *fb = gfx_con.bgcol; fb++; - *fb = con->bgcol; + *fb = gfx_con.bgcol; } else fb++; v >>= 1; fb++; } - fb += con->gfx_ctxt->stride - 16; + fb += gfx_ctxt.stride - 16; v = *cbuf; } + cbuf++; } - con->x += 16; + gfx_con.x += 16; } else if (c == '\n') { - con->x = 0; - con->y +=16; - if (con->y > con->gfx_ctxt->height - 16) - con->y = 0; + gfx_con.x = 0; + gfx_con.y += 16; + if (gfx_con.y > gfx_ctxt.height - 16) + gfx_con.y = 0; } break; case 8: @@ -228,44 +233,44 @@ void gfx_putc(gfx_con_t *con, char c) if (c >= 32 && c <= 126) { u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)]; - u32 *fb = con->gfx_ctxt->fb + con->x + con->y * con->gfx_ctxt->stride; + u32 *fb = gfx_ctxt.fb + gfx_con.x + gfx_con.y * gfx_ctxt.stride; for (u32 i = 0; i < 8; i++) { u8 v = *cbuf++; for (u32 j = 0; j < 8; j++) { if (v & 1) - *fb = con->fgcol; - else if (con->fillbg) - *fb = con->bgcol; + *fb = gfx_con.fgcol; + else if (gfx_con.fillbg) + *fb = gfx_con.bgcol; v >>= 1; fb++; } - fb += con->gfx_ctxt->stride - 8; + fb += gfx_ctxt.stride - 8; } - con->x += 8; + gfx_con.x += 8; } else if (c == '\n') { - con->x = 0; - con->y += 8; - if (con->y > con->gfx_ctxt->height - 8) - con->y = 0; + gfx_con.x = 0; + gfx_con.y += 8; + if (gfx_con.y > gfx_ctxt.height - 8) + gfx_con.y = 0; } break; } } -void gfx_puts(gfx_con_t *con, const char *s) +void gfx_puts(char *s) { - if (!s || con->mute) + if (!s || gfx_con.mute) return; for (; *s; s++) - gfx_putc(con, *s); + gfx_putc(*s); } -static void _gfx_putn(gfx_con_t *con, u32 v, int base, char fill, int fcnt) +static void _gfx_putn(u32 v, int base, char fill, int fcnt) { char buf[65]; static const char digits[] = "0123456789ABCDEFghijklmnopqrstuvwxyz"; @@ -293,28 +298,28 @@ static void _gfx_putn(gfx_con_t *con, u32 v, int base, char fill, int fcnt) } } - gfx_puts(con, p); + gfx_puts(p); } -void gfx_put_small_sep(gfx_con_t *con) +void gfx_put_small_sep() { - u8 prevFontSize = con->fntsz; - con->fntsz = 8; - gfx_putc(con, '\n'); - con->fntsz = prevFontSize; + u8 prevFontSize = gfx_con.fntsz; + gfx_con.fntsz = 8; + gfx_putc('\n'); + gfx_con.fntsz = prevFontSize; } -void gfx_put_big_sep(gfx_con_t *con) +void gfx_put_big_sep() { - u8 prevFontSize = con->fntsz; - con->fntsz = 16; - gfx_putc(con, '\n'); - con->fntsz = prevFontSize; + u8 prevFontSize = gfx_con.fntsz; + gfx_con.fntsz = 16; + gfx_putc('\n'); + gfx_con.fntsz = prevFontSize; } -void gfx_printf(gfx_con_t *con, const char *fmt, ...) +void gfx_printf(const char *fmt, ...) { - if (con->mute) + if (gfx_con.mute) return; va_list ap; @@ -347,40 +352,40 @@ void gfx_printf(gfx_con_t *con, const char *fmt, ...) switch(*fmt) { case 'c': - gfx_putc(con, va_arg(ap, u32)); + gfx_putc(va_arg(ap, u32)); break; case 's': - gfx_puts(con, va_arg(ap, char *)); + gfx_puts(va_arg(ap, char *)); break; case 'd': - _gfx_putn(con, va_arg(ap, u32), 10, fill, fcnt); + _gfx_putn(va_arg(ap, u32), 10, fill, fcnt); break; case 'p': case 'P': case 'x': case 'X': - _gfx_putn(con, va_arg(ap, u32), 16, fill, fcnt); + _gfx_putn(va_arg(ap, u32), 16, fill, fcnt); break; case 'k': - con->fgcol = va_arg(ap, u32); + gfx_con.fgcol = va_arg(ap, u32); break; case 'K': - con->bgcol = va_arg(ap, u32); - con->fillbg = 1; + gfx_con.bgcol = va_arg(ap, u32); + gfx_con.fillbg = 1; break; case '%': - gfx_putc(con, '%'); + gfx_putc('%'); break; case '\0': goto out; default: - gfx_putc(con, '%'); - gfx_putc(con, *fmt); + gfx_putc('%'); + gfx_putc(*fmt); break; } } else - gfx_putc(con, *fmt); + gfx_putc(*fmt); fmt++; } @@ -388,33 +393,33 @@ void gfx_printf(gfx_con_t *con, const char *fmt, ...) va_end(ap); } -void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len) +void gfx_hexdump(u32 base, const u8 *buf, u32 len) { - if (con->mute) + if (gfx_con.mute) return; - u8 prevFontSize = con->fntsz; - con->fntsz = 8; + u8 prevFontSize = gfx_con.fntsz; + gfx_con.fntsz = 8; for(u32 i = 0; i < len; i++) { if(i % 0x10 == 0) { if(i != 0) { - gfx_puts(con, "| "); + gfx_puts("| "); for(u32 j = 0; j < 0x10; j++) { u8 c = buf[i - 0x10 + j]; if(c >= 32 && c <= 126) - gfx_putc(con, c); + gfx_putc(c); else - gfx_putc(con, '.'); + gfx_putc('.'); } - gfx_putc(con, '\n'); + gfx_putc('\n'); } - gfx_printf(con, "%08x: ", base + i); + gfx_printf("%08x: ", base + i); } - gfx_printf(con, "%02x ", buf[i]); + gfx_printf("%02x ", buf[i]); if (i == len - 1) { int ln = len % 0x10 != 0; @@ -423,22 +428,22 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len) { k = (len & 0xF) - 1; for (u32 j = 0; j < 0x10 - k; j++) - gfx_puts(con, " "); + gfx_puts(" "); } - gfx_puts(con, "| "); + gfx_puts("| "); for(u32 j = 0; j < (ln ? k : k + 1); j++) { u8 c = buf[i - k + j]; if(c >= 32 && c <= 126) - gfx_putc(con, c); + gfx_putc(c); else - gfx_putc(con, '.'); + gfx_putc('.'); } - gfx_putc(con, '\n'); + gfx_putc('\n'); } } - gfx_putc(con, '\n'); - con->fntsz = prevFontSize; + gfx_putc('\n'); + gfx_con.fntsz = prevFontSize; } static int abs(int x) @@ -448,12 +453,12 @@ static int abs(int x) return x; } -void gfx_set_pixel(gfx_ctxt_t *ctxt, u32 x, u32 y, u32 color) +void gfx_set_pixel(u32 x, u32 y, u32 color) { - ctxt->fb[x + y * ctxt->stride] = color; + gfx_ctxt.fb[x + y * gfx_ctxt.stride] = color; } -void gfx_line(gfx_ctxt_t *ctxt, int x0, int y0, int x1, int y1, u32 color) +void gfx_line(int x0, int y0, int x1, int y1, u32 color) { int dx = abs(x1 - x0), sx = x0 < x1 ? 1 : -1; int dy = abs(y1 - y0), sy = y0 < y1 ? 1 : -1; @@ -461,7 +466,7 @@ void gfx_line(gfx_ctxt_t *ctxt, int x0, int y0, int x1, int y1, u32 color) while (1) { - gfx_set_pixel(ctxt, x0, y0, color); + gfx_set_pixel(x0, y0, color); if (x0 == x1 && y0 == y1) break; e2 = err; @@ -478,51 +483,46 @@ void gfx_line(gfx_ctxt_t *ctxt, int x0, int y0, int x1, int y1, u32 color) } } -void gfx_set_rect_grey(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y) +void gfx_set_rect_grey(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y) { u32 pos = 0; for (u32 y = pos_y; y < (pos_y + size_y); y++) { for (u32 x = pos_x; x < (pos_x + size_x); x++) { - memset(&ctxt->fb[x + y*ctxt->stride], buf[pos], 4); + memset(&gfx_ctxt.fb[x + y*gfx_ctxt.stride], buf[pos], 4); pos++; } } } -void gfx_set_rect_rgb(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y) +void gfx_set_rect_rgb(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y) { u32 pos = 0; for (u32 y = pos_y; y < (pos_y + size_y); y++) { for (u32 x = pos_x; x < (pos_x + size_x); x++) { - ctxt->fb[x + y*ctxt->stride] = buf[pos + 2] | (buf[pos + 1] << 8) | (buf[pos] << 16); + gfx_ctxt.fb[x + y * gfx_ctxt.stride] = buf[pos + 2] | (buf[pos + 1] << 8) | (buf[pos] << 16); pos+=3; } } } -void gfx_set_rect_argb(gfx_ctxt_t *ctxt, const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y) +void gfx_set_rect_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y) { - u32 pos = 0; + u32 *ptr = (u32 *)buf; for (u32 y = pos_y; y < (pos_y + size_y); y++) - { for (u32 x = pos_x; x < (pos_x + size_x); x++) - { - ctxt->fb[x + y*ctxt->stride] = buf[pos]; - pos+=1; - } - } + gfx_ctxt.fb[x + y * gfx_ctxt.stride] = *ptr++; } -void gfx_render_bmp_argb(gfx_ctxt_t *ctxt, const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y) +void gfx_render_bmp_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y) { for (u32 y = pos_y; y < (pos_y + size_y); y++) { for (u32 x = pos_x; x < (pos_x + size_x); x++) - ctxt->fb[x + y*ctxt->stride] = buf[(size_y + pos_y - 1 - y ) * size_x + x - pos_x]; + gfx_ctxt.fb[x + y * gfx_ctxt.stride] = buf[(size_y + pos_y - 1 - y ) * size_x + x - pos_x]; } } diff --git a/modules/simple_sample/gfx/gfx.h b/modules/simple_sample/gfx/gfx.h index ecf42c9..ddcfd74 100644 --- a/modules/simple_sample/gfx/gfx.h +++ b/modules/simple_sample/gfx/gfx.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018 CTCaer + * Copyright (c) 2018-2020 CTCaer * Copyright (c) 2018 M4xw * * This program is free software; you can redistribute it and/or modify it @@ -19,28 +19,59 @@ #ifndef _GFX_H_ #define _GFX_H_ -#include "../../../common/common_gfx.h" +#include -void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride); -void gfx_clear_grey(gfx_ctxt_t *ctxt, u8 color); -void gfx_clear_partial_grey(gfx_ctxt_t *ctxt, u8 color, u32 pos_x, u32 height); -void gfx_clear_color(gfx_ctxt_t *ctxt, u32 color); -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_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, ...); -void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len); +#define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC) +#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC) +#define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC) +#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC) -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_put_small_sep(gfx_con_t *con); -void gfx_put_big_sep(gfx_con_t *con); -void gfx_set_rect_grey(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); -void gfx_set_rect_rgb(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); -void gfx_set_rect_argb(gfx_ctxt_t *ctxt, const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); -void gfx_render_bmp_argb(gfx_ctxt_t *ctxt, const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); +typedef struct _gfx_ctxt_t +{ + u32 *fb; + u32 width; + u32 height; + u32 stride; +} gfx_ctxt_t; + +typedef struct _gfx_con_t +{ + gfx_ctxt_t *gfx_ctxt; + u32 fntsz; + u32 x; + u32 y; + u32 savedx; + u32 savedy; + u32 fgcol; + int fillbg; + u32 bgcol; + bool mute; +} gfx_con_t; + +// Global gfx console and context. +extern gfx_ctxt_t gfx_ctxt; +extern gfx_con_t gfx_con; + +void gfx_init_ctxt(u32 *fb, u32 width, u32 height, u32 stride); +void gfx_clear_grey(u8 color); +void gfx_clear_partial_grey(u8 color, u32 pos_x, u32 height); +void gfx_clear_color(u32 color); +void gfx_con_init(); +void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol); +void gfx_con_getpos(u32 *x, u32 *y); +void gfx_con_setpos(u32 x, u32 y); +void gfx_putc(char c); +void gfx_puts(char *s); +void gfx_printf(const char *fmt, ...); +void gfx_hexdump(u32 base, const u8 *buf, u32 len); + +void gfx_set_pixel(u32 x, u32 y, u32 color); +void gfx_line(int x0, int y0, int x1, int y1, u32 color); +void gfx_put_small_sep(); +void gfx_put_big_sep(); +void gfx_set_rect_grey(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); +void gfx_set_rect_rgb(const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); +void gfx_set_rect_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); +void gfx_render_bmp_argb(const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); #endif diff --git a/modules/simple_sample/module_sample.c b/modules/simple_sample/module_sample.c index 51b3681..a113644 100644 --- a/modules/simple_sample/module_sample.c +++ b/modules/simple_sample/module_sample.c @@ -2,11 +2,17 @@ 2018 - M4xw */ -#include "../../common/common_module.h" -#include "../../common/common_gfx.h" -#include "gfx/gfx.h" +#include +#include +#include void _modInit(void *moduleConfig, bdkParams_t bp) { - gfx_puts(bp->gfxCon, "Hello World!"); + memcpy(&gfx_con, bp->gfxCon, sizeof(gfx_con_t)); + memcpy(&gfx_ctxt, bp->gfxCtx, sizeof(gfx_ctxt_t)); + + gfx_puts("Hello World!"); + + memcpy(bp->gfxCon, &gfx_con, sizeof(gfx_con_t)); + memcpy(bp->gfxCtx, &gfx_ctxt, sizeof(gfx_ctxt_t)); } diff --git a/nyx/Makefile b/nyx/Makefile index b6b3593..d801ec0 100644 --- a/nyx/Makefile +++ b/nyx/Makefile @@ -16,8 +16,11 @@ TARGET := nyx BUILDDIR := ./../build OUTPUTDIR := ./../output SOURCEDIR = nyx_gui +BDKDIR := bdk +BDKINC := -I../$(BDKDIR) VPATH = $(dir $(wildcard ./$(SOURCEDIR)/)) $(dir $(wildcard ./$(SOURCEDIR)/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/)) VPATH += $(dir $(wildcard ./$(SOURCEDIR)/*/*/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/*/*/)) +VPATH += $(dir $(wildcard ../$(BDKDIR)/*/)) $(dir $(wildcard ../$(BDKDIR)/*/*/)) $(dir $(wildcard ../$(BDKDIR)/*/*/*/)) # Main and graphics. OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \ @@ -68,11 +71,14 @@ OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \ lv_theme.o lv_theme_hekate.o \ ) +GFX_INC := '"../nyx/$(SOURCEDIR)/gfx/gfx.h"' +FFCFG_INC := '"../nyx/$(SOURCEDIR)/libs/fatfs/ffconf.h"' + ################################################################################ CUSTOMDEFINES := -DNYX_LOAD_ADDR=$(NYX_LOAD_ADDR) -DNYX_MAGIC=$(NYX_MAGIC) CUSTOMDEFINES += -DNYX_VER_MJ=$(NYXVERSION_MAJOR) -DNYX_VER_MN=$(NYXVERSION_MINOR) -DNYX_VER_HF=$(NYXVERSION_HOTFX) -DNYX_RESERVED=$(NYXVERSION_RSVD) -CUSTOMDEFINES += -DNYX +CUSTOMDEFINES += -DNYX -DGFX_INC=$(GFX_INC) -DFFCFG_INC=$(FFCFG_INC) # 0: UART_A, 1: UART_B. #CUSTOMDEFINES += -DDEBUG_UART_PORT=1 @@ -106,7 +112,7 @@ $(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS) $(BUILDDIR)/$(TARGET)/%.o: %.c @echo Building $@ - @$(CC) $(CFLAGS) -c $< -o $@ + @$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@ $(BUILDDIR)/$(TARGET)/%.o: %.S @echo Building $@ diff --git a/nyx/nyx_gui/config.c b/nyx/nyx_gui/config.c index b442788..8c9469f 100644 --- a/nyx/nyx_gui/config.c +++ b/nyx/nyx_gui/config.c @@ -18,16 +18,16 @@ #include #include "config.h" -#include "ini.h" -#include "../gfx/gfx.h" -#include "../libs/fatfs/ff.h" -#include "../soc/fuse.h" -#include "../soc/t210.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/list.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include extern hekate_config h_cfg; extern nyx_config n_cfg; diff --git a/nyx/nyx_gui/config.h b/nyx/nyx_gui/config.h index 2510110..8199122 100644 --- a/nyx/nyx_gui/config.h +++ b/nyx/nyx_gui/config.h @@ -17,8 +17,8 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ -#include "../hos/hos.h" -#include "../utils/types.h" +#include "hos/hos.h" +#include typedef struct _hekate_config { diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 0acff43..167c95d 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -24,19 +24,19 @@ #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" -#include "../sec/se.h" -#include "../sec/se_t210.h" -#include "../storage/mbr_gpt.h" +#include +#include "../config.h" +#include +#include +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/sprintf.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include #define NUM_SECTORS_PER_ITER 8192 // 4MB Cache. #define OUT_FILENAME_SZ 128 diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 0ddd74d..f229108 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -23,18 +23,18 @@ #include "gui.h" #include "fe_emummc_tools.h" -#include "../config/config.h" -#include "../config/ini.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../sec/se.h" -#include "../storage/mbr_gpt.h" +#include "../config.h" +#include +#include +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/sprintf.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include #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 765193c..2188196 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -21,33 +21,33 @@ #include "gui_tools.h" #include "gui_info.h" #include "gui_options.h" -#include "../libs/lvgl/lv_themes/lv_theme_hekate.h" -#include "../libs/lvgl/lvgl.h" +#include +#include #include "../gfx/logos-gui.h" -#include "../config/config.h" -#include "../config/ini.h" -#include "../gfx/di.h" -#include "../gfx/gfx.h" -#include "../input/joycon.h" -#include "../input/touch.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../mem/minerva.h" -#include "../power/bq24193.h" -#include "../power/max17050.h" -#include "../rtc/max77620-rtc.h" -#include "../soc/bpmp.h" -#include "../soc/hw_init.h" -#include "../soc/t210.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../thermal/fan.h" -#include "../thermal/tmp451.h" -#include "../utils/dirlist.h" -#include "../utils/sprintf.h" -#include "../utils/types.h" -#include "../utils/util.h" +#include "../config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include extern hekate_config h_cfg; extern nyx_config n_cfg; diff --git a/nyx/nyx_gui/frontend/gui.h b/nyx/nyx_gui/frontend/gui.h index 126e6f1..0990113 100644 --- a/nyx/nyx_gui/frontend/gui.h +++ b/nyx/nyx_gui/frontend/gui.h @@ -17,7 +17,7 @@ #ifndef _GUI_H_ #define _GUI_H_ -#include "../libs/lvgl/lvgl.h" +#include typedef struct _emmc_tool_gui_t { diff --git a/nyx/nyx_gui/frontend/gui_emmc_tools.c b/nyx/nyx_gui/frontend/gui_emmc_tools.c index 8a5e1ed..c62ad3b 100644 --- a/nyx/nyx_gui/frontend/gui_emmc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emmc_tools.c @@ -20,19 +20,19 @@ #include "gui_emmc_tools.h" #include "gui_tools.h" #include "fe_emmc_tools.h" -#include "../config/config.h" +#include "../config.h" #include "../hos/pkg1.h" #include "../hos/pkg2.h" #include "../hos/hos.h" #include "../hos/sept.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../sec/se.h" -#include "../soc/fuse.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/sprintf.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include extern boot_cfg_t b_cfg; extern hekate_config h_cfg; diff --git a/nyx/nyx_gui/frontend/gui_emmc_tools.h b/nyx/nyx_gui/frontend/gui_emmc_tools.h index 1bc031f..91aa2cd 100644 --- a/nyx/nyx_gui/frontend/gui_emmc_tools.h +++ b/nyx/nyx_gui/frontend/gui_emmc_tools.h @@ -17,7 +17,7 @@ #ifndef _GUI_EMMC_TOOLS_H_ #define _GUI_EMMC_TOOLS_H_ -#include "../libs/lvgl/lvgl.h" +#include lv_res_t create_window_backup_restore_tool(lv_obj_t *btn); diff --git a/nyx/nyx_gui/frontend/gui_emummc_tools.c b/nyx/nyx_gui/frontend/gui_emummc_tools.c index 7acfbc1..e4a98f8 100644 --- a/nyx/nyx_gui/frontend/gui_emummc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emummc_tools.c @@ -19,17 +19,17 @@ #include "gui.h" #include "fe_emummc_tools.h" #include "gui_tools_partition_manager.h" -#include "../../../common/memory_map.h" -#include "../config/ini.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../storage/mbr_gpt.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/dirlist.h" -#include "../utils/list.h" -#include "../utils/sprintf.h" -#include "../utils/types.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage); diff --git a/nyx/nyx_gui/frontend/gui_emummc_tools.h b/nyx/nyx_gui/frontend/gui_emummc_tools.h index 84cdb6d..d25bb32 100644 --- a/nyx/nyx_gui/frontend/gui_emummc_tools.h +++ b/nyx/nyx_gui/frontend/gui_emummc_tools.h @@ -17,7 +17,7 @@ #ifndef _GUI_EMUMMC_TOOLS_H_ #define _GUI_EMUMMC_TOOLS_H_ -#include "../libs/lvgl/lvgl.h" +#include lv_res_t create_win_emummc_tools(lv_obj_t *btn); diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 4797e31..26a99a3 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -17,29 +17,29 @@ */ #include "gui.h" -#include "../gfx/di.h" +#include #include "../hos/hos.h" #include "../hos/pkg1.h" -#include "../libs/fatfs/ff.h" -#include "../input/touch.h" -#include "../mem/emc.h" -#include "../mem/heap.h" -#include "../mem/sdram.h" -#include "../power/bq24193.h" -#include "../power/max17050.h" -#include "../sec/tsec.h" -#include "../soc/fuse.h" -#include "../soc/kfuse.h" -#include "../soc/i2c.h" -#include "../soc/smmu.h" -#include "../soc/t210.h" -#include "../storage/mmc.h" -#include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/sprintf.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../storage/nx_emmc_bis.h" +#include +#include +#include +#include +#include #define SECTORS_TO_MIB_COEFF 11 diff --git a/nyx/nyx_gui/frontend/gui_info.h b/nyx/nyx_gui/frontend/gui_info.h index f729957..caa1d21 100644 --- a/nyx/nyx_gui/frontend/gui_info.h +++ b/nyx/nyx_gui/frontend/gui_info.h @@ -17,7 +17,7 @@ #ifndef _GUI_INFO_H_ #define _GUI_INFO_H_ -#include "../libs/lvgl/lvgl.h" +#include void create_tab_info(lv_theme_t *th, lv_obj_t *parent); diff --git a/nyx/nyx_gui/frontend/gui_options.c b/nyx/nyx_gui/frontend/gui_options.c index cd656cc..8e410b5 100644 --- a/nyx/nyx_gui/frontend/gui_options.c +++ b/nyx/nyx_gui/frontend/gui_options.c @@ -17,17 +17,17 @@ #include #include "gui.h" -#include "../config/config.h" -#include "../config/ini.h" -#include "../gfx/di.h" -#include "../input/joycon.h" -#include "../libs/lvgl/lvgl.h" -#include "../mem/heap.h" -#include "../rtc/max77620-rtc.h" -#include "../storage/nx_sd.h" -#include "../utils/list.h" -#include "../utils/sprintf.h" -#include "../utils/types.h" +#include "../config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include extern hekate_config h_cfg; extern nyx_config n_cfg; diff --git a/nyx/nyx_gui/frontend/gui_options.h b/nyx/nyx_gui/frontend/gui_options.h index 9c9f7ef..0fee5e0 100644 --- a/nyx/nyx_gui/frontend/gui_options.h +++ b/nyx/nyx_gui/frontend/gui_options.h @@ -17,7 +17,7 @@ #ifndef _GUI_OPTIONS_H_ #define _GUI_OPTIONS_H_ -#include "../libs/lvgl/lvgl.h" +#include void nyx_options_clear_ini_changes_made(); bool nyx_options_get_ini_changes_made(); diff --git a/nyx/nyx_gui/frontend/gui_tools.c b/nyx/nyx_gui/frontend/gui_tools.c index 35fc2e1..2de8770 100644 --- a/nyx/nyx_gui/frontend/gui_tools.c +++ b/nyx/nyx_gui/frontend/gui_tools.c @@ -22,27 +22,27 @@ #include "gui_tools_partition_manager.h" #include "gui_emmc_tools.h" #include "fe_emummc_tools.h" -#include "../../../common/memory_map.h" -#include "../config/config.h" -#include "../gfx/di.h" +#include +#include "../config.h" +#include #include "../hos/pkg1.h" #include "../hos/pkg2.h" #include "../hos/hos.h" #include "../hos/sept.h" -#include "../input/touch.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../mem/minerva.h" -#include "../sec/se.h" -#include "../soc/bpmp.h" -#include "../soc/fuse.h" +#include +#include +#include +#include +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../usb/usbd.h" -#include "../utils/btn.h" -#include "../utils/sprintf.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include extern volatile boot_cfg_t *b_cfg; extern hekate_config h_cfg; diff --git a/nyx/nyx_gui/frontend/gui_tools.h b/nyx/nyx_gui/frontend/gui_tools.h index d01ccef..de40004 100644 --- a/nyx/nyx_gui/frontend/gui_tools.h +++ b/nyx/nyx_gui/frontend/gui_tools.h @@ -17,7 +17,7 @@ #ifndef _GUI_TOOLS_H_ #define _GUI_TOOLS_H_ -#include "../libs/lvgl/lvgl.h" +#include extern lv_obj_t *ums_mbox; diff --git a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c index 2cb4935..b6657c5 100644 --- a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c +++ b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c @@ -19,21 +19,21 @@ #include "gui.h" #include "gui_tools.h" #include "gui_tools_partition_manager.h" -#include "../libs/fatfs/diskio.h" -#include "../libs/lvgl/lvgl.h" -#include "../mem/heap.h" -#include "../sec/se.h" -#include "../soc/hw_init.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" -#include "../storage/mbr_gpt.h" +#include +#include +#include +#include +#include +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/ramdisk.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/sprintf.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include +#include extern volatile boot_cfg_t *b_cfg; extern volatile nyx_storage_t *nyx_str; diff --git a/nyx/nyx_gui/gfx/gfx.h b/nyx/nyx_gui/gfx/gfx.h index 2ed25aa..e5abe81 100644 --- a/nyx/nyx_gui/gfx/gfx.h +++ b/nyx/nyx_gui/gfx/gfx.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2019 CTCaer + * Copyright (c) 2018-2020 CTCaer * Copyright (c) 2018 M4xw * * This program is free software; you can redistribute it and/or modify it @@ -19,13 +19,39 @@ #ifndef _GFX_H_ #define _GFX_H_ -#include "../../../common/common_gfx.h" +#include #define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC) #define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC) #define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC) #define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC) +typedef struct _gfx_ctxt_t +{ + u32 *fb; + u32 width; + u32 height; + u32 stride; +} gfx_ctxt_t; + +typedef struct _gfx_con_t +{ + gfx_ctxt_t *gfx_ctxt; + u32 fntsz; + u32 x; + u32 y; + u32 savedx; + u32 savedy; + u32 fgcol; + int fillbg; + u32 bgcol; + bool mute; +} gfx_con_t; + +// Global gfx console and context. +extern gfx_ctxt_t gfx_ctxt; +extern gfx_con_t gfx_con; + void gfx_init_ctxt(u32 *fb, u32 width, u32 height, u32 stride); void gfx_clear_grey(u8 color); void gfx_clear_color(u32 color); @@ -43,8 +69,4 @@ void gfx_set_pixel(u32 x, u32 y, u32 color); void gfx_set_rect_land_pitch(u32 *fb, const u32 *buf, u32 stride, u32 pos_x, u32 pos_y, u32 pos_x2, u32 pos_y2); void gfx_set_rect_land_block(u32 *fb, const u32 *buf, u32 pos_x, u32 pos_y, u32 pos_x2, u32 pos_y2); -// Global gfx console and context. -extern gfx_ctxt_t gfx_ctxt; -extern gfx_con_t gfx_con; - #endif diff --git a/nyx/nyx_gui/gfx/logos-gui.h b/nyx/nyx_gui/gfx/logos-gui.h index c854601..6bae619 100644 --- a/nyx/nyx_gui/gfx/logos-gui.h +++ b/nyx/nyx_gui/gfx/logos-gui.h @@ -1,11 +1,11 @@ #ifndef _LOGOS_GUI_H_ #define _LOGOS_GUI_H_ -#include "../../../common/memory_map.h" +#include -#include "../libs/lv_conf.h" -#include "../libs/lvgl/lv_draw/lv_draw_img.h" -#include "../utils/types.h" +#include +#include +#include #define HEKATE_LOGO diff --git a/nyx/nyx_gui/hos/hos.c b/nyx/nyx_gui/hos/hos.c index 834a15b..0151028 100644 --- a/nyx/nyx_gui/hos/hos.c +++ b/nyx/nyx_gui/hos/hos.c @@ -22,24 +22,24 @@ #include "hos.h" #include "sept.h" -#include "../config/config.h" -#include "../gfx/di.h" -#include "../gfx/gfx.h" -#include "../mem/heap.h" -#include "../mem/mc.h" -#include "../sec/se.h" -#include "../sec/se_t210.h" -#include "../sec/tsec.h" -#include "../soc/bpmp.h" -#include "../soc/fuse.h" -#include "../soc/pmc.h" -#include "../soc/smmu.h" -#include "../soc/t210.h" -#include "../storage/mbr_gpt.h" +#include "../config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/util.h" +#include +#include +#include extern hekate_config h_cfg; diff --git a/nyx/nyx_gui/hos/hos.h b/nyx/nyx_gui/hos/hos.h index 6d8e802..fcc19ae 100644 --- a/nyx/nyx_gui/hos/hos.h +++ b/nyx/nyx_gui/hos/hos.h @@ -20,9 +20,9 @@ #include "pkg1.h" #include "pkg2.h" -#include "../utils/types.h" -#include "../config/ini.h" -#include "../sec/tsec.h" +#include +#include +#include #include diff --git a/nyx/nyx_gui/hos/pkg1.c b/nyx/nyx_gui/hos/pkg1.c index 6b5ebd1..f841797 100644 --- a/nyx/nyx_gui/hos/pkg1.c +++ b/nyx/nyx_gui/hos/pkg1.c @@ -20,10 +20,10 @@ #include #include "pkg1.h" -#include "../gfx/gfx.h" -#include "../mem/heap.h" -#include "../sec/se.h" -#include "../utils/aarch64_util.h" +#include +#include +#include +#include /* * package1.1 header: diff --git a/nyx/nyx_gui/hos/pkg1.h b/nyx/nyx_gui/hos/pkg1.h index d22b672..d55024e 100644 --- a/nyx/nyx_gui/hos/pkg1.h +++ b/nyx/nyx_gui/hos/pkg1.h @@ -17,7 +17,7 @@ #ifndef _PKG1_H_ #define _PKG1_H_ -#include "../utils/types.h" +#include typedef struct _pkg1_id_t { diff --git a/nyx/nyx_gui/hos/pkg2.c b/nyx/nyx_gui/hos/pkg2.c index ac9ed6b..36f087e 100644 --- a/nyx/nyx_gui/hos/pkg2.c +++ b/nyx/nyx_gui/hos/pkg2.c @@ -20,14 +20,13 @@ #include "pkg2.h" #include "hos.h" -#include "../config/config.h" -#include "../libs/fatfs/ff.h" -#include "../utils/aarch64_util.h" -#include "../mem/heap.h" -#include "../sec/se.h" -#include "../libs/compr/blz.h" +#include "../config.h" +#include +#include +#include +#include -#include "../gfx/gfx.h" +#include extern hekate_config h_cfg; extern const u8 package2_keyseed[]; @@ -36,7 +35,7 @@ u32 pkg2_newkern_ini1_val; u32 pkg2_newkern_ini1_start; u32 pkg2_newkern_ini1_end; -/*#include "util.h" +/*#include #define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DEBUG_PRINTING*/ #define DPRINTF(...) diff --git a/nyx/nyx_gui/hos/pkg2.h b/nyx/nyx_gui/hos/pkg2.h index 6080e2e..fddfce7 100644 --- a/nyx/nyx_gui/hos/pkg2.h +++ b/nyx/nyx_gui/hos/pkg2.h @@ -18,8 +18,8 @@ #ifndef _PKG2_H_ #define _PKG2_H_ -#include "../utils/types.h" -#include "../utils/list.h" +#include +#include #define PKG2_MAGIC 0x31324B50 #define PKG2_SEC_BASE 0x80000000 diff --git a/nyx/nyx_gui/hos/sept.c b/nyx/nyx_gui/hos/sept.c index 1f91fc5..fad4ec0 100644 --- a/nyx/nyx_gui/hos/sept.c +++ b/nyx/nyx_gui/hos/sept.c @@ -18,22 +18,22 @@ #include "hos.h" #include "sept.h" -#include "../config/config.h" -#include "../gfx/di.h" -#include "../ianos/ianos.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" -#include "../soc/hw_init.h" -#include "../soc/pmc.h" -#include "../soc/t210.h" +#include "../config.h" +#include +#include +#include +#include +#include +#include +#include #include "../storage/nx_emmc.h" -#include "../storage/nx_sd.h" -#include "../storage/sdmmc.h" -#include "../utils/btn.h" -#include "../utils/types.h" -#include "../utils/util.h" +#include +#include +#include +#include +#include -#include "../gfx/gfx.h" +#include #define RELOC_META_OFF 0x7C #define PATCHED_RELOC_SZ 0x94 diff --git a/nyx/nyx_gui/hos/sept.h b/nyx/nyx_gui/hos/sept.h index 7b44c73..d431840 100644 --- a/nyx/nyx_gui/hos/sept.h +++ b/nyx/nyx_gui/hos/sept.h @@ -17,7 +17,7 @@ #ifndef _SEPT_H_ #define _SEPT_H_ -#include "../utils/types.h" +#include void check_sept(); int reboot_to_sept(const u8 *tsec_fw, u32 kb); diff --git a/nyx/nyx_gui/libs/fatfs/diskio.c b/nyx/nyx_gui/libs/fatfs/diskio.c index 4482fad..f2f52b0 100644 --- a/nyx/nyx_gui/libs/fatfs/diskio.c +++ b/nyx/nyx_gui/libs/fatfs/diskio.c @@ -9,12 +9,12 @@ #include -#include "diskio.h" /* FatFs lower layer API */ -#include "../../../../common/memory_map.h" +#include /* FatFs lower layer API */ +#include #include "../../storage/nx_emmc_bis.h" -#include "../../storage/nx_sd.h" -#include "../../storage/ramdisk.h" -#include "../../storage/sdmmc.h" +#include +#include +#include /*-----------------------------------------------------------------------*/ /* Get Drive Status */ diff --git a/nyx/nyx_gui/libs/fatfs/ffsystem.c b/nyx/nyx_gui/libs/fatfs/ffsystem.c index 3c02f40..cdd2a7a 100644 --- a/nyx/nyx_gui/libs/fatfs/ffsystem.c +++ b/nyx/nyx_gui/libs/fatfs/ffsystem.c @@ -5,10 +5,10 @@ /*------------------------------------------------------------------------*/ -#include "ff.h" -#include "../../config/config.h" -#include "../../mem/heap.h" -#include "../../rtc/max77620-rtc.h" +#include +#include "../../config.h" +#include +#include extern nyx_config n_cfg; diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index 938ab36..e0c9082 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -19,33 +19,33 @@ #include #include -#include "../../common/memory_map.h" +#include -#include "config/config.h" -#include "gfx/di.h" -#include "gfx/gfx.h" +#include "config.h" +#include +#include #include "hos/hos.h" -#include "ianos/ianos.h" -#include "libs/compr/blz.h" -#include "libs/fatfs/ff.h" -#include "mem/heap.h" -#include "mem/minerva.h" -#include "mem/sdram.h" -#include "power/max77620.h" -#include "soc/bpmp.h" -#include "soc/fuse.h" -#include "soc/gpio.h" -#include "soc/hw_init.h" -#include "soc/i2c.h" -#include "soc/pmc.h" -#include "soc/t210.h" -#include "soc/uart.h" -#include "storage/nx_sd.h" -#include "storage/sdmmc.h" -#include "utils/btn.h" -#include "utils/dirlist.h" -#include "utils/list.h" -#include "utils/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "frontend/fe_emmc_tools.h" #include "frontend/gui.h" diff --git a/nyx/nyx_gui/storage/nx_emmc.c b/nyx/nyx_gui/storage/nx_emmc.c index aa58d60..fa36e59 100644 --- a/nyx/nyx_gui/storage/nx_emmc.c +++ b/nyx/nyx_gui/storage/nx_emmc.c @@ -16,10 +16,10 @@ #include -#include "mbr_gpt.h" +#include #include "nx_emmc.h" -#include "../mem/heap.h" -#include "../utils/list.h" +#include +#include sdmmc_t emmc_sdmmc; sdmmc_storage_t emmc_storage; diff --git a/nyx/nyx_gui/storage/nx_emmc.h b/nyx/nyx_gui/storage/nx_emmc.h index 380b7a0..5db6a1f 100644 --- a/nyx/nyx_gui/storage/nx_emmc.h +++ b/nyx/nyx_gui/storage/nx_emmc.h @@ -17,10 +17,10 @@ #ifndef _NX_EMMC_H_ #define _NX_EMMC_H_ -#include "sdmmc.h" -#include "../libs/fatfs/ff.h" -#include "../utils/types.h" -#include "../utils/list.h" +#include +#include +#include +#include #define NX_GPT_FIRST_LBA 1 #define NX_GPT_NUM_BLOCKS 33 diff --git a/nyx/nyx_gui/storage/nx_emmc_bis.c b/nyx/nyx_gui/storage/nx_emmc_bis.c index aab7e2b..f88a644 100644 --- a/nyx/nyx_gui/storage/nx_emmc_bis.c +++ b/nyx/nyx_gui/storage/nx_emmc_bis.c @@ -19,12 +19,12 @@ #include -#include "../../../common/memory_map.h" +#include -#include "../sec/se.h" +#include #include "../storage/nx_emmc.h" -#include "../storage/sdmmc.h" -#include "../utils/types.h" +#include +#include #define MAX_SEC_CACHE_ENTRIES 1500 diff --git a/nyx/nyx_gui/storage/nx_emmc_bis.h b/nyx/nyx_gui/storage/nx_emmc_bis.h index 607bdae..70ec895 100644 --- a/nyx/nyx_gui/storage/nx_emmc_bis.h +++ b/nyx/nyx_gui/storage/nx_emmc_bis.h @@ -19,7 +19,7 @@ #define NX_EMMC_BIS_H #include "../storage/nx_emmc.h" -#include "../storage/sdmmc.h" +#include typedef struct _nx_emmc_cal0_spk_t { diff --git a/nyx/nyx_gui/storage/nx_sd.c b/nyx/nyx_gui/storage/nx_sd.c index c7eb3d6..175ec3e 100644 --- a/nyx/nyx_gui/storage/nx_sd.c +++ b/nyx/nyx_gui/storage/nx_sd.c @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -#include "nx_sd.h" -#include "sdmmc.h" -#include "sdmmc_driver.h" -#include "../gfx/gfx.h" -#include "../libs/fatfs/ff.h" -#include "../mem/heap.h" +#include +#include +#include +#include +#include +#include static bool sd_mounted = false; static bool sd_init_done = false;