Daniel S. Chivers <email@example.com> wrote:
In article <9ttrf8$mf9$> firstname.lastname@example.org> >, “Unknown” <> email@example.com
But is there a way to build a scatter-gather list of a currently
'spozedly you can use mphys() on each 4k page of your malloc’d buffer to
get the physical equivalent. A little bird told me this one day, so it
may or may not be “official” and YMMV. > > -RK
Yes, this is the idea of scatter-gather when the system uses a page size
of 4k. However, there is no way to tell how much of the buffer is on the
first page. It is not likely that the first 4k of the buffer is on one
page (ie. the buffer is probably not page aligned).
Also, the buffer must be locked down per page so it isn’t swapped out.
Without “official” scatter-gather list support in the OS… there isn’t
really a way to accomplish this.
Huh? Why does it matter where the buffer begins? The offset from the
beginning of the 4k page is the same in physical as it is in virtual.
For example, if I have a 2k data area that straddles two virtual pages, say
from 0x77770C00 to 0x77771400, you do an mphys() on the 0x77770000 page
to get the starting physical address of the first page, and then an mphys()
on the 0x77771000 page to get the starting physical address of the second
page. Let’s say this gives you 0x12340000 and 0x43210000. Then, you’d
feed your DMA controller 0x12340C00 through 0x12340FFF as the first
scatter/gather list, and 0x43210000 through 0x432103FF as the second
scatter/gather list element…
Locking down is accomplished “by default” now because paging is turn off
Or did I misunderstand your point?
Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Consulting and Training at www.parse.com
Email my initials at parse dot com.