diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2008-11-12 05:11:18 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2008-11-12 05:11:18 +0000 |
commit | f32336e4a5ba3fe70e0af24b5d815518dfb223ea (patch) | |
tree | ca903b05de6ac0a0229a2c8ed0dac30800bbeb00 | |
parent | d922f31a09f391d2aac26b421e75611f83972b90 (diff) | |
download | rockbox-f32336e4a5ba3fe70e0af24b5d815518dfb223ea.tar.gz rockbox-f32336e4a5ba3fe70e0af24b5d815518dfb223ea.zip |
Last commit for the flash bootloader. The bootloader build works properly either flashed or unflashed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19098 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | bootloader/gigabeat.c | 82 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/crt0.S | 11 |
2 files changed, 85 insertions, 8 deletions
diff --git a/bootloader/gigabeat.c b/bootloader/gigabeat.c index 6b3a68be6e..11ab93a5e2 100644 --- a/bootloader/gigabeat.c +++ b/bootloader/gigabeat.c | |||
@@ -44,11 +44,29 @@ | |||
44 | #include "rbunicode.h" | 44 | #include "rbunicode.h" |
45 | #include "usb.h" | 45 | #include "usb.h" |
46 | #include "mmu-arm.h" | 46 | #include "mmu-arm.h" |
47 | #include "rtc.h" | ||
47 | 48 | ||
48 | #include <stdarg.h> | 49 | #include <stdarg.h> |
49 | 50 | ||
50 | char version[] = APPSVERSION; | 51 | char version[] = APPSVERSION; |
51 | 52 | ||
53 | void shutdown(void) | ||
54 | { | ||
55 | /* We need to gracefully spin down the disk to prevent clicks. */ | ||
56 | if (ide_powered()) | ||
57 | { | ||
58 | /* Make sure ATA has been initialized. */ | ||
59 | ata_init(); | ||
60 | |||
61 | /* And put the disk into sleep immediately. */ | ||
62 | ata_sleepnow(); | ||
63 | } | ||
64 | |||
65 | _backlight_off(); | ||
66 | |||
67 | power_off(); | ||
68 | } | ||
69 | |||
52 | void main(void) | 70 | void main(void) |
53 | { | 71 | { |
54 | unsigned char* loadbuffer; | 72 | unsigned char* loadbuffer; |
@@ -56,14 +74,72 @@ void main(void) | |||
56 | int rc; | 74 | int rc; |
57 | int(*kernel_entry)(void); | 75 | int(*kernel_entry)(void); |
58 | 76 | ||
59 | power_init(); | ||
60 | system_init(); | 77 | system_init(); |
61 | lcd_init(); | 78 | lcd_init(); |
62 | backlight_init(); | 79 | backlight_init(); |
80 | button_init(); | ||
63 | font_init(); | 81 | font_init(); |
82 | kernel_init(); /* Need the kernel to sleep */ | ||
83 | adc_init(); | ||
64 | 84 | ||
65 | lcd_setfont(FONT_SYSFIXED); | 85 | lcd_setfont(FONT_SYSFIXED); |
86 | |||
87 | /* These checks should only run if the bootloader is flashed */ | ||
88 | if(GSTATUS3&0x02) | ||
89 | { | ||
90 | GSTATUS3&=0xFFFFFFFD; | ||
91 | if(!(GPGDAT&BUTTON_POWER) && charger_inserted()) | ||
92 | { | ||
93 | while(!(GPGDAT&BUTTON_POWER) && charger_inserted()) | ||
94 | { | ||
95 | char msg[20]; | ||
96 | if(charging_state()) | ||
97 | { | ||
98 | snprintf(msg,sizeof(msg),"Charging"); | ||
99 | } | ||
100 | else | ||
101 | { | ||
102 | snprintf(msg,sizeof(msg),"Charge Complete"); | ||
103 | } | ||
104 | reset_screen(); | ||
105 | lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2, | ||
106 | (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); | ||
107 | lcd_update(); | ||
108 | |||
109 | #if defined(HAVE_RTC_ALARM) | ||
110 | /* Check if the alarm went off while charging */ | ||
111 | if(rtc_check_alarm_flag()) | ||
112 | { | ||
113 | GSTATUS3=1; /* Normally this is set in crt0.s */ | ||
114 | break; | ||
115 | } | ||
116 | #endif | ||
117 | } | ||
118 | if(!(GPGDAT&BUTTON_POWER) | ||
119 | #if defined(HAVE_RTC_ALARM) | ||
120 | && !GSTATUS3 | ||
121 | #endif | ||
122 | ) | ||
123 | { | ||
124 | shutdown(); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | if(button_hold()) | ||
129 | { | ||
130 | const char msg[] = "HOLD is enabled"; | ||
131 | reset_screen(); | ||
132 | lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2, | ||
133 | (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); | ||
134 | lcd_update(); | ||
135 | |||
136 | sleep(2*HZ); | ||
137 | |||
138 | shutdown(); | ||
139 | } | ||
140 | } | ||
66 | 141 | ||
142 | power_init(); | ||
67 | usb_init(); | 143 | usb_init(); |
68 | 144 | ||
69 | /* Enter USB mode without USB thread */ | 145 | /* Enter USB mode without USB thread */ |
@@ -88,9 +164,7 @@ void main(void) | |||
88 | lcd_update(); | 164 | lcd_update(); |
89 | } | 165 | } |
90 | 166 | ||
91 | kernel_init(); | 167 | reset_screen(); |
92 | adc_init(); | ||
93 | button_init(); | ||
94 | 168 | ||
95 | /* Show debug messages if button is pressed */ | 169 | /* Show debug messages if button is pressed */ |
96 | if(button_read_device()) | 170 | if(button_read_device()) |
diff --git a/firmware/target/arm/s3c2440/crt0.S b/firmware/target/arm/s3c2440/crt0.S index af0ef5bba8..a05fd78fe9 100644 --- a/firmware/target/arm/s3c2440/crt0.S +++ b/firmware/target/arm/s3c2440/crt0.S | |||
@@ -105,10 +105,13 @@ start: | |||
105 | ldr r1, [r2] | 105 | ldr r1, [r2] |
106 | ands r1, r1, #0x40000000 | 106 | ands r1, r1, #0x40000000 |
107 | 107 | ||
108 | /* Woke up with the alarm - store a flag in GSTATUS3 */ | 108 | /* Store a flag in GSTATUS3 to indicate that the bootloader is flashed */ |
109 | ldrne r2, =0x560000b8 | 109 | ldr r2, =0x560000b8 |
110 | movne r1, #0x01 | 110 | mov r1, #0x02 |
111 | strne r1, [r2] | 111 | |
112 | /* Woke up with the alarm? - store a flag in GSTATUS3 */ | ||
113 | orrne r1, r1, #0x01 | ||
114 | str r1, [r2] | ||
112 | bne poweron | 115 | bne poweron |
113 | 116 | ||
114 | /* Set GPG up to read power and menu status */ | 117 | /* Set GPG up to read power and menu status */ |