freemyipod r127 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r126‎ | r127 | r128 >
Date:23:18, 13 August 2010
Author:theseven
Status:new
Tags:
Comment:
Add execfirmware syscall and USB command
Modified paths:
  • /embios/trunk/arm/contextswitch.S (modified) (history)
  • /embios/trunk/contextswitch.h (modified) (history)
  • /embios/trunk/export/syscallapi.h (modified) (history)
  • /embios/trunk/export/syscallwrappers.h (modified) (history)
  • /embios/trunk/shutdown.c (modified) (history)
  • /embios/trunk/shutdown.h (modified) (history)
  • /embios/trunk/syscallapi.c (modified) (history)
  • /embios/trunk/usb/usb.c (modified) (history)

Diff [purge]

Index: embios/trunk/shutdown.c
@@ -25,7 +25,7 @@
2626 #include "storage.h"
2727
2828
29 -void shutdown()
 29+void shutdown(bool shutdownhw)
3030 {
3131 DEBUGF("Shutting down...");
3232 #ifdef HAVE_STORAGE_FLUSH
Index: embios/trunk/shutdown.h
@@ -28,7 +28,7 @@
2929 #include "global.h"
3030
3131
32 -void shutdown();
 32+void shutdown(bool shutdownhw);
3333
3434
3535 #endif
Index: embios/trunk/arm/contextswitch.S
@@ -142,5 +142,12 @@
143143 mov pc, lr
144144 .size leave_critical_section, .-leave_critical_section
145145
 146+.global execfirmware
 147+.type execfirmware, %function
 148+execfirmware:
 149+ msr cpsr_c, #0xd3
 150+ bx r0
 151+.size execfirmware, .-execfirmware
 152+
146153 unknown_swi_string:
147154 .ascii "Unhandled SWI %06X\0"
Index: embios/trunk/export/syscallwrappers.h
@@ -174,6 +174,7 @@
175175 #define tlsf_check_heap(args...) __embios_syscall->tlsf_check_heap(args)
176176 #define tlsf_block_size(args...) __embios_syscall->tlsf_block_size(args)
177177 #define tlsf_overhead(args...) __embios_syscall->tlsf_overhead(args)
 178+#define execfirmware(args...) __embios_syscall->execfirmware(args)
178179
179180
180181 #endif
Index: embios/trunk/export/syscallapi.h
@@ -48,6 +48,7 @@
4949 #include "../backlight.h"
5050 #include "../syscall.h"
5151 #include "../progressbar.h"
 52+#include "../contextswitch.h"
5253 #include "../libc/include/string.h"
5354 #include "../libc/include/stdlib.h"
5455 #include "../libc/include/stdio.h"
@@ -209,6 +210,7 @@
210211 typeof(tlsf_check_heap) *tlsf_check_heap;
211212 typeof(tlsf_block_size) *tlsf_block_size;
212213 typeof(tlsf_overhead) *tlsf_overhead;
 214+ typeof(execfirmware) *execfirmware;
213215 };
214216
215217
Index: embios/trunk/syscallapi.c
@@ -108,6 +108,7 @@
109109 .tlsf_check_heap = tlsf_check_heap,
110110 .tlsf_block_size = tlsf_block_size,
111111 .tlsf_overhead = tlsf_overhead,
 112+ .execfirmware = execfirmware,
112113 #ifdef HAVE_STORAGE
113114 .opendir = opendir,
114115 .closedir = closedir,
Index: embios/trunk/usb/usb.c
@@ -59,6 +59,7 @@
6060 DBGACTION_CREAD,
6161 DBGACTION_CFLUSH,
6262 DBGACTION_EXECIMAGE,
 63+ DBGACTION_EXECFIRMWARE,
6364 DBGACTION_READBOOTFLASH,
6465 DBGACTION_WRITEBOOTFLASH
6566 };
@@ -533,6 +534,10 @@
534535 dbgactionlength = dbgrecvbuf[3];
535536 break;
536537 #endif
 538+ case 24: // EXECFIRMWARE
 539+ if (set_dbgaction(DBGACTION_EXECFIRMWARE, 0)) break;
 540+ dbgactionaddr = dbgrecvbuf[1];
 541+ break;
537542 default:
538543 dbgsendbuf[0] = 2;
539544 size = 16;
@@ -593,11 +598,11 @@
594599 break;
595600 #endif
596601 case DBGACTION_POWEROFF:
597 - if (dbgactiontype) shutdown();
 602+ if (dbgactiontype) shutdown(true);
598603 power_off();
599604 break;
600605 case DBGACTION_RESET:
601 - shutdown();
 606+ shutdown(false);
602607 reset();
603608 break;
604609 case DBGACTION_CWRITE:
@@ -621,6 +626,11 @@
622627 dbgasyncsendbuf[1] = execimage((void*)dbgactionaddr);
623628 usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
624629 break;
 630+ case DBGACTION_EXECFIRMWARE:
 631+ shutdown(false);
 632+ dbgasyncsendbuf[0] = 1;
 633+ usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
 634+ execfirmware((void*)dbgactionaddr);
625635 #ifdef HAVE_BOOTFLASH
626636 case DBGACTION_READBOOTFLASH:
627637 bootflash_readraw((void*)dbgactionaddr, dbgactionoffset, dbgactionlength);
Index: embios/trunk/contextswitch.h
@@ -33,6 +33,7 @@
3434 void resume_thread(void) __attribute__((noreturn)) ICODE_ATTR;
3535 uint32_t enter_critical_section(void) ICODE_ATTR;
3636 void leave_critical_section(uint32_t mode) ICODE_ATTR;
 37+void execfirmware(void* addr) ICODE_ATTR;
3738
3839
3940 #endif