/*
	test the ggmem module
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <asm/io.h>

int main(int argc, char **argv)
{
	int fd, err;
	unsigned long dma_info[2];
	char dma1[100], dma2[100], *dmaremap2;
	
	if ((fd = open("/dev/ggmem", O_RDWR)) < 0)
	{
		printf("Can't open device\n");
		exit(1);
	}
	if (ioctl(fd, 1, &dma_info) < 0)
	{
		printf("ioctl fail\n");
		exit(1);
	}
	printf("Area: %lx  Size: %lx\n", dma_info[0], dma_info[1]);
//
//				This is the mapping of the DMA area to the
//				user space.
//
	dmaremap2 = (char *) mmap(0, dma_info[1] << 10, PROT_WRITE | PROT_READ,
			MAP_SHARED, fd, dma_info[0]);
			
	printf("Remaped: %lx  ", dmaremap2);
	printf("%s\n", dmaremap2);
	close(fd);
	
	exit(0);
}
