freemyipod r35 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r34‎ | r35 | r36 >
Date:01:29, 6 August 2010
Author:theseven
Status:new
Tags:
Comment:
Implement the remaining monitor functionality
Modified paths:
  • /embios/trunk/target/ipodnano2g/ls.x (modified) (history)
  • /embios/trunk/target/ipodnano2g/mmu.c (modified) (history)
  • /embios/trunk/target/ipodnano2g/mmu.h (modified) (history)
  • /embios/trunk/usb/usb.c (modified) (history)

Diff [purge]

Index: embios/trunk/target/ipodnano2g/mmu.c
@@ -62,3 +62,12 @@
6363 "MOV PC, LR \n\t"
6464 );
6565 }
 66+
 67+void invalidate_icache()
 68+{
 69+ asm volatile(
 70+ "MOV R0, #0 \n\t"
 71+ "MCR p15, 0, R0,c7,c5,0 \n\t"
 72+ "MOV PC, LR \n\t"
 73+ );
 74+}
Index: embios/trunk/target/ipodnano2g/ls.x
@@ -14,10 +14,12 @@
1515 {
1616 .init :
1717 {
 18+ _initstart = .;
1819 *(.initcode*)
1920 *(.initrodata*)
2021 *(.initdata*)
2122 . = ALIGN(0x4);
 23+ _initend = .;
2224 } > INIT
2325
2426 .sram :
Index: embios/trunk/target/ipodnano2g/mmu.h
@@ -30,6 +30,7 @@
3131
3232 void clean_dcache() __attribute__((naked, noinline)) ICODE_ATTR;
3333 void invalidate_dcache() __attribute__((naked, noinline)) ICODE_ATTR;
 34+void invalidate_icache() __attribute__((naked, noinline)) ICODE_ATTR;
3435
3536
3637 #endif
Index: embios/trunk/usb/usb.c
@@ -33,6 +33,7 @@
3434 #include "strlen.h"
3535 #include "contextswitch.h"
3636 #include "pmu.h"
 37+#include "mmu.h"
3738 #include "shutdown.h"
3839
3940
@@ -76,7 +77,10 @@
7778
7879 static const char dbgconoverflowstr[] = "\n\n[overflowed]\n\n";
7980
 81+extern int _initstart; // These aren't ints at all, but gcc complains about void types being
 82+extern int _sdramstart; // used here, and we only need the address, so forget about it...
8083
 84+
8185 static struct usb_device_descriptor CACHEALIGN_ATTR device_descriptor =
8286 {
8387 .bLength = sizeof(struct usb_device_descriptor),
@@ -328,6 +332,10 @@
329333 dbgsendbuf[2] = usb_drv_get_max_out_size();
330334 dbgsendbuf[3] = usb_drv_get_max_in_size();
331335 break;
 336+ case 2: // GET USER MEMORY INFO
 337+ dbgsendbuf[1] = (uint32_t)&_initstart;
 338+ dbgsendbuf[2] = (uint32_t)&_sdramstart;
 339+ break;
332340 default:
333341 dbgsendbuf[0] = 2;
334342 }
@@ -463,6 +471,30 @@
464472 dbgsendbuf[0] = 1;
465473 size = 16;
466474 break;
 475+ case 17: // SUSPEND THREAD
 476+ if (dbgrecvbuf[1]) thread_suspend(dbgrecvbuf[2]);
 477+ else thread_resume(dbgrecvbuf[2]);
 478+ dbgsendbuf[0] = 1;
 479+ size = 16;
 480+ break;
 481+ case 18: // KILL THREAD
 482+ thread_terminate(dbgrecvbuf[1]);
 483+ dbgsendbuf[0] = 1;
 484+ size = 16;
 485+ break;
 486+ case 19: // KILL THREAD
 487+ dbgsendbuf[0] = 1;
 488+ dbgsendbuf[1] = thread_create((const char*)dbgsendbuf[1], (const void*)dbgsendbuf[2],
 489+ (char*)dbgsendbuf[3], dbgsendbuf[4], dbgsendbuf[5],
 490+ dbgsendbuf[6], dbgsendbuf[7]);
 491+ size = 16;
 492+ break;
 493+ case 20: // FLUSH CACHE
 494+ clean_dcache();
 495+ invalidate_icache();
 496+ dbgsendbuf[0] = 1;
 497+ size = 16;
 498+ break;
467499 default:
468500 dbgsendbuf[0] = 2;
469501 size = 16;
@@ -496,8 +528,12 @@
497529 if (scheduler_threads[i].state == THREAD_DEFUNCT)
498530 {
499531 if (scheduler_threads[i].block_type == THREAD_DEFUNCT_STKOV)
500 - cprintf(1, "\n*PANIC*\nStack overflow! (%s)\n",
501 - scheduler_threads[i].name);
 532+ {
 533+ if (scheduler_threads[i].name)
 534+ cprintf(1, "\n*PANIC*\nStack overflow! (%s)\n",
 535+ scheduler_threads[i].name);
 536+ else cprintf(1, "\n*PANIC*\nStack overflow! (ID %d)\n", i);
 537+ }
502538 scheduler_threads[i].state = THREAD_DEFUNCT_ACK;
503539 }
504540 if (dbgaction != DBGACTION_IDLE)