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