diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-08-02 15:18:41 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2017-01-24 15:25:14 +0100 |
commit | 56340f4cd0a6ab318a52d2a62ded36aad2946e1d (patch) | |
tree | 32cb9a8380131b93249abd4ab68d2ebaf7dcc541 /utils/hwstub/stub/main.c | |
parent | 83155f32bfa3e8f3641b81098744431f6fc59e56 (diff) | |
download | rockbox-56340f4cd0a6ab318a52d2a62ded36aad2946e1d.tar.gz rockbox-56340f4cd0a6ab318a52d2a62ded36aad2946e1d.zip |
hwstub: add the possibility to flush caches before exec
This is needed on the jz4760b because if some data is loaded to DRAM, then it
is cached and a disaster lurks if dcaches/icache are not flushed. Targets that
needs this must define CONFIG_FLUSH_CACHES in target-config.h and implement
target_flush_caches(). Currently MIPS has some generic code for mips32r1 that
requires to define {D,I}CACHE_SIZE and {D,I}CACHE_LINE_SIZE in target-config.h
Change-Id: I5a3fc085de9445d8c8a2eb61ae4e2dc9bb6b4e8e
Diffstat (limited to 'utils/hwstub/stub/main.c')
-rw-r--r-- | utils/hwstub/stub/main.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/utils/hwstub/stub/main.c b/utils/hwstub/stub/main.c index ee93ad4b63..c35872f320 100644 --- a/utils/hwstub/stub/main.c +++ b/utils/hwstub/stub/main.c | |||
@@ -518,10 +518,17 @@ static void handle_exec(struct usb_ctrlrequest *req) | |||
518 | if(size != sizeof(struct hwstub_exec_req_t)) | 518 | if(size != sizeof(struct hwstub_exec_req_t)) |
519 | return usb_drv_stall(EP_CONTROL, true, true); | 519 | return usb_drv_stall(EP_CONTROL, true, true); |
520 | uint32_t addr = exec->dAddress; | 520 | uint32_t addr = exec->dAddress; |
521 | |||
522 | #if defined(CPU_ARM) | ||
521 | if(exec->bmFlags & HWSTUB_EXEC_THUMB) | 523 | if(exec->bmFlags & HWSTUB_EXEC_THUMB) |
522 | addr |= 1; | 524 | addr |= 1; |
523 | else | 525 | else |
524 | addr &= ~1; | 526 | addr &= ~1; |
527 | #endif | ||
528 | |||
529 | #ifdef CONFIG_FLUSH_CACHES | ||
530 | target_flush_caches(); | ||
531 | #endif | ||
525 | 532 | ||
526 | if(exec->bmFlags & HWSTUB_EXEC_CALL) | 533 | if(exec->bmFlags & HWSTUB_EXEC_CALL) |
527 | { | 534 | { |
@@ -540,11 +547,13 @@ static void handle_exec(struct usb_ctrlrequest *req) | |||
540 | else | 547 | else |
541 | { | 548 | { |
542 | /* in case of jump, respond immediately and disconnect usb */ | 549 | /* in case of jump, respond immediately and disconnect usb */ |
550 | #if defined(CPU_ARM) | ||
543 | usb_drv_send(EP_CONTROL, NULL, 0); | 551 | usb_drv_send(EP_CONTROL, NULL, 0); |
544 | usb_drv_exit(); | 552 | usb_drv_exit(); |
545 | #if defined(CPU_ARM) | ||
546 | asm volatile("bx %0\n" : : "r" (addr) : "memory"); | 553 | asm volatile("bx %0\n" : : "r" (addr) : "memory"); |
547 | #elif defined(CPU_MIPS) | 554 | #elif defined(CPU_MIPS) |
555 | usb_drv_send(EP_CONTROL, NULL, 0); | ||
556 | usb_drv_exit(); | ||
548 | asm volatile("jr %0\nnop\n" : : "r" (addr) : "memory"); | 557 | asm volatile("jr %0\nnop\n" : : "r" (addr) : "memory"); |
549 | #else | 558 | #else |
550 | #warning jump is unsupported on this platform | 559 | #warning jump is unsupported on this platform |