2012-11-24 04:23:20 +01:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2016-01-10 04:06:50 +01:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2012-11-24 04:23:20 +01:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-09-01 12:10:26 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2016-09-12 16:39:50 +02:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifdef VITA
|
|
|
|
#include <psp2/power.h>
|
2016-07-31 09:59:53 +02:00
|
|
|
#include <psp2/sysmodule.h>
|
2016-09-08 01:25:14 +02:00
|
|
|
#include <psp2/appmgr.h>
|
2016-09-08 20:40:19 +02:00
|
|
|
#include <pthread.h>
|
2016-09-26 01:06:01 +02:00
|
|
|
|
|
|
|
#include "../../bootstrap/vita/sbrk.c"
|
|
|
|
|
2015-09-02 13:07:13 +02:00
|
|
|
#else
|
2012-11-24 04:23:20 +01:00
|
|
|
#include <pspkernel.h>
|
|
|
|
#include <pspdebug.h>
|
2014-02-17 14:26:03 +01:00
|
|
|
#include <pspfpu.h>
|
2014-02-18 18:43:23 +01:00
|
|
|
#include <psppower.h>
|
2014-06-04 01:35:26 +01:00
|
|
|
#include <pspsdk.h>
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2012-11-24 04:23:20 +01:00
|
|
|
|
2017-01-17 18:12:23 +01:00
|
|
|
#include <string/stdstring.h>
|
2015-09-15 04:49:10 +02:00
|
|
|
#include <boolean.h>
|
2014-10-22 00:23:06 +02:00
|
|
|
#include <file/file_path.h>
|
2015-06-15 22:45:02 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2016-03-20 14:53:54 +01:00
|
|
|
#include <lists/file_list.h>
|
2015-06-15 22:45:02 +02:00
|
|
|
#endif
|
|
|
|
|
2017-01-17 18:55:59 +01:00
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "../../menu/menu_driver.h"
|
|
|
|
#endif
|
|
|
|
|
2015-11-29 01:59:41 +01:00
|
|
|
#include "../frontend_driver.h"
|
|
|
|
#include "../../defaults.h"
|
2016-06-20 17:49:20 +02:00
|
|
|
#include "../../file_path_special.h"
|
2015-08-10 23:11:40 +02:00
|
|
|
#include "../../defines/psp_defines.h"
|
2017-01-17 18:55:59 +01:00
|
|
|
#include "../../retroarch.h"
|
|
|
|
#include "../../paths.h"
|
2015-11-23 12:03:38 +01:00
|
|
|
#include "../../verbosity.h"
|
2014-06-05 00:17:37 +01:00
|
|
|
|
2015-08-30 19:46:19 +02:00
|
|
|
#if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER)
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifndef VITA
|
2015-09-20 15:33:54 +02:00
|
|
|
#include "../../bootstrap/psp1/kernel_functions.h"
|
2014-06-05 00:17:37 +01:00
|
|
|
#endif
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2012-11-24 04:23:20 +01:00
|
|
|
|
2017-01-17 11:43:12 +01:00
|
|
|
#ifndef VITA
|
2015-08-12 12:33:27 +02:00
|
|
|
PSP_MODULE_INFO("RetroArch", 0, 1, 1);
|
2014-03-08 15:46:59 +01:00
|
|
|
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER|THREAD_ATTR_VFPU);
|
2014-06-29 05:45:36 +01:00
|
|
|
#ifdef BIG_STACK
|
|
|
|
PSP_MAIN_THREAD_STACK_SIZE_KB(4*1024);
|
|
|
|
#endif
|
2012-11-24 04:23:20 +01:00
|
|
|
PSP_HEAP_SIZE_MAX();
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2012-11-24 04:23:20 +01:00
|
|
|
|
2014-06-05 00:17:37 +01:00
|
|
|
char eboot_path[512];
|
2016-09-04 01:55:22 -05:00
|
|
|
char user_path[512];
|
2014-06-05 00:17:37 +01:00
|
|
|
|
2016-02-05 18:43:23 +01:00
|
|
|
static enum frontend_fork psp_fork_mode = FRONTEND_FORK_NONE;
|
2014-10-02 21:39:29 +02:00
|
|
|
|
2014-06-03 03:35:12 +02:00
|
|
|
static void frontend_psp_get_environment_settings(int *argc, char *argv[],
|
|
|
|
void *args, void *params_data)
|
2012-11-24 04:23:20 +01:00
|
|
|
{
|
2015-09-02 13:07:13 +02:00
|
|
|
struct rarch_main_wrap *params = NULL;
|
|
|
|
|
2014-02-11 16:10:40 +01:00
|
|
|
(void)args;
|
2015-09-02 13:07:13 +02:00
|
|
|
|
2013-08-10 20:59:10 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
|
|
|
#if defined(HAVE_LOGGER)
|
|
|
|
logger_init();
|
|
|
|
#elif defined(HAVE_FILE_LOGGER)
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifndef VITA
|
2016-09-03 23:58:37 -05:00
|
|
|
retro_main_log_file_init("ms0:/temp/retroarch-log.txt");
|
2016-07-31 09:59:53 +02:00
|
|
|
#else
|
|
|
|
retro_main_log_file_init("ux0:/temp/retroarch-log.txt");
|
2013-08-10 20:59:10 +02:00
|
|
|
#endif
|
2013-01-08 08:38:25 +01:00
|
|
|
#endif
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2013-01-08 08:38:25 +01:00
|
|
|
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifdef VITA
|
2016-10-10 11:43:05 +02:00
|
|
|
strlcpy(eboot_path, "app0:/", sizeof(eboot_path));
|
2015-09-02 13:07:13 +02:00
|
|
|
strlcpy(g_defaults.dir.port, eboot_path, sizeof(g_defaults.dir.port));
|
2016-10-10 11:43:05 +02:00
|
|
|
strlcpy(user_path, "ux0:/data/retroarch/", sizeof(user_path));
|
2015-09-02 13:07:13 +02:00
|
|
|
#else
|
2016-09-04 00:02:49 -05:00
|
|
|
strlcpy(eboot_path, argv[0], sizeof(eboot_path));
|
2016-09-04 12:18:27 -05:00
|
|
|
/* for PSP, use uppercase directories, and no trailing slashes
|
|
|
|
otherwise mkdir fails */
|
|
|
|
strlcpy(user_path, "ms0:/PSP/RETROARCH", sizeof(user_path));
|
2016-09-04 00:26:05 -05:00
|
|
|
fill_pathname_basedir(g_defaults.dir.port, argv[0], sizeof(g_defaults.dir.port));
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2015-07-27 17:18:10 +02:00
|
|
|
RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port);
|
2016-09-04 02:19:16 -05:00
|
|
|
|
2016-09-04 01:55:22 -05:00
|
|
|
#ifdef VITA
|
2016-09-04 02:19:16 -05:00
|
|
|
/* bundle data*/
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port,
|
2016-09-08 01:25:14 +02:00
|
|
|
"", sizeof(g_defaults.dir.core));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port,
|
|
|
|
"assets", sizeof(g_defaults.dir.assets));
|
2016-08-02 01:27:25 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core,
|
|
|
|
"info", sizeof(g_defaults.dir.core_info));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.database, g_defaults.dir.port,
|
|
|
|
"database/rdb", sizeof(g_defaults.dir.database));
|
|
|
|
fill_pathname_join(g_defaults.dir.cursor, g_defaults.dir.port,
|
|
|
|
"database/cursors", sizeof(g_defaults.dir.cursor));
|
2016-09-04 02:19:16 -05:00
|
|
|
/* user data*/
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.cheats, user_path,
|
2015-07-27 17:18:10 +02:00
|
|
|
"cheats", sizeof(g_defaults.dir.cheats));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.menu_config, user_path,
|
2016-08-05 02:12:12 +02:00
|
|
|
"config", sizeof(g_defaults.dir.menu_config));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.core_assets, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"downloads", sizeof(g_defaults.dir.core_assets));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.playlist, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"playlists", sizeof(g_defaults.dir.playlist));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.remap, user_path,
|
2015-07-27 17:18:10 +02:00
|
|
|
"remaps", sizeof(g_defaults.dir.remap));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.sram, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"savefiles", sizeof(g_defaults.dir.sram));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.savestate, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"savestates", sizeof(g_defaults.dir.savestate));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.system, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"system", sizeof(g_defaults.dir.system));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.cache, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"temp", sizeof(g_defaults.dir.cache));
|
2016-10-10 11:43:05 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.overlay, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"overlays", sizeof(g_defaults.dir.overlay));
|
2016-10-15 12:54:31 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.thumbnails, user_path,
|
|
|
|
"thumbnails", sizeof(g_defaults.dir.thumbnails));
|
2016-09-04 12:18:27 -05:00
|
|
|
strlcpy(g_defaults.dir.content_history,
|
2016-10-10 11:43:05 +02:00
|
|
|
user_path, sizeof(g_defaults.dir.content_history));
|
|
|
|
fill_pathname_join(g_defaults.path.config, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
|
2016-09-03 23:58:37 -05:00
|
|
|
#else
|
2016-09-09 00:06:13 -05:00
|
|
|
|
2016-09-04 02:19:16 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port,
|
2016-09-04 12:18:27 -05:00
|
|
|
"CORES", sizeof(g_defaults.dir.core));
|
2016-09-04 02:19:16 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.port,
|
2016-09-04 12:18:27 -05:00
|
|
|
"INFO", sizeof(g_defaults.dir.core_info));
|
2016-09-08 23:56:43 -05:00
|
|
|
|
2016-09-09 00:06:13 -05:00
|
|
|
/* bundle data */
|
2016-09-09 00:12:48 -05:00
|
|
|
/*
|
2016-09-09 00:06:13 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port,
|
|
|
|
"BUNDLE/ASSETS", sizeof(g_defaults.dir.assets));
|
|
|
|
fill_pathname_join(g_defaults.dir.autoconfig, g_defaults.dir.port,
|
|
|
|
"BUNDLE/AUTOCONFIG", sizeof(g_defaults.dir.autoconfig));
|
|
|
|
fill_pathname_join(g_defaults.dir.cursor, base_path,
|
|
|
|
"BUNDLE/DATABASE/CURSORS", sizeof(g_defaults.dir.cursor));
|
|
|
|
fill_pathname_join(g_defaults.dir.database, base_path,
|
|
|
|
"BUNDLE/DATABASE/RDB", sizeof(g_defaults.dir.database));
|
|
|
|
fill_pathname_join(g_defaults.dir.overlay, base_path,
|
|
|
|
"BUNDLE/OVERLAYS", sizeof(g_defaults.dir.overlay));
|
|
|
|
fill_pathname_join(g_defaults.dir.shader, base_path,
|
|
|
|
"BUNDLE/SHADERS", sizeof(g_defaults.dir.shader));
|
2016-09-09 00:12:48 -05:00
|
|
|
*/
|
2016-09-09 00:06:13 -05:00
|
|
|
|
2016-09-04 02:19:16 -05:00
|
|
|
/* user data */
|
2016-09-04 01:55:22 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.cheats, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"CHEATS", sizeof(g_defaults.dir.cheats));
|
2016-09-04 01:55:22 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.menu_config, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"CONFIG", sizeof(g_defaults.dir.menu_config));
|
2016-09-04 01:55:22 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.core_assets, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"DOWNLOADS", sizeof(g_defaults.dir.core_assets));
|
|
|
|
fill_pathname_join(g_defaults.dir.playlist, user_path,
|
|
|
|
"PLAYLISTS", sizeof(g_defaults.dir.playlist));
|
2016-09-08 23:56:43 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config,
|
2016-09-04 12:18:27 -05:00
|
|
|
"REMAPS", sizeof(g_defaults.dir.remap));
|
|
|
|
fill_pathname_join(g_defaults.dir.sram, user_path,
|
|
|
|
"SAVEFILES", sizeof(g_defaults.dir.sram));
|
|
|
|
fill_pathname_join(g_defaults.dir.savestate, user_path,
|
|
|
|
"SAVESTATES", sizeof(g_defaults.dir.savestate));
|
2016-09-04 01:55:22 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.screenshot, user_path,
|
2016-09-04 12:18:27 -05:00
|
|
|
"SCREENSHOTS", sizeof(g_defaults.dir.screenshot));
|
|
|
|
fill_pathname_join(g_defaults.dir.system, user_path,
|
|
|
|
"SYSTEM", sizeof(g_defaults.dir.system));
|
2016-09-09 00:12:48 -05:00
|
|
|
/* fill_pathname_join(g_defaults.dir.thumbnails, user_path,
|
|
|
|
"THUMBNAILS", sizeof(g_defaults.dir.thumbnails)); */
|
2016-09-08 23:56:43 -05:00
|
|
|
|
|
|
|
/* cache dir */
|
2016-09-04 12:18:27 -05:00
|
|
|
fill_pathname_join(g_defaults.dir.cache, user_path,
|
|
|
|
"TEMP", sizeof(g_defaults.dir.cache));
|
2016-09-08 23:56:43 -05:00
|
|
|
|
|
|
|
/* history and main config */
|
2016-09-04 12:18:27 -05:00
|
|
|
strlcpy(g_defaults.dir.content_history,
|
|
|
|
user_path, sizeof(g_defaults.dir.content_history));
|
|
|
|
fill_pathname_join(g_defaults.path.config, user_path,
|
|
|
|
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
|
|
|
|
#endif
|
2016-09-09 00:26:20 -05:00
|
|
|
/* create user data dirs */
|
2016-09-04 02:19:16 -05:00
|
|
|
path_mkdir(g_defaults.dir.cheats);
|
2016-09-04 12:18:27 -05:00
|
|
|
path_mkdir(g_defaults.dir.core_assets);
|
|
|
|
path_mkdir(g_defaults.dir.playlist);
|
2016-09-04 02:19:16 -05:00
|
|
|
path_mkdir(g_defaults.dir.menu_config);
|
2016-09-09 00:12:48 -05:00
|
|
|
path_mkdir(g_defaults.dir.playlist);
|
2016-09-04 02:19:16 -05:00
|
|
|
path_mkdir(g_defaults.dir.remap);
|
2016-09-04 12:18:27 -05:00
|
|
|
path_mkdir(g_defaults.dir.savestate);
|
2016-09-04 02:19:16 -05:00
|
|
|
path_mkdir(g_defaults.dir.screenshot);
|
2016-09-04 12:18:27 -05:00
|
|
|
path_mkdir(g_defaults.dir.sram);
|
|
|
|
path_mkdir(g_defaults.dir.system);
|
2016-10-15 12:54:31 +02:00
|
|
|
#ifdef VITA
|
|
|
|
path_mkdir(g_defaults.dir.thumbnails);
|
|
|
|
#endif
|
2016-09-09 00:12:48 -05:00
|
|
|
/* create cache dir */
|
|
|
|
path_mkdir(g_defaults.dir.cache);
|
2015-09-29 00:40:53 +02:00
|
|
|
|
2016-09-08 01:25:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef IS_SALAMANDER
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifdef VITA
|
2016-09-08 16:18:30 +02:00
|
|
|
params = (struct rarch_main_wrap*)params_data;
|
2015-09-02 13:07:13 +02:00
|
|
|
params->verbose = true;
|
|
|
|
#endif
|
2015-12-26 07:45:19 +01:00
|
|
|
if (!string_is_empty(argv[1]))
|
2014-06-03 17:34:25 +02:00
|
|
|
{
|
2016-09-08 16:18:30 +02:00
|
|
|
static char path[PATH_MAX_LENGTH] = {0};
|
2016-10-10 11:43:05 +02:00
|
|
|
struct rarch_main_wrap *args =
|
2016-09-08 16:18:30 +02:00
|
|
|
(struct rarch_main_wrap*)params_data;
|
2014-06-03 17:34:25 +02:00
|
|
|
|
|
|
|
if (args)
|
|
|
|
{
|
|
|
|
strlcpy(path, argv[1], sizeof(path));
|
|
|
|
|
|
|
|
args->touched = true;
|
2014-07-28 19:55:28 +02:00
|
|
|
args->no_content = false;
|
2014-06-03 17:34:25 +02:00
|
|
|
args->verbose = false;
|
|
|
|
args->config_path = NULL;
|
|
|
|
args->sram_path = NULL;
|
|
|
|
args->state_path = NULL;
|
2014-07-28 19:55:28 +02:00
|
|
|
args->content_path = path;
|
2014-06-03 17:34:25 +02:00
|
|
|
args->libretro_path = NULL;
|
|
|
|
|
|
|
|
RARCH_LOG("argv[0]: %s\n", argv[0]);
|
|
|
|
RARCH_LOG("argv[1]: %s\n", argv[1]);
|
|
|
|
RARCH_LOG("argv[2]: %s\n", argv[2]);
|
|
|
|
|
|
|
|
RARCH_LOG("Auto-start game %s.\n", argv[1]);
|
|
|
|
}
|
|
|
|
}
|
2015-01-12 06:51:57 +01:00
|
|
|
#endif
|
2012-11-24 04:23:20 +01:00
|
|
|
}
|
|
|
|
|
2014-06-05 00:17:37 +01:00
|
|
|
static void frontend_psp_deinit(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
#ifndef IS_SALAMANDER
|
2016-05-31 04:42:04 +02:00
|
|
|
verbosity_disable();
|
2014-06-05 00:17:37 +01:00
|
|
|
#ifdef HAVE_FILE_LOGGER
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
|
2014-06-05 00:17:37 +01:00
|
|
|
#endif
|
2014-06-06 04:14:02 +01:00
|
|
|
|
|
|
|
#endif
|
2014-06-05 00:17:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void frontend_psp_shutdown(bool unused)
|
|
|
|
{
|
|
|
|
(void)unused;
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifdef VITA
|
2016-09-08 01:25:14 +02:00
|
|
|
//sceKernelExitProcess(0);
|
|
|
|
return;
|
2015-09-02 13:07:13 +02:00
|
|
|
#else
|
2014-06-05 00:17:37 +01:00
|
|
|
sceKernelExitGame();
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2014-06-05 00:17:37 +01:00
|
|
|
}
|
|
|
|
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifndef VITA
|
2014-06-05 00:17:37 +01:00
|
|
|
static int exit_callback(int arg1, int arg2, void *common)
|
|
|
|
{
|
|
|
|
frontend_psp_deinit(NULL);
|
|
|
|
frontend_psp_shutdown(false);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-09 05:53:58 +02:00
|
|
|
static int callback_thread(SceSize args, void *argp)
|
2012-11-24 04:23:20 +01:00
|
|
|
{
|
|
|
|
int cbid = sceKernelCreateCallback("Exit callback", exit_callback, NULL);
|
|
|
|
sceKernelRegisterExitCallback(cbid);
|
|
|
|
sceKernelSleepThreadCB();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int setup_callback(void)
|
|
|
|
{
|
2014-09-02 17:42:44 +02:00
|
|
|
int thread_id = sceKernelCreateThread("update_thread",
|
|
|
|
callback_thread, 0x11, 0xFA0, 0, 0);
|
2012-11-24 04:23:20 +01:00
|
|
|
|
|
|
|
if (thread_id >= 0)
|
|
|
|
sceKernelStartThread(thread_id, 0, 0);
|
|
|
|
|
|
|
|
return thread_id;
|
|
|
|
}
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2012-11-24 04:23:20 +01:00
|
|
|
|
2014-05-17 14:56:12 +02:00
|
|
|
static void frontend_psp_init(void *data)
|
2012-11-24 04:23:20 +01:00
|
|
|
{
|
2014-06-05 00:17:37 +01:00
|
|
|
#ifndef IS_SALAMANDER
|
2015-08-12 19:30:30 +02:00
|
|
|
|
2016-08-04 01:26:53 +02:00
|
|
|
#ifdef VITA
|
|
|
|
scePowerSetArmClockFrequency(444);
|
|
|
|
sceSysmoduleLoadModule(SCE_SYSMODULE_NET);
|
2016-09-08 20:40:19 +02:00
|
|
|
pthread_init();
|
2016-08-04 01:26:53 +02:00
|
|
|
#else
|
|
|
|
(void)data;
|
2015-08-10 23:29:50 +02:00
|
|
|
/* initialize debug screen */
|
2015-08-30 19:46:19 +02:00
|
|
|
pspDebugScreenInit();
|
2012-11-24 04:23:20 +01:00
|
|
|
pspDebugScreenClear();
|
2015-08-30 19:46:19 +02:00
|
|
|
|
2012-11-24 04:23:20 +01:00
|
|
|
setup_callback();
|
2015-08-30 19:46:19 +02:00
|
|
|
|
2015-08-10 23:29:50 +02:00
|
|
|
pspFpuSetEnable(0); /* disable FPU exceptions */
|
2014-02-18 18:43:23 +01:00
|
|
|
scePowerSetClockFrequency(333,333,166);
|
2014-06-05 00:17:37 +01:00
|
|
|
#endif
|
2016-08-04 01:26:53 +02:00
|
|
|
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2014-06-04 01:35:26 +01:00
|
|
|
|
2014-06-05 00:17:37 +01:00
|
|
|
#if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER)
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifndef VITA
|
2014-06-05 00:17:37 +01:00
|
|
|
pspSdkLoadStartModule("kernel_functions.prx", PSP_MEMORY_PARTITION_KERNEL);
|
2014-06-04 02:52:29 +02:00
|
|
|
#endif
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2013-01-08 08:38:25 +01:00
|
|
|
}
|
2012-11-24 04:23:20 +01:00
|
|
|
|
2014-06-05 00:17:37 +01:00
|
|
|
static void frontend_psp_exec(const char *path, bool should_load_game)
|
2013-01-08 08:38:25 +01:00
|
|
|
{
|
2016-09-08 01:25:14 +02:00
|
|
|
#if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER) || defined(VITA)
|
2015-06-12 23:38:46 +02:00
|
|
|
char argp[512] = {0};
|
|
|
|
SceSize args = 0;
|
2014-06-05 00:17:37 +01:00
|
|
|
|
2016-10-07 08:24:27 +02:00
|
|
|
#if !defined(VITA)
|
2014-06-05 00:17:37 +01:00
|
|
|
strlcpy(argp, eboot_path, sizeof(argp));
|
|
|
|
args = strlen(argp) + 1;
|
2016-10-07 08:24:27 +02:00
|
|
|
#endif
|
2014-06-05 00:17:37 +01:00
|
|
|
|
|
|
|
#ifndef IS_SALAMANDER
|
2016-10-03 15:43:03 +02:00
|
|
|
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT))
|
2014-06-05 00:17:37 +01:00
|
|
|
{
|
|
|
|
argp[args] = '\0';
|
2016-10-03 15:43:03 +02:00
|
|
|
strlcat(argp + args, path_get(RARCH_PATH_CONTENT), sizeof(argp) - args);
|
2014-06-05 00:17:37 +01:00
|
|
|
args += strlen(argp + args) + 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
RARCH_LOG("Attempt to load executable: [%s].\n", path);
|
2016-09-08 01:25:14 +02:00
|
|
|
#if defined(VITA)
|
2016-10-07 08:24:27 +02:00
|
|
|
RARCH_LOG("Attempt to load executable: %d [%s].\n", args, argp);
|
|
|
|
int ret = sceAppMgrLoadExec(path, args==0? NULL : (char * const*)((const char*[]){argp, 0}), NULL);
|
|
|
|
RARCH_LOG("Attempt to load executable: [%d].\n", ret);
|
2016-09-08 01:25:14 +02:00
|
|
|
#else
|
2014-06-05 00:17:37 +01:00
|
|
|
exitspawn_kernel(path, args, argp);
|
2016-09-08 01:25:14 +02:00
|
|
|
#endif
|
2014-06-05 00:17:37 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-02-05 18:43:23 +01:00
|
|
|
#ifndef IS_SALAMANDER
|
2016-02-04 17:46:50 +01:00
|
|
|
static bool frontend_psp_set_fork(enum frontend_fork fork_mode)
|
2014-10-02 21:39:29 +02:00
|
|
|
{
|
2016-02-04 17:46:50 +01:00
|
|
|
switch (fork_mode)
|
|
|
|
{
|
|
|
|
case FRONTEND_FORK_CORE:
|
2016-02-05 18:43:23 +01:00
|
|
|
RARCH_LOG("FRONTEND_FORK_CORE\n");
|
|
|
|
psp_fork_mode = fork_mode;
|
2016-02-04 17:46:50 +01:00
|
|
|
break;
|
|
|
|
case FRONTEND_FORK_CORE_WITH_ARGS:
|
2016-02-05 18:43:23 +01:00
|
|
|
RARCH_LOG("FRONTEND_FORK_CORE_WITH_ARGS\n");
|
|
|
|
psp_fork_mode = fork_mode;
|
2016-02-04 17:46:50 +01:00
|
|
|
break;
|
2016-02-05 18:57:44 +01:00
|
|
|
case FRONTEND_FORK_RESTART:
|
|
|
|
RARCH_LOG("FRONTEND_FORK_RESTART\n");
|
2016-02-05 18:43:23 +01:00
|
|
|
/* NOTE: We don't implement Salamander, so just turn
|
|
|
|
* this into FRONTEND_FORK_CORE. */
|
|
|
|
psp_fork_mode = FRONTEND_FORK_CORE;
|
|
|
|
break;
|
2016-02-04 17:46:50 +01:00
|
|
|
case FRONTEND_FORK_NONE:
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-04 17:08:09 +01:00
|
|
|
|
|
|
|
return true;
|
2014-10-02 21:39:29 +02:00
|
|
|
}
|
2016-02-05 18:43:23 +01:00
|
|
|
#endif
|
2014-06-05 00:17:37 +01:00
|
|
|
|
2015-06-02 18:28:51 +02:00
|
|
|
static void frontend_psp_exitspawn(char *s, size_t len)
|
2014-06-05 00:17:37 +01:00
|
|
|
{
|
|
|
|
bool should_load_game = false;
|
2014-06-05 06:36:30 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2016-02-05 18:43:23 +01:00
|
|
|
if (psp_fork_mode == FRONTEND_FORK_NONE)
|
2014-10-02 21:39:29 +02:00
|
|
|
return;
|
2016-02-05 18:43:23 +01:00
|
|
|
|
|
|
|
switch (psp_fork_mode)
|
|
|
|
{
|
|
|
|
case FRONTEND_FORK_CORE_WITH_ARGS:
|
|
|
|
should_load_game = true;
|
|
|
|
break;
|
|
|
|
case FRONTEND_FORK_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-06-05 00:17:37 +01:00
|
|
|
#endif
|
2015-06-02 18:28:51 +02:00
|
|
|
frontend_psp_exec(s, should_load_game);
|
2013-01-08 08:38:25 +01:00
|
|
|
}
|
|
|
|
|
2014-05-16 22:20:33 +02:00
|
|
|
static int frontend_psp_get_rating(void)
|
|
|
|
{
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifdef VITA
|
|
|
|
return 6; /* Go with a conservative figure for now. */
|
|
|
|
#else
|
2014-05-16 22:20:33 +02:00
|
|
|
return 4;
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2014-05-16 22:20:33 +02:00
|
|
|
}
|
|
|
|
|
2015-04-18 15:28:06 +02:00
|
|
|
static enum frontend_powerstate frontend_psp_get_powerstate(int *seconds, int *percent)
|
|
|
|
{
|
|
|
|
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifndef VITA
|
|
|
|
int battery = scePowerIsBatteryExist();
|
|
|
|
#endif
|
2015-04-18 15:28:06 +02:00
|
|
|
int plugged = scePowerIsPowerOnline();
|
|
|
|
int charging = scePowerIsBatteryCharging();
|
|
|
|
|
|
|
|
*percent = scePowerGetBatteryLifePercent();
|
|
|
|
*seconds = scePowerGetBatteryLifeTime() * 60;
|
|
|
|
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifndef VITA
|
2015-04-18 15:28:06 +02:00
|
|
|
if (!battery)
|
|
|
|
{
|
|
|
|
ret = FRONTEND_POWERSTATE_NO_SOURCE;
|
|
|
|
*seconds = -1;
|
|
|
|
*percent = -1;
|
|
|
|
}
|
2015-08-12 12:33:27 +02:00
|
|
|
else
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2015-08-12 12:33:27 +02:00
|
|
|
if (charging)
|
2015-04-18 15:28:06 +02:00
|
|
|
ret = FRONTEND_POWERSTATE_CHARGING;
|
|
|
|
else if (plugged)
|
|
|
|
ret = FRONTEND_POWERSTATE_CHARGED;
|
|
|
|
else
|
|
|
|
ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-18 20:03:59 +02:00
|
|
|
enum frontend_architecture frontend_psp_get_architecture(void)
|
|
|
|
{
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifdef VITA
|
2016-05-18 22:09:01 +02:00
|
|
|
return FRONTEND_ARCH_ARMV7;
|
2015-09-02 13:07:13 +02:00
|
|
|
#else
|
2015-04-18 20:03:59 +02:00
|
|
|
return FRONTEND_ARCH_MIPS;
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2015-04-18 20:03:59 +02:00
|
|
|
}
|
|
|
|
|
2015-06-15 22:45:02 +02:00
|
|
|
static int frontend_psp_parse_drive_list(void *data)
|
|
|
|
{
|
|
|
|
#ifndef IS_SALAMANDER
|
|
|
|
file_list_t *list = (file_list_t*)data;
|
|
|
|
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifdef VITA
|
2016-10-15 12:54:31 +02:00
|
|
|
menu_entries_append_enum(list,
|
2016-12-13 01:43:18 +01:00
|
|
|
"app0:/",
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
|
|
|
MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR,
|
|
|
|
MENU_SETTING_ACTION, 0, 0);
|
2016-08-03 01:15:06 +02:00
|
|
|
menu_entries_append_enum(list,
|
2016-12-13 01:43:18 +01:00
|
|
|
"ur0:/",
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
|
|
|
MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR,
|
|
|
|
MENU_SETTING_ACTION, 0, 0);
|
2016-07-13 01:17:09 +02:00
|
|
|
menu_entries_append_enum(list,
|
2016-12-13 01:43:18 +01:00
|
|
|
"ux0:/",
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
|
|
|
MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR,
|
|
|
|
MENU_SETTING_ACTION, 0, 0);
|
2015-09-02 13:07:13 +02:00
|
|
|
#else
|
2016-07-13 01:17:09 +02:00
|
|
|
menu_entries_append_enum(list,
|
2016-12-13 01:43:18 +01:00
|
|
|
"ms0:/",
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
|
|
|
MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR,
|
|
|
|
MENU_SETTING_ACTION, 0, 0);
|
2016-07-13 01:17:09 +02:00
|
|
|
menu_entries_append_enum(list,
|
2016-12-13 01:43:18 +01:00
|
|
|
"ef0:/",
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
|
|
|
MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR,
|
|
|
|
MENU_SETTING_ACTION, 0, 0);
|
2016-07-13 01:17:09 +02:00
|
|
|
menu_entries_append_enum(list,
|
2016-12-13 01:43:18 +01:00
|
|
|
"host0:/",
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
|
|
|
MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR,
|
|
|
|
MENU_SETTING_ACTION, 0, 0);
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2015-06-15 22:45:02 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-27 03:44:28 +02:00
|
|
|
frontend_ctx_driver_t frontend_ctx_psp = {
|
2015-04-18 15:28:06 +02:00
|
|
|
frontend_psp_get_environment_settings,
|
|
|
|
frontend_psp_init,
|
|
|
|
frontend_psp_deinit,
|
|
|
|
frontend_psp_exitspawn,
|
2014-06-03 19:21:49 +02:00
|
|
|
NULL, /* process_args */
|
2015-04-18 15:28:06 +02:00
|
|
|
frontend_psp_exec,
|
2016-02-05 18:43:23 +01:00
|
|
|
#ifdef IS_SALAMANDER
|
|
|
|
NULL,
|
|
|
|
#else
|
2015-04-18 15:28:06 +02:00
|
|
|
frontend_psp_set_fork,
|
2016-02-05 18:43:23 +01:00
|
|
|
#endif
|
2015-04-18 15:28:06 +02:00
|
|
|
frontend_psp_shutdown,
|
2014-06-12 16:26:33 +02:00
|
|
|
NULL, /* get_name */
|
2015-04-07 22:48:46 +02:00
|
|
|
NULL, /* get_os */
|
2015-04-18 15:28:06 +02:00
|
|
|
frontend_psp_get_rating,
|
2014-10-17 03:55:16 +02:00
|
|
|
NULL, /* load_content */
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_psp_get_architecture,
|
2015-04-18 15:28:06 +02:00
|
|
|
frontend_psp_get_powerstate,
|
2015-06-15 22:45:02 +02:00
|
|
|
frontend_psp_parse_drive_list,
|
2016-06-12 02:33:07 +02:00
|
|
|
NULL, /* get_mem_total */
|
2016-06-12 12:44:28 +02:00
|
|
|
NULL, /* get_mem_free */
|
2016-07-08 02:10:40 +02:00
|
|
|
NULL, /* install_signal_handler */
|
2016-07-08 02:20:42 +02:00
|
|
|
NULL, /* get_sighandler_state */
|
2016-07-08 12:48:01 +02:00
|
|
|
NULL, /* set_sighandler_state */
|
2016-07-08 02:24:56 +02:00
|
|
|
NULL, /* destroy_sighandler_state */
|
2016-10-09 17:15:50 +02:00
|
|
|
NULL, /* attach_console */
|
|
|
|
NULL, /* detach_console */
|
2015-09-02 13:07:13 +02:00
|
|
|
#ifdef VITA
|
|
|
|
"vita",
|
|
|
|
#else
|
2013-07-27 03:59:01 +02:00
|
|
|
"psp",
|
2015-09-02 13:07:13 +02:00
|
|
|
#endif
|
2013-07-27 03:59:01 +02:00
|
|
|
};
|