Skip to content

Commit

Permalink
rxtools: Merge reboot.S to firm.c
Browse files Browse the repository at this point in the history
  • Loading branch information
173210 committed Feb 27, 2016
1 parent bfb558d commit a0e56f3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 67 deletions.
3 changes: 1 addition & 2 deletions rxtools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ CCOBJS := $(addprefix $(BUILD)/,main.o features/CTRDecryptor.o \
lib/media/nand.o lib/media/tmio/tmio.o \
lib/polarssl/padlock.o lib/polarssl/sha2.o lib/polarssl/aes.o \
lib/ui/console.o lib/ui/draw.o lib/cfg.o lib/crypto.o lib/fs.o lib/hid.o \
lib/lang.o lib/log.o lib/i2c.o lib/jsmn/jsmn.o lib/menu.o lib/ncch.o \
features/reboot.o)
lib/lang.o lib/log.o lib/i2c.o lib/jsmn/jsmn.o lib/menu.o lib/ncch.o)

OBJS := $(CCOBJS) $(addprefix $(BUILD)/, start.o font_ascii.o lib/delay.o)
DEPS := $(subst $(BUILD)/,$(DEPS_DIR)/,$(CCOBJS))
Expand Down
40 changes: 34 additions & 6 deletions rxtools/source/features/firm.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 The PASTA Team
* Copyright (C) 2015-2016 The PASTA Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -44,8 +44,6 @@ const wchar_t firmPatchPathFmt[] = _T("") FIRM_PATCH_PATH_FMT;
unsigned int emuNandMounted = 0;
_Noreturn void (* const _softreset)() = (void *)0x080F0000;

_Noreturn void execReboot(uint32_t, void *, uintptr_t, const Elf32_Shdr *);

static FRESULT loadExecReboot()
{
FIL fd;
Expand Down Expand Up @@ -165,14 +163,16 @@ static void setAgbBios()

int rxMode(int emu)
{
const Elf32_Addr line = 32;
wchar_t path[64];
const char *shstrtab;
const wchar_t *msg;
uint8_t keyx[16];
uint32_t tid;
int r, sector;
Elf32_Ehdr *ehdr;
Elf32_Shdr *shdr, *btm;
Elf32_Shdr *shdr, *btmShdr;
Elf32_Addr cur, btm;
void *keyxArg;
FIL fd;
UINT br, fsz;
Expand Down Expand Up @@ -245,9 +245,37 @@ int rxMode(int emu)
ehdr = (void *)PATCH_ADDR;
shdr = (void *)(PATCH_ADDR + ehdr->e_shoff);
shstrtab = (char *)PATCH_ADDR + shdr[ehdr->e_shstrndx].sh_offset;
for (btm = shdr + ehdr->e_shnum; shdr != btm; shdr++) {
for (btmShdr = shdr + ehdr->e_shnum; shdr != btmShdr; shdr++) {
if (!strcmp(shstrtab + shdr->sh_name, ".patch.p9.reboot.body")) {
execReboot(sector, keyxArg, ehdr->e_entry, shdr);
/* Set MPU area 2.
address: 0x0800000, size: 2^0x28 = 2M, enable */
__asm__ volatile ("mcr p15, 0, %0, c6, c2, 0"
:: "r"(0x08000029));

memcpy((void *)ehdr->e_entry,
(void *)(PATCH_ADDR + shdr->sh_offset),
shdr->sh_size);

// Drain write buffer
__asm__ volatile ("mcr p15, 0, %0, c7, c10, 4" :: "r"(0));

cur = ehdr->e_entry & ~(line - 1);
btm = ehdr->e_entry + shdr->sh_size;
while (cur < btm) {
__asm__ volatile (
// Clean Dcache
"mcr p15, 0, %0, c7, c10, 1\n\t"

// Flush Icache
"mcr p15, 0, %0, c7, c5, 1"
:: "r"(cur));

cur += line;
}

((void (*)(uint32_t, void *, uintptr_t))ehdr->e_entry)(
sector, keyxArg, 0x1FFFFFF8);

__builtin_unreachable();
}
}
Expand Down
59 changes: 0 additions & 59 deletions rxtools/source/features/reboot.S

This file was deleted.

1 comment on commit a0e56f3

@MelonGx
Copy link

@MelonGx MelonGx commented on a0e56f3 Mar 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[For people who still want Tool-enhanced rxTools]
This, Feb.27 (a0e56f3), is the FINAL version enhancing legacy tools.
However, Generate FAT16 XORPAD function is still broken.
For people want rxTools generating FAT16 XORPAD, please build Dec.05 (a08cfdd), or mod it to this version yourself.

Please sign in to comment.