Beispiel #1
0
 public static extern bool getPhyPort32(int scsiPort, ref CSMI_SAS_PHY_INFO csni_sas_phy_info);
Beispiel #2
0
 private bool getPhyPort(int scsiPort, ref CSMI_SAS_PHY_INFO csni_sas_phy_info)
 {
     return(IntPtr.Size == 8 /* 64bit */ ? getPhyPort64(scsiPort, ref csni_sas_phy_info) : getPhyPort32(scsiPort, ref csni_sas_phy_info));
 }
Beispiel #3
0
        public List <RaidInfo> GetRaidDeviceList_SATA()
        {
            List <RaidInfo> infoList = new List <RaidInfo>();

            byte[] id_buf    = new byte[512];
            byte[] smart_buf = new byte[512];
            //scan SATA raid device
            const int MAX_SEARCH_SCSI_PORT = 16;

            for (int index = 0; index < MAX_SEARCH_SCSI_PORT; index++)
            {
                CSMI_SAS_PHY_INFO csni_sas_phy_info = new CSMI_SAS_PHY_INFO();
                bool res = getPhyPort(index, ref csni_sas_phy_info);      // Get physical info of each scsi port (0 ~ MAX_SEARCH_SCSI_PORT)

                IntPtr intPtr_id    = IntPtr.Zero;                        //Pointer of ID info buffer
                IntPtr intPtr_smart = IntPtr.Zero;                        //Pointer of SMART info buffer
                IntPtr intPtr_addr  = IntPtr.Zero;                        //Pointer of SASAddress from physical entity

                for (int i = 0; i < csni_sas_phy_info.bNumberOfPhys; i++) //Get ID/SMART buffer foreach physical entity under physical info
                {
                    byte[]   id        = new byte[512];
                    GCHandle handle_id = GCHandle.Alloc(id, GCHandleType.Pinned);
                    intPtr_id = handle_id.AddrOfPinnedObject();

                    byte[]   smart        = new byte[512];
                    GCHandle handle_smart = GCHandle.Alloc(smart, GCHandleType.Pinned);
                    intPtr_smart = handle_smart.AddrOfPinnedObject();

                    byte[]   addr        = Encoding.GetEncoding("UTF-8").GetBytes(csni_sas_phy_info.Phy[i].Attached.bSASAddress);
                    GCHandle handle_addr = GCHandle.Alloc(addr, GCHandleType.Pinned);
                    intPtr_addr = handle_addr.AddrOfPinnedObject();

                    //Use physical entity contents to get ID/SMART buffer
                    res = getIdSmart(index, csni_sas_phy_info.Phy[i].Attached.bPhyIdentifier, csni_sas_phy_info.Phy[i].bPortIdentifier, intPtr_addr, intPtr_id, intPtr_smart);

                    if (res)
                    {
                        Marshal.Copy(id, 0, intPtr_id, id.Length);
                        Marshal.Copy(smart, 0, intPtr_smart, smart.Length);
                        string Model_number = "";
                        Model_number = UtilityClass.getModelName(id, false);
                        Model_number = Model_number.Replace("\0", "").Trim();

                        if (Model_number.Length > 0)
                        {
                            string ctlName = "";
                            for (int j = 400; j < 410; j = j + 2)   //get controller
                            {
                                if (smart[j] != 0 || smart[j + 1] != 0)
                                {
                                    ctlName = string.Concat(ctlName, Convert.ToString((char)smart[j]), Convert.ToString((char)smart[j + 1]));
                                }
                            }
                            if (ctlName.IndexOf("\0", StringComparison.OrdinalIgnoreCase) != -1)
                            {
                                ctlName = ctlName.Replace("\0", "");
                            }

                            RaidInfo info = new RaidInfo();
                            info.id    = id;
                            info.smart = smart;
                            info.ctl   = ctlName.Trim();;

                            infoList.Add(info);
                        }
                    }
                }
            }
            return(infoList);
        }