Exemple #1
0
int
serial_printk(const char *fmt, ...)
{
  va_list a;
  va_start(a, fmt);
  char *s=iobuf;
  int rv=vsnprintk(iobuf, IOBUFSIZE, fmt, a);

  if (rv)
    while (*s)
      if (0>serial_putchar(*(s++)))
        break;

  va_end(a);
  return rv;
}
Exemple #2
0
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);
}
Exemple #3
0
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);
}
Exemple #4
0
/* Format trace of user ta. Inline with kernel ta */
void trace_printf(const char *function, int line, int level, bool level_ok,
		  const char *fmt, ...)
{
	va_list ap;
	char buf[MAX_PRINT_SIZE];
	size_t boffs = 0;
	int res;
	int thread_id;

	if (level_ok && level > trace_level)
		return;

	/* Print the type of message */
	res = snprintk(buf, sizeof(buf), "%c/",
		       trace_level_to_string(level, level_ok));
	if (res < 0)
		return;
	boffs += res;

	/* Print the location, i.e., TEE core or TA */
	res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:",
		       trace_ext_prefix);
	if (res < 0)
		return;
	boffs += res;

	/* Print the Thread ID */
	if (level_ok && !(BIT(level) & CFG_MSG_LONG_PREFIX_MASK))
		thread_id = -1;
	else
		thread_id = trace_ext_get_thread_id();

	res = print_thread_id(buf + boffs, sizeof(buf) - boffs, thread_id);

	if (res < 0)
		return;
	boffs += res;

	/* Print the function and line */
	if (level_ok && !(BIT(level) & CFG_MSG_LONG_PREFIX_MASK))
		function = NULL;

	if (function) {
		res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:%d ",
			       function, line);
		if (res < 0)
			return;
		boffs += res;
	}

	va_start(ap, fmt);
	res = vsnprintk(buf + boffs, sizeof(buf) - boffs, fmt, ap);
	va_end(ap);
	if (res > 0)
		boffs += res;

	if (boffs >= (sizeof(buf) - 1))
		boffs = sizeof(buf) - 2;

	buf[boffs] = '\n';
	while (boffs && buf[boffs] == '\n')
		boffs--;
	boffs++;
	buf[boffs + 1] = '\0';

	trace_ext_puts(buf);
}