mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
FS#10756 - Free unused init code
Introduce a new .init section for initialisation code, so that it can be copied to an area which is later overwritten before calling. The stack/bss can then overwrite that code, effectively freeing the code size that the initialisation routines need. Gives a few kB ram usage back. Only implemented for PP and as3525 so far. More targets could be added, as well as more functions. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25013 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e479853f15
commit
f8edc32589
33 changed files with 98 additions and 37 deletions
|
@ -56,7 +56,7 @@ void tree_get_filetypes(const struct filetype**, int*);
|
|||
|
||||
/* init the filetypes structs.
|
||||
uses audio buffer for storage, so call early in init... */
|
||||
void filetype_init(void);
|
||||
void filetype_init(void) INIT_ATTR;
|
||||
void read_viewer_theme_file(void);
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
void read_color_theme_file(void);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile);
|
||||
|
||||
void sb_create_from_settings(enum screen_type screen);
|
||||
void sb_skin_init(void);
|
||||
void sb_skin_init(void) INIT_ATTR;
|
||||
struct viewport *sb_skin_get_info_vp(enum screen_type screen);
|
||||
void sb_skin_update(enum screen_type screen, bool force);
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ struct gui_syncstatusbar
|
|||
struct gui_statusbar statusbars[NB_SCREENS];
|
||||
};
|
||||
|
||||
extern void gui_syncstatusbar_init(struct gui_syncstatusbar * bars);
|
||||
extern void gui_syncstatusbar_init(struct gui_syncstatusbar * bars) INIT_ATTR;
|
||||
extern void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars,
|
||||
bool force_redraw);
|
||||
void gui_statusbar_changed(enum screen_type screen,
|
||||
|
|
|
@ -42,8 +42,7 @@ int viewport_get_nb_lines(const struct viewport *vp);
|
|||
* Initialize the viewportmanager, which in turns initializes the UI vp and
|
||||
* statusbar stuff
|
||||
*/
|
||||
void viewportmanager_init(void);
|
||||
|
||||
void viewportmanager_init(void) INIT_ATTR;
|
||||
|
||||
void viewport_set_defaults(struct viewport *vp,
|
||||
const enum screen_type screen);
|
||||
|
|
|
@ -28,7 +28,7 @@ long gui_wps_show(void);
|
|||
/* wrapper for the wps to load the skin (.wps/.rwps) files */
|
||||
void wps_data_load(enum screen_type, const char *, bool);
|
||||
|
||||
void gui_sync_wps_init(void);
|
||||
void gui_sync_wps_init(void) INIT_ATTR;
|
||||
|
||||
/* fades the volume, e.g. on pause or stop */
|
||||
void fade(bool fade_in, bool updatewps);
|
||||
|
|
|
@ -127,7 +127,7 @@ static void init(void);
|
|||
#ifdef SIMULATOR
|
||||
void app_main(void)
|
||||
#else
|
||||
int main(void) __attribute__((noreturn));
|
||||
int main(void) INIT_ATTR __attribute__((noreturn));
|
||||
int main(void)
|
||||
#endif
|
||||
{
|
||||
|
@ -164,6 +164,7 @@ int main(void)
|
|||
root_menu();
|
||||
}
|
||||
|
||||
static int init_dircache(bool preinit) INIT_ATTR;
|
||||
static int init_dircache(bool preinit)
|
||||
{
|
||||
#ifdef HAVE_DIRCACHE
|
||||
|
@ -239,6 +240,7 @@ static int init_dircache(bool preinit)
|
|||
}
|
||||
|
||||
#ifdef HAVE_TAGCACHE
|
||||
static void init_tagcache(void) INIT_ATTR;
|
||||
static void init_tagcache(void)
|
||||
{
|
||||
bool clear = false;
|
||||
|
@ -372,6 +374,7 @@ static void init(void)
|
|||
|
||||
#else
|
||||
|
||||
static void init(void) INIT_ATTR;
|
||||
static void init(void)
|
||||
{
|
||||
int rc;
|
||||
|
|
|
@ -119,7 +119,7 @@ struct playlist_track_info
|
|||
};
|
||||
|
||||
/* Exported functions only for current playlist. */
|
||||
void playlist_init(void);
|
||||
void playlist_init(void) INIT_ATTR;
|
||||
void playlist_shutdown(void);
|
||||
int playlist_create(const char *dir, const char *file);
|
||||
int playlist_resume(void);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#if CONFIG_TUNER
|
||||
void radio_load_presets(char *filename);
|
||||
void radio_init(void);
|
||||
void radio_init(void) INIT_ATTR;
|
||||
int radio_screen(void);
|
||||
void radio_start(void);
|
||||
void radio_pause(void);
|
||||
|
|
|
@ -239,7 +239,7 @@ bool tagcache_is_ramcache(void);
|
|||
bool tagcache_fill_tags(struct mp3entry *id3, const char *filename);
|
||||
void tagcache_unload_ramcache(void);
|
||||
#endif
|
||||
void tagcache_init(void);
|
||||
void tagcache_init(void) INIT_ATTR;
|
||||
bool tagcache_is_initialized(void);
|
||||
bool tagcache_is_usable(void);
|
||||
void tagcache_start_scan(void);
|
||||
|
|
|
@ -38,7 +38,7 @@ struct tagentry {
|
|||
|
||||
bool tagtree_export(void);
|
||||
bool tagtree_import(void);
|
||||
void tagtree_init(void);
|
||||
void tagtree_init(void) INIT_ATTR;
|
||||
int tagtree_enter(struct tree_context* c);
|
||||
void tagtree_exit(struct tree_context* c);
|
||||
int tagtree_load(struct tree_context* c);
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define GET_STRETCH(pitch, speed) \
|
||||
((speed * PITCH_SPEED_100 + pitch / 2L) / pitch)
|
||||
|
||||
void tdspeed_init(void);
|
||||
void tdspeed_init(void) INIT_ATTR;
|
||||
bool tdspeed_config(int samplerate, bool stereo, int32_t factor);
|
||||
long tdspeed_est_output_size(void);
|
||||
long tdspeed_est_input_size(long size);
|
||||
|
|
|
@ -71,8 +71,8 @@ struct tree_context {
|
|||
};
|
||||
|
||||
void tree_drawlists(void);
|
||||
void tree_mem_init(void);
|
||||
void tree_gui_init(void);
|
||||
void tree_mem_init(void) INIT_ATTR;
|
||||
void tree_gui_init(void) INIT_ATTR;
|
||||
void get_current_file(char* buffer, int buffer_len);
|
||||
void set_dirfilter(int l_dirfilter);
|
||||
void set_current_file(char *path);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "adc-target.h"
|
||||
|
||||
unsigned short adc_read(int channel);
|
||||
void adc_init(void);
|
||||
void adc_init(void) INIT_ATTR;
|
||||
|
||||
#ifndef NEED_ADC_CLOSE
|
||||
#define adc_close()
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#define AUDIO_GAIN_MIC 1
|
||||
|
||||
|
||||
void audio_init(void);
|
||||
void audio_init(void) INIT_ATTR;
|
||||
void audio_play(long offset);
|
||||
void audio_stop(void);
|
||||
void audio_pause(void);
|
||||
|
|
|
@ -36,7 +36,7 @@ void backlight_off(void);
|
|||
void backlight_set_timeout(int value);
|
||||
|
||||
#ifdef HAVE_BACKLIGHT
|
||||
void backlight_init(void);
|
||||
void backlight_init(void) INIT_ATTR;
|
||||
void backlight_close(void);
|
||||
|
||||
int backlight_get_current_timeout(void);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef BUFFER_H
|
||||
#define BUFFER_H
|
||||
|
||||
#include "config.h"
|
||||
/* defined in linker script */
|
||||
#ifdef SIMULATOR
|
||||
extern unsigned char *audiobufend;
|
||||
|
@ -30,7 +31,7 @@ extern unsigned char audiobufend[];
|
|||
|
||||
extern unsigned char *audiobuf;
|
||||
|
||||
void buffer_init(void);
|
||||
void buffer_init(void) INIT_ATTR;
|
||||
void *buffer_alloc(size_t size);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
extern struct event_queue button_queue;
|
||||
|
||||
void button_init (void);
|
||||
void button_init (void) INIT_ATTR;
|
||||
void button_close(void);
|
||||
int button_queue_count(void);
|
||||
long button_get (bool block);
|
||||
|
|
|
@ -747,6 +747,11 @@ Lyre prototype 1 */
|
|||
#define IBSS_ATTR
|
||||
#define STATICIRAM static
|
||||
#endif
|
||||
#if (defined(CPU_PP) || (CONFIG_CPU == AS3525)) && !defined(SIMULATOR)
|
||||
#define INIT_ATTR __attribute__ ((section(".init")))
|
||||
#else
|
||||
#define INIT_ATTR
|
||||
#endif
|
||||
|
||||
#if defined(SIMULATOR) && defined(__APPLE__)
|
||||
#define DATA_ATTR __attribute__ ((section("__DATA, .data")))
|
||||
|
|
|
@ -115,7 +115,7 @@ struct font {
|
|||
};
|
||||
|
||||
/* font routines*/
|
||||
void font_init(void);
|
||||
void font_init(void) INIT_ATTR;
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
/* Load a font into the special remote ui font slot */
|
||||
int font_load_remoteui(const char* path);
|
||||
|
|
|
@ -214,7 +214,7 @@ static inline void call_tick_tasks(void)
|
|||
#endif
|
||||
|
||||
/* kernel functions */
|
||||
extern void kernel_init(void);
|
||||
extern void kernel_init(void) INIT_ATTR;
|
||||
extern void yield(void);
|
||||
extern void sleep(int ticks);
|
||||
int tick_add_task(void (*f)(void));
|
||||
|
|
|
@ -175,8 +175,8 @@ extern void lcd_write_command(int byte);
|
|||
extern void lcd_write_command_e(int cmd, int data);
|
||||
extern void lcd_write_command_ex(int cmd, int data1, int data2);
|
||||
extern void lcd_write_data(const fb_data* p_bytes, int count);
|
||||
extern void lcd_init(void);
|
||||
extern void lcd_init_device(void);
|
||||
extern void lcd_init(void) INIT_ATTR;
|
||||
extern void lcd_init_device(void) INIT_ATTR;
|
||||
|
||||
extern void lcd_backlight(bool on);
|
||||
extern int lcd_default_contrast(void);
|
||||
|
|
|
@ -83,7 +83,7 @@ bool charging_state(void);
|
|||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
void power_init(void);
|
||||
void power_init(void) INIT_ATTR;
|
||||
|
||||
bool ide_powered(void);
|
||||
#endif
|
||||
|
|
|
@ -131,7 +131,7 @@ extern const unsigned short percent_to_volt_charge[11];
|
|||
#endif
|
||||
|
||||
/* Start up power management thread */
|
||||
void powermgmt_init(void);
|
||||
void powermgmt_init(void) INIT_ATTR;
|
||||
|
||||
#endif /* SIMULATOR */
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <lcd.h>
|
||||
#include "file.h"
|
||||
|
||||
void scroll_init(void);
|
||||
void scroll_init(void) INIT_ATTR;
|
||||
void lcd_scroll_stop(const struct viewport* vp);
|
||||
void lcd_scroll_stop_line(const struct viewport* vp, int y);
|
||||
void lcd_scroll_fn(void);
|
||||
|
|
|
@ -479,7 +479,7 @@ void core_idle(void);
|
|||
void core_wake(IF_COP_VOID(unsigned int core));
|
||||
|
||||
/* Initialize the scheduler */
|
||||
void init_threads(void);
|
||||
void init_threads(void) INIT_ATTR;
|
||||
|
||||
/* Allocate a thread in the scheduler */
|
||||
#define CREATE_THREAD_FROZEN 0x00000001 /* Thread is frozen at create time */
|
||||
|
|
|
@ -158,7 +158,7 @@ enum
|
|||
|
||||
/** **/
|
||||
|
||||
void tuner_init(void);
|
||||
void tuner_init(void) INIT_ATTR;
|
||||
|
||||
#endif /* #if CONFIG_TUNER */
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ struct usb_transfer_completion_event_data
|
|||
};
|
||||
#endif /* HAVE_USBSTACK */
|
||||
|
||||
void usb_init(void);
|
||||
void usb_init(void) INIT_ATTR;
|
||||
void usb_enable(bool on);
|
||||
void usb_attach(void);
|
||||
void usb_start_monitoring(void);
|
||||
|
|
|
@ -92,7 +92,7 @@ typedef struct {
|
|||
DIR_UNCACHED *regulardir;
|
||||
} DIR_CACHED;
|
||||
|
||||
void dircache_init(void);
|
||||
void dircache_init(void) INIT_ATTR;
|
||||
int dircache_load(void);
|
||||
int dircache_save(void);
|
||||
int dircache_build(int last_size);
|
||||
|
|
|
@ -99,6 +99,8 @@ SECTIONS
|
|||
_iramend = .;
|
||||
} > IRAM AT> DRAM
|
||||
|
||||
_iramcopy = LOADADDR(.iram);
|
||||
|
||||
.ibss (NOLOAD) :
|
||||
{
|
||||
_iedata = .;
|
||||
|
@ -108,9 +110,17 @@ SECTIONS
|
|||
_iend = .;
|
||||
} > IRAM
|
||||
|
||||
_iramcopy = LOADADDR(.iram);
|
||||
.init ENDAUDIOADDR :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_initstart = .;
|
||||
*(.init)
|
||||
_initend = .;
|
||||
} AT> DRAM
|
||||
|
||||
.stack (NOLOAD) :
|
||||
_initcopy = LOADADDR(.init);
|
||||
|
||||
.stack _iramcopy (NOLOAD) :
|
||||
{
|
||||
*(.stack)
|
||||
stackbegin = .;
|
||||
|
|
|
@ -213,6 +213,19 @@ cpu_init:
|
|||
strhi r5, [r3], #4
|
||||
bhi 1b
|
||||
|
||||
#ifdef INIT_ATTR
|
||||
/* copy init code to codec buffer */
|
||||
ldr r2, =_initstart
|
||||
ldr r3, =_initend
|
||||
ldr r4, =_initcopy
|
||||
|
||||
1:
|
||||
cmp r3, r2
|
||||
ldrhi r5, [r4], #4
|
||||
strhi r5, [r2], #4
|
||||
bhi 1b
|
||||
#endif
|
||||
|
||||
/* Zero out IBSS */
|
||||
ldr r2, =_iedata
|
||||
ldr r3, =_iend
|
||||
|
|
|
@ -71,6 +71,7 @@ newstart:
|
|||
bhi 1b
|
||||
|
||||
/* Copy the IRAM */
|
||||
/* must be done before bss is zeroed */
|
||||
ldr r2, =_iramcopy
|
||||
ldr r3, =_iramstart
|
||||
ldr r4, =_iramend
|
||||
|
@ -79,6 +80,23 @@ newstart:
|
|||
ldrhi r5, [r2], #4
|
||||
strhi r5, [r3], #4
|
||||
bhi 1b
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef INIT_ATTR
|
||||
/* copy init data to codec buffer */
|
||||
/* must be done before bss is zeroed */
|
||||
ldr r2, =_initcopy
|
||||
ldr r3, =_initstart
|
||||
ldr r4, =_initend
|
||||
1:
|
||||
cmp r4, r3
|
||||
ldrhi r5, [r2], #4
|
||||
strhi r5, [r3], #4
|
||||
bhi 1b
|
||||
|
||||
mov r2, #0
|
||||
mcr p15, 0, r2, c7, c5, 0 @ Invalidate ICache
|
||||
#endif
|
||||
|
||||
/* Initialise bss section to zero */
|
||||
|
@ -115,7 +133,6 @@ newstart:
|
|||
|
||||
/* Switch back to supervisor mode */
|
||||
msr cpsr_c, #0xd3
|
||||
|
||||
bl main
|
||||
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ STARTUP(target/arm/crt0-pp.o)
|
|||
|
||||
MEMORY
|
||||
{
|
||||
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
|
||||
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
|
||||
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
|
||||
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
|
@ -126,6 +126,17 @@ SECTIONS
|
|||
|
||||
_iramcopy = LOADADDR(.iram);
|
||||
|
||||
|
||||
.init ENDAUDIOADDR :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_initstart = .;
|
||||
*(.init)
|
||||
_initend = .;
|
||||
} AT> DRAM
|
||||
|
||||
_initcopy = LOADADDR(.init);
|
||||
|
||||
.idle_stacks (NOLOAD) :
|
||||
{
|
||||
*(.idle_stacks)
|
||||
|
@ -175,6 +186,7 @@ SECTIONS
|
|||
.audiobuf (NOLOAD) :
|
||||
{
|
||||
_audiobuffer = .;
|
||||
. = ALIGN(0x4);
|
||||
audiobuffer = .;
|
||||
} > DRAM
|
||||
|
||||
|
|
|
@ -724,6 +724,7 @@ static void __attribute__((naked))
|
|||
* initializations.
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
static void core_thread_init(unsigned int core) INIT_ATTR;
|
||||
static void core_thread_init(unsigned int core)
|
||||
{
|
||||
if (core == CPU)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue