示例#1
0
文件: ta_trace.c 项目: gxliu/optee_os
/* To be call from user side */
int _dprintf_uta(const char *function, int line, int level, const char *prefix,
		 const char *fmt, ...)
{
	char to_format[MAX_PRINT_SIZE];
	char formatted[MAX_PRINT_SIZE];
	char trunc[] = "...\n";
	va_list ap;
	int s;

	va_start(ap, fmt);
	s = vsnprintf(to_format, sizeof(to_format), fmt, ap);
	va_end(ap);

	if (s < 0) {
		utee_log(failed, strlen(failed) + 1);
		return s;
	}
	if (((unsigned int)s >= sizeof(to_format)) &&
	    (MAX_PRINT_SIZE > sizeof(trunc)))
		memcpy(&to_format[sizeof(to_format) - sizeof(trunc)], trunc,
		       sizeof(trunc));

	/* Format trace at user side */
	s = format_trace(function, line, level, prefix, to_format, formatted);

	/* sys call */
	utee_log(formatted, strlen(formatted) + 1);

	return s;
}
示例#2
0
int _dprintf_hwsync(const char *function, int line, const char *fmt, ...)
{
	char to_format[MAX_PRINT_SIZE];
	char formatted[MAX_PRINT_SIZE];
	va_list ap;
	int nb;

	va_start(ap, fmt);
	(void)vsnprintf(to_format, sizeof(to_format), fmt, ap);
	va_end(ap);

	nb = format_trace(function, line, TRACE_ALWAYS, "HWSYNC", to_format,
			  formatted);

	/* note: no contention or synchro handle with other CPU core ! */
	output_flush();
	output_string(formatted);
	output_flush();

	return nb;
}
示例#3
0
int _dprintf(const char *function, int line, int level, const char *prefix,
	     const char *fmt, ...)
{
	char to_format[MAX_PRINT_SIZE];
	char formatted[MAX_PRINT_SIZE];
	va_list ap;
	int nb;

	va_start(ap, fmt);
	(void)vsnprintf(to_format, sizeof(to_format), fmt, ap);
	va_end(ap);

	nb = format_trace(function, line, level, prefix, to_format, formatted);

	/*
	 * dprint is making use of the uart.
	 * a shared mem / circular buffer based trace could be used instead
	 */
	output_string(formatted);

	return nb;
}