Skip to content
Permalink
Browse files
Merge pull request #5570 from rbalint/mips
Mips port
  • Loading branch information
wsnipex committed Feb 1, 2015
2 parents 4aa711b + 796839b commit b217174
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 29 deletions.
@@ -439,7 +439,7 @@ ifeq (@USE_ASAP_CODEC@,1)
endif
endif
$(MAKE) -C lib/stsound/StSoundLibrary
ifeq ($(or $(findstring powerpc,@ARCH@),$(findstring x86_64-linux,@ARCH@),$(findstring arm, @ARCH@),$(findstring freebsd,@ARCH@)),)
ifeq ($(or $(findstring powerpc,@ARCH@),$(findstring x86_64-linux,@ARCH@),$(findstring arm, @ARCH@),$(findstring freebsd,@ARCH@),$(findstring mips,@ARCH@)),)
$(MAKE) -C lib/snesapu/SNES/SNESAPU
endif
imagelib: dllloader
@@ -55,8 +55,8 @@ typedef intptr_t ssize_t;
#define ADDON_HELPER_ARCH "powerpc64-linux"
#elif defined(__ARMEL__)
#define ADDON_HELPER_ARCH "arm"
#elif defined(_MIPSEL)
#define ADDON_HELPER_ARCH "mipsel-linux"
#elif defined(__mips__)
#define ADDON_HELPER_ARCH "mips"
#else
#define ADDON_HELPER_ARCH "i486-linux"
#endif
@@ -689,6 +689,16 @@ case $host in
use_wayland=no
build_shared_lib=yes
;;
mips*-*-linux-gnu*)
ARCH="mips"
use_arch="mips"
use_joystick=no
use_gles=no
use_gl=yes
use_sdl=yes
use_wayland=no
USE_STATIC_FFMPEG=1
;;
*)
AC_MSG_ERROR(unsupported host ($host))
esac
@@ -32,6 +32,9 @@ case $host in
arm*-*-linux-gnu*|arm*-*-linux-uclibc*)
AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
;;
mips*-*-linux-gnu*|mips*-*-linux-uclibc*)
AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
;;
*-*linux-android*)
AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID")
;;
@@ -49,6 +49,9 @@ endif
ifeq ($(findstring arm, $(CPU)), arm)
ffmpg_config += --enable-pic --disable-armv5te --disable-armv6t2
endif
ifeq ($(findstring mips, $(CPU)), mips)
ffmpg_config += --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2
endif
ifeq ($(Configuration), Release)
ffmpg_config += --disable-debug
endif
@@ -156,6 +156,9 @@ CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" \
--enable-nonfree \
--enable-pthreads \
--enable-zlib \
--disable-mips32r2 \
--disable-mipsdspr1 \
--disable-mipsdspr2 \
${FLAGS}

make -j ${BUILDTHREADS}
@@ -23,7 +23,7 @@
#include "coffldr.h"
#include "LibraryLoader.h"

#if defined(__linux__) && !defined(__powerpc__) && !defined(__arm__)
#if defined(__linux__) && !defined(__powerpc__) && !defined(__arm__) && !defined(__mips__)
#define USE_LDT_KEEPER
#include "ldt_keeper.h"
#endif
@@ -19,7 +19,7 @@
*/

//#ifndef __powerpc__
#if !defined(__powerpc__) && !defined(__ppc__) && !defined(__arm__)
#if !defined(__powerpc__) && !defined(__ppc__) && !defined(__arm__) && !defined(__mips__)

#include "ldt_keeper.h"

@@ -325,7 +325,7 @@ class CLinuxRendererGL : public CBaseRenderer


inline int NP2( unsigned x ) {
#if defined(TARGET_POSIX) && !defined(__POWERPC__) && !defined(__PPC__) && !defined(__arm__)
#if defined(TARGET_POSIX) && !defined(__POWERPC__) && !defined(__PPC__) && !defined(__arm__) && !defined(__mips__)
// If there are any issues compiling this, just append a ' && 0'
// to the above to make it '#if defined(TARGET_POSIX) && 0'

@@ -161,7 +161,7 @@
#define __int64 long long
#define __uint64 unsigned long long

#if defined(__x86_64__) || defined(__powerpc__) || defined(__ppc__) || defined (__arm__) // should this be powerpc64 only?
#if defined(__x86_64__) || defined(__powerpc__) || defined(__ppc__) || defined (__arm__) || defined(__mips__) // should this be powerpc64 only?
#define __stdcall
#else /* !__x86_64__ */
#define __stdcall __attribute__((__stdcall__))
@@ -20,6 +20,12 @@

#include "Atomics.h"
#include "system.h"

#if defined(__mips__)
#include "MipsAtomics.h"
pthread_mutex_t cmpxchg_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif

///////////////////////////////////////////////////////////////////////////
// 32-bit atomic compare-and-swap
// Returns previous value of *pAddr
@@ -63,10 +69,7 @@ long cas(volatile long *pAddr, long expectedVal, long swapVal)
return prev;

#elif defined(__mips__)
// TODO:
unsigned int prev;
#error atomic cas undefined for mips
return prev;
return cmpxchg32(pAddr, expectedVal, swapVal);

#elif defined(TARGET_WINDOWS)
long prev;
@@ -103,11 +106,14 @@ long cas(volatile long *pAddr, long expectedVal, long swapVal)
///////////////////////////////////////////////////////////////////////////
long long cas2(volatile long long* pAddr, long long expectedVal, long long swapVal)
{
#if defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || defined(__mips__) // PowerPC, ARM, and MIPS
#if defined(__ppc__) || defined(__powerpc__) || defined(__arm__)// PowerPC and ARM
// Not available/required
// Hack to allow compilation
throw "cas2 is not implemented";

#elif defined(__mips__)
return cmpxchg64(pAddr, expectedVal, swapVal);

#elif defined(TARGET_WINDOWS)
long long prev;
__asm
@@ -183,10 +189,7 @@ long AtomicIncrement(volatile long* pAddr)
return val;

#elif defined(__mips__)
// TODO:
long val;
#error AtomicIncrement undefined for mips
return val;
return atomic_add(1, pAddr);

#elif defined(TARGET_WINDOWS)
long val;
@@ -261,10 +264,7 @@ long AtomicAdd(volatile long* pAddr, long amount)
return val;

#elif defined(__mips__)
// TODO:
long val;
#error AtomicAdd undefined for mips
return val;
return atomic_add(amount, pAddr);

#elif defined(TARGET_WINDOWS)
__asm
@@ -339,10 +339,7 @@ long AtomicDecrement(volatile long* pAddr)
return val;

#elif defined(__mips__)
// TODO:
long val;
#error AtomicDecrement undefined for mips
return val;
return atomic_sub(1, pAddr);

#elif defined(TARGET_WINDOWS)
long val;
@@ -418,9 +415,7 @@ long AtomicSubtract(volatile long* pAddr, long amount)
return val;

#elif defined(__mips__)
// TODO:
#error AtomicSubtract undefined for mips
return val;
return atomic_sub(amount, pAddr);

#elif defined(TARGET_WINDOWS)
amount *= -1;
@@ -0,0 +1,110 @@
/*
* Copyright (C) 2014 Team XBMC
* http://www.xbmc.org
*
* This Program 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 Foundation; either version 2, or (at your option)
* any later version.
*
* This Program 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 XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2003, 06, 07 by Ralf Baechle (ralf@linux-mips.org)
*
* Most of this file was borrowed from the linux kernel.
*/

#pragma once

#include <inttypes.h>
#include <pthread.h>

extern pthread_mutex_t cmpxchg_mutex;

static inline long cmpxchg32(volatile long *m, long oldval, long newval)
{
long retval;
__asm__ __volatile__( \
" .set push \n" \
" .set noat \n" \
" .set mips3 \n" \
"1: ll %0, %2 # __cmpxchg_asm \n" \
" bne %0, %z3, 2f \n" \
" .set mips0 \n" \
" move $1, %z4 \n" \
" .set mips3 \n" \
" sc $1, %1 \n" \
" beqz $1, 3f \n" \
"2: \n" \
" .subsection 2 \n" \
"3: b 1b \n" \
" .previous \n" \
" .set pop \n" \
: "=&r" (retval), "=R" (*m) \
: "R" (*m), "Jr" (oldval), "Jr" (newval) \
: "memory"); \

return retval;
}


static inline long long cmpxchg64(volatile long long *ptr,
long long oldval, long long newval)
{
long long prev;

pthread_mutex_lock(&cmpxchg_mutex);
prev = *(long long *)ptr;
if (prev == oldval)
*(long long *)ptr = newval;
pthread_mutex_unlock(&cmpxchg_mutex);
return prev;
}


static __inline__ long atomic_add(int i, volatile long* v)
{
long temp;

__asm__ __volatile__(
" .set mips3 \n"
"1: ll %0, %1 # atomic_add \n"
" addu %0, %2 \n"
" sc %0, %1 \n"
" beqz %0, 2f \n"
" .subsection 2 \n"
"2: b 1b \n"
" .previous \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (*v)
: "Ir" (i), "m" (*v));

return temp;
}

static __inline__ long atomic_sub(int i, volatile long* v)
{
long temp;

__asm__ __volatile__(
" .set mips3 \n"
"1: ll %0, %1 # atomic_sub \n"
" subu %0, %2 \n"
" sc %0, %1 \n"
" beqz %0, 2f \n"
" .subsection 2 \n"
"2: b 1b \n"
" .previous \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (*v)
: "Ir" (i), "m" (*v));

return temp;
}
@@ -34,6 +34,7 @@

#if defined(__ppc__) || \
defined(__powerpc__) || \
defined(__mips__) || \
defined(__arm__)
#define DISABLE_MATHUTILS_ASM_ROUND_INT
#endif
@@ -25,7 +25,7 @@
* <http://www.gnu.org/licenses/>.
*
*/
#if !defined(TARGET_WINDOWS) && !defined(__ppc__) && !defined(__powerpc__) && !defined(__arm__)
#if !defined(TARGET_WINDOWS) && !defined(__ppc__) && !defined(__powerpc__) && !defined(__arm__) && !defined(__mips__)
#define HAVE_MMX2
#define HAVE_SSE

@@ -23,7 +23,7 @@
extern "C" {
#endif

#if !defined(TARGET_WINDOWS) && !defined(__ppc__) && !defined(__powerpc__) && !defined(TARGET_ANDROID) && !defined(TARGET_DARWIN_IOS)
#if !defined(TARGET_WINDOWS) && !defined(__ppc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(TARGET_ANDROID) && !defined(TARGET_DARWIN_IOS)
void * fast_memcpy(void * to, const void * from, size_t len);
//#define fast_memcpy memcpy
#else

0 comments on commit b217174

Please sign in to comment.