mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Porting pice. Intermediate checkin.
svn path=/trunk/; revision=2502
This commit is contained in:
parent
fd4d47ccfc
commit
2c1c5c45b1
19 changed files with 696 additions and 821 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
//#include <ddk/winnt.h>
|
//#include <ddk/winnt.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <ddk/kefuncs.h>
|
||||||
|
|
||||||
//#include <winnt.h>
|
//#include <winnt.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
|
@ -15,7 +15,7 @@ Environment:
|
||||||
LINUX 2.2.X
|
LINUX 2.2.X
|
||||||
Kernel mode only
|
Kernel mode only
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
Klaus P. Gerlicher
|
Klaus P. Gerlicher
|
||||||
|
|
||||||
|
@ -34,8 +34,6 @@ Copyright notice:
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
////
|
////
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include <asm/delay.h>
|
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
@ -47,31 +45,31 @@ ULONG OldDblFltHandler = 0;
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
////
|
////
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// HandleDoubleFault()
|
// HandleDoubleFault()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void HandleDoubleFault(FRAME* ptr)
|
void HandleDoubleFault(FRAME* ptr)
|
||||||
{
|
{
|
||||||
DPRINT((0,"HandleDoubleFault(): ptr = %x\n",ptr));
|
DPRINT((0,"HandleDoubleFault(): ptr = %x\n",ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// NewDblFltHandler()
|
// NewDblFltHandler()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
__asm__ ("
|
__asm__ ("
|
||||||
NewDblFltHandler:
|
NewDblFltHandler:
|
||||||
pushfl
|
pushfl
|
||||||
cli
|
cli
|
||||||
cld
|
cld
|
||||||
pushal
|
pushal
|
||||||
pushl %ds
|
pushl %ds
|
||||||
|
|
||||||
// setup default data selectors
|
// setup default data selectors
|
||||||
movw %ss,%ax
|
movw %ss,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
|
|
||||||
// get frame ptr
|
// get frame ptr
|
||||||
lea 40(%esp),%eax
|
lea 40(%esp),%eax
|
||||||
|
@ -79,7 +77,7 @@ NewDblFltHandler:
|
||||||
call HandleDoubleFault
|
call HandleDoubleFault
|
||||||
addl $4,%esp
|
addl $4,%esp
|
||||||
|
|
||||||
popl %ds
|
popl %ds
|
||||||
popal
|
popal
|
||||||
popfl
|
popfl
|
||||||
// remove error code from stack and replace with reason code
|
// remove error code from stack and replace with reason code
|
||||||
|
@ -88,10 +86,10 @@ NewDblFltHandler:
|
||||||
jmp NewInt31Handler");
|
jmp NewInt31Handler");
|
||||||
|
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// InstallDblFltHook()
|
// InstallDblFltHook()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void InstallDblFltHook(void)
|
void InstallDblFltHook(void)
|
||||||
{
|
{
|
||||||
ULONG LocalDblFltHandler;
|
ULONG LocalDblFltHandler;
|
||||||
|
@ -112,10 +110,10 @@ void InstallDblFltHook(void)
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// DeInstallDblFltHook()
|
// DeInstallDblFltHook()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void DeInstallDblFltHook(void)
|
void DeInstallDblFltHook(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
@ -132,4 +130,4 @@ void DeInstallDblFltHook(void)
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -15,7 +15,7 @@ Environment:
|
||||||
LINUX 2.2.X
|
LINUX 2.2.X
|
||||||
Kernel mode only
|
Kernel mode only
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
Klaus P. Gerlicher
|
Klaus P. Gerlicher
|
||||||
|
|
||||||
|
@ -37,9 +37,8 @@ Copyright notice:
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include <asm/io.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "serial_port.h"
|
#include "serial_port.h"
|
||||||
|
|
||||||
#define STANDARD_DEBUG_PREFIX "pICE: "
|
#define STANDARD_DEBUG_PREFIX "pICE: "
|
||||||
|
@ -58,13 +57,13 @@ USHORT usDebugPortBase;
|
||||||
void DebugSendString(LPSTR s);
|
void DebugSendString(LPSTR s);
|
||||||
|
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// Pice_dprintf()
|
// Pice_dprintf()
|
||||||
//
|
//
|
||||||
// internal debug print
|
// internal debug print
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
VOID Pice_dprintf(ULONG DebugLevel, PCHAR DebugMessage, ...)
|
VOID Pice_dprintf(ULONG DebugLevel, PCHAR DebugMessage, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, DebugMessage);
|
va_start(ap, DebugMessage);
|
||||||
|
@ -82,7 +81,7 @@ VOID Pice_dprintf(ULONG DebugLevel, PCHAR DebugMessage, ...)
|
||||||
//************************************************************************
|
//************************************************************************
|
||||||
// SendByte()
|
// SendByte()
|
||||||
//
|
//
|
||||||
// Output a character to the serial port
|
// Output a character to the serial port
|
||||||
//************************************************************************
|
//************************************************************************
|
||||||
BOOLEAN DebugSendByte(UCHAR x)
|
BOOLEAN DebugSendByte(UCHAR x)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +89,7 @@ BOOLEAN DebugSendByte(UCHAR x)
|
||||||
|
|
||||||
timeout = 0x00FFFFL;
|
timeout = 0x00FFFFL;
|
||||||
|
|
||||||
// Wait for transmitter to clear
|
// Wait for transmitter to clear
|
||||||
while ((inportb((USHORT)(usDebugPortBase + LSR)) & XMTRDY) == 0)
|
while ((inportb((USHORT)(usDebugPortBase + LSR)) & XMTRDY) == 0)
|
||||||
if (!(--timeout))
|
if (!(--timeout))
|
||||||
{
|
{
|
||||||
|
@ -129,17 +128,17 @@ void DebugSetSpeed(ULONG baudrate)
|
||||||
divisor = (ULONG) (115200L/baudrate);
|
divisor = (ULONG) (115200L/baudrate);
|
||||||
|
|
||||||
c = inportb((USHORT)(usDebugPortBase + LCR));
|
c = inportb((USHORT)(usDebugPortBase + LCR));
|
||||||
outportb((USHORT)(usDebugPortBase + LCR), (UCHAR)(c | 0x80)); // Set DLAB
|
outportb((USHORT)(usDebugPortBase + LCR), (UCHAR)(c | 0x80)); // Set DLAB
|
||||||
outportb((USHORT)(usDebugPortBase + DLL), (UCHAR)(divisor & 0x00FF));
|
outportb((USHORT)(usDebugPortBase + DLL), (UCHAR)(divisor & 0x00FF));
|
||||||
outportb((USHORT)(usDebugPortBase + DLH), (UCHAR)((divisor >> 8) & 0x00FF));
|
outportb((USHORT)(usDebugPortBase + DLH), (UCHAR)((divisor >> 8) & 0x00FF));
|
||||||
outportb((USHORT)(usDebugPortBase + LCR), c); // Reset DLAB
|
outportb((USHORT)(usDebugPortBase + LCR), c); // Reset DLAB
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///************************************************************************
|
///************************************************************************
|
||||||
// DebugSetOthers()
|
// DebugSetOthers()
|
||||||
//
|
//
|
||||||
// Set other communications parameters
|
// Set other communications parameters
|
||||||
//************************************************************************
|
//************************************************************************
|
||||||
void DebugSetOthers(ULONG Parity, ULONG Bits, ULONG StopBit)
|
void DebugSetOthers(ULONG Parity, ULONG Bits, ULONG StopBit)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +156,7 @@ void DebugSetOthers(ULONG Parity, ULONG Bits, ULONG StopBit)
|
||||||
setting |= Parity;
|
setting |= Parity;
|
||||||
|
|
||||||
c = inportb((USHORT)(usDebugPortBase + LCR));
|
c = inportb((USHORT)(usDebugPortBase + LCR));
|
||||||
outportb((USHORT)(usDebugPortBase + LCR), (UCHAR)(c & ~0x80)); // Reset DLAB
|
outportb((USHORT)(usDebugPortBase + LCR), (UCHAR)(c & ~0x80)); // Reset DLAB
|
||||||
|
|
||||||
// no ints
|
// no ints
|
||||||
outportb((USHORT)(usDebugPortBase + IER), (UCHAR)0);
|
outportb((USHORT)(usDebugPortBase + IER), (UCHAR)0);
|
||||||
|
|
|
@ -14,7 +14,7 @@ Environment:
|
||||||
|
|
||||||
Kernel mode only
|
Kernel mode only
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
Klaus P. Gerlicher
|
Klaus P. Gerlicher
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ Copyright notice:
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
////
|
////
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include <asm/delay.h>
|
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
@ -48,30 +46,30 @@ char tempGP[1024];
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
////
|
////
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// NewGPFaultHandler()
|
// NewGPFaultHandler()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void HandleGPFault(FRAME* ptr)
|
void HandleGPFault(FRAME* ptr)
|
||||||
{
|
{
|
||||||
DPRINT((0,"HandleGPFault(): ptr = %x\n",ptr));
|
DPRINT((0,"HandleGPFault(): ptr = %x\n",ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// NewGPFaultHandler()
|
// NewGPFaultHandler()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
__asm__ ("
|
__asm__ ("
|
||||||
NewGPFaultHandler:
|
NewGPFaultHandler:
|
||||||
pushfl
|
pushfl
|
||||||
cli
|
cli
|
||||||
cld
|
cld
|
||||||
pushal
|
pushal
|
||||||
pushl %ds
|
pushl %ds
|
||||||
|
|
||||||
// setup default data selectors
|
// setup default data selectors
|
||||||
movw %ss,%ax
|
movw %ss,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
|
|
||||||
// get frame ptr
|
// get frame ptr
|
||||||
lea 40(%esp),%eax
|
lea 40(%esp),%eax
|
||||||
|
@ -79,7 +77,7 @@ NewGPFaultHandler:
|
||||||
call HandleGPFault
|
call HandleGPFault
|
||||||
addl $4,%esp
|
addl $4,%esp
|
||||||
|
|
||||||
popl %ds
|
popl %ds
|
||||||
popal
|
popal
|
||||||
popfl
|
popfl
|
||||||
// remove error code from stack and replace with reason code
|
// remove error code from stack and replace with reason code
|
||||||
|
@ -88,10 +86,10 @@ NewGPFaultHandler:
|
||||||
jmp NewInt31Handler");
|
jmp NewInt31Handler");
|
||||||
|
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// InstallGPFaultHook()
|
// InstallGPFaultHook()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void InstallGPFaultHook(void)
|
void InstallGPFaultHook(void)
|
||||||
{
|
{
|
||||||
ULONG LocalGPFaultHandler;
|
ULONG LocalGPFaultHandler;
|
||||||
|
@ -112,10 +110,10 @@ void InstallGPFaultHook(void)
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// DeInstallGPFaultHook()
|
// DeInstallGPFaultHook()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void DeInstallGPFaultHook(void)
|
void DeInstallGPFaultHook(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
@ -132,4 +130,4 @@ void DeInstallGPFaultHook(void)
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -7,7 +7,7 @@ Module Name:
|
||||||
hardware.c
|
hardware.c
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
|
|
||||||
output to console
|
output to console
|
||||||
|
|
||||||
Environment:
|
Environment:
|
||||||
|
@ -22,7 +22,7 @@ Revision History:
|
||||||
|
|
||||||
04-Aug-1998: created
|
04-Aug-1998: created
|
||||||
15-Nov-2000: general cleanup of source files
|
15-Nov-2000: general cleanup of source files
|
||||||
|
|
||||||
Copyright notice:
|
Copyright notice:
|
||||||
|
|
||||||
This file may be distributed under the terms of the GNU Public License.
|
This file may be distributed under the terms of the GNU Public License.
|
||||||
|
@ -35,10 +35,6 @@ Copyright notice:
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
#include <asm/io.h>
|
|
||||||
#include <linux/ctype.h>
|
|
||||||
#include <asm/delay.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// PROTOTYPES
|
// PROTOTYPES
|
||||||
////
|
////
|
||||||
|
@ -210,7 +206,7 @@ BOOLEAN AddToRingBuffer(LPSTR p)
|
||||||
}
|
}
|
||||||
// it's a debug print and the current line is starting with ':'
|
// it's a debug print and the current line is starting with ':'
|
||||||
else if(aBuffers[ulInPos][0]==':' &&
|
else if(aBuffers[ulInPos][0]==':' &&
|
||||||
( (*p=='<' && isdigit(*(p+1)) && *(p+2)=='>') || bIsDebugPrint) )
|
( (*p=='<' && PICE_isdigit(*(p+1)) && *(p+2)=='>') || bIsDebugPrint) )
|
||||||
{
|
{
|
||||||
if(j==1)
|
if(j==1)
|
||||||
{
|
{
|
||||||
|
@ -232,7 +228,7 @@ BOOLEAN AddToRingBuffer(LPSTR p)
|
||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
// it's a debug print
|
// it's a debug print
|
||||||
else if(( (*p=='<' && isdigit(*(p+1)) && *(p+2)=='>') || bIsDebugPrint) )
|
else if(( (*p=='<' && PICE_isdigit(*(p+1)) && *(p+2)=='>') || bIsDebugPrint) )
|
||||||
{
|
{
|
||||||
p += 3;
|
p += 3;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +285,7 @@ BOOLEAN AddToRingBuffer(LPSTR p)
|
||||||
{
|
{
|
||||||
if((UCHAR)p[i]<0x20 && (UCHAR)p[i]>0x7f)
|
if((UCHAR)p[i]<0x20 && (UCHAR)p[i]>0x7f)
|
||||||
p[i]=0x20;
|
p[i]=0x20;
|
||||||
|
|
||||||
aBuffers[ulInPos][j++] = p[i];
|
aBuffers[ulInPos][j++] = p[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,7 +325,7 @@ void PrintRingBuffer(ULONG ulLines)
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ulDelta)
|
if(!ulDelta)
|
||||||
{
|
{
|
||||||
DPRINT((0,"PrintRingBuffer(): no lines in ring buffer\n"));
|
DPRINT((0,"PrintRingBuffer(): no lines in ring buffer\n"));
|
||||||
|
@ -491,7 +487,7 @@ BOOLEAN PrintRingBufferHome(ULONG ulLines)
|
||||||
Print(OUTPUT_WINDOW_UNBUFFERED,aBuffers[ulInPos]);
|
Print(OUTPUT_WINDOW_UNBUFFERED,aBuffers[ulInPos]);
|
||||||
wWindow[OUTPUT_WINDOW].usCurX = PICE_strlen(aBuffers[ulInPos])+1;
|
wWindow[OUTPUT_WINDOW].usCurX = PICE_strlen(aBuffers[ulInPos])+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LEAVE_FUNC();
|
// LEAVE_FUNC();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -729,7 +725,7 @@ void PrintCaption(void)
|
||||||
SetForegroundColor(COLOR_TEXT);
|
SetForegroundColor(COLOR_TEXT);
|
||||||
SetBackgroundColor(COLOR_CAPTION);
|
SetBackgroundColor(COLOR_CAPTION);
|
||||||
|
|
||||||
ClrLine(0);
|
ClrLine(0);
|
||||||
PutChar((LPSTR)title,
|
PutChar((LPSTR)title,
|
||||||
(GLOBAL_SCREEN_WIDTH-sizeof(title))/2,
|
(GLOBAL_SCREEN_WIDTH-sizeof(title))/2,
|
||||||
0);
|
0);
|
||||||
|
@ -763,9 +759,9 @@ void PrintTemplate(void)
|
||||||
SetForegroundColor(COLOR_TEXT);
|
SetForegroundColor(COLOR_TEXT);
|
||||||
SetBackgroundColor(COLOR_CAPTION);
|
SetBackgroundColor(COLOR_CAPTION);
|
||||||
|
|
||||||
ClrLine(wWindow[DATA_WINDOW].y-1);
|
ClrLine(wWindow[DATA_WINDOW].y-1);
|
||||||
ClrLine(wWindow[SOURCE_WINDOW].y-1);
|
ClrLine(wWindow[SOURCE_WINDOW].y-1);
|
||||||
ClrLine(wWindow[OUTPUT_WINDOW].y-1);
|
ClrLine(wWindow[OUTPUT_WINDOW].y-1);
|
||||||
|
|
||||||
ResetColor();
|
ResetColor();
|
||||||
|
|
||||||
|
@ -811,7 +807,7 @@ void Print(USHORT Window,LPSTR p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// the OUTPUT_WINDOW is specially handled
|
// the OUTPUT_WINDOW is specially handled
|
||||||
if(Window == OUTPUT_WINDOW)
|
if(Window == OUTPUT_WINDOW)
|
||||||
{
|
{
|
||||||
DPRINT((0,"Print(): OUTPUT_WINDOW\n"));
|
DPRINT((0,"Print(): OUTPUT_WINDOW\n"));
|
||||||
|
@ -830,7 +826,7 @@ void Print(USHORT Window,LPSTR p)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOLEAN bOutput = TRUE;
|
BOOLEAN bOutput = TRUE;
|
||||||
|
|
||||||
if(Window == OUTPUT_WINDOW_UNBUFFERED)
|
if(Window == OUTPUT_WINDOW_UNBUFFERED)
|
||||||
{
|
{
|
||||||
|
@ -945,7 +941,7 @@ void FlushKeyboardQueue(void)
|
||||||
//
|
//
|
||||||
// init terminal screen
|
// init terminal screen
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
BOOLEAN ConsoleInit(void)
|
BOOLEAN ConsoleInit(void)
|
||||||
{
|
{
|
||||||
BOOLEAN bResult = FALSE;
|
BOOLEAN bResult = FALSE;
|
||||||
|
|
||||||
|
@ -975,7 +971,7 @@ BOOLEAN ConsoleInit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that outputhandlers have all been set
|
// check that outputhandlers have all been set
|
||||||
// ohandlers.Flush may be zero on return
|
// ohandlers.Flush may be zero on return
|
||||||
if( !ohandlers.ClrLine ||
|
if( !ohandlers.ClrLine ||
|
||||||
!ohandlers.CopyLineTo ||
|
!ohandlers.CopyLineTo ||
|
||||||
!ohandlers.HatchLine ||
|
!ohandlers.HatchLine ||
|
||||||
|
@ -1012,14 +1008,14 @@ BOOLEAN ConsoleInit(void)
|
||||||
//
|
//
|
||||||
// exit terminal screen
|
// exit terminal screen
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void ConsoleShutdown(void)
|
void ConsoleShutdown(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
// sleep for a few seconds
|
// sleep for a few seconds
|
||||||
__udelay(1000*5000);
|
Sleep(1000*5000);
|
||||||
|
|
||||||
switch(eTerminalMode)
|
switch(eTerminalMode)
|
||||||
{
|
{
|
||||||
case TERMINAL_MODE_HERCULES_GRAPHICS:
|
case TERMINAL_MODE_HERCULES_GRAPHICS:
|
||||||
ConsoleShutdownHercules();
|
ConsoleShutdownHercules();
|
||||||
|
|
|
@ -7,7 +7,7 @@ Module Name:
|
||||||
hercules.c
|
hercules.c
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
|
|
||||||
HW dependent draw routines
|
HW dependent draw routines
|
||||||
|
|
||||||
Environment:
|
Environment:
|
||||||
|
@ -22,7 +22,7 @@ Revision History:
|
||||||
|
|
||||||
04-Aug-1998: created
|
04-Aug-1998: created
|
||||||
15-Nov-2000: general cleanup of source files
|
15-Nov-2000: general cleanup of source files
|
||||||
|
|
||||||
Copyright notice:
|
Copyright notice:
|
||||||
|
|
||||||
This file may be distributed under the terms of the GNU Public License.
|
This file may be distributed under the terms of the GNU Public License.
|
||||||
|
@ -34,10 +34,6 @@ Copyright notice:
|
||||||
////
|
////
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include <linux/pci.h>
|
|
||||||
#include <asm/io.h>
|
|
||||||
#include <asm/delay.h>
|
|
||||||
#include <linux/ctype.h>
|
|
||||||
|
|
||||||
#include "charset.h"
|
#include "charset.h"
|
||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
|
@ -88,7 +84,7 @@ struct _attr
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|
||||||
UCHAR fgcol : 4;
|
UCHAR fgcol : 4;
|
||||||
UCHAR bkcol : 3;
|
UCHAR bkcol : 3;
|
||||||
UCHAR blink : 1;
|
UCHAR blink : 1;
|
||||||
|
@ -126,7 +122,7 @@ void PrintGrafHercules(ULONG x,ULONG y,UCHAR c)
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PUCHAR p;
|
PUCHAR p;
|
||||||
ULONG _line = y<<3;
|
ULONG _line = y<<3;
|
||||||
|
|
||||||
if(!pScreenBufferHercules)
|
if(!pScreenBufferHercules)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -162,9 +158,9 @@ void FlushHercules(void)
|
||||||
void ShowCursorHercules(void)
|
void ShowCursorHercules(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
bCursorEnabled=TRUE;
|
bCursorEnabled=TRUE;
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +172,7 @@ void ShowCursorHercules(void)
|
||||||
void HideCursorHercules(void)
|
void HideCursorHercules(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
bCursorEnabled=FALSE;
|
bCursorEnabled=FALSE;
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
|
@ -373,7 +369,7 @@ void PrintCursorHercules(BOOLEAN bForce)
|
||||||
count=0;
|
count=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__udelay(2500);
|
KeStallExecutionProcessor(2500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
@ -399,7 +395,7 @@ void RestoreGraphicsStateHercules(void)
|
||||||
//
|
//
|
||||||
// init terminal screen
|
// init terminal screen
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
BOOLEAN ConsoleInitHercules(void)
|
BOOLEAN ConsoleInitHercules(void)
|
||||||
{
|
{
|
||||||
BOOLEAN bResult = FALSE;
|
BOOLEAN bResult = FALSE;
|
||||||
PUCHAR pMGATable = MGATable43;
|
PUCHAR pMGATable = MGATable43;
|
||||||
|
@ -428,40 +424,40 @@ BOOLEAN ConsoleInitHercules(void)
|
||||||
// init HERCULES adapter
|
// init HERCULES adapter
|
||||||
outb_p(0,0x3b8);
|
outb_p(0,0x3b8);
|
||||||
outb_p(0x03,0x3bf);
|
outb_p(0x03,0x3bf);
|
||||||
for(i=0;i<sizeof(MGATable43);i++)
|
for(i=0;i<sizeof(MGATable43);i++)
|
||||||
{
|
{
|
||||||
reg=i;
|
reg=i;
|
||||||
outb_p(reg,0x3b4);
|
outb_p(reg,0x3b4);
|
||||||
data=pMGATable[i];
|
data=pMGATable[i];
|
||||||
outb_p(data,0x3b5);
|
outb_p(data,0x3b5);
|
||||||
}
|
}
|
||||||
outb_p(0x0a,0x3b8);
|
outb_p(0x0a,0x3b8);
|
||||||
|
|
||||||
SetWindowGeometry(wWindowHercGraph);
|
SetWindowGeometry(wWindowHercGraph);
|
||||||
|
|
||||||
GLOBAL_SCREEN_WIDTH = 90;
|
GLOBAL_SCREEN_WIDTH = 90;
|
||||||
GLOBAL_SCREEN_HEIGHT = 45;
|
GLOBAL_SCREEN_HEIGHT = 45;
|
||||||
|
|
||||||
attr.u.Asuchar = 0x07;
|
attr.u.Asuchar = 0x07;
|
||||||
|
|
||||||
pScreenBufferHercules=MmMapIoSpace(0xb0000,FRAMEBUFFER_SIZE,MmWriteCombined);
|
pScreenBufferHercules=MmMapIoSpace(0xb0000,FRAMEBUFFER_SIZE,MmWriteCombined);
|
||||||
|
|
||||||
DPRINT((0,"VGA memory phys. 0xb0000 mapped to virt. 0x%x\n",pScreenBufferHercules));
|
DPRINT((0,"VGA memory phys. 0xb0000 mapped to virt. 0x%x\n",pScreenBufferHercules));
|
||||||
|
|
||||||
if(pScreenBufferHercules)
|
if(pScreenBufferHercules)
|
||||||
{
|
{
|
||||||
for(i=0;i<4;i++)
|
for(i=0;i<4;i++)
|
||||||
{
|
{
|
||||||
pVgaOffset[i] = (PUCHAR)pScreenBufferHercules+0x2000*i;
|
pVgaOffset[i] = (PUCHAR)pScreenBufferHercules+0x2000*i;
|
||||||
DPRINT((0,"VGA offset %u = 0x%.8X\n",i,pVgaOffset[i]));
|
DPRINT((0,"VGA offset %u = 0x%.8X\n",i,pVgaOffset[i]));
|
||||||
}
|
}
|
||||||
bResult = TRUE;
|
bResult = TRUE;
|
||||||
|
|
||||||
PICE_memset(pScreenBufferHercules,0x0,FRAMEBUFFER_SIZE);
|
PICE_memset(pScreenBufferHercules,0x0,FRAMEBUFFER_SIZE);
|
||||||
|
|
||||||
EmptyRingBuffer();
|
EmptyRingBuffer();
|
||||||
|
|
||||||
DPRINT((0,"ConsoleInitHercules() SUCCESS!\n"));
|
DPRINT((0,"ConsoleInitHercules() SUCCESS!\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
|
@ -474,16 +470,16 @@ BOOLEAN ConsoleInitHercules(void)
|
||||||
//
|
//
|
||||||
// exit terminal screen
|
// exit terminal screen
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void ConsoleShutdownHercules(void)
|
void ConsoleShutdownHercules(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
// HERC video off
|
// HERC video off
|
||||||
outb_p(0,0x3b8);
|
outb_p(0,0x3b8);
|
||||||
outb_p(0,0x3bf);
|
outb_p(0,0x3bf);
|
||||||
|
|
||||||
if(pScreenBufferHercules)
|
if(pScreenBufferHercules)
|
||||||
MmUnmapIoSpace(pScreenBufferHercules,FRAMEBUFFER_SIZE);
|
MmUnmapIoSpace(pScreenBufferHercules,FRAMEBUFFER_SIZE);
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ Module Name:
|
||||||
hooks.c
|
hooks.c
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
|
|
||||||
hooking of interrupts
|
hooking of interrupts
|
||||||
|
|
||||||
Environment:
|
Environment:
|
||||||
|
@ -35,8 +35,6 @@ Copyright notice:
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
#include <asm/io.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// PROTOTYPES
|
// PROTOTYPES
|
||||||
////
|
////
|
||||||
|
@ -67,28 +65,28 @@ ULONG ulOldFlags;
|
||||||
// MaskIrqs()
|
// MaskIrqs()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void MaskIrqs(void)
|
void MaskIrqs(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
save_flags(ulOldFlags);
|
save_flags(ulOldFlags);
|
||||||
cli();
|
cli();
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// UnmaskIrqs()
|
// UnmaskIrqs()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void UnmaskIrqs(void)
|
void UnmaskIrqs(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
restore_flags(ulOldFlags);
|
restore_flags(ulOldFlags);
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// SetGlobalInt()
|
// SetGlobalInt()
|
||||||
|
@ -176,4 +174,4 @@ void RestoreIdt(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -35,11 +35,6 @@ Copyright notice:
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
#include <linux/fs.h>
|
|
||||||
#include <asm/uaccess.h>
|
|
||||||
#include <asm/io.h>
|
|
||||||
#include <asm/delay.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// GLOBALS
|
// GLOBALS
|
||||||
ULONG ulDoInitialBreak=1;
|
ULONG ulDoInitialBreak=1;
|
||||||
|
@ -49,6 +44,9 @@ char tempInit[256];
|
||||||
PDIRECTORY_OBJECT *pNameSpaceRoot = NULL;
|
PDIRECTORY_OBJECT *pNameSpaceRoot = NULL;
|
||||||
PDEBUG_MODULE pdebug_module_tail = NULL;
|
PDEBUG_MODULE pdebug_module_tail = NULL;
|
||||||
PDEBUG_MODULE pdebug_module_head = NULL;
|
PDEBUG_MODULE pdebug_module_head = NULL;
|
||||||
|
PMADDRESS_SPACE mm_init_mm;
|
||||||
|
|
||||||
|
ULONG KeyboardIRQL;
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// InitPICE()
|
// InitPICE()
|
||||||
|
@ -58,9 +56,20 @@ BOOLEAN InitPICE(void)
|
||||||
{
|
{
|
||||||
ULONG ulHandleScancode=0,ulHandleKbdEvent=0;
|
ULONG ulHandleScancode=0,ulHandleKbdEvent=0;
|
||||||
ARGS Args;
|
ARGS Args;
|
||||||
|
KIRQL Dirql;
|
||||||
|
KAFFINITY Affinity;
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
|
DPRINT((0,"InitPICE(): trace step 0.5\n"));
|
||||||
|
KeyboardIRQL = HalGetInterruptVector(Internal,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
KEYBOARD_IRQ,
|
||||||
|
&Dirql,
|
||||||
|
&Affinity);
|
||||||
|
DPRINT((0,"KeyboardIRQL: %x\n", KeyboardIRQL));
|
||||||
|
|
||||||
DPRINT((0,"InitPICE(): trace step 1\n"));
|
DPRINT((0,"InitPICE(): trace step 1\n"));
|
||||||
// enable monochrome passthrough on BX type chipset
|
// enable monochrome passthrough on BX type chipset
|
||||||
EnablePassThrough();
|
EnablePassThrough();
|
||||||
|
@ -103,9 +112,9 @@ BOOLEAN InitPICE(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT((0,"InitPICE(): trace step 6\n"));
|
DPRINT((0,"InitPICE(): trace step 6\n"));
|
||||||
// get kernel mm_struct
|
|
||||||
my_init_mm = GetInitMm();
|
ScanExport(_KernelAddressSpace,(PULONG)&mm_init_mm);
|
||||||
if(!my_init_mm)
|
if(!my_init_mm)
|
||||||
{
|
{
|
||||||
Print(OUTPUT_WINDOW,"pICE: ABORT (initial memory map not found)\n");
|
Print(OUTPUT_WINDOW,"pICE: ABORT (initial memory map not found)\n");
|
||||||
Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
|
Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
|
||||||
|
@ -117,6 +126,21 @@ BOOLEAN InitPICE(void)
|
||||||
}
|
}
|
||||||
DPRINT((0,"init_mm @ %X\n",my_init_mm));
|
DPRINT((0,"init_mm @ %X\n",my_init_mm));
|
||||||
|
|
||||||
|
DPRINT((0,"InitPICE(): trace step 6.1\n"));
|
||||||
|
|
||||||
|
ScanExport(_PsProcessListHead,(PULONG)&pPsProcessListHead);
|
||||||
|
if(!pPsProcessListHead)
|
||||||
|
{
|
||||||
|
Print(OUTPUT_WINDOW,"pICE: ABORT (PsProcessListHead not found)\n");
|
||||||
|
Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
|
||||||
|
while(!GetKeyPolled());
|
||||||
|
UnloadSymbols();
|
||||||
|
ConsoleShutdown();
|
||||||
|
LEAVE_FUNC();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
DPRINT((0,"PsProcessListHead @ %X\n",pPsProcessListHead));
|
||||||
|
|
||||||
DPRINT((0,"InitPICE(): trace step 7\n"));
|
DPRINT((0,"InitPICE(): trace step 7\n"));
|
||||||
// load the file /boot/System.map.
|
// load the file /boot/System.map.
|
||||||
// !!! It must be consistent with the current kernel at all cost!!!
|
// !!! It must be consistent with the current kernel at all cost!!!
|
||||||
|
@ -133,7 +157,8 @@ BOOLEAN InitPICE(void)
|
||||||
|
|
||||||
DPRINT((0,"InitPICE(): trace step 8\n"));
|
DPRINT((0,"InitPICE(): trace step 8\n"));
|
||||||
// end of the kernel
|
// end of the kernel
|
||||||
ScanExports("_end",(PULONG)&kernel_end);
|
/*
|
||||||
|
ScanExports("_end",(PULONG)&kernel_end);
|
||||||
if(!kernel_end)
|
if(!kernel_end)
|
||||||
{
|
{
|
||||||
Print(OUTPUT_WINDOW,"pICE: ABORT (kernel size is unknown)\n");
|
Print(OUTPUT_WINDOW,"pICE: ABORT (kernel size is unknown)\n");
|
||||||
|
@ -145,6 +170,7 @@ BOOLEAN InitPICE(void)
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
DPRINT((0,"InitPICE(): trace step 9\n"));
|
DPRINT((0,"InitPICE(): trace step 9\n"));
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ Environment:
|
||||||
|
|
||||||
Kernel mode only
|
Kernel mode only
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
Klaus P. Gerlicher
|
Klaus P. Gerlicher
|
||||||
|
|
||||||
|
@ -57,11 +57,11 @@ asmlinkage int printk(const char *fmt, ...);
|
||||||
|
|
||||||
EXPORT_SYMBOL(printk);
|
EXPORT_SYMBOL(printk);
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// printk()
|
// printk()
|
||||||
//
|
//
|
||||||
// this function overrides printk() in the kernel
|
// this function overrides printk() in the kernel
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
asmlinkage int printk(const char *fmt, ...)
|
asmlinkage int printk(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
ULONG len,ulRingBufferLock;
|
ULONG len,ulRingBufferLock;
|
||||||
|
@ -100,12 +100,12 @@ asmlinkage int printk(const char *fmt, ...)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// CountArgs()
|
// CountArgs()
|
||||||
//
|
//
|
||||||
// count occurrence of '%' in format string (except %%)
|
// count occurrence of '%' in format string (except %%)
|
||||||
// validity of whole format string must have been enforced
|
// validity of whole format string must have been enforced
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
ULONG CountArgs(LPSTR fmt)
|
ULONG CountArgs(LPSTR fmt)
|
||||||
{
|
{
|
||||||
ULONG count=0;
|
ULONG count=0;
|
||||||
|
@ -119,16 +119,17 @@ ULONG CountArgs(LPSTR fmt)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// PrintkCallback()
|
// PrintkCallback()
|
||||||
//
|
//
|
||||||
// called from RealIsr() when processing INT3 placed
|
// called from RealIsr() when processing INT3 placed
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void PrintkCallback(void)
|
void PrintkCallback(void)
|
||||||
{
|
{
|
||||||
LPSTR fmt,args;
|
LPSTR fmt,args;
|
||||||
ULONG ulAddress;
|
ULONG ulAddress;
|
||||||
ULONG countArgs,i,len;
|
ULONG countArgs,i,len;
|
||||||
|
PANSI_STRING temp;
|
||||||
|
|
||||||
bInPrintk = TRUE;
|
bInPrintk = TRUE;
|
||||||
|
|
||||||
|
@ -138,7 +139,9 @@ void PrintkCallback(void)
|
||||||
{
|
{
|
||||||
if(IsAddressValid(ulAddress+sizeof(char *)) )
|
if(IsAddressValid(ulAddress+sizeof(char *)) )
|
||||||
{
|
{
|
||||||
fmt = (LPSTR)*(PULONG)(ulAddress+sizeof(char *));
|
//KdpPrintString has PANSI_STRING as a parameter
|
||||||
|
temp = (PANSI_STRING)*(PULONG)(ulAddress+sizeof(char *));
|
||||||
|
fmt = temp->Buffer;
|
||||||
|
|
||||||
// validate format string
|
// validate format string
|
||||||
if((len = PICE_strlen(fmt)) )
|
if((len = PICE_strlen(fmt)) )
|
||||||
|
@ -149,7 +152,7 @@ void PrintkCallback(void)
|
||||||
|
|
||||||
if((countArgs = CountArgs(fmt))>0)
|
if((countArgs = CountArgs(fmt))>0)
|
||||||
{
|
{
|
||||||
|
|
||||||
args = (LPSTR)(ulAddress+2*sizeof(char *));
|
args = (LPSTR)(ulAddress+2*sizeof(char *));
|
||||||
if(IsAddressValid((ULONG)args))
|
if(IsAddressValid((ULONG)args))
|
||||||
{
|
{
|
||||||
|
@ -182,12 +185,12 @@ void PrintkCallback(void)
|
||||||
bInPrintk = FALSE;
|
bInPrintk = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// PiceRunningTimer()
|
// PiceRunningTimer()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|
||||||
KTIMER PiceTimer;
|
KTIMER PiceTimer;
|
||||||
KDPC PiceTimerDPC;
|
KDPC PiceTimerDPC;
|
||||||
|
|
||||||
// do I need it here? Have to keep DPC memory resident #pragma code_seg()
|
// do I need it here? Have to keep DPC memory resident #pragma code_seg()
|
||||||
|
@ -203,7 +206,7 @@ VOID PiceRunningTimer(IN PKDPC Dpc,
|
||||||
ulCountTimerEvents = 0;
|
ulCountTimerEvents = 0;
|
||||||
|
|
||||||
LARGE_INTEGER jiffies;
|
LARGE_INTEGER jiffies;
|
||||||
|
|
||||||
KeQuerySystemTime(&jiffies);
|
KeQuerySystemTime(&jiffies);
|
||||||
SetForegroundColor(COLOR_TEXT);
|
SetForegroundColor(COLOR_TEXT);
|
||||||
SetBackgroundColor(COLOR_CAPTION);
|
SetBackgroundColor(COLOR_CAPTION);
|
||||||
|
@ -213,48 +216,49 @@ VOID PiceRunningTimer(IN PKDPC Dpc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// InitPiceRunningTimer()
|
// InitPiceRunningTimer()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void InitPiceRunningTimer(void)
|
void InitPiceRunningTimer(void)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER Interval;
|
LARGE_INTEGER Interval;
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
ÿÿ
|
#if 0 //won't work. we have to intercept timer interrupt so dpc will never fire while we are in pice
|
||||||
KeInitializeTimer( &PiceTimer );
|
KeInitializeTimer( &PiceTimer );
|
||||||
KeInitializeDpc( &PiceTimerDPC, PiceRunningTimer, NULL );
|
KeInitializeDpc( &PiceTimerDPC, PiceRunningTimer, NULL );
|
||||||
|
|
||||||
Interval.QuadPart=-1000000L; // 100 millisec. (unit is 100 nanosec.)
|
Interval.QuadPart=-1000000L; // 100 millisec. (unit is 100 nanosec.)
|
||||||
|
|
||||||
KeSetTimerEx(&PiceTimer,
|
KeSetTimerEx(&PiceTimer,
|
||||||
Interval, 1000000L,
|
Interval, 1000000L,
|
||||||
&PiceTimerDpc);
|
&PiceTimerDpc);
|
||||||
|
#endif
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// RemovePiceRunningTimer()
|
// RemovePiceRunningTimer()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void RemovePiceRunningTimer(void)
|
void RemovePiceRunningTimer(void)
|
||||||
{
|
{
|
||||||
KeCancelTimer( &PiceTimer );
|
KeCancelTimer( &PiceTimer );
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// InstallPrintkHook()
|
// InstallPrintkHook()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void InstallPrintkHook(void)
|
void InstallPrintkHook(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
DPRINT((0,"installing PrintString hook\n"));
|
DPRINT((0,"installing PrintString hook\n"));
|
||||||
|
|
||||||
ScanExports("_KdpPrintString",(PULONG)&ulPrintk);
|
ScanExports("_KdpPrintString",(PULONG)&ulPrintk);
|
||||||
|
|
||||||
ASSERT( ulPrintk ); // temporary
|
assert( ulPrintk ); // temporary
|
||||||
|
|
||||||
if(ulPrintk)
|
if(ulPrintk)
|
||||||
{
|
{
|
||||||
|
@ -264,10 +268,10 @@ void InstallPrintkHook(void)
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// DeInstallPrintkHook()
|
// DeInstallPrintkHook()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void DeInstallPrintkHook(void)
|
void DeInstallPrintkHook(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
|
@ -36,14 +36,6 @@ Copyright notice:
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include "pci_ids.h"
|
#include "pci_ids.h"
|
||||||
|
|
||||||
#include <linux/sched.h>
|
|
||||||
#include <asm/io.h>
|
|
||||||
#include <asm/page.h>
|
|
||||||
#include <asm/pgtable.h>
|
|
||||||
#include <linux/utsname.h>
|
|
||||||
#include <linux/timer.h>
|
|
||||||
#include <linux/ctype.h>
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
// GLOBALS
|
// GLOBALS
|
||||||
|
|
||||||
|
@ -56,7 +48,7 @@ USHORT usOldDisasmSegment = 0;
|
||||||
ULONG ulOldDisasmOffset = 0;
|
ULONG ulOldDisasmOffset = 0;
|
||||||
static ULONG ulCountForWaitKey = 0;
|
static ULONG ulCountForWaitKey = 0;
|
||||||
|
|
||||||
extern unsigned long sys_call_table[];
|
//extern unsigned long sys_call_table[];
|
||||||
|
|
||||||
BOOLEAN (*DisplayMemory)(PARGS) = DisplayMemoryDword;
|
BOOLEAN (*DisplayMemory)(PARGS) = DisplayMemoryDword;
|
||||||
|
|
||||||
|
@ -842,7 +834,7 @@ COMMAND_PROTOTYPE(ShowIdt)
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
// get GDT register
|
// get GDT register
|
||||||
__asm__ ("sidt %0\n"
|
__asm__ ("sidt %0\n"
|
||||||
:"=m" (idtr));
|
:"=m" (idtr));
|
||||||
// info out
|
// info out
|
||||||
|
@ -905,35 +897,17 @@ COMMAND_PROTOTYPE(ShowPageDirs)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PPAGEDIR pPageDir;
|
PPAGEDIR pPageDir;
|
||||||
pgd_t * pPGD;
|
PULONG pPGD;
|
||||||
pmd_t * pPMD;
|
PULONG pPTE;
|
||||||
pte_t * pPTE;
|
PEPROCESS my_current = IoGetCurrentProcess();
|
||||||
struct mm_struct* mm;
|
|
||||||
struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
|
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
// get current process pointer
|
|
||||||
(ULONG)my_current &= ulRealStackPtr;
|
|
||||||
|
|
||||||
DPRINT((0,"ShowPageDirs(): my_current = %.8X\n",(ULONG)my_current));
|
DPRINT((0,"ShowPageDirs(): my_current = %.8X\n",(ULONG)my_current));
|
||||||
|
|
||||||
// don't touch if not valid process
|
// don't touch if not valid process
|
||||||
if(my_current)
|
if(my_current)
|
||||||
{
|
{
|
||||||
if(my_current->mm)
|
|
||||||
{
|
|
||||||
pPageDir = (PPAGEDIR)pgd_offset(my_current->mm,0);
|
|
||||||
mm = my_current->mm;
|
|
||||||
DPRINT((0,"ShowPageDirs(): (1) pPageDir = %.8X\n",(ULONG)pPageDir));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mm = my_init_mm;
|
|
||||||
pPageDir = (PPAGEDIR)my_init_mm->pgd;
|
|
||||||
DPRINT((0,"ShowPageDirs(): (2) pPageDir = %.8X\n",(ULONG)pPageDir));
|
|
||||||
}
|
|
||||||
|
|
||||||
// no arguments supplied -> show all page directories
|
// no arguments supplied -> show all page directories
|
||||||
if(!pArgs->Count)
|
if(!pArgs->Count)
|
||||||
{
|
{
|
||||||
|
@ -943,12 +917,12 @@ COMMAND_PROTOTYPE(ShowPageDirs)
|
||||||
{
|
{
|
||||||
ULONG ulAddress = i<<22;
|
ULONG ulAddress = i<<22;
|
||||||
// from the mm_struct get pointer to page directory for this address
|
// from the mm_struct get pointer to page directory for this address
|
||||||
pPGD = pgd_offset(mm,ulAddress);
|
pPGD = ADDR_TO_PDE(ulAddress);
|
||||||
|
// create a structurized pointer from PGD
|
||||||
|
pPageDir = (PPAGEDIR)pPGD;
|
||||||
|
|
||||||
if(pPGD)
|
if(pPageDir->PTBase)
|
||||||
{
|
{
|
||||||
// create a structurized pointer from PGD
|
|
||||||
pPageDir = (PPAGEDIR)pPGD;
|
|
||||||
|
|
||||||
PICE_sprintf(tempCmd,"%.8X-%.8X %.8X %s %s %s\n",
|
PICE_sprintf(tempCmd,"%.8X-%.8X %.8X %s %s %s\n",
|
||||||
ulAddress, ulAddress + 0x400000,
|
ulAddress, ulAddress + 0x400000,
|
||||||
|
@ -962,18 +936,19 @@ COMMAND_PROTOTYPE(ShowPageDirs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// one arg supplied -> show individual page
|
|
||||||
|
// one arg supplied -> show individual page
|
||||||
else if(pArgs->Count == 1)
|
else if(pArgs->Count == 1)
|
||||||
{
|
{
|
||||||
pPGD = pgd_offset(mm,pArgs->Value[0]);
|
pPGD = (ULONG)PAGEDIRECTORY_MAP+(((ULONG)pArgs->Value[0] / (1024 * 1024))&(~0x3));
|
||||||
|
|
||||||
DPRINT((0,"ShowPageDirs(): VA = %.8X\n",pArgs->Value[0]));
|
DPRINT((0,"ShowPageDirs(): VA = %.8X\n",pArgs->Value[0]));
|
||||||
DPRINT((0,"ShowPageDirs(): pPGD = %.8X\n",(ULONG)pPGD));
|
DPRINT((0,"ShowPageDirs(): pPGD = %.8X\n",(ULONG)pPGD));
|
||||||
|
|
||||||
if(pPGD && pgd_val(*pPGD)&_PAGE_PRESENT)
|
if(pPGD && ((*pPGD)&_PAGE_PRESENT))
|
||||||
{
|
{
|
||||||
// 4M page
|
// 4M page
|
||||||
if(pgd_val(*pPGD)&_PAGE_4M)
|
if((*pPGD)&_PAGE_4M)
|
||||||
{
|
{
|
||||||
PPAGEDIR pPage = (PPAGEDIR)pPGD;
|
PPAGEDIR pPage = (PPAGEDIR)pPGD;
|
||||||
|
|
||||||
|
@ -989,15 +964,11 @@ COMMAND_PROTOTYPE(ShowPageDirs)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pPMD = pmd_offset(pPGD,pArgs->Value[0]);
|
pPTE = ADDR_TO_PTE(pArgs->Value[0]);
|
||||||
DPRINT((0,"ShowPageDirs(): pPMD = %.8X\n",(ULONG)pPMD));
|
|
||||||
pPTE = pte_offset(pPMD,pArgs->Value[0]);
|
|
||||||
DPRINT((0,"ShowPageDirs(): pPTE = %.8X\n",(ULONG)pPTE));
|
DPRINT((0,"ShowPageDirs(): pPTE = %.8X\n",(ULONG)pPTE));
|
||||||
if(pPTE)
|
if(pPTE)
|
||||||
{
|
{
|
||||||
PPAGEDIR pPage = (PPAGEDIR)pPTE;
|
PPAGEDIR pPage = (PPAGEDIR)pPTE;
|
||||||
|
|
||||||
DPRINT((0,"ShowPageDirs(): pte_val = %.8X\n",(ULONG)pte_val(*pPTE)));
|
|
||||||
DPRINT((0,"ShowPageDirs(): pPage->PTBase = %.8X\n",(ULONG)pPage->PTBase));
|
DPRINT((0,"ShowPageDirs(): pPage->PTBase = %.8X\n",(ULONG)pPage->PTBase));
|
||||||
|
|
||||||
PutStatusText("Linear Physical Attributes");
|
PutStatusText("Linear Physical Attributes");
|
||||||
|
@ -1031,33 +1002,32 @@ COMMAND_PROTOTYPE(ShowPageDirs)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
COMMAND_PROTOTYPE(ShowProcesses)
|
COMMAND_PROTOTYPE(ShowProcesses)
|
||||||
{
|
{
|
||||||
struct task_struct* p;
|
PEPROCESS my_current = IoGetCurrentProcess();
|
||||||
struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
|
PLIST_ENTRY current_entry;
|
||||||
ULONG i;
|
PEPROCESS currentps;
|
||||||
\
|
|
||||||
(ULONG)my_current &= ulRealStackPtr;
|
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
if(my_current)
|
current_entry = pPsProcessListHead->Flink;
|
||||||
{
|
|
||||||
DPRINT((0,"current = %x current->prev_task = %x current->next_task = %x\n",
|
|
||||||
my_current,
|
|
||||||
my_current->prev_task,
|
|
||||||
my_current->next_task));
|
|
||||||
|
|
||||||
PutStatusText("NAME TASK PID");
|
if( current_entry ){
|
||||||
|
|
||||||
for(i=0,p = my_current; (p = p->next_task) != my_current;i++)
|
PutStatusText("NAME TASK PID");
|
||||||
{
|
|
||||||
DPRINT((0,"p = %x\n",p));
|
while( current_entry != pPsProcessListHead ){
|
||||||
PICE_sprintf(tempCmd,"%-16.16s %-12x %x\n",(LPSTR)&(p->comm),(ULONG)p,p->pid);
|
currentps = CONTAINING_RECORD(current_entry,
|
||||||
Print(OUTPUT_WINDOW,tempCmd);
|
EPROCESS,
|
||||||
if(WaitForKey()==FALSE)
|
ProcessListEntry);
|
||||||
break;
|
DPRINT((0,"currentps = %x\n",currentps));
|
||||||
|
//ei would be nice to mark current process!
|
||||||
|
PICE_sprintf(tempCmd,"%-16.16s %-12x %x\n",currentps->ImageFileName,
|
||||||
|
(ULONG)currentps,currentps->UniqueProcessId);
|
||||||
|
Print(OUTPUT_WINDOW,tempCmd);
|
||||||
|
if(WaitForKey()==FALSE)
|
||||||
|
break;
|
||||||
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1904,6 +1874,7 @@ COMMAND_PROTOTYPE(ShowModules)
|
||||||
// DecodeVmFlags()
|
// DecodeVmFlags()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
//ei FIX THIS!!!!!!!!!!!!!!!!!!
|
||||||
LPSTR DecodeVmFlags(ULONG flags)
|
LPSTR DecodeVmFlags(ULONG flags)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
@ -1961,44 +1932,48 @@ LPSTR DecodeVmFlags(ULONG flags)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
COMMAND_PROTOTYPE(ShowVirtualMemory)
|
COMMAND_PROTOTYPE(ShowVirtualMemory)
|
||||||
{
|
{
|
||||||
struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
|
PEPROCESS my_current = IoGetCurrentProcess();
|
||||||
struct mm_struct *mm;
|
PLIST_ENTRY current_entry;
|
||||||
struct vm_area_struct * vma;
|
PMADDRESS_SPACE vma;
|
||||||
char filename[32];
|
MEMORY_AREA* current;
|
||||||
|
char filename[64];
|
||||||
|
|
||||||
DPRINT((0,"ShowVirtualMemory()\n"));
|
DPRINT((0,"ShowVirtualMemory()\n"));
|
||||||
|
|
||||||
(ULONG)my_current &= ulRealStackPtr;
|
vma = &(my_current->AddressSpace);
|
||||||
|
if(vma)
|
||||||
mm = my_current->mm;
|
|
||||||
if(mm != my_init_mm)
|
|
||||||
{
|
{
|
||||||
if(pArgs->Count == 0)
|
if(pArgs->Count == 0)
|
||||||
{
|
{
|
||||||
PutStatusText("START END VMA FLAGS");
|
PutStatusText("START END LENGTH VMA TYPE ATTR");
|
||||||
for(vma = mm->mmap;vma;vma = vma->vm_next)
|
current_entry = vma->MAreaListHead.Flink;
|
||||||
|
while (current_entry != &vma->MAreaListHead)
|
||||||
{
|
{
|
||||||
*filename = 0;
|
*filename = 0;
|
||||||
// find the filename
|
|
||||||
if((vma->vm_flags&VM_EXECUTABLE) &&
|
current = CONTAINING_RECORD(current_entry,
|
||||||
vma->vm_file)
|
MEMORY_AREA,
|
||||||
|
Entry);
|
||||||
|
// find the filename
|
||||||
|
if(((current->Type == MEMORY_AREA_SECTION_VIEW_COMMIT) ||
|
||||||
|
(current->Type == MEMORY_AREA_SECTION_VIEW_RESERVE) )&&
|
||||||
|
current->Data.SectionData.Section->FileObject)
|
||||||
{
|
{
|
||||||
if (vma->vm_file->f_dentry)
|
if(IsAddressValid((ULONG)current->Data.SectionData.Section->FileObject->FileName.Buffer) )
|
||||||
{
|
PICE_sprintf(filename,"%.64S",current->Data.SectionData.Section->FileObject->FileName.Buffer);
|
||||||
if(IsAddressValid((ULONG)vma->vm_file->f_dentry->d_iname) )
|
|
||||||
PICE_sprintf(filename,"%15s",vma->vm_file->f_dentry->d_iname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PICE_sprintf(tempCmd,"%.8X %.8X %.8X %s %s\n",
|
PICE_sprintf(tempCmd,"%.8X %.8X %.8X %.8X %x %x %s\n",
|
||||||
(ULONG)vma->vm_start,
|
(ULONG)current->BaseAddress,
|
||||||
(ULONG)vma->vm_end,
|
(ULONG)current->BaseAddress+current->Length,
|
||||||
(ULONG)vma,
|
current->Length,
|
||||||
DecodeVmFlags(vma->vm_flags),
|
(ULONG)current,
|
||||||
|
current->Type, current->Attributes,//DecodeVmFlags(current->Type, current->Attributes),
|
||||||
filename);
|
filename);
|
||||||
Print(OUTPUT_WINDOW,tempCmd);
|
Print(OUTPUT_WINDOW,tempCmd);
|
||||||
|
|
||||||
if(WaitForKey()==FALSE)break;
|
if(WaitForKey()==FALSE)break;
|
||||||
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2012,18 +1987,20 @@ COMMAND_PROTOTYPE(ShowVirtualMemory)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
COMMAND_PROTOTYPE(Ver)
|
COMMAND_PROTOTYPE(Ver)
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempCmd,"pICE: version %u.%u (build %u) for Linux kernel release %s\n",
|
//ei add kernel version info??!!
|
||||||
|
PICE_sprintf(tempCmd,"pICE: version %u.%u (build %u) for Reactos\n",
|
||||||
PICE_MAJOR_VERSION,
|
PICE_MAJOR_VERSION,
|
||||||
PICE_MINOR_VERSION,
|
PICE_MINOR_VERSION,
|
||||||
PICE_BUILD,
|
PICE_BUILD);
|
||||||
UTS_RELEASE);
|
|
||||||
Print(OUTPUT_WINDOW,tempCmd);
|
Print(OUTPUT_WINDOW,tempCmd);
|
||||||
|
|
||||||
PICE_sprintf(tempCmd,"pICE: loaded on %s kernel release %s\n",
|
/* PICE_sprintf(tempCmd,"pICE: loaded on %s kernel release %s\n",
|
||||||
system_utsname.sysname,
|
system_utsname.sysname,
|
||||||
system_utsname.release);
|
system_utsname.release);
|
||||||
|
*/
|
||||||
Print(OUTPUT_WINDOW,tempCmd);
|
Print(OUTPUT_WINDOW,tempCmd);
|
||||||
Print(OUTPUT_WINDOW,"pICE: written by Klaus P. Gerlicher and Goran Devic\n");
|
Print(OUTPUT_WINDOW,"pICE: written by Klaus P. Gerlicher and Goran Devic. Ported to Reactos by Eugene Ingerman.\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2106,7 +2083,6 @@ COMMAND_PROTOTYPE(I3here)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LINUX
|
|
||||||
COMMAND_PROTOTYPE(I1here)
|
COMMAND_PROTOTYPE(I1here)
|
||||||
{
|
{
|
||||||
if(pArgs->Count==1)
|
if(pArgs->Count==1)
|
||||||
|
@ -2146,7 +2122,6 @@ COMMAND_PROTOTYPE(I1here)
|
||||||
// never gets here
|
// never gets here
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif // LINUX
|
|
||||||
|
|
||||||
COMMAND_PROTOTYPE(NextInstr)
|
COMMAND_PROTOTYPE(NextInstr)
|
||||||
{
|
{
|
||||||
|
@ -2857,6 +2832,7 @@ COMMAND_PROTOTYPE(ClearScreen)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
COMMAND_PROTOTYPE(ShowMappings)
|
COMMAND_PROTOTYPE(ShowMappings)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
ULONG ulPageDir;
|
ULONG ulPageDir;
|
||||||
ULONG ulPageTable;
|
ULONG ulPageTable;
|
||||||
ULONG address;
|
ULONG address;
|
||||||
|
@ -2947,7 +2923,9 @@ COMMAND_PROTOTYPE(ShowMappings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
PICE_sprintf(tempCmd,"Not implemented yet!\n");
|
||||||
|
Print(OUTPUT_WINDOW,tempCmd);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3155,6 +3133,7 @@ COMMAND_PROTOTYPE(SetKeyboardLayout)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
COMMAND_PROTOTYPE(ShowSysCallTable)
|
COMMAND_PROTOTYPE(ShowSysCallTable)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
LPSTR pName;
|
LPSTR pName;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
|
@ -3198,8 +3177,10 @@ COMMAND_PROTOTYPE(ShowSysCallTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
|
#endif
|
||||||
return TRUE;
|
PICE_sprintf(tempCmd,"Not implemented yet!\n");
|
||||||
|
Print(OUTPUT_WINDOW,tempCmd);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|
|
@ -96,6 +96,7 @@ extern char szCurrentFile[256];
|
||||||
extern PDEBUG_MODULE pCurrentMod;
|
extern PDEBUG_MODULE pCurrentMod;
|
||||||
extern PICE_SYMBOLFILE_HEADER* pCurrentSymbols;
|
extern PICE_SYMBOLFILE_HEADER* pCurrentSymbols;
|
||||||
extern LONG ulCurrentlyDisplayedLineNumber;
|
extern LONG ulCurrentlyDisplayedLineNumber;
|
||||||
|
extern LIST_ENTRY* pPsProcessListHead;
|
||||||
|
|
||||||
BOOLEAN AsciiToHex(LPSTR p,PULONG pValue);
|
BOOLEAN AsciiToHex(LPSTR p,PULONG pValue);
|
||||||
void Parse(LPSTR pCmdLine,BOOLEAN bInvokedByFkey);
|
void Parse(LPSTR pCmdLine,BOOLEAN bInvokedByFkey);
|
||||||
|
@ -165,3 +166,15 @@ COMMAND_PROTOTYPE(SetKeyboardLayout);
|
||||||
COMMAND_PROTOTYPE(ShowSysCallTable);
|
COMMAND_PROTOTYPE(ShowSysCallTable);
|
||||||
COMMAND_PROTOTYPE(SetAltKey);
|
COMMAND_PROTOTYPE(SetAltKey);
|
||||||
COMMAND_PROTOTYPE(ShowContext);
|
COMMAND_PROTOTYPE(ShowContext);
|
||||||
|
|
||||||
|
//ei make sure the following correspond to ntoskrnl/mm/i386/page.c
|
||||||
|
#define PAGETABLE_MAP (0xf0000000)
|
||||||
|
#define PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (1024)))
|
||||||
|
#define PAGE_SHIFT 12
|
||||||
|
#define PTRS_PER_PTE 1024
|
||||||
|
#define PAGE_SIZE (1UL << PAGE_SHIFT)
|
||||||
|
#define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (4 * 1024 * 1024))
|
||||||
|
#define ADDR_TO_PDE(v) (PULONG)(PAGEDIRECTORY_MAP + \
|
||||||
|
(((ULONG)v / (1024 * 1024))&(~0x3)))
|
||||||
|
#define ADDR_TO_PTE(v) (PULONG)(PAGETABLE_MAP + ((((ULONG)v / 1024))&(~0x3)))
|
||||||
|
#define ADDR_TO_PDE_OFFSET(v) (((ULONG)v / (4 * 1024 * 1024)))
|
||||||
|
|
|
@ -7,14 +7,14 @@ Module Name:
|
||||||
pgflt.c
|
pgflt.c
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
|
|
||||||
page fault handling on x86
|
page fault handling on x86
|
||||||
|
|
||||||
Environment:
|
Environment:
|
||||||
|
|
||||||
Kernel mode only
|
Kernel mode only
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
Klaus P. Gerlicher
|
Klaus P. Gerlicher
|
||||||
|
|
||||||
|
@ -35,13 +35,6 @@ Copyright notice:
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include <asm/io.h>
|
|
||||||
#include <asm/page.h>
|
|
||||||
#include <asm/pgtable.h>
|
|
||||||
#include <linux/fs.h>
|
|
||||||
#include <asm/uaccess.h>
|
|
||||||
#include <asm/delay.h>
|
|
||||||
#include <linux/interrupt.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// GLOBALS
|
// GLOBALS
|
||||||
|
@ -57,20 +50,18 @@ BOOLEAN bInPageFaultHandler = FALSE;
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
////
|
////
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// HandleInDebuggerFault()
|
// HandleInDebuggerFault()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
ULONG HandleInDebuggerFault(FRAME* ptr,ULONG address)
|
ULONG HandleInDebuggerFault(FRAME* ptr,ULONG address)
|
||||||
{
|
{
|
||||||
struct task_struct *tsk;
|
PEPROCESS tsk;
|
||||||
struct mm_struct *mm;
|
|
||||||
struct mm_struct *p = NULL;
|
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
DPRINT((0,"HandleInDebuggerFault(): ###### page fault @ %.8X while inside debugger\n",address));
|
DPRINT((0,"HandleInDebuggerFault(): ###### page fault @ %.8X while inside debugger\n",address));
|
||||||
|
|
||||||
// fault in this page fault handler
|
// fault in this page fault handler
|
||||||
if(bInPageFaultHandler)
|
if(bInPageFaultHandler)
|
||||||
{
|
{
|
||||||
|
@ -88,10 +79,9 @@ ULONG HandleInDebuggerFault(FRAME* ptr,ULONG address)
|
||||||
|
|
||||||
// when we come here from DebuggerShell() we live on a different stack
|
// when we come here from DebuggerShell() we live on a different stack
|
||||||
// so the current task is different as well
|
// so the current task is different as well
|
||||||
tsk = (struct task_struct *)(0xFFFFE000 & ulRealStackPtr);
|
tsk = IoGetCurrentProcess();
|
||||||
mm = tsk->mm;
|
|
||||||
|
|
||||||
DPRINT((0,"%.8X (%.4X:%.8X %.8X %s %s %s task=%.8X mm=%.8X)\n",
|
DPRINT((0,"%.8X (%.4X:%.8X %.8X %s %s %s task=%.8X )\n",
|
||||||
address,
|
address,
|
||||||
ptr->cs,
|
ptr->cs,
|
||||||
ptr->eip,
|
ptr->eip,
|
||||||
|
@ -99,8 +89,7 @@ ULONG HandleInDebuggerFault(FRAME* ptr,ULONG address)
|
||||||
(ptr->error_code&1)?"PLP":"NP",
|
(ptr->error_code&1)?"PLP":"NP",
|
||||||
(ptr->error_code&2)?"WRITE":"READ",
|
(ptr->error_code&2)?"WRITE":"READ",
|
||||||
(ptr->error_code&4)?"USER-MODE":"KERNEL-MODE",
|
(ptr->error_code&4)?"USER-MODE":"KERNEL-MODE",
|
||||||
(ULONG)tsk,
|
(ULONG)tsk);
|
||||||
(ULONG)mm));
|
|
||||||
|
|
||||||
if(!bInPrintk)
|
if(!bInPrintk)
|
||||||
{
|
{
|
||||||
|
@ -111,39 +100,24 @@ ULONG HandleInDebuggerFault(FRAME* ptr,ULONG address)
|
||||||
DPRINT((0,"HandleInDebuggerFault(): unexpected pagefault in command handler while in PrintkCallback()!\n",address));
|
DPRINT((0,"HandleInDebuggerFault(): unexpected pagefault in command handler while in PrintkCallback()!\n",address));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(tsk)
|
||||||
if(address < TASK_SIZE)
|
|
||||||
{
|
{
|
||||||
p = mm;
|
PULONG pPGD;
|
||||||
}
|
PULONG pPTE;
|
||||||
else
|
|
||||||
{
|
|
||||||
p = my_init_mm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p)
|
|
||||||
{
|
|
||||||
pgd_t * pPGD;
|
|
||||||
pmd_t * pPMD;
|
|
||||||
pte_t * pPTE;
|
|
||||||
|
|
||||||
pPGD = pgd_offset(p,address);
|
pPGD = ADDR_TO_PDE(address);
|
||||||
|
|
||||||
DPRINT((0,"PGD for %.8X @ %.8X = %.8X\n",address,(ULONG)pPGD,(ULONG)pgd_val(*pPGD) ));
|
DPRINT((0,"PGD for %.8X @ %.8X = %.8X\n",address,(ULONG)pPGD,(ULONG)(*pPGD) ));
|
||||||
|
|
||||||
if(pPGD && pgd_val(*pPGD)&_PAGE_PRESENT)
|
if(pPGD && (*pPGD)&_PAGE_PRESENT)
|
||||||
{
|
{
|
||||||
// not large page
|
// not large page
|
||||||
if(!(pgd_val(*pPGD)&_PAGE_4M))
|
if(!((*pPGD)&_PAGE_4M))
|
||||||
{
|
{
|
||||||
pPMD = pmd_offset(pPGD,address);
|
pPTE = ADDR_TO_PTE(address);
|
||||||
if(pPMD)
|
if(pPTE)
|
||||||
{
|
{
|
||||||
pPTE = pte_offset(pPMD,address);
|
DPRINT((0,"PTE for %.8X @ %.8X = %.8X\n",address,(ULONG)pPTE,(ULONG)(*pPTE) ));
|
||||||
if(pPTE)
|
|
||||||
{
|
|
||||||
DPRINT((0,"PTE for %.8X @ %.8X = %.8X\n",address,(ULONG)pPTE,(ULONG)pte_val(*pPTE) ));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,26 +134,27 @@ ULONG HandleInDebuggerFault(FRAME* ptr,ULONG address)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// HandlePageFault()
|
// HandlePageFault()
|
||||||
//
|
//
|
||||||
// returns:
|
// returns:
|
||||||
// 0 = let the system handle it
|
// 0 = let the system handle it
|
||||||
// 1 = call DebuggerShell()
|
// 1 = call DebuggerShell()
|
||||||
// 2 = FATAL error inside debugger
|
// 2 = FATAL error inside debugger
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
ULONG HandlePageFault(FRAME* ptr)
|
ULONG HandlePageFault(FRAME* ptr)
|
||||||
{
|
{
|
||||||
ULONG address;
|
ULONG address;
|
||||||
struct task_struct *tsk;
|
PEPROCESS tsk;
|
||||||
struct mm_struct *mm;
|
PMADDRESS_SPACE vma;
|
||||||
struct vm_area_struct * vma;
|
PLIST_ENTRY current_entry;
|
||||||
|
MEMORY_AREA* current;
|
||||||
|
|
||||||
// get linear address of page fault
|
// get linear address of page fault
|
||||||
__asm__("movl %%cr2,%0":"=r" (address));
|
__asm__("movl %%cr2,%0":"=r" (address));
|
||||||
|
|
||||||
// current process
|
// current process
|
||||||
tsk = current;
|
tsk = IoGetCurrentProcess();
|
||||||
|
|
||||||
// there's something terribly wrong if we get a fault in our command handler
|
// there's something terribly wrong if we get a fault in our command handler
|
||||||
if(bInDebuggerShell)
|
if(bInDebuggerShell)
|
||||||
|
@ -190,116 +165,77 @@ ULONG HandlePageFault(FRAME* ptr)
|
||||||
// remember error code so we can push it back on the stack
|
// remember error code so we can push it back on the stack
|
||||||
error_code = ptr->error_code;
|
error_code = ptr->error_code;
|
||||||
|
|
||||||
//////////////////////////////////////
|
|
||||||
// kernel page fault
|
|
||||||
|
|
||||||
// since LINUX kernel is not pageable this is death
|
|
||||||
// so call handler
|
|
||||||
if(address >= TASK_SIZE)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
if(error_code & 4)
|
|
||||||
{
|
|
||||||
PICE_sprintf(tempPageFault,"pICE: kernel page fault from user-mode code (error code %x)!\n",error_code);
|
|
||||||
Print(OUTPUT_WINDOW,tempPageFault);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PICE_sprintf(tempPageFault,"pICE: kernel page fault from kernel-mode code (error code %x)!\n",error_code);
|
|
||||||
Print(OUTPUT_WINDOW,tempPageFault);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// and it's memory environment
|
|
||||||
mm = tsk->mm;
|
|
||||||
|
|
||||||
//////////////////////////////////////
|
|
||||||
// user page fault
|
|
||||||
// fault address is below TASK_SIZE
|
|
||||||
|
|
||||||
// no user context, i.e. no pages below TASK_SIZE are mapped
|
|
||||||
if(mm == my_init_mm)
|
|
||||||
{
|
|
||||||
Print(OUTPUT_WINDOW,"pICE: there's no user context!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// interrupt handlers can't have page faults
|
// interrupt handlers can't have page faults
|
||||||
|
/*
|
||||||
if(in_interrupt())
|
if(in_interrupt())
|
||||||
{
|
{
|
||||||
Print(OUTPUT_WINDOW,"pICE: system is currently processing an interrupt!\n");
|
Print(OUTPUT_WINDOW,"pICE: system is currently processing an interrupt!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// lookup VMA for this address
|
// lookup VMA for this address
|
||||||
vma = find_vma(mm, address);
|
vma = &(my_current->AddressSpace);
|
||||||
if(!vma)
|
current_entry = vma->MAreaListHead.Flink;
|
||||||
{
|
while(current_entry != &vma->MAreaListHead)
|
||||||
Print(OUTPUT_WINDOW,"pICE: no virtual memory arena at this address!\n");
|
{
|
||||||
return 1;
|
current = CONTAINING_RECORD(current_entry,
|
||||||
}
|
MEMORY_AREA,
|
||||||
|
Entry);
|
||||||
|
if( (address >= current->BaseAddress) && (address <= current->BaseAddress + current->Length ))
|
||||||
|
{
|
||||||
|
if(error_code & 2)
|
||||||
|
{
|
||||||
|
// area was not writable
|
||||||
|
if(!(current->Attributes & PAGE_READONLY))
|
||||||
|
{
|
||||||
|
Print(OUTPUT_WINDOW,"pICE: virtual memory arena is not writeable!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// READ ACCESS
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// test EXT bit in error code
|
||||||
|
if (error_code & 1)
|
||||||
|
{
|
||||||
|
Print(OUTPUT_WINDOW,"pICE: page-level protection fault!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!(current->Attributes & PAGE_EXECUTE_READ))
|
||||||
|
{
|
||||||
|
Print(OUTPUT_WINDOW,"pICE: VMA is not readable!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// let the system handle it
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
current_entry = current_entry->Flink;
|
||||||
|
}
|
||||||
|
|
||||||
// address is greater than the start of this VMA
|
Print(OUTPUT_WINDOW,"pICE: no virtual memory arena at this address!\n");
|
||||||
if (address >= vma->vm_start)
|
return 1;
|
||||||
{
|
|
||||||
// WRITE ACCESS
|
|
||||||
// write bit set in error_code
|
|
||||||
if(error_code & 2)
|
|
||||||
{
|
|
||||||
// area was not writable
|
|
||||||
if(!(vma->vm_flags & VM_WRITE))
|
|
||||||
{
|
|
||||||
Print(OUTPUT_WINDOW,"pICE: virtual memory arena is not writeable!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// READ ACCESS
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// test EXT bit in error code
|
|
||||||
if (error_code & 1)
|
|
||||||
{
|
|
||||||
Print(OUTPUT_WINDOW,"pICE: page-level protection fault!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
|
|
||||||
{
|
|
||||||
Print(OUTPUT_WINDOW,"pICE: VMA is not readable!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// let the system handle it
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (!(vma->vm_flags & VM_GROWSDOWN))
|
|
||||||
{
|
|
||||||
Print(OUTPUT_WINDOW,"pICE: virtual memory arena doesn't grow down!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// let the system handle it
|
// let the system handle it
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// NewIntEHandler()
|
// NewIntEHandler()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
__asm__ ("
|
__asm__ ("
|
||||||
NewIntEHandler:
|
NewIntEHandler:
|
||||||
pushfl
|
pushfl
|
||||||
cli
|
cli
|
||||||
cld
|
cld
|
||||||
pushal
|
pushal
|
||||||
pushl %ds
|
pushl %ds
|
||||||
|
|
||||||
// setup default data selectors
|
// setup default data selectors
|
||||||
movw %ss,%ax
|
movw %ss,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
|
|
||||||
// get frame ptr
|
// get frame ptr
|
||||||
lea 40(%esp),%eax
|
lea 40(%esp),%eax
|
||||||
|
@ -313,18 +249,18 @@ NewIntEHandler:
|
||||||
cmpl $2,%eax
|
cmpl $2,%eax
|
||||||
je call_handler_unknown_reason
|
je call_handler_unknown_reason
|
||||||
|
|
||||||
popl %ds
|
popl %ds
|
||||||
popal
|
popal
|
||||||
popfl
|
popfl
|
||||||
// remove error code. will be restored later when we call
|
// remove error code. will be restored later when we call
|
||||||
// original handler again.
|
// original handler again.
|
||||||
addl $4,%esp
|
addl $4,%esp
|
||||||
// call debugger loop
|
// call debugger loop
|
||||||
pushl $" STR(REASON_PAGEFAULT) "
|
pushl $" STR(REASON_PAGEFAULT) "
|
||||||
jmp NewInt31Handler
|
jmp NewInt31Handler
|
||||||
|
|
||||||
call_old_inte_handler:
|
call_old_inte_handler:
|
||||||
popl %ds
|
popl %ds
|
||||||
popal
|
popal
|
||||||
popfl
|
popfl
|
||||||
// chain to old handler
|
// chain to old handler
|
||||||
|
@ -332,22 +268,22 @@ call_old_inte_handler:
|
||||||
jmp *OldIntEHandler
|
jmp *OldIntEHandler
|
||||||
|
|
||||||
call_handler_unknown_reason:
|
call_handler_unknown_reason:
|
||||||
popl %ds
|
popl %ds
|
||||||
popal
|
popal
|
||||||
popfl
|
popfl
|
||||||
// remove error code. will be restored later when we call
|
// remove error code. will be restored later when we call
|
||||||
// original handler again.
|
// original handler again.
|
||||||
addl $4,%esp
|
addl $4,%esp
|
||||||
// call debugger loop
|
// call debugger loop
|
||||||
pushl $" STR(REASON_INTERNAL_ERROR) "
|
pushl $" STR(REASON_INTERNAL_ERROR) "
|
||||||
jmp NewInt31Handler
|
jmp NewInt31Handler
|
||||||
");
|
");
|
||||||
|
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// InstallIntEHook()
|
// InstallIntEHook()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void InstallIntEHook(void)
|
void InstallIntEHook(void)
|
||||||
{
|
{
|
||||||
ULONG LocalIntEHandler;
|
ULONG LocalIntEHandler;
|
||||||
|
@ -368,10 +304,10 @@ void InstallIntEHook(void)
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// DeInstallIntEHook()
|
// DeInstallIntEHook()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void DeInstallIntEHook(void)
|
void DeInstallIntEHook(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
|
@ -15,7 +15,7 @@ Environment:
|
||||||
LINUX 2.2.X
|
LINUX 2.2.X
|
||||||
Kernel mode only
|
Kernel mode only
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
Klaus P. Gerlicher
|
Klaus P. Gerlicher
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ Copyright notice:
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include <asm/io.h>
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include "serial_port.h"
|
#include "serial_port.h"
|
||||||
|
|
||||||
|
@ -72,17 +71,17 @@ void SerialSetSpeed(ULONG baudrate)
|
||||||
divisor = (ULONG) (115200L/baudrate);
|
divisor = (ULONG) (115200L/baudrate);
|
||||||
|
|
||||||
c = inportb((USHORT)(usSerialPortBase + LCR));
|
c = inportb((USHORT)(usSerialPortBase + LCR));
|
||||||
outportb((USHORT)(usSerialPortBase + LCR), (UCHAR)(c | 0x80)); // Set DLAB
|
outportb((USHORT)(usSerialPortBase + LCR), (UCHAR)(c | 0x80)); // Set DLAB
|
||||||
outportb((USHORT)(usSerialPortBase + DLL), (UCHAR)(divisor & 0x00FF));
|
outportb((USHORT)(usSerialPortBase + DLL), (UCHAR)(divisor & 0x00FF));
|
||||||
outportb((USHORT)(usSerialPortBase + DLH), (UCHAR)((divisor >> 8) & 0x00FF));
|
outportb((USHORT)(usSerialPortBase + DLH), (UCHAR)((divisor >> 8) & 0x00FF));
|
||||||
outportb((USHORT)(usSerialPortBase + LCR), c); // Reset DLAB
|
outportb((USHORT)(usSerialPortBase + LCR), c); // Reset DLAB
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///************************************************************************
|
///************************************************************************
|
||||||
// SerialSetOthers()
|
// SerialSetOthers()
|
||||||
//
|
//
|
||||||
// Set other communications parameters
|
// Set other communications parameters
|
||||||
//************************************************************************
|
//************************************************************************
|
||||||
void SerialSetOthers(ULONG Parity, ULONG Bits, ULONG StopBit)
|
void SerialSetOthers(ULONG Parity, ULONG Bits, ULONG StopBit)
|
||||||
{
|
{
|
||||||
|
@ -100,13 +99,13 @@ void SerialSetOthers(ULONG Parity, ULONG Bits, ULONG StopBit)
|
||||||
setting |= Parity;
|
setting |= Parity;
|
||||||
|
|
||||||
c = inportb((USHORT)(usSerialPortBase + LCR));
|
c = inportb((USHORT)(usSerialPortBase + LCR));
|
||||||
outportb((USHORT)(usSerialPortBase + LCR), (UCHAR)(c & ~0x80)); // Reset DLAB
|
outportb((USHORT)(usSerialPortBase + LCR), (UCHAR)(c & ~0x80)); // Reset DLAB
|
||||||
|
|
||||||
// no ints
|
// no ints
|
||||||
outportb((USHORT)(usSerialPortBase + IER), (UCHAR)0);
|
outportb((USHORT)(usSerialPortBase + IER), (UCHAR)0);
|
||||||
|
|
||||||
// clear FIFO and disable them
|
// clear FIFO and disable them
|
||||||
outportb((USHORT)(usSerialPortBase + FCR), (UCHAR)0);
|
outportb((USHORT)(usSerialPortBase + FCR), (UCHAR)0);
|
||||||
|
|
||||||
outportb((USHORT)(usSerialPortBase + LCR), (UCHAR)setting);
|
outportb((USHORT)(usSerialPortBase + LCR), (UCHAR)setting);
|
||||||
|
|
||||||
|
@ -148,7 +147,7 @@ void SetupSerial(ULONG port,ULONG baudrate)
|
||||||
///************************************************************************
|
///************************************************************************
|
||||||
// SerialReadByte()
|
// SerialReadByte()
|
||||||
//
|
//
|
||||||
// Output a character to the serial port
|
// Output a character to the serial port
|
||||||
//************************************************************************
|
//************************************************************************
|
||||||
BOOLEAN SerialReadByte(PUCHAR px)
|
BOOLEAN SerialReadByte(PUCHAR px)
|
||||||
{
|
{
|
||||||
|
@ -156,7 +155,7 @@ BOOLEAN SerialReadByte(PUCHAR px)
|
||||||
|
|
||||||
timeout = 0x00FFFFL;
|
timeout = 0x00FFFFL;
|
||||||
|
|
||||||
// Wait for transmitter to clear
|
// Wait for transmitter to clear
|
||||||
while ((inportb((USHORT)(usSerialPortBase + LSR)) & RCVRDY) == 0)
|
while ((inportb((USHORT)(usSerialPortBase + LSR)) & RCVRDY) == 0)
|
||||||
if (!(--timeout))
|
if (!(--timeout))
|
||||||
{
|
{
|
||||||
|
@ -171,7 +170,7 @@ BOOLEAN SerialReadByte(PUCHAR px)
|
||||||
///************************************************************************
|
///************************************************************************
|
||||||
// SerialSendByte()
|
// SerialSendByte()
|
||||||
//
|
//
|
||||||
// Output a character to the serial port
|
// Output a character to the serial port
|
||||||
//************************************************************************
|
//************************************************************************
|
||||||
BOOLEAN SerialSendByte(UCHAR x)
|
BOOLEAN SerialSendByte(UCHAR x)
|
||||||
{
|
{
|
||||||
|
@ -179,7 +178,7 @@ BOOLEAN SerialSendByte(UCHAR x)
|
||||||
|
|
||||||
timeout = 0x00FFFFL;
|
timeout = 0x00FFFFL;
|
||||||
|
|
||||||
// Wait for transmitter to clear
|
// Wait for transmitter to clear
|
||||||
while ((inportb((USHORT)(usSerialPortBase + LSR)) & XMTRDY) == 0)
|
while ((inportb((USHORT)(usSerialPortBase + LSR)) & XMTRDY) == 0)
|
||||||
if (!(--timeout))
|
if (!(--timeout))
|
||||||
{
|
{
|
||||||
|
@ -244,14 +243,14 @@ BOOLEAN SendPacket(PSERIAL_PACKET p)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
c = 0;
|
c = 0;
|
||||||
SerialReadByte(&c);
|
SerialReadByte(&c);
|
||||||
if(c != ACK)
|
if(c != ACK)
|
||||||
ucLastKeyRead = c;
|
ucLastKeyRead = c;
|
||||||
}while(c != ACK && timeout--);
|
}while(c != ACK && timeout--);
|
||||||
|
|
||||||
}while(c != ACK);
|
}while(c != ACK);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,9 +296,9 @@ PSERIAL_PACKET AssemblePacket(PUCHAR pData,ULONG ulSize)
|
||||||
{
|
{
|
||||||
PSERIAL_PACKET p;
|
PSERIAL_PACKET p;
|
||||||
ULONG ulCheckSum;
|
ULONG ulCheckSum;
|
||||||
|
|
||||||
p = (PSERIAL_PACKET)assemble_packet;
|
p = (PSERIAL_PACKET)assemble_packet;
|
||||||
|
|
||||||
// fill in header
|
// fill in header
|
||||||
p->header.packet_chksum = CheckSum(pData,ulSize);
|
p->header.packet_chksum = CheckSum(pData,ulSize);
|
||||||
p->header.packet_size = ulSize;
|
p->header.packet_size = ulSize;
|
||||||
|
@ -307,8 +306,8 @@ PSERIAL_PACKET AssemblePacket(PUCHAR pData,ULONG ulSize)
|
||||||
ulCheckSum = (ULONG)CheckSum((PUCHAR)p,sizeof(SERIAL_PACKET_HEADER));
|
ulCheckSum = (ULONG)CheckSum((PUCHAR)p,sizeof(SERIAL_PACKET_HEADER));
|
||||||
p->header.packet_header_chksum = ulCheckSum;
|
p->header.packet_header_chksum = ulCheckSum;
|
||||||
// attach data to packet
|
// attach data to packet
|
||||||
PICE_memcpy(p->data,pData,ulSize);
|
PICE_memcpy(p->data,pData,ulSize);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +339,7 @@ void SetBackgroundColorSerial(ECOLORS col)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void PrintGrafSerial(ULONG x,ULONG y,UCHAR c)
|
void PrintGrafSerial(ULONG x,ULONG y,UCHAR c)
|
||||||
{
|
{
|
||||||
// put this into memory
|
// put this into memory
|
||||||
pScreenBufferSerial[y*GLOBAL_SCREEN_WIDTH + x] = c;
|
pScreenBufferSerial[y*GLOBAL_SCREEN_WIDTH + x] = c;
|
||||||
|
|
||||||
// put this into cache
|
// put this into cache
|
||||||
|
@ -387,7 +386,7 @@ void ShowCursorSerial(void)
|
||||||
PSERIAL_PACKET p;
|
PSERIAL_PACKET p;
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
bCursorEnabled = TRUE;
|
bCursorEnabled = TRUE;
|
||||||
|
|
||||||
pCursor = (PSERIAL_DATA_PACKET_CURSOR)packet;
|
pCursor = (PSERIAL_DATA_PACKET_CURSOR)packet;
|
||||||
|
@ -413,7 +412,7 @@ void HideCursorSerial(void)
|
||||||
PSERIAL_PACKET p;
|
PSERIAL_PACKET p;
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
bCursorEnabled = FALSE;
|
bCursorEnabled = FALSE;
|
||||||
|
|
||||||
pCursor = (PSERIAL_DATA_PACKET_CURSOR)packet;
|
pCursor = (PSERIAL_DATA_PACKET_CURSOR)packet;
|
||||||
|
@ -536,7 +535,7 @@ UCHAR GetKeyPolledSerial(void)
|
||||||
pPoll->type = PACKET_TYPE_POLL;
|
pPoll->type = PACKET_TYPE_POLL;
|
||||||
pPoll->major_version = PICE_MAJOR_VERSION;
|
pPoll->major_version = PICE_MAJOR_VERSION;
|
||||||
pPoll->minor_version = PICE_MINOR_VERSION;
|
pPoll->minor_version = PICE_MINOR_VERSION;
|
||||||
pPoll->build_number = PICE_BUILD;
|
pPoll->build_number = PICE_BUILD;
|
||||||
|
|
||||||
p = AssemblePacket((PUCHAR)pPoll,sizeof(SERIAL_DATA_PACKET_POLL));
|
p = AssemblePacket((PUCHAR)pPoll,sizeof(SERIAL_DATA_PACKET_POLL));
|
||||||
SendPacket(p);
|
SendPacket(p);
|
||||||
|
@ -580,7 +579,7 @@ BOOLEAN Connect(USHORT xSize,USHORT ySize)
|
||||||
//
|
//
|
||||||
// init terminal screen
|
// init terminal screen
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
BOOLEAN ConsoleInitSerial(void)
|
BOOLEAN ConsoleInitSerial(void)
|
||||||
{
|
{
|
||||||
BOOLEAN bResult = FALSE;
|
BOOLEAN bResult = FALSE;
|
||||||
|
|
||||||
|
@ -609,7 +608,7 @@ BOOLEAN ConsoleInitSerial(void)
|
||||||
GLOBAL_SCREEN_WIDTH = 80;
|
GLOBAL_SCREEN_WIDTH = 80;
|
||||||
GLOBAL_SCREEN_HEIGHT = 60;
|
GLOBAL_SCREEN_HEIGHT = 60;
|
||||||
|
|
||||||
pScreenBufferSerial = PICE_malloc(FRAMEBUFFER_SIZE, NONPAGEDPOOL);
|
pScreenBufferSerial = PICE_malloc(FRAMEBUFFER_SIZE, NONPAGEDPOOL);
|
||||||
|
|
||||||
if(pScreenBufferSerial)
|
if(pScreenBufferSerial)
|
||||||
{
|
{
|
||||||
|
@ -639,7 +638,7 @@ BOOLEAN ConsoleInitSerial(void)
|
||||||
//
|
//
|
||||||
// exit terminal screen
|
// exit terminal screen
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void ConsoleShutdownSerial(void)
|
void ConsoleShutdownSerial(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,6 @@ Copyright notice:
|
||||||
////
|
////
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include <asm/io.h>
|
|
||||||
#include <linux/interrupt.h>
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
@ -133,7 +131,10 @@ volatile BOOLEAN bSingleStep=FALSE;
|
||||||
// the last command lines
|
// the last command lines
|
||||||
char aszCommandLines[LINES_IN_COMMAND_BUFFER][sizeof(ucCommandBuffer)+2];
|
char aszCommandLines[LINES_IN_COMMAND_BUFFER][sizeof(ucCommandBuffer)+2];
|
||||||
ULONG ulCommandInPos=0,ulCommandLastPos=0;
|
ULONG ulCommandInPos=0,ulCommandLastPos=0;
|
||||||
ULONG ulCommandCurrentPos=0;
|
ULONG ulCommandCurrentPos=0;
|
||||||
|
|
||||||
|
|
||||||
|
extern ULONG KeyboardIRQL;
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// GetLinesInCommandHistory()
|
// GetLinesInCommandHistory()
|
||||||
|
@ -200,7 +201,7 @@ LPSTR GetFromCommandLineHistory(ULONG ulCurrentCommandPos)
|
||||||
|
|
||||||
// skip leading ':'
|
// skip leading ':'
|
||||||
pRet = aszCommandLines[ulCurrentCommandPos] + 1;
|
pRet = aszCommandLines[ulCurrentCommandPos] + 1;
|
||||||
|
|
||||||
DPRINT((0,"GetFromCommandLineHistory(%s)\n",pRet));
|
DPRINT((0,"GetFromCommandLineHistory(%s)\n",pRet));
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
|
@ -214,13 +215,11 @@ LPSTR GetFromCommandLineHistory(ULONG ulCurrentCommandPos)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void ShowStatusLine(void)
|
void ShowStatusLine(void)
|
||||||
{
|
{
|
||||||
struct task_struct* pCurrentProcess;
|
PEPROCESS pCurrentProcess = IoGetCurrentProcess();
|
||||||
LPSTR pProcessName;
|
LPSTR pProcessName;
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
pCurrentProcess = (struct task_struct*)(0xFFFFE000&ulRealStackPtr);
|
|
||||||
|
|
||||||
if(IsAddressValid((ULONG)pCurrentProcess))
|
if(IsAddressValid((ULONG)pCurrentProcess))
|
||||||
{
|
{
|
||||||
SetForegroundColor(COLOR_TEXT);
|
SetForegroundColor(COLOR_TEXT);
|
||||||
|
@ -228,7 +227,7 @@ void ShowStatusLine(void)
|
||||||
|
|
||||||
ClrLine(wWindow[OUTPUT_WINDOW].y-1);
|
ClrLine(wWindow[OUTPUT_WINDOW].y-1);
|
||||||
|
|
||||||
pProcessName = pCurrentProcess->comm;
|
pProcessName = pCurrentProcess->ImageFileName;
|
||||||
if(IsAddressValid((ULONG)pProcessName) )
|
if(IsAddressValid((ULONG)pProcessName) )
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,
|
PICE_sprintf(tempShell,
|
||||||
|
@ -296,52 +295,52 @@ void ProcessBootParams(void)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
BOOLEAN inline bNoCtrlKeys(void)
|
BOOLEAN inline bNoCtrlKeys(void)
|
||||||
{
|
{
|
||||||
return (!bControl && !bAlt && !bShift);
|
return (!bControl && !bAlt && !bShift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// DebuggerShell()
|
// DebuggerShell()
|
||||||
//
|
//
|
||||||
// handle user interface when stopped system
|
// handle user interface when stopped system
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void DebuggerShell(void)
|
void DebuggerShell(void)
|
||||||
{
|
{
|
||||||
ARGS Args;
|
ARGS Args;
|
||||||
UCHAR speaker;
|
UCHAR speaker;
|
||||||
struct task_struct* pCurrentProcess;
|
PEPROCESS pCurrentProcess;
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
// save the graphics state
|
// save the graphics state
|
||||||
SaveGraphicsState();
|
SaveGraphicsState();
|
||||||
|
|
||||||
// tell USER we are stopped
|
// tell USER we are stopped
|
||||||
ShowStoppedMsg();
|
ShowStoppedMsg();
|
||||||
|
|
||||||
FlushKeyboardQueue();
|
FlushKeyboardQueue();
|
||||||
|
|
||||||
CheckRingBuffer();
|
CheckRingBuffer();
|
||||||
|
|
||||||
// kill the speakers annoying beep
|
// kill the speakers annoying beep
|
||||||
speaker = inb_p(0x61);
|
speaker = inb_p(0x61);
|
||||||
speaker &= 0xFC;
|
speaker &= 0xFC;
|
||||||
outb_p(speaker,0x61);
|
outb_p(speaker,0x61);
|
||||||
|
|
||||||
ProcessBootParams();
|
ProcessBootParams();
|
||||||
|
|
||||||
DPRINT((0,"DebuggerShell(): DisplayRegs()\n"));
|
DPRINT((0,"DebuggerShell(): DisplayRegs()\n"));
|
||||||
// display register contents
|
// display register contents
|
||||||
DisplayRegs();
|
DisplayRegs();
|
||||||
|
|
||||||
DPRINT((0,"DebuggerShell(): DisplayMemory()\n"));
|
DPRINT((0,"DebuggerShell(): DisplayMemory()\n"));
|
||||||
// display data window
|
// display data window
|
||||||
Args.Value[0]=OldSelector;
|
Args.Value[0]=OldSelector;
|
||||||
Args.Value[1]=OldOffset;
|
Args.Value[1]=OldOffset;
|
||||||
Args.Count=2;
|
Args.Count=2;
|
||||||
DisplayMemory(&Args);
|
DisplayMemory(&Args);
|
||||||
|
|
||||||
DPRINT((0,"DebuggerShell(): Unassemble()\n"));
|
DPRINT((0,"DebuggerShell(): Unassemble()\n"));
|
||||||
|
|
||||||
// disassembly from current address
|
// disassembly from current address
|
||||||
PICE_memset(&Args,0,sizeof(ARGS));
|
PICE_memset(&Args,0,sizeof(ARGS));
|
||||||
|
@ -351,14 +350,14 @@ void DebuggerShell(void)
|
||||||
Unassemble(&Args);
|
Unassemble(&Args);
|
||||||
|
|
||||||
// try to find current process's name
|
// try to find current process's name
|
||||||
pCurrentProcess = (struct task_struct*)(0xFFFFE000&ulRealStackPtr);
|
pCurrentProcess = = IoGetCurrentProcess();
|
||||||
CurrentProcess = (ULONG)pCurrentProcess;
|
CurrentProcess = (ULONG)pCurrentProcess;
|
||||||
|
|
||||||
// display status line
|
// display status line
|
||||||
ShowStatusLine();
|
ShowStatusLine();
|
||||||
|
|
||||||
// switch on cursor
|
// switch on cursor
|
||||||
ShowCursor();
|
ShowCursor();
|
||||||
|
|
||||||
// while we are not told to exit
|
// while we are not told to exit
|
||||||
while(bNotifyToExit==FALSE)
|
while(bNotifyToExit==FALSE)
|
||||||
|
@ -416,7 +415,7 @@ void DebuggerShell(void)
|
||||||
if(ucConverted == 'f')
|
if(ucConverted == 'f')
|
||||||
bNotifyToExit = TRUE;
|
bNotifyToExit = TRUE;
|
||||||
}
|
}
|
||||||
// normal key while holding down ALT
|
// normal key while holding down ALT
|
||||||
else if(!bControl && bAlt && !bShift && ucConverted)
|
else if(!bControl && bAlt && !bShift && ucConverted)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -426,9 +425,9 @@ void DebuggerShell(void)
|
||||||
}
|
}
|
||||||
// we didn't get a converted key
|
// we didn't get a converted key
|
||||||
// so this must be a control key
|
// so this must be a control key
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// RETURN
|
// RETURN
|
||||||
if(bNoCtrlKeys() && ucKeyPressedWhileIdle == SCANCODE_ENTER)
|
if(bNoCtrlKeys() && ucKeyPressedWhileIdle == SCANCODE_ENTER)
|
||||||
{
|
{
|
||||||
DPRINT((0,"DebuggerShell(): RETURN\n"));
|
DPRINT((0,"DebuggerShell(): RETURN\n"));
|
||||||
|
@ -451,7 +450,7 @@ void DebuggerShell(void)
|
||||||
pushl %%eax
|
pushl %%eax
|
||||||
call Parse
|
call Parse
|
||||||
movl %0,%%ebx
|
movl %0,%%ebx
|
||||||
movl %%ebx,%%esp"
|
movl %%ebx,%%esp"
|
||||||
:"=m" (ulOldStack)
|
:"=m" (ulOldStack)
|
||||||
:"m" (ulOldStack),"m" (ucCommandBuffer)
|
:"m" (ulOldStack),"m" (ucCommandBuffer)
|
||||||
:"eax","ebx");
|
:"eax","ebx");
|
||||||
|
@ -492,7 +491,7 @@ void DebuggerShell(void)
|
||||||
if(usCurrentPosInInputBuffer)
|
if(usCurrentPosInInputBuffer)
|
||||||
{
|
{
|
||||||
LPSTR pCmd;
|
LPSTR pCmd;
|
||||||
|
|
||||||
if((pCmd=FindCommand(ucCommandBuffer)) )
|
if((pCmd=FindCommand(ucCommandBuffer)) )
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
@ -540,7 +539,7 @@ void DebuggerShell(void)
|
||||||
pushl %%eax
|
pushl %%eax
|
||||||
call Parse
|
call Parse
|
||||||
movl %0,%%ebx
|
movl %0,%%ebx
|
||||||
movl %%ebx,%%esp"
|
movl %%ebx,%%esp"
|
||||||
:"=m" (ulOldStack)
|
:"=m" (ulOldStack)
|
||||||
:"m" (ulOldStack),"m" (ucCommandBuffer)
|
:"m" (ulOldStack),"m" (ucCommandBuffer)
|
||||||
:"eax","ebx");
|
:"eax","ebx");
|
||||||
|
@ -702,7 +701,7 @@ void DebuggerShell(void)
|
||||||
// if it has a string attached
|
// if it has a string attached
|
||||||
if((len = PICE_strlen(pCurrentCmd)))
|
if((len = PICE_strlen(pCurrentCmd)))
|
||||||
{
|
{
|
||||||
// replace the current command line
|
// replace the current command line
|
||||||
PICE_sprintf(tempShell,":");
|
PICE_sprintf(tempShell,":");
|
||||||
ReplaceRingBufferCurrent(tempShell);
|
ReplaceRingBufferCurrent(tempShell);
|
||||||
PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer));
|
PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer));
|
||||||
|
@ -780,7 +779,7 @@ void DebuggerShell(void)
|
||||||
// if it has a string attached
|
// if it has a string attached
|
||||||
if((len = PICE_strlen(pCurrentCmd)))
|
if((len = PICE_strlen(pCurrentCmd)))
|
||||||
{
|
{
|
||||||
// replace the current command line
|
// replace the current command line
|
||||||
PICE_sprintf(tempShell,":");
|
PICE_sprintf(tempShell,":");
|
||||||
ReplaceRingBufferCurrent(tempShell);
|
ReplaceRingBufferCurrent(tempShell);
|
||||||
PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer));
|
PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer));
|
||||||
|
@ -995,32 +994,32 @@ void DebuggerShell(void)
|
||||||
|
|
||||||
PrintLogo(TRUE);
|
PrintLogo(TRUE);
|
||||||
|
|
||||||
ShowRunningMsg();
|
ShowRunningMsg();
|
||||||
|
|
||||||
if(bRev)
|
if(bRev)
|
||||||
PrintCursor(TRUE);
|
PrintCursor(TRUE);
|
||||||
|
|
||||||
// hide the cursor
|
// hide the cursor
|
||||||
HideCursor();
|
HideCursor();
|
||||||
|
|
||||||
FlushKeyboardQueue();
|
FlushKeyboardQueue();
|
||||||
|
|
||||||
RestoreGraphicsState();
|
RestoreGraphicsState();
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// RealIsr()
|
// RealIsr()
|
||||||
//
|
//
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void RealIsr(ULONG dwReasonForBreak)
|
void RealIsr(ULONG dwReasonForBreak)
|
||||||
{
|
{
|
||||||
DPRINT((0,"#################################################################\n"));
|
DPRINT((0,"#################################################################\n"));
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
// in handler
|
// in handler
|
||||||
bInDebuggerShell = TRUE;
|
bInDebuggerShell = TRUE;
|
||||||
|
|
||||||
bStepping = FALSE;
|
bStepping = FALSE;
|
||||||
|
|
||||||
|
@ -1030,18 +1029,18 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
bEnterNow = FALSE;
|
bEnterNow = FALSE;
|
||||||
|
|
||||||
// reset trace flag (TF) on the stack
|
// reset trace flag (TF) on the stack
|
||||||
CurrentEFL&=(~0x100);
|
CurrentEFL&=(~0x100);
|
||||||
|
|
||||||
InstallPrintkHook();
|
InstallPrintkHook();
|
||||||
|
|
||||||
// control is not depressed
|
// control is not depressed
|
||||||
bControl=FALSE;
|
bControl=FALSE;
|
||||||
|
|
||||||
bIrqStateAtBreak = ((CurrentEFL&(1<<9))!=0);
|
bIrqStateAtBreak = ((CurrentEFL&(1<<9))!=0);
|
||||||
|
|
||||||
// came in because TF flag was set
|
// came in because TF flag was set
|
||||||
if(dwReasonForBreak == REASON_SINGLESTEP)
|
if(dwReasonForBreak == REASON_SINGLESTEP)
|
||||||
{
|
{
|
||||||
ULONG ulAddress,ulAddressCurrent;
|
ULONG ulAddress,ulAddressCurrent;
|
||||||
|
|
||||||
DPRINT((0,"REASON_SINGLESTEP\n"));
|
DPRINT((0,"REASON_SINGLESTEP\n"));
|
||||||
|
@ -1076,11 +1075,11 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
if(bStepThroughSource)
|
if(bStepThroughSource)
|
||||||
{
|
{
|
||||||
// set TF flag
|
// set TF flag
|
||||||
CurrentEFL |= 0x100;
|
CurrentEFL |= 0x100;
|
||||||
}
|
}
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
DPRINT((0,"-----------------------------------------------------------------\n"));
|
DPRINT((0,"-----------------------------------------------------------------\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bPreviousCommandWasGo = FALSE;
|
bPreviousCommandWasGo = FALSE;
|
||||||
|
@ -1118,32 +1117,32 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
|
|
||||||
bInDebuggerShell = FALSE;
|
bInDebuggerShell = FALSE;
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
DPRINT((0,"-----------------------------------------------------------------\n"));
|
DPRINT((0,"-----------------------------------------------------------------\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bStepThroughSource = FALSE;
|
bStepThroughSource = FALSE;
|
||||||
bNotifyToExit = FALSE;
|
bNotifyToExit = FALSE;
|
||||||
bSkipMainLoop = FALSE;
|
bSkipMainLoop = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// came in because hardware register triggered a breakpoint
|
// came in because hardware register triggered a breakpoint
|
||||||
else if(dwReasonForBreak == REASON_HARDWARE_BP)
|
else if(dwReasonForBreak == REASON_HARDWARE_BP)
|
||||||
{
|
{
|
||||||
ULONG ulReason;
|
ULONG ulReason;
|
||||||
|
|
||||||
DPRINT((0,"REASON_HARDWARE_BP\n"));
|
DPRINT((0,"REASON_HARDWARE_BP\n"));
|
||||||
|
|
||||||
// disable HW breakpoints
|
// disable HW breakpoints
|
||||||
__asm__("
|
__asm__("
|
||||||
movl %%dr6,%%eax
|
movl %%dr6,%%eax
|
||||||
movl %%eax,%0
|
movl %%eax,%0
|
||||||
xorl %%eax,%%eax
|
xorl %%eax,%%eax
|
||||||
movl %%eax,%%dr6
|
movl %%eax,%%dr6
|
||||||
movl %%eax,%%dr7"
|
movl %%eax,%%dr7"
|
||||||
:"=m" (ulReason)
|
:"=m" (ulReason)
|
||||||
:
|
:
|
||||||
:"eax"
|
:"eax"
|
||||||
);
|
);
|
||||||
|
|
||||||
DPRINT((0,"REASON_HARDWARE_BP: %x\n",(ulReason&0xF)));
|
DPRINT((0,"REASON_HARDWARE_BP: %x\n",(ulReason&0xF)));
|
||||||
|
|
||||||
|
@ -1193,19 +1192,19 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
|
|
||||||
bInDebuggerShell = FALSE;
|
bInDebuggerShell = FALSE;
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
DPRINT((0,"-----------------------------------------------------------------\n"));
|
DPRINT((0,"-----------------------------------------------------------------\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bNotifyToExit = FALSE;
|
bNotifyToExit = FALSE;
|
||||||
bSkipMainLoop = FALSE;
|
bSkipMainLoop = FALSE;
|
||||||
bStepThroughSource = FALSE;
|
bStepThroughSource = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(dwReasonForBreak==REASON_INT3)
|
else if(dwReasonForBreak==REASON_INT3)
|
||||||
{
|
{
|
||||||
ULONG ulAddress;
|
ULONG ulAddress;
|
||||||
|
|
||||||
DPRINT((0,"REASON_INT3\n"));
|
DPRINT((0,"REASON_INT3\n"));
|
||||||
|
|
||||||
// must subtract one cause INT3s are generated after instructions execution
|
// must subtract one cause INT3s are generated after instructions execution
|
||||||
|
@ -1227,8 +1226,8 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
// do a callback
|
// do a callback
|
||||||
if( (p = IsPermanentSWBreakpoint(ulAddress)) )
|
if( (p = IsPermanentSWBreakpoint(ulAddress)) )
|
||||||
{
|
{
|
||||||
DPRINT((0,"permanent breakpoint\n"));
|
DPRINT((0,"permanent breakpoint\n"));
|
||||||
|
|
||||||
OldCS = CurrentCS;
|
OldCS = CurrentCS;
|
||||||
OldEIP = CurrentEIP;
|
OldEIP = CurrentEIP;
|
||||||
|
|
||||||
|
@ -1242,49 +1241,51 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
LPSTR pFind;
|
LPSTR pFind;
|
||||||
if(ScanExportsByAddress(&pFind,GetLinearAddress(CurrentCS,CurrentEIP)))
|
if(ScanExportsByAddress(&pFind,GetLinearAddress(CurrentCS,CurrentEIP)))
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: SW Breakpoint at %s (%.4X:%.8X)\n",pFind,CurrentCS,CurrentEIP);
|
PICE_sprintf(tempShell,"pICE: SW Breakpoint at %s (%.4X:%.8X)\n",pFind,CurrentCS,CurrentEIP);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: SW Breakpoint at %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
PICE_sprintf(tempShell,"pICE: SW Breakpoint at %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
||||||
}
|
}
|
||||||
Print(OUTPUT_WINDOW,tempShell);
|
Print(OUTPUT_WINDOW,tempShell);
|
||||||
}
|
}
|
||||||
CurrentEFL &= ~(1<<16); // clear resume flag
|
CurrentEFL &= ~(1<<16); // clear resume flag
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LPSTR pFind;
|
LPSTR pFind;
|
||||||
struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
|
PEPROCESS my_current = IoGetCurrentProcess();
|
||||||
|
|
||||||
(ULONG)my_current &= ulRealStackPtr;
|
|
||||||
|
|
||||||
// if no other debugger is running on this process and the address is
|
// if no other debugger is running on this process and the address is
|
||||||
// above TASK_SIZE we assume this to be a hard embedded INT3
|
// above TASK_SIZE we assume this to be a hard embedded INT3
|
||||||
#if REAL_LINUX_VERSION_CODE < 0x020400
|
/*
|
||||||
if(ulAddress<TASK_SIZE && !(my_current->flags & PF_PTRACED) )
|
#if REAL_LINUX_VERSION_CODE < 0x020400
|
||||||
#else
|
if(ulAddress<TASK_SIZE && !(my_current->flags & PF_PTRACED) )
|
||||||
if(ulAddress<TASK_SIZE && !(my_current->ptrace & PT_PTRACED) )
|
#else
|
||||||
#endif
|
if(ulAddress<TASK_SIZE && !(my_current->ptrace & PT_PTRACED) )
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
if( ulAddress )
|
||||||
{
|
{
|
||||||
if(ScanExportsByAddress(&pFind,GetLinearAddress(CurrentCS,CurrentEIP)))
|
if(ScanExportsByAddress(&pFind,GetLinearAddress(CurrentCS,CurrentEIP)))
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at %s (%.4X:%.8X)\n",pFind,CurrentCS,CurrentEIP);
|
PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at %s (%.4X:%.8X)\n",pFind,CurrentCS,CurrentEIP);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at user-mode address %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at user-mode address %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
||||||
}
|
}
|
||||||
Print(OUTPUT_WINDOW,tempShell);
|
Print(OUTPUT_WINDOW,tempShell);
|
||||||
CurrentEFL &= ~(1<<16); // clear resume flag
|
CurrentEFL &= ~(1<<16); // clear resume flag
|
||||||
}
|
}
|
||||||
// well someone is already debugging this, we must pass the INT3 on to old handler
|
// well someone is already debugging this, we must pass the INT3 on to old handler
|
||||||
// but only when it's a user-mode address
|
// but only when it's a user-mode address
|
||||||
|
/*
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(ulAddress<TASK_SIZE || !bInt3Here)
|
if(ulAddress<TASK_SIZE || !bInt3Here)
|
||||||
{
|
{
|
||||||
DPRINT((0,"SW Breakpoint but debugged by other process at %.4X:%.8X\n",CurrentCS,CurrentEIP));
|
DPRINT((0,"SW Breakpoint but debugged by other process at %.4X:%.8X\n",CurrentCS,CurrentEIP));
|
||||||
// call the old handler on return from RealIsr()
|
// call the old handler on return from RealIsr()
|
||||||
dwCallOldInt3Handler = 1;
|
dwCallOldInt3Handler = 1;
|
||||||
// and skip DebuggerShell()
|
// and skip DebuggerShell()
|
||||||
|
@ -1295,59 +1296,60 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
if(ScanExportsByAddress(&pFind,GetLinearAddress(CurrentCS,CurrentEIP)))
|
if(ScanExportsByAddress(&pFind,GetLinearAddress(CurrentCS,CurrentEIP)))
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at (%s) %.4X:%.8X\n",
|
PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at (%s) %.4X:%.8X\n",
|
||||||
pFind,CurrentCS,CurrentEIP);
|
pFind,CurrentCS,CurrentEIP);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at kernel-mode address %.4X:%.8X\n",
|
PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at kernel-mode address %.4X:%.8X\n",
|
||||||
CurrentCS,CurrentEIP);
|
CurrentCS,CurrentEIP);
|
||||||
}
|
}
|
||||||
Print(OUTPUT_WINDOW,tempShell);
|
Print(OUTPUT_WINDOW,tempShell);
|
||||||
CurrentEFL &= ~(1<<16); // clear resume flag
|
CurrentEFL &= ~(1<<16); // clear resume flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// skip INT3
|
// skip INT3
|
||||||
CurrentEIP++;
|
CurrentEIP++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(dwReasonForBreak == REASON_PAGEFAULT)
|
else if(dwReasonForBreak == REASON_PAGEFAULT)
|
||||||
{
|
{
|
||||||
LPSTR pSymbolName;
|
LPSTR pSymbolName;
|
||||||
|
|
||||||
DPRINT((0,"REASON_PAGEFAULT\n"));
|
DPRINT((0,"REASON_PAGEFAULT\n"));
|
||||||
|
|
||||||
if( ScanExportsByAddress(&pSymbolName,GetLinearAddress(CurrentCS,CurrentEIP)) )
|
if( ScanExportsByAddress(&pSymbolName,GetLinearAddress(CurrentCS,CurrentEIP)) )
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: Breakpoint due to page fault at %.4X:%.8X (%s)\n",CurrentCS,CurrentEIP,pSymbolName);
|
PICE_sprintf(tempShell,"pICE: Breakpoint due to page fault at %.4X:%.8X (%s)\n",CurrentCS,CurrentEIP,pSymbolName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: Breakpoint due to page fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
PICE_sprintf(tempShell,"pICE: Breakpoint due to page fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
||||||
}
|
}
|
||||||
Print(OUTPUT_WINDOW,tempShell);
|
Print(OUTPUT_WINDOW,tempShell);
|
||||||
PICE_sprintf(tempShell,"pICE: memory referenced %x\n",CurrentCR2);
|
PICE_sprintf(tempShell,"pICE: memory referenced %x\n",CurrentCR2);
|
||||||
Print(OUTPUT_WINDOW,tempShell);
|
Print(OUTPUT_WINDOW,tempShell);
|
||||||
dwCallOldIntEHandler = 1;
|
dwCallOldIntEHandler = 1;
|
||||||
}
|
}
|
||||||
else if(dwReasonForBreak == REASON_GP_FAULT)
|
else if(dwReasonForBreak == REASON_GP_FAULT)
|
||||||
{
|
{
|
||||||
LPSTR pSymbolName;
|
LPSTR pSymbolName;
|
||||||
|
|
||||||
DPRINT((0,"REASON_GPFAULT\n"));
|
DPRINT((0,"REASON_GPFAULT\n"));
|
||||||
|
|
||||||
if( ScanExportsByAddress(&pSymbolName,GetLinearAddress(CurrentCS,CurrentEIP)) )
|
if( ScanExportsByAddress(&pSymbolName,GetLinearAddress(CurrentCS,CurrentEIP)) )
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: Breakpoint due to general protection fault at %.4X:%.8X (%s)\n",CurrentCS,CurrentEIP,pSymbolName);
|
PICE_sprintf(tempShell,"pICE: Breakpoint due to general protection fault at %.4X:%.8X (%s)\n",CurrentCS,CurrentEIP,pSymbolName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PICE_sprintf(tempShell,"pICE: Breakpoint due to general protection fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
PICE_sprintf(tempShell,"pICE: Breakpoint due to general protection fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
||||||
}
|
}
|
||||||
Print(OUTPUT_WINDOW,tempShell);
|
Print(OUTPUT_WINDOW,tempShell);
|
||||||
dwCallOldGPFaultHandler = 1;
|
dwCallOldGPFaultHandler = 1;
|
||||||
}
|
}
|
||||||
else if(dwReasonForBreak == REASON_CTRLF)
|
else if(dwReasonForBreak == REASON_CTRLF)
|
||||||
{
|
{
|
||||||
DPRINT((0,"REASON_CTRLF\n"));
|
DPRINT((0,"REASON_CTRLF\n"));
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
@ -1355,8 +1357,8 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
{
|
{
|
||||||
DPRINT((0,"REASON_DOUBLE_FAULT\n"));
|
DPRINT((0,"REASON_DOUBLE_FAULT\n"));
|
||||||
|
|
||||||
PICE_sprintf(tempShell,"pICE: Breakpoint due to double fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
PICE_sprintf(tempShell,"pICE: Breakpoint due to double fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
|
||||||
Print(OUTPUT_WINDOW,tempShell);
|
Print(OUTPUT_WINDOW,tempShell);
|
||||||
}
|
}
|
||||||
else if(dwReasonForBreak == REASON_INTERNAL_ERROR)
|
else if(dwReasonForBreak == REASON_INTERNAL_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -1370,8 +1372,8 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
{
|
{
|
||||||
DPRINT((0,"REASON_UNKNOWN\n"));
|
DPRINT((0,"REASON_UNKNOWN\n"));
|
||||||
|
|
||||||
PICE_sprintf(tempShell,"pICE: Breakpoint due to unknown reason at %.4X:%.8X (code %x)\n",CurrentCS,CurrentEIP,dwReasonForBreak);
|
PICE_sprintf(tempShell,"pICE: Breakpoint due to unknown reason at %.4X:%.8X (code %x)\n",CurrentCS,CurrentEIP,dwReasonForBreak);
|
||||||
Print(OUTPUT_WINDOW,tempShell);
|
Print(OUTPUT_WINDOW,tempShell);
|
||||||
Print(OUTPUT_WINDOW,"pICE: Please report this error to klauspg@diamondmm.com!\n");
|
Print(OUTPUT_WINDOW,"pICE: Please report this error to klauspg@diamondmm.com!\n");
|
||||||
Print(OUTPUT_WINDOW,"pICE: !!! SYSTEM HALTED !!!\n");
|
Print(OUTPUT_WINDOW,"pICE: !!! SYSTEM HALTED !!!\n");
|
||||||
__asm__ __volatile__("hlt");
|
__asm__ __volatile__("hlt");
|
||||||
|
@ -1379,7 +1381,7 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
|
|
||||||
// we don't single-step yet
|
// we don't single-step yet
|
||||||
DPRINT((0,"RealIsr(): not stepping yet\n"));
|
DPRINT((0,"RealIsr(): not stepping yet\n"));
|
||||||
bSingleStep=FALSE;
|
bSingleStep=FALSE;
|
||||||
|
|
||||||
// process commands
|
// process commands
|
||||||
if(bSkipMainLoop == FALSE)
|
if(bSkipMainLoop == FALSE)
|
||||||
|
@ -1389,29 +1391,29 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
("
|
("
|
||||||
pushl %eax
|
pushl %eax
|
||||||
movw %es,%ax
|
movw %es,%ax
|
||||||
movw %ax,CurrentES
|
movw %ax,CurrentES
|
||||||
movw %fs,%ax
|
movw %fs,%ax
|
||||||
movw %ax,CurrentFS
|
movw %ax,CurrentFS
|
||||||
movw %gs,%ax
|
movw %gs,%ax
|
||||||
movw %ax,CurrentGS
|
movw %ax,CurrentGS
|
||||||
movl %dr0,%eax
|
movl %dr0,%eax
|
||||||
movl %eax,CurrentDR0
|
movl %eax,CurrentDR0
|
||||||
movl %dr1,%eax
|
movl %dr1,%eax
|
||||||
movl %eax,CurrentDR1
|
movl %eax,CurrentDR1
|
||||||
movl %dr2,%eax
|
movl %dr2,%eax
|
||||||
movl %eax,CurrentDR2
|
movl %eax,CurrentDR2
|
||||||
movl %dr3,%eax
|
movl %dr3,%eax
|
||||||
movl %eax,CurrentDR3
|
movl %eax,CurrentDR3
|
||||||
movl %dr6,%eax
|
movl %dr6,%eax
|
||||||
movl %eax,CurrentDR6
|
movl %eax,CurrentDR6
|
||||||
movl %dr7,%eax
|
movl %dr7,%eax
|
||||||
movl %eax,CurrentDR7
|
movl %eax,CurrentDR7
|
||||||
movl %cr0,%eax
|
movl %cr0,%eax
|
||||||
movl %eax,CurrentCR0
|
movl %eax,CurrentCR0
|
||||||
movl %cr2,%eax
|
movl %cr2,%eax
|
||||||
movl %eax,CurrentCR2
|
movl %eax,CurrentCR2
|
||||||
movl %cr3,%eax
|
movl %cr3,%eax
|
||||||
movl %eax,CurrentCR3
|
movl %eax,CurrentCR3
|
||||||
popl %eax"
|
popl %eax"
|
||||||
);
|
);
|
||||||
|
@ -1430,7 +1432,7 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
// remember how we restarted last time
|
// remember how we restarted last time
|
||||||
bPreviousCommandWasGo = !bSingleStep;
|
bPreviousCommandWasGo = !bSingleStep;
|
||||||
// do a single step to reinstall breakpoint
|
// do a single step to reinstall breakpoint
|
||||||
// modify trace flag
|
// modify trace flag
|
||||||
CurrentEFL|=0x100; // set trace flag (TF)
|
CurrentEFL|=0x100; // set trace flag (TF)
|
||||||
|
|
||||||
bSingleStep=TRUE;
|
bSingleStep=TRUE;
|
||||||
|
@ -1439,21 +1441,21 @@ void RealIsr(ULONG dwReasonForBreak)
|
||||||
|
|
||||||
common_return_point:
|
common_return_point:
|
||||||
|
|
||||||
// reset the global flags
|
// reset the global flags
|
||||||
bNotifyToExit = FALSE;
|
bNotifyToExit = FALSE;
|
||||||
bSkipMainLoop = FALSE;
|
bSkipMainLoop = FALSE;
|
||||||
|
|
||||||
// not in handler anymore
|
// not in handler anymore
|
||||||
bInDebuggerShell = FALSE;
|
bInDebuggerShell = FALSE;
|
||||||
|
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
DPRINT((0,"-----------------------------------------------------------------\n"));
|
DPRINT((0,"-----------------------------------------------------------------\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
__asm__("
|
__asm__("
|
||||||
NewInt31Handler:
|
NewInt31Handler:
|
||||||
cli
|
cli
|
||||||
cld
|
cld
|
||||||
|
|
||||||
pushl %eax
|
pushl %eax
|
||||||
pushl %ds
|
pushl %ds
|
||||||
|
@ -1461,60 +1463,60 @@ NewInt31Handler:
|
||||||
movw %ss,%ax
|
movw %ss,%ax
|
||||||
mov %ax,%ds
|
mov %ax,%ds
|
||||||
|
|
||||||
mov 0x4(%esp),%eax
|
mov 0x4(%esp),%eax
|
||||||
movl %eax,CurrentEAX
|
movl %eax,CurrentEAX
|
||||||
movl %ebx,CurrentEBX
|
movl %ebx,CurrentEBX
|
||||||
movl %ecx,CurrentECX
|
movl %ecx,CurrentECX
|
||||||
movl %edx,CurrentEDX
|
movl %edx,CurrentEDX
|
||||||
movl %esi,CurrentESI
|
movl %esi,CurrentESI
|
||||||
movl %edi,CurrentEDI
|
movl %edi,CurrentEDI
|
||||||
movl %ebp,CurrentEBP
|
movl %ebp,CurrentEBP
|
||||||
movl (%esp),%eax
|
movl (%esp),%eax
|
||||||
movw %ax,CurrentDS
|
movw %ax,CurrentDS
|
||||||
|
|
||||||
// test for V86 mode
|
// test for V86 mode
|
||||||
testl $0x20000,5*4(%esp)
|
testl $0x20000,5*4(%esp)
|
||||||
jz notV86
|
jz notV86
|
||||||
|
|
||||||
int $0x03
|
int $0x03
|
||||||
|
|
||||||
notV86:
|
notV86:
|
||||||
// test if stack switched (ring3->ring0 transition)
|
// test if stack switched (ring3->ring0 transition)
|
||||||
// stack is switched if orig. SS is not global kernel code segment
|
// stack is switched if orig. SS is not global kernel code segment
|
||||||
movl 4*4(%esp),%eax
|
movl 4*4(%esp),%eax
|
||||||
cmpw $" STR(GLOBAL_CODE_SEGMENT) ",%ax
|
cmpw $" STR(GLOBAL_CODE_SEGMENT) ",%ax
|
||||||
je notswitched
|
je notswitched
|
||||||
|
|
||||||
// switched stack
|
// switched stack
|
||||||
movl 6*4(%esp),%eax
|
movl 6*4(%esp),%eax
|
||||||
mov %eax,CurrentESP
|
mov %eax,CurrentESP
|
||||||
mov 7*4(%esp),%eax
|
mov 7*4(%esp),%eax
|
||||||
movzwl %ax,%eax
|
movzwl %ax,%eax
|
||||||
mov %ax,CurrentSS
|
mov %ax,CurrentSS
|
||||||
jmp afterswitch
|
jmp afterswitch
|
||||||
|
|
||||||
notswitched:
|
notswitched:
|
||||||
// didn't switch stack
|
// didn't switch stack
|
||||||
movl %esp,CurrentESP
|
movl %esp,CurrentESP
|
||||||
addl $24,CurrentESP
|
addl $24,CurrentESP
|
||||||
movw %ss,%ax
|
movw %ss,%ax
|
||||||
movzwl %ax,%eax
|
movzwl %ax,%eax
|
||||||
mov %ax,CurrentSS
|
mov %ax,CurrentSS
|
||||||
|
|
||||||
afterswitch:
|
afterswitch:
|
||||||
// save EIP
|
// save EIP
|
||||||
mov 3*4(%esp),%eax
|
mov 3*4(%esp),%eax
|
||||||
mov %eax,CurrentEIP
|
mov %eax,CurrentEIP
|
||||||
//save CS
|
//save CS
|
||||||
mov 4*4(%esp),%eax
|
mov 4*4(%esp),%eax
|
||||||
movzwl %ax,%eax
|
movzwl %ax,%eax
|
||||||
movw %ax,CurrentCS
|
movw %ax,CurrentCS
|
||||||
// save flags
|
// save flags
|
||||||
movl 5*4(%esp),%eax
|
movl 5*4(%esp),%eax
|
||||||
andl $0xFFFFFEFF,%eax
|
andl $0xFFFFFEFF,%eax
|
||||||
movl %eax,CurrentEFL
|
movl %eax,CurrentEFL
|
||||||
|
|
||||||
pushal
|
pushal
|
||||||
|
|
||||||
// get reason code
|
// get reason code
|
||||||
mov 0x28(%esp),%ebx
|
mov 0x28(%esp),%ebx
|
||||||
|
@ -1528,77 +1530,77 @@ afterswitch:
|
||||||
addl $4,%esp
|
addl $4,%esp
|
||||||
|
|
||||||
// restore all regs
|
// restore all regs
|
||||||
popal
|
popal
|
||||||
|
|
||||||
// do an EOI to IRQ controller (because we definitely pressed some key)
|
// do an EOI to IRQ controller (because we definitely pressed some key)
|
||||||
// TODO: SMP APIC support
|
// TODO: SMP APIC support
|
||||||
movb $0x20,%al
|
movb $0x20,%al
|
||||||
outb %al,$0x20
|
outb %al,$0x20
|
||||||
|
|
||||||
popl %ds
|
popl %ds
|
||||||
popl %eax
|
popl %eax
|
||||||
|
|
||||||
// remove reason code
|
// remove reason code
|
||||||
addl $4,%esp
|
addl $4,%esp
|
||||||
|
|
||||||
// make EAX available
|
// make EAX available
|
||||||
pushl %eax
|
pushl %eax
|
||||||
|
|
||||||
// modify or restore EFLAGS
|
// modify or restore EFLAGS
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
mov CurrentEFL,%eax
|
mov CurrentEFL,%eax
|
||||||
mov %eax,3*4(%esp)
|
mov %eax,3*4(%esp)
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
movzwl CurrentCS,%eax
|
movzwl CurrentCS,%eax
|
||||||
mov %eax,2*4(%esp)
|
mov %eax,2*4(%esp)
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
mov CurrentEIP,%eax
|
mov CurrentEIP,%eax
|
||||||
mov %eax,1*4(%esp)
|
mov %eax,1*4(%esp)
|
||||||
|
|
||||||
// restore EAX
|
// restore EAX
|
||||||
popl %eax
|
popl %eax
|
||||||
|
|
||||||
// do we need to call old INT1 handler
|
// do we need to call old INT1 handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
cmp $0,dwCallOldInt1Handler
|
cmp $0,dwCallOldInt1Handler
|
||||||
je do_iret2
|
je do_iret2
|
||||||
|
|
||||||
// call INT3 handler
|
// call INT3 handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
jmp *OldInt1Handler
|
jmp *OldInt1Handler
|
||||||
|
|
||||||
do_iret2:
|
do_iret2:
|
||||||
// do we need to call old INT3 handler
|
// do we need to call old INT3 handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
cmp $0,dwCallOldInt3Handler
|
cmp $0,dwCallOldInt3Handler
|
||||||
je do_iret1
|
je do_iret1
|
||||||
|
|
||||||
// call INT3 handler
|
// call INT3 handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
jmp *OldInt3Handler
|
jmp *OldInt3Handler
|
||||||
|
|
||||||
do_iret1:
|
do_iret1:
|
||||||
// do we need to call old pagefault handler
|
// do we need to call old pagefault handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
cmp $0,dwCallOldIntEHandler
|
cmp $0,dwCallOldIntEHandler
|
||||||
je do_iret3
|
je do_iret3
|
||||||
|
|
||||||
// call old pagefault handler
|
// call old pagefault handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
pushl error_code
|
pushl error_code
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
jmp *OldIntEHandler
|
jmp *OldIntEHandler
|
||||||
|
|
||||||
do_iret3:
|
do_iret3:
|
||||||
// do we need to call old general protection fault handler
|
// do we need to call old general protection fault handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
cmp $0,dwCallOldGPFaultHandler
|
cmp $0,dwCallOldGPFaultHandler
|
||||||
je do_iret
|
je do_iret
|
||||||
|
|
||||||
// call old pagefault handler
|
// call old pagefault handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
pushl error_code
|
pushl error_code
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
jmp *OldGPFaultHandler
|
jmp *OldGPFaultHandler
|
||||||
|
|
||||||
do_iret:
|
do_iret:
|
||||||
|
@ -1609,17 +1611,17 @@ do_iret:
|
||||||
//
|
//
|
||||||
// IDTs keyboard IRQ points here
|
// IDTs keyboard IRQ points here
|
||||||
//
|
//
|
||||||
__asm__ ("
|
__asm__ ("
|
||||||
NewGlobalInt31Handler:
|
NewGlobalInt31Handler:
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
cmpb $0,bEnterNow
|
cmpb $0,bEnterNow
|
||||||
jne dotheenter
|
jne dotheenter
|
||||||
|
|
||||||
// chain to old handler
|
// chain to old handler
|
||||||
.byte 0x2e
|
.byte 0x2e
|
||||||
jmp *OldGlobalInt31Handler
|
jmp *OldGlobalInt31Handler
|
||||||
|
|
||||||
dotheenter:
|
dotheenter:
|
||||||
pushl $" STR(REASON_CTRLF) "
|
pushl $" STR(REASON_CTRLF) "
|
||||||
jmp NewInt31Handler "
|
jmp NewInt31Handler "
|
||||||
);
|
);
|
||||||
|
@ -1637,7 +1639,7 @@ void InstallGlobalKeyboardHook(void)
|
||||||
:"=r" (LocalNewGlobalInt31Handler)
|
:"=r" (LocalNewGlobalInt31Handler)
|
||||||
:
|
:
|
||||||
:"eax");
|
:"eax");
|
||||||
OldGlobalInt31Handler=SetGlobalInt(0x21,(ULONG)LocalNewGlobalInt31Handler);
|
OldGlobalInt31Handler=SetGlobalInt(KeyboardIRQL,(ULONG)LocalNewGlobalInt31Handler);
|
||||||
}
|
}
|
||||||
UnmaskIrqs();
|
UnmaskIrqs();
|
||||||
|
|
||||||
|
@ -1651,7 +1653,7 @@ void DeInstallGlobalKeyboardHook(void)
|
||||||
MaskIrqs();
|
MaskIrqs();
|
||||||
if(OldGlobalInt31Handler)
|
if(OldGlobalInt31Handler)
|
||||||
{
|
{
|
||||||
SetGlobalInt(0x21,(ULONG)OldGlobalInt31Handler);
|
SetGlobalInt(KeyboardIRQL,(ULONG)OldGlobalInt31Handler);
|
||||||
OldGlobalInt31Handler=0;
|
OldGlobalInt31Handler=0;
|
||||||
}
|
}
|
||||||
UnmaskIrqs();
|
UnmaskIrqs();
|
||||||
|
|
|
@ -15,7 +15,7 @@ Environment:
|
||||||
LINUX 2.2.X
|
LINUX 2.2.X
|
||||||
Kernel mode only
|
Kernel mode only
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
Klaus P. Gerlicher
|
Klaus P. Gerlicher
|
||||||
|
|
||||||
|
@ -91,3 +91,5 @@ void ShowStatusLine(void);
|
||||||
#define USA (0)
|
#define USA (0)
|
||||||
#define GERMANY (1)
|
#define GERMANY (1)
|
||||||
extern UCHAR ucKeyboardLayout;
|
extern UCHAR ucKeyboardLayout;
|
||||||
|
|
||||||
|
#define KEYBOARD_IRQ 1
|
||||||
|
|
|
@ -2335,7 +2335,7 @@ BOOLEAN FindGlobalStabSymbol(LPSTR pExpression,PULONG pValue,PULONG pulTypeNumbe
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void ExtractToken(LPSTR pStringToken)
|
void ExtractToken(LPSTR pStringToken)
|
||||||
{
|
{
|
||||||
while(isalpha(pExpression[ulIndex]) || isdigit(pExpression[ulIndex]) || pExpression[ulIndex]=='_')
|
while(isalpha(pExpression[ulIndex]) || PICE_isdigit(pExpression[ulIndex]) || pExpression[ulIndex]=='_')
|
||||||
{
|
{
|
||||||
*pStringToken++=pExpression[ulIndex++];
|
*pStringToken++=pExpression[ulIndex++];
|
||||||
*pStringToken=0;
|
*pStringToken=0;
|
||||||
|
@ -2406,7 +2406,7 @@ LONG ExtractNumber(LPSTR p)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(isdigit(*p))
|
while(PICE_isdigit(*p))
|
||||||
{
|
{
|
||||||
lNumber *= lBase;
|
lNumber *= lBase;
|
||||||
lNumber += *p-'0';
|
lNumber += *p-'0';
|
||||||
|
@ -2717,7 +2717,7 @@ BOOLEAN EvaluateSymbol(PVRET pvr,LPSTR pToken)
|
||||||
DPRINT((0,"%x struct size = %x\n",pvr->type,lLowerRange));
|
DPRINT((0,"%x struct size = %x\n",pvr->type,lLowerRange));
|
||||||
|
|
||||||
// skip over the digits
|
// skip over the digits
|
||||||
while(isdigit(*pTypeBase))
|
while(PICE_isdigit(*pTypeBase))
|
||||||
pTypeBase++;
|
pTypeBase++;
|
||||||
|
|
||||||
// the structs address is is value
|
// the structs address is is value
|
||||||
|
|
|
@ -33,14 +33,6 @@ Copyright notice:
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
#include <linux/sched.h>
|
|
||||||
#include <asm/io.h>
|
|
||||||
#include <asm/page.h>
|
|
||||||
#include <asm/pgtable.h>
|
|
||||||
#include <linux/utsname.h>
|
|
||||||
#include <linux/sched.h>
|
|
||||||
#include <asm/unistd.h>
|
|
||||||
|
|
||||||
char syscallTemp[1024];
|
char syscallTemp[1024];
|
||||||
|
|
||||||
typedef struct _FRAME_SYSCALL
|
typedef struct _FRAME_SYSCALL
|
||||||
|
@ -75,11 +67,12 @@ void other_module_cleanup_module(void)
|
||||||
RevirtualizeBreakpointsForModule(pModJustFreed);
|
RevirtualizeBreakpointsForModule(pModJustFreed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#error fix that
|
|
||||||
void CSyscallHandler(FRAME_SYSCALL* ptr,ULONG ulSysCall,ULONG ebx)
|
void CSyscallHandler(FRAME_SYSCALL* ptr,ULONG ulSysCall,ULONG ebx)
|
||||||
{
|
{
|
||||||
// DPRINT((0,"CSyscallHandler(): %.4X:%.8X (syscall = %u)\n",ptr->cs,ptr->eip,ulSysCall));
|
// DPRINT((0,"CSyscallHandler(): %.4X:%.8X (syscall = %u)\n",ptr->cs,ptr->eip,ulSysCall));
|
||||||
switch(ulSysCall)
|
/*
|
||||||
|
switch(ulSysCall)
|
||||||
{
|
{
|
||||||
case 1: // sys_exit
|
case 1: // sys_exit
|
||||||
DPRINT((0,"CSysCallHandler(): 1\n"));
|
DPRINT((0,"CSysCallHandler(): 1\n"));
|
||||||
|
@ -160,6 +153,7 @@ void CSyscallHandler(FRAME_SYSCALL* ptr,ULONG ulSysCall,ULONG ebx)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
__asm__ ("
|
__asm__ ("
|
||||||
|
@ -202,7 +196,7 @@ void InstallSyscallHook(void)
|
||||||
ULONG LocalSyscallHandler;
|
ULONG LocalSyscallHandler;
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
/*ei fix later
|
||||||
MaskIrqs();
|
MaskIrqs();
|
||||||
if(!OldSyscallHandler)
|
if(!OldSyscallHandler)
|
||||||
{
|
{
|
||||||
|
@ -210,28 +204,28 @@ void InstallSyscallHook(void)
|
||||||
:"=r" (LocalSyscallHandler)
|
:"=r" (LocalSyscallHandler)
|
||||||
:
|
:
|
||||||
:"eax");
|
:"eax");
|
||||||
OldSyscallHandler=SetGlobalInt(0x80,(ULONG)LocalSyscallHandler);
|
OldSyscallHandler=SetGlobalInt(0x2e,(ULONG)LocalSyscallHandler);
|
||||||
|
|
||||||
ScanExports("free_module",(PULONG)&ulFreeModule);
|
ScanExports("free_module",(PULONG)&ulFreeModule);
|
||||||
|
|
||||||
DPRINT((0,"InstallSyscallHook(): free_module @ %x\n",ulFreeModule));
|
DPRINT((0,"InstallSyscallHook(): free_module @ %x\n",ulFreeModule));
|
||||||
}
|
}
|
||||||
UnmaskIrqs();
|
UnmaskIrqs();
|
||||||
|
*/
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeInstallSyscallHook(void)
|
void DeInstallSyscallHook(void)
|
||||||
{
|
{
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
/*ei
|
||||||
MaskIrqs();
|
MaskIrqs();
|
||||||
if(OldSyscallHandler)
|
if(OldSyscallHandler)
|
||||||
{
|
{
|
||||||
SetGlobalInt(0x80,(ULONG)OldSyscallHandler);
|
SetGlobalInt(0x2e,(ULONG)OldSyscallHandler);
|
||||||
(ULONG)OldSyscallHandler=0;
|
(ULONG)OldSyscallHandler=0;
|
||||||
}
|
}
|
||||||
UnmaskIrqs();
|
UnmaskIrqs();
|
||||||
|
*/
|
||||||
LEAVE_FUNC();
|
LEAVE_FUNC();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,16 +32,6 @@ Copyright notice:
|
||||||
////
|
////
|
||||||
#include "remods.h"
|
#include "remods.h"
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include <asm/io.h>
|
|
||||||
#include <asm/page.h>
|
|
||||||
#include <asm/pgtable.h>
|
|
||||||
#include <linux/fs.h>
|
|
||||||
#include <asm/uaccess.h>
|
|
||||||
#include <asm/delay.h>
|
|
||||||
#include <linux/types.h>
|
|
||||||
#include <linux/string.h>
|
|
||||||
#include <linux/ctype.h>
|
|
||||||
|
|
||||||
#include <defines.h>
|
#include <defines.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +42,7 @@ Copyright notice:
|
||||||
char tempUtil[1024];
|
char tempUtil[1024];
|
||||||
char tempFlowChanges[256];
|
char tempFlowChanges[256];
|
||||||
|
|
||||||
struct mm_struct* my_init_mm=(struct mm_struct*)NULL;
|
//PMADDRESS_SPACE my_init_mm=NULL;
|
||||||
struct module **pmodule_list=NULL;
|
|
||||||
|
|
||||||
ULONG TwoPagesForPhysMem[2*PAGE_SIZE];
|
ULONG TwoPagesForPhysMem[2*PAGE_SIZE];
|
||||||
|
|
||||||
|
@ -243,6 +232,21 @@ char PICE_toupper(char c)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PICE_isdigit( int c )
|
||||||
|
{
|
||||||
|
return ((c>=0x30) && (c<=0x39));
|
||||||
|
}
|
||||||
|
|
||||||
|
int PICE_isxdigit( int c )
|
||||||
|
{
|
||||||
|
return (PICE_isdigit(c) || ((c>=0x41) && (c<=0x46)) || ((c>=0x61) && (c<=0x66)));
|
||||||
|
}
|
||||||
|
|
||||||
|
int PICE_islower( int c )
|
||||||
|
{
|
||||||
|
return ((c>=0x61) && (c<=0x7a));
|
||||||
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// PICE_strncmpi()
|
// PICE_strncmpi()
|
||||||
//
|
//
|
||||||
|
@ -401,46 +405,25 @@ ULONG j;
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
BOOLEAN IsAddressValid(ULONG address)
|
BOOLEAN IsAddressValid(ULONG address)
|
||||||
{
|
{
|
||||||
pgd_t * pPGD;
|
PULONG pPGD;
|
||||||
pmd_t * pPMD;
|
PULONG pPTE;
|
||||||
pte_t * pPTE;
|
|
||||||
BOOLEAN bResult = FALSE;
|
BOOLEAN bResult = FALSE;
|
||||||
struct mm_struct* p = NULL;
|
PEPROCESS my_current = IoGetCurrentProcess();
|
||||||
struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
|
|
||||||
|
|
||||||
address &= (~(PAGE_SIZE-1));
|
address &= (~(PAGE_SIZE-1));
|
||||||
|
|
||||||
// if we're in DebuggerShell() we live on a different stack
|
if(my_current)
|
||||||
if(bInDebuggerShell)
|
|
||||||
(ULONG)my_current &= ulRealStackPtr;
|
|
||||||
else
|
|
||||||
my_current = current;
|
|
||||||
|
|
||||||
if(address < TASK_SIZE)
|
|
||||||
{
|
{
|
||||||
p = my_current->mm;
|
pPGD = ADDR_TO_PDE(address);
|
||||||
}
|
if(pPGD && ((*pPGD)&_PAGE_PRESENT))
|
||||||
else
|
|
||||||
{
|
|
||||||
p = my_init_mm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p)
|
|
||||||
{
|
|
||||||
pPGD = pgd_offset(p,address);
|
|
||||||
if(pPGD && pgd_val(*pPGD)&_PAGE_PRESENT)
|
|
||||||
{
|
{
|
||||||
// not large page
|
// not large page
|
||||||
if(!(pgd_val(*pPGD)&_PAGE_4M))
|
if(!((*pPGD)&_PAGE_4M))
|
||||||
{
|
{
|
||||||
pPMD = pmd_offset(pPGD,address);
|
pPTE = ADDR_TO_PTE(address);
|
||||||
if(pPMD)
|
if(pPTE)
|
||||||
{
|
{
|
||||||
pPTE = pte_offset(pPMD,address);
|
bResult = (*pPTE)&(_PAGE_PRESENT | _PAGE_PSE);
|
||||||
if(pPTE)
|
|
||||||
{
|
|
||||||
bResult = pte_present(*pPTE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// large page
|
// large page
|
||||||
|
@ -465,57 +448,34 @@ BOOLEAN IsAddressValid(ULONG address)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
BOOLEAN IsAddressWriteable(ULONG address)
|
BOOLEAN IsAddressWriteable(ULONG address)
|
||||||
{
|
{
|
||||||
pgd_t * pPGD;
|
PULONG pPGD;
|
||||||
pmd_t * pPMD;
|
PULONG pPTE;
|
||||||
pte_t * pPTE;
|
|
||||||
BOOLEAN bResult = FALSE;
|
BOOLEAN bResult = FALSE;
|
||||||
struct mm_struct* p = NULL;
|
PEPROCESS my_current = IoGetCurrentProcess();
|
||||||
struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
|
|
||||||
|
|
||||||
address &= (~(PAGE_SIZE-1));
|
address &= (~(PAGE_SIZE-1));
|
||||||
|
|
||||||
// if we're in DebuggerShell() we live on a different stack
|
if(my_current)
|
||||||
if(bInDebuggerShell)
|
|
||||||
(ULONG)my_current &= ulRealStackPtr;
|
|
||||||
else
|
|
||||||
my_current = current;
|
|
||||||
|
|
||||||
if(address < TASK_SIZE)
|
|
||||||
{
|
{
|
||||||
p = my_current->mm;
|
pPGD = ADDR_TO_PDE(address);
|
||||||
}
|
if(pPGD && ((*pPGD)&_PAGE_PRESENT))
|
||||||
else
|
|
||||||
{
|
|
||||||
p = my_init_mm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p)
|
|
||||||
{
|
|
||||||
pPGD = pgd_offset(p,address);
|
|
||||||
if(pPGD && pgd_val(*pPGD)&_PAGE_PRESENT)
|
|
||||||
{
|
{
|
||||||
// not large page
|
// not large page
|
||||||
if(!(pgd_val(*pPGD)&_PAGE_4M))
|
if(!((*pPGD)&_PAGE_4M))
|
||||||
{
|
{
|
||||||
bResult |= pgd_val(*pPGD) & _PAGE_RW;
|
bResult |= (*pPGD) & _PAGE_RW;
|
||||||
|
|
||||||
pPMD = pmd_offset(pPGD,address);
|
pPTE = ADDR_TO_PTE(address);
|
||||||
if(pPMD)
|
if(pPTE)
|
||||||
{
|
{
|
||||||
bResult |= pmd_val(*pPMD) & _PAGE_RW;
|
if( (*pPTE)&(_PAGE_PRESENT | _PAGE_PSE) )
|
||||||
|
bResult |= (*pPTE) & _PAGE_RW;
|
||||||
pPTE = pte_offset(pPMD,address);
|
|
||||||
if(pPTE)
|
|
||||||
{
|
|
||||||
if( pte_present(*pPTE) )
|
|
||||||
bResult |= pte_write(*pPTE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// large page
|
// large page
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bResult |= pgd_val(*pPGD) & _PAGE_RW;
|
bResult |= (*pPGD) & _PAGE_RW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,62 +490,41 @@ BOOLEAN IsAddressWriteable(ULONG address)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
BOOLEAN SetAddressWriteable(ULONG address,BOOLEAN bSet)
|
BOOLEAN SetAddressWriteable(ULONG address,BOOLEAN bSet)
|
||||||
{
|
{
|
||||||
pgd_t * pPGD;
|
PULONG pPGD;
|
||||||
pmd_t * pPMD;
|
PULONG pPTE;
|
||||||
pte_t * pPTE;
|
|
||||||
BOOLEAN bResult = FALSE;
|
BOOLEAN bResult = FALSE;
|
||||||
struct mm_struct* p = NULL;
|
PEPROCESS my_current = IoGetCurrentProcess();
|
||||||
struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
|
|
||||||
|
|
||||||
address &= (~(PAGE_SIZE-1));
|
address &= (~(PAGE_SIZE-1));
|
||||||
|
|
||||||
// if we're in DebuggerShell() we live on a different stack
|
if(my_current)
|
||||||
if(bInDebuggerShell)
|
|
||||||
(ULONG)my_current &= ulRealStackPtr;
|
|
||||||
else
|
|
||||||
my_current = current;
|
|
||||||
|
|
||||||
if(address < TASK_SIZE)
|
|
||||||
{
|
{
|
||||||
p = my_current->mm;
|
pPGD = ADDR_TO_PDE(address);
|
||||||
}
|
if(pPGD && ((*pPGD)&_PAGE_PRESENT))
|
||||||
else
|
|
||||||
{
|
|
||||||
p = my_init_mm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p)
|
|
||||||
{
|
|
||||||
pPGD = pgd_offset(p,address);
|
|
||||||
if(pPGD && pgd_val(*pPGD)&_PAGE_PRESENT)
|
|
||||||
{
|
{
|
||||||
// not large page
|
// not large page
|
||||||
if(!(pgd_val(*pPGD)&_PAGE_4M))
|
if(!((*pPGD)&_PAGE_4M))
|
||||||
{
|
{
|
||||||
pPMD = pmd_offset(pPGD,address);
|
pPTE = ADDR_TO_PTE(address);
|
||||||
if(pPMD)
|
if(pPTE)
|
||||||
{
|
{
|
||||||
pPTE = pte_offset(pPMD,address);
|
if( (*pPTE)&(_PAGE_PRESENT | _PAGE_PSE) )
|
||||||
if(pPTE)
|
|
||||||
{
|
{
|
||||||
if( pte_present(*pPTE) )
|
if( bSet )
|
||||||
{
|
*pPTE |= _PAGE_RW;
|
||||||
if( bSet )
|
else
|
||||||
pte_mkwrite(*pPTE);
|
*pPTE &= ~_PAGE_RW;
|
||||||
else
|
bResult = TRUE;
|
||||||
pte_wrprotect(*pPTE);
|
}
|
||||||
bResult = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// large page
|
// large page
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( bSet )
|
if( bSet )
|
||||||
pgd_val(*pPGD) |= _PAGE_RW;
|
*pPGD |= _PAGE_RW;
|
||||||
else
|
else
|
||||||
pgd_val(*pPGD) &= ~_PAGE_RW;
|
*pPGD &= ~_PAGE_RW;
|
||||||
bResult = TRUE;
|
bResult = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1320,11 +1259,13 @@ UCHAR KeyboardGetKeyPolled(void)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
void KeyboardFlushKeyboardQueue(void)
|
void KeyboardFlushKeyboardQueue(void)
|
||||||
{
|
{
|
||||||
__udelay(10);
|
//__udelay(10);
|
||||||
|
KeStallExecutionProcessor(10);
|
||||||
while(GetKeyStatus()&OUTPUT_BUFFER_FULL)
|
while(GetKeyStatus()&OUTPUT_BUFFER_FULL)
|
||||||
{
|
{
|
||||||
GetKeyData();
|
GetKeyData();
|
||||||
__udelay(10);
|
//__udelay(10);
|
||||||
|
KeStallExecutionProcessor(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,7 +1309,7 @@ UCHAR ucKey;
|
||||||
else
|
else
|
||||||
goto load;
|
goto load;
|
||||||
}
|
}
|
||||||
__udelay(1000);
|
Sleep(1000);
|
||||||
}
|
}
|
||||||
load:
|
load:
|
||||||
Clear(REGISTER_WINDOW);
|
Clear(REGISTER_WINDOW);
|
||||||
|
@ -1436,48 +1377,28 @@ void IntelStackWalk(ULONG pc,ULONG ebp,ULONG esp)
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
pte_t * FindPteForLinearAddress(ULONG address)
|
pte_t * FindPteForLinearAddress(ULONG address)
|
||||||
{
|
{
|
||||||
pgd_t * pPGD;
|
PULONG pPGD;
|
||||||
pmd_t * pPMD;
|
PULONG pPTE;
|
||||||
pte_t * pPTE;
|
BOOLEAN bResult = FALSE;
|
||||||
struct mm_struct* p = NULL;
|
PEPROCESS my_current = IoGetCurrentProcess();
|
||||||
struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
|
|
||||||
|
|
||||||
ENTER_FUNC();
|
ENTER_FUNC();
|
||||||
|
|
||||||
address &= (~(PAGE_SIZE-1));
|
address &= (~(PAGE_SIZE-1));
|
||||||
|
|
||||||
// if we're in DebuggerShell() we live on a different stack
|
if(my_current)
|
||||||
if(bInDebuggerShell)
|
|
||||||
(ULONG)my_current &= ulRealStackPtr;
|
|
||||||
else
|
|
||||||
my_current = current;
|
|
||||||
|
|
||||||
if(address < TASK_SIZE)
|
|
||||||
{
|
{
|
||||||
p = my_current->mm;
|
pPGD = ADDR_TO_PDE(address);
|
||||||
}
|
if(pPGD && ((*pPGD)&_PAGE_PRESENT))
|
||||||
else
|
|
||||||
{
|
|
||||||
p = my_init_mm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p)
|
|
||||||
{
|
|
||||||
pPGD = pgd_offset(p,address);
|
|
||||||
if(pPGD && pgd_val(*pPGD)&_PAGE_PRESENT)
|
|
||||||
{
|
{
|
||||||
// not large page
|
// not large page
|
||||||
if(!(pgd_val(*pPGD)&_PAGE_4M))
|
if(!((*pPGD)&_PAGE_4M))
|
||||||
{
|
{
|
||||||
pPMD = pmd_offset(pPGD,address);
|
pPTE = ADDR_TO_PTE(address);
|
||||||
if(pPMD)
|
if(pPTE)
|
||||||
{
|
{
|
||||||
pPTE = pte_offset(pPMD,address);
|
LEAVE_FUNC();
|
||||||
if(pPTE)
|
return pPTE;
|
||||||
{
|
|
||||||
LEAVE_FUNC();
|
|
||||||
return pPTE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// large page
|
// large page
|
||||||
|
@ -1602,14 +1523,14 @@ unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
|
||||||
if (*cp == '0') {
|
if (*cp == '0') {
|
||||||
base = 8;
|
base = 8;
|
||||||
cp++;
|
cp++;
|
||||||
if ((*cp == 'x') && isxdigit(cp[1])) {
|
if ((*cp == 'x') && PICE_isxdigit(cp[1])) {
|
||||||
cp++;
|
cp++;
|
||||||
base = 16;
|
base = 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
|
while (PICE_isxdigit(*cp) && (value = PICE_isdigit(*cp) ? *cp-'0' : (PICE_islower(*cp)
|
||||||
? toupper(*cp) : *cp)-'A'+10) < base) {
|
? PICE_toupper(*cp) : *cp)-'A'+10) < base) {
|
||||||
result = result*base + value;
|
result = result*base + value;
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
@ -2041,7 +1962,7 @@ ULONG inl(PULONG port)
|
||||||
return READ_PORT_ULONG(port);
|
return READ_PORT_ULONG(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// GetInitMm()
|
// GetInitMm()
|
||||||
//
|
//
|
||||||
|
@ -2072,6 +1993,7 @@ struct mm_struct *GetInitMm(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
// EnablePassThrough()
|
// EnablePassThrough()
|
||||||
|
|
|
@ -131,8 +131,6 @@ typedef struct tagPageDir
|
||||||
ULONG PTBase :20;
|
ULONG PTBase :20;
|
||||||
}PAGEDIR,*PPAGEDIR;
|
}PAGEDIR,*PPAGEDIR;
|
||||||
|
|
||||||
extern struct mm_struct* my_init_mm;
|
|
||||||
|
|
||||||
typedef struct tagGdt
|
typedef struct tagGdt
|
||||||
{
|
{
|
||||||
ULONG Limit_15_0 :16;
|
ULONG Limit_15_0 :16;
|
||||||
|
@ -168,7 +166,6 @@ typedef struct tagDESCRIPTOR
|
||||||
USHORT Val :13; // index into table
|
USHORT Val :13; // index into table
|
||||||
}DESCRIPTOR,*PDESCRIPTOR;
|
}DESCRIPTOR,*PDESCRIPTOR;
|
||||||
|
|
||||||
extern struct module **pmodule_list;
|
|
||||||
|
|
||||||
void PICE_memset(void* p,unsigned char c,int sz);
|
void PICE_memset(void* p,unsigned char c,int sz);
|
||||||
void PICE_memcpy(void* t,void* s,int sz);
|
void PICE_memcpy(void* t,void* s,int sz);
|
||||||
|
@ -182,6 +179,9 @@ BOOLEAN PICE_isprint(char c);
|
||||||
char* PICE_strcpy(char* s1,char* s2);
|
char* PICE_strcpy(char* s1,char* s2);
|
||||||
char* PICE_strncpy(char* s1,char* s2,int len);
|
char* PICE_strncpy(char* s1,char* s2,int len);
|
||||||
char* PICE_strchr(char* s,char c);
|
char* PICE_strchr(char* s,char c);
|
||||||
|
int PICE_isdigit( int c );
|
||||||
|
int PICE_isxdigit( int c );
|
||||||
|
int PICE_islower( int c );
|
||||||
|
|
||||||
int PICE_sprintf(char * buf, const char *fmt, ...);
|
int PICE_sprintf(char * buf, const char *fmt, ...);
|
||||||
int PICE_vsprintf(char *buf, const char *fmt, va_list args);
|
int PICE_vsprintf(char *buf, const char *fmt, va_list args);
|
||||||
|
@ -214,8 +214,9 @@ void SetHardwareBreakPoint(ULONG ulAddress,ULONG ulReg);
|
||||||
BOOLEAN Disasm(PULONG pOffset, PUCHAR pchDst);
|
BOOLEAN Disasm(PULONG pOffset, PUCHAR pchDst);
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define GLOBAL_CODE_SEGMENT (__KERNEL_CS)
|
//segments defined in \include\napi\i386\segment.h
|
||||||
#define GLOBAL_DATA_SEGMENT (__KERNEL_DS)
|
#define GLOBAL_CODE_SEGMENT (KERNEL_CS)
|
||||||
|
#define GLOBAL_DATA_SEGMENT (KERNEL_DS)
|
||||||
|
|
||||||
//#define OVR_CS .byte 0x2e
|
//#define OVR_CS .byte 0x2e
|
||||||
//#define OVR_FS .byte 0x64
|
//#define OVR_FS .byte 0x64
|
||||||
|
@ -228,9 +229,15 @@ BOOLEAN CheckLoadAbort(void);
|
||||||
UCHAR KeyboardGetKeyPolled(void);
|
UCHAR KeyboardGetKeyPolled(void);
|
||||||
void KeyboardFlushKeyboardQueue(void);
|
void KeyboardFlushKeyboardQueue(void);
|
||||||
|
|
||||||
#if REAL_LINUX_VERSION_CODE >= 0x020400
|
#define _PAGE_PRESENT 0x001
|
||||||
|
#define _PAGE_RW 0x002
|
||||||
|
#define _PAGE_USER 0x004
|
||||||
|
#define _PAGE_PWT 0x008
|
||||||
|
#define _PAGE_PCD 0x010
|
||||||
|
#define _PAGE_ACCESSED 0x020
|
||||||
|
#define _PAGE_DIRTY 0x040
|
||||||
|
#define _PAGE_PSE 0x080
|
||||||
#define _PAGE_4M _PAGE_PSE
|
#define _PAGE_4M _PAGE_PSE
|
||||||
#endif
|
|
||||||
|
|
||||||
UCHAR AsciiFromScan(UCHAR s);
|
UCHAR AsciiFromScan(UCHAR s);
|
||||||
UCHAR AsciiToScan(UCHAR s);
|
UCHAR AsciiToScan(UCHAR s);
|
||||||
|
@ -251,9 +258,12 @@ ULONG inl(PULONG port);
|
||||||
#define sti() __asm__ __volatile__("sti": : :"memory")
|
#define sti() __asm__ __volatile__("sti": : :"memory")
|
||||||
|
|
||||||
|
|
||||||
extern unsigned long sys_call_table[];
|
//extern unsigned long sys_call_table[];
|
||||||
|
|
||||||
struct mm_struct *GetInitMm(void);
|
//struct mm_struct *GetInitMm(void);
|
||||||
|
|
||||||
|
PEPROCESS my_init_mm;
|
||||||
|
LIST_ENTRY* pPsProcessListHead;
|
||||||
|
|
||||||
void EnablePassThrough(void);
|
void EnablePassThrough(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue