diff options
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/main.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/bootloader/main.c b/bootloader/main.c index 4f1ee3c120..8ca44e8c47 100644 --- a/bootloader/main.c +++ b/bootloader/main.c | |||
@@ -69,7 +69,7 @@ int load_firmware(void) | |||
69 | if(fd < 0) | 69 | if(fd < 0) |
70 | return -1; | 70 | return -1; |
71 | 71 | ||
72 | len = lseek(fd, 0, SEEK_END) - 8; | 72 | len = filesize(fd) - 8; |
73 | 73 | ||
74 | snprintf(str, 80, "Length: %x", len); | 74 | snprintf(str, 80, "Length: %x", len); |
75 | lcd_puts(0, line++, str); | 75 | lcd_puts(0, line++, str); |
@@ -122,11 +122,10 @@ void start_firmware(void) | |||
122 | asm(" jmp (%a0)"); | 122 | asm(" jmp (%a0)"); |
123 | } | 123 | } |
124 | 124 | ||
125 | int main(void) | 125 | void main(void) |
126 | { | 126 | { |
127 | int i; | 127 | int i; |
128 | int rc; | 128 | int rc; |
129 | int button; | ||
130 | char buf[256]; | 129 | char buf[256]; |
131 | 130 | ||
132 | power_init(); | 131 | power_init(); |
@@ -141,15 +140,30 @@ int main(void) | |||
141 | 140 | ||
142 | lcd_setfont(FONT_SYSFIXED); | 141 | lcd_setfont(FONT_SYSFIXED); |
143 | 142 | ||
144 | sleep(HZ/10); /* Allow the button driver to check the buttons */ | 143 | sleep(HZ/50); /* Allow the button driver to check the buttons */ |
145 | 144 | ||
146 | if(button_status() & BUTTON_REC) { | 145 | if(button_status() & BUTTON_REC || |
146 | button_status() & BUTTON_RC_ON) { | ||
147 | lcd_puts(0, 8, "Starting original firmware..."); | 147 | lcd_puts(0, 8, "Starting original firmware..."); |
148 | lcd_update(); | 148 | lcd_update(); |
149 | sleep(HZ); | ||
150 | start_iriver_fw(); | 149 | start_iriver_fw(); |
151 | } | 150 | } |
152 | 151 | ||
152 | if((button_status() & BUTTON_ON) & button_hold()) { | ||
153 | lcd_puts(0, 8, "HOLD switch on, power off..."); | ||
154 | lcd_update(); | ||
155 | sleep(HZ/2); | ||
156 | power_off(); | ||
157 | } | ||
158 | #if 0 | ||
159 | if((button_status() & BUTTON_RC_ON) & remote_button_hold()) { | ||
160 | lcd_puts(0, 8, "HOLD switch on, power off..."); | ||
161 | lcd_update(); | ||
162 | sleep(HZ/2); | ||
163 | power_off(); | ||
164 | } | ||
165 | #endif | ||
166 | |||
153 | rc = ata_init(); | 167 | rc = ata_init(); |
154 | if(rc) | 168 | if(rc) |
155 | { | 169 | { |
@@ -186,14 +200,7 @@ int main(void) | |||
186 | if(i == 0) | 200 | if(i == 0) |
187 | start_firmware(); | 201 | start_firmware(); |
188 | 202 | ||
189 | while(1) { | 203 | start_iriver_fw(); |
190 | button = button_get_w_tmo(HZ/2); | ||
191 | if(button) | ||
192 | { | ||
193 | if(button == (BUTTON_OFF | BUTTON_REPEAT)) | ||
194 | power_off(); | ||
195 | } | ||
196 | } | ||
197 | } | 204 | } |
198 | 205 | ||
199 | /* These functions are present in the firmware library, but we reimplement | 206 | /* These functions are present in the firmware library, but we reimplement |