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