Skip to content

Commit

Permalink
Diagnosing WIN32SS video init.
Browse files Browse the repository at this point in the history
  • Loading branch information
HBelusca committed Oct 19, 2023
1 parent 2b66dc2 commit 435ec43
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 14 deletions.
23 changes: 23 additions & 0 deletions win32ss/drivers/displays/framebuf/surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@

#include "framebuf.h"


#ifndef NDEBUG
#define DPRINT DbgPrint
#else
#define DPRINT
#endif
#define DPRINT1 DbgPrint

ULONG DbgPrint(PCCH Format,...)
{
va_list ap;
va_start(ap, Format);
EngDebugPrint("VGADDI", (PCHAR)Format, ap);
va_end(ap);
return 0;
}


/*
* DrvEnableSurface
*
Expand Down Expand Up @@ -50,6 +68,8 @@ DrvEnableSurface(
&(ppdev->ModeIndex), sizeof(ULONG), NULL, 0,
&ulTemp))
{
DPRINT1("DrvEnableSurface - EngDeviceIoControl(IOCTL_VIDEO_SET_CURRENT_MODE ModeIndex = %lu) failing\n", ppdev->ModeIndex);
__debugbreak();
return NULL;
}

Expand All @@ -63,6 +83,7 @@ DrvEnableSurface(
&VideoMemoryInfo, sizeof(VIDEO_MEMORY_INFORMATION),
&ulTemp))
{
DPRINT1("DrvEnableSurface - EngDeviceIoControl(IOCTL_VIDEO_MAP_VIDEO_MEMORY) failing\n");
return NULL;
}

Expand Down Expand Up @@ -101,6 +122,7 @@ DrvEnableSurface(
ppdev->ScreenPtr);
if (hSurface == NULL)
{
DPRINT1("DrvEnableSurface - EngCreateBitmap() failing\n");
return NULL;
}

Expand All @@ -110,6 +132,7 @@ DrvEnableSurface(

if (!EngAssociateSurface(hSurface, ppdev->hDevEng, 0))
{
DPRINT1("DrvEnableSurface - EngAssociateSurface() failing\n");
EngDeleteSurface(hSurface);
return NULL;
}
Expand Down
22 changes: 14 additions & 8 deletions win32ss/gdi/eng/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ EngpUpdateGraphicsDeviceList(VOID)

/* Initialize the driver for this device */
pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
if (!pGraphicsDevice) continue;
if (!pGraphicsDevice)
{
ERR("InitDisplayDriver(%S, %S) failed!\n", awcDeviceName, awcDeviceName);
continue;
}

/* Check if this is a VGA compatible adapter */
if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
Expand All @@ -245,7 +249,7 @@ EngpUpdateGraphicsDeviceList(VOID)
if (!gpVgaGraphicsDevice)
{
gpVgaGraphicsDevice = pGraphicsDevice;
TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
ERR("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
}
}
bFoundNewDevice = TRUE;
Expand All @@ -254,7 +258,7 @@ EngpUpdateGraphicsDeviceList(VOID)
if (!gpPrimaryGraphicsDevice || EngpHasVgaDriver(gpPrimaryGraphicsDevice))
{
gpPrimaryGraphicsDevice = pGraphicsDevice;
TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
ERR("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
}
}

Expand All @@ -268,9 +272,10 @@ EngpUpdateGraphicsDeviceList(VOID)
!gpPrimaryGraphicsDevice->pVgaDevice)
{
/* Yes. Remove VGA device from global list, and attach it to primary device */
TRACE("Linking VGA device %S to primary device %S\n", gpVgaGraphicsDevice->szNtDeviceName, gpPrimaryGraphicsDevice->szNtDeviceName);
ERR("Linking VGA device %S to primary device %S\n", gpVgaGraphicsDevice->szNtDeviceName, gpPrimaryGraphicsDevice->szNtDeviceName);
EngpUnlinkGraphicsDevice(gpVgaGraphicsDevice);
gpPrimaryGraphicsDevice->pVgaDevice = gpVgaGraphicsDevice;
ERR("Using VGA device...\n");
}

if (bFoundNewDevice && gbBaseVideo)
Expand All @@ -288,7 +293,7 @@ EngpUpdateGraphicsDeviceList(VOID)
{
/* Not base-video device. Remove it */
pToDelete = pGraphicsDevice;
TRACE("Removing non-base-video device %S (%S)\n", pToDelete->szWinDeviceName, pToDelete->szNtDeviceName);
ERR("Removing non-base-video device %S (%S)\n", pToDelete->szWinDeviceName, pToDelete->szNtDeviceName);

EngpUnlinkGraphicsDevice(pGraphicsDevice);
pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice;
Expand Down Expand Up @@ -508,7 +513,7 @@ EngpRegisterGraphicsDevice(
PWSTR pwsz;
ULONG cj;

TRACE("EngpRegisterGraphicsDevice(%wZ)\n", pustrDeviceName);
ERR("EngpRegisterGraphicsDevice(%wZ)\n", pustrDeviceName);

/* Allocate a GRAPHICS_DEVICE structure */
pGraphicsDevice = ExAllocatePoolZero(PagedPool,
Expand Down Expand Up @@ -620,7 +625,7 @@ EngpRegisterGraphicsDevice(

/* Unlock loader */
EngReleaseSemaphore(ghsemGraphicsDeviceList);
TRACE("Prepared %lu modes for %ls\n", pGraphicsDevice->cDevModes, pGraphicsDevice->pwszDescription);
ERR("Prepared %lu modes for %ls\n", pGraphicsDevice->cDevModes, pGraphicsDevice->pwszDescription);

/* HACK: already in graphic mode; display wallpaper on this new display */
if (ScreenDeviceContext)
Expand All @@ -645,7 +650,8 @@ EngpFindGraphicsDevice(
UNICODE_STRING ustrCurrent;
PGRAPHICS_DEVICE pGraphicsDevice;
ULONG i;
TRACE("EngpFindGraphicsDevice('%wZ', %lu)\n",

ERR("EngpFindGraphicsDevice('%wZ', %lu)\n",
pustrDevice, iDevNum);

/* Lock list */
Expand Down
18 changes: 14 additions & 4 deletions win32ss/gdi/ntgdi/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <win32k.h>

#define NDEBUG
// #define NDEBUG
#include <debug.h>

PDC defaultDCstate = NULL;
Expand All @@ -17,12 +17,13 @@ BOOL FASTCALL
IntCreatePrimarySurface(VOID)
{
/* Create surface */
PDEVOBJ_pSurface(gpmdev->ppdevGlobal);
if (!PDEVOBJ_pSurface(gpmdev->ppdevGlobal))
return FALSE;

DPRINT("IntCreatePrimarySurface, ppdevGlobal=%p, ppdevGlobal->pSurface = %p\n",
DPRINT("IntCreatePrimarySurface() ppdevGlobal = 0x%p, ppdevGlobal->pSurface = 0x%p\n",
gpmdev->ppdevGlobal, gpmdev->ppdevGlobal->pSurface);

// Init Primary Displays Device Capabilities.
/* Init Primary Display Device Capabilities */
PDEVOBJ_vGetDeviceCaps(gpmdev->ppdevGlobal, &GdiHandleTable->DevCaps);

return TRUE;
Expand All @@ -31,6 +32,15 @@ IntCreatePrimarySurface(VOID)
VOID FASTCALL
IntDestroyPrimarySurface(VOID)
{
ASSERT(gpmdev);

DPRINT("IntDestroyPrimarySurface() ppdevGlobal = 0x%p, ppdevGlobal->pSurface = 0x%p\n",
gpmdev->ppdevGlobal, gpmdev->ppdevGlobal->pSurface);

ASSERT(gpmdev->ppdevGlobal->pSurface);
SURFACE_ShareUnlockSurface(gpmdev->ppdevGlobal->pSurface);
gpmdev->ppdevGlobal->pSurface = NULL;

UNIMPLEMENTED;
}

Expand Down
5 changes: 3 additions & 2 deletions win32ss/user/ntuser/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ InitDisplayDriver(
HKEY hkey;
DWORD dwVga;

TRACE("InitDisplayDriver(%S, %S);\n",
ERR("InitDisplayDriver(%S, %S);\n",
pwszDeviceName, pwszRegKey);

/* Open the driver's registry key */
Expand Down Expand Up @@ -153,7 +153,7 @@ InitVideo(VOID)
NTSTATUS Status;
HKEY hkey;

TRACE("----------------------------- InitVideo() -------------------------------\n");
ERR("----------------------------- InitVideo() -------------------------------\n");

/* Check if VGA mode is requested, by finding the special volatile key created by VIDEOPRT */
Status = RegOpenKey(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\BaseVideo", &hkey);
Expand All @@ -176,6 +176,7 @@ InitVideo(VOID)
{
/* There is, use the VGA device */
gpPrimaryGraphicsDevice = gpVgaGraphicsDevice;
ERR("Using VGA device...\n");
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions win32ss/user/ntuser/winsta.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ co_IntInitializeDesktopGraphics(VOID)
UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
PDESKTOP pdesk;

DbgBreakPoint();

if (PDEVOBJ_lChangeDisplaySettings(NULL, NULL, NULL, &gpmdev, TRUE) != DISP_CHANGE_SUCCESSFUL)
{
ERR("PDEVOBJ_lChangeDisplaySettings() failed.\n");
Expand Down

0 comments on commit 435ec43

Please sign in to comment.