ReactOS 0.4.15-dev-7934-g1dc8d80
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 PAGED_CODE()
#define NO_ERROR
Definition: dderror.h:5
#define Trace(x)
Definition: inflate.c:42
#define __FUNCTION__
Definition: types.h:116
#define VIDEO_CHILD_ACTIVE
Definition: ntddvdeo.h:608
#define VideoDebugPrint(x)
Definition: video.h:75
uint32_t ULONG
Definition: typedefs.h:59

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{
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}
BOOL Error
Definition: chkdsk.c:66
Status
Definition: gdiplustypes.h:25
struct _VIDEO_MEMORY_INFORMATION VIDEO_MEMORY_INFORMATION
LONG VP_STATUS
Definition: video.h:153
VPAPI VP_STATUS NTAPI VideoPortMapMemory(IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, IN OUT PULONG Length, IN PULONG InIoSpace, IN OUT PVOID *VirtualAddress)
#define VIDEO_MEMORY_SPACE_MEMORY
Definition: video.h:132

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
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}
struct _VideoMode VideoMode
struct _VIDEO_MODE_INFORMATION VIDEO_MODE_INFORMATION
static VOID FASTCALL Pc98VidQueryMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ ULONG ModeNumber, _Out_ PVIDEO_MODE_INFORMATION VideoMode)
Definition: ioctl.c:18
unsigned char UCHAR
Definition: xmlstorage.h:181

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}

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;
45}
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:364
#define VIDEO_MODE_COLOR
Definition: ntddvdeo.h:363
#define VIDEO_MODE_PALETTE_DRIVEN
Definition: ntddvdeo.h:365
#define VIDEO_MODE_MANAGED_PALETTE
Definition: ntddvdeo.h:366
static CONST VGA_MODE VideoModes[BIOS_MAX_VIDEO_MODE+1]
Definition: vidbios.c:1941

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
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

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}

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
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_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define TRUE
Definition: types.h:120
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:173
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:248
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:182
#define IOCTL_VIDEO_GET_CHILD_STATE
Definition: ntddvdeo.h:164
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:221
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:218
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:206
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:176
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:191
uint32_t * PULONG
Definition: typedefs.h:59
VP_STATUS FASTCALL Pc98VidSetColorRegisters(_In_ PVIDEO_CLUT ColorLookUpTable)
Definition: hardware.c:261
VP_STATUS FASTCALL Pc98VidSetCurrentMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MODE RequestedMode)
Definition: hardware.c:83
static VP_STATUS FASTCALL Pc98VidUnmapVideoMemory(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MEMORY VideoMemory)
Definition: ioctl.c:162
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
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 Pc98VidQueryNumAvailModes(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_NUM_MODES Modes, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:79
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 Pc98VidResetDevice(VOID)
Definition: ioctl.c:179
static VP_STATUS FASTCALL Pc98VidQueryCurrentMode(_In_ PHW_DEVICE_EXTENSION DeviceExtension, _Out_ PVIDEO_MODE_INFORMATION VideoMode, _Out_ PSTATUS_BLOCK StatusBlock)
Definition: ioctl.c:100

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 NULL
Definition: types.h:112
VPAPI VP_STATUS NTAPI VideoPortUnmapMemory(IN PVOID HwDeviceExtension, IN OUT PVOID VirtualAddress, IN HANDLE ProcessHandle)

Referenced by Pc98VidStartIO().