lkml.org 
[lkml]   [1998]   [Mar]   [15]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: PCI Driver for NIC, base address problem!!
DateSun, 15 Mar 1998 10:14:08 -0800
FromStephen Williams <>
Here is an example that maps a BAR. Note that the handling of offsets
is necessary because some smarter BIOSes may map memory to places
within a page.

	    pcibios_read_config_dword(bus, dfn, PCI_BASE_ADDRESS_0, &dw);

	    { unsigned long base = dw & PAGE_MASK;
	      unsigned long off = dw & (~0xf & (PAGE_SIZE-1));
	      xsp->amcc0 = off + (unsigned long)ioremap(base, AMCC_SIZE+off);
	    }
	    if (debug_flag&DBG_VERBIAGE)
		  printk("sinj%u: BAR[0] = 0x%08x [%p]\n", xsp->dev_num,
			 dw, xsp->amcc0);

Note that there is a #define ioremap vremap up higher. Also note that
I use readl and writel to access memory mapped registers. This is the
most portable way to do it, and looks neater then a bunch of casts.

I can provide the source to the entire driver if anyone is interested
(it is for a scanner simulator board we built) and I have other drivers
buried in uCR packages in:

	ftp://ftp.picturel.com/pub/source/ucr/ucr-1.0.tar.gz

-- 
Steve Williams                "The woods are lovely, dark and deep.
steve@icarus.com              But I have promises to keep,
steve@picturel.com            and lines to code before I sleep,
http://www.picturel.com       And lines to code before I sleep."



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 12:41    [from the cache]
©2003-2008