#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>

static const int count = 1024;

int main(int argc, char *argv[])
{
	int fileDescriptor;
	char *frameBuffer;
	int index;

	/* Open the framebuffer device */
	fileDescriptor = open("/dev/fb0", O_RDWR);
	if (fileDescriptor <= 0) {
		perror("Error opening framebuffer device /dev/fb0");
		return 0;
	}

	/* Map the framebuffer to the process address space */
	frameBuffer = (char *)mmap(0, count, PROT_READ | PROT_WRITE,
		MAP_SHARED, fileDescriptor, 0);
	if (frameBuffer <= 0) {
		perror("Error mapping framebuffer to address space");
		return 0;
	}

	/* Write to the framebuffer memory */
	for (index = 0; index < count; index++) {
		frameBuffer[index] = 0xFF;
	}

	/* Shutdown */
	munmap((void *)frameBuffer, count);
	close(fileDescriptor);
	return 1;
}

