Subversion Repositories freemyipod

Rev

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

Rev 92 Rev 95
Line 35... Line 35...
35
#include "shutdown.h"
35
#include "shutdown.h"
36
#include "execimage.h"
36
#include "execimage.h"
37
#ifdef HAVE_I2C
37
#ifdef HAVE_I2C
38
#include "i2c.h"
38
#include "i2c.h"
39
#endif
39
#endif
-
 
40
#ifdef HAVE_BOOTFLASH
-
 
41
#include "bootflash.h"
-
 
42
#endif
40
 
43
 
41
 
44
 
42
static uint8_t ctrlresp[2] CACHEALIGN_ATTR;
45
static uint8_t ctrlresp[2] CACHEALIGN_ATTR;
43
static uint32_t dbgrecvbuf[0x80] CACHEALIGN_ATTR;
46
static uint32_t dbgrecvbuf[0x80] CACHEALIGN_ATTR;
44
static uint32_t dbgsendbuf[0x80] CACHEALIGN_ATTR;
47
static uint32_t dbgsendbuf[0x80] CACHEALIGN_ATTR;
Line 53... Line 56...
53
    DBGACTION_RESET,
56
    DBGACTION_RESET,
54
    DBGACTION_POWEROFF,
57
    DBGACTION_POWEROFF,
55
    DBGACTION_CWRITE,
58
    DBGACTION_CWRITE,
56
    DBGACTION_CREAD,
59
    DBGACTION_CREAD,
57
    DBGACTION_CFLUSH,
60
    DBGACTION_CFLUSH,
58
    DBGACTION_EXECIMAGE
61
    DBGACTION_EXECIMAGE,
-
 
62
    DBGACTION_READBOOTFLASH,
-
 
63
    DBGACTION_WRITEBOOTFLASH
59
};
64
};
60
 
65
 
61
static uint32_t dbgstack[0x100] STACK_ATTR;
66
static uint32_t dbgstack[0x100] STACK_ATTR;
62
struct wakeup dbgwakeup IBSS_ATTR;
67
struct wakeup dbgwakeup IBSS_ATTR;
63
extern struct scheduler_thread* scheduler_threads;
68
extern struct scheduler_thread* scheduler_threads;
64
static enum dbgaction_t dbgaction IBSS_ATTR;
69
static enum dbgaction_t dbgaction IBSS_ATTR;
65
static int dbgi2cbus;
70
static int dbgi2cbus;
66
static int dbgi2cslave;
71
static int dbgi2cslave;
67
static int dbgactionaddr;
72
static int dbgactionaddr;
-
 
73
static int dbgactionoffset;
68
static int dbgactionlength;
74
static int dbgactionlength;
69
static int dbgactionconsoles;
75
static int dbgactionconsoles;
70
static int dbgactiontype;
76
static int dbgactiontype;
71
static char dbgconsendbuf[4096];
77
static char dbgconsendbuf[4096];
72
static char dbgconrecvbuf[1024];
78
static char dbgconrecvbuf[1024];
Line 511... Line 517...
511
            break;
517
            break;
512
        case 21:  // EXECIMAGE
518
        case 21:  // EXECIMAGE
513
            if (set_dbgaction(DBGACTION_EXECIMAGE, 0)) break;
519
            if (set_dbgaction(DBGACTION_EXECIMAGE, 0)) break;
514
            dbgactionaddr = dbgrecvbuf[1];
520
            dbgactionaddr = dbgrecvbuf[1];
515
            break;
521
            break;
-
 
522
#ifdef HAVE_BOOTFLASH
-
 
523
        case 22:  // READ BOOT FLASH
-
 
524
            if (set_dbgaction(DBGACTION_READBOOTFLASH, 0)) break;
-
 
525
            dbgactionaddr = dbgrecvbuf[1];
-
 
526
            dbgactionoffset = dbgrecvbuf[2];
-
 
527
            dbgactionlength = dbgrecvbuf[3];
-
 
528
            break;
-
 
529
        case 23:  // WRITE BOOT FLASH
-
 
530
            if (set_dbgaction(DBGACTION_WRITEBOOTFLASH, 0)) break;
-
 
531
            dbgactionaddr = dbgrecvbuf[1];
-
 
532
            dbgactionoffset = dbgrecvbuf[2];
-
 
533
            dbgactionlength = dbgrecvbuf[3];
-
 
534
            break;
-
 
535
#endif
516
        default:
536
        default:
517
            dbgsendbuf[0] = 2;
537
            dbgsendbuf[0] = 2;
518
            size = 16;
538
            size = 16;
519
        }
539
        }
520
        usb_setup_dbg_listener();
540
        usb_setup_dbg_listener();
Line 599... Line 619...
599
            case DBGACTION_EXECIMAGE:
619
            case DBGACTION_EXECIMAGE:
600
                dbgasyncsendbuf[0] = 1;
620
                dbgasyncsendbuf[0] = 1;
601
                dbgasyncsendbuf[1] = execimage((void*)dbgactionaddr);
621
                dbgasyncsendbuf[1] = execimage((void*)dbgactionaddr);
602
                usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
622
                usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
603
                break;
623
                break;
-
 
624
#ifdef HAVE_BOOTFLASH
-
 
625
            case DBGACTION_READBOOTFLASH:
-
 
626
                bootflash_readraw((void*)dbgactionaddr, dbgactionoffset, dbgactionlength);
-
 
627
                dbgasyncsendbuf[0] = 1;
-
 
628
                usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
-
 
629
                break;
-
 
630
            case DBGACTION_WRITEBOOTFLASH:
-
 
631
                bootflash_writeraw((void*)dbgactionaddr, dbgactionoffset, dbgactionlength);
-
 
632
                dbgasyncsendbuf[0] = 1;
-
 
633
                usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
-
 
634
                break;
-
 
635
#endif
604
            }
636
            }
605
            dbgaction = DBGACTION_IDLE;
637
            dbgaction = DBGACTION_IDLE;
606
        }
638
        }
607
    }
639
    }
608
}
640
}