Mercurial > mplayer.hg
annotate vidix/sysdep/libdha_os2.c @ 33703:84346d087e4e
Fix ridiculously slow LIVE555 test by sanity-checking the path for
existence of the libraries with "test" before running compilation.
author | reimar |
---|---|
date | Fri, 01 Jul 2011 18:58:13 +0000 |
parents | 0f1b5b68af32 |
children |
rev | line source |
---|---|
4164 | 1 /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.14 2000/10/28 01:42:28 mvojkovi Exp $ */ |
2 /* Modified for libdha by Nick Kurshev. */ | |
3 /* | |
4 * (c) Copyright 1994,1999 by Holger Veit | |
5 * <Holger.Veit@gmd.de> | |
6 * Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca> | |
7 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
8 * Permission is hereby granted, free of charge, to any person obtaining a |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
9 * copy of this software and associated documentation files (the "Software"), |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
10 * to deal in the Software without restriction, including without limitation |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
12 * and/or sell copies of the Software, and to permit persons to whom the |
4164 | 13 * Software is furnished to do so, subject to the following conditions: |
14 * | |
15 * The above copyright notice and this permission notice shall be included in | |
16 * all copies or substantial portions of the Software. | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
17 * |
4164 | 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
21 * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
4164 | 24 * SOFTWARE. |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
25 * |
4164 | 26 * Except as contained in this notice, the name of Holger Veit shall not be |
27 * used in advertising or otherwise to promote the sale, use or other dealings | |
28 * in this Software without prior written authorization from Holger Veit. | |
29 * | |
30 */ | |
31 /* $XConsortium: os2_video.c /main/8 1996/10/27 11:49:02 kaleb $ */ | |
32 | |
33 #define INCL_DOSFILEMGR | |
34 #include "os2.h" | |
35 | |
36 /***************************************************************************/ | |
37 /* Video Memory Mapping helper functions */ | |
38 /***************************************************************************/ | |
39 | |
40 /* This section uses the xf86sup.sys driver developed for xfree86. | |
41 * The driver allows mapping of physical memory | |
42 * You must install it with a line DEVICE=path\xf86sup.sys in config.sys. | |
43 */ | |
44 | |
45 static HFILE mapdev = -1; | |
46 static ULONG stored_virt_addr; | |
47 static char* mappath = "\\DEV\\PMAP$"; | |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
22900
diff
changeset
|
48 static HFILE open_mmap(void) |
4164 | 49 { |
50 APIRET rc; | |
51 ULONG action; | |
52 | |
53 if (mapdev != -1) | |
54 return mapdev; | |
55 | |
56 rc = DosOpen((PSZ)mappath, (PHFILE)&mapdev, (PULONG)&action, | |
57 (ULONG)0, FILE_SYSTEM, FILE_OPEN, | |
58 OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY, | |
59 (ULONG)0); | |
60 if (rc!=0) | |
61 mapdev = -1; | |
62 return mapdev; | |
63 } | |
64 | |
28232
8df85ad26746
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
22900
diff
changeset
|
65 static void close_mmap(void) |
4164 | 66 { |
67 if (mapdev != -1) | |
68 DosClose(mapdev); | |
69 mapdev = -1; | |
70 } | |
71 | |
72 /* this structure is used as a parameter packet for the direct access | |
73 * ioctl of pmap$ | |
74 */ | |
75 | |
76 /* Changed here for structure of driver PMAP$ */ | |
77 | |
78 typedef struct{ | |
79 ULONG addr; | |
80 ULONG size; | |
81 } DIOParPkt; | |
82 | |
83 /* This is the data packet for the mapping function */ | |
84 | |
85 typedef struct { | |
86 ULONG addr; | |
87 USHORT sel; | |
88 } DIODtaPkt; | |
89 | |
90 /***************************************************************************/ | |
91 /* Video Memory Mapping section */ | |
92 /***************************************************************************/ | |
93 | |
94 static long callcount = 0L; | |
95 | |
96 /* ARGSUSED */ | |
97 void * map_phys_mem(unsigned long base, unsigned long size) | |
98 { | |
99 DIOParPkt par; | |
100 ULONG plen; | |
101 DIODtaPkt dta; | |
102 ULONG dlen; | |
103 static BOOL ErrRedir = FALSE; | |
104 APIRET rc; | |
105 | |
106 par.addr = (ULONG)base; | |
107 par.size = (ULONG)size; | |
108 plen = sizeof(par); | |
109 dlen = sizeof(dta); | |
110 | |
111 open_mmap(); | |
112 if (mapdev == -1) | |
113 { | |
114 perror("libdha: device xf86sup.sys is not installed"); | |
115 exit(1); | |
116 } | |
117 if ((rc=DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x44, | |
118 (PVOID)&par, (ULONG)plen, (PULONG)&plen, | |
119 (PVOID)&dta, (ULONG)dlen, (PULONG)&dlen)) == 0) { | |
120 if (dlen==sizeof(dta)) { | |
121 callcount++; | |
122 return (void *)dta.addr; | |
123 } | |
124 /*else fail*/ | |
125 } | |
126 return (void *)-1; | |
127 } | |
128 | |
129 /* ARGSUSED */ | |
130 void unmap_phys_mem(void * base, unsigned long size) | |
131 { | |
132 DIOParPkt par; | |
133 ULONG plen,vmaddr; | |
134 | |
135 /* We need here the VIRTADDR for unmapping, not the physical address */ | |
136 /* This should be taken care of either here by keeping track of allocated */ | |
137 /* pointers, but this is also already done in the driver... Thus it would */ | |
138 /* be a waste to do this tracking twice. Can this be changed when the fn. */ | |
139 /* is called? This would require tracking this function in all servers, */ | |
140 /* and changing it appropriately to call this with the virtual adress */ | |
141 /* If the above mapping function is only called once, then we can store */ | |
142 /* the virtual adress and use it here.... */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
143 |
4164 | 144 par.addr = (ULONG)base; |
145 par.size = 0xffffffff; /* This is the virtual address parameter. Set this to ignore */ | |
146 plen = sizeof(par); | |
147 | |
148 if (mapdev != -1) | |
149 { | |
150 DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x46, | |
151 (PVOID)&par, (ULONG)plen, (PULONG)&plen, | |
152 &vmaddr, sizeof(ULONG), &plen); | |
153 callcount--; | |
154 } | |
155 /* Now if more than one region has been allocated and we close the driver, | |
156 * the other pointers will immediately become invalid. We avoid closing | |
157 * driver for now, but this should be fixed for server exit | |
158 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28232
diff
changeset
|
159 |
4164 | 160 if(!callcount) close_mmap(); |
161 } |