aprv2_vm.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2017, 2019 The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __APRV2_VM_H__
  6. #define __APRV2_VM_H__
  7. #define APRV2_VM_MAX_DNS_SIZE (31)
  8. /* Includes NULL character. */
  9. #define APRV2_VM_PKT_SERVICE_ID_MASK (0x00FF)
  10. /* Bitmask of the service ID field. */
  11. /* Packet Structure Definition */
  12. struct aprv2_vm_packet_t {
  13. uint32_t header;
  14. uint16_t src_addr;
  15. uint16_t src_port;
  16. uint16_t dst_addr;
  17. uint16_t dst_port;
  18. uint32_t token;
  19. uint32_t opcode;
  20. };
  21. /**
  22. * In order to send command/event via MM HAB, the following buffer
  23. * format shall be followed, where the buffer is provided to the
  24. * HAB send API.
  25. * |-----cmd_id or evt_id -----| <- 32 bit, e.g. APRV2_VM_CMDID_REGISTER
  26. * |-----cmd payload ----------| e.g. aprv2_vm_cmd_register_t
  27. * | ... |
  28. *
  29. * In order to receive a command response or event ack, the following
  30. * buffer format shall be followed, where the buffer is provided to
  31. * the HAB receive API.
  32. * |-----cmd response ---------| e.g. aprv2_vm_cmd_register_rsp_t
  33. * | ... |
  34. */
  35. /* Registers a service with the backend APR driver. */
  36. #define APRV2_VM_CMDID_REGISTER (0x00000001)
  37. struct aprv2_vm_cmd_register_t {
  38. uint32_t name_size;
  39. /**< The service name string size in bytes. */
  40. char name[APRV2_VM_MAX_DNS_SIZE];
  41. /**<
  42. * The service name string to register.
  43. *
  44. * A NULL name means the service does not have a name.
  45. */
  46. uint16_t addr;
  47. /**<
  48. * The address to register.
  49. *
  50. * A zero value means to auto-generate a free dynamic address.
  51. * A non-zero value means to directly use the statically assigned address.
  52. */
  53. };
  54. struct aprv2_vm_cmd_register_rsp_t {
  55. int32_t status;
  56. /**< The status of registration. */
  57. uint32_t handle;
  58. /**< The registered service handle. */
  59. uint16_t addr;
  60. /**< The actual registered address. */
  61. };
  62. #define APRV2_VM_CMDID_DEREGISTER (0x00000002)
  63. struct aprv2_vm_cmd_deregister_t {
  64. uint32_t handle;
  65. /**< The registered service handle. */
  66. };
  67. struct aprv2_vm_cmd_deregister_rsp_t {
  68. int32_t status;
  69. /**< The status of de-registration. */
  70. };
  71. #define APRV2_VM_CMDID_ASYNC_SEND (0x00000003)
  72. struct aprv2_vm_cmd_async_send_t {
  73. uint32_t handle;
  74. /**< The registered service handle. */
  75. struct aprv2_vm_packet_t pkt_header;
  76. /**< The packet header. */
  77. /* The apr packet payload follows */
  78. };
  79. struct aprv2_vm_cmd_async_send_rsp_t {
  80. int32_t status;
  81. /**< The status of send. */
  82. };
  83. #define APRV2_VM_EVT_RX_PKT_AVAILABLE (0x00000004)
  84. struct aprv2_vm_evt_rx_pkt_available_t {
  85. struct aprv2_vm_packet_t pkt_header;
  86. /**< The packet header. */
  87. /* The apr packet payload follows */
  88. };
  89. struct aprv2_vm_ack_rx_pkt_available_t {
  90. int32_t status;
  91. };
  92. #endif /* __APRV2_VM_H__ */