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.


Guest-side test tools, config, and X11 stuff for PARAGRAPH graphics device
[palacios.git] / guest / linux / paragraph / write_paragraph / write_paragraph_devmem.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 (1024*1024*4)
8
9 int main(int argc, char *argv[]) 
10 {
11   int start;
12
13   if (argc < 2) {
14     printf("Usage: write_paragraph_devmem 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_SHARED, fd, PARAGRAPH_PADDR);
28
29   if (mem == MAP_FAILED) {
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     if (i<16) { printf("0x%p = %d\n", mem+i, *(mem+i)); } 
40   }
41   printf("Wrote %d bytes\n", PARAGRAPH_LEN);
42
43 }