Changeset 70227 in vbox for trunk/src/VBox
- Timestamp:
- Dec 19, 2017 6:41:19 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r70223 r70227 203 203 static VOID vgdrvNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext); 204 204 static BOOLEAN vgdrvNtIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext); 205 static NTSTATUS vgdrvNtScanPCIResourceList(P CM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt);205 static NTSTATUS vgdrvNtScanPCIResourceList(PVBOXGUESTDEVEXTWIN pDevExt, PCM_RESOURCE_LIST pResList, bool fTranslated); 206 206 static NTSTATUS vgdrvNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap, 207 207 void **ppvMMIOBase, uint32_t *pcbMMIO); … … 545 545 if (NT_SUCCESS(rcNt)) 546 546 { 547 rcNt = vgdrvNtScanPCIResourceList(p ResourceList, pDevExt);547 rcNt = vgdrvNtScanPCIResourceList(pDevExt, pResourceList, false /*fTranslated*/); 548 548 ExFreePool(pResourceList); 549 549 } … … 564 564 vgdrvNtShowDeviceResources(pStack->Parameters.StartDevice.AllocatedResources); 565 565 # endif 566 rcNt = vgdrvNtScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated, pDevExt); 566 rcNt = vgdrvNtScanPCIResourceList(pDevExt, pStack->Parameters.StartDevice.AllocatedResourcesTranslated, 567 true /*fTranslated*/); 567 568 } 568 569 if (NT_SUCCESS(rcNt)) … … 2214 2215 * Helper to scan the PCI resource list and remember stuff. 2215 2216 * 2216 * @param pResList Resource list 2217 * @param pDevExt Device extension 2218 */ 2219 static NTSTATUS vgdrvNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt) 2217 * @param pDevExt The device extension. 2218 * @param pResList Resource list 2219 * @param fTranslated Whether the addresses are translated or not. 2220 */ 2221 static NTSTATUS vgdrvNtScanPCIResourceList(PVBOXGUESTDEVEXTWIN pDevExt, PCM_RESOURCE_LIST pResList, bool fTranslated) 2220 2222 { 2221 2223 /* Enumerate the resource list. */ … … 2225 2227 NTSTATUS rc = STATUS_SUCCESS; 2226 2228 PCM_PARTIAL_RESOURCE_DESCRIPTOR pPartialData = NULL; 2227 ULONG rangeCount = 0; 2228 ULONG cMMIORange = 0; 2229 PVBOXGUESTWINBASEADDRESS pBaseAddress = pDevExt->aPciBaseAddresses; 2229 PVBOXGUESTWINBASEADDRESS pBaseAddress = pDevExt->aPciBaseAddresses; 2230 uint32_t cBaseAddresses = 0; 2231 bool fGotIrq = false; 2232 bool fGotMmio = false; 2233 bool fGotIoPorts = false; 2230 2234 for (ULONG i = 0; i < pResList->List->PartialResourceList.Count; i++) 2231 2235 { … … 2235 2239 case CmResourceTypePort: 2236 2240 { 2241 LogFlowFunc(("I/O range: Base=%#RX64, length=%08x\n", 2242 pPartialData->u.Port.Start.QuadPart, pPartialData->u.Port.Length)); 2243 2237 2244 /* Overflow protection. */ 2238 if ( rangeCount< PCI_TYPE0_ADDRESSES)2245 if (cBaseAddresses < PCI_TYPE0_ADDRESSES) 2239 2246 { 2240 LogFlowFunc(("I/O range: Base=%08x:%08x, length=%08x\n", 2241 pPartialData->u.Port.Start.HighPart, 2242 pPartialData->u.Port.Start.LowPart, 2243 pPartialData->u.Port.Length)); 2244 2245 /* Save the IO port base. */ 2246 /** @todo Not so good. 2247 * Update/bird: What is not so good? That we just consider the last range? */ 2248 pDevExt->Core.IOPortBase = (RTIOPORT)pPartialData->u.Port.Start.LowPart; 2247 /* Save the first I/O port base. */ 2248 if (!fGotIoPorts) 2249 { 2250 pDevExt->Core.IOPortBase = (RTIOPORT)pPartialData->u.Port.Start.LowPart; 2251 fGotIoPorts = true; 2252 } 2253 else 2254 LogRelFunc(("More than one I/O port range?!?\n")); 2249 2255 2250 2256 /* Save resource information. */ … … 2254 2260 pBaseAddress->ResourceMapped = FALSE; 2255 2261 2256 LogFunc(("I/O range for VMMDev found! Base=%08x:%08x, length=%08x\n", 2257 pPartialData->u.Port.Start.HighPart, 2258 pPartialData->u.Port.Start.LowPart, 2259 pPartialData->u.Port.Length)); 2262 LogFunc(("I/O range for VMMDev found! Base=%#RX64, length=%08x\n", 2263 pPartialData->u.Port.Start.QuadPart, pPartialData->u.Port.Length)); 2260 2264 2261 2265 /* Next item ... */ 2262 rangeCount++; pBaseAddress++; 2266 pBaseAddress++; 2267 cBaseAddresses++; 2263 2268 } 2269 else 2270 LogFunc(("Too many PCI addresses!\n")); 2264 2271 break; 2265 2272 } … … 2268 2275 { 2269 2276 LogFunc(("Interrupt: Level=%x, vector=%x, mode=%x\n", 2270 pPartialData->u.Interrupt.Level, 2271 pPartialData->u.Interrupt.Vector, 2272 pPartialData->Flags)); 2273 2274 /* Save information. */ 2275 pDevExt->uInterruptLevel = pPartialData->u.Interrupt.Level; 2276 pDevExt->uInterruptVector = pPartialData->u.Interrupt.Vector; 2277 pDevExt->fInterruptAffinity = pPartialData->u.Interrupt.Affinity; 2278 2279 /* Check interrupt mode. */ 2280 if (pPartialData->Flags & CM_RESOURCE_INTERRUPT_LATCHED) 2281 pDevExt->enmInterruptMode = Latched; 2277 pPartialData->u.Interrupt.Level, pPartialData->u.Interrupt.Vector, pPartialData->Flags)); 2278 2279 if (!fGotIrq) 2280 { 2281 /* Save information. */ 2282 pDevExt->uInterruptLevel = pPartialData->u.Interrupt.Level; 2283 pDevExt->uInterruptVector = pPartialData->u.Interrupt.Vector; 2284 pDevExt->fInterruptAffinity = pPartialData->u.Interrupt.Affinity; 2285 2286 /* Check interrupt mode. */ 2287 if (pPartialData->Flags & CM_RESOURCE_INTERRUPT_LATCHED) 2288 pDevExt->enmInterruptMode = Latched; 2289 else 2290 pDevExt->enmInterruptMode = LevelSensitive; 2291 fGotIrq = true; 2292 } 2282 2293 else 2283 pDevExt->enmInterruptMode = LevelSensitive;2294 LogFunc(("More than one IRQ resource!\n")); 2284 2295 break; 2285 2296 } … … 2287 2298 case CmResourceTypeMemory: 2288 2299 { 2300 LogFlowFunc(("Memory range: Base=%#RX64, length=%08x\n", 2301 pPartialData->u.Memory.Start.QuadPart, pPartialData->u.Memory.Length)); 2302 2289 2303 /* Overflow protection. */ 2290 if ( rangeCount< PCI_TYPE0_ADDRESSES)2304 if (cBaseAddresses < PCI_TYPE0_ADDRESSES) 2291 2305 { 2292 LogFlowFunc(("Memory range: Base=%08x:%08x, length=%08x\n", 2293 pPartialData->u.Memory.Start.HighPart, 2294 pPartialData->u.Memory.Start.LowPart, 2295 pPartialData->u.Memory.Length)); 2296 2297 /* We only care about read/write memory. */ 2298 /** @todo Reconsider memory type. */ 2299 if ( cMMIORange == 0 /* Only care about the first MMIO range (!!!). */ 2300 && (pPartialData->Flags & VBOX_CM_PRE_VISTA_MASK) == CM_RESOURCE_MEMORY_READ_WRITE) 2306 /* We only care about the first read/write memory range. */ 2307 if ( !fGotMmio 2308 && (pPartialData->Flags & CM_RESOURCE_MEMORY_WRITEABILITY_MASK) == CM_RESOURCE_MEMORY_READ_WRITE) 2301 2309 { 2302 2310 /* Save physical MMIO base + length for VMMDev. */ … … 2304 2312 pDevExt->cbVmmDevMemory = (ULONG)pPartialData->u.Memory.Length; 2305 2313 2306 /* Technically we need to make the HAL translate the address. since we 2307 didn't used to do this and it probably just returns the input address, 2308 we allow ourselves to ignore failures. */ 2309 ULONG uAddressSpace = 0; 2310 PHYSICAL_ADDRESS PhysAddr = pPartialData->u.Memory.Start; 2311 if (HalTranslateBusAddress(pResList->List->InterfaceType, pResList->List->BusNumber, PhysAddr, 2312 &uAddressSpace, &PhysAddr)) 2314 if (!fTranslated) 2313 2315 { 2314 Log(("HalTranslateBusAddress(%#RX64) -> %RX64, type %#x\n", 2315 pPartialData->u.Memory.Start.QuadPart, PhysAddr.QuadPart, uAddressSpace)); 2316 if (pPartialData->u.Memory.Start.QuadPart != PhysAddr.QuadPart) 2317 pDevExt->uVmmDevMemoryPhysAddr = PhysAddr; 2316 /* Technically we need to make the HAL translate the address. since we 2317 didn't used to do this and it probably just returns the input address, 2318 we allow ourselves to ignore failures. */ 2319 ULONG uAddressSpace = 0; 2320 PHYSICAL_ADDRESS PhysAddr = pPartialData->u.Memory.Start; 2321 if (HalTranslateBusAddress(pResList->List->InterfaceType, pResList->List->BusNumber, PhysAddr, 2322 &uAddressSpace, &PhysAddr)) 2323 { 2324 Log(("HalTranslateBusAddress(%#RX64) -> %RX64, type %#x\n", 2325 pPartialData->u.Memory.Start.QuadPart, PhysAddr.QuadPart, uAddressSpace)); 2326 if (pPartialData->u.Memory.Start.QuadPart != PhysAddr.QuadPart) 2327 pDevExt->uVmmDevMemoryPhysAddr = PhysAddr; 2328 } 2329 else 2330 Log(("HalTranslateBusAddress(%#RX64) -> failed!\n", pPartialData->u.Memory.Start.QuadPart)); 2318 2331 } 2319 else2320 Log(("HalTranslateBusAddress(%#RX64) -> failed!\n", pPartialData->u.Memory.Start.QuadPart));2321 2332 2322 2333 /* Save resource information. */ … … 2326 2337 pBaseAddress->ResourceMapped = FALSE; 2327 2338 2328 LogFunc(("Memory range for VMMDev found! Base = %08x:%08x, Length = %08x\n", 2329 pPartialData->u.Memory.Start.HighPart, 2330 pPartialData->u.Memory.Start.LowPart, 2331 pPartialData->u.Memory.Length)); 2339 LogFunc(("Found memory range for VMMDev! Base = %#RX64, Length = %08x\n", 2340 pPartialData->u.Memory.Start.QuadPart, pPartialData->u.Memory.Length)); 2332 2341 2333 2342 /* Next item ... */ 2334 rangeCount++; pBaseAddress++; cMMIORange++; 2343 cBaseAddresses++; 2344 pBaseAddress++; 2345 fGotMmio = true; 2335 2346 } 2336 2347 else 2337 LogFunc(("Ignoring memory: Flags=%08x\n", pPartialData->Flags)); 2348 LogFunc(("Ignoring memory: Flags=%08x Base=%#RX64\n", 2349 pPartialData->Flags, pPartialData->u.Memory.Start.QuadPart)); 2338 2350 } 2351 else 2352 LogFunc(("Too many PCI addresses!\n")); 2339 2353 break; 2340 2354 } … … 2349 2363 2350 2364 /* Memorize the number of resources found. */ 2351 pDevExt->cPciAddresses = rangeCount;2365 pDevExt->cPciAddresses = cBaseAddresses; 2352 2366 return rc; 2353 2367 }
Note:
See TracChangeset
for help on using the changeset viewer.