MMIO And Physical->Virtual

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Sentient

MMIO And Physical->Virtual

Post by Sentient »

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 :)
Sentient

RE:MMIO And Physical->Virtual

Post by Sentient »

OK nevermind...

Silly oversight on my part. I was too busy looking for a solution that the obvious didnt even occur to me. All fixed now :)

Incase any one is wondering (I doubt you are, but just in case)...

The page table for the address, just needs to point to the actual physical address. Kinda obvious now that I think about it (PS: yes that was the idea I had when I ran away for sec)
Post Reply