Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Oct 2000 17:02:25 -0700
From:      "Simon Block" <sblock@computer.org>
To:        <freebsd-questions@freebsd.org>
Subject:   PCI resources in driver
Message-ID:  <LOBBJIBIIEAFNGPIGIKNCEAFCIAA.sblock@computer.org>

next in thread | raw e-mail | index | archive | help
Hello FreeBSD,

I am using using the bus_alloc_resource() API (for a PCI interrupt and
memory region on FreeBSD 4.1 Stable) but we are still experiencing
situations where the resource is not allocated (bus_alloc_resource returns
NULL).

On my development machine I can map all memory regions (3 per card) but
cannot map one of the three interrupts (we have 3 PCI bridge chips per
card). On my clients machine they cannot even map all memory regions.

The bottom line is that I need to know what determines the limit on PCI
resource for interrupts (IRQ's) and memory regions. Typically an OS will
allow the PCI interrupts to be shared (based on the limitations of the
motherboard) and will allocate so much address space to the PCI bus for
memory mapping (we have no IO space). What are these limits for FreeBSD? How
do we determine them? How do we change them?

Any ideas will be greatly appreciated! :)

The following two code segments show how I map the memory and interrupts
respectively:
==========================================================================
/*
	temp_resc_id = 0x10;
	pDevice->mem = bus_alloc_resource( device,
					   SYS_RES_MEMORY,
					   &temp_resc_id,
					   0, ~0, 1,
					   RF_ACTIVE );
	pDevice->memid = temp_resc_id;
	if( !pDevice->mem )
	{
	  Ddbg(2, (device, "rln_attach: could not map memory\n"));
	  error = ENXIO;
	  goto failed_alloc_mem;
        }
==========================================================================
	temp_resc_id = 0;
	pDevice->irq = bus_alloc_resource( device,
				      SYS_RES_IRQ,
				      &temp_resc_id,
				      0ul, ~0ul, 1,
				      (RF_SHAREABLE | RF_ACTIVE) );
	pDevice->irqid = temp_resc_id;
	if( pDevice->irq == NULL )
	{
	  Ddbg(2, (device, "rln_attach: could not map interrupt (irqid: %d)\n",
		   pDevice->irqid));
	  error = ENXIO;
	  goto failed_alloc_irq;
	}

	Ddbg(4, (device, "rln_attach: interrupt mapped ok (irqid: %d).\n",
		 pDevice->irqid));
	error = bus_setup_intr( device,
				pDevice->irq,
				INTR_TYPE_TTY,
				rln_intr,
				pDevice,
				&pDevice->ih );
	if( error )
	{
	  Ddbg(2, (device, "rln_attach: could not setup irq, error: %d\n", error));
	  error = ENXIO;
	  goto failed_setup_irq;
	}
==========================================================================

PS. Do you know of any documentation for the bus_dma (bus_dmamem_alloc() and
bus_dmammap_load() API's). The NET BSD man pages are close but the API's are
different, with differing prototypes.


Regards,

Simon Block
Shula Consulting Incorporated
1-1430 Maple St
Vancouver, BC V6J 3R9
Phone: 604 736 8791
Fax:   604 736 8796
Cell:  604 841 8791
Email: sblock@computer.org



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?LOBBJIBIIEAFNGPIGIKNCEAFCIAA.sblock>