From edb5f312ca6a57bf69993a5083b22c9fd8eba461 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 3 Jul 2014 07:58:43 -0600 Subject: [PATCH] Move cypto debug definitions to debug.h with other susbsystem-level debug --- arch/arm/src/sam34/sam_aes.c | 18 +-- crypto/crypto.c | 4 +- crypto/testmngr.c | 4 +- include/crypto/crypto.h | 16 +-- include/debug.h | 261 +++++++++++++++++++---------------- 5 files changed, 151 insertions(+), 152 deletions(-) diff --git a/arch/arm/src/sam34/sam_aes.c b/arch/arm/src/sam34/sam_aes.c index 12aa0cb690..c66e27086f 100644 --- a/arch/arm/src/sam34/sam_aes.c +++ b/arch/arm/src/sam34/sam_aes.c @@ -44,11 +44,11 @@ #include #include #include +#include #include #include -#include -#include +#include #include #include @@ -63,20 +63,6 @@ * Pre-processor Definitions ****************************************************************************/ -#define CONFIG_DEBUG_CRYPTO - -#ifdef CONFIG_DEBUG_CRYPTO -# define cryptdbg lldbg -# ifdef CONFIG_DEBUG_VERBOSE -# define cryptvdbg lldbg -# else -# define cryptvdbg(x...) -# endif -#else -# define cryptdbg(x...) -# define cryptvdbg(x...) -#endif - #define AES_BLOCK_SIZE 16 /**************************************************************************** diff --git a/crypto/crypto.c b/crypto/crypto.c index 470d018839..5b4f1c6924 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -76,9 +76,9 @@ void up_cryptoinitialize(void) #if defined(CONFIG_CRYPTO_ALGTEST) res = crypto_test(); if (res) - cryptdbg("crypto test failed\n"); + cryptlldbg("crypto test failed\n"); else - cryptvdbg("crypto test OK\n"); + cryptllvdbg("crypto test OK\n"); #endif return res; diff --git a/crypto/testmngr.c b/crypto/testmngr.c index 2b44bc5601..1cfc2d6286 100644 --- a/crypto/testmngr.c +++ b/crypto/testmngr.c @@ -78,7 +78,7 @@ static int do_test_aes(FAR struct cipher_testvec* test, int mode, int encrypt) #define AES_CYPHER_TEST_ENCRYPT(mode, mode_str, count, template) \ for (i = 0; i < count; i++) { \ if (do_test_aes(template + i, mode, CYPHER_ENCRYPT)) { \ - cryptdbg("Failed " mode_str " encrypt test #%i\n", i); \ + cryptlldbg("Failed " mode_str " encrypt test #%i\n", i); \ return -1; \ } \ } @@ -86,7 +86,7 @@ static int do_test_aes(FAR struct cipher_testvec* test, int mode, int encrypt) #define AES_CYPHER_TEST_DECRYPT(mode, mode_str, count, template) \ for (i = 0; i < count; i++) { \ if (do_test_aes(template + i, mode, CYPHER_DECRYPT)) { \ - cryptdbg("Failed " mode_str " decrypt test #%i\n", i); \ + cryptlldbg("Failed " mode_str " decrypt test #%i\n", i); \ return -1; \ } \ } diff --git a/include/crypto/crypto.h b/include/crypto/crypto.h index 9b8c06101e..f918171c7d 100644 --- a/include/crypto/crypto.h +++ b/include/crypto/crypto.h @@ -60,24 +60,12 @@ #define CYPHER_ENCRYPT 1 #define CYPHER_DECRYPT 0 -#ifdef CONFIG_DEBUG_CRYPTO -# define cryptdbg lldbg -# ifdef CONFIG_DEBUG_VERBOSE -# define cryptvdbg lldbg -# else -# define cryptvdbg(x...) -# endif -#else -# define cryptdbg(x...) -# define cryptvdbg(x...) -#endif - -#ifndef __ASSEMBLY__ - /************************************************************************************ * Public Data ************************************************************************************/ +#ifndef __ASSEMBLY__ + #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" diff --git a/include/debug.h b/include/debug.h index ba7d1d9643..7fd6bc4977 100644 --- a/include/debug.h +++ b/include/debug.h @@ -56,9 +56,9 @@ * that the output is not buffered. The first character indicates the * system system (e.g., n=network, f=filesystm, etc.). If the first * character is missing (i.e., dbg()), then it is common. The common - * dbg() macro is enabled by CONFIG_DEBUG. Subystem debug requires an + * dbg() macro is enabled by CONFIG_DEBUG. Subsystem debug requires an * additional configuration setting to enable it (e.g., CONFIG_DEBUG_NET - * for the network, CONFIG_DEBUG_FS for the file syste, etc). + * for the network, CONFIG_DEBUG_FS for the file system, etc). * * In general, error messages and output of importance use [a-z]dbg(). * [a-z]dbg() is implementation dependent but usually uses file descriptors. @@ -66,7 +66,7 @@ * directed stdout). Therefore [a-z]dbg() should not be used in interrupt * handlers. * - * [a-z]vdbg() -- Identifcal to [a-z]dbg() except that it also requires that + * [a-z]vdbg() -- Identical to [a-z]dbg() except that it also requires that * CONFIG_DEBUG_VERBOSE be defined. This is intended for general debug * output that you would normally want to suppress. * @@ -81,7 +81,7 @@ * in low-level code where it is inappropriate to use file descriptors. For * example, only [a-z]lldbg() should be used in interrupt handlers. * - * [a-z]llvdbg() -- Identifcal to [a-z]lldbg() except that it also requires that + * [a-z]llvdbg() -- Identical to [a-z]lldbg() except that it also requires that * CONFIG_DEBUG_VERBOSE be defined. This is intended for general debug * output that you would normally want to suppress. */ @@ -224,6 +224,18 @@ # define fllvdbg(x...) #endif +#ifdef CONFIG_DEBUG_CRYPTO +# define cryptdbg(format, ...) dbg(format, ##__VA_ARGS__) +# define cryptlldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define cryptvdbg(format, ...) vdbg(format, ##__VA_ARGS__) +# define cryptllvdbg(format, ...) llvdbg(format, ##__VA_ARGS__) +#else +# define cryptdbg(x...) +# define cryptlldbg(x...) +# define cryptvdbg(x...) +# define cryptllvdbg(x...) +#endif + #ifdef CONFIG_DEBUG_INPUT # define idbg(format, ...) dbg(format, ##__VA_ARGS__) # define illdbg(format, ...) lldbg(format, ##__VA_ARGS__) @@ -302,179 +314,191 @@ #ifdef CONFIG_DEBUG # ifndef CONFIG_ARCH_LOWPUTC -# define lldbg (void) +# define lldbg (void) # endif # ifndef CONFIG_DEBUG_VERBOSE -# define vdbg (void) -# define llvdbg (void) +# define vdbg (void) +# define llvdbg (void) # else # ifndef CONFIG_ARCH_LOWPUTC -# define llvdbg (void) +# define llvdbg (void) # endif # endif #else -# define dbg (void) -# define lldbg (void) -# define vdbg (void) -# define llvdbg (void) +# define dbg (void) +# define lldbg (void) +# define vdbg (void) +# define llvdbg (void) #endif /* Subsystem specific debug */ #ifdef CONFIG_DEBUG_MM -# define mdbg dbg -# define mlldbg lldbg -# define mvdbg vdbg -# define mllvdbg llvdbg +# define mdbg dbg +# define mlldbg lldbg +# define mvdbg vdbg +# define mllvdbg llvdbg #else -# define mdbg (void) -# define mlldbg (void) -# define mvdbg (void) -# define mllvdbg (void) +# define mdbg (void) +# define mlldbg (void) +# define mvdbg (void) +# define mllvdbg (void) #endif #ifdef CONFIG_DEBUG_SCHED -# define sdbg dbg -# define slldbg lldbg -# define svdbg vdbg -# define sllvdbg llvdbg +# define sdbg dbg +# define slldbg lldbg +# define svdbg vdbg +# define sllvdbg llvdbg #else -# define sdbg (void) -# define slldbg (void) -# define svdbg (void) -# define sllvdbg (void) +# define sdbg (void) +# define slldbg (void) +# define svdbg (void) +# define sllvdbg (void) #endif #ifdef CONFIG_DEBUG_PAGING -# define pgdbg dbg -# define pglldbg lldbg -# define pgvdbg vdbg -# define pgllvdbg llvdbg +# define pgdbg dbg +# define pglldbg lldbg +# define pgvdbg vdbg +# define pgllvdbg llvdbg #else -# define pgdbg (void) -# define pglldbg (void) -# define pgvdbg (void) -# define pgllvdbg (void) +# define pgdbg (void) +# define pglldbg (void) +# define pgvdbg (void) +# define pgllvdbg (void) #endif #ifdef CONFIG_DEBUG_DMA -# define dmadbg dbg -# define dmalldbg lldbg -# define dmavdbg vdbg -# define dmallvdbg llvdbg +# define dmadbg dbg +# define dmalldbg lldbg +# define dmavdbg vdbg +# define dmallvdbg llvdbg #else -# define dmadbg (void) -# define dmalldbg (void) -# define dmavdbg (void) -# define dmallvdbg (void) +# define dmadbg (void) +# define dmalldbg (void) +# define dmavdbg (void) +# define dmallvdbg (void) #endif #ifdef CONFIG_DEBUG_NET -# define ndbg dbg -# define nlldbg lldbg -# define nvdbg vdbg -# define nllvdbg llvdbg +# define ndbg dbg +# define nlldbg lldbg +# define nvdbg vdbg +# define nllvdbg llvdbg #else -# define ndbg (void) -# define nlldbg (void) -# define nvdbg (void) -# define nllvdbg (void) +# define ndbg (void) +# define nlldbg (void) +# define nvdbg (void) +# define nllvdbg (void) #endif #ifdef CONFIG_DEBUG_USB -# define udbg dbg -# define ulldbg lldbg -# define uvdbg vdbg -# define ullvdbg llvdbg +# define udbg dbg +# define ulldbg lldbg +# define uvdbg vdbg +# define ullvdbg llvdbg #else -# define udbg (void) -# define ulldbg (void) -# define uvdbg (void) -# define ullvdbg (void) +# define udbg (void) +# define ulldbg (void) +# define uvdbg (void) +# define ullvdbg (void) #endif #ifdef CONFIG_DEBUG_FS -# define fdbg dbg -# define flldbg lldbg -# define fvdbg vdbg -# define fllvdbg llvdbg +# define fdbg dbg +# define flldbg lldbg +# define fvdbg vdbg +# define fllvdbg llvdbg #else -# define fdbg (void) -# define flldbg (void) -# define fvdbg (void) -# define fllvdbg (void) +# define fdbg (void) +# define flldbg (void) +# define fvdbg (void) +# define fllvdbg (void) +#endif + +#ifdef CONFIG_DEBUG_CRYPTO +# define cryptdbg dbg +# define cryptlldbg lldbg +# define cryptvdbg vdbg +# define cryptllvdbg llvdbg +#else +# define cryptdbg (void) +# define cryptlldbg (void) +# define cryptvdbg (void) +# define cryptllvdbg (void) #endif #ifdef CONFIG_DEBUG_INPUT -# define idbg dbg -# define illdbg lldbg -# define ivdbg vdbg -# define illvdbg llvdbg +# define idbg dbg +# define illdbg lldbg +# define ivdbg vdbg +# define illvdbg llvdbg #else -# define idbg (void) -# define illdbg (void) -# define ivdbg (void) -# define illvdbg (void) +# define idbg (void) +# define illdbg (void) +# define ivdbg (void) +# define illvdbg (void) #endif #ifdef CONFIG_DEBUG_ANALOG -# define adbg dbg -# define alldbg lldbg -# define avdbg vdbg -# define allvdbg llvdbg +# define adbg dbg +# define alldbg lldbg +# define avdbg vdbg +# define allvdbg llvdbg #else -# define adbg (void) -# define alldbg (void) -# define avdbg (void) -# define allvdbg (void) +# define adbg (void) +# define alldbg (void) +# define avdbg (void) +# define allvdbg (void) #endif #ifdef CONFIG_DEBUG_GRAPHICS -# define gdbg dbg -# define glldbg lldbg -# define gvdbg vdbg -# define gllvdbg llvdbg +# define gdbg dbg +# define glldbg lldbg +# define gvdbg vdbg +# define gllvdbg llvdbg #else -# define gdbg (void) -# define glldbg (void) -# define gvdbg (void) -# define gllvdbg (void) +# define gdbg (void) +# define glldbg (void) +# define gvdbg (void) +# define gllvdbg (void) #endif #ifdef CONFIG_DEBUG_BINFMT -# define bdbg dbg -# define blldbg lldbg -# define bvdbg vdbg -# define bllvdbg llvdbg +# define bdbg dbg +# define blldbg lldbg +# define bvdbg vdbg +# define bllvdbg llvdbg #else -# define bdbg (void) -# define blldbg (void) -# define bvdbg (void) -# define bllvdbg (void) +# define bdbg (void) +# define blldbg (void) +# define bvdbg (void) +# define bllvdbg (void) #endif #ifdef CONFIG_DEBUG_LIB -# define ldbg dbg -# define llldbg lldbg -# define lvdbg vdbg -# define lllvdbg llvdbg +# define ldbg dbg +# define llldbg lldbg +# define lvdbg vdbg +# define lllvdbg llvdbg #else -# define ldbg (void) -# define llldbg (void) -# define lvdbg (void) -# define lllvdbg (void) +# define ldbg (void) +# define llldbg (void) +# define lvdbg (void) +# define lllvdbg (void) #endif #ifdef CONFIG_DEBUG_AUDIO -# define auddbg dbg -# define audlldbg lldbg -# define audvdbg vdbg -# define audllvdbg llvdbg +# define auddbg dbg +# define audlldbg lldbg +# define audvdbg vdbg +# define audllvdbg llvdbg #else -# define auddbg (void) -# define audlldbg (void) -# define audvdbg (void) -# define audllvdbg (void) +# define auddbg (void) +# define audlldbg (void) +# define audvdbg (void) +# define audllvdbg (void) #endif #endif /* CONFIG_CPP_HAVE_VARARGS */ @@ -610,9 +634,10 @@ extern "C" /* Dump a buffer of data */ -void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, unsigned int buflen); +void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, + unsigned int buflen); -/* The system logging interfaces are pnormally accessed via the macros +/* The system logging interfaces are normally accessed via the macros * provided above. If the cross-compiler's C pre-processor supports a * variable number of macro arguments, then those macros below will map all * debug statements to the logging interfaces declared in syslog.h.