Changeset 50094 in vbox
- Timestamp:
- Jan 17, 2014 2:17:53 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r50084 r50094 508 508 509 509 510 /** Helper that finds out the next SATA port used510 /** Helper that finds out the next HBA port used 511 511 */ 512 static LONG GetNextUsed SataPort(LONG aSataPortUsed[30], LONG lBaseVal, uint32_t u32Size)512 static LONG GetNextUsedPort(LONG aPortUsed[30], LONG lBaseVal, uint32_t u32Size) 513 513 { 514 514 LONG lNextPortUsed = 30; 515 515 for (size_t j = 0; j < u32Size; ++j) 516 516 { 517 if ( a SataPortUsed[j] > lBaseVal518 && a SataPortUsed[j] <= lNextPortUsed)519 lNextPortUsed = a SataPortUsed[j];517 if ( aPortUsed[j] > lBaseVal 518 && aPortUsed[j] <= lNextPortUsed) 519 lNextPortUsed = aPortUsed[j]; 520 520 } 521 521 return lNextPortUsed; 522 } 523 524 #define MAX_BIOS_LUN_COUNT 4 525 526 static int SetBiosDiskInfo(ComPtr<IMachine> pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg, 527 Bstr controllerName, const char * const s_apszBiosConfig[4]) 528 { 529 HRESULT hrc; 530 #define MAX_DEVICES 30 531 #define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_GENERAL_FAILURE) 532 533 LONG lPortLUN[MAX_BIOS_LUN_COUNT]; 534 LONG lPortUsed[MAX_DEVICES]; 535 uint32_t u32HDCount = 0; 536 537 /* init to max value */ 538 lPortLUN[0] = MAX_DEVICES; 539 540 com::SafeIfaceArray<IMediumAttachment> atts; 541 hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(), 542 ComSafeArrayAsOutParam(atts)); H(); 543 size_t uNumAttachments = atts.size(); 544 if (uNumAttachments > MAX_DEVICES) 545 { 546 LogRel(("Number of Attachments > Max=%d.\n", uNumAttachments)); 547 uNumAttachments = MAX_DEVICES; 548 } 549 550 /* Find the relevant ports/IDs, i.e the ones to which a HD is attached. */ 551 for (size_t j = 0; j < uNumAttachments; ++j) 552 { 553 IMediumAttachment *pMediumAtt = atts[j]; 554 LONG lPortNum = 0; 555 hrc = pMediumAtt->COMGETTER(Port)(&lPortNum); H(); 556 if (SUCCEEDED(hrc)) 557 { 558 DeviceType_T lType; 559 hrc = pMediumAtt->COMGETTER(Type)(&lType); H(); 560 if (SUCCEEDED(hrc) && lType == DeviceType_HardDisk) 561 { 562 /* find min port number used for HD */ 563 if (lPortNum < lPortLUN[0]) 564 lPortLUN[0] = lPortNum; 565 lPortUsed[u32HDCount++] = lPortNum; 566 LogFlowFunc(("HD port Count=%d\n", u32HDCount)); 567 } 568 569 /* Configure the hotpluggable flag for the port. */ 570 BOOL fHotPluggable = FALSE; 571 hrc = pMediumAtt->COMGETTER(HotPluggable)(&fHotPluggable); H(); 572 if (SUCCEEDED(hrc)) 573 { 574 PCFGMNODE pPortCfg; 575 char szName[24]; 576 RTStrPrintf(szName, sizeof(szName), "Port%d", lPortNum); 577 578 InsertConfigNode(pCfg, szName, &pPortCfg); 579 InsertConfigInteger(pPortCfg, "Hotpluggable", fHotPluggable ? 1 : 0); 580 } 581 } 582 } 583 584 585 /* Pick only the top 4 used HD Ports as CMOS doesn't have space 586 * to save details for all 30 ports 587 */ 588 uint32_t u32MaxPortCount = MAX_BIOS_LUN_COUNT; 589 if (u32HDCount < MAX_BIOS_LUN_COUNT) 590 u32MaxPortCount = u32HDCount; 591 for (size_t j = 1; j < u32MaxPortCount; j++) 592 lPortLUN[j] = GetNextUsedPort(lPortUsed, 593 lPortLUN[j-1], 594 u32HDCount); 595 if (pBiosCfg) 596 { 597 for (size_t j = 0; j < u32MaxPortCount; j++) 598 { 599 InsertConfigInteger(pBiosCfg, s_apszBiosConfig[j], lPortLUN[j]); 600 LogFlowFunc(("Top %d HBA ports = %s, %d\n", j, s_apszBiosConfig[j], lPortLUN[j])); 601 } 602 } 603 return VINF_SUCCESS; 522 604 } 523 605 … … 1859 1941 } 1860 1942 1943 static const char * const apszBiosConfigScsi[MAX_BIOS_LUN_COUNT] = 1944 { "ScsiLUN1", "ScsiLUN2", "ScsiLUN3", "ScsiLUN4" }; 1945 1946 static const char * const apszBiosConfigSata[MAX_BIOS_LUN_COUNT] = 1947 { "SataLUN1", "SataLUN2", "SataLUN3", "SataLUN4" }; 1948 1861 1949 switch (enmCtrlType) 1862 1950 { … … 1866 1954 1867 1955 InsertConfigInteger(pCfg, "Bootable", fBootable); 1956 1957 if (pBiosCfg) 1958 { 1959 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "lsilogicscsi"); 1960 } 1961 1962 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 1868 1963 1869 1964 /* Attach the status driver */ … … 1881 1976 InsertConfigInteger(pCfg, "Bootable", fBootable); 1882 1977 1978 if (pBiosCfg) 1979 { 1980 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "buslogic"); 1981 } 1982 1983 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 1984 1883 1985 /* Attach the status driver */ 1884 1986 Assert(cLedScsi >= 16); … … 1901 2003 if (!pBusMgr->hasPCIDevice("ahci", 1)) 1902 2004 { 1903 #define MAX_SATA_LUN_COUNT 41904 #define MAX_SATA_PORTS 301905 1906 static const char * const s_apszBiosConfig[4] =1907 { "SataLUN1", "SataLUN2", "SataLUN3", "SataLUN4" };1908 1909 LONG lPortLUN[MAX_SATA_LUN_COUNT];1910 LONG lPortUsed[MAX_SATA_PORTS];1911 uint32_t u32HDSataPortCount = 0;1912 1913 /* init to max value */1914 lPortLUN[0] = MAX_SATA_PORTS;1915 1916 2005 if (pBiosCfg) 1917 2006 { … … 1919 2008 } 1920 2009 1921 com::SafeIfaceArray<IMediumAttachment> atts; 1922 hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(), 1923 ComSafeArrayAsOutParam(atts)); H(); 1924 size_t uNumAttachments = atts.size(); 1925 if (uNumAttachments > MAX_SATA_PORTS) 1926 { 1927 LogRel(("Number of Sata Port Attachments > Max=%d.\n", uNumAttachments)); 1928 uNumAttachments = MAX_SATA_PORTS; 1929 } 1930 1931 /* find the relavant ports i.e Sata ports to which 1932 * HD is attached. 1933 */ 1934 for (size_t j = 0; j < uNumAttachments; ++j) 1935 { 1936 IMediumAttachment *pMediumAtt = atts[j]; 1937 LONG lPortNum = 0; 1938 hrc = pMediumAtt->COMGETTER(Port)(&lPortNum); H(); 1939 if (SUCCEEDED(hrc)) 1940 { 1941 DeviceType_T lType; 1942 hrc = pMediumAtt->COMGETTER(Type)(&lType); H(); 1943 if (SUCCEEDED(hrc) && lType == DeviceType_HardDisk) 1944 { 1945 /* find min port number used for HD */ 1946 if (lPortNum < lPortLUN[0]) 1947 lPortLUN[0] = lPortNum; 1948 lPortUsed[u32HDSataPortCount++] = lPortNum; 1949 LogFlowFunc(("HD Sata port Count=%d\n", u32HDSataPortCount)); 1950 } 1951 1952 /* Configure the hotpluggable flag for the port. */ 1953 BOOL fHotPluggable = FALSE; 1954 hrc = pMediumAtt->COMGETTER(HotPluggable)(&fHotPluggable); H(); 1955 if (SUCCEEDED(hrc)) 1956 { 1957 PCFGMNODE pPortCfg; 1958 char szName[24]; 1959 RTStrPrintf(szName, sizeof(szName), "Port%d", lPortNum); 1960 1961 InsertConfigNode(pCfg, szName, &pPortCfg); 1962 InsertConfigInteger(pPortCfg, "Hotpluggable", fHotPluggable ? 1 : 0); 1963 } 1964 } 1965 } 1966 1967 1968 /* Pick only the top 4 used HD Sata Ports as CMOS doesn't have space 1969 * to save details for every 30 ports 1970 */ 1971 uint32_t u32MaxPortCount = MAX_SATA_LUN_COUNT; 1972 if (u32HDSataPortCount < MAX_SATA_LUN_COUNT) 1973 u32MaxPortCount = u32HDSataPortCount; 1974 for (size_t j = 1; j < u32MaxPortCount; j++) 1975 lPortLUN[j] = GetNextUsedSataPort(lPortUsed, 1976 lPortLUN[j-1], 1977 u32HDSataPortCount); 1978 if (pBiosCfg) 1979 { 1980 for (size_t j = 0; j < u32MaxPortCount; j++) 1981 { 1982 InsertConfigInteger(pBiosCfg, s_apszBiosConfig[j], lPortLUN[j]); 1983 LogFlowFunc(("Top %d ports = %s, %d\n", j, s_apszBiosConfig[j], lPortLUN[j])); 1984 } 1985 } 2010 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigSata); H(); 1986 2011 } 1987 2012 … … 2041 2066 InsertConfigString(pCfg, "ControllerType", "SAS1068"); 2042 2067 InsertConfigInteger(pCfg, "Bootable", fBootable); 2068 2069 if (pBiosCfg) 2070 { 2071 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "lsilogicsas"); 2072 } 2073 2074 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 2043 2075 2044 2076 ULONG cPorts = 0;
Note:
See TracChangeset
for help on using the changeset viewer.