static VOID NTAPI XenGfxChangeXgfxMode(PXENGFX_DEVICE_EXTENSION pXenGfxExtension, BOOLEAN Enable) { ULONG ControlReg; if ((Enable)&&(!pXenGfxExtension->XgfxMode)) { ControlReg = VideoPortReadRegisterUlong((PULONG)(pXenGfxExtension->pGlobal + XGFX_CONTROL)); // Enable XGFX mode (note the interrupt is not enabled currently). ControlReg |= XGFX_CONTROL_HIRES_EN; VideoPortWriteRegisterUlong((PULONG)(pXenGfxExtension->pGlobal + XGFX_CONTROL), ControlReg); pXenGfxExtension->XgfxMode = TRUE; } else if ((!Enable)&&(pXenGfxExtension->XgfxMode)) { ControlReg = VideoPortReadRegisterUlong((PULONG)(pXenGfxExtension->pGlobal + XGFX_CONTROL)); // Disable XGFX mode ControlReg &= ~(XGFX_CONTROL_HIRES_EN); VideoPortWriteRegisterUlong((PULONG)(pXenGfxExtension->pGlobal + XGFX_CONTROL), ControlReg); pXenGfxExtension->XgfxMode = FALSE; } }
static BOOLEAN NTAPI XenGfxInitializeEdid(PXENGFX_DEVICE_EXTENSION pXenGfxExtension) { UCHAR Sum = 0; ULONG i; UCHAR *pEdidBuf; int notDone; PUCHAR edidOffset = pXenGfxExtension->pVCrtc0 + XGFX_VCRTC_EDID; PULONG pEdid; // Allocate a single page for the VCRTC0 EDID and fetch it. pXenGfxExtension->pEdid = XenGfxAllocateContiguousPages(1); if (pXenGfxExtension->pEdid == NULL) { TraceError(("%s Failed to allocate EDID page!\n", __FUNCTION__)); return FALSE; } pEdid = (PULONG)pXenGfxExtension->pEdid; //Request memory VideoPortWriteRegisterUlong((PULONG)(pXenGfxExtension->pVCrtc0 + XGFX_VCRTC_EDID_REQUEST), 1); do { notDone = VideoPortReadRegisterUlong( (PULONG) (pXenGfxExtension->pVCrtc0 + XGFX_VCRTC_EDID_REQUEST)); }while (notDone); for (i = 0; i < 4096/sizeof(ULONG); i++) { pEdid[i] = VideoPortReadRegisterUlong( (PULONG) (edidOffset + (i * sizeof(ULONG)))); } // Check the checksum pEdidBuf = (UCHAR*)pXenGfxExtension->pEdid; for (i = 0; i < XENGFX_EDID_SIZE; i++) Sum += pEdidBuf[i]; if (Sum != 0) { TraceWarning(("%s EDID checksum is not valid.\n", __FUNCTION__)); } // The XDDM driver will not attempt to report extensions after the EDID. Clear // the Extension flag. if (pXenGfxExtension->pEdid->ExtensionFlag[0] != 0) { pXenGfxExtension->pEdid->ExtensionFlag[0] = 0; Sum = 1; } // Recalculate the checksum if needed. if (Sum != 0) { Sum = 0; pXenGfxExtension->pEdid->Checksum[0] = 0; for (i = 0; i < XENGFX_EDID_SIZE; i++) Sum += pEdidBuf[i]; pXenGfxExtension->pEdid->Checksum[0] = -Sum; } return TRUE; }
BOOLEAN P91TestVideoMemory( PHW_DEVICE_EXTENSION HwDeviceExtension, USHORT iNumLongWords ) /*++ Routine Description: Routine to check if our memory configuration is set right. Argumentss: HwDeviceExtension - Pointer to the miniport driver's device extension. Specified number of longwords to test. Return Values: TRUE == if video memory checks out OK. FALSE == otherwise. --*/ { unsigned long i; ULONG ulOtherBankBits; ULONG aulOldBits[32]; BOOLEAN bRet = TRUE; // // The SandleFoot blue screen showed corruption from this test. // We tried to not save this data, but we had to. // In addition to saving the screen data around the test, we have also // saved the state of the Memory Configuration register. ulOtherBankBits = VideoPortReadRegisterUlong((PULONG) HwDeviceExtension->FrameAddress + 0x8000); for (i = 0; i < 32; i++) { aulOldBits[i] = VideoPortReadRegisterUlong((PULONG) HwDeviceExtension->FrameAddress + i); } // // Make sure you cause a row change at the beginning of the memory // by first accessing a location that is guaranteed to be in another row. // VideoPortWriteRegisterUlong((PULONG) HwDeviceExtension->FrameAddress + 0x8000, 0x5A5A5A5A); // // Test iNumLongWords doubleword locations by writing the inverse of the // address to each memory location. // for (i = 0 ; i < iNumLongWords; i++) { VideoPortWriteRegisterUlong((PULONG) HwDeviceExtension->FrameAddress + i, ~i); } // // Now read them back and test for failure // for (i = 0 ; i < iNumLongWords; i++) { // // If any one fails, return error... // if (VideoPortReadRegisterUlong((PULONG) HwDeviceExtension->FrameAddress + i) != ~i) { bRet = FALSE; break; } } // // Restore everything. // VideoPortWriteRegisterUlong((PULONG) HwDeviceExtension->FrameAddress + 0x8000, ulOtherBankBits); for (i = 0; i < 32; i++) { VideoPortWriteRegisterUlong((PULONG) HwDeviceExtension->FrameAddress + i, aulOldBits[i]); } // // If all of them work, return success // return(bRet); } // End of int P91TestVideoMemory()