public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Driver access ito PCI card memory space question.
@ 2004-10-06 20:20 Alan Kilian
  2004-10-06 22:43 ` Roland Dreier
  2004-10-06 22:51 ` Richard B. Johnson
  0 siblings, 2 replies; 6+ messages in thread
From: Alan Kilian @ 2004-10-06 20:20 UTC (permalink / raw)
  To: linux-kernel



  Folks,

     I'm not sure how to access the memory spaces on my PCI card.

     I do 


     From /var/log/messages:

		SSE: Start of card attachment.
		SSE: Found a DeCypher card, interrupting on line 3
		SSE: Bar0 From 0xfeaff000 to 0xfeafffff F=0x200 MEMORY space
		SSE: Bar1 From 0xfeafc000 to 0xfeafdfff F=0x200 MEMORY space
		SSE: Bar2 From 0xfe000000 to 0xfe7fffff F=0x200 MEMORY space

     My driver detects the card, and asks about the memory areas.

     Then I do request_mem_area(0xfeaff000,4095, "SSE");

     Then I do a readl(0xfeaff100); and get this:

        Unable to handle kernel paging request at virtual address feaff100

     Any hints? Maybe these are byte-addresses, and I need to do:
     readl(0xfeaff100>>2);

     I'm just beginning this adventure, so please excuse the basic 
     questions.

                           -Alan

-- 
- Alan Kilian <kilian(at)timelogic.com> 
Director of Bioinformatics, TimeLogic Corporation 763-449-7622

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Driver access ito PCI card memory space question.
  2004-10-06 20:20 Driver access ito PCI card memory space question Alan Kilian
@ 2004-10-06 22:43 ` Roland Dreier
  2004-10-08 16:59   ` Erik Mouw
  2004-10-06 22:51 ` Richard B. Johnson
  1 sibling, 1 reply; 6+ messages in thread
From: Roland Dreier @ 2004-10-06 22:43 UTC (permalink / raw)
  To: Alan Kilian; +Cc: linux-kernel

    Alan>      Then I do request_mem_area(0xfeaff000,4095, "SSE");

    Alan>      Then I do a readl(0xfeaff100); and get this:

    Alan>         Unable to handle kernel paging request at virtual address feaff100

You can't blindly access an address from your device's BARs; on many
architectures PCI access needs setting up and/or addresses need
munging before use.  The API you need is ioremap().

You need to do something like:

	void __iomem *mybase = ioremap(pci_resource_start(my_pdev, 0), 4095);
	u32 value = readl(mybase + 0x100);

(Delete the __iomem annotation for kernels before 2.6.9).

The "Linux Device Drivers" online book, available at
<http://www.xml.com/ldd/chapter/book/> will probably be pretty
helpful.  In fact if you're serious about writing drivers, you should
buy a dead-tree copy.

 - Roland

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Driver access ito PCI card memory space question.
  2004-10-06 20:20 Driver access ito PCI card memory space question Alan Kilian
  2004-10-06 22:43 ` Roland Dreier
@ 2004-10-06 22:51 ` Richard B. Johnson
  1 sibling, 0 replies; 6+ messages in thread
From: Richard B. Johnson @ 2004-10-06 22:51 UTC (permalink / raw)
  To: Alan Kilian; +Cc: linux-kernel

On Wed, 6 Oct 2004, Alan Kilian wrote:

>
>
>  Folks,
>
>     I'm not sure how to access the memory spaces on my PCI card.
>
>     I do
>
>     From /var/log/messages:
>
> 		SSE: Start of card attachment.
> 		SSE: Found a DeCypher card, interrupting on line 3
> 		SSE: Bar0 From 0xfeaff000 to 0xfeafffff F=0x200 MEMORY space
> 		SSE: Bar1 From 0xfeafc000 to 0xfeafdfff F=0x200 MEMORY space
> 		SSE: Bar2 From 0xfe000000 to 0xfe7fffff F=0x200 MEMORY space
>
>     My driver detects the card, and asks about the memory areas.
>

Please look at a driver module that uses PCI. There are plenty in
the kernel.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.5-1.358-noreg on an i686 machine (5537.79 BogoMips).
             Note 96.31% of all statistics are fiction.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Driver access ito PCI card memory space question.
  2004-10-06 22:43 ` Roland Dreier
@ 2004-10-08 16:59   ` Erik Mouw
  0 siblings, 0 replies; 6+ messages in thread
From: Erik Mouw @ 2004-10-08 16:59 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Alan Kilian, linux-kernel

On Wed, Oct 06, 2004 at 03:43:13PM -0700, Roland Dreier wrote:
> The "Linux Device Drivers" online book, available at
> <http://www.xml.com/ldd/chapter/book/> will probably be pretty
> helpful.  In fact if you're serious about writing drivers, you should
> buy a dead-tree copy.

Note that LDD is focused on 2.4, but LWN has a nice series of articles
that describes how to port 2.4 drivers to 2.6:

  http://lwn.net/Articles/driver-porting/

LDD should give you the basics, the articles on lwn.net should tell you
what's different.


Erik

-- 
+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Driver access ito PCI card memory space question.
@ 2004-10-14 20:47 Alan Kilian
  2004-10-14 21:22 ` Jesper Juhl
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Kilian @ 2004-10-14 20:47 UTC (permalink / raw)
  To: linux-kernel



  I want to thank everyone for helping me get my Solaris driver 
  running under Linux.

  It's taken three days, but it appears to be working, it passes all
  my hardware diagnostics and I'm ready to hook it up to the
  application layer. I think going from knowing NOTHING about the
  Linux kernel to a working PCI bus driver in three days is not too 
  shabby.
  
  The Rubini and Corbet book helped a LOT, but it helped more after
  I knew what I was doing a bit.

  I suspect I'll be back when I start implementing the DMA part.

  Hey! what RPM do I install so I can get man pages for kernel
  functions? A man page for readl() sure would have been useful.

  Thanks a million folks!!!

                            -Alan

-- 
- Alan Kilian <kilian(at)timelogic.com> 
Director of Bioinformatics, TimeLogic Corporation 763-449-7622

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Driver access ito PCI card memory space question.
  2004-10-14 20:47 Alan Kilian
@ 2004-10-14 21:22 ` Jesper Juhl
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Juhl @ 2004-10-14 21:22 UTC (permalink / raw)
  To: kilian; +Cc: linux-kernel

On Thu, 14 Oct 2004 kilian@bobodyne.com wrote:

> 
>   Hey! what RPM do I install so I can get man pages for kernel
>   functions? A man page for readl() sure would have been useful.
> 
I don't know about any RPM for that (using a non-rpm based distribution), 
but what I do personally is use "make mandocs" and "make installmandocs".

If you run "make help" in the kernel source tree you'll see this bit:

[...]
Documentation targets:
  Linux kernel internal documentation in different formats:
  sgmldocs (SGML), psdocs (Postscript), pdfdocs (PDF)
  htmldocs (HTML), mandocs (man pages, use installmandocs to install)
[...]

As you see you can get docs in various forms.

Hope that helps.

--
Jesper Juhl



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-10-14 21:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-06 20:20 Driver access ito PCI card memory space question Alan Kilian
2004-10-06 22:43 ` Roland Dreier
2004-10-08 16:59   ` Erik Mouw
2004-10-06 22:51 ` Richard B. Johnson
  -- strict thread matches above, loose matches on Subject: below --
2004-10-14 20:47 Alan Kilian
2004-10-14 21:22 ` Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox