mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
(NGC) Remove sidestep code
This commit is contained in:
parent
236cae258d
commit
f0770eec48
@ -53,7 +53,7 @@ CFLAGS += -DHAVE_FILE_LOGGER
|
||||
CFLAGS += -Iconsole/logger
|
||||
endif
|
||||
|
||||
CFLAGS += -std=gnu99 -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_RMENU -DHAVE_RGUI -DHAVE_THREAD -DRARCH_CONSOLE -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RARCH_EXEC -DGEKKO -DHAVE_ZLIB -DWANT_RZLIB -DHAVE_RARCH_MAIN_WRAP -DHAVE_GRIFFIN=1 -DHAVE_SCREENSHOTS -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -Wno-char-subscripts
|
||||
CFLAGS += -std=gnu99 -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_RMENU -DHAVE_RGUI -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_THREAD -DRARCH_CONSOLE -DGEKKO -DHAVE_ZLIB -DWANT_RZLIB -DHAVE_RARCH_MAIN_WRAP -DHAVE_GRIFFIN=1 -DHAVE_SCREENSHOTS -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -Wno-char-subscripts
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -g
|
||||
|
@ -1,83 +0,0 @@
|
||||
|
||||
##
|
||||
# Makefile for RetroArch GameCube.
|
||||
##
|
||||
|
||||
DEBUG = 0
|
||||
HAVE_LOGGER = 0
|
||||
HAVE_FILE_LOGGER = 0
|
||||
|
||||
# system platform
|
||||
system_platform = unix
|
||||
ifeq ($(shell uname -a),)
|
||||
EXE_EXT = .exe
|
||||
system_platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
system_platform = osx
|
||||
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
system_platform = win
|
||||
endif
|
||||
|
||||
PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7"
|
||||
PC_DEVELOPMENT_UDP_PORT = 3490
|
||||
|
||||
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
|
||||
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
|
||||
LD = $(DEVKITPPC)/bin/powerpc-eabi-ld$(EXE_EXT)
|
||||
ELF2DOL = $(DEVKITPPC)/bin/elf2dol$(EXE_EXT)
|
||||
|
||||
DOL_TARGET := retroarch-salamander_ngc.dol
|
||||
ELF_TARGET := retroarch-salamander_ngc.elf
|
||||
|
||||
INCLUDE := -I. -I$(DEVKITPRO)/libogc/include
|
||||
LIBDIRS := -L$(DEVKITPRO)/libogc/lib/cube -L.
|
||||
|
||||
MACHDEP := -DGEKKO -DHW_DOL -mogc -mcpu=750 -meabi -mhard-float
|
||||
CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE)
|
||||
LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map
|
||||
LIBS := -lfat -logc
|
||||
|
||||
OBJ = frontend/frontend_console.o file_path.o compat/compat.o conf/config_file.o ngc/ssaram.o ngc/sidestep.o
|
||||
|
||||
ifeq ($(HAVE_LOGGER), 1)
|
||||
CFLAGS += -DHAVE_LOGGER
|
||||
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
|
||||
CFLAGS += -Iconsole/logger
|
||||
OBJ += console/logger/logger.o
|
||||
LIBS += -lbba
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_FILE_LOGGER), 1)
|
||||
CFLAGS += -DHAVE_FILE_LOGGER
|
||||
CFLAGS += -Iconsole/logger
|
||||
endif
|
||||
|
||||
CFLAGS += -std=gnu99 -DHAVE_DEFAULT_RETROPAD_INPUT -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_RARCH_EXEC -DGEKKO -DPACKAGE_VERSION=\"0.9.8\" -Wno-char-subscripts
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -g
|
||||
else
|
||||
CFLAGS += -O3
|
||||
endif
|
||||
|
||||
all: $(DOL_TARGET)
|
||||
|
||||
%.dol: %.elf
|
||||
$(ELF2DOL) $< $@
|
||||
|
||||
$(ELF_TARGET): $(OBJ)
|
||||
$(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(LIBS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
pkg: all
|
||||
cp -r $(DOL_TARGET) ngc/pkg/boot.dol
|
||||
|
||||
clean:
|
||||
rm -f $(DOL_TARGET)
|
||||
rm -f $(ELF_TARGET)
|
||||
rm -f $(OBJ)
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -37,7 +37,6 @@ CONSOLE EXTENSIONS
|
||||
|
||||
#ifdef HW_DOL
|
||||
#include "../../ngc/ssaram.c"
|
||||
#include "../../ngc/sidestep.c"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DEFAULT_RETROPAD_INPUT
|
||||
|
@ -1,11 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
make -C ../ -f Makefile.ngc.salamander clean || exit 1
|
||||
make -C ../ -f Makefile.ngc clean || exit 1
|
||||
|
||||
make -C ../ -f Makefile.ngc.salamander || exit 1
|
||||
make -C ../ -f Makefile.ngc.salamander pkg || exit 1
|
||||
|
||||
for f in *_ngc.a ; do
|
||||
name=`echo "$f" | sed 's/\(_libretro\|\)_ngc.a$//'`
|
||||
whole_archive=
|
||||
|
@ -28,7 +28,9 @@
|
||||
#include "platform/platform_ps3_exec.c"
|
||||
#elif defined(GEKKO)
|
||||
#include "platform/platform_gx.c"
|
||||
#ifdef HW_RVL
|
||||
#include "platform/platform_gx_exec.c"
|
||||
#endif
|
||||
#elif defined(_XBOX)
|
||||
#include "platform/platform_xdk.c"
|
||||
#include "platform/platform_xdk_exec.c"
|
||||
|
@ -18,7 +18,9 @@
|
||||
#define _FRONTEND_CONSOLE_H
|
||||
|
||||
//optional RetroArch forward declarations
|
||||
#ifdef HAVE_RARCH_EXEC
|
||||
static void rarch_console_exec(const char *path);
|
||||
#endif
|
||||
static void verbose_log_init(void);
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
|
@ -334,9 +334,9 @@ static void system_init(void)
|
||||
|
||||
static void system_exitspawn(void)
|
||||
{
|
||||
#ifdef IS_SALAMANDER
|
||||
#if defined(IS_SALAMANDER)
|
||||
rarch_console_exec(default_paths.libretro_path);
|
||||
#else
|
||||
#elif defined(HW_RVL)
|
||||
// try to launch the core directly first, then fallback to salamander
|
||||
rarch_console_exec(g_settings.libretro);
|
||||
rarch_console_exec(g_extern.fullpath);
|
||||
|
@ -1,115 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that 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 RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(HW_RVL)
|
||||
#include <string.h>
|
||||
#include <fat.h>
|
||||
#include <gctypes.h>
|
||||
#include <ogc/cache.h>
|
||||
#include <ogc/lwp_threads.h>
|
||||
#include <ogc/system.h>
|
||||
#include <ogc/usbstorage.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
|
||||
#define EXECUTE_ADDR ((uint8_t *) 0x91800000)
|
||||
#define BOOTER_ADDR ((uint8_t *) 0x93000000)
|
||||
#define ARGS_ADDR ((uint8_t *) 0x93200000)
|
||||
|
||||
extern uint8_t _binary_wii_app_booter_app_booter_bin_start[];
|
||||
extern uint8_t _binary_wii_app_booter_app_booter_bin_end[];
|
||||
#define booter_start _binary_wii_app_booter_app_booter_bin_start
|
||||
#define booter_end _binary_wii_app_booter_app_booter_bin_end
|
||||
|
||||
#elif defined(HW_DOL)
|
||||
#include "../../ngc/sidestep.h"
|
||||
#endif
|
||||
|
||||
#include "../../retroarch_logger.h"
|
||||
|
||||
#ifdef HW_RVL
|
||||
// NOTE: this does not update the path to point to the new loading .dol file.
|
||||
// we only need it for keeping the current directory anyway.
|
||||
void dol_copy_argv_path(void)
|
||||
{
|
||||
struct __argv *argv = (struct __argv *) ARGS_ADDR;
|
||||
memset(ARGS_ADDR, 0, sizeof(struct __argv));
|
||||
char *cmdline = (char *) ARGS_ADDR + sizeof(struct __argv);
|
||||
argv->argvMagic = ARGV_MAGIC;
|
||||
argv->commandLine = cmdline;
|
||||
size_t len = strlen(__system_argv->argv[0]);
|
||||
memcpy(cmdline, __system_argv->argv[0], ++len);
|
||||
cmdline[len++] = 0;
|
||||
cmdline[len++] = 0;
|
||||
argv->length = len;
|
||||
DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + argv->length);
|
||||
}
|
||||
#endif
|
||||
|
||||
// WARNING: after we move any data into EXECUTE_ADDR, we can no longer use any
|
||||
// heap memory and are restricted to the stack only
|
||||
static void rarch_console_exec(const char *path)
|
||||
{
|
||||
RARCH_LOG("Attempt to load executable: [%s].\n", path);
|
||||
#if defined(HW_RVL)
|
||||
FILE * fp = fopen(path, "rb");
|
||||
if (fp == NULL)
|
||||
{
|
||||
RARCH_ERR("Could not open DOL file %s.\n", path);
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size_t size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
// try to allocate a buffer for it. if we can't, fail
|
||||
void *dol = malloc(size);
|
||||
if (!dol)
|
||||
{
|
||||
RARCH_ERR("Could not execute DOL file %s.\n", path);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
fread(dol, 1, size, fp);
|
||||
fclose(fp);
|
||||
|
||||
fatUnmount("carda:");
|
||||
fatUnmount("cardb:");
|
||||
fatUnmount("sd:");
|
||||
fatUnmount("usb:");
|
||||
__io_wiisd.shutdown();
|
||||
__io_usbstorage.shutdown();
|
||||
|
||||
// luckily for us, newlib's memmove doesn't allocate a seperate buffer for
|
||||
// copying in situations of overlap, so it's safe to do this
|
||||
memmove(EXECUTE_ADDR, dol, size);
|
||||
DCFlushRange(EXECUTE_ADDR, size);
|
||||
|
||||
dol_copy_argv_path();
|
||||
|
||||
size_t booter_size = booter_end - booter_start;
|
||||
memcpy(BOOTER_ADDR, booter_start, booter_size);
|
||||
DCFlushRange(BOOTER_ADDR, booter_size);
|
||||
|
||||
RARCH_LOG("jumping to %08x\n", (unsigned) BOOTER_ADDR);
|
||||
SYS_ResetSystem(SYS_SHUTDOWN,0,0);
|
||||
__lwp_thread_stopmultitasking((void (*)(void)) BOOTER_ADDR);
|
||||
#elif defined(HW_DOL)
|
||||
DOLtoARAM(path);
|
||||
#endif
|
||||
}
|
@ -693,6 +693,8 @@ static void gx_resize(void *data)
|
||||
unsigned width = gx->win_width, height = gx->win_height;
|
||||
uint64_t lifecycle_mode_state = g_extern.lifecycle_mode_state;
|
||||
|
||||
(void)lifecycle_mode_state;
|
||||
|
||||
#ifdef HW_RVL
|
||||
VIDEO_SetTrapFilter(lifecycle_mode_state & (1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE));
|
||||
#endif
|
||||
|
329
ngc/sidestep.c
329
ngc/sidestep.c
@ -1,329 +0,0 @@
|
||||
/** This code is licensed to you under the terms of the GNU GPL, version 2;
|
||||
see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */
|
||||
|
||||
/****************************************************************************
|
||||
* SideStep DOL Loading
|
||||
*
|
||||
* This module runs a DOL file from Auxilliary RAM. This removes any memory
|
||||
* issues which might occur - and also means you can easily overwrite yourself!
|
||||
*
|
||||
* softdev March 2007
|
||||
***************************************************************************/
|
||||
#ifndef HW_RVL
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <network.h>
|
||||
#include <smb.h>
|
||||
|
||||
#include "sidestep.h"
|
||||
#include "ssaram.h"
|
||||
#include "../retroarch_logger.h"
|
||||
|
||||
#define ARAMSTART 0x8000
|
||||
|
||||
/*** A global or two ***/
|
||||
static DOLHEADER *dolhdr;
|
||||
static u32 minaddress = 0;
|
||||
static u32 maxaddress = 0;
|
||||
static char dol_readbuf[2048];
|
||||
|
||||
typedef int (*BOOTSTUB) (u32 entrypoint, u32 dst, u32 src, int len, u32 invlen, u32 invaddress);
|
||||
|
||||
/*--- Auxilliary RAM Support ----------------------------------------------*/
|
||||
/****************************************************************************
|
||||
* ARAMStub
|
||||
*
|
||||
* This is an assembly routine and should only be called through ARAMRun
|
||||
* *DO NOT CALL DIRECTLY!*
|
||||
****************************************************************************/
|
||||
static void ARAMStub(void)
|
||||
{
|
||||
/*** The routine expects to receive
|
||||
R3 = entrypoint
|
||||
R4 = Destination in main RAM
|
||||
R5 = Source from ARAM
|
||||
R6 = Data length
|
||||
R7 = Invalidate Length / 32
|
||||
R8 = Invalidate Start Address
|
||||
***/
|
||||
|
||||
asm("mtctr 7");
|
||||
asm("Invalidate:");
|
||||
asm("dcbi 0,8");
|
||||
asm("addi 8,8,32");
|
||||
asm("bdnz Invalidate");
|
||||
|
||||
asm("lis 8,0xcc00");
|
||||
asm("ori 8,8,0x3004");
|
||||
asm("lis 7,0");
|
||||
asm("stw 7,0(8)");
|
||||
|
||||
asm("mfmsr 8");
|
||||
asm("ori 8,8,2");
|
||||
asm("rlwinm 8,8,0,17,15");
|
||||
asm("mtmsr 8");
|
||||
|
||||
asm("lis 7,0xcc00");
|
||||
asm("ori 7,7,0x5020");
|
||||
asm("stw 4,0(7)"); /*** Store Memory Address ***/
|
||||
asm("stw 5,4(7)"); /*** Store ARAM Address ***/
|
||||
asm("stw 6,8(7)"); /*** Store Length ***/
|
||||
|
||||
asm("lis 7,0xcc00");
|
||||
asm("ori 7,7,0x500a");
|
||||
asm("WaitDMA:");
|
||||
asm("lhz 5,0(7)");
|
||||
asm("andi. 5,5,0x200");
|
||||
asm("cmpwi 5,5,0");
|
||||
asm("bne WaitDMA"); /*** Wait DMA Complete ***/
|
||||
|
||||
/*** Update exceptions ***/
|
||||
asm("lis 8,0x8000");
|
||||
asm("lis 5,0x4c00");
|
||||
asm("ori 5,5,0x64");
|
||||
asm("stw 5,0x100(8)");
|
||||
asm("stw 5,0x200(8)");
|
||||
asm("stw 5,0x300(8)");
|
||||
asm("stw 5,0x400(8)");
|
||||
asm("stw 5,0x500(8)");
|
||||
asm("stw 5,0x600(8)");
|
||||
asm("stw 5,0x700(8)");
|
||||
asm("stw 5,0x800(8)");
|
||||
asm("stw 5,0x900(8)");
|
||||
asm("stw 5,0xC00(8)");
|
||||
asm("stw 5,0xD00(8)");
|
||||
asm("stw 5,0xF00(8)");
|
||||
asm("stw 5,0x1300(8)");
|
||||
asm("stw 5,0x1400(8)");
|
||||
asm("stw 5,0x1700(8)");
|
||||
|
||||
/*** Flush it all again ***/
|
||||
asm("lis 7,0x30");
|
||||
asm("lis 8,0x8000");
|
||||
asm("mtctr 7");
|
||||
asm("flush:");
|
||||
asm("dcbst 0,8");
|
||||
asm("sync");
|
||||
asm("icbi 0,8");
|
||||
asm("addi 8,8,8");
|
||||
asm("bdnz flush");
|
||||
asm("isync");
|
||||
|
||||
/*** Fix ints ***/
|
||||
asm("mfmsr 8");
|
||||
asm("rlwinm 8,8,0,17,15");
|
||||
asm("mtmsr 8");
|
||||
|
||||
asm("mfmsr 8");
|
||||
asm("ori 8,8,8194");
|
||||
asm("mtmsr 8");
|
||||
|
||||
/*** Party! ***/
|
||||
asm("mtlr 3");
|
||||
asm("blr"); /*** Boot DOL ***/
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* ARAMRun
|
||||
*
|
||||
* This actually runs the new DOL ... eventually ;)
|
||||
****************************************************************************/
|
||||
void ARAMRun(u32 entrypoint, u32 dst, u32 src, u32 len)
|
||||
{
|
||||
char *p;
|
||||
char *s = (char *) ARAMStub;
|
||||
BOOTSTUB stub;
|
||||
|
||||
/*** Shutdown libOGC ***/
|
||||
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||
|
||||
/*** Copy ARAMStub to 81300000 ***/
|
||||
if (dst + len < 0x81300000) p = (void *) 0x81300000;
|
||||
else p = (void *) 0x80003100;
|
||||
memcpy(p, s, 256); /*** Way too much - but who cares ***/
|
||||
|
||||
/*** Round length to 32 bytes ***/
|
||||
if (len & 0x1f) len = (len & ~0x1f) + 0x20;
|
||||
|
||||
/*** Flush everything! ***/
|
||||
DCFlushRange((void *) 0x80000000, 0x1800000);
|
||||
|
||||
/*** Boot the bugger :D ***/
|
||||
stub = (BOOTSTUB) p;
|
||||
RARCH_LOG("Launching relocated stub at %08x\n", (unsigned) p);
|
||||
stub((u32) entrypoint, dst, src, len | 0x80000000, len >> 5, dst);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* ARAMClear
|
||||
*
|
||||
* To make life easy, just clear out the Auxilliary RAM completely.
|
||||
****************************************************************************/
|
||||
static void ARAMClear(void)
|
||||
{
|
||||
int i;
|
||||
char *buffer = memalign(32, 2048); /*** A little 2k buffer ***/
|
||||
|
||||
memset(buffer, 0, 2048);
|
||||
DCFlushRange(buffer, 2048);
|
||||
|
||||
for (i = ARAMSTART; i < 0x1000000; i += 2048)
|
||||
{
|
||||
ARAMPut(buffer, (char *) i, 2048);
|
||||
while (AR_GetDMAStatus());
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
/*--- DOL Decoding functions -----------------------------------------------*/
|
||||
/****************************************************************************
|
||||
* DOLMinMax
|
||||
*
|
||||
* Calculate the DOL minimum and maximum memory addresses
|
||||
****************************************************************************/
|
||||
static void DOLMinMax(DOLHEADER * dol)
|
||||
{
|
||||
int i;
|
||||
|
||||
maxaddress = 0;
|
||||
minaddress = 0x87100000;
|
||||
|
||||
/*** Go through DOL sections ***/
|
||||
/*** Text sections ***/
|
||||
for (i = 0; i < MAXTEXTSECTION; i++)
|
||||
{
|
||||
if (dol->textAddress[i] && dol->textLength[i])
|
||||
{
|
||||
if (dol->textAddress[i] < minaddress)
|
||||
minaddress = dol->textAddress[i];
|
||||
if ((dol->textAddress[i] + dol->textLength[i]) > maxaddress)
|
||||
maxaddress = dol->textAddress[i] + dol->textLength[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*** Data sections ***/
|
||||
for (i = 0; i < MAXDATASECTION; i++)
|
||||
{
|
||||
if (dol->dataAddress[i] && dol->dataLength[i])
|
||||
{
|
||||
if (dol->dataAddress[i] < minaddress)
|
||||
minaddress = dol->dataAddress[i];
|
||||
if ((dol->dataAddress[i] + dol->dataLength[i]) > maxaddress)
|
||||
maxaddress = dol->dataAddress[i] + dol->dataLength[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*** And of course, any BSS section ***/
|
||||
if (dol->bssAddress)
|
||||
{
|
||||
if ((dol->bssAddress + dol->bssLength) > maxaddress)
|
||||
maxaddress = dol->bssAddress + dol->bssLength;
|
||||
}
|
||||
|
||||
/*** Some OLD dols, Xrick in particular, require ~128k clear memory ***/
|
||||
maxaddress += 0x20000;
|
||||
|
||||
RARCH_LOG("Min Address: %08x Max Address: %08x\n", minaddress, maxaddress);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* DOLtoARAM
|
||||
*
|
||||
* Moves the DOL from main memory to ARAM, positioning as it goes
|
||||
*
|
||||
* Pass in a memory pointer to a previously loaded DOL
|
||||
****************************************************************************/
|
||||
int DOLtoARAM(const char *dol_name)
|
||||
{
|
||||
u32 sizeinbytes;
|
||||
int i, j;
|
||||
static DOLHEADER dolhead;
|
||||
FILE *f = fopen(dol_name, "rb");
|
||||
|
||||
if (!f)
|
||||
{
|
||||
RARCH_ERR("Could not open\"%s\"\n", dol_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fread(&dolhead, 1, sizeof(DOLHEADER), f);
|
||||
/*** Make sure ARAM subsystem is alive! ***/
|
||||
AR_Init(NULL, 0); /*** No stack - we need it all ***/
|
||||
ARAMClear();
|
||||
|
||||
/*** Get DOL header ***/
|
||||
dolhdr = (DOLHEADER *) &dolhead;
|
||||
|
||||
/*** First, does this look like a DOL? ***/
|
||||
if (dolhdr->textOffset[0] != DOLHDRLENGTH)
|
||||
{
|
||||
RARCH_ERR("\"%s\" is not a .dol file\n", dol_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*** Get DOL stats ***/
|
||||
DOLMinMax(dolhdr);
|
||||
sizeinbytes = maxaddress - minaddress;
|
||||
|
||||
/*** Move all DOL sections into ARAM ***/
|
||||
/*** Move text sections ***/
|
||||
for (i = 0; i < MAXTEXTSECTION; i++)
|
||||
{
|
||||
/*** This may seem strange, but in developing d0lLZ we found some with section addresses with zero length ***/
|
||||
if (dolhdr->textAddress[i] && dolhdr->textLength[i])
|
||||
{
|
||||
fseek(f, dolhdr->textOffset[i], SEEK_SET);
|
||||
unsigned count = dolhdr->textLength[i] / sizeof(dol_readbuf);
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
fread(dol_readbuf, 1, sizeof(dol_readbuf), f);
|
||||
ARAMPut(dol_readbuf, (char *) ((dolhdr->textAddress[i] - minaddress) + (sizeof(dol_readbuf) * j) + ARAMSTART),
|
||||
sizeof(dol_readbuf));
|
||||
}
|
||||
unsigned remaining = dolhdr->textLength[i] % sizeof(dol_readbuf);
|
||||
if (remaining)
|
||||
{
|
||||
fread(dol_readbuf, 1, remaining, f);
|
||||
ARAMPut(dol_readbuf, (char *) ((dolhdr->textAddress[i] - minaddress) + (sizeof(dol_readbuf) * count) + ARAMSTART),
|
||||
remaining);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*** Move data sections ***/
|
||||
for (i = 0; i < MAXDATASECTION; i++)
|
||||
{
|
||||
if (dolhdr->dataAddress[i] && dolhdr->dataLength[i])
|
||||
{
|
||||
fseek(f, dolhdr->dataOffset[i], SEEK_SET);
|
||||
unsigned count = dolhdr->dataLength[i] / sizeof(dol_readbuf);
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
fread(dol_readbuf, 1, sizeof(dol_readbuf), f);
|
||||
ARAMPut(dol_readbuf, (char *) ((dolhdr->dataAddress[i] - minaddress) + (sizeof(dol_readbuf) * j) + ARAMSTART),
|
||||
sizeof(dol_readbuf));
|
||||
}
|
||||
unsigned remaining = dolhdr->dataLength[i] % sizeof(dol_readbuf);
|
||||
if (remaining)
|
||||
{
|
||||
fread(dol_readbuf, 1, remaining, f);
|
||||
ARAMPut(dol_readbuf, (char *) ((dolhdr->dataAddress[i] - minaddress) + (sizeof(dol_readbuf) * count) + ARAMSTART),
|
||||
remaining);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
/*** Now go run it ***/
|
||||
ARAMRun(dolhdr->entryPoint, minaddress, ARAMSTART, sizeinbytes);
|
||||
|
||||
/*** Will never return ***/
|
||||
return 1;
|
||||
}
|
||||
#endif
|
@ -1,39 +0,0 @@
|
||||
/****************************************************************************
|
||||
* SideStep DOL Loading
|
||||
*
|
||||
* This module runs a DOL file from Auxilliary RAM. This removes any memory
|
||||
* issues which might occur - and also means you can easily overwrite yourself!
|
||||
*
|
||||
* softdev March 2007
|
||||
***************************************************************************/
|
||||
#ifndef HW_RVL
|
||||
#ifndef __SIDESTEP__
|
||||
#define __SIDESTEP__
|
||||
|
||||
/*** A standard DOL header ***/
|
||||
#define DOLHDRLENGTH 256 /*** All DOLS must have a 256 byte header ***/
|
||||
#define MAXTEXTSECTION 7
|
||||
#define MAXDATASECTION 11
|
||||
|
||||
/*** A handy DOL structure ***/
|
||||
typedef struct {
|
||||
unsigned int textOffset[MAXTEXTSECTION];
|
||||
unsigned int dataOffset[MAXDATASECTION];
|
||||
|
||||
unsigned int textAddress[MAXTEXTSECTION];
|
||||
unsigned int dataAddress[MAXDATASECTION];
|
||||
|
||||
unsigned int textLength[MAXTEXTSECTION];
|
||||
unsigned int dataLength[MAXDATASECTION];
|
||||
|
||||
unsigned int bssAddress;
|
||||
unsigned int bssLength;
|
||||
|
||||
unsigned int entryPoint;
|
||||
unsigned int unused[MAXTEXTSECTION];
|
||||
} DOLHEADER;
|
||||
|
||||
int DOLtoARAM(const char *dol_name);
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user