Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * SPDX-License-Identifier: BSD-3-Clause |
| 3 | * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 4 | */ |
| 5 | #ifndef HOST_HARNESS_H |
| 6 | #define HOST_HARNESS_H |
| 7 | |
| 8 | #include <stdbool.h> |
| 9 | #include <stddef.h> |
| 10 | #include <stdint.h> |
| 11 | #include <types.h> |
| 12 | |
| 13 | /* Forward declaration of buffer_slot */ |
| 14 | enum buffer_slot; |
| 15 | |
| 16 | /* Fake host wrapper to read and write sysregs */ |
| 17 | u_register_t host_read_sysreg(char *reg_name); |
| 18 | void host_write_sysreg(char *reg_name, u_register_t v); |
| 19 | |
| 20 | struct spinlock_s; |
| 21 | /* Fake host harness to lock and release spin lock */ |
| 22 | void host_spinlock_acquire(struct spinlock_s *l); |
| 23 | void host_spinlock_release(struct spinlock_s *l); |
| 24 | |
| 25 | /* |
| 26 | * Fake host Wrapper to copy data from NS into Realm memory. The function |
| 27 | * returns true if the copy succeeds. If the access to the NS memory generates |
| 28 | * a fault, false is returned to the caller. In case of failure |
| 29 | * (when false is returned), partial data may have been written to the |
| 30 | * destination buffer. |
| 31 | * |
| 32 | * Args: |
| 33 | * dest - The address of buffer in Realm memory to write into. |
| 34 | * ns_src - The address of buffer in NS memory to read from. |
| 35 | * size - The number of bytes to copy. |
| 36 | * All arguments must be aligned to 8 bytes. |
| 37 | */ |
| 38 | |
| 39 | bool host_memcpy_ns_read(void *dest, const void *ns_src, unsigned long size); |
| 40 | |
| 41 | /* |
| 42 | * Fake host wrapper to copy data from Realm into NS memory.The function |
| 43 | * returns true if the copy succeeds. If the access to the NS memory generates |
| 44 | * a fault, false is returned to the caller. In case of failure (when false is |
| 45 | * returned), partial data may have been written to the destination buffer. |
| 46 | * |
| 47 | * Args: |
| 48 | * ns_dest - The address of buffer in NS memory to write into. |
| 49 | * src - The address of buffer in Realm memory to read from. |
| 50 | * size - The number of bytes to copy. |
| 51 | * All arguments must be aligned to 8 bytes. |
| 52 | */ |
| 53 | bool host_memcpy_ns_write(void *ns_dest, const void *src, unsigned long size); |
| 54 | |
| 55 | /* |
| 56 | * Fake host wrapper to run a realm. |
| 57 | * Args: |
| 58 | * regs - pointer to GP regs to be restored/save when entering/exiting |
| 59 | * Realm |
| 60 | * Return: Realm exception syndrome return. |
| 61 | */ |
| 62 | int host_run_realm(unsigned long *regs); |
| 63 | |
| 64 | /* |
| 65 | * Fake Host wrapper for monitor_call. |
| 66 | */ |
| 67 | unsigned long host_monitor_call(unsigned long id, unsigned long arg0, |
| 68 | unsigned long arg1, unsigned long arg2, unsigned long arg3, |
| 69 | unsigned long arg4, unsigned long arg5); |
| 70 | |
| 71 | struct smc_result; |
| 72 | /* |
| 73 | * Fake Host wrapper for monitor_call_with_res. |
| 74 | */ |
| 75 | void host_monitor_call_with_res(unsigned long id, unsigned long arg0, |
| 76 | unsigned long arg1, unsigned long arg2, unsigned long arg3, |
| 77 | unsigned long arg4, unsigned long arg5, |
| 78 | struct smc_result *res); |
| 79 | |
| 80 | /* |
| 81 | * Fake host wrapper to map a given PA. |
| 82 | * |
| 83 | * It returns the VA to which the buffer is mapped. |
| 84 | */ |
| 85 | void *host_buffer_arch_map(enum buffer_slot slot, |
| 86 | unsigned long addr, bool ns); |
| 87 | |
| 88 | /* |
| 89 | * Fake host wrapper to unmap a buffer slot correspondig to the VA passed |
| 90 | * in `buf`. |
| 91 | */ |
| 92 | void host_buffer_arch_unmap(void *buf); |
| 93 | |
| 94 | #endif /* HOST_HARNESS_H */ |