ReactOS  0.4.14-dev-608-gd495a4f
output.c File Reference
#include "remods.h"
#include "precomp.h"
Include dependency graph for output.c:

Go to the source code of this file.

Macros

#define CPP_ASMLINKAGE
 
#define asmlinkage   CPP_ASMLINKAGE __attribute__((regparm(0)))
 

Functions

asmlinkage int printk (const char *fmt,...)
 
ULONG CountArgs (LPSTR fmt)
 
ULONG PICE_KdpPrintString (PANSI_STRING String)
 
void PrintkCallback (void)
 
VOID PiceRunningTimer (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
void InitPiceRunningTimer (void)
 
void RemovePiceRunningTimer (void)
 
void InstallPrintkHook (void)
 
void DeInstallPrintkHook (void)
 

Variables

char tempOutput [1024]
 
char tempOutput2 [1024]
 
ULONG(* ulPrintk )(PANSI_STRING String)
 
BOOLEAN bInPrintk = FALSE
 
BOOLEAN bIsDebugPrint = FALSE
 
BOOLEAN bIsPrintkPatched = FALSE
 
ULONG ulCountTimerEvents = 0
 
KTIMER PiceTimer
 
KDPC PiceTimerDPC
 

Macro Definition Documentation

◆ asmlinkage

#define asmlinkage   CPP_ASMLINKAGE __attribute__((regparm(0)))

Definition at line 65 of file output.c.

◆ CPP_ASMLINKAGE

#define CPP_ASMLINKAGE

Definition at line 63 of file output.c.

Function Documentation

◆ CountArgs()

ULONG CountArgs ( LPSTR  fmt)

Definition at line 120 of file output.c.

121 {
122  ULONG count=0;
123 
124  while(*fmt)
125  {
126  if(*fmt=='%' && *(fmt+1)!='%')
127  count++;
128  fmt++;
129  }
130  return count;
131 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int ULONG
Definition: retypes.h:1
Definition: dsound.c:943

◆ DeInstallPrintkHook()

void DeInstallPrintkHook ( void  )

Definition at line 278 of file output.c.

279 {
280  ENTER_FUNC();
281 
282  DPRINT((0,"enter DeInstallPrintkHook()\n"));
284  {
285  // will be done on exit debugger
288  }
289  LEAVE_FUNC();
290 }
#define LEAVE_FUNC()
Definition: debug.h:43
void DPRINT(...)
Definition: polytest.cpp:61
BOOLEAN bIsPrintkPatched
Definition: output.c:56
BOOLEAN DeInstallSWBreakpoint(ULONG ulAddress)
Definition: bp.c:428
#define ENTER_FUNC()
Definition: debug.h:42
ULONG(* ulPrintk)(PANSI_STRING String)
Definition: output.c:52

Referenced by CleanUpPICE(), and COMMAND_PROTOTYPE().

◆ InitPiceRunningTimer()

void InitPiceRunningTimer ( void  )

Definition at line 221 of file output.c.

222 {
224 
225  ENTER_FUNC();
226 #if 0 //won't work. we have to intercept timer interrupt so dpc will never fire while we are in pice
229 
230  Interval.QuadPart=-1000000L; // 100 millisec. (unit is 100 nanosec.)
231 
233  Interval, 1000000L,
234  &PiceTimerDpc);
235 #endif
236  LEAVE_FUNC();
237 }
#define LEAVE_FUNC()
Definition: debug.h:43
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
DWORD Interval
Definition: netstat.c:33
VOID PiceRunningTimer(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: output.c:195
static const WCHAR L[]
Definition: oid.c:1250
KDPC PiceTimerDPC
Definition: output.c:192
KTIMER PiceTimer
Definition: output.c:191
#define ENTER_FUNC()
Definition: debug.h:42
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711

Referenced by InitPICE().

◆ InstallPrintkHook()

void InstallPrintkHook ( void  )

Definition at line 252 of file output.c.

253 {
254 
255  ENTER_FUNC();
256 
257  if( bIsPrintkPatched )
258  return;
259 
260  DPRINT((0,"installing PrintString hook\n"));
261  ScanExports("_KdpPrintString",(PULONG)&ulPrintk);
262 
263  DPRINT((0,"_KdpPrintString @ %x\n", ulPrintk));
264  ASSERT( ulPrintk ); // temporary
265  if(ulPrintk)
266  {
268  DPRINT((0,"KdpPrintStringTest breakpoint installed? %d\n", bIsPrintkPatched));
269  }
270 
271  LEAVE_FUNC();
272 }
#define TRUE
Definition: types.h:120
#define LEAVE_FUNC()
Definition: debug.h:43
BOOLEAN InstallSWBreakpoint(ULONG ulAddress, BOOLEAN bPermanent, void(*SWBreakpointCallback)(void))
Definition: bp.c:236
void DPRINT(...)
Definition: polytest.cpp:61
void PrintkCallback(void)
Definition: output.c:157
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN bIsPrintkPatched
Definition: output.c:56
BOOLEAN ScanExports(const char *pFind, PULONG pValue)
Definition: symbols.c:327
unsigned int * PULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
ULONG(* ulPrintk)(PANSI_STRING String)
Definition: output.c:52

Referenced by InitPICE(), and RealIsr().

◆ PICE_KdpPrintString()

ULONG PICE_KdpPrintString ( PANSI_STRING  String)

Definition at line 137 of file output.c.

138 {
139  ULONG ulRingBufferLock;
140 
141  save_flags(ulRingBufferLock);
142  cli();
143 
144  /* CH: What is bIsDebugPrint used for? */
146 
147  DPRINT((0,"PICE_KdpPrintString\n\n\n"));
148  AddToRingBuffer(String->Buffer);
149  restore_flags(ulRingBufferLock);
150 }
static WCHAR String[]
Definition: stringtable.c:55
#define save_flags(x)
Definition: utils.h:285
void DPRINT(...)
Definition: polytest.cpp:61
RECT cli
Definition: sndrec32.cpp:79
BOOLEAN bIsDebugPrint
Definition: output.c:55
#define restore_flags(x)
Definition: utils.h:286
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN AddToRingBuffer(LPSTR p)
Definition: hardware.c:154

Referenced by PrintkCallback().

◆ PiceRunningTimer()

VOID PiceRunningTimer ( IN PKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 195 of file output.c.

199 {
200  CheckRingBuffer();
201 
202  if(ulCountTimerEvents++ > 10)
203  {
205 
206  ulCountTimerEvents = 0;
207 
211  PICE_sprintf(tempOutput,"jiffies = %.8X\n",jiffies.u.LowPart);
213  ResetColor();
214  }
215 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
void SetForegroundColor(ECOLORS c)
Definition: hardware.c:576
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
ULONG GLOBAL_SCREEN_WIDTH
Definition: hardware.c:62
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
#define jiffies
Definition: module.h:1075
ULONG GLOBAL_SCREEN_HEIGHT
Definition: hardware.c:62
ULONG ulCountTimerEvents
Definition: output.c:58
#define COLOR_TEXT
Definition: hardware.h:158
char tempOutput[1024]
Definition: output.c:48
void PutChar(LPSTR p, ULONG x, ULONG y)
Definition: hardware.c:604
void CheckRingBuffer(void)
Definition: hardware.c:133
void SetBackgroundColor(ECOLORS c)
Definition: hardware.c:590
void ResetColor(void)
Definition: hardware.c:500
#define COLOR_CAPTION
Definition: hardware.h:156

Referenced by InitPiceRunningTimer().

◆ printk()

asmlinkage int printk ( const char fmt,
  ... 
)

Definition at line 76 of file output.c.

77 {
78  ULONG len,ulRingBufferLock;
79  static LONGLONG ulOldJiffies = 0;
81 
82  va_list args;
83  va_start(args, fmt);
84 
85  if((len = PICE_strlen((LPSTR)fmt)) )
86  {
87  save_flags(ulRingBufferLock);
88  cli();
89 
92  // if the last debug print was longer than 50 ms ago
93  // directly print it, else just add it to the ring buffer
94  // and let the timer process it.
96  if( (jiffies.QuadPart-ulOldJiffies) > 10000*(1*wWindow[OUTPUT_WINDOW].cy)/2)
97  {
98  ulOldJiffies = jiffies.QuadPart;
100  }
101  else
102  {
104  }
105 
107  restore_flags(ulRingBufferLock);
108  }
109  va_end(args);
110 
111  return 0;
112 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define TRUE
Definition: types.h:120
#define jiffies
Definition: module.h:1075
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
USHORT cy
Definition: hardware.h:33
char * LPSTR
Definition: xmlstorage.h:182
Definition: match.c:390
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
#define save_flags(x)
Definition: utils.h:285
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
WINDOW wWindow[4]
Definition: hardware.c:59
int PICE_vsprintf(char *buf, const char *fmt, va_list args)
Definition: utils.c:1850
int64_t LONGLONG
Definition: typedefs.h:66
char tempOutput[1024]
Definition: output.c:48
RECT cli
Definition: sndrec32.cpp:79
BOOLEAN bIsDebugPrint
Definition: output.c:55
GLenum GLsizei len
Definition: glext.h:6722
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define restore_flags(x)
Definition: utils.h:286
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN AddToRingBuffer(LPSTR p)
Definition: hardware.c:154
#define args
Definition: format.c:66
Definition: dsound.c:943

Referenced by __journal_remove_journal_head(), do_one_pass(), ext2_init_bh(), Ext2InitializeVcb(), ext3_find_entry(), ext3_warning(), ext4_check_descriptors(), ext4_ext_binsearch_idx(), journal_alloc_journal_head(), journal_bmap(), journal_convert_superblock_v1(), journal_exit(), journal_get_superblock(), journal_init_handle_cache(), journal_init_inode(), journal_init_journal_head_cache(), journal_load(), journal_skip_recovery(), journal_wipe(), jread(), load_nls(), tcp_clear_xmit_timer(), tcp_reset_xmit_timer(), and tcp_tw_put().

◆ PrintkCallback()

void PrintkCallback ( void  )

Definition at line 157 of file output.c.

158 {
159  LPSTR fmt,args;
160  ULONG ulAddress;
161  ULONG countArgs,i,len;
163  CHAR buf[128];
164 
165  DPRINT((0,"In PrintkCallback\n"));
166 
167  bInPrintk = TRUE;
168 
169  // get the linear address of stack where string resides
171  if(ulAddress)
172  {
173  DPRINT((0,"In PrintkCallback: ulAddress: %x\n", ulAddress));
174  if(IsAddressValid(ulAddress+sizeof(char *)) )
175  {
176  //KdpPrintString has PANSI_STRING as a parameter
177  temp = (PANSI_STRING)*(PULONG)(ulAddress+sizeof(char *));
178  DPRINT((0,"PrintkCallback: %s\n", temp->Buffer));
179  /* Call our version of KdpPrintString() */
181  }
182  }
183  bInPrintk = FALSE;
184 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
USHORT CurrentSS
Definition: shell.c:116
BOOLEAN bInPrintk
Definition: output.c:54
char CHAR
Definition: xmlstorage.h:175
const char * fmt
Definition: wsprintf.c:30
char * LPSTR
Definition: xmlstorage.h:182
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void DPRINT(...)
Definition: polytest.cpp:61
ANSI_STRING * PANSI_STRING
Definition: env_spec_w32.h:380
ULONG GetLinearAddress(USHORT Segment, ULONG Offset)
Definition: utils.c:782
GLenum GLsizei len
Definition: glext.h:6722
ULONG PICE_KdpPrintString(PANSI_STRING String)
Definition: output.c:137
static calc_node_t temp
Definition: rpn_ieee.c:38
ULONG CurrentEIP
Definition: shell.c:113
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
ULONG CurrentESP
Definition: shell.c:115
#define args
Definition: format.c:66
BOOLEAN IsAddressValid(ULONG address)
Definition: utils.c:611

Referenced by InstallPrintkHook().

◆ RemovePiceRunningTimer()

void RemovePiceRunningTimer ( void  )

Definition at line 243 of file output.c.

244 {
246 }
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
KTIMER PiceTimer
Definition: output.c:191

Referenced by CleanUpPICE().

Variable Documentation

◆ bInPrintk

BOOLEAN bInPrintk = FALSE

Definition at line 54 of file output.c.

Referenced by HandleInDebuggerFault(), and PrintkCallback().

◆ bIsDebugPrint

BOOLEAN bIsDebugPrint = FALSE

Definition at line 55 of file output.c.

Referenced by AddToRingBuffer(), PICE_KdpPrintString(), and printk().

◆ bIsPrintkPatched

BOOLEAN bIsPrintkPatched = FALSE

Definition at line 56 of file output.c.

Referenced by DeInstallPrintkHook(), and InstallPrintkHook().

◆ PiceTimer

KTIMER PiceTimer

Definition at line 191 of file output.c.

Referenced by InitPiceRunningTimer(), and RemovePiceRunningTimer().

◆ PiceTimerDPC

KDPC PiceTimerDPC

Definition at line 192 of file output.c.

Referenced by InitPiceRunningTimer().

◆ tempOutput

char tempOutput[1024]

Definition at line 48 of file output.c.

Referenced by PiceRunningTimer(), and printk().

◆ tempOutput2

char tempOutput2[1024]

Definition at line 48 of file output.c.

◆ ulCountTimerEvents

ULONG ulCountTimerEvents = 0

Definition at line 58 of file output.c.

Referenced by PiceRunningTimer().

◆ ulPrintk

ULONG(* ulPrintk) (PANSI_STRING String)

Definition at line 52 of file output.c.

Referenced by DeInstallPrintkHook(), and InstallPrintkHook().