_vsprintk(char *buf, char const *fmt, va_list ap) { int ret; _sprintk_ptr = buf; ret = _vprintk(_sputc, fmt, ap); return (ret); }
_printk(char const *fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = _vprintk(putc, fmt, ap); va_end(ap); return (ret); }
void _printk(char const *fmt, ...) { va_list ap; va_start(ap, fmt); _vprintk(putc, fmt, ap); va_end(ap); return; }
_sprintk(char *buf, char const *fmt, ...) { int ret; va_list ap; va_start(ap, fmt); _sprintk_ptr = buf; ret = _vprintk(_sputc, fmt, ap); va_end(ap); return (ret); }
void bt_log(int prio, const char *fmt, ...) { struct bt_monitor_user_logging log; struct bt_monitor_hdr hdr; const char id[] = "bt"; va_list ap; int len; va_start(ap, fmt); len = vsnprintk(NULL, 0, fmt, ap); va_end(ap); if (len < 0) { return; } log.priority = prio; log.ident_len = sizeof(id); if (atomic_test_and_set_bit(&flags, BT_LOG_BUSY)) { drop_add(BT_MONITOR_USER_LOGGING); return; } encode_hdr(&hdr, BT_MONITOR_USER_LOGGING, sizeof(log) + sizeof(id) + len + 1); monitor_send(&hdr, BT_MONITOR_BASE_HDR_LEN + hdr.hdr_len); monitor_send(&log, sizeof(log)); monitor_send(id, sizeof(id)); va_start(ap, fmt); _vprintk(log_out, NULL, fmt, ap); va_end(ap); /* Terminate the string with null */ uart_poll_out(monitor_dev, '\0'); atomic_clear_bit(&flags, BT_LOG_BUSY); }
void bt_log(int prio, const char *fmt, ...) { struct bt_monitor_user_logging log; struct bt_monitor_hdr hdr; const char id[] = "bt"; va_list ap; int len, key; va_start(ap, fmt); len = vsnprintk(NULL, 0, fmt, ap); va_end(ap); if (len < 0) { return; } log.priority = prio; log.ident_len = sizeof(id); encode_hdr(&hdr, BT_MONITOR_USER_LOGGING, sizeof(log) + sizeof(id) + len + 1); key = irq_lock(); monitor_send(&hdr, sizeof(hdr)); monitor_send(&log, sizeof(log)); monitor_send(id, sizeof(id)); va_start(ap, fmt); _vprintk(log_out, NULL, fmt, ap); va_end(ap); /* Terminate the string with null */ uart_poll_out(monitor_dev, '\0'); irq_unlock(key); }