diff --git a/AI.md b/AI.md index ebc342f..38fc8a5 100644 --- a/AI.md +++ b/AI.md @@ -317,6 +317,7 @@ implementing namespace changes. 0488 core: import NSS mailbox runtime +0489 core: import NSS production debug header base - Imported shared/sdk/include/mailbox.h as include/core/mailbox.h. - Imported public_core/library/os/mailbox.c as src/core/mailbox.c. - Added nwcore.mailbox CTest. diff --git a/doc/NSS_NAMESPACE_AUDIT.md b/doc/NSS_NAMESPACE_AUDIT.md index d0f6f95..50e06db 100644 --- a/doc/NSS_NAMESPACE_AUDIT.md +++ b/doc/NSS_NAMESPACE_AUDIT.md @@ -366,3 +366,25 @@ Imported the real NSS mailbox runtime before FSM/latch: - `public_core/library/os/mailbox.c` -> `src/core/mailbox.c` This is a bottom-up dependency for `public_core/library/fsm/fsmnw.c` and the latch runtime. No scheduler wrapper is introduced in this step. + +## 0489 core: import NSS production debug header base + +Imported the real NSS production-debug interface before FSM/latch: + +- `shared/sdk/include/pssDebug.h` -> `include/core/pssDebug.h` +- `shared/sdk/include/schedule.h` -> `include/core/schedule.h` +- `shared/sdk/library/xStdio.h` -> `include/core/xStdio.h` +- `shared/sdk/library/inlines.h` -> `include/core/inlines.h` +- `public_core/library/debug/pssDebug.c` -> `src/core/pssDebug.c` + +This is intentionally the production/no-debug path: `NSS_DEBUG` is disabled by +`include/core/omni.h`, so `DEBUG_PRINTF`, `ENTER`, `RTN_*`, and related macros +compile to the same inert form as the original header's `#else /* NSS_DEBUG */` +branch. The Linux userspace port keeps the original header/source shape but +moves the scheduler/xStdio/inlines includes behind `NSS_DEBUG IS_ENABLED`, so the +inactive debug branch does not pull the full scheduler/console stack before FSM +and alarm are imported. + +The next runtime import can now use `` without local stubs. FSM still +comes later from `public_core/library/fsm/fsmnw.c`; do not reintroduce a scheduler +wrapper. diff --git a/include/core/inlines.h b/include/core/inlines.h new file mode 100644 index 0000000..af8a6d3 --- /dev/null +++ b/include/core/inlines.h @@ -0,0 +1,341 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2007-04-18 23:26:20 +0530 (Wed, 18 Apr 2007) $ + | + | $RCSfile$ + | $Revision: 1954 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Assembly inline routines for the PSS libraries + | + |******** DO NOT INCLUDE THIS UNLESS YOU ARE A LIBRARY ROUTINE ******* + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _INLINES_H_ +#define _INLINES_H_ + +#include + +#ifndef _ZOMNI_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WATCOMC_ + + /** + * This is a little Watcom specific routine that reads the + * QUAD cycle count that Pentiums have. + */ + +QUAD LB_CycleCount(); + +#pragma aux LB_CycleCount = \ + 0x0f 0x31 \ + modify exact [EAX EDX]; + +/*--------------------------------------------------------------------------- + * inline find a long in a list of longs + *---------------------------------------------------------------------------*/ +extern LONG FindLongInList( + LONG value, + void *address, + LONG numberOfBytes); + +//#pragma aux FindLongInList parm [EAX] [EDI] [ECX]; + +#pragma aux FindLongInList = \ + "test ecx, ecx", \ + "jz *+0x0d", \ + "mov edx, ecx", \ + "repne scasd", \ + "jnz *+7", \ + "lea eax, [edx - 1]", \ + "sub eax, ecx", \ + "jmp *+5", \ + "mov eax, -1" \ + parm [EAX] [EDI] [ECX] \ + modify exact [EAX ECX EDX EDI]; + + +/*--------------------------------------------------------------------------- + * inline ZERO array function + *---------------------------------------------------------------------------*/ +extern void inline_bzero( + void *dst, + size_t numberOfBytes); + +//#pragma aux inline_bzero parm [EDI] [ECX]; + +#pragma aux inline_bzero = \ + "mov edx,ecx", \ + "xor eax,eax", \ + "shr ecx,2", \ + "rep stosd", \ + "mov ecx,edx", \ + "and ecx,3", \ + "je *+2", \ + "rep stosb" \ + parm [edi] [ecx] \ + modify exact [eax edx edi ecx]; + +/*--------------------------------------------------------------------------- + * Inline MOVE function + *---------------------------------------------------------------------------*/ +extern void inline_movefwd( + void *dst, + const void *src, + size_t len); + +#pragma aux inline_movefwd = \ + "mov eax,ecx", \ + "shr ecx,2", \ + "rep movsd", \ + "mov ecx,eax", \ + "and ecx,3", \ + "je *+2", \ + "rep movsb" \ + parm [edi] [esi] [ecx] \ + modify exact [eax edi esi ecx]; + + +/*--------------------------------------------------------------------------- + * Inline MOVE function + *---------------------------------------------------------------------------*/ +extern void inline_movebwd( + void *dst, + const void *src, + size_t len); + +#pragma aux inline_movebwd = \ + "sub esi,4", \ + "sub edi,4", \ + "mov eax,ecx", \ + "std", \ + "shr ecx,2", \ + "rep movsd", \ + "mov ecx,eax", \ + "and ecx,3", \ + "je *+8", \ + "add esi,3", \ + "add edi,3", \ + "rep movsb", \ + "cld" \ + parm [edi] [esi] [ecx] \ + modify exact [eax edi esi ecx]; + +/*--------------------------------------------------------------------------- + * + *---------------------------------------------------------------------------*/ +extern void inline_movebwd_bytesOnly( + void *dst, + const void *src, + size_t len); + +#pragma aux inline_movebwd_bytesOnly = \ + "dec esi", \ + "dec edi", \ + "std", \ + "rep movsb", \ + "cld" \ + parm [edi] [esi] [ecx] \ + modify exact [edi esi ecx]; + +/*--------------------------------------------------------------------------- + * INLINE strlen routine + *---------------------------------------------------------------------------*/ +#ifdef i386 /*PJT*/ +extern size_t inline_strlen( + const char *str); + +#pragma aux inline_strlen = \ + "sub ecx,ecx", \ + "dec ecx", \ + "xor eax,eax", \ + "repne scasb", \ + "not ecx", \ + "dec ecx", \ + "mov eax,ecx" \ + parm [edi] \ + modify exact [eax edi ecx]; +#endif /*PJT*/ + +/*--------------------------------------------------------------------------- + * INLINE unilen routine + *---------------------------------------------------------------------------*/ +extern size_t inline_unilen( + const unicode_t *str); + +#pragma aux inline_unilen = \ + "sub ecx,ecx", \ + "dec ecx", \ + "xor eax,eax", \ + "repne scasw", \ + "not ecx", \ + "dec ecx", \ + "mov eax,ecx" \ + parm [edi] \ + modify exact [eax edi ecx]; + +/*--------------------------------------------------------------------------- + * Rotates a NINT value LEFT by the numBits count + *---------------------------------------------------------------------------*/ +NINT inline_RotateLeft(NINT value, NINT numBits); + +#pragma aux inline_RotateLeft = \ + "rol eax,cl" \ + parm [eax] [ecx] \ + modify exact [eax]; + +/*--------------------------------------------------------------------------- + * Rotates a NINT value RIGHT by the numBits count + *---------------------------------------------------------------------------*/ +NINT inline_RotateRight(NINT value, NINT numBits); + +#pragma aux inline_RotateRight = \ + "ror eax,cl" \ + parm [EAX] [ECX] \ + modify exact [EAX]; + +/*--------------------------------------------------------------------------- + * Disable interrupts + *---------------------------------------------------------------------------*/ +#if MPK_REAL IS_ENABLED + # define Disable() +#else + void Disable(void); + #pragma aux Disable = \ + "cli" \ + modify exact []; +#endif + +/*--------------------------------------------------------------------------- + * Enable interrupts + *---------------------------------------------------------------------------*/ +#if MPK_REAL IS_ENABLED + #define Enable() +#else + void Enable(void); + #pragma aux Enable = \ + "sti" \ + modify exact []; +#endif + +//#if NSS_DEBUG IS_ENABLED +// #define DEBUG_ENABLE_INTERRUPTS() (Enable()) +//#else +// #define DEBUG_ENABLE_INTERRUPTS() +//#endif + + +/*--------------------------------------------------------------------------- + * Set FLAGS register + *---------------------------------------------------------------------------*/ +#if MPK_REAL IS_ENABLED + # define SetFlags(_flags) ((void)0) +#else + void SetFlags(NINT flag); + #pragma aux SetFlags = \ + "push eax", \ + "popfd" \ + parm [eax] \ + modify exact []; +#endif + +/*--------------------------------------------------------------------------- + * Disable interrupts and RETURN flags register + *---------------------------------------------------------------------------*/ +#if MPK_REAL IS_ENABLED + # define DisableAndRetFlags() 0 +#else + NINT DisableAndRetFlags(void); + #pragma aux DisableAndRetFlags = \ + "pushfd", \ + "pop eax", \ + "cli" \ + modify exact [eax]; +#endif + +/*------------------------------------------------------------------------- + * Enable interrupts and RETURN flags register + *-------------------------------------------------------------------------*/ +#if MPK_REAL IS_ENABLED + # define EnableAndRetFlags() 0 +#else + NINT EnableAndRetFlags(void); + #pragma aux EnableAndRetFlags = \ + "pushfd", \ + "pop eax", \ + "sti" \ + modify exact [eax]; +#endif + +/*--------------------------------------------------------------------------- + * Returns TRUE if interrupts are enabled, else false + *---------------------------------------------------------------------------*/ +BOOL IntsEnabled(void); + +#pragma aux IntsEnabled = \ + "pushfd", \ + "pop eax", \ + "and eax,200h" \ + modify exact [eax]; + +#endif /*_WATCOMC_*/ + +#ifdef __linux__ + +#if MPK_REAL IS_ENABLED + # define Disable() + # define DisableAndRetFlags() 0 + # define Enable() + # define SetFlags(_flags) ((void)0) +#else +// FixFixFix(linux) - Added by Greg - need to add actual function. Look at callers to see if we really need. + # define Disable() + # define DisableAndRetFlags() 0 + # define Enable() + # define SetFlags(_flags) ((void)0) +// # error Need to define Disable(), DisableAndRetFlags(), Enable() and SetFlags(). +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/core/pssDebug.h b/include/core/pssDebug.h new file mode 100644 index 0000000..2bfa22f --- /dev/null +++ b/include/core/pssDebug.h @@ -0,0 +1,825 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _PSSDEBUG_H_ +#define _PSSDEBUG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _OMNI_H_ +# include +#endif + +#if NSS_DEBUG IS_ENABLED +#ifndef _SCHEDULE_H_ +# include +#endif +#ifndef _XSTDIO_H_ +# include +#endif +#ifndef _INLINES_H_ +# include +#endif +#endif + +/* Pre-define struct(s) so Linux compiler doesn't complain */ +struct ScreenStruct; +struct StackFrame; + +/*- internal prototype -*/ +extern void freeDebugContext(); + +/* basic I/O device to do debug output to*/ +extern struct WFile_s *DBG_DbgScreen; + +/* basic MACROS for doing I/O*/ +#if NSS_DEBUG IS_ENABLED +# define PRINT(attr) DBG_DebugPrintf(attr, +#else +# define PRINT(attr) LB_aprintf(attr, +#endif +#define PRSEQ(attr) DBG_prseq(), DBG_DebugPrintf(attr, + + +typedef struct DebugEntryHeader_s +{ + LONG DEH_attribute; + LONG DEH_utc; /* UTC time of debug print call */ + QUAD DEH_mask; + WORD DEH_length; /* Length of STRING (includes NULL) */ +} DebugEntryHeader_s; + +typedef struct DebugEntryTail_s +{ + WORD DET_length; /* Length of STRING (includes NULL) */ +} DebugEntryTail_s; + +#define MAX_LOG_ELEMENT_SIZE (1024) +#define MAX_LOG_ENTRY_SIZE (MAX_LOG_ELEMENT_SIZE + sizeof(DebugEntryHeader_s) + sizeof(DebugEntryTail_s)) + + /* EOS is End Of String */ +#define DBG_EOS_INDEX_FROM_TAIL (-2) /* Location of strings last non-NULL + * character relative to the records + * tail pointer. + */ +#define DBG_EOS_INDEX_PREV(_index) \ + (((_index) - sizeof(DebugEntryTail_s)) + DBG_EOS_INDEX_FROM_TAIL) +#define DBG_EOS_CHAR_PREV(_index) \ + DBG_debugLogBuffer[DBG_EOS_INDEX_PREV(_index)] +#define DBG_EOS_INDEX_OF_END_RECORD() \ + (DBG_debugLogEndRecordTail + DBG_EOS_INDEX_FROM_TAIL) +#define DBG_EOS_CHAR_OF_END_RECORD() \ + DBG_debugLogBuffer[DBG_EOS_INDEX_OF_END_RECORD()] +#define DBG_BEGIN_LINE(_current) \ + (_current == DBG_debugLogBufferRemove) || \ + (DBG_EOS_CHAR_PREV(_current) == 0x0A) ) + + +#define DBG_TIME_NONE 0 +#define DBG_TIME_PARTIAL 1 +#define DBG_TIME_FULL 2 + + +extern void DBG_prseq(void); +//extern int DBG_grabdebug(void); +//extern int bugAbort(char *what, int error); +extern int DBG_fatal(char *where, char *string, int errCode); +extern int DBG_error(char *where, char *string, int value); +//extern int debug(char *what); +//extern int here(char *where); +//extern int stop(char *where); +//extern int pr(char *what); +//extern int tr(char *what); +//extern int prx(char *what, unsigned value); +//extern int prd(char *what, unsigned value); +//extern int prc(char *what, char value); +//extern int prs(char *what, char *value); +//extern int debugCount(char *what); + +extern void DBG_Startup(void); +extern void DBG_Shutdown(void); +extern void DBG_Denter(char *where, QUAD trace, char *name); +extern void DBG_Dindent(void); +extern void DBG_Dexit(char *where); +extern void DBG_DrtnVoid(char *where); +extern void DBG_DrtnSNINT(char *where, SNINT returnCode); +extern void DBG_DrtnNINT(char *where, NINT returnCode); +extern void DBG_DrtnStatus(char *where, STATUS status); +extern void DBG_DrtnPtr(char *where, void *returnCode); +extern void DBG_DrtnQUAD(char *where, QUAD returnCode); + +#define DBG_LOG_MAX_DISP_LINES 8 /* Used to clear area for '=s' command + * display information. + */ +extern LONG DBG_IsDOSFATLoaded( ); + +//int ztrace(char *msg, Zid_t zid, Blknum_t logical, Blknum_t physical); +//void zdumpMap(); +extern char *DBG_DebugFormatBinary(char *buf,NINT len); +extern void DBG_SaveDebugLogToFile(struct ScreenStruct *debugScreen); +extern void DBG_DumpLogBuffer(struct ScreenStruct *debugScreen); +extern void DBG_DebugLogProcessBuffer(void); + + +extern void DBG_InitDebug(void); +extern void DBG_FlushDebug(void); +extern void DBG_UninitDebug(void); +extern LONG DBG_DoNSSDebuggerCommand( + struct ScreenStruct *debugScreen, + char *commandLine, + struct StackFrame *StkFrm); + + +//extern void printBitMap(NINT *map, NINT numBits); + +extern int DBG_Depth; +extern int DBG_printDebug(char *string); + +extern NINT DBG_Sequence; +extern NINT DBG_DebugLogBufferSize; +extern QUAD DBG_DebugFlag; +extern QUAD DBG_SavedDebugFlag; +extern QUAD DBG_TraceFlag; +extern QUAD DBG_SavedTraceFlag; +extern BOOL DBG_ScreenDebug; +extern BOOL DBG_DebugEnabled; +extern BOOL DBG_TraceEnabled; + +//extern NINT DBG_Audit; +//extern NINT DBG_TraceLevel; +extern NINT DBG_PageSize; +extern BOOL DBG_Paging; +//extern NINT DBG_Matcher; +extern BOOL DBG_Stub; + +//extern BYTE *DBG_debugLogStack; +extern BYTE *DBG_debugLogBuffer; +extern NINT DBG_debugLogBufferInsert; +extern NINT DBG_debugLogBufferRemove; +extern NINT DBG_debugLogMask; + +//extern char *DBG_DebugWhere; +extern char DBG_NotImpDbgMsg[]; +//extern char DBG_StubbedMsg[]; + +/* Routines to hook TRACING of NCPS */ +extern void DBG_HookNCPTrace(void); +extern void DBG_UnHookNCPTrace(void); +extern void DBG_HookNCPLog(void); +extern void DBG_UnHookNCPLog(void); + + +/**************************************************************************** + * Defines for tracing & debug + ****************************************************************************/ +#define TDEFAULT UI64_CONST(0x0000000000000001) /* Default value when DBG_DebugPrintf + * is called directly. + */ +#define TCACHE UI64_CONST(0x0000000000000002) +#define TFSM UI64_CONST(0x0000000000000004) +#define TBOND UI64_CONST(0x0000000000000008) +#define TZLOG UI64_CONST(0x0000000000000010) /* zfs logging system */ +#define TZCB UI64_CONST(0x0000000000000020) /* Entry points into Beast B-tree */ +#define TZTREE UI64_CONST(0x0000000000000040) /* Beast B-tree */ +#define TBIO UI64_CONST(0x0000000000000080) /* Beast IO */ +#define TAUTH UI64_CONST(0x0000000000000100) /* ZAS Auth System */ +#define TCOMMON UI64_CONST(0x0000000000000200) +#define TZPOOL UI64_CONST(0x0000000000000400) +#define TZVOL UI64_CONST(0x0000000000000800) +#define TXACTION UI64_CONST(0x0000000000001000) +#define TZPOOLIO UI64_CONST(0x0000000000002000) +#define TNAMING UI64_CONST(0x0000000000004000) +#define TZFREETREE UI64_CONST(0x0000000000008000) +#define TLOCKING UI64_CONST(0x0000000000010000) +#define TMAL UI64_CONST(0x0000000000020000) +#define TNWSAAPI UI64_CONST(0x0000000000040000) /* NWSA NLM APIs */ +#define TPLOG UI64_CONST(0x0000000000080000) /* purge log */ +#define TZLOG2 UI64_CONST(0x0000000000100000) /* ZLOG extra hex dump */ +#define TADMVOL UI64_CONST(0x0000000000200000) +#define TNCP UI64_CONST(0x0000000000400000) /* NWSA NCPs */ +#define TCNTRL UI64_CONST(0x0000000000800000) /* control.c */ +#define TWILD UI64_CONST(0x0000000001000000) /* wildcarding */ +#define TMATCHATTR UI64_CONST(0x0000000002000000) /* match attributes */ +#define TTIMER UI64_CONST(0x0000000004000000) /* timer */ +#define TCREATE UI64_CONST(0x0000000008000000) /* create debug */ +#define TNAMETREE UI64_CONST(0x0000000010000000) /* Name Tree */ +#define TNAMECACHE UI64_CONST(0x0000000020000000) /* Name cache */ +#define TLOCK UI64_CONST(0x0000000040000000) /* Locking */ +#define TYIELDS UI64_CONST(0x0000000080000000) +#define TDELETE UI64_CONST(0x0000000100000000) /* common delete stuff */ +#define TUSERSPC UI64_CONST(0x0000000200000000) /* user space restrictions */ +#define TLVOLUMES UI64_CONST(0x0000000400000000) /* Common Logical Volume items */ +#define TPOOL UI64_CONST(0x0000000800000000) /* Common Pool items */ +#define TUSERX UI64_CONST(0x0000001000000000) /* User tasks and xations */ +#define TLATCH UI64_CONST(0x0000002000000000) +#define TVIRT UI64_CONST(0x0000004000000000) /* virtual file */ +#define TCONNECT UI64_CONST(0x0000008000000000) /* connection info */ +#define TUXACTION UI64_CONST(0x0000010000000000) /* user transaction debug */ +#define TLVDELETE UI64_CONST(0x0000020000000000) /* LV delete info */ + +#define TZAPI UI64_CONST(0x0000080000000000) /* zAPIs */ +#define TNWSACHAIN UI64_CONST(0x0000100000000000) /* NWSA chain to legacy calls */ +#define TDIRQCACHE UI64_CONST(0x0000200000000000) /* directory quota */ +#define TCIFS UI64_CONST(0x0000400000000000) /* CIFS SMB packets */ +#define TPSA UI64_CONST(0x0000800000000000) + +#define TALL UI64_CONST(0xffffffffffffffff) +#define TNONE UI64_CONST(0) + + +#define TZLOG_COLOR CYAN +#define TZLOG2_COLOR LGREEN + + +#define NAME(_x_) static char __NAME__[] = #_x_; + +#define ABORT(_err_) DBG_bugAbort(WHERE " " #_err_, _err_) +#define ERR(_string_, _err_) DBG_error(WHERE, _string_, _err_) +#define NSS_ERROR(_err_) DBG_error(WHERE, #_err_, _err_) ///Abhijit 12/21/98 Error by OS +#define ERRNULL(_string_) DBG_error(WHERE, _string_, 0) +#define FATAL(_string_, _err_) DBG_fatal(WHERE, _string_, _err_) + +char *DBG_UTCTime2Str( + Time_t utcTime, + char *str); + + +#if NSS_DEBUG IS_ENABLED + +#define NOT_IMPLEMENTED() /*fatal*/DBG_error(WHERE, DBG_NotImpDbgMsg, 0) + +#ifdef UNIX +#define CHOKE_DEBUG_LOG() ((void)0) +#define DBGLOCK() ((void)0) +#define DBGUNLOCK() ((void)0) +#define INITDBGIO() ((void)0) +#else +#define CHOKE_DEBUG_LOG() ((void)0) + +#define DBGLOCK() \ + ASSERT_MPKNSS_LOCK(); \ + wLock(DBG_DbgScreen); + +#define DBGUNLOCK() wUnlock(DBG_DbgScreen) +#define INITDBGIO() ((DBG_DbgScreen == NULL) ? DBG_InitDebug() : (void)0) +#endif + +//#define STUBBED() if (DBG_Stub) DBG_error(WHERE, DBG_StubbedMsg, 0) + +/* defines for debugLogMask */ +#define DEBUG_LOG_MEMORY 1 +#define DEBUG_LOG_SCREEN 2 + + + +/* The "_ioprms" must contains the following fields: + * (color,formatstr,optParameters) + * They are used for printing information to the trace or log display */ +#if 0 +//#define DEBUG_PRINTF(_dmask,_ioprms) \ +// if (DBG_DebugFlag & (_dmask)) \ +// { \ +// DebugPrintf _ioprms; \ +// } +#endif + +extern QUAD DBG_ScreenSwitches; + +#define DBG_SS_WHERE 0x00000001 +#define DBG_SS_UTC 0x00000002 +#define DBG_SS_MASK 0x00000004 + + +extern QUAD DBG_DebugMask; + +#define DBG_NOINDENT 0x01 /* use the debug mask -- do not indent */ +#define DBG_INDENT 0x02 /* use the debug mask -- indent if trace on */ +#define DBG_TRACE_NOINDENT 0x04 /* use the trace mask -- don't indent*/ +#define DBG_TRACE 0x08 /* use the trace mask -- indent*/ +#define DBG_BOTH_NOINDENT 0x10 /* use the trace mask and the debug mask -- don't indent*/ +#define DBG_BOTH 0x20 /* use the trace mask and the debug mask -- indent if trace on*/ + +#define DEBUG_PRINTF(_mask,_flag,_ioprms) \ +{ \ + NINT _temp_; \ + BOOL _printFlag_=FALSE; \ + _temp_ = (_flag); \ + if (DBG_TraceFlag & (_mask)) \ + { \ + if (_temp_ & (DBG_TRACE | DBG_BOTH)) \ + { \ + DBG_DebugMask = _mask; \ + INDENT(); DBG_prseq(); \ + } \ + if (_temp_ & (DBG_TRACE | DBG_TRACE_NOINDENT | DBG_BOTH_NOINDENT | DBG_BOTH)) \ + { \ + DBG_DebugMask = _mask; \ + DBG_DebugPrintf _ioprms; \ + _printFlag_ = TRUE; \ + } \ + } \ + if ((DBG_DebugFlag & (_mask)) && !_printFlag_) \ + { \ + if ((_temp_ & (DBG_INDENT | DBG_BOTH)) && DBG_TraceFlag) \ + { \ + DBG_DebugMask = _mask; \ + INDENT(); DBG_prseq(); \ + } \ + if (_temp_ & (DBG_INDENT | DBG_BOTH | DBG_NOINDENT | DBG_BOTH_NOINDENT)) \ + { \ + DBG_DebugMask = _mask; \ + DBG_DebugPrintf _ioprms; \ + } \ + } \ +} +#if 0 +//#define TRACE_NOINDENT_PRINTF(_dmask,_tmask,_ioprms) \ +// if ((DBG_DebugFlag & (_dmask)) || (DBG_TraceFlag & (_tmask))) \ +// { \ +// DBG_DebugPrintf _ioprms; \ +// } +#endif + +#define DEBUG_HEX_DUMP(_dmask, _color, _mode, _memory, _len) \ + if (DBG_DebugFlag & (_dmask)) \ + { \ + DBG_DebugHexDump( _dmask, _color, _mode, _memory, _len); \ + } + + + /* Defines for Debug Hex Dump's Debug Mode flag */ +#define DHD_DM_BYTE 0x0001 +#define DHD_DM_ASCII 0x8000 + +extern void DBG_DebugHexDump( + NINT debugMask, + NINT debugColor, + NINT displayMode, + void *userArea, + int len ); + +/* basic I/O routine for output to the PSS screen, do NOT call this directly*/ +extern void DBG_DebugPrintf( + NINT attr, + const char *formatStr, + ...); + +/* basic I/O routine for output to the NSS Debug Screen */ +extern void DBG_ScreenAPrintf( + char *maskString, + char *where, + NINT attr, + const char *formatStr, + ...); + + + +/*------------------------------------------------------------------------- + * Macros used for TRACING code to the trace screen. + *-------------------------------------------------------------------------*/ +#if 0 +#define ENTER(_tmask, _s_) \ + { \ + /*CHECK_INTERRUPTS();*/ \ + if (DBG_TraceFlag != TNONE) \ + { \ + DBG_Denter(WHERE, _tmask, # _s_);\ + } \ + } +#endif + +#define ENTER(_tamsk, _s_) \ + { \ + extern int pr(const char *); \ + pr(WHERE # _s_); \ + } + +#define INDENT() (DBG_Dindent()) + + /* + * The exit routines prepare to return but + * don't return. Useful in our MP code. + */ +#define EXIT_VOID() \ + { \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnVoid(WHERE); \ + } + +#define RTN_VOID() \ + { \ + /*CHECK_INTERRUPTS();*/ \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnVoid(WHERE); \ + return; \ + } +#define RTN_SNINT(_i) \ + { \ + SNINT __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnSNINT(WHERE, __i); \ + return __i; \ + } +#define RTN_NINT(_i) \ + { \ + NINT __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + return __i; \ + } +#define RTN_BLOCK(_i) \ + { \ + Blknum_t __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + return __i; \ + } + +#define RTN_BYTE(_i) \ + { \ + BYTE __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + return __i; \ + } +#define RTN_BOOL(_i) \ + { \ + BOOL __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + return __i; \ + } +#define RTN_STATUS(_i) \ + { \ + STATUS __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnStatus(WHERE, __i); \ + return __i; \ + } +#define RTN_PTR(_p) \ + { \ + void *__p = (_p); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnPtr(WHERE, __p); \ + return __p; \ + } +#define RTN_LONG(_i) \ + { \ + NINT __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + return __i; \ + } + +#define RTN_ZID(_i) \ + { \ + Zid_t __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnQUAD(WHERE, __i); \ + return __i; \ + } + +#define RTN_MPKUNLOCK_VOID() \ + { \ + /*CHECK_INTERRUPTS();*/ \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnVoid(WHERE); \ + MPKNSS_UNLOCK(); \ + return; \ + } +#define RTN_MPKUNLOCK_SNINT(_i) \ + { \ + SNINT __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnSNINT(WHERE, __i); \ + MPKNSS_UNLOCK(); \ + return __i; \ + } +#define RTN_MPKUNLOCK_NINT(_i) \ + { \ + NINT __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + MPKNSS_UNLOCK(); \ + return __i; \ + } +#define RTN_MPKUNLOCK_BLOCK(_i) \ + { \ + Blknum_t __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + MPKNSS_UNLOCK(); \ + return __i; \ + } + +#define RTN_MPKUNLOCK_BYTE(_i) \ + { \ + BYTE __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + MPKNSS_UNLOCK(); \ + return __i; \ + } +#define RTN_MPKUNLOCK_BOOL(_i) \ + { \ + BOOL __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + MPKNSS_UNLOCK(); \ + return __i; \ + } +#define RTN_MPKUNLOCK_STATUS(_i) \ + { \ + STATUS __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnStatus(WHERE, __i); \ + MPKNSS_UNLOCK(); \ + return __i; \ + } +#define RTN_MPKUNLOCK_PTR(_p) \ + { \ + void *__p = (_p); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnPtr(WHERE, __p); \ + MPKNSS_UNLOCK(); \ + return __p; \ + } +#define RTN_MPKUNLOCK_LONG(_i) \ + { \ + NINT __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnNINT(WHERE, __i); \ + MPKNSS_UNLOCK(); \ + return __i; \ + } + +#define RTN_MPKUNLOCK_ZID(_i) \ + { \ + Zid_t __i = (_i); \ + /*CHECK_INTERRUPTS();*/ \ + \ + if (DBG_TraceFlag != TNONE) \ + DBG_DrtnQUAD(WHERE, __i); \ + MPKNSS_UNLOCK(); \ + return __i; \ + } + + +#if 0 +//#define DEBUG(_x_) ((void) (zDebug && (_x_))) +//#define BUG(_x_) ((void)((_x_) && debug(WHERE " " #_x_))) +//#define PRx(_x_) (prx(WHERE " " #_x_, (unsigned long)_x_)) +//#define PRd(_x_) (prd(WHERE " " #_x_, (unsigned long)_x_)) +//#define PRc(_x_) (prc(WHERE " " #_x_, (char)_x_)) +//#define PRs(_x_) (prs(WHERE " " #_x_, (char *)_x_)) +//#define PR(_s_) (pr(WHERE " " #_s_)) +//#define HERE (here(WHERE)) +//#define STOP (stop(WHERE)) +// +//#define TPRx(_t_,_x_) ((void)(zDebug && (_t_) && \ +// prx(WHERE " " #_x_, (unsigned long)_x_))) +// +//#define TPRd(_t_,_x_) ((void)(zDebug && (_t_) && \ +// prd(WHERE " " #_x_, (unsigned long)_x_))) +// +//#define TPRc(_t_,_x_) ((void)(zDebug && (_t_) && \ +// prc(WHERE " " #_x_, (char)_x_))) +// +//#define TPR(_t_,_x_) ((void)(zDebug && (_t_) && \ +// pr(WHERE, #_x_))) +// +//#define TSPY(_t_) ((void)(zDebug && (_t_) && SPY)) +//#define TSTOP(_t_) ((void)(zDebug && (_t_) && STOP)) +//#define TEST(_t_) ((void)(zDebug && (_t_) && \ +// pr(WHERE " " #_t_))) +//#define T(_t_,_x_) ((void)(zDebug && (_t_) && \ +// pr(WHERE " " #_x_))) +// +// +//#define DPRx(_x_) ((void)(zDebug && \ +// prx(WHERE " " #_x_, (unsigned long)_x_))) +// +//#define DPRd(_x_) ((void)(zDebug && \ +// prd(WHERE " " #_x_, (unsigned long)_x_))) +// +//#define DPRc(_x_) ((void)(zDebug && \ +// prc(WHERE " " #_x_, (char)_x_))) +// +//#define DPRs(_x_) ((void)(zDebug && \ +// prs(WHERE " " #_x_, (char *)_x_))) +// +//#define DPR(_x_) ((void)(zDebug && \ +// pr(WHERE " " #_x_))) +// +//#define DHERE ((void)(zDebug && HERE)) +//#define DSTOP ((void)(zDebug && STOP)) +// +//#define TR(_t_, _x_) ((void)((zTrace & (_t_)) && \ +// tr(WHERE " " #_x_))) +// +//#define TR1(_t_, _x_) ((void)((zTrace & (_t_)) && \ +// (zTraceLevel >= 1) && \ +// tr(WHERE " " #_x_))) +// +//#define TR2(_t_, _x_) ((void)((zTrace & (_t_)) && \ +// (zTraceLevel >= 2) && \ +// tr(WHERE " " #_x_))) +// +//#define TR3(_t_, _x_) ((void)((zTrace & (_t_)) && \ +// (zTraceLevel >= 3) && \ +// tr(WHERE " " #_x_))) +// +//#define TR4(_t_, _x_) ((void)((zTrace & (_t_)) && \ +// (zTraceLevel >= 4) && \ +// tr(WHERE " " #_x_))) +// +//#define TR5(_t_, _x_) ((void)((zTrace & (_t_)) && \ +// (zTraceLevel >= 5) && \ +// tr(WHERE " " #_x_))) +// +//#define CNT(id) debugCount(WHERE " " # id) +// +//#define SETWHERE() (zDebugWhere = WHERE) +//#define CLRWHERE() (zDebugWhere = NULL) +// +/*#define IN(_x_) (printDepth("in" #_x_), ++Depth)*/ +/*#define OUT(_x_) (--Depth, printDepth("out" #_x_))*/ +// +// +//#define ZIN(_msg, _zid, _logical, _physical) \ +// (ztrace("IN " #_msg, (_zid), (_logical), (_physical))) +// +//#define ZOUT(_msg, _zid, _logical, _physical) \ +// (ztrace("OUT " #_msg, (_zid), (_logical), (_physical))) +#endif + + +#else /* NSS_DEBUG */ + +/*========================================================================= + * These are versions of the debug macros that do nothing + *=========================================================================*/ +#define NOT_IMPLEMENTED() ((void)0) +#define CHOKE_DEBUG_LOG() ((void)0) +#define INITDBGIO() ((void)0) +#define DBGLOCK() ((void)0) +#define DBGUNLOCK() ((void)0) +//#define STUBBED() ((void)0) + +#if 0 +//#define DEBUG(_x_) ((void) 0) +// +//#define PRx(_x_) ((void) 0) +//#define PRd(_x_) ((void) 0) +//#define PRc(_x_) ((void) 0) +//#define PRs(_x_) ((void) 0) +//#define PR(_s_) ((void) 0) +//#define HERE ((void) 0) +//#define STOP ((void) 0) +// +//#define TPRx(_x_) ((void) 0) +//#define TPRd(_x_) ((void) 0) +//#define TPRc(_x_) ((void) 0) +//#define TPR(_s_) ((void) 0) +//#define TSPY ((void) 0) +//#define TSTOP ((void) 0) +//#define T ((void) 0) +// +//#define DPRx(_x_) ((void) 0) +//#define DPRd(_x_) ((void) 0) +//#define DPRc(_x_) ((void) 0) +//#define DPR(_s_) ((void) 0) +//#define DSPY ((void) 0) +//#define DSTOP ((void) 0) +//#define TR(_t_, _x_) ((void) 0) +//#define TR1(_t_, _x_) ((void) 0) +//#define TR2(_t_, _x_) ((void) 0) +//#define TR3(_t_, _x_) ((void) 0) +//#define TR4(_t_, _x_) ((void) 0) +//#define TR5(_t_, _x_) ((void) 0) +// +//#define CNT(id) ((void) 0) +// +//#define SETWHERE() ((void) 0) +//#define CLRWHERE() ((void) 0) +// +//#define IN(_x_) ((void) 0) +//#define OUT(_x_) ((void) 0) +// +//#define ZIN(_msg, _zid, _logical, _physical) ((void) 0) +//#define ZOUT(_msg, _zid, _logical, _physical) ((void) 0) +#endif + +#define DEBUG_PRINTF(_mask,_flag,_ioprms) ((void) 0) +//#define TRACE_PRINTF(_dmask,_tmask,_ioprms) ((void) 0) +//#define TRACE_NOINDENT_PRINTF(_dmask,_tmask,_ioprms) ((void) 0) +#define DEBUG_HEX_DUMP(_dmask, _color, _mode, _memory, _len) ((void) 0) + +#define ENTER(_t,_s) ((void) 0) +#define INDENT() ((void) 0) +#define EXIT_VOID() ((void) 0) + +#define RTN_VOID() return +#define RTN_SNINT(_i) return (_i) +#define RTN_NINT(_i) return (_i) +#define RTN_BLOCK(_i) return (_i) +#define RTN_BYTE(_i) return (_i) +#define RTN_BOOL(_i) return (_i) +#define RTN_STATUS(_i) return (_i) +#define RTN_PTR(_p) return (_p) +#define RTN_LONG(_p) return (_p) +#define RTN_ZID(_q) return (_q) + +#define RTN_MPKUNLOCK_VOID() MPKNSS_UNLOCK(); return +#define RTN_MPKUNLOCK_SNINT(_i) MPKNSS_UNLOCK(); return (_i) +#define RTN_MPKUNLOCK_NINT(_i) MPKNSS_UNLOCK(); return (_i) +#define RTN_MPKUNLOCK_BLOCK(_i) MPKNSS_UNLOCK(); return (_i) +#define RTN_MPKUNLOCK_BYTE(_i) MPKNSS_UNLOCK(); return (_i) +#define RTN_MPKUNLOCK_BOOL(_i) MPKNSS_UNLOCK(); return (_i) +#define RTN_MPKUNLOCK_STATUS(_i) MPKNSS_UNLOCK(); return (_i) +#define RTN_MPKUNLOCK_PTR(_p) MPKNSS_UNLOCK(); return (_p) +#define RTN_MPKUNLOCK_LONG(_p) MPKNSS_UNLOCK(); return (_p) +#define RTN_MPKUNLOCK_ZID(_q) MPKNSS_UNLOCK(); return (_q) + +#endif /* NSS_DEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PSSDEBUG_H_ */ diff --git a/include/core/schedule.h b/include/core/schedule.h new file mode 100644 index 0000000..c9c01ec --- /dev/null +++ b/include/core/schedule.h @@ -0,0 +1,402 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _SCHEDULE_H_ +#define _SCHEDULE_H_ + +#if zLINUX +#include "linuxmpk.h" +#endif + +#ifndef _ZOMNI_H_ +# include +#endif + +#ifndef _PSSDEBUG_H_ +# include +#endif + +#ifndef _INST_H_ +# include +#endif + +#ifndef _PSSMPK_H_ +# include +#endif + +#ifndef _NSSOSAPIS_H_ +# include +#endif + +#ifndef _INLINES_H_ +# include +#endif + +#ifndef _QUE_H_ +#include +#endif + +#ifndef _OSMPKHDRS_H_ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Pre-define struct(s) so Linux compiler doesn't complain */ +struct WorkToDoStructure; + +/*- AES structure defines -*/ +#define AESNOTINUSE 0 +#define AESBEINGUSED 1 + +/*- thread priority -*/ +#define THREAD_HIGH 0 +#define THREAD_MED 1 +#define THREAD_LOW 2 + + +/*- this structure is the same size as AESProcessStructure in aesproc.h -*/ +typedef struct zAESP_s +{ + LONG osReserved0; /* set NULL by user */ + LONG timeDelay; /* always set by user */ + LONG osReserved1; /* set NULL by user */ + voidfunc_t ProcedureToCall; /* always set by user */ + struct ResourceTagStructure *AESResourceTag; /* always set by user */ + LONG osReserved2; /* set NULL by user */ +} zAESP_s; + +/*- this structure is only used in the do it yourself AES Process -*/ +typedef struct zAESProc_s +{ + zAESP_s zaesp; + LONG inUseFlag; + void *info; +} zAESProc_s; + +extern CIRhead_t QueuedThreads; +extern CIRhead_t QueuedThreadsHigh; +extern BOOL waitForWorkHigh(void); +extern BOOL waitForWork(void); + +typedef struct ThreadsQueue_s +{ + CIRlink_t nextThread; + ADDR threadID; +} ThreadsQueue_s; + + /* + * library prototypes + */ +extern void LB_delay( + NINT millisec); + + + /* + * Work To Do Scheduling routines + */ +extern void fillInWork( + void *process, + voidfunc_t procedureToCall, + void *userParameter); + + /* + * Async Event Scheduling routines + */ +extern LONG makeAESP( + voidfunc_t procedureToCall, + LONG delayTime, + void *userParameter); + +/*- Process Thread routines -*/ +extern STATUS InitThreadProcess(); + +extern void UninitThreadProcess(); + +extern STATUS CreateThread( + voidfunc_t ExecuteRoutine, + char *threadName, + LONG priority, + LONG *retThreadID); + +extern STATUS DestroyThread( + LONG threadID); + +/* MP APIs*/ +extern ERROR kDestroyThread(THREAD ThreadHandle); + +extern THREAD kCurrentThread(void); +extern ERROR kDelayThread(unsigned int); + +#define ThreadId() (ADDR)kCurrentThread() + +extern ERROR kWakeUp(THREAD); +extern void kSleep(); +extern void kYieldThread(); + + /* + * Routines that are in NetWare that we are calling directly to get the + * desired functionality. + */ +extern LONG GetRunningProcess(void); +extern void CDestroyProcess(LONG processID); +extern LONG CMakeProcess( + LONG schedulingPriority, + void (*codeAddress)(void), + void *stackTopAddress, + LONG stackLength, + BYTE *processName, + struct ResourceTagStructure *RTag); /* ProcessSignature */ + + /* + * Function prototypes for NetWare interfaces + */ +extern void CSleepUntilInterrupt(void); +extern void CRescheduleFromInterrupt(LONG processID); +extern void CYieldIfNeeded(void); +extern void CYieldUntilIdle(void); + + +#define Wait() \ +{ \ + DEBUG_PRINTF(TYIELDS,DBG_BOTH_NOINDENT, \ + (LRED, "Thread Waiting(%08x):%s\n", ThreadId(), WHERE)); \ + ZOS_Sleep(); \ + DEBUG_PRINTF(TYIELDS,DBG_BOTH_NOINDENT, \ + (LRED, "Returning from WAIT(%08x):%s\n", ThreadId(), WHERE)); \ +} + +#define Continue(pid) \ +{ \ + DEBUG_PRINTF(TYIELDS,DBG_BOTH_NOINDENT, \ + (LRED, "Waking Thread(%08x):%s\n", pid, WHERE)); \ + ZOS_WakeUp((THREAD)pid); \ +} + + +#define Yield() \ +{ \ + DEBUG_PRINTF(TYIELDS,DBG_BOTH_NOINDENT, \ + (LRED, "Yielding Thread(%08x):%s\n", ThreadId(), WHERE)); \ + ZOS_YieldThread(); \ + DEBUG_PRINTF(TYIELDS, DBG_BOTH_NOINDENT, \ + (LRED, "Returning from YIELD(%08x):%s\n", ThreadId(), WHERE)); \ +} + +#ifdef __linux__ +# define EnableInts() sti() +#else +void EnableInts(void); +#pragma aux EnableInts = \ + "sti" \ + modify exact []; +#endif + + + + /* + * To allow other threads to run, we have to yield periodically in the + * the code. PERIODIC_YIELD checks if we should do a periodic yield. + */ + +extern LONG TimeToYield; + +#if zLINUX + +#define PERIODIC_YIELD_COUNT 50 + +extern BOOL gYieldJiffy; +extern LONG gYieldCount; +extern LONG gYieldPeriodicCount; + +#define PERIODIC_YIELD() \ + if (TimeToYield != jiffies) \ + { \ + TimeToYield = jiffies; \ + if (gYieldJiffy) \ + { \ + Yield(); \ + } \ + else if (gYieldCount++ == gYieldPeriodicCount) \ + { \ + gYieldCount=0; \ + Yield(); \ + } \ + } +#endif + +#if zNETWARE +extern LONG CurrentTime; + +#define PERIODIC_YIELD() \ + if (TimeToYield != CurrentTime) \ + { \ + TimeToYield = CurrentTime; \ + Yield(); \ + } + +#endif +/* + * Snooze routines for letting threads sleep on a queue and then + * rousting them (scheduling) them all at the same time. + */ + +STATUS snoozeSec(DQhead_t *list, NINT seconds); +void roust(DQhead_t *list, STATUS status); + + +/*------------------------------------------------------------------------- + * This is the internal support definitions for NetWare WorkToDo routines. + * IMPORTANT NOTE: normally in NSS you should NOT be using this workToDo + * code. You should call WORK_Schedule (defined in + * xCache.h). + *-------------------------------------------------------------------------*/ +/*- this structure is the same size as WorkToDoStructure in thread.h -*/ +typedef struct zWork_s +{ + LONG osReserved; /* set NULL by user */ + voidfunc_t ProcedureToCall; /* always set by user */ + struct ResourceTagStructure *WorkResourceTag; /* always set by user */ + LONG reserved[2]; /* set NULL by user */ +} zWork_s; + +/*- this structure is only used in the do it yourself work to do -*/ +typedef struct zWorkProc_s +{ + struct zWork_s zwork; + void *info; +} zWorkProc_s; + +typedef struct zWorkProc2_s +{ + struct zWork_s zwork; + void *info; + void *info2; +} zWorkProc2_s; + + +#if MPK_REAL IS_ENABLED + #define WORK_PROCESS_INIT() +#else + #define WORK_PROCESS_INIT() Enable() +#endif + +/************************************************************************** + * + * + * Abhijit + * + * MPK changes 6th Oct 1998 + * + * + * Following are the changes to the library schedule routines which + * has been made to be compatible with the MPK APIS which are SMP + * aware. + * + * These APIS are to be added to the .imp file and put in the + * Modules.bld file + * + * The header files MPKAPIS.h, MPKLIB.h, MPKtypes.h, MPKOSLIB.h + * are to be included in the include search path in our environment + * + **************************************************************************/ + + + + extern ERROR kScheduleWorkToDo(struct WorkToDoStructure *); + extern ERROR kScheduleFastWorkTo(struct WorkToDoStructure *); + extern ERROR kCancelWorkToDo(struct WorkToDoStructure *); + + + #define ScheduleWork(_work) \ + ZOS_ScheduleWorkToDo((struct WorkToDoStructure *)_work) + + #define ScheduleFastWork(_work) \ + ZOS_ScheduleFastWorkToDo((struct WorkToDoStructure *)_work,1) + + #define CancelWork(_work) \ + ZOS_CancelWorkToDo((struct WorkToDoStructure *)_work) + + +/* When you use the CHECK macros uncomment the SIGNAL macros from the + * WORK_Run code + */ +#define CHECK_AND_WAIT_FOR_HIGH_WORK() \ + ((void)((WorkHighWaitingCount >= Config.work.waitingHigh) && waitForWorkHigh())) + +#define CHECK_AND_WAIT_FOR_WORK() \ + ((void)((WorkWaitingCount >= Config.work.waiting) && waitForWork())) + +#define SIGNAL_NEXT_THREAD() \ +{ \ + ThreadsQueue_s *_queue; \ + if (WorkWaitingCount < (Config.work.waiting >> 1)) \ + { \ + if (CIR_NOT_EMPTY(QueuedThreads)) \ + { \ + CIR_DEQ_NO_CHECK(QueuedThreads, _queue, ThreadsQueue_s, \ + nextThread); \ + Continue(_queue->threadID); \ + } \ + } \ +} + +#define SIGNAL_NEXT_THREAD_HIGH() \ +{ \ + ThreadsQueue_s *_queue; \ + if (WorkHighWaitingCount < (Config.work.waitingHigh >> 1)) \ + { \ + if (CIR_NOT_EMPTY(QueuedThreadsHigh)) \ + { \ + CIR_DEQ_NO_CHECK(QueuedThreadsHigh, _queue, ThreadsQueue_s, \ + nextThread); \ + Continue(_queue->threadID); \ + } \ + } \ +} +#ifdef __cplusplus +} +#endif + +#endif /* _SCHEDULE_H_ */ diff --git a/include/core/xStdio.h b/include/core/xStdio.h new file mode 100644 index 0000000..398799e --- /dev/null +++ b/include/core/xStdio.h @@ -0,0 +1,137 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library file + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _XSTDIO_H_ +#define _XSTDIO_H_ + +#ifndef _STDARG_H_ +# include +#endif + +#ifndef _SIZE_T +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*------------------------------------------------------------------------- + * SCREEN color definitions + *-------------------------------------------------------------------------*/ +#define BLACK 0 +#define BLUE 1 +#define GREEN 2 +#define CYAN 3 +#define RED 4 +#define MAGENTA 5 +#define BROWN 6 +#define LGRAY 7 +#define DARKGRAY 8 +#define LBLUE 9 +#define LGREEN 10 +#define LCYAN 11 +#define LRED 12 +#define LMAGENTA 13 +#define YELLOW 14 +#define WHITE 15 + +extern int LB_getchar(void); + +extern char *LB_gets( + char *buf); + +extern void LB_printf( + const char *__format, + ...); + +extern int LB_snprintf( + char *destBuf, + size_t destBufSize, + const char *format, + ...); + +extern void LB_sprintf( + char *__s, + const char *__format, + ...); + +extern void LB_vaprintf( + int attr, + const char *format, + va_list args); + +extern void LB_vprintf( + const char *__format, + va_list __arg); + +extern void LB_vsprintf( + char *__s, + const char *__format, + va_list __arg); + +extern int LB_vsnprintf( + char *destBuf, + size_t destBufSize, + const char *format, + va_list args ); + +/*------------------------------ PSS Routines -----------------------------*/ + +extern void LB_aprintf( + int attribute, + const char *__format, + ...); + +extern void LB_errPrintf( + const char *where, + const char *moduleName, + int errnum, + const char *formatStr, + ...); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 256f3b0..784642a 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -79,6 +79,22 @@ configure_file( "${CMAKE_SOURCE_DIR}/include/core/mailbox.h" "${NWCORE_BUILD_INCLUDE_DIR}/mailbox.h" COPYONLY) +configure_file( + "${CMAKE_SOURCE_DIR}/include/core/pssDebug.h" + "${NWCORE_BUILD_INCLUDE_DIR}/pssDebug.h" + COPYONLY) +configure_file( + "${CMAKE_SOURCE_DIR}/include/core/inlines.h" + "${NWCORE_BUILD_INCLUDE_DIR}/inlines.h" + COPYONLY) +configure_file( + "${CMAKE_SOURCE_DIR}/include/core/xStdio.h" + "${NWCORE_BUILD_INCLUDE_DIR}/xStdio.h" + COPYONLY) +configure_file( + "${CMAKE_SOURCE_DIR}/include/core/schedule.h" + "${NWCORE_BUILD_INCLUDE_DIR}/schedule.h" + COPYONLY) configure_file( "${CMAKE_SOURCE_DIR}/include/core/size_t.h" "${NWCORE_BUILD_INCLUDE_DIR}/size_t.h" @@ -196,6 +212,7 @@ add_library(nwcore SHARED ini.c histogram.c mailbox.c + pssDebug.c pssmpk.c ${NWCORE_IMPORTED_NSS_SOURCES} ) diff --git a/src/core/pssDebug.c b/src/core/pssDebug.c new file mode 100644 index 0000000..acce004 --- /dev/null +++ b/src/core/pssDebug.c @@ -0,0 +1,536 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#ifndef UNIX +#define UNIX 1 +#endif +#ifndef UNIX +#include +#endif +#include +#include + + +#if NSS_DEBUG IS_ENABLED + +char DBG_NotImpDbgMsg[] = MSGNot("NOT IMPLEMENTED YET"); +//char DBG_StubbedMsg[] = MSGNot("STUBBED"); +BOOL DBG_Stub = FALSE; +BOOL DBG_ScreenDebug = FALSE; +BOOL DBG_DebugEnabled = FALSE; +BOOL DBG_TraceEnabled = FALSE; + + +//#define HALT TRUE + +//#define ALTO {bugWait(); grabdebug();} + +NINT DBG_Sequence = 0; +//unsigned zMatcher = 0; +//QUAD DBG_DebugFlag = TNONE; /* debug is disabled*/ +#ifdef USER_GPACHNER +QUAD DBG_DebugFlag = TZVOL|TZPOOL|TLVOLUMES|TPOOL|TLVDELETE|TZPOOLIO; /* All LV stuff until it is working */ +#else +QUAD DBG_DebugFlag = 0; +#endif +QUAD DBG_SavedDebugFlag = TALL; /* toggle state defaults to all tracing*/ +QUAD DBG_TraceFlag = TNONE; /* all tracing default off*/ +QUAD DBG_SavedTraceFlag = TALL; /* toggle state defaults to all tracing*/ +//unsigned zAudit = 0; +//unsigned zLongTrace = 0; +NINT DBG_Paging = 0; +NINT DBG_PageSize = 20; +//unsigned zStop = TRUE; +//unsigned zTraceLevel = 9; +//int zDepth = 0; +//NINT zfsDebugBtree = 0; /* no btree debug */ +//char *zDebugWhere = NULL; + + +/*------------------------------------------------------------------------- + * + *-------------------------------------------------------------------------*/ +void DBG_prseq (void) +{ + PRINT(CYAN) MSGNot("%d|UTC=%d|"), DBG_Sequence++, GetUTCTime()); +} + +///*------------------------------------------------------------------------- +// * +// *-------------------------------------------------------------------------*/ +//grabdebug (void) +//{ +// /* Just here so we can grab things with ddb */ +// return TRUE; +//} + +///*------------------------------------------------------------------------- +// * +// *-------------------------------------------------------------------------*/ +//void DBG_bugWait (void) +//{ +// PRINT(YELLOW) MSGNot("Press any key to continue")); +// +//#ifndef UNIX +// wActivate(DBG_DbgScreen); +// wGetc(DBG_DbgScreen); +//#else +// getchar(); +//#endif +// +// PRINT(LGRAY) +// MSGNot("") /* back spaces*/ +// MSGNot(" ") +// MSGNot("")); +//} + +//static void match (int halt) +//{ +// if (zPaging && (zSequence % zPageSize == 0)) +// { +// PRINT(YELLOW) MSGNot("#####PAGE#####")); +// PRINT(LGRAY) MSGNot(" %x\n"), &zPaging); +// if (halt) ALTO; +// } +// if (zMatcher == zSequence) +// { +// PRINT(LGRAY) MSGNot("####MATCH#### %x\n"), &zMatcher); +// if (halt) ALTO; +// } +//} + +//stop (char *where) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%s *** ALTO ***\n"), where); +// match(!HALT); +// if (zStop) ALTO; +// DBGUNLOCK(); +// return TRUE; +//} +// +//here (char *where) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%s\n"), where); +// match(!HALT); +// DBGUNLOCK(); +// return TRUE; +//} +// +//debug (char *what) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%s\n"), what); +// match(!HALT); +// if (zStop) ALTO; +// DBGUNLOCK(); +// return TRUE; +//} +// +//bugAbort (char *what, int errCode) +//{ +// static char abortmsg[] = MSGNot("ABORT %s=%d\n"); +// +// INITDBGIO(); +// DBGLOCK(); +// PRINT(LRED) abortmsg, what, errCode); +// match(!HALT); +// if (zStop) ALTO; +// DBGUNLOCK(); +//#ifdef UNIX +// printf(abortmsg, what, errCode); +//#else +// OutputToScreenWithAttribute(Resource.debuggerScreenID,LRED,abortmsg, what, errCode); +//#endif +// ZOS_EnterDebugger(); +// return errCode; +//} +// +//spy (char *where) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRINT(LGRAY) MSGNot("%d@%s\n"), where); +// match(HALT); +// DBGUNLOCK(); +// return TRUE; +//} +// +//tr (char *what) +//{ +// INITDBGIO(); +// DBGLOCK(); +// if (zLongTrace) +// { +// PRSEQ(LGRAY) MSGNot("%s\n"), what); +// } +// else +// { +// PRSEQ(LGRAY) MSGNot("%s\n"), what /*need to parse out good stuff*/); +// } +// match(TRUE); +// DBGUNLOCK(); +// return TRUE; +//} +// +//pr (char *what) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%s\n"), what); +// match(TRUE); +// DBGUNLOCK(); +// return TRUE; +//} +// +//prc (char *what, char value) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%s=%c\n"), what, value); +// match(HALT); +// DBGUNLOCK(); +// return TRUE; +//} +// +//prs (char *what, char *value) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%s=%s\n"), what, value); +// match(HALT); +// DBGUNLOCK(); +// return TRUE; +//} +// +//prd (char *what, unsigned value) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%s=%d\n"), what, value); +// match(HALT); +// DBGUNLOCK(); +// return TRUE; +//} +// +//prx (char *what, unsigned value) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%s=%x\n"), what, value); +// match(HALT); +// DBGUNLOCK(); +// return TRUE; +//} + +/* + * Routines for entering and exiting functions + */ +//#include "schedule.h" + +//#define MAX_HERE 200 + +//LONG Here[MAX_HERE] = { 0 }; +//NINT NumHere = 0; + +//void BeenHere () +//{ +// LONG myThread; +// NINT i; +// +// myThread = (LONG)kCurrentThread(); +// +// for (i = 0; i < NumHere; ++i) +// { +// if (Here[i] == myThread) +// { +// FATAL(MSGNot("Been here; Done that"), myThread); +// } +// } +// Here[NumHere++] = myThread; +//} + +//void NotHere () +//{ +// LONG myThread; +// NINT i; +// +// myThread = (LONG)kCurrentThread(); +// +// for (i = 0; i < NumHere; ++i) +// { +// if (Here[i] == myThread) +// { +// Here[i] = Here[--NumHere]; +// return; +// } +// } +// FATAL(MSGNot("Haven't been here!"), myThread); +//} + +/************************************************************************** + * Returns a static buffer with the data + ***************************************************************************/ +char *DBG_DebugFormatBinary( + char *buf, + NINT len) +{ + NINT i; + static char retBuf[32]; + + if (len > 32) + len = 32; + for (i=0;i < len;i++) + { + retBuf[i] = (((buf[i] >= ' ') && (buf[i] <= '~')) ? buf[i] : '.'); + } + return retBuf; +} + + + +/************************************************************************** + * + ***************************************************************************/ +//typedef struct COUNTER { +// char *what; +// unsigned count; +//} COUNTER; +// +//#define MAX_COUNTERS 20 +// +//COUNTER Counters[MAX_COUNTERS+1] = { 0 }; +// +//debugCount (char *what) +//{ +// unsigned i; +// +// for (i = 0; what != Counters[i].what; ++i) +// { +// if (Counters[i].what == NULL) +// { +// if (i < MAX_COUNTERS) +// { +// Counters[i].what = what; +// Counters[i].count = 1; +// return 1; +// } +// else +// { +// return 0; +// } +// } +// } +// return ++Counters[i].count; +//} + +/* START BLOCK COMMENT +**void printCount () +**{ +** unsigned i; +** +** for (i = 0; Counters[i].what != NULL; ++i) +** { +** PRINT(LGRAY) MSGNot("%s=%d\n"), Counters[i].what, Counters[i].count); +** } +**} +** END BLOCK COMMENT */ + +//printDepth (char *string) +//{ +// unsigned i; +// +// INITDBGIO(); +// DBGLOCK(); +// for (i = 0; i < zDepth; ++i) +// { +// PRINT(LGRAY) MSGNot("\t")); +// } +// PRINT(LGRAY) MSGNot("%s\n"), string); +// DBGUNLOCK(); +// return TRUE; +//} + +/* + * Tracing for zfs block level events + */ + +//typedef struct Ztrace_s +//{ +// char *msg; +// Zid_t zid; +// Blknum_t logical; +// Blknum_t physical; +//} Ztrace_s; +// +//#define NUM_TRACES 1024 +// +////Ztrace_s ZtraceMap[NUM_TRACES]; //= { 0 }; C++ doesn't GROK this +//Ztrace_s *ZtraceMap=0; +//Ztrace_s *Znext = 0; //ZtraceMap; +//NINT ZnumWrap = 0; +//NINT ZdumpCnt; + +//void zprint (Ztrace_s *trace) +//{ +// INITDBGIO(); +// DBGLOCK(); +// PRSEQ(LGRAY) MSGNot("%.25s %4x %8x %8x\n"), trace->msg, trace->zid, +// trace->logical, trace->physical); +// match(HALT); +// DBGUNLOCK(); +//} + +//void zdump (Ztrace_s *trace) +//{ +// PRINT(LGRAY) MSGNot("%.25s %4x %8x %8x\n"), trace->msg, trace->zid, +// trace->logical, trace->physical); +// if ((++ZdumpCnt % zPageSize) == 0) +// { +// PRINT(YELLOW) MSGNot("--------------------------------------\n")); +// ZOS_EnterDebugger(); +// } +//} + +//ztrace (char *msg, Zid_t zid, Blknum_t logical, Blknum_t physical) +//{ +// Znext->msg = msg; +// Znext->zid = zid; +// Znext->logical = logical; +// Znext->physical = physical; +// +// zprint(Znext); +// +// ++Znext; +// if (Znext == &ZtraceMap[NUM_TRACES]) +// { +// Znext = ZtraceMap; +// ++ZnumWrap; +// } +// return TRUE; +//} + +//void zdumpMap () +//{ +// Ztrace_s *trace; +// Ztrace_s *last; +// NINT line = 1; +// NINT cr = 0; +// +// printf(MSGNot("Begin Map Dump--------------------------\n")); +// +// if (Znext == ZtraceMap) +// { +// last = &ZtraceMap[NUM_TRACES - 1]; +// } +// else +// { +// last = Znext - 1; +// } +// if (ZnumWrap != 0) +// { +// for (trace = Znext; trace < &ZtraceMap[NUM_TRACES]; ++trace, ++line) +// { +// if ((trace->zid == last->zid) && (trace->logical == last->logical)) +// { +// printf(MSGNot("%4d %.25s %4x %8x %8x"), line, trace->msg, trace->zid, +// trace->logical, trace->physical); +// if (cr++ & 1) printf(MSGNot("\n")); +// } +// } +// } +// for (trace = ZtraceMap; trace < Znext; ++trace, ++line) +// { +// if ((trace->zid == last->zid) && (trace->logical == last->logical)) +// { +// printf(MSGNot("%4d %.25s %4x %8x %8x"), line, trace->msg, trace->zid, +// trace->logical, trace->physical); +// if (cr++ & 1) printf(MSGNot("\n")); +// } +// } +// +//#if 0 +// ZdumpCnt = 0; +// +// for (trace = Znext - 1; trace > ZtraceMap; --trace) +// { +// zdump(trace); +// } +// zdump(ZtraceMap); +// if (ZnumWrap > 0) +// { +// for (trace = &ZtraceMap[NUM_TRACES] - 1; trace > Znext - 1; --trace) +// { +// zdump(trace); +// } +// } +//#endif +//} +// +//void printBitMap (NINT *map, NINT numBits) +//{ +// NINT i; +// NINT column; +// +// for (i = 0, column = 0; i < numBits; i += BITS_PER_NINT) +// { +// printf(MSGNot("%.8x"), *map++); +// if (column == 7) +// { +// printf(MSGNot("\n")); +// column = 0; +// } +// else +// { +// printf(MSGNot(" ")); +// ++column; +// } +// } +// if (i != numBits) +// { +// printf(MSGNot("%.8x\n"), *map); +// } +// else if (column != 0) +// { +// printf(MSGNot("\n")); +// } +//} + +#endif /* NSS_DEBUG */ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0f58800..35923b2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -21,6 +21,7 @@ if(MARS_NWE_BUILD_NWFS_TESTS) add_subdirectory(core/spinlock) add_subdirectory(core/pssmpk) add_subdirectory(core/mailbox) + add_subdirectory(core/pssdebug) endif() add_subdirectory(nwfs) endif() diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index 9424e25..79fb299 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -7,6 +7,7 @@ add_subdirectory(log) add_subdirectory(spinlock) add_subdirectory(pssmpk) add_subdirectory(mailbox) +add_subdirectory(pssdebug) add_subdirectory(bit) add_subdirectory(bitmap) add_subdirectory(crc) diff --git a/tests/core/pssdebug/CMakeLists.txt b/tests/core/pssdebug/CMakeLists.txt new file mode 100644 index 0000000..832c47a --- /dev/null +++ b/tests/core/pssdebug/CMakeLists.txt @@ -0,0 +1,6 @@ +add_executable(test_nwcore_pssdebug test_nwcore_pssdebug.c) +target_compile_features(test_nwcore_pssdebug PRIVATE c_std_99) +target_include_directories(test_nwcore_pssdebug PRIVATE + "${CMAKE_SOURCE_DIR}/include/core") +target_link_libraries(test_nwcore_pssdebug PRIVATE mars_nwe::core) +add_test(NAME nwcore.pssdebug COMMAND test_nwcore_pssdebug) diff --git a/tests/core/pssdebug/test_nwcore_pssdebug.c b/tests/core/pssdebug/test_nwcore_pssdebug.c new file mode 100644 index 0000000..d0c342d --- /dev/null +++ b/tests/core/pssdebug/test_nwcore_pssdebug.c @@ -0,0 +1,10 @@ +#include +#include + +int main(void) +{ + DEBUG_PRINTF(TFSM, DBG_BOTH_NOINDENT, (LRED, "fsm debug no-op\n")); + CHOKE_DEBUG_LOG(); + NOT_IMPLEMENTED(); + return 0; +}