feat(realm): add host call to flush realm prints
add new host call to push out realm print buffer
buffer is flushed after every print statement
Change-Id: I6efa92a7c75ab7df4615a432802426de39d0032c
Signed-off-by: Shruti Gupta <shruti.gupta@arm.com>
diff --git a/include/runtime_services/host_realm_managment/host_realm_helper.h b/include/runtime_services/host_realm_managment/host_realm_helper.h
index c22bf27..b0a9e59 100644
--- a/include/runtime_services/host_realm_managment/host_realm_helper.h
+++ b/include/runtime_services/host_realm_managment/host_realm_helper.h
@@ -24,5 +24,6 @@
bool host_enter_realm_execute(uint8_t cmd, struct realm **realm_ptr,
int test_exit_reason, unsigned int rec_num);
test_result_t host_cmp_result(void);
+void realm_print_handler(unsigned int rec_num);
#endif /* HOST_REALM_HELPER_H */
diff --git a/include/runtime_services/host_realm_managment/host_shared_data.h b/include/runtime_services/host_realm_managment/host_shared_data.h
index e8dae1d..fbeb257 100644
--- a/include/runtime_services/host_realm_managment/host_shared_data.h
+++ b/include/runtime_services/host_realm_managment/host_shared_data.h
@@ -69,7 +69,8 @@
enum host_call_cmd {
HOST_CALL_GET_SHARED_BUFF_CMD = 1U,
HOST_CALL_EXIT_SUCCESS_CMD,
- HOST_CALL_EXIT_FAILED_CMD
+ HOST_CALL_EXIT_FAILED_CMD,
+ HOST_CALL_EXIT_PRINT_CMD
};
/***************************************
diff --git a/realm/realm_debug.c b/realm/realm_debug.c
index d7989ca..1c4ee03 100644
--- a/realm/realm_debug.c
+++ b/realm/realm_debug.c
@@ -11,6 +11,7 @@
#include <arch_helpers.h>
#include <host_shared_data.h>
+#include <realm_rsi.h>
/*
* A printf formatted function used in the Realm world to log messages
@@ -31,6 +32,7 @@
strnlen((const char *)log_buffer, MAX_BUF_SIZE),
MAX_BUF_SIZE, fmt, args);
va_end(args);
+ rsi_exit_to_host(HOST_CALL_EXIT_PRINT_CMD);
}
void __attribute__((__noreturn__)) do_panic(const char *file, int line)
diff --git a/realm/realm_rsi.c b/realm/realm_rsi.c
index c805514..586d4d2 100644
--- a/realm/realm_rsi.c
+++ b/realm/realm_rsi.c
@@ -42,6 +42,7 @@
void rsi_exit_to_host(enum host_call_cmd exit_code)
{
host_cal.imm = exit_code;
+ host_cal.gprs[0] = read_mpidr_el1() & MPID_MASK;
tftf_smc(&(smc_args) {RSI_HOST_CALL, (u_register_t)&host_cal,
0UL, 0UL, 0UL, 0UL, 0UL, 0UL});
}
diff --git a/tftf/tests/runtime_services/host_realm_managment/host_realm_helper.c b/tftf/tests/runtime_services/host_realm_managment/host_realm_helper.c
index d3b50d3..51b058c 100644
--- a/tftf/tests/runtime_services/host_realm_managment/host_realm_helper.c
+++ b/tftf/tests/runtime_services/host_realm_managment/host_realm_helper.c
@@ -59,7 +59,7 @@
if (str_len != 0UL) {
/* Avoid memory overflow */
log_buffer[MAX_BUF_SIZE - 1] = 0U;
- mp_printf("%s", log_buffer);
+ mp_printf("Rec%u: %s", rec_num, log_buffer);
(void)memset((char *)log_buffer, 0, MAX_BUF_SIZE);
}
}
diff --git a/tftf/tests/runtime_services/host_realm_managment/host_realm_rmi.c b/tftf/tests/runtime_services/host_realm_managment/host_realm_rmi.c
index 8516fab..47713d5 100644
--- a/tftf/tests/runtime_services/host_realm_managment/host_realm_rmi.c
+++ b/tftf/tests/runtime_services/host_realm_managment/host_realm_rmi.c
@@ -1260,6 +1260,10 @@
run->entry.gprs[0] = realm->ipa_ns_buffer;
re_enter_rec = true;
break;
+ case HOST_CALL_EXIT_PRINT_CMD:
+ realm_print_handler(run->exit.gprs[0]);
+ re_enter_rec = true;
+ break;
case HOST_CALL_EXIT_SUCCESS_CMD:
*host_call_result = TEST_RESULT_SUCCESS;
break;