Commit d637640f authored by Alexandre Julliard's avatar Alexandre Julliard

krnl386: Get rid of DOS parallel port I/O support.

parent 61ad36fd
......@@ -14424,41 +14424,6 @@ esac
enable_fonts=${enable_fonts:-no}
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for parport header/ppdev.h" >&5
$as_echo_n "checking for parport header/ppdev.h... " >&6; }
if ${ac_cv_c_ppdev+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#include <linux/ppdev.h>
int
main ()
{
ioctl (1,PPCLAIM,0)
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_ppdev="yes"
else
ac_cv_c_ppdev="no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_ppdev" >&5
$as_echo "$ac_cv_c_ppdev" >&6; }
if test "$ac_cv_c_ppdev" = "yes"
then
$as_echo "#define HAVE_PPDEV 1" >>confdefs.h
fi
ac_wine_check_funcs_save_LIBS="$LIBS"
LIBS="$LIBS $PTHREAD_LIBS"
for ac_func in \
......
......@@ -1579,18 +1579,6 @@ WINE_ERROR_WITH(freetype,[test "x$ac_cv_lib_soname_freetype" = x],
[FreeType ${notice_platform}development files not found. Fonts will not be built.],
[enable_fonts])
dnl **** Check for parport (currently Linux only) ****
AC_CACHE_CHECK([for parport header/ppdev.h], ac_cv_c_ppdev,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#include <linux/ppdev.h>]], [[ioctl (1,PPCLAIM,0)]])],
[ac_cv_c_ppdev="yes"],[ac_cv_c_ppdev="no"]))
if test "$ac_cv_c_ppdev" = "yes"
then
AC_DEFINE(HAVE_PPDEV, 1, [Define if we can use ppdev.h for parallel port access])
fi
dnl **** Check for pthread functions ****
WINE_CHECK_LIB_FUNCS(\
pthread_getthreadid_np,
......
......@@ -35,18 +35,6 @@
# include <sys/stat.h>
#endif
#ifdef HAVE_PPDEV
#include <fcntl.h>
#include <errno.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_LINUX_IOCTL_H
# include <linux/ioctl.h>
#endif
#include <linux/ppdev.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
......@@ -168,11 +156,6 @@ static void IO_FixCMOSCheckSum(void)
TRACE("calculated hi %02x, lo %02x\n", cmosimage[0x2e], cmosimage[0x2f]);
}
#ifdef HAVE_PPDEV
static int do_pp_port_access = -1; /* -1: uninitialized, 1: not available
0: available);*/
#endif
#define BCD2BIN(a) \
((a)%10 + ((a)>>4)%10*10 + ((a)>>8)%10*100 + ((a)>>12)%10*1000)
#define BIN2BCD(a) \
......@@ -254,291 +237,6 @@ static WORD get_timer_val(unsigned timer)
}
#ifdef HAVE_PPDEV
typedef struct _PPDEVICESTRUCT{
int fd; /* NULL if device not available */
char *devicename;
int userbase; /* where wine thinks the ports are */
DWORD lastaccess; /* or NULL if release */
int timeout; /* time in second of inactivity to release the port */
} PPDeviceStruct;
static PPDeviceStruct PPDeviceList[5];
static int PPDeviceNum=0;
static int IO_pp_sort(const void *p1,const void *p2)
{
return ((const PPDeviceStruct*)p1)->userbase - ((const PPDeviceStruct*)p2)->userbase;
}
/* IO_pp_init
*
* Read the ppdev entries from registry, open the device and check
* for necessary IOCTRL
* Report verbose about possible errors
*/
static char IO_pp_init(void)
{
char name[80];
char buffer[256];
HANDLE root, hkey;
int i,idx=0,fd,res,userbase,nports=0;
char * timeout;
char ret=1;
int lasterror;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
static const WCHAR configW[] = {'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','V','D','M','\\','p','p','d','e','v',0};
TRACE("\n");
RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
attr.Length = sizeof(attr);
attr.RootDirectory = root;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, configW );
/* @@ Wine registry key: HKCU\Software\Wine\VDM\ppdev */
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) hkey = 0;
NtClose( root );
if (!hkey) return 1;
for (;;)
{
DWORD total_size, len;
char temp[256];
KEY_VALUE_FULL_INFORMATION *info = (KEY_VALUE_FULL_INFORMATION *)temp;
if (NtEnumerateValueKey( hkey, idx, KeyValueFullInformation,
temp, sizeof(temp), &total_size )) break;
if (info->Type != REG_SZ) break;
RtlUnicodeToMultiByteN( name, sizeof(name)-1, &len, info->Name, info->NameLength );
name[len] = 0;
RtlUnicodeToMultiByteN( buffer, sizeof(buffer)-1, &len,
(WCHAR *)(temp + info->DataOffset), total_size-info->DataOffset );
buffer[len] = 0;
idx++;
if(nports >4)
{
FIXME("Make the PPDeviceList larger than 5 elements\n");
break;
}
TRACE("Device '%s' at virtual userbase '%s'\n", buffer,name);
timeout = strchr(buffer,',');
if (timeout)
*timeout++=0;
fd=open(buffer,O_RDWR);
lasterror=errno;
if (fd == -1)
{
WARN("Configuration: No access to %s Cause: %s\n",buffer,strerror(lasterror));
WARN("Rejecting configuration item\n");
if (lasterror == ENODEV)
ERR("Is the ppdev module loaded?\n");
continue;
}
userbase = strtol(name, NULL, 16);
if ( errno == ERANGE)
{
WARN("Configuration: Invalid base %s for %s\n",name,buffer);
WARN("Rejecting configuration item\n");
continue;
}
if (ioctl (fd,PPCLAIM,0))
{
ERR("PPCLAIM rejected %s\n",buffer);
ERR("Perhaps the device is already in use or nonexistent\n");
continue;
}
if (nports > 0)
{
for (i=0; i<= nports; i++)
{
if (PPDeviceList[i].userbase == userbase)
{
WARN("Configuration: %s uses the same virtual ports as %s\n",
buffer,PPDeviceList[0].devicename);
WARN("Configuration: Rejecting configuration item\n");
userbase = 0;
break;
}
}
if (!userbase) continue;
}
/* Check for the minimum required IOCTLS */
if ((ioctl(fd,PPRDATA,&res))||
(ioctl(fd,PPRSTATUS,&res))||
(ioctl(fd,PPRCONTROL,&res)))
{
ERR("PPUSER IOCTL not available for parport device %s\n",buffer);
continue;
}
if (ioctl (fd,PPRELEASE,0))
{
ERR("PPRELEASE rejected %s\n",buffer);
ERR("Perhaps the device is already in use or nonexistent\n");
continue;
}
PPDeviceList[nports].devicename = HeapAlloc(GetProcessHeap(), 0, sizeof(buffer)+1);
if (!PPDeviceList[nports].devicename)
{
ERR("No (more) space for devicename\n");
break;
}
strcpy(PPDeviceList[nports].devicename,buffer);
PPDeviceList[nports].fd = fd;
PPDeviceList[nports].userbase = userbase;
PPDeviceList[nports].lastaccess=GetTickCount();
if (timeout)
{
PPDeviceList[nports].timeout = strtol(timeout, NULL, 10);
if (errno == ERANGE)
{
WARN("Configuration: Invalid timeout %s in configuration for %s, Setting to 0\n",
timeout,buffer);
PPDeviceList[nports].timeout = 0;
}
}
else
PPDeviceList[nports].timeout = 0;
nports++;
}
TRACE("found %d ports\n",nports);
NtClose( hkey );
PPDeviceNum= nports;
if (nports > 1)
/* sort in ascending order for userbase for faster access */
qsort (PPDeviceList,PPDeviceNum,sizeof(PPDeviceStruct),IO_pp_sort);
if (nports)
ret=0;
for (idx= 0;idx<PPDeviceNum; idx++)
TRACE("found device %s userbase %x fd %x timeout %d\n",
PPDeviceList[idx].devicename, PPDeviceList[idx].userbase,
PPDeviceList[idx].fd,PPDeviceList[idx].timeout);
/* FIXME:
register a timer callback perhaps every 30 seconds to release unused ports
Set lastaccess = 0 as indicator when port was released
*/
return ret;
}
/* IO_pp_do_access
*
* Do the actual IOCTL
* Return NULL on success
*/
static int IO_pp_do_access(int idx,int ppctl, DWORD* res)
{
int ret;
if (ioctl(PPDeviceList[idx].fd,PPCLAIM,0))
{
ERR("Can't reclaim device %s, PPUSER/PPDEV handling confused\n",
PPDeviceList[idx].devicename);
return 1;
}
ret = ioctl(PPDeviceList[idx].fd,ppctl,res);
if (ioctl(PPDeviceList[idx].fd,PPRELEASE,0))
{
ERR("Can't release device %s, PPUSER/PPDEV handling confused\n",
PPDeviceList[idx].devicename);
return 1;
}
return ret;
}
/* IO_pp_inp
*
* Check if we can satisfy the INP command with some of the configured PPDEV device
* Return NULL on success
*/
static int IO_pp_inp(int port, DWORD* res)
{
int idx,j=0;
for (idx=0;idx<PPDeviceNum ;idx++)
{
j = port - PPDeviceList[idx].userbase;
if (j <0) return 1;
switch (j)
{
case 0:
return IO_pp_do_access(idx,PPRDATA,res);
case 1:
return IO_pp_do_access(idx,PPRSTATUS,res);
case 2:
return IO_pp_do_access(idx,PPRCONTROL,res);
case 0x400:
case 0x402:
case 3:
case 4:
case 0x401:
FIXME("Port 0x%x not accessible for reading with ppdev\n",port);
FIXME("If this is causing problems, try direct port access\n");
return 1;
default:
break;
}
}
return 1;
}
/* IO_pp_outp
*
* Check if we can satisfy the OUTP command with some of the configured PPDEV device
* Return NULL on success
*/
static BOOL IO_pp_outp(int port, DWORD* res)
{
int idx,j=0;
for (idx=0;idx<PPDeviceNum ;idx++)
{
j = port - PPDeviceList[idx].userbase;
if (j <0) return 1;
switch (j)
{
case 0:
return IO_pp_do_access(idx,PPWDATA,res);
case 2:
{
/* We can't switch port direction via PPWCONTROL,
so do it via PPDATADIR
*/
DWORD mode = *res & 0x20;
IO_pp_do_access(idx,PPDATADIR,&mode);
mode = (*res & ~0x20);
return IO_pp_do_access(idx,PPWCONTROL,&mode);
}
case 1:
case 0x400:
case 0x402:
case 3:
case 4:
case 0x401:
FIXME("Port %d not accessible for writing with ppdev\n",port);
FIXME("If this is causing problems, try direct port access\n");
return 1;
default:
break;
}
}
return TRUE;
}
#endif /* HAVE_PPDEV */
/**********************************************************************
* DOSVM_inport
......@@ -554,14 +252,6 @@ DWORD DOSVM_inport( int port, int size )
DOSMEM_InitDosMemory();
#ifdef HAVE_PPDEV
if (do_pp_port_access == -1) do_pp_port_access =IO_pp_init();
if ((do_pp_port_access == 0 ) && (size == 1))
{
if (!IO_pp_inp(port,&res)) return res;
}
#endif
switch (port)
{
case 0x40:
......@@ -649,14 +339,6 @@ void DOSVM_outport( int port, int size, DWORD value )
DOSMEM_InitDosMemory();
#ifdef HAVE_PPDEV
if (do_pp_port_access == -1) do_pp_port_access = IO_pp_init();
if ((do_pp_port_access == 0) && (size == 1))
{
if (!IO_pp_outp(port,&value)) return;
}
#endif
switch (port)
{
case 0x20:
......
......@@ -707,9 +707,6 @@
/* Define to 1 if you have the <port.h> header file. */
#undef HAVE_PORT_H
/* Define if we can use ppdev.h for parallel port access */
#undef HAVE_PPDEV
/* Define to 1 if you have the `prctl' function. */
#undef HAVE_PRCTL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment