MMIO And Physical->Virtual
Posted: Thu Aug 21, 2003 11:00 pm
I am trying to implement my Realtek 8139 into my OS.
The PCI side of things is working (enough...).
I can read the Configuration space and get a) the IO Address range, and b) the Memory Mapped Address range. (a = D000h, b = DFFFFF00)
Using this info, I can inb() from D000, D001... D005 and get the MAC address of the network card. This was great
Then I decided that, for the sake of completeness, I would do the same with MMIO. UGGHH - Problem
If I disable Paging (PG), then reading from DFFFFF00h-DFFFFF05h gives me the MAC address as expected.
But I don't want to disable Paging as you can probably understand. With Paging enabled, first off, I get a Page fault because there is no entry in the Directory Table for that address. If I map that address to a physical memory location, then it simply returns 00,00 etc.. (IE. The actual memory data, not the MMIO data).
Looking at the source for another RTL8139 driver, I see that they use the Linux function ioremap() to remap the address. I've been reading and decyphering it for a while now, but I just can't seem to figure out what the ioremap() function does.
The definition I found said "remap IO memory to kernel address space".
I don't get it I don't so much need to know how to do it (not that I'd complain), but more understand what it's doing.
Is it remapping a physical address to a virtual address? if so, what address to what address?
Hmm, just had an idea.. back soon
The PCI side of things is working (enough...).
I can read the Configuration space and get a) the IO Address range, and b) the Memory Mapped Address range. (a = D000h, b = DFFFFF00)
Using this info, I can inb() from D000, D001... D005 and get the MAC address of the network card. This was great
Then I decided that, for the sake of completeness, I would do the same with MMIO. UGGHH - Problem
If I disable Paging (PG), then reading from DFFFFF00h-DFFFFF05h gives me the MAC address as expected.
But I don't want to disable Paging as you can probably understand. With Paging enabled, first off, I get a Page fault because there is no entry in the Directory Table for that address. If I map that address to a physical memory location, then it simply returns 00,00 etc.. (IE. The actual memory data, not the MMIO data).
Looking at the source for another RTL8139 driver, I see that they use the Linux function ioremap() to remap the address. I've been reading and decyphering it for a while now, but I just can't seem to figure out what the ioremap() function does.
The definition I found said "remap IO memory to kernel address space".
I don't get it I don't so much need to know how to do it (not that I'd complain), but more understand what it's doing.
Is it remapping a physical address to a virtual address? if so, what address to what address?
Hmm, just had an idea.. back soon