public override StorApiStatus UpdateDrives() { StorApiStatus result = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; if (this.drives != null) { this.drives.Clear(); } for (byte b2 = 0; b2 < 128; b2 += 1) { MvApi.MvApi.HD_Info_Request hd_Info_Request = default(MvApi.MvApi.HD_Info_Request); hd_Info_Request.header.Init(); hd_Info_Request.header.requestType = 2; hd_Info_Request.header.startingIndexOrId = (short)b2; hd_Info_Request.header.numRequested = 1; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PD_GetHDInfo_Ext(this.AdapterId, ref hd_Info_Request); } catch (Exception ex) { Logger.Warn("MV_PD_GetHDInfo_Ext exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } Storage.Debug("MV_PD_GetHDInfo_Ext: mvstatus={0}", new object[] { b }); if (b == 0) { Storage.Debug("numReturned: {0}", new object[] { hd_Info_Request.header.numReturned }); if (hd_Info_Request.header.numReturned == 1) { if (this.drives == null) { this.drives = new List <Drive>(); } MvApi.MvApi.HD_Info hdInfo = hd_Info_Request.hdInfo[0]; this.drives.Add(this.MakeDrive(hdInfo)); } } } return(result); }
protected DrivePort GetDrivePort(MvApi.MvApi.HD_Info hdInfo) { DrivePort drivePort = new DrivePort(); if (hdInfo.Link.Parent.DevType == 255) { drivePort.ports.Add((int)hdInfo.Link.Parent.PhyID[0]); } else if (hdInfo.Link.Parent.DevType == 2) { MvApi.MvApi.PM_Info_Request pm_Info_Request = default(MvApi.MvApi.PM_Info_Request); pm_Info_Request.header.Init(); pm_Info_Request.header.requestType = 2; pm_Info_Request.header.startingIndexOrId = hdInfo.Link.Parent.DevID; pm_Info_Request.header.numRequested = 1; byte b; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PD_GetPMInfo(this.AdapterId, ref pm_Info_Request); } catch (Exception ex) { Logger.Warn("MV_PD_GetPMInfo exception: {0}", new object[] { ex }); return(drivePort); } } if (b != 0) { Storage.Debug("Failed MV_PD_GetPMInfo: mvstatus={0}", new object[] { b }); return(drivePort); } if (pm_Info_Request.header.numReturned == 1) { MvApi.MvApi.PM_Info pm_Info = pm_Info_Request.pmInfo[0]; drivePort.ports.Add((int)pm_Info.Link.Parent.PhyID[0]); drivePort.ports.Add((int)hdInfo.Link.Parent.PhyID[0]); return(drivePort); } return(drivePort); } return(drivePort); }
protected MarvellDrive MakeDrive(MvApi.MvApi.HD_Info hdInfo) { byte b = 0; StorApiStatus a = StorApiStatusEnum.STOR_NO_ERROR; MarvellDrive marvellDrive = new MarvellDrive(hdInfo.Link.Self.DevID, this); marvellDrive.Port = this.GetDrivePort(hdInfo); marvellDrive.Model = MarvellUtil.GetApiString(hdInfo.Model, 40); marvellDrive.Serial = MarvellUtil.GetApiString(hdInfo.SerialNo, 20); marvellDrive.Revision = MarvellUtil.GetApiString(hdInfo.FWVersion, 8); marvellDrive.SectorSize = (ulong)((hdInfo.BlockSize == 0u) ? 512u : hdInfo.BlockSize); marvellDrive.SectorCount = hdInfo.Size.ToUlong() * 1024UL / marvellDrive.SectorSize; marvellDrive.IsSmartEnabled = false; marvellDrive.IsSystem = false; marvellDrive.Status = DriveStatus.DRIVE_UNKNOWN; marvellDrive.Domain = DriveDomain.DRIVE_DOMAIN_UNKNOWN; short[] id = new short[] { hdInfo.Link.Self.DevID }; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_DiskHasOS(this.AdapterId, 1, 1, id); } catch (Exception ex) { Logger.Warn("MV_DiskHasOS exception: {0}", new object[] { ex }); throw ex; } } if (b == 159) { marvellDrive.IsSystem = true; } MvApi.MvApi.HD_Config_Request hd_Config_Request = default(MvApi.MvApi.HD_Config_Request); hd_Config_Request.header.Init(); hd_Config_Request.header.requestType = 2; hd_Config_Request.header.startingIndexOrId = hdInfo.Link.Self.DevID; hd_Config_Request.header.numRequested = 1; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PD_GetConfig(this.AdapterId, ref hd_Config_Request); } catch (Exception ex2) { Logger.Warn("MV_PD_GetConfig exception: {0}", new object[] { ex2 }); throw ex2; } } marvellDrive.IsSmartEnabled = (hd_Config_Request.hdConfig[0].SMARTOn == 1); if (!marvellDrive.IsSmartEnabled) { a = marvellDrive.EnableSmart(); if (a == StorApiStatusEnum.STOR_NO_ERROR) { marvellDrive.IsSmartEnabled = true; } } return(marvellDrive); }