Page 1 of 1
Mapping memory
Posted: Sun Dec 01, 2013 12:51 am
by hidnplayr
Hi,
I'm trying to work with some PCI device that needs a piece of address space where it can map it's own memory to, so I can access it.
But how do I do such a thing in KolibriOS ? I have used 'map_io_mem' before, when the device tells you the address, but now the device is asking me for the virtual address..
Any help appreciated.
Re: Mapping memory
Posted: Sun Dec 01, 2013 12:56 pm
by art_zh
http://wiki.kolibrios.org/wiki/SysFn62/ ... 0.BA.D0.B0
to let users access MMIO, the kernel shoul be compiled with mmio_pci_addr = b:d.f
(
http://websvn.kolibrios.org/filedetails ... Fpci32.inc)
or you need to map MMIO in your driver?
Re: Mapping memory
Posted: Sun Dec 01, 2013 1:48 pm
by hidnplayr
All I need is one
virtual physical address (range) that is available for 4096 bytes
(If I understand it correctly).
Re: Mapping memory
Posted: Sun Dec 01, 2013 3:44 pm
by Asper
KernelAlloc ?
Re: Mapping memory
Posted: Sun Dec 01, 2013 3:45 pm
by hidnplayr
Asper wrote:KernelAlloc ?
I dont need memory from RAM.
Re: Mapping memory
Posted: Sun Dec 01, 2013 10:32 pm
by hidnplayr
I just need to find a physical address that is still free.
For example, 0x7f000000 worked on my test machine. But there is no guarantee that it will work on others...
Re: Mapping memory
Posted: Sun Dec 01, 2013 10:35 pm
by Mario_r4
hidnplayr
You just need to wait for the forum to come Serge - he will most likely answer your question about the memory manager.
Re: Mapping memory
Posted: Tue Dec 03, 2013 1:57 am
by art_zh
hidnplayr
the only way to detect the MMIO physical range is to read the device's
base address registers (BARs) located in its configspace.
use bus/pci/pci32.inc functions (also available in userspace via fn62)
Re: Mapping memory
Posted: Tue Dec 03, 2013 11:59 am
by hidnplayr
art_zh wrote:hidnplayr
the only way to detect the MMIO physical range is to read the device's
base address registers (BARs) located in its configspace.
use bus/pci/pci32.inc functions (also available in userspace via fn62)
For regular PCI devices this has been filled in by the BIOS yes, but not for PCI-pc card bridges.
Re: Mapping memory
Posted: Wed Dec 04, 2013 1:30 am
by art_zh
Then your driver needs to do the work BIOS does.
I tryed this for PCIe hotplug, but stepped back - it takes tons of clever tricks with MRRs, northbridge apertures and IRQ allocations.
Plug-and-restart is much simpler.