ReactOS  0.4.15-dev-1207-g698a8e6
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 21 of file hardware.c.

Function Documentation

◆ GraphGetStatus()

static BOOLEAN GraphGetStatus ( _In_ UCHAR  Status)
static

Definition at line 26 of file hardware.c.

28 {
29  UCHAR Result;
30 
33 
34  return (Result & GRAPH_STATUS_SET) && (Result != 0xFF);
35 }
unsigned char * PUCHAR
Definition: retypes.h:3
VPAPI UCHAR NTAPI VideoPortReadPortUchar(IN PUCHAR Port)
#define GRAPH_STATUS_SET
Definition: video.h:347
_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:426
#define GRAPH_IO_o_STATUS_SELECT
Definition: video.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
#define GRAPH_IO_i_STATUS
Definition: video.h:346
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)

Referenced by HasPegcController().

◆ HasPegcController()

BOOLEAN NTAPI HasPegcController ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension)

Definition at line 70 of file hardware.c.

72 {
74 
76  return TestMmio(DeviceExtension);
77 
80  Success = GraphGetStatus(GRAPH_STATUS_PEGC) ? TestMmio(DeviceExtension) : FALSE;
83 
84  return Success;
85 }
unsigned char * PUCHAR
Definition: retypes.h:3
#define GRAPH_STATUS_PEGC
Definition: video.h:352
#define GDC2_IO_o_MODE_FLIPFLOP2
Definition: video.h:280
#define GDC2_EGC_FF_PROTECT
Definition: video.h:285
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
#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:38
static BOOLEAN GraphGetStatus(_In_ UCHAR Status)
Definition: hardware.c:26
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)

◆ Pc98VidGetPowerState()

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

Definition at line 296 of file hardware.c.

300 {
301  PAGED_CODE();
302 
303  VideoDebugPrint((Trace, "%s() Id %lX, State %x\n",
304  __FUNCTION__, HwId, VideoPowerControl->PowerState));
305 
306  if (HwId == MONITOR_HW_ID || HwId == DISPLAY_ADAPTER_HW_ID)
307  {
308  switch (VideoPowerControl->PowerState)
309  {
310  case VideoPowerOn:
311  case VideoPowerStandBy:
312  case VideoPowerSuspend:
313  case VideoPowerOff:
314  case VideoPowerShutdown:
315  return NO_ERROR;
316  }
317  }
318 
320 }
#define DISPLAY_ADAPTER_HW_ID
Definition: video.h:115
#define MONITOR_HW_ID
Definition: pc98vid.h:24
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_DEVICE_REINITIALIZATION_NEEDED
Definition: dderror.h:16
#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 DriverEntry().

◆ Pc98VidSetColorRegisters()

VP_STATUS FASTCALL Pc98VidSetColorRegisters ( _In_ PVIDEO_CLUT  ColorLookUpTable)

Definition at line 266 of file hardware.c.

268 {
269  USHORT Entry;
270 
271  PAGED_CODE();
272 
273  VideoDebugPrint((Trace, "%s()\n", __FUNCTION__));
274 
275  if (ColorLookUpTable->NumEntries > PEGC_MAX_COLORS)
277 
278  for (Entry = ColorLookUpTable->FirstEntry;
279  Entry < ColorLookUpTable->FirstEntry + ColorLookUpTable->NumEntries;
280  ++Entry)
281  {
284  ColorLookUpTable->LookupTable[Entry].RgbArray.Red);
286  ColorLookUpTable->LookupTable[Entry].RgbArray.Green);
288  ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
289  }
290 
291  return NO_ERROR;
292 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define GDC2_IO_o_RED
Definition: video.h:277
struct _Entry Entry
Definition: kefuncs.h:627
#define GDC2_IO_o_BLUE
Definition: video.h:278
unsigned char * PUCHAR
Definition: retypes.h:3
#define PEGC_MAX_COLORS
Definition: hardware.c:21
#define NO_ERROR
Definition: dderror.h:5
#define GDC2_IO_o_PALETTE_INDEX
Definition: video.h:275
#define GDC2_IO_o_GREEN
Definition: video.h:276
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
unsigned short USHORT
Definition: pedump.c:61
#define __FUNCTION__
Definition: types.h:112
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)
base of all file and directory entries
Definition: entries.h:82
#define PAGED_CODE()

Referenced by Pc98VidStartIO().

◆ Pc98VidSetCurrentMode()

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

Definition at line 89 of file hardware.c.

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

Referenced by Pc98VidStartIO().

◆ Pc98VidSetPowerState()

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

Definition at line 324 of file hardware.c.

328 {
329  UCHAR Dpms;
330 
331  PAGED_CODE();
332 
333  VideoDebugPrint((Trace, "%s() Id %lX, State %x\n",
334  __FUNCTION__, HwId, VideoPowerControl->PowerState));
335 
336  if (HwId == MONITOR_HW_ID)
337  {
339 
340  switch (VideoPowerControl->PowerState)
341  {
342  case VideoPowerOn:
343  /* Turn on HS/VS signals */
346 
347  /* Unblank screen */
350  break;
351 
352  case VideoPowerStandBy:
353  /* Disable HS signal */
354  Dpms = (Dpms | GRAPH_DPMS_HSYNC_MASK) & ~GRAPH_DPMS_VSYNC_MASK;
356  break;
357 
358  case VideoPowerSuspend:
359  /* Disable VS signal */
360  Dpms = (Dpms | GRAPH_DPMS_VSYNC_MASK) & ~GRAPH_DPMS_HSYNC_MASK;
362  break;
363 
364  case VideoPowerOff:
365  case VideoPowerShutdown:
366  /* Turn off HS/VS signals */
369 
370  /* Blank screen */
373  break;
374  }
375  }
376 
377  return NO_ERROR;
378 }
#define GRAPH_MODE_DISPLAY_DISABLE
Definition: video.h:253
#define GRAPH_IO_o_DPMS
Definition: video.h:355
#define MONITOR_HW_ID
Definition: pc98vid.h:24
#define GDC1_IO_o_MODE_FLIPFLOP1
Definition: video.h:238
unsigned char * PUCHAR
Definition: retypes.h:3
#define GRAPH_DPMS_HSYNC_MASK
Definition: video.h:356
#define NO_ERROR
Definition: dderror.h:5
VPAPI UCHAR NTAPI VideoPortReadPortUchar(IN PUCHAR Port)
#define GRAPH_DPMS_VSYNC_MASK
Definition: video.h:357
unsigned char UCHAR
Definition: xmlstorage.h:181
#define GRAPH_IO_i_DPMS
Definition: video.h:354
#define Trace(x)
Definition: inflate.c:42
#define VideoDebugPrint(x)
Definition: video.h:75
#define __FUNCTION__
Definition: types.h:112
VPAPI VOID NTAPI VideoPortWritePortUchar(IN PUCHAR Port, IN UCHAR Value)
#define GRAPH_MODE_DISPLAY_ENABLE
Definition: video.h:254
#define PAGED_CODE()

Referenced by DriverEntry().

◆ TestMmio()

static BOOLEAN TestMmio ( _In_ PHW_DEVICE_EXTENSION  DeviceExtension)
static

Definition at line 38 of file hardware.c.

40 {
41  USHORT OldValue, NewValue;
42 
43  OldValue = VideoPortReadRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
45 
46  /* Bits [15:1] are not writable */
47  VideoPortWriteRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
48  PEGC_MMIO_MODE), 0x80);
49  NewValue = VideoPortReadRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
51 
52  VideoPortWriteRegisterUshort((PUSHORT)(DeviceExtension->PegcControlVa +
53  PEGC_MMIO_MODE), OldValue);
54 
55  return !(NewValue & 0x80);
56 }
#define PEGC_MMIO_MODE
Definition: video.h:420
VPAPI VOID NTAPI VideoPortWriteRegisterUshort(IN PUSHORT Register, IN USHORT Value)
VPAPI USHORT NTAPI VideoPortReadRegisterUshort(IN PUSHORT Register)
unsigned short USHORT
Definition: pedump.c:61
unsigned short * PUSHORT
Definition: retypes.h:2

Referenced by HasPegcController().

◆ TextSync()

static VOID TextSync ( VOID  )
static

Definition at line 59 of file hardware.c.

60 {
62  NOTHING;
63 
65  NOTHING;
66 }
unsigned char * PUCHAR
Definition: retypes.h:3
VPAPI UCHAR NTAPI VideoPortReadPortUchar(IN PUCHAR Port)
#define GDC1_IO_i_STATUS
Definition: video.h:230
#define NOTHING
Definition: env_spec_w32.h:461
#define GDC_STATUS_VSYNC
Definition: video.h:41

Referenced by Pc98VidSetCurrentMode().