2019-09-03 11:58:42 +02:00
/** @file
Provides simple log services to memory buffer .
* */
# ifndef __MEMLOG_LIB_H__
# define __MEMLOG_LIB_H__
//
// Mem log sizes
//
# define MEM_LOG_INITIAL_SIZE (128 * 1024)
# define MEM_LOG_MAX_SIZE (2 * 1024 * 1024)
# define MEM_LOG_MAX_LINE_SIZE 1024
/** Callback that can be installed to be called when some message is printed with MemLog() or MemLogVA(). **/
typedef VOID ( EFIAPI * MEM_LOG_CALLBACK ) ( IN INTN DebugMode , IN CHAR8 * LastMessage ) ;
2021-09-29 15:32:55 +02:00
EFI_STATUS
EFIAPI
MemLogInit (
VOID
) ;
2019-09-03 11:58:42 +02:00
/**
Prints a log message to memory buffer .
@ param Timing TRUE to prepend timing to log .
@ param DebugMode DebugMode will be passed to Callback function if it is set .
@ param Format The format string for the debug message to print .
@ param Marker VA_LIST with variable arguments for Format .
* */
VOID
EFIAPI
MemLogVA (
IN CONST BOOLEAN Timing ,
IN CONST INTN DebugMode ,
IN CONST CHAR8 * Format ,
IN VA_LIST Marker
) ;
/**
Prints a log message to memory buffer .
If Format is NULL , then does nothing .
@ param Timing TRUE to prepend timing to log .
@ param DebugMode DebugMode will be passed to Callback function if it is set .
@ param Format The format string for the debug message to print .
@ param . . . The variable argument list whose contents are accessed
based on the format string specified by Format .
* */
VOID
EFIAPI
MemLog (
IN CONST BOOLEAN Timing ,
IN CONST INTN DebugMode ,
IN CONST CHAR8 * Format ,
. . .
) ;
/**
Returns pointer to MemLog buffer .
* */
CHAR8 *
EFIAPI
GetMemLogBuffer (
VOID
) ;
/**
Returns the length of log ( number of chars written ) in mem buffer .
* */
UINTN
EFIAPI
GetMemLogLen (
VOID
) ;
/**
Sets callback that will be called when message is added to mem log .
* */
VOID
EFIAPI
SetMemLogCallback (
MEM_LOG_CALLBACK Callback
) ;
2020-10-17 15:01:33 +02:00
/**
Sets callback that will be called when message is added to mem log .
* */
MEM_LOG_CALLBACK
EFIAPI
2021-02-06 18:16:46 +01:00
GetMemLogCallback ( void ) ;
2020-10-17 15:01:33 +02:00
2019-09-03 11:58:42 +02:00
/**
Returns TSC ticks per second .
* */
UINT64
EFIAPI
GetMemLogTscTicksPerSecond ( VOID ) ;
2020-03-21 14:12:26 +01:00
/* new function that use printf like format (%s and %ls for example). We need both because only Clover use the new one. Not the drivers and protocols */
/**
Prints a log message to memory buffer .
@ param Timing TRUE to prepend timing to log .
@ param DebugMode DebugMode will be passed to Callback function if it is set .
@ param Format The format string for the debug message to print .
@ param Marker VA_LIST with variable arguments for Format .
* */
VOID
EFIAPI
MemLogfVA (
IN CONST BOOLEAN Timing ,
IN CONST INTN DebugMode ,
IN CONST CHAR8 * Format ,
IN VA_LIST Marker
) ;
/**
Prints a log message to memory buffer .
If Format is NULL , then does nothing .
@ param Timing TRUE to prepend timing to log .
@ param DebugMode DebugMode will be passed to Callback function if it is set .
@ param Format The format string for the debug message to print .
@ param . . . The variable argument list whose contents are accessed
based on the format string specified by Format .
* */
# ifdef _MSC_VER
# define __attribute__(x)
# endif
VOID
EFIAPI
MemLogf (
IN CONST BOOLEAN Timing ,
IN CONST INTN DebugMode ,
IN CONST CHAR8 * Format ,
. . .
) __attribute__ ( ( format ( printf , 3 , 4 ) ) ) ;
2019-09-03 11:58:42 +02:00
# endif // __MEMLOG_LIB_H__