Commit 4d47ec26 authored by Andreas Mohr's avatar Andreas Mohr Committed by Alexandre Julliard

Added newer (ASPI 3.0 ?) function stubs to WNASPI32.

Better error messages.
parent 2c268318
/************************************************************************** /**************************************************************************
ASPI routines ASPI routines
(C) 2000 David Elliott <dfe@netnitco.net> (C) 2000 David Elliott <dfe@infinite-internet.net>
Licensed under the WINE (X11) license Licensed under the WINE (X11) license
*/ */
...@@ -28,6 +28,7 @@ HKEY_DYN_DATA ...@@ -28,6 +28,7 @@ HKEY_DYN_DATA
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
...@@ -71,7 +72,7 @@ ASPI_GetNumControllers() ...@@ -71,7 +72,7 @@ ASPI_GetNumControllers()
if( RegOpenKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, KEY_ALL_ACCESS, &hkeyScsi ) != ERROR_SUCCESS ) if( RegOpenKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, KEY_ALL_ACCESS, &hkeyScsi ) != ERROR_SUCCESS )
{ {
ERR("Could not open HEKY_DYN_DATA\\%s\n",KEYNAME_SCSI); ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
return 0; return 0;
} }
...@@ -84,7 +85,7 @@ ASPI_GetNumControllers() ...@@ -84,7 +85,7 @@ ASPI_GetNumControllers()
} }
if( RegQueryValueExA(hkeyControllerMap, NULL, NULL, &type, (LPBYTE)&num_ha, &cbData ) != ERROR_SUCCESS ) if( RegQueryValueExA(hkeyControllerMap, NULL, NULL, &type, (LPBYTE)&num_ha, &cbData ) != ERROR_SUCCESS )
{ {
ERR("Could not query value HEKY_DYN_DATA\\%s\n",KEYNAME_SCSI); ERR("Could not query value HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
num_ha=0; num_ha=0;
} }
RegCloseKey(hkeyControllerMap); RegCloseKey(hkeyControllerMap);
...@@ -103,7 +104,7 @@ SCSI_GetDeviceName( int h, int c, int t, int d, LPSTR devstr, LPDWORD lpcbData ) ...@@ -103,7 +104,7 @@ SCSI_GetDeviceName( int h, int c, int t, int d, LPSTR devstr, LPDWORD lpcbData )
if( RegOpenKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, KEY_ALL_ACCESS, &hkeyScsi ) != ERROR_SUCCESS ) if( RegOpenKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, KEY_ALL_ACCESS, &hkeyScsi ) != ERROR_SUCCESS )
{ {
ERR("Could not open HEKY_DYN_DATA\\%s\n",KEYNAME_SCSI); ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
return FALSE; return FALSE;
} }
...@@ -145,7 +146,7 @@ ASPI_GetHCforController( int controller ) ...@@ -145,7 +146,7 @@ ASPI_GetHCforController( int controller )
#endif #endif
if( (error=RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition )) != ERROR_SUCCESS ) if( (error=RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition )) != ERROR_SUCCESS )
{ {
ERR("Could not open HEKY_DYN_DATA\\%s\n",KEYNAME_SCSI); ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
SetLastError(error); SetLastError(error);
return hc; return hc;
} }
...@@ -183,6 +184,7 @@ SCSI_OpenDevice( int h, int c, int t, int d ) ...@@ -183,6 +184,7 @@ SCSI_OpenDevice( int h, int c, int t, int d )
char devstr[20]; char devstr[20];
DWORD cbData = 20; DWORD cbData = 20;
int fd = -1; int fd = -1;
char dainbread_linux_hack = 1;
if(!SCSI_GetDeviceName( h, c, t, d, devstr, &cbData )) if(!SCSI_GetDeviceName( h, c, t, d, devstr, &cbData ))
{ {
...@@ -190,14 +192,33 @@ SCSI_OpenDevice( int h, int c, int t, int d ) ...@@ -190,14 +192,33 @@ SCSI_OpenDevice( int h, int c, int t, int d )
return -1; return -1;
} }
linux_hack:
TRACE("Opening device %s mode O_RDWR\n",devstr); TRACE("Opening device %s mode O_RDWR\n",devstr);
fd = open(devstr, O_RDWR); fd = open(devstr, O_RDWR);
if( fd < 0 ) if( fd < 0 )
{ {
TRACE("open failed\n"); int len = strlen(devstr);
FILE_SetDosError(); /* SetLastError() to errno */ FILE_SetDosError(); /* SetLastError() to errno */
TRACE("GetLastError: %ld\n", GetLastError()); TRACE("Open failed (%s)\n", strerror(errno));
/* in case of "/dev/sgX", convert from sga to sg0
* and the other way around.
* FIXME: remove it if the distributions
* finally manage to agree on something.
* The best would probably be a complete
* rewrite of the Linux SCSI layer
* to use CAM + devfs :-) */
if ( (dainbread_linux_hack) &&
(len >= 3) &&
(devstr[len-3] == 's') && (devstr[len-2] == 'g') )
{
char *p = &devstr[len-1];
*p = (*p >= 'a') ? *p - 'a' + '0' : *p - '0' + 'a';
dainbread_linux_hack = 0;
TRACE("Retry with \"equivalent\" Linux device '%s'\n", devstr);
goto linux_hack;
}
} }
return fd; return fd;
} }
...@@ -227,7 +248,7 @@ SCSI_LinuxSetTimeout( int fd, int timeout ) ...@@ -227,7 +248,7 @@ SCSI_LinuxSetTimeout( int fd, int timeout )
retval=ioctl(fd,SG_SET_TIMEOUT,&timeout); retval=ioctl(fd,SG_SET_TIMEOUT,&timeout);
if(retval) if(retval)
{ {
WARN("Could not set timeout errno=%d!\n",errno); WARN("Could not set timeout ! (%s)\n", strerror(errno));
} }
return retval; return retval;
...@@ -249,7 +270,7 @@ SCSI_LinuxDeviceIo( int fd, ...@@ -249,7 +270,7 @@ SCSI_LinuxDeviceIo( int fd,
DWORD dwBytes; DWORD dwBytes;
DWORD save_error; DWORD save_error;
TRACE("Writing to Liunx sg device\n"); TRACE("Writing to Linux sg device\n");
dwBytes = write( fd, lpInBuffer, cbInBuffer ); dwBytes = write( fd, lpInBuffer, cbInBuffer );
if( dwBytes != cbInBuffer ) if( dwBytes != cbInBuffer )
{ {
...@@ -257,7 +278,7 @@ SCSI_LinuxDeviceIo( int fd, ...@@ -257,7 +278,7 @@ SCSI_LinuxDeviceIo( int fd,
save_error = GetLastError(); save_error = GetLastError();
WARN("Not enough bytes written to scsi device. bytes=%ld .. %ld\n", cbInBuffer, dwBytes ); WARN("Not enough bytes written to scsi device. bytes=%ld .. %ld\n", cbInBuffer, dwBytes );
if( save_error == ERROR_NOT_ENOUGH_MEMORY ) if( save_error == ERROR_NOT_ENOUGH_MEMORY )
MESSAGE("Your Linux kernel was not able to handle the amount of data sent to the scsi device. Try recompiling with a larger SG_BIG_BUFF value (kernel 2.0.x sg.h"); MESSAGE("Your Linux kernel was not able to handle the amount of data sent to the scsi device. Try recompiling with a larger SG_BIG_BUFF value (kernel 2.0.x sg.h)");
WARN("error= %ld\n", save_error ); WARN("error= %ld\n", save_error );
*lpcbBytesReturned = 0; *lpcbBytesReturned = 0;
return FALSE; return FALSE;
...@@ -381,7 +402,7 @@ SCSI_MapHCtoController() ...@@ -381,7 +402,7 @@ SCSI_MapHCtoController()
if( RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition ) != ERROR_SUCCESS ) if( RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition ) != ERROR_SUCCESS )
{ {
ERR("Could not open HEKY_DYN_DATA\\%s\n",KEYNAME_SCSI); ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
return; return;
} }
if( disposition != REG_OPENED_EXISTING_KEY ) if( disposition != REG_OPENED_EXISTING_KEY )
...@@ -425,7 +446,7 @@ SCSI_MapHCtoController() ...@@ -425,7 +446,7 @@ SCSI_MapHCtoController()
/* Set (default) value to number of controllers */ /* Set (default) value to number of controllers */
if( RegSetValueExA(hkeyControllerMap, NULL, 0, REG_DWORD, (LPBYTE)&num_controller, sizeof(DWORD) ) != ERROR_SUCCESS ) if( RegSetValueExA(hkeyControllerMap, NULL, 0, REG_DWORD, (LPBYTE)&num_controller, sizeof(DWORD) ) != ERROR_SUCCESS )
{ {
ERR("Could not set value HEKY_DYN_DATA\\%s\\%s\n",KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP); ERR("Could not set value HKEY_DYN_DATA\\%s\\%s\n",KEYNAME_SCSI, KEYNAME_SCSI_CONTROLLERMAP);
} }
RegCloseKey(hkeyControllerMap); RegCloseKey(hkeyControllerMap);
RegCloseKey(hkeyScsi); RegCloseKey(hkeyScsi);
...@@ -433,6 +454,27 @@ SCSI_MapHCtoController() ...@@ -433,6 +454,27 @@ SCSI_MapHCtoController()
} }
#endif #endif
int SCSI_Linux_CheckDevices(void)
{
DIR *devdir;
struct dirent *dent = NULL;
devdir = opendir("/dev");
for (dent=readdir(devdir);dent;dent=readdir(devdir))
{
if (!(strncmp(dent->d_name, "sg", 2)))
break;
}
closedir(devdir);
if (dent == NULL)
{
MESSAGE("WARNING: You don't have any /dev/sgX generic scsi devices ! \"man MAKEDEV\" !\n");
return 0;
}
return 1;
}
static void static void
SCSI_GetProcinfo() SCSI_GetProcinfo()
/* I'll admit, this function is somewhat of a mess... it was originally /* I'll admit, this function is somewhat of a mess... it was originally
...@@ -441,8 +483,10 @@ SCSI_GetProcinfo() ...@@ -441,8 +483,10 @@ SCSI_GetProcinfo()
*/ */
{ {
#ifdef linux #ifdef linux
static const char procname[] = "/proc/scsi/scsi";
FILE * procfile = NULL; FILE * procfile = NULL;
char read_line[40], read1[10] = "\0", read2[10] = "\0";
int result = 0; int result = 0;
struct LinuxProcScsiDevice dev; struct LinuxProcScsiDevice dev;
...@@ -456,23 +500,35 @@ SCSI_GetProcinfo() ...@@ -456,23 +500,35 @@ SCSI_GetProcinfo()
HKEY hkeyScsi; HKEY hkeyScsi;
DWORD disposition; DWORD disposition;
procfile = fopen( "/proc/scsi/scsi", "r" ); /* Check whether user has generic scsi devices at all */
if (!(SCSI_Linux_CheckDevices()))
return;
procfile = fopen( procname, "r" );
if( !procfile ) if( !procfile )
{ {
ERR("Could not open /proc/scsi/scsi\n"); ERR("Could not open %s\n", procname);
return;
}
fgets(read_line, 40, procfile);
sscanf( read_line, "Attached %9s %9s", read1, read2);
if(strcmp(read1, "devices:"))
{
ERR("Incorrect %s format\n", procname);
return; return;
} }
result = fscanf( procfile, "Attached devices: \n"); if(!(strcmp(read2, "none")))
if( result != 0 )
{ {
ERR("Incorrect /proc/scsi/scsi format"); ERR("No devices found in %s. Make sure you loaded your SCSI driver or set up ide-scsi emulation for your IDE device if this app needs it !\n", procname);
return; return;
} }
if( RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition ) != ERROR_SUCCESS ) if( RegCreateKeyExA(HKEY_DYN_DATA, KEYNAME_SCSI, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkeyScsi, &disposition ) != ERROR_SUCCESS )
{ {
ERR("Could not create HEKY_DYN_DATA\\%s\n",KEYNAME_SCSI); ERR("Could not create HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
return; return;
} }
...@@ -485,7 +541,7 @@ SCSI_GetProcinfo() ...@@ -485,7 +541,7 @@ SCSI_GetProcinfo()
sprintf(devstr, "/dev/sg%c", 'a'+devnum); sprintf(devstr, "/dev/sg%c", 'a'+devnum);
if( RegSetValueExA(hkeyScsi, idstr, 0, REG_SZ, devstr, strlen(devstr)+1 ) != ERROR_SUCCESS ) if( RegSetValueExA(hkeyScsi, idstr, 0, REG_SZ, devstr, strlen(devstr)+1 ) != ERROR_SUCCESS )
{ {
ERR("Could not set value HEKY_DYN_DATA\\%s\\%s\n",KEYNAME_SCSI, idstr); ERR("Could not set value HKEY_DYN_DATA\\%s\\%s\n",KEYNAME_SCSI, idstr);
} }
/* Debug output */ /* Debug output */
...@@ -499,12 +555,12 @@ SCSI_GetProcinfo() ...@@ -499,12 +555,12 @@ SCSI_GetProcinfo()
} /* while(1) */ } /* while(1) */
if( result != EOF ) if( result != EOF )
{ {
ERR("Incorrect /proc/scsi/scsi format"); ERR("Sorry, incorrect %s format\n", procname);
} }
fclose( procfile ); fclose( procfile );
if( RegSetValueExA(hkeyScsi, NULL, 0, REG_DWORD, (LPBYTE)&num_ha, sizeof(num_ha) ) != ERROR_SUCCESS ) if( RegSetValueExA(hkeyScsi, NULL, 0, REG_DWORD, (LPBYTE)&num_ha, sizeof(num_ha) ) != ERROR_SUCCESS )
{ {
ERR("Could not set value HEKY_DYN_DATA\\%s\n",KEYNAME_SCSI); ERR("Could not set value HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
} }
RegCloseKey(hkeyScsi); RegCloseKey(hkeyScsi);
return; return;
......
...@@ -192,12 +192,12 @@ ASPI_PrintSenseArea(SRB_ExecSCSICmd *prb) ...@@ -192,12 +192,12 @@ ASPI_PrintSenseArea(SRB_ExecSCSICmd *prb)
{ {
DPRINTF("Request Sense reports:\n"); DPRINTF("Request Sense reports:\n");
if ((rqbuf[0]&0x7f)!=0x70) { if ((rqbuf[0]&0x7f)!=0x70) {
DPRINTF("\tInvalid sense header.\n"); DPRINTF("\tInvalid sense header: 0x%02x instead of 0x70\n", rqbuf[0]&0x7f);
return; return;
} }
DPRINTF("\tCurrent command read filemark: %s\n",(rqbuf[2]&0x80)?"yes":"no"); DPRINTF("\tCurrent command read filemark: %s\n",(rqbuf[2]&0x80)?"yes":"no");
DPRINTF("\tEarly warning passed: %s\n",(rqbuf[2]&0x40)?"yes":"no"); DPRINTF("\tEarly warning passed: %s\n",(rqbuf[2]&0x40)?"yes":"no");
DPRINTF("\tIncorrect blocklengt: %s\n",(rqbuf[2]&0x20)?"yes":"no"); DPRINTF("\tIncorrect blocklength: %s\n",(rqbuf[2]&0x20)?"yes":"no");
DPRINTF("\tSense Key: %d\n",rqbuf[2]&0xf); DPRINTF("\tSense Key: %d\n",rqbuf[2]&0xf);
if (rqbuf[0]&0x80) if (rqbuf[0]&0x80)
DPRINTF("\tResidual Length: %d\n",rqbuf[3]*0x1000000+rqbuf[4]*0x10000+rqbuf[5]*0x100+rqbuf[6]); DPRINTF("\tResidual Length: %d\n",rqbuf[3]*0x1000000+rqbuf[4]*0x10000+rqbuf[5]*0x100+rqbuf[6]);
...@@ -315,8 +315,6 @@ ASPI_ExecScsiCmd(SRB_ExecSCSICmd *lpPRB) ...@@ -315,8 +315,6 @@ ASPI_ExecScsiCmd(SRB_ExecSCSICmd *lpPRB)
ASPI_DebugPrintCmd(lpPRB); ASPI_DebugPrintCmd(lpPRB);
fd = ASPI_OpenDevice(lpPRB); fd = ASPI_OpenDevice(lpPRB);
if (fd == -1) { if (fd == -1) {
TRACE("Failed: could not open device c%01dt%01dd%01d. Device permissions !?\n",
lpPRB->SRB_HaId,lpPRB->SRB_Target,lpPRB->SRB_Lun);
return WNASPI32_DoPosting( lpPRB, SS_NO_DEVICE ); return WNASPI32_DoPosting( lpPRB, SS_NO_DEVICE );
} }
...@@ -550,3 +548,20 @@ DWORD WINAPI GetASPI32DLLVersion() ...@@ -550,3 +548,20 @@ DWORD WINAPI GetASPI32DLLVersion()
#endif #endif
} }
BOOL __cdecl GetASPI32Buffer(/*PASPI32BUFF*/LPVOID pab)
{
FIXME("(%p), stub !\n", pab);
return TRUE;
}
BOOL __cdecl FreeASPI32Buffer(/*PASPI32BUFF*/LPVOID pab)
{
FIXME("(%p), stub !\n", pab);
return TRUE;
}
BOOL __cdecl TranslateASPI32Address(LPDWORD pdwPath, LPDWORD pdwDEVNODE)
{
FIXME("(%p, %p), stub !\n", pdwPath, pdwDEVNODE);
return TRUE;
}
...@@ -4,7 +4,16 @@ init WNASPI32_LibMain ...@@ -4,7 +4,16 @@ init WNASPI32_LibMain
import kernel32.dll import kernel32.dll
1 stdcall GetASPI32SupportInfo() GetASPI32SupportInfo # we have several ordinal clashes here, it seems...
1 cdecl GetASPI32SupportInfo() GetASPI32SupportInfo
2 cdecl SendASPI32Command(ptr) SendASPI32Command 2 cdecl SendASPI32Command(ptr) SendASPI32Command
4 stdcall GetASPI32DLLVersion() GetASPI32DLLVersion 4 cdecl GetASPI32DLLVersion() GetASPI32DLLVersion
7 stub OrdinalOnlyExport
# 5 is the ordinal used by Adaptec's WNASPI32 DLL
#5 cdecl GetASPI32DLLVersion() GetASPI32DLLVersion
6 stub RegisterWOWPost
7 cdecl TranslateASPI32Address(ptr ptr) TranslateASPI32Address
8 cdecl GetASPI32Buffer(ptr) GetASPI32Buffer
# FreeASPI32Buffer: ord clash with GetASPI32DLLVersion (4), so use 14 instead
14 cdecl FreeASPI32Buffer(ptr) FreeASPI32Buffer
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