#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>

#define VMEM_START 0xe0000000
#define VMEM_SIZE 0x10000000
#define BOMB_STEP 0x1000

int main(int argc, char *argv[])
{
	int fd = open("/dev/mem", O_RDWR);
	if (fd == -1) {
		perror("Cannot open /dev/mem");
		return 1;
	}
	unsigned int *vgamem = mmap(NULL, VMEM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, VMEM_START);
	if (vgamem == MAP_FAILED) {
		perror("Cannot map video memory");
		return 1;
	}

	// Bomb the video memory...
	unsigned int i;
	for (i = 0; i < VMEM_SIZE / sizeof(unsigned int); i += BOMB_STEP) {
		vgamem[i] = 0;
	}

	munmap(vgamem, VMEM_SIZE);
	close(fd);
	return 0;
}
