blob: 85487df7e70efb868d15c2b98191ec08a9f4e491 [file] [log] [blame]
Daniel Boulbyb2fb80e2021-02-03 15:09:23 +00001/*
2 * Copyright 2021 The Hafnium Authors.
3 *
4 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/BSD-3-Clause.
7 */
8
9#pragma once
10
11#include "hf/ffa.h"
Olivier Deprez55a189e2021-06-09 15:45:27 +020012#include "hf/vcpu.h"
J-Alvesc003a7a2021-03-18 13:06:53 +000013#include "hf/vm.h"
Daniel Boulbyb2fb80e2021-02-03 15:09:23 +000014
Daniel Boulby87b2dc82021-08-04 14:07:43 +010015/** Returns information on features that are specific to the platform. */
16struct ffa_value plat_ffa_features(uint32_t function_id);
Daniel Boulbyb2fb80e2021-02-03 15:09:23 +000017/** Returns the SPMC ID. */
18struct ffa_value plat_ffa_spmc_id_get(void);
Olivier Deprez55a189e2021-06-09 15:45:27 +020019
20void plat_ffa_log_init(void);
21void plat_ffa_init(bool tee_enabled);
22bool plat_ffa_is_direct_request_valid(struct vcpu *current,
23 ffa_vm_id_t sender_vm_id,
24 ffa_vm_id_t receiver_vm_id);
25bool plat_ffa_is_direct_response_valid(struct vcpu *current,
26 ffa_vm_id_t sender_vm_id,
27 ffa_vm_id_t receiver_vm_id);
28bool plat_ffa_direct_request_forward(ffa_vm_id_t receiver_vm_id,
29 struct ffa_value args,
30 struct ffa_value *ret);
J-Alvesa0f317d2021-06-09 13:31:59 +010031bool plat_ffa_is_notifications_create_valid(struct vcpu *current,
32 ffa_vm_id_t vm_id);
J-Alvesc003a7a2021-03-18 13:06:53 +000033
34bool plat_ffa_is_notifications_bind_valid(struct vcpu *current,
35 ffa_vm_id_t sender_id,
36 ffa_vm_id_t receiver_id);
J-Alvesb15e9402021-09-08 11:44:42 +010037bool plat_ffa_notifications_update_bindings_forward(
38 ffa_vm_id_t receiver_id, ffa_vm_id_t sender_id, uint32_t flags,
39 ffa_notifications_bitmap_t bitmap, bool is_bind, struct ffa_value *ret);
J-Alvesc003a7a2021-03-18 13:06:53 +000040
J-Alvesaa79c012021-07-09 14:29:45 +010041bool plat_ffa_is_notification_set_valid(struct vcpu *current,
42 ffa_vm_id_t sender_id,
43 ffa_vm_id_t receiver_id);
44
45bool plat_ffa_is_notification_get_valid(struct vcpu *current,
46 ffa_vm_id_t receiver_id);
47
J-Alves98ff9562021-09-09 14:39:41 +010048bool plat_ffa_notifications_get_from_sp(struct vm_locked receiver_locked,
49 ffa_vcpu_index_t vcpu_id,
50 ffa_notifications_bitmap_t *from_sp,
51 struct ffa_value *ret);
52
J-Alvesaa79c012021-07-09 14:29:45 +010053bool plat_ffa_notifications_get_call(ffa_vm_id_t receiver_id, uint32_t vcpu_id,
54 uint32_t flags, struct ffa_value *ret);
55
Olivier Deprez55a189e2021-06-09 15:45:27 +020056/**
Maksims Svecovs9ddf86a2021-05-06 17:17:21 +010057 * Checks whether managed exit is supported by given SP.
58 */
59bool plat_ffa_vm_managed_exit_supported(struct vm *vm);
60
61/**
Olivier Deprez55a189e2021-06-09 15:45:27 +020062 * Encodes memory handle according to section 5.10.2 of the FF-A v1.0 spec.
63 */
64ffa_memory_handle_t plat_ffa_memory_handle_make(uint64_t index);
65
66/**
67 * Checks whether given handle was allocated by current world, according to
68 * handle encoding rules.
69 */
70bool plat_ffa_memory_handle_allocated_by_current_world(
71 ffa_memory_handle_t handle);
Maksims Svecovsb596eab2021-04-27 00:52:27 +010072
73/**
74 * Return the FF-A partition info VM/SP properties given the VM id.
75 */
76ffa_partition_properties_t plat_ffa_partition_properties(
77 ffa_vm_id_t current_id, const struct vm *target);
J-Alves4ef6e842021-03-18 12:47:01 +000078
79/**
80 * Initializes the NWd VM structures for Notifications support.
81 */
82void plat_ffa_vm_init(void);
J-Alvesa0f317d2021-06-09 13:31:59 +010083
84/**
85 * Get NWd VM's structure.
86 */
87struct vm_locked plat_ffa_vm_find_locked(ffa_vm_id_t vm_id);
88
89/**
90 * Creates a bitmap for the VM of the given ID.
91 */
92struct ffa_value plat_ffa_notifications_bitmap_create(
93 ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count);
94
95/**
J-Alvesa9c7cba2021-08-25 16:26:11 +010096 * Issues a FFA_NOTIFICATION_BITMAP_CREATE.
97 */
98bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id,
99 ffa_vcpu_count_t vcpu_count,
100 struct ffa_value *ret);
101
102/**
J-Alvesa0f317d2021-06-09 13:31:59 +0100103 * Destroys the notifications bitmap for the given VM ID.
104 */
105struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id);
J-Alvesc003a7a2021-03-18 13:06:53 +0000106
107/**
108 * Helper to get the struct notifications, depending on the sender's id.
109 */
110struct notifications *plat_ffa_vm_get_notifications_senders_world(
111 struct vm_locked vm_locked, ffa_vm_id_t sender_id);
112
113/**
114 * Helper to check if FF-A ID is a VM ID.
115 */
116bool plat_ffa_is_vm_id(ffa_vm_id_t vm_id);
Raghu Krishnamurthy62f97a72021-07-27 02:14:59 -0700117
118/**
119 * Forward normal world calls of FFA_RUN ABI to other world.
120 */
121bool plat_ffa_run_forward(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx,
122 struct ffa_value *ret);
J-Alvesc8e8a222021-06-08 17:33:52 +0100123
124bool plat_ffa_notification_info_get_call(struct ffa_value *ret);
125
126bool plat_ffa_vm_notifications_info_get(uint16_t *ids, uint32_t *ids_count,
127 uint32_t *lists_sizes,
128 uint32_t *lists_count,
129 const uint32_t ids_count_max);