diff --git a/sys/external/bsd/drm2/dist/drm/drm_print.c b/sys/external/bsd/drm2/dist/drm/drm_print.c index eddb09acf1d7..49d3250ab258 100644 --- a/sys/external/bsd/drm2/dist/drm/drm_print.c +++ b/sys/external/bsd/drm2/dist/drm/drm_print.c @@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD$"); #include #include #include +#include #else #include @@ -69,6 +70,31 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat module_param_named(debug, __drm_debug, int, 0600); #endif +#ifdef __NetBSD__ +static bool +drm_symstr(vaddr_t val, char *out, size_t outsize) +{ + unsigned long naddr; + const char *mod; + const char *sym; + + if (ksyms_getname(&mod, &sym, val, KSYMS_PROC|KSYMS_CLOSEST) == 0) { + char offset[32]; + + if (ksyms_getval(mod, sym, &naddr, KSYMS_ANY) == 0 && + (val - naddr) != 0) + snprintf(offset, sizeof offset, "+%p", + (void *)(val - naddr)); + else + offset[0] = '\0'; + snprintf(out, outsize, "%s:%s%s", mod, sym, offset); + return true; + } + + return false; +} +#endif + void __drm_puts_coredump(struct drm_printer *p, const char *str) { struct drm_print_iterator *iterator = p->arg; @@ -175,19 +201,34 @@ EXPORT_SYMBOL(__drm_printfn_seq_file); void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf) { +#ifdef __NetBSD__ + dev_info(p->arg, "[" DRM_NAME "] "); + vprintf(vaf->fmt, *vaf->va); /* XXX */ +#else dev_info(p->arg, "[" DRM_NAME "] %pV", vaf); +#endif } EXPORT_SYMBOL(__drm_printfn_info); void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) { +#ifdef __NetBSD__ + pr_debug("%s ", p->prefix); + vprintf(vaf->fmt, *vaf->va); /* XXX */ +#else pr_debug("%s %pV", p->prefix, vaf); +#endif } EXPORT_SYMBOL(__drm_printfn_debug); void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf) { +#ifdef __NetBSD__ + pr_err("*ERROR* %s ", p->prefix); + vprintf(vaf->fmt, *vaf->va); /* XXX */ +#else pr_err("*ERROR* %s %pV", p->prefix, vaf); +#endif } EXPORT_SYMBOL(__drm_printfn_err); @@ -259,10 +300,17 @@ void drm_dev_printk(const struct device *dev, const char *level, { #ifdef __NetBSD__ va_list va; + char symbuf[128]; + + if (!drm_symstr((vaddr_t)__builtin_return_address(0), + symbuf, sizeof symbuf)) + symbuf[0] = '\0'; va_start(va, format); if (dev) - printf("%s: ", device_xname(__UNCONST(dev))); + printf("%s [" DRM_NAME ":%s] ", device_xname(__UNCONST(dev)), symbuf); + else + printf("[" DRM_NAME ":%s] ", symbuf); vprintf(format, va); va_end(va); #else @@ -290,13 +338,20 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, { #ifdef __NetBSD__ va_list va; + char symbuf[128]; if (!(__drm_debug & category)) return; + if (!drm_symstr((vaddr_t)__builtin_return_address(0), + symbuf, sizeof symbuf)) + symbuf[0] = '\0'; + va_start(va, format); if (dev) - printf("%s: ", device_xname(__UNCONST(dev))); + printf("%s [" DRM_NAME ":%s] ", device_xname(__UNCONST(dev)), symbuf); + else + printf("[" DRM_NAME ":%s] ", symbuf); vprintf(format, va); va_end(va); #else @@ -325,11 +380,17 @@ EXPORT_SYMBOL(drm_dev_dbg); void __drm_dbg(enum drm_debug_category category, const char *format, ...) { #ifdef __NetBSD__ + char symbuf[128]; va_list va; if (!(__drm_debug & category)) return; + if (!drm_symstr((vaddr_t)__builtin_return_address(0), + symbuf, sizeof symbuf)) + symbuf[0] = '\0'; + printf("[" DRM_NAME ":%s] ", symbuf); + va_start(va, format); vprintf(format, va); va_end(va); @@ -354,6 +415,19 @@ EXPORT_SYMBOL(__drm_dbg); void __drm_err(const char *format, ...) { +#ifdef __NetBSD__ + char symbuf[128]; + va_list va; + + if (!drm_symstr((vaddr_t)__builtin_return_address(0), + symbuf, sizeof symbuf)) + symbuf[0] = '\0'; + printf("[" DRM_NAME ":%s] *ERROR* ", symbuf); + + va_start(va, format); + vprintf(format, va); + va_end(va); +#else struct va_format vaf; va_list args; @@ -365,6 +439,7 @@ void __drm_err(const char *format, ...) __builtin_return_address(0), &vaf); va_end(args); +#endif } EXPORT_SYMBOL(__drm_err);