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