diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-05-07 07:14:39 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-05-07 07:14:39 +0000 |
commit | c41cacaf30ce5222001e6cb088ce594b3b4f9525 (patch) | |
tree | 15542914fd8df0bea7cffd171bd19916e2329a8c | |
parent | 82cda9b091744d3ee44ea9a6b14f623499083fb5 (diff) | |
download | rockbox-c41cacaf30ce5222001e6cb088ce594b3b4f9525.tar.gz rockbox-c41cacaf30ce5222001e6cb088ce594b3b4f9525.zip |
Do some gigabeat S bootloader cleanup (includes, const, static-ing, number of variables, etc.). Make sure a tar file isn't too big before loading it however unlikely that is. No overall functional change but bump to v.00000013 for tracking purposes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17403 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | bootloader/gigabeat-s.c | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c index abfe57ce1f..30c2955c19 100644 --- a/bootloader/gigabeat-s.c +++ b/bootloader/gigabeat-s.c | |||
@@ -17,48 +17,32 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "config.h" | 19 | #include "config.h" |
20 | |||
21 | #include <stdlib.h> | ||
22 | #include <stdio.h> | ||
23 | #include "inttypes.h" | ||
24 | #include "string.h" | ||
25 | #include "cpu.h" | ||
26 | #include "system.h" | 20 | #include "system.h" |
27 | #include "lcd.h" | 21 | #include <sprintf.h> |
28 | #include "kernel.h" | 22 | #include "kernel.h" |
29 | #include "thread.h" | 23 | #include "string.h" |
30 | #include "ata.h" | 24 | #include "ata.h" |
31 | #include "dir.h" | 25 | #include "dir.h" |
32 | #include "fat.h" | ||
33 | #include "disk.h" | 26 | #include "disk.h" |
34 | #include "font.h" | ||
35 | #include "adc.h" | ||
36 | #include "backlight.h" | ||
37 | #include "backlight-target.h" | ||
38 | #include "button.h" | ||
39 | #include "panic.h" | ||
40 | #include "power.h" | ||
41 | #include "file.h" | ||
42 | #include "common.h" | 27 | #include "common.h" |
43 | #include "rbunicode.h" | ||
44 | #include "usb.h" | 28 | #include "usb.h" |
45 | #include "mmu-imx31.h" | 29 | #include "font.h" |
46 | #include "lcd-target.h" | 30 | #include "lcd.h" |
47 | #include "avic-imx31.h" | ||
48 | #include <stdarg.h> | ||
49 | #include "usb-target.h" | 31 | #include "usb-target.h" |
50 | 32 | ||
51 | #define TAR_CHUNK 512 | 33 | #define TAR_CHUNK 512 |
52 | #define TAR_HEADER_SIZE 157 | 34 | #define TAR_HEADER_SIZE 157 |
53 | 35 | ||
54 | char version[] = APPSVERSION; | 36 | const char version[] = APPSVERSION; |
55 | char basedir[] = "/Content/0b00/00/"; /* Where files sent via MTP are stored */ | 37 | /* Where files sent via MTP are stored */ |
56 | int (*kernel_entry)(void); | 38 | static const char basedir[] = "/Content/0b00/00/"; |
57 | char *tarbuf = (char *)0x00000040; | 39 | /* Can use memory after vector table up to 0x01f00000 */ |
58 | extern void reference_system_c(void); | 40 | static char * const tarbuf = (char *)0x00000040; |
41 | static const size_t tarbuf_size = 0x01f00000 - 0x00000040; | ||
42 | /* Queue to get notifications when in USB mode */ | ||
59 | static struct event_queue usb_wait_queue; | 43 | static struct event_queue usb_wait_queue; |
60 | 44 | ||
61 | void show_splash(int timeout, const char *msg) | 45 | static void show_splash(int timeout, const char *msg) |
62 | { | 46 | { |
63 | lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2, | 47 | lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2, |
64 | (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); | 48 | (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); |
@@ -67,13 +51,19 @@ void show_splash(int timeout, const char *msg) | |||
67 | sleep(timeout); | 51 | sleep(timeout); |
68 | } | 52 | } |
69 | 53 | ||
70 | void untar(int tar_fd) | 54 | static void untar(int tar_fd) |
71 | { | 55 | { |
72 | char header[TAR_HEADER_SIZE]; | 56 | char header[TAR_HEADER_SIZE]; |
73 | char *ptr; | 57 | char *ptr; |
74 | char path[102]; | 58 | char path[102]; |
75 | int fd, i, size = 0; | 59 | int fd, i; |
76 | int ret; | 60 | int ret; |
61 | size_t size = filesize(tar_fd); | ||
62 | |||
63 | if (size > tarbuf_size) { | ||
64 | printf("tar file too large"); /* Paranoid but proper */ | ||
65 | return; | ||
66 | } | ||
77 | 67 | ||
78 | ret = read(tar_fd, tarbuf, filesize(tar_fd)); | 68 | ret = read(tar_fd, tarbuf, filesize(tar_fd)); |
79 | if (ret < 0) { | 69 | if (ret < 0) { |
@@ -151,7 +141,7 @@ void main(void) | |||
151 | invalidate_icache(); | 141 | invalidate_icache(); |
152 | 142 | ||
153 | lcd_clear_display(); | 143 | lcd_clear_display(); |
154 | printf("Gigabeat S Rockbox Bootloader v.00000012"); | 144 | printf("Gigabeat S Rockbox Bootloader v.00000013"); |
155 | system_init(); | 145 | system_init(); |
156 | kernel_init(); | 146 | kernel_init(); |
157 | printf("kernel init done"); | 147 | printf("kernel init done"); |
@@ -286,9 +276,8 @@ void main(void) | |||
286 | 276 | ||
287 | if (rc == EOK) | 277 | if (rc == EOK) |
288 | { | 278 | { |
289 | kernel_entry = (void*) loadbuffer; | ||
290 | invalidate_icache(); | 279 | invalidate_icache(); |
291 | rc = kernel_entry(); | 280 | asm volatile ("bx %0": : "r"(loadbuffer)); |
292 | } | 281 | } |
293 | 282 | ||
294 | /* Halt */ | 283 | /* Halt */ |