Re: /proc/self/mem

Search this archive.

From: Egbert Eich (eich@hilbert.ikp.physik.tu-darmstadt.de)
Date: Thu 02 Dec 1999 - 23:12:54 IST


Matan Ziv-Av writes:
 > 
 > Hi
 > 
 > As of 2.3.27 mmapping of /proc/self/mem is not possible.
 > svgalib (in background mode uses it as follows):
 > 
 > 1.  frame buffer (at physical 0x000a0000) is mapped into program's
 >     memory space (at GM=0x43210000, for example)
 > 
 > 2.  program writes to screen.
 > 
 > 3.  a console switch occurs (program goes to background)
 > 
 > 4.  svgalib allocates a virtual frame buffer (at VBF), and copies the
 >     physical one to it.
 > 
 > 5.  svgalib calls mmap(GM,0x10000,,,proc_self_mem_fd,VBF), so that
 >     writes at 0x4321xxxx go to the virtual frame buffer, and not to the
 >     physical one.
 > 
 > 6. when the program returns to foreground, svgalib copies virtual frame
 >    buffer to physical.
 > 
 > 
 > Now, step 5 is broken. Is the same result (that of the mmap in
 > step 5) achievable by other means?
 > 
 > 
This is much simpler than my case in XFree86.

You can mmap memory to any location that is page aligned:

mmap(loc,size,...,MAP_PRIVATE | MAP_FIXED | MAP_ANON,-1,0);

Before you do the console switch you remap your framebuffer to a
different location, map memory to the previous location of the fb, 
copy the fb over. On return you copy data back to the fb, unmap the
memory region and remap the fb.

Regards,
	Egbert.


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:22 IST