busses/usb: Move ::AddTo to be above the class constructors.
It is called before them (and is responsible for calling them), so having it in the middle of the file does not make a lot of sense. Already done for XHCI. Only one functional change -- removing the set_dprintf_enabled call. Drivers probably shouldn't spuriously re-enable that if it was specifically disabled.
This commit is contained in:
@@ -110,6 +110,93 @@ print_queue(ehci_qh *queueHead)
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
EHCI::AddTo(Stack *stack)
|
||||||
|
{
|
||||||
|
if (!sPCIModule) {
|
||||||
|
status_t status = get_module(B_PCI_MODULE_NAME,
|
||||||
|
(module_info **)&sPCIModule);
|
||||||
|
if (status != B_OK) {
|
||||||
|
TRACE_MODULE_ERROR("getting pci module failed! 0x%08" B_PRIx32
|
||||||
|
"\n", status);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE_MODULE("searching devices\n");
|
||||||
|
bool found = false;
|
||||||
|
pci_info *item = new(std::nothrow) pci_info;
|
||||||
|
if (!item) {
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to get the PCI x86 module as well so we can enable possible MSIs.
|
||||||
|
if (sPCIx86Module == NULL && get_module(B_PCI_X86_MODULE_NAME,
|
||||||
|
(module_info **)&sPCIx86Module) != B_OK) {
|
||||||
|
// If it isn't there, that's not critical though.
|
||||||
|
TRACE_MODULE_ERROR("failed to get pci x86 module\n");
|
||||||
|
sPCIx86Module = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32 i = 0; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) {
|
||||||
|
if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb
|
||||||
|
&& item->class_api == PCI_usb_ehci) {
|
||||||
|
if (item->u.h0.interrupt_line == 0
|
||||||
|
|| item->u.h0.interrupt_line == 0xFF) {
|
||||||
|
TRACE_MODULE_ERROR("found device with invalid IRQ - "
|
||||||
|
"check IRQ assignement\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE_MODULE("found device at IRQ %u\n", item->u.h0.interrupt_line);
|
||||||
|
EHCI *bus = new(std::nothrow) EHCI(item, stack);
|
||||||
|
if (!bus) {
|
||||||
|
delete item;
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
if (sPCIx86Module != NULL) {
|
||||||
|
sPCIx86Module = NULL;
|
||||||
|
put_module(B_PCI_X86_MODULE_NAME);
|
||||||
|
}
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bus->InitCheck() != B_OK) {
|
||||||
|
TRACE_MODULE_ERROR("bus failed init check\n");
|
||||||
|
delete bus;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the bus took it away
|
||||||
|
item = new(std::nothrow) pci_info;
|
||||||
|
|
||||||
|
if (bus->Start() != B_OK) {
|
||||||
|
delete bus;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
TRACE_MODULE_ERROR("no devices found\n");
|
||||||
|
delete item;
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
if (sPCIx86Module != NULL) {
|
||||||
|
sPCIx86Module = NULL;
|
||||||
|
put_module(B_PCI_X86_MODULE_NAME);
|
||||||
|
}
|
||||||
|
return ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete item;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EHCI::EHCI(pci_info *info, Stack *stack)
|
EHCI::EHCI(pci_info *info, Stack *stack)
|
||||||
: BusManager(stack),
|
: BusManager(stack),
|
||||||
fCapabilityRegisters(NULL),
|
fCapabilityRegisters(NULL),
|
||||||
@@ -1150,97 +1237,6 @@ EHCI::NotifyPipeChange(Pipe *pipe, usb_change change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
EHCI::AddTo(Stack *stack)
|
|
||||||
{
|
|
||||||
#ifdef TRACE_USB
|
|
||||||
set_dprintf_enabled(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!sPCIModule) {
|
|
||||||
status_t status = get_module(B_PCI_MODULE_NAME,
|
|
||||||
(module_info **)&sPCIModule);
|
|
||||||
if (status != B_OK) {
|
|
||||||
TRACE_MODULE_ERROR("getting pci module failed! 0x%08" B_PRIx32
|
|
||||||
"\n", status);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_MODULE("searching devices\n");
|
|
||||||
bool found = false;
|
|
||||||
pci_info *item = new(std::nothrow) pci_info;
|
|
||||||
if (!item) {
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to get the PCI x86 module as well so we can enable possible MSIs.
|
|
||||||
if (sPCIx86Module == NULL && get_module(B_PCI_X86_MODULE_NAME,
|
|
||||||
(module_info **)&sPCIx86Module) != B_OK) {
|
|
||||||
// If it isn't there, that's not critical though.
|
|
||||||
TRACE_MODULE_ERROR("failed to get pci x86 module\n");
|
|
||||||
sPCIx86Module = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 i = 0; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) {
|
|
||||||
if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb
|
|
||||||
&& item->class_api == PCI_usb_ehci) {
|
|
||||||
if (item->u.h0.interrupt_line == 0
|
|
||||||
|| item->u.h0.interrupt_line == 0xFF) {
|
|
||||||
TRACE_MODULE_ERROR("found device with invalid IRQ - "
|
|
||||||
"check IRQ assignement\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_MODULE("found device at IRQ %u\n", item->u.h0.interrupt_line);
|
|
||||||
EHCI *bus = new(std::nothrow) EHCI(item, stack);
|
|
||||||
if (!bus) {
|
|
||||||
delete item;
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
if (sPCIx86Module != NULL) {
|
|
||||||
sPCIx86Module = NULL;
|
|
||||||
put_module(B_PCI_X86_MODULE_NAME);
|
|
||||||
}
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bus->InitCheck() != B_OK) {
|
|
||||||
TRACE_MODULE_ERROR("bus failed init check\n");
|
|
||||||
delete bus;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the bus took it away
|
|
||||||
item = new(std::nothrow) pci_info;
|
|
||||||
|
|
||||||
if (bus->Start() != B_OK) {
|
|
||||||
delete bus;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
TRACE_MODULE_ERROR("no devices found\n");
|
|
||||||
delete item;
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
if (sPCIx86Module != NULL) {
|
|
||||||
sPCIx86Module = NULL;
|
|
||||||
put_module(B_PCI_X86_MODULE_NAME);
|
|
||||||
}
|
|
||||||
return ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete item;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
EHCI::GetPortStatus(uint8 index, usb_port_status *status)
|
EHCI::GetPortStatus(uint8 index, usb_port_status *status)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ typedef struct isochronous_transfer_data {
|
|||||||
|
|
||||||
class EHCI : public BusManager {
|
class EHCI : public BusManager {
|
||||||
public:
|
public:
|
||||||
|
static status_t AddTo(Stack *stack);
|
||||||
|
|
||||||
EHCI(pci_info *info, Stack *stack);
|
EHCI(pci_info *info, Stack *stack);
|
||||||
~EHCI();
|
~EHCI();
|
||||||
|
|
||||||
@@ -73,8 +75,6 @@ virtual status_t CancelQueuedTransfers(Pipe *pipe, bool force);
|
|||||||
virtual status_t NotifyPipeChange(Pipe *pipe,
|
virtual status_t NotifyPipeChange(Pipe *pipe,
|
||||||
usb_change change);
|
usb_change change);
|
||||||
|
|
||||||
static status_t AddTo(Stack *stack);
|
|
||||||
|
|
||||||
// Port operations for root hub
|
// Port operations for root hub
|
||||||
uint8 PortCount() { return fPortCount; }
|
uint8 PortCount() { return fPortCount; }
|
||||||
status_t GetPortStatus(uint8 index, usb_port_status *status);
|
status_t GetPortStatus(uint8 index, usb_port_status *status);
|
||||||
|
|||||||
@@ -57,6 +57,102 @@ module_info *modules[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// #pragma mark -
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
OHCI::AddTo(Stack *stack)
|
||||||
|
{
|
||||||
|
if (!sPCIModule) {
|
||||||
|
status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule);
|
||||||
|
if (status < B_OK) {
|
||||||
|
TRACE_MODULE_ERROR("getting pci module failed! 0x%08" B_PRIx32 "\n",
|
||||||
|
status);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE_MODULE("searching devices\n");
|
||||||
|
bool found = false;
|
||||||
|
pci_info *item = new(std::nothrow) pci_info;
|
||||||
|
if (!item) {
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to get the PCI x86 module as well so we can enable possible MSIs.
|
||||||
|
if (sPCIx86Module == NULL && get_module(B_PCI_X86_MODULE_NAME,
|
||||||
|
(module_info **)&sPCIx86Module) != B_OK) {
|
||||||
|
// If it isn't there, that's not critical though.
|
||||||
|
TRACE_MODULE_ERROR("failed to get pci x86 module\n");
|
||||||
|
sPCIx86Module = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32 i = 0 ; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) {
|
||||||
|
if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb
|
||||||
|
&& item->class_api == PCI_usb_ohci) {
|
||||||
|
if (item->u.h0.interrupt_line == 0
|
||||||
|
|| item->u.h0.interrupt_line == 0xFF) {
|
||||||
|
TRACE_MODULE_ERROR("found device with invalid IRQ -"
|
||||||
|
" check IRQ assignement\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE_MODULE("found device at IRQ %u\n",
|
||||||
|
item->u.h0.interrupt_line);
|
||||||
|
OHCI *bus = new(std::nothrow) OHCI(item, stack);
|
||||||
|
if (!bus) {
|
||||||
|
delete item;
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
|
||||||
|
if (sPCIx86Module != NULL) {
|
||||||
|
sPCIx86Module = NULL;
|
||||||
|
put_module(B_PCI_X86_MODULE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bus->InitCheck() < B_OK) {
|
||||||
|
TRACE_MODULE_ERROR("bus failed init check\n");
|
||||||
|
delete bus;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the bus took it away
|
||||||
|
item = new(std::nothrow) pci_info;
|
||||||
|
|
||||||
|
if (bus->Start() != B_OK) {
|
||||||
|
delete bus;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
TRACE_MODULE_ERROR("no devices found\n");
|
||||||
|
delete item;
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
|
||||||
|
if (sPCIx86Module != NULL) {
|
||||||
|
sPCIx86Module = NULL;
|
||||||
|
put_module(B_PCI_X86_MODULE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete item;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
OHCI::OHCI(pci_info *info, Stack *stack)
|
OHCI::OHCI(pci_info *info, Stack *stack)
|
||||||
: BusManager(stack),
|
: BusManager(stack),
|
||||||
fPCIInfo(info),
|
fPCIInfo(info),
|
||||||
@@ -579,101 +675,6 @@ OHCI::NotifyPipeChange(Pipe *pipe, usb_change change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
OHCI::AddTo(Stack *stack)
|
|
||||||
{
|
|
||||||
#ifdef TRACE_USB
|
|
||||||
set_dprintf_enabled(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!sPCIModule) {
|
|
||||||
status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule);
|
|
||||||
if (status < B_OK) {
|
|
||||||
TRACE_MODULE_ERROR("getting pci module failed! 0x%08" B_PRIx32 "\n",
|
|
||||||
status);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_MODULE("searching devices\n");
|
|
||||||
bool found = false;
|
|
||||||
pci_info *item = new(std::nothrow) pci_info;
|
|
||||||
if (!item) {
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to get the PCI x86 module as well so we can enable possible MSIs.
|
|
||||||
if (sPCIx86Module == NULL && get_module(B_PCI_X86_MODULE_NAME,
|
|
||||||
(module_info **)&sPCIx86Module) != B_OK) {
|
|
||||||
// If it isn't there, that's not critical though.
|
|
||||||
TRACE_MODULE_ERROR("failed to get pci x86 module\n");
|
|
||||||
sPCIx86Module = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint32 i = 0 ; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) {
|
|
||||||
if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb
|
|
||||||
&& item->class_api == PCI_usb_ohci) {
|
|
||||||
if (item->u.h0.interrupt_line == 0
|
|
||||||
|| item->u.h0.interrupt_line == 0xFF) {
|
|
||||||
TRACE_MODULE_ERROR("found device with invalid IRQ -"
|
|
||||||
" check IRQ assignement\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_MODULE("found device at IRQ %u\n",
|
|
||||||
item->u.h0.interrupt_line);
|
|
||||||
OHCI *bus = new(std::nothrow) OHCI(item, stack);
|
|
||||||
if (!bus) {
|
|
||||||
delete item;
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
|
|
||||||
if (sPCIx86Module != NULL) {
|
|
||||||
sPCIx86Module = NULL;
|
|
||||||
put_module(B_PCI_X86_MODULE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bus->InitCheck() < B_OK) {
|
|
||||||
TRACE_MODULE_ERROR("bus failed init check\n");
|
|
||||||
delete bus;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the bus took it away
|
|
||||||
item = new(std::nothrow) pci_info;
|
|
||||||
|
|
||||||
if (bus->Start() != B_OK) {
|
|
||||||
delete bus;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
TRACE_MODULE_ERROR("no devices found\n");
|
|
||||||
delete item;
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
|
|
||||||
if (sPCIx86Module != NULL) {
|
|
||||||
sPCIx86Module = NULL;
|
|
||||||
put_module(B_PCI_X86_MODULE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete item;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
OHCI::GetPortStatus(uint8 index, usb_port_status *status)
|
OHCI::GetPortStatus(uint8 index, usb_port_status *status)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ typedef struct transfer_data {
|
|||||||
|
|
||||||
class OHCI : public BusManager {
|
class OHCI : public BusManager {
|
||||||
public:
|
public:
|
||||||
|
static status_t AddTo(Stack *stack);
|
||||||
|
|
||||||
OHCI(pci_info *info, Stack *stack);
|
OHCI(pci_info *info, Stack *stack);
|
||||||
~OHCI();
|
~OHCI();
|
||||||
|
|
||||||
@@ -45,8 +47,6 @@ virtual status_t CancelQueuedTransfers(Pipe *pipe,
|
|||||||
virtual status_t NotifyPipeChange(Pipe *pipe,
|
virtual status_t NotifyPipeChange(Pipe *pipe,
|
||||||
usb_change change);
|
usb_change change);
|
||||||
|
|
||||||
static status_t AddTo(Stack *stack);
|
|
||||||
|
|
||||||
// Port operations
|
// Port operations
|
||||||
uint8 PortCount() { return fPortCount; };
|
uint8 PortCount() { return fPortCount; };
|
||||||
status_t GetPortStatus(uint8 index,
|
status_t GetPortStatus(uint8 index,
|
||||||
|
|||||||
@@ -298,6 +298,87 @@ Queue::PrintToStream()
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
UHCI::AddTo(Stack *stack)
|
||||||
|
{
|
||||||
|
if (!sPCIModule) {
|
||||||
|
status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule);
|
||||||
|
if (status < B_OK) {
|
||||||
|
TRACE_MODULE_ERROR("AddTo(): getting pci module failed! 0x%08"
|
||||||
|
B_PRIx32 "\n", status);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE_MODULE("AddTo(): setting up hardware\n");
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
pci_info *item = new(std::nothrow) pci_info;
|
||||||
|
if (!item) {
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to get the PCI x86 module as well so we can enable possible MSIs.
|
||||||
|
if (sPCIx86Module == NULL && get_module(B_PCI_X86_MODULE_NAME,
|
||||||
|
(module_info **)&sPCIx86Module) != B_OK) {
|
||||||
|
// If it isn't there, that's not critical though.
|
||||||
|
TRACE_MODULE_ERROR("failed to get pci x86 module\n");
|
||||||
|
sPCIx86Module = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32 i = 0; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) {
|
||||||
|
|
||||||
|
if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb
|
||||||
|
&& item->class_api == PCI_usb_uhci) {
|
||||||
|
if (item->u.h0.interrupt_line == 0
|
||||||
|
|| item->u.h0.interrupt_line == 0xFF) {
|
||||||
|
TRACE_MODULE_ERROR("AddTo(): found with invalid IRQ - check IRQ assignement\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE_MODULE("AddTo(): found at IRQ %u\n",
|
||||||
|
item->u.h0.interrupt_line);
|
||||||
|
UHCI *bus = new(std::nothrow) UHCI(item, stack);
|
||||||
|
if (!bus) {
|
||||||
|
delete item;
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bus->InitCheck() < B_OK) {
|
||||||
|
TRACE_MODULE_ERROR("AddTo(): InitCheck() failed 0x%08" B_PRIx32
|
||||||
|
"\n", bus->InitCheck());
|
||||||
|
delete bus;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the bus took it away
|
||||||
|
item = new(std::nothrow) pci_info;
|
||||||
|
|
||||||
|
if (bus->Start() != B_OK) {
|
||||||
|
delete bus;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
TRACE_MODULE_ERROR("no devices found\n");
|
||||||
|
delete item;
|
||||||
|
sPCIModule = NULL;
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
return ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete item;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
UHCI::UHCI(pci_info *info, Stack *stack)
|
UHCI::UHCI(pci_info *info, Stack *stack)
|
||||||
: BusManager(stack),
|
: BusManager(stack),
|
||||||
fPCIInfo(info),
|
fPCIInfo(info),
|
||||||
@@ -1859,91 +1940,6 @@ UHCI::Interrupt()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
UHCI::AddTo(Stack *stack)
|
|
||||||
{
|
|
||||||
#ifdef TRACE_USB
|
|
||||||
set_dprintf_enabled(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!sPCIModule) {
|
|
||||||
status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule);
|
|
||||||
if (status < B_OK) {
|
|
||||||
TRACE_MODULE_ERROR("AddTo(): getting pci module failed! 0x%08"
|
|
||||||
B_PRIx32 "\n", status);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_MODULE("AddTo(): setting up hardware\n");
|
|
||||||
|
|
||||||
bool found = false;
|
|
||||||
pci_info *item = new(std::nothrow) pci_info;
|
|
||||||
if (!item) {
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to get the PCI x86 module as well so we can enable possible MSIs.
|
|
||||||
if (sPCIx86Module == NULL && get_module(B_PCI_X86_MODULE_NAME,
|
|
||||||
(module_info **)&sPCIx86Module) != B_OK) {
|
|
||||||
// If it isn't there, that's not critical though.
|
|
||||||
TRACE_MODULE_ERROR("failed to get pci x86 module\n");
|
|
||||||
sPCIx86Module = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 i = 0; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) {
|
|
||||||
|
|
||||||
if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb
|
|
||||||
&& item->class_api == PCI_usb_uhci) {
|
|
||||||
if (item->u.h0.interrupt_line == 0
|
|
||||||
|| item->u.h0.interrupt_line == 0xFF) {
|
|
||||||
TRACE_MODULE_ERROR("AddTo(): found with invalid IRQ - check IRQ assignement\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_MODULE("AddTo(): found at IRQ %u\n",
|
|
||||||
item->u.h0.interrupt_line);
|
|
||||||
UHCI *bus = new(std::nothrow) UHCI(item, stack);
|
|
||||||
if (!bus) {
|
|
||||||
delete item;
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bus->InitCheck() < B_OK) {
|
|
||||||
TRACE_MODULE_ERROR("AddTo(): InitCheck() failed 0x%08" B_PRIx32
|
|
||||||
"\n", bus->InitCheck());
|
|
||||||
delete bus;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the bus took it away
|
|
||||||
item = new(std::nothrow) pci_info;
|
|
||||||
|
|
||||||
if (bus->Start() != B_OK) {
|
|
||||||
delete bus;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
TRACE_MODULE_ERROR("no devices found\n");
|
|
||||||
delete item;
|
|
||||||
sPCIModule = NULL;
|
|
||||||
put_module(B_PCI_MODULE_NAME);
|
|
||||||
return ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete item;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
UHCI::CreateFilledTransfer(Transfer *transfer, uhci_td **_firstDescriptor,
|
UHCI::CreateFilledTransfer(Transfer *transfer, uhci_td **_firstDescriptor,
|
||||||
uhci_qh **_transferQueue)
|
uhci_qh **_transferQueue)
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ typedef struct isochronous_transfer_data {
|
|||||||
|
|
||||||
class UHCI : public BusManager {
|
class UHCI : public BusManager {
|
||||||
public:
|
public:
|
||||||
|
static status_t AddTo(Stack *stack);
|
||||||
|
|
||||||
UHCI(pci_info *info, Stack *stack);
|
UHCI(pci_info *info, Stack *stack);
|
||||||
~UHCI();
|
~UHCI();
|
||||||
|
|
||||||
@@ -109,8 +111,6 @@ virtual status_t CancelQueuedTransfers(Pipe *pipe, bool force);
|
|||||||
status_t SubmitRequest(Transfer *transfer);
|
status_t SubmitRequest(Transfer *transfer);
|
||||||
status_t SubmitIsochronous(Transfer *transfer);
|
status_t SubmitIsochronous(Transfer *transfer);
|
||||||
|
|
||||||
static status_t AddTo(Stack *stack);
|
|
||||||
|
|
||||||
// Port operations
|
// Port operations
|
||||||
status_t GetPortStatus(uint8 index, usb_port_status *status);
|
status_t GetPortStatus(uint8 index, usb_port_status *status);
|
||||||
status_t SetPortFeature(uint8 index, uint16 feature);
|
status_t SetPortFeature(uint8 index, uint16 feature);
|
||||||
|
|||||||
Reference in New Issue
Block a user