1 /* 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 <stdint.h> 12 13 #include "hf/check.h" 14 15 #include "vmapi/hf/ffa.h" 16 17 #define FFA_VERSION_RESERVED_BIT (UINT32_C(1) << 31) 18 ffa_error(int32_t error_code)19static inline struct ffa_value ffa_error(int32_t error_code) 20 { 21 return (struct ffa_value){.func = FFA_ERROR_32, 22 .arg2 = (uint32_t)error_code}; 23 } 24 25 /** 26 * Return the offset to the first constituent within the 27 * `ffa_composite_memory_region` for the given receiver from an 28 * `ffa_memory_region`. The caller must check that the receiver_index is within 29 * bounds, and that it has a composite memory region offset. 30 */ ffa_composite_constituent_offset(struct ffa_memory_region * memory_region,uint32_t receiver_index)31static inline uint32_t ffa_composite_constituent_offset( 32 struct ffa_memory_region *memory_region, uint32_t receiver_index) 33 { 34 CHECK(receiver_index < memory_region->receiver_count); 35 CHECK(memory_region->receivers[receiver_index] 36 .composite_memory_region_offset != 0); 37 38 return memory_region->receivers[receiver_index] 39 .composite_memory_region_offset + 40 sizeof(struct ffa_composite_memory_region); 41 } 42