android_vendor.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * android_vendor.h - Android vendor data
  4. *
  5. * Copyright 2020 Google LLC
  6. *
  7. * These macros are to be used to reserve space in kernel data structures
  8. * for use by vendor modules.
  9. *
  10. * These macros should be used before the kernel abi is "frozen".
  11. * Fields can be added to various kernel structures that need space
  12. * for functionality implemented in vendor modules. The use of
  13. * these fields is vendor specific.
  14. */
  15. #ifndef _ANDROID_VENDOR_H
  16. #define _ANDROID_VENDOR_H
  17. #include "android_kabi.h"
  18. #define _ANDROID_BACKPORT_RESERVED(n) u64 android_backport_reserved##n
  19. /*
  20. * ANDROID_VENDOR_DATA
  21. * Reserve some "padding" in a structure for potential future use.
  22. * This normally placed at the end of a structure.
  23. * number: the "number" of the padding variable in the structure. Start with
  24. * 1 and go up.
  25. *
  26. * ANDROID_VENDOR_DATA_ARRAY
  27. * Same as ANDROID_VENDOR_DATA but allocates an array of u64 with
  28. * the specified size
  29. *
  30. * ANDROID_BACKPORT_RESERVED
  31. * Reserve some "padding" in a structure for potential future use while
  32. * backporting upstream changes. This normally placed at the end of a
  33. * structure.
  34. * number: the "number" of the padding variable in the structure. Start with
  35. * 1 and go up.
  36. */
  37. #ifdef CONFIG_ANDROID_VENDOR_OEM_DATA
  38. #define ANDROID_VENDOR_DATA(n) u64 android_vendor_data##n
  39. #define ANDROID_VENDOR_DATA_ARRAY(n, s) u64 android_vendor_data##n[s]
  40. #define ANDROID_OEM_DATA(n) u64 android_oem_data##n
  41. #define ANDROID_OEM_DATA_ARRAY(n, s) u64 android_oem_data##n[s]
  42. #define ANDROID_BACKPORT_RESERVED(n) _ANDROID_BACKPORT_RESERVED(n)
  43. #define android_init_vendor_data(p, n) \
  44. memset(&p->android_vendor_data##n, 0, sizeof(p->android_vendor_data##n))
  45. #define android_init_oem_data(p, n) \
  46. memset(&p->android_oem_data##n, 0, sizeof(p->android_oem_data##n))
  47. #else
  48. #define ANDROID_VENDOR_DATA(n)
  49. #define ANDROID_VENDOR_DATA_ARRAY(n, s)
  50. #define ANDROID_OEM_DATA(n)
  51. #define ANDROID_OEM_DATA_ARRAY(n, s)
  52. #define ANDROID_BACKPORT_RESERVED(n)
  53. #define android_init_vendor_data(p, n)
  54. #define android_init_oem_data(p, n)
  55. #endif
  56. /*
  57. * Macros to use _after_ the ABI is frozen
  58. */
  59. /*
  60. * ANDROID_BACKPORT_RESERVED_USE(number, _new)
  61. * Use a previous padding entry that was defined with
  62. * ANDROID_BACKPORT_RESERVED
  63. * number: the previous "number" of the padding variable
  64. * _new: the variable to use now instead of the padding variable
  65. */
  66. #define ANDROID_BACKPORT_RESERVED_USE(number, _new) \
  67. _ANDROID_KABI_REPLACE(_ANDROID_BACKPORT_RESERVED(number), _new)
  68. /*
  69. * ANDROID_BACKPORT_RESERVED_USE2(number, _new1, _new2)
  70. * Use a previous padding entry that was defined with
  71. * ANDROID_BACKPORT_RESERVED for two new variables that fit into 64 bits.
  72. * This is good for when you do not want to "burn" a 64bit padding variable
  73. * for a smaller variable size if not needed.
  74. */
  75. #define ANDROID_BACKPORT_RESERVED_USE2(number, _new1, _new2) \
  76. _ANDROID_KABI_REPLACE(_ANDROID_BACKPORT_RESERVED(number), struct{ _new1; _new2; })
  77. #endif /* _ANDROID_VENDOR_H */