diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/rtc/rtc_jz4740.c | 2 | ||||
-rw-r--r-- | firmware/export/thread.h | 8 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/crt0.S | 84 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | 2 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c | 44 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c | 15 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/system-jz4740.c | 72 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/usb-jz4740.c | 33 | ||||
-rw-r--r-- | firmware/thread.c | 180 |
9 files changed, 212 insertions, 228 deletions
diff --git a/firmware/drivers/rtc/rtc_jz4740.c b/firmware/drivers/rtc/rtc_jz4740.c index dadc93a8e0..a1a864d27a 100644 --- a/firmware/drivers/rtc/rtc_jz4740.c +++ b/firmware/drivers/rtc/rtc_jz4740.c | |||
@@ -52,6 +52,7 @@ static const unsigned int sum_monthday[13] = { | |||
52 | 365 | 52 | 365 |
53 | }; | 53 | }; |
54 | 54 | ||
55 | #if 0 | ||
55 | static unsigned int jz_mktime(int year, int mon, int day, int hour, int min, int sec) | 56 | static unsigned int jz_mktime(int year, int mon, int day, int hour, int min, int sec) |
56 | { | 57 | { |
57 | unsigned int seccounter; | 58 | unsigned int seccounter; |
@@ -78,6 +79,7 @@ static unsigned int jz_mktime(int year, int mon, int day, int hour, int min, int | |||
78 | 79 | ||
79 | return seccounter; | 80 | return seccounter; |
80 | } | 81 | } |
82 | #endif | ||
81 | 83 | ||
82 | static void jz_gettime(unsigned int rtc, int *year, int *mon, int *day, int *hour, | 84 | static void jz_gettime(unsigned int rtc, int *year, int *mon, int *day, int *hour, |
83 | int *min, int *sec, int *weekday) | 85 | int *min, int *sec, int *weekday) |
diff --git a/firmware/export/thread.h b/firmware/export/thread.h index ecba179693..c4dfbf4ed3 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h | |||
@@ -112,10 +112,10 @@ struct regs | |||
112 | #elif defined(CPU_MIPS) | 112 | #elif defined(CPU_MIPS) |
113 | struct regs | 113 | struct regs |
114 | { | 114 | { |
115 | uint32_t r[27]; /* 0-104 - Registers $1, v0-v1, a0-a3, t0-t9, s0-s7, gp, fp */ | 115 | uint32_t r[10]; /* 0-36 - Registers s0-s7, gp, fp */ |
116 | uint32_t sp; /* 108 - Stack pointer */ | 116 | uint32_t sp; /* 40 - Stack pointer */ |
117 | uint32_t ra; /* 112 - Return address */ | 117 | uint32_t ra; /* 44 - Return address */ |
118 | uint32_t start; /* 116 - Thread start address, or NULL when started */ | 118 | uint32_t start; /* 48 - Thread start address, or NULL when started */ |
119 | }; | 119 | }; |
120 | #endif /* CONFIG_CPU */ | 120 | #endif /* CONFIG_CPU */ |
121 | #else | 121 | #else |
diff --git a/firmware/target/mips/ingenic_jz47xx/crt0.S b/firmware/target/mips/ingenic_jz47xx/crt0.S index 97e01d8566..5cfd49141a 100644 --- a/firmware/target/mips/ingenic_jz47xx/crt0.S +++ b/firmware/target/mips/ingenic_jz47xx/crt0.S | |||
@@ -66,17 +66,16 @@ _start: | |||
66 | 66 | ||
67 | li t0, (M_StatusBEV | M_StatusIM7 | M_StatusIM6 \ | 67 | li t0, (M_StatusBEV | M_StatusIM7 | M_StatusIM6 \ |
68 | | M_StatusIM5 | M_StatusIM4 | M_StatusIM3 \ | 68 | | M_StatusIM5 | M_StatusIM4 | M_StatusIM3 \ |
69 | | M_StatusIM2 | M_StatusERL | M_StatusSM) | 69 | | M_StatusIM2 | M_StatusERL) |
70 | /* | 70 | /* |
71 | BEV = Enable Boot Exception Vectors | 71 | BEV = Enable Boot Exception Vectors |
72 | IMx = Interrupt mask | 72 | IMx = Interrupt mask |
73 | ERL = Denotes error level | 73 | ERL = Denotes error level |
74 | SM = Supervisor Mode | ||
75 | */ | 74 | */ |
76 | mtc0 t0, C0_STATUS | 75 | mtc0 t0, C0_STATUS |
77 | 76 | ||
78 | li t1, M_CauseIV | 77 | li t0, M_CauseIV |
79 | mtc0 t1, C0_CAUSE | 78 | mtc0 t0, C0_CAUSE |
80 | 79 | ||
81 | /* | 80 | /* |
82 | ---------------------------------------------------- | 81 | ---------------------------------------------------- |
@@ -85,7 +84,7 @@ _start: | |||
85 | */ | 84 | */ |
86 | li t0, 3 // enable cache for kseg0 accesses | 85 | li t0, 3 // enable cache for kseg0 accesses |
87 | mtc0 t0, C0_CONFIG // CONFIG reg | 86 | mtc0 t0, C0_CONFIG // CONFIG reg |
88 | la t0, 0x80000000 // an idx op should use a unmappable address | 87 | la t0, 0x80000000 // an idx op should use an unmappable address |
89 | ori t1, t0, 0x4000 // 16kB cache | 88 | ori t1, t0, 0x4000 // 16kB cache |
90 | mtc0 zero, C0_TAGLO // TAGLO reg | 89 | mtc0 zero, C0_TAGLO // TAGLO reg |
91 | mtc0 zero, C0_TAGHI // TAGHI reg | 90 | mtc0 zero, C0_TAGHI // TAGHI reg |
@@ -215,25 +214,26 @@ real_exception_handler: | |||
215 | sw v1, 0x64(sp) | 214 | sw v1, 0x64(sp) |
216 | sw v0, 0x68(sp) | 215 | sw v0, 0x68(sp) |
217 | sw $1, 0x6C(sp) | 216 | sw $1, 0x6C(sp) |
218 | mflo t0 # Move From LO | 217 | mflo k0 # Move From LO |
219 | nop | 218 | nop |
220 | sw t0, 0x70(sp) | 219 | sw k0, 0x70(sp) |
221 | mfhi t0 # Move From HI | 220 | mfhi k0 # Move From HI |
222 | nop | 221 | nop |
223 | sw t0, 0x74(sp) | 222 | sw k0, 0x74(sp) |
224 | mfc0 t0, C0_STATUS # Status register | 223 | mfc0 k0, C0_STATUS # Status register |
225 | sll zero, 1 | 224 | sll zero, 1 |
226 | sll zero, 1 | 225 | sll zero, 1 |
227 | sll zero, 1 | 226 | sll zero, 1 |
228 | sll zero, 1 | 227 | sll zero, 1 |
229 | sw t0, 0x78(sp) | 228 | sw k0, 0x78(sp) |
230 | mfc0 t0, C0_EPC # Exception Program Counter | 229 | mfc0 k0, C0_EPC # Exception Program Counter |
231 | sll zero, 1 | 230 | sll zero, 1 |
232 | sll zero, 1 | 231 | sll zero, 1 |
233 | sll zero, 1 | 232 | sll zero, 1 |
234 | sll zero, 1 | 233 | sll zero, 1 |
235 | sw t0, 0x7C(sp) | 234 | sw k0, 0x7C(sp) |
236 | li k1, 0x7C | 235 | |
236 | li k1, M_CauseExcCode | ||
237 | mfc0 k0, C0_CAUSE # C0_CAUSE of last exception | 237 | mfc0 k0, C0_CAUSE # C0_CAUSE of last exception |
238 | and k0, k1 | 238 | and k0, k1 |
239 | beq zero, k0, _int | 239 | beq zero, k0, _int |
@@ -273,7 +273,7 @@ _int: | |||
273 | lw a0, 0x60(sp) | 273 | lw a0, 0x60(sp) |
274 | lw v1, 0x64(sp) | 274 | lw v1, 0x64(sp) |
275 | lw v0, 0x68(sp) | 275 | lw v0, 0x68(sp) |
276 | lw v1, 0x6C(sp) | 276 | lw $1, 0x6C(sp) |
277 | lw k0, 0x70(sp) | 277 | lw k0, 0x70(sp) |
278 | mtlo k0 # Move To LO | 278 | mtlo k0 # Move To LO |
279 | nop | 279 | nop |
@@ -313,7 +313,57 @@ _exception: | |||
313 | sll zero, 1 | 313 | sll zero, 1 |
314 | sll zero, 1 | 314 | sll zero, 1 |
315 | sll zero, 1 | 315 | sll zero, 1 |
316 | la k0, exception_handler | 316 | jal exception_handler |
317 | jr k0 | 317 | nop |
318 | lw ra, 0(sp) | ||
319 | lw fp, 4(sp) | ||
320 | sw gp, 8(sp) | ||
321 | lw t9, 0xC(sp) | ||
322 | lw t8, 0x10(sp) | ||
323 | lw s7, 0x14(sp) | ||
324 | lw s6, 0x18(sp) | ||
325 | lw s5, 0x1C(sp) | ||
326 | lw s4, 0x20(sp) | ||
327 | lw s3, 0x24(sp) | ||
328 | lw s2, 0x28(sp) | ||
329 | lw s1, 0x2C(sp) | ||
330 | lw s0, 0x30(sp) | ||
331 | lw t7, 0x34(sp) | ||
332 | lw t6, 0x38(sp) | ||
333 | lw t5, 0x3C(sp) | ||
334 | lw t4, 0x40(sp) | ||
335 | lw t3, 0x44(sp) | ||
336 | lw t2, 0x48(sp) | ||
337 | lw t1, 0x4C(sp) | ||
338 | lw t0, 0x50(sp) | ||
339 | lw a3, 0x54(sp) | ||
340 | lw a2, 0x58(sp) | ||
341 | lw a1, 0x5C(sp) | ||
342 | lw a0, 0x60(sp) | ||
343 | lw v1, 0x64(sp) | ||
344 | lw v0, 0x68(sp) | ||
345 | lw $1, 0x6C(sp) | ||
346 | lw k0, 0x70(sp) | ||
347 | mtlo k0 # Move To LO | ||
348 | nop | ||
349 | lw k0, 0x74(sp) | ||
350 | mthi k0 # Move To HI | ||
351 | nop | ||
352 | lw k0, 0x78(sp) | ||
353 | nop | ||
354 | mtc0 k0, C0_STATUS # Status register | ||
355 | sll zero, 1 | ||
356 | sll zero, 1 | ||
357 | sll zero, 1 | ||
358 | sll zero, 1 | ||
359 | lw k0, 0x7C(sp) | ||
360 | nop | ||
361 | mtc0 k0, C0_EPC # Exception Program Counter | ||
362 | sll zero, 1 | ||
363 | sll zero, 1 | ||
364 | sll zero, 1 | ||
365 | sll zero, 1 | ||
366 | addiu sp, 0x80 | ||
367 | eret # Exception Return | ||
318 | nop | 368 | nop |
319 | .set reorder | 369 | .set reorder |
diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c index 6bb7db8d9b..90ecfc6a3a 100644 --- a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | |||
@@ -68,7 +68,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
68 | | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT); /* | (2 << 12) | (3 << 8) */ | 68 | | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT); /* | (2 << 12) | (3 << 8) */ |
69 | REG_DMAC_DCCSR(0) = (DMAC_DCCSR_NDES | DMAC_DCCSR_EN); /* (1 << 31) | (1 << 0) */ | 69 | REG_DMAC_DCCSR(0) = (DMAC_DCCSR_NDES | DMAC_DCCSR_EN); /* (1 << 31) | (1 << 0) */ |
70 | 70 | ||
71 | dma_cache_wback_inv((unsigned long)&lcd_framebuffer[y][x], width*height); | 71 | __dcache_writeback_all(); /* Size of framebuffer is way bigger than cache size */ |
72 | 72 | ||
73 | REG_DMAC_DMACR = DMAC_DMACR_DMAE; | 73 | REG_DMAC_DMACR = DMAC_DMACR_DMAE; |
74 | 74 | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c index 98fa8e7a20..3846987026 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c | |||
@@ -24,14 +24,14 @@ | |||
24 | #include "r61509.h" | 24 | #include "r61509.h" |
25 | #include "lcd-target.h" | 25 | #include "lcd-target.h" |
26 | 26 | ||
27 | #define PIN_CS_N (32*1+17) /* Chip select */ | 27 | #define PIN_CS_N (32*1+17) /* Chip select */ |
28 | #define PIN_RESET_N (32*1+18) /* Reset */ | 28 | #define PIN_RESET_N (32*1+18) /* Reset */ |
29 | 29 | ||
30 | #define my__gpio_as_lcd_16bit() \ | 30 | #define my__gpio_as_lcd_16bit() \ |
31 | do { \ | 31 | do { \ |
32 | REG_GPIO_PXFUNS(2) = 0x001cffff; \ | 32 | REG_GPIO_PXFUNS(2) = 0x001cffff; \ |
33 | REG_GPIO_PXSELC(2) = 0x001cffff; \ | 33 | REG_GPIO_PXSELC(2) = 0x001cffff; \ |
34 | REG_GPIO_PXPES(2) = 0x001cffff; \ | 34 | REG_GPIO_PXPES(2) = 0x001cffff; \ |
35 | } while (0) | 35 | } while (0) |
36 | 36 | ||
37 | 37 | ||
@@ -45,12 +45,12 @@ static void _display_pin_init(void) | |||
45 | __gpio_as_output(PIN_RESET_N); | 45 | __gpio_as_output(PIN_RESET_N); |
46 | __gpio_clear_pin(PIN_CS_N); | 46 | __gpio_clear_pin(PIN_CS_N); |
47 | 47 | ||
48 | __gpio_set_pin(PIN_RESET_N); | 48 | __gpio_set_pin(PIN_RESET_N); |
49 | DELAY; | 49 | DELAY; |
50 | __gpio_clear_pin(PIN_RESET_N); | 50 | __gpio_clear_pin(PIN_RESET_N); |
51 | DELAY; | 51 | DELAY; |
52 | __gpio_set_pin(PIN_RESET_N); | 52 | __gpio_set_pin(PIN_RESET_N); |
53 | DELAY; | 53 | DELAY; |
54 | } | 54 | } |
55 | 55 | ||
56 | #define WAIT_ON_SLCD while(REG_SLCD_STATE & SLCD_STATE_BUSY); | 56 | #define WAIT_ON_SLCD while(REG_SLCD_STATE & SLCD_STATE_BUSY); |
@@ -189,7 +189,7 @@ static void _display_off(void) | |||
189 | static void _set_lcd_bus(void) | 189 | static void _set_lcd_bus(void) |
190 | { | 190 | { |
191 | REG_LCD_CFG &= ~LCD_CFG_LCDPIN_MASK; | 191 | REG_LCD_CFG &= ~LCD_CFG_LCDPIN_MASK; |
192 | REG_LCD_CFG |= LCD_CFG_LCDPIN_SLCD; | 192 | REG_LCD_CFG |= LCD_CFG_LCDPIN_SLCD; |
193 | 193 | ||
194 | REG_SLCD_CFG = (SLCD_CFG_BURST_8_WORD | SLCD_CFG_DWIDTH_16 | SLCD_CFG_CWIDTH_16BIT | 194 | REG_SLCD_CFG = (SLCD_CFG_BURST_8_WORD | SLCD_CFG_DWIDTH_16 | SLCD_CFG_CWIDTH_16BIT |
195 | | SLCD_CFG_CS_ACTIVE_LOW | SLCD_CFG_RS_CMD_LOW | SLCD_CFG_CLK_ACTIVE_FALLING | 195 | | SLCD_CFG_CS_ACTIVE_LOW | SLCD_CFG_RS_CMD_LOW | SLCD_CFG_CLK_ACTIVE_FALLING |
@@ -200,17 +200,17 @@ static void _set_lcd_bus(void) | |||
200 | 200 | ||
201 | static void _set_lcd_clock(void) | 201 | static void _set_lcd_clock(void) |
202 | { | 202 | { |
203 | unsigned int val; | 203 | unsigned int val; |
204 | int pll_div; | 204 | int pll_div; |
205 | 205 | ||
206 | __cpm_stop_lcd(); | 206 | __cpm_stop_lcd(); |
207 | pll_div = ( REG_CPM_CPCCR & CPM_CPCCR_PCS ); /* clock source, 0:pllout/2 1: pllout */ | 207 | pll_div = ( REG_CPM_CPCCR & CPM_CPCCR_PCS ); /* clock source, 0:pllout/2 1: pllout */ |
208 | pll_div = pll_div ? 1 : 2 ; | 208 | pll_div = pll_div ? 1 : 2 ; |
209 | val = ( __cpm_get_pllout()/pll_div ) / 336000000; | 209 | val = ( __cpm_get_pllout()/pll_div ) / 336000000; |
210 | val--; | 210 | val--; |
211 | if ( val > 0x1ff ) | 211 | if ( val > 0x1ff ) |
212 | val = 0x1ff; /* CPM_LPCDR is too large, set it to 0x1ff */ | 212 | val = 0x1ff; /* CPM_LPCDR is too large, set it to 0x1ff */ |
213 | __cpm_set_pixdiv(val); | 213 | __cpm_set_pixdiv(val); |
214 | __cpm_start_lcd(); | 214 | __cpm_start_lcd(); |
215 | } | 215 | } |
216 | 216 | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c index 0f11782d3f..dd169c3a44 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c | |||
@@ -122,13 +122,16 @@ int button_read_device(int *data) | |||
122 | ret |= BUTTON_POWER; | 122 | ret |= BUTTON_POWER; |
123 | } | 123 | } |
124 | 124 | ||
125 | if(pendown_flag) | 125 | if(data != NULL) |
126 | { | 126 | { |
127 | *data = touch_to_pixels(stable_x_pos, stable_y_pos); | 127 | if(pendown_flag) |
128 | ret |= BUTTON_TOUCH; | 128 | { |
129 | *data = touch_to_pixels(stable_x_pos, stable_y_pos); | ||
130 | ret |= BUTTON_TOUCH; | ||
131 | } | ||
132 | else | ||
133 | *data = 0; | ||
129 | } | 134 | } |
130 | else | ||
131 | *data = 0; | ||
132 | 135 | ||
133 | return ret; | 136 | return ret; |
134 | } | 137 | } |
@@ -199,7 +202,7 @@ void SADC(void) | |||
199 | 202 | ||
200 | xData = (dat >> 0) & 0xfff; | 203 | xData = (dat >> 0) & 0xfff; |
201 | yData = (dat >> 16) & 0xfff; | 204 | yData = (dat >> 16) & 0xfff; |
202 | 205 | ||
203 | dat = REG_SADC_TSDAT; | 206 | dat = REG_SADC_TSDAT; |
204 | tsz1Data = (dat >> 0) & 0xfff; | 207 | tsz1Data = (dat >> 0) & 0xfff; |
205 | tsz2Data = (dat >> 16) & 0xfff; | 208 | tsz2Data = (dat >> 16) & 0xfff; |
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c index 61be6c60de..1a41723ffc 100644 --- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c | |||
@@ -324,7 +324,7 @@ static int get_irq_number(void) | |||
324 | 324 | ||
325 | void intr_handler(void) | 325 | void intr_handler(void) |
326 | { | 326 | { |
327 | irq = get_irq_number(); | 327 | int irq = get_irq_number(); |
328 | if(irq < 0) | 328 | if(irq < 0) |
329 | return; | 329 | return; |
330 | 330 | ||
@@ -361,7 +361,7 @@ static char* parse_exception(unsigned int cause) | |||
361 | } | 361 | } |
362 | 362 | ||
363 | void exception_handler(void* stack_ptr, unsigned int cause, unsigned int epc) | 363 | void exception_handler(void* stack_ptr, unsigned int cause, unsigned int epc) |
364 | { | 364 | { |
365 | panicf("Exception occurred: %s [0x%08x] at 0x%08x (stack at 0x%08x)", parse_exception(cause), cause, epc, (unsigned int)stack_ptr); | 365 | panicf("Exception occurred: %s [0x%08x] at 0x%08x (stack at 0x%08x)", parse_exception(cause), cause, epc, (unsigned int)stack_ptr); |
366 | } | 366 | } |
367 | 367 | ||
@@ -457,23 +457,6 @@ void __icache_invalidate_all(void) | |||
457 | { | 457 | { |
458 | unsigned int i; | 458 | unsigned int i; |
459 | 459 | ||
460 | /* | ||
461 | do | ||
462 | { | ||
463 | unsigned long __k0_addr; | ||
464 | |||
465 | __asm__ __volatile__( | ||
466 | "la %0, 1f \n" | ||
467 | "or %0, %0, %1 \n" | ||
468 | "jr %0 \n" | ||
469 | "nop \n" | ||
470 | "1: nop \n" | ||
471 | : "=&r"(__k0_addr) | ||
472 | : "r" (0x20000000) | ||
473 | ); | ||
474 | } while(0); | ||
475 | */ | ||
476 | |||
477 | asm volatile (".set noreorder \n" | 460 | asm volatile (".set noreorder \n" |
478 | ".set mips32 \n" | 461 | ".set mips32 \n" |
479 | "mtc0 $0, $28 \n" /* TagLo */ | 462 | "mtc0 $0, $28 \n" /* TagLo */ |
@@ -484,34 +467,16 @@ void __icache_invalidate_all(void) | |||
484 | for(i=KSEG0; i<KSEG0+CACHE_SIZE; i+=CACHE_LINE_SIZE) | 467 | for(i=KSEG0; i<KSEG0+CACHE_SIZE; i+=CACHE_LINE_SIZE) |
485 | __CACHE_OP(Index_Store_Tag_I, i); | 468 | __CACHE_OP(Index_Store_Tag_I, i); |
486 | 469 | ||
487 | /* | 470 | /* invalidate btb */ |
488 | do | 471 | asm volatile ( |
489 | { | 472 | ".set mips32 \n" |
490 | unsigned long __k0_addr; | 473 | "mfc0 %0, $16, 7 \n" |
491 | __asm__ __volatile__( | 474 | "nop \n" |
492 | "nop;nop;nop;nop;nop;nop;nop \n" | 475 | "ori %0, 2 \n" |
493 | "la %0, 1f \n" | 476 | "mtc0 %0, $16, 7 \n" |
494 | "jr %0 \n" | 477 | ".set mips0 \n" |
495 | "nop \n" | 478 | : |
496 | "1: nop \n" | 479 | : "r" (i)); |
497 | : "=&r" (__k0_addr) | ||
498 | ); | ||
499 | } while(0); | ||
500 | */ | ||
501 | |||
502 | do | ||
503 | { | ||
504 | unsigned long tmp; | ||
505 | __asm__ __volatile__( | ||
506 | ".set mips32 \n" | ||
507 | "mfc0 %0, $16, 7 \n" /* Config */ | ||
508 | "nop \n" | ||
509 | "ori %0, 2 \n" | ||
510 | "mtc0 %0, $16, 7 \n" /* Config */ | ||
511 | "nop \n" | ||
512 | ".set mips0 \n" | ||
513 | : "=&r" (tmp)); | ||
514 | } while(0); | ||
515 | } | 480 | } |
516 | 481 | ||
517 | void __dcache_invalidate_all(void) | 482 | void __dcache_invalidate_all(void) |
@@ -657,13 +622,14 @@ static void tlb_init(void) | |||
657 | 622 | ||
658 | void tlb_refill_handler(void) | 623 | void tlb_refill_handler(void) |
659 | { | 624 | { |
660 | panicf("TLB refill handler! [0x%x] [0x%lx]", read_c0_badvaddr(), read_c0_epc()); | 625 | panicf("TLB refill handler at 0x%08lx! [0x%x]", read_c0_epc(), read_c0_badvaddr()); |
661 | } | 626 | } |
662 | 627 | ||
663 | static void tlb_call_refill(void) | 628 | static void tlb_call_refill(void) |
664 | { | 629 | { |
665 | asm("la $8, tlb_refill_handler \n" | 630 | asm("la $8, tlb_refill_handler \n" |
666 | "jr $8 \n"); | 631 | "jr $8 \n" |
632 | ); | ||
667 | } | 633 | } |
668 | 634 | ||
669 | extern int main(void); | 635 | extern int main(void); |
@@ -687,18 +653,18 @@ void system_main(void) | |||
687 | __dcache_writeback_all(); | 653 | __dcache_writeback_all(); |
688 | __icache_invalidate_all(); | 654 | __icache_invalidate_all(); |
689 | 655 | ||
690 | write_c0_status(1 << 28 | 1 << 10 | 1 << 3); /* Enable CP | Mask interrupt 2 | Supervisor mode */ | 656 | write_c0_status(1 << 28 | 1 << 10 ); /* Enable CP | Mask interrupt 2 */ |
691 | 657 | ||
692 | /* Disable all interrupts */ | 658 | /* Disable all interrupts */ |
693 | for(i=0; i<IRQ_MAX; i++) | 659 | for(i=0; i<IRQ_MAX; i++) |
694 | dis_irq(i); | 660 | dis_irq(i); |
695 | 661 | ||
696 | //tlb_init(); | 662 | tlb_init(); |
697 | |||
698 | sti(); | ||
699 | 663 | ||
700 | detect_clock(); | 664 | detect_clock(); |
701 | 665 | ||
666 | sti(); | ||
667 | |||
702 | main(); | 668 | main(); |
703 | 669 | ||
704 | while(1); | 670 | while(1); |
diff --git a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c index 92a2f3b801..cf107397e3 100644 --- a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c | |||
@@ -824,25 +824,21 @@ void usbHandleStandDevReq(u8 *buf) | |||
824 | 824 | ||
825 | extern char printfbuf[256]; | 825 | extern char printfbuf[256]; |
826 | 826 | ||
827 | int GET_CUP_INFO_Handle() | ||
828 | { | ||
829 | HW_SendPKT(0, printfbuf, 64); | ||
830 | udc_state = IDLE; | ||
831 | return 0; | ||
832 | } | ||
833 | |||
834 | void usbHandleVendorReq(u8 *buf) | 827 | void usbHandleVendorReq(u8 *buf) |
835 | { | 828 | { |
836 | int ret_state; | 829 | int ret_state, i; |
837 | USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf; | 830 | USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf; |
838 | switch (dreq->bRequest) { | 831 | switch (dreq->bRequest) |
839 | case 0xAB: | 832 | { |
840 | ret_state=GET_CUP_INFO_Handle(); | 833 | case 0xAB: |
841 | break; | 834 | //for(i=0; i<256; i+=64) |
842 | case 0x12: | 835 | HW_SendPKT(0, printfbuf, 64); |
843 | HW_SendPKT(0, "TEST", 4); | 836 | udc_state = IDLE; |
844 | udc_state = IDLE; | 837 | break; |
845 | break; | 838 | case 0x12: |
839 | HW_SendPKT(0, "TEST", 4); | ||
840 | udc_state = IDLE; | ||
841 | break; | ||
846 | } | 842 | } |
847 | } | 843 | } |
848 | 844 | ||
@@ -1032,6 +1028,9 @@ void __udc_start(void) | |||
1032 | system_enable_irq(IRQ_UDC); | 1028 | system_enable_irq(IRQ_UDC); |
1033 | } | 1029 | } |
1034 | 1030 | ||
1035 | void usb_init_device(void){} | 1031 | void usb_init_device(void) |
1032 | { | ||
1033 | __udc_start(); | ||
1034 | } | ||
1036 | 1035 | ||
1037 | #endif | 1036 | #endif |
diff --git a/firmware/thread.c b/firmware/thread.c index f70eb5af7f..58d1b39d74 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -991,34 +991,31 @@ static inline void core_sleep(void) | |||
991 | * Start the thread running and terminate it if it returns | 991 | * Start the thread running and terminate it if it returns |
992 | *--------------------------------------------------------------------------- | 992 | *--------------------------------------------------------------------------- |
993 | */ | 993 | */ |
994 | |||
994 | void start_thread(void); /* Provide C access to ASM label */ | 995 | void start_thread(void); /* Provide C access to ASM label */ |
995 | #if 0 | 996 | static void __attribute__((used)) _start_thread(void) |
996 | static void __attribute__((used)) __start_thread(void) | ||
997 | { | 997 | { |
998 | 998 | ||
999 | /* $v0 = context */ | 999 | /* $t1 = context */ |
1000 | asm volatile ( | 1000 | asm volatile ( |
1001 | ".set noreorder \n" | 1001 | "start_thread: \n" |
1002 | "_start_thread: \n" /* Start here - no naked attribute */ | 1002 | ".set noreorder \n" |
1003 | "lw $8, (4)$2 \n" /* Fetch thread function pointer ($8 = $t0, $2 = $v0) */ | 1003 | ".set noat \n" |
1004 | "lw $29, (108)$2 \n" /* Set initial sp(=$29) */ | 1004 | "lw $8, 4($9) \n" /* Fetch thread function pointer ($8 = $t0, $9 = $t1) */ |
1005 | "jalr $8 \n" /* Start the thread ($8 = $t0,)*/ | 1005 | "lw $29, 40($9) \n" /* Set initial sp(=$29) */ |
1006 | "sw $0, (116)$2 \n" /* Clear start address ($2 = $v0) */ | 1006 | "sw $0, 48($9) \n" /* Clear start address */ |
1007 | ".set reorder \n" | 1007 | "jalr $8 \n" /* Start the thread */ |
1008 | "nop \n" | ||
1009 | ".set at \n" | ||
1010 | ".set reorder \n" | ||
1008 | ); | 1011 | ); |
1009 | thread_exit(); | 1012 | thread_exit(); |
1010 | 1013 | ||
1011 | } | 1014 | } |
1012 | #else | ||
1013 | void start_thread(void) | ||
1014 | { | ||
1015 | return; | ||
1016 | } | ||
1017 | #endif | ||
1018 | 1015 | ||
1019 | /* Place context pointer in $v0 slot, function pointer in $v1 slot, and | 1016 | /* Place context pointer in $s0 slot, function pointer in $s1 slot, and |
1020 | * start_thread pointer in context_start */ | 1017 | * start_thread pointer in context_start */ |
1021 | #define THREAD_STARTUP_INIT(core, thread, function) \ | 1018 | #define THREAD_STARTUP_INIT(core, thread, function) \ |
1022 | ({ (thread)->context.r[0] = (uint32_t)&(thread)->context, \ | 1019 | ({ (thread)->context.r[0] = (uint32_t)&(thread)->context, \ |
1023 | (thread)->context.r[1] = (uint32_t)(function), \ | 1020 | (thread)->context.r[1] = (uint32_t)(function), \ |
1024 | (thread)->context.start = (uint32_t)start_thread; }) | 1021 | (thread)->context.start = (uint32_t)start_thread; }) |
@@ -1029,43 +1026,26 @@ void start_thread(void) | |||
1029 | */ | 1026 | */ |
1030 | static inline void store_context(void* addr) | 1027 | static inline void store_context(void* addr) |
1031 | { | 1028 | { |
1032 | #if 0 | ||
1033 | asm volatile ( | 1029 | asm volatile ( |
1034 | ".set noreorder \n" | 1030 | ".set noreorder \n" |
1035 | ".set noat \n" | 1031 | ".set noat \n" |
1036 | "sw $1, (0)%0 \n" | 1032 | "move $8, %0 \n" |
1037 | "sw $2,(4)%0 \n" /* $v0 */ | 1033 | "sw $16, 0($8) \n" /* $s0 */ |
1038 | "sw $3,(8)%0 \n" /* $v1 */ | 1034 | "sw $17, 4($8) \n" /* $s1 */ |
1039 | "sw $4,(12)%0 \n" /* $a0 */ | 1035 | "sw $18, 8($8) \n" /* $s2 */ |
1040 | "sw $5,(16)%0 \n" /* $a1 */ | 1036 | "sw $19, 12($8) \n" /* $s3 */ |
1041 | "sw $6,(20)%0 \n" /* $a2 */ | 1037 | "sw $20, 16($8) \n" /* $s4 */ |
1042 | "sw $7,(24)%0 \n" /* $a3 */ | 1038 | "sw $21, 20($8) \n" /* $s5 */ |
1043 | "sw $8,(28)%0 \n" /* $t0 */ | 1039 | "sw $22, 24($8) \n" /* $s6 */ |
1044 | "sw $9,(32)%0 \n" /* $t1 */ | 1040 | "sw $23, 28($8) \n" /* $s7 */ |
1045 | "sw $10,(36)%0 \n" /* $t2 */ | 1041 | "sw $28, 32($8) \n" /* gp */ |
1046 | "sw $11,(40)%0 \n" /* $t3 */ | 1042 | "sw $30, 36($8) \n" /* fp */ |
1047 | "sw $12,(44)%0 \n" /* $t4 */ | 1043 | "sw $29, 40($8) \n" /* sp */ |
1048 | "sw $13,(48)%0 \n" /* $t5 */ | 1044 | "sw $31, 44($8) \n" /* ra */ |
1049 | "sw $14,(52)%0 \n" /* $t6 */ | 1045 | ".set at \n" |
1050 | "sw $15,(56)%0 \n" /* $t7 */ | 1046 | ".set reorder \n" |
1051 | "sw $24,(60)%0 \n" /* $t8 */ | 1047 | : : "r" (addr) : "t0" |
1052 | "sw $25,(64)%0 \n" /* $t9 */ | ||
1053 | "sw $16,(68)%0 \n" /* $s0 */ | ||
1054 | "sw $17,(72)%0 \n" /* $s1 */ | ||
1055 | "sw $18,(76)%0 \n" /* $s2 */ | ||
1056 | "sw $19,(80)%0 \n" /* $s3 */ | ||
1057 | "sw $20,(84)%0 \n" /* $s4 */ | ||
1058 | "sw $21,(88)%0 \n" /* $s5 */ | ||
1059 | "sw $22,(92)%0 \n" /* $s6 */ | ||
1060 | "sw $23,(96)%0 \n" /* $s7 */ | ||
1061 | "sw $28,(100)%0 \n" /* gp */ | ||
1062 | "sw $30,(104)%0 \n" /* fp */ | ||
1063 | "sw $29,(108)%0 \n" /* sp */ | ||
1064 | "sw $31,(112)%0 \n" /* ra */ | ||
1065 | ".set reorder \n" | ||
1066 | : : "r" (addr) | ||
1067 | ); | 1048 | ); |
1068 | #endif | ||
1069 | } | 1049 | } |
1070 | 1050 | ||
1071 | /*--------------------------------------------------------------------------- | 1051 | /*--------------------------------------------------------------------------- |
@@ -1074,48 +1054,33 @@ static inline void store_context(void* addr) | |||
1074 | */ | 1054 | */ |
1075 | static inline void load_context(const void* addr) | 1055 | static inline void load_context(const void* addr) |
1076 | { | 1056 | { |
1077 | #if 0 | ||
1078 | asm volatile ( | 1057 | asm volatile ( |
1079 | ".set noat \n" | 1058 | ".set noat \n" |
1080 | ".set noreorder \n" | 1059 | ".set noreorder \n" |
1081 | "lw $8, 116(%0) \n" /* Get start address ($8 = $t0) */ | 1060 | "lw $8, 48(%0) \n" /* Get start address ($8 = $t0) */ |
1082 | //"tst r0, r0 \n" | 1061 | "beqz $8, running \n" /* NULL -> already running */ |
1083 | "j .running \n" /* NULL -> already running */ | 1062 | "nop \n" |
1084 | "jr $8 \n" /* $t0 = $8 = context */ | 1063 | "move $9, %0 \n" /* $t1 = context */ |
1085 | ".running: \n" | 1064 | "jr $8 \n" |
1086 | "lw $1, (0)%0 \n" | 1065 | "nop \n" |
1087 | "lw $2,(4)%0 \n" /* $v0 */ | 1066 | "running: \n" |
1088 | "lw $3,(8)%0 \n" /* $v1 */ | 1067 | "move $8, %0 \n" |
1089 | "lw $4,(12)%0 \n" /* $a0 */ | 1068 | "lw $16, 0($8) \n" /* $s0 */ |
1090 | "lw $5,(16)%0 \n" /* $a1 */ | 1069 | "lw $17, 4($8) \n" /* $s1 */ |
1091 | "lw $6,(20)%0 \n" /* $a2 */ | 1070 | "lw $18, 8($8) \n" /* $s2 */ |
1092 | "lw $7,(24)%0 \n" /* $a3 */ | 1071 | "lw $19, 12($8) \n" /* $s3 */ |
1093 | "lw $8,(28)%0 \n" /* $t0 */ | 1072 | "lw $20, 16($8) \n" /* $s4 */ |
1094 | "lw $9,(32)%0 \n" /* $t1 */ | 1073 | "lw $21, 20($8) \n" /* $s5 */ |
1095 | "lw $10,(36)%0 \n" /* $t2 */ | 1074 | "lw $22, 24($8) \n" /* $s6 */ |
1096 | "lw $11,(40)%0 \n" /* $t3 */ | 1075 | "lw $23, 28($8) \n" /* $s7 */ |
1097 | "lw $12,(44)%0 \n" /* $t4 */ | 1076 | "lw $28, 32($8) \n" /* gp */ |
1098 | "lw $13,(48)%0 \n" /* $t5 */ | 1077 | "lw $30, 36($8) \n" /* fp */ |
1099 | "lw $14,(52)%0 \n" /* $t6 */ | 1078 | "lw $29, 40($8) \n" /* sp */ |
1100 | "lw $15,(56)%0 \n" /* $t7 */ | 1079 | "lw $31, 44($8) \n" /* ra */ |
1101 | "lw $24,(60)%0 \n" /* $t8 */ | 1080 | ".set at \n" |
1102 | "lw $25,(64)%0 \n" /* $t9 */ | 1081 | ".set reorder \n" |
1103 | "lw $16,(68)%0 \n" /* $s0 */ | 1082 | : : "r" (addr) : "t0" /* only! */ |
1104 | "lw $17,(72)%0 \n" /* $s1 */ | ||
1105 | "lw $18,(76)%0 \n" /* $s2 */ | ||
1106 | "lw $19,(80)%0 \n" /* $s3 */ | ||
1107 | "lw $20,(84)%0 \n" /* $s4 */ | ||
1108 | "lw $21,(88)%0 \n" /* $s5 */ | ||
1109 | "lw $22,(92)%0 \n" /* $s6 */ | ||
1110 | "lw $23,(96)%0 \n" /* $s7 */ | ||
1111 | "lw $28,(100)%0 \n" /* gp */ | ||
1112 | "lw $30,(104)%0 \n" /* fp */ | ||
1113 | "lw $29,(108)%0 \n" /* sp */ | ||
1114 | "lw $31,(112)%0 \n" /* ra */ | ||
1115 | ".set reorder \n" | ||
1116 | : : "r" (addr) : "v0" /* only! */ | ||
1117 | ); | 1083 | ); |
1118 | #endif | ||
1119 | } | 1084 | } |
1120 | 1085 | ||
1121 | /*--------------------------------------------------------------------------- | 1086 | /*--------------------------------------------------------------------------- |
@@ -1124,26 +1089,27 @@ static inline void load_context(const void* addr) | |||
1124 | */ | 1089 | */ |
1125 | static inline void core_sleep(void) | 1090 | static inline void core_sleep(void) |
1126 | { | 1091 | { |
1127 | /* | 1092 | #if 0 |
1093 | #if CONFIG_CPU == JZ4732 | ||
1128 | REG_CPM_LCR &= ~CPM_LCR_LPM_MASK; | 1094 | REG_CPM_LCR &= ~CPM_LCR_LPM_MASK; |
1129 | REG_CPM_LCR |= CPM_LCR_LPM_SLEEP; | 1095 | REG_CPM_LCR |= CPM_LCR_LPM_SLEEP; |
1130 | */ | 1096 | #endif |
1131 | #if 0 | 1097 | asm volatile(".set mips32r2 \n" |
1132 | asm volatile(".set mips32 \n" | 1098 | "mfc0 $8, $12 \n" /* mfc $t0, $12 */ |
1133 | "mfc0 t0, 12 \n" | 1099 | "move $9, $8 \n" /* move $t1, $t0 */ |
1134 | "move t1, t0 \n" | 1100 | "la $10, 0x8000000 \n" /* la $t2, 0x8000000 */ |
1135 | "ori t0, t0, 0x8000000 \n" /* Enable reduced power mode */ | 1101 | "or $8, $8, $10 \n" /* Enable reduced power mode */ |
1136 | "mtc0 t0, 12 \n" | 1102 | "mtc0 $8, $12 \n" |
1137 | "wait \n" | 1103 | "wait \n" |
1138 | "mtc0 t1, 12 \n" | 1104 | "mtc0 $9, $12 \n" |
1139 | ".set mips0 \n" | 1105 | ".set mips0 \n" |
1140 | ::: "t0", "t1" | 1106 | ::: "t0", "t1", "t2" |
1141 | ); | 1107 | ); |
1142 | #endif | 1108 | #if CONFIG_CPU == JZ4732 |
1143 | /* | ||
1144 | REG_CPM_LCR &= ~CPM_LCR_LPM_MASK; | 1109 | REG_CPM_LCR &= ~CPM_LCR_LPM_MASK; |
1145 | REG_CPM_LCR |= CPM_LCR_LPM_IDLE; | 1110 | REG_CPM_LCR |= CPM_LCR_LPM_IDLE; |
1146 | */ | 1111 | #endif |
1112 | #endif | ||
1147 | } | 1113 | } |
1148 | 1114 | ||
1149 | 1115 | ||
@@ -2071,7 +2037,6 @@ static inline void block_thread_on_l(struct thread_entry *thread, | |||
2071 | */ | 2037 | */ |
2072 | void switch_thread(void) | 2038 | void switch_thread(void) |
2073 | { | 2039 | { |
2074 | #ifndef ONDA_VX747 | ||
2075 | 2040 | ||
2076 | const unsigned int core = CURRENT_CORE; | 2041 | const unsigned int core = CURRENT_CORE; |
2077 | struct thread_entry *block = cores[core].block_task; | 2042 | struct thread_entry *block = cores[core].block_task; |
@@ -2208,7 +2173,6 @@ void switch_thread(void) | |||
2208 | profile_thread_started(thread - threads); | 2173 | profile_thread_started(thread - threads); |
2209 | #endif | 2174 | #endif |
2210 | 2175 | ||
2211 | #endif | ||
2212 | } | 2176 | } |
2213 | 2177 | ||
2214 | /*--------------------------------------------------------------------------- | 2178 | /*--------------------------------------------------------------------------- |