Page 1 of 1
Memory mapping
Posted: Tue Nov 23, 2021 9:12 pm
by punk_joker
How to map virtual memory to real?
Should I use map_page procedure?
Re: Memory mapping
Posted: Wed Nov 24, 2021 1:50 am
by punk_joker
I found. I should use get_pg_addr.
Re: Memory mapping
Posted: Wed Nov 24, 2021 10:59 pm
by hidnplayr
Either you did not describe the problem accurately, or the proposed solution is wrong.
My answer to your original question would be, use "MapIoMem" from driver or "map_io_mem" from inside kernel.
An example can be found in drivers that use memory mapped I/O such as i8254x network driver line 414.
Code: Select all
invoke MapIoMem, eax, 10000h, PG_SW+PG_NOCACHE
If however you just want to know the "real" address of some pre-allocated memory (by using kernel_alloc for example), you can use "GetPhysAddr" aka get_phys_addr for any address location, or "GetPgAddr" and "get_pg_addr" when it is aligned on a page boundary (4096 bytes in current kernel).