| /* |
| * Adapted from Hafnium. |
| * TODO: Figure out the right way of specifying the license header. |
| */ |
| |
| #pragma once |
| |
| #include <libcflat.h> |
| |
| #include "call.h" |
| #include "ffa.h" |
| #include "ffa_mailbox.h" |
| |
| #define memcpy_s(dest, destmax, src, count) memcpy(dest, src, count) |
| |
| #define TEST_ASSERT(a, b, op) \ |
| do { \ |
| if (!((a) op (b))) { \ |
| report_info("%s:%d: Assertion failed: %s %s %s", \ |
| __FILE__, __LINE__, #a, #op, #b); \ |
| dump_stack(); \ |
| assert(0); \ |
| } \ |
| } while (0) |
| |
| #define EXPECT(a) TEST_ASSERT(a, true, ==) |
| #define EXPECT_EQ(a, b) TEST_ASSERT(a, b, ==) |
| #define EXPECT_NE(a, b) TEST_ASSERT(a, b, !=) |
| #define EXPECT_GT(a, b) TEST_ASSERT(a, b, >) |
| #define EXPECT_GE(a, b) TEST_ASSERT(a, b, >=) |
| #define EXPECT_LE(a, b) TEST_ASSERT(a, b, <=) |
| #define ASSERT_LE(a, b) TEST_ASSERT(a, b, <=) |
| #define ASSERT_EQ(a, b) TEST_ASSERT(a, b, ==) |
| #define ASSERT_NE(a, b) TEST_ASSERT(a, b, !=) |
| #define ASSERT_GE(a, b) TEST_ASSERT(a, b, >=) |
| |
| #define EXPECT_FFA_ERROR(value, ffa_error) \ |
| do { \ |
| struct ffa_value v = (value); \ |
| EXPECT_EQ(v.func, FFA_ERROR_32); \ |
| EXPECT_EQ(v.arg2, (ffa_error)); \ |
| } while (0) |
| |
| |
| /* SMCCC reserves ID 0 for the hypervisor itself. */ |
| #define HYPERVISOR_ID 0 |
| |
| /* For now, assume the primary VM has an ID of 1, same as hafnium */ |
| #define PRIMARY_VM_ID 1 |
| |
| #define SERVICE_VM1 (PRIMARY_VM_ID + 1) |
| |
| #define SERVICE_VM2 (PRIMARY_VM_ID + 2) |
| |
| ffa_vm_id_t get_vm_id(void); |
| |
| bool is_primary_vm(void); |