diff options
author | Daniel Stenberg <daniel@haxx.se> | 2006-08-02 09:47:17 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2006-08-02 09:47:17 +0000 |
commit | 5747049a44df9fdead2bbb1fcce5e2ba620fd826 (patch) | |
tree | b0b1c5f3928ded28b44828f0eac079d63044088f /bootloader | |
parent | 6a8aebbce7be63d426187d1bbc6171f41ad133c1 (diff) | |
download | rockbox-5747049a44df9fdead2bbb1fcce5e2ba620fd826.tar.gz rockbox-5747049a44df9fdead2bbb1fcce5e2ba620fd826.zip |
cut out all the ipod cruft we don't need
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10408 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/e200.c | 235 |
1 files changed, 1 insertions, 234 deletions
diff --git a/bootloader/e200.c b/bootloader/e200.c index 2cf78942a2..efbbfe8ae0 100644 --- a/bootloader/e200.c +++ b/bootloader/e200.c | |||
@@ -73,213 +73,7 @@ extern image_t boot_table[]; | |||
73 | 73 | ||
74 | int line=0; | 74 | int line=0; |
75 | 75 | ||
76 | static void memmove16(void *dest, const void *src, unsigned count) | 76 | void main(void) |
77 | { | ||
78 | struct bufstr { | ||
79 | unsigned _buf[4]; | ||
80 | } *d, *s; | ||
81 | |||
82 | if (src >= dest) { | ||
83 | count = (count + 15) >> 4; | ||
84 | d = (struct bufstr *) dest; | ||
85 | s = (struct bufstr *) src; | ||
86 | while (count--) | ||
87 | *d++ = *s++; | ||
88 | } else { | ||
89 | count = (count + 15) >> 4; | ||
90 | d = (struct bufstr *)(dest + (count <<4)); | ||
91 | s = (struct bufstr *)(src + (count <<4)); | ||
92 | while (count--) | ||
93 | *--d = *--s; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | #if CONFIG_KEYPAD == IPOD_4G_PAD && !defined(IPOD_MINI) | ||
98 | /* check if number of seconds has past */ | ||
99 | int timer_check(int clock_start, unsigned int usecs) | ||
100 | { | ||
101 | if ((USEC_TIMER - clock_start) >= usecs) { | ||
102 | return 1; | ||
103 | } else { | ||
104 | return 0; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | static void ser_opto_keypad_cfg(int val) | ||
109 | { | ||
110 | int start_time; | ||
111 | |||
112 | outl(inl(0x6000d004) & ~0x80, 0x6000d004); | ||
113 | |||
114 | outl(inl(0x7000c104) | 0xc000000, 0x7000c104); | ||
115 | outl(val, 0x7000c120); | ||
116 | outl(inl(0x7000c100) | 0x80000000, 0x7000c100); | ||
117 | |||
118 | outl(inl(0x6000d024) & ~0x10, 0x6000d024); | ||
119 | outl(inl(0x6000d014) | 0x10, 0x6000d014); | ||
120 | |||
121 | start_time = USEC_TIMER; | ||
122 | do { | ||
123 | if ((inl(0x7000c104) & 0x80000000) == 0) { | ||
124 | break; | ||
125 | } | ||
126 | } while (timer_check(start_time, 1500) != 0); | ||
127 | |||
128 | outl(inl(0x7000c100) & ~0x80000000, 0x7000c100); | ||
129 | |||
130 | outl(inl(0x6000d004) | 0x80, 0x6000d004); | ||
131 | outl(inl(0x6000d024) | 0x10, 0x6000d024); | ||
132 | outl(inl(0x6000d014) & ~0x10, 0x6000d014); | ||
133 | |||
134 | outl(inl(0x7000c104) | 0xc000000, 0x7000c104); | ||
135 | outl(inl(0x7000c100) | 0x60000000, 0x7000c100); | ||
136 | } | ||
137 | |||
138 | int opto_keypad_read(void) | ||
139 | { | ||
140 | int loop_cnt, had_io = 0; | ||
141 | |||
142 | for (loop_cnt = 5; loop_cnt != 0;) | ||
143 | { | ||
144 | int key_pressed = 0; | ||
145 | int start_time; | ||
146 | unsigned int key_pad_val; | ||
147 | |||
148 | ser_opto_keypad_cfg(0x8000023a); | ||
149 | |||
150 | start_time = USEC_TIMER; | ||
151 | do { | ||
152 | if (inl(0x7000c104) & 0x4000000) { | ||
153 | had_io = 1; | ||
154 | break; | ||
155 | } | ||
156 | |||
157 | if (had_io != 0) { | ||
158 | break; | ||
159 | } | ||
160 | } while (timer_check(start_time, 1500) != 0); | ||
161 | |||
162 | key_pad_val = inl(0x7000c140); | ||
163 | if ((key_pad_val & ~0x7fff0000) != 0x8000023a) { | ||
164 | loop_cnt--; | ||
165 | } else { | ||
166 | key_pad_val = (key_pad_val << 11) >> 27; | ||
167 | key_pressed = 1; | ||
168 | } | ||
169 | |||
170 | outl(inl(0x7000c100) | 0x60000000, 0x7000c100); | ||
171 | outl(inl(0x7000c104) | 0xc000000, 0x7000c104); | ||
172 | |||
173 | if (key_pressed != 0) { | ||
174 | return key_pad_val ^ 0x1f; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | #endif | ||
181 | |||
182 | static int key_pressed(void) | ||
183 | { | ||
184 | unsigned char state; | ||
185 | |||
186 | #if CONFIG_KEYPAD == IPOD_4G_PAD | ||
187 | #ifdef IPOD_MINI /* mini 1G only */ | ||
188 | state = GPIOA_INPUT_VAL & 0x3f; | ||
189 | if ((state & 0x10) == 0) return BUTTON_LEFT; | ||
190 | if ((state & 0x2) == 0) return BUTTON_MENU; | ||
191 | if ((state & 0x4) == 0) return BUTTON_PLAY; | ||
192 | if ((state & 0x8) == 0) return BUTTON_RIGHT; | ||
193 | #else | ||
194 | state = opto_keypad_read(); | ||
195 | if ((state & 0x4) == 0) return BUTTON_LEFT; | ||
196 | if ((state & 0x10) == 0) return BUTTON_MENU; | ||
197 | if ((state & 0x8) == 0) return BUTTON_PLAY; | ||
198 | if ((state & 0x2) == 0) return BUTTON_RIGHT; | ||
199 | #endif | ||
200 | #elif CONFIG_KEYPAD == IPOD_3G_PAD | ||
201 | state = inb(0xcf000030); | ||
202 | if (((state & 0x20) == 0)) return BUTTON_HOLD; /* hold on */ | ||
203 | if ((state & 0x08) == 0) return BUTTON_LEFT; | ||
204 | if ((state & 0x10) == 0) return BUTTON_MENU; | ||
205 | if ((state & 0x04) == 0) return BUTTON_PLAY; | ||
206 | if ((state & 0x01) == 0) return BUTTON_RIGHT; | ||
207 | #endif | ||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | int load_rockbox(unsigned char* buf) | ||
212 | { | ||
213 | int fd; | ||
214 | int rc; | ||
215 | int len; | ||
216 | unsigned long chksum; | ||
217 | char model[5]; | ||
218 | unsigned long sum; | ||
219 | int i; | ||
220 | char str[80]; | ||
221 | |||
222 | fd = open("/.rockbox/" BOOTFILE, O_RDONLY); | ||
223 | if(fd < 0) | ||
224 | { | ||
225 | fd = open("/" BOOTFILE, O_RDONLY); | ||
226 | if(fd < 0) | ||
227 | return -1; | ||
228 | } | ||
229 | |||
230 | len = filesize(fd) - 8; | ||
231 | |||
232 | if (len > MAX_LOADSIZE) | ||
233 | return -6; | ||
234 | |||
235 | lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET); | ||
236 | |||
237 | rc = read(fd, &chksum, 4); | ||
238 | chksum=betoh32(chksum); /* Rockbox checksums are big-endian */ | ||
239 | if(rc < 4) | ||
240 | return -2; | ||
241 | |||
242 | rc = read(fd, model, 4); | ||
243 | if(rc < 4) | ||
244 | return -3; | ||
245 | |||
246 | model[4] = 0; | ||
247 | |||
248 | snprintf(str, 80, "Model: %s", model); | ||
249 | lcd_puts(0, line++, str); | ||
250 | snprintf(str, 80, "Checksum: %x", chksum); | ||
251 | lcd_puts(0, line++, str); | ||
252 | lcd_update(); | ||
253 | |||
254 | lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); | ||
255 | |||
256 | rc = read(fd, buf, len); | ||
257 | if(rc < len) | ||
258 | return -4; | ||
259 | |||
260 | close(fd); | ||
261 | |||
262 | sum = MODEL_NUMBER; | ||
263 | |||
264 | for(i = 0;i < len;i++) { | ||
265 | sum += buf[i]; | ||
266 | } | ||
267 | |||
268 | snprintf(str, 80, "Sum: %x", sum); | ||
269 | lcd_puts(0, line++, str); | ||
270 | lcd_update(); | ||
271 | |||
272 | if(sum != chksum) | ||
273 | return -5; | ||
274 | |||
275 | return len; | ||
276 | } | ||
277 | |||
278 | |||
279 | /* A buffer to load the Linux kernel or Rockbox into */ | ||
280 | unsigned char loadbuffer[MAX_LOADSIZE]; | ||
281 | |||
282 | void* main(void) | ||
283 | { | 77 | { |
284 | char buf[256]; | 78 | char buf[256]; |
285 | int imageno=0; | 79 | int imageno=0; |
@@ -290,33 +84,6 @@ void* main(void) | |||
290 | void* entry; | 84 | void* entry; |
291 | struct partinfo* pinfo; | 85 | struct partinfo* pinfo; |
292 | unsigned short* identify_info; | 86 | unsigned short* identify_info; |
293 | |||
294 | /* Turn on the backlight */ | ||
295 | |||
296 | #if CONFIG_BACKLIGHT==BL_IPOD4G | ||
297 | /* brightness full */ | ||
298 | outl(0x80000000 | (0xff << 16), 0x7000a010); | ||
299 | |||
300 | /* set port B03 on */ | ||
301 | outl(((0x100 | 1) << 3), 0x6000d824); | ||
302 | |||
303 | #elif CONFIG_BACKLIGHT==BL_IPODMINI | ||
304 | /* set port B03 on */ | ||
305 | outl(((0x100 | 1) << 3), 0x6000d824); | ||
306 | |||
307 | #elif CONFIG_BACKLIGHT==BL_IPODNANO | ||
308 | |||
309 | /* set port B03 on */ | ||
310 | outl(((0x100 | 1) << 3), 0x6000d824); | ||
311 | |||
312 | /* set port L07 on */ | ||
313 | outl(((0x100 | 1) << 7), 0x6000d12c); | ||
314 | #elif CONFIG_BACKLIGHT==BL_IPOD3G | ||
315 | outl(inl(IPOD_LCD_BASE) | 0x2, IPOD_LCD_BASE); | ||
316 | #endif | ||
317 | |||
318 | /* Return the start address in loaded image */ | ||
319 | return entry; | ||
320 | } | 87 | } |
321 | 88 | ||
322 | /* These functions are present in the firmware library, but we reimplement | 89 | /* These functions are present in the firmware library, but we reimplement |