From f3de71483d65acbbb315771e7ba192d046b50443 Mon Sep 17 00:00:00 2001 From: DizzyOfCRN Date: Sat, 9 Aug 2014 17:04:19 +0000 Subject: [PATCH] Enumerator fills host controller list git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49282 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/usb/pciusbhc/xhci/pcixhci_device.h | 15 ++++ rom/usb/pciusbhc/xhci/pcixhci_discover.c | 145 ++++++++++++++++++++----------- 2 files changed, 111 insertions(+), 49 deletions(-) diff --git a/rom/usb/pciusbhc/xhci/pcixhci_device.h b/rom/usb/pciusbhc/xhci/pcixhci_device.h index 958df7602a..f3127832e8 100644 --- a/rom/usb/pciusbhc/xhci/pcixhci_device.h +++ b/rom/usb/pciusbhc/xhci/pcixhci_device.h @@ -85,10 +85,25 @@ struct PCIXHCIUnit { }; +struct PCIXHCIHost { + struct Node node; + char name[256]; + + OOP_Object *pcidevice; + OOP_Object *pcidriver; + + IPTR bus; + IPTR dev; + IPTR sub; + IPTR intline; + +}; + struct PCIXHCIBase { struct Library library; struct List unit_list; + struct List host_list; ULONG unit_count; OOP_Object *pci; diff --git a/rom/usb/pciusbhc/xhci/pcixhci_discover.c b/rom/usb/pciusbhc/xhci/pcixhci_discover.c index aa0abae30f..108e8cfb82 100644 --- a/rom/usb/pciusbhc/xhci/pcixhci_discover.c +++ b/rom/usb/pciusbhc/xhci/pcixhci_discover.c @@ -36,20 +36,43 @@ #include LC_LIBDEFS_FILE +/* + Keep this one short and simple +*/ static AROS_UFH3(void, GM_UNIQUENAME(Enumerator), AROS_UFHA(struct Hook *, hook, A0), AROS_UFHA(OOP_Object *, pciDevice, A2), AROS_UFHA(APTR, message, A1)) { AROS_USERFUNC_INIT LIBBASETYPE *LIBBASE = (LIBBASETYPE *)hook->h_Data; - mybug(-1, ("[PCIXHCI] Enumerator: Found PCI XHCI host controller\n\n")); + mybug(-1, ("\n[PCIXHCI] Enumerator: Found PCI XHCI host controller\n")); + + struct PCIXHCIHost *host; + + host = AllocVec(sizeof(struct PCIXHCIHost), MEMF_ANY|MEMF_CLEAR); + if(host != NULL) { + host->node.ln_Type = NT_USER; + host->node.ln_Name = (STRPTR)&host->name; - LIBBASE->unit_count = 0; + host->pcidevice = pciDevice; + + OOP_GetAttr(pciDevice, aHidd_PCIDevice_Bus, &host->bus); + OOP_GetAttr(pciDevice, aHidd_PCIDevice_Dev, &host->dev); + OOP_GetAttr(pciDevice, aHidd_PCIDevice_Sub, &host->sub); + OOP_GetAttr(pciDevice, aHidd_PCIDevice_INTLine, &host->intline); + OOP_GetAttr(pciDevice, aHidd_PCIDevice_Driver, (IPTR *)&host->pcidriver); + AddTail(&LIBBASE->host_list, (struct Node *)host); + } else { + mybug(-1, ("\n[PCIXHCI] Enumerator: Failed to allocate host controller structure!\n\n")); + } AROS_USERFUNC_EXIT } BOOL PCIXHCI_Discover(LIBBASETYPEPTR LIBBASE) { + mybug(0, ("[PCIXHCI] PCIXHCI_Discover: Entering function\n")); + NEWLIST(&LIBBASE->unit_list); + NEWLIST(&LIBBASE->host_list); if ( (LIBBASE->pci = OOP_NewObject(NULL, (STRPTR)CLID_Hidd_PCI, NULL)) ) { struct TagItem tags[] = { @@ -73,65 +96,89 @@ BOOL PCIXHCI_Discover(LIBBASETYPEPTR LIBBASE) { OOP_ObtainAttrBases(attrbases); HIDD_PCI_EnumDevices(LIBBASE->pci, &FindHook, (struct TagItem *)&tags); - struct PCIXHCIUnit *unit; - ULONG i; + struct PCIXHCIHost *host; + CONST_STRPTR owner; + + ForeachNode(&LIBBASE->host_list, host) { + mybug(-1, ("[PCIXHCI] *pcidevice = %p\n", host->pcidevice)); + mybug(-1, ("[PCIXHCI] *pcidriver = %p\n", host->pcidriver)); + mybug(-1, ("[PCIXHCI] bus = %x\n", host->bus)); + mybug(-1, ("[PCIXHCI] dev = %x\n", host->dev)); + mybug(-1, ("[PCIXHCI] sub = %x\n", host->sub)); + mybug(-1, ("[PCIXHCI] intline = %d\n\n", host->intline)); + + /* Try to obtain the host controller */ + owner = HIDD_PCIDevice_Obtain(host->pcidevice, LIBBASE->library.lib_Node.ln_Name); + if (owner) { + mybug(-1, ("[PCIXHCI] Host controller already reserved for %s\n", owner)); + REMOVE(host); + } + } - LIBBASE->unit_count = 0; + if(!IsListEmpty(&LIBBASE->host_list)) { - for (i=0; iunit_count, 0x210); - if(unit == NULL) { - mybug(-1, ("[PCIXHCI] Init: Failed to create new unit!\n")); + struct PCIXHCIUnit *unit; + ULONG i; - /* - Free previous units if any exists - */ + LIBBASE->unit_count = 0; - ForeachNode(&LIBBASE->unit_list, unit) { - mybug(-1,("[PCIXHCI] Init: Removing unit structure %s at %p\n", unit->node.ln_Name, unit)); - REMOVE(unit); - FreeVec(unit); - } - return FALSE; - } else { - AddTail(&LIBBASE->unit_list,(struct Node *)unit); - LIBBASE->unit_count++; - } - #endif + for (i=0; iunit_count, 0x311); - if(unit == NULL) { - mybug(-1, ("[PCIXHCI] Init: Failed to create new unit!\n")); + #ifdef PCIXHCI_NUMPORTS20 + unit = PCIXHCI_AddNewUnit(LIBBASE->unit_count, 0x210); + if(unit == NULL) { + mybug(-1, ("[PCIXHCI] Init: Failed to create new unit!\n")); - /* - Free previous units if any exists - */ + /* + Free previous units if any exists + */ + + ForeachNode(&LIBBASE->unit_list, unit) { + mybug(-1,("[PCIXHCI] Init: Removing unit structure %s at %p\n", unit->node.ln_Name, unit)); + REMOVE(unit); + FreeVec(unit); + } + return FALSE; + } else { + AddTail(&LIBBASE->unit_list,(struct Node *)unit); + LIBBASE->unit_count++; + } + #endif + + unit = PCIXHCI_AddNewUnit(LIBBASE->unit_count, 0x311); + if(unit == NULL) { + mybug(-1, ("[PCIXHCI] Init: Failed to create new unit!\n")); + + /* + Free previous units if any exists + */ + + ForeachNode(&LIBBASE->unit_list, unit) { + mybug(-1,("[PCIXHCI] Init: Removing unit structure %s at %p\n", unit->node.ln_Name, unit)); + REMOVE(unit); + FreeVec(unit); + } + return FALSE; + } else { + AddTail(&LIBBASE->unit_list,(struct Node *)unit); + LIBBASE->unit_count++; + } - ForeachNode(&LIBBASE->unit_list, unit) { - mybug(-1,("[PCIXHCI] Init: Removing unit structure %s at %p\n", unit->node.ln_Name, unit)); - REMOVE(unit); - FreeVec(unit); } - return FALSE; - } else { - AddTail(&LIBBASE->unit_list,(struct Node *)unit); - LIBBASE->unit_count++; - } - } + D(ForeachNode(&LIBBASE->unit_list, unit) { + mybug(-1, ("[PCIXHCI] Init: Created unit %d at %p %s\n", unit->number, unit, unit->name)); + struct PCIXHCIPort *port; + ForeachNode(&unit->roothub.port_list, port) { + mybug(-1, (" port %d at %p %s\n", port->number, port, port->name)); + } + mybug(-1,("\n")); + }); - D(ForeachNode(&LIBBASE->unit_list, unit) { - mybug(-1, ("[PCIXHCI] Init: Created unit %d at %p %s\n", unit->number, unit, unit->name)); - struct PCIXHCIPort *port; - ForeachNode(&unit->roothub.port_list, port) { - mybug(-1, (" port %d at %p %s\n", port->number, port, port->name)); + return TRUE; } - mybug(-1,("\n")); - }); - - return TRUE; } return FALSE; -- 2.11.4.GIT