Re: /dev/mem contains physical memory addresses?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2006-07-07 at 11:28 +0530, Daniel Rodrick wrote:
> > > How about peripheral memory mapped to some addresses? Assuming I have
> > > a PCI device and a on board flash PROM, would I be able to see them in
> > > /proc/(k)mem ? I feel not. Am I correct?
> >
> > /dev/mem yes
> >
> > HOWEVER, there is a much nicer way to mmap a PCI device's resources, and
> > that is sysfs.
> > /sys/bus/pci/devices/0000:00:02.0/resource0
> > for example is the first resource of a PCI device on my system.
> > No need to muck about with the dangerous /dev/mem; this one is at least
> > well defined and portable across systems, including virtualization etc
> > etc
> 
> So you mean to say that if I have a device whose registers are are
> memory mapped to say physical addresses "0x20020000 - 0x20020010".
> Then the file /sys/bus/pci/devices/0000:00:02.0/resource0 will contain
> thsi memory range as its contents?

well assuming the device is 00:02.0 on the bus (obviously you need to
find the right device) and that it's the first resource of the device,
then yes. (and you have to mmap it, not "read"/"write")

lspci -v  is your friend in finding out which resource and which device
it is...


Greetings,
   Arjan van de Ven


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux