From 2751dcf045276d6cd700bb8f584b1c5486cb008b Mon Sep 17 00:00:00 2001 From: Lephe Date: Fri, 10 Jul 2020 16:36:05 +0200 Subject: [PATCH] remove the .gint.data section Since both platforms now have their VBR and gint-specific data loaded along the add-in's data, the .gint.data section is entirely unused. The .gint.bss section is still used for uninitialized objects (it has different semantics than .bss which is initially cleared) and the .gint.data.sh3 and .gint.bss.sh3 sections that are dropped on the SH4-only fx-CG 50 are also still used. --- fx9860g.ld | 17 ++++++++--------- fxcg50.ld | 17 ++--------------- include/gint/defs/attributes.h | 3 +-- src/core/exch.c | 4 ++-- src/core/inth.S | 2 +- src/core/start.c | 9 +++++++-- src/gray/engine.c | 4 ++-- src/intc/intc.c | 2 +- src/keysc/keysc.c | 11 +++++------ src/r61524/r61524.c | 4 ++-- src/render-fx/dupdate.c | 2 +- src/rtc/rtc.c | 2 +- src/t6k11/t6k11.c | 4 ++-- src/tmu/tmu.c | 8 ++++---- 14 files changed, 39 insertions(+), 50 deletions(-) diff --git a/fx9860g.ld b/fx9860g.ld index 9b02184..9a85e09 100644 --- a/fx9860g.ld +++ b/fx9860g.ld @@ -136,14 +136,14 @@ SECTIONS /* Read-write data going to RAM: - Data sections generated by the compiler (.data and .data.*) - Data sections from fxlib, "D" - - Data sections from gint (.gint.data) */ + - The SH3-only data section (.gint.data.sh3) */ .data ALIGN(4) : ALIGN(4) { _ldata = LOADADDR(.data); _rdata = . ; *(.data .data.*) *(D) - *(.gint.data .gint.data.sh3) + *(.gint.data.sh3) . = ALIGN(16); } > ram AT> rom @@ -159,7 +159,7 @@ SECTIONS /* gint's uninitialized BSS section */ .gint.bss (NOLOAD) : { /* Since it's uninitialized, the location doesn't matter */ - *(.gint.bss) + *(.gint.bss .gint.bss.sh3) . = ALIGN(16); } > ram :NONE @@ -210,24 +210,23 @@ SECTIONS /* VBR address: let's just start at the beginning of the RRAM area. 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 */ _gint_vbr_fx9860g = ORIGIN(vbr) - 0x100; . = ORIGIN(rram); /* Code that must remain permanently mapped (.gint.mapped) */ - .gint.data ALIGN(4) : ALIGN(4) { - _lgdata = LOADADDR(.gint.data); - _rgdata = . ; + .gint.mapped ALIGN(4) : ALIGN(4) { + _lgmapped = LOADADDR(.gint.mapped); + _rgmapped = . ; - /* Also code that must remain permanently mapped! */ *(.gint.mapped) . = ALIGN(16); } > rram AT> rom - _sgdata = SIZEOF(.gint.data); + _sgmapped = SIZEOF(.gint.mapped); diff --git a/fxcg50.ld b/fxcg50.ld index 8a4f2b6..d5edfd2 100644 --- a/fxcg50.ld +++ b/fxcg50.ld @@ -192,24 +192,11 @@ SECTIONS . = ORIGIN(ram) + _sbss + _sdata; - /* gint's data section, going to static RAM. This section contains many - small objects from the library (static/global variables, etc) */ - .gint.data ALIGN(4) : ALIGN(4) { - _lgdata = LOADADDR(.gint.data); - _rgdata = . ; - - *(.gint.data .gint.data.*) - - . = ALIGN(16); - } > ram AT> rom - - _sgdata = SIZEOF(.gint.data); - /* gint's uninitialized BSS section, going to static RAM. All the large data arrays will be located here */ .gint.bss (NOLOAD) : { /* Since it's uninitialized, the location doesn't matter */ - *(.gint.bss .gint.bss.*) + *(.gint.bss) . = ALIGN(16); } > ram :NONE @@ -229,8 +216,8 @@ SECTIONS - Asynchronous unwind tables: no C++ exception handling for now ^^ - Comments or anything the compiler might put in its assembler */ /DISCARD/ : { - *(.gint.bss.sh3) *(.gint.data.sh3) + *(.gint.bss.sh3) *(.debug_info .debug_abbrev .debug_loc .debug_aranges .debug_ranges .debug_line .debug_str) diff --git a/include/gint/defs/attributes.h b/include/gint/defs/attributes.h index 3c75322..db31c22 100644 --- a/include/gint/defs/attributes.h +++ b/include/gint/defs/attributes.h @@ -7,8 +7,7 @@ /* Objects from specific sections */ #define GSECTION(x) __attribute__((section(x))) -/* Objects from the .gint.data and .gint.bss sections */ -#define GDATA __attribute__((section(".gint.data"))) +/* Objects from the gint's uninitialized BSS section */ #define GBSS __attribute__((section(".gint.bss"))) /* Additional sections that are only needed on SH3 */ #define GDATA3 __attribute__((section(".gint.data.sh3"))) diff --git a/src/core/exch.c b/src/core/exch.c index 4ae4415..cdecc6f 100644 --- a/src/core/exch.c +++ b/src/core/exch.c @@ -119,9 +119,9 @@ GNORETURN static void gint_default_panic(GUNUSED uint32_t code) } /* Panic handler */ -GDATA GNORETURN void (*gint_exc_panic)(uint32_t code) = gint_default_panic; +GNORETURN void (*gint_exc_panic)(uint32_t code) = gint_default_panic; /* Exception catcher */ -GDATA int (*gint_exc_catcher)(uint32_t code) = NULL; +int (*gint_exc_catcher)(uint32_t code) = NULL; /* gint_panic(): Panic handler function */ void gint_panic(uint32_t code) diff --git a/src/core/inth.S b/src/core/inth.S index 4df2410..d5dfbca 100644 --- a/src/core/inth.S +++ b/src/core/inth.S @@ -143,7 +143,7 @@ _gint_inth_7705: 1: .long 0xa4000000 /* INTEVT2 register */ 2: .long _inth_remap -.section .gint.data +.data .align 4 /* EVENT CODE TRANSLATION TABLE - 96 BYTES diff --git a/src/core/start.c b/src/core/start.c index 650133e..19cc2e7 100644 --- a/src/core/start.c +++ b/src/core/start.c @@ -19,12 +19,15 @@ gint's BSS section is not mentioned here because it's never initialized */ extern uint32_t brom, srom, /* Limits of ROM mappings */ - lgdata, sgdata, rgdata, /* gint's data section */ ldata, sdata, rdata, /* User's data section */ lilram, silram, rilram, /* IL memory section */ lxram, sxram, rxram, /* X memory section */ lyram, syram, ryram, /* Y memory section */ sbss, rbss; /* User's BSS section */ +#ifdef FX9860G +extern uint32_t + lgmapped, sgmapped, rgmapped; /* Permanently mapped functions */ +#endif /* Constructor and destructor arrays */ extern void (*bctors)(void), (*ectors)(void); @@ -101,8 +104,10 @@ int start(int isappli, int optnum) /* Load data sections and wipe the bss section. This has to be done first for static and global variables to be initialized */ - regcpy(lgdata, sgdata, rgdata); regcpy(ldata, sdata, rdata); + #ifdef FX9860G + regcpy(lgmapped, sgmapped, rgmapped); + #endif regcpy(lilram, silram, rilram); regcpy(lxram, sxram, rxram); regcpy(lyram, syram, ryram); diff --git a/src/gray/engine.c b/src/gray/engine.c index d0d1d4a..b49dd1c 100644 --- a/src/gray/engine.c +++ b/src/gray/engine.c @@ -21,10 +21,10 @@ GBSS static uint32_t *vrams[4]; /* Current VRAM pair used for drawing; the value can either be 0 (draws to VRAMs 0 and 1) or 2 (draws to VRAMs 2 and 3). */ -GDATA static volatile int st = 0; +static volatile int st = 0; /* Whether the engine is running. Delays of light and dark frames. */ -GDATA static int runs = 0; +static int runs = 0; GBSS static int delays[2]; /* Underlying timer */ diff --git a/src/intc/intc.c b/src/intc/intc.c index 8d2f6ed..4e1b7ea 100644 --- a/src/intc/intc.c +++ b/src/intc/intc.c @@ -13,7 +13,7 @@ GDATA3 sh7705_intc_t SH7705_INTC = { .ICR1 = (void *)0xa4000010, }; -GDATA sh7305_intc_t SH7305_INTC = { +sh7305_intc_t SH7305_INTC = { .IPR = (void *)0xa4080000, .MSK = (void *)0xa4080080, .MSKCLR = (void *)0xa40800c0, diff --git a/src/keysc/keysc.c b/src/keysc/keysc.c index 2802a2a..cbc0bc3 100644 --- a/src/keysc/keysc.c +++ b/src/keysc/keysc.c @@ -26,13 +26,13 @@ To ensure that adding pending events to the last-read state always gives the internal driver state, this array is not updated if the generation of an event fails. (Most likely the even will be regenerated at the next scan.) */ -GDATA static volatile uint8_t state[12] = { 0 }; +static volatile uint8_t state[12] = { 0 }; /* The driver's current event state. This state corresponds to the sum of all events sent to the user so far.When the event queue is empty, this is equal to [state]. For each generated event, this array is updated to reflect the user's view of the keyboard. */ -GDATA static uint8_t current[12] = { 0 }; +static uint8_t current[12] = { 0 }; /* A driver event, which is a common change in a full row */ typedef struct @@ -49,11 +49,11 @@ typedef struct be at least one free entry. */ GBSS static driver_event_t buffer[KEYBOARD_QUEUE_SIZE]; /* Buffer bounds */ -GDATA static int buffer_start = 0; -GDATA static int buffer_end = 0; +static int buffer_start = 0; +static int buffer_end = 0; /* Current time, in keyboard-scanning ticks */ -GDATA static uint time = 0; +static uint time = 0; /* buffer_push(): Add an event in the keyboard buffer Returns non-zero if the event cannot be pushed. */ @@ -260,7 +260,6 @@ static void init(void) { /* Configure the timer to do 128 keyboard scans per second. This frequency *must* be high for the KEYSC interface to work! */ - /* Note: the supporting timer always runs at 32768 Hz. */ int delay = 1000000 / KEYBOARD_SCAN_FREQUENCY; if(!delay) delay = 1; diff --git a/src/r61524/r61524.c b/src/r61524/r61524.c index 13c6f1a..1002aeb 100644 --- a/src/r61524/r61524.c +++ b/src/r61524/r61524.c @@ -55,9 +55,9 @@ typedef word_union(entry_mode_t, //--- /* Interface with the controller */ -GDATA static volatile uint16_t *intf = (void *)0xb4000000; +static volatile uint16_t *intf = (void *)0xb4000000; /* Bit 4 of Port R controls the RS bit of the display driver */ -GDATA static volatile uint8_t *PRDR = (void *)0xa405013c; +static volatile uint8_t *PRDR = (void *)0xa405013c; GINLINE static void select(uint16_t reg) { diff --git a/src/render-fx/dupdate.c b/src/render-fx/dupdate.c index 0c23bd4..707020b 100644 --- a/src/render-fx/dupdate.c +++ b/src/render-fx/dupdate.c @@ -5,7 +5,7 @@ GSECTION(".bss") static uint32_t fx_vram[256]; /* Here is the definition of the VRAM pointer, exposed in */ -GDATA uint32_t *gint_vram = fx_vram; +uint32_t *gint_vram = fx_vram; /* dupdate() - push the video RAM to the display driver */ void dupdate(void) diff --git a/src/rtc/rtc.c b/src/rtc/rtc.c index c1a74fe..4944490 100644 --- a/src/rtc/rtc.c +++ b/src/rtc/rtc.c @@ -16,7 +16,7 @@ //--- /* RTC address on SH7305, adjusted at startup on SH7337 and SH7355 */ -GDATA static rtc_t *RTC = &SH7305_RTC; +static rtc_t *RTC = &SH7305_RTC; /* Address of interrupt handler parameters */ GBSS struct { int (*callback)(volatile void *arg); diff --git a/src/t6k11/t6k11.c b/src/t6k11/t6k11.c index dbc909a..fa52625 100644 --- a/src/t6k11/t6k11.c +++ b/src/t6k11/t6k11.c @@ -52,9 +52,9 @@ enum { pins in the address. (?) */ /* RS = 0: Register selection */ -GDATA static volatile uint8_t *sel = (void *)0xb4000000; +static volatile uint8_t *sel = (void *)0xb4000000; /* RS = 1: Command data or vram data */ -GDATA static volatile uint8_t *cmd = (void *)0xb4010000; +static volatile uint8_t *cmd = (void *)0xb4010000; /* command() - send a command to set the value of a register @reg Register number diff --git a/src/tmu/tmu.c b/src/tmu/tmu.c index a45d394..fe6ea7e 100644 --- a/src/tmu/tmu.c +++ b/src/tmu/tmu.c @@ -27,13 +27,13 @@ typedef struct } GPACKED(4) inth_data_t; /* This array references the storage areas of all timer handlers */ -GDATA static inth_data_t *timers[9] = { NULL }; +static inth_data_t *timers[9] = { NULL }; /* Arrays of standard and extra timers */ -GDATA static tmu_t *TMU = SH7305_TMU.TMU; -GDATA static etmu_t *ETMU = SH7305_ETMU; +static tmu_t *TMU = SH7305_TMU.TMU; +static etmu_t *ETMU = SH7305_ETMU; /* TSTR register for standard timers */ -GDATA static volatile uint8_t *TSTR = &SH7305_TMU.TSTR; +static volatile uint8_t *TSTR = &SH7305_TMU.TSTR; //--- // Local functions