one would need to do
----------------------- caddr is the kernel allocated memory.
for (i = MAP_NR(caddr); i <= MAP_NR(caddr + size-1);
i++) {
set_bit(PG_reserved, &mem_map[i].flags);
}
--------------------
to get system addr from user addr, first you need to lock the user pages,
then
you can do this to get a kernel virtual addr once the pages are pinned down.
pgd = pgd_offset(current->mm, (unsigned long)addr);
pmd = pmd_offset(pgd, (unsigned long) addr);
pte = pte_offset(pmd, (unsigned long) addr);
phys_addr = pte_page (*pte);
kern_addr = (void *)(phys_addr | ((unsigned long) addr & (~PAGE_MASK)));
-----Original Message-----
From: Manfred Spraul [mailto:manfreds@colorfullife.com]
Sent: Wednesday, April 26, 2000 2:09 PM
To: jmcmullan@linuxcare.com
Cc: linux-kernel@vger.rutgers.edu
Subject: Re: VM: Bizzare MM tricks...
jmcmullan@linuxcare.com wrote:
>
> I'm working on a port of a driver from NT to Linux, and was
> wondering how to best go about mapping kernel memory to
> user space and vice versa. mmap(2) is a possibility, but would
> require a vast rework of the code, and break the ability of
> the customer to use their existing code base in NT/95.
>
What's the problem with mmap?
You could also call do_mmap() from within your ioctl, but I don't why
you want to do that. (it seems to be a one line change in the user space
app)
-- Manfred- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/