Changeset 84060 in vbox for trunk/src/VBox/Devices/Bus
- Timestamp:
- Apr 28, 2020 5:13:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r84027 r84060 417 417 /** PprOverflowEarly: PPR log overflow early warning. */ 418 418 #define IOMMU_STATUS_PPR_LOG_OVERFLOW_EARLY RT_BIT_64(18) 419 /** @} */ 420 421 /** 422 * @name IOMMU Control Register Bits. 423 * In accordance with the AMD spec. 424 * @{ 425 */ 426 /** IommuEn: Enable the IOMMU. */ 427 #define IOMMU_CTRL_IOMMU_EN RT_BIT_64(0) 428 /** HtTunEn: HyperTransport tunnel translation enable. */ 429 #define IOMMU_CTRL_HT_TUNNEL_EN RT_BIT_64(1) 430 /** EventLogEn: Event log enable. */ 431 #define IOMMU_CTRL_EVT_LOG_EN RT_BIT_64(2) 432 /** EventIntEn: Event interrupt enable. */ 433 #define IOMMU_CTRL_EVT_INTR_EN RT_BIT_64(3) 434 /** ComWaitIntEn: Completion wait interrupt enable. */ 435 #define IOMMU_CTRL_COMPLETION_WAIT_INTR_EN RT_BIT_64(4) 436 /** InvTimeout: Invalidation timeout. */ 437 #define IOMMU_CTRL_INV_TIMEOUT RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7) 438 /** @todo IOMMU: the rest or remove it. */ 419 439 /** @} */ 420 440 … … 1221 1241 } IOMMU_CTRL_T; 1222 1242 AssertCompileSize(IOMMU_CTRL_T, 8); 1243 #define IOMMU_CTRL_VALID_MASK UINT64_C(0x004defffffffffff) 1223 1244 1224 1245 /** … … 2209 2230 2210 2231 2232 /** 2233 * The IOMMU command thread. 2234 * 2235 * @returns VBox status code. 2236 * @param pDevIns The IOMMU device instance. 2237 * @param pThread The command thread. 2238 */ 2239 static DECLCALLBACK(int) iommuAmdR3CmdThread(PPDMDEVINS pDevIns, PPDMTHREAD pThread) 2240 { 2241 RT_NOREF(pDevIns, pThread); 2242 } 2243 2244 2245 /** 2246 * Unblocks the command thread so it can respond to a state change. 2247 * 2248 * @returns VBox status code. 2249 * @param pDevIns The IOMMU device instance. 2250 * @param pThread The command thread. 2251 */ 2252 static DECLCALLBACK(int) iommuAmdR3CmdThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread) 2253 { 2254 RT_NOREF(pThread); 2255 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2256 return PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread); 2257 } 2258 2211 2259 2212 2260 /** … … 2280 2328 2281 2329 /* 2282 * Writing the command logbase address, clears the command buffer head and tail pointers.2330 * Writing the command buffer base address, clears the command buffer head and tail pointers. 2283 2331 * See AMD spec. 2.4 "Commands". 2284 2332 */ … … 2335 2383 2336 2384 return VINF_SUCCESS; 2385 } 2386 2387 2388 /** 2389 * Writes the Control Register. 2390 */ 2391 static VBOXSTRICTRC iommuAmdCtrl_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value) 2392 { 2393 RT_NOREF(pDevIns, iReg); 2394 2395 /* Mask out all unrecognized bits. */ 2396 u64Value &= IOMMU_CTRL_VALID_MASK; 2397 2398 IOMMU_CTRL_T const OldCtrl = iommuAmdGetCtrl(pThis); 2399 IOMMU_CTRL_T NewCtrl; 2400 NewCtrl.u64 = u64Value; 2401 2402 /* Enable or disable event logging when the bit transitions. */ 2403 if (OldCtrl.n.u1EvtLogEn != NewCtrl.n.u1EvtLogEn) 2404 { 2405 if (NewCtrl.n.u1EvtLogEn) 2406 { 2407 ASMAtomicAndU64(&pThis->Status.u64, ~IOMMU_STATUS_EVT_LOG_OVERFLOW); 2408 ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_EVT_LOG_RUNNING); 2409 } 2410 else 2411 ASMAtomicAndU64(&pThis->Status.u64, ~IOMMU_STATUS_EVT_LOG_RUNNING); 2412 } 2413 2414 /* Update the control register. */ 2415 ASMAtomicWriteU64(&pThis->Ctrl.u64, NewCtrl.u64); 2416 2417 /* Enable or disable command buffer processing when the bit transitions. */ 2418 if (OldCtrl.n.u1CmdBufEn != NewCtrl.n.u1CmdBufEn) 2419 { 2420 if (NewCtrl.n.u1CmdBufEn) 2421 { 2422 ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_CMD_BUF_RUNNING); 2423 /* If the command buffer isn't empty, kick the command thread to start processing commands. */ 2424 if (pThis->CmdBufHeadPtr.n.u15Ptr != pThis->CmdBufTailPtr.n.u15Ptr) 2425 PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread); 2426 } 2427 else 2428 { 2429 ASMAtomicAndU64(&pThis->Status.u64, ~IOMMU_STATUS_CMD_BUF_RUNNING); 2430 /* Kick the command thread to stop processing commands. */ 2431 PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread); 2432 } 2433 } 2337 2434 } 2338 2435 … … 2623 2720 2624 2721 2625 /**2626 * The IOMMU command thread.2627 *2628 * @returns VBox status code.2629 * @param pDevIns The IOMMU device instance.2630 * @param pThread The command thread.2631 */2632 static DECLCALLBACK(int) iommuAmdR3CmdThread(PPDMDEVINS pDevIns, PPDMTHREAD pThread)2633 {2634 RT_NOREF(pDevIns, pThread);2635 }2636 2637 2638 /**2639 * Unblocks the command thread so it can respond to a state change.2640 *2641 * @returns VBox status code.2642 * @param pDevIns The IOMMU device instance.2643 * @param pThread The command thread.2644 */2645 static DECLCALLBACK(int) iommuAmdR3CmdThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)2646 {2647 RT_NOREF(pThread);2648 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);2649 return PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread);2650 }2651 2652 2653 2722 #if 0 2654 2723 /** … … 2689 2758 case IOMMU_MMIO_OFF_CMD_BUF_BAR: return iommuAmdCmdBufBar_w(pDevIns, pThis, off, uValue); 2690 2759 case IOMMU_MMIO_OFF_EVT_LOG_BAR: return iommuAmdEvtLogBar_w(pDevIns, pThis, off, uValue); 2691 case IOMMU_MMIO_OFF_CTRL: /** @todo IOMMU: Control register. */2760 case IOMMU_MMIO_OFF_CTRL: return iommuAmdCtrl_w(pDevIns, pThis, off, uValue); 2692 2761 case IOMMU_MMIO_OFF_EXCL_BAR: return iommuAmdExclRangeBar_w(pDevIns, pThis, off, uValue); 2693 2762 case IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT: return iommuAmdExclRangeLimit_w(pDevIns, pThis, off, uValue); … … 2998 3067 2999 3068 /** 3000 * Writes an entry to the event log .3069 * Writes an entry to the event log in memory. 3001 3070 * 3002 3071 * @returns VBox status code.
Note:
See TracChangeset
for help on using the changeset viewer.