Subversion Repositories freemyipod

Rev

Rev 34 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34 Rev 35
Line 31... Line 31...
31
#include "util.h"
31
#include "util.h"
32
#include "i2c.h"
32
#include "i2c.h"
33
#include "strlen.h"
33
#include "strlen.h"
34
#include "contextswitch.h"
34
#include "contextswitch.h"
35
#include "pmu.h"
35
#include "pmu.h"
-
 
36
#include "mmu.h"
36
#include "shutdown.h"
37
#include "shutdown.h"
37
 
38
 
38
 
39
 
39
static uint8_t ctrlresp[2] CACHEALIGN_ATTR;
40
static uint8_t ctrlresp[2] CACHEALIGN_ATTR;
40
static uint32_t dbgrecvbuf[0x80] CACHEALIGN_ATTR;
41
static uint32_t dbgrecvbuf[0x80] CACHEALIGN_ATTR;
Line 74... Line 75...
74
static struct wakeup dbgconrecvwakeup IBSS_ATTR;
75
static struct wakeup dbgconrecvwakeup IBSS_ATTR;
75
static bool dbgconsoleattached IBSS_ATTR;
76
static bool dbgconsoleattached IBSS_ATTR;
76
 
77
 
77
static const char dbgconoverflowstr[] = "\n\n[overflowed]\n\n";
78
static const char dbgconoverflowstr[] = "\n\n[overflowed]\n\n";
78
 
79
 
-
 
80
extern int _initstart;   // These aren't ints at all, but gcc complains about void types being
-
 
81
extern int _sdramstart;  // used here, and we only need the address, so forget about it...
-
 
82
 
79
 
83
 
80
static struct usb_device_descriptor CACHEALIGN_ATTR device_descriptor =
84
static struct usb_device_descriptor CACHEALIGN_ATTR device_descriptor =
81
{
85
{
82
    .bLength            = sizeof(struct usb_device_descriptor),
86
    .bLength            = sizeof(struct usb_device_descriptor),
83
    .bDescriptorType    = USB_DT_DEVICE,
87
    .bDescriptorType    = USB_DT_DEVICE,
Line 326... Line 330...
326
            case 1:  // GET PACKET SIZE INFO
330
            case 1:  // GET PACKET SIZE INFO
327
                dbgsendbuf[1] = 0x02000200;
331
                dbgsendbuf[1] = 0x02000200;
328
                dbgsendbuf[2] = usb_drv_get_max_out_size();
332
                dbgsendbuf[2] = usb_drv_get_max_out_size();
329
                dbgsendbuf[3] = usb_drv_get_max_in_size();
333
                dbgsendbuf[3] = usb_drv_get_max_in_size();
330
                break;
334
                break;
-
 
335
            case 2:  // GET USER MEMORY INFO
-
 
336
                dbgsendbuf[1] = (uint32_t)&_initstart;
-
 
337
                dbgsendbuf[2] = (uint32_t)&_sdramstart;
-
 
338
                break;
331
            default:
339
            default:
332
                dbgsendbuf[0] = 2;
340
                dbgsendbuf[0] = 2;
333
            }
341
            }
334
            break;
342
            break;
335
        case 2:  // RESET
343
        case 2:  // RESET
Line 461... Line 469...
461
        case 16:  // FREEZE SCHEDULER
469
        case 16:  // FREEZE SCHEDULER
462
            scheduler_freeze(dbgrecvbuf[1]);
470
            scheduler_freeze(dbgrecvbuf[1]);
463
            dbgsendbuf[0] = 1;
471
            dbgsendbuf[0] = 1;
464
            size = 16;
472
            size = 16;
465
            break;
473
            break;
-
 
474
        case 17:  // SUSPEND THREAD
-
 
475
            if (dbgrecvbuf[1]) thread_suspend(dbgrecvbuf[2]);
-
 
476
            else thread_resume(dbgrecvbuf[2]);
-
 
477
            dbgsendbuf[0] = 1;
-
 
478
            size = 16;
-
 
479
            break;
-
 
480
        case 18:  // KILL THREAD
-
 
481
            thread_terminate(dbgrecvbuf[1]);
-
 
482
            dbgsendbuf[0] = 1;
-
 
483
            size = 16;
-
 
484
            break;
-
 
485
        case 19:  // KILL THREAD
-
 
486
            dbgsendbuf[0] = 1;
-
 
487
            dbgsendbuf[1] = thread_create((const char*)dbgsendbuf[1], (const void*)dbgsendbuf[2],
-
 
488
                                          (char*)dbgsendbuf[3], dbgsendbuf[4], dbgsendbuf[5],
-
 
489
                                          dbgsendbuf[6], dbgsendbuf[7]);
-
 
490
            size = 16;
-
 
491
            break;
-
 
492
        case 20:  // FLUSH CACHE
-
 
493
            clean_dcache();
-
 
494
            invalidate_icache();
-
 
495
            dbgsendbuf[0] = 1;
-
 
496
            size = 16;
-
 
497
            break;
466
        default:
498
        default:
467
            dbgsendbuf[0] = 2;
499
            dbgsendbuf[0] = 2;
468
            size = 16;
500
            size = 16;
469
        }
501
        }
470
        usb_setup_dbg_listener();
502
        usb_setup_dbg_listener();
Line 494... Line 526...
494
        wakeup_wait(&dbgwakeup, TIMEOUT_BLOCK);
526
        wakeup_wait(&dbgwakeup, TIMEOUT_BLOCK);
495
        for (i = 0; i < MAX_THREADS; i++)
527
        for (i = 0; i < MAX_THREADS; i++)
496
            if (scheduler_threads[i].state == THREAD_DEFUNCT)
528
            if (scheduler_threads[i].state == THREAD_DEFUNCT)
497
            {
529
            {
498
                if (scheduler_threads[i].block_type == THREAD_DEFUNCT_STKOV)
530
                if (scheduler_threads[i].block_type == THREAD_DEFUNCT_STKOV)
-
 
531
                {
-
 
532
                    if (scheduler_threads[i].name)
499
                    cprintf(1, "\n*PANIC*\nStack overflow! (%s)\n",
533
                        cprintf(1, "\n*PANIC*\nStack overflow! (%s)\n",
500
                            scheduler_threads[i].name);
534
                                scheduler_threads[i].name);
-
 
535
                    else cprintf(1, "\n*PANIC*\nStack overflow! (ID %d)\n", i);
-
 
536
                }
501
                scheduler_threads[i].state = THREAD_DEFUNCT_ACK;
537
                scheduler_threads[i].state = THREAD_DEFUNCT_ACK;
502
            }
538
            }
503
        if (dbgaction != DBGACTION_IDLE)
539
        if (dbgaction != DBGACTION_IDLE)
504
        {
540
        {
505
            switch (dbgaction)
541
            switch (dbgaction)