1 /* 2 * SPDX-License-Identifier: BSD-3-Clause 3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. 4 */ 5 6 #ifndef DEV_ASSIGN_APP_H 7 #define DEV_ASSIGN_APP_H 8 9 #include <dev_assign_structs.h> 10 11 12 /* 13 * Initialize an instance of device_assignment app. 14 * 15 * Arguments: 16 * app_data - Pointer to app_data_cfg. This is uninitialized and opaque to caller 17 * granule_pas - Array of contiguous granule addresses to be used for the app. 18 * granule_pa_count - Num of elements in `granule_pas` array. 19 * granule_va_start - Start VA address of the `granule_pas` array. 20 * params - Pointer to the dev_assign_params populated by the caller. 21 * 22 * Returns DEV_ASSIGN_STATUS_SUCCESS on success, DEV_ASSIGN_STATUS_ERROR 23 * on error. 24 */ 25 int dev_assign_app_init(struct app_data_cfg *app_data, uintptr_t granule_pas[], 26 size_t granule_pa_count, void *granule_va_start, 27 struct dev_assign_params *params); 28 29 30 /* 31 * Communicate with device and continue the device command as part of 32 * device assignment sequence. 33 * Arguments: 34 * app_data - Pointer to app_data_cfg. This is opaque to caller 35 * comm_enter_args - Entry arguments to app 36 * comm_exit_args - Exit arguments from app 37 * comm_digest_ptr - Pointer to the location where the calculated digest is to 38 * be copied. Should be NULL if no digest is expected. 39 * dev_cmd - Valid device communicate cmds. 40 * 41 * Note that when this function indicates that the app is yeilded 42 * then the only valid dev_cmd is DEVICE_ASSIGN_APP_FUNC_ID_RESUME. 43 * 44 * Returns DEV_ASSIGN_STATUS_SUCCESS if cmd is successful. 45 * DEV_ASSIGN_STATUS_ERROR if cmd is unsuccessful 46 * DEV_ASSIGN_STATUS_COMM_BLOCKED if the app is yielded. 47 */ 48 int dev_assign_dev_communicate(struct app_data_cfg *app_data, 49 struct rmi_dev_comm_enter *comm_enter_args, 50 struct rmi_dev_comm_exit *comm_exit_args, 51 struct dev_obj_digest *comm_digest_ptr, 52 int dev_cmd); 53 54 /* 55 * Aborts the current communication with the device. 56 * Arguments: 57 * app_data - Pointer to app_data_cfg. This is opaque to caller 58 * 59 * This command updates the status field of the struct rmi_dev_comm_enter 60 * is going to be read by spdm_send_message. The value is set to error, and the 61 * app is resumed, which causes the app to abort the operation and return with 62 * error. 63 * 64 * Returns DEV_ASSIGN_STATUS_SUCCESS. 65 */ 66 int dev_assign_abort_app_operation(struct app_data_cfg *app_data); 67 68 /* 69 * Sets public key of the device. 70 * Arguments: 71 * app_data - Pointer to app_data_cfg. This is opaque to caller 72 * pubkey_params - Public key parameters as received from the NS host 73 * 74 * Returns DEV_ASSIGN_STATUS_SUCCESS if setting the public was successful 75 * DEV_ASSIGN_STATUS_ERROR otherwise. 76 */ 77 int dev_assign_set_public_key(struct app_data_cfg *app_data, 78 struct rmi_public_key_params *pubkey_params); 79 80 #endif /* DEV_ASSIGN_APP_H */ 81