annotate libdha/sysdep/pci_os2.c @ 7884:081f66465944

updated
author arpi
date Wed, 23 Oct 2002 22:56:19 +0000
parents 4cfb6b9a6da3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
1 /*
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
2 This file is based on:
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
3 $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
4 Modified for readability by Nick Kurshev
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
5 */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
6 #define INCL_DOSFILEMGR
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
7 #include <os2.h>
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
8
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
9 static USHORT callgate[3] = {0,0,0};
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
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
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
12 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
13 HFILE hfd;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
14 ULONG dlen,action;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
15 APIRET rc;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
16 static char *ioDrvPath = "/dev/fastio$";
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
17
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
18 if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
19 (ULONG)0, FILE_SYSTEM, FILE_OPEN,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
20 OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
21 (ULONG)0) != 0) {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
22 fprintf(stderr,"Error opening fastio$ driver...\n");
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
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
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
25 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
26 callgate[0] = callgate[1] = 0;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
27
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
28 /* Get callgate from driver for fast io to ports and other stuff */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
29
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
30 rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
31 NULL, 0, NULL,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
32 (ULONG*)&callgate[2], sizeof(USHORT), &dlen);
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
33 if (rc) {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
34 fprintf(stderr,"xf86-OS/2: EnableIOPorts failed, rc=%d, dlen=%d; emergency exit\n",
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
35 rc,dlen);
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
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
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
38 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
39
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
40 /* Calling callgate with function 13 sets IOPL for the program */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
41
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
42 asm volatile ("movl $13,%%ebx;.byte 0xff,0x1d;.long _callgate"
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
43 : /*no outputs */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
44 : /*no inputs */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
45 : "eax","ebx","ecx","edx","cc");
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
46
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
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
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
49 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
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
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
52 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
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
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
55 }