refactor(dlog): move `dlog_flush_buffer` to `api.c`
Move `dlog_flush_vm_buffer` into `api.c` and rename it to
`api_flush_vm_buffer`. `dlog.c` doesn't need to have knowledge of how
VMs' buffer their output.
Change-Id: I21943df2e35288b46575fb28daf5df4b5edd73fe
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/src/api.c b/src/api.c
index e320e6e..0affad1 100644
--- a/src/api.c
+++ b/src/api.c
@@ -4507,6 +4507,16 @@
}
/**
+ * Send the contents of the given VM's log buffer to the log, preceded
+ * by the VM ID and followed by a newline.
+ */
+void api_flush_vm_buffer(ffa_id_t id, char *buffer, size_t length)
+{
+ buffer[length] = '\0';
+ dlog("%s %x: %s\n", ffa_is_vm_id(id) ? "VM" : "SP", id, buffer);
+}
+
+/**
* Implements FF-A v1.2 FFA_CONSOLE_LOG ABI for buffered logging.
*/
struct ffa_value api_ffa_console_log(const struct ffa_value args,
@@ -4582,9 +4592,9 @@
}
if (flush) {
- dlog_flush_vm_buffer(vm_locked.vm->id,
- vm_locked.vm->log_buffer,
- vm_locked.vm->log_buffer_length);
+ api_flush_vm_buffer(vm_locked.vm->id,
+ vm_locked.vm->log_buffer,
+ vm_locked.vm->log_buffer_length);
vm_locked.vm->log_buffer_length = 0;
}
}
diff --git a/src/dlog.c b/src/dlog.c
index 10a7ed2..1b5f2cd 100644
--- a/src/dlog.c
+++ b/src/dlog.c
@@ -226,31 +226,6 @@
}
/**
- * Send the contents of the given VM's log buffer to the log, preceded by the VM
- * ID and followed by a newline.
- */
-void dlog_flush_vm_buffer(ffa_id_t id, char buffer[], size_t length)
-{
- lock();
-
- if (ffa_is_vm_id(id)) {
- print_raw_string("VM ");
- } else {
- print_raw_string("SP ");
- }
- print_num(id, 16, 0, 0);
- print_raw_string(": ");
-
- for (size_t i = 0; i < length; ++i) {
- dlog_putchar(buffer[i]);
- buffer[i] = '\0';
- }
- dlog_putchar('\n');
-
- unlock();
-}
-
-/**
* Same as "dlog", except that arguments are passed as a va_list
*
* Returns number of characters written, or `-1` if format string is invalid.