示例#1
0
        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);
        }