2007-12-06 13:11:21 +00:00
|
|
|
|
/*
|
2007-10-23 08:30:39 +00:00
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
|
* PROJECT: ReactOS kernel
|
2007-12-06 13:11:21 +00:00
|
|
|
|
* FILE: drivers/base/kdcom/kdbg.c
|
2007-10-23 08:30:39 +00:00
|
|
|
|
* PURPOSE: Serial i/o functions for the kernel debugger.
|
2007-12-06 13:11:21 +00:00
|
|
|
|
* PROGRAMMER: Alex Ionescu
|
|
|
|
|
* Herv<EFBFBD> Poussineau
|
2007-10-23 08:30:39 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
|
|
#define NOEXTAPI
|
2010-03-06 18:55:27 +00:00
|
|
|
|
#include <ntifs.h>
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#define NDEBUG
|
|
|
|
|
#include <halfuncs.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <debug.h>
|
|
|
|
|
#include "arc/arc.h"
|
|
|
|
|
#include "windbgkd.h"
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#include <kddll.h>
|
2008-02-12 17:45:58 +00:00
|
|
|
|
#include <ioaccess.h> /* port intrinsics */
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
|
|
|
|
typedef struct _KD_PORT_INFORMATION
|
|
|
|
|
{
|
|
|
|
|
ULONG ComPort;
|
|
|
|
|
ULONG BaudRate;
|
|
|
|
|
ULONG BaseAddress;
|
|
|
|
|
} KD_PORT_INFORMATION, *PKD_PORT_INFORMATION;
|
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
BOOLEAN
|
|
|
|
|
NTAPI
|
|
|
|
|
KdPortInitializeEx(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
IN ULONG Unknown1,
|
|
|
|
|
IN ULONG Unknown2);
|
|
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
|
NTAPI
|
|
|
|
|
KdPortGetByteEx(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
OUT PUCHAR ByteReceived);
|
|
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
|
NTAPI
|
|
|
|
|
KdPortPollByteEx(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
OUT PUCHAR ByteReceived);
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
|
NTAPI
|
|
|
|
|
KdPortPutByteEx(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
IN UCHAR ByteToSend);
|
|
|
|
|
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#define DEFAULT_BAUD_RATE 19200
|
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#ifdef _M_IX86
|
|
|
|
|
const ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
|
|
|
|
|
#elif defined(_M_PPC)
|
2008-01-06 14:52:00 +00:00
|
|
|
|
const ULONG BaseArray[2] = {0, 0x800003f8};
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#elif defined(_M_MIPS)
|
2008-01-06 14:52:00 +00:00
|
|
|
|
const ULONG BaseArray[3] = {0, 0x80006000, 0x80007000};
|
2008-02-08 08:20:06 +00:00
|
|
|
|
#elif defined(_M_ARM)
|
|
|
|
|
const ULONG BaseArray[2] = {0, 0xF1012000};
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#else
|
|
|
|
|
#error Unknown architecture
|
|
|
|
|
#endif
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
|
|
|
|
/* MACROS *******************************************************************/
|
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#define SER_RBR(x) ((PUCHAR)(x)+0)
|
|
|
|
|
#define SER_THR(x) ((PUCHAR)(x)+0)
|
|
|
|
|
#define SER_DLL(x) ((PUCHAR)(x)+0)
|
|
|
|
|
#define SER_IER(x) ((PUCHAR)(x)+1)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#define SR_IER_ERDA 0x01
|
|
|
|
|
#define SR_IER_ETHRE 0x02
|
|
|
|
|
#define SR_IER_ERLSI 0x04
|
|
|
|
|
#define SR_IER_EMS 0x08
|
|
|
|
|
#define SR_IER_ALL 0x0F
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#define SER_DLM(x) ((PUCHAR)(x)+1)
|
|
|
|
|
#define SER_IIR(x) ((PUCHAR)(x)+2)
|
|
|
|
|
#define SER_FCR(x) ((PUCHAR)(x)+2)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#define SR_FCR_ENABLE_FIFO 0x01
|
|
|
|
|
#define SR_FCR_CLEAR_RCVR 0x02
|
|
|
|
|
#define SR_FCR_CLEAR_XMIT 0x04
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#define SER_LCR(x) ((PUCHAR)(x)+3)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#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
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#define SER_MCR(x) ((PUCHAR)(x)+4)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#define SR_MCR_DTR 0x01
|
|
|
|
|
#define SR_MCR_RTS 0x02
|
|
|
|
|
#define SR_MCR_OUT1 0x04
|
|
|
|
|
#define SR_MCR_OUT2 0x08
|
|
|
|
|
#define SR_MCR_LOOP 0x10
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#define SER_LSR(x) ((PUCHAR)(x)+5)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#define SR_LSR_DR 0x01
|
|
|
|
|
#define SR_LSR_TBE 0x20
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#define SER_MSR(x) ((PUCHAR)(x)+6)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#define SR_MSR_CTS 0x10
|
|
|
|
|
#define SR_MSR_DSR 0x20
|
2007-12-06 13:11:21 +00:00
|
|
|
|
#define SER_SCR(x) ((PUCHAR)(x)+7)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* GLOBAL VARIABLES *********************************************************/
|
|
|
|
|
|
|
|
|
|
/* STATIC VARIABLES *********************************************************/
|
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
static KD_PORT_INFORMATION DefaultPort = { 0, 0, 0 };
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
|
|
|
|
/* The com port must only be initialized once! */
|
|
|
|
|
static BOOLEAN PortInitialized = FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* STATIC FUNCTIONS *********************************************************/
|
|
|
|
|
|
|
|
|
|
static BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
KdpDoesComPortExist(
|
|
|
|
|
IN ULONG BaseAddress)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
BOOLEAN found;
|
|
|
|
|
UCHAR mcr;
|
|
|
|
|
UCHAR msr;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
found = FALSE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* save Modem Control Register (MCR) */
|
|
|
|
|
mcr = READ_PORT_UCHAR(SER_MCR(BaseAddress));
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* enable loop mode (set Bit 4 of the MCR) */
|
|
|
|
|
WRITE_PORT_UCHAR(SER_MCR(BaseAddress), SR_MCR_LOOP);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* clear all modem output bits */
|
|
|
|
|
WRITE_PORT_UCHAR(SER_MCR(BaseAddress), SR_MCR_LOOP);
|
|
|
|
|
|
|
|
|
|
/* read the Modem Status Register */
|
|
|
|
|
msr = READ_PORT_UCHAR(SER_MSR(BaseAddress));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* the upper nibble of the MSR (modem output bits) must be
|
|
|
|
|
* equal to the lower nibble of the MCR (modem input bits)
|
|
|
|
|
*/
|
|
|
|
|
if ((msr & 0xF0) == 0x00)
|
|
|
|
|
{
|
|
|
|
|
/* set all modem output bits */
|
|
|
|
|
WRITE_PORT_UCHAR(SER_MCR(BaseAddress), SR_MCR_DTR | SR_MCR_RTS | SR_MCR_OUT1 | SR_MCR_OUT2 | SR_MCR_LOOP);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
|
|
|
|
/* read the Modem Status Register */
|
2007-12-06 13:11:21 +00:00
|
|
|
|
msr = READ_PORT_UCHAR(SER_MSR(BaseAddress));
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* the upper nibble of the MSR (modem output bits) must be
|
|
|
|
|
* equal to the lower nibble of the MCR (modem input bits)
|
|
|
|
|
*/
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if ((msr & 0xF0) == 0xF0)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/*
|
|
|
|
|
* setup a resonable state for the port:
|
|
|
|
|
* enable fifo and clear recieve/transmit buffers
|
|
|
|
|
*/
|
|
|
|
|
WRITE_PORT_UCHAR(SER_FCR(BaseAddress),
|
|
|
|
|
(SR_FCR_ENABLE_FIFO | SR_FCR_CLEAR_RCVR | SR_FCR_CLEAR_XMIT));
|
|
|
|
|
WRITE_PORT_UCHAR(SER_FCR(BaseAddress), 0);
|
|
|
|
|
READ_PORT_UCHAR(SER_RBR(BaseAddress));
|
|
|
|
|
WRITE_PORT_UCHAR(SER_IER(BaseAddress), 0);
|
|
|
|
|
found = TRUE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
2007-12-06 13:11:21 +00:00
|
|
|
|
}
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* restore MCR */
|
|
|
|
|
WRITE_PORT_UCHAR(SER_MCR(BaseAddress), mcr);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return found;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortInitialize */
|
|
|
|
|
BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortInitialize(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
IN ULONG Unknown1,
|
|
|
|
|
IN ULONG Unknown2)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
SIZE_T i;
|
|
|
|
|
CHAR buffer[80];
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if (!PortInitialized)
|
|
|
|
|
{
|
|
|
|
|
DefaultPort.BaudRate = PortInformation->BaudRate;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if (PortInformation->ComPort == 0)
|
|
|
|
|
{
|
|
|
|
|
for (i = sizeof(BaseArray) / sizeof(BaseArray[0]) - 1; i > 0; i--)
|
|
|
|
|
{
|
|
|
|
|
if (KdpDoesComPortExist(BaseArray[i]))
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
DefaultPort.BaseAddress = BaseArray[i];
|
|
|
|
|
DefaultPort.ComPort = i;
|
|
|
|
|
PortInformation->BaseAddress = DefaultPort.BaseAddress;
|
|
|
|
|
PortInformation->ComPort = DefaultPort.ComPort;
|
|
|
|
|
break;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
2007-12-06 13:11:21 +00:00
|
|
|
|
}
|
|
|
|
|
if (i == 0)
|
|
|
|
|
{
|
|
|
|
|
sprintf(buffer,
|
|
|
|
|
"\nKernel Debugger: No COM port found!\n\n");
|
|
|
|
|
HalDisplayString(buffer);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
PortInitialized = TRUE;
|
|
|
|
|
}
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* initialize port */
|
|
|
|
|
if (!KdPortInitializeEx(&DefaultPort, Unknown1, Unknown2))
|
|
|
|
|
return FALSE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* set global info */
|
2009-01-19 23:22:22 +00:00
|
|
|
|
KdComPortInUse = (PUCHAR)DefaultPort.BaseAddress;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return TRUE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortInitializeEx */
|
|
|
|
|
BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortInitializeEx(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
IN ULONG Unknown1,
|
|
|
|
|
IN ULONG Unknown2)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
ULONG ComPortBase;
|
|
|
|
|
CHAR buffer[80];
|
|
|
|
|
ULONG divisor;
|
|
|
|
|
UCHAR lcr;
|
|
|
|
|
|
2008-02-12 22:50:54 +00:00
|
|
|
|
#ifdef _ARM_
|
|
|
|
|
UNIMPLEMENTED;
|
2008-02-13 04:58:43 +00:00
|
|
|
|
return FALSE;
|
2008-02-12 22:50:54 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if (PortInformation->BaudRate == 0)
|
|
|
|
|
PortInformation->BaudRate = DEFAULT_BAUD_RATE;
|
|
|
|
|
|
|
|
|
|
if (PortInformation->ComPort == 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!KdpDoesComPortExist(BaseArray[PortInformation->ComPort]))
|
|
|
|
|
{
|
|
|
|
|
sprintf(buffer,
|
|
|
|
|
"\nKernel Debugger: Serial port not found!\n\n");
|
|
|
|
|
HalDisplayString(buffer);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ComPortBase = BaseArray[PortInformation->ComPort];
|
|
|
|
|
PortInformation->BaseAddress = ComPortBase;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#ifndef NDEBUG
|
2007-12-06 13:11:21 +00:00
|
|
|
|
sprintf(buffer,
|
|
|
|
|
"\nSerial port COM%ld found at 0x%lx\n",
|
|
|
|
|
PortInformation->ComPort,
|
2008-07-03 08:16:34 +00:00
|
|
|
|
ComPortBase);
|
2007-12-06 13:11:21 +00:00
|
|
|
|
HalDisplayString(buffer);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* set baud rate and data format (8N1) */
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* turn on DTR and RTS */
|
|
|
|
|
WRITE_PORT_UCHAR(SER_MCR(ComPortBase), SR_MCR_DTR | SR_MCR_RTS);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* set DLAB */
|
|
|
|
|
lcr = READ_PORT_UCHAR(SER_LCR(ComPortBase)) | SR_LCR_DLAB;
|
|
|
|
|
WRITE_PORT_UCHAR(SER_LCR(ComPortBase), lcr);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* set baud rate */
|
|
|
|
|
divisor = 115200 / PortInformation->BaudRate;
|
|
|
|
|
WRITE_PORT_UCHAR(SER_DLL(ComPortBase), (UCHAR)(divisor & 0xff));
|
|
|
|
|
WRITE_PORT_UCHAR(SER_DLM(ComPortBase), (UCHAR)((divisor >> 8) & 0xff));
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* reset DLAB and set 8N1 format */
|
|
|
|
|
WRITE_PORT_UCHAR(SER_LCR(ComPortBase),
|
|
|
|
|
SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* read junk out of the RBR */
|
|
|
|
|
lcr = READ_PORT_UCHAR(SER_RBR(ComPortBase));
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2007-12-06 13:11:21 +00:00
|
|
|
|
/* print message to blue screen */
|
|
|
|
|
sprintf(buffer,
|
|
|
|
|
"\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n",
|
|
|
|
|
PortInformation->ComPort,
|
|
|
|
|
ComPortBase,
|
|
|
|
|
PortInformation->BaudRate);
|
|
|
|
|
|
|
|
|
|
HalDisplayString(buffer);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return TRUE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortGetByte */
|
|
|
|
|
BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortGetByte(
|
|
|
|
|
OUT PUCHAR ByteReceived)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if (!PortInitialized)
|
|
|
|
|
return FALSE;
|
|
|
|
|
return KdPortGetByteEx(&DefaultPort, ByteReceived);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortGetByteEx */
|
|
|
|
|
BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortGetByteEx(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
OUT PUCHAR ByteReceived)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if ((READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_DR))
|
|
|
|
|
{
|
|
|
|
|
*ByteReceived = READ_PORT_UCHAR(SER_RBR(ComPortBase));
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return FALSE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortPollByte */
|
|
|
|
|
BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortPollByte(
|
|
|
|
|
OUT PUCHAR ByteReceived)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if (!PortInitialized)
|
|
|
|
|
return FALSE;
|
|
|
|
|
return KdPortPollByteEx(&DefaultPort, ByteReceived);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortPollByteEx */
|
|
|
|
|
BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortPollByteEx(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
OUT PUCHAR ByteReceived)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
while ((READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_DR) == 0)
|
|
|
|
|
;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
*ByteReceived = READ_PORT_UCHAR(SER_RBR(ComPortBase));
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return TRUE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortPutByte */
|
|
|
|
|
VOID
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortPutByte(
|
|
|
|
|
IN UCHAR ByteToSend)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if (!PortInitialized)
|
|
|
|
|
return;
|
|
|
|
|
KdPortPutByteEx(&DefaultPort, ByteToSend);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortPutByteEx */
|
|
|
|
|
VOID
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortPutByteEx(
|
|
|
|
|
IN PKD_PORT_INFORMATION PortInformation,
|
|
|
|
|
IN UCHAR ByteToSend)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
PUCHAR ComPortBase = (PUCHAR)PortInformation->BaseAddress;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
while ((READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_TBE) == 0)
|
|
|
|
|
;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
WRITE_PORT_UCHAR(SER_THR(ComPortBase), ByteToSend);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortRestore */
|
|
|
|
|
VOID
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortRestore(VOID)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
UNIMPLEMENTED;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortSave */
|
|
|
|
|
VOID
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortSave(VOID)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
UNIMPLEMENTED;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortDisableInterrupts */
|
|
|
|
|
BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortDisableInterrupts(VOID)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
UCHAR ch;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if (!PortInitialized)
|
|
|
|
|
return FALSE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
ch = READ_PORT_UCHAR(SER_MCR(DefaultPort.BaseAddress));
|
|
|
|
|
ch &= (~(SR_MCR_OUT1 | SR_MCR_OUT2));
|
|
|
|
|
WRITE_PORT_UCHAR(SER_MCR(DefaultPort.BaseAddress), ch);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
ch = READ_PORT_UCHAR(SER_IER(DefaultPort.BaseAddress));
|
|
|
|
|
ch &= (~SR_IER_ALL);
|
|
|
|
|
WRITE_PORT_UCHAR(SER_IER(DefaultPort.BaseAddress), ch);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return TRUE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* HAL.KdPortEnableInterrupts */
|
|
|
|
|
BOOLEAN
|
2007-12-06 13:11:21 +00:00
|
|
|
|
NTAPI
|
|
|
|
|
KdPortEnableInterrupts(VOID)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
UCHAR ch;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
if (PortInitialized == FALSE)
|
|
|
|
|
return FALSE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
ch = READ_PORT_UCHAR(SER_IER(DefaultPort.BaseAddress));
|
|
|
|
|
ch &= (~SR_IER_ALL);
|
|
|
|
|
ch |= SR_IER_ERDA;
|
|
|
|
|
WRITE_PORT_UCHAR(SER_IER(DefaultPort.BaseAddress), ch);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
ch = READ_PORT_UCHAR(SER_MCR(DefaultPort.BaseAddress));
|
|
|
|
|
ch &= (~SR_MCR_LOOP);
|
|
|
|
|
ch |= (SR_MCR_OUT1 | SR_MCR_OUT2);
|
|
|
|
|
WRITE_PORT_UCHAR(SER_MCR(DefaultPort.BaseAddress), ch);
|
2007-10-23 08:30:39 +00:00
|
|
|
|
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return TRUE;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @unimplemented
|
|
|
|
|
*/
|
|
|
|
|
NTSTATUS
|
|
|
|
|
NTAPI
|
2007-12-06 13:11:21 +00:00
|
|
|
|
KdDebuggerInitialize0(
|
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @unimplemented
|
|
|
|
|
*/
|
|
|
|
|
NTSTATUS
|
|
|
|
|
NTAPI
|
2007-12-06 13:11:21 +00:00
|
|
|
|
KdDebuggerInitialize1(
|
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @implemented
|
|
|
|
|
*/
|
|
|
|
|
NTSTATUS
|
|
|
|
|
NTAPI
|
2007-12-06 13:11:21 +00:00
|
|
|
|
KdSave(
|
|
|
|
|
IN BOOLEAN SleepTransition)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
|
|
|
|
/* Nothing to do on COM ports */
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @implemented
|
|
|
|
|
*/
|
|
|
|
|
NTSTATUS
|
|
|
|
|
NTAPI
|
2007-12-06 13:11:21 +00:00
|
|
|
|
KdRestore(
|
|
|
|
|
IN BOOLEAN SleepTransition)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
|
|
|
|
/* Nothing to do on COM ports */
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @unimplemented
|
|
|
|
|
*/
|
|
|
|
|
VOID
|
|
|
|
|
NTAPI
|
2007-12-06 13:11:21 +00:00
|
|
|
|
KdSendPacket(
|
|
|
|
|
IN ULONG PacketType,
|
|
|
|
|
IN PSTRING MessageHeader,
|
|
|
|
|
IN PSTRING MessageData,
|
|
|
|
|
IN OUT PKD_CONTEXT Context)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
UNIMPLEMENTED;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @unimplemented
|
|
|
|
|
*/
|
2007-12-06 13:11:21 +00:00
|
|
|
|
KDSTATUS
|
2007-10-23 08:30:39 +00:00
|
|
|
|
NTAPI
|
2007-12-06 13:11:21 +00:00
|
|
|
|
KdReceivePacket(
|
|
|
|
|
IN ULONG PacketType,
|
|
|
|
|
OUT PSTRING MessageHeader,
|
|
|
|
|
OUT PSTRING MessageData,
|
|
|
|
|
OUT PULONG DataLength,
|
|
|
|
|
IN OUT PKD_CONTEXT Context)
|
2007-10-23 08:30:39 +00:00
|
|
|
|
{
|
2007-12-06 13:11:21 +00:00
|
|
|
|
UNIMPLEMENTED;
|
2007-10-23 08:30:39 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* EOF */
|