annotate vidix/dhahelper/test.c @ 30518:654cad7ea876

Rename exit_reason_t enum to exit_reason and do not typedef it. The _t namespace is reserved for POSIX; the typedef is pointless obfuscation.
author diego
date Sun, 14 Feb 2010 11:02:05 +0000
parents 0f1b5b68af32
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27006
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
1 /*
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
2 * dhahelper test program
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
3 *
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
4 * Copyright (C) 2002 Alex Beregszsaszi
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
5 *
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
6 * This file is part of MPlayer.
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
7 *
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
9 * it under the terms of the GNU General Public License as published by
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
11 * (at your option) any later version.
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
12 *
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
16 * GNU General Public License for more details.
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
17 *
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
18 * You should have received a copy of the GNU General Public License along
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
21 */
ad17225e13b4 Add standard license headers.
diego
parents: 26901
diff changeset
22
26901
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
23 #include <string.h>
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
24 #include <stdio.h>
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
25 #include <sys/ioctl.h>
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
26 #include <unistd.h>
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
27 #include <errno.h>
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
28 #include <fcntl.h>
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
29 #include <sys/mman.h>
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27006
diff changeset
30
26901
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
31 #include "dhahelper.h"
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
32
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
33 int main(int argc, char *argv[])
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
34 {
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
35 int fd;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
36 int ret;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
37
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
38 fd = open("/dev/dhahelper", O_RDWR);
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
39
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
40 ioctl(fd, DHAHELPER_GET_VERSION, &ret);
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
41
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
42 printf("api version: %d\n", ret);
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
43 if (ret != API_VERSION)
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
44 printf("incompatible api!\n");
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
45
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
46 {
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
47 dhahelper_memory_t mem;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
48
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
49 mem.operation = MEMORY_OP_MAP;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
50 //mem.start = 0xe0000000;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
51 mem.start = 0xe4000008;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
52 mem.offset = 0;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
53 mem.size = 0x4000;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
54 mem.ret = 0;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
55
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
56 ret = ioctl(fd, DHAHELPER_MEMORY, &mem);
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
57
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
58 printf("ret: %s\n", strerror(errno));
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
59
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
60 mem.ret = (int)mmap(NULL, (size_t)mem.size, PROT_READ, MAP_SHARED, fd, (off_t)0);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27006
diff changeset
61 printf("allocated to %x\n", mem.ret);
26901
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
62
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
63 if (argc > 1)
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
64 if (mem.ret != 0)
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
65 {
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
66 int i;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27006
diff changeset
67
26901
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
68 for (i = 0; i < 256; i++)
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
69 printf("[%x] ", *(int *)(mem.ret+i));
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
70 printf("\n");
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
71 }
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
72
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
73 munmap((void *)mem.ret, mem.size);
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
74
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
75 mem.operation = MEMORY_OP_UNMAP;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
76 mem.start = mem.ret;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
77
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
78 ioctl(fd, DHAHELPER_MEMORY, &mem);
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
79 }
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
80
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
81 return 0;
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff changeset
82 }