Add Ps2 Support

This commit is contained in:
Francisco Javier Trujillo Mata
2021-02-07 21:03:24 +01:00
parent 2f077a6e3a
commit c684af3563
6 changed files with 99 additions and 3 deletions
+11 -1
View File
@@ -62,7 +62,11 @@ include:
# Nintendo Switch
- project: 'libretro-infrastructure/ci-templates'
file: '/libnx-static.yml'
# PlayStation 2
- project: 'libretro-infrastructure/ci-templates'
file: '/ps2-static.yml'
# PlayStation Portable
- project: 'libretro-infrastructure/ci-templates'
file: '/psp-static.yml'
@@ -140,6 +144,12 @@ android-x86:
- .core-defs
################################### CONSOLES #################################
# PlayStation 2
libretro-build-ps2:
extends:
- .libretro-ps2-static-retroarch-master
- .core-defs
# PlayStation Portable
libretro-build-psp:
extends:
+12 -2
View File
@@ -179,9 +179,19 @@ else ifeq ($(platform), psl1ght)
STATIC_LINKING = 1
HAVE_COMPAT = 1
# PS2
else ifeq ($(platform), ps2)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT)
AR = mips64r5900el-ps2-elf-ar$(EXE_EXT)
PLATFORM_DEFINES := -DPS2 -D_EE -DABGR1555 -G0 -O3
STATIC_LINKING = 1
HAVE_COMPAT = 1
EXTRA_INCLUDES := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include
# PSP
else ifeq ($(platform), psp1)
TARGET := $(TARGET_NAME)_libretro_psp1.a
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = psp-gcc$(EXE_EXT)
AR = psp-ar$(EXE_EXT)
PLATFORM_DEFINES := -DPSP
@@ -489,7 +499,7 @@ include Makefile.common
HEADERS += $(ROMS:.rom=.h) $(SNAPS:.szx=.h)
OBJECTS += $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o)
INCDIRS := $(EXTRA_INCLUDES) $(INCFLAGS)
INCDIRS := $(INCFLAGS) $(EXTRA_INCLUDES)
OBJOUT = -o
LINKOUT = -o
+4
View File
@@ -568,6 +568,10 @@
code using `volatile' can become incorrect without. Disable with care. */
/* #undef volatile */
#if defined(PS2)
#undef HAVE_CHMOD
#endif
#if defined(VITA) || defined(PSP)
#undef HAVE_CHMOD
+2
View File
@@ -29,6 +29,8 @@ void genode_free_secondary_stack(void *stack);
#include "ppc.c"
#elif defined(__aarch64__)
#include "aarch64.c"
#elif defined(PS2)
#include "ps2.c"
#elif defined(PSP)
#include "psp1.c"
#elif defined VITA
+66
View File
@@ -0,0 +1,66 @@
#define LIBCO_C
#include "libco.h"
#include <stdlib.h>
#include <stdint.h>
#include <kernel.h>
/* Since cothread_t is a void pointer it must contain an address. We can't return a reference to a local variable
* because it would go out of scope, so we create a static variable instead so we can return a reference to it.
*/
static int32_t active_thread_id = -1;
extern void *_gp;
cothread_t co_active()
{
active_thread_id = GetThreadId();
return &active_thread_id;
}
cothread_t co_create(unsigned int size, void (*entrypoint)(void))
{
/* Similar scenario as with active_thread_id except there will only be one active_thread_id while there could be many
* new threads each with their own handle, so we create them on the heap instead and delete them manually when they're
* no longer needed in co_delete().
*/
cothread_t handle = malloc(sizeof(cothread_t));
ee_thread_t thread;
// u8 threadStack[size/8] __attribute__ ((aligned(16)));
void *threadStack = (void *)malloc(size);
if ( threadStack== NULL)
{
printf("libco: ERROR: creating threadStack\n");
return(-1);
}
thread.stack_size = size;
thread.gp_reg = &_gp;
thread.func = (void *)entrypoint;
thread.stack = threadStack;
thread.option = 0;
thread.initial_priority = 1;
int32_t new_thread_id = CreateThread(&thread);
if (new_thread_id < 0)
printf("libco: ERROR: creating thread\n");
StartThread(new_thread_id, NULL);
*(uint32_t *)handle = new_thread_id;
return handle;
}
void co_delete(cothread_t handle)
{
TerminateThread(*(uint32_t *)handle);
DeleteThread(*(uint32_t *)handle);
free(handle);
}
void co_switch(cothread_t handle)
{
WakeupThread(*(uint32_t *)handle);
/* Sleep the currently active thread so the new thread can start */
SleepThread();
}
+4
View File
@@ -59,8 +59,12 @@ extern int pauseg;
#ifndef RENDER16B
#define RGB565(r, g, b) (((r) << (5+16)) | ((g) << (5+8)) | (b<<5))
#else
#if defined(ABGR1555)
#define RGB565(r, g, b) (((b) << (10)) | ((g) << 5) | (r))
#else
#define RGB565(r, g, b) (((r) << (5+6)) | ((g) << 6) | (b))
#endif
#endif
#define uint32 unsigned int
#define uint8 unsigned char
#endif