/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */
#include <iostypes.h>
#include <ios.h>
#include <iop.h>
#include <ioslibc.h>

#include "iosusbtypes.h"
#include "iosusb.h"

#ifndef ENABLE_TEST
#define STACK_SIZE 4096
const u8        _initStack[STACK_SIZE];
const u32       _initStackSize = sizeof(_initStack);
const u32       _initPriority = 20;
#endif /* ENABLE_TEST */

static void
__ctrlTransferTests(IOSFd fd)
{
    u8 buf[64];
    struct USB_DevDescr d;

    { 
        IOSError rv;
        printf("**** Generating error: \n");
        rv = IUSB_WriteCtrlMsg(fd, 0x0a, (0x01 << 5)|0x01, SWAP16((1 << 8)), 0, 
                0, NULL);
        printf("**** Generating error: returned : %d\n", rv);
    }
    IUSB_GetDevDescr(fd, &d); 
    if ( (d.iManufacturer != 0 )
            && (0 < IUSB_GetAsciiStr(fd, 0, d.iManufacturer, 
                    USB_LANG_EN_US, buf, sizeof(buf))))
       printf("Manufacturer: %s\n", buf);
    if ( (d.iProduct != 0)
            && (0 < IUSB_GetAsciiStr(fd, 0, d.iProduct, 
                    USB_LANG_EN_US, buf, sizeof(buf))) ) 
        printf("Product: %s\n", buf);
    if ( (d.iSerialNumber != 0)
            && (0 < IUSB_GetAsciiStr(fd, 0, d.iSerialNumber, 
                    USB_LANG_EN_US, buf, sizeof(buf))) ) 
        printf("Serial number: %s\n", buf);
}

#ifdef ENABLE_TEST
void
ehci_test(u32 arg)
#else
void
main(u32 arg)
#endif
{
    IOSFd fd0;
    fd0 = IOS_Open("/dev/usb/ehc/0b95/7720", 0);
    __ctrlTransferTests(fd0);
    printf("ASIX error test exiting \n");
    IOS_DestroyThread(0, NULL);
    return;
}
