4471
|
1 #include <string.h>
|
|
2 #include <stdio.h>
|
|
3 #include <sys/ioctl.h>
|
4470
|
4 #include <unistd.h>
|
|
5 #include <errno.h>
|
|
6 #include <fcntl.h>
|
|
7 #include <sys/mman.h>
|
4471
|
8
|
4470
|
9 #include "dhahelper.h"
|
|
10
|
|
11 int main(int argc, char *argv[])
|
|
12 {
|
|
13 int fd;
|
|
14 int ret;
|
|
15
|
|
16 fd = open("/dev/dhahelper", O_RDWR);
|
|
17
|
|
18 ioctl(fd, DHAHELPER_GET_VERSION, &ret);
|
|
19
|
|
20 printf("api version: %d\n", ret);
|
|
21 if (ret != API_VERSION)
|
|
22 printf("incompatible api!\n");
|
|
23
|
|
24 {
|
4471
|
25 dhahelper_memory_t mem;
|
4470
|
26
|
|
27 mem.operation = MEMORY_OP_MAP;
|
|
28 //mem.start = 0xe0000000;
|
|
29 mem.start = 0xe4000008;
|
4471
|
30 mem.offset = 0;
|
|
31 mem.size = 0x4000;
|
4470
|
32 mem.ret = 0;
|
|
33
|
|
34 ret = ioctl(fd, DHAHELPER_MEMORY, &mem);
|
|
35
|
|
36 printf("ret: %s\n", strerror(errno));
|
|
37
|
|
38 mem.ret = (int)mmap(NULL, (size_t)mem.size, PROT_READ, MAP_SHARED, fd, (off_t)0);
|
4471
|
39 printf("allocated to %x\n", mem.ret);
|
4470
|
40
|
|
41 if (argc > 1)
|
|
42 if (mem.ret != 0)
|
|
43 {
|
4471
|
44 int i;
|
|
45
|
4470
|
46 for (i = 0; i < 256; i++)
|
|
47 printf("[%x] ", *(int *)(mem.ret+i));
|
|
48 printf("\n");
|
|
49 }
|
|
50
|
|
51 munmap((void *)mem.ret, mem.size);
|
|
52
|
|
53 mem.operation = MEMORY_OP_UNMAP;
|
|
54 mem.start = mem.ret;
|
|
55
|
|
56 ioctl(fd, DHAHELPER_MEMORY, &mem);
|
|
57 }
|
4471
|
58
|
|
59 return(0);
|
4470
|
60 }
|