Skip to content

Commit

Permalink
riscos: Add CPU feature detection
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Jan 6, 2020
1 parent eb3d39b commit 78ce18f
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions src/cpuinfo/SDL_cpuinfo.c
Expand Up @@ -90,6 +90,11 @@
#endif
#endif

#ifdef __RISCOS__
#include <kernel.h>
#include <swis.h>
#endif

#define CPU_HAS_RDTSC (1 << 0)
#define CPU_HAS_ALTIVEC (1 << 1)
#define CPU_HAS_MMX (1 << 2)
Expand Down Expand Up @@ -333,7 +338,7 @@ CPU_haveAltiVec(void)
return altivec;
}

#if !defined(__ARM_ARCH)
#if !defined(__arm__)
static int
CPU_haveARMSIMD(void)
{
Expand Down Expand Up @@ -373,6 +378,27 @@ CPU_haveARMSIMD(void)
return arm_simd;
}

#elif defined(__RISCOS__)

static int
CPU_haveARMSIMD(void)
{
_kernel_swi_regs regs;
regs.r[0] = 0;
if (_kernel_swi(OS_PlatformFeatures, &regs, &regs) != NULL)
return 0;

if (!(regs.r[0] & (1<<31)))
return 0;

regs.r[0] = 34;
regs.r[1] = 29;
if (_kernel_swi(OS_PlatformFeatures, &regs, &regs) != NULL)
return 0;

return regs.r[0];
}

#else
static int
CPU_haveARMSIMD(void)
Expand Down Expand Up @@ -419,7 +445,7 @@ CPU_haveNEON(void)
# endif
/* All WinRT ARM devices are required to support NEON, but just in case. */
return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
#elif !defined(__ARM_ARCH)
#elif !defined(__arm__)
return 0; /* not an ARM CPU at all. */
#elif __ARM_ARCH >= 8
return 1; /* ARMv8 always has non-optional NEON support. */
Expand All @@ -446,6 +472,18 @@ CPU_haveNEON(void)
}
return 0;
}
#elif defined(__RISCOS__)
/* Use the VFPSupport_Features SWI to access the MVFR registers */
{
_kernel_swi_regs regs;
regs.r[0] = 0;
if (_kernel_swi(VFPSupport_Features, &regs, &regs) == NULL) {
if ((regs.r[2] & 0xFFF000) == 0x111000) {
return 1;
}
}
return 0;
}
#else
#warning SDL_HasNEON is not implemented for this ARM platform. Write me.
return 0;
Expand Down Expand Up @@ -871,6 +909,15 @@ SDL_GetSystemRAM(void)
SDL_SystemRAM = (int) (sysram / 0x100000U);
}
#endif
#ifdef __RISCOS__
if (SDL_SystemRAM <= 0) {
_kernel_swi_regs regs;
regs.r[0] = 0x108;
if (_kernel_swi(OS_Memory, &regs, &regs) == NULL) {
SDL_SystemRAM = (int)(regs.r[1] * regs.r[2] / (1024 * 1024));
}
}
#endif
#endif
}
return SDL_SystemRAM;
Expand Down

0 comments on commit 78ce18f

Please sign in to comment.