Implement payload compression

This commit is contained in:
shchmue 2021-05-12 16:47:06 -06:00
parent a7712b173c
commit 918b00ce07
20 changed files with 2305 additions and 28 deletions

11
.gitignore vendored
View file

@ -1,4 +1,9 @@
.vs
.vscode
build
output
research
build/*
output/*
research/*
loader/payload_00.h
loader/payload_01.h
tools/bin2c/bin2c
tools/lz/lz77

View file

@ -8,10 +8,8 @@ include $(DEVKITARM)/base_rules
################################################################################
IPL_LOAD_ADDR := 0x40003000
LPVERSION_MAJOR := 1
LPVERSION_MINOR := 9
LPVERSION_BUGFX := 1
IPL_LOAD_ADDR := 0x40008000
include ./Versions.inc
################################################################################
@ -40,52 +38,84 @@ CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
CUSTOMDEFINES += -DLP_VER_MJ=$(LPVERSION_MAJOR) -DLP_VER_MN=$(LPVERSION_MINOR) -DLP_VER_BF=$(LPVERSION_BUGFX)
CUSTOMDEFINES += -DGFX_INC=$(GFX_INC) -DFFCFG_INC=$(FFCFG_INC)
# 0: UART_A, 1: UART_B.
#CUSTOMDEFINES += -DDEBUG_UART_PORT=0
#CUSTOMDEFINES += -DDEBUG
# UART Logging: Max baudrate 12.5M.
# DEBUG_UART_PORT - 0: UART_A, 1: UART_B, 2: UART_C.
#CUSTOMDEFINES += -DDEBUG_UART_BAUDRATE=115200 -DDEBUG_UART_INVERT=0 -DDEBUG_UART_PORT=0
#TODO: Considering reinstating some of these when pointer warnings have been fixed.
WARNINGS := -Wall -Wno-array-bounds -Wno-stringop-overread -Wno-stringop-overflow
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
CFLAGS = $(ARCH) -Os -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 $(WARNINGS) $(CUSTOMDEFINES)
CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 $(WARNINGS) $(CUSTOMDEFINES)
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=IPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
LDRDIR := $(wildcard loader)
TOOLSLZ := $(wildcard tools/lz)
TOOLSB2C := $(wildcard tools/bin2c)
TOOLS := $(TOOLSLZ) $(TOOLSB2C)
################################################################################
.PHONY: all clean
.PHONY: all clean $(LDRDIR) $(TOOLS)
all: $(OUTPUTDIR)/$(TARGET).bin
@echo -n "Payload size is "
all: $(OUTPUTDIR)/$(TARGET).bin $(LDRDIR)
@echo "--------------------------------------"
@echo -n "Uncompr size: "
$(eval BIN_SIZE = $(shell wc -c < $(OUTPUTDIR)/$(TARGET)_unc.bin))
@echo $(BIN_SIZE)" Bytes"
@echo "Uncompr Max: 140288 Bytes + 3 KiB BSS"
@if [ ${BIN_SIZE} -gt 140288 ]; then echo "\e[1;33mUncompr size exceeds limit!\e[0m"; fi
@echo -n "Payload size: "
$(eval BIN_SIZE = $(shell wc -c < $(OUTPUTDIR)/$(TARGET).bin))
@echo $(BIN_SIZE)
@echo "Max size is 126296 Bytes."
@echo $(BIN_SIZE)" Bytes"
@echo "Payload Max: 126296 Bytes"
@if [ ${BIN_SIZE} -gt 126296 ]; then echo "\e[1;33mPayload size exceeds limit!\e[0m"; fi
@echo "--------------------------------------"
clean:
clean: $(TOOLS)
@rm -rf $(BUILDDIR)
@rm -rf $(OUTPUTDIR)
$(OUTPUTDIR)/$(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf
$(LDRDIR): $(OUTPUTDIR)/$(TARGET).bin
@$(TOOLSLZ)/lz77 $(OUTPUTDIR)/$(TARGET).bin
mv $(OUTPUTDIR)/$(TARGET).bin $(OUTPUTDIR)/$(TARGET)_unc.bin
@mv $(OUTPUTDIR)/$(TARGET).bin.00.lz payload_00
@mv $(OUTPUTDIR)/$(TARGET).bin.01.lz payload_01
@$(TOOLSB2C)/bin2c payload_00 > $(LDRDIR)/payload_00.h
@$(TOOLSB2C)/bin2c payload_01 > $(LDRDIR)/payload_01.h
@rm payload_00
@rm payload_01
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) -$(MAKEFLAGS) PAYLOAD_NAME=$(TARGET)
$(TOOLS):
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) -$(MAKEFLAGS)
$(OUTPUTDIR)/$(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf $(TOOLS)
@mkdir -p "$(@D)"
$(OBJCOPY) -S -O binary $< $@
$(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
@$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
@echo "Lockpick_RCM was built with the following flags:\nCFLAGS: "$(CFLAGS)"\nLDFLAGS: "$(LDFLAGS)
$(BUILDDIR)/$(TARGET)/%.o: $(SOURCEDIR)/%.c
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@
@echo Building $@
@$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@
$(BUILDDIR)/$(TARGET)/%.o: $(SOURCEDIR)/%.S
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -c $< -o $@
@echo Building $@
@$(CC) $(CFLAGS) -c $< -o $@
$(BUILDDIR)/$(TARGET)/%.o: $(BDKDIR)/%.c
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@
@echo Building $@
@$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@
$(BUILDDIR)/$(TARGET)/%.o: $(BDKDIR)/%.S
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -c $< -o $@
@echo Building $@
@$(CC) $(CFLAGS) -c $< -o $@

4
Versions.inc Normal file
View file

@ -0,0 +1,4 @@
# LP Version.
LPVERSION_MAJOR := 1
LPVERSION_MINOR := 9
LPVERSION_BUGFX := 1

View file

@ -20,7 +20,7 @@
#include <soc/clock.h>
#include <utils/util.h>
#define CONFIG_ENABLE_AHB_REDIRECT
//#define CONFIG_ENABLE_AHB_REDIRECT
void mc_config_tsec_carveout(u32 bom, u32 size1mb, bool lock)
{

View file

@ -19,10 +19,10 @@
//#define IPL_STACK_TOP 0x4003FF00
/* --- BIT/BCT: 0x40000000 - 0x40003000 --- */
/* --- IPL: 0x40003000 - 0x40028000 --- */
/* --- IPL: 0x40008000 - 0x40028000 --- */
#define LDR_LOAD_ADDR 0x40007000
#define IPL_LOAD_ADDR 0x40003000
#define IPL_LOAD_ADDR 0x40008000
#define IPL_SZ_MAX 0x20000 // 128KB.
/* --- XUSB EP context and TRB ring buffers --- */

65
loader/Makefile Normal file
View file

@ -0,0 +1,65 @@
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/base_rules
################################################################################
LDR_LOAD_ADDR := 0x40007000
IPL_MAGIC := 0x43544349 #"ICTC"
include ../Versions.inc
################################################################################
TARGET := loader
BUILDDIR := ../build
OUTPUTDIR := ../output
BDKDIR := bdk
BDKINC := -I../$(BDKDIR)
VPATH += $(dir $(wildcard ../$(BDKDIR)/*/)) $(dir $(wildcard ../$(BDKDIR)/*/*/))
# Main and graphics.
OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \
start.o loader.o lz.o \
)
################################################################################
CUSTOMDEFINES := -DBL_MAGIC=$(IPL_MAGIC)
CUSTOMDEFINES += -DBL_VER_MJ=$(BLVERSION_MAJOR) -DBL_VER_MN=$(BLVERSION_MINOR) -DBL_VER_HF=$(BLVERSION_HOTFX) -DBL_RESERVED=$(BLVERSION_RSVD)
#TODO: Considering reinstating some of these when pointer warnings have been fixed.
WARNINGS := -Wall -Wno-array-bounds -Wno-stringop-overflow
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb-interwork
CFLAGS = $(ARCH) -O2 -g -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -std=gnu11 $(WARNINGS) $(CUSTOMDEFINES)
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=LDR_LOAD_ADDR=$(LDR_LOAD_ADDR)
################################################################################
.PHONY: all clean
all: $(TARGET).bin $(TOOLSLZ) $(TOOLSB2C)
clean:
@rm -rf $(OBJS)
$(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf
$(OBJCOPY) -S -O binary $< $(OUTPUTDIR)/$(PAYLOAD_NAME).bin
$(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS)
@$(CC) $(LDFLAGS) -T link.ld $^ -o $@
$(BUILDDIR)/$(TARGET)/%.o: %.c
@$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@
$(BUILDDIR)/$(TARGET)/%.o: %.S
@$(CC) $(CFLAGS) -c $< -o $@
$(OBJS): $(BUILDDIR)/$(TARGET)
$(BUILDDIR)/$(TARGET):
@mkdir -p "$(BUILDDIR)"
@mkdir -p "$(BUILDDIR)/$(TARGET)"
@mkdir -p "$(OUTPUTDIR)"

21
loader/link.ld Normal file
View file

@ -0,0 +1,21 @@
ENTRY(_start)
SECTIONS {
PROVIDE(__ipl_start = LDR_LOAD_ADDR);
. = __ipl_start;
.text : {
*(.text._start);
KEEP(*(._boot_cfg));
KEEP(*(._octopus));
*(.text*);
}
.data : {
*(.data*);
*(.rodata*);
*(._payload_00);
*(._payload_01);
}
__ldr_end = .;
. = ALIGN(0x10);
__ipl_end = .;
}

101
loader/loader.c Normal file
View file

@ -0,0 +1,101 @@
/*
* Copyright (c) 2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <stdlib.h>
#include "payload_00.h"
#include "payload_01.h"
#include <memory_map.h>
#include <libs/compr/lz.h>
#include <soc/clock.h>
#include <soc/t210.h>
// 0x4003D000: Safe for panic preserving, 0x40038000: Safe for debugging needs.
#define IPL_RELOC_TOP 0x40038000
#define IPL_PATCHED_RELOC_SZ 0x94
boot_cfg_t __attribute__((section ("._boot_cfg"))) b_cfg;
const volatile char __attribute__((section ("._octopus"))) octopus[] =
"\n"
" ___\n"
" .-' `'.\n"
" / \\\n"
" | ;\n"
" | | ___.--,\n"
" _.._ |0) = (0) | _.---'`__.-( (_.\n"
" __.--'`_.. '.__.\\ '--. \\_.-' ,.--'` `\"\"`\n"
" ( ,.--'` ',__ /./; ;, '.__.'` __\n"
" _`) ) .---.__.' / | |\\ \\__..--\"\" \"\"\"--.,_\n"
" `---' .'.''-._.-'`_./ /\\ '. \\ _.--''````'''--._`-.__.'\n"
" | | .' _.-' | | \\ \\ '. `----`\n"
" \\ \\/ .' \\ \\ '. '-._)\n"
" \\/ / \\ \\ `=.__`'-.\n"
" / /\\ `) ) / / `\"\".`\\\n"
" , _.-'.'\\ \\ / / ( ( / /\n"
" `--'` ) ) .-'.' '.'. | (\n"
" (/` ( (` ) ) '-; [switchbrew]\n";
void loader_main()
{
// Preliminary BPMP clocks init.
CLOCK(CLK_RST_CONTROLLER_CLK_SYSTEM_RATE) = 0x10; // Set HCLK div to 2 and PCLK div to 1.
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_SYS) = 0; // Set SCLK div to 1.
CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20004444; // Set clk source to Run and PLLP_OUT2 (204MHz).
CLOCK(CLK_RST_CONTROLLER_SUPER_SCLK_DIVIDER) = 0x80000000; // Enable SUPER_SDIV to 1.
CLOCK(CLK_RST_CONTROLLER_CLK_SYSTEM_RATE) = 2; // Set HCLK div to 1 and PCLK div to 3.
CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20003333; // Set SCLK to PLLP_OUT (408MHz).
// Get Loader and Payload size.
u32 payload_size = sizeof(payload_00) + sizeof(payload_01); // Actual payload size.
payload_size += (u32)payload_01 - (u32)payload_00 - sizeof(payload_00); // Add array alignment.
u32 *payload_addr = (u32 *)payload_00;
// Relocate payload to a safer place.
u32 bytes = ALIGN(payload_size, 4) >> 2;
u32 *addr = payload_addr + bytes - 1;
u32 *dst = (u32 *)(IPL_RELOC_TOP - 4);
while (bytes)
{
*dst = *addr;
dst--;
addr--;
bytes--;
}
// Set source address of the first part.
u8 *src_addr = (void *)(IPL_RELOC_TOP - ALIGN(payload_size, 4));
// Uncompress first part.
u32 dst_pos = LZ_Uncompress((const u8 *)src_addr, (u8*)IPL_LOAD_ADDR, sizeof(payload_00));
// Set source address of the second part. Includes array alignment.
src_addr += (u32)payload_01 - (u32)payload_00;
// Uncompress second part.
LZ_Uncompress((const u8 *)src_addr, (u8*)IPL_LOAD_ADDR + dst_pos, sizeof(payload_01));
// Copy over boot configuration storage.
memcpy((u8 *)(IPL_LOAD_ADDR + IPL_PATCHED_RELOC_SZ), &b_cfg, sizeof(boot_cfg_t));
// Chainload into uncompressed payload.
void (*ipl_ptr)() = (void *)IPL_LOAD_ADDR;
(*ipl_ptr)();
// Halt if we managed to get out of execution.
while (true)
;
}

73
loader/start.S Normal file
View file

@ -0,0 +1,73 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
.section .text._start
.arm
.extern _reloc_ipl
.type _reloc_ipl, %function
.extern memset
.type memset, %function
.extern loader_main
.type loader_main, %function
.globl _start
.type _start, %function
_start:
ADR R0, _start
LDR R1, =__ipl_start
CMP R0, R1
BEQ _real_start
/* If we are not in the right location already, copy a relocator to upper IRAM. */
ADR R2, _reloc_ipl
LDR R3, =0x4003FF00
MOV R4, #(_real_start - _reloc_ipl)
_copy_loop:
LDMIA R2!, {R5}
STMIA R3!, {R5}
SUBS R4, #4
BNE _copy_loop
/* Use the relocator to copy ourselves into the right place. */
LDR R2, =__ipl_end
SUB R2, R2, R1
LDR R3, =_real_start
LDR R4, =0x4003FF00
BX R4
_reloc_ipl:
LDMIA R0!, {R4-R7}
STMIA R1!, {R4-R7}
SUBS R2, #0x10
BNE _reloc_ipl
/* Jump to the relocated entry. */
BX R3
_real_start:
/* Initially, we place our stack in IRAM but will move it to SDRAM later. */
LDR SP, =0x40007000
LDR R0, =__ldr_end
BL loader_main
B .
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0

View file

@ -202,7 +202,7 @@ static bool _derive_tsec_keys(tsec_ctxt_t *tsec_ctxt, u32 kb, key_derivation_ctx
int res = 0;
u32 retries = 0;
mc_disable_ahb_redirect();
// mc_disable_ahb_redirect();
while (tsec_query(keys->tsec_keys, kb, tsec_ctxt) < 0) {
memset(keys->tsec_keys, 0, sizeof(keys->tsec_keys));
@ -213,7 +213,7 @@ static bool _derive_tsec_keys(tsec_ctxt_t *tsec_ctxt, u32 kb, key_derivation_ctx
}
}
mc_enable_ahb_redirect();
// mc_enable_ahb_redirect();
if (res < 0) {
EPRINTFARGS("ERROR %x dumping TSEC.\n", res);

16
tools/bin2c/Makefile Normal file
View file

@ -0,0 +1,16 @@
NATIVE_CC ?= gcc
ifeq (, $(shell which $(NATIVE_CC) 2>/dev/null))
$(error "Native GCC is missing. Please install it first. If it's path is custom, set it with export NATIVE_CC=<path to native gcc toolchain>")
endif
.PHONY: all clean
all: bin2c
@echo > /dev/null
clean:
@rm -f bin2c
bin2c: bin2c.c
@$(NATIVE_CC) -o $@ bin2c.c

83
tools/bin2c/bin2c.c Normal file
View file

@ -0,0 +1,83 @@
/*
* This is bin2c program, which allows you to convert binary file to
* C language array, for use as embedded resource, for instance you can
* embed graphics or audio file directly into your program.
* This is public domain software, use it on your own risk.
* Contact Serge Fukanchik at fuxx@mail.ru if you have any questions.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
/* Replace . with _ */
char*
make_ident ( char* name )
{
char* ret;
char* p;
ret = strdup ( name );
for ( p = ret; p[0]; p++ )
{
if ( !isalnum ( p[0] ) ) p[0] = '_';
}
return ret;
}
int
main ( int argc, char* argv[] )
{
unsigned char buf[BUFSIZ];
char* ident;
FILE *fd;
size_t size, i, total, blksize = BUFSIZ;
int need_comma = 0;
if ( argc != 2 )
{
fprintf ( stderr, "Usage: %s binary_file > output_file\n", argv[0] );
return -1;
}
fd = fopen ( argv[1], "rb" );
if ( fd == NULL )
{
fprintf ( stderr, "%s: can't open %s for reading\n", argv[0], argv[1] );
return -1;
}
fseek(fd, 0, SEEK_END);
size = ftell(fd);
rewind(fd);
ident = make_ident ( argv[1] );
printf ( "static const unsigned char __attribute__((section (\"._%s\"))) %s[] = {", ident, ident );
for ( total = 0; total < size; )
{
if ( size - total < blksize ) blksize = size - total;
if ( fread ( buf, 1, blksize, fd ) != blksize )
{
fprintf ( stderr, "%s: file read error\n", argv[0] );
return -1;
}
for ( i = 0; i < blksize; i++ )
{
if ( need_comma ) printf ( ", " );
else need_comma = 1;
if ( ( total % 11 ) == 0 ) printf ( "\n\t" );
printf ( "0x%.2x", buf[i] );
total++;
}
}
printf ( "\n};\n" );
fclose ( fd );
free ( ident );
return 0;
}

641
tools/emc.def Normal file
View file

@ -0,0 +1,641 @@
EMC_DBG 8
EMC_CFG C
EMC_CONFIG_SAMPLE_DELAY 5f0
EMC_CFG_UPDATE 5f4
EMC_ADR_CFG 10
EMC_REFCTRL 20
EMC_PIN 24
EMC_TIMING_CONTROL 28
EMC_RC 2c
EMC_RFC 30
EMC_RFCPB 590
EMC_RAS 34
EMC_RP 38
EMC_R2W 3c
EMC_W2R 40
EMC_R2P 44
EMC_W2P 48
EMC_CCDMW 5c0
EMC_RD_RCD 4c
EMC_WR_RCD 50
EMC_RRD 54
EMC_REXT 58
EMC_WDV 5c
EMC_QUSE 60
EMC_QRST 64
EMC_ISSUE_QRST 428
EMC_QSAFE 68
EMC_RDV 6c
EMC_REFRESH 70
EMC_BURST_REFRESH_NUM 74
EMC_PDEX2WR 78
EMC_PDEX2RD 7c
EMC_PDEX2CKE 118
EMC_PCHG2PDEN 80
EMC_ACT2PDEN 84
EMC_AR2PDEN 88
EMC_RW2PDEN 8c
EMC_CKE2PDEN 11c
EMC_TXSR 90
EMC_TCKE 94
EMC_TFAW 98
EMC_TRPAB 9c
EMC_TCLKSTABLE a0
EMC_TCLKSTOP a4
EMC_TREFBW a8
EMC_TPPD ac
EMC_PDEX2MRR b4
EMC_ODT_WRITE b0
EMC_WEXT b8
EMC_RFC_SLR c0
EMC_MRS_WAIT_CNT2 c4
EMC_MRS_WAIT_CNT c8
EMC_MRS cc
EMC_EMRS d0
EMC_REF d4
EMC_PRE d8
EMC_NOP dc
EMC_SELF_REF e0
EMC_DPD e4
EMC_MRW e8
EMC_MRR ec
EMC_CMDQ f0
EMC_MC2EMCQ f4
EMC_FBIO_SPARE 100
EMC_FBIO_CFG5 104
EMC_CFG_RSV 120
EMC_ACPD_CONTROL 124
EMC_MPC 128
EMC_EMRS2 12c
EMC_EMRS3 130
EMC_MRW2 134
EMC_MRW3 138
EMC_MRW4 13c
EMC_MRW5 4a0
EMC_MRW6 4a4
EMC_MRW7 4a8
EMC_MRW8 4ac
EMC_MRW9 4b0
EMC_MRW10 4b4
EMC_MRW11 4b8
EMC_MRW12 4bc
EMC_MRW13 4c0
EMC_MRW14 4c4
EMC_MRW15 4d0
EMC_CFG_SYNC 4d4
EMC_CLKEN_OVERRIDE 140
EMC_R2R 144
EMC_W2W 148
EMC_EINPUT 14c
EMC_EINPUT_DURATION 150
EMC_PUTERM_EXTRA 154
E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SWIZZLE_RANK0_BYTE3 410
EMC_SWIZZLE_RANK1_BYTE0 418
EMC_SWIZZLE_RANK1_BYTE1 41c
EMC_SWIZZLE_RANK1_BYTE2 420
EMC_SWIZZLE_RANK1_BYTE3 424
EMC_TR_TIMING_0 3b4
EMC_TR_CTRL_0 3b8
EMC_TR_CTRL_1 3bc
EMC_TR_DVFS 460
EMC_SWITCH_BACK_CTRL 3c0
EMC_TR_RDV 3c4
EMC_TR_QPOP 3f4
EMC_TR_RDV_MASK 3f8
EMC_TR_QSAFE 3fc
EMC_TR_QRST 400
EMC_IBDLY 468
EMC_OBDLY 46c
EMC_TXDSRVTTGEN 480
EMC_WE_DURATION 48c
EMC_WS_DURATION 490
EMC_WEV 494
EMC_WSV 498
EMC_CFG_3 49c
EMC_CFG_PIPE_2 554
EMC_CFG_PIPE_CLK 558
EMC_CFG_PIPE_1 55c
EMC_CFG_PIPE 560
EMC_QPOP 564
EMC_QUSE_WIDTH 568
EMC_PUTERM_WIDTH 56c
EMC_PROTOBIST_CONFIG_ADR_1 5d0
EMC_PROTOBIST_CONFIG_ADR_2 5d4
EMC_PROTOBIST_MISC 5d8
EMC_PROTOBIST_WDATA_LOWER 5dc
EMC_PROTOBIST_WDATA_UPPER 5e0
EMC_PROTOBIST_RDATA 5ec
EMC_DLL_CFG_0 5e4
EMC_DLL_CFG_1 5e8
EMC_TRAINING_CMD e00
EMC_TRAINING_CTRL e04
EMC_TRAINING_STATUS e08
EMC_TRAINING_QUSE_CORS_CTRL e0c
EMC_TRAINING_QUSE_FINE_CTRL e10
EMC_TRAINING_QUSE_CTRL_MISC e14
EMC_TRAINING_WRITE_FINE_CTRL e18
EMC_TRAINING_WRITE_CTRL_MISC e1c
EMC_TRAINING_WRITE_VREF_CTRL e20
EMC_TRAINING_READ_FINE_CTRL e24
EMC_TRAINING_READ_CTRL_MISC e28
EMC_TRAINING_READ_VREF_CTRL e2c
EMC_TRAINING_CA_FINE_CTRL e30
EMC_TRAINING_CA_CTRL_MISC e34
EMC_TRAINING_CA_CTRL_MISC1 e38
EMC_TRAINING_CA_VREF_CTRL e3c
EMC_TRAINING_CA_TADR_CTRL e40
EMC_TRAINING_SETTLE e44
EMC_TRAINING_DEBUG_CTRL e48
EMC_TRAINING_DEBUG_DQ0 e4c
EMC_TRAINING_DEBUG_DQ1 e50
EMC_TRAINING_DEBUG_DQ2 e54
EMC_TRAINING_DEBUG_DQ3 e58
EMC_TRAINING_MPC e5c
EMC_TRAINING_PATRAM_CTRL e60
EMC_TRAINING_PATRAM_DQ e64
EMC_TRAINING_PATRAM_DMI e68
EMC_TRAINING_VREF_SETTLE e6c
EMC_TRAINING_RW_EYE_CENTER_IB_BYTE0 e70
EMC_TRAINING_RW_EYE_CENTER_IB_BYTE1 e74
EMC_TRAINING_RW_EYE_CENTER_IB_BYTE2 e78
EMC_TRAINING_RW_EYE_CENTER_IB_BYTE3 e7c
EMC_TRAINING_RW_EYE_CENTER_IB_MISC e80
EMC_TRAINING_RW_EYE_CENTER_OB_BYTE0 e84
EMC_TRAINING_RW_EYE_CENTER_OB_BYTE1 e88
EMC_TRAINING_RW_EYE_CENTER_OB_BYTE2 e8c
EMC_TRAINING_RW_EYE_CENTER_OB_BYTE3 e90
EMC_TRAINING_RW_EYE_CENTER_OB_MISC e94
EMC_TRAINING_RW_OFFSET_IB_BYTE0 e98
EMC_TRAINING_RW_OFFSET_IB_BYTE1 e9c
EMC_TRAINING_RW_OFFSET_IB_BYTE2 ea0
EMC_TRAINING_RW_OFFSET_IB_BYTE3 ea4
EMC_TRAINING_RW_OFFSET_IB_MISC ea8
EMC_TRAINING_RW_OFFSET_OB_BYTE0 eac
EMC_TRAINING_RW_OFFSET_OB_BYTE1 eb0
EMC_TRAINING_RW_OFFSET_OB_BYTE2 eb4
EMC_TRAINING_RW_OFFSET_OB_BYTE3 eb8
EMC_TRAINING_RW_OFFSET_OB_MISC ebc
EMC_TRAINING_OPT_CA_VREF ec0
EMC_TRAINING_OPT_DQ_OB_VREF ec4
EMC_TRAINING_OPT_DQ_IB_VREF_RANK0 ec8
EMC_TRAINING_OPT_DQ_IB_VREF_RANK1 ecc
EMC_TRAINING_QUSE_VREF_CTRL ed0
EMC_TRAINING_OPT_DQS_IB_VREF_RANK0 ed4
EMC_TRAINING_OPT_DQS_IB_VREF_RANK1 ed8
EMC_TRAINING_DRAMC_TIMING edc
EMC_PMACRO_QUSE_DDLL_RANK0_0 600
EMC_PMACRO_QUSE_DDLL_RANK0_1 604
EMC_PMACRO_QUSE_DDLL_RANK0_2 608
EMC_PMACRO_QUSE_DDLL_RANK0_3 60c
EMC_PMACRO_QUSE_DDLL_RANK0_4 610
EMC_PMACRO_QUSE_DDLL_RANK0_5 614
EMC_PMACRO_QUSE_DDLL_RANK1_0 620
EMC_PMACRO_QUSE_DDLL_RANK1_1 624
EMC_PMACRO_QUSE_DDLL_RANK1_2 628
EMC_PMACRO_QUSE_DDLL_RANK1_3 62c
EMC_PMACRO_QUSE_DDLL_RANK1_4 630
EMC_PMACRO_QUSE_DDLL_RANK1_5 634
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0 640
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1 644
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2 648
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3 64c
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_4 650
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_5 654
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0 660
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1 664
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2 668
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3 66c
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_4 670
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_5 674
EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_0 680
EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_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EMC_PMACRO_BRICK_MAPPING_0 c80
EMC_PMACRO_BRICK_MAPPING_1 c84
EMC_PMACRO_BRICK_MAPPING_2 c88
EMC_PMACRO_DDLLCAL_CAL ce0
EMC_PMACRO_DDLL_OFFSET ce4
EMC_PMACRO_DDLL_PERIODIC_OFFSET ce8
EMC_PMACRO_BRICK_CTRL_RFU1 330
EMC_PMACRO_BRICK_CTRL_RFU2 334
EMC_PMACRO_CMD_BRICK_CTRL_FDPD 318
EMC_PMACRO_DATA_BRICK_CTRL_FDPD 31c
EMC_PMACRO_TRAINING_CTRL_0 cf8
EMC_PMACRO_TRAINING_CTRL_1 cfc
EMC_PMC_SCRATCH1 440
EMC_PMC_SCRATCH2 444
EMC_PMC_SCRATCH3 448

36
tools/fix_regs.py Normal file
View file

@ -0,0 +1,36 @@
import re
import sys
def parse_defs(fname):
f = open(fname, "r")
lines = f.readlines()
f.close()
res = {}
for l in lines:
p = [str(_.strip()) for _ in l.strip().split(" ", 1)]
res[int(p[1], 16)] = p[0]
return res
mc = parse_defs("mc.def")
emc = parse_defs("emc.def")
f = open(sys.argv[1], "r")
buf = f.read()
f.close()
def fix(m):
what = m.groups()[0]
off = int(m.groups()[1], 16)
if what == "MC":
if off in mc:
return "MC({0})".format(mc[off])
elif what == "EMC":
if off in emc:
return "EMC({0})".format(emc[off])
return "{0}(0x{1:X})".format(what, off)
buf = re.sub(r'([A-Z]+)\(0x([0-9a-fA-F]+)\)', fix, buf)
f = open(sys.argv[2], "w")
f.write(buf)
f.close()

16
tools/lz/Makefile Normal file
View file

@ -0,0 +1,16 @@
NATIVE_CC ?= gcc
ifeq (, $(shell which $(NATIVE_CC) 2>/dev/null))
$(error "Native GCC is missing. Please install it first. If it's path is custom, set it with export NATIVE_CC=<path to native gcc toolchain>")
endif
.PHONY: all clean
all: lz77
@echo > /dev/null
clean:
@rm -f lz77
lz77: lz.c lz77.c
@$(NATIVE_CC) -o $@ lz.c lz77.c

546
tools/lz/lz.c Normal file
View file

@ -0,0 +1,546 @@
//
// Name: lz.c
// Author: Marcus Geelnard
// Description: LZ77 coder/decoder implementation.
// Reentrant: Yes
// $ATH_LICENSE_NULL$
//
// The LZ77 compression scheme is a substitutional compression scheme
// proposed by Abraham Lempel and Jakob Ziv in 1977. It is very simple in
// its design, and uses no fancy bit level compression.
//
// This is my first attempt at an implementation of a LZ77 code/decoder.
//
// The principle of the LZ77 compression algorithm is to store repeated
// occurrences of strings as references to previous occurrences of the same
// string. The point is that the reference consumes less space than the
// string itself, provided that the string is long enough (in this
// implementation, the string has to be at least 4 bytes long, since the
// minimum coded reference is 3 bytes long). Also note that the term
// "string" refers to any kind of byte sequence (it does not have to be
// an ASCII string, for instance).
//
// The coder uses a brute force approach to finding string matches in the
// history buffer (or "sliding window", if you wish), which is very, very
// slow. I recon the complexity is somewhere between O(n^2) and O(n^3),
// depending on the input data.
//
// There is also a faster implementation that uses a large working buffer
// in which a "jump table" is stored, which is used to quickly find
// possible string matches (see the source code for LZ_CompressFast() for
// more information). The faster method is an order of magnitude faster,
// but still quite slow compared to other compression methods.
//
// The upside is that decompression is very fast, and the compression ratio
// is often very good.
//
// The reference to a string is coded as a (length,offset) pair, where the
// length indicates the length of the string, and the offset gives the
// offset from the current data position. To distinguish between string
// references and literal strings (uncompressed bytes), a string reference
// is preceded by a marker byte, which is chosen as the least common byte
// symbol in the input data stream (this marker byte is stored in the
// output stream as the first byte).
//
// Occurrences of the marker byte in the stream are encoded as the marker
// byte followed by a zero byte, which means that occurrences of the marker
// byte have to be coded with two bytes.
//
// The lengths and offsets are coded in a variable length fashion, allowing
// values of any magnitude (up to 4294967295 in this implementation).
//
// With this compression scheme, the worst case compression result is
// (257/256)*insize + 1.
//
//------------------------------------------------------------------------
// Copyright (c) 2003-2006 Marcus Geelnard
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
// Marcus Geelnard
// marcus.geelnard at home.se
//
//
// This file has been altered from the original version.
//
/*************************************************************************
* Constants used for LZ77 coding
*************************************************************************/
/* Maximum offset (can be any size < 2^31). Lower values give faster
compression, while higher values gives better compression. The default
value of 100000 is quite high. Experiment to see what works best for
you. */
#define LZ_MAX_OFFSET 100000
/*************************************************************************
* INTERNAL FUNCTIONS *
*************************************************************************/
/*************************************************************************
* _LZ_StringCompare() - Return maximum length string match.
*************************************************************************/
static unsigned int _LZ_StringCompare( unsigned char * str1,
unsigned char * str2, unsigned int minlen, unsigned int maxlen )
{
unsigned int len;
for( len = minlen; (len < maxlen) && (str1[len] == str2[len]); ++ len );
return len;
}
/*************************************************************************
* _LZ_WriteVarSize() - Write unsigned integer with variable number of
* bytes depending on value.
*************************************************************************/
static int _LZ_WriteVarSize( unsigned int x, unsigned char * buf )
{
unsigned int y;
int num_bytes, i, b;
/* Determine number of bytes needed to store the number x */
y = x >> 3;
for( num_bytes = 5; num_bytes >= 2; -- num_bytes )
{
if( y & 0xfe000000 ) break;
y <<= 7;
}
/* Write all bytes, seven bits in each, with 8:th bit set for all */
/* but the last byte. */
for( i = num_bytes-1; i >= 0; -- i )
{
b = (x >> (i*7)) & 0x0000007f;
if( i > 0 )
{
b |= 0x00000080;
}
*buf ++ = (unsigned char) b;
}
/* Return number of bytes written */
return num_bytes;
}
/*************************************************************************
* _LZ_ReadVarSize() - Read unsigned integer with variable number of
* bytes depending on value.
*************************************************************************/
static int _LZ_ReadVarSize( unsigned int * x, unsigned char * buf )
{
unsigned int y, b, num_bytes;
/* Read complete value (stop when byte contains zero in 8:th bit) */
y = 0;
num_bytes = 0;
do
{
b = (unsigned int) (*buf ++);
y = (y << 7) | (b & 0x0000007f);
++ num_bytes;
}
while( b & 0x00000080 );
/* Store value in x */
*x = y;
/* Return number of bytes read */
return num_bytes;
}
/*************************************************************************
* PUBLIC FUNCTIONS *
*************************************************************************/
/*************************************************************************
* LZ_Compress() - Compress a block of data using an LZ77 coder.
* in - Input (uncompressed) buffer.
* out - Output (compressed) buffer. This buffer must be 0.4% larger
* than the input buffer, plus one byte.
* insize - Number of input bytes.
* The function returns the size of the compressed data.
*************************************************************************/
int LZ_Compress( unsigned char *in, unsigned char *out,
unsigned int insize )
{
unsigned char marker, symbol;
unsigned int inpos, outpos, bytesleft, i;
unsigned int maxoffset, offset, bestoffset;
unsigned int maxlength, length, bestlength;
unsigned int histogram[ 256 ];
unsigned char *ptr1, *ptr2;
/* Do we have anything to compress? */
if( insize < 1 )
{
return 0;
}
/* Create histogram */
for( i = 0; i < 256; ++ i )
{
histogram[ i ] = 0;
}
for( i = 0; i < insize; ++ i )
{
++ histogram[ in[ i ] ];
}
/* Find the least common byte, and use it as the marker symbol */
marker = 0;
for( i = 1; i < 256; ++ i )
{
if( histogram[ i ] < histogram[ marker ] )
{
marker = i;
}
}
/* Remember the marker symbol for the decoder */
out[ 0 ] = marker;
/* Start of compression */
inpos = 0;
outpos = 1;
/* Main compression loop */
bytesleft = insize;
do
{
/* Determine most distant position */
if( inpos > LZ_MAX_OFFSET ) maxoffset = LZ_MAX_OFFSET;
else maxoffset = inpos;
/* Get pointer to current position */
ptr1 = &in[ inpos ];
/* Search history window for maximum length string match */
bestlength = 3;
bestoffset = 0;
for( offset = 3; offset <= maxoffset; ++ offset )
{
/* Get pointer to candidate string */
ptr2 = &ptr1[ -(int)offset ];
/* Quickly determine if this is a candidate (for speed) */
if( (ptr1[ 0 ] == ptr2[ 0 ]) &&
(ptr1[ bestlength ] == ptr2[ bestlength ]) )
{
/* Determine maximum length for this offset */
maxlength = (bytesleft < offset ? bytesleft : offset);
/* Count maximum length match at this offset */
length = _LZ_StringCompare( ptr1, ptr2, 0, maxlength );
/* Better match than any previous match? */
if( length > bestlength )
{
bestlength = length;
bestoffset = offset;
}
}
}
/* Was there a good enough match? */
if( (bestlength >= 8) ||
((bestlength == 4) && (bestoffset <= 0x0000007f)) ||
((bestlength == 5) && (bestoffset <= 0x00003fff)) ||
((bestlength == 6) && (bestoffset <= 0x001fffff)) ||
((bestlength == 7) && (bestoffset <= 0x0fffffff)) )
{
out[ outpos ++ ] = (unsigned char) marker;
outpos += _LZ_WriteVarSize( bestlength, &out[ outpos ] );
outpos += _LZ_WriteVarSize( bestoffset, &out[ outpos ] );
inpos += bestlength;
bytesleft -= bestlength;
}
else
{
/* Output single byte (or two bytes if marker byte) */
symbol = in[ inpos ++ ];
out[ outpos ++ ] = symbol;
if( symbol == marker )
{
out[ outpos ++ ] = 0;
}
-- bytesleft;
}
}
while( bytesleft > 3 );
/* Dump remaining bytes, if any */
while( inpos < insize )
{
if( in[ inpos ] == marker )
{
out[ outpos ++ ] = marker;
out[ outpos ++ ] = 0;
}
else
{
out[ outpos ++ ] = in[ inpos ];
}
++ inpos;
}
return outpos;
}
/*************************************************************************
* LZ_CompressFast() - Compress a block of data using an LZ77 coder.
* in - Input (uncompressed) buffer.
* out - Output (compressed) buffer. This buffer must be 0.4% larger
* than the input buffer, plus one byte.
* insize - Number of input bytes.
* work - Pointer to a temporary buffer (internal working buffer), which
* must be able to hold (insize+65536) unsigned integers.
* The function returns the size of the compressed data.
*************************************************************************/
int LZ_CompressFast( unsigned char *in, unsigned char *out,
unsigned int insize, unsigned int *work )
{
unsigned char marker, symbol;
unsigned int inpos, outpos, bytesleft, i, index, symbols;
unsigned int offset, bestoffset;
unsigned int maxlength, length, bestlength;
unsigned int histogram[ 256 ], *lastindex, *jumptable;
unsigned char *ptr1, *ptr2;
/* Do we have anything to compress? */
if( insize < 1 )
{
return 0;
}
/* Assign arrays to the working area */
lastindex = work;
jumptable = &work[ 65536 ];
/* Build a "jump table". Here is how the jump table works:
jumptable[i] points to the nearest previous occurrence of the same
symbol pair as in[i]:in[i+1], so in[i] == in[jumptable[i]] and
in[i+1] == in[jumptable[i]+1], and so on... Following the jump table
gives a dramatic boost for the string search'n'match loop compared
to doing a brute force search. The jump table is built in O(n) time,
so it is a cheap operation in terms of time, but it is expensice in
terms of memory consumption. */
for( i = 0; i < 65536; ++ i )
{
lastindex[ i ] = 0xffffffff;
}
for( i = 0; i < insize-1; ++ i )
{
symbols = (((unsigned int)in[i]) << 8) | ((unsigned int)in[i+1]);
index = lastindex[ symbols ];
lastindex[ symbols ] = i;
jumptable[ i ] = index;
}
jumptable[ insize-1 ] = 0xffffffff;
/* Create histogram */
for( i = 0; i < 256; ++ i )
{
histogram[ i ] = 0;
}
for( i = 0; i < insize; ++ i )
{
++ histogram[ in[ i ] ];
}
/* Find the least common byte, and use it as the marker symbol */
marker = 0;
for( i = 1; i < 256; ++ i )
{
if( histogram[ i ] < histogram[ marker ] )
{
marker = i;
}
}
/* Remember the marker symbol for the decoder */
out[ 0 ] = marker;
/* Start of compression */
inpos = 0;
outpos = 1;
/* Main compression loop */
bytesleft = insize;
do
{
/* Get pointer to current position */
ptr1 = &in[ inpos ];
/* Search history window for maximum length string match */
bestlength = 3;
bestoffset = 0;
index = jumptable[ inpos ];
while( (index != 0xffffffff) && ((inpos - index) < LZ_MAX_OFFSET) )
{
/* Get pointer to candidate string */
ptr2 = &in[ index ];
/* Quickly determine if this is a candidate (for speed) */
if( ptr2[ bestlength ] == ptr1[ bestlength ] )
{
/* Determine maximum length for this offset */
offset = inpos - index;
maxlength = (bytesleft < offset ? bytesleft : offset);
/* Count maximum length match at this offset */
length = _LZ_StringCompare( ptr1, ptr2, 2, maxlength );
/* Better match than any previous match? */
if( length > bestlength )
{
bestlength = length;
bestoffset = offset;
}
}
/* Get next possible index from jump table */
index = jumptable[ index ];
}
/* Was there a good enough match? */
if( (bestlength >= 8) ||
((bestlength == 4) && (bestoffset <= 0x0000007f)) ||
((bestlength == 5) && (bestoffset <= 0x00003fff)) ||
((bestlength == 6) && (bestoffset <= 0x001fffff)) ||
((bestlength == 7) && (bestoffset <= 0x0fffffff)) )
{
out[ outpos ++ ] = (unsigned char) marker;
outpos += _LZ_WriteVarSize( bestlength, &out[ outpos ] );
outpos += _LZ_WriteVarSize( bestoffset, &out[ outpos ] );
inpos += bestlength;
bytesleft -= bestlength;
}
else
{
/* Output single byte (or two bytes if marker byte) */
symbol = in[ inpos ++ ];
out[ outpos ++ ] = symbol;
if( symbol == marker )
{
out[ outpos ++ ] = 0;
}
-- bytesleft;
}
}
while( bytesleft > 3 );
/* Dump remaining bytes, if any */
while( inpos < insize )
{
if( in[ inpos ] == marker )
{
out[ outpos ++ ] = marker;
out[ outpos ++ ] = 0;
}
else
{
out[ outpos ++ ] = in[ inpos ];
}
++ inpos;
}
return outpos;
}
/*************************************************************************
* LZ_Uncompress() - Uncompress a block of data using an LZ77 decoder.
* in - Input (compressed) buffer.
* out - Output (uncompressed) buffer. This buffer must be large
* enough to hold the uncompressed data.
* insize - Number of input bytes.
*************************************************************************/
int LZ_Uncompress( unsigned char *in, unsigned char *out,
unsigned int insize )
{
unsigned char marker, symbol;
unsigned int i, inpos, outpos, length, offset;
/* Do we have anything to uncompress? */
if( insize < 1 )
{
return 0;
}
/* Get marker symbol from input stream */
marker = in[ 0 ];
inpos = 1;
/* Main decompression loop */
outpos = 0;
do
{
symbol = in[ inpos ++ ];
if( symbol == marker )
{
/* We had a marker byte */
if( in[ inpos ] == 0 )
{
/* It was a single occurrence of the marker byte */
out[ outpos ++ ] = marker;
++ inpos;
}
else
{
/* Extract true length and offset */
inpos += _LZ_ReadVarSize( &length, &in[ inpos ] );
inpos += _LZ_ReadVarSize( &offset, &in[ inpos ] );
/* Copy corresponding data from history window */
for( i = 0; i < length; ++ i )
{
out[ outpos ] = out[ outpos - offset ];
++ outpos;
}
}
}
else
{
/* No marker, plain copy */
out[ outpos ++ ] = symbol;
}
}
while( inpos < insize );
return outpos;
}

61
tools/lz/lz.h Normal file
View file

@ -0,0 +1,61 @@
//
// Name: lz.h
// Author: Marcus Geelnard
// Description: LZ77 coder/decoder interface.
// Reentrant: Yes
// ------------------------------------------------------------------------
// $ATH_LICENSE_NULL$
// Copyright (c) 2003-2006 Marcus Geelnard
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
// Marcus Geelnard
// marcus.geelnard at home.se
//
//
// This file has been altered from the original version.
//
#ifndef _lz_h_
#define _lz_h_
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************
* Function prototypes
*************************************************************************/
int LZ_Compress( unsigned char *in, unsigned char *out,
unsigned int insize );
int LZ_CompressFast( unsigned char *in, unsigned char *out,
unsigned int insize, unsigned int *work );
int LZ_Uncompress( unsigned char *in, unsigned char *out,
unsigned int insize );
#ifdef __cplusplus
}
#endif
#endif /* _lz_h_ */

93
tools/lz/lz77.c Normal file
View file

@ -0,0 +1,93 @@
/*
* Copyright (c) 2019 CTCaer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>
#include "lz.h"
char filename[1024];
int main(int argc, char *argv[])
{
int nbytes;
int filename_len;
struct stat statbuf;
FILE *in_file, *out_file;
if(stat(argv[1], &statbuf))
goto error;
if((in_file=fopen(argv[1], "rb")) == NULL)
goto error;
strcpy(filename, argv[1]);
filename_len = strlen(filename);
uint32_t in_size = statbuf.st_size;
uint8_t *in_buf = (uint8_t *)malloc(in_size);
uint32_t out_size = statbuf.st_size + 257;
uint8_t *out_buf = (uint8_t *)malloc(out_size);
if(!(in_buf && out_buf))
goto error;
if(fread(in_buf, 1, in_size, in_file) != in_size)
goto error;
fclose(in_file);
uint32_t *work = (uint32_t*)malloc(sizeof(uint32_t) * (in_size + 65536));
for (int i = 0; i < 2; i++)
{
uint32_t in_size_tmp;
if (!i)
{
in_size_tmp = in_size / 2;
strcpy(filename + filename_len, ".00.lz");
}
else
{
in_size_tmp = in_size - (in_size / 2);
strcpy(filename + filename_len, ".01.lz");
}
if (work)
nbytes = LZ_CompressFast(in_buf + (in_size / 2) * i, out_buf, in_size_tmp, work);
else
goto error;
if (nbytes > out_size)
goto error;
if((out_file = fopen(filename,"wb")) == NULL)
goto error;
if (fwrite(out_buf, 1, nbytes, out_file) != nbytes)
goto error;
fclose(out_file);
}
return 0;
error:
fprintf(stderr, "Failed to compress: %s\n", argv[1]);
exit(1);
}

448
tools/mc.def Normal file
View file

@ -0,0 +1,448 @@
MC_INTSTATUS 0
MC_INTMASK 4
MC_ERR_STATUS 8
MC_ERR_ADR c
MC_PCFIFO_CLIENT_CONFIG0 dd0
MC_PCFIFO_CLIENT_CONFIG1 dd4
MC_PCFIFO_CLIENT_CONFIG2 dd8
MC_PCFIFO_CLIENT_CONFIG3 ddc
MC_PCFIFO_CLIENT_CONFIG4 de0
MC_EMEM_CFG 50
MC_EMEM_ADR_CFG 54
MC_EMEM_ADR_CFG_DEV0 58
MC_EMEM_ADR_CFG_DEV1 5c
MC_EMEM_ADR_CFG_CHANNEL_MASK 60
MC_EMEM_ADR_CFG_BANK_MASK_0 64
MC_EMEM_ADR_CFG_BANK_MASK_1 68
MC_EMEM_ADR_CFG_BANK_MASK_2 6c
MC_SECURITY_CFG0 70
MC_SECURITY_CFG1 74
MC_SECURITY_CFG3 9bc
MC_SECURITY_RSV 7c
MC_EMEM_ARB_CFG 90
MC_EMEM_ARB_OUTSTANDING_REQ 94
MC_EMEM_ARB_TIMING_RCD 98
MC_EMEM_ARB_TIMING_RP 9c
MC_EMEM_ARB_TIMING_RC a0
MC_EMEM_ARB_TIMING_RAS a4
MC_EMEM_ARB_TIMING_FAW a8
MC_EMEM_ARB_TIMING_RRD ac
MC_EMEM_ARB_TIMING_RAP2PRE b0
MC_EMEM_ARB_TIMING_WAP2PRE b4
MC_EMEM_ARB_TIMING_R2R b8
MC_EMEM_ARB_TIMING_W2W bc
MC_EMEM_ARB_TIMING_R2W c0
MC_EMEM_ARB_TIMING_W2R c4
MC_EMEM_ARB_TIMING_RFCPB 6c0
MC_EMEM_ARB_TIMING_CCDMW 6c4
MC_EMEM_ARB_REFPB_HP_CTRL 6f0
MC_EMEM_ARB_REFPB_BANK_CTRL 6f4
MC_EMEM_ARB_DA_TURNS d0
MC_EMEM_ARB_DA_COVERS d4
MC_EMEM_ARB_MISC0 d8
MC_EMEM_ARB_MISC1 dc
MC_EMEM_ARB_MISC2 c8
MC_EMEM_ARB_RING1_THROTTLE e0
MC_EMEM_ARB_RING3_THROTTLE e4
MC_EMEM_ARB_NISO_THROTTLE 6b0
MC_EMEM_ARB_OVERRIDE e8
MC_EMEM_ARB_RSV ec
MC_CLKEN_OVERRIDE f4
MC_TIMING_CONTROL_DBG f8
MC_TIMING_CONTROL fc
MC_STAT_CONTROL 100
MC_STAT_STATUS 104
MC_STAT_EMC_CLOCK_LIMIT 108
MC_STAT_EMC_CLOCK_LIMIT_MSBS 10c
MC_STAT_EMC_CLOCKS 110
MC_STAT_EMC_CLOCKS_MSBS 114
MC_STAT_EMC_FILTER_SET0_ADR_LIMIT_LO 118
MC_STAT_EMC_FILTER_SET1_ADR_LIMIT_LO 158
MC_STAT_EMC_FILTER_SET0_ADR_LIMIT_HI 11c
MC_STAT_EMC_FILTER_SET1_ADR_LIMIT_HI 15c
MC_STAT_EMC_FILTER_SET0_ADR_LIMIT_UPPER a20
MC_STAT_EMC_FILTER_SET1_ADR_LIMIT_UPPER a24
MC_STAT_EMC_FILTER_SET0_VIRTUAL_ADR_LIMIT_LO 198
MC_STAT_EMC_FILTER_SET1_VIRTUAL_ADR_LIMIT_LO 1a8
MC_STAT_EMC_FILTER_SET0_VIRTUAL_ADR_LIMIT_HI 19c
MC_STAT_EMC_FILTER_SET1_VIRTUAL_ADR_LIMIT_HI 1ac
MC_STAT_EMC_FILTER_SET0_VIRTUAL_ADR_LIMIT_UPPER a28
MC_STAT_EMC_FILTER_SET1_VIRTUAL_ADR_LIMIT_UPPER a2c
MC_STAT_EMC_FILTER_SET0_ASID 1a0
MC_STAT_EMC_FILTER_SET1_ASID 1b0
MC_STAT_EMC_FILTER_SET0_SLACK_LIMIT 120
MC_STAT_EMC_FILTER_SET1_SLACK_LIMIT 160
MC_STAT_EMC_FILTER_SET0_CLIENT_0 128
MC_STAT_EMC_FILTER_SET1_CLIENT_0 168
MC_STAT_EMC_FILTER_SET0_CLIENT_1 12c
MC_STAT_EMC_FILTER_SET1_CLIENT_1 16c
MC_STAT_EMC_FILTER_SET0_CLIENT_2 130
MC_STAT_EMC_FILTER_SET1_CLIENT_2 170
MC_STAT_EMC_FILTER_SET0_CLIENT_3 134
MC_STAT_EMC_FILTER_SET0_CLIENT_4 b88
MC_STAT_EMC_FILTER_SET1_CLIENT_3 174
MC_STAT_EMC_FILTER_SET1_CLIENT_4 b8c
MC_STAT_EMC_SET0_COUNT 138
MC_STAT_EMC_SET0_COUNT_MSBS 13c
MC_STAT_EMC_SET1_COUNT 178
MC_STAT_EMC_SET1_COUNT_MSBS 17c
MC_STAT_EMC_SET0_SLACK_ACCUM 140
MC_STAT_EMC_SET0_SLACK_ACCUM_MSBS 144
MC_STAT_EMC_SET1_SLACK_ACCUM 180
MC_STAT_EMC_SET1_SLACK_ACCUM_MSBS 184
MC_STAT_EMC_SET0_HISTO_COUNT 148
MC_STAT_EMC_SET0_HISTO_COUNT_MSBS 14c
MC_STAT_EMC_SET1_HISTO_COUNT 188
MC_STAT_EMC_SET1_HISTO_COUNT_MSBS 18c
MC_STAT_EMC_SET0_MINIMUM_SLACK_OBSERVED 150
MC_STAT_EMC_SET1_MINIMUM_SLACK_OBSERVED 190
MC_STAT_EMC_SET0_IDLE_CYCLE_COUNT 1b8
MC_STAT_EMC_SET0_IDLE_CYCL_COUNT_MSBS 1bc
MC_STAT_EMC_SET1_IDLE_CYCLE_COUNT 1c8
MC_STAT_EMC_SET1_IDLE_CYCL_COUNT_MSBS 1cc
MC_STAT_EMC_SET0_IDLE_CYCLE_PARTITION_SELECT 1c0
MC_STAT_EMC_SET1_IDLE_CYCLE_PARTITION_SELECT 1d0
MC_CLIENT_HOTRESET_CTRL 200
MC_CLIENT_HOTRESET_CTRL_1 970
MC_CLIENT_HOTRESET_STATUS 204
MC_CLIENT_HOTRESET_STATUS_1 974
MC_EMEM_ARB_ISOCHRONOUS_0 208
MC_EMEM_ARB_ISOCHRONOUS_1 20c
MC_EMEM_ARB_ISOCHRONOUS_2 210
MC_EMEM_ARB_ISOCHRONOUS_3 214
MC_EMEM_ARB_ISOCHRONOUS_4 b94
MC_EMEM_ARB_HYSTERESIS_0 218
MC_EMEM_ARB_HYSTERESIS_1 21c
MC_EMEM_ARB_HYSTERESIS_2 220
MC_EMEM_ARB_HYSTERESIS_3 224
MC_EMEM_ARB_HYSTERESIS_4 b84
MC_EMEM_ARB_DHYSTERESIS_0 bb0
MC_EMEM_ARB_DHYSTERESIS_1 bb4
MC_EMEM_ARB_DHYSTERESIS_2 bb8
MC_EMEM_ARB_DHYSTERESIS_3 bbc
MC_EMEM_ARB_DHYSTERESIS_4 bc0
MC_EMEM_ARB_DHYST_CTRL bcc
MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_0 bd0
MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_1 bd4
MC_EMEM_ARB_DHYST_TIMEOUT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ROTECT_VPR_OVERRIDE 418
MC_VIDEO_PROTECT_VPR_OVERRIDE1 590
MC_IRAM_BOM 65c
MC_IRAM_TOM 660
MC_IRAM_ADR_HI 980
MC_IRAM_REG_CTRL 964
MC_EMEM_CFG_ACCESS_CTRL 664
MC_TZ_SECURITY_CTRL 668
MC_EMEM_ARB_OUTSTANDING_REQ_RING3 66c
MC_EMEM_ARB_OUTSTANDING_REQ_NISO 6b4
MC_EMEM_ARB_RING0_THROTTLE_MASK 6bc
MC_EMEM_ARB_NISO_THROTTLE_MASK 6b8
MC_EMEM_ARB_NISO_THROTTLE_MASK_1 b80
MC_SEC_CARVEOUT_BOM 670
MC_SEC_CARVEOUT_SIZE_MB 674
MC_SEC_CARVEOUT_ADR_HI 9d4
MC_SEC_CARVEOUT_REG_CTRL 678
MC_ERR_SEC_STATUS 67c
MC_ERR_SEC_ADR 680
MC_PC_IDLE_CLOCK_GATE_CONFIG 684
MC_STUTTER_CONTROL 688
MC_RESERVED_RSV_1 958
MC_DVFS_PIPE_SELECT 95c
MC_AHB_PTSA_MIN 4e0
MC_AUD_PTSA_MIN 54c
MC_MLL_MPCORER_PTSA_RATE 44c
MC_RING2_PTSA_RATE 440
MC_USBD_PTSA_RATE 530
MC_USBX_PTSA_MIN 528
MC_USBD_PTSA_MIN 534
MC_APB_PTSA_MAX 4f0
MC_JPG_PTSA_RATE 584
MC_DIS_PTSA_MIN 420
MC_AVP_PTSA_MAX 4fc
MC_AVP_PTSA_RATE 4f4
MC_RING1_PTSA_MIN 480
MC_DIS_PTSA_MAX 424
MC_SD_PTSA_MAX 4d8
MC_MSE_PTSA_RATE 4c4
MC_VICPC_PTSA_MIN 558
MC_PCX_PTSA_MAX 4b4
MC_ISP_PTSA_RATE 4a0
MC_A9AVPPC_PTSA_MIN 48c
MC_RING2_PTSA_MAX 448
MC_AUD_PTSA_RATE 548
MC_HOST_PTSA_MIN 51c
MC_MLL_MPCORER_PTSA_MAX 454
MC_SD_PTSA_MIN 4d4
MC_RING1_PTSA_RATE 47c
MC_JPG_PTSA_MIN 588
MC_HDAPC_PTSA_MIN 62c
MC_AVP_PTSA_MIN 4f8
MC_JPG_PTSA_MAX 58c
MC_VE_PTSA_MAX 43c
MC_DFD_PTSA_MAX 63c
MC_VICPC_PTSA_RATE 554
MC_GK_PTSA_MAX 544
MC_VICPC_PTSA_MAX 55c
MC_SDM_PTSA_MAX 624
MC_SAX_PTSA_RATE 4b8
MC_PCX_PTSA_MIN 4b0
MC_APB_PTSA_MIN 4ec
MC_GK2_PTSA_MIN 614
MC_PCX_PTSA_RATE 4ac
MC_RING1_PTSA_MAX 484
MC_HDAPC_PTSA_RATE 628
MC_MLL_MPCORER_PTSA_MIN 450
MC_GK2_PTSA_MAX 618
MC_AUD_PTSA_MAX 550
MC_GK2_PTSA_RATE 610
MC_ISP_PTSA_MAX 4a8
MC_DISB_PTSA_RATE 428
MC_VE2_PTSA_MAX 49c
MC_DFD_PTSA_MIN 638
MC_FTOP_PTSA_RATE 50c
MC_A9AVPPC_PTSA_RATE 488
MC_VE2_PTSA_MIN 498
MC_USBX_PTSA_MAX 52c
MC_DIS_PTSA_RATE 41c
MC_USBD_PTSA_MAX 538
MC_A9AVPPC_PTSA_MAX 490
MC_USBX_PTSA_RATE 524
MC_FTOP_PTSA_MAX 514
MC_HDAPC_PTSA_MAX 630
MC_SD_PTSA_RATE 4d0
MC_DFD_PTSA_RATE 634
MC_FTOP_PTSA_MIN 510
MC_SDM_PTSA_RATE 61c
MC_AHB_PTSA_RATE 4dc
MC_SMMU_SMMU_PTSA_MAX 460
MC_RING2_PTSA_MIN 444
MC_SDM_PTSA_MIN 620
MC_APB_PTSA_RATE 4e8
MC_MSE_PTSA_MIN 4c8
MC_HOST_PTSA_RATE 518
MC_VE_PTSA_RATE 434
MC_AHB_PTSA_MAX 4e4
MC_SAX_PTSA_MIN 4bc
MC_SMMU_SMMU_PTSA_MIN 45c
MC_ISP_PTSA_MIN 4a4
MC_HOST_PTSA_MAX 520
MC_SAX_PTSA_MAX 4c0
MC_VE_PTSA_MIN 438
MC_GK_PTSA_MIN 540
MC_MSE_PTSA_MAX 4cc
MC_DISB_PTSA_MAX 430
MC_DISB_PTSA_MIN 42c
MC_SMMU_SMMU_PTSA_RATE 458
MC_VE2_PTSA_RATE 494
MC_GK_PTSA_RATE 53c
MC_PTSA_GRANT_DECREMENT 960
MC_LATENCY_ALLOWANCE_AVPC_0 2e4
MC_LATENCY_ALLOWANCE_AXIAP_0 3a0
MC_LATENCY_ALLOWANCE_XUSB_1 380
MC_LATENCY_ALLOWANCE_ISP2B_0 384
MC_LATENCY_ALLOWANCE_SDMMCAA_0 3bc
MC_LATENCY_ALLOWANCE_SDMMCA_0 3b8
MC_LATENCY_ALLOWANCE_ISP2_0 370
MC_LATENCY_ALLOWANCE_SE_0 3e0
MC_LATENCY_ALLOWANCE_ISP2_1 374
MC_LATENCY_ALLOWANCE_DC_0 2e8
MC_LATENCY_ALLOWANCE_VIC_0 394
MC_LATENCY_ALLOWANCE_DCB_1 2f8
MC_LATENCY_ALLOWANCE_NVDEC_0 3d8
MC_LATENCY_ALLOWANCE_DCB_2 2fc
MC_LATENCY_ALLOWANCE_TSEC_0 390
MC_LATENCY_ALLOWANCE_DC_2 2f0
MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0AB 694
MC_LATENCY_ALLOWANCE_PPCS_1 348
MC_LATENCY_ALLOWANCE_XUSB_0 37c
MC_LATENCY_ALLOWANCE_PPCS_0 344
MC_LATENCY_ALLOWANCE_TSECB_0 3f0
MC_LATENCY_ALLOWANCE_AFI_0 2e0
MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0B 698
MC_LATENCY_ALLOWANCE_DC_1 2ec
MC_LATENCY_ALLOWANCE_APE_0 3dc
MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0C 6a0
MC_LATENCY_ALLOWANCE_A9AVP_0 3a4
MC_LATENCY_ALLOWANCE_GPU2_0 3e8
MC_LATENCY_ALLOWANCE_DCB_0 2f4
MC_LATENCY_ALLOWANCE_HC_1 314
MC_LATENCY_ALLOWANCE_SDMMC_0 3c0
MC_LATENCY_ALLOWANCE_NVJPG_0 3e4
MC_LATENCY_ALLOWANCE_PTC_0 34c
MC_LATENCY_ALLOWANCE_ETR_0 3ec
MC_LATENCY_ALLOWANCE_MPCORE_0 320
MC_LATENCY_ALLOWANCE_VI2_0 398
MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0BB 69c
MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0CB 6a4
MC_LATENCY_ALLOWANCE_SATA_0 350
MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0A 690
MC_LATENCY_ALLOWANCE_HC_0 310
MC_LATENCY_ALLOWANCE_DC_3 3c8
MC_LATENCY_ALLOWANCE_GPU_0 3ac
MC_LATENCY_ALLOWANCE_SDMMCAB_0 3c4
MC_LATENCY_ALLOWANCE_ISP2B_1 388
MC_LATENCY_ALLOWANCE_NVENC_0 328
MC_LATENCY_ALLOWANCE_HDA_0 318
MC_MIN_LENGTH_APE_0 b34
MC_MIN_LENGTH_DCB_2 8a8
MC_MIN_LENGTH_A9AVP_0 950
MC_MIN_LENGTH_TSEC_0 93c
MC_MIN_LENGTH_DC_1 898
MC_MIN_LENGTH_AXIAP_0 94c
MC_MIN_LENGTH_ISP2B_0 930
MC_MIN_LENGTH_VI2_0 944
MC_MIN_LENGTH_DCB_0 8a0
MC_MIN_LENGTH_DCB_1 8a4
MC_MIN_LENGTH_PPCS_1 8f4
MC_MIN_LENGTH_NVJPG_0 b3c
MC_MIN_LENGTH_HDA_0 8c4
MC_MIN_LENGTH_NVENC_0 8d4
MC_MIN_LENGTH_SDMMC_0 b18
MC_MIN_LENGTH_ISP2B_1 934
MC_MIN_LENGTH_HC_1 8c0
MC_MIN_LENGTH_DC_3 b20
MC_MIN_LENGTH_AVPC_0 890
MC_MIN_LENGTH_VIC_0 940
MC_MIN_LENGTH_ISP2_0 91c
MC_MIN_LENGTH_HC_0 8bc
MC_MIN_LENGTH_SE_0 b38
MC_MIN_LENGTH_NVDEC_0 b30
MC_MIN_LENGTH_SATA_0 8fc
MC_MIN_LENGTH_DC_0 894
MC_MIN_LENGTH_XUSB_1 92c
MC_MIN_LENGTH_DC_2 89c
MC_MIN_LENGTH_SDMMCAA_0 b14
MC_MIN_LENGTH_GPU_0 b04
MC_MIN_LENGTH_ETR_0 b44
MC_MIN_LENGTH_AFI_0 88c
MC_MIN_LENGTH_PPCS_0 8f0
MC_MIN_LENGTH_ISP2_1 920
MC_MIN_LENGTH_XUSB_0 928
MC_MIN_LENGTH_MPCORE_0 8cc
MC_MIN_LENGTH_TSECB_0 b48
MC_MIN_LENGTH_SDMMCA_0 b10
MC_MIN_LENGTH_GPU2_0 b40
MC_MIN_LENGTH_SDMMCAB_0 b1c
MC_MIN_LENGTH_PTC_0 8f8
MC_EMEM_ARB_OVERRIDE_1 968
MC_VIDEO_PROTECT_GPU_OVERRIDE_0 984
MC_VIDEO_PROTECT_GPU_OVERRIDE_1 988
MC_EMEM_ARB_STATS_0 990
MC_EMEM_ARB_STATS_1 994
MC_MTS_CARVEOUT_BOM 9a0
MC_MTS_CARVEOUT_SIZE_MB 9a4
MC_MTS_CARVEOUT_ADR_HI 9a8
MC_MTS_CARVEOUT_REG_CTRL 9ac
MC_ERR_MTS_STATUS 9b0
MC_ERR_MTS_ADR 9b4
MC_ERR_GENERALIZED_CARVEOUT_STATUS c00
MC_ERR_GENERALIZED_CARVEOUT_ADR c04
MC_SECURITY_CARVEOUT5_CLIENT_FORCE_INTERNAL_ACCESS2 d74
MC_SECURITY_CARVEOUT4_CFG0 cf8
MC_SECURITY_CARVEOUT4_CLIENT_ACCESS2 d10
MC_SECURITY_CARVEOUT4_SIZE_128KB d04
MC_SECURITY_CARVEOUT1_CLIENT_ACCESS4 c28
MC_SECURITY_CARVEOUT1_CLIENT_FORCE_INTERNAL_ACCESS1 c30
MC_SECURITY_CARVEOUT2_CLIENT_FORCE_INTERNAL_ACCESS4 c8c
MC_SECURITY_CARVEOUT4_CLIENT_FORCE_INTERNAL_ACCESS0 d1c
MC_SECURITY_CARVEOUT5_CLIENT_FORCE_INTERNAL_ACCESS1 d70
MC_SECURITY_CARVEOUT1_CLIENT_FORCE_INTERNAL_ACCESS0 c2c
MC_SECURITY_CARVEOUT5_CLIENT_FORCE_INTERNAL_ACCESS4 d7c
MC_SECURITY_CARVEOUT3_SIZE_128KB cb4
MC_SECURITY_CARVEOUT2_CFG0 c58
MC_SECURITY_CARVEOUT1_CFG0 c08
MC_SECURITY_CARVEOUT2_CLIENT_FORCE_INTERNAL_ACCESS2 c84
MC_SECURITY_CARVEOUT2_CLIENT_ACCESS0 c68
MC_SECURITY_CARVEOUT3_BOM cac
MC_SECURITY_CARVEOUT2_CLIENT_ACCESS2 c70
MC_SECURITY_CARVEOUT5_CLIENT_FORCE_INTERNAL_ACCESS3 d78
MC_SECURITY_CARVEOUT2_CLIENT_FORCE_INTERNAL_ACCESS0 c7c
MC_SECURITY_CARVEOUT4_CLIENT_ACCESS4 d18
MC_SECURITY_CARVEOUT3_CLIENT_ACCESS1 cbc
MC_SECURITY_CARVEOUT1_CLIENT_FORCE_INTERNAL_ACCESS3 c38
MC_SECURITY_CARVEOUT1_CLIENT_FORCE_INTERNAL_ACCESS2 c34
MC_SECURITY_CARVEOUT3_CLIENT_ACCESS2 cc0
MC_SECURITY_CARVEOUT5_CLIENT_ACCESS2 d60
MC_SECURITY_CARVEOUT3_CFG0 ca8
MC_SECURITY_CARVEOUT3_CLIENT_ACCESS0 cb8
MC_SECURITY_CARVEOUT2_CLIENT_FORCE_INTERNAL_ACCESS3 c88
MC_SECURITY_CARVEOUT2_SIZE_128KB c64
MC_SECURITY_CARVEOUT5_BOM_HI d50
MC_SECURITY_CARVEOUT1_SIZE_128KB c14
MC_SECURITY_CARVEOUT4_CLIENT_ACCESS3 d14
MC_SECURITY_CARVEOUT1_BOM c0c
MC_SECURITY_CARVEOUT4_CLIENT_FORCE_INTERNAL_ACCESS4 d2c
MC_SECURITY_CARVEOUT5_CLIENT_ACCESS4 d68
MC_SECURITY_CARVEOUT3_CLIENT_ACCESS4 cc8
MC_SECURITY_CARVEOUT5_CLIENT_ACCESS0 d58
MC_SECURITY_CARVEOUT4_CLIENT_FORCE_INTERNAL_ACCESS2 d24
MC_SECURITY_CARVEOUT3_CLIENT_ACCESS3 cc4
MC_SECURITY_CARVEOUT2_CLIENT_ACCESS4 c78
MC_SECURITY_CARVEOUT1_CLIENT_ACCESS1 c1c
MC_SECURITY_CARVEOUT1_CLIENT_ACCESS0 c18
MC_SECURITY_CARVEOUT4_CLIENT_FORCE_INTERNAL_ACCESS3 d28
MC_SECURITY_CARVEOUT5_CLIENT_ACCESS1 d5c
MC_SECURITY_CARVEOUT3_BOM_HI cb0
MC_SECURITY_CARVEOUT3_CLIENT_FORCE_INTERNAL_ACCESS3 cd8
MC_SECURITY_CARVEOUT2_BOM_HI c60
MC_SECURITY_CARVEOUT4_BOM_HI d00
MC_SECURITY_CARVEOUT5_CLIENT_ACCESS3 d64
MC_SECURITY_CARVEOUT3_CLIENT_FORCE_INTERNAL_ACCESS4 cdc
MC_SECURITY_CARVEOUT2_CLIENT_FORCE_INTERNAL_ACCESS1 c80
MC_SECURITY_CARVEOUT5_SIZE_128KB d54
MC_SECURITY_CARVEOUT4_CLIENT_FORCE_INTERNAL_ACCESS1 d20
MC_SECURITY_CARVEOUT3_CLIENT_FORCE_INTERNAL_ACCESS2 cd4
MC_SECURITY_CARVEOUT4_CLIENT_ACCESS1 d0c
MC_SECURITY_CARVEOUT2_CLIENT_ACCESS3 c74
MC_SECURITY_CARVEOUT3_CLIENT_FORCE_INTERNAL_ACCESS0 ccc
MC_SECURITY_CARVEOUT4_BOM cfc
MC_SECURITY_CARVEOUT5_CFG0 d48
MC_SECURITY_CARVEOUT2_BOM c5c
MC_SECURITY_CARVEOUT5_BOM d4c
MC_SECURITY_CARVEOUT1_CLIENT_ACCESS3 c24
MC_SECURITY_CARVEOUT5_CLIENT_FORCE_INTERNAL_ACCESS0 d6c
MC_SECURITY_CARVEOUT3_CLIENT_FORCE_INTERNAL_ACCESS1 cd0
MC_SECURITY_CARVEOUT1_BOM_HI c10
MC_SECURITY_CARVEOUT1_CLIENT_ACCESS2 c20
MC_SECURITY_CARVEOUT1_CLIENT_FORCE_INTERNAL_ACCESS4 c3c
MC_SECURITY_CARVEOUT2_CLIENT_ACCESS1 c6c
MC_SECURITY_CARVEOUT4_CLIENT_ACCESS0 d08
MC_ERR_APB_ASID_UPDATE_STATUS 9d0
MC_DA_CONFIG0 9dc

38
tools/smmu_payload.py Normal file
View file

@ -0,0 +1,38 @@
'''
Copyright (c) 2018 balika011
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
from keystone import *
CODE = b'''
LDR X1, =0x70019010
MOV X0, #0x1
STR W0, [X1]
loop:
IC IALLUIS
DSB ISH
B loop
MOV X0, #0x0
STR W0, [X1]
LDR X0, =0x4002B000
BR X0
'''
try:
ks = Ks(KS_ARCH_ARM64, KS_MODE_LITTLE_ENDIAN)
encoding, count = ks.asm(CODE, 0x0)
print("%s = %s (number of statements: %u)" %(CODE, ', '.join([('0x%02x' % (x)) for x in encoding]), count))
except KsError as e:
print("ERROR: %s" %e)