summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/rolo.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/firmware/rolo.c b/firmware/rolo.c
index 08223ae889..46819d82fb 100644
--- a/firmware/rolo.c
+++ b/firmware/rolo.c
@@ -30,6 +30,54 @@
30 30
31#define IRQ0_EDGE_TRIGGER 0x80 31#define IRQ0_EDGE_TRIGGER 0x80
32 32
33/* test code, to be removed later */
34extern union /* defined in main.c */
35{
36 unsigned char port8 [512];
37 unsigned short port16[256];
38 unsigned port32[128];
39} startup_io;
40
41
42bool rolo_io_load(char* filename)
43{
44 int fd;
45 fd = open(filename, O_RDONLY);
46 if(fd >= 0) /* no complaint if it doesn't exit */
47 {
48 read(fd, (void *)&startup_io, sizeof(startup_io));
49 close(fd);
50 return true; /* success */
51 }
52 return false; /* not found */
53}
54
55void rolo_io_restore(void)
56{
57 int i;
58 for (i = 0; i < 512; i++)
59 { /* most can be written with 8 bit access */
60 *((volatile unsigned char*)0x5FFFE00 + i) = startup_io.port8[i];
61 }
62 /* some don't allow that, write with 32 bit if aligned */
63 *((volatile unsigned char*)0x5FFFF40) = startup_io.port32[0x140/4];
64 *((volatile unsigned char*)0x5FFFF44) = startup_io.port32[0x144/4];
65 *((volatile unsigned char*)0x5FFFF50) = startup_io.port32[0x150/4];
66 *((volatile unsigned char*)0x5FFFF54) = startup_io.port32[0x154/4];
67 *((volatile unsigned char*)0x5FFFF60) = startup_io.port32[0x160/4];
68 *((volatile unsigned char*)0x5FFFF70) = startup_io.port32[0x170/4];
69 *((volatile unsigned char*)0x5FFFF74) = startup_io.port32[0x174/4];
70
71 /* write the rest with 16 bit */
72 *((volatile unsigned short*)0x5FFFF4A) = startup_io.port16[0x14A/2];
73 *((volatile unsigned short*)0x5FFFF5A) = startup_io.port16[0x15A/2];
74 *((volatile unsigned short*)0x5FFFF6A) = startup_io.port16[0x16A/2];
75 *((volatile unsigned short*)0x5FFFF7A) = startup_io.port16[0x17A/2];
76}
77/* end of test code */
78
79
80
33static void rolo_error(char *text) 81static void rolo_error(char *text)
34{ 82{
35 lcd_clear_display(); 83 lcd_clear_display();
@@ -55,6 +103,7 @@ int rolo_load(char* filename)
55 unsigned short checksum,file_checksum; 103 unsigned short checksum,file_checksum;
56 unsigned char* ramstart = (void*)0x09000000; 104 unsigned char* ramstart = (void*)0x09000000;
57 void (*start_func)(void) = (void*)ramstart + 0x200; 105 void (*start_func)(void) = (void*)ramstart + 0x200;
106 bool restore_io; /* debug value */
58 107
59 lcd_clear_display(); 108 lcd_clear_display();
60 lcd_puts(0, 0, "ROLO..."); 109 lcd_puts(0, 0, "ROLO...");
@@ -122,6 +171,8 @@ int rolo_load(char* filename)
122 return -1; 171 return -1;
123 } 172 }
124 173
174 restore_io = rolo_io_load("/startup_io.bin"); /* test code, recycle a variable */
175
125 lcd_puts(0, 1, "Executing "); 176 lcd_puts(0, 1, "Executing ");
126 lcd_update(); 177 lcd_update();
127 178
@@ -135,6 +186,9 @@ int rolo_load(char* filename)
135 i2c_init(); /* Init i2c bus - it seems like a good idea */ 186 i2c_init(); /* Init i2c bus - it seems like a good idea */
136 ICR = IRQ0_EDGE_TRIGGER; /* Make IRQ0 edge triggered */ 187 ICR = IRQ0_EDGE_TRIGGER; /* Make IRQ0 edge triggered */
137 188
189 if (restore_io) /* test code */
190 rolo_io_restore(); /* restore the I/Os from the file content */
191
138 /* move firmware to start of ram */ 192 /* move firmware to start of ram */
139 for ( i=0; i < length/4+1; i++ ) 193 for ( i=0; i < length/4+1; i++ )
140 ((unsigned int*)ramstart)[i] = ((unsigned int*)mp3buf)[i]; 194 ((unsigned int*)ramstart)[i] = ((unsigned int*)mp3buf)[i];