ReactOS  0.4.15-dev-3187-ge372f2b
ioctl.c File Reference
#include "pc98vid.h"
Include dependency graph for ioctl.c:

Go to the source code of this file.

Functions

static VOID FASTCALL Pc98VidQueryMode (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ ULONG ModeNumber, _Out_ PVIDEO_MODE_INFORMATION VideoMode)
 
static VP_STATUS FASTCALL Pc98VidQueryAvailModes (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION ModeInformation, _Out_ PSTATUS_BLOCK StatusBlock)
 
static VP_STATUS FASTCALL Pc98VidQueryNumAvailModes (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_NUM_MODES Modes, _Out_ PSTATUS_BLOCK StatusBlock)
 
static VP_STATUS FASTCALL Pc98VidQueryCurrentMode (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION VideoMode, _Out_ PSTATUS_BLOCK StatusBlock)
 
static VP_STATUS FASTCALL Pc98VidMapVideoMemory (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY RequestedAddress, _Out_ PVIDEO_MEMORY_INFORMATION MapInformation, _Out_ PSTATUS_BLOCK StatusBlock)
 
static VP_STATUS FASTCALL Pc98VidUnmapVideoMemory (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY VideoMemory)
 
static VP_STATUS FASTCALL Pc98VidResetDevice (VOID)
 
static VP_STATUS FASTCALL Pc98VidGetChildState (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PULONG ChildIndex, _Out_ PULONG ChildState, _Out_ PSTATUS_BLOCK StatusBlock)
 
BOOLEAN NTAPI Pc98VidStartIO (_In_ PVOID HwDeviceExtension, _Inout_ PVIDEO_REQUEST_PACKET RequestPacket)
 

Function Documentation

◆ Pc98VidGetChildState()

static VP_STATUS FASTCALL Pc98VidGetChildState ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension,
_In_ PULONG  ChildIndex,
_Out_ PULONG  ChildState,
_Out_ PSTATUS_BLOCK  StatusBlock 
)
static

Definition at line 192 of file ioctl.c.

197 {
198  PAGED_CODE();
199 
200  VideoDebugPrint((Trace, "%s() Child %d\n", __FUNCTION__, *ChildIndex));
201 
202  *ChildState = VIDEO_CHILD_ACTIVE;
203 
204  StatusBlock->Information = sizeof(ULONG);
205 
206  return NO_ERROR;
207 }
#define NO_ERROR
Definition: dderror.h:5
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
#define VIDEO_CHILD_ACTIVE
Definition: ntddvdeo.h:539
unsigned int ULONG
Definition: retypes.h:1
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().

◆ Pc98VidMapVideoMemory()

static VP_STATUS FASTCALL Pc98VidMapVideoMemory ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension,
_In_ PVIDEO_MEMORY  RequestedAddress,
_Out_ PVIDEO_MEMORY_INFORMATION  MapInformation,
_Out_ PSTATUS_BLOCK  StatusBlock 
)
static

Definition at line 121 of file ioctl.c.

126 {
128  ULONG inIoSpace = VIDEO_MEMORY_SPACE_MEMORY;
129 
130  PAGED_CODE();
131 
132  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
133 
134  MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
135  MapInformation->VideoRamLength = DeviceExtension->FrameBufferLength;
136 
137  Status = VideoPortMapMemory(DeviceExtension,
138  DeviceExtension->FrameBuffer,
139  &MapInformation->VideoRamLength,
140  &inIoSpace,
141  &MapInformation->VideoRamBase);
142  if (Status != NO_ERROR)
143  {
144  VideoDebugPrint((Error, "%s() Failed to map framebuffer memory\n",
145  __FUNCTION__));
146  }
147  else
148  {
149  MapInformation->FrameBufferBase = MapInformation->VideoRamBase;
150  MapInformation->FrameBufferLength = MapInformation->VideoRamLength;
151 
152  StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
153  }
154 
155  return Status;
156 }
#define NO_ERROR
Definition: dderror.h:5
Status
Definition: gdiplustypes.h:24
VPAPI VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN OUT PULONG Length, IN PULONG InIoSpace, IN OUT PVOID *VirtualAddress)
struct _VIDEO_MEMORY_INFORMATION VIDEO_MEMORY_INFORMATION
BOOL Error
Definition: chkdsk.c:66
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
unsigned int ULONG
Definition: retypes.h:1
LONG VP_STATUS
Definition: video.h:153
#define VIDEO_MEMORY_SPACE_MEMORY
Definition: video.h:132
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().

◆ Pc98VidQueryAvailModes()

static VP_STATUS FASTCALL Pc98VidQueryAvailModes ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension,
_Out_ PVIDEO_MODE_INFORMATION  ModeInformation,
_Out_ PSTATUS_BLOCK  StatusBlock 
)
static

Definition at line 51 of file ioctl.c.

55 {
56  UCHAR ModeNumber;
58 
59  PAGED_CODE();
60 
61  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
62 
63  for (ModeNumber = 0, VideoMode = ModeInformation;
64  ModeNumber < DeviceExtension->ModeCount;
65  ++ModeNumber, ++VideoMode)
66  {
67  Pc98VidQueryMode(DeviceExtension, ModeNumber, VideoMode);
68  }
69 
70  StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION) * DeviceExtension->ModeCount;
71 
72  return NO_ERROR;
73 }
#define NO_ERROR
Definition: dderror.h:5
struct _VideoMode VideoMode
unsigned char UCHAR
Definition: xmlstorage.h:181
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
static VOID FASTCALL Pc98VidQueryMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ ULONG ModeNumber, _Out_ PVIDEO_MODE_INFORMATION VideoMode)
Definition: ioctl.c:18
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().

◆ Pc98VidQueryCurrentMode()

static VP_STATUS FASTCALL Pc98VidQueryCurrentMode ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension,
_Out_ PVIDEO_MODE_INFORMATION  VideoMode,
_Out_ PSTATUS_BLOCK  StatusBlock 
)
static

Definition at line 100 of file ioctl.c.

104 {
105  PAGED_CODE();
106 
107  VideoDebugPrint((Trace, "%s() Mode %d\n",
108  __FUNCTION__, DeviceExtension->CurrentMode));
109 
110  Pc98VidQueryMode(DeviceExtension, DeviceExtension->CurrentMode, VideoMode);
111 
112  StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION);
113 
114  return NO_ERROR;
115 }
#define NO_ERROR
Definition: dderror.h:5
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
static VOID FASTCALL Pc98VidQueryMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ ULONG ModeNumber, _Out_ PVIDEO_MODE_INFORMATION VideoMode)
Definition: ioctl.c:18
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().

◆ Pc98VidQueryMode()

static VOID FASTCALL Pc98VidQueryMode ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension,
_In_ ULONG  ModeNumber,
_Out_ PVIDEO_MODE_INFORMATION  VideoMode 
)
static

Definition at line 18 of file ioctl.c.

22 {
23  PAGED_CODE();
24 
25  VideoDebugPrint((Trace, "%s() Mode %d\n", __FUNCTION__, ModeNumber));
26 
27  VideoMode->Length = sizeof(VIDEO_MODE_INFORMATION);
28  VideoMode->ModeIndex = ModeNumber;
29  VideoMode->VisScreenWidth = VideoModes[ModeNumber].HResolution;
30  VideoMode->VisScreenHeight = VideoModes[ModeNumber].VResolution;
31  VideoMode->ScreenStride = VideoModes[ModeNumber].HResolution;
32  VideoMode->NumberOfPlanes = 1;
33  VideoMode->BitsPerPlane = 8;
34  VideoMode->Frequency = VideoModes[ModeNumber].RefreshRate;
35  VideoMode->XMillimeter = 320;
36  VideoMode->YMillimeter = 240;
37  VideoMode->NumberRedBits =
38  VideoMode->NumberGreenBits =
39  VideoMode->NumberBlueBits = 8;
40  VideoMode->RedMask =
41  VideoMode->GreenMask =
42  VideoMode->BlueMask = 0;
43  VideoMode->AttributeFlags = VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS |
45 }
#define VIDEO_MODE_MANAGED_PALETTE
Definition: ntddvdeo.h:297
static CONST VGA_MODE VideoModes[BIOS_MAX_VIDEO_MODE+1]
Definition: vidbios.c:1941
#define VIDEO_MODE_PALETTE_DRIVEN
Definition: ntddvdeo.h:296
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
#define VIDEO_MODE_COLOR
Definition: ntddvdeo.h:294
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:295

Referenced by Pc98VidQueryAvailModes(), and Pc98VidQueryCurrentMode().

◆ Pc98VidQueryNumAvailModes()

static VP_STATUS FASTCALL Pc98VidQueryNumAvailModes ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension,
_Out_ PVIDEO_NUM_MODES  Modes,
_Out_ PSTATUS_BLOCK  StatusBlock 
)
static

Definition at line 79 of file ioctl.c.

83 {
84  PAGED_CODE();
85 
86  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
87 
88  Modes->NumModes = DeviceExtension->ModeCount;
89  Modes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
90 
91  StatusBlock->Information = sizeof(VIDEO_NUM_MODES);
92 
93  return NO_ERROR;
94 }
struct _VIDEO_NUM_MODES VIDEO_NUM_MODES
static const VBE_MODE Modes[VBE_MODE_COUNT]
Definition: vbe.c:189
#define NO_ERROR
Definition: dderror.h:5
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().

◆ Pc98VidResetDevice()

static VP_STATUS FASTCALL Pc98VidResetDevice ( VOID  )
static

Definition at line 179 of file ioctl.c.

180 {
181  PAGED_CODE();
182 
183  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
184 
185  return NO_ERROR;
186 }
#define NO_ERROR
Definition: dderror.h:5
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().

◆ Pc98VidStartIO()

BOOLEAN NTAPI Pc98VidStartIO ( _In_ PVOID  HwDeviceExtension,
_Inout_ PVIDEO_REQUEST_PACKET  RequestPacket 
)

Definition at line 212 of file ioctl.c.

215 {
217 
218  PAGED_CODE();
219 
220  VideoDebugPrint((Trace, "%s() IOCTL 0x%lX\n",
221  __FUNCTION__, RequestPacket->IoControlCode));
222 
223  switch (RequestPacket->IoControlCode)
224  {
226  {
227  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_NUM_MODES))
228  {
230  break;
231  }
232 
234  (PVIDEO_NUM_MODES)RequestPacket->OutputBuffer,
235  RequestPacket->StatusBlock);
236  break;
237  }
238 
240  {
241  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION) *
242  ((PHW_DEVICE_EXTENSION)HwDeviceExtension)->ModeCount)
243  {
245  break;
246  }
247 
249  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
250  RequestPacket->StatusBlock);
251  break;
252  }
253 
255  {
256  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MODE))
257  {
259  break;
260  }
261 
263  (PVIDEO_MODE)RequestPacket->InputBuffer);
264  break;
265  }
266 
268  {
269  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
270  {
272  break;
273  }
274 
276  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
277  RequestPacket->StatusBlock);
278  break;
279  }
280 
282  {
283  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY) ||
284  RequestPacket->OutputBufferLength < sizeof(VIDEO_MEMORY_INFORMATION))
285  {
287  break;
288  }
289 
291  (PVIDEO_MEMORY)RequestPacket->InputBuffer,
292  (PVIDEO_MEMORY_INFORMATION)RequestPacket->OutputBuffer,
293  RequestPacket->StatusBlock);
294  break;
295  }
296 
298  {
299  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
300  {
302  break;
303  }
304 
306  (PVIDEO_MEMORY)RequestPacket->InputBuffer);
307  break;
308  }
309 
311  {
313  break;
314  }
315 
317  {
318  if (RequestPacket->InputBufferLength < sizeof(VIDEO_CLUT))
319  {
321  break;
322  }
323 
324  Status = Pc98VidSetColorRegisters((PVIDEO_CLUT)RequestPacket->InputBuffer);
325  break;
326  }
327 
329  {
330  if (RequestPacket->InputBufferLength < sizeof(ULONG) ||
331  RequestPacket->OutputBufferLength < sizeof(ULONG))
332  {
334  break;
335  }
336 
337  Status = Pc98VidGetChildState((PHW_DEVICE_EXTENSION)HwDeviceExtension,
338  (PULONG)RequestPacket->InputBuffer,
339  (PULONG)RequestPacket->OutputBuffer,
340  RequestPacket->StatusBlock);
341  break;
342  }
343 
344  default:
346  }
347 
348  if (Status != NO_ERROR)
349  VideoDebugPrint((Trace, "%s() Failed 0x%lX\n", __FUNCTION__, Status));
350 
351  RequestPacket->StatusBlock->Status = Status;
352 
353  return TRUE;
354 }
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define TRUE
Definition: types.h:120
static VP_STATUS FASTCALL Pc98VidMapVideoMemory(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY RequestedAddress, _Out_ PVIDEO_MEMORY_INFORMATION MapInformation, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:121
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:137
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
#define NO_ERROR
Definition: dderror.h:5
VP_STATUS FASTCALL Pc98VidSetColorRegisters(_In_ PVIDEO_CLUT ColorLookUpTable)
Definition: hardware.c:261
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:113
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
VP_STATUS FASTCALL Pc98VidSetCurrentMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MODE RequestedMode)
Definition: hardware.c:83
static VP_STATUS FASTCALL Pc98VidQueryCurrentMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION VideoMode, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:100
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
Status
Definition: gdiplustypes.h:24
static VP_STATUS FASTCALL Pc98VidQueryAvailModes(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION ModeInformation, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:51
static VP_STATUS FASTCALL Pc98VidUnmapVideoMemory(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY VideoMemory)
Definition: ioctl.c:162
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:122
#define Trace(x)
Definition: inflate.c:42
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:107
#define VideoDebugPrint(x)
Definition: video.h:75
unsigned int * PULONG
Definition: retypes.h:1
#define IOCTL_VIDEO_GET_CHILD_STATE
Definition: ntddvdeo.h:95
unsigned int ULONG
Definition: retypes.h:1
LONG VP_STATUS
Definition: video.h:153
static VP_STATUS FASTCALL Pc98VidQueryNumAvailModes(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_NUM_MODES Modes, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:79
#define __FUNCTION__
Definition: types.h:112
static VP_STATUS FASTCALL Pc98VidGetChildState(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PULONG ChildIndex, _Out_ PULONG ChildState, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:192
static VP_STATUS FASTCALL Pc98VidResetDevice(VOID)
Definition: ioctl.c:179
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149
#define PAGED_CODE()
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by DriverEntry().

◆ Pc98VidUnmapVideoMemory()

static VP_STATUS FASTCALL Pc98VidUnmapVideoMemory ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension,
_In_ PVIDEO_MEMORY  VideoMemory 
)
static

Definition at line 162 of file ioctl.c.

165 {
166  PAGED_CODE();
167 
168  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
169 
170  return VideoPortUnmapMemory(DeviceExtension,
171  VideoMemory->RequestedVirtualAddress,
172  NULL);
173 }
#define Trace(x)
Definition: inflate.c:42
VPAPI VP_STATUS NTAPI VideoPortUnmapMemory(IN PVOID HwDeviceExtension, IN OUT PVOID VirtualAddress, IN HANDLE ProcessHandle)
#define VideoDebugPrint(x)
Definition: video.h:75
#define NULL
Definition: types.h:112
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().