mirror of
https://github.com/reactos/reactos.git
synced 2024-10-15 05:37:44 +00:00
Fixed hal display and initialization code.
svn path=/trunk/; revision=697
This commit is contained in:
parent
4551dfba1e
commit
29812be566
|
@ -12,6 +12,8 @@
|
|||
#ifndef __INCLUDE_INTERNAL_HAL_DDK_H
|
||||
#define __INCLUDE_INTERNAL_HAL_DDK_H
|
||||
|
||||
#include <internal/ntoskrnl.h>
|
||||
|
||||
/* HalReturnToFirmware */
|
||||
#define FIRMWARE_HALT 1
|
||||
#define FIRMWARE_REBOOT 3
|
||||
|
@ -59,13 +61,17 @@ typedef struct _DEVICE_DESCRIPTION
|
|||
ULONG DmaPort;
|
||||
} DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
|
||||
|
||||
typedef BOOLEAN STDCALL (*RESET_DISPLAY_ROUTINE)(ULONG SizeX, ULONG SizeY);
|
||||
typedef BOOLEAN (*PHAL_RESET_DISPLAY_PARAMETERS)(ULONG Columns, ULONG Rows);
|
||||
|
||||
|
||||
VOID HalAcquireDisplayOwnership (
|
||||
PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
|
||||
|
||||
VOID HalAcquireDisplayOwnership(RESET_DISPLAY_ROUTINE ResetRoutine);
|
||||
PVOID HalAllocateCommonBuffer(PADAPTER_OBJECT AdapterObject,
|
||||
ULONG Length,
|
||||
PPHYSICAL_ADDRESS LogicalAddress,
|
||||
BOOLEAN CacheEnabled);
|
||||
|
||||
NTSTATUS HalAssignSlotResources(PUNICODE_STRING RegistryPath,
|
||||
PUNICODE_STRING DriverClassName,
|
||||
PDRIVER_OBJECT DriverObject,
|
||||
|
@ -74,57 +80,79 @@ NTSTATUS HalAssignSlotResources(PUNICODE_STRING RegistryPath,
|
|||
ULONG BusNumber,
|
||||
ULONG SlotNumber,
|
||||
PCM_RESOURCE_LIST* AllocatedResources);
|
||||
|
||||
VOID HalDisplayString (PCH String);
|
||||
|
||||
VOID HalExamineMBR(PDEVICE_OBJECT DeviceObject,
|
||||
ULONG SectorSize,
|
||||
ULONG MBRTypeIdentifier,
|
||||
PVOID Buffer);
|
||||
|
||||
VOID HalFreeCommonBuffer(PADAPTER_OBJECT AdapterObject,
|
||||
ULONG Length,
|
||||
PHYSICAL_ADDRESS LogicalAddress,
|
||||
PVOID VirtualAddress,
|
||||
BOOLEAN CacheEnabled);
|
||||
|
||||
PADAPTER_OBJECT HalGetAdapter(PDEVICE_DESCRIPTION DeviceDescription,
|
||||
PULONG NumberOfMapRegisters);
|
||||
|
||||
ULONG HalGetBusData(BUS_DATA_TYPE BusDataType,
|
||||
ULONG BusNumber,
|
||||
ULONG SlotNumber,
|
||||
PVOID Buffer,
|
||||
ULONG Length);
|
||||
|
||||
ULONG HalGetBusDataByOffset(BUS_DATA_TYPE BusDataType,
|
||||
ULONG BusNumber,
|
||||
ULONG SlotNumber,
|
||||
PVOID Buffer,
|
||||
ULONG Offset,
|
||||
ULONG Length);
|
||||
|
||||
ULONG HalGetDmaAlignmentRequirement(VOID);
|
||||
|
||||
ULONG HalGetInterruptVector(INTERFACE_TYPE InterfaceType,
|
||||
ULONG BusNumber,
|
||||
ULONG BusInterruptLevel,
|
||||
ULONG BusInterruptVector,
|
||||
PKIRQL Irql,
|
||||
PKAFFINITY Affinity);
|
||||
|
||||
BOOLEAN HalInitSystem (ULONG Phase,
|
||||
boot_param *bp);
|
||||
|
||||
BOOLEAN HalMakeBeep (ULONG Frequency);
|
||||
|
||||
VOID HalQueryDisplayParameters(PULONG DispSizeX,
|
||||
PULONG DispSizeY,
|
||||
PULONG CursorPosX,
|
||||
PULONG CursorPosY);
|
||||
|
||||
VOID HalQueryRealTimeClock(PTIME_FIELDS pTime);
|
||||
|
||||
VOID HalQuerySystemInformation(VOID);
|
||||
|
||||
ULONG HalReadDmaCounter(PADAPTER_OBJECT AdapterObject);
|
||||
|
||||
VOID HalReturnToFirmware(ULONG Action);
|
||||
|
||||
ULONG HalSetBusData(BUS_DATA_TYPE BusDataType,
|
||||
ULONG BusNumber,
|
||||
ULONG SlotNumber,
|
||||
PVOID Buffer,
|
||||
ULONG Length);
|
||||
|
||||
ULONG HalSetBusDataByOffset(BUS_DATA_TYPE BusDataType,
|
||||
ULONG BusNumber,
|
||||
ULONG SlotNumber,
|
||||
PVOID Buffer,
|
||||
ULONG Offset,
|
||||
ULONG Length);
|
||||
|
||||
VOID HalSetDisplayParameters(ULONG CursorPosX,
|
||||
ULONG CursorPosY);
|
||||
|
||||
BOOLEAN HalTranslateBusAddress(INTERFACE_TYPE InterfaceType,
|
||||
ULONG BusNumber,
|
||||
PHYSICAL_ADDRESS BusAddress,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef __INTERNAL_HAL_HAL_H
|
||||
#define __INTERNAL_HAL_HAL_H
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short previous_task;
|
||||
|
@ -71,7 +72,7 @@ BOOLEAN Hal_bios32_is_service_present(ULONG service);
|
|||
/*
|
||||
* FUNCTION: Initializes the text mode display (blue screen)
|
||||
*/
|
||||
VOID HalInitializeDisplay (VOID);
|
||||
|
||||
VOID HalInitializeDisplay (boot_param *bp);
|
||||
VOID HalResetDisplay (VOID)
|
||||
|
||||
#endif /* __INTERNAL_HAL_HAL_H */
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define __INTERNAL_HAL_HAL_H
|
||||
|
||||
#include <internal/service.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -78,4 +79,7 @@ NTSTATUS HalRegisterServiceTable(DWORD Mask,
|
|||
PSERVICE_TABLE Table,
|
||||
DWORD Count);
|
||||
|
||||
VOID HalInitializeDisplay (boot_param *bp);
|
||||
VOID HalResetDisplay (VOID);
|
||||
|
||||
#endif /* __INTERNAL_HAL_HAL_H */
|
||||
|
|
|
@ -79,13 +79,11 @@ VOID NtInit(VOID);
|
|||
* Initalization functions (called once by main())
|
||||
*/
|
||||
VOID MmInitialize(boot_param* bp, ULONG LastKernelAddress);
|
||||
VOID HalInit(boot_param* bp);
|
||||
VOID IoInit(VOID);
|
||||
VOID ObInit(VOID);
|
||||
VOID PsInit(VOID);
|
||||
VOID TstBegin(VOID);
|
||||
VOID KeInit(VOID);
|
||||
VOID HalInitConsole(boot_param* bp);
|
||||
VOID CmInitializeRegistry(VOID);
|
||||
|
||||
#endif
|
||||
|
|
57
reactos/ntoskrnl/dbg/print.c
Normal file
57
reactos/ntoskrnl/dbg/print.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* $Id: print.c,v 1.1 1999/10/15 15:20:31 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/dbg/print.c
|
||||
* PURPOSE: Debug output
|
||||
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||
* UPDATE HISTORY:
|
||||
* 14/10/99: Created
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/hal/ddk.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
ULONG DbgPrint(PCH Format, ...)
|
||||
{
|
||||
char buffer[256];
|
||||
va_list ap;
|
||||
unsigned int eflags;
|
||||
|
||||
/*
|
||||
* Because this is used by alomost every subsystem including irqs it
|
||||
* must be atomic. The following code sequence disables interrupts after
|
||||
* saving the previous state of the interrupt flag
|
||||
*/
|
||||
__asm__("pushf\n\tpop %0\n\tcli\n\t"
|
||||
: "=m" (eflags)
|
||||
: /* */);
|
||||
|
||||
/*
|
||||
* Process the format string into a fixed length buffer using the
|
||||
* standard C RTL function
|
||||
*/
|
||||
va_start(ap,Format);
|
||||
vsprintf(buffer,Format,ap);
|
||||
va_end(ap);
|
||||
|
||||
HalDisplayString (buffer);
|
||||
|
||||
/*
|
||||
* Restore the interrupt flag
|
||||
*/
|
||||
__asm__("push %0\n\tpopf\n\t"
|
||||
:
|
||||
: "m" (eflags));
|
||||
return(strlen(buffer));
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,9 +1,9 @@
|
|||
/* $Id: display.c,v 1.1 1999/10/11 20:50:32 ekohl Exp $
|
||||
/* $Id: display.c,v 1.2 1999/10/15 15:18:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/hal/x86/display.c
|
||||
* PURPOSE: Text mode display functions (blue screen)
|
||||
* PURPOSE: Blue screen display
|
||||
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||
* UPDATE HISTORY:
|
||||
* Created 08/10/99
|
||||
|
@ -11,6 +11,66 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/hal.h>
|
||||
#include <internal/halio.h>
|
||||
|
||||
|
||||
//#define BOCHS_DEBUGGING
|
||||
//#define SERIAL_DEBUGGING
|
||||
#define SCREEN_DEBUGGING
|
||||
|
||||
|
||||
#define SERIAL_PORT 0x03f8
|
||||
#define SERIAL_BAUD_RATE 19200
|
||||
#define SERIAL_LINE_CONTROL (SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef BOCHS_DEBUGGING
|
||||
#define BOCHS_LOGGER_PORT (0x3ed)
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
#define SER_RBR SERIAL_PORT + 0
|
||||
#define SER_THR SERIAL_PORT + 0
|
||||
#define SER_DLL SERIAL_PORT + 0
|
||||
#define SER_IER SERIAL_PORT + 1
|
||||
#define SER_DLM SERIAL_PORT + 1
|
||||
#define SER_IIR SERIAL_PORT + 2
|
||||
#define SER_LCR SERIAL_PORT + 3
|
||||
#define SR_LCR_CS5 0x00
|
||||
#define SR_LCR_CS6 0x01
|
||||
#define SR_LCR_CS7 0x02
|
||||
#define SR_LCR_CS8 0x03
|
||||
#define SR_LCR_ST1 0x00
|
||||
#define SR_LCR_ST2 0x04
|
||||
#define SR_LCR_PNO 0x00
|
||||
#define SR_LCR_POD 0x08
|
||||
#define SR_LCR_PEV 0x18
|
||||
#define SR_LCR_PMK 0x28
|
||||
#define SR_LCR_PSP 0x38
|
||||
#define SR_LCR_BRK 0x40
|
||||
#define SR_LCR_DLAB 0x80
|
||||
#define SER_MCR SERIAL_PORT + 4
|
||||
#define SR_MCR_DTR 0x01
|
||||
#define SR_MCR_RTS 0x02
|
||||
#define SER_LSR SERIAL_PORT + 5
|
||||
#define SR_LSR_TBE 0x20
|
||||
#define SER_MSR SERIAL_PORT + 6
|
||||
#endif
|
||||
|
||||
#ifdef SCREEN_DEBUGGING
|
||||
#define CRTC_COMMAND 0x3d4
|
||||
#define CRTC_DATA 0x3d5
|
||||
#define CRTC_CURLO 0x0f
|
||||
#define CRTC_CURHI 0x0e
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#define CHAR_ATTRIBUTE 0x17 /* grey on blue */
|
||||
|
||||
|
||||
/* VARIABLES ****************************************************************/
|
||||
|
@ -23,9 +83,9 @@ static ULONG SizeY = 50;
|
|||
static BOOLEAN DisplayInitialized = FALSE;
|
||||
static BOOLEAN HalOwnsDisplay = TRUE;
|
||||
|
||||
static BYTE *VideoBuffer = NULL;
|
||||
static WORD *VideoBuffer = NULL;
|
||||
|
||||
static RESET_DISPLAY_ROUTINE ResetRoutine = NULL;
|
||||
static PHAL_RESET_DISPLAY_PARAMETERS HalResetDisplayParameters = NULL;
|
||||
|
||||
|
||||
/* STATIC FUNCTIONS *********************************************************/
|
||||
|
@ -37,23 +97,97 @@ HalClearDisplay (VOID)
|
|||
ULONG i;
|
||||
|
||||
for (i = 0; i < SizeX * SizeY; i++, ptr++)
|
||||
*ptr = 0x1720;
|
||||
*ptr = ((CHAR_ATTRIBUTE << 8) + ' ');
|
||||
|
||||
CursorX = 0;
|
||||
CursorY = 0;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
HalScrollDisplay (VOID)
|
||||
{
|
||||
WORD *ptr;
|
||||
int i;
|
||||
|
||||
ptr = VideoBuffer + SizeX;
|
||||
RtlMoveMemory (VideoBuffer,
|
||||
ptr,
|
||||
SizeX * (SizeY - 1) * 2);
|
||||
|
||||
ptr = VideoBuffer + (SizeX * (SizeY - 1));
|
||||
for (i = 0; i < SizeX; i++, ptr++)
|
||||
{
|
||||
*ptr = (CHAR_ATTRIBUTE << 8) + ' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
HalPutCharacter (CHAR Character)
|
||||
{
|
||||
WORD *ptr;
|
||||
|
||||
ptr = VideoBuffer + ((CursorY * SizeX) + CursorX);
|
||||
*ptr = (CHAR_ATTRIBUTE << 8) + Character;
|
||||
}
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS ********************************************************/
|
||||
|
||||
VOID
|
||||
HalInitializeDisplay (VOID)
|
||||
HalInitializeDisplay (boot_param *bp)
|
||||
/*
|
||||
* FUNCTION: Initalize the display
|
||||
* ARGUMENTS:
|
||||
* InitParameters = Parameters setup by the boot loader
|
||||
*/
|
||||
{
|
||||
if (DisplayInitialized == FALSE)
|
||||
{
|
||||
DisplayInitialized = TRUE;
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
/* turn on DTR and RTS */
|
||||
outb_p(SER_MCR, SR_MCR_DTR | SR_MCR_RTS);
|
||||
/* set baud rate, line control */
|
||||
outb_p(SER_LCR, SERIAL_LINE_CONTROL | SR_LCR_DLAB);
|
||||
outb_p(SER_DLL, (115200 / SERIAL_BAUD_RATE) & 0xff);
|
||||
outb_p(SER_DLM, ((115200 / SERIAL_BAUD_RATE) >> 8) & 0xff);
|
||||
outb_p(SER_LCR, SERIAL_LINE_CONTROL);
|
||||
#endif
|
||||
|
||||
VideoBuffer = (BYTE *)(0xd0000000 + 0xb8000);
|
||||
VideoBuffer = (WORD *)(0xd0000000 + 0xb8000);
|
||||
// VideoBuffer = HalMapPhysicalMemory (0xb8000, 2);
|
||||
|
||||
/* Set cursor position */
|
||||
CursorX = bp->cursorx;
|
||||
CursorY = bp->cursory;
|
||||
SizeX = 80;
|
||||
SizeY = 50;
|
||||
|
||||
HalClearDisplay ();
|
||||
|
||||
DisplayInitialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
HalResetDisplay (VOID)
|
||||
/*
|
||||
* FUNCTION: Reset the display
|
||||
* ARGUMENTS:
|
||||
* None
|
||||
*/
|
||||
{
|
||||
if (HalResetDisplayParameters == NULL)
|
||||
return;
|
||||
|
||||
if (HalOwnsDisplay == TRUE)
|
||||
return;
|
||||
|
||||
if (HalResetDisplayParameters(SizeX, SizeY) == TRUE)
|
||||
{
|
||||
HalOwnsDisplay = TRUE;
|
||||
HalClearDisplay ();
|
||||
}
|
||||
}
|
||||
|
@ -63,25 +197,107 @@ HalInitializeDisplay (VOID)
|
|||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
HalAcquireDisplayOwnership (RESET_DISPLAY_ROUTINE ResetDisplay)
|
||||
HalAcquireDisplayOwnership (
|
||||
IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters
|
||||
)
|
||||
/*
|
||||
* FUNCTION:
|
||||
* ARGUMENTS:
|
||||
* ResetDisplayParameters = Pointer to a driver specific
|
||||
* reset routine.
|
||||
*/
|
||||
{
|
||||
HalOwnsDisplay = FALSE;
|
||||
ResetRoutine = ResetDisplay;
|
||||
HalResetDisplayParameters = ResetDisplayParameters;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
HalDisplayString (VOID)
|
||||
HalDisplayString(PCH String)
|
||||
/*
|
||||
* FUNCTION: Switches the screen to HAL console mode (BSOD) if not there
|
||||
* already and displays a string
|
||||
* ARGUMENT:
|
||||
* string = ASCII string to display
|
||||
* NOTE: Use with care because there is no support for returning from BSOD
|
||||
* mode
|
||||
*/
|
||||
{
|
||||
PCH pch;
|
||||
#ifdef SCREEN_DEBUGGING
|
||||
int offset;
|
||||
#endif
|
||||
|
||||
pch = String;
|
||||
|
||||
if (HalOwnsDisplay == FALSE)
|
||||
{
|
||||
HalResetDisplay ();
|
||||
}
|
||||
|
||||
#ifdef BOCHS_DEBUGGING
|
||||
outb_p(BOCHS_LOGGER_PORT,c);
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
while ((inb_p(SER_LSR) & SR_LSR_TBE) == 0)
|
||||
;
|
||||
|
||||
outb_p(SER_THR, c);
|
||||
#endif
|
||||
|
||||
#ifdef SCREEN_DEBUGGING
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
offset = inb_p(CRTC_DATA)<<8;
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
offset += inb_p(CRTC_DATA);
|
||||
|
||||
CursorY = offset / SizeX;
|
||||
CursorX = offset % SizeX;
|
||||
#endif
|
||||
|
||||
while (*pch != 0)
|
||||
{
|
||||
if (*pch == '\n')
|
||||
{
|
||||
CursorY++;
|
||||
CursorX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
HalPutCharacter (*pch);
|
||||
CursorX++;
|
||||
|
||||
if (CursorX >= SizeX)
|
||||
{
|
||||
CursorY++;
|
||||
CursorX = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (CursorY >= SizeY)
|
||||
{
|
||||
HalScrollDisplay ();
|
||||
CursorY = SizeY - 1;
|
||||
}
|
||||
|
||||
pch++;
|
||||
}
|
||||
|
||||
#ifdef SCREEN_DEBUGGING
|
||||
offset = (CursorY * SizeX) + CursorX;
|
||||
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
outb_p(CRTC_DATA, offset);
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
offset >>= 8;
|
||||
outb_p(CRTC_DATA, offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
HalQueryDisplayParameters (PULONG DispSizeX,
|
||||
PULONG DispSizeY,
|
||||
PULONG CursorPosX,
|
||||
|
@ -99,7 +315,6 @@ HalQueryDisplayParameters (PULONG DispSizeX,
|
|||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
HalSetDisplayParameters (ULONG CursorPosX,
|
||||
ULONG CursorPosY)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
/* $Id: halinit.c,v 1.6 1999/10/15 15:18:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/hal/x86/halinit.c
|
||||
|
@ -11,16 +12,23 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/hal.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID HalInit(boot_param* bp)
|
||||
BOOLEAN
|
||||
HalInitSystem (ULONG Phase, boot_param *bp)
|
||||
{
|
||||
if (Phase == 0)
|
||||
{
|
||||
HalInitializeDisplay (bp);
|
||||
}
|
||||
else
|
||||
{
|
||||
KeInitExceptions();
|
||||
KeInitIRQ();
|
||||
|
@ -38,11 +46,13 @@ VOID HalInit(boot_param* bp)
|
|||
#if 0
|
||||
if (HalPciProbe())
|
||||
{
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
HalIsaProbe();
|
||||
#endif
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,327 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/hal/x86/printk.c
|
||||
* PURPOSE: Writing to the console
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* ??/??/??: Created
|
||||
* 05/06/98: Implemented BSOD
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/mmhal.h>
|
||||
#include <internal/halio.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
//#define BOCHS_DEBUGGING 1
|
||||
//#define SERIAL_DEBUGGING
|
||||
#define SERIAL_PORT 0x03f8
|
||||
#define SERIAL_BAUD_RATE 19200
|
||||
#define SERIAL_LINE_CONTROL (SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO)
|
||||
|
||||
|
||||
#define IDMAP_BASE (0xd0000000)
|
||||
|
||||
/*
|
||||
* Return a linear address which can be used to access the physical memory
|
||||
* starting at x
|
||||
*/
|
||||
extern inline unsigned int physical_to_linear(unsigned int x)
|
||||
{
|
||||
return(x+IDMAP_BASE);
|
||||
}
|
||||
|
||||
extern inline unsigned int linear_to_physical(unsigned int x)
|
||||
{
|
||||
return(x-IDMAP_BASE);
|
||||
}
|
||||
|
||||
|
||||
#ifdef BOCHS_DEBUGGING
|
||||
#define BOCHS_LOGGER_PORT (0x3ed)
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
#define SER_RBR SERIAL_PORT + 0
|
||||
#define SER_THR SERIAL_PORT + 0
|
||||
#define SER_DLL SERIAL_PORT + 0
|
||||
#define SER_IER SERIAL_PORT + 1
|
||||
#define SER_DLM SERIAL_PORT + 1
|
||||
#define SER_IIR SERIAL_PORT + 2
|
||||
#define SER_LCR SERIAL_PORT + 3
|
||||
#define SR_LCR_CS5 0x00
|
||||
#define SR_LCR_CS6 0x01
|
||||
#define SR_LCR_CS7 0x02
|
||||
#define SR_LCR_CS8 0x03
|
||||
#define SR_LCR_ST1 0x00
|
||||
#define SR_LCR_ST2 0x04
|
||||
#define SR_LCR_PNO 0x00
|
||||
#define SR_LCR_POD 0x08
|
||||
#define SR_LCR_PEV 0x18
|
||||
#define SR_LCR_PMK 0x28
|
||||
#define SR_LCR_PSP 0x38
|
||||
#define SR_LCR_BRK 0x40
|
||||
#define SR_LCR_DLAB 0x80
|
||||
#define SER_MCR SERIAL_PORT + 4
|
||||
#define SR_MCR_DTR 0x01
|
||||
#define SR_MCR_RTS 0x02
|
||||
#define SER_LSR SERIAL_PORT + 5
|
||||
#define SR_LSR_TBE 0x20
|
||||
#define SER_MSR SERIAL_PORT + 6
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PURPOSE: Current cursor position
|
||||
*/
|
||||
static unsigned int cursorx=0, cursory=0;
|
||||
static unsigned int lines_seen = 0;
|
||||
static unsigned char CharAttribute = 0x17;
|
||||
|
||||
//#define NR_ROWS 25
|
||||
#define NR_ROWS 50
|
||||
#define NR_COLUMNS 80
|
||||
#define VIDMEM_BASE 0xb8000
|
||||
|
||||
/*
|
||||
* PURPOSE: Points to the base of text mode video memory
|
||||
*/
|
||||
static char* vidmem = (char *)(VIDMEM_BASE + IDMAP_BASE);
|
||||
|
||||
#define CRTC_COMMAND 0x3d4
|
||||
#define CRTC_DATA 0x3d5
|
||||
#define CRTC_CURLO 0x0f
|
||||
#define CRTC_CURHI 0x0e
|
||||
|
||||
/*
|
||||
* PURPOSE: This flag is set to true if the system is in HAL managed
|
||||
* console mode. This is initially true then once the graphics drivers
|
||||
* initialize, it is turned off, HAL console mode is reentered if a fatal
|
||||
* error occurs or on system shutdown
|
||||
*/
|
||||
static unsigned int in_hal_console = 1;
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
|
||||
void __putchar(char c);
|
||||
|
||||
|
||||
void HalSwitchToBlueScreen(void)
|
||||
/*
|
||||
* FUNCTION: Switches the monitor to text mode and writes a blue background
|
||||
* NOTE: This function is entirely self contained and can be used from any
|
||||
* graphics mode.
|
||||
*/
|
||||
{
|
||||
/*
|
||||
* Sanity check
|
||||
*/
|
||||
if (in_hal_console)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the cursor position
|
||||
*/
|
||||
cursorx=0;
|
||||
cursory=0;
|
||||
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
outb_p(CRTC_DATA, 0);
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
outb_p(CRTC_DATA, 0);
|
||||
|
||||
/*
|
||||
* This code section is taken from the sample routines by
|
||||
* Jeff Morgan (kinfira@hotmail.com)
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtDisplayString(IN PUNICODE_STRING DisplayString)
|
||||
{
|
||||
// DbgPrint("NtDisplayString(%w)\n",DisplayString->Buffer);
|
||||
DbgPrint("%w",DisplayString->Buffer);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
void HalDisplayString(char* string)
|
||||
/*
|
||||
* FUNCTION: Switches the screen to HAL console mode (BSOD) if not there
|
||||
* already and displays a string
|
||||
* ARGUMENT:
|
||||
* string = ASCII string to display
|
||||
* NOTE: Use with care because there is no support for returning from BSOD
|
||||
* mode
|
||||
*/
|
||||
{
|
||||
char* str=string;
|
||||
|
||||
if (!in_hal_console)
|
||||
{
|
||||
HalSwitchToBlueScreen();
|
||||
}
|
||||
|
||||
while ((*str)!=0)
|
||||
{
|
||||
__putchar(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
void __putchar(char c)
|
||||
/*
|
||||
* FUNCTION: Writes a character to the console and updates the cursor position
|
||||
* ARGUMENTS:
|
||||
* c = the character to write
|
||||
* NOTE: This function handles newlines as well
|
||||
*/
|
||||
{
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
#ifdef BOCHS_DEBUGGING
|
||||
outb_p(BOCHS_LOGGER_PORT,c);
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
while ((inb_p(SER_LSR) & SR_LSR_TBE) == 0)
|
||||
;
|
||||
outb_p(SER_THR, c);
|
||||
#endif
|
||||
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
offset = inb_p(CRTC_DATA)<<8;
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
offset += inb_p(CRTC_DATA);
|
||||
|
||||
cursory = offset / NR_COLUMNS;
|
||||
cursorx = offset % NR_COLUMNS;
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case '\n':
|
||||
cursory++;
|
||||
cursorx = 0;
|
||||
lines_seen++;
|
||||
break;
|
||||
|
||||
default:
|
||||
vidmem[(cursorx * 2) + (cursory * 80 * 2)] = c;
|
||||
vidmem[(cursorx * 2) + (cursory * 80 * 2) + 1] = CharAttribute;
|
||||
cursorx++;
|
||||
if (cursorx >= NR_COLUMNS)
|
||||
{
|
||||
cursory++;
|
||||
lines_seen++;
|
||||
cursorx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (cursory >= NR_ROWS)
|
||||
{
|
||||
unsigned short *LinePtr;
|
||||
|
||||
memcpy(vidmem,
|
||||
&vidmem[NR_COLUMNS * 2],
|
||||
NR_COLUMNS * (NR_ROWS - 1) * 2);
|
||||
LinePtr = (unsigned short *) &vidmem[NR_COLUMNS * (NR_ROWS - 1) * 2];
|
||||
for (i = 0; i < NR_COLUMNS; i++)
|
||||
{
|
||||
LinePtr[i] = CharAttribute << 8;
|
||||
}
|
||||
cursory = NR_ROWS - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the cursor position
|
||||
*/
|
||||
|
||||
offset = (cursory * NR_COLUMNS) + cursorx;
|
||||
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
outb_p(CRTC_DATA, offset);
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
offset >>= 8;
|
||||
outb_p(CRTC_DATA, offset);
|
||||
}
|
||||
|
||||
|
||||
ULONG DbgPrint(PCH Format, ...)
|
||||
{
|
||||
char buffer[256];
|
||||
va_list ap;
|
||||
unsigned int eflags;
|
||||
|
||||
/*
|
||||
* Because this is used by alomost every subsystem including irqs it
|
||||
* must be atomic. The following code sequence disables interrupts after
|
||||
* saving the previous state of the interrupt flag
|
||||
*/
|
||||
__asm__("pushf\n\tpop %0\n\tcli\n\t"
|
||||
: "=m" (eflags)
|
||||
: /* */);
|
||||
|
||||
/*
|
||||
* Process the format string into a fixed length buffer using the
|
||||
* standard C RTL function
|
||||
*/
|
||||
va_start(ap,Format);
|
||||
vsprintf(buffer,Format,ap);
|
||||
va_end(ap);
|
||||
|
||||
HalDisplayString (buffer);
|
||||
|
||||
/*
|
||||
* Restore the interrupt flag
|
||||
*/
|
||||
__asm__("push %0\n\tpopf\n\t"
|
||||
:
|
||||
: "m" (eflags));
|
||||
return(strlen(buffer));
|
||||
}
|
||||
|
||||
void HalInitConsole(boot_param* bp)
|
||||
/*
|
||||
* FUNCTION: Initalize the console
|
||||
* ARGUMENTS:
|
||||
* bp = Parameters setup by the boot loader
|
||||
*/
|
||||
{
|
||||
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
/* turn on DTR and RTS */
|
||||
outb_p(SER_MCR, SR_MCR_DTR | SR_MCR_RTS);
|
||||
/* set baud rate, line control */
|
||||
outb_p(SER_LCR, SERIAL_LINE_CONTROL | SR_LCR_DLAB);
|
||||
outb_p(SER_DLL, (115200 / SERIAL_BAUD_RATE) & 0xff);
|
||||
outb_p(SER_DLM, ((115200 / SERIAL_BAUD_RATE) >> 8) & 0xff);
|
||||
outb_p(SER_LCR, SERIAL_LINE_CONTROL);
|
||||
#endif
|
||||
|
||||
/* Set cursor position */
|
||||
|
||||
cursorx=bp->cursorx;
|
||||
cursory=bp->cursory;
|
||||
|
||||
#if 0
|
||||
offset = (cursory * NR_COLUMNS) + cursorx;
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
outb_p(CRTC_DATA, offset);
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
offset >>= 8;
|
||||
outb_p(CRTC_DATA, offset);
|
||||
#endif
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: reboot.c,v 1.1 1999/10/11 20:50:33 ekohl Exp $
|
||||
/* $Id: reboot.c,v 1.2 1999/10/15 15:18:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -61,7 +61,7 @@ HalReturnToFirmware (ULONG Action)
|
|||
}
|
||||
else if (Action == FIRMWARE_REBOOT)
|
||||
{
|
||||
// HalVideoReboot();
|
||||
HalResetDisplay ();
|
||||
HalReboot ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
HAL_OBJECTS = hal/x86/head.o hal/x86/irq.o hal/x86/exp.o hal/x86/isa.o \
|
||||
hal/x86/pci.o hal/x86/irqhand.o hal/x86/page.o hal/x86/halinit.o \
|
||||
hal/x86/irql.o hal/x86/bios32.o hal/x86/thread.o hal/x86/spinlock.o \
|
||||
hal/x86/printk.o hal/x86/mp.o hal/x86/dma.o hal/x86/bus.o hal/x86/mbr.o \
|
||||
hal/x86/mp.o hal/x86/dma.o hal/x86/bus.o hal/x86/mbr.o \
|
||||
hal/x86/sysinfo.o hal/x86/time.o hal/x86/usercall.o hal/x86/beep.o \
|
||||
hal/x86/display.o hal/x86/reboot.o
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: main.c,v 1.24 1999/10/14 16:53:30 ekohl Exp $
|
||||
/* $Id: main.c,v 1.25 1999/10/15 15:21:03 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -144,11 +144,11 @@ asmlinkage void _main(boot_param* _bp)
|
|||
memcpy(&bp,_bp,sizeof(boot_param));
|
||||
|
||||
/*
|
||||
* Initalize the console (before printing anything)
|
||||
* Initalize the hal (Phase 0)
|
||||
*/
|
||||
HalInitConsole(&bp);
|
||||
HalInitSystem (0, &bp);
|
||||
|
||||
DbgPrint("Starting ReactOS "KERNEL_VERSION" (Build "__DATE__", "__TIME__")\n");
|
||||
HalDisplayString("Starting ReactOS "KERNEL_VERSION" (Build "__DATE__", "__TIME__")\n");
|
||||
|
||||
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
||||
if (start < ((int)&end))
|
||||
|
@ -170,7 +170,7 @@ asmlinkage void _main(boot_param* _bp)
|
|||
/*
|
||||
* Initalize various critical subsystems
|
||||
*/
|
||||
HalInit(&bp);
|
||||
HalInitSystem (1, &bp);
|
||||
MmInitialize(&bp, last_kernel_address);
|
||||
KeInit();
|
||||
ExInit();
|
||||
|
|
|
@ -16,6 +16,22 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtDisplayString(IN PUNICODE_STRING DisplayString)
|
||||
{
|
||||
ANSI_STRING AnsiString;
|
||||
|
||||
RtlUnicodeStringToAnsiString (&AnsiString, DisplayString, TRUE);
|
||||
|
||||
HalDisplayString (AnsiString.Buffer);
|
||||
|
||||
RtlFreeAnsiString (&AnsiString);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtVdmControl(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
|
Loading…
Reference in a new issue