Jump to content
3 posts in this topic

Recommended Posts

With a Windows platform we have the following code:

 

PCM_PARTIAL_RESOURCE_DESCRIPTOR resource;

PHYSICAL_ADDRESS PhyAddress;

PVOID pDspRegs;

dWord dwIrq;

 

 

resource=ResourceList->FindUntranslatedInterrupt(0);

dwIrq=Resource->u.Interrupt.Level;

 

 

resource=ResourceList->FindTranslatedMemory(0);

PhyAddress=resource->u.Memory.Start;

 

m_pDspRegs=(PDWORD) MmMapIOSpace(PhysAddr,DSP_REG_WINDOW,MmNonCached);

 

 

This code is for Windows and recovers the Interrupt for a PCI card and its on board memory page(0)

 

How can we achieve the same on OS X, I think I have worked out the shared memory call, I can see the interrupt values in IORegExplorer but there iare no comments in the IOReg headers to point me in the right direction regarding the interrupt value.

 

Thanks in Advance

Mark

Link to comment
https://www.insanelymac.com/forum/topic/139756-driver-development-question/
Share on other sites

With a Windows platform we have the following code:

 

PCM_PARTIAL_RESOURCE_DESCRIPTOR resource;

PHYSICAL_ADDRESS PhyAddress;

PVOID pDspRegs;

dWord dwIrq;

 

 

resource=ResourceList->FindUntranslatedInterrupt(0);

dwIrq=Resource->u.Interrupt.Level;

 

 

resource=ResourceList->FindTranslatedMemory(0);

PhyAddress=resource->u.Memory.Start;

 

m_pDspRegs=(PDWORD) MmMapIOSpace(PhysAddr,DSP_REG_WINDOW,MmNonCached);

 

 

This code is for Windows and recovers the Interrupt for a PCI card and its on board memory page(0)

 

How can we achieve the same on OS X, I think I have worked out the shared memory call, I can see the interrupt values in IORegExplorer but there iare no comments in the IOReg headers to point me in the right direction regarding the interrupt value.

 

Thanks in Advance

Mark

Looking into my Marvell_sources

	//save a reference to our provider
if ( (pciNub = OSDynamicCast(IOPCIDevice, provider)) == 0) {
	ERROR_LOG("%s ERR: pciNub == 0\n", getName());
	goto fail;
}
//get the virtual address mapping of CSR registers located at Base Address Range 0 (0x10).
//map hardware registers
csrMap = pciNub->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress0, kIOMapInhibitCache);
  if (csrMap == 0) {
	ERROR_LOG("%s ERR: map hardware registers failed\n", getName());
	goto fail;
}
csrMap->retain();
csrBase = (volatile void*) csrMap->getVirtualAddress();

  //get a reference to our own workloop
IOWorkLoop * wl = getWorkLoop();
if (!wl) {
	ERROR_LOG("%s ERR: getWorkLoop failed\n", getName());
	return false;
}

// Create an interrupt event source to handle hardware interrupts.
fInterruptSource = IOInterruptEventSource::interruptEventSource(this,
			   OSMemberFunctionCast(IOInterruptEventSource::Action, this, &Marvell::interruptOccurred), pciNub, 0);
if ( !fInterruptSource || (wl->addEventSource(fInterruptSource) != kIOReturnSuccess) ) {
	ERROR_LOG("%s ERR: create and add interrupt event source failed\n", getName());
	return false;
}

// This is important. If the interrupt line is shared with other devices,
// then the interrupt vector will be enabled only if all corresponding
// interrupt event sources are enabled. To avoid masking interrupts for
// other devices that are sharing the interrupt line, the event source
// is enabled immediately. Hardware interrupt sources remain disabled.
fInterruptSource->enable();

PCI information

/* config registers for header type 0 devices */

#define PCIR_BARS	0x10
#define	PCIR_BAR(x)	(PCIR_BARS + (x) * 4)
#define PCI_RID2BAR(rid) (((rid)-PCIR_BARS)/4)
#define PCIR_CIS	0x28
#define PCIR_SUBVEND_0	0x2c
#define PCIR_SUBDEV_0	0x2e
#define PCIR_BIOS	0x30
#define	PCIR_CAP_PTR	0x34
#define PCIR_INTLINE	0x3c
#define PCIR_INTPIN	0x3d
#define PCIR_MINGNT	0x3e
#define PCIR_MAXLAT	0x3f

But MacOSX does not use explicitly IRQ number (INTLINE). All interrupts always shared.

 

Other question?

×
×
  • Create New...