vgamp.c
来自「一个类似windows」· C语言 代码 · 共 565 行 · 第 1/2 页
C
565 行
case IOCTL_VIDEO_DISABLE_CURSOR:
case IOCTL_VIDEO_DISABLE_POINTER:
case IOCTL_VIDEO_ENABLE_CURSOR:
case IOCTL_VIDEO_ENABLE_POINTER:
case IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES:
VGAFreePublicAccessRanges((PVIDEO_PUBLIC_ACCESS_RANGES)
RequestPacket->InputBuffer,
RequestPacket->StatusBlock);
break;
case IOCTL_VIDEO_GET_BANK_SELECT_CODE:
case IOCTL_VIDEO_GET_POWER_MANAGEMENT:
case IOCTL_VIDEO_LOAD_AND_SET_FONT:
case IOCTL_VIDEO_QUERY_CURSOR_POSITION:
case IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES:
case IOCTL_VIDEO_QUERY_CURSOR_ATTR:
case IOCTL_VIDEO_QUERY_POINTER_ATTR:
case IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES:
case IOCTL_VIDEO_QUERY_POINTER_POSITION:
case IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES:
VGAQueryPublicAccessRanges((PVIDEO_PUBLIC_ACCESS_RANGES)
RequestPacket->OutputBuffer,
RequestPacket->StatusBlock);
break;
case IOCTL_VIDEO_RESTORE_HARDWARE_STATE:
case IOCTL_VIDEO_SAVE_HARDWARE_STATE:
case IOCTL_VIDEO_SET_CURSOR_ATTR:
case IOCTL_VIDEO_SET_CURSOR_POSITION:
case IOCTL_VIDEO_SET_POINTER_ATTR:
case IOCTL_VIDEO_SET_POINTER_POSITION:
case IOCTL_VIDEO_SET_POWER_MANAGEMENT:
#endif
default:
RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
return FALSE;
}
if (Result)
RequestPacket->StatusBlock->Status = NO_ERROR;
return TRUE;
}
#if 0
// VGAInterrupt
//
// DESCRIPTION:
// This function will be called upon receipt of a adapter generated
// interrupt when enabled.
//
// RUN LEVEL:
// IRQL
//
// ARGUMENTS:
// PVOID DeviceExtension
// RETURNS:
// BOOLEAN TRUE if the interrupt was handled by the routine
static BOOLEAN STDCALL
VGAInterrupt(PVOID DeviceExtension)
{
return(TRUE);
}
#endif
// VGAResetHw
//
// DESCRIPTION:
// This function is called to reset the hardware to a known state
// if calling a BIOS int 10 reset will not achieve this result.
//
// RUN LEVEL:
// PASSIVE_LEVEL
//
// ARGUMENTS:
// PVOID DeviceExtension
// ULONG Columns Columns and Rows specify the mode parameters
// ULONG Rows to reset to.
// RETURNS:
// BOOLEAN TRUE if no further action is necessary, FALSE if the system
// needs to still do a BIOS int 10 reset.
BOOLEAN STDCALL
VGAResetHw(PVOID DeviceExtension,
ULONG Columns,
ULONG Rows)
{
/* We don't anything to the vga that int10 can't cope with. */
return(FALSE);
}
#if 0
// VGATimer
//
// DESCRIPTION:
// This function will be called once a second when enabled
//
// RUN LEVEL:
// PASSIVE_LEVEL
//
// ARGUMENTS:
// PVOID DeviceExtension
// RETURNS:
// VOID
static VOID STDCALL
VGATimer(PVOID DeviceExtension)
{
}
#endif
BOOLEAN VGAMapVideoMemory(IN PVOID DeviceExtension,
IN PVIDEO_MEMORY RequestedAddress,
OUT PVIDEO_MEMORY_INFORMATION MapInformation,
OUT PSTATUS_BLOCK StatusBlock)
{
ULONG ReturnedLength;
PVOID ReturnedAddress;
ULONG IoSpace;
PHYSICAL_ADDRESS FrameBufferBase;
ReturnedAddress = RequestedAddress->RequestedVirtualAddress;
ReturnedLength = 256 * 1024;
FrameBufferBase.QuadPart = 0xA0000;
IoSpace = VIDEO_MEMORY_SPACE_MEMORY;
StatusBlock->Status = VideoPortMapMemory(DeviceExtension,
FrameBufferBase,
&ReturnedLength,
&IoSpace,
&ReturnedAddress);
if (StatusBlock->Status != 0)
{
StatusBlock->Information = 0;
return TRUE;
}
MapInformation->VideoRamBase = MapInformation->FrameBufferBase =
ReturnedAddress;
MapInformation->VideoRamLength = MapInformation->FrameBufferLength =
ReturnedLength;
StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
return TRUE;
}
BOOLEAN VGAQueryAvailModes(OUT PVIDEO_MODE_INFORMATION ReturnedModes,
OUT PSTATUS_BLOCK StatusBlock)
{
/* Only one mode exists in VGA (640x480), so use VGAQueryCurrentMode */
return VGAQueryCurrentMode(ReturnedModes, StatusBlock);
}
BOOLEAN VGAQueryCurrentMode(OUT PVIDEO_MODE_INFORMATION CurrentMode,
OUT PSTATUS_BLOCK StatusBlock)
{
CurrentMode->Length = sizeof(VIDEO_MODE_INFORMATION);
CurrentMode->ModeIndex = 12;
CurrentMode->VisScreenWidth = 640;
CurrentMode->VisScreenHeight = 480;
CurrentMode->ScreenStride = 320;
CurrentMode->NumberOfPlanes = 1;
CurrentMode->BitsPerPlane = 4;
CurrentMode->Frequency = 60;
CurrentMode->XMillimeter = 0; /* FIXME */
CurrentMode->YMillimeter = 0; /* FIXME */
CurrentMode->NumberRedBits =
CurrentMode->NumberGreenBits =
CurrentMode->NumberBlueBits = 6;
CurrentMode->RedMask =
CurrentMode->GreenMask =
CurrentMode->BlueMask = 0; /* FIXME */
CurrentMode->VideoMemoryBitmapWidth = 640;
CurrentMode->VideoMemoryBitmapHeight = 480;
CurrentMode->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR |
VIDEO_MODE_NO_OFF_SCREEN;
CurrentMode->DriverSpecificAttributeFlags = 0;
StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION);
return TRUE;
}
BOOLEAN VGAQueryNumAvailModes(OUT PVIDEO_NUM_MODES NumberOfModes,
OUT PSTATUS_BLOCK StatusBlock)
{
NumberOfModes->NumModes = 1;
NumberOfModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
StatusBlock->Information = sizeof(VIDEO_NUM_MODES);
return TRUE;
}
BOOLEAN VGASetPaletteRegisters(IN PUSHORT PaletteRegisters,
OUT PSTATUS_BLOCK StatusBlock)
{
;
/*
We don't need the following code because the palette registers are set correctly on VGA initialization.
Still, we may include\test this is in the future.
int i, j = 2;
char tmp, v;
tmp = VideoPortReadPortUchar(0x03da);
v = VideoPortReadPortUchar(0x03c0);
// Set the first 16 palette registers to map to the first 16 palette colors
for (i=PaletteRegisters[1]; i<PaletteRegisters[0]; i++)
{
tmp = VideoPortReadPortUchar(0x03da);
VideoPortWritePortUchar(0x03c0, i);
VideoPortWritePortUchar(0x03c0, PaletteRegisters[j++]);
}
tmp = VideoPortReadPortUchar(0x03da);
VideoPortWritePortUchar(0x03d0, v | 0x20);
*/
return TRUE;
}
BOOLEAN VGASetColorRegisters(IN PVIDEO_CLUT ColorLookUpTable,
OUT PSTATUS_BLOCK StatusBlock)
{
int i;
for (i=ColorLookUpTable->FirstEntry; i<ColorLookUpTable->NumEntries; i++)
{
VideoPortWritePortUchar((PUCHAR)0x03c8, i);
VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Red);
VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Green);
VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Blue);
}
return TRUE;
}
BOOLEAN VGASetCurrentMode(IN PVIDEO_MODE RequestedMode,
OUT PSTATUS_BLOCK StatusBlock)
{
if(RequestedMode->RequestedMode == 12)
{
InitVGAMode();
return TRUE;
} else {
VideoPortDebugPrint(Warn, "Unrecognised mode for VGASetCurrentMode\n");
return FALSE;
}
}
BOOLEAN VGAShareVideoMemory(IN PVIDEO_SHARE_MEMORY RequestedMemory,
OUT PVIDEO_MEMORY_INFORMATION ReturnedMemory,
OUT PSTATUS_BLOCK StatusBlock)
{
UNIMPLEMENTED;
StatusBlock->Status = ERROR_INVALID_FUNCTION;
return FALSE;
}
BOOLEAN VGAUnmapVideoMemory(IN PVOID DeviceExtension,
IN PVIDEO_MEMORY MemoryToUnmap,
OUT PSTATUS_BLOCK StatusBlock)
{
if (VideoPortUnmapMemory(DeviceExtension,
MemoryToUnmap->RequestedVirtualAddress,
0) == NO_ERROR)
return TRUE;
else
return FALSE;
}
BOOLEAN VGAUnshareVideoMemory(IN PVIDEO_MEMORY MemoryToUnshare,
OUT PSTATUS_BLOCK StatusBlock)
{
UNIMPLEMENTED;
StatusBlock->Status = ERROR_INVALID_FUNCTION;
return FALSE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?