summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHristo Kovachev <bger@rockbox.org>2006-08-11 09:51:04 +0000
committerHristo Kovachev <bger@rockbox.org>2006-08-11 09:51:04 +0000
commit1204136632777e84eac790811fb074552ef2e6b7 (patch)
tree0261c054c38a06a2e0f3b9cc869a774650eb3ce9
parent79f60d4054fdf0e97dca9817c778c74847d18ba0 (diff)
downloadrockbox-1204136632777e84eac790811fb074552ef2e6b7.tar.gz
rockbox-1204136632777e84eac790811fb074552ef2e6b7.zip
Some indent/c99 style cleanup by Barry Wardell
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10524 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/h10.c252
-rw-r--r--firmware/target/arm/iriver/h10/backlight-h10.c2
-rw-r--r--firmware/target/arm/iriver/h10/button-h10.c44
-rw-r--r--firmware/target/arm/iriver/h10/power-h10.c6
-rw-r--r--firmware/target/arm/iriver/h10/usb-h10.c6
5 files changed, 156 insertions, 154 deletions
diff --git a/bootloader/h10.c b/bootloader/h10.c
index e80e28fe5b..d7942c9583 100644
--- a/bootloader/h10.c
+++ b/bootloader/h10.c
@@ -66,10 +66,10 @@ static void memmove16(void *dest, const void *src, unsigned count)
66} 66}
67 67
68 68
69/* Load original iriver firmware. This function expects a file called "H10_20GC.mi4" in 69/* Load original iriver firmware. This function expects a file called
70 the root directory of the player. It should be decrypted and have the header stripped 70 "H10_20GC.mi4" in the root directory of the player. It should be decrypted
71 using mi4code. It reads the file in to a memory buffer called buf. The rest of the 71 and have the header stripped using mi4code. It reads the file in to a memory
72 loading is done in main() 72 buffer called buf. The rest of the loading is done in main()
73*/ 73*/
74int load_iriver(unsigned char* buf) 74int load_iriver(unsigned char* buf)
75{ 75{
@@ -93,144 +93,146 @@ unsigned char loadbuffer[MAX_LOADSIZE];
93 93
94void main(void) 94void main(void)
95{ 95{
96 /* Attempt to load original iriver firmware. Successfully starts loading the iriver 96 /* Attempt to load original iriver firmware. Successfully starts loading the
97 firmware but then locks up once the "System Initialising" screen is displayed. 97 iriver firmware but then locks up once the "System Initialising" screen
98 98 is displayed.
99 The iriver firmware was decrypted and the header removed. It was then appended to 99
100 the end of bootloader.bin and an mi4 file was created from the resulting file. 100 The iriver firmware was decrypted and the header removed. It was then
101 101 appended to the end of bootloader.bin and an mi4 file was created from
102 The original firmware starts at 0xd800 in the file and is of length 0x47da00. 102 the resulting file.
103 103
104 The whole file (bootloader.bin + decrypted mi4) are loaded to memory by the 104 The original firmware starts at 0xd800 in the file and is of length
105 original iriver bootloader on startup. This copies the mi4 part to the start 105 0x47da00.
106 of DRAM and passes execution to there. 106
107 107 The whole file (bootloader.bin + decrypted mi4) are loaded to memory by
108 memmove16((void*)DRAMORIG, (void*)(DRAMORIG + 0xd800), 0x47da00); 108 the original iriver bootloader on startup. This copies the mi4 part to
109 asm volatile( 109 the start of DRAM and passes execution to there.
110 "mov r0, #" SC(DRAMORIG) "\n" 110
111 "mov pc, r0 \n" 111 memmove16((void*)DRAMORIG, (void*)(DRAMORIG + 0xd800), 0x47da00);
112 ); 112 asm volatile(
113 */ 113 "mov r0, #" SC(DRAMORIG) "\n"
114 "mov pc, r0 \n"
115 );
116 */
114 117
115 int i; 118 int i;
116 int rc; 119 int rc;
117 int btn; 120 int btn;
121 int fd;
122 char buffer[24];
118 123
119 i=ata_init(); 124 i=ata_init();
120 disk_init(); 125 disk_init();
121 rc = disk_mount_all(); 126 rc = disk_mount_all();
122 127
123 /* Load original iriver firmware. Uses load_iriver(buf) to load the decrypted mi4 file from 128 /* Load original iriver firmware. Uses load_iriver(buf) to load the
124 disk to DRAM. This then copies that part of DRAM to the start of DRAM and passes 129 decrypted mi4 file from disk to DRAM. This then copies that part of DRAM
125 execution to there. 130 to the start of DRAM and passes
126 131 execution to there.
127 rc=load_iriver(loadbuffer); 132
128 memcpy((void*)DRAMORIG,loadbuffer,rc); 133 rc=load_iriver(loadbuffer);
129 asm volatile( 134 memcpy((void*)DRAMORIG,loadbuffer,rc);
130 "mov r0, #" SC(DRAMORIG) "\n" 135 asm volatile(
131 "mov pc, r0 \n" 136 "mov r0, #" SC(DRAMORIG) "\n"
132 );*/ 137 "mov pc, r0 \n"
133 138 );*/
134 139
135 /* This assumes that /test.txt exists */ 140
136 int fd; 141 /* This assumes that /test.txt exists */
137 char buffer[24]; 142 fd=open("/test.txt",O_RDWR);
138 fd=open("/test.txt",O_RDWR); 143
139 144
140 145 /*
141 /* WARNING: Running this code on the H10 caused permanent damage to my H10's hdd 146 for(i=0;i<100;i++){
142 I strongly recommend against trying it. 147 btn = button_read_device();
143 148 switch(btn){
144 for(i=0;i<100;i++){ 149 case BUTTON_LEFT:
145 btn = button_read_device(); 150 snprintf(buffer, sizeof(buffer), "Left");
146 switch(btn){ 151 write(fd,buffer,sizeof(buffer));
147 case BUTTON_LEFT: 152 break;
148 snprintf(buffer, sizeof(buffer), "Left"); 153 case BUTTON_RIGHT:
149 write(fd,buffer,sizeof(buffer)); 154 break;
150 break; 155 case BUTTON_REW:
151 case BUTTON_RIGHT: 156 break;
152 break; 157 case BUTTON_FF:
153 case BUTTON_REW: 158 break;
154 break; 159 case BUTTON_PLAY:
155 case BUTTON_FF: 160 break;
156 break; 161 default:
157 case BUTTON_PLAY: 162 break;
158 break; 163 }
159 default: 164
160 break;
161 }
162
163 165
164 } 166 }
165 */ 167 */
166 168
167 169
168 170
169 /* Investigate gpio 171 /* Investigate gpio
170 172
171 unsigned int gpio_a, gpio_b, gpio_c, gpio_d; 173 unsigned int gpio_a, gpio_b, gpio_c, gpio_d;
172 unsigned int gpio_e, gpio_f, gpio_g, gpio_h; 174 unsigned int gpio_e, gpio_f, gpio_g, gpio_h;
173 unsigned int gpio_i, gpio_j, gpio_k, gpio_l; 175 unsigned int gpio_i, gpio_j, gpio_k, gpio_l;
174 176
175 gpio_a = GPIOA_INPUT_VAL; 177 gpio_a = GPIOA_INPUT_VAL;
176 gpio_b = GPIOB_INPUT_VAL; 178 gpio_b = GPIOB_INPUT_VAL;
177 gpio_c = GPIOC_INPUT_VAL; 179 gpio_c = GPIOC_INPUT_VAL;
178 180
179 gpio_g = GPIOG_INPUT_VAL; 181 gpio_g = GPIOG_INPUT_VAL;
180 gpio_h = GPIOH_INPUT_VAL; 182 gpio_h = GPIOH_INPUT_VAL;
181 gpio_i = GPIOI_INPUT_VAL; 183 gpio_i = GPIOI_INPUT_VAL;
182 184
183 snprintf(buffer, sizeof(buffer), "GPIO_A: %02x GPIO_G: %02x\n", gpio_a, gpio_g); 185 snprintf(buffer,sizeof(buffer),"GPIO_A: %02x GPIO_G: %02x\n",gpio_a,gpio_g);
184 write(fd,buffer,sizeof(buffer)); 186 write(fd,buffer,sizeof(buffer));
185 snprintf(buffer, sizeof(buffer), "GPIO_B: %02x GPIO_H: %02x\n", gpio_b, gpio_h); 187 snprintf(buffer,sizeof(buffer),"GPIO_B: %02x GPIO_H: %02x\n",gpio_b,gpio_h);
186 write(fd,buffer,sizeof(buffer)); 188 write(fd,buffer,sizeof(buffer));
187 snprintf(buffer, sizeof(buffer), "GPIO_C: %02x GPIO_I: %02x\n", gpio_c, gpio_i); 189 snprintf(buffer,sizeof(buffer),"GPIO_C: %02x GPIO_I: %02x\n",gpio_c,gpio_i);
188 write(fd,buffer,sizeof(buffer)); 190 write(fd,buffer,sizeof(buffer));
189 191
190 gpio_d = GPIOD_INPUT_VAL; 192 gpio_d = GPIOD_INPUT_VAL;
191 gpio_e = GPIOE_INPUT_VAL; 193 gpio_e = GPIOE_INPUT_VAL;
192 gpio_f = GPIOF_INPUT_VAL; 194 gpio_f = GPIOF_INPUT_VAL;
193 195
194 gpio_j = GPIOJ_INPUT_VAL; 196 gpio_j = GPIOJ_INPUT_VAL;
195 gpio_k = GPIOK_INPUT_VAL; 197 gpio_k = GPIOK_INPUT_VAL;
196 gpio_l = GPIOL_INPUT_VAL; 198 gpio_l = GPIOL_INPUT_VAL;
197 199
198 snprintf(buffer, sizeof(buffer), "GPIO_D: %02x GPIO_J: %02x\n", gpio_d, gpio_j); 200 snprintf(buffer,sizeof(buffer),"GPIO_D: %02x GPIO_J: %02x\n",gpio_d,gpio_j);
199 write(fd,buffer,sizeof(buffer)); 201 write(fd,buffer,sizeof(buffer));
200 snprintf(buffer, sizeof(buffer), "GPIO_E: %02x GPIO_K: %02x\n", gpio_e, gpio_k); 202 snprintf(buffer,sizeof(buffer),"GPIO_E: %02x GPIO_K: %02x\n",gpio_e,gpio_k);
201 write(fd,buffer,sizeof(buffer)); 203 write(fd,buffer,sizeof(buffer));
202 snprintf(buffer, sizeof(buffer), "GPIO_F: %02x GPIO_L: %02x\n", gpio_f, gpio_l); 204 snprintf(buffer,sizeof(buffer),"GPIO_F: %02x GPIO_L: %02x\n",gpio_f,gpio_l);
203 write(fd,buffer,sizeof(buffer)); 205 write(fd,buffer,sizeof(buffer));
204 */ 206 */
205 207
206 208
207 209
208 /* Detect the scroller being touched 210 /* Detect the scroller being touched
209 211
210 int j = 0; 212 int j = 0;
211 for(j=0;j<1000;j++){ 213 for(j=0;j<1000;j++){
212 if(gpio_c!=0xF7){ 214 if(gpio_c!=0xF7){
213 snprintf(buffer, sizeof(buffer), "GPIO_C: %02x\n", gpio_c); 215 snprintf(buffer, sizeof(buffer), "GPIO_C: %02x\n", gpio_c);
214 write(fd,buffer,sizeof(buffer)); 216 write(fd,buffer,sizeof(buffer));
215 } 217 }
216 if(gpio_d!=0xDD){ 218 if(gpio_d!=0xDD){
217 snprintf(buffer, sizeof(buffer), "GPIO_D: %02x\n", gpio_d); 219 snprintf(buffer, sizeof(buffer), "GPIO_D: %02x\n", gpio_d);
218 write(fd,buffer,sizeof(buffer)); 220 write(fd,buffer,sizeof(buffer));
219 } 221 }
220 }*/ 222 }*/
221 223
222 224
223 /* Apparently necessary for the data to be actually written to file */ 225 /* Apparently necessary for the data to be actually written to file */
224 fsync(fd); 226 fsync(fd);
225 udelay(1000000); 227 udelay(1000000);
226 228
227 /* This causes the device to shut off instantly 229 /* This causes the device to shut off instantly
228 230
229 GPIOF_OUTPUT_VAL = 0; 231 GPIOF_OUTPUT_VAL = 0;
230 */ 232 */
231 233
232 close(fd); 234 close(fd);
233 udelay(1000000); 235 udelay(1000000);
234} 236}
235 237
236/* These functions are present in the firmware library, but we reimplement 238/* These functions are present in the firmware library, but we reimplement
diff --git a/firmware/target/arm/iriver/h10/backlight-h10.c b/firmware/target/arm/iriver/h10/backlight-h10.c
index b4221dd60a..51218e21be 100644
--- a/firmware/target/arm/iriver/h10/backlight-h10.c
+++ b/firmware/target/arm/iriver/h10/backlight-h10.c
@@ -28,7 +28,7 @@
28void __backlight_on(void) 28void __backlight_on(void)
29{ 29{
30#if 0 30#if 0
31 int level = set_irq_level(HIGHEST_IRQ_LEVEL); 31 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
32 pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */ 32 pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */
33 set_irq_level(level); 33 set_irq_level(level);
34#endif 34#endif
diff --git a/firmware/target/arm/iriver/h10/button-h10.c b/firmware/target/arm/iriver/h10/button-h10.c
index 7979a52976..2a5983e97a 100644
--- a/firmware/target/arm/iriver/h10/button-h10.c
+++ b/firmware/target/arm/iriver/h10/button-h10.c
@@ -33,7 +33,7 @@
33 33
34void button_init_device(void) 34void button_init_device(void)
35{ 35{
36 /* No hardware initialisation required as it is done by the bootloader */ 36 /* No hardware initialisation required as it is done by the bootloader */
37} 37}
38 38
39bool button_hold(void) 39bool button_hold(void)
@@ -47,8 +47,8 @@ bool button_hold(void)
47int button_read_device(void) 47int button_read_device(void)
48{ 48{
49 int btn = BUTTON_NONE; 49 int btn = BUTTON_NONE;
50 unsigned char state; 50 unsigned char state;
51 static bool hold_button = false; 51 static bool hold_button = false;
52 52
53#if 0 53#if 0
54 /* light handling */ 54 /* light handling */
@@ -59,25 +59,25 @@ int button_read_device(void)
59#endif 59#endif
60 60
61 hold_button = button_hold(); 61 hold_button = button_hold();
62 if (!hold_button) 62 if (!hold_button)
63 { 63 {
64 /* Read normal buttons */ 64 /* Read normal buttons */
65 state = GPIOA_INPUT_VAL & 0xf8; 65 state = GPIOA_INPUT_VAL & 0xf8;
66 if ((state & 0x8) == 0) btn |= BUTTON_FF; 66 if ((state & 0x8) == 0) btn |= BUTTON_FF;
67 if ((state & 0x10) == 0) btn |= BUTTON_PLAY; 67 if ((state & 0x10) == 0) btn |= BUTTON_PLAY;
68 if ((state & 0x20) == 0) btn |= BUTTON_REW; 68 if ((state & 0x20) == 0) btn |= BUTTON_REW;
69 if ((state & 0x40) == 0) btn |= BUTTON_RIGHT; 69 if ((state & 0x40) == 0) btn |= BUTTON_RIGHT;
70 if ((state & 0x80) == 0) btn |= BUTTON_LEFT; 70 if ((state & 0x80) == 0) btn |= BUTTON_LEFT;
71 71
72 /* Read power button */ 72 /* Read power button */
73 if ((GPIOB_INPUT_VAL & 0x1) == 0) btn |= BUTTON_POWER; 73 if ((GPIOB_INPUT_VAL & 0x1) == 0) btn |= BUTTON_POWER;
74 74
75 /* Read scroller */ 75 /* Read scroller */
76 if ( ((GPIOC_INPUT_VAL & 0x4)==1) && ((GPIOD_INPUT_VAL & 0x10)==1) ) 76 if ( ((GPIOC_INPUT_VAL & 0x4)==1) && ((GPIOD_INPUT_VAL & 0x10)==1) )
77 { 77 {
78 /* Scroller is pressed */ 78 /* Scroller is pressed */
79 } 79 }
80 } 80 }
81 81
82 return btn; 82 return btn;
83} 83}
diff --git a/firmware/target/arm/iriver/h10/power-h10.c b/firmware/target/arm/iriver/h10/power-h10.c
index 58dd25174f..71eae2105e 100644
--- a/firmware/target/arm/iriver/h10/power-h10.c
+++ b/firmware/target/arm/iriver/h10/power-h10.c
@@ -71,7 +71,7 @@ void power_init(void)
71 71
72bool charger_inserted(void) 72bool charger_inserted(void)
73{ 73{
74 return (GPIOL_INPUT_VAL & 0x04)?true:false; /* FIXME: This only checks if USB is connected */ 74 return (GPIOL_INPUT_VAL & 0x04)?true:false; /* FIXME: This only checks if USB is connected */
75} 75}
76 76
77void ide_power_enable(bool on) 77void ide_power_enable(bool on)
@@ -90,10 +90,10 @@ bool ide_powered(void)
90void power_off(void) 90void power_off(void)
91{ 91{
92 /* set_irq_level(HIGHEST_IRQ_LEVEL);*/ 92 /* set_irq_level(HIGHEST_IRQ_LEVEL);*/
93 #ifndef BOOTLOADER 93 #ifndef BOOTLOADER
94 /* We don't turn off the ipod, we put it in a deep sleep */ 94 /* We don't turn off the ipod, we put it in a deep sleep */
95 /* pcf50605_standby_mode(); */ 95 /* pcf50605_standby_mode(); */
96 while(1) 96 while(1)
97 yield(); 97 yield();
98 #endif 98 #endif
99} 99}
diff --git a/firmware/target/arm/iriver/h10/usb-h10.c b/firmware/target/arm/iriver/h10/usb-h10.c
index dccdea81aa..c6d275a9be 100644
--- a/firmware/target/arm/iriver/h10/usb-h10.c
+++ b/firmware/target/arm/iriver/h10/usb-h10.c
@@ -92,10 +92,10 @@ bool usb_detect(void)
92 92
93void usb_enable(bool on) 93void usb_enable(bool on)
94{ 94{
95 (void)on; 95 (void)on;
96#if 0 96#if 0
97 /* For the ipod, we can only do one thing with USB mode - reboot 97 /* For the ipod, we can only do one thing with USB mode - reboot
98 into Apple's flash-based disk-mode. This does not return. */ 98 into Apple's flash-based disk-mode. This does not return. */
99 if (on) 99 if (on)
100 { 100 {
101 /* The following code is copied from ipodlinux */ 101 /* The following code is copied from ipodlinux */