diff options
author | Jens Arnold <amiconn@rockbox.org> | 2008-10-12 22:10:22 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2008-10-12 22:10:22 +0000 |
commit | ca99f8efa49fbc053ea3a264c5cc23bda3b2a50c (patch) | |
tree | f0924d9866b1a6323ca58be4b5e67e42ea8c5753 | |
parent | 142ac2a35af99ddd80636b8973c5ee082550c215 (diff) | |
download | rockbox-ca99f8efa49fbc053ea3a264c5cc23bda3b2a50c.tar.gz rockbox-ca99f8efa49fbc053ea3a264c5cc23bda3b2a50c.zip |
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
-rw-r--r-- | flash/bootbox/main.c | 14 | ||||
-rw-r--r-- | flash/bootloader/Makefile | 2 | ||||
-rw-r--r-- | flash/bootloader/bootloader.c | 40 | ||||
-rw-r--r-- | flash/bootloader/bootloader.h | 17 |
4 files changed, 33 insertions, 40 deletions
diff --git a/flash/bootbox/main.c b/flash/bootbox/main.c index 71708675f4..2bd3fea115 100644 --- a/flash/bootbox/main.c +++ b/flash/bootbox/main.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include "usb.h" | 44 | #include "usb.h" |
45 | #include "powermgmt.h" | 45 | #include "powermgmt.h" |
46 | 46 | ||
47 | void usb_screen(void) | 47 | static void usb_screen(void) |
48 | { | 48 | { |
49 | lcd_clear_display(); | 49 | lcd_clear_display(); |
50 | lcd_puts(0, 0, "USB mode"); | 50 | lcd_puts(0, 0, "USB mode"); |
@@ -55,7 +55,7 @@ void usb_screen(void) | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | void show_logo(void) | 58 | static void show_logo(void) |
59 | { | 59 | { |
60 | lcd_clear_display(); | 60 | lcd_clear_display(); |
61 | lcd_puts(0, 0, "Rockbox"); | 61 | lcd_puts(0, 0, "Rockbox"); |
@@ -64,13 +64,7 @@ void show_logo(void) | |||
64 | } | 64 | } |
65 | 65 | ||
66 | #if CONFIG_CHARGING | 66 | #if CONFIG_CHARGING |
67 | /* | 67 | static void charging_screen(void) |
68 | bool backlight_get_on_when_charging(void) | ||
69 | { | ||
70 | return false; | ||
71 | } | ||
72 | */ | ||
73 | void charging_screen(void) | ||
74 | { | 68 | { |
75 | unsigned int button; | 69 | unsigned int button; |
76 | const char* msg; | 70 | const char* msg; |
@@ -123,7 +117,7 @@ void charging_screen(void) | |||
123 | #endif /* CONFIG_CHARGING */ | 117 | #endif /* CONFIG_CHARGING */ |
124 | 118 | ||
125 | /* prompt user to plug USB and fix a problem */ | 119 | /* prompt user to plug USB and fix a problem */ |
126 | void prompt_usb(const char* msg1, const char* msg2) | 120 | static void prompt_usb(const char* msg1, const char* msg2) |
127 | { | 121 | { |
128 | int button; | 122 | int button; |
129 | lcd_clear_display(); | 123 | lcd_clear_display(); |
diff --git a/flash/bootloader/Makefile b/flash/bootloader/Makefile index 6872fcbc99..e7bd17aae9 100644 --- a/flash/bootloader/Makefile +++ b/flash/bootloader/Makefile | |||
@@ -35,7 +35,7 @@ DEFINES= -DPLATFORM_$(PLATFORM) | |||
35 | 35 | ||
36 | OBJDIR := . | 36 | OBJDIR := . |
37 | 37 | ||
38 | CFLAGS = -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(DEFINES) | 38 | CFLAGS = -Os -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(DEFINES) |
39 | AFLAGS += -small -relax | 39 | AFLAGS += -small -relax |
40 | 40 | ||
41 | 41 | ||
diff --git a/flash/bootloader/bootloader.c b/flash/bootloader/bootloader.c index dc094d1b2e..d1955c2ccd 100644 --- a/flash/bootloader/bootloader.c +++ b/flash/bootloader/bootloader.c | |||
@@ -27,6 +27,22 @@ | |||
27 | #include "sh7034.h" | 27 | #include "sh7034.h" |
28 | #include "bootloader.h" | 28 | #include "bootloader.h" |
29 | 29 | ||
30 | // prototypes | ||
31 | static void PlatformInit(void); | ||
32 | static int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len); | ||
33 | static void DecompressStart(tImage* pImage); | ||
34 | #ifdef USE_ADC | ||
35 | static int ReadADC(int channel); | ||
36 | #endif | ||
37 | static int ButtonPressed(void); | ||
38 | static tImage* GetStartImage(int nPreferred); | ||
39 | // test functions | ||
40 | static void SetLed(BOOL bOn); | ||
41 | static void UartInit(void); | ||
42 | static UINT8 UartRead(void); | ||
43 | static void UartWrite(UINT8 byte); | ||
44 | static void MiniMon(void); | ||
45 | |||
30 | 46 | ||
31 | #ifdef NO_ROM | 47 | #ifdef NO_ROM |
32 | /* start with the vector table */ | 48 | /* start with the vector table */ |
@@ -71,7 +87,7 @@ void _main(void) | |||
71 | } | 87 | } |
72 | 88 | ||
73 | 89 | ||
74 | void BootInit(void) | 90 | static void BootInit(void) |
75 | { | 91 | { |
76 | /* inits from the boot ROM, whether they make sense or not */ | 92 | /* inits from the boot ROM, whether they make sense or not */ |
77 | PBDR &= 0xFFBF; /* LED off (0x131E) */ | 93 | PBDR &= 0xFFBF; /* LED off (0x131E) */ |
@@ -117,7 +133,7 @@ int main(void) | |||
117 | 133 | ||
118 | 134 | ||
119 | /* init code that is specific to certain platform */ | 135 | /* init code that is specific to certain platform */ |
120 | void PlatformInit(void) | 136 | static void PlatformInit(void) |
121 | { | 137 | { |
122 | #ifdef NO_ROM | 138 | #ifdef NO_ROM |
123 | BootInit(); /* if not started by boot ROM, we need to init what it did */ | 139 | BootInit(); /* if not started by boot ROM, we need to init what it did */ |
@@ -177,7 +193,7 @@ void PlatformInit(void) | |||
177 | #define GETBIT(bb, src, ilen) \ | 193 | #define GETBIT(bb, src, ilen) \ |
178 | (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) | 194 | (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) |
179 | 195 | ||
180 | int ucl_nrv2e_decompress_8( | 196 | static int ucl_nrv2e_decompress_8( |
181 | const UINT8 *src, UINT8 *dst, UINT32* dst_len) | 197 | const UINT8 *src, UINT8 *dst, UINT32* dst_len) |
182 | { | 198 | { |
183 | UINT32 bb = 0; | 199 | UINT32 bb = 0; |
@@ -239,7 +255,7 @@ int ucl_nrv2e_decompress_8( | |||
239 | 255 | ||
240 | 256 | ||
241 | /* move the image into place and start it */ | 257 | /* move the image into place and start it */ |
242 | void DecompressStart(tImage* pImage) | 258 | static void DecompressStart(tImage* pImage) |
243 | { | 259 | { |
244 | UINT32* pSrc; | 260 | UINT32* pSrc; |
245 | UINT32* pDest; | 261 | UINT32* pDest; |
@@ -273,7 +289,7 @@ void DecompressStart(tImage* pImage) | |||
273 | } | 289 | } |
274 | 290 | ||
275 | #ifdef USE_ADC | 291 | #ifdef USE_ADC |
276 | int ReadADC(int channel) | 292 | static int ReadADC(int channel) |
277 | { | 293 | { |
278 | /* after channel 3, the ports wrap and get re-used */ | 294 | /* after channel 3, the ports wrap and get re-used */ |
279 | volatile UINT16* pResult = (UINT16*)(ADDRAH_ADDR + 2 * (channel & 0x03)); | 295 | volatile UINT16* pResult = (UINT16*)(ADDRAH_ADDR + 2 * (channel & 0x03)); |
@@ -289,7 +305,7 @@ int ReadADC(int channel) | |||
289 | 305 | ||
290 | /* This function is platform-dependent, | 306 | /* This function is platform-dependent, |
291 | * until I figure out how to distinguish at runtime. */ | 307 | * until I figure out how to distinguish at runtime. */ |
292 | int ButtonPressed(void) /* return 1,2,3 for F1,F2,F3, 0 if none pressed */ | 308 | static int ButtonPressed(void) /* return 1,2,3 for F1,F2,F3, 0 if none pressed */ |
293 | { | 309 | { |
294 | #ifdef USE_ADC | 310 | #ifdef USE_ADC |
295 | int value = ReadADC(CHANNEL); | 311 | int value = ReadADC(CHANNEL); |
@@ -316,7 +332,7 @@ int ButtonPressed(void) /* return 1,2,3 for F1,F2,F3, 0 if none pressed */ | |||
316 | 332 | ||
317 | 333 | ||
318 | /* Determine the image to be started */ | 334 | /* Determine the image to be started */ |
319 | tImage* GetStartImage(int nPreferred) | 335 | static tImage* GetStartImage(int nPreferred) |
320 | { | 336 | { |
321 | tImage* pImage1; | 337 | tImage* pImage1; |
322 | tImage* pImage2 = NULL; /* default to not present */ | 338 | tImage* pImage2 = NULL; /* default to not present */ |
@@ -357,7 +373,7 @@ tImage* GetStartImage(int nPreferred) | |||
357 | 373 | ||
358 | /* diagnostic functions */ | 374 | /* diagnostic functions */ |
359 | 375 | ||
360 | void SetLed(BOOL bOn) | 376 | static void SetLed(BOOL bOn) |
361 | { | 377 | { |
362 | if (bOn) | 378 | if (bOn) |
363 | PBDR |= 0x0040; | 379 | PBDR |= 0x0040; |
@@ -366,7 +382,7 @@ void SetLed(BOOL bOn) | |||
366 | } | 382 | } |
367 | 383 | ||
368 | 384 | ||
369 | void UartInit(void) | 385 | static void UartInit(void) |
370 | { | 386 | { |
371 | PBIOR &= 0xFBFF; /* input: RXD1 remote pin */ | 387 | PBIOR &= 0xFBFF; /* input: RXD1 remote pin */ |
372 | PBCR1 |= 0x00A0; /* set PB11+PB10 to UART */ | 388 | PBCR1 |= 0x00A0; /* set PB11+PB10 to UART */ |
@@ -378,7 +394,7 @@ void UartInit(void) | |||
378 | } | 394 | } |
379 | 395 | ||
380 | 396 | ||
381 | UINT8 UartRead(void) | 397 | static UINT8 UartRead(void) |
382 | { | 398 | { |
383 | UINT8 byte; | 399 | UINT8 byte; |
384 | while (!(SSR1 & SCI_RDRF)); /* wait for char to be available */ | 400 | while (!(SSR1 & SCI_RDRF)); /* wait for char to be available */ |
@@ -388,7 +404,7 @@ UINT8 UartRead(void) | |||
388 | } | 404 | } |
389 | 405 | ||
390 | 406 | ||
391 | void UartWrite(UINT8 byte) | 407 | static void UartWrite(UINT8 byte) |
392 | { | 408 | { |
393 | while (!(SSR1 & SCI_TDRE)); /* wait for transmit buffer empty */ | 409 | while (!(SSR1 & SCI_TDRE)); /* wait for transmit buffer empty */ |
394 | TDR1 = byte; | 410 | TDR1 = byte; |
@@ -397,7 +413,7 @@ void UartWrite(UINT8 byte) | |||
397 | 413 | ||
398 | 414 | ||
399 | /* include the mini monitor as a rescue feature, started with F3 */ | 415 | /* include the mini monitor as a rescue feature, started with F3 */ |
400 | void MiniMon(void) | 416 | static void MiniMon(void) |
401 | { | 417 | { |
402 | UINT8 cmd; | 418 | UINT8 cmd; |
403 | UINT32 addr; | 419 | UINT32 addr; |
diff --git a/flash/bootloader/bootloader.h b/flash/bootloader/bootloader.h index fc6bcb1eed..948311f55d 100644 --- a/flash/bootloader/bootloader.h +++ b/flash/bootloader/bootloader.h | |||
@@ -76,26 +76,9 @@ typedef struct | |||
76 | #define FLASH_BASE 0x02000000 // start of the flash memory | 76 | #define FLASH_BASE 0x02000000 // start of the flash memory |
77 | #define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version | 77 | #define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version |
78 | 78 | ||
79 | |||
80 | // prototypes | 79 | // prototypes |
81 | void _main(void) __attribute__ ((section (".startup"))); | 80 | void _main(void) __attribute__ ((section (".startup"))); |
82 | int main(void); | 81 | int main(void); |
83 | void PlatformInit(void); | ||
84 | void DramInit(void); | ||
85 | int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len); | ||
86 | void DecompressStart(tImage* pImage); | ||
87 | #ifdef USE_ADC | ||
88 | int ReadADC(int channel); | ||
89 | #endif | ||
90 | int ButtonPressed(void); | ||
91 | tImage* GetStartImage(int nPreferred); | ||
92 | // test functions | ||
93 | void SetLed(BOOL bOn); | ||
94 | void UartInit(void); | ||
95 | UINT8 UartRead(void); | ||
96 | void UartWrite(UINT8 byte); | ||
97 | void MiniMon(void); | ||
98 | |||
99 | 82 | ||
100 | // minimon commands | 83 | // minimon commands |
101 | #define BAUDRATE 0x00 // followed by BRR value; response: command byte | 84 | #define BAUDRATE 0x00 // followed by BRR value; response: command byte |