3 * Copyright (C) 1998, 1999, 2000, 2001, 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: display.c,v 1.8 2003/08/24 20:56:16 dwelch Exp $
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: ntoskrnl/hal/x86/display.c
24 * PURPOSE: Blue screen display
25 * PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
31 * Portions of this code are from the XFree86 Project and available from the
34 * Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved.
36 * Permission is hereby granted, free of charge, to any person obtaining a copy
37 * of this software and associated documentation files (the "Software"), to
38 * deal in the Software without restriction, including without limitation the
39 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
40 * sell copies of the Software, and to permit persons to whom the Software is
41 * furnished to do so, subject to the following conditions:
43 * The above copyright notice and this permission notice shall be included in
44 * all copies or substantial portions of the Software.
46 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49 * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
50 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
51 * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53 * Except as contained in this notice, the name of the XFree86 Project shall
54 * not be used in advertising or otherwise to promote the sale, use or other
55 * dealings in this Software without prior written authorization from the
61 * So, who owns the physical display and is allowed to write to it?
63 * In MS NT, upon boot HAL owns the display. Somewhere in the boot
64 * sequence (haven't figured out exactly where or by who), some
65 * component calls HalAcquireDisplayOwnership. From that moment on,
66 * the display is owned by that component and is switched to graphics
67 * mode. The display is not supposed to return to text mode, except
68 * in case of a bug check. The bug check will call HalDisplayString
69 * to output a string to the text screen. HAL will notice that it
70 * currently doesn't own the display and will re-take ownership, by
71 * calling the callback function passed to HalAcquireDisplayOwnership.
72 * After the bugcheck, execution is halted. So, under NT, the only
73 * possible sequence of display modes is text mode -> graphics mode ->
74 * text mode (the latter hopefully happening very infrequently).
76 * Things are a little bit different in the current state of ReactOS.
77 * We want to have a functional interactive text mode. We should be
78 * able to switch from text mode to graphics mode when a GUI app is
79 * started and switch back to text mode when it's finished. Then, when
80 * another GUI app is started, another switch to and from graphics mode
81 * is possible. Also, when the system bugchecks in graphics mode we want
82 * to switch back to text mode to show the registers and stack trace.
83 * Last but not least, HalDisplayString is used a lot more in ReactOS,
84 * e.g. to print debug messages when the /DEBUGPORT=SCREEN boot option
86 * 3 Components are involved in Reactos: HAL, BLUE.SYS and VIDEOPRT.SYS.
87 * As in NT, on boot HAL owns the display. When entering the text mode
88 * command interpreter, BLUE.SYS kicks in. It will write directly to the
89 * screen, more or less behind HALs back.
90 * When a GUI app is started, WIN32K.SYS will open the DISPLAY device.
91 * This open call will end up in VIDEOPRT.SYS. That component will then
92 * take ownership of the display by calling HalAcquireDisplayOwnership.
93 * When the GUI app terminates (WIN32K.SYS will close the DISPLAY device),
94 * we want to give ownership of the display back to HAL. Using the
95 * standard exported HAL functions, that's a bit of a problem, because
96 * there is no function defined to do that. In NT, this is handled by
97 * HalDisplayString, but that solution isn't satisfactory in ReactOS,
98 * because HalDisplayString is (in some cases) also used to output debug
99 * messages. If we do it the NT way, the first debug message output while
100 * in graphics mode would switch the display back to text mode.
101 * So, instead, if HalDisplayString detects that HAL doesn't have ownership
102 * of the display, it doesn't do anything.
103 * To return ownership to HAL, a new function is exported,
104 * HalReleaseDisplayOwnership. This function is called by the DISPLAY
105 * device Close routine in VIDEOPRT.SYS. It is also called at the beginning
106 * of a bug check, so HalDisplayString is activated again.
107 * Now, while the display is in graphics mode (not owned by HAL), BLUE.SYS
108 * should also refrain from writing to the screen buffer. The text mode
109 * screen buffer might overlap the graphics mode screen buffer, so changing
110 * something in the text mode buffer might mess up the graphics screen. To
111 * allow BLUE.SYS to detect if HAL owns the display, another new function is
112 * exported, HalQueryDisplayOwnership. BLUE.SYS will call this function to
113 * check if it's allowed to touch the text mode buffer.
115 * In an ideal world, when HAL takes ownership of the display, it should set
116 * up the CRT using real-mode (actually V86 mode, but who cares) INT 0x10
117 * calls. Unfortunately, this will require HAL to setup a real-mode interrupt
118 * table etc. So, we chickened out of that by having the loader set up the
119 * display before switching to protected mode. If HAL is given back ownership
120 * after a GUI app terminates, the INT 0x10 calls are made by VIDEOPRT.SYS,
121 * since there is already support for them via the VideoPortInt10 routine.
124 #include <ddk/ntddk.h>
127 #define SCREEN_SYNCHRONIZATION
129 #define VGA_AC_INDEX 0x3c0
130 #define VGA_AC_READ 0x3c1
131 #define VGA_AC_WRITE 0x3c0
133 #define VGA_MISC_WRITE 0x3c2
135 #define VGA_SEQ_INDEX 0x3c4
136 #define VGA_SEQ_DATA 0x3c5
138 #define VGA_DAC_MASK 0x3c8
139 #define VGA_DAC_READ_INDEX 0x3c7
140 #define VGA_DAC_WRITE_INDEX 0x3c8
141 #define VGA_DAC_DATA 0x3c9
142 #define VGA_FEATURE_READ 0x3ca
143 #define VGA_MISC_READ 0x3cc
145 #define VGA_GC_INDEX 0x3ce
146 #define VGA_GC_DATA 0x3cf
148 #define VGA_CRTC_INDEX 0x3d4
149 #define VGA_CRTC_DATA 0x3d5
151 #define VGA_INSTAT_READ 0x3da
153 #define VGA_SEQ_NUM_REGISTERS 5
154 #define VGA_CRTC_NUM_REGISTERS 25
155 #define VGA_GC_NUM_REGISTERS 9
156 #define VGA_AC_NUM_REGISTERS 21
158 #define CRTC_COLUMNS 0x01
159 #define CRTC_OVERFLOW 0x07
160 #define CRTC_ROWS 0x12
161 #define CRTC_SCANLINES 0x09
163 #define CRTC_CURHI 0x0e
164 #define CRTC_CURLO 0x0f
167 #define CHAR_ATTRIBUTE_BLACK 0x00 /* black on black */
168 #define CHAR_ATTRIBUTE 0x17 /* grey on blue */
170 #define FONT_AMOUNT (8*8192)
172 /* VARIABLES ****************************************************************/
174 static ULONG CursorX
= 0; /* Cursor Position */
175 static ULONG CursorY
= 0;
176 static ULONG SizeX
= 80; /* Display size */
177 static ULONG SizeY
= 25;
179 static BOOLEAN DisplayInitialized
= FALSE
;
180 static BOOLEAN HalOwnsDisplay
= TRUE
;
182 static WORD
*VideoBuffer
= NULL
;
183 static PUCHAR GraphVideoBuffer
= NULL
;
185 static PHAL_RESET_DISPLAY_PARAMETERS HalResetDisplayParameters
= NULL
;
187 static UCHAR SavedTextPalette
[768];
188 static UCHAR SavedTextMiscOutReg
;
189 static UCHAR SavedTextCrtcReg
[VGA_CRTC_NUM_REGISTERS
];
190 static UCHAR SavedTextAcReg
[VGA_AC_NUM_REGISTERS
];
191 static UCHAR SavedTextGcReg
[VGA_GC_NUM_REGISTERS
];
192 static UCHAR SavedTextSeqReg
[VGA_SEQ_NUM_REGISTERS
];
193 static UCHAR SavedTextFont
[2][FONT_AMOUNT
];
194 static BOOL TextPaletteEnabled
= FALSE
;
196 /* STATIC FUNCTIONS *********************************************************/
199 HalClearDisplay (UCHAR CharAttribute
)
201 WORD
*ptr
= (WORD
*)VideoBuffer
;
204 for (i
= 0; i
< SizeX
* SizeY
; i
++, ptr
++)
205 *ptr
= ((CharAttribute
<< 8) + ' ');
213 HalScrollDisplay (VOID
)
218 ptr
= VideoBuffer
+ SizeX
;
219 RtlMoveMemory(VideoBuffer
,
221 SizeX
* (SizeY
- 1) * 2);
223 ptr
= VideoBuffer
+ (SizeX
* (SizeY
- 1));
224 for (i
= 0; i
< SizeX
; i
++, ptr
++)
226 *ptr
= (CHAR_ATTRIBUTE
<< 8) + ' ';
232 HalPutCharacter (CHAR Character
)
236 ptr
= VideoBuffer
+ ((CursorY
* SizeX
) + CursorX
);
237 *ptr
= (CHAR_ATTRIBUTE
<< 8) + Character
;
241 HalDisablePalette(VOID
)
243 (VOID
)READ_PORT_UCHAR((PUCHAR
)VGA_INSTAT_READ
);
244 WRITE_PORT_UCHAR((PUCHAR
)VGA_AC_INDEX
, 0x20);
245 TextPaletteEnabled
= FALSE
;
249 HalEnablePalette(VOID
)
251 (VOID
)READ_PORT_UCHAR((PUCHAR
)VGA_INSTAT_READ
);
252 WRITE_PORT_UCHAR((PUCHAR
)VGA_AC_INDEX
, 0x00);
253 TextPaletteEnabled
= TRUE
;
257 HalReadGc(ULONG Index
)
259 WRITE_PORT_UCHAR((PUCHAR
)VGA_GC_INDEX
, Index
);
260 return(READ_PORT_UCHAR((PUCHAR
)VGA_GC_DATA
));
264 HalWriteGc(ULONG Index
, UCHAR Value
)
266 WRITE_PORT_UCHAR((PUCHAR
)VGA_GC_INDEX
, Index
);
267 WRITE_PORT_UCHAR((PUCHAR
)VGA_GC_DATA
, Value
);
271 HalReadSeq(ULONG Index
)
273 WRITE_PORT_UCHAR((PUCHAR
)VGA_SEQ_INDEX
, Index
);
274 return(READ_PORT_UCHAR((PUCHAR
)VGA_SEQ_DATA
));
278 HalWriteSeq(ULONG Index
, UCHAR Value
)
280 WRITE_PORT_UCHAR((PUCHAR
)VGA_SEQ_INDEX
, Index
);
281 WRITE_PORT_UCHAR((PUCHAR
)VGA_SEQ_DATA
, Value
);
285 HalWriteAc(ULONG Index
, UCHAR Value
)
287 if (TextPaletteEnabled
)
295 (VOID
)READ_PORT_UCHAR((PUCHAR
)VGA_INSTAT_READ
);
296 WRITE_PORT_UCHAR((PUCHAR
)VGA_AC_INDEX
, Index
);
297 WRITE_PORT_UCHAR((PUCHAR
)VGA_AC_WRITE
, Value
);
301 HalReadAc(ULONG Index
)
303 if (TextPaletteEnabled
)
311 (VOID
)READ_PORT_UCHAR((PUCHAR
)VGA_INSTAT_READ
);
312 WRITE_PORT_UCHAR((PUCHAR
)VGA_AC_INDEX
, Index
);
313 return(READ_PORT_UCHAR((PUCHAR
)VGA_AC_READ
));
317 HalWriteCrtc(ULONG Index
, UCHAR Value
)
319 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, Index
);
320 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
, Value
);
324 HalReadCrtc(ULONG Index
)
326 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, Index
);
327 return(READ_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
));
331 HalResetSeq(BOOL Start
)
335 HalWriteSeq(0x00, 0x01);
339 HalWriteSeq(0x00, 0x03);
344 HalBlankScreen(BOOL On
)
348 Scrn
= HalReadSeq(0x01);
360 HalWriteSeq(0x01, Scrn
);
368 UCHAR MiscOut
, Gc4
, Gc5
, Gc6
, Seq2
, Seq4
;
371 /* Check if we are already in graphics mode. */
372 Attr10
= HalReadAc(0x10);
378 /* Save registers. */
379 MiscOut
= READ_PORT_UCHAR((PUCHAR
)VGA_MISC_READ
);
380 Gc4
= HalReadGc(0x04);
381 Gc5
= HalReadGc(0x05);
382 Gc6
= HalReadGc(0x06);
383 Seq2
= HalReadSeq(0x02);
384 Seq4
= HalReadSeq(0x04);
386 /* Force colour mode. */
387 WRITE_PORT_UCHAR((PUCHAR
)VGA_MISC_WRITE
, MiscOut
| 0x01);
389 HalBlankScreen(FALSE
);
391 for (i
= 0; i
< 2; i
++)
394 HalWriteSeq(0x02, 0x04 << i
); /* Write to plane 2 or 3 */
395 HalWriteSeq(0x04, 0x06); /* Enable plane graphics. */
396 HalWriteGc(0x04, 0x02 + i
); /* Read plane 2 or 3 */
397 HalWriteGc(0x05, 0x00); /* Write mode 0; read mode 0 */
398 HalWriteGc(0x06, 0x05); /* Set graphics. */
399 memcpy(SavedTextFont
[i
], GraphVideoBuffer
, FONT_AMOUNT
);
402 /* Restore registers. */
403 HalWriteAc(0x10, Attr10
);
404 HalWriteSeq(0x02, Seq2
);
405 HalWriteSeq(0x04, Seq4
);
406 HalWriteGc(0x04, Gc4
);
407 HalWriteGc(0x05, Gc5
);
408 HalWriteGc(0x06, Gc6
);
409 WRITE_PORT_UCHAR((PUCHAR
)VGA_MISC_WRITE
, MiscOut
);
411 HalBlankScreen(TRUE
);
419 SavedTextMiscOutReg
= READ_PORT_UCHAR((PUCHAR
)VGA_MISC_READ
);
421 for (i
= 0; i
< VGA_CRTC_NUM_REGISTERS
; i
++)
423 SavedTextCrtcReg
[i
] = HalReadCrtc(i
);
427 for (i
= 0; i
< VGA_AC_NUM_REGISTERS
; i
++)
429 SavedTextAcReg
[i
] = HalReadAc(i
);
433 for (i
= 0; i
< VGA_GC_NUM_REGISTERS
; i
++)
435 SavedTextGcReg
[i
] = HalReadGc(i
);
438 for (i
= 0; i
< VGA_SEQ_NUM_REGISTERS
; i
++)
440 SavedTextSeqReg
[i
] = HalReadSeq(i
);
447 (VOID
)READ_PORT_UCHAR((PUCHAR
)VGA_INSTAT_READ
);
448 (VOID
)READ_PORT_UCHAR((PUCHAR
)VGA_INSTAT_READ
);
455 WRITE_PORT_UCHAR((PUCHAR
)VGA_DAC_MASK
, 0xFF);
456 WRITE_PORT_UCHAR((PUCHAR
)VGA_DAC_READ_INDEX
, 0x00);
457 for (i
= 0; i
< 768; i
++)
459 SavedTextPalette
[i
] = READ_PORT_UCHAR((PUCHAR
)VGA_DAC_DATA
);
467 UCHAR MiscOut
, Attr10
, Gc1
, Gc3
, Gc4
, Gc5
, Gc6
, Gc8
;
471 /* Save registers. */
472 MiscOut
= READ_PORT_UCHAR((PUCHAR
)VGA_MISC_READ
);
473 Attr10
= HalReadAc(0x10);
474 Gc1
= HalReadGc(0x01);
475 Gc3
= HalReadGc(0x03);
476 Gc4
= HalReadGc(0x04);
477 Gc5
= HalReadGc(0x05);
478 Gc6
= HalReadGc(0x06);
479 Gc8
= HalReadGc(0x08);
480 Seq2
= HalReadSeq(0x02);
481 Seq4
= HalReadSeq(0x04);
483 /* Force into colour mode. */
484 WRITE_PORT_UCHAR((PUCHAR
)VGA_MISC_WRITE
, MiscOut
| 0x10);
486 HalBlankScreen(FALSE
);
488 HalWriteGc(0x03, 0x00); /* Don't rotate; write unmodified. */
489 HalWriteGc(0x08, 0xFF); /* Write all bits. */
490 HalWriteGc(0x01, 0x00); /* All planes from CPU. */
492 for (i
= 0; i
< 2; i
++)
494 HalWriteSeq(0x02, 0x04 << i
); /* Write to plane 2 or 3 */
495 HalWriteSeq(0x04, 0x06); /* Enable plane graphics. */
496 HalWriteGc(0x04, 0x02 + i
); /* Read plane 2 or 3 */
497 HalWriteGc(0x05, 0x00); /* Write mode 0; read mode 0. */
498 HalWriteGc(0x06, 0x05); /* Set graphics. */
499 memcpy(GraphVideoBuffer
, SavedTextFont
[i
], FONT_AMOUNT
);
502 HalBlankScreen(TRUE
);
504 /* Restore registers. */
505 WRITE_PORT_UCHAR((PUCHAR
)VGA_MISC_WRITE
, MiscOut
);
506 HalWriteAc(0x10, Attr10
);
507 HalWriteGc(0x01, Gc1
);
508 HalWriteGc(0x03, Gc3
);
509 HalWriteGc(0x04, Gc4
);
510 HalWriteGc(0x05, Gc5
);
511 HalWriteGc(0x06, Gc6
);
512 HalWriteGc(0x08, Gc8
);
513 HalWriteSeq(0x02, Seq2
);
514 HalWriteSeq(0x04, Seq4
);
522 WRITE_PORT_UCHAR((PUCHAR
)VGA_MISC_WRITE
, SavedTextMiscOutReg
);
524 for (i
= 1; i
< VGA_SEQ_NUM_REGISTERS
; i
++)
526 HalWriteSeq(i
, SavedTextSeqReg
[i
]);
529 /* Unlock CRTC registers 0-7 */
530 HalWriteCrtc(17, SavedTextCrtcReg
[17] & ~0x80);
532 for (i
= 0; i
< VGA_CRTC_NUM_REGISTERS
; i
++)
534 HalWriteCrtc(i
, SavedTextCrtcReg
[i
]);
537 for (i
= 0; i
< VGA_GC_NUM_REGISTERS
; i
++)
539 HalWriteGc(i
, SavedTextGcReg
[i
]);
543 for (i
= 0; i
< VGA_AC_NUM_REGISTERS
; i
++)
545 HalWriteAc(i
, SavedTextAcReg
[i
]);
551 HalRestorePalette(VOID
)
554 WRITE_PORT_UCHAR((PUCHAR
)VGA_DAC_MASK
, 0xFF);
555 WRITE_PORT_UCHAR((PUCHAR
)VGA_DAC_WRITE_INDEX
, 0x00);
556 for (i
= 0; i
< 768; i
++)
558 WRITE_PORT_UCHAR((PUCHAR
)VGA_DAC_DATA
, SavedTextPalette
[i
]);
564 /* PRIVATE FUNCTIONS ********************************************************/
567 HalInitializeDisplay (PLOADER_PARAMETER_BLOCK LoaderBlock
)
569 * FUNCTION: Initalize the display
571 * InitParameters = Parameters setup by the boot loader
574 if (DisplayInitialized
== FALSE
)
579 VideoBuffer
= (WORD
*)(0xd0000000 + 0xb8000);
580 GraphVideoBuffer
= (PUCHAR
)(0xd0000000 + 0xa0000);
581 // VideoBuffer = HalMapPhysicalMemory (0xb8000, 2);
583 /* Set cursor position */
584 // CursorX = LoaderBlock->cursorx;
585 // CursorY = LoaderBlock->cursory;
589 /* read screen size from the crtc */
590 /* FIXME: screen size should be read from the boot parameters */
591 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, CRTC_COLUMNS
);
592 SizeX
= READ_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
) + 1;
593 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, CRTC_ROWS
);
594 SizeY
= READ_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
);
595 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, CRTC_OVERFLOW
);
596 Data
= READ_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
);
597 SizeY
|= (((Data
& 0x02) << 7) | ((Data
& 0x40) << 3));
599 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, CRTC_SCANLINES
);
600 ScanLines
= (READ_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
) & 0x1F) + 1;
601 SizeY
= SizeY
/ ScanLines
;
606 HalClearDisplay(CHAR_ATTRIBUTE_BLACK
);
608 DisplayInitialized
= TRUE
;
611 Save the VGA state at this point so we can restore it on a bugcheck.
620 /* PUBLIC FUNCTIONS *********************************************************/
623 HalReleaseDisplayOwnership()
625 * FUNCTION: Release ownership of display back to HAL
628 if (HalResetDisplayParameters
== NULL
)
631 if (HalOwnsDisplay
== TRUE
)
634 if (!HalResetDisplayParameters(SizeX
, SizeY
))
640 HalOwnsDisplay
= TRUE
;
641 HalClearDisplay(CHAR_ATTRIBUTE
);
646 HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters
)
650 * ResetDisplayParameters = Pointer to a driver specific
654 HalOwnsDisplay
= FALSE
;
655 HalResetDisplayParameters
= ResetDisplayParameters
;
659 HalDisplayString(IN PCH String
)
661 * FUNCTION: Switches the screen to HAL console mode (BSOD) if not there
662 * already and displays a string
664 * string = ASCII string to display
665 * NOTE: Use with care because there is no support for returning from BSOD
670 #ifdef SCREEN_SYNCHRONIZATION
673 static KSPIN_LOCK Lock
;
676 /* See comment at top of file */
677 if (! HalOwnsDisplay
)
686 KeAcquireSpinLockAtDpcLevel(&Lock
);
689 if (HalOwnsDisplay
== FALSE
)
691 HalReleaseDisplayOwnership();
695 #ifdef SCREEN_SYNCHRONIZATION
696 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, CRTC_CURHI
);
697 offset
= READ_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
)<<8;
698 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, CRTC_CURLO
);
699 offset
+= READ_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
);
701 CursorY
= offset
/ SizeX
;
702 CursorX
= offset
% SizeX
;
712 else if (*pch
!= '\r')
714 HalPutCharacter (*pch
);
717 if (CursorX
>= SizeX
)
724 if (CursorY
>= SizeY
)
733 #ifdef SCREEN_SYNCHRONIZATION
734 offset
= (CursorY
* SizeX
) + CursorX
;
736 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, CRTC_CURLO
);
737 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
, offset
& 0xff);
738 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_INDEX
, CRTC_CURHI
);
739 WRITE_PORT_UCHAR((PUCHAR
)VGA_CRTC_DATA
, (offset
>> 8) & 0xff);
741 KeReleaseSpinLockFromDpcLevel(&Lock
);
746 HalQueryDisplayParameters(OUT PULONG DispSizeX
,
747 OUT PULONG DispSizeY
,
748 OUT PULONG CursorPosX
,
749 OUT PULONG CursorPosY
)
756 *CursorPosX
= CursorX
;
758 *CursorPosY
= CursorY
;
763 HalSetDisplayParameters(IN ULONG CursorPosX
,
766 CursorX
= (CursorPosX
< SizeX
) ? CursorPosX
: SizeX
- 1;
767 CursorY
= (CursorPosY
< SizeY
) ? CursorPosY
: SizeY
- 1;
771 HalQueryDisplayOwnership()
773 return ! HalOwnsDisplay
;