Ignore:
Timestamp:
Sep 14, 2000, 9:08:36 PM (25 years ago)
Author:
sandervl
Message:

implemented IOCTL_SCSI_GET_ADDRESS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmdisk.cpp

    r4257 r4259  
    1 /* $Id: hmdisk.cpp,v 1.2 2000-09-13 21:14:18 sandervl Exp $ */
     1/* $Id: hmdisk.cpp,v 1.3 2000-09-14 19:08:36 sandervl Exp $ */
    22
    33/*
     
    1010 *
    1111 */
    12 #define INCL_DOSPROFILE
    13 #define INCL_DOSDEVICES
    14 #define INCL_DOSDEVIOCTL
    15 #define INCL_GPI
    16 #define INCL_DOSFILEMGR          /* File Manager values      */
    17 #define INCL_DOSERRORS           /* DOS Error values         */
    18 #define INCL_DOSPROCESS          /* DOS Process values       */
    19 #define INCL_DOSMISC             /* DOS Miscellanous values  */
    20 #include <os2wrap.h>    //Odin32 OS/2 api wrappers
     12#include <os2win.h>
    2113#include <string.h>
    2214
    23 #include <win32type.h>
    24 #include <win32api.h>
    2515#include <misc.h>
    2616#include "hmdisk.h"
     
    2818#include <win\winioctl.h>
    2919#include <win\ntddscsi.h>
     20#include <win\wnaspi32.h>
     21#include <win\aspi.h>
    3022
    3123#define DBG_LOCALLOG    DBG_hmdisk
     
    6860  {
    6961        pHMHandleData->hHMHandle  = hFile;
     62        pHMHandleData->dwUserData = GetDriveTypeA(lpFileName);
    7063        return (NO_ERROR);
    7164  }
     
    131124        case IOCTL_SCSI_GET_ADDRESS:
    132125        {
     126         HINSTANCE hInstAspi;
     127         DWORD (WIN32API *GetASPI32SupportInfo)();
     128         DWORD (CDECL *SendASPI32Command)(LPSRB lpSRB);
     129         DWORD numAdapters, rc;
     130         SRB   srb;
     131         int   i, j, k;
     132
    133133                if(!lpOutBuffer || nOutBufferSize < 8) {
    134                         SetLastError(ERROR_INSUFFICIENT_BUFFER_W);  //todo: right error?
     134                        SetLastError(ERROR_INSUFFICIENT_BUFFER);  //todo: right error?
    135135                        return(FALSE);
    136136                }
    137                 //TODO: Not finished yet (need to query id + lun of drive)
    138137                SCSI_ADDRESS *addr = (SCSI_ADDRESS *)lpOutBuffer;
    139138                addr->Length = sizeof(SCSI_ADDRESS);
    140139                addr->PortNumber = 0;
    141140                addr->PathId     = 0;
    142                 addr->TargetId   = 1;
    143                 addr->Lun        = 3;
     141                hInstAspi = LoadLibraryA("WNASPI32.DLL");
     142                if(hInstAspi == NULL) {
     143                        SetLastError(ERROR_INVALID_PARAMETER); //todo
     144                        return FALSE;
     145                }
     146                *(FARPROC *)&GetASPI32SupportInfo = GetProcAddress(hInstAspi, "GetASPI32SupportInfo");
     147                *(FARPROC *)&SendASPI32Command    = GetProcAddress(hInstAspi, "SendASPI32Command");
     148                numAdapters = GetASPI32SupportInfo();
     149                if(LOBYTE(numAdapters) == 0) goto failure;
     150
     151                memset(&srb, 0, sizeof(srb));
     152                srb.common.SRB_Cmd = SC_HA_INQUIRY;
     153                rc = SendASPI32Command(&srb);
     154
     155                for(i=0;i<LOBYTE(numAdapters);i++) {
     156                        for(j=0;j<8;j++) {
     157                                for(k=0;k<16;k++) {
     158                                        memset(&srb, 0, sizeof(srb));
     159                                        srb.common.SRB_Cmd     = SC_GET_DEV_TYPE;
     160                                        srb.devtype.SRB_HaId   = i;
     161                                        srb.devtype.SRB_Target = j;
     162                                        srb.devtype.SRB_Lun    = k;
     163                                        rc = SendASPI32Command(&srb);
     164                                        if(rc == SS_COMP) {
     165                                                if(srb.devtype.SRB_DeviceType == SS_DEVTYPE_CDROM &&
     166                                                   pHMHandleData->dwUserData == DRIVE_CDROM)
     167                                                {
     168                                                        goto done;
     169                                                }
     170                                        }
     171                                }
     172                        }
     173                }
     174done:
     175                if(rc == SS_COMP) {
     176                        addr->TargetId   = j;
     177                        addr->Lun        = k;
     178                        SetLastError(ERROR_SUCCESS);
     179                }
     180                else    SetLastError(ERROR_FILE_NOT_FOUND); //todo
     181                FreeLibrary(hInstAspi);
    144182                return TRUE;
     183failure:
     184                FreeLibrary(hInstAspi);
     185                SetLastError(ERROR_INVALID_PARAMETER); //todo
     186                return FALSE;
    145187        }
     188
    146189        case IOCTL_SCSI_RESCAN_BUS:
    147190        case IOCTL_SCSI_GET_DUMP_POINTERS:
     
    152195   }
    153196   dprintf(("HMDeviceDiskClass::DeviceIoControl: unimplemented dwIoControlCode=%08lx\n", dwIoControlCode));
    154    SetLastError( ERROR_CALL_NOT_IMPLEMENTED_W );
     197   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    155198   return FALSE;
    156199}
Note: See TracChangeset for help on using the changeset viewer.