diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2007-02-22 21:38:59 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2007-02-22 21:38:59 +0000 |
commit | ec549ec42e359d9ded159f8e645b1601a8310c9d (patch) | |
tree | b9b05c704a2ba4b016118755cb6a01a6d838d6db /bootloader | |
parent | bd073cdb8d5eaaa504d3d9b3c31fe0296ca56ce0 (diff) | |
download | rockbox-ec549ec42e359d9ded159f8e645b1601a8310c9d.tar.gz rockbox-ec549ec42e359d9ded159f8e645b1601a8310c9d.zip |
Put the X5 bootloader in a separate file
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12456 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/SOURCES | 2 | ||||
-rw-r--r-- | bootloader/iaudio_x5.c | 199 | ||||
-rw-r--r-- | bootloader/main.c | 65 |
3 files changed, 202 insertions, 64 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES index 68002caf0b..92a4eb11ce 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES | |||
@@ -8,6 +8,8 @@ gigabeat.c | |||
8 | main-pp.c | 8 | main-pp.c |
9 | #elif defined(ELIO_TPJ1022) | 9 | #elif defined(ELIO_TPJ1022) |
10 | tpj1022.c | 10 | tpj1022.c |
11 | #elif defined(IAUDIO_X5) | ||
12 | iaudio_x5.c | ||
11 | #else | 13 | #else |
12 | main.c | 14 | main.c |
13 | #endif | 15 | #endif |
diff --git a/bootloader/iaudio_x5.c b/bootloader/iaudio_x5.c new file mode 100644 index 0000000000..412b8f03f6 --- /dev/null +++ b/bootloader/iaudio_x5.c | |||
@@ -0,0 +1,199 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: main.c 12453 2007-02-22 15:09:49Z linus $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
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" | ||
27 | #include "lcd.h" | ||
28 | #include "lcd-remote.h" | ||
29 | #include "kernel.h" | ||
30 | #include "thread.h" | ||
31 | #include "ata.h" | ||
32 | #include "usb.h" | ||
33 | #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 | |||
43 | #include "pcf50606.h" | ||
44 | #include "common.h" | ||
45 | |||
46 | #include <stdarg.h> | ||
47 | |||
48 | /* Maximum allowed firmware image size. 10MB is more than enough */ | ||
49 | #define MAX_LOADSIZE (10*1024*1024) | ||
50 | |||
51 | #define DRAM_START 0x31000000 | ||
52 | |||
53 | int usb_screen(void) | ||
54 | { | ||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | char version[] = APPSVERSION; | ||
59 | |||
60 | /* Reset the cookie for the crt0 crash check */ | ||
61 | inline void __reset_cookie(void) | ||
62 | { | ||
63 | asm(" move.l #0,%d0"); | ||
64 | asm(" move.l %d0,0x10017ffc"); | ||
65 | } | ||
66 | |||
67 | void start_firmware(void) | ||
68 | { | ||
69 | asm(" move.w #0x2700,%sr"); | ||
70 | __reset_cookie(); | ||
71 | asm(" move.l %0,%%d0" :: "i"(DRAM_START)); | ||
72 | asm(" movec.l %d0,%vbr"); | ||
73 | asm(" move.l %0,%%sp" :: "m"(*(int *)DRAM_START)); | ||
74 | asm(" move.l %0,%%a0" :: "m"(*(int *)(DRAM_START+4))); | ||
75 | asm(" jmp (%a0)"); | ||
76 | } | ||
77 | |||
78 | void shutdown(void) | ||
79 | { | ||
80 | printf("Shutting down..."); | ||
81 | |||
82 | /* We need to gracefully spin down the disk to prevent clicks. */ | ||
83 | if (ide_powered()) | ||
84 | { | ||
85 | /* Make sure ATA has been initialized. */ | ||
86 | ata_init(); | ||
87 | |||
88 | /* And put the disk into sleep immediately. */ | ||
89 | ata_sleepnow(); | ||
90 | } | ||
91 | |||
92 | sleep(HZ*2); | ||
93 | |||
94 | /* Backlight OFF */ | ||
95 | __backlight_off(); | ||
96 | #ifdef HAVE_REMOTE_LCD | ||
97 | __remote_backlight_off(); | ||
98 | #endif | ||
99 | |||
100 | __reset_cookie(); | ||
101 | power_off(); | ||
102 | } | ||
103 | |||
104 | /* Print the battery voltage (and a warning message). */ | ||
105 | void check_battery(void) | ||
106 | { | ||
107 | int adc_battery, battery_voltage, batt_int, batt_frac; | ||
108 | |||
109 | adc_battery = adc_read(ADC_BATTERY); | ||
110 | |||
111 | battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000; | ||
112 | batt_int = battery_voltage / 100; | ||
113 | batt_frac = battery_voltage % 100; | ||
114 | |||
115 | printf("Batt: %d.%02dV", batt_int, batt_frac); | ||
116 | |||
117 | if (battery_voltage <= 350) | ||
118 | { | ||
119 | printf("WARNING! BATTERY LOW!!"); | ||
120 | sleep(HZ*2); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | void main(void) | ||
125 | { | ||
126 | int i; | ||
127 | int rc; | ||
128 | bool rc_on_button = false; | ||
129 | bool on_button = false; | ||
130 | bool rec_button = false; | ||
131 | bool hold_status = false; | ||
132 | int data; | ||
133 | |||
134 | (void)rc_on_button; | ||
135 | (void)on_button; | ||
136 | (void)rec_button; | ||
137 | (void)hold_status; | ||
138 | (void)data; | ||
139 | power_init(); | ||
140 | |||
141 | system_init(); | ||
142 | kernel_init(); | ||
143 | |||
144 | set_cpu_frequency(CPUFREQ_NORMAL); | ||
145 | coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); | ||
146 | |||
147 | set_irq_level(0); | ||
148 | lcd_init(); | ||
149 | #ifdef HAVE_REMOTE_LCD | ||
150 | lcd_remote_init(); | ||
151 | #endif | ||
152 | backlight_init(); | ||
153 | font_init(); | ||
154 | adc_init(); | ||
155 | button_init(); | ||
156 | |||
157 | printf("Rockbox boot loader"); | ||
158 | printf("Version %s", version); | ||
159 | |||
160 | check_battery(); | ||
161 | |||
162 | rc = ata_init(); | ||
163 | if(rc) | ||
164 | { | ||
165 | printf("ATA error: %d", rc); | ||
166 | sleep(HZ*5); | ||
167 | power_off(); | ||
168 | } | ||
169 | |||
170 | disk_init(); | ||
171 | |||
172 | rc = disk_mount_all(); | ||
173 | if (rc<=0) | ||
174 | { | ||
175 | printf("No partition found"); | ||
176 | sleep(HZ*5); | ||
177 | power_off(); | ||
178 | } | ||
179 | |||
180 | printf("Loading firmware"); | ||
181 | i = load_firmware((unsigned char *)DRAM_START, BOOTFILE, MAX_LOADSIZE); | ||
182 | printf("Result: %s", strerror(i)); | ||
183 | |||
184 | if (i < EOK) { | ||
185 | printf("Error!"); | ||
186 | printf("Can't load rockbox.ipod:"); | ||
187 | printf(strerror(rc)); | ||
188 | sleep(HZ*3); | ||
189 | power_off(); | ||
190 | } else { | ||
191 | start_firmware(); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | /* These functions are present in the firmware library, but we reimplement | ||
196 | them here because the originals do a lot more than we want */ | ||
197 | void screen_dump(void) | ||
198 | { | ||
199 | } | ||
diff --git a/bootloader/main.c b/bootloader/main.c index c2e3cce302..27e3a8b303 100644 --- a/bootloader/main.c +++ b/bootloader/main.c | |||
@@ -370,70 +370,8 @@ void main(void) | |||
370 | bool rec_button = false; | 370 | bool rec_button = false; |
371 | bool hold_status = false; | 371 | bool hold_status = false; |
372 | int data; | 372 | int data; |
373 | |||
374 | #ifdef IAUDIO_X5 | ||
375 | (void)rc_on_button; | ||
376 | (void)on_button; | ||
377 | (void)rec_button; | ||
378 | (void)hold_status; | ||
379 | (void)data; | ||
380 | power_init(); | ||
381 | |||
382 | system_init(); | ||
383 | kernel_init(); | ||
384 | |||
385 | set_cpu_frequency(CPUFREQ_NORMAL); | ||
386 | coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); | ||
387 | |||
388 | set_irq_level(0); | ||
389 | lcd_init(); | ||
390 | #ifdef HAVE_REMOTE_LCD | ||
391 | lcd_remote_init(); | ||
392 | #endif | ||
393 | backlight_init(); | ||
394 | font_init(); | ||
395 | adc_init(); | ||
396 | button_init(); | ||
397 | |||
398 | printf("Rockbox boot loader"); | ||
399 | printf("Version %s", version); | ||
400 | |||
401 | check_battery(); | ||
402 | |||
403 | rc = ata_init(); | ||
404 | if(rc) | ||
405 | { | ||
406 | printf("ATA error: %d", rc); | ||
407 | sleep(HZ*5); | ||
408 | power_off(); | ||
409 | } | ||
410 | |||
411 | disk_init(); | ||
412 | |||
413 | rc = disk_mount_all(); | ||
414 | if (rc<=0) | ||
415 | { | ||
416 | printf("No partition found"); | ||
417 | sleep(HZ*5); | ||
418 | power_off(); | ||
419 | } | ||
420 | |||
421 | printf("Loading firmware"); | ||
422 | i = load_firmware((unsigned char *)DRAM_START, BOOTFILE, MAX_LOADSIZE); | ||
423 | printf("Result: %s", strerror(i)); | ||
424 | |||
425 | if (i < EOK) { | ||
426 | printf("Error!"); | ||
427 | printf("Can't load rockbox.ipod:"); | ||
428 | printf(strerror(rc)); | ||
429 | sleep(HZ*3); | ||
430 | power_off(); | ||
431 | } else { | ||
432 | start_firmware(); | ||
433 | } | ||
434 | |||
435 | #else | ||
436 | extern int line; | 373 | extern int line; |
374 | |||
437 | /* We want to read the buttons as early as possible, before the user | 375 | /* We want to read the buttons as early as possible, before the user |
438 | releases the ON button */ | 376 | releases the ON button */ |
439 | 377 | ||
@@ -644,7 +582,6 @@ void main(void) | |||
644 | } | 582 | } |
645 | else | 583 | else |
646 | start_iriver_fw(); | 584 | start_iriver_fw(); |
647 | #endif /* IAUDIO_X5 */ | ||
648 | } | 585 | } |
649 | 586 | ||
650 | /* These functions are present in the firmware library, but we reimplement | 587 | /* These functions are present in the firmware library, but we reimplement |