NetBSD-Ports archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Porting USB stack -- questions on ioconf.c



I am porting the USB stack of NetBSD to a different OS/platform and have some 
questions regarding the content of ioconf.c.  I am expecting to support mass 
storage, keyboard, mouse (generic HID).  I have the stack up and running except 
for being able to unplug and re-plug devices.

For example, when I plug in a keyboard, I get:

Found uhidev0 and uhub0  port 2 configuration 1 interface 0
Dell Dell QuietKey Keyboard, rev 1.10/1.55, addr 2, iclass 3/1
Found uhid0 at uhidev0
: input=8, output=1,feature=0

Then when I un-plug it:

detached
detached
uhidev0: at uhub0 port 2 (addr 2) disconnected

Then when I plug it back in:

Found ugen0 at uhub0  port 2
Dell Dell QuietKey Keyboard, rev 1.10/1.55, addr 2, iclass 3/1

I had to hack together ioconf.c to get this far...so I'm *sure* my ioconf.c is 
a total mess.  However I've been unable to find anything resembling 
useful-including searching through the code for "config"-to help figure out 
what I need to have in ioconf.c.  

Hopefully someone out there can give me some pointers as to how the tables in 
ioconf.c relate and how they should be set up differently than what I've got...?

Here's my ioconf.c:

#include <deos_stuff.h>

#define _KERNEL

#include <sys/param.h>
#include <sys/conf.h>
#include <sys/device.h>

const struct cfiattrdata ohci_attrs = { "usbus", NULL };
const struct cfiattrdata * const ohci_attr_ptrs[] = {&ohci_attrs, 0};
CFDRIVER_DECL(ohci, DV_DULL, ohci_attr_ptrs);

const struct cfiattrdata ehci_attrs = { "usbus", NULL };
const struct cfiattrdata * const ehci_attr_ptrs[] = {&ehci_attrs, 0};
CFDRIVER_DECL(ehci, DV_DULL, ehci_attr_ptrs);

const struct cfiattrdata uhci_attrs = { "usbus", NULL };
const struct cfiattrdata * const uhci_attr_ptrs[] = {&uhci_attrs, 0};
CFDRIVER_DECL(uhci, DV_DULL, uhci_attr_ptrs);

static const struct cfiattrdata usbififcf_iattrdata = {
  "usbifif", 6,
  {
    {"port", "-1", -1},
    {"configuration", "-1", -1},
    {"interface", "-1", -1},
    {"vendor", "-1", -1},
    {"product", "-1", -1},
    {"release", "-1", -1},
  }
};
static const struct cfiattrdata usbdevifcf_iattrdata = {
  "usbdevif", 6,
  {
    {"port", "-1", -1},
    {"configuration", "-1", -1},
    {"interface", "-1", -1},
    {"vendor", "-1", -1},
    {"product", "-1", -1},
    {"release", "-1", -1},
  }
};
static const struct cfiattrdata usbroothubifcf_iattrdata = {
  "usbroothubif", 0, {
    { NULL, NULL, 0 },
  }
};

static const struct cfiattrdata * const uhub_attrs[] = { &usbififcf_iattrdata, 
&usbdevifcf_iattrdata, NULL };
CFDRIVER_DECL(uhub, DV_DULL, uhub_attrs);

static const struct cfiattrdata * const usb_attrs[] = { 
&usbroothubifcf_iattrdata, NULL };
CFDRIVER_DECL(usb, DV_DULL, usb_attrs);

static const struct cfiattrdata uhidbuscf_iattrdata = {
                "uhidbus", 1,
                {
                                { "reportid", "-1", -1 },
                }
};

static const struct cfiattrdata * const uhidev_attrs[] = { 
&uhidbuscf_iattrdata, NULL };
CFDRIVER_DECL(uhidev, DV_DULL, uhidev_attrs);

CFDRIVER_DECL(uhid, DV_DULL, NULL);

CFDRIVER_DECL(ukbd, DV_DULL, NULL);

CFDRIVER_DECL(ums, DV_DULL, NULL);

CFDRIVER_DECL(ugen, DV_DULL, NULL);

struct cfdriver * const cfdriver_list_initial[] = {
      &ohci_cd,
        &usb_cd,
        &uhub_cd,
        &uhidev_cd,
                                &uhid_cd,
                                &ukbd_cd,
                                &ums_cd,
        &ugen_cd,
        &ehci_cd,
        &uhci_cd,
        NULL
};

extern struct cfattach ohci_pci_ca;
extern struct cfattach ehci_pci_ca;
extern struct cfattach uhci_pci_ca;
extern struct cfattach usb_ca;
extern struct cfattach uhub_ca;
extern struct cfattach uroothub_ca;
extern struct cfattach ugen_ca;
extern struct cfattach ukbd_ca;
extern struct cfattach ums_ca;
extern struct cfattach uhid_ca;
extern struct cfattach uhidev_ca;

static struct cfattach * const ohci_cfattachinit[] = {
        &ohci_pci_ca, NULL
};
static struct cfattach * const ehci_cfattachinit[] = {
        &ehci_pci_ca, NULL
};

static struct cfattach * const uhci_cfattachinit[] = {
        &uhci_pci_ca, NULL
};

static struct cfattach * const usb_cfattachinit[] = {
        &usb_ca, NULL
};
static struct cfattach * const uhub_cfattachinit[] = {
  &uroothub_ca, &uhub_ca, NULL
};
static struct cfattach * const uhidev_cfattachinit[] = {
        &uhidev_ca, NULL
};
static struct cfattach * const uhid_cfattachinit[] = {
        &uhid_ca, NULL
};
static struct cfattach * const ukbd_cfattachinit[] = {
        &ukbd_ca, NULL
};
static struct cfattach * const ums_cfattachinit[] = {
        &ums_ca, NULL
};
static struct cfattach * const ugen_cfattachinit[] = {
        &ugen_ca, NULL
};

const struct cfattachinit cfattachinit[] = {
        { "ohci", ohci_cfattachinit },
        { "ehci", ehci_cfattachinit },
        { "uhci", uhci_cfattachinit },
        { "usb", usb_cfattachinit },
        { "uhub", uhub_cfattachinit },
        { "ugen", ugen_cfattachinit },
        { "ukbd", ukbd_cfattachinit },
        { "ums", ums_cfattachinit },
        { "uhid", uhid_cfattachinit },
                                { "uhidev", uhidev_cfattachinit },
        { NULL, NULL }
};

// DI:  I don't have a clue what these are used for, but the following
// array is completely bogus for this config.  It came from an old NetBSD
// ioconf.c file.
/* locators */
static int loc[259] = {
        0x378, 0, -1, 0, 7, -1, -1, -1, 0, -1,
        0, -1, -1, -1, 0x300, 0, -1, 0, 10, -1,
        -1, 0x280, 0, -1, 0, 9, -1, -1, 0x300, 0,
        -1, 0, 10, -1, -1, 0x3f8, 0, -1, 0, 4,
        -1, -1, 0x2f8, 0, -1, 0, 3, -1, -1, 0x3e8,
        0, -1, 0, 5, -1, -1, -1, 0, -1, 0,
        -1, -1, -1, 0x1f0, 0, -1, 0, 14, -1, -1,
        0x170, 0, -1, 0, 15, -1, -1, 0x280, 0, 0xd0000,
        0, 9, -1, -1, 0x300, 0, 0xcc000, 0, 10, -1,
        -1, 0x2a0, 0, -1, 0, -1, -1, -1, 0x2a0, 0,
        -1, 0, -1, -1, -1, -1, 0, -1, 0, -1,
        -1, -1, 0x250, 0, 0xd8000, 0, 9, -1, -1, 0x280,
        0, -1, 0, 9, -1, -1, 0x300, 0, -1, 0,
        9, -1, -1, 0x360, 0, -1, 0, -1, -1, -1,
        0x320, 0, -1, 0, 9, 7, -1, 0x320, 0, -1,
        0, 10, 7, -1, 0x360, 0, 0xd0000, 0, 7, -1,
        -1, 0x360, 0, 0xd0000, 0, 7, -1, -1, 0x300, 0,
        -1, 0, 10, -1, -1, -1, 0, -1, 0, -1,
        -1, -1, 0xf0, 0, -1, 0, 13, -1, -1, 0x3f0,
        0, -1, 0, 6, 2, -1, 0x3e0, 0, 0xd0000, 0x4000,
        -1, -1, -1, 0x3e2, 0, 0xd4000, 0x4000, -1, -1, -1,
        0x320, 0, -1, 0, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, 1, -1, 1, -1, -1, -1, 1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,
};

static const struct cfparent pspec17 = {
        "pci", "pci", DVUNIT_ANY
};
static const struct cfparent pspec18 = {
        "usbus", "ohci", DVUNIT_ANY
};
static const struct cfparent pspec53 = {
        "usbus", "ehci", DVUNIT_ANY
};
static const struct cfparent pspec55 = {
        "usbus", "uhci", DVUNIT_ANY
};
static const struct cfparent pspec19 = {
        "usb", "usb", DVUNIT_ANY
};
static const struct cfparent pspec20 = {
        "uhub", "uhub", DVUNIT_ANY
};

static const struct cfparent pspec78 = {
  "usbroothubif", "usb", DVUNIT_ANY
};

static const struct cfparent pspec48 = {
  "ukbd", "uhid", DVUNIT_ANY
};
static const struct cfparent pspec46 = {
  "ums", "uhid", DVUNIT_ANY
};
static const struct cfparent pspec49 = {
  "uhidbus", "uhidev", DVUNIT_ANY
};

static const struct cfparent pspec79 = {
  "usbdevif", "uhub", DVUNIT_ANY
};
static const struct cfparent pspec80 = {
  "usbifif", "uhub", DVUNIT_ANY
};

#define NORM FSTATE_NOTFOUND
#define STAR FSTATE_STAR

const char * const nullcf_locnames[] = {NULL};
const char * const uhubcf_locnames[] = { "port", "configuration", "interface", 
"vendor", "product", "release", NULL};
const char * const pcicf_locnames[] = { "dev", "function", NULL};

struct cfdata cfdata[] = {
    /* driver           attachment    unit state loc   flags pspec       
locnames */

    { "uhci",           "uhci_pci",   0, STAR, loc+249, 0, &pspec55},
    { "ehci",           "ehci_pci",   0, STAR, loc+249, 0, &pspec53},

/* 26: ohci* at pci? dev -1 function -1 */
    { "ohci",           "ohci_pci",   0, STAR, loc+249, 0, &pspec18},

/*455: uhub* at uhub? port -1 configuration -1 interface -1 vendor -1 product 
-1 release -1 */
    {"uhub",            "uhub",       0, STAR, loc+249, 0, &pspec79},
    
/* 55: usb* at uhci? */
    { "usb",            "usb",        0, STAR, loc,     0, &pspec55},

/* 55: usb* at ohci? */
    { "usb",            "usb",        0, STAR, loc,     0, &pspec18},

/* 55: usb* at ehci? */
    { "usb",            "usb",        0, STAR, loc,     0, &pspec53},

/*454: uhub* at usb? */
    {"uhub",            "uroothub",   0, STAR, loc,     0, &pspec78},

/* 58: uhidev* at uhub? port -1 configuration -1 interface -1 vendor -1 product
-1 release -1 */
    { "uhidev",         "uhidev",     0, STAR, loc+223, 0, &pspec80},
/* 59: ugen* at uhub? port -1 configuration -1 interface -1 vendor -1 product
-1 release -1 */
    { "ugen",           "ugen",       0, STAR, loc+223, 0, &pspec79},
    { "uhid",           "uhid",       0, STAR, loc+223, 0, &pspec49},
    {0}
};

const short cfroots[] = {
        0 /* DI: ohci is our mainbus */,
        1,
        2,
        -1
};



Home | Main Index | Thread Index | Old Index