| Index: emcore/trunk/arm/contextswitch.S |
| — | — | @@ -151,11 +151,13 @@ |
| 152 | 152 | .global execfirmware
|
| 153 | 153 | .type execfirmware, %function
|
| 154 | 154 | execfirmware:
|
| 155 | | - str r0, [sp,#-4]!
|
| | 155 | + stmfd sp!, {r0-r2}
|
| 156 | 156 | bl interrupt_shutdown
|
| | 157 | + msr cpsr_c, #0xd3
|
| | 158 | + ldmfd sp, {r0-r2}
|
| | 159 | + bl memmove
|
| 157 | 160 | bl clean_dcache
|
| 158 | | - ldr r1, [sp], #4
|
| 159 | | - msr cpsr_c, #0xd3
|
| | 161 | + ldr r1, [sp]
|
| 160 | 162 | mrc p15, 0, r0,c1,c0
|
| 161 | 163 | bic r0, r0, #5
|
| 162 | 164 | mcr p15, 0, r0,c1,c0
|
| Index: emcore/trunk/usb/usb.c |
| — | — | @@ -81,7 +81,12 @@ |
| 82 | 82 | DBGACTION_HWKEYAES,
|
| 83 | 83 | DBGACTION_HMACSHA1,
|
| 84 | 84 | DBGACTION_TARGETSPECIFIC,
|
| 85 | | - DBGACTION_STORAGE
|
| | 85 | + DBGACTION_STORAGE,
|
| | 86 | + DBGACTION_MALLOC,
|
| | 87 | + DBGACTION_MEMALIGN,
|
| | 88 | + DBGACTION_REALLOC,
|
| | 89 | + DBGACTION_REOWNALLOC,
|
| | 90 | + DBGACTION_FREE
|
| 86 | 91 | };
|
| 87 | 92 |
|
| 88 | 93 | static struct scheduler_thread dbgthread_handle IBSS_ATTR;
|
| — | — | @@ -107,8 +112,8 @@ |
| 108 | 113 |
|
| 109 | 114 | static const char dbgconoverflowstr[] = "\n\n[overflowed]\n\n";
|
| 110 | 115 |
|
| 111 | | -extern int _initstart; // These aren't ints at all, but gcc complains about void types being
|
| 112 | | -extern int _sdramstart; // used here, and we only need the address, so just make it happy...
|
| | 116 | +extern int _poolstart; // These aren't ints at all, but gcc complains about void types being
|
| | 117 | +extern int _poolend; // used here, and we only need the address, so just make it happy...
|
| 113 | 118 |
|
| 114 | 119 |
|
| 115 | 120 | static struct usb_device_descriptor CACHEALIGN_ATTR device_descriptor =
|
| — | — | @@ -373,8 +378,8 @@ |
| 374 | 379 | dbgsendbuf[3] = usb_drv_get_max_in_size();
|
| 375 | 380 | break;
|
| 376 | 381 | case 2: // GET USER MEMORY INFO
|
| 377 | | - dbgsendbuf[1] = (uint32_t)&_initstart;
|
| 378 | | - dbgsendbuf[2] = (uint32_t)&_sdramstart;
|
| | 382 | + dbgsendbuf[1] = (uint32_t)&_poolstart;
|
| | 383 | + dbgsendbuf[2] = (uint32_t)&_poolend;
|
| 379 | 384 | break;
|
| 380 | 385 | default:
|
| 381 | 386 | dbgsendbuf[0] = 2;
|
| — | — | @@ -537,7 +542,7 @@ |
| 538 | 543 | dbgsendbuf[0] = 1;
|
| 539 | 544 | size = 16;
|
| 540 | 545 | break;
|
| 541 | | - case 19: // KILL THREAD
|
| | 546 | + case 19: // CREATE THREAD
|
| 542 | 547 | dbgsendbuf[0] = 1;
|
| 543 | 548 | dbgsendbuf[1] = (uint32_t)thread_create(NULL, (const char*)(dbgsendbuf[1]),
|
| 544 | 549 | (const void*)(dbgsendbuf[2]),
|
| — | — | @@ -573,6 +578,8 @@ |
| 574 | 579 | case 24: // EXECFIRMWARE
|
| 575 | 580 | if (set_dbgaction(DBGACTION_EXECFIRMWARE, 0)) break;
|
| 576 | 581 | dbgactionaddr = dbgrecvbuf[1];
|
| | 582 | + dbgactionoffset = dbgrecvbuf[2];
|
| | 583 | + dbgactionlength = dbgrecvbuf[3];
|
| 577 | 584 | break;
|
| 578 | 585 | #ifdef HAVE_HWKEYAES
|
| 579 | 586 | case 25: // HWKEYAES
|
| — | — | @@ -623,6 +630,29 @@ |
| 624 | 631 | memcpy(dbgasyncsendbuf, dbgrecvbuf, sizeof(dbgasyncsendbuf));
|
| 625 | 632 | break;
|
| 626 | 633 | #endif
|
| | 634 | + case 52: // MALLOC
|
| | 635 | + if (set_dbgaction(DBGACTION_MALLOC, 0)) break;
|
| | 636 | + dbgactionlength = dbgrecvbuf[1];
|
| | 637 | + break;
|
| | 638 | + case 53: // MEMALIGN
|
| | 639 | + if (set_dbgaction(DBGACTION_MEMALIGN, 0)) break;
|
| | 640 | + dbgactionoffset = dbgrecvbuf[1];
|
| | 641 | + dbgactionlength = dbgrecvbuf[2];
|
| | 642 | + break;
|
| | 643 | + case 54: // REALLOC
|
| | 644 | + if (set_dbgaction(DBGACTION_REALLOC, 0)) break;
|
| | 645 | + dbgactionaddr = dbgrecvbuf[1];
|
| | 646 | + dbgactionlength = dbgrecvbuf[2];
|
| | 647 | + break;
|
| | 648 | + case 55: // REOWNALLOC
|
| | 649 | + if (set_dbgaction(DBGACTION_REOWNALLOC, 0)) break;
|
| | 650 | + dbgactionaddr = dbgrecvbuf[1];
|
| | 651 | + dbgactionoffset = dbgrecvbuf[2];
|
| | 652 | + break;
|
| | 653 | + case 56: // FREE
|
| | 654 | + if (set_dbgaction(DBGACTION_FREE, 0)) break;
|
| | 655 | + dbgactionaddr = dbgrecvbuf[1];
|
| | 656 | + break;
|
| 627 | 657 | default:
|
| 628 | 658 | dbgsendbuf[0] = 2;
|
| 629 | 659 | size = 16;
|
| — | — | @@ -712,7 +742,8 @@ |
| 713 | 743 | shutdown(false);
|
| 714 | 744 | dbgasyncsendbuf[0] = 1;
|
| 715 | 745 | usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
| 716 | | - execfirmware((void*)dbgactionaddr);
|
| | 746 | + execfirmware((void*)dbgactionaddr, (void*)dbgactionoffset,
|
| | 747 | + (size_t)dbgactionlength);
|
| 717 | 748 | #ifdef HAVE_BOOTFLASH
|
| 718 | 749 | case DBGACTION_READBOOTFLASH:
|
| 719 | 750 | bootflash_readraw((void*)dbgactionaddr, dbgactionoffset, dbgactionlength);
|
| — | — | @@ -912,6 +943,33 @@ |
| 913 | 944 | }
|
| 914 | 945 | break;
|
| 915 | 946 | #endif
|
| | 947 | + case DBGACTION_MALLOC:
|
| | 948 | + dbgasyncsendbuf[0] = 1;
|
| | 949 | + dbgasyncsendbuf[1] = (uint32_t)malloc((size_t)dbgactionlength);
|
| | 950 | + usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
| | 951 | + break;
|
| | 952 | + case DBGACTION_MEMALIGN:
|
| | 953 | + dbgasyncsendbuf[0] = 1;
|
| | 954 | + dbgasyncsendbuf[1] = (uint32_t)memalign((size_t)dbgactionoffset,
|
| | 955 | + (size_t)dbgactionlength);
|
| | 956 | + usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
| | 957 | + break;
|
| | 958 | + case DBGACTION_REALLOC:
|
| | 959 | + dbgasyncsendbuf[0] = 1;
|
| | 960 | + dbgasyncsendbuf[1] = (uint32_t)realloc((void*)dbgactionaddr,
|
| | 961 | + (size_t)dbgactionlength);
|
| | 962 | + usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
| | 963 | + break;
|
| | 964 | + case DBGACTION_REOWNALLOC:
|
| | 965 | + dbgasyncsendbuf[0] = 1;
|
| | 966 | + reownalloc((void*)dbgactionaddr, (void*)dbgactionoffset);
|
| | 967 | + usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
| | 968 | + break;
|
| | 969 | + case DBGACTION_FREE:
|
| | 970 | + dbgasyncsendbuf[0] = 1;
|
| | 971 | + free((void*)dbgactionaddr);
|
| | 972 | + usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
| | 973 | + break;
|
| 916 | 974 | }
|
| 917 | 975 | dbgaction = DBGACTION_IDLE;
|
| 918 | 976 | }
|
| Index: emcore/trunk/contextswitch.h |
| — | — | @@ -33,7 +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 | +void execfirmware(void* dest, void* src, size_t size) ICODE_ATTR;
|
| 38 | 38 |
|
| 39 | 39 |
|
| 40 | 40 | #endif
|