Index: embios/trunk/shutdown.c |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | #include "storage.h"
|
27 | 27 |
|
28 | 28 |
|
29 | | -void shutdown()
|
| 29 | +void shutdown(bool shutdownhw)
|
30 | 30 | {
|
31 | 31 | DEBUGF("Shutting down...");
|
32 | 32 | #ifdef HAVE_STORAGE_FLUSH
|
Index: embios/trunk/shutdown.h |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | #include "global.h"
|
30 | 30 |
|
31 | 31 |
|
32 | | -void shutdown();
|
| 32 | +void shutdown(bool shutdownhw);
|
33 | 33 |
|
34 | 34 |
|
35 | 35 | #endif
|
Index: embios/trunk/arm/contextswitch.S |
— | — | @@ -142,5 +142,12 @@ |
143 | 143 | mov pc, lr
|
144 | 144 | .size leave_critical_section, .-leave_critical_section
|
145 | 145 |
|
| 146 | +.global execfirmware
|
| 147 | +.type execfirmware, %function
|
| 148 | +execfirmware:
|
| 149 | + msr cpsr_c, #0xd3
|
| 150 | + bx r0
|
| 151 | +.size execfirmware, .-execfirmware
|
| 152 | +
|
146 | 153 | unknown_swi_string:
|
147 | 154 | .ascii "Unhandled SWI %06X\0"
|
Index: embios/trunk/export/syscallwrappers.h |
— | — | @@ -174,6 +174,7 @@ |
175 | 175 | #define tlsf_check_heap(args...) __embios_syscall->tlsf_check_heap(args)
|
176 | 176 | #define tlsf_block_size(args...) __embios_syscall->tlsf_block_size(args)
|
177 | 177 | #define tlsf_overhead(args...) __embios_syscall->tlsf_overhead(args)
|
| 178 | +#define execfirmware(args...) __embios_syscall->execfirmware(args)
|
178 | 179 |
|
179 | 180 |
|
180 | 181 | #endif
|
Index: embios/trunk/export/syscallapi.h |
— | — | @@ -48,6 +48,7 @@ |
49 | 49 | #include "../backlight.h"
|
50 | 50 | #include "../syscall.h"
|
51 | 51 | #include "../progressbar.h"
|
| 52 | +#include "../contextswitch.h"
|
52 | 53 | #include "../libc/include/string.h"
|
53 | 54 | #include "../libc/include/stdlib.h"
|
54 | 55 | #include "../libc/include/stdio.h"
|
— | — | @@ -209,6 +210,7 @@ |
210 | 211 | typeof(tlsf_check_heap) *tlsf_check_heap;
|
211 | 212 | typeof(tlsf_block_size) *tlsf_block_size;
|
212 | 213 | typeof(tlsf_overhead) *tlsf_overhead;
|
| 214 | + typeof(execfirmware) *execfirmware;
|
213 | 215 | };
|
214 | 216 |
|
215 | 217 |
|
Index: embios/trunk/syscallapi.c |
— | — | @@ -108,6 +108,7 @@ |
109 | 109 | .tlsf_check_heap = tlsf_check_heap,
|
110 | 110 | .tlsf_block_size = tlsf_block_size,
|
111 | 111 | .tlsf_overhead = tlsf_overhead,
|
| 112 | + .execfirmware = execfirmware,
|
112 | 113 | #ifdef HAVE_STORAGE
|
113 | 114 | .opendir = opendir,
|
114 | 115 | .closedir = closedir,
|
Index: embios/trunk/usb/usb.c |
— | — | @@ -59,6 +59,7 @@ |
60 | 60 | DBGACTION_CREAD,
|
61 | 61 | DBGACTION_CFLUSH,
|
62 | 62 | DBGACTION_EXECIMAGE,
|
| 63 | + DBGACTION_EXECFIRMWARE,
|
63 | 64 | DBGACTION_READBOOTFLASH,
|
64 | 65 | DBGACTION_WRITEBOOTFLASH
|
65 | 66 | };
|
— | — | @@ -533,6 +534,10 @@ |
534 | 535 | dbgactionlength = dbgrecvbuf[3];
|
535 | 536 | break;
|
536 | 537 | #endif
|
| 538 | + case 24: // EXECFIRMWARE
|
| 539 | + if (set_dbgaction(DBGACTION_EXECFIRMWARE, 0)) break;
|
| 540 | + dbgactionaddr = dbgrecvbuf[1];
|
| 541 | + break;
|
537 | 542 | default:
|
538 | 543 | dbgsendbuf[0] = 2;
|
539 | 544 | size = 16;
|
— | — | @@ -593,11 +598,11 @@ |
594 | 599 | break;
|
595 | 600 | #endif
|
596 | 601 | case DBGACTION_POWEROFF:
|
597 | | - if (dbgactiontype) shutdown();
|
| 602 | + if (dbgactiontype) shutdown(true);
|
598 | 603 | power_off();
|
599 | 604 | break;
|
600 | 605 | case DBGACTION_RESET:
|
601 | | - shutdown();
|
| 606 | + shutdown(false);
|
602 | 607 | reset();
|
603 | 608 | break;
|
604 | 609 | case DBGACTION_CWRITE:
|
— | — | @@ -621,6 +626,11 @@ |
622 | 627 | dbgasyncsendbuf[1] = execimage((void*)dbgactionaddr);
|
623 | 628 | usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
624 | 629 | 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);
|
625 | 635 | #ifdef HAVE_BOOTFLASH
|
626 | 636 | case DBGACTION_READBOOTFLASH:
|
627 | 637 | bootflash_readraw((void*)dbgactionaddr, dbgactionoffset, dbgactionlength);
|
Index: embios/trunk/contextswitch.h |
— | — | @@ -33,6 +33,7 @@ |
34 | 34 | void resume_thread(void) __attribute__((noreturn)) ICODE_ATTR;
|
35 | 35 | uint32_t enter_critical_section(void) ICODE_ATTR;
|
36 | 36 | void leave_critical_section(uint32_t mode) ICODE_ATTR;
|
| 37 | +void execfirmware(void* addr) ICODE_ATTR;
|
37 | 38 |
|
38 | 39 |
|
39 | 40 | #endif
|