Index: embios/trunk/usb/usbtarget.h |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +//
|
| 3 | +//
|
| 4 | +// Copyright 2010 TheSeven
|
| 5 | +//
|
| 6 | +//
|
| 7 | +// This file is part of emBIOS.
|
| 8 | +//
|
| 9 | +// emBIOS is free software: you can redistribute it and/or
|
| 10 | +// modify it under the terms of the GNU General Public License as
|
| 11 | +// published by the Free Software Foundation, either version 2 of the
|
| 12 | +// License, or (at your option) any later version.
|
| 13 | +//
|
| 14 | +// emBIOS is distributed in the hope that it will be useful,
|
| 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| 17 | +// See the GNU General Public License for more details.
|
| 18 | +//
|
| 19 | +// You should have received a copy of the GNU General Public License along
|
| 20 | +// with emBIOS. If not, see <http://www.gnu.org/licenses/>.
|
| 21 | +//
|
| 22 | +//
|
| 23 | +
|
| 24 | +
|
| 25 | +#ifndef __USBTARGET_H__
|
| 26 | +#define __USBTARGET_H__
|
| 27 | +
|
| 28 | +
|
| 29 | +#include "global.h"
|
| 30 | +
|
| 31 | +
|
| 32 | +int usb_target_handle_request(uint32_t* buffer, int bufsize);
|
| 33 | +
|
| 34 | +
|
| 35 | +#endif
|
Index: embios/trunk/usb/usb.c |
— | — | @@ -46,6 +46,9 @@ |
47 | 47 | #ifdef HAVE_HMACSHA1
|
48 | 48 | #include "hmacsha1.h"
|
49 | 49 | #endif
|
| 50 | +#ifdef USB_HAVE_TARGET_SPECIFIC_REQUESTS
|
| 51 | +#include "usbtarget.h"
|
| 52 | +#endif
|
50 | 53 |
|
51 | 54 |
|
52 | 55 | static uint8_t ctrlresp[2] CACHEALIGN_ATTR;
|
— | — | @@ -69,7 +72,8 @@ |
70 | 73 | DBGACTION_READBOOTFLASH,
|
71 | 74 | DBGACTION_WRITEBOOTFLASH,
|
72 | 75 | DBGACTION_HWKEYAES,
|
73 | | - DBGACTION_HMACSHA1
|
| 76 | + DBGACTION_HMACSHA1,
|
| 77 | + DBGACTION_TARGETSPECIFIC
|
74 | 78 | };
|
75 | 79 |
|
76 | 80 | static uint32_t dbgstack[0x100] STACK_ATTR;
|
— | — | @@ -332,6 +336,15 @@ |
333 | 337 | int size = 0;
|
334 | 338 | if (endpoint == dbgendpoints[0])
|
335 | 339 | {
|
| 340 | +#ifdef USB_HAVE_TARGET_SPECIFIC_REQUESTS
|
| 341 | + if (dbgrecvbuf[0] >= 0xffff0000)
|
| 342 | + {
|
| 343 | + if (!set_dbgaction(DBGACTION_TARGETSPECIFIC, 0))
|
| 344 | + memcpy(dbgasyncsendbuf, dbgrecvbuf, sizeof(dbgasyncsendbuf));
|
| 345 | + usb_setup_dbg_listener();
|
| 346 | + return;
|
| 347 | + }
|
| 348 | +#endif
|
336 | 349 | switch (dbgrecvbuf[0])
|
337 | 350 | {
|
338 | 351 | case 1: // GET INFO
|
— | — | @@ -641,7 +654,7 @@ |
642 | 655 | dbgasyncsendbuf[0] = 1;
|
643 | 656 | dbgasyncsendbuf[1] = cread(dbgactionconsoles, (char*)&dbgasyncsendbuf[4],
|
644 | 657 | dbgactionlength, 0);
|
645 | | - usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
| 658 | + usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16 + dbgactionlength);
|
646 | 659 | break;
|
647 | 660 | case DBGACTION_CFLUSH:
|
648 | 661 | cflush(dbgactionconsoles);
|
— | — | @@ -685,7 +698,15 @@ |
686 | 699 | usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
687 | 700 | break;
|
688 | 701 | #endif
|
| 702 | +#ifdef USB_HAVE_TARGET_SPECIFIC_REQUESTS
|
| 703 | + case DBGACTION_TARGETSPECIFIC:
|
| 704 | + {
|
| 705 | + int size = usb_target_handle_request(dbgasyncsendbuf, sizeof(dbgasyncsendbuf));
|
| 706 | + if (size) usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, size);
|
| 707 | + break;
|
689 | 708 | }
|
| 709 | +#endif
|
| 710 | + }
|
690 | 711 | dbgaction = DBGACTION_IDLE;
|
691 | 712 | }
|
692 | 713 | }
|