static void parse_header(const uint8_t *data, struct coff_header *hdr)
{
	hdr->version = LE_WORD(data, 0);
	hdr->sec_count = LE_WORD(data, 2);
	hdr->timestamp = LE_LONG(data, 4);
	hdr->stab_start = LE_LONG(data, 8);
	hdr->stab_count = LE_LONG(data, 12);
	hdr->opt_bytes = LE_WORD(data, 16);
	hdr->flags = LE_WORD(data, 18);
	hdr->target_id = LE_WORD(data, 20);
}
Пример #2
0
static int parse_sym(Elf32_Sym *s, FILE *in)
{
	uint8_t data[16];

	if (fread(data, sizeof(data), 1, in) != 1)
		return -1;

	s->st_name = LE_LONG(data, 0);
	s->st_value = LE_LONG(data, 4);
	s->st_size = LE_LONG(data, 8);
	s->st_info = data[12];
	s->st_other = data[13];
	s->st_shndx = LE_WORD(data, 14);

	return 0;
}
Пример #3
0
static int parse_ehdr(Elf32_Ehdr *e, FILE *in)
{
	uint8_t data[52];

	if (fread(data, sizeof(data), 1, in) != 1)
		return -1;

	memcpy(e->e_ident, data, EI_NIDENT);
	e->e_type = LE_WORD(data, 16);
	e->e_machine = LE_WORD(data, 18);
	e->e_version = LE_LONG(data, 20);
	e->e_entry = LE_LONG(data, 24);
	e->e_phoff = LE_LONG(data, 28);
	e->e_shoff = LE_LONG(data, 32);
	e->e_flags = LE_LONG(data, 36);
	e->e_ehsize = LE_WORD(data, 40);
	e->e_phentsize = LE_WORD(data, 42);
	e->e_phnum = LE_WORD(data, 44);
	e->e_shentsize = LE_WORD(data, 46);
	e->e_shnum = LE_WORD(data, 48);
	e->e_shstrndx = LE_WORD(data, 50);

	return 0;
}
Пример #4
0
} TLineCoding;

static TLineCoding LineCoding = {460800, 0, 0, 8};
static unsigned char dataBuf[65];
static unsigned char abClassReqData[8];

USBSerialStream *USBSerialStream::m_instance = NULL;


// USB Descriptors.
static const unsigned char abDescriptors[] = {

// device descriptor
	0x12,
	DESC_DEVICE,
	LE_WORD(0x0200),			// bcdUSB
	0x02,						// bDeviceClass
	0x00,						// bDeviceSubClass
	0x00,						// bDeviceProtocol
	MAX_PACKET_SIZE0,			// bMaxPacketSize
	LE_WORD(0xFFFF),			// idVendor
	LE_WORD(0x0005),			// idProduct
	LE_WORD(0x0100),			// bcdDevice
	0x01,						// iManufacturer
	0x02,						// iProduct
	0x03,						// iSerialNumber
	0x01,						// bNumConfigurations

// configuration descriptor
	0x09,
	DESC_CONFIGURATION,
Пример #5
0
static unsigned char txbuf[SERIAL_FIFO_SIZE];
static unsigned char rxbuf[SERIAL_FIFO_SIZE];

static U8 abBulkBuf[64];
static U8 abClassReqData[8];

// forward declaration of interrupt handler
void USBIntHandler(void);

static U8 abDescriptors[] = {

    // device descriptor
      0x12,
      DESC_DEVICE,
      LE_WORD(0x0110),            // bcdUSB
      0xFF,                       // bDeviceClass
      0x00,                       // bDeviceSubClass
      0x00,                       // bDeviceProtocol
      MAX_PACKET_SIZE0,           // bMaxPacketSize
#ifdef BTF_OLD
      LE_WORD(0xffff),            // idVendor
#else
      LE_WORD(0x29C9),            // idVendor
#endif
#ifdef BTF
      LE_WORD(0x0001),               // idProduct
#endif
#ifdef BTF_PLUS
      LE_WORD(0x0002),               // idProduct
#endif
Пример #6
0
#define	INT_VECT_NUM	0

#define IRQ_MASK 0x00000080

//static U8 abBulkBuf[64];
static U8 abClassReqData[8];

// forward declaration of interrupt handler
static void USBIntHandler(void) __attribute__ ((interrupt(IRQ), naked));

static const U8 abDescriptors[] = {

// device descriptor
	0x12,
	DESC_DEVICE,
	LE_WORD(0x0101),			// bcdUSB
	0x02,						// bDeviceClass
	0x00,						// bDeviceSubClass
	0x00,						// bDeviceProtocol
	MAX_PACKET_SIZE0,			// bMaxPacketSize
	LE_WORD(0xFFFF),			// idVendor
	LE_WORD(0x0005),			// idProduct
	LE_WORD(0x0100),			// bcdDevice
	0x01,						// iManufacturer
	0x02,						// iProduct
	0x03,						// iSerialNumber
	0x01,						// bNumConfigurations

// configuration descriptor
	0x09,
	DESC_CONFIGURATION,
__xdata u16  ep0len;
__xdata u16  ep0value;

//__xdata dmacfg_t usbdma;
__xdata DMA_DESC *usbdma;
__data u8 usbdmachan, usbdmaarm;
//__xdata u8 usbdmar[8];

__xdata int (*cb_ep0outdone)(void);
__xdata int (*cb_ep0out)(void);
__xdata int (*cb_ep0vendor)(USB_Setup_Header*);
__xdata int (*cb_ep5)(void);

__code u8 sdccver[] = {
    'S','D','C','C','v',
    LE_WORD(SDCC)
};
// BUILD_VERSION is passed in -D from Makefile
__code u8 buildname[] = {
#ifdef DONSDONGLES
    'D','O','N','S','D','O','N','G','L','E',' ','r',ASCII_LONG(BUILD_VERSION),'\x00',
#elif defined YARDSTICKONE
    'Y','A','R','D','S','T','I','C','K','O','N','E',' ','r',ASCII_LONG(BUILD_VERSION),'\x00',
#elif defined CHRONOSDONGLE
    'C','H','R','O','N','O','S',' ','r',ASCII_LONG(BUILD_VERSION),'\x00',
#else
    'I','M','M','E',' ','r',ASCII_LONG(BUILD_VERSION),'\x00',
#endif
};

// USB endpoint
Пример #8
0
#define MAX_PACKET_SIZE (64)

/* #define ETH_DEV_DEBUG  */
#define ETH_DEV_DBG_ERROR(fmt, args...) DBG("USB DEV ERROR:" fmt, ##args)

#ifdef ETH_DEV_DEBUG
#define ETH_DEV_DBG_INFO(fmt, args...) DBG("USB DEV INFO:" fmt, ##args)
#else
#define ETH_DEV_DBG_INFO(fmt, args...)
#endif

static const uint8_t usb_descriptors[] = {
  0x12,                /* length                      */
  DESC_DEVICE,
  LE_WORD(0x0110),     /* USB version (BCD)           */
  0x02,                /* Class = CDC (Communication) */
  0x00,                /* Device Sub Class            */
  0x00,                /* Device Protocol             */
  MAX_PACKET_SIZE0,    /* max packet size for EP 0    */
  LE_WORD(0x050d),     /* Vendor: Belkin              */
  LE_WORD(0x0004),     /* Product: Belkin             */
  LE_WORD(0x0201),     /* Device release number (BCD) */
  1,                   /* Manufacturer String Index   */
  2,                   /* Product String Index        */
  3,                   /* SerialNumber String Index   */
  1,                   /* Number of Configurations    */

  0x09,
  DESC_CONFIGURATION,
  LE_WORD(32),         /* total length                */
Пример #9
0
static bool usb_control_vendor_handler() { return FALSE; }
static bool usb_control_reserved_handler() { return FALSE; }

#define MAX_USB_PACKET_SIZE (64)
#define ETHERNET_FRAME_SIZE_MAX               1536


#define CDC_ECM_BULK_EP_IN  5
#define CDC_ECM_BULK_EP_OUT 5


#define CS_INTERFACE            0x24
static const uint8_t usb_descriptors[] = {
  0x12,                /* length                      */
  DESC_DEVICE,
  LE_WORD(0x0110),     /* USB version (BCD)           */
  0x02,                /* Class = CDC (Communication) */
  0x00,                /* Device Sub Class            */
  0x00,                /* Device Protocol             */
  MAX_PACKET_SIZE0,    /* max packet size for EP 0    */
  LE_WORD(0x16C0),     /* Vendor: Wouter van Ooijen   */
  LE_WORD(  1002),     /* Product: lab-use only #2    */
  LE_WORD(0x0101),     /* Device release number (BCD) */
  1,                   /* Manufacturer String Index   */
  2,                   /* Product String Index        */
  3,                   /* SerialNumber String Index   */
  1,                   /* Number of Configurations    */

  // CDC Ethernet Networking Control Model" (CDC ECM)

  0x09,
Пример #10
0
#include "lpc23xx-uart.h"
#include "lpc23xx-util.h"
#include "lpc23xx-vic.h"

#include "usbapi.h"
#include "usbhw_lpc.h"

#include "dp-isoc.h"


static const U8 abDescriptors[] = {

// device descriptor
	0x12,
	DESC_DEVICE,
	LE_WORD(0x0101),			// bcdUSB
	0x02,						// bDeviceClass
	0x00,						// bDeviceSubClass
	0x00,						// bDeviceProtocol
	MAX_PACKET_SIZE0,			// bMaxPacketSize
	LE_WORD(0xFFFF),			// idVendor
	LE_WORD(0x0005),			// idProduct
	LE_WORD(0x0100),			// bcdDevice
	0x01,						// iManufacturer
	0x02,						// iProduct
	0x03,						// iSerialNumber
	0x01,						// bNumConfigurations

// configuration descriptor
	0x09,
	DESC_CONFIGURATION,
Пример #11
0
static unsigned int write_ram_adr;
static unsigned int read_mem_adr;
static int write_ram_len;
static int read_mem_len;
static char unlocked;
static char bEcho;

static unsigned int start_app;
static unsigned int start_adr;

static const U8 abDescriptors[] = {

// device descriptor
    0x12,
    DESC_DEVICE,
    LE_WORD(0x0110),            // bcdUSB
    0x00,                       // bDeviceClass
    0x00,                       // bDeviceSubClass
    0x00,                       // bDeviceProtocol
    MAX_PACKET_SIZE0,           // bMaxPacketSize
    LE_WORD(VENDOR_ID),         // idVendor
    LE_WORD(DEVICE_ID),         // idProduct
    LE_WORD(0x0100),            // bcdDevice
    0x01,                       // iManufacturer
    0x02,                       // iProduct
    0x03,                       // iSerialNumber
    0x01,                       // bNumConfigurations

// configuration descriptor
    0x09,
    DESC_CONFIGURATION,
Пример #12
0
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 */

#include "cc1111.h"
#include "usb.h"

// USB descriptors in one giant block of bytes
// __code __at(0x00aa) uint8_t usb_descriptors [] =
__xdata uint8_t usb_descriptors [] =
{
  // Device descriptor
  0x12,
  USB_DESC_DEVICE,
  LE_WORD(0x0110),  // bcdUSB
  0x02,             // bDeviceClass
  0x00,             // bDeviceSubClass
  0x00,             // bDeviceProtocol
  USB_CONTROL_SIZE, // bMaxPacketSize
  LE_WORD(USB_VID), // idVendor
  LE_WORD(USB_PID), // idProduct
  LE_WORD(0x010),   // bcdDevice
  0x01,             // iManufacturer
  0x02,             // iProduct
  0x03,             // iSerialNumber
  0x01,             // bNumConfigurations

  // Configuration descriptor
  0x09,
  USB_DESC_CONFIGURATION,
Пример #13
0
#define BAUD_RATE   115200

#define MAX_PACKET_SIZE 64

#define LE_WORD(x)      ((x)&0xFF),((x)>>8)

static U8 abClassReqData[4];

//static const U8 abDescriptors[] =
static U8 abDescriptors[] =
{

    // device descriptor
    0x12,
    DESC_DEVICE,
    LE_WORD(0x0200),        // bcdUSB
    0x00,                   // bDeviceClass
    0x00,                   // bDeviceSubClass
    0x00,                   // bDeviceProtocol
    MAX_PACKET_SIZE0,       // bMaxPacketSize
    LE_WORD(0x1b4f),        // idVendor
    LE_WORD(0x0001),        // idProduct
    LE_WORD(0x0100),        // bcdDevice
    0x01,                   // iManufacturer
    0x02,                   // iProduct
    0x03,                   // iSerialNumber
    0x01,                   // bNumConfigurations

    // configuration descriptor
    0x09,
    DESC_CONFIGURATION,
Пример #14
0








static const U8 isoDescriptors[] = {

// device descriptor
// struct offset 0x0                 // (bytes)    Name                (notes)
    0x12,                            // (1)        bLength             (length of descriptor) 18d 
    DESC_DEVICE,                     // (1)        bDescriptorType     (0x1)
    LE_WORD(0x0101),                 // (2)        bcdUSB              (version number)
    0x00,                            // (1)        bDeviceClass        (vendor specific - each interface independent)
    0x00,                            // (1)        bDeviceSubClass     (should be 0 if bDeviceClass is 0)
    0xFF,                            // (1)        bDeviceProtocol     (spec says 0xff for vendor defined)
    MAX_PACKET_SIZE_CTL,                // (1)        bMaxPacketSize      (control endpoint specific)
    LE_WORD(0xFFFF),                 // (2)        idVendor
    LE_WORD(0x0005),                 // (2)        idProduct
    LE_WORD(0x0100),                 // (2)        bcdDevice
    0x01,                            // (1)        iManufacturer       (index of Manufacturer String Descriptor)
    0x02,                            // (1)        iProduct            (index of Product String Descriptor)
    0x04,                            // (1)        iSerialNumber       (index of Serial number String Descriptor)
    0x01,                            // (1)        bNumConfigurations  (just iso for now)
///////////////////////////////////
// configuration descriptor
///////////////////////////////////
// struct offset (0x12) (18d)        // (bytes)    Name                (notes)
//#define INT_IN_EP		  0x81
//#define BULK_OUT_EP   0x02
//#define BULK_IN_EP    0x82

#define INT_EP  1
#define BULK_EP 2

#define MAX_PACKET_SIZE	64

#define CS_INTERFACE			      0x24
//#define CS_ENDPOINT				      0x25

static const uint8_t usb_descriptors[] = {
  0x12,                /* length                      */
  DESC_DEVICE,
  LE_WORD(0x0110),     /* USB version (BCD)           */
  0x02,                /* Class = CDC (Communication) */
  0x00,                /* Device Sub Class            */
  0x00,                /* Device Protocol             */
  MAX_PACKET_SIZE0,    /* max packet size for EP 0    */
  LE_WORD(0x16C0),     /* Vendor: Wouter van Ooijen   */
  LE_WORD(  1001),     /* Product: lab-use only #1    */
  LE_WORD(0x0100),     /* Device release number (BCD) */
  1,                   /* Manufacturer String Index   */
  2,                   /* Product String Index        */
  3,                   /* SerialNumber String Index   */
  1,                   /* Number of Configurations    */

  0x09,
  DESC_CONFIGURATION,
  LE_WORD(67),         /* total lendth                */
Пример #16
0


#define LE_WORD(x)		((x)&0xFF),((x)>>8)

/*
 * This is supposed to be a lock-free ring buffer, but I haven't verified
 * atomicity of the operations on head and tail.
 */

const u8 abDescriptors[] = {

/* Device descriptor */
	0x12,              		
	DESC_DEVICE,       		
	LE_WORD(0x0200),		// bcdUSB	
	0xFF,              		// bDeviceClass
	0x00,              		// bDeviceSubClass
	0x00,              		// bDeviceProtocol
	MAX_PACKET_SIZE0,  		// bMaxPacketSize
	LE_WORD(ID_VENDOR),		// idVendor
	LE_WORD(ID_PRODUCT),	// idProduct
	LE_WORD(0x0100),		// bcdDevice
	0x01,              		// iManufacturer
	0x02,              		// iProduct
	0x03,              		// iSerialNumber
	0x01,              		// bNumConfigurations

// configuration
	0x09,
	DESC_CONFIGURATION,