X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=guest%2Flinux%2Fparagraph%2Fwrite_paragraph%2Fwrite_paragraph.c;fp=guest%2Flinux%2Fparagraph%2Fwrite_paragraph%2Fwrite_paragraph.c;h=bc39c06e28493a5515df4e5881ce260a03dbad03;hb=6bc36dbea509d599d3c6fdb42e1a9c67144f5023;hp=0000000000000000000000000000000000000000;hpb=74c8b93121e177a843f461c8e0538ae1691ebcc8;p=palacios.git diff --git a/guest/linux/paragraph/write_paragraph/write_paragraph.c b/guest/linux/paragraph/write_paragraph/write_paragraph.c new file mode 100644 index 0000000..bc39c06 --- /dev/null +++ b/guest/linux/paragraph/write_paragraph/write_paragraph.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include + +#define PARAGRAPH_PADDR 0x80000000 +#define PARAGRAPH_LEN (640*480*4) + +int main(int argc, char *argv[]) +{ + int start; + + if (argc < 2) { + printf("Usage: write_paragraph start\n"); + return 0; + } + + start = atoi(argv[1]); + + int fd = open("/dev/mem", O_RDWR | O_SYNC); + + if (fd<0) { + perror("Cannot open /dev/mem"); + return -1; + } + + unsigned char *mem = mmap(NULL, PARAGRAPH_LEN, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, PARAGRAPH_PADDR); + + if (mem == NULL) { + perror("Can't map memory"); + return -1; + } else { + printf("Mapped to 0x%p (%d bytes)\n", mem, PARAGRAPH_LEN); + } + + int i; + for (i = 0; i < PARAGRAPH_LEN; ++i) { + mem[i] = i+start; + } + printf("Wrote %d bytes\n", PARAGRAPH_LEN); + + sleep(99999); + +}