Oops. Surprised to see it crashed :). Never I have seen a crash on my system.
Regards, Prabhu On Tue, Jan 18, 2011 at 1:29 PM, Alexandre Courbot <[email protected]> wrote: > On Tue, Jan 18, 2011 at 3:40 PM, Prabhu nath <[email protected]> > wrote: > > If you are working on a desktop machine, then the following idea works. > > Usually, the VGA compatible controller memory will be mapped to the > physical > > address space which can be viewed with the help of "lspci -vv" command. > Then > > open the device file "/dev/mem" and mmap with the offset equal to the > > physical address of the Graphics card. Here is a small snippet which > works > > on my machine > > Now open the device mem as > > fd = open = ("/dev/mem", O_RDWR) > > and do an mmap as > > vgamem = mmap (NULL, 0x10000000, PROT_READ | PROT_WRITE, > > MAP_SHARED, fd, 0xd0000000) > > 0x10000000 = 256MB of graphics card memory > > 0xd0000000 = base of the physical address of graphics card memory > > > > vgamem will be the user virtual address which is mapped to the physical > > address of Graphics card memory. > > > > To verify the mapping, write some bit patterns to 256MB of memory > starting > > from vgamem. > > If you see distortion on your desktop, then you have written on to your > > graphics card > > memory. > > Just gave it a shot, for the fun of it (program attached - needs root > rights). Indeed after running it my screen was stripped with little > black dots, as one could expect. However it also screwed my fonts and > after a few seconds crashed my system. ;) Indeed, the video memory > does not only contain the screen framebuffer, it also hosts other data > related to 3d management, compositing, and probably data structures > that X rely on. But at least this validates your approach to easily > access video memory. > > Now all that is needed for Elvis to get the screen contents is to know > the boundaries of the screen's buffer, as well as its format. > Following your idea, he could probably access the memory-mapped > registers of his video card, but this is highly vendor-dependant. > Cannot think of a more generic way though. > > Alex. >
_______________________________________________ Kernelnewbies mailing list [email protected] http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
