Possible IPCI error or is it my code?

This forum is for general developer support questions.
Post Reply
Belxjander
Posts: 314
Joined: Mon May 14, 2012 10:26 pm
Location: 日本千葉県松戸市 / Matsudo City, Chiba, Japan
Contact:

Possible IPCI error or is it my code?

Post by Belxjander »

Within the following code...

Code: Select all

/*
**
*/
uint8 OpenUnit(struct DEVICE_CLASS *Base, struct USBIOReqHCD *iovec, uint32 unitn, uint32 flags)
{
	uint8 rc=0L;
	struct DEVICE_UNIT_CLASS *Unit=NULL;

	if(Base)
	{
		Unit=Base->DevUnit[unitn];
		if(Unit==NULL)
			Unit=Base->IExec->AllocVecTags(DEVICE_UNIT_SIZE,AVT_Type,MEMF_SHARED,AVT_ClearWithValue,0L,TAG_DONE,TAG_DONE);
	}
	if(Unit)
	{
		Base->DevUnit[unitn]=(APTR)Unit;
		Base->IExec->InitSemaphore((APTR)Unit);

		Unit->InterruptService.is_Node.ln_Name=(APTR)InterruptName;
		Unit->InterruptService.is_Data=(APTR)Unit;
		Unit->InterruptService.is_Code=(APTR)&InterruptExec;

		if(Base->IPCI)
		{
			Unit->ICard=NULL;
			Unit->ICard=(APTR)Base->IPCI->FindDeviceTags(
				FDT_Index,		unitn,
				FDT_Class,		0x000C0300,
				FDT_ClassMask,	0x000F0F00,
				TAG_DONE,		TAG_DONE);
		}
		if(Unit->ICard)
		{
			KDEBUG("XHCI::OpenUnit() ** Card Found!!! **\n");
			Unit->ICard->Lock(PCI_LOCK_EXCLUSIVE);
			Unit->MMIOspace=NULL;
			Unit->MMIOspace=(APTR)Unit->ICard->GetResourceRange(0);
			if(Unit->MMIOspace)
				KDEBUG("XHCI::OpenUnit() ** ResourceRange(0) == [%lx,%lx,%lx,%lx] **\n",
					Unit->MMIOspace->BaseAddress,
					Unit->MMIOspace->Physical,
					Unit->MMIOspace->Size,
					Unit->MMIOspace->Flags);
		}
	}
	return(rc);
};
I get the output of ...

Code: Select all

XHCI::OpenUnit() ** Card Found!!! **
XHCI::OpenUnit() ** ResourceRange(0) == [a0020000,a0020000,1000,2] ** << [ Base Address, Hard Address, Size, Type ]
XHCI::OpenDevice(0,0)
XHCI::USBHCGetAttrsA(4e210890,5767eeb8)
XHCI::USBHCInitRootHubA(0)
XHCI::USBHCGetAttrsA(4e210890,5767ee44)
XHCI::GetAttrsA( USBA_SignalsRunning )
XHCI::USBHCInitRootHubA(N)
However this is a different resource range value to what is shown in Ranger for exactly the same card *before* and *after* the skeleton driver attempts to bind to the hardware

Ranger displays a ResourceRange(0) == [ HardAddress=0xA0100000,size=8192, type= Memory ]

Am I doing anything particularly wrong here?
Belxjander
Posts: 314
Joined: Mon May 14, 2012 10:26 pm
Location: 日本千葉県松戸市 / Matsudo City, Chiba, Japan
Contact:

RESOLVED+QUESTION of IPCI->FindDeviceTags() -- Was IPCI error or my code?

Post by Belxjander »

Code: Select all

		if(Base->IPCI)
		{
			Unit->ICard=NULL;
			Unit->ICard=(APTR)Base->IPCI->FindDeviceTags(
//        FDT_CandidateList,  &Candidates,
        FDT_VendorID, 0x1912,
        FDT_DeviceID, 0x0014,
				FDT_Index,		unitn,
				TAG_DONE,		TAG_DONE);
		}
		if(Unit->ICard)
		{
			KDEBUG("XHCI::OpenUnit() ** Card Found!!! **\n");
			Unit->ICard->Lock(PCI_LOCK_EXCLUSIVE);
      MMIOspace=(APTR)Unit->ICard->GetResourceRange(0);
      Unit->HwBase=MMIOspace->BaseAddress;
      Unit->HwSize=MMIOspace->Size;
      Unit->HwFlags=MMIOspace->Flags;
      Unit->ICard->FreeResourceRange(0);
			KDEBUG("XHCI::OpenUnit() ** ResourceRange(0) == [%lx,%lx,%lx] **\n",
        Unit->HwBase, Unit->HwSize, Unit->HwFlags );
		}
replaces what was previously posted, with a caveat emptor...

for the previous output

Code: Select all

XHCI::OpenUnit() ** ResourceRange(0) == [a0020000,a0020000,1000,2] ** << [ Base Address, Hard Address, Size, Type ]
I determined that this was actually a BAR register **from*the*NEXT*pci*card*installed**...
Not

Code: Select all

XHCI::OpenUnit() ** ResourceRange(0) == [a0100000,2000,2] **
Which is the correct hardware I was attempting to address.

The difference was entirely down to the usage of "FindDeviceTags()" and explicit usage of VendorID+DeviceID tags instead of searching by class,
N.B. the actual card returned from the class search was NOT a USB3 controller but actually another network controller!.

When searching by Class of device, the FindDeviceTags() method appears to be providing the *next*card* on the expansion device list *after* the card actually wanted.

Is this confirmable for anyone else?
Post Reply