The supported format specifiers are %c, %s, %u/%d and %x.
+config SPL_USE_TINY_PRINTF_POINTER_SUPPORT
+ bool "Extend tiny printf with the pointer formatting %p"
+ depends on SPL_USE_TINY_PRINTF
+ help
+ This option enables the formatting of pointers %p. It supports
+ %p and %pa / %pap. If this option is selected by SPL_NET
+ it also supports the formatting with %pm, %pM and %pI4.
+
config PANIC_HANG
bool "Do not reset the system on fatal error"
help
string(info, ip4_addr);
}
-#endif
+#endif /* CONFIG_SPL_NET */
/*
* Show a '%p' thing. A kernel extension is that the '%p' is followed
* decimal).
*/
-static void __maybe_unused pointer(struct printf_info *info, const char *fmt,
- void *ptr)
+#if defined(CONFIG_SPL_USE_TINY_PRINTF_POINTER_SUPPORT) || defined(DEBUG)
+static void pointer(struct printf_info *info, const char *fmt, void *ptr)
{
-#ifdef DEBUG
unsigned long num = (uintptr_t)ptr;
unsigned long div;
-#endif
switch (*fmt) {
-#ifdef DEBUG
case 'a':
-
switch (fmt[1]) {
case 'p':
default:
break;
}
break;
-#endif
#ifdef CONFIG_SPL_NET
case 'm':
return mac_address_string(info, ptr, false);
case 'I':
if (fmt[1] == '4')
return ip4_addr_string(info, ptr);
+#else
+ case 'm':
+ case 'M':
+ case 'I':
+ out(info, '?');
+ return;
#endif
default:
break;
}
-#ifdef DEBUG
+
div = 1UL << (sizeof(long) * 8 - 4);
for (; div; div /= 0x10)
div_out(info, &num, div);
-#endif
}
+#endif
static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
{
div_out(info, &num, div);
}
break;
+#if defined(CONFIG_SPL_USE_TINY_PRINTF_POINTER_SUPPORT) || defined(DEBUG)
case 'p':
- if (CONFIG_IS_ENABLED(NET) ||
- CONFIG_IS_ENABLED(NET_LWIP) || _DEBUG) {
- pointer(info, fmt, va_arg(va, void *));
- /*
- * Skip this because it pulls in _ctype which is
- * 256 bytes, and we don't generally implement
- * pointer anyway
- */
- while (isalnum(fmt[0]))
- fmt++;
- break;
- }
- islong = true;
- fallthrough;
+ pointer(info, fmt, va_arg(va, void *));
+ /*
+ * Skip this because it pulls in _ctype which is
+ * 256 bytes, and we don't generally implement
+ * pointer anyway
+ */
+ while (isalnum(fmt[0]))
+ fmt++;
+ break;
+#endif
case 'x':
case 'X':
if (islong) {
break;
case '%':
out(info, '%');
+ break;
default:
+ out(info, '?');
break;
}