Subversion Repositories freemyipod

Rev

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

Rev 240 Rev 336
Line 98... Line 98...
98
static bool dbgconsoleattached IBSS_ATTR;
98
static bool dbgconsoleattached IBSS_ATTR;
99
 
99
 
100
static const char dbgconoverflowstr[] = "\n\n[overflowed]\n\n";
100
static const char dbgconoverflowstr[] = "\n\n[overflowed]\n\n";
101
 
101
 
102
extern int _initstart;   // These aren't ints at all, but gcc complains about void types being
102
extern int _initstart;   // These aren't ints at all, but gcc complains about void types being
103
extern int _sdramstart;  // used here, and we only need the address, so forget about it...
103
extern int _sdramstart;  // used here, and we only need the address, so just make it happy...
104
 
104
 
105
 
105
 
106
static struct usb_device_descriptor CACHEALIGN_ATTR device_descriptor =
106
static struct usb_device_descriptor CACHEALIGN_ATTR device_descriptor =
107
{
107
{
108
    .bLength            = sizeof(struct usb_device_descriptor),
108
    .bLength            = sizeof(struct usb_device_descriptor),
Line 427... Line 427...
427
            break;
427
            break;
428
#endif
428
#endif
429
        case 10:  // READ CONSOLE
429
        case 10:  // READ CONSOLE
430
            dbgconsoleattached = true;
430
            dbgconsoleattached = true;
431
            int bytes = dbgconsendwriteidx - dbgconsendreadidx;
431
            int bytes = dbgconsendwriteidx - dbgconsendreadidx;
432
            if (bytes >= sizeof(dbgconsendbuf)) bytes -= sizeof(dbgconsendbuf);
432
            int used = 0;
433
            if (bytes)
433
            if (bytes)
434
            {
434
            {
435
                if (bytes < 0) bytes += sizeof(dbgconsendbuf);
435
                if (bytes < 0) bytes += sizeof(dbgconsendbuf);
-
 
436
                used = bytes;
436
                if (bytes > dbgrecvbuf[1]) bytes = dbgrecvbuf[1];
437
                if (bytes > dbgrecvbuf[1]) bytes = dbgrecvbuf[1];
437
                int readbytes = bytes;
438
                int readbytes = bytes;
438
                char* outptr = (char*)&dbgsendbuf[4];
439
                char* outptr = (char*)&dbgsendbuf[4];
439
                if (dbgconsendreadidx + bytes >= sizeof(dbgconsendbuf))
440
                if (dbgconsendreadidx + bytes >= sizeof(dbgconsendbuf))
440
                {
441
                {
Line 449... Line 450...
449
                wakeup_signal(&dbgconsendwakeup);
450
                wakeup_signal(&dbgconsendwakeup);
450
            }
451
            }
451
            dbgsendbuf[0] = 1;
452
            dbgsendbuf[0] = 1;
452
            dbgsendbuf[1] = bytes;
453
            dbgsendbuf[1] = bytes;
453
            dbgsendbuf[2] = sizeof(dbgconsendbuf);
454
            dbgsendbuf[2] = sizeof(dbgconsendbuf);
454
            dbgsendbuf[3] = dbgconsendwriteidx - dbgconsendreadidx;
455
            dbgsendbuf[3] = used - bytes;
455
            size = 16 + dbgrecvbuf[1];
456
            size = 16 + dbgrecvbuf[1];
456
            break;
457
            break;
457
        case 11:  // WRITE CONSOLE
458
        case 11:  // WRITE CONSOLE
458
            bytes = dbgconrecvreadidx - dbgconrecvwriteidx - 1;
459
            bytes = dbgconrecvreadidx - dbgconrecvwriteidx - 1;
459
            if (bytes < 0) bytes += sizeof(dbgconrecvbuf);
460
            if (bytes < 0) bytes += sizeof(dbgconrecvbuf);
Line 740... Line 741...
740
int dbgconsole_makespace(int length)
741
int dbgconsole_makespace(int length)
741
{
742
{
742
    int free = dbgconsole_getfree();
743
    int free = dbgconsole_getfree();
743
    while (!free && dbgconsoleattached)
744
    while (!free && dbgconsoleattached)
744
    {
745
    {
745
        if (wakeup_wait(&dbgconsendwakeup, 2000000) == THREAD_TIMEOUT)
746
        dbgconsoleattached = false;
746
            dbgconsoleattached = false;
747
        wakeup_wait(&dbgconsendwakeup, 2000000);
747
        free = dbgconsole_getfree();
748
        free = dbgconsole_getfree();
748
    }
749
    }
749
    if (free) return free > length ? length : free;
750
    if (free) return free > length ? length : free;
750
    if (length > sizeof(dbgconsendbuf) - 17) length = sizeof(dbgconsendbuf) - 17;
751
    if (length > sizeof(dbgconsendbuf) - 17) length = sizeof(dbgconsendbuf) - 17;
751
    uint32_t mode = enter_critical_section();
752
    uint32_t mode = enter_critical_section();