Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


HVM capability enhancement: asynchronous upcalls to ROS userspace
[palacios.git] / guest / linux / paragraph / write_paragraph / write_paragraph.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <fcntl.h>
4 #include <sys/mman.h>
5
6 #define PARAGRAPH_PADDR 0x80000000
7 #define PARAGRAPH_LEN (640*480*4)
8
9 int main(int argc, char *argv[]) 
10 {
11   int start;
12
13   if (argc < 2) {
14     printf("Usage: write_paragraph start\n");
15     return 0;
16   }
17   
18   start = atoi(argv[1]);
19
20   int fd = open("/dev/mem", O_RDWR | O_SYNC);
21
22   if (fd<0) { 
23     perror("Cannot open /dev/mem");
24     return -1;
25   }
26
27   unsigned char *mem = mmap(NULL, PARAGRAPH_LEN, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, PARAGRAPH_PADDR);
28
29   if (mem == NULL) {
30     perror("Can't map memory");
31     return -1;
32   } else { 
33     printf("Mapped to 0x%p (%d bytes)\n", mem, PARAGRAPH_LEN);
34   }
35   
36   int i;
37   for (i = 0; i < PARAGRAPH_LEN; ++i) {
38     mem[i] = i+start;
39   }
40   printf("Wrote %d bytes\n", PARAGRAPH_LEN);
41
42   sleep(99999);
43
44 }