Archos flash loader: compile with -Os and make all internal functions static to save space. main() and _main() must not be static or they wouldn't end up in IRAM for execution. * Also make some bootbox functions static, and drop the useless return value from charging_screen().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18791 a1c6a512-1295-4272-9138-f99709370657
diff --git a/flash/bootbox/main.c b/flash/bootbox/main.c
index 7170867..2bd3fea 100644
--- a/flash/bootbox/main.c
+++ b/flash/bootbox/main.c
@@ -44,7 +44,7 @@
#include "usb.h"
#include "powermgmt.h"
-void usb_screen(void)
+static void usb_screen(void)
{
lcd_clear_display();
lcd_puts(0, 0, "USB mode");
@@ -55,7 +55,7 @@
}
}
-void show_logo(void)
+static void show_logo(void)
{
lcd_clear_display();
lcd_puts(0, 0, "Rockbox");
@@ -64,13 +64,7 @@
}
#if CONFIG_CHARGING
-/*
-bool backlight_get_on_when_charging(void)
-{
- return false;
-}
-*/
-void charging_screen(void)
+static void charging_screen(void)
{
unsigned int button;
const char* msg;
@@ -123,7 +117,7 @@
#endif /* CONFIG_CHARGING */
/* prompt user to plug USB and fix a problem */
-void prompt_usb(const char* msg1, const char* msg2)
+static void prompt_usb(const char* msg1, const char* msg2)
{
int button;
lcd_clear_display();
diff --git a/flash/bootloader/Makefile b/flash/bootloader/Makefile
index 6872fcb..e7bd17a 100644
--- a/flash/bootloader/Makefile
+++ b/flash/bootloader/Makefile
@@ -35,7 +35,7 @@
OBJDIR := .
-CFLAGS = -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(DEFINES)
+CFLAGS = -Os -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(DEFINES)
AFLAGS += -small -relax
diff --git a/flash/bootloader/bootloader.c b/flash/bootloader/bootloader.c
index dc094d1..d1955c2 100644
--- a/flash/bootloader/bootloader.c
+++ b/flash/bootloader/bootloader.c
@@ -27,6 +27,22 @@
#include "sh7034.h"
#include "bootloader.h"
+// prototypes
+static void PlatformInit(void);
+static int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len);
+static void DecompressStart(tImage* pImage);
+#ifdef USE_ADC
+static int ReadADC(int channel);
+#endif
+static int ButtonPressed(void);
+static tImage* GetStartImage(int nPreferred);
+// test functions
+static void SetLed(BOOL bOn);
+static void UartInit(void);
+static UINT8 UartRead(void);
+static void UartWrite(UINT8 byte);
+static void MiniMon(void);
+
#ifdef NO_ROM
/* start with the vector table */
@@ -71,7 +87,7 @@
}
-void BootInit(void)
+static void BootInit(void)
{
/* inits from the boot ROM, whether they make sense or not */
PBDR &= 0xFFBF; /* LED off (0x131E) */
@@ -117,7 +133,7 @@
/* init code that is specific to certain platform */
-void PlatformInit(void)
+static void PlatformInit(void)
{
#ifdef NO_ROM
BootInit(); /* if not started by boot ROM, we need to init what it did */
@@ -177,7 +193,7 @@
#define GETBIT(bb, src, ilen) \
(((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1)
-int ucl_nrv2e_decompress_8(
+static int ucl_nrv2e_decompress_8(
const UINT8 *src, UINT8 *dst, UINT32* dst_len)
{
UINT32 bb = 0;
@@ -239,7 +255,7 @@
/* move the image into place and start it */
-void DecompressStart(tImage* pImage)
+static void DecompressStart(tImage* pImage)
{
UINT32* pSrc;
UINT32* pDest;
@@ -273,7 +289,7 @@
}
#ifdef USE_ADC
-int ReadADC(int channel)
+static int ReadADC(int channel)
{
/* after channel 3, the ports wrap and get re-used */
volatile UINT16* pResult = (UINT16*)(ADDRAH_ADDR + 2 * (channel & 0x03));
@@ -289,7 +305,7 @@
/* This function is platform-dependent,
* until I figure out how to distinguish at runtime. */
-int ButtonPressed(void) /* return 1,2,3 for F1,F2,F3, 0 if none pressed */
+static int ButtonPressed(void) /* return 1,2,3 for F1,F2,F3, 0 if none pressed */
{
#ifdef USE_ADC
int value = ReadADC(CHANNEL);
@@ -316,7 +332,7 @@
/* Determine the image to be started */
-tImage* GetStartImage(int nPreferred)
+static tImage* GetStartImage(int nPreferred)
{
tImage* pImage1;
tImage* pImage2 = NULL; /* default to not present */
@@ -357,7 +373,7 @@
/* diagnostic functions */
-void SetLed(BOOL bOn)
+static void SetLed(BOOL bOn)
{
if (bOn)
PBDR |= 0x0040;
@@ -366,7 +382,7 @@
}
-void UartInit(void)
+static void UartInit(void)
{
PBIOR &= 0xFBFF; /* input: RXD1 remote pin */
PBCR1 |= 0x00A0; /* set PB11+PB10 to UART */
@@ -378,7 +394,7 @@
}
-UINT8 UartRead(void)
+static UINT8 UartRead(void)
{
UINT8 byte;
while (!(SSR1 & SCI_RDRF)); /* wait for char to be available */
@@ -388,7 +404,7 @@
}
-void UartWrite(UINT8 byte)
+static void UartWrite(UINT8 byte)
{
while (!(SSR1 & SCI_TDRE)); /* wait for transmit buffer empty */
TDR1 = byte;
@@ -397,7 +413,7 @@
/* include the mini monitor as a rescue feature, started with F3 */
-void MiniMon(void)
+static void MiniMon(void)
{
UINT8 cmd;
UINT32 addr;
diff --git a/flash/bootloader/bootloader.h b/flash/bootloader/bootloader.h
index fc6bcb1..948311f 100644
--- a/flash/bootloader/bootloader.h
+++ b/flash/bootloader/bootloader.h
@@ -76,26 +76,9 @@
#define FLASH_BASE 0x02000000 // start of the flash memory
#define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version
-
// prototypes
void _main(void) __attribute__ ((section (".startup")));
int main(void);
-void PlatformInit(void);
-void DramInit(void);
-int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len);
-void DecompressStart(tImage* pImage);
-#ifdef USE_ADC
-int ReadADC(int channel);
-#endif
-int ButtonPressed(void);
-tImage* GetStartImage(int nPreferred);
-// test functions
-void SetLed(BOOL bOn);
-void UartInit(void);
-UINT8 UartRead(void);
-void UartWrite(UINT8 byte);
-void MiniMon(void);
-
// minimon commands
#define BAUDRATE 0x00 // followed by BRR value; response: command byte