//------------------------------------------------------------------- // mmtest.cpp // // This program tests the 'mymmfb.c' character driver, which is // supposed to statically map the video frame-buffer to a known // user-space address when the '/dev/vram' file is opened. // // NOTE: Written and tested with Linux kernel version 2.4.20. // // programmer: ALLAN CRUSE // written on: 29 APR 2003 //------------------------------------------------------------------- #include // for printf(), perror() #include // for open() #include // for exit() #include // for read(), write(), close() #define HRES 1280 #define VRES 1024 char filename[] = "/dev/vram"; long *vram = (long*)0x10000000; int main( int argc, char **argv ) { // open the device file and determine video memory size int mm = open( filename, O_RDWR ); if ( mm < 0 ) { perror( filename ); exit(1); } int vramsize = lseek( mm, 0, SEEK_END ); printf( "\n\tvramsize=%d bytes (%d MB)\n\n", vramsize, vramsize>>20 ); // do some drawing (to verify the memory mapping) long color = 0x0000FFFF; for (int i = 0; i < 50*HRES; i++) vram[i] = color; // close the device file and exit close( mm ); exit(0); }