Refactor ALL the things + enable LTO

This commit is contained in:
Kostas Missos 2018-08-13 11:58:24 +03:00
parent 2666b440ef
commit e5abdd938e
110 changed files with 275 additions and 1961 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
.vs .vs
.vscode .vscode
build_ipl/* build/*
output/* output/*

View file

@ -4,17 +4,17 @@ endif
include $(DEVKITARM)/base_rules include $(DEVKITARM)/base_rules
TARGET := ipl TARGET := hekate
BUILD := build_ipl BUILD := build
OUTPUT := output OUTPUT := output
SOURCEDIR := ipl SOURCEDIR = bootloader
VPATH = $(dir $(wildcard ./$(SOURCEDIR)/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/))
OBJS = $(addprefix $(BUILD)/, \ OBJS = $(addprefix $(BUILD)/$(TARGET)/, \
start.o \ start.o \
main.o \ main.o \
config.o \ config.o \
btn.o \ btn.o \
blz.o \
clock.o \ clock.o \
cluster.o \ cluster.o \
fuse.o \ fuse.o \
@ -23,7 +23,6 @@ OBJS = $(addprefix $(BUILD)/, \
hos.o \ hos.o \
i2c.o \ i2c.o \
kfuse.o \ kfuse.o \
lz.o \
bq24193.o \ bq24193.o \
max7762x.o \ max7762x.o \
max17050.o \ max17050.o \
@ -46,12 +45,15 @@ OBJS = $(addprefix $(BUILD)/, \
ini.o \ ini.o \
) )
OBJS += $(addprefix $(BUILD)/, diskio.o ff.o ffunicode.o ffsystem.o) OBJS += $(addprefix $(BUILD)/$(TARGET)/, \
OBJS += $(addprefix $(BUILD)/elfloader/, elfload.o elfreloc_arm.o) lz.o blz.o \
diskio.o ff.o ffunicode.o ffsystem.o \
elfload.o elfreloc_arm.o \
)
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
CUSTOMDEFINES := -DMENU_LOGO_ENABLE #-DDEBUG CUSTOMDEFINES := -DMENU_LOGO_ENABLE #-DDEBUG
CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall $(CUSTOMDEFINES) CFLAGS = $(ARCH) -O2 -nostdlib -flto -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall $(CUSTOMDEFINES)
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections
MODULEDIRS := $(wildcard modules/*) MODULEDIRS := $(wildcard modules/*)
@ -71,17 +73,17 @@ clean:
$(MODULEDIRS): $(MODULEDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS) $(MAKE) -C $@ $(MAKECMDGOALS)
$(TARGET).bin: $(BUILD)/$(TARGET).elf $(MODULEDIRS) $(TARGET).bin: $(BUILD)/$(TARGET)/$(TARGET).elf $(MODULEDIRS)
$(OBJCOPY) -S -O binary $< $(OUTPUT)/$@ $(OBJCOPY) -S -O binary $< $(OUTPUT)/$@
$(BUILD)/$(TARGET).elf: $(OBJS) $(BUILD)/$(TARGET)/$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) -T ipl/link.ld $^ -o $@ $(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
$(BUILD)/%.o: $(SOURCEDIR)/%.c $(BUILD)/$(TARGET)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
$(BUILD)/%.o: $(SOURCEDIR)/%.S $(BUILD)/$(TARGET)/%.o: %.S
@mkdir -p "$(BUILD)" @mkdir -p "$(BUILD)"
@mkdir -p "$(BUILD)/elfloader" @mkdir -p "$(BUILD)/$(TARGET)"
@mkdir -p "$(OUTPUT)" @mkdir -p "$(OUTPUT)"
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@

View file

@ -17,14 +17,14 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "btn.h" #include "../utils/btn.h"
#include "config.h" #include "config.h"
#include "ff.h" #include "../libs/fatfs/ff.h"
#include "ini.h" #include "ini.h"
#include "list.h" #include "../utils/list.h"
#include "tui.h" #include "../gfx/tui.h"
#include "util.h" #include "../utils/util.h"
#include "gfx.h" #include "../gfx/gfx.h"
extern gfx_ctxt_t gfx_ctxt; extern gfx_ctxt_t gfx_ctxt;
extern gfx_con_t gfx_con; extern gfx_con_t gfx_con;

View file

@ -17,7 +17,7 @@
#ifndef _CONFIG_H_ #ifndef _CONFIG_H_
#define _CONFIG_H_ #define _CONFIG_H_
#include "types.h" #include "../utils/types.h"
typedef struct _hekate_config typedef struct _hekate_config
{ {

4
ipl/ini.c → bootloader/config/ini.c Executable file → Normal file
View file

@ -18,8 +18,8 @@
#include <string.h> #include <string.h>
#include "ini.h" #include "ini.h"
#include "ff.h" #include "../libs/fatfs/ff.h"
#include "heap.h" #include "../mem/heap.h"
static char *_strdup(char *str) static char *_strdup(char *str)
{ {

4
ipl/ini.h → bootloader/config/ini.h Executable file → Normal file
View file

@ -18,8 +18,8 @@
#ifndef _INI_H_ #ifndef _INI_H_
#define _INI_H_ #define _INI_H_
#include "types.h" #include "../utils/types.h"
#include "list.h" #include "../utils/list.h"
#define INI_CHOICE 3 #define INI_CHOICE 3
#define INI_CAPTION 5 #define INI_CAPTION 5

16
ipl/di.c → bootloader/gfx/di.c Executable file → Normal file
View file

@ -18,14 +18,14 @@
#include <string.h> #include <string.h>
#include "di.h" #include "di.h"
#include "t210.h" #include "../soc/t210.h"
#include "util.h" #include "../utils/util.h"
#include "i2c.h" #include "../soc/i2c.h"
#include "pmc.h" #include "../soc/pmc.h"
#include "max77620.h" #include "../power/max77620.h"
#include "gpio.h" #include "../soc/gpio.h"
#include "pinmux.h" #include "../soc/pinmux.h"
#include "clock.h" #include "../soc/clock.h"
#include "di.inl" #include "di.inl"

2
ipl/di.h → bootloader/gfx/di.h Executable file → Normal file
View file

@ -18,7 +18,7 @@
#ifndef _DI_H_ #ifndef _DI_H_
#define _DI_H_ #define _DI_H_
#include "types.h" #include "../utils/types.h"
/*! Display registers. */ /*! Display registers. */
#define _DIREG(reg) ((reg) * 4) #define _DIREG(reg) ((reg) * 4)

0
ipl/di.inl → bootloader/gfx/di.inl Executable file → Normal file
View file

0
ipl/gfx.c → bootloader/gfx/gfx.c Executable file → Normal file
View file

2
ipl/gfx.h → bootloader/gfx/gfx.h Executable file → Normal file
View file

@ -19,7 +19,7 @@
#ifndef _GFX_H_ #ifndef _GFX_H_
#define _GFX_H_ #define _GFX_H_
#include "../common/common_gfx.h" #include "../../common/common_gfx.h"
void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride); 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_grey(gfx_ctxt_t *ctxt, u8 color);

8
ipl/tui.c → bootloader/gfx/tui.c Executable file → Normal file
View file

@ -16,10 +16,10 @@
*/ */
#include "tui.h" #include "tui.h"
#include "btn.h" #include "../utils/btn.h"
#include "config.h" #include "../config/config.h"
#include "max17050.h" #include "../power/max17050.h"
#include "util.h" #include "../utils/util.h"
#ifdef MENU_LOGO_ENABLE #ifdef MENU_LOGO_ENABLE
extern u8 *Kc_MENU_LOGO; extern u8 *Kc_MENU_LOGO;

2
ipl/tui.h → bootloader/gfx/tui.h Executable file → Normal file
View file

@ -18,7 +18,7 @@
#ifndef _TUI_H_ #ifndef _TUI_H_
#define _TUI_H_ #define _TUI_H_
#include "types.h" #include "../utils/types.h"
#include "gfx.h" #include "gfx.h"
#define MENT_END 0 #define MENT_END 0

32
ipl/hos.c → bootloader/hos/hos.c Executable file → Normal file
View file

@ -20,26 +20,24 @@
#include <string.h> #include <string.h>
#include "hos.h" #include "hos.h"
#include "sdmmc.h" #include "../storage/sdmmc.h"
#include "nx_emmc.h" #include "../storage/nx_emmc.h"
#include "t210.h" #include "../soc/t210.h"
#include "se.h" #include "../sec/se.h"
#include "se_t210.h" #include "../sec/se_t210.h"
#include "pmc.h" #include "../soc/pmc.h"
#include "cluster.h" #include "../soc/cluster.h"
#include "heap.h" #include "../mem/heap.h"
#include "tsec.h" #include "../sec/tsec.h"
#include "pkg2.h" #include "../utils/util.h"
#include "nx_emmc.h"
#include "util.h"
#include "pkg1.h" #include "pkg1.h"
#include "pkg2.h" #include "pkg2.h"
#include "ff.h" #include "../libs/fatfs/ff.h"
#include "di.h" #include "../gfx/di.h"
#include "config.h" #include "../config/config.h"
#include "mc.h" #include "../mem/mc.h"
#include "gfx.h" #include "../gfx/gfx.h"
extern gfx_ctxt_t gfx_ctxt; extern gfx_ctxt_t gfx_ctxt;
extern gfx_con_t gfx_con; extern gfx_con_t gfx_con;
extern void sd_unmount(); extern void sd_unmount();

4
ipl/hos.h → bootloader/hos/hos.h Executable file → Normal file
View file

@ -17,8 +17,8 @@
#ifndef _HOS_H_ #ifndef _HOS_H_
#define _HOS_H_ #define _HOS_H_
#include "types.h" #include "../utils/types.h"
#include "ini.h" #include "../config/ini.h"
int hos_launch(ini_sec_t *cfg); int hos_launch(ini_sec_t *cfg);
int keygen(u8 *keyblob, u32 kb, void *tsec_fw); int keygen(u8 *keyblob, u32 kb, void *tsec_fw);

4
ipl/pkg1.c → bootloader/hos/pkg1.c Executable file → Normal file
View file

@ -19,8 +19,8 @@
#include <string.h> #include <string.h>
#include "pkg1.h" #include "pkg1.h"
#include "arm64.h" #include "../utils/aarch64_util.h"
#include "se.h" #include "../sec/se.h"
#define SM_100_ADR 0x4002B020 #define SM_100_ADR 0x4002B020
PATCHSET_DEF(_secmon_1_patchset, PATCHSET_DEF(_secmon_1_patchset,

2
ipl/pkg1.h → bootloader/hos/pkg1.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _PKG1_H_ #ifndef _PKG1_H_
#define _PKG1_H_ #define _PKG1_H_
#include "types.h" #include "../utils/types.h"
typedef struct _patch_t typedef struct _patch_t
{ {

10
ipl/pkg2.c → bootloader/hos/pkg2.c Executable file → Normal file
View file

@ -19,12 +19,12 @@
#include <string.h> #include <string.h>
#include "pkg2.h" #include "pkg2.h"
#include "arm64.h" #include "../utils/aarch64_util.h"
#include "heap.h" #include "../mem/heap.h"
#include "se.h" #include "../sec/se.h"
#include "blz.h" #include "../libs/compr/blz.h"
#include "gfx.h" #include "../gfx/gfx.h"
extern gfx_con_t gfx_con; extern gfx_con_t gfx_con;

4
ipl/pkg2.h → bootloader/hos/pkg2.h Executable file → Normal file
View file

@ -18,8 +18,8 @@
#ifndef _PKG2_H_ #ifndef _PKG2_H_
#define _PKG2_H_ #define _PKG2_H_
#include "types.h" #include "../utils/types.h"
#include "list.h" #include "../utils/list.h"
#define PKG2_MAGIC 0x31324B50 #define PKG2_MAGIC 0x31324B50
#define PKG2_SEC_BASE 0x80000000 #define PKG2_SEC_BASE 0x80000000

View file

@ -17,7 +17,7 @@
#ifndef _BLZ_H_ #ifndef _BLZ_H_
#define _BLZ_H_ #define _BLZ_H_
#include "types.h" #include "../../utils/types.h"
typedef struct _blz_footer typedef struct _blz_footer
{ {

0
ipl/lz.c → bootloader/libs/compr/lz.c Executable file → Normal file
View file

0
ipl/lz.h → bootloader/libs/compr/lz.h Executable file → Normal file
View file

View file

@ -1,4 +1,5 @@
/* Copyright © 2014, Owen Shepherd /*
* Copyright © 2014, Owen Shepherd
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -12,6 +13,7 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
#ifndef ELFARCH_H #ifndef ELFARCH_H
#define ELFARCH_H #define ELFARCH_H

View file

@ -1,4 +1,5 @@
/* Copyright © 2018, M4xw /*
* Copyright © 2018, M4xw
* Copyright © 2014, Owen Shepherd * Copyright © 2014, Owen Shepherd
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
@ -13,9 +14,11 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "elfload.h"
#include <string.h> #include <string.h>
#include "elfload.h"
el_status el_pread(el_ctx *ctx, void *def, size_t nb, size_t offset) el_status el_pread(el_ctx *ctx, void *def, size_t nb, size_t offset)
{ {
return ctx->pread(ctx, def, nb, offset) ? EL_OK : EL_EIO; return ctx->pread(ctx, def, nb, offset) ? EL_OK : EL_EIO;
@ -141,7 +144,6 @@ el_status el_init(el_ctx *ctx)
// Section String Table // Section String Table
if (ctx->ehdr.e_type == ET_DYN) if (ctx->ehdr.e_type == ET_DYN)
{ {
i = ctx->ehdr.e_shstrndx - 1; i = ctx->ehdr.e_shstrndx - 1;
if ((rv = el_findshdr(ctx, &ctx->shstr, SHT_STRTAB, &i))) if ((rv = el_findshdr(ctx, &ctx->shstr, SHT_STRTAB, &i)))

View file

@ -1,4 +1,5 @@
/* Copyright © 2018, M4xw /*
* Copyright © 2018, M4xw
* Copyright © 2014, Owen Shepherd * Copyright © 2014, Owen Shepherd
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
@ -16,13 +17,15 @@
#ifndef ELFLOAD_H #ifndef ELFLOAD_H
#define ELFLOAD_H #define ELFLOAD_H
#include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include "elfarch.h" #include "elfarch.h"
#include "elf.h" #include "elf.h"
#include "../../utils/types.h"
#ifdef DEBUG #ifdef DEBUG
#include "../gfx.h" #include "../../gfx/gfx.h"
extern gfx_con_t gfx_con; extern gfx_con_t gfx_con;
#define EL_DEBUG(format, ...) \ #define EL_DEBUG(format, ...) \
gfx_printf(&gfx_con, format __VA_OPT__(, ) __VA_ARGS__) gfx_printf(&gfx_con, format __VA_OPT__(, ) __VA_ARGS__)

View file

@ -1,4 +1,5 @@
/* Copyright © 2014, Owen Shepherd /*
* Copyright © 2014, Owen Shepherd
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above

View file

@ -1,9 +1,9 @@
/* /*
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42): * "THE BEER-WARE LICENSE" (Revision 42):
* <m4x@m4xw.net> wrote this file. As long as you retain this notice you * <m4x@m4xw.net> wrote this file. As long as you retain this notice you can do
* can do whatever you want with this stuff. If we meet some day, and you think * whatever you want with this stuff. If we meet some day, and you think this
* this stuff is worth it, you can buy me a beer in return. M4xw * stuff is worth it, you can buy me a beer in return. M4xw
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
*/ */

2
ipl/diskio.c → bootloader/libs/fatfs/diskio.c Executable file → Normal file
View file

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include "diskio.h" /* FatFs lower layer API */ #include "diskio.h" /* FatFs lower layer API */
#include "sdmmc.h" #include "../../storage/sdmmc.h"
extern sdmmc_storage_t sd_storage; extern sdmmc_storage_t sd_storage;

2
ipl/diskio.h → bootloader/libs/fatfs/diskio.h Executable file → Normal file
View file

@ -9,7 +9,7 @@
extern "C" { extern "C" {
#endif #endif
#include "integer.h" #include "../../utils/types.h"
/* Status of Disk Functions */ /* Status of Disk Functions */

2
ipl/ff.c → bootloader/libs/fatfs/ff.c Executable file → Normal file
View file

@ -24,7 +24,7 @@
#include "ff.h" /* Declarations of FatFs API */ #include "ff.h" /* Declarations of FatFs API */
#include "diskio.h" /* Declarations of device I/O functions */ #include "diskio.h" /* Declarations of device I/O functions */
#include "gfx.h" #include "../../gfx/gfx.h"
extern gfx_ctxt_t gfx_ctxt; extern gfx_ctxt_t gfx_ctxt;
extern gfx_con_t gfx_con; extern gfx_con_t gfx_con;
#define EFSPRINTF(text, ...) print_error(); gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFFFF00, 0xFFFFFFFF); #define EFSPRINTF(text, ...) print_error(); gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFFFF00, 0xFFFFFFFF);

2
ipl/ff.h → bootloader/libs/fatfs/ff.h Executable file → Normal file
View file

@ -26,7 +26,7 @@
extern "C" { extern "C" {
#endif #endif
#include "integer.h" /* Basic integer types */ #include "../../utils/types.h" /* Basic integer types */
#include "ffconf.h" /* FatFs configuration options */ #include "ffconf.h" /* FatFs configuration options */
#if FF_DEFINED != FFCONF_DEF #if FF_DEFINED != FFCONF_DEF

0
ipl/ffconf.h → bootloader/libs/fatfs/ffconf.h Executable file → Normal file
View file

View file

@ -6,7 +6,7 @@
#include "ff.h" #include "ff.h"
#include "heap.h" #include "../../mem/heap.h"

0
ipl/ffunicode.c → bootloader/libs/fatfs/ffunicode.c Executable file → Normal file
View file

0
ipl/link.ld → bootloader/link.ld Executable file → Normal file
View file

72
ipl/main.c → bootloader/main.c Executable file → Normal file
View file

@ -22,43 +22,43 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "clock.h" #include "soc/clock.h"
#include "uart.h" #include "soc/uart.h"
#include "i2c.h" #include "soc/i2c.h"
#include "sdram.h" #include "mem/sdram.h"
#include "di.h" #include "gfx/di.h"
#include "mc.h" #include "mem/mc.h"
#include "t210.h" #include "soc/t210.h"
#include "pmc.h" #include "soc/pmc.h"
#include "pinmux.h" #include "soc/pinmux.h"
#include "fuse.h" #include "soc/fuse.h"
#include "util.h" #include "utils/util.h"
#include "gfx.h" #include "gfx/gfx.h"
#include "btn.h" #include "utils/btn.h"
#include "tsec.h" #include "sec/tsec.h"
#include "kfuse.h" #include "soc/kfuse.h"
#include "max77620.h" #include "power/max77620.h"
#include "max7762x.h" #include "power/max7762x.h"
#include "gpio.h" #include "soc/gpio.h"
#include "sdmmc.h" #include "storage/sdmmc.h"
#include "ff.h" #include "libs/fatfs/ff.h"
#include "hekate_logos.h" #include "gfx/logos.h"
#include "tui.h" #include "gfx/tui.h"
#include "heap.h" #include "mem/heap.h"
#include "list.h" #include "utils/list.h"
#include "nx_emmc.h" #include "storage/nx_emmc.h"
#include "se.h" #include "sec/se.h"
#include "se_t210.h" #include "sec/se_t210.h"
#include "hos.h" #include "hos/hos.h"
#include "pkg1.h" #include "hos/pkg1.h"
#include "pkg2.h" #include "hos/pkg2.h"
#include "mmc.h" #include "storage/mmc.h"
#include "blz.h" #include "libs/compr/blz.h"
#include "max17050.h" #include "power/max17050.h"
#include "bq24193.h" #include "power/bq24193.h"
#include "config.h" #include "config/config.h"
#include "elfloader/elfload.h" #include "libs/elfload/elfload.h"
#include "../common/common_module.h" #include "../common/common_module.h"
// TODO: Make it not suck // TODO: Make it not suck

0
ipl/emc.h → bootloader/mem/emc.h Executable file → Normal file
View file

2
ipl/heap.c → bootloader/mem/heap.c Executable file → Normal file
View file

@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
#include "heap.h" #include "heap.h"
#include "../common/common_heap.h" #include "../../common/common_heap.h"
static void _heap_create(heap_t *heap, u32 start) static void _heap_create(heap_t *heap, u32 start)
{ {

2
ipl/heap.h → bootloader/mem/heap.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _HEAP_H_ #ifndef _HEAP_H_
#define _HEAP_H_ #define _HEAP_H_
#include "types.h" #include "../utils/types.h"
void heap_init(u32 base); void heap_init(u32 base);
void *malloc(u32 size); void *malloc(u32 size);

8
ipl/mc.c → bootloader/mem/mc.c Executable file → Normal file
View file

@ -1,7 +1,7 @@
#include "mc.h" #include "../mem/mc.h"
#include "t210.h" #include "../soc/t210.h"
#include "clock.h" #include "../soc/clock.h"
#include "util.h" #include "../utils/util.h"
void mc_config_tsec_carveout(u32 bom, u32 size1mb, int lock) void mc_config_tsec_carveout(u32 bom, u32 size1mb, int lock)
{ {

4
ipl/mc.h → bootloader/mem/mc.h Executable file → Normal file
View file

@ -1,8 +1,8 @@
#ifndef _MC_H_ #ifndef _MC_H_
#define _MC_H_ #define _MC_H_
#include "types.h" #include "../utils/types.h"
#include "mc_t210.h" #include "../mem/mc_t210.h"
void mc_config_tsec_carveout(u32 bom, u32 size1mb, int lock); void mc_config_tsec_carveout(u32 bom, u32 size1mb, int lock);
void mc_config_carveout(); void mc_config_carveout();

0
ipl/mc_t210.h → bootloader/mem/mc_t210.h Executable file → Normal file
View file

22
ipl/sdram.c → bootloader/mem/sdram.c Executable file → Normal file
View file

@ -14,24 +14,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "i2c.h" #include "../soc/i2c.h"
#include "t210.h" #include "../soc/t210.h"
#include "mc.h" #include "mc.h"
#include "emc.h" #include "emc.h"
#include "pmc.h" #include "../soc/pmc.h"
#include "util.h" #include "../utils/util.h"
#include "fuse.h" #include "../soc/fuse.h"
#include "max77620.h" #include "../power/max77620.h"
#include "sdram_param_t210.h" #include "../mem/sdram_param_t210.h"
#include "clock.h" #include "../soc/clock.h"
#define CONFIG_SDRAM_COMPRESS_CFG #define CONFIG_SDRAM_COMPRESS_CFG
#ifdef CONFIG_SDRAM_COMPRESS_CFG #ifdef CONFIG_SDRAM_COMPRESS_CFG
#include "lz.h" #include "../libs/compr/lz.h"
#include "sdram_lz.inl" #include "sdram_config_lz.inl"
#else #else
#include "sdram.inl" #include "sdram_config.inl"
#endif #endif
static u32 _get_sdram_id() static u32 _get_sdram_id()

0
ipl/sdram.h → bootloader/mem/sdram.h Executable file → Normal file
View file

0
ipl/sdram.inl → bootloader/mem/sdram_config.inl Executable file → Normal file
View file

View file

6
ipl/sdram_lp0.c → bootloader/mem/sdram_lp0.c Executable file → Normal file
View file

@ -14,9 +14,9 @@
* more details. * more details.
*/ */
#include "t210.h" #include "../soc/t210.h"
#include "pmc_t210_lp0.h" #include "../soc/pmc_lp0_t210.h"
#include "sdram_param_t210_lp0.h" #include "sdram_lp0_param_t210.h"
/* /*
* This function reads SDRAM parameters from the common BCT format and * This function reads SDRAM parameters from the common BCT format and

View file

@ -23,7 +23,7 @@
#ifndef __SOC_NVIDIA_TEGRA210_SDRAM_PARAM_H__ #ifndef __SOC_NVIDIA_TEGRA210_SDRAM_PARAM_H__
#define __SOC_NVIDIA_TEGRA210_SDRAM_PARAM_H__ #define __SOC_NVIDIA_TEGRA210_SDRAM_PARAM_H__
#include "types.h" #include "../utils/types.h"
enum enum
{ {

View file

View file

@ -17,8 +17,8 @@
*/ */
#include "bq24193.h" #include "bq24193.h"
#include "i2c.h" #include "../soc/i2c.h"
#include "util.h" #include "../utils/util.h"
int bq24193_get_property(enum BQ24193_reg_prop prop, int *value) int bq24193_get_property(enum BQ24193_reg_prop prop, int *value)
{ {

View file

@ -23,8 +23,8 @@
*/ */
#include "max17050.h" #include "max17050.h"
#include "i2c.h" #include "../soc/i2c.h"
#include "util.h" #include "../utils/util.h"
/* Status register bits */ /* Status register bits */
#define STATUS_POR_BIT (1 << 1) #define STATUS_POR_BIT (1 << 1)

0
ipl/max77620.h → bootloader/power/max77620.h Executable file → Normal file
View file

4
ipl/max7762x.c → bootloader/power/max7762x.c Executable file → Normal file
View file

@ -16,8 +16,8 @@
#include "max7762x.h" #include "max7762x.h"
#include "max77620.h" #include "max77620.h"
#include "i2c.h" #include "../soc/i2c.h"
#include "util.h" #include "../utils/util.h"
#define REGULATOR_SD 0 #define REGULATOR_SD 0
#define REGULATOR_LDO 1 #define REGULATOR_LDO 1

2
ipl/max7762x.h → bootloader/power/max7762x.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _MAX7762X_H_ #ifndef _MAX7762X_H_
#define _MAX7762X_H_ #define _MAX7762X_H_
#include "types.h" #include "../utils/types.h"
/* /*
* Switch Power domains (max77620): * Switch Power domains (max77620):

0
ipl/reloc.S → bootloader/reloc.S Executable file → Normal file
View file

10
ipl/se.c → bootloader/sec/se.c Executable file → Normal file
View file

@ -18,11 +18,11 @@
#include <string.h> #include <string.h>
#include "se.h" #include "../sec/se.h"
#include "heap.h" #include "../mem/heap.h"
#include "t210.h" #include "../soc/t210.h"
#include "se_t210.h" #include "../sec/se_t210.h"
#include "util.h" #include "../utils/util.h"
typedef struct _se_ll_t typedef struct _se_ll_t
{ {

2
ipl/se.h → bootloader/sec/se.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _SE_H_ #ifndef _SE_H_
#define _SE_H_ #define _SE_H_
#include "types.h" #include "../utils/types.h"
void se_rsa_acc_ctrl(u32 rs, u32 flags); void se_rsa_acc_ctrl(u32 rs, u32 flags);
void se_key_acc_ctrl(u32 ks, u32 flags); void se_key_acc_ctrl(u32 ks, u32 flags);

2
ipl/se_t210.h → bootloader/sec/se_t210.h Executable file → Normal file
View file

@ -21,7 +21,7 @@
#ifndef _CRYPTO_TEGRA_SE_H #ifndef _CRYPTO_TEGRA_SE_H
#define _CRYPTO_TEGRA_SE_H #define _CRYPTO_TEGRA_SE_H
#include "types.h" #include "../utils/types.h"
#define TEGRA_SE_CRA_PRIORITY 300 #define TEGRA_SE_CRA_PRIORITY 300
#define TEGRA_SE_COMPOSITE_PRIORITY 400 #define TEGRA_SE_COMPOSITE_PRIORITY 400

10
ipl/tsec.c → bootloader/sec/tsec.c Executable file → Normal file
View file

@ -16,11 +16,11 @@
#include <string.h> #include <string.h>
#include "tsec.h" #include "../sec/tsec.h"
#include "clock.h" #include "../soc/clock.h"
#include "t210.h" #include "../soc/t210.h"
#include "heap.h" #include "../mem/heap.h"
#include "util.h" #include "../utils/util.h"
static int _tsec_dma_wait_idle() static int _tsec_dma_wait_idle()
{ {

2
ipl/tsec.h → bootloader/sec/tsec.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _TSEC_H_ #ifndef _TSEC_H_
#define _TSEC_H_ #define _TSEC_H_
#include "types.h" #include "../utils/types.h"
int tsec_query(u8 *dst, u32 rev, void *fw); int tsec_query(u8 *dst, u32 rev, void *fw);

8
ipl/clock.c → bootloader/soc/clock.c Executable file → Normal file
View file

@ -14,10 +14,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "clock.h" #include "../soc/clock.h"
#include "t210.h" #include "../soc/t210.h"
#include "util.h" #include "../utils/util.h"
#include "sdmmc.h" #include "../storage/sdmmc.h"
static const clock_t _clock_uart[] = { static const clock_t _clock_uart[] = {
/* UART A */ { CLK_RST_CONTROLLER_RST_DEVICES_L, CLK_RST_CONTROLLER_CLK_OUT_ENB_L, CLK_RST_CONTROLLER_CLK_SOURCE_UARTA, 6, 0, 0 }, /* UART A */ { CLK_RST_CONTROLLER_RST_DEVICES_L, CLK_RST_CONTROLLER_CLK_OUT_ENB_L, CLK_RST_CONTROLLER_CLK_SOURCE_UARTA, 6, 0, 0 },

2
ipl/clock.h → bootloader/soc/clock.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _CLOCK_H_ #ifndef _CLOCK_H_
#define _CLOCK_H_ #define _CLOCK_H_
#include "types.h" #include "../utils/types.h"
/*! Clock registers. */ /*! Clock registers. */
#define CLK_RST_CONTROLLER_RST_SOURCE 0x0 #define CLK_RST_CONTROLLER_RST_SOURCE 0x0

14
ipl/cluster.c → bootloader/soc/cluster.c Executable file → Normal file
View file

@ -14,13 +14,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "cluster.h" #include "../soc/cluster.h"
#include "i2c.h" #include "../soc/i2c.h"
#include "clock.h" #include "../soc/clock.h"
#include "util.h" #include "../utils/util.h"
#include "pmc.h" #include "../soc/pmc.h"
#include "t210.h" #include "../soc/t210.h"
#include "max77620.h" #include "../power/max77620.h"
void _cluster_enable_power() void _cluster_enable_power()
{ {

2
ipl/cluster.h → bootloader/soc/cluster.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _CLUSTER_H_ #ifndef _CLUSTER_H_
#define _CLUSTER_H_ #define _CLUSTER_H_
#include "types.h" #include "../utils/types.h"
/*! Flow controller registers. */ /*! Flow controller registers. */
#define FLOW_CTLR_HALT_COP_EVENTS 0x4 #define FLOW_CTLR_HALT_COP_EVENTS 0x4

4
ipl/fuse.c → bootloader/soc/fuse.c Executable file → Normal file
View file

@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "fuse.h" #include "../soc/fuse.h"
#include "t210.h" #include "../soc/t210.h"
void fuse_disable_program() void fuse_disable_program()
{ {

2
ipl/fuse.h → bootloader/soc/fuse.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _FUSE_H_ #ifndef _FUSE_H_
#define _FUSE_H_ #define _FUSE_H_
#include "types.h" #include "../utils/types.h"
/*! Fuse registers. */ /*! Fuse registers. */
#define FUSE_CTRL 0x0 #define FUSE_CTRL 0x0

4
ipl/gpio.c → bootloader/soc/gpio.c Executable file → Normal file
View file

@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "gpio.h" #include "../soc/gpio.h"
#include "t210.h" #include "../soc/t210.h"
static const u16 _gpio_cnf[31] = { static const u16 _gpio_cnf[31] = {
0x000, 0x004, 0x008, 0x00C, 0x000, 0x004, 0x008, 0x00C,

2
ipl/gpio.h → bootloader/soc/gpio.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _GPIO_H_ #ifndef _GPIO_H_
#define _GPIO_H_ #define _GPIO_H_
#include "types.h" #include "../utils/types.h"
#define GPIO_MODE_SPIO 0 #define GPIO_MODE_SPIO 0
#define GPIO_MODE_GPIO 1 #define GPIO_MODE_GPIO 1

2
ipl/i2c.c → bootloader/soc/i2c.c Executable file → Normal file
View file

@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
#include "i2c.h" #include "i2c.h"
#include "util.h" #include "../utils/util.h"
static u32 i2c_addrs[] = { static u32 i2c_addrs[] = {
0x7000C000, 0x7000C400, 0x7000C500, 0x7000C000, 0x7000C400, 0x7000C500,

2
ipl/i2c.h → bootloader/soc/i2c.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _I2C_H_ #ifndef _I2C_H_
#define _I2C_H_ #define _I2C_H_
#include "types.h" #include "../utils/types.h"
#define I2C_1 0 #define I2C_1 0
#define I2C_2 1 #define I2C_2 1

6
ipl/kfuse.c → bootloader/soc/kfuse.c Executable file → Normal file
View file

@ -14,9 +14,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "kfuse.h" #include "../soc/kfuse.h"
#include "clock.h" #include "../soc/clock.h"
#include "t210.h" #include "../soc/t210.h"
int kfuse_read(u32 *buf) int kfuse_read(u32 *buf)
{ {

2
ipl/kfuse.h → bootloader/soc/kfuse.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _KFUSE_H_ #ifndef _KFUSE_H_
#define _KFUSE_H_ #define _KFUSE_H_
#include "types.h" #include "../utils/types.h"
#define KFUSE_STATE_SOFTRESET (1 << 31) #define KFUSE_STATE_SOFTRESET (1 << 31)
#define KFUSE_STATE_STOP (1 << 25) #define KFUSE_STATE_STOP (1 << 25)

4
ipl/pinmux.c → bootloader/soc/pinmux.c Executable file → Normal file
View file

@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "pinmux.h" #include "../soc/pinmux.h"
#include "t210.h" #include "../soc/t210.h"
void pinmux_config_uart(u32 idx) void pinmux_config_uart(u32 idx)
{ {

2
ipl/pinmux.h → bootloader/soc/pinmux.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _PINMUX_H_ #ifndef _PINMUX_H_
#define _PINMUX_H_ #define _PINMUX_H_
#include "types.h" #include "../utils/types.h"
/*! APB MISC registers. */ /*! APB MISC registers. */
#define APB_MISC_GP_SDMMC1_CLK_LPBK_CONTROL 0x8D4 #define APB_MISC_GP_SDMMC1_CLK_LPBK_CONTROL 0x8D4

0
ipl/pmc.h → bootloader/soc/pmc.h Executable file → Normal file
View file

2
ipl/pmc_t210_lp0.h → bootloader/soc/pmc_lp0_t210.h Executable file → Normal file
View file

@ -14,7 +14,7 @@
#ifndef _TEGRA210_PMC_H_ #ifndef _TEGRA210_PMC_H_
#define _TEGRA210_PMC_H_ #define _TEGRA210_PMC_H_
#include "types.h" #include "../utils/types.h"
struct tegra_pmc_regs { struct tegra_pmc_regs {
u32 cntrl; u32 cntrl;

2
ipl/t210.h → bootloader/soc/t210.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _T210_H_ #ifndef _T210_H_
#define _T210_H_ #define _T210_H_
#include "types.h" #include "../utils/types.h"
#define HOST1X_BASE 0x50000000 #define HOST1X_BASE 0x50000000
#define DISPLAY_A_BASE 0x54200000 #define DISPLAY_A_BASE 0x54200000

6
ipl/uart.c → bootloader/soc/uart.c Executable file → Normal file
View file

@ -14,9 +14,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "uart.h" #include "../soc/uart.h"
#include "t210.h" #include "../soc/t210.h"
#include "util.h" #include "../utils/util.h"
/* UART A, B, C, D and E. */ /* UART A, B, C, D and E. */
static const u32 uart_baseoff[5] = { 0, 0x40, 0x200, 0x300, 0x400 }; static const u32 uart_baseoff[5] = { 0, 0x40, 0x200, 0x300, 0x400 };

2
ipl/uart.h → bootloader/soc/uart.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _UART_H_ #ifndef _UART_H_
#define _UART_H_ #define _UART_H_
#include "types.h" #include "../utils/types.h"
#define UART_A 0 #define UART_A 0
#define UART_B 1 #define UART_B 1

0
ipl/start.S → bootloader/start.S Executable file → Normal file
View file

0
ipl/mmc.h → bootloader/storage/mmc.h Executable file → Normal file
View file

4
ipl/nx_emmc.c → bootloader/storage/nx_emmc.c Executable file → Normal file
View file

@ -17,8 +17,8 @@
#include <string.h> #include <string.h>
#include "nx_emmc.h" #include "nx_emmc.h"
#include "heap.h" #include "../mem/heap.h"
#include "list.h" #include "../utils/list.h"
void nx_emmc_gpt_parse(link_t *gpt, sdmmc_storage_t *storage) void nx_emmc_gpt_parse(link_t *gpt, sdmmc_storage_t *storage)
{ {

4
ipl/nx_emmc.h → bootloader/storage/nx_emmc.h Executable file → Normal file
View file

@ -17,8 +17,8 @@
#ifndef _NX_EMMC_H_ #ifndef _NX_EMMC_H_
#define _NX_EMMC_H_ #define _NX_EMMC_H_
#include "types.h" #include "../utils/types.h"
#include "list.h" #include "../utils/list.h"
#include "sdmmc.h" #include "sdmmc.h"
typedef struct _gpt_entry_t typedef struct _gpt_entry_t

0
ipl/sd.h → bootloader/storage/sd.h Executable file → Normal file
View file

4
ipl/sdmmc.c → bootloader/storage/sdmmc.c Executable file → Normal file
View file

@ -19,8 +19,8 @@
#include "sdmmc.h" #include "sdmmc.h"
#include "mmc.h" #include "mmc.h"
#include "sd.h" #include "sd.h"
#include "util.h" #include "../utils/util.h"
#include "heap.h" #include "../mem/heap.h"
/*#include "gfx.h" /*#include "gfx.h"
extern gfx_ctxt_t gfx_ctxt; extern gfx_ctxt_t gfx_ctxt;

2
ipl/sdmmc.h → bootloader/storage/sdmmc.h Executable file → Normal file
View file

@ -18,7 +18,7 @@
#ifndef _SDMMC_H_ #ifndef _SDMMC_H_
#define _SDMMC_H_ #define _SDMMC_H_
#include "types.h" #include "../utils/types.h"
#include "sdmmc_driver.h" #include "sdmmc_driver.h"
typedef struct _mmc_cid typedef struct _mmc_cid

View file

@ -18,14 +18,14 @@
#include <string.h> #include <string.h>
#include "sdmmc.h" #include "sdmmc.h"
#include "util.h" #include "../utils/util.h"
#include "clock.h" #include "../soc/clock.h"
#include "mmc.h" #include "mmc.h"
#include "max7762x.h" #include "../power/max7762x.h"
#include "t210.h" #include "../soc/t210.h"
#include "pmc.h" #include "../soc/pmc.h"
#include "pinmux.h" #include "../soc/pinmux.h"
#include "gpio.h" #include "../soc/gpio.h"
/*#include "gfx.h" /*#include "gfx.h"
extern gfx_ctxt_t gfx_ctxt; extern gfx_ctxt_t gfx_ctxt;

View file

@ -17,7 +17,7 @@
#ifndef _SDMMC_DRIVER_H_ #ifndef _SDMMC_DRIVER_H_
#define _SDMMC_DRIVER_H_ #define _SDMMC_DRIVER_H_
#include "types.h" #include "../utils/types.h"
#include "sdmmc_t210.h" #include "sdmmc_t210.h"
/*! SDMMC controller IDs. */ /*! SDMMC controller IDs. */

2
ipl/sdmmc_t210.h → bootloader/storage/sdmmc_t210.h Executable file → Normal file
View file

@ -17,7 +17,7 @@
#ifndef _SDMMC_T210_H_ #ifndef _SDMMC_T210_H_
#define _SDMMC_T210_H_ #define _SDMMC_T210_H_
#include "types.h" #include "../utils/types.h"
#define TEGRA_MMC_PWRCTL_SD_BUS_POWER 0x1 #define TEGRA_MMC_PWRCTL_SD_BUS_POWER 0x1
#define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8 0xA #define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8 0xA

0
ipl/arm64.h → bootloader/utils/aarch64_util.h Executable file → Normal file
View file

6
ipl/btn.c → bootloader/utils/btn.c Executable file → Normal file
View file

@ -16,9 +16,9 @@
*/ */
#include "btn.h" #include "btn.h"
#include "i2c.h" #include "../soc/i2c.h"
#include "gpio.h" #include "../soc/gpio.h"
#include "t210.h" #include "../soc/t210.h"
#include "util.h" #include "util.h"
u32 btn_read() u32 btn_read()

0
ipl/btn.h → bootloader/utils/btn.h Executable file → Normal file
View file

0
ipl/list.h → bootloader/utils/list.h Executable file → Normal file
View file

9
ipl/types.h → bootloader/utils/types.h Executable file → Normal file
View file

@ -28,11 +28,20 @@
typedef char s8; typedef char s8;
typedef short s16; typedef short s16;
typedef short SHORT;
typedef int s32; typedef int s32;
typedef int INT;
typedef long LONG;
typedef long long int s64; typedef long long int s64;
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned char BYTE;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned short WORD;
typedef unsigned short WCHAR;
typedef unsigned int u32; typedef unsigned int u32;
typedef unsigned int UINT;
typedef unsigned long DWORD;
typedef unsigned long long QWORD;
typedef unsigned long long int u64; typedef unsigned long long int u64;
typedef volatile unsigned char vu8; typedef volatile unsigned char vu8;
typedef volatile unsigned short vu16; typedef volatile unsigned short vu16;

2
ipl/util.c → bootloader/utils/util.c Executable file → Normal file
View file

@ -16,7 +16,7 @@
*/ */
#include "util.h" #include "util.h"
#include "t210.h" #include "../soc/t210.h"
u32 get_tmr_s() u32 get_tmr_s()
{ {

Some files were not shown because too many files have changed in this diff Show more