mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
fxcg50: remove rram region and fxcg20-friendly VBR address
This change removes the RRAM region which was inherited from the fx9860g memory layout but no longer relevant on fxcg50. This removed one occurrence of a hardcoded user stack address in the linker script, the other being the VBR address. But since the VBR only contains position-independent code that is manually "relocated" at startup, the linker script needs not actually use its value, so this is not a true dependency. gint should now more or less be able to boot up on an fxcg20, except for the hardcoded VRAM addresses which need to be moved to the fxcg20 system stack.
This commit is contained in:
parent
2fd4238d31
commit
4a3c396284
4 changed files with 35 additions and 16 deletions
|
@ -201,7 +201,7 @@ SECTIONS
|
||||||
There's an unused 0x100-byte gap at the start of the VBR space.
|
There's an unused 0x100-byte gap at the start of the VBR space.
|
||||||
The VBR space is already a large block (> 2 kiB), so I'm cutting off
|
The VBR space is already a large block (> 2 kiB), so I'm cutting off
|
||||||
the gap to spare some memory */
|
the gap to spare some memory */
|
||||||
_gint_vbr = 0x8800df00;
|
_gint_vbr_fx9860g = 0x8800df00;
|
||||||
|
|
||||||
. = ORIGIN(rram);
|
. = ORIGIN(rram);
|
||||||
|
|
||||||
|
|
21
fxcg50.ld
21
fxcg50.ld
|
@ -16,11 +16,13 @@ MEMORY
|
||||||
rom (rx): o = 0x00300000, l = 2M
|
rom (rx): o = 0x00300000, l = 2M
|
||||||
/* Static RAM; stack grows down from the end of this region.
|
/* Static RAM; stack grows down from the end of this region.
|
||||||
The first 0x2000 bytes are reserved by gint, see below */
|
The first 0x2000 bytes are reserved by gint, see below */
|
||||||
ram (rw): o = 0x08102000, l = 504k
|
ram (rw): o = 0x08101400, l = 507k
|
||||||
/* gint's VBR space, at the start of the user stack */
|
/* gint's VBR space at the start of the user stack on fx-CG 50 and on
|
||||||
vbr (rwx): o = 0x8c160000, l = 5k
|
fx-CG 20. This address needs not be determined now because VBR code
|
||||||
/* gint's data resides in these few kilobytes before the user area */
|
is position-independent and stored in ROM so the linker doesn't even
|
||||||
rram (rwx): o = 0x8c161400, l = 3k
|
need to know the value */
|
||||||
|
vbr50 (rwx): o = 0x8c160000, l = 5k
|
||||||
|
vbr20 (rwx): o = 0x88160000, l = 5k
|
||||||
/* On-chip IL memory */
|
/* On-chip IL memory */
|
||||||
ilram (rwx): o = 0xe5200000, l = 4k
|
ilram (rwx): o = 0xe5200000, l = 4k
|
||||||
/* On-chip X and Y memory */
|
/* On-chip X and Y memory */
|
||||||
|
@ -189,9 +191,10 @@ SECTIONS
|
||||||
There's an unused 0x100-byte gap at the start of the VBR space.
|
There's an unused 0x100-byte gap at the start of the VBR space.
|
||||||
The VBR space is already a large block (> 2 kiB), so I'm cutting off
|
The VBR space is already a large block (> 2 kiB), so I'm cutting off
|
||||||
the gap to spare some memory */
|
the gap to spare some memory */
|
||||||
_gint_vbr = ORIGIN(vbr) - 0x100;
|
_gint_vbr_fxcg50 = ORIGIN(vbr50) - 0x100;
|
||||||
|
_gint_vbr_fxcg20 = ORIGIN(vbr20) - 0x100;
|
||||||
|
|
||||||
. = ORIGIN(rram);
|
. = ORIGIN(ram) + _sbss + _sdata;
|
||||||
|
|
||||||
/* gint's data section, going to static RAM. This section contains many
|
/* gint's data section, going to static RAM. This section contains many
|
||||||
small objects from the library (static/global variables, etc) */
|
small objects from the library (static/global variables, etc) */
|
||||||
|
@ -202,7 +205,7 @@ SECTIONS
|
||||||
*(.gint.data .gint.data.*)
|
*(.gint.data .gint.data.*)
|
||||||
|
|
||||||
. = ALIGN(16);
|
. = ALIGN(16);
|
||||||
} > rram AT> rom
|
} > ram AT> rom
|
||||||
|
|
||||||
_sgdata = SIZEOF(.gint.data);
|
_sgdata = SIZEOF(.gint.data);
|
||||||
|
|
||||||
|
@ -213,7 +216,7 @@ SECTIONS
|
||||||
*(.gint.bss .gint.bss.*)
|
*(.gint.bss .gint.bss.*)
|
||||||
|
|
||||||
. = ALIGN(16);
|
. = ALIGN(16);
|
||||||
} > rram :NONE
|
} > ram :NONE
|
||||||
|
|
||||||
_sgbss = SIZEOF(.gint.bss);
|
_sgbss = SIZEOF(.gint.bss);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ int gint_intlevel(int intid, int level)
|
||||||
/* gint_inthandler() - configure interrupt handlers */
|
/* gint_inthandler() - configure interrupt handlers */
|
||||||
void *gint_inthandler(int event_code, const void *handler, size_t size)
|
void *gint_inthandler(int event_code, const void *handler, size_t size)
|
||||||
{
|
{
|
||||||
extern char gint_vbr;
|
extern uint32_t gint_vbr;
|
||||||
|
|
||||||
/* Normalize the event code */
|
/* Normalize the event code */
|
||||||
event_code -= 0x400;
|
event_code -= 0x400;
|
||||||
|
@ -58,6 +58,6 @@ void *gint_inthandler(int event_code, const void *handler, size_t size)
|
||||||
/* Prevent overriding the entry gate */
|
/* Prevent overriding the entry gate */
|
||||||
if(event_code < 0) return NULL;
|
if(event_code < 0) return NULL;
|
||||||
|
|
||||||
void *dest = (void *)&gint_vbr + event_code + 0x640;
|
void *dest = (void *)gint_vbr + event_code + 0x640;
|
||||||
return memcpy(dest, handler, size);
|
return memcpy(dest, handler, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,16 @@
|
||||||
#include <gint/display.h>
|
#include <gint/display.h>
|
||||||
|
|
||||||
/* VBR address, from the linker script */
|
/* VBR address, from the linker script */
|
||||||
extern char gint_vbr[];
|
#ifdef FX9860G
|
||||||
/* System's VBR address */
|
extern char gint_vbr_fx9860g[];
|
||||||
|
#endif
|
||||||
|
#ifdef FXCG50
|
||||||
|
extern char gint_vbr_fxcg50[];
|
||||||
|
extern char gint_vbr_fxcg20[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* VBR addresses for gint and the system */
|
||||||
|
GBSS uint32_t gint_vbr;
|
||||||
GBSS static uint32_t system_vbr;
|
GBSS static uint32_t system_vbr;
|
||||||
/* Size of exception and TLB handler */
|
/* Size of exception and TLB handler */
|
||||||
extern char gint_exch_size;
|
extern char gint_exch_size;
|
||||||
|
@ -98,7 +106,14 @@ GMAPPED static void lock(void)
|
||||||
void gint_install(void)
|
void gint_install(void)
|
||||||
{
|
{
|
||||||
/* VBR address, provided by the linker script */
|
/* VBR address, provided by the linker script */
|
||||||
void *vbr = (void *)&gint_vbr;
|
#ifdef FX9860G
|
||||||
|
gint_vbr = (uint32_t)&gint_vbr_fx9860g;
|
||||||
|
#endif
|
||||||
|
#ifdef FXCG50
|
||||||
|
gint_vbr = (gint[HWCALC] == HWCALC_FXCG50)
|
||||||
|
? (uint32_t)&gint_vbr_fxcg50
|
||||||
|
: (uint32_t)&gint_vbr_fxcg20;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Event handler entry points */
|
/* Event handler entry points */
|
||||||
void *inth_entry = isSH3() ? gint_inth_7705 : gint_inth_7305;
|
void *inth_entry = isSH3() ? gint_inth_7705 : gint_inth_7305;
|
||||||
|
@ -113,12 +128,13 @@ void gint_install(void)
|
||||||
gint_ctx_save(&sys_ctx);
|
gint_ctx_save(&sys_ctx);
|
||||||
|
|
||||||
/* Load the event handler entry points into memory */
|
/* Load the event handler entry points into memory */
|
||||||
|
void *vbr = (void *)gint_vbr;
|
||||||
memcpy(vbr + 0x100, gint_exch, exch_size);
|
memcpy(vbr + 0x100, gint_exch, exch_size);
|
||||||
memcpy(vbr + 0x400, gint_tlbh, tlbh_size);
|
memcpy(vbr + 0x400, gint_tlbh, tlbh_size);
|
||||||
memcpy(vbr + 0x600, inth_entry, 64);
|
memcpy(vbr + 0x600, inth_entry, 64);
|
||||||
|
|
||||||
/* Time to switch VBR and roll! */
|
/* Time to switch VBR and roll! */
|
||||||
system_vbr = gint_setvbr((uint32_t)vbr, lock);
|
system_vbr = gint_setvbr(gint_vbr, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unlock() - unlock interrupts, restoring system settings */
|
/* unlock() - unlock interrupts, restoring system settings */
|
||||||
|
|
Loading…
Reference in a new issue