summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishnu Banavath <vishnu.banavath@arm.com>2019-06-27 11:07:07 +0100
committerTushar Khandelwal <tushar.khandelwal@arm.com>2019-09-04 12:11:13 +0100
commitc41e86af10917b05984f4824b57f21c849ad73c1 (patch)
tree602b1b182c78eb7339221829b1163fb01aaa3000
parente8857c6422660e6955052daa1e721b6e89c6ecce (diff)
add support for external system reset and communication with Host
These changes are to add support to reset External System and sending messages from ES to Host and vice-versa Change-Id: I912f2e8694ac6d8e92e9a1dc912239b7f10eefc6 Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
-rw-r--r--test-app.c98
1 files changed, 97 insertions, 1 deletions
diff --git a/test-app.c b/test-app.c
index 145d51a..92e5453 100644
--- a/test-app.c
+++ b/test-app.c
@@ -29,11 +29,30 @@
enum test_apps
{
INVALID,
+ ES_RESET,
+ ES_MHU,
SE_MHU,
SE_TIMER,
NUM_TEST_APPS
};
+enum es_command
+{
+ ES_NONE,
+ /* Send the value to the PE, the PE will then increment the value
+ and send it back to here (Host) */
+ ES_INC_RETURN,
+ /* Send the value to the ES, the ES will then increment the value
+ and send it to Secure enclave*/
+ ES_INC_SEND_TO_SE,
+ /* Send the value to the ES, make the ES send this
+ * value to the secure enclave, and make the secure enclave increment and echo
+ * the value back to the ES
+ */
+ ES_INC_ECHO_SE,
+ ES_NUM_COMMANDS,
+};
+
/* Macros for executing API commands, which will fail the test if the
command fails. */
#define TRY_OPEN(FD, DEVICE, ...) \
@@ -76,6 +95,8 @@ struct rpmsg_endpoint_info
#define RPMSG_CREATE_EPT_IOCTL _IOW(0xb5, 0x1, struct rpmsg_endpoint_info)
#define RPMSG_DESTROY_EPT_IOCTL _IO(0xb5, 0x2)
+#define EXTSYS_CPU_WAIT_DISABLE 0x0
+
/* MHU test command encoding */
#define BITMASK(x) ((unsigned)-1 >> ((sizeof(int) * CHAR_BIT) - x))
#define CMD_WIDTH 4
@@ -89,11 +110,82 @@ enum se_command
// Send the value to the PE, the PE will then increment the value
// and send it back to here (Host)
SE_INC_RETURN,
- // Start a single-shot timer which will be routed to the boot processor
+ // Start a single-shot timer which will be routed to the boot processor
SE_TIMER_ONCE,
SE_NUM_COMMANDS
};
+/* Desassert the reset signal of the external system#0 harness */
+int es_reset_test()
+{
+ int status;
+ /* Bring external system out of reset */
+ TRY_OPEN(fd_sdk, "/dev/extsys_ctrl", O_RDWR);
+ TRY_IOCTL(status, fd_sdk, EXTSYS_CPU_WAIT_DISABLE, 0);
+ TRY_CLOSE(fd_sdk);
+ return 0;
+}
+
+/* Test MHU connection between HOST <=> ES0 MHU 0 and 1, and SE <=> ES0 MHU 0 and 1 */
+int es_mhu_test()
+{
+ int status;
+ int message;
+ const int value = 0xABCDEF;
+
+ struct rpmsg_endpoint_info es0mhu0_eptinfo = {"es0mhu0", 0XFFFFFFFF, 0xFFFFFFFF};
+ struct rpmsg_endpoint_info es0mhu1_eptinfo = {"es0mhu1", 0XFFFFFFFF, 0xFFFFFFFF};
+
+ TRY_OPEN(fd, "/dev/rpmsg_ctrl0", O_RDWR);
+ /* Create endpoint interfaces for each MHU */
+ TRY_IOCTL(status, fd, RPMSG_CREATE_EPT_IOCTL, &es0mhu0_eptinfo); /* /dev/rpmsg1 is created */
+ TRY_IOCTL(status, fd, RPMSG_CREATE_EPT_IOCTL, &es0mhu1_eptinfo); /* /dev/rpmsg2 is created */
+
+ /* create endpoints for each mhu */
+ TRY_OPEN(fd_es0mhu0_ept, "/dev/rpmsg0", O_RDWR);
+ TRY_OPEN(fd_es0mhu1_ept, "/dev/rpmsg1", O_RDWR);
+ int epts[2];
+ epts[0] = fd_es0mhu0_ept;
+ epts[1] = fd_es0mhu1_ept;
+
+ /* Bring external system out of reset */
+ es_reset_test();
+ /* Await es system boot. Currently there is no signalling mechanism for
+ * this, so revert to sleeping */
+ sleep(1);
+ /* External system test */
+ for (int i = 0; i < 2; i++)
+ {
+ int ept = epts[i];
+ char *name;
+ /* ========== ES < = > HOST TESTS ========== */
+ /* Make ES echo the value back to host with the incremented value */
+ message = ENCODE(ES_INC_RETURN, value);
+ write(ept, &message, sizeof(message));
+ /* External system cannot execute the test command within an interrupt
+ * handler. Since no command buffering has been implemented on the ES, a
+ * sleep allows the ES to process a command before the host transmits
+ * subsequent commands.
+ */
+ sleep(1);
+ /* Read the data transmitted by the previous command */
+ read(ept, &message, sizeof(message));
+ printf("Received %x from %s\n", message,
+ ept == fd_es0mhu0_ept ? "es0mhu0" : "es0mhu1");
+ /* ================== ES < = > SE ================== */
+ /* Make ES send a message to the SE with the incremented value */
+ message = ENCODE(ES_INC_SEND_TO_SE, value);
+ write(ept, &message, sizeof(message));
+ sleep(1);
+ }
+ /* destroy endpoints */
+ TRY_IOCTL(status, fd_es0mhu0_ept, RPMSG_DESTROY_EPT_IOCTL);
+ TRY_IOCTL(status, fd_es0mhu1_ept, RPMSG_DESTROY_EPT_IOCTL);
+ TRY_CLOSE(fd_es0mhu0_ept);
+ TRY_CLOSE(fd_es0mhu1_ept);
+ TRY_CLOSE(fd);
+ return 0;
+}
/* Test MHU connection between HOST <=> BP MHU 1 */
int se_mhu_test()
@@ -170,6 +262,10 @@ int main(int argc, char *argv[])
printf("Invalid test app specified\n");
printf("%d test apps are available\n", NUM_TEST_APPS - 1);
break;
+ case ES_RESET:
+ return es_reset_test();
+ case ES_MHU:
+ return es_mhu_test();
case SE_MHU:
return se_mhu_test();
case SE_TIMER: