diff options
Diffstat (limited to 'utils/hwstub/stub')
-rw-r--r-- | utils/hwstub/stub/asm/mips/system.S | 25 | ||||
-rw-r--r-- | utils/hwstub/stub/jz4760b/target-config.h | 6 | ||||
-rw-r--r-- | utils/hwstub/stub/main.c | 11 | ||||
-rw-r--r-- | utils/hwstub/stub/target.h | 4 |
4 files changed, 45 insertions, 1 deletions
diff --git a/utils/hwstub/stub/asm/mips/system.S b/utils/hwstub/stub/asm/mips/system.S index ab134aed48..97b0207ec9 100644 --- a/utils/hwstub/stub/asm/mips/system.S +++ b/utils/hwstub/stub/asm/mips/system.S | |||
@@ -18,6 +18,7 @@ | |||
18 | * | 18 | * |
19 | ****************************************************************************/ | 19 | ****************************************************************************/ |
20 | #include "mips.h" | 20 | #include "mips.h" |
21 | #include "target-config.h" | ||
21 | 22 | ||
22 | /* Handling of data abort: | 23 | /* Handling of data abort: |
23 | * the code can register a "longjmp" buffer to restore the context in case of | 24 | * the code can register a "longjmp" buffer to restore the context in case of |
@@ -49,3 +50,27 @@ set_data_abort_jmp: | |||
49 | jr ra | 50 | jr ra |
50 | move v0, zero | 51 | move v0, zero |
51 | .set reorder | 52 | .set reorder |
53 | |||
54 | #ifdef CONFIG_FLUSH_CACHES | ||
55 | .set noreorder | ||
56 | .text | ||
57 | .global target_flush_caches | ||
58 | target_flush_caches: | ||
59 | /* commit dcache and invalidate icache */ | ||
60 | la t0, 0x80000000 /* an idx op should use an unmappable address */ | ||
61 | ori t1, t0, DCACHE_SIZE /* cache size */ | ||
62 | reloc_dcache_loop: | ||
63 | cache DCIndexWBInv, 0(t0) /* invalidate and write-back dcache index */ | ||
64 | addiu t0, t0, DCACHE_LINE_SIZE /* bytes per cache line */ | ||
65 | bne t0, t1, reloc_dcache_loop | ||
66 | nop | ||
67 | la t0, 0x80000000 /* an idx op should use an unmappable address */ | ||
68 | ori t1, t0, ICACHE_SIZE /* cache size */ | ||
69 | reloc_icache_loop: | ||
70 | cache ICIndexInv, 0(t0) /* invalidate icache index */ | ||
71 | addiu t0, t0, ICACHE_LINE_SIZE /* bytes per cache line */ | ||
72 | bne t0, t1, reloc_icache_loop | ||
73 | nop | ||
74 | jr ra | ||
75 | nop | ||
76 | #endif | ||
diff --git a/utils/hwstub/stub/jz4760b/target-config.h b/utils/hwstub/stub/jz4760b/target-config.h index fa018c14dc..681e17e6f6 100644 --- a/utils/hwstub/stub/jz4760b/target-config.h +++ b/utils/hwstub/stub/jz4760b/target-config.h | |||
@@ -3,6 +3,12 @@ | |||
3 | #define TCSM0_SIZE 0x4000 | 3 | #define TCSM0_SIZE 0x4000 |
4 | #define CPU_MIPS | 4 | #define CPU_MIPS |
5 | #define STACK_SIZE 0x300 | 5 | #define STACK_SIZE 0x300 |
6 | #define DCACHE_SIZE 0x4000 /* 16 kB */ | ||
7 | #define DCACHE_LINE_SIZE 0x20 /* 32 B */ | ||
8 | #define ICACHE_SIZE 0x4000 /* 16 kB */ | ||
9 | #define ICACHE_LINE_SIZE 0x20 /* 32 B */ | ||
10 | /* we need to flush caches before executing */ | ||
11 | #define CONFIG_FLUSH_CACHES | ||
6 | 12 | ||
7 | /* something provides define | 13 | /* something provides define |
8 | * #define mips 1 | 14 | * #define mips 1 |
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 |
diff --git a/utils/hwstub/stub/target.h b/utils/hwstub/stub/target.h index 5cd049d04f..4992dd5bf8 100644 --- a/utils/hwstub/stub/target.h +++ b/utils/hwstub/stub/target.h | |||
@@ -41,6 +41,10 @@ uint32_t target_read32(const void *addr); | |||
41 | void target_write8(void *addr, uint8_t val); | 41 | void target_write8(void *addr, uint8_t val); |
42 | void target_write16(void *addr, uint16_t val); | 42 | void target_write16(void *addr, uint16_t val); |
43 | void target_write32(void *addr, uint32_t val); | 43 | void target_write32(void *addr, uint32_t val); |
44 | #ifdef CONFIG_FLUSH_CACHES | ||
45 | /* flush cache: commit dcache and invalidate icache */ | ||
46 | void target_flush_caches(void); | ||
47 | #endif | ||
44 | 48 | ||
45 | /* mandatory for all targets */ | 49 | /* mandatory for all targets */ |
46 | extern struct hwstub_target_desc_t target_descriptor; | 50 | extern struct hwstub_target_desc_t target_descriptor; |