wlan_platform_modules.bzl 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 = ["anorak", "niobe", "pineapple", "sun"]
  11. _icnss2_enabled_target = ["blair", "pineapple", "monaco", "pitti", "volcano"]
  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. deps = [
  67. ":{}_cnss_utils".format(tv),
  68. ":{}_cnss_prealloc".format(tv),
  69. ":{}_wlan_firmware_service".format(tv),
  70. ":{}_cnss_plat_ipc_qmi_svc".format(tv),
  71. "//msm-kernel:all_headers",
  72. ":wlan-platform-headers",
  73. ]
  74. if target != "anorak":
  75. deps.append("//vendor/qcom/opensource/securemsm-kernel:{}_smcinvoke_dlkm".format(tv))
  76. ddk_module(
  77. name = "{}_cnss2".format(tv),
  78. srcs = native.glob([
  79. "cnss2/main.c",
  80. "cnss2/bus.c",
  81. "cnss2/debug.c",
  82. "cnss2/pci.c",
  83. "cnss2/pci_platform.h",
  84. "cnss2/power.c",
  85. "cnss2/genl.c",
  86. "cnss2/*.h",
  87. "cnss_utils/*.h",
  88. ]),
  89. includes = ["cnss", "cnss_utils"],
  90. kconfig = "cnss2/Kconfig",
  91. defconfig = defconfig,
  92. conditional_srcs = {
  93. "CONFIG_CNSS2_QMI": {
  94. True: [
  95. "cnss2/qmi.c",
  96. "cnss2/coexistence_service_v01.c",
  97. ],
  98. },
  99. "CONFIG_PCI_MSM": {
  100. True: [
  101. "cnss2/pci_qcom.c",
  102. ],
  103. },
  104. },
  105. out = "cnss2.ko",
  106. kernel_build = "//msm-kernel:{}".format(tv),
  107. deps = deps,
  108. )
  109. if icnss2_enabled:
  110. module = "icnss2"
  111. _define_platform_config_rule(module, target, variant)
  112. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  113. ddk_module(
  114. name = "{}_icnss2".format(tv),
  115. srcs = native.glob([
  116. "icnss2/main.c",
  117. "icnss2/debug.c",
  118. "icnss2/power.c",
  119. "icnss2/genl.c",
  120. "icnss2/*.h",
  121. "cnss_utils/*.h",
  122. ]),
  123. includes = ["icnss2", "cnss_utils"],
  124. kconfig = "icnss2/Kconfig",
  125. copts = ["-Wno-format"],
  126. defconfig = defconfig,
  127. conditional_srcs = {
  128. "CONFIG_ICNSS2_QMI": {
  129. True: [
  130. "icnss2/qmi.c",
  131. ],
  132. },
  133. },
  134. out = "icnss2.ko",
  135. kernel_build = "//msm-kernel:{}".format(tv),
  136. deps = [
  137. ":{}_cnss_utils".format(tv),
  138. ":{}_cnss_prealloc".format(tv),
  139. ":{}_wlan_firmware_service".format(tv),
  140. "//msm-kernel:all_headers",
  141. ":wlan-platform-headers",
  142. ],
  143. )
  144. module = "cnss_genl"
  145. _define_platform_config_rule(module, target, variant)
  146. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  147. ddk_module(
  148. name = "{}_cnss_nl".format(tv),
  149. srcs = [
  150. "cnss_genl/cnss_nl.c",
  151. ],
  152. kconfig = "cnss_genl/Kconfig",
  153. defconfig = defconfig,
  154. out = "cnss_nl.ko",
  155. kernel_build = "//msm-kernel:{}".format(tv),
  156. deps = [
  157. "//msm-kernel:all_headers",
  158. ":wlan-platform-headers",
  159. ],
  160. )
  161. module = "cnss_prealloc"
  162. _define_platform_config_rule(module, target, variant)
  163. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  164. ddk_module(
  165. name = "{}_cnss_prealloc".format(tv),
  166. srcs = native.glob([
  167. "cnss_prealloc/cnss_prealloc.c",
  168. "cnss_utils/*.h",
  169. ]),
  170. includes = ["cnss_utils"],
  171. kconfig = "cnss_prealloc/Kconfig",
  172. defconfig = defconfig,
  173. out = "cnss_prealloc.ko",
  174. kernel_build = "//msm-kernel:{}".format(tv),
  175. deps = [
  176. "//msm-kernel:all_headers",
  177. ":wlan-platform-headers",
  178. ],
  179. )
  180. module = "cnss_utils"
  181. _define_platform_config_rule(module, target, variant)
  182. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  183. ddk_module(
  184. name = "{}_cnss_utils".format(tv),
  185. srcs = native.glob([
  186. "cnss_utils/cnss_utils.c",
  187. "cnss_utils/*.h",
  188. ]),
  189. kconfig = "cnss_utils/Kconfig",
  190. defconfig = defconfig,
  191. out = "cnss_utils.ko",
  192. kernel_build = "//msm-kernel:{}".format(tv),
  193. deps = [
  194. "//msm-kernel:all_headers",
  195. ":wlan-platform-headers",
  196. ],
  197. )
  198. module = "cnss_utils"
  199. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  200. ddk_module(
  201. name = "{}_wlan_firmware_service".format(tv),
  202. srcs = native.glob([
  203. "cnss_utils/wlan_firmware_service_v01.c",
  204. "cnss_utils/device_management_service_v01.c",
  205. "cnss_utils/ip_multimedia_subsystem_private_service_v01.c",
  206. "cnss_utils/*.h",
  207. ]),
  208. kconfig = "cnss_utils/Kconfig",
  209. defconfig = defconfig,
  210. out = "wlan_firmware_service.ko",
  211. kernel_build = "//msm-kernel:{}".format(tv),
  212. deps = ["//msm-kernel:all_headers"],
  213. )
  214. module = "cnss_utils"
  215. defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
  216. if plat_ipc_qmi_svc_enabled:
  217. ddk_module(
  218. name = "{}_cnss_plat_ipc_qmi_svc".format(tv),
  219. srcs = native.glob([
  220. "cnss_utils/cnss_plat_ipc_qmi.c",
  221. "cnss_utils/cnss_plat_ipc_service_v01.c",
  222. "cnss_utils/*.h",
  223. ]),
  224. kconfig = "cnss_utils/Kconfig",
  225. defconfig = defconfig,
  226. out = "cnss_plat_ipc_qmi_svc.ko",
  227. kernel_build = "//msm-kernel:{}".format(tv),
  228. deps = ["//msm-kernel:all_headers"],
  229. )
  230. tv = "{}_{}".format(target, variant)
  231. copy_to_dist_dir(
  232. name = "{}_modules_dist".format(tv),
  233. data = _get_module_list(target, variant),
  234. dist_dir = "out/target/product/{}/dlkm/lib/modules/".format(target),
  235. flat = True,
  236. wipe_dist_dir = False,
  237. allow_duplicate_filenames = False,
  238. mode_overrides = {"**/*": "644"},
  239. log = "info",
  240. )
  241. def define_modules():
  242. for (t, v) in get_all_variants():
  243. print("v=", v)
  244. _define_modules_for_target_variant(t, v)