Changeset 75100 in vbox
- Timestamp:
- Oct 26, 2018 2:41:41 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevBusLogic.cpp
r73097 r75100 316 316 /** @} */ 317 317 318 /** 319 * Emulated device types. 320 */ 321 enum BL_DEVICE_TYPE 322 { 323 DEV_BT_958D = 0, /* BusLogic BT-958D, PCI. */ 324 DEV_BT_545C = 1, /* BusLogic BT-545C, ISA. */ 325 DEV_AHA_1540C = 2 /* Adaptec AHA-1540C, ISA. */ 326 }; 327 318 328 /** Pointer to a task state structure. */ 319 329 typedef struct BUSLOGICREQ *PBUSLOGICREQ; … … 387 397 /** ISA I/O port base (encoded in FW-compatible format). */ 388 398 uint8_t uISABaseCode; 389 uint8_t Alignment00; 399 /** ISA IRQ, non-zero if in ISA mode. */ 400 uint8_t uIsaIrq; 390 401 391 402 /** ISA I/O port base (disabled if zero). */ … … 393 404 /** Default ISA I/O port base in FW-compatible format. */ 394 405 uint8_t uDefaultISABaseCode; 406 407 /** Emulated device type. */ 408 uint8_t uDevType; 395 409 396 410 /** Number of mailboxes the guest set up. */ … … 983 997 * 984 998 * @returns nothing. 985 * @param pThis The LsiLogic controller instance.999 * @param pThis The BusLogic controller instance. 986 1000 * @param GCPhys The guest physical address of the memory buffer. 987 1001 * @param pSgBuf The pointer to the host R3 S/G buffer. … … 1041 1055 pBusLogic->regInterrupt |= BL_INTR_INTV; 1042 1056 if (pBusLogic->fIRQEnabled && !fSuppressIrq) 1043 PDMDevHlpPCISetIrq(pBusLogic->CTX_SUFF(pDevIns), 0, 1); 1057 if (!pBusLogic->uIsaIrq) 1058 PDMDevHlpPCISetIrq(pBusLogic->CTX_SUFF(pDevIns), 0, 1); 1059 else 1060 PDMDevHlpISASetIrq(pBusLogic->CTX_SUFF(pDevIns), pBusLogic->uIsaIrq, 1); 1044 1061 } 1045 1062 … … 1056 1073 pBusLogic->regInterrupt = 0; 1057 1074 pBusLogic->regStatus &= ~BL_STAT_CMDINV; 1058 PDMDevHlpPCISetIrq(pBusLogic->CTX_SUFF(pDevIns), 0, 0); 1075 if (!pBusLogic->uIsaIrq) 1076 PDMDevHlpPCISetIrq(pBusLogic->CTX_SUFF(pDevIns), 0, 0); 1077 else 1078 PDMDevHlpISASetIrq(pBusLogic->CTX_SUFF(pDevIns), pBusLogic->uIsaIrq, 0); 1059 1079 /* If there's another pending interrupt, report it now. */ 1060 1080 if (pBusLogic->uPendingIntr) … … 1175 1195 } 1176 1196 1197 /** 1198 * Memory write helper to handle PCI/ISA differences. 1199 * 1200 * @returns nothing. 1201 * @param pThis Pointer to the BusLogic device instance 1202 * @param GCPhys Guest physical memory address 1203 * @param pvBuf Host side buffer address 1204 * @param cbWrite Number of bytes to write 1205 */ 1206 static void blPhysWrite(PBUSLOGIC pThis, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) 1207 { 1208 if (!pThis->uIsaIrq) 1209 PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhys, pvBuf, cbWrite); 1210 else 1211 PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhys, pvBuf, cbWrite); 1212 } 1213 1177 1214 #if defined(IN_RING3) 1178 1215 … … 1200 1237 } 1201 1238 } 1239 1202 1240 1203 1241 /** … … 1239 1277 pCCBGuest->c.uDeviceStatus = uDeviceStatus; 1240 1278 /* Rewrite CCB up to the CDB; perhaps more than necessary. */ 1241 PDMDevHlpPCIPhysWrite(pBusLogic->CTX_SUFF(pDevIns), GCPhysAddrCCB, 1242 pCCBGuest, RT_UOFFSETOF(CCBC, abCDB)); 1279 blPhysWrite(pBusLogic, GCPhysAddrCCB, pCCBGuest, RT_UOFFSETOF(CCBC, abCDB)); 1243 1280 } 1244 1281 … … 1258 1295 U32_TO_ADDR(Mbx24.aPhysAddrCCB, MbxIn.u32PhysAddrCCB); 1259 1296 Log(("24-bit mailbox: completion code=%u, CCB at %RGp\n", Mbx24.uCmdState, (RTGCPHYS)ADDR_TO_U32(Mbx24.aPhysAddrCCB))); 1260 PDMDevHlpPCIPhysWrite(pBusLogic->CTX_SUFF(pDevIns), GCPhysAddrMailboxIncoming, &Mbx24, sizeof(Mailbox24));1297 blPhysWrite(pBusLogic, GCPhysAddrMailboxIncoming, &Mbx24, sizeof(Mailbox24)); 1261 1298 } 1262 1299 else 1263 1300 { 1264 1301 Log(("32-bit mailbox: completion code=%u, CCB at %RGp\n", MbxIn.u.in.uCompletionCode, GCPhysAddrCCB)); 1265 PDMDevHlpPCIPhysWrite(pBusLogic->CTX_SUFF(pDevIns), GCPhysAddrMailboxIncoming, 1266 &MbxIn, sizeof(Mailbox32)); 1302 blPhysWrite(pBusLogic, GCPhysAddrMailboxIncoming, &MbxIn, sizeof(Mailbox32)); 1267 1303 } 1268 1304 … … 1507 1543 1508 1544 AssertPtr(pvSeg); 1509 PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhys, pvSeg, cbSeg);1545 blPhysWrite(pThis, GCPhys, pvSeg, cbSeg); 1510 1546 GCPhys += cbSeg; 1511 1547 cbCopy -= cbSeg; … … 1635 1671 * 1636 1672 * @returns Amount of bytes copied to the guest. 1637 * @param pThis The LsiLogic controller device instance.1673 * @param pThis The BusLogic controller device instance. 1638 1674 * @param pReq Request structure. 1639 1675 * @param pSgBuf The S/G buffer to copy from. … … 1652 1688 * 1653 1689 * @returns Amount of bytes copied from the guest. 1654 * @param pThis The LsiLogic controller device instance.1690 * @param pThis The BusLogic controller device instance. 1655 1691 * @param pReq Request structure. 1656 1692 * @param pSgBuf The S/G buffer to copy into. … … 1695 1731 if (fCopy && cbSenseBuffer) 1696 1732 { 1697 P PDMDEVINS pDevIns = pReq->pTargetDevice->CTX_SUFF(pBusLogic)->CTX_SUFF(pDevIns);1733 PBUSLOGIC pThis = pReq->pTargetDevice->CTX_SUFF(pBusLogic); 1698 1734 RTGCPHYS GCPhysAddrSenseBuffer; 1699 1735 … … 1711 1747 1712 1748 Log3(("%s: sense buffer: %.*Rhxs\n", __FUNCTION__, cbSenseBuffer, pReq->pbSenseBuffer)); 1713 PDMDevHlpPCIPhysWrite(pDevIns, GCPhysAddrSenseBuffer, pReq->pbSenseBuffer, cbSenseBuffer);1749 blPhysWrite(pThis, GCPhysAddrSenseBuffer, pReq->pbSenseBuffer, cbSenseBuffer); 1714 1750 } 1715 1751 … … 1890 1926 case BUSLOGICCOMMAND_INQUIRE_CONFIGURATION: 1891 1927 { 1892 uint8_t uPciIrq = PCIDevGetInterruptLine(&pBusLogic->dev); 1928 uint8_t uIrq; 1929 1930 if (pBusLogic->uIsaIrq) 1931 uIrq = pBusLogic->uIsaIrq; 1932 else 1933 uIrq = PCIDevGetInterruptLine(&pBusLogic->dev); 1893 1934 1894 1935 pBusLogic->cbReplyParametersLeft = sizeof(ReplyInquireConfiguration); … … 1897 1938 1898 1939 pReply->uHostAdapterId = 7; /* The controller has always 7 as ID. */ 1899 pReply->fDmaChannel6 = 1; /* DMA channel 6 is a good default. */ 1940 pReply->fDmaChannel5 = 1; /* DMA channel 6 is a good default. */ 1941 1900 1942 /* The PCI IRQ is not necessarily representable in this structure. 1901 1943 * If that is the case, the guest likely won't function correctly, 1902 * therefore we log a warning. 1944 * therefore we log a warning. Note that for ISA configurations, we 1945 * can only allow IRQs that can be supported; for PCI, the HBA 1946 * has no control over IRQ assignment. 1903 1947 */ 1904 switch (u PciIrq)1948 switch (uIrq) 1905 1949 { 1906 1950 case 9: pReply->fIrqChannel9 = 1; break; … … 1911 1955 case 15: pReply->fIrqChannel15 = 1; break; 1912 1956 default: 1913 LogRel(("Warning: PCI IRQ %d cannot be represented as ISA!\n", u PciIrq));1957 LogRel(("Warning: PCI IRQ %d cannot be represented as ISA!\n", uIrq)); 1914 1958 break; 1915 1959 } … … 2177 2221 GCPhysFifoBuf = (RTGCPHYS)ADDR_TO_U32(addr); 2178 2222 Log(("Read busmaster FIFO at: %04X\n", ADDR_TO_U32(addr))); 2179 PDMDevHlpPCIPhysWrite(pBusLogic->CTX_SUFF(pDevIns), GCPhysFifoBuf, 2180 &pBusLogic->LocalRam.u8View[64], 64); 2223 blPhysWrite(pBusLogic, GCPhysFifoBuf, &pBusLogic->LocalRam.u8View[64], 64); 2181 2224 break; 2182 2225 } … … 2198 2241 2199 2242 Log(("uOperationCode=%#x, cbReplyParametersLeft=%d\n", pBusLogic->uOperationCode, pBusLogic->cbReplyParametersLeft)); 2243 2244 /* Fail command if too much parameter data requested. */ 2245 if ((pBusLogic->cbCommandParametersLeft + pBusLogic->iParameter) > sizeof(pBusLogic->aCommandBuffer)) 2246 { 2247 Log(("Invalid command parameter length (%u)\n", pBusLogic->cbCommandParametersLeft)); 2248 pBusLogic->cbReplyParametersLeft = 0; 2249 pBusLogic->cbCommandParametersLeft = 0; 2250 pBusLogic->regStatus |= BL_STAT_CMDINV; 2251 } 2200 2252 2201 2253 /* Set the data in ready bit in the status register in case the command has a reply. */ … … 3273 3325 uint8_t uActionCode = BUSLOGIC_MAILBOX_OUTGOING_ACTION_FREE; 3274 3326 unsigned uCodeOffs = pBusLogic->fMbxIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode); 3275 PDMDevHlpPCIPhysWrite(pBusLogic->CTX_SUFF(pDevIns), GCPhysAddrMailboxCurrent + uCodeOffs, &uActionCode, sizeof(uActionCode));3327 blPhysWrite(pBusLogic, GCPhysAddrMailboxCurrent + uCodeOffs, &uActionCode, sizeof(uActionCode)); 3276 3328 3277 3329 if (MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_START_COMMAND) … … 3698 3750 static DECLCALLBACK(void) buslogicR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 3699 3751 { 3752 static const char *apszModels[] = { "BusLogic BT-958D", "BusLogic BT-545C", "Adaptec AHA-1540C" }; 3700 3753 PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC); 3701 3754 unsigned i; … … 3707 3760 3708 3761 /* Show basic information. */ 3709 pHlp->pfnPrintf(pHlp, 3710 "%s#%d: PCI I/O=%RTiop ISA I/O=%RTiop MMIO=%RGp IRQ=%u GC=%RTbool R0=%RTbool\n", 3762 pHlp->pfnPrintf(pHlp, "%s#%d: %s ", 3711 3763 pDevIns->pReg->szName, 3712 3764 pDevIns->iInstance, 3713 pThis->IOPortBase, pThis->IOISABase, pThis->MMIOBase, 3714 PCIDevGetInterruptLine(&pThis->dev), 3765 pThis->uDevType >= RT_ELEMENTS(apszModels) ? "Uknown model" : apszModels[pThis->uDevType]); 3766 if (pThis->uIsaIrq) 3767 pHlp->pfnPrintf(pHlp, "ISA I/O=%RTiop IRQ=%u ", 3768 pThis->IOISABase, 3769 pThis->uIsaIrq); 3770 else 3771 pHlp->pfnPrintf(pHlp, "PCI I/O=%RTiop ISA I/O=%RTiop MMIO=%RGp IRQ=%u ", 3772 pThis->IOPortBase, pThis->IOISABase, pThis->MMIOBase, 3773 PCIDevGetInterruptLine(&pThis->dev)); 3774 pHlp->pfnPrintf(pHlp, "GC=%RTbool R0=%RTbool\n", 3715 3775 !!pThis->fGCEnabled, !!pThis->fR0Enabled); 3716 3776 … … 4066 4126 int rc = VINF_SUCCESS; 4067 4127 bool fBootable = true; 4068 char ach ISACompat[16];4128 char achCfgStr[16]; 4069 4129 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 4070 4130 … … 4099 4159 "R0Enabled\0" 4100 4160 "Bootable\0" 4161 "AdapterType\0" 4101 4162 "ISACompat\0")) 4102 4163 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, … … 4120 4181 Log(("%s: fBootable=%RTbool\n", __FUNCTION__, fBootable)); 4121 4182 4183 /* Figure out the emulated device type. */ 4184 rc = CFGMR3QueryStringDef(pCfg, "AdapterType", achCfgStr, sizeof(achCfgStr), "BT-958D"); 4185 if (RT_FAILURE(rc)) 4186 return PDMDEV_SET_ERROR(pDevIns, rc, 4187 N_("BusLogic configuration error: failed to read AdapterType as string")); 4188 Log(("%s: AdapterType=%s\n", __FUNCTION__, achCfgStr)); 4189 4190 /* Grok the AdapterType setting. */ 4191 if (!strcmp(achCfgStr, "BT-958D")) /* Default PCI device, 32-bit and 24-bit addressing. */ 4192 { 4193 pThis->uDevType = DEV_BT_958D; 4194 pThis->uDefaultISABaseCode = ISA_BASE_DISABLED; 4195 } 4196 else if (!strcmp(achCfgStr, "BT-545C")) /* ISA device, 24-bit addressing only. */ 4197 { 4198 pThis->uDevType = DEV_BT_545C; 4199 pThis->uIsaIrq = 11; 4200 } 4201 #if 0 /* Maybe someday. */ 4202 else if (!strcmp(achCfgStr, "AHA-1540C")) /* Competitor ISA device. */ 4203 { 4204 pThis->uDevType = DEV_AHA_1540C; 4205 pThis->uIsaIrq = 11; 4206 } 4207 #endif 4208 else 4209 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 4210 N_("BusLogic configuration error: invalid AdapterType setting")); 4211 4122 4212 /* Only the first instance defaults to having the ISA compatibility ports enabled. */ 4123 4213 if (iInstance == 0) 4124 rc = CFGMR3QueryStringDef(pCfg, "ISACompat", ach ISACompat, sizeof(achISACompat), "Alternate");4214 rc = CFGMR3QueryStringDef(pCfg, "ISACompat", achCfgStr, sizeof(achCfgStr), "Alternate"); 4125 4215 else 4126 rc = CFGMR3QueryStringDef(pCfg, "ISACompat", ach ISACompat, sizeof(achISACompat), "Disabled");4216 rc = CFGMR3QueryStringDef(pCfg, "ISACompat", achCfgStr, sizeof(achCfgStr), "Disabled"); 4127 4217 if (RT_FAILURE(rc)) 4128 4218 return PDMDEV_SET_ERROR(pDevIns, rc, 4129 4219 N_("BusLogic configuration error: failed to read ISACompat as string")); 4130 Log(("%s: ISACompat=%s\n", __FUNCTION__, ach ISACompat));4220 Log(("%s: ISACompat=%s\n", __FUNCTION__, achCfgStr)); 4131 4221 4132 4222 /* Grok the ISACompat setting. */ 4133 if (!strcmp(ach ISACompat, "Disabled"))4223 if (!strcmp(achCfgStr, "Disabled")) 4134 4224 pThis->uDefaultISABaseCode = ISA_BASE_DISABLED; 4135 else if (!strcmp(ach ISACompat, "Primary"))4225 else if (!strcmp(achCfgStr, "Primary")) 4136 4226 pThis->uDefaultISABaseCode = 0; /* I/O base at 330h. */ 4137 else if (!strcmp(ach ISACompat, "Alternate"))4227 else if (!strcmp(achCfgStr, "Alternate")) 4138 4228 pThis->uDefaultISABaseCode = 1; /* I/O base at 334h. */ 4139 4229 else … … 4142 4232 4143 4233 /* 4144 * Register the PCI device and its I/O regions .4234 * Register the PCI device and its I/O regions if applicable. 4145 4235 */ 4146 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev); 4147 if (RT_FAILURE(rc)) 4148 return rc; 4149 4150 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, buslogicR3MmioMap); 4151 if (RT_FAILURE(rc)) 4152 return rc; 4153 4154 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, buslogicR3MmioMap); 4155 if (RT_FAILURE(rc)) 4156 return rc; 4236 if (!pThis->uIsaIrq) 4237 { 4238 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev); 4239 if (RT_FAILURE(rc)) 4240 return rc; 4241 4242 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, buslogicR3MmioMap); 4243 if (RT_FAILURE(rc)) 4244 return rc; 4245 4246 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, buslogicR3MmioMap); 4247 if (RT_FAILURE(rc)) 4248 return rc; 4249 } 4157 4250 4158 4251 if (fBootable)
Note:
See TracChangeset
for help on using the changeset viewer.