1 /* 2 * Copyright (c) 2017-2020, NVIDIA Corporation. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef BPMP_IVC_H 8 #define BPMP_IVC_H 9 10 #include <lib/utils_def.h> 11 #include <stdint.h> 12 #include <stddef.h> 13 14 #define IVC_ALIGN U(64) 15 #define IVC_CHHDR_TX_FIELDS U(16) 16 #define IVC_CHHDR_RX_FIELDS U(16) 17 18 struct ivc_channel_header; 19 20 struct ivc { 21 struct ivc_channel_header *rx_channel; 22 struct ivc_channel_header *tx_channel; 23 uint32_t w_pos; 24 uint32_t r_pos; 25 void (*notify)(const struct ivc *); 26 uint32_t nframes; 27 uint32_t frame_size; 28 }; 29 30 /* callback handler for notify on receiving a response */ 31 typedef void (* ivc_notify_function)(const struct ivc *); 32 33 int32_t tegra_ivc_init(struct ivc *ivc, uintptr_t rx_base, uintptr_t tx_base, 34 uint32_t nframes, uint32_t frame_size, 35 ivc_notify_function notify); 36 size_t tegra_ivc_total_queue_size(size_t queue_size); 37 size_t tegra_ivc_align(size_t size); 38 int32_t tegra_ivc_channel_notified(struct ivc *ivc); 39 void tegra_ivc_channel_reset(const struct ivc *ivc); 40 int32_t tegra_ivc_write_advance(struct ivc *ivc); 41 void *tegra_ivc_write_get_next_frame(const struct ivc *ivc); 42 int32_t tegra_ivc_write(struct ivc *ivc, const void *buf, size_t size); 43 int32_t tegra_ivc_read_advance(struct ivc *ivc); 44 void *tegra_ivc_read_get_next_frame(const struct ivc *ivc); 45 int32_t tegra_ivc_read(struct ivc *ivc, void *buf, size_t max_read); 46 bool tegra_ivc_tx_empty(const struct ivc *ivc); 47 bool tegra_ivc_can_write(const struct ivc *ivc); 48 bool tegra_ivc_can_read(const struct ivc *ivc); 49 50 #endif /* BPMP_IVC_H */ 51