[WIN32SS:ENG] Add EngpLinkGraphicsDevice, to add a device to gpGraphicsDeviceFirst list

This commit is contained in:
Hervé Poussineau 2022-11-10 22:11:22 +01:00
parent 3d01a103d7
commit b3cdb7e713

View file

@ -98,6 +98,36 @@ EngpHasVgaDriver(
return (_wcsnicmp(awcServiceName, L"VGA", 3) == 0);
}
/*
* Add a device to gpGraphicsDeviceFirst/gpGraphicsDeviceLast list (if not already present).
*/
_Requires_lock_held_(ghsemGraphicsDeviceList)
static
VOID
EngpLinkGraphicsDevice(
_In_ PGRAPHICS_DEVICE pToAdd)
{
PGRAPHICS_DEVICE pGraphicsDevice;
TRACE("EngLinkGraphicsDevice(%p)\n", pToAdd);
/* Search if device is not already linked */
for (pGraphicsDevice = gpGraphicsDeviceFirst;
pGraphicsDevice;
pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
{
if (pGraphicsDevice == pToAdd)
return;
}
pToAdd->pNextGraphicsDevice = NULL;
if (gpGraphicsDeviceLast)
gpGraphicsDeviceLast->pNextGraphicsDevice = pToAdd;
gpGraphicsDeviceLast = pToAdd;
if (!gpGraphicsDeviceFirst)
gpGraphicsDeviceFirst = pToAdd;
}
/*
* Remove a device from gpGraphicsDeviceFirst/gpGraphicsDeviceLast list.
*/
@ -567,12 +597,7 @@ EngpRegisterGraphicsDevice(
EngAcquireSemaphore(ghsemGraphicsDeviceList);
/* Insert the device into the global list */
pGraphicsDevice->pNextGraphicsDevice = NULL;
if (gpGraphicsDeviceLast)
gpGraphicsDeviceLast->pNextGraphicsDevice = pGraphicsDevice;
gpGraphicsDeviceLast = pGraphicsDevice;
if (!gpGraphicsDeviceFirst)
gpGraphicsDeviceFirst = pGraphicsDevice;
EngpLinkGraphicsDevice(pGraphicsDevice);
/* Increment the device number */
giDevNum++;