x1000: Enable support for INIT_ATTR

Enable INIT_ATTR support in config.h. Load init code to the
codec buffer, following the convention used by other targets
that support INIT_ATTR.

Change-Id: I8935fbaa100f0013bb328d71c4a49ec2ffafd003
This commit is contained in:
Aidan MacDonald 2022-12-30 23:18:02 +00:00
parent ea7b80dab0
commit a980d5f869
4 changed files with 33 additions and 1 deletions

View file

@ -1070,7 +1070,7 @@ Lyre prototype 1 */
#if (defined(CPU_PP) || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) || \ #if (defined(CPU_PP) || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) || \
(CONFIG_CPU == IMX31L) || (CONFIG_CPU == IMX233) || \ (CONFIG_CPU == IMX31L) || (CONFIG_CPU == IMX233) || \
(CONFIG_CPU == RK27XX) || defined(CPU_COLDFIRE)) \ (CONFIG_CPU == RK27XX) || (CONFIG_CPU == X1000) || defined(CPU_COLDFIRE)) \
&& (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER) && (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER)
/* Functions that have INIT_ATTR attached are NOT guaranteed to survive after /* Functions that have INIT_ATTR attached are NOT guaranteed to survive after
* root_menu() has been called. Their code may be overwritten by other data or * root_menu() has been called. Their code may be overwritten by other data or

View file

@ -13,6 +13,10 @@ INPUT(target/mips/system-mips.o)
# undef CODEC_SIZE # undef CODEC_SIZE
# define PLUGIN_BUFFER_SIZE 0 # define PLUGIN_BUFFER_SIZE 0
# define CODEC_SIZE 0 # define CODEC_SIZE 0
# if defined(HAVE_INIT_ATTR)
/* This needs to be fixed for the bootloader */
# error "bootloader does not support INIT_ATTR"
# endif
#endif #endif
/* End of the audio buffer, where the codec buffer starts */ /* End of the audio buffer, where the codec buffer starts */
@ -21,11 +25,16 @@ INPUT(target/mips/system-mips.o)
/* Where the codec buffer ends, and the plugin buffer starts */ /* Where the codec buffer ends, and the plugin buffer starts */
#define ENDCODECADDR (ENDAUDIOADDR + CODEC_SIZE) #define ENDCODECADDR (ENDAUDIOADDR + CODEC_SIZE)
/* Place init code in the codec buffer */
#define INIT_BASE ENDAUDIOADDR
#define INIT_SIZE CODEC_SIZE
MEMORY MEMORY
{ {
IRAM : ORIGIN = X1000_IRAM_BASE, LENGTH = X1000_IRAM_SIZE IRAM : ORIGIN = X1000_IRAM_BASE, LENGTH = X1000_IRAM_SIZE
DRAM : ORIGIN = X1000_DRAM_BASE, LENGTH = X1000_DRAM_SIZE DRAM : ORIGIN = X1000_DRAM_BASE, LENGTH = X1000_DRAM_SIZE
TCSM : ORIGIN = X1000_TCSM_BASE, LENGTH = X1000_TCSM_SIZE TCSM : ORIGIN = X1000_TCSM_BASE, LENGTH = X1000_TCSM_SIZE
INIT : ORIGIN = INIT_BASE, LENGTH = INIT_SIZE
} }
SECTIONS SECTIONS
@ -40,6 +49,9 @@ SECTIONS
.text : .text :
{ {
*(.text*); *(.text*);
#ifndef HAVE_INIT_ATTR
*(.init*);
#endif
} > DRAM } > DRAM
. = ALIGN(4); . = ALIGN(4);
@ -89,6 +101,16 @@ SECTIONS
} > TCSM AT> DRAM } > TCSM AT> DRAM
_tcsmcopy = LOADADDR(.tcsm); _tcsmcopy = LOADADDR(.tcsm);
#ifdef HAVE_INIT_ATTR
.init :
{
_initstart = .;
*(.init*);
_initend = .;
} > INIT AT> DRAM
_initcopy = LOADADDR(.init);
#endif
/* Sections below have no data. */ /* Sections below have no data. */
. = ALIGN(4); . = ALIGN(4);

View file

@ -75,6 +75,15 @@ _realstart:
bal _copy bal _copy
nop nop
#ifdef HAVE_INIT_ATTR
/* Copy init code */
la a0, _initcopy
la a1, _initstart
la a2, _initend
bal _copy
nop
#endif
/* Clear the BSS segment (needed to zero-initialize C static values) */ /* Clear the BSS segment (needed to zero-initialize C static values) */
la a0, _bssbegin la a0, _bssbegin
la a1, _bssend la a1, _bssend

View file

@ -18,6 +18,7 @@ SECTIONS
*(.startup.spl); *(.startup.spl);
*(.text*); *(.text*);
*(.icode*); *(.icode*);
*(.init*);
} > TCSM } > TCSM
. = ALIGN(4); . = ALIGN(4);