blob: 7071c76367302edddff6e89c833c8864ffa06a96 [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
15/** Returns the SPMC ID. */
16struct ffa_value plat_ffa_spmc_id_get(void);
Olivier Deprez55a189e2021-06-09 15:45:27 +020017
18void plat_ffa_log_init(void);
19void plat_ffa_init(bool tee_enabled);
20bool plat_ffa_is_direct_request_valid(struct vcpu *current,
21 ffa_vm_id_t sender_vm_id,
22 ffa_vm_id_t receiver_vm_id);
23bool plat_ffa_is_direct_response_valid(struct vcpu *current,
24 ffa_vm_id_t sender_vm_id,
25 ffa_vm_id_t receiver_vm_id);
26bool plat_ffa_direct_request_forward(ffa_vm_id_t receiver_vm_id,
27 struct ffa_value args,
28 struct ffa_value *ret);
J-Alvesa0f317d2021-06-09 13:31:59 +010029bool plat_ffa_is_notifications_create_valid(struct vcpu *current,
30 ffa_vm_id_t vm_id);
J-Alvesc003a7a2021-03-18 13:06:53 +000031
32bool plat_ffa_is_notifications_bind_valid(struct vcpu *current,
33 ffa_vm_id_t sender_id,
34 ffa_vm_id_t receiver_id);
35
Olivier Deprez55a189e2021-06-09 15:45:27 +020036/**
Maksims Svecovs9ddf86a2021-05-06 17:17:21 +010037 * Checks whether managed exit is supported by given SP.
38 */
39bool plat_ffa_vm_managed_exit_supported(struct vm *vm);
40
41/**
Olivier Deprez55a189e2021-06-09 15:45:27 +020042 * Encodes memory handle according to section 5.10.2 of the FF-A v1.0 spec.
43 */
44ffa_memory_handle_t plat_ffa_memory_handle_make(uint64_t index);
45
46/**
47 * Checks whether given handle was allocated by current world, according to
48 * handle encoding rules.
49 */
50bool plat_ffa_memory_handle_allocated_by_current_world(
51 ffa_memory_handle_t handle);
Maksims Svecovsb596eab2021-04-27 00:52:27 +010052
53/**
54 * Return the FF-A partition info VM/SP properties given the VM id.
55 */
56ffa_partition_properties_t plat_ffa_partition_properties(
57 ffa_vm_id_t current_id, const struct vm *target);
J-Alves4ef6e842021-03-18 12:47:01 +000058
59/**
60 * Initializes the NWd VM structures for Notifications support.
61 */
62void plat_ffa_vm_init(void);
J-Alvesa0f317d2021-06-09 13:31:59 +010063
64/**
65 * Get NWd VM's structure.
66 */
67struct vm_locked plat_ffa_vm_find_locked(ffa_vm_id_t vm_id);
68
69/**
70 * Creates a bitmap for the VM of the given ID.
71 */
72struct ffa_value plat_ffa_notifications_bitmap_create(
73 ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count);
74
75/**
76 * Destroys the notifications bitmap for the given VM ID.
77 */
78struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id);
J-Alvesc003a7a2021-03-18 13:06:53 +000079
80/**
81 * Helper to get the struct notifications, depending on the sender's id.
82 */
83struct notifications *plat_ffa_vm_get_notifications_senders_world(
84 struct vm_locked vm_locked, ffa_vm_id_t sender_id);
85
86/**
87 * Helper to check if FF-A ID is a VM ID.
88 */
89bool plat_ffa_is_vm_id(ffa_vm_id_t vm_id);
Raghu Krishnamurthy62f97a72021-07-27 02:14:59 -070090
91/**
92 * Forward normal world calls of FFA_RUN ABI to other world.
93 */
94bool plat_ffa_run_forward(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx,
95 struct ffa_value *ret);