ReactOS 0.4.15-dev-7127-g2dd0c6c
hardware.c File Reference
#include "pc98vid.h"
Include dependency graph for hardware.c:

Go to the source code of this file.

Macros

#define PEGC_MAX_COLORS   256
 

Functions

static BOOLEAN GraphGetStatus (_In_ UCHAR Status)
 
static BOOLEAN TestMmio (_In_ PHW_DEVICE_EXTENSION DeviceExtension)
 
static VOID TextSync (VOID)
 
BOOLEAN NTAPI HasPegcController (_In_ PHW_DEVICE_EXTENSION DeviceExtension)
 
VP_STATUS FASTCALL Pc98VidSetCurrentMode (_In_ PHW_DEVICE_EXTENSION DeviceExtension, _In_ PVIDEO_MODE RequestedMode)
 
VP_STATUS FASTCALL Pc98VidSetColorRegisters (_In_ PVIDEO_CLUT ColorLookUpTable)
 
VP_STATUS NTAPI Pc98VidGetPowerState (_In_ PVOID HwDeviceExtension, _In_ ULONG HwId, _In_ PVIDEO_POWER_MANAGEMENT VideoPowerControl)
 
VP_STATUS NTAPI Pc98VidSetPowerState (_In_ PVOID HwDeviceExtension, _In_ ULONG HwId, _In_ PVIDEO_POWER_MANAGEMENT VideoPowerControl)
 

Macro Definition Documentation

◆ PEGC_MAX_COLORS

#define PEGC_MAX_COLORS   256

Definition at line 14 of file hardware.c.

Function Documentation

◆ GraphGetStatus()

static BOOLEAN GraphGetStatus ( _In_ UCHAR  Status)
static

Definition at line 19 of file hardware.c.

21{
23
26
27 return (Result & GRAPH_STATUS_SET) && (Result != 0xFF);
28}
Status
Definition: gdiplustypes.h:25
VPAPI UCHAR NTAPI VideoPortReadPortUchar(IN PUCHAR Port)
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)
#define GRAPH_IO_i_STATUS
Definition: video.h:346
#define GRAPH_IO_o_STATUS_SELECT
Definition: video.h:350
#define GRAPH_STATUS_SET
Definition: video.h:347
unsigned char * PUCHAR
Definition: typedefs.h:53
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by HasPegcController().

◆ HasPegcController()

BOOLEAN NTAPI HasPegcController ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension)

Definition at line 63 of file hardware.c.

65{
67
69 return TestMmio(DeviceExtension);
70
76
77 return Success;
78}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
@ Success
Definition: eventcreate.c:712
#define GDC2_IO_o_MODE_FLIPFLOP2
Definition: video.h:280
#define GDC2_EGC_FF_PROTECT
Definition: video.h:285
#define GRAPH_STATUS_PEGC
Definition: video.h:352
#define GDC2_EGC_FF_UNPROTECT
Definition: video.h:286
#define GDC2_MODE_PEGC_ENABLE
Definition: video.h:288
#define GDC2_MODE_PEGC_DISABLE
Definition: video.h:287
static BOOLEAN TestMmio(_In_ PHW_DEVICE_EXTENSION DeviceExtension)
Definition: hardware.c:31
static BOOLEAN GraphGetStatus(_In_ UCHAR Status)
Definition: hardware.c:19

◆ Pc98VidGetPowerState()

VP_STATUS NTAPI Pc98VidGetPowerState ( _In_ PVOID  HwDeviceExtension,
_In_ ULONG  HwId,
_In_ PVIDEO_POWER_MANAGEMENT  VideoPowerControl 
)

Definition at line 292 of file hardware.c.

296{
297 PAGED_CODE();
298
299 VideoDebugPrint((Trace, "%s() Id %lX, State %x\n",
300 __FUNCTION__, HwId, VideoPowerControl->PowerState));
301
302 if (HwId == MONITOR_HW_ID || HwId == DISPLAY_ADAPTER_HW_ID)
303 {
304 switch (VideoPowerControl->PowerState)
305 {
306 case VideoPowerOn:
309 case VideoPowerOff:
311 return NO_ERROR;
312 }
313 }
314
316}
#define PAGED_CODE()
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_DEVICE_REINITIALIZATION_NEEDED
Definition: dderror.h:16
#define Trace(x)
Definition: inflate.c:42
#define __FUNCTION__
Definition: types.h:116
@ VideoPowerOn
Definition: ntddvdeo.h:334
@ VideoPowerSuspend
Definition: ntddvdeo.h:336
@ VideoPowerOff
Definition: ntddvdeo.h:337
@ VideoPowerShutdown
Definition: ntddvdeo.h:339
@ VideoPowerStandBy
Definition: ntddvdeo.h:335
#define MONITOR_HW_ID
Definition: pc98vid.h:29
#define DISPLAY_ADAPTER_HW_ID
Definition: video.h:115
#define VideoDebugPrint(x)
Definition: video.h:75

Referenced by DriverEntry().

◆ Pc98VidSetColorRegisters()

VP_STATUS FASTCALL Pc98VidSetColorRegisters ( _In_ PVIDEO_CLUT  ColorLookUpTable)

Definition at line 261 of file hardware.c.

263{
265
266 PAGED_CODE();
267
268 VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
269
270 if (ColorLookUpTable->NumEntries > PEGC_MAX_COLORS)
272
273 for (Entry = ColorLookUpTable->FirstEntry;
274 Entry < ColorLookUpTable->FirstEntry + ColorLookUpTable->NumEntries;
275 ++Entry)
276 {
279 ColorLookUpTable->LookupTable[Entry].RgbArray.Red);
281 ColorLookUpTable->LookupTable[Entry].RgbArray.Green);
283 ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
284 }
285
286 return NO_ERROR;
287}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
unsigned short USHORT
Definition: pedump.c:61
#define GDC2_IO_o_RED
Definition: video.h:277
#define GDC2_IO_o_GREEN
Definition: video.h:276
#define GDC2_IO_o_PALETTE_INDEX
Definition: video.h:275
#define GDC2_IO_o_BLUE
Definition: video.h:278
base of all file and directory entries
Definition: entries.h:83
#define PEGC_MAX_COLORS
Definition: hardware.c:14

Referenced by Pc98VidStartIO().

◆ Pc98VidSetCurrentMode()

VP_STATUS FASTCALL Pc98VidSetCurrentMode ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension,
_In_ PVIDEO_MODE  RequestedMode 
)

Definition at line 83 of file hardware.c.

86{
87 SYNCPARAM SyncParameters;
88 CSRFORMPARAM CursorParameters;
90 PITCHPARAM PitchParameters;
91 PRAMPARAM RamParameters;
92 ZOOMPARAM ZoomParameters;
93 UCHAR RelayState;
94
95 PAGED_CODE();
96
97 VideoDebugPrint((Trace, "%s() Mode %d\n",
98 __FUNCTION__, RequestedMode->RequestedMode));
99
100 if (RequestedMode->RequestedMode > DeviceExtension->ModeCount)
102
103 /* Blank screen */
105
106 /* RESET, without FIFO check */
109
110 /* Configure chipset */
118 VideoModes[RequestedMode->RequestedMode].Clock1);
120 VideoModes[RequestedMode->RequestedMode].Clock2);
122 VideoModes[RequestedMode->RequestedMode].HorizontalScanRate);
125
126 /* =========================== MASTER ============================ */
127
128 /* MASTER */
130
131 /* SYNC */
132 SyncParameters = VideoModes[RequestedMode->RequestedMode].TextSyncParameters;
136 WRITE_GDC_SYNC((PUCHAR)GDC1_IO_o_PARAM, &SyncParameters);
137
138 /* CSRFORM */
139 CursorParameters.Show = FALSE;
140 CursorParameters.Blink = FALSE;
141 CursorParameters.BlinkRate = 12;
142 CursorParameters.LinesPerRow = 16;
143 CursorParameters.StartScanLine = 0;
144 CursorParameters.EndScanLine = 15;
146 WRITE_GDC_CSRFORM((PUCHAR)GDC1_IO_o_PARAM, &CursorParameters);
147
148 /* PITCH */
149 PitchParameters.WordsPerScanline = 80;
151 WRITE_GDC_PITCH((PUCHAR)GDC1_IO_o_PARAM, &PitchParameters);
152
153 /* PRAM */
154 RamParameters.StartingAddress = 0;
155 RamParameters.Length = 1023;
156 RamParameters.ImageBit = FALSE;
157 RamParameters.WideDisplay = FALSE;
159 WRITE_GDC_PRAM((PUCHAR)GDC1_IO_o_PARAM, &RamParameters);
160
161 /* ZOOM */
162 ZoomParameters.DisplayZoomFactor = 0;
163 ZoomParameters.WritingZoomFactor = 0;
165 WRITE_GDC_ZOOM((PUCHAR)GDC1_IO_o_PARAM, &ZoomParameters);
166
167 /* CSRW */
168 CursorPosition.CursorAddress = 0;
169 CursorPosition.DotAddress = 0;
172
173 /* START */
175
176 /* ============================ SLAVE ============================ */
177
178 /* SLAVE */
180
181 /* SYNC */
182 SyncParameters = VideoModes[RequestedMode->RequestedMode].VideoSyncParameters;
187 WRITE_GDC_SYNC((PUCHAR)GDC2_IO_o_PARAM, &SyncParameters);
188
189 /* CSRFORM */
190 CursorParameters.Show = FALSE;
191 CursorParameters.Blink = FALSE;
192 CursorParameters.BlinkRate = 0;
193 CursorParameters.LinesPerRow = 1;
194 CursorParameters.StartScanLine = 0;
195 CursorParameters.EndScanLine = 0;
197 WRITE_GDC_CSRFORM((PUCHAR)GDC2_IO_o_PARAM, &CursorParameters);
198
199 /* PITCH */
200 PitchParameters.WordsPerScanline = 80;
202 WRITE_GDC_PITCH((PUCHAR)GDC2_IO_o_PARAM, &PitchParameters);
203
204 /* PRAM */
205 RamParameters.StartingAddress = 0;
206 RamParameters.Length = 1023;
207 RamParameters.ImageBit = TRUE;
208 RamParameters.WideDisplay = FALSE;
210 WRITE_GDC_PRAM((PUCHAR)GDC2_IO_o_PARAM, &RamParameters);
211
212 /* ZOOM */
213 ZoomParameters.DisplayZoomFactor = 0;
214 ZoomParameters.WritingZoomFactor = 0;
216 WRITE_GDC_ZOOM((PUCHAR)GDC2_IO_o_PARAM, &ZoomParameters);
217
218 /* CSRW */
219 CursorPosition.CursorAddress = 0;
220 CursorPosition.DotAddress = 0;
223
224 /* Synchronize the master sync source */
225 TextSync();
226 TextSync();
227 TextSync();
228 TextSync();
229
230 /* START */
232
233 /* 256 colors, packed pixel */
237 VideoModes[RequestedMode->RequestedMode].Mem);
239 VideoPortWriteRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
241 VideoPortWriteRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
243
244 /* Select the video source */
249
250 /* Unblank screen */
252
253 DeviceExtension->CurrentMode = RequestedMode->RequestedMode;
254
255 return NO_ERROR;
256}
#define TRUE
Definition: types.h:120
static USHORT CursorPosition
Definition: pc98cons.c:20
VPAPI VOID NTAPI VideoPortWriteRegisterUshort(IN PUSHORT Register, IN USHORT Value)
#define GDC_COMMAND_PITCH
Definition: video.h:138
#define PEGC_MODE_PACKED
Definition: video.h:421
#define GDC1_IO_o_MODE_FLIPFLOP1
Definition: video.h:238
#define GDC_COMMAND_MASTER
Definition: video.h:200
#define SYNC_VIDEO_FRAMING_NONINTERLACED
Definition: video.h:83
FORCEINLINE VOID WRITE_GDC_CSRFORM(PUCHAR Port, PCSRFORMPARAM CursorParameters)
Definition: video.h:186
#define GDC2_IO_o_COMMAND
Definition: video.h:272
#define GRAPH_MODE_DISPLAY_ENABLE
Definition: video.h:254
#define SYNC_DISPLAY_MODE_GRAPHICS
Definition: video.h:80
#define GDC2_MODE_ODD_RLINE_SHOW
Definition: video.h:247
#define PEGC_MMIO_MODE
Definition: video.h:420
#define GDC2_MODE_LINES_400
Definition: video.h:301
#define GDC_COMMAND_BCTRL_START
Definition: video.h:73
#define GDC2_IO_o_VIDEO_PAGE_ACCESS
Definition: video.h:274
#define GDC2_MODE_LCD
Definition: video.h:298
#define GDC1_IO_o_COMMAND
Definition: video.h:235
#define PEGC_FB_MAP
Definition: video.h:426
#define PEGC_MMIO_FRAMEBUFFER
Definition: video.h:424
#define GRAPH_VID_SRC_INTERNAL
Definition: video.h:370
FORCEINLINE VOID WRITE_GDC_CSRW(PUCHAR Port, PCSRWPARAM CursorParameters)
Definition: video.h:160
#define GDC2_MODE_GRCG
Definition: video.h:283
#define GDC2_IO_o_VIDEO_PAGE
Definition: video.h:273
#define GRAPH_IO_i_RELAY
Definition: video.h:364
#define GRAPH_IO_o_RELAY
Definition: video.h:368
#define GDC_COMMAND_SLAVE
Definition: video.h:199
FORCEINLINE VOID WRITE_GDC_ZOOM(PUCHAR Port, PZOOMPARAM ZoomParameters)
Definition: video.h:133
#define GDC2_MODE_COLORS_16
Definition: video.h:282
#define GDC_COMMAND_PRAM
Definition: video.h:202
#define GRAPH_SRC_GDC
Definition: video.h:373
FORCEINLINE VOID WRITE_GDC2_COMMAND(UCHAR Command)
Definition: video.h:336
FORCEINLINE VOID WRITE_GDC_PITCH(PUCHAR Port, PPITCHPARAM PitchParameters)
Definition: video.h:146
FORCEINLINE VOID WRITE_GDC_PRAM(PUCHAR Port, PPRAMPARAM RamParameters)
Definition: video.h:213
#define GRAPH_MODE_COLORED
Definition: video.h:241
#define SYNC_DRAW_ONLY_DURING_RETRACE_BLANKING
Definition: video.h:88
#define GDC_COMMAND_ZOOM
Definition: video.h:124
#define SYNC_STATIC_RAM_NO_REFRESH
Definition: video.h:90
#define GRAPH_IO_o_HORIZONTAL_SCAN_RATE
Definition: video.h:360
#define GDC_COMMAND_RESET1
Definition: video.h:68
#define SYNC_DISPLAY_MODE_GRAPHICS_AND_CHARACTERS
Definition: video.h:79
#define GDC1_IO_o_PARAM
Definition: video.h:234
#define GRAPH_MODE_DISPLAY_DISABLE
Definition: video.h:253
#define GDC_COMMAND_CSRW
Definition: video.h:151
#define SYNC_DRAW_DURING_ACTIVE_DISPLAY_TIME_AND_RETRACE_BLANKING
Definition: video.h:87
FORCEINLINE VOID WRITE_GDC1_COMMAND(UCHAR Command)
Definition: video.h:326
#define GRAPH_RELAY_1
Definition: video.h:366
#define GDC2_IO_o_PARAM
Definition: video.h:271
FORCEINLINE VOID WRITE_GDC_SYNC(PUCHAR Port, PSYNCPARAM SyncParameters)
Definition: video.h:105
#define GDC_COMMAND_SYNC_ON
Definition: video.h:75
#define GRAPH_RELAY_0
Definition: video.h:365
#define GDC_COMMAND_CSRFORM
Definition: video.h:173
UCHAR StartScanLine
Definition: video.h:180
UCHAR LinesPerRow
Definition: video.h:179
BOOLEAN Show
Definition: video.h:176
UCHAR EndScanLine
Definition: video.h:181
BOOLEAN Blink
Definition: video.h:177
UCHAR BlinkRate
Definition: video.h:178
ULONG WordsPerScanline
Definition: video.h:141
ULONG StartingAddress
Definition: video.h:205
USHORT Length
Definition: video.h:206
BOOLEAN ImageBit
Definition: video.h:207
BOOLEAN WideDisplay
Definition: video.h:208
UCHAR Flags
Definition: video.h:78
UCHAR WritingZoomFactor
Definition: video.h:128
UCHAR DisplayZoomFactor
Definition: video.h:127
uint16_t * PUSHORT
Definition: typedefs.h:56
static CONST VGA_MODE VideoModes[BIOS_MAX_VIDEO_MODE+1]
Definition: vidbios.c:1941
static VOID TextSync(VOID)
Definition: hardware.c:52

Referenced by Pc98VidStartIO().

◆ Pc98VidSetPowerState()

VP_STATUS NTAPI Pc98VidSetPowerState ( _In_ PVOID  HwDeviceExtension,
_In_ ULONG  HwId,
_In_ PVIDEO_POWER_MANAGEMENT  VideoPowerControl 
)

Definition at line 321 of file hardware.c.

325{
326 UCHAR Dpms;
327
328 PAGED_CODE();
329
330 VideoDebugPrint((Trace, "%s() Id %lX, State %x\n",
331 __FUNCTION__, HwId, VideoPowerControl->PowerState));
332
333 if (HwId == MONITOR_HW_ID)
334 {
336
337 switch (VideoPowerControl->PowerState)
338 {
339 case VideoPowerOn:
340 /* Turn on HS/VS signals */
343
344 /* Unblank screen */
347 break;
348
350 /* Disable HS signal */
353 break;
354
356 /* Disable VS signal */
359 break;
360
361 case VideoPowerOff:
363 /* Turn off HS/VS signals */
366
367 /* Blank screen */
370 break;
371 }
372 }
373
374 return NO_ERROR;
375}
#define GRAPH_DPMS_HSYNC_MASK
Definition: video.h:356
#define GRAPH_IO_o_DPMS
Definition: video.h:355
#define GRAPH_DPMS_VSYNC_MASK
Definition: video.h:357
#define GRAPH_IO_i_DPMS
Definition: video.h:354

Referenced by DriverEntry().

◆ TestMmio()

static BOOLEAN TestMmio ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension)
static

Definition at line 31 of file hardware.c.

33{
34 USHORT OldValue, NewValue;
35
36 OldValue = VideoPortReadRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
38
39 /* Bits [15:1] are not writable */
40 VideoPortWriteRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
41 PEGC_MMIO_MODE), 0x80);
42 NewValue = VideoPortReadRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
44
45 VideoPortWriteRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
46 PEGC_MMIO_MODE), OldValue);
47
48 return !(NewValue & 0x80);
49}
VPAPI USHORT NTAPI VideoPortReadRegisterUshort(IN PUSHORT Register)

Referenced by HasPegcController().

◆ TextSync()

static VOID TextSync ( VOID  )
static

Definition at line 52 of file hardware.c.

53{
55 NOTHING;
56
58 NOTHING;
59}
#define NOTHING
Definition: input_list.c:10
#define GDC1_IO_i_STATUS
Definition: video.h:230
#define GDC_STATUS_VSYNC
Definition: video.h:41

Referenced by Pc98VidSetCurrentMode().