mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-01-06 08:53:36 +01:00
60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
//---
|
|
// gint:core:mpu - Runtime MPU detection
|
|
//
|
|
// This component detects the architecture and MPU type of the underlying
|
|
// hardware by relying on version registers and/or side-information. It
|
|
// provides macros isSH3() and isSH4(), but the best way of performing
|
|
// MPU-dependent jobs is to use mpuSwitch():
|
|
//
|
|
// mpuSwitch(
|
|
// print("SH3 code"),
|
|
// print("SH4 code")
|
|
// );
|
|
//---
|
|
|
|
#ifndef GINT_CORE_MPU
|
|
#define GINT_CORE_MPU
|
|
|
|
#include <defs/attributes.h>
|
|
|
|
/* mpu_t - supported MPUs */
|
|
typedef enum
|
|
{
|
|
mpu_unknown = 0,
|
|
mpu_sh7337 = 1, /* fx9860g, SH-3 based */
|
|
mpu_sh7305 = 2, /* fx9860g II, fxcg50, SH-4A based */
|
|
mpu_sh7355 = 3, /* fx9860g II, SH-3 based */
|
|
mpu_sh7724 = 4, /* For reference */
|
|
} mpu_t;
|
|
|
|
#ifdef FX9860G
|
|
|
|
/* mpu_id() - get the name of the underlying MPU */
|
|
HDRFUNC mpu_t mpu_id(void)
|
|
{
|
|
extern const mpu_t mpu;
|
|
return mpu;
|
|
}
|
|
|
|
/* Quick SH-3/SH-4 tests. Unknown models are assumed to be SH-4A */
|
|
#define isSH3() (mpu_id() & 1)
|
|
#define isSH4() (!isSH3())
|
|
|
|
#define mpuSwitch(a, b) do { if(isSH3()) { a; } else { b; } } while(0)
|
|
|
|
/* mpu_init() - probe the MPU type
|
|
This function must be executed before mpu_id() can be used. */
|
|
void mpu_init(void);
|
|
|
|
#else /* FXCG50 */
|
|
|
|
/* All fxcg50 machines have an SH7305, which makes things simpler. */
|
|
#define mpu_id() mpu_sh7305
|
|
#define isSH3() 0
|
|
#define isSH4() 1
|
|
|
|
#define mpuSwitch(a, b) do { b; } while(0)
|
|
|
|
#endif /* FX9860G */
|
|
|
|
#endif /* GINT_CORE_MPU */
|