AAC codec: accept M4B files.
[kugel-rb.git] / bootloader / gigabeat.c
blobc04042cead06450c5daf27c07a9897942a75801a
1 #include "config.h"
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include "cpu.h"
7 #include "system.h"
8 #include "lcd.h"
9 #include "kernel.h"
10 #include "thread.h"
11 #include "ata.h"
12 #include "fat.h"
13 #include "disk.h"
14 #include "font.h"
15 #include "adc.h"
16 #include "backlight.h"
17 #include "panic.h"
18 #include "power.h"
19 #include "file.h"
21 char version[] = APPSVERSION;
23 void go_usb_mode(void) {
24 /* Drop into USB mode. This does not check for disconnection. */
26 int i;
28 GPBDAT &= 0x7EF;
29 GPBCON |= 1<<8;
31 GPGDAT &= 0xE7FF;
32 GPGDAT |= 1<<11;
34 for (i = 0; i < 10000000; i++) {continue;}
36 GPBCON &= 0x2FFCFF;
37 GPBDAT |= 1<<5;
38 GPBDAT |= 1<<6;
41 void * main(void)
43 int line = 0, i;
44 char buf[256];
45 struct partinfo* pinfo;
46 unsigned short* identify_info;
47 int testfile;
49 lcd_init();
50 lcd_setfont(FONT_SYSFIXED);
52 lcd_puts(0, line++, "Rockbox boot loader");
53 snprintf(buf, sizeof(buf), "Version: 20%s", version);
54 lcd_puts(0, line++, buf);
55 snprintf(buf, sizeof(buf), "Gigabeat version: 0x%08x", 1);
56 lcd_puts(0, line++, buf);
59 lcd_puts(0, line++, "Hold MENU when booting for rescue mode.");
60 lcd_update();
62 /* hold MENU to enter rescue mode */
63 if (GPGDAT & 2) {
64 lcd_puts(0, line++, "Entering rescue mode..");
65 lcd_update();
66 go_usb_mode();
67 while(1);
70 i = ata_init();
71 i = disk_mount_all();
73 snprintf(buf, sizeof(buf), "disk_mount_all: %d", i);
74 lcd_puts(0, line++, buf);
76 identify_info = ata_get_identify();
78 for (i=0; i < 20; i++)
79 ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
81 buf[40]=0;
83 /* kill trailing space */
84 for (i=39; i && buf[i]==' '; i--)
85 buf[i] = 0;
87 lcd_puts(0, line++, "Model");
88 lcd_puts(0, line++, buf);
90 for (i=0; i < 4; i++)
91 ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]);
93 buf[8]=0;
95 lcd_puts(0, line++, "Firmware");
96 lcd_puts(0, line++, buf);
98 pinfo = disk_partinfo(0);
99 snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB",
100 pinfo->type, pinfo->size / 2048);
101 lcd_puts(0, line++, buf);
103 testfile = open("/boottest.txt", O_WRONLY|O_CREAT|O_TRUNC);
104 write(testfile, "It works!", 9);
105 close(testfile);
107 lcd_update();
109 /* now wait in USB mode so the bootloader can be updated */
110 go_usb_mode();
111 while(1);
113 return((void *)0);