This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#10756 - Free unused init code
Attached to Project:
Rockbox
Opened by Thomas Martitz (kugel.) - Tuesday, 03 November 2009, 14:24 GMT+1
Last edited by Thomas Martitz (kugel.) - Friday, 02 April 2010, 19:10 GMT+1
Opened by Thomas Martitz (kugel.) - Tuesday, 03 November 2009, 14:24 GMT+1
Last edited by Thomas Martitz (kugel.) - Friday, 02 April 2010, 19:10 GMT+1
|
DetailsI've some code here that creates a dedicated section for init functions (i.e. those that are only called once and very early), inspired by the Linux Kernel.
There's little point in keeping that code in otherwise usable RAM. That's why my patch would copy move that code into a section that's overwritten later. For example, as my current patch works for e200v1: The code is in the same address area as bss. Before bss is zeroed, the init code is copied to the codec buffer. After calling main(), the init code is called from the codec buffer. The bss, following sections are moved over the init code, which effectively frees the code size init functions take. I use a very similar approach as iram code does. On my e200, it yields ~6.7k. I would like to know if this kind of self-modifying code is considerable for SVN, or if it's too dirty and/or dangerous. -6.7k isn't *that* much. Where the init code lands (codec or plugin buffer), and if the mechanism is really used, is entirely up to 1 ifdef in config.h and the target's app.lds. |
This task depends upon
Closed by Thomas Martitz (kugel.)
Friday, 02 April 2010, 19:10 GMT+1
Reason for closing: Accepted
Additional comments about closing: Committed as of r25013.
Friday, 02 April 2010, 19:10 GMT+1
Reason for closing: Accepted
Additional comments about closing: Committed as of r25013.
However I failed doing this as I couldn't get the linker do this..
diff --git a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
index 03f6a1b..96d1326 100644
--- a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
@@ -353,6 +353,7 @@ static void lcd_display_off(void)
}
#endif
+void lcd_init_device(void) INIT_ATTR;
void lcd_init_device(void)
{
/* All this is magic worked out by MrH */
@@ -435,6 +436,7 @@ void lcd_init_device(void)
#endif
LCD_REG_6 |= 1; /* Start DMA */
+ _backlight_set_brightness(0);
}
#if defined(HAVE_LCD_ENABLE
And I think the description is wrong: the code isn't copied in bss section
Where does the description indicate it's copied in the bss section?
What I see is that the copy in crt0.S is done just before bss zeroing, but I read the first sentence as "code is copied inside bss section"