wlan_platform_modules.bzl 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
  2. load("//build/kernel/kleaf:kernel.bzl", "ddk_module")
  3. load("//msm-kernel:target_variants.bzl", "get_all_variants")
  4. _default_module_enablement_list = [
  5. "cnss_nl",
  6. "cnss_prealloc",
  7. "cnss_utils",
  8. "wlan_firmware_service"
  9. ]
  10. _cnss2_enabled_target = ["niobe", "pineapple", "sun"]
  11. _icnss2_enabled_target = ["blair", "pineapple", "monaco", "pitti"]
  12. def _get_module_list(target, variant):
  13. tv = "{}_{}".format(target, variant)
  14. ret = []
  15. is_wlan_platform_enabled = False
  16. if target in _cnss2_enabled_target:
  17. ret.extend(["cnss2", "cnss_plat_ipc_qmi_svc"])
  18. is_wlan_platform_enabled = True
  19. if target in _icnss2_enabled_target:
  20. ret.extend(["icnss2"])
  21. is_wlan_platform_enabled = True
  22. if is_wlan_platform_enabled:
  23. ret.extend(_default_module_enablement_list)
  24. return [":{}_{}".format(tv, mod) for mod in ret]
  25. def _define_platform_config_rule(module, target, variant):
  26. tv = "{}_{}".format(target, variant)
  27. native.genrule(
  28. name = "{}/{}_defconfig_generate_perf".format(module, tv),
  29. outs = ["{}/{}_defconfig.generated_perf".format(module, tv)],
  30. srcs = [
  31. "{}/{}_gki_defconfig".format(module, target),
  32. ],
  33. cmd = "cat $(SRCS) > $@",
  34. )
  35. native.genrule(
  36. name = "{}/{}_defconfig_generate_gki".format(module, tv),
  37. outs = ["{}/{}_defconfig.generated_gki".format(module, tv)],
  38. srcs = [
  39. "{}/{}_gki_defconfig".format(module, target),
  40. ],
  41. cmd = "cat $(SRCS) > $@",
  42. )
  43. native.genrule(
  44. name = "{}/{}_defconfig_generate_consolidate".format(module, tv),
  45. outs = ["{}/{}_defconfig.generated_consolidate".format(module, tv)],
  46. srcs = [
  47. "{}/{}_consolidate_defconfig".format(module, target),
  48. ],
  49. cmd = "cat $(SRCS) > $@",
  50. )
  51. def _define_modules_for_target_variant(target, variant):
  52. tv = "{}_{}".format(target, variant)
  53. cnss2_enabled = 0
  54. plat_ipc_qmi_svc_enabled = 0
  55. icnss2_enabled = 0
  56. if target in _cnss2_enabled_target:
  57. cnss2_enabled = 1
  58. plat_ipc_qmi_svc_enabled = 1
  59. if target in _icnss2_enabled_target:
  60. icnss2_enabled = 1
  61. print("tv=", tv)
  62. if cnss2_enabled:
  63. module = "cnss2"
  64. _define_platform_config_rule(module, target, variant)
  65. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  66. ddk_module(
  67. name = "{}_cnss2".format(tv),
  68. srcs = native.glob([
  69. "cnss2/main.c",
  70. "cnss2/bus.c",
  71. "cnss2/debug.c",
  72. "cnss2/pci.c",
  73. "cnss2/pci_platform.h",
  74. "cnss2/power.c",
  75. "cnss2/genl.c",
  76. "cnss2/*.h",
  77. "cnss_utils/*.h",
  78. ]),
  79. includes = ["cnss", "cnss_utils"],
  80. kconfig = "cnss2/Kconfig",
  81. defconfig = defconfig,
  82. conditional_srcs = {
  83. "CONFIG_CNSS2_QMI": {
  84. True: [
  85. "cnss2/qmi.c",
  86. "cnss2/coexistence_service_v01.c",
  87. "cnss2/ip_multimedia_subsystem_private_service_v01.c",
  88. ]
  89. },
  90. "CONFIG_PCI_MSM": {
  91. True: [
  92. "cnss2/pci_qcom.c",
  93. ],
  94. },
  95. },
  96. out = "cnss2.ko",
  97. kernel_build = "//msm-kernel:{}".format(tv),
  98. deps = [
  99. "//vendor/qcom/opensource/securemsm-kernel:{}_smcinvoke_dlkm".format(tv),
  100. ":{}_cnss_utils".format(tv),
  101. ":{}_cnss_prealloc".format(tv),
  102. ":{}_wlan_firmware_service".format(tv),
  103. ":{}_cnss_plat_ipc_qmi_svc".format(tv),
  104. "//msm-kernel:all_headers",
  105. ":wlan-platform-headers",
  106. ],
  107. )
  108. if icnss2_enabled:
  109. module = "icnss2"
  110. _define_platform_config_rule(module, target, variant)
  111. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  112. ddk_module(
  113. name = "{}_icnss2".format(tv),
  114. srcs = native.glob([
  115. "icnss2/main.c",
  116. "icnss2/debug.c",
  117. "icnss2/power.c",
  118. "icnss2/genl.c",
  119. "icnss2/*.h",
  120. "cnss_utils/*.h",
  121. ]),
  122. includes = ["icnss2", "cnss_utils"],
  123. kconfig = "icnss2/Kconfig",
  124. copts = ["-Wno-format"],
  125. defconfig = defconfig,
  126. conditional_srcs = {
  127. "CONFIG_ICNSS2_QMI": {
  128. True: [
  129. "icnss2/qmi.c",
  130. ],
  131. },
  132. },
  133. out = "icnss2.ko",
  134. kernel_build = "//msm-kernel:{}".format(tv),
  135. deps = [
  136. ":{}_cnss_utils".format(tv),
  137. ":{}_cnss_prealloc".format(tv),
  138. ":{}_wlan_firmware_service".format(tv),
  139. "//msm-kernel:all_headers",
  140. ":wlan-platform-headers",
  141. ],
  142. )
  143. module = "cnss_genl"
  144. _define_platform_config_rule(module, target, variant)
  145. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  146. ddk_module(
  147. name = "{}_cnss_nl".format(tv),
  148. srcs = [
  149. "cnss_genl/cnss_nl.c",
  150. ],
  151. kconfig = "cnss_genl/Kconfig",
  152. defconfig = defconfig,
  153. out = "cnss_nl.ko",
  154. kernel_build = "//msm-kernel:{}".format(tv),
  155. deps = [
  156. "//msm-kernel:all_headers",
  157. ":wlan-platform-headers",
  158. ],
  159. )
  160. module = "cnss_prealloc"
  161. _define_platform_config_rule(module, target, variant)
  162. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  163. ddk_module(
  164. name = "{}_cnss_prealloc".format(tv),
  165. srcs = native.glob([
  166. "cnss_prealloc/cnss_prealloc.c",
  167. "cnss_utils/*.h",
  168. ]),
  169. includes = ["cnss_utils"],
  170. kconfig = "cnss_prealloc/Kconfig",
  171. defconfig = defconfig,
  172. out = "cnss_prealloc.ko",
  173. kernel_build = "//msm-kernel:{}".format(tv),
  174. deps = [
  175. "//msm-kernel:all_headers",
  176. ":wlan-platform-headers",
  177. ],
  178. )
  179. module = "cnss_utils"
  180. _define_platform_config_rule(module, target, variant)
  181. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  182. ddk_module(
  183. name = "{}_cnss_utils".format(tv),
  184. srcs = native.glob([
  185. "cnss_utils/cnss_utils.c",
  186. "cnss_utils/*.h"
  187. ]),
  188. kconfig = "cnss_utils/Kconfig",
  189. defconfig = defconfig,
  190. out = "cnss_utils.ko",
  191. kernel_build = "//msm-kernel:{}".format(tv),
  192. deps = [
  193. "//msm-kernel:all_headers",
  194. ":wlan-platform-headers",
  195. ],
  196. )
  197. module = "cnss_utils"
  198. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  199. ddk_module(
  200. name = "{}_wlan_firmware_service".format(tv),
  201. srcs = native.glob([
  202. "cnss_utils/wlan_firmware_service_v01.c",
  203. "cnss_utils/device_management_service_v01.c",
  204. "cnss_utils/*.h"
  205. ]),
  206. kconfig = "cnss_utils/Kconfig",
  207. defconfig = defconfig,
  208. out = "wlan_firmware_service.ko",
  209. kernel_build = "//msm-kernel:{}".format(tv),
  210. deps = ["//msm-kernel:all_headers"],
  211. )
  212. module = "cnss_utils"
  213. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  214. if plat_ipc_qmi_svc_enabled:
  215. ddk_module(
  216. name = "{}_cnss_plat_ipc_qmi_svc".format(tv),
  217. srcs = native.glob([
  218. "cnss_utils/cnss_plat_ipc_qmi.c",
  219. "cnss_utils/cnss_plat_ipc_service_v01.c",
  220. "cnss_utils/*.h"
  221. ]),
  222. kconfig = "cnss_utils/Kconfig",
  223. defconfig = defconfig,
  224. out = "cnss_plat_ipc_qmi_svc.ko",
  225. kernel_build = "//msm-kernel:{}".format(tv),
  226. deps = ["//msm-kernel:all_headers"],
  227. )
  228. tv = "{}_{}".format(target, variant)
  229. copy_to_dist_dir(
  230. name = "{}_modules_dist".format(tv),
  231. data = _get_module_list(target, variant),
  232. dist_dir = "out/target/product/{}/dlkm/lib/modules/".format(target),
  233. flat = True,
  234. wipe_dist_dir = False,
  235. allow_duplicate_filenames = False,
  236. mode_overrides = {"**/*": "644"},
  237. log = "info"
  238. )
  239. def define_modules():
  240. for (t, v) in get_all_variants():
  241. print("v=", v)
  242. _define_modules_for_target_variant(t, v)