periodic check of SH3 compatibility

This commit is contained in:
Lephe 2020-05-31 22:26:30 +02:00
parent 50cc536324
commit 0498344349
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
4 changed files with 36 additions and 7 deletions

View File

@ -24,7 +24,8 @@
extern uint32_t gint[HW_KEYS];
/* MPU detection macros, with a faster version on fx-CG 50 and a generic
dual-platform version for libraries. */
dual-platform version for libraries.
Warning: this macro is also used hardcoded in exch.s. */
#if defined(FX9860G) || (!defined(FX9860G) && !defined(FXCG50))
#define isSH3() (gint[HWMPU] & 1)
@ -75,7 +76,7 @@ void hw_detect(void);
#define HWMPU_UNKNOWN 0
/* Used on original fx-9860G, SH-3-based */
#define HWMPU_SH7337 1
/* Used on recent fx-9860G derivates such as the fx-9750G II, and also on the
/* Used on recent fx-9860G derivatives such as the fx-9750G II, and also on the
fx-CG 10/20/50. SH-4A-based */
#define HWMPU_SH7305 2
/* Used on the fx-9860G II, SH-3-based */

View File

@ -11,8 +11,18 @@
/* gint_panic_default(): Default panic handler */
GNORETURN static void gint_default_panic(GUNUSED uint32_t code)
{
uint32_t TEA = *(volatile uint32_t *)0xff00000c;
uint32_t TRA = *(volatile uint32_t *)0xff000020 >> 2;
uint32_t TEA, TRA;
if(isSH3())
{
TEA = *(volatile uint32_t *)0xfffffffc;
TRA = *(volatile uint32_t *)0xffffffd0 >> 2;
}
else
{
TEA = *(volatile uint32_t *)0xff00000c;
TRA = *(volatile uint32_t *)0xff000020 >> 2;
}
uint32_t PC;
__asm__("stc spc, %0" : "=r"(PC));

View File

@ -4,10 +4,21 @@
_gint_exch_tlbh:
sts.l pr, @-r15
stc.l gbr, @-r15
sts.l mach, @-r15
sts.l macl, @-r15
mov.l r8, @-r15
mov.l .expevt, r8
/* Get the first word of the gint hardware array (HWMPU). If it has the
last bit set, we're SH3 */
mov.l .gint, r0
mov.l @r0, r0
tst #1, r0
mov.l .expevt_sh4, r8
bt catch
mov.l .expevt_sh3, r8
catch:
/* Panic if the catcher is NULL */
mov.l .catcher, r0
mov.l @r0, r0
@ -39,14 +50,21 @@ panic:
end:
mov.l @r15+, r8
lds.l @r15+, macl
lds.l @r15+, mach
ldc.l @r15+, gbr
lds.l @r15+, pr
rte
nop
.align 4
.expevt:
.gint:
.long _gint
.expevt_sh4:
.long 0xff000024
.expevt_sh3:
.long 0xffffffd4
.catcher:
.long _gint_exc_catcher
.panic:

View File

@ -101,7 +101,7 @@ void hw_detect(void)
/* Will be detected later on */
gint[HWURAM] = -1;
/* Traditionally 4 MiB, Graph 35+E II has 8 MiB */
gint[HWROM] = (gint[HWCALC] == HWCALC_G35PE2) ? (4 << 20) : (8 << 20);
gint[HWROM] = (gint[HWCALC] == HWCALC_G35PE2) ? (8 << 20) : (4 << 20);
}
#endif /* FX9860G and platform-agnostic */