J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include "cactus_message_loop.h" |
| 8 | #include "cactus_test_cmds.h" |
| 9 | #include "cactus_tests.h" |
| 10 | #include <debug.h> |
| 11 | #include <ffa_helpers.h> |
| 12 | |
| 13 | CACTUS_CMD_HANDLER(notifications_bind, CACTUS_NOTIFICATION_BIND_CMD) |
| 14 | { |
| 15 | ffa_id_t source = ffa_dir_msg_source(*args); |
| 16 | ffa_id_t vm_id = ffa_dir_msg_dest(*args); |
| 17 | ffa_id_t receiver = cactus_notification_get_receiver(*args); |
| 18 | ffa_id_t sender = cactus_notification_get_sender(*args); |
| 19 | ffa_notification_bitmap_t notifications = |
| 20 | cactus_notification_get_notifications(*args); |
| 21 | uint32_t flags = cactus_notification_get_flags(*args); |
| 22 | smc_ret_values ret; |
| 23 | |
| 24 | VERBOSE("Partition %x requested to bind notifications '%llx' to %x\n", |
| 25 | source, notifications, receiver); |
| 26 | |
| 27 | ret = ffa_notification_bind(sender, receiver, flags, notifications); |
| 28 | |
| 29 | if (is_ffa_call_error(ret)) { |
| 30 | return cactus_error_resp(vm_id, source, ffa_error_code(ret)); |
| 31 | } |
| 32 | |
| 33 | return cactus_response(vm_id, source, CACTUS_SUCCESS); |
| 34 | } |
| 35 | |
| 36 | CACTUS_CMD_HANDLER(notifications_unbind, CACTUS_NOTIFICATION_UNBIND_CMD) |
| 37 | { |
| 38 | ffa_id_t source = ffa_dir_msg_source(*args); |
| 39 | ffa_id_t vm_id = ffa_dir_msg_dest(*args); |
| 40 | ffa_id_t receiver = cactus_notification_get_receiver(*args); |
| 41 | ffa_id_t sender = cactus_notification_get_sender(*args); |
| 42 | ffa_notification_bitmap_t notifications = |
| 43 | cactus_notification_get_notifications(*args); |
| 44 | smc_ret_values ret; |
| 45 | |
| 46 | VERBOSE("Partition %x requested to unbind notifications '%llx' to %x\n", |
| 47 | source, notifications, receiver); |
| 48 | |
| 49 | ret = ffa_notification_unbind(sender, receiver, notifications); |
| 50 | |
| 51 | if (is_ffa_call_error(ret)) { |
| 52 | return cactus_error_resp(vm_id, source, ffa_error_code(ret)); |
| 53 | } |
| 54 | |
| 55 | return cactus_response(vm_id, source, CACTUS_SUCCESS); |
| 56 | } |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame^] | 57 | |
| 58 | CACTUS_CMD_HANDLER(notifications_get, CACTUS_NOTIFICATION_GET_CMD) |
| 59 | { |
| 60 | ffa_id_t source = ffa_dir_msg_source(*args); |
| 61 | ffa_id_t vm_id = ffa_dir_msg_dest(*args); |
| 62 | ffa_id_t notification_receiver = |
| 63 | cactus_notification_get_receiver(*args); |
| 64 | uint32_t flags = cactus_notification_get_flags(*args); |
| 65 | uint32_t vcpu_id = cactus_notification_get_vcpu(*args); |
| 66 | smc_ret_values ret; |
| 67 | |
| 68 | VERBOSE("Partition %x requested to get notifications.\n", source); |
| 69 | |
| 70 | ret = ffa_notification_get(notification_receiver, vcpu_id, flags); |
| 71 | |
| 72 | if (is_ffa_call_error(ret)) { |
| 73 | return cactus_error_resp(vm_id, source, ffa_error_code(ret)); |
| 74 | } |
| 75 | |
| 76 | VERBOSE("Notifications returned:\n" |
| 77 | " from sp: %llx\n" |
| 78 | " from vm: %llx\n", |
| 79 | ffa_notifications_get_from_sp(ret), |
| 80 | ffa_notifications_get_from_vm(ret)); |
| 81 | |
| 82 | return cactus_notifications_get_success_resp( |
| 83 | vm_id, source, ffa_notifications_get_from_sp(ret), |
| 84 | ffa_notifications_get_from_vm(ret)); |
| 85 | } |
| 86 | |
| 87 | CACTUS_CMD_HANDLER(notifications_set, CACTUS_NOTIFICATIONS_SET_CMD) |
| 88 | { |
| 89 | ffa_id_t source = ffa_dir_msg_source(*args); |
| 90 | ffa_id_t vm_id = ffa_dir_msg_dest(*args); |
| 91 | ffa_id_t receiver = cactus_notification_get_receiver(*args); |
| 92 | ffa_id_t sender = cactus_notification_get_sender(*args); |
| 93 | ffa_notification_bitmap_t notifications = cactus_notification_get_notifications(*args); |
| 94 | uint32_t flags = cactus_notification_get_flags(*args); |
| 95 | smc_ret_values ret; |
| 96 | |
| 97 | VERBOSE("Partition %x requested to set notifications.\n", source); |
| 98 | |
| 99 | ret = ffa_notification_set(sender, receiver, flags, notifications); |
| 100 | |
| 101 | if (is_ffa_call_error(ret)) { |
| 102 | return cactus_error_resp(vm_id, source, ffa_error_code(ret)); |
| 103 | } |
| 104 | |
| 105 | return cactus_response(vm_id, source, CACTUS_SUCCESS); |
| 106 | } |