]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1110b2.zip
authorToni Wilen <twilen@winuae.net>
Sat, 15 Oct 2005 09:54:28 +0000 (12:54 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:27:08 +0000 (21:27 +0200)
debug.c
disk.c
include/parallel.h
include/zfile.h
main.c
od-win32/blkdev_win32_spti.c
od-win32/parser.c
od-win32/win32.h
od-win32/win32gui.c
zfile.c

diff --git a/debug.c b/debug.c
index 12529059d05f74ded19633df2162e515af092178..e1ea1304ba63b713f99fbce0dc609c195d800630 100755 (executable)
--- a/debug.c
+++ b/debug.c
@@ -1255,7 +1255,7 @@ static void disk_debug(char **inptr)
     char parm[10];
     int i;
 
-    disk_debug_logging = 1;
+    disk_debug_logging = 2;
     disk_debug_mode = 0;
     disk_debug_track = -1;
     ignore_ws(inptr);
diff --git a/disk.c b/disk.c
index b0ab93014382ddbae9847a3135af2351e7108084..4c3dfdca517037dcb7be20fab76cc4edf9c03bf7 100755 (executable)
--- a/disk.c
+++ b/disk.c
@@ -2139,10 +2139,12 @@ static void disk_doupdate_predict (drive * drv, int startcycle)
            updatetrackspeed (drv, mfmpos);
        if (dskdmaen != 3) {
            tword <<= 1;
-           if (unformatted (drv))
-               tword |= (rand() & 0x1000) ? 1 : 0;
-           else
-               tword |= getonebit (drv->bigmfmbuf, mfmpos);
+           if (!drive_empty (drv)) {
+               if (unformatted (drv))
+                   tword |= (rand() & 0x1000) ? 1 : 0;
+               else
+                   tword |= getonebit (drv->bigmfmbuf, mfmpos);
+           }
            if ((tword & 0xffff) == dsksync)
                diskevent_flag |= DISK_WORDSYNC;
        }
@@ -2210,10 +2212,12 @@ static void disk_doupdate_read (drive * drv, int floppybits)
        if (drv->tracktiming[0])
            updatetrackspeed (drv, drv->mfmpos);
        word <<= 1;
-       if (unformatted (drv))
-           word |= (rand() & 0x1000) ? 1 : 0;
-       else
-           word |= getonebit (drv->bigmfmbuf, drv->mfmpos);
+        if (!drive_empty (drv)) {
+           if (unformatted (drv))
+               word |= (rand() & 0x1000) ? 1 : 0;
+           else
+               word |= getonebit (drv->bigmfmbuf, drv->mfmpos);
+       }
        //write_log ("%08.8X bo=%d so=%d mfmpos=%d dma=%d\n", (word & 0xffffff), bitoffset, syncoffset, drv->mfmpos,dma_enable);
        drv->mfmpos++;
        drv->mfmpos %= drv->tracklen;
index 043d2e9b143ab54c14cf5759db15815539009e49..c53fde227da5e94651ae4e49d045838d0e542147 100755 (executable)
@@ -5,3 +5,4 @@ extern void flushprinter (void);
 extern void closeprinter (void);
 extern void openprinter (void);
 extern int isprinteropen (void);
+extern void initparallel (void);
\ No newline at end of file
index 8735ad7e9fa3c4291d46de4edea08c51fdb8e103..f340e53740e2e5db3fa10663970e486bed645fc1 100755 (executable)
@@ -39,3 +39,4 @@ extern struct zfile *zfile_dup (struct zfile *f);
 #define ZFILE_STATEFILE 6
 #define ZFILE_NVR 7
 
+extern char *archive_extensions[];
diff --git a/main.c b/main.c
index fa2043b8c9f0942f49af1360126868bae1a48b4a..85aa0959ae35552d8c87b900b86e3de78e3b74c2 100755 (executable)
--- a/main.c
+++ b/main.c
@@ -40,6 +40,7 @@
 #include "akiko.h"
 #include "savestate.h"
 #include "filesys.h"
+#include "parallel.h"
 
 #ifdef USE_SDL
 #include "SDL.h"
@@ -486,6 +487,9 @@ void reset_all_systems (void)
     scsidev_reset ();
     scsidev_start_threads ();
 #endif
+#if defined (PARALLEL_PORT)
+    initparallel ();
+#endif
 }
 
 /* Okay, this stuff looks strange, but it is here to encourage people who
index eb850e5f2e8ed3c267dbda34996513b86f5d0d3c..36234bb871030d1c33612f8f42056acfb1afa246 100755 (executable)
 #include <initguid.h>   // Guid definition
 #include <devguid.h>    // Device guids
 #include <setupapi.h>   // for SetupDiXxx functions.
-#include <cfgmgr32.h>   // for SetupDiXxx functions.
 
 #include <ntddscsi.h>
 
+#define INQUIRY_SIZE 36
 
 typedef struct _SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER {
   SCSI_PASS_THROUGH_DIRECT spt;
@@ -47,11 +47,13 @@ static int unitcnt = 0;
 struct dev_info_spti {
     char *drvpath;
     char *name;
+    char *inquirydata;
     int mediainserted;
     HANDLE handle;
     int isatapi;
     int type;
     int bus, path, target, lun;
+    int scanmode;
 };
 
 static uae_sem_t scgp_sem;
@@ -236,57 +238,33 @@ static uae_u8 *execscsicmd_in (int unitnum, uae_u8 *data, int len, int *outlen)
 
 static int total_devices;
 
-static int adddrive (char *drvpath, int bus, int pathid, int targetid, int lunid)
-{
-    struct dev_info_spti *di;
-    int cnt = total_devices, i;
 
-    if (cnt >= MAX_TOTAL_DEVICES)
-       return 0;
-    for (i = 0; i < total_devices; i++) {
-       di = &dev_info[i];
-       if (!strcmp(drvpath, di->drvpath))
-           return 0;
-    }
-    write_log("SPTI: unit %d '%s' added\n", total_devices, drvpath);
-    di = &dev_info[total_devices];
-    di->drvpath = my_strdup(drvpath);
-    di->type = 0;
-    di->bus = bus;
-    di->path = pathid;
-    di->target = targetid;
-    di->lun = lunid;
-    total_devices++;
-    return 1;
+static void close_scsi_device (int unitnum)
+{
+    write_log ("SPTI: unit %d closed\n", unitnum);
+    if (dev_info[unitnum].handle != INVALID_HANDLE_VALUE)
+       CloseHandle (dev_info[unitnum].handle);
+    dev_info[unitnum].handle = INVALID_HANDLE_VALUE;
 }
 
-int rescan(void);
-static int open_scsi_bus (int flags)
+static void free_scsi_device(int dev)
 {
-    int i;
-
-    total_devices = 0;
-    uae_sem_init (&scgp_sem, 0, 1);
-    for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
-       memset (&dev_info[i], 0, sizeof (struct dev_info_spti));
-       dev_info[i].handle = INVALID_HANDLE_VALUE;
-    }
-    if (!scsibuf)
-       scsibuf = VirtualAlloc (NULL, DEVICE_SCSI_BUFSIZE, MEM_COMMIT, PAGE_READWRITE);
-    rescan();
-    return total_devices;
+    close_scsi_device (dev);
+    xfree(dev_info[dev].name);
+    xfree(dev_info[dev].drvpath);
+    xfree(dev_info[dev].inquirydata);
+    dev_info[dev].name = NULL;
+    dev_info[dev].drvpath = NULL;
+    dev_info[dev].inquirydata = NULL;
+    memset(&dev_info[dev], 0, sizeof (struct dev_info_spti));
 }
 
-#if 0
+int rescan(void);
 static int open_scsi_bus (int flags)
 {
-    int dwDriveMask;
-    int drive, firstdrive;
-    char tmp[10], tmp2[10];
     int i;
 
     total_devices = 0;
-    firstdrive = 0;
     uae_sem_init (&scgp_sem, 0, 1);
     for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
        memset (&dev_info[i], 0, sizeof (struct dev_info_spti));
@@ -294,46 +272,23 @@ static int open_scsi_bus (int flags)
     }
     if (!scsibuf)
        scsibuf = VirtualAlloc (NULL, DEVICE_SCSI_BUFSIZE, MEM_COMMIT, PAGE_READWRITE);
-    dwDriveMask = GetLogicalDrives ();
-    device_debug ("SPTI: drive mask = %08.8X\n", dwDriveMask);
-    dwDriveMask >>= 2; // Skip A and B drives...
-    for( drive = 'C'; drive <= 'Z'; drive++) {
-       if (dwDriveMask & 1) {
-           int dt;
-           sprintf( tmp, "%c:\\", drive );
-           sprintf( tmp2, "%c:\\.", drive );
-           dt = GetDriveType (tmp);
-           device_debug ("SPTI: drive %c type %d\n", drive, dt);
-           if (dt == DRIVE_CDROM) {
-               if (!firstdrive)
-                   firstdrive = drive;
-               if (adddrive (total_devices, drive))
-                   total_devices++;
-           }
-       }
-       dwDriveMask >>= 1;
-    }
+    rescan();
     return total_devices;
 }
-#endif
 
 static void close_scsi_bus (void)
 {
     int i;
     VirtualFree (scsibuf, 0, MEM_RELEASE);
     scsibuf = 0;
-    for (i = 0; i < total_devices; i++) {
-       xfree(dev_info[i].name);
-       xfree(dev_info[i].drvpath);
-       dev_info[i].name = NULL;
-       dev_info[i].drvpath = NULL;
-    }
+    for (i = 0; i < total_devices; i++)
+       free_scsi_device(i);
 }
 
 static int inquiry (int unitnum, int *type, uae_u8 *inquirydata, int *inqlen)
 {
     uae_u8 cmd[6] = { 0x12,0,0,0,36,0 }; /* INQUIRY */
-    uae_u8 out[36];
+    uae_u8 out[INQUIRY_SIZE] = { 0 };
     int outlen = sizeof (out);
     uae_u8 *p = execscsicmd_in (unitnum, cmd, sizeof (cmd), &outlen);
     int v = 0;
@@ -342,17 +297,17 @@ static int inquiry (int unitnum, int *type, uae_u8 *inquirydata, int *inqlen)
     *type = 0x1f;
     if (!p) {
        if (log_scsi)
-           write_log("SPTI: INQUIRY failed!?\n");
+           write_log("SPTI: INQUIRY failed\n");
        return 0;
     }
-    *inqlen = outlen > 36 ? 36 : outlen;
+    *inqlen = outlen > INQUIRY_SIZE ? INQUIRY_SIZE : outlen;
     if (outlen >= 1)
        *type = p[0] & 31;
     if (outlen >= 2 && (p[0] & 31) == 5 && (p[2] & 7) == 0)
        v = 1;
     memcpy (inquirydata, p, *inqlen);
     if (log_scsi) {
-       if (outlen >= 36
+       if (outlen >= INQUIRY_SIZE
            write_log("SPTI: INQUIRY: %02.2X%02.2X%02.2X %d '%-8.8s' '%-16.16s'\n",
                p[0], p[1], p[2], v, p + 8, p + 16);
     }
@@ -369,14 +324,6 @@ static int mediacheck (int unitnum)
     return v >= 0 ? 1 : 0;
 }
 
-static void close_scsi_device (int unitnum)
-{
-    write_log ("SPTI: cd unit %d closed\n", unitnum);
-    if (dev_info[unitnum].handle != INVALID_HANDLE_VALUE)
-       CloseHandle (dev_info[unitnum].handle);
-    dev_info[unitnum].handle = INVALID_HANDLE_VALUE;
-}
-
 int open_scsi_device (int unitnum)
 {
     HANDLE h;
@@ -399,7 +346,7 @@ int open_scsi_device (int unitnum)
     if (h == INVALID_HANDLE_VALUE) {
        write_log ("SPTI: failed to open unit %d err=%d ('%s')\n", unitnum, GetLastError(), dev);
     } else {
-       uae_u8 inqdata[37] = { 0 };
+       uae_u8 inqdata[INQUIRY_SIZE + 1] = { 0 };
        int inqlen;
         dev_info[unitnum].isatapi = inquiry (unitnum, &dev_info[unitnum].type, inqdata, &inqlen);
        if (inqlen == 0) {
@@ -409,7 +356,7 @@ int open_scsi_device (int unitnum)
            xfree (dev);
            return 0;
        }
-       inqdata[36] = 0;
+       inqdata[INQUIRY_SIZE] = 0;
        if (dev_info[unitnum].type == INQ_ROMD) {
            dev_info[unitnum].mediainserted = mediacheck (unitnum);
            write_log ("SPTI: unit %d opened [%s], %s, '%s'\n", unitnum,
@@ -420,6 +367,8 @@ int open_scsi_device (int unitnum)
                unitnum, dev_info[unitnum].type, inqdata + 8);
        }
        dev_info[unitnum].name = my_strdup (inqdata + 8);
+       dev_info[unitnum].inquirydata = xmalloc (INQUIRY_SIZE);
+       memcpy (dev_info[unitnum].inquirydata, inqdata, INQUIRY_SIZE);
         xfree (dev);
        return 1;
     }
@@ -427,6 +376,48 @@ int open_scsi_device (int unitnum)
     return 0;
 }
 
+static int adddrive (char *drvpath, int bus, int pathid, int targetid, int lunid, int scanmode)
+{
+    struct dev_info_spti *di;
+    int cnt = total_devices, i;
+    int freeit = 1;
+
+    if (cnt >= MAX_TOTAL_DEVICES)
+       return 0;
+    for (i = 0; i < total_devices; i++) {
+       di = &dev_info[i];
+       if (!strcmp(drvpath, di->drvpath))
+           return 0;
+    }
+    write_log("SPTI: unit %d '%s' added\n", total_devices, drvpath);
+    di = &dev_info[total_devices];
+    di->drvpath = my_strdup(drvpath);
+    di->type = 0;
+    di->bus = bus;
+    di->path = pathid;
+    di->target = targetid;
+    di->lun = lunid;
+    di->scanmode = scanmode;
+    total_devices++;
+    if (open_scsi_device(cnt)) {
+       for (i = 0; i < cnt; i++) {
+           if (!memcmp(di->inquirydata, dev_info[i].inquirydata, INQUIRY_SIZE) && di->scanmode != dev_info[i].scanmode) {
+               write_log("duplicate device, skipped..\n");
+               break;
+           }
+       }
+       if (i == cnt) {
+           freeit = 0;
+           close_scsi_device(cnt);
+       }
+    }
+    if (freeit) {
+       free_scsi_device(cnt);
+       total_devices--;
+    }
+    return 1;
+}
+
 static struct device_info *info_device (int unitnum, struct device_info *di)
 {
     if (unitnum >= MAX_TOTAL_DEVICES || dev_info[unitnum].handle == INVALID_HANDLE_VALUE)
@@ -471,477 +462,6 @@ struct device_functions devicefunc_win32_spti = {
     0, 0, 0, 0, 0, 0, 0, check_isatapi
 };
 
-#define        SCSI_INFO_BUFFER_SIZE   0x5000  // Big enough to hold all Bus/Device info.
-static char* BusType[] = {
-    "UNKNOWN",  // 0x00
-    "SCSI",
-    "ATAPI",
-    "ATA",
-    "IEEE 1394",
-    "SSA",
-    "FIBRE",
-    "USB",
-    "RAID"
-};
-
-static void GetInquiryData(PCTSTR pDevId, DWORD idx)
-{
-    SP_DEVICE_INTERFACE_DATA            interfaceData;
-    PSP_DEVICE_INTERFACE_DETAIL_DATA    interfaceDetailData = NULL;
-    STORAGE_PROPERTY_QUERY              query;
-    PSTORAGE_ADAPTER_DESCRIPTOR         adpDesc;
-    PSCSI_BUS_DATA                     BusData;
-    PSCSI_INQUIRY_DATA                 InquiryData;
-    PSCSI_ADAPTER_BUS_INFO             AdapterInfo;
-    HANDLE                              hDevice;
-    BOOL                                status;
-    DWORD                               index = 0;
-    HDEVINFO                            hIntDevInfo;
-    UCHAR                               outBuf[512];
-    BOOL                               Claimed;
-    ULONG                               returnedLength;
-    SHORT                              Bus,
-                                       Luns;
-    DWORD                               interfaceDetailDataSize,
-                                       reqSize,
-                                       errorCode;
-
-
-    hIntDevInfo = SetupDiGetClassDevs (
-                &StoragePortClassGuid,
-                pDevId,                                 // Enumerator
-                NULL,                                   // Parent Window
-                (DIGCF_PRESENT | DIGCF_INTERFACEDEVICE  // Only Devices present & Interface class
-                ));
-
-    if (hIntDevInfo == INVALID_HANDLE_VALUE) {
-       write_log ("SetupDiGetClassDevs failed with error: %d\n", GetLastError());
-       return;
-    }
-
-    interfaceData.cbSize = sizeof (SP_INTERFACE_DEVICE_DATA);
-
-    status = SetupDiEnumDeviceInterfaces ( 
-               hIntDevInfo,            // Interface Device Info handle
-               0,
-               (LPGUID) &StoragePortClassGuid,
-               index,                  // Member
-               &interfaceData          // Device Interface Data
-               );
-
-    if (status == FALSE) {
-       errorCode = GetLastError();
-       if (errorCode == ERROR_NO_MORE_ITEMS)
-           return;
-       write_log ("SetupDiEnumDeviceInterfaces failed with error: %d\n", errorCode);
-       return;
-    }
-       
-    //
-    // Find out required buffer size, so pass NULL 
-    //
-
-    status = SetupDiGetDeviceInterfaceDetail (
-               hIntDevInfo,        // Interface Device info handle
-               &interfaceData,     // Interface data for the event class
-               NULL,               // Checking for buffer size
-               0,                  // Checking for buffer size
-               &reqSize,           // Buffer size required to get the detail data
-               NULL                // Checking for buffer size
-               );
-
-    //
-    // This call returns ERROR_INSUFFICIENT_BUFFER with reqSize 
-    // set to the required buffer size. Ignore the above error and
-    // pass a bigger buffer to get the detail data
-    //
-
-    if (status == FALSE) {
-       errorCode = GetLastError();
-       if (errorCode != ERROR_INSUFFICIENT_BUFFER) {
-           write_log ("SetupDiGetDeviceInterfaceDetail failed with error: %d\n", errorCode);
-           return;
-       }
-    }
-
-    //
-    // Allocate memory to get the interface detail data
-    // This contains the devicepath we need to open the device
-    //
-
-    interfaceDetailDataSize = reqSize;
-    interfaceDetailData = malloc (interfaceDetailDataSize);
-    if (interfaceDetailData == NULL) {
-       write_log ("Unable to allocate memory to get the interface detail data.\n");
-       return;
-    }
-    interfaceDetailData->cbSize = sizeof (SP_INTERFACE_DEVICE_DETAIL_DATA);
-
-    status = SetupDiGetDeviceInterfaceDetail (
-                 hIntDevInfo,              // Interface Device info handle
-                 &interfaceData,           // Interface data for the event class
-                 interfaceDetailData,      // Interface detail data
-                 interfaceDetailDataSize,  // Interface detail data size
-                 &reqSize,                 // Buffer size required to get the detail data
-                 NULL);                    // Interface device info
-
-    if (status == FALSE) {
-       write_log ("Error in SetupDiGetDeviceInterfaceDetail failed with error: %d\n", GetLastError());
-       return;
-    }
-
-    //
-    // Now we have the device path. Open the device interface
-    // to get adapter property and inquiry data
-
-
-    hDevice = CreateFile(
-               interfaceDetailData->DevicePath,    // device interface name
-               GENERIC_READ | GENERIC_WRITE,       // dwDesiredAccess
-               FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
-               NULL,                               // lpSecurityAttributes
-               OPEN_EXISTING,                      // dwCreationDistribution
-               0,                                  // dwFlagsAndAttributes
-               NULL                                // hTemplateFile
-               );
-               
-    //
-    // We have the handle to talk to the device. 
-    // So we can release the interfaceDetailData buffer
-    //
-
-    free (interfaceDetailData);
-
-    if (hDevice == INVALID_HANDLE_VALUE) {
-       write_log ("CreateFile failed with error: %d\n", GetLastError());
-       CloseHandle ( hDevice );        
-       return;
-    }
-
-    query.PropertyId = StorageAdapterProperty;
-    query.QueryType = PropertyStandardQuery;
-
-    status = DeviceIoControl(
-                       hDevice,                
-                       IOCTL_STORAGE_QUERY_PROPERTY,
-                       &query,
-                       sizeof(STORAGE_PROPERTY_QUERY),
-                       &outBuf,                   
-                       512,                      
-                       &returnedLength,      
-                       NULL                    
-                       );
-    if (!status) {
-       write_log ("IOCTL failed with error code%d.\n\n", GetLastError());
-    } else {
-       adpDesc = (PSTORAGE_ADAPTER_DESCRIPTOR) outBuf;
-       write_log ("\nAdapter Properties\n");
-       write_log ("------------------\n");
-       write_log ("Bus Type       : %s\n",   BusType[adpDesc->BusType]);
-       write_log ("Max. Tr. Length: 0x%x\n", adpDesc->MaximumTransferLength );
-       write_log ("Max. Phy. Pages: 0x%x\n", adpDesc->MaximumPhysicalPages );
-       write_log ("Alignment Mask : 0x%x\n", adpDesc->AlignmentMask );
-    }
-    
-    AdapterInfo = (PSCSI_ADAPTER_BUS_INFO) malloc(SCSI_INFO_BUFFER_SIZE) ;
-    if (AdapterInfo == NULL) {
-       CloseHandle (hDevice);  
-       return;
-    }
-
-    // Get the SCSI inquiry data for all devices for the given SCSI bus
-    status = DeviceIoControl(  
-                           hDevice,
-                           IOCTL_SCSI_GET_INQUIRY_DATA,
-                           NULL,
-                           0,
-                           AdapterInfo,
-                           SCSI_INFO_BUFFER_SIZE,
-                           &returnedLength,
-                           NULL );
-
-    if (!status) {
-       write_log ("Error in IOCTL_SCSI_GET_INQUIRY_DATA\n" );
-       free (AdapterInfo);
-       CloseHandle (hDevice);
-       return;
-    }
-
-    write_log ("Initiator   Path ID  Target ID    LUN  Claimed  Device   \n");
-    write_log ("---------------------------------------------------------\n");
-
-    for (Bus = 0; Bus < AdapterInfo->NumberOfBuses; Bus++) {
-       int luncheck = 0;
-       BusData = &AdapterInfo->BusData[Bus];
-       InquiryData = (PSCSI_INQUIRY_DATA) ( (PUCHAR) AdapterInfo + BusData->InquiryDataOffset );
-       for (Luns = 0; Luns < BusData->NumberOfLogicalUnits; Luns++) {
-           char label[100];
-           int type = InquiryData->InquiryData[0] & 0x1f;
-           Claimed = InquiryData->DeviceClaimed;
-           write_log ("   %3d        %d         %d          %d     %s     %d\n",
-               BusData->InitiatorBusId, InquiryData->PathId, InquiryData->TargetId, 
-               InquiryData->Lun, Claimed ? "Yes" : "No ", type);
-           if (Claimed == 0 && !luncheck && type != INQ_DASD) {
-               luncheck = 1;
-               sprintf (label, "SCSI(%d):%d:%d:%d:%d", idx, BusData->InitiatorBusId,
-                   InquiryData->PathId, InquiryData->TargetId, InquiryData->Lun);
-               adddrive (label, idx, InquiryData->PathId, InquiryData->TargetId, InquiryData->Lun);
-           }
-           InquiryData = (PSCSI_INQUIRY_DATA) ( (PUCHAR) AdapterInfo + InquiryData->NextInquiryDataOffset );
-       }   // for Luns
-    }  // for Bus
-
-    write_log ("\n" );
-    free (AdapterInfo);
-    CloseHandle (hDevice);
-}
-
-#if 0
-static void GetChildDevices(DEVINST DevInst)
-{
-    DEVINST         childDevInst;
-    DEVINST         siblingDevInst;
-    CONFIGRET       configRetVal;
-    TCHAR           deviceInstanceId[MAX_DEVICE_ID_LEN];
-//    HDEVINFO     tmpdi;
-
-    configRetVal = CM_Get_Child (
-                       &childDevInst,
-                       DevInst,
-                       0 );
-
-    if (configRetVal == CR_NO_SUCH_DEVNODE) {
-       write_log ("No child devices\n");
-       return;
-    }
-
-    if (configRetVal != CR_SUCCESS) {
-       write_log ("CM_Get_Child failed with error: %x\n", configRetVal);
-       return;
-    }
-
-    do {
-
-       // Get the Device Instance ID using the handle
-       configRetVal = CM_Get_Device_ID(
-                           childDevInst,
-                           deviceInstanceId,
-                           sizeof(deviceInstanceId)/sizeof(TCHAR),
-                           0
-                           );
-       if (configRetVal != CR_SUCCESS) {
-           write_log ("CM_Get_Device_ID: Get Device Instance ID failed with error: %x\n", configRetVal);
-           return;
-       }
-
-       write_log ("'%s'\n", deviceInstanceId);
-#if 0
-       tmpdi = SetupDiCreateDeviceInfoList (NULL, NULL);
-       if (tmpdi) {
-           SP_DEVINFO_DATA did;
-           did.cbSize = sizeof (did);
-           SetupDiOpenDeviceInfo(tmpdi, deviceInstanceId, NULL, 0, &did);
-           adddrive (deviceInstanceId, -1, -1, -1, -1);
-           SetupDiDestroyDeviceInfoList (tmpdi);
-       }
-#endif
-       // Get sibling
-       configRetVal = CM_Get_Sibling (
-                           &siblingDevInst,
-                           childDevInst,
-                           0 );
-
-       if (configRetVal == CR_NO_SUCH_DEVNODE)
-           return;
-
-       if (configRetVal != CR_SUCCESS) {
-           write_log ("CM_Get_Sibling failed with error: 0x%X\n", configRetVal);
-           return;
-       }
-       childDevInst = siblingDevInst;
-
-    } while (TRUE);
-
-}
-#endif
-
-static BOOL GetRegistryProperty(HDEVINFO DevInfo, DWORD Index, int *first)
-{
-    SP_DEVINFO_DATA deviceInfoData;
-    DWORD errorCode;
-    DWORD bufferSize = 0;
-    DWORD dataType;
-    LPTSTR buffer = NULL;
-    BOOL status;
-    CONFIGRET configRetVal;
-    TCHAR deviceInstanceId[MAX_DEVICE_ID_LEN];
-
-    // Get the DEVINFO data. This has the handle to device instance 
-    deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
-    status = SetupDiEnumDeviceInfo(
-       DevInfo,                // Device info set
-       Index,                  // Index in the info set
-       &deviceInfoData);       // Info data. Contains handle to dev inst
-
-    if (status == FALSE) {
-        errorCode = GetLastError();
-       if (errorCode == ERROR_NO_MORE_ITEMS) {
-           if (*first)
-               write_log ("SPTI: No SCSI adapters detected\n");
-           return FALSE;
-       }
-       write_log ("SetupDiEnumDeviceInfo failed with error: %d\n", errorCode);
-        return FALSE;
-    }
-    *first = 0;
-
-    // Get the Device Instance ID using the handle
-    configRetVal = CM_Get_Device_ID(
-       deviceInfoData.DevInst,                 // Handle to dev inst
-       deviceInstanceId,                       // Buffer to receive dev inst
-       sizeof(deviceInstanceId)/sizeof(TCHAR), // Buffer size
-       0);                                     // Must be zero
-    if (configRetVal != CR_SUCCESS) {
-        write_log ("CM_Get_Device_ID failed with error: %d\n", configRetVal);
-        return FALSE;
-    }
-
-    //
-    // We won't know the size of the HardwareID buffer until we call
-    // this function. So call it with a null to begin with, and then 
-    // use the required buffer size to Alloc the necessary space.
-    // Call it again with the obtained buffer size
-    //
-    status = SetupDiGetDeviceRegistryProperty(
-       DevInfo,
-       &deviceInfoData,
-       SPDRP_HARDWAREID,
-       &dataType,
-       (PBYTE)buffer,
-       bufferSize,
-       &bufferSize);
-
-    if (status == FALSE) {
-       errorCode = GetLastError();
-       if (errorCode != ERROR_INSUFFICIENT_BUFFER) {
-           if (errorCode == ERROR_INVALID_DATA) {
-               //
-               // May be a Legacy Device with no HardwareID. Continue.
-               //
-               write_log ("No Hardware ID, may be a legacy device!\n");
-       } else {
-               write_log ("SetupDiGetDeviceRegistryProperty failed with error: %d\n", errorCode);
-               return FALSE;
-           }
-       }
-    }
-
-    //
-    // We need to change the buffer size.
-    //
-    buffer = LocalAlloc(LPTR, bufferSize);
-    status = SetupDiGetDeviceRegistryProperty(
-       DevInfo,
-       &deviceInfoData,
-       SPDRP_HARDWAREID,
-       &dataType,
-       (PBYTE)buffer,
-       bufferSize,
-       &bufferSize);
-
-    if (status == FALSE) {
-       errorCode = GetLastError();
-       if (errorCode == ERROR_INVALID_DATA) {
-           //
-           // May be a Legacy Device with no HardwareID. Continue.
-           //
-           write_log ("No Hardware ID, may be a legacy device!\n");
-       } else {
-           write_log ("SetupDiGetDeviceRegistryProperty failed with error: %d\n", errorCode);
-           return FALSE;
-       }
-    }
-    write_log ("Device ID '%s'\n",buffer);
-
-    if (buffer)
-        LocalFree(buffer);
-
-    // **** Now get the Device Description
-
-    //
-    // We won't know the size of the Location Information buffer until
-    // we call this function. So call it with a null to begin with,
-    // and then use the required buffer size to Alloc the necessary space.
-    // Call it again with the obtained buffer size
-    //
-
-    status = SetupDiGetDeviceRegistryProperty(
-       DevInfo,
-       &deviceInfoData,
-       SPDRP_DEVICEDESC,
-       &dataType,
-       (PBYTE)buffer,
-       bufferSize,
-       &bufferSize);
-
-    if (status == FALSE) {
-       errorCode = GetLastError();
-       if (errorCode != ERROR_INSUFFICIENT_BUFFER) {
-           if (errorCode == ERROR_INVALID_DATA) {
-               write_log("No Device Description!\n");
-           } else {
-               write_log("SetupDiGetDeviceRegistryProperty failed with error: %d\n", errorCode);
-               return FALSE;
-           }
-       }
-    }
-
-    //
-    // We need to change the buffer size.
-    //
-
-    buffer = LocalAlloc(LPTR, bufferSize);
-    
-    status = SetupDiGetDeviceRegistryProperty(
-       DevInfo,
-       &deviceInfoData,
-       SPDRP_DEVICEDESC,
-       &dataType,
-       (PBYTE)buffer,
-       bufferSize,
-       &bufferSize);
-
-    if (status == FALSE) {
-       errorCode = GetLastError();
-       if (errorCode == ERROR_INVALID_DATA) {
-           write_log ("No Device Description!\n");
-       } else {
-           write_log ("SetupDiGetDeviceRegistryProperty failed with error: %d\n", errorCode);
-           return FALSE;
-       }
-    }
-
-    write_log ("Device Description '%s'\n",buffer);
-
-    if (buffer)
-        LocalFree(buffer);
-
-    // Reenumerate the SCSI adapter device node
-    configRetVal = CM_Reenumerate_DevNode(deviceInfoData.DevInst, 0);
-    
-    if (configRetVal != CR_SUCCESS) {
-       write_log ("CM_Reenumerate_DevNode failed with error: %d\n", configRetVal);
-       return FALSE;
-    }
-
-    GetInquiryData ((PCTSTR)&deviceInstanceId, Index);
-#if 0
-    // Find the children devices
-    GetChildDevices (deviceInfoData.DevInst);
-#endif
-    return TRUE;
-}
-
 static int getCDROMProperty(int idx, HDEVINFO DevInfo, const GUID *guid)
 {
     SP_DEVICE_INTERFACE_DATA interfaceData;
@@ -992,28 +512,113 @@ static int getCDROMProperty(int idx, HDEVINFO DevInfo, const GUID *guid)
     if (status == FALSE)
        return FALSE;
 
-    adddrive (interfaceDetailData->DevicePath, -1, -1, -1, -1);
+    adddrive (interfaceDetailData->DevicePath, -1, -1, -1, -1, 1);
 
     free (interfaceDetailData);
 
     return TRUE;
 }
 
+#define        SCSI_INFO_BUFFER_SIZE 0x5000
+static void scanscsi(void)
+{
+    PSCSI_BUS_DATA BusData;
+    PSCSI_INQUIRY_DATA InquiryData;
+    PSCSI_ADAPTER_BUS_INFO AdapterInfo;
+    HANDLE h;
+    BOOL status;
+    BOOL Claimed;
+    ULONG returnedLength;
+    SHORT Bus, Luns;
+    DWORD bytesTransferred;
+    int idx;
+    char DeviceName[256];
+
+    AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)xmalloc(SCSI_INFO_BUFFER_SIZE) ;
+    if (AdapterInfo == NULL)
+       return;
+
+    idx = 0;
+    for (;;) {
+        sprintf(DeviceName, "\\\\.\\Scsi%d:", idx++);
+        h = CreateFile (DeviceName,
+           GENERIC_READ | GENERIC_WRITE,
+           0,
+           NULL, // no SECURITY_ATTRIBUTES structure
+           OPEN_EXISTING, // No special create flags
+           0, // No special attributes
+           NULL);
+       if (h == INVALID_HANDLE_VALUE)
+           return;
+
+       if(!DeviceIoControl(h,
+           IOCTL_SCSI_RESCAN_BUS,
+           NULL,
+           0,
+           NULL,
+           0,
+           &bytesTransferred,
+           NULL)) {
+           write_log( "Rescan SCSI port %d failed [Error %d]\n", idx - 1, GetLastError());
+           CloseHandle(h);
+            continue;
+        }
+
+       // Get the SCSI inquiry data for all devices for the given SCSI bus
+       status = DeviceIoControl(       
+           h,
+           IOCTL_SCSI_GET_INQUIRY_DATA,
+           NULL,
+           0,
+           AdapterInfo,
+           SCSI_INFO_BUFFER_SIZE,
+           &returnedLength,
+           NULL);
+
+       if (!status) {
+           write_log ("Error in IOCTL_SCSI_GET_INQUIRY_DATA\n" );
+           CloseHandle (h);
+           continue;
+       }
+
+       for (Bus = 0; Bus < AdapterInfo->NumberOfBuses; Bus++) {
+           int luncheck = 0;
+           BusData = &AdapterInfo->BusData[Bus];
+           InquiryData = (PSCSI_INQUIRY_DATA) ( (PUCHAR) AdapterInfo + BusData->InquiryDataOffset );
+           for (Luns = 0; Luns < BusData->NumberOfLogicalUnits; Luns++) {
+               char label[100];
+               int type = InquiryData->InquiryData[0] & 0x1f;
+               Claimed = InquiryData->DeviceClaimed;
+               write_log ("SCSI=%d Initiator=%d Path=%d Target=%d LUN=%d Claimed=%s Type=%d\n",
+                   idx - 1,
+                   BusData->InitiatorBusId, InquiryData->PathId, InquiryData->TargetId, 
+                   InquiryData->Lun, Claimed ? "Yes" : "No ", type);
+               if (Claimed == 0 && !luncheck) {
+                   luncheck = 1;
+                   sprintf (label, "SCSI(%d):%d:%d:%d:%d", idx - 1, BusData->InitiatorBusId,
+                       InquiryData->PathId, InquiryData->TargetId, InquiryData->Lun);
+                   adddrive (label, idx - 1, InquiryData->PathId, InquiryData->TargetId, InquiryData->Lun, 3);
+               }
+               InquiryData = (PSCSI_INQUIRY_DATA) ( (PUCHAR) AdapterInfo + InquiryData->NextInquiryDataOffset );
+           }   // for Luns
+       }       // for Bus
+       CloseHandle(h);
+    }
+}
+
 static const GUID *guids[] = {
     &GUID_DEVINTERFACE_CDROM,
     &GUID_DEVCLASS_IMAGE,
     &GUID_DEVCLASS_TAPEDRIVE,
     NULL };
-static const char *scsinames[] = { "Tape", "Scanner", NULL };
+static const char *scsinames[] = { "Tape", "Scanner", "Changer", NULL };
 
 static int rescan(void)
 {
-    HDEVINFO hDevInfo;
     int idx, idx2;
-    int first;
 
     for (idx2 = 0; guids[idx2]; idx2++) {
-       hDevInfo = SetupDiGetClassDevs(
+       HDEVINFO hDevInfo = SetupDiGetClassDevs(
            guids[idx2],
            NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
        if (hDevInfo != INVALID_HANDLE_VALUE) {
@@ -1024,37 +629,27 @@ static int rescan(void)
            SetupDiDestroyDeviceInfoList(hDevInfo);
        }
     }
-#if 0
+
     for (idx2 = 0; scsinames[idx2]; idx2++) {
        int max = 10;
        for (idx = 0; idx < max; idx++) {
            char tmp[100];
            HANDLE h;
            sprintf (tmp, "\\\\.\\%s%d", scsinames[idx2], idx);
-           write_log("SPTI: %s\n", tmp);
            h = CreateFile(tmp, GENERIC_READ | GENERIC_WRITE,
                FILE_SHARE_READ | FILE_SHARE_WRITE,
                NULL, OPEN_EXISTING, 0, NULL);
            if (h != INVALID_HANDLE_VALUE) {
-               adddrive(tmp, -1, -1, -1, -1);
+               adddrive(tmp, -1, -1, -1, -1, 2);
                CloseHandle(h);
                if (idx == max - 1)
                    max++;
            }
        }
     }
-#endif
     if (currprefs.win32_uaescsimode == UAESCSI_SPTISCAN) {
        write_log("SCSI adapter enumeration..\n");
-       first = 1;
-       hDevInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_SCSIADAPTER, NULL, NULL, DIGCF_PRESENT);
-       if (hDevInfo != INVALID_HANDLE_VALUE) {
-           for (idx = 0; ; idx++) {
-               if (!GetRegistryProperty(hDevInfo, idx, &first))
-                   break;
-           }
-       }
-       SetupDiDestroyDeviceInfoList(hDevInfo);
+       scanscsi();
        write_log("SCSI adapter enumeration ends\n");
     }
     return 1;
index 12f00c7f768b63111b2eb7707ecacdc301dab3bf..24c2744a61175b4c23256f5b9f37ac5267be3455 100755 (executable)
@@ -765,13 +765,21 @@ int setbaud (long baud)
     return 1;
 }
 
+void initparallel (void)
+{
+    uaecptr a = here (); //this install the ahisound
+    org (RTAREA_BASE + 0xFFC0);
+    calltrap (deftrap (ahi_demux));
+    dw (0x4e75);// rts
+    org (a);
+}
+
 void hsyncstuff(void)
 //only generate Interrupts when 
 //writebuffer is complete flushed
 //check state of lwin rwin
 {
     static int keycheck = 0;
-    static int installahi;
     
 #ifdef AHI
     { //begin ahi_sound
@@ -784,15 +792,6 @@ void hsyncstuff(void)
                count = 0;
            }
        }
-       if (!installahi)
-       { 
-           uaecptr a = here (); //this install the ahisound
-           org (RTAREA_BASE + 0xFFC0);
-           calltrap (deftrap (ahi_demux));
-           dw (0x4e75);// rts
-           org (a);
-           installahi=1;
-       }
     } //end ahi_sound
 #endif
 #ifdef PARALLEL_PORT
index dc926adec69504327e6aff08c9d2bb2ffb5e5b78..8fdb8e637fc316a1c74e58f9723547b4be8691ac 100755 (executable)
@@ -22,7 +22,7 @@ extern int manual_palette_refresh_needed;
 extern int mouseactive, focus;
 extern int ignore_messages_all;
 #define WINUAEBETA 1
-#define WINUAEBETASTR " Beta 1"
+#define WINUAEBETASTR " Beta 2"
 
 extern char start_path_exe[MAX_DPATH];
 extern char start_path_data[MAX_DPATH];
index 65c29dd4b76025946432accf8beea47e31ba981d..38af8522033385cd04573917867654b8989c4cb7 100755 (executable)
@@ -4329,7 +4329,7 @@ static void enable_for_miscdlg (HWND hDlg)
 #endif
 #if !defined (SCSIEMU)
        EnableWindow (GetDlgItem(hDlg, IDC_SCSIDEVICE), FALSE);
-       EnableWindow (GetDlgItem (hDlg, IDC_SCSIMODE), workprefs.scsi ? TRUE : FALSE);
+       EnableWindow (GetDlgItem(hDlg, IDC_SCSIMODE), TRUE);
 #endif
        if (workprefs.win32_logfile)
            EnableWindow (GetDlgItem (hDlg, IDC_ILLEGAL), TRUE);
@@ -5976,9 +5976,9 @@ static void floppytooltip (HWND hDlg, int num, uae_u32 crc32)
 
 static void addfloppyhistory (HWND hDlg, HKEY fkey, int n, int f_text)
 {
-    int i;
+    int i, j;
     char *s;
-    char tmp[1000];
+    char tmp[MAX_DPATH];
     int nn = workprefs.dfxtype[n] + 1;
 
     if (f_text < 0)
@@ -5987,11 +5987,37 @@ static void addfloppyhistory (HWND hDlg, HKEY fkey, int n, int f_text)
     SendDlgItemMessage(hDlg, f_text, WM_SETTEXT, 0, (LPARAM)workprefs.df[n]); 
     i = 0;
     while (s = DISK_history_get (i)) {
+#if 1
+       char tmpname[MAX_DPATH], tmppath[MAX_DPATH], *p, *p2;
+#endif
        i++;
        if (strlen (s) == 0)
            continue;
+#if 1
+       strcpy (tmppath, s);
+        p = tmppath + strlen(tmppath) - 1;
+       for (j = 0; archive_extensions[j]; j++) {
+           p2 = strstr (tmppath, archive_extensions[j]);
+           if (p2) {
+               p = p2;
+               break;
+           }
+       }
+        while (p > tmppath) {
+           if (*p == '\\' || *p == '/')
+               break;
+           p--;
+       }
+       strcpy (tmpname, p + 1);
+       *++p = 0;
+       if (tmppath[0]) {
+           strcat (tmpname, " { ");
+           strcat (tmpname, tmppath);
+           strcat (tmpname, " }");
+       }
+#endif
        if (f_text >= 0)
-           SendDlgItemMessage (hDlg, f_text, CB_ADDSTRING, 0, (LPARAM)s);
+           SendDlgItemMessage (hDlg, f_text, CB_ADDSTRING, 0, (LPARAM)tmpname);
        if (fkey) {
            sprintf (tmp, "Image%02d", i);
            RegSetValueEx (fkey, tmp, 0, REG_SZ, (CONST BYTE *)s, strlen(s) + 1);
@@ -6077,8 +6103,13 @@ static int getfloppybox (HWND hDlg, int f_text, char *out, int maxlen)
     if (val == CB_ERR) {
        SendDlgItemMessage (hDlg, f_text, WM_GETTEXT, (WPARAM)maxlen, (LPARAM)out);
     } else {
+       char *p = DISK_history_get (val);
+#if 0
        val = SendDlgItemMessage (hDlg, f_text, CB_GETLBTEXT, (WPARAM)val, (LPARAM)out);
        if (val != CB_ERR && val > 0) {
+#endif
+       if (p) {
+           strcpy (out, p);
            if (out[0]) {
                /* add to top of list */
                DISK_history_add (out, -1);
diff --git a/zfile.c b/zfile.c
index fce5481e56f85f79aecfa4f33d5c13c313dac123..9de411728779108f6e5855eb277fcb508f28aec6 100755 (executable)
--- a/zfile.c
+++ b/zfile.c
@@ -36,6 +36,8 @@ struct zfile {
 
 static struct zfile *zlist = 0;
 
+char *archive_extensions[] = { "zip", "rar", "7z", NULL };
+
 static struct zfile *zfile_create (void)
 {
     struct zfile *z;