DHPDEV DrvEnablePDEV( DEVMODEW *pDevmode, // Pointer to DEVMODE PWSTR pwszLogAddress, // Logical address ULONG cPatterns, // number of patterns HSURF *ahsurfPatterns, // return standard patterns ULONG cjGdiInfo, // Length of memory pointed to by pGdiInfo ULONG *pGdiInfo, // Pointer to GdiInfo structure ULONG cjDevInfo, // Length of following PDEVINFO structure DEVINFO *pDevInfo, // physical device information structure HDEV hdev, // HDEV, used for callbacks PWSTR pwszDeviceName, // DeviceName - not used HANDLE hDriver) // Handle to base driver { GDIINFO GdiInfo; DEVINFO DevInfo; PPDEV ppdev = (PPDEV) NULL; UNREFERENCED_PARAMETER(pwszLogAddress); UNREFERENCED_PARAMETER(pwszDeviceName); // Allocate a physical device structure. ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG); if (ppdev == (PPDEV) NULL) { RIP("DISP DrvEnablePDEV failed EngAllocMem\n"); return((DHPDEV) 0); } memset(ppdev, 0, sizeof(PDEV)); // Save the screen handle in the PDEV. ppdev->hDriver = hDriver; // Get the current screen mode information. Set up device caps and devinfo. if (!bInitPDEV(ppdev, pDevmode, &GdiInfo, &DevInfo)) { DISPDBG((0,"DISP DrvEnablePDEV failed\n")); goto error_free; } // eVb: 1.2 [VGARISC Change] - Disable hardware pointer support #if 0 // Initialize the cursor information. if (!bInitPointer(ppdev, &DevInfo)) { // Not a fatal error... DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n")); } #endif // eVb: 1.2 [END] // Initialize palette information. if (!bInitPaletteInfo(ppdev, &DevInfo)) { RIP("DrvEnablePDEV failed bInitPalette\n"); goto error_free; } // Copy the devinfo into the engine buffer. memcpy(pDevInfo, &DevInfo, min(sizeof(DEVINFO), cjDevInfo)); // Set the pdevCaps with GdiInfo we have prepared to the list of caps for this // pdev. memcpy(pGdiInfo, &GdiInfo, min(cjGdiInfo, sizeof(GDIINFO))); return((DHPDEV) ppdev); // Error case for failure. error_free: EngFreeMem(ppdev); return((DHPDEV) 0); }
DHPDEV DrvEnablePDEV ( DEVMODEW *pdrivw, PWSTR pwszLogAddress, ULONG cPatterns, HSURF *ahsurfPatterns, ULONG cjGdiInfo, ULONG *pdevcaps, ULONG cb, PDEVINFO pdevinfo, HDEV hdev, // HDEV, used for callbacks PWSTR pwszDeviceName, HANDLE hDriver // Handle to base driver ) { PPDEV ppdev; DISPDBG((2, "enabling PDEV\n")); // // Define flag to keep track of allocation // ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG); if (ppdev == NULL) { goto errorAllocPDEV; } memset(ppdev, 0, sizeof(PDEV)); // // Identifier, for debugging purposes // ppdev->ident = PDEV_IDENT; // // Cache the device driver handle away for later use. // ppdev->hDriver = hDriver; // // Initialize the cursor stuff. We can violate the atomic rule here // since nobody can talk to the driver yet. // ppdev->xyCursor.x = 320; // Non-atomic ppdev->xyCursor.y = 240; // Non-atomic ppdev->ptlExtent.x = 0; ppdev->ptlExtent.y = 0; ppdev->cExtent = 0; ppdev->flCursor = CURSOR_DOWN; // // Get the current screen mode information. Set up device caps and devinfo. // if (!bInitPDEV(ppdev, pdrivw, &gaulCap, &devinfoVGA)) { DISPDBG((1, "DrvEnablePDEV failed bInitPDEV\n")); goto errorbInitPDEV; } cjGdiInfo=min(cjGdiInfo, sizeof(GDIINFO)); memcpy(pdevcaps, &gaulCap, cjGdiInfo); // Now let's pass back the devinfo devinfoVGA.hpalDefault = EngCreatePalette(PAL_INDEXED, 16, (PULONG) (logPalVGA.palPalEntry), 0, 0, 0); if (devinfoVGA.hpalDefault == (HPALETTE) 0) { goto errorEngCreatePalette; } *pdevinfo = devinfoVGA; // Try to preallocate a saved screen bits buffer. If we fail, set the flag // to indicate the buffer is in use, so that we'll never attempt to use it. // If we succeed, mark the buffer as free. if ((ppdev->pjPreallocSSBBuffer = (PUCHAR) EngAllocMem(0, PREALLOC_SSB_SIZE, ALLOC_TAG)) != NULL) { ppdev->flPreallocSSBBufferInUse = FALSE; ppdev->ulPreallocSSBSize = PREALLOC_SSB_SIZE; } else { ppdev->flPreallocSSBBufferInUse = TRUE; } // Fill in the DIB4->VGA conversion tables. Allow 256 extra bytes so that // we can always safely align the tables to a 256-byte boundary, for // look-up reasons. There are four tables, each 256 bytes long ppdev->pucDIB4ToVGAConvBuffer = (UCHAR *) EngAllocMem(0, (256*4+256)*sizeof(UCHAR), ALLOC_TAG); if (ppdev->pucDIB4ToVGAConvBuffer == NULL) { goto errorAllocpucDIB4ToVGAConvBuffer; } // Round the table start up to the nearest 256 byte boundary, because the // tables must start on 256-byte boundaries for look-up reasons ppdev->pucDIB4ToVGAConvTables = (UCHAR *) ((ULONG) (ppdev->pucDIB4ToVGAConvBuffer + 0xFF) & ~0xFF); vSetDIB4ToVGATables(ppdev->pucDIB4ToVGAConvTables); return((DHPDEV) ppdev); errorAllocpucDIB4ToVGAConvBuffer: // // Free the preallocated saved screen bits buffer, if there is one. // if (ppdev->pjPreallocSSBBuffer != NULL) { EngFreeMem(ppdev->pjPreallocSSBBuffer); } EngDeletePalette(devinfoVGA.hpalDefault); errorEngCreatePalette: errorbInitPDEV: EngFreeMem(ppdev); errorAllocPDEV: return((DHPDEV) 0); UNREFERENCED_PARAMETER(cb); UNREFERENCED_PARAMETER(pwszLogAddress); UNREFERENCED_PARAMETER(pwszDeviceName); }