| 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 |
|
| 11 |
static __inline__ int enable_os_io(void) |
| 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"); |
| 24 |
return(42); |
| 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); |
| 37 |
return(42); |
| 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); |
| 48 |
return(0); |
| 49 |
} |
| 50 |
|
| 51 |
static __inline__ int disable_os_io(void) |
| 52 |
{ |
| 53 |
/* Nothing to do */ |
| 54 |
return(0); |
| 55 |
} |