Ignore '\r' in HalDisplayString().

svn path=/trunk/; revision=2499
This commit is contained in:
Eric Kohl 2002-01-10 01:01:27 +00:00
parent 25c85c7dfe
commit fd4d47ccfc

View file

@ -1,10 +1,28 @@
/* $Id: display.c,v 1.1 2001/08/21 20:18:26 chorns Exp $ /*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001, 2002 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: display.c,v 1.2 2002/01/10 01:01:27 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/hal/x86/display.c * FILE: ntoskrnl/hal/x86/display.c
* PURPOSE: Blue screen display * PURPOSE: Blue screen display
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de) * PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
* UPDATE HISTORY: * UPDATE HISTORY:
* Created 08/10/99 * Created 08/10/99
*/ */
@ -50,43 +68,43 @@ static PHAL_RESET_DISPLAY_PARAMETERS HalResetDisplayParameters = NULL;
static VOID static VOID
HalClearDisplay (VOID) HalClearDisplay (VOID)
{ {
WORD *ptr = (WORD*)VideoBuffer; WORD *ptr = (WORD*)VideoBuffer;
ULONG i; ULONG i;
for (i = 0; i < SizeX * SizeY; i++, ptr++) for (i = 0; i < SizeX * SizeY; i++, ptr++)
*ptr = ((CHAR_ATTRIBUTE << 8) + ' '); *ptr = ((CHAR_ATTRIBUTE << 8) + ' ');
CursorX = 0; CursorX = 0;
CursorY = 0; CursorY = 0;
} }
VOID VOID
HalScrollDisplay (VOID) HalScrollDisplay (VOID)
{ {
WORD *ptr; WORD *ptr;
int i; int i;
ptr = VideoBuffer + SizeX; ptr = VideoBuffer + SizeX;
RtlMoveMemory (VideoBuffer, RtlMoveMemory(VideoBuffer,
ptr, ptr,
SizeX * (SizeY - 1) * 2); SizeX * (SizeY - 1) * 2);
ptr = VideoBuffer + (SizeX * (SizeY - 1)); ptr = VideoBuffer + (SizeX * (SizeY - 1));
for (i = 0; i < SizeX; i++, ptr++) for (i = 0; i < SizeX; i++, ptr++)
{ {
*ptr = (CHAR_ATTRIBUTE << 8) + ' '; *ptr = (CHAR_ATTRIBUTE << 8) + ' ';
} }
} }
static VOID static VOID
HalPutCharacter (CHAR Character) HalPutCharacter (CHAR Character)
{ {
WORD *ptr; WORD *ptr;
ptr = VideoBuffer + ((CursorY * SizeX) + CursorX); ptr = VideoBuffer + ((CursorY * SizeX) + CursorX);
*ptr = (CHAR_ATTRIBUTE << 8) + Character; *ptr = (CHAR_ATTRIBUTE << 8) + Character;
} }
@ -100,73 +118,70 @@ HalInitializeDisplay (PLOADER_PARAMETER_BLOCK LoaderBlock)
* InitParameters = Parameters setup by the boot loader * InitParameters = Parameters setup by the boot loader
*/ */
{ {
if (DisplayInitialized == FALSE) if (DisplayInitialized == FALSE)
{ {
ULONG ScanLines; ULONG ScanLines;
ULONG Data; ULONG Data;
VideoBuffer = (WORD *)(0xd0000000 + 0xb8000); VideoBuffer = (WORD *)(0xd0000000 + 0xb8000);
// VideoBuffer = HalMapPhysicalMemory (0xb8000, 2); // VideoBuffer = HalMapPhysicalMemory (0xb8000, 2);
/* Set cursor position */ /* Set cursor position */
// CursorX = LoaderBlock->cursorx; // CursorX = LoaderBlock->cursorx;
// CursorY = LoaderBlock->cursory; // CursorY = LoaderBlock->cursory;
CursorX = 0; CursorX = 0;
CursorY = 0; CursorY = 0;
/* read screen size from the crtc */ /* read screen size from the crtc */
/* FIXME: screen size should be read from the boot parameters */ /* FIXME: screen size should be read from the boot parameters */
WRITE_PORT_UCHAR((PUCHAR)CRTC_COMMAND, CRTC_COLUMNS); WRITE_PORT_UCHAR((PUCHAR)CRTC_COMMAND, CRTC_COLUMNS);
SizeX = READ_PORT_UCHAR((PUCHAR)CRTC_DATA) + 1; SizeX = READ_PORT_UCHAR((PUCHAR)CRTC_DATA) + 1;
WRITE_PORT_UCHAR((PUCHAR)CRTC_COMMAND, CRTC_ROWS); WRITE_PORT_UCHAR((PUCHAR)CRTC_COMMAND, CRTC_ROWS);
SizeY = READ_PORT_UCHAR((PUCHAR)CRTC_DATA); SizeY = READ_PORT_UCHAR((PUCHAR)CRTC_DATA);
WRITE_PORT_UCHAR((PUCHAR)CRTC_COMMAND, CRTC_OVERFLOW); WRITE_PORT_UCHAR((PUCHAR)CRTC_COMMAND, CRTC_OVERFLOW);
Data = READ_PORT_UCHAR((PUCHAR)CRTC_DATA); Data = READ_PORT_UCHAR((PUCHAR)CRTC_DATA);
SizeY |= (((Data & 0x02) << 7) | ((Data & 0x40) << 3)); SizeY |= (((Data & 0x02) << 7) | ((Data & 0x40) << 3));
SizeY++; SizeY++;
WRITE_PORT_UCHAR((PUCHAR)CRTC_COMMAND, CRTC_SCANLINES); WRITE_PORT_UCHAR((PUCHAR)CRTC_COMMAND, CRTC_SCANLINES);
ScanLines = (READ_PORT_UCHAR((PUCHAR)CRTC_DATA) & 0x1F) + 1; ScanLines = (READ_PORT_UCHAR((PUCHAR)CRTC_DATA) & 0x1F) + 1;
SizeY = SizeY / ScanLines; SizeY = SizeY / ScanLines;
#ifdef BOCHS_30ROWS #ifdef BOCHS_30ROWS
SizeY=30; SizeY=30;
#endif #endif
HalClearDisplay (); HalClearDisplay();
DisplayInitialized = TRUE; DisplayInitialized = TRUE;
} }
} }
VOID VOID
HalResetDisplay (VOID) HalResetDisplay(VOID)
/* /*
* FUNCTION: Reset the display * FUNCTION: Reset the display
* ARGUMENTS: * ARGUMENTS:
* None * None
*/ */
{ {
if (HalResetDisplayParameters == NULL) if (HalResetDisplayParameters == NULL)
return; return;
if (HalOwnsDisplay == TRUE) if (HalOwnsDisplay == TRUE)
return; return;
if (HalResetDisplayParameters(SizeX, SizeY) == TRUE) if (HalResetDisplayParameters(SizeX, SizeY) == TRUE)
{ {
HalOwnsDisplay = TRUE; HalOwnsDisplay = TRUE;
HalClearDisplay (); HalClearDisplay();
} }
} }
/* PUBLIC FUNCTIONS *********************************************************/ /* PUBLIC FUNCTIONS *********************************************************/
VOID VOID STDCALL
STDCALL HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
HalAcquireDisplayOwnership (
IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters
)
/* /*
* FUNCTION: * FUNCTION:
* ARGUMENTS: * ARGUMENTS:
@ -174,13 +189,13 @@ HalAcquireDisplayOwnership (
* reset routine. * reset routine.
*/ */
{ {
HalOwnsDisplay = FALSE; HalOwnsDisplay = FALSE;
HalResetDisplayParameters = ResetDisplayParameters; HalResetDisplayParameters = ResetDisplayParameters;
} }
VOID STDCALL VOID STDCALL
HalDisplayString (IN PCH String) HalDisplayString(IN PCH String)
/* /*
* FUNCTION: Switches the screen to HAL console mode (BSOD) if not there * FUNCTION: Switches the screen to HAL console mode (BSOD) if not there
* already and displays a string * already and displays a string
@ -221,28 +236,28 @@ HalDisplayString (IN PCH String)
while (*pch != 0) while (*pch != 0)
{ {
if (*pch == '\n') if (*pch == '\n')
{ {
CursorY++; CursorY++;
CursorX = 0; CursorX = 0;
} }
else else if (*pch != '\r')
{ {
HalPutCharacter (*pch); HalPutCharacter (*pch);
CursorX++; CursorX++;
if (CursorX >= SizeX) if (CursorX >= SizeX)
{ {
CursorY++; CursorY++;
CursorX = 0; CursorX = 0;
} }
} }
if (CursorY >= SizeY) if (CursorY >= SizeY)
{ {
HalScrollDisplay (); HalScrollDisplay ();
CursorY = SizeY - 1; CursorY = SizeY - 1;
} }
pch++; pch++;
} }
@ -259,35 +274,29 @@ HalDisplayString (IN PCH String)
} }
VOID VOID STDCALL
STDCALL HalQueryDisplayParameters(OUT PULONG DispSizeX,
HalQueryDisplayParameters ( OUT PULONG DispSizeY,
PULONG DispSizeX, OUT PULONG CursorPosX,
PULONG DispSizeY, OUT PULONG CursorPosY)
PULONG CursorPosX,
PULONG CursorPosY
)
{ {
if (DispSizeX) if (DispSizeX)
*DispSizeX = SizeX; *DispSizeX = SizeX;
if (DispSizeY) if (DispSizeY)
*DispSizeY = SizeY; *DispSizeY = SizeY;
if (CursorPosX) if (CursorPosX)
*CursorPosX = CursorX; *CursorPosX = CursorX;
if (CursorPosY) if (CursorPosY)
*CursorPosY = CursorY; *CursorPosY = CursorY;
} }
VOID VOID STDCALL
STDCALL HalSetDisplayParameters(IN ULONG CursorPosX,
HalSetDisplayParameters ( IN ULONG CursorPosY)
ULONG CursorPosX,
ULONG CursorPosY
)
{ {
CursorX = (CursorPosX < SizeX) ? CursorPosX : SizeX - 1; CursorX = (CursorPosX < SizeX) ? CursorPosX : SizeX - 1;
CursorY = (CursorPosY < SizeY) ? CursorPosY : SizeY - 1; CursorY = (CursorPosY < SizeY) ? CursorPosY : SizeY - 1;
} }
/* EOF */ /* EOF */