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

Go to the source code of this file.

Functions

VOID FASTCALL Pc98VidQueryMode (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ ULONG ModeNumber, _Out_ PVIDEO_MODE_INFORMATION VideoMode)
 
VP_STATUS FASTCALL Pc98VidQueryAvailModes (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION ModeInformation, _Out_ PSTATUS_BLOCK StatusBlock)
 
VP_STATUS FASTCALL Pc98VidQueryNumAvailModes (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_NUM_MODES Modes, _Out_ PSTATUS_BLOCK StatusBlock)
 
VP_STATUS FASTCALL Pc98VidQueryCurrentMode (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION VideoMode, _Out_ PSTATUS_BLOCK StatusBlock)
 
VP_STATUS FASTCALL Pc98VidMapVideoMemory (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY RequestedAddress, _Out_ PVIDEO_MEMORY_INFORMATION MapInformation, _Out_ PSTATUS_BLOCK StatusBlock)
 
VP_STATUS FASTCALL Pc98VidUnmapVideoMemory (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY VideoMemory)
 
VP_STATUS FASTCALL Pc98VidResetDevice (VOID)
 
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()

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

Definition at line 190 of file ioctl.c.

195 {
196  PAGED_CODE();
197 
198  VideoDebugPrint((Trace, "%s() Child %d\n", __FUNCTION__, *ChildIndex));
199 
200  *ChildState = VIDEO_CHILD_ACTIVE;
201 
202  StatusBlock->Information = sizeof(ULONG);
203 
204  return NO_ERROR;
205 }
#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:538
unsigned int ULONG
Definition: retypes.h:1
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().

◆ Pc98VidMapVideoMemory()

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

Definition at line 125 of file ioctl.c.

130 {
132  ULONG inIoSpace = VIDEO_MEMORY_SPACE_MEMORY;
133 
134  PAGED_CODE();
135 
136  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
137 
138  MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress;
139  MapInformation->VideoRamLength = DeviceExtension->FrameBufferLength;
140 
141  Status = VideoPortMapMemory(DeviceExtension,
142  DeviceExtension->FrameBuffer,
143  &MapInformation->VideoRamLength,
144  &inIoSpace,
145  &MapInformation->VideoRamBase);
146  if (Status != NO_ERROR)
147  {
148  VideoDebugPrint((Error, "%s() Failed to map framebuffer memory\n",
149  __FUNCTION__));
150  }
151  else
152  {
153  MapInformation->FrameBufferBase = MapInformation->VideoRamBase;
154  MapInformation->FrameBufferLength = MapInformation->VideoRamLength;
155 
156  StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
157  }
158 
159  return Status;
160 }
#define NO_ERROR
Definition: dderror.h:5
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
Status
Definition: gdiplustypes.h:24
#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()

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

Definition at line 61 of file ioctl.c.

65 {
66  UCHAR ModeNumber;
68 
69  PAGED_CODE();
70 
71  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
72 
73  for (ModeNumber = 0, VideoMode = ModeInformation;
74  ModeNumber < DeviceExtension->ModeCount;
75  ++ModeNumber, ++VideoMode)
76  {
77  Pc98VidQueryMode(DeviceExtension, ModeNumber, VideoMode);
78  }
79 
80  StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION) * DeviceExtension->ModeCount;
81 
82  return NO_ERROR;
83 }
#define NO_ERROR
Definition: dderror.h:5
struct _VideoMode VideoMode
VOID FASTCALL Pc98VidQueryMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ ULONG ModeNumber, _Out_ PVIDEO_MODE_INFORMATION VideoMode)
Definition: ioctl.c:30
unsigned char UCHAR
Definition: xmlstorage.h:181
#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().

◆ Pc98VidQueryCurrentMode()

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

Definition at line 106 of file ioctl.c.

110 {
111  PAGED_CODE();
112 
113  VideoDebugPrint((Trace, "%s() Mode %d\n",
114  __FUNCTION__, DeviceExtension->CurrentMode));
115 
116  Pc98VidQueryMode(DeviceExtension, DeviceExtension->CurrentMode, VideoMode);
117 
118  StatusBlock->Information = sizeof(VIDEO_MODE_INFORMATION);
119 
120  return NO_ERROR;
121 }
#define NO_ERROR
Definition: dderror.h:5
VOID FASTCALL Pc98VidQueryMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ ULONG ModeNumber, _Out_ PVIDEO_MODE_INFORMATION VideoMode)
Definition: ioctl.c:30
#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().

◆ Pc98VidQueryMode()

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

Definition at line 30 of file ioctl.c.

34 {
35  PAGED_CODE();
36 
37  VideoDebugPrint((Trace, "%s() Mode %d\n", __FUNCTION__, ModeNumber));
38 
39  VideoMode->Length = sizeof(VIDEO_MODE_INFORMATION);
40  VideoMode->ModeIndex = ModeNumber;
41  VideoMode->VisScreenWidth = VideoModes[ModeNumber].HResolution;
42  VideoMode->VisScreenHeight = VideoModes[ModeNumber].VResolution;
43  VideoMode->ScreenStride = VideoModes[ModeNumber].HResolution;
44  VideoMode->NumberOfPlanes = 1;
45  VideoMode->BitsPerPlane = 8;
46  VideoMode->Frequency = VideoModes[ModeNumber].RefreshRate;
47  VideoMode->XMillimeter = 320;
48  VideoMode->YMillimeter = 240;
49  VideoMode->NumberRedBits =
50  VideoMode->NumberGreenBits =
51  VideoMode->NumberBlueBits = 8;
52  VideoMode->RedMask =
53  VideoMode->GreenMask =
54  VideoMode->BlueMask = 0;
55  VideoMode->AttributeFlags = VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS |
57 }
#define VIDEO_MODE_MANAGED_PALETTE
Definition: ntddvdeo.h:296
static CONST VGA_MODE VideoModes[BIOS_MAX_VIDEO_MODE+1]
Definition: vidbios.c:1941
#define VIDEO_MODE_PALETTE_DRIVEN
Definition: ntddvdeo.h:295
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
#define VIDEO_MODE_COLOR
Definition: ntddvdeo.h:293
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
#define __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:294

Referenced by Pc98VidQueryAvailModes(), and Pc98VidQueryCurrentMode().

◆ Pc98VidQueryNumAvailModes()

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

Definition at line 87 of file ioctl.c.

91 {
92  PAGED_CODE();
93 
94  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
95 
96  Modes->NumModes = DeviceExtension->ModeCount;
97  Modes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
98 
99  StatusBlock->Information = sizeof(VIDEO_NUM_MODES);
100 
101  return NO_ERROR;
102 }
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()

VP_STATUS FASTCALL Pc98VidResetDevice ( VOID  )

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 209 of file ioctl.c.

212 {
214 
215  PAGED_CODE();
216 
217  VideoDebugPrint((Trace, "%s() IOCTL 0x%lX\n",
218  __FUNCTION__, RequestPacket->IoControlCode));
219 
220  switch (RequestPacket->IoControlCode)
221  {
223  {
224  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_NUM_MODES))
225  {
227  break;
228  }
229 
231  (PVIDEO_NUM_MODES)RequestPacket->OutputBuffer,
232  RequestPacket->StatusBlock);
233  break;
234  }
235 
237  {
238  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION) *
239  ((PHW_DEVICE_EXTENSION)HwDeviceExtension)->ModeCount)
240  {
242  break;
243  }
244 
246  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
247  RequestPacket->StatusBlock);
248  break;
249  }
250 
252  {
253  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MODE))
254  {
256  break;
257  }
258 
260  (PVIDEO_MODE)RequestPacket->InputBuffer);
261  break;
262  }
263 
265  {
266  if (RequestPacket->OutputBufferLength < sizeof(VIDEO_MODE_INFORMATION))
267  {
269  break;
270  }
271 
273  (PVIDEO_MODE_INFORMATION)RequestPacket->OutputBuffer,
274  RequestPacket->StatusBlock);
275  break;
276  }
277 
279  {
280  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY) ||
281  RequestPacket->OutputBufferLength < sizeof(VIDEO_MEMORY_INFORMATION))
282  {
284  break;
285  }
286 
288  (PVIDEO_MEMORY)RequestPacket->InputBuffer,
289  (PVIDEO_MEMORY_INFORMATION)RequestPacket->OutputBuffer,
290  RequestPacket->StatusBlock);
291  break;
292  }
293 
295  {
296  if (RequestPacket->InputBufferLength < sizeof(VIDEO_MEMORY))
297  {
299  break;
300  }
301 
303  (PVIDEO_MEMORY)RequestPacket->InputBuffer);
304  break;
305  }
306 
308  {
310  break;
311  }
312 
314  {
315  if (RequestPacket->InputBufferLength < sizeof(VIDEO_CLUT))
316  {
318  break;
319  }
320 
321  Status = Pc98VidSetColorRegisters((PVIDEO_CLUT)RequestPacket->InputBuffer);
322  break;
323  }
324 
326  {
327  if (RequestPacket->InputBufferLength < sizeof(ULONG) ||
328  RequestPacket->OutputBufferLength < sizeof(ULONG))
329  {
331  break;
332  }
333 
334  Status = Pc98VidGetChildState((PHW_DEVICE_EXTENSION)HwDeviceExtension,
335  (PULONG)RequestPacket->InputBuffer,
336  (PULONG)RequestPacket->OutputBuffer,
337  RequestPacket->StatusBlock);
338  break;
339  }
340 
341  default:
343  }
344 
345  if (Status != NO_ERROR)
346  VideoDebugPrint((Trace, "%s() Failed 0x%lX\n", __FUNCTION__, Status));
347 
348  RequestPacket->StatusBlock->Status = Status;
349 
350  return TRUE;
351 }
VP_STATUS FASTCALL Pc98VidQueryNumAvailModes(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_NUM_MODES Modes, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:87
VP_STATUS FASTCALL Pc98VidQueryCurrentMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION VideoMode, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:106
VP_STATUS FASTCALL Pc98VidQueryAvailModes(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION ModeInformation, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:61
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
VP_STATUS FASTCALL Pc98VidUnmapVideoMemory(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY VideoMemory)
Definition: ioctl.c:164
#define TRUE
Definition: types.h:120
VP_STATUS FASTCALL Pc98VidGetChildState(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PULONG ChildIndex, _Out_ PULONG ChildState, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:190
#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 Pc98VidMapVideoMemory(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY RequestedAddress, _Out_ PVIDEO_MEMORY_INFORMATION MapInformation, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:125
VP_STATUS FASTCALL Pc98VidSetColorRegisters(_In_ PVIDEO_CLUT ColorLookUpTable)
Definition: hardware.c:266
#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:89
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
Status
Definition: gdiplustypes.h:24
#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
VP_STATUS FASTCALL Pc98VidResetDevice(VOID)
Definition: ioctl.c:179
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
#define __FUNCTION__
Definition: types.h:112
#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()

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

Definition at line 164 of file ioctl.c.

167 {
168  PAGED_CODE();
169 
170  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
171 
172  return VideoPortUnmapMemory(DeviceExtension,
173  VideoMemory->RequestedVirtualAddress,
174  NULL);
175 }
smooth NULL
Definition: ftsmooth.c:416
#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 __FUNCTION__
Definition: types.h:112
#define PAGED_CODE()

Referenced by Pc98VidStartIO().