From 632ab90161d2bf1d4b25b22efb2680d9d4c456bc Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 22 Nov 2017 00:53:42 +0000 Subject: [PATCH 01/24] Apply cosmetic changes --- arch/cpu/arm/common/dbg-io/dbg-printf.c | 10 ++++----- arch/cpu/arm/common/dbg-io/dbg-putchar.c | 10 +++++---- arch/cpu/arm/common/dbg-io/dbg-puts.c | 4 +++- arch/cpu/arm/common/dbg-io/dbg-snprintf.c | 10 +++++---- arch/cpu/arm/common/dbg-io/dbg-sprintf.c | 6 +++-- arch/cpu/arm/common/dbg-io/strformat.c | 27 +++++++++++++---------- arch/cpu/arm/common/dbg-io/strformat.h | 13 ++++++----- 7 files changed, 47 insertions(+), 33 deletions(-) diff --git a/arch/cpu/arm/common/dbg-io/dbg-printf.c b/arch/cpu/arm/common/dbg-io/dbg-printf.c index 9bd09c1ac..01a02aef2 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-printf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-printf.c @@ -1,21 +1,22 @@ +/*---------------------------------------------------------------------------*/ #include #include #include #include - +/*---------------------------------------------------------------------------*/ static StrFormatResult write_str(void *user_data, const char *data, unsigned int len) { if (len > 0) dbg_send_bytes((unsigned char*)data, len); return STRFORMAT_OK; } - - +/*---------------------------------------------------------------------------*/ static StrFormatContext ctxt = { write_str, NULL }; +/*---------------------------------------------------------------------------*/ int printf(const char *fmt, ...) { @@ -26,5 +27,4 @@ printf(const char *fmt, ...) va_end(ap); return res; } - - +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/arm/common/dbg-io/dbg-putchar.c b/arch/cpu/arm/common/dbg-io/dbg-putchar.c index 54f3db53f..159b54a6e 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-putchar.c +++ b/arch/cpu/arm/common/dbg-io/dbg-putchar.c @@ -1,26 +1,28 @@ +/*---------------------------------------------------------------------------*/ #include #include #include - +/*---------------------------------------------------------------------------*/ #undef putchar #undef putc - +/*---------------------------------------------------------------------------*/ int putchar(int c) { dbg_putchar(c); return c; } - +/*---------------------------------------------------------------------------*/ int putc(int c, FILE *f) { dbg_putchar(c); return c; } - +/*---------------------------------------------------------------------------*/ int __sp(struct _reent *_ptr, int c, FILE *_p) { dbg_putchar(c); return c; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/arm/common/dbg-io/dbg-puts.c b/arch/cpu/arm/common/dbg-io/dbg-puts.c index fa90d1022..5ad494ae3 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-puts.c +++ b/arch/cpu/arm/common/dbg-io/dbg-puts.c @@ -1,7 +1,8 @@ +/*---------------------------------------------------------------------------*/ #include #include #include - +/*---------------------------------------------------------------------------*/ int puts(const char *str) { @@ -9,3 +10,4 @@ puts(const char *str) dbg_putchar('\n'); return 0; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c b/arch/cpu/arm/common/dbg-io/dbg-snprintf.c index 230d6891a..10a1631ef 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-snprintf.c @@ -1,13 +1,14 @@ +/*---------------------------------------------------------------------------*/ #include #include #include - +/*---------------------------------------------------------------------------*/ struct FmtBuffer { char *pos; size_t left; }; - +/*---------------------------------------------------------------------------*/ static StrFormatResult buffer_str(void *user_data, const char *data, unsigned int len) { @@ -22,7 +23,7 @@ buffer_str(void *user_data, const char *data, unsigned int len) buffer->left -= len; return STRFORMAT_OK; } - +/*---------------------------------------------------------------------------*/ int snprintf(char *str, size_t size, const char *format, ...) { int res; @@ -32,7 +33,7 @@ int snprintf(char *str, size_t size, const char *format, ...) va_end(ap); return res; } - +/*---------------------------------------------------------------------------*/ int vsnprintf(char *str, size_t size, const char *format, va_list ap) { struct FmtBuffer buffer; @@ -46,3 +47,4 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap) *buffer.pos = '\0'; return res; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c b/arch/cpu/arm/common/dbg-io/dbg-sprintf.c index 8124fc363..e5abd4dc5 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-sprintf.c @@ -1,7 +1,8 @@ +/*---------------------------------------------------------------------------*/ #include #include #include - +/*---------------------------------------------------------------------------*/ static StrFormatResult buffer_str(void *user_data, const char *data, unsigned int len) { @@ -9,7 +10,7 @@ buffer_str(void *user_data, const char *data, unsigned int len) (*(char**)user_data) += len; return STRFORMAT_OK; } - +/*---------------------------------------------------------------------------*/ int sprintf(char *str, const char *format, ...) { @@ -24,3 +25,4 @@ sprintf(char *str, const char *format, ...) va_end(ap); return res; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/arm/common/dbg-io/strformat.c b/arch/cpu/arm/common/dbg-io/strformat.c index 13b91a563..6106a75f9 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.c +++ b/arch/cpu/arm/common/dbg-io/strformat.c @@ -1,5 +1,6 @@ +/*---------------------------------------------------------------------------*/ #include - +/*---------------------------------------------------------------------------*/ #define HAVE_DOUBLE #define HAVE_LONGLONG @@ -22,9 +23,9 @@ #ifndef POINTER_INT #define POINTER_INT unsigned long #endif - +/*---------------------------------------------------------------------------*/ typedef unsigned int FormatFlags; - +/*---------------------------------------------------------------------------*/ #define MAKE_MASK(shift,size) (((1 << size) - 1) << (shift)) #define JUSTIFY_SHIFT 0 @@ -33,7 +34,6 @@ typedef unsigned int FormatFlags; #define JUSTIFY_LEFT 0x0001 #define JUSTIFY_MASK MAKE_MASK(JUSTIFY_SHIFT,JUSTIFY_SIZE) - /* How a positive number is prefixed */ #define POSITIVE_SHIFT (JUSTIFY_SHIFT + JUSTIFY_SIZE) #define POSITIVE_NONE (0x0000 << POSITIVE_SHIFT) @@ -99,6 +99,7 @@ typedef unsigned int FormatFlags; #define FLOAT_DEPENDANT (0x0002 << FLOAT_SHIFT) #define FLOAT_HEX (0x0003 << FLOAT_SHIFT) #define FLOAT_MASK MAKE_MASK(FLOAT_SHIFT, FLOAT_SIZE) +/*---------------------------------------------------------------------------*/ static FormatFlags parse_flags(const char **posp) @@ -130,7 +131,7 @@ parse_flags(const char **posp) } } - +/*---------------------------------------------------------------------------*/ static unsigned int parse_uint(const char **posp) { @@ -151,6 +152,7 @@ parse_uint(const char **posp) */ #define MAXCHARS ((sizeof(LARGEST_UNSIGNED) * 8 + 2) / 3 ) +/*---------------------------------------------------------------------------*/ static unsigned int output_uint_decimal(char **posp, LARGEST_UNSIGNED v) { @@ -164,7 +166,7 @@ output_uint_decimal(char **posp, LARGEST_UNSIGNED v) *posp = pos; return len; } - +/*---------------------------------------------------------------------------*/ static unsigned int output_uint_hex(char **posp, LARGEST_UNSIGNED v, unsigned int flags) { @@ -179,7 +181,7 @@ output_uint_hex(char **posp, LARGEST_UNSIGNED v, unsigned int flags) *posp = pos; return len; } - +/*---------------------------------------------------------------------------*/ static unsigned int output_uint_octal(char **posp, LARGEST_UNSIGNED v) { @@ -193,7 +195,7 @@ output_uint_octal(char **posp, LARGEST_UNSIGNED v) *posp = pos; return len; } - +/*---------------------------------------------------------------------------*/ static StrFormatResult fill_space(const StrFormatContext *ctxt, unsigned int len) { @@ -207,7 +209,7 @@ fill_space(const StrFormatContext *ctxt, unsigned int len) if (len == 0) return STRFORMAT_OK; return ctxt->write_str(ctxt->user_data, buffer, len); } - +/*---------------------------------------------------------------------------*/ static StrFormatResult fill_zero(const StrFormatContext *ctxt, unsigned int len) { @@ -221,9 +223,9 @@ fill_zero(const StrFormatContext *ctxt, unsigned int len) if (len == 0) return STRFORMAT_OK; return ctxt->write_str(ctxt->user_data, buffer, len); } - +/*---------------------------------------------------------------------------*/ #define CHECKCB(res) {if ((res) != STRFORMAT_OK) {va_end(ap); return -1;}} - +/*---------------------------------------------------------------------------*/ int format_str(const StrFormatContext *ctxt, const char *format, ...) { @@ -234,7 +236,7 @@ format_str(const StrFormatContext *ctxt, const char *format, ...) va_end(ap); return ret; } - +/*---------------------------------------------------------------------------*/ int format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap) { @@ -615,3 +617,4 @@ format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap) return written; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/arm/common/dbg-io/strformat.h b/arch/cpu/arm/common/dbg-io/strformat.h index c32eed670..df6a56f39 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.h +++ b/arch/cpu/arm/common/dbg-io/strformat.h @@ -1,12 +1,14 @@ +/*---------------------------------------------------------------------------*/ #ifndef STRFORMAT_H_ #define STRFORMAT_H_ - +/*---------------------------------------------------------------------------*/ #include - +/*---------------------------------------------------------------------------*/ #define STRFORMAT_OK 0 #define STRFORMAT_FAILED 1 +/*---------------------------------------------------------------------------*/ typedef unsigned int StrFormatResult; - +/*---------------------------------------------------------------------------*/ /* The data argument may only be considered valid during the function call */ typedef StrFormatResult (*StrFormatWrite)(void *user_data, const char *data, unsigned int len); @@ -15,11 +17,12 @@ typedef struct _StrFormatContext StrFormatWrite write_str; void *user_data; } StrFormatContext; - +/*---------------------------------------------------------------------------*/ int format_str(const StrFormatContext *ctxt, const char *format, ...) __attribute__ ((__format__ (__printf__, 2,3))); int format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap); - +/*---------------------------------------------------------------------------*/ #endif /* STRFORMAT_H_ */ +/*---------------------------------------------------------------------------*/ From 4e3c7efa5fc28d554064586697d3277a473fe951 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 22 Nov 2017 00:58:50 +0000 Subject: [PATCH 02/24] Fix code style --- arch/cpu/arm/common/dbg-io/dbg-printf.c | 12 +- arch/cpu/arm/common/dbg-io/dbg-putchar.c | 3 +- arch/cpu/arm/common/dbg-io/dbg-puts.c | 2 +- arch/cpu/arm/common/dbg-io/dbg-snprintf.c | 15 +- arch/cpu/arm/common/dbg-io/dbg-sprintf.c | 4 +- arch/cpu/arm/common/dbg-io/strformat.c | 740 ++++++++++++---------- arch/cpu/arm/common/dbg-io/strformat.h | 3 +- 7 files changed, 420 insertions(+), 359 deletions(-) diff --git a/arch/cpu/arm/common/dbg-io/dbg-printf.c b/arch/cpu/arm/common/dbg-io/dbg-printf.c index 01a02aef2..9ee3bd0e9 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-printf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-printf.c @@ -7,15 +7,17 @@ static StrFormatResult write_str(void *user_data, const char *data, unsigned int len) { - if (len > 0) dbg_send_bytes((unsigned char*)data, len); + if(len > 0) { + dbg_send_bytes((unsigned char *)data, len); + } return STRFORMAT_OK; } /*---------------------------------------------------------------------------*/ static StrFormatContext ctxt = - { - write_str, - NULL - }; +{ + write_str, + NULL +}; /*---------------------------------------------------------------------------*/ int printf(const char *fmt, ...) diff --git a/arch/cpu/arm/common/dbg-io/dbg-putchar.c b/arch/cpu/arm/common/dbg-io/dbg-putchar.c index 159b54a6e..eb0cb2180 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-putchar.c +++ b/arch/cpu/arm/common/dbg-io/dbg-putchar.c @@ -21,7 +21,8 @@ putc(int c, FILE *f) } /*---------------------------------------------------------------------------*/ int -__sp(struct _reent *_ptr, int c, FILE *_p) { +__sp(struct _reent *_ptr, int c, FILE *_p) +{ dbg_putchar(c); return c; } diff --git a/arch/cpu/arm/common/dbg-io/dbg-puts.c b/arch/cpu/arm/common/dbg-io/dbg-puts.c index 5ad494ae3..222a436dc 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-puts.c +++ b/arch/cpu/arm/common/dbg-io/dbg-puts.c @@ -6,7 +6,7 @@ int puts(const char *str) { - dbg_send_bytes((unsigned char*)str, strlen(str)); + dbg_send_bytes((unsigned char *)str, strlen(str)); dbg_putchar('\n'); return 0; } diff --git a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c b/arch/cpu/arm/common/dbg-io/dbg-snprintf.c index 10a1631ef..051d922ed 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-snprintf.c @@ -3,8 +3,7 @@ #include #include /*---------------------------------------------------------------------------*/ -struct FmtBuffer -{ +struct FmtBuffer { char *pos; size_t left; }; @@ -12,19 +11,20 @@ struct FmtBuffer static StrFormatResult buffer_str(void *user_data, const char *data, unsigned int len) { - struct FmtBuffer *buffer = (struct FmtBuffer*)user_data; - if (len >= buffer->left) { + struct FmtBuffer *buffer = (struct FmtBuffer *)user_data; + if(len >= buffer->left) { len = buffer->left; len--; } - + memcpy(buffer->pos, data, len); buffer->pos += len; buffer->left -= len; return STRFORMAT_OK; } /*---------------------------------------------------------------------------*/ -int snprintf(char *str, size_t size, const char *format, ...) +int +snprintf(char *str, size_t size, const char *format, ...) { int res; va_list ap; @@ -34,7 +34,8 @@ int snprintf(char *str, size_t size, const char *format, ...) return res; } /*---------------------------------------------------------------------------*/ -int vsnprintf(char *str, size_t size, const char *format, va_list ap) +int +vsnprintf(char *str, size_t size, const char *format, va_list ap) { struct FmtBuffer buffer; StrFormatContext ctxt; diff --git a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c b/arch/cpu/arm/common/dbg-io/dbg-sprintf.c index e5abd4dc5..8fb0d612f 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-sprintf.c @@ -6,8 +6,8 @@ static StrFormatResult buffer_str(void *user_data, const char *data, unsigned int len) { - memcpy(*(char**)user_data, data, len); - (*(char**)user_data) += len; + memcpy(*(char **)user_data, data, len); + (*(char **)user_data) += len; return STRFORMAT_OK; } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/arm/common/dbg-io/strformat.c b/arch/cpu/arm/common/dbg-io/strformat.c index 6106a75f9..37ac4ae25 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.c +++ b/arch/cpu/arm/common/dbg-io/strformat.c @@ -2,23 +2,23 @@ #include /*---------------------------------------------------------------------------*/ #define HAVE_DOUBLE - #define HAVE_LONGLONG + #ifndef LARGEST_SIGNED #ifdef HAVE_LONGLONG #define LARGEST_SIGNED long long int #else #define LARGEST_UNSIGNED long int -#endif -#endif +#endif /* HAVE_LONGLONG */ +#endif /* LARGEST_SIGNED */ #ifndef LARGEST_UNSIGNED #ifdef HAVE_LONGLONG #define LARGEST_UNSIGNED unsigned long long int #else #define LARGEST_UNSIGNED unsigned long int -#endif -#endif +#endif /* HAVE_LONGLONG */ +#endif /* LARGEST_UNSIGNED */ #ifndef POINTER_INT #define POINTER_INT unsigned long @@ -26,79 +26,78 @@ /*---------------------------------------------------------------------------*/ typedef unsigned int FormatFlags; /*---------------------------------------------------------------------------*/ -#define MAKE_MASK(shift,size) (((1 << size) - 1) << (shift)) - -#define JUSTIFY_SHIFT 0 -#define JUSTIFY_SIZE 1 -#define JUSTIFY_RIGHT 0x0000 -#define JUSTIFY_LEFT 0x0001 -#define JUSTIFY_MASK MAKE_MASK(JUSTIFY_SHIFT,JUSTIFY_SIZE) - +#define MAKE_MASK(shift, size) (((1 << size) - 1) << (shift)) +/*---------------------------------------------------------------------------*/ +#define JUSTIFY_SHIFT 0 +#define JUSTIFY_SIZE 1 +#define JUSTIFY_RIGHT 0x0000 +#define JUSTIFY_LEFT 0x0001 +#define JUSTIFY_MASK MAKE_MASK(JUSTIFY_SHIFT, JUSTIFY_SIZE) +/*---------------------------------------------------------------------------*/ /* How a positive number is prefixed */ -#define POSITIVE_SHIFT (JUSTIFY_SHIFT + JUSTIFY_SIZE) -#define POSITIVE_NONE (0x0000 << POSITIVE_SHIFT) -#define POSITIVE_SPACE (0x0001 << POSITIVE_SHIFT) -#define POSITIVE_PLUS (0x0003 << POSITIVE_SHIFT) -#define POSITIVE_MASK MAKE_MASK(POSITIVE_SHIFT, POSITIVE_SIZE) - -#define POSITIVE_SIZE 2 +#define POSITIVE_SHIFT (JUSTIFY_SHIFT + JUSTIFY_SIZE) +#define POSITIVE_NONE (0x0000 << POSITIVE_SHIFT) +#define POSITIVE_SPACE (0x0001 << POSITIVE_SHIFT) +#define POSITIVE_PLUS (0x0003 << POSITIVE_SHIFT) +#define POSITIVE_MASK MAKE_MASK(POSITIVE_SHIFT, POSITIVE_SIZE) +#define POSITIVE_SIZE 2 +/*---------------------------------------------------------------------------*/ #define ALTERNATE_FORM_SHIFT (POSITIVE_SHIFT + POSITIVE_SIZE) -#define ALTERNATE_FORM_SIZE 1 -#define ALTERNATE_FORM (0x0001 << ALTERNATE_FORM_SHIFT) - - -#define PAD_SHIFT (ALTERNATE_FORM_SHIFT + ALTERNATE_FORM_SIZE) -#define PAD_SIZE 1 -#define PAD_SPACE (0x0000 << PAD_SHIFT) -#define PAD_ZERO (0x0001 << PAD_SHIFT) - -#define SIZE_SHIFT (PAD_SHIFT + PAD_SIZE) -#define SIZE_SIZE 3 -#define SIZE_CHAR (0x0001 << SIZE_SHIFT) -#define SIZE_SHORT (0x0002 << SIZE_SHIFT) -#define SIZE_INT (0x0000 << SIZE_SHIFT) -#define SIZE_LONG (0x0003 << SIZE_SHIFT) -#define SIZE_LONGLONG (0x0004 << SIZE_SHIFT) -#define SIZE_MASK MAKE_MASK(SIZE_SHIFT,SIZE_SIZE) - -#define CONV_SHIFT (SIZE_SHIFT + SIZE_SIZE) -#define CONV_SIZE 3 -#define CONV_INTEGER (0x0001 << CONV_SHIFT) -#define CONV_FLOAT (0x0002 << CONV_SHIFT) -#define CONV_POINTER (0x0003 << CONV_SHIFT) -#define CONV_STRING (0x0004 << CONV_SHIFT) -#define CONV_CHAR (0x0005 << CONV_SHIFT) -#define CONV_PERCENT (0x0006 << CONV_SHIFT) -#define CONV_WRITTEN (0x0007 << CONV_SHIFT) -#define CONV_MASK MAKE_MASK(CONV_SHIFT, CONV_SIZE) - -#define RADIX_SHIFT (CONV_SHIFT + CONV_SIZE) -#define RADIX_SIZE 2 -#define RADIX_DECIMAL (0x0001 << RADIX_SHIFT) -#define RADIX_OCTAL (0x0002 << RADIX_SHIFT) -#define RADIX_HEX (0x0003 << RADIX_SHIFT) -#define RADIX_MASK MAKE_MASK(RADIX_SHIFT,RADIX_SIZE) - -#define SIGNED_SHIFT (RADIX_SHIFT + RADIX_SIZE) -#define SIGNED_SIZE 1 -#define SIGNED_NO (0x0000 << SIGNED_SHIFT) -#define SIGNED_YES (0x0001 << SIGNED_SHIFT) -#define SIGNED_MASK MAKE_MASK(SIGNED_SHIFT,SIGNED_SIZE) - -#define CAPS_SHIFT (SIGNED_SHIFT + SIGNED_SIZE) -#define CAPS_SIZE 1 -#define CAPS_NO (0x0000 << CAPS_SHIFT) -#define CAPS_YES (0x0001 << CAPS_SHIFT) -#define CAPS_MASK MAKE_MASK(CAPS_SHIFT,CAPS_SIZE) - -#define FLOAT_SHIFT (CAPS_SHIFT + CAPS_SIZE) -#define FLOAT_SIZE 2 -#define FLOAT_NORMAL (0x0000 << FLOAT_SHIFT) -#define FLOAT_EXPONENT (0x0001 << FLOAT_SHIFT) -#define FLOAT_DEPENDANT (0x0002 << FLOAT_SHIFT) -#define FLOAT_HEX (0x0003 << FLOAT_SHIFT) -#define FLOAT_MASK MAKE_MASK(FLOAT_SHIFT, FLOAT_SIZE) +#define ALTERNATE_FORM_SIZE 1 +#define ALTERNATE_FORM (0x0001 << ALTERNATE_FORM_SHIFT) +/*---------------------------------------------------------------------------*/ +#define PAD_SHIFT (ALTERNATE_FORM_SHIFT + ALTERNATE_FORM_SIZE) +#define PAD_SIZE 1 +#define PAD_SPACE (0x0000 << PAD_SHIFT) +#define PAD_ZERO (0x0001 << PAD_SHIFT) +/*---------------------------------------------------------------------------*/ +#define SIZE_SHIFT (PAD_SHIFT + PAD_SIZE) +#define SIZE_SIZE 3 +#define SIZE_CHAR (0x0001 << SIZE_SHIFT) +#define SIZE_SHORT (0x0002 << SIZE_SHIFT) +#define SIZE_INT (0x0000 << SIZE_SHIFT) +#define SIZE_LONG (0x0003 << SIZE_SHIFT) +#define SIZE_LONGLONG (0x0004 << SIZE_SHIFT) +#define SIZE_MASK MAKE_MASK(SIZE_SHIFT, SIZE_SIZE) +/*---------------------------------------------------------------------------*/ +#define CONV_SHIFT (SIZE_SHIFT + SIZE_SIZE) +#define CONV_SIZE 3 +#define CONV_INTEGER (0x0001 << CONV_SHIFT) +#define CONV_FLOAT (0x0002 << CONV_SHIFT) +#define CONV_POINTER (0x0003 << CONV_SHIFT) +#define CONV_STRING (0x0004 << CONV_SHIFT) +#define CONV_CHAR (0x0005 << CONV_SHIFT) +#define CONV_PERCENT (0x0006 << CONV_SHIFT) +#define CONV_WRITTEN (0x0007 << CONV_SHIFT) +#define CONV_MASK MAKE_MASK(CONV_SHIFT, CONV_SIZE) +/*---------------------------------------------------------------------------*/ +#define RADIX_SHIFT (CONV_SHIFT + CONV_SIZE) +#define RADIX_SIZE 2 +#define RADIX_DECIMAL (0x0001 << RADIX_SHIFT) +#define RADIX_OCTAL (0x0002 << RADIX_SHIFT) +#define RADIX_HEX (0x0003 << RADIX_SHIFT) +#define RADIX_MASK MAKE_MASK(RADIX_SHIFT, RADIX_SIZE) +/*---------------------------------------------------------------------------*/ +#define SIGNED_SHIFT (RADIX_SHIFT + RADIX_SIZE) +#define SIGNED_SIZE 1 +#define SIGNED_NO (0x0000 << SIGNED_SHIFT) +#define SIGNED_YES (0x0001 << SIGNED_SHIFT) +#define SIGNED_MASK MAKE_MASK(SIGNED_SHIFT, SIGNED_SIZE) +/*---------------------------------------------------------------------------*/ +#define CAPS_SHIFT (SIGNED_SHIFT + SIGNED_SIZE) +#define CAPS_SIZE 1 +#define CAPS_NO (0x0000 << CAPS_SHIFT) +#define CAPS_YES (0x0001 << CAPS_SHIFT) +#define CAPS_MASK MAKE_MASK(CAPS_SHIFT, CAPS_SIZE) +/*---------------------------------------------------------------------------*/ +#define FLOAT_SHIFT (CAPS_SHIFT + CAPS_SIZE) +#define FLOAT_SIZE 2 +#define FLOAT_NORMAL (0x0000 << FLOAT_SHIFT) +#define FLOAT_EXPONENT (0x0001 << FLOAT_SHIFT) +#define FLOAT_DEPENDANT (0x0002 << FLOAT_SHIFT) +#define FLOAT_HEX (0x0003 << FLOAT_SHIFT) +#define FLOAT_MASK MAKE_MASK(FLOAT_SHIFT, FLOAT_SIZE) /*---------------------------------------------------------------------------*/ static FormatFlags @@ -106,7 +105,8 @@ parse_flags(const char **posp) { FormatFlags flags = 0; const char *pos = *posp; - while (1) { + + while(1) { switch(*pos) { case '-': flags |= JUSTIFY_LEFT; @@ -127,9 +127,9 @@ parse_flags(const char **posp) *posp = pos; return flags; } + pos++; } - } /*---------------------------------------------------------------------------*/ static unsigned int @@ -138,11 +138,14 @@ parse_uint(const char **posp) unsigned v = 0; const char *pos = *posp; char ch; + while((ch = *pos) >= '0' && ch <= '9') { v = v * 10 + (ch - '0'); pos++; } + *posp = pos; + return v; } @@ -158,12 +161,15 @@ output_uint_decimal(char **posp, LARGEST_UNSIGNED v) { unsigned int len; char *pos = *posp; - while (v > 0) { + + while(v > 0) { *--pos = (v % 10) + '0'; v /= 10; } + len = *posp - pos; *posp = pos; + return len; } /*---------------------------------------------------------------------------*/ @@ -171,14 +177,17 @@ static unsigned int output_uint_hex(char **posp, LARGEST_UNSIGNED v, unsigned int flags) { unsigned int len; - const char *hex = (flags & CAPS_YES) ?"0123456789ABCDEF":"0123456789abcdef"; + const char *hex = (flags & CAPS_YES) ? "0123456789ABCDEF" : "0123456789abcdef"; char *pos = *posp; - while (v > 0) { + + while(v > 0) { *--pos = hex[(v % 16)]; v /= 16; } + len = *posp - pos; *posp = pos; + return len; } /*---------------------------------------------------------------------------*/ @@ -187,12 +196,15 @@ output_uint_octal(char **posp, LARGEST_UNSIGNED v) { unsigned int len; char *pos = *posp; - while (v > 0) { + + while(v > 0) { *--pos = (v % 8) + '0'; v /= 8; } + len = *posp - pos; *posp = pos; + return len; } /*---------------------------------------------------------------------------*/ @@ -201,12 +213,19 @@ fill_space(const StrFormatContext *ctxt, unsigned int len) { StrFormatResult res; static const char buffer[16] = " "; + while(len > 16) { res = ctxt->write_str(ctxt->user_data, buffer, 16); - if (res != STRFORMAT_OK) return res; + if(res != STRFORMAT_OK) { + return res; + } len -= 16; } - if (len == 0) return STRFORMAT_OK; + + if(len == 0) { + return STRFORMAT_OK; + } + return ctxt->write_str(ctxt->user_data, buffer, len); } /*---------------------------------------------------------------------------*/ @@ -215,12 +234,18 @@ fill_zero(const StrFormatContext *ctxt, unsigned int len) { StrFormatResult res; static const char buffer[16] = "0000000000000000"; + while(len > 16) { res = ctxt->write_str(ctxt->user_data, buffer, 16); - if (res != STRFORMAT_OK) return res; + if(res != STRFORMAT_OK) { + return res; + } len -= 16; } - if (len == 0) return STRFORMAT_OK; + + if(len == 0) { + return STRFORMAT_OK; + } return ctxt->write_str(ctxt->user_data, buffer, len); } /*---------------------------------------------------------------------------*/ @@ -242,67 +267,82 @@ format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap) { unsigned int written = 0; const char *pos = format; + while(*pos != '\0') { FormatFlags flags; unsigned int minwidth = 0; int precision = -1; /* Negative means no precision */ char ch; const char *start = pos; - while( (ch = *pos) != '\0' && ch != '%') pos++; - if (pos != start) { + + while((ch = *pos) != '\0' && ch != '%') { + pos++; + } + + if(pos != start) { CHECKCB(ctxt->write_str(ctxt->user_data, start, pos - start)); written += pos - start; } - if (*pos == '\0') { + + if(*pos == '\0') { va_end(ap); return written; } + pos++; - if (*pos == '\0') { + + if(*pos == '\0') { va_end(ap); return written; } + flags = parse_flags(&pos); /* parse width */ - if (*pos >= '1' && *pos <= '9') { + if(*pos >= '1' && *pos <= '9') { minwidth = parse_uint(&pos); - } else if (*pos == '*') { - int w = va_arg(ap,int); - if (w < 0) { - flags |= JUSTIFY_LEFT; - minwidth = w; + } else if(*pos == '*') { + int w = va_arg(ap, int); + + if(w < 0) { + flags |= JUSTIFY_LEFT; + minwidth = w; } else { - minwidth = w; + minwidth = w; } - pos ++; + + pos++; } /* parse precision */ - if (*pos == '.') { + if(*pos == '.') { pos++; - if (*pos >= '0' && *pos <= '9') { - precision = parse_uint(&pos); - } else if (*pos == '*') { - pos++; - precision = va_arg(ap,int); + + if(*pos >= '0' && *pos <= '9') { + precision = parse_uint(&pos); + } else if(*pos == '*') { + pos++; + precision = va_arg(ap, int); } } - if (*pos == 'l') { + + if(*pos == 'l') { pos++; - if (*pos == 'l') { - flags |= SIZE_LONGLONG; - pos++; + + if(*pos == 'l') { + flags |= SIZE_LONGLONG; + pos++; } else { - flags |= SIZE_LONG; + flags |= SIZE_LONG; } - } else if (*pos == 'h') { + } else if(*pos == 'h') { pos++; - if (*pos == 'h') { - flags |= SIZE_CHAR; - pos++; + + if(*pos == 'h') { + flags |= SIZE_CHAR; + pos++; } else { - flags |= SIZE_SHORT; + flags |= SIZE_SHORT; } } @@ -370,251 +410,269 @@ format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap) return written; } pos++; + switch(flags & CONV_MASK) { case CONV_PERCENT: CHECKCB(ctxt->write_str(ctxt->user_data, "%", 1)); written++; break; case CONV_INTEGER: - { - /* unsigned integers */ - char *prefix = 0; /* sign, "0x" or "0X" */ - unsigned int prefix_len = 0; - char buffer[MAXCHARS]; - char *conv_pos = buffer + MAXCHARS; - unsigned int conv_len = 0; - unsigned int width = 0; - unsigned int precision_fill; - unsigned int field_fill; - LARGEST_UNSIGNED uvalue = 0; - int negative = 0; - - if (precision < 0) precision = 1; - else flags &= ~PAD_ZERO; - - if (flags & SIGNED_YES) { - /* signed integers */ - LARGEST_SIGNED value = 0; - switch(flags & SIZE_MASK) { - case SIZE_CHAR: - value = (signed char)va_arg(ap, int); - break; - case SIZE_SHORT: - value = (short)va_arg(ap, int); - break; - case SIZE_INT: - value = va_arg(ap, int); - break; -#ifndef HAVE_LONGLONG - case SIZE_LONGLONG: /* Treat long long the same as long */ -#endif - case SIZE_LONG: - value = va_arg(ap, long); - break; -#ifdef HAVE_LONGLONG - case SIZE_LONGLONG: - value = va_arg(ap, long long); - break; -#endif - } - if (value < 0) { - uvalue = -value; - negative = 1; - } else { - uvalue = value; - } - } else { - - switch(flags & SIZE_MASK) { - case SIZE_CHAR: - uvalue = (unsigned char)va_arg(ap,unsigned int); - break; - case SIZE_SHORT: - uvalue = (unsigned short)va_arg(ap,unsigned int); - break; - case SIZE_INT: - uvalue = va_arg(ap,unsigned int); - break; -#ifndef HAVE_LONGLONG - case SIZE_LONGLONG: /* Treat long long the same as long */ -#endif - case SIZE_LONG: - uvalue = va_arg(ap,unsigned long); - break; -#ifdef HAVE_LONGLONG - case SIZE_LONGLONG: - uvalue = va_arg(ap,unsigned long long); - break; -#endif - } - } - - switch(flags & (RADIX_MASK)) { - case RADIX_DECIMAL: - conv_len = output_uint_decimal(&conv_pos,uvalue); - break; - case RADIX_OCTAL: - conv_len = output_uint_octal(&conv_pos,uvalue); - break; - case RADIX_HEX: - conv_len = output_uint_hex(&conv_pos,uvalue, flags); - break; - } + { + /* unsigned integers */ + char *prefix = 0; /* sign, "0x" or "0X" */ + unsigned int prefix_len = 0; + char buffer[MAXCHARS]; + char *conv_pos = buffer + MAXCHARS; + unsigned int conv_len = 0; + unsigned int width = 0; + unsigned int precision_fill; + unsigned int field_fill; + LARGEST_UNSIGNED uvalue = 0; + int negative = 0; - width += conv_len; - precision_fill = (precision > conv_len) ? precision - conv_len : 0; - if ((flags & (RADIX_MASK | ALTERNATE_FORM)) - == (RADIX_OCTAL | ALTERNATE_FORM)) { - if (precision_fill < 1) precision_fill = 1; - } - - width += precision_fill; - - if ((flags & (RADIX_MASK | ALTERNATE_FORM)) - == (RADIX_HEX | ALTERNATE_FORM) && uvalue != 0) { - prefix_len = 2; - if (flags & CAPS_YES) { - prefix = "0X"; - } else { - prefix = "0x"; - } - } - - if (flags & SIGNED_YES) { - if (negative) { - prefix = "-"; - prefix_len = 1; - } else { - switch(flags & POSITIVE_MASK) { - case POSITIVE_SPACE: - prefix = " "; - prefix_len = 1; - break; - case POSITIVE_PLUS: - prefix = "+"; - prefix_len = 1; - break; - } - } - } - - width += prefix_len; - - field_fill = (minwidth > width) ? minwidth - width : 0; - - if ((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { - if (flags & PAD_ZERO) { - precision_fill += field_fill; - field_fill = 0; /* Do not double count padding */ - } else { - CHECKCB(fill_space(ctxt,field_fill)); - } - } - - if (prefix_len > 0) - CHECKCB(ctxt->write_str(ctxt->user_data, prefix, prefix_len)); - written += prefix_len; - - CHECKCB(fill_zero(ctxt,precision_fill)); - written += precision_fill; - - CHECKCB(ctxt->write_str(ctxt->user_data, conv_pos,conv_len)); - written += conv_len; - - if ((flags & JUSTIFY_MASK) == JUSTIFY_LEFT) { - CHECKCB(fill_space(ctxt,field_fill)); - } - written += field_fill; + if(precision < 0) { + precision = 1; + } else { + flags &= ~PAD_ZERO; } - break; + + if(flags & SIGNED_YES) { + /* signed integers */ + LARGEST_SIGNED value = 0; + switch(flags & SIZE_MASK) { + case SIZE_CHAR: + value = (signed char)va_arg(ap, int); + break; + case SIZE_SHORT: + value = (short)va_arg(ap, int); + break; + case SIZE_INT: + value = va_arg(ap, int); + break; +#ifndef HAVE_LONGLONG + case SIZE_LONGLONG: /* Treat long long the same as long */ +#endif + case SIZE_LONG: + value = va_arg(ap, long); + break; +#ifdef HAVE_LONGLONG + case SIZE_LONGLONG: + value = va_arg(ap, long long); + break; +#endif + } + if(value < 0) { + uvalue = -value; + negative = 1; + } else { + uvalue = value; + } + } else { + + switch(flags & SIZE_MASK) { + case SIZE_CHAR: + uvalue = (unsigned char)va_arg(ap, unsigned int); + break; + case SIZE_SHORT: + uvalue = (unsigned short)va_arg(ap, unsigned int); + break; + case SIZE_INT: + uvalue = va_arg(ap, unsigned int); + break; +#ifndef HAVE_LONGLONG + case SIZE_LONGLONG: /* Treat long long the same as long */ +#endif + case SIZE_LONG: + uvalue = va_arg(ap, unsigned long); + break; +#ifdef HAVE_LONGLONG + case SIZE_LONGLONG: + uvalue = va_arg(ap, unsigned long long); + break; +#endif + } + } + + switch(flags & (RADIX_MASK)) { + case RADIX_DECIMAL: + conv_len = output_uint_decimal(&conv_pos, uvalue); + break; + case RADIX_OCTAL: + conv_len = output_uint_octal(&conv_pos, uvalue); + break; + case RADIX_HEX: + conv_len = output_uint_hex(&conv_pos, uvalue, flags); + break; + } + + width += conv_len; + precision_fill = (precision > conv_len) ? precision - conv_len : 0; + if((flags & (RADIX_MASK | ALTERNATE_FORM)) + == (RADIX_OCTAL | ALTERNATE_FORM)) { + if(precision_fill < 1) { + precision_fill = 1; + } + } + + width += precision_fill; + + if((flags & (RADIX_MASK | ALTERNATE_FORM)) + == (RADIX_HEX | ALTERNATE_FORM) && uvalue != 0) { + prefix_len = 2; + if(flags & CAPS_YES) { + prefix = "0X"; + } else { + prefix = "0x"; + } + } + + if(flags & SIGNED_YES) { + if(negative) { + prefix = "-"; + prefix_len = 1; + } else { + switch(flags & POSITIVE_MASK) { + case POSITIVE_SPACE: + prefix = " "; + prefix_len = 1; + break; + case POSITIVE_PLUS: + prefix = "+"; + prefix_len = 1; + break; + } + } + } + + width += prefix_len; + + field_fill = (minwidth > width) ? minwidth - width : 0; + + if((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { + if(flags & PAD_ZERO) { + precision_fill += field_fill; + field_fill = 0; /* Do not double count padding */ + } else { + CHECKCB(fill_space(ctxt, field_fill)); + } + } + + if(prefix_len > 0) { + CHECKCB(ctxt->write_str(ctxt->user_data, prefix, prefix_len)); + } + written += prefix_len; + + CHECKCB(fill_zero(ctxt, precision_fill)); + written += precision_fill; + + CHECKCB(ctxt->write_str(ctxt->user_data, conv_pos, conv_len)); + written += conv_len; + + if((flags & JUSTIFY_MASK) == JUSTIFY_LEFT) { + CHECKCB(fill_space(ctxt, field_fill)); + } + written += field_fill; + } + break; case CONV_STRING: - { - unsigned int field_fill; - unsigned int len; - char *str = va_arg(ap,char *); - if (str) { - char *pos = str; - while(*pos != '\0') pos++; - len = pos - str; - } else { - str = "(null)"; - len = 6; - } - if (precision >= 0 && precision < len) len = precision; - field_fill = (minwidth > len) ? minwidth - len : 0; - if ((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { - CHECKCB(fill_space(ctxt,field_fill)); - } - CHECKCB(ctxt->write_str(ctxt->user_data, str,len)); - written += len; - if ((flags & JUSTIFY_MASK) == JUSTIFY_LEFT) { - CHECKCB(fill_space(ctxt,field_fill)); - } - written += field_fill; + { + unsigned int field_fill; + unsigned int len; + char *str = va_arg(ap, char *); + + if(str) { + char *pos = str; + while(*pos != '\0') pos++; + len = pos - str; + } else { + str = "(null)"; + len = 6; } - break; + + if(precision >= 0 && precision < len) { + len = precision; + } + + field_fill = (minwidth > len) ? minwidth - len : 0; + + if((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { + CHECKCB(fill_space(ctxt, field_fill)); + } + + CHECKCB(ctxt->write_str(ctxt->user_data, str, len)); + written += len; + + if((flags & JUSTIFY_MASK) == JUSTIFY_LEFT) { + CHECKCB(fill_space(ctxt, field_fill)); + } + written += field_fill; + } + break; case CONV_POINTER: - { - LARGEST_UNSIGNED uvalue = - (LARGEST_UNSIGNED)(POINTER_INT)va_arg(ap,void *); - char buffer[MAXCHARS_HEX + 3]; - char *conv_pos = buffer + MAXCHARS_HEX+3; - unsigned int conv_len; - unsigned int field_fill; - - conv_len = output_uint_hex(&conv_pos,uvalue,flags); - if (conv_len == 0) { - *--conv_pos = '0'; - conv_len++; - } - *--conv_pos = 'x'; - *--conv_pos = '0'; - *--conv_pos = '#'; - conv_len += 3; + { + LARGEST_UNSIGNED uvalue = + (LARGEST_UNSIGNED)(POINTER_INT)va_arg(ap, void *); + char buffer[MAXCHARS_HEX + 3]; + char *conv_pos = buffer + MAXCHARS_HEX + 3; + unsigned int conv_len; + unsigned int field_fill; - field_fill = (minwidth > conv_len) ? minwidth - conv_len : 0; - - if ((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { - CHECKCB(fill_space(ctxt,field_fill)); - } - - CHECKCB(ctxt->write_str(ctxt->user_data, conv_pos,conv_len)); - written += conv_len; - - if ((flags & JUSTIFY_MASK) == JUSTIFY_LEFT) { - CHECKCB(fill_space(ctxt,field_fill)); - } - written += field_fill; + conv_len = output_uint_hex(&conv_pos, uvalue, flags); + + if(conv_len == 0) { + *--conv_pos = '0'; + conv_len++; } - break; + + *--conv_pos = 'x'; + *--conv_pos = '0'; + *--conv_pos = '#'; + conv_len += 3; + + field_fill = (minwidth > conv_len) ? minwidth - conv_len : 0; + + if((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { + CHECKCB(fill_space(ctxt, field_fill)); + } + + CHECKCB(ctxt->write_str(ctxt->user_data, conv_pos, conv_len)); + written += conv_len; + + if((flags & JUSTIFY_MASK) == JUSTIFY_LEFT) { + CHECKCB(fill_space(ctxt, field_fill)); + } + + written += field_fill; + } + break; case CONV_CHAR: - { - char ch = va_arg(ap,int); - unsigned int field_fill = (minwidth > 1) ? minwidth - 1 : 0; - if ((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { - CHECKCB(fill_space(ctxt,field_fill)); - written += field_fill; - } - - CHECKCB(ctxt->write_str(ctxt->user_data, &ch, 1)); - written++; - - if ((flags & JUSTIFY_MASK) == JUSTIFY_LEFT) { - CHECKCB(fill_space(ctxt,field_fill)); - } - written+= field_fill; - } - break; - case CONV_WRITTEN: - { - int *p = va_arg(ap,int*); - *p = written; - } - break; + { + char ch = va_arg(ap, int); + unsigned int field_fill = (minwidth > 1) ? minwidth - 1 : 0; + if((flags & JUSTIFY_MASK) == JUSTIFY_RIGHT) { + CHECKCB(fill_space(ctxt, field_fill)); + written += field_fill; + } + + CHECKCB(ctxt->write_str(ctxt->user_data, &ch, 1)); + written++; + + if((flags & JUSTIFY_MASK) == JUSTIFY_LEFT) { + CHECKCB(fill_space(ctxt, field_fill)); + } + written += field_fill; + } + break; + case CONV_WRITTEN: + { + int *p = va_arg(ap, int *); + *p = written; + } + break; } } - + return written; } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/arm/common/dbg-io/strformat.h b/arch/cpu/arm/common/dbg-io/strformat.h index df6a56f39..c873e3649 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.h +++ b/arch/cpu/arm/common/dbg-io/strformat.h @@ -12,8 +12,7 @@ typedef unsigned int StrFormatResult; /* The data argument may only be considered valid during the function call */ typedef StrFormatResult (*StrFormatWrite)(void *user_data, const char *data, unsigned int len); -typedef struct _StrFormatContext -{ +typedef struct _StrFormatContext { StrFormatWrite write_str; void *user_data; } StrFormatContext; From 888a99ed3c8ce3955327dd9ee886adbc1c8f86e8 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 22 Nov 2017 01:01:19 +0000 Subject: [PATCH 03/24] Move macros to top of file --- arch/cpu/arm/common/dbg-io/strformat.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/cpu/arm/common/dbg-io/strformat.c b/arch/cpu/arm/common/dbg-io/strformat.c index 37ac4ae25..19e09caf4 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.c +++ b/arch/cpu/arm/common/dbg-io/strformat.c @@ -99,7 +99,13 @@ typedef unsigned int FormatFlags; #define FLOAT_HEX (0x0003 << FLOAT_SHIFT) #define FLOAT_MASK MAKE_MASK(FLOAT_SHIFT, FLOAT_SIZE) /*---------------------------------------------------------------------------*/ +#define CHECKCB(res) { if((res) != STRFORMAT_OK) { va_end(ap); return -1; } } +/*---------------------------------------------------------------------------*/ +#define MAXCHARS_HEX ((sizeof(LARGEST_UNSIGNED) * 8) / 4) +/* Largest number of characters needed for converting an unsigned integer. */ +#define MAXCHARS ((sizeof(LARGEST_UNSIGNED) * 8 + 2) / 3) +/*---------------------------------------------------------------------------*/ static FormatFlags parse_flags(const char **posp) { @@ -148,13 +154,6 @@ parse_uint(const char **posp) return v; } - -#define MAXCHARS_HEX ((sizeof(LARGEST_UNSIGNED) * 8) / 4 ) - -/* Largest number of characters needed for converting an unsigned integer. - */ -#define MAXCHARS ((sizeof(LARGEST_UNSIGNED) * 8 + 2) / 3 ) - /*---------------------------------------------------------------------------*/ static unsigned int output_uint_decimal(char **posp, LARGEST_UNSIGNED v) @@ -249,8 +248,6 @@ fill_zero(const StrFormatContext *ctxt, unsigned int len) return ctxt->write_str(ctxt->user_data, buffer, len); } /*---------------------------------------------------------------------------*/ -#define CHECKCB(res) {if ((res) != STRFORMAT_OK) {va_end(ap); return -1;}} -/*---------------------------------------------------------------------------*/ int format_str(const StrFormatContext *ctxt, const char *format, ...) { From 89148eb030beb4d100114c7ce6514855bdc40338 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 22 Nov 2017 01:23:59 +0000 Subject: [PATCH 04/24] Include contiki.h --- arch/cpu/arm/common/dbg-io/dbg-printf.c | 2 ++ arch/cpu/arm/common/dbg-io/dbg-putchar.c | 2 ++ arch/cpu/arm/common/dbg-io/dbg-puts.c | 2 ++ arch/cpu/arm/common/dbg-io/dbg-snprintf.c | 2 ++ arch/cpu/arm/common/dbg-io/dbg-sprintf.c | 2 ++ arch/cpu/arm/common/dbg-io/strformat.c | 2 ++ arch/cpu/arm/common/dbg-io/strformat.h | 2 ++ 7 files changed, 14 insertions(+) diff --git a/arch/cpu/arm/common/dbg-io/dbg-printf.c b/arch/cpu/arm/common/dbg-io/dbg-printf.c index 9ee3bd0e9..88174276c 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-printf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-printf.c @@ -1,4 +1,6 @@ /*---------------------------------------------------------------------------*/ +#include "contiki.h" + #include #include #include diff --git a/arch/cpu/arm/common/dbg-io/dbg-putchar.c b/arch/cpu/arm/common/dbg-io/dbg-putchar.c index eb0cb2180..f817f1699 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-putchar.c +++ b/arch/cpu/arm/common/dbg-io/dbg-putchar.c @@ -1,4 +1,6 @@ /*---------------------------------------------------------------------------*/ +#include "contiki.h" + #include #include #include diff --git a/arch/cpu/arm/common/dbg-io/dbg-puts.c b/arch/cpu/arm/common/dbg-io/dbg-puts.c index 222a436dc..21e6ac64b 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-puts.c +++ b/arch/cpu/arm/common/dbg-io/dbg-puts.c @@ -1,4 +1,6 @@ /*---------------------------------------------------------------------------*/ +#include "contiki.h" + #include #include #include diff --git a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c b/arch/cpu/arm/common/dbg-io/dbg-snprintf.c index 051d922ed..d650b13e0 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-snprintf.c @@ -1,4 +1,6 @@ /*---------------------------------------------------------------------------*/ +#include "contiki.h" + #include #include #include diff --git a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c b/arch/cpu/arm/common/dbg-io/dbg-sprintf.c index 8fb0d612f..85eb6669a 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-sprintf.c @@ -1,4 +1,6 @@ /*---------------------------------------------------------------------------*/ +#include "contiki.h" + #include #include #include diff --git a/arch/cpu/arm/common/dbg-io/strformat.c b/arch/cpu/arm/common/dbg-io/strformat.c index 19e09caf4..e905f67fd 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.c +++ b/arch/cpu/arm/common/dbg-io/strformat.c @@ -1,4 +1,6 @@ /*---------------------------------------------------------------------------*/ +#include "contiki.h" + #include /*---------------------------------------------------------------------------*/ #define HAVE_DOUBLE diff --git a/arch/cpu/arm/common/dbg-io/strformat.h b/arch/cpu/arm/common/dbg-io/strformat.h index c873e3649..38315c772 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.h +++ b/arch/cpu/arm/common/dbg-io/strformat.h @@ -2,6 +2,8 @@ #ifndef STRFORMAT_H_ #define STRFORMAT_H_ /*---------------------------------------------------------------------------*/ +#include "contiki.h" + #include /*---------------------------------------------------------------------------*/ #define STRFORMAT_OK 0 From a0e8b5195080aee73ccd288820cd2994b458e5df Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 22 Nov 2017 01:24:24 +0000 Subject: [PATCH 05/24] Add license and copyright notice --- arch/cpu/arm/common/dbg-io/dbg-printf.c | 30 +++++++++++++++++++++++ arch/cpu/arm/common/dbg-io/dbg-putchar.c | 30 +++++++++++++++++++++++ arch/cpu/arm/common/dbg-io/dbg-puts.c | 30 +++++++++++++++++++++++ arch/cpu/arm/common/dbg-io/dbg-snprintf.c | 30 +++++++++++++++++++++++ arch/cpu/arm/common/dbg-io/dbg-sprintf.c | 30 +++++++++++++++++++++++ arch/cpu/arm/common/dbg-io/strformat.c | 30 +++++++++++++++++++++++ arch/cpu/arm/common/dbg-io/strformat.h | 30 +++++++++++++++++++++++ 7 files changed, 210 insertions(+) diff --git a/arch/cpu/arm/common/dbg-io/dbg-printf.c b/arch/cpu/arm/common/dbg-io/dbg-printf.c index 88174276c..5afca6123 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-printf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-printf.c @@ -1,3 +1,33 @@ +/* + * Copyright (c) 2009, Simon Berg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/arch/cpu/arm/common/dbg-io/dbg-putchar.c b/arch/cpu/arm/common/dbg-io/dbg-putchar.c index f817f1699..842939ac3 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-putchar.c +++ b/arch/cpu/arm/common/dbg-io/dbg-putchar.c @@ -1,3 +1,33 @@ +/* + * Copyright (c) 2009, Simon Berg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/arch/cpu/arm/common/dbg-io/dbg-puts.c b/arch/cpu/arm/common/dbg-io/dbg-puts.c index 21e6ac64b..a15019620 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-puts.c +++ b/arch/cpu/arm/common/dbg-io/dbg-puts.c @@ -1,3 +1,33 @@ +/* + * Copyright (c) 2009, Simon Berg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c b/arch/cpu/arm/common/dbg-io/dbg-snprintf.c index d650b13e0..e7a04ac31 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-snprintf.c @@ -1,3 +1,33 @@ +/* + * Copyright (c) 2009, Simon Berg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c b/arch/cpu/arm/common/dbg-io/dbg-sprintf.c index 85eb6669a..8d0437869 100644 --- a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c +++ b/arch/cpu/arm/common/dbg-io/dbg-sprintf.c @@ -1,3 +1,33 @@ +/* + * Copyright (c) 2009, Simon Berg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/arch/cpu/arm/common/dbg-io/strformat.c b/arch/cpu/arm/common/dbg-io/strformat.c index e905f67fd..8e7d8bd3f 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.c +++ b/arch/cpu/arm/common/dbg-io/strformat.c @@ -1,3 +1,33 @@ +/* + * Copyright (c) 2009, Simon Berg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ /*---------------------------------------------------------------------------*/ #include "contiki.h" diff --git a/arch/cpu/arm/common/dbg-io/strformat.h b/arch/cpu/arm/common/dbg-io/strformat.h index 38315c772..f02bc1791 100644 --- a/arch/cpu/arm/common/dbg-io/strformat.h +++ b/arch/cpu/arm/common/dbg-io/strformat.h @@ -1,3 +1,33 @@ +/* + * Copyright (c) 2009, Simon Berg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ /*---------------------------------------------------------------------------*/ #ifndef STRFORMAT_H_ #define STRFORMAT_H_ From bb338affeb3a9c54096b6717f99f5ff7080a7d76 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 22 Nov 2017 01:33:05 +0000 Subject: [PATCH 06/24] Move dbg-io to os --- arch/cpu/arm/common/dbg-io/dbg-printf.c => os/lib/dbg-io/printf.c | 0 .../arm/common/dbg-io/dbg-putchar.c => os/lib/dbg-io/putchar.c | 0 arch/cpu/arm/common/dbg-io/dbg-puts.c => os/lib/dbg-io/puts.c | 0 .../arm/common/dbg-io/dbg-snprintf.c => os/lib/dbg-io/snprintf.c | 0 .../arm/common/dbg-io/dbg-sprintf.c => os/lib/dbg-io/sprintf.c | 0 {arch/cpu/arm/common => os/lib}/dbg-io/strformat.c | 0 {arch/cpu/arm/common => os/lib}/dbg-io/strformat.h | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename arch/cpu/arm/common/dbg-io/dbg-printf.c => os/lib/dbg-io/printf.c (100%) rename arch/cpu/arm/common/dbg-io/dbg-putchar.c => os/lib/dbg-io/putchar.c (100%) rename arch/cpu/arm/common/dbg-io/dbg-puts.c => os/lib/dbg-io/puts.c (100%) rename arch/cpu/arm/common/dbg-io/dbg-snprintf.c => os/lib/dbg-io/snprintf.c (100%) rename arch/cpu/arm/common/dbg-io/dbg-sprintf.c => os/lib/dbg-io/sprintf.c (100%) rename {arch/cpu/arm/common => os/lib}/dbg-io/strformat.c (100%) rename {arch/cpu/arm/common => os/lib}/dbg-io/strformat.h (100%) diff --git a/arch/cpu/arm/common/dbg-io/dbg-printf.c b/os/lib/dbg-io/printf.c similarity index 100% rename from arch/cpu/arm/common/dbg-io/dbg-printf.c rename to os/lib/dbg-io/printf.c diff --git a/arch/cpu/arm/common/dbg-io/dbg-putchar.c b/os/lib/dbg-io/putchar.c similarity index 100% rename from arch/cpu/arm/common/dbg-io/dbg-putchar.c rename to os/lib/dbg-io/putchar.c diff --git a/arch/cpu/arm/common/dbg-io/dbg-puts.c b/os/lib/dbg-io/puts.c similarity index 100% rename from arch/cpu/arm/common/dbg-io/dbg-puts.c rename to os/lib/dbg-io/puts.c diff --git a/arch/cpu/arm/common/dbg-io/dbg-snprintf.c b/os/lib/dbg-io/snprintf.c similarity index 100% rename from arch/cpu/arm/common/dbg-io/dbg-snprintf.c rename to os/lib/dbg-io/snprintf.c diff --git a/arch/cpu/arm/common/dbg-io/dbg-sprintf.c b/os/lib/dbg-io/sprintf.c similarity index 100% rename from arch/cpu/arm/common/dbg-io/dbg-sprintf.c rename to os/lib/dbg-io/sprintf.c diff --git a/arch/cpu/arm/common/dbg-io/strformat.c b/os/lib/dbg-io/strformat.c similarity index 100% rename from arch/cpu/arm/common/dbg-io/strformat.c rename to os/lib/dbg-io/strformat.c diff --git a/arch/cpu/arm/common/dbg-io/strformat.h b/os/lib/dbg-io/strformat.h similarity index 100% rename from arch/cpu/arm/common/dbg-io/strformat.h rename to os/lib/dbg-io/strformat.h From 8e52414e44b8cf8e58a4edcc994f5618a2f4aba1 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 22 Nov 2017 01:34:08 +0000 Subject: [PATCH 07/24] Fix naming convention --- os/lib/dbg-io/printf.c | 4 ++-- os/lib/dbg-io/snprintf.c | 10 +++++----- os/lib/dbg-io/sprintf.c | 4 ++-- os/lib/dbg-io/strformat.c | 16 ++++++++-------- os/lib/dbg-io/strformat.h | 16 +++++++++------- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/os/lib/dbg-io/printf.c b/os/lib/dbg-io/printf.c index 5afca6123..36ac0d2e1 100644 --- a/os/lib/dbg-io/printf.c +++ b/os/lib/dbg-io/printf.c @@ -36,7 +36,7 @@ #include #include /*---------------------------------------------------------------------------*/ -static StrFormatResult +static strformat_result write_str(void *user_data, const char *data, unsigned int len) { if(len > 0) { @@ -45,7 +45,7 @@ write_str(void *user_data, const char *data, unsigned int len) return STRFORMAT_OK; } /*---------------------------------------------------------------------------*/ -static StrFormatContext ctxt = +static strformat_context_t ctxt = { write_str, NULL diff --git a/os/lib/dbg-io/snprintf.c b/os/lib/dbg-io/snprintf.c index e7a04ac31..96f99e568 100644 --- a/os/lib/dbg-io/snprintf.c +++ b/os/lib/dbg-io/snprintf.c @@ -35,15 +35,15 @@ #include #include /*---------------------------------------------------------------------------*/ -struct FmtBuffer { +struct fmt_buffer { char *pos; size_t left; }; /*---------------------------------------------------------------------------*/ -static StrFormatResult +static strformat_result buffer_str(void *user_data, const char *data, unsigned int len) { - struct FmtBuffer *buffer = (struct FmtBuffer *)user_data; + struct fmt_buffer *buffer = (struct fmt_buffer *)user_data; if(len >= buffer->left) { len = buffer->left; len--; @@ -69,8 +69,8 @@ snprintf(char *str, size_t size, const char *format, ...) int vsnprintf(char *str, size_t size, const char *format, va_list ap) { - struct FmtBuffer buffer; - StrFormatContext ctxt; + struct fmt_buffer buffer; + strformat_context_t ctxt; int res; ctxt.write_str = buffer_str; ctxt.user_data = &buffer; diff --git a/os/lib/dbg-io/sprintf.c b/os/lib/dbg-io/sprintf.c index 8d0437869..4ecf5b540 100644 --- a/os/lib/dbg-io/sprintf.c +++ b/os/lib/dbg-io/sprintf.c @@ -35,7 +35,7 @@ #include #include /*---------------------------------------------------------------------------*/ -static StrFormatResult +static strformat_result buffer_str(void *user_data, const char *data, unsigned int len) { memcpy(*(char **)user_data, data, len); @@ -46,7 +46,7 @@ buffer_str(void *user_data, const char *data, unsigned int len) int sprintf(char *str, const char *format, ...) { - StrFormatContext ctxt; + strformat_context_t ctxt; int res; va_list ap; va_start(ap, format); diff --git a/os/lib/dbg-io/strformat.c b/os/lib/dbg-io/strformat.c index 8e7d8bd3f..b5ad18f89 100644 --- a/os/lib/dbg-io/strformat.c +++ b/os/lib/dbg-io/strformat.c @@ -239,10 +239,10 @@ output_uint_octal(char **posp, LARGEST_UNSIGNED v) return len; } /*---------------------------------------------------------------------------*/ -static StrFormatResult -fill_space(const StrFormatContext *ctxt, unsigned int len) +static strformat_result +fill_space(const strformat_context_t *ctxt, unsigned int len) { - StrFormatResult res; + strformat_result res; static const char buffer[16] = " "; while(len > 16) { @@ -260,10 +260,10 @@ fill_space(const StrFormatContext *ctxt, unsigned int len) return ctxt->write_str(ctxt->user_data, buffer, len); } /*---------------------------------------------------------------------------*/ -static StrFormatResult -fill_zero(const StrFormatContext *ctxt, unsigned int len) +static strformat_result +fill_zero(const strformat_context_t *ctxt, unsigned int len) { - StrFormatResult res; + strformat_result res; static const char buffer[16] = "0000000000000000"; while(len > 16) { @@ -281,7 +281,7 @@ fill_zero(const StrFormatContext *ctxt, unsigned int len) } /*---------------------------------------------------------------------------*/ int -format_str(const StrFormatContext *ctxt, const char *format, ...) +format_str(const strformat_context_t *ctxt, const char *format, ...) { int ret; va_list ap; @@ -292,7 +292,7 @@ format_str(const StrFormatContext *ctxt, const char *format, ...) } /*---------------------------------------------------------------------------*/ int -format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap) +format_str_v(const strformat_context_t *ctxt, const char *format, va_list ap) { unsigned int written = 0; const char *pos = format; diff --git a/os/lib/dbg-io/strformat.h b/os/lib/dbg-io/strformat.h index f02bc1791..62d99b303 100644 --- a/os/lib/dbg-io/strformat.h +++ b/os/lib/dbg-io/strformat.h @@ -39,21 +39,23 @@ #define STRFORMAT_OK 0 #define STRFORMAT_FAILED 1 /*---------------------------------------------------------------------------*/ -typedef unsigned int StrFormatResult; +typedef unsigned int strformat_result; /*---------------------------------------------------------------------------*/ /* The data argument may only be considered valid during the function call */ -typedef StrFormatResult (*StrFormatWrite)(void *user_data, const char *data, unsigned int len); +typedef strformat_result (*strformat_write)(void *user_data, + const char *data, + unsigned int len); -typedef struct _StrFormatContext { - StrFormatWrite write_str; +typedef struct strformat_context_s { + strformat_write write_str; void *user_data; -} StrFormatContext; +} strformat_context_t; /*---------------------------------------------------------------------------*/ -int format_str(const StrFormatContext *ctxt, const char *format, ...) +int format_str(const strformat_context_t *ctxt, const char *format, ...) __attribute__ ((__format__ (__printf__, 2,3))); int -format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap); +format_str_v(const strformat_context_t *ctxt, const char *format, va_list ap); /*---------------------------------------------------------------------------*/ #endif /* STRFORMAT_H_ */ /*---------------------------------------------------------------------------*/ From ed3e2c850e8e47118e38c8179b0936f7136d38ce Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 22 Nov 2017 01:41:11 +0000 Subject: [PATCH 08/24] Remove depedency to a debug-uart.h --- arch/cpu/arm/common/SD-card/cfs-sdcard.c | 1 - arch/cpu/cc2538/debug-uart.h | 47 -------------------- arch/cpu/cc26xx-cc13xx/debug-uart.h | 49 -------------------- arch/platform/nrf52dk/dbg-io/debug-uart.h | 54 ----------------------- os/lib/dbg-io/printf.c | 1 - os/lib/dbg-io/putchar.c | 1 - os/lib/dbg-io/puts.c | 1 - 7 files changed, 154 deletions(-) delete mode 100644 arch/cpu/cc2538/debug-uart.h delete mode 100644 arch/cpu/cc26xx-cc13xx/debug-uart.h delete mode 100644 arch/platform/nrf52dk/dbg-io/debug-uart.h diff --git a/arch/cpu/arm/common/SD-card/cfs-sdcard.c b/arch/cpu/arm/common/SD-card/cfs-sdcard.c index 9be29fd2e..4c44e3e6b 100644 --- a/arch/cpu/arm/common/SD-card/cfs-sdcard.c +++ b/arch/cpu/arm/common/SD-card/cfs-sdcard.c @@ -1,7 +1,6 @@ #include #include #include -#include #include diff --git a/arch/cpu/cc2538/debug-uart.h b/arch/cpu/cc2538/debug-uart.h deleted file mode 100644 index 88a2fc3e0..000000000 --- a/arch/cpu/cc2538/debug-uart.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * \addtogroup cc2538-char-io - * @{ - * - * \file - * This file is here because DBG I/O expects it to be. It just includes - * our own dbg.h which has a non-misleading name and which also adheres - * to Contiki's naming convention - */ -#ifndef DEBUG_UART_H_ -#define DEBUG_UART_H_ - -#include "dbg.h" - -#endif /* DEBUG_UART_H_ */ - -/** @} */ diff --git a/arch/cpu/cc26xx-cc13xx/debug-uart.h b/arch/cpu/cc26xx-cc13xx/debug-uart.h deleted file mode 100644 index c2d9b0ffb..000000000 --- a/arch/cpu/cc26xx-cc13xx/debug-uart.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/*---------------------------------------------------------------------------*/ -/** - * \addtogroup cc26xx-char-io - * @{ - * - * \file - * This file is here because DBG I/O expects it to be. It just includes - * our own dbg.h which has a non-misleading name and which also adheres - * to Contiki's naming convention - */ -/*---------------------------------------------------------------------------*/ -#ifndef DEBUG_UART_H_ -#define DEBUG_UART_H_ -/*---------------------------------------------------------------------------*/ -#include "dbg.h" -/*---------------------------------------------------------------------------*/ -#endif /* DEBUG_UART_H_ */ -/*---------------------------------------------------------------------------*/ -/** @} */ diff --git a/arch/platform/nrf52dk/dbg-io/debug-uart.h b/arch/platform/nrf52dk/dbg-io/debug-uart.h deleted file mode 100644 index b52d2fb50..000000000 --- a/arch/platform/nrf52dk/dbg-io/debug-uart.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015, Nordic Semiconductor - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/** - * \addtogroup nrf52dk - * @{ - * - * \addtogroup nrf52dk-dbg-io Debug IO over UART - * @{ - * - * \file - * A header file to maintain compatibility with DBG I/O. - * \author - * Wojciech Bober - * - */ -/*---------------------------------------------------------------------------*/ -#ifndef DEBUG_UART_H_ -#define DEBUG_UART_H_ -/*---------------------------------------------------------------------------*/ -#include "dbg.h" -/*---------------------------------------------------------------------------*/ -#endif /* DEBUG_UART_H_ */ -/*---------------------------------------------------------------------------*/ -/** - * @} - * @} - */ diff --git a/os/lib/dbg-io/printf.c b/os/lib/dbg-io/printf.c index 36ac0d2e1..9a747d538 100644 --- a/os/lib/dbg-io/printf.c +++ b/os/lib/dbg-io/printf.c @@ -32,7 +32,6 @@ #include "contiki.h" #include -#include #include #include /*---------------------------------------------------------------------------*/ diff --git a/os/lib/dbg-io/putchar.c b/os/lib/dbg-io/putchar.c index 842939ac3..98a3617b2 100644 --- a/os/lib/dbg-io/putchar.c +++ b/os/lib/dbg-io/putchar.c @@ -32,7 +32,6 @@ #include "contiki.h" #include -#include #include /*---------------------------------------------------------------------------*/ #undef putchar diff --git a/os/lib/dbg-io/puts.c b/os/lib/dbg-io/puts.c index a15019620..6332ae471 100644 --- a/os/lib/dbg-io/puts.c +++ b/os/lib/dbg-io/puts.c @@ -32,7 +32,6 @@ #include "contiki.h" #include -#include #include /*---------------------------------------------------------------------------*/ int From 40f6b1a2ba12b2f58c4e3bfe04144ba752ab54a5 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 24 Mar 2018 21:17:32 +0000 Subject: [PATCH 09/24] Rename files to resolve filename conflicts --- arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx | 2 +- arch/cpu/cc26xx-cc13xx/{putchar.c => dbg.c} | 0 arch/cpu/nrf52832/Makefile.nrf52832 | 2 +- arch/cpu/nrf52832/{putchar.c => dbg.c} | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename arch/cpu/cc26xx-cc13xx/{putchar.c => dbg.c} (100%) rename arch/cpu/nrf52832/{putchar.c => dbg.c} (100%) diff --git a/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx b/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx index 979d7f5e4..f5543bbc0 100644 --- a/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx +++ b/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx @@ -30,7 +30,7 @@ CONTIKI_CPU_DIRS += . dev rf-core rf-core/api rf-core/ble-hal $(TI_XXWARE_STARTU ### CPU-dependent source files CONTIKI_CPU_SOURCEFILES += clock.c rtimer-arch.c soc-rtc.c uart.c CONTIKI_CPU_SOURCEFILES += contiki-watchdog.c aux-ctrl.c -CONTIKI_CPU_SOURCEFILES += putchar.c ieee-addr.c batmon-sensor.c adc-sensor.c +CONTIKI_CPU_SOURCEFILES += dbg.c ieee-addr.c batmon-sensor.c adc-sensor.c CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c cc26xx-uart.c lpm.c CONTIKI_CPU_SOURCEFILES += gpio-interrupt.c gpio-hal-arch.c oscillators.c CONTIKI_CPU_SOURCEFILES += rf-core.c rf-ble.c ieee-mode.c diff --git a/arch/cpu/cc26xx-cc13xx/putchar.c b/arch/cpu/cc26xx-cc13xx/dbg.c similarity index 100% rename from arch/cpu/cc26xx-cc13xx/putchar.c rename to arch/cpu/cc26xx-cc13xx/dbg.c diff --git a/arch/cpu/nrf52832/Makefile.nrf52832 b/arch/cpu/nrf52832/Makefile.nrf52832 index c2bdbbf81..5e0db414d 100644 --- a/arch/cpu/nrf52832/Makefile.nrf52832 +++ b/arch/cpu/nrf52832/Makefile.nrf52832 @@ -54,7 +54,7 @@ remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-ou CONTIKI_CPU_DIRS += . dev ble #compat ### CPU-dependent source files -CONTIKI_CPU_SOURCEFILES += clock.c rtimer-arch.c uart0.c putchar.c watchdog.c +CONTIKI_CPU_SOURCEFILES += clock.c rtimer-arch.c uart0.c dbg.c watchdog.c CONTIKI_CPU_SOURCEFILES += int-master.c ifneq ($(NRF52_WITHOUT_SOFTDEVICE),1) diff --git a/arch/cpu/nrf52832/putchar.c b/arch/cpu/nrf52832/dbg.c similarity index 100% rename from arch/cpu/nrf52832/putchar.c rename to arch/cpu/nrf52832/dbg.c From 6d592945a04fc3a2190fadfbc540bce978932202 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 24 Mar 2018 21:22:54 +0000 Subject: [PATCH 10/24] Use a single common dbg.h --- arch/cpu/cc2538/dbg.c | 1 - arch/cpu/cc2538/dbg.h | 89 ------------------- arch/platform/nrf52dk/dbg-io/dbg.h | 67 -------------- .../cpu/cc26xx-cc13xx => os/lib/dbg-io}/dbg.h | 25 +++--- os/lib/dbg-io/printf.c | 1 + os/lib/dbg-io/putchar.c | 1 + os/lib/dbg-io/puts.c | 1 + 7 files changed, 17 insertions(+), 168 deletions(-) delete mode 100644 arch/cpu/cc2538/dbg.h delete mode 100644 arch/platform/nrf52dk/dbg-io/dbg.h rename {arch/cpu/cc26xx-cc13xx => os/lib/dbg-io}/dbg.h (80%) diff --git a/arch/cpu/cc2538/dbg.c b/arch/cpu/cc2538/dbg.c index b97936feb..e95a6c94a 100644 --- a/arch/cpu/cc2538/dbg.c +++ b/arch/cpu/cc2538/dbg.c @@ -37,7 +37,6 @@ */ #include "contiki.h" -#include "dbg.h" #include "dev/uart.h" #include "usb/usb-serial.h" diff --git a/arch/cpu/cc2538/dbg.h b/arch/cpu/cc2538/dbg.h deleted file mode 100644 index d5ab51f9d..000000000 --- a/arch/cpu/cc2538/dbg.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * \addtogroup cc2538 - * @{ - * - * \defgroup cc2538-char-io cc2538 Character I/O - * - * CPU-specific functions for debugging and SLIP I/O - * - * On the cc2538, character I/O can be directed over USB or UART. This is - * controlled by a series of configuration directives: - * - SLIP_ARCH_CONF_USB: Controls the operation of slip-arch. - * - DBG_CONF_USB: Controls all debugging output - * - * Defaults for those defines are set in contiki-conf.h - * @{ - * - * \file - * Header file for the cc2538 Debug I/O module - */ -#ifndef DBG_H_ -#define DBG_H_ - -#include "contiki.h" - -#include "usb/usb-serial.h" -/** - * \brief Print a stream of bytes - * \param seq A pointer to the stream - * \param len The number of bytes to print - * \return The number of printed bytes - * - * This function is an arch-specific implementation required by the dbg-io - * API in cpu/arm/common/dbg-io. It prints a stream of bytes over the - * peripheral used by the platform. - */ -unsigned int dbg_send_bytes(const unsigned char *seq, unsigned int len); - -/** - * \brief Flushes character output - * - * When debugging is sent over USB, this functions causes the USB - * driver to immediately TX the content of output buffers. When - * debugging is over UART, this function does nothing. - * - * There is nothing stopping you from using this macro in your code but - * normally, you won't have to. - */ -#if DBG_CONF_USB -#define dbg_flush() usb_serial_flush() -#else -#define dbg_flush() -#endif - -#endif /* DBG_H_ */ - -/** - * @} - * @} - */ diff --git a/arch/platform/nrf52dk/dbg-io/dbg.h b/arch/platform/nrf52dk/dbg-io/dbg.h deleted file mode 100644 index 5d9568270..000000000 --- a/arch/platform/nrf52dk/dbg-io/dbg.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, Nordic Semiconductor - * All rights reserved. - * -3 * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/** - * \addtogroup nrf52dk - * @{ - * - * \addtogroup nrf52dk-dbg-io Debug IO over UART - * @{ - * - * \file - * Header file for the debug module. - * \author - * Wojciech Bober - * - */ -#ifndef DBG_H_ -#define DBG_H_ -/*---------------------------------------------------------------------------*/ -#include "contiki.h" -/*---------------------------------------------------------------------------*/ -/** - * \brief Print a stream of bytes - * \param seq A pointer to the stream - * \param len The number of bytes to print - * \return The number of printed bytes - */ -unsigned int dbg_send_bytes(const unsigned char *seq, unsigned int len); -/** - * \brief Print a character to debug output - * \param c Character to print - * \return Printed character - */ -int dbg_putchar(int c); -/*---------------------------------------------------------------------------*/ -#endif /* DBG_H_ */ -/*---------------------------------------------------------------------------*/ -/** - * @} - * @} - */ diff --git a/arch/cpu/cc26xx-cc13xx/dbg.h b/os/lib/dbg-io/dbg.h similarity index 80% rename from arch/cpu/cc26xx-cc13xx/dbg.h rename to os/lib/dbg-io/dbg.h index 4460b6eb4..14f06fd31 100644 --- a/arch/cpu/cc26xx-cc13xx/dbg.h +++ b/os/lib/dbg-io/dbg.h @@ -1,10 +1,11 @@ /* - * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2015, Nordic Semiconductor * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -27,18 +28,18 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ -/*---------------------------------------------------------------------------*/ /** - * \addtogroup cc26xx + * \addtogroup nrf52dk * @{ * - * \defgroup cc26xx-char-io CC13xx/CC26xx Character I/O - * - * CC13xx/CC26xx CPU-specific functions for debugging and SLIP I/O + * \addtogroup nrf52dk-dbg-io Debug IO over UART * @{ * * \file - * Header file for the CC13xx/CC26xx Debug I/O module + * Header file for the debug module. + * \author + * Wojciech Bober + * */ #ifndef DBG_H_ #define DBG_H_ @@ -50,12 +51,14 @@ * \param seq A pointer to the stream * \param len The number of bytes to print * \return The number of printed bytes - * - * This function is an arch-specific implementation required by the dbg-io - * API in cpu/arm/common/dbg-io. It prints a stream of bytes over the - * peripheral used by the platform. */ unsigned int dbg_send_bytes(const unsigned char *seq, unsigned int len); +/** + * \brief Print a character to debug output + * \param c Character to print + * \return Printed character + */ +int dbg_putchar(int c); /*---------------------------------------------------------------------------*/ #endif /* DBG_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/os/lib/dbg-io/printf.c b/os/lib/dbg-io/printf.c index 9a747d538..9749f1f7d 100644 --- a/os/lib/dbg-io/printf.c +++ b/os/lib/dbg-io/printf.c @@ -30,6 +30,7 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" +#include "lib/dbg-io/dbg.h" #include #include diff --git a/os/lib/dbg-io/putchar.c b/os/lib/dbg-io/putchar.c index 98a3617b2..11bb7b5e6 100644 --- a/os/lib/dbg-io/putchar.c +++ b/os/lib/dbg-io/putchar.c @@ -30,6 +30,7 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" +#include "lib/dbg-io/dbg.h" #include #include diff --git a/os/lib/dbg-io/puts.c b/os/lib/dbg-io/puts.c index 6332ae471..93d73d3a5 100644 --- a/os/lib/dbg-io/puts.c +++ b/os/lib/dbg-io/puts.c @@ -30,6 +30,7 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" +#include "lib/dbg-io/dbg.h" #include #include From 1bf1f37b24ae1b0d6631ed1ab206c56ed8dfa1e3 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 24 Mar 2018 21:25:04 +0000 Subject: [PATCH 11/24] Build dbg-io as a module --- arch/cpu/cc2538/Makefile.cc2538 | 5 ++--- arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx | 4 ++-- arch/platform/nrf52dk/Makefile.nrf52dk | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/cpu/cc2538/Makefile.cc2538 b/arch/cpu/cc2538/Makefile.cc2538 index f6e76f571..03758aa9b 100644 --- a/arch/cpu/cc2538/Makefile.cc2538 +++ b/arch/cpu/cc2538/Makefile.cc2538 @@ -27,14 +27,13 @@ CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c CONTIKI_CPU_SOURCEFILES += i2c.c cc2538-temp-sensor.c vdd3-sensor.c CONTIKI_CPU_SOURCEFILES += cfs-coffee.c cfs-coffee-arch.c pwm.c -DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c +MODULES += os/lib/dbg-io USB_SOURCEFILES += usb-core.c cdc-acm.c usb-arch.c usb-serial.c cdc-acm-descriptors.c CPU_START_SOURCEFILES = startup-gcc.c -CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES) -CONTIKI_SOURCEFILES += $(USB_SOURCEFILES) +CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(USB_SOURCEFILES) ### Always re-build ieee-addr.o in case the command line passes a new NODEID FORCE: diff --git a/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx b/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx index f5543bbc0..75dbad7ad 100644 --- a/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx +++ b/arch/cpu/cc26xx-cc13xx/Makefile.cc26xx-cc13xx @@ -37,9 +37,9 @@ CONTIKI_CPU_SOURCEFILES += rf-core.c rf-ble.c ieee-mode.c CONTIKI_CPU_SOURCEFILES += ble-cc2650.c ble-hal-cc26xx.c ble-addr.c rf-ble-cmd.c CONTIKI_CPU_SOURCEFILES += random.c soc-trng.c int-master.c -DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c +MODULES += os/lib/dbg-io -CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES) +CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) CPU_START_SOURCEFILES += fault-handlers.c $(TI_XXWARE_STARTUP_SRCS) diff --git a/arch/platform/nrf52dk/Makefile.nrf52dk b/arch/platform/nrf52dk/Makefile.nrf52dk index 6187fc532..f52467afb 100644 --- a/arch/platform/nrf52dk/Makefile.nrf52dk +++ b/arch/platform/nrf52dk/Makefile.nrf52dk @@ -15,8 +15,7 @@ CONTIKI_SOURCEFILES += rtt-printf.c segger-rtt.c segger-rtt-printf.c else CONTIKI_TARGET_DIRS += dbg-io CONTIKI_SOURCEFILES += dbg.c -CONTIKI_CPU_DIRS += ../arm/common/dbg-io -CONTIKI_CPU_SOURCEFILES += dbg-printf.c dbg-putchar.c dbg-snprintf.c dbg-sprintf.c strformat.c +MODULES += os/lib/dbg-io endif CLEAN += *.nrf52dk From 86b10b69aaebfc754bb940e04e49ac576e5d4734 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 24 Mar 2018 21:29:51 +0000 Subject: [PATCH 12/24] Resolve multiple symbol definitions --- arch/cpu/cc2538/dbg.c | 17 ++--------------- arch/cpu/cc26xx-cc13xx/dbg.c | 23 +---------------------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/arch/cpu/cc2538/dbg.c b/arch/cpu/cc2538/dbg.c index e95a6c94a..8f51f235c 100644 --- a/arch/cpu/cc2538/dbg.c +++ b/arch/cpu/cc2538/dbg.c @@ -60,7 +60,7 @@ #define SLIP_END 0300 /*---------------------------------------------------------------------------*/ int -putchar(int c) +dbg_putchar(int c) { #if DBG_CONF_SLIP_MUX static char debug_frame = 0; @@ -79,7 +79,7 @@ putchar(int c) write_byte(SLIP_END); debug_frame = 0; #endif - dbg_flush(); + flush(); } return c; } @@ -99,18 +99,5 @@ dbg_send_bytes(const unsigned char *s, unsigned int len) return i; } /*---------------------------------------------------------------------------*/ -int -puts(const char *s) -{ - unsigned int i = 0; - - while(s && *s != 0) { - putchar(*s++); - i++; - } - putchar('\n'); - return i; -} -/*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/cpu/cc26xx-cc13xx/dbg.c b/arch/cpu/cc26xx-cc13xx/dbg.c index 7cbd1901a..bf03aade4 100644 --- a/arch/cpu/cc26xx-cc13xx/dbg.c +++ b/arch/cpu/cc26xx-cc13xx/dbg.c @@ -34,33 +34,12 @@ #include /*---------------------------------------------------------------------------*/ int -putchar(int c) +dbg_putchar(int c) { cc26xx_uart_write_byte(c); return c; } /*---------------------------------------------------------------------------*/ -int -puts(const char *str) -{ - int i; - if(str == NULL) { - return 0; - } - for(i = 0; i < strlen(str); i++) { - cc26xx_uart_write_byte(str[i]); - } - cc26xx_uart_write_byte('\n'); - - /* - * Wait for the line to go out. This is to prevent garbage when used between - * UART on/off cycles - */ - while(cc26xx_uart_busy() == UART_BUSY); - - return i; -} -/*---------------------------------------------------------------------------*/ unsigned int dbg_send_bytes(const unsigned char *s, unsigned int len) { From 04ca5fd46ad593922682fbd7ae5c4317737c398e Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 24 Mar 2018 22:47:13 +0000 Subject: [PATCH 13/24] Update doxygen content and structure --- arch/cpu/cc2538/dbg.c | 10 +--------- arch/cpu/cc2538/slip-arch.c | 22 ++-------------------- arch/cpu/cc26xx-cc13xx/slip-arch.c | 17 ----------------- os/lib/dbg-io/dbg.h | 7 ++++--- 4 files changed, 7 insertions(+), 49 deletions(-) diff --git a/arch/cpu/cc2538/dbg.c b/arch/cpu/cc2538/dbg.c index 8f51f235c..c39e05af7 100644 --- a/arch/cpu/cc2538/dbg.c +++ b/arch/cpu/cc2538/dbg.c @@ -28,13 +28,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** \addtogroup cc2538-char-io - * @{ */ -/** - * \file - * Implementation of arch-specific functions required by the dbg_io API in - * cpu/arm/common/dbg-io - */ +/*---------------------------------------------------------------------------*/ #include "contiki.h" #include "dev/uart.h" @@ -99,5 +93,3 @@ dbg_send_bytes(const unsigned char *s, unsigned int len) return i; } /*---------------------------------------------------------------------------*/ - -/** @} */ diff --git a/arch/cpu/cc2538/slip-arch.c b/arch/cpu/cc2538/slip-arch.c index 58aec9f84..dee023a4f 100644 --- a/arch/cpu/cc2538/slip-arch.c +++ b/arch/cpu/cc2538/slip-arch.c @@ -28,21 +28,12 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - * \addtogroup cc2538-char-io - * @{ - * - * \file - * Arch-specific SLIP functions for the cc2538 - * - * SLIP can be configured to operate over UART or over USB-Serial, depending - * on the value of SLIP_ARCH_CONF_USB - */ +/*---------------------------------------------------------------------------*/ #include "contiki.h" #include "dev/slip.h" #include "dev/uart.h" #include "usb/usb-serial.h" - +/*---------------------------------------------------------------------------*/ #ifndef SLIP_ARCH_CONF_USB #define SLIP_ARCH_CONF_USB 0 #endif @@ -59,10 +50,6 @@ #define SLIP_END 0300 /*---------------------------------------------------------------------------*/ -/** - * \brief Write a byte over SLIP - * \param c the byte - */ void slip_arch_writeb(unsigned char c) { @@ -72,14 +59,9 @@ slip_arch_writeb(unsigned char c) } } /*---------------------------------------------------------------------------*/ -/** - * \brief Initialise the arch-specific SLIP driver - */ void slip_arch_init() { set_input(slip_input_byte); } /*---------------------------------------------------------------------------*/ - -/** @} */ diff --git a/arch/cpu/cc26xx-cc13xx/slip-arch.c b/arch/cpu/cc26xx-cc13xx/slip-arch.c index 6c6914363..f4141e11d 100644 --- a/arch/cpu/cc26xx-cc13xx/slip-arch.c +++ b/arch/cpu/cc26xx-cc13xx/slip-arch.c @@ -29,31 +29,16 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -/** - * \addtogroup cc26xx-char-io - * @{ - * - * \file - * Arch-specific SLIP functions for the CC13xx/CC26xx - */ -/*---------------------------------------------------------------------------*/ #include "contiki.h" #include "dev/cc26xx-uart.h" #include "dev/slip.h" /*---------------------------------------------------------------------------*/ -/** - * \brief Write a byte over SLIP - * \param c the byte - */ void slip_arch_writeb(unsigned char c) { cc26xx_uart_write_byte(c); } /*---------------------------------------------------------------------------*/ -/** - * \brief Initialise the arch-specific SLIP driver - */ void slip_arch_init() { @@ -64,5 +49,3 @@ slip_arch_init() cc26xx_uart_set_input(slip_input_byte); } /*---------------------------------------------------------------------------*/ - -/** @} */ diff --git a/os/lib/dbg-io/dbg.h b/os/lib/dbg-io/dbg.h index 14f06fd31..6440b5eca 100644 --- a/os/lib/dbg-io/dbg.h +++ b/os/lib/dbg-io/dbg.h @@ -28,15 +28,16 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ +/*---------------------------------------------------------------------------*/ /** - * \addtogroup nrf52dk + * \addtogroup lib * @{ * - * \addtogroup nrf52dk-dbg-io Debug IO over UART + * \addtogroup dbg-io Portable debugging output functons * @{ * * \file - * Header file for the debug module. + * Header file for the dbg-io module. * \author * Wojciech Bober * From 87dfa61fd62ab9c0b39b3eb2f812642ff773d6dd Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Fri, 30 Mar 2018 21:06:52 +0100 Subject: [PATCH 14/24] Use dbg.c from the CPU dir and delete platform file --- arch/cpu/nrf52832/dbg.c | 38 +++++++------- arch/platform/nrf52dk/Makefile.nrf52dk | 1 - arch/platform/nrf52dk/dbg-io/dbg.c | 72 -------------------------- 3 files changed, 18 insertions(+), 93 deletions(-) delete mode 100644 arch/platform/nrf52dk/dbg-io/dbg.c diff --git a/arch/cpu/nrf52832/dbg.c b/arch/cpu/nrf52832/dbg.c index c4163ba3d..8f7be5cfc 100644 --- a/arch/cpu/nrf52832/dbg.c +++ b/arch/cpu/nrf52832/dbg.c @@ -37,34 +37,32 @@ * Wojciech Bober * */ -/*---------------------------------------------------------------------------*/ -#include #include "dev/uart0.h" /*---------------------------------------------------------------------------*/ +unsigned int +dbg_send_bytes(const unsigned char *s, unsigned int len) +{ + unsigned int i = 0; + + while (s && *s != 0) { + if (i >= len) { + break; + } + uart0_writeb(*s++); + i++; + } + + return i; +} +/*---------------------------------------------------------------------------*/ int -putchar(int c) +dbg_putchar(int c) { uart0_writeb(c); return c; } /*---------------------------------------------------------------------------*/ -int -puts(const char *str) -{ - int i; - - if (str == NULL) { - return 0; - } - - for (i = 0; i < strlen(str); i++) { - uart0_writeb(str[i]); - } - - uart0_writeb('\n'); - return i; -} -/*---------------------------------------------------------------------------*/ /** + * @} * @} */ diff --git a/arch/platform/nrf52dk/Makefile.nrf52dk b/arch/platform/nrf52dk/Makefile.nrf52dk index f52467afb..6561de980 100644 --- a/arch/platform/nrf52dk/Makefile.nrf52dk +++ b/arch/platform/nrf52dk/Makefile.nrf52dk @@ -13,7 +13,6 @@ ifeq ($(NRF52_USE_RTT),1) CONTIKI_TARGET_DIRS += rtt CONTIKI_SOURCEFILES += rtt-printf.c segger-rtt.c segger-rtt-printf.c else -CONTIKI_TARGET_DIRS += dbg-io CONTIKI_SOURCEFILES += dbg.c MODULES += os/lib/dbg-io endif diff --git a/arch/platform/nrf52dk/dbg-io/dbg.c b/arch/platform/nrf52dk/dbg-io/dbg.c deleted file mode 100644 index db9bb63c0..000000000 --- a/arch/platform/nrf52dk/dbg-io/dbg.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2015, Nordic Semiconductor - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/** - * \addtogroup nrf52dk - * @{ - * - * \addtogroup nrf52dk-dbg-io Debug IO over UART - * @{ - * - * \file - * Function implementations for debug io module. - * \author - * Wojciech Bober - * - */ -#include "dev/uart0.h" -/*---------------------------------------------------------------------------*/ -unsigned int -dbg_send_bytes(const unsigned char *s, unsigned int len) -{ - unsigned int i = 0; - - while (s && *s != 0) { - if (i >= len) { - break; - } - uart0_writeb(*s++); - i++; - } - - return i; -} -/*---------------------------------------------------------------------------*/ -int -dbg_putchar(int c) -{ - uart0_writeb(c); - return c; -} -/*---------------------------------------------------------------------------*/ -/** - * @} - * @} - */ From b2438b4563e9974415238b627c47b34e33835d05 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Fri, 30 Mar 2018 22:20:10 +0100 Subject: [PATCH 15/24] Enable putchar for all arm platforms Instead of having to #undef putchar in every file where we want to use it, we undef it across the board. See the comment in arm-def.h as to why this needs done. --- arch/cpu/arm/arm-def.h | 19 +++++++++++++++++++ arch/cpu/cc2538/dbg.c | 3 --- os/lib/dbg-io/putchar.c | 1 - 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/cpu/arm/arm-def.h b/arch/cpu/arm/arm-def.h index 2cd31604c..92b19048d 100644 --- a/arch/cpu/arm/arm-def.h +++ b/arch/cpu/arm/arm-def.h @@ -60,6 +60,25 @@ typedef uint32_t uip_stats_t; typedef uint32_t rtimer_clock_t; #define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b))) /** @} */ + +/* + * The stdio.h that ships with the arm-gcc toolchain does this: + * + * int _EXFUN(putchar, (int)); + * [...] + * #define putchar(x) putc(x, stdout) + * + * This causes us a lot of trouble: For platforms using this toolchain, every + * time we use putchar we need to first #undef putchar. What we do here is to + * #undef putchar across the board. The resulting code will cause the linker + * to search for a symbol named putchar and this allows us to use the + * implementation under os/lib/dbg-io. + * + * This will fail if stdio.h is included before contiki.h, but it is common + * practice to include contiki.h first + */ +#include +#undef putchar /*---------------------------------------------------------------------------*/ #endif /* ARM_DEF_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc2538/dbg.c b/arch/cpu/cc2538/dbg.c index c39e05af7..7b33bc471 100644 --- a/arch/cpu/cc2538/dbg.c +++ b/arch/cpu/cc2538/dbg.c @@ -48,9 +48,6 @@ #define flush() #endif /*---------------------------------------------------------------------------*/ -#undef putchar -#undef puts - #define SLIP_END 0300 /*---------------------------------------------------------------------------*/ int diff --git a/os/lib/dbg-io/putchar.c b/os/lib/dbg-io/putchar.c index 11bb7b5e6..d5b81e2ab 100644 --- a/os/lib/dbg-io/putchar.c +++ b/os/lib/dbg-io/putchar.c @@ -35,7 +35,6 @@ #include #include /*---------------------------------------------------------------------------*/ -#undef putchar #undef putc /*---------------------------------------------------------------------------*/ int From 148e796ee115fe386381077e244980503c4eeb20 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Fri, 30 Mar 2018 22:21:24 +0100 Subject: [PATCH 16/24] Don't implement putc and __sp Those two functions are not necessary in Contiki-NG --- os/lib/dbg-io/putchar.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/os/lib/dbg-io/putchar.c b/os/lib/dbg-io/putchar.c index d5b81e2ab..26a35446d 100644 --- a/os/lib/dbg-io/putchar.c +++ b/os/lib/dbg-io/putchar.c @@ -35,8 +35,6 @@ #include #include /*---------------------------------------------------------------------------*/ -#undef putc -/*---------------------------------------------------------------------------*/ int putchar(int c) { @@ -44,17 +42,3 @@ putchar(int c) return c; } /*---------------------------------------------------------------------------*/ -int -putc(int c, FILE *f) -{ - dbg_putchar(c); - return c; -} -/*---------------------------------------------------------------------------*/ -int -__sp(struct _reent *_ptr, int c, FILE *_p) -{ - dbg_putchar(c); - return c; -} -/*---------------------------------------------------------------------------*/ From 59e26c8b210215d5dda456dfb597449d59f428d9 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 1 Apr 2018 14:28:08 +0100 Subject: [PATCH 17/24] Add some logging to the GPIO HAL --- os/dev/gpio-hal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/os/dev/gpio-hal.c b/os/dev/gpio-hal.c index 70b50b688..658152293 100644 --- a/os/dev/gpio-hal.c +++ b/os/dev/gpio-hal.c @@ -40,10 +40,15 @@ #include "contiki.h" #include "dev/gpio-hal.h" #include "lib/list.h" +#include "sys/log.h" #include #include /*---------------------------------------------------------------------------*/ +/* Log configuration */ +#define LOG_MODULE "GPIO HAL" +#define LOG_LEVEL LOG_LEVEL_NONE +/*---------------------------------------------------------------------------*/ LIST(handlers); /*---------------------------------------------------------------------------*/ void @@ -78,6 +83,7 @@ void gpio_hal_arch_toggle_pin(gpio_hal_pin_t pin) { if(pin >= GPIO_HAL_PIN_COUNT) { + LOG_ERR("Pin %u out of bounds\n", pin); return; } From 1d59a258edfa9154c5064312cf73f26f9b38e334 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 31 Mar 2018 21:55:31 +0100 Subject: [PATCH 18/24] Remove obsolete typedefs --- arch/platform/native/contiki-conf.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/platform/native/contiki-conf.h b/arch/platform/native/contiki-conf.h index b8a43a604..ea1383660 100644 --- a/arch/platform/native/contiki-conf.h +++ b/arch/platform/native/contiki-conf.h @@ -58,12 +58,6 @@ int select_set_callback(int fd, const struct select_callback *callback); #define EEPROM_CONF_SIZE 1024 #endif -/* These names are deprecated, use C99 names. */ -typedef uint8_t u8_t; -typedef uint16_t u16_t; -typedef uint32_t u32_t; -typedef int32_t s32_t; - typedef unsigned int uip_stats_t; #define LEDS_CONF_LEGACY_API 1 From 84a74907f3983e138c3e0d6efaed645daebbd124 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 1 Apr 2018 14:31:06 +0100 Subject: [PATCH 19/24] Allow the LED HAL to work on platforms without LEDs --- os/dev/leds.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/os/dev/leds.c b/os/dev/leds.c index eff3197a1..f2ce82c29 100644 --- a/os/dev/leds.c +++ b/os/dev/leds.c @@ -97,7 +97,11 @@ leds_toggle(leds_mask_t ledv) /*---------------------------------------------------------------------------*/ #else /* LEDS_LEGACY_API */ /*---------------------------------------------------------------------------*/ +#if LEDS_COUNT extern const leds_t leds_arch_leds[]; +#else +static const leds_t *leds_arch_leds = NULL; +#endif /*---------------------------------------------------------------------------*/ void leds_init() From 5d1ed3c17f8c97bb01f57363e7e442fda7f65f1b Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 1 Apr 2018 16:15:02 +0100 Subject: [PATCH 20/24] Fix CONTIKI_VERSION_STRING Currently, the version string always ends with -dirty. This is related to the logic behind --git-dir, which assumes that the current working dir is the top-level dir of the repo, unless --work-tree is also specified --- Makefile.include | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.include b/Makefile.include index a37c5ad6a..39ec53974 100644 --- a/Makefile.include +++ b/Makefile.include @@ -263,7 +263,8 @@ CFLAGS += ${addprefix -I,$(SOURCEDIRS) $(CONTIKI)} ### Check for a git repo and pass version if found ### git.exe in Windows cmd shells may require no stderr redirection ifndef RELSTR -RELSTR:=${shell git --git-dir ${CONTIKI}/.git describe --tags --always --dirty} +RELSTR:=${shell git --git-dir ${CONTIKI}/.git --work-tree ${CONTIKI} describe \ + --tags --always --dirty} endif ifneq ($(RELSTR),) From a025a9020f4c2acb3d7086b65f914f084dfbdf47 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Fri, 30 Mar 2018 16:16:36 +0100 Subject: [PATCH 21/24] Allow the MQTT client to build & work without platform-specific extensions --- .../arch/platform/cc2538dk/module-macros.h | 34 +++++++++++++++++++ .../platform/openmote-cc2538/module-macros.h | 34 +++++++++++++++++++ .../platform/srf06-cc26xx/module-macros.h | 34 +++++++++++++++++++ .../arch/platform/zoul/module-macros.h | 34 +++++++++++++++++++ examples/mqtt-client/mqtt-client.c | 11 ++++++ 5 files changed, 147 insertions(+) create mode 100644 examples/mqtt-client/arch/platform/cc2538dk/module-macros.h create mode 100644 examples/mqtt-client/arch/platform/openmote-cc2538/module-macros.h create mode 100644 examples/mqtt-client/arch/platform/srf06-cc26xx/module-macros.h create mode 100644 examples/mqtt-client/arch/platform/zoul/module-macros.h diff --git a/examples/mqtt-client/arch/platform/cc2538dk/module-macros.h b/examples/mqtt-client/arch/platform/cc2538dk/module-macros.h new file mode 100644 index 000000000..6f0bce121 --- /dev/null +++ b/examples/mqtt-client/arch/platform/cc2538dk/module-macros.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +/* Enable MQTT client extensions */ +#define MQTT_CLIENT_CONF_WITH_EXTENSIONS 1 +/*---------------------------------------------------------------------------*/ diff --git a/examples/mqtt-client/arch/platform/openmote-cc2538/module-macros.h b/examples/mqtt-client/arch/platform/openmote-cc2538/module-macros.h new file mode 100644 index 000000000..097c26dd8 --- /dev/null +++ b/examples/mqtt-client/arch/platform/openmote-cc2538/module-macros.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +/* Enable MQTT client extensions */ +#define MQTT_CLIENT_CONF_WITH_EXTENSIONS 1 +/*---------------------------------------------------------------------------*/ diff --git a/examples/mqtt-client/arch/platform/srf06-cc26xx/module-macros.h b/examples/mqtt-client/arch/platform/srf06-cc26xx/module-macros.h new file mode 100644 index 000000000..6f0bce121 --- /dev/null +++ b/examples/mqtt-client/arch/platform/srf06-cc26xx/module-macros.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +/* Enable MQTT client extensions */ +#define MQTT_CLIENT_CONF_WITH_EXTENSIONS 1 +/*---------------------------------------------------------------------------*/ diff --git a/examples/mqtt-client/arch/platform/zoul/module-macros.h b/examples/mqtt-client/arch/platform/zoul/module-macros.h new file mode 100644 index 000000000..6f0bce121 --- /dev/null +++ b/examples/mqtt-client/arch/platform/zoul/module-macros.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*---------------------------------------------------------------------------*/ +/* Enable MQTT client extensions */ +#define MQTT_CLIENT_CONF_WITH_EXTENSIONS 1 +/*---------------------------------------------------------------------------*/ diff --git a/examples/mqtt-client/mqtt-client.c b/examples/mqtt-client/mqtt-client.c index 867ef9982..258660459 100644 --- a/examples/mqtt-client/mqtt-client.c +++ b/examples/mqtt-client/mqtt-client.c @@ -71,6 +71,12 @@ static const char *broker_ip = "0064:ff9b:0000:0000:0000:0000:b8ac:7cbd"; #define MQTT_CLIENT_STATUS_LED LEDS_GREEN #endif /*---------------------------------------------------------------------------*/ +#ifdef MQTT_CLIENT_CONF_WITH_EXTENSIONS +#define MQTT_CLIENT_WITH_EXTENSIONS MQTT_CLIENT_CONF_WITH_EXTENSIONS +#else +#define MQTT_CLIENT_WITH_EXTENSIONS 0 +#endif +/*---------------------------------------------------------------------------*/ /* * A timeout used when waiting for something to happen (e.g. to connect or to * disconnect) @@ -197,8 +203,13 @@ static int def_rt_rssi = 0; /*---------------------------------------------------------------------------*/ static mqtt_client_config_t conf; /*---------------------------------------------------------------------------*/ +#if MQTT_CLIENT_WITH_EXTENSIONS extern const mqtt_client_extension_t *mqtt_client_extensions[]; extern const uint8_t mqtt_client_extension_count; +#else +static const mqtt_client_extension_t *mqtt_client_extensions[] = { NULL }; +static const uint8_t mqtt_client_extension_count = 0; +#endif /*---------------------------------------------------------------------------*/ PROCESS(mqtt_client_process, "MQTT Client"); /*---------------------------------------------------------------------------*/ From 4bc9424dd347d73562dcca58ee12c84987c8b898 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Mon, 2 Apr 2018 15:48:48 +0100 Subject: [PATCH 22/24] Ignore .e and .o even if outside obj_ --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f8f72f54b..9f825c9f3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ *.elf *.zip *.d +*.o +*.e *.ihex *.pyc *~ From 7a17d652b56c861d31e3329b349924867a24a2f0 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Mon, 2 Apr 2018 15:50:09 +0100 Subject: [PATCH 23/24] Git ignore the msp430-specific .firmware make target --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9f825c9f3..a67ff3f50 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ COOJA.testlog *.nrf52dk *.openmote-cc2538 *.sky +*.firmware *.srf06-cc26xx *.zoul From 46f73b9a8ae13e62793404cf13a200f71bf1ab17 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Mon, 2 Apr 2018 23:00:52 +0100 Subject: [PATCH 24/24] Remove obsolete Makefile --- os/net/mac/tsch/Makefile.tsch | 1 - 1 file changed, 1 deletion(-) delete mode 100644 os/net/mac/tsch/Makefile.tsch diff --git a/os/net/mac/tsch/Makefile.tsch b/os/net/mac/tsch/Makefile.tsch deleted file mode 100644 index e19ff8b13..000000000 --- a/os/net/mac/tsch/Makefile.tsch +++ /dev/null @@ -1 +0,0 @@ -CONTIKI_SOURCEFILES += tsch.c tsch-slot-operation.c tsch-queue.c tsch-packet.c tsch-schedule.c tsch-log.c tsch-rpl.c tsch-adaptive-timesync.c