implement user mode catchable exceptions, refactor system status codes to use NTLSTATUS_ prefix, update build scripts to use shared literal macros for linker arguments, update named queue lifetime cleanup to include KeNamedQueueUnpublishHandle.
This commit is contained in:
1 parent
1f5477cf66
commit
b7fcfce6f7
140 files changed
+7649
-3943
No files matched your search
@@ -46,7 +46,7 @@ static uint32_t VmwSvgaProbeId(VMWSVGA_DEVICE* v) {
|
||||
// Chooses the runtime display mode, preferring the current boot framebuffer size.
|
||||
static KSTATUS VmwSvgaChooseMode(uint32_t* outWidth, uint32_t* outHeight) {
|
||||
if (!outWidth || !outHeight)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
DISPLAY_MODE current;
|
||||
memset(¤t, 0, sizeof(current));
|
||||
@@ -55,12 +55,12 @@ static KSTATUS VmwSvgaChooseMode(uint32_t* outWidth, uint32_t* outHeight) {
|
||||
current.Width > 0 && current.Height > 0) {
|
||||
*outWidth = current.Width;
|
||||
*outHeight = current.Height;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
*outWidth = 1024;
|
||||
*outHeight = 768;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Programs the visible guest display rectangle used by the legacy framebuffer path.
|
||||
@@ -81,7 +81,7 @@ static void VmwSvgaProgramLegacyDisplayTopology(VMWSVGA_DEVICE* v, uint32_t widt
|
||||
// Programs the SVGA device mode before FIFO and framebuffer use.
|
||||
static KSTATUS VmwSvgaSetMode(VMWSVGA_DEVICE* v) {
|
||||
if (!v)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
uint32_t desiredWidth = 0;
|
||||
uint32_t desiredHeight = 0;
|
||||
@@ -97,7 +97,7 @@ static KSTATUS VmwSvgaSetMode(VMWSVGA_DEVICE* v) {
|
||||
if (maxHeight && desiredHeight > maxHeight)
|
||||
desiredHeight = maxHeight;
|
||||
if (desiredWidth == 0 || desiredHeight == 0)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
VmwSvgaWriteReg(v, SVGA_REG_CONFIG_DONE, 0u);
|
||||
VmwSvgaWriteReg(v, SVGA_REG_ENABLE, 0u);
|
||||
@@ -116,7 +116,7 @@ static KSTATUS VmwSvgaSetMode(VMWSVGA_DEVICE* v) {
|
||||
|
||||
DbgPrint("VMWSVGA: requested mode %ux%u max=%ux%u caps=0x%x\n",
|
||||
desiredWidth, desiredHeight, maxWidth, maxHeight, caps);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Clips a display rectangle to the current framebuffer bounds.
|
||||
@@ -156,18 +156,18 @@ static uint32_t VmwSvgaFifoNext(VMWSVGA_DEVICE* v, uint32_t offset) {
|
||||
// Writes one command dword into the SVGA FIFO and waits for space if needed.
|
||||
static KSTATUS VmwSvgaFifoWrite(VMWSVGA_DEVICE* v, uint32_t value) {
|
||||
if (!v || !v->FifoReady || !v->Fifo)
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
|
||||
uint32_t min = v->Fifo[SVGA_FIFO_MIN];
|
||||
uint32_t max = v->Fifo[SVGA_FIFO_MAX];
|
||||
if (min < SVGA_FIFO_NUM_LEGACY_REGS * sizeof(uint32_t) || max > v->FifoBytes || min >= max)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
for (uint32_t guard = 0; guard < VMWSVGA_MAX_WAIT_ITERS; guard++) {
|
||||
uint32_t next = v->Fifo[SVGA_FIFO_NEXT_CMD];
|
||||
uint32_t stop = v->Fifo[SVGA_FIFO_STOP];
|
||||
if (next < min || next >= max || stop < min || stop >= max)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
uint32_t nextAfter = VmwSvgaFifoNext(v, next);
|
||||
if (nextAfter != stop) {
|
||||
@@ -175,7 +175,7 @@ static KSTATUS VmwSvgaFifoWrite(VMWSVGA_DEVICE* v, uint32_t value) {
|
||||
_ReadWriteBarrier();
|
||||
v->Fifo[SVGA_FIFO_NEXT_CMD] = nextAfter;
|
||||
_ReadWriteBarrier();
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
KSTATUS syncSt = VmwSvgaSyncDevice(v);
|
||||
@@ -183,7 +183,7 @@ static KSTATUS VmwSvgaFifoWrite(VMWSVGA_DEVICE* v, uint32_t value) {
|
||||
return syncSt;
|
||||
}
|
||||
|
||||
return STATUS_TIMEOUT;
|
||||
return NTLSTATUS_TIMEOUT;
|
||||
}
|
||||
|
||||
// Checks whether an extended FIFO register is valid for this device.
|
||||
@@ -406,14 +406,14 @@ static KSTATUS VmwSvgaDefineClassicCursor(VMWSVGA_DEVICE* v, int width, int heig
|
||||
size_t pixelCount = (size_t)encodedWidth * (size_t)height;
|
||||
|
||||
if (encodedWidth > 256 || pixelCount > 256u * 256u)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
uint8_t* andBits = (uint8_t*)MmAllocatePool(pixelCount);
|
||||
uint8_t* xorBits = (uint8_t*)MmAllocatePool(pixelCount);
|
||||
if (!andBits || !xorBits) {
|
||||
if (andBits) MmFreePool(andBits);
|
||||
if (xorBits) MmFreePool(xorBits);
|
||||
return STATUS_NO_MEMORY;
|
||||
return NTLSTATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
VmwSvgaBuildMonoCursorBits(argbPixels, width, encodedWidth, height, andBits, xorBits);
|
||||
@@ -463,9 +463,9 @@ done:
|
||||
// Implements the upload Cursor Image operation.
|
||||
static KSTATUS VmwSvgaUploadCursorImage(VMWSVGA_DEVICE* v, int width, int height, int hotX, int hotY, const uint32_t* argbPixels) {
|
||||
if (!v || !v->HardwareCursor || !argbPixels || width <= 0 || height <= 0)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
if (width > 256 || height > 256 || hotX < 0 || hotY < 0 || hotX >= width || hotY >= height)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
KSTATUS st;
|
||||
if (v->AlphaCursor)
|
||||
@@ -481,14 +481,14 @@ static KSTATUS VmwSvgaUploadCursorImage(VMWSVGA_DEVICE* v, int width, int height
|
||||
// Implements the define Cursor Image operation.
|
||||
static KSTATUS VmwSvgaDefineCursorImage(VMWSVGA_DEVICE* v, int width, int height, int hotX, int hotY, const uint32_t* argbPixels) {
|
||||
if (!v || !v->HardwareCursor || !argbPixels || width <= 0 || height <= 0)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
if (width > 256 || height > 256 || hotX < 0 || hotY < 0 || hotX >= width || hotY >= height)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
size_t bytes = (size_t)width * (size_t)height * sizeof(uint32_t);
|
||||
uint32_t* copy = (uint32_t*)MmAllocatePool(bytes);
|
||||
if (!copy)
|
||||
return STATUS_NO_MEMORY;
|
||||
return NTLSTATUS_NO_MEMORY;
|
||||
memcpy(copy, argbPixels, bytes);
|
||||
|
||||
KSTATUS st = VmwSvgaUploadCursorImage(v, width, height, hotX, hotY, copy);
|
||||
@@ -506,7 +506,7 @@ static KSTATUS VmwSvgaDefineCursorImage(VMWSVGA_DEVICE* v, int width, int height
|
||||
v->CursorHotX = hotX;
|
||||
v->CursorHotY = hotY;
|
||||
v->CursorImageDefined = true;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the align Up32 operation.
|
||||
@@ -517,7 +517,7 @@ static uint32_t VmwSvgaAlignUp32(uint32_t value, uint32_t alignment) {
|
||||
// Implements the define Screen Object operation.
|
||||
static KSTATUS VmwSvgaDefineScreenObject(VMWSVGA_DEVICE* v) {
|
||||
if (!v || !v->FifoReady || !v->UseScreenObject)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
KSTATUS st = VmwSvgaFifoWrite(v, SVGA_CMD_DEFINE_SCREEN);
|
||||
if (!KSUCCESS(st)) return st;
|
||||
@@ -552,7 +552,7 @@ static KSTATUS VmwSvgaDefineScreenObject(VMWSVGA_DEVICE* v) {
|
||||
// Implements the define Gmrfb operation.
|
||||
static KSTATUS VmwSvgaDefineGmrfb(VMWSVGA_DEVICE* v) {
|
||||
if (!v || !v->FifoReady || !v->UseScreenObject)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
KSTATUS st = VmwSvgaFifoWrite(v, SVGA_CMD_DEFINE_GMRFB);
|
||||
if (!KSUCCESS(st)) return st;
|
||||
@@ -564,14 +564,14 @@ static KSTATUS VmwSvgaDefineGmrfb(VMWSVGA_DEVICE* v) {
|
||||
if (!KSUCCESS(st)) return st;
|
||||
st = VmwSvgaFifoWrite(v, SVGA_GMRFB_FORMAT_32BPP_24DEPTH);
|
||||
if (!KSUCCESS(st)) return st;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Blits gmrfb To Screen.
|
||||
static KSTATUS VmwSvgaBlitGmrfbToScreen(VMWSVGA_DEVICE* v, int x, int y, int w, int h) {
|
||||
DISPLAY_RECT r = { x, y, w, h };
|
||||
if (!VmwSvgaClipRect(v, &r))
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
KSTATUS st = VmwSvgaFifoWrite(v, SVGA_CMD_BLIT_GMRFB_TO_SCREEN);
|
||||
if (!KSUCCESS(st)) return st;
|
||||
@@ -591,13 +591,13 @@ static KSTATUS VmwSvgaBlitGmrfbToScreen(VMWSVGA_DEVICE* v, int x, int y, int w,
|
||||
if (!KSUCCESS(st)) return st;
|
||||
|
||||
VmwSvgaWakeFifo(v);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Initializes screen Object.
|
||||
static KSTATUS VmwSvgaInitializeScreenObject(VMWSVGA_DEVICE* v) {
|
||||
if (!v || !v->FifoReady)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
DbgPrint("VMWSVGA: screen object probe caps=0x%x fifoCaps=0x%x\n", v->Capabilities, v->FifoCaps);
|
||||
|
||||
@@ -616,7 +616,7 @@ static KSTATUS VmwSvgaInitializeScreenObject(VMWSVGA_DEVICE* v) {
|
||||
hasScreenObject2 ? 1u : 0u,
|
||||
v->Capabilities,
|
||||
v->FifoCaps);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
DbgPrint("VMWSVGA: using screen object generation %u\n", hasScreenObject2 ? 2u : 1u);
|
||||
@@ -630,7 +630,7 @@ static KSTATUS VmwSvgaInitializeScreenObject(VMWSVGA_DEVICE* v) {
|
||||
(uint64_t)backingOffset + backingBytes > v->FramebufferBytes) {
|
||||
DbgPrint("VMWSVGA: screen object disabled; insufficient GFB source=0x%x backing=0x%x fbLen=0x%llx\n",
|
||||
sourceBytes, backingBytes, (unsigned long long)v->FramebufferBytes);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
v->ScreenId = SVGA_SCREEN_OBJECT_ID_PRIMARY;
|
||||
@@ -655,14 +655,14 @@ static KSTATUS VmwSvgaInitializeScreenObject(VMWSVGA_DEVICE* v) {
|
||||
|
||||
DbgPrint("VMWSVGA: screen object enabled id=%u sourceOff=0x%x backingOff=0x%x bytes=0x%x\n",
|
||||
v->ScreenId, v->ScreenSourceOffset, v->ScreenBackingOffset, v->ScreenSourceBytes);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the legacy Update operation.
|
||||
static KSTATUS VmwSvgaLegacyUpdate(VMWSVGA_DEVICE* v, int x, int y, int w, int h) {
|
||||
DISPLAY_RECT r = { x, y, w, h };
|
||||
if (!VmwSvgaClipRect(v, &r))
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
KSTATUS st = VmwSvgaFifoWrite(v, SVGA_CMD_UPDATE);
|
||||
if (!KSUCCESS(st)) return st;
|
||||
@@ -676,14 +676,14 @@ static KSTATUS VmwSvgaLegacyUpdate(VMWSVGA_DEVICE* v, int x, int y, int w, int h
|
||||
if (!KSUCCESS(st)) return st;
|
||||
|
||||
VmwSvgaWakeFifo(v);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Updates the requested value.
|
||||
static KSTATUS VmwSvgaUpdate(VMWSVGA_DEVICE* v, int x, int y, int w, int h) {
|
||||
DISPLAY_RECT r = { x, y, w, h };
|
||||
if (!VmwSvgaClipRect(v, &r))
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
v->Stats.DirtyRectCount++;
|
||||
|
||||
@@ -699,17 +699,17 @@ static KSTATUS VmwSvgaUpdate(VMWSVGA_DEVICE* v, int x, int y, int w, int h) {
|
||||
// Waits until the SVGA host has consumed the queued FIFO work.
|
||||
static KSTATUS VmwSvgaSyncDevice(VMWSVGA_DEVICE* v) {
|
||||
if (!v)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
v->Stats.SyncCount++;
|
||||
VmwSvgaWriteReg(v, SVGA_REG_SYNC, 1u);
|
||||
for (uint32_t guard = 0; guard < VMWSVGA_MAX_WAIT_ITERS; guard++) {
|
||||
if (VmwSvgaReadReg(v, SVGA_REG_BUSY) == 0) {
|
||||
if (VmwSvgaHasFifoRegister(v, SVGA_FIFO_BUSY))
|
||||
v->Fifo[SVGA_FIFO_BUSY] = 0u;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
return STATUS_TIMEOUT;
|
||||
return NTLSTATUS_TIMEOUT;
|
||||
}
|
||||
|
||||
// Implements the blend Pixel operation.
|
||||
@@ -740,23 +740,23 @@ static VMWSVGA_DEVICE* VmwSvgaFromDisplay(DISPLAY_DEVICE* device) {
|
||||
static KSTATUS VmwSvgaDisplayGetMode(DISPLAY_DEVICE* device, DISPLAY_MODE* outMode) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v || !outMode || !v->Framebuffer)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
outMode->Width = v->Width;
|
||||
outMode->Height = v->Height;
|
||||
outMode->Stride = v->Stride;
|
||||
outMode->Format = DisplayPixelFormatX8R8G8B8;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the display Blit operation.
|
||||
static KSTATUS VmwSvgaDisplayBlit(DISPLAY_DEVICE* device, int x, int y, int w, int h, const uint32_t* pixels) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v || !v->Backbuffer || !pixels || w <= 0 || h <= 0)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
DISPLAY_RECT r = { x, y, w, h };
|
||||
if (!VmwSvgaClipRect(v, &r))
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
v->Stats.BlitCount++;
|
||||
v->Stats.BytesCopied += (uint64_t)(uint32_t)r.W * (uint64_t)(uint32_t)r.H * sizeof(uint32_t);
|
||||
@@ -769,18 +769,18 @@ static KSTATUS VmwSvgaDisplayBlit(DISPLAY_DEVICE* device, int x, int y, int w, i
|
||||
const uint32_t* src = pixels + ((size_t)(srcOffsetY + row) * (size_t)w) + srcOffsetX;
|
||||
memcpy(dst, src, bytesPerRow);
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the display Fill Rect operation.
|
||||
static KSTATUS VmwSvgaDisplayFillRect(DISPLAY_DEVICE* device, int x, int y, int w, int h, uint32_t color) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v || !v->Backbuffer || w <= 0 || h <= 0)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
DISPLAY_RECT r = { x, y, w, h };
|
||||
if (!VmwSvgaClipRect(v, &r))
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
v->Stats.FillRectCount++;
|
||||
v->Stats.BytesCopied += (uint64_t)(uint32_t)r.W * (uint64_t)(uint32_t)r.H * sizeof(uint32_t);
|
||||
@@ -790,14 +790,14 @@ static KSTATUS VmwSvgaDisplayFillRect(DISPLAY_DEVICE* device, int x, int y, int
|
||||
for (int xx = 0; xx < r.W; xx++)
|
||||
*dst++ = color;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the display Copy Rect operation.
|
||||
static KSTATUS VmwSvgaDisplayCopyRect(DISPLAY_DEVICE* device, int dstX, int dstY, int srcX, int srcY, int w, int h) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v || !v->Backbuffer || w <= 0 || h <= 0)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
if (srcX < 0) { int d = -srcX; srcX = 0; dstX += d; w -= d; }
|
||||
if (srcY < 0) { int d = -srcY; srcY = 0; dstY += d; h -= d; }
|
||||
@@ -808,7 +808,7 @@ static KSTATUS VmwSvgaDisplayCopyRect(DISPLAY_DEVICE* device, int dstX, int dstY
|
||||
if (srcY + h > (int)v->Height) h = (int)v->Height - srcY;
|
||||
if (dstY + h > (int)v->Height) h = (int)v->Height - dstY;
|
||||
if (w <= 0 || h <= 0)
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
v->Stats.CopyRectCount++;
|
||||
v->Stats.BytesCopied += (uint64_t)(uint32_t)w * (uint64_t)(uint32_t)h * sizeof(uint32_t);
|
||||
@@ -827,18 +827,18 @@ static KSTATUS VmwSvgaDisplayCopyRect(DISPLAY_DEVICE* device, int dstX, int dstY
|
||||
memmove(dst, src, rowBytes);
|
||||
}
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the display Read Rect operation.
|
||||
static KSTATUS VmwSvgaDisplayReadRect(DISPLAY_DEVICE* device, int x, int y, int w, int h, uint32_t* outPixels, uint32_t outStride) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v || !v->Backbuffer || !outPixels || outStride == 0 || w <= 0 || h <= 0)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
DISPLAY_RECT r = { x, y, w, h };
|
||||
if (!VmwSvgaClipRect(v, &r))
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
v->Stats.ReadRectCount++;
|
||||
v->Stats.BytesCopied += (uint64_t)(uint32_t)r.W * (uint64_t)(uint32_t)r.H * sizeof(uint32_t);
|
||||
@@ -850,21 +850,21 @@ static KSTATUS VmwSvgaDisplayReadRect(DISPLAY_DEVICE* device, int x, int y, int
|
||||
uint32_t* dst = outPixels + ((size_t)(dstOffsetY + row) * outStride) + dstOffsetX;
|
||||
memcpy(dst, src, (size_t)r.W * sizeof(uint32_t));
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the display Present operation.
|
||||
static KSTATUS VmwSvgaDisplayPresent(DISPLAY_DEVICE* device, const DISPLAY_RECT* rects, size_t rectCount) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v || !v->Framebuffer || !v->Backbuffer)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
if (!rects || rectCount == 0)
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
v->Stats.PresentCount++;
|
||||
v->Stats.PresentRectCount += rectCount;
|
||||
|
||||
KSTATUS result = STATUS_SUCCESS;
|
||||
KSTATUS result = NTLSTATUS_SUCCESS;
|
||||
for (size_t i = 0; i < rectCount; i++) {
|
||||
DISPLAY_RECT r = rects[i];
|
||||
if (!VmwSvgaClipRect(v, &r))
|
||||
@@ -902,7 +902,7 @@ static KSTATUS VmwSvgaDisplaySync(DISPLAY_DEVICE* device) {
|
||||
static KSTATUS VmwSvgaDisplaySetCursorImage(DISPLAY_DEVICE* device, int width, int height, int hotX, int hotY, const uint32_t* argbPixels) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v || !v->HardwareCursor)
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
return VmwSvgaDefineCursorImage(v, width, height, hotX, hotY, argbPixels);
|
||||
}
|
||||
|
||||
@@ -910,13 +910,13 @@ static KSTATUS VmwSvgaDisplaySetCursorImage(DISPLAY_DEVICE* device, int width, i
|
||||
static KSTATUS VmwSvgaDisplaySetCursorPosition(DISPLAY_DEVICE* device, int x, int y) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
v->CursorX = x;
|
||||
v->CursorY = y;
|
||||
v->Stats.CursorMoveCount++;
|
||||
if (v->HardwareCursor && v->CursorImageDefined)
|
||||
VmwSvgaCursorSetPosition(v, x, y);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the restore Cursor operation.
|
||||
@@ -976,11 +976,11 @@ static void VmwSvgaDrawCursor(VMWSVGA_DEVICE* v) {
|
||||
static KSTATUS VmwSvgaDisplayShowCursor(DISPLAY_DEVICE* device, bool show) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
if (v->HardwareCursor) {
|
||||
if (!v->CursorImageDefined)
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
if (show) {
|
||||
v->Stats.CursorShowCount++;
|
||||
VmwSvgaCursorSetPosition(v, v->CursorX, v->CursorY);
|
||||
@@ -989,11 +989,11 @@ static KSTATUS VmwSvgaDisplayShowCursor(DISPLAY_DEVICE* device, bool show) {
|
||||
v->Stats.CursorHideCount++;
|
||||
VmwSvgaCursorSetVisible(v, false);
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (!v->Framebuffer || !v->Backbuffer)
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
|
||||
if (show) {
|
||||
v->Stats.CursorShowCount++;
|
||||
@@ -1004,16 +1004,16 @@ static KSTATUS VmwSvgaDisplayShowCursor(DISPLAY_DEVICE* device, bool show) {
|
||||
v->Stats.CursorHideCount++;
|
||||
VmwSvgaRestoreCursor(v);
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the display Query Stats operation.
|
||||
static KSTATUS VmwSvgaDisplayQueryStats(DISPLAY_DEVICE* device, DISPLAY_STATS* outStats) {
|
||||
VMWSVGA_DEVICE* v = VmwSvgaFromDisplay(device);
|
||||
if (!v || !outStats)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
*outStats = v->Stats;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static const DISPLAY_DEVICE_OPS gVmwSvgaDisplayOps = {
|
||||
@@ -1039,7 +1039,7 @@ static KSTATUS VmwSvgaSelectBars(VMWSVGA_DEVICE* v) {
|
||||
if (!KSUCCESS(st) || bar.Type != PciBarIo || bar.Base > 0xFFFFu) {
|
||||
DbgPrint("VMWSVGA: BAR0 is not a usable I/O register BAR st=0x%x type=%u base=0x%llx\n",
|
||||
st, bar.Type, (unsigned long long)bar.Base);
|
||||
return KSUCCESS(st) ? STATUS_NOT_SUPPORTED : st;
|
||||
return KSUCCESS(st) ? NTLSTATUS_NOT_SUPPORTED : st;
|
||||
}
|
||||
v->IoBar = bar;
|
||||
v->IoBase = (uint16_t)bar.Base;
|
||||
@@ -1047,17 +1047,17 @@ static KSTATUS VmwSvgaSelectBars(VMWSVGA_DEVICE* v) {
|
||||
st = PciGetBar(v->Pdo, 1, &bar);
|
||||
if (!KSUCCESS(st) || (bar.Type != PciBarMemory32 && bar.Type != PciBarMemory64)) {
|
||||
DbgPrint("VMWSVGA: BAR1 is not a usable framebuffer BAR st=0x%x type=%u\n", st, bar.Type);
|
||||
return KSUCCESS(st) ? STATUS_NOT_SUPPORTED : st;
|
||||
return KSUCCESS(st) ? NTLSTATUS_NOT_SUPPORTED : st;
|
||||
}
|
||||
v->FramebufferBar = bar;
|
||||
|
||||
st = PciGetBar(v->Pdo, 2, &bar);
|
||||
if (!KSUCCESS(st) || (bar.Type != PciBarMemory32 && bar.Type != PciBarMemory64)) {
|
||||
DbgPrint("VMWSVGA: BAR2 is not a usable FIFO BAR st=0x%x type=%u\n", st, bar.Type);
|
||||
return KSUCCESS(st) ? STATUS_NOT_SUPPORTED : st;
|
||||
return KSUCCESS(st) ? NTLSTATUS_NOT_SUPPORTED : st;
|
||||
}
|
||||
v->FifoBar = bar;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the mmio Page Flags operation.
|
||||
@@ -1076,7 +1076,7 @@ static KSTATUS VmwSvgaMapBars(VMWSVGA_DEVICE* v) {
|
||||
(unsigned long long)(uintptr_t)v->FramebufferMapping,
|
||||
(unsigned long long)v->FramebufferBar.Base,
|
||||
(unsigned long long)v->FramebufferBar.Length);
|
||||
return KSUCCESS(st) ? STATUS_DEVICE_ERROR : st;
|
||||
return KSUCCESS(st) ? NTLSTATUS_DEVICE_ERROR : st;
|
||||
}
|
||||
|
||||
st = PciMapBar(v->Pdo, 2, mmioFlags,
|
||||
@@ -1087,7 +1087,7 @@ static KSTATUS VmwSvgaMapBars(VMWSVGA_DEVICE* v) {
|
||||
(unsigned long long)(uintptr_t)v->Fifo,
|
||||
(unsigned long long)v->FifoBar.Base,
|
||||
(unsigned long long)v->FifoBar.Length);
|
||||
return KSUCCESS(st) ? STATUS_DEVICE_ERROR : st;
|
||||
return KSUCCESS(st) ? NTLSTATUS_DEVICE_ERROR : st;
|
||||
}
|
||||
|
||||
DbgPrint("VMWSVGA: BARs io=0x%04x fbBase=0x%llx fbLen=0x%llx fbVirt=0x%llx fifoBase=0x%llx fifoLen=0x%llx fifoVirt=0x%llx\n",
|
||||
@@ -1098,7 +1098,7 @@ static KSTATUS VmwSvgaMapBars(VMWSVGA_DEVICE* v) {
|
||||
(unsigned long long)v->FifoBar.Base,
|
||||
(unsigned long long)v->FifoBar.Length,
|
||||
(unsigned long long)(uintptr_t)v->Fifo);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Returns mode.
|
||||
@@ -1120,29 +1120,29 @@ static KSTATUS VmwSvgaReadMode(VMWSVGA_DEVICE* v) {
|
||||
|
||||
if (v->Width == 0 || v->Height == 0 || v->BytesPerLine == 0) {
|
||||
DbgPrint("VMWSVGA: invalid mode %ux%u pitch=%u\n", v->Width, v->Height, v->BytesPerLine);
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
}
|
||||
if (v->BitsPerPixel != 32) {
|
||||
DbgPrint("VMWSVGA: unsupported bpp=%u\n", v->BitsPerPixel);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
}
|
||||
if ((v->BytesPerLine & 3u) != 0) {
|
||||
DbgPrint("VMWSVGA: unsupported non-dword pitch=%u\n", v->BytesPerLine);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
v->Stride = v->BytesPerLine / sizeof(uint32_t);
|
||||
if (v->Stride < v->Width)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
if (!v->FramebufferMapping)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
uint64_t needed = (uint64_t)v->BytesPerLine * (uint64_t)v->Height;
|
||||
if (fbSize && needed > fbSize)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
if ((uint64_t)fbOffset > v->FramebufferBytes || needed > v->FramebufferBytes - (uint64_t)fbOffset)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
v->FramebufferOffset = fbOffset;
|
||||
v->Framebuffer = v->FramebufferMapping + fbOffset;
|
||||
@@ -1150,7 +1150,7 @@ static KSTATUS VmwSvgaReadMode(VMWSVGA_DEVICE* v) {
|
||||
v->BackbufferBytes = (size_t)needed;
|
||||
v->Backbuffer = (uint32_t*)MmAllocatePool(v->BackbufferBytes);
|
||||
if (!v->Backbuffer)
|
||||
return STATUS_NO_MEMORY;
|
||||
return NTLSTATUS_NO_MEMORY;
|
||||
|
||||
memset(v->Backbuffer, 0, v->BackbufferBytes);
|
||||
|
||||
@@ -1164,7 +1164,7 @@ static KSTATUS VmwSvgaReadMode(VMWSVGA_DEVICE* v) {
|
||||
fbStart,
|
||||
fifoSize,
|
||||
v->Capabilities);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Returns the active FIFO size reported by the device, not the larger PCI BAR aperture.
|
||||
@@ -1180,7 +1180,7 @@ static uint32_t VmwSvgaGetFifoMaxBytes(VMWSVGA_DEVICE* v) {
|
||||
// Initializes fifo.
|
||||
static KSTATUS VmwSvgaInitializeFifo(VMWSVGA_DEVICE* v) {
|
||||
if (!v->Fifo || v->FifoBytes < 4096u)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
VmwSvgaWriteReg(v, SVGA_REG_CONFIG_DONE, 0u);
|
||||
|
||||
@@ -1195,7 +1195,7 @@ static KSTATUS VmwSvgaInitializeFifo(VMWSVGA_DEVICE* v) {
|
||||
min = SVGA_FIFO_NUM_LEGACY_REGS * sizeof(uint32_t);
|
||||
|
||||
if (max <= min + 32u)
|
||||
return STATUS_DEVICE_ERROR;
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
|
||||
v->FifoRegCount = min / sizeof(uint32_t);
|
||||
|
||||
@@ -1221,15 +1221,15 @@ static KSTATUS VmwSvgaInitializeFifo(VMWSVGA_DEVICE* v) {
|
||||
v->FifoCaps,
|
||||
v->FifoDeviceBytes,
|
||||
(unsigned long long)v->FifoBytes);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Starts device.
|
||||
static KSTATUS VmwSvgaStartDevice(VMWSVGA_DEVICE* v) {
|
||||
if (!v || v->Magic != VMWSVGA_DEVICE_MAGIC || !v->Fdo || !v->Pdo)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
if (v->Started)
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
KSTATUS st = PciGetDeviceInfo(v->Pdo, &v->PciInfo);
|
||||
if (!KSUCCESS(st))
|
||||
@@ -1253,7 +1253,7 @@ static KSTATUS VmwSvgaStartDevice(VMWSVGA_DEVICE* v) {
|
||||
v->DeviceId = VmwSvgaProbeId(v);
|
||||
if (v->DeviceId == SVGA_ID_INVALID) {
|
||||
DbgPrint("VMWSVGA: SVGA ID probe failed\n");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
return NTLSTATUS_NOT_SUPPORTED;
|
||||
}
|
||||
VmwSvgaWriteReg(v, SVGA_REG_GUEST_ID, 0u);
|
||||
|
||||
@@ -1284,7 +1284,7 @@ static KSTATUS VmwSvgaStartDevice(VMWSVGA_DEVICE* v) {
|
||||
|
||||
#if VMWSVGA_ENABLE_SCREEN_OBJECTS
|
||||
KSTATUS screenSt = VmwSvgaInitializeScreenObject(v);
|
||||
if (!KSUCCESS(screenSt) && screenSt != STATUS_NOT_SUPPORTED)
|
||||
if (!KSUCCESS(screenSt) && screenSt != NTLSTATUS_NOT_SUPPORTED)
|
||||
DbgPrint("VMWSVGA: screen object init failed st=0x%x; using legacy GFB UPDATE\n", screenSt);
|
||||
#else
|
||||
v->UseScreenObject = false;
|
||||
@@ -1340,7 +1340,7 @@ static KSTATUS VmwSvgaStartDevice(VMWSVGA_DEVICE* v) {
|
||||
}
|
||||
|
||||
st = KeDisplayRegisterDevice(&v->DisplayDevice);
|
||||
if (!KSUCCESS(st) && st != STATUS_ALREADY_EXISTS) {
|
||||
if (!KSUCCESS(st) && st != NTLSTATUS_ALREADY_EXISTS) {
|
||||
KeDisplaySuspendConsole(false);
|
||||
return st;
|
||||
}
|
||||
@@ -1356,21 +1356,21 @@ static KSTATUS VmwSvgaStartDevice(VMWSVGA_DEVICE* v) {
|
||||
(void)VmwSvgaDisplaySync(&v->DisplayDevice);
|
||||
|
||||
DbgPrint("VMWSVGA: initialized as primary display id=0x%x io=0x%04x\n", v->DeviceId, v->IoBase);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Dispatches pnp.
|
||||
KSTATUS VmwSvgaDispatchPnp(DEVICE_OBJECT* device, IRP* irp) {
|
||||
if (!device || !irp || !device->DeviceExtension)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
VMWSVGA_DEVICE* v = (VMWSVGA_DEVICE*)device->DeviceExtension;
|
||||
if (v->Magic != VMWSVGA_DEVICE_MAGIC)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
IO_STACK_LOCATION* ios = IoGetCurrentIrpStackLocation(irp);
|
||||
if (!ios || ios->MajorFunction != IRP_MJ_PNP)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
switch ((IO_PNP_MINOR_FUNCTION)ios->MinorFunction) {
|
||||
case IRP_MN_START_DEVICE:
|
||||
@@ -1378,12 +1378,12 @@ KSTATUS VmwSvgaDispatchPnp(DEVICE_OBJECT* device, IRP* irp) {
|
||||
|
||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
case IRP_MN_SURPRISE_REMOVAL:
|
||||
v->SurpriseRemoved = true;
|
||||
device->PnpState = DevicePnpSurpriseRemoved;
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
case IRP_MN_REMOVE_DEVICE:
|
||||
v->Removed = true;
|
||||
@@ -1399,7 +1399,7 @@ KSTATUS VmwSvgaDispatchPnp(DEVICE_OBJECT* device, IRP* irp) {
|
||||
}
|
||||
IoDetachDevice(device);
|
||||
IoDeleteDevice(device);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
default:
|
||||
return IoForwardIrpToLower(device, irp);
|
||||
@@ -1409,7 +1409,7 @@ KSTATUS VmwSvgaDispatchPnp(DEVICE_OBJECT* device, IRP* irp) {
|
||||
// Implements the add Device operation.
|
||||
KSTATUS VmwSvgaAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObject) {
|
||||
if (!driver || !physicalDeviceObject || physicalDeviceObject->Type != DeviceObjectPhysical)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
DEVICE_OBJECT* fdo = NULL;
|
||||
KSTATUS st = IoCreateDevice(driver, sizeof(VMWSVGA_DEVICE), &fdo);
|
||||
@@ -1428,17 +1428,17 @@ KSTATUS VmwSvgaAddDevice(DRIVER_OBJECT* driver, DEVICE_OBJECT* physicalDeviceObj
|
||||
v->LowerDevice = IoAttachDeviceToDeviceStack(fdo, physicalDeviceObject);
|
||||
if (!v->LowerDevice) {
|
||||
IoDeleteDevice(fdo);
|
||||
return STATUS_FAILURE;
|
||||
return NTLSTATUS_FAILURE;
|
||||
}
|
||||
|
||||
DbgPrint("VMWSVGA: FDO attached to %v\n", physicalDeviceObject->Name);
|
||||
return STATUS_SUCCESS;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the driver Entry operation.
|
||||
KSTATUS DriverEntry(const HAL_API* hal) {
|
||||
if (!hal)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
DbgPrint("VMWSVGA: driver loading...\n");
|
||||
gVmwSvgaHal = hal;
|
||||
|
||||
Reference in new issue
Block a user