rpmsg_platform.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2018-2022 NXP
  3. * All rights reserved.
  4. *
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef RPMSG_PLATFORM_H_
  9. #define RPMSG_PLATFORM_H_
  10. #include <stdint.h>
  11. /*
  12. * No need to align the VRING as defined in Linux because LPC55S69 is not intended
  13. * to run the Linux
  14. */
  15. #ifndef VRING_ALIGN
  16. #define VRING_ALIGN (0x10U)
  17. #endif
  18. /* contains pool of descriptors and two circular buffers */
  19. #ifndef VRING_SIZE
  20. /* set VRING_SIZE based on number of used buffers as calculated in vring_init */
  21. #define VRING_DESC_SIZE (((RL_BUFFER_COUNT * sizeof(struct vring_desc)) + VRING_ALIGN - 1UL) & ~(VRING_ALIGN - 1UL))
  22. #define VRING_AVAIL_SIZE \
  23. (((sizeof(struct vring_avail) + (RL_BUFFER_COUNT * sizeof(uint16_t)) + sizeof(uint16_t)) + VRING_ALIGN - 1UL) & \
  24. ~(VRING_ALIGN - 1UL))
  25. #define VRING_USED_SIZE \
  26. (((sizeof(struct vring_used) + (RL_BUFFER_COUNT * sizeof(struct vring_used_elem)) + sizeof(uint16_t)) + \
  27. VRING_ALIGN - 1UL) & \
  28. ~(VRING_ALIGN - 1UL))
  29. #define VRING_SIZE (VRING_DESC_SIZE + VRING_AVAIL_SIZE + VRING_USED_SIZE)
  30. #endif
  31. /* define shared memory space for VRINGS per one channel */
  32. #define RL_VRING_OVERHEAD (2UL * VRING_SIZE)
  33. #define RL_GET_VQ_ID(link_id, queue_id) (((queue_id)&0x1U) | (((link_id) << 1U) & 0xFFFFFFFEU))
  34. #define RL_GET_LINK_ID(id) (((id)&0xFFFFFFFEU) >> 1U)
  35. #define RL_GET_Q_ID(id) ((id)&0x1U)
  36. #define RL_PLATFORM_LPC55S69_M33_M33_LINK_ID (0U)
  37. #define RL_PLATFORM_HIGHEST_LINK_ID (0U)
  38. /* platform interrupt related functions */
  39. int32_t platform_init_interrupt(uint32_t vector_id, void *isr_data);
  40. int32_t platform_deinit_interrupt(uint32_t vector_id);
  41. int32_t platform_interrupt_enable(uint32_t vector_id);
  42. int32_t platform_interrupt_disable(uint32_t vector_id);
  43. int32_t platform_in_isr(void);
  44. void platform_notify(uint32_t vector_id);
  45. /* platform low-level time-delay (busy loop) */
  46. void platform_time_delay(uint32_t num_msec);
  47. /* platform memory functions */
  48. void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags);
  49. void platform_cache_all_flush_invalidate(void);
  50. void platform_cache_disable(void);
  51. uintptr_t platform_vatopa(void *addr);
  52. void *platform_patova(uintptr_t addr);
  53. /* platform init/deinit */
  54. int32_t platform_init(void);
  55. int32_t platform_deinit(void);
  56. #endif /* RPMSG_PLATFORM_H_ */