Refactored out of existence rarch_console_exec.c - now implemented

per platform port that needs it
This commit is contained in:
twinaphex 2013-01-09 02:31:54 +01:00
parent 56e8b3233a
commit 70c85be081
17 changed files with 19 additions and 431 deletions

View File

@ -37,7 +37,7 @@ CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE)
LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map
LIBS := -lfat -logc
OBJ = gx/salamander/main.o console/rarch_console_exec.o console/rarch_console_libretro_mgmt.o file_path.o compat/compat.o conf/config_file.o ngc/ssaram.o ngc/sidestep.o
OBJ = frontend/frontend_console.o console/rarch_console_libretro_mgmt.o file_path.o compat/compat.o conf/config_file.o ngc/ssaram.o ngc/sidestep.o
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER

View File

@ -19,7 +19,7 @@ endif
STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe
PPU_CFLAGS += -I. -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC
PPU_SRCS = frontend/frontend_console.c console/rarch_console_exec.c console/rarch_console_libretro_mgmt.c file_path.c compat/compat.c conf/config_file.c
PPU_SRCS = frontend/frontend_console.c console/rarch_console_libretro_mgmt.c file_path.c compat/compat.c conf/config_file.c
ifeq ($(HAVE_LOGGER), 1)
PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger

View File

@ -39,7 +39,7 @@ LIBS := -lfat -lwiiuse -logc -lbte
APP_BOOTER_DIR = wii/app_booter
OBJ = frontend/frontend_console.o console/rarch_console_exec.o console/rarch_console_libretro_mgmt.o file_path.o compat/compat.o conf/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj
OBJ = frontend/frontend_console.o console/rarch_console_libretro_mgmt.o file_path.o compat/compat.o conf/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER

View File

@ -45,10 +45,6 @@ default_paths_t default_paths;
#include "../../ngc/sidestep.c"
#endif
#ifdef HAVE_RARCH_EXEC
#include "../rarch_console_exec.c"
#endif
#ifdef HAVE_RSOUND
#include "../rarch_console_rsound.c"
#endif

View File

@ -1,142 +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(__CELLOS_LV2__)
#include <cell/sysmodule.h>
#include <sys/process.h>
#include <sysutil/sysutil_common.h>
#include <netex/net.h>
#include <np.h>
#include <np/drm.h>
#elif defined(_XBOX)
#include <xtl.h>
#elif 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 "rarch_console_exec.h"
#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
void rarch_console_exec(const char *path)
{
RARCH_LOG("Attempt to load executable: [%s].\n", path);
#if defined(_XBOX)
XLaunchNewImage(path, NULL);
#elif defined(__CELLOS_LV2__)
char spawn_data[256];
for(unsigned int i = 0; i < sizeof(spawn_data); ++i)
spawn_data[i] = i & 0xff;
char spawn_data_size[16];
snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256);
const char * const spawn_argv[] = {
spawn_data_size,
"test argv for",
"sceNpDrmProcessExitSpawn2()",
NULL
};
SceNpDrmKey * k_licensee = NULL;
int ret = sceNpDrmProcessExitSpawn2(k_licensee, path, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
if(ret < 0)
{
RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n");
sys_game_process_exitspawn(path, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
}
sceNpTerm();
sys_net_finalize_network();
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP);
cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
#elif defined(HW_RVL)
FILE * fp = fopen(path, "rb");
if (fp == NULL)
{
RARCH_ERR("Could not execute DOL file.\n");
return;
}
fseek(fp, 0, SEEK_END);
size_t size = ftell(fp);
fseek(fp, 0, SEEK_SET);
fread(EXECUTE_ADDR, 1, size, fp);
fclose(fp);
DCFlushRange(EXECUTE_ADDR, size);
dol_copy_argv_path();
fatUnmount("carda:");
fatUnmount("cardb:");
fatUnmount("sd:");
fatUnmount("usb:");
__io_wiisd.shutdown();
__io_usbstorage.shutdown();
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);
#else
RARCH_WARN("External loading of executables is not supported for this platform.\n");
#endif
}

View File

@ -1,22 +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/>.
*/
#ifndef RARCH_CONSOLE_EXEC_H__
#define RARCH_CONSOLE_EXEC_H__
void rarch_console_exec(const char *path);
#endif

View File

@ -19,12 +19,18 @@
#include <stddef.h>
#include <string.h>
//forward declarations
static void rarch_console_exec(const char *path);
#if defined(__CELLOS_LV2__)
#include "platform/platform_ps3.c"
#include "platform/platform_ps3_exec.c"
#elif defined(GEKKO)
#include "platform/platform_gx.c"
#include "platform/platform_gx_exec.c"
#elif defined(_XBOX)
#include "platform/platform_xdk.c"
#include "platform/platform_xdk_exec.c"
#elif defined(PSP)
#include "platform/platform_psp.c"
#endif

View File

@ -29,7 +29,6 @@
#endif
#include "../../console/rarch_console.h"
#include "../../console/rarch_console_exec.h"
#include "../../console/rarch_console_libretro_mgmt.h"
#include "../../console/rarch_console_input.h"
#include "../../console/rarch_console_settings.h"

View File

@ -23,10 +23,6 @@
#include "../../console/rarch_console.h"
#ifdef HAVE_RARCH_EXEC
#include "../../console/rarch_console_exec.h"
#endif
#include "../../console/rarch_console_libretro_mgmt.h"
#include "../../console/rarch_console_config.h"
#include "../../console/rarch_console_settings.h"

View File

@ -10,7 +10,6 @@
#include "classic.h"
#include "motion_plus.h"
#include "io.h"
#include "lwp_wkspace.inl"
void wiiuse_handshake(struct wiimote_t *wm,ubyte *data,uword len)
{
@ -25,7 +24,7 @@ void wiiuse_handshake(struct wiimote_t *wm,ubyte *data,uword len)
wiiuse_set_leds(wm,WIIMOTE_LED_NONE,NULL);
buf = __lwp_wkspace_allocate(sizeof(ubyte)*8);
buf = __lwp_heap_allocate(&__wkspace_heap, sizeof(ubyte) * 8);
wiiuse_read_data(wm,buf,WM_MEM_OFFSET_CALIBRATION,7,wiiuse_handshake);
break;
case 1:
@ -38,7 +37,7 @@ void wiiuse_handshake(struct wiimote_t *wm,ubyte *data,uword len)
accel->cal_g.x = (((data[4]<<2)|((data[7]>>4)&3)) - accel->cal_zero.x);
accel->cal_g.y = (((data[5]<<2)|((data[7]>>2)&3)) - accel->cal_zero.y);
accel->cal_g.z = (((data[6]<<2)|(data[7]&3)) - accel->cal_zero.z);
__lwp_wkspace_free(data);
__lwp_heap_free(&__wkspace_heap, data);
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
@ -82,7 +81,7 @@ void wiiuse_handshake_expansion(struct wiimote_t *wm,ubyte *data,uword len)
break;
case 2:
wm->expansion_state = 3;
buf = __lwp_wkspace_allocate(sizeof(ubyte)*EXP_HANDSHAKE_LEN);
buf = __lwp_heap_allocate(&__wkspace_heap, sizeof(ubyte) * EXP_HANDSHAKE_LEN);
wiiuse_read_data(wm,buf,WM_EXP_MEM_CALIBR,EXP_HANDSHAKE_LEN,wiiuse_handshake_expansion);
break;
case 3:
@ -108,11 +107,11 @@ void wiiuse_handshake_expansion(struct wiimote_t *wm,ubyte *data,uword len)
if(!classic_ctrl_handshake(wm,&wm->exp.classic,data,len)) return;
/*WIIMOTE_DISABLE_STATE(wm,WIIMOTE_STATE_EXP_HANDSHAKE);
WIIMOTE_ENABLE_STATE(wm,WIIMOTE_STATE_EXP_FAILED);
__lwp_wkspace_free(data);
_lwp_heap_free(&__wkspace_heap, data);
wiiuse_status(wm,NULL);
return;*/
}
__lwp_wkspace_free(data);
__lwp_heap_free(&__wkspace_heap, data);
WIIMOTE_DISABLE_STATE(wm,WIIMOTE_STATE_EXP_HANDSHAKE);
WIIMOTE_ENABLE_STATE(wm,WIIMOTE_STATE_EXP);

View File

@ -162,7 +162,7 @@ void wiiuse_init_cmd_queue(struct wiimote_t *wm)
if (!__queue_buffer[wm->unid]) {
size = (MAX_COMMANDS*sizeof(struct cmd_blk_t));
__queue_buffer[wm->unid] = __lwp_wkspace_allocate(size);
__queue_buffer[wm->unid] = __lwp_heap_allocate(&__wkspace_heap,size);
if(!__queue_buffer[wm->unid]) return;
}

View File

@ -1,49 +0,0 @@
#ifndef __LWP_PRIORITY_INL__
#define __LWP_PRIORITY_INL__
static inline void __lwp_priomap_init(prio_cntrl *theprio,u32 prio)
{
u32 major,minor,mask;
major = prio/16;
minor = prio%16;
theprio->minor = &_prio_bitmap[major];
mask = 0x80000000>>major;
theprio->ready_major = mask;
theprio->block_major = ~mask;
mask = 0x80000000>>minor;
theprio->ready_minor = mask;
theprio->block_minor = ~mask;
#ifdef _LWPPRIO_DEBUG
printf("__lwp_priomap_init(%p,%d,%p,%d,%d,%d,%d)\n",theprio,prio,theprio->minor,theprio->ready_major,theprio->ready_minor,theprio->block_major,theprio->block_minor);
#endif
}
static inline void __lwp_priomap_addto(prio_cntrl *theprio)
{
*theprio->minor |= theprio->ready_minor;
_prio_major_bitmap |= theprio->ready_major;
}
static inline void __lwp_priomap_removefrom(prio_cntrl *theprio)
{
*theprio->minor &= theprio->block_minor;
if(*theprio->minor==0)
_prio_major_bitmap &= theprio->block_major;
}
static inline u32 __lwp_priomap_highest()
{
u32 major,minor;
major = cntlzw(_prio_major_bitmap);
minor = cntlzw(_prio_bitmap[major]);
#ifdef _LWPPRIO_DEBUG
printf("__lwp_priomap_highest(%d)\n",((major<<4)+minor));
#endif
return ((major<<4)+minor);
}
#endif

View File

@ -1,93 +0,0 @@
#ifndef __LWP_INL__
#define __LWP_INL__
static __inline__ u32 __lwp_thread_isexec(lwp_cntrl *thethread)
{
return (thethread==_thr_executing);
}
static __inline__ u32 __lwp_thread_isheir(lwp_cntrl *thethread)
{
return (thethread==_thr_heir);
}
static __inline__ void __lwp_thread_calcheir()
{
_thr_heir = (lwp_cntrl*)_lwp_thr_ready[__lwp_priomap_highest()].first;
#ifdef _LWPTHREADS_DEBUG
printf("__lwp_thread_calcheir(%p)\n",_thr_heir);
#endif
}
static __inline__ u32 __lwp_thread_isallocatedfp(lwp_cntrl *thethread)
{
return (thethread==_thr_allocated_fp);
}
static __inline__ void __lwp_thread_deallocatefp()
{
_thr_allocated_fp = NULL;
}
static __inline__ void __lwp_thread_dispatchinitialize()
{
_thread_dispatch_disable_level = 1;
}
static __inline__ void __lwp_thread_dispatchenable()
{
if((--_thread_dispatch_disable_level)==0)
__thread_dispatch();
}
static __inline__ void __lwp_thread_dispatchdisable()
{
++_thread_dispatch_disable_level;
}
static __inline__ void __lwp_thread_dispatchunnest()
{
--_thread_dispatch_disable_level;
}
static __inline__ void __lwp_thread_unblock(lwp_cntrl *thethread)
{
__lwp_thread_clearstate(thethread,LWP_STATES_BLOCKED);
}
static __inline__ void** __lwp_thread_getlibcreent()
{
return __lwp_thr_libc_reent;
}
static __inline__ void __lwp_thread_setlibcreent(void **libc_reent)
{
__lwp_thr_libc_reent = libc_reent;
}
static __inline__ bool __lwp_thread_isswitchwant()
{
return _context_switch_want;
}
static __inline__ bool __lwp_thread_isdispatchenabled()
{
return (_thread_dispatch_disable_level==0);
}
static __inline__ void __lwp_thread_inittimeslice()
{
__lwp_wd_initialize(&_lwp_wd_timeslice,__lwp_thread_tickle_timeslice,LWP_TIMESLICE_TIMER_ID,NULL);
}
static __inline__ void __lwp_thread_starttimeslice()
{
__lwp_wd_insert_ticks(&_lwp_wd_timeslice,millisecs_to_ticks(1));
}
static __inline__ void __lwp_thread_stoptimeslice()
{
__lwp_wd_remove_ticks(&_lwp_wd_timeslice);
}
#endif

View File

@ -1,84 +0,0 @@
#ifndef __LWP_WATCHDOG_INL__
#define __LWP_WATCHDOG_INL__
static __inline__ void __lwp_wd_initialize(wd_cntrl *wd,wd_service_routine routine,u32 id,void *usr_data)
{
wd->state = LWP_WD_INACTIVE;
wd->id = id;
wd->routine = routine;
wd->usr_data = usr_data;
}
static __inline__ wd_cntrl* __lwp_wd_first(lwp_queue *queue)
{
return (wd_cntrl*)queue->first;
}
static __inline__ wd_cntrl* __lwp_wd_last(lwp_queue *queue)
{
return (wd_cntrl*)queue->last;
}
static __inline__ wd_cntrl* __lwp_wd_next(wd_cntrl *wd)
{
return (wd_cntrl*)wd->node.next;
}
static __inline__ wd_cntrl* __lwp_wd_prev(wd_cntrl *wd)
{
return (wd_cntrl*)wd->node.prev;
}
static __inline__ void __lwp_wd_activate(wd_cntrl *wd)
{
wd->state = LWP_WD_ACTIVE;
}
static __inline__ void __lwp_wd_deactivate(wd_cntrl *wd)
{
wd->state = LWP_WD_REMOVE;
}
static __inline__ u32 __lwp_wd_isactive(wd_cntrl *wd)
{
return (wd->state==LWP_WD_ACTIVE);
}
static __inline__ u64 __lwp_wd_calc_ticks(const struct timespec *time)
{
u64 ticks;
ticks = secs_to_ticks(time->tv_sec);
ticks += nanosecs_to_ticks(time->tv_nsec);
return ticks;
}
static __inline__ void __lwp_wd_tickle_ticks()
{
__lwp_wd_tickle(&_wd_ticks_queue);
}
static __inline__ void __lwp_wd_insert_ticks(wd_cntrl *wd,s64 interval)
{
wd->start = gettime();
wd->fire = (wd->start+LWP_WD_ABS(interval));
__lwp_wd_insert(&_wd_ticks_queue,wd);
}
static __inline__ void __lwp_wd_adjust_ticks(u32 dir,s64 interval)
{
__lwp_wd_adjust(&_wd_ticks_queue,dir,interval);
}
static __inline__ void __lwp_wd_remove_ticks(wd_cntrl *wd)
{
__lwp_wd_remove(&_wd_ticks_queue,wd);
}
static __inline__ void __lwp_wd_reset(wd_cntrl *wd)
{
__lwp_wd_remove(&_wd_ticks_queue,wd);
__lwp_wd_insert(&_wd_ticks_queue,wd);
}
#endif

View File

@ -1,14 +0,0 @@
#ifndef __LWP_WKSPACE_INL__
#define __LWP_WKSPACE_INL__
static __inline__ void* __lwp_wkspace_allocate(u32 size)
{
return __lwp_heap_allocate(&__wkspace_heap,size);
}
static __inline__ BOOL __lwp_wkspace_free(void *ptr)
{
return __lwp_heap_free(&__wkspace_heap,ptr);
}
#endif

View File

@ -67,14 +67,14 @@ struct wiimote_t** wiiuse_init(int wiimotes, wii_event_cb event_cb) {
return NULL;
if (!__wm) {
__wm = __lwp_wkspace_allocate(sizeof(struct wiimote_t*) * wiimotes);
__wm = __lwp_heap_allocate(&__wkspace_heap, sizeof(struct wiimote_t*) * wiimotes);
if(!__wm) return NULL;
memset(__wm, 0, sizeof(struct wiimote_t*) * wiimotes);
}
for (i = 0; i < wiimotes; ++i) {
if(!__wm[i])
__wm[i] = __lwp_wkspace_allocate(sizeof(struct wiimote_t));
__wm[i] = __lwp_heap_allocate(&__wkspace_heap, sizeof(struct wiimote_t));
memset(__wm[i], 0, sizeof(struct wiimote_t));
__wm[i]->unid = i;

View File

@ -38,10 +38,6 @@ distribution.
#include <unistd.h>
#include "os.h"
#include "lwp_wkspace.inl"
#include "lwp_priority.inl"
#include "lwp_watchdog.inl"
#include "lwp_threads.inl"
#include "conf.h"
#include "ir.h"
@ -147,7 +143,7 @@ static void __wpad_timeouthandler(syswd_t alarm,void *cbarg)
if(!__wpads_active) return;
__lwp_thread_dispatchdisable();
++_thread_dispatch_disable_level;
for(i=0;i<WPAD_MAX_WIIMOTES;i++) {
wpdcb = &__wpdcb[i];
wm = wpdcb->wm;
@ -159,7 +155,7 @@ static void __wpad_timeouthandler(syswd_t alarm,void *cbarg)
}
}
}
__lwp_thread_dispatchunnest();
--_thread_dispatch_disable_level;
}
#ifdef HAVE_WIIUSE_SPEAKER