Mercurial > mplayer.hg
annotate libdha/sysdep/pci_os2.c @ 20768:dd6bccfdf7ae
sync with r20774
author | voroshil |
---|---|
date | Wed, 08 Nov 2006 17:29:34 +0000 |
parents | 4cfb6b9a6da3 |
children |
rev | line source |
---|---|
4164 | 1 /* |
2 This file is based on: | |
3 $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $ | |
4 Modified for readability by Nick Kurshev | |
5 */ | |
6 #define INCL_DOSFILEMGR | |
7 #include <os2.h> | |
8 | |
9 static USHORT callgate[3] = {0,0,0}; | |
10 | |
4174
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
11 static __inline__ int enable_os_io(void) |
4164 | 12 { |
13 HFILE hfd; | |
14 ULONG dlen,action; | |
15 APIRET rc; | |
16 static char *ioDrvPath = "/dev/fastio$"; | |
17 | |
18 if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action, | |
19 (ULONG)0, FILE_SYSTEM, FILE_OPEN, | |
20 OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY, | |
21 (ULONG)0) != 0) { | |
22 fprintf(stderr,"Error opening fastio$ driver...\n"); | |
23 fprintf(stderr,"Please install xf86sup.sys in config.sys!\n"); | |
4174
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
24 return(42); |
4164 | 25 } |
26 callgate[0] = callgate[1] = 0; | |
27 | |
28 /* Get callgate from driver for fast io to ports and other stuff */ | |
29 | |
30 rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64, | |
31 NULL, 0, NULL, | |
32 (ULONG*)&callgate[2], sizeof(USHORT), &dlen); | |
33 if (rc) { | |
34 fprintf(stderr,"xf86-OS/2: EnableIOPorts failed, rc=%d, dlen=%d; emergency exit\n", | |
35 rc,dlen); | |
36 DosClose(hfd); | |
4174
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
37 return(42); |
4164 | 38 } |
39 | |
40 /* Calling callgate with function 13 sets IOPL for the program */ | |
41 | |
42 asm volatile ("movl $13,%%ebx;.byte 0xff,0x1d;.long _callgate" | |
43 : /*no outputs */ | |
44 : /*no inputs */ | |
45 : "eax","ebx","ecx","edx","cc"); | |
46 | |
47 DosClose(hfd); | |
4174
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
48 return(0); |
4164 | 49 } |
50 | |
4174
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
51 static __inline__ int disable_os_io(void) |
4164 | 52 { |
53 /* Nothing to do */ | |
4174
4cfb6b9a6da3
api changed: enable/disable_os_io returns error-code (or zero if ok) and pciconfig_read exported for mga_vid
alex
parents:
4164
diff
changeset
|
54 return(0); |
4164 | 55 } |