| 1 |
#include <string.h> |
| 2 |
#include <stdio.h> |
| 3 |
#include <sys/ioctl.h> |
| 4 |
#include <unistd.h> |
| 5 |
#include <errno.h> |
| 6 |
#include <fcntl.h> |
| 7 |
#include <sys/mman.h> |
| 8 |
|
| 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 |
{ |
| 25 |
void *mem; |
| 26 |
unsigned long size=256; |
| 27 |
mem = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); |
| 28 |
printf("allocated to %p\n", mem); |
| 29 |
|
| 30 |
if (argc > 1) |
| 31 |
if (mem != 0) |
| 32 |
{ |
| 33 |
int i; |
| 34 |
|
| 35 |
for (i = 0; i < 256; i++) |
| 36 |
printf("[%x] ", *(int *)(mem+i)); |
| 37 |
printf("\n"); |
| 38 |
} |
| 39 |
|
| 40 |
munmap((void *)mem, size); |
| 41 |
} |
| 42 |
|
| 43 |
return(0); |
| 44 |
} |