OpenCBM
Data Structures | Macros | Typedefs | Functions | Variables
sys/libcommon/debug.c File Reference

Debug helper functions for kernel-mode drivers. More...

#include <wdm.h>
#include "cbm_driver.h"
#include "../../arch/windows/debug.c"

Go to the source code of this file.

Data Structures

struct  NTSTATUS_DEBUGCODE
 

Macros

#define min(_x, _y)   ( ((_x) < (_y)) ? (_x) : (_y) )
 
#define REPORT_BUG(_no, _a, _b, _c, _d, _str)
 @@@ More...
 
#define DEFINE_STATUSCODE(_x)   { #_x, _x }
 
#define _MARKLASTENTRY   ((NTSTATUS) -1)
 
#define _LASTENTRY   { "", _MARKLASTENTRY }
 
#define USE_SPINLOCK   1
 use a spinlock for the debugging buffer implementation
 
#define DBG_SIZE_MEMORY_BUFFER   0x20000u
 the size of the memory buffer used for the debugging buffer
 

Typedefs

typedef struct NTSTATUS_DEBUGCODE NTSTATUS_DEBUGCODE
 

Functions

const UCHAR * DebugNtStatus (NTSTATUS Value)
 Return the description of an NTSTATUS code. More...
 
VOID DbgInit (VOID)
 Initialise debugging system. More...
 
VOID DbgAllocateMemoryBuffer (VOID)
 Get storage area for debugging output. More...
 
VOID DbgFreeMemoryBuffer (VOID)
 Free storage area for debugging output. More...
 
VOID DbgOutputMemoryBuffer (const char *String)
 Output into the debugging buffer. More...
 
NTSTATUS cbm_dbg_readbuffer (IN PDEVICE_EXTENSION Pdx, OUT PCHAR ReturnBuffer, IN OUT PULONG ReturnLength)
 Give the debug buffer contents to the installer. More...
 

Variables

const NTSTATUS_DEBUGCODE text []
 

Detailed Description

Debug helper functions for kernel-mode drivers.



Author
Spiro Trikaliotis

Definition in file sys/libcommon/debug.c.

Macro Definition Documentation

#define _LASTENTRY   { "", _MARKLASTENTRY }

this marks the last entry of the array

Definition at line 81 of file sys/libcommon/debug.c.

#define _MARKLASTENTRY   ((NTSTATUS) -1)

This mark is used as value for the last entry of the array

Definition at line 78 of file sys/libcommon/debug.c.

Referenced by DebugNtStatus().

#define DEFINE_STATUSCODE (   _x)    { #_x, _x }

Define one NTSTATUS entry

Definition at line 75 of file sys/libcommon/debug.c.

#define min (   _x,
  _y 
)    ( ((_x) < (_y)) ? (_x) : (_y) )

Mark: This file is DEBUG.C, thus, some variables and functions should not be defined as "extern"

find the minimum of both parameters

Definition at line 31 of file sys/libcommon/debug.c.

Referenced by cbm_dbg_readbuffer().

#define REPORT_BUG (   _no,
  _a,
  _b,
  _c,
  _d,
  _str 
)
Value:
DbgPrint("--- REPORT_BUG: %04x (%08x, %08x, %08x, %08x). '%s' " \
"in %s, %s(), line %u\n", \
_no, _a, _b, _c, _d, _str, \
__FILE__, __FUNCTION__, __LINE__);

@@@

Todo:
document
Parameters
_no
_a
_b
_c
_d
_str
Returns

Definition at line 53 of file sys/libcommon/debug.c.

Referenced by DbgOutputMemoryBuffer().

Typedef Documentation

one descriptional entry for the NTSTATUS codes

Function Documentation

NTSTATUS cbm_dbg_readbuffer ( IN PDEVICE_EXTENSION  Pdx,
OUT PCHAR  ReturnBuffer,
IN OUT PULONG  ReturnLength 
)

Give the debug buffer contents to the installer.

This function is used to get the contents of the debug buffer for the use of the installer.

Parameters
PdxPointer to the device extension.
ReturnBufferPointer to a buffer which will contain the result.
ReturnLengthPointer to a ULONG which contains the length of the ReturnBuffer on entry, and which will contain the length of the written ReturnBuffer on exit.
Returns
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.

This function copies the last ReturnLength bytes into the buffer.

Todo:

Definition at line 1416 of file sys/libcommon/debug.c.

References FUNC_ENTER, and min.

Referenced by cbm_execute_devicecontrol().

VOID DbgAllocateMemoryBuffer ( VOID  )

Get storage area for debugging output.

This function allocates memory for the debugging output storage.

Definition at line 1192 of file sys/libcommon/debug.c.

References DBG_SIZE_MEMORY_BUFFER, and MTAG_DBGBUFFER.

Referenced by DriverEntry().

VOID DbgFreeMemoryBuffer ( VOID  )

Free storage area for debugging output.

This function frees the memory of the debugging output.

Definition at line 1214 of file sys/libcommon/debug.c.

Referenced by DriverUnload().

VOID DbgInit ( VOID  )

Initialise debugging system.

This function performs initialisation which does not need any undoing.

Definition at line 1177 of file sys/libcommon/debug.c.

VOID DbgOutputMemoryBuffer ( const char *  String)

Output into the debugging buffer.

This function outputs a string into the debugging output buffer.

Parameters
StringPointer to the string which is to be output
Todo:
More debugging for the sanity checks to find the cause why DbgBufferSynchronizeStart() does not work without using the SpinLock.

Definition at line 1241 of file sys/libcommon/debug.c.

References DBG_SIZE_MEMORY_BUFFER, and REPORT_BUG.

const UCHAR* DebugNtStatus ( NTSTATUS  Value)

Return the description of an NTSTATUS code.

Searches in the NTSTATUS array for the supplied value, and returns a description for it if it finds some.

Parameters
ValueThe NTSTATUS value to be searched for
Returns
If the value is found, its alphanumerical description is used; if not, "*UNKNOWN*" is returned.

Definition at line 1027 of file sys/libcommon/debug.c.

References _MARKLASTENTRY, and NTSTATUS_DEBUGCODE::Name.

Referenced by AddDevice(), cbmiec_i_raw_write(), ParPortSetModeWdm(), and ParPortUnsetModeWdm().

Variable Documentation

const NTSTATUS_DEBUGCODE text[]

The array of NTSTATUS codes

Definition at line 85 of file sys/libcommon/debug.c.