Changeset 18171 in vbox for trunk/src/VBox/Additions/WINNT/VBoxGuest/HelperBugCheck.cpp
- Timestamp:
- Mar 24, 2009 11:12:35 AM (16 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxGuest/HelperBugCheck.cpp
r18170 r18171 19 19 */ 20 20 21 //#define LOG_ENABLED 22 21 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 22 /******************************************************************************* 23 * Header Files * 24 *******************************************************************************/ 23 25 #include "VBoxGuest_Internal.h" 24 26 #include "Helper.h" … … 27 29 #include <VBox/VBoxGuestLib.h> 28 30 29 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 30 # ifndef TARGET_NT4 31 # include <aux_klib.h> 32 # endif 31 #ifndef TARGET_NT4 32 # include <aux_klib.h> 33 33 #endif 34 34 35 #ifdef ALLOC_PRAGMA36 #pragma alloc_text (PAGE, VBoxScanPCIResourceList)37 #endif38 35 39 /* CM_RESOURCE_MEMORY_* flags which were used on XP or earlier. */40 #define VBOX_CM_PRE_VISTA_MASK (0x3f)41 42 /**43 * Helper to scan the PCI resource list and remember stuff.44 *45 * @param pResList Resource list46 * @param pDevExt Device extension47 */48 NTSTATUS VBoxScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXT pDevExt)49 {50 NTSTATUS rc = STATUS_SUCCESS;51 PCM_PARTIAL_RESOURCE_DESCRIPTOR partialData;52 53 // enumerate the resource list54 dprintf(("found %d resources\n", pResList->List->PartialResourceList.Count));55 ULONG rangeCount = 0;56 ULONG cMMIORange = 0;57 PBASE_ADDRESS baseAddress = pDevExt->baseAddress;58 for (ULONG i = 0; i < pResList->List->PartialResourceList.Count; i++)59 {60 partialData = &pResList->List->PartialResourceList.PartialDescriptors[i];61 switch (partialData->Type)62 {63 case CmResourceTypePort:64 {65 // overflow protection66 if (rangeCount < PCI_TYPE0_ADDRESSES)67 {68 dprintf(("I/O range: Base = %08x : %08x Length = %08x \n",69 partialData->u.Port.Start.HighPart,70 partialData->u.Port.Start.LowPart,71 partialData->u.Port.Length));72 //@todo not so gut73 dprintf(("I got all I want, my dear port, oh!\n"));74 pDevExt->startPortAddress = (ULONG)partialData->u.Port.Start.LowPart;75 // save resource information76 baseAddress->RangeStart = partialData->u.Port.Start;77 baseAddress->RangeLength = partialData->u.Port.Length;78 baseAddress->RangeInMemory = FALSE;79 baseAddress->ResourceMapped = FALSE;80 // next item81 rangeCount++; baseAddress++;82 }83 break;84 }85 86 case CmResourceTypeInterrupt:87 {88 dprintf(("Interrupt: Level = %x Vector = %x Mode = %x \n",89 partialData->u.Interrupt.Level,90 partialData->u.Interrupt.Vector,91 partialData->Flags));92 // save information93 pDevExt->interruptLevel = partialData->u.Interrupt.Level;94 pDevExt->interruptVector = partialData->u.Interrupt.Vector;95 pDevExt->interruptAffinity = partialData->u.Interrupt.Affinity;96 // check interrupt mode97 if (partialData->Flags & CM_RESOURCE_INTERRUPT_LATCHED)98 {99 pDevExt->interruptMode = Latched;100 }101 else102 {103 pDevExt->interruptMode = LevelSensitive;104 }105 break;106 }107 108 case CmResourceTypeMemory:109 {110 // overflow protection111 if (rangeCount < PCI_TYPE0_ADDRESSES)112 {113 dprintf(("Memory range: Base = %08x : %08x Length = %08x \n",114 partialData->u.Memory.Start.HighPart,115 partialData->u.Memory.Start.LowPart,116 partialData->u.Memory.Length));117 // we only care about read/write memory118 /** @todo reconsider memory type */119 if ( cMMIORange == 0 /* only care about the first mmio range (!!!) */120 && (partialData->Flags & VBOX_CM_PRE_VISTA_MASK) == CM_RESOURCE_MEMORY_READ_WRITE)121 {122 pDevExt->memoryAddress = partialData->u.Memory.Start;123 pDevExt->memoryLength = (ULONG)partialData->u.Memory.Length;124 // save resource information125 baseAddress->RangeStart = partialData->u.Memory.Start;126 baseAddress->RangeLength = partialData->u.Memory.Length;127 baseAddress->RangeInMemory = TRUE;128 baseAddress->ResourceMapped = FALSE;129 // next item130 rangeCount++; baseAddress++;cMMIORange++;131 } else132 {133 dprintf(("Ignoring memory: flags = %08x \n", partialData->Flags));134 }135 }136 break;137 }138 139 case CmResourceTypeDma:140 {141 dprintf(("DMA resource found. Hmm...\n"));142 break;143 }144 145 default:146 {147 dprintf(("Unexpected resource found %d. Hmm...\n", partialData->Type));148 break;149 }150 }151 }152 // memorize the number of resources found153 pDevExt->addressCount = rangeCount;154 155 return rc;156 }157 158 159 NTSTATUS hlpVBoxMapVMMDevMemory (PVBOXGUESTDEVEXT pDevExt)160 {161 NTSTATUS rc = STATUS_SUCCESS;162 163 if (pDevExt->memoryLength != 0)164 {165 pDevExt->pVMMDevMemory = (VMMDevMemory *)MmMapIoSpace (pDevExt->memoryAddress, pDevExt->memoryLength, MmNonCached);166 dprintf(("VBoxGuest::VBoxGuestPnp: VMMDevMemory: ptr = 0x%x\n", pDevExt->pVMMDevMemory));167 if (pDevExt->pVMMDevMemory)168 {169 dprintf(("VBoxGuest::VBoxGuestPnp: VMMDevMemory: version = 0x%x, size = %d\n", pDevExt->pVMMDevMemory->u32Version, pDevExt->pVMMDevMemory->u32Size));170 171 /* Check version of the structure */172 if (pDevExt->pVMMDevMemory->u32Version != VMMDEV_MEMORY_VERSION)173 {174 /* Not our version, refuse operation and unmap the memory */175 hlpVBoxUnmapVMMDevMemory (pDevExt);176 177 rc = STATUS_UNSUCCESSFUL;178 }179 }180 else181 {182 rc = STATUS_UNSUCCESSFUL;183 }184 }185 186 return rc;187 }188 189 void hlpVBoxUnmapVMMDevMemory (PVBOXGUESTDEVEXT pDevExt)190 {191 if (pDevExt->pVMMDevMemory)192 {193 MmUnmapIoSpace (pDevExt->pVMMDevMemory, pDevExt->memoryLength);194 pDevExt->pVMMDevMemory = NULL;195 }196 197 pDevExt->memoryAddress.QuadPart = 0;198 pDevExt->memoryLength = 0;199 }200 201 NTSTATUS hlpVBoxReportGuestInfo (PVBOXGUESTDEVEXT pDevExt)202 {203 VMMDevReportGuestInfo *req = NULL;204 205 int rc = VbglGRAlloc ((VMMDevRequestHeader **)&req, sizeof (VMMDevReportGuestInfo), VMMDevReq_ReportGuestInfo);206 207 dprintf(("hlpVBoxReportGuestInfo: VbglGRAlloc rc = %d\n", rc));208 209 if (RT_SUCCESS(rc))210 {211 req->guestInfo.additionsVersion = VMMDEV_VERSION;212 213 /* we've already determined the Windows product before */214 switch (winVersion)215 {216 case WINNT4:217 req->guestInfo.osType = VBOXOSTYPE_WinNT4;218 break;219 case WIN2K:220 req->guestInfo.osType = VBOXOSTYPE_Win2k;221 break;222 case WINXP:223 req->guestInfo.osType = VBOXOSTYPE_WinXP;224 break;225 case WIN2K3:226 req->guestInfo.osType = VBOXOSTYPE_Win2k3;227 break;228 case WINVISTA:229 req->guestInfo.osType = VBOXOSTYPE_WinVista;230 break;231 default:232 /* we don't know, therefore NT family */233 req->guestInfo.osType = VBOXOSTYPE_WinNT;234 break;235 }236 237 /** @todo registry lookup for additional information */238 239 240 rc = VbglGRPerform (&req->header);241 242 if (RT_FAILURE(rc) || RT_FAILURE(req->header.rc))243 {244 dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: error reporting guest info to VMMDev."245 "rc = %d, VMMDev rc = %Rrc\n", rc, req->header.rc));246 }247 248 rc = RT_SUCCESS(rc) ? req->header.rc : rc;249 250 VbglGRFree (&req->header);251 }252 253 return RT_FAILURE(rc) ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;254 }255 256 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION257 36 /** 258 37 * Called when a bug check occurs. … … 304 83 } 305 84 306 NTSTATUShlpRegisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt)85 void hlpRegisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt) 307 86 { 308 NTSTATUS rc = STATUS_SUCCESS;309 87 pDevExt->bBugcheckCallbackRegistered = FALSE; 310 88 … … 313 91 * This is required for calling AuxKlibGetBugCheckData() in hlpVBoxGuestBugCheckCallback(). 314 92 */ 315 rc = AuxKlibInitialize();93 NTSTATUS rc = AuxKlibInitialize(); 316 94 if (NT_ERROR(rc)) 317 95 { 318 dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Unabled to initialize AuxKlib! rc=%#x\n", rc));319 return STATUS_DRIVER_UNABLE_TO_LOAD;96 LogRelBackdoor(("VBoxGuest: Failed to initialize AuxKlib! rc=%#x\n", rc)); 97 return; 320 98 } 321 99 # endif … … 336 114 } 337 115 else 338 LogRelBackdoor(("Could not register bugcheck callback routine!\n")); 339 340 return rc; 116 LogRelBackdoor(("VBoxGuest: Could not register bugcheck callback routine!\n")); 341 117 } 342 118 … … 350 126 } 351 127 } 352 #endif 128 129 #endif /* VBOX_WITH_GUEST_BUGCHECK_DETECTION */ 130
Note:
See TracChangeset
for help on using the changeset viewer.