lkml.org 
[lkml]   [2001]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] svgalib error in mmap documentation
From
Date
Matan Ziv-Av <matan@svgalib.org> writes:

> I hope it is reasonable to ask, how?
>
> What I need is to allocate a big amount of memory (say 1MB, for
> example), copy the video memory to it, and then have fixed 64K of
> virutal address of the process point to any 64K window of the large
> allocated memory. How can I do it?

fd = shm_open("vidmem-filename", O_CREAT,...);
ftruncate(fd, 1<<20);
ptr = mmap(0, 64 * 1<<10, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

to remap another area:

if (mmap(ptr, 64 * 1<<10, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED,
fd, blocknr * 64 * 1<<10) != ptr)
error();

On exit:

munmap(ptr, 64 * 1<<10);
shm_unlink ("vidmem-filename");

Note the MAP_FIXED argument to the remap operation. You do not need to
unmap on Linux to remap an area when giving MAP_FIXED. (So MAP_FIXED
can to really bad things to your program...)

Greetings
Christoph

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:52    [W:0.087 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site