From eb9bdfaed9b103eb8521f75a1f5d9e6e8cf5bd98 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Mon, 17 Jan 2022 14:32:13 +0100 Subject: [PATCH] ipq807x: add certification support Fixes: WIFI-7055 Signed-off-by: John Crispin --- feeds/ipq807x/ipq807x/modules.mk | 16 + feeds/wifi-ax/ftm/Makefile | 69 + feeds/wifi-ax/ftm/files/compress_vart.sh | 74 + feeds/wifi-ax/ftm/files/ftm.init | 97 + feeds/wifi-ax/ftm/src/Android.mk | 133 + feeds/wifi-ax/ftm/src/LICENSE | 181 + feeds/wifi-ax/ftm/src/Makefile | 12 + feeds/wifi-ax/ftm/src/Makefile.am | 86 + feeds/wifi-ax/ftm/src/NOTICE | 72 + feeds/wifi-ax/ftm/src/configure.ac | 149 + feeds/wifi-ax/ftm/src/ftm_ant.c | 585 ++ feeds/wifi-ax/ftm/src/ftm_ant_common.h | 124 + feeds/wifi-ax/ftm/src/ftm_bt.c | 2013 +++++ feeds/wifi-ax/ftm/src/ftm_bt.h | 289 + feeds/wifi-ax/ftm/src/ftm_bt_common.h | 115 + feeds/wifi-ax/ftm/src/ftm_bt_hci_hal.h | 161 + feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal.h | 177 + feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal_linux.c | 674 ++ feeds/wifi-ax/ftm/src/ftm_bt_persist.cpp | 278 + feeds/wifi-ax/ftm/src/ftm_bt_persist.h | 113 + feeds/wifi-ax/ftm/src/ftm_bt_power_hal.h | 76 + feeds/wifi-ax/ftm/src/ftm_bt_power_pfal.h | 71 + .../wifi-ax/ftm/src/ftm_bt_power_pfal_linux.c | 197 + feeds/wifi-ax/ftm/src/ftm_common.h | 141 + feeds/wifi-ax/ftm/src/ftm_dbg.h | 34 + feeds/wifi-ax/ftm/src/ftm_fm.c | 3804 +++++++++ feeds/wifi-ax/ftm/src/ftm_fm_common.h | 993 +++ feeds/wifi-ax/ftm/src/ftm_fm_pfal.h | 1178 +++ feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux.c | 3668 +++++++++ .../wifi-ax/ftm/src/ftm_fm_pfal_linux_3990.c | 3338 ++++++++ feeds/wifi-ax/ftm/src/ftm_iot.c | 544 ++ feeds/wifi-ax/ftm/src/ftm_iot.h | 131 + feeds/wifi-ax/ftm/src/ftm_main.c | 1033 +++ feeds/wifi-ax/ftm/src/ftm_nfc.c | 108 + feeds/wifi-ax/ftm/src/ftm_nfc.h | 37 + feeds/wifi-ax/ftm/src/ftm_nfcnq.c | 807 ++ feeds/wifi-ax/ftm/src/ftm_nfcnq.h | 168 + feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.c | 664 ++ feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.h | 111 + feeds/wifi-ax/ftm/src/ftm_nfcnq_test.c | 461 ++ feeds/wifi-ax/ftm/src/ftm_nfcnq_test.h | 202 + feeds/wifi-ax/ftm/src/ftm_nfcqti.c | 724 ++ feeds/wifi-ax/ftm/src/ftm_nfcqti.h | 141 + feeds/wifi-ax/ftm/src/ftm_wlan.c | 1110 +++ feeds/wifi-ax/ftm/src/ftm_wlan.h | 221 + feeds/wifi-ax/ftm/src/ftm_wlan_win.h | 194 + feeds/wifi-ax/ftm/src/ftm_write_to_flash.c | 505 ++ feeds/wifi-ax/ftm/src/testcmd.h | 159 + feeds/wifi-ax/ftm/src/wds/Android.mk | 45 + feeds/wifi-ax/ftm/src/wds/wds_hci_pfal.h | 170 + .../wifi-ax/ftm/src/wds/wds_hci_pfal_linux.c | 720 ++ feeds/wifi-ax/ftm/src/wds/wds_main.c | 568 ++ feeds/wifi-ax/libtcmd/Makefile | 54 + feeds/wifi-ax/libtcmd/src/Android.mk | 54 + feeds/wifi-ax/libtcmd/src/Makefile | 24 + feeds/wifi-ax/libtcmd/src/Makefile.am | 23 + feeds/wifi-ax/libtcmd/src/libtcmd.c | 132 + feeds/wifi-ax/libtcmd/src/libtcmd.h | 95 + feeds/wifi-ax/libtcmd/src/nl80211.c | 563 ++ feeds/wifi-ax/libtcmd/src/nl80211_drv.h | 34 + feeds/wifi-ax/libtcmd/src/os.c | 57 + feeds/wifi-ax/libtcmd/src/os.h | 10 + feeds/wifi-ax/qca-diag/Makefile | 76 + feeds/wifi-ax/qca-diag/src/Android.mk | 1 + feeds/wifi-ax/qca-diag/src/Makefile | 44 + feeds/wifi-ax/qca-diag/src/Makefile.am | 11 + .../qca-diag/src/PktRspTest/Android.mk | 28 + .../qca-diag/src/PktRspTest/Makefile.am | 23 + .../qca-diag/src/PktRspTest/PktRspTest.c | 214 + feeds/wifi-ax/qca-diag/src/autogen.sh | 10 + .../qca-diag/src/callback_sample/Android.mk | 29 + .../qca-diag/src/callback_sample/Makefile.am | 27 + .../callback_sample/diag_callback_sample.c | 184 + feeds/wifi-ax/qca-diag/src/configure.ac | 110 + .../qca-diag/src/dci_sample/Android.mk | 29 + .../qca-diag/src/dci_sample/Makefile.am | 28 + .../qca-diag/src/dci_sample/diag_dci_sample.c | 590 ++ feeds/wifi-ax/qca-diag/src/diag.pc.in | 10 + feeds/wifi-ax/qca-diag/src/include/comdef.h | 54 + feeds/wifi-ax/qca-diag/src/include/diag.h | 232 + feeds/wifi-ax/qca-diag/src/include/diag_lsm.h | 553 ++ .../qca-diag/src/include/diag_lsm_dci.h | 212 + feeds/wifi-ax/qca-diag/src/include/diagcmd.h | 679 ++ feeds/wifi-ax/qca-diag/src/include/diagi.h | 96 + feeds/wifi-ax/qca-diag/src/include/diaglogi.h | 203 + feeds/wifi-ax/qca-diag/src/include/diagpkt.h | 759 ++ feeds/wifi-ax/qca-diag/src/include/event.h | 95 + .../wifi-ax/qca-diag/src/include/event_defs.h | 2764 +++++++ feeds/wifi-ax/qca-diag/src/include/log.h | 442 ++ .../wifi-ax/qca-diag/src/include/log_codes.h | 2990 +++++++ feeds/wifi-ax/qca-diag/src/include/msg.h | 1097 +++ .../qca-diag/src/include/msg_arrays_i.h | 55 + .../qca-diag/src/include/msg_pkt_defs.h | 154 + feeds/wifi-ax/qca-diag/src/include/msg_qsr.h | 512 ++ feeds/wifi-ax/qca-diag/src/include/msgcfg.h | 7038 +++++++++++++++++ feeds/wifi-ax/qca-diag/src/include/msgtgt.h | 847 ++ feeds/wifi-ax/qca-diag/src/klog/Android.mk | 28 + feeds/wifi-ax/qca-diag/src/klog/Makefile.am | 23 + feeds/wifi-ax/qca-diag/src/klog/diag_klog.c | 178 + feeds/wifi-ax/qca-diag/src/mdlog/Android.mk | 27 + feeds/wifi-ax/qca-diag/src/mdlog/Makefile.am | 28 + feeds/wifi-ax/qca-diag/src/mdlog/diag_mdlog.c | 893 +++ feeds/wifi-ax/qca-diag/src/qdss_setup.sh | 66 + feeds/wifi-ax/qca-diag/src/qld_server.c | 221 + feeds/wifi-ax/qca-diag/src/registerReboot.c | 1199 +++ .../qca-diag/src/socket_log/Android.mk | 29 + .../qca-diag/src/socket_log/Makefile.am | 27 + .../qca-diag/src/socket_log/diag_socket_log.c | 710 ++ feeds/wifi-ax/qca-diag/src/src/Makefile.am | 63 + feeds/wifi-ax/qca-diag/src/src/diag.mk | 53 + feeds/wifi-ax/qca-diag/src/src/diag_logger.c | 290 + feeds/wifi-ax/qca-diag/src/src/diag_logger.h | 61 + feeds/wifi-ax/qca-diag/src/src/diag_lsm.c | 3248 ++++++++ feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci.c | 703 ++ .../wifi-ax/qca-diag/src/src/diag_lsm_dci_i.h | 239 + .../wifi-ax/qca-diag/src/src/diag_lsm_event.c | 414 + .../qca-diag/src/src/diag_lsm_event_i.h | 38 + feeds/wifi-ax/qca-diag/src/src/diag_lsm_log.c | 844 ++ .../wifi-ax/qca-diag/src/src/diag_lsm_log_i.h | 47 + feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg.c | 959 +++ .../wifi-ax/qca-diag/src/src/diag_lsm_msg_i.h | 61 + feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt.c | 1447 ++++ .../wifi-ax/qca-diag/src/src/diag_lsm_pkt_i.h | 52 + feeds/wifi-ax/qca-diag/src/src/diag_lsmi.h | 101 + .../src/src/diag_qshrink4_db_parser.c | 1264 +++ .../wifi-ax/qca-diag/src/src/diag_shared_i.h | 182 + feeds/wifi-ax/qca-diag/src/src/diagdiag.h | 1273 +++ feeds/wifi-ax/qca-diag/src/src/diaglib.mak | 53 + .../wifi-ax/qca-diag/src/src/diagsvc_malloc.c | 232 + .../wifi-ax/qca-diag/src/src/diagsvc_malloc.h | 117 + feeds/wifi-ax/qca-diag/src/src/eventi.h | 98 + feeds/wifi-ax/qca-diag/src/src/msg_arrays_i.c | 1083 +++ feeds/wifi-ax/qca-diag/src/src/ts_linux.c | 201 + feeds/wifi-ax/qca-diag/src/src/ts_linux.h | 66 + feeds/wifi-ax/qca-diag/src/test/Android.mk | 28 + feeds/wifi-ax/qca-diag/src/test/Makefile.am | 22 + feeds/wifi-ax/qca-diag/src/test/test_diag.c | 551 ++ .../wifi-ax/qca-diag/src/uart_log/Android.mk | 29 + .../wifi-ax/qca-diag/src/uart_log/Makefile.am | 27 + .../qca-diag/src/uart_log/diag_uart_log.c | 394 + 140 files changed, 66652 insertions(+) create mode 100755 feeds/wifi-ax/ftm/Makefile create mode 100755 feeds/wifi-ax/ftm/files/compress_vart.sh create mode 100755 feeds/wifi-ax/ftm/files/ftm.init create mode 100755 feeds/wifi-ax/ftm/src/Android.mk create mode 100755 feeds/wifi-ax/ftm/src/LICENSE create mode 100755 feeds/wifi-ax/ftm/src/Makefile create mode 100755 feeds/wifi-ax/ftm/src/Makefile.am create mode 100755 feeds/wifi-ax/ftm/src/NOTICE create mode 100755 feeds/wifi-ax/ftm/src/configure.ac create mode 100755 feeds/wifi-ax/ftm/src/ftm_ant.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_ant_common.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_common.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_hci_hal.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal_linux.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_persist.cpp create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_persist.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_power_hal.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_power_pfal.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_bt_power_pfal_linux.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_common.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_dbg.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_fm.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_fm_common.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_fm_pfal.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux_3990.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_iot.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_iot.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_main.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfc.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfc.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfcnq.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfcnq.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfcnq_test.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfcnq_test.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfcqti.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_nfcqti.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_wlan.c create mode 100755 feeds/wifi-ax/ftm/src/ftm_wlan.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_wlan_win.h create mode 100755 feeds/wifi-ax/ftm/src/ftm_write_to_flash.c create mode 100755 feeds/wifi-ax/ftm/src/testcmd.h create mode 100755 feeds/wifi-ax/ftm/src/wds/Android.mk create mode 100755 feeds/wifi-ax/ftm/src/wds/wds_hci_pfal.h create mode 100755 feeds/wifi-ax/ftm/src/wds/wds_hci_pfal_linux.c create mode 100755 feeds/wifi-ax/ftm/src/wds/wds_main.c create mode 100755 feeds/wifi-ax/libtcmd/Makefile create mode 100755 feeds/wifi-ax/libtcmd/src/Android.mk create mode 100755 feeds/wifi-ax/libtcmd/src/Makefile create mode 100755 feeds/wifi-ax/libtcmd/src/Makefile.am create mode 100755 feeds/wifi-ax/libtcmd/src/libtcmd.c create mode 100755 feeds/wifi-ax/libtcmd/src/libtcmd.h create mode 100755 feeds/wifi-ax/libtcmd/src/nl80211.c create mode 100755 feeds/wifi-ax/libtcmd/src/nl80211_drv.h create mode 100755 feeds/wifi-ax/libtcmd/src/os.c create mode 100755 feeds/wifi-ax/libtcmd/src/os.h create mode 100755 feeds/wifi-ax/qca-diag/Makefile create mode 100755 feeds/wifi-ax/qca-diag/src/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/Makefile create mode 100755 feeds/wifi-ax/qca-diag/src/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/PktRspTest/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/PktRspTest/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/PktRspTest/PktRspTest.c create mode 100755 feeds/wifi-ax/qca-diag/src/autogen.sh create mode 100755 feeds/wifi-ax/qca-diag/src/callback_sample/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/callback_sample/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/callback_sample/diag_callback_sample.c create mode 100755 feeds/wifi-ax/qca-diag/src/configure.ac create mode 100755 feeds/wifi-ax/qca-diag/src/dci_sample/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/dci_sample/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/dci_sample/diag_dci_sample.c create mode 100755 feeds/wifi-ax/qca-diag/src/diag.pc.in create mode 100755 feeds/wifi-ax/qca-diag/src/include/comdef.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/diag.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/diag_lsm.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/diag_lsm_dci.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/diagcmd.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/diagi.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/diaglogi.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/diagpkt.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/event.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/event_defs.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/log.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/log_codes.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/msg.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/msg_arrays_i.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/msg_pkt_defs.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/msg_qsr.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/msgcfg.h create mode 100755 feeds/wifi-ax/qca-diag/src/include/msgtgt.h create mode 100755 feeds/wifi-ax/qca-diag/src/klog/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/klog/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/klog/diag_klog.c create mode 100755 feeds/wifi-ax/qca-diag/src/mdlog/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/mdlog/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/mdlog/diag_mdlog.c create mode 100755 feeds/wifi-ax/qca-diag/src/qdss_setup.sh create mode 100755 feeds/wifi-ax/qca-diag/src/qld_server.c create mode 100755 feeds/wifi-ax/qca-diag/src/registerReboot.c create mode 100755 feeds/wifi-ax/qca-diag/src/socket_log/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/socket_log/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/socket_log/diag_socket_log.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag.mk create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_logger.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_logger.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci_i.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_event.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_event_i.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_log.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_log_i.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg_i.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt_i.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_lsmi.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_qshrink4_db_parser.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diag_shared_i.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diagdiag.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/diaglib.mak create mode 100755 feeds/wifi-ax/qca-diag/src/src/diagsvc_malloc.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/diagsvc_malloc.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/eventi.h create mode 100755 feeds/wifi-ax/qca-diag/src/src/msg_arrays_i.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/ts_linux.c create mode 100755 feeds/wifi-ax/qca-diag/src/src/ts_linux.h create mode 100755 feeds/wifi-ax/qca-diag/src/test/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/test/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/test/test_diag.c create mode 100755 feeds/wifi-ax/qca-diag/src/uart_log/Android.mk create mode 100755 feeds/wifi-ax/qca-diag/src/uart_log/Makefile.am create mode 100755 feeds/wifi-ax/qca-diag/src/uart_log/diag_uart_log.c diff --git a/feeds/ipq807x/ipq807x/modules.mk b/feeds/ipq807x/ipq807x/modules.mk index 658581085..e62ef94c0 100644 --- a/feeds/ipq807x/ipq807x/modules.mk +++ b/feeds/ipq807x/ipq807x/modules.mk @@ -95,3 +95,19 @@ define KernelPackage/usb-phy-ipq5018/description endef $(eval $(call KernelPackage,usb-phy-ipq5018)) + +define KernelPackage/diag-char + TITLE:=CHAR DIAG + KCONFIG:= CONFIG_DIAG_MHI=y@ge5.4 \ + CONFIG_DIAG_OVER_PCIE=n@ge5.4 \ + CONFIG_DIAGFWD_BRIDGE_CODE=y \ + CONFIG_DIAG_CHAR=m + DEPENDS:=+kmod-lib-crc-ccitt + FILES:=$(LINUX_DIR)/drivers/char/diag/diagchar.ko +endef + +define KernelPackage/diag-char/description + CHAR DIAG +endef + +$(eval $(call KernelPackage,diag-char)) diff --git a/feeds/wifi-ax/ftm/Makefile b/feeds/wifi-ax/ftm/Makefile new file mode 100755 index 000000000..866d874c2 --- /dev/null +++ b/feeds/wifi-ax/ftm/Makefile @@ -0,0 +1,69 @@ +include $(TOPDIR)/rules.mk + +PKG:=ftm +PKG_NAME:=$(PKG) +PKG_RELEASE:=1 +PKG_VERSION:=11.4-csu1 + +#PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG) + +include $(INCLUDE_DIR)/package.mk + +define Package/$(PKG_NAME) + SECTION:=QCA + CATEGORY:=QCA + URL:=http://www.qca.qualcomm.com + MAINTAINER:=Qualcomm Atheros + TITLE:= QCA ftm utils + DEPENDS:= @TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64||TARGET_ipq807x||TARGET_ipq50xx +libnl +libtcmd +qca-diag +librt +FEATURE_QCA_IOT:qca-IOT +FEATURE_QCA_IOT_IPQ50XX_SUPPORT:btdaemon +kmod-diag-char +endef + +define Package/$(PKG_NAME)/description/Default + FTM Package Support for QCA WIFI 11 drivers +endef + +TARGET_CFLAGS += -DCONFIG_FTM_WLAN -DDEBUG -DFTM_DEBUG -DWIN_AP_HOST +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/qca-diag +TARGET_CFLAGS += -MMD -O2 -Wall -g +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include +TARGET_CFLAGS += -fpie +TARGET_LDFLAGS += -ldiag -lnl-3 -lnl-genl-3 -lrt -ltcmd +TARGET_CSRCS := ftm_main.c ftm_wlan.c ftm_write_to_flash.c +TARGET_LDFLAGS += -pie + +ifneq ($(CONFIG_PACKAGE_kmod-ath11k),) + TARGET_CFLAGS+=-DWIN_AP_HOST_OPEN=1 +endif + +ifeq ($(CONFIG_FEATURE_QCA_IOT),y) +TARGET_CFLAGS += -DIPQ_AP_HOST_IOT -DIPQ_AP_HOST_IOT_QCA402X -ggdb3 -DCONFIG_DAEMON_MODE +TARGET_CSRCS += ftm_iot.c +TARGET_LDFLAGS += -lpthread +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/qca-iot +TARGET_LDFLAGS += -ldiag_demo +endif + +ifeq ($(CONFIG_FEATURE_QCA_IOT_IPQ50XX_SUPPORT),y) +TARGET_CFLAGS += -DIPQ_AP_HOST_IOT -DIPQ_AP_HOST_IOT_IPQ50XX -ggdb3 -I$(STAGING_DIR)/usr/include/btdaemon +TARGET_CSRCS += ftm_iot.c +TARGET_LDFLAGS += -lpthread -lbtdaemon +endif + +define Build/Compile +$(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + CSRCS="$(TARGET_CSRCS)" +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ftm $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/ftm.init $(1)/etc/init.d/ftm + $(INSTALL_DIR) $(1)/lib/wifi + $(INSTALL_BIN) ./files/compress_vart.sh $(1)/lib/compress_vart.sh +endef + +$(eval $(call BuildPackage,ftm)) diff --git a/feeds/wifi-ax/ftm/files/compress_vart.sh b/feeds/wifi-ax/ftm/files/compress_vart.sh new file mode 100755 index 000000000..ba9f53f7a --- /dev/null +++ b/feeds/wifi-ax/ftm/files/compress_vart.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# Copyright (c) 2020 Qualcomm Technologies, Inc. +# +# All Rights Reserved. +# Confidential and Proprietary - Qualcomm Technologies, Inc. +# +# + +[ -e /lib/ipq806x.sh ] && . /lib/ipq806x.sh +. /lib/functions.sh + +low_mem_compress_art() +{ + local mtdblock=$(find_mtd_part 0:ART) + + if [ -z "$mtdblock" ]; then + # read from mmc + mtdblock=$(find_mmc_part 0:ART) + fi + + [ -n "$mtdblock" ] || return + + local apmp="/tmp" + + lzma -zvfk -4 ${apmp}/virtual_art.bin 2> /dev/null || { + echo "Error Compressing Virtual ART" > /dev/console + return + } + + dd if=${apmp}/virtual_art.bin.lzma of=${mtdblock} + echo "Success compressing Virtual ART(${mtdblock})" > /dev/console + return +} + +normal_art() +{ + local mtdblock=$(find_mtd_part 0:ART) + + if [ -z "$mtdblock" ]; then + # read from mmc + mtdblock=$(find_mmc_part 0:ART) + fi + + [ -n "$mtdblock" ] || return + + local apmp="/tmp" + + dd if=${apmp}/virtual_art.bin of=${mtdblock} + echo "Success writing to ART(${mtdblock})" > /dev/console + return +} + +write_caldata() +{ + local board + [ -f /tmp/sysinfo/board_name ] && { + board=ap$(cat /tmp/sysinfo/board_name | awk -F 'ap' '{print$2}') + } + + if [ -e /sys/firmware/devicetree/base/compressed_art ] + then + echo "Compressed ART Supported Platform $board " > /dev/console + low_mem_compress_art + else + echo "Non Compressed ART Platform $board " > /dev/console + normal_art + fi +} + +if [ "$1" = "write_caldata" ] +then + write_caldata +fi diff --git a/feeds/wifi-ax/ftm/files/ftm.init b/feeds/wifi-ax/ftm/files/ftm.init new file mode 100755 index 000000000..b526b54dc --- /dev/null +++ b/feeds/wifi-ax/ftm/files/ftm.init @@ -0,0 +1,97 @@ +#!/bin/sh /etc/rc.common +# +# Copyright (c) 2013, 2017, 2020 Qualcomm Technologies, Inc. +# +# All Rights Reserved. +# Confidential and Proprietary - Qualcomm Technologies, Inc. +# +# 2013 Qualcomm Atheros, Inc. +# +# All Rights Reserved. +# Qualcomm Atheros Confidential and Proprietary +# + +. /lib/functions.sh +[ -e /lib/ipq806x.sh ] && . /lib/ipq806x.sh + +START=97 +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 + +MTD_ART_PART_NAME="art" + +compressed_art_read() { + local mtdblock=$(find_mtd_part 0:ART) + + if [ -z "$mtdblock" ]; then + #read from mmc + mtdblock=$(find_mmc_part 0:ART) + fi + + [ -n "$mtdblock" ] || return + + local apmp="/tmp" + + dd if=${mtdblock} of=${apmp}/virtual_art.bin.lzma + lzma -fdv --single-stream ${apmp}/virtual_art.bin.lzma || { + # Create dummy virtual_art.bin file of size 512K + dd if=/dev/zero of=${apmp}/virtual_art.bin bs=1024 count=512 + } + echo "Uncompressed and Copied ART content from ${mtdblock} to /tmp/virtual_art.bin" > /dev/console +} + +raw_art_read() { + local mtdblock=$(find_mtd_part 0:ART) + + if [ -z "$mtdblock" ]; then + #read from mmc + mtdblock=$(find_mmc_part 0:ART) + fi + + [ -n "$mtdblock" ] || return + + local apmp="/tmp" + + dd if=${mtdblock} of=${apmp}/virtual_art.bin + echo "Copy ART caldata from ${mtdblock} to /tmp/virtual_art.bin" > /dev/console +} + +retrieve_caldata() { + local board + [ -f /tmp/sysinfo/board_name ] && { + board=ap$(cat /tmp/sysinfo/board_name | awk -F 'ap' '{print$2}') + } + echo "**** Platform Name: $board *****" > /dev/console + + if [ -e /sys/firmware/devicetree/base/compressed_art ] + then + compressed_art_read + else + raw_art_read + fi +} + +start() { + local emmc_flash="" + local nor_flash="" + + emmc_flash=$(find_mmc_part 0:ART 2> /dev/null) + mtd_name=$(grep -i -w ${MTD_ART_PART_NAME} /proc/mtd | cut -f1 -d:) + nor_flash=`find /sys/bus/spi/devices/*/mtd -name ${mtd_name} 2> /dev/null` + + if [ -n "$emmc_flash" ]; then + [ -L /dev/caldata ] || \ + ln -s $emmc_flash /dev/caldata + elif [ -n "$nor_flash" ]; then + [ -L /dev/caldata ] || \ + ln -s /dev/${mtd_name//mtd/mtdblock} /dev/caldata + elif [ -n "$mtd_name" ]; then + [ -L /dev/caldata ] || \ + ln -s /dev/${mtd_name//mtd/mtdblock} /dev/caldata + fi + retrieve_caldata +} + +stop() { + [ -L /dev/caldata ] && rm /dev/caldata +} diff --git a/feeds/wifi-ax/ftm/src/Android.mk b/feeds/wifi-ax/ftm/src/Android.mk new file mode 100755 index 000000000..6d1349939 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/Android.mk @@ -0,0 +1,133 @@ +ifeq ($(call is-vendor-board-platform,QCOM),true) + +# Build only if board has BT/FM/WLAN +ifeq ($(findstring true, $(BOARD_HAVE_QCOM_FM) $(BOARD_HAVE_BLUETOOTH) $(BOARD_HAS_ATH_WLAN_AR6320)),true) + +LOCAL_PATH:= $(call my-dir) + +BDROID_DIR:= system/bt +ifeq ($(TARGET_SUPPORTS_WEARABLES),true) +QTI_DIR := hardware/qcom/bt/msm8909/libbt-vendor +else +QTI_DIR := hardware/qcom/bt/libbt-vendor +endif + + +include $(CLEAR_VARS) + +LOCAL_C_INCLUDES := $(TARGET_OUT_HEADERS)/diag/include \ +LOCAL_C_INCLUDES += vendor/qcom/proprietary/diag/src \ +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc \ +LOCAL_C_INCLUDES += vendor/qcom/proprietary/bt/hci_qcomm_init \ +LOCAL_C_INCLUDES += vendor/qcom/opensource/fm/helium \ +LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \ +LOCAL_C_INCLUDES += $(BDROID_DIR)/hci/include \ +LOCAL_C_INCLUDES += $(QTI_DIR)/include +ifeq ($(TARGET_SUPPORTS_WEARABLES),true) +LOCAL_C_INCLUDES += device/qcom/msm8909w/opensource/bluetooth/tools/hidl_client/inc +else +LOCAL_C_INCLUDES += vendor/qcom/opensource/bluetooth/tools/hidl_client/inc +endif + +LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr + +LOCAL_CFLAGS:= \ + -DANDROID \ + -DDEBUG + +#LOCAL_CFLAGS += -include bionic/libc/include/sys/socket.h +#LOCAL_CFLAGS += -include bionic/libc/include/netinet/in.h + +ifneq ($(DISABLE_BT_FTM),true) +LOCAL_CFLAGS += -DCONFIG_FTM_BT +endif + +ifeq ($(BOARD_HAVE_QCOM_FM),true) +LOCAL_CFLAGS += -DCONFIG_FTM_FM +endif + +ifeq ($(BOARD_HAS_QCA_FM_SOC), "cherokee") +LOCAL_CFLAGS += -DFM_SOC_TYPE_CHEROKEE +endif + +ifneq ($(BOARD_ANT_WIRELESS_DEVICE), ) +LOCAL_CFLAGS += -DCONFIG_FTM_ANT +endif +LOCAL_CFLAGS += -DCONFIG_FTM_NFC + +ifeq ($(BOARD_HAVE_BLUETOOTH_BLUEZ), true) + LOCAL_CFLAGS += -DHAS_BLUEZ_BUILDCFG +endif # BOARD_HAVE_BLUETOOTH_BLUEZ + +LOCAL_SRC_FILES:= \ + ftm_main.c \ + ftm_nfc.c \ + ftm_nfcnq.c \ + ftm_nfcqti.c \ + ftm_nfcnq_fwdl.c \ + ftm_nfcnq_test.c + +ifneq ($(DISABLE_BT_FTM),true) +LOCAL_SRC_FILES += \ + ftm_bt.c \ + ftm_bt_power_pfal_linux.c \ + ftm_bt_hci_pfal_linux.c \ + ftm_bt_persist.cpp +endif + +ifeq ($(call is-platform-sdk-version-at-least,23),true) +LOCAL_CFLAGS += -DANDROID_M +endif + +ifeq ($(BOARD_HAVE_QCOM_FM),true) +ifeq ($(BOARD_HAS_QCA_FM_SOC), "cherokee") +LOCAL_SRC_FILES += ftm_fm.c ftm_fm_pfal_linux_3990.c +else +LOCAL_SRC_FILES += ftm_fm.c ftm_fm_pfal_linux.c +endif +endif + +ifneq ($(BOARD_ANT_WIRELESS_DEVICE), ) +LOCAL_SRC_FILES += ftm_ant.c +endif + +ifeq ($(findstring true, $(BOARD_HAS_ATH_WLAN) $(BOARD_HAS_ATH_WLAN_AR6320)),true) +LOCAL_CFLAGS += -DBOARD_HAS_ATH_WLAN_AR6320 +LOCAL_CFLAGS += -DCONFIG_FTM_WLAN +LOCAL_CFLAGS += -DCONFIG_FTM_WLAN_AUTOLOAD +LOCAL_STATIC_LIBRARIES += libtcmd +LOCAL_SHARED_LIBRARIES += libnl +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libtcmd +LOCAL_SRC_FILES += ftm_wlan.c +endif + +LOCAL_SHARED_LIBRARIES += libdl + +ifneq ($(DISABLE_BT_FTM),true) +LOCAL_SHARED_LIBRARIES += libbt-hidlclient +endif + +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +LOCAL_MODULE:= ftmdaemon +LOCAL_CLANG := true +ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true) +LOCAL_PROPRIETARY_MODULE := true +endif +LOCAL_MODULE_TAGS := optional +LOCAL_SHARED_LIBRARIES += libdiag +LOCAL_SHARED_LIBRARIES += libcutils liblog libhardware + +ifneq ($(DISABLE_BT_FTM),true) +LOCAL_SHARED_LIBRARIES += libbtnv +endif + +# By default NV persist gets used +LOCAL_CFLAGS += -DBT_NV_SUPPORT + +LDFLAGS += -ldl + +include $(BUILD_EXECUTABLE) +include $(call all-makefiles-under,$(LOCAL_PATH)) + +endif # filter +endif # is-vendor-board-platform diff --git a/feeds/wifi-ax/ftm/src/LICENSE b/feeds/wifi-ax/ftm/src/LICENSE new file mode 100755 index 000000000..53f3da5eb --- /dev/null +++ b/feeds/wifi-ax/ftm/src/LICENSE @@ -0,0 +1,181 @@ +This text file is provided to comply with the attribution requirements of +the licenses herein, but see NOTICE for license terms of this software. +The Apache 2.0 license can be found at +http://www.apache.org/licenses/LICENSE-2.0.html + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/feeds/wifi-ax/ftm/src/Makefile b/feeds/wifi-ax/ftm/src/Makefile new file mode 100755 index 000000000..54e2ec30b --- /dev/null +++ b/feeds/wifi-ax/ftm/src/Makefile @@ -0,0 +1,12 @@ +#CC := $(ATH_CROSS_COMPILE_TYPE)gcc +TARGET_TYPE ?= AR9888 +TARGET_VERS ?= v2 + +#Sources to compile +CSRCS := ftm_main.c ftm_wlan.c ftm_write_to_flash.c + +all: + $(CC) $(CFLAGS) $(LDFLAGS) -g3 -Wall \ + $(CSRCS) -o ftm +clean: + rm -f ftm diff --git a/feeds/wifi-ax/ftm/src/Makefile.am b/feeds/wifi-ax/ftm/src/Makefile.am new file mode 100755 index 000000000..6a100c571 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/Makefile.am @@ -0,0 +1,86 @@ +AM_CFLAGS = -Wall \ + -g -O0 \ + $(DIAG_CFLAGS) + +AM_CPPFLAGS = -Wall \ + -g -O0 \ + $(DIAG_CFLAGS) + +AM_CFLAGS += -I${WORKSPACE}/system/bt/hci/include +AM_CFLAGS += -I${WORKSPACE}/vendor/qcom/proprietary/bt/hci_qcomm_init/ + +AM_CPPFLAGS += -I${WORKSPACE}/system/bt/hci/include +AM_CPPFLAGS += -I${WORKSPACE}/vendor/qcom/proprietary/bt/hci_qcomm_init/ + +if DEBUG +AM_CFLAGS += -DDEBUG +AM_CPPFLAGS += -DDEBUG +endif + +requiredlibs = -lrt $(DIAG_LIBS) + +if USE_GLIB +AM_CFLAGS += -DUSE_GLIB $(GLIB_CFLAGS) +AM_CPPFLAGS += -DUSE_GLIB $(GLIB_CFLAGS) +requiredlibs += $(GLIB_LIBS) +endif + +#By default build for MDM_LE +AM_CFLAGS += -DMDM_LE +AM_CPPFLAGS += -DMDM_LE + +if MDM_ROME +AM_CFLAGS += -DBT_SOC_TYPE_ROME +AM_CPPFLAGS += -DBT_SOC_TYPE_ROME +else +if MDM_PRONTO +AM_CFLAGS += -DHCI_USE_MCT +AM_CPPFLAGS += -DHCI_USE_MCT +endif +endif + +c_sources = ftm_main.c + +if CONFIG_FTM_BT +AM_CFLAGS += -DCONFIG_FTM_BT -DBT_NV_SUPPORT +AM_CPPFLAGS += -DCONFIG_FTM_BT -DBT_NV_SUPPORT +c_sources += ftm_bt.c +c_sources += ftm_bt_power_pfal_linux.c +c_sources += ftm_bt_hci_pfal_linux.c +c_sources += ftm_bt_persist.cpp +endif + +if CONFIG_FTM_FM +AM_CFLAGS += -DCONFIG_FTM_FM +c_sources += ftm_fm.c +c_sources += ftm_fm_pfal_linux.c +endif + +if CONFIG_FTM_ANT +AM_CFLAGS += -DCONFIG_FTM_ANT +c_sources += ftm_ant.c +endif + +if CONFIG_FTM_NFC +AM_CFLAGS += -DCONFIG_FTM_NFC +c_sources += ftm_nfc.c +c_sources += ftm_nfcnq.c +c_sources += ftm_nfcqti.c +c_sources += ftm_nfcnq_fwdl.c +c_sources += ftm_nfcnq_test.c +endif + +if CONFIG_FTM_WLAN + +AM_CFLAGS += -DCONFIG_FTM_WLAN -DCONFIG_FTM_WLAN_AUTOLOAD +AM_CFLAGS += $(LIBNL_CFLAGS) $(ATH6KL_UTILS_CFLAGS) +AM_CPPFLAGS += $(LIBNL_CFLAGS) $(ATH6KL_UTILS_CFLAGS) + +requiredlibs += $(ATH6KL_UTILS_LIBS) $(LIBNL_LIBS) + +c_sources += ftm_wlan.c +endif + +ftmdaemon_SOURCES = $(c_sources) +ftmdaemon_LDADD = -ldl $(requiredlibs) -lbtnv +bin_PROGRAMS = ftmdaemon diff --git a/feeds/wifi-ax/ftm/src/NOTICE b/feeds/wifi-ax/ftm/src/NOTICE new file mode 100755 index 000000000..a74fbfab1 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/NOTICE @@ -0,0 +1,72 @@ +This NOTICE file contains certain notices of software components included +with the software that Qualcomm Technologies, Inc. ("Qualcomm Technologies") +is required to provide you. Notwithstanding anything in the notices in this +file, your use of these software components together with the +Qualcomm Technologies software (Qualcomm Technologies software hereinafter +referred to as "Software") is subject to the terms of your license from +Qualcomm Technologies. Compliance with all copyright laws and software +license agreements included in the notice section of this file are the +responsibility of the user. Except as may be granted by separate express +written agreement, this file provides no license to any patents, +trademarks, copyrights, or other intellectual property. + +Copyright (c) 2016 Qualcomm Technologies, Inc. +All rights reserved. +Qualcomm is a registered trademark and registered service mark of +QUALCOMM Incorporated. All other trademarks and service marks are the +property of their respective owners. +________________________________________ +NOTICES +________________________________________ + +Copyright (C) 2010 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +________________________________________ + +Copyright (C) 2015 NXP Semiconductors +The original Work has been changed by NXP Semiconductors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +________________________________________ + +Copyright (C) 2015 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +________________________________________ + +Note: Any files for which the above Apache License notices are required +to be provided are not contributions. + +A copy of the Apache 2.0 license is included in the file LICENSE +for attribution purposes only. diff --git a/feeds/wifi-ax/ftm/src/configure.ac b/feeds/wifi-ax/ftm/src/configure.ac new file mode 100755 index 000000000..9dc5973f3 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/configure.ac @@ -0,0 +1,149 @@ +# -*- Autoconf -*- + +# configure.ac -- Autoconf script for ftm. +# + +# Process this file with autoconf to produce a configure script + +# Requires autoconf tool later than 2.61 +AC_PREREQ(2.61) +# Initialize the ftm package version 1.0.0 +AC_INIT([ftm],1.0.0) +# Does not strictly follow GNU Coding standards +AM_INIT_AUTOMAKE([foreign]) +# Disables auto rebuilding of configure, Makefile.ins +AM_MAINTAINER_MODE +# defines some macros variable to be included by source +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AM_PROG_CC_C_O +AC_PROG_LIBTOOL +AC_PROG_AWK +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET + +# Checks for libraries. +PKG_CHECK_MODULES([DIAG], [diag]) +AC_SUBST([DIAG_CFLAGS]) +AC_SUBST([DIAG_LIBS]) + +has_libnl_ver=0 +# libnl-2 provides only libnl-2.0.pc file, so we check for separate libnl-genl-3.0.pc +# pkg-config file just for libnl-3.0 case. +# +PKG_CHECK_MODULES([LIBNL], [libnl-3.0 >= 3.0 libnl-genl-3.0 >= 3.0], [has_libnl_ver=3], [ + PKG_CHECK_MODULES([LIBNL], [libnl-2.0 >= 2.0], [has_libnl_ver=2], [ + PKG_CHECK_MODULES([LIBNL], [libnl-1], [has_libnl_ver=1], [has_libnl_ver=0])])]) + +if (test "$has_libnl_ver" -eq 0); then + AC_MSG_ERROR(libnl and libnl-genl are required but were not found) +fi + +if (test "$has_libnl_ver" -gt 1); then + AC_DEFINE([HAVE_LIBNL20], [1], [Define if you have libnl-2.0 or higher]) +fi + +AC_SUBST([LIBNL_CFLAGS]) +AC_SUBST([LIBNL_LIBS]) + +PKG_CHECK_MODULES([ATH6KL_UTILS], [ath6kl-utils]) +AC_SUBST([ATH6KL_UTILS_CFLAGS]) +AC_SUBST([ATH6KL_UTILS_LIBS]) + +AC_ARG_WITH([glib], + AC_HELP_STRING([--with-glib], + [enable glib, building FTM Daemon which use glib])) + +if (test "x${with_glib}" = "xyes"); then + PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes, + AC_MSG_ERROR(GThread >= 2.16 is required)) + PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes, + AC_MSG_ERROR(GLib >= 2.16 is required)) + GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS" + GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS" + + AC_SUBST(GLIB_CFLAGS) + AC_SUBST(GLIB_LIBS) +fi +AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") + +AC_ARG_ENABLE([debug], + [ --enable-debug Turn on debugging], + [case "${enableval}" in + yes) debug=true ;; + no) debug=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; + esac],[debug=false]) + +AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) + +AC_ARG_ENABLE([all], + [ --enable-all Enable all FTM functionality], + [case "${enableval}" in + yes) all=true ;; + no) all=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-all]) ;; + esac],[all=false]) + +AM_CONDITIONAL([CONFIG_FTM_BT], [test x$all = xtrue]) +AM_CONDITIONAL([CONFIG_FTM_FM], [test x$all = xtrue]) +AM_CONDITIONAL([CONFIG_FTM_ANT], [test x$all = xtrue]) +AM_CONDITIONAL([CONFIG_FTM_NFC], [test x$all = xtrue]) + +AC_ARG_ENABLE([wlan], + [ --enable-wlan Enable WLAN FTM functionality], + [case "${enableval}" in + yes) wlan=true ;; + no) wlan=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-wlan]) ;; + esac],[wlan=false]) + +AM_CONDITIONAL([CONFIG_FTM_WLAN], [test x$wlan = xtrue -o x$all = xtrue]) + +AC_ARG_ENABLE([bt], + [ --enable-bt Enable BT FTM functionality], + [case "${enableval}" in + yes) bt=true ;; + no) bt=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-bt]) ;; + esac],[bt=false]) + +AM_CONDITIONAL([CONFIG_FTM_BT], [test x$bt = xtrue -o x$all = xtrue]) + + +AC_ARG_ENABLE(target, + [AS_HELP_STRING([--enable-target=TARGET], [Specify the target product to build])], + [TARGET=$enableval], + [TARGET=none] +) +AM_CONDITIONAL([MDM_ROME], [test "x$TARGET" = "xmdm9607" -o "x$TARGET" = "xmdm9635" -o "x$TARGET" = "xmdm9640" -o "x$TARGET" = "xmdmcalifornium"]) +AM_CONDITIONAL([MDM_PRONTO], [test "x$TARGET" = "xapq8009" -o "x$TARGET" = "xapq8017" -o "x$TARGET" = "xapq8053"]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_HEADER_STDC +AC_C_INLINE +AC_TYPE_INT64_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT8_T + +# Checks for library functions. +AC_FUNC_ERROR_AT_LINE +AC_FUNC_FORK +AC_FUNC_MALLOC + +AC_CONFIG_FILES([ \ + Makefile \ + ]) +AC_OUTPUT + diff --git a/feeds/wifi-ax/ftm/src/ftm_ant.c b/feeds/wifi-ax/ftm/src/ftm_ant.c new file mode 100755 index 000000000..5adb48ba1 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_ant.c @@ -0,0 +1,585 @@ +/*========================================================================== + + FTM ANT Source File + +Description + FTM platform independent processing of packet data + +# Copyright (c) 2010-2012 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +05/16/12 ankurn Adding support for ANT commands +11/28/12 c_ssugas implements efficent method for Ant cmd transfer + and implements Rx thread for event handling. +===========================================================================*/ +#include "event.h" +#include "msg.h" +#include "log.h" + +#include "diag_lsm.h" +#include "diagpkt.h" +#include "diagcmd.h" +#include "diag.h" +#include "termios.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "bt_vendor_qcom.h" +#include "ftm_ant_common.h" +#include "ftm_bt.h" +#include +#include "hidl_client.h" + +#ifdef ANDROID +#include +#endif + +#ifdef ANDROID +extern int soc_type; +#endif + +#define ANT_CTRL_PACKET_TYPE 0x0c +#define ANT_DATA_PACKET_TYPE 0x0e + +#define UNUSED(x) (void)(x) + +int init_transport_ant(int on); +// The following functions are dummy implementations of the callbacks required by libbt-vendor. +static void vendor_fwcfg_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void vendor_scocfg_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void vendor_lpm_vnd_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void vendor_audio_state_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void* vendor_alloc(int size) { + UNUSED(size); + return NULL; +} +static void vendor_dealloc(void *p_buf) { + UNUSED(p_buf); +} +static uint8_t vendor_xmit_cb(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback) { + UNUSED(opcode); + UNUSED(p_buf); + UNUSED(p_cback); + return 0; +} +static void vendor_epilog_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void vendor_a2dp_offload_cb(bt_vendor_op_result_t result, bt_vendor_opcode_t op, unsigned char handle) { + UNUSED(result); + UNUSED(op); + UNUSED(handle); +} + +// This struct is used to regsiter the dummy callbacks with libbt-vendor +static bt_vendor_interface_t *vendor_interface=NULL; +static const bt_vendor_callbacks_t vendor_callbacks = { + sizeof(bt_vendor_callbacks_t), + vendor_fwcfg_cb, + vendor_scocfg_cb, + vendor_lpm_vnd_cb, + vendor_audio_state_cb, + vendor_alloc, + vendor_dealloc, + vendor_xmit_cb, + vendor_epilog_cb, + vendor_a2dp_offload_cb +}; + +/* Transport file descriptor */ +int fd_transport_ant_cmd; +extern int first_ant_command; +/* Reader thread handle */ +pthread_t ant_cmd_thread_hdl; +/* Pipe file descriptors for cancelling read operation */ +int ant_pipefd[2]; + +/* Enable FTM_DEBUG to turn on Debug messages */ +//#define FTM_DEBUG + +/*=========================================================================== +FUNCTION ftm_ant_readerthread + +DESCRIPTION + Thread Routine to perfom asynchrounous handling of events coming on Smd + descriptor. It invokes a callback to the FTM ANT layer to intiate a request + to read event bytes. + +DEPENDENCIES + The LifeTime of ReaderThraad is dependent on the status returned by the + call to ftm_ant_qcomm_handle_event + +RETURN VALUE + RETURN NULL + +SIDE EFFECTS + None + +===========================================================================*/ +void *ftm_ant_readerthread(void *ptr) +{ + boolean status = FALSE; + int retval; + fd_set readfds; + int buf; + + UNUSED(ptr); +#ifdef FTM_DEBUG + printf("ftm_ant_readerthread --> \n"); +#endif + do + { + FD_ZERO(&readfds); + FD_SET(fd_transport_ant_cmd, &readfds); + FD_SET(ant_pipefd[0],&readfds); + retval = select((fd_transport_ant_cmd>ant_pipefd[0]?fd_transport_ant_cmd + :ant_pipefd[0]) + 1, &readfds, NULL, NULL, NULL); + if(retval == -1) + { + printf("select failed\n"); + break; + } + if(FD_ISSET(ant_pipefd[0],&readfds)) + { +#ifdef FTM_DEBUG + printf("Pipe descriptor set\n"); +#endif + read(ant_pipefd[0],&buf,1); + if(buf == 1) + break; + } + if(FD_ISSET(fd_transport_ant_cmd,&readfds)) + { +#ifdef FTM_DEBUG + printf("Read descriptor set\n"); +#endif + status = ftm_ant_qcomm_handle_event(); + if(TRUE != status) + break; + } + } + while(1); +#ifdef FTM_DEBUG + printf("\nReader thread exited\n"); +#endif + return 0; +} + +/*=========================================================================== +FUNCTION ftm_ant_open_channel + +DESCRIPTION + Open the SMD transport associated with ANT + +DEPENDENCIES + NIL + +RETURN VALUE + int value indicating success or failure + +SIDE EFFECTS + NONE + +===========================================================================*/ +static bool ftm_ant_open_channel() +{ + struct termios term_port; + int opts; + + printf("%s: \n",__func__ ); + switch (soc_type) + { + case BT_SOC_ROME: + case BT_SOC_CHEROKEE: + case BT_SOC_NAPIER: + //Use hidl_client_initialize for chip initialization + if (hidl_client_initialize(MODE_ANT,&fd_transport_ant_cmd) == false) { + printf("%s: HIDL client initialization failed, opening port with init_transpor_ant\n", __func__); + //Use libbt-vendor for chip initialization + fd_transport_ant_cmd = init_transport_ant(TRUE); + if (fd_transport_ant_cmd == -1) { + printf("%s: ANT Device open Failed, fd:%d: \n", __func__, fd_transport_ant_cmd); + return false; + } + } + break; + case BT_SOC_AR3K: + case BT_SOC_SMD: +#ifdef FTM_DEBUG + printf("ftm_ant_open_channel --> \n"); +#endif + + fd_transport_ant_cmd = open(APPS_RIVA_ANT_CMD_CH, (O_RDWR)); + if (fd_transport_ant_cmd == -1) { + printf("Ant Device open Failed= %d\n ", fd_transport_ant_cmd); + return false; + } + + // Blocking Read + opts = fcntl(fd_transport_ant_cmd, F_GETFL); + if (opts < 0) { + perror("fcntl(F_GETFL)"); + exit(EXIT_FAILURE); + } + + opts = opts & (~O_NONBLOCK); + if (fcntl(fd_transport_ant_cmd, F_SETFL, opts) < 0) { + perror("fcntl(F_SETFL)"); + exit(EXIT_FAILURE); + } + + if (tcgetattr(fd_transport_ant_cmd, &term_port) < 0) + close(fd_transport_ant_cmd); + cfmakeraw(&term_port); + if (tcsetattr(fd_transport_ant_cmd, TCSANOW, &term_port) < 0) { + printf("\n Error while setting attributes\n"); + return false; + } + + tcflush(fd_transport_ant_cmd, TCIFLUSH); +#ifdef FTM_DEBUG + printf("ftm_ant_open_channel success \n"); +#endif + break; + default: + ALOGE("%s:Unknown soc type.",__func__); + return false; + } + if (pipe(ant_pipefd) == -1) + { + printf("pipe create error"); + return STATUS_FAIL; + } + /* Creating read thread which listens for various masks & pkt requests */ + pthread_create( &ant_cmd_thread_hdl, NULL, ftm_ant_readerthread, NULL); + return true; +} + +int init_transport_ant(int on) { + + void *so_handle; + unsigned char bdaddr[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; + int fd[CH_MAX], powerstate, ret = -1; + char ref_count[PROPERTY_VALUE_MAX]; + int value; + + if (on) { + so_handle = dlopen("libbt-vendor.so", RTLD_NOW); + if (!so_handle) + { + ALOGE("Failed to load vendor component"); + return -1; + } + + vendor_interface = (bt_vendor_interface_t *) dlsym(so_handle, "BLUETOOTH_VENDOR_LIB_INTERFACE"); + if (!vendor_interface) + { + ALOGE("Failed to accesst bt vendor interface"); + return -1; + } + + vendor_interface->init(&vendor_callbacks, bdaddr); + + ALOGI("Turn On BT power"); + powerstate = BT_VND_PWR_ON; + ret = vendor_interface->op(BT_VND_OP_POWER_CTRL, &powerstate); + if (ret < 0) + { + ALOGE("Failed to turn on power from bt vendor interface"); + return -1; + } + for (int i = 0; i < CH_MAX; i++) + fd[i] = -1; + +#ifdef ANDROID + if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE || soc_type == BT_SOC_NAPIER) { + /*call ANT_USERIAL_OPEN to get ANT handle*/ + ret = vendor_interface->op((bt_vendor_opcode_t)BT_VND_OP_ANT_USERIAL_OPEN, fd); + } +#else +#ifdef BT_SOC_TYPE_ROME + /*call ANT_USERIAL_OPEN to get ANT handle*/ + ret = vendor_interface->op((bt_vendor_opcode_t)BT_VND_OP_ANT_USERIAL_OPEN, fd); +#endif +#endif + ALOGE("ret value: %d", ret); + if (ret != 1) + { + ALOGE("Failed to get fd from bt vendor interface"); + return -1; + } else { + ALOGE("FD: %x", fd[0]); + return fd[0]; + } + } else { + if (vendor_interface) { + ALOGE("Close and cleanup the interfaces"); + +#ifdef ANDROID + if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE || soc_type == BT_SOC_NAPIER) { + int ret = vendor_interface->op((bt_vendor_opcode_t)BT_VND_OP_ANT_USERIAL_CLOSE, NULL); + } +#else +#ifdef BT_SOC_TYPE_ROME + int ret = vendor_interface->op((bt_vendor_opcode_t)BT_VND_OP_ANT_USERIAL_CLOSE, NULL); +#endif +#endif + + ALOGE("ret value: %d", ret); + ALOGI("Turn off BT power"); + powerstate = BT_VND_PWR_OFF; + ret = vendor_interface->op(BT_VND_OP_POWER_CTRL, &powerstate); + if (ret < 0) + { + ALOGE("Failed to turn off power from bt vendor interface"); + return -1; + } + vendor_interface->cleanup(); + vendor_interface = NULL; + return 0; + } else { + + ALOGE("Not able to find vendor interface handle"); + return -1; + } + } +} + +/*=========================================================================== +FUNCTION ftm_log_send_msg + +DESCRIPTION + Processes the buffer sent and sends it to the libdiag for sending the Cmd + response + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ +void ftm_ant_log_send_msg(const uint8 *pEventBuf,int event_bytes) +{ + int result = log_status(LOG_FTM_VER_2_C); + ftm_ant_log_pkt_type* ftm_ant_log_pkt_ptr = NULL; + + if((pEventBuf == NULL) || (event_bytes == 0)) + return; +#ifdef FTM_DEBUG + printf("ftm_ant_log_send_msg --> \n"); +#endif + if(result == 1) + { + ftm_ant_log_pkt_ptr = (ftm_ant_log_pkt_type *)log_alloc(LOG_FTM_VER_2_C, + FTM_ANT_LOG_HEADER_SIZE + (event_bytes-1)); + if(ftm_ant_log_pkt_ptr != NULL) + { + /* FTM ANT Log PacketID */ + ftm_ant_log_pkt_ptr->ftm_log_id = FTM_ANT_LOG_PKT_ID; + memcpy((void *)ftm_ant_log_pkt_ptr->data,(void *)pEventBuf,event_bytes); + log_commit( ftm_ant_log_pkt_ptr ); + } + } +} + +/*=========================================================================== +FUNCTION ftm_ant_dispatch + +DESCRIPTION + Dispatch routine for the various FM Rx/Tx commands. Copies the data into + a global union data structure before calling the processing routine + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +void * ftm_ant_dispatch(ftm_ant_pkt_type *ant_ftm_pkt, uint16 pkt_len) +{ + ftm_ant_generic_sudo_res *rsp; + int err = 0, i; + int data_len = ant_ftm_pkt->cmd_data_len; + bool resp = false; + unsigned char *pdata = NULL, *ptemp; +#ifdef FTM_DEBUG + printf("ftm_ant_dispatch --> \n"); +#endif + + UNUSED(pkt_len); + + if (first_ant_command == 0) { + first_ant_command = 1; + ftm_ant_open_channel(); + } + + rsp = (ftm_ant_generic_sudo_res*)diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_ANT_CMD_CODE + , sizeof(ftm_ant_generic_sudo_res) + ); + if(rsp == NULL) + { + printf("%s Failed to allocate resource",__func__); + return NULL; + } + + switch (soc_type) { + //Rome shares the same UART transport for ANT and BT. Hence, to differenciate the + //packets by controller, adding one extra byte for ANT data and control packets + case BT_SOC_ROME: + case BT_SOC_CHEROKEE: + case BT_SOC_NAPIER: + data_len = data_len + 1; + pdata = (unsigned char *) malloc(data_len); + if (pdata == NULL) { + ALOGE("Failed to allocate the memory for ANT command packet"); + rsp->result = FTM_ANT_FAIL; + return (void *) rsp; + } + //To be compatible with Legacy, SMD based PLs, send all the packets + //with cmd opcode 0x0c + pdata[0] = 0x0c; + memcpy(pdata+1, ant_ftm_pkt->data, data_len-1); + err = write(fd_transport_ant_cmd, pdata, data_len); + ptemp = pdata; + break; + case BT_SOC_AR3K: + case BT_SOC_SMD: + /* Send the packet to controller and send a dummy response back to host*/ + err = write(fd_transport_ant_cmd, ant_ftm_pkt->data, data_len); + ptemp = ant_ftm_pkt->data; + break; + default: + ALOGE("%s:Unknown soc type", __func__); + break; + } + if (err == data_len) { + rsp->result = FTM_ANT_SUCCESS; + printf("ANT CMD: "); + for (i = 1; iresult = FTM_ANT_FAIL; + printf("FTM ANT write fail len: %d\n", err); + } + if (pdata) + free(pdata); + return (void *)rsp; +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_qcomm_handle_event + +DESCRIPTION + Routine called by the HAL layer reader thread to process the HCI events + The post conditions of each event is covered in a state machine pattern + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean ftm_ant_qcomm_handle_event () +{ + boolean status = TRUE; + int nbytes,i,len =0; + int event_type; + ftm_ant_generic_res *res = (ftm_ant_generic_res *)diagpkt_subsys_alloc( + DIAG_SUBSYS_FTM + , FTM_ANT_CMD_CODE + , sizeof(ftm_ant_generic_res) + ); + if(res == NULL) + { + printf("%s Failed to allocate res",__func__); + tcflush(fd_transport_ant_cmd, TCIFLUSH); + return FALSE; + } +#ifdef FTM_DEBUG + printf("ftm_ant_hci_qcomm_handle_event --> \n"); +#endif + + /* Read length and event type of Ant Resp event*/ + nbytes = read(fd_transport_ant_cmd, (void *)res->evt, 2); + if(nbytes <= 0) { + status = FALSE; + printf("ftm_ant_qcomm_handle_event read fail len=%d\n", nbytes); + return status; + } + event_type = res->evt[0]; + len = res->evt[1]; +#ifdef FTM_DEBUG + printf(" event type =%d\n",event_type); + printf("length of event =%d\n",len); +#endif + /* Read out the Ant Resp event*/ + if (len <= (int)sizeof(res->evt)) + { + nbytes = read(fd_transport_ant_cmd, (void *)res->evt, len); + if (nbytes != len) { + res->result = FTM_ANT_FAIL; + status = FALSE; + printf("ftm_ant_qcomm_handle_event read fail len=%d\n", nbytes); + } + else { + res->result = FTM_ANT_SUCCESS; + printf("ANT EVT: "); + for (i=0; ievt[i]); + } + printf("\n"); + ftm_ant_log_send_msg(res->evt, nbytes); + tcflush(fd_transport_ant_cmd, TCIOFLUSH); + } + } + else + { + res->result = FTM_ANT_FAIL; + status = FALSE; + printf("ftm_ant_qcomm_handle_event read fail len=%d is more than sizeof(res->evt)=%d\n", len, (int)sizeof(res->evt)); + } + return status; +} diff --git a/feeds/wifi-ax/ftm/src/ftm_ant_common.h b/feeds/wifi-ax/ftm/src/ftm_ant_common.h new file mode 100755 index 000000000..c40e1caf8 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_ant_common.h @@ -0,0 +1,124 @@ +/*========================================================================== + + FTM FM Common Header File + +Description + Global Data declarations of the ftm ant component. + +# Copyright (c) 2012,2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +05/16/2012 ankurn Adding support for ANT+ +11/28/12 c_ssugas Adds data structures and macro for ant log event support. +===========================================================================*/ + +#ifdef CONFIG_FTM_ANT + +#include "diagpkt.h" +#include "log.h" +#include "ftm_bt_common.h" + +#include + +#define APPS_RIVA_ANT_CMD_CH "/dev/smd5" +#define APPS_RIVA_ANT_DATA_CH "/dev/smd6" + +#define FTM_ANT_CMD_CODE 94 +#define OPCODE_OFFSET 5 + +#define FTM_ANT_LOG_HEADER_SIZE (sizeof(ftm_ant_log_pkt_type) - 1) +#define FTM_ANT_LOG_PKT_ID 0x0D + +/* FTM Log Packet - Used to send back the event of a ANT Command */ +typedef PACKED struct +{ + log_hdr_type hdr; + word ftm_log_id; /* FTM log id */ + byte data[1]; /* Variable length payload, + look at FTM log id for contents */ +} ftm_ant_log_pkt_type; + +/* Generic result, used for any command that only returns an error code */ +typedef enum { + FTM_ANT_FAIL, + FTM_ANT_SUCCESS, +} ftm_ant_api_result_type; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; +} ftm_ant_generic_sudo_res; + + +/* Generic Response */ +typedef PACKED struct +{ + diagpkt_subsys_header_type header; /*Diag header*/ + uint8 evt[18]; /*allocates memory to hold longest valid event */ + char result; /* result */ +}__attribute__((packed)) ftm_ant_generic_res; + +/* FTM ANT request type */ +typedef PACKED struct +{ + diagpkt_cmd_code_type cmd_code; + diagpkt_subsys_id_type subsys_id; + diagpkt_subsys_cmd_code_type subsys_cmd_code; + uint8 cmd_id; /* command id (required) */ + uint8 cmd_data_len; + byte data[1]; +}__attribute__((packed))ftm_ant_pkt_type; + + + +/*=========================================================================== +FUNCTION ftm_ant_dispatch + +DESCRIPTION + Dispatch routine for the various ANT commands. Copies the data into + a global union data structure before calling the processing routine + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the FTM ANT packet + +SIDE EFFECTS + None + +===========================================================================*/ + +void * ftm_ant_dispatch(ftm_ant_pkt_type *ftm_ant_pkt, uint16 length ); + +/*=========================================================================== +FUNCTION ftm_ant_qcomm_handle_event + +DESCRIPTION + Handler for the various ANT Events received. Sends data as log packets + using diag to upper layers. +DEPENDENCIES + NIL + +RETURN VALUE + Status value TRUE if event received successfuly + otherwise returns status value FALSE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean ftm_ant_qcomm_handle_event (); + +#endif /* CONFIG_FTM_ANT */ diff --git a/feeds/wifi-ax/ftm/src/ftm_bt.c b/feeds/wifi-ax/ftm/src/ftm_bt.c new file mode 100755 index 000000000..4f0475140 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt.c @@ -0,0 +1,2013 @@ +/*========================================================================== + + FTM BT Task Source File + +Description + FTM state machine and platform independent routines for BT + +# Copyright (c) 2010-2013 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +02/29/12 rrr Added/Modified LE & BR/EDR power class configuration +09/27/11 bneti Added packet indicator for hci events for msm8960 +09/28/11 rrr Moved peristent NV item related APIs to CPP, + for having BD address being programmed twice if previous + BD address was random generated. +06/07/11 bneti Add support smd support for msm8960 +09/03/11 agaja Added support for NV_READ and NV_WRITE Commands to write + onto Persist File system +02/08/11 braghave Reading the HCI commands from binary file + for non-Android case +01/19/11 rakeshk Added the connectivity test implementation +01/07/11 rakeshk Updated the debug log warnings related to typecasting +07/07/10 rakeshk Updated the function name of BT power set routine + of pointers +06/18/10 rakeshk Created a source file to implement routines for FTM + states and command processing +==========================================================================*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ftm_bt_power_hal.h" +#include "ftm_fm_common.h" +#include "ftm_bt_hci_hal.h" +#include "ftm_common.h" +#include +#ifdef BT_NV_SUPPORT +#include "ftm_bt_persist.h" +#endif +#include "hidl_client.h" + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +#define I2C_SLAVE_ADDR 0x0C +#define MAX_PIN_CONFIGS 8 + +#define NVM_PAYLOAD_MAXLENGTH (1024) +#define MAX_FILE_NAME (255) +#define LOG_FTM_FM_C ((uint16) 0x14CC) + +extern uint8_t is_slim_bus_test; +int fd_pintest = -1; +FILE *fp; +unsigned char *nvm_cmd; +typedef struct pintest { + char *gpiostring; + /* GPIO number */ + int gpionum; + /* Pin control register */ + int pinctrlreg; + /* Data register */ + int datareg; + /* Bit position in Data register */ + int bitpos; + /* Direction of the Pin */ + char direction; +} pintest; + +typedef struct platformpintest { + /* MSM number for pin test*/ + int platform; + /* Pin test config */ + pintest pinconfig[MAX_PIN_CONFIGS]; + /* Pin direction config register 0 */ + int pinctloe0; + /* Pin direction config register 1 */ + int pinctloe1; + /* Data register 0 */ + int pinctldata0; + /* Data register 1 */ + int pinctldata1; + /* PIN CTL enable value */ + int pinctlenable; + /* Output enable mask for UART pins */ + int hcioeenablemask; + /* Output enable mask for AUX PCM pins */ + int pcmoeenablemask; +}platformpintest; + +const platformpintest pintestconfigs[] = { + { + .platform = 8660, + .pinconfig = { + { + .gpiostring = "53",/*UARTDM_TX*/ + .gpionum = 53, + .pinctrlreg = 0x87,/*BT_HCI_0_MODE*/ + .datareg = 0x0D,/*PIN_CTL_DATA0*/ + .bitpos = 7, + .direction = 1, + }, + { + .gpiostring = "54",/*UARTDM_RX*/ + .gpionum = 54, + .pinctrlreg = 0x86,/*BT_HCI_1_MODE*/ + .datareg = 0x0D,/*PIN_CTL_DATA0*/ + .bitpos = 6, + .direction = 0, + }, + { + .gpiostring = "55",/*UARTDM_CTS*/ + .gpionum = 55, + .pinctrlreg = 0x84,/*BT_HCI_3_MODE*/ + .datareg = 0x0D,/*PIN_CTL_DATA0*/ + .bitpos = 4, + .direction = 0, + }, + { + .gpiostring = "56",/*UARTDM_RFR*/ + .gpionum = 56, + .pinctrlreg = 0x85,/*BT_HCI_2_MODE*/ + .datareg = 0x0D,/*PIN_CTL_DATA0*/ + .bitpos = 5, + .direction = 1, + }, + { + .gpiostring = "111",/*AUX_PCM_DOUT_S*/ + .gpionum = 111, + .pinctrlreg = 0x89,/*BT_PCM_DIN_MODE */ + .datareg = 0x0E,/*PIN_CTL_DATA1*/ + .bitpos = 1, + .direction = 1, + }, + { + .gpiostring = "112",/*AUX_PCM_DIN_S*/ + .gpionum = 112, + .pinctrlreg = 0x8A,/*BT_PCM_DOUT_MODE*/ + .datareg = 0x0E,/*PIN_CTL_DATA1*/ + .bitpos = 2, + .direction = 0, + }, + { + .gpiostring = "113",/*AUX_PCM_SYNC_S*/ + .gpionum = 113, + .pinctrlreg = 0x8B,/*BT_PCM_SYNC_MODE*/ + .datareg= 0x0E,/*PIN_CTL_DATA1*/ + .bitpos = 3, + .direction = 1, + }, + { + .gpiostring = "114",/*AUX_PCM_CLK_S*/ + .gpionum = 114, + .pinctrlreg = 0x88,/* BT_PCM_BCLK_MODE */ + .datareg = 0x0E,/*PIN_CTL_DATA1*/ + .bitpos = 0, + .direction = 1, + }, + }, + .pinctloe0 = 0xA, + .pinctloe1 = 0xB, + .pinctldata0 = 0xD, + .pinctldata1 = 0xE, + .pinctlenable = 0x15, + .hcioeenablemask = 0x50, + .pcmoeenablemask = 0x04, + }, +}; +platformpintest *pintestconfig= (platformpintest *)&pintestconfigs[0]; +/* I2C bus and GPIO mux entry drivers */ +#define I2C_PATH "/dev/i2c-4" +#define PINTEST_ENABLE_PATH "/sys/kernel/debug/btpintest/enable" + +const char HIGH = '1'; +const char LOW = '0'; + +/* ------------------------------------------------------------------------- +** Definitions and Declarations +** ------------------------------------------------------------------------- */ + +/*Flag to manage the verbose output */ +extern int verbose; +/* HCI Command buffer */ +static uint8 bt_ftm_buffer[BT_FTM_CMD_RSP_LEN]; +/* HCI Event buffer */ +static uint8 event_buf[HC_VS_MAX_ACL]; +/* Varibale to handle the stages of Sleep disable cmds */ +static int sleep_stage =0; +/* FTM Global state variable */ +static ftm_state global_state = FTM_SOC_NOT_INITIALISED; +/* pointer to the SOC version string */ +static uint8 *bt_soc_app_version_string = NULL; +/*variable to identify the msm type*/ +static boolean is_transportSMD = 0; +/* Variables to identify the platform */ +extern char transport_type[PROPERTY_VALUE_MAX]; +/* Default hw version register contents for 4020BD B0, if it's different than it's 4020BD B1 */ +static uint8 bt_soc_hw_version[] = +{ + 0x05, 0x00, 0x00, 0x00 +}; +/* Default Bluetooth address if read from NV fails, same in AMSS */ +static const uint8 default_bt_bd_addr[] = +{ + 0x34, 0x12, 0x78, 0x56, 0xBC, 0x9A +}; +/* Uart Protocol config tag*/ +static const bt_qsoc_cfg_tbl_struct_type bt_qsoc_tag17 = +{ + 0x8, {0x01, 0x11, 0x05, 0x0A, 0x01, 0x00, 0x00, 0x00,} +}; + +/* Uart Protocol config tag for latest hw */ +static const bt_qsoc_cfg_tbl_struct_type bt_qsoc_tag17_latest_hw = +{ + 0x0B, {0x01, 0x11, 0x08, 0x02,0x01,0x0E,0x08,0x04,0x32,0x0A,0x00} +}; + +/* FTM status log size*/ +const uint8 logsize = 2; +/* HCI user Cmd pass Log Packet */ +const uint8 event_buf_user_cmd_pass[2] = {0x0f,FTM_BT_DRV_NO_ERR}; +/* HCI user Cmd fail Log Packet */ +const uint8 event_buf_user_cmd_fail[2] = {0x0f,FTM_BT_DRV_CONN_TEST_FAILS}; +/* HCI user Cmd timed out Log Packet */ +const uint8 event_buf_user_cmd_timeout[2] = {0x0f,FTM_BT_DRV_NO_SOC_RSP_TOUT}; +/* HCI user Cmd Unknown error Log Packet */ +const uint8 event_buf_user_unknown_err[2] = {0x0f,FTM_BT_DRV_UNKNOWN_ERR}; + +struct first_cmd ptr_powerup; +#ifdef USE_LIBSOCCFG +/* Run time SoC Cfg paramters */ +ftm_bt_soc_runtime_cfg_type soc_cfg_parameters; +#endif +/* Peek table Loop count for 4025 R3 SoC */ +uint loopCount; +/* Command Queue front pointer */ +cmdQ *front = NULL; +/* Command Queue rear pointer */ +cmdQ *rear = NULL; +/* cmd count for unprocessed cmds in queue */ +uint32 num_pending_cmds = 0; +/* Descriptors for connectivity test */ +static int fd_i2c; +static char ctime_buf[10]; + +char *get_current_time(void) +{ + struct timeval tv; + time_t ctime; + + gettimeofday(&tv, NULL); + ctime = tv.tv_sec; + strftime(ctime_buf, 10, "%T", localtime(&ctime)); + return ctime_buf; +} +/*=========================================================================== +FUNCTION qinsert_cmd + +DESCRIPTION + Command Queue insert routine. Add the FTM BT packet to the Queue + +DEPENDENCIES + NIL + +RETURN VALUE + RETURNS FALSE without adding queue entry in failure + to allocate a new Queue item + else returns TRUE + +SIDE EFFECTS + increments the number of commands queued + +===========================================================================*/ +boolean qinsert_cmd(ftm_bt_pkt_type *ftm_bt_pkt) +{ + cmdQ *newitem; +#ifdef FTM_DEBUG + printf("qinsert_cmd > rear = 0x%x front = 0x%x\n", + (unsigned int)rear,(unsigned int)front); +#endif + if(num_pending_cmds == 20) + { + ftm_log_send_msg(&event_buf_user_unknown_err[0],logsize); + return FALSE; + } + newitem = (cmdQ*)malloc(sizeof(cmdQ)); + if(newitem == NULL) + { + ftm_log_send_msg(&event_buf_user_unknown_err[0],logsize); + return FALSE; + } + newitem->next=NULL; + newitem->data = (void *)malloc(ftm_bt_pkt->ftm_hdr.cmd_data_len); + if(newitem->data == NULL) + { + free(newitem); + ftm_log_send_msg(&event_buf_user_unknown_err[0],logsize); + return FALSE; + } + /* Copy the data into the queue buffer */ + memcpy(newitem->data,(void*)ftm_bt_pkt->data, ftm_bt_pkt->ftm_hdr.cmd_data_len); + /* Set Flag to notify BT command*/ + newitem->bt_command = 1; + newitem->cmd_len = ftm_bt_pkt->ftm_hdr.cmd_data_len; + + if(front==NULL && rear==NULL) + { + front=newitem; + rear=newitem; + } + else + { + (rear)->next=newitem; + rear=newitem; + } + num_pending_cmds++; +#ifdef FTM_DEBUG + printf("qinsert_cmd < rear = 0x%x front = 0x%x\n", + (unsigned int)rear,(unsigned int)front); +#endif + return TRUE; +} + +/*=========================================================================== +FUNCTION dequeue_send + +DESCRIPTION + Command Queue delete and calls HCI send routine. Dequeues the HCI data from + the queue and sends it to HCI HAL layer. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN NIL + +SIDE EFFECTS + decrements the number of command queued + +===========================================================================*/ +void dequeue_send() +{ + cmdQ *delitem; /* Node to be deleted */ +#ifdef FTM_DEBUG + printf("dequeue_send > rear = 0x%x front = 0x%x\n", + (unsigned int)rear,(unsigned int)front); +#endif + if((front)==NULL && (rear)==NULL) + printf("\nQueue is empty to delete any element\n"); + else + { + delitem=front; + if(delitem) + { + ftm_bt_dispatch(delitem->data,delitem->cmd_len); + front=front->next; + if(front == NULL) + { + rear = NULL; + num_pending_cmds = 0; + } + free(delitem->data); + free(delitem); + num_pending_cmds--; + } + } +#ifdef FTM_DEBUG + printf("dequeue_send < rear = 0x%x front = 0x%x\n", + (unsigned int)rear,(unsigned int)front); +#endif +} + +/*=========================================================================== +FUNCTION cleanup_pending_cmd_queue + +DESCRIPTION + Command Queue delete routine. Dequeues the HCI cmds from the + queue. This routine is useful in case the HCI interface has + hung up and a FTM module restart is immimnent. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN NIL + +SIDE EFFECTS + NONE + +===========================================================================*/ + +void cleanup_pending_cmd_queue() +{ + cmdQ *delitem; /* Node to be deleted */ +#ifdef FTM_DEBUG + printf("cleanup_pending_cmd_queue > rear = 0x%x front = 0x%x\n", + (unsigned int)rear,(unsigned int)front); +#endif + if((front==NULL) && (rear==NULL)) + { + printf("\nQueue is empty to delete any element\n"); + } + else + { + while(front != NULL) + { + delitem=front; + front=front->next; + if(front == NULL) + rear = NULL; + free(delitem->data); + free(delitem); + } + } +#ifdef FTM_DEBUG + printf("cleanup_pending_cmd_queue < rear = 0x%x front = 0x%x\n", + (unsigned int)rear,(unsigned int)front); +#endif +} + +/*=========================================================================== +FUNCTION ftm_bt_err_timedout + +DESCRIPTION + This routine triggers the shutdown of the HCI and Power resources in case + a HCI command previously sent times out. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN NIL + +SIDE EFFECTS + NONE + +===========================================================================*/ +void ftm_bt_err_timedout() +{ + ftm_bt_hci_hal_deinit_transport(); + if(!is_transportSMD) + ftm_bt_power_hal_set(BT_OFF); +#ifdef FTM_DEBUG + printf("\nTimed out \n"); +#endif + global_state = FTM_SOC_NOT_INITIALISED; + cleanup_pending_cmd_queue(); + ftm_log_send_msg(&event_buf_user_cmd_timeout[0],logsize); +} + +/*=========================================================================== +FUNCTION export_gpio + +DESCRIPTION + Writes the gpio number passed in the argumnet to export a sysfs entry + +DEPENDENCIES + NIL + +RETURN VALUE + number of bytes written + +SIDE EFFECTS + None + +===========================================================================*/ +int export_gpio(int fd,char *gpionum) +{ + int sz; + sz = write(fd,gpionum,strlen(gpionum)); + return sz; +} +/*=========================================================================== +FUNCTION ftm_bt_conn_init + +DESCRIPTION + Initialises the connectivity test settings + 1. Exports the sysfs entries for MSM GPIOs + 2. Configures the TLMM settings on BT SoC to be in I2C PIN + control mode and directions. + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE,if the init fails + TRUE,if it passes + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_conn_init(void) +{ + char out[] = "out"; + char in[] = "in"; + int sz,i; + unsigned char buffer; + char direction_path[64]; + int fd_gpio = -1; + int fd = -1; +#ifdef FTM_DEBUG + printf("ftm_bt_conn_init start \n"); +#endif + fd_gpio = open("/sys/class/gpio/export", O_WRONLY); + + if(fd_gpio < 0) + return FALSE; + + for(i = 0; i < MAX_PIN_CONFIGS; i++) + { +#ifdef FTM_DEBUG + printf("pintestconfig->gpiostring = %s\n",pintestconfig->pinconfig[i].gpiostring); +#endif + sz = export_gpio(fd_gpio,pintestconfig->pinconfig[i].gpiostring); + if (sz < 0) + { + goto out; + } + } +#ifdef FTM_DEBUG + printf("Enabling pin test path\n"); +#endif + /* Configure the TLMM settings for the GPIOs requested using export */ + fd = open(PINTEST_ENABLE_PATH, O_WRONLY); + if(fd < 0) + goto out; + + buffer = HIGH; + sz = write(fd,&buffer,sizeof(buffer)); + if (sz < 0) + { + goto out; + } + close(fd); +#ifdef FTM_DEBUG + printf("open I2C_PATH\n"); +#endif + fd_i2c = open(I2C_PATH,O_RDWR); + + if(fd_i2c < 0) + { + goto out; + } + + buffer = pintestconfig->pinctlenable; + for(i = 0; i < MAX_PIN_CONFIGS ; i++) + { +#ifdef FTM_DEBUG + printf("pintestconfig->pinconfig[i]pinctrlreg = 0x%x\n",pintestconfig->pinconfig[i].pinctrlreg); +#endif + sz = i2c_write(fd_i2c,pintestconfig->pinconfig[i].pinctrlreg,&buffer,sizeof(buffer),I2C_SLAVE_ADDR); + if (sz < 0) + { + goto out; + } + } + + buffer = pintestconfig->hcioeenablemask; + sz = i2c_write(fd_i2c,pintestconfig->pinctloe0,&buffer,sizeof(buffer),I2C_SLAVE_ADDR); + if (sz < 0) + { + goto out; + } + for(i = 0; i < MAX_PIN_CONFIGS; i++) + { + snprintf(direction_path,sizeof(direction_path), + "/sys/class/gpio/gpio%d/direction", pintestconfig->pinconfig[i].gpionum); + fd = open(direction_path,O_WRONLY); + if(fd < 0) + goto out; + if(pintestconfig->pinconfig[i].direction) + sz = write(fd,&out,sizeof(out)); + else + sz = write(fd,&in,sizeof(in)); + if (sz < 0) + { + goto out; + } + close(fd); + } + + buffer = pintestconfig->pcmoeenablemask; + sz = i2c_write(fd_i2c,pintestconfig->pinctloe1,&buffer,sizeof(buffer),I2C_SLAVE_ADDR); + +out : +#ifdef FTM_DEBUG + printf("ftm_bt_conn_init end\n"); +#endif + if(fd >= 0) + close(fd); + if(fd_gpio >= 0) + close(fd_gpio); + + if ((sz < 0) || (fd < 0) || (fd_gpio < 0)) + { + return FALSE; + } + return TRUE; + +} + +/*=========================================================================== +FUNCTION ftm_bt_conn_outputpin_test + +DESCRIPTION + Executes the connectivity test for a output pin on + MSM 8660 to input pin on BT SOC + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE,if the connectivity test fails + TRUE,if it passes for all pins combination + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_conn_outputpin_test(const pintest *config) +{ + int fd_gpioN = -1; + int bit; + unsigned char wr_gpio_value = HIGH,rd_reg_value = 0; + char value_path[64]; +#ifdef FTM_DEBUG + printf("ftm_bt_conn_outputpin_test\n"); +#endif + /* Test UART Tx --> HCI0(RX on SoC) */ + snprintf(value_path,sizeof(value_path), + "/sys/class/gpio/gpio%d/value", config->gpionum); + fd_gpioN = open(value_path,O_WRONLY); + wr_gpio_value = HIGH; + /* Write a HIGH on the GPIO line on MSM */ + write(fd_gpioN,&wr_gpio_value,sizeof(wr_gpio_value)); + + i2c_read(fd_i2c,config->datareg,&rd_reg_value,sizeof(rd_reg_value),I2C_SLAVE_ADDR); + + bit = ((rd_reg_value & (1 << config->bitpos)) >> config->bitpos); + /* Check the Bit position in the Pin's Data register on SoC for a 1 */ + if(bit != 1) + { + close(fd_gpioN); + printf("OUT :HIGH Test GPIO %d FAIL data reg = %d\n",config->gpionum,config->datareg); + return FALSE; + } + + wr_gpio_value = LOW; + /* Write a LOW on the GPIO line on MSM*/ + write(fd_gpioN,&wr_gpio_value,sizeof(wr_gpio_value)); + + i2c_read(fd_i2c,config->datareg,&rd_reg_value,sizeof(rd_reg_value),I2C_SLAVE_ADDR); + + bit = ((rd_reg_value & (1 << config->bitpos)) >> config->bitpos); + /* Check if the bit position in the Pin's data register on SoC is cleared */ + if(bit != 0) + { + close(fd_gpioN); + printf("OUT : HIGH Test GPIO %d FAIL data reg = %d\n",config->gpionum,config->datareg); + return FALSE; + } + close(fd_gpioN); + + printf("OUT : Test GPIO %d PASS \n",config->gpionum); + + return TRUE; + +} + +/*=========================================================================== +FUNCTION ftm_bt_conn_inputpin_test + +DESCRIPTION + Executes the connectivity test for a input pin on + MSM 8660 from output pin on BT SOC + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE,if the connectivity test fails + TRUE,if it passes for all pins combination + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_conn_inputpin_test(const pintest *config) +{ + int fd_gpioN = -1; + unsigned char wr_reg_value = HIGH,rd_gpio_value; + char value_path[64]; +#ifdef FTM_DEBUG + printf("ftm_bt_conn_inputpin_test\n"); +#endif + + snprintf(value_path,sizeof(value_path), + "/sys/class/gpio/gpio%d/value", config->gpionum); + fd_gpioN = open(value_path,O_RDONLY); + + /* Write a 1 to the Pins bit position on SoC */ + wr_reg_value = (1 << config->bitpos); + i2c_write(fd_i2c,config->datareg,&wr_reg_value,sizeof(wr_reg_value),I2C_SLAVE_ADDR); + + read(fd_gpioN,&rd_gpio_value,sizeof(rd_gpio_value)); + /* Check if the value is high on the MSM GPIO line */ + if(rd_gpio_value != HIGH) + { + close(fd_gpioN); + printf("IN : HIGH Test GPIO %d FAIL data reg = %d\n",config->gpionum,config->datareg); + return FALSE; + } + + close(fd_gpioN); + fd_gpioN = open(value_path,O_RDONLY); + /* Clear the Pins bit position on SoC */ + wr_reg_value = wr_reg_value & ~(1 << config->bitpos); + i2c_write(fd_i2c,config->datareg,&wr_reg_value,sizeof(wr_reg_value),I2C_SLAVE_ADDR); + + read(fd_gpioN,&rd_gpio_value,sizeof(rd_gpio_value)); + + /* Check if the value is low on the MSM GPIO line */ + if(rd_gpio_value != LOW) + { + close(fd_gpioN); + printf("IN : LOW Test GPIO %d FAIL data reg = %d\n",config->gpionum,config->datareg); + return FALSE; + } + close(fd_gpioN); + + printf("IN : Test GPIO %d PASS \n",config->gpionum); + + return TRUE; +} + + +/*=========================================================================== +FUNCTION ftm_bt_conn_test_execute + +DESCRIPTION + Executes the connectivity test for MSM 8660-Bahama SOC + MSM 8660 Bahama SoC + ======== ========== + UART Tx ------> UART Rx + UART Rx <------ UART Tx + UART RTS ------> UART CTS + UART CTS <------ UART RTS + + AUX_PCM_CLK ------> PCM_BCLK + AUX_PCM_SYNC ------> PCM_SYNC + AUX_PCM_DOUT ------> PCM_DIN + AUX_PCM_DIN <------ PCM_DOUT + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE,if the connectivity test fails + TRUE,if it passes for all pins combination + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_conn_test_execute(void) +{ + + int i = 0,ret = 0; + + printf("Conn test begin \n"); + + for(i = 0; i < MAX_PIN_CONFIGS; i++) + { + if(pintestconfig->pinconfig[i].direction) + ret = ftm_bt_conn_outputpin_test(&pintestconfig->pinconfig[i]); + else + ret = ftm_bt_conn_inputpin_test(&pintestconfig->pinconfig[i]); + + if(ret != TRUE) + return FALSE; + } + printf("Conn test successfully done \n"); + return TRUE; +} + +/*=========================================================================== +FUNCTION ftm_bt_conn_deinit + +DESCRIPTION + Deinitialise the resources allocated for connectivity tests which includes + 1. unexport the GPIO sysfs entries + 2. Reset the settings in I2C registers of Bahama top level module + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ +void ftm_bt_conn_deinit(void) +{ + int sz,fd,i; + int fd_gpio; + unsigned char buffer; + +#ifdef FTM_DEBUG + printf("ftm_bt_conn_deinit start\n"); +#endif + /* Restore the Mux settings of the requested GPIOs*/ + fd = open(PINTEST_ENABLE_PATH, O_WRONLY); + buffer = '0'; + sz = write(fd,&buffer,sizeof(buffer)); + close(fd); + /* Unexport all the GPIOs */ + fd_gpio = open("/sys/class/gpio/unexport", O_WRONLY); + + if(fd_gpio < 0) + return ; + + for(i = 0; i < MAX_PIN_CONFIGS; i++) + { + sz = export_gpio(fd_gpio,pintestconfig->pinconfig[i].gpiostring); + if (sz < 0) + { + break; + } + } + + for(i = 0; i < MAX_PIN_CONFIGS; i++) + { + if(pintestconfig->pinconfig[i].gpionum >= 53 && pintestconfig->pinconfig[i].gpionum <= 56) + buffer = 0x40; + else + buffer = 0xC0; + + sz = i2c_write(fd_i2c,pintestconfig->pinconfig[i].pinctrlreg,&buffer,sizeof(buffer),I2C_SLAVE_ADDR); + if (sz < 0) + { + break; + } + } + buffer = 0x00; + i2c_write(fd_i2c,pintestconfig->pinctloe0,&buffer,sizeof(buffer),I2C_SLAVE_ADDR); + i2c_write(fd_i2c,pintestconfig->pinctloe1,&buffer,sizeof(buffer),I2C_SLAVE_ADDR); + i2c_write(fd_i2c,pintestconfig->pinctldata0,&buffer,sizeof(buffer),I2C_SLAVE_ADDR); + i2c_write(fd_i2c,pintestconfig->pinctldata1,&buffer,sizeof(buffer),I2C_SLAVE_ADDR); + + close(fd_gpio); + close(fd_i2c); + fd_i2c = -1; +#ifdef FTM_DEBUG + printf("ftm_bt_conn_deinit end\n"); +#endif + return; +} + +/*=========================================================================== +FUNCTION ftm_bt_conn_test + +DESCRIPTION + Executes the connectivity test for MSM 8660-Bahama SOC + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE,if the connectivity test fails + TRUE,if it passes + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_conn_test(void) +{ + boolean ret; + unsigned int i = 0; +#ifdef FTM_DEBUG + printf("ftm_bt_conn_test = %d\n",pintestconfigs[i].platform); +#endif + /* Walk through the avaialble pin test configs*/ + for(i = 0; i < ARRAY_SIZE(pintestconfigs);i++) + { + printf("board type = %d stored type = %d \n",boardtype,pintestconfigs[i].platform); + if(boardtype == pintestconfigs[i].platform) + { + pintestconfig = (platformpintest *)&pintestconfigs[i]; + break; + } + } + /* If we dont find a matching test config return here itself */ + if(i == ARRAY_SIZE(pintestconfigs)) + { + printf("Board type not supported %d\n",boardtype); + return FALSE; + } + /* Initialise the connectivity test + * related settings + */ + if((ret = ftm_bt_conn_init())) + { + /* Execute the test */ + ret = ftm_bt_conn_test_execute(); + } + /* Deinitliase the pin settings and i2c resources/mux + * settings + */ + ftm_bt_conn_deinit(); + return ret; +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_vs_event + +DESCRIPTION + Processes the VS event buffer and stores the App version and HW version + +DEPENDENCIES + NIL + +RETURN VALUE + NIL, Error in the event buffer will mean a NULL App version and Zero HW + version + +SIDE EFFECTS + None + +===========================================================================*/ +void ftm_bt_hci_hal_vs_event +( + const uint8* pEventBuffer, + uint8 nLength +) +{ + const uint8 poke_reg_addr[] = { 0xFF,0x0B,BT_QSOC_EDL_CMD_CODE,0x01, + 0x34,0x00,0x00,0x8C,0x04}; + if ( nLength > 3 ) + { + if ( ( pEventBuffer[ 0] == 0xFF) /* VS Event */ + && (pEventBuffer[1] > 5) /* VS Length > 5*/ + && (pEventBuffer[2] == BT_QSOC_EDL_CMD_CODE) + && (pEventBuffer[3] == BT_QSOC_VS_EDL_APPVER_RESP) + ) + { + if( NULL != bt_soc_app_version_string ) + { + free(bt_soc_app_version_string); + bt_soc_app_version_string = NULL; + } + bt_soc_app_version_string = (uint8 *)malloc(nLength-5); + if( NULL != bt_soc_app_version_string ) + { + memmove(bt_soc_app_version_string, + &pEventBuffer[5],nLength-5); + } + } + else if ( (nLength > 12) // make sure we have enough event bytes + && (!memcmp(pEventBuffer,poke_reg_addr,sizeof(poke_reg_addr)))) + { + bt_soc_hw_version[0] = pEventBuffer[9]; + bt_soc_hw_version[1] = pEventBuffer[10]; + bt_soc_hw_version[2] = pEventBuffer[11]; + bt_soc_hw_version[3] = pEventBuffer[12]; + } + } +} /* ftm_bt_hci_hal_vs_event */ + +int is_snoop_log_enabled () +{ + char value[PROPERTY_VALUE_MAX] = {'\0'}; + property_get("persist.service.bdroid.snooplog", value, "false"); + return (strcmp(value, "true") == 0); +} + +/*=========================================================================== +FUNCTION ftm_log_send_msg + +DESCRIPTION + Processes the buffer sent and sends it to the libdiag for sending the Cmd + response + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ + + +void ftm_log_send_msg(const uint8 *pEventBuf,int event_bytes) +{ + if (strcasecmp(transport_type, "smd") || ((pEventBuf != NULL) && (pEventBuf[0] == FTM_BT_CMD_NV_READ))) + { + /* ftmdaemon uses log opcode 0x1366 to send the HCI Event logs to QRCT via DIAG + * but Riva/Pronto also uses the same opcode to send the events over DIAG. + * So this is causing the QRCT to recv some time 2 events for one cmd and some + * time pkt corruption. + * With this change ftmdaemon wont send any logs to QRCT in case of Riva/Pronto + */ + ftm_bt_log_pkt_type* ftm_bt_log_pkt_ptr = NULL; + + if((pEventBuf == NULL) || (event_bytes == 0)) + return; + + if(!is_snoop_log_enabled()) + { + if(pEventBuf[0] == BT_HCI_ACL_PKT && log_status(LOG_BT_HCI_RX_ACL_C)) + { + ftm_bt_log_pkt_ptr = (ftm_bt_log_pkt_type *)log_alloc(LOG_BT_HCI_RX_ACL_C, + FTM_BT_LOG_HEADER_SIZE + (event_bytes-1)); + } + else if(pEventBuf[0] == BT_HCI_EVT_PKT && log_status(LOG_BT_HCI_EV_C)) + { + ftm_bt_log_pkt_ptr = (ftm_bt_log_pkt_type *)log_alloc(LOG_BT_HCI_EV_C, + FTM_BT_LOG_HEADER_SIZE + (event_bytes-1)); + } + } + if(pEventBuf[0] == FM_HCI_EVT_PKT ) + { + ftm_bt_log_pkt_ptr = (ftm_bt_log_pkt_type *)log_alloc(LOG_FTM_FM_C, + FTM_BT_LOG_HEADER_SIZE + (event_bytes-1)); + } + if(ftm_bt_log_pkt_ptr != NULL) + { + /* We should not send HCI event code 0x04 for the log opcode 0x1366. Hence + * move the pointer to the next location to skip first byte in HCI event. + */ + pEventBuf++; + memcpy((void *)ftm_bt_log_pkt_ptr->data,(void *)pEventBuf, event_bytes-1); + log_commit( ftm_bt_log_pkt_ptr ); + } + else + { + printf("ftm_log_send_msg: Dropping packet\n"); + return; + } + } +} +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_send_reset_cmd + +DESCRIPTION + Sends the HCI packet to reset the BT SoC + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE: If write Fails, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean ftm_bt_hci_hal_send_reset_cmd() +{ + const uint8 ResetCmd[4] = {0x01, 0x03, 0x0C, 0x00}; + global_state = FTM_SOC_RESET; + return ((ftm_bt_hci_hal_nwrite((uint8*)(&ResetCmd[0]), 4) == STATUS_SUCCESS) + ? TRUE: FALSE); +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_retrieve_send_nvm + +DESCRIPTION + Retrieves the NVM commands from the NVM parser module + and packages the VS HCI packet before calling ftm_bt_hci_hal_vs_sendcmd + When NVM entries are exhausted it Calls the next stage of Init to + disable sleep + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE: If Failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +#ifdef USE_LIBSOCCFG +boolean ftm_bt_hci_hal_retrieve_send_nvm() +{ + bt_qsoc_nvm_status nvm_status; + uint8 * nvm_ptr=NULL; + static const bt_qsoc_cfg_tbl_struct_type bt_qsoc_tag27 = + { + 0x04, {0x01, 0x1B, 0x01, 0x00} + }; + + /* Get the next NVM "string" */ + nvm_status = bt_qsoc_nvm_get_next_cmd(&nvm_ptr); + if(nvm_status == BT_QSOC_NVM_STATUS_SUCCESS) + { + if( nvm_ptr != NULL ) + { + return ftm_bt_hci_hal_vs_sendcmd( BT_QSOC_NVM_ACCESS_OPCODE, + (uint8 *)(&nvm_ptr[1]),(uint8)(nvm_ptr[0]) ); + } + } + else + { + bt_qsoc_nvm_close(); + sleep_stage = 0; + global_state = FTM_SOC_SLEEP_DISABLE; + if ( (ftm_bt_hci_hal_vs_sendcmd ( + BT_QSOC_NVM_ACCESS_OPCODE, + (uint8 *)(bt_qsoc_tag27.vs_cmd_data), + bt_qsoc_tag27.vs_cmd_len ) + ) != TRUE ) + return FALSE; + sleep_stage++; + } + + return TRUE; +} +#endif +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_vs_sendcmd + +DESCRIPTION + Helper Routine to process the VS HCI cmd and constucts the HCI packet before + calling ftm_bt_hci_send_cmd routine + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean ftm_bt_hci_hal_vs_sendcmd +( + uint16 opcode, + uint8 *pCmdBuffer, + uint8 nSize +) +{ + uint8 cmd[HC_VS_MAX_CMD_EVENT]; //JN: change this + request_status status = FALSE; + + int nwrite; + cmd[0] = BT_HCI_CMD_PKT; // JN: bluetooth header files in linux has a define + // HCI_COMMAND_PKT for this but do we want to use + // something thats command between QC platforms. + cmd[1] = (uint8)(opcode & 0xFF); + cmd[2] = (uint8)( (opcode>>8) & 0xFF); + cmd[3] = (uint8)(nSize); + + memcpy(&cmd[HCI_CMD_HDR_SIZE], pCmdBuffer, nSize); + + status = ftm_bt_hci_hal_nwrite((&cmd[0]), (HCI_CMD_HDR_SIZE+nSize)); + + if (status != STATUS_SUCCESS) + { + printf("Error->Send Header failed : %d\n",status); + return FALSE; + } + return TRUE; +} +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_read_app_version + +DESCRIPTION + Helper Routine to package the VS HCI cmd to read the Application version + and calls the ftm_bt_hci_hal_vs_sendcmd + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean ftm_bt_hci_hal_read_app_version() +{ + const uint8 getAppVerCmd[] = {0x06}; + global_state = FTM_SOC_READ_APP_VER; + ALOGV("ftm_bt_hci_hal_read_app_version:global_state = %d\n",global_state); + return ftm_bt_hci_hal_vs_sendcmd(BT_QSOC_EDL_CMD_OPCODE,(uint8 *)&getAppVerCmd[0],1); +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_read_hw_version + +DESCRIPTION + Helper Routine to package the VS HCI cmd to read the HW version + and calls the ftm_bt_hci_hal_vs_sendcmd + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean ftm_bt_hci_hal_read_hw_version() +{ + const uint8 getHWVerRegCmd[] = {0x0D, 0x34, 0x00, 0x00, 0x8C, 0x04 }; + global_state = FTM_SOC_READ_HW_VER; + return ftm_bt_hci_hal_vs_sendcmd(BT_QSOC_EDL_CMD_OPCODE,(uint8 *)&getHWVerRegCmd[0],6); +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_nvm_download_init + +DESCRIPTION + Routine to lookup the Soc type and initiate a Poke Table in case of a R3 + Soc type or else go ahead and proceed with the NvM open with runtime parameters + in AUTO MODE +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +#ifdef USE_LIBSOCCFG +boolean ftm_bt_hci_hal_nvm_download_init() +{ + bt_qsoc_config_params_struct_type run_time_params; + bt_qsoc_lookup_param soc_data; + bt_qsoc_nvm_status nvm_status; + bt_qsoc_enum_type soc_type; + boolean returnStatus = TRUE; + int loopCount; + bt_qsoc_enum_nvm_mode nvm_mode = NVM_AUTO_MODE; + + soc_data.app_ver_str = (char *)bt_soc_app_version_string; + soc_data.hw_ver_str = (char *)bt_soc_hw_version; + soc_type = bt_qsoc_type_look_up(&soc_data); + + if (soc_type == BT_QSOC_R2B) + { + printf("bt_hci_qcomm_init Failed R2B Not supported\n"); + returnStatus = FALSE; + } + else if (soc_type == BT_QSOC_R2C) + { + printf("bt_hci_qcomm_init Failed R2C Not supported"); + returnStatus = FALSE; + } + else + { +#ifdef FTM_DEBUG + printf("\nbt_hci_qcomm_init : Found QSoC type %d.\n", soc_type); +#endif + } + // default run-time parameters for SOC + memmove((uint8*)(&run_time_params.bd_address[0]), + (const uint8 *)(&(default_bt_bd_addr[0])), + BT_QSOC_MAX_BD_ADDRESS_SIZE); + run_time_params.refclock_type = BT_SOC_REFCLOCK_19P2MHZ; + run_time_params.clock_sharing =BT_SOC_CLOCK_SHARING_ENABLED; + run_time_params.soc_logging = 0; + run_time_params.bt_2_1_lisbon_disabled = 0; + /* ROM defualt LE & BR/EDR SoC power class configurations + */ + run_time_params.bt_qsoc_bredr_dev_class = BT_QSOC_DEV_CLASS1; + run_time_params.bt_qsoc_le_dev_class = BT_QSOC_DEV_CLASS2; + + /* After the Firmware is detected, start intializing the Poke table */ + if ( returnStatus != FALSE) + { + /* Patch: Pokes Only specific to R3 */ + global_state = FTM_SOC_POKE8_TBL_INIT; + if ( soc_type == BT_QSOC_R3 ) + { + printf("bt_hci_qcomm_init - Initialize R3 Poke table"); + loopCount = 0; + if ( (ftm_bt_hci_hal_vs_sendcmd( + BT_QSOC_EDL_CMD_OPCODE, + (uint8 *)bt_qsoc_vs_poke8_tbl_r3[loopCount].vs_poke8_data, + bt_qsoc_vs_poke8_tbl_r3[loopCount].vs_poke8_data_len) + ) != TRUE) + { + printf("bt_hci_qcomm_init Failed Poke VS Set Cmds"); + returnStatus = FALSE; + return returnStatus; + } + loopCount++; + } + memcpy(&soc_cfg_parameters.run_time_params,&run_time_params, + sizeof(bt_qsoc_config_params_struct_type)); + soc_cfg_parameters.soc_type = soc_type; + soc_cfg_parameters.nvm_mode = nvm_mode; + } + else + { + nvm_status = bt_qsoc_nvm_open(soc_type, nvm_mode, &run_time_params); + + if(nvm_status != BT_QSOC_NVM_STATUS_SUCCESS) + return FALSE; + global_state = FTM_SOC_DOWNLOAD_NVM; + /* Send all the NVM data to the SOC */ + returnStatus = ftm_bt_hci_hal_retrieve_send_nvm(); + } + + return returnStatus; +} +#endif +/*=========================================================================== +FUNCTION ftm_bt_hal_soc_init + +DESCRIPTION + Opens the handle to UART/SMD, configures the BT SoC high level power, + and initiates a read for application version + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hal_soc_init(int mode) +{ + request_status ret = 0; + int i,init_success = 0; + char value; + + if(!is_transportSMD && !isLatestTarget()){ + if(ftm_bt_power_hal_check() != BT_ON) + { + ret = ftm_bt_power_hal_set(BT_ON); + if(ret != STATUS_SUCCESS) + { + return FALSE; + } + } + else + return FALSE; + } + + ret = ftm_bt_hci_hal_init_transport(mode) ; +#ifdef FTM_DEBUG + printf("Transport open ret = %d\n",ret); +#endif + if(ret != STATUS_SUCCESS) + { + return FALSE; + } + if(mode != MODE_FM) { + /*ToDo: this can be featuturized under USE_LIBSOCCFG */ + return ftm_bt_hci_hal_read_app_version(); + } + return TRUE; +} + +/*=========================================================================== +FUNCTION ftm_bt_dispatch + +DESCRIPTION + Processes the BT FTM packet and dispatches the command to FTM HCI driver + +DEPENDENCIES + NIL + +RETURN VALUE + NIL,The error in the Command Processing is sent to the DIAG App on PC via + log packets + +SIDE EFFECTS + None + +===========================================================================*/ +void ftm_bt_dispatch(void *ftm_bt_pkt ,int cmd_len ) +{ + int ret; + memcpy(bt_ftm_buffer, (void*)ftm_bt_pkt, cmd_len); + ret = ftm_bt_hci_send_cmd((uint8 *) bt_ftm_buffer, cmd_len); + if (ret != TRUE) + { + ftm_log_send_msg(&event_buf_user_unknown_err[0],logsize); + printf("Error->Send FTM command failed:: %d\n", ret); + /** We had a premature exit here even before the command is Queued + * So notify the semaphore to wait for the next command + */ + sem_post(&semaphore_cmd_complete); + return ; + } + return ; +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_send_cmd + +DESCRIPTION + Helper Routine to process the HCI cmd and invokes the sub routines to intialise + /deinitialise the SoC if needed based on the state of the FTM module + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_send_cmd +( + uint8 * cmd_buf, /* pointer to Cmd */ + uint16 cmd_len /* Cmd length */ +) +{ + request_status ret = 0; + boolean status = FALSE; + if(NULL == cmd_buf) + { + return FALSE; + } + #ifdef BT_NV_SUPPORT + if (*cmd_buf == FTM_BT_CMD_NV_READ) + { + status = ftm_bt_send_nv_read_cmd(cmd_buf, cmd_len); + return status; + } + if (*cmd_buf == FTM_BT_CMD_NV_WRITE) + { + status = ftm_bt_send_nv_write_cmd(cmd_buf, cmd_len); + return status; + } +#endif /* End of BT_NV_SUPPORT */ + + if (*cmd_buf == FTM_BT_DRV_START_TEST) + { + /** Deinit the queue only if we are not initialised */ + if(global_state != FTM_SOC_NOT_INITIALISED) + { + ftm_bt_hci_hal_deinit_transport(); + if(!is_transportSMD && !isLatestTarget() ) + ftm_bt_power_hal_set(BT_OFF); + } + if(ftm_bt_conn_test() != TRUE) + return FALSE; +#ifdef FTM_DEBUG + printf("\nBT Soc Shutdown\n"); +#endif + global_state = FTM_SOC_NOT_INITIALISED; + } + + if(global_state == FTM_SOC_NOT_INITIALISED) + { +#ifdef HAS_BLUEZ_BUILDCFG + // BT disabled for FTM to procceed + // BT test is only aplicable for BLUEZ stack + if(system("/system/xbin/bttest disable") != 0) + { + printf("\nbttest disable failed"); + } + else + { + /* Bluetooth resources like bluetoothd & hciattach (if applicable + * based on transport) are asynchronously cleaned. + * This delay ensures that the transport device is released before + * being used by BT-FTM module. + * Note: This delay as expected is < 5 seconds timeout set up for + * the command complete of the received BT FTM commmand. */ + printf("\nsleep for 2 seconds"); + usleep(2000000); + } +#endif + ptr_powerup.cmd_buf = cmd_buf; + ptr_powerup.cmd_len = cmd_len; + /*To identify the transport based on the target name*/ + is_transportSMD = ftm_bt_hci_hal_set_transport(); + /* Creating power up thread for asynchronous completion of request */ + status = ftm_bt_hal_soc_init(MODE_BT); + if (*cmd_buf == FM_HCI_CMD_PKT) + status = ftm_bt_hal_soc_init(MODE_FM); + } + else + { + ret = ftm_bt_hci_hal_nwrite((uint8 *) cmd_buf, cmd_len); + if(ret == STATUS_SUCCESS) + status = TRUE; + } + return status; +} +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_read_event + +DESCRIPTION + Helper Routine to read the HCI event by invoking the UART/SMD HAL read routines + and returns the event in the pointer passed + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_hal_read_event (uint8 * event_buf_ptr) +{ + boolean status = FALSE; + boolean long_event = FALSE; + request_status rx_status; + int event_bytes; + int i, ret_val; + /*hci packet is not required to carry the Packet indicator (for UART interfaces) for msm8960 + as it is using share memory interface */ + rx_status = ftm_bt_hci_hal_nread(event_buf_ptr , PROTOCOL_BYTE_SIZE); + if (rx_status == STATUS_SHORT_READ) + { + printf("ftm_bt_hci_qcomm_handle_event: VERY SHORT READ!\n"); + return status; + } + + printf("%s:protocol byte: %02X\n", __FUNCTION__, event_buf_ptr[0]); + /* else get rest of the packet */ + if(event_buf_ptr[0] == BT_HCI_ACL_PKT) + { + rx_status = ftm_bt_hci_hal_nread(event_buf_ptr + PROTOCOL_BYTE_SIZE, HCI_ACL_HDR_SIZE - PROTOCOL_BYTE_SIZE); + if (rx_status == STATUS_SHORT_READ) + { + printf("ftm_bt_hci_qcomm_handle_event: VERY SHORT READ!\n"); + return status; + } + + event_bytes = ( event_buf_ptr[HCI_ACL_HDR_SIZE - 1 ] << 8 ) | ( event_buf_ptr[HCI_ACL_HDR_SIZE - 2 ] ) ; + if (HC_VS_MAX_ACL < event_bytes) + { + printf("ftm_bt_hci_qcomm_handle_event: LONG ACL PKT!\n"); + long_event = TRUE; + event_bytes = HC_VS_MAX_ACL; + } + + rx_status = ftm_bt_hci_hal_nread(&(event_buf_ptr[HCI_ACL_HDR_SIZE]), event_bytes); + + if (rx_status == STATUS_SUCCESS) + { + status = TRUE; + } + else + { + printf("ftm_bt_hci_qcomm_handle_event: SHORT READ!\n"); + fflush (stderr); + } + + event_bytes += HCI_ACL_HDR_SIZE; + } + else if((event_buf_ptr[0] == BT_HCI_EVT_PKT) || (event_buf_ptr[0] == FM_HCI_EVT_PKT)) + { + rx_status = ftm_bt_hci_hal_nread(event_buf_ptr + PROTOCOL_BYTE_SIZE, HCI_EVT_HDR_SIZE - PROTOCOL_BYTE_SIZE); + if (rx_status == STATUS_SHORT_READ) + { + printf("ftm_bt_hci_qcomm_handle_event: VERY SHORT READ!\n"); + return status; + } + + event_bytes = event_buf_ptr[HCI_EVT_HDR_SIZE - 1 ]; + if (HC_VS_MAX_CMD_EVENT < event_bytes) + { + printf("ftm_bt_hci_qcomm_handle_event: LONG EVENT!\n"); + long_event = TRUE; + event_bytes = HC_VS_MAX_CMD_EVENT; + } + rx_status = ftm_bt_hci_hal_nread(&(event_buf_ptr[HCI_EVT_HDR_SIZE]), event_bytes); + + if (rx_status == STATUS_SUCCESS) + { + status = TRUE; + } + else + { + printf("ftm_bt_hci_qcomm_handle_event: SHORT READ!\n"); + fflush (stderr); + } + + event_bytes += HCI_EVT_HDR_SIZE; + } + else + { + printf("ftm_bt_hci_qcomm_handle_event: Unknown packet type!\n"); + return status; + } + + /* + ** Validate if the loopback command event has arrived and has succsfull + ** response from FW, if yes enable slimbus to validate pinc connectivity + ** test + */ + + if ( event_buf_ptr[0] == BT_HCI_EVT_PKT && + event_buf_ptr[LOOP_BACK_EVT_OGF_BIT] == LOOP_BACK_EVT_OGF && + event_buf_ptr[LOOP_BACK_EVT_OCF_BIT] == LOOP_BACK_EVT_OCF && + event_buf_ptr[LOOP_BACK_EVT_STATUS_BIT] == LOOP_BACK_EVT_STATUS && + is_slim_bus_test == 1) + { + printf("\nInitializing slim bus for pin-connectivity\n"); + fd_pintest = open("/dev/pintest",O_RDONLY, O_NONBLOCK); + if(fd_pintest < 0) + printf("\nfailed to open\n"); + ret_val = ioctl(fd_pintest, BT_CMD_SLIM_TEST, NULL); + event_buf_ptr[PIN_CON_EVENT_LEN_BIT] = PIN_CON_EVENT_LEN; + event_buf_ptr[PIN_CON_EVT_OCF_BIT] = PIN_CON_CMD_OCF; + event_buf_ptr[PIN_CON_EVT_OGF_BIT] = PIN_CON_CMD_OGF; + event_buf_ptr[PIN_CON_EVT_SUB_OP_BIT] = PIN_CON_CMD_SUB_OP; + event_buf_ptr[PIN_CON_INTERFACE_ID_EVT_BIT] = PIN_CON_INTERFACE_ID; + event_bytes += EXT_PIN_CON_LEN; + if( ret_val < 0) { + event_buf_ptr[PIN_CON_EVT_STATUS_BIT] = ret_val; + printf("\nFailed to initialise slim bus %d\n", ret_val); + status = FALSE; + } else { + event_buf_ptr[PIN_CON_EVT_STATUS_BIT] = 0; + printf("\nSlim bus initiazed succesfully\n"); + } + } + + if (verbose == 1) + { + if((event_buf_ptr[0] == BT_HCI_EVT_PKT) || (event_buf_ptr[0] == FM_HCI_EVT_PKT)) + { + printf("[%s] %s: EVT:", get_current_time(), __FUNCTION__); + for (i = 0; i < event_bytes; i++) + { + printf(" %02X", event_buf_ptr[i]); + } + + printf(long_event? " ...\n": "\n"); + } + else if (event_buf_ptr[0] == BT_HCI_ACL_PKT) + { + printf("[%s] %s: ACL packet: %d bytes\n", get_current_time(), __FUNCTION__, event_bytes); + + printf(long_event? " ...\n": "\n"); + } + } + ftm_log_send_msg(event_buf_ptr,event_bytes); + return status; +} + +boolean ftm_bt_hci_hal_retrieve_nvm_and_send_efs(FILE* fp) +{ + unsigned char payload[NVM_PAYLOAD_MAXLENGTH]; + unsigned char header[HCI_CMD_HDR_SIZE]; + int n = 0; + int len=0; + static const bt_qsoc_cfg_tbl_struct_type bt_qsoc_tag27 = + { + 0x04, {0x01, 0x1B, 0x01, 0x00} + }; + + n = fread(header, 1, HCI_CMD_HDR_SIZE, fp); + + if(feof(fp)) + { + if(nvm_cmd) + free(nvm_cmd); + fclose(fp); + sleep_stage = 0; + if(!isLatestTarget()){//Do not disable sleep for ROME + global_state = FTM_SOC_SLEEP_DISABLE; + if ( (ftm_bt_hci_hal_vs_sendcmd ( + BT_QSOC_NVM_ACCESS_OPCODE,(uint8 *)(bt_qsoc_tag27.vs_cmd_data), + bt_qsoc_tag27.vs_cmd_len )) != TRUE ) + return FALSE; + sleep_stage++; + } + return TRUE; + } + + /*Last byte gives the length*/ + len = (int)header[3]; + + printf("PayLoad length: %d\n", len); + n = fread(payload, 1, len, fp); + + /*Form the resultant buffer*/ + if(nvm_cmd) + { + /*Delete the previous buffer*/ + free(nvm_cmd); + } + nvm_cmd = (unsigned char*)malloc(HCI_CMD_HDR_SIZE+len); + if(nvm_cmd) + { + memcpy(nvm_cmd, header, HCI_CMD_HDR_SIZE); + memcpy(nvm_cmd+HCI_CMD_HDR_SIZE, payload, len); + + global_state = FTM_SOC_DOWNLOAD_NVM_EFS; + + if(ftm_bt_hci_hal_nwrite((uint8 *) &nvm_cmd[0],HCI_CMD_HDR_SIZE+len) == STATUS_SUCCESS) + return TRUE; + } + return FALSE; +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_qcomm_handle_event + +DESCRIPTION + Routine called by the HAL layer reader thread to process the HCI events + The post conditions of each event is covered in a state machine pattern + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean ftm_bt_hci_qcomm_handle_event () +{ + boolean status = TRUE; + char filename[MAX_FILE_NAME]; +#ifdef USE_LIBSOCCFG + bt_qsoc_nvm_status nvm_status; +#endif + int ret = 0; +#ifdef FTM_DEBUG + printf("ftm_bt_hci_qcomm_handle_event global_state --> %d\n",global_state); +#endif + switch(global_state) + { + case FTM_SOC_READ_APP_VER: + /* Read the VS event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) { + printf("Failed to read VS event"); + return FALSE; + } + ftm_bt_hci_hal_vs_event(&event_buf[1], 2 + event_buf[2]); + /* Read out the HCI event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) { + printf("Failed to read HCI event"); + return FALSE; + } + /* Until libsoccfg is part of the Android system + * we will use the system call to perform the + * soc initialisation + */ +#ifndef USE_LIBSOCCFG + if(!isLatestTarget()) + { + ret = system("/system/bin/hci_qcomm_init -e -H"); + if(ret != 0) + { + return FALSE; + } + else + { + global_state = FTM_SOC_INITIALISED; + } + } + else + { +#if 0//Do not Disable Sleep for ROME + global_state = FTM_SOC_SLEEP_DISABLE; + if ( (ftm_bt_hci_hal_vs_sendcmd(BT_QSOC_NVM_ACCESS_OPCODE, + (uint8 *)(bt_qsoc_tag17_latest_hw.vs_cmd_data), + bt_qsoc_tag17.vs_cmd_len )) != TRUE ) + { + return FALSE; + } +#endif + if(ftm_bt_hci_hal_send_reset_cmd() != TRUE) + return FALSE; + } + printf("\nFTM Global state = %d\n",global_state); + // Dont send HCI reset before inband sleep disable + if (!isLatestTarget()) + { + if(ptr_powerup.cmd_buf[0] == FTM_BT_DRV_START_TEST) + { + ftm_log_send_msg(&event_buf_user_cmd_pass[0],logsize); + sem_post(&semaphore_cmd_complete); + return TRUE; + } + if(ftm_bt_hci_hal_nwrite((uint8 *) ptr_powerup.cmd_buf, + ptr_powerup.cmd_len) != STATUS_SUCCESS) + return FALSE; + } +#else + if(ftm_bt_hci_hal_read_hw_version() != TRUE) + return FALSE; +#ifdef FTM_DEBUG + printf("FTM_SOC_READ_APP_VER Done\n"); +#endif +#endif + break; +#ifdef USE_LIBSOCCFG + case FTM_SOC_READ_HW_VER: + /* Read the VS event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + ftm_bt_hci_hal_vs_event(&event_buf[1], 2 + event_buf[2]); + /* Read out the HCI event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + + if(ftm_bt_hci_hal_nvm_download_init() != TRUE) + return FALSE; +#ifdef FTM_DEBUG + printf("FTM_SOC_READ_HW_VER Done\n"); +#endif + break; + case FTM_SOC_POKE8_TBL_INIT : + /* Read the VS event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + /* Read out the HCI event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + if(loopCount < BT_QSOC_R3_POKETBL_COUNT) + { + if ( (ftm_bt_hci_hal_vs_sendcmd( + BT_QSOC_EDL_CMD_OPCODE, + (uint8 *)bt_qsoc_vs_poke8_tbl_r3[loopCount].vs_poke8_data, + bt_qsoc_vs_poke8_tbl_r3[loopCount].vs_poke8_data_len) + ) != TRUE) + { + printf("bt_hci_qcomm_init Failed Poke VS Set Cmds"); + return FALSE; + } + loopCount++; + } + else + { + nvm_status = bt_qsoc_nvm_open(soc_cfg_parameters.soc_type, + soc_cfg_parameters.nvm_mode, + &soc_cfg_parameters.run_time_params); + + if(nvm_status != BT_QSOC_NVM_STATUS_SUCCESS) + return FALSE; + global_state = FTM_SOC_DOWNLOAD_NVM; + /* Send all the NVM data to the SOC */ + if(ftm_bt_hci_hal_retrieve_send_nvm() != TRUE) + return FALSE; + } + break; + case FTM_SOC_DOWNLOAD_NVM: + /* Read the VS event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + /* Read out the HCI event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + if(ftm_bt_hci_hal_retrieve_send_nvm()!= TRUE) + return FALSE; +#ifdef FTM_DEBUG + printf("FTM_SOC_DOWNLOAD_NVM in progress\n"); +#endif + break; +#endif //USE_LIBSOCCFG + + case FTM_SOC_DOWNLOAD_NVM_EFS: + /* Read the VS event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + /* Read out the HCI event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + if(ftm_bt_hci_hal_retrieve_nvm_and_send_efs(fp) != TRUE) + return FALSE; + printf("FTM_SOC_DOWNLOAD_NVM in progress\n"); + break; + + case FTM_SOC_SLEEP_DISABLE: + /* Read the VS event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + /* Read out the HCI event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + if(sleep_stage == 1) + { +#ifdef FTM_DEBUG + printf("Sleep Stage tag 17 set\n"); +#endif + if ( (ftm_bt_hci_hal_vs_sendcmd(BT_QSOC_NVM_ACCESS_OPCODE, + (uint8 *)(bt_qsoc_tag17.vs_cmd_data), + bt_qsoc_tag17.vs_cmd_len )) != TRUE ) + { + return FALSE; + } + sleep_stage++; + return TRUE; + } + if(ftm_bt_hci_hal_send_reset_cmd() != TRUE) + return FALSE; +#ifdef FTM_DEBUG + printf("FTM_SOC_SLEEP_DISABLE done\n"); +#endif + break; + case FTM_SOC_RESET: + /* Read out the HCI event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + global_state = FTM_SOC_INITIALISED; + if(ptr_powerup.cmd_buf[0] == FTM_BT_DRV_START_TEST) + { + ftm_log_send_msg(&event_buf_user_cmd_pass[0],logsize); + sem_post(&semaphore_cmd_complete); + return TRUE; + } + if(ftm_bt_hci_hal_nwrite((uint8 *) ptr_powerup.cmd_buf, + ptr_powerup.cmd_len) != STATUS_SUCCESS) + return FALSE; +#ifdef FTM_DEBUG + printf("FTM_SOC_RESET done queued the Command\n"); +#endif + break; + case FTM_SOC_INITIALISED : + /* Read out the HCI event*/ + if(ftm_bt_hci_hal_read_event(event_buf) != TRUE) + return FALSE; + sem_post(&semaphore_cmd_complete); + break; + default : + return FALSE; + } + return status; +} + +/*=========================================================================== +FUNCTION isLatestTarget + +DESCRIPTION +For all the target/solution which has Bluedroid as stack and libbt-vendor as +vendor initialization component considered as latest target + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean isLatestTarget() +{ +#ifdef ANDROID + int ret = 0; + char bt_soc_type[PROPERTY_VALUE_MAX]; + ret = property_get("qcom.bluetooth.soc", bt_soc_type, NULL); + if (ret != 0) + { + if (!strncasecmp(bt_soc_type, "ath3k", sizeof("ath3k"))) + { + return FALSE; + } + } + return TRUE; +#else + return TRUE; +#endif +} diff --git a/feeds/wifi-ax/ftm/src/ftm_bt.h b/feeds/wifi-ax/ftm/src/ftm_bt.h new file mode 100755 index 000000000..c807977e5 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt.h @@ -0,0 +1,289 @@ +/*========================================================================== + + FTM BT Task Header File + +Description + Global Data declarations of the ftm bt component. + +# Copyright (c) 2010-2011, 2013-2014 by Qualcomm Technologies, Inc. +# All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +09/28/11 rrr Moved peristent NV item related APIs to CPP, + for having BD address being programmed twice if previous + BD address was random generated. +09/03/11 agaja Added support for NV_READ and NV_WRITE Commands to write + onto Persist File system +02/08/11 braghave Changes to read the HCI commands from a binary file for + non-Android case +06/18/10 rakeshk Created a header file to hold the definitons for ftm bt + task +===========================================================================*/ + +#ifdef CONFIG_FTM_BT + +#include "diagpkt.h" +#include +#ifdef USE_LIBSOCCFG +#include "btqsocnvm.h" +#include "btqsocnvmutils.h" +#endif + +/* ------------------------------------------------------------------------- +** Definitions and Declarations +** ------------------------------------------------------------------------- */ + +#define FTM_BT_CMD_CODE 4 /* BT FTM Command code */ +#define FTM_FM_CMD_CODE 28 /* FM FTM Command code */ +#define HCI_EVT_HDR_SIZE 3 +#define HCI_ACL_HDR_SIZE 5 +#define PROTOCOL_BYTE_SIZE 1 +#define HC_VS_MAX_CMD_EVENT 260 +#define HC_VS_MAX_ACL 1200 +#define FTM_BT_HCI_USER_CMD 0 +#define BT_FTM_CMD_RSP_LEN 1100 +#define FTM_BT_DRV_START_TEST 0xA + +/* MACROS for pin connectivty test*/ +#define BT_CMD_SLIM_TEST 0xBFAC +#define LOOP_BACK_EVT_OGF 0x02 +#define LOOP_BACK_EVT_OCF 0x18 +#define LOOP_BACK_EVT_STATUS 0x00 +#define LOOP_BACK_EVT_OGF_BIT 0x04 +#define LOOP_BACK_EVT_OCF_BIT 0x05 +#define LOOP_BACK_EVT_STATUS_BIT 0x06 + + +#define FTM_BT_LOG_HEADER_SIZE (sizeof(ftm_bt_log_pkt_type) - 1) + + +/* Vendor Specific command codes */ +#define BT_QSOC_EDL_CMD_OPCODE (0xFC00) +#define BT_QSOC_NVM_ACCESS_OPCODE (0xFC0B) + +#define BT_QSOC_EDL_CMD_CODE (0x00) +#define BT_QSOC_NVM_ACCESS_CODE (0x0B) +#define BT_QSOC_VS_EDL_APPVER_RESP (0x02) + +#ifndef HC_VS_MAX_CMD_EVENT +#define HC_VS_MAX_CMD_EVENT 260 +#endif /* HC_VS_MAX_CMD_EVENT */ + +#define BT_QSOC_MAX_NVM_CMD_SIZE 0x64 /* Maximum size config (NVM) cmd */ +#define BT_QSOC_MAX_BD_ADDRESS_SIZE 0x06 /**< Length of BT Address */ + +#ifndef HCI_CMD_HDR_SIZE +#define HCI_CMD_HDR_SIZE 4 +#endif /* HCI_CMD_HDR_SIZE */ + +#ifndef HCI_EVT_HDR_SIZE +#define HCI_EVT_HDR_SIZE 3 +#endif /* HCI_EVT_HDR_SIZE */ + +#define FTM_BT_LOG_PKT_ID 0x01 + + +#define BT_HCI_CMD_PKT 0x01 +#define BT_HCI_ACL_PKT 0x02 +#define BT_HCI_EVT_PKT 0x04 + +#define BT_HCI_CMD_CMPLT_EVT 0x0E +#define FM_HCI_EVT_PKT 0x14 +#define FM_HCI_CMD_PKT 0x11 + +extern int boardtype; + +/* VS command structure */ +typedef struct +{ + uint8 vs_cmd_len; + uint8 vs_cmd_data[BT_QSOC_MAX_NVM_CMD_SIZE]; +} bt_qsoc_cfg_tbl_struct_type; + +/* First Commamd structure - Used to store the First command for later +* processing +*/ +struct first_cmd +{ + uint8 *cmd_buf; + int cmd_len; +}; + +/* FTM Global State - Enum defines the various states of the FTM +* module +*/ +typedef enum ftm_state +{ + FTM_SOC_NOT_INITIALISED, + FTM_SOC_READ_APP_VER, + FTM_SOC_READ_HW_VER, + FTM_SOC_POKE8_TBL_INIT, + FTM_SOC_DOWNLOAD_NVM, + FTM_SOC_DOWNLOAD_NVM_EFS, + FTM_SOC_SLEEP_DISABLE, + FTM_SOC_RESET, + FTM_SOC_INITIALISED +}ftm_state; +/* FTM CMD status */ +typedef enum ftm_log_packet_type +{ + FTM_USER_CMD_PASS, + FTM_USER_CMD_FAIL, + FTM_HCI_EVENT +}ftm_log_packet_type; + +/* FTM Log Packet - Used to send back the event of a HCI Command */ +typedef PACKED struct +{ + log_hdr_type hdr; + byte data[1]; /* Variable length payload, + look at FTM log id for contents */ +} ftm_bt_log_pkt_type; + + +/* FTM (BT) PKT Header */ +typedef PACKED struct +{ + word cmd_id; /* command id (required) */ + word cmd_data_len; /* request pkt data length, excluding the diag and ftm headers + (optional, set to 0 if not used)*/ + word cmd_rsp_pkt_size; /* rsp pkt size, size of response pkt if different then req pkt + (optional, set to 0 if not used)*/ +} ftm_bt_cmd_header_type; + +/* Bluetooth FTM packet */ +typedef PACKED struct +{ + diagpkt_subsys_header_type diag_hdr; + ftm_bt_cmd_header_type ftm_hdr; + byte data[1]; +} ftm_bt_pkt_type; + +/* SoC Cfg open Struct*/ +#ifdef USE_LIBSOCCFG +typedef struct +{ + bt_qsoc_config_params_struct_type run_time_params; + bt_qsoc_enum_nvm_mode nvm_mode; + bt_qsoc_enum_type soc_type; +}ftm_bt_soc_runtime_cfg_type; +#endif + +/*=========================================================================== +FUNCTION ftm_bt_err_timedout + +DESCRIPTION + This routine triggers the shutdown of the HCI and Power resources in case + a HCI command previously sent times out. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN NIL + +SIDE EFFECTS + NONE + +===========================================================================*/ +void ftm_bt_err_timedout(); + +/*=========================================================================== +FUNCTION ftm_bt_dispatch + +DESCRIPTION + Processes the BT FTM packet and dispatches the command to FTM HCI driver + +DEPENDENCIES + NIL + +RETURN VALUE + NIL,The error in the Command Processing is sent to the DIAG App on PC via + log packets + +SIDE EFFECTS + None + +===========================================================================*/ +void ftm_bt_dispatch(void *ftm_bt_pkt ,int cmd_len ); + +/*=========================================================================== +FUNCTION bt_hci_send_ftm_cmd + +DESCRIPTION + Helper Routine to process the HCI cmd and invokes the sub routines to intialise + the SoC if needed based on the state of the FTM module + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean ftm_bt_hci_send_cmd +( + uint8 * cmd_buf, /* pointer to Cmd */ + uint16 cmd_len /* Cmd length */ +); + +/*=========================================================================== +FUNCTION bt_hci_hal_vs_sendcmd + +DESCRIPTION + Helper Routine to process the VS HCI cmd and constucts the HCI packet before + calling bt_hci_send_ftm_cmd routine + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_hal_vs_sendcmd +( +uint16 opcode, /* Opcode */ +uint8 *pCmdBuffer, /* Pointer to Payload*/ +uint8 nSize /* Cmd Size */ +); + +/*=========================================================================== +FUNCTION isLatestTarget + +DESCRIPTION +For all the target/solution which has Bluedroid as stack and libbt-vendor as +vendor initialization component considered as latest target + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean isLatestTarget(); +char *get_current_time(void); +#endif /* CONFIG_FTM_BT */ diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_common.h b/feeds/wifi-ax/ftm/src/ftm_bt_common.h new file mode 100755 index 000000000..5704ba65e --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_common.h @@ -0,0 +1,115 @@ +/*========================================================================== + + FTM BT Commom Header File + +Description + The header file includes helper enums for request_status and bt_power_state. + +# Copyright (c) 2010-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +09/28/11 rrr Common utility API abstracted, +06/18/10 rakeshk Created a header file to hold the helper enums for + request_status and bt_power_state +========================================================================*/ + +#ifdef CONFIG_FTM_BT + +#include "event.h" +#include "msg.h" +#include "log.h" + +#include "diag_lsm.h" +#include + +#ifndef __FTM_BT_COMMON_H__ + +#define __FTM_BT_COMMON_H__ + +#define TRUE 1 +#define FALSE 0 + +/* request_status - enum to encapuslate the status of a HAL request*/ +typedef enum request_status +{ + STATUS_SUCCESS, + STATUS_FAIL, + STATUS_NO_RESOURCES, + STATUS_SHORT_WRITE, + STATUS_SHORT_READ +}request_status; + +/* request_status - enum to encapuslate the possible statea of BT power*/ +typedef enum bt_power_state +{ + BT_OFF = 0x30, /* Its the value 0 to be input to rfkill driver */ + BT_ON = 0x31 /* ASCII value for '1'*/ +}bt_power_state; + +typedef enum +{ + FTM_BT_DRV_NO_ERR = 0, + FTM_BT_DRV_CONN_TEST_FAILS, + FTM_BT_DRV_QSOC_POWERUP_FAILS, + FTM_BT_DRV_RX_PKT_TYPE_NOT_SUPPORTED, + FTM_BT_DRV_SIO_OPEN_FAILS, + FTM_BT_DRV_NO_SOC_RSP_TOUT, + FTM_BT_DRV_BAD_NVM, +#ifdef BT_NV_SUPPORT + FTM_BT_NV_READ_FAIL, + FTM_BT_NV_WRITE_FAIL, +#endif + FTM_BT_DRV_UNKNOWN_ERR +} ftm_bt_drv_err_state_type; + +/*=========================================================================== +FUNCTION ftm_bt_hci_qcomm_handle_event + +DESCRIPTION + Routine called by the HAL layer reader thread to process the HCI events + The post conditions of each event is covered in a state machine pattern + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_qcomm_handle_event(); + +/*=========================================================================== +FUNCTION ftm_log_send_msg + +DESCRIPTION + Processes the buffer sent and sends it to the libdiag for sending the Cmd + response + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ + + +void ftm_log_send_msg(const uint8 *pEventBuf,int event_bytes); +#endif //__FTM_BT_COMMON_H__ +#endif /* CONFIG_FTM_BT */ diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_hci_hal.h b/feeds/wifi-ax/ftm/src/ftm_bt_hci_hal.h new file mode 100755 index 000000000..c1b82efa1 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_hci_hal.h @@ -0,0 +1,161 @@ +/*========================================================================== + + FTM BT HCI PFAL Header File + +Description + Warpper API definitions of the ftm bt hci hal component. + +# Copyright (c) 2010 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/18/10 rakeshk Created a header file to hold the wrapper HAL + definitions for HCI UART control +===========================================================================*/ + +#include "ftm_bt_common.h" +#include "ftm_bt_hci_pfal.h" +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_set_transport + +DESCRIPTION + sets the type of transport based on the msm type + +DEPENDENCIES + NIL + +RETURN VALUE +returns the type of transport + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_hal_set_transport() +{ + return ftm_bt_hci_pfal_set_transport(); +} +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_deinit_transport + +DESCRIPTION + Platform independent wrapper API which intiatea a De-intialise of UART/SMD + resources with PFAL layer and returns the status of the PFAL operation + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_hal_deinit_transport() +{ + return ftm_bt_hci_pfal_deinit_transport(); +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_init_transport + +DESCRIPTION + Platform independent wrapper API which intiatea a intialise of UART/SMD + resources with PFAL layer and returns the status of the PFAL operation + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_hal_init_transport (int mode) +{ + return ftm_bt_hci_pfal_init_transport(mode); +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_nwrite + +DESCRIPTION + Platform independent wrapper API which intiates a write operation + with the PFAL layer and returns the status of the PFAL operation. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_hal_nwrite(uint8 *buf, int size) +{ + return ftm_bt_hci_pfal_nwrite(buf,size); + +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_nread + +DESCRIPTION + Platform independent wrapper API which intiates a read operation + with the PFAL layer and returns the status of the PFAL operation. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_hal_nread(uint8 *buf, int size) +{ + return ftm_bt_hci_pfal_nread(buf,size); +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_hal_changebaudrate + +DESCRIPTION + Platform independent wrapper API which intiatea a UART baud rate change + with the PFAL layer and returns the status of the PFAL request. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + TRUE if SUCCESS, else FAIL + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_hal_changebaudrate (uint32 new_baud) +{ + return ftm_bt_hci_pfal_changebaudrate(new_baud); +} + diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal.h b/feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal.h new file mode 100755 index 000000000..7bc199e41 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal.h @@ -0,0 +1,177 @@ +/*========================================================================== + + FTM BT HCI PFAL Header File + +Description + PFAL API declarations of the ftm bt hci pfal component. + +# Copyright (c) 2010 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/18/10 rakeshk Created a header file to hold the PFAL declarations for + HCI UART programming +===========================================================================*/ +#include "ftm_bt_common.h" + +#ifndef __FTM_BT_HCI_PFAL_H__ +#define __FTM_BT_HCI_PFAL_H__ + +#define PIN_CON_CMD_OGF 0xFC +#define PIN_CON_CMD_OCF 0x0C +#define PIN_CON_CMD_SUB_OP 0x38 +#define PIN_CON_INTERFACE_ID 0x01 +#define PIN_CON_EVENT_LEN 0x06 +#define EXT_PIN_CON_LEN 0x02 + +#define PIN_CON_CMD_OCF_BIT 0x01 +#define PIN_CON_CMD_OGF_BIT 0x02 +#define PIN_CON_CMD_SUBOP_BIT 0x04 +#define PIN_CON_CMD_INTER_BIT 0x05 + +#define PIN_CON_EVT_OGF_BIT 0x05 +#define PIN_CON_EVT_OCF_BIT 0x04 +#define PIN_CON_EVT_SUB_OP_BIT 0x07 +#define PIN_CON_INTERFACE_ID_EVT_BIT 0x08 +#define PIN_CON_EVENT_LEN_BIT 0x02 +#define PIN_CON_EVT_STATUS_BIT 0x06 + +#define LOG_TAG "ftmdaemon" + +#define PRI_INFO " I" +#define PRI_WARN " W" +#define PRI_ERROR " E" +#define PRI_DEBUG " D" +#define PRI_VERB " V" + +#define ALOG(pri, tag, fmt, arg...) fprintf(stderr, tag pri ": " fmt"\n", ##arg) +#define ALOGV(fmt, arg...) ALOG(PRI_VERB, LOG_TAG, fmt, ##arg) +#define ALOGD(fmt, arg...) ALOG(PRI_DEBUG, LOG_TAG, fmt, ##arg) +#define ALOGI(fmt, arg...) ALOG(PRI_INFO, LOG_TAG, fmt, ##arg) +#define ALOGW(fmt, arg...) ALOG(PRI_WARN, LOG_TAG, fmt, ##arg) +#define ALOGE(fmt, arg...) ALOG(PRI_ERROR, LOG_TAG, fmt, ##arg) + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_set_transport + +DESCRIPTION + sets the type of transport based on the msm type + +DEPENDENCIES + NIL + +RETURN VALUE +returns the type of transport + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_pfal_set_transport(void); + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_deinit_transport + +DESCRIPTION + Platform specific routine to de-intialise the UART/SMD resource. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_pfal_deinit_transport(); + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_init_transport + +DESCRIPTION + Platform specific routine to intialise the UART/SMD resources. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_pfal_init_transport (); + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_nwrite + +DESCRIPTION + Platform specific routine to write the data in the argument to the UART/SMD + port intialised. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_pfal_nwrite(uint8 *buf, int size); + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_nread + +DESCRIPTION + Platform specific routine to read data from the UART/SMD port intialised into + the buffer passed in argument. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_pfal_nread(uint8 *buf, int size); + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_changebaudrate + +DESCRIPTION + Platform specific routine to intiate a change in baud rate + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + TRUE if SUCCESS, else FALSE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_pfal_changebaudrate (uint32 new_baud); + +#endif //__FTM_BT_HCI_PFAL_H__ diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal_linux.c b/feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal_linux.c new file mode 100755 index 000000000..e339567b7 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_hci_pfal_linux.c @@ -0,0 +1,674 @@ +/*========================================================================== + + FTM Platform specfic HCI UART/SMD File + +Description + Platform specific routines to program the UART/SMD descriptors + +# Copyright (c) 2010-2011, 2013 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/07/11 bneti Add support smd support for msm8960 +06/18/10 rakeshk Created a source file to implement platform specific + routines for UART +07/07/10 rakeshk Removed the conversion of 3.2 Mbps baud rate +01/07/10 rakeshk Added support for verbose logging of Cmd and events +===========================================================================*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "bt_vendor_lib.h" +#include "ftm_bt_hci_pfal.h" +#include "ftm_common.h" +#include +#include "log.h" +#include +#include "hidl_client.h" + +#ifdef ANDROID +#define VENDOR_LIB "libbt-vendor.so" +#else +#define VENDOR_LIB "libbt-vendor.so.0" +#endif + +uint8_t is_slim_bus_test = 0; +#define UNUSED(x) (void)(x) + +/*identify the transport type*/ +static char *transport_dev; + +typedef enum { + BT_SOC_DEFAULT = 0, + BT_SOC_SMD = BT_SOC_DEFAULT, + BT_SOC_AR3K, + BT_SOC_ROME, + BT_SOC_CHEROKEE, + BT_SOC_NAPIER, + /* Add chipset type here */ + BT_SOC_RESERVED +} bt_soc_type; + +static void vendor_fwcfg_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void vendor_scocfg_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void vendor_lpm_vnd_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void vendor_audio_state_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void* vendor_alloc(int size) { + UNUSED(size); + return NULL; +} +static void vendor_dealloc(void *p_buf) { + UNUSED(p_buf); +} +static uint8_t vendor_xmit_cb(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback) { + UNUSED(opcode); + UNUSED(p_buf); + UNUSED(p_cback); + return 0; +} +static void vendor_epilog_cb(bt_vendor_op_result_t result) { + UNUSED(result); +} +static void vendor_a2dp_offload_cb(bt_vendor_op_result_t result, bt_vendor_opcode_t op, unsigned char handle) { + UNUSED(result); + UNUSED(op); + UNUSED(handle); +} + + +bt_vendor_interface_t *vendor_interface=NULL; +static const bt_vendor_callbacks_t vendor_callbacks = { + sizeof(bt_vendor_callbacks_t), + vendor_fwcfg_cb, + vendor_scocfg_cb, + vendor_lpm_vnd_cb, + vendor_audio_state_cb, + vendor_alloc, + vendor_dealloc, + vendor_xmit_cb, + vendor_epilog_cb, + vendor_a2dp_offload_cb +}; + + +/*BT HS UART TTY DEVICE */ +#define BT_HS_UART_DEVICE "/dev/ttyHS0" + +/*BT RIVA-SMD CHANNELS */ +#define APPS_RIVA_BT_ACL_CH "/dev/smd2" +#define APPS_RIVA_BT_CMD_CH "/dev/smd3" + +/* Variables to identify the platform */ +char transport_type[PROPERTY_VALUE_MAX]; +static boolean is_transportSMD; + +extern int soc_type; + +/* Reader thread handle */ +pthread_t hci_cmd_thread_hdl; +/* Pipe file descriptors for cancelling read operation */ +int pipefd[2]; +/* Transport file descriptor */ +int fd_transport; +/* Starting baud rate to init the tty device */ +int starting_baud = 115200; +/* Verbose output monitoring variable */ +int verbose = 1; +/* Defintion to convert integer baud rate to the + * Data type understood by tty device + */ +#define BAUDCLAUS(i) case (i): return ( B##i ) + +/*=========================================================================== +FUNCTION convert_baud + +DESCRIPTION + Routine to convert the integer baud rate to type speed_t + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + Converted Baud rate, else default 0 + +SIDE EFFECTS + None + +===========================================================================*/ +static speed_t convert_baud(uint32 baud_rate) +{ + switch (baud_rate) + { + BAUDCLAUS(50); + BAUDCLAUS(75); + BAUDCLAUS(110); + BAUDCLAUS(134); + BAUDCLAUS(150); + BAUDCLAUS(200); + BAUDCLAUS(300); + BAUDCLAUS(600); + BAUDCLAUS(1200); + BAUDCLAUS(1800); + BAUDCLAUS(2400); + BAUDCLAUS(4800); + BAUDCLAUS(9600); + BAUDCLAUS(19200); + BAUDCLAUS(38400); + BAUDCLAUS(57600); + BAUDCLAUS(115200); + BAUDCLAUS(230400); + BAUDCLAUS(460800); + BAUDCLAUS(500000); + BAUDCLAUS(576000); + BAUDCLAUS(921600); + BAUDCLAUS(1000000); + BAUDCLAUS(1152000); + BAUDCLAUS(1500000); + BAUDCLAUS(2000000); + BAUDCLAUS(2500000); + BAUDCLAUS(3000000); + BAUDCLAUS(3500000); + BAUDCLAUS(4000000); + + default: return 0; + } +} + +/*=========================================================================== +FUNCTION ftm_readerthread + +DESCRIPTION + Thread Routine to perfom asynchrounous handling of events coming on Uart/Smd + descriptor. It invokes a callback to the FTM BT layer to intiate a request + to read event bytes. + +DEPENDENCIES + The LifeTime of ReaderThraad is dependent on the status returned by the + call to ftm_bt_hci_qcomm_handle_event + +RETURN VALUE + RETURN NIL + +SIDE EFFECTS + None + +===========================================================================*/ +void *ftm_readerthread(void *ptr) +{ + UNUSED(ptr); + boolean status = FALSE; + int retval; + fd_set readfds; + int buf; + + do + { + FD_ZERO(&readfds); + FD_SET(fd_transport, &readfds); + FD_SET(pipefd[0],&readfds); + retval = select((pipefd[0] > fd_transport? pipefd[0] : fd_transport) + 1, + &readfds, NULL, NULL, NULL); + if(retval == -1) + { + printf("select failed\n"); + break; + } + if(FD_ISSET(pipefd[0],&readfds)) + { +#ifdef FTM_DEBUG + printf("Pipe descriptor set\n"); +#endif + read(pipefd[0],&buf,1); + if(buf == 1) + break; + } + if(FD_ISSET(fd_transport,&readfds)) + { +#ifdef FTM_DEBUG + printf("Read descriptor set\n"); +#endif + status = ftm_bt_hci_qcomm_handle_event(); + if(TRUE != status) + break; + } + } + while(1); +#ifdef FTM_DEBUG + printf("\nReader thread exited\n"); +#endif + return 0; +} +/*=========================================================================== +FUNCTION ftm_bt_pfal_set_transport + +DESCRIPTION + sets the type of transport based on the msm type + +DEPENDENCIES + NIL + +RETURN VALUE +returns the type of transport +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_pfal_set_transport(void) +{ + if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE || soc_type == BT_SOC_NAPIER) { + strlcpy(transport_type, "uart", sizeof(transport_type)); + printf("[%s]: Transport type is: %s\n", __FUNCTION__, transport_type); + is_transportSMD = 0; + transport_dev = BT_HS_UART_DEVICE; + } else { + strlcpy(transport_type, "smd", sizeof(transport_type)); + printf("[%s]: Transport type is: %s\n", __FUNCTION__, transport_type); + is_transportSMD = 1; + transport_dev = APPS_RIVA_BT_CMD_CH; + } + return is_transportSMD; +} + + +int init_transport_bdroid(boolean on) { + + void *so_handle; + unsigned char bdaddr[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; + request_status st; + int fd[CH_MAX], powerstate, ret; + + if (on) { + so_handle = dlopen(VENDOR_LIB, RTLD_NOW); + if (!so_handle) + { + ALOGE("Failed to load vendor component %s", dlerror()); + return -1; + } + + vendor_interface = (bt_vendor_interface_t *) dlsym(so_handle, "BLUETOOTH_VENDOR_LIB_INTERFACE"); + if (!vendor_interface) + { + ALOGE("Failed to accesst bt vendor interface"); + return -1; + } + + vendor_interface->init(&vendor_callbacks, bdaddr); + + ALOGI("Turn On BT power"); + powerstate = BT_VND_PWR_ON; + ret = vendor_interface->op(BT_VND_OP_POWER_CTRL, &powerstate); + if (ret < 0) + { + ALOGE("Failed to turn on power from bt vendor interface"); + return -1; + } + ret = vendor_interface->op(BT_VND_OP_USERIAL_OPEN, fd); + ALOGE("ret value: %d", ret); + /* This is just a hack; needs to be removed */ + ret = 1; + ALOGE("setting ret value to 1 manually"); + if (ret != 1) + { + ALOGE("Failed to get fd from bt vendor interface"); + return -1; + } else { + ALOGE("FD: %x", fd[0]); + return fd[0]; + } + } else { + if (vendor_interface) { + ALOGE("Close and cleanup the interfaces"); + int ret = vendor_interface->op(BT_VND_OP_USERIAL_CLOSE, NULL); + + ALOGE("ret value: %d", ret); + vendor_interface->cleanup(); + return 0; + } else { + + ALOGE("Not able to find vendor interface handle"); + return -1; + } + } +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_deinit_transport + +DESCRIPTION + Platform specific routine to de-intialise the UART/SMD resource. + +PLATFORM SPECIFIC DESCRIPTION + Closes the TTY/SMD file descriptor and sets the descriptor value to -1 + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + The Close of the descriptor will trigger a failure in the Reader Thread + and hence cause a Deinit of the ReaderThread + +===========================================================================*/ +request_status ftm_bt_hci_pfal_deinit_transport() +{ + int buf = 1; + write(pipefd[1],&buf,1); + if(!isLatestTarget()) + { + close(fd_transport); + fd_transport = -1; + } + else + { + //Use libbt-vendor for chip de-initialization + init_transport_bdroid(FALSE); + } + return STATUS_SUCCESS; +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_init_uart + +DESCRIPTION + Platform specific routine to intialise the UART/SMD resources. + +PLATFORM SPECIFIC DESCRIPTION + Opens the TTY/SMD device file descriptor, congiures the TTY/SMD device for CTS/RTS + flow control,sets 115200 for TTY as the default baudrate and starts the Reader + Thread + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_pfal_init_transport(int mode) +{ + struct termios term; + if(isLatestTarget()) + { + printf("%s: ",__func__ ); + //Use hidl_client_initialize for chip initialization + if (hidl_client_initialize(mode, &fd_transport) == false) { + printf("%s: HIDL client initialization failed \n", __func__); + return STATUS_NO_RESOURCES; + } + printf("%s: , fd:%d: ", __func__, fd_transport); + } + else + { + fd_transport = open(transport_dev, (O_RDWR | O_NOCTTY)); + + if (-1 == fd_transport) + { + return STATUS_NO_RESOURCES; + } + + if (tcflush(fd_transport, TCIOFLUSH) < 0) + { + close(fd_transport); + return STATUS_FAIL; + } + + if (tcgetattr(fd_transport, &term) < 0) + { + close(fd_transport); + return STATUS_FAIL; + } + + cfmakeraw(&term); + /* Set RTS/CTS HW Flow Control*/ + term.c_cflag |= (CRTSCTS | CLOCAL); + + if (tcsetattr(fd_transport, TCSANOW, &term) < 0) + { + close(fd_transport); + return STATUS_FAIL; + } + + /* Configure the /dev/ttyHS0 device to operate at 115200. + no need for msm8960 as it is using smd as transport + */ + if (!is_transportSMD) + if (ftm_bt_hci_pfal_changebaudrate(starting_baud) == FALSE) + { + close(fd_transport); + return STATUS_FAIL; + } + } + if (pipe(pipefd) == -1) + { + printf("pipe create error"); + return STATUS_FAIL; + } + if(mode != MODE_FM) { + /* Creating read thread which listens for various masks & pkt requests */ + pthread_create( &hci_cmd_thread_hdl, NULL, ftm_readerthread, NULL); + } + return STATUS_SUCCESS; +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_nwrite + +DESCRIPTION + Platform specific routine to write the data in the argument to the UART/SMD + port intialised. + +PLATFORM SPECIFIC DESCRIPTION + Write the buffer to the tty device and ensure it is completely written + In case of short write report error to the BT FTM layer. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_pfal_nwrite(uint8 *buf, int size) +{ + int tx_bytes = 0, nwrite; + int i = 0, buf_size = size; + uint8 loop_back_cmd[6] = {0x1, 0x02, 0x18, 0x01, 0x01}; + /*hci packet is not required to carry the Packet indicator (for UART interfaces) for msm8960 + as it is using share memory interface */ + int hci_uart_pkt_ind = 0; + + if(fd_transport < 0) + return STATUS_NO_RESOURCES; + if ( buf[PIN_CON_CMD_OGF_BIT] == PIN_CON_CMD_OGF && + buf[PIN_CON_CMD_OCF_BIT] == PIN_CON_CMD_OCF && + (size > PIN_CON_CMD_SUBOP_BIT) && + buf[PIN_CON_CMD_SUBOP_BIT] == PIN_CON_CMD_SUB_OP && + (size > PIN_CON_CMD_INTER_BIT) && + buf[PIN_CON_CMD_INTER_BIT] == PIN_CON_INTERFACE_ID) + { + is_slim_bus_test = 1; + printf("\nPinConnectivityTest: Sending loopback command to SOC before initiasing slimbus\n"); + strlcpy(buf, loop_back_cmd, size); + } + do + { + nwrite = write(fd_transport, (buf + hci_uart_pkt_ind + tx_bytes), (size - hci_uart_pkt_ind - tx_bytes)); + + if (nwrite < 0) + { + printf("Error while writing ->\n"); + return STATUS_SHORT_WRITE; + } + if (nwrite == 0) + { + printf("ftm_bt_hci_pfal_nwrite: zero-length write\n"); + return STATUS_SHORT_WRITE; + } + + tx_bytes += nwrite; + size -= nwrite; + } while (tx_bytes < size - hci_uart_pkt_ind); + + if (verbose == 1) + { + printf("[%s] %s: CMD:", get_current_time(), __FUNCTION__); + for (i = 0; i < buf_size; i++) + { + printf(" %02X", buf[i]); + } + printf("\n"); + } + + return STATUS_SUCCESS; +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_nread + +DESCRIPTION + Platform specific routine to read data from the UART/SMD port intialised into + the buffer passed in argument. + +PLATFORM SPECIFIC DESCRIPTION + Read from the tty device into the buffer and ensure the read request is + completed, in case of short read report error to the BT FTM layer. + + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_hci_pfal_nread(uint8 *buf, int size) +{ + int rx_bytes = 0, nread; + + if(fd_transport < 0) + return STATUS_NO_RESOURCES; + + do + { + nread = read(fd_transport, (buf + rx_bytes), (size - rx_bytes)); + if (nread < 0) + { + printf("Error while reading ->\n"); + return STATUS_SHORT_READ; + } + + rx_bytes += nread; + + } while (rx_bytes < size); + + return STATUS_SUCCESS; +} + +/*=========================================================================== +FUNCTION ftm_bt_hci_pfal_changebaudrate + +DESCRIPTION + Platform specific routine to intiate a change in baud rate + +PLATFORM SPECIFIC DESCRIPTION + Convert the Baud rate passed to the speed_t type and program the + Baud rate change after ensuring all transmit is drained at the + current baud rate + +DEPENDENCIES + It is expected that the Upper layer will intiate a Flow Off to the + BT SoC, to signal the stop of receive if the baud rate change is + initiated while SoC init is in progress + +RETURN VALUE + RETURN VALUE + TRUE if SUCCESS, else FALSE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_hci_pfal_changebaudrate (uint32 new_baud) +{ + struct termios term; + boolean status = TRUE; + speed_t baud_code; + speed_t actual_baud_code; + + if (tcgetattr(fd_transport, &term) < 0) + { + printf("Can't get port settings\n"); + status = FALSE; + } + else + { + baud_code = convert_baud(new_baud); + (void) cfsetospeed(&term, baud_code); + if (tcsetattr(fd_transport, TCSADRAIN, &term) < 0) /* don't change speed until last write done */ + { + printf("bt_hci_qcomm_pfal_changebaudrate: tcsetattr:\n"); + status = FALSE; + } + /* make sure that we reportedly got the speed we tried to set */ + if (1 < verbose) + { + if (tcgetattr(fd_transport, &term) < 0) + { + printf("bt_hci_qcomm_pfal_changebaudrate: tcgetattr:\n"); + status = FALSE; + } + if (baud_code != (actual_baud_code = cfgetospeed(&term))) + { + printf("bt_hci_qcomm_pfal_changebaudrate: new baud %u FAILED, got 0x%x\n", new_baud, actual_baud_code); + } + else + { + printf("bt_hci_qcomm_pfal_changebaudrate: new baud %u SUCCESS, got 0x%x\n", new_baud, actual_baud_code); + } + } + } + + return status; +} diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_persist.cpp b/feeds/wifi-ax/ftm/src/ftm_bt_persist.cpp new file mode 100755 index 000000000..e1e659bf2 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_persist.cpp @@ -0,0 +1,278 @@ +/*========================================================================== + + BT persist NV items access source file + +Description + Read/Write APIs for retreiving NV items from persist memory. + +# Copyright (c) 2011-12 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +05/25/12 jav Added FTM log that will display bt address while testing. +09/27/11 rrr Moved persist related API for c/c++ compatibility, needed + for random BD address to be persistent across target + reboots. +==========================================================================*/ + +#include "ftm_bt_persist.h" +#include + +#ifdef BT_NV_SUPPORT +#include "bt_nv.h" + +/* Semaphore shared by the Event handler and main thread */ +extern sem_t semaphore_cmd_complete; +/*Flag to manage the verbose output */ +extern int verbose; + +/*=========================================================================== +FUNCTION ftm_bt_send_nv_read_cmd + +DESCRIPTION + Helper Routine to process the nv read command + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_send_nv_read_cmd +( + uint8 * cmd_buf, /* pointer to Cmd */ + uint16 cmd_len /* Cmd length */ +) +{ + nv_persist_item_type my_nv_item; + nv_persist_stat_enum_type cmd_result; + boolean result = TRUE; + + if(cmd_len >1) + { + switch(*(cmd_buf+1)) + { + case NV_BD_ADDR_I: + cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BD_ADDR_I, &my_nv_item); + if (NV_SUCCESS != cmd_result) + { + if (verbose > 0) + { + fprintf (stderr, "nv_cmd_remote failed to get BD_ADDR from NV, code %d\n", cmd_result); + } + /* Send fail response */ + result = FALSE; + } + else + { + /* copy bytes */ + event_buf_nv_read_response[0] = FTM_BT_CMD_NV_READ; + event_buf_nv_read_response[1] = NV_BD_ADDR_I; + event_buf_nv_read_response[7] = my_nv_item.bd_addr[5]; + event_buf_nv_read_response[6] = my_nv_item.bd_addr[4]; + event_buf_nv_read_response[5] = my_nv_item.bd_addr[3]; + event_buf_nv_read_response[4] = my_nv_item.bd_addr[2]; + event_buf_nv_read_response[3] = my_nv_item.bd_addr[1]; + event_buf_nv_read_response[2] = my_nv_item.bd_addr[0]; + /* send BD_ADDR in the response */ + fprintf (stderr, "nv_cmd_remote got NV_BD_ADDR_I from NV: %x:%x:%x:%x:%x:%x\n", + (unsigned int) my_nv_item.bd_addr[5], (unsigned int) my_nv_item.bd_addr[4], + (unsigned int) my_nv_item.bd_addr[3], (unsigned int) my_nv_item.bd_addr[2], + (unsigned int) my_nv_item.bd_addr[1], (unsigned int) my_nv_item.bd_addr[0]); + + ftm_log_send_msg((const uint8 *)event_buf_nv_read_response,nv_read_response_size); + result = TRUE; + } + break; + + case NV_BT_SOC_REFCLOCK_TYPE_I: + cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BT_SOC_REFCLOCK_TYPE_I, &my_nv_item); + if (NV_SUCCESS != cmd_result) + { + if (verbose > 0) + { + fprintf (stderr, "nv_cmd_remote failed to get BD_ADDR from NV, code %d\n", cmd_result); + } + /* Send fail response */ + result = FALSE; + } + else + { + event_buf_nv_read_response[0] = FTM_BT_CMD_NV_READ; + event_buf_nv_read_response[1] = NV_BT_SOC_REFCLOCK_TYPE_I; + event_buf_nv_read_response[2] = (uint8) my_nv_item.bt_soc_refclock_type ; + event_buf_nv_read_response[7] = 0x0; + event_buf_nv_read_response[6] = 0x0; + event_buf_nv_read_response[5] = 0x0; + event_buf_nv_read_response[4] = 0x0; + event_buf_nv_read_response[3] = 0x0; + fprintf (stderr, "nv_cmd_remote got NV_BT_SOC_REFCLOCK_TYPE_I from NV: 0x%x\n", + (unsigned int) my_nv_item.bt_soc_refclock_type); + ftm_log_send_msg((const uint8 *)event_buf_nv_read_response,nv_read_response_size); + result = TRUE; + } + break; + + case NV_BT_SOC_CLK_SHARING_TYPE_I: + cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BT_SOC_CLK_SHARING_TYPE_I, &my_nv_item); + if (NV_SUCCESS != cmd_result) + { + if (verbose > 0) + { + fprintf (stderr, "nv_cmd_remote failed to get CLK_SHARING from NV, code %d\n", cmd_result); + } + /* Send fail response */ + result = FALSE; + } + else + { + event_buf_nv_read_response[0] = FTM_BT_CMD_NV_READ; + event_buf_nv_read_response[1] = NV_BT_SOC_CLK_SHARING_TYPE_I; + event_buf_nv_read_response[2] = (uint8) my_nv_item.bt_soc_clk_sharing_type ; + event_buf_nv_read_response[7] = 0x0; + event_buf_nv_read_response[6] = 0x0; + event_buf_nv_read_response[5] = 0x0; + event_buf_nv_read_response[4] = 0x0; + event_buf_nv_read_response[3] = 0x0; + fprintf (stderr, "nv_cmd_remote got NV_BT_SOC_CLK_SHARING_TYPE_I from NV: 0x%x\n", + (unsigned int) my_nv_item.bt_soc_refclock_type); + ftm_log_send_msg((const uint8 *)event_buf_nv_read_response,nv_read_response_size); + result = TRUE; + } + break; + } + if(result == FALSE) + ftm_log_send_msg(event_buf_nv_read_response_fail,nv_read_response_size_fail); + + sem_post(&semaphore_cmd_complete); + return result; + } + return TRUE; +} +/*=========================================================================== +FUNCTION ftm_bt_send_nv_write_cmd + +DESCRIPTION + Helper Routine to process the nv write command + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_send_nv_write_cmd +( + uint8 * cmd_buf, /* pointer to Cmd */ + uint16 cmd_len /* Cmd length */ +) +{ + nv_persist_item_type my_nv_item; + nv_persist_stat_enum_type cmd_result; + boolean result = TRUE; + if(cmd_len >1) + { + switch(*(cmd_buf+1)) + { + case NV_BD_ADDR_I: + memcpy(&my_nv_item.bd_addr, (cmd_buf+2), NV_BD_ADDR_SIZE); + cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_WRITE_F, NV_BD_ADDR_I, &my_nv_item); + if (NV_SUCCESS != cmd_result) + { + if (verbose > 0) + { + fprintf (stderr, "nv_cmd_remote failed to get BD_ADDR from NV, code %d\n", cmd_result); + } + /* Send fail response */ + result = FALSE; + } + else + { + result = TRUE; + } + break; + + case NV_BT_SOC_REFCLOCK_TYPE_I: + switch (*(cmd_buf+2)) + { + case NV_PS_BT_SOC_REFCLOCK_32MHZ: + case NV_PS_BT_SOC_REFCLOCK_19P2MHZ: + my_nv_item.bt_soc_refclock_type = (nv_ps_bt_soc_refclock_enum_type)(*(cmd_buf+2)) ; + break; + default: + fprintf (stderr, "Invalid Ref Clock option\n"); + result = FALSE; + } + if (result != FALSE) + { + cmd_result= (nv_persist_stat_enum_type)bt_nv_cmd(NV_WRITE_F, NV_BT_SOC_REFCLOCK_TYPE_I, &my_nv_item); + if (NV_SUCCESS != cmd_result) + { + fprintf (stderr, "nv_cmd_remote failed to write SOC_REFCLOCK_TYPE to NV, code %d\n", cmd_result); + result = FALSE; + } + else + { + result = TRUE; + } + break; + } + case NV_BT_SOC_CLK_SHARING_TYPE_I: + switch (*(cmd_buf+2)) + { + case NV_PS_BT_SOC_CLOCK_SHARING_ENABLED: + case NV_PS_BT_SOC_CLOCK_SHARING_DISABLED: + my_nv_item.bt_soc_clk_sharing_type = (nv_ps_bt_soc_clock_sharing_enum_type)(*(cmd_buf+2)) ; + break; + default: + fprintf (stderr, "Invalid Clock Sharing option\n"); + result = FALSE; + } + if (result != FALSE) + { + cmd_result= (nv_persist_stat_enum_type)bt_nv_cmd(NV_WRITE_F, NV_BT_SOC_CLK_SHARING_TYPE_I, &my_nv_item); + if (NV_SUCCESS != cmd_result) + { + fprintf (stderr, "nv_cmd_remote failed to write SOC_CLK_SHARING_TYPE to NV, code %d\n", cmd_result); + result = FALSE; + } + else + { + result = TRUE; + } + break; + } + } + if(result == FALSE) + { + ftm_log_send_msg(event_buf_bt_nv_write_fail,nv_write_response_size); + sem_post(&semaphore_cmd_complete); + } + else + { + ftm_log_send_msg((const uint8 *)event_buf_bt_nv_write_pass,nv_write_response_size); + sem_post(&semaphore_cmd_complete); + } + return result; + } + return TRUE; +} +#endif /* End of BT_NV_SUPPORT */ diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_persist.h b/feeds/wifi-ax/ftm/src/ftm_bt_persist.h new file mode 100755 index 000000000..353c12faa --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_persist.h @@ -0,0 +1,113 @@ +#ifndef _FTM_BT_PERSIST_H_ +#define _FTM_BT_PERSIST_H_ + +/*========================================================================== + + BT persist NV items access source file + +Description + Read/Write APIs for retreiving NV items from persist memory. + +# Copyright (c) 2011 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +09/27/11 rrr Moved persist related API for c/c++ compatibility, needed + for random BD address to be persistent across target + reboots. +==========================================================================*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include +#include +#include "ftm_bt_common.h" +#include + + +#ifdef BT_NV_SUPPORT + +#define FTM_BT_CMD_NV_READ 0xB +#define FTM_BT_CMD_NV_WRITE 0xC + +const uint8 nv_read_response_size = 8; +const uint8 nv_read_response_size_fail = 2; +const uint8 nv_write_response_size = 2; + +/* NV Write Responses */ +const uint8 event_buf_bt_nv_write_pass[2] = { FTM_BT_CMD_NV_WRITE, FTM_BT_DRV_NO_ERR}; +const uint8 event_buf_bt_nv_write_fail[2] = { FTM_BT_CMD_NV_WRITE, FTM_BT_NV_WRITE_FAIL}; + +/* NV Read Responses */ +const uint8 event_buf_nv_read_response_fail[8] = +{ + FTM_BT_CMD_NV_READ, FTM_BT_NV_READ_FAIL, 0x0, 0x0,0x0,0x0,0x0,0x0 +}; + +uint8 event_buf_nv_read_response[8]; +#endif /* BT_NV_SUPPORT */ + +/*=========================================================================== +FUNCTION ftm_bt_send_nv_read_cmd + +DESCRIPTION + Helper Routine to process the nv read command + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_send_nv_read_cmd +( + uint8 * cmd_buf, /* pointer to Cmd */ + uint16 cmd_len /* Cmd length */ +); + +/*=========================================================================== +FUNCTION ftm_bt_send_nv_write_cmd + +DESCRIPTION + Helper Routine to process the nv write command + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean ftm_bt_send_nv_write_cmd +( + uint8 * cmd_buf, /* pointer to Cmd */ + uint16 cmd_len /* Cmd length */ +); + +#ifdef __cplusplus +} +#endif + +#endif /* _FTM_BT_PERSIST_H_ */ + diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_power_hal.h b/feeds/wifi-ax/ftm/src/ftm_bt_power_hal.h new file mode 100755 index 000000000..2c861b92b --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_power_hal.h @@ -0,0 +1,76 @@ +/*========================================================================== + + FTM BT POWER HAL Header File + +Description + Wrapper API definitions of the ftm bt power hal component. + +# Copyright (c) 2010 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/18/10 rakeshk Created a header file to include the wrapper API + definitions for BT power control +07/07/10 rakeshk Modified the function name of BT power set HAL routine +===========================================================================*/ +#include "ftm_bt_common.h" +#include "ftm_bt_power_pfal.h" + + +#ifndef __FTM_BT_POWER_HAL_H__ +#define __FTM_BT_POWER_HAL_H__ +/*=========================================================================== +FUNCTION ftm_bt_power_hal_set + +DESCRIPTION + Platform independent wrapper API which sets a BT power from PFAL + layer and returns the status of the PFAL operation. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_power_hal_set(bt_power_state state) +{ + return ftm_bt_power_pfal_set(state); +} +/*=========================================================================== +FtUNCTION ftm_bt_power_hal_check + +DESCRIPTION + + Platform independent wrapper API which gets the BT power from PFAL + layer and returns the current state of the BT HW. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + Current BT power state + +SIDE EFFECTS + None + +===========================================================================*/ +bt_power_state ftm_bt_power_hal_check() +{ + return ftm_bt_power_pfal_check(); +} + +#endif //__FTM_BT_POWER_HAL_H__ diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_power_pfal.h b/feeds/wifi-ax/ftm/src/ftm_bt_power_pfal.h new file mode 100755 index 000000000..d81c47fb3 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_power_pfal.h @@ -0,0 +1,71 @@ +/*========================================================================== + + FTM BT POWER PFAL Header File + +Description + PFAL API declarations of the ftm bt power pfal component. + +# Copyright (c) 2010 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/18/10 rakeshk Created a header file to hold the PFAL declarations for + BT power programming +07/07/10 rakeshk Modified the function name of BT power set PFAL routine +===========================================================================*/ +#include "ftm_bt_common.h" + +#ifndef __FTM_BT_POWER_PFAL_H__ +#define __FTM_BT_POWER_PFAL_H__ + +/*=========================================================================== +FUNCTION ftm_bt_power_pfal_set + +DESCRIPTION + Platform dependent interface API which sets the BT power + and returns the status of the toggle operation. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_power_pfal_set(bt_power_state state); + +/*=========================================================================== +FUNCTION ftm_bt_power_pfal_check + +DESCRIPTION + + Platform dependent interface API which intiates a BT power read/check + and returns the current state of the BT HW. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + Current BT power state + +SIDE EFFECTS + None + +===========================================================================*/ +bt_power_state ftm_bt_power_pfal_check(); + +#endif + diff --git a/feeds/wifi-ax/ftm/src/ftm_bt_power_pfal_linux.c b/feeds/wifi-ax/ftm/src/ftm_bt_power_pfal_linux.c new file mode 100755 index 000000000..aa45bd01a --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_bt_power_pfal_linux.c @@ -0,0 +1,197 @@ +/*========================================================================== + + FTM Platform specfic BT power File + +Description + Platform specific routines to toggle/read the BT power state + +# Copyright (c) 2010-2011 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/18/10 rakeshk Created a source file to implement platform specific + routines for BT power. +07/07/10 rakeshk Added routine to find the sysfs entry for bluetooth in + runtime +07/07/10 rakeshk Added call to init the rfkill state path in case of first + read +===========================================================================*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include "ftm_bt_power_pfal.h" +#include + +/* Bluetooth Rfkill Entry for Android */ +static char *rfkill_state_path = NULL; +/*=========================================================================== +FUNCTION init_rfkill_path + +DESCRIPTION + Opens the sysfs entry for different types of rfkill and finds the one + which matches Bluetooth by iterating through the rfkill entries + and checking for bluetooth + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + TRUE if SUCCESS, else FALSE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean init_rfkill_path() +{ + int fd; + int readsize; + int rfkillid; + char rfkill_path[64]; + char buf[16]; + + for (rfkillid = 0; ; rfkillid++) + { + /* Open the different rfkill type entries and check if type macthes bluetooth */ + snprintf(rfkill_path, sizeof(rfkill_path), "/sys/class/rfkill/rfkill%d/type", rfkillid); + fd = open(rfkill_path, O_RDONLY); + if (fd < 0) + { + printf("open(%s) failed: \n", rfkill_path); + return FALSE; + } + readsize = read(fd, &buf, sizeof(buf)); + close(fd); + + if (memcmp(buf, "bluetooth", 9) == 0) + { + break; + } + } + + asprintf(&rfkill_state_path, "/sys/class/rfkill/rfkill%d/state", rfkillid); + return TRUE; +} + +/*=========================================================================== +FUNCTION ftm_bt_power_pfal_set + +DESCRIPTION + Platform dependent interface API which sets the BT power state + and returns the status of the toggle operation. + +PLATFORM SPECIFIC DESCRIPTION + Opens the rfkill entry for Bleutooth and initiates a write of the value + passed as argument. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + STATUS_SUCCESS if SUCCESS, else other reasons + +SIDE EFFECTS + None + +===========================================================================*/ +request_status ftm_bt_power_pfal_set(bt_power_state state) +{ + int sz; + int fd = -1; + request_status ret = STATUS_FAIL; + const char buffer = state; + if(rfkill_state_path == NULL) + { + if(init_rfkill_path() != TRUE) + goto out; + } + + fd = open(rfkill_state_path, O_WRONLY); + if (fd < 0) + { + ret = STATUS_NO_RESOURCES; + goto out; + } + sz = write(fd, &buffer, 1); + if (sz < 0) + { + goto out; + } + ret = STATUS_SUCCESS; + +out: + if (fd >= 0) + close(fd); + return ret; +} + +/*=========================================================================== +FUNCTION ftm_bt_power_pfal_check + +DESCRIPTION + + Platform dependent interface API which intiates a BT power read/check + and returns the current state of the BT HW. + +PLATFORM SPECIFIC DESCRIPTION + Opens the rfkill entry for Bleutooth and initiates a read on the rfkill + descriptor. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN VALUE + Current BT power state + +SIDE EFFECTS + None + +===========================================================================*/ +bt_power_state ftm_bt_power_pfal_check() +{ + int sz; + bt_power_state state= BT_OFF; + int fd = -1; + char buffer = '0'; + + if(rfkill_state_path == NULL) + { + if(init_rfkill_path() != TRUE) + goto out; + } + fd = open(rfkill_state_path, O_RDONLY); + if (fd < 0) + { + goto out; + } + sz = read(fd, &buffer, 1); + if (sz < 0) + { + goto out; + } + +out: + if (fd >= 0) + close(fd); + state = (bt_power_state)buffer; + return state; +} + diff --git a/feeds/wifi-ax/ftm/src/ftm_common.h b/feeds/wifi-ax/ftm/src/ftm_common.h new file mode 100755 index 000000000..48bb478a9 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_common.h @@ -0,0 +1,141 @@ +/*========================================================================== + + FTM BT HCI PFAL Header File + +Description + Queue insert/delete routines and data structures + +# Copyright (c) 2010-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/18/10 rakeshk Created +11/09/10 rakeshk Added two APIs to perform read/write of BT Top level + I2C registers +===========================================================================*/ + +#if defined(CONFIG_FTM_BT) || defined(CONFIG_FTM_FM) +#include +#include "ftm_bt.h" +#include +#include +/* Semaphore shared by the Event handler and main thread */ +extern sem_t semaphore_cmd_complete; +/* Structure used by the FTM BT/FM component to + * queue the FTM packet contents + */ + +pthread_mutex_t fm_event_lock; +pthread_cond_t fm_event_cond; +extern int fm_passthrough; + +typedef struct cmdQ +{ + int command_id;/*Command id */ + void *data; /* Command data */ + boolean bt_command; /* whether BT or FM command */ + int cmd_len; /* Command length */ + struct cmdQ *next; /* pointer to next CmdQ item */ +}cmdQ; + +/* Callback declaration for BT FTM packet processing */ +void *bt_ftm_diag_dispatch(void *req_pkt, uint16 pkt_len); + +/*=========================================================================== +FUNCTION qinsert_cmd + +DESCRIPTION + Command Queue insert routine. Add the FTM BT packet to the Queue + +DEPENDENCIES + NIL + +RETURN VALUE + RETURNS FALSE without adding queue entry in failure + to allocate a new Queue item + else returns TRUE + +SIDE EFFECTS + increments the number of commands queued + +===========================================================================*/ +boolean qinsert_cmd(ftm_bt_pkt_type *ftm_bt_pkt); +/*=========================================================================== +FUNCTION dequeue_send + +DESCRIPTION + Command Queue delete and calls HCI send routine. Dequeues the HCI data from + the queue and sends it to HCI HAL layer. + +DEPENDENCIES + NIL + +RETURN VALUE + RETURN NIL + +SIDE EFFECTS + decrements the number of command queued + +===========================================================================*/ +void dequeue_send(); + +/*=========================================================================== +FUNCTION i2c_write + +DESCRIPTION + Helper function to construct the I@C request to be sent to the FM I2C + driver + +DEPENDENCIES + NIL + +RETURN VALUE + -1 in failure,positive or zero in success + +SIDE EFFECTS + None + +===========================================================================*/ +int i2c_write +( +int fd, +unsigned char offset, +const unsigned char* buf, +unsigned char len, +unsigned int slave_addr +); + +/*=========================================================================== +FUNCTION i2c_read + +DESCRIPTION + Helper function to construct the I2C request to read data from the FM I2C + driver + +DEPENDENCIES + NIL + +RETURN VALUE + -1 in failure,positive or zero in success + +SIDE EFFECTS + None + +===========================================================================*/ +int i2c_read +( +int fd, +unsigned char offset, +const unsigned char* buf, +unsigned char len, +unsigned int slave_addr +); +#endif diff --git a/feeds/wifi-ax/ftm/src/ftm_dbg.h b/feeds/wifi-ax/ftm/src/ftm_dbg.h new file mode 100755 index 000000000..592b44aa6 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_dbg.h @@ -0,0 +1,34 @@ +/*========================================================================== + + FTM WLAN Source File + +# Copyright (c) 2013-2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ +#ifndef _FTM_DBG_H_ +#define _FTM_DBG_H_ + +#define FTM_DBG_ERROR 0x00000001 +#define FTM_DBG_INFO 0x00000002 +#define FTM_DBG_TRACE 0x00000004 + +#define FTM_DBG_DEFAULT (FTM_DBG_ERROR) + +extern unsigned int g_dbg_level; + +#ifdef DEBUG +void current_time(); +#define DPRINTF(_level, _x...)\ + do {\ + if (g_dbg_level & (_level))\ + {\ + fprintf(stderr, _x);\ + }\ + } while (0); + +#else +#define DPRINTF(_level, x...) do { } while (0); +#endif + +#endif /* _FTM_DBG_H_ */ diff --git a/feeds/wifi-ax/ftm/src/ftm_fm.c b/feeds/wifi-ax/ftm/src/ftm_fm.c new file mode 100755 index 000000000..f266b10bf --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_fm.c @@ -0,0 +1,3804 @@ +/*========================================================================== + + FTM FM Source File + +Description + FTM platform independent processing of packet data + +# Copyright (c) 2010-2012 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +08/03/2011 uppalas Adding support for new ftm commands +06/18/10 rakeshk Created a source file to implement routines for FTM + command processing for FM +07/06/10 rakeshk Updated the ftm_fm_dispatch with new commands +01/07/11 rakeshk Removed the check condition in FM bus read/write for + FM On. This is due to the reason that the top level i2c + read/write of the Bahama/Marimba SoC doesnot depend on FM + SoC being intialised. + Added support for new FM FTM APIS +02/09/11 rakeshk Added support for BLER FTM APIs +04/03/11 ananthk Added support for FM FTM Transmit APIs +===========================================================================*/ +#include +#include "event.h" +#include "msg.h" +#include "log.h" + +#include "diag_lsm.h" + +#include "diagpkt.h" +#include "diagcmd.h" +#include "diag.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "ftm_fm_pfal.h" +#include "ftm_common.h" +#include +#include +#include +#include +#include + +#define UNUSED(x) (void)(x) + +#define FTM_DEBUG +const int PROP_SET_SUCC = 0; +const int init_audio_vlm = 50; //set the initial volume to 50 +const char *const fm_audio_disable = "quit"; +const char *const audio_ftm_cmds = "/data/vendor/misc/audio/ftm_commands"; +/* Global union type for FM params */ +fm_cfg_request fmrequestparams; +static uint8 fm_audio_output = -1; +static uint8 enable_mm_fmconfig = 0; +extern int ftm_audio_fd; +volatile fm_power_state fmPowerState = FM_POWER_OFF; +fm_i2c_params common_handle; +extern fm_station_params_available fm_global_params; +/*=========================================================================== +FUNCTION ftm_send_async_msg + +DESCRIPTION + Processes the log buffer sent and writes it to the libdiag for sending the Cmd + response + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ + +void ftm_send_async_msg( + uint8 EvName, + /**< Event ID indicates which event is being returned. */ + + FmEvResultType EvResult, + /**< Event result indicates success or failure. */ + + PACKED void* response, + /**< Event body contains the returned event information. */ + + uint16 length + /**< Event response length. */) +{ + int result = log_status(LOG_FTM_FM_C); + ftm_fm_log_pkt_type* ftm_fm_log_pkt_ptr = NULL; + + if((response == NULL) || (length == 0)) + { + return; + } + + if(result == 1) + { + ftm_fm_log_pkt_ptr = (ftm_fm_log_pkt_type *)log_alloc(LOG_FTM_FM_C,FTM_FM_LOG_HEADER_SIZE + (length-1)); + if(ftm_fm_log_pkt_ptr != NULL) + { + /* FTM LOG FM ID */ + ftm_fm_log_pkt_ptr->EvName = EvName; + ftm_fm_log_pkt_ptr->EvResult = EvResult; + memcpy((void *)ftm_fm_log_pkt_ptr->data,(void *)response,length); + log_commit( ftm_fm_log_pkt_ptr ); + } + } +} + +/*=========================================================================== +FUNCTION convert_cmdstatus_to_ftmstatus + +DESCRIPTION + Helper routine to convert the FM command status to FTM command status + +DEPENDENCIES + NIL + +RETURN VALUE + FTM command status + +SIDE EFFECTS + None + +===========================================================================*/ +ftm_fm_api_result_type convert_cmdstatus_to_ftmstatus(fm_cmd_status_type cmdStatus) +{ + switch(cmdStatus) + { + case FM_CMD_SUCCESS: + return FTM_FM_SUCCESS; + case FM_CMD_NO_RESOURCES: + return FTM_NO_RESOURCES; + case FM_CMD_INVALID_PARAM: + return FTM_INVALID_PARAM; + case FM_CMD_DISALLOWED: + return FTM_FM_DISALLOWED; + case FM_CMD_UNRECOGNIZED_CMD: + return FTM_FM_UNRECOGNIZED_CMD; + case FM_CMD_FAILURE: + return FTM_FAIL; + case FM_CMD_PENDING: + return FTM_FM_PENDING; + default : + return FTM_FAIL; + } +} + +/*=========================================================================== +FUNCTION ftm_fm_copy_request_data + +DESCRIPTION + Helper routine to copy the FTM command data to the global union data type + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ +void ftm_fm_copy_request_data +( + PACKED void * request , + uint16 length +) +{ + ftm_fm_pkt_type* req_pkt; + int i; + req_pkt = (ftm_fm_pkt_type *) request; + /* Copy any params into our union if they exist. */ + memmove((void*)(&fmrequestparams), + (void*)(&req_pkt->data), + (length)); +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_enable_receiver + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + EnableReceiver, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Enable Receiver + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_enable_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + response->result = FTM_FM_SUCCESS; + if(fmPowerState == FM_TX_ON || fmPowerState == FM_POWER_TRANSITION) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + else if (fmPowerState == FM_RX_ON) + return response; + + ftm_fm_run_mm(); + cmdStatus = EnableFM(&fmrequestparams.cfg_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_tx_enable_transmitter + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + EnableTransmitter, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Enable Transmitter + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_enable_transmitter +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + printf("\n Inside ftm_fm_tx_enable_transmitter() function...\n"); + + response->result = FTM_FM_SUCCESS; + if(fmPowerState == FM_RX_ON || fmPowerState == FM_POWER_TRANSITION) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + else if (fmPowerState == FM_TX_ON) + return response; + + fmrequestparams.cfg_param.is_fm_tx_on = 1; + cmdStatus = EnableFM(&fmrequestparams.cfg_param); + + printf("\nValue of 'cmdStatus' is %d",cmdStatus); + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} +/*=========================================================================== +FUNCTION ftm_fm_tx_ps_info + +DESCRIPTION + This routine is used to send the RDS PS Info over the transmitting station + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Enable Transmitter + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_ps_info +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_TX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + + printf("\n Inside ftm_fm_tx_ps_info() function...\n"); + + cmdStatus = TransmitPS(&fmrequestparams.tuFmPSParams); + + printf("\nValue of 'cmdStatus' is %d",cmdStatus); + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_tx_stop_ps_info + +DESCRIPTION + This routine is used to stop transmitting the RDS PS info + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the stopTransmitPS + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_stop_ps_info +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_TX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + + printf("\n Inside ftm_fm_tx_stop_ps_info() function...\n"); + + cmdStatus = stopTransmitPS(); + + printf("\nValue of 'cmdStatus' is %d",cmdStatus); + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} +/*=========================================================================== */ + + +/*=========================================================================== +FUNCTION ftm_fm_tx_rt_info + +DESCRIPTION + This routine is used to send the RDS RT Info over the transmitting station + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the RT Start + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_rt_info +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_TX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + + printf("\n Inside ftm_fm_tx_rt_info() function...\n"); + + cmdStatus = TransmitRT(&fmrequestparams.tuFmRTParams); + + printf("\nValue of 'cmdStatus' is %d",cmdStatus); + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== */ +/*=========================================================================== +FUNCTION ftm_fm_tx_stop_rt_info + +DESCRIPTION + This routine is used to stop transmitting the RDS RT info + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the stopTransmitRT + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_stop_rt_info +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_TX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + + printf("\n Inside ftm_fm_tx_stop_rt_info() function...\n"); + + cmdStatus = stopTransmitRT(); + + printf("\nValue of 'cmdStatus' is %d",cmdStatus); + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} +/*=========================================================================== */ + +/*=========================================================================== +FUNCTION ftm_fm_tx_get_ps_features + +DESCRIPTION + This routine is used to get all the supported TX PS features + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the getTxPSFeatures() + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_get_ps_features +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_TX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + +#ifdef FTM_DEBUG + printf("\n Inside ftm_fm_tx_get_ps_features function...\n"); +#endif + + cmdStatus = getTxPSFeatures(); + +#ifdef FTM_DEBUG + printf("\nValue of 'cmdStatus' is %d",cmdStatus); +#endif + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + + +/*=========================================================================== + +FUNCTION ftm_fm_disable_audio + +DESCRIPTION + This function is used to disable FTM FM audio. + +DEPENDENCIES + none + +===========================================================================*/ +PACKED void* ftm_fm_disable_audio +( +void +) +{ + int ret; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( generic_response ) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + printf("enter ftm_fm_disable_audio\n"); + + if (response != NULL) { + response->result = FTM_FM_SUCCESS; + ret = property_set("ftm.fm_stop", "true"); + if (ret != PROP_SET_SUCC) { + response->result = FTM_FAIL; + return response; + } + } else + printf("ftm_fm_disable_audio unable to allocate memory for response packet \n"); + if (ftm_audio_fd > 0) + close(ftm_audio_fd); + printf("Disable audio\n"); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_disable_receiver + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + DisableFM, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the DisableFM + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_disable_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + response->result = FTM_FM_SUCCESS; + + if(fmPowerState == FM_POWER_OFF) + return response; + + else if(fmPowerState == FM_TX_ON || fmPowerState == FM_POWER_TRANSITION) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + + cmdStatus = DisableFM(&fmrequestparams.cfg_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + fmPowerState = FM_POWER_OFF; + ftm_fm_disable_audio(); + return response; +} +/*=========================================================================== +FUNCTION ftm_fm_tx_disable_transmitter + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + DisableFM, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the DisableFM + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_disable_transmitter +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + response->result = FTM_FM_SUCCESS; + + if(fmPowerState == FM_POWER_OFF) + return response; + else if (fmPowerState == FM_RX_ON || fmPowerState == FM_POWER_TRANSITION) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } + + cmdStatus = DisableFM(&fmrequestparams.cfg_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + fmPowerState = FM_POWER_OFF; + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_configure_receiver + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + ConfigureFM, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the ConfigureFM + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_configure_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + response->result = FTM_FM_SUCCESS; + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + fmrequestparams.cfg_param.is_fm_tx_on = 0; + cmdStatus = ConfigureFM(&fmrequestparams.cfg_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_tx_configure_transmitter + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + ConfigureFM, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the ConfigureFM + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_configure_transmitter +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + response->result = FTM_FM_SUCCESS; + if(fmPowerState != FM_TX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + fmrequestparams.cfg_param.is_fm_tx_on = 1; + cmdStatus = ConfigureFM(&fmrequestparams.cfg_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_setfrequency_receiver + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + SetFrequencyReceiver, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set Frequency + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_setfrequency_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetFrequencyReceiver(fmrequestparams.freq); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_tx_setfrequency_transmitter + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + SetFrequencyTransmitter, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set Frequency + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_setfrequency_transmitter +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_TX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetFrequencyTransmitter(fmrequestparams.freq); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_setmutemode_receiver + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + SetMuteModeReceiver, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set Mute Mode + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_setmutemode_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + mutemode_response * response = (mutemode_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(mutemode_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetMuteModeReceiver(fmrequestparams.mute_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + response->mutemode = fmrequestparams.mute_param; + return response; +} + + +/*=========================================================================== +FUNCTION ftm_fm_set_soft_mute_receiver + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + SetMuteModeReceiver, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set Mute Mode + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_set_soft_mute_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetSoftMuteModeReceiver(fmrequestparams.soft_mute_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_set_antenna + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + setAntenna, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set Antenna + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_set_antenna +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = SetAntenna(fmrequestparams.antenna_type); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_peek_riva_word + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + FmRivaPeekData, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the peek riva word + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_peek_riva_word +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + rivaData_response * response = (rivaData_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(rivaData_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if((fmPowerState != FM_RX_ON) && (fmPowerState != FM_TX_ON)) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + + cmdStatus = FmRivaPeekData(fmrequestparams.riva_peek_params); + response->start_address = fm_global_params.riva_data_access_params.startaddress; + response->length = fm_global_params.riva_data_access_params.payload_length; + memcpy(&response->data[0], &fm_global_params.riva_data_access_params.data[0], + response->length); + response->sub_opcode = fm_global_params.riva_data_access_params.subOpcode; + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; + +} + +/*=========================================================================== +FUNCTION ftm_fm_poke_riva_word + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + FmRivaPokeData, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the poke riva word + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_poke_riva_word +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if((fmPowerState != FM_RX_ON) && (fmPowerState != FM_TX_ON)) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = FmRivaPokeData(fmrequestparams.riva_data_access_params); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; + +} + +/*=========================================================================== +FUNCTION ftm_fm_poke_ssbi_reg + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + FmSSBIPokeData, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the poke ssbi reg + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_poke_ssbi_reg +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if((fmPowerState != FM_RX_ON) && (fmPowerState != FM_TX_ON)) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; +#ifdef FTM_DEBUG + printf("ssbi address = %x \n", fmrequestparams.ssbi_access_params.startaddress); + printf("ssbi data = %x \n",fmrequestparams.ssbi_access_params.data); +#endif + + cmdStatus = FmSSBIPokeData(fmrequestparams.ssbi_access_params); + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_peek_ssbi_reg + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + FmSSBIPeekData, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the poke ssbi reg + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_peek_ssbi_reg +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + ssbiPeek_response * response = (ssbiPeek_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(ssbiPeek_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if((fmPowerState != FM_RX_ON) && (fmPowerState != FM_TX_ON)) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; +#ifdef FTM_DEBUG + printf("SSBI peek address = %x",fmrequestparams.ssbi_access_params.startaddress); +#endif + + cmdStatus = FmSSBIPeekData(fmrequestparams.ssbi_access_params); + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + response->data = fm_global_params.ssbi_peek_data; + return response; + +} + +/*=========================================================================== +FUNCTION ftm_fm_set_get_reset_agc + +DESCRIPTION + This is a synchronous command for Set/Get Gain State and Reset AGC. + +DEPENDENCIES + NIL + +RETURN VALUE + Current AGC Gain State + AGC Gain State one Change ago + AGC Gain State two Changes ago + AGC Gain State three changes ago + +SIDE EFFECTS + None + +===========================================================================*/ + +PACKED void * ftm_fm_set_get_reset_agc +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + set_get_reset_agc_response * response = (set_get_reset_agc_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(set_get_reset_agc_response) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) //&& (fmPowerState != FM_TX_ON)) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + +#ifdef FM_SOC_TYPE_CHEROKEE + response->result = FTM_FM_SUCCESS; + + printf("AGC req. ucctrl params = %x\n",fmrequestparams.set_get_agc_req_parameters.ucCtrl); + printf("AGC req. params state = %x\n",fmrequestparams.set_get_agc_req_parameters.ucGainState); + + cmdStatus = FmSetGetResetAGC(fmrequestparams.set_get_agc_req_parameters); + + sleep(1); //In order to get the current value which can be delayed. + + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + response->uccurrentgainstate = fm_global_params.set_get_reset_agc_params.ucCurrentGainState; + response->ucgainstatechange1 = fm_global_params.set_get_reset_agc_params.ucGainStateChange1; + response->ucgainstatechange2 = fm_global_params.set_get_reset_agc_params.ucGainStateChange2; + response->ucgainstatechange3 = fm_global_params.set_get_reset_agc_params.ucGainStateChange3; + + printf("response->result = %d\n", response->result); + + if (fmrequestparams.set_get_agc_req_parameters.ucCtrl == 0x00) { + printf("AGC states set successfully\n"); + } else if (fmrequestparams.set_get_agc_req_parameters.ucCtrl == 0x02) { + printf("AGC states reset successfully\n"); + } else { + printf("AGC response: \nCurrentGainState: %x\nGainStateChangeBack1: %x\nGainStateChangeBack2:\ + %x\nGainStateChangeBack3: %x\n", response->uccurrentgainstate, response->ucgainstatechange1, + response->ucgainstatechange2, response->ucgainstatechange3); + } + + return response; + +#else + printf("response->result = %d\n", response->result); + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + +#endif + +} + +/*=========================================================================== +FUNCTION ftm_fm_read_rds_grp_cntrs + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + FmReadRdsGrpCntrs, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Read RDS Grp + counters FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ + + +PACKED void * ftm_fm_read_rds_grp_cntrs +( +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + ReadRDSCntrs_responce * response = (ReadRDSCntrs_responce *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(ReadRDSCntrs_responce) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = FmRDSGrpcntrs(fmrequestparams.rds_grp_counters); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + memcpy(&response->read_rds_cntrs.totalRdsSBlockErrors , + &fm_global_params.rds_group_counters,sizeof(fm_rds_grp_cntrsparams)); + return response; +} +/*=========================================================================== +FUNCTION ftm_fm_read_rds_grp_cntrs_ext + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + FmReadRdsGrpCntrsExt, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Read RDS Grp + counters FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ + + +PACKED void * ftm_fm_read_rds_grp_cntrs_ext +( +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + ReadRDSCntrs_ext_response * response = (ReadRDSCntrs_ext_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(ReadRDSCntrs_ext_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + +#ifdef FM_SOC_TYPE_CHEROKEE + response->result = FTM_FM_SUCCESS; + cmdStatus = FmRDSGrpcntrsExt(fmrequestparams.rds_grp_counters_ext); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + memcpy(&response->read_rds_cntrs_ext.totalRdsSyncLoss , + &fm_global_params.rds_group_counters_extended,sizeof(fm_rds_grpcntrs_extendedparams)); + return response; +#else + printf("response->result = %d\n", response->result); + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; +#endif +} + +/*=========================================================================== +FUNCTION ftm_fm_default_read + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + FmDefaultRead, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Read Default FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ + +PACKED void * ftm_fm_default_read +( +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + default_read_rsp * response = (default_read_rsp *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(default_read_rsp) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if ((fmPowerState != FM_RX_ON) && (fmPowerState != FM_TX_ON)) + { + response->status= convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } +#ifdef FTM_DEBUG + printf("\n Inside ftm_fm_read_defaults() function...\n"); +#endif + + cmdStatus = FmDefaultRead(fmrequestparams.rd_default); + response->status = convert_cmdstatus_to_ftmstatus(cmdStatus); +#ifdef FTM_DEBUG + printf("\nValue of 'response->status'is %d",response->status); +#endif + if (response->status == FTM_FM_SUCCESS) { + response->data_length = fm_global_params.default_read_data.data_length; + memcpy(&response->data[0], &fm_global_params.default_read_data.data[0], + response->data_length); + } + return response; +} +/*=========================================================================== +FUNCTION ftm_fm_default_write + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + DefaultWrite, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the write Default FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ + +PACKED void * ftm_fm_default_write +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if ((fmPowerState != FM_RX_ON) && (fmPowerState != FM_TX_ON)) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_DISALLOWED); + return response; + } +#ifdef FTM_DEBUG + printf("\n Inside ftm_fm_rx_write_defaults() function...\n"); +#endif + cmdStatus = FmDefaultWrite(&fmrequestparams.wr_default); +#ifdef FTM_DEBUG + printf("\nValue of 'cmdStatus' is %d",cmdStatus); +#endif + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); +#ifdef FTM_DEBUG + printf("\nValue of 'response->result' is %d",response->result); +#endif + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_tx_pwr_lvl_cfg + +DESCRIPTION + + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the tx power level + configuration command + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_pwr_lvl_cfg +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc(DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if (fmPowerState != FM_TX_ON) { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; +#ifdef FTM_DEBUG + printf("FM Tx power configuration to = %x", fmrequestparams.tx_pwr_cfg); +#endif + + cmdStatus = FmTxPwrLvlCfg(fmrequestparams.tx_pwr_cfg); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_tx_tone_generation + +DESCRIPTION + + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the tx tonoe generator + command + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_tx_tone_generation +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_TX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + +#ifdef FTM_DEBUG + printf("FM Tx tone type is setting to = %x",fmrequestparams.tx_tone_param); +#endif + + cmdStatus = FmTxToneGen(fmrequestparams.tx_tone_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_set_hlsi + +DESCRIPTION + + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set HlSi + command + +SIDE EFFECTS + None + +===========================================================================*/ + +PACKED void * ftm_fm_set_hlsi +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + +#ifdef FTM_DEBUG + printf("FM Rx HlSi is setting to = %x",fmrequestparams.hlsi); +#endif + + cmdStatus = FmSetHlSi(fmrequestparams.hlsi); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} +/*=========================================================================== +FUNCTION ftm_fm_set_notch_filter + +DESCRIPTION + + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set notch filter + command + +SIDE EFFECTS + None + +===========================================================================*/ + +PACKED void * ftm_fm_set_notch_filter +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + +#ifdef FTM_DEBUG + printf("FM Rx Notch filter is setting to = %x",fmrequestparams.notch); +#endif + + cmdStatus = FmSetNotchFilter(fmrequestparams.notch); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + printf("responce->staus= %d",response->result); + return response; +} + + + + +/*=========================================================================== +FUNCTION ftm_fm_rx_setstereomode_receiver + +DESCRIPTION + HAL routine to process the response from the PFAL layer call + SetStereoModeReceiver, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set Stereo Mode + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_setstereomode_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + stereomode_response * response = (stereomode_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(stereomode_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetStereoModeReceiver(fmrequestparams.stereo_param); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + response->stereomode = fmrequestparams.stereo_param; + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_getstationparameters_receiver + +DESCRIPTION + HAL routine to aggregrate the reponse from the PFAL layer call + GetStationParametersReceiver, also constructs the response packet + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Get Station + parameters FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_getstationparameters_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + fm_station_params_available getparamavble; + fm_rx_get_station_parameters_response * response = (fm_rx_get_station_parameters_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(fm_rx_get_station_parameters_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = GetStationParametersReceiver(&getparamavble); + if(cmdStatus == FM_CMD_SUCCESS) + { + response->result = FTM_FM_SUCCESS; + response->stationFreq = getparamavble.current_station_freq; + response->servAvble = getparamavble.service_available; + response->rssi = getparamavble.rssi; + response->stereoProgram = getparamavble.stype; + response->rdsSyncStatus = getparamavble.rds_sync_status; + response->muteMode = getparamavble.mute_status; + } + return response; +} +/*=========================================================================== +FUNCTION ftm_fm_rx_setrdsoptions_receiver + +DESCRIPTION + HAL routine to set the RDS options for the RDS/RDBS subsystem. + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set RDS options + FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_setrdsoptions_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetRdsOptionsReceiver(fmrequestparams.rds_options); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_setrdsgroupproc_receiver + +DESCRIPTION + HAL routine to set the RDS group process options for the RDS/RDBS + subsystem. + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the Set RDS group proc + options FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ + +PACKED void * ftm_fm_rx_setrdsgroupproc_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetRdsGroupProcReceiver(fmrequestparams.rds_group_options); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_setpowermode_receiver + +DESCRIPTION + HAL routine to set the power mode of FM Receiver Operation + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_setpowermode_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetPowerModeReceiver(fmrequestparams.power_mode); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_setsignalthreshold_receiver + +DESCRIPTION + HAL routine to set the signal threshold of FM Receiver + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_setsignalthreshold_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SetSignalThresholdReceiver(fmrequestparams.signal_threshold); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_getsignalthreshold_receiver + +DESCRIPTION + HAL routine to get the signal threshold of FM Receiver + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_getsignalthreshold_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + threshold_response * response = (threshold_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(threshold_response) + ); + uint8 threshold; + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = GetSignalThresholdReceiver(&threshold); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + response->threshold = threshold; + return response; +} + + +/*=========================================================================== +FUNCTION ftm_fm_rx_getrssilimit_receiver + +DESCRIPTION + HAL routine to print the rssi limit of FM Receiver + This command is used for debug purposes + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_getrssilimit_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = GetRSSILimits(); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_getpsinfo_receiver + +DESCRIPTION + HAL routine to print the PS info of tuned channel on the Diag + This command is used for debug purposes + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_getpsinfo_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + fmrdsps_response * response = (fmrdsps_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(fmrdsps_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + memcpy(response->string, fm_global_params.pgm_services, + fm_global_params.fm_ps_length); + response->length = fm_global_params.fm_ps_length; + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_getrtinfo_receiver + +DESCRIPTION + HAL routine to print the Radio text data of tuned channel on the Diag + This command is used for debug purposes + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_getrtinfo_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + fmrdsrt_response * response = (fmrdsrt_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(fmrdsrt_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + memcpy(response->string, fm_global_params.radio_text, + fm_global_params.fm_rt_length); + response->length = fm_global_params.fm_rt_length; + return response; +} + + +/*=========================================================================== +FUNCTION ftm_fm_rx_getafinfo_receiver + +DESCRIPTION + HAL routine to print the Alternate Frequency list of current tuned channel + on the Diag. This command is used for debug purposes + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + None + +===========================================================================*/ +PACKED void * ftm_fm_rx_getafinfo_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = GetAFInfoReceiver(); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_searchstations_receiver + +DESCRIPTION + HAL routine to search for stations from the currently tuned frequency + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + The Result of the search will be output on the Diag through debug messages + +===========================================================================*/ +PACKED void * ftm_fm_rx_searchstations_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SearchStationsReceiver(fmrequestparams.search_stations_options); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_searchrdsstations_receiver + +DESCRIPTION + HAL routine to search for stations from the currently tuned frequency with + a specific program type match + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + The Result of the search will be output on the Diag through debug messages + +===========================================================================*/ +PACKED void * ftm_fm_rx_searchrdsstations_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SearchRdsStationsReceiver(fmrequestparams.search_rds_stations_options); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== +FUNCTION ftm_fm_rx_searchstationslist_receiver + +DESCRIPTION + HAL routine to search for list of stations from the currently tuned frequency with + a specific program type match,signal quality etc + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + The Result of the search will be output on the Diag through debug messages + +===========================================================================*/ +PACKED void * ftm_fm_rx_searchstationslist_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = SearchStationListReceiver(fmrequestparams.search_list_stations_options); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + + +/*=========================================================================== +FUNCTION ftm_fm_rx_cancelsearch_receiver + +DESCRIPTION + HAL routine to cancel the previous search for stations + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + NONE + +===========================================================================*/ +PACKED void * ftm_fm_rx_cancelsearch_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = CancelSearchReceiver(); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} +/*=========================================================================== +FUNCTION ftm_fm_rx_fmbuswrite_receiver + +DESCRIPTION + HAL routine to perform a I2C bus write operation to FM Slave ID + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + NONE + +===========================================================================*/ +PACKED void * ftm_fm_rx_fmbuswrite_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = FmBusWriteReceiver(fmrequestparams.i2c_params); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + + +/*=========================================================================== +FUNCTION ftm_fm_rx_fmbusread_receiver + +DESCRIPTION + HAL routine to perform a I2C bus read operation to FM Slave ID + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the generic response to the FTM FM + packet + +SIDE EFFECTS + NONE + +===========================================================================*/ +PACKED void * ftm_fm_rx_fmbusread_receiver +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + fmbusread_response * response = (fmbusread_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(fmbusread_response) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + response->result = FTM_FM_SUCCESS; + cmdStatus = FmBusReadReceiver(&fmrequestparams.i2c_params); + response->length = fmrequestparams.i2c_params.payload_length; + memcpy(response->data,fmrequestparams.i2c_params.data,fmrequestparams.i2c_params.payload_length); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + + +/*=========================================================================== + +FUNCTION ftm_fm_rx_get_af_threshold + +DESCRIPTION + This function is used to get the current AF threshold of the FM SoC + +DEPENDENCIES + none + +===========================================================================*/ +PACKED void* ftm_fm_rx_get_af_threshold +( +void +) +{ + fm_cmd_status_type fmCmdStatus = FM_CMD_SUCCESS; + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + fmrxsetafthreshold_response * response = (fmrxsetafthreshold_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( fmrxsetafthreshold_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + /* Populate the registers 0x20-0x2F */ + common_handle.slaveaddress = FM_SLAVE_ADDR; + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x0F; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + usleep(WAIT_ON_ISR_DELAY); + + /* Read the RDS AF threshold value */ + common_handle.offset = AFTH_OFFSET; + common_handle.payload_length = 0x02; + + /* Clear buffer */ + memset(&common_handle.data[0], + 0, + sizeof(common_handle.data)); + + if (FM_CMD_SUCCESS != FmBusReadReceiver(&common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + printf(" Get AF threshold data [0] = 0x%x data[1] = 0x%x\n",common_handle.data[0],common_handle.data[1]); + +out : + response->afthreshold = (common_handle.data[0] << 8) | (common_handle.data[1]); + + if(FM_CMD_SUCCESS != fmCmdStatus) + { + printf(" ftm_fm_get_af_threshold Failure - %d", fmCmdStatus); + response->result = FTM_FAIL; + } + else + { + printf(" ftm_fm_get_af_threshold - FM_CMD_SUCCESS\n"); + printf(" ftm_fm_get_af_threshold = 0x%x \n", response->afthreshold); + response->result = FTM_FM_SUCCESS; + } + + return response; +} + +/*=========================================================================== + +FUNCTION ftm_fm_rx_get_rssi_check_timer + +DESCRIPTION + This function is used to get the configured periodic timer to monitor + channel quality + +DEPENDENCIES + none + +===========================================================================*/ +PACKED void* ftm_fm_rx_get_rssi_check_timer +( +void +) +{ + fm_cmd_status_type fmCmdStatus = FM_CMD_SUCCESS; + + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + + fmrxsetrssichecktimer_response * response = (fmrxsetrssichecktimer_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( fmrxsetrssichecktimer_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + /* Populate the registers 0x20-0x2C */ + common_handle.slaveaddress = FM_SLAVE_ADDR; + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x16; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + usleep(WAIT_ON_ISR_DELAY); + + /* Read the CHCOND value */ + common_handle.offset = CHCOND_OFFSET; + common_handle.payload_length = 0x01; + + /* Clear buffer */ + memset(&common_handle.data[0], + 0, + sizeof(common_handle.data)); + + if (FM_CMD_SUCCESS != FmBusReadReceiver(&common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + } +out : + response->rssitimer = common_handle.data[0]; + + if(FM_CMD_SUCCESS != fmCmdStatus) + { + printf(" ftm_fm_get_rssi_check_timer Failure - %d\n", fmCmdStatus); + response->result = FTM_FAIL; + } + else + { + printf(" ftm_fm_get_rssi_check_timer - FM_CMD_SUCCESS\n"); + printf(" ftm_fm_get_rssi_check_timer = 0x%x \n", response->rssitimer); + response->result = FTM_FM_SUCCESS; + } + return response; +} + +/*=========================================================================== + +FUNCTION ftm_fm_rx_get_rds_pi_timer + +DESCRIPTION + This function is used to get the time set to wait for an RDS interrupt before + reporting no RDS data + +DEPENDENCIES + none + +===========================================================================*/ +PACKED void* ftm_fm_rx_get_rds_pi_timer +( +void +) +{ + fm_cmd_status_type fmCmdStatus = FM_CMD_SUCCESS; + + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + + fmrxsetrdspitimer_response * response = (fmrxsetrdspitimer_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( fmrxsetrdspitimer_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + /* Populate the registers 0x20-0x2C */ + common_handle.slaveaddress = FM_SLAVE_ADDR; + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x16; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + usleep(WAIT_ON_ISR_DELAY); + /* Read the RDS timeout value */ + common_handle.offset = RDSTIMEOUT_OFFSET; + common_handle.payload_length = 0x01; + + /* Clear buffer */ + memset(&common_handle.data[0], + 0, + sizeof(common_handle.data)); + + if (FM_CMD_SUCCESS != FmBusReadReceiver(&common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + } + +out : + response->rdspitimer = common_handle.data[0]; + + if(FM_CMD_SUCCESS != fmCmdStatus) + { + printf(" ftm_fm_get_rds_pi_timer Failure - %d\n", fmCmdStatus); + response->result = FTM_FAIL; + } + else + { + printf(" ftm_fm_get_rds_pi_timer - FM_CMD_SUCCESS\n"); + printf(" ftm_fm_get_rds_pi_timer = 0x%x \n", response->rdspitimer); + response->result = FTM_FM_SUCCESS; + } + return response; +} +/*=========================================================================== + +FUNCTION ftm_fm_rx_set_af_threshold + +DESCRIPTION + This function is used to set the AF threshold of the FM SoC + +DEPENDENCIES + none + +===========================================================================*/ + +PACKED void* ftm_fm_rx_set_af_threshold +( +void +) +{ + fm_cmd_status_type fmCmdStatus = FM_CMD_SUCCESS; + + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + fmrxsetafthreshold_response * response = (fmrxsetafthreshold_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( fmrxsetafthreshold_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + /* Populate the registers 0x20-0x2F */ + common_handle.slaveaddress = FM_SLAVE_ADDR; + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x0F; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + /* Wait for 15 ms to allow the SoC to poulate the registers 0x20-0x2F */ + usleep(WAIT_ON_ISR_DELAY); + + /* Override the RDS AF threshold value */ + common_handle.offset = AFTH_OFFSET; + common_handle.data[0] = ((fmrequestparams.rx_af_threshold >> 8) & 0xFF); + common_handle.data[1] = ((fmrequestparams.rx_af_threshold) & 0xFF); + common_handle.payload_length = 0x02; + + printf(" Set AF threshold data [0] = 0x%x data[1] = 0x%x\n",common_handle.data[0],common_handle.data[1]); + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + /* Apply back the new values */ + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x8F; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + +out : + response->afthreshold = fmrequestparams.rx_af_threshold; + + if(FM_CMD_SUCCESS != fmCmdStatus) + { + printf(" FmApi_SetAfThreshold Failure - %d\n", fmCmdStatus); + response->result = FTM_FAIL; + } + else + { + printf(" FmApi_SetAfThreshold - fmrequestparams.rx_af_threshold = 0x%x\n", fmrequestparams.rx_af_threshold); + response->result = FTM_FM_SUCCESS; + } + + return response; + +} + +/*=========================================================================== + +FUNCTION ftm_fm_rx_set_rssi_check_timer + +DESCRIPTION + This function is used to set the periodic timer to monitor channel quality + +DEPENDENCIES + none + +===========================================================================*/ + +PACKED void* ftm_fm_rx_set_rssi_check_timer +( +void +) +{ + fm_cmd_status_type fmCmdStatus= FM_CMD_SUCCESS; + + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + + fmrxsetrssichecktimer_response * response = (fmrxsetrssichecktimer_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( fmrxsetrssichecktimer_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + printf(" ftm_fm_set_rssi_check_timer gtsFtmFM.tuFmParams.ucRxRssichecktimer = %d\n",fmrequestparams.rx_rssi_checktimer); + /* Populate the registers 0x20-0x2C */ + common_handle.slaveaddress = FM_SLAVE_ADDR; + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x16; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + /* Wait for 15 ms to allow the SoC to poulate the registers 0x20-0x2C */ + usleep(WAIT_ON_ISR_DELAY); + + /* Override the CHCOND value */ + common_handle.offset = CHCOND_OFFSET; + common_handle.data[0] = (fmrequestparams.rx_rssi_checktimer & 0xFF); + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + /* Apply back the new values */ + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x96; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + +out : + response->rssitimer = fmrequestparams.rx_rssi_checktimer; + + if(FM_CMD_SUCCESS != fmCmdStatus) + { + printf(" FmApi_SetRssiCheckTimer Failure - %d\n", fmCmdStatus); + response->result = FTM_FAIL; + } + else + { + printf(" FmApi_SetRssiCheckTimer - fmrequestparams.rx_rssi_checktimer = %d\n", + fmrequestparams.rx_rssi_checktimer); + response->result = FTM_FM_SUCCESS; + } + + return response; +} + +/*=========================================================================== + +FUNCTION ftm_fm_rx_set_rds_pi_timer + +DESCRIPTION + This function is used to set the time to wait for an RDS interrupt before + reporting no RDS data + +DEPENDENCIES + none + +===========================================================================*/ + +PACKED void* ftm_fm_rx_set_rds_pi_timer +( +void +) +{ + fm_cmd_status_type fmCmdStatus = FM_CMD_SUCCESS; + + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + + fmrxsetrdspitimer_response * response = (fmrxsetrdspitimer_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( fmrxsetrdspitimer_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + printf(" ftm_fm_set_rds_pi_timer gtsFtmFM.tuFmParams.ucRxRdsPItimer = %d\n",fmrequestparams.rx_rds_pi_timer); + /* Populate the registers 0x20-0x2C */ + common_handle.slaveaddress = FM_SLAVE_ADDR; + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x16; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + /* Wait for 15 ms to allow the SoC to poulate the registers 0x20-0x2C */ + usleep(WAIT_ON_ISR_DELAY); + + /* Override the RDS timeout value */ + common_handle.offset = RDSTIMEOUT_OFFSET; + common_handle.data[0] = (fmrequestparams.rx_rds_pi_timer & 0xFF); + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + + /* Apply back the new values */ + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = 0x96; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + +out : + response->rdspitimer = fmrequestparams.rx_rds_pi_timer; + if(FM_CMD_SUCCESS != fmCmdStatus) + { + printf(" FmApi_SetRdsPiTimer Failure - %d\n", fmCmdStatus); + response->result = FTM_FAIL; + } + else + { + printf(" FmApi_SetRdsPiTimer - fmrequestparams.rx_rds_pi_timer = %d\n", + fmrequestparams.rx_rds_pi_timer); + response->result = FTM_FM_SUCCESS; + } + + return response; + +} +/*=========================================================================== + +FUNCTION ftm_fm_rx_get_sinr_samples + +DESCRIPTION + This function is used to get the signal to noise ratio samples + +DEPENDENCIES + none + +===========================================================================*/ + +PACKED void * ftm_fm_rx_get_sinr_samples +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + getsinrsamples_response * response = (getsinrsamples_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(getsinrsamples_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = GetSINRSamples(); + response->sinr_sample = fm_global_params.sinr_samples; + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*=========================================================================== + +FFUNCTION ftm_fm_rx_set_sinr_samples + +DESCRIPTION + This function is used to set the signal to noise ratio samples to take into + accounts for SINR avg calculation + +DEPENDENCIES + none + +===========================================================================*/ + +PACKED void * ftm_fm_rx_set_sinr_samples +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = SetSINRSamples( fmrequestparams.sinr_samples ); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*======================================================================== + FUNCTION ftm_fm_rx_get_sinr_threshold + +DESCRIPTION + This function is used to get the SINR threshold + +DEPENDENCIES + none + +==========================================================================*/ +PACKED void * ftm_fm_rx_get_sinr_threshold +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + getsinrthreshold_response * response = (getsinrthreshold_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(getsinrthreshold_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = GetSINRThreshold(); + response->sinr_threshold = fm_global_params.sinr_threshold; + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} +/*======================================================================== + FUNCTION ftm_fm_rx_set_sinr_threshold + +DESCRIPTION + This function is used to set the SINR threshold + +DEPENDENCIES + none + +==========================================================================*/ +PACKED void * ftm_fm_rx_set_sinr_threshold +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = SetSINRThreshold( fmrequestparams.sinr_threshold ); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*======================================================================== + FUNCTION ftm_fm_rx_get_onchannel_threshold + +DESCRIPTION + This function is used to get the on channel threshold + +DEPENDENCIES + none + +==========================================================================*/ +PACKED void * ftm_fm_rx_get_onchannel_threshold +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + getonchannelthreshold_response * response = (getonchannelthreshold_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(getonchannelthreshold_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = GetOnChannelThreshold(); + response->sinr_on_th = fm_global_params.On_channel_threshold; + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*======================================================================== + FUNCTION ftm_fm_rx_set_onchannel_threshold + +DESCRIPTION + This function is used to set the on channel threshold + +DEPENDENCIES + none + +==========================================================================*/ + +PACKED void * ftm_fm_rx_set_onchannel_threshold +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = SetOnChannelThreshold( fmrequestparams.On_channel_threshold ); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + +/*======================================================================== + FUNCTION ftm_fm_rx_get_offchannel_threshold + +DESCRIPTION + This function is used to get the Off channel threshold + +DEPENDENCIES + none + +==========================================================================*/ +PACKED void * ftm_fm_rx_get_offchannel_threshold +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + getoffchannelthreshold_response * response = (getoffchannelthreshold_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(getoffchannelthreshold_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = GetOffChannelThreshold(); + response->sinr_off_th = fm_global_params.Off_channel_threshold; + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} +/*======================================================================== + FUNCTION ftm_fm_rx_set_offchannel_threshold + +DESCRIPTION + This function is used to set the off channel threshold + +DEPENDENCIES + none + +==========================================================================*/ +PACKED void * ftm_fm_rx_set_offchannel_threshold +( + void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof(generic_response) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + if(fmPowerState != FM_RX_ON) + { + response->result = convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + return response; + } + response->result = FTM_FM_SUCCESS; + cmdStatus = SetOffChannelThreshold( fmrequestparams.Off_channel_threshold ); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + return response; +} + + +/*=========================================================================== + +FUNCTION ftm_fm_rx_get_rds_block_err + +DESCRIPTION + This function is used to get the current RDS block error parameters + +DEPENDENCIES + none + +===========================================================================*/ +PACKED void* ftm_fm_rx_get_rds_block_err +( +void +) +{ + fm_cmd_status_type fmCmdStatus = FM_CMD_SUCCESS; + + + rds_err_count_response * response = (rds_err_count_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( rds_err_count_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + common_handle.slaveaddress = FM_SLAVE_ADDR; + common_handle.offset = XFR_CTRL_OFFSET; + common_handle.data[0] = FTM_FM_RDS_COUNT; + common_handle.payload_length = 0x01; + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + usleep(WAIT_ON_ISR_DELAY); + /* Read the RDS block error rate */ + common_handle.offset = RDSERR_OFFSET; + common_handle.payload_length = 0x08; + + /* Clear buffer */ + memset(&common_handle.data[0], + 0, + sizeof(common_handle.data)); + + if (FM_CMD_SUCCESS != FmBusReadReceiver(&common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + } + +out : + response->rdserrcount = ((common_handle.data[0] << 24) | (common_handle.data[1] << 16) + | (common_handle.data[2] << 8) | common_handle.data[3]); + response->numofblocks = BLOCKS_PER_GROUP *((common_handle.data[4] << 24) | (common_handle.data[5] << 16) + | (common_handle.data[6] << 8) | common_handle.data[7]); + + if(FM_CMD_SUCCESS != fmCmdStatus) + { + printf(" ftm_fm_rx_get_rds_block_err Failure - %d\n", fmCmdStatus); + response->result = FTM_FAIL; + } + else + { + printf(" ftm_fm_rx_get_rds_block_err - FM_CMD_SUCCESS\n"); + printf(" ftm_fm_rx_get_rds_block_err = 0x%x 0x%x\n", (unsigned int)response->rdserrcount,(unsigned int)response->numofblocks); + response->result = FTM_FM_SUCCESS; + } + return response; +} + + +/*=========================================================================== + +FUNCTION ftm_fm_enable_audio + +DESCRIPTION + This function is used to take the audio output mode from QRCT. + +DEPENDENCIES + none + +===========================================================================*/ +PACKED void* ftm_fm_enable_audio +( +void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( generic_response ) + ); + + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + printf("enter ftm_fm_enable_audio\n"); + + if (response != NULL) { + response->result = FTM_FM_SUCCESS; + mkfifo(audio_ftm_cmds, 0777) ; + + fm_audio_output = fmrequestparams.audio_output; + cmdStatus = ftm_fm_audio(fm_audio_output, init_audio_vlm); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); + } else + printf("ftm_fm_enable_audio unable to allocate memory for response packet \n"); + + return response; +} + + +/*=========================================================================== + +FUNCTION ftm_fm_setting_volume + +DESCRIPTION + This function is used to set the FM volume. + +DEPENDENCIES + none + +===========================================================================*/ +#define MSEC_TO_NSEC (1000 * 1000) + +#ifdef FM_SOC_TYPE_CHEROKEE +#define DISABLE_SLIMBUS_DATA_PORT 0 +#define ENABLE_SLIMBUS_DATA_PORT 1 +#define ENABLE_SLIMBUS_CLOCK_DATA 2 +#endif + +PACKED void* ftm_fm_setting_volume +( +void +) +{ + fm_cmd_status_type cmdStatus = FM_CMD_UNRECOGNIZED_CMD; + struct timespec ts; + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( generic_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + printf("enter ftm_fm_setting_volume\n"); + ts.tv_sec = 0; + ts.tv_nsec = 100 * MSEC_TO_NSEC; + + if (response != NULL) { + response->result = FTM_FM_SUCCESS; + printf("Disabling audio"); + ftm_fm_disable_audio(); +#ifdef FM_SOC_TYPE_CHEROKEE + nanosleep(&ts, NULL); + ftm_fm_enable_slimbus(DISABLE_SLIMBUS_DATA_PORT); +#endif + + printf("audio_output = %d", fmrequestparams.audio_output); + printf("audio_vlm = %d",fmrequestparams.audio_vlm); + cmdStatus = ftm_fm_audio(fm_audio_output, fmrequestparams.audio_vlm); + response->result = convert_cmdstatus_to_ftmstatus(cmdStatus); +#ifdef FM_SOC_TYPE_CHEROKEE + sleep(1); + ftm_fm_enable_slimbus(ENABLE_SLIMBUS_DATA_PORT); +#endif + } else + printf("ftm_fm_setting_volume NULL repsonse packet\n"); + + return response; +} +/*=========================================================================== + +FUNCTION ftm_fm_rx_reset_rds_err_count + +DESCRIPTION + This function is used to reseet the current RDS block error parameters + +DEPENDENCIES + none + +===========================================================================*/ +PACKED void* ftm_fm_rx_reset_rds_err_count +( +void +) +{ + fm_cmd_status_type fmCmdStatus = FM_CMD_SUCCESS; + /* Default data to be written for Marimba versions + * not applicable for Bahama versions + */ + uint8 uData[] = { 0xD0 ,0x03 ,0xCE, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + + generic_response * response = (generic_response *) + diagpkt_subsys_alloc( DIAG_SUBSYS_FTM + , FTM_FM_CMD_CODE + , sizeof( generic_response ) + ); + if(response == NULL) + { + printf("%s Failed to allocate resource",__func__); + return (void *)convert_cmdstatus_to_ftmstatus(FM_CMD_NO_RESOURCES); + } + + /* if chip version not determined we can't reset */ + if(chipVersion == 0) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + if((chipVersion == FMQSOCCOM_FM6500_WCN2243_10_VERSION) || + (chipVersion == FMQSOCCOM_FM6500_WCN2243_20_VERSION)) + { + uint8 uData_bahama[] = {0xD0, 0x00, 0xE6, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00}; + printf("Chip Id is 0x%x\n",chipVersion); + /* The Reset data for Bahama is different from + * Marimba the data is dynamically selected based + * on ChipVersion + */ + memcpy(uData,uData_bahama,sizeof(uData)); + } + common_handle.slaveaddress = FM_SLAVE_ADDR; + common_handle.offset = XFR_CTRL_OFFSET; + /* Copy the data to i2c request buffer */ + memcpy(&common_handle.data[0], + uData, + sizeof(uData)); + common_handle.payload_length = sizeof(uData); + + if (FM_CMD_SUCCESS != FmBusWriteReceiver(common_handle)) + { + fmCmdStatus = FM_CMD_FAILURE; + goto out; + } + + usleep(WAIT_ON_ISR_DELAY); + +out: + if(FM_CMD_SUCCESS != fmCmdStatus) + { + printf(" ftm_fm_reset_rds_err_count Failure - %d", fmCmdStatus); + response->result = FTM_FAIL; + } + else + { + printf(" ftm_fm_reset_rds_err_count - FM_CMD_SUCCESS"); + response->result = FTM_FM_SUCCESS; + } + return(response); + +} + + +/*=========================================================================== +FUNCTION ftm_fm_dispatch + +DESCRIPTION + Dispatch routine for the various FM Rx/Tx commands. Copies the data into + a global union data structure before calling the processing routine + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ +void * ftm_fm_dispatch(ftm_fm_pkt_type *ftm_fm_pkt, uint16 length ) +{ + ftm_fm_sub_cmd_type ftm_fm_sub_cmd; + + UNUSED(length); + ftm_fm_sub_cmd = (ftm_fm_sub_cmd_type)ftm_fm_pkt->cmd_id; +#ifdef FTM_DEBUG + printf("ftm_fm_pkt->cmd_id = %d\n cmd_data_len = %d\n", ftm_fm_pkt->cmd_id,ftm_fm_pkt->cmd_data_len); +#endif + ftm_fm_copy_request_data(ftm_fm_pkt,ftm_fm_pkt->cmd_data_len); + switch(ftm_fm_sub_cmd) + { + if(!fm_passthrough) + { + case FTM_FM_RX_ENABLE_RECEIVER: + return(ftm_fm_rx_enable_receiver()); + case FTM_FM_RX_DISABLE_RECEIVER: + return(ftm_fm_rx_disable_receiver()); + case FTM_FM_RX_CONFIGURE_RECEIVER: + return(ftm_fm_rx_configure_receiver()); + case FTM_FM_RX_SET_STATION: + return(ftm_fm_rx_setfrequency_receiver()); + case FTM_FM_RX_SET_MUTE_MODE: + return(ftm_fm_rx_setmutemode_receiver()); + case FTM_FM_RX_SET_STEREO_MODE: + return(ftm_fm_rx_setstereomode_receiver()); + case FTM_FM_RX_GET_STATION_PARAMETERS: + return(ftm_fm_rx_getstationparameters_receiver()); + case FTM_FM_RX_RDS_GROUP_OPTIONS : + return (ftm_fm_rx_setrdsoptions_receiver()); + case FTM_FM_RX_SET_POWER_MODE : + return (ftm_fm_rx_setpowermode_receiver()); + case FTM_FM_RX_SET_SIGNAL_THRESHOLD : + return (ftm_fm_rx_setsignalthreshold_receiver()); + case FTM_FM_RX_GET_RSSI_LIMIT : + return (ftm_fm_rx_getrssilimit_receiver()); + case FTM_FM_RX_SEARCH_STATIONS : + return (ftm_fm_rx_searchstations_receiver()); + case FTM_FM_RX_SEARCH_RDS_STATIONS : + return (ftm_fm_rx_searchrdsstations_receiver()); + case FTM_FM_RX_SEARCH_STATIONS_LIST : + return (ftm_fm_rx_searchstationslist_receiver()); + case FTM_FM_RX_CANCEL_SEARCH: + return (ftm_fm_rx_cancelsearch_receiver()); + case FTM_FM_RX_GET_PS_INFO : + return (ftm_fm_rx_getpsinfo_receiver()); + case FTM_FM_RX_GET_RT_INFO : + return (ftm_fm_rx_getrtinfo_receiver()); + case FTM_FM_RX_GET_AF_INFO : + return (ftm_fm_rx_getafinfo_receiver()); + case FTM_FM_BUS_WRITE: + return (ftm_fm_rx_fmbuswrite_receiver()); + case FTM_FM_BUS_READ: + return (ftm_fm_rx_fmbusread_receiver()); + case FTM_FM_RX_RDS_GROUP_PROC_OPTIONS: + return (ftm_fm_rx_setrdsgroupproc_receiver()); + case FTM_FM_RX_GET_AF_THRESHOLD: + return(ftm_fm_rx_get_af_threshold()); + case FTM_FM_RX_GET_RSSI_CHECK_TIMER: + return(ftm_fm_rx_get_rssi_check_timer()); + case FTM_FM_RX_GET_RDS_PI_TIMER: + return(ftm_fm_rx_get_rds_pi_timer()); + case FTM_FM_RX_SET_AF_THRESHOLD: + return(ftm_fm_rx_set_af_threshold()); + case FTM_FM_RX_SET_RSSI_CHECK_TIMER: + return(ftm_fm_rx_set_rssi_check_timer()); + case FTM_FM_RX_SET_RDS_PI_TIMER: + return(ftm_fm_rx_set_rds_pi_timer()); + case FTM_FM_RX_GET_SIGNAL_THRESHOLD : + return (ftm_fm_rx_getsignalthreshold_receiver()); + case FTM_FM_RX_GET_RDS_ERR_COUNT : + return (ftm_fm_rx_get_rds_block_err()); + case FTM_FM_RX_RESET_RDS_ERR_COUNT : + return (ftm_fm_rx_reset_rds_err_count()); + case FTM_FM_TX_ENABLE_TRANSMITTER : + return(ftm_fm_tx_enable_transmitter()); + case FTM_FM_TX_CONFIGURE_TRANSMITTER: + return(ftm_fm_tx_configure_transmitter()); + case FTM_FM_TX_DISABLE_TRANSMITTER: + return(ftm_fm_tx_disable_transmitter()); + case FTM_FM_TX_SET_STATION: + return(ftm_fm_tx_setfrequency_transmitter()); + case FTM_FM_TX_TX_PS_INFO : + return ftm_fm_tx_ps_info(); + case FTM_FM_TX_STOP_PS_INFO_TX : + return ftm_fm_tx_stop_ps_info(); + case FTM_FM_TX_TX_RT_INFO : + return ftm_fm_tx_rt_info(); + case FTM_FM_TX_STOP_RT_INFO_TX : + return ftm_fm_tx_stop_rt_info(); + case FTM_FM_TX_GET_PS_FEATURES : + return ftm_fm_tx_get_ps_features(); + case FTM_FM_SET_SOFT_MUTE: + return ftm_fm_set_soft_mute_receiver(); + case FTM_FM_SET_ANTENNA: + return ftm_fm_set_antenna(); + case FTM_FM_POKE_RIVA_WORD: + return ftm_fm_poke_riva_word(); + case FTM_FM_PEEK_RIVA_WORD: + return ftm_fm_peek_riva_word(); + case FTM_FM_PEEK_SSBI: + return ftm_fm_peek_ssbi_reg(); + case FTM_FM_POKE_SSBI: + return ftm_fm_poke_ssbi_reg(); + case FTM_FM_SET_TONE_GENERATION: + return (ftm_fm_tx_tone_generation()); + case FTM_FM_READ_RDS_GRP_CNTRS: + return (ftm_fm_read_rds_grp_cntrs()); + case FTM_FM_READ_RDS_GRP_CNTRS_EXT: + return (ftm_fm_read_rds_grp_cntrs_ext()); + case FTM_FM_SET_HLSI: + return (ftm_fm_set_hlsi()); + case FTM_FM_RX_GET_SINR_SAMPLES: + return (ftm_fm_rx_get_sinr_samples()); + case FTM_FM_RX_SET_SINR_SAMPLES: + return (ftm_fm_rx_set_sinr_samples()); + case FTM_FM_RX_GET_SINR_THRESHOLD: + return (ftm_fm_rx_get_sinr_threshold()); + case FTM_FM_RX_SET_SINR_THRESHOLD: + return (ftm_fm_rx_set_sinr_threshold()); + case FTM_FM_RX_GET_ONCHANNEL_TH: + return (ftm_fm_rx_get_onchannel_threshold()); + case FTM_FM_RX_SET_ONCHANNEL_TH: + return (ftm_fm_rx_set_onchannel_threshold()); + case FTM_FM_RX_GET_OFFCHANNEL_TH: + return (ftm_fm_rx_get_offchannel_threshold()); + case FTM_FM_RX_SET_OFFCHANNEL_TH: + return (ftm_fm_rx_set_offchannel_threshold()); + case FTM_FM_SET_NOTCH_FILTER: + return (ftm_fm_set_notch_filter()); + case FTM_FM_RX_GET_DEFAULTS: + return (ftm_fm_default_read()); + case FTM_FM_RX_SET_DEFAULTS: + return (ftm_fm_default_write()); + case FTM_FM_TX_PWR_LVL_CFG: + return ftm_fm_tx_pwr_lvl_cfg(); + case FTM_FM_SET_GET_RESET_AGC: + return ftm_fm_set_get_reset_agc(); + } + case FTM_FM_ENABLE_AUDIO: + return ftm_fm_enable_audio(); + case FTM_FM_DISABLE_AUDIO: + return ftm_fm_disable_audio(); + case FTM_FM_VOLUME_SETTING: + return ftm_fm_setting_volume(); + default: + if(fm_passthrough) { + if(!enable_mm_fmconfig) + { + ftm_fm_run_mm(); + enable_mm_fmconfig = 1; + } + return bt_ftm_diag_dispatch(ftm_fm_pkt, length); + } + return NULL; + } +} diff --git a/feeds/wifi-ax/ftm/src/ftm_fm_common.h b/feeds/wifi-ax/ftm/src/ftm_fm_common.h new file mode 100755 index 000000000..77025f004 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_fm_common.h @@ -0,0 +1,993 @@ +/*========================================================================== + + FTM FM Common Header File + +Description + Global Data declarations of the ftm fm component. + +# Copyright (c) 2010-2012, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +08/03/2011 uppalas Adding support for new ftm commands +06/18/10 rakeshk Created a header file to hold the definitons for ftm fm + task +07/06/10 rakeshk Clean roomed the data structures and defined data + structures to be passed to the PFAL layers +01/11/11 rakeshk Added support for new FTM APIS +02/09/11 rakeshk Added support for BLER FTM APIs +04/03/11 ananthk Added support for FM FTM Transmit APIs +===========================================================================*/ +#ifdef CONFIG_FTM_FM + +#include "diagpkt.h" +#include "log.h" +#include + +#define FTM_FM_LOG_PKT_ID 65 +#define FTM_FM_CMD_CODE 28 +#define LOG_FTM_FM_C ((uint16) 0x14CC) +#define FEATURE_FTM_FM_DEBUG +#define DEFAULT_DATA_SIZE 249 + +/* FM6500 A0 chip version. + **/ +#define FM6500_A0_VERSION (0x01010013) +/** + * * FM6500 2.0 chip version. + **/ +#define FMQSOCCOM_FM6500_20_VERSION (0x01010010) +/** + * * FM6500 2.1 chip version. + **/ +#define FMQSOCCOM_FM6500_21_VERSION (0x02010204) +/** + * WCN 2243 1.0's FM chip version. + */ +#define FMQSOCCOM_FM6500_WCN2243_10_VERSION (0x0302010A) +/** + * WCN 2243 2.0's FM chip version. + */ +#define FMQSOCCOM_FM6500_WCN2243_20_VERSION (0x04020205) + +extern int chipVersion; + +/* RDS Group processing parameters */ +#define FM_RX_RDS_GRP_RT_EBL 1 +#define FM_RX_RDS_GRP_PS_EBL 2 +#define FM_RX_RDS_GRP_AF_EBL 4 +#ifdef FM_SOC_TYPE_CHEROKEE +#define FM_RX_RDS_GRP_PS_SIMPLE_EBL 8 +#define FM_RX_RDS_GRP_ECC_EBL 32 +#define FM_RX_RDS_GRP_PTYN_EBL 64 +#define FM_RX_RDS_GRP_RT_PLUS_EBL 128 +#else +#define FM_RX_RDS_GRP_PS_SIMPLE_EBL 16 +#endif + + +/* lower and upper band limits of regions */ +#define REGION_US_EU_BAND_LOW 87500 +#define REGION_US_EU_BAND_HIGH 107900 +#define REGION_JAPAN_STANDARD_BAND_LOW 76000 +#define REGION_JAPAN_STANDARD_BAND_HIGH 90000 +#define REGION_JAPAN_WIDE_BAND_LOW 90000 +#define REGION_JAPAN_WIDE_BAND_HIGH 108000 +#define V4L2_CID_PRIVATE_BASE 0x08000000 +#define MAX_RDS_PS_LENGTH 108 +#define MAX_RDS_RT_LENGTH 64 +#define V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS_EXT 0x08000042 + +typedef enum { +V4L2_CID_PRIVATE_IRIS_HLSI = (V4L2_CID_PRIVATE_BASE + 0x1d), +V4L2_CID_PRIVATE_IRIS_SOFT_MUTE, +V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR, +V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN, +V4L2_CID_PRIVATE_IRIS_RIVA_PEEK, +V4L2_CID_PRIVATE_IRIS_RIVA_POKE, +V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR, +V4L2_CID_PRIVATE_IRIS_SSBI_PEEK, +V4L2_CID_PRIVATE_IRIS_SSBI_POKE, +V4L2_CID_PRIVATE_IRIS_TX_TONE, +V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS, +V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER, +V4L2_CID_PRIVATE_IRIS_AGC_CTRL = 0x08000043, +V4L2_CID_PRIVATE_IRIS_AGC_STATE, +V4L2_CID_PRIVATE_IRIS_READ_DEFAULT = 0x00980928,//using private CIDs under userclass +V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT, +}v4l2_cid_private_iris_t_copy; +typedef enum +{ + /* Total no. of PS names that can be transmitted : 12 + Width of each transmitted PS name is : 8 + Total no. of PS characters that can be transmitted : (12*8 = 96) + */ + MAX_TX_PS_LEN = 96, + MAX_TX_PS_RPT_CNT = 15, +}FmTxPSFeatures; + +/* FTM FM command IDs */ +typedef enum +{ +#ifdef FEATURE_FTM_FM_DEBUG + FTM_FM_RX_SET_POWER_MODE = 13, + FTM_FM_RX_SET_SIGNAL_THRESHOLD = 14, + FTM_FM_RX_GET_RSSI_LIMIT = 16, + FTM_FM_RX_GET_PS_INFO = 17, + FTM_FM_RX_GET_RT_INFO = 18, + FTM_FM_RX_GET_AF_INFO = 19, + FTM_FM_RX_SEARCH_STATIONS = 20, + FTM_FM_RX_SEARCH_RDS_STATIONS = 21, + FTM_FM_RX_SEARCH_STATIONS_LIST = 22, + FTM_FM_RX_CANCEL_SEARCH = 23, + FTM_FM_RX_RDS_GROUP_PROC_OPTIONS = 25, + FTM_FM_RX_RDS_PI_MATCH_OPTIONS = 26, + FTM_FM_TX_GET_PS_FEATURES = 36, + FTM_FM_TX_TX_PS_INFO = 38, + FTM_FM_TX_STOP_PS_INFO_TX = 39, + FTM_FM_TX_TX_RT_INFO = 40, + FTM_FM_TX_STOP_RT_INFO_TX = 41, + FTM_FM_RX_GET_SIGNAL_THRESHOLD = 46, + FTM_FM_FMWAN_REG_RD = 51, + FTM_FM_RX_GET_DEFAULTS = 62, + FTM_FM_RX_SET_DEFAULTS = 63, + FTM_FM_RX_GET_SINR_SAMPLES = 64, + FTM_FM_RX_SET_SINR_SAMPLES = 65, + FTM_FM_RX_GET_SINR_THRESHOLD = 66, + FTM_FM_RX_SET_SINR_THRESHOLD = 67, + FTM_FM_RX_GET_ONCHANNEL_TH = 68, + FTM_FM_RX_SET_ONCHANNEL_TH = 69, + FTM_FM_RX_GET_OFFCHANNEL_TH = 70, + FTM_FM_RX_SET_OFFCHANNEL_TH = 71, + FTM_FM_TX_PWR_LVL_CFG = 72, +#endif /* FEATURE_FTM_FM_DEBUG */ + + FTM_FM_RX_ENABLE_RECEIVER = 7, + FTM_FM_RX_DISABLE_RECEIVER = 8, + FTM_FM_RX_CONFIGURE_RECEIVER = 9, + FTM_FM_RX_SET_MUTE_MODE = 10, + FTM_FM_RX_SET_STEREO_MODE = 11, + FTM_FM_RX_SET_STATION = 12, + FTM_FM_RX_GET_STATION_PARAMETERS = 15, + FTM_FM_RX_RDS_GROUP_OPTIONS = 24, + FTM_FM_TX_ENABLE_TRANSMITTER = 33, + FTM_FM_TX_DISABLE_TRANSMITTER = 34, + FTM_FM_TX_CONFIGURE_TRANSMITTER = 35, + FTM_FM_TX_SET_STATION = 37, + FTM_FM_TX_TX_RDS_GROUPS = 42, + FTM_FM_TX_TX_CONT_RDS_GROUPS = 43, + FTM_FM_TX_TX_RDS_CTRL = 44, + FTM_FM_TX_GET_RDS_GROUP_BUF_SIZE = 45, + FTM_FM_BUS_WRITE = 47, + FTM_FM_BUS_READ = 48, + FTM_FM_NOTIFY_WAN = 49, + FTM_FM_NOTIFY_FM = 50, + FTM_FM_ROUTE_AUDIO = 52, + FTM_FM_RX_SET_AF_THRESHOLD = 53, + FTM_FM_RX_SET_RSSI_CHECK_TIMER = 54, + FTM_FM_RX_SET_RDS_PI_TIMER = 55, + FTM_FM_RX_GET_AF_THRESHOLD = 56, + FTM_FM_RX_GET_RSSI_CHECK_TIMER = 57, + FTM_FM_RX_GET_RDS_PI_TIMER = 58, + FTM_FM_RX_GET_RDS_ERR_COUNT = 59, + FTM_FM_RX_RESET_RDS_ERR_COUNT = 60, + FTM_FM_TX_SEARCH_STATIONS = 61, + FTM_FM_SET_HLSI = 100, + FTM_FM_SET_SOFT_MUTE = 101, + FTM_FM_SET_ANTENNA = 102, + FTM_FM_SET_NOTCH_FILTER = 103, + FTM_FM_READ_RDS_GRP_CNTRS = 104, + FTM_FM_SET_TONE_GENERATION = 105, + FTM_FM_PEEK_SSBI = 106, + FTM_FM_POKE_SSBI = 107, + FTM_FM_PEEK_RIVA_WORD = 108, + FTM_FM_POKE_RIVA_WORD = 109, + FTM_FM_ENABLE_AUDIO = 111, + FTM_FM_DISABLE_AUDIO = 112, + FTM_FM_VOLUME_SETTING = 113, + FTM_FM_READ_RDS_GRP_CNTRS_EXT = 114, + FTM_FM_SET_GET_RESET_AGC = 115, + FTM_FM_MAX +} ftm_fm_sub_cmd_type; + +#define XFR_CTRL_OFFSET 0x1F +/* Wait time for ensuring XFR is generated */ +#define WAIT_ON_ISR_DELAY 15000 //15 ms +#define AFTH_OFFSET 0x2E +#define CHCOND_OFFSET 0x22 +#define RDSTIMEOUT_OFFSET 0x25 +#define FM_SLAVE_ADDR 0x2A +#define RDSERR_OFFSET 0x24 +#define RDSRESET_OFFSET 0x20 +#define BLOCKS_PER_GROUP 0x04 +#define FTM_FM_RDS_COUNT 0x11 + + +#define MAX_RIVA_DATA_LEN 245 +#define MAX_RIVA_PEEK_RSP_SIZE 251 +#define SSBI_PEEK_DATA_SIZE 1 + +#define IRIS_BUF_PEEK 6 +#define IRIS_BUF_SSBI_PEEK IRIS_BUF_PEEK+1 +#define IRIS_BUF_RDS_CNTRS IRIS_BUF_SSBI_PEEK+1 +#define IRIS_BUF_RD_DEFAULT IRIS_BUF_RDS_CNTRS+1 +#ifdef FM_SOC_TYPE_CHEROKEE +#define RDS_GRP_CNTRS_SIZE 48 +#else +#define RDS_GRP_CNTRS_SIZE 36 +#endif +/* Generic result, used for any command that only returns an error code */ +typedef enum +{ + FTM_FM_SUCCESS, + FTM_FAIL, + FTM_FILE_DOES_NOT_EXIST, + FTM_MMC_ERROR, + FTM_FM_UNRECOGNIZED_CMD, + FTM_NO_RESOURCES, + FTM_FM_PENDING, + FTM_INVALID_PARAM, + FTM_FM_DISALLOWED, + FTM_TEST_NOT_IMPLEMENTED, + FTM_CUST_HW_ID_UNKNOWN, + FTM_FM_BUS_WRITE_ERROR, + FTM_FM_BUS_READ_ERROR, + FTM_FM_CLIENT_MAX, + +} ftm_fm_api_result_type; + +/* FM power state enum */ +typedef enum +{ + FM_POWER_OFF, + FM_POWER_TRANSITION, + FM_RX_ON, + FM_TX_ON +}fm_power_state; + +/* FM command status enum */ +typedef enum +{ + FM_CMD_SUCCESS, + FM_CMD_PENDING, + FM_CMD_NO_RESOURCES, + FM_CMD_INVALID_PARAM, + FM_CMD_DISALLOWED, + FM_CMD_UNRECOGNIZED_CMD, + FM_CMD_FAILURE +}fm_cmd_status_type; + +/** +* FM event result. +*/ +typedef enum +{ + FM_EV_SUCCESS = 0, + /**< Event indicates success. */ + + FM_EV_FAILURE = 1, + /**< Event is a response to a command that failed */ + + FM_EV_CMD_DISALLOWED = 2, + /**< Event is a response to a command that was disallowed. */ + + FM_EV_CMD_INVALID_PARAM = 3 + /**< Event is a response to a command that contained an invalid parameter. */ + +} FmEvResultType; + +/** +* FM Receiver event names. +*/ +typedef enum +{ + /* ----------------------------------------------- + 1 -> FM Receiver initialization events + ----------------------------------------------- */ + + FM_RX_EV_ENABLE_RECEIVER = 0, + + FM_RX_EV_DISABLE_RECEIVER, + + FM_RX_EV_CFG_RECEIVER, + + /* ----------------------------------------------- + 2 -> FM receiver control events + ----------------------------------------------- */ + + FM_RX_EV_MUTE_MODE_SET, + + FM_RX_EV_STEREO_MODE_SET, + + FM_RX_EV_RADIO_STATION_SET, + + FM_RX_EV_PWR_MODE_SET, + + FM_RX_EV_SET_SIGNAL_THRESHOLD, + + /* ----------------------------------------------- + 3 -> FM receiver status events + ----------------------------------------------- */ + + FM_RX_EV_RADIO_TUNE_STATUS, + + FM_RX_EV_STATION_PARAMETERS, + + FM_RX_EV_RDS_LOCK_STATUS, + + FM_RX_EV_STEREO_STATUS, + + FM_RX_EV_SERVICE_AVAILABLE, + + FM_RX_EV_GET_SIGNAL_THRESHOLD, + + /* ----------------------------------------------- + 4 -> FM search status events + ----------------------------------------------- */ + + FM_RX_EV_SEARCH_IN_PROGRESS, + + FM_RX_EV_SEARCH_RDS_IN_PROGRESS, + + FM_RX_EV_SEARCH_LIST_IN_PROGRESS, + + FM_RX_EV_SEARCH_COMPLETE, + + FM_RX_EV_SEARCH_RDS_COMPLETE, + + FM_RX_EV_SEARCH_LIST_COMPLETE, + + FM_RX_EV_SEARCH_CANCELLED, + + /* ----------------------------------------------- + 5 -> FM RDS status events + ----------------------------------------------- */ + + FM_RX_EV_RDS_GROUP_DATA, + + FM_RX_EV_RDS_PS_INFO, + + FM_RX_EV_RDS_RT_INFO, + + FM_RX_EV_RDS_AF_INFO, + + FM_RX_EV_RDS_PI_MATCH_AVAILABLE, + + /* ----------------------------------------------- + 6 -> FM RDS control events + ----------------------------------------------- */ + + FM_RX_EV_RDS_GROUP_OPTIONS_SET, + + FM_RX_EV_RDS_PROC_REG_DONE, + + FM_RX_EV_RDS_PI_MATCH_REG_DONE, + + FM_RX_EV_MAX_EVENT + +} FmRxEventType; + +typedef enum radio_band_type +{ + FM_US_EU = 0x0, + FM_JAPAN_STANDARD = 0x1, + FM_JAPAN_WIDE = 0x2, + FM_USER_DEFINED = 0x4 +}radio_band_type; + +typedef enum emphasis_type +{ + FM_RX_EMP75 = 0x0, + FM_RX_EMP50 = 0x1 +}emphasis_type; + +typedef enum channel_space_type +{ + FM_RX_SPACE_200KHZ = 0x0, + FM_RX_SPACE_100KHZ = 0x1, + FM_RX_SPACE_50KHZ = 0x2 +}channel_space_type; + +typedef enum rds_system_type +{ + FM_RX_RDBS_SYSTEM = 0x0, + FM_RX_RDS_SYSTEM = 0x1, + FM_RX_NO_RDS_SYSTEM = 0x2 +}rds_sytem_type; + +typedef struct band_limit_freq +{ + uint32 lower_limit; + uint32 upper_limit; +}band_limit_freq; + + +typedef enum rds_sync_type +{ + FM_RDS_NOT_SYNCED = 0x0, + FM_RDS_SYNCED = 0x1 +}rds_sync_type; + +typedef enum stereo_type +{ + FM_RX_MONO = 0x0, + FM_RX_STEREO = 0x1 +}stereo_type; + +typedef enum fm_service_available +{ + FM_SERVICE_NOT_AVAILABLE = 0x0, + FM_SERVICE_AVAILABLE = 0x1 +}fm_service_available; + +typedef enum mute_type +{ + FM_RX_NO_MUTE = 0x00, + FM_RX_MUTE_RIGHT = 0x01, + FM_RX_MUTE_LEFT = 0x02, + FM_RX_MUTE_BOTH = 0x03 +}mute_type; + +typedef enum antenna_type +{ + WIRED_HS, + PWB_ANT +}antenna_type; + +typedef enum audio_output +{ + HEADSET, + SPEAKER, +} audio_output; +/** +* RDS/RBDS Program Type type. +*/ +typedef uint8 fm_prgm_type; + +/** +* RDS/RBDS Program Identification type. +*/ +typedef uint16 fm_prgmid_type; +/** +* RDS/RBDS Program Services type. +*/ +typedef char fm_prm_services; +/** +* RDS/RBDS Radio Text type. +*/ +/* +* FM RX RIVA peek request +*/ +typedef struct fm_riva_peek_word +{ + uint8 subOpcode; + uint32 startaddress; + uint8 payload_length;/*In Bytes*/ + uint8 data[MAX_RIVA_DATA_LEN]; +}__attribute__((packed))fm_riva_peek_word; + +/* +* FM RX RIVA poke request +*/ +typedef struct fm_riva_poke_word +{ + uint8 subOpcode; + uint32 startaddress; + uint8 payload_length;/*In Bytes*/ + uint8 data[MAX_RIVA_DATA_LEN]; +}__attribute__((packed))fm_riva_poke_word ; + + +/* +* FM RX SSBI peek/poke request +*/ +typedef struct fm_ssbi_poke_reg +{ + uint16 startaddress; + uint8 data; +}__attribute__((packed))fm_ssbi_poke_reg; + +/* +* fm Set Get Reset AGC request +*/ +typedef struct fm_set_get_reset_agc_req +{ + uint8 ucCtrl; + uint8 ucGainState; +}__attribute__((packed))fm_set_get_reset_agc_req; + +typedef struct fm_set_get_reset_agc_params +{ + uint8 ucCurrentGainState; + uint8 ucGainStateChange1; + uint8 ucGainStateChange2; + uint8 ucGainStateChange3; +}__attribute__((packed))fm_set_get_reset_agc_params; + +typedef PACKED struct +{ + uint8 status ; + uint8 data_length ; + uint8 data[DEFAULT_DATA_SIZE]; +}__attribute__((packed)) readDefaults_data; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + uint8 status ; + uint8 data_length ; + uint8 data[DEFAULT_DATA_SIZE]; +}__attribute__((packed)) default_read_rsp; + +/*RDS Group counters*/ +typedef struct fm_rds_grp_cntrsparams +{ + uint32 totalRdsSBlockErrors; + uint32 totalRdsGroups; + uint32 totalRdsGroup0; + uint32 totalRdsGroup2; + uint32 totalRdsBlockB; + uint32 totalRdsProcessedGroup0; + uint32 totalRdsProcessedGroup2; + uint32 totalRdsGroupFiltered; + uint32 totalRdsChangeFiltered; +}__attribute__((packed)) fm_rds_grp_cntrsparams; + +/*RDS Group counters extended */ +typedef struct fm_rds_grpcntrs_extendedparams +{ + uint32 totalRdsSyncLoss; + uint32 totalRdsNotSync; + uint32 totalRdsSyncInt; +}__attribute__((packed)) fm_rds_grpcntrs_extendedparams; + +typedef char fm_radiotext_info; +/** +* FM Global Paramaters struct. +*/ +typedef struct +{ + uint32 current_station_freq;/*a frequency in kHz the band range*/ + uint8 service_available; + uint8 rssi; /* rssi range from 0-100*/ + uint8 stype; + uint8 rds_sync_status; + uint8 mute_status; + uint8 ssbi_peek_data; + fm_prgmid_type pgm_id; /* Program Id */ + fm_prgm_type pgm_type; /* Program type */ + fm_prm_services pgm_services[MAX_RDS_PS_LENGTH]; + fm_radiotext_info radio_text[MAX_RDS_RT_LENGTH];/* RT maximum is 64 bytes */ + fm_riva_poke_word riva_data_access_params; + fm_set_get_reset_agc_params set_get_reset_agc_params; + fm_rds_grp_cntrsparams rds_group_counters; + fm_rds_grpcntrs_extendedparams rds_group_counters_extended; + readDefaults_data default_read_data; + uint8 fm_ps_length; + uint8 fm_rt_length; + uint8 sinr_samples; + char sinr_threshold; + uint8 On_channel_threshold; + uint8 Off_channel_threshold; +}fm_station_params_available; +/** +* FM Config Request structure. +*/ +typedef struct fm_config_data +{ + uint8 band; + uint8 emphasis; + uint8 spacing; + uint8 rds_system; + band_limit_freq bandlimits; + uint8 is_fm_tx_on; +}fm_config_data; + +/* +* FM RDS Options Config Request +*/ +typedef struct fm_rds_options +{ + uint32 rds_group_mask; + uint32 rds_group_buffer_size; + uint8 rds_change_filter; +}fm_rds_options; +/* +* FM RX Search stations request +*/ +typedef struct fm_search_stations +{ + uint8 search_mode; + uint8 dwell_period; + uint8 search_dir; +}fm_search_stations; + +/* +* FM RX Search DDS stations request +*/ +typedef struct fm_search_rds_stations +{ + uint8 search_mode; + uint8 dwell_period; + uint8 search_dir; + uint8 program_type; + uint16 program_id; +}fm_search_rds_stations; + +/* +* FM RX Search station lists request +*/ +typedef struct fm_search_list_stations +{ + uint8 search_mode; + uint8 search_dir; + uint32 srch_list_max; + /**< Maximum number of stations that can be returned from a search. */ + uint8 program_type; +}fm_search_list_stations; + +/* +* FM RX I2C request +*/ +typedef struct fm_i2c_params +{ + uint8 slaveaddress; + uint8 offset; + uint8 payload_length; + uint8 data[64]; +}fm_i2c_params; + +/* Structure containing the RDS PS Info to be transmitted */ +typedef struct _tsFtmFmRdsTxPsType +{ + uint32 ulPSStrLen; + /**< The size of the cTxPSStrPtr buffer. + */ + + uint32 ucTxPSRptCnt; + /**< The number of times each 8 character string is repeated before the next + string is transmitted. + */ + + uint16 tusTxPi; + /**< RDS/RBDS Program Identification to use for Program Service transmissions. + */ + + uint8 tucTxPSPty; + /**< The RDS/RBDS Program Type to transmit. + */ + + const char cTxPSStrPtr[108]; + /**< A pointer to a buffer containing the Program Service string to transmit + (must be null terminated). + */ + +} tsFtmFmRdsTxPsType; + +typedef struct _tsFtmFmRdsTxRtType +{ + uint32 ulRTStrLen; + /**< The size of the cTxRTStrPtr buffer. + */ + + uint16 tusTxPi; + /**< RDS/RBDS Program Identification to use for RadioText transmissions. + */ + + uint8 tucTxRTPty; + /**< The RDS/RBDS Program Type to transmit. + */ + + const char cTxRTStrPtr[65]; + /**< A pointer to a buffer containing the RadioText string to transmit + (must be null terminated). + */ + +} tsFtmFmRdsTxRtType; + +typedef struct _ftm_def_data_rd_req +{ + uint8 mode; + uint8 length; + uint8 param_len; + uint8 param; +} __attribute__((packed))ftm_fm_def_data_rd_req; + +typedef struct _ftm_def_data_wr_req +{ + uint8 mode; + uint8 length; + uint8 data[DEFAULT_DATA_SIZE]; +} __attribute__((packed))ftm_fm_def_data_wr_req; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint8 length; /*RDS PS string length*/ + uint8 string[MAX_RDS_PS_LENGTH]; /* RDS string */ +}__attribute__((packed)) fmrdsps_response; + + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint8 length; /*RDS PS string length*/ + uint8 string[MAX_RDS_RT_LENGTH]; /* RDS string */ +}__attribute__((packed)) fmrdsrt_response; + + +/** +* FM All Request Union type. +*/ +typedef union fm_cfg_request +{ + fm_config_data cfg_param; + uint8 mute_param; + uint8 stereo_param; + uint32 freq; + fm_rds_options rds_options; + uint8 power_mode; + uint8 signal_threshold; + fm_search_stations search_stations_options; + fm_search_rds_stations search_rds_stations_options; + fm_search_list_stations search_list_stations_options; + fm_i2c_params i2c_params; + uint32 rds_group_options; + uint16 rx_af_threshold; + uint8 rx_rssi_checktimer; + uint rx_rds_pi_timer; + tsFtmFmRdsTxPsType tuFmPSParams; + tsFtmFmRdsTxRtType tuFmRTParams; + uint8 soft_mute_param; + uint8 antenna_type; + uint8 tx_tone_param; + uint8 rds_grp_counters; + uint8 rds_grp_counters_ext; + uint8 hlsi; + uint8 sinr_samples; + char sinr_threshold; + uint8 On_channel_threshold; + uint8 Off_channel_threshold; + uint8 notch; + fm_riva_peek_word riva_peek_params; + fm_riva_poke_word riva_data_access_params; + fm_ssbi_poke_reg ssbi_access_params; + fm_set_get_reset_agc_req set_get_agc_req_parameters; + ftm_fm_def_data_rd_req rd_default; + ftm_fm_def_data_wr_req wr_default; + uint8 tx_pwr_cfg; + uint8 audio_output; + uint8 audio_vlm; +}fm_cfg_request; + +/* FTM FM request type */ +typedef PACKED struct +{ + diagpkt_cmd_code_type cmd_code; + diagpkt_subsys_id_type subsys_id; + diagpkt_subsys_cmd_code_type subsys_cmd_code; + uint16 cmd_id; /* command id (required) */ + uint16 cmd_data_len; + uint16 cmd_rsp_pkt_size; + byte data[1]; +}__attribute__((packed))ftm_fm_pkt_type; + +/* Set MuteMode Response */ +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint8 mutemode; +}__attribute__((packed)) mutemode_response; + +/* Set StereoMode Response */ +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint8 stereomode; +}__attribute__((packed)) stereomode_response; + +/* I2C Response */ +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint32 length; /*length of data read */ + uint8 data[64]; /* I2C read dat buffer */ +}__attribute__((packed)) fmbusread_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint8 sub_opcode; + uint32 start_address; + uint8 length; /*length of data read */ + uint8 data[MAX_RIVA_DATA_LEN]; /* read dat buffer */ +}__attribute__((packed)) rivaData_response; + + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint8 data; +}__attribute__((packed)) ssbiPeek_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint8 uccurrentgainstate; + uint8 ucgainstatechange1; + uint8 ucgainstatechange2; + uint8 ucgainstatechange3; +}__attribute__((packed)) set_get_reset_agc_response; + +/*Read RDS Group counters responce*/ +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + fm_rds_grp_cntrsparams read_rds_cntrs; +}__attribute__((packed)) ReadRDSCntrs_responce; + +/*Read RDS Group counters response*/ +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + fm_rds_grpcntrs_extendedparams read_rds_cntrs_ext; +}__attribute__((packed)) ReadRDSCntrs_ext_response; + + +/* Generic Response */ +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ +}__attribute__((packed)) generic_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + uint16 afthreshold; +} fmrxsetafthreshold_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + uint8 sinr_sample; +} getsinrsamples_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + char sinr_threshold; +} getsinrthreshold_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + uint8 sinr_on_th; +} getonchannelthreshold_response; +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + uint8 sinr_off_th; +} getoffchannelthreshold_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + uint8 rssitimer; +} fmrxsetrssichecktimer_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + uint8 rdspitimer; +} fmrxsetrdspitimer_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + uint8 threshold; +} threshold_response; + +typedef PACKED struct +{ + diagpkt_subsys_header_type header ; + char result ; + uint32 rdserrcount; + uint32 numofblocks; +} rds_err_count_response; + +/* Custom response for Get station parameters request */ +struct fm_rx_get_station_parameters_response_t +{ + diagpkt_subsys_header_type header ; /*Diag header*/ + char result ;/* result */ + uint32 stationFreq; + /* The currently tuned frequency in kHz (Example: 96500 -> 96.5Mhz)*/ + uint8 servAvble; + /* The current service available indicator for the current station */ + uint8 rssi; + /* The current signal strength level (0-100 range). */ + uint8 stereoProgram; + /* The current mono/stereo indicator for this station */ + uint8 rdsSyncStatus; + /* The current RDS/RBDS synchronization status */ + uint8 muteMode; + /* The current FM mute mode */ +}__attribute__((packed)); + +/* FTM Log Packet - Used to send back the event of a HCI Command */ +typedef PACKED struct +{ + log_hdr_type hdr; + byte EvName; + /* Event ID indicates which event is being returned. */ + byte EvResult; + byte data[1]; /* Variable length payload, + look at FTM log id for contents */ +} ftm_fm_log_pkt_type; +#define FTM_FM_LOG_HEADER_SIZE (sizeof (ftm_fm_log_pkt_type) - 1) + +typedef struct fm_rx_get_station_parameters_response_t fm_rx_get_station_parameters_response; +/*=========================================================================== +FUNCTION ftm_fm_dispatch + +DESCRIPTION + Dispatch routine for the various FM Rx/Tx commands. Copies the data into + a global union data structure before calling the processing routine + +DEPENDENCIES + NIL + +RETURN VALUE + A Packed structre pointer including the response to the FTM FM packet + +SIDE EFFECTS + None + +===========================================================================*/ + +void * ftm_fm_dispatch(ftm_fm_pkt_type *ftm_fm_pkt, uint16 length ); + + +/*=========================================================================== + +FUNCTION ftm_fm_enable_audio + +DESCRIPTION + This function is used to take the audio output mode from QRCT. + +DEPENDENCIES + none + +===========================================================================*/ +PACKED void* ftm_fm_enable_audio( void ); +PACKED void* ftm_fm_disable_audio( void ); +PACKED void* ftm_fm_setting_volume(void); + +#endif /* CONFIG_FTM_FM */ diff --git a/feeds/wifi-ax/ftm/src/ftm_fm_pfal.h b/feeds/wifi-ax/ftm/src/ftm_fm_pfal.h new file mode 100755 index 000000000..cde8d18de --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_fm_pfal.h @@ -0,0 +1,1178 @@ +/*========================================================================== + + FTM FM PFAL Header File + +Description + Function declarations of the PFAL interfaces for FM. + +# Copyright (c) 2010-2012 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +08/03/2011 uppalas Adding support for new ftm commands +06/18/10 rakeshk Created a header file to hold the interface declarations + for ftm fm commands +07/06/10 rakeshk Added the support for new PFAL APIs for FM Rx +04/03/11 ananthk Added the support for FM Tx functionalities +===========================================================================*/ +#ifdef CONFIG_FTM_FM + +#include "event.h" +#include "diagpkt.h" +#include "ftm_fm_common.h" + +/*=========================================================================== +FUNCTION EnableFM + +DESCRIPTION + PFAL specific routine to enable FM with the Radio Configuration parameters + passed. + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type EnableFM +( + fm_config_data* radiocfgptr +); + +/*=========================================================================== +FUNCTION ConfigureFM + +DESCRIPTION + PFAL specific routine to configure FM with the Radio Configuration + parameters passed. + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type ConfigureFM +( + fm_config_data* radiocfgptr +); + +/*=========================================================================== +FUNCTION SetFrequencyTransmitter + +DESCRIPTION + PFAL specific routine to configure the FM transmitter's Frequency of reception + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetFrequencyTransmitter +( + uint32 ulfreq +); + +/*=========================================================================== +FUNCTION TransmitPS + +DESCRIPTION + PFAL specific routine to transmit RDS PS strings + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type TransmitPS +( + tsFtmFmRdsTxPsType* tuFmPSParams +); + +/*=========================================================================== +FUNCTION stopTransmitPS + +DESCRIPTION + PFAL specific routine to stop transmitting the PS string. + +PARAMS PASSED + NIL + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +============================================================================*/ +fm_cmd_status_type stopTransmitPS +( + void +); + +/*=========================================================================== +FUNCTION TransmitRT + +DESCRIPTION + PFAL specific routine to transmit the RT string which provides a brief info + of the audio content being transmitted. This includes artist name, movie name + few lines of the audio. Usually the metadata of the song is transmitted as RT + +PARAMS PASSED + 'tuFmRTParams' containing RDS PI, and RT information of the transmitting + station + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None +===========================================================================*/ +fm_cmd_status_type TransmitRT +( + tsFtmFmRdsTxRtType* tuFmRTParams +); +/*=========================================================================== +FUNCTION stopTransmitRT + +DESCRIPTION + PFAL specific routine to stop transmitting the RT string for the + transmitting station + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type stopTransmitRT +( + void +); + +/*=========================================================================== +FUNCTION getTxPSFeatures + +DESCRIPTION + PFAL specific routine to get the supported PS features for the + transmitting station + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type getTxPSFeatures +( + void +); + +/*=========================================================================== +FUNCTION SetTxPowerLevel + +DESCRIPTION + PFAL specific routine to configure the FM transmitter's power level + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetTxPowerLevel +( + uint32 ulfreq +); + +/*=========================================================================== +FUNCTION DisableFM + +DESCRIPTION + PFAL specific routine to disable FM and free all the FM resources + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type DisableFM +( + fm_config_data* radiocfgptr +); + +/*=========================================================================== +FUNCTION SetFrequencyReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's Frequency of reception + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetFrequencyReceiver +( + uint32 ulfreq +); + +/*=========================================================================== +FUNCTION SetMuteModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's mute status + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSoftMuteModeReceiver +( + mute_type mutemode +); + +/*=========================================================================== +FUNCTION SetMuteModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's mute status + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetMuteModeReceiver +( + mute_type mutemode +); + +/*=========================================================================== +FUNCTION SetAntenna + +DESCRIPTION + PFAL specific routine to configure the FM receiver's antenna type + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetAntenna +( + antenna_type antenna +); + + +/*=========================================================================== +FUNCTION SetStereoModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's Audio mode on the + frequency tuned + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetStereoModeReceiver +( + stereo_type stereomode +); + +/*=========================================================================== +FUNCTION GetStationParametersReceiver + +DESCRIPTION + PFAL specific routine to get the station parameters of the Frequency at + which the Radio receiver is tuned + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetStationParametersReceiver +( + fm_station_params_available* configparams +); +/*=========================================================================== +FUNCTION SetRdsOptionsReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's RDS options + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetRdsOptionsReceiver +( + fm_rds_options rdsoptions +); + +/*=========================================================================== +FUNCTION SetRdsGroupProcReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's RDS group proc options + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetRdsGroupProcReceiver +( + uint32 rdsgroupoptions +); + +/*=========================================================================== +FUNCTION SetPowerModeReceiver + +DESCRIPTION + PFAL specific routine to configure the power mode of FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetPowerModeReceiver +( + uint8 powermode +); + +/*=========================================================================== +FUNCTION SetSignalThresholdReceiver + +DESCRIPTION + PFAL specific routine to configure the signal threshold of FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSignalThresholdReceiver +( + uint8 signalthreshold +); + +/*=========================================================================== +FUNCTION GetSignalThresholdReceiver + +DESCRIPTION + PFAL specific routine to get the signal threshold of FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetSignalThresholdReceiver +( + uint8* signalthreshold +); + + +/*=========================================================================== +FUNCTION GetRSSILimits + +DESCRIPTION + PFAL specific routine to print the RSSI limits of FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetRSSILimits +( +); + + +/*=========================================================================== +FUNCTION GetPSInfoReceiver + +DESCRIPTION + PFAL specific routine to print the PS info of current frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetPSInfoReceiver +( +); + +/*=========================================================================== +FUNCTION GetRTInfoReceiver + +DESCRIPTION + PFAL specific routine to print the Radio text info of current frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetRTInfoReceiver +( +); + +/*=========================================================================== +FUNCTION GetAFInfoReceiver + +DESCRIPTION + PFAL specific routine to print the AF list for current frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetAFInfoReceiver +( +); + +/*=========================================================================== +FUNCTION SearchStationsReceiver + +DESCRIPTION + PFAL specific routine to search for stations from the current frequency of + FM receiver and print the information on diag + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchStationsReceiver +( +fm_search_stations searchstationsoptions +); + + +/*=========================================================================== +FUNCTION SearchRDSStationsReceiver + +DESCRIPTION + PFAL specific routine to search for stations from the current frequency of + FM receiver with a specific program type and print the information on diag + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchRdsStationsReceiver +( +fm_search_rds_stations searchrdsstationsoptions +); + + +/*=========================================================================== +FUNCTION SearchStationListReceiver + +DESCRIPTION + PFAL specific routine to search for stations with a specific mode of + informaation like WEAK,STRONG,STRONGEST etc + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchStationListReceiver +( +fm_search_list_stations searchliststationsoptions +); + + +/*=========================================================================== +FUNCTION CancelSearchReceiver + +DESCRIPTION + PFAL specific routine to cancel the ongoing search operation + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type CancelSearchReceiver +( +); + +/*=========================================================================== +FUNCTION FmBusWriteReceiver + +DESCRIPTION + PFAL specific routine to program the FM I2C bus + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmBusWriteReceiver +( +fm_i2c_params writeparams +); + +/*=========================================================================== +FUNCTION FmBusReadReceiver + +DESCRIPTION + PFAL specific routine to read the FM I2C bus + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmBusReadReceiver +( +fm_i2c_params *readparams +); + +/*=========================================================================== +FUNCTION FmRivaPeekData + +DESCRIPTION + PFAL specific routine to get the data from Riva Memory + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmRivaPeekData +( +fm_riva_peek_word peek_word +); + +/*=========================================================================== +FUNCTION FmRivaPokeData + +DESCRIPTION + PFAL specific routine to write the data into the Riva Memory + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmRivaPokeData +( +fm_riva_poke_word poke_word +); + +/*=========================================================================== +FUNCTION FmSSBIPeekData + +DESCRIPTION + PFAL specific routine to get the data from SSBI registers + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmSSBIPeekData( +fm_ssbi_poke_reg peek_reg +); + +/*=========================================================================== +FUNCTION FmSetGetResetAGC + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmSetGetResetAGC( +fm_set_get_reset_agc_req agc_params +); + +/*=========================================================================== +FUNCTION FmSSBIPokeData + +DESCRIPTION + PFAL specific routine to program the SSBI registers + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmSSBIPokeData( +fm_ssbi_poke_reg peek_reg +); + +/*=========================================================================== +FUNCTION FmTxToneGen + +DESCRIPTION + PFAL specific routine to configure the FM Tx internal tone Generation + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmTxToneGen +( +uint8 txTone +); + +/*=========================================================================== +FUNCTION FmRDSGrpcntrs + +DESCRIPTION + PFAL specific routine to read the FM RDS group counters + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmRDSGrpcntrs +( + uint8 rdsCounters +); + +/*=========================================================================== +FUNCTION FmRDSGrpcntrsExt + +DESCRIPTION + PFAL specific routine to read the FM RDS group counters extended + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmRDSGrpcntrsExt +( + uint8 rdsCounters +); + +/*=========================================================================== +FUNCTION FmSetHlSi + +DESCRIPTION + PFAL specific routine to configure the FM receiver's HlSi on the + frequency tuned + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmSetHlSi +( + uint8 hlsi +); + +/*=========================================================================== +FUNCTION GetSINRSamples + +DESCRIPTION + PFAL specific routine to get the FM receiver's SINR samples + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetSINRSamples +( + +); +/*=========================================================================== +FUNCTION SetSINRSamples + +DESCRIPTION + PFAL specific routine to set the FM receiver's SINR samples + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type SetSINRSamples +( + uint8 sinr_sample +); + +/*=========================================================================== +FUNCTION GetSINRThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's SINR threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetSINRThreshold +( + +); +/*=========================================================================== +FUNCTION SetSINRThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's SINR Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type SetSINRThreshold +( + char sinr_threshold +); + +/*=========================================================================== +FUNCTION GetOnChannelThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's on channel threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetOnChannelThreshold +( + +); + +/*=========================================================================== +FUNCTION SetOnChannelThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's on channel threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type SetOnChannelThreshold +( + uint8 on_channel_th +); + +/*=========================================================================== +FUNCTION GetOffChannelThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's off channel threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetOffChannelThreshold +( + +); + +/*=========================================================================== +FUNCTION SetOffChannelThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's off channel threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type SetOffChannelThreshold +( + uint8 off_channel_th +); +/*=========================================================================== +FUNCTION FmSetNotchFilter + +DESCRIPTION + PFAL specific routine to configure the FM receiver's notch filter + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmSetNotchFilter +( + uint8 notch +); + +/*=========================================================================== +FUNCTION FmDefaultRead + +DESCRIPTION + PFAL specific routine to get the FM Default Values + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmDefaultRead +( + ftm_fm_def_data_rd_req defaultRead +); + +/*=========================================================================== +FUNCTION FmDefaultWrite + +DESCRIPTION + PFAL specific routine to write the default values + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmDefaultWrite +( + ftm_fm_def_data_wr_req* + defaults +); + +/*=========================================================================== +FUNCTION FmTxPwrLvlCfg + +DESCRIPTION + PFAL specific routine to configure the FM Tx power level + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmTxPwrLvlCfg +( + uint8 pwrCfg +); + +/*=========================================================================== + +FUNCTION ftm_fm_run_mm + +DESCRIPTION + This function is used to run mm-audio-ftm. + +DEPENDENCIES + none + +===========================================================================*/ +void ftm_fm_run_mm +( + void +); + +/*=========================================================================== + +FUNCTION ftm_fm_audio + +DESCRIPTION + This function is used to load the target based config file and + set the audio output and volume. + +DEPENDENCIES + none + +===========================================================================*/ +fm_cmd_status_type ftm_fm_audio +( + uint8 source, + uint8 volume +); + +#endif /* CONFIG_FTM_FM */ +void ftm_fm_enable_slimbus(int val); diff --git a/feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux.c b/feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux.c new file mode 100755 index 000000000..206c33062 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux.c @@ -0,0 +1,3668 @@ +/*========================================================================== + +Description + Platform specific routines to program the V4L2 driver for FM + +# Copyright (c) 2010-2015 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +08/03/2011 uppalas Adding support for new ftm commands +04/05/11 ananthk Added support for FM Tx functionalities +03/15/11 naveenr Choosing I2C device path based on board type. Added + support for 7x30 +02/08/11 braghave Calling the fm_qsoc_patches with right parameter + for non-Android case. +06/30/10 rakeshk Created a source file to implement platform specific + routines for FM +07/06/10 rakeshk Added support for all the Rx commands and clean roomed + the header and data structures +01/07/11 rakeshk Added two support APIs to read/write the I2C bus with +==========================================================================*/ + +#include "ftm_fm_pfal.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef ANDROID +#include +#endif +#include +#include +#include +#include +#include +#include "ftm_common.h" +#include +#define BIT16 (1<<16) +#define FM_SLAVE_ADDR 0x2A +/* Multiplying factor to convert to Radio freqeuncy */ +#define TUNE_MULT 16000 +/* Constant to request for Radio Events */ +#define EVENT_LISTEN 1 +/* 1000 multiplier */ +#define MULTIPLE_1000 1000 +/* Tavaura I2C address */ +int SLAVE_ADDR = 0x2A; +/* Tavaura I2C statu register*/ +#define INTSTAT_0 0x0 +/* Debug Macro */ +#define FTM_DEBUG +#ifdef FTM_DEBUG +#define print(x) printf(x) +#define print2(x,y) printf(x,y) +#define print3(x,y,z) printf(x,y,z) +#else +#define print(x) +#define print2(x,y) +#define print3(x,y,z) +#endif + +#define UNUSED(x) (void)(x) + +enum tavarua_buf_t { + TAVARUA_BUF_SRCH_LIST, + TAVARUA_BUF_EVENTS, + TAVARUA_BUF_RT_RDS, + TAVARUA_BUF_PS_RDS, + TAVARUA_BUF_RAW_RDS, + TAVARUA_BUF_AF_LIST, + TAVARUA_BUF_MAX +}; + +enum tavarua_xfr_ctrl_t { + RDS_PS_0 = 0x01, + RDS_PS_1, + RDS_PS_2, + RDS_PS_3, + RDS_PS_4, + RDS_PS_5, + RDS_PS_6 +}; + +enum tavarua_evt_t { + TAVARUA_EVT_RADIO_READY, + TAVARUA_EVT_TUNE_SUCC, + TAVARUA_EVT_SEEK_COMPLETE, + TAVARUA_EVT_SCAN_NEXT, + TAVARUA_EVT_NEW_RAW_RDS, + TAVARUA_EVT_NEW_RT_RDS, + TAVARUA_EVT_NEW_PS_RDS, + TAVARUA_EVT_ERROR, + TAVARUA_EVT_BELOW_TH, + TAVARUA_EVT_ABOVE_TH, + TAVARUA_EVT_STEREO, + TAVARUA_EVT_MONO, + TAVARUA_EVT_RDS_AVAIL, + TAVARUA_EVT_RDS_NOT_AVAIL, + TAVARUA_EVT_NEW_SRCH_LIST, + TAVARUA_EVT_NEW_AF_LIST, + TAVARUA_EVT_TXRDSDAT, + TAVARUA_EVT_TXRDSDONE, + TAVARUA_EVT_RADIO_DISABLED +}; + +#define TAVARUA_BUF_PS_RDS 3 +#define V4L2_CID_PRIVATE_TAVARUA_REGION 0x08000007 +#define V4L2_CID_PRIVATE_TAVARUA_TX_SETPSREPEATCOUNT 0x08000015 +#define V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_PS_NAME 0x08000016 +#define V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_RT 0x08000017 +#define V4L2_CID_PRIVATE_TAVARUA_STATE 0x08000004 +#define V4L2_CID_PRIVATE_TAVARUA_SET_AUDIO_PATH 0x8000029 +#define V4L2_CID_PRIVATE_TAVARUA_RDSON 0x0800000F +#define V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC 0x08000010 +#define V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK 0x08000006 +#define V4L2_CID_PRIVATE_TAVARUA_RDSD_BUF 0x08000013 +#define V4L2_CID_PRIVATE_TAVARUA_ANTENNA 0x08000012 +#define V4L2_CID_PRIVATE_TAVARUA_RDSON 0x0800000F +#define V4L2_CID_PRIVATE_TAVARUA_EMPHASIS 0x0800000C +#define V4L2_CID_PRIVATE_TAVARUA_SPACING 0x0800000E +#define V4L2_CID_PRIVATE_TAVARUA_RDS_STD 0x0800000D +#define V4L2_CID_PRIVATE_TAVARUA_LP_MODE 0x08000011 +#define V4L2_CID_PRIVATE_TAVARUA_SRCHMODE 0x08000001 +#define V4L2_CID_PRIVATE_TAVARUA_SCANDWELL 0x08000002 +#define V4L2_CID_PRIVATE_TAVARUA_SRCH_PI 0x0800000A +#define V4L2_CID_PRIVATE_TAVARUA_SRCH_CNT 0x0800000B +#define V4L2_CID_PRIVATE_TAVARUA_SRCH_PTY 0x08000009 +#define V4L2_CID_PRIVATE_TAVARUA_SRCHON 0x08000003 +#define V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD 0x800002D +#define V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD 0x800002E +#define V4L2_CID_PRIVATE_SINR_THRESHOLD 0x800002F +#define V4L2_CID_PRIVATE_SINR_SAMPLES 0x8000030 +#define V4L2_CID_PRIVATE_TAVARUA_SIGNAL_TH 0x08000008 +#define SRCH_DIR_UP (0) +#define SRCH_DIR_DOWN (1) + +#define FM_TX_PWR_LVL_0 0 /* Lowest power lvl that can be set for Tx */ +#define FM_TX_PWR_LVL_MAX 7 /* Max power lvl for Tx */ +#define RDS_Tx 0x80 +const char* fm_i2c_path_8660 = "/dev/i2c-4"; +const char* fm_i2c_path_7x30 = "/dev/i2c-2"; +const char* fm_i2c_path_7627a = "/dev/i2c-1"; +/* To get the current status of PS/RT transmission */ +volatile unsigned char is_rt_transmitting = 0; +volatile unsigned char is_ps_transmitting = 0; +int ftm_audio_fd = -1; +const char *const audio_config = "-c /vendor/etc/ftm_test_config"; +const char *const ext_audio_config = "-c /system/etc/ftm_test_config_wcd9335"; +const unsigned int CMD_len = 16; +const int config_len = 31; +const int ext_config_len = 39; +const int sound_card_name_len = 16; +const char *const mm_audio_path = "/vendor/bin/mm-audio-ftm"; +/* enum to montior the Power On status */ +typedef enum +{ + INPROGRESS, + COMPLETE +}poweron_status; + +boolean cmd_queued = FALSE; +/* Resourcse Numbers for Rx/TX */ +int FM_RX = 1; +int FM_TX = 2; +/* Boolean to control the power down sequence */ +volatile boolean power_down = FALSE; +/* V4L2 radio handle */ +int fd_radio = -1; +/* FM asynchornous thread to perform the long running ON */ +pthread_t fm_interrupt_thread,fm_on_thread; +/* Prototype ofFM ON thread */ +void *(ftm_on_long_thread)(void *ptr); +/* Global state ofthe FM task */ +fm_station_params_available fm_global_params; + +volatile poweron_status poweron; + +int chipVersion = 0; +extern volatile fm_power_state fmPowerState; +static char transport[PROPERTY_VALUE_MAX]; + +/*=========================================================================== +FUNCTION WaitonInterrupt + +DESCRIPTION + Helper function to read the Interrupt register to check for a trasnfer + complete interrupt + +DEPENDENCIES + NIL + +RETURN VALUE + -1 in failure,positive or zero in success + +SIDE EFFECTS + None + +===========================================================================*/ + +int WaitonInterrupt(int fd,unsigned int intmask,unsigned int waittime) +{ + unsigned char buf[4]; + unsigned int maxtries=0; + unsigned int readdata=0; + int ret; + print("WaitonInterrupt >\n"); + while(((readdata & intmask) != intmask)&&(maxtries < 10)) + { + usleep(waittime*MULTIPLE_1000); + /* Read the 3 interrupt registers */ + ret = i2c_read(fd, INTSTAT_0, buf, 3,SLAVE_ADDR); + if (ret < 0) + { + return -1; + } + readdata |= buf[0]; + readdata |= buf[1] << 8; + readdata |= buf[2] << 16; + maxtries++; + } + if((readdata & intmask) != intmask) + { + return -1; + } + print("WaitonInterrupt <\n"); + return 0; +} + +/*=========================================================================== +FUNCTION set_v4l2_ctrl + +DESCRIPTION + Sets the V4L2 control sent as argument with the requested value and returns the status + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE in failure,TRUE in success + +SIDE EFFECTS + None + +===========================================================================*/ +boolean set_v4l2_ctrl(int fd,uint32 id,int32 value) +{ + struct v4l2_control control; + int err; + + control.value = value; + control.id = id; + switch(id) + { + case V4L2_CID_PRIVATE_TAVARUA_REGION : + if (value == FM_US_EU) + { + print("\n Region : US-EUROPE\n"); + control.value = FM_US_EU; + } + /* + Increment the 'control.value' to match the 'tavarua_region_t' enum + variable defined in the V4L2 driver. + + FTM: V4L2: + + US/EUROPE - '0' US - '0' + JAPAN STD - '1' EU - '1' + JAPAN WIDE - '2' JAPAN - '2' + USER-DEFINED - '3' JAPAN WIDE - '3' + REGION OTHER - '4' + */ + + else if(value == FM_JAPAN_STANDARD) + { + print("\n Region : JAPAN-STANARD\n"); + control.value = FM_JAPAN_STANDARD+1; + } + else if(value == FM_JAPAN_WIDE) + { + print("\n Region : JAPAN-WIDE\n"); + control.value = FM_JAPAN_WIDE+1; + } + else if(value == 3) + { + print("\n Region : USER-DEFINED\n"); + control.value = FM_USER_DEFINED; + } + break; + } + err = ioctl(fd,VIDIOC_S_CTRL,&control); + if(err < 0) + { + print3("set_v4l2_ctrl failed for control : %x with return value : %d\n",control.id,err); + return FALSE; + } + return TRUE; +} + +/*=========================================================================== +FUNCTION read_data_from_v4l2 + +DESCRIPTION + reads the fm_radio handle and updates the FM global configuration based on + the interrupt data received + +DEPENDENCIES + NIL + +RETURN VALUE + FALSE in failure,TRUE in success + +SIDE EFFECTS + None + +===========================================================================*/ +int read_data_from_v4l2(int fd,uint8* buf,int index) +{ + struct v4l2_requestbuffers reqbuf; + struct v4l2_buffer v4l2_buf; + int err; + memset(&reqbuf, 0x0, sizeof(reqbuf)); + enum v4l2_buf_type type = V4L2_BUF_TYPE_PRIVATE; + + reqbuf.type = V4L2_BUF_TYPE_PRIVATE; + reqbuf.memory = V4L2_MEMORY_USERPTR; + memset(&v4l2_buf, 0x0, sizeof(v4l2_buf)); + v4l2_buf.index = index; + v4l2_buf.type = type; + v4l2_buf.length = 128; + v4l2_buf.m.userptr = (unsigned long)buf; + err = ioctl(fd,VIDIOC_DQBUF,&v4l2_buf) ; + if(err < 0) + { + print2("ioctl failed with error = %d\n",err); + return -1; + } + return v4l2_buf.bytesused; +} + +/*=========================================================================== +FUNCTION extract_program_service + +DESCRIPTION + Helper routine to read the Program Services data from the V4L2 buffer + following a PS event + +DEPENDENCIES + PS event + +RETURN VALUE + TRUE if success,else FALSE + +SIDE EFFECTS + Updates the Global data strutures PS info entry + +===========================================================================*/ +boolean extract_program_service() +{ + uint8 buf[64]; + int ret; + print("extract_program_service\n"); + ret = read_data_from_v4l2(fd_radio,buf,TAVARUA_BUF_PS_RDS); + print2("read_data_from_v4l2 ret = %d\n",ret); + int num_of_ps = (int)(buf[0] & 0x0F); + int ps_services_len = ((int )((num_of_ps*8) + 5)) - 5; + fm_global_params.fm_ps_length = ps_services_len; + fm_global_params.pgm_id = (((buf[2] & 0xFF) << 8) | (buf[3] & 0xFF)); + fm_global_params.pgm_type = (int)( buf[1] & 0x1F); + memset(fm_global_params.pgm_services,0x0,MAX_RDS_PS_LENGTH); + memcpy(fm_global_params.pgm_services,&buf[5],ps_services_len); + fm_global_params.pgm_services[ps_services_len] = '\0'; + print2("Pid = %d\n",fm_global_params.pgm_id); + print2("Ptype = %d\n",fm_global_params.pgm_type); + print2("PS name %s\n",fm_global_params.pgm_services); + return TRUE; +} +/*=========================================================================== +FUNCTION extract_radio_text + +DESCRIPTION + Helper routine to read the Radio text data from the V4L2 buffer + following a RT event + +DEPENDENCIES + RT event + +RETURN VALUE + TRUE if success,else FALSE + +SIDE EFFECTS + Updates the Global data strutures RT info entry + +===========================================================================*/ + +boolean extract_radio_text() +{ + uint8 buf[120]; + + int bytesread = read_data_from_v4l2(fd_radio,buf,TAVARUA_BUF_RT_RDS); + int radiotext_size = (int)(buf[0] & 0x0F); + fm_global_params.fm_rt_length = radiotext_size; + fm_global_params.pgm_id = (((buf[2] & 0xFF) << 8) | (buf[3] & 0xFF)); + fm_global_params.pgm_type = (int)( buf[1] & 0x1F); + memset(fm_global_params.radio_text,0x0,MAX_RDS_RT_LENGTH); + memcpy(fm_global_params.radio_text,&buf[5],radiotext_size); + printf("RT is %s\n", fm_global_params.radio_text); + return TRUE; +} + + +/*=========================================================================== +FUNCTION extract_peek_data + +DESCRIPTION + Helper routine to read the data from the V4L2 buffer + following a riva peek data command complete + +DEPENDENCIES + NIL + +RETURN VALUE + void + +SIDE EFFECTS + Updates the Global data strutures member riva_data_access_params + +===========================================================================*/ + +void extract_peek_data() +{ + uint8 buf[MAX_RIVA_PEEK_RSP_SIZE]; + int bytesread = read_data_from_v4l2(fd_radio,buf,IRIS_BUF_PEEK); + struct fm_riva_poke_word *responce = (struct fm_riva_poke_word *)buf; + memcpy((void*)&fm_global_params.riva_data_access_params, + (void*)responce,sizeof(buf)); +} +/*=========================================================================== +FUNCTION extract_ssbi_peek_data + +DESCRIPTION + Helper routine to read the data from the V4L2 buffer + following a ssbi peek data command complete + +DEPENDENCIES + NIL + +RETURN VALUE + void + +SIDE EFFECTS + Updates the Global data strutures member ssbi_peek_data + +===========================================================================*/ + + +void extract_ssbi_peek_data() +{ + uint8 buf[SSBI_PEEK_DATA_SIZE]; + int bytesread = read_data_from_v4l2(fd_radio,buf,IRIS_BUF_SSBI_PEEK); + fm_global_params.ssbi_peek_data = buf[0]; +} + +/*=========================================================================== +FUNCTION extract_rds_grp_cntr_data + +DESCRIPTION + Helper routine to read the data from the V4L2 buffer + following a Read Rds Group counters command complete + +DEPENDENCIES + NIL + +RETURN VALUE + void + +SIDE EFFECTS + Updates the Global data strutures member rds_group_counters + +===========================================================================*/ + +void extract_rds_grp_cntr_data() +{ + uint8 buf[RDS_GRP_CNTRS_SIZE]; + int bytesread = read_data_from_v4l2(fd_radio,buf,IRIS_BUF_RDS_CNTRS); + struct RDSCntrsParams *responce = (struct RDSCntrsParams *)buf; + memcpy((void*)&fm_global_params.rds_group_counters,(void*)responce,sizeof(buf)); +} +/*=========================================================================== +FUNCTION extract_default_read_data + +DESCRIPTION + Helper routine to read the data from the V4L2 buffer + following a defaultRead command complete + +DEPENDENCIES + NIL + +RETURN VALUE + void + +SIDE EFFECTS + Updates the Global data struture member rd_default + +===========================================================================*/ + +void extract_default_read_data() +{ + uint8 buf[DEFAULT_DATA_SIZE+2]; //2-bytes for status and data length + int bytesread = read_data_from_v4l2(fd_radio,buf,IRIS_BUF_RD_DEFAULT); + readDefaults_data *response = (readDefaults_data *)buf; + memcpy((void*)&fm_global_params.default_read_data,(void*)response,bytesread); +} +/*=========================================================================== +FUNCTION reset_rds + +DESCRIPTION + Reset the existing RDS data. + +DEPENDENCIES + Radio event + +RETURN VALUE + void + +IDE EFFECTS + Reset the Global RDS data info like RT, PS etc. +===========================================================================*/ + +void reset_rds() +{ + memset(fm_global_params.pgm_services,0x0,MAX_RDS_PS_LENGTH); + memset(fm_global_params.radio_text,0x0,MAX_RDS_RT_LENGTH); + fm_global_params.pgm_id = 0; + fm_global_params.pgm_type = 0; +} +/*=========================================================================== +FUNCTION process_radio_event + +DESCRIPTION + Helper routine to process the radio event read from the V4L2 and performs + the corresponding action. + +DEPENDENCIES + Radio event + +RETURN VALUE + TRUE if success,else FALSE + +SIDE EFFECTS + Updates the Global data strutures info entry like frequency, station + available, RDS sync status etc. + +===========================================================================*/ + +boolean process_radio_event(uint8 event_buf) +{ + print2("Process event %d\n",event_buf); + struct v4l2_frequency freq; + boolean ret= TRUE; + switch(event_buf) + { + case TAVARUA_EVT_RADIO_READY: + print("Radio ON complete\n"); + break; + case TAVARUA_EVT_TUNE_SUCC: + print("Tune successful\n"); + reset_rds(); + freq.type = V4L2_TUNER_RADIO; + if(ioctl(fd_radio, VIDIOC_G_FREQUENCY, &freq)< 0) + { + return FALSE; + } + fm_global_params.current_station_freq =((freq.frequency*MULTIPLE_1000)/TUNE_MULT); + break; + case TAVARUA_EVT_SEEK_COMPLETE: + print("Seek Complete\n"); + freq.type = V4L2_TUNER_RADIO; + if(ioctl(fd_radio, VIDIOC_G_FREQUENCY, &freq)< 0) + { + return FALSE; + } + fm_global_params.current_station_freq =((freq.frequency*MULTIPLE_1000)/TUNE_MULT); + break; + case TAVARUA_EVT_SCAN_NEXT: + print("Event Scan next\n"); + break; + case TAVARUA_EVT_NEW_RAW_RDS: + print("Received Raw RDS info\n"); + break; + case TAVARUA_EVT_NEW_RT_RDS: + print("Received RT \n"); + ret = extract_radio_text(); + break; + case TAVARUA_EVT_NEW_PS_RDS: + print("Received PS\n"); + ret = extract_program_service(); + break; + case TAVARUA_EVT_ERROR: + print("Received Error\n"); + break; + case TAVARUA_EVT_BELOW_TH: + print("Received Below TH\n"); + fm_global_params.service_available = FM_SERVICE_NOT_AVAILABLE; + break; + case TAVARUA_EVT_ABOVE_TH: + print("Received above TH\n"); + fm_global_params.service_available = FM_SERVICE_AVAILABLE; + break; + case TAVARUA_EVT_STEREO: + print("Received Stereo Mode\n"); + fm_global_params.stype = FM_RX_STEREO; + break; + case TAVARUA_EVT_MONO: + print("Received Mono Mode\n"); + fm_global_params.stype = FM_RX_MONO; + break; + case TAVARUA_EVT_RDS_AVAIL: + print("Received RDS Available\n"); + fm_global_params.rds_sync_status = FM_RDS_SYNCED; + break; + case TAVARUA_EVT_RDS_NOT_AVAIL: + print("Received RDS Not Available\n"); + fm_global_params.rds_sync_status = FM_RDS_NOT_SYNCED; + break; + case TAVARUA_EVT_NEW_SRCH_LIST: + print("Received new search list\n"); + break; + case TAVARUA_EVT_NEW_AF_LIST: + print("Received new AF List\n"); + break; + case (RDS_Tx | RDS_PS_0): + print("\nSuccessfully transmitted PS Header\n"); + break; + case (RDS_Tx | RDS_PS_1): + case (RDS_Tx | RDS_PS_2): + case (RDS_Tx | RDS_PS_3): + case (RDS_Tx | RDS_PS_4): + case (RDS_Tx | RDS_PS_5): + case (RDS_Tx | RDS_PS_6): + print("\n Successfully transmitted PS Contents \n"); + break; + + } + /* + * This logic is applied to ensure the exit ofthe Event read thread + * before the FM Radio control is turned off. This is a temporary fix + */ + if(power_down == TRUE) + return FALSE; + return ret; +} + +/*=========================================================================== +FUNCTION ftm_fm_interrupt_thread + +DESCRIPTION + Thread to perform a continous read on the radio handle for events + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ + +void * ftm_fm_interrupt_thread(void *ptr) +{ + print("Starting FM event listener\n"); + uint8 buf[128]; + boolean status = TRUE; + int i =0; + int bytesread = 0; + + UNUSED(ptr); + + while(1) + { + bytesread = read_data_from_v4l2(fd_radio,buf,EVENT_LISTEN); + if(bytesread == -1) + break; + for(i =0;iis_fm_tx_on) + print("\nEnable Transmitter entry\n"); + else + print("\nEnable Receiver entry\n"); +#endif + /*Opening the handle to the V4L2 device */ + fd_radio = open("/dev/radio0",O_RDONLY, O_NONBLOCK); + if(fd_radio < 0) + { + if(radiocfgptr->is_fm_tx_on) + { + print2("EnableTransmitter Failed to open = %d\n",fd_radio); + return FM_CMD_FAILURE; + } + else + { + print2("EnableReceiver Failed to open = %d\n",fd_radio); + return FM_CMD_FAILURE; + } + } + + if(radiocfgptr->is_fm_tx_on) + print("\nOpened Transmitter\n"); + else + print("\nOpened Receiver\n"); + +/* + Starting 'ftm_on_long_thread' where we do all the FM configurations + and intializations. + +*/ + fmPowerState = FM_POWER_TRANSITION; + pthread_create( &fm_on_thread, NULL, ftm_on_long_thread, radiocfgptr); + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION TransmitPS + +DESCRIPTION + PFAL specific routine to transmit RDS PS strings + +PARAMS PASSED + 'tuFmPSParams' containing RDS PI, PTY, max. no. of PS repeat count and + PS name of the transmitting station + +PLATFORM SPECIFIC DESCRIPTION + This routine is used to transmit the PS string describing the transmitter's + information and genre of the audio content being transmitted + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type TransmitPS +( + tsFtmFmRdsTxPsType* tuFmPSParams +) +{ + int ret = 0; + + struct v4l2_control control; + struct v4l2_ext_controls v4l2_ctls; + struct v4l2_ext_control ext_ctl; + + print("\n Entering Transmit PS \n"); + + /* Set Program Type (PTY) */ + control.id = V4L2_CID_RDS_TX_PTY; + control.value = 0; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set PTY failed \n"); + return FM_CMD_FAILURE; + } + + /* Set Program Identifier (PI) */ + control.id = V4L2_CID_RDS_TX_PI; + control.value = tuFmPSParams->tusTxPi; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set PI failed \n"); + return FM_CMD_FAILURE; + } + + /*Set PS max. repeat count */ + control.id = V4L2_CID_PRIVATE_TAVARUA_TX_SETPSREPEATCOUNT; + control.value = tuFmPSParams->ucTxPSRptCnt; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set MAX_REPEAT_CNT failed \n"); + return FM_CMD_FAILURE; + } + + /*Set Program Service name (PS) */ + ext_ctl.id = V4L2_CID_RDS_TX_PS_NAME; + ext_ctl.string = (char *)tuFmPSParams->cTxPSStrPtr; + ext_ctl.size = tuFmPSParams->ulPSStrLen; + v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + v4l2_ctls.count = 0; + v4l2_ctls.controls = &ext_ctl; + + ret = ioctl(fd_radio, VIDIOC_S_EXT_CTRLS, &v4l2_ctls ); + if(ret < 0 ) + { + print("\n VIDIOC_S_EXT_CTRLS ioctl: Set PS failed \n"); + return FM_CMD_FAILURE; + } + is_ps_transmitting = 1; + print("\n Exiting Transmit PS \n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION stopTransmitPS + +DESCRIPTION + PFAL specific routine to stop transmitting the PS string. + +PARAMS PASSED + NIL + +PLATFORM SPECIFIC DESCRIPTION + This routine is used to stop transmitting the PS string + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +============================================================================*/ +fm_cmd_status_type stopTransmitPS +( + void +) +{ + int ret = 0; + struct v4l2_control control; + + print("\n Entering stopTransmitPS \n"); + + control.id = V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_PS_NAME; + ret = ioctl(fd_radio, VIDIOC_S_CTRL , &control); + if(ret < 0){ + print("Failed to stop Transmit PS"); + return FM_CMD_FAILURE; + } + else { + print("\nStopped transmitting PS\n"); + is_ps_transmitting = 0; + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION TransmitRT + +DESCRIPTION + PFAL specific routine to transmit the RT string. + +PARAMS PASSED + 'tuFmRTParams' containing RDS PI, and RT information of the transmitting + station + +PLATFORM SPECIFIC DESCRIPTION + This routine is used to transmit the RT string which provides a brief info + of the audio content being transmitted. This includes artist name, movie name + few lines of the audio. Usually the metadata of the song is transmitted as RT + + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None +===========================================================================*/ +fm_cmd_status_type TransmitRT +( + tsFtmFmRdsTxRtType* tuFmRTParams +) +{ + int ret = 0; + + struct v4l2_control control; + struct v4l2_ext_controls v4l2_ctls; + struct v4l2_ext_control ext_ctl; + + v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + v4l2_ctls.count = 1; + v4l2_ctls.controls = &ext_ctl; + + print("\n Entering Transmit RT \n"); + + if(tuFmRTParams == NULL) + { + print("\n 'tuFmRTParams ' is not NULL \n "); + return FM_CMD_FAILURE; + } + else + { + ext_ctl.id = V4L2_CID_RDS_TX_RADIO_TEXT; + ext_ctl.string = (char *)tuFmRTParams->cTxRTStrPtr; + ext_ctl.size = tuFmRTParams->ulRTStrLen; + } + /* Set Program Type (PTY) */ + control.id = V4L2_CID_RDS_TX_PTY; + control.value = 0; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set PTY failed \n"); + return FM_CMD_FAILURE; + } + + /* Set Program Identifier (PI) */ + control.id = V4L2_CID_RDS_TX_PI; + control.value = tuFmRTParams->tusTxPi; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set PI failed \n"); + return FM_CMD_FAILURE; + } + + /* Set the Radio Text (RT) to be transmitted */ + ret = ioctl(fd_radio, VIDIOC_S_EXT_CTRLS, &v4l2_ctls ); + if(ret < 0 ) + { + print("\n VIDIOC_S_EXT_CTRLS ioctl: Set RT failed \n"); + return FM_CMD_FAILURE; + } + + is_rt_transmitting = 1; + return FM_CMD_SUCCESS; + +} + +/*=========================================================================== +FUNCTION stopTransmitRT + +DESCRIPTION + PFAL specific routine to stop transmitting the RT string. + +PLATFORM SPECIFIC DESCRIPTION + This routine is called to stop transmitting the RT string for the + transmitting station + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type stopTransmitRT +( + void +) +{ + int ret = 0; + + print("\n Entering stopTransmitRT \n"); + + struct v4l2_control control; + control.id = V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_RT; + ret = ioctl(fd_radio, VIDIOC_S_CTRL , &control); + if(ret < 0){ + print("Failed to stop Transmit RT"); + return FM_CMD_FAILURE; + } + else { + print("\nStopped transmitting RT\n"); + is_rt_transmitting = 0; + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION getTxPSFeatures + +DESCRIPTION + PFAL specific routine to get all the supported Tx PS features + +PLATFORM SPECIFIC DESCRIPTION + This routine is called to get the supported PS features for the + transmitting station + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type getTxPSFeatures +( + void +) +{ + print("\n Entering getTxPSFeatures() \n"); + printf("\n Supported Tx PS Features:\n"); + printf("\n Max PS Count : %d\n",MAX_TX_PS_LEN); + printf("\n Max PS Repeat Count : %d\n",MAX_TX_PS_RPT_CNT); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION ftm_on_long_thread + +DESCRIPTION + Helper routine to perform the rest ofthe FM calibration and SoC Patch + download and configuration settings following the opening ofradio handle + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ +void *(ftm_on_long_thread)(void *ptr) +{ + int ret = 0; + struct v4l2_control control; + struct v4l2_tuner tuner; + int i,init_success = 0; + char value[PROPERTY_VALUE_MAX]; + struct v4l2_capability cap; + char versionStr[40]; + char cmdBuffer[40]; + char product_board_platform_type[PROPERTY_VALUE_MAX]; + fm_cmd_status_type status; + + fm_config_data* radiocfgptr = (fm_config_data *)ptr; + + /* Query the V4L2 device for capabilities */ + ret = ioctl(fd_radio, VIDIOC_QUERYCAP, &cap); + + if(ret < 0 ) + { + print("Failed to retrieve the Fm SOC version\n"); + return NULL; + } + else + { + print3("VIDIOC_QUERYCAP returns :%d: version: %d \n", ret , cap.version ); + chipVersion = cap.version; + } + + property_get("qcom.bluetooth.soc", value, NULL); + print2("BT soc is %s\n", value); + if (strcmp(value, "rome") != 0) + { + print("Initiating Soc patch download\n"); + +#ifndef ANDROID + snprintf(cmdBuffer, sizeof(cmdBuffer)-1, "fm_qsoc_patches %d %d", cap.version, 0); + ret = system(cmdBuffer); + if(ret != 0) + { + print2("Failed to download patches = %d\n",ret); + return NULL; + } +#else + if( ret >= 0 ) + { + print2("Driver Version(Same as ChipId): %x \n", cap.version ); + /*Convert the integer to string */ + snprintf(versionStr, sizeof(versionStr)-1, "%d", cap.version ); + property_set("hw.fm.version", versionStr); + } + else + { + return NULL; + } + /*Set the mode for soc downloader*/ + property_set("hw.fm.mode", "normal"); + property_set("ctl.start", "fm_dl"); + sleep(1); + for(i=0;i<9;i++) + { + property_get("hw.fm.init", value, NULL); + if(strcmp(value, "1") == 0) + { + init_success = 1; + break; + } + else + { + sleep(1); + } + } + print3("init_success:%d after %d seconds \n", init_success, i); + if(!init_success) + { + property_set("ctl.stop", "fm_dl"); + // close the fd(power down) + close(fd_radio); + return NULL; + } + + property_get("ro.qualcomm.bt.hci_transport", transport, NULL); + print2("ro.qualcomm.bt.hci_transport = %s\n", transport); + if ((3 == strlen(transport)) && (!strncmp("smd", transport, 3))) { + print("Not a WCN2243 target.\n"); + } else { + /* + * For WCN2243 based targets check what is the target type. + * DAC configuration is applicable only msm7627a target. + */ + property_get("ro.board.platform", product_board_platform_type, NULL); + if (!strncmp("msm7627a", product_board_platform_type, + strlen(product_board_platform_type))) { + property_set("hw.fm.mode", "config_dac"); + property_set("hw.fm.init", "0"); + property_set("hw.fm.isAnalog", "true"); + property_set("ctl.start", "fm_dl"); + for (i = 0; i < 3; i++) { + property_get("hw.fm.init", value, NULL); + if (strcmp(value, "1") == 0) { + init_success = 1; + break; + } else { + sleep(1); + } + } + print3("init_success:%d after %d seconds \n", init_success, i); + if (!init_success) { + property_set("ctl.stop", "fm_dl"); + close(fd_radio); + return NULL; + } + } else { + print("Analog audio path not supported\n"); + } + } + +#endif + } + /** + * V4L2_CID_PRIVATE_TAVARUA_STATE + * V4L2_CID_PRIVATE_TAVARUA_EMPHASIS + * V4L2_CID_PRIVATE_TAVARUA_SPACING + * V4L2_CID_PRIVATE_TAVARUA_RDS_STD + * V4L2_CID_PRIVATE_TAVARUA_REGION + */ + + /* Switching on FM */ + if (radiocfgptr->is_fm_tx_on) + { + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_STATE,FM_TX); + if(ret == FALSE) + { + print("Failed to turn on FM Trnasmitter\n"); + return NULL; + } + else + print("\nEnabled FM Transmitter successfully\n"); + } + else + { + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_STATE,FM_RX); + if(ret == FALSE) + { + print("Failed to turn on FM Receiver\n"); + return NULL; + } + else + print("\nEnabled FM Receiver successfully\n"); + } + + /*Enable Analog audio path*/ + ret = set_v4l2_ctrl(fd_radio, V4L2_CID_PRIVATE_TAVARUA_SET_AUDIO_PATH, 1); + if(ret == FALSE) + { + print("Failed to set Audio path \n"); + } + + status = ConfigureFM(radiocfgptr); + if(status != FM_CMD_SUCCESS) + { + print("Failed to configure fm\n"); + return NULL; + } + + /* Setting RDS On */ + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDSON,1); + if(ret == FALSE) + { + print("Failed to set RDS on \n"); + return NULL; + } + + /* Set the RDS Group Processing : Only in case of FM Receiver */ + if (!radiocfgptr->is_fm_tx_on) + { + control.id = V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC; + ret = ioctl(fd_radio,VIDIOC_G_CTRL,&control); + if(ret < 0) + { + print2("Failed to set RDS group!!!Return value : %d\n",ret); + return NULL; + } + + int rdsMask = FM_RX_RDS_GRP_RT_EBL | FM_RX_RDS_GRP_PS_EBL | + FM_RX_RDS_GRP_AF_EBL | FM_RX_RDS_GRP_PS_SIMPLE_EBL ; + + byte rds_group_mask = (byte)control.value; + byte rdsFilt = 0; + int psAllVal=rdsMask & (1 << 4); + print2("rdsOptions: rdsMask: %x\n",rdsMask); + rds_group_mask &= 0xC7; + + rds_group_mask |= ((rdsMask & 0x07) << 3); + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC, + rds_group_mask); + + if(ret == FALSE) + { + print("Failed to set RDS GROUP PROCESSING!!!\n"); + return NULL; + } + + if (strcmp(value, "rome") == 0) + { + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK, 1); + if (ret == FALSE) + { + print("Failed to set RDS GRP MASK!!!\n"); + return NULL; + } + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDSD_BUF, 1); + if (ret == FALSE) + { + print("Failed to set RDS BUF!!!\n"); + return NULL; + } + } + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_ANTENNA,0); + if(ret == FALSE) + { + print("Failed to set ANTENNA!!!\n"); + return NULL; + } + ret = set_v4l2_ctrl(fd_radio, V4L2_CID_PRIVATE_IRIS_SOFT_MUTE, 0); + if(ret == FALSE) + { + print("Failed to Disable Soft Mute!!!\n"); + return NULL; + } + + } + + /* + + Start the 'ftm_fm_interrupt_thread' thread which listens for and processes + radio events received from the SoC + + */ + pthread_create( &fm_interrupt_thread, NULL, ftm_fm_interrupt_thread, NULL); + power_down = FALSE; + + + + if(radiocfgptr->is_fm_tx_on) { +#ifdef FTM_DEBUG + print("\nEnable Transmitter exit\n"); +#endif + fmPowerState = FM_TX_ON; + } + else { +#ifdef FTM_DEBUG + print("\nEnable Receiver exit\n"); +#endif + fmPowerState = FM_RX_ON; + } + poweron = COMPLETE; + return NULL; +} + +/*=========================================================================== +FUNCTION DisableFM + +DESCRIPTION + PFAL specific routine to disable FM and free the FM resources + +PLATFORM SPECIFIC DESCRIPTION + Closes the handle to /dev/radio0 V4L2 device + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None +===========================================================================*/ +fm_cmd_status_type DisableFM +( + fm_config_data* radiocfgptr +) +{ + struct v4l2_control control; + uint8 buf[128]; + double tune; + char value[PROPERTY_VALUE_MAX]; + struct v4l2_frequency freq_struct; + int ret; + + /* Wait till the previous ON sequence has completed */ + while(poweron != COMPLETE); + +#ifdef FTM_DEBUG + print("DisableFM start\n"); +#endif + + power_down = TRUE; + + /* Set RDS Off */ + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDSON,0); + if(ret == FALSE) + { + print("DisableFM failed to set RDS off \n"); + return FM_CMD_FAILURE; + } + + /* Turn off FM */ + /* As part of Turning off FM we will get 'READY' event */ + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_STATE,0); + if(ret == FALSE) + { + if(radiocfgptr->is_fm_tx_on) + { + print("\nFailed to Turn Off FM Transmitter\n"); + return FM_CMD_FAILURE; + } + else + { + print("\nFailed to Turn Off FM Receiver\n"); + return FM_CMD_FAILURE; + } + } + + /* Wait for 'fm_interrupt_thread' thread to complete its execution */ + pthread_join(fm_interrupt_thread,NULL); + +#ifdef FTM_DEBUG + + print("Stopping the FM control\n"); + +#endif + +#ifdef ANDROID + + property_get("qcom.bluetooth.soc", value, NULL); + print2("BT soc is %s\n", value); + if (strcmp(value, "rome") != 0) + { + property_set("ctl.stop", "fm_dl"); + } + +#endif/*ANDROID*/ + + print2("Stopping the FM control = %d\n",close(fd_radio)); + fd_radio = -1; + cmd_queued = TRUE; + +#ifdef FTM_DEBUG + + if(radiocfgptr->is_fm_tx_on) + print("Disabled FM Transmitter\n"); + else + print("Disabled FM Receiver\n"); + +#endif + fmPowerState = FM_POWER_OFF; + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION ConfigureFM + +DESCRIPTION + PFAL specific routine to configure FM with the Radio Configuration + parameters passed. + +PLATFORM SPECIFIC DESCRIPTION + Configures the Init parameters like emphasis, channel spacing, Band Limit, + RDS type, Frequency Band, and Radio State. + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type ConfigureFM +( + fm_config_data* radiocfgptr +) +{ + int ret = 0; + struct v4l2_control control; + struct v4l2_tuner tuner; + +#ifdef FTM_DEBUG + + if(radiocfgptr->is_fm_tx_on) + print("\nConfigure FM Transmitter entry\n"); + else + print("\nConfigure FM Receiver entry\n"); +#endif + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + /* Set Emphasis, Channel spacing and RDS Standard : + Emphasis : + '0' - 75 - US/EU + '1' - 50 - JAPAN/JAPAN-WIDE/ASIA + Channel Spacing : + '0' - 200kHz - US/EU + '1' - 100kHz - JAPAN + '2' - 50kHz - JAPAN-WIDE + RDS/RDBS Standard : + '0' - RDBS - US/EU + '1' - RDS - All regions + */ + switch(radiocfgptr->band) + { + case FM_US_EU: + radiocfgptr->emphasis = 0; + radiocfgptr->spacing = 0; + radiocfgptr->rds_system = 0; + break; + case FM_JAPAN_STANDARD: + radiocfgptr->emphasis = 1; + radiocfgptr->spacing = 1; + radiocfgptr->rds_system = 1; + case FM_JAPAN_WIDE: + radiocfgptr->emphasis = 1; + radiocfgptr->spacing = 2; + radiocfgptr->rds_system = 1; + break; + } + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_EMPHASIS, + radiocfgptr->emphasis); + if(ret == FALSE) + { + print("ConfigureFM : Failed to set Emphasis \n"); + return FM_CMD_FAILURE; + } + + /* Set channel spacing */ + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_SPACING, + radiocfgptr->spacing); + if(ret == FALSE) + { + print("ConfigureFM : Failed to set channel spacing \n"); + return FM_CMD_FAILURE; + } + + /* Set RDS/RDBS Standard */ + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDS_STD, + radiocfgptr->rds_system); + if(ret == FALSE) + { + print("ConfigureFM : Failed to set RDS std \n"); + return FM_CMD_FAILURE; + } + + /* Set band limit and audio mode to Mono/Stereo */ + tuner.index = 0; + tuner.signal = 0; + + switch(radiocfgptr->band) + { + case FM_US_EU: + tuner.rangelow = REGION_US_EU_BAND_LOW * (TUNE_MULT/1000); + tuner.rangehigh = REGION_US_EU_BAND_HIGH * (TUNE_MULT/1000); + break; + case FM_JAPAN_STANDARD: + tuner.rangelow = REGION_JAPAN_STANDARD_BAND_LOW * (TUNE_MULT/1000); + tuner.rangehigh = REGION_JAPAN_STANDARD_BAND_HIGH * (TUNE_MULT/1000); + break; + case FM_JAPAN_WIDE: + tuner.rangelow = REGION_JAPAN_WIDE_BAND_LOW * (TUNE_MULT/1000); + tuner.rangehigh = REGION_JAPAN_WIDE_BAND_HIGH * (TUNE_MULT/1000); + break; + default: + tuner.rangelow = radiocfgptr->bandlimits.lower_limit * (TUNE_MULT/1000); + tuner.rangehigh = radiocfgptr->bandlimits.upper_limit * (TUNE_MULT/1000); + break; + } + + ret = ioctl(fd_radio,VIDIOC_S_TUNER,&tuner); + if(ret < 0) + { + print("ConfigureFM : Failed to set band limits and audio mode \n"); + return FM_CMD_FAILURE; + } + + /* Set Region */ + radiocfgptr->band = FM_USER_DEFINED; + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_REGION,radiocfgptr->band); + if(ret == FALSE) + { + print("ConfigureFM : Failed to set band\n"); + return FM_CMD_FAILURE; + } + +out : +#ifdef FTM_DEBUG + + if(radiocfgptr->is_fm_tx_on) + print("\nConfigure FM Transmitter exit\n"); + else + print("\nConfigure FM Receiver exit\n"); +#endif + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetFrequencyReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's Frequency ofreception + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetFrequencyReceiver +( + uint32 ulfreq +) +{ + int err; + double tune; + struct v4l2_frequency freq_struct; + struct v4l2_tuner tuner; +#ifdef FTM_DEBUG + print2("\nSetFrequency Receiver entry freq = %d\n",(int)ulfreq); +#endif + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + tuner.index = 0; + + err = ioctl(fd_radio,VIDIOC_G_TUNER,&tuner); + if(err < 0) + { + print("SetFrequencyReceiver : Failed to get band limits and audio mode \n"); + return FM_CMD_FAILURE; + } + freq_struct.type = V4L2_TUNER_RADIO; + freq_struct.frequency = (ulfreq) * (TUNE_MULT/1000); + if (freq_struct.frequency >= tuner.rangelow && freq_struct.frequency <= tuner.rangehigh) + { + err = ioctl(fd_radio, VIDIOC_S_FREQUENCY, &freq_struct); + if(err < 0) + { + return FM_CMD_FAILURE; + } + } + else + { + print("SetFrequencyReceiver : frequency out of band limits \n"); + return FM_CMD_DISALLOWED; + } +#ifdef FTM_DEBUG + print("\nSetFrequency Receiver exit\n"); +#endif + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetFrequencyTransmitter + +DESCRIPTION + PFAL specific routine to configure the FM Transmitter's frequency + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetFrequencyTransmitter +( + uint32 ulfreq +) +{ + int err; + double tune; + struct v4l2_frequency freq_struct; + struct v4l2_control control; + struct v4l2_tuner tuner; +#ifdef FTM_DEBUG + print2("\n SetFrequencyTransmitter() entry : Freq = %d \n",(int)ulfreq); +#endif + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + /* Stop transmitting PS/RT frequency of currently tuned station */ + print2("\n Currently tuned station is : %u \n",fm_global_params.current_station_freq); + if(is_ps_transmitting) + stopTransmitPS(); + if(is_rt_transmitting) + stopTransmitRT(); + + tuner.index = 0; + + err = ioctl(fd_radio,VIDIOC_G_TUNER,&tuner); + if(err < 0) + { + print("SetFrequencyTransmitter : Failed to get band limits and audio mode \n"); + return FM_CMD_FAILURE; + } + + /* Fill up the 'v4l2_frequency' structure */ + freq_struct.type = V4L2_TUNER_RADIO; + freq_struct.frequency = (ulfreq) * (TUNE_MULT/1000); + if (freq_struct.frequency >= tuner.rangelow && freq_struct.frequency <= tuner.rangehigh) + { + err = ioctl(fd_radio, VIDIOC_S_FREQUENCY, &freq_struct); + if(err < 0) + return FM_CMD_FAILURE; + else + print2("\n Frequency : %u \n",ulfreq); + } + else + { + print("SetFrequencyTransmitter : Frequency out of bandlimits\n"); + return FM_CMD_DISALLOWED; + } + +#ifdef FTM_DEBUG + print("\n SetFrequencyTransmitter() exit \n"); +#endif + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetTxPowerLevel + +DESCRIPTION + PFAL specific routine to configure the FM transmitter's power level + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetTxPowerLevel +( + uint32 ulfreq +) +{ + int err; + struct v4l2_control control; + + /* Set the power level as requested */ + control.id = V4L2_CID_TUNE_POWER_LEVEL; + control.value = FM_TX_PWR_LVL_MAX; + err = ioctl(fd_radio, VIDIOC_S_CTRL, &control); + if(err < 0) + { + if( err == -ETIME) + print("\nTimeout to read PHY_TX gain Register\n"); + else + { + print2("\nFailed to set the Power Level for %u\n",ulfreq); + return FM_CMD_FAILURE; + } + } + else + print2("\nSuccessfully set the Power Level for %u\n",ulfreq); + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetMuteModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's mute status + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetMuteModeReceiver +( + mute_type mutemode +) +{ + int err,i; + struct v4l2_control control; + print2("SetMuteModeReceiver mode = %d\n",mutemode); + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = mutemode; + control.id = V4L2_CID_AUDIO_MUTE; + + for(i=0;i<3;i++) + { + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetMuteMode Success\n"); + return FM_CMD_SUCCESS; + } + } + print2("Set mute mode ret = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== + +FUNCTION SetSoftMuteModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's soft mute status + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSoftMuteModeReceiver +( + mute_type mutemode +) +{ + int err; + struct v4l2_control control; + print2("SetMuteModeReceiver mode = %d\n",mutemode); + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = mutemode; + control.id = V4L2_CID_PRIVATE_IRIS_SOFT_MUTE; + + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetMuteMode Success\n"); + return FM_CMD_SUCCESS; + } + print2("Set mute mode ret = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION SetAntenna + +DESCRIPTION + PFAL specific routine to configure the FM receiver's antenna type + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type SetAntenna +( + antenna_type antenna +) +{ + int err; + struct v4l2_control control; + control.value = antenna; + control.id = V4L2_CID_PRIVATE_TAVARUA_ANTENNA; + + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetAntenna Success\n"); + return FM_CMD_SUCCESS; + } + + print2("Set antenna ret = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION FmRivaPeekData + +DESCRIPTION + PFAL specific routine to get the data from Riva Memory +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmRivaPeekData +( + fm_riva_peek_word peek_word +) +{ + int err; + struct v4l2_control control; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = peek_word.startaddress; + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR; + + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetRiva Address Success\n"); + } + control.value = peek_word.payload_length; + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN; + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetDataLen Success\n"); + } + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_PEEK; + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + extract_peek_data(); + print("RivaPeek Success\n"); + return FM_CMD_SUCCESS; + } + + print2("RivaPeekData ret = %d\n",err); + return FM_CMD_FAILURE; +} + + +/*=========================================================================== +FUNCTION FmRivaPokeData + +DESCRIPTION + PFAL specific routine to write the data into the Riva Memory +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmRivaPokeData +( + fm_riva_poke_word poke_word +) +{ + int err; + struct v4l2_control control; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = poke_word.startaddress; + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR; + + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetRiva Address Success\n"); + } + control.value = poke_word.payload_length; + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN; + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetDataLen Success\n"); + } + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_POKE; + control.value = (uint32)(uintptr_t)(&poke_word.data); + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("RivaPoke Success\n"); + return FM_CMD_SUCCESS; + } + + print2("RivaPokeData ret = %d\n",err); + return FM_CMD_FAILURE; +} + + +/*=========================================================================== +FUNCTION FmSSBIPeekData + +DESCRIPTION + PFAL specific routine to get the data from SSBI registers +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmSSBIPeekData +( + fm_ssbi_poke_reg peek_reg +) +{ + int err; + struct v4l2_control control; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.id = V4L2_CID_PRIVATE_IRIS_SSBI_PEEK; + control.value = peek_reg.startaddress; + if( control.value == 0x00) + return FM_CMD_FAILURE; + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + extract_ssbi_peek_data(); + print2("SSBIPeek Success\n %d",peek_reg.data); + return FM_CMD_SUCCESS; + } + + print2("SSBIPeekData ret = %d\n",err); + return FM_CMD_FAILURE; +} + + +/*=========================================================================== +FUNCTION FmSSBIPokeData + +DESCRIPTION + PFAL specific routine to program the SSBI registers +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmSSBIPokeData +( + fm_ssbi_poke_reg poke_reg +) +{ + int err; + struct v4l2_control control; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = poke_reg.startaddress; + control.id = V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR; + + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetRiva Address Success\n"); + } + control.id = V4L2_CID_PRIVATE_IRIS_SSBI_POKE; + control.value = poke_reg.data; + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print2("SSBIPoke Success\n value =%d",poke_reg.data); + return FM_CMD_SUCCESS; + } + + print2("SSBIPokeData ret = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmTxPwrLvlCfg + +DESCRIPTION + PFAL specific routine to configure the FM Tx power level + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmTxPwrLvlCfg +( + uint8 pwrlvl +) +{ + int err; + struct v4l2_control control; + control.value = pwrlvl; + control.id = V4L2_CID_TUNE_POWER_LEVEL; + err = ioctl(fd_radio, VIDIOC_S_CTRL, &control); + if (err >= 0) { + print2("Tx power level set to %d\n", pwrlvl); + return FM_CMD_SUCCESS; + } + print2("Set Tx power level failed = %d\n", err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmTxToneGen + +DESCRIPTION + PFAL specific routine to configure the FM Tx internal tone Generation + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmTxToneGen +( + uint8 txTone +) +{ + int err; + struct v4l2_control control; + control.value = txTone; + control.id = V4L2_CID_PRIVATE_IRIS_TX_TONE; + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("Set Tx internal tone Success\n"); + return FM_CMD_SUCCESS; + } + print2("Set Tx internal tone = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmRDSGrpcntrs + +DESCRIPTION + PFAL specific routine to get the FM RDS group conuters + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmRDSGrpcntrs +( + uint8 rdsCounters +) +{ + int err; + struct v4l2_control control; + control.value = rdsCounters; + control.id = V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS; + + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + extract_rds_grp_cntr_data(); + print("Read RDS GROUP counters success\n"); + return FM_CMD_SUCCESS; + } + print2("Read RDS GROUP counters = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmDefaultRead + +DESCRIPTION + PFAL specific routine to get the FM Default Values + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmDefaultRead +( + ftm_fm_def_data_rd_req defaultRead +) +{ + int err; + struct v4l2_control control; + struct v4l2_ext_controls v4l2_ctls; + struct v4l2_ext_control ext_ctl; + + ext_ctl.id = V4L2_CID_PRIVATE_IRIS_READ_DEFAULT; + ext_ctl.size = sizeof(ftm_fm_def_data_rd_req); + memcpy(ext_ctl.string,(char *)&defaultRead,ext_ctl.size); + + v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_USER; + v4l2_ctls.count = 1; + v4l2_ctls.controls = &ext_ctl; + + err = ioctl(fd_radio,VIDIOC_G_EXT_CTRLS,&v4l2_ctls); + if(err >= 0) + { + extract_default_read_data(); + print("Read Defaults success\n"); + return FM_CMD_SUCCESS; + } + print2("Read Defaults =%d \n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmDefaultWrite + +DESCRIPTION + PFAL specific routine to write the default values + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmDefaultWrite +( + ftm_fm_def_data_wr_req* writedefaults +) +{ + int ret = 0; + + struct v4l2_control control; + struct v4l2_ext_controls v4l2_ctls; + struct v4l2_ext_control ext_ctl; + + if(writedefaults == NULL) + { + print("\n 'writedefaults' is NULL \n "); + return FM_CMD_FAILURE; + } + ext_ctl.id = V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT; + ext_ctl.size = (writedefaults->length + 2); + ext_ctl.string = (char *)&writedefaults->mode; + + v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_USER; + v4l2_ctls.count = 1; + v4l2_ctls.controls = &ext_ctl; + + print("\n Entering Write defaults \n"); + + ret = ioctl(fd_radio, VIDIOC_S_EXT_CTRLS, &v4l2_ctls ); + if(ret < 0 ) + { + print("\n VIDIOC_S_EXT_CTRLS ioctl: Set Default failed \n"); + return FM_CMD_FAILURE; + } + + return FM_CMD_SUCCESS; + +} + +/*=========================================================================== +FUNCTION FmSetHlSi + +DESCRIPTION + PFAL specific routine to configure the FM receiver's HlSi + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmSetHlSi +( + uint8 hlsi +) +{ + int err; + struct v4l2_control control; + control.value = hlsi; + control.id = V4L2_CID_PRIVATE_IRIS_HLSI; + print2("Setting HLSI to = %d",hlsi); + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("Set HlSi success"); + return FM_CMD_SUCCESS; + } + print2("Set HlSi status = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmSetNotchFilter + +DESCRIPTION + PFAL specific routine to configure the FM receiver's notch filter + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmSetNotchFilter +( + uint8 notch +) +{ + int err; + struct v4l2_control control; + control.value = notch; + control.id = V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER; + print2("Setting Notch filter to = %d",notch); + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("Set Notch filter success"); + return FM_CMD_SUCCESS; + } + print2("Set Notch filter status = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION SetStereoModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's Audio mode on the + frequency tuned + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetStereoModeReceiver +( + stereo_type stereomode +) +{ + struct v4l2_tuner tuner; + int err; + print2("SetStereoModeReceiver stereomode = %d \n",stereomode); + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + tuner.index = 0; + err = ioctl(fd_radio, VIDIOC_G_TUNER, &tuner); + print3("Get stereo mode ret = %d tuner.audmode = %d\n",err,tuner.audmode); + if(err < 0) + return FM_CMD_FAILURE; + +/*There is a discrepancy between V4L2 macros and FTM/HCI +Interface documentation. The stereo/mono settings are swapped +In FTM/HCI documentation. So we are providing a work around by +Swapping the mono/stereo settings here*/ + + tuner.audmode = (!stereomode); + err = ioctl(fd_radio, VIDIOC_S_TUNER, &tuner); + print2("Set stereo mode ret = %d\n",err); + if(err < 0) + return FM_CMD_FAILURE; + print("SetStereoMode Success\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION GetStationParametersReceiver + +DESCRIPTION + PFAL specific routine to get the station parameters ofthe Frequency at + which the Radio receiver is tuned + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetStationParametersReceiver +( + fm_station_params_available* configparams +) +{ + int i; + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + configparams->current_station_freq = fm_global_params.current_station_freq; + configparams->service_available = fm_global_params.service_available; + + struct v4l2_tuner tuner; + tuner.index = 0; + tuner.signal = 0; + if(ioctl(fd_radio, VIDIOC_G_TUNER, &tuner) < 0) + return FM_CMD_FAILURE; + + configparams->rssi = tuner.signal; + configparams->stype = fm_global_params.stype; + configparams->rds_sync_status = fm_global_params.rds_sync_status; + + struct v4l2_control control; + control.id = V4L2_CID_AUDIO_MUTE; + + for(i=0;i<3;i++) + { + int err = ioctl(fd_radio,VIDIOC_G_CTRL,&control); + if(err >= 0) + { + configparams->mute_status = control.value; + return FM_CMD_SUCCESS; + } + } + + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION SetRdsOptionsReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's RDS options + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetRdsOptionsReceiver +( + fm_rds_options rdsoptions +) +{ + int ret; + print("SetRdsOptionsReceiver\n"); + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK, + rdsoptions.rds_group_mask); + if(ret == FALSE) + { + print2("SetRdsOptionsReceiver Failed to set RDS group options = %d\n",ret); + return FM_CMD_FAILURE; + } + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDSD_BUF, + rdsoptions.rds_group_buffer_size); + if(ret == FALSE) + { + print2("SetRdsOptionsReceiver Failed to set RDS group options = %d\n",ret); + return FM_CMD_FAILURE; + } + + /*Chnage Filter not supported */ + print("SetRdsOptionsReceiver<\n"); + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetRdsGroupProcReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's RDS group proc options + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetRdsGroupProcReceiver +( + uint32 rdsgroupoptions +) +{ + int ret; + print("SetRdsGroupProcReceiver\n"); + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC, + rdsgroupoptions); + if(ret == FALSE) + { + print2("SetRdsGroupProcReceiver Failed to set RDS proc = %d\n",ret); + return FM_CMD_FAILURE; + } + + print("SetRdsGroupProcReceiver<\n"); + return FM_CMD_SUCCESS; +} + + +/*=========================================================================== +FUNCTION SetPowerModeReceiver + +DESCRIPTION + PFAL specific routine to configure the power mode of FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetPowerModeReceiver +( + uint8 powermode +) +{ + struct v4l2_control control; + int i,err; + print2("SetPowerModeReceiver mode = %d\n",powermode); + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = powermode; + control.id = V4L2_CID_PRIVATE_TAVARUA_LP_MODE; + + for(i=0;i<3;i++) + { + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetPowerMode Success\n"); + return FM_CMD_SUCCESS; + } + } + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION SetSignalThresholdReceiver + +DESCRIPTION + PFAL specific routine to configure the signal threshold ofFM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSignalThresholdReceiver +( + uint8 signalthreshold +) +{ + struct v4l2_control control; + int i,err; + print2("SetSignalThresholdReceiver threshold = %d\n",signalthreshold); + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = signalthreshold; + control.id = V4L2_CID_PRIVATE_TAVARUA_SIGNAL_TH; + + for(i=0;i<3;i++) + { + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("SetSignalThresholdReceiver Success\n"); + return FM_CMD_SUCCESS; + } + } + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION GetSignalThresholdReceiver + +DESCRIPTION + PFAL specific routine to get the signal threshold of FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetSignalThresholdReceiver +( + uint8* signalthreshold +) +{ + struct v4l2_control control; + int i,err; + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.id = V4L2_CID_PRIVATE_TAVARUA_SIGNAL_TH; + + for(i=0;i<3;i++) + { + err = ioctl(fd_radio,VIDIOC_G_CTRL,&control); + if(err >= 0) + { + print2("GetSignalThresholdReceiver Success = %d\n",control.value); + *signalthreshold = control.value; + return FM_CMD_SUCCESS; + } + } + + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION GetRSSILimits + +DESCRIPTION + PFAL specific routine to print the RSSI limts ofFM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetRSSILimits +( +) +{ + int limits[] ={0,100}; + + return FM_CMD_SUCCESS; +} + + +/*=========================================================================== +FUNCTION GetPSInfoReceiver + +DESCRIPTION + PFAL specific routine to print the PS info ofcurrent frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetPSInfoReceiver +( +) +{ + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION GetRTInfoReceiver + +DESCRIPTION + PFAL specific routine to print the Radio text info ofcurrent frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetRTInfoReceiver +( +) +{ + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION GetAFInfoReceiver + +DESCRIPTION + PFAL specific routine to print the AF list for current frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetAFInfoReceiver +( +) +{ + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SearchStationsReceiver + +DESCRIPTION + PFAL specific routine to search for stations from the current frequency of + FM receiver and print the information on diag + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchStationsReceiver +( +fm_search_stations searchstationsoptions +) +{ + int err,i; + struct v4l2_control control; + struct v4l2_hw_freq_seek hwseek; + boolean ret; + print("SearchStationsReceiver\n"); + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_SRCHMODE, + searchstationsoptions.search_mode); + if(ret == FALSE) + { + print("SearchStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_SCANDWELL, + searchstationsoptions.dwell_period); + if(ret == FALSE) + { + print("SearchStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + if (searchstationsoptions.search_dir) + searchstationsoptions.search_dir = SRCH_DIR_UP; + else + searchstationsoptions.search_dir = SRCH_DIR_DOWN; + + hwseek.seek_upward = searchstationsoptions.search_dir; + hwseek.type = V4L2_TUNER_RADIO; + err = ioctl(fd_radio,VIDIOC_S_HW_FREQ_SEEK,&hwseek); + + if(err < 0) + { + print("SearchStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + print("SearchRdsStationsReceiver<\n"); + return FM_CMD_SUCCESS; +} + + +/*=========================================================================== +FUNCTION SearchRDSStationsReceiver + +DESCRIPTION + PFAL specific routine to search for stations from the current frequency of + FM receiver with a specific program type and print the information on diag + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchRdsStationsReceiver +( +fm_search_rds_stations searchrdsstationsoptions +) +{ + int i,err; + boolean ret; + struct v4l2_control control; + struct v4l2_hw_freq_seek hwseek; + + print("SearchRdsStationsReceiver>\n"); + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_SRCHMODE, + searchrdsstationsoptions.search_mode); + if(ret == FALSE) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_SCANDWELL, + searchrdsstationsoptions.dwell_period); + if(ret == FALSE) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_SRCH_PTY, + searchrdsstationsoptions.program_type); + if(ret == FALSE) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = set_v4l2_ctrl(fd_radio,V4L2_CID_PRIVATE_TAVARUA_SRCH_PI, + searchrdsstationsoptions.program_id); + if(ret == FALSE) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + hwseek.seek_upward = searchrdsstationsoptions.search_dir; + hwseek.type = V4L2_TUNER_RADIO; + err = ioctl( fd_radio, VIDIOC_S_HW_FREQ_SEEK,&hwseek); + + if(err < 0) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + print("SearchRdsStationsReceiver<\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SearchStationListReceiver + +DESCRIPTION + PFAL specific routine to search for stations with a specific mode of + informaation like WEAK,STRONG,STRONGEST etc + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchStationListReceiver +( +fm_search_list_stations searchliststationsoptions +) +{ + int i,err; + boolean ret; + struct v4l2_control control; + struct v4l2_hw_freq_seek hwseek; + + print("SearchStationListReceiver>\n"); + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + ret = set_v4l2_ctrl( fd_radio, V4L2_CID_PRIVATE_TAVARUA_SRCHMODE, + searchliststationsoptions.search_mode); + if(ret == FALSE) + { + print("SearchStationListReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = set_v4l2_ctrl( fd_radio, V4L2_CID_PRIVATE_TAVARUA_SRCH_CNT, + searchliststationsoptions.srch_list_max); + if(ret == FALSE) + { + print("SearchStationListReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = set_v4l2_ctrl( fd_radio, V4L2_CID_PRIVATE_TAVARUA_SRCH_PTY, + searchliststationsoptions.program_type); + if(ret == FALSE) + { + print("SearchStationListReceiver failed \n"); + return FM_CMD_FAILURE; + } + + hwseek.seek_upward = searchliststationsoptions.search_dir; + hwseek.type = V4L2_TUNER_RADIO; + err = ioctl( fd_radio, VIDIOC_S_HW_FREQ_SEEK,&hwseek); + + if(err < 0) + { + print("SearchStationListReceiver failed \n"); + return FM_CMD_FAILURE; + } + print("SearchStationListReceiver<\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION + +DESCRIPTION + PFAL specific routine to cancel the ongoing search operation + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type CancelSearchReceiver +( +) +{ + struct v4l2_control control; + boolean ret; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + ret = set_v4l2_ctrl( fd_radio, V4L2_CID_PRIVATE_TAVARUA_SRCHON,0); + if(ret == FALSE) + { + return FM_CMD_FAILURE; + } + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION GetSINRSamples + +DESCRIPTION + PFAL specific routine to get the FM receiver's SINR sample + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetSINRSamples +( + +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_SINR_SAMPLES; + err = ioctl(fd_radio, VIDIOC_G_CTRL, &control); + if( err < 0 ) + { + print("Failed to get the SINR samples"); + return FM_CMD_FAILURE; + } + else + { + fm_global_params.sinr_samples = control.value; + print2("Successfully get the SINR samples %d\n", control.value); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION SetSINRSamples + +DESCRIPTION + PFAL specific routine to set the FM receiver's SINR sample + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSINRSamples +( + uint8 sinr_sample +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_SINR_SAMPLES; + control.value = sinr_sample; + err = ioctl(fd_radio, VIDIOC_S_CTRL, &control); + if( err < 0 ) + { + print("Failed to set the SINR samples\n"); + return FM_CMD_FAILURE; + } + else + { + print2("Successfully set the SINR samples %d\n", sinr_sample); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION GetSINRThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's SINR Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetSINRThreshold +( + +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_SINR_THRESHOLD; + err = ioctl(fd_radio, VIDIOC_G_CTRL, &control); + if( err < 0 ) + { + print("Failed to get the SINR threshold\n"); + return FM_CMD_FAILURE; + } + else + { + fm_global_params.sinr_threshold = control.value; + print2("Successfully get the SINR threshold %d\n", control.value); + return FM_CMD_SUCCESS; + } +} + + +/*=========================================================================== +FUNCTION SetSINRThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's SINR Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSINRThreshold +( + char sinr_th +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_SINR_THRESHOLD; + control.value = sinr_th; + err = ioctl(fd_radio, VIDIOC_S_CTRL, &control); + if( err < 0 ) + { + print("Failed to set the SINR threshold\n"); + return FM_CMD_FAILURE; + } + else + { + print2("Successfully set the SINR threshold %d\n", sinr_th); + return FM_CMD_SUCCESS; + } +} + + +/*=========================================================================== +FUNCTION GetOnChannelThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's On channel Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetOnChannelThreshold +( + +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD; + err = ioctl(fd_radio, VIDIOC_G_CTRL, &control); + if( err < 0 ) + { + print("Failed to get the On channel threshold \n"); + return FM_CMD_FAILURE; + } + else + { + fm_global_params.On_channel_threshold = control.value; + print2("Successfully get the On channel threshold %d\n", control.value); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION SetOnChannelThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's On channel Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type SetOnChannelThreshold +( + uint8 on_channel_th +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD; + control.value = on_channel_th; + err = ioctl(fd_radio, VIDIOC_S_CTRL, &control); + if( err < 0 ) + { + print("Failed to set the On channel threshold\n"); + return FM_CMD_FAILURE; + } + else + { + print2("Successfully set the On channel threshold %d\n", on_channel_th); + return FM_CMD_SUCCESS; + } +} +/*=========================================================================== +FUNCTION GetOffChannelThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's Off channel Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetOffChannelThreshold +( + +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD; + err = ioctl(fd_radio, VIDIOC_G_CTRL, &control); + if( err < 0 ) + { + print("Failed to get the Off channel threshold \n"); + return FM_CMD_FAILURE; + } + else + { + fm_global_params.Off_channel_threshold = control.value; + print2("Successfully get the Off channel threshold %d\n", control.value); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION SetOffChannelThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's Off channel Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type SetOffChannelThreshold +( + uint8 off_channel_th +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD; + control.value = off_channel_th; + err = ioctl(fd_radio, VIDIOC_S_CTRL, &control); + if( err < 0 ) + { + print("Failed to set the Off channel threshold\n"); + return FM_CMD_FAILURE; + } + else + { + print2("Successfully set the Off channel threshold %d\n", off_channel_th); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION get_fm_i2c_path + +DESCRIPTION + Helper function to get the path of i2c based on the board + +DEPENDENCIES + NIL + +RETURN VALUE + Path to the i2c device. NULL in case of failure. + +SIDE EFFECTS + None + +===========================================================================*/ + +static char* get_fm_i2c_path( void ) +{ + char *fm_i2c_path = NULL; + char board_platform_type[92]; // max possible length for 'value' from property_get() + property_get("ro.board.platform", board_platform_type, "default"); + print2("ro.board.platform %s \n", board_platform_type); + if(strcasestr(board_platform_type, "default")) + { + print("unable to determine the board platform type \n"); + return NULL; + } + if(strcasestr(board_platform_type, "msm8660")) + { + fm_i2c_path = (char *)fm_i2c_path_8660; + } + else if(strcasestr(board_platform_type, "msm7630_surf")) + { + fm_i2c_path = (char *)fm_i2c_path_7x30; + } + else if(strcasestr(board_platform_type, "msm7627a")) + { + fm_i2c_path = (char *)fm_i2c_path_7627a; + } + if(fm_i2c_path != NULL) + print2("I2c device path is %s \n", fm_i2c_path); + + return fm_i2c_path; +} + + +/*=========================================================================== +FUNCTION FmBusWriteReceiver + +DESCRIPTION + PFAL specific routine to program the FM I2C bus + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmBusWriteReceiver +( +fm_i2c_params writeparams +) +{ + int fd_i2c; + int ret; + char *i2cdevice = get_fm_i2c_path(); + if (i2cdevice == NULL) + { + print("== I2C device path not available \n"); + return FM_CMD_FAILURE; + } + fd_i2c = open(i2cdevice, O_RDWR); + print("FmBusWriteReceiver >\n"); + if(fd_i2c < 0) + return FM_CMD_FAILURE; + ret = i2c_write( fd_i2c, writeparams.offset, writeparams.data, + writeparams.payload_length, writeparams.slaveaddress); + if (ret < 0) + { + print(" i2c_write failed to Write the data \n"); + close(fd_i2c); + return FM_CMD_FAILURE; + } + print2("== I2C Write SLAVE_ADDR = 0x%x\n",writeparams.slaveaddress); + print2("== I2C reg = 0x%x ===\n",writeparams.offset); + print2("== I2C data = 0x%x \n",writeparams.data[0]); + + close(fd_i2c); + print("FmBusWriteReceiver <\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION FmBusReadReceiver + +DESCRIPTION + PFAL specific routine to read the FM I2C bus + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmBusReadReceiver +( +fm_i2c_params *readparams +) +{ + int fd_i2c; + int ret; + char *i2cdevice = get_fm_i2c_path(); + if (i2cdevice == NULL) + { + print("== I2C device path not available \n"); + return FM_CMD_FAILURE; + } + fd_i2c = open(i2cdevice, O_RDWR); + print("FmBusReadReceiver >\n"); + ret = i2c_read( fd_i2c, readparams->offset, readparams->data, + readparams->payload_length, readparams->slaveaddress); + if (ret < 0) + { + print(" i2c_read failed to read the data \n"); + close(fd_i2c); + return FM_CMD_FAILURE; + } + close(fd_i2c); + print2("== I2C Read SLAVE_ADDR = 0x%x\n",readparams->slaveaddress); + print2("== I2C reg = 0x%x ===\n",readparams->offset); + print2("== I2C data = 0x%x \n",readparams->data[0]); + + print("FmBusReadReceiver <\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== + +FUNCTION ftm_fm_run_mm + +DESCRIPTION + This function is used to run mm-audio-ftm. + +DEPENDENCIES + none + +===========================================================================*/ +void ftm_fm_run_mm(void) { + pid_t pid; + int err = 1; + + printf("entered ftm_fm_run_mm\n"); + pid = fork(); + + if (!pid) { + err = execl(mm_audio_path, mm_audio_path, NULL); + printf("mm module error %d\n", err); + exit(0); + } else if (pid < 0) { + printf("could not create child process to execute mm audio module\n"); + } + return; +} + +/*=========================================================================== + +FUNCTION ftm_fm_audio + +DESCRIPTION + This function is used to load the target based config file and + set the audio output and volume. + +DEPENDENCIES + none + +===========================================================================*/ +fm_cmd_status_type ftm_fm_audio(uint8 source, uint8 volume) { + + char *cmd = NULL; + char vlm[4]; + int sound_card_fd = -1; + char sound_card_name[sound_card_name_len]; + char *buffer; + size_t len; + ssize_t ret; + int tmp; + fm_cmd_status_type status = FM_CMD_FAILURE; + int prop_ret = 0; + char bt_soc_type[PROPERTY_VALUE_MAX]; + + printf("Enter ftm_fm_audio\n"); + memset(sound_card_name, 0, sizeof(sound_card_name)); + cmd = (char*) malloc(CMD_len * sizeof(char)); + if (!cmd) { + printf("memory allocation failed\n"); + goto failure; + } + memset(cmd, 0, CMD_len); + + if (strlcat(cmd, "-tc ", CMD_len) >= CMD_len) + goto failure; + + printf("string = %s \n",cmd); + printf("audio_output = %d\n", source); + buffer = source ? "51 -v " : "74 -v "; + if (strlcat(cmd, buffer, CMD_len) >= CMD_len) + goto failure; + + printf("string = %s \n",cmd); + tmp = snprintf(vlm, sizeof(vlm), "%d", volume); + if (tmp < 0 || sizeof (vlm) <= (size_t)tmp) + goto failure; + if (strlcat(cmd, vlm, CMD_len) >= CMD_len) + goto failure; + + sound_card_fd = open("/proc/asound/card0/id", O_RDWR); + if (sound_card_fd < 0) { + printf("failed to open sound card. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + + len = sound_card_name_len - 1; + while (len > 0) { + ret = read (sound_card_fd, + &sound_card_name[sound_card_name_len - 1 - len], len); + if (ret < 0) { + printf("Failed to read sound card name. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + if (!ret) { + if(!sound_card_name[0]) + goto failure; + else + break; + } + len -= ret; + } + printf("sound_card_name = %s\n", sound_card_name); + printf("string = %s \n",cmd); + + ftm_audio_fd = open("/data/vendor/misc/audio/ftm_commands", O_RDWR); + if (ftm_audio_fd < 0) { + printf("Failed to open ftm_commands with write. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + printf(" writing config path\n"); + prop_ret = property_get("qcom.bluetooth.soc", bt_soc_type, NULL); + if (prop_ret != 0) { + printf("qcom.bluetooth.soc set to %s\n", bt_soc_type); + if (!strncasecmp(bt_soc_type, "rome", sizeof("rome"))) { + buffer = audio_config; + len = config_len; + goto skip; + } + } + if (strstr(sound_card_name, "tasha")) { + printf("using external codec\n"); + buffer = (char *)ext_audio_config; + len = ext_config_len; + } else { + printf("using internal codec\n"); + buffer = (char *)audio_config; + len = config_len; + } + +skip: + while (len > 0) { + ret = write(ftm_audio_fd, buffer, len); + if (ret < 0) { + printf("Failed to write config_file. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + len -= ret; + buffer += ret; + } + printf("done write config path\n"); + sleep(1); + printf("writing command for path = 0x%zx \n", strlen(cmd)); + len = strlen(cmd) + 1; + + buffer = cmd; + while (len > 0) { + ret = write(ftm_audio_fd, buffer, strlen(cmd) + 1); + if (ret < 0) { + printf("Failed to write cmd. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + len -= ret; + buffer += ret; + } + printf("done write command for path\n"); + status = FM_CMD_SUCCESS; + // fall through intentional +failure: + if (cmd) + free(cmd); + if (sound_card_fd > 0) + close(sound_card_fd); + if (ftm_audio_fd > 0) { + close(ftm_audio_fd); + ftm_audio_fd = -1; + } + return status; +} + diff --git a/feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux_3990.c b/feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux_3990.c new file mode 100755 index 000000000..88ec7da15 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_fm_pfal_linux_3990.c @@ -0,0 +1,3338 @@ +/*========================================================================== +* +* Description +* Platform specific routines to program FM over Uart transport +* Copyright (c) 2010-2017 Qualcomm Technologies, Inc. +* All Rights Reserved. +* Confidential and Proprietary - Qualcomm Technologies, Inc. +* +*===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +3/10/16 ssugasi Add FTM support for FM module for uart based chipsets +==========================================================================*/ + +#include "ftm_fm_pfal.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef ANDROID +#include +#endif +#include +#include +#include +#include +#include +#include "ftm_common.h" +#include "radio-helium-commands.h" +#include +#define BIT16 (1<<16) + +/* Multiplying factor to convert to Radio freqeuncy */ +#define TUNE_MULT 16000 +/* Constant to request for Radio Events */ +#define EVENT_LISTEN 1 +/* 1000 multiplier */ +#define MULTIPLE_1000 1000 +/* Tavaura I2C address */ +int SLAVE_ADDR = 0x2A; +/* Tavaura I2C statu register*/ +#define INTSTAT_0 0x0 +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) +/* Debug Macro */ +#define FTM_DEBUG +#ifdef FTM_DEBUG +#define print(x) printf(x) +#define print2(x,y) printf(x,y) +#define print3(x,y,z) printf(x,y,z) +#else +#define print(x) +#define print2(x,y) +#define print3(x,y,z) +#endif +typedef unsigned char boolean; + +#define TAVARUA_BUF_PS_RDS 3 +#define V4L2_CID_PRIVATE_TAVARUA_REGION 0x08000007 +#define V4L2_CID_PRIVATE_TAVARUA_TX_SETPSREPEATCOUNT 0x08000015 +#define V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_PS_NAME 0x08000016 +#define V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_RT 0x08000017 +#define V4L2_CID_PRIVATE_TAVARUA_STATE 0x08000004 +#define V4L2_CID_PRIVATE_TAVARUA_SET_AUDIO_PATH 0x8000029 +#define V4L2_CID_PRIVATE_TAVARUA_RDSON 0x0800000F +#define V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC 0x08000010 +#define V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK 0x08000006 +#define V4L2_CID_PRIVATE_TAVARUA_RDSD_BUF 0x08000013 +#define V4L2_CID_PRIVATE_TAVARUA_ANTENNA 0x08000012 +#define V4L2_CID_PRIVATE_TAVARUA_RDSON 0x0800000F +#define V4L2_CID_PRIVATE_TAVARUA_EMPHASIS 0x0800000C +#define V4L2_CID_PRIVATE_TAVARUA_SPACING 0x0800000E +#define V4L2_CID_PRIVATE_TAVARUA_RDS_STD 0x0800000D +#define V4L2_CID_PRIVATE_TAVARUA_LP_MODE 0x08000011 +#define V4L2_CID_PRIVATE_TAVARUA_SRCHMODE 0x08000001 +#define V4L2_CID_PRIVATE_TAVARUA_SCANDWELL 0x08000002 +#define V4L2_CID_PRIVATE_TAVARUA_SRCH_PI 0x0800000A +#define V4L2_CID_PRIVATE_TAVARUA_SRCH_CNT 0x0800000B +#define V4L2_CID_PRIVATE_TAVARUA_SRCH_PTY 0x08000009 +#define V4L2_CID_PRIVATE_TAVARUA_SRCHON 0x08000003 +#define V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD 0x800002D +#define V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD 0x800002E +#define V4L2_CID_PRIVATE_SINR_THRESHOLD 0x800002F +#define V4L2_CID_PRIVATE_SINR_SAMPLES 0x8000030 +#define V4L2_CID_PRIVATE_TAVARUA_SIGNAL_TH 0x08000008 +#define V4L2_CID_PRV_ENABLE_SLIMBUS 0x00980940 +#define SRCH_DIR_UP (0) +#define SRCH_DIR_DOWN (1) + +#define FM_TX_PWR_LVL_0 0 /* Lowest power lvl that can be set for Tx */ +#define FM_TX_PWR_LVL_MAX 7 /* Max power lvl for Tx */ +#define RDS_Tx 0x80 +const char* fm_i2c_path_8660 = "/dev/i2c-4"; +const char* fm_i2c_path_7x30 = "/dev/i2c-2"; +const char* fm_i2c_path_7627a = "/dev/i2c-1"; +/* To get the current status of PS/RT transmission */ +volatile unsigned char is_rt_transmitting = 0; +volatile unsigned char is_ps_transmitting = 0; +int ftm_audio_fd = -1; +const char *const audio_config = "-c /vendor/etc/ftm_test_config"; +const unsigned int CMD_len = 16; +const int config_len = 31; +const int ext_config_len = 39; +const int sound_card_len = 200; +const char *const mm_audio_path = "/vendor/bin/mm-audio-ftm"; +char *FM_LIBRARY_NAME = "fm_helium.so"; +char *FM_LIBRARY_SYMBOL_NAME = "FM_HELIUM_LIB_INTERFACE"; +void *lib_handle; + +fm_config_data * fmconfig_ptr; +typedef void (*enb_result_cb)(); +typedef void (*tune_rsp_cb)(int Freq); +typedef void (*seek_rsp_cb)(int Freq); +typedef void (*scan_rsp_cb)(); +typedef void (*srch_list_rsp_cb)(uint16_t *scan_tbl); +typedef void (*stereo_mode_cb)(boolean status); +typedef void (*rds_avl_sts_cb)(boolean status); +typedef void (*af_list_cb)(uint16_t *af_list); +typedef void (*rt_cb)(char *rt); +typedef void (*ps_cb)(char *ps); +typedef void (*oda_cb)(); +typedef void (*rt_plus_cb)(char *rt_plus); +typedef void (*ert_cb)(char *ert); +typedef void (*disable_cb)(); +typedef void (*callback_thread_event)(unsigned int evt); +typedef void (*rds_grp_cntrs_cb)(char *rds_params); +typedef void (*rds_grp_cntrs_ext_cb)(char *rds_params); +typedef void (*fm_peek_cb)(char *peek_rsp); +typedef void (*fm_ssbi_peek_cb)(char *ssbi_peek_rsp); +typedef void (*fm_agc_gain_cb)(char *agc_gain_rsp); +typedef void (*fm_ch_det_th_cb)(char *ch_det_rsp); +typedef void (*fm_sig_thr_cb) (int val, int status); +typedef void (*fm_get_ch_det_thrs_cb) (int val, int status); +typedef void (*fm_def_data_rd_cb) (int val, int status); +typedef void (*fm_get_blnd_cb) (int val, int status); +typedef void (*fm_set_ch_det_thrs_cb) (int status); +typedef void (*fm_def_data_wrt_cb) (int status); +typedef void (*fm_set_blnd_cb) (int status); +typedef void (*fm_get_stn_prm_cb) (int val, int status); +typedef void (*fm_get_stn_dbg_prm_cb) (int val, int status); +typedef void (*fm_ecc_evt_cb)(char *ecc_rsp); +typedef void (*fm_enable_sb_cb) (int status); + +/* enum to montior the Power On status */ +typedef enum +{ + INPROGRESS, + COMPLETE +}poweron_status; + +boolean cmd_queued = FALSE; +/* Resourcse Numbers for Rx/TX */ +int FM_RX = 1; +int FM_TX = 2; +/* Boolean to control the power down sequence */ +volatile boolean power_down = FALSE; +/* V4L2 radio handle */ +int fd_radio = -1; +/* FM asynchornous thread to perform the long running ON */ +pthread_t fm_interrupt_thread,fm_on_thread; +/* Prototype ofFM ON thread */ +void *(ftm_on_long_thread)(void *ptr); +/* Global state ofthe FM task */ +fm_station_params_available fm_global_params; + +volatile poweron_status poweron; + +int chipVersion = 0; +extern volatile fm_power_state fmPowerState; +static char transport[PROPERTY_VALUE_MAX]; + +typedef struct { + size_t size; + enb_result_cb enabled_cb; + tune_rsp_cb tune_cb; + seek_rsp_cb seek_cmpl_cb; + scan_rsp_cb scan_next_cb; + srch_list_rsp_cb srch_list_cb; + stereo_mode_cb stereo_status_cb; + rds_avl_sts_cb rds_avail_status_cb; + af_list_cb af_list_update_cb; + rt_cb rt_update_cb; + ps_cb ps_update_cb; + oda_cb oda_update_cb; + rt_plus_cb rt_plus_update_cb; + ert_cb ert_update_cb; + disable_cb disabled_cb; + rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb; + rds_grp_cntrs_ext_cb rds_grp_cntrs_ext_rsp_cb; + fm_peek_cb fm_peek_rsp_cb; + fm_ssbi_peek_cb fm_ssbi_peek_rsp_cb; + fm_agc_gain_cb fm_agc_gain_rsp_cb; + fm_ch_det_th_cb fm_ch_det_th_rsp_cb; + fm_ecc_evt_cb fm_ext_country_code_cb; + callback_thread_event thread_evt_cb; + fm_sig_thr_cb fm_get_sig_thres_cb; + fm_get_ch_det_thrs_cb fm_get_ch_det_thr_cb; + fm_def_data_rd_cb fm_def_data_read_cb; + fm_get_blnd_cb fm_get_blend_cb; + fm_set_ch_det_thrs_cb fm_set_ch_det_thr_cb; + fm_def_data_wrt_cb fm_def_data_write_cb; + fm_set_blnd_cb fm_set_blend_cb; + fm_get_stn_prm_cb fm_get_station_param_cb; + fm_get_stn_dbg_prm_cb fm_get_station_debug_param_cb; + fm_enable_sb_cb fm_enable_slimbus_cb; +} fm_vendor_callbacks_t; + +typedef struct { + int (*hal_init)(fm_vendor_callbacks_t *p_cb); + int (*set_fm_ctrl)(int ioctl, int val); + int (*get_fm_ctrl) (int ioctl, int* val); +} fm_interface_t; + +void fm_enabled_cb() { + ALOGE("Entered %s", __func__); +} + +void fm_tune_cb(int Freq) +{ + ALOGE("TUNE:Freq:%d", Freq); + fm_global_params.current_station_freq =Freq; +} + +void fm_seek_cmpl_cb(int Freq) +{ + ALOGE("SEEK_CMPL: Freq: %d", Freq); + fm_global_params.current_station_freq =Freq; +} + +void fm_scan_next_cb() +{ + ALOGE("SCAN_NEXT"); +} + +void fm_srch_list_cb(uint16_t *scan_tbl) +{ + ALOGE("SRCH_LIST"); +} + +void fm_stereo_status_cb(boolean stereo) +{ + ALOGE("STEREO: %d", stereo); + fm_global_params.stype = stereo; +} + +void fm_rds_avail_status_cb(boolean rds_avl) +{ + ALOGE("fm_rds_avail_status_cb: %d", rds_avl); + fm_global_params.rds_sync_status = rds_avl; +} + +void fm_rt_update_cb(char *rt) +{ + ALOGE("Entered %s", __func__); + int radiotext_size = (int)(rt[0] & 0xFF); + fm_global_params.fm_rt_length = radiotext_size; + print2("radio text size = %d\n",fm_global_params.fm_rt_length); + fm_global_params.pgm_id = (((rt[2] & 0xFF) << 8) | (rt[3] & 0xFF)); + fm_global_params.pgm_type = (int)( rt[1] & 0x1F); + memset(fm_global_params.radio_text,0x0,MAX_RDS_RT_LENGTH); + memcpy(fm_global_params.radio_text,&rt[5],radiotext_size); +} + +void fm_ps_update_cb(char *buf) +{ + ALOGE("Entered %s", __func__); + int num_of_ps = (int)(buf[0] & 0xFF); + int ps_services_len = ((int )((num_of_ps*8) + 5)) - 5; + fm_global_params.fm_ps_length = ps_services_len; + fm_global_params.pgm_id = (((buf[2] & 0xFF) << 8) | (buf[3] & 0xFF)); + fm_global_params.pgm_type = (int)( buf[1] & 0x1F); + memset(fm_global_params.pgm_services,0x0,MAX_RDS_PS_LENGTH); + memcpy(fm_global_params.pgm_services,&buf[5],ps_services_len); + fm_global_params.pgm_services[ps_services_len] = '\0'; + print2("Pid = %d\n",fm_global_params.pgm_id); + print2("Ptype = %d\n",fm_global_params.pgm_type); + print2("PS name %s\n",fm_global_params.pgm_services); + +} +void fm_oda_update_cb() +{ + ALOGD("ODA_EVT"); +} + +void fm_af_list_update_cb(uint16_t *af_list) +{ + ALOGD("Entered %s", __func__); + +} +void fm_rt_plus_update_cb(char *rt_plus) +{ + ALOGD("Entered %s", __func__); +} + +void fm_ert_update_cb(char *ert) +{ + ALOGD("Entered %s", __func__); +} +void fm_disabled_cb() +{ + ALOGD("Entered %s", __func__); +} + +void rds_grp_cntrs_rsp_cb(char *rds_grp_cntr_buff) +{ + ALOGV("Entered %s", __func__); + struct fm_rds_grp_cntrsparams *response = (struct fm_rds_grp_cntrsparams *)rds_grp_cntr_buff; + ALOGI("copy RDS grp counter response "); + memcpy((void*)&fm_global_params.rds_group_counters,(void*)response,RDS_GRP_CNTRS_SIZE); + pthread_mutex_lock(&fm_event_lock); + pthread_cond_signal(&fm_event_cond); + pthread_mutex_unlock(&fm_event_lock); + ALOGD("Exit %s", __func__); +} +void rds_grp_cntrs_ext_rsp_cb(char * rds_grp_cntr_buff) +{ + ALOGD("rds_grp_cntrs_ext_rsp_cb"); + struct fm_rds_grpcntrs_extendedparams *response = (struct fm_rds_grpcntrs_extendedparams*)rds_grp_cntr_buff; + memcpy((void*)&fm_global_params.rds_group_counters_extended,(void*)response,sizeof(fm_rds_grpcntrs_extendedparams)); + ALOGV(" response totalRdsSyncLoss:%d\n totalRdsNotSync:%d\n totalRdsSyncInt:%d\n ", + fm_global_params.rds_group_counters_extended.totalRdsNotSync, + fm_global_params.rds_group_counters_extended.totalRdsSyncInt, + fm_global_params.rds_group_counters_extended.totalRdsSyncLoss); + ALOGV("Exit %s", __func__); +} + +void fm_peek_rsp_cb(char *peek_rsp) { + struct fm_riva_poke_word *responce = (struct fm_riva_poke_word *)peek_rsp; + memcpy((void*)&fm_global_params.riva_data_access_params, + (void*)responce,sizeof(struct fm_riva_poke_word)); +} + +void fm_ssbi_peek_rsp_cb(char *ssbi_peek_rsp){ + fm_global_params.ssbi_peek_data = ssbi_peek_rsp[0]; +} + +void fm_agc_gain_rsp_cb(char *agc_gain_Resp){ + ALOGD("Entered %s", __func__); + struct fm_set_get_reset_agc_params *response =( + struct fm_set_get_reset_agc_params *)agc_gain_Resp; + memcpy((void*)&fm_global_params.set_get_reset_agc_params, + (void*)response, sizeof(struct fm_set_get_reset_agc_params)); + + ALOGV("Get AGC gain state success\n"); + ALOGV("Current state: %x\nUcGainStateChng1: %x\nUcGainStateChng2: %x\nUcGainStateChng3: %x", + fm_global_params.set_get_reset_agc_params.ucCurrentGainState, + fm_global_params.set_get_reset_agc_params.ucGainStateChange1, + fm_global_params.set_get_reset_agc_params.ucGainStateChange2, + fm_global_params.set_get_reset_agc_params.ucGainStateChange3); +} + +void fm_ch_det_th_rsp_cb(char *ch_det_rsp){ + ALOGD("Entered %s", __func__); +} + +void fm_thread_evt_cb(unsigned int event) +{ + ALOGE("Entered %s", __func__); +} + + static void fm_get_sig_thres_cb(int val, int status) +{ + ALOGD("Get signal Thres callback"); +} + +static void fm_get_ch_det_thr_cb(int val, int status) +{ + ALOGI("fm_get_ch_det_thr_cb"); +} + +static void fm_set_ch_det_thr_cb(int status) +{ + ALOGE("fm_set_ch_det_thr_cb"); +} + +static void fm_def_data_read_cb(int val, int status) +{ + ALOGE("fm_def_data_read_cb"); +} + +static void fm_def_data_write_cb(int status) +{ + ALOGE("fm_def_data_write_cb"); +} + +static void fm_get_blend_cb(int val, int status) +{ + ALOGE("fm_get_blend_cb"); +} + +static void fm_set_blend_cb(int status) +{ + ALOGE("fm_set_blend_cb"); +} + +static void fm_get_station_param_cb(int val, int status) +{ + if (status == 0) + fm_global_params.rssi = val; + else + fm_global_params.rssi = 0; + pthread_mutex_lock(&fm_event_lock); + pthread_cond_signal(&fm_event_cond); + pthread_mutex_unlock(&fm_event_lock); + ALOGD("fm_get_station_param_cb rssi =%d\n",fm_global_params.rssi); +} + +static void fm_get_station_debug_param_cb(int val, int status) +{ + ALOGE("fm_get_station_debug_param_cb"); +} + +static void fm_ext_country_code_cb(char *ecc_rsp) +{ + ALOGD("Entered %s", __func__); +} + +static void fm_enable_slimbus_cb(int status) +{ + ALOGD("%s status %d", __func__, status); + pthread_mutex_lock(&fm_event_lock); + pthread_cond_signal(&fm_event_cond); + pthread_mutex_unlock(&fm_event_lock); +} + +fm_interface_t *vendor_interface; +static fm_vendor_callbacks_t fm_callbacks = { + sizeof(fm_callbacks), + fm_enabled_cb, + fm_tune_cb, + fm_seek_cmpl_cb, + fm_scan_next_cb, + fm_srch_list_cb, + fm_stereo_status_cb, + fm_rds_avail_status_cb, + fm_af_list_update_cb, + fm_rt_update_cb, + fm_ps_update_cb, + fm_oda_update_cb, + fm_rt_plus_update_cb, + fm_ert_update_cb, + fm_disabled_cb, + rds_grp_cntrs_rsp_cb, + rds_grp_cntrs_ext_rsp_cb, + fm_peek_rsp_cb, + fm_ssbi_peek_rsp_cb, + fm_agc_gain_rsp_cb, + fm_ch_det_th_rsp_cb, + fm_ext_country_code_cb, + fm_thread_evt_cb, + fm_get_sig_thres_cb, + fm_get_ch_det_thr_cb, + fm_def_data_read_cb, + fm_get_blend_cb, + fm_set_ch_det_thr_cb, + fm_def_data_write_cb, + fm_set_blend_cb, + fm_get_station_param_cb, + fm_get_station_debug_param_cb, + fm_enable_slimbus_cb +}; + +/*=========================================================================== +FUNCTION extract_rds_grp_cntr_data + +DESCRIPTION + Helper routine to read the data from the V4L2 buffer + following a Read Rds Group counters command complete + +DEPENDENCIES + NIL + +RETURN VALUE + void + +SIDE EFFECTS + Updates the Global data strutures member rds_group_counters + +===========================================================================*/ + +void extract_rds_grp_cntr_data() +{ + uint8 buf[RDS_GRP_CNTRS_SIZE]; + struct RDSCntrsParams *responce = (struct RDSCntrsParams *)buf; + memcpy((void*)&fm_global_params.rds_group_counters,(void*)responce,sizeof(buf)); +} +/*=========================================================================== +FUNCTION extract_default_read_data + +DESCRIPTION + Helper routine to read the data from the V4L2 buffer + following a defaultRead command complete + +DEPENDENCIES + NIL + +RETURN VALUE + void + +SIDE EFFECTS + Updates the Global data struture member rd_default + +===========================================================================*/ + +void extract_default_read_data() +{ + print("Not implemented"); +} +/*=========================================================================== +FUNCTION reset_rds + +DESCRIPTION + Reset the existing RDS data. + +DEPENDENCIES + Radio event + +RETURN VALUE + void + +IDE EFFECTS + Reset the Global RDS data info like RT, PS etc. +===========================================================================*/ + +void reset_rds() +{ + memset(fm_global_params.pgm_services,0x0,MAX_RDS_PS_LENGTH); + memset(fm_global_params.radio_text,0x0,MAX_RDS_RT_LENGTH); + fm_global_params.pgm_id = 0; + fm_global_params.pgm_type = 0; +} + +struct timespec* set_time_out(int secs) +{ + struct timespec *ts; + struct timeval tp; + ts = malloc(sizeof(struct timespec)); + if(!ts) + { + printf("malloc failed"); + return NULL; + } + gettimeofday(&tp, NULL); + ts->tv_sec = tp.tv_sec; + ts->tv_nsec = tp.tv_usec * 1000; + ts->tv_sec += secs; + + return ts; +} + +/*=========================================================================== +FUNCTION EnableFM + +DESCRIPTION + PFAL specific routine to enable the FM receiver/transmitter with the Radio + Configuration parameters passed. + +PLATFORM SPECIFIC DESCRIPTION + Opens the handle to /dev/radio0 V4L2 device and intiates a Soc Patch + download, configurs the Init parameters like emphasis, channel spacing, + band limit, RDS type, frequency band, and Radio State. + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type EnableFM +( + fm_config_data* radiocfgptr +) +{ + int status; +#ifdef FTM_DEBUG + + if(radiocfgptr->is_fm_tx_on) + print("\nEnable Transmitter entry\n"); + else + print("\nEnable Receiver entry\n"); +#endif + + lib_handle = dlopen(FM_LIBRARY_NAME, RTLD_NOW); + if (!lib_handle) { + ALOGE("%s unable to open %s: %s", __func__, FM_LIBRARY_NAME, dlerror()); + lib_handle = NULL; + return FM_CMD_NO_RESOURCES; + } + + printf("Obtaining handle: '%s' to the shared object library...\n", FM_LIBRARY_SYMBOL_NAME); + vendor_interface = (fm_interface_t *)dlsym(lib_handle, FM_LIBRARY_SYMBOL_NAME); + if (!vendor_interface) { + ALOGE("%s unable to find symbol %s in %s: %s", __func__, FM_LIBRARY_SYMBOL_NAME, FM_LIBRARY_NAME, dlerror()); + vendor_interface = NULL; + if (lib_handle) + dlclose(lib_handle); + return FM_CMD_NO_RESOURCES; + } + + if (vendor_interface) { + ALOGE("Initializing the FM HAL module & registering the JNI callback functions..."); + status = vendor_interface->hal_init(&fm_callbacks); + if (status) { + ALOGE("%s unable to initialize vendor library: %d", __func__, status); + return FM_CMD_NO_RESOURCES; + } + ALOGD("***** FM HAL Initialization complete *****\n"); + } + + if(radiocfgptr->is_fm_tx_on) + print("\nOpened Transmitter\n"); + else + print("\nOpened Receiver\n"); + +/* + Starting 'ftm_on_long_thread' where we do all the FM configurations + and intializations. + +*/ + fmPowerState = FM_POWER_TRANSITION; + pthread_create( &fm_on_thread, NULL, ftm_on_long_thread, radiocfgptr); + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION TransmitPS + +DESCRIPTION + PFAL specific routine to transmit RDS PS strings + +PARAMS PASSED + 'tuFmPSParams' containing RDS PI, PTY, max. no. of PS repeat count and + PS name of the transmitting station + +PLATFORM SPECIFIC DESCRIPTION + This routine is used to transmit the PS string describing the transmitter's + information and genre of the audio content being transmitted + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type TransmitPS +( + tsFtmFmRdsTxPsType* tuFmPSParams +) +{ + int ret = 0; + + struct v4l2_control control; + struct v4l2_ext_controls v4l2_ctls; + struct v4l2_ext_control ext_ctl; + + print("\n Entering Transmit PS \n"); + + /* Set Program Type (PTY) */ + control.id = V4L2_CID_RDS_TX_PTY; + control.value = 0; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set PTY failed \n"); + return FM_CMD_FAILURE; + } + + /* Set Program Identifier (PI) */ + control.id = V4L2_CID_RDS_TX_PI; + control.value = tuFmPSParams->tusTxPi; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set PI failed \n"); + return FM_CMD_FAILURE; + } + + /*Set PS max. repeat count */ + control.id = V4L2_CID_PRIVATE_TAVARUA_TX_SETPSREPEATCOUNT; + control.value = tuFmPSParams->ucTxPSRptCnt; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set MAX_REPEAT_CNT failed \n"); + return FM_CMD_FAILURE; + } + + /*Set Program Service name (PS) */ + ext_ctl.id = V4L2_CID_RDS_TX_PS_NAME; + ext_ctl.string = (char *)tuFmPSParams->cTxPSStrPtr; + ext_ctl.size = tuFmPSParams->ulPSStrLen; + v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + v4l2_ctls.count = 0; + v4l2_ctls.controls = &ext_ctl; + + ret = ioctl(fd_radio, VIDIOC_S_EXT_CTRLS, &v4l2_ctls ); + if(ret < 0 ) + { + print("\n VIDIOC_S_EXT_CTRLS ioctl: Set PS failed \n"); + return FM_CMD_FAILURE; + } + is_ps_transmitting = 1; + print("\n Exiting Transmit PS \n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION stopTransmitPS + +DESCRIPTION + PFAL specific routine to stop transmitting the PS string. + +PARAMS PASSED + NIL + +PLATFORM SPECIFIC DESCRIPTION + This routine is used to stop transmitting the PS string + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +============================================================================*/ +fm_cmd_status_type stopTransmitPS +( + void +) +{ + int ret = 0; + struct v4l2_control control; + + print("\n Entering stopTransmitPS \n"); + + control.id = V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_PS_NAME; + ret = ioctl(fd_radio, VIDIOC_S_CTRL , &control); + if(ret < 0){ + print("Failed to stop Transmit PS"); + return FM_CMD_FAILURE; + } + else { + print("\nStopped transmitting PS\n"); + is_ps_transmitting = 0; + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION TransmitRT + +DESCRIPTION + PFAL specific routine to transmit the RT string. + +PARAMS PASSED + 'tuFmRTParams' containing RDS PI, and RT information of the transmitting + station + +PLATFORM SPECIFIC DESCRIPTION + This routine is used to transmit the RT string which provides a brief info + of the audio content being transmitted. This includes artist name, movie name + few lines of the audio. Usually the metadata of the song is transmitted as RT + + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None +===========================================================================*/ +fm_cmd_status_type TransmitRT +( + tsFtmFmRdsTxRtType* tuFmRTParams +) +{ + int ret = 0; + + struct v4l2_control control; + struct v4l2_ext_controls v4l2_ctls; + struct v4l2_ext_control ext_ctl; + + v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_FM_TX; + v4l2_ctls.count = 1; + v4l2_ctls.controls = &ext_ctl; + + print("\n Entering Transmit RT \n"); + + if(tuFmRTParams == NULL) + { + print("\n 'tuFmRTParams ' is not NULL \n "); + return FM_CMD_FAILURE; + } + else + { + ext_ctl.id = V4L2_CID_RDS_TX_RADIO_TEXT; + ext_ctl.string = (char *)tuFmRTParams->cTxRTStrPtr; + ext_ctl.size = tuFmRTParams->ulRTStrLen; + } + /* Set Program Type (PTY) */ + control.id = V4L2_CID_RDS_TX_PTY; + control.value = 0; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set PTY failed \n"); + return FM_CMD_FAILURE; + } + + /* Set Program Identifier (PI) */ + control.id = V4L2_CID_RDS_TX_PI; + control.value = tuFmRTParams->tusTxPi; + ret = ioctl(fd_radio, VIDIOC_S_CTRL,&control ); + if(ret < 0 ) + { + print("\n VIDIOC_S_CTRL ioctl: Set PI failed \n"); + return FM_CMD_FAILURE; + } + + /* Set the Radio Text (RT) to be transmitted */ + ret = ioctl(fd_radio, VIDIOC_S_EXT_CTRLS, &v4l2_ctls ); + if(ret < 0 ) + { + print("\n VIDIOC_S_EXT_CTRLS ioctl: Set RT failed \n"); + return FM_CMD_FAILURE; + } + + is_rt_transmitting = 1; + return FM_CMD_SUCCESS; + +} + +/*=========================================================================== +FUNCTION stopTransmitRT + +DESCRIPTION + PFAL specific routine to stop transmitting the RT string. + +PLATFORM SPECIFIC DESCRIPTION + This routine is called to stop transmitting the RT string for the + transmitting station + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type stopTransmitRT +( + void +) +{ + int ret = 0; + + print("\n Entering stopTransmitRT \n"); + + struct v4l2_control control; + control.id = V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_RT; + ret = ioctl(fd_radio, VIDIOC_S_CTRL , &control); + if(ret < 0){ + print("Failed to stop Transmit RT"); + return FM_CMD_FAILURE; + } + else { + print("\nStopped transmitting RT\n"); + is_rt_transmitting = 0; + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION getTxPSFeatures + +DESCRIPTION + PFAL specific routine to get all the supported Tx PS features + +PLATFORM SPECIFIC DESCRIPTION + This routine is called to get the supported PS features for the + transmitting station + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type getTxPSFeatures +( + void +) +{ + print("\n Entering getTxPSFeatures() \n"); + printf("\n Supported Tx PS Features:\n"); + printf("\n Max PS Count : %d\n",MAX_TX_PS_LEN); + printf("\n Max PS Repeat Count : %d\n",MAX_TX_PS_RPT_CNT); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION ftm_on_long_thread + +DESCRIPTION + Helper routine to perform the rest ofthe FM calibration and SoC Patch + download and configuration settings following the opening ofradio handle + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + None + +===========================================================================*/ +void *(ftm_on_long_thread)(void *ptr) +{ + int ret = 0; + struct v4l2_control control; + struct v4l2_tuner tuner; + int i,init_success = 0; + char value[PROPERTY_VALUE_MAX]; + struct v4l2_capability cap; + char versionStr[40]; + char cmdBuffer[40]; + char product_board_platform_type[PROPERTY_VALUE_MAX]; + fm_cmd_status_type status; + + fm_config_data* radiocfgptr = (fm_config_data *)ptr; + + property_get("qcom.bluetooth.soc", value, NULL); + print2("BT soc is %s\n", value); + /** + * V4L2_CID_PRIVATE_TAVARUA_STATE + * V4L2_CID_PRIVATE_TAVARUA_EMPHASIS + * V4L2_CID_PRIVATE_TAVARUA_SPACING + * V4L2_CID_PRIVATE_TAVARUA_RDS_STD + * V4L2_CID_PRIVATE_TAVARUA_REGION + */ + + /* Switching on FM */ + if (radiocfgptr->is_fm_tx_on) + { + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_STATE, FM_TX); + if(ret < FALSE) + { + print("Failed to turn on FM Trnasmitter\n"); + return NULL; + } + else + print("\nEnabled FM Transmitter successfully\n"); + } + else + { + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_STATE, FM_RX); + if(ret < FALSE) + { + print("Failed to turn on FM Receiver\n"); + return NULL; + } + else + print("\nEnabled FM Receiver successfully\n"); + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SET_AUDIO_PATH,1); + if(ret < FALSE) + { + print("Failed to set Audio path \n"); + } + + status = ConfigureFM(radiocfgptr); + if(status != FM_CMD_SUCCESS) + { + print("Failed to configure fm\n"); + return NULL; + } + + /* Setting RDS On */ + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSON,1); + if(ret is_fm_tx_on) + { + int rdsMask = FM_RX_RDS_GRP_RT_EBL | FM_RX_RDS_GRP_PS_EBL | + FM_RX_RDS_GRP_AF_EBL | FM_RX_RDS_GRP_PS_SIMPLE_EBL | + FM_RX_RDS_GRP_ECC_EBL| FM_RX_RDS_GRP_PTYN_EBL | + FM_RX_RDS_GRP_RT_PLUS_EBL; + + byte rdsFilt = 0; + int psAllVal=rdsMask & (1 << 4); + print2("rdsOptions: rdsMask: %x\n",rdsMask); + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC, + rdsMask); + if(ret < FALSE) + { + print("Failed to set RDS GROUP PROCESSING!!!\n"); + return NULL; + } + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK,0x0FFF); + if (ret < FALSE) + { + print("Failed to set RDS GRP MASK!!!\n"); + return NULL; + } + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSD_BUF,1); + if (ret < FALSE) + { + print("Failed to set RDS BUF!!!\n"); + return NULL; + } + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_ANTENNA,0); + if(ret < FALSE) + { + print("Failed to set ANTENNA!!!\n"); + return NULL; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_SOFT_MUTE, 0); + if(ret < FALSE) + { + print("Failed to Disable Soft Mute!!!\n"); + return NULL; + } + + } + power_down = FALSE; + + if(radiocfgptr->is_fm_tx_on) { +#ifdef FTM_DEBUG + print("\nEnable Transmitter exit\n"); +#endif + fmPowerState = FM_TX_ON; + } + else { +#ifdef FTM_DEBUG + print("\nEnable Receiver exit\n"); +#endif + fmPowerState = FM_RX_ON; + } + poweron = COMPLETE; + return NULL; +} + +/*=========================================================================== +FUNCTION DisableFM + +DESCRIPTION + PFAL specific routine to disable FM and free the FM resources + +PLATFORM SPECIFIC DESCRIPTION + Closes the handle to /dev/radio0 V4L2 device + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None +===========================================================================*/ +fm_cmd_status_type DisableFM +( + fm_config_data* radiocfgptr +) +{ + struct v4l2_control control; + uint8 buf[128]; + double tune; + char value[PROPERTY_VALUE_MAX]; + struct v4l2_frequency freq_struct; + int ret; + + /* Wait till the previous ON sequence has completed */ + while(poweron != COMPLETE); + +#ifdef FTM_DEBUG + print("DisableFM start\n"); +#endif + + power_down = TRUE; + + /* Set RDS Off */ + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSON,0); + if(ret < FALSE) + { + print("DisableFM failed to set RDS off \n"); + return FM_CMD_FAILURE; + } + + /* Turn off FM */ + /* As part of Turning off FM we will get 'READY' event */ + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_STATE,0); + if(ret < FALSE) + { + if(radiocfgptr->is_fm_tx_on) + { + print("\nFailed to Turn Off FM Transmitter\n"); + return FM_CMD_FAILURE; + } + else + { + print("\nFailed to Turn Off FM Receiver\n"); + return FM_CMD_FAILURE; + } + } + +#ifdef FTM_DEBUG + print("Stopping the FM control\n"); +#endif + +#ifdef ANDROID + + property_get("qcom.bluetooth.soc", value, NULL); + print2("BT soc is %s\n", value); + if (strcmp(value, "rome") != 0) + { + property_set("ctl.stop", "fm_dl"); + } + +#endif/*ANDROID*/ +cmd_queued = TRUE; + +#ifdef FTM_DEBUG + + if(radiocfgptr->is_fm_tx_on) + print("Disabled FM Transmitter\n"); + else + print("Disabled FM Receiver\n"); + +#endif + fmPowerState = FM_POWER_OFF; + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION ConfigureFM + +DESCRIPTION + PFAL specific routine to configure FM with the Radio Configuration + parameters passed. + +PLATFORM SPECIFIC DESCRIPTION + Configures the Init parameters like emphasis, channel spacing, Band Limit, + RDS type, Frequency Band, and Radio State. + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type ConfigureFM +( + fm_config_data* radiocfgptr +) +{ + int ret = 0; + struct v4l2_control control; + struct v4l2_tuner tuner; + +#ifdef FTM_DEBUG + + if(radiocfgptr->is_fm_tx_on) + print("\nConfigure FM Transmitter entry\n"); + else + print("\nConfigure FM Receiver entry\n"); +#endif + + /* Set Emphasis, Channel spacing and RDS Standard : + Emphasis : + '0' - 75 - US/EU + '1' - 50 - JAPAN/JAPAN-WIDE/ASIA + Channel Spacing : + '0' - 200kHz - US/EU + '1' - 100kHz - JAPAN + '2' - 50kHz - JAPAN-WIDE + RDS/RDBS Standard : + '0' - RDBS - US/EU + '1' - RDS - All regions + */ + fmconfig_ptr =(fm_config_data *) malloc(sizeof(fm_config_data)); + if(!fmconfig_ptr) + { + print("malloc failed"); + return FM_CMD_FAILURE; + } + fmconfig_ptr->band = radiocfgptr->band; + switch(radiocfgptr->band) + { + case FM_US_EU: + radiocfgptr->emphasis = 0; + radiocfgptr->spacing = 0; + radiocfgptr->rds_system = 0; + break; + case FM_JAPAN_STANDARD: + radiocfgptr->emphasis = 1; + radiocfgptr->spacing = 1; + radiocfgptr->rds_system = 1; + case FM_JAPAN_WIDE: + radiocfgptr->emphasis = 1; + radiocfgptr->spacing = 2; + radiocfgptr->rds_system = 1; + break; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_EMPHASIS, radiocfgptr->emphasis); + if(ret < FALSE) + { + print("ConfigureFM : Failed to set Emphasis \n"); + return FM_CMD_FAILURE; + } + + /* Set channel spacing */ + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SPACING,radiocfgptr->spacing); + if(ret < FALSE) + { + print("ConfigureFM : Failed to set channel spacing \n"); + return FM_CMD_FAILURE; + } + + /* Set RDS/RDBS Standard */ + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDS_STD,radiocfgptr->rds_system); + if(ret < FALSE) + { + print("ConfigureFM : Failed to set RDS std \n"); + return FM_CMD_FAILURE; + } + + /* Set band limit and audio mode to Mono/Stereo */ + tuner.index = 0; + tuner.signal = 0; + + print2("ConfigureFM : radio band = %d\n",radiocfgptr->band); + switch(radiocfgptr->band) + { + case FM_US_EU: + tuner.rangelow = REGION_US_EU_BAND_LOW ; + tuner.rangehigh = REGION_US_EU_BAND_HIGH; + break; + case FM_JAPAN_STANDARD: + tuner.rangelow = REGION_JAPAN_STANDARD_BAND_LOW; + tuner.rangehigh = REGION_JAPAN_STANDARD_BAND_HIGH; + break; + case FM_JAPAN_WIDE: + tuner.rangelow = REGION_JAPAN_WIDE_BAND_LOW; + tuner.rangehigh = REGION_JAPAN_WIDE_BAND_HIGH; + break; + default: + tuner.rangelow = radiocfgptr->bandlimits.lower_limit; + tuner.rangehigh = radiocfgptr->bandlimits.upper_limit; + break; + } + + ret = vendor_interface->set_fm_ctrl(HCI_FM_HELIUM_UPPER_BAND, tuner.rangehigh); + ret = vendor_interface->set_fm_ctrl(HCI_FM_HELIUM_LOWER_BAND, tuner.rangelow); + fmconfig_ptr->bandlimits.lower_limit = tuner.rangelow; + fmconfig_ptr->bandlimits.upper_limit = tuner.rangehigh; + print3("ConfigureFM : set band limits: lower_limit=%d\t upper_limit = %d \n", fmconfig_ptr->bandlimits.lower_limit,fmconfig_ptr->bandlimits.upper_limit ); + if(ret < 0) + { + print("ConfigureFM : Failed to set band limits and audio mode \n"); + return FM_CMD_FAILURE; + } + + /* Set Region */ + radiocfgptr->band = FM_USER_DEFINED; + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_REGION,radiocfgptr->band); + if(ret < FALSE) + { + print("ConfigureFM : Failed to set band\n"); + return FM_CMD_FAILURE; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSON,1); + if(ret < 0) + { + print("ConfigureFM : Failed to set RDS ON \n"); + return FM_CMD_FAILURE; + } +out : +#ifdef FTM_DEBUG + + if(radiocfgptr->is_fm_tx_on) + print("\nConfigure FM Transmitter exit\n"); + else + print("\nConfigure FM Receiver exit\n"); +#endif + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetFrequencyReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's Frequency ofreception + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetFrequencyReceiver +( + uint32 ulfreq +) +{ + int err; + int freq_rangehigh,freq_rangelow; +#ifdef FTM_DEBUG + print2("\nSetFrequency Receiver entry freq = %d\n",(int)ulfreq); +#endif + freq_rangehigh = fmconfig_ptr->bandlimits.upper_limit; + freq_rangelow = fmconfig_ptr->bandlimits.lower_limit; + printf("\n set frequency=%d\t range_high=%d\t range_low =%d\n",ulfreq,freq_rangehigh,freq_rangelow); + ALOGE("\n set frequency=%d\t range_high=%d\t range_low =%d\n",ulfreq,freq_rangehigh,freq_rangelow); + if (ulfreq >= freq_rangelow && ulfreq <= freq_rangehigh) + { + err = vendor_interface->set_fm_ctrl(HCI_FM_HELIUM_FREQ, ulfreq); + if (err < 0) + { + print("SetFrequencyReceiver : Failed to set Freq \n"); + return FM_CMD_FAILURE; + } + } + else + { + print("SetFrequencyReceiver : frequency out of band limits \n"); + return FM_CMD_DISALLOWED; + } + +#ifdef FTM_DEBUG + print("\nSetFrequency Receiver exit\n"); +#endif + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetFrequencyTransmitter + +DESCRIPTION + PFAL specific routine to configure the FM Transmitter's frequency + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetFrequencyTransmitter +( + uint32 ulfreq +) +{ + int err; + double tune; + struct v4l2_frequency freq_struct; + struct v4l2_control control; + struct v4l2_tuner tuner; +#ifdef FTM_DEBUG + print2("\n SetFrequencyTransmitter() entry : Freq = %d \n",(int)ulfreq); +#endif + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + /* Stop transmitting PS/RT frequency of currently tuned station */ + print2("\n Currently tuned station is : %ld \n",fm_global_params.current_station_freq); + if(is_ps_transmitting) + stopTransmitPS(); + if(is_rt_transmitting) + stopTransmitRT(); + + tuner.index = 0; + + err = ioctl(fd_radio,VIDIOC_G_TUNER,&tuner); + if(err < 0) + { + print("SetFrequencyTransmitter : Failed to get band limits and audio mode \n"); + return FM_CMD_FAILURE; + } + + /* Fill up the 'v4l2_frequency' structure */ + freq_struct.type = V4L2_TUNER_RADIO; + freq_struct.frequency = (ulfreq) * (TUNE_MULT/1000); + if (freq_struct.frequency >= tuner.rangelow && freq_struct.frequency <= tuner.rangehigh) + { + err = ioctl(fd_radio, VIDIOC_S_FREQUENCY, &freq_struct); + if(err < 0) + return FM_CMD_FAILURE; + else + print2("\n Frequency : %ld \n",ulfreq); + } + else + { + print("SetFrequencyTransmitter : Frequency out of bandlimits\n"); + return FM_CMD_DISALLOWED; + } + +#ifdef FTM_DEBUG + print("\n SetFrequencyTransmitter() exit \n"); +#endif + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetTxPowerLevel + +DESCRIPTION + PFAL specific routine to configure the FM transmitter's power level + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetTxPowerLevel +( + uint32 ulfreq +) +{ + int err; + struct v4l2_control control; + + /* Set the power level as requested */ + control.id = V4L2_CID_TUNE_POWER_LEVEL; + control.value = FM_TX_PWR_LVL_MAX; + err = ioctl(fd_radio, VIDIOC_S_CTRL, &control); + if(err < 0) + { + if( err == -ETIME) + print("\nTimeout to read PHY_TX gain Register\n"); + else + { + print2("\nFailed to set the Power Level for %ld\n",ulfreq); + return FM_CMD_FAILURE; + } + } + else + print2("\nSuccessfully set the Power Level for %ld\n",ulfreq); + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetMuteModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's mute status + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetMuteModeReceiver +( + mute_type mutemode +) +{ + int err,i; + struct v4l2_control control; + print2("SetMuteModeReceiver mode = %d\n",mutemode); + + err = vendor_interface->set_fm_ctrl(HCI_FM_HELIUM_AUDIO_MUTE,mutemode); + if(err >= 0) + { + print("SetMuteMode Success\n"); + return FM_CMD_SUCCESS; + } + print2("Set mute mode ret = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== + +FUNCTION SetSoftMuteModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's soft mute status + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSoftMuteModeReceiver +( + mute_type mutemode +) +{ + int err; + struct v4l2_control control; + print2("SetMuteModeReceiver mode = %d\n",mutemode); + + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_SOFT_MUTE,mutemode); + if(err >= 0) + { + print("SetMuteMode Success\n"); + return FM_CMD_SUCCESS; + } + print2("Set mute mode ret = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION SetAntenna + +DESCRIPTION + PFAL specific routine to configure the FM receiver's antenna type + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type SetAntenna +( + antenna_type antenna +) +{ + int err; + struct v4l2_control control; + control.value = antenna; + control.id = V4L2_CID_PRIVATE_TAVARUA_ANTENNA; + + err = vendor_interface->set_fm_ctrl(HCI_FM_HELIUM_ANTENNA,antenna); + if(err >= 0) + { + print("SetAntenna Success\n"); + return FM_CMD_SUCCESS; + } + + print2("Set antenna ret = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION FmRivaPeekData + +DESCRIPTION + PFAL specific routine to get the data from Riva Memory +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmRivaPeekData +( + fm_riva_peek_word peek_word +) +{ + int err; + struct v4l2_control control; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = peek_word.startaddress; + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR; + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR, + peek_word.startaddress); + if(err >= 0) + { + print("SetRiva Address Success\n"); + } + control.value = peek_word.payload_length; + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN; + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN, + peek_word.payload_length); + if(err >= 0) + { + print("SetDataLen Success\n"); + } + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_PEEK; + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_RIVA_PEEK, control.value); + if(err >= 0) + { + print("RivaPeek Success\n"); + return FM_CMD_SUCCESS; + } + + print2("RivaPeekData ret = %d\n",err); + return FM_CMD_FAILURE; +} + + +/*=========================================================================== +FUNCTION FmRivaPokeData + +DESCRIPTION + PFAL specific routine to write the data into the Riva Memory +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmRivaPokeData +( + fm_riva_poke_word poke_word +) +{ + int err; + struct v4l2_control control; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = poke_word.startaddress; + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR; + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR, + poke_word.startaddress); + if(err >= 0) + { + print("SetRiva Address Success\n"); + } + control.value = poke_word.payload_length; + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN; +// err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN, + poke_word.payload_length); + if(err >= 0) + { + print("SetDataLen Success\n"); + } + control.id = V4L2_CID_PRIVATE_IRIS_RIVA_POKE; + control.value = (uint32)(uintptr_t)(&poke_word.data); + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_RIVA_POKE, + control.value); + if(err >= 0) + { + print("RivaPoke Success\n"); + return FM_CMD_SUCCESS; + } + + print2("RivaPokeData ret = %d\n",err); + return FM_CMD_FAILURE; +} + + +/*=========================================================================== +FUNCTION FmSSBIPeekData + +DESCRIPTION + PFAL specific routine to get the data from SSBI registers +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmSSBIPeekData +( + fm_ssbi_poke_reg peek_reg +) +{ + int err; + struct v4l2_control control; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.id = V4L2_CID_PRIVATE_IRIS_SSBI_PEEK; + control.value = peek_reg.startaddress; + if( control.value == 0x00) + return FM_CMD_FAILURE; + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_SSBI_PEEK, + peek_reg.startaddress); + if(err >= 0) + { + //extract_ssbi_peek_data(); + print2("SSBIPeek Success\n %d",peek_reg.data); + return FM_CMD_SUCCESS; + } + + print2("SSBIPeekData ret = %d\n",err); + return FM_CMD_FAILURE; +} + +fm_cmd_status_type FmSetGetResetAGC +( + fm_set_get_reset_agc_req agc_params +) +{ + int err; + struct v4l2_control control; + control.value = agc_params.ucCtrl; + control.id = V4L2_CID_PRIVATE_IRIS_AGC_CTRL; + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_AGC_CTRL, + agc_params.ucCtrl); + if(err >= 0) + { + print("Sending AGC ucCtrL Success\n"); + } + control.value = agc_params.ucGainState; + control.id = V4L2_CID_PRIVATE_IRIS_AGC_STATE; + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_AGC_STATE, + agc_params.ucGainState); + if(err >= 0) + { + print("Set ucGainstate Success\n"); + return FM_CMD_SUCCESS; + } + + print2("SetGetResetAGC ret = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION FmSSBIPokeData + +DESCRIPTION + PFAL specific routine to program the SSBI registers +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmSSBIPokeData +( + fm_ssbi_poke_reg poke_reg +) +{ + int err; + struct v4l2_control control; + + if(fd_radio < 0) + return FM_CMD_NO_RESOURCES; + + control.value = poke_reg.startaddress; + control.id = V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR; + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR, + poke_reg.startaddress); + if(err >= 0) + { + print("SetRiva Address Success\n"); + } + control.id = V4L2_CID_PRIVATE_IRIS_SSBI_POKE; + control.value = poke_reg.data; + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_SSBI_POKE, + control.value); + if(err >= 0) + { + print2("SSBIPoke Success\n value =%d",poke_reg.data); + return FM_CMD_SUCCESS; + } + + print2("SSBIPokeData ret = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmTxPwrLvlCfg + +DESCRIPTION + PFAL specific routine to configure the FM Tx power level + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmTxPwrLvlCfg +( + uint8 pwrlvl +) +{ + int err; + struct v4l2_control control; + control.value = pwrlvl; + control.id = V4L2_CID_TUNE_POWER_LEVEL; + err = ioctl(fd_radio, VIDIOC_S_CTRL, &control); + if (err >= 0) { + print2("Tx power level set to %d\n", pwrlvl); + return FM_CMD_SUCCESS; + } + print2("Set Tx power level failed = %d\n", err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmTxToneGen + +DESCRIPTION + PFAL specific routine to configure the FM Tx internal tone Generation + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + + +fm_cmd_status_type FmTxToneGen +( + uint8 txTone +) +{ + int err; + struct v4l2_control control; + control.value = txTone; + control.id = V4L2_CID_PRIVATE_IRIS_TX_TONE; + err = ioctl(fd_radio,VIDIOC_S_CTRL,&control); + if(err >= 0) + { + print("Set Tx internal tone Success\n"); + return FM_CMD_SUCCESS; + } + print2("Set Tx internal tone = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmRDSGrpcntrs + +DESCRIPTION + PFAL specific routine to get the FM RDS group conuters + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmRDSGrpcntrs +( + uint8 rdsCounters +) +{ + int err; + struct timespec* ts; + pthread_mutex_lock(&fm_event_lock); + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS, rdsCounters); + if (err >= 0) + { + print("Read RDS GROUP counters success\n"); + ts = set_time_out(2); + if(ts) + { + err = pthread_cond_timedwait(&fm_event_cond, &fm_event_lock, ts); + ALOGD("Unlocked mutex timedout or condition satisfied %s", __func__); + pthread_mutex_unlock(&fm_event_lock); + free(ts); + return FM_CMD_SUCCESS; + } + } + print2("Read RDS GROUP counters = %d\n",err); + pthread_mutex_unlock(&fm_event_lock); + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION FmRDSGrpcntrsExt + +DESCRIPTION + PFAL specific routine to get the FM RDS group conuters + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmRDSGrpcntrsExt +( + uint8 rdsCounters +) +{ + int err; + struct v4l2_control control; + control.value = rdsCounters; + control.id = V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS_EXT; + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS_EXT, rdsCounters); + if(err >= 0) + { + print("Read RDS GROUP counters extn success\n"); + return FM_CMD_SUCCESS; + } + print2("Read RDS GROUP counters extn = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION FmDefaultRead + +DESCRIPTION + PFAL specific routine to get the FM Default Values + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmDefaultRead +( + ftm_fm_def_data_rd_req defaultRead +) +{ + int err; + struct v4l2_control control; + struct v4l2_ext_controls v4l2_ctls; + struct v4l2_ext_control ext_ctl; + + ext_ctl.id = V4L2_CID_PRIVATE_IRIS_READ_DEFAULT; + ext_ctl.size = sizeof(ftm_fm_def_data_rd_req); + memcpy(ext_ctl.string,(char *)&defaultRead,ext_ctl.size); + + v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_USER; + v4l2_ctls.count = 1; + v4l2_ctls.controls = &ext_ctl; + + err = ioctl(fd_radio,VIDIOC_G_EXT_CTRLS,&v4l2_ctls); + if(err >= 0) + { + extract_default_read_data(); + print("Read Defaults success\n"); + return FM_CMD_SUCCESS; + } + print2("Read Defaults =%d \n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmDefaultWrite + +DESCRIPTION + PFAL specific routine to write the default values + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmDefaultWrite +( + ftm_fm_def_data_wr_req* writedefaults +) +{ + int ret = 0; + + struct v4l2_control control; + struct v4l2_ext_controls v4l2_ctls; + struct v4l2_ext_control ext_ctl; + + if(writedefaults == NULL) + { + print("\n 'writedefaults' is NULL \n "); + return FM_CMD_FAILURE; + } + ext_ctl.id = V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT; + ext_ctl.size = (writedefaults->length + 2); + ext_ctl.string = (char *)&writedefaults->mode; + + v4l2_ctls.ctrl_class = V4L2_CTRL_CLASS_USER; + v4l2_ctls.count = 1; + v4l2_ctls.controls = &ext_ctl; + + print("\n Entering Write defaults \n"); + + ret = ioctl(fd_radio, VIDIOC_S_EXT_CTRLS, &v4l2_ctls ); + if(ret < 0 ) + { + print("\n VIDIOC_S_EXT_CTRLS ioctl: Set Default failed \n"); + return FM_CMD_FAILURE; + } + + return FM_CMD_SUCCESS; + +} + +/*=========================================================================== +FUNCTION FmSetHlSi + +DESCRIPTION + PFAL specific routine to configure the FM receiver's HlSi + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmSetHlSi +( + uint8 hlsi +) +{ + int err = -1; + struct v4l2_control control; + control.value = hlsi; + control.id = V4L2_CID_PRIVATE_IRIS_HLSI; + err = vendor_interface->set_fm_ctrl( FTM_FM_SET_HLSI, hlsi); + print2("Setting HLSI to = %d",hlsi); + if(err >= 0) + { + print("Set HlSi success"); + return FM_CMD_SUCCESS; + } + print2("Set HlSi status = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION FmSetNotchFilter + +DESCRIPTION + PFAL specific routine to configure the FM receiver's notch filter + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type FmSetNotchFilter +( + uint8 notch +) +{ + int err = -1 ; + struct v4l2_control control; + control.value = notch; + control.id = V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER; + print2("Setting Notch filter to = %d",notch); + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER, notch); + if(err >= 0) + { + print("Set Notch filter success"); + return FM_CMD_SUCCESS; + } + print2("Set Notch filter status = %d\n",err); + return FM_CMD_FAILURE; +} +/*=========================================================================== +FUNCTION SetStereoModeReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's Audio mode on the + frequency tuned + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetStereoModeReceiver +( + stereo_type stereomode +) +{ + int err = -1; + err = vendor_interface->set_fm_ctrl(HCI_FM_HELIUM_AUDIO_MODE,stereomode); + ALOGD("Stereo mode =%d ... %s", stereomode,__func__); + if(err >= 0) { + print("SetStereoMode Success\n"); + return FM_CMD_SUCCESS; + } + print2("Set Stereo Mode status = %d\n",err); + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION GetStationParametersReceiver + +DESCRIPTION + PFAL specific routine to get the station parameters ofthe Frequency at + which the Radio receiver is tuned + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetStationParametersReceiver +( + fm_station_params_available* configparams +) +{ + int ret = 0, value = 0; + struct timespec* ts; + configparams->current_station_freq = fm_global_params.current_station_freq; + configparams->service_available = fm_global_params.service_available; + + pthread_mutex_lock(&fm_event_lock); + ret = vendor_interface->get_fm_ctrl(HCI_FM_HELIUM_RMSSI, &value); + if (ret < 0) { + print2("GetStationParametersReceiver:Failed to get Rssi error = %d\n",ret); + pthread_mutex_unlock(&fm_event_lock); + return FM_CMD_FAILURE; + } + ts = set_time_out(2); + if(ts) + { + ret = pthread_cond_timedwait(&fm_event_cond, &fm_event_lock, ts); + ALOGD("Unlocked mutex timedout or condition satisfied %s", __func__); + free(ts); + } + else + { + print("Cmd timeout failed .."); + pthread_mutex_unlock(&fm_event_lock); + return FM_CMD_FAILURE; + } + pthread_mutex_unlock(&fm_event_lock); + + ret = vendor_interface->get_fm_ctrl(HCI_FM_HELIUM_AUDIO_MUTE,&value); + if (ret < 0) { + print2("Failed to get mute status error = %d\n",ret); + return FM_CMD_FAILURE; + } + configparams->mute_status = value; + print2("GetStationParametersReceiver: Rssi = %d\n",fm_global_params.rssi); + configparams->rssi = fm_global_params.rssi; + configparams->stype = fm_global_params.stype; + configparams->rds_sync_status = fm_global_params.rds_sync_status; + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetRdsOptionsReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's RDS options + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetRdsOptionsReceiver +( + fm_rds_options rdsoptions +) +{ + int ret; + print("SetRdsOptionsReceiver\n"); + ALOGE("SetRdsOptionsReceiver\n"); + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK, + rdsoptions.rds_group_mask); + if(ret < FALSE) + { + print2("SetRdsOptionsReceiver Failed to set RDS group options = %d\n",ret); + return FM_CMD_FAILURE; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSD_BUF, + rdsoptions.rds_group_buffer_size); + if(ret < FALSE) + { + print2("SetRdsOptionsReceiver Failed to set RDS group options = %d\n",ret); + return FM_CMD_FAILURE; + } + + /*Chnage Filter not supported */ + print("SetRdsOptionsReceiver<\n"); + + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetRdsGroupProcReceiver + +DESCRIPTION + PFAL specific routine to configure the FM receiver's RDS group proc options + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetRdsGroupProcReceiver +( + uint32 rdsgroupoptions +) +{ + int ret; + print("SetRdsGroupProcReceiver\n"); + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC, + rdsgroupoptions); + if(ret < FALSE) + { + print2("SetRdsGroupProcReceiver Failed to set RDS proc = %d\n",ret); + return FM_CMD_FAILURE; + } + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_RDSON,1); + if(ret < FALSE) + { + print2(" Failed to set RDS proc ON = %d\n",ret); + return FM_CMD_FAILURE; + } + return FM_CMD_SUCCESS; +} + + +/*=========================================================================== +FUNCTION SetPowerModeReceiver + +DESCRIPTION + PFAL specific routine to configure the power mode of FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetPowerModeReceiver +( + uint8 powermode +) +{ + struct v4l2_control control; + int i,err; + print2("SetPowerModeReceiver mode = %d\n",powermode); + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_LP_MODE, powermode); + if (err < 0) + { + print("SetPowerMode Failed\n"); + return FM_CMD_FAILURE; + } + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SetSignalThresholdReceiver + +DESCRIPTION + PFAL specific routine to configure the signal threshold ofFM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSignalThresholdReceiver +( + uint8 signalthreshold +) +{ + struct v4l2_control control; + int i,err; + print2("SetSignalThresholdReceiver threshold = %d\n",signalthreshold); + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SIGNAL_TH,signalthreshold); + if(err >= 0) + { + print("SetSignalThresholdReceiver Success\n"); + return FM_CMD_SUCCESS; + } + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION GetSignalThresholdReceiver + +DESCRIPTION + PFAL specific routine to get the signal threshold of FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetSignalThresholdReceiver +( + uint8* signalthreshold +) +{ + int i,err,value=0; + + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SIGNAL_TH, &value); + if(err >= 0) + { + print2("GetSignalThresholdReceiver Success = %d\n",value); + *signalthreshold = value; + return FM_CMD_SUCCESS; + } + + return FM_CMD_FAILURE; +} + +/*=========================================================================== +FUNCTION GetRSSILimits + +DESCRIPTION + PFAL specific routine to print the RSSI limts ofFM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetRSSILimits +( +) +{ + int limits[] ={0,100}; + + return FM_CMD_SUCCESS; +} + + +/*=========================================================================== +FUNCTION GetPSInfoReceiver + +DESCRIPTION + PFAL specific routine to print the PS info ofcurrent frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetPSInfoReceiver +( +) +{ + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION GetRTInfoReceiver + +DESCRIPTION + PFAL specific routine to print the Radio text info ofcurrent frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetRTInfoReceiver +( +) +{ + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION GetAFInfoReceiver + +DESCRIPTION + PFAL specific routine to print the AF list for current frequency of + FM receiver + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type GetAFInfoReceiver +( +) +{ + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SearchStationsReceiver + +DESCRIPTION + PFAL specific routine to search for stations from the current frequency of + FM receiver and print the information on diag + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchStationsReceiver +( +fm_search_stations searchstationsoptions +) +{ + int err,i; + int ret; + print("SearchStationsReceiver\n"); + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SRCHMODE, + searchstationsoptions.search_mode); + if(ret < FALSE) + { + print("SearchStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SCANDWELL, + searchstationsoptions.dwell_period); + if(ret < FALSE) + { + print("SearchStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + if (searchstationsoptions.search_dir) + searchstationsoptions.search_dir = SRCH_DIR_UP; + else + searchstationsoptions.search_dir = SRCH_DIR_DOWN; + + err = vendor_interface->set_fm_ctrl(HCI_FM_HELIUM_SEEK,searchstationsoptions.search_dir); + if(err < 0) + { + print("SearchStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + print("SearchRdsStationsReceiver<\n"); + return FM_CMD_SUCCESS; +} + + +/*=========================================================================== +FUNCTION SearchRDSStationsReceiver + +DESCRIPTION + PFAL specific routine to search for stations from the current frequency of + FM receiver with a specific program type and print the information on diag + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchRdsStationsReceiver +( +fm_search_rds_stations searchrdsstationsoptions +) +{ + int i,err; + int ret; + + print("SearchRdsStationsReceiver>\n"); + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SRCHMODE, + searchrdsstationsoptions.search_mode); + if(ret < FALSE) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SCANDWELL, + searchrdsstationsoptions.dwell_period); + if(ret < FALSE) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SRCH_PTY, + searchrdsstationsoptions.program_type); + if(ret < FALSE) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SRCH_PI, + searchrdsstationsoptions.program_id); + if(ret set_fm_ctrl(HCI_FM_HELIUM_SEEK,searchrdsstationsoptions.search_dir); + if(err < 0) + { + print("SearchRdsStationsReceiver failed \n"); + return FM_CMD_FAILURE; + } + + print("SearchRdsStationsReceiver<\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION SearchStationListReceiver + +DESCRIPTION + PFAL specific routine to search for stations with a specific mode of + informaation like WEAK,STRONG,STRONGEST etc + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SearchStationListReceiver +( +fm_search_list_stations searchliststationsoptions +) +{ + int i,ret; + + print("SearchStationListReceiver>\n"); + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SRCHMODE, + searchliststationsoptions.search_mode); + if(ret < FALSE) + { + print("SearchStationListReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SRCH_CNT, + searchliststationsoptions.srch_list_max); + if(ret < FALSE) + { + print("SearchStationListReceiver failed \n"); + return FM_CMD_FAILURE; + } + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SRCH_PTY, + searchliststationsoptions.program_type); + if(ret set_fm_ctrl(HCI_FM_HELIUM_SEEK,searchliststationsoptions.search_dir); + if(ret < 0) + { + print("SearchStationListReceiver failed \n"); + return FM_CMD_FAILURE; + } + print("SearchStationListReceiver<\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION + +DESCRIPTION + PFAL specific routine to cancel the ongoing search operation + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type CancelSearchReceiver +( +) +{ + int ret; + + ret = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_TAVARUA_SRCHON,0); + if(ret < FALSE) + { + return FM_CMD_FAILURE; + } + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION GetSINRSamples + +DESCRIPTION + PFAL specific routine to get the FM receiver's SINR sample + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetSINRSamples +( + +) +{ + int err,value=0; + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRIVATE_SINR_SAMPLES,&value); + if( err < 0 ) + { + print("Failed to get the SINR samples"); + return FM_CMD_FAILURE; + } + else + { + fm_global_params.sinr_samples = value; + print2("Successfully get the SINR samples %d\n", value); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION SetSINRSamples + +DESCRIPTION + PFAL specific routine to set the FM receiver's SINR sample + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSINRSamples +( + uint8 sinr_sample +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_SINR_SAMPLES; + control.value = sinr_sample; + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_SINR_SAMPLES, sinr_sample); + if( err < 0 ) + { + print("Failed to set the SINR samples\n"); + return FM_CMD_FAILURE; + } + else + { + print2("Successfully set the SINR samples %d\n", sinr_sample); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION GetSINRThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's SINR Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetSINRThreshold +( + +) +{ + int err,value=0; + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRIVATE_SINR_THRESHOLD, + &value); + if( err < 0 ) + { + print("Failed to get the SINR threshold\n"); + return FM_CMD_FAILURE; + } + else + { + fm_global_params.sinr_threshold = value; + print2("Successfully get the SINR threshold %d\n", value); + return FM_CMD_SUCCESS; + } +} + + +/*=========================================================================== +FUNCTION SetSINRThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's SINR Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type SetSINRThreshold +( + char sinr_th +) +{ + int err,value; + value = (int)sinr_th; + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_SINR_THRESHOLD, + sinr_th); + if( err < 0 ) + { + print("Failed to set the SINR threshold\n"); + return FM_CMD_FAILURE; + } + else + { + print2("Successfully set the SINR threshold %d\n", sinr_th); + return FM_CMD_SUCCESS; + } +} + + +/*=========================================================================== +FUNCTION GetOnChannelThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's On channel Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetOnChannelThreshold +( + +) +{ + int err,value=0; + + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD, + &value); + if( err < 0 ) + { + print("Failed to get the On channel threshold \n"); + return FM_CMD_FAILURE; + } + else + { + fm_global_params.On_channel_threshold = value; + print2("Successfully get the On channel threshold %d\n",value); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION SetOnChannelThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's On channel Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type SetOnChannelThreshold +( + uint8 on_channel_th +) +{ + int err; + + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD, on_channel_th); + if( err < 0 ) + { + print("Failed to set the On channel threshold\n"); + return FM_CMD_FAILURE; + } + else + { + print2("Successfully set the On channel threshold %d\n", on_channel_th); + return FM_CMD_SUCCESS; + } +} +/*=========================================================================== +FUNCTION GetOffChannelThreshold + +DESCRIPTION + PFAL specific routine to get the FM receiver's Off channel Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type GetOffChannelThreshold +( + +) +{ + int err,value=0; + + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD, + &value); + if( err < 0 ) + { + print("Failed to get the Off channel threshold \n"); + return FM_CMD_FAILURE; + } + else + { + fm_global_params.Off_channel_threshold = value; + print2("Successfully get the Off channel threshold %d\n",value); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION SetOffChannelThreshold + +DESCRIPTION + PFAL specific routine to set the FM receiver's Off channel Threshold + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ + +fm_cmd_status_type SetOffChannelThreshold +( + uint8 off_channel_th +) +{ + int err; + struct v4l2_control control; + + control.id = V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD; + control.value = off_channel_th; + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD, + off_channel_th); + if( err < 0 ) + { + print("Failed to set the Off channel threshold\n"); + return FM_CMD_FAILURE; + } + else + { + print2("Successfully set the Off channel threshold %d\n", off_channel_th); + return FM_CMD_SUCCESS; + } +} + +/*=========================================================================== +FUNCTION get_fm_i2c_path + +DESCRIPTION + Helper function to get the path of i2c based on the board + +DEPENDENCIES + NIL + +RETURN VALUE + Path to the i2c device. NULL in case of failure. + +SIDE EFFECTS + None + +===========================================================================*/ + +/*=========================================================================== +FUNCTION FmBusWriteReceiver + +DESCRIPTION + PFAL specific routine to program the FM I2C bus + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmBusWriteReceiver +( +fm_i2c_params writeparams +) +{ + print("FmBusWriteReceiver <\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== +FUNCTION FmBusReadReceiver + +DESCRIPTION + PFAL specific routine to read the FM I2C bus + +DEPENDENCIES + NIL + +RETURN VALUE + FM command status + +SIDE EFFECTS + None + +===========================================================================*/ +fm_cmd_status_type FmBusReadReceiver +( +fm_i2c_params *readparams +) +{ + + print("FmBusReadReceiver <\n"); + return FM_CMD_SUCCESS; +} + +/*=========================================================================== + +FUNCTION ftm_fm_run_mm + +DESCRIPTION + This function is used to run mm-audio-ftm. + +DEPENDENCIES + none + +===========================================================================*/ +void ftm_fm_run_mm(void) { + pid_t pid; + int err = 1; + + printf("entered ftm_fm_run_mm\n"); + pid = fork(); + + if (!pid) { + err = execl(mm_audio_path, mm_audio_path, NULL); + printf("mm module error %d\n", err); + exit(0); + } else if (pid < 0) { + printf("could not create child process to execute mm audio module\n"); + } + return; +} + +/*=========================================================================== + +FUNCTION ftm_fm_audio + +DESCRIPTION + This function is used to load the target based config file and + set the audio output and volume. + +DEPENDENCIES + none + +===========================================================================*/ +fm_cmd_status_type ftm_fm_audio(uint8 source, uint8 volume) { + + char *cmd = NULL; + char vlm[4]; + FILE *sound_card_fp = NULL; + FILE *config_fp = NULL; + char sound_card_name[sound_card_len] = {0}; + char sound_card_info[sound_card_len] = {0}; + char config_path[sound_card_len] = {0}; + char *buffer; + char *config_file = NULL; + size_t len; + ssize_t ret; + int tmp; + fm_cmd_status_type status = FM_CMD_FAILURE; + + printf("Enter ftm_fm_audio\n"); + cmd = (char*) malloc(CMD_len * sizeof(char)); + if (!cmd) { + printf("memory allocation failed\n"); + goto failure; + } + memset(cmd, 0, CMD_len); + + if (strlcat(cmd, "-tc ", CMD_len) >= CMD_len) + goto failure; + + printf("string = %s \n",cmd); + printf("audio_output = %d\n", source); + + buffer = source ? "83 -v " : "74 -v "; + if (strlcat(cmd, buffer, CMD_len) >= CMD_len) + goto failure; + + printf("string = %s \n",cmd); + tmp = snprintf(vlm, sizeof(vlm), "%d", volume); + if (tmp < 0 || sizeof (vlm) <= (size_t)tmp) + goto failure; + if (strlcat(cmd, vlm, CMD_len) >= CMD_len) + goto failure; + + sound_card_fp = fopen("/proc/asound/cards", "r"); + if (!sound_card_fp) { + printf("failed to open sound card. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + + while (fgets(sound_card_info, sizeof(sound_card_info), sound_card_fp) != NULL) { + sscanf(sound_card_info, "%*s%*s%*s%*s%s", sound_card_name); + printf("soundCard Name = %s\n", sound_card_name); + snprintf(config_path, sizeof(config_path), "%s_%s",audio_config, + sound_card_name); + } + fclose(sound_card_fp); + + if (!(config_file = strchr(config_path, '/'))) { + memset(config_path, 0,sizeof(config_path)); + snprintf(config_path, sizeof(config_path), "%s", audio_config); + } else if ((config_fp = fopen(config_file, "r")) == NULL) { + printf("%s file doesn't exist.\n", config_file); + memset(config_path, 0,sizeof(config_path)); + snprintf(config_path, sizeof(config_path), "%s", audio_config); + } + + if (config_fp) + fclose (config_fp); + + printf("Use audio config file %s\n", config_path); + printf("string = %s \n",cmd); + + ftm_audio_fd = open("/data/vendor/misc/audio/ftm_commands", O_RDWR); + if (ftm_audio_fd < 0) { + printf("Failed to open ftm_commands with write. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + printf(" writing config path\n"); + buffer = config_path; + len = strlen(config_path) + 1; + + while (len > 0) { + ret = write(ftm_audio_fd, buffer, len); + if (ret < 0) { + printf("Failed to write config_file. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + len -= ret; + buffer += ret; + } + printf("done write config path\n"); + sleep(1); + printf("writing command for path = 0x%zx \n", strlen(cmd)); + len = strlen(cmd) + 1; + + buffer = cmd; + while (len > 0) { + ret = write(ftm_audio_fd, buffer, strlen(cmd) + 1); + if (ret < 0) { + printf("Failed to write cmd. err: %d (%s)\n", errno, + strerror(errno)); + goto failure; + } + len -= ret; + buffer += ret; + } + printf("done write command for path\n"); + status = FM_CMD_SUCCESS; + // fall through intentional +failure: + if (cmd) + free(cmd); + if (ftm_audio_fd > 0) { + close(ftm_audio_fd); + ftm_audio_fd = -1; + } + return status; +} + +void ftm_fm_enable_slimbus(int val) +{ + int err = 0; + struct timespec* ts; + + printf("++%s val %d\n", __func__, val); + + pthread_mutex_lock(&fm_event_lock); + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_ENABLE_SLIMBUS, val); + if (err < 0) + printf("set_fm_ctrl failed for V4L2_CID_PRV_ENABLE_SLIMBUS\n"); + else { + ts = set_time_out(1); + if(ts) { + err = pthread_cond_timedwait(&fm_event_cond, &fm_event_lock, ts); + ALOGD("%s: event received", __func__); + pthread_mutex_unlock(&fm_event_lock); + free(ts); + } + } + pthread_mutex_unlock(&fm_event_lock); + printf("--%s\n", __func__); +} diff --git a/feeds/wifi-ax/ftm/src/ftm_iot.c b/feeds/wifi-ax/ftm/src/ftm_iot.c new file mode 100755 index 000000000..7cbff7d91 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_iot.c @@ -0,0 +1,544 @@ +/* +*Copyright (c) 2018-2020 Qualcomm Technologies, Inc. +* +*All Rights Reserved. +*Confidential and Proprietary - Qualcomm Technologies, Inc. +*/ + +/* IPQ-QCA402X specific file */ + +#ifdef IPQ_AP_HOST_IOT + +#include +#include +#include +#include +#include +#include + +#include +#include +#include "comdef.h" +#include "diagcmd.h" +#include "ftm_wlan.h" +#include "ftm_dbg.h" +#include "ftm_iot.h" +#ifdef IPQ_AP_HOST_IOT_QCA402X +#include "diag_api.h" +#endif /* IPQ_AP_HOST_IOT_QCA402X */ +#ifdef IPQ_AP_HOST_IOT_IPQ50XX +#include "btdaemon.h" +#endif /* IPQ_AP_HOST_IOT_IPQ50XX */ + +#define NHDLC_TERM 126 +#define NHDLC_VERSION 1 +#define NHDLC_TERM_SIZE 1 +#define FLASH_CMD_ID_POS 1 +#define MAX_BUF_SIZE 2048 +#define WAIT_TIME_MS 100 +#define SUBSYS_CMD_ID_POS 2 +#define RESERVED_CMD_ID 0 +#define DUT_INTERFACE_SELECT 1 +#define DUT_INTERFACE_ID_POS 4 +#define DUT_INTERFACE_SELECT_POS 10 +#define DIAG_HDR_LEN (sizeof(diag_nonhdlc_hdr_t) + NHDLC_TERM_SIZE) +#define FTM_IOT_LOG_HEADER_SIZE sizeof(ftm_iot_log_pkt_type) + +/* Sempahore Timeout Period set for 2 seconds */ +#define SEM_WAIT_TIMEOUT 5 +#define MEMSET_RESET_VALUE 0 +#define DIAG_HEADER_SIZE 12 + +extern void diagpkt_free(void *pkt); + +void print_array(uint8_t *addr, int len) +{ + int i; + int line = 1; + for (i = 0; i < len; i++) { + if (i == (line * 80)) { + DPRINTF(FTM_DBG_TRACE, "\n"); + line++; + } + DPRINTF(FTM_DBG_TRACE, "%02X ", addr[i]); + } + DPRINTF(FTM_DBG_TRACE, "\n"); +} +#ifdef IPQ_AP_HOST_IOT_QCA402X +/*=========================================================================== + FUNCTION iot_thr_func_qca402x + + DESCRIPTION + Continously polls QCA402X for asynchronous data responses and + logs receievd asynchronous data responses to Diag module using + log-submit() + + DEPENDENCIES + NIL + + RETURN VALUE + Returns NULL on failure. Function also exits with NULL return value + when main indicates that this thread should be stopped + + SIDE EFFECTS + NONE + + ===========================================================================*/ +void *iot_thr_func_qca402x(void *hdl) +{ + int bytes = 0; + void *rsp2 = NULL; + int diag_hdr_len = DIAG_HDR_LEN ; + void *new_iot_ftm_rsp2_pkt = NULL; + + if (!hdl) { + DPRINTF(FTM_DBG_ERROR, "Invalid iotd handle\n"); + return NULL; + } + + new_iot_ftm_rsp2_pkt = malloc(MAX_BUF_SIZE); + if (!new_iot_ftm_rsp2_pkt) { + DPRINTF(FTM_DBG_ERROR, "Could not allocate response packet \n"); + return NULL; + } + + while(1) { + + if (thread_stop == 1) { + DPRINTF(FTM_DBG_TRACE, "FTMd: Exiting thread.\n"); + break; + } + + memset(new_iot_ftm_rsp2_pkt, MEMSET_RESET_VALUE, MAX_BUF_SIZE); + sem_wait(&iot_sem); + + /*If we recieve a response from QCA402X, allocate a buffer using diag alloc with correct + subsystem code and length */ + while ((bytes = diag_recv(hdl, (uint8_t *)new_iot_ftm_rsp2_pkt, + MAX_BUF_SIZE, + WAIT_TIME_MS)) >= 0) { + if (bytes > MAX_BUF_SIZE || bytes <= diag_hdr_len) { + DPRINTF(FTM_DBG_ERROR, "Could not allocate async log response packet\n"); + free (new_iot_ftm_rsp2_pkt); + return NULL; + } + + rsp2 = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, (bytes - diag_hdr_len)); + if (!rsp2) { + DPRINTF(FTM_DBG_ERROR, "Could not allocate async log response packet\n"); + free (new_iot_ftm_rsp2_pkt); + return NULL; + } + + /* Remove NHDLC header from recieved packet and store contents in + buffer allocated above */ + memcpy(rsp2, (new_iot_ftm_rsp2_pkt + diag_hdr_len - NHDLC_TERM_SIZE), + (bytes - diag_hdr_len)); + + DPRINTF(FTM_DBG_TRACE, "FTMd: Asynchronous Data response has been sent.\n"); + print_array((uint8_t *)rsp2, (bytes - diag_hdr_len) ); + + /*Remove an additional 4 bytes of header and log packet to diag module + asynchronously for further processing*/ + log_submit(rsp2 + diag_hdr_len - NHDLC_TERM_SIZE); + diagpkt_free (rsp2); + memset(new_iot_ftm_rsp2_pkt, MEMSET_RESET_VALUE, MAX_BUF_SIZE); + } + + sem_post(&iot_sem_async); + } + + free (new_iot_ftm_rsp2_pkt); + diagpkt_free (rsp2); + pthread_exit(NULL); +} + +/*=========================================================================== + FUNCTION ftm_iot_dispatch_qca402x + + DESCRIPTION + Function processes WIN IOT specific requests and relays to + QCA402x FTM layer for further processing. Recieves response + buffer from QCA402x and returns buffer meant for diag call back + + This function handles NHDLC to HDLC translation and vice-versa + before sending and receivng buffers to QCA402X FTM layer + + DEPENDENCIES + NIL + + RETURN VALUE + Returns back buffer that is meant for diag callback + + SIDE EFFECTS + NONE + + ===========================================================================*/ + +void *ftm_iot_dispatch_qca402x(void *iot_ftm_pkt, int pkt_len, void *hdl) +{ + int diag_hdr_len = DIAG_HDR_LEN; + int ret = 0; + byte *payload_ptr = NULL; + void *rsp1 = NULL; + ftm_iot_req_pkt_type *new_iot_ftm_pkt = NULL; + void *new_iot_ftm_rsp_pkt = NULL; + char command[50] = {'\0'}; + uint16_t *ftm_iot_flash_ptr = NULL; + uint16 ftm_iot_flash_cmd_code = 0; + /* The new packet length will be length of original request packet + + size of NHDLC header + 1 byte of termination character */ + int new_pkt_len = pkt_len + diag_hdr_len; + + if (!iot_ftm_pkt || !pkt_len || !hdl) { + DPRINTF(FTM_DBG_ERROR, "Invalid ftm iot request packet or iotd handle\n"); + return NULL; + } + + new_iot_ftm_pkt = malloc(sizeof(ftm_iot_req_pkt_type) + pkt_len + NHDLC_TERM_SIZE); + if (!new_iot_ftm_pkt) { + DPRINTF(FTM_DBG_ERROR, "Could not create new ftm iot request packet\n"); + return NULL; + } + memset(new_iot_ftm_pkt, MEMSET_RESET_VALUE, (sizeof(ftm_iot_req_pkt_type) + pkt_len + NHDLC_TERM_SIZE)); + + new_iot_ftm_rsp_pkt = malloc(MAX_BUF_SIZE); + if (!new_iot_ftm_rsp_pkt) { + DPRINTF(FTM_DBG_ERROR, "Could not create new ftm iot response packet\n"); + free (new_iot_ftm_pkt); + return NULL; + } + memset(new_iot_ftm_rsp_pkt, MEMSET_RESET_VALUE, MAX_BUF_SIZE); + + /* Add Non-HDLC header to request packet + and populate NHDLC header*/ + new_iot_ftm_pkt->hdr.start = NHDLC_TERM; + new_iot_ftm_pkt->hdr.version = NHDLC_VERSION; + new_iot_ftm_pkt->hdr.length = pkt_len; + memcpy(&(new_iot_ftm_pkt->payload), iot_ftm_pkt, pkt_len); + payload_ptr = (byte *) &(new_iot_ftm_pkt->payload); + *( payload_ptr + pkt_len) = NHDLC_TERM; + ftm_iot_cmd_code = *(payload_ptr + SUBSYS_CMD_ID_POS); + ftm_iot_dut_interface_code = *(payload_ptr + DUT_INTERFACE_ID_POS); + ftm_iot_reserved_code = *(payload_ptr + SUBSYS_CMD_ID_POS + 1); + ftm_iot_flash_ptr = (uint16_t *) &(new_iot_ftm_pkt->payload); + ftm_iot_flash_cmd_code = *(ftm_iot_flash_ptr + FLASH_CMD_ID_POS); + /*Print packet after adding headers */ + DPRINTF(FTM_DBG_TRACE, "FTMd: Request Packet of size %d bytes sent:\n", new_pkt_len); + print_array((uint8_t *)new_iot_ftm_pkt, new_pkt_len); + + /*If the request packet it a DUT interface selection command, + update interface number and return a response packet that + is an encho of the request packet. ( In the case of multiple + QCA402x DUT attaches on IPQ platforms) */ + if (((ftm_iot_cmd_code == MFG_CMD_ID_BLE_HCI) || (ftm_iot_cmd_code == MFG_CMD_ID_I15P4_HMI)) + && (ftm_iot_dut_interface_code == DUT_INTERFACE_SELECT) + && (ftm_iot_reserved_code == RESERVED_CMD_ID)){ + interface = *(payload_ptr + DUT_INTERFACE_SELECT_POS) - 1; + if (interface < 0) { + DPRINTF(FTM_DBG_ERROR, "Invalid DUT interface selection command\n"); + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + return NULL; + } + rsp1 = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, pkt_len); + if (!rsp1){ + DPRINTF(FTM_DBG_ERROR, "Could not allocate response packet for interface selection\n"); + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + return NULL; + } + + memcpy(rsp1, iot_ftm_pkt, pkt_len); + + DPRINTF(FTM_DBG_TRACE, "FTMd: The DUT interface selected is %d \n",interface); + DPRINTF(FTM_DBG_TRACE, "FTMd: DUT interface resp packet of size %d bytes sent:\n",pkt_len); + print_array((uint8_t *)rsp1, pkt_len); + + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + + /*This resp pointer will be freed by diag later*/ + return rsp1; + } + + /*If the request packet is a MFG PROG command, + launch flash script and return a response packet that indicates + flashing mode of QCA402x is enabled or disabled */ + if ((ftm_iot_flash_cmd_code == MFG_CMD_ID_MISC_PROG_MODE)){ + + if (ftm_iot_dut_interface_code == MFG_FLASH_ON){ + strlcpy(command, "/usr/bin/qca402x_flash.sh flash on", sizeof(command)); + } + + if (ftm_iot_dut_interface_code == MFG_FLASH_OFF){ + strlcpy(command, "/usr/bin/qca402x_flash.sh flash off", sizeof(command)); + } + + if (ftm_iot_dut_interface_code == MFG_USB_OFF){ + strlcpy(command, "/usr/bin/qca402x_flash.sh usb-select off", sizeof(command)); + } + + if (ftm_iot_dut_interface_code == MFG_USB_ON){ + strlcpy(command, "/usr/bin/qca402x_flash.sh usb-select on", sizeof(command)); + } + + if (ftm_iot_dut_interface_code == MFG_EDL_OFF){ + strlcpy(command, "/usr/bin/qca402x_flash.sh edl off", sizeof(command)); + } + + if (ftm_iot_dut_interface_code == MFG_EDL_ON){ + strlcpy(command, "/usr/bin/qca402x_flash.sh edl on", sizeof(command)); + } + + /*Return with NULL if string is empty or packet length is less than + 10 for a DUT interface selection command to make sure there will be + no out of bound access */ + if ( (command[0] == '\0') || (pkt_len <= DUT_INTERFACE_ID_POS) ) { + DPRINTF(FTM_DBG_ERROR, "Error: Invalid MFG Program command\n"); + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + return NULL; + } + + system(command); + DPRINTF(FTM_DBG_TRACE, "\n FTMd: Sent system command: %s \n", command); + + /* Check of size for packet pointed to by payload_ptr has been done above + using pkt_len to make sure there is no out of bound access */ + + *(payload_ptr + DUT_INTERFACE_ID_POS) = MFG_PROG_RESP; + + rsp1 = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, pkt_len); + if (!rsp1){ + DPRINTF(FTM_DBG_ERROR, "Could not allocate response packet for MFG flash commands\n"); + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + return NULL; + } + + memcpy(rsp1, payload_ptr, pkt_len); + + DPRINTF(FTM_DBG_TRACE, "FTMd: MFG Flash resp packet of size %d bytes sent:\n",pkt_len); + print_array((uint8_t *)rsp1, pkt_len); + + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + + /*This resp pointer will be freed by diag later*/ + return rsp1; + } + + sem_wait(&iot_sem_async); + /* Call IPQ-QCA402x diag APIs */ + ret = diag_send(hdl, interface, (uint8_t *)new_iot_ftm_pkt, new_pkt_len); + if ((ret < 0) || (ret > MAX_BUF_SIZE)) { + DPRINTF(FTM_DBG_ERROR, "Could not send the request packet to QCA402x \n"); + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + return NULL; + } + + ret = diag_recv(hdl, (uint8_t *)new_iot_ftm_rsp_pkt, MAX_BUF_SIZE, WAIT_TIME_MS); + if ((ret < 0) || (ret > MAX_BUF_SIZE) || (ret <= diag_hdr_len)) { + DPRINTF(FTM_DBG_ERROR, "Could not recieve packet from QCA402x\n"); + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + return NULL; + } + + DPRINTF(FTM_DBG_TRACE,"Received Command Response of %d bytes\n",ret); + print_array((uint8_t *)new_iot_ftm_rsp_pkt, ret); + + rsp1 = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, (ret - diag_hdr_len)); + if (!rsp1){ + DPRINTF(FTM_DBG_ERROR, "Could not allocate response packet\n"); + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + return NULL; + } + + memcpy(rsp1, (new_iot_ftm_rsp_pkt + diag_hdr_len - NHDLC_TERM_SIZE), (ret - diag_hdr_len)); + + free (new_iot_ftm_pkt); + free (new_iot_ftm_rsp_pkt); + sem_post(&iot_sem); + + /*This resp pointer will be freed by diag module later*/ + return (void *)rsp1; +} +#endif /* IPQ_AP_HOST_IOT_QCA402X */ + +#ifdef IPQ_AP_HOST_IOT_IPQ50XX +/*=========================================================================== + FUNCTION iot_thr_func_ipq50xx + + DESCRIPTION + Continously polls IPQ50XX BTSS for asynchronous data responses and + logs received asynchronous data responses to Diag module using + log-submit() + + DEPENDENCIES + NIL + + RETURN VALUE + Returns NULL on failure. Function also exits with NULL return value + when main indicates that this thread should be stopped + + SIDE EFFECTS + NONE + +===========================================================================*/ + +void *iot_thr_func_ipq50xx(void *hdl) +{ + int bytes_read = 0, handle = 0; + void *buffer = NULL; + void *rsp = NULL; + struct timespec ts; + ftm_bt_rsp_pkt_type *ftm_async_pkt; + + buffer = malloc(MAX_BUF_SIZE); + if (!buffer) + { + DPRINTF(FTM_DBG_ERROR, "Could not allocate memory to the buffer \n"); + return NULL; + } + + memset(buffer, MEMSET_RESET_VALUE, MAX_BUF_SIZE); + + if(hdl == NULL || *((int*)hdl) < 0) + { + DPRINTF(FTM_DBG_ERROR, "\n Invalid Handle received from BTSS \n"); + free(buffer); + return NULL; + } + + handle = *((int*)hdl); + while(1) + { + if (thread_stop == 1) { + DPRINTF(FTM_DBG_TRACE, "FTMd: Exiting thread.\n"); + break; + } + + if (clock_gettime(CLOCK_REALTIME, &ts) == -1) + { + DPRINTF(FTM_DBG_ERROR, "clock_gettime"); + free(buffer); + return NULL; + } + ts.tv_sec += SEM_WAIT_TIMEOUT; + sem_timedwait(&iot_sem, &ts); + while((bytes_read = bt_daemon_receive(handle, &buffer)) > 0) + { + rsp = log_alloc(LOG_BT_HCI_EV_C, (DIAG_HEADER_SIZE + bytes_read)); + if (!rsp) + { + DPRINTF(FTM_DBG_ERROR, "Could not allocate rsp packet \n"); + free(buffer); + return NULL; + } + + ftm_async_pkt = (ftm_bt_rsp_pkt_type*)rsp; + memcpy(ftm_async_pkt->buf, buffer, bytes_read); + DPRINTF(FTM_DBG_TRACE, "\n Printing the Async Packet sent to QDART\n"); + print_array((uint8_t *)rsp, (DIAG_HEADER_SIZE + bytes_read)); + + log_submit(rsp); + log_free(rsp); + memset(buffer, MEMSET_RESET_VALUE, MAX_BUF_SIZE); + } + sem_post(&iot_sem_async); + } + free(buffer); + pthread_exit(NULL); +} +/*=========================================================================== + FUNCTION ftm_iot_dispatch_ipq50xx + + DESCRIPTION + Function processes WIN IOT specific requests and relays to + IPQ50XX BTSS for further processing. Constructs response packet + and returns buffer meant for callback. + + DEPENDENCIES + NIL + + RETURN VALUE + Returns back buffer that is meant for diag callback + + SIDE EFFECTS + NONE + + ===========================================================================*/ + +void *ftm_iot_dispatch_ipq50xx(void *iot_ftm_pkt, int pkt_len, int *hdl) +{ + void *rsp = NULL; + struct timespec ts; + int bytes_sent = -1; + + if(hdl == NULL || *hdl < 0) + { + DPRINTF(FTM_DBG_ERROR, "\n Invalid Handle received from BTSS \n"); + return NULL; + } + + if (!iot_ftm_pkt) + { + DPRINTF(FTM_DBG_ERROR, "Invalid iot_ftm_pkt received \n"); + return NULL; + } + + if (clock_gettime(CLOCK_REALTIME, &ts) == -1) + { + perror("clock_gettime"); + return NULL; + } + ts.tv_sec += SEM_WAIT_TIMEOUT; + sem_timedwait(&iot_sem_async, &ts); + + DPRINTF(FTM_DBG_TRACE, "\n Request Packet received for IPQ50xx BTSS\n"); + print_array((uint8_t *)iot_ftm_pkt, pkt_len); + + bytes_sent = bt_daemon_send(*hdl, iot_ftm_pkt); + if(bytes_sent < 0) + { + perror("Unable to send Request Packet to IPQ50xx BTSS"); + return NULL; + } + + /* Constructing ACK Packet */ + rsp = diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, ftm_iot_cmd_code, pkt_len); + if (!rsp) + { + DPRINTF(FTM_DBG_ERROR, "\n Unable to allocate diag response packet \n"); + return NULL; + } + + memcpy(rsp, iot_ftm_pkt, pkt_len); + + DPRINTF(FTM_DBG_TRACE, "\n ACK Packet constructed in FTM layer\n"); + print_array((uint8_t *)rsp, pkt_len); + + sem_post(&iot_sem); + + /*This rsp pointer will be freed by diag later */ + return rsp; +} +#endif /* IPQ_AP_HOST_IOT_IPQ50XX */ + +void *ftm_iot_dispatch(void *iot_ftm_pkt, int pkt_len, void *hdl) +{ + void* retValue = NULL; +#ifdef IPQ_AP_HOST_IOT_QCA402X + retValue = ftm_iot_dispatch_qca402x(iot_ftm_pkt, pkt_len ,hdl); +#endif +#ifdef IPQ_AP_HOST_IOT_IPQ50XX + retValue = ftm_iot_dispatch_ipq50xx(iot_ftm_pkt, pkt_len ,(int *)hdl); +#endif + return retValue; +} + +#endif /*ifdef IPQ_AP_HOST_IOT*/ diff --git a/feeds/wifi-ax/ftm/src/ftm_iot.h b/feeds/wifi-ax/ftm/src/ftm_iot.h new file mode 100755 index 000000000..435a701fb --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_iot.h @@ -0,0 +1,131 @@ +/* + *Copyright (c) 2018-2020 Qualcomm Technologies, Inc. + * + *All Rights Reserved. + *Confidential and Proprietary - Qualcomm Technologies, Inc. + */ + +/* IPQ-QCA402X specific file */ +#ifdef IPQ_AP_HOST_IOT + +#include +#include +#include "diagpkt.h" +#include "log.h" + +#define MFG_CMD_ID_BLE_HCI 4 +#define MFG_CMD_ID_I15P4_HMI 5 +#define MFG_CMD_ID_OTP_INVALID 256 +#define MFG_CMD_ID_OTP_SET_BITS 257 +#define MFG_CMD_ID_OTP_WRITE_BYTE 258 +#define MFG_CMD_ID_OTP_READ_BYTE 259 +#define MFG_CMD_ID_OTP_TLV_INIT 260 +#define MFG_CMD_ID_OTP_TLV_READ 261 +#define MFG_CMD_ID_OTP_TLV_WRITE 262 +#define MFG_CMD_ID_OTP_TLV_STATUS 263 +#define MFG_CMD_ID_OTP_TLV_DELETE 264 + +#define MFG_CMD_ID_RAWFLASH_INVALID 288 +#define MFG_CMD_ID_RAWFLASH_CLEAR_BITS 289 +#define MFG_CMD_ID_RAWFLASH_WRITE 290 +#define MFG_CMD_ID_RAWFLASH_READ 291 +#define MFG_CMD_ID_RAWFLASH_ERASE 292 +#define MFG_CMD_ID_RAWFLASH_DISABLE_MFG 293 + +#define MFG_CMD_ID_FS_INVALID 304 +#define MFG_CMD_ID_FS_READ 305 +#define MFG_CMD_ID_FS_WRITE 306 +#define MFG_CMD_ID_FS_DELETE 307 +#define MFG_CMD_ID_FS_LIST_SETUP 308 +#define MFG_CMD_ID_FS_LIST_NEXT 309 +#define MFG_CMD_ID_FS_MOUNT 310 +#define MFG_CMD_ID_FS_UNMOUNT 311 + +/* Add more MFG tool commands for QCA402x. These +command are interpreted internally within QCA402x */ +#define MFG_CMD_ID_MISC_REBOOT 352 +#define MFG_CMD_ID_MISC_ADDR_READ 353 +#define MFG_CMD_ID_MISC_ADDR_WRITE 354 +#define MFG_CMD_ID_MISC_HWSS_DONE 355 +#define MFG_CMD_ID_MISC_XTAL_CAP_SET 356 +#define MFG_CMD_ID_MISC_PART_SZ_GET 357 + +/* Add MFG tool command to enable flashing of QCA402x +by putting QCA402x in EDL mode and selecting USB mux +select option to tie USB port 81 on IPQ402x to QCA402x */ +#define MFG_CMD_ID_MISC_PROG_MODE 358 + +/*Command to invalidate specified QCA402x Imageset */ +#define MFG_CMD_ID_MISC_FWUP 359 +/* Add MFG tool PROG_MODE subcommands to enable flashing +of QCA402x on IPQ807x. Interpretation of sub-commands is as +follows: + +MFG_FLASH_ON - Put QCA402x into reset state, Put QCA402x in +EDL mode and enable USB port to be tied to QCA402x + +MFG_FLASH_OFF - Pull QCA402x out of EDL mode and Pull QCA402x +out of reset + +MFG_EDL_ON - Put QCA402x in EDL mode + +MFG_FLASH_OFF - Pull QCA402x out of EDL mode + +MFG_USB_ON - Enable USB port to be tied to QCA402x + +MFG_USB_OFF - Enable USB port to be tied to IPQ807x + +MFG_PROG_RESP - Expected response field +*/ + +enum flash_state { + MFG_PROG_RESP, + MFG_FLASH_ON, + MFG_FLASH_OFF, + MFG_EDL_ON, + MFG_EDL_OFF, + MFG_USB_ON, + MFG_USB_OFF +}; + +typedef struct +{ + uint8 start; + uint8 version; + uint16 length; +} PACKED_STRUCT diag_nonhdlc_hdr_t; + +typedef struct +{ + diag_nonhdlc_hdr_t hdr; + byte payload[0]; +} PACKED_STRUCT ftm_iot_req_pkt_type; + +typedef struct +{ + log_hdr_type hdr; + byte buf[1]; +} PACKED_STRUCT ftm_bt_rsp_pkt_type; + +/* Two semaphores are used to handle sequencing of requests, ack responses +and multiple asynchronous data responses from QCA402x */ + +sem_t iot_sem; +sem_t iot_sem_async; + +int ftm_iot_cmd_code; +int ftm_iot_dut_interface_code; +int ftm_iot_reserved_code; +int interface; +int thread_stop; + +void *ftm_iot_dispatch(void *iot_ftm_pkt, int pkt_len, void *hdl); +#ifdef IPQ_AP_HOST_IOT_QCA402X +void *ftm_iot_dispatch_qca402x(void *iot_ftm_pkt, int pkt_len, void *hdl); +void *iot_thr_func_qca402x(void *hdl); +#endif +#ifdef IPQ_AP_HOST_IOT_IPQ50XX +void *ftm_iot_dispatch_ipq50xx(void *iot_ftm_pkt, int pkt_len, int *hdl); +void *iot_thr_func_ipq50xx(void *hdl); +#endif +#endif /*ifdef IPQ_AP_HOST_IOT*/ diff --git a/feeds/wifi-ax/ftm/src/ftm_main.c b/feeds/wifi-ax/ftm/src/ftm_main.c new file mode 100755 index 000000000..1a487ebc8 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_main.c @@ -0,0 +1,1033 @@ +/* Copyright (c) 2010-2020 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. +*/ + +/*========================================================================== + + FTM Main Task Source File + +Description + Unit test component file for regsitering the routines to Diag library + for BT and FTM commands + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/18/10 rakeshk Created a source file to implement routines for + registering the callback routines for FM and BT FTM + packets +07/06/10 rakeshk changed the name of FM common header file in inclusion +07/07/10 rakeshk Removed the sleep and wake in the main thread loop +===========================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef WIN_AP_HOST +#include +#endif +#include +#include +#ifndef WIN_AP_HOST +#include +#endif +#ifndef ANDROID +#include +#include +#endif +#ifndef WIN_AP_HOST +#include "hidl_client.h" +#endif +/* Diag related header files */ +#include "event.h" +#include "msg.h" +#include "log.h" +#include "diag_lsm.h" +#include "diagpkt.h" +#include "diagcmd.h" +#include "diag.h" + +#ifdef WIN_AP_HOST_OPEN +#include "signal.h" +#include "libtcmd.h" +#endif +#include "ftm_dbg.h" +#include "ftm_wlan.h" +#include "ftm_common.h" +#include "ftm_ant_common.h" +#ifndef WIN_AP_HOST +#ifdef CONFIG_FTM_BT +#include "ftm_bt_hci_pfal.h" +#endif +#ifdef CONFIG_FTM_FM +#include "ftm_fm_pfal.h" +#endif + +#include "ftm_nfc.h" +#endif +#ifdef USE_GLIB +#include +#define strlcat g_strlcat +#define strlcpy g_strlcpy +#endif + +#ifdef IPQ_AP_HOST_IOT +#include +#include "ftm_iot.h" +#ifdef IPQ_AP_HOST_IOT_QCA402X +#include "diag_api.h" +#endif /* Including IPQ-QCA402x specific headerfiles */ +#endif + +extern void hidl_client_close(); +int boardtype = 8660; +int first_ant_command; + +int fm_passthrough = 0; +int sibs_enabled = 0; +static char *progname = NULL; + +unsigned int g_dbg_level = FTM_DBG_DEFAULT; + +#define SHOW_PRIO 1 +#define SHOW_TIME 2 +#define SHOW_POLICY 4 +#define SHOW_CPU 8 +#define SHOW_MACLABEL 16 +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) + +#ifndef WIN_AP_HOST +#ifndef ANDROID +#define SOCKETNAME "/etc/bluetooth/btprop" +static int sk; +#endif +#endif + +#ifdef CONFIG_FTM_BT +/* Semaphore to monitor the completion of +* the queued command before sending down the +* next HCI cmd +*/ +sem_t semaphore_cmd_complete; +/* Semaphore to monitor whether a command +* is queued before proceeding to dequeue +* the HCI packet +*/ +sem_t semaphore_cmd_queued; + +typedef enum { + BT_SOC_DEFAULT = 0, + BT_SOC_SMD = BT_SOC_DEFAULT, + BT_SOC_AR3K, + BT_SOC_ROME, + BT_SOC_CHEROKEE, + BT_SOC_NAPIER, + /* Add chipset type here */ + BT_SOC_RESERVED +} bt_soc_type; + +int soc_type; + +/* Diag pkt table for BT */ +static const diagpkt_user_table_entry_type bt_ftm_diag_func_table[] = +{ + {FTM_BT_CMD_CODE, FTM_BT_CMD_CODE, bt_ftm_diag_dispatch}, +}; +#endif /* CONFIG_FTM_BT */ + +#ifdef DEBUG +void current_time() +{ + + struct timeval curTime; + time_t now; + int milli, usec; + struct tm timeinfo; + char buffer[80]; + char currentTime[84] = ""; + gettimeofday(&curTime, NULL); + now = curTime.tv_sec; + milli = curTime.tv_usec / 1000; + usec = curTime.tv_usec; + localtime_r(&now, &timeinfo); + strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &timeinfo); + snprintf(currentTime, sizeof(currentTime), "%s:%03d:%06d", buffer, milli, usec); + DPRINTF(FTM_DBG_TRACE, "Time:%s\n", currentTime); + +} +#endif /* DEBUG */ + + + +#ifdef CONFIG_FTM_FM +/* Callback declaration for BT FTM packet processing */ +void *fm_ftm_diag_dispatch (void *req_pkt, uint16 pkt_len); + +/* Diag pkt table for FM */ +static const diagpkt_user_table_entry_type fm_ftm_diag_func_table[] = +{ + {FTM_FM_CMD_CODE, FTM_FM_CMD_CODE, fm_ftm_diag_dispatch}, +}; +#endif /* CONFIG_FTM_FM */ + +#ifdef CONFIG_FTM_ANT +/* Callback declaration for ANT FTM packet processing */ +void *ant_ftm_diag_dispatch(void *req_pkt, uint16 pkt_len); + +/*Diag pkt table for ANT */ +static const diagpkt_user_table_entry_type ant_ftm_diag_func_table[] = +{ + {FTM_ANT_CMD_CODE, FTM_ANT_CMD_CODE, ant_ftm_diag_dispatch} +}; +#endif /* CONFIG_FTM_ANT */ + +#ifdef CONFIG_FTM_WLAN +/* Callback declaration for WLAN FTM packet processing */ +void * wlan_ftm_diag_dispatch (void *req_pkt, + uint16 pkt_len); + +/* Diag pkt table for WLAN */ +static const diagpkt_user_table_entry_type wlan_ftm_diag_func_table[] = +{ + {FTM_WLAN_CMD_CODE, FTM_WLAN_CMD_CODE, wlan_ftm_diag_dispatch} +}; +#endif + +#ifdef IPQ_AP_HOST_IOT +/*IPQ-QCA402x specific diag API handler*/ +void *iotd_desc; +#ifdef IPQ_AP_HOST_IOT_IPQ50XX +int btss_desc; +extern int btss_init(); +extern void btss_deinit(); +#endif /* IPQ_AP_HOST_IOT_IPQ50XX */ +/* Callback declaration for IPQ-QCA402x FTM packet processing */ +void *iot_ftm_diag_dispatch (void *req_pkt, + uint16 pkt_len); + + + /* Diag pkt table for IPQ-QCA402X */ + static const diagpkt_user_table_entry_type iot_ftm_diag_func_table[] = + { + {MFG_CMD_ID_BLE_HCI, MFG_CMD_ID_BLE_HCI, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_I15P4_HMI, MFG_CMD_ID_I15P4_HMI, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_WRITE_BYTE, MFG_CMD_ID_OTP_WRITE_BYTE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_READ_BYTE, MFG_CMD_ID_OTP_READ_BYTE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_INVALID, MFG_CMD_ID_OTP_INVALID, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_SET_BITS, MFG_CMD_ID_OTP_SET_BITS, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_TLV_INIT, MFG_CMD_ID_OTP_TLV_INIT, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_TLV_READ, MFG_CMD_ID_OTP_TLV_READ, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_TLV_WRITE, MFG_CMD_ID_OTP_TLV_WRITE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_TLV_STATUS, MFG_CMD_ID_OTP_TLV_STATUS, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_OTP_TLV_DELETE, MFG_CMD_ID_OTP_TLV_DELETE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_FS_INVALID, MFG_CMD_ID_FS_INVALID, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_FS_READ, MFG_CMD_ID_FS_READ, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_FS_WRITE, MFG_CMD_ID_FS_WRITE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_FS_DELETE, MFG_CMD_ID_FS_DELETE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_FS_LIST_SETUP, MFG_CMD_ID_FS_LIST_SETUP, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_FS_LIST_NEXT, MFG_CMD_ID_FS_LIST_NEXT, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_FS_MOUNT, MFG_CMD_ID_FS_MOUNT, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_FS_UNMOUNT, MFG_CMD_ID_FS_UNMOUNT, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_MISC_REBOOT, MFG_CMD_ID_MISC_REBOOT, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_MISC_ADDR_READ, MFG_CMD_ID_MISC_ADDR_READ, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_MISC_ADDR_WRITE, MFG_CMD_ID_MISC_ADDR_WRITE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_MISC_HWSS_DONE, MFG_CMD_ID_MISC_HWSS_DONE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_MISC_XTAL_CAP_SET, MFG_CMD_ID_MISC_XTAL_CAP_SET, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_MISC_PART_SZ_GET, MFG_CMD_ID_MISC_PART_SZ_GET, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_MISC_PROG_MODE, MFG_CMD_ID_MISC_PROG_MODE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_MISC_FWUP, MFG_CMD_ID_MISC_FWUP, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_RAWFLASH_INVALID, MFG_CMD_ID_RAWFLASH_INVALID, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_RAWFLASH_CLEAR_BITS, MFG_CMD_ID_RAWFLASH_CLEAR_BITS, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_RAWFLASH_READ, MFG_CMD_ID_RAWFLASH_READ, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_RAWFLASH_WRITE, MFG_CMD_ID_RAWFLASH_WRITE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_RAWFLASH_ERASE, MFG_CMD_ID_RAWFLASH_ERASE, iot_ftm_diag_dispatch}, + {MFG_CMD_ID_RAWFLASH_DISABLE_MFG, MFG_CMD_ID_RAWFLASH_DISABLE_MFG, iot_ftm_diag_dispatch}, + }; + +#endif /*ifdef IPQ_AP_HOST_IOT*/ + +#ifdef CONFIG_FTM_NFC +/* Callback declaration for NFC FTM packet processing */ +void *nfc_ftm_diag_dispatch (void *req_pkt, uint16 pkt_len); + +/*Diag pkt table for NFC */ +static const diagpkt_user_table_entry_type nfc_ftm_diag_func_table[] = +{ + {FTM_NFC_CMD_CODE, FTM_NFC_CMD_CODE, nfc_ftm_diag_dispatch} +}; +#endif /* CONFIG_FTM_NFC */ +#ifdef WIN_AP_HOST_OPEN +static void signal_handler(int32_t signum) +{ + printf("FTM Daemon Exit called signal %d\n", signum ); + tcmd_tx_stop(); + exit(0); +} +#endif + +#ifdef CONFIG_FTM_BT +#ifndef WIN_AP_HOST +#ifndef ANDROID +/* set up Socket connection to btproperty */ +int prop_get(const char *key, char *value, const char *default_value) +{ + char prop_string[200]; + int ret, bytes_read = 0, i = 0; + sprintf(prop_string, "get_property %s,", key); + ret = send(sk, prop_string, strlen(prop_string), 0); + memset(value, 0, sizeof(value)); + do + { + bytes_read = recv(sk, &value[i], 1, 0); + if (bytes_read == 1) + { + if (value[i] == ',') + { + value[i] = '\0'; + break; + } + i++; + } + } while(1); + ALOGI("property_get_bt: key(%s) has value: %s", key, value); + if (bytes_read) { + return 0; + } else { + strncpy(value, default_value, strlen(default_value)); + return 1; + } +} + +int prop_set(const char *key, const char *value) +{ + char prop_string[200]; + int ret; + sprintf(prop_string, "set_property %s %s,", key, value); + ALOGI("property_set_bt: setting key(%s) to value: %s\n", key, value); + ret = send(sk, prop_string, strlen(prop_string), 0); + return 0; +} + +int bt_property_init(void) +{ + int len; /* length of sockaddr */ + struct sockaddr_un name; + if( (sk = socket(AF_UNIX, SOCK_STREAM, 0) ) < 0) { + perror("socket"); + exit(1); + } + /*Create the address of the server.*/ + memset(&name, 0, sizeof(struct sockaddr_un)); + name.sun_family = AF_UNIX; + strlcpy(name.sun_path, SOCKETNAME, sizeof(name.sun_path)); + ALOGI("connecting to %s, fd = %d", SOCKETNAME, sk); + len = sizeof(name.sun_family) + strlen(name.sun_path); + /*Connect to the server.*/ + if (connect(sk, (struct sockaddr *) &name, len) < 0){ + perror("connect"); + exit(1); + } +#if (BT_SOC_TYPE_ROME || BT_SOC_TYPE_CHEROKEE) + prop_set("qcom.bluetooth.soc", "rome"); +#else + prop_set("qcom.bluetooth.soc", "pronto"); +#endif +} +#endif + +/* Get Bluetooth SoC type from system setting */ +static int get_bt_soc_type(void) +{ + int ret = 0; + char bt_soc_type[PROPERTY_VALUE_MAX]; + + ALOGI("bt-hci: get_bt_soc_type"); +#ifdef ANDROID + ret = property_get("qcom.bluetooth.soc", bt_soc_type, NULL); + if (ret != 0) { +#else + ret = prop_get("qcom.bluetooth.soc", bt_soc_type, NULL); + if (ret == 0) { +#endif + ALOGI("qcom.bluetooth.soc set to %s\n", bt_soc_type); + if (!strncasecmp(bt_soc_type, "rome", sizeof("rome"))) { + return BT_SOC_ROME; + } + else if (!strncasecmp(bt_soc_type, "cherokee", sizeof("cherokee"))) { + return BT_SOC_CHEROKEE; + } + else if (!strncasecmp(bt_soc_type, "pronto", sizeof("pronto"))) { + return BT_SOC_DEFAULT; + } + else if (!strncasecmp(bt_soc_type, "ath3k", sizeof("ath3k"))) { + return BT_SOC_AR3K; + } + else if(!strncasecmp(bt_soc_type, "napier", sizeof("napier"))) { + return BT_SOC_NAPIER; + } + else { + ALOGI("qcom.bluetooth.soc not set, so using default.\n"); + return BT_SOC_DEFAULT; + } + } + else { + ALOGE("%s: Failed to get soc type", __FUNCTION__); + ret = BT_SOC_DEFAULT; + } + + return ret; +} +#endif //ifndef WIN_AP_HOST +#endif //ifdef CONFIG_FTM_BT + +/*=========================================================================== +FUNCTION ioctl_write + +DESCRIPTION + Helper function to package the ioctl messages and send it to the I2C driver + +DEPENDENCIES + NIL + +RETURN VALUE + -1 in failure,positive or zero in success + +SIDE EFFECTS + None + +===========================================================================*/ + +static int ioctl_readwrite(int fd, struct i2c_msg *msgs, int nmsgs) +{ + struct i2c_rdwr_ioctl_data msgset = + { + .msgs = msgs, + .nmsgs = nmsgs, + }; + + if ((fd < 0) || (NULL == msgs) || (nmsgs <= 0)) + { + return -1; + } + + if (ioctl(fd, I2C_RDWR, &msgset) < 0) + { + return -1; + } + return 0; +} +/*=========================================================================== +FUNCTION i2c_write + +DESCRIPTION + Helper function to construct the I@C request to be sent to the FM I2C + driver + +DEPENDENCIES + NIL + +RETURN VALUE + -1 in failure,positive or zero in success + +SIDE EFFECTS + None + +===========================================================================*/ +int i2c_write +( +int fd, +unsigned char offset, +const unsigned char* buf, +unsigned char len, +unsigned int slave_addr +) +{ + unsigned char offset_data[((1 + len) * sizeof(unsigned char))]; + struct i2c_msg msgs[] = + { + [0] = { + .addr = slave_addr, + .flags = 0, + .buf = (void *)offset_data, + .len = (1 + len) * sizeof(*offset_data), + }, + }; + + offset_data[0] = offset; + memcpy(offset_data + 1, buf, len); + + return ioctl_readwrite(fd, msgs, ARRAY_SIZE(msgs)); +} + +/*=========================================================================== +FUNCTION i2c_read + +DESCRIPTION + Helper function to construct the I2C request to read data from the FM I2C + driver + +DEPENDENCIES + NIL + +RETURN VALUE + -1 in failure,positive or zero in success + +SIDE EFFECTS + None + +===========================================================================*/ +int i2c_read +( +int fd, +unsigned char offset, +const unsigned char* buf, +unsigned char len, +unsigned int slave_addr +) +{ + unsigned char offset_data[] = {offset}; + struct i2c_msg msgs[] = + { + [0] = { + .addr = slave_addr, + .flags = 0, + .buf = (void *)offset_data, + .len = sizeof(*offset_data), + }, + [1] = { + .addr = slave_addr, + .flags = I2C_M_RD, + .buf = (void *)buf, + .len = len, + }, + }; + + return ioctl_readwrite(fd, msgs, ARRAY_SIZE(msgs)); +} + +#ifdef CONFIG_FTM_FM +/*========================================================================= +FUNCTION fm_ftm_diag_dispatch + +DESCRIPTION + Processes the request packet and sends it to the FTM FM layer for further + processing + +DEPENDENCIES + NIL + +RETURN VALUE + pointer to FTM FM Response packet + +SIDE EFFECTS + None + +===========================================================================*/ +void *fm_ftm_diag_dispatch +( + void *req_pkt, + uint16 pkt_len +) +{ + void *rsp = NULL; + + DPRINTF(FTM_DBG_TRACE, "FM I2C Send Response = %d\n",pkt_len); + + // Allocate the same length as the request. + rsp = ftm_fm_dispatch(req_pkt,pkt_len); + return rsp; +} +#endif /* CONFIG_FTM_FM */ + +#ifdef CONFIG_FTM_ANT +/*=========================================================================== +FUNCTION ant_ftm_diag_dispatch + +DESCRIPTION + Processes the request packet and sends it to the FTM ANT layer for further + processing +DEPENDENCIES + NIL + +RETURN VALUE + pointer to FTM ANT Response packet + +SIDE EFFECTS + None + +===========================================================================*/ +void *ant_ftm_diag_dispatch +( + void *req_pkt, + uint16 pkt_len +) +{ + void *rsp = NULL; + + DPRINTF(FTM_DBG_TRACE, "ANT diag dispatch send response = %d\n", pkt_len); + +// Allocate the same length as the request. + rsp = ftm_ant_dispatch(req_pkt,pkt_len); + return rsp; +} +#endif /* CONFIG_FTM_ANT */ + +#ifdef CONFIG_FTM_BT +/*=========================================================================== +FUNCTION bt_ftm_diag_dispatch + +DESCRIPTION + Processes the request packet and sends it to the FTM BT layer for further + processing + +DEPENDENCIES + NIL + +RETURN VALUE + pointer to FTM BT Response packet + +SIDE EFFECTS + None + +===========================================================================*/ +void *bt_ftm_diag_dispatch +( + void *req_pkt, + uint16 pkt_len +) +{ + void *rsp = NULL; + boolean status = TRUE; + + DPRINTF(FTM_DBG_TRACE, "Send Response = %d\n",pkt_len); + + // Allocate the same length as the request. + rsp = diagpkt_subsys_alloc (DIAG_SUBSYS_FTM, FTM_BT_CMD_CODE, pkt_len); + + if (rsp != NULL) + { + memcpy ((void *) rsp, (void *) req_pkt, pkt_len); + } + /* Spurious incoming request packets are occasionally received + * by DIAG_SUBSYS_FTM which needs to be ignored and accordingly responded. + * TODO: Reason for these spurious incoming request packets is yet to be + * found, though its always found to be corresponding to this majic + * length of 65532. + */ + if (pkt_len == 65532) + { + printf("\nIgnore spurious DIAG packet processing & respond immediately"); + } + else + { + + DPRINTF(FTM_DBG_TRACE, "Insert BT packet = %d\n", pkt_len); + + /* add the BT packet into the Cmd Queue + * and notify the main thread its queued + */ + status = qinsert_cmd((ftm_bt_pkt_type *)req_pkt); + if(status == TRUE) + sem_post(&semaphore_cmd_queued); + + DPRINTF(FTM_DBG_TRACE, "Insert BT packet done\n"); + + } + return (rsp); +} +#endif /* CONFIG_FTM_BT */ + +#ifdef CONFIG_FTM_WLAN +/*=========================================================================== +FUNCTION wlan_ftm_diag_dispatch + +DESCRIPTION + Processes the request packet and sends it to the FTM WLAN layer for further + processing + +DEPENDENCIES + NIL + +RETURN VALUE + pointer to FTM WLAN Response packet + +SIDE EFFECTS + None + +===========================================================================*/ + +void * wlan_ftm_diag_dispatch +( + void *req_pkt, + uint16 pkt_len +) +{ + void *rsp = NULL; + + DPRINTF(FTM_DBG_TRACE, "WLAN Send Response = %d\n", pkt_len); + + rsp = ftm_wlan_dispatch(req_pkt, pkt_len); + + return rsp; +} +#endif /* CONFIG_FTM_WLAN */ + +#ifdef IPQ_AP_HOST_IOT + +void *iot_ftm_diag_dispatch +( + void *req_pkt, + uint16 pkt_len +) +{ + void *rsp = NULL; + rsp = ftm_iot_dispatch(req_pkt, pkt_len ,iotd_desc); + return rsp; +} + +#endif /*IPQ_AP_HOST_IOT*/ + +#ifdef CONFIG_FTM_NFC +/*=========================================================================== +FUNCTION nfcs_ftm_diag_dispatch + +DESCRIPTION + Processes the request packet and sends it to the FTM NFC layer for further + processing +DEPENDENCIES + NIL + +RETURN VALUE + + +SIDE EFFECTS + + +===========================================================================*/ +void *nfc_ftm_diag_dispatch +( + void *req_pkt, + uint16 pkt_len +) +{ + void *rsp = NULL; + boolean status = TRUE; + + DPRINTF(FTM_DBG_TRACE, " NFC Send Response = %d\n",pkt_len); + + /*now send the incoming nfc diag command packet to the nfc ftm layer to + get it processed*/ + rsp = ftm_nfc_dispatch(req_pkt, pkt_len); + + /* send same response as recieved back*/ + return rsp; +} +#endif /* CONFIG_FTM_NFC */ + +static void usage(void) +{ + fprintf(stderr, "\nusage: %s [options] \n" + " -n, --nodaemon do not run as a daemon\n" + " -p, --passthrough FM passthrough mode \n" + " -d show more debug messages (-dd for even more)\n" +#ifdef CONFIG_FTM_BT + " -b, --board-type Board Type\n" +#endif +#ifdef CONFIG_FTM_WLAN + " -i \n" + " --interface=\n" + " wlan adapter name (wlan, eth, etc.) default wlan\n" +#endif +#ifdef CONFIG_FTM_NFC + " -f nfc firmware download\n" + " -t nfc test\n" +#endif + " --help display this help and exit\n" + , progname); + exit(EXIT_FAILURE); +} + +/*=========================================================================== +FUNCTION main + +DESCRIPTION + Initialises the Diag library and registers the PKT table for FM and BT + and daemonises + +DEPENDENCIES + NIL + +RETURN VALUE + NIL, Error in the event buffer will mean a NULL App version and Zero HW + version + +SIDE EFFECTS + None + +===========================================================================*/ + +int main(int argc, char *argv[]) +{ + int c; + static struct option options[] = + { + {"help", no_argument, NULL, 'h'}, +#ifdef CONFIG_FTM_WLAN + {"interface", required_argument, NULL, 'i'}, +#endif +#ifdef CONFIG_FTM_BT + {"board-type", required_argument, NULL, 'b'}, +#endif +#ifdef CONFIG_FTM_NFC + {"firmware-download", no_argument, NULL, 'f'}, + {"nfc-test", no_argument, NULL, 't'}, +#endif + {"nodaemon", no_argument, NULL, 'n'}, + {"passthrough", no_argument, NULL, 'p'}, + {"uart-baudrate", no_argument, NULL, 'u'}, + {"sibs", no_argument, NULL, 's'}, + {0, 0, 0, 0} + }; + int daemonize = 1; + + progname = argv[0]; + + while (1) + { + c = getopt_long(argc, argv, "hdi:npb:ft", options, NULL); + if (c < 0) + break; + + switch (c) + { +#ifdef CONFIG_FTM_WLAN + case 'i': + strlcpy(g_ifname, optarg, IFNAMSIZ); + break; +#endif + case 'n': + daemonize = 0; + break; + case 'p': + fm_passthrough = 1; + daemonize = 0; +#ifndef WIN_AP_HOST + property_set("wc_transport.skip_patch_dload" , "true"); +#endif + break; + case 'd': +#ifdef DEBUG + g_dbg_level = g_dbg_level << 1 | 0x1; +#else + printf("Debugging disabled, please build with -DDEBUG option\n"); + exit(EXIT_FAILURE); +#endif + break; + +#ifdef CONFIG_FTM_BT + case 'b': + boardtype = atoi(optarg); + break; +#endif + +#ifdef CONFIG_FTM_NFC + case 'f': + ftm_nfc_dispatch_nq_fwdl(); + break; + case 't': + ftm_nfc_dispatch_nq_test( argc, argv); + break; +#endif + + case 'h': + default: + usage(); + break; + } + } + + if (optind < argc) + usage(); + + if (daemonize && daemon(0, 0)) + { + perror("daemon"); + exit(EXIT_FAILURE); + } + + DPRINTF(FTM_DBG_TRACE, "FTM Daemon calling LSM init\n"); + + if (!Diag_LSM_Init(NULL)) + { + DPRINTF(FTM_DBG_ERROR, "FTM Daemon: Diag_LSM_Init() failed\n"); + exit(EXIT_FAILURE); + } + + DPRINTF(FTM_DBG_TRACE, "FTMDaemon: Diag_LSM_Init succesful\n"); + +#ifdef CONFIG_FTM_BT +#ifndef WIN_AP_HOST +#ifndef ANDROID + bt_property_init(); +#endif + soc_type = get_bt_soc_type(); +#endif +#endif + +#ifdef CONFIG_FTM_FM + DIAGPKT_DISPATCH_TABLE_REGISTER( DIAG_SUBSYS_FTM, fm_ftm_diag_func_table); +#endif + +#ifdef CONFIG_FTM_WLAN + DIAGPKT_DISPATCH_TABLE_REGISTER( DIAG_SUBSYS_FTM, wlan_ftm_diag_func_table); +#ifdef WIN_AP_HOST_OPEN + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); +#endif +#endif +#ifdef IPQ_AP_HOST_IOT + DIAGPKT_DISPATCH_TABLE_REGISTER( DIAG_SUBSYS_FTM, iot_ftm_diag_func_table); + interface = 0; + thread_stop = 0; + pthread_t *iot_thr = NULL; + iotd_desc = NULL; + +#ifdef IPQ_AP_HOST_IOT_QCA402X + iotd_desc = diag_open("/iotdiag"); +#endif /* IPQ_AP_HOST_IOT_QCA402X */ +#ifdef IPQ_AP_HOST_IOT_IPQ50XX + btss_desc = -1; + btss_desc = btss_init(); + if(btss_desc < 0) + { + DPRINTF(FTM_DBG_ERROR, "FTMd : Unable to fetch BT Devnode Descriptor \n"); + } + else + { + iotd_desc = (void *)(&btss_desc); + } +#endif /* IPQ_AP_HOST_IOT_IPQ50XX */ + if (iotd_desc != NULL) { +#ifdef IPQ_AP_HOST_IOT_QCA402X + DPRINTF(FTM_DBG_ERROR, "FTMd : FTMd has registered a handle with IOTD \n"); +#endif /* IPQ_AP_HOST_IOT_QCA402X */ + sem_init(&iot_sem, 0, 0); + sem_init(&iot_sem_async, 0, 1); + + iot_thr = (pthread_t *)malloc( sizeof(*iot_thr)); + if (!iot_thr) { + DPRINTF(FTM_DBG_ERROR, "Could not create thread for async log packets \n"); + } + else + { +#ifdef IPQ_AP_HOST_IOT_QCA402X + pthread_create(iot_thr, NULL, (void*)iot_thr_func_qca402x, (void *)iotd_desc); +#endif +#ifdef IPQ_AP_HOST_IOT_IPQ50XX + pthread_create(iot_thr, NULL, (void*)iot_thr_func_ipq50xx, (void *)iotd_desc); +#endif + } + } + + if (iotd_desc == NULL) + { + DPRINTF(FTM_DBG_ERROR, "FTMd : IOT Daemon has not been enabled \n"); + } + +#endif /* IPQ_AP_HOST_IOT */ + +#ifdef CONFIG_FTM_ANT + DIAGPKT_DISPATCH_TABLE_REGISTER( DIAG_SUBSYS_FTM, ant_ftm_diag_func_table); +#endif + +#ifdef CONFIG_FTM_NFC + DIAGPKT_DISPATCH_TABLE_REGISTER( DIAG_SUBSYS_FTM, nfc_ftm_diag_func_table); +#endif + +#ifdef CONFIG_FTM_BT + DIAGPKT_DISPATCH_TABLE_REGISTER( DIAG_SUBSYS_FTM, bt_ftm_diag_func_table); + + sem_init(&semaphore_cmd_complete,0, 1); + sem_init(&semaphore_cmd_queued,0,0); + first_ant_command = 0; + + DPRINTF(FTM_DBG_TRACE, "Initialised the BT FTM cmd queue handlers \n"); + + do + { + struct timespec ts; + int sem_status; + /* We have the freedom to send the first request without wating + * for a command complete + */ + DPRINTF(FTM_DBG_TRACE, + "Wait on cmd complete from the previous command\n"); + if (clock_gettime(CLOCK_REALTIME, &ts) == -1) + printf("get clock_gettime error"); + ts.tv_sec += 5; + /*we wait for 5 secs for a command already queued for + * transmision + */ + sem_status = sem_timedwait(&semaphore_cmd_complete,&ts); + if(sem_status == -1) + { + printf("Command complete timed out\n"); + ftm_bt_err_timedout(); + } + + DPRINTF(FTM_DBG_TRACE, "Waiting on next Cmd to be queued\n"); + + sem_wait(&semaphore_cmd_queued); + dequeue_send(); + } + while(1); +#else /* CONFIG_FTM_BT */ +#ifdef CONFIG_FTM_FM + pthread_cond_init(&fm_event_cond, NULL); + pthread_mutex_init(&fm_event_lock, NULL); +#endif + while (1); +#endif + + DPRINTF(FTM_DBG_TRACE, "\nFTMDaemon Deinit the LSM\n"); +#ifdef CONFIG_FTM_FM + pthread_cond_destroy(&fm_event_cond); + pthread_mutex_destroy(&fm_event_lock); +#endif + +#ifdef IPQ_AP_HOST_IOT + if (iotd_desc != NULL) { + thread_stop = 1; + pthread_join(*iot_thr, NULL); + free(iot_thr); +#ifdef IPQ_AP_HOST_IOT_IPQ50XX + btss_deinit(); +#endif + } +#endif /* IPQ_AP_HOST_IOT */ + hidl_client_close(); + /* Clean up before exiting */ + Diag_LSM_DeInit(); + + exit(EXIT_SUCCESS); +} diff --git a/feeds/wifi-ax/ftm/src/ftm_nfc.c b/feeds/wifi-ax/ftm/src/ftm_nfc.c new file mode 100755 index 000000000..121aa4aba --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfc.c @@ -0,0 +1,108 @@ +/*========================================================================= + NFC FTM C File +Description + This file contains the definitions of the function used to check + which chip is present on the device. + +Copyright (c) 2013-2015 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. + +===========================================================================*/ +/*=========================================================================== + Edit History +when who what, where, why +-------- --- ---------------------------------------------------------- +===========================================================================*/ + +#include "ftm_nfc.h" + +CHIP_TYPE chipType = UNDEFINED_CHIP_TYPE; + +/*========================================================================= +FUNCTION checkChip + +DESCRIPTION + Checks whether it can open the NQ Kernel, if not, it means + the device has a QTI chip. + +PARAMETERS + None + +RETURN VALUE + void + +===========================================================================*/ +void checkChip( void ) +{ + int ret = 0; + + ret = ftm_nq_nfc_open( ); // can you open the NQ Kernel? + + if( ret > 0 ) // yes + { + printf( "%s: NQ CHIP \n", __func__ ); + chipType = NQ_CHIP; // so it's an NQ Chip + + ret = ftm_nq_nfc_close( ); // close the handle + if( ret != 0 ) // not successful? + { + printf( "%s: Could not close the File Handle for NQ Chip \n", __func__ ); + chipType = CHIP_ERROR; // something is wrong + } + } + else + { + printf( "%s: QTI CHIP \n", __func__ ); + chipType = QTI_CHIP; + } +} + +/*========================================================================= +FUNCTION ftm_nfc_dispatch + +DESCRIPTION + Dispatches QRCT commands and Chip Replies/Notifications/Data + to the required FTM NFC Chip Handler + +PARAMETERS + ftm_nfc_pkt_type *nfc_ftm_pkt - FTM Packet + uint16 pkt_len - FTM Packet Length + +RETURN VALUE + void * + +===========================================================================*/ +void* ftm_nfc_dispatch( ftm_nfc_pkt_type *nfc_ftm_pkt, uint16 pkt_len ) +{ + ftm_nfc_pkt_type *reply = NULL; + + if( UNDEFINED_CHIP_TYPE == chipType ) + { + printf( "%s: Checking Chip Type \n", __func__ ); + checkChip( ); + } + + switch( chipType ) + { + case NQ_CHIP: + if( nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_REQ_CHIP_TYPE ) + reply = PrepareRsp( nfc_ftm_pkt ); + else + reply = ftm_nfc_dispatch_nq( nfc_ftm_pkt, pkt_len ); + break; + + case QTI_CHIP: + if( nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_REQ_CHIP_TYPE ) + reply = PrepareRsp( nfc_ftm_pkt ); + else + reply = ftm_nfc_dispatch_qti( nfc_ftm_pkt, pkt_len ); + break; + + default: + printf( "%s: ERROR - THIS SHOULD HAVE NEVER BEEN REACHED, CHIP TYPE %d", __func__, chipType ); + break; + } + + return reply; +} diff --git a/feeds/wifi-ax/ftm/src/ftm_nfc.h b/feeds/wifi-ax/ftm/src/ftm_nfc.h new file mode 100755 index 000000000..3a48f7541 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfc.h @@ -0,0 +1,37 @@ +/*========================================================================= + NFC FTM HEADER File +Description + This file contains the definitions of the function used to check + which chip is present on the device. + +Copyright (c) 2013-2016 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. + +===========================================================================*/ + +#ifndef _FTM_NFC +#define _FTM_NFC + +#include "ftm_nfcnq.h" + +#define NFC_QCA1990 // Defnition to enable the NFC FTM inclusion + +typedef enum _CHIP_TYPE{ + UNDEFINED_CHIP_TYPE = 0, + QTI_CHIP = 1, + NQ_CHIP = 2, + CHIP_ERROR = 3, + MAXIMUM_CHIP_TYPE = 4, +} CHIP_TYPE; + +extern CHIP_TYPE chipType; + +void* ftm_nfc_dispatch(ftm_nfc_pkt_type *ftm_nfc_pkt, uint16 pkt_len); + +void* ftm_nfc_dispatch_qti(ftm_nfc_pkt_type *ftm_nfc_pkt, uint16 pkt_len); + +void ftm_nfc_dispatch_nq_fwdl(); + +void ftm_nfc_dispatch_nq_test(int argc, char **argv); +#endif // _FTM_NFC diff --git a/feeds/wifi-ax/ftm/src/ftm_nfcnq.c b/feeds/wifi-ax/ftm/src/ftm_nfcnq.c new file mode 100755 index 000000000..3b1f72573 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfcnq.c @@ -0,0 +1,807 @@ +/*========================================================================= + NQ NFC FTM C File +Description + This file contains the definitions of the functions + used to communicate with the NQ Chip. + +Copyright (c) 2015-2016 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. + +===========================================================================*/ +/*=========================================================================== + Edit History +when who what, where, why +-------- --- ---------------------------------------------------------- +===========================================================================*/ + +#include "ftm_nfcnq.h" +#include "ftm_nfc.h" +#include "ftm_nfcnq_fwdl.h" + +/* Global variables */ +pthread_t clientThread; +PNCI_MESSAGE pNCIMessage; +sem_t sRspReady; +int fdNfc = 0; +uint8_t nciReplyMessage[ 255 ] = { 0 }; +NQ_CHIP_TYPE whatNQChip = UNKNOWN_NQ_CHIP_TYPE; +uint8_t RFdeactivateCmd[ ] = { 0x21, 0x06, 0x01, 0x03}; +uint8_t EseDataRsp[ ] = { 0x03, 0x00, 0x21, 0x99, 0x50, 0xFE}; + +/*========================================================================= +FUNCTION ftm_nq_nfc_close + +DESCRIPTION + Close the kernel driver for the NQ Chip + +PARAMETERS + None + +RETURN VALUE + int + +===========================================================================*/ +int ftm_nq_nfc_close( void ) +{ + fdNfc = close( fdNfc ); // close the file descriptor + + LOG_MESSAGE( "%s : Exit with fdNfc = %d \n", __func__, fdNfc ); + + return fdNfc; // return the result +} + +/*========================================================================= +FUNCTION ftm_nq_nfc_open + +DESCRIPTION + Open the kernel driver for the NQ Chip + +PARAMETERS + None + +RETURN VALUE + int + +===========================================================================*/ +int ftm_nq_nfc_open( void ) +{ + fdNfc = open( "/dev/nq-nci", // try to open /dev/nq-nci + O_RDWR ); + + LOG_MESSAGE( "%s : Exit with fdNfc = %d \n", __func__, fdNfc ); + + return fdNfc; // return the result +} + +/*========================================================================= +FUNCTION ftm_nfc_hw_reset + +DESCRIPTION + Resets the NQ Chip + +PARAMETERS + None + +RETURN VALUE + int + +===========================================================================*/ +int ftm_nfc_hw_reset( void ) +{ + + int ret = -1; // return value + + do + { + if( fdNfc < 0 ) // fdNfc valid? + break; + + ret = ioctl( fdNfc, NFC_SET_PWR, POWER_ON ); // turn the chip on + if( ret != 0 ) // successful? + { + LOG_ERROR( "%s ioctl( fdNfc, NFC_SET_PWR, POWER_ON ) returned %d", __func__, ret ); + ret = -2; + break; + } + usleep( 1000 ); // wait + + ret = ioctl( fdNfc, NFC_SET_PWR, POWER_OFF ); // turn the chip off + if( ret != 0 ) // successful? + { + LOG_ERROR( "%s ioctl( fdNfc, NFC_SET_PWR, POWER_OFF ) returned %d", __func__, ret ); + ret = -3; + break; + } + usleep( 1000 ); // wait + + ret = ioctl( fdNfc, NFC_SET_PWR, POWER_ON ); // turn the chip back on + if( ret != 0 ) // successful? + { + LOG_ERROR( "%s ioctl( fdNfc, NFC_SET_PWR, POWER_ON ) returned %d", __func__, ret ); + ret = -4; + break; + } + + }while( 0 ); + + return ret; +} + +/*========================================================================= +FUNCTION PrintBytes + +DESCRIPTION + Print bytes from an array + +PARAMETERS + uint8_t *buf - Byte array to print + uint8_t len - Length of the array +RETURN VALUE + void + +===========================================================================*/ +void PrintBytes( uint8_t *buf, uint8_t len) +{ +#ifdef NFC_FTM_DEBUG + int idx; + + LOG_INFORMATION( "%s: Length: %d bytes \n", __func__, len ); // print the number of bytes + for( idx = 0; idx < len; idx++ ) // print every byte + { + LOG_INFORMATION( "%02x ", buf[idx] ); + } + LOG_INFORMATION( "\n" ); +#else + UNUSED_PARAMETER( buf ); + UNUSED_PARAMETER( len ); +#endif +} + +/*========================================================================= +FUNCTION ftm_nfc_send + +DESCRIPTION + Sends a message to the chip + +PARAMETERS + uint8_t *buf - buffer to be sent + int len - the length of the buffer + +RETURN VALUE + int ret - Status + +===========================================================================*/ +int ftm_nfc_send( uint8_t* buf ) +{ + int ret = -1; // return value + int retries = 15; // number of retries + int i; + uint16_t nciSendMessageLength; + PNCI_MESSAGE pMessageToSend = ( PNCI_MESSAGE ) buf; + pfirmware_download_packet_t pFirmwarePacketsToSend = + ( pfirmware_download_packet_t ) buf; + + + do + { + if( fdNfc < 0 ) // fdNfc valid? + break; + + if( NULL == buf ) // is the buffer valid? + { + ret = -2; + LOG_ERROR( "%s: buf == NULL Invalid Buffer", __func__ ); + break; + } + + if( ( pFirmwarePacketsToSend->fFragmentedPacket == FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_NONE ) || + ( pFirmwarePacketsToSend->fFragmentedPacket == FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_SET ) ) + nciSendMessageLength = pFirmwarePacketsToSend->payloadLen + + FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN + + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN; + else + nciSendMessageLength = pMessageToSend->len + offsetof( NCI_MESSAGE, buf ); + + PrintBytes( buf, nciSendMessageLength ); + + do + { + retries--; // retries left + ret = write( fdNfc, + buf, + nciSendMessageLength ); // try to write + + if( ret < nciSendMessageLength ) // did you write the length? + { + LOG_MESSAGE( "%s: %d = write( fdNfc, buf, nciSendMessageLength ), errno = %d, tries left = %d \n", __func__, ret, errno, retries ); + continue; // try again + } + else + break; // done + + } while( retries > 0 ); + } while( 0 ); + + return ret; +} + +/*========================================================================= +FUNCTION ProcessCommand + +DESCRIPTION + Processes a Command for the NQ Chip + +PARAMETERS + uint8_t *nci_data - NCI Data to send + +RETURN VALUE + int ret - 0 if successfully received a reply + +===========================================================================*/ +int ProcessCommand( uint8_t *nci_data ) +{ + int ret = -1; // return value + struct timespec time_sec; + + do + { + LOG_MESSAGE( "%s: FTM_NFC_SEND_DATA \n", __func__ ); + + ret = ftm_nfc_send( nci_data ); // send the message + + LOG_MESSAGE( "%s: Wait for response \n", __func__ ); + + ret = clock_gettime( CLOCK_REALTIME, &time_sec ); + + if( ret == -1 ) + { // didn't get the time? + LOG_ERROR( "%s: clock_gettime for nci_data error \n", __func__ ); + break; + } + + time_sec.tv_sec += FTM_NFC_CMD_CMPL_TIMEOUT; // maximum wait + ret = sem_timedwait( &sRspReady, // start waiting + &time_sec ); + + if( ret == -1 ) // wait finished, not signalled? + { + if(!ese_dwp_test) + LOG_ERROR( "%s: nfc ftm command timed out \n", __func__ ); + break; + } + } while( 0 ); + + return ret; +} +/*========================================================================= +FUNCTION ftm_nfc_read + +DESCRIPTION + Reads a message from the chip + +PARAMETERS + int len - the length of the buffer + +RETURN VALUE + int ret - Number of bytes read + +===========================================================================*/ +int ftm_nfc_read( uint8_t* buf, int len ) +{ + int ret = -1; + + do + { + if( fdNfc < 0 ) // fdNfc valid? + break; + + ret = read( fdNfc, buf, len ); // try to read + + } while( 0 ); + + return ret; +} + +/*========================================================================== +FUNCTION + CommitLog + +DESCRIPTION + This commits the log to Diag + +PARAMETERS + NCI_MESSAGE pReadNCIMessage - Pointer to the read NCI Message + +RETURN VALUE + void +==========================================================================*/ +void CommitLog( PNCI_MESSAGE pReadNCIMessage ) +{ + pftm_nfc_log_pkt_type pLogBuff; + + do + { + pLogBuff = ( ftm_nfc_log_pkt_type * ) log_alloc( LOG_NFC_FTM, // allocate a buffer for the log + pReadNCIMessage->len + offsetof( NCI_MESSAGE, buf ) + LOG_HEADER_LENGTH ); + if( NULL == pLogBuff ) + { + LOG_ERROR( "%s: log_alloc returned NULL \n", __func__ ); + break; + } + + memcpy( pLogBuff->data, // fill the buffer + pReadNCIMessage, + pReadNCIMessage->len + offsetof( NCI_MESSAGE, buf ) ); + + log_commit( pLogBuff ); // commit the log + } while ( 0 ); + +} + +/*============================================================================= +FUNCTION + ProcessReturnedMessage + +DESCRIPTION + Routine that processes an NCI Message that was returned and + will decide if the message is a notification or a response. + +PARAMETERS + PNCI_MESSAGE pReadNCIMessage - Pointer to the read message + +RETURN VALUE + void +==============================================================================*/ +void ProcessReturnedMessage( PNCI_MESSAGE pReadNCIMessage ) +{ + + switch( pReadNCIMessage->gid & NCIMT_NTF ) // check the first byte + { + case NCIMT_RSP: // reply? + sem_post( &sRspReady ); // notify the dispatch function + break; + + case NCIMT_NTF: // notification? + if (pReadNCIMessage->oid == 0x05) + { + LOG_INFORMATION("\n << ...TAG DETECTED... >> \n"); + printTecnologyDetails(pReadNCIMessage->buf[3],pReadNCIMessage->buf[2]); + sem_post( &sRfNtf ); + ProcessCommand( RFdeactivateCmd ); + } + case NCIMT_DATA: // data? + if (ese_dwp_test) + { + if( memcmp( EseDataRsp, nciReplyMessage, sizeof( EseDataRsp ) ) == 0 ) + { + LOG_INFORMATION("\n << ESE detected over DWP >> \n\n"); + } + } + if( log_status( LOG_NFC_FTM ) ) // logging enabled? + { + CommitLog( pReadNCIMessage ); + } + break; + + default: + LOG_ERROR( "%s: ERROR - SHOULD NOT HAVE REACHED THIS POINT", __func__ ); + break; + } + +} + +/*========================================================================= +FUNCTION nfc_read_thread + +DESCRIPTION + Thread that constantly looks for messages from the chip + +PARAMETERS + void + +RETURN VALUE + void + +===========================================================================*/ +void *nfc_read_thread( void *arg ) +{ + uint8_t readLength = 0; + int i; + uint8_t readNCIUpToLength = offsetof( NCI_MESSAGE, buf ); + + UNUSED_PARAMETER( arg ); + + for( ; ; ) // keep reading + { + readLength = ftm_nfc_read( nciReplyMessage, readNCIUpToLength ); // read the first 3 bytes + + if( readLength == readNCIUpToLength ) // read the message up to NCI Len? + { + readLength = ftm_nfc_read( pNCIMessage->buf, // go and get the rest + pNCIMessage->len ); + + if( readLength == pNCIMessage->len ) // successful? + { + PrintBytes( nciReplyMessage, pNCIMessage->len + readNCIUpToLength ); + + ProcessReturnedMessage( pNCIMessage ); // Process the read message + + } + } + } + +} + +/*========================================================================== +FUNCTION PrepareRsp + +DESCRIPTION + Routine to prepare a response for diag. + +PARAMETERS + ftm_nfc_pkt_type *nfc_ftm_pkt - FTM Packet + +RETURN VALUE + void * +==========================================================================*/ +void *PrepareRsp( ftm_nfc_pkt_type *nfc_ftm_pkt ) +{ + void *response = NULL; + switch( nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id ) + { + case FTM_NFC_NFCC_COMMAND: + { + ftm_nfc_pkt_type *nfc_nci_rsp = ( ftm_nfc_pkt_type* ) diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, + FTM_NFC_CMD_CODE, + sizeof( ftm_nfc_pkt_type ) ); // get a Response Buffer for NFCC Command + + if( NULL == nfc_nci_rsp ) + { + LOG_ERROR( "%s: diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, FTM_NFC_CMD_CODE, sizeof( ftm_nfc_pkt_type ) ) returned NULL \n", __func__ ); + } + else + { + nfc_nci_rsp->ftm_nfc_hdr.nfc_cmd_id = FTM_NFC_NFCC_COMMAND; + nfc_nci_rsp->ftm_nfc_hdr.nfc_cmd_len = offsetof( ftm_nfc_cmd_header, nfc_cmd_len ) + offsetof( NCI_MESSAGE, buf ) + pNCIMessage->len ; + nfc_nci_rsp->nfc_nci_pkt_len = offsetof( NCI_MESSAGE, buf ) + pNCIMessage->len; + + memcpy( nfc_nci_rsp->nci_data, + pNCIMessage, + nfc_nci_rsp->nfc_nci_pkt_len ); + + response = ( void* ) nfc_nci_rsp; + } + break; + } + + case FTM_NFC_REQ_CHIP_TYPE: + { + // change from a NCI packet type to a request chip type packet type + ftm_nfc_chip_type_pkt_type *nfc_chip_type_rsp = ( ftm_nfc_chip_type_pkt_type* ) diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, + FTM_NFC_CMD_CODE, + sizeof( ftm_nfc_chip_type_pkt_type ) ); // get a Response Buffer for Request Chip Type Command + if( NULL == nfc_chip_type_rsp ) + { + LOG_ERROR( "%s: diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, FTM_NFC_CMD_CODE, sizeof( ftm_nfc_chip_type_pkt_type ) ) returned NULL \n", __func__ ); + } + else + { + nfc_chip_type_rsp->nfc_chip_type_cmd_id = FTM_NFC_REQ_CHIP_TYPE; + nfc_chip_type_rsp->nfc_chip_type_pkt_len = 1; // only 1 byte for response packet data + if( chipType == 1 ) // 1 for QTI, 2 for NQ + nfc_chip_type_rsp->nfc_chip_type_pkt_data = FTM_NFC_QTI_CHIP; + else + nfc_chip_type_rsp->nfc_chip_type_pkt_data = FTM_NFC_NQ_CHIP; + + response = ( void* ) nfc_chip_type_rsp; + } + break; + } + + case FTM_NFC_FWPIN_CTRL: + { + // change from a NCI packet type to a firmware download packet type + ftm_nfc_fwdl_pkt_type *nfc_fwdl_rsp = ( ftm_nfc_fwdl_pkt_type* ) diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, + FTM_NFC_CMD_CODE, + sizeof( ftm_nfc_fwdl_pkt_type ) ); // get a Response Buffer for Firmware Download Pin Command + if( NULL == nfc_fwdl_rsp ) + { + LOG_ERROR( "%s: diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, FTM_NFC_CMD_CODE, sizeof( ftm_nfc_fwdl_pkt_type ) ) returned NULL \n", __func__ ); + } + else + { + nfc_fwdl_rsp->nfc_fwdl_cmd_id = FTM_NFC_FWPIN_CTRL; + nfc_fwdl_rsp->nfc_fwdl_pkt_len = 1; // only 1 byte for response packet data + nfc_fwdl_rsp->nfc_fwdl_pkt_data = FTM_NFC_FWDL_SUCCESS; // 0 for fail, 1 for success + + response = ( void* ) nfc_fwdl_rsp; + } + break; + } + + default : + + LOG_ERROR( "%s: ERROR - SHOULD NOT HAVE ENDED UP HERE: default case \n", __func__ ); + break; + } + + return response; + +} + +/*========================================================================= +FUNCTION ftm_nfc_nq_vs_nxp + +DESCRIPTION + Check whether the chip is an NQ Chip + +PARAMETERS + None + +RETURN VALUE + int + +===========================================================================*/ +int ftm_nfc_nq_vs_nxp( void ) +{ + int ret = 0; + uint8_t coreResetCmd[ ] = { 0x20, 0x00, 0x01, 0x00 }; + uint8_t coreResetRsp[ ] = { 0x40, 0x00, 0x03, 0x00, 0x11, 0x00 }; + uint8_t coreInitCmd[ ] = { 0x20, 0x01, 0x00 }; + + do + { + ret = ProcessCommand( coreResetCmd ); // send a Core Reset CMD + + if( ret == -1 ) // wait finished, not signalled? + { + LOG_ERROR( "%s: ProcessCommand( coreResetCmd ) error %d \n", __func__, ret ); + break; + } + + if( memcmp( coreResetRsp, nciReplyMessage, sizeof( coreResetRsp ) ) ) + { // not a good reply? + coreResetRsp[4] = 0x10; + if( memcmp( coreResetRsp, nciReplyMessage, sizeof( coreResetRsp ) ) ) + { // check if NCI version is 1.0 + ret = -1; + LOG_ERROR( "%s: bad reply for coreResetRsp", __func__ ); + break; + } + } + + ret = ProcessCommand( coreInitCmd ); // send the message + + if( ret == -1 ) // wait finished, not signalled? + { + LOG_ERROR( "%s: ProcessCommand( coreInitCmd ) error %d \n", __func__, ret ); + break; + } + + switch( nciReplyMessage[ CHIP_ID ] ) // what type of chip is it? + { + case 0x48: + whatNQChip = NQ_210; + LOG_INFORMATION( "Connected to NQ210 \n" ); + break; + + case 0x58: + whatNQChip = NQ_220; + LOG_INFORMATION( "Connected to NQ220 \n" ); + break; + + case 0x40: + case 0x41: + whatNQChip = NQ_310; + LOG_INFORMATION( "Connected to NQ310 \n" ); + break; + + case 0x50: + case 0x51: + whatNQChip = NQ_330; + LOG_INFORMATION( "Connected to NQ330 \n" ); + break; + + default: + whatNQChip = UNKNOWN_NQ_CHIP_TYPE; + ret = -1; + LOG_INFORMATION( "ERROR Connected to an unknown NQ Chip \n" ); + break; + } + }while( 0 ); + + return ret; +} + +/*========================================================================= +FUNCTION ftm_nfc_set_fwdl_pin + +DESCRIPTION + Sets or resets the firmware download pin high or low + +PARAMETERS + ftm_nfc_pkt_type *nfc_ftm_pkt - FTM Packet + +RETURN VALUE + void + +===========================================================================*/ +void ftm_nfc_set_fwdl_pin( ftm_nfc_pkt_type *nfc_ftm_pkt ) +{ + int ret = 0; + // change from a NCI packet type to a firmware download packet type + pftm_nfc_fwdl_pkt_type pnfc_fwdl_pkt = ( pftm_nfc_fwdl_pkt_type ) nfc_ftm_pkt; + + switch ( pnfc_fwdl_pkt->nfc_fwdl_pkt_data ) + { + case 0: + + ret = ftm_nfc_hw_reset( ); // Can you reset the hardware? + if( ret < 0 ) // successful? + { + LOG_ERROR( "%s: ftm_nfc_hw_reset() failed with ret = %d \n", __func__, ret ); + break; + } + + LOG_MESSAGE( "%s: Firmware download pin set LOW\n", __func__ ); + break; + + + case 1: + + ret = ioctl( fdNfc, NFC_SET_PWR, FIRMWARE_MODE ); + if( ret != 0 ) // successful? + { + LOG_ERROR( "%s ioctl( fdNfc, NFC_SET_PWR, FIRMWARE_MODE ) returned %d", __func__, ret ); + break; + } + + LOG_MESSAGE( "%s: Firmware download pin set HIGH\n", __func__ ); + break; + + default : + + LOG_ERROR( "%s: ERROR - SHOULD NOT HAVE ENDED UP HERE: default case \n", __func__ ); + break; + } + + ret = ftm_nq_nfc_close( ); // close the handle + if( ret != 0 ) // not successful? + { + LOG_ERROR( "\n\t %s: ftm_nq_nfc_close() failed with ret = %d \n", __func__, ret ); + } + + ret = ftm_nq_nfc_open( ); // open the kernel driver + if( ret < 0 ) // successful? + { + LOG_ERROR( "\n\t %s: ftm_nq_nfc_open() failed with ret = %d \n", __func__, ret ); + } +} + +/*========================================================================= +FUNCTION ftm_nfc_dispatch_nq + +DESCRIPTION + Dispatches QRCT commands and Chip Replies/Notifications/Data + +PARAMETERS + ftm_nfc_pkt_type *nfc_ftm_pkt - FTM Packet + uint16 pkt_len - FTM Packet Length + +RETURN VALUE + void * + +===========================================================================*/ +void* ftm_nfc_dispatch_nq( ftm_nfc_pkt_type *nfc_ftm_pkt, uint16 pkt_len ) +{ + int ret = 0; + int len = 0; + struct timespec time_sec; + char *SkipNQHardwareCheck = NULL; + + void *rsp = NULL; + UNUSED_PARAMETER( pkt_len ); + + do + { + if( !fdNfc ) // Already initialized? + { + ret = ftm_nq_nfc_open( ); // open the kernel driver + if( ret < 0 ) // successful? + { + LOG_ERROR( "\n\t %s: ftm_nq_nfc_open() failed with ret = %d \n", __func__, ret ); + break; + } + + ret = ftm_nfc_hw_reset( ); // Can you reset the hardware? + if( ret < 0 ) // successful? + { + LOG_ERROR( "%s: ftm_nfc_hw_reset() failed with ret = %d \n", __func__, ret ); + break; + } + + pNCIMessage = ( PNCI_MESSAGE ) nciReplyMessage; + + ret = pthread_create( &clientThread, // Start the Read Thread + NULL, + &nfc_read_thread, + NULL ); + if( ret != 0 ) // successful? + { + LOG_MESSAGE( "%s: pthread_create( nfc_read_thread ) failed with ret = %d \n", __func__, ret ); + break; + } + + SkipNQHardwareCheck = getenv( SKIP_NQ_HARDWARE_CHECK ); + LOG_MESSAGE( "%s: SkipNQHardwareCheck = %s \n", __func__, SkipNQHardwareCheck ); + + if( NULL == SkipNQHardwareCheck ) // no value so check for NQ Chip? + { + ret = ftm_nfc_nq_vs_nxp( ); + if( ret < 0 ) // Not an NQ Chip? + { + LOG_ERROR( "ERROR NOT A KNOWN NQ Chip \n" ); + break; + } + } + else + { + LOG_INFORMATION( " Skipping NQ Chip Check \n" ); + whatNQChip = SKIP_CHIP_CHECK; + } + + LOG_INFORMATION( "FTM for NFC SUCCESSFULLY STARTED \n" ); + } + + if( UNKNOWN_NQ_CHIP_TYPE == whatNQChip ) + { + LOG_ERROR( "ERROR This version of the chip is not accepted" ); + break; + } + + if( NULL == nfc_ftm_pkt ) // valid packet? + { + LOG_ERROR( "%s: Error : nfc_ftm_pkt is NULL \n", __func__ ); + break; + } + + if( offsetof( ftm_nfc_pkt_type, ftm_nfc_hdr ) < MIN_CMD_PKT_LEN ) + { // packet contains anything? + LOG_ERROR( "%s: Error : Invalid FTM Packet \n", __func__ ); + break; + } + + switch( nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id ) // what type of packet is it? + { + + case FTM_NFC_NFCC_COMMAND: // NFC Command? + case FTM_NFC_SEND_DATA: // NFC Data? + + ret = ProcessCommand( nfc_ftm_pkt->nci_data ); + if( ret == -1 ) // wait finished, not signalled? + { + LOG_ERROR( "%s: ProcessCommand( nfc_ftm_pkt->nci_data ) error %d \n", __func__, ret ); + break; + } + rsp = PrepareRsp( nfc_ftm_pkt ); // Prepare the response for Diag + + break; + + case FTM_NFC_REQ_CHIP_TYPE: + case FTM_NFC_FWPIN_CTRL: + + ftm_nfc_set_fwdl_pin( nfc_ftm_pkt ); + + rsp = PrepareRsp( nfc_ftm_pkt ); // Prepare the response for Diag + break; + + default : + LOG_ERROR( "%s: ERROR - SHOULD NOT HAVE ENDED UP HERE: default case \n", __func__ ); + break; + + } + } while( 0 ); + + return rsp; +} diff --git a/feeds/wifi-ax/ftm/src/ftm_nfcnq.h b/feeds/wifi-ax/ftm/src/ftm_nfcnq.h new file mode 100755 index 000000000..af8c2db56 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfcnq.h @@ -0,0 +1,168 @@ +/*========================================================================= + NQ NFC FTM Header File +Description + This file contains the declarations of the functions + used to communicate with the NQ Chip and various definitions. + +Copyright (c) 2015-2017 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. + +===========================================================================*/ +/*=========================================================================== + Edit History +when who what, where, why +-------- --- ---------------------------------------------------------- +===========================================================================*/ + +#ifndef _FTM_NFCNQ +#define _FTM_NFCNQ + +#include "msg.h" +#include "diagpkt.h" +#include "diagcmd.h" +#include "errno.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "log.h" + +#define LOG_ERROR( ... ) printf( __VA_ARGS__ ) +#define LOG_INFORMATION( ... ) printf( __VA_ARGS__ ) + +#ifdef NFC_FTM_DEBUG +#define LOG_MESSAGE( ... ) printf( __VA_ARGS__ ) +#else +#define LOG_MESSAGE( ... ) do{ } while ( FALSE ) +#endif + +typedef PACKED struct _ftm_nfc_cmd_header{ + uint16 nfc_cmd_id; + uint16 nfc_cmd_len; +} ftm_nfc_cmd_header, *pftm_nfc_cmd_header; + +typedef PACKED struct{ + diagpkt_subsys_header_type diag_hdr; + ftm_nfc_cmd_header ftm_nfc_hdr; + uint16 nfc_nci_pkt_len; + byte nci_data[258]; +}ftm_nfc_pkt_type, *pftm_nfc_pkt_type; + +typedef PACKED struct{ + diagpkt_subsys_header_type diag_hdr; + uint16 nfc_fwdl_cmd_id; + byte nfc_fwdl_pkt_len; + byte nfc_fwdl_pkt_data; +}ftm_nfc_fwdl_pkt_type, *pftm_nfc_fwdl_pkt_type; + +typedef PACKED struct{ + diagpkt_subsys_header_type diag_hdr; + uint16 nfc_chip_type_cmd_id; + byte nfc_chip_type_pkt_len; + byte nfc_chip_type_pkt_data; +}ftm_nfc_chip_type_pkt_type, *pftm_nfc_chip_type_pkt_type; + +typedef PACKED struct{ + log_hdr_type hdr; + byte data[1]; +} ftm_nfc_log_pkt_type, *pftm_nfc_log_pkt_type; + +typedef PACKED struct _NCI_MESSAGE +{ + byte gid; // Group ID + byte oid; // Operation ID + byte len; // payload length in bytes + byte buf[ 252 ]; // Payload Buffer +} NCI_MESSAGE, *PNCI_MESSAGE; + +typedef enum +{ + NCIMT_DATA = 0x00, /**< DATA packet. */ + NCIMT_CMD = 0x20, /**< Control packet - Command. */ + NCIMT_RSP = 0x40, /**< Control packet - Response. */ + NCIMT_NTF = 0x60, /**< Control packet - Notification. */ + + NCIMT_INVALID_VALUE = 0xFF, /**< Invalid packet type. */ + + NCIMT_BITMASK = 0xE0, /**< Most significant three bits. */ + NCIMT_BITSHIFT = 5 + +} NCIMT; + +typedef enum +{ + UNKNOWN_NQ_CHIP_TYPE = 0, + SKIP_CHIP_CHECK = 1, + NQ_110 = 11, + NQ_120 = 12, + NQ_210 = 21, + NQ_220 = 22, + NQ_310 = 31, + NQ_330 = 33, + MAXIMUM_NQ_CHIP_TYPE +} NQ_CHIP_TYPE; + +struct nqx_devinfo +{ + unsigned char chip_type; + unsigned char rom_version; + unsigned char fw_major; + unsigned char fw_minor; +}; + +union nqx_uinfo +{ + unsigned int i; + struct nqx_devinfo info; +}; + +int ftm_nq_nfc_open( void ); +int ftm_nq_nfc_close( void ); +int ftm_nfc_hw_reset( void ); +int ProcessCommand( uint8_t *nci_data ); +void *PrepareRsp( ftm_nfc_pkt_type *nfc_ftm_pkt ); +void *ftm_nfc_dispatch_nq( ftm_nfc_pkt_type *nfc_ftm_pkt, uint16 pkt_len); +void *nfc_read_thread( void *arg ); +extern sem_t sRfNtf; +extern int ese_dwp_test; +extern void printTecnologyDetails(char technology, char protocol); + +#define FTM_NFC_CMD_CODE 55 +#define FTM_NFC_NFCC_COMMAND 0x02 +#define FTM_NFC_SEND_DATA 0x03 +#define FTM_NFC_REQ_CHIP_TYPE 0x04 +#define FTM_NFC_FWPIN_CTRL 0x05 +#define FTM_NFC_CMD_CMPL_TIMEOUT 3 + +#define FTM_NFC_QTI_CHIP 0x00 +#define FTM_NFC_NQ_CHIP 0x01 +#define FTM_NFC_FWDL_SUCCESS 0x01 + +#define MIN_CMD_PKT_LEN 4 // Minimum length for a valid FTM packet, 2 bytes for Diag header, 2 bytes for command ID + +#define LOG_NFC_FTM 0x1802 +#define LOG_HEADER_LENGTH 12 + +#define NFC_SET_PWR _IOW(0xE9, 0x01, unsigned int) +#define NFCC_GET_INFO _IOW(0xE9, 0x09, unsigned int) +#define POWER_OFF 0 +#define POWER_ON 1 +#define FIRMWARE_MODE 2 + +#define EXPECTED_CORE_INIT_RSP_LEN 29 +#define CHIP_ID 24 + +#define SKIP_NQ_HARDWARE_CHECK "SkipNQHardwareCheck" +#define HARDWARE_TYPE_TIMEOUT 2 + +#define UNUSED_PARAMETER( x ) ( void )( x ) + +#endif // _FTM_NFCNQ diff --git a/feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.c b/feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.c new file mode 100755 index 000000000..458bcde64 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.c @@ -0,0 +1,664 @@ +/* + * Copyright (c) 2016-2017 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + * Not a Contribution. + * Apache license notifications and license are retained + * for attribution purposes only. + */ + +/* + * Copyright (C) 2015 NXP Semiconductors + * The original Work has been changed by NXP Semiconductors. + * + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*========================================================================= + FTM NFC NQ Firmware Download Source File + Description + This file contains the definitions of the functions + used to download firmware onto the NQ Chip. +===========================================================================*/ + +#include "ftm_nfcnq_fwdl.h" +#include "ftm_nfcnq.h" + +unsigned int chip_version = 0x00; + +/* lookup table for CRC-16-CCITT calculation */ +static uint16_t const crcTable[ 256 ] = + { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, + 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, + 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, + 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, + 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, + 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, + 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, + 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, + 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, + 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, + 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, + 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, + 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, + 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, + 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, + 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, + 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, + 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, + 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 }; + + +/*========================================================================================================== +FUNCTION + load_firmware_from_library + +DESCRIPTION + gets a pointer to the firmware image and the length of the image + +PARAMETERS + const char *pathToLib - path to the firmware image library + uint8_t **ppFirmwareImage - pointer to the pointer to the firmware image + uint16_t *pFirmwareImageLen - pointer to the firmware image length + +RETURN VALUE + void + +==========================================================================================================*/ +static void load_firmware_from_library( const char *pathToLib, uint8_t **ppFirmwareImage, + uint16_t *pFirmwareImageLen ) +{ + void *pFirmwareLibHandle = NULL; + void *pTempFirmwareImage = NULL; + void *pTempFirmwareImageLen = NULL; + int status = -1; + + do + { + if( NULL == pathToLib ) + { + if(chip_version == 0x51 || chip_version == 0x50 || chip_version == 0x41 || chip_version == 0x40 ) + pathToLib = "/system/vendor/firmware/libpn553_fw.so"; // set the path to pn553 firmware library + else + pathToLib = "/system/vendor/firmware/libpn548ad_fw.so"; // set the default path to pn548ad firmware library + } + + if( NULL != pFirmwareLibHandle ) + { + status = dlclose( pFirmwareLibHandle ); // if the firmware library handle is not NULL, release the handle + pFirmwareLibHandle = NULL; + + dlerror( ); // clear existing errors + if( 0 != status ) + { + LOG_ERROR( "%s: dlclose() failed with status = %d \n", __FUNCTION__, status ); + break; + } + } + + pFirmwareLibHandle = dlopen( pathToLib, RTLD_LAZY ); // get a handle to firmware library + LOG_MESSAGE( "Opening library handle from %s\n", pathToLib ); + + if( NULL == pFirmwareLibHandle ) + { + LOG_ERROR( "%s: dlopen() failed \n", __FUNCTION__ ); + break; + } + dlerror( ); // clear existing errors + + pTempFirmwareImage = ( void * )dlsym( pFirmwareLibHandle, "gphDnldNfc_DlSeq" ); // get a pointer to the firmware library + + if( dlerror( ) || ( NULL == pTempFirmwareImage ) ) + { + LOG_ERROR( "%s: dlsym() failed, failed to load gphDnldNfc_DlSeq symbol \n", __FUNCTION__ ); + break; + } + *ppFirmwareImage = *( uint8_t ** )pTempFirmwareImage; // the returned pointer is a pointer to an uint8_t array + + pTempFirmwareImageLen = ( void * ) dlsym( pFirmwareLibHandle, "gphDnldNfc_DlSeqSz" ); // get a pointer to the firmware library length + + if( dlerror( ) || ( NULL == pTempFirmwareImageLen ) ) + { + LOG_ERROR( "%s: dlsym() failed, failed to load gphDnldNfc_DlSeqSz symbol \n", __FUNCTION__ ); + break; + } + *pFirmwareImageLen = ( uint16_t )( *( ( uint16_t * )pTempFirmwareImageLen ) ); // the returned pointer is a pointer to the length of the image + + } while( FALSE ); +} + +/*========================================================================================================== +FUNCTION + send_packet_packet_to_chip + +DESCRIPTION + sends the constructed packets to the NFC chip by calling ProcessCommand() from ftm_nfcnq.c + +PARAMETERS + pfirmware_download_context_t pDownloadContext - pointer to structure containing all the + information required + +RETURN VALUE + void + +==========================================================================================================*/ +static void send_packet_packet_to_chip( pfirmware_download_context_t pDownloadContext ) +{ + int status = -1; + + status = ProcessCommand( &pDownloadContext->packetToSend ); // call ProcessCommand() from ftm_nfcnq.c + if( 0 != status ) + { + LOG_ERROR( "%s: ProcessCommand() failed with status = %d \n", __FUNCTION__, status ); + } +} + +/*========================================================================================================== +FUNCTION + calculate_crc16 + +DESCRIPTION + calculates CRC-16-CCITT of a given buffer with a given length with seed value of 0xffff(Hex) + +PARAMETERS + uint8_t *pBuff - buffer for CRC-16-CCITT calculation + uint16_t buffLen - length of buffer for CRC-16-CCITT calculation + +RETURN VALUE + uint16_t - calculated CRC-16-CCITT value of buffer + +==========================================================================================================*/ +static uint16_t calculate_crc16( uint8_t *pBuff, uint16_t buffLen ) +{ + uint16_t temp = 0; + uint16_t value = 0; + uint16_t crc = 0xffff; // seed value + uint32_t i = 0; + + if ( ( NULL == pBuff ) || ( 0 == buffLen ) ) + { + LOG_ERROR( "%s: Invalid parameters \n", __FUNCTION__ ); + } + else + { + for( i = 0; i < buffLen; i++ ) + { + value = 0x00ffU & ( uint16_t )pBuff[ i ]; + temp = ( crc >> 8U ) ^ value; + crc = ( crc << 8U ) ^ crcTable[ temp ]; + } + } + + return crc; +} + +/*========================================================================================================== +FUNCTION + insert_crc16 + +DESCRIPTION + inserts the calculated CRC-16-CCITT value into the end of the buffer + +PARAMETERS + pfirmware_download_context_t pDownloadContext - pointer to structure containing all the + information required + +RETURN VALUE + void + +==========================================================================================================*/ +static void insert_crc16( pfirmware_download_context_t pDownloadContext ) +{ + uint16_t crcValueToWrite = 0; + uint8_t *crcValueInBytes = NULL; + + /* get CRC-16-CCITT value of packet and convert it into 2 bytes */ + crcValueToWrite = calculate_crc16( &pDownloadContext->packetToSend, + pDownloadContext->headerPlusPayloadLen ); + crcValueInBytes = ( uint8_t * )&crcValueToWrite; + + /* insert crc value into last 2 bytes of the packet */ + if( pDownloadContext->packetToSend.payloadLen < ( FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN - 1 )) + { + pDownloadContext->packetToSend.payloadBuff[ pDownloadContext->packetToSend.payloadLen ] = crcValueInBytes[ 1 ]; + pDownloadContext->packetToSend.payloadBuff[ pDownloadContext->packetToSend.payloadLen + 1 ] = crcValueInBytes[ 0 ]; + } + else + { + LOG_ERROR( "%s: Packet to send payloadLen more than maximum payloadBuff size \n", __FUNCTION__ ); + } +} + +/*========================================================================================================== +FUNCTION + read_response_from_chip + +DESCRIPTION + reader thread that constantly checks for responses from NFC chip, checks the integrity of the + response packets by matching the CRC-16-CCITT values and signals the semaphore held by + the call to ProcessCommand() + +PARAMETERS + pfirmware_download_context_t pDownloadContext - pointer to structure containing all the + information required + +RETURN VALUE + void + +==========================================================================================================*/ +static void read_response_from_chip( pfirmware_download_context_t pDownloadContext ) +{ + uint8_t lenRead = 0; + uint8_t *pPacketReceived = NULL; + uint16_t calculatedCrcValue = 0; + uint16_t crcValueFromResponse = 0; + + do + { + if( fdNfc < 0 ) + { + LOG_ERROR( "%s: Invalid handle \n", __FUNCTION__ ); + break; + } + + lenRead = read( fdNfc, &pDownloadContext->packetReceived, // get the response packet header + FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN ); + + if( 0 == lenRead ) + { + LOG_ERROR( "%s: Error reading response packet header \n", __FUNCTION__ ); + break; + } + else + { + pDownloadContext->totalPacketLen = lenRead; + } + + lenRead = read( fdNfc, &pDownloadContext->packetReceived.payloadBuff, // get the rest fo the response packet + ( pDownloadContext->packetReceived.payloadLen + + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN ) ); + + if( 0 == lenRead ) + { + LOG_ERROR( "%s: Error reading response packet payload \n", __FUNCTION__ ); + break; + } + else + { + pDownloadContext->totalPacketLen += lenRead; // update the total length of the received packet + } + + calculatedCrcValue = calculate_crc16( &pDownloadContext->packetReceived, // calculate the CRC-16-CCITT value of the received packet + ( pDownloadContext->packetReceived.payloadLen + + FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN ) ); + + /* convert crc value from the response packet to an uint16_t */ + if( pDownloadContext->packetReceived.payloadLen < ( FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN - 1 )) + { + crcValueFromResponse = pDownloadContext->packetReceived.payloadBuff[ pDownloadContext->packetReceived.payloadLen ]; + crcValueFromResponse <<= 8; + crcValueFromResponse |= pDownloadContext->packetReceived.payloadBuff[ pDownloadContext->packetReceived.payloadLen + 1 ]; + } + else + { + LOG_ERROR( "%s: Packet received payloadLen more than maximum payloadBuff size \n", __FUNCTION__ ); + } + + if( calculatedCrcValue != crcValueFromResponse ) // compare the CRC-16-CCITT values + { + LOG_ERROR( "%s: CRC-16-CCITT values do not match, discarding packet \n", __FUNCTION__ ); + break; + } + else + { + sem_post( &sRspReady ); // signal the semaphore for subsequent packets to be sent + } + + } while( FALSE == pDownloadContext->fExitReadThread ); // exit only when the flag is set +} + +/*========================================================================================================== +FUNCTION + get_device_firmware_version + +DESCRIPTION + sends the get-firmware-version command (0xF1) to the device and outputs the firmware version of + the device + +PARAMETERS + pfirmware_download_context_t pDownloadContext - pointer to structure containing all the + information required + +RETURN VALUE + void + +==========================================================================================================*/ +static void get_device_firmware_version( pfirmware_download_context_t pDownloadContext ) +{ + uint8_t getFirmwareVersionCommand[ ] = { 0x00, 0x04, 0xF1, 0x00, 0x00, 0x00 }; // command to get firmware version on device + uint8_t firmwareMajorVersion = 0; + uint8_t firmwareMinorVersion = 0; + + pDownloadContext->headerPlusPayloadLen = + sizeof( getFirmwareVersionCommand ) / sizeof( getFirmwareVersionCommand[ 0 ] ); + + memcpy( &pDownloadContext->packetToSend, &getFirmwareVersionCommand, // construct the command packet + ( pDownloadContext->headerPlusPayloadLen ) ); + + insert_crc16( pDownloadContext ); // insert the CRC-16-CCITT value + + send_packet_packet_to_chip( pDownloadContext ); // send the command packet to NFC chip + + /* continues from here once the reader thread reads the response and flags the semaphore, + the last 2 bytes of the get version response payload contains the firmware version currently on the device */ + firmwareMajorVersion = pDownloadContext->packetReceived.payloadBuff[ pDownloadContext->packetReceived.payloadLen - 1 ]; + firmwareMinorVersion = pDownloadContext->packetReceived.payloadBuff[ pDownloadContext->packetReceived.payloadLen - 2 ]; + + if(chip_version == 0x51 || chip_version == 0x50 || chip_version == 0x41 || chip_version == 0x40 ) + LOG_INFORMATION( "Firmware version: 11.%02X.%02X\n", firmwareMajorVersion, firmwareMinorVersion ); + else + LOG_INFORMATION( "Firmware version: 10.%02X.%02X\n", firmwareMajorVersion, firmwareMinorVersion ); +} + +/*========================================================================================================== +FUNCTION + build_first_packet + +DESCRIPTION + constructs the first packet to be sent to the NFC chip + +PARAMETERS + pfirmware_download_context_t pDownloadContext - pointer to structure containing all the + information required + +RETURN VALUE + void + +==========================================================================================================*/ +static void build_first_packet( pfirmware_download_context_t pDownloadContext ) +{ + memset( pDownloadContext->packetToSend.payloadBuff, 0, // initialise the payload buffer to zero + FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN ); + + memcpy( &pDownloadContext->packetToSend, // copy the first chunk from the firmware library to the packet + pDownloadContext->pFirmwareImage, + pDownloadContext->headerPlusPayloadLen ); + + insert_crc16( pDownloadContext ); // insert the CRC-16-CCITT value +} + +/*========================================================================================================== +FUNCTION + build_next_packet + +DESCRIPTION + constructs subsequent packets required to be sent to the NFC chip + +PARAMETERS + pfirmware_download_context_t pDownloadContext - pointer to structure containing all the + information required + +RETURN VALUE + void + +==========================================================================================================*/ +static void build_next_packet( pfirmware_download_context_t pDownloadContext ) +{ + /* for chunks from library that are larger than 256 bytes, the packets have to be fragmented */ + if( pDownloadContext->bytesLeftToSend > FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN ) + { + pDownloadContext->headerPlusPayloadLen = FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN + // length of header plus the payload for CRC-16-CCITT calculation + FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN; + + pDownloadContext->totalPacketLen = FIRMWARE_DOWNLOAD_MAX_PACKET_LEN; // length of the entire packet to be sent + + pDownloadContext->packetToSend.fFragmentedPacket = FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_SET; // set the fragment flag as the first byte + + pDownloadContext->packetToSend.payloadLen = FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN; // insert the payload length in the second byte + + memcpy( ( &pDownloadContext->packetToSend.payloadBuff ), // copy payload from firmware library + &pDownloadContext->pFirmwareImage[ pDownloadContext->readIndexFromLib ], + FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN ); + + pDownloadContext->readIndexFromLib += FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN; // update the buffer index used to read from firmware library + + pDownloadContext->bytesLeftToSend -= FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN; // update the number of bytes left to send from the chunk + } + + /* for chunks from library that are smaller than 256 bytes, no fragmentation needed */ + else + { + pDownloadContext->headerPlusPayloadLen = pDownloadContext->bytesLeftToSend + // length of header plus the payload for CRC-16-CCITT calculation + FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN; + + pDownloadContext->totalPacketLen = pDownloadContext->bytesLeftToSend + // length of the entire packet to be sent + FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN + + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN; + + pDownloadContext->packetToSend.fFragmentedPacket = FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_NONE; // set the fragment flag to none as the first byte + + pDownloadContext->packetToSend.payloadLen = pDownloadContext->bytesLeftToSend; // insert the payload length in the second byte + + memcpy( ( &pDownloadContext->packetToSend.payloadBuff ), // copy payload from firmware library + &pDownloadContext->pFirmwareImage[ pDownloadContext->readIndexFromLib ], + pDownloadContext->bytesLeftToSend ); + + pDownloadContext->readIndexFromLib += pDownloadContext->bytesLeftToSend; // update the buffer index used to read from firmware library + + pDownloadContext->bytesLeftToSend = 0; // most likely the last fragment from the chunk + } + + insert_crc16( pDownloadContext ); +} + +/*========================================================================================================== +FUNCTION + process_packets_to_send + +DESCRIPTION + determines if the incoming packet is the first one or any subsequent ones and process them + accordingly + +PARAMETERS + pfirmware_download_context_t pDownloadContext - pointer to structure containing all the + information required + +RETURN VALUE + void + +==========================================================================================================*/ +static void process_packets_to_send( pfirmware_download_context_t pDownloadContext ) +{ + uint8_t firstChunkLenFromLib = 0; + uint16_t nextChunkLenFromLib = 0; + uint16_t buffIndex = pDownloadContext->readIndexFromLib; + + if( TRUE == pDownloadContext->fFirstPacket ) + { + pDownloadContext->fFirstPacket = FALSE; // indicates that the first packet has been processed + + firstChunkLenFromLib = pDownloadContext->pFirmwareImage[ 1 ] + // length of the first chunk read from firmware library + FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN; + + pDownloadContext->totalPacketLen = firstChunkLenFromLib + // length of the entire packet to send + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN; + + pDownloadContext->readIndexFromLib += firstChunkLenFromLib; // update the buffer index used to read from firmware library + + pDownloadContext->headerPlusPayloadLen = firstChunkLenFromLib; // length of header plus the payload for CRC-16-CCITT calculation + + build_first_packet( pDownloadContext ); // build the first packet + + send_packet_packet_to_chip( pDownloadContext ); // send the packet to the NFC chip + } + else if( FALSE == pDownloadContext->fFirstPacket ) + { + nextChunkLenFromLib = pDownloadContext->pFirmwareImage[ buffIndex ]; // length of next chunk read from the firmware library + + /* length of next chunk is stored in 2 bytes in the firmware library */ + nextChunkLenFromLib <<= 8; + nextChunkLenFromLib |= pDownloadContext->pFirmwareImage[ buffIndex + 1 ]; + + buffIndex += 2; // add 2 bytes to the buffer index after length of next chunk is read + + pDownloadContext->readIndexFromLib = buffIndex; // update the buffer index used to read from firmware library + + pDownloadContext->bytesLeftToSend = nextChunkLenFromLib; // number of bytes left on the chunk to be sent to the chip + + while( pDownloadContext->bytesLeftToSend > 0 ) // constructs and sends packets as long as there are bytes left in the chunk + { + build_next_packet( pDownloadContext ); + send_packet_packet_to_chip( pDownloadContext ); + } + } + else + { + LOG_ERROR( "%s: Should not reach this point \n", __FUNCTION__ ); + } +} + +/*========================================================================================================== +FUNCTION + ftm_nfc_dispatch_nq_fwdl + +DESCRIPTION + called by main() in ftm_main.c to start the firmware download routine + +PARAMETERS + none + +RETURN VALUE + void + +==========================================================================================================*/ +void ftm_nfc_dispatch_nq_fwdl( void ) +{ + int status = 0; + + char *pathToLib = NULL; + uint8_t *pFirmwareImage = NULL; + uint16_t firmwareImageLen = 0; + + uint8_t *pNextChunkFromLib = NULL; + uint16_t nextChunkLenFromLib = 0; + uint16_t totalBytesReadFromLib = 0; + uint16_t readIndexFromLib = 0; + union nqx_uinfo nqx_info; + pthread_t readerThread; + + firmware_download_context_t downloadContext = { 0 }; + pfirmware_download_context_t pDownloadContext = &downloadContext; + pDownloadContext->fFirstPacket = TRUE; + + + do + { + if( !fdNfc ) + { + status = ftm_nq_nfc_open( ); // get a handle to the kernel driver + if( status < 0 ) + { + LOG_ERROR( "\n%s: ftm_nq_nfc_open() failed with status = %d \n", __FUNCTION__, status ); + break; + } + + status = ftm_nfc_hw_reset( ); // reset NFC hardware + if( status < 0 ) + { + LOG_ERROR( "%s: ftm_nq_nfc_reset() failed with status = %d \n", __FUNCTION__, status ); + break; + } + + nqx_info.i = ioctl( fdNfc, NFCC_GET_INFO, 0 ); + if( nqx_info.i < 0 ) + { + LOG_ERROR( "%s: nqnfcinfo not enabled, info = %d \n", __FUNCTION__, nqx_info.i ); + } + chip_version = nqx_info.info.chip_type; + LOG_INFORMATION( "\n NQ Chip ID : %x\n", chip_version); + } + + status = pthread_create( &readerThread, NULL, // create a reader thread + &read_response_from_chip, pDownloadContext ); + if( 0 != status ) + { + LOG_ERROR( "%s: pthread_create() failed with status = %d \n", __FUNCTION__, status ); + break; + } + + load_firmware_from_library( pathToLib, &pFirmwareImage, &firmwareImageLen ); // get a pointer to firmware library image and get its length + if( ( NULL == pFirmwareImage ) || ( 0 == firmwareImageLen ) ) + { + LOG_ERROR( "%s: Firmware library image extraction failed\n", __FUNCTION__ ); + break; + } + + LOG_MESSAGE( "Firmware major version number: %02X\n", pFirmwareImage[ 5 ] ); + LOG_MESSAGE( "Firmware minor version number: %02X\n", pFirmwareImage[ 4 ] ); + LOG_MESSAGE( "Firmware library image length: %d\n", firmwareImageLen ); + LOG_MESSAGE( "Firmware library image pointer: %X\n", ( uintptr_t )pFirmwareImage ); + + pDownloadContext->pFirmwareImage = pFirmwareImage; + pDownloadContext->firmwareImageLen = firmwareImageLen; + + status = ioctl( fdNfc, NFC_SET_PWR, FIRMWARE_MODE ); // set NFCC to firmware download mode + if( 0 != status ) + { + LOG_ERROR( "%s: Failed to set firmware pin high.\n", __FUNCTION__ ); + break; + } + + LOG_INFORMATION( "\nBefore firmware update...\n" ); + get_device_firmware_version( pDownloadContext ); // get device version before loading firmware + + LOG_INFORMATION( "\nSending firmware packets... Please wait\n" ); + while( pDownloadContext->readIndexFromLib < pDownloadContext->firmwareImageLen ) + { + process_packets_to_send( pDownloadContext ); // build and send download packets with payload from the firmware library image + } + + LOG_INFORMATION( "All packets sent!\n\n" ); + + pDownloadContext->fExitReadThread = TRUE; // set flag to indicate that reader thread is safe to exit + + LOG_INFORMATION( "After firmware update...\n" ); + get_device_firmware_version( pDownloadContext ); // get device version number after loading firmware + + LOG_MESSAGE( "Waiting for reader thread to terminate...\n" ); + pthread_join( readerThread, NULL ); // wait for reader thread to terminate + LOG_MESSAGE( "Reader thread terminated!\n" ); + + LOG_MESSAGE( "Resetting NFCC...\n" ); + + status = ftm_nfc_hw_reset( ); // reset the NFC hardware which resets the firmware pin as well + if( status < 0 ) + { + LOG_ERROR( "%s: ftm_nfc_hw_reset() failed with status = %d \n", __FUNCTION__, status ); + break; + } + + status = ftm_nq_nfc_close( ); // release the handle to the kernel driver + if( 0 != status ) + { + LOG_ERROR( "%s: ftm_nq_nfc_close() failed with status = %d \n", __FUNCTION__, status ); + } + + LOG_INFORMATION( "All done!\n\n" ); + + } while( FALSE ); + +} diff --git a/feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.h b/feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.h new file mode 100755 index 000000000..b8f308dd7 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfcnq_fwdl.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2016 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + * Not a Contribution. + * Apache license notifications and license are retained + * for attribution purposes only. + */ + +/* + * Copyright (C) 2015 NXP Semiconductors + * The original Work has been changed by NXP Semiconductors. + * + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*========================================================================= + FTM NFC NQ Firmware Download Header File + Description + This file contains the declarations of the functions and various + definitions used to download firmware onto the NQ Chip. +===========================================================================*/ + +#include +#include +#include +#include +#include +#include + +#define FALSE ( 0 ) +#define TRUE ( !FALSE ) + +#define FIRMWARE_DOWNLOAD_MAX_PACKET_LEN ( 0x100U ) // maximum length for a download packet +#define FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN ( 0x02U ) // length of the header +#define FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN ( 0x02U ) // length of CRC-16-CCITT value +#define FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN FIRMWARE_DOWNLOAD_MAX_PACKET_LEN - \ + FIRMWARE_DOWNLOAD_PACKET_HEADER_LEN - \ + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN + +/* Values for the first byte of each packet, indicates if the packet is fragmented */ +#define FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_NONE ( 0x00U ) // not fragmented +#define FIRMWARE_DOWNLOAD_PACKET_FRAG_FLAG_SET ( 0x04U ) // fragmented packet, next packet is a part of this one + +extern sem_t sRspReady; // semaphore used by reader thread +extern int fdNfc; // a handle to the kernel driver + +typedef uint8_t bool_t; + +/* structure of the packet to be sent or received */ +typedef struct firmware_download_packet +{ + uint8_t fFragmentedPacket; // flag to indicate if the packet is fragmented + uint8_t payloadLen; // length of payload + uint8_t payloadBuff[ FIRMWARE_DOWNLOAD_PACKET_MAX_PAYLOAD_LEN + + FIRMWARE_DOWNLOAD_PACKET_CRC16_LEN ]; // buffer containing the payload and CRC-16-CCITT value +} firmware_download_packet_t, *pfirmware_download_packet_t; + +/* structure that contains all the other information about the packets */ +typedef struct firmware_download_context +{ + const uint8_t *pFirmwareImage; // pointer to the firmware image library + uint16_t firmwareImageLen; // length of the firmware image + + uint8_t headerPlusPayloadLen; // header and payload length of a packet for CRC calculation + uint16_t readIndexFromLib; // index used to read from the firmware library + uint16_t bytesLeftToSend; // number of bytes left to send when the chunk read is fragmented + uint16_t totalPacketLen; // total length of packet to be sent or received + bool_t fFirstPacket; // flag to indicate if it is the first packet + bool_t fExitReadThread; // flag to indicate if reader thread is safe to exit + firmware_download_packet_t packetToSend; // contains information about packet to be sent + firmware_download_packet_t packetReceived; // contains information about packet from response received +} firmware_download_context_t, *pfirmware_download_context_t; + + + +/** + + Firmware download packet format + + ----------------------------------------------------------------------------------------------------- + | Header | Payload | CRC-16-CCITT value | + ----------------------------------------------------------------------------------------------------- + | Fragment flag | Payload length | Command/Response | Data | CRC-16-CCITT value | + ----------------------------------------------------------------------------------------------------- + | 1 byte | 1 byte | 1 byte | n bytes | 2 bytes | + ----------------------------------------------------------------------------------------------------- + + + Firmware library image format + + --------------------------------------------------------------------------------- ---------------------------------- + | 0x00 | First chunk length | First chunk | Next chunk length | Next chunk | ... | Last chunk length | Last chunk | + --------------------------------------------------------------------------------- ---------------------------------- + | 1 byte | 1 byte | n bytes | 2 bytes | n bytes | ... | 2 bytes | n bytes | + --------------------------------------------------------------------------------- ---------------------------------- + +*/ diff --git a/feeds/wifi-ax/ftm/src/ftm_nfcnq_test.c b/feeds/wifi-ax/ftm/src/ftm_nfcnq_test.c new file mode 100755 index 000000000..7581ac8ff --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfcnq_test.c @@ -0,0 +1,461 @@ +/* + * Copyright (c) 2017 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + */ + +#include +#include "ftm_nfcnq.h" +#include "ftm_nfcnq_test.h" + +/* Global variables */ +pthread_t clientThread; +PNCI_MESSAGE pNCIMessage; +char *progname; + +/*============================================================================== +FUNCTION + eseSpiTest + +DESCRIPTION + Send APDU for eSE SPI HLOS test + +PARAMETERS + int argc - argument count + char **argv - argument vector + +RETURN VALUE + void + +=============================================================================*/ +void eseSpiTest(int argc, char **argv ) +{ + int ret = 0; + int test_mode = 0; + unsigned char i = 0; + int fp = 0; + int choice = 0; + unsigned char send_APDU[] = {0x5A,0x00,0x05,0x00,0xA4,0x04,0x00,0x00,0xA5}; + int size_APDU = 0; + unsigned char recv_response[259] = {0}; + progname = basename(argv[2]); + test_mode = getopt(argc, argv, "01"); + size_APDU = sizeof(send_APDU); + + LOG_INFORMATION("\n### eSE SPI test ###\n"); + + if(test_mode == '0') + { + choice = 0; + LOG_INFORMATION("\nInterrupt Mode test\n"); + } + else + { + choice = 1; + LOG_INFORMATION("\nPoll Mode test(default)\n"); + } + + do + { + //open module + if ((ret = (fp = open("/dev/ese", O_RDWR))) < 0) + { + LOG_INFORMATION("eSE open error retcode = %d, errno = %d\n", ret, errno); + LOG_INFORMATION("\n... eSE SPI Test requires modified boot and TZ image ..."); + break; + } + LOG_INFORMATION("eSE open : Ret = %2d\n", ret); + + //enable the logs + ioctl(fp, ESE_SET_DBG, 1); + //hardware reset + ioctl(fp, ESE_SET_PWR, 1); + + ioctl(fp, ESE_SET_MODE, choice); + + //write one APDU + ret = write(fp, send_APDU, sizeof(send_APDU)); + if (ret < 0) + { + LOG_INFORMATION("ese write error retcode = %d, errno = %d\n", ret, errno); + break; + } + LOG_INFORMATION("ese Write : Ret = %.2X \n", ret); + LOG_INFORMATION("APDU sent to eSE: "); + for (i=0; inci_data, -1, MAX_CMD_LEN); + memcpy(nfc_pkt->nci_data, &buffer[rows], payloadlen); + ret = ProcessCommand( nfc_pkt->nci_data ); + if( ret == -1 ) // wait finished, not signalled? + { + LOG_ERROR( "Waited for NCI NTF/DATA timeout\n" ); + } + } +} + +/*============================================================================== +FUNCTION + usage + +DESCRIPTION + Print usage information for test + +PARAMETERS + +RETURN VALUE + void + +=============================================================================*/ +void usage() +{ + LOG_INFORMATION("\nUsage:"); + LOG_INFORMATION(" %s [-n] [-e] [-d] [h] \n", progname); + LOG_INFORMATION(" %s -n ..for NFC test only\n", progname); + LOG_INFORMATION(" %s -e ..for eSE SPI test only\n \t-0 ..Interrupt Mode\n \t-1 ..Poll Mode\n", progname); + LOG_INFORMATION(" %s -d ..for eSE DWP test only\n", progname); + LOG_INFORMATION(" %s -h HELP\n", progname); + LOG_INFORMATION(" %s default NFC test only\n", progname); +} + +/*============================================================================== +FUNCTION + nfc_ese_pwr + +DESCRIPTION + Set ESE power using NFC driver + +PARAMETERS + +RETURN VALUE + void + +=============================================================================*/ +void nfc_ese_pwr() +{ + int ret; + ret = ioctl( fdNfc, NFC_ESE_SET_PWR, POWER_ON ); // turn the chip on + if( ret != 0 ) + { + LOG_INFORMATION("Can't find ESE GPIO in NFC driver: "); + LOG_INFORMATION("ret=%d\n",ret); + } +} + + + +/*============================================================================== +FUNCTION + ftm_nfc_dispatch_nq_test + +DESCRIPTION + called by main() in ftm_main.c to start the nfc test routine + +PARAMETERS + int argc - argument count + char **argv - argument vector + +RETURN VALUE + void + +=============================================================================*/ +void ftm_nfc_dispatch_nq_test( int argc, char **argv ) +{ + int cmds = 0; + unsigned int chip_version = 0x00; + unsigned int major_version = 0x00; + unsigned int minor_version = 0x00; + unsigned int rom_version = 0x00; + char firmware_version[10]; + struct timespec time_sec; + int type_of_test = 0; + int default_test = 0; + int status = 0; + + union nqx_uinfo nqx_info; + pthread_t readerThread; + + do + { + if( !fdNfc ) + { + status = ftm_nq_nfc_open( ); // get a handle to the kernel driver + if( status < 0 ) + { + LOG_ERROR( "\n%s: ftm_nq_nfc_open() failed with status = %d \n", __FUNCTION__, status ); + break; + } + + status = ftm_nfc_hw_reset( ); // reset NFC hardware + if( status < 0 ) + { + LOG_ERROR( "%s: ftm_nq_nfc_reset() failed with status = %d \n", __FUNCTION__, status ); + break; + } + + nqx_info.i = ioctl( fdNfc, NFCC_GET_INFO, 0 ); + if( nqx_info.i < 0 ) + { + LOG_ERROR( "%s: nqnfcinfo not enabled, info = %d \n", __FUNCTION__, nqx_info.i ); + } + + chip_version = nqx_info.info.chip_type; + rom_version = nqx_info.info.rom_version; + major_version = nqx_info.info.fw_major; + minor_version = nqx_info.info.fw_minor; + + LOG_INFORMATION( "\n NQ Chip ID : %x\n", chip_version); + snprintf(firmware_version, 10, "%02x.%02x.%02x", rom_version, major_version, minor_version); + LOG_INFORMATION(" Firmware version : %s\n\n", firmware_version); + + + if(sem_init(&sRspReady, 0, 0) != 0) + { + LOG_ERROR("NFC FTM :semaphore_halcmd_complete creation failed \n"); + break; + } + if(sem_init(&sRfNtf, 0, 0) != 0) + { + LOG_ERROR("NFC FTM :semaphore_halcmd_complete creation failed \n"); + break; + } + + pNCIMessage = ( PNCI_MESSAGE ) nciReplyMessage; + status = pthread_create( &clientThread, NULL, &nfc_read_thread, NULL ); // Start the Read Thread + + if( status != 0 ) // successful? + { + LOG_ERROR("nqnfc %s: pthread_create( nfc_read_thread ) failed with ret = %d \n", __func__, status ); + break; + } + + status = ftm_nfc_nq_vs_nxp( ); + if( status < 0 ) // Not an NQ Chip? + { + LOG_ERROR("ERROR NOT A KNOWN NQ Chip \n" ); + } + } + + progname = basename(argv[1]); + type_of_test = getopt(argc, argv, "nedhf"); + + switch (type_of_test) { + case 'n': + LOG_INFORMATION("NFC test only\n"); + break; + case 'e': + LOG_INFORMATION("eSE SPI test only\n"); + nfc_ese_pwr(); + ese_spi_test = 1; + eseSpiTest(argc, argv); + break; + case 'd': + LOG_INFORMATION("eSE DWP test only\n"); + ese_dwp_test = 1; + eseDwpTest(); + break; + case 'h': + usage(); + break; + default: + usage(); + default_test = 1; + LOG_INFORMATION("\nDefault NFC test only\n"); + } + + if(ese_dwp_test || ese_spi_test) + break; + + if(type_of_test == 'n' || default_test) + { + switch(whatNQChip) + { + case NQ_210: + case NQ_220: + cmds = sizeof(NQ220_cmds) / sizeof(NQ220_cmds[0]); + sendcmds(NQ220_cmds, cmds); + break; + case NQ_310: + case NQ_330: + cmds = sizeof(NQ330_cmds) / sizeof(NQ330_cmds[0]); + sendcmds(NQ330_cmds, cmds); + break; + default: + LOG_INFORMATION( "Chip not supported, taking NQ330 as default\n "); + cmds = sizeof(NQ330_cmds) / sizeof(NQ330_cmds[0]); + sendcmds(NQ330_cmds, cmds); + break; + } + + LOG_INFORMATION("\n<<>> Waiting for TAG detect or 20sec timeout <<>> ...\n"); + status = clock_gettime( CLOCK_REALTIME, &time_sec ); + time_sec.tv_sec += NFC_NTF_TIMEOUT; + status = sem_timedwait( &sRfNtf, &time_sec ); //start waiting + if (status <0) { + LOG_INFORMATION("\n No NFC Tag detected, continue ...\n"); + } + } + + status = ftm_nq_nfc_close( ); // release the handle to the kernel driver + if( 0 != status ) + { + LOG_ERROR( "%s: ftm_nq_nfc_close() failed with status = %d \n", __FUNCTION__, status ); + } + + } while( FALSE ); + +} diff --git a/feeds/wifi-ax/ftm/src/ftm_nfcnq_test.h b/feeds/wifi-ax/ftm/src/ftm_nfcnq_test.h new file mode 100755 index 000000000..d2c73ed5d --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfcnq_test.h @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2017 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + * Not a Contribution. + * Apache license notifications and license are retained + * for attribution purposes only. + * + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define ESE_MAGIC 0xEA +#define ESE_SET_PWR _IOW(ESE_MAGIC, 0x01, unsigned int) +#define ESE_SET_DBG _IOW(ESE_MAGIC, 0x02, unsigned int) +#define ESE_SET_MODE _IOW(ESE_MAGIC, 0x03, unsigned int) +#define NFC_ESE_SET_PWR _IOW(0xE9, 0x02, unsigned int) +#define NFC_ESE_GET_PWR _IOR(0xE9, 0x03, unsigned int) +#define NFC_NTF_TIMEOUT 20 + +/* Supported Protocols */ +#define NFC_PROTOCOL_UNKNOWN 0x00 /* Unknown */ +#define NFC_PROTOCOL_T1T 0x01 /* Type1Tag - NFC-A */ +#define NFC_PROTOCOL_T2T 0x02 /* Type2Tag - NFC-A */ +#define NFC_PROTOCOL_T3T 0x03 /* Type3Tag - NFC-F */ +#define NFC_PROTOCOL_ISO_DEP 0x04 /* Type 4A,4B - NFC-A or NFC-B */ +#define NFC_PROTOCOL_NFC_DEP 0x05 /* NFCDEP/LLCP - NFC-A or NFC-F */ + +#define MAX_CMD_LEN 255 +#define READ_SAMPLE_SIZE 258 +extern int fdNfc; // a handle to the kernel driver +extern uint8_t nciReplyMessage[ 255 ]; +extern NQ_CHIP_TYPE whatNQChip; +extern sem_t sRspReady; +extern int ftm_nfc_nq_vs_nxp( void ); +int ese_dwp_test = 0; +int ese_spi_test = 0; +void sendcmds(uint8_t buffer[][255], int no_of_cmds); +void printTecnologyDetails(char technology, char protocol); +sem_t sRfNtf; + +struct ese_spi_platform_data +{ + unsigned int use_pwr_req; + unsigned int pwr_req; + unsigned int ese_intr; +}; + +/* + * Enum definition contains RF technology modes supported. + * This information is a part of RF_DISCOVER_NTF or RF_INTF_ACTIVATED_NTF. + */ +typedef enum +{ + NFC_NFCA_Poll = 0x00, /* Nfc A Technology in Poll Mode */ + NFC_NFCB_Poll = 0x01, /* Nfc B Technology in Poll Mode */ + NFC_NFCF_Poll = 0x02, /* Nfc F Technology in Poll Mode */ + NFC_NFCA_Active_Poll = 0x03, /* Nfc A Technology in Active Poll Mode */ + NFC_NFCF_Active_Poll = 0x05, /* Nfc F Technology in Active Poll Mode */ + NFC_NFCISO15693_Poll = 0x06, /* Nfc ISO15693 Technology in Poll Mode */ + NFC_NxpProp_NFCHID_Poll = 0x70, /* Nfc Hid Technology in Poll Mode */ + NFC_NxpProp_NFCEPFGEN2_Poll = 0x71, /* Nfc EpcGen2 Technology in Poll Mode */ + NFC_NxpProp_NFCKOVIO_Poll = 0x72, /* Nfc Kovio Technology in Poll Mode */ + NFC_NFCA_Listen = 0x80, /* Nfc A Technology in Listen Mode */ + NFC_NFCB_Listen = 0x81, /* Nfc B Technology in Listen Mode */ + NFC_NFCF_Listen = 0x82, /* Nfc F Technology in Listen Mode */ + NFC_NFCA_Active_Listen = 0x83, /* Nfc A Technology in Active Listen Mode */ + NFC_NFCF_Active_Listen = 0x85, /* Nfc F Technology in Active Listen Mode */ + NFC_NFCISO15693_Active_Listen = 0x86 /* Nfc ISO15693 Technology in Listen Mode */ +} NFC_RfTechMode_t; + +uint8_t NQ330_cmds[][255] = +{ +{ 0x20,0x00,0x01,0x00 }, +{ 0x20,0x01,0x00}, +{ 0x2F,0x02,0x00 }, +{ 0x20,0x03,0x03,0x01,0xA0,0x0F }, +{ 0x20,0x03,0x03,0x01,0xA0,0xFC }, +{ 0x20,0x03,0x03,0x01,0xA0,0xF2 }, +{ 0x20,0x03,0x03,0x01,0xA0,0xD7 }, +{ 0x20,0x03,0x07,0x03,0xA0,0x02,0xA0,0x03,0xA0,0x04 }, +{ 0x20,0x02,0x09,0x02,0xA0,0x03,0x01,0x01,0xA0,0x04,0x01,0x06 }, +{ 0x20,0x02,0x0F,0x01,0xA0,0x0E,0x0B,0x11,0x01,0xC2,0xB2,0x00,0xB2,0x1E,0x1F,0x00,0xD0,0x0C }, +{ 0x20,0x02,0x05,0x01,0xA0,0xF2,0x01,0x01 }, +{ 0x20,0x03,0x03,0x01,0xA0,0xEC }, +{ 0x20,0x03,0x03,0x01,0xA0,0xD4 }, +{ 0x20,0x03,0x03,0x01,0xA0,0x14 }, +{ 0x20,0x02,0x2E,0x0E,0x28,0x01,0x00,0x21,0x01,0x00,0x30,0x01,0x08,0x31,0x01,0x03,0x32,0x01,0x60,0x38,0x01,0x01,0x33,0x04,0x01,0x02,0x03,0x04,0x54,0x01,0x06,0x50,0x01,0x02,0x5B,0x01,0x00,0x80,0x01,0x01,0x81,0x01,0x01,0x82,0x01,0x0E,0x18,0x01,0x01 }, +{ 0x20,0x02,0x05,0x01,0xA0,0x62,0x01,0x01 }, +{ 0x20,0x02,0x06,0x01,0xA0,0xF3,0x02,0x10,0x27 }, +{ 0x20,0x03,0x03,0x01,0xA0,0x85 }, +{ 0x21,0x01,0x07,0x00,0x01,0x01,0x03,0x00,0x01,0x05 }, +{ 0x20,0x02,0x05,0x01,0xA0,0xF1,0x01,0x00 }, +{ 0x20,0x03,0x03,0x01,0xA0,0x0F }, +{ 0x20,0x03,0x03,0x01,0xA0,0xEB }, +{ 0x20,0x00,0x01,0x00 }, +{ 0x20,0x01,0x00}, +{ 0x20,0x03,0x02,0x01,0x00 }, +{ 0x20,0x03,0x02,0x01,0x29 }, +{ 0x20,0x03,0x02,0x01,0x61 }, +{ 0x20,0x03,0x02,0x01,0x60 }, +{ 0x20,0x02,0x0F,0x01,0xA0,0x0E,0x0B,0x11,0x01,0xC2,0xB2,0x00,0xB2,0x1E,0x1F,0x00,0xD0,0x0C }, +{ 0x21,0x00,0x0D,0x04,0x04,0x03,0x02,0x05,0x03,0x03,0x03,0x02,0x01,0x80,0x01,0x80 }, +{ 0x20,0x03,0x07,0x03,0xA0,0xEC,0xA0,0xED,0xA0,0xD4 }, +{ 0x20,0x03,0x03,0x01,0xA0,0xEB }, +{ 0x20,0x03,0x03,0x01,0xA0,0xF0 }, +{ 0x22,0x01,0x02,0xC0,0x01 }, +{ 0x22,0x03,0x02,0xC0,0x00 }, +{ 0x20,0x03,0x03,0x01,0xA0,0x14 }, +{ 0x20,0x03,0x03,0x01,0xA0,0xEB }, +{ 0x20,0x03,0x03,0x01,0xA0,0x07 }, +{ 0x20,0x03,0x02,0x01,0x52 }, +{ 0x2F,0x15,0x01,0x02 }, +{ 0x21,0x03,0x07,0x03,0x80,0x01,0x81,0x01,0x82,0x01 }, +{ 0x21,0x06,0x01,0x00 }, +{ 0x2F,0x15,0x01,0x00 }, +{ 0x20,0x02,0x07,0x02,0x32,0x01,0x60,0x38,0x01,0x01 }, +{ 0x21,0x01,0x1B,0x00,0x05,0x01,0x03,0x00,0x01,0x03,0x01,0x03,0x00,0x41,0x04,0x01,0x03,0x00,0x41,0xA0,0x01,0x03,0x00,0x01,0x05,0x00,0x03,0xC0,0xC3,0x02 }, +{ 0x20,0x02,0x07,0x02,0x32,0x01,0x60,0x38,0x01,0x01}, +{ 0x21,0x03,0x19,0x0C,0x00,0x01,0x01,0x01,0x02,0x01,0x03,0x01,0x05,0x01,0x80,0x01,0x81,0x01,0x82,0x01,0x83,0x01,0x85,0x01,0x06,0x01,0x70,0x01} +}; + +uint8_t NQ330_ESE_DWP[][255] = +{ +{ 0x20,0x00,0x01,0x00 }, +{ 0x20,0x01,0x00}, +{ 0x20,0x02,0x05,0x01,0xA0,0xF2,0x01,0x01 }, +{ 0x22,0x00,0x01,0x01 }, +{ 0x22,0x01,0x2,0x01,0x01 }, +{ 0x20,0x04,0x06,0x03,0x01,0x01,0x02,0x01,0x01 }, +{ 0x03,0x00,0x03,0x81,0x02,0x01 }, +{ 0x03,0x00,0x03,0x81,0x02,0x04 }, +{ 0x03,0x00,0x03,0x81,0x02,0x07 }, +{ 0x21,0x01,0x1B,0x00,0x05,0x01,0x03,0x00,0x01,0x03,0x01,0x03,0x00,0x41,0x04,0x01,0x03,0x00,0x41,0xA0,0x01,0x03,0x00,0x01,0x05,0x00,0x03,0xC0,0xC3,0x02 }, +{ 0x21,0x03,0x19,0x0C,0x00,0x01,0x01,0x01,0x02,0x01,0x03,0x01,0x05,0x01,0x80,0x01,0x81,0x01,0x82,0x01,0x83,0x01,0x85,0x01,0x06,0x01,0x70,0x01}, +{ 0x03,0x00,0x07,0x99,0x50,0x00,0x70,0x00,0x00,0x01}, +{ 0x03,0x00,0x09,0x99,0x50,0x80,0xCA,0x00,0xFE,0x02,0xDF,0x21 } +}; + +uint8_t NQ220_cmds[][255] = +{ + { 0x20,0x00,0x01,0x00 }, + { 0x20,0x01,0x00 }, + { 0x2F,0x02,0x00 }, + { 0x20,0x03,0x03,0x01,0xA0,0x0F }, + { 0x20,0x03,0x07,0x03,0xA0,0x02,0xA0,0x03,0xA0,0x04 }, + { 0x20,0x02,0x05,0x01,0xA0,0x44,0x01,0x00 }, + { 0x20,0x02,0x0B,0x02,0xA0,0x66,0x01,0x00,0xA0,0x0E,0x03,0x02,0x09,0x00 }, + { 0x20,0x02,0x26,0x09,0xA0,0xEC,0x01,0x01,0xA0,0xED,0x01,0x03,0xA0,0x5E,0x01,0x01,0xA0,0x12,0x01,0x02,0xA0,0x40,0x01,0x01,0xA0,0xDD,0x01,0x2D,0xA0,0xF2,0x01,0x01,0xA0,0x96,0x01,0x01,0xA0,0x9F,0x02,0x08,0x08 }, + { 0x20,0x03,0x03,0x01,0xA0,0xEC }, + { 0x20,0x03,0x03,0x01,0xA0,0x14 }, + { 0x20,0x02,0x2E,0x0E,0x28,0x01,0x00,0x21,0x01,0x00,0x30,0x01,0x08,0x31,0x01,0x03,0x32,0x01,0x60,0x38,0x01,0x01,0x33,0x04,0x01,0x02,0x03,0x04,0x54,0x01,0x06,0x50,0x01,0x02,0x5B,0x01,0x00,0x80,0x01,0x01,0x81,0x01,0x01,0x82,0x01,0x0E,0x18,0x01,0x01 }, + { 0x20,0x02,0x05,0x01,0xA0,0x62,0x01,0x01 }, + { 0x20,0x02,0x06,0x01,0xA0,0xF3,0x02,0x10,0x27 }, + { 0x20,0x03,0x03,0x01,0xA0,0x85 }, + { 0x21,0x01,0x07,0x00,0x01,0x01,0x03,0x00,0x01,0x05 }, + { 0x20,0x02,0x05,0x01,0xA0,0xF1,0x01,0x00 }, + { 0x20,0x02,0x05,0x01,0xA0,0x91,0x01,0x01 }, + { 0x20,0x03,0x03,0x01,0xA0,0x0F }, + { 0x20,0x03,0x03,0x01,0xA0,0xEB }, + { 0x20,0x00,0x01,0x00 }, + { 0x20,0x01,0x00 }, + { 0x20,0x03,0x02,0x01,0x00 }, + { 0x20,0x03,0x02,0x01,0x29 }, + { 0x20,0x03,0x02,0x01,0x61 }, + { 0x20,0x03,0x02,0x01,0x60 }, + { 0x21,0x00,0x0D,0x04,0x04,0x03,0x02,0x05,0x03,0x03,0x03,0x02,0x01,0x80,0x01,0x80 }, + { 0x22,0x00,0x01,0x01 }, + { 0x20,0x04,0x06,0x03,0x01,0x01,0x02,0x01,0x01 }, + { 0x03,0x00,0x05,0x81,0x01,0x03,0x02,0xC0 }, + { 0x03,0x00,0x05,0x81,0x01,0x06,0x01,0x00 }, + { 0x03,0x00,0x03,0x81,0x02,0x01 }, + { 0x03,0x00,0x03,0x81,0x02,0x04 }, + { 0x20,0x03,0x05,0x02,0xA0,0xEC,0xA0,0xED }, + { 0x20,0x03,0x03,0x01,0xA0,0xEB }, + { 0x20,0x03,0x03,0x01,0xA0,0xF0 }, + { 0x20,0x03,0x05,0x02,0xA0,0xEC,0xA0,0xED }, + { 0x20,0x03,0x03,0x01,0xA0,0x14 }, + { 0x20,0x03,0x03,0x01,0xA0,0xEB }, + { 0x20,0x03,0x03,0x01,0xA0,0x07 }, + { 0x20,0x02,0x05,0x01,0xA0,0x07,0x01,0x03 }, + { 0x20,0x03,0x02,0x01,0x52 }, + { 0x21,0x01,0x16,0x00,0x04,0x01,0x03,0x00,0x01,0x03,0x01,0x03,0x00,0x41,0x04,0x01,0x03,0x00,0x41,0xA0,0x01,0x03,0x00,0x01,0x05 }, + { 0x20,0x02,0x0A,0x03,0x32,0x01,0x20,0x38,0x01,0x01,0x50,0x01,0x00 }, + { 0x21,0x03,0x07,0x03,0x80,0x01,0x81,0x01,0x82,0x01 }, + { 0x21,0x06,0x01,0x00 }, + { 0x20,0x02,0x17,0x01,0x61,0x14,0x46,0x66,0x6D,0x01,0x01,0x12,0x02,0x02,0x07,0xFF,0x03,0x02,0x00,0x13,0x04,0x01,0x64,0x07,0x01,0x03 }, + { 0x20,0x02,0x0A,0x03,0x32,0x01,0x60,0x38,0x01,0x01,0x50,0x01,0x02 }, + { 0x21,0x03,0x19,0x0C,0x00,0x01,0x01,0x01,0x02,0x01,0x03,0x01,0x05,0x01,0x80,0x01,0x81,0x01,0x82,0x01,0x83,0x01,0x85,0x01,0x06,0x01,0x70,0x01 } +}; diff --git a/feeds/wifi-ax/ftm/src/ftm_nfcqti.c b/feeds/wifi-ax/ftm/src/ftm_nfcqti.c new file mode 100755 index 000000000..cfe1a6ec7 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfcqti.c @@ -0,0 +1,724 @@ +/*========================================================================= + NFC FTM Source File +Description + This file contains the routines to communicate with the NFCC in FTM mode. + +Copyright (c) 2015 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. +===========================================================================*/ +/*=========================================================================== + Edit History +when who what, where, why +-------- --- ---------------------------------------------------------- +===========================================================================*/ +/*==========================================================================* +* INCLUDE FILES * +*==========================================================================*/ +#include "ftm_nfcqti.h" + +#define UNUSED(x) (void)(x) + +/*=========================================================================* +* file scope local defnitions * +*==========================================================================*/ +const hw_module_t* hw_module = NULL; +nfc_nci_device_t* dev = NULL; +uint8 hal_state = NCI_HAL_INIT, nfc_ftmthread = FALSE; +uint8 *nfc_cmd_buff = NULL, len = 0; +uint16 res_len = 0, async_msg_cnt = 0; +uint8 *response_buff = NULL; +static uint8 hal_opened = FALSE, wait_rsp = FALSE; +static uint8 async_msg_available = FALSE, ftm_data_rsp_pending = FALSE; +asyncdata *buff = NULL; +asyncdata *start = NULL; +/*I2C read/write*/ +static uint8 i2c_cmd_cnt = 0; +uint8 i2c_status=0,i2c_req_write = FALSE, i2c_req_read = FALSE; +uint8 i2c_num_of_reg_to_read = 0, i2c_reg_read_data[40]={0}, ii = 0; +pthread_mutex_t nfcftm_mutex = PTHREAD_MUTEX_INITIALIZER; +/*===================================================================================* +* Function Defnitions * +*===================================================================================*/ +/*==================================================================================== +FUNCTION nfc_ftm_hal_cback +DESCRIPTION + This is the call back function which will indicate if the nfc hal open is successful + or failed. +DEPENDENCIES + NIL +RETURN VALUE +none +SIDE EFFECTS + NONE +=====================================================================================*/ +static void nfc_ftm_cback(uint8 event, uint8 status) +{ + switch(event) + { + case HAL_NFC_OPEN_CPLT_EVT: + if(status == HAL_NFC_STATUS_OK) + { + /* Release semaphore to indicate that hal open is done + and change the state to write.*/ + hal_state = NCI_HAL_WRITE; + hal_opened = TRUE; + printf("HAL Open Success..state changed to Write \n"); + } + else + { + printf("HAL Open Failed \n"); + hal_state = NCI_HAL_ERROR; + hal_opened = FALSE; + } + sem_post(&semaphore_halcmd_complete); + break; + case HAL_NFC_CLOSE_CPLT_EVT: + printf("HAL_NFC_CLOSE_CPLT_EVT recieved..\n"); + break; + default: + printf ("nfc_ftm_hal_cback unhandled event %x \n", event); + break; + } +} +/*========================================================================================== +FUNCTION fill_async_data +DESCRIPTION +This function will store all the incoming async msgs( like ntfs and data from QCA1990) +in to a list to be committed further. +DEPENDENCIES + NIL +RETURN VALUE + NONE +SIDE EFFECTS + NONE +==============================================================================================*/ +void fill_async_data(uint16 data_len, uint8 *p_data) +{ + uint16 i = 0; + asyncdata *next_node = NULL; + printf("fill_async_data() function \n"); + /* Initialize a list which will store all async message untill they are sent*/ + if(buff == NULL) + { + /* first node creation*/ + buff = (asyncdata*)malloc(sizeof(asyncdata)); + if(buff) + { + start = buff; + buff->response_buff = (uint8*)malloc(data_len); + if(buff->response_buff) + { + memcpy(buff->response_buff, p_data, data_len); + buff->async_datalen = data_len; + buff->next = NULL; + async_msg_cnt = 0; + async_msg_cnt++; + } + else + { + printf("mem allocation failed while storing asysnc msg \n"); + } + } + else + { + printf("mem allocation failed while trying to make the async list \n"); + } + } + else + { + /* this is the case when some data is already present in the list which has not been sent yet*/ + next_node = (asyncdata*)malloc(sizeof(asyncdata)); + if(next_node) + { + next_node->response_buff = (uint8*)malloc(data_len); + if(next_node->response_buff) + { + memcpy(next_node->response_buff, p_data,data_len); + next_node->async_datalen = data_len; + next_node->next = NULL; + async_msg_cnt++; + while(buff->next != NULL) + { + buff = buff->next; + } + buff->next = next_node; + } + else + { + printf("mem allocation failed while storing asysnc msg \n"); + } + } + else + { + printf("mem allocation failed while trying to make the async list \n"); + } + } +} +/*====================================================================================================== +FUNCTION nfc_ftm_data_cback +DESCRIPTION + This is the call back function which will provide back incoming data from the QCA1990 + to nfc ftm. +DEPENDENCIES + NIL +RETURN VALUE + NONE +SIDE EFFECTS + NONE +========================================================================================================*/ +static void nfc_ftm_data_cback(uint16 data_len, uint8 *p_data) +{ + uint8 i = 0; + if(hal_opened == FALSE) + { + /* Reject data call backs untill HAL in initialized */ + return; + } + if((data_len == 0x00) || (p_data == NULL)) + { + printf("Error case : wrong data lentgh or buffer revcieved \n"); + return; + } + if((i2c_req_write == TRUE) || (i2c_req_read == TRUE)) + { + if(i2c_req_write) + { + /*check the incoming status*/ + if(p_data[0] != 0x00) /* 0x00 = Command executed successfully*/ + { + /* some error has occured in I2C write.Send the status code back now to pc app*/ + i2c_status = p_data[0]; + printf("Error occured in I2C write .. reporting to application..Error Code = %X \n", i2c_status); + hal_state = NCI_HAL_READ; + sem_post(&semaphore_halcmd_complete); + } + else + { + /*status is fine. Complete further requests as ftmdaemon is writing one by one*/ + if(len) + { + /*send further addr and value pair*/ + printf("I2C write status correct..sending next..\n"); + hal_state = NCI_HAL_WRITE; + } + else + { + /*All I2C write completed .Send final status to app*/ + i2c_status = p_data[0]; + printf(" All I2C write completed i2c_status = %X \n", i2c_status); + hal_state = NCI_HAL_READ; + } + sem_post(&semaphore_halcmd_complete); + } + } + else + { + /*I2C read rsp arrived . fill it in buffer if correct or report error if wrong*/ + if(p_data[0] != 0x00) + { + /* some error has occured in I2C read.Send the status code to app*/ + i2c_status = p_data[0]; + printf("Error occured in I2C read .. reporting to application..Error Code = %X \n", i2c_status); + hal_state = NCI_HAL_READ; + memset(nfc_cmd_buff, 0, len); + sem_post(&semaphore_halcmd_complete); + } + else + { + if(len) + { + /*send further addr to read*/ + i2c_status = p_data[0]; + i2c_reg_read_data[ii++] = p_data[1]; + hal_state = NCI_HAL_WRITE; + } + else + { + /*All I2C read completed .Send the read data back to pc app*/ + i2c_status = p_data[0]; + i2c_reg_read_data[ii++] = p_data[1]; + hal_state = NCI_HAL_READ; + ii = 0; + } + sem_post(&semaphore_halcmd_complete); + } + } + } + else + { + if(((p_data[0] & 0xF0) == 0x60 /*ntf packets*/) || ((p_data[0] & 0xF0) == 0x00)/*data packet rsps*/) + { + async_msg_available = TRUE; + pthread_mutex_lock(&nfcftm_mutex); + fill_async_data(data_len, p_data); + pthread_mutex_unlock(&nfcftm_mutex); + if(ftm_data_rsp_pending == TRUE) + { + printf("Sending data rsp \n"); + hal_state = NCI_HAL_READ; + sem_post(&semaphore_halcmd_complete); + ftm_data_rsp_pending = FALSE; + } + else + { + if((wait_rsp == FALSE) || ((p_data[0] == 0x60) && (p_data[1] == 0x00))) + { + /*This is the case when ntf receieved after rsp is logged to pc app*/ + printf("Sending async msg to logging subsystem \n"); + hal_state = NCI_HAL_ASYNC_LOG; + sem_post(&semaphore_halcmd_complete); + } + } + } + else + { + if(response_buff || res_len) + { + printf("nfc_ftm_data_cback : response_buff = %p, res_len = %d", response_buff, res_len); + return; + } + response_buff = (uint8*)malloc(data_len); + if(response_buff) + { + memcpy(response_buff, p_data, data_len); + res_len = data_len; + printf("nfc_ftm_data_cback: res_len=%d data_len=%d response_buff= %X %X %X %X %X %X \n", res_len,data_len, \ + response_buff[0],response_buff[1],response_buff[2],response_buff[3],response_buff[4],response_buff[5]); + hal_state = NCI_HAL_READ; + sem_post(&semaphore_halcmd_complete); + } + else + { + printf("Mem allocation failed in nfc_ftm_data_cback \n"); + } + } + } +} +/*=========================================================================== +FUNCTION ftm_nfc_hal_open +DESCRIPTION + This function will open the nfc hal for ftm nfc command processing. +DEPENDENCIES + NIL +RETURN VALUE + void +SIDE EFFECTS + NONE +===============================================================================*/ +uint8 ftm_nfc_hal_open(void) +{ + uint8 ret = 0; + ret = hw_get_module(NFC_NCI_HARDWARE_MODULE, &hw_module); + if(ret == 0) + { + dev = (nfc_nci_device_t*)malloc(sizeof(nfc_nci_device_t)); + if(!dev) + { + printf("NFC FTM : mem allocation failed \n"); + return FALSE; + } + else + { + ret = nfc_nci_open (hw_module, &dev); + if(ret != 0) + { + printf("NFC FTM : nfc_nci_open fail \n"); + free(dev); + return FALSE; + } + else + { + printf("NFC FTM : opening NCI HAL \n"); + dev->common.reserved[0] = FTM_MODE; + dev->open (dev, nfc_ftm_cback, nfc_ftm_data_cback); + sem_wait(&semaphore_halcmd_complete); + } + } + } + else + { + printf("NFC FTM : hw_get_module() call failed \n"); + return FALSE; + } + return TRUE; +} +/*================================================================================================= +FUNCTION ftm_nfc_log_send_msg +DESCRIPTION +This function will log the asynchronous messages(NTFs and data packets) to the logging subsystem + of DIAG. +DEPENDENCIES +RETURN VALUE +TRUE if data logged successfully and FALSE if failed. +SIDE EFFECTS + None +==================================================================================================*/ +int ftm_nfc_log_send_msg(void) +{ + uint16 i = 0; + ftm_nfc_log_pkt_type* ftm_nfc_log_pkt_ptr = NULL; + asyncdata* node = NULL; + uint8 arr[1]= {'\n'}; + if(log_status(LOG_NFC_FTM)) + { + buff = start; + if(buff != NULL) + { + do{ + printf("buff->async_datalen : %d \n", buff->async_datalen); + ftm_nfc_log_pkt_ptr = (ftm_nfc_log_pkt_type *)log_alloc(LOG_NFC_FTM, (FTM_NFC_LOG_HEADER_SIZE + (buff->async_datalen))); + if(ftm_nfc_log_pkt_ptr) + { + memcpy((void *)ftm_nfc_log_pkt_ptr->data, (void *)buff->response_buff, buff->async_datalen); + printf("Async msg is = "); + for(i=0; iasync_datalen; i++) + { + printf("%X ", ftm_nfc_log_pkt_ptr->data[i]); + } + printf("%c",arr[0]); + node = buff; + buff = buff->next; + free(node); + printf("Commiting the log message(async msg) \n"); + log_commit(ftm_nfc_log_pkt_ptr); + } + else + { + printf("\nmem alloc failed in log_alloc \n"); + return FALSE; + } + }while(buff != NULL); + printf("all msgs committed \n"); + async_msg_available = FALSE; + return TRUE; + } + else + { + printf("No async message left to be logged \n"); + } + } + else + { + printf("LOG_NFC_FTM code is not enabled in logging subsystem \n"); + } + return FALSE; +} +/*=========================================================================== +FUNCTION nfc_ftm_readerthread +DESCRIPTION + Thread Routine to perfom asynchrounous handling of events coming from + NFCC. It will perform read and write for all type of commands/data. +DEPENDENCIES +RETURN VALUE + RETURN NIL +SIDE EFFECTS + None +===========================================================================*/ +void* nfc_ftm_thread(void *ptr) +{ + uint8 i2c_buff[3] = {0}; + + UNUSED(ptr); + + while(1) + { + printf("Waiting for Cmd/Rsp \n"); + sem_wait (&semaphore_halcmd_complete); + switch(hal_state) + { + case NCI_HAL_INIT: + printf("NFC FTM : HAL Open request recieved..\n"); + if(ftm_nfc_hal_open() == FALSE) + { + hal_state = NCI_HAL_ERROR; + hal_opened = FALSE; + } + else + { + break; + } + case NCI_HAL_ERROR: + /* HAL open failed.Post sem and handle error case*/ + sem_post(&semaphore_nfcftmcmd_complete); + break; + case NCI_HAL_WRITE: + if(dev != NULL) + { + printf("NFC FTM : Cmd recieved for nfc ftm..sending.\n"); + if((!i2c_req_write) && (!i2c_req_read)) + { + /* send data to the NFCC*/ + if(nfc_cmd_buff[0] == 0x00 /*data req*/) + { + printf("Data send request arrived \n"); + ftm_data_rsp_pending = TRUE; + } + else + { + printf("cmd request arrived \n"); + wait_rsp = TRUE; + } + dev->write(dev, len, nfc_cmd_buff); + } + else + { + if(i2c_req_write) + { + i2c_buff[0] = 0xFF; + i2c_buff[1] = nfc_cmd_buff[i2c_cmd_cnt++]; /* addr*/ + i2c_buff[2] = nfc_cmd_buff[i2c_cmd_cnt++]; /*value*/ + len -=2; + dev->write(dev, 3, i2c_buff); + } + else + { + /* I2c Read req*/ + i2c_buff[0] = 0xFF; + i2c_buff[1] = nfc_cmd_buff[i2c_cmd_cnt++]; /* I2C addr to read*/ + i2c_reg_read_data[ii++] = i2c_buff[1]; /* store address to send in response.*/ + len -= 1; + dev->write(dev, 2, i2c_buff); + } + } + } + else + { + printf("dev is null \n"); + } + break; + case NCI_HAL_READ: + /* indicate to ftm that response is avilable now*/ + sem_post(&semaphore_nfcftmcmd_complete); + printf("NFC FTM : State changed to READ i2c_req_read: %d\n",i2c_req_read); + break; + case NCI_HAL_ASYNC_LOG: + /* indicate to ftm that response is avilable now*/ + printf("NFC FTM : State changed to NCI_HAL_ASYNC_LOG.Logging aysnc message \n"); + pthread_mutex_lock(&nfcftm_mutex); + if(ftm_nfc_log_send_msg()) + { + printf("async msgs commited to the log system..changing HAL state to write \n"); + } + else + { + printf("async msgs commit failed..changing HAL state to write \n"); + } + hal_state = NCI_HAL_WRITE; + pthread_mutex_unlock(&nfcftm_mutex); + break; + default: + break; + } + } +} +/*=========================================================================== +FUNCTION ftm_nfc_dispatch +DESCRIPTION +This is the function which will be called by the NFC FTM layer callback function +registered with the DIAG service./ +DEPENDENCIES +RETURN VALUE + RETURN rsp pointer(containing the NFCC rsp packets) to the callback function + (subsequently for DIAG service) +SIDE EFFECTS + None +===========================================================================*/ +void* ftm_nfc_dispatch_qti(ftm_nfc_pkt_type *nfc_ftm_pkt, uint16 pkt_len) +{ + ftm_nfc_i2c_write_rsp_pkt_type *i2c_write_rsp = NULL; + ftm_nfc_i2c_read_rsp_pkt_type *i2c_read_rsp = NULL; + ftm_nfc_pkt_type *rsp = NULL; + ftm_nfc_data_rsp_pkt_type *nfc_data_rsp = NULL; + struct timespec time_sec; + int sem_status; + + UNUSED(pkt_len); + + printf("NFC FTM : nfc ftm mode requested \n"); + if(nfc_ftm_pkt == NULL) + { + printf("Error : NULL packet recieved from DIAG \n"); + goto error_case; + } + /* Start nfc_ftm_thread which will process all requests as per + state machine flow. By Default First state will be NCI_HAL_INIT*/ + if(!nfc_ftmthread) + { + if(sem_init(&semaphore_halcmd_complete, 0, 1) != 0) + { + printf("NFC FTM :semaphore_halcmd_complete creation failed \n"); + goto error_case; + } + if(sem_init(&semaphore_nfcftmcmd_complete, 0, 0) != 0) + { + printf("NFC FTM :semaphore_nfcftmcmd_complete creation failed \n"); + goto error_case; + } + printf("NFC FTM : nfc ftm thread is being started \n"); + pthread_create(&nfc_thread_handle, NULL, nfc_ftm_thread, NULL); + nfc_ftmthread = TRUE; + } + /* parse the diag packet to identify the NFC FTM command which needs to be sent + to QCA 1990*/ + if(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_len > 2) + { + len = nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_len-2; + } + else + { + /*Wrong nfc ftm packet*/ + goto error_case; + } + switch(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id) + { + case FTM_NFC_I2C_SLAVE_WRITE: + i2c_req_write = TRUE; + break; + case FTM_NFC_I2C_SLAVE_READ: + i2c_num_of_reg_to_read = len; + i2c_req_read = TRUE; + break; + case FTM_NFC_NFCC_COMMAND: + case FTM_NFC_SEND_DATA: + break; + default : + goto error_case; + break; + } + /*copy command to send it further to QCA1990*/ + nfc_cmd_buff = (uint8 *)malloc(len+1); + if(nfc_cmd_buff) + { + memcpy(nfc_cmd_buff, nfc_ftm_pkt->nci_data, len); + } + else + { + printf("Mem allocation failed for cmd storage"); + goto error_case; + } + /*send the command */ + sem_post(&semaphore_halcmd_complete); + printf("\nwaiting for nfc ftm response \n"); + if (clock_gettime(CLOCK_REALTIME, &time_sec) == -1) + { + printf("get clock_gettime error"); + } + time_sec.tv_sec += FTM_NFC_CMD_CMPL_TIMEOUT; + sem_status = sem_timedwait(&semaphore_nfcftmcmd_complete,&time_sec); + if(sem_status == -1) + { + printf("nfc ftm command timed out\n"); + goto error_case; + } + if(!hal_opened) + { + /*Hal open is failed */ + free(nfc_cmd_buff); + hal_state = NCI_HAL_INIT; + goto error_case; + } + printf("\n\n *****Framing the response to send back to Diag service******** \n\n"); + /* Frame the response as per the cmd request*/ + switch(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id) + { + case FTM_NFC_I2C_SLAVE_WRITE: + printf("Framing the response for FTM_NFC_I2C_SLAVE_WRITE cmd \n"); + i2c_write_rsp = (ftm_nfc_i2c_write_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_NFC_CMD_CODE, + sizeof(ftm_nfc_i2c_write_rsp_pkt_type)); + if(i2c_write_rsp) + { + i2c_write_rsp->nfc_i2c_slave_status = i2c_status; + i2c_status = 0; + i2c_cmd_cnt = 0; + i2c_req_write = FALSE; + } + break; + case FTM_NFC_I2C_SLAVE_READ: + printf("Framing the response for FTM_NFC_I2C_SLAVE_READ cmd \n"); + i2c_read_rsp = (ftm_nfc_i2c_read_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_NFC_CMD_CODE, + sizeof(ftm_nfc_i2c_read_rsp_pkt_type)); + if(i2c_read_rsp) + { + i2c_read_rsp->ftm_nfc_hdr.nfc_cmd_id = FTM_NFC_I2C_SLAVE_READ; + i2c_read_rsp->ftm_nfc_hdr.nfc_cmd_len = 2+(2*i2c_num_of_reg_to_read); + i2c_read_rsp->nfc_i2c_slave_status = i2c_status; + if(i2c_status == 0x00) + { + i2c_read_rsp->nfc_nb_reg_reads = i2c_num_of_reg_to_read; + } + else + { + i2c_read_rsp->nfc_nb_reg_reads = 0x00; // error case so return num of read as 0x00. + } + memcpy(i2c_read_rsp->i2c_reg_read_rsp, i2c_reg_read_data, (i2c_num_of_reg_to_read*2)); + i2c_cmd_cnt = 0; + } + break; + case FTM_NFC_NFCC_COMMAND: + printf("Framing the response for FTM_NFC_NFCC_COMMAND cmd \n"); + if(response_buff && res_len) + { + rsp = (ftm_nfc_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_NFC_CMD_CODE, + sizeof(ftm_nfc_pkt_type)); + if(rsp) + { + rsp->ftm_nfc_hdr.nfc_cmd_id = FTM_NFC_NFCC_COMMAND; + rsp->ftm_nfc_hdr.nfc_cmd_len = 2+res_len; + rsp->nfc_nci_pkt_len = res_len; + memcpy(rsp->nci_data, response_buff, res_len); + free(response_buff); + response_buff = 0; + res_len = 0; + } + } + else + printf("ftm_nfc_dispatch : response_buff = %p, res_len = %d", response_buff, res_len); + break; + case FTM_NFC_SEND_DATA: + printf("Framing the response for FTM_NFC_SEND_DATA cmd \n"); + nfc_data_rsp = (ftm_nfc_data_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_NFC_CMD_CODE, + sizeof(ftm_nfc_data_rsp_pkt_type)); + if(nfc_data_rsp) + { + nfc_data_rsp->ftm_nfc_hdr.nfc_cmd_id = FTM_NFC_SEND_DATA; + nfc_data_rsp->ftm_nfc_hdr.nfc_cmd_len = 0;/*Rsp as per the NFC FTM data rsp req*/ + } + break; + default: + goto error_case; + break; + } + free(nfc_cmd_buff); + hal_state = NCI_HAL_WRITE; + if(async_msg_available) + { + printf(" Some async message available.. committing now.\n"); + hal_state = NCI_HAL_ASYNC_LOG; + sem_post(&semaphore_halcmd_complete); + } + wait_rsp = FALSE; + if(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_I2C_SLAVE_WRITE) + { + return(void*)i2c_write_rsp; + } + else if(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_I2C_SLAVE_READ) + { + i2c_req_read = FALSE; + return(void*)i2c_read_rsp; + } + else if(nfc_ftm_pkt->ftm_nfc_hdr.nfc_cmd_id == FTM_NFC_NFCC_COMMAND) + { + return(void*)rsp; + } + else + { + return(void*)nfc_data_rsp; + } +error_case: + return NULL; +} diff --git a/feeds/wifi-ax/ftm/src/ftm_nfcqti.h b/feeds/wifi-ax/ftm/src/ftm_nfcqti.h new file mode 100755 index 000000000..28968b991 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_nfcqti.h @@ -0,0 +1,141 @@ +#ifndef FTM_NFCQTI_H_ +#define FTM_NFCQTI_H_ +/*========================================================================== + + nfc FTM header File + +Description + This file contains the decalarations used by ftm_nfc.c + +Copyright (c) 2015 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +08/06/13 NFC FTM layer +===========================================================================*/ + +#ifdef CONFIG_FTM_NFC + +#include "stdio.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "msg.h" +#include "log.h" + +#include "diag_lsm.h" +#include "diagpkt.h" +#include "diagcmd.h" +#include "diag.h" +#include "termios.h" + +/*==========================================================================* +* Defnitions * +*==========================================================================*/ +#define FTM_MODE 1 +#define TRUE 1 +#define FALSE 0 +#define FTM_MODE 1 +#define FTM_NFC_CMD_CODE 55 +#define LOG_NFC_FTM 0x1802 +#define FTM_NFC_LOG_HEADER_SIZE 12 + +#define FTM_NFC_I2C_SLAVE_WRITE 0x00 +#define FTM_NFC_I2C_SLAVE_READ 0x01 +#define FTM_NFC_NFCC_COMMAND 0x02 +#define FTM_NFC_SEND_DATA 0x03 + +#define FTM_NFC_CMD_CMPL_TIMEOUT 15 + +#ifdef ANDROID_M +#define NFC_NCI_HARDWARE_MODULE "nfc_nci.qc199x" +#else +#define NFC_NCI_HARDWARE_MODULE "nfc_nci" +#endif + +enum +{ + NCI_HAL_INIT, + NCI_HAL_WRITE, + NCI_HAL_READ, + NCI_HAL_DEINIT, + NCI_HAL_ASYNC_LOG, + NCI_HAL_ERROR +}; +/*==========================================================================* +* Declarations * +*==========================================================================*/ +/* Reader thread handle */ +pthread_t nfc_thread_handle; +sem_t semaphore_halcmd_complete; +sem_t semaphore_nfcftmcmd_complete; + +/* structure that contains nfc cmd id and len + part of the packet recieved from DIAG*/ +PACKED struct ftm_nfc_cmd_header_type{ + uint16 nfc_cmd_id; + uint16 nfc_cmd_len; +}; + +/* nfc FTM packet(for NCI cmd/rsp messages)*/ +typedef PACKED struct{ + diagpkt_subsys_header_type diag_hdr; + struct ftm_nfc_cmd_header_type ftm_nfc_hdr; + uint16 nfc_nci_pkt_len; + byte nci_data[258]; +}ftm_nfc_pkt_type; + +/* nfc FTM packet (for I2C write messgaes)*/ +typedef PACKED struct{ + diagpkt_subsys_header_type diag_hdr; + uint8 nfc_i2c_slave_status; +}ftm_nfc_i2c_write_rsp_pkt_type; + +/* nfc FTM packet (for I2C read messgaes)*/ +typedef PACKED struct{ + diagpkt_subsys_header_type diag_hdr; + struct ftm_nfc_cmd_header_type ftm_nfc_hdr; + uint8 nfc_i2c_slave_status; + uint8 nfc_nb_reg_reads; + byte i2c_reg_read_rsp[30]; +}ftm_nfc_i2c_read_rsp_pkt_type; + + +typedef PACKED struct{ + diagpkt_subsys_header_type diag_hdr; + struct ftm_nfc_cmd_header_type ftm_nfc_hdr; +}ftm_nfc_data_rsp_pkt_type; + +typedef PACKED struct{ + log_hdr_type hdr; + byte data[1]; +}ftm_nfc_log_pkt_type; + +/*Data buffer linked list*/ +typedef struct asyncdata { + uint8 *response_buff; + uint8 async_datalen; + struct asyncdata *next; +}asyncdata; + +typedef void (tHAL_NFC_CBACK) (uint8 event, uint8 status); +typedef void (tHAL_NFC_DATA_CBACK) (uint16 data_len, uint8 *p_data); + +void* ftm_nfc_dispatch_qti(ftm_nfc_pkt_type *ftm_nfc_pkt, uint16 pkt_len); + +#endif /* CONFIG_FTM_NFC */ +#endif /* FTM_NFCQTI_H_ */ diff --git a/feeds/wifi-ax/ftm/src/ftm_wlan.c b/feeds/wifi-ax/ftm/src/ftm_wlan.c new file mode 100755 index 000000000..68e5189ca --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_wlan.c @@ -0,0 +1,1110 @@ +/*========================================================================== + + FTM WLAN Source File + +============================================================================ + +# Copyright (c) 2011, 2013-2018 Qualcomm Technologies, Inc. +# All Rights Reserved. +# Confidential and Proprietary - Qualcomm Technologies, Inc. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +07/11/11 karthikm Wrapper that contains routines for directing FTM commands + sent from host to the IOCTL calls of Atheros driver. +*/ + +/* + * Copyright (c) 2006 Atheros Communications Inc. + * All rights reserved. + * + * +// The software source and binaries included in this development package are +// licensed, not sold. You, or your company, received the package under one +// or more license agreements. The rights granted to you are specifically +// listed in these license agreement(s). All other rights remain with Atheros +// Communications, Inc., its subsidiaries, or the respective owner including +// those listed on the included copyright notices. Distribution of any +// portion of this package must be in strict compliance with the license +// agreement(s) terms. +// +// +// +// FTM_WLAN_TCMD +// Based on athtestcmd.c from AR6003 drop +// +// + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "comdef.h" +#include "diagcmd.h" + +#include "testcmd.h" +#include "libtcmd.h" +#include "ftm_wlan.h" +#include "ftm_dbg.h" + +#define INVALID_FREQ 0 +#define A_RATE_NUM 28 +#define G_RATE_NUM 28 +#define RATE_STR_LEN 20 + +int old_iface_id = -1; +#ifdef CONFIG_FTM_WLAN_AUTOLOAD +#define MODULE_FILE "/proc/modules" +#define DRIVER_MODULE_TAG "wlan" +#define WLAN_CFG_FILE "/persist/wlan_mac.bin" +/* Offset for set mac address cmd */ +#define MAIN_CMD_OFFSET 16 +#define SUB_CMD_OFFSET 24 +#define LENGTH_OFFSET 32 +#define NMAC_OFFSET 48 +#define PMAC_OFFSET 49 + +#if defined(ANDROID) +#if defined(BOARD_HAS_ATH_WLAN_AR6320) +#if BOARD_HAS_ATH_WLAN_AR6320 +#define FTM_WLAN_LOAD_CMD "/system/bin/insmod " \ + "/system/lib/modules/wlan.ko con_mode=5" +#define FTM_WLAN_UNLOAD_CMD "/system/bin/rmmod wlan" +#endif +#endif +#elif defined(MDM_LE) +#define FTM_WLAN_LOAD_CMD "/etc/init.d/wlan start_ftm" +#define FTM_WLAN_UNLOAD_CMD "/etc/init.d/wlan stop" +#else +#warning "Load and Unload driver may not work!" +#endif + +typedef enum { + SUBCMD_DRIVER_LOAD = 'L', + SUBCMD_DRIVER_UNLOAD = 'U', + SUBCMD_DRIVER_AUTO_MODE = 'A', +} sub_cmds; + +static int load_wifi_driver_testmode(void); +static int unload_wifi_driver(void); +static bool is_wifi_driver_loaded(char *mod_tag); +static bool flag_driver_auto_load = false; +#endif /* CONFIG_FTM_WLAN_AUTOLOAD */ +extern void diagpkt_free(void *pkt); + +char bdf_file[128] = {'0'}; +static void rxReport(void *buf); +#ifndef WIN_AP_HOST +char g_ifname[IFNAMSIZ] = "wlan"; +#else +#ifdef WIN_AP_HOST_OPEN +char g_ifname[IFNAMSIZ] = "wlan"; +#else +char g_ifname[IFNAMSIZ] = "wifi"; +#endif +#endif + +#ifdef WIN_AP_HOST + +#define WIN_COMMON_OP_REQ 0xFE +#define BT_CMD_REQ 198 +#define BTCMD_ID_POS 64 +#define BT_MAC_LEN_POS 80 +#define BT_CMD_LEN 0xC + +#endif + +void print_uchar_array(uint8_t *addr, int len) +{ + int i; + for (i = 0;i< len; i++) + DPRINTF(FTM_DBG_TRACE, "%02X ", addr[i]); + DPRINTF(FTM_DBG_TRACE, "\n"); +} + +void print_uint16_array(uint16_t *addr, int len) +{ + int i; + for (i = 0;i< len; i++) + DPRINTF(FTM_DBG_TRACE, "%02X %02X ", addr[i]>>8, addr[i]&0xFF); + DPRINTF(FTM_DBG_TRACE, "\n"); +} + +/*=========================================================================== +FUNCTION rxReport + +DESCRIPTION + Quick debug routine that will print all the receive statistics + +DEPENDENCIES + NIL + +RETURN VALUE + NIL + +SIDE EFFECTS + NONE + +===========================================================================*/ +static void rxReport(void *buf) +{ + uint32 pkt; + int rssi; + uint32 crcError; + uint32 secErr; + uint16 rateCnt[TCMD_MAX_RATES]; + uint16 rateCntShortGuard[TCMD_MAX_RATES]; + + pkt = *(uint32 *)buf; + rssi = (int)(*((uint32 *)buf + 1)); + crcError = *((uint32 *)buf + 2); + secErr = *((uint32 *)buf + 3); + + DPRINTF(FTM_DBG_TRACE, "total pkt %u, crcError pkt %u, secErr pkt %u, average rssi %d\n", + pkt, crcError, secErr, (int)( pkt ? (rssi / (int)pkt) : 0)); + + + memcpy(rateCnt, ((unsigned char *)buf) + (4 * sizeof(uint32)), sizeof(rateCnt)); + memcpy(rateCntShortGuard, ((unsigned char *)buf) + (4 * sizeof(uint32)) + + (TCMD_MAX_RATES * sizeof(uint16)), sizeof(rateCntShortGuard)); + + DPRINTF(FTM_DBG_INFO, "1Mbps %d\n", rateCnt[0]); + DPRINTF(FTM_DBG_INFO, "2Mbps %d\n", rateCnt[1]); + DPRINTF(FTM_DBG_INFO, "5.5Mbps %d\n", rateCnt[2]); + DPRINTF(FTM_DBG_INFO, "11Mbps %d\n", rateCnt[3]); + DPRINTF(FTM_DBG_INFO, "6Mbps %d\n", rateCnt[4]); + DPRINTF(FTM_DBG_INFO, "9Mbps %d\n", rateCnt[5]); + DPRINTF(FTM_DBG_INFO, "12Mbps %d\n", rateCnt[6]); + DPRINTF(FTM_DBG_INFO, "18Mbps %d\n", rateCnt[7]); + DPRINTF(FTM_DBG_INFO, "24Mbps %d\n", rateCnt[8]); + DPRINTF(FTM_DBG_INFO, "36Mbps %d\n", rateCnt[9]); + DPRINTF(FTM_DBG_INFO, "48Mbps %d\n", rateCnt[10]); + DPRINTF(FTM_DBG_INFO, "54Mbps %d\n", rateCnt[11]); + DPRINTF(FTM_DBG_INFO, "\n"); + DPRINTF(FTM_DBG_INFO, "HT20 MCS0 6.5Mbps %d (SGI: %d)\n", rateCnt[12], rateCntShortGuard[12]); + DPRINTF(FTM_DBG_INFO, "HT20 MCS1 13Mbps %d (SGI: %d)\n", rateCnt[13], rateCntShortGuard[13]); + DPRINTF(FTM_DBG_INFO, "HT20 MCS2 19.5Mbps %d (SGI: %d)\n", rateCnt[14], rateCntShortGuard[14]); + DPRINTF(FTM_DBG_INFO, "HT20 MCS3 26Mbps %d (SGI: %d)\n", rateCnt[15], rateCntShortGuard[15]); + DPRINTF(FTM_DBG_INFO, "HT20 MCS4 39Mbps %d (SGI: %d)\n", rateCnt[16], rateCntShortGuard[16]); + DPRINTF(FTM_DBG_INFO, "HT20 MCS5 52Mbps %d (SGI: %d)\n", rateCnt[17], rateCntShortGuard[17]); + DPRINTF(FTM_DBG_INFO, "HT20 MCS6 58.5Mbps %d (SGI: %d)\n", rateCnt[18], rateCntShortGuard[18]); + DPRINTF(FTM_DBG_INFO, "HT20 MCS7 65Mbps %d (SGI: %d)\n", rateCnt[19], rateCntShortGuard[19]); + DPRINTF(FTM_DBG_INFO, "\n"); + DPRINTF(FTM_DBG_INFO, "HT40 MCS0 13.5Mbps %d (SGI: %d)\n", rateCnt[20], rateCntShortGuard[20]); + DPRINTF(FTM_DBG_INFO, "HT40 MCS1 27.0Mbps %d (SGI: %d)\n", rateCnt[21], rateCntShortGuard[21]); + DPRINTF(FTM_DBG_INFO, "HT40 MCS2 40.5Mbps %d (SGI: %d)\n", rateCnt[22], rateCntShortGuard[22]); + DPRINTF(FTM_DBG_INFO, "HT40 MCS3 54Mbps %d (SGI: %d)\n", rateCnt[23], rateCntShortGuard[23]); + DPRINTF(FTM_DBG_INFO, "HT40 MCS4 81Mbps %d (SGI: %d)\n", rateCnt[24], rateCntShortGuard[24]); + DPRINTF(FTM_DBG_INFO, "HT40 MCS5 108Mbps %d (SGI: %d)\n", rateCnt[25], rateCntShortGuard[25]); + DPRINTF(FTM_DBG_INFO, "HT40 MCS6 121.5Mbps %d (SGI: %d)\n", rateCnt[26], rateCntShortGuard[26]); + DPRINTF(FTM_DBG_INFO, "HT40 MCS7 135Mbps %d (SGI: %d)\n", rateCnt[27], rateCntShortGuard[27]); +} + +ftm_wlan_rsp_pkt_type *g_rsp = NULL; +TCMD_ID tcmd = TCMD_CONT_RX_ID; +uint32 mode = 0; + +/*=========================================================================== +FUNCTION ftm_wlan_tcmd_rx + +DESCRIPTION + Call back handler + +DEPENDENCIES + NIL + +RETURN VALUE + NONE + +SIDE EFFECTS + NONE + +===========================================================================*/ + +void ftm_wlan_tcmd_rx(void *buf, int len) +{ + void *data = NULL; + int data_len = 0; + struct TCMD_CONT_RX_REPORT *report = NULL; + TC_CMDS *tCmd = NULL; + u_int32_t *src, *dest; + int j; + +#ifdef DEBUG + current_time(); +#endif + DPRINTF(FTM_DBG_TRACE, "Rx call back received with len %d\n", len); + + /* Build the response to be sent */ + switch(tcmd) { + case TCMD_CONT_RX_ID: + report = &((TCMD_CONT_RX *) buf)->u.report; + + if (mode == TCMD_CONT_RX_REPORT) { + rxReport((void*)report); + } else if (mode == TCMD_CONT_RX_GETMAC) { + tCmd = (TC_CMDS *)buf; + + DPRINTF(FTM_DBG_TRACE, "length %d version %d act %d\n", + tCmd->hdr.u.parm.length, tCmd->hdr.u.parm.version, + tCmd->hdr.act); + + DPRINTF(FTM_DBG_INFO, + "MAC address : %02x:%02x:%02x:%02x:%02x:%02x\n", + tCmd->buf[0], tCmd->buf[1], tCmd->buf[2], + tCmd->buf[3], tCmd->buf[4], tCmd->buf[5]); + } + + data = report; + data_len = sizeof(struct TCMD_CONT_RX_REPORT); + break; + + case TC_CMDS_ID: + tCmd = (TC_CMDS *)buf; + + DPRINTF(FTM_DBG_TRACE, "length %d version %d act %d\n", + tCmd->hdr.u.parm.length, tCmd->hdr.u.parm.version, + tCmd->hdr.act); + data = buf; + data_len = sizeof(TC_CMDS); + + if ( mode == TC_CMDS_READTHERMAL ) + DPRINTF(FTM_DBG_INFO, "Chip Thermal value: %d\n", tCmd->buf[0]); + break; + + case TC_CMD_TLV_ID: + data = buf; + data_len = len; + src = (u_int32_t *)buf; + dest = (u_int32_t *)buf; + for (j = 0; j < roundup(len, sizeof(u_int32_t))/4; j++) { + *(dest+j) = le32toh(*(src+j)); + } + print_uchar_array(buf, len); + + DPRINTF(FTM_DBG_TRACE, "tcmd_rx TC_CMD_TLV_ID length %d\n", len); + break; + + default: + data_len = 0; + data = NULL; + DPRINTF(FTM_DBG_TRACE, "Unknown TCMD response\n"); + break; + } + + g_rsp = (ftm_wlan_rsp_pkt_type*)diagpkt_subsys_alloc( DIAG_SUBSYS_FTM, + FTM_WLAN_CMD_CODE, (sizeof(g_rsp->common_header) + + sizeof(g_rsp->cmd.common_ops) + data_len)); + + if (g_rsp == NULL) { + DPRINTF(FTM_DBG_ERROR, "Failed to allocate diag packet! tcmd: %d", + tcmd); + return; + } + +#ifdef WIN_AP_HOST + /* Handle win specific fw responses */ + if (data == NULL || data_len == 0) + g_rsp->cmd.common_ops.result = htole32(FTM_ERR_CODE_IOCTL_FAIL); + else + win_host_handle_fw_resp(g_rsp, data, data_len); + if (g_rsp == NULL) + return; +#else + + if (data && data_len != 0) + memcpy(g_rsp->cmd.common_ops.rx_and_therm.rxReport.data, data, data_len); + + g_rsp->cmd.common_ops.result = htole32(FTM_ERR_CODE_PASS); +#endif +} + +/*=========================================================================== +FUNCTION isResponseNeeded + +DESCRIPTION + Do we need a response for the command + +DEPENDENCIES + NIL + +RETURN VALUE + boolean response required/not + +SIDE EFFECTS + NONE + +===========================================================================*/ +static bool isResponseNeeded(void *buf) +{ + bool respNeeded = false; + + tcmd = le32toh(*((uint32 *) buf)); + mode = le32toh(*((uint32 *) buf + 1)); + + /// Insert commands which need response + switch (tcmd) + { + case TC_CMD_TLV_ID: + respNeeded = true; + break; + case TCMD_CONT_RX_ID: + switch (mode) + { + case TCMD_CONT_RX_REPORT: + case TCMD_CONT_RX_GETMAC: + respNeeded = true; + break; + } + break; + case TC_CMDS_ID: + switch (mode) + { + case TC_CMDS_READTHERMAL: + case TC_CMDS_EFUSEDUMP: + case TC_CMDS_EFUSEWRITE: + case TC_CMDS_OTPSTREAMWRITE: + case TC_CMDS_OTPDUMP: + respNeeded = true; //TC_CMDS_EFUSEDUMP, TC_CMDS_EFUSEWRITE, TC_CMDS_OTPSTREAMWRITE, TC_CMDS_OTPDUMP, TC_CMDS_READTHERMAL + break; + } + break; + default: + break; + } + + if (respNeeded) + { + DPRINTF(FTM_DBG_TRACE, "cmdID %d response needed\n", tcmd); + } + else + { + DPRINTF(FTM_DBG_TRACE, "cmdID %d response not needed\n", tcmd); + } + + return respNeeded; +} + + +/*=========================================================================== +FUNCTION ftm_wlan_common_op + +DESCRIPTION + Process ftm commands like load driver, Tx, Rx and few test commands + +DEPENDENCIES + NIL + +RETURN VALUE + Returns back buffer that is meant to be passed to the diag callback + +SIDE EFFECTS + NONE + +===========================================================================*/ +static void *ftm_wlan_common_op(ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len) +{ + uint8_t *input_msg = (uint8_t*)wlan_ftm_pkt; + uint32_t *cmd; + ftm_wlan_rsp_pkt_type *rsp; + int data_len = pkt_len - sizeof(diagpkt_subsys_header_v2_type) - 4; + char ifname[IFNAMSIZ]; + bool resp = false; + int curr_iface_id; + + snprintf(ifname, sizeof(ifname), "%s%d", g_ifname, + wlan_ftm_pkt->cmd.common_ops.wlandeviceno); + if (data_len <= 0) { + DPRINTF(FTM_DBG_ERROR, "Invalid data_len: %d\n", data_len); + return NULL; + } + + cmd = (uint32_t*)(wlan_ftm_pkt->cmd.common_ops.data); + DPRINTF(FTM_DBG_TRACE, "Command ID rec'd: 0x%X length %d\n", le32toh(*cmd), data_len); + + print_uchar_array((uint8_t*)(wlan_ftm_pkt->cmd.common_ops.data), data_len); + + g_rsp = NULL; + + rsp = (ftm_wlan_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_WLAN_CMD_CODE, + sizeof(rsp->common_header) + + sizeof(rsp->cmd.common_ops)); + + if (rsp == NULL) { + DPRINTF(FTM_DBG_ERROR, "Failed to allocate Diag packet: %p\n", rsp); + goto err_out; + } + + rsp->cmd.common_ops.result = htole32(FTM_ERR_CODE_PASS); + +#ifdef CONFIG_FTM_WLAN_AUTOLOAD + if (le32toh(*cmd) == TCMD_LOAD_DRIVER) { + /* Get sub-cmd */ + unsigned int sub_cmd = 0; + if (data_len >= (int)(2*sizeof(uint32))) + sub_cmd = *((uint32*)wlan_ftm_pkt->cmd.common_ops.data + 1); + + /* execute sub_cmd */ + if (sub_cmd == SUBCMD_DRIVER_LOAD) { + load_wifi_driver_testmode(); + } else if (sub_cmd == SUBCMD_DRIVER_UNLOAD) { + unload_wifi_driver(); + } else if (sub_cmd == SUBCMD_DRIVER_AUTO_MODE) { + flag_driver_auto_load = true; + } + + /* These commands will not go to firmware */ + return rsp; + } + else if ((data_len > PMAC_OFFSET) && *(wlan_ftm_pkt->cmd.common_ops.data + MAIN_CMD_OFFSET) == OP_GENERIC_NART_CMD) { + if (*(wlan_ftm_pkt->cmd.common_ops.data + SUB_CMD_OFFSET) == TCMD_SET_MAC_ADDR) { + int i = 0; + uint8_t length = 0, nMac = 0, *pMac = NULL; + length = *(wlan_ftm_pkt->cmd.common_ops.data + LENGTH_OFFSET); + nMac = *(wlan_ftm_pkt->cmd.common_ops.data + NMAC_OFFSET); + pMac = (wlan_ftm_pkt->cmd.common_ops.data + PMAC_OFFSET); + + DPRINTF(FTM_DBG_TRACE, "Handling WLAN request of setting Mac address\n"); + + if (!nMac || (length < (5 + 6*nMac))) { + DPRINTF(FTM_DBG_ERROR, "invalid data, nMac = %u, length = %u\n", + nMac, length); + rsp->cmd.common_ops.result = htole32(FTM_ERR_CODE_IOCTL_FAIL); + goto err_out; + } + + FILE *fp = fopen(WLAN_CFG_FILE, "wb"); + if (fp == NULL) { + DPRINTF(FTM_DBG_INFO, "Can't open file %s\n", WLAN_CFG_FILE); + rsp->cmd.common_ops.result = htole32(FTM_ERR_CODE_IOCTL_FAIL); + goto err_out; + } + + for (i = 0; i < nMac; i++) { + fprintf(fp, "Intf%dMacAddress=%02X%02X%02X%02X%02X%02X\n", i, + pMac[0], pMac[1], pMac[2], pMac[3], pMac[4], pMac[5]); + pMac = pMac + 6; + } + fprintf(fp, "END"); + fclose(fp); + /* This command will not go to the firmware */ + return rsp; + } + } + + if ((flag_driver_auto_load == true) \ + && (!is_wifi_driver_loaded(DRIVER_MODULE_TAG))) { + /* load the driver to testmode */ + load_wifi_driver_testmode(); + } +#endif + +#ifdef WIN_AP_HOST + /* 0xFE is the command id(first byte) for BD capture/Flash write requests */ + if (le32toh(*cmd) == WIN_COMMON_OP_REQ) { + diagpkt_free(rsp); + rsp = win_host_handle_bdf_req (wlan_ftm_pkt, pkt_len); + return (void *)rsp; + } + if (data_len > BTCMD_ID_POS) { + if((input_msg[BTCMD_ID_POS] == BT_CMD_REQ) && (input_msg[BT_MAC_LEN_POS] == BT_CMD_LEN)){ + diagpkt_free(rsp); + rsp = win_bt_mac_flash_write(wlan_ftm_pkt, pkt_len); + if (rsp) + return (void *)rsp; + else { + DPRINTF(FTM_DBG_ERROR, "Response is NULL!\n"); + goto err_out; + } + } + } +#endif + curr_iface_id = wlan_ftm_pkt->cmd.common_ops.wlandeviceno; + if (curr_iface_id != old_iface_id) + { + DPRINTF(FTM_DBG_TRACE, "Initializing Interface: %s\n", ifname); + + if (tcmd_tx_init(ifname, ftm_wlan_tcmd_rx)) + { + DPRINTF(FTM_DBG_ERROR, "Couldn't init tcmd transport!\n"); + rsp->cmd.common_ops.result = htole32(FTM_ERR_CODE_IOCTL_FAIL); + goto err_out; + } + + DPRINTF(FTM_DBG_TRACE, "tcmd: Initialized Interface: %s\n", ifname); +#ifdef WIN_AP_HOST_OPEN + tcmd_tx_start(); + DPRINTF(FTM_DBG_TRACE, "tcmd: tcmd_tx_start done\n"); +#endif + old_iface_id = curr_iface_id; + } + + resp = isResponseNeeded( (void*)wlan_ftm_pkt->cmd.common_ops.data); + + if (tcmd_tx(wlan_ftm_pkt->cmd.common_ops.data, data_len, resp)) + { + DPRINTF(FTM_DBG_ERROR, "TCMD timed out!\n"); + rsp->cmd.common_ops.result = htole32(FTM_ERR_CODE_IOCTL_FAIL); + goto err_out; + } + + if (resp) + { + if (g_rsp) + { + diagpkt_free(rsp); + return (void *) g_rsp; + } + else + { + DPRINTF(FTM_DBG_ERROR, "No response got probably timing out.... \n"); + rsp->cmd.common_ops.result = htole32(FTM_ERR_CODE_IOCTL_FAIL); + } + } else { + DPRINTF(FTM_DBG_ERROR, "Resp is false \n"); + } + +err_out: + return (void *) rsp; +} + +/*=========================================================================== +FUNCTION ftm_wlan_bdf_read + +DESCRIPTION + Read the data from bdf_file + +DEPENDENCIES + NIL + +RETURN VALUE + Returns back buffer that is meant to be passed to the diag callback + +SIDE EFFECTS + NONE + +===========================================================================*/ +static void *ftm_wlan_bdf_read(ftm_wlan_req_pkt_type *wlan_ftm_read_pkt) +{ + FILE *fp; + byte err_code; + int ret; + unsigned long file_size; + unsigned int size; /*actual number of bytes transferred in resp pkt*/ + char *buf = NULL; + struct stat st; + int byte_rem; + uint16 rsp_pkt_size; + ftm_wlan_rsp_pkt_type *ftm_read_resp = NULL; + + rsp_pkt_size = sizeof(ftm_read_resp->common_header) + sizeof(ftm_read_resp->cmd.read_file); + + fp = fopen(bdf_file, "r"); + if (fp == NULL) { + DPRINTF(FTM_DBG_ERROR, " failed to open file: %s\n", bdf_file); + err_code = WLAN_BDF_FILE_OPEN_FAIL; + goto ftm_read_out; + } + st.st_size = 0; + /*get size of the file*/ + if (stat(bdf_file, &st) == 0) + file_size = st.st_size; + else { + DPRINTF(FTM_DBG_ERROR, "Failed to get file size \n"); + err_code = WLAN_BDF_FILE_STAT_FAIL; + goto ftm_read_out; + } + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: %s file size is: %lu\n", bdf_file, file_size); + if (file_size <= wlan_ftm_read_pkt->cmd.read_file.offset) { + DPRINTF(FTM_DBG_ERROR, " Bad offset \n"); + err_code = WLAN_BDF_BAD_OFFSET; + goto ftm_read_out; + } + + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: offset: %d\n", wlan_ftm_read_pkt->cmd.read_file.offset); + ret = fseek(fp, wlan_ftm_read_pkt->cmd.read_file.offset, SEEK_SET); + if (ret == -1) { + DPRINTF(FTM_DBG_ERROR, "fseek failed \n"); + err_code = WLAN_BDF_FILE_SEEK_FAIL; + goto ftm_read_out; + } + + /*validate the size(number of bytes) to be read from file */ + if ((wlan_ftm_read_pkt->cmd_rsp_pkt_size - rsp_pkt_size) > (file_size - wlan_ftm_read_pkt->cmd.read_file.offset)) { + size = file_size - wlan_ftm_read_pkt->cmd.read_file.offset; + } else + size = wlan_ftm_read_pkt->cmd_rsp_pkt_size - rsp_pkt_size; + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: number of bytes to be read: %d\n", size); + + buf = (char *)malloc(size); + if(!buf) { + DPRINTF(FTM_DBG_ERROR, " failed to allocate buf memory \n"); + err_code = WLAN_BDF_READ_FAILED; + goto ftm_read_out; + } + ret = fread(buf, 1, size, fp); + if (ret ==(signed)size || feof(fp)) { + size = ret; + err_code = WLAN_BDF_READ_SUCCESS; + rsp_pkt_size += size; + } else { + DPRINTF(FTM_DBG_ERROR, "ftm_daemon: fread failed\n"); + err_code = WLAN_BDF_READ_FAILED; + } + +ftm_read_out: + if (err_code != WLAN_BDF_READ_SUCCESS) + rsp_pkt_size += 1; //need to send atleast 1 byte of data to diag in case of read failure + + ftm_read_resp = (ftm_wlan_rsp_pkt_type *)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_WLAN_CMD_CODE, + rsp_pkt_size + ); + if (ftm_read_resp == NULL) { + DPRINTF(FTM_DBG_ERROR, "Failed to allocate Diag resp packet\n"); + if (fp) + fclose(fp); + if (buf) + free(buf); + return NULL; + } + ftm_read_resp->common_header.cmd_id = htole16(FTM_WLAN_BDF_READ); + ftm_read_resp->common_header.cmd_rsp_pkt_size = htole16(rsp_pkt_size); + ftm_read_resp->cmd.read_file.result = err_code; + if (err_code == WLAN_BDF_READ_SUCCESS) { + ftm_read_resp->cmd.read_file.size = htole16(size); + byte_rem = file_size - (size + wlan_ftm_read_pkt->cmd.read_file.offset); + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: byte_rem: %d\n", byte_rem); + memcpy(ftm_read_resp->cmd.read_file.bytes_remaining, &byte_rem, sizeof(ftm_read_resp->cmd.read_file.bytes_remaining)); + memcpy(ftm_read_resp->cmd.read_file.data, buf, size); + } else + memset(ftm_read_resp->cmd.read_file.data, 0, 1); + + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: read resp msg dump:\n"); + print_uchar_array((uint8_t *)ftm_read_resp, (int)rsp_pkt_size); + + if (fp) + fclose(fp); + if (buf) + free(buf); + return (void *)ftm_read_resp; +} + +/*=========================================================================== +FUNCTION ftm_wlan_bdf_write + +DESCRIPTION + Write the data received from application to bdf_file + +DEPENDENCIES + NIL + +RETURN VALUE + Returns back buffer that is meant to be passed to the diag callback + +SIDE EFFECTS + NONE + +===========================================================================*/ +static void *ftm_wlan_bdf_write(ftm_wlan_req_pkt_type *wlan_ftm_write_pkt) +{ + FILE *fp; + byte err_code; + ftm_wlan_rsp_pkt_type *ftm_write_resp = NULL; + uint16 rsp_pkt_len; + + rsp_pkt_len = sizeof(ftm_write_resp->common_header) + sizeof(ftm_write_resp->cmd.write_file) + 1; + ftm_write_resp = (ftm_wlan_rsp_pkt_type *)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_WLAN_CMD_CODE, + rsp_pkt_len + ); + if (ftm_write_resp == NULL) { + DPRINTF(FTM_DBG_ERROR, "Failed to allocate Diag resp packet\n"); + return NULL; + } + + if (!wlan_ftm_write_pkt->cmd.write_file.append_flag) { + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: bdf_file = %s open in write mode\n", bdf_file); + fp = fopen(bdf_file, "w"); + if (fp == NULL) { + DPRINTF(FTM_DBG_ERROR, " failed to open file: %s\n", bdf_file); + err_code = WLAN_BDF_FILE_OPEN_FAIL; + goto ftm_write_out; + } + } else { + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: bdf_file = %s open in append mode\n", bdf_file); + fp = fopen(bdf_file, "a"); + if (fp == NULL) { + DPRINTF(FTM_DBG_ERROR, " failed to open file: %s\n", bdf_file); + err_code = WLAN_BDF_FILE_OPEN_FAIL; + goto ftm_write_out; + } + } + + fwrite(&(wlan_ftm_write_pkt->cmd.write_file.data), 1, wlan_ftm_write_pkt->cmd.write_file.size, fp); + if (ferror(fp)) { + DPRINTF(FTM_DBG_ERROR, " failed to write\n"); + err_code = WLAN_BDF_WRITE_FAILED; + } else + err_code = WLAN_BDF_WRITE_SUCCESS; + +ftm_write_out: + if (fp) + fclose(fp); + ftm_write_resp->common_header.cmd_id = htole16(FTM_WLAN_BDF_WRITE); + ftm_write_resp->common_header.cmd_rsp_pkt_size = htole16(rsp_pkt_len); + ftm_write_resp->cmd.write_file.result = err_code; + memset(ftm_write_resp->cmd.write_file.rsvd, 0, + sizeof(ftm_write_resp->cmd.write_file.rsvd)); + memset(ftm_write_resp->cmd.write_file.data, 0, 1); + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: write resp msg dump:\n"); + print_uchar_array((uint8_t *)ftm_write_resp, (int)rsp_pkt_len); + + return (void *)ftm_write_resp; +} + +/*=========================================================================== +FUNCTION ftm_wlan_bdf_get_filename + +DESCRIPTION + Get bdf_file path + +DEPENDENCIES + NIL + +RETURN VALUE + Returns back buffer that is meant to be passed to the diag callback + +SIDE EFFECTS + NONE + +===========================================================================*/ +static void *ftm_wlan_bdf_get_filename() +{ + ftm_wlan_rsp_pkt_type *ftm_get_fname_resp = NULL; + uint16 rsp_pkt_len; + int fname_len = 1; //allocate 1 byte of data in case of error + byte err_code; + + if (bdf_file[0]) + fname_len = strlen(bdf_file); + + rsp_pkt_len = sizeof(ftm_get_fname_resp->common_header) + sizeof(ftm_get_fname_resp->cmd.get_fname) + fname_len; + ftm_get_fname_resp = (ftm_wlan_rsp_pkt_type *)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_WLAN_CMD_CODE, + rsp_pkt_len + ); + if (ftm_get_fname_resp == NULL) { + DPRINTF(FTM_DBG_ERROR, "Failed to allocate Diag resp packet\n"); + return NULL; + } + + if (!bdf_file[0] || strlen(bdf_file) > 128) { + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: get_filename failed: bdf_file:%s fname_len: %d\n", bdf_file, fname_len); + err_code = WLAN_BDF_PATH_GET_FAILED; + memset(ftm_get_fname_resp->cmd.get_fname.data, 0, 1); + } else { + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: bdf_file is %s\n", bdf_file); + memcpy(ftm_get_fname_resp->cmd.get_fname.data, bdf_file, fname_len); + err_code = WLAN_BDF_PATH_GET_SUCCESS; + } + + ftm_get_fname_resp->common_header.cmd_id = htole16(FTM_WLAN_BDF_GET_FNAMEPATH); + ftm_get_fname_resp->common_header.cmd_rsp_pkt_size = htole16(rsp_pkt_len); + memset(ftm_get_fname_resp->cmd.get_fname.rsvd, 0, sizeof(ftm_get_fname_resp->cmd.get_fname.rsvd)); + ftm_get_fname_resp->cmd.get_fname.result = err_code; + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: get_filename resp msg dump:\n"); + print_uchar_array((uint8_t *)ftm_get_fname_resp, (int)rsp_pkt_len); + + return (void *)ftm_get_fname_resp; +} + +/*=========================================================================== +FUNCTION ftm_wlan_bdf_set_filename + +DESCRIPTION + Set bdf_file path for further bdf file read/write operation + +DEPENDENCIES + NIL + +RETURN VALUE + Returns back buffer that is meant to be passed to the diag callback + +SIDE EFFECTS + NONE + +===========================================================================*/ +static void *ftm_wlan_bdf_set_filename(ftm_wlan_req_pkt_type *wlan_ftm_set_fname_pkt) +{ + ftm_wlan_rsp_pkt_type *ftm_set_fname_resp = NULL; + uint16 rsp_pkt_len; + uint16 size; + byte err_code; + + rsp_pkt_len = sizeof(ftm_set_fname_resp->common_header) + sizeof(ftm_set_fname_resp->cmd.set_fname); + size = wlan_ftm_set_fname_pkt->cmd_data_len - rsp_pkt_len; + rsp_pkt_len += 1; //for 1 byte of reserved data + ftm_set_fname_resp = (ftm_wlan_rsp_pkt_type *)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_WLAN_CMD_CODE, + rsp_pkt_len + ); + if (ftm_set_fname_resp == NULL) { + DPRINTF(FTM_DBG_ERROR, "Failed to allocate Diag resp packet\n"); + return NULL; + } + ftm_set_fname_resp->common_header.cmd_id = htole16(FTM_WLAN_BDF_SET_FNAMEPATH); + + if (size == 0 || size >= 128) { + DPRINTF(FTM_DBG_ERROR, "ftm_daemon: set_filename failed: fname_length %d\n", size); + err_code = WLAN_BDF_PATH_SET_FAILED; + } else { + memcpy(bdf_file, wlan_ftm_set_fname_pkt->cmd.set_fname.data, size); + bdf_file[size] = '\0'; + if (strncmp(bdf_file, "/firmware", 9) == 0) { + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: remount /firmware partition as rw\n"); + system("mount -o rw,remount /firmware /firmware"); + } + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: bdf_file set to %s\n", bdf_file); + err_code = WLAN_BDF_PATH_SET_SUCCESS; + } + + ftm_set_fname_resp->common_header.cmd_rsp_pkt_size = htole16(rsp_pkt_len); + ftm_set_fname_resp->cmd.set_fname.result = err_code; + memset(ftm_set_fname_resp->cmd.set_fname.rsvd, 0, sizeof(ftm_set_fname_resp->cmd.set_fname.rsvd)); + memset(ftm_set_fname_resp->cmd.set_fname.data, 0, 1); + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: set_filename resp msg dump:\n"); + print_uchar_array((uint8_t *)ftm_set_fname_resp, (int)rsp_pkt_len); + return (void *)ftm_set_fname_resp; +} + +/*=========================================================================== +FUNCTION ftm_wlan_bdf_get_max_transfer_size + +DESCRIPTION + Get maximum transfer size(in bytes) for further bdf file read/write operation + +DEPENDENCIES + NIL + +RETURN VALUE + Returns back buffer that is meant to be passed to the diag callback + +SIDE EFFECTS + NONE + +===========================================================================*/ +static void *ftm_wlan_bdf_get_max_transfer_size() +{ + ftm_wlan_rsp_pkt_type *ftm_get_max_size_resp = NULL; + uint16 rsp_pkt_len; + + rsp_pkt_len = sizeof(ftm_get_max_size_resp->common_header) + sizeof(ftm_get_max_size_resp->cmd.get_max_transfer_size); + ftm_get_max_size_resp = (ftm_wlan_rsp_pkt_type *)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_WLAN_CMD_CODE, + rsp_pkt_len + ); + if (ftm_get_max_size_resp == NULL) { + DPRINTF(FTM_DBG_ERROR, "Failed to allocate Diag resp packet\n"); + return NULL; + } + ftm_get_max_size_resp->common_header.cmd_id = htole16(FTM_WLAN_BDF_GET_MAX_TRANSFER_SIZE); + ftm_get_max_size_resp->common_header.cmd_rsp_pkt_size = htole16(rsp_pkt_len); + ftm_get_max_size_resp->cmd.get_max_transfer_size.max_size = 1024; + ftm_get_max_size_resp->cmd.get_max_transfer_size.result = 0; + memset(ftm_get_max_size_resp->cmd.get_max_transfer_size.rsvd, 0, + sizeof(ftm_get_max_size_resp->cmd.get_max_transfer_size.rsvd)); + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: get_max_transfer_size resp msg dump:\n"); + print_uchar_array((uint8_t *)ftm_get_max_size_resp, (int)rsp_pkt_len); + return (void *)ftm_get_max_size_resp; + } + +#ifdef CONFIG_FTM_WLAN_AUTOLOAD +/*=========================================================================== +FUNCTION + load_wifi_driver_testmode + +DESCRIPTION + Use system call to load driver + +DEPENDENCIES + NIL + +RETURN VALUE + NONE + +SIDE EFFECTS + NONE +===========================================================================*/ + +static int load_wifi_driver_testmode(void) +{ + int ret = 0; + + /* clean-up the driver state */ + if ((ret = unload_wifi_driver())) { + DPRINTF(FTM_DBG_ERROR, "%s: Unload driver failed: %d\n", __func__, ret); + return ret; + } + +#ifdef FTM_WLAN_LOAD_CMD + if ((ret = system(FTM_WLAN_LOAD_CMD))) { + DPRINTF(FTM_DBG_ERROR, "WLAN driver load failed!\n"); + return ret; + } +#else +#error "FTM_WLAN_LOAD_CMD is not defined!" +#endif + + DPRINTF(FTM_DBG_TRACE, "WLAN driver loaded in FTM mode successfully!\n"); + + return ret; +} +/*=========================================================================== +FUNCTION + Unload_wifi_driver if the drvier is detected existing already + +DESCRIPTION + Use system call to unload driver + +DEPENDENCIES + NIL + +RETURN VALUE + NONE + +SIDE EFFECTS + NONE +===========================================================================*/ +static int unload_wifi_driver(void) +{ + int ret = 0; + + if (is_wifi_driver_loaded(DRIVER_MODULE_TAG)) { +#ifdef FTM_WLAN_UNLOAD_CMD + if ((ret = system(FTM_WLAN_UNLOAD_CMD))) { + DPRINTF(FTM_DBG_ERROR, "WLAN driver unload failed!\n"); + return ret; + } +#else +#error "FTM_WLAN_UNLOAD_CMD is not defined!" +#endif + } + + DPRINTF(FTM_DBG_TRACE, "WLAN driver unloaded successfully!\n"); + + return ret; +} + +/*=========================================================================== +FUNCTION + is_wifi_driver_loaded + +DESCRIPTION + Check if WLAN driver is loaded or not + +DEPENDENCIES + NIL + +RETURN VALUE + Returns true if driver already loaded, false if driver not loaded + +SIDE EFFECTS + NONE +===========================================================================*/ +static bool is_wifi_driver_loaded(char *mod_tag) +{ + FILE *proc = NULL; + char cmd[NAME_MAX + 64]; /* File name max + room for command */ + bool ret = false; + + snprintf(cmd, sizeof(cmd), "cat /proc/modules | grep %s", mod_tag); + + proc = popen(cmd, "r"); + + if (proc == NULL) { + DPRINTF(FTM_DBG_ERROR, "%s failed!\n", __func__); + return ret; + } + + if (fread (cmd, 1, sizeof(cmd), proc) > 0) + ret = true; + + fclose(proc); + + return ret; +} +#endif /* CONFIG_FTM_WLAN_AUTOLOAD */ + +/*=========================================================================== +FUNCTION ftm_wlan_dispatch + +DESCRIPTION + WLAN FTM dispatch routine. Main entry point routine for WLAN FTM for + AR6003 + +DEPENDENCIES + NIL + +RETURN VALUE + Returns back buffer that is meant to be passed to the diag callback + +SIDE EFFECTS + NONE + +===========================================================================*/ +void* ftm_wlan_dispatch(ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len) +{ + if (!wlan_ftm_pkt || !pkt_len) { + DPRINTF(FTM_DBG_ERROR, "Invalid ftm wlan Requst Packet\n"); + return NULL; + } +#ifdef DEBUG + current_time(); +#endif + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: cmd: %d\n", wlan_ftm_pkt->cmd_id); + DPRINTF(FTM_DBG_TRACE, "ftm_daemon: Request Packet Dump:\n"); + print_uchar_array((uint8_t *)wlan_ftm_pkt, pkt_len); + + switch (le16toh(wlan_ftm_pkt->cmd_id)) { + case FTM_WLAN_COMMON_OP: + return ftm_wlan_common_op(wlan_ftm_pkt, pkt_len); + case FTM_WLAN_BDF_GET_MAX_TRANSFER_SIZE: + return ftm_wlan_bdf_get_max_transfer_size(); + case FTM_WLAN_BDF_READ: + return ftm_wlan_bdf_read(wlan_ftm_pkt); + case FTM_WLAN_BDF_WRITE: + return ftm_wlan_bdf_write(wlan_ftm_pkt); + case FTM_WLAN_BDF_GET_FNAMEPATH: + return ftm_wlan_bdf_get_filename(); + case FTM_WLAN_BDF_SET_FNAMEPATH: + return ftm_wlan_bdf_set_filename(wlan_ftm_pkt); + default: + DPRINTF(FTM_DBG_ERROR, " Unknown Command\n"); + return NULL; + } +} + + + diff --git a/feeds/wifi-ax/ftm/src/ftm_wlan.h b/feeds/wifi-ax/ftm/src/ftm_wlan.h new file mode 100755 index 000000000..fc9e1a5c5 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_wlan.h @@ -0,0 +1,221 @@ +/*========================================================================== + + FTM WLAN Header File + +Description + The header file includes enums, struct definitions for WLAN FTM packets + +# Copyright (c) 2010-2011, 2014 by Qualcomm Technologies, Inc. +# All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + + Edit History + + +when who what, where, why +-------- --- ---------------------------------------------------------- +07/11/11 karthikm Created header file to include enums, struct for WLAN FTM + for Atheros support +========================================================================*/ + +#ifndef FTM_WLAN_H_ +#define FTM_WLAN_H_ + +#ifdef CONFIG_FTM_WLAN + +#include "diagpkt.h" +#include + +#define FTM_WLAN_CMD_CODE 22 + +/* TODO: For LE platforms only - need to extend it for BE platform too*/ +#define cpu32_to_le32(buf, val) \ + do { \ + buf[0] = val & 0xff; \ + buf[1] = (val >> 8) & 0xff; \ + buf[2] = (val >> 16) & 0xff; \ + buf[3] = (val >> 24) & 0xff; \ + } while(0) + +/* TODO: For LE platforms only - need to extend it for BE platform too*/ +#define le_to_cpu16(buf, uint16_val) \ + do { \ + uint16_val = (buf[0] | buf[1] << 8); \ + } while(0) + +/* TODO: For LE platforms only - need to extend it for BE platform too*/ +#define le_to_cpu32(buf, uint32_val) \ + do { \ + uint32_val = (buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24); \ + } while(0) + +extern char g_ifname[]; + +/* Various ERROR CODES supported by the FTM WLAN module*/ +typedef enum { + FTM_ERR_CODE_PASS = 0, + FTM_ERR_CODE_IOCTL_FAIL, + FTM_ERR_CODE_SOCK_FAIL, + FTM_ERR_CODE_UNRECOG_FTM +}FTM_WLAN_LOAD_ERROR_CODES; + + +#define CONFIG_HOST_TCMD_SUPPORT 1 +#define AR6000_IOCTL_SUPPORTED 1 + +#define ATH_MAC_LEN 6 + +typedef enum { + FTM_WLAN_COMMON_OP, + FTM_WLAN_BDF_GET_MAX_TRANSFER_SIZE, + FTM_WLAN_BDF_READ, + FTM_WLAN_BDF_WRITE, + FTM_WLAN_BDF_GET_FNAMEPATH, + FTM_WLAN_BDF_SET_FNAMEPATH +}FTM_WLAN_CMD; + +typedef enum { + WLAN_BDF_READ_SUCCESS, + WLAN_BDF_READ_FAILED, + WLAN_BDF_WRITE_SUCCESS, + WLAN_BDF_WRITE_FAILED, + WLAN_BDF_INVALID_SIZE = 5, + WLAN_BDF_BAD_OFFSET, + WLAN_BDF_FILE_OPEN_FAIL, + WLAN_BDF_FILE_SEEK_FAIL, + WLAN_BDF_FILE_STAT_FAIL, + WLAN_BDF_PATH_GET_SUCCESS, + WLAN_BDF_PATH_GET_FAILED, + WLAN_BDF_PATH_SET_SUCCESS, + WLAN_BDF_PATH_SET_FAILED +}FTM_WLAN_ERROR_CODES; + +#ifdef WIN_AP_HOST +#define PACKED_STRUCT __attribute__((__packed__)) +#else +#define PACKED_STRUCT __attribute__((packed)) +#endif + +/*FTM WLAN request type*/ + +typedef struct +{ + diagpkt_cmd_code_type cmd_code; + diagpkt_subsys_id_type subsys_id; + diagpkt_subsys_cmd_code_type subsys_cmd_code; + uint16 cmd_id; /* command id (required) */ + uint16 cmd_data_len; + uint16 cmd_rsp_pkt_size; + union { + struct { + uint16 rsvd; + byte rsvd1; + byte rsvd2; + byte wlanslotno; + byte wlandeviceno; + byte data[0]; + }PACKED_STRUCT common_ops; + struct { + byte rsvd[6]; + byte data[0]; + }PACKED_STRUCT get_max_transfer_size; + struct { + uint32 offset; + byte rsvd[2]; + byte data[0]; + }PACKED_STRUCT read_file; + struct { + uint16 size; + uint8 append_flag; + byte rsvd[3]; + byte data[0]; + }PACKED_STRUCT write_file; + struct { + byte rsvd[6]; + byte data[0]; + }PACKED_STRUCT get_fname; + struct { + byte rsvd[6]; + byte data[0]; + }PACKED_STRUCT set_fname; + }cmd; +}PACKED_STRUCT ftm_wlan_req_pkt_type; + +/*FTM WLAM response type */ +typedef struct +{ + struct { + diagpkt_subsys_header_type header; /*diag header*/ + uint16 cmd_id; /* command id (required) */ + uint16 cmd_data_len; + uint16 cmd_rsp_pkt_size; + }PACKED_STRUCT common_header; + union { + struct { + uint16 rsvd; + uint32 result ;/* error_code */ + union { + struct { + byte data[0]; /*rxReport*/ + }rxReport; + struct { + byte data[0]; /*ThermValReport*/ + }thermval_report; + }rx_and_therm; + }PACKED_STRUCT common_ops; + struct { + uint16 result; /*error_code*/ + byte rsvd[4]; + uint16 max_size; + }PACKED_STRUCT get_max_transfer_size; + struct { + byte result; /*error_code*/ + uint16 size; + byte bytes_remaining[3]; + byte data[0]; + }PACKED_STRUCT read_file; + struct { + byte result; + byte rsvd[5]; + byte data[0]; + }PACKED_STRUCT write_file; + struct { + byte result; + byte rsvd[5]; + byte data[0]; + }PACKED_STRUCT get_fname; + struct { + byte result; + byte rsvd[5]; + byte data[0]; + }PACKED_STRUCT set_fname; + struct { + uint16 win_cmd_specific; + uint16 data_len; + uint8 rsvd; + uint8 wlandeviceno; + byte data[0]; + }PACKED_STRUCT win_resp; + }cmd; +}PACKED_STRUCT ftm_wlan_rsp_pkt_type; + +void* ftm_wlan_dispatch(ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len); + +#ifdef WIN_AP_HOST +void setBoardDataCaptureFlag (int flag); +void setDeviceId(int id); +extern ftm_wlan_rsp_pkt_type *win_bt_mac_flash_write( + ftm_wlan_req_pkt_type *wlan_ftm_pkt, + int pkt_len); + +extern void win_host_handle_fw_resp (ftm_wlan_rsp_pkt_type *rsp, void *data, uint32_t data_len); +extern ftm_wlan_rsp_pkt_type *win_host_handle_bdf_req( + ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len); +#endif + +#endif /* CONFIG_FTM_WLAN */ +#endif /* FTM_WLAN_H_ */ diff --git a/feeds/wifi-ax/ftm/src/ftm_wlan_win.h b/feeds/wifi-ax/ftm/src/ftm_wlan_win.h new file mode 100755 index 000000000..0a4c51683 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_wlan_win.h @@ -0,0 +1,194 @@ +/* +*Copyright (c) 2017-2019 Qualcomm Technologies, Inc. +* +*All Rights Reserved. +*Confidential and Proprietary - Qualcomm Technologies, Inc. +*/ + +#ifndef __FTM_WLAN_WIN_H +#define __FTM_WLAN_WIN_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include "comdef.h" +#include "diagcmd.h" + +#include "ftm_wlan.h" +#include "ftm_dbg.h" + +#define MAC_XTAL_LENGTH 7 +#define MAC_LENGTH_POS 103 +#define MAC_POS 105 +#define BT_TLV1_RESP_LEN 84 +#define BT_RESP_LEN 100 +#define FLASH_SECTOR_SIZE 0x10000 +#define BD_LEN_EXPECTED 500 +#define BD_SIZE_REQ_ID 106 +#define BD_SIZE_REQ_POS 28 +#define BD_SIZE_VAL 60 + +/* Identifier for first segment of + * Board data response + */ +#define FIRST_SEG 48 + +/* Identifier for second segment of + * board data response + */ +#define SECOND_SEG 49 +#define THIRD_SEG 50 +#define NO_ERROR 0 + +/* header length for first segment of + * board data response + */ +#define FIRST_SEG_TLV_HDR 84 +#define SECOND_SEG_TLV_HDR 28 +#define THIRD_SEG_TLV_HDR 28 + +#define SEQUENCE_ID_POS 24 + +/* Position at which first parameter of + * TLV request is located + */ +#define TLV_PAYLOAD_PARAM_1 80 + +/* Position at which second paramter of + * TLV request is located + */ +#define TLV_PAYLOAD_PARAM_2 96 + +/* Parameter 1 value if request is for + * board data capture + */ +#define BD_CAPTURE_REQ 101 + +/* Parameter 1 value if flash write request */ +#define FLASH_WRITE_REQ 102 + +/* Parameter 1 value for device identify request */ +#define DEVICE_IDENTIFY 103 + + +/* Parameter 2 value for swift device identify */ +#define QC9887_DEVICE_ID 0x50 +#define QC9888_DEVICE_ID 0x3c +#define QC99xx_DEVICE_ID 0x46 +#define QCN9000_DEVICE_ID 0x1104 + +#define TLV1_CMD_RESP_SIZE 118 +#define TLV1_RESP_LEN 102 + +/* Offset at which BT_mac is to be stored in flash */ +#define BT_MAC_OFFSET 0x40 + +#define FLASH_BASE_CALDATA_OFFSET_SOC_0 0x1000 +#define FLASH_BASE_CALDATA_OFFSET_SOC_1 0x33000 +#define REQ_SEG_SIZE 4096 + +#define FLASH_BASE_CALDATA_OFFSET_PCI_1 0x26800 +#define FLASH_BASE_CALDATA_OFFSET_PCI_2 0x4C000 + +#define DIAG_HDR_LEN 16 + +#define FLASH_PARTITION "/dev/caldata" +#define VIRTUAL_FLASH_PARTITION "/tmp/virtual_art.bin" +#define WRITE_ART "/lib/compress_vart.sh write_caldata" + +/* (0x33000-0x1000)=0x32000, Max available BDF size */ +#define MAX_BDF_SIZE 200*1024 + +#define QC98XX_BLOCK_SIZE 512 + +#define BD_BLOCK_SIZE 256 + +/* Position of block size for the data */ +#define QC98XX_BLOCK_SIZE_VAL 164 + +/* Position of block size for the data (radio != qc98XX) */ +#define LEGACY_BLOCK_SIZE_VAL 100 + +#define M_EEEPROM_BLOCK_READ_ID_QC98XX 0xC8 + +#define M_EEEPROM_BLOCK_READ_ID_LEGACY 0xE9 + +/* Position where block data starts */ +#define QC98XX_BLOCK_START_POS 200 + +#define LEGACY_BLOCK_START_POS 104 + +#define BD_READ_CMD_ID_POS 48 + +#define BD_READ_RESP_PARAM_POS 88 + +#define BD_READ_RESP_PARAM 0x7 + +/* Use of this parameter is not known */ +#define LEGACY_RADIO_PARAM_POS 103 + +#define LEGACY_RADIO_PARAM_THRESHOLD 0x30 + +/* Valid caldata in each segment from FW */ +#define CALDATA_SIZE_FIRST_SEG 1480 +#define CALDATA_SIZE_SECOND_SEG 1536 +#define CALDATA_SIZE_THIRD_SEG 1080 + + +uint16_t TLV2_Specific_byte; + +unsigned char BDbuffer[MAX_BDF_SIZE]; +uint32_t BDbuffer_offset; +uint32_t resp_counter; +uint32_t bd_size; +uint8_t start_capture; + +/* Deviceno is the instance id sent from + * Qdart for the radio. + */ +int deviceno; + +/* Device id received in the radio's + * radio flash write requests, defaults to 0 + */ +int deviceid = 0; + +/* This is the remainder after whole 4096 size responses are sent */ +uint32_t remaining_bytes ; +uint32_t total_4K_responses; + +unsigned char BTsetmacResponse[] = { + 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xC6, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/* Response sent for BDcapture and Flash write Requests */ +unsigned char ftm_wlan_tlvRespMsg[] = { + 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x4A, 0x00, 0x00, 0x00, + 0x72, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xEA, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x2F +}; + +#endif /* __FTM_WLAN_WIN_H */ + diff --git a/feeds/wifi-ax/ftm/src/ftm_write_to_flash.c b/feeds/wifi-ax/ftm/src/ftm_write_to_flash.c new file mode 100755 index 000000000..6de1cc41a --- /dev/null +++ b/feeds/wifi-ax/ftm/src/ftm_write_to_flash.c @@ -0,0 +1,505 @@ +/* +*Copyright (c) 2017-2019 Qualcomm Technologies, Inc. +* +*All Rights Reserved. +*Confidential and Proprietary - Qualcomm Technologies, Inc. +*/ + +#ifdef WIN_AP_HOST + +#include "ftm_wlan_win.h" +#include + +/*=========================================================================== +FUNCTION bt_setmac_flash_write + +DESCRIPTION + Write MAC and XTAL to flash region + +DEPENDENCIES + NIL + +RETURN VALUE + Returns status success or failure + +SIDE EFFECTS + NONE + +===========================================================================*/ +int bt_setmac_flash_write(uint8_t *mac, unsigned int len) +{ + int fd; + int offset; + int i; + uint8_t *flashdata; + + fd = open(VIRTUAL_FLASH_PARTITION, O_RDWR); + + if (fd < 0) { + perror("Could not open flash. Returning without write\n"); + return -1; + } + + DPRINTF(FTM_DBG_TRACE,"\nNumber of bytes = %d\n",len); + + offset = BT_MAC_OFFSET; + lseek(fd, offset, SEEK_SET); + if (write(fd, mac, len) < 1) { + DPRINTF(FTM_DBG_TRACE,"flash write error. Returning\n"); + close(fd); + return -1; + } + + DPRINTF(FTM_DBG_TRACE, + "BT mac written successfully to flash @ offset %X size %X\n", + offset, len); + + flashdata = (uint8_t *)malloc(len); + if (!flashdata){ + DPRINTF(FTM_DBG_TRACE, "Write verification failed. Unable to allocate memory.\n"); + close(fd); + return -1; + } + + lseek(fd, offset, SEEK_SET); + if (read(fd, flashdata, len) < 1){ + DPRINTF(FTM_DBG_TRACE, "Flashdata read failed\n"); + free(flashdata); + return -1; + } + for(i = 0; i < len; i++){ + DPRINTF(FTM_DBG_TRACE, "input mac = 0x%x, flashdata = 0x%x\n", mac[i], flashdata[i]); + } + + free(flashdata); + close(fd); + return 1; +} + + +/*=========================================================================== +FUNCTION win_bt_mac_flash_write + +DESCRIPTION + Call bt_setmac_flash_write function and populate response to Qdart + +DEPENDENCIES + NIL + +RETURN VALUE + Returns resp to qdart + +SIDE EFFECTS + NONE + +===========================================================================*/ +ftm_wlan_rsp_pkt_type *win_bt_mac_flash_write(ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len) +{ + int i; + int status; + ftm_wlan_rsp_pkt_type *rsp; + unsigned char BtDiagMAC[MAC_XTAL_LENGTH]; + unsigned int dataLen = 0; + uint8_t *input_msg = (uint8_t*)wlan_ftm_pkt; + TLV2_Specific_byte = wlan_ftm_pkt->cmd.common_ops.rsvd; + + dataLen = input_msg[MAC_LENGTH_POS]; + for(i=0; icommon_header) + + sizeof(rsp->cmd.common_ops)+ + BT_TLV1_RESP_LEN )); + if (!rsp) + return rsp; + + rsp->common_header.cmd_rsp_pkt_size = BT_RESP_LEN; + rsp->common_header.cmd_data_len = 0; + rsp->cmd.win_resp.data_len = BT_TLV1_RESP_LEN; + rsp->cmd.win_resp.win_cmd_specific = TLV2_Specific_byte; + + status = bt_setmac_flash_write(BtDiagMAC, dataLen); + if (status > 0) { + memcpy(rsp->cmd.win_resp.data, BTsetmacResponse, BT_TLV1_RESP_LEN); + DPRINTF(FTM_DBG_TRACE,"Response sent to Qdart\n"); + /*print_uchar_array((uint8_t*)(rsp->cmd.win_resp.data), BT_TLV1_RESP_LEN);*/ + return rsp; + } + else + return rsp; +} + +/*=========================================================================== +FUNCTION win_host_handle_bdf_req + +DESCRIPTION + Function to process WIN specific bdf requests. + This handles the requests related to device identify, + boarddata capture and flash write requests, and sends + the response to QDART. + + +DEPENDENCIES + NIL + +RETURN VALUE + Returns back buffer that is meant for diag callback + +SIDE EFFECTS + NONE + +===========================================================================*/ +ftm_wlan_rsp_pkt_type *win_host_handle_bdf_req(ftm_wlan_req_pkt_type *wlan_ftm_pkt, int pkt_len) +{ + uint8_t *input_msg = (uint8_t*)wlan_ftm_pkt; + int error = 0; + int fd; + int file_offset; + int art_slot_id; + ftm_wlan_rsp_pkt_type *rsp; + deviceno = wlan_ftm_pkt->cmd.common_ops.wlandeviceno; + art_slot_id = wlan_ftm_pkt->cmd.common_ops.wlanslotno; + TLV2_Specific_byte = wlan_ftm_pkt->cmd.common_ops.rsvd; + rsp = (ftm_wlan_rsp_pkt_type*)diagpkt_subsys_alloc(DIAG_SUBSYS_FTM, + FTM_WLAN_CMD_CODE, + (sizeof(rsp->common_header) + + sizeof(rsp->cmd.common_ops)+ + TLV1_RESP_LEN)); + + if (rsp == NULL) { + DPRINTF(FTM_DBG_ERROR, "Failed to allocate Diag packet: %p\n", rsp); + return rsp; + } + rsp->cmd.win_resp.win_cmd_specific = htole16(TLV2_Specific_byte); + rsp->common_header.cmd_rsp_pkt_size = htole16(TLV1_CMD_RESP_SIZE); + rsp->common_header.cmd_data_len = 0; + rsp->cmd.win_resp.data_len = htole16(TLV1_RESP_LEN); + rsp->cmd.win_resp.rsvd = 0; + rsp->cmd.win_resp.wlandeviceno = deviceno; + + DPRINTF(FTM_DBG_TRACE, "Received FTM daemon specific TLV\n"); + + /* Byte 80 in request signifies type of request, 101 is used for BD capture*/ + if(input_msg[TLV_PAYLOAD_PARAM_1] == BD_CAPTURE_REQ) { + DPRINTF(FTM_DBG_TRACE, "BOARD_DATA_CAPTURE\n"); + if (input_msg[TLV_PAYLOAD_PARAM_2] == 1) { + setBoardDataCaptureFlag(1); + } else if (input_msg[TLV_PAYLOAD_PARAM_2] == 0) { + setBoardDataCaptureFlag(0); + } + + } else if (input_msg[TLV_PAYLOAD_PARAM_1] == FLASH_WRITE_REQ) { + fd = open(VIRTUAL_FLASH_PARTITION, O_RDWR); + if (fd < 0) { + DPRINTF(FTM_DBG_TRACE, "FILE OPEN FAILED\n"); + error = WLAN_BDF_FILE_OPEN_FAIL; + } else { + DPRINTF(FTM_DBG_TRACE, "FILE OPEN SUCCESSFULL\n"); + if (!deviceid) { + file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_0; + + if(art_slot_id == 1) + file_offset = FLASH_BASE_CALDATA_OFFSET_PCI_1; + else if(art_slot_id == 2) + file_offset = FLASH_BASE_CALDATA_OFFSET_PCI_2; + + } else if (deviceid == QC9887_DEVICE_ID || + deviceid == QC9888_DEVICE_ID) { + file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_1; + } else if (deviceid == QC99xx_DEVICE_ID) { + file_offset = FLASH_BASE_CALDATA_OFFSET_SOC_1; + } else if (deviceid == QCN9000_DEVICE_ID) { + if(art_slot_id == 1) + file_offset = FLASH_BASE_CALDATA_OFFSET_PCI_1; + else if(art_slot_id == 2) + file_offset = FLASH_BASE_CALDATA_OFFSET_PCI_2; + else { + close(fd); + return rsp; + } + } else { + DPRINTF(FTM_DBG_TRACE, "%s:%d - Invalid Device ID %d\n", + __func__, __LINE__, deviceid); + close(fd); + return rsp; + } + lseek(fd, file_offset, SEEK_SET); + if (write(fd, BDbuffer , BDbuffer_offset) < 1) { + DPRINTF(FTM_DBG_TRACE, "%s:%d - Flash write error\n", + __func__, __LINE__); + error = WLAN_BDF_WRITE_FAILED; + close(fd); + } else { + fsync(fd); + close(fd); + system(WRITE_ART); + + DPRINTF(FTM_DBG_INFO, + "Flash commit success @ offset %0x Size %d\n", + file_offset, BDbuffer_offset); + } + } + + } else if (input_msg[TLV_PAYLOAD_PARAM_1] == DEVICE_IDENTIFY) { + DPRINTF(FTM_DBG_TRACE, "Device Identify \n"); + setDeviceId(input_msg[TLV_PAYLOAD_PARAM_2]); + } + if (error!=NO_ERROR) + /* These commands will not go to firmware */ + return rsp; + else { + memcpy(rsp->cmd.win_resp.data, ftm_wlan_tlvRespMsg, TLV1_RESP_LEN); + return rsp; + } +} + +/*=========================================================================== +FUNCTION setBordDataCaptureFlag + +DESCRIPTION + Sets the BDCapture variable + +DEPENDENCIES + NIL + +RETURN VALUE + NONE + +SIDE EFFECTS + NONE + +===========================================================================*/ +void setBoardDataCaptureFlag (int flag) +{ + DPRINTF(FTM_DBG_TRACE, "Setting BDCapture flag to %d\n", flag); + if (flag == 1) { + BDbuffer_offset = 0; + resp_counter = 0; + start_capture = 1; + } + + // when board data capture is turned off, set the device id to 0 + if (flag == 0){ + start_capture = 0; + setDeviceId(0); + } +} + +/*=========================================================================== +FUNCTION setDeviceId + +DESCRIPTION + Sets the global variable device id, upon requests + according to the parameter 2 of the TLV command + +DEPENDENCIES + NIL + +RETURN VALUE + NONE + +SIDE EFFECTS + NONE +============================================================================*/ +void setDeviceId(int id) +{ + DPRINTF(FTM_DBG_TRACE, "Setting Device id to %d\n", id); + deviceid = id; +} + +/*=========================================================================== +FUNCTION win_host_handle_fw_resp + +DESCRIPTION + WIN specific handler for responses from FW. + FW responses for board data are snooped here + and stored in a global buffer which is then + accessed by the WIN request handler for flash + write requests. + +DEPENDENCIES + NIL + +RETURN VALUE + 0 on success + 1 on failure + +SIDE EFFECTS + NONE +===========================================================================*/ + +void win_host_handle_fw_resp (ftm_wlan_rsp_pkt_type *rsp, void *data, uint32_t data_len) +{ + uint32_t sequence_id; + int legacy_dataSize; + if (!rsp || !data || !data_len) { + DPRINTF(FTM_DBG_ERROR, "rsp/data is NULL\n"); + rsp = NULL; + return; + } + rsp->cmd.win_resp.win_cmd_specific = htole16(TLV2_Specific_byte); + rsp->common_header.cmd_rsp_pkt_size = htole16(data_len + DIAG_HDR_LEN); + rsp->cmd.win_resp.data_len = htole16(data_len); + rsp->cmd.win_resp.wlandeviceno = deviceno; + rsp->cmd.win_resp.rsvd = 0; + memcpy(rsp->cmd.win_resp.data, data, data_len); + + /*TODO: Need better identification method for BDF responses*/ + /* Check if the deviceid is set */ + + switch (deviceid) { + + /* DeviceId is 0 for HK and lithium family targets */ + case 0: + { /* Check if request is for BD_get size. */ + if (((uint8_t *)data)[BD_SIZE_REQ_POS] == BD_SIZE_REQ_ID ) { + bd_size = 0 ; + BDbuffer_offset = 0; + resp_counter = 0; + le_to_cpu32(((uint8_t *)data + BD_SIZE_VAL), bd_size); + DPRINTF(FTM_DBG_INFO, "bd_size = %d \n", bd_size); + total_4K_responses = bd_size / REQ_SEG_SIZE; + remaining_bytes = bd_size % REQ_SEG_SIZE; + DPRINTF(FTM_DBG_INFO, "Total_responses= %d \n", + total_4K_responses); + DPRINTF(FTM_DBG_INFO, "Remaining_bytes = %d \n", + remaining_bytes); + } + + if (data_len > BD_LEN_EXPECTED && start_capture == 1) { + sequence_id = ((uint8_t *)data)[SEQUENCE_ID_POS]; + DPRINTF(FTM_DBG_INFO, "Sequence_ID= %d\n", sequence_id); + + if (sequence_id == FIRST_SEG) + resp_counter ++; + DPRINTF(FTM_DBG_INFO, "Response counter == %d\n", + resp_counter); + DPRINTF(FTM_DBG_INFO, "Buffer offset == %d\n", + BDbuffer_offset); + + if (resp_counter < total_4K_responses + 1) { + /* Handle 3 segments of BDF resonses + * 1st segment - BDF is from offset 84 + * 2nd segment - BDF is from offset 28 + * 3rd segment - BDF is from offset 28 + */ + switch (sequence_id) { + + case FIRST_SEG: + memcpy(BDbuffer + BDbuffer_offset, + (void *)((uint8_t*)data + FIRST_SEG_TLV_HDR), + data_len - FIRST_SEG_TLV_HDR); + BDbuffer_offset += (data_len - FIRST_SEG_TLV_HDR); + break; + + case SECOND_SEG: + memcpy(BDbuffer + BDbuffer_offset, + (void *)((uint8_t *)data + SECOND_SEG_TLV_HDR), + data_len - SECOND_SEG_TLV_HDR); + BDbuffer_offset += (data_len - SECOND_SEG_TLV_HDR); + break; + + case THIRD_SEG: + memcpy(BDbuffer + BDbuffer_offset, + (void *)((uint8_t*)data + THIRD_SEG_TLV_HDR), + data_len - THIRD_SEG_TLV_HDR); + BDbuffer_offset += (data_len - THIRD_SEG_TLV_HDR); + break; + + default: + /* error */ + break; + + } + /* In case of total bdf data size not being a multiple + * of 4k, extra remaining bdf data is handled based on + * which segment of 4k it belongs to. + */ + } else { + switch (sequence_id) { + case FIRST_SEG: + if (remaining_bytes < CALDATA_SIZE_FIRST_SEG) { + memcpy(BDbuffer + BDbuffer_offset, + data + FIRST_SEG_TLV_HDR, + remaining_bytes); + BDbuffer_offset += remaining_bytes; + } else { + memcpy(BDbuffer + BDbuffer_offset, + data + FIRST_SEG_TLV_HDR, + data_len - FIRST_SEG_TLV_HDR); + BDbuffer_offset += (data_len - FIRST_SEG_TLV_HDR); + remaining_bytes -= CALDATA_SIZE_FIRST_SEG; + } + break; + + case SECOND_SEG: + if (remaining_bytes < CALDATA_SIZE_SECOND_SEG) { + memcpy(BDbuffer + BDbuffer_offset, + data + SECOND_SEG_TLV_HDR, + remaining_bytes); + BDbuffer_offset += remaining_bytes; + } else { + memcpy(BDbuffer + BDbuffer_offset, + data + SECOND_SEG_TLV_HDR, + data_len - SECOND_SEG_TLV_HDR); + BDbuffer_offset += (data_len - SECOND_SEG_TLV_HDR); + remaining_bytes -= CALDATA_SIZE_SECOND_SEG; + } + break; + + case THIRD_SEG: + memcpy(BDbuffer + BDbuffer_offset, + (void *)((uint8_t*)data + THIRD_SEG_TLV_HDR), + remaining_bytes); + BDbuffer_offset += remaining_bytes; + break; + } + } + } + break; + } + case QC9887_DEVICE_ID: + case QC9888_DEVICE_ID: + { + if ((((uint8_t *)data)[BD_READ_CMD_ID_POS] == M_EEEPROM_BLOCK_READ_ID_QC98XX) && + (((uint8_t *)data)[BD_READ_RESP_PARAM_POS] == BD_READ_RESP_PARAM)){ + le_to_cpu32(((uint8_t *)data + QC98XX_BLOCK_SIZE_VAL), + legacy_dataSize); + DPRINTF(FTM_DBG_TRACE, + "Capturing Caldata for QC98xx by FTM :: Size %d\n", + legacy_dataSize); + DPRINTF(FTM_DBG_TRACE, + "BDbuffer Offset : %d \n", + (resp_counter * QC98XX_BLOCK_SIZE)); + memcpy(BDbuffer + BDbuffer_offset, (void *)((uint8_t *)data + + QC98XX_BLOCK_START_POS), + legacy_dataSize); + resp_counter = resp_counter + 1; + BDbuffer_offset += legacy_dataSize; + } + break; + } + case QC99xx_DEVICE_ID: + { + if ((((uint8_t *)data)[BD_READ_CMD_ID_POS] == M_EEEPROM_BLOCK_READ_ID_LEGACY) && + (((uint8_t *)data)[BD_READ_RESP_PARAM_POS] == BD_READ_RESP_PARAM) && + ((uint8_t *)data)[LEGACY_RADIO_PARAM_POS] < LEGACY_RADIO_PARAM_THRESHOLD) { + le_to_cpu16(((uint8_t *)data + LEGACY_BLOCK_SIZE_VAL), legacy_dataSize); + DPRINTF(FTM_DBG_TRACE, + "Capturing Caldata by FTM :: Size %d\n", + legacy_dataSize); + DPRINTF(FTM_DBG_TRACE, + "BDbuffer Offset : %d \n", + (resp_counter * BD_BLOCK_SIZE)); + memcpy(BDbuffer + BDbuffer_offset, + (void *)((uint8_t *)data + LEGACY_BLOCK_START_POS), + legacy_dataSize); + resp_counter = resp_counter + 1; + BDbuffer_offset+=legacy_dataSize; + } + break; + } + } +} +#endif diff --git a/feeds/wifi-ax/ftm/src/testcmd.h b/feeds/wifi-ax/ftm/src/testcmd.h new file mode 100755 index 000000000..9a7b89934 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/testcmd.h @@ -0,0 +1,159 @@ +/*========================================================================== + + TCMD header File + +# Copyright (c) 2011, 2013-2014 by Qualcomm Technologies, Inc. +# All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +===========================================================================*/ + +/*=========================================================================== + +*/ + +/* + * Copyright (c) 2006 Atheros Communications Inc. + * All rights reserved. + * + * +// The software source and binaries included in this development package are +// licensed, not sold. You, or your company, received the package under one +// or more license agreements. The rights granted to you are specifically +// listed in these license agreement(s). All other rights remain with Atheros +// Communications, Inc., its subsidiaries, or the respective owner including +// those listed on the included copyright notices. Distribution of any +// portion of this package must be in strict compliance with the license +// agreement(s) terms. +// +// +// + * + */ + +#ifndef TESTCMD_H_ +#define TESTCMD_H_ + +#include + +#ifdef AR6002_REV2 +#define TCMD_MAX_RATES 12 +#else +#define TCMD_MAX_RATES 28 +#endif + +#define PREPACK +#define POSTPACK __attribute__ ((packed)) + +#define ATH_MAC_LEN 6 +#define TC_CMDS_SIZE_MAX 256 + +/* Continuous Rx + act: TCMD_CONT_RX_PROMIS - promiscuous mode (accept all incoming frames) + TCMD_CONT_RX_FILTER - filter mode (accept only frames with dest + address equal specified + mac address (set via act =3) + TCMD_CONT_RX_REPORT off mode (disable cont rx mode and get the + report from the last cont + Rx test) + + TCMD_CONT_RX_SETMAC - set MacAddr mode (sets the MAC address for the + target. This Overrides + the default MAC address.) + +*/ +typedef enum { + TCMD_CONT_RX_PROMIS = 0, + TCMD_CONT_RX_FILTER, + TCMD_CONT_RX_REPORT, + TCMD_CONT_RX_SETMAC, + TCMD_CONT_RX_SET_ANT_SWITCH_TABLE, + TC_CMD_RESP, + TCMD_CONT_RX_GETMAC, +} TCMD_CONT_RX_ACT; + +typedef PREPACK struct { + uint32_t testCmdId; + uint32_t act; + uint32_t enANI; + PREPACK union { + struct PREPACK TCMD_CONT_RX_PARA { + uint32_t freq; + uint32_t antenna; + uint32_t wlanMode; + } POSTPACK para; + struct PREPACK TCMD_CONT_RX_REPORT { + uint32_t totalPkt; + int32_t rssiInDBm; + uint32_t crcErrPkt; + uint32_t secErrPkt; + uint16_t rateCnt[TCMD_MAX_RATES]; + uint16_t rateCntShortGuard[TCMD_MAX_RATES]; + } POSTPACK report; + struct PREPACK TCMD_CONT_RX_MAC { + char addr[ATH_MAC_LEN]; + char btaddr[ATH_MAC_LEN]; + uint16_t regDmn[2]; + uint32_t otpWriteFlag; + } POSTPACK mac; + struct PREPACK TCMD_CONT_RX_ANT_SWITCH_TABLE { + uint32_t antswitch1; + uint32_t antswitch2; + } POSTPACK antswitchtable; + } POSTPACK u; +} POSTPACK TCMD_CONT_RX; + +typedef enum { + TC_CMDS_TS =0, + TC_CMDS_CAL, + TC_CMDS_TPCCAL = TC_CMDS_CAL, + TC_CMDS_TPCCAL_WITH_OTPWRITE, + TC_CMDS_OTPDUMP, + TC_CMDS_OTPSTREAMWRITE, + TC_CMDS_EFUSEDUMP, + TC_CMDS_EFUSEWRITE, + TC_CMDS_READTHERMAL, +} TC_CMDS_ACT; + +typedef PREPACK struct { + uint32_t testCmdId; + uint32_t act; + PREPACK union { + uint32_t enANI; // to be identical to CONT_RX struct + struct PREPACK { + uint16_t length; + uint8_t version; + uint8_t bufLen; + } POSTPACK parm; + } POSTPACK u; +} POSTPACK TC_CMDS_HDR; + +typedef PREPACK struct { + TC_CMDS_HDR hdr; + char buf[TC_CMDS_SIZE_MAX]; +} POSTPACK TC_CMDS; + +typedef enum { + TCMD_CONT_TX_ID, + TCMD_CONT_RX_ID, + TCMD_PM_ID, + TC_CMDS_ID, + TCMD_SET_REG_ID, + TC_CMD_TLV_ID, + OP_GENERIC_NART_CMD = 8, + + /*For synergy purpose we added the following tcmd id but these + tcmd's will not go to the firmware instead we will write values + to the NV area */ + + TCMD_NIC_MAC = 100, + TCMD_CAL_FILE_INDEX = 101, + TCMD_LOAD_DRIVER = 102, + TCMD_SET_MAC_ADDR = 198, +} TCMD_ID; + +#ifdef __cplusplus +} +#endif + +#endif /* TESTCMD_H_ */ diff --git a/feeds/wifi-ax/ftm/src/wds/Android.mk b/feeds/wifi-ax/ftm/src/wds/Android.mk new file mode 100755 index 000000000..1d00d925b --- /dev/null +++ b/feeds/wifi-ax/ftm/src/wds/Android.mk @@ -0,0 +1,45 @@ +ifeq ($(call is-vendor-board-platform,QCOM),true) +ifeq ($(findstring true, $(BOARD_HAVE_QCOM_FM) $(BOARD_HAVE_BLUETOOTH)),true) + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +BDROID_DIR:= system/bt +ifeq ($(TARGET_SUPPORTS_WEARABLES),true) +QTI_DIR := hardware/qcom/bt/msm8909/libbt-vendor +else +QTI_DIR := hardware/qcom/bt/libbt-vendor +endif + +LOCAL_C_INCLUDES := $(TARGET_OUT_HEADERS)/common/inc +LOCAL_C_INCLUDES += $(BDROID_DIR)/hci/include +LOCAL_C_INCLUDES += $(QTI_DIR)/include +ifeq ($(TARGET_SUPPORTS_WEARABLES),true) +LOCAL_C_INCLUDES += device/qcom/msm8909w/opensource/bluetooth/tools/hidl_client/inc +else +LOCAL_C_INCLUDES += vendor/qcom/opensource/bluetooth/tools/hidl_client/inc +endif + +LOCAL_CFLAGS := -DANDROID + +ifneq ($(BOARD_ANT_WIRELESS_DEVICE), ) +LOCAL_CFLAGS += -DCONFIG_ANT +endif +LOCAL_SRC_FILES := wds_main.c +LOCAL_SRC_FILES += wds_hci_pfal_linux.c + +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +LOCAL_MODULE := wdsdaemon +ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true) +LOCAL_PROPRIETARY_MODULE := true +endif +LOCAL_MODULE_TAGS := optional +LOCAL_SHARED_LIBRARIES := libdiag +LOCAL_SHARED_LIBRARIES += libcutils \ + libdl \ + libbt-hidlclient + +include $(BUILD_EXECUTABLE) +endif # filter +endif # is-vendor-board-platform diff --git a/feeds/wifi-ax/ftm/src/wds/wds_hci_pfal.h b/feeds/wifi-ax/ftm/src/wds/wds_hci_pfal.h new file mode 100755 index 000000000..60bd8830f --- /dev/null +++ b/feeds/wifi-ax/ftm/src/wds/wds_hci_pfal.h @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2016 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + * Copyright (c) 2012 by Qualcomm Atheros, Inc.. + * All Rights Reserved. + * Qualcomm Atheros Confidential and Proprietary. + */ + +#ifndef DEBUG +#define DEBUG printf +#endif + +#ifndef ERROR +#define ERROR printf +#endif + +#include "bt_vendor_qcom.h" + +/* error codes */ +enum { + STATUS_SUCCESS, + STATUS_ERROR, + STATUS_INVALID_LENGTH, + STATUS_NO_MEMORY, + STATUS_NULL_POINTER, + STATUS_CLIENT_ERROR, +}; + +enum { + RX_ERROR = -1, + RX_BT_EVT_IND = 1, + RX_BT_HDR, + RX_BT_DATA, + RX_ANT_HDR, + RX_ANT_DATA, + RX_FM_EVT_IND, + RX_FM_HDR, + RX_FM_DATA, + RX_PKT_IND +}; + +enum pkt_type { + BT_PKT_TYPE = 1, + FM_PKT_TYPE, + ANT_PKT_TYPE +}; +/* device to communicate between PC and DUT */ +#define BT_HS_NMEA_DEVICE "/dev/ttyGS0" +#define BT_HSLITE_UART_DEVICE "/dev/ttyHSL0" + +/* interface between PC-DUT */ +typedef struct pc_uart_interafce { + unsigned char *intf; + int uart_fd; +} pc_uart_interface; + +typedef union pc_interface { + pc_uart_interface uart; +} pc_interface; + +/* device to communicate between DUT and BTSOC */ +#define APPS_RIVA_FM_CMD_CH "/dev/smd1" +#define APPS_RIVA_BT_ACL_CH "/dev/smd2" +#define APPS_RIVA_BT_CMD_CH "/dev/smd3" +#define APPS_RIVA_ANT_CMD "/dev/smd5" +#define APPS_RIVA_ANT_DATA "/dev/smd6" +#define BT_HS_UART_DEVICE "/dev/ttyHS0" + +/* SMD interface between DUT-SOC */ +typedef struct soc_smd_interface { + unsigned char *fm_cmd; + unsigned char *bt_acl; + unsigned char *bt_cmd; + unsigned char *ant_cmd; + unsigned char *ant_data; + int fm_cmd_fd; + int bt_acl_fd; + int bt_cmd_fd; + int ant_cmd_fd; + int ant_data_fd; +} soc_smd_interface; + +/* UART interface between DUT-SOC */ +typedef struct soc_uart_interface { + unsigned char *intf; + int uart_fd; +} soc_uart_interface; + +typedef union soc_interface { + soc_smd_interface smd; + soc_uart_interface uart; +} soc_interface; + +/* context for wdsdaemon */ +typedef struct wdsdaemon { + int mode; + int soc_type; + bool pcinit_mask; + pc_interface pc_if; + soc_interface soc_if; + bool is_server_enabled; + int server_socket_fd; + pthread_t soc_rthread; +} wdsdaemon; + +/* packet types */ +#define PACKET_TYPE_INVALID (0) +#define PACKET_TYPE_BT_CMD (1) +#define PACKET_TYPE_FM_CMD (2) +#define PACKET_TYPE_BT_ACL (3) +#define PACKET_TYPE_ANT_CMD (4) +#define PACKET_TYPE_ANT_DATA (5) + +/* operation modes for wdsdaemon */ +#define MODE_BT_SMD (0) +#define MODE_FM_SMD (1) +#define MODE_ANT_SMD (2) +#define MODE_ALL_SMD (3) +#define MODE_BT_UART (4) +#define MODE_ANT_UART (5) +#define MODE_FM_UART (6) + +/* Bluetooth Header */ +#define BT_CMD_PKT_HDR_LEN (2) +#define BT_EVT_PKT_HDR_LEN (2) +#define BT_FM_PKT_UART_HDR_LEN (4) +#define BT_ACL_PKT_HDR_LEN (4) +#define BT_ACL_PKT_UART_HDR_LEN (5) + +/* FM Header */ +#define FM_CMD_PKT_HDR_LEN (3) //Opcode(2byte) + Param len(1 byte) +#define FM_EVT_PKT_HDR_LEN (2) //Opcode(1 byte) + Param len(1 byte) + +/* ANT Header */ +#define ANT_CMD_PKT_HDR_LEN (1) +#define ANT_DATA_PKT_HDR_LEN (1) +#define ANT_CMD_DATA_PKT_UART_HDR_LEN (2) + +#define BT_EVT_PKT_HDR_LEN_UART (BT_CMD_PKT_HDR_LEN+1) +#define BT_ACL_PKT_HDR_LEN_UART (BT_ACL_PKT_HDR_LEN+1) + +/* ANT data packet type */ +#define ANT_DATA_TYPE_BROADCAST (0x4E) +#define ANT_DATA_TYPE_ACKNOWLEDGED (0x4F) +#define ANT_DATA_TYPE_BURST (0x50) +#define ANT_DATA_TYPE_ADV_BURST (0x72) + +/*Packet Identifiers */ +#define BT_CMD_PKT_ID 0x01 +#define FM_CMD_PKT_ID 0x11 +#define BT_EVT_PKT_ID 0x04 +#define FM_EVT_PKT_ID 0x14 +#define ANT_CMD_PKT_ID 0x0C +#define ANT_EVT_PKT_ID 0x0C +#define ANT_DATA_PKT_ID 0x0E +#define BT_ACL_DATA_PKT_ID 0x02 + +#define SMD_BUF_SIZE (9000) +#define UART_BUF_SIZE (9000) + +#define PC_TO_SOC (1) +#define SOC_TO_PC (2) + +int get_acl_pkt_length(unsigned char, unsigned char); +unsigned short get_pkt_data_len(unsigned char type, unsigned char *buf); +int init_pc_interface(wdsdaemon *wds); +int init_soc_interface(wdsdaemon *wds); +int establish_server_socket(wdsdaemon *wds); diff --git a/feeds/wifi-ax/ftm/src/wds/wds_hci_pfal_linux.c b/feeds/wifi-ax/ftm/src/wds/wds_hci_pfal_linux.c new file mode 100755 index 000000000..05f47344a --- /dev/null +++ b/feeds/wifi-ax/ftm/src/wds/wds_hci_pfal_linux.c @@ -0,0 +1,720 @@ +/* + * Copyright (c) 2016 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + * Copyright (c) 2012 by Qualcomm Atheros, Inc.. + * All Rights Reserved. + * Qualcomm Atheros Confidential and Proprietary. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "wds_hci_pfal.h" +#include +#include +#include +#include +#include "hidl_client.h" + +#ifdef ANDROID +#include "bt_vendor_lib.h" +#else +#ifdef BT_SOC_TYPE_ROME +#include "bt_vendor_lib.h" +#endif +#endif + +#define SOCKET_NAME "wdssock" + +typedef unsigned char uint8; +extern int process_packet_type(wdsdaemon *wds, unsigned char pkt_id, + int *dst_fd, int *len, int dir); + +#ifdef ANDROID +extern int soc_type; +#endif + +static int find_max(int *arr, int len) +{ + int max = arr[0]; + int i; + + for (i = 1; i < len; i++) { + if (arr[i] > max) + max = arr[i]; + } + + return max; +} + +unsigned short get_pkt_data_len(unsigned char type, + unsigned char *buf) +{ + unsigned short len = 0; + switch (type) { + case BT_EVT_PKT_ID: + /* Event packet: 1 byte length */ + len = buf[BT_EVT_PKT_HDR_LEN_UART - 1]; + break; + case BT_ACL_DATA_PKT_ID: + /* ACL packet: 2 byte length */ + len = + (((unsigned short) buf[BT_ACL_PKT_HDR_LEN_UART - 1] << 8) & + 0xFF00) | (((unsigned short) buf[BT_ACL_PKT_HDR_LEN_UART - 2]) + & 0x00FF); + break; + case BT_CMD_PKT_ID: + len = buf[BT_EVT_PKT_HDR_LEN_UART]; + break; + case FM_CMD_PKT_ID: + /* FM Cmd packet param len: 1 byte length */ + len = buf[FM_CMD_PKT_HDR_LEN]; + break; + case FM_EVT_PKT_ID: + /* FM Evt packet param len: 1 byte length */ + len = buf[FM_EVT_PKT_HDR_LEN]; + break; + } + return len; +} + +static int process_soc_data_to_pc(wdsdaemon *wds, unsigned char *buf_in, + int src_fd) +{ + int retval = STATUS_SUCCESS; + ssize_t n_bytes = 0, n_total = 0; + int len = 1, dst_fd = 0, i; + int state = RX_PKT_IND, offset = 0; + unsigned char pkt_ind_to_read = 1; + + + /* In case of Pronto, we have different channels for CMD and ACL, + * so we don't get packet indicator from SoC. + * Below condition will skip reading packet indicator byte in + * case of Pronto. + */ + if (wds->mode != MODE_BT_UART && wds->mode != MODE_ANT_UART && + wds->mode != MODE_FM_UART) { + pkt_ind_to_read = 0; + offset++; + } + + do { + while (len) { + if (pkt_ind_to_read == 0) + goto dont_read_pkt_ind; + + if ((n_bytes = read(src_fd, + (unsigned char *)(&buf_in[offset + n_total]), + len)) > 0) { + n_total += n_bytes; + len -= n_bytes; + if (len) + continue; +dont_read_pkt_ind: + switch(state) { + case RX_PKT_IND: + pkt_ind_to_read = 1; + state = process_packet_type(wds, buf_in[0], &dst_fd, &len, + SOC_TO_PC); + break; + case RX_BT_HDR: + len = get_pkt_data_len(buf_in[0], buf_in); + state = RX_BT_DATA; + break; + case RX_BT_DATA: + len = 0; + break; + case RX_ANT_HDR: + pkt_ind_to_read = 1; + len = buf_in[n_total]; + state = RX_ANT_DATA; + break; + case RX_ANT_DATA: + if (buf_in[2] == + ANT_DATA_TYPE_BROADCAST || + buf_in[2] == + ANT_DATA_TYPE_ACKNOWLEDGED || + buf_in[2] == ANT_DATA_TYPE_BURST || + buf_in[2] == ANT_DATA_TYPE_ADV_BURST) + buf_in[0] = ANT_DATA_PKT_ID; + else + buf_in[0] = ANT_EVT_PKT_ID; + + retval = STATUS_SUCCESS; + break; + case RX_FM_HDR: + len = get_pkt_data_len(buf_in[0], buf_in); + state = RX_FM_DATA; + break; + case RX_FM_DATA: + len = 0; + break; + default: + retval = STATUS_ERROR; + break; + } + } else { + ERROR("%s Failed To read from SoC fd = %d\n",__func__, src_fd); + break; + } + } + if (retval) + break; + n_total += offset; + len = 0; + + DEBUG("evt:\t"); + for (i = 0; i < n_total; i++) + DEBUG("0x%x\t", buf_in[i]); + DEBUG("\n"); + while (n_total) { + if((n_bytes = write(dst_fd, buf_in + len, n_total)) >= 0) { + len += n_bytes; + n_total -= n_bytes; + } + else { + if (wds->is_server_enabled) { + retval = STATUS_CLIENT_ERROR; + ERROR("%s: unable to write to client socket, fd = %d err = %s\n", __func__, dst_fd, strerror(errno)); + } + else { + retval = STATUS_ERROR; + ERROR("%s: unable to write to pc_if fd = %d err = %s\n", __func__, dst_fd, strerror(errno)); + } + break; + } + } + } while (0); + + return retval; +} + +static void *process_soc_data(void *arg) +{ + int retval = STATUS_ERROR; + fd_set readfds, saved_readfds; + wdsdaemon *wds = (wdsdaemon *) arg; + int max, src_fd = 0, dst_fd = 0; + size_t sz = 0; + unsigned char *buf_in = NULL; + int arr[5], num = 0; + + FD_ZERO(&readfds); + FD_ZERO(&saved_readfds); + + if (wds->mode == MODE_BT_UART || wds->mode == MODE_ANT_UART || + wds->mode == MODE_FM_UART) { + FD_SET(wds->soc_if.uart.uart_fd, &saved_readfds); + max = wds->soc_if.uart.uart_fd; + sz = UART_BUF_SIZE * sizeof(unsigned char); + } else { + if (wds->mode == MODE_BT_SMD || wds->mode == MODE_ALL_SMD) { + FD_SET((arr[num] = wds->soc_if.smd.bt_acl_fd), &saved_readfds);num++; + FD_SET((arr[num] = wds->soc_if.smd.bt_cmd_fd), &saved_readfds);num++; + } + if (wds->mode == MODE_ANT_SMD || wds->mode == MODE_ALL_SMD) { + FD_SET((arr[num] = wds->soc_if.smd.ant_cmd_fd), &saved_readfds);num++; + FD_SET((arr[num] = wds->soc_if.smd.ant_data_fd), &saved_readfds);num++; + } + + if (wds->mode == MODE_FM_SMD || wds->mode == MODE_ALL_SMD) + FD_SET((arr[num] = wds->soc_if.smd.fm_cmd_fd), &saved_readfds);num++; + + max = find_max(arr, num); + + sz = SMD_BUF_SIZE * sizeof(unsigned char); + } + + buf_in = (unsigned char *) calloc(sz, 1); + if (!buf_in) { + ERROR("Insufficient Memory"); + retval = STATUS_NO_MEMORY; + goto failed; + } + + do { + readfds = saved_readfds; + retval = select(max + 1, &readfds, NULL, NULL, NULL); + if (retval == -1) { + ERROR("select failed, Error: %s (%d)\n", strerror(errno), + errno); + break; + } + + switch (wds->mode) { + case MODE_BT_UART: + case MODE_FM_UART: + case MODE_ANT_UART: + src_fd = wds->soc_if.uart.uart_fd; + if (FD_ISSET(src_fd,&readfds)) + retval = process_soc_data_to_pc(wds, buf_in, src_fd); + break; + case MODE_ALL_SMD: + case MODE_BT_SMD: + src_fd = wds->soc_if.smd.bt_cmd_fd; + if (FD_ISSET(src_fd ,&readfds)) { + buf_in[0] = BT_EVT_PKT_ID; + retval = process_soc_data_to_pc(wds, buf_in,src_fd); + } + src_fd = wds->soc_if.smd.bt_acl_fd; + if (FD_ISSET(src_fd ,&readfds)) { + buf_in[0] = BT_ACL_DATA_PKT_ID; + retval = process_soc_data_to_pc(wds, buf_in, src_fd); + } + if (wds->mode == MODE_BT_SMD) + break; + case MODE_FM_SMD: + src_fd = wds->soc_if.smd.fm_cmd_fd; + if (FD_ISSET(src_fd ,&readfds)) { + buf_in[0] = FM_EVT_PKT_ID; + retval = process_soc_data_to_pc(wds, buf_in, src_fd); + } + if (wds->mode == MODE_FM_SMD) + break; + break; + case MODE_ANT_SMD: + src_fd = wds->soc_if.smd.ant_cmd_fd; + if (FD_ISSET(src_fd, &readfds)) { + buf_in[0] = ANT_EVT_PKT_ID; + retval = process_soc_data_to_pc(wds, buf_in, src_fd); + } + src_fd = wds->soc_if.smd.ant_data_fd; + if (FD_ISSET(src_fd ,&readfds)) { + buf_in[0] = ANT_DATA_PKT_ID; + retval = process_soc_data_to_pc(wds, buf_in, src_fd); + } + break; + } + + if (STATUS_SUCCESS != retval) { + if (retval == STATUS_CLIENT_ERROR) { + ERROR("Write to client failed\n"); + continue; + } + ERROR("Failed to process SOC data\n"); + break; + } + } while(1); + +failed: + ERROR("\nReader thread exited\n"); + if (buf_in) { + free(buf_in); + buf_in = NULL; + } + return 0; +} + +static int set_port_raw_mode(int fd) +{ + struct termios term; + int ret = STATUS_SUCCESS; + + if (tcgetattr(fd, &term) < 0) { + ERROR("Failed to get attributes"); + ERROR("Error: %s (%d)", strerror(errno), errno); + return STATUS_ERROR; + } + cfmakeraw(&term); + if (tcsetattr(fd, TCSANOW, &term) < 0) { + ERROR("Failed to set attributes"); + ERROR("Error: %s (%d)", strerror(errno), errno); + return STATUS_ERROR; + } + if (tcflush(fd, TCIFLUSH) < 0) { + ERROR("Failed to flush port"); + ERROR("Error: %s (%d)", strerror(errno), errno); + return STATUS_ERROR; + } + + return ret; +} + +/*=========================================================================== +FUNCTION port_init_libbt + +DESCRIPTION +Initilize port and open the file through libbt-vendor + +DEPENDENCIES +NIL + +RETURN VALUE +RETURN fd handle + +SIDE EFFECTS +None + +===========================================================================*/ +#ifndef BT_BLUEZ +static int port_init_libbt(uint8 option) +{ + int fd_array[CH_MAX]; + bt_vendor_callbacks_t cb; + uint8_t init_bd_addr[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; + bt_vendor_interface_t * p_btf = NULL; + bt_vendor_opcode_t opCmd1, opCmd2; + int iState; + + void* vendor_handle = dlopen("libbt-vendor.so", RTLD_NOW); + if(!vendor_handle){ + ERROR("Error open libbt-vendor \n"); + return -1; + } + p_btf = (bt_vendor_interface_t *)dlsym(vendor_handle, + "BLUETOOTH_VENDOR_LIB_INTERFACE"); + if(!p_btf){ + ERROR("Failed obtain the address of libbt-vendor \n"); + return -1; + } + if (p_btf->init(&cb, &init_bd_addr[0]) < 0){ + ERROR("bt vendor init failed \n"); + return -1; + } + + switch (option) { + case MODE_BT_UART: + opCmd1 = BT_VND_OP_POWER_CTRL; + opCmd2 = BT_VND_OP_USERIAL_OPEN; + break; + case MODE_FM_UART: + opCmd1 = FM_VND_OP_POWER_CTRL; + opCmd2 = BT_VND_OP_FM_USERIAL_OPEN; + break; + case MODE_ANT_UART: + opCmd1 = BT_VND_OP_POWER_CTRL; + opCmd2 = BT_VND_OP_USERIAL_OPEN; + break; + default: + printf("Invalid option\n"); + return -1; + } + + iState = BT_VND_PWR_ON; + + if (p_btf->op(opCmd1, &iState) < 0){ + ERROR("Power on failed \n"); + return -1; + } + + if (p_btf->op(opCmd2, (void*)fd_array) < 0){ + ERROR("op(VND_OP_USERIAL_OPEN) failed \n"); + return -1; + } + + return fd_array[0]; +} +#endif + +static int change_baud(int fd, speed_t baud) +{ + struct termios term; + int ret = STATUS_SUCCESS; /* assume success */ + + do { + if (tcgetattr(fd, &term) < 0) { + ERROR("Failed to get attributes"); + ret = STATUS_ERROR; + break; + } + cfsetospeed(&term, baud); + /* don't change speed until last write done */ + if (tcsetattr(fd, TCSADRAIN, &term) < 0) { + ERROR("Failed to set attribute"); + ERROR("Error: %s (%d)", strerror(errno), errno); + ret = STATUS_ERROR; + break; + } + } while(0); + return 0; +} + +int init_soc_interface(wdsdaemon *wds) +{ + int ret = STATUS_ERROR; + int fd = 0; + struct termios term; + + if (!wds) { + ret = STATUS_NULL_POINTER; + ERROR("Invalid input argument\n"); + return ret; + } + + switch (wds->mode) { + case MODE_FM_UART: + if(hidl_client_initialize(MODE_FM,&fd) == false) + { + ERROR("HIDL client initialization failed"); + exit(1); + } + wds->soc_if.uart.uart_fd = fd; + ret = STATUS_SUCCESS; + break; + case MODE_BT_UART: +#ifdef BT_BLUEZ + fd = open(wds->soc_if.uart.intf, + O_RDWR | O_NONBLOCK | O_NOCTTY); + if (-1 == fd) { + ERROR("Failed to open port: %s\n", + wds->soc_if.uart.intf); + ERROR("Error: %s (%d)", strerror(errno), errno); + break; + } + if (tcflush(fd, TCIOFLUSH) < 0) { + ERROR("Failed to flush port: %s\n", + wds->soc_if.uart.intf); + ERROR("Error: %s (%d)", strerror(errno), errno); + close(fd); + break; + } + if (tcgetattr(fd, &term) < 0) { + ERROR("Failed to get attributes for port: %s\n", + wds->soc_if.uart.intf); + ERROR("Error: %s (%d)", strerror(errno), errno); + close(fd); + break; + } + cfmakeraw(&term); + /* enable flow control */ + term.c_cflag |= (CRTSCTS | CLOCAL); + if (tcsetattr(fd, TCSANOW, &term) < 0) { + ERROR("Failed to set attributes for port: %s\n", + wds->soc_if.uart.intf); + ERROR("Error: %s (%d)", strerror(errno), errno); + close(fd); + break; + } + if (STATUS_SUCCESS != change_baud(fd, B3000000)) { //TODO:set baud rate + ERROR("Failed to change baud rate\n"); + close(fd); + break; + } +#else + if(hidl_client_initialize(MODE_BT,&fd) == false) + { + ERROR("HIDL client initialization failed"); + exit(1); + } +#endif + /* everything okay */ + wds->soc_if.uart.uart_fd = fd; + ret = STATUS_SUCCESS; + break; + case MODE_ANT_UART: +#ifndef BT_BLUEZ + if(hidl_client_initialize(MODE_ANT,&fd) == true){ + wds->soc_if.uart.uart_fd = fd; + } + else { + ERROR("HIDL client initialization failed, opening port with port_init_libbt\n"); + wds->soc_if.uart.uart_fd = port_init_libbt(wds->mode); + } + ret = STATUS_SUCCESS; +#endif + break; + case MODE_ALL_SMD: + case MODE_ANT_SMD: + /* ANT commdnas */ + fd = open(wds->soc_if.smd.ant_cmd, + O_RDWR | O_NONBLOCK | O_NOCTTY); + if (-1 == fd) { + ERROR("Failed to open port: %s\n", + wds->soc_if.smd.ant_cmd); + ERROR("Error: %s (%d)\n", strerror(errno), + errno); + break; + } + set_port_raw_mode(fd); + wds->soc_if.smd.ant_cmd_fd = fd; + /* ANT data */ + fd = open(wds->soc_if.smd.ant_data, + O_RDWR | O_NONBLOCK | O_NOCTTY); + if (-1 == fd) { + ERROR("Failed to open port: %s\n", + wds->soc_if.smd.ant_data); + ERROR("Error: %s (%d)", strerror(errno), + errno); + break; + } + set_port_raw_mode(fd); + wds->soc_if.smd.ant_data_fd = fd; + if (wds->mode == MODE_ANT_SMD) { + ret = STATUS_SUCCESS; + break; + } + /* fallthrough intentional for MODE_ALL_SMD */ + case MODE_BT_SMD: + /* BT commdnas */ + fd = open(wds->soc_if.smd.bt_cmd, + O_RDWR | O_NONBLOCK | O_NOCTTY); + if (-1 == fd) { + ERROR("Failed to open port: %s\n", + wds->soc_if.smd.bt_cmd_fd); + ERROR("Error: %s (%d)\n", + strerror(errno), errno); + break; + } + set_port_raw_mode(fd); + wds->soc_if.smd.bt_cmd_fd = fd; + /* BT ACL */ + fd = open(wds->soc_if.smd.bt_acl, + O_RDWR | O_NONBLOCK | O_NOCTTY); + if (-1 == fd) { + ERROR("Failed to open port: %s\n", + wds->soc_if.smd.bt_acl); + ERROR("Error: %s (%d)\n", + strerror(errno), errno); + break; + } + set_port_raw_mode(fd); + wds->soc_if.smd.bt_acl_fd = fd; + if (wds->mode == MODE_BT_SMD) { + ret = STATUS_SUCCESS; + break; + } + /* fallthrough intentional for MODE_ALL_SMD */ + case MODE_FM_SMD: + /* FM commdnas */ + fd = open(wds->soc_if.smd.fm_cmd, O_RDWR | O_NONBLOCK | O_NOCTTY); + if (-1 == fd) { + ERROR("Failed to open port: %s\n", + wds->soc_if.smd.fm_cmd_fd); + ERROR("Error: %s (%d)\n", + strerror(errno), errno); + break; + } + set_port_raw_mode(fd); + wds->soc_if.smd.fm_cmd_fd = fd; + ret = STATUS_SUCCESS; + break; + } + + if (ret == STATUS_SUCCESS) + if (pthread_create(&wds->soc_rthread, NULL, process_soc_data, + wds) != 0) { + ERROR("%s:Unable to create pthread err = %s\n", __func__, + strerror(errno)); + close(fd); + ret = STATUS_ERROR; + } + +failed: + return ret; +} + +int init_pc_interface(wdsdaemon *wds) +{ + int fd = 0; + int ret = STATUS_ERROR; + struct termios term; + + if (!wds) { + ret = STATUS_NULL_POINTER; + ERROR("Invalid input argument"); + return ret; + } + + do { + fd = open(wds->pc_if.uart.intf, O_RDWR); + if (-1 == fd) { + ERROR("Unable to open port: %s", wds->pc_if.uart.intf); + ERROR("Error: %s (%d)", strerror(errno), errno); + ret = STATUS_ERROR; + break; + } + /* set terminal properties */ + if (tcgetattr(fd, &term) < 0) { + ERROR("Failed to get attributes of port: %s", + wds->pc_if.uart.intf); + ERROR("Error: %s (%d)", strerror(errno), errno); + close(fd); + ret = STATUS_ERROR; + break; + } + cfmakeraw(&term); + term.c_lflag = term.c_lflag & ((tcflag_t)(~ECHO)); + /* TODO: Make baud rate command line argument */ + cfsetospeed(&term, B115200); + cfsetispeed(&term, B115200); + if (tcsetattr(fd, TCSANOW, &term) < 0) { + ERROR("Failed to set attributes of port: %s", + wds->pc_if.uart.intf); + ERROR("Error: %s (%d)", strerror(errno), errno); + close(fd); + ret = STATUS_ERROR; + break; + } + tcflush(fd, TCIOFLUSH); + + /* everything okay, set success */ + wds->pc_if.uart.uart_fd = fd; + ret = STATUS_SUCCESS; + } while(0); + + return ret; +} + +int establish_server_socket(wdsdaemon *wds) +{ + int fd = -1; + struct sockaddr_un client_address; + socklen_t clen; + int sock_id, ret = STATUS_ERROR; + DEBUG("%s(%s) Entry \n", __func__, SOCKET_NAME); + + if (!wds) { + ret = STATUS_NULL_POINTER; + ERROR("Invalid input argument\n"); + return ret; + } + + sock_id = socket(AF_LOCAL, SOCK_STREAM, 0); + if (sock_id < 0) { + ERROR("%s: server Socket creation failure\n", __func__); + return ret; + } + + DEBUG("convert name to android abstract name:%s %d\n", SOCKET_NAME, sock_id); + if (socket_local_server_bind(sock_id, + SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_ABSTRACT) >= 0) { + if (listen(sock_id, 5) == 0) { + DEBUG("listen to local socket:%s, fd:%d\n", SOCKET_NAME, sock_id); + } else { + ERROR("listen to local socket:failed\n"); + close(sock_id); + return ret; + } + } else { + close(sock_id); + ERROR("%s: server bind failed for socket : %s\n", __func__, SOCKET_NAME); + return ret; + } + + clen = sizeof(client_address); + DEBUG("%s: before accept_server_socket\n", SOCKET_NAME); + fd = accept(sock_id, (struct sockaddr *)&client_address, &clen); + if (fd > 0) { + DEBUG("%s accepted fd:%d for server fd:%d\n", SOCKET_NAME, fd, sock_id); + close(sock_id); + wds->server_socket_fd = fd; + return STATUS_SUCCESS; + } else { + ERROR("Accept failed fd:%d sock d:%d error %s\n", fd, sock_id, strerror(errno)); + close(sock_id); + return ret; + } +} diff --git a/feeds/wifi-ax/ftm/src/wds/wds_main.c b/feeds/wifi-ax/ftm/src/wds/wds_main.c new file mode 100755 index 000000000..9c1c8f768 --- /dev/null +++ b/feeds/wifi-ax/ftm/src/wds/wds_main.c @@ -0,0 +1,568 @@ +/* + * Copyright (c) 2016 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + * Copyright (c) 2012 by Qualcomm Atheros, Inc.. + * All Rights Reserved. + * Qualcomm Atheros Confidential and Proprietary. + */ + +/* +* Description: +* Added wdsdaemon to enable testing of Host Controller Interface (HCI) +* communication with stack layers bypassed. +* 1. Acts as a communication bridge between PC to DUT over UART (/dev/ttyHSL0) +* and also UART transport between DUT and BTSOC (/dev/ttyHS0). +* 2. Used to test exchange of BT-FM HCI commands, events and ACL data packets +* between host and controller. +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "wds_hci_pfal.h" +#include "hidl_client.h" + +#ifdef ANDROID +#include +#endif + +/*=========================================================================== +FUNCTION get_pkt_type + +DESCRIPTION + Routine to get the packet type from the data bytes received + +DEPENDENCIES + NIL + +RETURN VALUE + Packet type for the data bytes received + +SIDE EFFECTS + None + +===========================================================================*/ +static int get_packet_type(unsigned char id) +{ + int type; + + switch (id) { + case BT_CMD_PKT_ID: + type = PACKET_TYPE_BT_CMD; + break; + case FM_CMD_PKT_ID: + type = PACKET_TYPE_FM_CMD; + break; + case BT_ACL_DATA_PKT_ID: + type = PACKET_TYPE_BT_ACL; + break; + case ANT_CMD_PKT_ID: + type = PACKET_TYPE_ANT_CMD; + break; + case ANT_DATA_PKT_ID: + type = PACKET_TYPE_ANT_DATA; + break; + default: + type = PACKET_TYPE_INVALID; + } + + return type; +} + +#ifdef ANDROID + +int soc_type; + +/** Get Bluetooth SoC type from system setting */ +static int get_bt_soc_type() +{ + int ret = 0; + char bt_soc_type[PROPERTY_VALUE_MAX]; + + DEBUG("bt-hci: get_bt_soc_type\n"); + + ret = property_get("qcom.bluetooth.soc", bt_soc_type, NULL); + if (ret != 0) { + DEBUG("qcom.bluetooth.soc set to %s\n", bt_soc_type); + if (!strncasecmp(bt_soc_type, "rome", sizeof("rome"))) { + return BT_SOC_ROME; + } + else if (!strncasecmp(bt_soc_type, "cherokee", sizeof("cherokee"))) { + return BT_SOC_CHEROKEE; + } + else if (!strncasecmp(bt_soc_type, "ath3k", sizeof("ath3k"))) { + return BT_SOC_AR3K; + } + else if (!strncasecmp(bt_soc_type, "napier", sizeof("napier"))) { + return BT_SOC_NAPIER; + } + else { + DEBUG("qcom.bluetooth.soc not set, so using default.\n"); + return BT_SOC_DEFAULT; + } + } + else { + DEBUG("%s: Failed to get soc type\n", __FUNCTION__); + ret = BT_SOC_DEFAULT; + } + + return ret; +} +#endif + +static int parse_options(wdsdaemon *wds, int argc, char *argv[]) +{ + int ret = STATUS_SUCCESS; + int opt; + + if (argc > 2) { + ERROR("Invalid number of arguments\n"); + ret = STATUS_INVALID_LENGTH; + ERROR("Usage %s [-abfunht]", argv[0]); + return ret; + } + + if (argc == 1) { + wds->mode = MODE_ALL_SMD; + return ret; + } + + while ((opt = getopt(argc, argv, "abfunhstm")) != -1) { + switch (opt) { + case 'a': + DEBUG("Opening ANT SMD channels\n"); + wds->mode = MODE_ANT_SMD; + break; + case 'b': + DEBUG("Opening BT SMD channels\n"); + wds->mode = MODE_BT_SMD; + break; + case 'f': + DEBUG("Opening FM SMD channels\n"); + wds->mode = MODE_FM_SMD; + break; + case 't': + ERROR("Setting mask for pc initialization\n"); + wds->pcinit_mask = true; + break; + case 's': + ERROR("Opening WDS server socket\n"); + wds->is_server_enabled = true; + wds->pcinit_mask = true; + break; +#ifdef ANDROID + if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE) { + case 'u': + DEBUG("Opening UART BT Channel\n"); + wds->mode = MODE_BT_UART; + break; + } + if (soc_type == BT_SOC_CHEROKEE) { + case 'm': + DEBUG("Opening UART FM Channel\n"); + wds->mode = MODE_FM_UART; + break; + } +#else +#ifdef BT_SOC_TYPE_ROME + case 'u': + DEBUG("Opening UART BT Channel\n"); + wds->mode = MODE_BT_UART; + break; +#endif +#endif +#ifdef CONFIG_ANT + case 'n': + ERROR("Opening ANT UART channels\n"); + wds->mode = MODE_ANT_UART; + break; +#endif + case 'h': + DEBUG("By Default, it will open all SMD channels\n"); + DEBUG("Use -a for opening only ANT Channels\n"); + DEBUG("Use -b for opening only BT Channels\n"); + DEBUG("Use -f for opening only FM Channels\n"); + +#ifdef ANDROID + if (soc_type == BT_SOC_ROME || soc_type == BT_SOC_CHEROKEE) { + DEBUG("Use -u for opening only UART Channel for BT (ROME)\n"); + } + if (soc_type == BT_SOC_CHEROKEE) { + DEBUG("Use -m for opening only UART Channel for FM\n"); + } +#else +#ifdef BT_SOC_TYPE_ROME + DEBUG("Use -u for opening only UART Channel for BT (ROME)\n"); +#endif +#endif + +#ifdef CONFIG_ANT + DEBUG("Use -n for opening ANT UART channels only\n"); +#endif + DEBUG("Use -t for masking pc initialization\n"); + DEBUG("Use -s for setting communication via server socket\n"); + DEBUG("Use -h to print help\n"); + ret = STATUS_ERROR; + break; + default: + DEBUG("Usage %s [-abfunhmst]\n", argv[0]); + ret = STATUS_ERROR; + break; + } + } + + return ret; +} + +static void wdsdaemon_init(wdsdaemon *wds) +{ + /* PC-DUT interface */ +#ifdef BT_BLUEZ + wds->pc_if.uart.intf = (unsigned char *)BT_HSLITE_UART_DEVICE; +#else + wds->pc_if.uart.intf = (unsigned char *)BT_HS_NMEA_DEVICE; +#endif + + /* DUT-BTSOC interface */ + switch (wds->mode) { + case MODE_ALL_SMD: + wds->soc_if.smd.fm_cmd = (unsigned char *)APPS_RIVA_FM_CMD_CH; + wds->soc_if.smd.bt_acl = (unsigned char*)APPS_RIVA_BT_ACL_CH; + wds->soc_if.smd.bt_cmd = (unsigned char *)APPS_RIVA_BT_CMD_CH; + wds->soc_if.smd.ant_cmd = (unsigned char *)APPS_RIVA_ANT_CMD; + wds->soc_if.smd.ant_data = (unsigned char *)APPS_RIVA_ANT_DATA; + break; + case MODE_ANT_SMD: + wds->soc_if.smd.ant_cmd = (unsigned char *)APPS_RIVA_ANT_CMD; + wds->soc_if.smd.ant_data = (unsigned char *)APPS_RIVA_ANT_DATA; + break; + case MODE_BT_SMD: + wds->soc_if.smd.bt_acl = (unsigned char *)APPS_RIVA_BT_ACL_CH; + wds->soc_if.smd.bt_cmd = (unsigned char *)APPS_RIVA_BT_CMD_CH; + break; + case MODE_FM_SMD: + wds->soc_if.smd.fm_cmd = (unsigned char *)APPS_RIVA_FM_CMD_CH; + break; + case MODE_BT_UART: + case MODE_ANT_UART: + wds->soc_if.uart.intf = (unsigned char *)BT_HS_UART_DEVICE; + break; + } +} + +int process_packet_type(wdsdaemon *wds, unsigned char pkt_id, + int *dst_fd, int *len, int dir) +{ + int state; + + switch(pkt_id) { + case BT_CMD_PKT_ID: + *len = BT_EVT_PKT_HDR_LEN_UART; + case BT_EVT_PKT_ID: + case BT_ACL_DATA_PKT_ID: + state = RX_BT_HDR; + if (wds->mode == MODE_BT_UART) + *dst_fd = wds->soc_if.uart.uart_fd; + else + if (pkt_id == BT_CMD_PKT_ID) + *dst_fd = wds->soc_if.smd.bt_cmd_fd; + else + *dst_fd = wds->soc_if.smd.bt_acl_fd; + if (pkt_id == BT_ACL_DATA_PKT_ID) + *len = BT_ACL_PKT_HDR_LEN; + else if (pkt_id == BT_EVT_PKT_ID) + *len = BT_EVT_PKT_HDR_LEN; + break; + case FM_CMD_PKT_ID: + if (wds-> mode == MODE_FM_UART) + *dst_fd = wds->soc_if.uart.uart_fd; + else + *dst_fd = wds->soc_if.smd.fm_cmd_fd; + case FM_EVT_PKT_ID: + state = RX_FM_HDR; + if (pkt_id == FM_CMD_PKT_ID) + *len = FM_CMD_PKT_HDR_LEN; + else if (pkt_id == FM_EVT_PKT_ID) + *len = FM_EVT_PKT_HDR_LEN; + break; + case ANT_CMD_PKT_ID: + case ANT_DATA_PKT_ID: + state = RX_ANT_HDR; + if (wds->mode == MODE_ANT_UART) + *dst_fd = wds->soc_if.uart.uart_fd; + else + if (pkt_id == ANT_CMD_PKT_ID) + *dst_fd = wds->soc_if.smd.ant_cmd_fd; + else + *dst_fd = wds->soc_if.smd.ant_data_fd; + break; + default: + state = RX_ERROR; + break; + } + + if (dir == SOC_TO_PC) { + if (wds->is_server_enabled) + *dst_fd = wds->server_socket_fd; + else + *dst_fd = wds->pc_if.uart.uart_fd; + } + + return state; +} + +static int process_pc_data_to_soc(wdsdaemon *wds, unsigned char *buf, int src_fd) +{ + int retval = STATUS_SUCCESS; + int len = 1, n_bytes = 0, n_total = 0; + int pkt_id = 0, dst_fd = 0; + int state = RX_PKT_IND, i; + + do { + if ((n_bytes = read(src_fd, (unsigned char *)&buf[n_total], len)) > 0) { + n_total += n_bytes; + len -= n_bytes; + if (len) + continue; + + switch(state) { + case RX_PKT_IND: + pkt_id = buf[0]; + state = process_packet_type(wds, pkt_id, &dst_fd, &len, + PC_TO_SOC); + break; + case RX_BT_HDR: + len = get_pkt_data_len(pkt_id, buf); + state = RX_BT_DATA; + break; + case RX_ANT_HDR: + len = buf[0]; + state = RX_ANT_DATA; + break; + case RX_FM_HDR: + len = get_pkt_data_len(pkt_id, buf); + state = RX_FM_DATA; + break; + case RX_BT_DATA: + case RX_ANT_DATA: + case RX_FM_DATA: + len = 0; + break; + default: + retval = STATUS_ERROR; + break; + } + } else { + ERROR("%s: error while reading from fd = %d err = %s\n", + __func__, src_fd, strerror(errno)); + if (n_bytes < 0) + ERROR("%s:read returns err: %d\n", __func__,n_bytes); + if (n_bytes == 0) + ERROR("%s: This indicates the close of other end\n", __func__); + retval = STATUS_ERROR; + break; + } + } while (len); + + if(retval) + goto fail; + + /* In case of Pronto, for BT, we have different channels for CMD and ACL, + * so we don't send packet indicator to SoC. + * Below condition will skip the packet indicator byte to Soc in\ + * case of Pronto. + */ + if (wds->mode != MODE_BT_UART && wds->mode != MODE_ANT_UART && + wds->mode != MODE_FM_UART) { + n_total -= 1; + len = 1; + } + while(n_total) { + if((n_bytes = write(dst_fd, buf + len, n_total)) > 0) { + len += n_bytes; + n_total -= n_bytes; + } else + ERROR("%s :Error while writeto fd = %d err = %s\n", + __func__, dst_fd, strerror(errno)); + break; + } + + DEBUG("cmd:\t"); + for (i = 0; i < len; i++) + DEBUG("0x%x\t", buf[i]); + DEBUG("\n"); + + if (n_total) + retval = STATUS_ERROR; + +fail: + return retval; +} + +static void thread_exit_handler(int signo){ + DEBUG("%s: %d",__func__,signo); +} + +int server_create(wdsdaemon *wds,int *src_fd) { + int retval = establish_server_socket(wds); + if (STATUS_SUCCESS == retval) + *src_fd = wds->server_socket_fd; + else + ERROR("Failed to init server socket\n"); + + return retval; +} + +int main(int argc, char *argv[]) +{ + int retval = STATUS_ERROR, src_fd = 0; + fd_set readfds; + wdsdaemon wds; + unsigned char *buf = NULL; + size_t size = UART_BUF_SIZE; + struct sigaction action; + sigset_t sigmask, emptymask; + + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGINT); + sigaddset(&sigmask, SIGPIPE); + if (sigprocmask(SIG_BLOCK, &sigmask, NULL) == -1) { + ERROR("failed to sigprocmask"); + } + memset(&action, 0, sizeof(struct sigaction)); + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + action.sa_handler = thread_exit_handler; + + sigemptyset(&emptymask); + + if (sigaction(SIGINT, &action, NULL) < 0) { + ERROR("%s:sigaction failed\n", __func__); + } + + memset(&wds, 0, sizeof(wdsdaemon)); + +#ifdef ANDROID + soc_type = get_bt_soc_type(); +#endif + + /* parse options */ + retval = parse_options(&wds, argc, argv); + if (STATUS_SUCCESS != retval) { + goto fail; + } + + wdsdaemon_init(&wds); + + if(!(wds.pcinit_mask)) + { + retval = init_pc_interface(&wds); + if (STATUS_SUCCESS != retval) { + ERROR("Failed to init DUT-PC interface\n"); + goto fail; + } + src_fd = wds.pc_if.uart.uart_fd; + } + + retval = init_soc_interface(&wds); + if (STATUS_SUCCESS != retval) { + ERROR("Failed to init DUT-BTSOC interface\n"); + goto fail; + } +#ifdef BT_BLUEZ + fflush(stdout); + fflush(stderr); +#endif + + buf = (unsigned char *)calloc(size, 1); + if (!buf) { + ERROR("%s:Unable to allocate memory\n", __func__); + goto fail; + } + + if( wds.is_server_enabled && ( server_create(&wds, &src_fd)!= STATUS_SUCCESS )) + goto fail; + + do { + FD_ZERO(&readfds); + FD_SET(src_fd, &readfds); + + DEBUG("Waiting for data:\n"); + if ((retval = select(src_fd + 1, &readfds, NULL, NULL, NULL)) == -1) { + ERROR("%s:select failed\n", __func__); + if (wds.is_server_enabled) + { + ERROR("%s:closing the server socket and reopening\n", __func__); + close(src_fd); + if(server_create(&wds, &src_fd)== STATUS_SUCCESS) + continue; + } + break; + } + + if (FD_ISSET(src_fd, &readfds)) { + retval = process_pc_data_to_soc(&wds, buf, src_fd); + } else + ERROR("%s:src_fd port not set\n",__func__); + if (retval != STATUS_SUCCESS) { + ERROR("%s: Error while processing Data to SoC err = %d\n", __func__, retval); + if (wds.is_server_enabled) + { + ERROR("%s:closing the server socket and reopening\n", __func__); + close(src_fd); + if(server_create(&wds, &src_fd)== STATUS_SUCCESS) + continue; + } + break; + } + }while(1); + +fail: + if (buf) + free(buf); + shutdown(src_fd, SHUT_RDWR); + switch (wds.mode) { + case MODE_BT_UART: + case MODE_FM_UART: + case MODE_ANT_UART: + shutdown(wds.soc_if.uart.uart_fd, SHUT_RDWR); + break; + case MODE_ALL_SMD: + case MODE_BT_SMD: + shutdown(wds.soc_if.smd.bt_cmd_fd, SHUT_RDWR); + shutdown(wds.soc_if.smd.bt_acl_fd, SHUT_RDWR); + if(wds.mode == MODE_BT_SMD) + break; + case MODE_FM_SMD: + shutdown(wds.soc_if.smd.fm_cmd_fd, SHUT_RDWR); + if (wds.mode == MODE_FM_SMD) + break; + case MODE_ANT_SMD: + shutdown(wds.soc_if.smd.ant_cmd_fd, SHUT_RDWR); + shutdown(wds.soc_if.smd.ant_data_fd, SHUT_RDWR); + break; + } + pthread_join(wds.soc_rthread, NULL); + + hidl_client_close(); + return retval; +} diff --git a/feeds/wifi-ax/libtcmd/Makefile b/feeds/wifi-ax/libtcmd/Makefile new file mode 100755 index 000000000..694a43b9f --- /dev/null +++ b/feeds/wifi-ax/libtcmd/Makefile @@ -0,0 +1,54 @@ +include $(TOPDIR)/rules.mk + +PKG:=libtcmd +PKG_NAME:=$(PKG) +PKG_RELEASE:=1 + +PKG_VERSION:=11.5 + +include $(INCLUDE_DIR)/package.mk + +define Package/$(PKG_NAME) + SECTION:=QCA + CATEGORY:=QCA + URL:=http://www.qca.qualcomm.com + MAINTAINER:=Qualcomm Atheros + TITLE:= QCA libtcmd utils + DEPENDS:= @TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64||TARGET_ipq807x||TARGET_ipq50xx||TARGET_ipq60xx||TARGET_ipq95xx +libpthread +libnl +endef + +define Package/$(PKG_NAME)/description/Default + LIBTCMD Package Support for QCA WIFI 11 drivers +endef + + +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include \ + -I$(STAGING_DIR)/usr/include/libnl3 \ + -I$(STAGING_DIR)/include \ + -fPIC -DWLAN_API_NL80211 -DLIBNL_2 -DWIN_AP_HOST + +TARGET_LDFLAGS += -lnl-3 -lnl-genl-3 -shared + +ifneq ($(CONFIG_PACKAGE_kmod-ath11k),) + TARGET_CFLAGS+=-DWIN_AP_HOST_OPEN=1 +endif + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS)" +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ + $(CP) $(PKG_BUILD_DIR)/*.h $(1)/usr/include/ + $(CP) $(PKG_BUILD_DIR)/libtcmd.so $(1)/usr/lib/ +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_BIN) $(PKG_BUILD_DIR)/libtcmd.so $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libtcmd)) diff --git a/feeds/wifi-ax/libtcmd/src/Android.mk b/feeds/wifi-ax/libtcmd/src/Android.mk new file mode 100755 index 000000000..2037bb0fc --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/Android.mk @@ -0,0 +1,54 @@ +LOCAL_PATH:=$(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := libtcmd_headers +LOCAL_CFLAGS := -Werror +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) +LOCAL_PROPRIETARY_MODULE := true +include $(BUILD_HEADER_LIBRARY) + +# Build libtcmd ========================= +include $(CLEAR_VARS) + +LOCAL_CLANG := true +LOCAL_MODULE := libtcmd +LOCAL_SRC_FILES:= \ + nl80211.c \ + libtcmd.c \ + os.c + +ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED), true) +LOCAL_PROPRIETARY_MODULE := true +endif + +ifeq ($(BOARD_HAS_ATH_WLAN_AR6004),true) + LOCAL_CFLAGS+= -DCONFIG_AR6002_REV6 +endif + +ifneq ($(wildcard external/libnl-headers),) +LOCAL_C_INCLUDES += external/libnl-headers +else +LOCAL_C_INCLUDES += external/libnl/include external/libnl/include/linux-private +endif + +LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include +LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr + +LOCAL_CFLAGS += \ + -DWLAN_API_NL80211 \ + -DANDROID \ + -DLIBNL_2 \ + -DSYSCONFDIR="\"/etc/libnl\""\ + -Werror + +ifneq ($(wildcard system/core/libnl_2),) +# ICS ships with libnl 2.0 +LOCAL_SHARED_LIBRARIES := libnl_2 +else +LOCAL_SHARED_LIBRARIES := libnl +endif + +LOCAL_MODULE_OWNER := qcom +LOCAL_SANITIZE := signed-integer-overflow unsigned-integer-overflow + +include $(BUILD_STATIC_LIBRARY) diff --git a/feeds/wifi-ax/libtcmd/src/Makefile b/feeds/wifi-ax/libtcmd/src/Makefile new file mode 100755 index 000000000..e5adea22c --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/Makefile @@ -0,0 +1,24 @@ +#CC := $(ATH_CROSS_COMPILE_TYPE)gcc +CC = gcc + +CFLAGS += -DWLAN_API_NL80211 -DLIBNL_2 +LDFLAGS += -shared + +TARGET_LIB = libtcmd.so +SRCS = os.c nl80211.c libtcmd.c +OBJS = $(SRCS:.c=.o) + +.PHONY=: all + +all: ${TARGET_LIB} + +$(TARGET_LIB): $(OBJS) + $(CC) ${LDFLAGS} -o $@ $^ + +$(SRCS:.c=.d):%.d:%.c + $(CC) $(CFLAGS) -MM $< >$@ + +.PHONY: clean + +clean: + rm -f ${TARGET_LIB} ${OBJS} diff --git a/feeds/wifi-ax/libtcmd/src/Makefile.am b/feeds/wifi-ax/libtcmd/src/Makefile.am new file mode 100755 index 000000000..b33bdfe81 --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/Makefile.am @@ -0,0 +1,23 @@ +AM_CFLAGS = -Wall \ + -g -O0 \ + -DLIBNL_2 \ + -DWLAN_API_NL80211 \ + $(LIBNL_CFLAGS) + +if USE_GLIB +AM_CFLAGS += -DUSE_GLIB $(GLIB_CFLAGS) +endif + +if MDM_SET +AM_CFLAGS += -DMDM +endif + +c_sources = os.c \ + nl80211.c \ + libtcmd.c + +AM_CFLAGS += -DWLAN_API_NL80211 +lib_LIBRARIES = libtcmd.a +libtcmd_a_SOURCES = $(c_sources) +libtcmd_a_LDFLAGS = -static +pkginclude_HEADERS = libtcmd.h diff --git a/feeds/wifi-ax/libtcmd/src/libtcmd.c b/feeds/wifi-ax/libtcmd/src/libtcmd.c new file mode 100755 index 000000000..db8cc9d16 --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/libtcmd.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2019 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. +*/ + +/* +* 2011-2012, 2016 Qualcomm Atheros Inc. All Rights Reserved. +* Qualcomm Atheros Proprietary and Confidential. +*/ + +#include "string.h" +#include "libtcmd.h" +#include "os.h" + +#ifdef USE_GLIB +#include +#define strlcat g_strlcat +#define strlcpy g_strlcpy +#endif + +int tcmd_tx(void *buf, int len, bool resp) +{ + int err = 0; + + /* XXX: just call nl80211 directly for now */ +#ifdef WLAN_API_NL80211 + err = nl80211_tcmd_tx(&tcmd_cfg, buf, len); + if (err) + goto err_out; +#endif + if (resp) +#ifdef WLAN_API_NL80211 + err = nl80211_tcmd_rx(&tcmd_cfg); +#endif + + return err; +err_out: + A_DBG("tcmd_tx failed: %s\n", strerror(-err)); + return err; +} + +static void tcmd_expire(union sigval sig) +{ + /* tcmd expired, do something */ + A_DBG("timer expired %d\n",sig.sival_int); + tcmd_cfg.timeout = true; +} + +#ifdef CONFIG_AR6002_REV6 +int tcmd_tx_init(char *iface, void (*rx_cb)(void *buf, int len)) +{ + int err; + + strlcpy(tcmd_cfg.iface, iface, sizeof(tcmd_cfg.iface)); + tcmd_cfg.rx_cb = rx_cb; + + tcmd_cfg.sev.sigev_notify = SIGEV_THREAD; + tcmd_cfg.sev.sigev_notify_function = tcmd_expire; + timer_create(CLOCK_REALTIME, &tcmd_cfg.sev, &tcmd_cfg.timer); + +#ifdef WLAN_API_NL80211 + err = nl80211_init(&tcmd_cfg); + if (err) { + A_DBG("couldn't init nl80211!: %s\n", strerror(-err)); + return err; + } +#endif + + return 0; +} + +#else +/* get driver ep from tcmd ep */ +static int tcmd_set_ep(uint32_t *driv_ep, enum tcmd_ep ep) +{ +#ifdef WLAN_API_NL80211 + return nl80211_set_ep(driv_ep, ep); +#endif +} + +void tcmd_response_cb(void *buf, int len) +{ + tcmd_cfg.timeout = true; + tcmd_reset_timer(&tcmd_cfg); + tcmd_cfg.docommand_rx_cb(buf, len); +} + +int tcmd_init(char *iface, void (*rx_cb)(void *buf, int len), ...) +{ + int err; + enum tcmd_ep ep; + va_list ap; + va_start(ap, rx_cb); + ep = va_arg(ap, enum tcmd_ep); + va_end(ap); + + strlcpy(tcmd_cfg.iface, iface, sizeof(tcmd_cfg.iface)); + tcmd_cfg.docommand_rx_cb = rx_cb; + tcmd_cfg.rx_cb = tcmd_response_cb; + err = tcmd_set_ep(&tcmd_cfg.ep, ep); + if (err) + return err; + + tcmd_cfg.sev.sigev_notify = SIGEV_THREAD; + tcmd_cfg.sev.sigev_notify_function = tcmd_expire; + timer_create(CLOCK_REALTIME, &tcmd_cfg.sev, &tcmd_cfg.timer); + +#ifdef WLAN_API_NL80211 + err = nl80211_init(&tcmd_cfg); + if (err) { + A_DBG("couldn't init nl80211!: %s\n", strerror(-err)); + return err; + } +#endif + + return 0; +} +int tcmd_tx_start( void ) +{ + return nl80211_tcmd_start(&tcmd_cfg); +} + +int tcmd_tx_stop( void ) +{ + return nl80211_tcmd_stop(&tcmd_cfg); +} +int tcmd_tx_init(char *iface, void (*rx_cb)(void *buf, int len)) +{ + return tcmd_init(iface, rx_cb, TCMD_EP_TCMD); +} +#endif diff --git a/feeds/wifi-ax/libtcmd/src/libtcmd.h b/feeds/wifi-ax/libtcmd/src/libtcmd.h new file mode 100755 index 000000000..c5e4dd8a9 --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/libtcmd.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2011-2012, 2020 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + * 2011-2012 Qualcomm Atheros Inc. All Rights Reserved. + * Qualcomm Atheros Proprietary and Confidential. + */ + +#ifndef _LIBTCMD_H_ +#define _LIBTCMD_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef CONFIG_AR6002_REV6 +#include +#endif + +#define A_ERR(ret, args...) { \ + printf(args); \ + exit(ret); \ + } +#define A_DBG printf + +#ifdef WIN_AP_HOST +/* In 6GHz the channel list is larger, + * it can potentially take 60s or more so + * increasing timeout. + */ +#define TCMD_TIMEOUT 70 /* s */ +#else +#define TCMD_TIMEOUT 16 /* s */ +#endif + +#define UNUSED(x) (void)(x) + +#ifndef CONFIG_AR6002_REV6 +enum tcmd_ep { + TCMD_EP_TCMD, + TCMD_EP_WMI, +}; +#endif + +struct tcmd_cfg { + char iface[100]; + void (*rx_cb)(void *buf, int len); + void (*docommand_rx_cb)(void *buf, int len); +#ifndef CONFIG_AR6002_REV6 + uint32_t ep; +#endif +#ifdef WLAN_API_NL80211 +/* XXX: eventually default to libnl-2.0 API */ +#ifdef LIBNL_2 +#define nl_handle nl_sock +#endif + struct nl_handle *nl_handle; + int nl_id; +#endif + struct sigevent sev; + timer_t timer; + bool timeout; +} tcmd_cfg; + +/* WLAN API */ +#ifdef WLAN_API_NL80211 +#include "nl80211_drv.h" +#endif + +/* send tcmd in buffer buf of length len. resp == true if a response by the FW + * is required. Returns: 0 on success, -ETIMEOUT on timeout + */ +int tcmd_tx(void *buf, int len, bool resp); + +/* Initialize tcmd transport layer on given iface. Call given rx_cb on tcmd + * response */ +int tcmd_tx_init(char *iface, void (*rx_cb)(void *buf, int len)); +#ifndef CONFIG_AR6002_REV6 +/* same as above, but takes optional testmode endpoint (e.g. WMI vs. TCMD) */ +int tcmd_init(char *iface, void (*rx_cb)(void *buf, int len), ...); +#endif +int tcmd_tx_start( void ); +int tcmd_tx_stop( void ); +#endif /* _LIBTCMD_H_ */ diff --git a/feeds/wifi-ax/libtcmd/src/nl80211.c b/feeds/wifi-ax/libtcmd/src/nl80211.c new file mode 100755 index 000000000..39834923e --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/nl80211.c @@ -0,0 +1,563 @@ +/* + * Copyright (c) 2011-2012, 2016-2018, 2021 Qualcomm Technologies Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + * 2011-2012, 2016 Qualcomm Atheros Inc. + * All rights reserved. + * + * $ATH_LICENSE_HOSTSDK0_C$ + * + * nl80211 code from iw and hwsim tool by Johannes Berg + * http://git.sipsolutions.net/?p=iw.git;a=summary + * http://git.sipsolutions.net/?p=hwsim.git;a=summary + */ + +#include "libtcmd.h" +#include "os.h" +#ifdef WIN_AP_HOST +#include +#include +#include +#include +#endif + +int cb_ret; + +#ifdef LIBNL_2 +static inline struct nl_sock *nl_handle_alloc(void) +{ + return nl_socket_alloc(); +} + +static inline void nl_handle_destroy(struct nl_handle *h) +{ + nl_socket_free(h); +} + +#define nl_disable_sequence_check nl_socket_disable_seq_check +#endif + +/* copied from ath6kl */ +enum ar6k_testmode_attr { + __AR6K_TM_ATTR_INVALID = 0, + AR6K_TM_ATTR_CMD = 1, + AR6K_TM_ATTR_DATA = 2, + AR6K_TM_ATTR_STREAM_ID = 3, + + /* keep last */ + __AR6K_TM_ATTR_AFTER_LAST, + AR6K_TM_ATTR_MAX = __AR6K_TM_ATTR_AFTER_LAST - 1 +}; + +#ifdef WIN_AP_HOST_OPEN +enum ar6k_testmode_cmd { + AR6K_TM_CMD_VERSION = 0, + AR6K_TM_CMD_START = 1, + AR6K_TM_CMD_STOP = 2, + AR6K_TM_CMD_WMI_CMD = 3, + AR6K_TM_CMD_TCMD = 4, +}; +#else +enum ar6k_testmode_cmd { + AR6K_TM_CMD_TCMD = 0, + AR6K_TM_CMD_START = 1, + AR6K_TM_CMD_STOP = 2, +#ifndef CONFIG_AR6002_REV6 + AR6K_TM_CMD_WMI_CMD = 0xF000, +#endif +}; +#endif + +static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, + void *arg) +{ + int *ret = arg; + *ret = err->error; + + UNUSED(nla); + return NL_STOP; +} + +static int finish_handler(struct nl_msg *msg, void *arg) +{ + int *ret = arg; + *ret = 0; + + UNUSED(msg); + return NL_SKIP; +} + +static int ack_handler(struct nl_msg *msg, void *arg) +{ + int *ret = arg; + *ret = 0; + + UNUSED(msg); + return NL_STOP; +} + +#ifdef ANDROID +#ifndef in_addr_t +typedef uint32_t in_addr_t; +#endif +#include "netlink-private/genl.h" +/* android's libnl_2 does not include this, define it here */ +static int android_genl_ctrl_resolve(struct nl_handle *handle, + const char *name) +{ + /* + * Android ICS has very minimal genl_ctrl_resolve() implementation, so + * need to work around that. + */ + struct nl_cache *cache = NULL; + struct genl_family *nl80211 = NULL; + int id = -1; + + if (genl_ctrl_alloc_cache(handle, &cache) < 0) { + A_DBG("nl80211: Failed to allocate generic " + "netlink cache"); + goto fail; + } + + nl80211 = genl_ctrl_search_by_name(cache, name); + if (nl80211 == NULL) + goto fail; + + id = genl_family_get_id(nl80211); + +fail: + if (nl80211) + genl_family_put(nl80211); + if (cache) + nl_cache_free(cache); + + return id; +} +#define genl_ctrl_resolve android_genl_ctrl_resolve + +#define nl_socket_get_cb nl_sk_get_cb +struct nl_cb *nl_socket_get_cb(const struct nl_sock *sk) +{ + return nl_cb_get(sk->s_cb); +} + +#define nl_socket_enable_msg_peek nl_sk_enable_msg_peek +void nl_socket_enable_msg_peek(struct nl_sock *sk) +{ + sk->s_flags |= NL_MSG_PEEK; +} + +#define nl_socket_set_nonblocking nl_sk_set_nb +int nl_socket_set_nonblocking(const struct nl_sock *sk) +{ + fcntl(sk->s_fd, F_SETFL, O_NONBLOCK); + return 0; +} + +static int seq_ok(struct nl_msg *msg, void *arg) +{ + UNUSED(msg); + UNUSED(arg); + + return NL_OK; +} + +#define nl_socket_disable_seq_check disable_seq_check +static inline void disable_seq_check(struct nl_handle *handle) +{ + nl_cb_set(nl_socket_get_cb(handle), NL_CB_SEQ_CHECK, + NL_CB_CUSTOM, seq_ok, NULL); +} +#endif + +struct handler_args { + const char *group; + int id; +}; + +static int family_handler(struct nl_msg *msg, void *arg) +{ + struct handler_args *grp = arg; + struct nlattr *tb[CTRL_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *mcgrp; + int rem_mcgrp; + + nla_parse(tb, CTRL_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (!tb[CTRL_ATTR_MCAST_GROUPS]) + return NL_SKIP; + + nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcgrp) { + struct nlattr *tb_mcgrp[CTRL_ATTR_MCAST_GRP_MAX + 1]; + + nla_parse(tb_mcgrp, CTRL_ATTR_MCAST_GRP_MAX, + nla_data(mcgrp), nla_len(mcgrp), NULL); + + if (!tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME] || + !tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]) + continue; + else + grp->id = nla_get_u32(tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]); + if (strncmp(nla_data(tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME]), + grp->group, + nla_len(tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME]))) + continue; + grp->id = nla_get_u32(tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]); + break; + } + + return NL_SKIP; +} + +int nl_get_multicast_id(struct nl_handle *sock, const char *family, + const char *group) +{ + struct nl_msg *msg; + struct nl_cb *cb; + int ret, ctrlid; + struct handler_args grp = { + .group = group, + .id = -ENOENT, + }; + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + cb = nl_cb_alloc(NL_CB_DEFAULT); + if (!cb) { + ret = -ENOMEM; + goto out_fail_cb; + } + + ctrlid = genl_ctrl_resolve(sock, "nlctrl"); + +#ifdef ANDROID + genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, GENL_ID_CTRL, 0, 0, + CTRL_CMD_GETFAMILY, 1); +#else + genlmsg_put(msg, 0, 0, ctrlid, 0, 0, CTRL_CMD_GETFAMILY, 0); +#endif + + ret = -ENOBUFS; + NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, family); + + ret = nl_send_auto_complete(sock, msg); + if (ret < 0) + goto out; + + ret = 1; + + nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &ret); + nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &ret); + nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &ret); + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, family_handler, &grp); + + while (ret > 0) + nl_recvmsgs(sock, cb); + + if (ret == 0) + ret = grp.id; + nla_put_failure: + out: + nl_cb_put(cb); + out_fail_cb: + nlmsg_free(msg); + return ret; +} + +#ifndef CONFIG_AR6002_REV6 +int nl80211_set_ep(uint32_t *driv_ep, enum tcmd_ep ep) +{ + switch (ep) { + case TCMD_EP_TCMD: + *driv_ep = AR6K_TM_CMD_TCMD; + break; + case TCMD_EP_WMI: + *driv_ep = AR6K_TM_CMD_WMI_CMD; + break; + default: + fprintf(stderr, "nl80211: unknown ep!"); + return -1; + } + return 0; +} +#endif + +/* tcmd rx_cb wrapper to "unpack" the nl80211 msg and call the "real" cb */ +int nl80211_rx_cb(struct nl_msg *msg, void *arg) +{ + struct nlattr *tb[NL80211_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *td[AR6K_TM_ATTR_MAX + 1]; + void *buf; + int len; + + UNUSED(arg); +#ifndef WIN_AP_HOST + A_DBG("nl80211: cb wrapper called\n"); +#endif + nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (!tb[NL80211_ATTR_TESTDATA] || !tb[NL80211_ATTR_WIPHY]) { + printf("no data!\n"); + return NL_SKIP; + } + + nla_parse(td, AR6K_TM_ATTR_MAX, nla_data(tb[NL80211_ATTR_TESTDATA]), + nla_len(tb[NL80211_ATTR_TESTDATA]), NULL); + + if (!td[AR6K_TM_ATTR_DATA]) { +#ifndef WIN_AP_HOST_OPEN + printf("no data in reply\n"); +#endif + return NL_SKIP; + } + + buf = nla_data(td[AR6K_TM_ATTR_DATA]); + len = nla_len(td[AR6K_TM_ATTR_DATA]); +#ifndef WIN_AP_HOST + A_DBG("nl80211: resp received, calling custom cb\n"); +#endif + tcmd_cfg.rx_cb(buf, len); + /* trip waiting thread */ + tcmd_cfg.timeout = true; + + return NL_SKIP; +} + +int nl80211_init(struct tcmd_cfg *cfg) +{ + struct nl_cb *cb; + int err; +#ifdef WIN_AP_HOST_OPEN + int opt; +#endif + + if(cfg->nl_handle) + nl_handle_destroy(cfg->nl_handle); + + cfg->nl_handle = nl_handle_alloc(); + if (!cfg->nl_handle) { + A_DBG("Failed to allocate netlink socket.\n"); + return -ENOMEM; + } + + if (genl_connect(cfg->nl_handle)) { + A_DBG("Failed to connect to generic netlink.\n"); + err = -ENOLINK; + goto out_handle_destroy; + } + + cfg->nl_id = genl_ctrl_resolve(cfg->nl_handle, "nl80211"); + if (cfg->nl_id < 0) { + A_DBG("nl80211 not found.\n"); + err = -ENOENT; + goto out_handle_destroy; + } + + /* replace this with genl_ctrl_resolve_grp() once we move to libnl3 */ + err = nl_get_multicast_id(cfg->nl_handle, "nl80211", "testmode"); + if (err >= 0) { + err = nl_socket_add_membership(cfg->nl_handle, err); + if (err) { + A_DBG("failed to join testmode group!\n"); + goto out_handle_destroy; + } + } else + goto out_handle_destroy; + /* + * Enable peek mode so drivers can send large amounts + * of data in blobs without problems. + */ + nl_socket_enable_msg_peek(cfg->nl_handle); + + /* + * disable sequence checking to handle events. + */ + nl_disable_sequence_check(cfg->nl_handle); + + cb = nl_socket_get_cb(cfg->nl_handle); +#ifdef ANDROID + /* libnl_2 does not provide default handlers */ + nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &cb_ret); + nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &cb_ret); + nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &cb_ret); +#endif + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_rx_cb, NULL); + + /* so we can handle timeouts properly */ + nl_socket_set_nonblocking(cfg->nl_handle); + +#ifdef WIN_AP_HOST_OPEN + /* nobuf errors are useful for identifying lost packets and doing a + * resync. Such handling is not performed by libtcmd since we + * do a synchronous recv after performing a tx. Since + * we are listening in multicast socket and we recv/process the + * data only when do a tx, there are chances we receive overrun + * or ENOBUF errors which affects our data recv and better to + * avoid them + */ + opt = 1; + setsockopt(nl_socket_get_fd(cfg->nl_handle), SOL_NETLINK, + NETLINK_NO_ENOBUFS, &opt, sizeof(opt)); +#endif + + return 0; + + out_handle_destroy: + nl_handle_destroy(cfg->nl_handle); + return err; +} + +int nl80211_tcmd_connect(struct tcmd_cfg *cfg, enum ar6k_testmode_cmd cmd ) +{ + struct nl_msg *msg; + struct nlattr *nest; + int devidx, err = 0; + + /* CHANGE HERE: you may need to allocate larger messages! */ + msg = nlmsg_alloc(); + if (!msg) { + A_DBG("failed to allocate netlink message\n"); + return 2; + } + + genlmsg_put(msg, 0, 0, cfg->nl_id, 0, + 0, NL80211_CMD_TESTMODE, 0); + + devidx = if_nametoindex(cfg->iface); + if (devidx) { + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, devidx); + } else { + A_DBG("Device not found\n"); + err = -ENOENT; + goto out_free_msg; + } + + nest = nla_nest_start(msg, NL80211_ATTR_TESTDATA); + if (!nest) { + A_DBG("failed to nest\n"); + err = -1; + goto out_free_msg; + } + + NLA_PUT_U32(msg, AR6K_TM_ATTR_CMD, cmd); + + nla_nest_end(msg, nest); + +#ifndef WIN_AP_HOST + A_DBG("nl80211: sending message\n"); +#endif + nl_send_auto_complete(cfg->nl_handle, msg); + + out_free_msg: + nlmsg_free(msg); + return err; + + nla_put_failure: + nlmsg_free(msg); + A_DBG("building message failed\n"); + return 2; +} + +int nl80211_tcmd_start(struct tcmd_cfg *cfg) +{ + return nl80211_tcmd_connect(cfg, AR6K_TM_CMD_START); +} + +int nl80211_tcmd_stop(struct tcmd_cfg *cfg) +{ + return nl80211_tcmd_connect(cfg,AR6K_TM_CMD_STOP); +} + +int nl80211_tcmd_tx(struct tcmd_cfg *cfg, void *buf, int len) +{ + struct nl_msg *msg; + struct nlattr *nest; + int devidx, err = 0; + + /* CHANGE HERE: you may need to allocate larger messages! */ + msg = nlmsg_alloc(); + if (!msg) { + A_DBG("failed to allocate netlink message\n"); + return 2; + } + + genlmsg_put(msg, 0, 0, cfg->nl_id, 0, + 0, NL80211_CMD_TESTMODE, 0); + + devidx = if_nametoindex(cfg->iface); + if (devidx) { + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, devidx); + } else { + A_DBG("Device not found\n"); + err = -ENOENT; + goto out_free_msg; + } + + nest = nla_nest_start(msg, NL80211_ATTR_TESTDATA); + if (!nest) { + A_DBG("failed to nest\n"); + err = -1; + goto out_free_msg; + } + +#ifdef CONFIG_AR6002_REV6 + NLA_PUT_U32(msg, AR6K_TM_ATTR_CMD, AR6K_TM_CMD_TCMD); +#else + NLA_PUT_U32(msg, AR6K_TM_ATTR_CMD, cfg->ep); +#endif + NLA_PUT(msg, AR6K_TM_ATTR_DATA, len, buf); + + nla_nest_end(msg, nest); + +#ifndef WIN_AP_HOST + A_DBG("nl80211: sending message\n"); +#endif + nl_send_auto_complete(cfg->nl_handle, msg); + + out_free_msg: + nlmsg_free(msg); + return err; + + nla_put_failure: + nlmsg_free(msg); + A_DBG("building message failed\n"); + return 2; +} + +int nl80211_tcmd_rx(struct tcmd_cfg *cfg) +{ + struct nl_cb *cb; + int err = 0; + + cb = nl_socket_get_cb(cfg->nl_handle); + if (!cb) { + fprintf(stderr, "failed to allocate netlink callbacks\n"); + err = 2; + goto out; + } + + err = tcmd_set_timer(cfg); + if (err) + goto out; + +#ifndef WIN_AP_HOST + A_DBG("nl80211: waiting for response\n"); +#endif + while (!cfg->timeout) + nl_recvmsgs(cfg->nl_handle, cb); + + if (!cfg->timeout) + return tcmd_reset_timer(cfg); + else + return 0; + +out: + return err; +} diff --git a/feeds/wifi-ax/libtcmd/src/nl80211_drv.h b/feeds/wifi-ax/libtcmd/src/nl80211_drv.h new file mode 100755 index 000000000..3c34f90a8 --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/nl80211_drv.h @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2011-2012 Qualcomm Atheros Inc. All Rights Reserved. +* Qualcomm Atheros Proprietary and Confidential. +*/ + +#ifndef _NL80211_DRV_H_ +#define _NL80211_DRV_H_ + +#include + +#if !defined(WIN_AP_HOST) && !defined(MDM) +#ifndef sockaddr_storage +#define sockaddr_storage __kernel_sockaddr_storage +#endif +#endif + +#include +#include +#include +#include +#include +#include +#include +#include "libtcmd.h" + +int nl80211_init(struct tcmd_cfg *cfg); +int nl80211_tcmd_tx(struct tcmd_cfg *cfg, void *buf, int len); +int nl80211_tcmd_rx(struct tcmd_cfg *cfg); +int nl80211_tcmd_start(struct tcmd_cfg *cfg); +int nl80211_tcmd_stop(struct tcmd_cfg *cfg); +#ifndef CONFIG_AR6002_REV6 +int nl80211_set_ep(uint32_t *driv_ep, enum tcmd_ep ep); +#endif +#endif /* _NL80211_DRV_H_ */ diff --git a/feeds/wifi-ax/libtcmd/src/os.c b/feeds/wifi-ax/libtcmd/src/os.c new file mode 100755 index 000000000..2d46f4b7b --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/os.c @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2011-2012, 2018 Qualcomm Technologies, Inc. +* All Rights Reserved. +* Confidential and Proprietary - Qualcomm Technologies, Inc. +* +* 2011-2012 Qualcomm Atheros Inc. All Rights Reserved. +* Qualcomm Atheros Proprietary and Confidential. +*/ + +#include +#include "libtcmd.h" +#include "os.h" + +#ifdef WIN_AP_HOST +#include +#endif + +int tcmd_set_timer(struct tcmd_cfg *cfg) +{ + struct itimerspec exp_time; + int err; + +#ifndef WIN_AP_HOST + A_DBG("setting timer\n"); +#endif + + bzero(&exp_time, sizeof(exp_time)); + exp_time.it_value.tv_sec = TCMD_TIMEOUT; + err = timer_settime(cfg->timer, 0, &exp_time, NULL); + cfg->timeout = false; + if (err < 0) + return -errno; + return 0; +} + +int tcmd_reset_timer(struct tcmd_cfg *cfg) +{ + struct itimerspec curr_time; + int err; + + err = timer_gettime(cfg->timer, &curr_time); + if (err < 0) + return -errno; + + if (!curr_time.it_value.tv_sec && !curr_time.it_value.tv_nsec) + return -ETIMEDOUT; + +#ifndef WIN_AP_HOST + A_DBG("resetting timer\n"); +#endif + + bzero(&curr_time, sizeof(curr_time)); + err = timer_settime(cfg->timer, 0, &curr_time, NULL); + if (err < 0) + return -errno; + return 0; +} diff --git a/feeds/wifi-ax/libtcmd/src/os.h b/feeds/wifi-ax/libtcmd/src/os.h new file mode 100755 index 000000000..41257a57e --- /dev/null +++ b/feeds/wifi-ax/libtcmd/src/os.h @@ -0,0 +1,10 @@ +/* +* Copyright (c) 2011-2012 Qualcomm Atheros Inc. All Rights Reserved. +* Qualcomm Atheros Proprietary and Confidential. +*/ + +/* private, os-specific things go here */ +int tcmd_set_timer(struct tcmd_cfg *cfg); +/* reset timer and return 0 if still running, return -ETIMEDOUT if the tcmd + * timer timed out */ +int tcmd_reset_timer(struct tcmd_cfg *cfg); diff --git a/feeds/wifi-ax/qca-diag/Makefile b/feeds/wifi-ax/qca-diag/Makefile new file mode 100755 index 000000000..7cc9cb1e4 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/Makefile @@ -0,0 +1,76 @@ + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=qca-diag +#PKG_SOURCE_PROTO:=git +#PKG_BRANCH:=master +PKG_RELEASE:=1 + +PKG_VERSION:=11.5 +#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +#PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +#PKG_SOURCE_VERSION:=$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk + +define Package/qca-diag + SECTION:=QCA + CATEGORY:=QCA + TITLE:=QCA Linux diag software + DEPENDS:=@TARGET_ipq50xx||TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64||TARGET_ipq807x||TARGET_ipq60xx||TARGET_ipq95xx +libpthread +endef + +define Package/qca-diag/Description + This package contains a Linux qca diag application such as on device logging + and socket logging for QCA chipset. + This package enables diag messages to log over sockets and also expose + interface for other modules to route the diag message to kernel diag + stack. +endef + + +QCASSDK_CONFIG_OPTS+= TOOL_PATH=$(TOOLCHAIN_DIR)/bin/ \ + SYS_PATH=$(LINUX_DIR) \ + TOOLPREFIX=$(TARGET_CROSS) \ + KVER=$(LINUX_VERSION) \ + ARCH=$(LINUX_KARCH) + + +define Build/InstallDev + $(INSTALL_DIR) $(STAGING_DIR)/usr/include/qca-diag $(STAGING_DIR)/usr/lib/ + $(CP) $(PKG_BUILD_DIR)/include/* $(STAGING_DIR)/usr/include/qca-diag/ + $(CP) $(PKG_BUILD_DIR)/lib/libdiag.so $(STAGING_DIR)/usr/lib/ +endef + + +define Package/qca-diag/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/diag_socket_app $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/diag_stress_app $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/registerReboot $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/qld_server $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/diag_mdlog $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/libdiag.so $(1)/usr/lib/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/qdss_setup.sh $(1)/usr/bin/ +endef + + +$(eval $(call BuildPackage,qca-diag)) + +define KernelPackage/coresight-stream-sock + TITLE:=Add Coresight network stream module + KCONFIG:=CONFIG_CORESIGHT_STREAM + DEPENDS:=\ + +kmod-udptunnel4 \ + +IPV6:kmod-udptunnel6 + FILES:=$(LINUX_DIR)/drivers/hwtracing/coresight/coresight-stream.ko +endef + +define KernelPackage/coresight-stream-sock/description + Add Coresight network stream module +endef + +$(eval $(call KernelPackage,coresight-stream-sock)) diff --git a/feeds/wifi-ax/qca-diag/src/Android.mk b/feeds/wifi-ax/qca-diag/src/Android.mk new file mode 100755 index 000000000..5053e7d64 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/Android.mk @@ -0,0 +1 @@ +include $(call all-subdir-makefiles) diff --git a/feeds/wifi-ax/qca-diag/src/Makefile b/feeds/wifi-ax/qca-diag/src/Makefile new file mode 100755 index 000000000..85ddbf57d --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/Makefile @@ -0,0 +1,44 @@ +INCLUDE_DIR += include -I src +LIB := -lpthread -shared +LDFLAGS += -Llib/ -ldiag -lpthread -pie +FLAGS = -fPIC -g -DUSE_MUSL +EXTRA_CFLAGS = $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(TARGET_CPPFLAGS) -fstack-protector-all -znow -zrelro -Werror +sample_cliobj := dci_client/diag_dci_sample.c +klogobj := klog/diag_klog.c +mdobj := mdlog/diag_mdlog.c +socketobj := socket_log/diag_socket_log.c +uartobj := uart_log/diag_uart_log.c +testdiag := test/test_diag.c + +libdiag := src/diag_lsm.c src/diag_lsm_dci.c src/ts_linux.c src/diag_lsm_event.c \ + src/diag_lsm_log.c src/diag_lsm_msg.c src/diag_lsm_pkt.c \ + src/diagsvc_malloc.c src/msg_arrays_i.c src/diag_qshrink4_db_parser.c + +all: + $(CC) -o libdiag.so $(libdiag) $(TARGET_LDFLAGS) $(FLAGS) $(EXTRA_CFLAGS) -I $(INCLUDE_DIR) $(LIB) + mkdir -p lib + mv libdiag.so lib/ + + $(CC) -o diag_socket_app $(socketobj) $(LDFLAGS) $(EXTRA_CFLAGS) -fpie -I $(INCLUDE_DIR) + mkdir -p bin + mv diag_socket_app bin/ + + $(CC) -o registerReboot registerReboot.c $(LDFLAGS) $(EXTRA_CFLAGS) -fpie -I $(INCLUDE_DIR) + mkdir -p bin + mv registerReboot bin/ + + $(CC) -o qld_server qld_server.c $(LDFLAGS) $(EXTRA_CFLAGS) -fpie -I $(INCLUDE_DIR) + mkdir -p bin + mv qld_server bin/ + + $(CC) -o diag_stress_app $(testdiag) $(LDFLAGS) $(EXTRA_CFLAGS) -fpie -I $(INCLUDE_DIR) + mv diag_stress_app bin/ + + $(CC) -o diag_mdlog $(mdobj) $(LDFLAGS) $(EXTRA_CFLAGS) -fpie -I $(INCLUDE_DIR) + mkdir -p bin + mv diag_mdlog bin/ + +clean: + rm -rf lib/ + rm -rf bin/ + rm -rf *.o diff --git a/feeds/wifi-ax/qca-diag/src/Makefile.am b/feeds/wifi-ax/qca-diag/src/Makefile.am new file mode 100755 index 000000000..2e507a05d --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/Makefile.am @@ -0,0 +1,11 @@ +# Makefile.am - Automake script for diag +# +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = src test klog mdlog PktRspTest uart_log dci_sample callback_sample socket_log +dist_doc_DATA = +docdir = doc + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = diag.pc +EXTRA_DIST = $(pkgconfig_DATA) diff --git a/feeds/wifi-ax/qca-diag/src/PktRspTest/Android.mk b/feeds/wifi-ax/qca-diag/src/PktRspTest/Android.mk new file mode 100755 index 000000000..51f64bcd7 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/PktRspTest/Android.mk @@ -0,0 +1,28 @@ +################################################################################ +# @file pkgs/diag/Android.mk +# @brief Makefile for building the string library on Android. +################################################################################ + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +libdiag_includes:= \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../src \ + +LOCAL_C_INCLUDES:= $(libdiag_includes) +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc + +LOCAL_SRC_FILES:= \ + PktRspTest.c \ + +commonSharedLibraries :=libdiag \ + +LOCAL_MODULE:= PktRspTest +LOCAL_MODULE_TAGS := optional debug +LOCAL_SHARED_LIBRARIES := $(commonSharedLibraries) + +LOCAL_MODULE_OWNER := qcom +include $(BUILD_EXECUTABLE) + diff --git a/feeds/wifi-ax/qca-diag/src/PktRspTest/Makefile.am b/feeds/wifi-ax/qca-diag/src/PktRspTest/Makefile.am new file mode 100755 index 000000000..2f2146460 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/PktRspTest/Makefile.am @@ -0,0 +1,23 @@ + +AM_CFLAGS = -Wall \ + -Wundef \ + -Wstrict-prototypes \ + -Wno-trigraphs \ + -Werror + +AM_CPPFLAGS = -D__packed__= \ + -DIMAGE_APPS_PROC \ + -DFEATURE_Q_SINGLE_LINK \ + -DFEATURE_Q_NO_SELF_QPTR \ + -DFEATURE_LINUX \ + -DFEATURE_NATIVELINUX \ + -DFEATURE_DSM_DUP_ITEMS \ + -DFEATURE_LE_DIAG \ + -I../src \ + -I../include + +bin_PROGRAMS = PktRspTest + +PktRspTest_SOURCES = PktRspTest.c +PktRspTest_LDFLAGS = -lpthread +PktRspTest_LDADD = ../src/libdiag.la diff --git a/feeds/wifi-ax/qca-diag/src/PktRspTest/PktRspTest.c b/feeds/wifi-ax/qca-diag/src/PktRspTest/PktRspTest.c new file mode 100755 index 000000000..e6607ae4c --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/PktRspTest/PktRspTest.c @@ -0,0 +1,214 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Sample Packet Response Test Application on Diag Interface + +GENERAL DESCRIPTION + Contains main implementation of PktRsp Test app. on Apps processor using + Diagnostic Services. + +EXTERNALIZED FUNCTIONS + None + +INITIALIZATION AND SEQUENCING REQUIREMENTS + +Copyright (c) 2007-2011, 2016 Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +3/11/2009 Shalabh Jain and Hiren Bhinde Created +4/2/2009 Shalabh Jain and Yash Kharia Adding ftmTest app to the mainline +===========================================================================*/ + +#include "msg.h" +#include "diag_lsm.h" +#include "stdio.h" +#include "diagpkt.h" +#include "string.h" +#include + +/* Subsystem command codes for the test app */ +#define DIAG_TEST_APP_MT_NO_SUBSYS 143 +#define DIAG_SUBSYS_TEST_CLIENT_MT 11 +#define DIAG_TEST_APP_F_75 0x0000 +#define DIAG_TEST_APP_F_75_test 0x0003 + +/*===========================================================================*/ +/* Local Function declarations */ +/*===========================================================================*/ + +void *dummy_func_no_subsys(void *req_pkt, + uint16 pkt_len); + +void *dummy_func_75(void *req_pkt, + uint16 pkt_len); + +void sample_parse_request(void *req_pkt, uint16 pkt_len, void *rsp); + +/*===========================================================================*/ +/* User tables for this client(ftmtest app) */ +/*===========================================================================*/ +static const diagpkt_user_table_entry_type test_tbl_1[] = +{ /* subsys cmd low, subsys cmd code high, call back function */ + {DIAG_TEST_APP_MT_NO_SUBSYS, DIAG_TEST_APP_MT_NO_SUBSYS, + dummy_func_no_subsys}, +}; + +static const diagpkt_user_table_entry_type test_tbl_2[] = +{ /* susbsys_cmd_code lo = 0 , susbsys_cmd_code hi = 0, call back function */ + {DIAG_TEST_APP_F_75, DIAG_TEST_APP_F_75, dummy_func_75}, + /* susbsys_cmd_code lo = 3 , susbsys_cmd_code hi = 3, call back function */ + {DIAG_TEST_APP_F_75_test, DIAG_TEST_APP_F_75_test, dummy_func_75}, +}; + +/*===========================================================================*/ +/* Main Function. This initializes Diag_LSM, calls the tested APIs and exits. */ +/*===========================================================================*/ +int main(void) +{ + boolean bInit_Success = FALSE; + + printf("\n\t\t====================="); + printf("\n\t\tStarting FTM Test App"); + printf("\n\t\t====================="); +#ifdef DIAG_DEBUG + printf("\n Calling LSM init \n"); +#endif + /* Calling LSM init */ + bInit_Success = Diag_LSM_Init(NULL); + + if (!bInit_Success) { + printf("FTM Test App: Diag_LSM_Init() failed."); + return -1; + } + +#ifdef DIAG_DEBUG + printf("FTM Test App: Diag_LSM_Init succeeded. \n"); +#endif + /* Registering diag packet with no subsystem id. + * This is so that an empty request to the app. gets a response back + * and we can ensure that the diag is working as well as the app. is + * responding subsys id = 255, table = test_tb1_1 .... + * To execute on QXDM :: "send_data 143 0 0 0 0 0" + */ + DIAGPKT_DISPATCH_TABLE_REGISTER(DIAGPKT_NO_SUBSYS_ID, test_tbl_1); + + /* Registering diag packet with no subsystem id. This is so + * that an empty request to the app. gets a response back + * and we can ensure that the diag is working as well as the app. is + * responding subsys id = 11, table = test_tbl_2, + * To execute on QXDM :: "send_data 75 11 0 0 0 0 0 0" + OR + * To execute on QXDM :: "send_data 75 11 3 0 0 0 0 0" + */ + DIAGPKT_DISPATCH_TABLE_REGISTER(DIAG_SUBSYS_TEST_CLIENT_MT, + test_tbl_2); + + /* Adding Sleep of 5 sec so that mask is updated */ + sleep(5); + do { + MSG_1(MSG_SSID_DIAG, MSG_LVL_HIGH, + "Hello world from FTM Test App.%d", 270938); + sleep(1); + } while (1); + + /* Now find the DeInit function and call it. + * Clean up before exiting + */ + Diag_LSM_DeInit(); + + return 0; +} + + +/*===========================================================================*/ +/* dummy registered functions */ +/*===========================================================================*/ + +void *dummy_func_no_subsys(void *req_pkt, uint16 pkt_len) +{ + void *rsp = NULL; +#ifdef DIAG_DEBUG + printf("\n ##### FTM Test App: : Inside dummy_func_no_subsys #####\n"); +#endif + /* Allocate the same length as the request. */ + rsp = diagpkt_alloc(DIAG_TEST_APP_MT_NO_SUBSYS, pkt_len); + + if (rsp != NULL) { + memcpy((void *) rsp, (void *) req_pkt, pkt_len); +#ifdef DIAG_DEBUG + printf("FTM Test APP: diagpkt_alloc succeeded"); +#endif + } else { + printf("FTM Test APP: diagpkt_subsys_alloc failed"); + } + + return rsp; +} + + +void *dummy_func_75(void *req_pkt, uint16 pkt_len) +{ + void *rsp = NULL; +#ifdef DIAG_DEBUG + printf("\n FTM Test App: Inside dummy_func_75 \n"); +#endif + /* Allocate the same length as the request. */ + rsp = diagpkt_subsys_alloc(DIAG_TEST_APP_MT_NO_SUBSYS, + DIAG_TEST_APP_F_75, 20); +/* The request sent in from QXDM is parsed here. The response to each kind of +request can be customized. To demonstrate this, we look for codes 1, 2, 3, 4 in +the request (in the same order). For example, send_data 75 11 3 0 1 2 3 4 0 0 0. +Here a specific response string will be sent back. Any other request is simply +echoed back.This is demonstrated in sample_parse_request function +*/ + if (rsp != NULL) { + sample_parse_request(req_pkt, pkt_len, rsp); +#ifdef DIAG_DEBUG + printf("FTM Test App: diagpkt_subsys_alloc succeeded \n"); +#endif + } else + printf("FTM Test APP: diagpkt_subsys_alloc failed"); + + + return rsp; +} + +/*===========================================================================*/ +/* dummy parse request function*/ +/*===========================================================================*/ + +void sample_parse_request(void *req_pkt, uint16 pkt_len, void *rsp) +{ + unsigned char *temp = (unsigned char *)req_pkt + 4; + int code1, code2, code3, code4; + char *rsp_string = "FTM response"; + + code1 = (int)(*(char *)temp); + temp++; + code2 = (int)(*(char *)temp); + temp++; + code3 = (int)(*(char *)temp); + temp++; + code4 = (int)(*(char *)temp); + + if (code1 == 1 && code2 == 2 && code3 == 3 && code4 == 4) { + memcpy((void *) rsp, (void *) req_pkt, 4); + memcpy((void *) ((unsigned char *)rsp+4), (void *) rsp_string, + strlen(rsp_string)); + } else + memcpy((void *) (rsp), (void *) req_pkt, pkt_len); + +} diff --git a/feeds/wifi-ax/qca-diag/src/autogen.sh b/feeds/wifi-ax/qca-diag/src/autogen.sh new file mode 100755 index 000000000..de72aa199 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/autogen.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# autogen.sh -- Autotools bootstrapping + +libtoolize --copy --force +aclocal &&\ +autoheader &&\ +autoconf &&\ +automake --add-missing --copy + diff --git a/feeds/wifi-ax/qca-diag/src/callback_sample/Android.mk b/feeds/wifi-ax/qca-diag/src/callback_sample/Android.mk new file mode 100755 index 000000000..966ec9c7a --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/callback_sample/Android.mk @@ -0,0 +1,29 @@ +################################################################################ +# @file pkgs/stringl/Android.mk +# @brief Makefile for building the string library on Android. +################################################################################ + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +libdiag_includes:= \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../src + +LOCAL_C_INCLUDES := $(libdiag_includes) +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc + +LOCAL_SRC_FILES:= \ + diag_callback_sample.c + +commonSharedLibraries :=libdiag + +LOCAL_MODULE := diag_callback_sample +LOCAL_MODULE_TAGS := optional +LOCAL_SHARED_LIBRARIES := $(commonSharedLibraries) +LOCAL_SHARED_LIBRARIES += liblog + +LOCAL_MODULE_OWNER := qcom +include $(BUILD_EXECUTABLE) + diff --git a/feeds/wifi-ax/qca-diag/src/callback_sample/Makefile.am b/feeds/wifi-ax/qca-diag/src/callback_sample/Makefile.am new file mode 100755 index 000000000..55ab7442e --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/callback_sample/Makefile.am @@ -0,0 +1,27 @@ + +AM_CFLAGS = -Wall \ + -Wundef \ + -Wstrict-prototypes \ + -Wno-trigraphs + +AM_CPPFLAGS = -D__packed__= \ + -DIMAGE_APPS_PROC \ + -DFEATURE_Q_SINGLE_LINK \ + -DFEATURE_Q_NO_SELF_QPTR \ + -DFEATURE_LINUX \ + -DFEATURE_NATIVELINUX \ + -DFEATURE_DSM_DUP_ITEMS \ + -DFEATURE_LE_DIAG \ + -I../src \ + -I../include + +bin_PROGRAMS = diag_callback_sample + +diag_callback_sample_SOURCES = diag_callback_sample.c +diag_callback_sample_LDADD = ../src/libdiag.la +if USE_GLIB +diag_callback_sample_CFLAGS = -DUSE_GLIB @GLIB_CFLAGS@ +diag_callback_sample_LDFLAGS = -lpthread @GLIB_LIBS@ +else +diag_callback_sample_LDFLAGS = -lpthread -lcutils +endif diff --git a/feeds/wifi-ax/qca-diag/src/callback_sample/diag_callback_sample.c b/feeds/wifi-ax/qca-diag/src/callback_sample/diag_callback_sample.c new file mode 100755 index 000000000..e9b8ce028 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/callback_sample/diag_callback_sample.c @@ -0,0 +1,184 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Sample Application for Diag Callback Interface + +GENERAL DESCRIPTION + Contains sample implementation of Diagnostic Callback APIs. + +EXTERNALIZED FUNCTIONS + None + +INITIALIZATION AND SEQUENCING REQUIREMENTS + +Copyright (c) 2012-2014 Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +#include +#include +#include "string.h" +#include "malloc.h" +#include +#include +#include +#include +#include "errno.h" +#include "msg.h" +#include "diag_lsm.h" +#include "stdio.h" +#include "diagpkt.h" +#include "diag_lsmi.h" +#include "diag_shared_i.h" + +#define REQ_LOOPBACK_LEN 7 +#define REQ_STRESSTEST_LEN 24 + +/* Callback for the receiving Diag data */ +int process_diag_data(unsigned char *ptr, int len, void *context_data) +{ + int i; + if (!ptr) { + return 0; + } + + if (context_data) { + if (*(int *)context_data == MSM) { + DIAG_LOGE("diag_callback_sample: Received data of len %d from MSM", len); + } else if (*(int *)context_data == MDM) { + DIAG_LOGE("diag_callback_sample: Received data of len %d from MDM", len); + } else { + DIAG_LOGE("diag_callback_sample: Received data of len %d from unknown proc %d", len, *(int *)context_data); + } + } + + for (i = 0; i < len; i++) { + if (i % 8 == 0) { + DIAG_LOGE("\n "); + } + DIAG_LOGE("%02x ", ptr[i]); + } + DIAG_LOGE("\n"); + + return 0; +} + +/* Helper function to check if MDM is supported */ +static uint8 is_mdm_supported() +{ + uint16 remote_mask = 0; + uint8 err = 0; + err = diag_has_remote_device(&remote_mask); + if (err != 1) { + DIAG_LOGE("diag_callback_sample: Unable to check for MDM support, err: %d\n", errno); + return 0; + } + return (remote_mask & MDM); +} + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + int err = 0; + int data_primary = MSM; + int data_remote = MDM; + uint8 mdm_support = 0; + boolean status = FALSE; + unsigned char req_modem_loopback[REQ_LOOPBACK_LEN] = + { 75, 18, 41, 0, 1, 2, 3 }; + unsigned char req_modem_msg_stress_test[REQ_STRESSTEST_LEN] = + { 75, 18, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + unsigned char req_adsp_log_stress_test[REQ_STRESSTEST_LEN] = + { 75, 18, 7, 0, 1, 0, 0, 0, 16, 1, 1, 0, 0, 1, 0, 0, 5, 0, 0, 0, 10, 0, 0, 0 }; + + status = Diag_LSM_Init(NULL); + if (!status) { + DIAG_LOGE("diag_callback_sample: Diag LSM Init failed, exiting... err: %d\n", errno); + exit(0); + } + + /* Register the callback function for receiving data from MSM */ + diag_register_callback(process_diag_data, &data_primary); + + /* Check if MDM is supported, If yes, register for MDM callback too */ + mdm_support = is_mdm_supported(); + if (mdm_support) + diag_register_remote_callback(process_diag_data, MDM, &data_remote); + + /* Switch to Callback mode to receive Diag data in this application */ + diag_switch_logging(CALLBACK_MODE, NULL); + + /* + * You can now send requests to the processors. The response, and any + * log, event or F3s will be sent via the callback function. + */ + DIAG_LOGE("diag_callback_sample: Sending Modem loopback request to MSM\n"); + err = diag_callback_send_data(MSM, req_modem_loopback, REQ_LOOPBACK_LEN); + if (err) { + DIAG_LOGE("diag_callback_sample: Unable to send Modem loopback request to MSM\n"); + } else { + sleep(2); + } + + DIAG_LOGE("diag_callback_sample: Sending Modem Message Stress Test to MSM\n"); + err = diag_callback_send_data(MSM, req_modem_msg_stress_test, REQ_STRESSTEST_LEN); + if (err) { + DIAG_LOGE("diag_callback_sample: Unable to send Modem Message Stress Test to MSM\n"); + } else { + sleep(30); + } + + DIAG_LOGE("diag_callback_sample: Sending ADSP Log Stress Test to MSM\n"); + err = diag_callback_send_data(MSM, req_adsp_log_stress_test, REQ_STRESSTEST_LEN); + if (err) { + DIAG_LOGE("diag_callback_sample: Unable to send ADSP Log Stress Test to MSM\n"); + } else { + sleep(30); + } + + if (!mdm_support) + goto finish; + + DIAG_LOGE("diag_callback_sample: Sending Modem loopback request to MDM\n"); + /* If MDM is supported, send the requests to MDM ASIC as well */ + err = diag_callback_send_data(MDM, req_modem_loopback, REQ_LOOPBACK_LEN); + if (err) { + DIAG_LOGE("diag_callback_sample: Unable to send Modem loopback request to MDM\n"); + } else { + sleep(2); + } + + DIAG_LOGE("diag_callback_sample: Sending Modem Message Stress Test to MDM\n"); + err = diag_callback_send_data(MDM, req_modem_msg_stress_test, REQ_STRESSTEST_LEN); + if (err) { + DIAG_LOGE("diag_callback_sample: Unable to send Modem Message Stress Test to MDM\n"); + } else { + sleep(30); + } + + DIAG_LOGE("diag_callback_sample: Sending ADSP Log Stress Test to MDM\n"); + err = diag_callback_send_data(MDM, req_adsp_log_stress_test, REQ_STRESSTEST_LEN); + if (err) { + DIAG_LOGE("diag_callback_sample: Unable to send ADSP Log Stress Test to MDM\n"); + } else { + sleep(30); + } + +finish: + /* + * When you are done using the Callback Mode, it is highly recommended + * that you switch back to USB Mode. + */ + diag_switch_logging(USB_MODE, NULL); + + /* Release the handle to Diag*/ + status = Diag_LSM_DeInit(); + if (!status) { + DIAG_LOGE("diag_callback_sample: Unable to close handle to diag driver, err: %d\n", errno); + exit(0); + } + + return 0; +} diff --git a/feeds/wifi-ax/qca-diag/src/configure.ac b/feeds/wifi-ax/qca-diag/src/configure.ac new file mode 100755 index 000000000..3953064e6 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/configure.ac @@ -0,0 +1,110 @@ +# -*- Autoconf -*- + +# configure.ac -- Autoconf script for diag +# + +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT([diag], + 1.0.0) +AM_INIT_AUTOMAKE([foreign]) +AM_MAINTAINER_MODE +AC_CONFIG_SRCDIR([src/diag_lsm.c]) +AC_CONFIG_HEADER([config.h]) +AC_CONFIG_MACRO_DIR([m4]) + +DIAG_LIBRARY_NAME=diag + +#release versioning +DIAG_MAJOR_VERSION=1 +DIAG_MINOR_VERSION=0 +DIAG_MICRO_VERSION=0 + +DIAG_LIBRARY_VERSION=1:0:0 +AC_SUBST(DIAG_LIBRARY_VERSION) + +PACKAGE=$DIAG_LIBRARY_NAME +AC_SUBST(DIAG_LIBRARY_NAME) + +DIAG_VERSION=$DIAG_MAJOR_VERSION.$DIAG_MINOR_VERSION.$DIAG_MICRO_VERSION +DIAG_RELEASE=$DIAG_MAJOR_VERSION.$DIAG_MINOR_VERSION +AC_SUBST(DIAG_RELEASE) +AC_SUBST(DIAG_VERSION) + +VERSION=$DIAG_VERSION + +LT_INIT +AM_PROG_LIBTOOL +# Checks for programs. +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_LIBTOOL +AC_PROG_AWK +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET +PKG_PROG_PKG_CONFIG + +AC_ARG_WITH([kernel], + AC_HELP_STRING([--with-kernel=@<:@dir@:>@], + [Specify the location of the Linux kernel headers]), + [kerneldir=$withval], + with_kernel=no) + +if test "x$with_kernel" != "xno"; then + CFLAGS="${CFLAGS} -I${kerneldir}/include -I${kerneldir}/arch/arm/include" +fi + +AC_ARG_WITH([glib], + AC_HELP_STRING([--with-glib], + [enable glib, building HLOS systems which use glib])) + +if (test "x${with_glib}" = "xyes"); then + AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib]) + PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes, + AC_MSG_ERROR(GThread >= 2.16 is required)) + PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes, + AC_MSG_ERROR(GLib >= 2.16 is required)) + GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS" + GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS" + + AC_SUBST(GLIB_CFLAGS) + AC_SUBST(GLIB_LIBS) +fi + +AC_ARG_WITH([common_includes], + AC_HELP_STRING([--with-common-includes=@<:@dir@:>@], + [Specify the location of the common headers]), + [common_incdir=$withval], + with_common_includes=no) + +if test "x$with_common_includes" != "xno"; then + CFLAGS="${CFLAGS} -I${common_incdir}" +fi + +AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") + +# Checks for libraries. +PKG_CHECK_MODULES([TGENOFF], [time-genoff]) +AC_SUBST([TGENOFF_CFLAGS]) +AC_SUBST([TGENOFF_LIBS]) + +AC_SUBST([CFLAGS]) +AC_SUBST([CC]) +AC_CONFIG_FILES([ \ + Makefile \ + src/Makefile \ + test/Makefile \ + klog/Makefile \ + mdlog/Makefile \ + uart_log/Makefile \ + PktRspTest/Makefile \ + dci_sample/Makefile \ + callback_sample/Makefile \ + socket_log/Makefile \ + diag.pc + ]) +AC_OUTPUT + diff --git a/feeds/wifi-ax/qca-diag/src/dci_sample/Android.mk b/feeds/wifi-ax/qca-diag/src/dci_sample/Android.mk new file mode 100755 index 000000000..6f4bdf027 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/dci_sample/Android.mk @@ -0,0 +1,29 @@ +################################################################################ +# @file pkgs/stringl/Android.mk +# @brief Makefile for building the string library on Android. +################################################################################ + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +libdiag_includes:= \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../src + +LOCAL_C_INCLUDES := $(libdiag_includes) +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc + +LOCAL_SRC_FILES:= \ + diag_dci_sample.c + +commonSharedLibraries :=libdiag + +LOCAL_MODULE := diag_dci_sample +LOCAL_MODULE_TAGS := optional +LOCAL_SHARED_LIBRARIES := $(commonSharedLibraries) +LOCAL_SHARED_LIBRARIES += liblog + +LOCAL_MODULE_OWNER := qcom +include $(BUILD_EXECUTABLE) + diff --git a/feeds/wifi-ax/qca-diag/src/dci_sample/Makefile.am b/feeds/wifi-ax/qca-diag/src/dci_sample/Makefile.am new file mode 100755 index 000000000..c437069e8 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/dci_sample/Makefile.am @@ -0,0 +1,28 @@ + +AM_CFLAGS = -Wall \ + -Wundef \ + -Wstrict-prototypes \ + -Wno-trigraphs + +AM_CPPFLAGS = -D__packed__= \ + -DIMAGE_APPS_PROC \ + -DFEATURE_Q_SINGLE_LINK \ + -DFEATURE_Q_NO_SELF_QPTR \ + -DFEATURE_LINUX \ + -DFEATURE_NATIVELINUX \ + -DFEATURE_DSM_DUP_ITEMS \ + -DFEATURE_LE_DIAG \ + -I../src \ + -I../include \ + -I$(WORKSPACE)/common/inc + +bin_PROGRAMS = diag_dci_sample + +diag_dci_sample_SOURCES = diag_dci_sample.c +diag_dci_sample_LDADD = ../src/libdiag.la +if USE_GLIB +diag_dci_sample_CFLAGS = -DUSE_GLIB @GLIB_CFLAGS@ +diag_dci_sample_LDFLAGS = -lpthread @GLIB_LIBS@ +else +diag_dci_sample_LDFLAGS = -lpthread -lcutils +endif diff --git a/feeds/wifi-ax/qca-diag/src/dci_sample/diag_dci_sample.c b/feeds/wifi-ax/qca-diag/src/dci_sample/diag_dci_sample.c new file mode 100755 index 000000000..d59beb001 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/dci_sample/diag_dci_sample.c @@ -0,0 +1,590 @@ + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Sample Application for Diag Consumer Interface + +GENERAL DESCRIPTION +This is a sample application to demonstrate using Diag Consumer Interface APIs. + +EXTERNALIZED FUNCTIONS + None + +INITIALIZATION AND SEQUENCING REQUIREMENTS + + +Copyright (c) 2013-2016 Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential. + +Author: Ravi Aravamudhan +Source: Jamila Murabbi +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*===========================================================================*/ + +#include "event.h" +#include "msg.h" +#include "log.h" +#include "diag_lsm.h" +#include "diag_lsmi.h" +#include "diag_lsm_dci.h" +#include "diag_shared_i.h" +#include "stdio.h" +#include "string.h" +#include "malloc.h" +#include "diagpkt.h" +#include "../src/diagdiag.h" /* For macros used in this sample. */ +#include +#include +#include +#include +#include +#include +#include +#include + +#define TOTAL_LOG_CODES 1 +#define TOTAL_LOG_CODES_APPS 3 +#define TOTAL_EVENT_CODES 4 +#define DIAG_SAMPLE_SIGNAL SIGRTMIN + 15 + +#define DIAG_CMD_CODE_IDX 0 +#define DIAG_SUBSYS_ID_IDX 1 +#define DIAG_STRESS_TEST_OP_IDX 8 + +/* Structure for Log packet parsing*/ +struct log_code_name_type { + int log_code; + char *name; +}; + +struct event_code_name_type { + event_id_enum_type event_code; + char *name; +}; + +/* Channel proc set to MSM by default */ +static int channel = MSM; + +/* Set a sample log codes */ +struct log_code_name_type log_codes[TOTAL_LOG_CODES] = { + { LOG_DIAG_STRESS_TEST_C, "Diag Log Stress Test" } +}; + +struct log_code_name_type log_codes_apps[TOTAL_LOG_CODES_APPS] = { + { LOG_WMS_SET_ROUTES_C, "WMS Set Routes" }, + { LOG_DATA_PROTOCOL_LOGGING_C, "DPL Log Messages" }, + { LOG_WMS_READ_C, "WMS Read" } +}; + +struct event_code_name_type event_codes[TOTAL_EVENT_CODES] = { + { EVENT_DIAG_STRESS_TEST_NO_PAYLOAD, "Diag Event Stress Test" }, + { EVENT_DIAG_STRESS_TEST_WITH_PAYLOAD, "Diag Event w/ Payload Stress Test"}, + { EVENT_DIAG_STRESS_TEST_COMPLETED, "Diag Event Stress Test Complete"}, + { EVENT_DIAG_DROP_DEBUG, "Diag Event Drop Debug"} +}; + +/* Set flag to print the bytes */ +static inline void print_bytes(unsigned char *buf, int len, int flag) +{ + int i = 0; + if (!flag) + return; + if (!buf || len <= 0) + return; + for (i = 0; i < len; i++) { + if(i % 8 == 0) + printf("\n"); + printf(" %02x ", buf[i]); + } + printf("\n"); +} + +static void usage(char *progname) +{ + printf("\n Usage for %s:\n", progname); + printf("\n-c --channel name:\t Designate the channel name for all operations 0 - MSM and 1 - MDM\n"); + exit(0); +} + +static void parse_args(int argc, char **argv) +{ + int command, proc_id; + int file_num = 0; + struct option longopts[] = + { + { "channelname", 1, NULL, 'c'}, + { "help", 0, NULL, 'h'}, + }; + + while ((command = getopt_long(argc, argv, "c:h", longopts, NULL)) + != -1) { + switch (command) { + case 'c': + proc_id = atol(optarg); + if (proc_id >= MSM && proc_id <= MDM) + channel = proc_id; + break; + case 'h': + default: + usage(argv[0]); + break; + } + } +} + +/* Signal handler that handles the change in DCI channel */ +void notify_handler(int signal, siginfo_t *info, void *unused) +{ + (void)unused; + + if (info) { + int err; + diag_dci_peripherals list = 0; + + DIAG_LOGE("diag: In %s, signal %d received from kernel, data is: %x\n", + __func__, signal, info->si_int); + + if (info->si_int & DIAG_STATUS_OPEN) { + if (info->si_int & DIAG_CON_MPSS) { + DIAG_LOGE("diag: DIAG_STATUS_OPEN on DIAG_CON_MPSS\n"); + } else if (info->si_int & DIAG_CON_LPASS) { + DIAG_LOGE("diag: DIAG_STATUS_OPEN on DIAG_CON_LPASS\n"); + } else { + DIAG_LOGE("diag: DIAG_STATUS_OPEN on unknown peripheral\n"); + } + } else if (info->si_int & DIAG_STATUS_CLOSED) { + if (info->si_int & DIAG_CON_MPSS) { + DIAG_LOGE("diag: DIAG_STATUS_CLOSED on DIAG_CON_MPSS\n"); + } else if (info->si_int & DIAG_CON_LPASS) { + DIAG_LOGE("diag: DIAG_STATUS_CLOSED on DIAG_CON_LPASS\n"); + } else { + DIAG_LOGE("diag: DIAG_STATUS_CLOSED on unknown peripheral\n"); + } + } + err = diag_get_dci_support_list_proc(MSM, &list); + if (err != DIAG_DCI_NO_ERROR) { + DIAG_LOGE("diag: could not get support list, err: %d\n", err); + } + /* This will print out all peripherals supporting DCI */ + if (list & DIAG_CON_MPSS) + DIAG_LOGE("diag: Modem supports DCI\n"); + if (list & DIAG_CON_LPASS) + DIAG_LOGE("diag: LPASS supports DCI\n"); + if (list & DIAG_CON_WCNSS) + DIAG_LOGE("diag: RIVA supports DCI\n"); + if (list & DIAG_CON_APSS) + DIAG_LOGE("diag: APSS supports DCI\n"); + if (!list) + DIAG_LOGE("diag: No current dci support\n"); + } else { + DIAG_LOGE("diag: In %s, signal %d received from kernel, but no info value, info: 0x%p\n", + __func__, signal, info); + } +} + +/* Singal Handler that will be fired when we receive DCI data */ +void dci_data_handler(int signal) +{ + (void)signal; + + /* Do something here when you receive DCI data. */ + + /* This is usually for holding wakelocks when the + clients are running in Diag Non Real Time mode + or when they know the Apps processor is in deep + sleep but they still need to process DCI data. + + Please Note: Wakelocks must be released + after processing the data in the respective + response/log/event handler. Failure to do so + will affect the power consumption of the Apps + processor. */ +} + +void process_dci_log_stream(unsigned char *ptr, int len) +{ + int i, found = 0; + for (i = 0; i < TOTAL_LOG_CODES; i++) { + if (*(uint16 *)(ptr + 2) == log_codes[i].log_code) { + DIAG_LOGE(" Received a Log of type %s, length = %d\n", log_codes[i].name, len); + found = 1; + break; + } + } + for (i = 0; i < TOTAL_LOG_CODES_APPS && !found; i++) { + if (*(uint16 *)(ptr + 2) == log_codes_apps[i].log_code) { + DIAG_LOGE(" Received a Log of type %s, length = %d\n", log_codes_apps[i].name, len); + break; + } + } + if (*(uint8 *)ptr == 0x98) { + DIAG_LOGE(" Received an EXT API LOG PKT %d bytes\n", len); + print_bytes(ptr, len, FALSE); + } + + print_bytes(ptr, len, FALSE); +} + +void process_dci_event_stream(unsigned char *ptr, int len) +{ + if (*(uint8 *)ptr == 0x98) { + DIAG_LOGE(" Received an EXT API EVENT PKT %d bytes\n", len); + print_bytes(ptr, len, FALSE); + return; + } + DIAG_LOGE(" Received an event of size %d bytes\n", len); + print_bytes(ptr, len, FALSE); +} + +void process_response(unsigned char *ptr, int len, void *data_ptr) +{ + int i = 0; + uint8 operation = 0; + (void)data_ptr; + + if (!ptr || len < 0) + return; + + DIAG_LOGE(" Received Response of size %d bytes.\n", len); + print_bytes(ptr, len, TRUE); + + /* Parsing Logic for the response - Based on the request in this sample */ + if (len <= DIAG_STRESS_TEST_OP_IDX) + return; + + operation = ptr[DIAG_STRESS_TEST_OP_IDX]; + if (ptr[DIAG_CMD_CODE_IDX] == DIAG_SUBSYS_CMD_F && + ptr[DIAG_SUBSYS_ID_IDX] == DIAG_SUBSYS_DIAG_SERV) { + DIAG_LOGE(" Command Code: Diag\n"); + DIAG_LOGE(" Subsystem ID: Diag\n"); + if (operation <= DIAGDIAG_STRESS_TEST_ERR_FATAL) { + DIAG_LOGE(" Test for: F3s\n"); + } else if (operation == DIAGDIAG_STRESS_TEST_LOG) { + DIAG_LOGE(" Test for: Logs\n"); + } else if (operation == DIAGDIAG_STRESS_TEST_EVENT_NO_PAYLOAD) { + DIAG_LOGE(" Test for: Events without payload\n"); + } else if (operation == DIAGDIAG_STRESS_TEST_EVENT_WITH_PAYLOAD) { + DIAG_LOGE(" Test for: Events with payload\n"); + } + } + printf("\n"); +} + +/* Main Function. This demonstrates using the DCI APIs defined in diag_lsm_dci.h*/ +int main(int argc, char *argv[]) +{ + int err, client_id; + int signal_type = SIGCONT; + boolean bInit_success = FALSE; + diag_dci_peripherals list = DIAG_CON_MPSS | DIAG_CON_APSS | DIAG_CON_LPASS; + struct diag_dci_health_stats *dci_health_stats; /* To collect DCI Health Statistics */ + unsigned char *dci_rsp_pkt = NULL; + (void)argc; + (void)argv; + + /* Signal handling to handle SSR */ + struct sigaction notify_action; + sigemptyset(¬ify_action.sa_mask); + notify_action.sa_sigaction = notify_handler; + /* Use SA_SIGINFO to denote we are expecting data with the signal */ + notify_action.sa_flags = SA_SIGINFO; + sigaction(signal_type, ¬ify_action, NULL); + + /* Signal handling for DCI Data */ + struct sigaction dci_data_action; + sigemptyset(&dci_data_action.sa_mask); + dci_data_action.sa_handler = dci_data_handler; + dci_data_action.sa_flags = 0; + sigaction(DIAG_SAMPLE_SIGNAL, &dci_data_action, NULL); + + parse_args(argc, argv); + /* Registering with Diag which gives the client a handle to the Diag driver */ + bInit_success = Diag_LSM_Init(NULL); + if (!bInit_success) { + DIAG_LOGE(" Couldn't register with Diag LSM, errno: %d\n", errno); + return -1; + } + + dci_rsp_pkt = (unsigned char *)malloc(DIAG_MAX_RX_PKT_SIZ); + if (!dci_rsp_pkt) { + DIAG_LOGE(" Unable to allocate memory for DCI rsp pkt, errno: %d", errno); + return -1; + } + + /* Registering with DCI - This assigns a client ID */ + /* Channel 0 - MSM, 1 - MDM */ + err = diag_register_dci_client(&client_id, &list, channel, &signal_type); + if (err != DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" Could not register with DCI, err: %d, errno: %d\n", err, errno); + free(dci_rsp_pkt); + return -1; + } else + DIAG_LOGE(" Successfully registered with DCI, client ID = %d\n", client_id); + + err = diag_register_dci_signal_data(client_id, DIAG_SAMPLE_SIGNAL); + if (err != DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" Could not register signal for DCI Data, err: %d, errno: %d\n", err, errno); + free(dci_rsp_pkt); + return -1; + } + + /* Getting supported Peripherals list*/ + DIAG_LOGE(" DCI Status on Processors:\n"); + err = diag_get_dci_support_list_proc(channel, &list); + if (err != DIAG_DCI_NO_ERROR) { + printf(" Could not get support list, err: %d, errno: %d\n", err, errno); + free(dci_rsp_pkt); + return -1; + } + DIAG_LOGE(" MPSS:\t "); + DIAG_LOGE((list & DIAG_CON_MPSS) ? "UP\n" : "DOWN\n"); + DIAG_LOGE(" LPASS:\t "); + DIAG_LOGE((list & DIAG_CON_LPASS) ? "UP\n" : "DOWN\n"); + DIAG_LOGE(" WCNSS:\t "); + DIAG_LOGE((list & DIAG_CON_WCNSS) ? "UP\n" : "DOWN\n"); + DIAG_LOGE(" APSS:\t "); + DIAG_LOGE((list & DIAG_CON_APSS) ? "UP\n" : "DOWN\n"); + + + /* Initializing Log and Event streaming by registering + listeners - This is required to receive Logs and Events */ + DIAG_LOGE(" Opening Data Stream, registering listeners\n"); + err = diag_register_dci_stream_proc(client_id, process_dci_log_stream, process_dci_event_stream); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Unable to register DCI stream, err: %d, errno: %d\n", err, errno); + + printf("\n"); + + DIAG_LOGE(" Sending Asynchronous Command \n"); + /* Diag Log stress test command - one Log packet comes out every second */ + unsigned char buf[24] = {75, 18, 0, 0, 1, 0, 0, 0, 16, 1, 1, 0, 0, 1, 0, 0, 232, 3, 0, 0, 1, 0, 0, 0}; + err = diag_send_dci_async_req(client_id, buf, 24, dci_rsp_pkt, DIAG_MAX_RX_PKT_SIZ, &process_response, NULL); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending SEND_REQUEST_ASYNC to peripheral %d\n", err); + + sleep(1); + printf("\n"); + + /* Setting Log masks ---------------------------- + 0x115F - Diag Stress Test Log + -------------------------------------------*/ + DIAG_LOGE(" Setting Log masks\n"); + DIAG_LOGE(" [0x115F] Diag Stress Test Log\n"); + uint16 log_codes_array[TOTAL_LOG_CODES] = { LOG_DIAG_STRESS_TEST_C }; + err = diag_log_stream_config(client_id, ENABLE, log_codes_array, TOTAL_LOG_CODES); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending SET_LOG_MASK to peripheral, err: %d, errno: %d\n", err, errno); + + /* Putting the thread to sleep for 30 seconds. The client must sleep for the time it + wants to receive logs/events/command responses */ + sleep(30); + printf("\n"); + + /* Display Health Statistics */ + DIAG_LOGE(" Modem Health Statistics on the Apps processor:\n"); + dci_health_stats = malloc(sizeof(struct diag_dci_health_stats)); + if (!dci_health_stats) { + DIAG_LOGE(" Unable to allocate memory for DCI health stats, errno: %d", errno); + free(dci_rsp_pkt); + return -1; + } + + err = diag_get_health_stats_proc(client_id, dci_health_stats, DIAG_MODEM_PROC); + if (err == DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" Log Drop Count for Modem:\t%d\n", dci_health_stats->dropped_logs); + DIAG_LOGE(" Log Total Count for Modem:\t%d\n", dci_health_stats->received_logs); + DIAG_LOGE(" Event Drop Count for Modem:\t%d\n", dci_health_stats->dropped_events); + DIAG_LOGE(" Event Total Count for Modem:\t%d\n", dci_health_stats->received_events); + } else + DIAG_LOGE(" Error in collecting statistics, err: %d, errno: %d\n", err, errno); + + sleep(1); + printf("\n"); + + /* Clearing these log masks ------------------------ + 0x115F - Diag Stress Test Log + ---------------------------------------------------- */ + DIAG_LOGE(" Clearing log masks\n"); + DIAG_LOGE(" [0x115F] Diag Stress Test Log\n"); + err = diag_log_stream_config(client_id, DISABLE, log_codes_array, TOTAL_LOG_CODES); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending CLEAR_LOG_MASK to peripheral, err: %d, errno: %d\n", err, errno); + + sleep(5); + printf("\n"); + + /* Setting Log masks ---------------------------- + 0x117B - WMS Set Routes + 0x11EB - DPL Log Messages + 0x1160 - WMS Read + -------------------------------------------*/ + DIAG_LOGE(" *** To generate the following logs on APSS, please run the test_diag app\n"); + DIAG_LOGE(" Setting Log masks\n"); + DIAG_LOGE(" [0x117B] WMS Set Routes\n"); + DIAG_LOGE(" [0x11EB] DPL Log Messages\n"); + DIAG_LOGE(" [0x1160] WMS Read\n"); + + uint16 log_codes_array_apps[TOTAL_LOG_CODES_APPS] = { LOG_WMS_SET_ROUTES_C, + LOG_DATA_PROTOCOL_LOGGING_C, + LOG_WMS_READ_C }; + err = diag_log_stream_config(client_id, ENABLE, log_codes_array_apps, TOTAL_LOG_CODES_APPS); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending SET_LOG_MASK to peripheral, err: %d, errno: %d\n", err, errno); + + /* Putting the thread to sleep for 30 seconds. The client must sleep for the time it + wants to receive logs/events/command responses */ + sleep(30); + printf("\n"); + + /* Display Health Statistics */ + DIAG_LOGE(" Health statistics for the Application processor Data:\n"); + err = diag_get_health_stats_proc(client_id, dci_health_stats, DIAG_APPS_PROC); + if (err == DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" Log Drop Count for APSS:\t%d\n", dci_health_stats->dropped_logs); + DIAG_LOGE(" Log Total Count for APSS:\t%d\n", dci_health_stats->received_logs); + DIAG_LOGE(" Event Drop Count for APSS:\t%d\n", dci_health_stats->dropped_events); + DIAG_LOGE(" Event Total Count for APSS:\t%d\n", dci_health_stats->received_events); + } else + DIAG_LOGE(" Error in collecting statistics, err: %d, errno: %d\n", err, errno); + + sleep(1); + + printf("\n"); + + /* Clearing these log masks ------------------------ + 0x117B - WMS Set Routes + 0x11EB - DPL Log Messages + 0x1160 - WMS Read + ---------------------------------------------------- */ + DIAG_LOGE(" Clearing log masks\n"); + DIAG_LOGE(" [0x117B] WMS Set Routes\n"); + DIAG_LOGE(" [0x11EB] DPL Log Messages\n"); + DIAG_LOGE(" [0x1160] WMS Read\n"); + err = diag_log_stream_config(client_id, DISABLE, log_codes_array_apps, TOTAL_LOG_CODES_APPS); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending CLEAR_LOG_MASK to peripheral, err: %d, errno: %d\n", err, errno); + + sleep(5); + printf("\n"); + + DIAG_LOGE(" ##### STARTING Ext API Log Packets unit test #####\n"); + DIAG_LOGE(" Registering for Version 1 of DCI (EXT Header Support)"); + err = diag_dci_set_version(client_id, 1); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error registering version to DCI %d\n", err); + + + DIAG_LOGE(" Sending Asynchronous Command for Ext API Log Packets\n"); + /* Diag Log stress test command - one Log packet comes out every second */ + unsigned char log_ext[24] = {75, 18, 0, 0, 1, 0, 0, 0, 57, 1, 1, 0, 0, 1, 0, 0, 232, 3, 0, 0, 1, 0, 0, 0}; + err = diag_send_dci_async_req(client_id, log_ext, 24, dci_rsp_pkt, DIAG_MAX_RX_PKT_SIZ, &process_response, NULL); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending SEND_REQUEST_ASYNC to peripheral %d\n", err); + + /* Diag Events w/ payload test command - one Log packet comes out every second */ + DIAG_LOGE(" Sending Asynchronous Command for Ext API Event Packets\n"); + unsigned char event_ext[24] = {75, 18, 0, 0, 1, 0, 0, 0, 70, 1, 1, 0, 0, 1, 0, 0, 232, 3, 0, 0, 1, 0, 0, 0}; + err = diag_send_dci_async_req(client_id, event_ext, 24, dci_rsp_pkt, DIAG_MAX_RX_PKT_SIZ, &process_response, NULL); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending SEND_REQUEST_ASYNC to peripheral %d\n", err); + + sleep(1); + printf("\n"); + + /* Setting Log masks ---------------------------- + 0x115F - Diag Stress Test Log + -------------------------------------------*/ + DIAG_LOGE(" Setting Log masks\n"); + DIAG_LOGE(" [0x115F] Diag Stress Test Log\n"); + err = diag_log_stream_config(client_id, ENABLE, log_codes_array, TOTAL_LOG_CODES); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending SET_LOG_MASK to peripheral, err: %d, errno: %d\n", err, errno); + + /* Setting Log masks ---------------------------- + 0x115F - Diag Stress Test Event + -------------------------------------------*/ + DIAG_LOGE(" Setting Event masks\n"); + DIAG_LOGE(" EVENT_DIAG_STRESS_TEST_NO_PAYLOAD\n"); + DIAG_LOGE(" EVENT_DIAG_STRESS_TEST_WITH_PAYLOAD\n"); + DIAG_LOGE(" EVENT_DIAG_STRESS_TEST_COMPLETED\n"); + DIAG_LOGE(" EVENT_DIAG_DROP_DEBUG\n"); + + int event_codes_array[TOTAL_EVENT_CODES] = { + EVENT_DIAG_STRESS_TEST_NO_PAYLOAD, + EVENT_DIAG_STRESS_TEST_WITH_PAYLOAD, + EVENT_DIAG_STRESS_TEST_COMPLETED, + EVENT_DIAG_DROP_DEBUG + }; + + err = diag_event_stream_config(client_id, ENABLE, event_codes_array, TOTAL_EVENT_CODES); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending SET_EVENT_MASK to peripheral, err: %d, errno: %d\n", err, errno); + + /* Putting the thread to sleep for 30 seconds. The client must sleep for the time it + wants to receive logs/events/command responses */ + sleep(30); + printf("\n"); + + /* Test Ext Header stripping for dci clients that do not support version 1 of DCI */ + DIAG_LOGE(" Un-Registering for Version 1 of DCI (EXT Header Support)"); + err = diag_dci_set_version(client_id, 0); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error registering version to DCI %d\n", err); + + sleep(30); + printf("\n"); + + /* Display Health Statistics */ + DIAG_LOGE(" Modem Health Statistics on the Apps processor:\n"); + dci_health_stats = malloc(sizeof(struct diag_dci_health_stats)); + if (!dci_health_stats) { + DIAG_LOGE(" Unable to allocate memory for DCI health stats, errno: %d", errno); + free(dci_rsp_pkt); + return -1; + } + + err = diag_get_health_stats_proc(client_id, dci_health_stats, DIAG_MODEM_PROC); + if (err == DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" Log Drop Count for Modem:\t%d\n", dci_health_stats->dropped_logs); + DIAG_LOGE(" Log Total Count for Modem:\t%d\n", dci_health_stats->received_logs); + DIAG_LOGE(" Event Drop Count for Modem:\t%d\n", dci_health_stats->dropped_events); + DIAG_LOGE(" Event Total Count for Modem:\t%d\n", dci_health_stats->received_events); + } else + DIAG_LOGE(" Error in collecting statistics, err: %d, errno: %d\n", err, errno); + + sleep(1); + printf("\n"); + + /* Clearing these log masks ------------------------ + 0x115F - Diag Stress Test Log + ---------------------------------------------------- */ + DIAG_LOGE(" Clearing log masks\n"); + DIAG_LOGE(" [0x115F] Diag Stress Test Log\n"); + err = diag_log_stream_config(client_id, DISABLE, log_codes_array, TOTAL_LOG_CODES); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending CLEAR_LOG_MASK to peripheral, err: %d, errno: %d\n", err, errno); + + /* Clearing Event masks ---------------------------- + 0x115F - Diag Stress Test Event + -------------------------------------------*/ + DIAG_LOGE(" Clearing event masks\n"); + DIAG_LOGE(" EVENT_DIAG_STRESS_TEST_NO_PAYLOAD\n"); + DIAG_LOGE(" EVENT_DIAG_STRESS_TEST_WITH_PAYLOAD\n"); + DIAG_LOGE(" EVENT_DIAG_STRESS_TEST_COMPLETED\n"); + DIAG_LOGE(" EVENT_DIAG_DROP_DEBUG\n"); + err = diag_event_stream_config(client_id, DISABLE, event_codes_array, TOTAL_EVENT_CODES); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error sending CLEAR_EVENT_MASK to peripheral, err: %d, errno: %d\n", err, errno); + + /* Releasing DCI connection */ + DIAG_LOGE(" Releasing DCI connection \n"); + err = diag_release_dci_client(&client_id); + if (err != DIAG_DCI_NO_ERROR) + DIAG_LOGE(" Error releasing DCI connection, err: %d, errno: %d\n", err, errno); + + Diag_LSM_DeInit(); + printf("\n"); + free(dci_health_stats); + free(dci_rsp_pkt); + return 0; +} diff --git a/feeds/wifi-ax/qca-diag/src/diag.pc.in b/feeds/wifi-ax/qca-diag/src/diag.pc.in new file mode 100755 index 000000000..2985234f6 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/diag.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: diag +Description: Common functions for DIAG project test assets +Version: @VERSION@ +Libs: -L${libdir} -ldiag +Cflags: -I${includedir}/diag diff --git a/feeds/wifi-ax/qca-diag/src/include/comdef.h b/feeds/wifi-ax/qca-diag/src/include/comdef.h new file mode 100755 index 000000000..388862c5a --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/comdef.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017-2018 Qualcomm Technologies, Inc. + * + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + */ + +#ifndef __COMDEF_H +#define __COMDEF_H + +#define PACK(x) x __attribute__((__packed__)) + +#define TRUE 1 +#define FALSE 0 +#define QSDK_BUILD 1 +#define FEATURE_LE_DIAG 1 + +#include + +/* + * type defs + */ + +typedef uint8_t boolean; /* Boolean value type. */ +typedef uint32_t uint32; /* Unsigned 32 bit value */ +typedef uint16_t uint16; /* Unsigned 16 bit value */ +typedef uint8_t uint8; /* Unsigned 8 bit value */ +typedef int32_t int32; /* Signed 32 bit value */ +typedef int16_t int16; /* Signed 16 bit value */ +typedef int8_t int8; /* Signed 8 bit value */ +typedef uint64_t uint64; +typedef uint8_t byte; +typedef uint32_t dword; +typedef uint16_t word; + +#if __SIZEOF_POINTER__ == 4 +# define FPOS( type, field ) \ + /*lint -e545 */ ( (dword) &(( type *) 0)-> field) /*lint +e545 */ +#else +# define FPOS( type, field ) \ + /*lint -e545 */ ((uint64) &(( type *) 0)-> field) /*lint +e545 */ +#endif + +#define FSIZ( type, field ) sizeof( ((type *) 0)->field ) + +#ifndef MAX +#define MAX( x, y ) ( ((x) > (y)) ? (x) : (y) ) +#endif + +#ifndef MIN +#define MIN( x, y ) ( ((x) < (y)) ? (x) : (y) ) +#endif + +#endif /* END _COMDEF_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/diag.h b/feeds/wifi-ax/qca-diag/src/include/diag.h new file mode 100755 index 000000000..e1c996a45 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/diag.h @@ -0,0 +1,232 @@ +#ifndef DIAG_H +#define DIAG_H +/*========================================================================== + + Diagnostic Task Header File + +Description + Global Data declarations of the diag_task. + +# Copyright (c) 2007-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential.===========================================================================*/ + + +/*=========================================================================== + + Edit History + + $Header: //depot/asic/msmshared/services/diag/DIAG_7K/diag.h#5 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +12/22/06 as Moved proc ID macros to diag.h +12/05/06 as Added signal for Diag drain timer +11/21/06 as Moved DIAG internal features from diagi.h to diag.h +03/30/05 sl Added support for SPC_UNLOCK_TTL to unlock/lock the sp_state +10/17/03 ph For Rel A builds, redirect to new MC subsystem command. +09/23/03 gr Function prototypes related to changes that enable more + efficient detection of the condition where diag is out of + heap space. +08/20/01 jal Changes to support more Diag packets. Support for powerup + online/offline state, service programming lock state. +04/06/01 lad Cosmetic changes. +02/23/01 lad Rearchitected the diagnostics subsystem to be a service + rather than a module. All coupling to targets has been + moved to target-specific implementations. This file now + contains an API. No other information or coupling remains + except for featurized legacy code that impacts existing + targets. + Old history comments have been removed since most of them + are no longer applicable. + +===========================================================================*/ + +/* ------------------------------------------------------------------------- +** Definitions and Declarations +** ------------------------------------------------------------------------- */ +/* Diagnostics version (protocol revision). +*/ +/* DIAG_DIAGVER + Diagnostics version, used to ensure compatibility of the DM and the DMSS. + 1 Original + 2 Changes to status packet and verno packet. Removed verstr packet + 3 for release to factory. Sends RF mode in status packet + 4 Adds release directory to verno packet and dipswitch packets + 5 Many changes in DM. + 6 Added Vocoder PCM and PKT loopback, and Analog IS-55 tests + 7 New FER data in tagraph packet + 8 Streaming protocol enhancements and event reporting. +*/ +#ifdef FEATURE_DIAG_NON_STREAMING +#define DIAG_DIAGVER 7 +#else +#define DIAG_DIAGVER 8 +#endif + +/* ------------------------------------------------------------------------- +** Diag Internal features +** ------------------------------------------------------------------------- */ +/* Group all standalone features */ +#if (defined(FEATURE_STANDALONE) || defined(FEATURE_STANDALONE_APPS) || \ + defined(FEATURE_STANDALONE_MODEM)) + #define DIAG_STANDALONE +#endif + +/* Multi processor Diag */ +#if defined(FEATURE_MULTIPROCESSOR) && !(defined(DIAG_STANDALONE)) + #define DIAG_MP +#endif + +#define DIAG_MODEM_PROC 0 +#define DIAG_APP_PROC 1 +#define DIAG_DUAL_PROC 2 + +#if defined (DIAG_MP) + #if defined (FEATURE_DIAG_MP_MASTER_MODEM) + /* Master DIAG is on Modem Processor */ + #if defined (IMAGE_MODEM_PROC) + #define DIAG_MP_MASTER IMAGE_MODEM_PROC + #undef DIAG_MP_SLAVE + #endif + #if defined (IMAGE_APPS_PROC) + #define DIAG_MP_SLAVE IMAGE_APPS_PROC + #undef DIAG_MP_MASTER + #endif + #define DIAGPKT_REQ_FWD_PROC DIAG_APP_PROC + #elif defined (FEATURE_DIAG_MP_MASTER_APPS) + /* Master DIAG is on Apps Processor */ + #if defined (IMAGE_APPS_PROC) + #define DIAG_MP_MASTER IMAGE_APPS_PROC + #undef DIAG_MP_SLAVE + /* Mobile View code */ + #define DIAG_MV_CMD_RPC + #endif + #if defined (IMAGE_MODEM_PROC) + #define DIAG_MP_SLAVE IMAGE_MODEM_PROC + #undef DIAG_MP_MASTER + #endif + #define DIAGPKT_REQ_FWD_PROC DIAG_MODEM_PROC + #elif defined (FEATURE_DIAG_MP_MODEM_ONLY) + /* Should be same as single processor DIAG_SINGLE_PROC */ + #else + #error "Select where master diag should be" + #endif +#else + /* Should be same as single processor DIAG_SINGLE_PROC*/ + +#endif + + +/* Runtime Device Map port selection for diag */ +#if defined (FEATURE_RUNTIME_DEVMAP) +#if defined (DIAG_MP) + #if defined (DIAG_MP_MASTER)|| defined(FEATURE_DIAG_MP_MODEM_ONLY) + #define DIAG_RUNTIME_DEVMAP + #endif +#else + #define DIAG_RUNTIME_DEVMAP +#endif +#endif + +#if defined DIAG_MP + #if defined (DIAG_MP_MASTER) + #define DIAG_REQ_FWD /* Fowards requests to the slave proc */ + #define DIAG_NO_DSM_CHAINING + #define DIAG_FRAMING + #define DIAG_SIO_USB + #elif defined (DIAG_MP_SLAVE) + #define DIAG_RSP_SEND /* sends response */ + #endif + + #if defined (FEATURE_DIAG_MP_MODEM_ONLY) + #define DIAG_NO_DSM_CHAINING + #define DIAG_FRAMING + #define DIAG_RSP_SEND /* sends response */ + #undef DIAG_REQ_FWD + #endif + +#else /*DIAG_MP */ +/* Single processor or standalone builds */ + #define DIAG_NO_DSM_CHAINING + #define DIAG_FRAMING + #define DIAG_RSP_SEND /* sends response */ +#endif /*DIAG_MP*/ + + +/* Error cases */ +#if defined (DIAG_MP) && !defined(FEATURE_SMD) + #error "Error: FEATURE_SND is required for DIAG_MP" +#endif +#if defined (FEATURE_DIAG_MP_MODEM_ONLY) && \ + !(defined (DIAG_MP) || defined (IMAGE_MODEM_PROC)) + #error "Error: Invalid configuration for DIAG MP" +#endif + +#if defined (DIAG_MP_MASTER) + #if defined (DIAG_RSP_SEND) + #error "Error DIAG_RSP_SEND defined on Master" + #endif +#endif + +#if defined (DIAG_MP_SLAVE) + #if defined (DIAG_REQ_FWD) + #error "Error: DIAG_REQ_FWD defined on Slave" + #endif + #if defined (DIAG_NO_DSM_CHAINING) + #error "Error: DIAG_NO_DSM_CHAINING defined on Slave" + #endif + #if defined (DIAG_FRAMING) + #error "Error: DIAG_FRAMING defined on Slave" + #endif +#endif + + +#define DIAG_FTM_SWITCH_VAL 2 +/* This structure is sent to an event listener when an event is processed. + The implementation relies on the format of this structure. It is + dangerous to change this format of this structure. */ +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct +{ + unsigned int event_id; /* event ID */ + //qword ts; /* 8-byte CDMA time stamp. */ + uint32 ts_lo; /* Time stamp */ + uint32 ts_hi; + + uint8 length; /* length of the payload */ + /* Payload of size 'length': */ + uint8 payload[255]; /* payload, if length > 0 */ + +} +diag_event_type; + +/*=========================================================================== + +FUNCTION TYPE DIAG_CMD_RSP + +DESCRIPTION + This function type is provided by the caller when sending a request packet + using diag_cmd_req(). After the request is processed, this function is + called (if specified) with a pointer to the response packet and the handle + returned from the corresponding diag_cmd_req() call. + + Memory is owned by the DIAG task and is freed when this function returns. + + 'param' is the unmodified value from the corresponding diag_cmd_req() call. + +RETURN VALUE + None. + +===========================================================================*/ + typedef void (*diag_cmd_rsp) (const byte *rsp, unsigned int length, + void *param); + +#ifdef __cplusplus +} +#endif + +#endif /* DIAG_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/diag_lsm.h b/feeds/wifi-ax/qca-diag/src/include/diag_lsm.h new file mode 100755 index 000000000..9cfe35011 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/diag_lsm.h @@ -0,0 +1,553 @@ +#ifndef DIAG_LSM_H +#define DIAG_LSM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*=========================================================================== + + Diag Mapping Layer DLL declarations + +DESCRIPTION + Function declarations for Diag Service Mapping Layer + + +Copyright (c)2007-2012, 2014-2016 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. +===========================================================================*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +02/04/08 mad Added declarations for Diag_LSM_Init and DeInit functions + to enable diag clients to call these directly. + Moved IDiagPkt handle declaration to an internal header + file, Diag_LSMi.h +11/29/07 mad Created File +===========================================================================*/ + +#define MSG_MASKS_TYPE 0x00000001 +#define LOG_MASKS_TYPE 0x00000002 +#define EVENT_MASKS_TYPE 0x00000004 +#define PKT_TYPE 0x00000008 +#define DEINIT_TYPE 0x00000010 +#define USER_SPACE_DATA_TYPE 0x00000020 +#define DCI_DATA_TYPE 0x00000040 +#define USER_SPACE_RAW_DATA_TYPE 0x00000080 +#define DCI_LOG_MASKS_TYPE 0x00000100 +#define DCI_EVENT_MASKS_TYPE 0x00000200 +#define DCI_PKT_TYPE 0x00000400 +#define HDLC_SUPPORT_TYPE 0x00001000 + +#define USB_MODE 1 +#define MEMORY_DEVICE_MODE 2 +#define NO_LOGGING_MODE 3 +#define UART_MODE 4 +#define SOCKET_MODE 5 +#define CALLBACK_MODE 6 + +#define MAX_NUM_FILES_ON_DEVICE 2000 /* If user wants to stop logging on SD after reaching a max file limit */ +#define CONTROL_CHAR 0x7E +#define FILE_NAME_LEN 500 +#define NUM_PROC 10 +/* Token to identify MDM log */ +#define MDM_TOKEN -1 +#define MDM2_TOKEN -2 +/* Token to identify QSC log */ +#define QSC_TOKEN -5 +#define MSM 0 +#define MDM 1 +#define QSC 2 + +#define MODE_NONREALTIME 0 +#define MODE_REALTIME 1 +#define MODE_UNKNOWN 2 + +#define DIAG_PROC_DCI 1 +#define DIAG_PROC_MEMORY_DEVICE 2 + +/* List of processors */ +#define DIAG_ALL_PROC -1 +#define DIAG_MODEM_PROC 0 +#define DIAG_LPASS_PROC 1 +#define DIAG_WCNSS_PROC 2 +#define DIAG_SENSORS_PROC 3 +#define NUM_PERIPHERALS 4 +#define DIAG_APPS_PROC (NUM_PERIPHERALS) + +#define DIAG_CON_APSS (0x0001) /* Bit mask for APSS */ +#define DIAG_CON_MPSS (0x0002) /* Bit mask for MPSS */ +#define DIAG_CON_LPASS (0x0004) /* Bit mask for LPASS */ +#define DIAG_CON_WCNSS (0x0008) /* Bit mask for WCNSS */ +#define DIAG_CON_SENSORS (0x0010) /* Bit mask for Sensors */ +#define DIAG_CON_WDSP (0x0020) +#define DIAG_CON_CDSP (0x0040) +#define DIAG_CON_NPU (0x0080) +#define DIAG_CON_NONE (0x0000) /* Bit mask for No SS*/ +#define DIAG_CON_ALL (DIAG_CON_APSS | DIAG_CON_MPSS \ + | DIAG_CON_LPASS | DIAG_CON_WCNSS \ + | DIAG_CON_SENSORS | DIAG_CON_WDSP \ + | DIAG_CON_CDSP | DIAG_CON_NPU) + +#define DIAG_MSM_MASK (0x0001) /* Bit mask for APSS */ +#define DIAG_MDM_MASK (0x0002) /* Bit mask for MPSS */ +#define DIAG_MDM2_MASK (0x0004) /* Bit mask for LPASS */ + +#define DIAG_STREAMING_MODE 0 +#define DIAG_THRESHOLD_BUFFERING_MODE 1 +#define DIAG_CIRCULAR_BUFFERING_MODE 2 + +#define DIAG_MD_NONE 0 +#define DIAG_MD_PERIPHERAL 1 + +/* + * The status bit masks when received in a signal handler are to be + * used in conjunction with the peripheral list bit mask to determine the + * status for a peripheral. For instance, 0x00010002 would denote an open + * status on the MPSS + */ +#define DIAG_STATUS_OPEN (0x00010000) /* Bit mask for DCI channel open status */ +#define DIAG_STATUS_CLOSED (0x00020000) /* Bit mask for DCI channel closed status */ + +#define GUID_LEN 16 + +#ifdef ANDROID + #define LOG_TAG "Diag_Lib" + #define DIAG_LOGE(...) { \ + ALOGE(__VA_ARGS__); \ + if (!diag_disable_console) \ + printf(__VA_ARGS__); \ + } + #include + #include "common_log.h" +#else + #define DIAG_LOGE(...) printf (__VA_ARGS__) +#endif +#include +#include + +#define GUID_LIST_XML_TAG_SIZE 13 +#define GUID_LIST_END_XML_TAG_SIZE 20 + +#ifdef USE_GLIB +#define strlcpy g_strlcpy +#define strlcat g_strlcat +#endif + +extern int logging_mode; +extern char mask_file[FILE_NAME_LEN]; +extern char mask_file_mdm[FILE_NAME_LEN]; +extern char output_dir[NUM_PROC][FILE_NAME_LEN]; +extern int diag_disable_console; +extern char dir_name[FILE_NAME_LEN]; +extern char proc_name[NUM_PROC][6]; +extern pthread_cond_t qsr4_read_db_cond; +extern uint8 hdlc_disabled; +extern char qsr4_xml_file_name[FILE_NAME_LEN]; +extern int fd_qsr4_xml[NUM_PROC]; + +typedef enum { + DB_PARSER_STATE_OFF, + DB_PARSER_STATE_ON, + DB_PARSER_STATE_LIST, + DB_PARSER_STATE_OPEN, + DB_PARSER_STATE_READ, + DB_PARSER_STATE_CLOSE, +} qsr4_db_file_parser_state; + +/* + * Structure to keep track of diag callback interface clients. Please note that + * there can be only client communicating with an ASIC at a given time. + * + * @inited: flag to indicate if the table entry is initialized + * @cb_func_ptr: callback function pointer + * @context_data: user specified data + * + */ +struct diag_callback_tbl_t { + int inited; + int (*cb_func_ptr)(unsigned char *, int len, void *context_data); + void *context_data; +}; + +struct diag_uart_tbl_t { + int proc_type; + int pid; + int (*cb_func_ptr)(unsigned char *, int len, void *context_data); + void *context_data; +}; + +struct diag_con_all_param_t { + uint32 diag_con_all; + uint32 num_peripherals; + uint32 upd_map_supported; +}; + +struct diag_query_pid_t { + uint32 peripheral_mask; + uint32 pd_mask; + int pid; + uint32 device_mask; +}; + +struct diag_logging_mode_param_t { + uint32 req_mode; + uint32 peripheral_mask; + uint32 pd_mask; + uint8 mode_param; + uint8 diag_id; + uint8 pd_val; + uint8 reserved; + int peripheral; + uint32 device_mask; +}; + +/*=========================================================================== +FUNCTION Diag_LSM_Init + +DESCRIPTION + Initializes the Diag Legacy Mapping Layer. This should be called + only once per process. + +DEPENDENCIES + Successful initialization requires Diag CS component files to be present + and accessible in the file system. + +RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ +boolean Diag_LSM_Init (byte* pIEnv); + +/*=========================================================================== +FUNCTION diag_switch_logging_proc + +DESCRIPTION + This swtiches the logging mode from default USB to memory device logging + +DEPENDENCIES + valid data type to be passed in: + +RETURN VALUE + 0 - Success; failure otherwise + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_switch_logging_proc(struct diag_logging_mode_param_t *params); + +/*=========================================================================== +FUNCTION diag_switch_logging + +DESCRIPTION + This swtiches the logging mode from default USB to memory device logging + +DEPENDENCIES + valid data type to be passed in: + In case of ODL second argument is to specifying directory location. + In case of UART mode second argument is specify PROC type. + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void diag_switch_logging(int requested_mode, char *dir_location); +/*=========================================================================== +FUNCTION diag_read_mask_file + +DESCRIPTION + This reads the mask file + +DEPENDENCIES + valid data type to be passed in + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ + +int diag_read_mask_file(void); +/*=========================================================================== +FUNCTION diag_register_callback + +DESCRIPTION + This allows diag client to register a callback function with LSM library. + If the library receives data from kernel space, it will invoke this call + back function, thus passing the data to the client through this function. + +DEPENDENCIES + valid data type to be passed in + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void diag_register_callback(int (*client_cb_func_ptr)(unsigned char *ptr, + int len, void *context_data), void *context_data); + +/*=========================================================================== +FUNCTION diag_register_remote_callback + +DESCRIPTION + This allows diag client to register a callback function with LSM library. + If the library receives data from kernel space originating from the remote + processor, it will invoke this call back function, thus passing the data + to the client through this function. + +DEPENDENCIES + valid data type to be passed in + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void diag_register_remote_callback(int (*client_rmt_cb_func_ptr)(unsigned char *ptr, + int len, void *context_data), int proc, + void *context_data); + +/*=========================================================================== + +FUNCTION diag_send_data + +DESCRIPTION + Inject data into diag kernel driver + +DEPENDENCIES + None. + +RETURN VALUE + FALSE = failure, else TRUE. + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_send_data(unsigned char *, int); + +/*=========================================================================== + +FUNCTION diag_callback_send_data + +DESCRIPTION + Inject data into diag kernel driver for a specific processor in + callback mode + +DEPENDENCIES + None. + +RETURN VALUE + FALSE = failure, else TRUE. + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_callback_send_data(int proc, unsigned char * buf, int len); + +/*=========================================================================== + +FUNCTION diag_callback_send_data_hdlc + +DESCRIPTION + Inject hdlc data into diag kernel driver for a specific processor in + callback mode + +DEPENDENCIES + None. + +RETURN VALUE + FALSE = failure, else TRUE. + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_callback_send_data_hdlc(int proc, unsigned char * buf, int len); + +/*=========================================================================== + +FUNCTION diag_vote_md_real_time + +DESCRIPTION + Votes the on device logging process for real/non-real time + mode + +DEPENDENCIES + None. + +RETURN VALUE + 0 = success, -1 = failure + +SIDE EFFECTS + Puts the entire diag in the mode specified if the process wins + the vote + +===========================================================================*/ +int diag_vote_md_real_time(int real_time); + +/*=========================================================================== + +FUNCTION diag_vote_md_real_time_proc + +DESCRIPTION + Votes the on device logging process for real/non-real time + mode, in a particular processor. + +DEPENDENCIES + None. + +RETURN VALUE + 0 = success, -1 = failure + +SIDE EFFECTS + Puts the entire diag in the mode specified if the process wins + the vote + +===========================================================================*/ +int diag_vote_md_real_time_proc(int proc, int real_time); + +/*=========================================================================== + +FUNCTION diag_get_real_time_status + +DESCRIPTION + Gets the mode (real time or non real time) in which Diag is in + +DEPENDENCIES + None. + +RETURN VALUE + 0 = success, -1 = failure + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_get_real_time_status(int *real_time); + +/*=========================================================================== + +FUNCTION diag_get_real_time_status_proc + +DESCRIPTION + Gets the mode (real time or non real time) in which Diag is + in, in a particular processor + +DEPENDENCIES + None. + +RETURN VALUE + 0 = success, -1 = failure + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_get_real_time_status_proc(int proc, int *real_time); + +/*=========================================================================== + +FUNCTION Diag_LSM_DeInit + +DESCRIPTION + De-Initialize the Diag service. + +DEPENDENCIES + None. + +RETURN VALUE + FALSE = failure, else TRUE. + Currently all the internal boolean return functions called by + this function just returns TRUE w/o doing anything. + +SIDE EFFECTS + None + +===========================================================================*/ +boolean Diag_LSM_DeInit(void); + +/*=========================================================================== + +FUNCTION diag_configure_peripheral_buffering_tx_mode + +DESCRIPTION + Configure the peripheral Diag's TX mode to Streaming, Circular, or + Threshold buffering mode and set high and low watermark threshold limits. + Streaming Mode is a default TX mode for peripheral Diag. + Switching to Threshold or Circular buffering mode puts the peripheral + Diag to Non-Real Time mode (NRT). + Switching to streaming mode will put the peripheral to Real Time (RT) mode. + +DEPENDENCIES + None. + +RETURN VALUE + 1 = success, else failure + +SIDE EFFECTS + Clients cannot vote for real/non-real time when the Tx mode is set + to Circular, or Threshold buffering mode. + +===========================================================================*/ +int diag_configure_peripheral_buffering_tx_mode(uint8 peripheral, uint8 tx_mode, + uint8 low_wm_val, uint8 high_wm_val); + +/*=========================================================================== + +FUNCTION diag_peripheral_buffering_drain_immediate + +DESCRIPTION + +Request the peripheral to drain its Tx buffering pool immediately. +If peripheral Diag receives this request in +Streaming mode - No action is taken since Diag is already streaming. +Threshold or Circular buffering modes - Diag will drain its Tx buffering +pool until the low watermark threshold is reached, and then resume +buffering in the tx mode it was set + + +DEPENDENCIES + None. + +RETURN VALUE + 1 = success, else failure + +SIDE EFFECTS + None + +===========================================================================*/ + +int diag_peripheral_buffering_drain_immediate(uint8 peripheral); + +#ifdef __cplusplus +} +#endif + +#endif /* DIAG_LSM_H */ + diff --git a/feeds/wifi-ax/qca-diag/src/include/diag_lsm_dci.h b/feeds/wifi-ax/qca-diag/src/include/diag_lsm_dci.h new file mode 100755 index 000000000..109a1e107 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/diag_lsm_dci.h @@ -0,0 +1,212 @@ +#ifndef DIAG_LSM_DCI_H +#define DIAG_LSM_DCI_H + +#ifdef __cplusplus +extern "C" +{ +#endif +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* +# Copyright (c) 2012-2013, 2015-2016 by Qualcomm Technologies, Inc. +# All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + + Diag Consumer Interface (DCI) + +GENERAL DESCRIPTION + +Headers specific to DCI. + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/09/12 RA Added Interface for DCI I/O +03/20/12 SJ Created +===========================================================================*/ + +/*strlcpy is from OpenBSD and not supported by Meego. +GNU has an equivalent g_strlcpy implementation into glib. +Featurized with compile time USE_GLIB flag for Meego builds.*/ +#ifdef USE_GLIB +#define strlcpy g_strlcpy +#define strlcat g_strlcat +#include +#include +#endif + +/* This is a bit mask used for peripheral list. */ +typedef uint16 diag_dci_peripherals; + +#define ENABLE 1 +#define DISABLE 0 +#define IN_BUF_SIZE 16384 + +#define DIAG_INVALID_SIGNAL 0 + +#define DIAG_PROC_MSM 0 +#define DIAG_PROC_MDM 1 + +/* This is used for health stats */ +struct diag_dci_health_stats { + int dropped_logs; + int dropped_events; + int received_logs; + int received_events; + int reset_status; +}; + +/* List of possible error codes returned during DCI transaction */ +enum { + DIAG_DCI_NO_ERROR = 1001, /* No error */ + DIAG_DCI_NO_REG, /* Could not register */ + DIAG_DCI_NO_MEM, /* Failed memory allocation */ + DIAG_DCI_NOT_SUPPORTED, /* This particular client is not supported */ + DIAG_DCI_HUGE_PACKET, /* Request/Response Packet too huge */ + DIAG_DCI_SEND_DATA_FAIL, /* writing to kernel or remote peripheral fails */ + DIAG_DCI_ERR_DEREG, /* Error while de-registering */ + DIAG_DCI_PARAM_FAIL, /* Incorrect Parameter */ + DIAG_DCI_DUP_CLIENT /* Client already exists for this proc */ +} diag_dci_error_type; + +/* --------------------------------------------------------------------------- + External functions + --------------------------------------------------------------------------- */ + +/* Initialization function required for DCI functions. Input parameters are: + a) pointer to an int which holds client id + b) pointer to a bit mask which holds peripheral information, + c) an integer to specify which processor to talk to (Local or Remote in the case of Fusion Devices), + d) void* for future needs (not implemented as of now) */ +int diag_register_dci_client(int *, diag_dci_peripherals *, int, void *); + +/* This API provides information about the peripherals that supports + DCI in the local processor. Input parameters are: + a) pointer to a diag_dci_peripherals variable to store the bit mask + + DEPRECATED - Use diag_get_dci_support_list_proc instead. */ +int diag_get_dci_support_list(diag_dci_peripherals *); + +/* This API provides information about the peripherals that support + DCI in a given processor. Input Parameters are: + a) processor id + b) pointer to a diag_dci_peripherals variable to store the bit mask */ +int diag_get_dci_support_list_proc(int proc, diag_dci_peripherals *list); + +/* Version handshaking function. This will get the dci version of diag lsm */ +int diag_dci_get_version(void); + +/* Version handshaking function. This will register the version the client is using */ +int diag_dci_set_version(int proc, int version); + +/* Main command to send the DCI request. Input parameters are: + a) client ID generate earlier + b) request buffer + c) request buffer length + d) response buffer + e) response buffer length + f) call back function pointer + g) data pointer */ +int diag_send_dci_async_req(int client_id, unsigned char buf[], int bytes, unsigned char *rsp_ptr, int rsp_len, + void (*func_ptr)(unsigned char *ptr, int len, void *data_ptr), void *data_ptr); + +/* Closes DCI connection for this client. The client needs to pass a pointer + to the client id generated earlier */ +int diag_release_dci_client(int *); + +/* Used to set up log streaming to the client. This will send an array of log codes, which are desired + by client. Input parameters are: + 1. Client ID + 2. Boolean value telling to set or disable logs specified later + 3. Array of log codes + 4. Number of log codes specified in argument 3 + */ +int diag_log_stream_config(int client_id, int set_mask, uint16 log_codes_array[], int num_codes); + +/* Initialization function required for DCI streaming. Input parameters are: + call back function pointers. + + DEPRECATED - Use diag_register_dci_stream_proc instead */ +int diag_register_dci_stream(void (*func_ptr_logs)(unsigned char *ptr, int len), + void (*func_ptr_events)(unsigned char *ptr, int len)); + +int diag_register_dci_stream_proc(int client_id, + void(*func_ptr_logs)(unsigned char *ptr, int len), + void(*func_ptr_events)(unsigned char *ptr, int len)); + +/* Used to set up event streaming to the client. This will send an array of event ids, which are desired + by client. Input parameters are: + 1. Client ID + 2. Boolean value telling to set or disable event specified later + 3. Array of event id + 4. Number of event ids specified in argument 3 + */ +int diag_event_stream_config(int client_id, int set_mask, int event_id_array[], int num_codes); + +/* Used to query DCI statistics on all processors for logs & events. + + DEPRECATED - Use diag_get_health_stats_proc instead */ +int diag_get_health_stats(struct diag_dci_health_stats *dci_health); + +/* Used to query DCI statistics on a specific processor for logs & events */ +int diag_get_health_stats_proc(int client_id, struct diag_dci_health_stats *dci_health, int proc); + +/* Queries a given Log Code to check if it is enabled or not. Input parameters are: + 1. Client ID + 2. Log Code that needs to be checked + 3. Pointer to boolean to store the result */ +int diag_get_log_status(int client_id, uint16 log_code, boolean *value); + +/* Queries a given Event ID to check if it is enabled or not. Input parameters are: + 1. Client ID + 2. Event ID that needs to be checked + 3. Pointer to boolean to store the result */ +int diag_get_event_status(int client_id, uint16 event_id, boolean *value); + +/* Disables all the Log Codes for a given client. The Input parameters are: + 1. Client ID */ +int diag_disable_all_logs(int client_id); + +/* Disables all the Event ID for a given client. The Input parameters are: + 1. Client ID */ +int diag_disable_all_events(int client_id); + +/* Votes for real time or non real time mode. The Input paramters are: + 1. Client ID + 2. The desired mode - MODE_REALTIME or MODE_NONREALTIME */ +int diag_dci_vote_real_time(int client_id, int real_time); + +/* Gets the current mode (Real time or Non Real Time ) Diag is in. + The Input parameters are: + 1. A pointer to an integer that will hold the result */ +int diag_dci_get_real_time_status(int *real_time); + +/* Gets the current mode (Real time or Non Real Time ) Diag is + in, in the requested processor. The Input parameters are: + 1. processor the client is interested in + 2. A pointer to an integer that will hold the result*/ +int diag_dci_get_real_time_status_proc(int proc, int *real_time); + +/* Registers a signal to be fired on receiving DCI data from + the peripherals. The input parameters are: + 1. Client ID + 2. Signal Type */ +int diag_register_dci_signal_data(int client_id, int signal_type); + +/* Disables the signal that fires on receiving DCI data from + the peripherals. The input parameters are: + 1. Client ID + 2. Signal Type */ +int diag_deregister_dci_signal_data(int client_id); + +#ifdef __cplusplus +} +#endif + +#endif /* DIAG_LSM_DCI_H */ + diff --git a/feeds/wifi-ax/qca-diag/src/include/diagcmd.h b/feeds/wifi-ax/qca-diag/src/include/diagcmd.h new file mode 100755 index 000000000..86fb9ce47 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/diagcmd.h @@ -0,0 +1,679 @@ +#ifndef DIAGCMD_H +#define DIAGCMD_H +/*! +@ingroup packet_service +@file diagcmd.h + +@brief + + Diagnostic Services Packet Processing Command Code Defintions + + + @details + This file contains packet id definitions and enumeration constants for subsystem identifiers (diagpkt_subsys_cmd_enum_type) + for the serial interface to the dmss. All packets must have unique identifiers (command codes). Once published, an identifier cannot + be changed. Subsystem identifiers (SSIDs) allow each technology area to define, grow, and maintain a list of unique packet identifiers + without coordinating with each other. It is required that all clients of the diagnostic dispatching service use the subsystem commands. + Subsystem Identifiers 250 to 254 are reserved for OEMs use only .Please refer to the documentation of 80-V1294-1 for the packet request/response + defintions of each packet id . + + @note + DO NOT MODIFY THIS FILE WITHOUT PRIOR APPROVAL + Diag commands, by design, are a tightly controlled set of values. + Developers may not create command IDs at will. + Request new commands using the following process: + + 1. Send email to asw.diag.request requesting command ID assignments. + 2. Identify the command needed by name. + 3. Provide a brief description for the command. + +*/ + +/* +Copyright (c) 1993-2015 by Qualcomm Technologies, Incorporated. All Rights Reserved. +*/ + + + +/*=========================================================================== + + Edit History + +$Header: //source/qcom/qct/core/api/services/diag/main/latest/diagcmd.h#48 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +08/04/14 xy Added DIAG_SUBSYS_AOSTLM_TEST +06/18/14 xy Added DIAG_SUBSYS_STORAGE and DIAG_SUBSYS_WCI2 +11/13/13 xy Added DIAG_QSR4_EXT_MSG_TERSE_F +10/09/13 xy Added DIAG_SUBSYS_IMS_QVP_RTP +09/25/13 xy Added DIAG_SUBSYS_LWIP +08/26/13 sr Added DIAG_SUBSYS_CNSS_POWER +06/26/13 sr Added DIAG_SUBSYS_SYSTEM_OPERATIONS +05/31/13 sr Removed the peek and poke cmds +05/08/13 sr Added DIAG_SUBSYS_DS_IPA +03/22/13 sr Added DIAG_SUBSYS_LIMITSMGR +10/23/12 sr Added DIAG_SUBSYS_FTM_ANT +09/19/12 rh Added DIAG_SUBSYS_TTLITE +09/17/12 rh Added DIAG_SUBSYS_GNSS_SOC +08/13/12 rh Added DIAG_SUBSYS_CXM +06/22/12 rh Added subsystem ID for QDSS +06/06/12 rh Added subsystem ID DIAG_SUBSYS_MPOWER +01/16/12 tbg Added Secure Service Module error response +01/03/12 is Add subsystem ID for TDSCDMA +10/21/11 rh CMAPI subsystem id added +10/18/11 hm New DCI commands added +07/01/11 hm Allocated subsystem command codes for Flash +04/06/11 hm Added subsystem id for 3GPP NAS team +02/25/11 hm Added subsystem id for USCRIPT tool +01/18/11 hm Added subsystem id for Q5 CORE +09/22/10 vg Added subsystem id for STRIDE +07/15/10 sg Added subsystem id for QNP +05/21/10 sg Doxygenated the file +05/16/10 as Added cmd_codes 101,102,105&106 for backward comparibility +04/21/10 sg Added new SSID for Ulog Services +04/20/10 is Remove support for DIAG_GET_PROPERTY_F, DIAG_PUT_PROPERTY_F, + DIAG_GET_PERM_PROPERTY_F, and DIAG_PUT_PERM_PROPERTY_F. +06/10/02 lcl/jwh FEATURE_HWTC changes. +05/23/02 sfh Added DIAG_PROTOCOL_LOOPBACK_F (123) command. +06/27/01 lad Assigned equipment ID 0 to be for OEMs to use. +05/21/01 sfh Added DIAG_TRACE_EVENT_REPORT_F for trace event support. +04/17/01 lad Moved subsystem dispatch IDs from diagpkt.h. +04/06/01 lad Changed the name of cmd code 111 from DUAG_TUNNEL_F to + DIAG_ROUTE_F. +02/23/01 lad Cosmetic changes. +09/06/00 bgc Added support for FEATURE_FACTORY_TESTMODE with + DIAG_FTM_CMD_F (set to 59, which is also DIAG_TMOB_F). +08/31/00 lad Added command code for tunneling capability. +06/23/00 lad Removed obsolete command codes and marked them "reserved". +06/19/00 lad Added DIAG_PARM_RETRIEVE_F +05/31/00 jal Added GPS statistics, session control, and grid support. +05/15/00 lad Added streaming config support (nice). +02/28/00 lad Added codes for event reporting service. +02/02/00 lad Added commands used with FEATURE_DIAG_QCT_EXT. +09/17/99 lcc Merged in RPC support from PLT archive. +08/17/99 tac Merged in EFS changes from branch. +07/19/99 sk Replacing reset_sup_fer with walsh code. +07/19/99 sk Added walsh code display command. +03/30/99 lad Added support for FEATURE_IS95B_MDR and FEATURE_SPECIAL_MDR. +11/04/98 lad Added 1998/1999 copyright information. +10/29/98 jmk Merged Module command changes into the mainline. + (Replaced MOD_GET_STATUS with MOD_EXTENDED_PKT cmd code 75) +10/27/98 jmk Added cmd IDs for CSS command, and SMS message read/write. +09/11/98 grl Added feature query command +10/06/97 jjn Added new commands for the Module Phase 1 interface. These + include Module Status Mask, AKEY and audio control packets. +04/23/97 jjn Added new packet pair to allow System Unit to access + service option and caller ID information +03/25/97 jjn Added new command (and packets) that allow writing to NV + without going offline (for the Module only) +02/28/97 jjn Enabled RSSI packets for the Module, added a packet for + module status and sound reporting, and added a pcket for + retrieving SMS messages +06/25/96 jmk Added cmd id for preferred roaming list read. +06/24/96 jmk Added cmd id for preferred roaming list write. +04/09/96 jmk Added cmd ids for sending security code, and return code + if phone is not unlocked for operations that require it. +03/06/96 jmk Added command id for serial mode change (to AT cmd mode) + and command id for get rssi (for antenna aiming/WLL only) +08/16/95 jmk Added command id for parm_get2 (includes MUX2 parms) +08/10/95 jmk Added command id for Phone State, Pilot Sets and SPC reqs +01/28/95 ptw Added command id to obtain System Time from the mobile. +12/07/94 jmk Added command id for portable sleep on/off request. +11/07/94 jmk Added command to request that seq_nums be used in pkts. +09/26/94 jmk Put DIAG_ORIG_F and DIAG_END_F back in. +07/23/93 twp Added DIAG_TMOB_F +01/14/93 twp First release + +===========================================================================*/ + +/*-------------------------------------------------------------------------- + + Command Codes between the Diagnostic Monitor and the mobile. Packets + travelling in each direction are defined here, while the packet templates + for requests and responses are distinct. Note that the same packet id + value can be used for both a request and a response. These values + are used to index a dispatch table in diag.c, so + + DON'T CHANGE THE NUMBERS ( REPLACE UNUSED IDS WITH FILLERS ). NEW IDs + MUST BE ASSIGNED AT THE END. + +----------------------------------------------------------------------------*/ + +/*! +@cond DOXYGEN_BLOAT +*/ +/* Version Number Request/Response */ +#define DIAG_VERNO_F 0 + +/* Mobile Station ESN Request/Response */ +#define DIAG_ESN_F 1 + +/* 2-11 Obsolete */ + + +/* DMSS status Request/Response */ +#define DIAG_STATUS_F 12 + +/* 13-14 Reserved */ + +/* Set logging mask Request/Response */ +#define DIAG_LOGMASK_F 15 + +/* Log packet Request/Response */ +#define DIAG_LOG_F 16 + +/* Peek at NV memory Request/Response */ +#define DIAG_NV_PEEK_F 17 + +/* Poke at NV memory Request/Response */ +#define DIAG_NV_POKE_F 18 + +/* Invalid Command Response */ +#define DIAG_BAD_CMD_F 19 + +/* Invalid parmaeter Response */ +#define DIAG_BAD_PARM_F 20 + +/* Invalid packet length Response */ +#define DIAG_BAD_LEN_F 21 + +/* 22-23 Reserved */ + +/* Packet not allowed in this mode + ( online vs offline ) */ +#define DIAG_BAD_MODE_F 24 + +/* info for TA power and voice graphs */ +#define DIAG_TAGRAPH_F 25 + +/* Markov statistics */ +#define DIAG_MARKOV_F 26 + +/* Reset of Markov statistics */ +#define DIAG_MARKOV_RESET_F 27 + +/* Return diag version for comparison to + detect incompatabilities */ +#define DIAG_DIAG_VER_F 28 + +/* Return a timestamp */ +#define DIAG_TS_F 29 + +/* Set TA parameters */ +#define DIAG_TA_PARM_F 30 + +/* Request for msg report */ +#define DIAG_MSG_F 31 + +/* Handset Emulation -- keypress */ +#define DIAG_HS_KEY_F 32 + +/* Handset Emulation -- lock or unlock */ +#define DIAG_HS_LOCK_F 33 + +/* Handset Emulation -- display request */ +#define DIAG_HS_SCREEN_F 34 + +/* 35 Reserved */ + +/* Parameter Download */ +#define DIAG_PARM_SET_F 36 + +/* 37 Reserved */ + +/* Read NV item */ +#define DIAG_NV_READ_F 38 +/* Write NV item */ +#define DIAG_NV_WRITE_F 39 +/* 40 Reserved */ + +/* Mode change request */ +#define DIAG_CONTROL_F 41 + +/* Error record retreival */ +#define DIAG_ERR_READ_F 42 + +/* Error record clear */ +#define DIAG_ERR_CLEAR_F 43 + +/* Symbol error rate counter reset */ +#define DIAG_SER_RESET_F 44 + +/* Symbol error rate counter report */ +#define DIAG_SER_REPORT_F 45 + +/* Run a specified test */ +#define DIAG_TEST_F 46 + +/* Retreive the current dip switch setting */ +#define DIAG_GET_DIPSW_F 47 + +/* Write new dip switch setting */ +#define DIAG_SET_DIPSW_F 48 + +/* Start/Stop Vocoder PCM loopback */ +#define DIAG_VOC_PCM_LB_F 49 + +/* Start/Stop Vocoder PKT loopback */ +#define DIAG_VOC_PKT_LB_F 50 + +/* 51-52 Reserved */ + +/* Originate a call */ +#define DIAG_ORIG_F 53 +/* End a call */ +#define DIAG_END_F 54 +/* 55-57 Reserved */ + +/* Switch to downloader */ +#define DIAG_DLOAD_F 58 +/* Test Mode Commands and FTM commands */ +#define DIAG_TMOB_F 59 +/* Test Mode Commands and FTM commands */ +#define DIAG_FTM_CMD_F 59 +/* 60-62 Reserved */ + +/* Featurization Removal requested by CMI +#ifdef FEATURE_HWTC +*/ + +#define DIAG_TEST_STATE_F 61 +/* +#endif +*/ + +/* Return the current state of the phone */ +#define DIAG_STATE_F 63 + +/* Return all current sets of pilots */ +#define DIAG_PILOT_SETS_F 64 + +/* Send the Service Prog. Code to allow SP */ +#define DIAG_SPC_F 65 + +/* Invalid nv_read/write because SP is locked */ +#define DIAG_BAD_SPC_MODE_F 66 + +/* get parms obsoletes PARM_GET */ +#define DIAG_PARM_GET2_F 67 + +/* Serial mode change Request/Response */ +#define DIAG_SERIAL_CHG_F 68 + +/* 69 Reserved */ + +/* Send password to unlock secure operations + the phone to be in a security state that + is wasn't - like unlocked. */ +#define DIAG_PASSWORD_F 70 + +/* An operation was attempted which required */ +#define DIAG_BAD_SEC_MODE_F 71 + +/* Write Preferred Roaming list to the phone. */ +#define DIAG_PR_LIST_WR_F 72 + +/* Read Preferred Roaming list from the phone.*/ +#define DIAG_PR_LIST_RD_F 73 + +/* 74 Reserved */ + +/* Subssytem dispatcher (extended diag cmd) */ +#define DIAG_SUBSYS_CMD_F 75 + +/* 76-80 Reserved */ + +/* Asks the phone what it supports */ +#define DIAG_FEATURE_QUERY_F 81 + +/* 82 Reserved */ + +/* Read SMS message out of NV */ +#define DIAG_SMS_READ_F 83 + +/* Write SMS message into NV */ +#define DIAG_SMS_WRITE_F 84 + +/* info for Frame Error Rate + on multiple channels */ +#define DIAG_SUP_FER_F 85 + +/* Supplemental channel walsh codes */ +#define DIAG_SUP_WALSH_CODES_F 86 + +/* Sets the maximum # supplemental + channels */ +#define DIAG_SET_MAX_SUP_CH_F 87 + +/* get parms including SUPP and MUX2: + obsoletes PARM_GET and PARM_GET_2 */ +#define DIAG_PARM_GET_IS95B_F 88 + +/* Performs an Embedded File System + (EFS) operation. */ +#define DIAG_FS_OP_F 89 + +/* AKEY Verification. */ +#define DIAG_AKEY_VERIFY_F 90 + +/* Handset emulation - Bitmap screen */ +#define DIAG_BMP_HS_SCREEN_F 91 + +/* Configure communications */ +#define DIAG_CONFIG_COMM_F 92 + +/* Extended logmask for > 32 bits. */ +#define DIAG_EXT_LOGMASK_F 93 + +/* 94-95 reserved */ + +/* Static Event reporting. */ +#define DIAG_EVENT_REPORT_F 96 + +/* Load balancing and more! */ +#define DIAG_STREAMING_CONFIG_F 97 + +/* Parameter retrieval */ +#define DIAG_PARM_RETRIEVE_F 98 + + /* A state/status snapshot of the DMSS. */ +#define DIAG_STATUS_SNAPSHOT_F 99 + +/* 100 obsolete */ + +/* Get_property requests */ +#define DIAG_GET_PROPERTY_F 101 + +/* Put_property requests */ +#define DIAG_PUT_PROPERTY_F 102 + +/* Get_guid requests */ +#define DIAG_GET_GUID_F 103 + +/* Invocation of user callbacks */ +#define DIAG_USER_CMD_F 104 + +/* Get permanent properties */ +#define DIAG_GET_PERM_PROPERTY_F 105 + +/* Put permanent properties */ +#define DIAG_PUT_PERM_PROPERTY_F 106 + +/* Permanent user callbacks */ +#define DIAG_PERM_USER_CMD_F 107 + +/* GPS Session Control */ +#define DIAG_GPS_SESS_CTRL_F 108 + +/* GPS search grid */ +#define DIAG_GPS_GRID_F 109 + +/* GPS Statistics */ +#define DIAG_GPS_STATISTICS_F 110 + +/* Packet routing for multiple instances of diag */ +#define DIAG_ROUTE_F 111 + +/* IS2000 status */ +#define DIAG_IS2000_STATUS_F 112 + +/* RLP statistics reset */ +#define DIAG_RLP_STAT_RESET_F 113 + +/* (S)TDSO statistics reset */ +#define DIAG_TDSO_STAT_RESET_F 114 + +/* Logging configuration packet */ +#define DIAG_LOG_CONFIG_F 115 + +/* Static Trace Event reporting */ +#define DIAG_TRACE_EVENT_REPORT_F 116 + +/* SBI Read */ +#define DIAG_SBI_READ_F 117 + +/* SBI Write */ +#define DIAG_SBI_WRITE_F 118 + +/* SSD Verify */ +#define DIAG_SSD_VERIFY_F 119 + +/* Log on Request */ +#define DIAG_LOG_ON_DEMAND_F 120 + +/* Request for extended msg report */ +#define DIAG_EXT_MSG_F 121 + +/* ONCRPC diag packet */ +#define DIAG_ONCRPC_F 122 + +/* Diagnostics protocol loopback. */ +#define DIAG_PROTOCOL_LOOPBACK_F 123 + +/* Extended build ID text */ +#define DIAG_EXT_BUILD_ID_F 124 + +/* Request for extended msg report */ +#define DIAG_EXT_MSG_CONFIG_F 125 + +/* Extended messages in terse format */ +#define DIAG_EXT_MSG_TERSE_F 126 + +/* Translate terse format message identifier */ +#define DIAG_EXT_MSG_TERSE_XLATE_F 127 + +/* Subssytem dispatcher Version 2 (delayed response capable) */ +#define DIAG_SUBSYS_CMD_VER_2_F 128 + +/* Get the event mask */ +#define DIAG_EVENT_MASK_GET_F 129 + +/* Set the event mask */ +#define DIAG_EVENT_MASK_SET_F 130 + +/* RESERVED CODES: 131-139 */ + +/* Command Code for Changing Port Settings */ +#define DIAG_CHANGE_PORT_SETTINGS 140 + +/* Country network information for assisted dialing */ +#define DIAG_CNTRY_INFO_F 141 + +/* Send a Supplementary Service Request */ +#define DIAG_SUPS_REQ_F 142 + +/* Originate SMS request for MMS */ +#define DIAG_MMS_ORIG_SMS_REQUEST_F 143 + +/* Change measurement mode*/ +#define DIAG_MEAS_MODE_F 144 + +/* Request measurements for HDR channels */ +#define DIAG_MEAS_REQ_F 145 + +/* Send Optimized F3 messages */ +#define DIAG_QSR_EXT_MSG_TERSE_F 146 + +/* Packet ID for command/responses sent over DCI */ +#define DIAG_DCI_CMD_REQ 147 + +/* Packet ID for delayed responses sent over DCI */ +#define DIAG_DCI_DELAYED_RSP 148 + +/* Error response code on DCI (only APSS side) */ +#define DIAG_BAD_TRANS_F 149 + +/* Error response code for cmomands disallowed by SSM */ +#define DIAG_SSM_DISALLOWED_CMD_F 150 + +/* Log on extended Request */ +#define DIAG_LOG_ON_DEMAND_EXT_F 151 + +/* Packet ID for extended event/log/F3 pkt */ +#define DIAG_CMD_EXT_F 152 + +/*Qshrink4 command code for Qshrink 4 packet*/ +#define DIAG_QSR4_EXT_MSG_TERSE_F 153 + +/*DCI command code for dci control packet*/ +#define DIAG_DCI_CONTROL_PACKET 154 + +/*Compressed diag data which is sent out by the DMSS to the host.*/ +#define DIAG_COMPRESSED_PKT 155 + + +/* Number of packets defined. */ +#define DIAG_MAX_F 155 + + + +typedef enum { + DIAG_SUBSYS_OEM = 0, /* Reserved for OEM use */ + DIAG_SUBSYS_ZREX = 1, /* ZREX */ + DIAG_SUBSYS_SD = 2, /* System Determination */ + DIAG_SUBSYS_BT = 3, /* Bluetooth */ + DIAG_SUBSYS_WCDMA = 4, /* WCDMA */ + DIAG_SUBSYS_HDR = 5, /* 1xEvDO */ + DIAG_SUBSYS_DIABLO = 6, /* DIABLO */ + DIAG_SUBSYS_TREX = 7, /* TREX - Off-target testing environments */ + DIAG_SUBSYS_GSM = 8, /* GSM */ + DIAG_SUBSYS_UMTS = 9, /* UMTS */ + DIAG_SUBSYS_HWTC = 10, /* HWTC */ + DIAG_SUBSYS_FTM = 11, /* Factory Test Mode */ + DIAG_SUBSYS_REX = 12, /* Rex */ + DIAG_SUBSYS_OS = DIAG_SUBSYS_REX, + DIAG_SUBSYS_GPS = 13, /* Global Positioning System */ + DIAG_SUBSYS_WMS = 14, /* Wireless Messaging Service (WMS, SMS) */ + DIAG_SUBSYS_CM = 15, /* Call Manager */ + DIAG_SUBSYS_HS = 16, /* Handset */ + DIAG_SUBSYS_AUDIO_SETTINGS = 17, /* Audio Settings */ + DIAG_SUBSYS_DIAG_SERV = 18, /* DIAG Services */ + DIAG_SUBSYS_FS = 19, /* File System - EFS2 */ + DIAG_SUBSYS_PORT_MAP_SETTINGS = 20, /* Port Map Settings */ + DIAG_SUBSYS_MEDIAPLAYER = 21, /* QCT Mediaplayer */ + DIAG_SUBSYS_QCAMERA = 22, /* QCT QCamera */ + DIAG_SUBSYS_MOBIMON = 23, /* QCT MobiMon */ + DIAG_SUBSYS_GUNIMON = 24, /* QCT GuniMon */ + DIAG_SUBSYS_LSM = 25, /* Location Services Manager */ + DIAG_SUBSYS_QCAMCORDER = 26, /* QCT QCamcorder */ + DIAG_SUBSYS_MUX1X = 27, /* Multiplexer */ + DIAG_SUBSYS_DATA1X = 28, /* Data */ + DIAG_SUBSYS_SRCH1X = 29, /* Searcher */ + DIAG_SUBSYS_CALLP1X = 30, /* Call Processor */ + DIAG_SUBSYS_APPS = 31, /* Applications */ + DIAG_SUBSYS_SETTINGS = 32, /* Settings */ + DIAG_SUBSYS_GSDI = 33, /* Generic SIM Driver Interface */ + DIAG_SUBSYS_UIMDIAG = DIAG_SUBSYS_GSDI, + DIAG_SUBSYS_TMC = 34, /* Task Main Controller */ + DIAG_SUBSYS_USB = 35, /* Universal Serial Bus */ + DIAG_SUBSYS_PM = 36, /* Power Management */ + DIAG_SUBSYS_DEBUG = 37, + DIAG_SUBSYS_QTV = 38, + DIAG_SUBSYS_CLKRGM = 39, /* Clock Regime */ + DIAG_SUBSYS_DEVICES = 40, + DIAG_SUBSYS_WLAN = 41, /* 802.11 Technology */ + DIAG_SUBSYS_PS_DATA_LOGGING = 42, /* Data Path Logging */ + DIAG_SUBSYS_PS = DIAG_SUBSYS_PS_DATA_LOGGING, + DIAG_SUBSYS_MFLO = 43, /* MediaFLO */ + DIAG_SUBSYS_DTV = 44, /* Digital TV */ + DIAG_SUBSYS_RRC = 45, /* WCDMA Radio Resource Control state */ + DIAG_SUBSYS_PROF = 46, /* Miscellaneous Profiling Related */ + DIAG_SUBSYS_TCXOMGR = 47, + DIAG_SUBSYS_NV = 48, /* Non Volatile Memory */ + DIAG_SUBSYS_AUTOCONFIG = 49, + DIAG_SUBSYS_PARAMS = 50, /* Parameters required for debugging subsystems */ + DIAG_SUBSYS_MDDI = 51, /* Mobile Display Digital Interface */ + DIAG_SUBSYS_DS_ATCOP = 52, + DIAG_SUBSYS_L4LINUX = 53, /* L4/Linux */ + DIAG_SUBSYS_MVS = 54, /* Multimode Voice Services */ + DIAG_SUBSYS_CNV = 55, /* Compact NV */ + DIAG_SUBSYS_APIONE_PROGRAM = 56, /* apiOne */ + DIAG_SUBSYS_HIT = 57, /* Hardware Integration Test */ + DIAG_SUBSYS_DRM = 58, /* Digital Rights Management */ + DIAG_SUBSYS_DM = 59, /* Device Management */ + DIAG_SUBSYS_FC = 60, /* Flow Controller */ + DIAG_SUBSYS_MEMORY = 61, /* Malloc Manager */ + DIAG_SUBSYS_FS_ALTERNATE = 62, /* Alternate File System */ + DIAG_SUBSYS_REGRESSION = 63, /* Regression Test Commands */ + DIAG_SUBSYS_SENSORS = 64, /* The sensors subsystem */ + DIAG_SUBSYS_FLUTE = 65, /* FLUTE */ + DIAG_SUBSYS_ANALOG = 66, /* Analog die subsystem */ + DIAG_SUBSYS_APIONE_PROGRAM_MODEM = 67, /* apiOne Program On Modem Processor */ + DIAG_SUBSYS_LTE = 68, /* LTE */ + DIAG_SUBSYS_BREW = 69, /* BREW */ + DIAG_SUBSYS_PWRDB = 70, /* Power Debug Tool */ + DIAG_SUBSYS_CHORD = 71, /* Chaos Coordinator */ + DIAG_SUBSYS_SEC = 72, /* Security */ + DIAG_SUBSYS_TIME = 73, /* Time Services */ + DIAG_SUBSYS_Q6_CORE = 74, /* Q6 core services */ + DIAG_SUBSYS_COREBSP = 75, /* CoreBSP */ + /* Command code allocation: + [0 - 2047] - HWENGINES + [2048 - 2147] - MPROC + [2148 - 2247] - BUSES + [2248 - 2347] - USB + [2348 - 2447] - FLASH + [2448 - 3447] - UART + [3448 - 3547] - PRODUCTS + [3547 - 65535] - Reserved + */ + + DIAG_SUBSYS_MFLO2 = 76, /* Media Flow */ + /* Command code allocation: + [0 - 1023] - APPs + [1024 - 65535] - Reserved + */ + DIAG_SUBSYS_ULOG = 77, /* ULog Services */ + DIAG_SUBSYS_APR = 78, /* Asynchronous Packet Router (Yu, Andy)*/ + DIAG_SUBSYS_QNP = 79 , /*QNP (Ravinder Are , Arun Harnoor)*/ + DIAG_SUBSYS_STRIDE = 80 , /* Ivailo Petrov */ + DIAG_SUBSYS_OEMDPP = 81 , /* to read/write calibration to DPP partition */ + DIAG_SUBSYS_Q5_CORE = 82 , /* Requested by ADSP team */ + DIAG_SUBSYS_USCRIPT = 83 , /* core/power team USCRIPT tool */ + DIAG_SUBSYS_NAS = 84 , /* Requested by 3GPP NAS team */ + DIAG_SUBSYS_CMAPI = 85 , /* Requested by CMAPI */ + DIAG_SUBSYS_SSM = 86, + DIAG_SUBSYS_TDSCDMA = 87, /* Requested by TDSCDMA team */ + DIAG_SUBSYS_SSM_TEST = 88, + DIAG_SUBSYS_MPOWER = 89, /* Requested by MPOWER team */ + DIAG_SUBSYS_QDSS = 90, /* For QDSS STM commands */ + DIAG_SUBSYS_CXM = 91, + DIAG_SUBSYS_GNSS_SOC = 92, /* Secondary GNSS system */ + DIAG_SUBSYS_TTLITE = 93, + DIAG_SUBSYS_FTM_ANT = 94, + DIAG_SUBSYS_MLOG = 95, + DIAG_SUBSYS_LIMITSMGR = 96, + DIAG_SUBSYS_EFSMONITOR = 97, + DIAG_SUBSYS_DISPLAY_CALIBRATION = 98, + DIAG_SUBSYS_VERSION_REPORT = 99, + DIAG_SUBSYS_DS_IPA = 100, + DIAG_SUBSYS_SYSTEM_OPERATIONS = 101, + DIAG_SUBSYS_CNSS_POWER = 102, + DIAG_SUBSYS_LWIP = 103, + DIAG_SUBSYS_IMS_QVP_RTP = 104, + DIAG_SUBSYS_STORAGE = 105, + DIAG_SUBSYS_WCI2 = 106, + DIAG_SUBSYS_AOSTLM_TEST = 107, + DIAG_SUBSYS_CFCM = 108, + DIAG_SUBSYS_CORE_SERVICES = 109, + DIAG_SUBSYS_CVD = 110, + DIAG_SUBSYS_MCFG = 111, + DIAG_SUBSYS_MODEM_STRESSFW = 112, + DIAG_SUBSYS_LAST, + + /* Subsystem IDs reserved for OEM use */ + DIAG_SUBSYS_RESERVED_OEM_0 = 250, + DIAG_SUBSYS_RESERVED_OEM_1 = 251, + DIAG_SUBSYS_RESERVED_OEM_2 = 252, + DIAG_SUBSYS_RESERVED_OEM_3 = 253, + DIAG_SUBSYS_RESERVED_OEM_4 = 254, + DIAG_SUBSYS_LEGACY = 255 +} diagpkt_subsys_cmd_enum_type; +/*! +@endcond +*/ +#endif /* DIAGCMD_H */ + + + diff --git a/feeds/wifi-ax/qca-diag/src/include/diagi.h b/feeds/wifi-ax/qca-diag/src/include/diagi.h new file mode 100755 index 000000000..e4caa1760 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/diagi.h @@ -0,0 +1,96 @@ +#ifndef DIAGI_H +#define DIAGI_H +/*========================================================================== + + Diagnostic Subsystem Internal Header File + +Description + Shared declarations and prototypes internal to the Diagnostic subsystem. + +# Copyright (c) 2007-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +===========================================================================*/ + + +/*=========================================================================== + + Edit History + +$Header: //depot/asic/msmshared/services/diag/DIAG_7K/diagi.h#1 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 sj Changes for CBSP2.0 +11/21/06 as Moved DIAG internal features from diagi.h to diag.h +08/28/06 as Added win mobile featurization support. +03/28/06 pc Changed DIAG_TX_APP_SIG from 0x00800000 to 0x00080000. +10/19/05 as Modified diag_searchlist_type to make it 4-byte aligned. +07/05/05 sl Added support for SPC_TIMEOUT to double the timeout value + on consecutive incorrect SPCs. +06/16/05 as New signal for DM to communicate completion. +05/17/05 as Added new signal for Application processor data. +10/24/01 jal New signal for SIO to indicate the UART is flushed. + New signal for SIO to indicate port closure is complete. +08/20/01 jal Supported more Diag packets. Added NV cache typedef, + prototypes for diag_set_sp_state(), downloader status. +06/27/01 lad Various non-functional changes to facilitate update of + log services. +04/06/01 lad Added definitions of DIAG_TASK_xxx sigs to decouple from + task.h. + ASYNC con + +/* ------------------------------------------------------------------------- +** Diag Task Signal Definitions +** ------------------------------------------------------------------------- */ +// Added this for CBSP2.0 +typedef enum { /* begin feature_query_enum_type */ + FEATURE_QUERY_ENUM_LENGTH /* used to determine mask size */ +} feature_query_enum_type; + + +/* The shortest length of the mask to cover all entries in the enum */ +#define FEATURE_MASK_LENGTH \ + ((FEATURE_QUERY_ENUM_LENGTH / 8)+1) + + +/* This specifies the last equipment ID for use in logging services. This is a + * 4-bit value, so it cannot exceed 15. */ +#define LOG_EQUIP_ID_LAST LOG_EQUIP_ID_LAST_DEFAULT + + +/* ------------------------------------------------------------------------- +** Externalized data members +** ------------------------------------------------------------------------- */ + + + +/* The following is used by the packet service to store rsp packets. */ +typedef struct { + unsigned int pattern; /* Pattern to check validity of committed pointers. */ + unsigned int size; /* Size of usable buffer (diagpkt_q_type->pkt) */ + unsigned int length; /* Size of packet */ + byte pkt[DIAG_MAX_RX_PKT_SIZ]; /* Sized by 'length' field. */ +} diagpkt_rsp_type; + +#endif /* DIAGI_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/diaglogi.h b/feeds/wifi-ax/qca-diag/src/include/diaglogi.h new file mode 100755 index 000000000..5966360f0 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/diaglogi.h @@ -0,0 +1,203 @@ +#ifndef DIAGLOGI_H +#define DIAGLOGI_H +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Logging Services internal header file + +General Description + Internal declarations to support data logging. + +Initializing and Sequencing Requirements + 'log_init()' must be called once during initialization prior to use. + +# Copyright (c) 2007-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + Edit History + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 sj Changes for CBSP2.0 +01/10/08 mad Added copyright and file description. +12/5/07 as Created + +===========================================================================*/ + + +#include "log_codes.h" +#include "./../include/log.h" +// COMMENTED OUT FOR LINUX +//#include "diagi.h" +/* ------------------------------------------------------------------------- + * Definitions and Declarations + * ------------------------------------------------------------------------- */ +typedef PACK(struct) +{ + uint16 len; /* Specifies the length, in bytes of + the entry, including this header. */ + + uint16 code; /* Specifies the log code for the + entry as enumerated above. + Note: This is specified as word + to guarantee size. */ +// removed AMSS specific code + //qword ts; // The system timestamp for the log entry. The upper 48 bits + // represent elapsed time since 6 Jan 1980 00:00:00 + // in 1.25 ms units. The low order 16 bits represent elapsed + // time since the last 1.25 ms tick in 1/32 chip units + // (this 16 bit counter wraps at the value 49152). + uint32 ts_lo; /* Time stamp */ + uint32 ts_hi; + +} log_header_type; + +#ifndef EQUIP_ID_MAX + #define EQUIP_ID_MAX 16 +#endif + +typedef enum +{ + LOG_INIT_STATE = 0, + LOG_NORMAL_STATE, + LOG_FLUSH_STATE, /* Pending flush operation. */ + LOG_PANIC_STATE /* Panic mode flush in progress */ + +} log_state_enum_type; + +//static log_state_enum_type log_state = LOG_INIT_STATE; +static void *log_commit_last = NULL; /* Many writers, 1 reader (DIAG) */ +//static void *log_flush_last = NULL; /* 1 writer, 1 reader (both DIAG) */ + + +#define LOG_DIAGPKT_OFFSET FPOS(diag_log_rsp_type, log) + +/* ------------------------------------------------------------------------- + * Definitions for last log code per equipment ID. + * If it is undefined, it is defined to 0. digatune.h need only to + * contain values for included equipment IDs. + * ------------------------------------------------------------------------- */ +#if !defined (LOG_EQUIP_ID_0_LAST_CODE) +#define LOG_EQUIP_ID_0_LAST_CODE LOG_EQUIP_ID_0_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_1_LAST_CODE) +#define LOG_EQUIP_ID_1_LAST_CODE LOG_EQUIP_ID_1_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_2_LAST_CODE) +#define LOG_EQUIP_ID_2_LAST_CODE LOG_EQUIP_ID_2_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_3_LAST_CODE) +#define LOG_EQUIP_ID_3_LAST_CODE LOG_EQUIP_ID_3_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_4_LAST_CODE) +#define LOG_EQUIP_ID_4_LAST_CODE LOG_EQUIP_ID_4_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_5_LAST_CODE) +#define LOG_EQUIP_ID_5_LAST_CODE LOG_EQUIP_ID_5_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_6_LAST_CODE) +#define LOG_EQUIP_ID_6_LAST_CODE LOG_EQUIP_ID_6_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_7_LAST_CODE) +#define LOG_EQUIP_ID_7_LAST_CODE LOG_EQUIP_ID_7_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_8_LAST_CODE) +#define LOG_EQUIP_ID_8_LAST_CODE LOG_EQUIP_ID_8_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_9_LAST_CODE) +#define LOG_EQUIP_ID_9_LAST_CODE LOG_EQUIP_ID_9_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_10_LAST_CODE) +#define LOG_EQUIP_ID_10_LAST_CODE LOG_EQUIP_ID_10_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_11_LAST_CODE) +#define LOG_EQUIP_ID_11_LAST_CODE LOG_EQUIP_ID_11_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_12_LAST_CODE) +#define LOG_EQUIP_ID_12_LAST_CODE LOG_EQUIP_ID_12_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_13_LAST_CODE) +#define LOG_EQUIP_ID_13_LAST_CODE LOG_EQUIP_ID_13_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_14_LAST_CODE) +#define LOG_EQUIP_ID_14_LAST_CODE LOG_EQUIP_ID_14_LAST_CODE_DEFAULT +#endif + +#if !defined (LOG_EQUIP_ID_15_LAST_CODE) +#define LOG_EQUIP_ID_15_LAST_CODE LOG_EQUIP_ID_15_LAST_CODE_DEFAULT +#endif + + +/* ------------------------------------------------------------------------- + * Logging mask implementation details. + * + * The logging mask stores a bit for every code within the range specified + * in log_codes.h. Each equipment ID has a mask that is represented + * as an array of bytes. All of this are listed in an array of bytes + * of size 'LOG_MASK_SIZE'. An offset into this array is used to determine + * the start of the mask associated with a particular equipment ID. + * + * The range is inclusive, meaning the beginning (0) and end value + * ('LOG_EQUIP_ID_xxx_LAST_ITEM') are included in the range. Therefore, all + * equipment IDs have at least 1 byte (range 0-0). + * + * 'log_mask' is the mask of bits used to represent the configuration of all + * log codes. '1' denotes the code being enabled, '0' denotes disabled. + * + * 'log_last_item_tbl' is an array of offsets into log_mask indexed by + * equipment ID. + * + * 'LOG_MASK_ARRAY_INDEX()' determine the index into the mask for a given + * equipment ID. + * + * 'LOG_MASK_BIT_MASK()' gives the bit of the code within its byte in the + * mask. + * + * 'LOG_GET_EQUIP_ID()' retuns the equipment ID of a given log code. + * + * 'LOG_GET_ITEM_NUM()' returns the item number of a given log code. + * + * 'log_mask_enabled()' returns non-zero if a code is enabled. + * + * 'log_set_equip_id()' sets the equipment ID in a log code. + * + * ------------------------------------------------------------------------- */ + +#define LOG_MASK_ARRAY_INDEX(xx_item) ((xx_item) >> 3) + +#define LOG_MASK_BIT_MASK(xx_item) (0x01 << ((xx_item) & 7)) + +#define LOG_GET_EQUIP_ID(xx_code) ((((log_code_type) (xx_code)) >> 12) & 0x000F) + +#define LOG_GET_ITEM_NUM(xx_code) (((log_code_type) (xx_code)) & 0x0FFF) + +/* This computes the number of bytes in the log mask array. */ +#define MAX_EQUIP_ID 16 +#define MAX_ITEMS_PER_EQUIP_ID 512 +#define LOG_MASK_ITEM_SIZE (sizeof(uint8) + sizeof(unsigned int) + MAX_ITEMS_PER_EQUIP_ID) +#define LOG_MASK_SIZE (MAX_EQUIP_ID * LOG_MASK_ITEM_SIZE) +#define DCI_LOG_EQUIP_MAX_SIZE (MAX_ITEMS_PER_EQUIP_ID + 2) +#define DCI_LOG_MASK_SIZE (MAX_EQUIP_ID*DCI_LOG_EQUIP_MAX_SIZE) + +typedef PACK(struct) { + uint8 equip_id; + unsigned int num_items; + byte mask[MAX_ITEMS_PER_EQUIP_ID]; +} diag_log_mask_t; + +#endif /* DIAGLOGI_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/diagpkt.h b/feeds/wifi-ax/qca-diag/src/include/diagpkt.h new file mode 100755 index 000000000..51575d1d0 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/diagpkt.h @@ -0,0 +1,759 @@ +#ifndef DIAGPKT_H +#define DIAGPKT_H + +/*========================================================================== + + Diagnostic System Packet Interface + + Description: Interface definitions use the diag packet processing service. + + !!! NOTE: Diagnostic packets are sent over an external interface. + Structure definitions must be portable to other C compilers. The easiest + way to do this is to byte-align the packet definitions. The ARM compiler + uses the PACKED keyword to denote byte alignment. Most other compilers + use #pragma pack(1) to enable structure packing. The structure is not + required to be byte-aligned, but it is required to be portable to other + compilers. + + !!! WARNING: Each command code is part of the externalized diagnostic command + interface. Internally within QCT, these numbers *MUST* be assigned by a + member of QCT's tools development team. 3rd party developers may use the + reserved subsystem IDs to define and grow the diagnostic packet needs. + +# Copyright (c) 2007-2011, 2016 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +===========================================================================*/ + +/* */ + +/*=========================================================================== + + Edit History + + $Header: //depot/asic/msmshared/services/diag/Diag_1.5/Diag_LSM/diagpkt.h#2 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +04/10/08 pc Introduced support for masking events. +12/22/06 as Moved proc ID macros to diag.h +10/31/05 as Fixed lint errors. +12/23/04 ec Added function diagpkt_free() declaration +03/15/04 as Implemented functions to access fields in delayed response + header +12/16/03 as Added new macro to support delayed response. +08/30/02 lad Revised file for multimode diagnostics version. +05/21/01 lad Made diagpkt headers in DIAGPKT macros opaque. + Added FEATURE_DIAG_PACKET_COUPLING to facililitate migration + to this API. +04/17/01 lad Removed inclusion of diagtune.h. + Moved subsystem dispatch IDs to diagcmd.h. +04/06/01 lad Introduced typedefs for command codes, etc. + Updated DIAGPKT_SUBSYS_REQ_DEFINE macros. + Added diagpkt_subsys_alloc(). + Removed diagpkt_process_request() since it is not part of the + externalized interface. +02/23/01 lad Rearchitected the diagnostics subsystem to be a service + rather than a module. All coupling to targets has been + moved to target-specific implementations. This file now + contains an API for packet processing services. + No other information or coupling remains except for + featurized legacy code that impacts existing targets. + Old history comments have been removed since most of them + are no longer applicable. + Packet definitions are no longer included in this file. + +===========================================================================*/ + +#include "diag.h" +/* Max size packet that the DIAG kernel driver allows. +These are additionally defined in diagchar_core.c & diagchar.h */ +#define DIAG_MAX_TX_PKT_SIZ (16*1024) +#define DIAG_MAX_RX_PKT_SIZ (16*1024) +/* ------------------------------------------------------------------------- + Type and Packet Definition Macros + ------------------------------------------------------------------------- */ +typedef uint8 diagpkt_cmd_code_type; +typedef uint8 diagpkt_subsys_id_type; +typedef uint16 diagpkt_subsys_cmd_code_type; +typedef uint32 diagpkt_subsys_status_type; +typedef uint16 diagpkt_subsys_delayed_rsp_id_type; +typedef uint16 diagpkt_subsys_rsp_cnt; + +typedef PACK(struct) +{ + byte opaque_header; +} +diagpkt_header_type; + +typedef PACK(struct) +{ + byte opaque_header[4]; +} +diagpkt_subsys_header_type; + +typedef PACK(struct) +{ + byte opaque_header[12]; +} +diagpkt_subsys_header_v2_type; + + +/* ------------------------------------------------------------------------- + Function Definitions + ------------------------------------------------------------------------- */ +#ifdef __cplusplus +extern "C" +{ +#endif + /* Packet Handler Types */ + + /* An array of this type is created by the client and registered with this + service. It must be declared 'const' (preferrably 'static const'). + The function is called when an inbound packet matches subsystem ID and + is within the command code range specified in the table. */ + typedef struct + { + word cmd_code_lo; + word cmd_code_hi; + void *(*func_ptr) (void *req_pkt_ptr, uint16 pkt_len); + } + diagpkt_user_table_entry_type; + + /* Note: the following 2 items are used internally via the macro below. */ + +/* User table type */ + typedef struct + { uint16 delay_flag; /* 0 means no delay and 1 means with delay */ + uint16 cmd_code; + word subsysid; + word count; + uint16 proc_id; + const diagpkt_user_table_entry_type *user_table; + } diagpkt_user_table_type; + + + +#define DIAGPKT_NO_SUBSYS_ID 0xFF + + void diagpkt_tbl_reg (const diagpkt_user_table_type * tbl_ptr); + + + + /* Use this macro to register your dispatch table with the diagnostics + packet dispatching service. */ + + /* This macro is used to manually register the client table with the + packet dispatch service. This solution is intended to be temporary + pending support for C++ on targets. This macro requires the client + to explicitly register the table. */ + + /* USAGE: For registering diag packet tables on dual processor target, use + the following functions: + For diag packets which are specific to APP's processor use: + DIAGPKT_DISPATCH_TABLE_REGISTER_PROC (DIAG_APP_PROC, DIAG_SUBSYS_XXXX, + XXXX_subsys_tbl_app); + For diag packets which are common to both processor's use: + DIAGPKT_DISPATCH_TABLE_REGISTER_PROC (DIAG_DUAL_PROC, DIAGPKT_SUBSYS_XXXX, + XXXX_common_tbl); + */ +#if defined (IMAGE_APPS_PROC) + #define DIAGPKT_DISPATCH_TABLE_REGISTER(xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 0, 0xFF, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), 1, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + + /* This macro is used if the diag packet has delayed response */ + #define DIAGPKT_DISPATCH_TABLE_REGISTER_V2(xx_cmdcode, xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 0, xx_cmdcode, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), 1, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + + /* This macro is used if the diag packet has delayed response */ + #define DIAGPKT_DISPATCH_TABLE_REGISTER_V2_DELAY(xx_cmdcode, xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 1, xx_cmdcode, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), 1, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + +#else +/* Single processor or modem proc*/ + #define DIAGPKT_DISPATCH_TABLE_REGISTER(xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 0, 0xFF, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), 0, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + + /* This macro is used if the diag packet has delayed response */ + #define DIAGPKT_DISPATCH_TABLE_REGISTER_V2(xx_cmdcode, xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 0, xx_cmdcode, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), 0, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + + /* This macro is used if the diag packet has delayed response */ + #define DIAGPKT_DISPATCH_TABLE_REGISTER_V2_DELAY(xx_cmdcode, xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 1, xx_cmdcode, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), 0, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + +#endif + + #define DIAGPKT_DISPATCH_TABLE_REGISTER_PROC(xx_proc_id, xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 0, 0xFF, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), xx_proc_id, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + + /* This macro is used if the diag packet has delayed response */ + #define DIAGPKT_DISPATCH_TABLE_REGISTER_V2_PROC(xx_proc_id, xx_cmdcode, xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 0, xx_cmdcode, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), xx_proc_id, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + + + /* This macro is used if the diag packet has delayed response */ + #define DIAGPKT_DISPATCH_TABLE_REGISTER_V2_DELAY_PROC(xx_proc_id, xx_cmdcode, xx_subsysid, xx_entry) \ + do { \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 1, xx_cmdcode, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), xx_proc_id, xx_entry \ + }; \ + /*lint -save -e717 */ \ + diagpkt_tbl_reg (&xx_entry##_table); \ + } while (0) + /*lint -restore */ + +#ifdef __cplusplus + /* C++ class used for autoregister */ + class DiagDispatch + { + public: + DiagDispatch (const diagpkt_user_table_type *tbl_ptr) + { + diagpkt_tbl_reg(tbl_ptr); + } + }; + + /* If C++ is supported in the build, this macro, defined in the + preprocessor, instantiates a class with a 'static const' constructor. + This class is therefore instantiated at boot, calling the constructor + prior to the system 'main()'. This eliminates the need to acquire + scope to register, it is done automatically. */ + + #define DIAGPKT_DISPATCH_AUTOREGISTER(xx_subsysid, xx_entry) \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 0, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), xx_entry \ + }; \ + DiagDispatch xx_entry##_instance(&xx_entry##_table) + + /* This macro is used if the diag packet has delayed response */ + + #define DIAGPKT_DISPATCH_AUTOREGISTER_DELAY(xx_subsysid, xx_entry) \ + static const diagpkt_user_table_type xx_entry##_table = { \ + 1, xx_subsysid, sizeof (xx_entry) / sizeof (xx_entry[0]), xx_entry \ + }; \ + DiagDispatch xx_entry##_instance(&xx_entry##_table) + +#endif + + /* ------------------------------------------------------------------------ + Functions + ------------------------------------------------------------------------ */ + +/*=========================================================================== + +FUNCTION DIAGPKT_ALLOC + +DESCRIPTION + This function allocates the specified amount of space in the diag output + buffer. If space is unavailable, access to the allocation buffer will be + blocked using a semaphore until space is available. + +DEPENDENCIES + This may only be called by the diag task for responses to explicit request + packets! This function is *not* re-entrant. If the OS ever supports + semaphores other than INTLOCK, this function can be made re-entrant. + + diagpkt_commit() must be called to commit the response packet to be sent. + Not calling diagpkt_commit() will result in a memory leak. + +============================================================================*/ + void *diagpkt_alloc (diagpkt_cmd_code_type code, unsigned int length); + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_ALLOC + +DESCRIPTION + This call is the same as calling diagpkt_alloc(), but is used for + allocating responses for subsystem commands. It fills in the subsystem + header info for you. + +DEPENDENCIES + This may only be called by the diag task for responses to explicit request + packets! This function is *not* re-entrant. If the OS ever supports + semaphores other than INTLOCK, this function can be made re-entrant. + + diagpkt_commit() must be called to commit the response packet to be sent. + Not calling diagpkt_commit() will result in a memory leak. + +============================================================================*/ + void *diagpkt_subsys_alloc (diagpkt_subsys_id_type id, + diagpkt_subsys_cmd_code_type code, unsigned int length); + + +/*=========================================================================== +FUNCTION DIAGPKT_SUBSYS_ALLOC_V2 + +DESCRIPTION + This function allocates the specified amount of space in the diag output + buffer. If space is unavailable, access to the allocation buffer will be + blocked using a semaphore until space is available. + +DEPENDENCIES + This may only be called by the diag task for responses to explicit request + packets! This function is *not* re-entrant. If the OS ever supports + semaphores other than INTLOCK, this function can be made re-entrant. + + diagpkt_commit() must be called to commit the response packet to be sent. + Not calling diagpkt_commit() will result in a memory leak. +===========================================================================*/ + void *diagpkt_subsys_alloc_v2 (diagpkt_subsys_id_type id, + diagpkt_subsys_cmd_code_type code, unsigned int length); + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_ALLOC_V2_DELAY + +DESCRIPTION + This function allocates the specified amount of space in the diag output + buffer. This function is used to send a delayed response.This response has + same priority as F3 messages and logs. + +DEPENDENCIES + diagpkt_delay_commit() must be called to commit the response packet to be + sent. Not calling diagpkt_delay_commit() will result in a memory leak. + + Note:User is required to provide delayed response id as an argument. + This helps tools to match the delayed response with the original + request response pair. + +===========================================================================*/ + void *diagpkt_subsys_alloc_v2_delay ( + diagpkt_subsys_id_type id, + diagpkt_subsys_cmd_code_type code, + diagpkt_subsys_delayed_rsp_id_type delayed_rsp_id, + unsigned int length); + +/*=========================================================================== + +FUNCTION DIAGPKT_SHORTEN + +DESCRIPTION + This function reduces the length field of a previously allcated buffer. + + 'ptr' must point to the same address that was returned by a prior call to + diagpkt_alloc() or diagpkt_subsys_alloc(). + + Allocating too much and using this to shorten the packet is ideal for + situations in which the length of the packet is not known prior to + allocation. Using this scheme does, however, consume resources that would + otherwise be used to buffer outbound diagnostics data. Please use this + capability sparingly. + +============================================================================*/ + void diagpkt_shorten (void *ptr, unsigned int length); + + +/*=========================================================================== + +FUNCTION DIAGPKT_MASK_TBL_CS_INIT + +DESCRIPTION + This function initializes the mask_tbl_cs mutex variable. +===========================================================================*/ + void diagpkt_mask_tbl_cs_init(void); + + +/*=========================================================================== + +FUNCTION DIAGPKT_MASTER_TBL_CS_INIT + +DESCRIPTION + This function initializes the master_tbl_cs mutex variable. +===========================================================================*/ + void diagpkt_master_tbl_cs_init(void); + + +/*=========================================================================== + +FUNCTION DIAGPKT_COMMIT_DCM + +DESCRIPTION + This function commits previously allocated space in the diagnostics output + buffer. + + 'ptr' must be the same pointer that was returned from diagpkt_alloc() or + diagpkt_subsys_alloc(). + + This function signals the DIAG task and may cause a context switch. + + The packet handler type returns the response pointer. The dispatcher + calls diagpkt_commit() internally. This only needs to be called + explicitly if the packet needs to be committed before the packet handler + returns. In this case, the packet handler should return NULL. + +============================================================================*/ + void diagpkt_commit_dcm (byte *ptr); + + +/*=========================================================================== + +FUNCTION DIAGPKT_COMMIT + +DESCRIPTION + This function commits previously allocated space in the diagnostics output + buffer. + + 'ptr' must be the same pointer that was returned from diagpkt_alloc() or + diagpkt_subsys_alloc(). + + This function signals the DIAG task and may cause a context switch. + + The packet handler type returns the response pointer. The dispatcher + calls diagpkt_commit() internally. This only needs to be called + explicitly if the packet needs to be committed before the packet handler + returns. In this case, the packet handler should return NULL. + +============================================================================*/ + void diagpkt_commit (void *ptr); + +/*=========================================================================== + +FUNCTION DIAGPKT_DELAY_COMMIT + +DESCRIPTION + This function is a wrapper to diagbuf_commit + +===========================================================================*/ + void diagpkt_delay_commit (void *pkt); + + +/*=========================================================================== + +FUNCTION DIAGPKT_GET_CMD_CODE + +DESCRIPTION + This function returns the command code in the specified diagnostics packet. + +===========================================================================*/ + diagpkt_cmd_code_type diagpkt_get_cmd_code (void *ptr); + +/*=========================================================================== + +FUNCTION DIAGPKT_SET_CMD_CODE + +DESCRIPTION + This function sets the command code in the specified diagnostics packet. + +===========================================================================*/ + void diagpkt_set_cmd_code (void *ptr, diagpkt_cmd_code_type cmd_code); + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_GET_ID + +DESCRIPTION + This function returns the subsystem ID in the specified diagnostics packet. + + If the packet is not a DIAG_SUBSYS_CMD_F or DIAG_SUBSYS_CMD_VER_2_F packet, + 0xFFFF is returned. + +===========================================================================*/ + diagpkt_subsys_id_type diagpkt_subsys_get_id (void *ptr); + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_GET_CMD_CODE + +DESCRIPTION + This function returns the subsystem command code in the specified + diagnostics packet. + + If the packet is not a DIAG_SUBSYS_CMD_F or DIAG_SUBSYS_CMD_VER_2_F packet, + 0xFFFF is returned. + +===========================================================================*/ + diagpkt_subsys_cmd_code_type diagpkt_subsys_get_cmd_code (void *ptr); + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_GET_STATUS + +DESCRIPTION + This function gets the status field in the DIAG_SUBSYS_CMD_VER_2_F packet + + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +===========================================================================*/ + diagpkt_subsys_status_type diagpkt_subsys_get_status (void *ptr); + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_SET_STATUS + +DESCRIPTION + This function sets the status field in the DIAG_SUBSYS_CMD_VER_2_F packet. + + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +===========================================================================*/ + void diagpkt_subsys_set_status (void *ptr, + diagpkt_subsys_status_type status); + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_GET_DELAYED_RSP_ID + +DESCRIPTION + This function gets the delayed response ID field in the + DIAG_SUBSYS_CMD_VER_2_F packet. + + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +===========================================================================*/ + diagpkt_subsys_delayed_rsp_id_type diagpkt_subsys_get_delayed_rsp_id + (void *ptr); + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_RESET_DELAYED_RSP_ID + +DESCRIPTION + This function sets the delayed response ID to zero in the + DIAG_SUBSYS_CMD_VER_2_F packet. + + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +===========================================================================*/ + void diagpkt_subsys_reset_delayed_rsp_id (void *ptr); + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_SET_RSP_CNT + +DESCRIPTION + This function sets the response count in the DIAG_SUBSYS_CMD_VER_2_F packet. + + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +===========================================================================*/ + void diagpkt_subsys_set_rsp_cnt (void *ptr, + diagpkt_subsys_rsp_cnt rsp_cnt); + + +/*=========================================================================== + +FUNCTION DIAGPKT_ERR_RSP + +DESCRIPTION + This function builds an error packet. + Usage: rsp_ptr = diagpkt_err_rsp ( error_code, req_pkt ); + +===========================================================================*/ + void *diagpkt_err_rsp (diagpkt_cmd_code_type code, + void *req_ptr, uint16 req_len); + +/*=========================================================================== + +FUNCTION DIAGPKT_ASYNC_BLOCK + +DESCRIPTION + This procedure blocks while we wait for the DIAG_ASYNC_BLOCK_SIG to be set + to allow for asynchronous delays in packet handling. + +============================================================================*/ + void diagpkt_async_block (void); + +/*=========================================================================== + +FUNCTION DIAGPKT_ASYNC_RELEASE + +DESCRIPTION + This procedure sets the DIAG_ASYNC_BLOCK_SIG to end the asynchronous delay + started with DIAGPKT_ASYNC_BLOCK + +============================================================================*/ + void diagpkt_async_release (void); + + + + +/*------------------------------------------------------------- + Diagnostics Packet Type Defintion Macros + + These macros were defined to provide and enforce naming + conventions for declaring packets. However, these macros + make editor tags useless and add consufion. The use of + these macros has been deprecated, but is included here for + compatibility with existing usage. The naming convention + enforced by these macros is not required for use of this + service. + + !!! It is not recommended to continue use of these macros. + + The naming convention enforced by these macros is outlined + below: + + Command codes use the naming convention: DIAG_xxx_F + + Requests types: + DIAG_xxx_F_req_type + + Response types: + DIAG_xxx_F_rsp_type + +-------------------------------------------------------------*/ +#ifndef FEATURE_DIAG_EXPOSED_HEADER +#define DIAGPKT_REQ_DEFINE( xx_cmd_code ) \ + typedef struct xx_cmd_code##_req_tag \ + xx_cmd_code##_req_type; \ + PACK(struct) xx_cmd_code##_req_tag { \ + diagpkt_header_type xx_header; +#else +#define DIAGPKT_REQ_DEFINE( xx_cmd_code ) \ + typedef struct xx_cmd_code##_req_tag \ + xx_cmd_code##_req_type; \ + PACK(struct) xx_cmd_code##_req_tag { \ + diagpkt_cmd_code_type command_code; +#endif + +#define DIAGPKT_REQ_END }; + + /* If the response is the same structure as the request... */ +#define DIAGPKT_DEFINE_RSP_AS_REQ( xx_cmd_code ) \ + typedef xx_cmd_code##_req_type xx_cmd_code##_rsp_type; + +#ifndef FEATURE_DIAG_EXPOSED_HEADER +#define DIAGPKT_RSP_DEFINE( xx_cmd_code ) \ + typedef struct xx_cmd_code##_rsp_tag \ + xx_cmd_code##_rsp_type; \ + PACK(struct) xx_cmd_code##_rsp_tag { \ + diagpkt_header_type xx_header; +#else +#define DIAGPKT_RSP_DEFINE( xx_cmd_code ) \ + typedef struct xx_cmd_code##_rsp_tag \ + xx_cmd_code##_rsp_type; \ + PACK(struct) xx_cmd_code##_rsp_tag { \ + diagpkt_cmd_code_type command_code; +#endif + +#define DIAGPKT_RSP_END }; + +/*------------------------------------------------------------- + Diagnostics Subsystem Packet Type Definition Macros + + These macros were defined to provide and enforce naming + conventions for declaring packets. + + !!! It is not recommended to continue use of these macros. + + The naming convention enforced by these macros is outlined + below: + + Diag has a subsystem command that dispatches diag commands to + various subsystems. All subsystem packet types use the same + naming convention throughout the DMSS. The subsystem command + uses a 16 bit command code per subsystem. This results in + user data starting on a 32 bit boundary. + + The naming convention is as follows: + + Command codes use the naming convnetion: DIAG_SUBSYS_xxx_F + + Requests types: + DIAG_SUBSYS_xxx_yyy_req_type + + Response types: + DIAG_SUBSYS_xxx_yyy_rsp_type + +-------------------------------------------------------------*/ +#define DIAGPKT_SUBSYS_REQ_DEFINE( xx_subsys, xx_subsys_cmd_code ) \ + typedef struct DIAG_SUBSYS_##xx_subsys##_##xx_subsys_cmd_code##_req_tag \ + DIAG_SUBSYS_##xx_subsys##_##xx_subsys_cmd_code##_req_type; \ + PACK(struct) DIAG_SUBSYS_##xx_subsys##_##xx_subsys_cmd_code##_req_tag { \ + diagpkt_subsys_header_type xx_header; + +#define DIAGPKT_SUBSYS_REQ_END }; + +#define DIAGPKT_SUBSYS_RSP_DEFINE( xx_subsys, xx_subsys_cmd_code ) \ + typedef struct DIAG_SUBSYS_##xx_subsys##_##xx_subsys_cmd_code##_rsp_tag \ + DIAG_SUBSYS_##xx_subsys##_##xx_subsys_cmd_code##_rsp_type; \ + PACK(struct) DIAG_SUBSYS_##xx_subsys##_##xx_subsys_cmd_code##_rsp_tag { \ + diagpkt_subsys_header_type xx_header; + +#define DIAGPKT_SUBSYS_RSP_END }; + + +#ifdef FEATURE_DIAG_PACKET_COUPLING + + /* As a temporary measure, this is added since mclog.h expects packet + definitions to be defined in diagpkt.h Once mclog.h is updated, this can + be removed. */ +#include "diagcmd.h" /* mclog.c needs to include this */ +#include "cdma2kdiag.h" +#include "parmdiag.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* DIAGPKT_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/event.h b/feeds/wifi-ax/qca-diag/src/include/event.h new file mode 100755 index 000000000..266531597 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/event.h @@ -0,0 +1,95 @@ +#ifndef EVENT_H +#define EVENT_H + +/*=========================================================================== + + Event Reporting Services + +General Description + All declarations and definitions necessary to support the static + system event reporting service. + +# Copyright (c) 2007-2011 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +===========================================================================*/ + +/*=========================================================================== + Edit History + +$Header: //depot/asic/msmshared/services/diag/Diag_1.5/Diag_LSM/event.h#1 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +01/02/08 mad Added extern "C" modifiers for function declarations +05/14/04 eav Added FEATURE_SAVE_DEBUG_TRACE. Added the function + event_save_circ_buffer_to_efs, which is called from err.c +04/17/01 lad Moved constants to diagtune.h. + Moved event definitions to event_defs.h. +02/23/01 lad Updated API for core diagnostics service. +11/17/00 jal Bit fields in event_id_type came out in inverted order + from what we wanted. Fixed. +11/13/00 lcc Added event and type definitions for some events. +11/10/00 lad Made obsolete event_report_data() a macro to NULL. +11/09/00 jal Took the old event IDs out (again!) +11/07/00 jal Renamed event_extra_data_type to event_payload_type +10/17/00 jal Changes for new event accumulation mechanism +05/15/00 lad Changed truncated timsteamp from uint32 to uint16. +04/11/00 lad Increased # of customer reserved event IDs to 0x100. +12/16/99 lad Added support for event reporting service. +01/21/99 lad Created file. + +===========================================================================*/ + +/* Since the IDs and type definitions are part of the API, include it here */ +#include "event_defs.h" + +/* ------------------------------------------------------------------------- + Function Defintions + ------------------------------------------------------------------------- */ +#ifdef __cplusplus +extern "C" +{ +#endif +/*=========================================================================== + +FUNCTION EVENT_REPORT + +DESCRIPTION + Report an event. + +DEPENDENCIES + Event services must be initialized. + +RETURN VALUE + None. + +SIDE EFFECTS + None. + +===========================================================================*/ +void event_report (event_id_enum_type event_id); + +/*=========================================================================== + +FUNCTION EVENT_REPORT_PAYLOAD + +DESCRIPTION + Report an event with payload data. + +DEPENDENCIES + Event services must be initialized. + +RETURN VALUE + None. + +SIDE EFFECTS + None. + +===========================================================================*/ +void event_report_payload (event_id_enum_type event_id, uint8 length, void *data); + + +#ifdef __cplusplus +} +#endif /* for extern "C" modifier */ +#endif /* EVENT_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/event_defs.h b/feeds/wifi-ax/qca-diag/src/include/event_defs.h new file mode 100755 index 000000000..3f9131c95 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/event_defs.h @@ -0,0 +1,2764 @@ +#ifndef EVENT_DEFS_H +#define EVENT_DEFS_H + +/*! +@ingroup event_service +@file event_defs.h + +@brief +Diagnostic Event Reporting Service ID and Payload Definitions + +@details +This file contains all enumeration constants for event Identifiers +(event_id_enum_type) and the typedefines for event payload structures used by +clients of Diagnostic event reporting service.Please refer to 80-V6196-1 for +details. + +@note +DO NOT MODIFY THIS FILE WITHOUT PRIOR APPROVAL + +Event IDs, by design, are a tightly controlled set of values. Developers +may not create event IDs at will. + +Request new events using the folloiwng process: + + 1. Send email to asw.diag.request requesting event ID assignments. + 2. Identify each event needed by name. + 3. Provide a brief description for each event. + 4. Describe the payload and size, if any. + +*/ + +/*======================================================================= + Copyright (c) 2001-2016 by Qualcomm Technologies, Inc. All Rights Reserved. +===========================================================================*/ + +/*=========================================================================== + Edit History + +$Header: //source/qcom/qct/core/api/services/diag/main/latest/event_defs.h#104 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/14/14 xy Added new events +10/01/14 xy Added new events +08/21/14 xy Added new events +08/04/14 xy Added new events +07/16/14 xy Added new events +06/18/14 xy Added new events +05/27/14 xy Added new events +04/23/14 xy Added new events +03/31/14 xy Added new events +02/25/14 xy Added new events +01/29/14 xy Added new events +01/14/14 xy Added new events +11/13/13 xy Added new events +10/09/13 xy Added new events +09/25/13 xy Added new events +09/09/13 sr Added new events +08/26/13 sr Added new events +08/09/13 sr Added new events +07/30/13 sr Added new events +06/26/13 sr Added new events +05/08/13 sr Added new events +03/12/13 sr Added new events +02/06/13 sr Added new events +01/22/13 sr Added new events +11/27/12 sr Added new events +11/08/12 sr Added new events +10/31/12 sr Added new events +10/15/12 sr Added new events +09/20/12 rh Added new events +08/29/12 rh Added new events +08/08/12 rh Added new events +07/16/12 rh Added new events +06/06/12 rh Added new events +03/26/12 rh Added new events +02/29/12 rh Added new GSM events +02/03/12 rh Added SSR power events +01/12/12 rh Added new events +11/29/11 rh Added new event +09/14/11 hm Added new events +08/19/11 hm Added two new WCDMA events +08/05/11 hm Reserved new event codes for TDSCDMA +06/13/11 hm Added new RRC events +06/10/11 hm Added new event +05/20/11 hm Added new events for Sensors and Geran +04/29/11 hm Added new events +04/25/11 hm Added new events +04/18/11 hm Added new events for LTE and WCDMA +04/05/11 hm Added new events for LTE NAS +03/14/11 hm Added new events for GPS and WCDMA +01/19/11 hm Added new event for LTE ML1 (Tx Power backoff) +10/07/10 sg Added new event for LTE ML1 +05/21/10 sg Doxygenated the file +08/24/09 mad Removed inclusion of customer.h +10/03/08 vg Updated code to use PACK() vs. PACKED +05/21/01 jal Removed the #ifndef FEATURE_DIAG_NO_EVENTS -- this stuff + still needs to be there, even if the service is turned off. +05/21/01 sfh Added EVENT_WCDMA_L1_STATE. +05/21/01 lad Removed version check (now in event.c). +05/08/01 sfh Merged events dropped when branch was made. Added ba + approved HDR events. +04/17/01 lad Created file from event.h. + +===========================================================================*/ + +#include "comdef.h" /* Definitions for byte, word, etc. */ + +/* ------------------------------------------------------------------------- +** Definitions and Declarations +** ------------------------------------------------------------------------- */ + +/*! +@cond DOXYGEN_BLOAT +*/ + +typedef enum +{ + EVENT_DROP_ID = 0, + + EVENT_BAND_CLASS_CHANGE = 0x0100, /* Includes band class as payload */ + EVENT_CDMA_CH_CHANGE = 0x0101, /* Includes cdma channel as payload */ + EVENT_BS_P_REV_CHANGE = 0x0102, /* Includes BS p_rev as payload */ + EVENT_P_REV_IN_USE_CHANGE = 0x0103, /* Includes p_rev_in_use as payload */ + EVENT_SID_CHANGE = 0x0104, /* Includes SID as payload */ + EVENT_NID_CHANGE = 0x0105, /* Includes NID as payload */ + EVENT_PZID_CHANGE = 0x0106, /* Includes PZID as payload */ + EVENT_PDE_SESSION_END = 0x0107, /* No payload */ + EVENT_OP_MODE_CHANGE = 0x0108, /* Includes operation mode as payload */ + EVENT_MESSAGE_RECEIVED = 0x0109, /* Includes channel and message ID as + payload */ + EVENT_MESSAGE_TRANSMITTED = 0x010a, /* Includes channel and message ID as + payload */ + EVENT_TIMER_EXPIRED = 0x010b, /* Includes timer ID as payload */ + EVENT_COUNTER_THRESHOLD =0x10c, /* Includes counter ID as payload */ + EVENT_CALL_PROCESSING_STATE_CHANGE = 0x010d, /* Includes new state and old state as + payload */ + EVENT_CALL_CONTROL_INSTANTIATED = 0x10e, /* Includes con_ref as payload */ + EVENT_CALL_CONTROL_STATE_CHANGE = 0x10f, /* Includes con_ref, old substate and + new substate as payload */ + EVENT_CALL_CONTROL_TERMINATED = 0x0110, /* Includes con_ref as payload */ + EVENT_REG_ZONE_CHANGE = 0x0111, /* Includes reg_zone as payload */ + EVENT_SLOTTED_MODE_OPERATION = 0x0112, /* Includes enter/exit bit as payload */ + EVENT_QPCH_IN_USE, /* Includes enable/disable bit as payload */ + EVENT_IDLE_HANDOFF, /* Includes pn_offset as payload */ + EVENT_ACCESS_HANDOFF, /* Includes pn_offset as payload */ + EVENT_ACCESS_PROBE_HANDOFF, /* Includes pn_offset as payload */ + EVENT_SOFT_HANDOFF, + /* Includes pn_offsets of each BS in aset and indicators whether BS in SCH + aset*/ + EVENT_HARD_HANDOFF_FREQ_CHANGE, + /* Includes pn_offsets of each BS in aset and indicators whether BS in SCH + aset*/ + EVENT_HARD_HANDOFF_FRAME_OFFSET_CHANGE, + /* Includes pn_offsets of each BS in aset and indicators whether BS in SCH + aset*/ + EVENT_HARD_HANDOFF_DISJOINT_ASET, + /* Includes pn_offsets of each BS in aset and indicators whether BS in SCH + aset*/ + EVENT_UNSUCCESSFUL_HARD_HANDOFF, /* No payload */ + EVENT_TMSI_ASSIGNED, /* Includes TMSI as payload */ + EVENT_SERVICE_NEGOTIATION_COMPLETED,/* No payload */ + EVENT_SO_NEGOTIATION_COMPLETED, /* No payload */ + EVENT_ENTER_CONTROL_HOLD_MODE, /* No payload */ + EVENT_EXIT_CONTROL_HOLD_MODE, /* No payload */ + EVENT_START_FWD_SUPP_BURST_ASSGN, /* Includes SCH rate as payload */ + EVENT_END_FWD_SUPP_BURST_ASSGN, /* No payload */ + EVENT_START_REV_SUPP_BURST_ASSGN, /* Includes SCH rate as payload */ + EVENT_END_REV_SUPP_BURST_ASSGN, /* No payload */ + EVENT_DTX, /* No payload */ + EVENT_T_ADD_ABORT, /* No payload */ + EVENT_CH_IND_CHANGE, /* Include ch_ind as payload */ + EVENT_TRANSMITTER_DISABLED, /* No payload */ + EVENT_TRANSMITTER_ENABLED, /* No payload */ + EVENT_SMS_RECEIVED, /* No payload */ + EVENT_SMS_SENT, /* No payload */ + EVENT_INACTIVITY_TIMER_EXPIRED, /* No payload */ + EVENT_DORMANT_TIMER_EXPIRED, /* No payload */ + EVENT_ACCESS_ATTEMPT_FAIL_MAX_PROBES_SENT, /* No payload */ + EVENT_ACCESS_ATTEMPT_FAIL_LOSS_OF_PC_OR_FCCC, /* No payload */ + EVENT_PCH_ACQUIRED, /* Includes pagech and pn_offset + as payload */ + EVENT_BCCH_ACQUIRED, /* Includes walsh code for BCCH and + pn_offset as payload */ + EVENT_FFCH_ACQUIRED, /* Payload: 14 bytes */ + EVENT_FDCCH_ACQUIRED, /* Payload: 14 bytes */ + EVENT_FFCH_PLUS_DCCH_ACQUIRED, /* No payload */ + EVENT_REGISTRATION_PERFORMED, /* Includes reg_type as payload */ + EVENT_NEW_SYSTEM_IDLE_HANDOFF, /* No payload */ + EVENT_SYSTEM_RESELECTION, /* Includes ecio and ps as payload */ + EVENT_RESCAN, /* No payload */ + EVENT_PROTOCOL_MISMATCH, /* No payload */ + EVENT_LOCK, /* No payload */ + EVENT_UNLOCK, /* No payload */ + EVENT_ACCESS_DENIED, /* No payload */ + EVENT_NDSS_OFF, /* No payload */ + EVENT_RELEASE, /* Payload: 1 byte */ + EVENT_ERROR, /* No payload */ + EVENT_REDIRECTION, /* No payload */ + EVENT_REGISTRATION_REJECTED, /* No payload */ + EVENT_WRONG_SYSTEM, /* No payload */ + EVENT_WRONG_NETWORK, /* No payload */ + EVENT_LOSS_OF_ACQ_AFTER_SLEEP, /* No payload */ + EVENT_POWER_DOWN, /* No payload */ + EVENT_CALL_RELEASE_REQUEST, /* No payload */ + EVENT_SERVICE_INACTIVE, /* No payload */ + EVENT_EXTENDED_RELEASE, /* No payload */ + + EVENT_HDR_MSG_RX, /* protocol, msg- 3 bytes */ + EVENT_HDR_RXMSG_IGNORED_STATE, /* protocol, msg- 3 bytes */ + EVENT_HDR_RXMSG_IGNORED_SEQ, /* protocol, msg- 3 bytes */ + EVENT_HDR_TXMSG_ACKED, /* protocol, msg- 3 bytes */ + EVENT_HDR_TXMSG_DROPPED, /* protocol, msg- 3 bytes */ + EVENT_HDR_STATE_CHANGE, /* protocol, from, to - 5 bytes */ + EVENT_HDR_ALMP_OBEYING_REDIRECTION, /* No payload */ + EVENT_HDR_ALMP_CONNECTION_CLOSED, /* No payload */ + EVENT_HDR_ALMP_T_SD_RESELECT, /* No payload */ + EVENT_HDR_ALMP_CONNECTION_OPENED, /* No payload */ + EVENT_HDR_HMP_QUEUED_MSG, /* protocol, msg- 3 bytes */ + EVENT_HDR_HMP_SENT_MSG, /* protocol, msg, chan, is_reliable - 5 bytes */ + EVENT_HDR_HMP_ABORTING_ACMAC_ACTIVATION, /* No payload */ + EVENT_HDR_IDLE_T_CONFIG_RSP, /* No payload */ + EVENT_HDR_IDLE_T_AT_SETUP, /* No payload */ + EVENT_HDR_IDLE_T_SUSPEND, /* No payload */ + EVENT_HDR_IDLE_CONNECTION_DENIED, /* No payload */ + EVENT_HDR_INIT_T_SYNC_ACQ, /* No payload */ + EVENT_HDR_INIT_PROTOCOL_MISMATCH, /* No payload */ + EVENT_HDR_OVHD_INFO_CURRENT, /* No payload */ + EVENT_HDR_OVHD_T_QC_SUPERVISION, /* No payload */ + EVENT_HDR_OVHD_T_SP_SUPERVISION, /* No payload */ + EVENT_HDR_OVHD_T_AP_SUPERVISION, /* No payload */ + EVENT_HDR_OVHD_IGNORED_MSG_UNEXPECTED_LINK, /* msg, exp_link.chan_num, + exp_link.pilot, rx_link.chan_num, + rx_link.pilot - 10 bytes */ + EVENT_HDR_OVHD_IGNORED_SP_MSG_DIFF_SEC_SIG, /* exp_sig, rx_sig - 8 bytes */ + EVENT_HDR_OVHD_IGNORED_AP_MSG_DIFF_ACC_SIG, /* exp_sig, rx_sig - 8 bytes */ + EVENT_HDR_OVHD_IGNORED_SP_MSG_DIFF_SEC_ID, /* No payload */ + EVENT_HDR_OVHD_SP_MSG_RX, /* No payload */ + EVENT_HDR_OVHD_AP_MSG_RX, /* No payload */ + EVENT_HDR_RUP_T_CONNECTION_SETUP, /* No payload */ + EVENT_HDR_SLP_MAX_RETRIES, /* msg - 2 bytes */ + EVENT_HDR_LMAC_ACQ_FAIL_PILOT, /* No payload */ + EVENT_HDR_LMAC_ACQ_SUCCESS, /* No payload */ + EVENT_HDR_LMAC_NETWORK_LOST, /* No payload */ + EVENT_HDR_LMAC_IDLE_HO, /* new_pilot - 2 bytes */ + EVENT_HDR_LMAC_CHAN_CHANGE_COMPLETE, /* No payload */ + EVENT_HDR_LMAC_ACCESS_HO_NEEDED, /* suggested_pilot - 2 bytes */ + EVENT_HDR_LMAC_ACCESS_HO_COMPLETE, /* new_pilot - 2 bytes */ + EVENT_HDR_LMAC_ACQUIRE, /* channel 2 bytes */ + EVENT_HDR_LMAC_CHANGING_CC_HASH, /* cc_hash - 1 byte */ + EVENT_HDR_LMAC_IDLE_CHAN_CHANGE, /* channel - 2 bytes */ + EVENT_HDR_CMAC_T_SUPERVISION, /* No payload */ + EVENT_HDR_AMAC_START_ACCESS, /* No payload */ + EVENT_HDR_AMAC_PROBING_STOPPED, /* No payload */ + EVENT_HDR_AMAC_ACCESS_COMPLETE, /* No payload */ + EVENT_HDR_AMAC_ACCESS_ABORTED, /* No payload */ + EVENT_HDR_AMAC_MAX_PROBES, /* No payload */ + EVENT_HDR_FMAC_DROP_PKT, /* No payload */ + EVENT_HDR_RMAC_T_RATE_LIMIT, /* No payload */ + EVENT_HDR_RMAC_TX_STARTED, /* No payload */ + EVENT_HDR_RMAC_TX_STOPPED, /* No payload */ + EVENT_HDR_SMP_T_KEEP_ALIVE, /* No payload */ + EVENT_HDR_AMP_ASSIGN_MSG_IGNORED_FRESH, /* No payload */ + EVENT_HDR_AMP_T_AT_RESPONSE, /* No payload */ + EVENT_HDR_AMP_T_DUAL_ADDRESS, /* No payload */ + EVENT_HDR_SCP_BEGIN_CONFIGURATION, /* No payload */ + EVENT_HDR_SCP_T_CONFIG_RSP, /* No payload */ + EVENT_HDR_SCP_T_AN_INIT_STATE, /* No payload */ + + EVENT_WCDMA_L1_STATE, /* l1_state - 1 byte */ + EVENT_WCDMA_IMSI, /* IMSI - 9 bytes */ + EVENT_GSM_L1_STATE, /* GSM l1_state - 1 byte */ + EVENT_RANDOM_ACCESS_REQUEST, /* GSM Random Access Request - 4 bytes */ + EVENT_HIGH_LEVEL_CALL_PROCESSING_STATE_CHANGE, /* Puma requested event */ + /* (same payload as CALL_PROCESSING_STATE_CHANGE) */ + EVENT_ENCRYPTION_FAILURE, /* Puma event, no payload */ + EVENT_ACCT_BLOCKED, /* Puma event, no payload */ + EVENT_COMMON_CHANNEL_MONITORED, /* Puma event, 1 byte payload */ + EVENT_SOFT_HANDOFF_V2, /* Puma event, 14 byte payload */ + EVENT_HARD_HANDOFF_FREQ_CHANGE_V2, /* Puma event, 14 byte payload */ + EVENT_HARD_HANDOFF_FRAME_OFFSET_CHANGE_V2, /* Puma event, 14 byte payload */ + EVENT_HARD_HANDOFF_DISJOINT_ASET_V2, /* Puma event, 14 byte payload */ + EVENT_WCDMA_NEW_REFERENCE_CELL, + EVENT_CALL_CONTROL_CONREF_CHANGE, /* Puma event, 2 byte payload */ + + EVENT_GPS_SESSION_BEGIN, + EVENT_GPS_SESSION_END, + EVENT_GPS_WAITING_ON_SA, + EVENT_GPS_PPM_START, + EVENT_GPS_PPM_RESULTS, + EVENT_GPS_PPM_END, + EVENT_GPS_VISIT_BEGIN, + EVENT_GPS_VISIT_END, + EVENT_GPS_CDMA_RESUMED_AFTER_GPS_VISIT, + EVENT_GPS_PD_SESSION_BEGIN, + EVENT_GPS_PD_SESSION_END, /* Payload: 1 byte PDSM substate */ + EVENT_GPS_IS801_RX, /* Payload, 1 byte msg_type */ + EVENT_GPS_IS801_TX, /* Payload: 1 byte msg_type */ + EVENT_POWERUP, + EVENT_WCDMA_ASET, + EVENT_CM_CALL_STATE, /* (1 byte payload: overall call state) */ + EVENT_CM_OPERATIONAL_MODE, /* (1 byte payload: op mode) */ + EVENT_CM_SYSTEM_MODE, /* (1 byte payload: sys_mode) */ + + EVENT_DEEP_SLEEP, /* no payload */ + EVENT_WAKEUP, /* unsigned long (4 bytes) payload */ + EVENT_ACQUISITION_MODE, /* unsigned char (1 byte) payload */ + EVENT_ACQUISITION_TYPE, /* unsigned char (1 byte) payload */ + EVENT_ACP_EXIT, /* unsigned char (1 byte) payload */ + EVENT_CDMA_EXIT, /* unsigned char (1 byte) payload */ + + EVENT_HDR_HYBRID_POWER_SAVE, /* No payload */ + EVENT_HDR_DEEP_SLEEP, /* No payload */ + EVENT_HDR_RESELECTION, /* No payload */ + EVENT_SAM_LOCK_GRANTED, /* 0.01 sec ). + +===========================================================================*/ + void log_commit (void *ptr); + +/*=========================================================================== + +FUNCTION LOG_FREE + +DESCRIPTION + This function frees the buffer in pre-allocated memory. + +DEPENDENCIES + 'ptr' must point to a log entry that was allocated by log_alloc(). + +===========================================================================*/ + void log_free (void *ptr); + +/*=========================================================================== + +FUNCTION LOG_SUBMIT + +DESCRIPTION + This function is called to log an accumlated log entry. If logging is + enabled for the entry by the external device, then the entry is copied + into the diag allocation manager and commited immediately. + + This function essentially does the folliwng: + log = log_alloc (); + memcpy (log, ptr, log->len); + log_commit (log); + + + +RETURN VALUE + Boolean indicating success. + +===========================================================================*/ + boolean log_submit (void *ptr); + +/*=========================================================================== + +FUNCTION LOG_SET_LENGTH + +DESCRIPTION + This function sets the length field in the given log record. + + !!! Use with caution. It is possible to corrupt a log record using this + command. It is intended for use only with accumulated log records, not + buffers returned by log_alloc(). + +===========================================================================*/ + void log_set_length (void *ptr, unsigned int length); + +/*=========================================================================== + +FUNCTION LOG_SET_CODE + +DESCRIPTION + This function sets the logging code in the given log record. + +===========================================================================*/ + void log_set_code (void *ptr, log_code_type code); + +/*=========================================================================== + +FUNCTION LOG_SET_TIMESTAMP + +DESCRIPTION + This function captures the system time and stores it in the given log record. + +===========================================================================*/ + void log_set_timestamp ( +#ifdef FEATURE_ZREX_TIME + void *ptr, log_time_indicator_type time_type +#else + void *ptr +#endif + ); + +/*=========================================================================== + +FUNCTION LOG_GET_LENGTH + +DESCRIPTION + This function returns the length field in the given log record. + + +RETURN VALUE + An unsigned int, the length + +===========================================================================*/ + unsigned int log_get_length (void *ptr); + +/*=========================================================================== + +FUNCTION LOG_GET_CODE + +DESCRIPTION + This function returns the log code field in the given log record. + + + +RETURN VALUE + log_code_type, the code +===========================================================================*/ + log_code_type log_get_code (void *ptr); + +/*=========================================================================== + +FUNCTION LOG_STATUS + +DESCRIPTION + This function returns whether a particular code is enabled for logging. + +===========================================================================*/ + boolean log_status (log_code_type code); + +/*=========================================================================== + +FUNCTION LOG_PROCESS_LSM_MASK_REQ +DESCRIPTION + Handles requests from LSM to transfer the event mask. +============================================================================*/ + +//int log_process_LSM_mask_req (unsigned char* mask, int maskLen, int * maskLenReq); +/* Not required here, not an external API */ + + +/*=========================================================================== + + +NOTE: No function pointer support in diag1.5A. These 2 functions are just stubs + +FUNCTION TYPE LOG_ON_DEMAND + +DESCRIPTION + This function, provided via reference by the caller, indicates a trigger + for the specified log code issued from the external device. This routine + must return status, which is send to the external device. + +DEPENDENCIES + None. + +RETURN VALUE + 'log_on_demand_status_enum_type' + +SIDE EFFECTS + None. + +===========================================================================*/ +typedef enum +{ + LOG_ON_DEMAND_SENT_S = 0, + LOG_ON_DEMAND_ACKNOWLEDGE_S, + LOG_ON_DEMAND_DROPPED_S, + LOG_ON_DEMAND_NOT_SUPPORTED_S, + LOG_ON_DEMAND_FAILED_ATTEMPT_S +} +log_on_demand_status_enum_type; + +typedef log_on_demand_status_enum_type (*log_on_demand) (log_code_type + log_code); + +/*=========================================================================== + +FUNCTION LOG_ON_DEMAND_REGISTER + +DESCRIPTION + This function registers a function pointer to be associated with a + log code for logging on demand. If the external device sends a request + to trigger this log code, the function will be called. The logging + must be performed by the client of this service. It will not be + performed by the logging service itself. + +===========================================================================*/ + boolean log_on_demand_register (log_code_type log_code, + log_on_demand log_on_demand_ptr); + +/*=========================================================================== + +FUNCTION LOG_ON_DEMAND_UNREGISTER + +DESCRIPTION + This function unregisters the log function + +===========================================================================*/ + boolean log_on_demand_unregister (log_code_type log_code); + + +/*=========================================================================== +MACRO LOG_RECORD_DEFINE +MACRO LOG_RECORD_END + +DESCRIPTION + These macros were defined to provide and enforce naming + conventions for declaring packets. However, these macros + make editor tags useless and add consufion. The use of + these macros has been deprecated, but is included here for + compatibility with existing usage. The naming convention + enforced by these macros is not required for use of this + service. + + !!! It is not recommended to continue use of these macros. + + All that is required for defining a log structure is to place + a member of 'log_hdr_type' at the top of the structure. Do not + access this member directly as this type is slated to be type-cast + to 'void' when extending the logging service beyond 16-bit log codes. + + The naming convention enforced by these macros is outlined + below: + + Log codes use the naming convention LOG_xxx_F. + + This macro expands the name of the defined structure to be: + LOG_xxx_C_type + +===========================================================================*/ +#ifdef FEATURE_LOG_EXPOSED_HEADER +#define LOG_RECORD_DEFINE( xx_code ) \ + typedef struct xx_code##_tag xx_code##_type; \ + PACK(struct) xx_code##_tag { \ + log_hdr_type hdr; +#else +#define LOG_RECORD_DEFINE( xx_code ) \ + typedef struct xx_code##_tag xx_code##_type; \ + PACK(struct) xx_code##_tag { \ + log_hdr_type xx_hdr; +#endif + +#define LOG_RECORD_END }; + +#if defined(FEATURE_DIAG_PACKET_COUPLING) + +/* In legacy versions, log.h contains log packet definitions. Those + definitions have been moved to a separate file to isolate coupling. */ +#include "log_dmss.h" + +#endif + + +#ifdef __cplusplus +} +#endif +#endif /* LOG_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/log_codes.h b/feeds/wifi-ax/qca-diag/src/include/log_codes.h new file mode 100755 index 000000000..851ea6129 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/log_codes.h @@ -0,0 +1,2990 @@ +#ifndef LOG_CODES_H +#define LOG_CODES_H + +/*! +@ingroup log_service +@file log_codes.h +@brief +List of all log codes supported. +@details +The log codes are not described in this document, for the sake of brevity. The log codes +enumerated in this file and the associated log payload structures are described in +"CDMA Dual-Mode Subscriber Station Serial Data Interface Control Document", +80-V1294-1. +@par +Log codes, by design, are a tightly controlled set of values. +Developers may not create log codes at will. +*/ + +/*=========================================================================== + + Log Code Definitions + +General Description + This file contains log code definitions and is shared with the tools. + +Copyright (c) 1991-2016 by Qualcomm Technologies, Inc. All Rights Reserved. +===========================================================================*/ + +/* DO NOT MODIFY THIS FILE WITHOUT PRIOR APPROVAL +** +** Log codes, by design, are a tightly controlled set of values. +** Developers may not create log codes at will. +** +** Request new logs using the following process: +** +** 1. Send email to asw.diag.request requesting log codassignmentsG +** 2. Identify the log needed by name. +** 3. Provide a brief description for the log. +** +*/ + +/*=========================================================================== + + Edit History + +$Header: //source/qcom/qct/core/api/services/diag/main/latest/log_codes.h#94 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/14/14 xy Added new log codes +10/01/14 xy Added new log codes +08/21/14 xy Added new log codes +08/04/14 xy Added new log codes +07/16/14 xy Added new log codes +06/18/14 xy Added new log codes +05/27/14 xy Added new log codes +04/24/14 xy Added new log codes +03/31/14 xy Added new log codes +02/25/14 xy Added new log codes +01/29/14 xy Added new log codes +01/14/14 xy Added new log codes +11/13/13 xy Added new log codes +10/09/13 xy Added new log codes +09/25/13 xy Added new log codes +08/26/13 sr Added new log codes +07/30/13 sr Added new log codes +06/26/13 sr Added new log codes +05/28/13 sr Added new log codes +05/08/13 sr Added new log codes +03/22/13 sr Added new log codes +03/12/13 sr Added new log codes +02/06/13 sr Added new log codes +01/22/13 sr Added new log codes +01/02/13 sr Added new log codes +11/08/12 sr Added new log codes +10/23/12 sr Added new log codes +08/30/12 rh Added new log codes +08/28/12 rh Reserved 100 log codes for 1X and DO +08/08/12 rh Added new log codes +07/16/12 rh Added new log codes +06/22/12 rh Added new log codes +03/26/12 rh Created QURT aliases for BLAST log codes. +02/17/12 rh Added LOG_CLKRGM_DRIVER_CLOCKS_C +02/03/12 rh Added new log codes +01/28/12 rh Added new log codes +01/12/12 rh Added new log codes +12/08/11 rh Added new log codes +11/28/11 rh Added new log codes and fixed a couple spelling errors +10/25/11 rh added new log codes +09/14/11 hm Added new log codes +09/01/11 hm Renamed reserved log codes +08/19/11 hm Added new log code +08/05/11 hm Added new log codes +07/19/11 hm Added new log code and renamed log code 0x1544 +07/01/11 hm Added new log codes +05/20/11 hm Added new log code +04/29/11 hm Renamed a log code, kept the old one as it is +04/25/11 hm Added new log codes for QCHAT and sensors +04/06/11 hm Added new log code for Data and Sensors team +03/24/11 hm Added new log codes for QTV and ADSP +03/10/11 hm Added new log codes for GNSS/GPS, Q6 ADSP and Sensors +02/10/11 hm Added Equipment ID for TDSCDMA +02/02/11 hm Added three new log codes for 8660 sensors core +01/26/11 hm Added two new log codes +07/20/10 vs Removed nested comment +06/17/10 mad doxygen document structure change +07/30/09 dhao Consolidate log_codes_apps.h +07/30/09 dhao Add Last log code definition for Equip ID 11 +06/26/09 dhao Update format the macro +06/24/09 sar Reverted last change. +06/24/09 sar Added log code for LOG_MC_STM_C. +11/02/01 sfh Featurize common NAS log codes for UMTS. +10/30/01 sfh Added log code for LOG_GPS_FATPATH_INFO_C. +10/24/01 sfh Added updates for UMTS equipment ID and log codes. +06/27/01 lad Added multiple equipment ID support. +05/22/01 sfh Reserved log codes 158 - 168. +05/21/01 sfh Keep confusing XXX_BASE_C names for backwards compatibility. +05/16/01 sfh Reserved log code 155. +05/08/01 sfh Reserved log codes 150 - 154. +04/06/01 lad Added definitions of base IDs (such as LOG_WCDMA_BASE_C). + This is currently using temporary ID values in the 0x1000 + range. +02/23/01 lad Created file from DMSS log.h. Log codes only + +===========================================================================*/ + +#include "comdef.h" + + + + +/*! +@cond DOXYGEN_BLOAT +*/ + + +/* ------------------------------------------------------------------------- + * Data Declarations + * ------------------------------------------------------------------------- */ + +/* ------------------------------------------------------------------------- + * Log equipment IDs. + * The most significant 4 bits of the 16 bit log code is the equipment ID. + * Orignally, the mobile was to have an ID, and base stations and other + * IDs. As QCT technology diversifies, new equipment IDs are assigned to new + * technology areas. 0x2000 and 0x3000 are reserved for legacy reasons, so + * the first + * addition starts at 0x4000. + * ------------------------------------------------------------------------- */ + +#define LOG_1X_BASE_C ((uint16) 0x1000) +#define LOG_WCDMA_BASE_C ((uint16) 0x4000) +#define LOG_GSM_BASE_C ((uint16) 0x5000) +#define LOG_LBS_BASE_C ((uint16) 0x6000) +#define LOG_UMTS_BASE_C ((uint16) 0x7000) +#define LOG_TDMA_BASE_C ((uint16) 0x8000) +#define LOG_DTV_BASE_C ((uint16) 0xA000) +#define LOG_APPS_BASE_C ((uint16) 0xB000) +#define LOG_LTE_BASE_C ((uint16) (0xB000 + 0x0010)) +#define LOG_LTE_LAST_C ((uint16) 0xB1FF) +#define LOG_WIMAX_BASE_C ((uint16) 0xB400) +#define LOG_DSP_BASE_C ((uint16) 0xC000) +#define LOG_TDSCDMA_BASE_C ((uint16) 0xD000) +#define LOG_TDSCDMA_LAST_C ((uint16) 0xD1FF) + + +#define LOG_TOOLS_BASE_C ((uint16) 0xF000) + +/* LOG_BASE_C is what was used before expanding the use of the equipment ID. + * TODO: Once all targets are using the "core" diag system, this should be + * ommitted. */ +#define LOG_BASE_C LOG_1X_BASE_C + +/* ------------------------------------------------------------------------- + * Log Codes + * These codes identify the kind of information contained in a log entry. + * They are used in conjunction with the 'code' field of the log entry + * header. The data types associated with each code are defined below. + * ------------------------------------------------------------------------- */ + +/* The upper 4 bits of the 16 bit log entry code specify which type + * of equipment created the log entry. */ + +/* 0 Mobile Station temporal analyzer entry */ +#define LOG_TA_C (0x0 + LOG_1X_BASE_C) + +/* 1 AGC values and closed loop power control entry */ +#define LOG_AGC_PCTL_C (0x1 + LOG_1X_BASE_C) + +/* 2 Forward link frame rates and types entry */ +#define LOG_F_MUX1_C (0x2 + LOG_1X_BASE_C) + +/* 3 Reverse link frame rates and types entry */ +#define LOG_R_MUX1_C (0x3 + LOG_1X_BASE_C) + +/* 4 Access channel message entry */ +#define LOG_AC_MSG_C (0x4 + LOG_1X_BASE_C) + +/* 5 Reverse link traffic channel message entry */ +#define LOG_R_TC_MSG_C (0x5 + LOG_1X_BASE_C) + +/* 6 Sync channel message entry */ +#define LOG_SC_MSG_C (0x6 + LOG_1X_BASE_C) + +/* 7 Paging channel message entry */ +#define LOG_PC_MSG_C (0x7 + LOG_1X_BASE_C) + +/* 8 Forward link traffic channel message entry */ +#define LOG_F_TC_MSG_C (0x8 + LOG_1X_BASE_C) + +/* 9 Forward link vocoder packet entry */ +#define LOG_VOC_FOR_C (0x9 + LOG_1X_BASE_C) + +/* 10 Reverse link vocoder packet entry */ +#define LOG_VOC_REV_C (0xA + LOG_1X_BASE_C) + +/* 11 Temporal analyzer finger info only */ +#define LOG_FING_C (0xB + LOG_1X_BASE_C) + +/* 12 Searcher pathlog info (Reused old SRCH logtype) */ +#define LOG_SRCH_C (0xC + LOG_1X_BASE_C) + +/* 13 Position and speed information read from ETAK */ +#define LOG_ETAK_C (0xD + LOG_1X_BASE_C) + +/* 14 Markov frame statistics */ +#define LOG_MAR_C (0xE + LOG_1X_BASE_C) + +/* 15 New and improved temporal analyzer searcher info */ +#define LOG_SRCH2_C (0xF + LOG_1X_BASE_C) + +/* 16 The Fujitsu handset information */ +#define LOG_HANDSET_C (0x10 + LOG_1X_BASE_C) + +/* 17 Vocoder bit error rate mask */ +#define LOG_ERRMASK_C (0x11 + LOG_1X_BASE_C) + +/* 18 Analog voice channel information */ +#define LOG_ANALOG_INFO_C (0x12 + LOG_1X_BASE_C) + +/* 19 Access probe information */ +#define LOG_ACC_INFO_C (0x13 + LOG_1X_BASE_C) + +/* 20 Position & speed info read from GPS receiver */ +#define LOG_GPS_C (0x14 + LOG_1X_BASE_C) + +/* 21 Test Command information */ +#define LOG_TEST_CMD_C (0x15 + LOG_1X_BASE_C) + +/* 22 Sparse (20ms) AGC / closed loop power control entry */ +#define LOG_S_AGC_PCTL_C (0x16 + LOG_1X_BASE_C) + +/* 23 Notification of a band class change */ +#define LOG_BAND_CHANGE_C (0x17 + LOG_1X_BASE_C) + +/* 24 DM debug messages, if being logged via log services */ +#define LOG_DBG_MSG_C (0x18 + LOG_1X_BASE_C) + +/* 25 General temporal analyzer entry */ +#define LOG_GENRL_TA_C (0x19 + LOG_1X_BASE_C) + +/* 26 General temporal analyzer w/supplemental channels */ +#define LOG_GENRL_TA_SUP_CH_C (0x1A + LOG_1X_BASE_C) + +/* Featurization Removal requested by CMI +#ifdef FEATURE_PLT +*/ + +/* 27 Decoder raw bits logging */ +#define LOG_PLT_C (0x1B + LOG_1X_BASE_C) + +/* Featurization Removal requested by CMI +#else +27 EFS Usage Info - No implementation as yet +#define LOG_EFS_INFO_C (0x1B + LOG_1X_BASE_C) +#endif +*/ + +/* 28 Analog Forward Channel */ +#define LOG_ANALOG_FORW_C (0x1C + LOG_1X_BASE_C) + +/* 29 Analog Reverse Channel */ +#define LOG_ANALOG_REVS_C (0x1D + LOG_1X_BASE_C) + +/* 30 Analog Handoff Entry */ +#define LOG_ANALOG_HANDOFF_C (0x1E + LOG_1X_BASE_C) + +/* 31 FM Slot Statistis entry */ +#define LOG_ANALOG_FMSLOT_C (0x1F + LOG_1X_BASE_C) + +/* 32 FOCC Word Sync Count entry */ +#define LOG_ANALOG_WS_COUNT_C (0x20 + LOG_1X_BASE_C) + +/* 33 */ +#define LOG_RLP_PACKET_C (0x21 + LOG_1X_BASE_C) + +/* 34 */ +#define LOG_ASYNC_TCP_SEG_C (0x22 + LOG_1X_BASE_C) + +/* 35 */ +#define LOG_PACKET_DATA_IP_PACKETS_C (0x23 + LOG_1X_BASE_C) + +/* 36 */ +#define LOG_FNBDT_MESSAGE_LOG_C (0x24 + LOG_1X_BASE_C) + +/* Begin IS-2000 LOG features */ + +/* 37 RLP RX Frames logging */ +#define LOG_RLP_RX_FRAMES_C (0x25 + LOG_1X_BASE_C) + +/* 38 RLP TX Frames logging */ +#define LOG_RLP_TX_FRAMES_C (0x26 + LOG_1X_BASE_C) + +/* 39 Reserved for additions to RLP frames */ +#define LOG_RLP_RSVD1_C (0x27 + LOG_1X_BASE_C) + +/* 40 Reserved for additions to RLP frames */ +#define LOG_RLP_RSVD2_C (0x28 + LOG_1X_BASE_C) + +/* 41 Forward Link Frame Types logging */ +#define LOG_FWD_FRAME_TYPES_C (0x29 + LOG_1X_BASE_C) + +/* 42 Reverse Link Frame Types logging */ +#define LOG_REV_FRAME_TYPES_C (0x2A + LOG_1X_BASE_C) + +/* 43 Fast Forward Power Control Parameters logging */ +#define LOG_FFWD_PCTRL_C (0x2B + LOG_1X_BASE_C) + +/* 44 Reverse Power Control Parameters logging */ +#define LOG_REV_PCTRL_C (0x2C + LOG_1X_BASE_C) + +/* 45 Searcher and Finger Information logging */ +#define LOG_SRCH_FING_INFO_C (0x2D + LOG_1X_BASE_C) + +/* 46 Service Configuration logging */ +#define LOG_SVC_CONFIG_C (0x2E + LOG_1X_BASE_C) + +/* 47 Active Set Configuration logging */ +#define LOG_ASET_CONFIG_C (0x2F + LOG_1X_BASE_C) + +/* 48 Quick Paging Channel logging */ +#define LOG_QPCH_C (0x30 + LOG_1X_BASE_C) + +/* 49 RLP Statistics logging */ +#define LOG_RLP_STAT_C (0x31 + LOG_1X_BASE_C) + +/* 50 Simple Test Data Service Option logging */ +#define LOG_STDSO_C (0x32 + LOG_1X_BASE_C) + +/* 51 Pilot Phase Measurement results logging */ +#define LOG_SRCH_PPM_RES_C (0x33 + LOG_1X_BASE_C) + +/* 52 Pilot Phase Measurement Data Base logging */ +#define LOG_SRCH_PPM_DB_C (0x34 + LOG_1X_BASE_C) + +/* 53 Pilot Phase Measurement search results logging */ +#define LOG_SRCH_PPM_C (0x35 + LOG_1X_BASE_C) + +/* 54 IS-801 forward link message */ +#define LOG_GPS_FWD_MSG_C (0x36 + LOG_1X_BASE_C) + +/* 55 IS-801 reverse link message */ +#define LOG_GPS_REV_MSG_C (0x37 + LOG_1X_BASE_C) + +/* 56 GPS search session statistics */ +#define LOG_GPS_STATS_MSG_C (0x38 + LOG_1X_BASE_C) + +/* 57 GPS search results */ +#define LOG_GPS_SRCH_PEAKS_MSG_C (0x39 + LOG_1X_BASE_C) + +/* 58 Factory Testmode logging */ +#define LOG_FTM_C (0x3A + LOG_1X_BASE_C) + +/* 59 Multiple Peak Logging */ +#define LOG_SRCH_GPS_MULTI_PEAKS_INFO_C (0x3B + LOG_1X_BASE_C) + +/* 60 Post processed search results logs */ +#define LOG_SRCH_GPS_POST_PROC_C (0x3C + LOG_1X_BASE_C) + +/* 61 FULL Test Data Service Option logging */ +#define LOG_FTDSO_C (0x3D + LOG_1X_BASE_C) + +/* 62 Bluetooth logging */ +#define LOG_BT_RESERVED_CODES_BASE_C (0x3E + LOG_1X_BASE_C) +/* Keep confusing name for backwards compatibility. */ +#define LOG_BT_BASE_C LOG_BT_RESERVED_CODES_BASE_C + +/* 92 Bluetooth's last log code */ +#define LOG_BT_LAST_C (30 + LOG_BT_RESERVED_CODES_BASE_C) + +/* 93 HDR log codes */ +#define LOG_HDR_RESERVED_CODES_BASE_C (0x5D + LOG_1X_BASE_C) +/* Keep confusing name for backwards compatibility. */ +#define LOG_HDR_BASE_C LOG_HDR_RESERVED_CODES_BASE_C + +/* 143 is HDR's last log code */ +#define LOG_HDR_LAST_C (50 + LOG_HDR_RESERVED_CODES_BASE_C) + +/* 144 IS2000 DCCH Forward link channel */ +#define LOG_FOR_DCCH_MSG_C (0x90 + LOG_1X_BASE_C) +#define LOG_DCCH_FWD_C LOG_FOR_DCCH_MSG_C + +/* 145 IS2000 DCCH Forward link channel */ +#define LOG_REV_DCCH_MSG_C (0x91 + LOG_1X_BASE_C) +#define LOG_DCCH_REV_C LOG_REV_DCCH_MSG_C + +/* 146 IS2000 DCCH Forward link channel */ +#define LOG_ZREX_C (0x92 + LOG_1X_BASE_C) + +/* 147 Active set info logging, similar to ASET_CONFIG, but simpler. */ +#define LOG_ASET_INFO_C (0x93 + LOG_1X_BASE_C) + +/* 148 Pilot Phase Measurement four-shoulder-search resutlts logging */ +#define LOG_SRCH_PPM_4SHOULDER_RES_C (0x94 + LOG_1X_BASE_C) + +/* 149 Extended Pilot Phase Measurement Data Base logging */ +#define LOG_SRCH_EXT_PPM_DB_C (0x95 + LOG_1X_BASE_C) + +/* 150 GPS Visit Parameters */ +#define LOG_GPS_VISIT_PARAMETERS_C (0x96 + LOG_1X_BASE_C) + +/* 151 GPS Measurement */ +#define LOG_GPS_MEASUREMENT_C (0x97 + LOG_1X_BASE_C) + +/* 152 UIM Data */ +#define LOG_UIM_DATA_C (0x98 + LOG_1X_BASE_C) + +/* 153 STDSO plus P2 */ +#define LOG_STDSO_P2_C (0x99 + LOG_1X_BASE_C) + +/* 154 FTDSO plus P2 */ +#define LOG_FTDSO_P2_C (0x9A + LOG_1X_BASE_C) + +/* 155 Search PPM Statistics */ +#define LOG_SRCH_PPM_STATS_C (0x9B + LOG_1X_BASE_C) + +/* 156 PPP Tx Frames */ +#define LOG_PPP_TX_FRAMES_C (0x9C + LOG_1X_BASE_C) + +/* 157 PPP Rx Frames */ +#define LOG_PPP_RX_FRAMES_C (0x9D + LOG_1X_BASE_C) + +/* 158-187 SSL reserved log codes */ +#define LOG_SSL_RESERVED_CODES_BASE_C (0x9E + LOG_1X_BASE_C) +#define LOG_SSL_LAST_C (29 + LOG_SSL_RESERVED_CODES_BASE_C) + +/* 188-199 Puma reserved log codes */ +/* 188 QPCH, version 2 */ +#define LOG_QPCH_VER_2_C (0xBC + LOG_1X_BASE_C) + +/* 189 Enhanced Access Probe */ +#define LOG_EA_PROBE_C (0xBD + LOG_1X_BASE_C) + +/* 190 BCCH Frame Information */ +#define LOG_BCCH_FRAME_INFO_C (0xBE + LOG_1X_BASE_C) + +/* 191 FCCCH Frame Information */ +#define LOG_FCCCH_FRAME_INFO_C (0xBF + LOG_1X_BASE_C) + +/* 192 FDCH Frame Information */ +#define LOG_FDCH_FRAME_INFO_C (0xC0 + LOG_1X_BASE_C) + +/* 193 RDCH Frame Information */ +#define LOG_RDCH_FRAME_INFO_C (0xC1 + LOG_1X_BASE_C) + +/* 194 FFPC Information */ +#define LOG_FFPC_INFO_C (0xC2 + LOG_1X_BASE_C) + +/* 195 RPC Information */ +#define LOG_RPC_INFO_C (0xC3 + LOG_1X_BASE_C) + +/* 196 Searcher and Finger Information */ +#define LOG_SRCH_FING_INFO_VER_2_C (0xC4 + LOG_1X_BASE_C) + +/* 197 Service Configuration, version 2 */ +#define LOG_SRV_CONFIG_VER_2_C (0xC5 + LOG_1X_BASE_C) + +/* 198 Active Set Information, version 2 */ +#define LOG_ASET_INFO_VER_2_C (0xC6 + LOG_1X_BASE_C) + +/* 199 Reduced Active Set */ +#define LOG_REDUCED_ASET_INFO_C (0xC7 + LOG_1X_BASE_C) + +/* 200 Search Triage Info */ +#define LOG_SRCH_TRIAGE_INFO_C (0xC8 + LOG_1X_BASE_C) + +/* 201 RDA Frame Information */ +#define LOG_RDA_FRAME_INFO_C (0xC9 + LOG_1X_BASE_C) + +/* 202 gpsOne fatpath information */ +#define LOG_GPS_FATPATH_INFO_C (0xCA + LOG_1X_BASE_C) + +/* 203 Extended AGC */ +#define LOG_EXTENDED_AGC_C (0xCB + LOG_1X_BASE_C) + +/* 204 Transmit AGC */ +#define LOG_TRANSMIT_AGC_C (0xCC + LOG_1X_BASE_C) + +/* 205 I/Q Offset registers */ +#define LOG_IQ_OFFSET_REGISTERS_C (0xCD + LOG_1X_BASE_C) + +/* 206 DACC I/Q Accumulator registers */ +#define LOG_DACC_IQ_ACCUMULATOR_C (0xCE + LOG_1X_BASE_C) + +/* 207 Register polling results */ +#define LOG_REGISTER_POLLING_RESULTS_C (0xCF + LOG_1X_BASE_C) + +/* 208 System arbitration module */ +#define LOG_AT_SAM_C (0xD0 + LOG_1X_BASE_C) + +/* 209 Diablo searcher finger log */ +#define LOG_DIABLO_SRCH_FING_INFO_C (0xD1 + LOG_1X_BASE_C) + +/* 210 log reserved for dandrus */ +#define LOG_SD20_LAST_ACTION_C (0xD2 + LOG_1X_BASE_C) + +/* 211 log reserved for dandrus */ +#define LOG_SD20_LAST_ACTION_HYBRID_C (0xD3 + LOG_1X_BASE_C) + +/* 212 log reserved for dandrus */ +#define LOG_SD20_SS_OBJECT_C (0xD4 + LOG_1X_BASE_C) + +/* 213 log reserved for dandrus */ +#define LOG_SD20_SS_OBJECT_HYBRID_C (0xD5 + LOG_1X_BASE_C) + +/* 214 log reserved for jpinos */ +#define LOG_BCCH_SIGNALING_C (0xD6 + LOG_1X_BASE_C) + +/* 215 log reserved for jpinos */ +#define LOG_REACH_SIGNALING_C (0xD7 + LOG_1X_BASE_C) + +/* 216 log reserved for jpinos */ +#define LOG_FCCCH_SIGNALING_C (0xD8 + LOG_1X_BASE_C) + +/* 217 RDA Frame Information 2 */ +#define LOG_RDA_FRAME_INFO_2_C (0xD9 + LOG_1X_BASE_C) + +/* 218 */ +#define LOG_GPS_BIT_EDGE_RESULTS_C (0xDA + LOG_1X_BASE_C) + +/* 219 */ +#define LOG_PE_DATA_C (0xDB + LOG_1X_BASE_C) + +/* 220 */ +#define LOG_PE_PARTIAL_DATA_C (0xDC + LOG_1X_BASE_C) + +/* 221 */ +#define LOG_GPS_SINGLE_PEAK_SRCH_RESULTS_C (0xDD + LOG_1X_BASE_C) + +/* 222 */ +#define LOG_SRCH4_SAMPRAM_C (0xDE + LOG_1X_BASE_C) + +/* 223 */ +#define HDR_AN_PPP_TX_FRAMES (0xDF + LOG_1X_BASE_C) + +/* 224 */ +#define HDR_AN_PPP_RX_FRAMES (0xE0 + LOG_1X_BASE_C) + +/* 225 */ +#define LOG_GPS_SCHEDULER_TRACE_C (0xE1 + LOG_1X_BASE_C) + +/* 226 */ +#define LOG_MPEG4_YUV_FRAME_C (0xE2 + LOG_1X_BASE_C) + +/* 227 */ +#define LOG_MPEG4_CLIP_STATS_C (0xE3 + LOG_1X_BASE_C) + +/* 228 */ +#define LOG_MPEG4_CLIP_STATS_VER2_C (0xE4 + LOG_1X_BASE_C) + +/* 226-241 MMEG reserved. */ +#define LOG_MPEG_RESERVED_CODES_BASE_C (0xF1 + LOG_1X_BASE_C) + +/* 242-274 BREW reserved log range */ +#define LOG_BREW_RESERVED_CODES_BASE_C (0xF2 + LOG_1X_BASE_C) +#define LOG_BREW_LAST_C (32 + LOG_BREW_RESERVED_CODES_BASE_C) + +/* 275-339 PPP Extended Frames */ +#define LOG_PPP_FRAMES_RESERVED_CODES_BASE_C (0x113 + LOG_1X_BASE_C) +#define LOG_PPP_FRAMES_LAST_C (64 + LOG_PPP_FRAMES_RESERVED_CODES_BASE_C) + +#define LOG_PPP_EXT_FRAMED_RX_UM_C (0x113 + LOG_1X_BASE_C) +#define LOG_PPP_EXT_FRAMED_RX_RM_C (0x114 + LOG_1X_BASE_C) +#define LOG_PPP_EXT_FRAMED_RX_AN_C (0x115 + LOG_1X_BASE_C) + +#define LOG_PPP_EXT_FRAMED_TX_UM_C (0x123 + LOG_1X_BASE_C) +#define LOG_PPP_EXT_FRAMED_TX_RM_C (0x124 + LOG_1X_BASE_C) +#define LOG_PPP_EXT_FRAMED_TX_AN_C (0x125 + LOG_1X_BASE_C) + +#define LOG_PPP_EXT_UNFRAMED_RX_UM_C (0x133 + LOG_1X_BASE_C) +#define LOG_PPP_EXT_UNFRAMED_RX_RM_C (0x134 + LOG_1X_BASE_C) +#define LOG_PPP_EXT_UNFRAMED_RX_AN_C (0x135 + LOG_1X_BASE_C) + +#define LOG_PPP_EXT_UNFRAMED_TX_UM_C (0x143 + LOG_1X_BASE_C) +#define LOG_PPP_EXT_UNFRAMED_TX_RM_C (0x144 + LOG_1X_BASE_C) +#define LOG_PPP_EXT_UNFRAMED_TX_AN_C (0x145 + LOG_1X_BASE_C) + +/* 340 LOG_PE_DATA_EXT_C */ +#define LOG_PE_DATA_EXT_C (0x154 + LOG_1X_BASE_C) + +/* REX Subsystem logs */ +#define LOG_MEMDEBUG_C (0x155 + LOG_1X_BASE_C) +#define LOG_SYSPROFILE_C (0x156 + LOG_1X_BASE_C) +#define LOG_TASKPROFILE_C (0x157 + LOG_1X_BASE_C) +#define LOG_COREDUMP_C (0x158 + LOG_1X_BASE_C) + +/* 341-349 REX subsystem logs */ +#define LOG_REX_RESERVED_CODES_BASE_C (0x155 + LOG_1X_BASE_C) +#define LOG_REX_LAST_C (8 + LOG_REX_RESERVED_CODES_BASE_C) + +/* 350 LOG_PE_PARTIAL_DATA_EXT_C */ +#define LOG_PE_PARTIAL_DATA_EXT_C (0x15E + LOG_1X_BASE_C) + +/* 351 LOG_DIAG_STRESS_TEST_C */ +#define LOG_DIAG_STRESS_TEST_C (0x15F + LOG_1X_BASE_C) + +/* 352 LOG_WMS_READ_C */ +#define LOG_WMS_READ_C (0x160 + LOG_1X_BASE_C) + +/* 353 Search Triage Info Version 2 */ +#define LOG_SRCH_TRIAGE_INFO2_C (0x161 + LOG_1X_BASE_C) + +/* 354 RLP Rx FDCH Frames */ +#define LOG_RLP_RX_FDCH_FRAMES_C (0x162 + LOG_1X_BASE_C) + + +/* 355 RLP Tx FDCH Frames */ +#define LOG_RLP_TX_FDCH_FRAMES_C (0x163 + LOG_1X_BASE_C) + +/* 356-371 QTV subsystem logs */ +#define LOG_QTV_RESERVED_CODES_BASE_C (0x164 + LOG_1X_BASE_C) +#define LOG_QTV_LAST_C (15 + LOG_QTV_RESERVED_CODES_BASE_C) + +/* 372 Searcher 4 1X */ +#define LOG_SRCH4_1X_C (0x174 + LOG_1X_BASE_C) + +/* 373 Searcher sleep statistics */ +#define LOG_SRCH_SLEEP_STATS_C (0x175 + LOG_1X_BASE_C) + +/* 374 Service Configuration, version 3 */ +#define LOG_SRV_CONFIG_VER_3_C (0x176 + LOG_1X_BASE_C) + +/* 375 Searcher 4 HDR */ +#define LOG_SRCH4_HDR_C (0x177 + LOG_1X_BASE_C) + +/* 376 Searcher 4 AFLT */ +#define LOG_SRCH4_AFLT_C (0x178 + LOG_1X_BASE_C) + +/* 377 Enhanced Finger Information */ +#define LOG_ENH_FING_INFO_C (0x179 + LOG_1X_BASE_C) + +/* 378 DV Information */ +#define LOG_DV_INFO_C (0x17A + LOG_1X_BASE_C) + +/* 379 WMS set routes information */ +#define LOG_WMS_SET_ROUTES_C (0x17B + LOG_1X_BASE_C) + +/* 380 FTM Version 2 Logs */ +#define LOG_FTM_VER_2_C (0x17C + LOG_1X_BASE_C) + +/* 381 GPS Multipeak logging */ +#define LOG_SRCH_GPS_MULTI_PEAKS_SIMPLIFIED_INFO_C (0x17D + LOG_1X_BASE_C) + +/* 382 GPS Multipeak logging */ +#define LOG_SRCH_GPS_MULTI_PEAKS_VERBOSE_INFO_C (0x17E + LOG_1X_BASE_C) + +/* 383-403 HDR reserved logs */ +#define LOG_HDR_RESERVED_CODES_BASE_2_C (0x17F + LOG_1X_BASE_C) +#define LOG_HDR_LAST_2_C (20 + LOG_HDR_RESERVED_CODES_BASE_2_C) + +/* RLP Rx - PDCH partial MuxPDU5 frames */ +#define LOG_RLP_RX_PDCH_PARTIAL_MUXPDU5_FRAMES_C (0x194 + LOG_1X_BASE_C) + +/* RLP Tx - PDCH partial MuxPDU5 frames */ +#define LOG_RLP_TX_PDCH_PARTIAL_MUXPDU5_FRAMES_C (0x195 + LOG_1X_BASE_C) + +/* RLP Rx internal details */ +#define LOG_RLP_RX_INTERNAL_DETAILS_C (0x196 + LOG_1X_BASE_C) + +/* RLP Tx internal details */ +#define LOG_RLP_TX_INTERNAL_DETAILS_C (0x197 + LOG_1X_BASE_C) + +/* MPEG4 Clip Statistics version 3 */ +#define LOG_MPEG4_CLIP_STATS_VER3_C (0x198 + LOG_1X_BASE_C) + +/* Mobile IP Performance */ +#define LOG_MOBILE_IP_PERFORMANCE_C (0x199 + LOG_1X_BASE_C) + +/* 410-430 Searcher reserved logs */ +#define LOG_SEARCHER_RESERVED_CODES_BASE_C (0x19A + LOG_1X_BASE_C) +#define LOG_SEARCHER_LAST_2_C (21 + LOG_SEARCHER_RESERVED_CODES_BASE_C) + +/* 432-480 QTV reserved logs */ +#define LOG_QTV2_RESERVED_CODES_BASE_C (0x1B0 + LOG_1X_BASE_C) +#define LOG_QTV2_LAST_C (48 + LOG_QTV2_RESERVED_CODES_BASE_C) + +#define LOG_QTV_PDS2_STATS (0x1B6 + LOG_1X_BASE_C) +#define LOG_QTV_PDS2_GET_REQUEST (0x1B7 + LOG_1X_BASE_C) +#define LOG_QTV_PDS2_GET_RESP_HEADER (0x1B8 + LOG_1X_BASE_C) +#define LOG_QTV_PDS2_GET_RESP_PCKT (0x1B9 + LOG_1X_BASE_C) +#define LOG_QTV_CMX_AUDIO_INPUT_DATA_C (0x1BA + LOG_1X_BASE_C) +#define LOG_QTV_RTSP_OPTIONS_C (0x1BB + LOG_1X_BASE_C) +#define LOG_QTV_RTSP_GET_PARAMETER_C (0x1BC + LOG_1X_BASE_C) +#define LOG_QTV_RTSP_SET_PARAMETER_C (0x1BD + LOG_1X_BASE_C) +#define LOG_QTV_VIDEO_BITSTREAM (0x1BE + LOG_1X_BASE_C) +#define LOG_ARM_VIDEO_DECODE_STATS (0x1BF + LOG_1X_BASE_C) +#define LOG_QTV_DSP_SLICE_BUFFER_C (0x1C0 + LOG_1X_BASE_C) +#define LOG_QTV_CMD_LOGGING_C (0x1C1 + LOG_1X_BASE_C) +#define LOG_QTV_AUDIO_FRAME_PTS_INFO_C (0x1C2 + LOG_1X_BASE_C) +#define LOG_QTV_VIDEO_FRAME_DECODE_INFO_C (0x1C3 + LOG_1X_BASE_C) +#define LOG_QTV_RTCP_COMPOUND_RR_C (0x1C4 + LOG_1X_BASE_C) +#define LOG_QTV_FRAME_BUFFER_RELEASE_REASON_C (0x1C5 + LOG_1X_BASE_C) +#define LOG_QTV_AUDIO_CHANNEL_SWITCH_FRAME_C (0x1C6 + LOG_1X_BASE_C) +#define LOG_QTV_RTP_DECRYPTED_PKT_C (0x1C7 + LOG_1X_BASE_C) +#define LOG_QTV_PCR_DRIFT_RATE_C (0x1C8 + LOG_1X_BASE_C) + +/* GPS PDSM logs */ +#define LOG_PDSM_POSITION_REPORT_CALLBACK_C (0x1E1 + LOG_1X_BASE_C) +#define LOG_PDSM_PD_EVENT_CALLBACK_C (0x1E2 + LOG_1X_BASE_C) +#define LOG_PDSM_PA_EVENT_CALLBACK_C (0x1E3 + LOG_1X_BASE_C) +#define LOG_PDSM_NOTIFY_VERIFY_REQUEST_C (0x1E4 + LOG_1X_BASE_C) +#define LOG_PDSM_RESERVED1_C (0x1E5 + LOG_1X_BASE_C) +#define LOG_PDSM_RESERVED2_C (0x1E6 + LOG_1X_BASE_C) + +/* Searcher Demodulation Status log */ +#define LOG_SRCH_DEMOD_STATUS_C (0x1E7 + LOG_1X_BASE_C) + +/* Searcher Call Statistics log */ +#define LOG_SRCH_CALL_STATISTICS_C (0x1E8 + LOG_1X_BASE_C) + +/* GPS MS-MPC Forward link */ +#define LOG_MS_MPC_FWD_LINK_C (0x1E9 + LOG_1X_BASE_C) + +/* GPS MS-MPC Reverse link */ +#define LOG_MS_MPC_REV_LINK_C (0x1EA + LOG_1X_BASE_C) + +/* Protocol Services Data */ +#define LOG_DATA_PROTOCOL_LOGGING_C (0x1EB + LOG_1X_BASE_C) + +/* MediaFLO reserved log codes */ +#define LOG_MFLO_RESERVED_CODES_BASE_C (0x1EC + LOG_1X_BASE_C) +#define LOG_MFLO_LAST_C (99 + LOG_MFLO_RESERVED_CODES_BASE_C) + +/* GPS demodulation tracking header info */ +#define LOG_GPS_DEMOD_TRACKING_HEADER_C (0x250 + LOG_1X_BASE_C) + +/* GPS demodulation tracking results */ +#define LOG_GPS_DEMOD_TRACKING_C (0x251 + LOG_1X_BASE_C) + +/* GPS bit edge logs from demod tracking */ +#define LOG_GPS_DEMOD_BIT_EDGE_C (0x252 + LOG_1X_BASE_C) + +/* GPS demodulation soft decisions */ +#define LOG_GPS_DEMOD_SOFT_DECISIONS_C (0x253 + LOG_1X_BASE_C) + +/* GPS post-processed demod tracking results */ +#define LOG_GPS_DEMOD_TRACKING_POST_PROC_C (0x254 + LOG_1X_BASE_C) + +/* GPS subframe log */ +#define LOG_GPS_DEMOD_SUBFRAME_C (0x255 + LOG_1X_BASE_C) + +/* F-CPCCH Quality Information */ +#define LOG_F_CPCCH_QUALITY_INFO_C (0x256 + LOG_1X_BASE_C) + +/* Reverse PDCCH/PDCH Frame Information */ +#define LOG_R_PDCCH_R_PDCH_FRAME_INFO_C (0x257 + LOG_1X_BASE_C) + +/* Forward G Channel Information */ +#define LOG_F_GCH_INFO_C (0x258 + LOG_1X_BASE_C) + +/* Forward G Channel Frame Information */ +#define LOG_F_GCH_FRAME_INFO_C (0x259 + LOG_1X_BASE_C) + +/* Forward RC Channel Information */ +#define LOG_F_RCCH_INFO_C (0x25A + LOG_1X_BASE_C) + +/* Forward ACK Channel Information */ +#define LOG_F_ACKCH_INFO_C (0x25B + LOG_1X_BASE_C) + +/* Forward ACK Channel ACKDA Information */ +#define LOG_F_ACKCH_ACKDA_C (0x25C + LOG_1X_BASE_C) + +/* Reverse REQ Channel Information */ +#define LOG_R_REQCH_INFO_C (0x25D + LOG_1X_BASE_C) + +/* Sleep Task Statistics */ +#define LOG_SLEEP_STATS_C (0x25E + LOG_1X_BASE_C) + +/* Sleep controller statistics 1X */ +#define LOG_1X_SLEEP_CONTROLLER_STATS_C (0x25F + LOG_1X_BASE_C) + +/* Sleep controller statistics HDR */ +#define LOG_HDR_SLEEP_CONTROLLER_STATS_C (0x260 + LOG_1X_BASE_C) + +/* Sleep controller statistics GSM */ +#define LOG_GSM_SLEEP_CONTROLLER_STATS_C (0x261 + LOG_1X_BASE_C) + +/* Sleep controller statistics WCDMA */ +#define LOG_WCDMA_SLEEP_CONTROLLER_STATS_C (0x262 + LOG_1X_BASE_C) + +/* Sleep task and controller reserved logs */ +#define LOG_SLEEP_APPS_STATS_C (0x263 + LOG_1X_BASE_C) +#define LOG_SLEEP_STATS_RESERVED2_C (0x264 + LOG_1X_BASE_C) +#define LOG_SLEEP_STATS_RESERVED3_C (0x265 + LOG_1X_BASE_C) + +/* DV Information placeholder channel logs */ +#define LOG_PDCCH_LO_SELECTED_C (0x266 + LOG_1X_BASE_C) +#define LOG_PDCCH_HI_SELECTED_C (0x267 + LOG_1X_BASE_C) +#define LOG_WALSH_SELECTED_C (0x268 + LOG_1X_BASE_C) +#define LOG_PDCH_BE_SELECTED_C (0x269 + LOG_1X_BASE_C) +#define LOG_PDCCH_LLR_SELECTED_C (0x26A + LOG_1X_BASE_C) +#define LOG_CQI_ACK_LO_SELECTED_C (0x26B + LOG_1X_BASE_C) +#define LOG_CQI_ACK_HI_SELECTED_C (0x26C + LOG_1X_BASE_C) +#define LOG_RL_GAIN_SELECTED_C (0x26D + LOG_1X_BASE_C) +#define LOG_PDCCH0_SNDA_SELECTED_C (0x26E + LOG_1X_BASE_C) +#define LOG_PDCCH1_SNDA_SELECTED_C (0x26F + LOG_1X_BASE_C) + +/* 624 WMS Message List */ +#define LOG_WMS_MESSAGE_LIST_C (0x270 + LOG_1X_BASE_C) + +/* 625 Multimode Generic SIM Driver Interface */ +#define LOG_MM_GENERIC_SIM_DRIVER_C (0x271 + LOG_1X_BASE_C) + +/* 626 Generic SIM Toolkit Task */ +#define LOG_GENERIC_SIM_TOOLKIT_TASK_C (0x272 + LOG_1X_BASE_C) + +/* 627 Call Manager Phone events log */ +#define LOG_CM_PH_EVENT_C (0x273 + LOG_1X_BASE_C) + +/* 628 WMS Set Message List */ +#define LOG_WMS_SET_MESSAGE_LIST_C (0x274 + LOG_1X_BASE_C) + +/* 629-704 HDR reserved logs */ +#define LOG_HDR_RESERVED_CODES_BASE_3_C (0x275 + LOG_1X_BASE_C) +#define LOG_HDR_LAST_3_C (75 + LOG_HDR_RESERVED_CODES_BASE_3_C) + +#define LOG_HDR_TUNEAWAY_INFO_C (0x2C0 + LOG_1X_BASE_C) +/* 705 Call Manager call event log */ +#define LOG_CM_CALL_EVENT_C (0x2C1 + LOG_1X_BASE_C) + +/* 706-738 QVP reserved logs */ +#define LOG_QVP_RESERVED_CODES_BASE_C (0x2C2 + LOG_1X_BASE_C) +#define LOG_QVP_LAST_C (32 + LOG_QVP_RESERVED_CODES_BASE_C) + +/* 739 GPS PE Position Report log */ +#define LOG_GPS_PE_POSITION_REPORT_C (0x2E3 + LOG_1X_BASE_C) + +/* 740 GPS PE Position Report Extended log */ +#define LOG_GPS_PE_POSITION_REPORT_EXT_C (0x2E4 + LOG_1X_BASE_C) + +/* 741 log */ +#define LOG_MDDI_HOST_STATS_C (0x2E5 + LOG_1X_BASE_C) + +/* GPS Decoded Ephemeris */ +#define LOG_GPS_DECODED_EPHEMERIS_C (0x2E6 + LOG_1X_BASE_C) + +/* GPS Decoded Almanac */ +#define LOG_GPS_DECODED_ALMANAC_C (0x2E7 + LOG_1X_BASE_C) + +/* Transceiver Resource Manager */ +#define LOG_TRANSCEIVER_RESOURCE_MGR_C (0x2E8 + LOG_1X_BASE_C) + +/* GPS Position Engine Info */ +#define LOG_GPS_POSITION_ENGINE_INFO_C (0x2E9 + LOG_1X_BASE_C) + +/* 746-810 RAPTOR reserved log range */ +#define LOG_RAPTOR_RESERVED_CODES_BASE_C (0x2EA + LOG_1X_BASE_C) +#define LOG_RAPTOR_LAST_C (64 + LOG_RAPTOR_RESERVED_CODES_BASE_C) + +/* QOS Specification Logging */ + +/* QOS Requested Log */ +#define LOG_QOS_REQUESTED_C (0x32B + LOG_1X_BASE_C) + +/* QOS Granted Log */ +#define LOG_QOS_GRANTED_C (0x32C + LOG_1X_BASE_C) + +/* QOS State Log */ +#define LOG_QOS_STATE_C (0x32D + LOG_1X_BASE_C) + +#define LOG_QOS_MODIFIED_C (0x32E + LOG_1X_BASE_C) + +#define LOG_QDJ_ENQUEUE_C (0x32F + LOG_1X_BASE_C) +#define LOG_QDJ_DEQUEUE_C (0x330 + LOG_1X_BASE_C) +#define LOG_QDJ_UPDATE_C (0x331 + LOG_1X_BASE_C) +#define LOG_QDTX_ENCODER_C (0x332 + LOG_1X_BASE_C) +#define LOG_QDTX_DECODER_C (0x333 + LOG_1X_BASE_C) + +#define LOG_PORT_ASSIGNMENT_STATUS_C (0x334 + LOG_1X_BASE_C) + +/* Protocol Services reserved log codes */ +#define LOG_PS_RESERVED_CODES_BASE_C (0x335 + LOG_1X_BASE_C) +#define LOG_PS_LAST_C (25 + LOG_PS_RESERVED_C) + +#define LOG_PS_STAT_IP_C (0x335 + LOG_1X_BASE_C) +#define LOG_PS_STAT_GLOBAL_IPV4_C (0x335 + LOG_1X_BASE_C) +#define LOG_PS_STAT_GLOBAL_IPV6_C (0x336 + LOG_1X_BASE_C) +#define LOG_PS_STAT_GLOBAL_ICMPV4_C (0x337 + LOG_1X_BASE_C) +#define LOG_PS_STAT_GLOBAL_ICMPV6_C (0x338 + LOG_1X_BASE_C) +#define LOG_PS_STAT_GLOBAL_TCP_C (0x339 + LOG_1X_BASE_C) +#define LOG_PS_STAT_GLOBAL_UDP_C (0x33A + LOG_1X_BASE_C) + +/* Protocol Services describe all TCP instances */ +#define LOG_PS_STAT_DESC_ALL_TCP_INST_C (0x33B + LOG_1X_BASE_C) + +/* Protocol Services describe all memory pool instances */ +#define LOG_PS_STAT_DESC_ALL_MEM_POOL_INST_C (0x33C + LOG_1X_BASE_C) + +/* Protocol Services describe all IFACE instances */ +#define LOG_PS_STAT_DESC_ALL_IFACE_INST_C (0x33D + LOG_1X_BASE_C) + +/* Protocol Services describe all PPP instances */ +#define LOG_PS_STAT_DESC_ALL_PPP_INST_C (0x33E + LOG_1X_BASE_C) + +/* Protocol Services describe all ARP instances */ +#define LOG_PS_STAT_DESC_ALL_ARP_INST_C (0x33F + LOG_1X_BASE_C) + +/* Protocol Services describe delta instance */ +#define LOG_PS_STAT_DESC_DELTA_INST_C (0x340 + LOG_1X_BASE_C) + +/* Protocol Services instance TCP statistics */ +#define LOG_PS_STAT_TCP_INST_C (0x341 + LOG_1X_BASE_C) + +/* Protocol Services instance UDP statistics */ +#define LOG_PS_STAT_UDP_INST_C (0x342 + LOG_1X_BASE_C) + +/* Protocol Services instance PPP statistics */ +#define LOG_PS_STAT_PPP_INST_C (0x343 + LOG_1X_BASE_C) + +/* Protocol Services instance IFACE statistics */ +#define LOG_PS_STAT_IFACE_INST_C (0x344 + LOG_1X_BASE_C) + +/* Protocol Services instance memory statistics */ +#define LOG_PS_STAT_MEM_INST_C (0x345 + LOG_1X_BASE_C) + +/* Protocol Services instance flow statistics */ +#define LOG_PS_STAT_FLOW_INST_C (0x346 + LOG_1X_BASE_C) + +/* Protocol Services instance physical link statistics */ +#define LOG_PS_STAT_PHYS_LINK_INST_C (0x347 + LOG_1X_BASE_C) + +/* Protocol Services instance ARP statistics */ +#define LOG_PS_STAT_ARP_INST_C (0x348 + LOG_1X_BASE_C) + +/* Protocol Services instance LLC statistics */ +#define LOG_PS_STAT_LLC_INST_C (0x349 + LOG_1X_BASE_C) + +/* Protocol Services instance IPHC statistics */ +#define LOG_PS_STAT_IPHC_INST_C (0x34A + LOG_1X_BASE_C) + +/* Protocol Services instance ROHC statistics */ +#define LOG_PS_STAT_ROHC_INST_C (0x34B + LOG_1X_BASE_C) + +/* Protocol Services instance RSVP statistics */ +#define LOG_PS_STAT_RSVP_INST_C (0x34C + LOG_1X_BASE_C) + +/* Protocol Services describe all LLC instances */ +#define LOG_PS_STAT_DESC_ALL_LLC_INST_C (0x34D + LOG_1X_BASE_C) + +/* Protocol Services describe all RSVP instances */ +#define LOG_PS_STAT_DESC_ALL_RSVP_INST_C (0x34E + LOG_1X_BASE_C) + +/* Call Manager Serving System event log */ +#define LOG_CM_SS_EVENT_C (0x34F + LOG_1X_BASE_C) + +/* VcTcxo manager’s automatic frequency control log */ +#define LOG_TCXOMGR_AFC_DATA_C (0x350 + LOG_1X_BASE_C) + +/* Clock transactions and general clocks status log */ +#define LOG_CLOCK_C (0x351 + LOG_1X_BASE_C) + +/* GPS search processed peak results and their associated search parameters */ +#define LOG_GPS_PROCESSED_PEAK_C (0x352 + LOG_1X_BASE_C) + +#define LOG_MDSP_LOG_CHUNKS_C (0x353 + LOG_1X_BASE_C) + +/* Periodic RSSI update log */ +#define LOG_WLAN_RSSI_UPDATE_C (0x354 + LOG_1X_BASE_C) + +/* Periodic Link Layer statistics log */ +#define LOG_WLAN_LL_STAT_C (0x355 + LOG_1X_BASE_C) + +/* QOS Extended State Log */ +#define LOG_QOS_STATE_EX_C (0x356 + LOG_1X_BASE_C) + +/* Bluetooth host HCI transmitted data */ +#define LOG_BT_HOST_HCI_TX_C (0x357 + LOG_1X_BASE_C) + +/* Bluetooth host HCI received data */ +#define LOG_BT_HOST_HCI_RX_C (0x358 + LOG_1X_BASE_C) + +/* Internal - GPS PE Position Report Part 3 */ +#define LOG_GPS_PE_POSITION_REPORT_PART3_C (0x359 + LOG_1X_BASE_C) + +/* Extended log code which logs requested QoS */ +#define LOG_QOS_REQUESTED_EX_C (0x35A + LOG_1X_BASE_C) + +/* Extended log code which logs granted QoS */ +#define LOG_QOS_GRANTED_EX_C (0x35B + LOG_1X_BASE_C) + +/* Extended log code which logs modified QoS */ +#define LOG_QOS_MODIFIED_EX_C (0x35C + LOG_1X_BASE_C) + +/* Bus Monitor Profiling Info */ +#define LOG_BUS_MON_PROF_INFO_C (0x35D + LOG_1X_BASE_C) + +/* Pilot Phase Measurement Search results */ +#define LOG_SRCH_PPM_RES_VER_2_C (0x35E + LOG_1X_BASE_C) + +/* Pilot Phase Measurement Data Base */ +#define LOG_SRCH_PPM_DB_VER_2_C (0x35F + LOG_1X_BASE_C) + +/* Pilot Phase Measurement state machine */ +#define LOG_PPM_SM_C (0x360 + LOG_1X_BASE_C) + +/* Robust Header Compression - Compressor */ +#define LOG_ROHC_COMPRESSOR_C (0x361 + LOG_1X_BASE_C) + +/* Robust Header Compression - Decompressor */ +#define LOG_ROHC_DECOMPRESSOR_C (0x362 + LOG_1X_BASE_C) + +/* Robust Header Compression - Feedback Compressor */ +#define LOG_ROHC_FEEDBACK_COMPRESSOR_C (0x363 + LOG_1X_BASE_C) + +/* Robust Header Compression - Feedback Decompressor */ +#define LOG_ROHC_FEEDBACK_DECOMPRESSOR_C (0x364 + LOG_1X_BASE_C) + +/* Bluetooth HCI commands */ +#define LOG_BT_HCI_CMD_C (0x365 + LOG_1X_BASE_C) + +/* Bluetooth HCI events */ +#define LOG_BT_HCI_EV_C (0x366 + LOG_1X_BASE_C) + +/* Bluetooth HCI Transmitted ACL data */ +#define LOG_BT_HCI_TX_ACL_C (0x367 + LOG_1X_BASE_C) + +/* Bluetooth HCI Received ACL data */ +#define LOG_BT_HCI_RX_ACL_C (0x368 + LOG_1X_BASE_C) + +/* Bluetooth SOC H4 Deep Sleep */ +#define LOG_BT_SOC_H4DS_C (0x369 + LOG_1X_BASE_C) + +/* UMTS to CDMA Handover Message */ +#define LOG_UMTS_TO_CDMA_HANDOVER_MSG_C (0x36A + LOG_1X_BASE_C) + +/* Graphic Event Data */ +#define LOG_PROFILER_GRAPHIC_DATA_C (0x36B + LOG_1X_BASE_C) + +/* Audio Event Data */ +#define LOG_PROFILER_AUDIO_DATA_C (0x36C + LOG_1X_BASE_C) + +/* GPS Spectral Information */ +#define LOG_GPS_SPECTRAL_INFO_C (0x36D + LOG_1X_BASE_C) + +/* AHB Performance Monitor LOG data */ +#define LOG_APM_C (0x36E + LOG_1X_BASE_C) + +/* GPS Clock Report */ +#define LOG_CONVERGED_GPS_CLOCK_REPORT_C (0x36F + LOG_1X_BASE_C) + +/* GPS Position Report */ +#define LOG_CONVERGED_GPS_POSITION_REPORT_C (0x370 + LOG_1X_BASE_C) + +/* GPS Measurement Report */ +#define LOG_CONVERGED_GPS_MEASUREMENT_REPORT_C (0x371 + LOG_1X_BASE_C) + +/* GPS RF Status Report */ +#define LOG_CONVERGED_GPS_RF_STATUS_REPORT_C (0x372 + LOG_1X_BASE_C) + +/* VOIP To CDMA Handover Message - Obsoleted by 0x138B - 0x138D */ +#define LOG_VOIP_TO_CDMA_HANDOVER_MSG_C (0x373 + LOG_1X_BASE_C) + +/* GPS Prescribed Dwell Result */ +#define LOG_GPS_PRESCRIBED_DWELL_RESULT_C (0x374 + LOG_1X_BASE_C) + +/* CGPS IPC Data */ +#define LOG_CGPS_IPC_DATA_C (0x375 + LOG_1X_BASE_C) + +/* CGPS Non IPC Data */ +#define LOG_CGPS_NON_IPC_DATA_C (0x376 + LOG_1X_BASE_C) + +/* CGPS Session Report */ +#define LOG_CGPS_REP_EVT_LOG_PACKET_C (0x377 + LOG_1X_BASE_C) + +/* CGPS PDSM Get Position */ +#define LOG_CGPS_PDSM_GET_POSITION_C (0x378 + LOG_1X_BASE_C) + +/* CGPS PDSM Set Parameters */ +#define LOG_CGPS_PDSM_SET_PARAMETERS_C (0x379 + LOG_1X_BASE_C) + +/* CGPS PDSM End Session */ +#define LOG_CGPS_PDSM_END_SESSION_C (0x37A + LOG_1X_BASE_C) + +/* CGPS PDSM Notify Verify Response */ +#define LOG_CGPS_PDSM_NOTIFY_VERIFY_RESP_C (0x37B + LOG_1X_BASE_C) + +/* CGPS PDSM Position Report Callback */ +#define LOG_CGPS_PDSM_POSITION_REPORT_CALLBACK_C (0x37C + LOG_1X_BASE_C) + +/* CGPS PDSM PD Event Callback */ +#define LOG_CGPS_PDSM_PD_EVENT_CALLBACK_C (0x37D + LOG_1X_BASE_C) + +/* CGPS PDSM PA Event Callback */ +#define LOG_CGPS_PDSM_PA_EVENT_CALLBACK_C (0x37E + LOG_1X_BASE_C) + +/* CGPS PDSM Notify Verify Request Callback */ +#define LOG_CGPS_PDSM_NOTIFY_VERIFY_REQUEST_C (0x37F + LOG_1X_BASE_C) + +/* CGPS PDSM PD Command Error Callback */ +#define LOG_CGPS_PDSM_PD_CMD_ERR_CALLBACK_C (0x380 + LOG_1X_BASE_C) + +/* CGPS PDSM PA Command Error Callback */ +#define LOG_CGPS_PDSM_PA_CMD_ERR_CALLBACK_C (0x381 + LOG_1X_BASE_C) + +/* CGPS PDSM Position Error */ +#define LOG_CGPS_PDSM_POS_ERROR_C (0x382 + LOG_1X_BASE_C) + +/* CGPS PDSM Extended Status Position Report */ +#define LOG_CGPS_PDSM_EXT_STATUS_POS_REPORT_C (0x383 + LOG_1X_BASE_C) + +/* CGPS PDSM Extended Status NMEA Report */ +#define LOG_CGPS_PDSM_EXT_STATUS_NMEA_REPORT_C (0x384 + LOG_1X_BASE_C) + +/* CGPS PDSM Extended Status Measurement Report */ +#define LOG_CGPS_PDSM_EXT_STATUS_MEAS_REPORT_C (0x385 + LOG_1X_BASE_C) + +/* CGPS Report Server TX Packet */ +#define LOG_CGPS_REP_SVR_TX_LOG_PACKET_C (0x386 + LOG_1X_BASE_C) + +/* CGPS Report Server RX Packet */ +#define LOG_CGPS_REP_SVR_RX_LOG_PACKET_C (0x387 + LOG_1X_BASE_C) + +/* UMTS To CDMA Handover Paging Channel Message */ +#define LOG_UMTS_TO_CDMA_HANDOVER_PCH_MSG_C (0x388 + LOG_1X_BASE_C) + +/* UMTS To CDMA Handover Traffic Channel Message */ +#define LOG_UMTS_TO_CDMA_HANDOVER_TCH_MSG_C (0x389 + LOG_1X_BASE_C) + +/* Converged GPS IQ Report */ +#define LOG_CONVERGED_GPS_IQ_REPORT_C (0x38A + LOG_1X_BASE_C) + +/* VOIP To CDMA Paging Channel Handover Message */ +#define LOG_VOIP_TO_CDMA_PCH_HANDOVER_MSG_C (0x38B + LOG_1X_BASE_C) + +/* VOIP To CDMA Access Channel Handover Message */ +#define LOG_VOIP_TO_CDMA_ACH_HANDOVER_MSG_C (0x38C + LOG_1X_BASE_C) + +/* VOIP To CDMA Forward Traffic Channel Handover Message */ +#define LOG_VOIP_TO_CDMA_FTC_HANDOVER_MSG_C (0x38D + LOG_1X_BASE_C) + +/* QMI reserved logs */ +#define LOG_QMI_RESERVED_CODES_BASE_C (0x38E + LOG_1X_BASE_C) +#define LOG_QMI_LAST_C (32 + LOG_QMI_RESERVED_CODES_BASE_C) + +/* QOS Info Code Update Log */ +#define LOG_QOS_INFO_CODE_UPDATE_C (0x3AF + LOG_1X_BASE_C) + +/* Transmit(Uplink) Vocoder PCM Packet Log */ +#define LOG_TX_PCM_PACKET_C (0x3B0 + LOG_1X_BASE_C) + +/* Audio Vocoder Data Paths */ +#define LOG_AUDVOC_DATA_PATHS_PACKET_C (0x3B0 + LOG_1X_BASE_C) + +/* Receive(Downlink) Vocoder PCM Packet Log */ +#define LOG_RX_PCM_PACKET_C (0x3B1 + LOG_1X_BASE_C) + +/* CRC of YUV frame log */ +#define LOG_DEC_CRC_FRAME_C (0x3B2 + LOG_1X_BASE_C) + +/* FLUTE Session Information */ +#define LOG_FLUTE_SESSION_INFO_C (0x3B3 + LOG_1X_BASE_C) + +/* FLUTE ADP File Information */ +#define LOG_FLUTE_ADP_FILE_INFO_C (0x3B4 + LOG_1X_BASE_C) + +/* FLUTE File Request Information */ +#define LOG_FLUTE_FILE_REQ_INFO_C (0x3B5 + LOG_1X_BASE_C) + +/* FLUTE FDT Instance Information */ +#define LOG_FLUTE_FDT_INST_C (0x3B6 + LOG_1X_BASE_C) + +/* FLUTE FDT Information */ +#define LOG_FLUTE_FDT_INFO_C (0x3B7 + LOG_1X_BASE_C) + +/* FLUTE File Log Packet Information */ +#define LOG_FLUTE_FILE_INFO_C (0x3B8 + LOG_1X_BASE_C) + +/* 3G 1X Parameter Overhead Information */ +#define LOG_VOIP_TO_CDMA_3G1X_PARAMETERS_C (0x3B9 + LOG_1X_BASE_C) + +/* CGPS ME Job Info */ +#define LOG_CGPS_ME_JOB_INFO_C (0x3BA + LOG_1X_BASE_C) + +/* CGPS ME SV Lists */ +#define LOG_CPGS_ME_SV_LISTS_C (0x3BB + LOG_1X_BASE_C) + +/* Flexible Profiling Status */ +#define LOG_PROFDIAG_GEN_STATUS_C (0x3BC + LOG_1X_BASE_C) + +/* Flexible Profiling Results */ +#define LOG_PROFDIAG_GEN_PROF_C (0x3BD + LOG_1X_BASE_C) + +/* FLUTE ADP File Content Log Packet Information */ +#define LOG_FLUTE_ADP_FILE_C (0x3BE + LOG_1X_BASE_C) + +/* FLUTE FDT Instance File Content Log Packet Information */ +#define LOG_FLUTE_FDT_INST_FILE_C (0x3BF + LOG_1X_BASE_C) + +/* FLUTE FDT Entries Information */ +#define LOG_FLUTE_FDT_ENTRIES_INFO_C (0x3C0 + LOG_1X_BASE_C) + +/* FLUTE File Contents Log Packet Information */ +#define LOG_FLUTE_FILE_C (0x3C1 + LOG_1X_BASE_C) + +/* CGPS ME Time-Transfer Info */ +#define LOG_CGPS_ME_TIME_TRANSFER_INFO_C (0x3C2 + LOG_1X_BASE_C) + +/* CGPS ME UMTS Time-Tagging Info */ +#define LOG_CGPS_ME_UMTS_TIME_TAGGING_INFO_C (0x3C3 + LOG_1X_BASE_C) + +/* CGPS ME Generic Time Estimate Put lnfo */ +#define LOG_CGPS_ME_TIME_EST_PUT_INFO_C (0x3C4 + LOG_1X_BASE_C) + +/* CGPS ME Generic Freq Estimate Put lnfo */ +#define LOG_CGPS_ME_FREQ_EST_PUT_INFO_C (0x3C5 + LOG_1X_BASE_C) + +/* CGPS Slow Clock Report */ +#define LOG_CGPS_SLOW_CLOCK_REPORT_C (0x3C6 + LOG_1X_BASE_C) + +/* Converged GPS Medium Grid */ +#define LOG_CONVERGED_GPS_MEDIUM_GRID_C (0x3C7 + LOG_1X_BASE_C) + +/* Static information about the driver or device */ +#define LOG_SNSD_INFO_C (0x3C8 + LOG_1X_BASE_C) + +/* Dynamic state information about the device or driver */ +#define LOG_SNSD_STATE_C (0x3C9 + LOG_1X_BASE_C) + +/* Data from a driver */ +#define LOG_SNSD_DATA (0x3CA + LOG_1X_BASE_C) +#define LOG_SNSD_DATA_C (0x3CA + LOG_1X_BASE_C) + +/* CGPS Cell DB Cell Change Info */ +#define LOG_CGPS_CELLDB_CELL_CHANGE_INFO_C (0x3CB + LOG_1X_BASE_C) + +/* xScalar YUV frame log */ +#define LOG_DEC_XSCALE_YUV_FRAME_C (0x3CC + LOG_1X_BASE_C) + +/* CRC of xScaled YUV frame log */ +#define LOG_DEC_XSCALE_CRC_FRAME_C (0x3CD + LOG_1X_BASE_C) + +/* CGPS Frequency Estimate Report */ +#define LOG_CGPS_FREQ_EST_REPORT_C (0x3CE + LOG_1X_BASE_C) + +/* GPS DCME Srch Job Completed */ +#define LOG_GPS_DCME_SRCH_JOB_COMPLETED_C (0x3CF + LOG_1X_BASE_C) + +/* CGPS ME Fastscan results */ +#define LOG_CGPS_ME_FASTSCAN_RESULTS_C (0x3D0 + LOG_1X_BASE_C) + +/* XO frequency Estimation log */ +#define LOG_XO_FREQ_EST_C (0x3D1 + LOG_1X_BASE_C) + +/* Tcxomgr field calibration data */ +#define LOG_TCXOMGR_FIELD_CAL_C (0x3D2 + LOG_1X_BASE_C) + +/* UMB Call Processing Connection Attempt */ +#define LOG_UMBCP_CONNECTION_ATTEMPT_C (0x3D3 + LOG_1X_BASE_C) + +/* UMB Call Processing Connection Release */ +#define LOG_UMBCP_CONNECTION_RELEASE_C (0x3D4 + LOG_1X_BASE_C) + +/* UMB Call Processing Page Message */ +#define LOG_UMBCP_PAGE_MESSAGE_C (0x3D5 + LOG_1X_BASE_C) + +/* UMB Call Processing OVHD Information */ +#define LOG_UMBCP_OVHD_INFO_C (0x3D6 + LOG_1X_BASE_C) + +/* UMB Call Processing Session Attempt */ +#define LOG_UMBCP_SESSION_ATTEMPT_C (0x3D7 + LOG_1X_BASE_C) + +/* UMB Call Processing Route Information */ +#define LOG_UMBCP_ROUTE_INFO_C (0x3D8 + LOG_1X_BASE_C) + +/* UMB Call Processing State Information */ +#define LOG_UMBCP_STATE_INFO_C (0x3D9 + LOG_1X_BASE_C) + +/* UMB Call Processing SNP */ +#define LOG_UMBCP_SNP_C (0x3DA + LOG_1X_BASE_C) + +/* CGPS Session Early Exit Decision */ +#define LOG_CGPS_SESSION_EARLY_EXIT_DECISION_C (0x3DB + LOG_1X_BASE_C) + +/* GPS RF Linearity Status */ +#define LOG_CGPS_ME_RF_LINEARITY_INFO_C (0x3DC + LOG_1X_BASE_C) + +/* CGPS ME 5ms IQ Sums */ +#define LOG_CGPS_ME_5MS_IQ_SUMS_C (0x3DD + LOG_1X_BASE_C) + +/* CGPS ME 20ms IQ Sums */ +#define LOG_CPGS_ME_20MS_IQ_SUMS_C (0x3DE + LOG_1X_BASE_C) + +/* ROHC Compressor Statistics */ +#define LOG_ROHC_COMPRESSOR_STATS_C (0x3DF + LOG_1X_BASE_C) + +/* ROHC Decompressor Statistics */ +#define LOG_ROHC_DECOMPRESSOR_STATS_C (0x3E0 + LOG_1X_BASE_C) + +/* Sensors - Kalman filter information */ +#define LOG_SENSOR_KF_INFO_C (0x3E1 + LOG_1X_BASE_C) + +/* Sensors - Integrated measurements */ +#define LOG_SENSOR_INT_MEAS_C (0x3E2 + LOG_1X_BASE_C) + +/* Sensors - Bias calibration values */ +#define LOG_SENSOR_BIAS_CALIBRATION_C (0x3E3 + LOG_1X_BASE_C) + +/* Log codes 0x13E4-0x13E7 are not following standard log naming convention */ + +/* DTV ISDB-T Transport Stream Packets */ +#define LOG_DTV_ISDB_TS_PACKETS (0x3E4 + LOG_1X_BASE_C) + +/* DTV ISDB-T PES Packets */ +#define LOG_DTV_ISDB_PES_PACKETS (0x3E5 + LOG_1X_BASE_C) + +/* DTV ISDB-T Sections */ +#define LOG_DTV_ISDB_SECTIONS (0x3E6 + LOG_1X_BASE_C) + +/* DTV ISDB-T Buffering */ +#define LOG_DTV_ISDB_BUFFERING (0x3E7 + LOG_1X_BASE_C) + +/* WLAN System Acquisition and Handoff */ +#define LOG_WLAN_SYS_ACQ_HO_C (0x3E8 + LOG_1X_BASE_C) + +/* WLAN General Configurable Parameters */ +#define LOG_WLAN_GEN_CONFIG_PARAMS_C (0x3E9 + LOG_1X_BASE_C) + +/* UMB Physical Layer Channel and Interference Estimation */ +#define LOG_UMB_PHY_RX_DPICH_CIE_C (0x3EA + LOG_1X_BASE_C) + +/* UMB Physical Layer MMSE/MRC Demodulated Data Symbols (Low) */ +#define LOG_UMB_PHY_RX_DATA_DEMOD_LOW_C (0x3EB + LOG_1X_BASE_C) + +/* UMB Physical Layer MMSE/MRC Demodulated Data Symbols (High) */ +#define LOG_UMB_PHY_RX_DATA_DEMOD_HIGH_C (0x3EC + LOG_1X_BASE_C) + +/* UMB Physical Layer DCH Decoder */ +#define LOG_UMB_PHY_RX_DCH_DECODER_C (0x3ED + LOG_1X_BASE_C) + +/* UMB Physical Layer DCH Statistics */ +#define LOG_UMB_PHY_DCH_STATISTICS_C (0x3EE + LOG_1X_BASE_C) + +/* UMB Physical Layer CqiPich Processing */ +#define LOG_UMB_PHY_RX_CQIPICH_C (0x3EF + LOG_1X_BASE_C) + +/* UMB Physical Layer MIMO/SIMO in CqiPich (High) */ +#define LOG_UMB_PHY_RX_CQIPICH_CHANTAPS_HIGH_C (0x3F0 + LOG_1X_BASE_C) + +/* UMB Physical Layer MIMO/SIMO in CquiPich (Low) */ +#define LOG_UMB_PHY_RX_CQIPICH_CHANTAPS_LOW_C (0x3F1 + LOG_1X_BASE_C) + +/* UMB Physical Layer Time-Domain Channel Taps (High) */ +#define LOG_UMB_PHY_RX_PPICH_CHAN_EST_HIGH_C (0x3F2 + LOG_1X_BASE_C) + +/* UMB Physical Layer Time-Domain Channel Taps (Low) */ +#define LOG_UMB_PHY_RX_PPICH_CHAN_EST_LOW_C (0x3F3 + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator */ +#define LOG_UMB_PHY_TX_PICH_CONFIG_C (0x3F4 + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for R-ACK (High) */ +#define LOG_UMB_PHY_TX_ACK_HIGH_C (0x3F5 + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for R-ACK (Low) */ +#define LOG_UMB_PHY_TX_ACK_LOW_C (0x3F6 + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for R-PICH */ +#define LOG_UMB_PHY_TX_PICH_C (0x3F7 + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for R-ACH (Access) */ +#define LOG_UMB_PHY_TX_ACH_C (0x3F8 + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for R-ODDCCH (High) */ +#define LOG_UMB_PHY_TX_ODCCH_HIGH_C (0x3F9 + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for R-ODDCCH (Low) */ +#define LOG_UMB_PHY_TX_ODCCH_LOW_C (0x3FA + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for R-CDCCH */ +#define LOG_UMB_PHY_TX_RCDCCH_CONFIG_C (0x3FB + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for CQI sent on RCDCCH */ +#define LOG_UMB_PHY_TX_NONFLSS_CQICH_C (0x3FC + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for CQI sent on RCDCCH */ +#define LOG_UMB_PHY_TX_FLSS_CQICH_C (0x3FD + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for PACH sent on RCDCCH */ +#define LOG_UMB_PHY_TX_PAHCH_C (0x3FE + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for REQ sent on RCDCCH */ +#define LOG_UMB_PHY_TX_REQCH_C (0x3FF + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for PSD sent on RCDCCH */ +#define LOG_UMB_PHY_TX_PSDCH_C (0x400 + LOG_1X_BASE_C) + +/* UMB Physical Layer AT Modulator for R-DCH */ +#define LOG_UMB_PHY_TX_DCH_C (0x401 + LOG_1X_BASE_C) + +/* UMB Physical Layer Time/Frequency/RxPower Estimate */ +#define LOG_UMB_PHY_RX_TIME_FREQ_POWER_ESTIMATE_C (0x402 + LOG_1X_BASE_C) + +/* UMB Physical Layer FLCS Processing */ +#define LOG_UMB_PHY_RX_FLCS_PROCESSING_C (0x403 + LOG_1X_BASE_C) + +/* UMB Physical Layer PBCCH Processing */ +#define LOG_UMB_PHY_RX_PBCCH_PROCESSING_C (0x404 + LOG_1X_BASE_C) + +/* UMB Physical Layer SBCCH Processing */ +#define LOG_UMB_PHY_RX_SBCCH_PROCESSING_C (0x405 + LOG_1X_BASE_C) + +/* UMB Physical Layer QPCH Processing */ +#define LOG_UMB_PHY_RX_QPCH_PROCESSING_C (0x406 + LOG_1X_BASE_C) + +/* UMB Physical Layer MRC Demodulated Data Symbols (Preamble SBCCH/QPCH) */ +#define LOG_UMB_PHY_RX_SBCCH_DEMOD_C (0x407 + LOG_1X_BASE_C) + +/* UMB Physical Layer MRC Demodulated Data Symbols (Preamble PBCCH) */ +#define LOG_UMB_PHY_RX_PBCCH_DEMOD_C (0x408 + LOG_1X_BASE_C) + +/* UMB Physical Layer VCQI */ +#define LOG_UMB_PHY_RX_VCQI_C (0x409 + LOG_1X_BASE_C) + +/* UMB Physical Layer Acquisition Algorithm */ +#define LOG_UMB_PHY_RX_INITIAL_ACQUISITION_C (0x40A + LOG_1X_BASE_C) + +/* UMB Physical Layer Handoff Search Algorithm */ +#define LOG_UMB_PHY_RX_HANDOFF_SEARCH_C (0x40B + LOG_1X_BASE_C) + +/* UMB RF RFFE Configuration Info */ +#define LOG_UMB_AT_RFFE_CONFG_C (0x40C + LOG_1X_BASE_C) + +/* UMB RF Calibrated Values After Powerup */ +#define LOG_UMB_AT_RFFE_RX_CALIB_C (0x40D + LOG_1X_BASE_C) + +/* UMB RF AGC Block in Acquisition Mode */ +#define LOG_UMB_AT_RFFE_RX_ACQ_C (0x40E + LOG_1X_BASE_C) + +/* UMB RF AGC Block in Idle Mode */ +#define LOG_UMB_AT_RFFE_RX_IDLE_C (0x40F + LOG_1X_BASE_C) + +/* UMB RF AGC Block in Connected Mode */ +#define LOG_UMB_AT_RFFE_RX_CONNECTED_C (0x410 + LOG_1X_BASE_C) + +/* UMB RF AGC Block in Connected Mode (FTM) */ +#define LOG_UMB_AT_RFFE_RX_CONNECTED_FTM_C (0x411 + LOG_1X_BASE_C) + +/* UMB RF Jammer Detector Functionality */ +#define LOG_UMB_AT_RFFE_RX_JAMMER_DETECTOR_FUNCTIONALITY_C (0x412 + LOG_1X_BASE_C) + +/* UMB RF Jammer Detector Response */ +#define LOG_UMB_AT_RFFE_RX_JAMMER_DETECTOR_RESPONSE_C (0x413 + LOG_1X_BASE_C) + +/* UMB RF RFFE TX Power Control */ +#define LOG_UMB_AT_RFFE_TX_BETA_SCALING_C (0x414 + LOG_1X_BASE_C) + +/* UMB Searcher Dump */ +#define LOG_UMB_SEARCHER_DUMP_C (0x415 + LOG_1X_BASE_C) + +/* UMB System Acquire */ +#define LOG_UMB_SYSTEM_ACQUIRE_C (0x416 + LOG_1X_BASE_C) + +/* UMB Set Maintenance */ +#define LOG_UMB_SET_MAINTENANCE_C (0x417 + LOG_1X_BASE_C) + +/* UMB QPCH */ +#define LOG_UMB_QPCH_C (0x418 + LOG_1X_BASE_C) + +/* UMB RLL Forward Partial RP Packet */ +#define LOG_UMB_RLL_FORWARD_PARTIAL_RP_C (0x419 + LOG_1X_BASE_C) + +/* UMB RLL Reverse Partial RP Packet */ +#define LOG_UMB_RLL_REVERSE_PARTIAL_RP_C (0x41A + LOG_1X_BASE_C) + +/* UMB RLL Forward Signal Packet */ +#define LOG_UMB_RLL_FORWARD_SIGNAL_C (0x41B + LOG_1X_BASE_C) + +/* UMB RLL Reverse Signal Packet */ +#define LOG_UMB_RLL_REVERSE_SIGNAL_C (0x41C + LOG_1X_BASE_C) + +/* UMB RLL Forward Statistics */ +#define LOG_UMB_RLL_FORWARD_STATS_C (0x41D + LOG_1X_BASE_C) + +/* UMB RLL Reverse Statistics */ +#define LOG_UMB_RLL_REVERSE_STATS_C (0x41E + LOG_1X_BASE_C) + +/* UMB RLL IRTP */ +#define LOG_UMB_RLL_IRTP_C (0x41F + LOG_1X_BASE_C) + +/* UMB AP Forward Link MAC Packets */ +#define LOG_UMB_AP_FL_MAC_PACKET_C (0x420 + LOG_1X_BASE_C) + +/* UMB AP Reverse Link MAC Packets */ +#define LOG_UMB_AP_RL_MAC_PACKET_C (0x421 + LOG_1X_BASE_C) + +/* GPS Performance Statistics log */ +#define LOG_CGPS_PERFORMANCE_STATS_C (0x422 + LOG_1X_BASE_C) + +/* UMB Searcher General Status */ +#define LOG_UMB_SRCH_GENERAL_STATUS_C (0x423 + LOG_1X_BASE_C) + +/* UMB Superframe Scheduler */ +#define LOG_UMB_SUPERFRAME_SCHEDULER_C (0x424 + LOG_1X_BASE_C) + +/* UMB Sector List */ +#define LOG_UMB_SECTOR_LIST_C (0x425 + LOG_1X_BASE_C) + +/* UMB MAC Access Attempt Command */ +#define LOG_UMB_MAC_ACCESS_ATTEMPT_CMD_C (0x426 + LOG_1X_BASE_C) + +/* UMB MAC Access Probe Information */ +#define LOG_UMB_MAC_ACCESS_PROBE_INFO_C (0x427 + LOG_1X_BASE_C) + +/* UMB MAC RTCMAC Package Information */ +#define LOG_UMB_MAC_RTCMAC_PKG_INFO_C (0x428 + LOG_1X_BASE_C) + +/* UMB MAC Super Frame Information */ +#define LOG_UMB_MAC_SI_INFO_C (0x429 + LOG_1X_BASE_C) + +/* UMB MAC Quick Channel Information */ +#define LOG_UMB_MAC_QCI_INFO_C (0x42A + LOG_1X_BASE_C) + +/* UMB MAC Paging Id List */ +#define LOG_UMB_MAC_PAGING_ID_LIST_C (0x42B + LOG_1X_BASE_C) + +/* UMB MAC Quick Paging Channel Information */ +#define LOG_UMB_MAC_QPCH_INFO_C (0x42C + LOG_1X_BASE_C) + +/* UMB MAC FTCMAC Information */ +#define LOG_UMB_MAC_FTCMAC_PKG_INFO_C (0x42D + LOG_1X_BASE_C) + +/* UMB MAC Access Grant Receiving */ +#define LOG_UMB_MAC_ACCESS_GRANT_C (0x42E + LOG_1X_BASE_C) + +/* UMB MAC Generic Debug Log */ +#define LOG_UMB_MAC_GEN_DEBUG_LOG_PKG_C (0x42F + LOG_1X_BASE_C) + +/* CGPS Frequency Bias Estimate */ +#define LOG_CGPS_MC_FREQ_BIAS_EST_C (0x430 + LOG_1X_BASE_C) + +/* UMB MAC Request Report Information Log */ +#define LOG_UMB_MAC_REQCH_REPORT_INFO_C (0x431 + LOG_1X_BASE_C) + +/* UMB MAC Reverse Link QoS Token Bucket Information Log */ +#define LOG_UMB_MAC_RLQOS_TOKEN_BUCKET_INFO_C (0x432 + LOG_1X_BASE_C) + +/* UMB MAC Reverse Link QoS Stream Information Log */ +#define LOG_UMB_MAC_RLQOS_STREAM_INFO_C (0x433 + LOG_1X_BASE_C) + +/* UMB MAC Reverse Link QoS Allotment Information Log */ +#define LOG_UMB_MAC_RLQOS_ALLOTMENT_INFO_C (0x434 + LOG_1X_BASE_C) + +/* UMB Searcher Recent State Machine Transactions */ +#define LOG_UMB_SRCH_STM_ACTIVITY_C (0x435 + LOG_1X_BASE_C) + +/* Performance Counters on ARM11 Profiling Information */ +#define LOG_ARM11_PERF_CNT_INFO_C (0x436 + LOG_1X_BASE_C) + +/* Protocol Services describe all flow instances */ +#define LOG_PS_STAT_DESC_ALL_FLOW_INST_C (0x437 + LOG_1X_BASE_C) + +/* Protocol Services describe all physical link instances */ +#define LOG_PS_STAT_DESC_ALL_PHYS_LINK_INST_C (0x438 + LOG_1X_BASE_C) + +/* Protocol Services describe all UDP instances */ +#define LOG_PS_STAT_DESC_ALL_UDP_INST_C (0x439 + LOG_1X_BASE_C) + +/* Searcher 4 Multi-Carrier HDR */ +#define LOG_SRCH4_MC_HDR_C (0x43A + LOG_1X_BASE_C) + +/* Protocol Services describe all IPHC instances */ +#define LOG_PS_STAT_DESC_ALL_IPHC_INST_C (0x43B + LOG_1X_BASE_C) + +/* Protocol Services describe all ROHC instances */ +#define LOG_PS_STAT_DESC_ALL_ROHC_INST_C (0x43C + LOG_1X_BASE_C) + +/* BCast security add program information */ +#define LOG_BCAST_SEC_ADD_PROGRAM_INFO_C (0x43D + LOG_1X_BASE_C) + +/* BCast security add program complete */ +#define LOG_BCAST_SEC_ADD_PROGRAM_COMPLETE_C (0x43E + LOG_1X_BASE_C) + +/* BCast security SDP parse */ +#define LOG_BCAST_SEC_SDP_PARSE_C (0x43F + LOG_1X_BASE_C) + +/* CGPS ME dynamic power optimization status */ +#define LOG_CGPS_ME_DPO_STATUS_C (0x440 + LOG_1X_BASE_C) + +/* CGPS PDSM on demand session start */ +#define LOG_CGPS_PDSM_ON_DEMAND_SESSION_START_C (0x441 + LOG_1X_BASE_C) + +/* CGPS PDSM on demand session stop */ +#define LOG_CGPS_PDSM_ON_DEMAND_SESSION_STOP_C (0x442 + LOG_1X_BASE_C) + +/* CGPS PDSM on demand session not started */ +#define LOG_CGPS_PDSM_ON_DEMAND_SESSION_NOT_STARTED_C (0x443 + LOG_1X_BASE_C) + +/* CGPS PDSM extern coarse position inject start */ +#define LOG_CGPS_PDSM_EXTERN_COARSE_POS_INJ_START_C (0x444 + LOG_1X_BASE_C) + +/* DTV ISDB-T TMCC information */ +#define LOG_DTV_ISDB_TMCC_C (0x445 + LOG_1X_BASE_C) + +/* RF development */ +#define LOG_RF_DEV_C (0x446 + LOG_1X_BASE_C) + +/* RF RFM API */ +#define LOG_RF_RFM_API_C (0x447 + LOG_1X_BASE_C) + +/* RF RFM state */ +#define LOG_RF_RFM_STATE_C (0x448 + LOG_1X_BASE_C) + +/* 1X RF Warmup */ +#define LOG_1X_RF_WARMUP_C (0x449 + LOG_1X_BASE_C) + +/* 1X RF power limiting */ +#define LOG_1X_RF_PWR_LMT_C (0x44A + LOG_1X_BASE_C) + +/* 1X RF state */ +#define LOG_1X_RF_STATE_C (0x44B + LOG_1X_BASE_C) + +/* 1X RF sleep */ +#define LOG_1X_RF_SLEEP_C (0x44C + LOG_1X_BASE_C) + +/* 1X RF TX state */ +#define LOG_1X_RF_TX_STATE_C (0x44D + LOG_1X_BASE_C) + +/* 1X RF IntelliCeiver state */ +#define LOG_1X_RF_INT_STATE_C (0x44E + LOG_1X_BASE_C) + +/* 1X RF RX ADC clock */ +#define LOG_1X_RF_RX_ADC_CLK_C (0x44F + LOG_1X_BASE_C) + +/* 1X RF LNA switch point */ +#define LOG_1X_RF_LNA_SWITCHP_C (0x450 + LOG_1X_BASE_C) + +/* 1X RF RX calibration */ +#define LOG_1X_RF_RX_CAL_C (0x451 + LOG_1X_BASE_C) + +/* 1X RF API */ +#define LOG_1X_RF_API_C (0x452 + LOG_1X_BASE_C) + +/* 1X RF RX PLL locking status */ +#define LOG_1X_RF_RX_PLL_LOCK_C (0x453 + LOG_1X_BASE_C) + +/* 1X RF voltage regulator */ +#define LOG_1X_RF_VREG_C (0x454 + LOG_1X_BASE_C) + +/* CGPS DIAG successful fix count */ +#define LOG_CGPS_DIAG_SUCCESSFUL_FIX_COUNT_C (0x455 + LOG_1X_BASE_C) + +/* CGPS MC track dynamic power optimization status */ +#define LOG_CGPS_MC_TRACK_DPO_STATUS_C (0x456 + LOG_1X_BASE_C) + +/* CGPS MC SBAS demodulated bits */ +#define LOG_CGPS_MC_SBAS_DEMOD_BITS_C (0x457 + LOG_1X_BASE_C) + +/* CGPS MC SBAS demodulated soft symbols */ +#define LOG_CGPS_MC_SBAS_DEMOD_SOFT_SYMBOLS_C (0x458 + LOG_1X_BASE_C) + +/* Data Services PPP configuration */ +#define LOG_DS_PPP_CONFIG_PARAMS_C (0x459 + LOG_1X_BASE_C) + +/* Data Services physical link configuration */ +#define LOG_DS_PHYS_LINK_CONFIG_PARAMS_C (0x45A + LOG_1X_BASE_C) + +/* Data Services PPP device configuration */ +#define LOG_PS_PPP_DEV_CONFIG_PARAMS_C (0x45B + LOG_1X_BASE_C) + +/* CGPS PDSM GPS state information */ +#define LOG_CGPS_PDSM_GPS_STATE_INFO_C (0x45C + LOG_1X_BASE_C) + +/* CGPS PDSM EXT status GPS state information */ +#define LOG_CGPS_PDSM_EXT_STATUS_GPS_STATE_INFO_C (0x45D + LOG_1X_BASE_C) + +/* CGPS ME Rapid Search Report */ +#define LOG_CGPS_ME_RAPID_SEARCH_REPORT_C (0x45E + LOG_1X_BASE_C) + +/* CGPS PDSM XTRA-T session */ +#define LOG_CGPS_PDSM_XTRA_T_SESSION_C (0x45F + LOG_1X_BASE_C) + +/* CGPS PDSM XTRA-T upload */ +#define LOG_CGPS_PDSM_XTRA_T_UPLOAD_C (0x460 + LOG_1X_BASE_C) + +/* CGPS Wiper Position Report */ +#define LOG_CGPS_WIPER_POSITION_REPORT_C (0x461 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard HTTP Digest Request Info */ +#define LOG_DTV_DVBH_SEC_SC_HTTP_DIGEST_REQ_C (0x462 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard HTTP Digest Response Info */ +#define LOG_DTV_DVBH_SEC_SC_HTTP_DIGEST_RSP_C (0x463 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard Services Registration Request Info */ +#define LOG_DTV_DVBH_SEC_SC_SVC_REG_REQ_C (0x464 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard Services Registration Complete Info */ +#define LOG_DTV_DVBH_SEC_SC_SVC_REG_COMPLETE_C (0x465 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard Services Deregistration Request Info */ +#define LOG_DTV_DVBH_SEC_SC_SVC_DEREG_REQ_C (0x466 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard Services Deregistration Complete Info */ +#define LOG_DTV_DVBH_SEC_SC_SVC_DEREG_COMPLETE_C (0x467 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard LTKM Request Info */ +#define LOG_DTV_DVBH_SEC_SC_LTKM_REQ_C (0x468 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard LTKM Request Complete Info */ +#define LOG_DTV_DVBH_SEC_SC_LTKM_REQ_COMPLETE_C (0x469 + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard Program Selection Info */ +#define LOG_DTV_DVBH_SEC_SC_PROG_SEL_C (0x46A + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard Program Selection Complete Info */ +#define LOG_DTV_DVBH_SEC_SC_PROG_SEL_COMPLETE_C (0x46B + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard LTKM */ +#define LOG_DTV_DVBH_SEC_SC_LTKM_C (0x46C + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard LTKM Verification Message */ +#define LOG_DTV_DVBH_SEC_SC_LTKM_VERIFICATION_C (0x46D + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard Parental Control Message */ +#define LOG_DTV_DVBH_SEC_SC_PARENTAL_CTRL_C (0x46E + LOG_1X_BASE_C) + +/* DTV DVBH Security SmartCard STKM */ +#define LOG_DTV_DVBH_SEC_SC_STKM_C (0x46F + LOG_1X_BASE_C) + +/* Protocol Services Statistics Global Socket */ +#define LOG_PS_STAT_GLOBAL_SOCK_C (0x470 + LOG_1X_BASE_C) + +/* MCS Application Manager */ +#define LOG_MCS_APPMGR_C (0x471 + LOG_1X_BASE_C) + +/* MCS MSGR */ +#define LOG_MCS_MSGR_C (0x472 + LOG_1X_BASE_C) + +/* MCS QTF */ +#define LOG_MCS_QTF_C (0x473 + LOG_1X_BASE_C) + +/* Sensors Stationary Detector Output */ +#define LOG_STATIONARY_DETECTOR_OUTPUT_C (0x474 + LOG_1X_BASE_C) + +/* Print out the ppm data portion */ +#define LOG_CGPS_PDSM_EXT_STATUS_MEAS_REPORT_PPM_C (0x475 + LOG_1X_BASE_C) + +/* GNSS Position Report */ +#define LOG_GNSS_POSITION_REPORT_C (0x476 + LOG_1X_BASE_C) + +/* GNSS GPS Measurement Report */ +#define LOG_GNSS_GPS_MEASUREMENT_REPORT_C (0x477 + LOG_1X_BASE_C) + +/* GNSS Clock Report */ +#define LOG_GNSS_CLOCK_REPORT_C (0x478 + LOG_1X_BASE_C) + +/* GNSS Demod Soft Decision */ +#define LOG_GNSS_DEMOD_SOFT_DECISIONS_C (0x479 + LOG_1X_BASE_C) + +/* GNSS ME 5MS IQ sum */ +#define LOG_GNSS_ME_5MS_IQ_SUMS_C (0x47A + LOG_1X_BASE_C) + +/* GNSS CD DB report */ +#define LOG_GNSS_CD_DB_REPORT_C (0x47B + LOG_1X_BASE_C) + +/* GNSS PE WLS position report */ +#define LOG_GNSS_PE_WLS_POSITION_REPORT_C (0x47C + LOG_1X_BASE_C) + +/* GNSS PE KF position report */ +#define LOG_GNSS_PE_KF_POSITION_REPORT_C (0x47D + LOG_1X_BASE_C) + +/* GNSS PRX RF HW status report */ +#define LOG_GNSS_PRX_RF_HW_STATUS_REPORT_C (0x47E + LOG_1X_BASE_C) + +/* GNSS DRX RF HW status report */ +#define LOG_GNSS_DRX_RF_HW_STATUS_REPORT_C (0x47F + LOG_1X_BASE_C) + +/* GNSS Glonass Measurement report */ +#define LOG_GNSS_GLONASS_MEASUREMENT_REPORT_C (0x480 + LOG_1X_BASE_C) + +/* GNSS GPS HBW RXD measurement */ +#define LOG_GNSS_GPS_HBW_RXD_MEASUREMENT_C (0x481 + LOG_1X_BASE_C) + +/* GNSS PDSM position report callback */ +#define LOG_GNSS_PDSM_POSITION_REPORT_CALLBACK_C (0x482 + LOG_1X_BASE_C) + +/* ISense Request String */ +#define LOG_ISENSE_REQUEST_STR_C (0x483 + LOG_1X_BASE_C) + +/* ISense Response String */ +#define LOG_ISENSE_RESPONSE_STR_C (0x484 + LOG_1X_BASE_C) + +/* Bluetooth SOC General Log Packet*/ +#define LOG_BT_SOC_GENERAL_C (0x485 + LOG_1X_BASE_C) + +/* QCRil Call Flow */ +#define LOG_QCRIL_CALL_FLOW_C (0x486 + LOG_1X_BASE_C) + +/* CGPS Wideband FFT stats */ +#define LOG_CGPS_WB_FFT_STATS_C (0x487 + LOG_1X_BASE_C) + +/* CGPS Slow Clock Calibration Report*/ +#define LOG_CGPS_SLOW_CLOCK_CALIB_REPORT_C (0x488 + LOG_1X_BASE_C) + +/* SNS GPS TIMESTAMP */ +#define LOG_SNS_GPS_TIMESTAMP_C (0x489 + LOG_1X_BASE_C) + +/* GNSS Search Strategy Task Allocation */ +#define LOG_GNSS_SEARCH_STRATEGY_TASK_ALLOCATION_C (0x48A + LOG_1X_BASE_C) + +/* RF MC STM state */ +#define LOG_1XHDR_MC_STATE_C (0x48B + LOG_1X_BASE_C) + +/* Record in the Sparse Network DB */ +#define LOG_CGPS_SNDB_RECORD_C (0x48C + LOG_1X_BASE_C) + +/* Record removed from the DB */ +#define LOG_CGPS_SNDB_REMOVE_C (0x48D + LOG_1X_BASE_C) + +/* CGPS Reserved */ +#define LOG_GNSS_CC_PERFORMANCE_STATS_C (0x48E + LOG_1X_BASE_C) + +/* GNSS PDSM Set Paramerters */ +#define LOG_GNSS_PDSM_SET_PARAMETERS_C (0x48F + LOG_1X_BASE_C) + +/* GNSS PDSM PD Event Callback */ +#define LOG_GNSS_PDSM_PD_EVENT_CALLBACK_C (0x490 + LOG_1X_BASE_C) + +/* GNSS PDSM PA Event Callback */ +#define LOG_GNSS_PDSM_PA_EVENT_CALLBACK_C (0x491 + LOG_1X_BASE_C) + +/* CGPS Reserved */ +#define LOG_CGPS_RESERVED2_C (0x492 + LOG_1X_BASE_C) + +/* CGPS Reserved */ +#define LOG_CGPS_RESERVED3_C (0x493 + LOG_1X_BASE_C) + +/* GNSS PDSM EXT Status MEAS Report */ +#define LOG_GNSS_PDSM_EXT_STATUS_MEAS_REPORT_C (0x494 + LOG_1X_BASE_C) + +/* GNSS SM Error */ +#define LOG_GNSS_SM_ERROR_C (0x495 + LOG_1X_BASE_C) + +/* WLAN Scan */ +#define LOG_WLAN_SCAN_C (0x496 + LOG_1X_BASE_C) + +/* WLAN IBSS */ +#define LOG_WLAN_IBSS_C (0x497 + LOG_1X_BASE_C) + +/* WLAN 802.11d*/ +#define LOG_WLAN_80211D_C (0x498 + LOG_1X_BASE_C) + +/* WLAN Handoff */ +#define LOG_WLAN_HANDOFF_C (0x499 + LOG_1X_BASE_C) + +/* WLAN QoS EDCA */ +#define LOG_WLAN_QOS_EDCA_C (0x49A + LOG_1X_BASE_C) + +/* WLAN Beacon Update */ +#define LOG_WLAN_BEACON_UPDATE_C (0x49B + LOG_1X_BASE_C) + +/* WLAN Power save wow add pattern */ +#define LOG_WLAN_POWERSAVE_WOW_ADD_PTRN_C (0x49C + LOG_1X_BASE_C) + +/* WLAN WCM link metrics */ +#define LOG_WLAN_WCM_LINKMETRICS_C (0x49D + LOG_1X_BASE_C) + +/* WLAN wps scan complete*/ +#define LOG_WLAN_WPS_SCAN_COMPLETE_C (0x49E + LOG_1X_BASE_C) + +/* WLAN WPS WSC Message */ +#define LOG_WLAN_WPS_WSC_MESSAGE_C (0x49F + LOG_1X_BASE_C) + +/* WLAN WPS credentials */ +#define LOG_WLAN_WPS_CREDENTIALS_C (0x4A0 + LOG_1X_BASE_C) + +/* WLAN Linklayer stat*/ +#define LOG_WLAN_LINKLAYER_STAT_C (0x4A1 + LOG_1X_BASE_C) + +/* WLAN Qos TSpec*/ +#define LOG_WLAN_QOS_TSPEC_C (0x4A2 + LOG_1X_BASE_C) + +/* PMIC Vreg Control */ +#define LOG_PM_VREG_CONTROL_C (0x4A3 + LOG_1X_BASE_C) + +/* PMIC Vreg Level */ +#define LOG_PM_VREG_LEVEL_C (0x4A4 + LOG_1X_BASE_C) + +/* PMIC Vreg State */ +#define LOG_PM_VREG_STATE_C (0x4A5 + LOG_1X_BASE_C) + +/* CGPS SM EPH Randomization info */ +#define LOG_CGPS_SM_EPH_RANDOMIZATION_INFO_C (0x4A6 + LOG_1X_BASE_C) + +/* Audio calibration data */ +#define LOG_QACT_DATA_C (0x4A7 + LOG_1X_BASE_C) + +/* Compass 2D Tracked Calibration Set */ +#define LOG_SNS_VCPS_2D_TRACKED_CAL_SET (0x4A8 + LOG_1X_BASE_C) + +/* Compass 3D Tracked Calibration Set */ +#define LOG_SNS_VCPS_3D_TRACKED_CAL_SET (0x4A9 + LOG_1X_BASE_C) + +/* Calibration metric */ +#define LOG_SNS_VCPS_CAL_METRIC (0x4AA + LOG_1X_BASE_C) + +/* Accelerometer distance */ +#define LOG_SNS_VCPS_ACCEL_DIST (0x4AB + LOG_1X_BASE_C) + +/* Plane update */ +#define LOG_SNS_VCPS_PLANE_UPDATE (0x4AC + LOG_1X_BASE_C) + +/* Location report */ +#define LOG_SNS_VCPS_LOC_REPORT (0x4AD + LOG_1X_BASE_C) + +/* CM Active subscription */ +#define LOG_CM_PH_EVENT_SUBSCRIPTION_PREF_INFO_C (0x4AE + LOG_1X_BASE_C) + +/* DSDS version of CM call event */ +#define LOG_CM_DS_CALL_EVENT_C (0x4AF + LOG_1X_BASE_C) + +/* Sensors ?MobiSens Output */ +#define LOG_MOBISENS_OUTPUT_C (0x4B0 + LOG_1X_BASE_C) + +/* Accelerometer Data */ +#define LOG_ACCEL_DATA_C (0x4B1 + LOG_1X_BASE_C) + +/* Accelerometer Compensated Data */ +#define LOG_ACCEL_COMP_DATA_C (0x4B2 + LOG_1X_BASE_C) + +/* Motion State Data */ +#define LOG_MOTION_STATE_DATA_C (0x4B3 + LOG_1X_BASE_C) + +/* Stationary Position Indicator */ +#define LOG_STAT_POS_IND_C (0x4B4 + LOG_1X_BASE_C) + +/* Motion State Features */ +#define LOG_MOTION_STATE_FEATURES_C (0x4B5 + LOG_1X_BASE_C) + +/* Motion State Hard Decision */ +#define LOG_MOTION_STATE_HARD_DECISION_C (0x4B6 + LOG_1X_BASE_C) + +/* Motion State Soft Decision */ +#define LOG_MOTION_STATE_SOFT_DECISION_C (0x4B7 + LOG_1X_BASE_C) + +/* Sensors Software Version */ +#define LOG_SENSORS_SOFTWARE_VERSION_C (0x4B8 + LOG_1X_BASE_C) + +/* MobiSens Stationary Position Indicator Log Packet */ +#define LOG_MOBISENS_SPI_C (0x4B9 + LOG_1X_BASE_C) + +/* XO calibration raw IQ data */ +#define LOG_XO_IQ_DATA_C (0x4BA + LOG_1X_BASE_C) + +/*DTV CMMB Control Tabl Updated*/ +#define LOG_DTV_CMMB_CONTROL_TABLE_UPDATE ((0x4BB) + LOG_1X_BASE_C) + +/*DTV CMMB Media API Buffering Status*/ +#define LOG_DTV_CMMB_MEDIA_BUFFERING_STATUS ((0x4BC) + LOG_1X_BASE_C) + +/*DTV CMMB *Emergency Broadcast Data*/ +#define LOG_DTV_CMMB_CONTROL_EMERGENCY_BCAST ((0x4BD) + LOG_1X_BASE_C) + +/*DTV CMMB EMM/ECM Data*/ +#define LOG_DTV_CMMB_CAS_EMM_ECM ((0x4BE) + LOG_1X_BASE_C) + +/*DTV CMMB HW Status*/ +#define LOG_DTV_CMMB_HW_PERFORMANCE ((0x4BF) + LOG_1X_BASE_C) + +/*DTV CMMB ESSG Program Indication Information*/ +#define LOG_DTV_CMMB_ESG_PROGRAM_INDICATION_INFORMATION ((0x4C0) + LOG_1X_BASE_C) + +/* Sensors ¨C binary output of converted sensor data */ +#define LOG_CONVERTED_SENSOR_DATA_C ((0x4C1) + LOG_1X_BASE_C) + +/* CM Subscription event */ +#define LOG_CM_SUBSCRIPTION_EVENT_C ((0x4C2) + LOG_1X_BASE_C) + +/* Sensor Ambient Light Data */ +#define LOG_SNS_ALS_DATA_C ((0x4C3) + LOG_1X_BASE_C) + +/*Sensor Ambient Light Adaptive Data */ +#define LOG_SNS_ALS_DATA_ADAPTIVE_C ((0x4C4) + LOG_1X_BASE_C) + +/*Sensor Proximity Distance Data */ +#define LOG_SNS_PRX_DIST_DATA_C ((0x4C5) + LOG_1X_BASE_C) + +/*Sensor Proximity Data */ +#define LOG_SNS_PRX_DATA_C ((0x4C6) + LOG_1X_BASE_C) + +#define LOG_GNSS_SBAS_REPORT_C ((0x4C7) + LOG_1X_BASE_C) + +#define LOG_CPU_MONITOR_MODEM_C ((0x4C8) + LOG_1X_BASE_C) + +#define LOG_CPU_MONITOR_APPS_C ((0x4C9) + LOG_1X_BASE_C) + +#define LOG_BLAST_TASKPROFILE_C ((0x4CA) + LOG_1X_BASE_C) + +#define LOG_BLAST_SYSPROFILE_C ((0x4CB) + LOG_1X_BASE_C) +/* Aliasing instead of replacing to keep backwards compatibility */ +#define LOG_QURT_SYSPROFILE_C (LOG_BLAST_SYSPROFILE_C) + +#define LOG_FM_RADIO_FTM_C ((0x4CC) + LOG_1X_BASE_C) + +#define LOG_FM_RADIO_C ((0x4CD) + LOG_1X_BASE_C) + +#define LOG_UIM_DS_DATA_C ((0x4CE) + LOG_1X_BASE_C) + +#define LOG_QMI_CALL_FLOW_C ((0x4CF) + LOG_1X_BASE_C) + +#define LOG_APR_MODEM_C ((0x4D0) + LOG_1X_BASE_C) + +#define LOG_APR_APPS_C ((0x4D1) + LOG_1X_BASE_C) + +#define LOG_APR_ADSP_C ((0x4D2) + LOG_1X_BASE_C) + +#define LOG_DATA_MUX_RX_RAW_PACKET_C ((0x4D3) + LOG_1X_BASE_C) + +#define LOG_DATA_MUX_TX_RAW_PACKET_C ((0x4D4) + LOG_1X_BASE_C) + +#define LOG_DATA_MUX_RX_FRAME_PACKET_C ((0x4D5) + LOG_1X_BASE_C) + +#define LOG_DATA_MUX_TX_FRAME_PACKET_C ((0x4D6) + LOG_1X_BASE_C) + +#define LOG_CGPS_PDSM_EXT_STATUS_POS_INJ_REQ_INFO_C ((0x4D7) + LOG_1X_BASE_C) + +#define LOG_TEMPERATURE_MONITOR_C ((0x4D8) + LOG_1X_BASE_C) + +#define LOG_SNS_GESTURES_REST_DETECT_C ((0x4D9) + LOG_1X_BASE_C) + +#define LOG_SNS_GESTURES_ORIENTATION_C ((0x4DA) + LOG_1X_BASE_C) + +#define LOG_SNS_GESTURES_FACING_C ((0x4DB) + LOG_1X_BASE_C) + +#define LOG_SNS_GESTURES_BASIC_C ((0x4DC) + LOG_1X_BASE_C) + +#define LOG_SNS_GESTURES_HINBYE_C ((0x4DD) + LOG_1X_BASE_C) + +#define LOG_GNSS_OEMDRE_MEASUREMENT_REPORT_C ((0x4DE) + LOG_1X_BASE_C) + +#define LOG_GNSS_OEMDRE_POSITION_REPORT_C ((0x4E0) + LOG_1X_BASE_C) + +#define LOG_GNSS_OEMDRE_SVPOLY_REPORT_C ((0x4E1) + LOG_1X_BASE_C) + +#define LOG_GNSS_OEMDRSYNC_C ((0x4E2) + LOG_1X_BASE_C) + +#define LOG_SNS_MGR_EVENT_NOTIFY_C ((0x4E3) + LOG_1X_BASE_C) + +#define LOG_SNS_MGR_EVENT_REGISTER_C ((0x4E4) + LOG_1X_BASE_C) + +#define LOG_GNSS_PDSM_PPM_SESSION_BEGIN_C ((0x4E5) + LOG_1X_BASE_C) + +#define LOG_GNSS_PDSM_PPM_SESSION_PPM_SUSPEND_C ((0x4E6) + LOG_1X_BASE_C) + +#define LOG_GNSS_PDSM_PPM_REPORT_THROTTLED_C ((0x4E7) + LOG_1X_BASE_C) + +#define LOG_GNSS_PDSM_PPM_REPORT_FIRED_C ((0x4E8) + LOG_1X_BASE_C) + +#define LOG_GNSS_PDSM_PPM_SESSION_END_C ((0x4E9) + LOG_1X_BASE_C) + +#define LOG_SNS_REGISTRY_OPERATION_C ((0x4EA) + LOG_1X_BASE_C) + +#define LOG_WMK_TRACE_C ((0x4EB) + LOG_1X_BASE_C) + +#define LOG_1X_ADV_FET_STATS_C ((0x4EC) + LOG_1X_BASE_C) + +#define LOG_1X_ADV_L1_PERF_C ((0x4ED) + LOG_1X_BASE_C) + +#define LOG_AUDIO_VOCODER_STREAM_DATA_PATH_C ((0x4EE) + LOG_1X_BASE_C) + +#define LOG_BLAST_PM_C ((0x4EF) + LOG_1X_BASE_C) + +#define LOG_SNS_SENSOR1_REQUEST_C ((0x4F0) + LOG_1X_BASE_C) + +#define LOG_SNS_SENSOR1_RESPONSE_C ((0x4F1) + LOG_1X_BASE_C) + +#define LOG_SNS_SENSOR1_INDICATION_C ((0x4F2) + LOG_1X_BASE_C) + +#define LOG_SNS_SMR_REQUEST_C ((0x4F3) + LOG_1X_BASE_C) + +#define LOG_SNS_SMR_RESPONSE_C ((0x4F4) + LOG_1X_BASE_C) + +#define LOG_SNS_SMR_INDICATION_C ((0x4F5) + LOG_1X_BASE_C) + +#define LOG_INTERNAL_TX_AUDIO_PCM_ADSP_C ((0x4F6) + LOG_1X_BASE_C) + +#define LOG_INTERNAL_RX_AUDIO_PCM_ADSP_C ((0x4F7) + LOG_1X_BASE_C) + +#define LOG_EXTERNAL_TX_AUDIO_PCM_ADSP_C ((0x4F8) + LOG_1X_BASE_C) + +#define LOG_EXTERNAL_RX_AUDIO_PCM_ADSP_C ((0x4F9) + LOG_1X_BASE_C) + +#define LOG_FM_RX_AUDIO_PCM_ADSP_C ((0x4FA) + LOG_1X_BASE_C) + +#define LOG_HDMI_RX_AUDIO_PCM_ADSP_C ((0x4FB) + LOG_1X_BASE_C) + +#define LOG_TLM_SNDB_RECORD_C ((0x4FC) + LOG_1X_BASE_C) + +#define LOG_TLM_CELLDB_RECORD_C ((0x4FD) + LOG_1X_BASE_C) + +#define LOG_TLM_OPS_MEASUREMENTS_C ((0x4FE) + LOG_1X_BASE_C) + +#define LOG_TLM_MOBILE_STATUS_HEADER_C ((0x4FF) + LOG_1X_BASE_C) + +#define LOG_TLM_MOBILE_STATUS_DATA_C ((0x500) + LOG_1X_BASE_C) + +#define LOG_TLM_XTA_PARTITION_C ((0x501) + LOG_1X_BASE_C) + +#define LOG_TLM_CLIENT_DOWNLOAD_DATA_C ((0x502) + LOG_1X_BASE_C) + +#define LOG_XTM_XTA_MSG_WRITE_C ((0x503) + LOG_1X_BASE_C) + +#define LOG_XTM_XTA_MSG_READ_C ((0x504) + LOG_1X_BASE_C) + +#define LOG_XTM_HTTP_RESPONSE_STATUS_C ((0x505) + LOG_1X_BASE_C) + +#define LOG_XTM_XTA_RESPONSE_STATUS_C ((0x506) + LOG_1X_BASE_C) + +#define LOG_TLM_FAILED_LOOKUP_C ((0x507) + LOG_1X_BASE_C) + +#define LOG_SENSORS_SDP_VIRGO ((0x508) + LOG_1X_BASE_C) + +#define LOG_SENSORS_SDP_SSD ((0x509) + LOG_1X_BASE_C) + +#define LOG_SENSORS_SDP_CRD ((0x50A) + LOG_1X_BASE_C) + +#define LOG_SENSORS_SDP_TIME_SYNC ((0x50B) + LOG_1X_BASE_C) + +#define LOG_SENSORS_SDP_MSD ((0x50C) + LOG_1X_BASE_C) + +#define LOG_GNSS_SENSOR_STREAMING_READY_STATUS ((0x50D) + LOG_1X_BASE_C) + +#define LOG_GNSS_TIME_SYNC_REQ ((0x50E) + LOG_1X_BASE_C) + +#define LOG_GNSS_INJECT_TIME_SYNC_DATA ((0x50F) + LOG_1X_BASE_C) + +#define LOG_GNSS_INJECT_SENSOR_DATA ((0x510) + LOG_1X_BASE_C) + +#define LOG_GNSS_GET_SENSOR_CONFIG_RESPONSE ((0x511) + LOG_1X_BASE_C) + +#define LOG_GNSS_SET_SENSOR_CONFIG ((0x512) + LOG_1X_BASE_C) + +#define LOG_GNSS_PE_HEADING_FILTER ((0x513) + LOG_1X_BASE_C) + +#define LOG_GNSS_PE_NHC ((0x514) + LOG_1X_BASE_C) + +#define LOG_GNSS_PE_CRD ((0x515) + LOG_1X_BASE_C) + +/* The below two logs are the same. This is done so we don't break any build that + is using the older name (LOG_GNSS_PE_RESERVED) */ +#define LOG_GNSS_PE_RESERVED ((0x516) + LOG_1X_BASE_C) + +#define LOG_GNSS_CONFIGURATION_STATE_C ((0x516) + LOG_1X_BASE_C) + +#define LOG_HSU_HEALTH_TXTHROUGHPUT_C ((0x517) + LOG_1X_BASE_C) + +#define LOG_HSU_HEALTH_RXTHROUGHPUT_C ((0x518) + LOG_1X_BASE_C) + +#define LOG_GNSS_YAW_GYRO_CALIBRATION ((0x519) + LOG_1X_BASE_C) + +#define LOG_SENSORS_SDP_INTERNAL ((0x51A) + LOG_1X_BASE_C) + +#define LOG_SNS_DSPS_PWR_C ((0x51B) + LOG_1X_BASE_C) + +#define LOG_SNS_RAW_I2C_DATA_C ((0x51C) + LOG_1X_BASE_C) + +#define LOG_SNS_QMD_CONFIG_C ((0x51D) + LOG_1X_BASE_C) + +#define LOG_SNS_QMD_RESULT_C ((0x51E) + LOG_1X_BASE_C) + +#define LOG_SNS_QMD_REPORT_C ((0x51F) + LOG_1X_BASE_C) + +#define LOG_GNSS_BP_AMP_INFO_C ((0x520) + LOG_1X_BASE_C) + +#define LOG_CORE_AUDIO_DRIVER_DATA_C ((0x521) + LOG_1X_BASE_C) + +#define LOG_CORE_AUDIO_DRIVER_CONTROL_C ((0x522) + LOG_1X_BASE_C) + +#define LOG_SNS_FNS_CONFIG_C ((0x523) + LOG_1X_BASE_C) + +#define LOG_SNS_FNS_RESULT_C ((0x524) + LOG_1X_BASE_C) + +#define LOG_SNS_FNS_REPORT_C ((0x525) + LOG_1X_BASE_C) + +#define LOG_GNSS_BROADBAND_JAMMER_INFO_C ((0x526) + LOG_1X_BASE_C) + +#define LOG_ADSP_PERFMON_C ((0x527) + LOG_1X_BASE_C) + +#define LOG_SNS_BTE_CONFIG_C ((0x528) + LOG_1X_BASE_C) + +#define LOG_SNS_BTE_RESULT_C ((0x529) + LOG_1X_BASE_C) + +#define LOG_SNS_BTE_REPORT_C ((0x52A) + LOG_1X_BASE_C) + +#define LOG_SNS_GYRO_SIMP_CAL_CONFIG_C ((0x52B) + LOG_1X_BASE_C) + +#define LOG_SNS_GYRO_SIMP_CAL_RESULT_C ((0x52C) + LOG_1X_BASE_C) + +#define LOG_SNS_GYRO_SIMP_CAL_REPORT_C ((0x52D) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_DEC_IN_C ((0x52E) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_POPP_IN_C ((0x52F) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_MTMX_RX_IN_C ((0x530) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_COPP_IN_C ((0x531) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_COPREP_IN_C ((0x532) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_MTMX_TX_IN_C ((0x533) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_POPREP_IN_C ((0x534) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_ENC_IN_C ((0x535) + LOG_1X_BASE_C) + +#define LOG_ADSP_AUD_ENC_OUT_C ((0x536) + LOG_1X_BASE_C) + +#define LOG_QTV_HTTP_BUFFER_OCCUPANCY_C ((0x537) + LOG_1X_BASE_C) + +#define LOG_QTV_HTTP_INCOMING_DATARATE_C ((0x538) + LOG_1X_BASE_C) + +#define LOG_QTV_HTTP_DOWNLOAD_BITRATE_SWITCH_C ((0x539) + LOG_1X_BASE_C) + +#define LOG_QTV_HTTP_PLAYBACK_BITRATE_SWITCH_C ((0x53A) + LOG_1X_BASE_C) + +#define LOG_DS_EPC_PDN_INFO_C ((0x53B) + LOG_1X_BASE_C) + +#define LOG_SNS_QUAT_CONFIG_C ((0x53C) + LOG_1X_BASE_C) + +#define LOG_SNS_QUAT_RESULT_C ((0x53D) + LOG_1X_BASE_C) + +#define LOG_SNS_QUAT_REPORT_C ((0x53E) + LOG_1X_BASE_C) + +#define LOG_SNS_GRAVITY_CONFIG_C ((0x53F) + LOG_1X_BASE_C) + +#define LOG_SNS_GRAVITY_RESULT_C ((0x540) + LOG_1X_BASE_C) + +#define LOG_SNS_GRAVITY_REPORT_C ((0x541) + LOG_1X_BASE_C) + +#define LOG_SENSOR_FULL_CALIBRATION_C ((0x542) + LOG_1X_BASE_C) + +#define LOG_QCHATUPK_C ((0x543) + LOG_1X_BASE_C) + +#define LOG_MCS_QCSI_PKT ((0x544) + LOG_1X_BASE_C) + +#define LOG_QBI_RX_CONTEXT_0_C ((0x545) + LOG_1X_BASE_C) + +#define LOG_QBI_TX_CONTEXT_0_C ((0x546) + LOG_1X_BASE_C) + +#define LOG_QBI_RX_CONTEXT_1_C ((0x547) + LOG_1X_BASE_C) + +#define LOG_QBI_TX_CONTEXT_1_C ((0x548) + LOG_1X_BASE_C) + +#define LOG_QBI_RX_CONTEXT_2_C ((0x549) + LOG_1X_BASE_C) + +#define LOG_QBI_TX_CONTEXT_2_C ((0x54A) + LOG_1X_BASE_C) + +#define LOG_QBI_RX_CONTEXT_3_C ((0x54B) + LOG_1X_BASE_C) + +#define LOG_QBI_TX_CONTEXT_3_C ((0x54C) + LOG_1X_BASE_C) + +#define LOG_QBI_RX_CONTEXT_4_C ((0x54D) + LOG_1X_BASE_C) + +#define LOG_QBI_TX_CONTEXT_4_C ((0x54E) + LOG_1X_BASE_C) + +#define LOG_QBI_RX_CONTEXT_5_C ((0x54F) + LOG_1X_BASE_C) + +#define LOG_QBI_TX_CONTEXT_5_C ((0x550) + LOG_1X_BASE_C) + +#define LOG_QBI_RX_CONTEXT_6_C ((0x551) + LOG_1X_BASE_C) + +#define LOG_QBI_TX_CONTEXT_6_C ((0x552) + LOG_1X_BASE_C) + +#define LOG_QBI_RX_CONTEXT_7_C ((0x553) + LOG_1X_BASE_C) + +#define LOG_QBI_TX_CONTEXT_7_C ((0x554) + LOG_1X_BASE_C) + +#define LOG_WMGR_C ((0x555) + LOG_1X_BASE_C) + +#define LOG_DS_MEMORY_PACKETS ((0x556) + LOG_1X_BASE_C) + +#define LOG_MMODE_CALL_FLOW_C ((0x557) + LOG_1X_BASE_C) + +#define LOG_WCNSS_AUDIO_DATA_C ((0x558) + LOG_1X_BASE_C) + +#define LOG_SNS_DRV_MD_IRQ_C ((0x559) + LOG_1X_BASE_C) + +#define LOG_SNS_MAG_CAL_CONFIG_C ((0x55A) + LOG_1X_BASE_C) + +#define LOG_SNS_MAG_CAL_RESULT_C ((0x55B) + LOG_1X_BASE_C) + +#define LOG_SNS_MAG_CAL_REPORT_C ((0x55C) + LOG_1X_BASE_C) + +#define LOG_GNSS_QUIPS_POSITION_REPORT_C ((0x55D) + LOG_1X_BASE_C) + +#define LOG_GNSS_QUIPS_AP_MEAS_BLOCKS_C ((0x55E) + LOG_1X_BASE_C) + +#define LOG_SNS_ROTATION_VECTOR_CONFIG_C ((0x55F) + LOG_1X_BASE_C) + +#define LOG_SNS_ROTATION_VECTOR_RESULT_C ((0x560) + LOG_1X_BASE_C) + +#define LOG_SNS_ROTATION_VECTOR_REPORT_C ((0x561) + LOG_1X_BASE_C) + +#define LOG_SNS_FMV_CONFIG_C ((0x562) + LOG_1X_BASE_C) + +#define LOG_SNS_FMV_QUAT_UPDATE_C ((0x563) + LOG_1X_BASE_C) + +#define LOG_SNS_FMV_MAG_UPDATE_C ((0x564) + LOG_1X_BASE_C) + +#define LOG_SNS_FMV_GYRO_UPDATE_C ((0x565) + LOG_1X_BASE_C) + +#define LOG_SNS_FMV_REPORT_C ((0x566) + LOG_1X_BASE_C) + +#define LOG_GNSS_FAST_TCAL_C ((0x567) + LOG_1X_BASE_C) + +#define LOG_IMS_RTP_SN_AND_PAYLOAD_LOG_PACKET_C ((0x568) + LOG_1X_BASE_C) + +#define LOG_IMS_RTP_PACKET_LOSS_C ((0x569) + LOG_1X_BASE_C) + +#define LOG_IMS_RTCP_PACKET_C ((0x56A) + LOG_1X_BASE_C) + +#define LOG_IMS_QDJ_ENQUEUE_C ((0x56B) + LOG_1X_BASE_C) + +#define LOG_IMS_QDJ_DEQUEUE_C ((0x56C) + LOG_1X_BASE_C) + +#define LOG_IMS_QDJ_UPDATE_C ((0x56D) + LOG_1X_BASE_C) + +#define LOG_IMS_MESSAGE_C ((0x56E) + LOG_1X_BASE_C) + +#define LOG_GNSS_QUIPS_IN_USE_AP_DATABASE_C ((0x56F) + LOG_1X_BASE_C) + +#define LOG_CGPS_PRS_OCCASION_MEAS_C ((0x570) + LOG_1X_BASE_C) + +#define LOG_IMS_AMR_REDUNDANCY ((0x571) + LOG_1X_BASE_C) + +#define LOG_DATA_PROTOCOL_LOGGING_NETWORK_IP_RM_TX_80_BYTES_C ((0x572) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_NETWORK_IP_RM_RX_80_BYTES_C ((0x573) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_NETWORK_IP_RM_TX_FULL_C ((0x574) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_NETWORK_IP_RM_RX_FULL_C ((0x575) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_NETWORK_IP_UM_TX_80_BYTES_C ((0x576) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_NETWORK_IP_UM_RX_80_BYTES_C ((0x577) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_NETWORK_IP_UM_TX_FULL_C ((0x578) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_NETWORK_IP_UM_RX_FULL_C ((0x579) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_LINK_RM_TX_80_BYTES_C ((0x57A) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_LINK_RM_RX_80_BYTES_C ((0x57B) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_LINK_RM_TX_FULL_C ((0x57C) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_LINK_RM_RX_FULL_C ((0x57D) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_LINK_UM_TX_80_BYTES_C ((0x57E) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_LINK_UM_RX_80_BYTES_C ((0x57F) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_LINK_UM_TX_FULL_C ((0x580) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_LINK_UM_RX_FULL_C ((0x581) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_FLOW_RM_TX_80_BYTES_C ((0x582) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_FLOW_RM_TX_FULL_C ((0x583) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_FLOW_UM_TX_80_BYTES_C ((0x584) + LOG_1X_BASE_C) +#define LOG_DATA_PROTOCOL_LOGGING_FLOW_UM_TX_FULL_C ((0x585) + LOG_1X_BASE_C) + +#define LOG_ADSP_AFE_PCM_RX_TX_C ((0x586) + LOG_1X_BASE_C) + +#define LOG_GNSS_PE_EVENTS_C ((0x587) + LOG_1X_BASE_C) + +#define LOG_QMI_SUPPORTED_INTERFACES_C ((0x588) + LOG_1X_BASE_C) + +#define LOG_GNSS_ISAGNAV_SDP_EVENTS_C ((0x589) + LOG_1X_BASE_C) +/* Aliasing instead of replacing to keep backwards compatibility */ +#define LOG_GNSS_SAP_SDP_EVENTS_C (LOG_GNSS_ISAGNAV_SDP_EVENTS_C) + +#define LOG_ADSP_VCP_VOICEPROC_RX_TX_C ((0x58A) + LOG_1X_BASE_C) +#define LOG_ADSP_VCP_VOICESTRM_RX_TX_C ((0x58B) + LOG_1X_BASE_C) + +#define LOG_XOADC_C ((0x58C) + LOG_1X_BASE_C) + +#define LOG_FM_RADIO_HCI_COMMAND_C ((0x58D) + LOG_1X_BASE_C) +#define LOG_FM_RADIO_HCI_EVENT_C ((0x58E) + LOG_1X_BASE_C) + +#define LOG_SNS_TIME_SERVICE_OFFSETS_C ((0x58F) + LOG_1X_BASE_C) + +#define LOG_CXM_CP_BT_MSG_C ((0x590) + LOG_1X_BASE_C) +#define LOG_CXM_CP_WLAN_MSG_C ((0x591) + LOG_1X_BASE_C) +#define LOG_CXM_CP_LTE_MSG_C ((0x592) + LOG_1X_BASE_C) +#define LOG_CXM_DP_BT_MSG_C ((0x593) + LOG_1X_BASE_C) +#define LOG_CXM_DP_WLAN_MSG_C ((0x594) + LOG_1X_BASE_C) +#define LOG_CXM_DP_LTE_MSG_C ((0x595) + LOG_1X_BASE_C) + +#define LOG_GNSS_WWAN_WLAN_IMD_JAMMER_STATUS_C ((0x596) + LOG_1X_BASE_C) + +#define LOG_TCXOMGR_IFC_SUMMARY_C ((0x597) + LOG_1X_BASE_C) +#define LOG_TCXOMGR_IFC_RPUSH_C ((0x598) + LOG_1X_BASE_C) + +#define LOG_LOC_LTE_OTDOA_PRS_RSTD_MEAS_C ((0x599) + LOG_1X_BASE_C) +#define LOG_LOC_LTE_OTDOA_PRS_TOA_MEAS_C ((0x59A) + LOG_1X_BASE_C) + +#define LOG_INTEG_ANGLE_CONFIG_C ((0x59B) + LOG_1X_BASE_C) +#define LOG_INTEG_ANGLE_RESULT_C ((0x59C) + LOG_1X_BASE_C) +#define LOG_INTEG_ANGLE_REPORT_C ((0x59D) + LOG_1X_BASE_C) + +#define LOG_GTAP_CONFIG_C ((0x59E) + LOG_1X_BASE_C) +#define LOG_GTAP_RESULT_C ((0x59F) + LOG_1X_BASE_C) +#define LOG_GTAP_REPORT_C ((0x5A0) + LOG_1X_BASE_C) + +#define LOG_SNS_BASIC_GESTURES_CONFIG_C ((0x5A1) + LOG_1X_BASE_C) +#define LOG_SNS_BASIC_GESTURES_RESULT_C ((0x5A2) + LOG_1X_BASE_C) +#define LOG_SNS_BASIC_GESTURES_REPORT_C ((0x5A3) + LOG_1X_BASE_C) + +#define LOG_SNS_FACING_CONFIG_C ((0x5A4) + LOG_1X_BASE_C) +#define LOG_SNS_FACING_RESULT_C ((0x5A5) + LOG_1X_BASE_C) +#define LOG_SNS_FACING_REPORT_C ((0x5A6) + LOG_1X_BASE_C) + +#define LOG_CLKRGM_DRIVER_CLOCKS_C ((0x5A7) + LOG_1X_BASE_C) + +#define LOG_TIME_TOD_ERROR_NOTIFY_C ((0x5A8) + LOG_1X_BASE_C) + +#define LOG_SNS_ALGO_INPUT_C ((0x5A9) + LOG_1X_BASE_C) + +#define LOG_GYROINT_CONFIG_C ((0x5AA) + LOG_1X_BASE_C) +#define LOG_GYROINT_UPDATE_C ((0x5AB) + LOG_1X_BASE_C) +#define LOG_GYROINT_REPORT_C ((0x5AC) + LOG_1X_BASE_C) +#define LOG_GYROINT_REPORT_REQ_C ((0x5AD) + LOG_1X_BASE_C) +#define LOG_GYROBUF_CONFIG_C ((0x5AE) + LOG_1X_BASE_C) +#define LOG_GYROBUF_REPORT_REQ_C ((0x5AF) + LOG_1X_BASE_C) +#define LOG_GYROBUF_REPORT_C ((0x5B0) + LOG_1X_BASE_C) + +#define LOG_GNSS_PDSM_BEST_AVAIL_POS_INFO_C ((0x5B1) + LOG_1X_BASE_C) +#define LOG_GNSS_PDSM_EXT_STATUS_BEST_AVAIL_POS_INFO_C ((0x5B2) + LOG_1X_BASE_C) + +#define LOG_KERNEL_TASKPROFILE_V3_C ((0x5B3) + LOG_1X_BASE_C) +#define LOG_KERNEL_SYSPROFILE_V3_C ((0x5B4) + LOG_1X_BASE_C) + +#define LOG_SYSTEMPROFILING_ID_LOOKUP_C ((0x5B5) + LOG_1X_BASE_C) +#define LOG_SYSTEM_PROFILING_C ((0x5B6) + LOG_1X_BASE_C) + +#define LOG_DS_3GPP_EVENT_C ((0x5B7) + LOG_1X_BASE_C) + +#define LOG_SNS_ACCEL_CAL_CONFIG_C ((0x5B8) + LOG_1X_BASE_C) +#define LOG_SNS_ACCEL_CAL_RESULT_C ((0x5B9) + LOG_1X_BASE_C) +#define LOG_SNS_ACCEL_CAL_REPORT_C ((0x5BA) + LOG_1X_BASE_C) + +#define GNSS_SOC_RFDEV_MSGS ((0x5BB) + LOG_1X_BASE_C) +#define GNSS_SOC_UBP_MSGS ((0x5BC) + LOG_1X_BASE_C) + +#define LOG_TCXOMGR_RGS_C ((0x5BD) + LOG_1X_BASE_C) + +#define LOG_RFIC_PMIC_STATUS_C ((0x5BE) + LOG_1X_BASE_C) + +#define LOG_HDR_RF_WARMUP_C ((0x5BF) + LOG_1X_BASE_C) +#define LOG_HDR_RF_PWR_LMT_C ((0x5C0) + LOG_1X_BASE_C) +#define LOG_HDR_RF_STATE_C ((0x5C1) + LOG_1X_BASE_C) +#define LOG_HDR_RF_SLEEP_C ((0x5C2) + LOG_1X_BASE_C) +#define LOG_HDR_RF_TX_STATE_C ((0x5C3) + LOG_1X_BASE_C) +#define LOG_HDR_RF_INT_STATE_C ((0x5C4) + LOG_1X_BASE_C) +#define LOG_HDR_RF_LNA_SWITCHP_C ((0x5C5) + LOG_1X_BASE_C) +#define LOG_HDR_RF_RX_CAL_C ((0x5C6) + LOG_1X_BASE_C) +#define LOG_HDR_RF_API_C ((0x5C7) + LOG_1X_BASE_C) +#define LOG_HDR_RF_RX_PLL_LOCK_C ((0x5C8) + LOG_1X_BASE_C) +#define LOG_HDR_RF_RX_QUALITY_C ((0x5C9) + LOG_1X_BASE_C) +#define LOG_1X_RF_RX_QUALITY_C ((0x5CA) + LOG_1X_BASE_C) + +#define LOG_IMS_VDJ_ENQUEUE_C ((0x5CB) + LOG_1X_BASE_C) +#define LOG_IMS_VDJ_DEQUEUE_C ((0x5CC) + LOG_1X_BASE_C) + +#define LOG_LOC_WWAN_MEDB_DUMP_C ((0x5CD) + LOG_1X_BASE_C) +/* 0x15CE -- 0x1632 a total of 100 log codes are reserved for 1x and DO */ +#define LOG_FW_CDMA1X_DEMFRONT_C ((0x601) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_RX_TIMING_C ((0x602) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_FINGER_STATE_MACHINE_C ((0x603) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_DEMFRONT_FINGER_CONFIG_C ((0x605) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_RXAGC_1_6_PCG_C ((0x608) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_RXAGC_1_12_PCG_C ((0x609) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_RPC_C ((0x610) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_FL_ACK_C ((0x611) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_RX_DS_DX_C ((0x615) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_FL_DRX_C ((0x616) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_TX_1_2_PCG_C ((0x618) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_TX_PER_UPDATE_C ((0x619) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_TX_FRAME_CONFIG_C ((0x61C) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_I_Q_SAMPLE_DUMP_C ((0x620) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_AFC_C ((0x630) + LOG_1X_BASE_C) +#define LOG_FW_CDMA1X_RX_SYNC_C ((0x631) + LOG_1X_BASE_C) + +#define LOG_IMS_AVPF_FEEDBACK_C ((0x633) + LOG_1X_BASE_C) +#define LOG_GNSS_SPECTRUM_ANALYZER_SCAN_PARAMS_C ((0x634) + LOG_1X_BASE_C) +#define LOG_GNSS_SPECTRUM_ANALYZER_JAMMER_MEASUREMENTS_C ((0x635) + LOG_1X_BASE_C) +#define LOG_GNSS_SPECTRUM_ANALYZER_NOTCH_ASSIGNMENT_C ((0x636) + LOG_1X_BASE_C) +#define LOG_SNS_PED_CONFIG_C ((0x637) + LOG_1X_BASE_C) +#define LOG_SNS_PED_RESULT_C ((0x638) + LOG_1X_BASE_C) +#define LOG_SNS_PED_REPORT_C ((0x639) + LOG_1X_BASE_C) +#define LOG_SNS_QMAG_CAL_CONFIG_C ((0x63A) + LOG_1X_BASE_C) +#define LOG_SNS_QMAG_CAL_RESULT_C ((0x63B) + LOG_1X_BASE_C) +#define LOG_SNS_QMAG_CAL_REPORT_C ((0x63C) + LOG_1X_BASE_C) +#define LOG_GNSS_ME_PQME1_C ((0x63D) + LOG_1X_BASE_C) +#define LOG_GNSS_ME_PQME2_C ((0x63E) + LOG_1X_BASE_C) +#define LOG_GNSS_ME_PQME3_C ((0x63F) + LOG_1X_BASE_C) +#define LOG_PAM_CONFIG_C ((0x640) + LOG_1X_BASE_C) +#define LOG_PAM_RESULT_C ((0x641) + LOG_1X_BASE_C) +#define LOG_PAM_REPORT_C ((0x642) + LOG_1X_BASE_C) +#define LOG_MCS_QCSI_EVENT_PKT ((0x643) + LOG_1X_BASE_C) +#define LOG_QURT_TASKPROFILE_C ((0x644) + LOG_1X_BASE_C) +#define LOG_QURT_PM_C ((0x645) + LOG_1X_BASE_C) +#define LOG_TCXOMGR_RGS_RETRIEVAL_C ((0x646) + LOG_1X_BASE_C) +#define LOG_LOC_LTE_OTDOA_ASSIST_DATA_C ((0x647) + LOG_1X_BASE_C) + +/* 1648-1747 Indoor reserved log codes */ +#define LOG_INDOOR_RESERVED_CODES_BASE_C ((0x648) + LOG_1X_BASE_C) +#define LOG_INDOOR_INFO (LOG_INDOOR_RESERVED_CODES_BASE_C) /*0x1648*/ +#define LOG_INDOOR_RTS_CTS_SCAN (1 + LOG_INDOOR_RESERVED_CODES_BASE_C) /*0x1649*/ +#define LOG_INDOOR_ACTIVE_SCAN (2 + LOG_INDOOR_RESERVED_CODES_BASE_C) /*0x1650*/ +#define LOG_INDOOR_IPE_IPC_DATA_C (3 + LOG_INDOOR_RESERVED_CODES_BASE_C) +#define LOG_INDOOR_SDP_IPC_DATA_C (4 + LOG_INDOOR_RESERVED_CODES_BASE_C) +#define LOG_INDOOR_IMC_IPC_DATA_C (5 + LOG_INDOOR_RESERVED_CODES_BASE_C) +#define LOG_INDOOR_IWMM_IPC_DATA_C (6 + LOG_INDOOR_RESERVED_CODES_BASE_C) + +#define LOG_INDOOR_LAST_C (99 + LOG_INDOOR_RESERVED_CODES_BASE_C) + +#define LOG_TLM_MOBILE_NW_POS_INFO_C ((0x748) + LOG_1X_BASE_C) +#define LOG_ANT_HCI_CMD_C ((0x749) + LOG_1X_BASE_C) +#define LOG_ANT_HCI_EV_C ((0x750) + LOG_1X_BASE_C) +#define LOG_IMS_CAMERA_C ((0x751) + LOG_1X_BASE_C) +#define LOG_IMS_VIDEO_ENCODER_C ((0x752) + LOG_1X_BASE_C) +#define LOG_IMS_VIDEO_PLAYOUT_C ((0x753) + LOG_1X_BASE_C) +#define LOG_C_MCS_IRATMAN ((0x754) + LOG_1X_BASE_C) +#define LOG_TCXOMGR_TEMP_SUBSCRIPTION_C ((0x755) + LOG_1X_BASE_C) +#define LOG_GNSS_BDS_MEASUREMENT_REPORT_C ((0x756) + LOG_1X_BASE_C) + +/*0x1757 to 0x17D7 a total of 128 log codes reserved for eMBMS Service Layer */ +#define LOG_EMBMS_SL_RESERVED_CODES_BASE_C ((0x757) + LOG_1X_BASE_C) +#define LOG_EMBMS_SL_SESSION_C (LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1757*/ +#define LOG_EMBMS_SL_FLUTE_C (1 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1758*/ +#define LOG_EMBMS_SL_LOCAL_HTTP_SERVER_C (2 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1759*/ +#define LOG_EMBMS_SL_BOOTSTRAP (3 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x175A*/ +#define LOG_EMBMS_SL_SERVICE_DISCOVERY (4 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x175B*/ +#define LOG_EMBMS_SL_I2 (5 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x175C*/ +#define LOG_EMBMS_SL_I1_COMMON (6 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x175D*/ +#define LOG_EMBMS_SL_I1_STREAMING (7 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x175E*/ +#define LOG_EMBMS_SL_STREAMING (8 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x175F*/ +#define LOG_EMBMS_SL_I1_FILE_DOWNLOAD (9 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1760*/ +#define LOG_EMBMS_SL_SCHEDULE (10 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1761*/ +#define LOG_EMBMS_SL_FILE_REPAIR (11 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1762*/ +#define LOG_EMBMS_SL_RECEPTION_REPORTING (12 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1763*/ +#define LOG_EMBMS_SL_MSP_COMMON (13 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1764*/ +#define LOG_EMBMS_SL_USD_DATA (14 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1765*/ +#define LOG_EMBMS_CONFIGURATION (15 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1766*/ +#define LOG_EMBMS_FD_STORE (16 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x1767*/ + +#define LOG_EMBMS_SL_LAST_C (128 + LOG_EMBMS_SL_RESERVED_CODES_BASE_C) /*0x17D7*/ + +#define LOG_ADSP_AFE_CALIBRATION_DATA_C ((0x7D8) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_PA_C ((0x7D9) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_ASM_C ((0x7DA) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_PAPM_C ((0x7DB) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_TRASCEIVER_C ((0x7DC) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_TUNER_C ((0x7DD) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_THERM_C ((0x7DE) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_HDET_C ((0x7DF) + LOG_1X_BASE_C) +#define LOG_RFA_RFC_SIGNALS_C ((0x7E0) + LOG_1X_BASE_C) +#define LOG_RFA_RFC_DEVICES_C ((0x7E1) + LOG_1X_BASE_C) +#define LOG_RFA_GSM_CMN_C ((0x7E2) + LOG_1X_BASE_C) +#define LOG_RFA_GSM_RX_C ((0x7E3) + LOG_1X_BASE_C) +#define LOG_RFA_GSM_TX_C ((0x7E4) + LOG_1X_BASE_C) +#define LOG_RFA_GSM_TEMP_COMP_C ((0x7E5) + LOG_1X_BASE_C) +#define LOG_RFA_GSM_VBATT_COMP_C ((0x7E6) + LOG_1X_BASE_C) +#define LOG_RFA_GSM_IRAT_C ((0x7E7) + LOG_1X_BASE_C) +#define LOG_RFA_GSM_FTM_C ((0x7E8) + LOG_1X_BASE_C) +#define LOG_RFA_GSM_CAL_C ((0x7E9) + LOG_1X_BASE_C) +#define LOG_SNS_CMC_CONFIG_C ((0x7EA) + LOG_1X_BASE_C) +#define LOG_SNS_CMC_RESULT_C ((0x7EB) + LOG_1X_BASE_C) +#define LOG_SNS_CMC_REPORT_C ((0x7EC) + LOG_1X_BASE_C) +#define LOG_SNS_DB_CONFIG_C ((0x7ED) + LOG_1X_BASE_C) +#define LOG_SNS_DB_RESULT_C ((0x7EE) + LOG_1X_BASE_C) +#define LOG_SNS_DB_REPORT_C ((0x7EF) + LOG_1X_BASE_C) +#define LOG_SNS_CMC_RESULT2_C ((0x7F0) + LOG_1X_BASE_C) +#define LOG_PKT_MEM_PROFILING_C ((0x7F1) + LOG_1X_BASE_C) +#define LOG_VOICE_CALL_STATISTICS_C ((0x7F2) + LOG_1X_BASE_C) +#define LOG_SENSOR_FIFO_EVENT_C ((0x7F3) + LOG_1X_BASE_C) +#define LOG_EFS_MONITOR_C ((0x7F4) + LOG_1X_BASE_C) +#define LOG_EFS_MONITOR_LOOKUP_C ((0x7F5) + LOG_1X_BASE_C) +#define LOG_MCS_WWCOEX_STATE_INFO_C ((0x7F6) + LOG_1X_BASE_C) +#define LOG_MCS_WWCOEX_POWER_INFO_C ((0x7F7) + LOG_1X_BASE_C) +#define LOG_SNS_SMD_CONFIG_C ((0x7F8) + LOG_1X_BASE_C) +#define LOG_SNS_SMD_RESULT_C ((0x7F9) + LOG_1X_BASE_C) +#define LOG_SNS_SMD_REPORT_C ((0x7FA) + LOG_1X_BASE_C) +#define LOG_SNS_LATENCY_SAMPLING_POLL_C ((0x7FB) + LOG_1X_BASE_C) +#define LOG_SNS_LATENCY_SAMPLING_DRI_C ((0x7FC) + LOG_1X_BASE_C) +#define LOG_SNS_LATENCY_DELIVERY_C ((0x7FD) + LOG_1X_BASE_C) +#define LOG_SNS_GAME_ROTATION_VECTOR_CONFIG_C ((0x7FE) + LOG_1X_BASE_C) +#define LOG_SNS_GAME_ROTATION_VECTOR_RESULT_C ((0x7FF) + LOG_1X_BASE_C) +#define LOG_SNS_GAME_ROTATION_VECTOR_REPORT_C ((0x800) + LOG_1X_BASE_C) +#define LOG_TRSP_DATA_STALL_C ((0x801) + LOG_1X_BASE_C) +#define LOG_NFC_FTM_C ((0x802) + LOG_1X_BASE_C) +#define LOG_TCXOMGR_COARSE_DC_CAL_C ((0x803) + LOG_1X_BASE_C) +#define LOG_ADSP_CVD_STREAM_TX ((0x804) + LOG_1X_BASE_C) +#define LOG_ADSP_CVD_STREAM_RX ((0x805) + LOG_1X_BASE_C) +#define LOG_GNSS_MBM_C ((0x806) + LOG_1X_BASE_C) +#define LOG_GNSS_PLE_UPDATE_C ((0x807) + LOG_1X_BASE_C) +#define LOG_WLAN_SLM_RA_LINK_C ((0x808) + LOG_1X_BASE_C) +#define LOG_RF_LTE_MTPL_C ((0x809) + LOG_1X_BASE_C) +#define LOG_RF_LTE_HDET_C ((0x80A) + LOG_1X_BASE_C) + +/* New QMI reserved logs 0x180B - 0x182B*/ +#define LOG_QMI_RESERVED_NEW_CODES_BASE_C (0x80B + LOG_1X_BASE_C) +#define LOG_QMI_NEW_LAST_C (32 + LOG_QMI_RESERVED_NEW_CODES_BASE_C) + +#define LOG_DATA_PROTOCOL_LOGGING_EX_C ((0x82C) + LOG_1X_BASE_C) +#define LOG_RF_WCDMA_LOG_V3_C ((0x82D) + LOG_1X_BASE_C) +#define LOG_ROHC_DECOMPRESSOR_INPUT_C ((0x82E) + LOG_1X_BASE_C) +#define LOG_ROHC_COMPRESSOR_OUTPUT_C ((0x82F) + LOG_1X_BASE_C) +#define LOG_VOIP_SESSION_SETUP_SUMMARY_C ((0x830) + LOG_1X_BASE_C) +#define LOG_VOIP_SESSION_END_SUMMARY_C ((0x831) + LOG_1X_BASE_C) +#define LOG_IMS_REGISTRATION_SUMMARY_C ((0x832) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_MOTION_DETECTION_REPORT_C ((0x833) + LOG_1X_BASE_C) +#define LOG_SNS_RUN_TIME_TUNING_REQUEST_C ((0x834) + LOG_1X_BASE_C) +#define LOG_SNS_RUN_TIME_TUNING_RESPONSE_C ((0x835) + LOG_1X_BASE_C) +#define LOG_SNS_BMA2X2_DOUBLETAP_TUNING_MESSAGE_C ((0x836) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_POSITION_REPORT_C ((0x837) + LOG_1X_BASE_C) +#define LOG_GNSS_ME_DPO_STATUS_C ((0x838) + LOG_1X_BASE_C) +#define LOG_GNSS_SLIM_TIME_SYNC_C ((0x839) + LOG_1X_BASE_C) +#define LOG_SNS_GEOMAG_ROT_VEC_CONFIG_C ((0x83A) + LOG_1X_BASE_C) +#define LOG_SNS_GEOMAG_ROT_VEC_RESULT_C ((0x83B) + LOG_1X_BASE_C) +#define LOG_SNS_GEOMAG_ROT_VEC_REPORT_C ((0x83C) + LOG_1X_BASE_C) +#define LOG_IPDC_COMPRESSOR_PER_PKT_METRICS_C ((0x83D) + LOG_1X_BASE_C) +#define LOG_IPDC_COMPRESSOR_STATS_C ((0x83E) + LOG_1X_BASE_C) +#define LOG_ROHC_COMPRESSOR_STATISTICS_EX_C ((0x83F) + LOG_1X_BASE_C) +#define LOG_ROHC_DECOMPRESSOR_STATISTICS_EX_C ((0x840) + LOG_1X_BASE_C) +#define LOG_RFA_ASDIV_C ((0x841) + LOG_1X_BASE_C) +#define LOG_RFLM_GENERIC_DEBUG_1_C ((0x842) + LOG_1X_BASE_C) +#define LOG_RFLM_GENERIC_DEBUG_2_C ((0x843) + LOG_1X_BASE_C) +#define LOG_RFLM_TXAGC_UPDATE_C ((0x844) + LOG_1X_BASE_C) +#define LOG_RFLM_TXAGC_TABLES_C ((0x845) + LOG_1X_BASE_C) +#define LOG_RFLM_DTR_TX_C ((0x846) + LOG_1X_BASE_C) +#define LOG_RFLM_DTR_RX_C ((0x847) + LOG_1X_BASE_C) +#define LOG_RFLM_DTR_CMN_C ((0x848) + LOG_1X_BASE_C) +#define LOG_RFLM_FBRX_ONLINE_CORRECTION_C ((0x849) + LOG_1X_BASE_C) +#define LOG_RFLM_FBRX_SAMPLE_CAPTURE_C ((0x84A) + LOG_1X_BASE_C) +#define LOG_ADSP_VCP_VOICEPROC_RTM_C ((0x84B) + LOG_1X_BASE_C) +#define LOG_LTE_RF_FED_TXAGC_C ((0x84C) + LOG_1X_BASE_C) +#define LOG_LTE_RF_FED_TXAGC_TIMING_C ((0x84D) + LOG_1X_BASE_C) +#define LOG_CM_SS_MSIM_EVENT_C ((0x84E) + LOG_1X_BASE_C) +#define LOG_DATA_MODEM_IPA_STATS_C ((0x84F) + LOG_1X_BASE_C) +#define LOG_DATA_MODEM_IPA_IPFLTR_STATS_C ((0x850) + LOG_1X_BASE_C) +#define LOG_DATA_MODEM_IPA_PKT_STATUS_DL_C ((0x851) + LOG_1X_BASE_C) +#define LOG_DATA_MODEM_IPA_PKT_STATUS_UL_C ((0x852) + LOG_1X_BASE_C) +#define LOG_DATA_MODEM_IPA_SIO_CFG_C ((0x853) + LOG_1X_BASE_C) +#define LOG_DATA_MODEM_IPA_WAN_CFG_C ((0x854) + LOG_1X_BASE_C) +#define LOG_DATA_MODEM_IPA_FLTR_TBL_UPDATE_C ((0x855) + LOG_1X_BASE_C) +#define LOG_DATA_MODEM_IPA_RING_TBL_UPDATE_C ((0x856) + LOG_1X_BASE_C) +#define LOG_WLAN_QCA_RA_STATS_C ((0x857) + LOG_1X_BASE_C) +#define LOG_IMS_VOIP_HANDOVER_CRITERIA_CHANGE_C ((0x858) + LOG_1X_BASE_C) +#define LOG_DS_FIRST_REORIG_IP_PACKET_HEADER_C ((0x859) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_RAW ((0x85A) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_POST_PROC ((0x85B) + LOG_1X_BASE_C) +#define LOG_TOUCH_BASELINE ((0x85C) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_0 ((0x85D) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_1 ((0x85E) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_2 ((0x85F) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_3 ((0x860) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_4 ((0x861) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_5 ((0x862) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_6 ((0x863) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_7 ((0x864) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_8 ((0x865) + LOG_1X_BASE_C) +#define LOG_TOUCH_FRAME_TYPE_9 ((0x866) + LOG_1X_BASE_C) +#define LOG_LOC_WWAN_ME_EVENTS_C ((0x867) + LOG_1X_BASE_C) +#define LOG_RFLM_TDSCDMA_UPLINK_REPORT_C ((0x868) + LOG_1X_BASE_C) +#define LOG_RFLM_TDSCDMA_DOWNLINK_REPORT_C ((0x869) + LOG_1X_BASE_C) +#define LOG_RFLM_TDSCDMA_DEBUG_C ((0x86A) + LOG_1X_BASE_C) +#define LOG_DSP_MODEM_FW_CXM_C ((0x86B) + LOG_1X_BASE_C) +#define LOG_SNS_PED_ALIGN_CONFIG_C ((0x86C) + LOG_1X_BASE_C) +#define LOG_SNS_PED_ALIGN_RESULT1_C ((0x86D) + LOG_1X_BASE_C) +#define LOG_SNS_PED_ALIGN_RESULT2_C ((0x86E) + LOG_1X_BASE_C) +#define LOG_SNS_PED_ALIGN_REPORT_C ((0x86F) + LOG_1X_BASE_C) +#define LOG_MCS_WWCOEX_BA_SERV_POWER_INFO_C ((0x870) + LOG_1X_BASE_C) +#define LOG_MCS_WWCOEX_BA_BLACKLIST_INFO_C ((0x871) + LOG_1X_BASE_C) +#define LOG_AOSTLM_REPORT_C ((0x872) + LOG_1X_BASE_C) +#define LOG_MCPM_DEVICE_POWER_INFO_C ((0x873) + LOG_1X_BASE_C) +#define LOG_MCPM_GENERAL_SESSOPM_POWER_C ((0x874) + LOG_1X_BASE_C) +#define LOG_MCPM_CHIPSET_CONFIG_POWER_INFO_C ((0x875) + LOG_1X_BASE_C) +#define LOG_MCPM_IDLE_AWALE_POWER_INFO_C ((0x876) + LOG_1X_BASE_C) +#define LOG_1X_PHYSICAL_LAYER_POWER_INFO_C ((0x877) + LOG_1X_BASE_C) +#define LOG_EVDO_PHYSICAL_LAYER_POWER_INFO_C ((0x878) + LOG_1X_BASE_C) +#define LOG_GERAN_PHYSICAL_LAYER_POWER_INFO_C ((0x879) + LOG_1X_BASE_C) +#define LOG_WCDMA_SESSION_POWER_INFO_C ((0x87A) + LOG_1X_BASE_C) +#define LOG_WCDMA_PHYSICAL_LAYER_POWER_INFO_C ((0x87B) + LOG_1X_BASE_C) +#define LOG_TDSCDMA_PHYSICAL_LAYER_POWER_INFO_C ((0x87C) + LOG_1X_BASE_C) +#define LOG_LTE_SESSION_POWER_INFO_C ((0x87D) + LOG_1X_BASE_C) +#define LOG_LTE_PHYSICAL_LAYER_POWER_INFO_C ((0x87E) + LOG_1X_BASE_C) +#define LOG_PA_POWER_C ((0x87F) + LOG_1X_BASE_C) +#define LOG_WTR_POWER_C ((0x880) + LOG_1X_BASE_C) +#define LOG_Q6_POWER_C ((0x881) + LOG_1X_BASE_C) +#define LOG_ADSP_LSM_OUT_C ((0x882) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_WWAN_MOT_CLASS_C ((0x883) + LOG_1X_BASE_C) +#define LOG_SENSOR_SAMLITE_ALGO_STATES_OUTPUT_C ((0x884) + LOG_1X_BASE_C) +#define LOG_GNSS_SLIM_EVENT_C ((0x885) + LOG_1X_BASE_C) +#define LOG_GNSS_GAL_MEASUREMENT_REPORT_C ((0x886) + LOG_1X_BASE_C) +#define LOG_SNS_TILT_DETECTOR_CONFIG_C ((0x887) + LOG_1X_BASE_C) +#define LOG_SNS_TILT_DETECTOR_RESULT_C ((0x888) + LOG_1X_BASE_C) +#define LOG_SNS_TILT_DETECTOR_REPORT_C ((0x889) + LOG_1X_BASE_C) +#define LOG_ADSP_CVD_CAL_DATA_C ((0x88A) + LOG_1X_BASE_C) +#define LOG_TLM_UPDATE_CONSISTENCY_INFO_C ((0x88B) + LOG_1X_BASE_C) +#define LOG_LOC_LTE_OTDOA_TDP_MEAS_C ((0x88C) + LOG_1X_BASE_C) +#define LOG_SNS_UIMG_MODE_C ((0x88D) + LOG_1X_BASE_C) +#define LOG_GNSS_OEMCPE_MEASUREMENT_REPORT_C ((0x88E) + LOG_1X_BASE_C) +#define LOG_RFLM_WTX ((0x88F) + LOG_1X_BASE_C) +#define LOG_ADSP_CVD_VP3_C ((0x890) + LOG_1X_BASE_C) +#define LOG_MPLM_ECS_LOGPACKET_C ((0x891) + LOG_1X_BASE_C) +#define LOG_CXM_SMEM_DATA_C ((0x892) + LOG_1X_BASE_C) +#define LOG_CXM_LOW_PRIO_C ((0x893) + LOG_1X_BASE_C) +#define LOG_CXM_MED_PRIO_C ((0x894) + LOG_1X_BASE_C) +#define LOG_CXM_HIGH_PRIO_C ((0x895) + LOG_1X_BASE_C) +#define LOG_IMS_STATE_SWITCH_C ((0x896) + LOG_1X_BASE_C) +#define LOG_IMS_SYSTEM_ANCHOR_C ((0x897) + LOG_1X_BASE_C) +#define LOG_MCS_WWCOEX_SLOT_ACTIVITY_TIMELINE_INFO_C ((0x898) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_MOTION_WIFI_STATE_C ((0x899) + LOG_1X_BASE_C) +#define LOG_WLAN_QCA_MEM_INFO_C ((0x89A) + LOG_1X_BASE_C) +#define LOG_SNS_DPC_CONFIG_C ((0x89B) + LOG_1X_BASE_C) +#define LOG_SNS_DPC_RESULT_C ((0x89C) + LOG_1X_BASE_C) +#define LOG_SNS_DPC_REPORT_C ((0x89D) + LOG_1X_BASE_C) +#define LOG_DPL_IFACE_DESCRIPTION_AND_STATUS_C ((0x89E) + LOG_1X_BASE_C) +#define LOG_MCS_WWCOEX_SPUR_INFO_C ((0x89F) + LOG_1X_BASE_C) +#define LOG_LOC_LTE_TDP_GLOBAL_CELL_PARAMS_C ((0x8A0) + LOG_1X_BASE_C) +#define LOG_LOC_LTE_TDP_TIMESTAMPED_MEAS_C ((0x8A1) + LOG_1X_BASE_C) +#define LOG_LOC_LTE_TDP_MEAS_DATABASE_C ((0x8A2) + LOG_1X_BASE_C) +#define LOG_GNSS_GTP_TDP_CONFIG_C ((0x8A3) + LOG_1X_BASE_C) +#define LOG_GNSS_TLM_TDP_SCANLIST_C ((0x8A4) + LOG_1X_BASE_C) +#define LOG_SNS_GENERIC_MESSAGE_C ((0x8A5) + LOG_1X_BASE_C) +#define LOG_LOC_LTE_TDP_DB_SINGLE_MEAS_C ((0x8A6) + LOG_1X_BASE_C) +#define LOG_MCS_CFCM_MONITOR_INFO_C ((0x8A7) + LOG_1X_BASE_C) +#define LOG_MCS_CFCM_COMMAND_INFO_C ((0x8A8) + LOG_1X_BASE_C) +#define LOG_PM_CONFIG_INFO_C ((0x8A9) + LOG_1X_BASE_C) +#define LOG_PM_SUBS_INFO_C ((0x8AA) + LOG_1X_BASE_C) +#define LOG_GNSS_GTS_INPUT_REPORT_C ((0x8AB) + LOG_1X_BASE_C) +#define LOG_GNSS_GTS_TIME_UPDATE_C ((0x8AC) + LOG_1X_BASE_C) +#define LOG_GNSS_GTS_DB_DUMP_C ((0x8AD) + LOG_1X_BASE_C) +#define LOG_GNSS_GTS_EVENTS_C ((0x8AE) + LOG_1X_BASE_C) +#define LOG_GNSS_DATA_BLOB_C ((0x8AF) + LOG_1X_BASE_C) +#define LOG_GNSS_CD_LPPM_STATE_TRANSITION_C ((0x8B0) + LOG_1X_BASE_C) +#define LOG_GNSS_CD_LPPM_ENGAGE_REPORT_C ((0x8B1) + LOG_1X_BASE_C) +#define LOG_GNSS_MC_CONFIG_C ((0x8B2) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_ADD_REPORT_C ((0x8B3) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_DELETE_REPORT_C ((0x8B4) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_PURGE_REPORT_C ((0x8B5) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_BREACH_REPORT_C ((0x8B6) + LOG_1X_BASE_C) +#define LOG_SNS_TILT_W_DETECTOR_CONFIG_C ((0x8B7) + LOG_1X_BASE_C) +#define LOG_SNS_TILT_W_DETECTOR_RESULT_C ((0x8B8) + LOG_1X_BASE_C) +#define LOG_SNS_TILT_W_DETECTOR_REPORT_C ((0x8B9) + LOG_1X_BASE_C) +#define SNS_LOG_QHEART_CONFIG_C ((0x8BA) + LOG_1X_BASE_C) +#define SNS_LOG_QHEART_RESULT_C ((0x8BB) + LOG_1X_BASE_C) +#define SNS_LOG_QHEART_REPORT_C ((0x8BC) + LOG_1X_BASE_C) +#define LOG_HEAP_ANALYZER_HEAP_INFO_LOG_C ((0x8BD) + LOG_1X_BASE_C) +#define LOG_HEAP_ANALYZER_TASK_INFO_LOG_C ((0x8BE) + LOG_1X_BASE_C) +#define LOG_GNSS_ME_LPPM_STATUS_C ((0x8BF) + LOG_1X_BASE_C) +#define LOG_ANT_HCI_DATA_TX_C ((0x8C0) + LOG_1X_BASE_C) +#define LOG_ANT_HCI_DATA_RX_C ((0x8C1) + LOG_1X_BASE_C) +#define LOG_SNS_SYNC_PROXY_CLIENT_C ((0x8C2) + LOG_1X_BASE_C) +#define LOG_ATUNER_INFO_DATA_C ((0x8C3) + LOG_1X_BASE_C) +#define LOG_ATUNER_INTERNAL_DATA_C ((0x8C4) + LOG_1X_BASE_C) +#define LOG_GNSS_ME_PQME5_C ((0x8C5) + LOG_1X_BASE_C) +#define LOG_DS_LTE_DL_TPUT_C ((0x8C6) + LOG_1X_BASE_C) +#define LOG_SENSOR_SAMLITE_MAGCAL_REGISTRY_C ((0x8C7) + LOG_1X_BASE_C) +#define LOG_GNSS_LOCMW_ALS_IOD_DATA_C ((0x8C8) + LOG_1X_BASE_C) + +/* 8C9-8D8 Searcher reserved logs */ +#define LOG_SEARCHER_RESERVED_CODES_NEW_BASE_C ((0x8C9) + LOG_1X_BASE_C) +#define LOG_SEARCHER_LAST_NEW_2_C (15 + LOG_SEARCHER_RESERVED_CODES_NEW_BASE_C) + +#define LOG_IMS_RTCP_APP ((0x8D9) + LOG_1X_BASE_C) +#define LOG_LOC_PRS_FD_BUFFER_C ((0x8DA) + LOG_1X_BASE_C) +#define LOG_LOC_PRS_PROG_PARAMS_C ((0x8DB) + LOG_1X_BASE_C) +#define LOG_BT_LE_LLP_TX_C ((0x8DC) + LOG_1X_BASE_C) +#define LOG_BT_LE_LLP_RX_C ((0x8DD) + LOG_1X_BASE_C) +#define LOG_RFA_CCRY_MGR_C ((0x8DE) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_POSITION_REQUEST_C ((0x8DF) + LOG_1X_BASE_C) +#define LOG_WLAN_PKT_LOG_INFO_C ((0x8E0) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_1_C ((0x8E1) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_2_C ((0x8E2) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_3_C ((0x8E3) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_4_C ((0x8E4) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_5_C ((0x8E5) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_6_C ((0x8E6) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_7_C ((0x8E7) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_8_C ((0x8E8) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_9_C ((0x8E9) + LOG_1X_BASE_C) +#define LOG_MODEM_TIMELINES_10_C ((0x8EA) + LOG_1X_BASE_C) +#define LOG_GNSS_GF_ALS_IOD_SENSOR_STATE_C ((0x8EB) + LOG_1X_BASE_C) +#define LOG_GNSS_COG_REFERENCE_C ((0x8EC) + LOG_1X_BASE_C) +#define LOG_GNSS_GIT_IPC_REPORT_C ((0x8ED) + LOG_1X_BASE_C) +#define LOG_GNSS_SLIM_QMI_EVT_C ((0x8EE) + LOG_1X_BASE_C) +#define LOG_GNSS_SLIM_QMI_MSG_C ((0x8EF) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_STATS_C ((0x8F0) + LOG_1X_BASE_C) +#define LOG_WLAN_EXTSCAN_CAPABILITIES ((0x8F1) + LOG_1X_BASE_C) +#define LOG_WLAN_EXTSCAN_FEATURE_STARTED ((0x8F2) + LOG_1X_BASE_C) +#define LOG_PS_FILTER_INFO_C ((0x8F3) + LOG_1X_BASE_C) +#define LOG_GNSS_GEOFENCE_EBEE_INFO_C ((0x8F4) + LOG_1X_BASE_C) +#define LOG_GNSS_QZSS_SBAS_MEASUREMENT_REPORT_C ((0x8F5) + LOG_1X_BASE_C) +#define LOG_GNSS_WIFI_COV_LOC_EST_C ((0x8F6) + LOG_1X_BASE_C) +#define LOG_RFLM_FBRX_BASIC_PARAM_UPDATES_C ((0x8F7) + LOG_1X_BASE_C) +#define LOG_MCS_VBATT_INFO_C ((0x8F8) + LOG_1X_BASE_C) +#define LOG_GNSS_UIMAGE_TRANSITION_INFO_C ((0x8F9) + LOG_1X_BASE_C) +#define LOG_GNSS_APDR_DIAG_MSG_C ((0x8FA) + LOG_1X_BASE_C) +#define RFLM_LOG_PACKET_AUTOPIN_DM_INFO_ID ((0x8FB) + LOG_1X_BASE_C) +#define RFLM_LOG_PACKET_AUTOPIN_IQ_CAPTURE_ID ((0x8FC) + LOG_1X_BASE_C) +#define LOG_LOC_LTE_OTDOA_DEBUG_C ((0x8FD) + LOG_1X_BASE_C) +#define LOG_Q6ZIP_REQUEST_RESPONSE_C ((0x8FE) + LOG_1X_BASE_C) +#define LOG_MCS_WWCOEX_CNHL_CFLT_C ((0x8FF) + LOG_1X_BASE_C) +#define LOG_MCS_WWCOEX_FW_QUERY_C ((0x900) + LOG_1X_BASE_C) +#define LOG_MMGSDI_BOOTUP_MESSAGE_C ((0x901) + LOG_1X_BASE_C) +#define LOG_GNSS_DGNSS_MESSAGES_C ((0x902) + LOG_1X_BASE_C) +#define LOG_UIM_PUP_MSG_C ((0x903) + LOG_1X_BASE_C) +#define LOG_IMS_VIDEO_CALL_STATISTICS_C ((0x904) + LOG_1X_BASE_C) +#define LOG_IMS_SIP_VIDEO_ESTABLISHED_C ((0x905) + LOG_1X_BASE_C) +#define LOG_IMS_SIP_VIDEO_SESSION_EST_FAILED_C ((0x906) + LOG_1X_BASE_C) +#define LOG_IMS_SIP_VIDEO_UPGRADE_SUCCESSFUL_C ((0x907) + LOG_1X_BASE_C) +#define LOG_IMS_SIP_VIDEO_UPGRADE_FAILURE_C ((0x908) + LOG_1X_BASE_C) +#define LOG_IMS_SIP_VIDEO_DOWNGRADE_SUCCESSFUL_C ((0x909) + LOG_1X_BASE_C) +#define LOG_IMS_SIP_VIDEO_ABNORMAL_SESSION_RELEASE_C ((0x90A) + LOG_1X_BASE_C) +#define LOG_IMS_SIP_VIDEO_SESSION_DROP_C ((0x90B) + LOG_1X_BASE_C) +#define LOG_NETWORK_PHYSLINK_TX_100_BYTES_C ((0x90C) + LOG_1X_BASE_C) +#define LOG_NETWORK_PHYSLINK_RX_100_BYTES_C ((0x90D) + LOG_1X_BASE_C) +#define LOG_NETWORK_PHYSLINK_TX_FULL_C ((0x90E) + LOG_1X_BASE_C) +#define LOG_NETWORK_PHYSLINK_RX_FULL_C ((0x90F) + LOG_1X_BASE_C) +#define LOG_NETWORK_IP_HEADER_RM_TX_C ((0x910) + LOG_1X_BASE_C) +#define LOG_NETWORK_IP_HEADER_RM_RX_C ((0x911) + LOG_1X_BASE_C) +#define LOG_NETWORK_IP_HEADER_UM_TX_C ((0x912) + LOG_1X_BASE_C) +#define LOG_NETWORK_IP_HEADER_UM_RX_C ((0x913) + LOG_1X_BASE_C) +#define LOG_VOICE_SERVICES_UL_VOCODER_PACKET_C ((0x914) + LOG_1X_BASE_C) +#define LOG_VOICE_SERVICES_DL_VOCODER_PACKET_C ((0x915) + LOG_1X_BASE_C) +#define LOG_GNSS_WLM_SCAN_INFO_C ((0x916) + LOG_1X_BASE_C) +#define RFLM_LOG_PACKET_FBRX_VSWR ((0x917) + LOG_1X_BASE_C) +#define LOG_SNS_IOD_CONFIG_C ((0x918) + LOG_1X_BASE_C) +#define LOG_SNS_IOD_RESULT_C ((0x919) + LOG_1X_BASE_C) +#define LOG_SNS_IOD_REPORT_C ((0x91A) + LOG_1X_BASE_C) +#define LOG_SNS_IOD_AUTOCAL_CONFIG_C ((0x91B) + LOG_1X_BASE_C) +#define LOG_SNS_IOD_AUTOCAL_RESULT_C ((0x91C) + LOG_1X_BASE_C) +#define LOG_SNS_IOD_AUTOCAL_REPORT_C ((0x91D) + LOG_1X_BASE_C) +#define LOG_ECM_C ((0x91E) + LOG_1X_BASE_C) +#define LOG_GNSS_INJECTED_XTRA_DATA_C ((0x91F) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_COUPLER_C ((0x920) + LOG_1X_BASE_C) +#define LOG_RFA_DEVICE_LNA_C ((0x921) + LOG_1X_BASE_C) +#define LOG_TASK_PRIORITY_C ((0x922) + LOG_1X_BASE_C) +#define LOG_IOE_WLAN_DBGLOG_C ((0x923) + LOG_1X_BASE_C) +#define LOG_IOE_WLAN_PKTLOG_TX_CTL_C ((0x924) + LOG_1X_BASE_C) +#define LOG_IOE_WLAN_PKTLOG_TX_STATUS_INFO_C ((0x925) + LOG_1X_BASE_C) +#define LOG_IOE_WLAN_PKTLOG_RX_INFO_C ((0x926) + LOG_1X_BASE_C) +#define LOG_IOE_WLAN_PKTLOG_RC_FIND_INFO_C ((0x927) + LOG_1X_BASE_C) +#define LOG_IOE_WLAN_PKTLOG_RC_UPDATE_INFO_C ((0x928) + LOG_1X_BASE_C) +#define LOG_IOE_WLAN_PKGTLOG_ANI_C ((0x929) + LOG_1X_BASE_C) +#define LOG_LTE_RF_FED_RXAGC_C ((0x92A) + LOG_1X_BASE_C) +#define LOG_QTI_QMI_PH_RX_C ((0x92B) + LOG_1X_BASE_C) +#define LOG_QTI_QMI_PH_TX_C ((0x92C) + LOG_1X_BASE_C) +#define LOG_DIAG_ULOG_PAYLOAD_C ((0x92D) + LOG_1X_BASE_C) +#define LOG_DIAG_ULOG_PAYLOAD LOG_DIAG_ULOG_PAYLOAD_C +#define LOG_GNSS_TLE_TDP_MEAS_BLK_C ((0x92E) + LOG_1X_BASE_C) +#define LOG_RFLM_PROFILING_C ((0x92F) + LOG_1X_BASE_C) +#define LOG_WLAN_OFFLOAD_STAT_C ((0x930) + LOG_1X_BASE_C) +#define LOG_WLAN_FW_MCC_UTILIZATION_C ((0x931) + LOG_1X_BASE_C) +#define LOG_WLAN_FW_BEACON_TX_STAT_C ((0x932) + LOG_1X_BASE_C) +#define LOG_WLAN_FW_BEACON_RX_STAT_C ((0x933) + LOG_1X_BASE_C) +#define LOG_WLAN_FW_SCAN_REPORT_C ((0x934) + LOG_1X_BASE_C) +#define LOG_WLAN_CHANNEL_CACHE_C ((0x935) + LOG_1X_BASE_C) +#define LOG_WLAN_RSSI_INFO_C ((0x936) + LOG_1X_BASE_C) +#define LOG_WLAN_CANDIDATE_LIST_C ((0x937) + LOG_1X_BASE_C) +#define LOG_WLAN_FW_DFS_ALLOWEDCHANNELS_C ((0x938) + LOG_1X_BASE_C) +#define LOG_WLAN_FW_TDLS_STAT_C ((0x939) + LOG_1X_BASE_C) +#define LOG_WLAN_FW_RTT_MEASUREMENT_REQUEST_C ((0x93A) + LOG_1X_BASE_C) +#define LOG_WLAN_FW_RTT_RESPONSE_C ((0x93B) + LOG_1X_BASE_C) +#define LOG_WLAN_HALPHY_RSSI_REPORT_C ((0x93C) + LOG_1X_BASE_C) +#define LOG_WLAN_HALPHY_PHY_STATS_REPORT_C ((0x93D) + LOG_1X_BASE_C) +#define LOG_WLAN_HALPHY_CHAN_INFO_REPORT_C ((0x93E) + LOG_1X_BASE_C) +#define LOG_WLAN_HALPHY_TX_POWER_REPORT_C ((0x93F) + LOG_1X_BASE_C) +#define LOG_WLAN_HALPHY_CAL_TIME_REPORT_C ((0x940) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_ASSOC_RX_C ((0x941) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_BEACON_RX_C ((0x942) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_BEACON_TX_C ((0x943) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_TX_PROBEREQ_C ((0x944) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_RX_PROBEREQ_C ((0x945) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_RX_PROBERSP_C ((0x946) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_TX_PROBERSP_C ((0x947) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_TX_ACTIONFRAME_C ((0x948) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_RX_ACTIONFRAME_C ((0x949) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_RX_FTMR_C ((0x94A) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_RX_FTM_C ((0x94B) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_TX_C ((0x94C) + LOG_1X_BASE_C) +#define LOG_WLAN_OTA_RX_C ((0x94D) + LOG_1X_BASE_C) +#define LOG_MCS_RT_SAR_FRAME_C ((0x94E) + LOG_1X_BASE_C) +#define LOG_IWLANS2B_IKEV2_C ((0x94F) + LOG_1X_BASE_C) +#define LOG_GNSS_MC_F3_GENERIC_C ((0x950) + LOG_1X_BASE_C) +#define LOG_DPL_HW_SIO_CONF_C ((0x951) + LOG_1X_BASE_C) +#define LOG_MPPM_PDN_DB_C ((0x952) + LOG_1X_BASE_C) +#define LOG_GNSS_MC_MEM_ALLOC_STATUS_C ((0x953) + LOG_1X_BASE_C) +#define LOG_SNS_MULTISHAKE_CONFIG_C ((0x954) + LOG_1X_BASE_C) +#define LOG_SNS_MULTISHAKE_RESULT_C ((0x955) + LOG_1X_BASE_C) +#define LOG_SNS_MULTISHAKE_REPORT_C ((0x956) + LOG_1X_BASE_C) +#define LOG_QDR_SENSOR_DATA_C ((0x957) + LOG_1X_BASE_C) +#define LOG_QDR_NAV_DATA_C ((0x958) + LOG_1X_BASE_C) +#define LOG_QDR_TRKR_DATA_C ((0x959) + LOG_1X_BASE_C) +#define LOG_QDR_CLOCK_STATUS_DATA_C ((0x95A) + LOG_1X_BASE_C) +#define LOG_QDR_NAV_REPORT_C ((0x95B) + LOG_1X_BASE_C) +#define LOG_QDR_NAV_SV_DATA_C ((0x95C) + LOG_1X_BASE_C) +#define LOG_QDR_DR_STATUS_C ((0x95D) + LOG_1X_BASE_C) +#define LOG_QDR_DR_NAV_STATE_C ((0x95E) + LOG_1X_BASE_C) +#define LOG_QDR_DR_NAV_SUBSYS_STATUS_C ((0x95F) + LOG_1X_BASE_C) +#define LOG_QDR_NAV_INIT_C ((0x960) + LOG_1X_BASE_C) +#define LOG_QDR_NAV_AUX_INIT_C ((0x961) + LOG_1X_BASE_C) +#define LOG_IPA_TCP_ACK_COAL_STATS_C ((0x962) + LOG_1X_BASE_C) +#define LOG_IPA_TCP_ACK_CFCM_CPU_STATS_C ((0x963) + LOG_1X_BASE_C) +#define LOG_SNS_HDRLL_DATA_C ((0x964) + LOG_1X_BASE_C) +#define LOG_QDR_GNSS_MEASUREMENT_DATA ((0x965) + LOG_1X_BASE_C) +#define LOG_QDR_GNSS_SV_STATE_DATA ((0x966) + LOG_1X_BASE_C) + +/* The last defined DMSS log code */ +#define LOG_1X_LAST_C ((0x966) + LOG_1X_BASE_C) + +/* This is only here for old (pre equipment ID update) logging code */ +#define LOG_LAST_C ( LOG_1X_LAST_C & 0xFFF ) + + +/* ------------------------------------------------------------------------- + * APPS LOG definition: + * The max number of 16 log codes is assigned for Apps. + * The last apps log code could be 0xB00F. + * Below definition is consolidated from log_codes_apps.h + * ------------------------------------------------------------------------- */ + +/* ======================== APPS Profiling ======================== */ +#define LOG_APPS_SYSPROFILE_C (0x01 + LOG_APPS_BASE_C) +#define LOG_APPS_TASKPROFILE_C (0x02 + LOG_APPS_BASE_C) + +/* The last defined APPS log code */ +/* Change it to (0x02 + LOG_LTE_LAST_C) to allow LTE log codes */ +#define LOG_APPS_LAST_C (0x02 + LOG_LTE_LAST_C) + +/* ------------------------------------------------------------------------- + * Log Equipment IDs. + * The number is represented by 4 bits. + * ------------------------------------------------------------------------- */ +typedef enum { + LOG_EQUIP_ID_OEM = 0, /* 3rd party OEM (licensee) use */ + LOG_EQUIP_ID_1X = 1, /* Traditional 1X line of products */ + LOG_EQUIP_ID_RSVD2 = 2, + LOG_EQUIP_ID_RSVD3 = 3, + LOG_EQUIP_ID_WCDMA = 4, + LOG_EQUIP_ID_GSM = 5, + LOG_EQUIP_ID_LBS = 6, + LOG_EQUIP_ID_UMTS = 7, + LOG_EQUIP_ID_TDMA = 8, + LOG_EQUIP_ID_BOA = 9, + LOG_EQUIP_ID_DTV = 10, + LOG_EQUIP_ID_APPS = 11, + LOG_EQUIP_ID_DSP = 12, + LOG_EQUIP_ID_TDSCDMA = 13, + + LOG_EQUIP_ID_LAST_DEFAULT = LOG_EQUIP_ID_TDSCDMA + +} log_equip_id_enum_type; + +#define LOG_EQUIP_ID_MAX 0xF /* The equipment ID is 4 bits */ + +/* Note that these are the official values and are used by default in + diagtune.h. +*/ +#define LOG_EQUIP_ID_0_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_1_LAST_CODE_DEFAULT LOG_1X_LAST_C +#define LOG_EQUIP_ID_2_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_3_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_4_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_5_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_6_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_7_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_8_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_9_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_10_LAST_CODE_DEFAULT (0x380 + LOG_DTV_BASE_C + 0x0A) +#define LOG_EQUIP_ID_11_LAST_CODE_DEFAULT LOG_LTE_LAST_C +#define LOG_EQUIP_ID_12_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_13_LAST_CODE_DEFAULT LOG_TDSCDMA_LAST_C +#define LOG_EQUIP_ID_14_LAST_CODE_DEFAULT 0 +#define LOG_EQUIP_ID_15_LAST_CODE_DEFAULT 0 + +/*! +@endcond +*/ + +#endif /* LOG_CODES_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/msg.h b/feeds/wifi-ax/qca-diag/src/include/msg.h new file mode 100755 index 000000000..2095f588a --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/msg.h @@ -0,0 +1,1097 @@ +#ifndef MSG_H +#define MSG_H + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + EXTENDED DIAGNOSTIC MESSAGE SERVICE HEADER FILE + +GENERAL DESCRIPTION + + All the declarations and definitions necessary to support the reporting + of messages for errors and debugging. This includes support for the + extended capabilities as well as the legacy messaging scheme. + +# Copyright (c) 2007-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + +$Header: //depot/asic/msmshared/services/diag/Diag_1.5/Diag_LSM/msg.h#1 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +01/02/08 mad Enabled real diag F3 messages for FEATURE_WINCE, + instead of retail messages. +09/01/04 eav Code reorganization +07/08/04 eav Moved F3 trace saving typedefs to diagdebug.h +06/02/04 eav Added "debug_mask". Determines whether or not to save + the F3 trace to the RAM buffer. +04/21/03 as Added MSG_SPRINTF macros for 4,5,6,7 &8 arguments. +03/12/04 eav Added msg_copy_to_efs_check prototype to be called from + tmc.c. +02/20/04 eav Added savetime and savevar flags to msg_const_type struct. +09/23/03 as defined (TARGET_UNIX) to support the DSPE - a Linux based + phone emulator used by data team in testing and debugging. +07/24/02 lad Updated to reflect requirements changes and final + implementation of extended message service. +02/06/02 igt Created module. + +===========================================================================*/ + +/*=========================================================================== + + INCLUDE FILES FOR MODULE + +===========================================================================*/ + +#ifdef FEATURE_L4_KERNEL + +extern int printf (const char * format, ...); +#define MSG_HIGH(str, a, b, c) printf("HIGH: " str, a, b, c) +#define MSG_MED(str, a, b, c) printf("HIGH: " str, a, b, c) +#define MSG_LOW(str, a, b, c) printf("HIGH: " str, a, b, c) + +#else + +#include +#include "msg_pkt_defs.h" /* Packet definitions */ +/*=========================================================================== + LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE +===========================================================================*/ + +/*--------------------------------------------------------------------------- + These are the masks that are used to identify a message as belonging to + group "i" of a particular Subsystem. This allows the user to selectively + turn groups of messages within a Subsystem to ON or OFF. The legacy + messages will continue to be supported thru the legacy masks. +---------------------------------------------------------------------------*/ +#define MSG_MASK_0 (0x00000001) +#define MSG_MASK_1 (0x00000002) +#define MSG_MASK_2 (0x00000004) +#define MSG_MASK_3 (0x00000008) +#define MSG_MASK_4 (0x00000010) +#define MSG_MASK_5 (0x00000020) +#define MSG_MASK_6 (0x00000040) +#define MSG_MASK_7 (0x00000080) +#define MSG_MASK_8 (0x00000100) +#define MSG_MASK_9 (0x00000200) +#define MSG_MASK_10 (0x00000400) +#define MSG_MASK_11 (0x00000800) +#define MSG_MASK_12 (0x00001000) +#define MSG_MASK_13 (0x00002000) +#define MSG_MASK_14 (0x00004000) +#define MSG_MASK_15 (0x00008000) +#define MSG_MASK_16 (0x00010000) +#define MSG_MASK_17 (0x00020000) +#define MSG_MASK_18 (0x00040000) +#define MSG_MASK_19 (0x00080000) +#define MSG_MASK_20 (0x00100000) +#define MSG_MASK_21 (0x00200000) +#define MSG_MASK_22 (0x00400000) +#define MSG_MASK_23 (0x00800000) +#define MSG_MASK_24 (0x01000000) +#define MSG_MASK_25 (0x02000000) +#define MSG_MASK_26 (0x04000000) +#define MSG_MASK_27 (0x08000000) +#define MSG_MASK_28 (0x10000000) +#define MSG_MASK_29 (0x20000000) +#define MSG_MASK_30 (0x40000000) +#define MSG_MASK_31 (0x80000000) + +/*--------------------------------------------------------------------------- + These masks are to be used for support of all legacy messages in the sw. + The user does not need to remember the names as they will be embedded in + the appropriate macros. +---------------------------------------------------------------------------*/ +#define MSG_LEGACY_LOW MSG_MASK_0 +#define MSG_LEGACY_MED MSG_MASK_1 +#define MSG_LEGACY_HIGH MSG_MASK_2 +#define MSG_LEGACY_ERROR MSG_MASK_3 +#define MSG_LEGACY_FATAL MSG_MASK_4 + +/*--------------------------------------------------------------------------- + Legacy Message Priorities +---------------------------------------------------------------------------*/ +#define MSG_LVL_FATAL (MSG_LEGACY_FATAL) +#define MSG_LVL_ERROR (MSG_LEGACY_ERROR | MSG_LVL_FATAL) +#define MSG_LVL_HIGH (MSG_LEGACY_HIGH | MSG_LVL_ERROR) +#define MSG_LVL_MED (MSG_LEGACY_MED | MSG_LVL_HIGH) +#define MSG_LVL_LOW (MSG_LEGACY_LOW | MSG_LVL_MED) + +#define MSG_LVL_NONE 0 + +#include "msgcfg.h" /* Header file listing SSIDs, build masks, etc. */ +#include "msg_qsr.h" /* Optimized F3 Debug messages */ + +/* If MSG_FILE is defined, use that as the filename, and allocate a single + character string to contain it. Note that this string is shared with the + Error Services, to conserve ROM and RAM. + + With ADS1.1 and later, multiple uses of __FILE__ or __MODULE__ within the + same file do not cause multiple literal strings to be stored in ROM. So in + builds that use the more recent versions of ADS, it is not necessary to + define the static variable msg_file. Note that __MODULE__ gets replaced + with the filename portion of the full pathname of the file. */ +/* Note, if this symbol is activated, the file is being compiled with legacy + message service defines. Older compilers may need the static const + variable to avoid multiple copies of the filename string in ROM. */ + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 110000) +/* Check for ARM version first. Defining static const char msg_file[] will + generate a compiler warning if the file doesn't actually use a message. */ + +#define msg_file __MODULE__ + +#elif defined (MSG_FILE) + +static const char msg_file[] = MSG_FILE; +// Added for Linux +#elif defined (TARGET_UNIX) || defined (__GNUC__) +#define msg_file __FILE__ + +#else + +static const char msg_file[] = __FILE__; + +#endif + +/*--------------------------------------------------------------------------- + The extended message packet is defined to be processed as efficiently as + possible in the caller's context. Therefore, the packet is divided into + logical blocks that are aligned w/out declaring the structure as PACKED. + + A header, static constant block, and argument list are defined to minimize + the work done by the caller's task. + + 1. Header + 2. Constant variable length data (format string and filename string, etc). + 3. Arguments ("Variable" variable-length data) + + The data is delivered in this order in the packet to simplify the runtime + processing of each message. All constant data is handled in DIAG task + context, leaving the caller's task to only process variable data at runtime. + + The phone will never process the constant data directly, except to copy + format and filename strings. +---------------------------------------------------------------------------*/ + +/*--------------------------------------------------------------------------- + All constant information stored for a message. + + The values for the fields of this structure are known at compile time. + So this is to be defined as a "static " in the MACRO, so it ends up + being defined and initialized at compile time for each and every message + in the software. This minimizes the amount of work to do during run time. + + So this structure is to be used in the "caller's" context. "Caller" is the + client of the Message Services. +---------------------------------------------------------------------------*/ +typedef struct +{ + msg_desc_type desc; /* ss_mask, line, ss_id */ + const char *fmt; /* Printf style format string */ + const char *fname; /* Pointer to source file name */ + +#if defined (FEATURE_ERR_EXTENDED_STORE) && defined (FEATURE_SAVE_DEBUG_TRACE) + boolean do_save; /* If TRUE, save msg to RAM buffer */ +#endif +} +msg_const_type; + +/*--------------------------------------------------------------------------- + This is the structure that is stored by the caller's task in msg_send (). + The DIAG task will expand the constant data into the final packet before + sending to the external device. +---------------------------------------------------------------------------*/ +typedef struct +{ + msg_hdr_type hdr; + const msg_const_type *const_data_ptr; /* desc, file_name, fmt */ + uint32 args[1]; +} +msg_ext_store_type; + + +#if defined (FEATURE_MSG_IFACE_VIOLATION) +/*=========================================================================== + Message Store Type. +===========================================================================*/ + typedef struct + { + byte level; /* Severity level / Priority of this message. */ + word line; /* Line number into source file */ + const char *file_ptr; /* Pointer to source file name */ + const char *xx_fmt; /* Printf style format string */ + } + msg_store_type; + + /* BREW still references this old-style message format */ + void msg_put (const msg_store_type * fmt_ptr, dword code1, dword code2, + dword code3); +#endif /* FEATURE_MSG_IFACE_VIOLATION */ + +/* Enabling real diag F3 messages, Diag 1.5 */ + +/*--------------------------------------------------------------------------- + The purpose of this macro is to define the constant part of the message + that can be initialized at compile time and stored in ROM. This will + define and initialize a msg_const_type for each call of a message macro. + The "static" limits the scope to the file the macro is called from while + using the macro in a do{}while() guarantees the uniqueness of the name. +---------------------------------------------------------------------------*/ +#if defined (FEATURE_ERR_EXTENDED_STORE) && defined (FEATURE_SAVE_DEBUG_TRACE) + #define XX_MSG_CONST(xx_ss_id, xx_ss_mask, xx_fmt) \ + XX_MSG_CONST_SAVE(xx_ss_id, xx_ss_mask, xx_fmt, TRUE) + + #define XX_MSG_CONST_SAVE(xx_ss_id, xx_ss_mask, xx_fmt, do_save) \ + static const msg_const_type xx_msg_const = { \ + {__LINE__, (xx_ss_id), (xx_ss_mask)}, (xx_fmt), msg_file, do_save} + +#else + #define XX_MSG_CONST(xx_ss_id, xx_ss_mask, xx_fmt) \ + static const msg_const_type xx_msg_const = { \ + {__LINE__, (xx_ss_id), (xx_ss_mask)}, (xx_fmt), msg_file} + +#endif /* (FEATURE_ERR_EXTENDED_STORE) && defined (FEATURE_SAVE_DEBUG_TRACE) */ + + +/*--------------------------------------------------------------------------- + This Macro is used when format string xx_fmt is passed as a variable.at + runtime instead of a literal. +---------------------------------------------------------------------------*/ +#define XX_MSG_CONST_FMT_VAR(xx_ss_id, xx_ss_mask, xx_fmt) \ + const msg_const_type xx_msg_const = { \ + {__LINE__, (xx_ss_id), (xx_ss_mask)}, (xx_fmt), msg_file} + +/*--------------------------------------------------------------------------- + These are the message macros that support messages with variable number + of parameters and message text of over 40 characters. + This is the macro for messages with no params but only a text string. +---------------------------------------------------------------------------*/ +#define MSG(xx_ss_id, xx_ss_mask, xx_fmt) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send (&xx_msg_const); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +#define MSG_TS(xx_ss_id, xx_ss_mask, xx_fmt, xx_ts) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST(xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_ts(&xx_msg_const, xx_ts); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + +/*--------------------------------------------------------------------------- + Macro for messages with 1 parameter. +---------------------------------------------------------------------------*/ +#define MSG_1(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_1 (&xx_msg_const, (uint32) (xx_arg1)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + Macro for messages with 2 parameters. +---------------------------------------------------------------------------*/ +#define MSG_2(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_2 (&xx_msg_const, (uint32)(xx_arg1), (uint32)(xx_arg2)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 3 parameters. +---------------------------------------------------------------------------*/ +#define MSG_3(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_3 (&xx_msg_const, (uint32) (xx_arg1), (uint32) (xx_arg2), \ + (uint32) (xx_arg3)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +#define MSG_3_SAVE(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, do_sav) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST_SAVE (xx_ss_id, xx_ss_mask, xx_fmt, do_sav); \ + /*lint -e571 */ \ + msg_send_3 (&xx_msg_const, (uint32) (xx_arg1), (uint32) (xx_arg2), \ + (uint32) (xx_arg3)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 4 parameters. In this case the function + called needs to have more than 4 parameters so it is going to be a slow + function call. So for this case the msg_send_var() uses var arg list + supported by the compiler. +---------------------------------------------------------------------------*/ +#define MSG_4(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_var (&xx_msg_const, (uint32)(4), (uintptr_t)(xx_arg1), \ + (uintptr_t) (xx_arg2), (uintptr_t) (xx_arg3), \ + (uintptr_t) (xx_arg4)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 5 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define MSG_5(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_var(&xx_msg_const, (uint32)(5), (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 6 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define MSG_6(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_var (&xx_msg_const, (uint32)(6), (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5), \ + (uintptr_t)(xx_arg6)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 7 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define MSG_7(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6, \ + xx_arg7) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_var (&xx_msg_const, (uint32)(7), (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5), \ + (uintptr_t)(xx_arg6), (uintptr_t)(xx_arg7)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 8 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define MSG_8(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6, \ + xx_arg7, xx_arg8) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_var (&xx_msg_const, (uint32)(8), (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5), \ + (uintptr_t)(xx_arg6), (uintptr_t)(xx_arg7), \ + (uintptr_t)(xx_arg8)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 9 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define MSG_9(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6, \ + xx_arg7, xx_arg8, xx_arg9) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_send_var (&xx_msg_const, (uint32)(9), (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5), \ + (uintptr_t)(xx_arg6), (uintptr_t)(xx_arg7), \ + (uintptr_t)(xx_arg8), (uintptr_t)(xx_arg9)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 1 parameters. msg_sprintf() + uses var arg list supported by the compiler.This Macro is used when xx_fmt + is passed as a literal. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_1(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 2 parameters. msg_sprintf() + uses var arg list supported by the compiler.This Macro is used when xx_fmt + is passed as a literal. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_2(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 3 parameters. msg_sprintf() + uses var arg list supported by the compiler.This Macro is used when xx_fmt + is passed as a literal. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_3(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 4 parameters. msg_sprintf() + uses var arg list supported by the compiler.This Macro is used when xx_fmt + is passed as a literal. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_4(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4 ); \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 5 parameters. msg_sprintf() + uses var arg list supported by the compiler.This Macro is used when xx_fmt + is passed as a literal. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_5(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5 ); \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 6 parameters. msg_sprintf() + uses var arg list supported by the compiler.This Macro is used when xx_fmt + is passed as a literal. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_6(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6 ); \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5), \ + (uintptr_t)(xx_arg6)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 7 parameters. msg_sprintf() + uses var arg list supported by the compiler.This Macro is used when xx_fmt + is passed as a literal. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_7(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6, \ + xx_arg7 ); \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5), \ + (uintptr_t)(xx_arg6), (uintptr_t)(xx_arg7)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 8 parameters. msg_sprintf() + uses var arg list supported by the compiler.This Macro is used when xx_fmt + is passed as a literal. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_8(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6, \ + xx_arg7, xx_arg8 ); \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3), \ + (uintptr_t)(xx_arg4), (uintptr_t)(xx_arg5), \ + (uintptr_t)(xx_arg6), (uintptr_t)(xx_arg7), \ + (uintptr_t)(xx_arg8)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + + +/*--------------------------------------------------------------------------- + This is the macro for sprintf messages with 3 parameters. This Macro is + used when xx_fmt is passed at runtime. +---------------------------------------------------------------------------*/ +#define MSG_SPRINTF_FMT_VAR_3(xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_MSG_CONST_FMT_VAR (xx_ss_id, xx_ss_mask, xx_fmt); \ + /*lint -e571 */ \ + msg_sprintf (&xx_msg_const, (uintptr_t)(xx_arg1), \ + (uintptr_t)(xx_arg2), (uintptr_t)(xx_arg3)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + The following MACROs are for LEGACY diagnostic messages support. +---------------------------------------------------------------------------*/ + +/*=========================================================================== + +MACRO MSG_FATAL, MSG_ERROR, MSG_HIGH, MSG_MED, MSG_LOW + +DESCRIPTION + Output a message to be sent to be picked up by the Diag Task. The + message levels are controlled by selecting the proper macro function. + + MSG_FATAL fatal + MSG_ERROR error + MSG_HIGH high + MSG_MED medium + MSG_LOW low + + Generation of message generating code is controlled by the setting + of the MSG_LEVEL #define (defined above and on the 'cl' command line). + +PARAMETERS + x_fmt Format string for message (printf style). Note, this parameter + must be a string literal (e.g. "Tuned to %lx"), not a variable. + This is because the value is compiled into ROM, and can clearly + not be a dynamic data type. + a 1st parameter for format string + b 2nd parameter for format string + c 3rd parameter for format string + +DEPENDENCIES + msg_init() must be called prior to this macro referencing msg_put(). + This macro, is multiple C expressions, and cannot be used as if it + is a single expression. + +RETURN VALUE + None + +SIDE EFFECTS + On the target hardware, the file and format strings are placed in ROM. + +===========================================================================*/ +#if defined (FEATURE_ERR_EXTENDED_STORE) && defined (FEATURE_SAVE_DEBUG_TRACE) + +#define MSG_FATAL(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_FATAL, x_fmt, a, b, c, TRUE) + +#define MSG_ERROR(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_ERROR, x_fmt, a, b, c, TRUE) + +#define MSG_HIGH(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_HIGH, x_fmt, a, b, c, TRUE) + +#define MSG_MED(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_MED, x_fmt, a, b, c, TRUE) + +#define MSG_LOW(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_LOW, x_fmt, a, b, c, TRUE) + +#else /* if not FEATURE_SAVE_DEBUG_TRACE */ + +#define MSG_FATAL(x_fmt, a, b, c) \ + MSG_3 (MSG_SSID_DFLT, MSG_LEGACY_FATAL, x_fmt, a, b, c) + +#define MSG_ERROR(x_fmt, a, b, c) \ + MSG_3 (MSG_SSID_DFLT, MSG_LEGACY_ERROR, x_fmt, a, b, c) + +#define MSG_HIGH(x_fmt, a, b, c) \ + MSG_3 (MSG_SSID_DFLT, MSG_LEGACY_HIGH, x_fmt, a, b, c) + +#define MSG_MED(x_fmt, a, b, c) \ + MSG_3 (MSG_SSID_DFLT, MSG_LEGACY_MED, x_fmt, a, b, c) + +#define MSG_LOW(x_fmt, a, b, c) \ + MSG_3 (MSG_SSID_DFLT, MSG_LEGACY_LOW, x_fmt, a, b, c) + +#endif /* FEATURE_SAVE_DEBUG_TRACE */ + +#if defined (FEATURE_ERR_EXTENDED_STORE) && defined (FEATURE_SAVE_DEBUG_TRACE) +/*=========================================================================== + +MACRO MSG_FATAL_NO_SAVE, MSG_ERROR_NO_SAVE, MSG_HIGH_NO_SAVE, MSG_MED_NO_SAVE, MSG_LOW_NO_SAVE + +DESCRIPTION + Output a message to be sent to be picked up by the Diag Task. The + message levels are controlled by selecting the proper macro function. + + MSG_FATAL_NO_SAVE fatal + MSG_ERROR_NO_SAVE error + MSG_HIGH_NO_SAVE high + MSG_MED_NO_SAVE medium + MSG_LOW_NO_SAVE low + + Generation of message generating code is controlled by the setting + of the MSG_LEVEL #define (defined above and on the 'cl' command line). + + The use of these macros will cause the const type to not be saved to the + RAM buffer. + +PARAMETERS + x_fmt Format string for message (printf style). Note, this parameter + must be a string literal (e.g. "Tuned to %lx"), not a variable. + This is because the value is compiled into ROM, and can clearly + not be a dynamic data type. + a 1st parameter for format string + b 2nd parameter for format string + c 3rd parameter for format string + +DEPENDENCIES + msg_init() must be called prior to this macro referencing msg_put(). + This macro, is multiple C expressions, and cannot be used as if it + is a single expression. + +RETURN VALUE + None + +SIDE EFFECTS + On the target hardware, the file and format strings are placed in ROM. + +===========================================================================*/ + +#define MSG_FATAL_NO_SAVE(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_FATAL, x_fmt, a, b, c, FALSE) + +#define MSG_ERROR_NO_SAVE(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_ERROR, x_fmt, a, b, c, FALSE) + +#define MSG_HIGH_NO_SAVE(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_HIGH, x_fmt, a, b, c, FALSE) + +#define MSG_MED_NO_SAVE(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_MED, x_fmt, a, b, c, FALSE) + +#define MSG_LOW_NO_SAVE(x_fmt, a, b, c) \ + MSG_3_SAVE (MSG_SSID_DFLT, MSG_LEGACY_LOW, x_fmt, a, b, c, FALSE) + +#else /* Not FEATURE_SAVE_DEBUG_TRACE */ +#define MSG_FATAL_NO_SAVE(x_fmt, a, b, c) MSG_FATAL (x_fmt, a, b, c) + +#define MSG_ERROR_NO_SAVE(x_fmt, a, b, c) MSG_ERROR (x_fmt, a, b, c) + +#define MSG_HIGH_NO_SAVE(x_fmt, a, b, c) MSG_HIGH (x_fmt, a, b, c) + +#define MSG_MED_NO_SAVE(x_fmt, a, b, c) MSG_MED (x_fmt, a, b, c) + +#define MSG_LOW_NO_SAVE(x_fmt, a, b, c) MSG_LOW (x_fmt, a, b, c) +#endif /* FEATURE_SAVE_DEBUG_TRACE */ + +/* Legacy stop-gap solutions to the need for string transport in MSG services. */ +#define MSG_STR_ERROR(x_fmt, s, a, b, c) +#define MSG_STR_HIGH(x_fmt, s, a, b, c) +#define MSG_STR_MED(x_fmt, s, a, b, c) +#define MSG_STR_LOW(x_fmt, s, a, b, c) + +/* These are unnecessary except for the fact that some of the legacy messages + out there have been compiled out for so long that they have args that are + invalid. The above will cause the compiler to reference those args, even + though they are optimized away. Therefore, we must do the following until + all such cases are fixed. */ + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_FATAL) + + #undef MSG_FATAL + #define MSG_FATAL(x, a, b, c) + +#endif + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_ERROR) + + #undef MSG_ERROR + #define MSG_ERROR(x, a, b, c) + +#endif + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_HIGH) + + #undef MSG_HIGH + #define MSG_HIGH(x, a, b, c) + +#endif + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_MED) + + #undef MSG_MED + #define MSG_MED(x, a, b, c) + +#endif + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_LOW) + + #undef MSG_LOW + #define MSG_LOW(x, a, b, c) + +#endif + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +/* ------------------------------------------------------------------------- + Function Definitions + ------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*=========================================================================== + +FUNCTION MSG_INIT + +DESCRIPTION + Initialize the message reporting services + +DEPENDENCIES + Can only be called by one task. + +RETURN VALUE + None + +SIDE EFFECTS + Sets the counts to 0, and throws away any buffered messages. + +===========================================================================*/ + void msg_init (void); + +/*=========================================================================== + +FUNCTION MSG_SEND + +DESCRIPTION + This will build a new style diagnostic Message with no parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void msg_send (const msg_const_type * xx_msg_const_ptr); + +/*=========================================================================== + +FUNCTION MSG_SEND_1 + +DESCRIPTION + This will build a new style diagnostic Message with 1 parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void msg_send_1 (const msg_const_type * xx_msg_const_ptr, uint32 xx_arg1); + +/*=========================================================================== + +FUNCTION MSG_SEND_2 + +DESCRIPTION + This will build a new style diagnostic Message with 2 parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void msg_send_2 (const msg_const_type * xx_msg_const_ptr, uint32 xx_arg1, + uint32 xx_arg2); + +/*=========================================================================== + +FUNCTION MSG_SEND_3 + +DESCRIPTION + This will build a new style diagnostic Message with 3 parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void msg_send_3 (const msg_const_type * xx_msg_const_ptr, uint32 xx_arg1, + uint32 xx_arg2, uint32 xx_arg3); + +/*=========================================================================== + +FUNCTION MSG_SEND_VAR + +DESCRIPTION + This will build a new style diagnostic Message with var # (4 to 6) + of parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void msg_send_var (const msg_const_type * xx_msg_const_ptr, uint32 num_args, + ...); + +/*=========================================================================== + +FUNCTION MSG_SPRINTF + +DESCRIPTION + This will build a message sprintf diagnostic Message with var # (1 to 6) + of parameters. + Do not call directly; use macro MSG_SPRINTF_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void msg_sprintf(const msg_const_type * const_blk,...); + +/*=========================================================================== + +FUNCTION MSG_SEND_TS + +DESCRIPTION + This will build a message with no parameter, and allow user to pass in a + timestamp. Limited usage: only for Native Debug messages like WM RETAILMSG etc + Do not call directly, use MSG_TS macro + +DEPENDENCIES + msg_init() and Diag_LSM_Init() must have been called previously. + A free buffer must be available or the message will be ignored + (never buffered). + +===========================================================================*/ +void msg_send_ts(const msg_const_type *const_blk, uint64 timestamp); + + +#if defined (FEATURE_ERR_EXTENDED_STORE) && defined (FEATURE_SAVE_DEBUG_TRACE) +/*=========================================================================== + +FUNCTION MSG_SAVE_3 + +DESCRIPTION + Saves the F3 message to the RAM buffer. Also called from the ERR_FATAL + macro. + +DEPENDENCIES + None + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void msg_save_3(const msg_const_type*, + uint32, uint32, uint32, msg_ext_store_type*); +/*=========================================================================== + +FUNCTION MSG_GET_NUM_ARGS + +DESCRIPTION + Determines the number of arguments in a given constant data pointer. It + scans the fmt field and determines the number of %'s. The printf conversion + of "%%" is not meant to be an argument. Therefore, must do a check so it + doesn't increase the count of arguments. + +DEPENDENCIES + None + +RETURN VALUE + Number of arguments required in a format string + +SIDE EFFECTS + None + +===========================================================================*/ +uint8 msg_get_num_args(const msg_const_type * const_data_ptr); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* FEATURE_L4_KERNEL */ +#endif /* MSG_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/msg_arrays_i.h b/feeds/wifi-ax/qca-diag/src/include/msg_arrays_i.h new file mode 100755 index 000000000..819f09755 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/msg_arrays_i.h @@ -0,0 +1,55 @@ +#ifndef MSG_ARRAYS_I_H +#define MSG_ARRAYS_I_H + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + DIAGNOSTIC MESSAGE SERVICE: ARRAYS FOR BUILD/RUN-TIME MASKS + + +GENERAL DESCRIPTION + Internal Header File. Contains structures/definitions for message masks. + +Copyright (c) 2009 by Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + + $Header: //source/qcom/qct/core/services/diag/main/latest/diag_mask_tbl/src/msg_arrays_i.h#1 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +11/10/09 sg Moved MSG_MASK_TBL_CNT to msgcfg.h +09/29/09 mad Created from msgcfg.h. +===========================================================================*/ + +#include "comdef.h" + +/*--------------------------------------------------------------------------- + This is the structure used for both the build mask array and the RT mask + array. It consists of a range of IDs and a pointer to an array indexed + as follows: + + index: + SSID - ssid_start + + Total # of entries: + ssid_last - ssid_first + 1; +---------------------------------------------------------------------------*/ +typedef struct +{ + uint16 ssid_first; /* Start of range of supported SSIDs */ + uint16 ssid_last; /* Last SSID in range */ + + /* Array of (ssid_last - ssid_first + 1) masks */ + const uint32 *bt_mask_array; + uint32 *rt_mask_array; +} +msg_mask_tbl_type; + +extern const msg_mask_tbl_type msg_mask_tbl[]; +/* Number of SSID range entries in table */ + +#endif /* MSG_ARRAYS_I_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/msg_pkt_defs.h b/feeds/wifi-ax/qca-diag/src/include/msg_pkt_defs.h new file mode 100755 index 000000000..fbb25bf28 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/msg_pkt_defs.h @@ -0,0 +1,154 @@ +#ifndef MSG_PKT_DEFS_H +#define MSG_PKT_DEFS_H + +/*! + @ingroup diag_message_service + @file msg_pkt_defs.h + @brief + Diagnostic Debug Message Service Packet Definitions and structures + + @par OVERVIEW: + The debug message service provides printf()-style debugging + with build-time and run-time granularity. This granularity + is achieved by assigning various technology areas to a + subsystem within the service. Each subsystem defines up to + 32 categories (denoted by a 32-bit mask) by which debug + messages may be identified. The external device may + configure each subsystem individually using a 32-bit mask + for each subsystem. + + + @par TERMINOLOGY: + Subsystem ID (SSID): + Unique identifer given to each subsystem within the target. + + @par Subsystem Mask: + 32-bit value with each bit denotes a category assigned by + the technology area assigned to the subsystem ID. + '1' denotes the category is enabled. + '0' denotes the category is disabled. + This mask is specified with the definition of each message. + + @par Build Mask: + A 32-bit mask specified at compile-time to determine which + messages are to be compiled in for each subsystem. This + build-time granularity is available to enable build managers + to compile out certain categories of messages to save ROM. + During compilation, a bitwise AND ('&') is performed between + the Build Mask and the Subsystem Mask of each message. If + the '&' operation is non-zero, the message is compiled in. + + @par Run-Time Mask (RT Mask): + A 32-bit mask specified at by the external device at run-time + to configure messages for a subsystem. At run-time, the + message's Subsystem Mask the subsystem's RT Mask are compared + with a bitwise AND ('&'). If the result if non-zero, the + message service attempts to send the message. + + @par Dropped Message: + If insuffient resources exist to send a message that is + enabled, the message is dropped. The next successful message + sent will contain a count of the number of messages dropped + since the last successful message. + + + @note + These packet definitions are part of an externalized + diagnostic command interface, defined in 80-V1294-1 + (CDMA Dual-Mode Subscriber Station Serial Data Interface Control + Document). These definitions must not be changed. +*/ +/* +Copyright (c) 2002-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +*/ + +/*=========================================================================== + + Edit History + + $Header: //source/qcom/qct/core/api/services/diag/main/latest/msg_pkt_defs.h#2 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +05/27/10 mad Doxygenated. +01/23/09 sg Moved msg_desc_type, msg_hdr_type here +05/15/09 mad Moved msg_desc_type, msg_hdr_type to msg.h. Included msg.h. +10/03/08 vg Updated code to use PACK() vs. PACKED +04/23/07 as Enabled pragma pack support for WINCE targets +11/04/04 as Added GW field for WCDMA phones in msg_ts_type +07/23/02 lad Updated to reflect requirements changes and final + implementation. +03/22/02 igt Created file. +===========================================================================*/ +#include "comdef.h" + +/* -------------------------------------------------------------------------- + Definitions and Declarations + ----------------------------------------------------------------------- */ +/*! +@ingroup diag_message_service + This structure is stored in ROM and is copied blindly by the phone. + The values for the fields of this structure are known at compile time. + So this is to be defined as a "static const" in the MACRO, so it ends up + being defined and initialized at compile time for each and every message + in the software. This minimizes the amount of work to do during run time. + + So this structure is to be used in the "caller's" context. "Caller" is the + client of the Message Services. +*/ +typedef struct { + uint16 line; /*!< Line number in source file */ + uint16 ss_id; /*!< Subsystem ID */ + uint32 ss_mask; /*!< Subsystem Mask */ +} msg_desc_type; + +/*! +@ingroup diag_message_service + This is the message HEADER type. It contains the beginning fields of the + packet and is of fixed length. These fields are filled by the calling task. +*/ +typedef struct { + uint8 cmd_code; /*!< Command code */ + uint8 ts_type; /*!< Time stamp type */ + uint8 num_args; /*!< Number of arguments in message */ + uint8 drop_cnt; /*!< number of messages dropped since last successful message */ + uint32 ts_lo; /* Time stamp */ + uint32 ts_hi; +} msg_hdr_type; + +/*! +@ingroup diag_message_service +This structure defines the Debug message packet :command-code 125, DIAG_MSG_EXT_F. +Provides debug messages with NULL terminated filename and format fields, a +variable number of 32-bit parameters, an originator-specific timestamp +format and filterability via subsystem ids and masks. +@par +For simplicity, only 'long' arguments are supported. This packet +allows for N arguments, though the macros support a finite number. +@note +This is the structure that is used to represent the final structure that is +sent to the external device. 'msg_ext_store_type' is expanded to this +structure in DIAG task context at the time it is sent to the communication +layer. +*/ +typedef struct { + msg_hdr_type hdr; /*!< Header */ + msg_desc_type desc; /*!< line number, SSID, mask */ + uint32 args[1]; /*!< Array of long args, specified by 'hdr.num_args' */ + /*!< followed by NULL terminated format and file strings */ +} msg_ext_type; + +/*--------------------------------------------------------------------------- + This is the structure that is used to represent the final structure that + is sent to the external device. 'msg_ext_store_type' is expanded to this + structure in DIAG task context at the time it is sent to the comm layer. +---------------------------------------------------------------------------*/ +typedef struct +{ + msg_hdr_type hdr; + msg_desc_type desc; + uint32 msg_hash; + uint32 args[1]; +} msg_qsr_type; + +#endif /* MSG_PKT_DEFS_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/msg_qsr.h b/feeds/wifi-ax/qca-diag/src/include/msg_qsr.h new file mode 100755 index 000000000..0693bf412 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/msg_qsr.h @@ -0,0 +1,512 @@ +#ifndef MSG_QSR_H +#define MSG_QSR_H + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + EXTENDED DIAGNOSTIC QSHRINK MESSAGE SERVICE HEADER FILE + +GENERAL DESCRIPTION + + All the declarations and definitions necessary to support the optimized f3 + messages for errors and debugging. This includes support for the + extended capabilities as well as the legacy messaging scheme. + +Copyright (c) 2009-2011, 2014 by Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + +$Header: //depot/asic/msmshared/services/diag/MSMSHARED_DIAG_1.2/msg_qsr.h#2 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/11/09 vg 8200 Warning Clean Up +20/05/09 ps Created new file for qsr feature based on msg.h + +===========================================================================*/ + +/*=========================================================================== + + INCLUDE FILES FOR MODULE + +===========================================================================*/ +#include "comdef.h" /* Definitions for byte, word, etc. */ +#include "msg_pkt_defs.h" +#include "msgcfg.h" + +/*--------------------------------------------------------------------------- + The extended message packet is defined to be processed as efficiently as + possible in the caller's context. Therefore, the packet is divided into + logical blocks that are aligned w/out declaring the structure as PACK. + + A header, static constant block, and argument list are defined to minimize + the work done by the caller's task. + + 1. Header + 2. Constant variable length data (format string and filename string, etc). + 3. Arguments ("Variable" variable-length data) + + The data is delivered in this order in the packet to simplify the runtime + processing of each message. All constant data is handled in DIAG task + context, leaving the caller's task to only process variable data at runtime. + + The phone will never process the constant data directly, except to copy + format and filename strings. +---------------------------------------------------------------------------*/ +/*--------------------------------------------------------------------------- + All constant information stored for a message. + + The values for the fields of this structure are known at compile time. + So this is to be defined as a "static " in the MACRO, so it ends up + being defined and initialized at compile time for each and every message + in the software. This minimizes the amount of work to do during run time. + + So this structure is to be used in the "caller's" context. "Caller" is the + client of the Message Services. +---------------------------------------------------------------------------*/ +typedef struct +{ + msg_desc_type desc; /* ss_mask, line, ss_id */ + uint32 msg_hash; /* message hash value */ +} +msg_qsr_const_type; + + /*--------------------------------------------------------------------------- + This is the structure that is stored by the caller's task in msg_send (). + The DIAG task will expand the constant data into the final packet before + sending to the external device. + ---------------------------------------------------------------------------*/ + typedef struct + { + msg_hdr_type hdr; + const msg_qsr_const_type* qsr_const_data_ptr; /* desc */ + uint32 args[1]; + } + msg_qsr_store_type; + + + #define XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash) \ + static const msg_qsr_const_type xx_msg_qsr_const = { \ + {__LINE__, (xx_ss_id), (xx_ss_mask)}, hash} + + #define XX_QSR_MSG_CONST_FMT_VAR(xx_ss_id, xx_ss_mask,hash) \ + const msg_qsr_const_type xx_msg_qsr_const = { \ + {__LINE__, (xx_ss_id), (xx_ss_mask)}, hash} + + +/*--------------------------------------------------------------------------- + These are the message macros that support messages with variable number + of parameters and message text of over 40 characters. + This is the macro for messages with no params but only a text string. +---------------------------------------------------------------------------*/ +#define QSR_MSG(hash, xx_ss_id, xx_ss_mask, xx_fmt) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send (&xx_msg_qsr_const); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + Macro for messages with 1 parameter. +---------------------------------------------------------------------------*/ +#define QSR_MSG_1(hash, xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_1 (&xx_msg_qsr_const, (uint32)(xx_arg1)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + Macro for messages with 2 parameters. +---------------------------------------------------------------------------*/ +#define QSR_MSG_2(hash,xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_2 (&xx_msg_qsr_const,(uint32)(xx_arg1), (uint32)(xx_arg2)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 3 parameters. +---------------------------------------------------------------------------*/ +#define QSR_MSG_3(hash,xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_3( &xx_msg_qsr_const,(uint32) (xx_arg1), (uint32) (xx_arg2), \ + (uint32) (xx_arg3)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 4 parameters. In this case the function + called needs to have more than 4 parameters so it is going to be a slow + function call. So for this case the msg_send_var() uses var arg list + supported by the compiler. +---------------------------------------------------------------------------*/ +#define QSR_MSG_4(hash,xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_var (&xx_msg_qsr_const, (uint32)(4), \ + (uintptr_t) (xx_arg1), (uintptr_t) (xx_arg2), \ + (uintptr_t) (xx_arg3), (uintptr_t) (xx_arg4)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 5 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define QSR_MSG_5(hash,xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_var(&xx_msg_qsr_const, (uint32)(5), \ + (uintptr_t)(xx_arg1), (uintptr_t)(xx_arg2), \ + (uintptr_t)(xx_arg3), (uintptr_t)(xx_arg4), \ + (uintptr_t)(xx_arg5)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 6 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define QSR_MSG_6(hash,xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_var (&xx_msg_qsr_const, (uint32)(6), \ + (uintptr_t)(xx_arg1), (uintptr_t)(xx_arg2), \ + (uintptr_t)(xx_arg3), (uintptr_t)(xx_arg4), \ + (uintptr_t)(xx_arg5), (uintptr_t)(xx_arg6)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 7 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define QSR_MSG_7(hash,xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6, \ + xx_arg7) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_var(&xx_msg_qsr_const, (uint32)(7), \ + (uintptr_t)(xx_arg1), (uintptr_t)(xx_arg2), \ + (uintptr_t)(xx_arg3), (uintptr_t)(xx_arg4), \ + (uintptr_t)(xx_arg5), (uintptr_t)(xx_arg6), \ + (uintptr_t)(xx_arg7)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 8 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define QSR_MSG_8(hash,xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6, \ + xx_arg7, xx_arg8) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_var(&xx_msg_qsr_const, (uint32)(8), \ + (uintptr_t)(xx_arg1), (uintptr_t)(xx_arg2), \ + (uintptr_t)(xx_arg3), (uintptr_t)(xx_arg4), \ + (uintptr_t)(xx_arg5), (uintptr_t)(xx_arg6), \ + (uintptr_t)(xx_arg7), (uintptr_t)(xx_arg8)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + +/*--------------------------------------------------------------------------- + This is the macro for messages with 9 parameters. msg_send_var() uses var + arg list supported by the compiler. +---------------------------------------------------------------------------*/ +#define QSR_MSG_9(hash,xx_ss_id, xx_ss_mask, xx_fmt, xx_arg1, xx_arg2, xx_arg3, \ + xx_arg4, xx_arg5, xx_arg6, \ + xx_arg7, xx_arg8, xx_arg9) \ + do { \ + /*lint -e506 -e774*/ \ + if (xx_ss_mask & (MSG_BUILD_MASK_ ## xx_ss_id)) { \ + /*lint +e506 +e774*/ \ + XX_QSR_MSG_CONST(xx_ss_id, xx_ss_mask, hash); \ + /*lint -e571 */ \ + qsr_msg_send_var(&xx_msg_qsr_const, (uint32)(9), \ + (uintptr_t)(xx_arg1), (uintptr_t)(xx_arg2), \ + (uintptr_t)(xx_arg3), (uintptr_t)(xx_arg4), \ + (uintptr_t)(xx_arg5), (uintptr_t)(xx_arg6), \ + (uintptr_t)(xx_arg7), (uintptr_t)(xx_arg8), \ + (uintptr_t)(xx_arg9)); \ + /*lint +e571 */ \ + } \ + /*lint -e717 */ \ + } while (0) \ + /* lint +e717 */ + + +// TODO: MSG_EXPENSIVE: on target string expansion (name?) + +/*--------------------------------------------------------------------------- + The following MACROs are for LEGACY diagnostic messages support. +---------------------------------------------------------------------------*/ + +/*=========================================================================== + +MACRO MSG_FATAL, MSG_ERROR, MSG_HIGH, MSG_MED, MSG_LOW + +DESCRIPTION + Output a message to be sent to be picked up by the Diag Task. The + message levels are controlled by selecting the proper macro function. + + MSG_FATAL fatal + MSG_ERROR error + MSG_HIGH high + MSG_MED medium + MSG_LOW low + + Generation of message generating code is controlled by the setting + of the MSG_LEVEL #define (defined above and on the 'cl' command line). + +PARAMETERS + x_fmt Format string for message (printf style). Note, this parameter + must be a string literal (e.g. "Tuned to %lx"), not a variable. + This is because the value is compiled into ROM, and can clearly + not be a dynamic data type. + a 1st parameter for format string + b 2nd parameter for format string + c 3rd parameter for format string + +DEPENDENCIES + msg_init() must be called prior to this macro referencing msg_put(). + This macro, is multiple C expressions, and cannot be used as if it + is a single expression. + +RETURN VALUE + None + +SIDE EFFECTS + On the target hardware, the file and format strings are placed in ROM. + +===========================================================================*/ + +#define QSR_MSG_FATAL(hash,x_fmt, a, b, c) \ + QSR_MSG_3 (hash,MSG_SSID_DFLT, MSG_LEGACY_FATAL, x_fmt, a, b, c) + +#define QSR_MSG_ERROR(hash, x_fmt, a, b, c) \ + QSR_MSG_3 (hash, MSG_SSID_DFLT, MSG_LEGACY_ERROR, x_fmt, a, b, c) + +#define QSR_MSG_HIGH(hash, x_fmt, a, b, c) \ + QSR_MSG_3 (hash, MSG_SSID_DFLT, MSG_LEGACY_HIGH, x_fmt, a, b, c) + +#define QSR_MSG_MED(hash,x_fmt, a, b, c) \ + QSR_MSG_3 (hash,MSG_SSID_DFLT, MSG_LEGACY_MED, x_fmt, a, b, c) + +#define QSR_MSG_LOW(hash,x_fmt, a, b, c) \ + QSR_MSG_3 (hash,MSG_SSID_DFLT, MSG_LEGACY_LOW, x_fmt, a, b, c) + + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_FATAL) + + #undef QSR_MSG_FATAL + #define QSR_MSG_FATAL(hash, x_fmt, a, b, c) + +#endif + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_ERROR) + + #undef QSR_MSG_ERROR + #define QSR_MSG_ERROR(hash, x_fmt, a, b, c) + +#endif + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_HIGH) + + #undef QSR_MSG_HIGH + #define QSR_MSG_HIGH(hash, x_fmt, a, b, c) + +#endif + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_MED) + + #undef QSR_MSG_MED + #define QSR_MSG_MED(hash, x_fmt, a, b, c) + +#endif + +#if !(MSG_BUILD_MASK_MSG_SSID_DFLT & MSG_LEGACY_LOW) + + #undef QSR_MSG_LOW + #define QSR_MSG_LOW(hash, x_fmt, a, b, c) + +#endif + +/* ------------------------------------------------------------------------- + Function Definitions + ------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*=========================================================================== + +FUNCTION QSR_MSG_SEND + +DESCRIPTION + This will build a new style diagnostic Message with no parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void qsr_msg_send ( const msg_qsr_const_type * xx_msg_const_ptr); + +/*=========================================================================== + +FUNCTION QSR_MSG_SEND_1 + +DESCRIPTION + This will build a new style diagnostic Message with 1 parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void qsr_msg_send_1 (const msg_qsr_const_type * xx_msg_const_ptr, uint32 xx_arg1); + +/*=========================================================================== + +FUNCTION QSR_MSG_SEND_2 + +DESCRIPTION + This will build a new style diagnostic Message with 2 parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void qsr_msg_send_2 ( const msg_qsr_const_type * xx_msg_const_ptr,uint32 xx_arg1, + uint32 xx_arg2); + +/*=========================================================================== + +FUNCTION QSR_MSG_SEND_3 + +DESCRIPTION + This will build a new style diagnostic Message with 3 parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void qsr_msg_send_3 ( const msg_qsr_const_type * xx_msg_const_ptr, uint32 xx_arg1, + uint32 xx_arg2, uint32 xx_arg3); + +/*=========================================================================== + +FUNCTION QSR_MSG_SEND_VAR + +DESCRIPTION + This will build a new style diagnostic Message with var # (4 to 6) + of parameters. + Do not call directly; use macro MSG_* defined in msg.h + + Send a message through diag output services. + +DEPENDENCIES + msg_init() must have been called previously. A free buffer must + be available or the message will be ignored (never buffered). + +===========================================================================*/ + void qsr_msg_send_var ( const msg_qsr_const_type * xx_msg_const_ptr, uint32 num_args, ...); + + +#ifdef __cplusplus +} +#endif + +#endif /* MSG_QSR_H */ + diff --git a/feeds/wifi-ax/qca-diag/src/include/msgcfg.h b/feeds/wifi-ax/qca-diag/src/include/msgcfg.h new file mode 100755 index 000000000..72d9f2354 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/msgcfg.h @@ -0,0 +1,7038 @@ +#ifndef MSGCFG_H +#define MSGCFG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + @ingroup diag_message_service + @file msgcfg.h + @brief + Configuration file for Diagnostic Message 2.0 Service + @par + MSG 2.0 offers the ability to utilize more build-time and run-time + filtering of debug messages. + @par + This file contains definitions to identify subsystem IDs (SSIDs) and + the ability to map legacy debug messages (MSG_LOW, MSG_MED, etc) to + different SSIDs. SSIDs are externally published and must not change + once published. + @par + This file includes msgtgt.h, which is a target-specific file used to + customize MSG 2.0's configuration. It may specify SSID build masks, + the default build mask (for undefined build masks), and other + configurable features. Defaults are listed in this file. + @note + All the SSIDs and default mask settings are not documented, for the sake of + brevity. +*/ + +/* +Copyright (c) 2002-2016 by Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary +*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + + $Header: //source/qcom/qct/core/api/services/diag/main/latest/msgcfg.h#49 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +03/31/14 xy Added new message SSIDs +01/29/14 xy Added new message SSIDs +12/03/13 xy Added new message SSIDs +09/25/13 xy Added new message SSIDs +07/30/13 sr Added new message SSIDs +06/26/13 sr Added new message SSIDs +05/08/13 sr Added new message SSIDs +03/22/13 sr Added new message SSIDs +03/12/13 sr Added new message SSIDs +01/22/13 sr Added new message SSIDs +12/07/12 sr Added new message SSIDs +11/27/12 sr Added new message SSIDs +10/15/12 sr Added new message SSIDs for QCNEA group +07/16/12 rh Added new message SSIDs +06/22/12 rh Added new message SSIDs +02/21/12 is Add MSG_BUILD_MASK_LEGACY catergory to support F3 listener testing +02/29/12 rh Added new message SSIDs +02/17/12 rs Added MSG_SSID_SEC_WIDEVINE in Security category +01/05/12 rh Added QCNEA SSIDs +12/08/11 rh Added MSG_SSID_ADC +11/29/11 rh Added SSID category for CTA +10/18/11 hm Renamed reserved MCS SSIDs +09/01/11 hm Added new WCDMA and TDSCDMA SSIDs +08/05/11 hm Added new SSID +07/01/11 hm New SSID added +04/26/11 is Resolve modem compilation issue +04/25/11 hm Added new SSID +04/05/11 hm Added new SSID for PPM module +03/24/11 hm Reverted Octopus Changes and added new QCHAT SSIDs +03/07/11 hm Added new set of SSIDs for Octopus +07/27/10 sg Added new SSID for Multimedia team +07/07/10 sg Added new SSID for Data Services +07/06/10 sg Changed MSG_SSID_MCS_RESERVED_1 to MSG_SSID_FWS +06/10/10 mad Doxygenated +05/05/10 sg Added new SSID MSG_SSID_CFM +04/27/10 sg Added new SSIDS for Sound Routing Driver , DAL +04/20/10 sg Added new SSIDS for Audio Team +04/09/10 sg Added new SSIDS for OMA device management + Secure Instant Wireless Access +04/02/10 sg Cleaning up the msg.h inclusion +03/04/10 sg Added new SSID for IMS team +02/22/10 sg Added new SSIDs for Data Services +02/08/10 sg Added new SSIDs for IMS team +01/13/10 sg Added new SSID for CAD team +12/22/09 sg Moved MSG_MASK_TBL_CNT to msgcfg.h +12/22/09 sg Added New SSID for Connectivity Engine Team +10/28/09 sg Added New SSID for Chaos CoOrdinator Service +10/22/09 sg Added new SSID for DS_MUX +09/29/09 mad Removed MSG_TBL_GEN feature. Moved all array definitions + to an internal header file, msg_arrays_i.h +09/23/09 sg Added new SSID for the ECALL feature +09/02/09 JV Added new SSIDs for the HDR team +08/04/09 JV Support for compiling on C++ +07/27/09 JV New SSID for ANDROID data and DS apps +07/16/09 mad Mainlined FEATUREs: IS2000, HDR, WCDMA, GSM, WLAN, DS, + DATA, HIT. msg_mask_tbl contents are now free of the above + external featurizations. +06/11/09 JV New SSID for data services +05/11/09 JV New SSIDs for Android QCRIL and A2 modules +04/23/09 JV Added SSIDs for the WLAN libra module. +04/10/09 JV Added SSIDs for MCS. +03/16/09 mad Featurized inclusion of customer.h +09/11/08 sj Included size for table and Fixed orphan file issue by FTM +12/15/06 as Fixed compiler warnings. +12/14/04 as Reallocated SSID's used by WinCE to L4LINUX. +03/07/03 lad Initial SSID deployment. +12/03/02 lad Created file. + +===========================================================================*/ +#include "comdef.h" + +#include "msgtgt.h" /* Target-specific MSG config info, such as build masks */ + +/*! +@ingroup diag_message_service +@name Some constants used in MSG macro implementation +*/ +/*@{*/ /* start group Some constants used in MSG macro implementation */ +/*! +This constant specifies the default maximum file and format string length. + It should be arbitrarily large as it is only used to protect against + invalid string pointers. */ +#ifndef MSG_MAX_STRLEN + #define MSG_MAX_STRLEN 512 +#endif + +/*! Default build mask for all SSIDs may be specified in msgtgt.h. + MSG_LEVEL is the minimum message priority which can be logged. If MSG_LEVEL + is not defined, default is NONE. If MSG_LEVEL is set to MSG_LVL_NONE, then + there will be no calls to msg_send() etc. +*/ +#ifndef MSG_BUILD_MASK_DFLT + #ifdef MSG_LEVEL + #define MSG_BUILD_MASK_DFLT MSG_LEVEL + #else + #define MSG_BUILD_MASK_DFLT 0 + #endif +#endif + +#ifndef MSG_LEVEL + #define MSG_LEVEL MSG_LVL_NONE +#endif + +#ifndef MSG_BUILD_MASK_LEGACY + #define MSG_BUILD_MASK_LEGACY 0 +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_DFLT +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_LEGACY + #define MSG_BUILD_MASK_MSG_SSID_LEGACY MSG_BUILD_MASK_LEGACY +#endif + + +/*@}*/ /* start group Some constants used in MSG macro implementation */ + +/*! +@cond DOXYGEN_BLOAT +*/ +/*--------------------------------------------------------------------------- + This section contains configuration entries for all SSIDs. + + Build-time filtering is accomplsihed using a name hash in a macro. As a + result, naming convention must be adhered to. + + SSIDs must be common and unique across all targets. The SSIDs and the + meaning of the mask bits for the SSID are to be published in an externalized + interface. They cannot be change once published. + + Not all targets support all SSIDs. + + MSG_SSID_DFLT is used to expand legacy macros (MSG_LOW, MSG_MED, e.t.c.). + Legacy macros may be mapped to another SSID (listed here) via the build + environment. For each invocation of the compiler, MSG_BT_SSID_LEGACY may + be specified to override the default SSID for legacy macros (0). + +---------------------------------------------------------------------------*/ + +#define MSG_SSID_GEN_FIRST 0 + /* Legacy messages may be mapped to a different SSID + by the build environment. */ + #define MSG_SSID_DFLT 0 + #define MSG_SSID_LEGACY 0 + #define MSG_SSID_AUDFMT 1 + #define MSG_SSID_AVS 2 + #define MSG_SSID_BOOT 3 + #define MSG_SSID_BT 4 + #define MSG_SSID_CM 5 + #define MSG_SSID_CMX 6 + #define MSG_SSID_DIAG 7 + #define MSG_SSID_DSM 8 + #define MSG_SSID_FS 9 + #define MSG_SSID_HS 10 + #define MSG_SSID_MDSP 11 + #define MSG_SSID_QDSP 12 + #define MSG_SSID_REX 13 + #define MSG_SSID_RF 14 + #define MSG_SSID_SD 15 + #define MSG_SSID_SIO 16 + #define MSG_SSID_VS 17 + #define MSG_SSID_WMS 18 + #define MSG_SSID_GPS 19 + #define MSG_SSID_MMOC 20 + #define MSG_SSID_RUIM 21 + #define MSG_SSID_TMC 22 + #define MSG_SSID_FTM 23 + #define MSG_SSID_MMGPS 24 + #define MSG_SSID_SLEEP 25 + #define MSG_SSID_SAM 26 + #define MSG_SSID_SRM 27 + #define MSG_SSID_SFAT 28 + #define MSG_SSID_JOYST 29 + #define MSG_SSID_MFLO 30 + #define MSG_SSID_DTV 31 + #define MSG_SSID_TCXOMGR 32 + #define MSG_SSID_EFS 33 + #define MSG_SSID_IRDA 34 + #define MSG_SSID_FM_RADIO 35 + #define MSG_SSID_AAM 36 + #define MSG_SSID_BM 37 + #define MSG_SSID_PE 38 + #define MSG_SSID_QIPCALL 39 + #define MSG_SSID_FLUTE 40 + #define MSG_SSID_CAMERA 41 + #define MSG_SSID_HSUSB 42 + #define MSG_SSID_FC 43 + #define MSG_SSID_USBHOST 44 + #define MSG_SSID_PROFILER 45 + #define MSG_SSID_MGP 46 + #define MSG_SSID_MGPME 47 + #define MSG_SSID_GPSOS 48 + #define MSG_SSID_MGPPE 49 + #define MSG_SSID_GPSSM 50 + #define MSG_SSID_IMS 51 + #define MSG_SSID_MBP_RF 52 + #define MSG_SSID_SNS 53 + #define MSG_SSID_WM 54 + #define MSG_SSID_LK 55 + #define MSG_SSID_PWRDB 56 + #define MSG_SSID_DCVS 57 + #define MSG_SSID_ANDROID_ADB 58 + #define MSG_SSID_VIDEO_ENCODER 59 + #define MSG_SSID_VENC_OMX 60 + #define MSG_SSID_GAN 61 /* Generic Access Network */ + #define MSG_SSID_KINETO_GAN 62 + #define MSG_SSID_ANDROID_QCRIL 63 + #define MSG_SSID_A2 64 + #define MSG_SSID_LINUX_DATA 65 + #define MSG_SSID_ECALL 66 + #define MSG_SSID_CHORD 67 + #define MSG_SSID_QCNE 68 + #define MSG_SSID_APPS_CAD_GENERAL 69 + #define MSG_SSID_OMADM 70 /* OMA device management */ + #define MSG_SSID_SIWA 71 /* Secure Instant Wireless Access */ + #define MSG_SSID_APR_MODEM 72 /* Audio Packet Router Modem */ + #define MSG_SSID_APR_APPS 73 /* Audio Packet Router Apps*/ + #define MSG_SSID_APR_ADSP 74 /* Audio Packet Router Adsp*/ + #define MSG_SSID_SRD_GENERAL 75 + #define MSG_SSID_ACDB_GENERAL 76 + #define MSG_SSID_DALTF 77 /* DAL Test Frame Work */ + #define MSG_SSID_CFM 78 /* Centralized Flow Control Manager */ + #define MSG_SSID_PMIC 79 /* PMIC SSID */ + #define MSG_SSID_GPS_SDP 80 + #define MSG_SSID_TLE 81 + #define MSG_SSID_TLE_XTM 82 + #define MSG_SSID_TLE_TLM 83 + #define MSG_SSID_TLE_TLM_MM 84 + #define MSG_SSID_WWAN_LOC 85 + #define MSG_SSID_GNSS_LOCMW 86 + #define MSG_SSID_QSET 87 + #define MSG_SSID_QBI 88 + #define MSG_SSID_ADC 89 + #define MSG_SSID_MMODE_QMI 90 + #define MSG_SSID_MCFG 91 + #define MSG_SSID_SSM 92 + #define MSG_SSID_MPOWER 93 + #define MSG_SSID_RMTS 94 + #define MSG_SSID_ADIE 95 + #define MSG_SSID_VT_VCEL 96 + #define MSG_SSID_FLASH_SCRUB 97 + #define MSG_SSID_STRIDE 98 + #define MSG_SSID_POLICYMAN 99 + #define MSG_SSID_TMS 100 + #define MSG_SSID_LWIP 101 + #define MSG_SSID_RFS 102 + #define MSG_SSID_RFS_ACCESS 103 + #define MSG_SSID_RLC 104 + #define MSG_SSID_MEMHEAP 105 + #define MSG_SSID_WCI2 106 + #define MSG_SSID_LOWI_TEST 107 + #define MSG_SSID_AOSTLM 108 + #define MSG_SSID_LOWI_AP 109 + #define MSG_SSID_LOWI_MP 110 + #define MSG_SSID_LOWI_LP 111 + #define MSG_SSID_MRE 112 + #define MSG_SSID_SLIM 113 + #define MSG_SSID_WLE 114 + #define MSG_SSID_WLM 115 + #define MSG_SSID_Q6ZIP 116 + #define MSG_SSID_RF_DEBUG 117 + #define MSG_SSID_NV 118 + +#define MSG_SSID_GEN_LAST 118 + + +/* Messages arising from ONCRPC AMSS modules */ +#define MSG_SSID_ONCRPC 500 +#define MSG_SSID_ONCRPC_MISC_MODEM 501 +#define MSG_SSID_ONCRPC_MISC_APPS 502 +#define MSG_SSID_ONCRPC_CM_MODEM 503 +#define MSG_SSID_ONCRPC_CM_APPS 504 +#define MSG_SSID_ONCRPC_DB 505 +#define MSG_SSID_ONCRPC_SND 506 +#define MSG_SSID_ONCRPC_LAST 506 + +/* Default master category for 1X. */ +#define MSG_SSID_1X 1000 + #define MSG_SSID_1X_ACP 1001 + #define MSG_SSID_1X_DCP 1002 + #define MSG_SSID_1X_DEC 1003 + #define MSG_SSID_1X_ENC 1004 + #define MSG_SSID_1X_GPSSRCH 1005 + #define MSG_SSID_1X_MUX 1006 + #define MSG_SSID_1X_SRCH 1007 +#define MSG_SSID_1X_LAST 1007 + + +/* Default master category for HDR. */ +#define MSG_SSID_HDR_PROT 2000 + #define MSG_SSID_HDR_DATA 2001 + #define MSG_SSID_HDR_SRCH 2002 + #define MSG_SSID_HDR_DRIVERS 2003 + #define MSG_SSID_HDR_IS890 2004 + #define MSG_SSID_HDR_DEBUG 2005 + #define MSG_SSID_HDR_HIT 2006 + #define MSG_SSID_HDR_PCP 2007 + #define MSG_SSID_HDR_HEAPMEM 2008 +#define MSG_SSID_HDR_LAST 2008 + + +/* Default master category for UMTS. */ +#define MSG_SSID_UMTS 3000 + #define MSG_SSID_WCDMA_L1 3001 + #define MSG_SSID_WCDMA_L2 3002 + #define MSG_SSID_WCDMA_MAC 3003 + #define MSG_SSID_WCDMA_RLC 3004 + #define MSG_SSID_WCDMA_RRC 3005 + #define MSG_SSID_NAS_CNM 3006 + #define MSG_SSID_NAS_MM 3007 + #define MSG_SSID_NAS_MN 3008 + #define MSG_SSID_NAS_RABM 3009 + #define MSG_SSID_NAS_REG 3010 + #define MSG_SSID_NAS_SM 3011 + #define MSG_SSID_NAS_TC 3012 + #define MSG_SSID_NAS_CB 3013 + #define MSG_SSID_WCDMA_LEVEL 3014 +#define MSG_SSID_UMTS_LAST 3014 + + +/* Default master category for GSM. */ +#define MSG_SSID_GSM 4000 + #define MSG_SSID_GSM_L1 4001 + #define MSG_SSID_GSM_L2 4002 + #define MSG_SSID_GSM_RR 4003 + #define MSG_SSID_GSM_GPRS_GCOMMON 4004 + #define MSG_SSID_GSM_GPRS_GLLC 4005 + #define MSG_SSID_GSM_GPRS_GMAC 4006 + #define MSG_SSID_GSM_GPRS_GPL1 4007 + #define MSG_SSID_GSM_GPRS_GRLC 4008 + #define MSG_SSID_GSM_GPRS_GRR 4009 + #define MSG_SSID_GSM_GPRS_GSNDCP 4010 +#define MSG_SSID_GSM_LAST 4010 + + + +#define MSG_SSID_WLAN 4500 + #define MSG_SSID_WLAN_ADP 4501 + #define MSG_SSID_WLAN_CP 4502 + #define MSG_SSID_WLAN_FTM 4503 + #define MSG_SSID_WLAN_OEM 4504 + #define MSG_SSID_WLAN_SEC 4505 + #define MSG_SSID_WLAN_TRP 4506 + #define MSG_SSID_WLAN_RESERVED_1 4507 + #define MSG_SSID_WLAN_RESERVED_2 4508 + #define MSG_SSID_WLAN_RESERVED_3 4509 + #define MSG_SSID_WLAN_RESERVED_4 4510 + #define MSG_SSID_WLAN_RESERVED_5 4511 + #define MSG_SSID_WLAN_RESERVED_6 4512 + #define MSG_SSID_WLAN_RESERVED_7 4513 + #define MSG_SSID_WLAN_RESERVED_8 4514 + #define MSG_SSID_WLAN_RESERVED_9 4515 + #define MSG_SSID_WLAN_RESERVED_10 4516 + #define MSG_SSID_WLAN_TL 4517 + #define MSG_SSID_WLAN_BAL 4518 + #define MSG_SSID_WLAN_SAL 4519 + #define MSG_SSID_WLAN_SSC 4520 + #define MSG_SSID_WLAN_HDD 4521 + #define MSG_SSID_WLAN_SME 4522 + #define MSG_SSID_WLAN_PE 4523 + #define MSG_SSID_WLAN_HAL 4524 + #define MSG_SSID_WLAN_SYS 4525 + #define MSG_SSID_WLAN_VOSS 4526 + #define MSG_SSID_WLAN_ATHOS 4527 + #define MSG_SSID_WLAN_WMI 4528 + #define MSG_SSID_WLAN_HTT 4529 + #define MSG_SSID_WLAN_PS_STA 4530 + #define MSG_SSID_WLAN_PS_IBSS 4531 + #define MSG_SSID_WLAN_PS_AP 4532 + #define MSG_SSID_WLAN_SMPS_STA 4533 + #define MSG_SSID_WLAN_WHAL 4534 + #define MSG_SSID_WLAN_COEX 4535 + #define MSG_SSID_WLAN_ROAM 4536 + #define MSG_SSID_WLAN_RESMGR 4537 + #define MSG_SSID_WLAN_PROTO 4538 + #define MSG_SSID_WLAN_SCAN 4539 + #define MSG_SSID_WLAN_BATCH_SCAN 4540 + #define MSG_SSID_WLAN_EXTSCAN 4541 + #define MSG_SSID_WLAN_RC 4542 + #define MSG_SSID_WLAN_BLOCKACK 4543 + #define MSG_SSID_WLAN_TXRX_DATA 4544 + #define MSG_SSID_WLAN_TXRX_MGMT 4545 + #define MSG_SSID_WLAN_BEACON 4546 + #define MSG_SSID_WLAN_OFFLOAD_MGR 4547 + #define MSG_SSID_WLAN_MACCORE 4548 + #define MSG_SSID_WLAN_PCIELP 4549 + #define MSG_SSID_WLAN_RTT 4550 + #define MSG_SSID_WLAN_DCS 4551 + #define MSG_SSID_WLAN_CACHEMGR 4552 + #define MSG_SSID_WLAN_ANI 4553 + #define MSG_SSID_WLAN_P2P 4554 + #define MSG_SSID_WLAN_CSA 4555 + #define MSG_SSID_WLAN_NLO 4556 + #define MSG_SSID_WLAN_CHATTER 4557 + #define MSG_SSID_WLAN_WOW 4558 + #define MSG_SSID_WLAN_WMMAC 4559 + #define MSG_SSID_WLAN_TDLS 4560 + #define MSG_SSID_WLAN_HB 4561 + #define MSG_SSID_WLAN_TXBF 4562 + #define MSG_SSID_WLAN_THERMAL 4563 + #define MSG_SSID_WLAN_DFS 4564 + #define MSG_SSID_WLAN_RMC 4565 + #define MSG_SSID_WLAN_STATS 4566 + #define MSG_SSID_WLAN_NAN 4567 + #define MSG_SSID_WLAN_HIF_UART 4568 + #define MSG_SSID_WLAN_LPI 4569 + #define MSG_SSID_WLAN_MLME 4570 + #define MSG_SSID_WLAN_SUPPL 4571 + #define MSG_SSID_WLAN_ERE 4572 + #define MSG_SSID_WLAN_OCB 4573 +#define MSG_SSID_WLAN_LAST 4573 + + +#define MSG_SSID_ATS 4600 + #define MSG_SSID_MSGR 4601 + #define MSG_SSID_APPMGR 4602 + #define MSG_SSID_QTF 4603 + #define MSG_SSID_FWS 4604 + #define MSG_SSID_SRCH4 4605 + #define MSG_SSID_CMAPI 4606 + #define MSG_SSID_MMAL 4607 + #define MSG_SSID_QRARB 4608 + #define MSG_SSID_LMTSMGR 4609 + #define MSG_SSID_MCS_RESERVED_7 4610 + #define MSG_SSID_MCS_RESERVED_8 4611 + #define MSG_SSID_IRATMAN 4612 + #define MSG_SSID_CXM 4613 + #define MSG_SSID_VSTMR 4614 + #define MSG_SSID_CFCM 4615 +#define MSG_SSID_MCS_LAST 4615 + + + + +/* Default master category for data services. */ +#define MSG_SSID_DS 5000 + #define MSG_SSID_DS_RLP 5001 + #define MSG_SSID_DS_PPP 5002 + #define MSG_SSID_DS_TCPIP 5003 + #define MSG_SSID_DS_IS707 5004 + #define MSG_SSID_DS_3GMGR 5005 + #define MSG_SSID_DS_PS 5006 + #define MSG_SSID_DS_MIP 5007 + #define MSG_SSID_DS_UMTS 5008 + #define MSG_SSID_DS_GPRS 5009 + #define MSG_SSID_DS_GSM 5010 + #define MSG_SSID_DS_SOCKETS 5011 + #define MSG_SSID_DS_ATCOP 5012 + #define MSG_SSID_DS_SIO 5013 + #define MSG_SSID_DS_BCMCS 5014 + #define MSG_SSID_DS_MLRLP 5015 + #define MSG_SSID_DS_RTP 5016 + #define MSG_SSID_DS_SIPSTACK 5017 + #define MSG_SSID_DS_ROHC 5018 + #define MSG_SSID_DS_DOQOS 5019 + #define MSG_SSID_DS_IPC 5020 + #define MSG_SSID_DS_SHIM 5021 + #define MSG_SSID_DS_ACLPOLICY 5022 + #define MSG_SSID_DS_APPS 5023 + #define MSG_SSID_DS_MUX 5024 + #define MSG_SSID_DS_3GPP 5025 + #define MSG_SSID_DS_LTE 5026 + #define MSG_SSID_DS_WCDMA 5027 + #define MSG_SSID_DS_ACLPOLICY_APPS 5028 /* ACL POLICY */ + #define MSG_SSID_DS_HDR 5029 + #define MSG_SSID_DS_IPA 5030 + #define MSG_SSID_DS_EPC 5031 + #define MSG_SSID_DS_APPSRV 5032 + +#define MSG_SSID_DS_LAST 5032 + + +/* Default master category for Security. */ +#define MSG_SSID_SEC 5500 +#define MSG_SSID_SEC_CRYPTO 5501 /* Cryptography */ +#define MSG_SSID_SEC_SSL 5502 /* Secure Sockets Layer */ +#define MSG_SSID_SEC_IPSEC 5503 /* Internet Protocol Security */ +#define MSG_SSID_SEC_SFS 5504 /* Secure File System */ +#define MSG_SSID_SEC_TEST 5505 /* Security Test Subsystem */ +#define MSG_SSID_SEC_CNTAGENT 5506 /* Content Agent Interface */ +#define MSG_SSID_SEC_RIGHTSMGR 5507 /* Rights Manager Interface */ +#define MSG_SSID_SEC_ROAP 5508 /* Rights Object Aquisition Protocol */ +#define MSG_SSID_SEC_MEDIAMGR 5509 /* Media Manager Interface */ +#define MSG_SSID_SEC_IDSTORE 5510 /* ID Store Interface */ +#define MSG_SSID_SEC_IXFILE 5511 /* File interface */ +#define MSG_SSID_SEC_IXSQL 5512 /* SQL interface */ +#define MSG_SSID_SEC_IXCOMMON 5513 /* Common Interface */ +#define MSG_SSID_SEC_BCASTCNTAGENT 5514 /* Broadcast Content Agent Interface */ +#define MSG_SSID_SEC_PLAYREADY 5515 /* Broadcast Content Agent Interface */ +#define MSG_SSID_SEC_WIDEVINE 5516 /* Broadcast Content Agent Interface */ +#define MSG_SSID_SEC_LAST 5516 + + +/* Default master category for applications. */ +#define MSG_SSID_APPS 6000 + #define MSG_SSID_APPS_APPMGR 6001 + #define MSG_SSID_APPS_UI 6002 + #define MSG_SSID_APPS_QTV 6003 + #define MSG_SSID_APPS_QVP 6004 + #define MSG_SSID_APPS_QVP_STATISTICS 6005 + #define MSG_SSID_APPS_QVP_VENCODER 6006 + #define MSG_SSID_APPS_QVP_MODEM 6007 + #define MSG_SSID_APPS_QVP_UI 6008 + #define MSG_SSID_APPS_QVP_STACK 6009 + #define MSG_SSID_APPS_QVP_VDECODER 6010 + #define MSG_SSID_APPS_ACM 6011 + #define MSG_SSID_APPS_HEAP_PROFILE 6012 + #define MSG_SSID_APPS_QTV_GENERAL 6013 + #define MSG_SSID_APPS_QTV_DEBUG 6014 + #define MSG_SSID_APPS_QTV_STATISTICS 6015 + #define MSG_SSID_APPS_QTV_UI_TASK 6016 + #define MSG_SSID_APPS_QTV_MP4_PLAYER 6017 + #define MSG_SSID_APPS_QTV_AUDIO_TASK 6018 + #define MSG_SSID_APPS_QTV_VIDEO_TASK 6019 + #define MSG_SSID_APPS_QTV_STREAMING 6020 + #define MSG_SSID_APPS_QTV_MPEG4_TASK 6021 + #define MSG_SSID_APPS_QTV_FILE_OPS 6022 + #define MSG_SSID_APPS_QTV_RTP 6023 + #define MSG_SSID_APPS_QTV_RTCP 6024 + #define MSG_SSID_APPS_QTV_RTSP 6025 + #define MSG_SSID_APPS_QTV_SDP_PARSE 6026 + #define MSG_SSID_APPS_QTV_ATOM_PARSE 6027 + #define MSG_SSID_APPS_QTV_TEXT_TASK 6028 + #define MSG_SSID_APPS_QTV_DEC_DSP_IF 6029 + #define MSG_SSID_APPS_QTV_STREAM_RECORDING 6030 + #define MSG_SSID_APPS_QTV_CONFIGURATION 6031 + #define MSG_SSID_APPS_QCAMERA 6032 + #define MSG_SSID_APPS_QCAMCORDER 6033 + #define MSG_SSID_APPS_BREW 6034 + #define MSG_SSID_APPS_QDJ 6035 + #define MSG_SSID_APPS_QDTX 6036 + #define MSG_SSID_APPS_QTV_BCAST_FLO 6037 + #define MSG_SSID_APPS_MDP_GENERAL 6038 + #define MSG_SSID_APPS_PBM 6039 + #define MSG_SSID_APPS_GRAPHICS_GENERAL 6040 + #define MSG_SSID_APPS_GRAPHICS_EGL 6041 + #define MSG_SSID_APPS_GRAPHICS_OPENGL 6042 + #define MSG_SSID_APPS_GRAPHICS_DIRECT3D 6043 + #define MSG_SSID_APPS_GRAPHICS_SVG 6044 + #define MSG_SSID_APPS_GRAPHICS_OPENVG 6045 + #define MSG_SSID_APPS_GRAPHICS_2D 6046 + #define MSG_SSID_APPS_GRAPHICS_QXPROFILER 6047 + #define MSG_SSID_APPS_GRAPHICS_DSP 6048 + #define MSG_SSID_APPS_GRAPHICS_GRP 6049 + #define MSG_SSID_APPS_GRAPHICS_MDP 6050 + #define MSG_SSID_APPS_CAD 6051 + #define MSG_SSID_APPS_IMS_DPL 6052 + #define MSG_SSID_APPS_IMS_FW 6053 + #define MSG_SSID_APPS_IMS_SIP 6054 + #define MSG_SSID_APPS_IMS_REGMGR 6055 + #define MSG_SSID_APPS_IMS_RTP 6056 + #define MSG_SSID_APPS_IMS_SDP 6057 + #define MSG_SSID_APPS_IMS_VS 6058 + #define MSG_SSID_APPS_IMS_XDM 6059 + #define MSG_SSID_APPS_IMS_HOM 6060 + #define MSG_SSID_APPS_IMS_IM_ENABLER 6061 + #define MSG_SSID_APPS_IMS_IMS_CORE 6062 + #define MSG_SSID_APPS_IMS_FWAPI 6063 + #define MSG_SSID_APPS_IMS_SERVICES 6064 + #define MSG_SSID_APPS_IMS_POLICYMGR 6065 + #define MSG_SSID_APPS_IMS_PRESENCE 6066 + #define MSG_SSID_APPS_IMS_QIPCALL 6067 + #define MSG_SSID_APPS_IMS_SIGCOMP 6068 + #define MSG_SSID_APPS_IMS_PSVT 6069 + #define MSG_SSID_APPS_IMS_UNKNOWN 6070 + #define MSG_SSID_APPS_IMS_SETTINGS 6071 + #define MSG_SSID_OMX_COMMON 6072 + #define MSG_SSID_APPS_IMS_RCS_CD 6073 + #define MSG_SSID_APPS_IMS_RCS_IM 6074 + #define MSG_SSID_APPS_IMS_RCS_FT 6075 + #define MSG_SSID_APPS_IMS_RCS_IS 6076 + #define MSG_SSID_APPS_IMS_RCS_AUTO_CONFIG 6077 + #define MSG_SSID_APPS_IMS_RCS_COMMON 6078 + #define MSG_SSID_APPS_IMS_UT 6079 + #define MSG_SSID_APPS_IMS_XML 6080 + #define MSG_SSID_APPS_IMS_COM 6081 + +#define MSG_SSID_APPS_LAST 6081 + + +/* Default master category for aDSP Tasks. */ +#define MSG_SSID_ADSPTASKS 6500 + #define MSG_SSID_ADSPTASKS_KERNEL 6501 + #define MSG_SSID_ADSPTASKS_AFETASK 6502 + #define MSG_SSID_ADSPTASKS_VOICEPROCTASK 6503 + #define MSG_SSID_ADSPTASKS_VOCDECTASK 6504 + #define MSG_SSID_ADSPTASKS_VOCENCTASK 6505 + #define MSG_SSID_ADSPTASKS_VIDEOTASK 6506 + #define MSG_SSID_ADSPTASKS_VFETASK 6507 + #define MSG_SSID_ADSPTASKS_VIDEOENCTASK 6508 + #define MSG_SSID_ADSPTASKS_JPEGTASK 6509 + #define MSG_SSID_ADSPTASKS_AUDPPTASK 6510 + #define MSG_SSID_ADSPTASKS_AUDPLAY0TASK 6511 + #define MSG_SSID_ADSPTASKS_AUDPLAY1TASK 6512 + #define MSG_SSID_ADSPTASKS_AUDPLAY2TASK 6513 + #define MSG_SSID_ADSPTASKS_AUDPLAY3TASK 6514 + #define MSG_SSID_ADSPTASKS_AUDPLAY4TASK 6515 + #define MSG_SSID_ADSPTASKS_LPMTASK 6516 + #define MSG_SSID_ADSPTASKS_DIAGTASK 6517 + #define MSG_SSID_ADSPTASKS_AUDRECTASK 6518 + #define MSG_SSID_ADSPTASKS_AUDPREPROCTASK 6519 + #define MSG_SSID_ADSPTASKS_MODMATHTASK 6520 + #define MSG_SSID_ADSPTASKS_GRAPHICSTASK 6521 + +#define MSG_SSID_ADSPTASKS_LAST 6521 + + +/* Messages arising from Linux on L4, or its drivers or applications. */ +#define MSG_SSID_L4LINUX_KERNEL 7000 +#define MSG_SSID_L4LINUX_KEYPAD 7001 +#define MSG_SSID_L4LINUX_APPS 7002 +#define MSG_SSID_L4LINUX_QDDAEMON 7003 +#define MSG_SSID_L4LINUX_LAST MSG_SSID_L4LINUX_QDDAEMON + +/* Messages arising from Iguana on L4, or its servers and drivers. */ +#define MSG_SSID_L4IGUANA_IGUANASERVER 7100 /* Iguana Server itself */ +#define MSG_SSID_L4IGUANA_EFS2 7101 /* platform/apps stuff */ +#define MSG_SSID_L4IGUANA_QDMS 7102 +#define MSG_SSID_L4IGUANA_REX 7103 +#define MSG_SSID_L4IGUANA_SMMS 7104 +#define MSG_SSID_L4IGUANA_FRAMEBUFFER 7105 /* platform/iguana stuff */ +#define MSG_SSID_L4IGUANA_KEYPAD 7106 +#define MSG_SSID_L4IGUANA_NAMING 7107 +#define MSG_SSID_L4IGUANA_SDIO 7108 +#define MSG_SSID_L4IGUANA_SERIAL 7109 +#define MSG_SSID_L4IGUANA_TIMER 7110 +#define MSG_SSID_L4IGUANA_TRAMP 7111 +#define MSG_SSID_L4IGUANA_LAST MSG_SSID_L4IGUANA_TRAMP + +/* Messages arising from L4-specific AMSS modules */ +#define MSG_SSID_L4AMSS_QDIAG 7200 +#define MSG_SSID_L4AMSS_APS 7201 +#define MSG_SSID_L4AMSS_LAST MSG_SSID_L4AMSS_APS + + +/* Default master category for HIT. */ +#define MSG_SSID_HIT 8000 +#define MSG_SSID_HIT_LAST 8000 + + +/* Default master category for Q6 */ +#define MSG_SSID_QDSP6 8500 +#define MSG_SSID_ADSP_AUD_SVC 8501 /* Audio Service */ +#define MSG_SSID_ADSP_AUD_ENCDEC 8502 /* audio encoders/decoders */ +#define MSG_SSID_ADSP_AUD_VOC 8503 /* voice encoders/decoders */ +#define MSG_SSID_ADSP_AUD_VS 8504 /* voice services */ +#define MSG_SSID_ADSP_AUD_MIDI 8505 /* MIDI-based file formats */ +#define MSG_SSID_ADSP_AUD_POSTPROC 8506 /* e.g. Graph EQ, Spec Analyzer */ +#define MSG_SSID_ADSP_AUD_PREPROC 8507 /* e.g. AGC-R */ +#define MSG_SSID_ADSP_AUD_AFE 8508 /* audio front end */ +#define MSG_SSID_ADSP_AUD_MSESSION 8509 /* media session */ +#define MSG_SSID_ADSP_AUD_DSESSION 8510 /* device session */ +#define MSG_SSID_ADSP_AUD_DCM 8511 /* device configuration */ +#define MSG_SSID_ADSP_VID_ENC 8512 /* Video Encoder */ +#define MSG_SSID_ADSP_VID_ENCRPC 8513 /* Video Encoder DAL driver */ +#define MSG_SSID_ADSP_VID_DEC 8514 /* Video Decoder */ +#define MSG_SSID_ADSP_VID_DECRPC 8515 /* Video Decoder DAL driver */ +#define MSG_SSID_ADSP_VID_COMMONSW 8516 /* Video Common Software Units */ +#define MSG_SSID_ADSP_VID_HWDRIVER 8517 /* Video Hardware */ +#define MSG_SSID_ADSP_JPG_ENC 8518 /* JPEG Encoder */ +#define MSG_SSID_ADSP_JPG_DEC 8519 /* JPEG Decoder */ +#define MSG_SSID_ADSP_OMM 8520 /* openmm */ +#define MSG_SSID_ADSP_PWRDEM 8521 /* Power or DEM messages */ +#define MSG_SSID_ADSP_RESMGR 8522 /* Resource Manager */ +#define MSG_SSID_ADSP_CORE 8523 /* General core (startup, heap stats, etc.) */ +#define MSG_SSID_ADSP_RDA 8524 +#define MSG_SSID_DSP_TOUCH_TAFE_HAL 8525 +#define MSG_SSID_DSP_TOUCH_ALGORITHM 8526 +#define MSG_SSID_DSP_TOUCH_FRAMEWORK 8527 +#define MSG_SSID_DSP_TOUCH_SRE 8528 +#define MSG_SSID_DSP_TOUCH_TAFE_DRIVER 8529 + +#define MSG_SSID_QDSP6_LAST 8529 + +/* Default master category for UMB. */ +#define MSG_SSID_UMB 9000 +#define MSG_SSID_UMB_APP 9001 /* UMB Application component */ +#define MSG_SSID_UMB_DS 9002 /* UMB Data Services component */ +#define MSG_SSID_UMB_CP 9003 /* UMB Call Processing component */ +#define MSG_SSID_UMB_RLL 9004 /* UMB Radio Link Layer component */ +#define MSG_SSID_UMB_MAC 9005 /* UMB MAC component */ +#define MSG_SSID_UMB_SRCH 9006 /* UMB SRCH component */ +#define MSG_SSID_UMB_FW 9007 /* UMB Firmware component */ +#define MSG_SSID_UMB_PLT 9008 /* UMB PLT component */ +#define MSG_SSID_UMB_LAST 9008 + +/* Default master category for LTE. */ +#define MSG_SSID_LTE 9500 +#define MSG_SSID_LTE_RRC 9501 +#define MSG_SSID_LTE_MACUL 9502 +#define MSG_SSID_LTE_MACDL 9503 +#define MSG_SSID_LTE_MACCTRL 9504 +#define MSG_SSID_LTE_RLCUL 9505 +#define MSG_SSID_LTE_RLCDL 9506 +#define MSG_SSID_LTE_PDCPUL 9507 +#define MSG_SSID_LTE_PDCPDL 9508 +#define MSG_SSID_LTE_ML1 9509 +#define MSG_SSID_LTE_DISCOVERY 9510 +#define MSG_SSID_LTE_LAST 9510 + +/*====================================================================================== + * SSIDs for Octopus Base Station Simulator. Although it needs only QXDM side changes + * diag needs to be updated to keep it consistent with the QXDM database. OCTOPUS team + * wanted the code changes reverted. They wanted to reserve the codes instead. + * RESERVED 9700 TILL 10199 + *====================================================================================*/ + + +/* Default master category for QCHAT */ + +#define MSG_SSID_QCHAT 10200 +#define MSG_SSID_QCHAT_CAPP 10201 +#define MSG_SSID_QCHAT_CENG 10202 +#define MSG_SSID_QCHAT_CREG 10203 +#define MSG_SSID_QCHAT_CMED 10204 +#define MSG_SSID_QCHAT_CAUTH 10205 +#define MSG_SSID_QCHAT_QBAL 10206 +#define MSG_SSID_QCHAT_OSAL 10207 +#define MSG_SSID_QCHAT_OEMCUST 10208 +#define MSG_SSID_QCHAT_MULTI_PROC 10209 +#define MSG_SSID_QCHAT_UPK 10210 +#define MSG_SSID_QCHAT_LAST 10210 + +/* Default master category for TDSCDMA */ +#define MSG_SSID_TDSCDMA_L1 10251 +#define MSG_SSID_TDSCDMA_L2 10252 +#define MSG_SSID_TDSCDMA_MAC 10253 +#define MSG_SSID_TDSCDMA_RLC 10254 +#define MSG_SSID_TDSCDMA_RRC 10255 +#define MSG_SSID_TDSCDMA_LAST 10255 + +/* Messages from the CTA framework */ +#define MSG_SSID_CTA 10300 +#define MSG_SSID_CTA_LAST 10300 + +/* QCNEA related SSIDs */ +#define MSG_SSID_QCNEA 10350 +#define MSG_SSID_QCNEA_CAC 10351 +#define MSG_SSID_QCNEA_CORE 10352 +#define MSG_SSID_QCNEA_CORE_CAS 10353 +#define MSG_SSID_QCNEA_CORE_CDE 10354 +#define MSG_SSID_QCNEA_CORE_COM 10355 +#define MSG_SSID_QCNEA_CORE_LEE 10356 +#define MSG_SSID_QCNEA_CORE_QMI 10357 +#define MSG_SSID_QCNEA_CORE_SRM 10358 +#define MSG_SSID_QCNEA_GENERIC 10359 +#define MSG_SSID_QCNEA_NETLINK 10360 +#define MSG_SSID_QCNEA_NIMS 10361 +#define MSG_SSID_QCNEA_NSRM 10362 +#define MSG_SSID_QCNEA_NSRM_CORE 10363 +#define MSG_SSID_QCNEA_NSRM_GATESM 10364 +#define MSG_SSID_QCNEA_NSRM_TRG 10365 +#define MSG_SSID_QCNEA_PLCY 10366 +#define MSG_SSID_QCNEA_PLCY_ANDSF 10367 +#define MSG_SSID_QCNEA_TEST 10368 +#define MSG_SSID_QCNEA_WQE 10369 +#define MSG_SSID_QCNEA_WQE_BQE 10370 +#define MSG_SSID_QCNEA_WQE_CQE 10371 +#define MSG_SSID_QCNEA_WQE_ICD 10372 +#define MSG_SSID_QCNEA_WQE_IFSEL 10373 +#define MSG_SSID_QCNEA_WQE_IFSELRSM 10374 +#define MSG_SSID_QCNEA_ATP 10375 +#define MSG_SSID_QCNEA_ATP_PLCY 10376 +#define MSG_SSID_QCNEA_ATP_RPRT 10377 + +#define MSG_SSID_QCNEA_LAST 10377 + +/* DPM related SSIDs */ +#define MSG_SSID_DPM 10400 +#define MSG_SSID_DPM_COMMON 10401 +#define MSG_SSID_DPM_COM 10402 +#define MSG_SSID_DPM_QMI 10403 +#define MSG_SSID_DPM_DSM 10404 +#define MSG_SSID_DPM_CONFIG 10405 +#define MSG_SSID_DPM_GENERIC 10406 +#define MSG_SSID_DPM_NETLINK 10407 +#define MSG_SSID_DPM_FD_MGR 10408 +#define MSG_SSID_DPM_CT_MGR 10409 +#define MSG_SSID_DPM_NSRM 10410 +#define MSG_SSID_DPM_NSRM_CORE 10411 +#define MSG_SSID_DPM_NSRM_GATESM 10412 +#define MSG_SSID_DPM_NSRM_TRG 10413 +#define MSG_SSID_DPM_TEST 10414 +#define MSG_SSID_DPM_TCM 10415 + +#define MSG_SSID_DPM_LAST 10415 + +/* EXAMPLE: Entry for an SSID */ +#if 0 + +/* MSG_SSID_FOO */ + +/* Donot add this block of code when adding new ssids further */ +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_FOO + #define MSG_BUILD_MASK_MSG_SSID_FOO MSG_BUILD_MASK_DFLT +#endif + +/* Donot add this block of code when adding new ssids further */ +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_FOO) + + #undef MSG_SSID_DFLT + #define MSG_SSID_LEGACY MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_FOO + +#endif + +#endif /* end example */ + + +/* MSG_SSID_AUDFMT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_AUDFMT + #define MSG_BUILD_MASK_MSG_SSID_AUDFMT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_AUDFMT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_AUDFMT + +#endif + +/* MSG_SSID_AVS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_AVS + #define MSG_BUILD_MASK_MSG_SSID_AVS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_AVS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_AVS + +#endif + + +/* MSG_SSID_BOOT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_BOOT + #define MSG_BUILD_MASK_MSG_SSID_BOOT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_BOOT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_BOOT + +#endif + +/* MSG_SSID_BT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_BT + #define MSG_BUILD_MASK_MSG_SSID_BT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_BT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_BT + +#endif + + +/* MSG_SSID_CM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_CM + #define MSG_BUILD_MASK_MSG_SSID_CM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_CM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_CM + +#endif + + +/* MSG_SSID_CMX */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_CMX + #define MSG_BUILD_MASK_MSG_SSID_CMX MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_CMX) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_CMX + +#endif + +/* MSG_SSID_DIAG */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DIAG + #define MSG_BUILD_MASK_MSG_SSID_DIAG MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DIAG) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DIAG + +#endif + + +/* MSG_SSID_DSM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DSM + #define MSG_BUILD_MASK_MSG_SSID_DSM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DSM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DSM + +#endif + + +/* MSG_SSID_FS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_FS + #define MSG_BUILD_MASK_MSG_SSID_FS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_FS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_FS + +#endif + +/* MSG_SSID_HS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HS + #define MSG_BUILD_MASK_MSG_SSID_HS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HS + +#endif + +/* MSG_SSID_MDSP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MDSP + #define MSG_BUILD_MASK_MSG_SSID_MDSP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MDSP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MDSP + +#endif + + +/* MSG_SSID_QDSP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_QDSP + #define MSG_BUILD_MASK_MSG_SSID_QDSP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_QDSP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_QDSP + +#endif + +/* MSG_SSID_REX */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_REX + #define MSG_BUILD_MASK_MSG_SSID_REX MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_REX) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_REX + +#endif + +/* MSG_SSID_RF */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_RF + #define MSG_BUILD_MASK_MSG_SSID_RF MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_RF) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_RF + +#endif + +/* MSG_SSID_SD */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SD + #define MSG_BUILD_MASK_MSG_SSID_SD MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SD) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SD + +#endif + + +/* MSG_SSID_SIO */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SIO + #define MSG_BUILD_MASK_MSG_SSID_SIO MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SIO) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SIO + +#endif + + +/* MSG_SSID_VS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_VS + #define MSG_BUILD_MASK_MSG_SSID_VS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_VS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_VS + +#endif + +/* MSG_SSID_WMS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WMS + #define MSG_BUILD_MASK_MSG_SSID_WMS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WMS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WMS + +#endif + +/* MSG_SSID_GPS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GPS + #define MSG_BUILD_MASK_MSG_SSID_GPS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GPS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GPS + +#endif + +/* MSG_SSID_MMOC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MMOC + #define MSG_BUILD_MASK_MSG_SSID_MMOC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MMOC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MMOC + +#endif + +/* MSG_SSID_RUIM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_RUIM + #define MSG_BUILD_MASK_MSG_SSID_RUIM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_RUIM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_RUIM + +#endif + +/* MSG_SSID_TMC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_TMC + #define MSG_BUILD_MASK_MSG_SSID_TMC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_TMC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_TMC + +#endif + +/* MSG_SSID_FTM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_FTM + #define MSG_BUILD_MASK_MSG_SSID_FTM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_FTM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_FTM + +#endif + +/* MSG_SSID_MMGPS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MMGPS + #define MSG_BUILD_MASK_MSG_SSID_MMGPS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MMGPS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MMGPS + +#endif + +/* MSG_SSID_SLEEP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SLEEP + #define MSG_BUILD_MASK_MSG_SSID_SLEEP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SLEEP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SLEEP + +#endif + +/* MSG_SSID_SAM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SAM + #define MSG_BUILD_MASK_MSG_SSID_SAM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SAM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SAM + +#endif + +/* MSG_SSID_SRM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SRM + #define MSG_BUILD_MASK_MSG_SSID_SRM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SRM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SRM + +#endif + +/* MSG_SSID_SFAT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SFAT + #define MSG_BUILD_MASK_MSG_SSID_SFAT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SFAT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SFAT + +#endif + +/* MSG_SSID_JOYST */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_JOYST + #define MSG_BUILD_MASK_MSG_SSID_JOYST MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_JOYST) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_JOYST + +#endif + +/* MSG_SSID_MFLO */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MFLO + #define MSG_BUILD_MASK_MSG_SSID_MFLO MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MFLO) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MFLO + +#endif + +/* MSG_SSID_DTV */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DTV + #define MSG_BUILD_MASK_MSG_SSID_DTV MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DTV) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DTV + +#endif + +/* MSG_SSID_FLUTE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_FLUTE + #define MSG_BUILD_MASK_MSG_SSID_FLUTE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_FLUTE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_FLUTE + +#endif + +/* MSG_SSID_CAMERA */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_CAMERA + #define MSG_BUILD_MASK_MSG_SSID_CAMERA MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_CAMERA) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_CAMERA + +#endif + +/* MSG_SSID_USBHOST */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_USBHOST + #define MSG_BUILD_MASK_MSG_SSID_USBHOST MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_USBHOST) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_USBHOST + +#endif + +/* MSG_SSID_PROFILER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_PROFILER + #define MSG_BUILD_MASK_MSG_SSID_PROFILER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_PROFILER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_PROFILER + +#endif + +/* MSG_SSID_TCXOMGR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_TCXOMGR + #define MSG_BUILD_MASK_MSG_SSID_TCXOMGR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_TCXOMGR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_TCXOMGR + +#endif + +/* MSG_SSID_EFS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_EFS + #define MSG_BUILD_MASK_MSG_SSID_EFS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_EFS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_EFS + +#endif + +/* MSG_SSID_IRDA */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_IRDA + #define MSG_BUILD_MASK_MSG_SSID_IRDA MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_IRDA) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_IRDA + +#endif + +/* MSG_SSID_FM_RADIO */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_FM_RADIO + #define MSG_BUILD_MASK_MSG_SSID_FM_RADIO MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_FM_RADIO) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_FM_RADIO + +#endif + +/* MSG_SSID_AAM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_AAM + #define MSG_BUILD_MASK_MSG_SSID_AAM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_AAM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_AAM + +#endif + +/* MSG_SSID_BM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_BM + #define MSG_BUILD_MASK_MSG_SSID_BM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_BM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_BM + +#endif + +/* MSG_SSID_PE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_PE + #define MSG_BUILD_MASK_MSG_SSID_PE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_PE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_PE + +#endif + +/* MSG_SSID_QIPCALL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_QIPCALL + #define MSG_BUILD_MASK_MSG_SSID_QIPCALL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_QIPCALL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_QIPCALL + +#endif + +/* MSG_SSID_HSUSB */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HSUSB + #define MSG_BUILD_MASK_MSG_SSID_HSUSB MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HSUSB) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HSUSB + +#endif + +/* MSG_SSID_FC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_FC + #define MSG_BUILD_MASK_MSG_SSID_FC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_FC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_FC + +#endif + +/* MSG_SSID_MGP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MGP + #define MSG_BUILD_MASK_MSG_SSID_MGP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MGP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MGP + +#endif + +/* MSG_SSID_MGPME */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MGPME + #define MSG_BUILD_MASK_MSG_SSID_MGPME MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MGPME) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MGPME + +#endif + +/* MSG_SSID_GPSOS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GPSOS + #define MSG_BUILD_MASK_MSG_SSID_GPSOS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GPSOS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GPSOS + +#endif + +/* MSG_SSID_MGPPE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MGPPE + #define MSG_BUILD_MASK_MSG_SSID_MGPPE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MGPPE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MGPPE + +#endif + +/* MSG_SSID_GPSSM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GPSSM + #define MSG_BUILD_MASK_MSG_SSID_GPSSM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GPSSM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GPSSM + +#endif + +/* MSG_SSID_IMS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_IMS + #define MSG_BUILD_MASK_MSG_SSID_IMS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_IMS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_IMS + +#endif + +/* MSG_SSID_MBP_RF */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MBP_RF + #define MSG_BUILD_MASK_MSG_SSID_MBP_RF MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MBP_RF) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MBP_RF + +#endif + +/* MSG_SSID_SNS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SNS + #define MSG_BUILD_MASK_MSG_SSID_SNS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SNS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SNS + +#endif + +/* MSG_SSID_WM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WM + #define MSG_BUILD_MASK_MSG_SSID_WM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WM + +#endif + +/* MSG_SSID_LK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LK + #define MSG_BUILD_MASK_MSG_SSID_LK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LK + +#endif + +/* MSG_SSID_ANDROID_ADB */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ANDROID_ADB + #define MSG_BUILD_MASK_MSG_SSID_ANDROID_ADB MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ANDROID_ADB) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ANDROID_ADB + +#endif + +/* MSG_SSID_PWRDB */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_PWRDB + #define MSG_BUILD_MASK_MSG_SSID_PWRDB MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_PWRDB) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_PWRDB + +#endif + +/* MSG_SSID_DCVS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DCVS + #define MSG_BUILD_MASK_MSG_SSID_DCVS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DCVS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DCVS + +#endif + +/* MSG_SSID_VIDEO_ENCODER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_VIDEO_ENCODER + #define MSG_BUILD_MASK_MSG_SSID_VIDEO_ENCODER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_VIDEO_ENCODER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_VIDEO_ENCODER + +#endif + +/* MSG_SSID_VENC_OMX */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_VENC_OMX + #define MSG_BUILD_MASK_MSG_SSID_VENC_OMX MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_VENC_OMX) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_VENC_OMX + +#endif + +/* MSG_SSID_GAN */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GAN + #define MSG_BUILD_MASK_MSG_SSID_GAN MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GAN) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GAN + +#endif + +/* MSG_SSID_KINETO_GAN */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_KINETO_GAN + #define MSG_BUILD_MASK_MSG_SSID_KINETO_GAN MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_KINETO_GAN) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_KINETO_GAN + +#endif + +/* MSG_SSID_ANDROID_QCRIL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ANDROID_QCRIL + #define MSG_BUILD_MASK_MSG_SSID_ANDROID_QCRIL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ANDROID_QCRIL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ANDROID_QCRIL + +#endif + +/* MSG_SSID_A2 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_A2 + #define MSG_BUILD_MASK_MSG_SSID_A2 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_A2) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_A2 + +#endif + + +/* MSG_SSID_LINUX_DATA */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LINUX_DATA + #define MSG_BUILD_MASK_MSG_SSID_LINUX_DATA MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LINUX_DATA) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LINUX_DATA + +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_ECALL + #define MSG_BUILD_MASK_MSG_SSID_ECALL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ECALL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ECALL + +#endif + +/* MSG_SSID_ONCRPC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ONCRPC + #define MSG_BUILD_MASK_MSG_SSID_ONCRPC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ONCRPC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ONCRPC + +#endif + +/* MSG_SSID_ONCRPC_MISC_MODEM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_MODEM + #define MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_MODEM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ONCRPC_MISC_MODEM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_MODEM + +#endif + +/* MSG_SSID_ONCRPC_MISC_APPS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_APPS + #define MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_APPS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ONCRPC_MISC_APPS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_APPS + +#endif + +/* MSG_SSID_ONCRPC_CM_MODEM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_MODEM + #define MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_MODEM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ONCRPC_CM_MODEM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_MODEM + +#endif + +/* MSG_SSID_ONCRPC_CM_APPS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_APPS + #define MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_APPS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ONCRPC_CM_APPS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_APPS + +#endif + +/* MSG_SSID_ONCRPC_DB */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ONCRPC_DB + #define MSG_BUILD_MASK_MSG_SSID_ONCRPC_DB MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ONCRPC_DB) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ONCRPC_DB + +#endif + +/* MSG_SSID_ONCRPC_SND */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ONCRPC_SND + #define MSG_BUILD_MASK_MSG_SSID_ONCRPC_SND MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ONCRPC_SND) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ONCRPC_SND + +#endif + +/* 1X related SSIDs */ + +/* MSG_SSID_1X */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_1X + #define MSG_BUILD_MASK_MSG_SSID_1X MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_1X) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_1X + +#endif + +/* MSG_SSID_1X_ACP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_ACP + #define MSG_BUILD_MASK_MSG_SSID_1X_ACP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_1X_ACP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_1X_ACP + +#endif + +/* MSG_SSID_1X_DCP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_DCP + #define MSG_BUILD_MASK_MSG_SSID_1X_DCP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_1X_DCP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_1X_DCP + +#endif + +/* MSG_SSID_1X_DEC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_DEC + #define MSG_BUILD_MASK_MSG_SSID_1X_DEC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_1X_DEC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_1X_DEC + +#endif + +/* MSG_SSID_1X_ENC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_ENC + #define MSG_BUILD_MASK_MSG_SSID_1X_ENC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_1X_ENC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_1X_ENC + +#endif + +/* MSG_SSID_1X_GPSSRCH */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_GPSSRCH + #define MSG_BUILD_MASK_MSG_SSID_1X_GPSSRCH MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_1X_GPSSRCH) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_1X_GPSSRCH + +#endif + +/* MSG_SSID_1X_MUX */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_MUX + #define MSG_BUILD_MASK_MSG_SSID_1X_MUX MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_1X_MUX) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_1X_MUX + +#endif + +/* MSG_SSID_1X_SRCH */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_SRCH + #define MSG_BUILD_MASK_MSG_SSID_1X_SRCH MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_1X_SRCH) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_1X_SRCH + +#endif + + + +/* HDR SSIDs */ + + +/* MSG_SSID_HDR_PROT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_PROT + #define MSG_BUILD_MASK_MSG_SSID_HDR_PROT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_PROT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_PROT + +#endif + +/* MSG_SSID_HDR_DATA */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_DATA + #define MSG_BUILD_MASK_MSG_SSID_HDR_DATA MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_DATA) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_DATA + +#endif + +/* MSG_SSID_HDR_SRCH */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_SRCH + #define MSG_BUILD_MASK_MSG_SSID_HDR_SRCH MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_SRCH) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_SRCH + +#endif + +/* MSG_SSID_HDR_DRIVERS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_DRIVERS + #define MSG_BUILD_MASK_MSG_SSID_HDR_DRIVERS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_DRIVERS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_DRIVERS + +#endif + +/* MSG_SSID_HDR_IS890 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_IS890 + #define MSG_BUILD_MASK_MSG_SSID_HDR_IS890 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_IS890) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_IS890 + +#endif + +/* MSG_SSID_HDR_DEBUG */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_DEBUG + #define MSG_BUILD_MASK_MSG_SSID_HDR_DEBUG MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_DEBUG) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_DEBUG + +#endif + +/* MSG_SSID_HDR_HIT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_HIT + #define MSG_BUILD_MASK_MSG_SSID_HDR_HIT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_HIT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_HIT + +#endif + + +/* MSG_SSID_HDR_PCP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_PCP + #define MSG_BUILD_MASK_MSG_SSID_HDR_PCP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_PCP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_PCP + +#endif + +/* MSG_SSID_HDR_HEAPMEM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_HEAPMEM + #define MSG_BUILD_MASK_MSG_SSID_HDR_HEAPMEM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HDR_HEAPMEM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HDR_HEAPMEM + +#endif + + + +/* UMTS SSIDs */ + +/* MSG_SSID_UMTS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMTS + #define MSG_BUILD_MASK_MSG_SSID_UMTS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMTS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMTS + +#endif + + +/* MSG_SSID_WCDMA_L1 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WCDMA_L1 + #define MSG_BUILD_MASK_MSG_SSID_WCDMA_L1 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WCDMA_L1) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WCDMA_L1 + +#endif + +/* MSG_SSID_WCDMA_L2 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WCDMA_L2 + #define MSG_BUILD_MASK_MSG_SSID_WCDMA_L2 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WCDMA_L2) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WCDMA_L2 + +#endif + +/* MSG_SSID_WCDMA_MAC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WCDMA_MAC + #define MSG_BUILD_MASK_MSG_SSID_WCDMA_MAC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WCDMA_MAC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WCDMA_MAC + +#endif + +/* MSG_SSID_WCDMA_RLC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WCDMA_RLC + #define MSG_BUILD_MASK_MSG_SSID_WCDMA_RLC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WCDMA_RLC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WCDMA_RLC + +#endif + +/* MSG_SSID_WCDMA_RRC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WCDMA_RRC + #define MSG_BUILD_MASK_MSG_SSID_WCDMA_RRC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WCDMA_RRC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WCDMA_RRC + +#endif + +/* MSG_SSID_NAS_CNM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_NAS_CNM + #define MSG_BUILD_MASK_MSG_SSID_NAS_CNM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_NAS_CNM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_NAS_CNM + +#endif + +/* MSG_SSID_NAS_MM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_NAS_MM + #define MSG_BUILD_MASK_MSG_SSID_NAS_MM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_NAS_MM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_NAS_MM + +#endif + +/* MSG_SSID_NAS_MN */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_NAS_MN + #define MSG_BUILD_MASK_MSG_SSID_NAS_MN MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_NAS_MN) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_NAS_MN + +#endif + +/* MSG_SSID_NAS_RABM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_NAS_RABM + #define MSG_BUILD_MASK_MSG_SSID_NAS_RABM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_NAS_RABM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_NAS_RABM + +#endif + +/* MSG_SSID_NAS_REG */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_NAS_REG + #define MSG_BUILD_MASK_MSG_SSID_NAS_REG MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_NAS_REG) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_NAS_REG + +#endif + +/* MSG_SSID_NAS_SM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_NAS_SM + #define MSG_BUILD_MASK_MSG_SSID_NAS_SM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_NAS_SM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_NAS_SM + +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_NAS_CB + #define MSG_BUILD_MASK_MSG_SSID_NAS_CB MSG_BUILD_MASK_DFLT +#endif +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_NAS_CB) + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_NAS_CB +#endif +/* MSG_SSID_NAS_TC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_NAS_TC + #define MSG_BUILD_MASK_MSG_SSID_NAS_TC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_NAS_TC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_NAS_TC + +#endif + + + +/* GSM SSIDs */ + + +/* MSG_SSID_GSM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM + #define MSG_BUILD_MASK_MSG_SSID_GSM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM + +#endif + +/* MSG_SSID_GSM_L1 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_L1 + #define MSG_BUILD_MASK_MSG_SSID_GSM_L1 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_L1) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_L1 + +#endif + +/* MSG_SSID_GSM_L2 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_L2 + #define MSG_BUILD_MASK_MSG_SSID_GSM_L2 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_L2) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_L2 + +#endif + +/* MSG_SSID_GSM_RR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_RR + #define MSG_BUILD_MASK_MSG_SSID_GSM_RR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_RR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_RR + +#endif + +/* MSG_SSID_GSM_GPRS_GCOMMON */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GCOMMON + #define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GCOMMON MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_GPRS_GCOMMON) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GCOMMON + +#endif + +/* MSG_SSID_GSM_GPRS_GLLC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GLLC + #define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GLLC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_GPRS_GLLC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GLLC + +#endif + +/* MSG_SSID_GSM_GPRS_GMAC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GMAC + #define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GMAC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_GPRS_GMAC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GMAC + +#endif + +/* MSG_SSID_GSM_GPRS_GPL1 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GPL1 + #define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GPL1 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_GPRS_GPL1) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GPL1 + +#endif + +/* MSG_SSID_GSM_GPRS_GRLC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRLC + #define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRLC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_GPRS_GRLC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRLC + +#endif + +/* MSG_SSID_GSM_GPRS_GRR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRR + #define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_GPRS_GRR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRR + +#endif + +/* MSG_SSID_GSM_GPRS_GSNDCP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GSNDCP + #define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GSNDCP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_GSM_GPRS_GSNDCP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GSNDCP + +#endif + + +/* MSG_SSID_WLAN */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN + #define MSG_BUILD_MASK_MSG_SSID_WLAN MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN + +#endif + +/* MSG_SSID_WLAN_ADP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_ADP + #define MSG_BUILD_MASK_MSG_SSID_WLAN_ADP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_ADP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_ADP + +#endif + +/* MSG_SSID_WLAN_CP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_CP + #define MSG_BUILD_MASK_MSG_SSID_WLAN_CP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_CP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_CP + +#endif + +/* MSG_SSID_WLAN_FTM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_FTM + #define MSG_BUILD_MASK_MSG_SSID_WLAN_FTM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_FTM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_FTM + +#endif + +/* MSG_SSID_WLAN_OEM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_OEM + #define MSG_BUILD_MASK_MSG_SSID_WLAN_OEM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_OEM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_OEM + +#endif + +/* MSG_SSID_WLAN_SEC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_SEC + #define MSG_BUILD_MASK_MSG_SSID_WLAN_SEC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_SEC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_SEC + +#endif + +/* MSG_SSID_WLAN_TRP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_TRP + #define MSG_BUILD_MASK_MSG_SSID_WLAN_TRP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_TRP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_TRP + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_1 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_1 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_1) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_1 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_2 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_2 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_2) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_2 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_3 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_3 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_3) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_3 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_4 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_4 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_4) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_4 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_5 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_5 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_5) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_5 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_6 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_6 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_6) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_6 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_7 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_7 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_7) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_7 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_8 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_8 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_8) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_8 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_9 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_9 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_9) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_9 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_10 + #define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_10 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_RESERVED_10) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_10 + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_TL + #define MSG_BUILD_MASK_MSG_SSID_WLAN_TL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_TL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_TL + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_BAL + #define MSG_BUILD_MASK_MSG_SSID_WLAN_BAL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_BAL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_BAL + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_SAL + #define MSG_BUILD_MASK_MSG_SSID_WLAN_SAL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_SAL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_SAL + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_SSC + #define MSG_BUILD_MASK_MSG_SSID_WLAN_SSC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_SSC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_SSC + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_HDD + #define MSG_BUILD_MASK_MSG_SSID_WLAN_HDD MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_HDD) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_HDD + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_SME + #define MSG_BUILD_MASK_MSG_SSID_WLAN_SME MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_SME) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_SME + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_PE + #define MSG_BUILD_MASK_MSG_SSID_WLAN_PE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_PE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_PE + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_HAL + #define MSG_BUILD_MASK_MSG_SSID_WLAN_HAL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_HAL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_HAL + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_SYS + #define MSG_BUILD_MASK_MSG_SSID_WLAN_SYS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_SYS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_SYS + +#endif + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_WLAN_VOSS + #define MSG_BUILD_MASK_MSG_SSID_WLAN_VOSS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_WLAN_VOSS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_WLAN_VOSS + +#endif + + +/* MSG_SSID_ATS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ATS + #define MSG_BUILD_MASK_MSG_SSID_ATS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ATS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ATS + +#endif + +/* MSG_SSID_MSGR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MSGR + #define MSG_BUILD_MASK_MSG_SSID_MSGR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MSGR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MSGR + +#endif + +/* MSG_SSID_APPMGR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPMGR + #define MSG_BUILD_MASK_MSG_SSID_APPMGR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPMGR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPMGR + +#endif + +/* MSG_SSID_QTF */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_QTF + #define MSG_BUILD_MASK_MSG_SSID_QTF MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_QTF) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_QTF + +#endif + +/* MSG_SSID_MCS_RESERVED_5 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_5 + #define MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_5 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MCS_RESERVED_5) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_5 + +#endif + +/* MSG_SSID_MCS_RESERVED_6 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_6 + #define MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_6 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MCS_RESERVED_6) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_6 + +#endif + +/* MSG_SSID_MCS_RESERVED_7 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_7 + #define MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_7 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MCS_RESERVED_7) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_7 + +#endif + +/* MSG_SSID_MCS_RESERVED_8*/ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_8 + #define MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_8 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_MCS_RESERVED_8) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_8 + +#endif + + +/* DS SSIDs */ + +/* MSG_SSID_DS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS + #define MSG_BUILD_MASK_MSG_SSID_DS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS + +#endif + +/* MSG_SSID_DS_RLP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_RLP + #define MSG_BUILD_MASK_MSG_SSID_DS_RLP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_RLP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_RLP + +#endif + +/* MSG_SSID_DS_PPP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_PPP + #define MSG_BUILD_MASK_MSG_SSID_DS_PPP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_PPP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_PPP + +#endif + +/* MSG_SSID_DS_TCPIP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_TCPIP + #define MSG_BUILD_MASK_MSG_SSID_DS_TCPIP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_TCPIP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_TCPIP + +#endif + +/* MSG_SSID_DS_IS707 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_IS707 + #define MSG_BUILD_MASK_MSG_SSID_DS_IS707 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_IS707) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_IS707 + +#endif + +/* MSG_SSID_DS_3GMGR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_3GMGR + #define MSG_BUILD_MASK_MSG_SSID_DS_3GMGR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_3GMGR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_3GMGR + +#endif + +/* MSG_SSID_DS_PS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_PS + #define MSG_BUILD_MASK_MSG_SSID_DS_PS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_PS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_PS + +#endif + +/* MSG_SSID_DS_MIP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_MIP + #define MSG_BUILD_MASK_MSG_SSID_DS_MIP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_MIP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_MIP + +#endif + +/* MSG_SSID_DS_UMTS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_UMTS + #define MSG_BUILD_MASK_MSG_SSID_DS_UMTS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_UMTS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_UMTS + +#endif + +/* MSG_SSID_DS_GPRS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_GPRS + #define MSG_BUILD_MASK_MSG_SSID_DS_GPRS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_GPRS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_GPRS + +#endif + +/* MSG_SSID_DS_GSM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_GSM + #define MSG_BUILD_MASK_MSG_SSID_DS_GSM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_GSM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_GSM + +#endif + +/* MSG_SSID_DS_SOCKETS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_SOCKETS + #define MSG_BUILD_MASK_MSG_SSID_DS_SOCKETS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_SOCKETS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_SOCKETS + +#endif + +/* MSG_SSID_DS_ATCOP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_ATCOP + #define MSG_BUILD_MASK_MSG_SSID_DS_ATCOP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_ATCOP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_ATCOP + +#endif + +/* MSG_SSID_DS_SIO */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_SIO + #define MSG_BUILD_MASK_MSG_SSID_DS_SIO MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_SIO) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_SIO + +#endif + +/* MSG_SSID_DS_BCMCS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_BCMCS + #define MSG_BUILD_MASK_MSG_SSID_DS_BCMCS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_BCMCS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_BCMCS + +#endif + +/* MSG_SSID_DS_MLRLP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_MLRLP + #define MSG_BUILD_MASK_MSG_SSID_DS_MLRLP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_MLRLP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_MLRLP + +#endif + +/* MSG_SSID_DS_RTP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_RTP + #define MSG_BUILD_MASK_MSG_SSID_DS_RTP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_RTP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_RTP + +#endif + +/* MSG_SSID_DS_SIPSTACK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_SIPSTACK + #define MSG_BUILD_MASK_MSG_SSID_DS_SIPSTACK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_SIPSTACK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_SIPSTACK + +#endif + +/* MSG_SSID_DS_ROHC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_ROHC + #define MSG_BUILD_MASK_MSG_SSID_DS_ROHC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_ROHC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_ROHC + +#endif + +/* MSG_SSID_DS_DOQOS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_DOQOS + #define MSG_BUILD_MASK_MSG_SSID_DS_DOQOS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_DOQOS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_DOQOS + +#endif + +/* MSG_SSID_DS_IPC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_IPC + #define MSG_BUILD_MASK_MSG_SSID_DS_IPC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_IPC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_IPC + +#endif + +/* MSG_SSID_DS_SHIM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_SHIM + #define MSG_BUILD_MASK_MSG_SSID_DS_SHIM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_SHIM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_SHIM + +#endif + +/* MSG_SSID_DS_ACLPOLICY */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_ACLPOLICY + #define MSG_BUILD_MASK_MSG_SSID_DS_ACLPOLICY MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_ACLPOLICY) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_ACLPOLICY + +#endif + +/* MSG_SSID_DS_APPS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_APPS + #define MSG_BUILD_MASK_MSG_SSID_DS_APPS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_APPS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_APPS + +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_DS_MUX + #define MSG_BUILD_MASK_MSG_SSID_DS_MUX MSG_BUILD_MASK_DFLT +#endif + + + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_DS_MUX) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_DS_MUX + +#endif + + +/* MSG_SSID_SEC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC + #define MSG_BUILD_MASK_MSG_SSID_SEC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC + +#endif + +/* MSG_SSID_SEC_CRYPTO */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_CRYPTO + #define MSG_BUILD_MASK_MSG_SSID_SEC_CRYPTO MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_CRYPTO) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_CRYPTO + +#endif + +/* MSG_SSID_SEC_SSL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_SSL + #define MSG_BUILD_MASK_MSG_SSID_SEC_SSL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_SSL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_SSL + +#endif + +/* MSG_SSID_SEC_IPSEC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_IPSEC + #define MSG_BUILD_MASK_MSG_SSID_SEC_IPSEC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_IPSEC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_IPSEC + +#endif + +/* MSG_SSID_SEC_SFS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_SFS + #define MSG_BUILD_MASK_MSG_SSID_SEC_SFS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_SFS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_SFS + +#endif + +/* MSG_SSID_SEC_TEST */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_TEST + #define MSG_BUILD_MASK_MSG_SSID_SEC_TEST MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_TEST) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_TEST + +#endif + +/* MSG_SSID_SEC_CNTAGENT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_CNTAGENT + #define MSG_BUILD_MASK_MSG_SSID_SEC_CNTAGENT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_CNTAGENT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_CNTAGENT + +#endif + +/* MSG_SSID_SEC_RIGHTSMGR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_RIGHTSMGR + #define MSG_BUILD_MASK_MSG_SSID_SEC_RIGHTSMGR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_RIGHTSMGR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_RIGHTSMGR + +#endif + +/* MSG_SSID_SEC_ROAP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_ROAP + #define MSG_BUILD_MASK_MSG_SSID_SEC_ROAP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_ROAP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_ROAP + +#endif + +/* MSG_SSID_SEC_MEDIAMGR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_MEDIAMGR + #define MSG_BUILD_MASK_MSG_SSID_SEC_MEDIAMGR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_MEDIAMGR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_MEDIAMGR + +#endif + +/* MSG_SSID_SEC_IDSTORE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_IDSTORE + #define MSG_BUILD_MASK_MSG_SSID_SEC_IDSTORE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_IDSTORE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_IDSTORE + +#endif + +/* MSG_SSID_SEC_IXFILE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_IXFILE + #define MSG_BUILD_MASK_MSG_SSID_SEC_IXFILE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_IXFILE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_IXFILE + +#endif + +/* MSG_SSID_SEC_IXSQL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_IXSQL + #define MSG_BUILD_MASK_MSG_SSID_SEC_IXSQL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_IXSQL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_IXSQL + +#endif + +/* MSG_SSID_SEC_IXCOMMON */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_IXCOMMON + #define MSG_BUILD_MASK_MSG_SSID_SEC_IXCOMMON MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_IXCOMMON) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_IXCOMMON + +#endif + +/* MSG_SSID_SEC_BCASTCNTAGENT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_SEC_BCASTCNTAGENT + #define MSG_BUILD_MASK_MSG_SSID_SEC_BCASTCNTAGENT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_SEC_BCASTCNTAGENT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_SEC_BCASTCNTAGENT + +#endif + +/* APPS SSIDs */ + +/* MSG_SSID_APPS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS + #define MSG_BUILD_MASK_MSG_SSID_APPS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS + +#endif + + +/* MSG_SSID_APPS_APPMGR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_APPMGR + #define MSG_BUILD_MASK_MSG_SSID_APPS_APPMGR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_APPMGR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_APPMGR + +#endif + +/* MSG_SSID_APPS_UI */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_UI + #define MSG_BUILD_MASK_MSG_SSID_APPS_UI MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_UI) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_UI + +#endif + +/* MSG_SSID_APPS_QTV */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV + +#endif + +/* MSG_SSID_APPS_QVP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QVP + #define MSG_BUILD_MASK_MSG_SSID_APPS_QVP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QVP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QVP + +#endif + +/* MSG_SSID_APPS_QVP_STATISTICS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STATISTICS + #define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STATISTICS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QVP_STATISTICS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STATISTICS + +#endif + +/* MSG_SSID_APPS_QVP_VENCODER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VENCODER + #define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VENCODER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QVP_VENCODER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VENCODER + +#endif + +/* MSG_SSID_APPS_QVP_MODEM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QVP_MODEM + #define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_MODEM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QVP_MODEM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QVP_MODEM + +#endif + +/* MSG_SSID_APPS_QVP_UI */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QVP_UI + #define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_UI MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QVP_UI) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QVP_UI + +#endif + +/* MSG_SSID_APPS_QVP_STACK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STACK + #define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STACK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QVP_STACK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STACK + +#endif + +/* MSG_SSID_APPS_QVP_VDECODER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VDECODER + #define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VDECODER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QVP_VDECODER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VDECODER + +#endif + +/* MSG_SSID_APPS_ACM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_ACM + #define MSG_BUILD_MASK_MSG_SSID_APPS_ACM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_ACM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_ACM + +#endif + +/* MSG_SSID_APPS_HEAP_PROFILE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_HEAP_PROFILE + #define MSG_BUILD_MASK_MSG_SSID_APPS_HEAP_PROFILE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_HEAP_PROFILE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_HEAP_PROFILE + +#endif + +/* MSG_SSID_APPS_QTV_GENERAL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_GENERAL + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_GENERAL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_GENERAL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_GENERAL + +#endif + +/* MSG_SSID_APPS_QTV_DEBUG */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEBUG + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEBUG MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_DEBUG) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEBUG + +#endif + +/* MSG_SSID_APPS_QTV_STATISTICS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STATISTICS + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STATISTICS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_STATISTICS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STATISTICS + +#endif + +/* MSG_SSID_APPS_QTV_UI_TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_UI_TASK + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_UI_TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_UI_TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_UI_TASK + +#endif + +/* MSG_SSID_APPS_QTV_MP4_PLAYER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MP4_PLAYER + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MP4_PLAYER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_MP4_PLAYER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MP4_PLAYER + +#endif + +/* MSG_SSID_APPS_QTV_AUDIO_TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_AUDIO_TASK + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_AUDIO_TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_AUDIO_TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_AUDIO_TASK + +#endif + +/* MSG_SSID_APPS_QTV_VIDEO_TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_VIDEO_TASK + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_VIDEO_TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_VIDEO_TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_VIDEO_TASK + +#endif + +/* MSG_SSID_APPS_QTV_STREAMING */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAMING + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAMING MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_STREAMING) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAMING + +#endif + +/* MSG_SSID_APPS_QTV_MPEG4_TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MPEG4_TASK + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MPEG4_TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_MPEG4_TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MPEG4_TASK + +#endif + +/* MSG_SSID_APPS_QTV_FILE_OPS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_FILE_OPS + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_FILE_OPS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_FILE_OPS ) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_FILE_OPS + +#endif + +/* MSG_SSID_APPS_QTV_RTP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTP + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_RTP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTP + +#endif + +/* MSG_SSID_APPS_QTV_RTCP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTCP + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTCP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_RTCP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTCP + +#endif + +/* MSG_SSID_APPS_QTV_RTSP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTSP + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTSP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_RTSP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTSP + +#endif + +/* MSG_SSID_APPS_QTV_SDP_PARSE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_SDP_PARSE + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_SDP_PARSE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_SDP_PARSE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_SDP_PARSE + +#endif + +/* MSG_SSID_APPS_QTV_ATOM_PARSE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_ATOM_PARSE + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_ATOM_PARSE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_ATOM_PARSE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_ATOM_PARSE + +#endif + +/* MSG_SSID_APPS_QTV_TEXT_TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_TEXT_TASK + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_TEXT_TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_TEXT_TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_TEXT_TASK + +#endif + +/* MSG_SSID_APPS_QTV_DEC_DSP_IF */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEC_DSP_IF + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEC_DSP_IF MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_DEC_DSP_IF) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEC_DSP_IF + +#endif + +/* MSG_SSID_APPS_QTV_STREAM_RECORDING */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAM_RECORDING + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAM_RECORDING MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_STREAM_RECORDING) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAM_RECORDING + +#endif + +/* MSG_SSID_APPS_QTV_CONFIGURATION */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_CONFIGURATION + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_CONFIGURATION MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_CONFIGURATION) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_CONFIGURATION + +#endif + +/* MSG_SSID_APPS_QCAMERA */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QCAMERA + #define MSG_BUILD_MASK_MSG_SSID_APPS_QCAMERA MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QCAMERA) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QCAMERA + +#endif + +/* MSG_SSID_APPS_QCAMCORDER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QCAMCORDER + #define MSG_BUILD_MASK_MSG_SSID_APPS_QCAMCORDER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QCAMCORDER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QCAMCORDER + +#endif + +/* MSG_SSID_APPS_BREW */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_BREW + #define MSG_BUILD_MASK_MSG_SSID_APPS_BREW MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_BREW) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_BREW + +#endif + +/* MSG_SSID_APPS_QDJ */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QDJ + #define MSG_BUILD_MASK_MSG_SSID_APPS_QDJ MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QDJ) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QDJ + +#endif + +/* MSG_SSID_APPS_QDTX */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QDTX + #define MSG_BUILD_MASK_MSG_SSID_APPS_QDTX MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QDTX) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QDTX + +#endif + +/* MSG_SSID_APPS_QTV_BCAST_FLO */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_QTV_BCAST_FLO + #define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_BCAST_FLO MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_QTV_BCAST_FLO) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_QTV_BCAST_FLO + +#endif + +/* MSG_SSID_APPS_MDP_GENERAL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_MDP_GENERAL + #define MSG_BUILD_MASK_MSG_SSID_APPS_MDP_GENERAL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_MDP_GENERAL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_MDP_GENERAL + +#endif + +/* MSG_SSID_APPS_PBM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_PBM + #define MSG_BUILD_MASK_MSG_SSID_APPS_PBM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_PBM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_PBM + +#endif + +/* MSG_SSID_APPS_GRAPHICS_GENERAL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GENERAL + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GENERAL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_GENERAL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GENERAL + +#endif + +/* MSG_SSID_APPS_GRAPHICS_EGL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_EGL + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_EGL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_EGL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_EGL + +#endif + +/* MSG_SSID_APPS_GRAPHICS_OPENGL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENGL + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENGL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_OPENGL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENGL + +#endif + +/* MSG_SSID_APPS_GRAPHICS_DIRECT3D */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DIRECT3D + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DIRECT3D MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_DIRECT3D) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DIRECT3D + +#endif + +/* MSG_SSID_APPS_GRAPHICS_SVG */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_SVG + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_SVG MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_SVG) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_SVG + +#endif + +/* MSG_SSID_APPS_GRAPHICS_OPENVG */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENVG + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENVG MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_OPENVG) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENVG + +#endif + +/* MSG_SSID_APPS_GRAPHICS_2D */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_2D + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_2D MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_2D) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_2D + +#endif + +/* MSG_SSID_APPS_GRAPHICS_QXPROFILER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_QXPROFILER + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_QXPROFILER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_QXPROFILER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_QXPROFILER + +#endif + +/* MSG_SSID_APPS_GRAPHICS_DSP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DSP + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DSP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_DSP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DSP + +#endif + +/* MSG_SSID_APPS_GRAPHICS_GRP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GRP + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GRP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_GRP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GRP + +#endif + +/* MSG_SSID_APPS_GRAPHICS_MDP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_MDP + #define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_MDP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_APPS_GRAPHICS_MDP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_MDP + +#endif + +/* MSG_SSID_ADSPTASKS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS + +#endif + +/* MSG_SSID_ADSPTASKS_KERNEL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_KERNEL + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_KERNEL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_KERNEL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_KERNEL + +#endif + +/* MSG_SSID_ADSPTASKS_AFETASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AFETASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AFETASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AFETASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AFETASK + +#endif + +/* MSG_SSID_ADSPTASKS_VOICEPROCTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOICEPROCTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOICEPROCTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_VOICEPROCTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOICEPROCTASK + +#endif + +/* MSG_SSID_ADSPTASKS_VOCDECTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCDECTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCDECTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_VOCDECTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCDECTASK + +#endif + +/* MSG_SSID_ADSPTASKS_VOCENCTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCENCTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCENCTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_VOCENCTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCENCTASK + +#endif + +/* MSG_SSID_ADSPTASKS_VIDEOTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_VIDEOTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOTASK + +#endif + +/* MSG_SSID_ADSPTASKS_VFETASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VFETASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VFETASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_VFETASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VFETASK + +#endif + +/* MSG_SSID_ADSPTASKS_VIDEOENCTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOENCTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOENCTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_VIDEOENCTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOENCTASK + +#endif + +/* MSG_SSID_ADSPTASKS_JPEGTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_JPEGTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_JPEGTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_JPEGTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_JPEGTASK + +#endif + +/* MSG_SSID_ADSPTASKS_AUDPPTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPPTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPPTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AUDPPTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPPTASK + +#endif + +/* MSG_SSID_ADSPTASKS_AUDPLAY0TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY0TASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY0TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AUDPLAY0TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY0TASK + +#endif + +/* MSG_SSID_ADSPTASKS_AUDPLAY1TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY1TASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY1TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AUDPLAY1TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY1TASK + +#endif + +/* MSG_SSID_ADSPTASKS_AUDPLAY2TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY2TASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY2TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AUDPLAY2TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY2TASK + +#endif + +/* MSG_SSID_ADSPTASKS_AUDPLAY3TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY3TASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY3TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AUDPLAY3TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY3TASK + +#endif + +/* MSG_SSID_ADSPTASKS_AUDPLAY4TASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY4TASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY4TASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AUDPLAY4TASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY4TASK + +#endif + +/* MSG_SSID_ADSPTASKS_LPMTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_LPMTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_LPMTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_LPMTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_LPMTASK + +#endif + +/* MSG_SSID_ADSPTASKS_DIAGTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_DIAGTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_DIAGTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_DIAGTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_DIAGTASK + +#endif + +/* MSG_SSID_ADSPTASKS_AUDRECTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDRECTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDRECTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AUDRECTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDRECTASK + +#endif + +/* MSG_SSID_ADSPTASKS_AUDPREPROCTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPREPROCTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPREPROCTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_AUDPREPROCTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPREPROCTASK + +#endif + +/* MSG_SSID_ADSPTASKS_MODMATHTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_MODMATHTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_MODMATHTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_MODMATHTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_MODMATHTASK + +#endif + +/* MSG_SSID_ADSPTASKS_GRAPHICSTASK */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_GRAPHICSTASK + #define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_GRAPHICSTASK MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSPTASKS_GRAPHICSTASK) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_GRAPHICSTASK + +#endif + +/* OS WINCE SSIDs */ + +/* MSG_SSID_L4LINUX_KERNEL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4LINUX_KERNEL + #define MSG_BUILD_MASK_MSG_SSID_L4LINUX_KERNEL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4LINUX_KERNEL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4LINUX_KERNEL + +#endif + +/* MSG_SSID_L4LINUX_KEYPAD */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4LINUX_KEYPAD + #define MSG_BUILD_MASK_MSG_SSID_L4LINUX_KEYPAD MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4LINUX_KEYPAD) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4LINUX_KEYPAD + +#endif + +/* MSG_SSID_L4LINUX_APPS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4LINUX_APPS + #define MSG_BUILD_MASK_MSG_SSID_L4LINUX_APPS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4LINUX_APPS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4LINUX_APPS + +#endif + +/* MSG_SSID_L4LINUX_QDDAEMON */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4LINUX_QDDAEMON + #define MSG_BUILD_MASK_MSG_SSID_L4LINUX_QDDAEMON MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4LINUX_QDDAEMON) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4LINUX_QDDAEMON + +#endif + +/* MSG_SSID_L4IGUANA_IGUANASERVER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_IGUANASERVER + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_IGUANASERVER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_IGUANASERVER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_IGUANASERVER + +#endif + +/* MSG_SSID_L4IGUANA_EFS2 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_EFS2 + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_EFS2 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_EFS2) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_EFS2 + +#endif + +/* MSG_SSID_L4IGUANA_QDMS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_QDMS + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_QDMS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_QDMS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_QDMS + +#endif + +/* MSG_SSID_L4IGUANA_REX */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_REX + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_REX MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_REX) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_REX + +#endif + +/* MSG_SSID_L4IGUANA_SMMS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SMMS + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SMMS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_SMMS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SMMS + +#endif + +/* MSG_SSID_L4IGUANA_FRAMEBUFFER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_FRAMEBUFFER + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_FRAMEBUFFER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_FRAMEBUFFER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_FRAMEBUFFER + +#endif + +/* MSG_SSID_L4IGUANA_KEYPAD */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_KEYPAD + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_KEYPAD MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_KEYPAD) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_KEYPAD + +#endif + +/* MSG_SSID_L4IGUANA_NAMING */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_NAMING + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_NAMING MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_NAMING) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_NAMING + +#endif + +/* MSG_SSID_L4IGUANA_SDIO */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SDIO + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SDIO MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_SDIO) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SDIO + +#endif + +/* MSG_SSID_L4IGUANA_SERIAL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SERIAL + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SERIAL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_SERIAL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SERIAL + +#endif + +/* MSG_SSID_L4IGUANA_TIMER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TIMER + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TIMER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_TIMER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TIMER + +#endif + +/* MSG_SSID_L4IGUANA_TRAMP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TRAMP + #define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TRAMP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4IGUANA_TRAMP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TRAMP + +#endif + +/* MSG_SSID_L4AMSS_QDIAG */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4AMSS_QDIAG + #define MSG_BUILD_MASK_MSG_SSID_L4AMSS_QDIAG MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4AMSS_QDIAG) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4AMSS_QDIAG + +#endif + +/* MSG_SSID_L4AMSS_APS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_L4AMSS_APS + #define MSG_BUILD_MASK_MSG_SSID_L4AMSS_APS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_L4AMSS_APS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_L4AMSS_APS + +#endif + + + +/* MSG_SSID_HIT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_HIT + #define MSG_BUILD_MASK_MSG_SSID_HIT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_HIT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_HIT + +#endif + + +/* MSG_SSID_QDSP6 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_QDSP6 + #define MSG_BUILD_MASK_MSG_SSID_QDSP6 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_QDSP6) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_QDSP6 + +#endif + +/* MSG_SSID_ADSP_AUD_SVC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_SVC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_SVC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_SVC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_SVC + +#endif /* MSG_SSID_ADSP_AUD_SVC */ + +/* MSG_SSID_ADSP_AUD_ENCDEC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_ENCDEC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_ENCDEC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_ENCDEC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_ENCDEC + +#endif /* MSG_SSID_ADSP_AUD_ENCDEC */ + +/* MSG_SSID_ADSP_AUD_VOC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VOC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VOC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_VOC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VOC + +#endif /* MSG_SSID_ADSP_AUD_VOC */ + +/* MSG_SSID_ADSP_AUD_VS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VS + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_VS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VS + +#endif /* MSG_SSID_ADSP_AUD_VS */ + +/* MSG_SSID_ADSP_AUD_MIDI */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MIDI + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MIDI MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_MIDI) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MIDI + +#endif /* MSG_SSID_ADSP_AUD_MIDI */ + +/* MSG_SSID_ADSP_AUD_POSTPROC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_POSTPROC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_POSTPROC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_POSTPROC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_POSTPROC + +#endif /* MSG_SSID_ADSP_AUD_POSTPROC */ + +/* MSG_SSID_ADSP_AUD_PREPROC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_PREPROC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_PREPROC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_PREPROC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_PREPROC + +#endif /* MSG_SSID_ADSP_AUD_PREPROC */ + +/* MSG_SSID_ADSP_AUD_AFE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_AFE + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_AFE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_AFE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_AFE + +#endif /* MSG_SSID_ADSP_AUD_AFE */ + +/* MSG_SSID_ADSP_AUD_MSESSION */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MSESSION + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MSESSION MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_MSESSION) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MSESSION + +#endif /* MSG_SSID_ADSP_AUD_MSESSION */ + +/* MSG_SSID_ADSP_AUD_DSESSION */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DSESSION + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DSESSION MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_DSESSION) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DSESSION + +#endif /* MSG_SSID_ADSP_AUD_DSESSION */ + +/* MSG_SSID_ADSP_AUD_DCM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DCM + #define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DCM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_AUD_DCM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DCM + +#endif /* MSG_SSID_ADSP_AUD_DCM */ + +/* MSG_SSID_ADSP_VID_ENC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_VID_ENC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENC + +#endif /* MSG_SSID_ADSP_VID_ENC */ + +/* MSG_SSID_ADSP_VID_ENCRPC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENCRPC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENCRPC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_VID_ENCRPC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENCRPC + +#endif /* MSG_SSID_ADSP_VID_ENCRPC */ + +/* MSG_SSID_ADSP_VID_DEC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DEC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DEC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_VID_DEC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DEC + +#endif /* MSG_SSID_ADSP_VID_DEC */ + +/* MSG_SSID_ADSP_VID_DECRPC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DECRPC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DECRPC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_VID_DECRPC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DECRPC + +#endif /* MSG_SSID_ADSP_VID_DECRPC */ + +/* MSG_SSID_ADSP_VID_COMMONSW */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_VID_COMMONSW + #define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_COMMONSW MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_VID_COMMONSW) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_VID_COMMONSW + +#endif /* MSG_SSID_ADSP_VID_COMMONSW */ + +/* MSG_SSID_ADSP_VID_HWDRIVER */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_VID_HWDRIVER + #define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_HWDRIVER MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_VID_HWDRIVER) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_VID_HWDRIVER + +#endif /* MSG_SSID_ADSP_VID_HWDRIVER */ + +/* MSG_SSID_ADSP_JPG_ENC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_ENC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_ENC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_JPG_ENC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_ENC + +#endif /* MSG_SSID_ADSP_JPG_ENC */ + +/* MSG_SSID_ADSP_JPG_DEC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_DEC + #define MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_DEC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_JPG_DEC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_DEC + +#endif /* MSG_SSID_ADSP_JPG_DEC */ + +/* MSG_SSID_ADSP_OMM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_OMM + #define MSG_BUILD_MASK_MSG_SSID_ADSP_OMM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_OMM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_OMM + +#endif /* MSG_SSID_ADSP_OMM */ + +/* MSG_SSID_ADSP_PWRDEM */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_PWRDEM + #define MSG_BUILD_MASK_MSG_SSID_ADSP_PWRDEM MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_PWRDEM) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_PWRDEM + +#endif /* MSG_SSID_ADSP_PWRDEM */ + +/* MSG_SSID_ADSP_RESMGR */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_RESMGR + #define MSG_BUILD_MASK_MSG_SSID_ADSP_RESMGR MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_RESMGR) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_RESMGR + +#endif /* MSG_SSID_ADSP_RESMGR */ + +/* MSG_SSID_ADSP_CORE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_ADSP_CORE + #define MSG_BUILD_MASK_MSG_SSID_ADSP_CORE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_ADSP_CORE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_ADSP_CORE + +#endif /* MSG_SSID_ADSP_CORE */ + +/* MSG_SSID_LTE */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE + #define MSG_BUILD_MASK_MSG_SSID_LTE MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE + +#endif + +/* MSG_SSID_LTE_RRC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_RRC + #define MSG_BUILD_MASK_MSG_SSID_LTE_RRC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_RRC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_RRC + +#endif + +/* MSG_SSID_LTE_MACUL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_MACUL + #define MSG_BUILD_MASK_MSG_SSID_LTE_MACUL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_MACUL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_MACUL + +#endif + +/* MSG_SSID_LTE_MACDL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_MACDL + #define MSG_BUILD_MASK_MSG_SSID_LTE_MACDL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_MACDL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_MACDL + +#endif + +/* MSG_SSID_LTE_MACCTRL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_MACCTRL + #define MSG_BUILD_MASK_MSG_SSID_LTE_MACCTRL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_MACCTRL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_MACCTRL + +#endif + +/* MSG_SSID_LTE_RLCUL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_RLCUL + #define MSG_BUILD_MASK_MSG_SSID_LTE_RLCUL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_RLCUL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_RLCUL + +#endif + +/* MSG_SSID_LTE_RLCDL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_RLCDL + #define MSG_BUILD_MASK_MSG_SSID_LTE_RLCDL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_RLCDL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_RLCDL + +#endif + +/* MSG_SSID_LTE_PDCPUL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_PDCPUL + #define MSG_BUILD_MASK_MSG_SSID_LTE_PDCPUL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_PDCPUL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_PDCPUL + +#endif + +/* MSG_SSID_LTE_PDCPDL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_PDCPDL + #define MSG_BUILD_MASK_MSG_SSID_LTE_PDCPDL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_PDCPDL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_PDCPDL + +#endif + +/* MSG_SSID_LTE_ML1 */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_LTE_ML1 + #define MSG_BUILD_MASK_MSG_SSID_LTE_ML1 MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_LTE_ML1) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_LTE_ML1 + +#endif + +/* MSG_SSID_UMB */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB + #define MSG_BUILD_MASK_MSG_SSID_UMB MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB + +#endif + +/* MSG_SSID_UMB_APP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB_APP + #define MSG_BUILD_MASK_MSG_SSID_UMB_APP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB_APP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB_APP + +#endif + +/* MSG_SSID_UMB_DS */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB_DS + #define MSG_BUILD_MASK_MSG_SSID_UMB_DS MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB_DS) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB_DS + +#endif + +/* MSG_SSID_UMB_CP */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB_CP + #define MSG_BUILD_MASK_MSG_SSID_UMB_CP MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB_CP) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB_CP + +#endif + +/* MSG_SSID_UMB_RLL */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB_RLL + #define MSG_BUILD_MASK_MSG_SSID_UMB_RLL MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB_RLL) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB_RLL + +#endif + +/* MSG_SSID_UMB_MAC */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB_MAC + #define MSG_BUILD_MASK_MSG_SSID_UMB_MAC MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB_MAC) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB_MAC + +#endif + +/* MSG_SSID_UMB_SRCH */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB_SRCH + #define MSG_BUILD_MASK_MSG_SSID_UMB_SRCH MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB_SRCH) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB_SRCH + +#endif + +/* MSG_SSID_UMB_FW */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB_FW + #define MSG_BUILD_MASK_MSG_SSID_UMB_FW MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB_FW) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB_FW + +#endif + +/* MSG_SSID_UMB_PLT */ + +/* In case it is not defined in msgtgt.h */ +#ifndef MSG_BUILD_MASK_MSG_SSID_UMB_PLT + #define MSG_BUILD_MASK_MSG_SSID_UMB_PLT MSG_BUILD_MASK_DFLT +#endif + +/* If the build environment has specified this file to translate legacy + messages to the this SSID. */ +#if defined (MSG_BT_SSID_DFLT) && (MSG_BT_SSID_DFLT==MSG_SSID_UMB_PLT) + + #undef MSG_SSID_DFLT + #define MSG_SSID_DFLT MSG_BT_SSID_DFLT + + #undef MSG_BUILD_MASK_MSG_SSID_DFLT + #define MSG_BUILD_MASK_MSG_SSID_DFLT MSG_BUILD_MASK_MSG_SSID_UMB_PLT + +#endif + +/* These SSIDs are reserved for OEM (customer) use only. These IDs will + never be used by Qualcomm. */ +#define MSG_FIRST_TARGET_OEM_SSID (0xC000) +#define MSG_LAST_TARGET_OEM_SSID (0xCFFF) + +/* Macros to generate the Build Mask and Run Time tables */ + +/* Important Note: This needs to be modified manually now, +when we add a new RANGE of SSIDs to the msg_mask_tbl */ +#define MSG_MASK_TBL_CNT 24 +/*! +@endcond DOXYGEN_BLOAT +*/ +#ifdef __cplusplus +} +#endif + +#endif /* MSGCFG_H */ diff --git a/feeds/wifi-ax/qca-diag/src/include/msgtgt.h b/feeds/wifi-ax/qca-diag/src/include/msgtgt.h new file mode 100755 index 000000000..41b071938 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/include/msgtgt.h @@ -0,0 +1,847 @@ +#ifndef MSGTGT_H +#define MSGTGT_H + +/*! + @ingroup diag_message_service + @file msgtgt.h + @brief + Target-specific configuration file for Diagnostic Message 2.0 Service + @par + MSG 2.0 offers the ability to utilize more build-time and run-time + filtering of debug messages. + @par + This file is used to customize MSG 2.0 for a specific build. All + definitions here override their counterparts in msgcfg.h. + @par + This file may contain, but is not limited to any or all of the following: + @par + Build masks for known SSIDs , default build mask , max string length + (used to avoid endless strcpy). + @par + Build masks are 32 bits, each specifying a category within a SSID. The + first 5 LSBs are reserved for legacy (Low, Med, High, Error, Fatal). These + can be reused with the tradeoff of any legacy tool interpreting those bits + as legacy message levels.The 27 MSBs in the mask are defined at the discretion + of the technology area associated with the SSID. These are to be published, + so changing the meaning is not allowed. + @note + The definitions of all these constants are omitted in the document for the + sake of brevity. +*/ + +/* +Copyright (c) 2002-2016 by Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary +*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + + $Header: //source/qcom/qct/core/api/services/diag/main/latest/msgtgt.h#49 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +03/31/14 xy Added new message SSIDs +02/25/14 xy Update levels of MSG_BUILD_MASK_MSG_SSID_LTE_RRC +01/29/14 xy Added new message SSIDs +12/03/13 xy Added new message SSIDs +10/09/13 xy Update levels of MSG_BUILD_MASK_MSG_SSID_HDR_DEBUG +09/25/13 xy Added new message SSIDs +07/30/13 sr Added new message SSIDs +06/26/13 sr Added new message SSIDs +05/08/13 sr Added new message SSIDs +04/17/13 sr Support to disable F3 msgs by target team +03/22/13 sr Added new message SSIDs +03/12/13 sr Added new message SSIDs +01/22/13 sr Added new message SSIDs +12/07/12 sr Added new message SSIDs +11/27/12 sr Added new message SSIDs +10/15/12 sr Added new message SSIDs +07/16/12 rh Added new message SSIDs +06/22/12 rh Added new message SSIDs +06/06/12 rh Updated several SSIDs to have different build-time masks. +03/26/12 rh Expanded the TDSCDMA L1 mask to encompass more level categories +02/29/12 rh Added new message SSIDs +02/21/12 is Add MSG_BUILD_MASK_LEGACY catergory to support F3 listener testing +02/17/12 rs Added build mask for MSG_SSID_SEC_WIDEVINE +01/12/12 rh Changed priority level for TDSCDMA SSIDs +01/05/12 rh Added build mask for QCNEA SSIDs +12/08/11 rh Added build mask for MSG_SSID_ADC +11/29/11 rh Added SSID category for CTA +10/18/11 hm Renamed reserved MCS SSIDs +09/01/11 hm Added new WCDMA and TDSCDMA SSIDs +08/05/11 hm Added new SSID +07/01/11 hm Added new SSID +06/10/11 hm Changed default level of AVS SSIDs +05/20/11 hm Changed default level of QCHAT SSIDs +04/25/11 hm Added new SSID +04/05/11 hm Added new SSID for PPM module +03/24/11 hm Reverted Octopus Changes and added new QCHAT SSIDs +03/07/11 hm Added new set of SSIDs for Octopus +02/03/11 hm Changed MSG level for Audio Packet Router (for 8k+9k Fusion) +01/21/11 hm Enabled ML1 messages 21 and 22 +07/27/10 sg Added new ssid for Multimedia team +07/07/10 sg Added new SSID for data services team +07/06/10 sg Changed MSG_SSID_MCS_RESERVED_1 to MSG_SSID_FWS +06/28/10 sg Changing MSG_BUILD_MASK_MSG_SSID_RF level to MSG_LVL_LOW +06/10/10 mad Doxygenated +04/27/10 sg Added new SSIDS for Sound Routing Driver , DAL +04/20/10 sg Added new SSIDS for Audio Team +04/09/10 sg Added new SSIDS for OMA device management + Secure Instant Wireless Access +04/02/10 sg Added inclusion of msg_mask.h +03/04/10 sg Added new SSIDs for IMS Team +02/22/10 sg Added new SSIDs for Data Services +02/12/10 sg Modified message level for LTE ML1 SSID +02/08/10 sg Added new SSIDs for IMS team +01/13/10 sg Added new SSID for CAD team +12/22/09 sg Added New SSID for Connectivity Engine Team +11/24/09 sg Changes made to allow target team to define MSG_BUILD_MASK_DFLT, + MSG_BUILD_MASK_MSG_SSID_DFLT +10/28/09 sg Added New SSID for Chaos CoOrdinator Service +10/27/09 sg Added new SSID for Data Services team +10/26/09 sg Fixed the ECALL SSID typo +09/30/09 as Removed feature T_MSM6200 and T_MSM6250 +09/23/09 sg Added new SSIDS for ECALL +09/02/09 JV Added new SSIDs for the HDR team +07/27/09 JV New SSID for ANDROID data and DS apps +07/18/09 mad Mainlined FEATUREs: IS2000, HDR, WCDMA, GSM, WLAN, DS, DATA, + HIT. +06/11/09 JV New SSID for data services +05/26/09 JV Added custom levels for LTE F3 SSIDs +05/11/09 JV New SSIDs for Android QCRIL and A2 modules +04/23/09 JV Added SSIDs for the WLAN libra module. +04/10/09 JV Added SSIDs for MCS. +03/16/09 mad Featurized inclusion of customer.h +12/14/04 as Reallocated SSID's used by WinCE to L4LINUX. +03/07/03 lad First SSID deployment. +12/03/02 lad Created file. + +===========================================================================*/ +#include "comdef.h" + +#include "msg.h" + +/*! +@name Default build mask +@ingroup diag_message_service +*/ +/*! + Default build mask for all uncategorizerd (default) messages. */ +#ifndef MSG_BUILD_MASK_DFLT +#define MSG_BUILD_MASK_DFLT MSG_LVL_ERROR +#endif + +#ifndef MSG_BUILD_MASK_LEGACY +#define MSG_BUILD_MASK_LEGACY MSG_LVL_HIGH +#endif + +/*! +@cond DOXYGEN_BLOAT +*/ +/* General SSIDs */ +#ifndef MSG_BUILD_MASK_MSG_SSID_DFLT +#define MSG_BUILD_MASK_MSG_SSID_DFLT (MSG_LVL_HIGH) +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_LEGACY +#define MSG_BUILD_MASK_MSG_SSID_LEGACY (MSG_LVL_HIGH) +#endif + +#define MSG_BUILD_MASK_MSG_SSID_AUDFMT (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_AVS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_BOOT (MSG_LVL_ERROR) +#define MSG_BUILD_MASK_MSG_SSID_BT (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_CM (MSG_LVL_LOW) //AST req +#define MSG_BUILD_MASK_MSG_SSID_CMX (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DIAG (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_DSM (MSG_LVL_ERROR) +#define MSG_BUILD_MASK_MSG_SSID_FTM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_FS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_HS (MSG_LVL_ERROR) +#define MSG_BUILD_MASK_MSG_SSID_GPS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MDSP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MMOC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_QDSP (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_REX (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_RF (MSG_LVL_LOW | MSG_MASK_5 | \ + MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8) +#define MSG_BUILD_MASK_MSG_SSID_RUIM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_SIO (MSG_LVL_ERROR) +#define MSG_BUILD_MASK_MSG_SSID_SD (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_SRM (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_TMC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_VS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WMS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MMGPS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_SLEEP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_SAM (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_SFAT (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_JOYST (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MFLO (MSG_LVL_MED|MSG_MASK_7 | \ + MSG_MASK_8|MSG_MASK_9|MSG_MASK_10|MSG_MASK_11|MSG_MASK_12 | \ + MSG_MASK_13|MSG_MASK_14|MSG_MASK_15|MSG_MASK_16 | \ + MSG_MASK_17|MSG_MASK_18|MSG_MASK_19|MSG_MASK_20|MSG_MASK_21) +#define MSG_BUILD_MASK_MSG_SSID_DTV (MSG_LVL_MED|MSG_MASK_5 | \ + MSG_MASK_6|MSG_MASK_7|MSG_MASK_8|MSG_MASK_9|MSG_MASK_10| \ + MSG_MASK_11|MSG_MASK_12|MSG_MASK_13|MSG_MASK_14| \ + MSG_MASK_15|MSG_MASK_16|MSG_MASK_17) +#define MSG_BUILD_MASK_MSG_SSID_TCXOMGR (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_EFS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_IRDA (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_FM_RADIO (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_AAM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_BM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_PE (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_QIPCALL (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_FLUTE (MSG_LVL_MED|MSG_MASK_5 | \ + MSG_MASK_6|MSG_MASK_7|MSG_MASK_8) +#define MSG_BUILD_MASK_MSG_SSID_CAMERA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_HSUSB (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_FC (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_USBHOST (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_PROFILER (MSG_LVL_HIGH) +#ifndef MSG_BUILD_MASK_MSG_SSID_MGP + #define MSG_BUILD_MASK_MSG_SSID_MGP (MSG_LVL_MED) +#endif +#ifndef MSG_BUILD_MASK_MSG_SSID_MGPME + #define MSG_BUILD_MASK_MSG_SSID_MGPME (MSG_LVL_MED|MSG_MASK_5 | \ + MSG_MASK_6|MSG_MASK_7|MSG_MASK_8|MSG_MASK_9|MSG_MASK_10| \ + MSG_MASK_11|MSG_MASK_12|MSG_MASK_13|MSG_MASK_14|MSG_MASK_15| \ + MSG_MASK_16|MSG_MASK_17|MSG_MASK_18|MSG_MASK_19|MSG_MASK_20| \ + MSG_MASK_21|MSG_MASK_22|MSG_MASK_23|MSG_MASK_24|MSG_MASK_25) +#endif +#ifndef MSG_BUILD_MASK_MSG_SSID_MGPPE + #define MSG_BUILD_MASK_MSG_SSID_MGPPE (MSG_LVL_MED|MSG_MASK_5 | \ + MSG_MASK_6|MSG_MASK_7|MSG_MASK_8|MSG_MASK_9|MSG_MASK_10) +#endif +#ifndef MSG_BUILD_MASK_MSG_SSID_GPSOS + #define MSG_BUILD_MASK_MSG_SSID_GPSOS (MSG_LVL_MED) +#endif +#ifndef MSG_BUILD_MASK_MSG_SSID_GPSSM + #define MSG_BUILD_MASK_MSG_SSID_GPSSM (MSG_LVL_LOW) +#endif +#ifndef MSG_BUILD_MASK_MSG_SSID_IMS + #define MSG_BUILD_MASK_MSG_SSID_IMS (MSG_LVL_LOW) +#endif +#ifndef MSG_BUILD_MASK_MSG_SSID_MBP_RF + #define MSG_BUILD_MASK_MSG_SSID_MBP_RF (MSG_LVL_MED) +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_SNS + #define MSG_BUILD_MASK_MSG_SSID_SNS (MSG_LVL_LOW) +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_WM + #define MSG_BUILD_MASK_MSG_SSID_WM (MSG_LVL_LOW) +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_LK + #define MSG_BUILD_MASK_MSG_SSID_LK (MSG_LVL_LOW) +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_PWRDB + #define MSG_BUILD_MASK_MSG_SSID_PWRDB (MSG_LVL_HIGH) +#endif + +#define MSG_BUILD_MASK_MSG_SSID_DCVS (MSG_LVL_LOW) /* Dynamic Clock and Voltage Scaling (asw.power req) */ + +#define MSG_BUILD_MASK_MSG_SSID_ANDROID_ADB (MSG_LVL_LOW) /* Created for Android messages drained from logcat */ + +#define MSG_BUILD_MASK_MSG_SSID_VIDEO_ENCODER (MSG_LVL_LOW | MSG_MASK_5 | \ + MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8) /* Video Encoder request */ +#define MSG_BUILD_MASK_MSG_SSID_VENC_OMX (MSG_LVL_LOW | MSG_MASK_5 | \ + MSG_MASK_6) /* Video Encoder request */ + +#define MSG_BUILD_MASK_MSG_SSID_GAN (MSG_LVL_MED) /* Generic Access Network (Requested by Priya Ahire) */ +#define MSG_BUILD_MASK_MSG_SSID_KINETO_GAN (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_ANDROID_QCRIL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_A2 (MSG_LVL_MED | MSG_MASK_5 | \ + MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8 | MSG_MASK_9 | MSG_MASK_10 | \ + MSG_MASK_11 | MSG_MASK_12 | MSG_MASK_13 | MSG_MASK_14 | MSG_MASK_15 | \ + MSG_MASK_16 | MSG_MASK_17 | MSG_MASK_18 | MSG_MASK_19 | MSG_MASK_20) +#define MSG_BUILD_MASK_MSG_SSID_LINUX_DATA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ECALL (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_CHORD (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_CAD_GENERAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_OMADM (MSG_LVL_HIGH) /* OMA device management */ +#define MSG_BUILD_MASK_MSG_SSID_SIWA (MSG_LVL_HIGH) /* Secure Instant Wireless Access */ +#define MSG_BUILD_MASK_MSG_SSID_APR_MODEM (MSG_LVL_LOW) /* Audio Packet Router Modem */ +#define MSG_BUILD_MASK_MSG_SSID_APR_APPS (MSG_LVL_LOW) /* Audio Packet Router Apps*/ +#define MSG_BUILD_MASK_MSG_SSID_APR_ADSP (MSG_LVL_LOW) /* Audio Packet Router Adsp*/ +#define MSG_BUILD_MASK_MSG_SSID_SRD_GENERAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ACDB_GENERAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DALTF (MSG_LVL_HIGH | MSG_MASK_21) +#define MSG_BUILD_MASK_MSG_SSID_CFM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_PMIC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_GPS_SDP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_TLE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_TLE_XTM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_TLE_TLM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_TLE_TLM_MM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WWAN_LOC (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_GNSS_LOCMW (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QSET (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_QBI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MMODE_QMI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_MCFG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_SSM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_MPOWER (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_RMTS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADIE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_VT_VCEL (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_FLASH_SCRUB (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_STRIDE (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_POLICYMAN (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_TMS (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_LWIP (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_RFS (MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR) +#define MSG_BUILD_MASK_MSG_SSID_RFS_ACCESS (MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR) +#define MSG_BUILD_MASK_MSG_SSID_RLC (MSG_LVL_MED | MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_MEMHEAP (MSG_LVL_MED | MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_WCI2 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_LOWI_TEST (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_AOSTLM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_LOWI_AP (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_LOWI_MP (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_LOWI_LP (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_MRE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_SLIM (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_WLE (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_WLM (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_Q6ZIP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_RF_DEBUG (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_NV (MSG_LVL_HIGH) + +/* ONCRPC related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_ONCRPC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_MODEM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_APPS (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_MODEM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_APPS (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_ONCRPC_DB (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_ONCRPC_SND (MSG_LVL_HIGH) + +/* 1X related SSIDs */ + +#define MSG_BUILD_MASK_MSG_SSID_1X (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_1X_ACP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_1X_DCP (MSG_LVL_MED) //AST req +#define MSG_BUILD_MASK_MSG_SSID_1X_DEC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_1X_ENC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_1X_GPSSRCH (MSG_LVL_MED|MSG_MASK_5) +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_MUX + #define MSG_BUILD_MASK_MSG_SSID_1X_MUX (MSG_LVL_MED) +#endif +#ifndef MSG_BUILD_MASK_MSG_SSID_1X_SRCH + #define MSG_BUILD_MASK_MSG_SSID_1X_SRCH (MSG_LVL_MED) +#endif + + +/* HDR related SSIDs */ + +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_PROT +#define MSG_BUILD_MASK_MSG_SSID_HDR_PROT (MSG_LVL_MED) +#endif +#define MSG_BUILD_MASK_MSG_SSID_HDR_DATA (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_HDR_SRCH (MSG_LVL_MED) +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_DRIVERS +#define MSG_BUILD_MASK_MSG_SSID_HDR_DRIVERS (MSG_LVL_MED) +#endif +#define MSG_BUILD_MASK_MSG_SSID_HDR_IS890 (MSG_LVL_MED) +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_DEBUG + #define MSG_BUILD_MASK_MSG_SSID_HDR_DEBUG (MSG_LVL_MED | MSG_MASK_5 | MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8 | MSG_MASK_9 | MSG_MASK_10) +#endif +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_HIT + #define MSG_BUILD_MASK_MSG_SSID_HDR_HIT (MSG_LVL_MED) +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_PCP + #define MSG_BUILD_MASK_MSG_SSID_HDR_PCP (MSG_LVL_MED) +#endif + +#ifndef MSG_BUILD_MASK_MSG_SSID_HDR_HEAPMEM + #define MSG_BUILD_MASK_MSG_SSID_HDR_HEAPMEM (MSG_LVL_MED) +#endif + + +/* HIT related SSIDs */ + +#ifndef MSG_BUILD_MASK_MSG_SSID_HIT +#define MSG_BUILD_MASK_MSG_SSID_HIT (MSG_LVL_MED) +#endif + + +/* QDSP6 related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_QDSP6 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_SVC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_ENCDEC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VOC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MIDI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_POSTPROC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_PREPROC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_AFE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MSESSION (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DSESSION (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DCM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENCRPC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DEC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DECRPC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_COMMONSW (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_VID_HWDRIVER (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_ENC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_DEC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_OMM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_PWRDEM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_RESMGR (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_CORE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSP_RDA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_TAFE_HAL (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_ALGORITHM (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_FRAMEWORK (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_SRE (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) +#define MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_TAFE_DRIVER (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) + +/* UMB related SSIDs*/ +#define MSG_BUILD_MASK_MSG_SSID_UMB (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_UMB_APP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_UMB_DS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_UMB_CP (MSG_LVL_MED | MSG_MASK_6 | \ + MSG_MASK_7 | MSG_MASK_8 | MSG_MASK_9) +#define MSG_BUILD_MASK_MSG_SSID_UMB_RLL (MSG_LVL_MED | MSG_MASK_5 | \ + MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8 | MSG_MASK_9 | MSG_MASK_10 | \ + MSG_MASK_11 | MSG_MASK_12 | MSG_MASK_13 | MSG_MASK_14 | MSG_MASK_15 | \ + MSG_MASK_16 | MSG_MASK_17) +#define MSG_BUILD_MASK_MSG_SSID_UMB_MAC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_UMB_SRCH (MSG_LVL_MED | MSG_MASK_5 | \ + MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8 | MSG_MASK_9 | MSG_MASK_10 | \ + MSG_MASK_11 | MSG_MASK_12 | MSG_MASK_13 | MSG_MASK_14 | MSG_MASK_15 | \ + MSG_MASK_16 | MSG_MASK_17 | MSG_MASK_18 | MSG_MASK_19 | MSG_MASK_20 | \ + MSG_MASK_21 | MSG_MASK_22) +#define MSG_BUILD_MASK_MSG_SSID_UMB_FW (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_UMB_PLT (MSG_LVL_MED) + +/* LTE related SSIDs*/ +#define MSG_BUILD_MASK_MSG_SSID_LTE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_LTE_RRC (MSG_LVL_LOW | MSG_MASK_8 | MSG_MASK_9 | MSG_MASK_10 | \ + MSG_MASK_11 | MSG_MASK_12 | MSG_MASK_13 | MSG_MASK_14 | MSG_MASK_15 | \ + MSG_MASK_16 | MSG_MASK_17 | MSG_MASK_18 | MSG_MASK_19 | MSG_MASK_20) +#define MSG_BUILD_MASK_MSG_SSID_LTE_MACUL (MSG_LVL_LOW | MSG_MASK_5 | MSG_MASK_6) +#define MSG_BUILD_MASK_MSG_SSID_LTE_MACDL (MSG_LVL_LOW | MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_LTE_MACCTRL (MSG_LVL_LOW | MSG_MASK_5 | MSG_MASK_6) +#define MSG_BUILD_MASK_MSG_SSID_LTE_RLCUL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_LTE_RLCDL (MSG_LVL_LOW | MSG_MASK_5 | \ + MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8 | MSG_MASK_9) +#define MSG_BUILD_MASK_MSG_SSID_LTE_PDCPUL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_LTE_PDCPDL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_LTE_ML1 (MSG_LVL_LOW | MSG_MASK_5 | MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8 | \ + MSG_MASK_9 | MSG_MASK_10 | MSG_MASK_11 | MSG_MASK_12 | MSG_MASK_13 | MSG_MASK_14 | MSG_MASK_15 | MSG_MASK_16 | \ + MSG_MASK_20 | MSG_MASK_21 | MSG_MASK_22) +#define MSG_BUILD_MASK_MSG_SSID_LTE_DISCOVERY (MSG_LVL_LOW) + +/* UMTS related SSIDs */ + +#define MSG_BUILD_MASK_MSG_SSID_UMTS (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_WCDMA_L1 (MSG_LVL_HIGH | MSG_MASK_5 | MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8 | \ + MSG_MASK_9 | MSG_MASK_10 | MSG_MASK_11 | MSG_MASK_12 | MSG_MASK_13 | MSG_MASK_14 | MSG_MASK_15 | MSG_MASK_16 | \ + MSG_MASK_20 | MSG_MASK_21 | MSG_MASK_22) +#define MSG_BUILD_MASK_MSG_SSID_WCDMA_L2 (MSG_LVL_HIGH | MSG_MASK_5 | MSG_MASK_6) +#define MSG_BUILD_MASK_MSG_SSID_WCDMA_MAC (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_WCDMA_RLC (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_WCDMA_RRC (MSG_LVL_HIGH | MSG_MASK_5 | MSG_MASK_6 | MSG_MASK_7) +#define MSG_BUILD_MASK_MSG_SSID_NAS_CNM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_NAS_MM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_NAS_MN (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_NAS_RABM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_NAS_REG (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_NAS_SM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_NAS_TC (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_NAS_CB (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WCDMA_LEVEL (MSG_LVL_LOW) + + +/* GSM related SSIDs */ + +#define MSG_BUILD_MASK_MSG_SSID_GSM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_GSM_L1 (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_GSM_L2 (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_GSM_RR (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GCOMMON (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GLLC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GMAC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GPL1 (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRLC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRR (MSG_LVL_MED|MSG_MASK_5 | MSG_MASK_6 | MSG_MASK_7 | MSG_MASK_8 | MSG_MASK_9) +#define MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GSNDCP (MSG_LVL_MED) + + + +#define MSG_BUILD_MASK_MSG_SSID_WLAN (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_ADP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_CP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_FTM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_OEM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_SEC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_TRP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_1 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_2 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_3 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_4 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_5 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_6 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_7 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_8 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_9 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_10 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_TL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_BAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_SAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_SSC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_HDD (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_SME (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_PE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_HAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_SYS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_VOSS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_ATHOS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_WMI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_HTT (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_PS_STA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_PS_IBSS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_PS_AP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_SMPS_STA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_WHAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_COEX (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_ROAM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RESMGR (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_PROTO (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_SCAN (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_BATCH_SCAN (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_EXTSCAN (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_BLOCKACK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_TXRX_DATA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_TXRX_MGMT (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_BEACON (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_OFFLOAD_MGR (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_MACCORE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_PCIELP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RTT (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_DCS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_CACHEMGR (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_ANI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_P2P (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_CSA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_NLO (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_CHATTER (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_WOW (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_WMMAC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_TDLS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_HB (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_TXBF (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_THERMAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_DFS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_RMC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_STATS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_NAN (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_HIF_UART (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_LPI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_MLME (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_SUPPL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_ERE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_WLAN_OCB (MSG_LVL_LOW) + + +#define MSG_BUILD_MASK_MSG_SSID_ATS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MSGR (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPMGR (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_QTF (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_FWS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_SRCH4 (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_CMAPI (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MMAL (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_QRARB (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_LMTSMGR (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_7 (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_8 (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_IRATMAN (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_CXM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_VSTMR (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_CFCM (MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR | MSG_LVL_FATAL) + +/* DS related SSIDs */ + +#define MSG_BUILD_MASK_MSG_SSID_DS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_RLP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_PPP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_TCPIP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_IS707 (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_3GMGR (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_PS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_MIP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_UMTS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_GPRS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_GSM (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_SOCKETS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_ATCOP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_SIO (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_BCMCS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_MLRLP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_RTP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DS_SIPSTACK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DS_ROHC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_DOQOS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_IPC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_SHIM (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_ACLPOLICY (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_APPS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_MUX (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_3GPP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_LTE (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_WCDMA (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_ACLPOLICY_APPS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_HDR (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_IPA (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_EPC (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_DS_APPSRV (MSG_LVL_MED) + +#define MSG_BUILD_MASK_MSG_SSID_SEC (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_CRYPTO (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_SSL (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_IPSEC (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_SFS (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_TEST (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_CNTAGENT (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_RIGHTSMGR (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_ROAP (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_MEDIAMGR (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_IDSTORE (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_IXFILE (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_IXSQL (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_IXCOMMON (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_BCASTCNTAGENT (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_PLAYREADY (MSG_LVL_MED|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_SEC_WIDEVINE (MSG_LVL_MED|MSG_MASK_5) + +/* APPS related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_APPS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_APPMGR (MSG_LVL_ERROR) +#define MSG_BUILD_MASK_MSG_SSID_APPS_UI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV (MSG_LVL_LOW|MSG_MASK_5 | \ + MSG_MASK_6|MSG_MASK_7|MSG_MASK_8|MSG_MASK_9|MSG_MASK_10| \ + MSG_MASK_11|MSG_MASK_12|MSG_MASK_13|MSG_MASK_14|MSG_MASK_15| \ + MSG_MASK_16|MSG_MASK_17|MSG_MASK_18|MSG_MASK_19|MSG_MASK_20| \ + MSG_MASK_21|MSG_MASK_22) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QVP (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STATISTICS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VENCODER (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_MODEM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_UI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STACK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VDECODER (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_ACM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_HEAP_PROFILE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_GENERAL (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEBUG (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STATISTICS (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_UI_TASK (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MP4_PLAYER (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_AUDIO_TASK (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_VIDEO_TASK (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAMING (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MPEG4_TASK (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_FILE_OPS (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTP (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTCP (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTSP (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_SDP_PARSE (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_ATOM_PARSE (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_TEXT_TASK (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEC_DSP_IF (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAM_RECORDING (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_CONFIGURATION (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QCAMERA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QCAMCORDER (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_BREW (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QDJ (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QDTX (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_QTV_BCAST_FLO (MSG_LVL_LOW|MSG_MASK_5) +#define MSG_BUILD_MASK_MSG_SSID_APPS_MDP_GENERAL (MSG_LVL_LOW|MSG_MASK_0| \ + MSG_MASK_1|MSG_MASK_2|MSG_MASK_3|MSG_MASK_4|MSG_MASK_5|MSG_MASK_6) +#define MSG_BUILD_MASK_MSG_SSID_APPS_PBM (MSG_LVL_HIGH) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GENERAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_EGL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENGL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DIRECT3D (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_SVG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENVG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_2D (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_QXPROFILER (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DSP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GRP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_MDP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_CAD (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_DPL (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_FW (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SIP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_REGMGR (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RTP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SDP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_VS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_XDM (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_HOM (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_IM_ENABLER (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_IMS_CORE (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_FWAPI (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SERVICES (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_POLICYMGR (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_PRESENCE (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_QIPCALL (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SIGCOMP (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_PSVT (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_UNKNOWN (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SETTINGS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_OMX_COMMON (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_CD (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_IM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_FT (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_IS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_AUTO_CONFIG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_COMMON (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_UT (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_XML (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_APPS_IMS_COM (MSG_LVL_MED) + +/* ADSP tasks related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_KERNEL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AFETASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOICEPROCTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCDECTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCENCTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VFETASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOENCTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_JPEGTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPPTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY0TASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY1TASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY2TASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY3TASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY4TASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_LPMTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_DIAGTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDRECTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPREPROCTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_MODMATHTASK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_GRAPHICSTASK (MSG_LVL_LOW) + +/* L4 LINUX KERNEL related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_L4LINUX_KERNEL (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4LINUX_KEYPAD (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4LINUX_APPS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4LINUX_QDDAEMON (MSG_LVL_MED) + +/* L4 IGUANA related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_IGUANASERVER (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_EFS2 (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_QDMS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_REX (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SMMS (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_FRAMEBUFFER (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_KEYPAD (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_NAMING (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SDIO (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SERIAL (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TIMER (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TRAMP (MSG_LVL_MED) + +/* L4 AMSS related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_L4AMSS_QDIAG (MSG_LVL_MED) +#define MSG_BUILD_MASK_MSG_SSID_L4AMSS_APS (MSG_LVL_MED) + +/* QCHAT related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_QCHAT (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_CAPP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_CENG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_CREG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_CMED (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_CAUTH (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_QBAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_OSAL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_OEMCUST (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_MULTI_PROC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCHAT_UPK (MSG_LVL_LOW) + +/* TDSCDMA related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_TDSCDMA_L1 (MSG_LVL_LOW|MSG_MASK_5|MSG_MASK_6|MSG_MASK_7|MSG_MASK_8|MSG_MASK_9|MSG_MASK_10|MSG_MASK_11|MSG_MASK_12) +#define MSG_BUILD_MASK_MSG_SSID_TDSCDMA_L2 (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_TDSCDMA_MAC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_TDSCDMA_RLC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_TDSCDMA_RRC (MSG_LVL_LOW) + +/* CTA related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_CTA (MSG_LVL_HIGH) + +/* QCNEA related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_QCNEA (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_CAC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_CAS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_CDE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_COM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_LEE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_QMI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_SRM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_GENERIC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_NETLINK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_NIMS (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_NSRM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_NSRM_CORE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_NSRM_GATESM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_NSRM_TRG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_PLCY (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_PLCY_ANDSF (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_TEST (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_BQE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_CQE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_ICD (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_IFSEL (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_IFSELRSM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_ATP (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_ATP_PLCY (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_QCNEA_ATP_RPRT (MSG_LVL_LOW) + +/* DPM related SSIDs */ +#define MSG_BUILD_MASK_MSG_SSID_DPM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_COMMON (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_COM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_QMI (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_DSM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_CONFIG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_GENERIC (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_NETLINK (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_FD_MGR (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_CT_MGR (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_NSRM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_NSRM_CORE (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_NSRM_GATESM (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_NSRM_TRG (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_TEST (MSG_LVL_LOW) +#define MSG_BUILD_MASK_MSG_SSID_DPM_TCM (MSG_LVL_LOW) + +/* Example: specify a build mask for SSID_FOO */ +#if 0 +#define MSG_BUILD_MASK_MSG_SSID_FOO (MSG_LVL_MED | 0x00ff00) +#endif + +/*! +@endcond DOXYGEN_BLOAT +*/ +#endif /* MSGTGT_H */ diff --git a/feeds/wifi-ax/qca-diag/src/klog/Android.mk b/feeds/wifi-ax/qca-diag/src/klog/Android.mk new file mode 100755 index 000000000..3a2c67aa7 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/klog/Android.mk @@ -0,0 +1,28 @@ +################################################################################ +# @file pkgs/stringl/Android.mk +# @brief Makefile for building the string library on Android. +################################################################################ + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +libdiag_includes:= \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../src \ + +LOCAL_C_INCLUDES:= $(libdiag_includes) +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc + +LOCAL_SRC_FILES:= \ + diag_klog.c \ + +commonSharedLibraries :=libdiag \ + +LOCAL_MODULE:= diag_klog +LOCAL_MODULE_TAGS := optional debug +LOCAL_SHARED_LIBRARIES := $(commonSharedLibraries) + +LOCAL_MODULE_OWNER := qcom +include $(BUILD_EXECUTABLE) + diff --git a/feeds/wifi-ax/qca-diag/src/klog/Makefile.am b/feeds/wifi-ax/qca-diag/src/klog/Makefile.am new file mode 100755 index 000000000..8f46be551 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/klog/Makefile.am @@ -0,0 +1,23 @@ + +AM_CFLAGS = -Wall \ + -Wundef \ + -Wstrict-prototypes \ + -Wno-trigraphs \ + -Werror + +AM_CPPFLAGS = -D__packed__= \ + -DIMAGE_APPS_PROC \ + -DFEATURE_Q_SINGLE_LINK \ + -DFEATURE_Q_NO_SELF_QPTR \ + -DFEATURE_LINUX \ + -DFEATURE_NATIVELINUX \ + -DFEATURE_DSM_DUP_ITEMS \ + -DFEATURE_LE_DIAG \ + -I../src \ + -I../include + +bin_PROGRAMS = diag_klog + +diag_klog_SOURCES = diag_klog.c +diag_klog_LDFLAGS = -lpthread +diag_klog_LDADD = ../src/libdiag.la diff --git a/feeds/wifi-ax/qca-diag/src/klog/diag_klog.c b/feeds/wifi-ax/qca-diag/src/klog/diag_klog.c new file mode 100755 index 000000000..5bde43161 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/klog/diag_klog.c @@ -0,0 +1,178 @@ +// Copyright (c) 2007-2012 by Qualcomm Technologies, Inc. All Rights Reserved. +//Qualcomm Technologies Proprietary and Confidential. + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Test Application for Diag Interface + +GENERAL DESCRIPTION + Contains main implementation of Diagnostic Services Test Application. + +EXTERNALIZED FUNCTIONS + None + +INITIALIZATION AND SEQUENCING REQUIREMENTS + + +Copyright (c) 2007-2012 Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Created +===========================================================================*/ + +#include "event.h" +#include "msg.h" +#include "log.h" +#include "diag_lsm.h" +#include "stdio.h" +#include "string.h" +#include "malloc.h" +#include +#include +#include + +#define NUM_BYTES 100 +/* Global Data */ +char buffer_temp[1000]; +int buffer_temp_end = 0; +char prev_delimiter = '6'; + +/* static data */ +pthread_t fd_testapp_thread_hdl; /* Diag task thread handle */ + +/*=============================================================================*/ +/* Local Function declarations */ +/*=============================================================================*/ +void print_string(void); +void scan_buffer(char *buffer,int start); +typedef boolean (*ptr_Diag_LSM_Init)(byte* pIEnv); +typedef boolean (*ptr_Diag_LSM_DeInit)(void); +/*=============================================================================*/ + +/* Main Function. This initializes Diag_LSM, calls the tested APIs and exits. */ +int main(void) +{ + boolean bInit_Success = FALSE; + char *buffer; + int count_bytes; + + buffer = (char*)malloc(sizeof(char) * NUM_BYTES); + if (!buffer) { + printf("TestApp_MultiThread: Could not allocate memory\n"); + return -1; + } + + bInit_Success = Diag_LSM_Init(NULL); + + if(!bInit_Success) + { + printf("TestApp_MultiThread: Diag_LSM_Init() failed."); + free(buffer); + return -1; + } + printf("TestApp_MultiThread: Diag_LSM_Init succeeded.\n"); + + do + { + memset(buffer, 0, sizeof(char) * NUM_BYTES); + count_bytes = klogctl(2, buffer, NUM_BYTES); + scan_buffer(buffer, 0); + if(count_bytes < NUM_BYTES) + print_string(); + } while(1); + + /* Now find the DeInit function and call it. Clean up before exiting */ + Diag_LSM_DeInit(); + + free(buffer); + + return 0; +} + +void scan_buffer(char *buffer, int start) +{ + int i,j; + int found = 0; + + for(i=start;i= 49 || buffer[i+1] <= 56) && buffer[i+2] == '>') + { + found = 1; + for(j=start;j +#include +#include +#include +#include +#include +#include +#include +#include +#include "errno.h" +#ifndef FEATURE_LE_DIAG +#include +#endif + +/* + * strlcpy is from OpenBSD and not supported by Meego. + * GNU has an equivalent g_strlcpy implementation into glib. + * Featurized with compile time USE_GLIB flag for Meego builds. + */ +#ifdef USE_GLIB +#define strlcpy g_strlcpy +#define strlcat g_strlcat +#endif + +#ifdef FEATURE_LE_DIAG +#define LE_UID_DIAG 53 +#define LE_GID_DIAG 53 +#define LE_GID_SDCARD 1015 +#define LE_GID_INET_RAW 3004 +#endif + +#define DIAG_MDLOG_WAKELOCK_NAME "diag_mdlog_wakelock" +#define DIAG_MDLOG_PROCESS_NAME "diag_mdlog" + +#define std_strlprintf snprintf +/* static data */ +static int dir_set = 0; +static int kill_mdlog = 0; +static int dir_access = 0; +static char mask_file_list[FILE_NAME_LEN] = "/tmp/diag_logs/Diag_list.txt"; +static char default_mask_file[NUM_PROC][36] = { + "/tmp/diag_logs/Diag.cfg", + "/tmp/diag_logs/mdm/Diag.cfg", + "/tmp/diag_logs/mdm2/Diag.cfg", + "/tmp/diag_logs/mdm3/Diag.cfg", + "/tmp/diag_logs/mdm4/Diag.cfg", + "/tmp/diag_logs/qsc/Diag.cfg", + "/tmp/diag_logs/Diag.cfg", + "/tmp/diag_logs/Diag.cfg", + "/tmp/diag_logs/Diag.cfg", + "/tmp/diag_logs/Diag.cfg" }; +static int mask_file_entered = 0; +static int mask_file_mdm_entered = 0; +static int mask_file_list_entered = 0; +static int enable_wakelock = 0; +static int enable_nonrealtime = 0; +static int disable_hdlc = 0; +static unsigned int peripheral_mask = 0; + +extern unsigned long max_file_size; +extern unsigned long min_file_size; +extern int cleanup_mask; +extern int proc_type; +extern unsigned int max_file_num; +extern int rename_file_names; +extern int rename_dir_name; +extern char pid_file[DIAG_MDLOG_PID_FILE_SZ]; + +/*=============================================================================*/ +/* Function declarations */ +/*=============================================================================*/ + +extern void flush_buffer(int); + +/*=============================================================================*/ + +static void usage(char *progname) +{ + printf("\n Usage for %s:\n", progname); + printf("\n-f, --filemsm:\t mask file name for MSM\n"); + printf("\n-m, --filemdm:\t mask file name for MDM\n"); + printf("\n-l, --filelist:\t name of file containing list of mask files\n"); + printf("\n-o, --output:\t output directory name\n"); + printf("\n-p, --peripheral:\t bit mask for the peripherals interested\n"); + printf("\n-s, --size:\t maximum file size in MB\n"); + printf("\n-w, --wait:\t waiting for directory\n"); + printf("\n-n, --number:\t maximum file number\n"); + printf("\n-k, --kill:\t kill existing instance of diag_mdlog\n"); + printf("\n-c --cleanmask:\t Send mask cleanup to modem at exit\n"); + printf("\n-d --disablecon:\t Disable console messages\n"); + printf("\n-e --enablelock:\t Run using wake lock to keep APPS processor on\n"); + printf("\n-b --nonrealtime:\t Have peripherals buffer data and send data in non-real-time\n"); + printf("\n-r --renamefiles:\t Rename dir/file names to time when closed\n"); + printf("\n-a --hdlcdisable:\t Disbale hdlc encoding\n"); + printf("\n-h, --help:\t usage help\n"); + printf("\ne.g. diag_mdlog -f -o " + " -s -c\n"); + exit(0); +} + +static void parse_args(int argc, char **argv) +{ + int command, z; + int file_num = 0; + struct option longopts[] = + { + { "filemsm", 1, NULL, 'f'}, + { "filemdm", 1, NULL, 'm'}, + { "filelist", 1, NULL, 'l'}, + { "output", 1, NULL, 'o'}, + { "size", 1, NULL, 's'}, + { "peripheral", 1, NULL, 'p'}, + { "wait", 1, NULL, 'w'}, + { "number", 1, NULL, 'n'}, + { "kill", 0, NULL, 'k'}, + { "cleanmask", 0, NULL, 'c'}, + { "disablecon", 0, NULL, 'd'}, + { "enablelock", 0, NULL, 'e'}, + { "nonrealtime",0, NULL, 'b'}, + { "renamefiles",0, NULL, 'r'}, + { "disablehdlc",0, NULL, 'a'}, + { "help", 0, NULL, 'h'}, + }; + + while ((command = getopt_long(argc, argv, "f:m:l:o:p:s:w:n:cdkebrah", longopts, NULL)) + != -1) { + switch (command) { + case 'f': + strlcpy(mask_file, optarg, FILE_NAME_LEN); + mask_file_entered = 1; + break; + case 'm': + strlcpy(mask_file_mdm, optarg, FILE_NAME_LEN); + mask_file_mdm_entered = 1; + break; + case 'l': + strlcpy(mask_file_list, optarg, FILE_NAME_LEN); + mask_file_list_entered = 1; + break; + case 'o': + for (z = 0; z < NUM_PROC; z++) + strlcpy(output_dir[z], optarg, + FILE_NAME_LEN - 6); + dir_set = 1; + break; + case 'p': + peripheral_mask = to_integer(optarg); + if (peripheral_mask < DIAG_CON_NONE || + peripheral_mask > DIAG_CON_ALL) { + DIAG_LOGE("diag: Unsupported peripheral mask: %d. Exiting...\n", peripheral_mask); + peripheral_mask = 0; + exit(0); + } + break; + case 's': + max_file_size = atol(optarg); + if ((long)max_file_size <= 0) + max_file_size = 100000000; + else { + max_file_size *= 1024 * 1024; + if (max_file_size >= 0 && max_file_size < 1024 * 1024) + max_file_size = 100000000; + } + min_file_size = ((max_file_size / 100) * 80); + break; + case 'w': + strlcpy(dir_name, optarg, FILE_NAME_LEN); + dir_access = 1; + break; + case 'n': + file_num = atoi(optarg); + if(file_num <= 1) { + DIAG_LOGE("\n diag_mdlog: Invalid file number, must be greater than 1\n"); + exit(0); + } + max_file_num = file_num; + break; + case 'k': + kill_mdlog = 1; + break; + case 'c': + cleanup_mask = 1; + break; + case 'd': + diag_disable_console = 1; + break; + case 'e': + enable_wakelock = 1; + break; + case 'b': + enable_nonrealtime = 1; + break; + case 'r': + rename_file_names = 1; + rename_dir_name = 1; + break; + case 'a': + disable_hdlc = 1; + break; + case 'h': + default: + usage(argv[0]); + }; + } +} + +void notify_handler(int signal, siginfo_t *info, void *unused) +{ + (void)unused; + + if (info) { + + DIAG_LOGE("diag: In %s, signal %d received from kernel, data is: %x\n", + __func__, signal, info->si_int); + + if (info->si_int & DIAG_STATUS_OPEN) { + if (info->si_int & DIAG_CON_MPSS) { + DIAG_LOGE("diag: DIAG_STATUS_OPEN on DIAG_CON_MPSS\n"); + diag_notify_parser_thread(DIAG_MSM_MASK, DIAG_CON_MPSS); + } else if (info->si_int & DIAG_CON_LPASS) { + DIAG_LOGE("diag: DIAG_STATUS_OPEN on DIAG_CON_LPASS\n"); + diag_notify_parser_thread(DIAG_MSM_MASK, DIAG_CON_LPASS); + } else if (info->si_int & DIAG_CON_WCNSS) { + DIAG_LOGE("diag: DIAG_STATUS_OPEN on DIAG_CON_WCNSS\n"); + diag_notify_parser_thread(DIAG_MSM_MASK, DIAG_CON_WCNSS); + } else if (info->si_int & DIAG_CON_SENSORS) { + DIAG_LOGE("diag: DIAG_STATUS_OPEN on DIAG_CON_SENSORS\n"); + diag_notify_parser_thread(DIAG_MSM_MASK, DIAG_CON_SENSORS); + } else { + DIAG_LOGE("diag: DIAG_STATUS_OPEN on unknown peripheral\n"); + } + } else if (info->si_int & DIAG_STATUS_CLOSED) { + if (info->si_int & DIAG_CON_MPSS) { + DIAG_LOGE("diag: DIAG_STATUS_CLOSED on DIAG_CON_MPSS\n"); + } else if (info->si_int & DIAG_CON_LPASS) { + DIAG_LOGE("diag: DIAG_STATUS_CLOSED on DIAG_CON_LPASS\n"); + } else if (info->si_int & DIAG_CON_WCNSS) { + DIAG_LOGE("diag: DIAG_STATUS_CLOSED on DIAG_CON_WCNSS\n"); + } else if (info->si_int & DIAG_CON_SENSORS) { + DIAG_LOGE("diag: DIAG_STATUS_CLOSED on DIAG_CON_SENSORS\n"); + } else { + DIAG_LOGE("diag: DIAG_STATUS_CLOSED on unknown peripheral\n"); + } + } + + } else { + DIAG_LOGE("diag: In %s, signal %d received from kernel, but no info value, info: 0x%p\n", + __func__, signal, info); + } + return; +} + +/* stop_mdlog is called when another instance of diag_mdlog is to be killed off */ +static void stop_mdlog(void) +{ + int fd; + int ret; + pid_t pid; + char pid_buff[10]; + + /* Determine the process id of the instance of diag_mdlog */ + fd = open(pid_file, O_RDONLY); + if (fd < 0) { + DIAG_LOGE("\n diag_mdlog: Unable to open pid file, errno: %d\n", errno); + return; + } + + ret = read(fd, pid_buff, 10); + if (ret < 0) { + DIAG_LOGE("\n diag_mdlog: Unable to read pid file, errno: %d\n", errno); + close(fd); + return; + } + + close(fd); + + /* Make sure the buffer is properly terminated */ + if (ret == sizeof(pid_buff)) + ret--; + pid_buff[ret] = '\0'; + + pid = atoi(pid_buff); + + if (pid == 0 || (kill(pid, SIGTERM)) < 0) { + DIAG_LOGE("\ndiag_mdlog: Unable to kill diag_mdlog instance pid: %d, errno: %d\n", pid, errno); + } else { + DIAG_LOGE("\ndiag_mdlog: stopping diag_mdlog instance pid: %d\n", pid); + } + + return; +} + +#ifndef FEATURE_LE_DIAG +static void adjust_permissions() +{ + int status; + int size; + +#ifdef AID_QCOM_DIAG + gid_t diag_groups[] = {AID_QCOM_DIAG, AID_SDCARD_R, AID_MEDIA_RW, AID_SDCARD_RW, AID_NET_RAW }; +#else + gid_t diag_groups[] = {AID_DIAG, AID_SDCARD_R, AID_MEDIA_RW, AID_SDCARD_RW, AID_NET_RAW }; +#endif + size = sizeof(diag_groups)/sizeof(gid_t); + + uid_t e_uid; + + /* Determine the effective user id */ + e_uid = geteuid(); + + /* + * If this app is running as root, we need to drop the permissions. + * We can only drop permissions if this app is running as root. If + * the app is not running as root, then the app will need to be + * running with the appropriate permissions to support logging to + * the SD card. + */ + if (e_uid != 0) + return; + + /* SD card access needs sdcard_rw group membership */ + status = setgid(AID_SHELL); + if (status < 0) { + DIAG_LOGE("diag_mdlog: Error setting group id, errno: %d, Exiting ...\n", errno); + goto fail_permissions; + } + + /* Add qcom_diag and sdcard_r as supplemental groups so we can access /dev/diag */ + /* and /storage. Add AID_MEDIA_RW so we can write to the external SD card */ + status = setgroups(size, diag_groups); + if (status == -1) { + DIAG_LOGE("diag_mdlog: setgroups error, errno: %d, Exiting ...\n", errno); + goto fail_permissions; + } + + /* Ideally we would like a dedicated UID for diag_mdlog, for now use sdcard_rw */ + /* Drop privileges to sdcard_rw since system user does not have access */ + status = setuid(AID_SHELL); + if (status < 0) { + DIAG_LOGE("diag_mdlog: Error setting user id, errno: %d, Exiting ...\n", errno); + goto fail_permissions; + } + return; + +fail_permissions: + if (diag_is_wakelock_init()) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + exit(0); +} +#else +static void adjust_permissions() +{ + int status; + uid_t uid; + gid_t supplemental_gid[] = {LE_GID_SDCARD, LE_GID_INET_RAW}; + int size = sizeof(supplemental_gid)/sizeof(gid_t); + + /* Determine the real user id */ + uid = getuid(); + + /* + * If this app is running as root, we need to drop the permissions + * We can only drop permissions if this app is running as root, + * since this app is not a setuid app on LE. + */ + if (uid == 0) { + /* Set the real group ID to the diag group */ + status = setgid(LE_GID_DIAG); + if (status < 0) { + printf("diag_mdlog: Error setting group id, errno: %d, Exiting ...\n", errno); + goto fail_permissions; + } + + /* Set 1 supplemental group, the sdcard group so it can access the SD card */ + status = setgroups(size, (gid_t *)&supplemental_gid); + if (status == -1) { + printf("diag_mdlog: setgroups error, errno: %d, Exiting ...\n", errno); + goto fail_permissions; + } + + /* Set the real user id to the diag user */ + status = setuid(LE_UID_DIAG); + if (status < 0) { + printf("diag_mdlog: Error setting user id, errno: %d, Exiting ...\n", errno); + goto fail_permissions; + } + } + return; + +fail_permissions: + if (diag_is_wakelock_init()) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + exit(0); +} +#endif + +int read_mask_file_default(int proc_index) +{ + int status = 0; + if (proc_index < 0 || proc_index >=NUM_PROC) { + status = -ENODEV; + return status; + } + + proc_type = proc_index; + DIAG_LOGE("diag_mdlog: Default mask file being read for proc_type: %d\n", + proc_type); + if (proc_type == 0) + strlcpy(mask_file, default_mask_file[proc_type], FILE_NAME_LEN); + else + strlcpy(mask_file_mdm, default_mask_file[proc_type], FILE_NAME_LEN); + + status = diag_read_mask_file(); + + return status; +} + +static void diag_mdlog_get_pid_file(void) +{ + int i; + + if (peripheral_mask == 0) { + strlcpy(pid_file, DIAG_MDLOG_PID_FILE, DIAG_MDLOG_PID_FILE_SZ); + } else { + strlcpy(pid_file, "/tmp/diag_logs/diag_mdlog", DIAG_MDLOG_PID_FILE_SZ); + diag_get_peripheral_name_from_mask(pid_file, + DIAG_MDLOG_PID_FILE_SZ, + peripheral_mask); + strlcat(pid_file, "_pid", DIAG_MDLOG_PID_FILE_SZ); + } +} + +/* + * This function checks if another instance of diag_mdlog already exists in the + * system. This is done by checking the pid file. If there are any errors in + * opening the pid file, the new instance of diag_mdlog exits. + * + * It retuns the errno on error, 0 if everything is successful; + */ +static int diag_mdlog_pid_init() +{ + int fd; + int pid; + int ret; + int proc_fd; + const int pid_len = 10; + const int proc_len = 30; + char pid_buff[pid_len]; + char process_name[proc_len]; + struct stat pid_stat; + + /* Determine the process id of the instance of diag_mdlog */ + fd = open(pid_file, O_RDONLY); + if (fd < 0) { + if (errno == ENOENT) { + /* The pid file doesn't exist. Create a new file. */ + goto create; + } + DIAG_LOGE("diag_mdlog: Unable to open pid file, err: %d\n", errno); + return errno; + } + + ret = read(fd, pid_buff, pid_len); + if (ret < 0) { + DIAG_LOGE("diag_mdlog: Unable to read pid file, err: %d\n", errno); + close(fd); + return errno; + } + close(fd); + + /* Make sure the buffer is properly terminated */ + if (ret == pid_len) + ret--; + pid_buff[ret] = '\0'; + + pid = atoi(pid_buff); + + snprintf(process_name, sizeof(process_name), "/proc/%d/cmdline", pid); + proc_fd = open(process_name, O_RDONLY); + if (proc_fd < 0) { + /* + * The process is no longer active in the system. This is + * actually a no error case and diag_mdlog should continue. + * Replace the contents of the pid file with the new pid. + */ + goto create; + } + + ret = read(proc_fd, process_name, proc_len); + if (ret < 0) { + DIAG_LOGE("diag_mdlog: Unable to read process file, err: %d\n", errno); + close(proc_fd); + return errno; + } + close(proc_fd); + + /* Make sure the buffer is properly terminated */ + if (ret == proc_len) + ret--; + process_name[ret] = '\0'; + + /* + * Check if the process is actually a mdlog process. If not, this is not + * the same process that we started and is not an error. Go ahead and + * store the new pid in the file. + */ + if (!strstr(process_name, DIAG_MDLOG_PROCESS_NAME)) + goto create; + + if (pid > 0) { + DIAG_LOGE("diag_mdlog: another instance of diag_mdlog already exitsts, pid: %d\n", pid); + return pid; + } + +create: + /* + * Make sure the default directory exists so the diag_pid file + * can be created. + */ + if (mkdir(DIAG_MDLOG_DIR, 0770)) { + if (errno != EEXIST) { + DIAG_LOGE("diag_mdlog: Failed to create directory for diag pid file, err: %d\n", errno); + return errno; + } + } + + /* Check if the PID file is present. Delete the file if present */ + if (stat(pid_file, &pid_stat) == 0) + unlink(pid_file); + + pid = getpid(); + fd = open(pid_file, O_RDWR | O_CREAT | O_EXCL | O_SYNC, 0770); + if (fd < 0) { + DIAG_LOGE("diag_mdlog: Unable to create pid file, err: %d\n", errno); + return errno; + } + + snprintf(pid_buff, pid_len, "%d", pid); + write(fd, pid_buff, pid_len); + close(fd); + DIAG_LOGE("diag_mdlog: successfully created pid file, pid: %d\n", pid); + return 0; +} + +/* Main Function. This initializes Diag_LSM, sets up On Device Logging, then exits. */ +int main(int argc, char *argv[]) +{ + boolean bInit_Success = FALSE; + int choice, input_scan = 1, i, result, pid, z; + char buffer[30]; + char temp_xml_buf[GUID_LIST_END_XML_TAG_SIZE]; + struct timeval tv; + time_t curtime; + struct tm *tm_ptr = NULL; + struct itimerval value, ovalue, pvalue; + struct sigaction sact; + uint16 remote_mask = 0; + struct stat dir_stat; + int stat_count = 0; + int status; + int num_mask_reads_succeeded = 0; + int ret = 0; + int index = 0; + int bytes_written = 0; + struct diag_logging_mode_param_t params; + + parse_args(argc, argv); + diag_mdlog_get_pid_file(); + /* If another instance of diag_mdlog is to be killed off */ + if (kill_mdlog) { + stop_mdlog(); + exit(0); + } + + /* Acquire wakelock if the client is requesting for wakelock*/ + if (enable_wakelock) { + diag_wakelock_init(DIAG_MDLOG_WAKELOCK_NAME); + diag_wakelock_acquire(); + } + + if (diag_mdlog_pid_init()) + goto exit; + + /* Waiting for directory access */ + if (dir_access) { + errno = 0; + stat(dir_name, &dir_stat); + while(errno != 0) { + DIAG_LOGE("diag_mdlog: Directory %s is not accessible with errno %d\n", + dir_name, errno); + sleep(5); + stat(dir_name, &dir_stat); + stat_count++; + if(stat_count == 24) { + DIAG_LOGE("diag_mdlog: Directory %s is not accessible for %d seconds so exiting...\n", + dir_name, stat_count*5); + dir_access = 0; + goto fail; + } + } + if(errno == 0) { + DIAG_LOGE("diag_mdlog: Directory %s is accessible\n", + dir_name); + } + dir_access = 0; + } + + /* Setup the directory that we will be logging to */ + if (dir_set) { + if (rename_dir_name) { + /* Two somewhat conflicting command line parameters + * have been entered. + * 1. The name of the directory where the logging + * files should be placed. + * 2. The renaming of the logging file when closed + * and renaming of the logging directory when + * on-device logging is halted. + * In this case, do not rename the logging directory. + * But still allow for renaming of logging files on close. + */ + rename_dir_name = 0; + } + status = mkdir(output_dir[MSM], 0770); + if (status == -1) { + if (errno == EEXIST) { + DIAG_LOGE("diag_mdlog: Warning output directory already exists: %s\n", + output_dir[MSM]); + DIAG_LOGE("diag_mdlog: Proceeding...\n"); + } else { + DIAG_LOGE("diag_mdlog: Error creating: %s, errno: %d\n", + output_dir[MSM], errno); + DIAG_LOGE("diag_mdlog: Attempting to use default directory\n"); + dir_set = 0; + } + } else { + DIAG_LOGE("diag_mdlog: Created logging directory %s\n", + output_dir[MSM]); + } + if (!disable_hdlc) { + (void)std_strlprintf(qsr4_xml_file_name, + FILE_NAME_LEN, "%s%s", + output_dir[MSM],"/diag_qsr4_guid_list.xml"); + fd_qsr4_xml[MSM] = open(qsr4_xml_file_name, O_CREAT | O_RDWR | O_SYNC | O_TRUNC, 0644); + if(fd_qsr4_xml[MSM] < 0) + DIAG_LOGE("diag:In %s failed to create xml file \n", __func__); + ret = std_strlprintf(temp_xml_buf, GUID_LIST_XML_TAG_SIZE, "%s\n", ""); + if((fd_qsr4_xml[MSM] >= 0) && (ret > 0)){ + bytes_written = write(fd_qsr4_xml[MSM], temp_xml_buf, ret); + if (bytes_written != ret) + DIAG_LOGE("diag: In %s failed to write to xml file with error %d", __func__, errno); + } + } + } + + if (!dir_set) { + gettimeofday(&tv, NULL); + curtime=tv.tv_sec; + tm_ptr = localtime(&curtime); + if (tm_ptr) + strftime(buffer, 30, "%Y%m%d_%H%M%S", tm_ptr); + else + strlcpy(buffer, "00000000_000000", 30); + mkdir(DIAG_MDLOG_DIR, 0770); + for (z = 0; z < NUM_PROC; z++) { + strlcpy(output_dir[z], DIAG_MDLOG_DIR, FILE_NAME_LEN); + (void)strlcat(output_dir[z], buffer, FILE_NAME_LEN); + } + + DIAG_LOGE("\ndiag_mdlog: Continuing with default directory path %s\n", + output_dir[MSM]); + if (mkdir(output_dir[MSM], 0770)) { + DIAG_LOGE("diag_mdlog: Unable to create directory, errno: %d Exiting....\n", errno); + goto fail; + } + if (!disable_hdlc) { + (void)std_strlprintf(qsr4_xml_file_name, + FILE_NAME_LEN, "%s%s", + output_dir[MSM],"/diag_qsr4_guid_list.xml"); + fd_qsr4_xml[MSM] = open(qsr4_xml_file_name, O_CREAT | O_RDWR | O_SYNC | O_TRUNC, 0644); + if(fd_qsr4_xml[MSM] < 0) + DIAG_LOGE("diag:In %s failed to create xml file \n", __func__); + ret = std_strlprintf(temp_xml_buf, GUID_LIST_XML_TAG_SIZE, "%s\n", ""); + if((fd_qsr4_xml[MSM] >= 0) && (ret > 0)){ + bytes_written = write(fd_qsr4_xml[MSM], temp_xml_buf, ret); + if (bytes_written != ret) + DIAG_LOGE("diag: In %s failed to write to xml file with error, errno: %d\n", __func__, errno); + } + } + } + + + /* + * Since On Device Logging optimizations have implemented + * a buffering scheme, set things up so that on receipt of + * specified signals the flush_buffer signal handler function + * will be call so that the data in the buffers can be flushed + * to the SD card before the app exits. + */ + sigemptyset( &sact.sa_mask ); + sact.sa_flags = 0; + sact.sa_handler = flush_buffer; + sigaction(SIGTERM, &sact, NULL); + sigaction(SIGHUP, &sact, NULL); + sigaction(SIGUSR1, &sact, NULL); + sigaction(SIGINT, &sact, NULL); + + struct sigaction notify_action; + sigemptyset(¬ify_action.sa_mask); + notify_action.sa_sigaction = notify_handler; + /* Use SA_SIGINFO to denote we are expecting data with the signal */ + notify_action.sa_flags = SA_SIGINFO; + sigaction(SIGCONT, ¬ify_action, NULL); + + /* Initialize the Diag LSM userspace library */ + bInit_Success = Diag_LSM_Init(NULL); + if (!bInit_Success) { + DIAG_LOGE("\ndiag_mdlog: Diag_LSM_Init() failed. Exiting...\n"); + goto fail; + } + + DIAG_LOGE("\ndiag_mdlog: Diag_LSM_Init succeeded.\n"); + + /* Get the mask for remote processor */ + diag_has_remote_device(&remote_mask); + DIAG_LOGE("\n REMOTE PROCESSOR MASK %x \n", remote_mask); + + if (enable_nonrealtime) { + status = diag_vote_md_real_time(MODE_NONREALTIME); + if (status == -1) { + DIAG_LOGE("diag_mdlog: unable to set mode to non real time mode\n"); + } + } + + /* Switch logging modes to turn on On Device Logging */ + params.req_mode = MEMORY_DEVICE_MODE; + params.mode_param = DIAG_MD_PERIPHERAL; + params.diag_id = 0; + params.pd_val = 0; + params.peripheral = -EINVAL; + params.pd_mask = 0; + + if (peripheral_mask != 0) { + params.peripheral_mask = peripheral_mask; + params.mode_param = DIAG_MD_PERIPHERAL; + } else { + params.peripheral_mask = DIAG_CON_ALL; + params.mode_param = DIAG_MD_PERIPHERAL; + } + + if (peripheral_mask) + diag_set_peripheral_mask(peripheral_mask); + + params.device_mask = DIAG_MSM_MASK | DIAG_MDM_MASK | DIAG_MDM2_MASK; + status = diag_switch_logging_proc(¶ms); + if (status) + goto fail_deinit; + + if (disable_hdlc) { + status = diag_hdlc_toggle(HDLC_DISABLE); + if (status == 1) { + DIAG_LOGE("diag_mdlog: HDLC successfully disabled\n"); + } else { + DIAG_LOGE("diag_mdlog: Unable to switch the HDLC, exiting app\n"); + goto fail_deinit; + } + } + + /* Read mask file to tell On Device Logging what you are interested in */ + if (mask_file_list_entered) { + status = diag_read_mask_file_list(mask_file_list); + if (!status) { + DIAG_LOGE("diag_mdlog: Error reading mask file list. Exiting ...\n"); + } + } else { + DIAG_LOGE("\ndiag_mdlog: Reading mask for MSM, proc_type: %d\n", proc_type); + proc_type = MSM; + if (mask_file_entered) + status = diag_read_mask_file(); + else + status = read_mask_file_default(proc_type); + + if (status) { + DIAG_LOGE("diag_mdlog: Error reading mask file, proc_type: %d, file: %s\n", + proc_type, mask_file); + } else { + num_mask_reads_succeeded++; + } + + z = 1; + while(remote_mask) { + if(remote_mask & 1 ) { + proc_type = z; + DIAG_LOGE("\ndiag_mdlog: Reading mask for proc_type: %d\n", + proc_type); + if (proc_type == 1 && mask_file_mdm_entered) + status = diag_read_mask_file(); + else + status = read_mask_file_default(proc_type); + + if (status) { + DIAG_LOGE("diag_mdlog: Error reading mask file, proc_type: %d, file: %s\n", + proc_type, mask_file_mdm); + } else { + num_mask_reads_succeeded++; + } + } + z++; + remote_mask = remote_mask >> 1; + } + + /* + * If no mask files have been successfully read, + * try reading from a mask list file + */ + if (num_mask_reads_succeeded == 0) { + DIAG_LOGE("\ndiag_mdlog: No successful mask file reads. Trying default mask list file.\n"); + status = diag_read_mask_file_list(mask_file_list); + if (!status) { + DIAG_LOGE("diag_mdlog: No mask files have been successfully read.\n"); + DIAG_LOGE("diag_mdlog: Running with masks that were set prior to diag_mdlog start-up.\n"); + } + } + status = 1; + } + + if (status) { + /* Reset proc type */ + proc_type = MSM; + while(1) { + /* Allow the main thread to sleep while logging is going on. */ + sleep(3600); + } + } + +fail_deinit: + /* De-Initialize the Diag LSM userspace library */ + Diag_LSM_DeInit(); + +fail: + unlink(pid_file); +exit: + /* Release and destroy wakelock if enabled */ + if (enable_wakelock) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + return 0; +} diff --git a/feeds/wifi-ax/qca-diag/src/qdss_setup.sh b/feeds/wifi-ax/qca-diag/src/qdss_setup.sh new file mode 100755 index 000000000..c81689aba --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/qdss_setup.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# Copyright (c) 2019 Qualcomm Technologies, Inc. +# +# All Rights Reserved. +# Confidential and Proprietary - Qualcomm Technologies, Inc. +# +if [ $# -ne 1 ] +then + echo "usage $0 {install | uninstall}" + exit 1 +fi +if [ $1 == "uninstall" ] +then + echo "uninstalling" + + fw_setenv usb_mode + sed -i '/sh \/diag.sh/d' /etc/rc.local + rm -f /diag.sh + + exit 0 +elif [ $1 == "install" ] +then + echo "installing" + + fw_printenv | grep "usb_mode=peripheral" + if [ $? -ne 0 ] + then + fw_setenv usb_mode "peripheral" + fi + + sed -i '/sh \/diag.sh/d' /etc/rc.local + sed -i '$ish /diag.sh' /etc/rc.local + + if [ -f /diag.sh ] + then + echo "Already installed returning" + exit 1 + fi + echo "mkdir -p /config" >> /diag.sh + echo "mount -t configfs none /config" >> /diag.sh + echo "mkdir -p /config/usb_gadget/g1" >> /diag.sh + echo "echo 0x05c6 > /config/usb_gadget/g1/idVendor" >> /diag.sh + echo "echo 0x9060 > /config/usb_gadget/g1/idProduct" >> /diag.sh + echo "mkdir -p /config/usb_gadget/g1/strings/0x409" >> /diag.sh + echo "echo 12345678 > /config/usb_gadget/g1/strings/0x409/serialnumber" >> /diag.sh + echo "echo Dummy > /config/usb_gadget/g1/strings/0x409/manufacturer" >> /diag.sh + echo "echo Demo > /config/usb_gadget/g1/strings/0x409/product" >> /diag.sh + echo "mkdir -p /config/usb_gadget/g1/configs/c.1" >> /diag.sh + echo "mkdir -p /config/usb_gadget/g1/configs/c.1/strings/0x409" >> /diag.sh + echo "echo "Conf 1" > /config/usb_gadget/g1/configs/c.1/strings/0x409/configuration" >> /diag.sh + echo "echo 120 > /config/usb_gadget/g1/configs/c.1/MaxPower" >> /diag.sh + echo "mkdir -p /config/usb_gadget/g1/functions/diag.diag" >> /diag.sh + echo "ln -s /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/c.1/diag.diag" >> /diag.sh + echo "mkdir -p /config/usb_gadget/g1/functions/qdss.qdss" >> /diag.sh + echo "ln -s /config/usb_gadget/g1/functions/qdss.qdss /config/usb_gadget/g1/configs/c.1/qdss.qdss" >> /diag.sh + echo "mkdir -p /config/usb_gadget/g1/functions/qdss.qdss2" >> /diag.sh + echo "ln -s /config/usb_gadget/g1/functions/qdss.qdss2 /config/usb_gadget/g1/configs/c.1/qdss.qdss2" >> /diag.sh + echo "echo "8a00000.dwc3" > /config/usb_gadget/g1/UDC" >> /diag.sh + echo "/usr/sbin/registerReboot &" >> /diag.sh + + exit 0 +else + echo "usage $0 {install | uninstall}" + exit 1 +fi diff --git a/feeds/wifi-ax/qca-diag/src/qld_server.c b/feeds/wifi-ax/qca-diag/src/qld_server.c new file mode 100755 index 000000000..7a84a0ea1 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/qld_server.c @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2020 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PORT 5002 +#define DIAG_PORT 5003 + +#define BIT(n) (1 << n) + +#define PING BIT(0) +#define PONG BIT(1) + +char filename[200]; +char client_message[2000]; +char diag_buffer[1024]; +socklen_t addrlen; +int rbytes = 0; +int diag_rbytes = 0; +int new_diag_socket, new_qld_socket; +int udpfd; +int bytes = 1024; + +struct sockaddr_in qld_serverAddr; +struct sockaddr_in qld_udpAddr; +struct sockaddr_in qld_servAddr; +struct sockaddr qld_ackAddr; +socklen_t acklen; +struct sockaddr_in diag_serverAddr; +struct sockaddr_in udpaddr; +int stop_data_thread = 0; +int start_data_streaming = 0; + +void * control_thread(void *arg) +{ + int start_req_flag = 0; + int start_accept_flag = 0; + int stop_req_flag = 0; + int stop_accept_flag = 0; + char start_command[] = {0x7E, 0x01, 0x05, 0x00, 0x4b, + 0x5a, 0x03, 0x01, 0x01, 0x7E}; + char stop_command[] = {0x7E, 0x01, 0x05, 0x00, 0x4b, + 0x5a, 0x03, 0x01, 0x00, 0x7E}; + int i; + + /* the diag start pattern is + * 0x7E 0x01 0x05 0x00 0x4b 0x5a 0x03 0x01 0x01 0x7E */ + /* the diag stop pattern is + * 0x7E 0x01 0x05 0x00 0x4b 0x5a 0x03 0x01 0x00 0x7E */ + do { + start_req_flag = 0; + rbytes = recv(new_qld_socket, client_message, + sizeof(client_message), 0); + + if (!(memcmp(start_command, client_message, sizeof(start_command)))) { + printf("Received a start command\n"); + start_req_flag = 1; + } + if (!(memcmp(stop_command, client_message, sizeof(stop_command)))) { + printf("Received a stop command\n"); + stop_req_flag = 1; + } + + send(new_diag_socket, client_message, rbytes, 0); + + diag_rbytes = recv(new_diag_socket, diag_buffer, + sizeof(diag_buffer), 0); + if ((start_req_flag) && (diag_buffer[0] == 0x7E) && + (diag_buffer[4] != 0x13)) { + printf("Received response for start command\n"); + start_accept_flag = 1; + } + send(new_qld_socket, diag_buffer, diag_rbytes, 0); + if (start_req_flag && start_accept_flag) { + start_data_streaming = 1; + start_req_flag = start_accept_flag = 0; + } + if (stop_req_flag && stop_accept_flag) { + start_data_streaming = 0; + stop_req_flag = stop_accept_flag = 0; + break; + } + } while (1); + stop_data_thread = 1; + pthread_exit(NULL); +} + +int main(int argc, char *argv[]) +{ + int qld_socket, diag_socket; + int qld_port_num; + int diag_port_num; + int stream_port_num; + int yes = 1; + pthread_t control_t; + pthread_t data_t; + int sendbytes = bytes; + int flags; + + if (argc != 4) { + fprintf(stderr, "Usage %s stream_port\n", argv[0]); + exit(1); + } else { + qld_port_num = atoi(argv[1]); + diag_port_num = atoi(argv[2]); + stream_port_num = atoi(argv[3]); + } + + //Create the socket. + qld_socket = socket(PF_INET, SOCK_STREAM, 0); + // Configure settings of the server address struct + // Address family = Internet + qld_serverAddr.sin_family = AF_INET; + //Set port number, using htons function to use proper byte order + qld_serverAddr.sin_port = htons(qld_port_num); + //Set IP address to localhost + qld_serverAddr.sin_addr.s_addr = htonl(INADDR_ANY); + //Set all bits of the padding field to 0 + memset(qld_serverAddr.sin_zero, '\0', sizeof(qld_serverAddr.sin_zero)); + //Bind the address struct to the socket + if (setsockopt(qld_socket, SOL_SOCKET, SO_REUSEADDR, &yes, + sizeof(int)) == -1) { + perror("setsockopt"); + exit(1); + } + + //Create the socket. + diag_socket = socket(PF_INET, SOCK_STREAM, 0); + // Configure settings of the server address struct + // Address family = Internet + diag_serverAddr.sin_family = AF_INET; + //Set port number, using htons function to use proper byte order + diag_serverAddr.sin_port = htons(diag_port_num); + //Set IP address to localhost + diag_serverAddr.sin_addr.s_addr = htonl(INADDR_ANY); + //Set all bits of the padding field to 0 + memset(diag_serverAddr.sin_zero, '\0', sizeof(diag_serverAddr.sin_zero)); + //Bind the address struct to the socket + if (setsockopt(diag_socket, SOL_SOCKET, SO_REUSEADDR, &yes, + sizeof(int)) == -1) { + perror("setsockopt"); + exit(1); + } + + /* TODO FIXME - all error handling */ + if (bind(qld_socket, (struct sockaddr *) &qld_serverAddr, + sizeof(qld_serverAddr))) { + printf("Could not bind to qld_socket port num %d\n", qld_port_num); + exit(-1); + } + + if (bind(diag_socket, (struct sockaddr *) &diag_serverAddr, + sizeof(diag_serverAddr))) { + printf("Could not bind to diag_socket port num %d\n", diag_port_num); + exit(-1); + } + + /* First let us establish connection with diagsocketapp */ + if(listen(diag_socket,1)==0) { + printf("Listening for diagsocketapp\n"); + } else { + printf("Could not listen to diagsocketapp\n"); + exit(-1); + } + addrlen = sizeof(diag_serverAddr); + new_diag_socket = accept(diag_socket, (struct sockaddr *) + &diag_serverAddr, &addrlen); + + printf("diag connected , socket fd is %d , ip is : %s , port : %d\n", + new_diag_socket, + inet_ntoa(diag_serverAddr.sin_addr), + ntohs(diag_serverAddr.sin_port)); + + //Listen on the socket, with 40 max connection requests queued + if(listen(qld_socket, 1)==0) { + printf("Listening for QLD connection\n"); + } else { + printf("could not listen on qldsocket\n"); + exit(-1); + } + addrlen = sizeof(qld_serverAddr); + new_qld_socket = accept(qld_socket, (struct sockaddr *) + &qld_serverAddr, &addrlen); + + printf("QLD connected , socket fd is %d , ip is : %s , port : %d\n", + new_qld_socket, + inet_ntoa(qld_serverAddr.sin_addr), + ntohs(qld_serverAddr.sin_port)); + + if (pthread_create(&control_t, NULL, control_thread, NULL) != 0) { + printf("Failed to create control thread\n"); + exit(1); + } + + pthread_join(control_t, NULL); + + return 0; +} + + diff --git a/feeds/wifi-ax/qca-diag/src/registerReboot.c b/feeds/wifi-ax/qca-diag/src/registerReboot.c new file mode 100755 index 000000000..8d19d2379 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/registerReboot.c @@ -0,0 +1,1199 @@ +/* + * Copyright (c) 2012, 2017-2019 Qualcomm Technologies, Inc. + * All Rights Reserved. + * Confidential and Proprietary - Qualcomm Technologies, Inc. + * + */ + +#include "msg.h" +#include "diag_lsm.h" +#include "stdio.h" +#include "diagpkt.h" +#include "diagcmd.h" +#include "string.h" +#include +#include +#include +#include +#include +#define DEFAULT_SMD_PORT QMI_PORT_RMNET_0 +#define LOGI(...) fprintf(stderr, "I:" __VA_ARGS__) +#define DIAG_CONTROL_F 41 +#define EDL_RESET_CMD_CODE 1 + +#define PACKED __attribute__ ((__packed__)) + +#ifdef USE_GLIB +#include +#define strlcat g_strlcat +#define strlcpy g_strlcpy +#endif + +/* string to send to reboot_daemon to reboot */ +#define REBOOT_STR "REBOOT" +/* string to send to reboot_daemon to edl-reboot */ +#define EDL_REBOOT_STR "EDL-REBOOT" +/* size to make write buffer */ +#define MAX_BUF 64 +/* name of pipe to write to */ +#define FIFO_NAME "/dev/rebooterdev" + +/* ID's for diag */ +#define DIAG_UID 53 +#define DIAG_GID 53 +#define REBOOTERS_GID 1301 +#define SDCARD_GID 1015 + +/* QDSS defines */ +#define QDSSDIAG_PROCESSOR_APPS 0x0100 +#define QDSS_DIAG_PROC_ID QDSSDIAG_PROCESSOR_APPS + +#define QDSS_QUERY_STATUS 0x00 +#define QDSS_TRACE_SINK 0x01 +#define QDSS_FILTER_ETM 0x02 +#define QDSS_FILTER_STM 0x03 +#define QDSS_FILTER_HWEVENT_ENABLE 0x04 + +#define QDSS_FILTER_HWEVENT_CONFIGURE 0x31 +#define QDSS_QTIMER_TS_SYNC 0x60 + +#define QDSS_DIAG_MAC_PROC_ID 0x4200 +#define QDSS_MAC0 0x00 +#define QDSS_MAC1 0x01 +#define QDSS_MAC2 0x02 +#define QDSS_UMAC 0x03 + +#define TMC_TRACESINK_ETB 0 +#define TMC_TRACESINK_RAM 1 +#define TMC_TRACESINK_TPIU 2 +#define TMC_TRACESINK_USB 3 +#define TMC_TRACESINK_STREAM 4 +#define TMC_TRACESINK_USB_BUFFERED 4 +#define TMC_TRACESINK_SD 6 + +#define QDSS_RSP_SUCCESS 0 +#define QDSS_RSP_FAIL 1 + +#define QDSS_CLK_FREQ_HZ 19200000 +#define QTIMER_CLK_FREQ_HZ 19200000 + +#define QDSS_ETB_SINK_FILE "/sys/bus/coresight/devices/coresight-tmc-etf/curr_sink" +#define QDSS_ETB_SINK_FILE_2 "/sys/bus/coresight/devices/coresight-tmc-etf/enable_sink" +#define QDSS_ETR_SINK_FILE "/sys/bus/coresight/devices/coresight-tmc-etr/curr_sink" +#define QDSS_ETR_SINK_FILE_2 "/sys/bus/coresight/devices/coresight-tmc-etr/enable_sink" +#define QDSS_ETR_OUTMODE_FILE "/sys/bus/coresight/devices/coresight-tmc-etr/out_mode" +#define QDSS_TPIU_SINK_FILE "/sys/bus/coresight/devices/coresight-tpiu/curr_sink" +#define QDSS_TPIU_OUTMODE_FILE "/sys/bus/coresight/devices/coresight-tpiu/out_mode" +#define QDSS_STM_FILE "/sys/bus/coresight/devices/coresight-stm/enable" +#define QDSS_STM_FILE_2 "/sys/bus/coresight/devices/coresight-stm/enable_source" +#define QDSS_HWEVENT_FILE "/sys/bus/coresight/devices/coresight-hwevent/enable" +#define QDSS_STM_HWEVENT_FILE "/sys/bus/coresight/devices/coresight-stm/hwevent_enable" +#define QDSS_HWEVENT_SET_REG_FILE "/sys/bus/coresight/devices/coresight-hwevent/setreg" +#define QDSS_SWAO_CSR_TIMESTAMP "/sys/bus/coresight/devices/coresight-swao-csr/timestamp" +#define QDSS_MACEVENT_SET_CFG_FILE "/data/vendor/wifi/qdss_trace_config.bin" +#define QDSS_CNSCLI_CMD_FILE "/tmp/cnsscli_cmds.txt" + +enum mac_trace_sub_enum +{ + SW, + HWSCH, + PGD, + TXDMA, + RXDMA, + TXOLE, + RXOLE, + CRYPTO, + TXPCU, + RXPCU, + RRI, + AMPI, + C, + MXI, + MCMN, + RXDMA1, + LEPC, + RXOLEB1, + SFM, + LPECEB1 +}; + +enum umac_trace_sub_enum +{ + USW, + CE, + CXC, + REO, + TQM, + WBM, + TCL, + CXC2, + TCL_1, + WBM2, + REO2, + TQM2, + PHY_A, + PHY_B, +}; + + +typedef struct _mac_diag_cfg_pkt_tag +{ + uint8 mac_id; //0 or 1 + //VID Val1 Val2 Val3 Val4 + /*mac0 & mac1*/ + uint32 sw[5]; + uint32 hwsch[5]; + uint32 pdg[5]; + uint32 txdma[5]; + uint32 rxdma[5]; + uint32 txole[5]; + uint32 rxole[5]; + uint32 crypto[5]; + uint32 txpcu[5]; + uint32 rxpcu[5]; + uint32 rri[5]; + uint32 ampi[5]; + uint32 c[5]; + uint32 mxi[5]; + uint32 mcmn[5]; + uint32 rxdma1[5]; + uint32 lepc[5]; + uint32 rxoleb1[5]; + uint32 sfm[5]; + uint32 lpeceb1[5]; +}__attribute__((packed))_mac_diag_cfg_pkt_t; + +typedef struct _umac_diag_cfg_pkt_tag +{ + /*umac*/ + uint8 mac_id; // 3 + uint32 usw[5]; + uint32 ce[5]; + uint32 cxc[5]; + uint32 reo[5]; + uint32 tqm[5]; + uint32 wbm[5]; + uint32 tcl[5]; + uint32 cxc2[5]; + uint32 tcl_1[5]; + uint32 wbm2[5]; + uint32 reo2[5]; + uint32 tqm2[5]; + uint32 phy_a[5]; + uint32 phy_b[5]; +}__attribute__((packed))_umac_diag_cfg_pkt_t; + +/* QDSS */ +typedef struct +{ + uint8 cmdCode; // Diag Message ID + uint8 subsysId; // Subsystem ID (DIAG_SUBSYS_QDSS) + uint16 subsysCmdCode; // Subsystem command code +}__attribute__((packed))qdss_diag_pkt_hdr; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; +}__attribute__((packed))qdss_diag_pkt_req; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; // Header + uint8 result; //See QDSS_CMDRESP_... definitions +}__attribute__((packed))qdss_diag_pkt_rsp; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + uint8 trace_sink; +}__attribute__((packed))qdss_trace_sink_req; + +typedef qdss_diag_pkt_rsp qdss_trace_sink_rsp; //generic response + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + _mac_diag_cfg_pkt_t mac_pkt; +}__attribute__((packed))qdss_trace_mac_req; + +typedef qdss_diag_pkt_rsp qdss_trace_mac_rsp; //generic mac response + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + _umac_diag_cfg_pkt_t umac_pkt; +}__attribute__((packed))qdss_trace_umac_req; + +typedef qdss_diag_pkt_rsp qdss_trace_umac_rsp; //generic umac response + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + uint8 state; +}__attribute__((packed))qdss_filter_etm_req; + +typedef qdss_diag_pkt_rsp qdss_filter_etm_rsp; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + uint8 state; +}__attribute__((packed))qdss_filter_stm_req; + +typedef qdss_diag_pkt_rsp qdss_filter_stm_rsp; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + uint8 state; +}__attribute__((packed))qdss_filter_hwevents_req; + +typedef qdss_diag_pkt_rsp qdss_filter_hwevents_rsp; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + uint32 register_addr; + uint32 register_value; +}__attribute__((packed))qdss_filter_hwevents_configure_req; + +typedef qdss_diag_pkt_rsp qdss_filter_hwevents_configure_rsp; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; +}__attribute__((packed))qdss_query_status_req; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + uint8 trace_sink; + uint8 stm_enabled; + uint8 hw_events_enabled; +}__attribute__((packed))qdss_query_status_rsp; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; +}__attribute__((packed))qdss_qtimer_ts_sync_req; + +typedef struct +{ + qdss_diag_pkt_hdr hdr; + uint32 status; + uint64 qdss_ticks; + uint64 qtimer_ticks; + uint64 qdss_freq; + uint64 qtimer_freq; +}__attribute__((packed))qdss_qtimer_ts_sync_rsp; + +//enable the line below if you want to turn on debug messages +//#define DIAG_REBOOT_DEBUG + +PACK(void *) qdss_diag_pkt_handler(PACK(void *) pReq, uint16 pkt_len); + +/*qdss dispatch table*/ +static const diagpkt_user_table_entry_type qdss_diag_pkt_tbl[] = +{ + {QDSS_DIAG_PROC_ID | QDSS_QUERY_STATUS, + QDSS_DIAG_PROC_ID | QDSS_QTIMER_TS_SYNC, + qdss_diag_pkt_handler} +}; + + +PACK(void *) qdss_diag_mac_pkt_handler(PACK(void *) pReq, uint16 pkt_len); +static const diagpkt_user_table_entry_type qdss_diag_mac_pkt_tbl[] = +{ + {QDSS_DIAG_MAC_PROC_ID | QDSS_MAC0, + QDSS_DIAG_MAC_PROC_ID | QDSS_UMAC, + qdss_diag_mac_pkt_handler} +}; + + +static char qdss_sink = 0, qdss_hwevent = 0, qdss_stm = 0; + +void drop_privileges() { + + /* Start as root */ + /* Update primary group */ + setgid(DIAG_GID); + + /* Update secondary groups */ + gid_t *groups; + int numGroups = 2; + groups = (gid_t *) malloc(numGroups * sizeof(gid_t)); + if (groups){ + groups[0] = REBOOTERS_GID; + groups[1] = SDCARD_GID; + } + setgroups(numGroups, groups); + + /* Update UID -- from root to diag */ + setuid(DIAG_UID); + + free(groups); +} + +void setup_qdss_sysfs_nodes() { + chown(QDSS_ETB_SINK_FILE, DIAG_UID, -1); + chown(QDSS_ETB_SINK_FILE_2, DIAG_UID, -1); + chown(QDSS_ETR_SINK_FILE, DIAG_UID, -1); + chown(QDSS_ETR_SINK_FILE_2, DIAG_UID, -1); + chown(QDSS_ETR_OUTMODE_FILE, DIAG_UID, -1); + chown(QDSS_TPIU_SINK_FILE, DIAG_UID, -1); + chown(QDSS_TPIU_OUTMODE_FILE, DIAG_UID, -1); + chown(QDSS_STM_FILE, DIAG_UID, -1); + chown(QDSS_STM_FILE_2, DIAG_UID, -1); + chown(QDSS_HWEVENT_FILE, DIAG_UID, -1); + chown(QDSS_STM_HWEVENT_FILE, DIAG_UID, -1); + chown(QDSS_HWEVENT_SET_REG_FILE, DIAG_UID, -1); + chown(QDSS_MACEVENT_SET_CFG_FILE, DIAG_UID, -1); +} + +int main (void) { + + boolean bInit_Success = FALSE; + bInit_Success = Diag_LSM_Init(NULL); + FILE *qdss_fd; + + if (!bInit_Success) { + printf("Diag_LSM_Init() failed.\n"); + return -1; + } + + DIAGPKT_DISPATCH_TABLE_REGISTER (DIAG_SUBSYS_QDSS, qdss_diag_pkt_tbl); + DIAGPKT_DISPATCH_TABLE_REGISTER (DIAG_SUBSYS_QDSS, qdss_diag_mac_pkt_tbl); + + /*Header writing*/ + qdss_fd = fopen(QDSS_MACEVENT_SET_CFG_FILE, "w"); + if (qdss_fd == NULL) { + LOGI("qdss open file: %s error: %s", QDSS_MACEVENT_SET_CFG_FILE, strerror(errno)); + exit(1); + } + fprintf(qdss_fd, "seq_start;\nseq_type:mac_event_trace;\nsink:etr_ddr;\n"); + fclose(qdss_fd); + + /*cnscli writing*/ + qdss_fd = fopen(QDSS_CNSCLI_CMD_FILE, "w"); + if (qdss_fd == NULL) { + LOGI("qdss open file: %s error: %s", QDSS_CNSCLI_CMD_FILE, strerror(errno)); + exit(1); + } + fprintf(qdss_fd, "qdss_trace_load_config\nqdss_trace_start\nquit\n"); + fclose(qdss_fd); + + do { + sleep (1); + } while (1); + + Diag_LSM_DeInit(); + + return 0; +} + +static int qdss_file_write_str(const char *qdss_file_path, const char *str) +{ + int qdss_fd, ret; + + if (!qdss_file_path || !str) { + return QDSS_RSP_FAIL; + } + + qdss_fd = open(qdss_file_path, O_RDWR | O_APPEND); + if (qdss_fd < 0) { + LOGI("qdss open file: %s error: %s", qdss_file_path, strerror(errno)); + return QDSS_RSP_FAIL; + } + + ret = write(qdss_fd, str, strlen(str)); + if (ret < 0) { + LOGI("qdss write file: %s error: %s", qdss_file_path, strerror(errno)); + close(qdss_fd); + return QDSS_RSP_FAIL; + } + + close(qdss_fd); + + return QDSS_RSP_SUCCESS; +} + +static int qdss_file_write_byte(const char *qdss_file_path, unsigned char val) +{ + int qdss_fd, ret; + + if (!qdss_file_path) { + return QDSS_RSP_FAIL; + } + + qdss_fd = open(qdss_file_path, O_WRONLY); + if (qdss_fd < 0) { + LOGI("qdss open file: %s error: %s", qdss_file_path, strerror(errno)); + return QDSS_RSP_FAIL; + } + + ret = write(qdss_fd, &val, 1); + if (ret < 0) { + LOGI("qdss write file: %s error: %s", qdss_file_path, strerror(errno)); + close(qdss_fd); + return QDSS_RSP_FAIL; + } + + close(qdss_fd); + + return QDSS_RSP_SUCCESS; +} + +/* Sets the Trace Sink */ +static int qdss_trace_sink_handler(qdss_trace_sink_req *pReq, int req_len, qdss_trace_sink_rsp *pRsp, int rsp_len) +{ + int ret = 0; + + if (!pReq || !pRsp) { + return QDSS_RSP_FAIL; + } + + pRsp->result = QDSS_RSP_FAIL; + if (pReq->trace_sink == TMC_TRACESINK_ETB) { + /* For enabling writing ASCII value of 1 i.e. 0x31 */ + ret = qdss_file_write_byte(QDSS_ETB_SINK_FILE, 0x31); + if (ret) { + ret = qdss_file_write_byte(QDSS_ETB_SINK_FILE_2, 0x31); + if (ret) + return QDSS_RSP_FAIL; + } + } else if (pReq->trace_sink == TMC_TRACESINK_RAM) { + ret = qdss_file_write_byte(QDSS_STM_FILE, 0x30); + if (ret) { + return QDSS_RSP_FAIL; + } + ret = qdss_file_write_str(QDSS_ETR_OUTMODE_FILE, "mem"); + if (ret) { + return QDSS_RSP_FAIL; + } + + } else if (pReq->trace_sink == TMC_TRACESINK_STREAM) { + ret = qdss_file_write_byte(QDSS_STM_FILE, 0x30); + if (ret) { + return QDSS_RSP_FAIL; + } + ret = qdss_file_write_str(QDSS_ETR_OUTMODE_FILE, "q6mem_stream"); + if (ret) { + return QDSS_RSP_FAIL; + } + + } else if (pReq->trace_sink == TMC_TRACESINK_USB) { + ret = qdss_file_write_byte(QDSS_STM_FILE, 0x30); + if (ret) { + return QDSS_RSP_FAIL; + } + ret = qdss_file_write_str(QDSS_ETR_OUTMODE_FILE, "usb"); + if (ret) { + return QDSS_RSP_FAIL; + } + + } else if (pReq->trace_sink == TMC_TRACESINK_TPIU) { + ret = qdss_file_write_byte(QDSS_TPIU_SINK_FILE, 0x31); + if (ret) { + return QDSS_RSP_FAIL; + } + + ret = qdss_file_write_str(QDSS_TPIU_OUTMODE_FILE, "mictor"); + if (ret) { + return QDSS_RSP_FAIL; + } + } else if (pReq->trace_sink == TMC_TRACESINK_SD) { + ret = qdss_file_write_byte(QDSS_TPIU_SINK_FILE, 0x31); + if (ret) { + return QDSS_RSP_FAIL; + } + + ret = qdss_file_write_str(QDSS_TPIU_OUTMODE_FILE, "sdc"); + if (ret) { + return QDSS_RSP_FAIL; + } + } else { + qdss_sink = 0; + return QDSS_RSP_FAIL; + } + + qdss_sink = pReq->trace_sink; + pRsp->result = QDSS_RSP_SUCCESS; + + return QDSS_RSP_SUCCESS; +} + +/* Enable/Disable STM */ +static int qdss_filter_stm_handler(qdss_filter_stm_req *pReq, int req_len, qdss_filter_stm_rsp *pRsp, int rsp_len) +{ + char ret = 0, stm_state = 0; + + if (!pReq || !pRsp) { + return QDSS_RSP_FAIL; + } + + pRsp->result = QDSS_RSP_FAIL; + + if (pReq->state) { + stm_state = 1; + } else { + stm_state = 0; + } + + ret = qdss_file_write_byte(QDSS_STM_FILE, stm_state + 0x30); + if (ret) { + ret = qdss_file_write_byte(QDSS_STM_FILE_2, stm_state + 0x30); + if (ret) + return QDSS_RSP_FAIL; + } + + qdss_stm = stm_state; + pRsp->result = QDSS_RSP_SUCCESS; + + return QDSS_RSP_SUCCESS; +} + +/* Enable/Disable HW Events */ +static int qdss_filter_hwevents_handler(qdss_filter_hwevents_req *pReq, int req_len, qdss_filter_hwevents_rsp *pRsp, int rsp_len) +{ + int ret = 0; + + if (!pReq || !pRsp) { + return QDSS_RSP_FAIL; + } + + pRsp->result = QDSS_RSP_FAIL; + + if (pReq->state) { + + qdss_hwevent = 1; + /* For disabling writing ASCII value of 0 i.e. 0x30 */ + ret = qdss_file_write_byte(QDSS_HWEVENT_FILE, 0x30); + if (ret) { + return QDSS_RSP_FAIL; + } + + ret = qdss_file_write_byte(QDSS_STM_HWEVENT_FILE, 0x30); + if (ret) { + return QDSS_RSP_FAIL; + } + + ret = qdss_file_write_byte(QDSS_HWEVENT_FILE, 0x31); + if (ret) { + return QDSS_RSP_FAIL; + } + + ret = qdss_file_write_byte(QDSS_STM_HWEVENT_FILE, 0x31); + if (ret) { + return QDSS_RSP_FAIL; + } + + } else { + + qdss_hwevent = 0; + + ret = qdss_file_write_byte(QDSS_HWEVENT_FILE, 0x30); + if (ret) { + return QDSS_RSP_FAIL; + } + + ret = qdss_file_write_byte(QDSS_STM_HWEVENT_FILE, 0x30); + if (ret) { + return QDSS_RSP_FAIL; + } + } + + pRsp->result = QDSS_RSP_SUCCESS; + return QDSS_RSP_SUCCESS; +} + +/* Programming registers to generate HW events */ +static int qdss_filter_hwevents_configure_handler(qdss_filter_hwevents_configure_req *pReq, int req_len, qdss_filter_hwevents_configure_rsp *pRsp, int rsp_len) +{ + char reg_buf[100]; + int ret = 0, qdss_fd; + + if (!pReq || !pRsp) { + return QDSS_RSP_FAIL; + } + + pRsp->result = QDSS_RSP_FAIL; + + snprintf(reg_buf, sizeof(reg_buf), "%x %x", pReq->register_addr, pReq->register_value); + + qdss_fd = open(QDSS_HWEVENT_SET_REG_FILE, O_WRONLY); + if (qdss_fd < 0) { + LOGI("qdss open file: %s error: %s", QDSS_HWEVENT_SET_REG_FILE, strerror(errno)); + return QDSS_RSP_FAIL; + } + + ret = write(qdss_fd, reg_buf, strlen(reg_buf)); + if (ret < 0) { + LOGI("qdss write file: %s error: %s", QDSS_HWEVENT_SET_REG_FILE, strerror(errno)); + close(qdss_fd); + return QDSS_RSP_FAIL; + } + + close(qdss_fd); + + pRsp->result = QDSS_RSP_SUCCESS; + return QDSS_RSP_SUCCESS; +} + +/* Get the status of sink, stm and HW events */ +static int qdss_query_status_handler(qdss_query_status_req *pReq, int req_len, qdss_query_status_rsp *pRsp, int rsp_len) +{ + + if (!pReq || !pRsp) { + return QDSS_RSP_FAIL; + } + + pRsp->trace_sink = qdss_sink; + pRsp->stm_enabled = qdss_stm; + pRsp->hw_events_enabled = qdss_hwevent; + + return QDSS_RSP_SUCCESS; +} + +/* Handling of qdss qtimer ts sync */ +static int qdss_qtimer_ts_sync_handler(qdss_qtimer_ts_sync_req *pReq, int req_len, qdss_qtimer_ts_sync_rsp *pRsp, int rsp_len) +{ + int ret = 0, qdss_ts_fd = 0; + uint64_t qdss_ticks = 0, qtimer_ticks = 0; + char qdss_ts_val[17]; + + if (!pReq || !pRsp) { + return QDSS_RSP_FAIL; + } + + memset(qdss_ts_val, '\0', sizeof(qdss_ts_val)); + + qdss_ts_fd = open(QDSS_SWAO_CSR_TIMESTAMP, O_RDONLY); + if (qdss_ts_fd < 0) { + LOGI("qdss open file: %s error: %s", QDSS_SWAO_CSR_TIMESTAMP, strerror(errno)); + goto fail; + } + + ret = read(qdss_ts_fd, qdss_ts_val, sizeof(qdss_ts_val)-1); + if (ret < 0) { + LOGI("qdss read file: %s error: %s", QDSS_SWAO_CSR_TIMESTAMP, strerror(errno)); + close(qdss_ts_fd); + goto fail; + } + + qdss_ticks = atoll(qdss_ts_val); + + close(qdss_ts_fd); + +#if defined __aarch64__ && __aarch64__ == 1 + asm volatile("mrs %0, cntvct_el0" : "=r" (qtimer_ticks)); +#else + asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (qtimer_ticks)); +#endif + + pRsp->status = 0; + pRsp->qdss_ticks = qdss_ticks; + pRsp->qtimer_ticks = qtimer_ticks; + pRsp->qdss_freq = QDSS_CLK_FREQ_HZ; + pRsp->qtimer_freq = QTIMER_CLK_FREQ_HZ; + return QDSS_RSP_SUCCESS; +fail: + pRsp->status = 1; + pRsp->qdss_ticks = 0; + pRsp->qtimer_ticks = 0; + pRsp->qdss_freq = 0; + pRsp->qtimer_freq = 0; + return QDSS_RSP_FAIL; +} + +/* QDSS commands handler */ +PACK(void *) qdss_diag_pkt_handler(PACK(void *) pReq, uint16 pkt_len) +{ +/* + * 1) Checks the request command size. If it fails send error response. + * 2) If request command size is valid then allocates response packet + * based on request. + * 3) Invokes the respective command handler + */ + +#define QDSS_HANDLE_DIAG_CMD(cmd) \ + if (pkt_len < sizeof(cmd##_req)) { \ + pRsp = diagpkt_err_rsp(DIAG_BAD_LEN_F, pReq, pkt_len); \ + } \ + else { \ + pRsp = diagpkt_subsys_alloc(DIAG_SUBSYS_QDSS, \ + pHdr->subsysCmdCode, \ + sizeof(cmd##_rsp)); \ + if (NULL != pRsp) { \ + cmd##_handler((cmd##_req *)pReq, \ + pkt_len, \ + (cmd##_rsp *)pRsp, \ + sizeof(cmd##_rsp)); \ + } \ + } + + qdss_diag_pkt_hdr *pHdr; + PACK(void *)pRsp = NULL; + + if (NULL != pReq) { + pHdr = (qdss_diag_pkt_hdr *)pReq; + + switch (pHdr->subsysCmdCode & 0x0FF) { + case QDSS_QUERY_STATUS: + QDSS_HANDLE_DIAG_CMD(qdss_query_status); + break; + case QDSS_TRACE_SINK: + QDSS_HANDLE_DIAG_CMD(qdss_trace_sink); + break; + case QDSS_FILTER_STM: + QDSS_HANDLE_DIAG_CMD(qdss_filter_stm); + break; + case QDSS_FILTER_HWEVENT_ENABLE: + QDSS_HANDLE_DIAG_CMD(qdss_filter_hwevents); + break; + case QDSS_FILTER_HWEVENT_CONFIGURE: + QDSS_HANDLE_DIAG_CMD(qdss_filter_hwevents_configure); + break; + case QDSS_QTIMER_TS_SYNC: + QDSS_HANDLE_DIAG_CMD(qdss_qtimer_ts_sync); + break; + default: + pRsp = diagpkt_err_rsp(DIAG_BAD_CMD_F, pReq, pkt_len); + break; + } + + if (NULL != pRsp) { + diagpkt_commit(pRsp); + pRsp = NULL; + } + } + return (pRsp); +} + +static int qdss_trace_mac_handler(qdss_trace_mac_req *pReq, int req_len, qdss_trace_mac_rsp *pRsp, int rsp_len) +{ + int i; + FILE *qdss_fd; + + if (!pReq || !pRsp) { + return QDSS_RSP_FAIL; + } + + qdss_fd = fopen(QDSS_MACEVENT_SET_CFG_FILE, "a"); + if (qdss_fd == NULL) { + LOGI("qdss open file: %s error: %s", QDSS_MACEVENT_SET_CFG_FILE, strerror(errno)); + return QDSS_RSP_FAIL; + } + + fprintf(qdss_fd, "subsys_cfg_start:mac%d;\n", pReq->mac_pkt.mac_id); + + for (i = SW; i <= LPECEB1; i++) { + switch (i) { + case SW: + if (pReq->mac_pkt.sw[0]) { + fprintf(qdss_fd, "sw:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.sw[0], pReq->mac_pkt.sw[1], + pReq->mac_pkt.sw[2],pReq->mac_pkt.sw[3], + pReq->mac_pkt.sw[4]); + + } + break; + + case HWSCH: + if (pReq->mac_pkt.hwsch[0]) { + fprintf(qdss_fd, "hwsch:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.hwsch[0], pReq->mac_pkt.hwsch[1], + pReq->mac_pkt.hwsch[2], pReq->mac_pkt.hwsch[3], + pReq->mac_pkt.hwsch[4]); + } + break; + + + case PGD: + if (pReq->mac_pkt.pdg[0]) { + fprintf(qdss_fd, "pdg:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.pdg[0], pReq->mac_pkt.pdg[1], + pReq->mac_pkt.pdg[2], pReq->mac_pkt.pdg[3], + pReq->mac_pkt.pdg[4]); + } + break; + + case TXDMA: + if (pReq->mac_pkt.txdma[0]) { + fprintf(qdss_fd, "txdma:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.txdma[0], pReq->mac_pkt.txdma[1], + pReq->mac_pkt.txdma[2], pReq->mac_pkt.txdma[3], + pReq->mac_pkt.txdma[4]); + } + break; + + case RXDMA: + if (pReq->mac_pkt.rxdma[0]) { + fprintf(qdss_fd, "rxdma:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.rxdma[0], pReq->mac_pkt.rxdma[1], + pReq->mac_pkt.rxdma[2], pReq->mac_pkt.rxdma[3], + pReq->mac_pkt.rxdma[4]); + } + break; + + case TXOLE: + if (pReq->mac_pkt.txole[0]) { + fprintf(qdss_fd, "txole:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.txole[0], pReq->mac_pkt.txole[1], + pReq->mac_pkt.txole[2], pReq->mac_pkt.txole[3], + pReq->mac_pkt.txole[4]); + } + break; + + case RXOLE: + if (pReq->mac_pkt.rxole[0]) { + fprintf(qdss_fd, "rxole:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.rxole[0], pReq->mac_pkt.rxole[1], + pReq->mac_pkt.rxole[2], pReq->mac_pkt.rxole[3], + pReq->mac_pkt.rxole[4]); + } + break; + + case CRYPTO: + if (pReq->mac_pkt.crypto[0]) { + fprintf(qdss_fd, "crypto:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.crypto[0], pReq->mac_pkt.crypto[1], + pReq->mac_pkt.crypto[2], pReq->mac_pkt.crypto[3], + pReq->mac_pkt.crypto[4]); + } + break; + + case TXPCU: + if (pReq->mac_pkt.txpcu[0]) { + fprintf(qdss_fd, "txpcu:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.txpcu[0], pReq->mac_pkt.txpcu[1], + pReq->mac_pkt.txpcu[2], pReq->mac_pkt.txpcu[3], + pReq->mac_pkt.txpcu[4]); + } + break; + + case RXPCU: + if (pReq->mac_pkt.rxpcu[0]) { + fprintf(qdss_fd, "rxpcu:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.rxpcu[0], pReq->mac_pkt.rxpcu[1], + pReq->mac_pkt.rxpcu[2], pReq->mac_pkt.rxpcu[3], + pReq->mac_pkt.rxpcu[4]); + } + break; + + case RRI: + if (pReq->mac_pkt.rri[0]) { + fprintf(qdss_fd, "rri:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.rri[0], pReq->mac_pkt.rri[1], + pReq->mac_pkt.rri[2], pReq->mac_pkt.rri[3], + pReq->mac_pkt.rri[4]); + } + break; + + case AMPI: + if (pReq->mac_pkt.ampi[0]) { + fprintf(qdss_fd, "ampi:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.ampi[0], pReq->mac_pkt.ampi[1], + pReq->mac_pkt.ampi[2], pReq->mac_pkt.ampi[3], + pReq->mac_pkt.ampi[4]); + } + break; + + case C: + if (pReq->mac_pkt.c[0]) { + fprintf(qdss_fd, "c:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.c[0], pReq->mac_pkt.c[1], + pReq->mac_pkt.c[2], pReq->mac_pkt.c[3], + pReq->mac_pkt.c[4]); + } + break; + + case MXI: + if (pReq->mac_pkt.mxi[0]) { + fprintf(qdss_fd, "mxi:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.mxi[0], pReq->mac_pkt.mxi[1], + pReq->mac_pkt.mxi[2], pReq->mac_pkt.mxi[3], + pReq->mac_pkt.mxi[4]); + } + break; + + case MCMN: + if (pReq->mac_pkt.mcmn[0]) { + fprintf(qdss_fd, "mcmn:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.mcmn[0], pReq->mac_pkt.mcmn[1], + pReq->mac_pkt.mcmn[2], pReq->mac_pkt.mcmn[3], + pReq->mac_pkt.mcmn[4]); + } + break; + + case RXDMA1: + if (pReq->mac_pkt.rxdma1[0]) { + fprintf(qdss_fd, "rxdma1:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.rxdma1[0], pReq->mac_pkt.rxdma1[1], + pReq->mac_pkt.rxdma1[2], pReq->mac_pkt.rxdma1[3], + pReq->mac_pkt.rxdma1[4]); + } + break; + + case LEPC: + if (pReq->mac_pkt.lepc[0]) { + fprintf(qdss_fd, "lepc:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.lepc[0], pReq->mac_pkt.lepc[1], + pReq->mac_pkt.lepc[2], pReq->mac_pkt.lepc[3], + pReq->mac_pkt.lepc[4]); + } + break; + + case RXOLEB1: + if (pReq->mac_pkt.rxoleb1[0]) { + fprintf(qdss_fd, "rxoleb1:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.rxoleb1[0], pReq->mac_pkt.rxoleb1[1], + pReq->mac_pkt.rxoleb1[2], pReq->mac_pkt.rxoleb1[3], + pReq->mac_pkt.rxoleb1[4]); + } + break; + + case SFM: + if (pReq->mac_pkt.sfm[0]) { + fprintf(qdss_fd, "sfm:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.sfm[0], pReq->mac_pkt.sfm[1], + pReq->mac_pkt.sfm[2], pReq->mac_pkt.sfm[3], + pReq->mac_pkt.sfm[4]); + } + break; + + case LPECEB1: + if (pReq->mac_pkt.lpeceb1[0]) { + fprintf(qdss_fd, "lpeceb1:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->mac_pkt.lpeceb1[0], pReq->mac_pkt.lpeceb1[1], + pReq->mac_pkt.lpeceb1[2], pReq->mac_pkt.lpeceb1[3], + pReq->mac_pkt.lpeceb1[4]); + } + break; + } + } + + fprintf(qdss_fd, "subsys_cfg_end:mac%d;\n",pReq->mac_pkt.mac_id); + + fclose(qdss_fd); + + pRsp->result = QDSS_RSP_SUCCESS; + return QDSS_RSP_SUCCESS; + +} + +static int qdss_trace_umac_handler(qdss_trace_umac_req *pReq, int req_len, qdss_trace_umac_rsp *pRsp, int rsp_len) +{ + int i; + FILE *qdss_fd; + + if (!pReq || !pRsp) { + return QDSS_RSP_FAIL; + } + + qdss_fd = fopen(QDSS_MACEVENT_SET_CFG_FILE, "a"); + if (qdss_fd == NULL) { + LOGI("qdss open file: %s error: %s", QDSS_MACEVENT_SET_CFG_FILE, strerror(errno)); + return QDSS_RSP_FAIL; + } + + fprintf(qdss_fd, "subsys_cfg_start:umac;\n"); + + for (i = USW; i <= PHY_B; i++) { + switch (i) { + case USW: + if (pReq->umac_pkt.usw[0]) { + fprintf(qdss_fd, "usw:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.usw[0], pReq->umac_pkt.usw[1], + pReq->umac_pkt.usw[2],pReq->umac_pkt.usw[3], + pReq->umac_pkt.usw[4]); + } + break; + + case CE: + if (pReq->umac_pkt.ce[0]) { + fprintf(qdss_fd, "ce:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.ce[0], pReq->umac_pkt.ce[1], + pReq->umac_pkt.ce[2], pReq->umac_pkt.ce[3], + pReq->umac_pkt.ce[4]); + } + break; + + case CXC: + if (pReq->umac_pkt.cxc[0]) { + fprintf(qdss_fd, "cxc:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.cxc[0], pReq->umac_pkt.cxc[1], + pReq->umac_pkt.cxc[2], pReq->umac_pkt.cxc[3], + pReq->umac_pkt.cxc[4]); + } + break; + + case REO: + if (pReq->umac_pkt.reo[0]) { + fprintf(qdss_fd, "reo:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.reo[0], pReq->umac_pkt.reo[1], + pReq->umac_pkt.reo[2], pReq->umac_pkt.reo[3], + pReq->umac_pkt.reo[4]); + } + break; + + case TQM: + if (pReq->umac_pkt.tqm[0]) { + fprintf(qdss_fd, "tqm:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.tqm[0], pReq->umac_pkt.tqm[1], + pReq->umac_pkt.tqm[2], pReq->umac_pkt.tqm[3], + pReq->umac_pkt.tqm[4]); + } + break; + + case WBM: + if (pReq->umac_pkt.wbm[0]) { + fprintf(qdss_fd, "wbm:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.wbm[0], pReq->umac_pkt.wbm[1], + pReq->umac_pkt.wbm[2], pReq->umac_pkt.wbm[3], + pReq->umac_pkt.wbm[4]); + } + break; + + case TCL: + if (pReq->umac_pkt.tcl[0]) { + fprintf(qdss_fd, "tcl:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.tcl[0], pReq->umac_pkt.tcl[1], + pReq->umac_pkt.tcl[2], pReq->umac_pkt.tcl[3], + pReq->umac_pkt.tcl[4]); + } + break; + + case CXC2: + if (pReq->umac_pkt.cxc2[0]) { + fprintf(qdss_fd, "cxc2:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.cxc2[0], pReq->umac_pkt.cxc2[1], + pReq->umac_pkt.cxc2[2], pReq->umac_pkt.cxc2[3], + pReq->umac_pkt.cxc2[4]); + } + break; + + case TCL_1: + if (pReq->umac_pkt.tcl_1[0]) { + fprintf(qdss_fd, "tcl_1:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.tcl_1[0], pReq->umac_pkt.tcl_1[1], + pReq->umac_pkt.tcl_1[2], pReq->umac_pkt.tcl_1[3], + pReq->umac_pkt.tcl_1[4]); + } + break; + + case WBM2: + if (pReq->umac_pkt.wbm2[0]) { + fprintf(qdss_fd, "wbm2:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.wbm2[0], pReq->umac_pkt.wbm2[1], + pReq->umac_pkt.wbm2[2], pReq->umac_pkt.wbm2[3], + pReq->umac_pkt.wbm2[4]); + } + break; + + case REO2: + if (pReq->umac_pkt.reo2[0]) { + fprintf(qdss_fd, "reo2:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.reo2[0], pReq->umac_pkt.reo2[1], + pReq->umac_pkt.reo2[2], pReq->umac_pkt.reo2[3], + pReq->umac_pkt.reo2[4]); + } + break; + + case TQM2: + if (pReq->umac_pkt.tqm2[0]) { + fprintf(qdss_fd, "tqm2:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.tqm2[0], pReq->umac_pkt.tqm2[1], + pReq->umac_pkt.tqm2[2], pReq->umac_pkt.tqm2[3], + pReq->umac_pkt.tqm2[4]); + } + break; + + case PHY_A: + if (pReq->umac_pkt.phy_a[0]) { + fprintf(qdss_fd, "phy_a:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.phy_a[0], pReq->umac_pkt.phy_a[1], + pReq->umac_pkt.phy_a[2], pReq->umac_pkt.phy_a[3], + pReq->umac_pkt.phy_a[4]); + } + break; + + case PHY_B: + if (pReq->umac_pkt.phy_b[0]) { + fprintf(qdss_fd, "phy_b:0x%x, 0x%x, 0x%x, 0x%x, 0x%x;\n", + pReq->umac_pkt.phy_b[0], pReq->umac_pkt.phy_b[1], + pReq->umac_pkt.phy_b[2], pReq->umac_pkt.phy_b[3], + pReq->umac_pkt.phy_b[4]); + } + break; + } + } + fprintf(qdss_fd, "subsys_cfg_end:umac;\n"); + + char rept[50] = "0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF"; + fprintf(qdss_fd, "swap:%.*s;\ntrigger_start:trc;\nwfi:%s;\nts0:%s;\nts1:%s;\nts2:%s;\nts3:%s;\nts4:%s;\ntrigger_end:trc;\nmemw:%.*s;\nseq_end;\n",10,rept,rept,rept,rept,rept,rept,rept,21,rept); + + fclose(qdss_fd); + + system("cd /data/vendor/wifi; cnsscli < /tmp/cnsscli_cmds.txt"); + + pRsp->result = QDSS_RSP_SUCCESS; + return QDSS_RSP_SUCCESS; +} + +/* QDSS mac command handler */ +PACK(void *) qdss_diag_mac_pkt_handler(PACK(void *) pReq, uint16 pkt_len) +{ +/* + * 1) Checks the request command size. If it fails send error response. + * 2) If request command size is valid then allocates response packet + * based on request. + * 3) Invokes the respective command handler + */ + +#define QDSS_HANDLE_DIAG_CMD(cmd) \ + if (pkt_len < sizeof(cmd##_req)) { \ + pRsp = diagpkt_err_rsp(DIAG_BAD_LEN_F, pReq, pkt_len); \ + } \ + else { \ + pRsp = diagpkt_subsys_alloc(DIAG_SUBSYS_QDSS, \ + pHdr->subsysCmdCode, \ + sizeof(cmd##_rsp)); \ + if (NULL != pRsp) { \ + cmd##_handler((cmd##_req *)pReq, \ + pkt_len, \ + (cmd##_rsp *)pRsp, \ + sizeof(cmd##_rsp)); \ + } \ + } + qdss_diag_pkt_hdr *pHdr; + PACK(void *)pRsp = NULL; + + if (NULL != pReq) { + pHdr = (qdss_diag_pkt_hdr *)pReq; + + switch (pHdr->subsysCmdCode & 0x0FF) { + case QDSS_MAC0: + QDSS_HANDLE_DIAG_CMD(qdss_trace_mac); + break; + case QDSS_MAC1: + QDSS_HANDLE_DIAG_CMD(qdss_trace_mac); + break; + case QDSS_MAC2: + QDSS_HANDLE_DIAG_CMD(qdss_trace_mac); + break; + case QDSS_UMAC: + QDSS_HANDLE_DIAG_CMD(qdss_trace_umac); + break; + default: + pRsp = diagpkt_err_rsp(DIAG_BAD_CMD_F, pReq, pkt_len); + break; + } + + if (NULL != pRsp) { + diagpkt_commit(pRsp); + pRsp = NULL; + } + } + return (pRsp); +} + diff --git a/feeds/wifi-ax/qca-diag/src/socket_log/Android.mk b/feeds/wifi-ax/qca-diag/src/socket_log/Android.mk new file mode 100755 index 000000000..1f651e745 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/socket_log/Android.mk @@ -0,0 +1,29 @@ +################################################################################ +# @file pkgs/stringl/Android.mk +# @brief Makefile for building the string library on Android. +################################################################################ + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +libdiag_includes:= \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../src + +LOCAL_C_INCLUDES := $(libdiag_includes) +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc + +LOCAL_SRC_FILES:= \ + diag_socket_log.c + +commonSharedLibraries :=libdiag + +LOCAL_MODULE := diag_socket_log +LOCAL_MODULE_TAGS := optional +LOCAL_SHARED_LIBRARIES := $(commonSharedLibraries) +LOCAL_SHARED_LIBRARIES += liblog + +LOCAL_MODULE_OWNER := qcom +include $(BUILD_EXECUTABLE) + diff --git a/feeds/wifi-ax/qca-diag/src/socket_log/Makefile.am b/feeds/wifi-ax/qca-diag/src/socket_log/Makefile.am new file mode 100755 index 000000000..3a342de3e --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/socket_log/Makefile.am @@ -0,0 +1,27 @@ + +AM_CFLAGS = -Wall \ + -Wundef \ + -Wstrict-prototypes \ + -Wno-trigraphs + +AM_CPPFLAGS = -D__packed__= \ + -DIMAGE_APPS_PROC \ + -DFEATURE_Q_SINGLE_LINK \ + -DFEATURE_Q_NO_SELF_QPTR \ + -DFEATURE_LINUX \ + -DFEATURE_NATIVELINUX \ + -DFEATURE_DSM_DUP_ITEMS \ + -DFEATURE_LE_DIAG \ + -I../src \ + -I../include + +bin_PROGRAMS = diag_socket_log + +diag_socket_log_SOURCES = diag_socket_log.c +diag_socket_log_LDADD = ../src/libdiag.la +if USE_GLIB +diag_socket_log_CFLAGS = -DUSE_GLIB @GLIB_CFLAGS@ +diag_socket_log_LDFLAGS = -lpthread @GLIB_LIBS@ +else +diag_socket_log_LDFLAGS = -lpthread -lcutils +endif diff --git a/feeds/wifi-ax/qca-diag/src/socket_log/diag_socket_log.c b/feeds/wifi-ax/qca-diag/src/socket_log/diag_socket_log.c new file mode 100755 index 000000000..6cdd9fad1 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/socket_log/diag_socket_log.c @@ -0,0 +1,710 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Test Application for Diag Interface + +GENERAL DESCRIPTION + Contains main implementation of Diagnostic Services Application for sockets. + +EXTERNALIZED FUNCTIONS + None + +INITIALIZATION AND SEQUENCING REQUIREMENTS + +Copyright (c) 2012-2014 Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +06/21/12 DP Created +===========================================================================*/ + +#include +#include +#include "string.h" +#include "malloc.h" +#include +#include +#include +#include "msg.h" +#include "diag_lsm.h" +#include "diag_lsmi.h" +#include "diag_shared_i.h" +#include +#include +#include +#include +#include "errno.h" +#include +#include +#include + +/* strlcpy is from OpenBSD and not supported by Linux Embedded. + * GNU has an equivalent g_strlcpy implementation into glib. + * Featurized with compile time USE_GLIB flag for Linux Embedded builds. + */ +#ifdef USE_GLIB +#define strlcpy g_strlcpy +#endif + +#define DIAG_SOCKET_WAKELOCK_NAME "diag_socket_wakelock" + +#define PID_FILE "/root/diag_logs/diag_socket_pid" +#define PID_DIR "/root/diag_logs" +#define MAX_CHAN 3 + +static unsigned char read_buf[4096]; +static char ip_addr_name[FILE_NAME_LEN] = "192.168.0.10"; +static char port_number_string[FILE_NAME_LEN] = "2500"; +static int port_number = 2500; +static int num_connect_retries = 10000; +static int ip_addr_entered; +static int keep_logging = 1; +static int keep_reading = 1; +static int num_sockets = 0; +static int num_connected = 0; +static fd_set read_fs; +sigset_t pselect_set; +static int enable_wakelock = 0; +static int kill_socket_log = 0; +extern unsigned int device_num; + +struct diag_socket { + int fd; + int id; + int connected; +}; + +static struct diag_socket *sockets; + +void sock_log_handler(int signal) +{ + /* Continue logging */ + (void)signal; + keep_logging = 1; +} + +void sock_kill_handler(int signal) +{ + /* Logging should be stoped and the main thread exited */ + (void)signal; + keep_logging = 0; +} + +/* + * Call back function that is called if data from a remote device is + * discovered and there is no socket for it + */ +int diag_socket_callback(void *data_ptr, int socket_id) +{ + int i; + int success = 0; + int max_sockets = diag_get_max_channels(); + (void)data_ptr; + + for (i = 0; i < max_sockets; i++) { + if (sockets[i].fd == -1) { + sockets[i].id = socket_id; + num_sockets++; + keep_reading = 0; + success = 1; + break; + } + } + + if (success) { + DIAG_LOGE("In diag_socket_callback, success: %d, socket_id: %d, max_sockets: %d, num_sockets: %d\n", + success, socket_id, max_sockets, num_sockets); + } else { + DIAG_LOGE("In diag_socket_callback, Not able to setup for new socket connection for id: %d. num_sockets: %d, max_sockets: %d\n", + socket_id, num_sockets, max_sockets); + } + + return success; +} + +void usage (char *progname) +{ + printf("\n Usage for %s:\n", progname); + printf("\n-a, --address:\t IP address\n"); + printf("\n-d, --device:\t Device number(0: IPQ, 1: MDM1, 2: MDM2)\n"); + printf("\n-p, --port:\t Port number\n"); + printf("\n-r, --retry:\t Number of retries for connect\n"); + printf("\n-e --enable wakelock:\t Run using wake lock to keep APPS processor on\n"); + printf("\n-k, --kill:\t kill existing instance of diag_socket_log\n"); + printf("\n-h, --help:\t usage help\n"); + printf("\ne.g. diag_socket_log -a -p -r \n"); +} + +void parse_args(int argc, char **argv) +{ + int command; + struct option longopts[] = + { + { "address", 1, NULL, 'a'}, + { "port", 1, NULL, 'p'}, + { "retry", 1, NULL, 'r'}, + { "kill", 0, NULL, 'k'}, + { "help", 0, NULL, 'h'}, + }; + + while ((command = getopt_long(argc, argv, "a:d:p:r:khe", longopts, + NULL)) != -1) { + switch (command) { + case 'a': + strlcpy(ip_addr_name, optarg, FILE_NAME_LEN); + ip_addr_entered = 1; + break; + case 'p': + strlcpy(port_number_string, optarg, FILE_NAME_LEN); + port_number = atol(optarg); + break; + case 'r': + num_connect_retries = atol(optarg); + break; + case 'k': + kill_socket_log = 1; + break; + case 'e': + enable_wakelock = 1; + break; + case 'd': + device_num = to_integer(optarg); + if (device_num >= MAX_CHAN) + device_num = 0; + break; + case 'h': + default: + usage(argv[0]); + exit(0); + }; + } +} + +/* stop_socket_log is called when another instance of diag_socket_log is to be killed off */ +static void stop_socket_log(char *pid_file) +{ + int fd; + int ret; + pid_t pid; + char pid_buff[10]; + + /* Determine the process id of the instance of diag_socket_log */ + fd = open(pid_file, O_RDONLY); + if (fd < 0) { + DIAG_LOGE("\n diag_socket_log: Unable to open pid file, errno: %d\n", errno); + return; + } + + ret = read(fd, pid_buff, 10); + if (ret < 0) { + DIAG_LOGE("\n diag_socket_log: Unable to read pid file, errno: %d\n", errno); + close(fd); + return; + } + + close(fd); + + /* Make sure the buffer is properly terminated */ + if (ret == sizeof(pid_buff)) + ret--; + pid_buff[ret] = '\0'; + + pid = atoi(pid_buff); + + if (pid == 0 || (kill(pid, SIGTERM)) < 0) { + DIAG_LOGE("\ndiag_socket_log: Unable to kill diag_socket_log instance pid: %d, errno: %d\n", pid, errno); + } else { + DIAG_LOGE("\ndiag_socket_log: stopping diag_socket_log instance pid: %d\n", pid); + } + + return; +} + +void close_connection(struct diag_socket *socket) +{ + int status = 0; + + if (keep_logging) + diag_switch_logging(USB_MODE, NULL); + + if (socket->fd != -1) { + FD_CLR(socket->fd, &read_fs); + + status = close(socket->fd); + if (status == -1) { + DIAG_LOGE("diag_socket_log: Error closing socket: %s, socket: %d, errno: %d\n", + strerror(errno), socket->fd, errno); + } + socket->fd = -1; + num_connected -= 1; + } +} + +int open_connection(struct diag_socket *sock) +{ + int connect_success = 0; + struct addrinfo hints; + struct addrinfo *res = NULL; + char ip_info_name[INET6_ADDRSTRLEN]; + char *display_name = ip_addr_name; + int turn_on = 1; + struct linger sock_linger; + int status; + int retries_count; + + /* Open and Configure socket */ + sock->fd = socket(AF_INET, SOCK_STREAM, 0); + if (sock->fd == -1) { + DIAG_LOGE("diag_socket_log: Error calling socket: %s, errno: %d\n", + strerror(errno), errno); + exit(0); + } + + /* Set socket options */ + status = setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, &turn_on, + (socklen_t)sizeof(turn_on)); + if (status == -1) { + DIAG_LOGE("diag_socket_log:, getsockopt SO_REUSEADDR error, %s, errno: %d\n", + strerror(errno), errno); + } + + sock_linger.l_onoff = 1; + sock_linger.l_linger = 0; + status = setsockopt(sock->fd, SOL_SOCKET, SO_LINGER, &sock_linger, + (socklen_t)sizeof(struct linger)); + if (status == -1) { + DIAG_LOGE("diag_socket_log:, getsockopt SO_LINGER error, %s, errno: %d\n", + strerror(errno), errno); + } + + /* + * With the possibility the target has a remote device and + * having more than one socket to read/write, we need to + * set the socket to be non-blocking + */ + status = fcntl(sock->fd, F_SETFL, O_NONBLOCK); + if (status == -1) { + DIAG_LOGE("diag_socket_log:, fcntl O_NONBLOCK error, %s, errno: %d\n", + strerror(errno), errno); + } + + memset(&hints, 0, sizeof(hints)); + + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_PASSIVE; + + DIAG_LOGE("diag_socket_log: Translating address: %s\n", ip_addr_name); + + status = getaddrinfo(ip_addr_name, port_number_string, &hints, &res); + + if (status != 0 || !res) { + if (status == EAI_SYSTEM) { + DIAG_LOGE("diag_socket_log: getaddrinfo error: %d, %s, errno: %d\n", + status, gai_strerror(status), errno); + } else { + DIAG_LOGE("diag_socket_log: getaddrinfo error: %d, %s\n", + status, gai_strerror(status)); + } + if (!res) + DIAG_LOGE("diag_socket_log: getaddrinfo did not return list of addrinfo structures.\n"); + DIAG_LOGE("diag_socket_log: Exiting ...\n"); + exit(0); + } else { + void *ip_info_addr; + + /* If the family is IPV4 */ + if (res->ai_family == AF_INET) { + struct sockaddr_in *ipv4 = (struct sockaddr_in *)res->ai_addr; + ip_info_addr = &(ipv4->sin_addr); + } else { + struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)res->ai_addr; + ip_info_addr = &(ipv6->sin6_addr); + } + inet_ntop(res->ai_family, ip_info_addr, ip_info_name, sizeof(ip_info_name)); + display_name = ip_info_name; + } + + DIAG_LOGE("diag_socket_log: Trying to connect to address: %s, port: %d\n", + display_name, port_number); + + retries_count = 0; + while (retries_count < num_connect_retries) { + /* If we are not to keep logging, stop trying to connect */ + if (!keep_logging) { + DIAG_LOGE("diag_socket_log: Discontinuing trying to connect\n"); + break; + } + + status = connect(sock->fd, res[0].ai_addr, res[0].ai_addrlen); + if (status == -1) { + if (errno == EISCONN) { + DIAG_LOGE("diag_socket_log: Socket %d already connected, errno: %d\n", + sock->fd, errno); + connect_success = 1; + break; + } else if (errno == EINPROGRESS) { + if (retries_count == 1) { + DIAG_LOGE("diag_socket_log: %s, errno: %d\n", + strerror(errno), errno); + } + } else { + DIAG_LOGE("diag_socket_log: Error calling connect: %s, errno: %d\n", + strerror(errno), errno); + + if (errno == ENETUNREACH) { + DIAG_LOGE("diag_socket_log: Network is unreachable, " + "errno: %d Exiting ...\n", errno); + exit(0); + } else if (errno == EINVAL) { + DIAG_LOGE("diag_socket_log: Invalid argument. Exiting... \n"); + exit(0); + } else if (errno == ECONNREFUSED) { + DIAG_LOGE("diag_socket_log: Error is ECONNREFUSED - " + "No one is listening on the remote ip address\n"); + } + retries_count++; + } + } else { + connect_success = 1; + break; + } + sleep(2); + } + + freeaddrinfo(res); + + if (connect_success) { + DIAG_LOGE("diag_socket_log: Successful connect to address: %s, port number: %d\n", + display_name, port_number); + } + + return connect_success; +} + +int read_socket(struct diag_socket *socket) +{ + int num_read; + + /* Read from the socket */ + memset(read_buf, 0, 4096); + num_read = recv(socket->fd, (unsigned char *)read_buf, 4096, 0); + if (num_read > 0) { + /* Send the data read off of the socket to the kernel via the library */ + diag_send_socket_data(socket->id, read_buf, num_read); + } else if (num_read == -1) { + DIAG_LOGE("diag_socket_log: Read socket error: %s, errno: %d\n", + strerror(errno), errno); + switch (errno) { + case EINTR: + case EWOULDBLOCK: + /* Don't close connection. We can continue from these errors. */ + break; + default: + close_connection(socket); + socket->connected = 0; + break; + } + } else { + /* + * When read returns 0, the peer closed the connection. + * Try to re-establish the connection + */ + DIAG_LOGE("diag_socket_log: Peer closed connection. Trying to recover connection\n"); + close_connection(socket); + socket->connected = 0; + } + + return num_read; +} + +int check_for_remote(uint16 *remote_ids) +{ + int status; + int socket_count = 1; /* Set to 1 for the MSM socket */ + + status = diag_has_remote_device(remote_ids); + if (status != 1) { + DIAG_LOGE("diag_socket_log: Error determining if there is a remote device\n"); + } else { + if (*remote_ids != 0) { + DIAG_LOGE("diag_socket_log: Remote device detected, remote_ids: 0x%x\n", + (unsigned int)*remote_ids); + } else { + DIAG_LOGE("diag_socket_log: This device does not have any remote devices\n"); + } + } + + if (remote_ids != 0) { + uint16 ids = *remote_ids; + while (ids) + { + if (ids & 0x1) { + socket_count++; + } + ids = ids >> 1; + } + } + + return socket_count; +} + +int main(int argc, char *argv[]) +{ + boolean bInit_Success = FALSE; + boolean bDeInit_Success = FALSE; + + int pid, pid_fd; + char pid_buff[10]; + char pid_file[32] = PID_FILE; + + int connected = 0; + int num_read; + int status; + int i; + struct sigaction sock_log_action, sock_kill_action; + uid_t uid; + uint16 remote_ids; + + int select_fd = -1; + int max_channels; + sigemptyset(&pselect_set); + sigaddset(&pselect_set, SIGCONT); + + ip_addr_entered = 0; + + sigemptyset(&sock_log_action.sa_mask); + sock_log_action.sa_handler = sock_log_handler; + sock_log_action.sa_flags = 0; + sigaction(SIGCONT, &sock_log_action, NULL); + + sigemptyset(&sock_kill_action.sa_mask); + sock_kill_action.sa_handler = sock_kill_handler; + sock_kill_action.sa_flags = 0; + sigaction(SIGTERM, &sock_kill_action, NULL); + sigaction(SIGHUP, &sock_kill_action, NULL); + sigaction(SIGINT, &sock_kill_action, NULL); + + parse_args(argc, argv); + + uid = getuid(); + if (uid != 0) { + DIAG_LOGE("diag_socket_log: You must be root to run diag_socket_log." + "Exiting ...\n"); + exit(0); + } + + /* If another instance of diag_socket_log is to be killed off */ + if (kill_socket_log) { + stop_socket_log(pid_file); + exit(0); + } + + /* Make sure the default directory exists so the diag_socket.pid file + * can be placed there + */ + if (mkdir(PID_DIR, 0660)) + if (errno != EEXIST) + DIAG_LOGE("diag_socket_log: Fail creating directory for diag_socket.pid file"); + + /* + * Determine our process id and write it to the file so that + * when we want to stop diag_socket_log we know its process id + */ + unlink(pid_file); + if ((pid_fd = open(pid_file, O_RDWR | O_CREAT | O_EXCL | O_SYNC, + 0660)) < 0) { + DIAG_LOGE("\n diag_socket_log: Unable to open Pid File," + "errno: %d\n ODL feature will loose data\n", errno); + } else { + pid = getpid(); + memset(pid_buff, 0, 10); + snprintf(pid_buff, 10, "%d", pid); + write(pid_fd, pid_buff, 10); + close(pid_fd); + } + + if (!ip_addr_entered) { + DIAG_LOGE("diag_socket_log: No ip address entered. You must enter an " + "ip address. Exiting...\n"); + usage(argv[0]); + exit(0); + } + + /* Initialize the Diag LSM userspace library */ + bInit_Success = Diag_LSM_Init(NULL); + if (!bInit_Success) { + DIAG_LOGE("diag_socket_log: Diag_LSM_Init() failed. Exiting...\n"); + return -1; + } + DIAG_LOGE("diag_socket_log: Diag_LSM_Init succeeded.\n"); + +/* Acquire wakelock if the client is requesting for wakelock*/ + if(enable_wakelock == 1) { + diag_wakelock_init(DIAG_SOCKET_WAKELOCK_NAME); + diag_wakelock_acquire(); + } + max_channels = diag_get_max_channels(); + sockets = malloc(max_channels * sizeof(struct diag_socket)); + if (sockets == NULL) { + DIAG_LOGE("diag_socket_log: Unable to allocate memory for socket structures. Exiting ...\n"); + + /* Need to cleanup the diag client items already established */ + if(enable_wakelock == 1) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + Diag_LSM_DeInit(); + return -1; + } + + for (i = 0; i < max_channels; i++) + { + sockets[i].fd = -1; + sockets[i].id = -1; + sockets[i].connected = 0; + } + + + remote_ids = 0; + num_sockets = check_for_remote(&remote_ids); + DIAG_LOGE("diag_socket_log: socket_count is: %d\n", num_sockets); + + + /* Set up for connecting to the MSM channel */ + num_connected = 0; + num_sockets = 1; + if (remote_ids && device_num && (device_num & remote_ids)) { + sockets[0].id = device_num; + } else { + device_num = 0; + sockets[0].id = MSM; + } + + keep_reading = 1; + + /* + * Register callback function to be called if + * remote device data is discovered + */ + status = diag_register_socket_cb(diag_socket_callback, sockets); + + while (keep_logging) { + /* If we need to open a new socket connection */ + if (num_connected < num_sockets) { + for (i = 0; i < num_sockets; i++) + { + if (sockets[i].fd == -1) { + connected = open_connection(&sockets[i]); + if (connected) { + num_connected++; + sockets[i].connected = 1; + diag_set_socket_fd(sockets[i].id, sockets[i].fd); + if (sockets[i].fd >= select_fd) + select_fd = sockets[i].fd + 1; + } else { + DIAG_LOGE("diag_socket_log: Not able to successfully " + "connect after %d retries. Exiting ...\n", + num_connect_retries); + break; + } + } + } + } + if (num_connected == num_sockets) { + diag_switch_logging(SOCKET_MODE, NULL); + keep_reading = 1; + } else if (!keep_logging) { + DIAG_LOGE("diag_socket_log: Diag logging mode changed " + "away from sockets. Exiting ...\n"); + } else { + break; + } + + while ((num_connected > 0) && keep_reading) { + /* Enter sockets that need to be monitored for reading */ + FD_ZERO(&read_fs); + for (i = 0; i < num_sockets; i++) + { + if ((sockets[i].fd != -1) && sockets[i].connected) { + FD_SET(sockets[i].fd, &read_fs); + } + } + + /* + * Determine is any of the sockets have data that needs to be read. + * Note that select() will put the process/thread to sleep until + * there is data to be read on at least one of the sockets. + */ + status = pselect(select_fd, &read_fs, NULL, NULL, NULL,&pselect_set); + if (status < 0) { + DIAG_LOGE("diag_socket_log: Error calling select, %s, errno: %d\n", + strerror(errno), errno); + if (!keep_logging) { + /* Thread is being shutdown. Fall out of the loop + to allow this function to end. */ + break; + } + } + + for (i = 0; i < num_sockets; i++) { + if (sockets[i].fd != -1) { + /* If the socket has data to be read */ + if (FD_ISSET(sockets[i].fd, &read_fs)) { + num_read = read_socket(&sockets[i]); + /* If an error occurred, determine if we need to reconnect */ + if ((num_read <= 0) && (num_connected < num_sockets)) { + keep_reading = 0; + + if (!keep_logging) { + /* Thread is being shutdown. Fall out of the loop + to allow this function to end. */ + break; + } + } + } + } + } + + if (!keep_logging) { + DIAG_LOGE("diag_socket_log: Diag logging mode changed away from sockets.\n"); + DIAG_LOGE("diag_socket_log: Closing connection. Exiting ...\n"); + keep_reading = 0; + break; + } + } + } + + DIAG_LOGE("diag_socket_log: keep_logging: %d, fell out of loop. preparing to exit\n", keep_logging); + + bDeInit_Success = Diag_LSM_DeInit(); + DIAG_LOGE("diag_socket_log: Diag_LSM_DeInit() status: %d, exiting ...\n", bDeInit_Success); + + for (i = 0; i < max_channels; i++) + { + if (sockets[i].fd != -1) + close(sockets[i].fd); + sockets[i].fd = -1; + sockets[i].connected = 0; + } + + free(sockets); + + if(enable_wakelock == 1) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + return 0; +} diff --git a/feeds/wifi-ax/qca-diag/src/src/Makefile.am b/feeds/wifi-ax/qca-diag/src/src/Makefile.am new file mode 100755 index 000000000..f649eb66f --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/Makefile.am @@ -0,0 +1,63 @@ +# sources and intermediate files are separated + +AM_CFLAGS = -Wall \ + -Wundef \ + -Wstrict-prototypes \ + -Wno-trigraphs + +AM_CPPFLAGS = -DIMAGE_APPS_PROC \ + -DFEATURE_Q_SINGLE_LINK \ + -DFEATURE_Q_NO_SELF_QPTR \ + -DFEATURE_LINUX \ + -DFEATURE_NATIVELINUX \ + -DFEATURE_DSM_DUP_ITEMS \ + -DFEATURE_LE_DIAG \ + -Iinclude \ + -I../include + +h_sources =../include/diag.h +h_sources +=../include/diag_lsm.h +h_sources +=../include/diag_lsm_dci.h +h_sources +=../include/diagpkt.h +h_sources +=../include/event_defs.h +h_sources +=../include/event.h +h_sources +=../include/log_codes.h +h_sources +=../include/log.h +h_sources +=../include/msg_arrays_i.h +h_sources +=../include/msgcfg.h +h_sources +=../include/msg.h +h_sources +=../include/msg_pkt_defs.h +h_sources +=../include/msg_qsr.h +h_sources +=../include/msgtgt.h +h_sources +=../include/diagcmd.h +h_sources +=../src/diagdiag.h +h_sources +=../include/diagi.h + +c_sources =diag_lsm.c \ + ts_linux.c \ + diag_lsm_dci.c \ + diag_lsm_event.c \ + diag_lsm_log.c \ + diag_lsm_msg.c \ + diag_lsm_pkt.c \ + diagsvc_malloc.c \ + msg_arrays_i.c \ + diag_logger.c \ + diag_qshrink4_db_parser.c + +requiredlibs = $(TGENOFF_LIBS) + +library_includedir = $(pkgincludedir) +library_include_HEADERS = $(h_sources) +lib_LTLIBRARIES = libdiag.la +libdiag_la_CC = @CC@ +libdiag_la_SOURCES = $(c_sources) +libdiag_la_CPPFLAGS =$(AM_CPPFLAGS) +libdiag_la_LIBADD = $(requiredlibs) +if USE_GLIB +libdiag_la_CFLAGS = $(AM_CFLAGS) -fPIC -DUSE_GLIB @GLIB_CFLAGS@ +libdiag_la_LDFLAGS = -lpthread @GLIB_LIBS@ -shared -version-info $(DIAG_LIBRARY_VERSION) +else +libdiag_la_CFLAGS = $(AM_CFLAGS) -fPIC +libdiag_la_LDFLAGS = -lcutils -shared -version-info $(DIAG_LIBRARY_VERSION) +endif diff --git a/feeds/wifi-ax/qca-diag/src/src/diag.mk b/feeds/wifi-ax/qca-diag/src/src/diag.mk new file mode 100755 index 000000000..252e5f05a --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag.mk @@ -0,0 +1,53 @@ +# sources and intermediate files are separated +vpath %.c $(SRCDIR) + +CPPFLAGS += $(QCT_CPPFLAGS) +CPPFLAGS += -I$(SRCDIR) +CPPFLAGS += -I$(SRCDIR)/../include +CPPFLAGS += -I$(KERNEL_DIR)/include +CPPFLAGS += -I$(KERNEL_OBJDIR)/include +CPPFLAGS += -I$(KERNEL_OBJDIR)/include2 +CPPFLAGS += -DFEATURE_LE_DIAG + +CFLAGS += $(QCT_CFLAGS) + +all: libdiag.so.$(LIBVER) + +libdiag.so.$(LIBVER): diag_lsm.c diag_lsm_dci.c ts_linux.c diag_lsm_event.c diag_lsm_log.c diag_lsm_msg.c diag_lsm_pkt.c diagsvc_malloc.c msg_arrays_i.c diag_logger.c diag_qshrink4_db_parser.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(QCT_CFLAGS_SO) $(QCT_LDFLAGS_SO) -Wl,-soname,libdiag.so.$(LIBMAJOR) -o $@ $^ + + +############################################################################### +# Test Target +############################################################################### +ifdef BUILD_TEST + +test_diag: libdiag.so.$(LIBVER) +diag_klog: libdiag.so.$(LIBVER) +PktRspTest: libdiag.so.$(LIBVER) +diag_socket_log: libdiag.so.$(LIBVER) + +all: test_diag diag_klog PktRspTest diag_socket_log + +# build invoked elsewhere to keep sources and intermediate files separate +vpath %.c $(SRCDIR)/../test + +TEST_DIAG_LDLIBS += $(OBJDIR)/libdiag.so.$(LIBVER) -lstringl + +test_diag: test_diag.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(TEST_DIAG_LDLIBS) -lpthread + +vpath %.c $(SRCDIR)/../klog +diag_klog: diag_klog.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(TEST_DIAG_LDLIBS) -lpthread + +vpath %.c $(SRCDIR)/../PktRspTest +PktRspTest: PktRspTest.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(TEST_DIAG_LDLIBS) -lpthread + +vpath %.c $(SRCDIR)/../socket_log +diag_socket_log: diag_socket_log.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(TEST_DIAG_LDLIBS) -lpthread + +endif # BUILD_TEST + diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_logger.c b/feeds/wifi-ax/qca-diag/src/src/diag_logger.c new file mode 100755 index 000000000..b0bdfa00c --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_logger.c @@ -0,0 +1,290 @@ +/* + * Copyright (c) 2014 by Qualcomm Technologies, Inc. All Rights Reserved. + * Qualcomm Technologies Proprietary and Confidential. + * + * + * DIAG LOGGER + * =========== + * This module saves diag data to a specified file. It handles proper opening + * and closing of the output file(s). This supports diag data coming from + * multiple ASICs. This file is internal to diag and is used by diag + * applications only. + * + * DESCRIPTION + * =========== + * Any application that wishes to log data from a processor/ASIC to a file can + * use these APIs to save diag data to a file. This module creates a file and + * dumps the data onto the file for each processor individually. It maintains + * two internal buffers and uses them interchangeably to store data passed + * by the caller. It creates a thread during initialization that takes care of + * writing the buffers to the file system. On exit, it flushes the internal + * buffers to the file and frees the internal buffers. It is highly recommended + * that the exit function is called after stopping the read thread where the + * data is coming from. + * + * + * EXTERNAL FUNCTIONS + * ================== + * diag_logger_init + * diag_logger_write + * diag_logger_exit + * diag_logger_flush + * + */ + +#include +#include +#include +#include "comdef.h" +#include "errno.h" +#include "stdio.h" +#include "stringl.h" +#include "diag_logger.h" +#include "diag_lsmi.h" +#include "./../include/diag_lsm.h" + +static struct diag_logger_proc_t logger_proc[NUM_PROC]; + +static int diag_logger_buf_init(int proc, int buf_size) +{ + int i; + struct diag_logger_proc_t *logger = NULL; + + if (buf_size <= 0) + return -EINVAL; + + if (proc < 0 || proc >= NUM_PROC) { + DIAG_LOGE("diag: In %s, invalid proc %d\n", __func__, proc); + return -EINVAL; + } + + logger = &logger_proc[proc]; + logger->output_buf = malloc(buf_size * NUM_BUFFERS); + if (!logger->output_buf) + return -ENOMEM; + + for (i = 0; i < NUM_BUFFERS; i++) { + logger->buffer[i].free = 1; + logger->buffer[i].data_ready = 0; + logger->buffer[i].bytes_in_buff = 0; + logger->buffer[i].buf_capacity = buf_size; + pthread_mutex_init(&(logger->buffer[i].write_mutex), NULL); + pthread_cond_init(&(logger->buffer[i].write_cond), NULL); + pthread_mutex_init(&(logger->buffer[i].read_mutex), NULL); + pthread_cond_init(&(logger->buffer[i].read_cond), NULL); + logger->buffer[i].data = &(logger->output_buf[i * buf_size]); + } + + logger->curr_read = 0; + logger->curr_write = 0; + logger->buffer_0 = &logger->output_buf[0]; + logger->buffer_1 = &logger->output_buf[buf_size]; + return 0; +} + +static void diag_logger_buf_exit(int proc) +{ + int i; + struct diag_logger_proc_t *logger = NULL; + + if (proc < 0 || proc >= NUM_PROC) { + DIAG_LOGE("diag: In %s, invalid proc %d\n", __func__, proc); + return; + } + + logger = &logger_proc[proc]; + for (i = 0; i < NUM_BUFFERS; i++) { + pthread_mutex_destroy(&(logger->buffer[i].write_mutex)); + pthread_cond_destroy(&(logger->buffer[i].write_cond)); + pthread_mutex_destroy(&(logger->buffer[i].read_mutex)); + pthread_cond_destroy(&(logger->buffer[i].read_cond)); + } + + if (logger->output_buf) + free(logger->output_buf); +} + +void *process_incoming_data(void *data) +{ + unsigned int i; + unsigned int j; + unsigned int num_chunks; + unsigned int last_chunk; + unsigned int proc = (uint32_t)(uintptr_t)data; + char *write_buffer = NULL; + struct diag_logger_proc_t *logger = NULL; + struct diag_logger_buf_t *buf_ptr = NULL; + + if (proc >= NUM_PROC) { + DIAG_LOGE("diag: In %s, invalid proc %d\n", __func__, proc); + return NULL; + } + + logger = &logger_proc[proc]; + while (1) { + buf_ptr = &logger->buffer[logger->curr_write]; + pthread_mutex_lock(&buf_ptr->write_mutex); + while (!buf_ptr->data_ready) { + pthread_cond_wait(&buf_ptr->write_cond, + &buf_ptr->write_mutex); + } + + write_buffer = (char *)buf_ptr->data; + if (!write_buffer) { + DIAG_LOGE(" Invalid Write Buffer in %s\n", __func__); + break; + } + + num_chunks = buf_ptr->bytes_in_buff / WRITE_QUANTUM; + last_chunk = buf_ptr->bytes_in_buff % WRITE_QUANTUM; + + for(i = 0; i < num_chunks; i++) { + write(logger->op_file, write_buffer, WRITE_QUANTUM); + write_buffer += WRITE_QUANTUM; + } + + if (last_chunk > 0) + write(logger->op_file, write_buffer, last_chunk); + + /* File pool structure */ + buf_ptr->free = 1; + buf_ptr->data_ready = 0; + buf_ptr->bytes_in_buff = 0; + if (logger->curr_write) + buf_ptr->data = logger->buffer_1; + else + buf_ptr->data = logger->buffer_0; + + /* Free Read thread if waiting on same buffer */ + pthread_mutex_lock(&buf_ptr->read_mutex); + pthread_cond_signal(&buf_ptr->read_cond); + pthread_mutex_unlock(&buf_ptr->read_mutex); + pthread_mutex_unlock(&buf_ptr->write_mutex); + logger->curr_write = !logger->curr_write; + } + + return NULL; +} + +int diag_logger_init(int proc, char *file_name, int buf_size) +{ + int err = 0; + struct diag_logger_proc_t *logger = NULL; + + if (proc < 0 || proc >= NUM_PROC) { + DIAG_LOGE("diag: In %s, invalid proc %d\n", __func__, proc); + return -EINVAL; + } + + logger = &logger_proc[proc]; + logger->op_file = open(file_name, O_CREAT|O_RDWR|O_SYNC|O_TRUNC, 644); + if (logger->op_file < 0) { + DIAG_LOGE("diag: In %s, unable to open output file %s\n, er: %d\n", + __func__, file_name, errno); + return -EIO; + } + + err = diag_logger_buf_init(proc, buf_size); + if (err) { + DIAG_LOGE("diag: In %s, failed to initialize buffers, err: %d\n", __func__, err); + return err; + } + + pthread_create(&logger_proc[proc].buf_process_hdl, NULL, process_incoming_data, (void *)(uintptr_t)proc); + if (logger_proc[proc].buf_process_hdl == 0) { + DIAG_LOGE("diag: In %s, Failed to create thread to process incoming data\n", __func__); + diag_logger_buf_exit(proc); + return -EIO; + } + + return 0; +} + +int diag_logger_write(int proc, void *buf, uint32_t len) +{ + unsigned int copy_bytes = 0; + unsigned int count_received_bytes = len; + unsigned int bytes_in_buff = 0; + unsigned char *ptr = buf; + struct diag_logger_proc_t *logger = NULL; + struct diag_logger_buf_t *buf_ptr = NULL; + + if (!buf || len == 0) + return -EINVAL; + + if (proc < 0 || proc >= NUM_PROC) { + DIAG_LOGE("diag: In %s, invalid proc %d\n", __func__, proc); + return -EINVAL; + } + + logger = &logger_proc[proc]; + buf_ptr = &logger->buffer[logger->curr_read]; + + bytes_in_buff = buf_ptr->bytes_in_buff; + while (len >= (buf_ptr->buf_capacity - bytes_in_buff)) { + copy_bytes = buf_ptr->buf_capacity - bytes_in_buff; + memcpy(buf_ptr->data, ptr, copy_bytes); + count_received_bytes -= copy_bytes; + buf_ptr->data_ready = 1; + buf_ptr->free = 0; + ptr += copy_bytes; + buf_ptr->data += copy_bytes; + buf_ptr->bytes_in_buff += copy_bytes; + + pthread_cond_signal(&buf_ptr->write_cond); + pthread_mutex_unlock(&(buf_ptr->write_mutex)); + logger->curr_read = !logger->curr_read; + buf_ptr = &logger->buffer[logger->curr_read]; + pthread_mutex_lock(&(buf_ptr->read_mutex)); + + if (!buf_ptr->free) { + pthread_mutex_unlock(&(buf_ptr->write_mutex)); + pthread_cond_wait(&(buf_ptr->read_cond), + &(buf_ptr->read_mutex)); + pthread_mutex_lock(&(buf_ptr->write_mutex)); + } + + pthread_mutex_unlock(&(buf_ptr->read_mutex)); + bytes_in_buff = buf_ptr->bytes_in_buff; + } + + if (len > 0) { + memcpy(buf_ptr->data, ptr, count_received_bytes); + buf_ptr->data += count_received_bytes; + buf_ptr->bytes_in_buff += count_received_bytes; + } + + return 0; +} + +void diag_logger_exit(int proc) +{ + struct diag_logger_proc_t *logger = NULL; + + if (proc < 0 || proc >= NUM_PROC) { + DIAG_LOGE("diag: In %s, invalid proc %d\n", __func__, proc); + return; + } + + logger = &logger_proc[proc]; + diag_logger_flush(proc); + if (logger->op_file) + close(logger->op_file); + diag_logger_buf_exit(proc); +} + +void diag_logger_flush(int proc) +{ + struct diag_logger_proc_t *logger = NULL; + + if (proc < 0 || proc >= NUM_PROC) { + DIAG_LOGE("diag: In %s, invalid proc %d\n", __func__, proc); + return; + } + + logger = &logger_proc[proc]; + logger->buffer[logger->curr_read].data_ready = 1; + pthread_cond_signal(&logger->buffer[logger->curr_read].write_cond); + pthread_mutex_unlock(&(logger->buffer[logger->curr_read].write_mutex)); +} + diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_logger.h b/feeds/wifi-ax/qca-diag/src/src/diag_logger.h new file mode 100755 index 000000000..83180e68b --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_logger.h @@ -0,0 +1,61 @@ +#ifndef DIAG_LOGGER_H +#define DIAG_LOGGER_H + +/* + * Copyright (c) 2014 by Qualcomm Technologies, Inc. All Rights Reserved. + * Qualcomm Technologies Proprietary and Confidential. + * + * + * DIAG LOGGER + * =========== + * This module saves diag data to a specified file. It handles proper opening + * and closing of the output file(s). This supports diag data coming from + * multiple ASICs. This file is internal to diag and is used by diag + * applications only. + * + * + * EXTERNAL FUNCTIONS + * ================== + * diag_logger_init + * diag_logger_write + * diag_logger_exit + * diag_logger_flush + * + */ + +#include "comdef.h" +#include "./../include/diag_lsm.h" + +#define WRITE_QUANTUM (64 * 1024) +#define NUM_BUFFERS 2 + +struct diag_logger_buf_t { + int free; + int data_ready; + unsigned int bytes_in_buff; + unsigned int buf_capacity; + unsigned char *data; + pthread_mutex_t write_mutex; + pthread_cond_t write_cond; + pthread_mutex_t read_mutex; + pthread_cond_t read_cond; +}; + +struct diag_logger_proc_t { + int op_file; + pthread_t buf_process_hdl; + uint8 curr_read; + uint8 curr_write; + unsigned char *output_buf; + unsigned int output_buf_size; + unsigned char *buffer_0; + unsigned char *buffer_1; + struct diag_logger_buf_t buffer[NUM_BUFFERS]; +}; + +int diag_logger_init(int proc, char *file_name, int buf_size); +int diag_logger_write(int proc, void *buf, uint32_t len); +void diag_logger_exit(int proc); +void diag_logger_flush(int proc); + +#endif diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm.c b/feeds/wifi-ax/qca-diag/src/src/diag_lsm.c new file mode 100755 index 000000000..489f9432d --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm.c @@ -0,0 +1,3248 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* +Copyright (c) 2007-2016 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. + + Diag Legacy Service Mapping DLL + +GENERAL DESCRIPTION + +Implementation of entry point and Initialization functions for Diag_LSM.dll. + + +EXTERNALIZED FUNCTIONS +DllMain +Diag_LSM_Init +Diag_LSM_DeInit + +INITIALIZATION AND SEQUENCING REQUIREMENTS + + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Ported WM7 code onto Linux for CBSP2.0 +04/23/08 JV Added calls to functions that update masks during bring-up. + LSM registers for a mask change during Init.Now calling + diagpkt_bindpkt with the UnBind ID during de-init. +04/14/08 JV Created instance of IDiagPktRsp +03/19/08 JV Added packet service to init and de-init functions. +02/05/08 mad Moved declarations for Diag_LSM_Init() and Diag_LSM_DeInit() + to Diag_LSM.h. This will enable clients to include + Diag_LSM.h and call the functions directly. +01/15/08 mad Removed explicit linking to a1Host.lib, now using + LoadLibrary() and GetProcAddress() to call functions + exported by a1Host.dll. This was done to avoid a1Host.dll + being loaded implicitly upon loading of Diag_LSM.dll. +11/29/07 mad Created + +===========================================================================*/ + +#include +#include "comdef.h" +#include "stdio.h" +#include "diag_lsmi.h" +#include "./../include/diag_lsm.h" +#include "diagsvc_malloc.h" +#include "diag_lsm_event_i.h" +#include "diag_lsm_log_i.h" +#include "diag_lsm_msg_i.h" +#include "diag.h" /* For definition of diag_cmd_rsp */ +#include "diag_lsm_pkt_i.h" +#include "diag_lsm_dci_i.h" +#include "diag_lsm_dci.h" +#include "diag_shared_i.h" /* For different constants */ +#include +#include +#include +#include "errno.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define std_strlprintf snprintf +/* strlcpy is from OpenBSD and not supported by Linux Embedded. + * GNU has an equivalent g_strlcpy implementation into glib. + * Featurized with compile time USE_GLIB flag for Linux Embedded builds. + */ +#ifdef USE_GLIB +#define strlcpy g_strlcpy +#endif + +#define MAX_CHANNELS 3 + +#define DCI_HEADER_LENGTH sizeof(int) +#define DCI_LEN_FIELD_LENGTH sizeof(int) +#define DCI_EVENT_OFFSET sizeof(uint16) +#define DCI_DEL_FLAG_LEN sizeof(uint8) +#define DCI_EXT_HDR_LENGTH 8 + +#define CALLBACK_TYPE_LEN 4 +#define CALLBACK_PROC_TYPE_LEN 4 + +#define MAX_GUID_ENTRIES 128 + static unsigned int diag_peripheral_mask = 0; + int gdwClientID = 0; + int diag_fd = -1; /* File descriptor for DIAG device */ + /* File descriptor for Memory device */ + int fd_md[NUM_PROC] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; + int fd_uart = -1; /* File descriptor for UART device */ + int fd_socket[MAX_CHANNELS] = {-1, -1, -1}; /* File descriptor for socket */ + int fd_dev = -1; /* Generic file descriptor */ + int num_bytes_read; + unsigned long count_written_bytes[NUM_PROC]; + /* This is for non MEMORY logging*/ + unsigned long count_written_bytes_1 = 0; + char file_name_curr[NUM_PROC][FILE_NAME_LEN]; + char file_name_del[FILE_NAME_LEN] = "/sdcard/diag_logs/diag_log_"; + char mask_file[FILE_NAME_LEN] = "/sdcard/diag_logs/Diag.cfg"; + char mask_file2[FILE_NAME_LEN] = "/sdcard/diag_logs/Diag.cfg2"; + char mask_file_mdm[FILE_NAME_LEN] = "/sdcard/diag_logs/Diag.cfg"; + char mask_file_mdm2[FILE_NAME_LEN] = "/sdcard/diag_logs/Diag.cfg2"; + char output_dir[NUM_PROC][FILE_NAME_LEN] = { + "/sdcard/diag_logs/" + }; + char qsr4_xml_file_name[FILE_NAME_LEN] = "/sdcard/diag_logs/"; + /* This array is used for proc names */ + char proc_name[NUM_PROC][6] = {"", "/mdm", "/mdm2", "/mdm3", "/mdm4", "/qsc", "", + "", "", ""}; + int logging_mode = USB_MODE; + int uart_logging_proc = MSM; + char* file_list[NUM_PROC] = {NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL}; + int file_list_size[NUM_PROC] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int file_list_index[NUM_PROC] = {-1, -1, -1, -1, -1, -1, -1, + -1, -1, -1}; + char dir_name[FILE_NAME_LEN]; + char peripheral_name[FILE_NAME_LEN]; + +static struct diag_callback_tbl_t cb_clients[NUM_PROC]; +static int socket_inited = 0; +static int (*socket_cb_ptr)(void *socket_cb_data_ptr, int socket_id); +static void *socket_cb_data_ptr; +static int socket_token[MAX_CHANNELS]; +static unsigned int file_count = 0; +static unsigned int circular_logging_inited = 0; +static int lsm_init_count = 0; +static void init_circular_logging(void); +static int create_oldest_file_list(char *oldest_dir, int type); +unsigned int device_num = 0; + +/* Globals related to diag wakelocks */ +#define WAKELOCK_FILE "/sys/power/wake_lock" +#define WAKEUNLOCK_FILE "/sys/power/wake_unlock" +static int wl_inited; +static int fd_wl; +static int fd_wul; +static char *wl_name; +uint8 hdlc_disabled; +uint8 write_qshrink_header; + + +/* This event will be set (by DCM) when a request arrives for this process. */ +//HANDLE ghReq_Sync_Event = NULL; + +/* This event will be set (by DCM) when a mask change occurs. */ +//HANDLE ghMask_Sync_Event = NULL; + +#define NUM_SYNC_EVENTS_DIAG_LSM 2 +#define SYNC_EVENT_DIAG_LSM_PKT_IDX 0 +#define SYNC_EVENT_DIAG_LSM_MASK_IDX 1 +#define READ_BUF_SIZE 100000 +#define DISK_BUF_SIZE 1024*140 +#define DISK_FLUSH_THRESHOLD 1024*128 + +#define FILE_LIST_NAME_SIZE 100 +#define MAX_FILES_IN_FILE_LIST 100 + +static void *CreateWaitThread(void* param); +unsigned char read_buffer[READ_BUF_SIZE]; + +pthread_t read_thread_hdl; /* Diag Read thread handle */ +pthread_t disk_write_hdl; /* Diag disk write thread handle */ + +unsigned long max_file_size = 100000000; +unsigned long min_file_size = 80000000; /* 80 percent of max size */ +unsigned int log_to_memory ; +int cleanup_mask; /*Control sending of empty mask to modem */ +int diag_disable_console = 0; /*Variable to control console message */ +unsigned int max_file_num = 0x7FFFFFFF; + +#define RENAME_CMD_LEN ((2*FILE_NAME_LEN) + 10) + +int rename_file_names = 0; /* Rename file name on close to current time */ +int rename_dir_name = 0; /* Rename directory name to current time when ODL is halted */ + +/* Static array for workaround */ +static unsigned char static_buffer[6][DISK_BUF_SIZE]; + +/* Externalized functions */ +static pthread_once_t mask_sync_is_inited = PTHREAD_ONCE_INIT; +static pthread_mutex_t mask_sync_mutex; +static int diag_sync_mask = 0; +static pthread_mutex_t lsm_init_count_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t hdlc_toggle_mutex = PTHREAD_MUTEX_INITIALIZER; + +#define MASK_SYNC_COMPLETE (MSG_MASKS_TYPE | LOG_MASKS_TYPE | EVENT_MASKS_TYPE) +#define MAX_MASK_SYNC_COUNT 100 + +extern qsr4_db_file_parser_state parser_state; +char pid_file[DIAG_MDLOG_PID_FILE_SZ]; + +void mask_sync_initialize(void) +{ + pthread_mutex_init(&mask_sync_mutex, NULL); +} + +int get_sync_mask(void) +{ + int sync_mask; + + pthread_once(&mask_sync_is_inited, mask_sync_initialize); + pthread_mutex_lock(&mask_sync_mutex); + sync_mask = diag_sync_mask; + pthread_mutex_unlock(&mask_sync_mutex); + + return sync_mask; +} + +void update_sync_mask(int mask) +{ + pthread_once(&mask_sync_is_inited, mask_sync_initialize); + pthread_mutex_lock(&mask_sync_mutex); + diag_sync_mask |= mask; + pthread_mutex_unlock(&mask_sync_mutex); +} + +int do_mask_sync(void) +{ + int sync_mask = get_sync_mask(); + int count = 0; + int success = 1; + + while (sync_mask != MASK_SYNC_COMPLETE) + { + usleep(1000); + sync_mask = get_sync_mask(); + count++; + if (count > MAX_MASK_SYNC_COUNT) { + DIAG_LOGE("diag: In %s, mask sync error, count: %d\n", + __func__, count); + success = 0; + break; + } + } + + return success; +} + +void diag_wakelock_init(char *wakelock_name) +{ + /* The max permissible length of the wakelock string. The value + 25 was chosen randomly */ + int wl_name_len = 25; + + if (!wakelock_name) { + DIAG_LOGE("diag: In %s, invalid wakelock name\n", __func__); + goto fail_init; + } + + /* Wake lock is already initialized */ + if (wl_inited && wl_name) { + /* Check if the wakelock name is the same as the wakelock held. + If not, just print a warning and continue to use the old + wakelock name */ + if (strncmp(wakelock_name, wl_name, wl_name_len)) + DIAG_LOGE("diag: %s, already holding another wakelock in this process\n", __func__); + return; + } + + wl_name = (char *)malloc(wl_name_len); + if (!wl_name) { + DIAG_LOGE("diag: In %s, cannot allocate memory for wl_name\n", __func__); + goto fail_init; + } + strlcpy(wl_name, wakelock_name, wl_name_len); + + fd_wl = open(WAKELOCK_FILE, O_WRONLY|O_APPEND); + if (fd_wl < 0) { + DIAG_LOGE("diag: could not open wakelock file, errno: %d\n", errno); + goto fail_init; + } else { + fd_wul = open(WAKEUNLOCK_FILE, O_WRONLY|O_APPEND); + if (fd_wul < 0) { + DIAG_LOGE("diag: could not open wake-unlock file, errno: %d\n", errno); + close(fd_wl); + goto fail_init; + } + } + + wl_inited = TRUE; + return; + +fail_init: + wl_inited = FALSE; +} + +void diag_wakelock_destroy() +{ + if (!wl_inited) { + DIAG_LOGE("diag: %s, wakelock files are not initialized\n", __func__); + return; + } + + close(fd_wl); + close(fd_wul); +} + +int diag_is_wakelock_init() +{ + return wl_inited; +} + +void diag_wakelock_acquire() +{ + int status = -1; + if (!wl_inited) { + DIAG_LOGE("diag: %s, wakelock files are not initialized\n", __func__); + return; + } + + if (!wl_name) { + DIAG_LOGE("diag: In %s, invalid wakelock name\n", __func__); + return; + } + + status = write(fd_wl, wl_name, strlen(wl_name)); + if(status != (int)strlen(wl_name)) + DIAG_LOGE("diag: error writing to wakelock file"); +} + +void diag_wakelock_release() +{ + int status = -1; + if (!wl_inited) { + DIAG_LOGE("diag: %s, wakelock files are not initialized\n", __func__); + return; + } + + if (!wl_name) { + DIAG_LOGE("diag: In %s, invalid wakelock name\n", __func__); + return; + } + + status = write(fd_wul, wl_name, strlen(wl_name)); + if(status != (int)strlen(wl_name)) + DIAG_LOGE("diag: error writing to wake unlock file"); +} + + +/*========= variables for optimisation =======*/ + +static int curr_write; +static int curr_read; +static int write_in_progress; +pthread_mutex_t stop_mutex; +pthread_cond_t stop_cond; + +static char cmd_disable_log_mask[] = { 0x73, 0, 0, 0, 0, 0, 0, 0}; +static char cmd_disable_msg_mask[] = { 0x7D, 0x05, 0, 0, 0, 0, 0, 0}; +static char cmd_disable_event_mask[] = { 0x60, 0}; + +typedef PACK(struct) { + uint32 header_length; + uint8 version; + uint8 hdlc_data_type; + uint32 guid_list_entry_count; + uint32 guid[MAX_GUID_ENTRIES][GUID_LEN]; +}qshrink4_header; + +static qshrink4_header qshrink4_data; + +struct buffer_pool { + int free; + int data_ready; + unsigned int bytes_in_buff[NUM_PROC]; + unsigned char *buffer_ptr[NUM_PROC]; + pthread_mutex_t write_mutex; + pthread_cond_t write_cond; + pthread_mutex_t read_mutex; + pthread_cond_t read_cond; + +}; + +enum status { + NOT_READY, + READY, +}; + +unsigned char *pool0_buffers[NUM_PROC]; +unsigned char *pool1_buffers[NUM_PROC]; +enum status buffer_init[NUM_PROC]; +int token_list[NUM_PROC] = {0, -1, -2, -3, -4, -5, -6, -7, -8, -9}; + +struct buffer_pool pools[] = { + [0] = { + .free = 1, + .data_ready = 0, + }, + [1] = { + .free = 1, + .data_ready = 0, + }, + +}; + +int diag_get_max_channels(void) +{ + return MAX_CHANNELS; +} + +int to_integer(char *str) +{ + int hex_int = 0; + int i = 0, is_hex = 0; + char *p; + if (str) { + while(str[i] != '\0') { + if(str[i] == 'x' || str[i] == 'X') { + sscanf(str, "%i", &hex_int); + is_hex = 1; + break; + } + i++; + } + if(is_hex == 0) + hex_int = strtol(str, &p, 10); + } + return hex_int; +} + +/*========================================================================== +FUNCTION diag_qshrink4_init + +DESCRIPTION + In case for HDLC encoding is disabled the qmdl2 file will + contain the header information for the qshrink4 messages. + + The current header structure is as follows: + + +Field Length (in bytes) Description +HeaderLength 4 Number of bytes reserved for header. + +Version 1 Version value to set + +HDLC DataType 1 0 - indicates hdlc encoding removed + 1-indicates hdlc encoding enabled + +GuidListEntryCount 4 Number of Guids available to read + +GUID[GuidListEntryCount] 16*( GuidListEntryCount) An array of available GUIDs.This can expand + upto the maximum number of GUIDlist entries reserved in diag. + +Any data will be followed by header + +SIDE EFFECTS + None + +===========================================================================*/ + +static void diag_qshrink4_init(void) +{ + qshrink4_data.header_length = 10; + qshrink4_data.version = 1; + qshrink4_data.hdlc_data_type = 0; + qshrink4_data.guid_list_entry_count = 0; +} + +static void diag_socket_init(void) +{ + if (!socket_inited) { + int i; + for (i = 0; i < MAX_CHANNELS; i++) { + fd_socket[i] = -1; + if (i > MSM) + socket_token[i] = -i; + else + socket_token[i] = 0; + } + socket_cb_ptr = NULL; + socket_cb_data_ptr = NULL; + socket_inited = 1; + } else { + DIAG_LOGE("diag: In %s, Socket info already initialized\n", __func__); + } +} + +/*========================================================================== +FUNCTION diag_has_remote_device + +DESCRIPTION + This function queries the kernel to determine if the target device has a + remote device or not. + remote_mask - 0, if the target does not have a remote device; otherwise + a bit mask representing remote channels supported by the target + +RETURN VALUE + Returns 1 on success. Anything else is a failure. + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_has_remote_device(uint16 *remote_mask) +{ + return(ioctl(diag_fd, DIAG_IOCTL_REMOTE_DEV, remote_mask, 0, NULL, 0, NULL, NULL)); +} + +/*========================================================================== +FUNCTION diag_register_socket_cb + +DESCRIPTION + This function is used to register a callback function in the case that + remote data is discovered that does not have a corresponding socket. + The purpose of the callback function is so that app can create a socket + to be used to read/write the remote data. + + callback_ptr - the function pointer to be called + cb_data_ptr - a pointer to data that will be passed when the callback + function is called + + The callback function must have the following signature: + int (*callback_ptr)(void *data_ptr, int socket_id) + + Where: + data_ptr - is the cb_data_ptr + socket_id - the id to be used when calling diag_send_socket_data() + to send data for that socket + +RETURN VALUE + Returns 1 on success. 0 on failure. + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_register_socket_cb(int (*callback_ptr)(void *data_ptr, int socket_id), void *cb_data_ptr) +{ + int success = 0; + if (callback_ptr) { + DIAG_LOGE("diag: In %s, registered socket callback function\n", __func__); + socket_cb_ptr = callback_ptr; + socket_cb_data_ptr = cb_data_ptr; + success = 1; + } else { + DIAG_LOGE("diag: in %s, Unable to register socket callback function\n", __func__); + } + + return success; +} + +/*========================================================================== +FUNCTION diag_set_socket_fd + +DESCRIPTION + This function is to be called when registering a socket file descriptor. + This function should be called anytime the socket file descriptor is changed. + If the socket is closed, this function should be called with a socket file + descriptor that has a value of -1. + + socket_id - the socket id is used internal to the diag library. If the socket + is for MSM data its value must be 0, regardless of whether the + target device has a remote device of not. In the case of a target + with a remote device, the socket id is assigned by the diag library + and sent in the socket callback function, see diag_register_socket_cb(). + socket_fd - the socket file descriptor. + +RETURN VALUE + Returns 1 on success. 0 on failure. + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_set_socket_fd(int socket_id, int socket_fd) +{ + int success; + if ((socket_id >= 0) && (socket_id < MAX_CHANNELS)) { + fd_socket[socket_id] = socket_fd; + /* DIAG_LOGE("diag: In %s, setting fd_socket[%d] to %d\n", __func__, socket_id, socket_fd); */ + success = 1; + } else { + DIAG_LOGE("diag: In %s, Setting of socket fd failed. Invalid socket id: %d\n", + __func__, socket_id); + success = 0; + } + + return success; +} + +/*========================================================================== +FUNCTION diag_send_socket_data + +DESCRIPTION + This function is to be called when sending data read from the socket. + + socket_id - the socket id is used internal to the diag library. If the + socket is for MSM data (target with remote device or or not) + its value must be 0. In the case of a target with a remote + device, the socket id is assigned by the diag library and sent + in the socket callback function, see diag_register_socket_cb(). + buf - the buffer containing the data + num_bytes - the number of bytes of data in the buffer that is to be sent + +RETURN VALUE + Returns 1 on success. 0 on failure. + +SIDE EFFECTS + None + +===========================================================================*/ +int diag_send_socket_data(int id, unsigned char buf[], int num_bytes) +{ + unsigned char send_buf[4100]; + unsigned char offset = 4; + int i; + int start = 0; + int end = 0; + int copy_bytes; + int success; + + if ((id >= 0) && (id < MAX_CHANNELS)) { + *(int *)send_buf = USER_SPACE_DATA_TYPE; + if (socket_token[id] != 0 ) { + *(int *)(send_buf + offset) = socket_token[id]; + offset += 4; + } + + for (i = 0; i < num_bytes; i++) { + if (hdlc_disabled) { + if (buf[i] == CONTROL_CHAR && i == 0) { + end = end + 1; + continue; + } + } + if (buf[i] == CONTROL_CHAR) { + copy_bytes = end-start+1; + memcpy(send_buf+offset, buf+start, copy_bytes); + diag_send_data(send_buf, copy_bytes+offset); + start = i+1; + end = i+1; + continue; + } + end = end+1; + } + success = 1; + } else { + DIAG_LOGE("diag: In %s, Error sending socket data. Invalid socket id: %d\n", + __func__, id); + success = 0; + } + + return success; +} + +/*========================================================================== +FUNCTION get_remote_socket_fd + +DESCRIPTION + This function is used internal to the diag library and returns the socket + file descriptor for the remote data. If there is no valid socket file + descriptor for the remote data, the registered socket callback function + (see diag_register_socket_cb) will be called to notify the app that a new + socket must be created for the remote data. + + token - the embedded token data that identifies the data as being + remote data. For instance, MDM_TOKEN. + +RETURN VALUE + Returns the socket file descriptor on success; -1 otherwise. + +SIDE EFFECTS + None + +===========================================================================*/ +static int get_remote_socket_fd(int token) +{ + int i; + int found = 0; + int fd = -1; + int status; + + for (i = 1; i < MAX_CHANNELS; i++) { + if (socket_token[i] == token) { + fd = fd_socket[i]; + found = i; + break; + } + } + + /* If there is no socket for this token */ + if (!found) { + for (i = 1; i < MAX_CHANNELS; i++) { + /* If we have found an unused socket entry */ + if (fd_socket[i] == -1) { + /* If the socket entry has not begun initialization */ + if (socket_token[i] != token) { + /* Notify the app that another socket needs to be opened */ + if (socket_cb_ptr) { + status = (*(socket_cb_ptr))(socket_cb_data_ptr, i); + socket_token[i] = token; + } else { + DIAG_LOGE("diag: In %s, Error, socket callback function has not been registered\n", + __func__); + } + } + break; + } + } + } + + return fd; +} + +/*========================================================================= + * FUNCTION send_empty_mask + * DESCRIPTION + * This function send empty mask to modem, thus modem stops generating + * logs and can enter low power mode. + * RETURN VALUE + * NONE + * SIDE EFFECTS + * NONE + *========================================================================*/ + +void send_empty_mask(int type) +{ + int offset = 0; + int length = 0; + const uint8 size = 20; + unsigned char mask_buf[size]; + unsigned char *ptr = mask_buf; + + *(int *)ptr = USER_SPACE_RAW_DATA_TYPE; + offset += sizeof(int); + if (type == MDM) { + *(int *)(ptr + offset) = MDM_TOKEN; + offset += sizeof(int); + } else if (type == QSC) { + *(int *)(ptr + offset) = QSC_TOKEN; + offset += sizeof(int); + } + + /* Send Disable Log Mask Command */ + length = sizeof(cmd_disable_log_mask) / sizeof(char); + if (length + offset <= size) { + memcpy(ptr + offset, cmd_disable_log_mask, length); + diag_send_data(ptr, offset + length); + } + + /* Send Disable Msg Mask Command */ + length = sizeof(cmd_disable_msg_mask) / sizeof(char); + if (length + offset <= size) { + memcpy(ptr + offset, cmd_disable_msg_mask, length); + diag_send_data(ptr, offset + length); + } + + /* Send Disable Event Mask Command */ + length = sizeof(cmd_disable_event_mask) / sizeof(char); + if (length + offset <= size) { + memcpy(ptr + offset, cmd_disable_event_mask, length); + diag_send_data(ptr, offset + length); + } +} + + +/* signal handler to flush logs to disk */ +volatile int flush_log; +volatile int in_read; +volatile int flush_in_progress; + +/* Global variable to decide the type of PROC */ +int proc_type = MSM; + +/*========================================================================== + * FUNCTION dummy_handler + * + * DESCRIPTION + * A dummy signal handler for read thraed only. + * RETURN VALUE + * None + * + * SIDE EFFECTS + * None + * + *========================================================================*/ +void dummy_handler(int signal) +{ + int sys_getpid, sys_gettid; + (void)signal; + +#ifdef FEATURE_LE_DIAG + sys_getpid = SYS_getpid; + sys_gettid = SYS_gettid; +#else + sys_getpid = __NR_getpid; + sys_gettid = __NR_gettid; +#endif + DIAG_LOGE("diag:%s: pid-tid %ld-%ld \n", __func__, + (long int)syscall(sys_getpid), + (long int)syscall(sys_gettid)); +} + +/*========================================================================== +FUNCTION flush_buffer + +DESCRIPTION + This function flushes the pending data in the buffers. + If application receives signal then it also stops the application. +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void flush_buffer(int signal) +{ + int status = 0; + struct stat pid_stat; + int success = 0; + uint16 remote_mask = 0; + int buf_mode = MODE_REALTIME; + char temp_xml_buf[GUID_LIST_END_XML_TAG_SIZE]; + int index = 0; + int ret = 0; + DIAG_LOGE("diag: Signal received\n"); + + /* Dismiss the signal if we are already processing a signal */ + if (signal) { + if (flush_in_progress) + return; + flush_in_progress = 1; + } + + status = diag_get_real_time_status(&buf_mode); + if (status) { + DIAG_LOGE("diag: In %s, error in querying for real time mode status: %d, errno: %d\n", + __func__, status, errno); + buf_mode = MODE_REALTIME; + } + if (buf_mode == MODE_UNKNOWN) + DIAG_LOGE("diag: One of the peripherals is in buffering mode.\n"); + + /* + * If we are going to exit and we are logging in non-real-time mode + * then let the kernel know it should move from nont-real-time mode + * to real-time mode. Then wait for a few seconds to allow diag on the + * peripherals to change to real-time logging mode and flush their + * buffers over the smd. This data will then be read from the kernel + * and placed into the this libraries buffers for later writing. Wait + * for a few seconds before progressing with the exit to allow this + * to take place. + */ + if (signal && buf_mode == MODE_NONREALTIME) { + int num_secs = 5; + errno = 0; + status = diag_vote_md_real_time(MODE_REALTIME); + if (status == -1) + DIAG_LOGE("diag: In %s unable to set mode to real time mode. errno = %d\n", __func__, errno); + + DIAG_LOGE("diag: In %s, Waiting for %d seconds for non-real-time data to arrive\n", + __func__, num_secs); + sleep(num_secs); + } + + if (signal && cleanup_mask) { + DIAG_LOGE("diag: Sending empty mask MSM\n"); + send_empty_mask(MSM); + success = diag_has_remote_device(&remote_mask); + if (success == 1) { + if (remote_mask & MDM) { + DIAG_LOGE("diag: Sending empty mask MDM\n"); + send_empty_mask(MDM); + } + if (remote_mask & QSC) { + DIAG_LOGE("diag: Sending empty mask QSC\n"); + send_empty_mask(QSC); + } + } else { + DIAG_LOGE("diag: error in getting remote processor mask, err: %d, errno: %d\n", success, errno); + } + } + diag_kill_qshrink4_threads(); + flush_log = 1; + + if (in_read) { + DIAG_LOGE("diag: sending signal to unblock read thread\n"); + pthread_kill(read_thread_hdl, SIGUSR2); + } + + while(flush_log < 3) { + sleep(1); + } + pthread_mutex_lock(&stop_mutex); + + /* Clean up */ + write_in_progress = 0; + in_read = 0; + curr_write = curr_read = 0; + + pools[0].free = pools[1].free = 1; + pools[0].data_ready = pools[1].data_ready = 0; + + /* Signal received destroy the mutexes and stop the application */ + if (signal) { + DIAG_LOGE("diag: Sending cond to CreateWaitThread\n"); + pthread_cond_signal(&stop_cond); + pthread_mutex_unlock(&stop_mutex); + + success = Diag_LSM_DeInit(); + if (!success) + DIAG_LOGE("diag: DIAG_LSM_DeInit() Failed\n"); + + pthread_mutex_destroy(&(pools[0].write_mutex)); + pthread_cond_destroy(&(pools[0].write_cond)); + pthread_mutex_destroy(&(pools[0].read_mutex)); + pthread_cond_destroy(&(pools[0].read_cond)); + pthread_mutex_destroy(&(pools[1].write_mutex)); + pthread_cond_destroy(&(pools[1].write_cond)); + pthread_mutex_destroy(&(pools[1].read_mutex)); + pthread_cond_destroy(&(pools[1].read_cond)); + if (!hdlc_disabled) { + ret = std_strlprintf(temp_xml_buf, GUID_LIST_END_XML_TAG_SIZE, "%s", ""); + for (index = 0; index < NUM_PROC; index++) { + if ((fd_qsr4_xml[index] >= 0) && (ret > 0)) { + status = write(fd_qsr4_xml[index], temp_xml_buf, ret); + if (status != ret) + DIAG_LOGE("diag:In %s failed to write to xml file with err %d\n", __func__, errno); + status = close(fd_qsr4_xml[index]); + if (status != 0) + DIAG_LOGE("diag:In %s failed to close xml file with err %d\n", __func__, errno); + fd_qsr4_xml[index] = -1; + } + } + } + + /* Release the wakelock if held */ + if (diag_is_wakelock_init()) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + + /* Delete the PID file */ + if (stat(pid_file, &pid_stat) == 0) + unlink(pid_file); + else + DIAG_LOGE("diag: Unable to delete the PID file: %s, err: %d\n", pid_file, errno); + + DIAG_LOGE("diag: Exiting program \n"); + _exit(0); + } + else + pthread_mutex_unlock(&stop_mutex); + +} + + +int valid_token(int token) +{ + int i; + + if (token >= 0) + return 0; + for (i = 0; i < NUM_PROC; i++) + if(token == token_list[i]) + return -token; + return 0; +} + +/*=========================================================================== +FUNCTION fill_pkt_buffer + +DESCRIPTION + This function creates a single byte stream of logs by removing header + information. +DEPENDENCIES + valid data type to be passed in + +RETURN VALUE + TRUE - if pkt is filled correctly + FALSE - pkt is not filled correctly due to invalid token + +SIDE EFFECTS + None + +===========================================================================*/ +static boolean fill_pkt_buffer(unsigned char *ptr) +{ + int num_data_fields = *(int *)ptr; + int i, index = 0, z; + uint32 count_received_bytes, copy_bytes = 0; + int status = 0; + char temp_xml_buf[GUID_LIST_END_XML_TAG_SIZE]; + int ret = 0; + unsigned char *buffer = NULL; + unsigned int *bytes_in_buff = NULL; + + ptr += 4; + for (i = 0; i < num_data_fields; i++) { + index = valid_token(*(int *)ptr); + if (index == -1) { + DIAG_LOGE("diag: In %s, invalid Token number %d\n", __func__, *(int *)ptr); + return FALSE; + } + buffer = pools[curr_read].buffer_ptr[index]; + bytes_in_buff = &pools[curr_read].bytes_in_buff[index]; + if (!buffer || !bytes_in_buff) + continue; + if (index > 0) { + ptr += 4; + if (buffer_init[index] != READY) { + + /* This check is added as calloc is failing */ + if (index > 2) { + /* Allocate buffer */ + pool0_buffers[index] = + calloc(DISK_BUF_SIZE, 1); + if (!pool0_buffers[index]) { + DIAG_LOGE("\nbuffer alloc failed \n"); + continue; + } + pool1_buffers[index] = + calloc(DISK_BUF_SIZE, 1); + if (!pool1_buffers[index]) { + DIAG_LOGE("\nbuffer alloc failed \n"); + free(pool0_buffers[index]); + continue; + } + pools[0].buffer_ptr[index] = + pool0_buffers[index]; + pools[1].buffer_ptr[index] = + pool1_buffers[index]; + pools[0].bytes_in_buff[index] = 0; + pools[1].bytes_in_buff[index] = 0; + } + + /* Create directory for this proc */ + (void)strlcat(output_dir[index], + proc_name[index], FILE_NAME_LEN); + status = mkdir(output_dir[index], 0770); + if (status == -1) { + if (errno == EEXIST) { + DIAG_LOGE("diag: In %s, Warning output directory already exists: %s\n", + __func__, output_dir[index]); + DIAG_LOGE("diag: Proceeding...\n"); + } else { + DIAG_LOGE("diag: In %s, Unable to create directory: %s, errno: %d\n", + __func__, output_dir[index], errno); + continue; + } + } + if (!hdlc_disabled) { + if (fd_qsr4_xml[index] < 0) { + (void)std_strlprintf(qsr4_xml_file_name, + FILE_NAME_LEN, "%s%s%s%s", + output_dir[index],"/diag_qsr4_guid_list_", + (char *)buffer, ".xml"); + fd_qsr4_xml[index] = open(qsr4_xml_file_name, O_CREAT | O_RDWR | O_SYNC | O_TRUNC, 0644); + if (fd_qsr4_xml[index] < 0) + DIAG_LOGE("diag: In %s failed to create xml file with err %d", __func__, errno); + ret = std_strlprintf(temp_xml_buf, GUID_LIST_XML_TAG_SIZE, "%s\n", ""); + if ((fd_qsr4_xml[index] >= 0) && (ret > 0)) { + status = write(fd_qsr4_xml[index], temp_xml_buf, ret); + if (status != ret) + DIAG_LOGE("diag: In %s failed to write to xml file with err %d", __func__, errno); + } + } + + } + buffer_init[index] = READY; + buffer = pools[curr_read].buffer_ptr[index]; + *bytes_in_buff = + pools[curr_read].bytes_in_buff[index]; + } + } + + count_received_bytes = *(uint32*)ptr; + ptr += sizeof(uint32); + while (count_received_bytes >= (DISK_BUF_SIZE - *bytes_in_buff)) { + copy_bytes = DISK_BUF_SIZE - *bytes_in_buff; + if (parser_state) + parse_data_for_qsr4_db_file_op_rsp(ptr, count_received_bytes); + memcpy(buffer + *bytes_in_buff, ptr, copy_bytes); + count_received_bytes -= copy_bytes; + pools[curr_read].data_ready = 1; + pools[curr_read].free = 0; + ptr += copy_bytes; + *bytes_in_buff += copy_bytes; + for (z = 0; z < NUM_PROC; z++) { + if (curr_read) + pools[curr_read].buffer_ptr[z] = + pool1_buffers[z]; + else + pools[curr_read].buffer_ptr[z] = + pool0_buffers[z]; + } + pthread_cond_signal(&pools[curr_read].write_cond); + pthread_mutex_unlock(&(pools[curr_read].write_mutex)); + curr_read = !curr_read; + pthread_mutex_lock(&(pools[curr_read].read_mutex)); + if (!pools[curr_read].free) { + pthread_mutex_unlock(&(pools[curr_read].write_mutex)); + pthread_cond_wait( + &(pools[curr_read].read_cond), + &(pools[curr_read].read_mutex)); + pthread_mutex_lock(&(pools[curr_read].write_mutex)); + } + pthread_mutex_unlock(&(pools[curr_read].read_mutex)); + buffer = pools[curr_read].buffer_ptr[index]; + bytes_in_buff = + &pools[curr_read].bytes_in_buff[index]; + } + if (count_received_bytes > 0) { + if (parser_state) + parse_data_for_qsr4_db_file_op_rsp(ptr, count_received_bytes); + + memcpy(buffer + *bytes_in_buff, ptr, count_received_bytes); + *bytes_in_buff += count_received_bytes; + ptr += count_received_bytes; + } + } + return TRUE; +} + +/*=========================================================================== +FUNCTION buffer_full + +DESCRIPTION + This function check if buffer flush is required. + +DEPENDENCIES + valid data type to be passed in + +RETURN VALUE + 1: buffer flush needed. + 0: no buffer flush. + +SIDE EFFECTS + None + +===========================================================================*/ +static int buffer_full(unsigned int bytes_in_buff[]) +{ + int i; + + for (i = 0; i < NUM_PROC; i++) + if (buffer_init[i] == READY) + if (bytes_in_buff[i] >= DISK_FLUSH_THRESHOLD) + return 1; + + return 0; +} + +/*=========================================================================== +FUNCTION process_ext_header_packet + +DESCRIPTION + This function handles parsing an extended header packet. + +DEPENDENCIES + valid data type to be passed in + +RETURN VALUE + Bytes read from read_buffer in this function + +SIDE EFFECTS + None + +===========================================================================*/ +static int process_ext_header_packet(int dci_proc, unsigned char* read_buffer) { + + //check version of dci application + int dci_version = dci_client_tbl[dci_proc].version; + int read_bytes = 0, len = 0; + uint32 pkt_cmd_type; + void (*callback_ptr)(unsigned char *, int) = NULL; + unsigned char* buf_ptr = NULL; + + if (!read_buffer) + return 0; + + /* Move read_buffer up to account for DCI HEADER for ext header*/ + read_bytes += DCI_HEADER_LENGTH; + read_buffer += DCI_HEADER_LENGTH; + + /* Default buf_ptr to start of extended header packet */ + buf_ptr = read_buffer; + read_buffer += DCI_EXT_HDR_LENGTH; + + /* Read type of enclose packet */ + pkt_cmd_type = *(uint32 *)read_buffer; + read_buffer += DCI_HEADER_LENGTH; + + /* Read length of enclosed packet */ + len = *(uint16 *)read_buffer; + + if (dci_version > 0) { + /* Client supports ext header packets + */ + len += DCI_EXT_HDR_LENGTH + DCI_HEADER_LENGTH; + } else { + /* Client does not support ext header packets + * strip ext header + */ + read_bytes += DCI_EXT_HDR_LENGTH + DCI_HEADER_LENGTH; + buf_ptr = read_buffer; + } + + switch (pkt_cmd_type) { + case DCI_LOG_TYPE: + callback_ptr = dci_client_tbl[dci_proc].func_ptr_logs; + break; + case DCI_EVENT_TYPE: + len += DCI_EVENT_OFFSET; + callback_ptr = dci_client_tbl[dci_proc].func_ptr_events; + break; + default: + DIAG_LOGE("diag: dci: received invalid packet type %d in extended packet\n", + pkt_cmd_type); + break; + } + read_bytes += len; + + if (!callback_ptr) { + DIAG_LOGE("diag: dci: no callback function registered for packet type %d\n", + pkt_cmd_type); + return 0; + } + + (*callback_ptr)(buf_ptr, len); + return read_bytes; +} + +/*=========================================================================== +FUNCTION process_diag_payload + +DESCRIPTION + This looks at the type of data being passed and then calls + the appropriate function for processing request. + +DEPENDENCIES + valid data type to be passed in + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +static void process_diag_payload(void) +{ + int type = *(int *)read_buffer, read_bytes = 0, z; + int dci_data_len, dci_proc = DIAG_PROC_MSM; + int ret, payload_len = 0; + unsigned char* ptr = read_buffer+4; + boolean result = FALSE; + + if (num_bytes_read < (int)sizeof(type)) + return; + payload_len = num_bytes_read - sizeof(type); /* Subtract size of the data type */ + + if(type == MSG_MASKS_TYPE) { + msg_update_mask(ptr, payload_len); + update_sync_mask(MSG_MASKS_TYPE); + } else if(type == LOG_MASKS_TYPE) { + log_update_mask(ptr, payload_len); + update_sync_mask(LOG_MASKS_TYPE); + } else if(type == EVENT_MASKS_TYPE) { + event_update_mask(ptr, payload_len); + update_sync_mask(EVENT_MASKS_TYPE); + } else if(type == DCI_LOG_MASKS_TYPE) + log_update_dci_mask(ptr, payload_len); + else if(type == DCI_EVENT_MASKS_TYPE) + event_update_dci_mask(ptr, payload_len); + else if (type == PKT_TYPE || type == DCI_PKT_TYPE) { + diagpkt_LSM_process_request((void*)ptr, (uint16)payload_len, type); + } else if (type == HDLC_SUPPORT_TYPE) { + pthread_mutex_lock(&hdlc_toggle_mutex); + hdlc_disabled = *(uint8*)ptr; + pthread_mutex_unlock(&hdlc_toggle_mutex); + } + else if(type == USER_SPACE_DATA_TYPE){ + if (logging_mode != MEMORY_DEVICE_MODE) + log_to_device(ptr, logging_mode, payload_len, -1); + else { + pthread_mutex_lock(&(pools[curr_read].write_mutex)); + + /* Wait if no buffer is free */ + pthread_mutex_lock(&(pools[curr_read].read_mutex)); + if (!pools[curr_read].free) { + pthread_mutex_unlock(&(pools[curr_read].write_mutex)); + pthread_cond_wait( + &(pools[curr_read].read_cond), + &(pools[curr_read].read_mutex)); + pthread_mutex_lock(&(pools[curr_read].write_mutex)); + } + pthread_mutex_unlock(&(pools[curr_read].read_mutex)); + + /* One buffer got free continue writing */ + result = fill_pkt_buffer(ptr); + if (result == FALSE) { + pthread_mutex_unlock(&pools[curr_read].write_mutex); + return; + } + + pthread_mutex_unlock(&pools[curr_read].write_mutex); + } + } + else if(type == DCI_DATA_TYPE) { + if (!dci_client_tbl) + return; + + dci_proc = *(int *)ptr; + if (!IS_VALID_DCI_PROC(dci_proc)) + return; + ptr += sizeof(int); + dci_data_len = *(int *)ptr; + ptr += DCI_LEN_FIELD_LENGTH; + while (read_bytes < dci_data_len) { + if (dci_client_tbl->data_signal_flag == ENABLE) + if (raise(dci_client_tbl->data_signal_type)) + DIAG_LOGE("diag: dci: signal sending failed"); + if (*(int *)ptr == DCI_PKT_RSP_TYPE) { + ptr += DCI_HEADER_LENGTH; + read_bytes += DCI_HEADER_LENGTH; + lookup_pkt_rsp_transaction(ptr, dci_proc); + read_bytes += DCI_LEN_FIELD_LENGTH + DCI_DEL_FLAG_LEN + *(int *)(ptr); + ptr += DCI_LEN_FIELD_LENGTH + DCI_DEL_FLAG_LEN + *(int *)(ptr); + } else if (*(int *)ptr == DCI_LOG_TYPE) { + ptr += DCI_HEADER_LENGTH; + read_bytes += DCI_HEADER_LENGTH; + if (dci_client_tbl[dci_proc].func_ptr_logs) + (*(dci_client_tbl[dci_proc].func_ptr_logs))(ptr, *(uint16 *)(ptr)); + else + DIAG_LOGE("diag: dci: no callback function registered for received log stream\n"); + read_bytes += *(uint16 *)(ptr); + ptr += *(uint16 *)(ptr); + } else if (*(int *)ptr == DCI_EVENT_TYPE) { + ptr += DCI_HEADER_LENGTH; + read_bytes += DCI_HEADER_LENGTH; + if (dci_client_tbl[dci_proc].func_ptr_events) + (*(dci_client_tbl[dci_proc].func_ptr_events))(ptr, DCI_EVENT_OFFSET + *(uint16 *)(ptr)); + else + DIAG_LOGE("diag: dci: no callback function registered for received event stream\n"); + read_bytes += DCI_EVENT_OFFSET + *(uint16 *)(ptr); + ptr += DCI_EVENT_OFFSET + *(uint16 *)(ptr); + } else if (*(int *)ptr == DCI_EXT_HDR_TYPE) { + ret = process_ext_header_packet(dci_proc, ptr); + read_bytes += ret; + ptr += ret; + } else { + DIAG_LOGE("diag: dci: unknown log type %d\n", *(int *)ptr); + break; + } + } + } +} + +static void get_time_string(char *buffer, int len) +{ + struct timeval tv; + struct tm *tm; + unsigned long long milliseconds = 0; + char timestamp_buf[30]; + + if (!buffer || len <= 0) + return; + + gettimeofday(&tv, NULL); + tm = localtime(&tv.tv_sec); + + if (!tm) + return; + + milliseconds = (tv.tv_sec * 1000LL) + (tv.tv_usec / 1000); + strftime(timestamp_buf, 30, "%Y%m%d_%H%M%S", tm); + + (void)std_strlprintf(buffer, len, "%s%lld", + timestamp_buf, milliseconds); +} + +static void rename_logging_directory(void) +{ + char timestamp_buf[30]; + char new_dirname[FILE_NAME_LEN]; + char rename_cmd[RENAME_CMD_LEN]; + int replace_pos = -1; + int index = 0; + int len = 0; + int status = 0; + int i; + + if (!rename_dir_name) + return; + + /* Loop backwards through the MSM directory name to find the date/time sub-directory */ + len = strlen(output_dir[0]); + index = len - 1; + for (i = 0; i < len, index >= 0; i++) { + if (output_dir[0][index] == '/') { + if (index != len - 1) { + replace_pos = index + 1; + break; + } + } else if ((output_dir[0][index] != '_') && + (output_dir[0][index] < '0') && + (output_dir[0][index] > '9')) { + /* The last subdirectory is not in date/time format, + * do not rename the directory */ + replace_pos = -1; + break; + } + index--; + } + + if (replace_pos < 0) { + DIAG_LOGE("diag: In %s, Not able to rename directory, invalid directory format, dir: %s\n", + __func__, output_dir[0]); + return; + } + + get_time_string(timestamp_buf, sizeof(timestamp_buf)); + + strlcpy(new_dirname, output_dir[0], FILE_NAME_LEN); + new_dirname[replace_pos] = '\0'; + strlcat(new_dirname, timestamp_buf, FILE_NAME_LEN); + + /* Create rename command and issue it */ + (void)std_strlprintf(rename_cmd, RENAME_CMD_LEN, "mv %s %s", + output_dir[0], new_dirname); + + status = system(rename_cmd); + if (status == -1) { + DIAG_LOGE("diag: In %s, Directory rename error (mv), errno: %d\n", + __func__, errno); + DIAG_LOGE("diag: Unable to rename directory %s to %s\n", + output_dir[0], new_dirname); + } else { + /* Update current directory names */ + for (i = 0; i < NUM_PROC; i++) + strlcpy(output_dir[i], new_dirname, FILE_NAME_LEN); + DIAG_LOGE("diag: Renamed logging directory to: %s\n", + output_dir[0]); + } +} + +void diag_get_peripheral_name_from_mask(char *buf, + unsigned int len, + unsigned int peripheral_mask) +{ + + if (!buf || !len) + return; + + if (peripheral_mask & DIAG_CON_APSS) { + strlcat(buf, "_apps", len); + peripheral_mask = peripheral_mask ^ DIAG_CON_APSS; + } + if (peripheral_mask & DIAG_CON_MPSS) { + strlcat(buf, "_mpss", len); + peripheral_mask = peripheral_mask ^ DIAG_CON_MPSS; + } + if (peripheral_mask & DIAG_CON_LPASS) { + strlcat(buf, "_adsp", len); + peripheral_mask = peripheral_mask ^ DIAG_CON_LPASS; + } + if (peripheral_mask & DIAG_CON_WCNSS) { + strlcat(buf, "_wcnss", len); + peripheral_mask = peripheral_mask ^ DIAG_CON_WCNSS; + } + if (peripheral_mask & DIAG_CON_SENSORS) { + strlcat(buf, "_slpi", len); + peripheral_mask = peripheral_mask ^ DIAG_CON_SENSORS; + } + + if (peripheral_mask > 0) + DIAG_LOGE("diag: Invalid peripheral mask set %d", peripheral_mask); + +} + +static void close_logging_file(int type) +{ + close(fd_md[type]); + fd_md[type] = -1; + + if (rename_file_names && file_name_curr[type][0] != '\0') { + int status; + char timestamp_buf[30]; + char new_filename[FILE_NAME_LEN]; + char rename_cmd[RENAME_CMD_LEN]; + + get_time_string(timestamp_buf, sizeof(timestamp_buf)); + + if (!hdlc_disabled) { + if (diag_peripheral_mask) + (void)std_strlprintf(new_filename, + FILE_NAME_LEN, "%s%s%s%s%s%s", + output_dir[type], "/diag_log", + peripheral_name, "_", + timestamp_buf, ".qmdl"); + else + (void)std_strlprintf(new_filename, + FILE_NAME_LEN, "%s%s%s%s", + output_dir[type], "/diag_log_", + timestamp_buf, ".qmdl"); + } + else { + if (diag_peripheral_mask) + (void)std_strlprintf(new_filename, + FILE_NAME_LEN, "%s%s%s%s%s%s", + output_dir[type], "/diag_log", + peripheral_name, "_", timestamp_buf, ".qmdl2"); + else + (void)std_strlprintf(new_filename, + FILE_NAME_LEN, "%s%s%s%s", + output_dir[type],"/diag_log_", + timestamp_buf, ".qmdl2"); + } + /* Create rename command and issue it */ + (void)std_strlprintf(rename_cmd, RENAME_CMD_LEN, "mv %s %s", + file_name_curr[type], new_filename); + + status = system(rename_cmd); + if (status == -1) { + DIAG_LOGE("diag: In %s, File rename error (mv), errno: %d\n", + __func__, errno); + DIAG_LOGE("diag: Unable to rename file %s to %s\n", + file_name_curr[type], new_filename); + } else { + /* Update current filename */ + strlcpy(file_name_curr[type], new_filename, FILE_NAME_LEN); + } + } +} + +#define S_64K (64*1024) +void *WriteToDisk (void *ptr) +{ + unsigned int i; + int z; + unsigned int chunks, last_chunk; + (void) ptr; + + while (1) { + pthread_mutex_lock(&(pools[curr_write].write_mutex)); + if (!pools[curr_write].data_ready){ + pthread_cond_wait(&(pools[curr_write].write_cond), + &(pools[curr_write].write_mutex)); + } + write_in_progress = 1; + + for (z = 0; z < NUM_PROC; z++) { + if (buffer_init[z] == READY) { + chunks = pools[curr_write].bytes_in_buff[z] / + S_64K; + last_chunk = + pools[curr_write].bytes_in_buff[z] % + S_64K; + for(i = 0; i < chunks; i++){ + log_to_device( + pools[curr_write].buffer_ptr[z], + MEMORY_DEVICE_MODE, S_64K, z); + pools[curr_write].buffer_ptr[z] += + S_64K; + } + if( last_chunk > 0) + log_to_device( + pools[curr_write].buffer_ptr[z], + MEMORY_DEVICE_MODE, last_chunk, z); + if ((logging_mode == MEMORY_DEVICE_MODE) && + (count_written_bytes[z] >= max_file_size)) { + close_logging_file(z); + fd_dev = fd_md[z]; + count_written_bytes[z] = 0; + } + } + } + + write_in_progress = 0; + + /* File pool structure */ + pools[curr_write].free = 1; + pools[curr_write].data_ready = 0; + + for (z = 0; z < NUM_PROC; z++) { + if (buffer_init[z] == READY) { + pools[curr_write].bytes_in_buff[z] = 0; + if(curr_write) + pools[curr_write].buffer_ptr[z] = + pool1_buffers[z]; + else + pools[curr_write].buffer_ptr[z] = + pool0_buffers[z]; + } + } + + if ( flush_log == 2){ + for (z = 0; z < NUM_PROC; z++) { + if (buffer_init[z] == READY) { + close_logging_file(z); + } + } + + if (rename_dir_name) { + rename_logging_directory(); + } + + pthread_mutex_unlock( + &(pools[curr_write].write_mutex)); + DIAG_LOGE(" Exiting....%s \n", __func__); + pthread_mutex_lock(&stop_mutex); + flush_log++; + pthread_mutex_unlock(&stop_mutex); + pthread_exit(NULL); + } + /* Free Read thread if waiting on same buffer */ + pthread_mutex_lock(&(pools[curr_write].read_mutex)); + pthread_cond_signal(&(pools[curr_write].read_cond)); + pthread_mutex_unlock(&(pools[curr_write].read_mutex)); + pthread_mutex_unlock(&(pools[curr_write].write_mutex)); + + curr_write = !curr_write; + } + return NULL; +} + +static void delete_oldest_file_list(int type) +{ + if (type >= 0 && type < NUM_PROC) { + if (file_list[type]) + free(file_list[type]); + file_list[type] = NULL; + file_list_index[type] = -1; + file_list_size[type] = 0; + } +} + +#define LOG_FILENAME_PREFIX_LEN 9 + +static int create_oldest_file_list(char *oldest_dir, int type) +{ + struct dirent **dirent_list = NULL; + int num_entries = 0; + int num_entries_capped = 0; + char *name_ptr; + int i; + int status = 1; + int num_bytes = 0; + + if (type < 0 || type >= NUM_PROC) { + DIAG_LOGE("diag: In %s, Invalid type: %d, for directory: %s\n", + __func__, type, oldest_dir); + return 0; + } + + /* If we need to find what files are in the directory */ + if (NULL == file_list[type]) { + DIAG_LOGE("diag: Determining contents of directory %s for circular logging ...\n", + oldest_dir); + num_entries = scandir(oldest_dir, &dirent_list, 0, + (int(*)(const struct dirent **, const struct dirent **))alphasort); + if(!dirent_list) { + DIAG_LOGE("diag: In %s, couldn't get the dirent_list, errno: %d, directory: %s\n", + __func__, errno, oldest_dir); + return 0; + } else if (num_entries < 0) { + DIAG_LOGE("diag: In %s, error determining directory entries, errno: %d, directory: %s\n", + __func__, errno, oldest_dir); + return 0; + } + + /* Limit the size of the list so we aren't working with too many files */ + num_entries_capped = (num_entries > MAX_FILES_IN_FILE_LIST) ? + MAX_FILES_IN_FILE_LIST : num_entries; + + /* We don't need the files "." and ".." */ + if (num_entries_capped - 2 > 0) { + file_list_size[type] = num_entries_capped - 2; + + num_bytes = FILE_LIST_NAME_SIZE * file_list_size[type]; + file_list[type] = malloc(num_bytes); + } + + /* If the directory contains some files */ + if (file_list[type]) { + file_list_index[type] = 0; + + /* Copy the file names into our list */ + for (i = 0; i < num_entries_capped; i++) + { + /* Don't copy any file names that are not logging files */ + if (strncmp(dirent_list[i]->d_name, "diag_log_", + LOG_FILENAME_PREFIX_LEN) != 0) + continue; + + if (file_list_index[type] < file_list_size[type]) { + name_ptr = file_list[type] + + (file_list_index[type] * FILE_LIST_NAME_SIZE); + strlcpy(name_ptr, dirent_list[i]->d_name, FILE_LIST_NAME_SIZE); + *(name_ptr + (FILE_LIST_NAME_SIZE - 1)) = 0; + file_list_index[type]++; + } + } + if (file_list_index[type] > 0) { + if (file_list_index[type] < file_list_size[type]) { + /* There are files in the directory that are + * not logging files. Reduce the memory size + * allocated to the list */ + int new_size = FILE_LIST_NAME_SIZE *file_list_index[type]; + char *temp_ptr = realloc(file_list[type], new_size); + if (temp_ptr) + file_list[type] = temp_ptr; + } + file_list_size[type] = file_list_index[type]; + file_list_index[type] = 0; + } else { + /* There were no logging files in the directory. Clean up */ + delete_oldest_file_list(type); + } + } else if (num_bytes > 0) { + DIAG_LOGE("diag: In %s, memory allocation error for directory: %s, type: %d\n", + __func__, oldest_dir, type); + status = 0; + } + + /* Deallocate directory entry list */ + i = num_entries; + while (i--) { + free(dirent_list[i]); + } + free(dirent_list); + } + + return status; +} + +static int get_oldest_file(char* oldest_file, char *oldest_dir, int type) +{ + int status = 0; + + if (type < 0 || type >= NUM_PROC) { + DIAG_LOGE("diag: In %s, Invalid type: %d, for directory: %s\n", + __func__, type, oldest_dir); + return 0; + } + + /* If we need to find what files are in the directory */ + if (NULL == file_list[type]) + status = create_oldest_file_list(oldest_dir, type); + + if (file_list[type]) { + if (oldest_file) { + strlcpy(oldest_file, (file_list[type] + + (file_list_index[type] * FILE_LIST_NAME_SIZE)), + FILE_LIST_NAME_SIZE); + file_list_index[type]++; + /* If we have exhausted the list */ + if (file_list_index[type] >= file_list_size[type]) { + /* Deallocate the file list and set up for determining + * directory entries on next call */ + delete_oldest_file_list(type); + } + status = 1; + } else { + DIAG_LOGE("diag: In %s, oldest_file is NULL\n", __func__); + } + } else { + status = 0; + if (file_list_size[type] == 0) { + /* The directory does not have any logging files in it, + * so we must return an error status since we cannot return + * an oldest file name */ + DIAG_LOGE("diag: In %s, Directory %s contains no logging files\n", + __func__, oldest_dir); + } else { + DIAG_LOGE("diag: In %s, Error determining directory file list for directory: %s, type: %d\n", + __func__, oldest_dir, type); + } + } + + return status; +} + +int delete_log(int type) +{ + int status; + char oldest_file[FILE_LIST_NAME_SIZE] = ""; + struct stat file_stat = {}; + + status = get_oldest_file(oldest_file, + output_dir[type], type); + if (0 == status) { + DIAG_LOGE("diag: In %s, Unable to determine oldest file for deletion\n", + __func__); + return -1; + } + + std_strlprintf(file_name_del, + FILE_NAME_LEN, "%s%s%s", + output_dir[type], "/", oldest_file); + + if (!strncmp(file_name_curr[type], file_name_del, FILE_NAME_LEN)) { + DIAG_LOGE("diag: In %s, Cannot delete file, file %s is in use \n", + __func__, file_name_curr[type]); + return -1; + } + + stat(file_name_del, &file_stat); + + /* Convert size to KB */ + file_stat.st_size /= 1024; + + if (unlink(file_name_del)) { + DIAG_LOGE("diag: In %s, Unable to delete file: %s, errno: %d\n", + __func__, file_name_del, errno); + return -1; + } else { + DIAG_LOGE("diag: In %s, Deleting logfile %s of size %lld KB\n", + __func__, file_name_del, + (long long int) file_stat.st_size); + } + return 0; +} + +static void get_circular_logging_info(int type) +{ + if (type < 0 || type >= NUM_PROC) + return; + + if (!circular_logging_inited && !file_list[type]) { + char dir_name[FILE_NAME_LEN]; + strlcpy(dir_name, output_dir[type], FILE_NAME_LEN); + if (buffer_init[type] != READY) { + /* The output directory name has not been fully constructed yet */ + (void)strlcat(dir_name, proc_name[type], FILE_NAME_LEN); + } + create_oldest_file_list(dir_name, type); + } +} + +static void init_circular_logging(void) +{ + int i; + int num_lists = 0; + + file_count = 0; + for (i = 0; i < NUM_PROC; i++) { + if (file_list[i] && file_list_size[i] > 0) { + file_count += file_list_size[i]; + num_lists++; + } + } + + /* If circular logging is enabled and there are too many logging files on the SD card */ + if(max_file_num > 1 && (file_count >= max_file_num)) { + int status = -1; + DIAG_LOGE("diag: Initializing circular logging, reducing number of pre-existing logging files, current: %d, max: %d\n", + file_count, max_file_num); + while ((file_count >= max_file_num) && (num_lists > 0)) { + /* Iterate over the lists to reduce the logging files + * in each logging directory one by one */ + num_lists = 0; + for (i = 0; i < NUM_PROC; i++) { + if (file_list[i] && file_list_size[i] > 0) { + status = delete_log(i); + /* Break out if there was an error */ + if (status) + break; + + file_count--; + num_lists++; + } + } + } + + if (status) { + DIAG_LOGE("diag: In %s, Problem initializing circular logging, continuing ...\n", + __func__); + } + } +} + +/* + * NOTE: Please always pass type as -1, type is only valid for mdlog. + * + */ +void log_to_device(unsigned char *ptr, int logging_mode, int size, int type) +{ + uint32 count_received_bytes; + int i, ret, rc, proc = MSM, z; + int num_data_fields = 0; + unsigned char *base_ptr = ptr; + char timestamp_buf[30]; + int token; + unsigned int bytes_read = 0; + unsigned int bytes_remaining; + unsigned char *sock_ptr; + struct stat logging_file_stat; + + if (ptr == NULL || size <= 0) { + DIAG_LOGE("diag: Invalid ptr in %s size is %d\n",__func__,size); + return; + } + num_data_fields = *(int *)ptr; + bytes_remaining = size; + ptr += sizeof(int); + bytes_read += sizeof(int); + if (CALLBACK_MODE == logging_mode) { + for (i = 0; i < num_data_fields && bytes_remaining > 0; i++) { + token = valid_token(*(int *)ptr); + if (token == -1) { + DIAG_LOGE("diag: Invalid token in %s, CALLBACK MODE", __func__); + return; + } + if (token > 0) { + ptr += sizeof(int); + bytes_read += sizeof(int); + } + count_received_bytes = *(uint32 *)ptr; + ptr += sizeof(uint32); + bytes_read += sizeof(uint32); + if (!cb_clients[token].cb_func_ptr) { + DIAG_LOGE("diag: In %s, no callback function registered for proc %d\n", + __func__, token); + return; + } + + if (bytes_remaining < (bytes_read + count_received_bytes)) { + DIAG_LOGE("diag: In %s received packet of invalid length bytes remaining:%d bytes_read:%d count_received_bytes:%d\n", + __func__, bytes_remaining, bytes_read, count_received_bytes); + return; + } + + (*(cb_clients[token].cb_func_ptr))((void *) ptr, + count_received_bytes, + cb_clients[token].context_data); + ptr += count_received_bytes; + bytes_read += count_received_bytes; + bytes_remaining -= bytes_read; + bytes_read = 0; + } + return; + } + + if (type >= 0 && (buffer_init[type] == READY)) + fd_dev = fd_md[type]; + else if (logging_mode == MEMORY_DEVICE_MODE) { + DIAG_LOGE("\n Buffer not initialized %d\n", type); + return; + } + + if (fd_dev < 0) { + if(logging_mode == MEMORY_DEVICE_MODE) { + if (!circular_logging_inited) { + init_circular_logging(); + circular_logging_inited = 1; + } + /* Check if we are to start circular logging on the basis + * of maximum number of logging files in the logging + * directories on the SD card */ + if(max_file_num > 1 && (file_count >= max_file_num)) { + DIAG_LOGE("diag: In %s, File count reached max file num %d so deleting oldest file\n", + __func__, file_count); + rc = -1; + for (z = 0; z < NUM_PROC; z++) { + if (buffer_init[z] == READY) + if (!delete_log(z)) { + file_count--; + rc = 0; + } + } + + if (rc) { + DIAG_LOGE("Delete failed \n"); + return; + } + } + + /* Construct the file name using the current time stamp */ + get_time_string(timestamp_buf, sizeof(timestamp_buf)); + + if (!hdlc_disabled) { + if (diag_peripheral_mask) + (void)std_strlprintf(file_name_curr[type], + FILE_NAME_LEN, "%s%s%s%s%s%s", + output_dir[type], "/diag_log", + peripheral_name, "_", timestamp_buf, ".qmdl"); + else + (void)std_strlprintf(file_name_curr[type], + FILE_NAME_LEN, "%s%s%s%s", + output_dir[type],"/diag_log_", + timestamp_buf, ".qmdl"); + } + else { + if (diag_peripheral_mask) + (void)std_strlprintf(file_name_curr[type], + FILE_NAME_LEN, "%s%s%s%s%s%s", + output_dir[type], "/diag_log", + peripheral_name, "_", timestamp_buf, ".qmdl2"); + else + (void)std_strlprintf(file_name_curr[type], + FILE_NAME_LEN, "%s%s%s%s", + output_dir[type],"/diag_log_", + timestamp_buf, ".qmdl2"); + } + + fd_md[type] = open(file_name_curr[type], + O_CREAT | O_RDWR | O_SYNC | O_TRUNC, + 0644); + fd_dev = fd_md[type]; + if (fd_md[type] < 0) { + DIAG_LOGE(" File open error, please check"); + DIAG_LOGE(" memory device %d, errno: %d \n", + fd_md[type], errno); + } + else { + DIAG_LOGE(" creating new file %s \n", + file_name_curr[type]); + file_count++; + /* + * The qshrink4 header needs to be the first + * information written in the qmdl2 file + */ + if (hdlc_disabled) + write_qshrink_header = 1; + } + } else if ((logging_mode == UART_MODE) || + (logging_mode == SOCKET_MODE)) + DIAG_LOGE(" Invalid file descriptor\n"); + } + if (fd_dev != -1) { + if(logging_mode == MEMORY_DEVICE_MODE ){ + errno = 0; + /* + * Write the header information for the QSHRINK4 in + * case for qmdl2 file. + */ + if (hdlc_disabled && write_qshrink_header) { + write_qshrink_header = 0; + ret = write(fd_dev, (const void*)&qshrink4_data, + qshrink4_data.header_length); + if (ret > 0) + count_written_bytes[type] += + qshrink4_data.header_length; + } + if (!fstat(fd_dev, &logging_file_stat)) { + ret = write(fd_dev, (const void*) base_ptr, size); + } else { + close(fd_md[type]); + fd_md[type] = -1; + ret = -EINVAL; + } + + if ( ret > 0) { + count_written_bytes[type] += size; + }else { + DIAG_LOGE("diag: In %s, error writing to sd card, %s, errno: %d\n", + __func__, strerror(errno), errno); + if (errno == ENOSPC) { + /* Delete oldest file */ + rc = -1; + for (z = 0; z < NUM_PROC; z++) { + if (buffer_init[z] == READY) + if (!delete_log(z)) + rc = 0; + } + + if (rc) { + DIAG_LOGE("Delete failed \n"); + return; + } + + /* Close file if it is big enough */ + if(count_written_bytes[type] > + min_file_size) { + close_logging_file(type); + fd_dev = fd_md[type]; + count_written_bytes[type] = 0; + }else { + DIAG_LOGE(" Disk Full " + "Continuing with " + "same file [%d] \n", type); + } + + log_to_device(base_ptr, + MEMORY_DEVICE_MODE, size, + type); + return; + } else + DIAG_LOGE(" failed to write " + "to file, device may" + " be absent, errno: %d\n", + errno); + } + } else if (SOCKET_MODE == logging_mode) { + int is_mdm; + int token; + for (i = 0; i < num_data_fields; i++) { + if ((*(int *)ptr < 0)) { + is_mdm = 1; + token = *(int *)ptr; + ptr += 4; + } else { + is_mdm = 0; + } + + memcpy((char*)&count_received_bytes, ptr, sizeof(uint32)); + ptr += sizeof(uint32); + sock_ptr = ptr; + bytes_remaining = (int)count_received_bytes; + + if (is_mdm) { + fd_dev = get_remote_socket_fd(token); + if (fd_dev == -1) { + /* + * There is currently no socket fd for this token. + * Dismiss this data by incrementing through the buffer + * to the next data field. + */ + ptr += count_received_bytes; + continue; + } + } else { + fd_dev = fd_socket[MSM]; + } + + if (fd_dev == -1 && device_num && *(char *)(ptr + 1) == 0x0B) + fd_dev = fd_socket[device_num]; + + while ((bytes_remaining > 0) && (fd_dev != -1)) { + ret = send(fd_dev, (const void*)sock_ptr, + bytes_remaining, MSG_NOSIGNAL); + if (ret > 0) { + /* + * There is a possibility that not all + * the data was written to the socket. + * We must continue sending data on + * the socket until all the data is + * written. + */ + bytes_remaining -= ret; + count_written_bytes_1 += ret; + sock_ptr += ret; + } else { + if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { + fd_set write_fs; + int status; + FD_ZERO(&write_fs); + FD_SET(fd_dev, &write_fs); + status = select(fd_dev+1, NULL, &write_fs, NULL, NULL); + if (status == -1) { + DIAG_LOGE("In %s: Error calling select for write, %s, errno: %d\n", + __func__, strerror(errno), errno); + } else if (!FD_ISSET(fd_dev, &write_fs)) { + DIAG_LOGE("In %s: FD_ISSET is false after write select call\n", + __func__); + } + } else { + DIAG_LOGE("%s, Error writing to socket: %s, errno: %d, " + "count_received_bytes: %u\n", + __func__, strerror(errno), errno, + (unsigned int)count_received_bytes); + break; + } + } + } + ptr += count_received_bytes; + } + fd_dev = fd_socket[device_num]; + } else if (UART_MODE == logging_mode) { + for (i = 0; i < num_data_fields; i++) { + /* Check if data is from MDM Proc + * For QSC we can check -2 also and + * based on that set value of is_mdm + */ + proc = valid_token(*(int *)ptr); + if (proc > 0) + ptr += 4; + else + proc= MSM; + + memcpy((char*)&count_received_bytes,ptr,sizeof(uint32)); + ptr += sizeof(uint32); + if (proc == uart_logging_proc) { + ret = write(fd_dev, (const void*) ptr, + count_received_bytes); + if ( ret > 0) { + count_written_bytes_1 += + count_received_bytes; + } else { + DIAG_LOGE("failed to write" + "%u bytes to file," + "device may be" + "absent,errno: %d \n", + (unsigned int)count_received_bytes, + errno); + } + } + + ptr += count_received_bytes; + } + } else + DIAG_LOGE("diag: Incorrect logging mode\n"); + } +} +/*=========================================================================== +FUNCTION diag_read_mask_file + +DESCRIPTION + This reads the mask file + +DEPENDENCIES + valid data type to be passed in + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ + +int diag_read_mask_file(void) +{ + FILE *read_mask_fp; + char *open_mask_file = NULL; + unsigned char mask_buf[8192]; + int count_mask_bytes = 0; + int ch, index, i = 0; + int payload = 0, flag = 0; + int found_cmd = 0; + + *(int *)mask_buf = USER_SPACE_DATA_TYPE; + count_mask_bytes = 4; + + index = valid_token(-1 * proc_type); + if (!hdlc_disabled) { + if (!index) + open_mask_file = mask_file; + else if (index > 0) + open_mask_file = mask_file_mdm; + } else { + if (!index) + open_mask_file = mask_file2; + else if (index > 0) + open_mask_file = mask_file_mdm2; + } + + if (open_mask_file) { + if ((read_mask_fp = fopen(open_mask_file, "rb")) == NULL) { + DIAG_LOGE("Sorry, can't open mask file: %s," + " for index: %d, please check the device, errno: %d\n", + open_mask_file, index, errno); + return -1; + } + } else { + DIAG_LOGE("Invalid proc type\n"); + return -1; + } + DIAG_LOGE("Reading the mask file: %s\n", open_mask_file); + get_circular_logging_info(proc_type); + + if (!hdlc_disabled) { + while (1) { + ch = fgetc(read_mask_fp); + if (ch == EOF) + break; + if ((index > 0) && (count_mask_bytes == 4)) { + *(int *)(mask_buf + count_mask_bytes) = + token_list[index]; + count_mask_bytes = 8; + } + mask_buf[count_mask_bytes] = ch; + if (mask_buf[count_mask_bytes] == CONTROL_CHAR) { +#ifdef DIAG_DEBUG + DIAG_LOGE("********************************** \n"); + for (i = 0; i <= count_mask_bytes; i++) { + DIAG_LOGE("%2x ", mask_buf[i]); + } + DIAG_LOGE("********************************** \n"); +#endif + if (!found_cmd) + found_cmd = 1; + diag_send_data(mask_buf, count_mask_bytes+1); + *(int *)mask_buf = USER_SPACE_DATA_TYPE; + count_mask_bytes = 4; + } else + count_mask_bytes++; + } + if (!found_cmd) { + DIAG_LOGE("Sorry, could not find valid commands in the mask file," + "please check the mask file again\n"); + return -1; + } + } else { + while (1) { + ch = fgetc(read_mask_fp); + if (ch == EOF) + break; + if ((index > 0) && (count_mask_bytes == 4)) { + *(int *)(mask_buf + count_mask_bytes) = + token_list[index]; + count_mask_bytes = 8; + } + if (i > 3 && !flag) { + /* Calculate the payload */ + payload = *(uint16 *)(mask_buf + count_mask_bytes - 2); + flag = 1; + } + mask_buf[count_mask_bytes] = ch; + if (mask_buf[count_mask_bytes] != CONTROL_CHAR && i == 0) { + DIAG_LOGE("Sorry, the mask file doesn't adhere to framing definition," + "please check the mask file again\n"); + return -1; + } + if (count_mask_bytes > payload && mask_buf[count_mask_bytes] == CONTROL_CHAR && i != 0) { +#ifdef DIAG_DEBUG + DIAG_LOGE("********************************** \n"); + for (i = 0; i <= count_mask_bytes; i++) { + DIAG_LOGE("%2x ", mask_buf[i]); + } + DIAG_LOGE("********************************** \n"); +#endif + i = 0; + flag = 0; + diag_send_data(mask_buf, count_mask_bytes+1); + *(int *)mask_buf = USER_SPACE_DATA_TYPE; + count_mask_bytes = 4; + } else { + i++; + count_mask_bytes++; + } + } + } + + fclose(read_mask_fp); + + return 0; +} + +int diag_read_mask_file_list(char *mask_list_file) +{ + FILE *list_fp; + char line[FILE_NAME_LEN+8]; + char *end_ptr; + char *file_name; + long val; + int num_files = 0; + int print_help = 0; + uint16 remote_mask = 0; + uint16 mask; + int val_is_valid; + int status; + + DIAG_LOGE("Mask list file name is: %s\n", mask_list_file); + list_fp = fopen(mask_list_file, "rb"); + if (list_fp == NULL) { + DIAG_LOGE("Sorry, can't open mask list file," + "please check the device, errno: %d\n", errno); + return 0; + } + + diag_has_remote_device(&remote_mask); + while (fgets(line, (FILE_NAME_LEN+8), list_fp) != NULL) { + errno = 0; + val_is_valid = 0; + /* Discard if the line is a comment */ + if (line[0] == ';') + continue; + val = strtol(line, &end_ptr, 0); + if (((errno == ERANGE) && (val == LONG_MAX || val == LONG_MIN)) || + (errno != 0 && val == 0)) { + DIAG_LOGE("Skipping line. Invalid processor type found. line: %s\n", line); + print_help = 1; + continue; + } else if (end_ptr == line) { + print_help = 1; + DIAG_LOGE("Skipping line. No processor type present. line: %s\n", line); + } + + if (remote_mask) { + if ((val > 0) && (val < NUM_PROC-1)) { + mask = 1 << (val-1); + if (mask & remote_mask) { + val_is_valid = 1; + } else { + DIAG_LOGE("Skipping line. Remote processor: %ld is not present.\n", val); + continue; + } + } else if (val == 0){ + val_is_valid = 1; + } else { + DIAG_LOGE("Skipping line. Invalid processor type: %ld specified. line; %s\n", val, line); + print_help = 1; + continue; + } + } else { + if (val != 0) { + DIAG_LOGE("Skipping line. No remote processors present. proc_type: %ld, line: %s\n", val, line); + continue; + } + } + /* + * Determine the name of the mask file. We are counting on the + * call to fopen in read_mask_file to do file name validation. + */ + file_name = end_ptr; + while (*file_name != 0) { + /* Find the first non-blank */ + if (*file_name != ' ') + break; + file_name++; + } + end_ptr = file_name; + while (*end_ptr != 0) { + if (*end_ptr == ';' || *end_ptr == ' ' || + isprint(*end_ptr) == 0) { + *end_ptr = 0; + break; + } + end_ptr++; + } + + if (file_name == end_ptr) { + DIAG_LOGE("Skipping line. No file name found. line: %s\n", line); + print_help = 1; + continue; + } + proc_type = (int)val; + if (proc_type == 0) { + strlcpy(mask_file, file_name, FILE_NAME_LEN); + DIAG_LOGE("Mask list read for proc_type: %d, mask file: %s\n", + proc_type, mask_file); + } else { + strlcpy(mask_file_mdm, file_name, FILE_NAME_LEN); + DIAG_LOGE("Mask list read for proc_type: %d, mask file: %s\n", + proc_type, mask_file_mdm); + } + + status = diag_read_mask_file(); + if (status != 0) { + if (proc_type == 0) { + DIAG_LOGE("Error reading mask file: %s\n", mask_file); + } else { + DIAG_LOGE("Error reading mask file: %s\n", mask_file_mdm); + } + } else { + num_files++; + } + } + + fclose(list_fp); + + DIAG_LOGE("Reading list of mask files complete. Successfully read %d files\n", num_files); + if (print_help) { + DIAG_LOGE("File format: proc_type full_path_to_config_file\n"); + DIAG_LOGE("Supported proc_types:\n"); + DIAG_LOGE("0 - MSM\n"); + DIAG_LOGE("Additional proc_types only valid for devices with remote processors\n"); + DIAG_LOGE("1 - MDM\n"); + DIAG_LOGE("2 - MDM2\n"); + DIAG_LOGE("3 - MDM3\n"); + DIAG_LOGE("4 - MDM4\n"); + DIAG_LOGE("5 - QSC (SMUX)\n"); + } + + return num_files; +} + +static int __diag_switch_logging(struct diag_logging_mode_param_t *params, char *dir_location_msm) +{ + int z; + int err = 0; + int mode = 0; + + if (!params) + return -1; + + mode = params->req_mode; + if (mode == logging_mode) { + DIAG_LOGE("diag: no actual logging switch required\n"); + return 0; + } + + /* + * If previously logging mode is MEMORY DEVICE then flush + * the buffer as we are switching to a different + * logging mode. + */ + + if(log_to_memory) { + flush_buffer(0); + log_to_memory = 0; + } + + if(logging_mode == MEMORY_DEVICE_MODE) { + for (z = 0; z < NUM_PROC; z++) { + if (buffer_init[z] == READY) { + close_logging_file(z); + count_written_bytes[z] = 0; + pools[0].buffer_ptr[z] = pool0_buffers[z]; + pools[1].buffer_ptr[z] = pool1_buffers[z]; + } + } + } + + if(mode == MEMORY_DEVICE_MODE) { + fd_dev = -1; + peripheral_name[0] = '\0'; + if (diag_peripheral_mask) + diag_get_peripheral_name_from_mask(peripheral_name, + FILE_NAME_LEN, + diag_peripheral_mask); + pthread_create( &disk_write_hdl, NULL, WriteToDisk, NULL); + if (disk_write_hdl == 0) { + DIAG_LOGE("Failed to create write thread"); + DIAG_LOGE(" Exiting...........\n"); + if (diag_is_wakelock_init()) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + exit(-1); + } + log_to_memory = 1; + } else if(mode == UART_MODE) { + fd_dev = fd_uart; + if (dir_location_msm) + uart_logging_proc = *(int *)dir_location_msm; + } else if (mode == SOCKET_MODE) { + fd_dev = fd_socket[device_num]; + } else if (mode == CALLBACK_MODE) { + /* make sure callback function is registered */ + for (z = 0; z < NUM_PROC; z++) { + if (cb_clients[z].inited && !(cb_clients[z].cb_func_ptr)) { + DIAG_LOGE("diag: callback function not registered for proc %d\n", z); + DIAG_LOGE("diag: unable to change logging mode \n"); + return -1; + } + } + } + + err = ioctl(diag_fd, DIAG_IOCTL_SWITCH_LOGGING, params, sizeof(struct diag_logging_mode_param_t), NULL, 0, NULL, NULL); + if (err) { + DIAG_LOGE("diag: unable to switch logging mode to %d, err: %d, errno: %d\n", + mode, err, errno); + return -1; + } else { + if (logging_mode == MEMORY_DEVICE_MODE) { + DIAG_LOGE("diag: Sending signal to thread\n"); + pthread_mutex_lock(&stop_mutex); + pthread_cond_signal(&stop_cond); + pthread_mutex_unlock(&stop_mutex); + } + DIAG_LOGE(" logging switched \n"); + if (mode == MEMORY_DEVICE_MODE) { + if (!create_diag_qshrink4_db_parser_thread(diag_peripheral_mask)) { + if (diag_is_wakelock_init()) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + exit(-1); + } + } + + if (dir_location_msm && + (mode == MEMORY_DEVICE_MODE)) { + strlcpy(output_dir[MSM], dir_location_msm,FILE_NAME_LEN); + DIAG_LOGE("Output dirs %s --- %s\n", output_dir[MSM], output_dir[MDM]); + } + logging_mode = mode; + } + return 0; +} + +int diag_switch_logging_proc(struct diag_logging_mode_param_t *params) +{ + return __diag_switch_logging(params, output_dir[MSM]); +} + +/*=========================================================================== +FUNCTION diag_switch_logging + +DESCRIPTION + This switches the logging mode from default USB to memory device logging + +DEPENDENCIES + valid data type to be passed in: + In case of ODL second argument is to specify the directory location for logs In case of UART logging second argument is to specify PROC type. + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void diag_switch_logging(int requested_mode, char *dir_location_msm) +{ + uint16 remote_mask; + int err, dev_idx, device_mask = 1; + struct diag_logging_mode_param_t params; + struct diag_con_all_param_t params_con; + + params_con.diag_con_all = DIAG_CON_ALL; + + err = ioctl(diag_fd, DIAG_IOCTL_QUERY_CON_ALL, ¶ms_con, + sizeof(struct diag_con_all_param_t), NULL, 0, NULL, NULL); + if (err) { + DIAG_LOGE("diag:%s: Querying peripheral info from kernel unsupported, Using default stats, err: %d, errno: %d\n", + __func__, err, errno); + params_con.diag_con_all = DIAG_CON_ALL; + } else { + DIAG_LOGE("diag:%s: kernel supported: NUM_PERIPHERALS = %d, DIAG_CON_ALL: %d\n", + __func__, params_con.num_peripherals, params_con.diag_con_all); + } + + params.req_mode = requested_mode; + params.mode_param = DIAG_MD_PERIPHERAL; + params.peripheral_mask = params_con.diag_con_all; + params.pd_mask = 0; + params.diag_id = 0; + params.pd_val = 0; + params.peripheral = -EINVAL; + if (diag_has_remote_device(&remote_mask) == 1) { + for (dev_idx = 1; dev_idx <= NUM_PROC; dev_idx++) + if (remote_mask & 1 << (dev_idx - 1)) + device_mask = device_mask | (1 << dev_idx); + } + params.device_mask = device_mask; + __diag_switch_logging(¶ms, dir_location_msm); +} + +void diag_register_callback(int (*client_cb_func_ptr)(unsigned char *ptr, int len, void *context_data), void *context_data) +{ + int err = 0; + struct diag_callback_reg_t reg; + + if (!client_cb_func_ptr) { + DIAG_LOGE("diag: Unable to register callback\n"); + return; + } + + cb_clients[MSM].inited = 1; + cb_clients[MSM].cb_func_ptr = client_cb_func_ptr; + cb_clients[MSM].context_data = context_data; + reg.proc = MSM; + + err = ioctl(diag_fd, DIAG_IOCTL_REGISTER_CALLBACK, ®, 0, NULL, 0, NULL, NULL); + if (err) + DIAG_LOGE("diag: In %s, Unable to register with the driver, err: %d\n", __func__, err); +} + +void diag_register_remote_callback(int (*client_rmt_cb_func_ptr)(unsigned char *ptr, int len, void *context_data), int proc, void *context_data) +{ + int err = 0; + uint16 remote_proc = 0; + struct diag_callback_reg_t reg; + + if (!client_rmt_cb_func_ptr) { + DIAG_LOGE("diag: Unable to register callback\n"); + return; + } + if (proc <= 0 || proc >= NUM_PROC) { + DIAG_LOGE("diag: Invalid processor ID\n"); + return; + } + diag_has_remote_device(&remote_proc); + if ((remote_proc & proc) != proc) { + DIAG_LOGE("diag: Cannot register callback. Processor not supported, requested: %d\n", proc); + return; + } + cb_clients[proc].inited = 1; + cb_clients[proc].cb_func_ptr = client_rmt_cb_func_ptr; + cb_clients[proc].context_data = context_data; + reg.proc = proc; + + err = ioctl(diag_fd, DIAG_IOCTL_REGISTER_CALLBACK, ®, 0, NULL, 0, NULL, NULL); + if (err) + DIAG_LOGE("diag: In %s, Unable to register with the driver, err: %d\n", __func__, err); +} + +void send_mask_modem(unsigned char mask_buf[], int count_mask_bytes) +{ + diag_send_data(mask_buf, count_mask_bytes); +} + +int diag_send_data(unsigned char buf[], int bytes) +{ + int bytes_written = 0; + errno = 0; + if (diag_fd == DIAG_INVALID_HANDLE) + return 0; + + bytes_written = write(diag_fd,(const void*)buf, bytes); + if (*(int *)buf == DCI_DATA_TYPE) { + if (bytes_written != DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" DCI send data failed, bytes written: %d, error: %d\n", bytes_written, errno); + return DIAG_DCI_SEND_DATA_FAIL; + } + } else if (bytes_written != 0) + DIAG_LOGE(" Send data failed, bytes written: %d, error: %d\n", bytes_written, errno); + + return bytes_written; +} + +static int diag_callback_send_data_int(int type, int proc, unsigned char *buf, int len) +{ + int offset = CALLBACK_TYPE_LEN; + uint16 remote_proc = 0; + unsigned char data_buf[len + CALLBACK_TYPE_LEN + CALLBACK_PROC_TYPE_LEN]; + + if (proc < MSM || proc >= NUM_PROC) { + DIAG_LOGE("diag: Invalid processor ID\n"); + return -1; + } + if (len <= 0) { + DIAG_LOGE("diag: Invalid length %d in %s", len, __func__); + return -1; + } + if (!buf) { + DIAG_LOGE("diag: Invalid buffer in %s", __func__); + return -1; + } + switch (type) { + case USER_SPACE_RAW_DATA_TYPE: + case USER_SPACE_DATA_TYPE: + break; + default: + DIAG_LOGE("diag: Invalid type %d in %s\n", type, __func__); + return -1; + } + + *(int *)data_buf = type; + if (proc != MSM) { + diag_has_remote_device(&remote_proc); + if ((remote_proc & proc) != proc) { + DIAG_LOGE("diag: Processor not supported, requested: %d\n", proc); + return -1; + } + *(int *)(data_buf + offset) = -proc; + offset += CALLBACK_PROC_TYPE_LEN; + } + memcpy(data_buf + offset, buf, len); + return diag_send_data(data_buf, len + offset); +} + +int diag_callback_send_data(int proc, unsigned char * buf, int len) +{ + return diag_callback_send_data_int(USER_SPACE_RAW_DATA_TYPE, proc, buf, len); +} + +int diag_callback_send_data_hdlc(int proc, unsigned char * buf, int len) +{ + return diag_callback_send_data_int(USER_SPACE_DATA_TYPE, proc, buf, len); +} + +int diag_vote_md_real_time(int real_time) +{ + return diag_vote_md_real_time_proc(MSM, real_time); +} + +int diag_vote_md_real_time_proc(int proc, int real_time) +{ + int ret = -1; + struct real_time_vote_t vote; + + if (proc < MSM || proc > MDM) { + DIAG_LOGE("diag: invalid proc %d in %s\n", proc, __func__); + return -1; + } + + if (!(real_time == MODE_REALTIME || real_time == MODE_NONREALTIME)) { + DIAG_LOGE("diag: invalid mode change request\n"); + return -1; + } + + vote.client_id = proc; + vote.proc = DIAG_PROC_MEMORY_DEVICE; + vote.real_time_vote = real_time; + ret = ioctl(diag_fd, DIAG_IOCTL_VOTE_REAL_TIME, &vote, 0, NULL, 0, NULL, NULL); + return ret; +} + +int diag_get_real_time_status(int *real_time) +{ + return diag_get_real_time_status_proc(MSM, real_time); +} + +int diag_get_real_time_status_proc(int proc, int *real_time) +{ + int err = 0; + struct real_time_query_t query; + + if (!real_time) { + DIAG_LOGE("diag: invalid pointer in %s\n", __func__); + return -1; + } + if (proc < MSM || proc > MDM) { + DIAG_LOGE("diag: invalid proc %d in %s\n", proc, __func__); + return -1; + } + query.proc = proc; + err = ioctl(diag_fd, DIAG_IOCTL_GET_REAL_TIME, &query, 0, NULL, 0, NULL, NULL); + if (err != 0) { + DIAG_LOGE(" diag: error in getting real time status, proc: %d, err: %d, error: %d\n", proc, err, errno); + return -1; + } + + *real_time = query.real_time; + return 0; +} + +static void diag_callback_init() +{ + int i; + + for (i = 0; i < NUM_PROC; i++) { + cb_clients[i].inited = 0; + cb_clients[i].cb_func_ptr = NULL; + cb_clients[i].context_data = NULL; + } +} + +/*=========================================================================== +FUNCTION Diag_LSM_Init + +DESCRIPTION + Initializes the Diag Legacy Mapping Layer. This should be called + only once per process. + +DEPENDENCIES + Successful initialization requires Diag CS component files to be present + and accessible in the file system. + +RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean Diag_LSM_Init (byte* pIEnv) +{ + sigset_t set; + int ret, i; + (void)pIEnv; + + pthread_mutex_lock(&lsm_init_count_mutex); + if(lsm_init_count == 0) { + // Open a handle to the diag driver + if (diag_fd == DIAG_INVALID_HANDLE) { +#ifdef FEATURE_LOG_STDOUT + diag_fd = 0; // Don't need to open anything to use stdout, so fake it. +#else // not FEATURE_LOG_STDOUT + diag_fd = open("/dev/diag", O_RDWR); +#endif // FEATURE_LOG_STDOUT + + if (diag_fd == DIAG_INVALID_HANDLE) { + DIAG_LOGE(" Diag_LSM_Init: Failed to open handle to diag driver," + " error = %d", errno); + pthread_mutex_unlock(&lsm_init_count_mutex); + lsm_init_count++; + return FALSE; + } + + pthread_mutex_init(&(pools[0].write_mutex), NULL); + pthread_cond_init(&(pools[0].write_cond), NULL); + pthread_mutex_init(&(pools[0].read_mutex), NULL); + pthread_cond_init(&(pools[0].read_cond), NULL); + pthread_mutex_init(&(pools[1].write_mutex), NULL); + pthread_cond_init(&(pools[1].write_cond), NULL); + pthread_mutex_init(&(pools[1].read_mutex), NULL); + pthread_cond_init(&(pools[1].read_cond), NULL); + pthread_mutex_init(&stop_mutex, NULL); + pthread_cond_init(&stop_cond, NULL); + + flush_in_progress = 0; + + /* Allocate initial buffer of MSM data only */ +#if 0 + /* Since calloc allocation is not working */ + pool0_buffers[0] = calloc(DISK_BUF_SIZE, 1); + if(!pool0_buffers[0]) + return FALSE; + + pool1_buffers[0] = calloc(DISK_BUF_SIZE, 1); + if(!pool1_buffers[0]) { + free(pool0_buffers[0]); + return FALSE; + } +#endif + /* Manually doing the initialisation as dynamic alloc is not working */ + + pool0_buffers[0] = static_buffer[0]; + pool0_buffers[1] = static_buffer[2]; + pool0_buffers[2] = static_buffer[4]; + pool1_buffers[0] = static_buffer[1]; + pool1_buffers[1] = static_buffer[3]; + pool1_buffers[2] = static_buffer[5]; + + pools[0].bytes_in_buff[0] = pools[0].bytes_in_buff[1] = pools[0].bytes_in_buff[2] = 0; + pools[1].bytes_in_buff[0] = pools[1].bytes_in_buff[1] = pools[1].bytes_in_buff[2] = 0; + buffer_init[0] = READY; + + pools[0].buffer_ptr[0] = pool0_buffers[0]; + pools[1].buffer_ptr[0] = pool1_buffers[0]; + + pools[0].buffer_ptr[1] = pool0_buffers[1]; + pools[1].buffer_ptr[1] = pool1_buffers[1]; + + pools[0].buffer_ptr[2] = pool0_buffers[2]; + pools[1].buffer_ptr[2] = pool1_buffers[2]; + + /* Block SIGUSR2 for the main application */ + if ((sigemptyset((sigset_t *) &set) == -1) || + (sigaddset(&set, SIGUSR2) == -1)) + DIAG_LOGE("diag: Failed to initialize block set\n"); + + ret = sigprocmask(SIG_BLOCK, &set, NULL); + if (ret != 0) + DIAG_LOGE("diag: Failed to block signal for main thread\n"); + + diag_socket_init(); + gdwClientID = getpid(); + + /* Initialize buffers needed for Diag event, log, F3 services */ + + if (!DiagSvc_Malloc_Init()) + goto failure_case; + + /* Initialize the services */ + if (!Diag_LSM_Pkt_Init()) + goto failure_case; + + if (!Diag_LSM_Log_Init()) + goto failure_case; + + if (!Diag_LSM_Msg_Init()) + goto failure_case; + + if (!Diag_LSM_Event_Init()) + goto failure_case; + + if (diag_lsm_dci_init() != DIAG_DCI_NO_ERROR) + goto failure_case; + + diag_callback_init(); + + diag_qshrink4_init(); + + /* Creating read thread which listens for various masks & pkt + * requests */ + pthread_create(&read_thread_hdl, NULL, CreateWaitThread, NULL); + if (read_thread_hdl == 0) { + DIAG_LOGE("Diag_LSM.c: Failed to create read thread"); + goto failure_case; + } + /* Performe mask synchronization to ensure + * we have the masks before proceeding */ + if (!do_mask_sync()) + goto failure_case; + } + } + lsm_init_count++; + pthread_mutex_unlock(&lsm_init_count_mutex); + return TRUE; + +failure_case: + lsm_init_count++; + pthread_mutex_unlock(&lsm_init_count_mutex); + Diag_LSM_DeInit(); + return FALSE; +} + + +/*=========================================================================== + +FUNCTION Diag_LSM_DeInit + +DESCRIPTION + De-Initialize the Diag service. + +DEPENDENCIES + None. + +RETURN VALUE + FALSE = failure, else TRUE. + Currently all the internal boolean return functions called by + this function just returns TRUE w/o doing anything. + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean Diag_LSM_DeInit(void) +{ + boolean bReturn = TRUE; + int i; + + pthread_mutex_lock(&lsm_init_count_mutex); + if (lsm_init_count > 1) { + lsm_init_count--; + pthread_mutex_unlock(&lsm_init_count_mutex); + return bReturn; + } + + if (diag_fd != DIAG_INVALID_HANDLE) { + int ret; + + socket_inited = 0; + + /* Free the buffers mallocated for events, logs, messages and packet req/res */ + DiagSvc_Malloc_Exit(); + + if (!Diag_LSM_Pkt_DeInit()) + bReturn = FALSE; + + if ((ret = ioctl(diag_fd, DIAG_IOCTL_LSM_DEINIT, NULL, 0, NULL, 0, NULL, NULL)) != 1) { + DIAG_LOGE(" Diag_LSM_DeInit: DeviceIOControl failed. ret: %d, error: %d\n", ret, errno); + bReturn = FALSE; + } + + ret = pthread_join(read_thread_hdl, NULL); + if (ret != 0) { + DIAG_LOGE("diag: In %s, Error trying to join with thread: %d\n", + __func__, ret); + bReturn = FALSE; + } + + ret = close(diag_fd); + if (ret < 0) { + DIAG_LOGE("diag: In %s, error closing file, ret: %d, errno: %d\n", + __func__, ret, errno); + bReturn = FALSE; + } + + diag_fd = DIAG_INVALID_HANDLE; + + for (i = 0; i < NUM_PROC; i++) + delete_oldest_file_list(i); + circular_logging_inited = 0; + + diag_lsm_dci_deinit(); + + Diag_LSM_Log_DeInit(); + + Diag_LSM_Event_DeInit(); + + Diag_LSM_Msg_DeInit(); + } + lsm_init_count = 0; + pthread_mutex_unlock(&lsm_init_count_mutex); + return bReturn; +} /* Diag_LSM_DeInit */ + +/* Internal functions */ +static void *CreateWaitThread(void* param) +{ + sigset_t set; + int rc, z; + struct sigaction sact; + (void)param; + + sigemptyset( &sact.sa_mask ); + sact.sa_flags = 0; + sact.sa_handler = dummy_handler; + sigaction(SIGUSR2, &sact, NULL ); + + if ((sigemptyset((sigset_t *) &set) == -1) || + (sigaddset(&set, SIGUSR2) == -1)) + DIAG_LOGE("diag: Failed to initialize block set\n"); + + rc = pthread_sigmask(SIG_UNBLOCK, &set, NULL); + if (rc != 0) + DIAG_LOGE("diag: Failed to unbock signal for read thread\n"); + + do{ + if (flush_log) { + + while(write_in_progress) { + sleep(1); + } + + DIAG_LOGE(" %s exiting ...[%d]..\n", + __func__, curr_read); + pools[curr_read].data_ready = 1; + pools[curr_read].free = 0; + + for (z = 0; z < NUM_PROC; z++) { + if (curr_read) + pools[curr_read].buffer_ptr[z] = + pool1_buffers[z]; + else + pools[curr_read].buffer_ptr[z] = + pool0_buffers[z]; + } + + pthread_mutex_lock( + &pools[curr_read].write_mutex); + pthread_mutex_lock(&stop_mutex); + flush_log++; + pthread_mutex_unlock(&stop_mutex); + + pthread_cond_signal( + &pools[curr_read].write_cond); + pthread_mutex_unlock( + &pools[curr_read].write_mutex); + curr_read = !curr_read; + /* As cleanup started now wait for cleanup to + * complete. + */ + pthread_mutex_lock(&stop_mutex); + if(flush_log) + pthread_cond_wait(&stop_cond, + &stop_mutex); + pthread_mutex_unlock(&stop_mutex); + break; + }else { + in_read = 1; + num_bytes_read = read(diag_fd, (void*)read_buffer, + READ_BUF_SIZE); + + in_read = 0; + /* read might return 0 across suspend */ + if (!num_bytes_read) + continue; + if((*(int *)read_buffer == DEINIT_TYPE) || + (num_bytes_read < 0)) + break; + if(!flush_log) + process_diag_payload(); + } + }while(1); + + return 0; +} + +int diag_configure_peripheral_buffering_tx_mode(uint8 peripheral, uint8 tx_mode, + uint8 low_wm_val, uint8 high_wm_val) +{ + int err = 0; + struct diag_periph_buffering_tx_mode params; + + switch (tx_mode) { + case DIAG_STREAMING_MODE: + case DIAG_CIRCULAR_BUFFERING_MODE: + case DIAG_THRESHOLD_BUFFERING_MODE: + break; + default: + DIAG_LOGE("diag: In %s, invalid tx mode requested %d\n", __func__, tx_mode); + return -EINVAL; + } + + if (peripheral >= NUM_PERIPHERALS) { + DIAG_LOGE("diag: In %s, invalid peripheral %d\n", __func__, peripheral); + return -EINVAL; + } + + if ((((high_wm_val > 100) || (low_wm_val > 100)) || (low_wm_val > high_wm_val)) || + ((low_wm_val == high_wm_val) && ((low_wm_val != 0) && (high_wm_val != 0)))) { + DIAG_LOGE("diag: In %s, invalid watermark values, low: %d, high: %d\n", + __func__, low_wm_val, high_wm_val); + return -EINVAL; + } + + params.peripheral = peripheral; + params.mode = tx_mode; + params.low_wm_val = low_wm_val; + params.high_wm_val = high_wm_val; + + err = ioctl(diag_fd, DIAG_IOCTL_CONFIG_BUFFERING_TX_MODE, ¶ms, sizeof(params), NULL, 0, NULL, NULL); + if (err) { + DIAG_LOGE("diag: In %s, unable to set peripheral buffering mode, ret: %d, error: %d\n", + __func__, err, errno); + return err; + } + + return 1; +} + +int diag_peripheral_buffering_drain_immediate(uint8 peripheral) +{ + int err = 0; + + if (peripheral >= NUM_PERIPHERALS) { + DIAG_LOGE("diag: In %s, invalid peripheral %d\n", __func__, peripheral); + return -EINVAL; + } + + err = ioctl(diag_fd, DIAG_IOCTL_BUFFERING_DRAIN_IMMEDIATE, &peripheral, + sizeof(peripheral), NULL, 0, NULL, NULL); + if (err) { + DIAG_LOGE("diag: In %s, unable to send ioctl to drain immediate, ret: %d, error: %d\n", + __func__, err, errno); + return err; + } + + return 1; +} + +int diag_hdlc_toggle(uint8 hdlc_support) +{ + int err = 0; + errno = 0; + + if (hdlc_support > 1) { + DIAG_LOGE("diag: In %s, invalid request %d\n", __func__, hdlc_support); + return -EINVAL; + } + + err = ioctl(diag_fd, DIAG_IOCTL_HDLC_TOGGLE, &hdlc_support, + sizeof(hdlc_support), NULL, 0, NULL, NULL); + if (err) { + DIAG_LOGE("diag: In %s, unable to send ioctl to change hdlc support, ret: %d, error: %d\n", + __func__, err, errno); + return err; + } + + pthread_mutex_lock(&hdlc_toggle_mutex); + hdlc_disabled = hdlc_support; + pthread_mutex_unlock(&hdlc_toggle_mutex); + + return 1; +} + +int add_guid_to_qshrink4_header(unsigned char * guid) { + memcpy(&qshrink4_data.guid[qshrink4_data.guid_list_entry_count], guid, GUID_LEN); + qshrink4_data.guid_list_entry_count++; + qshrink4_data.header_length = qshrink4_data.header_length + GUID_LEN; + return 0; +} +void diag_set_peripheral_mask(unsigned int peripheral_mask) +{ + diag_peripheral_mask = peripheral_mask; + +} diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci.c b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci.c new file mode 100755 index 000000000..95306ba0d --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci.c @@ -0,0 +1,703 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* +# Copyright (c) 2012-2014,2016 Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + + Diag Consumer Interface (DCI) + +GENERAL DESCRIPTION + +Implementation of functions specific to DCI. + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/08/12 RA Interface Implementation for DCI I/O +03/20/12 SJ Created +===========================================================================*/ + +#include +#include "comdef.h" +#include "stdio.h" +#include "diag_lsmi.h" +#include "./../include/diag_lsm.h" +#include "diagsvc_malloc.h" +#include "diag_lsm_event_i.h" +#include "diag_lsm_log_i.h" +#include "diag_lsm_msg_i.h" +#include "diag.h" /* For definition of diag_cmd_rsp */ +#include "diag_lsm_pkt_i.h" +#include "diag_lsm_dci_i.h" +#include "diag_lsm_dci.h" +#include "diag_shared_i.h" /* For different constants */ +#include +#include +#include +#include "errno.h" +#include +#include +#include +#include +#include +#include +#include + +int dci_transaction_id; +int num_dci_proc; +struct diag_dci_client_tbl *dci_client_tbl; + +static inline int diag_dci_get_proc(int client_id) +{ + int i; + for (i = 0; i < num_dci_proc && dci_client_tbl; i++) + if (dci_client_tbl[i].client_info.client_id == client_id) + return i; + + return -1; +} + +int diag_lsm_dci_init(void) +{ + int i, num_remote_proc = 0, success = 0; + uint16 remote_proc = 0; + struct diag_dci_client_tbl *temp = NULL; + + success = diag_has_remote_device(&remote_proc); + if (success) { + for (num_remote_proc = 0; remote_proc; num_remote_proc++) + remote_proc &= remote_proc - 1; + } else { + DIAG_LOGE("diag: Unable to get remote processor info. Continuing with just the local processor\n"); + } + + num_dci_proc = num_remote_proc + 1; /* Add 1 for Local processor */ + dci_client_tbl = (struct diag_dci_client_tbl *)malloc(num_dci_proc * sizeof(struct diag_dci_client_tbl)); + if (!dci_client_tbl) + return DIAG_DCI_NO_MEM; + + dci_transaction_id = 0; + for (i = 0; i < num_dci_proc; i++) { + temp = &dci_client_tbl[i]; + temp->dci_req_buf = NULL; + diag_pkt_rsp_tracking_tbl *head = &temp->req_tbl_head; + head->next = head; + head->prev = head; + head->info = NULL; + pthread_mutex_init(&(dci_client_tbl[i].req_tbl_mutex), NULL); + temp->client_info.notification_list = 0; + temp->client_info.signal_type = 0; + temp->client_info.token = i; + temp->client_info.client_id = INVALID_DCI_CLIENT; + temp->data_signal_flag = DISABLE; + temp->data_signal_type = DIAG_INVALID_SIGNAL; + temp->func_ptr_logs = (void *)NULL; + temp->func_ptr_events = (void *)NULL; + temp->version = 0; + pthread_mutex_init(&temp->req_tbl_mutex, NULL); + } + + return DIAG_DCI_NO_ERROR; +} + +void diag_lsm_dci_deinit(void) +{ + if (dci_client_tbl) { + free(dci_client_tbl); + dci_client_tbl = NULL; + } +} + +int diag_dci_get_dci_version(void) +{ + return DCI_VERSION; +} + +int diag_dci_set_version(int client_id, int version) +{ + int proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_PARAM_FAIL; + + if (!dci_client_tbl) { + DIAG_LOGE(" diag: In %s, dci_client_tbl is NULL\n", __func__); + return DIAG_DCI_NO_REG; + } + + if (version < 0 || version > DCI_VERSION) { + DIAG_LOGE(" diag: In %s, Unsupported version req:%d cur:%d\n", + __func__, version, DCI_VERSION); + return DIAG_DCI_NOT_SUPPORTED; + } + + dci_client_tbl[proc].version = version; + return DIAG_DCI_NO_ERROR; +} + +static void dci_delete_request_entry(diag_pkt_rsp_tracking_tbl *entry) +{ + if (!entry) + return; + entry->prev->next = entry->next; + entry->next->prev = entry->prev; + free(entry->info); + free(entry); +} + +void lookup_pkt_rsp_transaction(unsigned char *ptr, int proc) +{ + int len, uid, found = 0; + uint8 delete_flag = 0; + unsigned char *temp = ptr; + diag_pkt_rsp_tracking_tbl *head = NULL, *walk_ptr = NULL; + diag_pkt_tracking_info info; + + if (!ptr) { + DIAG_LOGE(" Invalid pointer in %s\n", __func__); + return; + } + + if (!IS_VALID_DCI_PROC(proc)) { + DIAG_LOGE(" Invalid proc %d in %s\n", proc, __func__); + return; + } + + len = *(int *)temp; + temp += sizeof(int); + delete_flag = *(uint8 *)temp; + temp += sizeof(uint8); + uid = *(int *)temp; + temp += sizeof(int); + len = len - sizeof(int); /* actual length of response */ + memset(&info, 0, sizeof(diag_pkt_tracking_info)); + + pthread_mutex_lock(&(dci_client_tbl[proc].req_tbl_mutex)); + head = &dci_client_tbl[proc].req_tbl_head; + for (walk_ptr = head->next; walk_ptr && walk_ptr != head; walk_ptr = walk_ptr->next) { + if (!walk_ptr->info || walk_ptr->info->uid != uid) + continue; + /* + * Found a match. Copy the response to the buffer and call + * the corresponding response handler + */ + if (len > 0 && len <= walk_ptr->info->rsp_len) { + memcpy(&info, walk_ptr->info, sizeof(diag_pkt_tracking_info)); + memcpy(info.rsp_ptr, temp, len); + } else { + DIAG_LOGE(" Invalid response in %s, len:%d rsp_len: %d\n", __func__, len, walk_ptr->info->rsp_len); + } + /* + * Delete Flag will be set if it is safe to delete the entry. + * This means that the response is either a regular response or + * the last response in a sequence of delayed responses. + */ + if (delete_flag) + dci_delete_request_entry(walk_ptr); + found = 1; + break; + } + pthread_mutex_unlock(&(dci_client_tbl[proc].req_tbl_mutex)); + + if (found) { + if (info.func_ptr) + (*(info.func_ptr))(info.rsp_ptr, len, info.data_ptr); + } else { + DIAG_LOGE(" In %s, incorrect transaction %d, proc: %d\n", __func__, uid, proc); + } +} + +int diag_register_dci_client(int *client_id, diag_dci_peripherals *list, int proc, void *os_params) +{ + int ret = 0; + int req_buf_len = DCI_MAX_REQ_BUF_SIZE; + + /* Make place for the header - Choose the header that has maximum size */ + if (sizeof(struct diag_dci_req_header_t) > sizeof(struct diag_dci_stream_header_t)) + req_buf_len += sizeof(struct diag_dci_req_header_t); + else + req_buf_len += sizeof(struct diag_dci_stream_header_t); + + if (!client_id) + return ret; + if (!IS_VALID_DCI_PROC(proc)) + return ret; + + if (dci_client_tbl[proc].client_info.client_id != INVALID_DCI_CLIENT) { + DIAG_LOGE("diag: There is already a DCI client registered for this proc: %d\n", proc); + return DIAG_DCI_DUP_CLIENT; + } + + dci_client_tbl[proc].client_info.notification_list = *list; + dci_client_tbl[proc].client_info.signal_type = *(int *)os_params; + dci_client_tbl[proc].client_info.token = proc; + dci_client_tbl[proc].data_signal_flag = DISABLE; + dci_client_tbl[proc].data_signal_type = DIAG_INVALID_SIGNAL; + dci_client_tbl[proc].dci_req_buf = (unsigned char *)malloc(req_buf_len); + if (!dci_client_tbl[proc].dci_req_buf) + return DIAG_DCI_NO_MEM; + + ret = ioctl(diag_fd, DIAG_IOCTL_DCI_REG, &dci_client_tbl[proc].client_info, 0, NULL, 0, NULL, NULL); + + if (ret == DIAG_DCI_NO_REG || ret < 0) { + DIAG_LOGE(" could not register client, ret: %d error: %d\n", ret, errno); + dci_client_tbl[proc].client_info.client_id = INVALID_DCI_CLIENT; + *client_id = INVALID_DCI_CLIENT; + ret = DIAG_DCI_NO_REG; + } else { + dci_client_tbl[proc].client_info.client_id = ret; + *client_id = ret; + ret = DIAG_DCI_NO_ERROR; + } + + return ret; +} + +int diag_register_dci_stream(void (*func_ptr_logs)(unsigned char *ptr, int len), + void (*func_ptr_events)(unsigned char *ptr, int len)) +{ + if (!dci_client_tbl) + return DIAG_DCI_NO_MEM; + return diag_register_dci_stream_proc(dci_client_tbl[DIAG_PROC_MSM].client_info.client_id, func_ptr_logs, func_ptr_events); +} + +int diag_register_dci_stream_proc(int client_id, void(*func_ptr_logs)(unsigned char *ptr, int len), + void(*func_ptr_events)(unsigned char *ptr, int len)) +{ + int proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + + dci_client_tbl[proc].func_ptr_logs = func_ptr_logs; + dci_client_tbl[proc].func_ptr_events = func_ptr_events; + return DIAG_DCI_NO_ERROR; +} + +int diag_release_dci_client(int *client_id) +{ + int result = 0, proc; + diag_pkt_rsp_tracking_tbl *head = NULL, *walk_ptr = NULL; + + if (!client_id) + return DIAG_DCI_NO_REG; + + proc = diag_dci_get_proc(*client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + + result = ioctl(diag_fd, DIAG_IOCTL_DCI_DEINIT, client_id, 0, NULL, 0, NULL, NULL); + + if (result != DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" diag: could not remove entries, result: %d error: %d\n", result, errno); + return DIAG_DCI_ERR_DEREG; + } else { + *client_id = 0; + dci_client_tbl[proc].client_info.client_id = INVALID_DCI_CLIENT; + + /* Delete the client requests */ + pthread_mutex_lock(&(dci_client_tbl[proc].req_tbl_mutex)); + head = &dci_client_tbl[proc].req_tbl_head; + for (walk_ptr = head->next; walk_ptr && walk_ptr != head; walk_ptr = head->next) + dci_delete_request_entry(walk_ptr); + pthread_mutex_unlock(&(dci_client_tbl[proc].req_tbl_mutex)); + + free(dci_client_tbl[proc].dci_req_buf); + return DIAG_DCI_NO_ERROR; + } +} + +static diag_pkt_rsp_tracking_tbl *diag_register_dci_pkt(int proc, void (*func_ptr)(unsigned char *ptr, int len, void *data_ptr), + int uid, unsigned char *rsp_ptr, int rsp_len, void *data_ptr) +{ + diag_pkt_tracking_info *req_info = NULL; + diag_pkt_rsp_tracking_tbl *temp = NULL; + diag_pkt_rsp_tracking_tbl *new_req = NULL; + diag_pkt_rsp_tracking_tbl *head = NULL; + if (!IS_VALID_DCI_PROC(proc)) + return NULL; + + req_info = (diag_pkt_tracking_info *)malloc(sizeof(diag_pkt_tracking_info)); + if (!req_info) + return NULL; + new_req = (diag_pkt_rsp_tracking_tbl *)malloc(sizeof(diag_pkt_rsp_tracking_tbl)); + if (!new_req) { + free(req_info); + return NULL; + } + + req_info->uid = uid; + req_info->func_ptr = func_ptr; + req_info->rsp_ptr = rsp_ptr; + req_info->rsp_len = rsp_len; + req_info->data_ptr = data_ptr; + new_req->info = req_info; + new_req->next = new_req->prev = NULL; + + pthread_mutex_lock(&(dci_client_tbl[proc].req_tbl_mutex)); + head = &dci_client_tbl[proc].req_tbl_head; + temp = head->prev; + head->prev = new_req; + new_req->next = head; + new_req->prev = temp; + temp->next = new_req; + pthread_mutex_unlock(&(dci_client_tbl[proc].req_tbl_mutex)); + + return new_req; +} + +int diag_send_dci_async_req(int client_id, unsigned char buf[], int bytes, unsigned char *rsp_ptr, int rsp_len, + void (*func_ptr)(unsigned char *ptr, int len, void *data_ptr), void *data_ptr) +{ + int err = -1, proc; + diag_pkt_rsp_tracking_tbl *new_req = NULL; + struct diag_dci_req_header_t header; + unsigned char *dci_req_buf = NULL; + unsigned int header_len = sizeof(struct diag_dci_req_header_t); + + proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + + if ((bytes > DCI_MAX_REQ_BUF_SIZE) || (bytes < 1)) { + DIAG_LOGE("diag: In %s, huge packet: %d, max supported: %d\n", + __func__, bytes, DCI_MAX_REQ_BUF_SIZE); + return DIAG_DCI_HUGE_PACKET; + } + + if (!buf) { + DIAG_LOGE("diag: Request Bufffer is not set\n"); + return DIAG_DCI_NO_MEM; + } + + dci_req_buf = dci_client_tbl[proc].dci_req_buf; + + if (!dci_req_buf) { + DIAG_LOGE("diag: Request Buffer not initialized\n"); + return DIAG_DCI_NO_MEM; + } + if (!rsp_ptr) { + DIAG_LOGE("diag: Response Buffer not initialized\n"); + return DIAG_DCI_NO_MEM; + } + dci_transaction_id++; + new_req = diag_register_dci_pkt(proc, func_ptr, dci_transaction_id, rsp_ptr, rsp_len, data_ptr); + if (!new_req) + return DIAG_DCI_NO_MEM; + header.start = DCI_DATA_TYPE; + header.uid = dci_transaction_id; + header.client_id = client_id; + memcpy(dci_req_buf, &header, header_len); + memcpy(dci_req_buf + header_len, buf, bytes); + err = diag_send_data(dci_req_buf, header_len + bytes); + + /* Registration failed. Delete entry from registration table */ + if (err != DIAG_DCI_NO_ERROR) { + pthread_mutex_lock(&(dci_client_tbl[proc].req_tbl_mutex)); + dci_delete_request_entry(new_req); + pthread_mutex_unlock(&(dci_client_tbl[proc].req_tbl_mutex)); + err = DIAG_DCI_SEND_DATA_FAIL; + } + + return err; +} + +int diag_get_dci_support_list(diag_dci_peripherals *list) +{ + return diag_get_dci_support_list_proc(DIAG_PROC_MSM, list); +} + +int diag_get_dci_support_list_proc(int proc, diag_dci_peripherals *list) +{ + struct diag_dci_peripheral_list_t p_list; + int err = DIAG_DCI_NO_ERROR; + + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_PARAM_FAIL; + + if (!list) + return DIAG_DCI_NO_MEM; + + p_list.proc = proc; + err = ioctl(diag_fd, DIAG_IOCTL_DCI_SUPPORT, &p_list, 0, NULL, 0, NULL, NULL); + if (err == DIAG_DCI_NO_ERROR) + *list = p_list.list; + + return err; +} + +int diag_log_stream_config(int client_id, int set_mask, uint16 log_codes_array[], int num_codes) +{ + int err = -1, proc; + struct diag_dci_stream_header_t header; + unsigned char *dci_req_buf = NULL; + unsigned int header_len = sizeof(struct diag_dci_stream_header_t); + unsigned int data_len = sizeof(uint16) * num_codes; + + proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + if (num_codes < 1) + return DIAG_DCI_PARAM_FAIL; + dci_req_buf = dci_client_tbl[proc].dci_req_buf; + if (!dci_req_buf) + return DIAG_DCI_NO_MEM; + if (data_len > DCI_MAX_REQ_BUF_SIZE) { + DIAG_LOGE("diag: In %s, huge packet: %d/%d\n", __func__, + data_len, DCI_MAX_REQ_BUF_SIZE); + return DIAG_DCI_HUGE_PACKET; + } + + header.start = DCI_DATA_TYPE; + header.type = DCI_LOG_TYPE; + header.client_id = client_id; + header.set_flag = set_mask; + header.count = num_codes; + memcpy(dci_req_buf, &header, header_len); + memcpy(dci_req_buf + header_len, log_codes_array, data_len); + err = diag_send_data(dci_req_buf, header_len + data_len); + if (err != DIAG_DCI_NO_ERROR) + return DIAG_DCI_SEND_DATA_FAIL; + else + return DIAG_DCI_NO_ERROR; +} + +int diag_event_stream_config(int client_id, int set_mask, int event_id_array[], int num_id) +{ + int err = -1, proc; + struct diag_dci_stream_header_t header; + unsigned char *dci_req_buf = NULL; + unsigned int header_len = sizeof(struct diag_dci_stream_header_t); + unsigned int data_len = sizeof(int) * num_id; + + proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + if (num_id < 1) + return DIAG_DCI_PARAM_FAIL; + dci_req_buf = dci_client_tbl[proc].dci_req_buf; + if (!dci_req_buf) + return DIAG_DCI_NO_MEM; + if (data_len > DCI_MAX_REQ_BUF_SIZE) { + DIAG_LOGE("diag: In %s, huge packet: %d/%d\n", __func__, + data_len, DCI_MAX_REQ_BUF_SIZE); + return DIAG_DCI_HUGE_PACKET; + } + + header.start = DCI_DATA_TYPE; + header.type = DCI_EVENT_TYPE; + header.client_id = client_id; + header.set_flag = set_mask; + header.count = num_id; + memcpy(dci_req_buf, &header, header_len); + memcpy(dci_req_buf + header_len, event_id_array, data_len); + err = diag_send_data(dci_req_buf, header_len + data_len); + if (err != DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" diag: error sending log stream config\n"); + return DIAG_DCI_SEND_DATA_FAIL; + } + + return DIAG_DCI_NO_ERROR; +} + +int diag_get_health_stats(struct diag_dci_health_stats *dci_health) +{ + return diag_get_health_stats_proc(dci_client_tbl[DIAG_PROC_MSM].client_info.client_id, dci_health, DIAG_ALL_PROC); +} + +int diag_get_health_stats_proc(int client_id, struct diag_dci_health_stats *dci_health, int proc) +{ + int err = DIAG_DCI_NO_ERROR, c_proc; + struct diag_dci_health_stats_proc health_proc; + + c_proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(c_proc)) + return DIAG_DCI_NOT_SUPPORTED; + if (proc < DIAG_ALL_PROC || proc > DIAG_APPS_PROC) + return DIAG_DCI_PARAM_FAIL; + if (!dci_health) + return DIAG_DCI_NO_MEM; + + health_proc.client_id = client_id; + health_proc.proc = proc; + health_proc.health.reset_status = dci_health->reset_status; + + err = ioctl(diag_fd, DIAG_IOCTL_DCI_HEALTH_STATS, &health_proc, 0, NULL, 0, NULL, NULL); + if (err == DIAG_DCI_NO_ERROR) { + dci_health->dropped_logs = health_proc.health.dropped_logs; + dci_health->dropped_events = health_proc.health.dropped_events; + dci_health->received_logs = health_proc.health.received_logs; + dci_health->received_events = health_proc.health.received_events; + } + + return err; +} + +int diag_get_log_status(int client_id, uint16 log_code, boolean *value) +{ + int err = DIAG_DCI_NO_ERROR, proc; + struct diag_log_event_stats stats; + + proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + if (!value) + return DIAG_DCI_NO_MEM; + + stats.client_id = client_id; + stats.code = log_code; + stats.is_set = 0; + err = ioctl(diag_fd, DIAG_IOCTL_DCI_LOG_STATUS, &stats, 0, NULL, 0, NULL, NULL); + if (err != DIAG_DCI_NO_ERROR) + return DIAG_DCI_SEND_DATA_FAIL; + else + *value = (stats.is_set == 1) ? TRUE : FALSE; + + return DIAG_DCI_NO_ERROR; +} + +int diag_get_event_status(int client_id, uint16 event_id, boolean *value) +{ + int err = DIAG_DCI_NO_ERROR, proc; + struct diag_log_event_stats stats; + + proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + if (!value) + return DIAG_DCI_NO_MEM; + + stats.client_id = client_id; + stats.code = event_id; + stats.is_set = 0; + err = ioctl(diag_fd, DIAG_IOCTL_DCI_EVENT_STATUS, &stats, 0, NULL, 0, NULL, NULL); + if (err != DIAG_DCI_NO_ERROR) + return DIAG_DCI_SEND_DATA_FAIL; + else + *value = (stats.is_set == 1) ? TRUE : FALSE; + + return DIAG_DCI_NO_ERROR; +} + +int diag_disable_all_logs(int client_id) +{ + int ret = DIAG_DCI_NO_ERROR, proc; + proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + ret = ioctl(diag_fd, DIAG_IOCTL_DCI_CLEAR_LOGS, &client_id, 0, NULL, 0, NULL, NULL); + if (ret != DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" diag: error clearing all log masks, ret: %d, error: %d\n", ret, errno); + return DIAG_DCI_SEND_DATA_FAIL; + } + return ret; +} + +int diag_disable_all_events(int client_id) +{ + int ret = DIAG_DCI_NO_ERROR, proc; + + proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + ret = ioctl(diag_fd, DIAG_IOCTL_DCI_CLEAR_EVENTS, &client_id, 0, NULL, 0, NULL, NULL); + if (ret != DIAG_DCI_NO_ERROR) { + DIAG_LOGE(" diag: error clearing all event masks, ret: %d, error: %d\n", ret, errno); + return DIAG_DCI_SEND_DATA_FAIL; + } + return ret; +} + +int diag_dci_vote_real_time(int client_id, int real_time) +{ + int err = DIAG_DCI_NO_ERROR, proc; + struct real_time_vote_t vote; + + proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + + if (!(real_time == MODE_REALTIME || real_time == MODE_NONREALTIME)) { + DIAG_LOGE("diag: invalid mode change request\n"); + return DIAG_DCI_PARAM_FAIL; + } + vote.client_id = client_id; + vote.proc = DIAG_PROC_DCI; + vote.real_time_vote = real_time; + err = ioctl(diag_fd, DIAG_IOCTL_VOTE_REAL_TIME, &vote, 0, NULL, 0, NULL, NULL); + if (err == -1) { + DIAG_LOGE(" diag: error voting for real time switch, ret: %d, error: %d\n", err, errno); + err = DIAG_DCI_SEND_DATA_FAIL; + } + return DIAG_DCI_NO_ERROR; +} + +int diag_dci_get_real_time_status(int *real_time) +{ + return diag_dci_get_real_time_status_proc(DIAG_PROC_MSM, real_time); +} + +int diag_dci_get_real_time_status_proc(int proc, int *real_time) +{ + int err = DIAG_DCI_NO_ERROR; + struct real_time_query_t query; + + if (!real_time) { + DIAG_LOGE("diag: invalid pointer in %s\n", __func__); + return DIAG_DCI_PARAM_FAIL; + } + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + query.proc = proc; + err = ioctl(diag_fd, DIAG_IOCTL_GET_REAL_TIME, &query, 0, NULL, 0, NULL, NULL); + if (err != 0) { + DIAG_LOGE(" diag: error in getting real time status, proc: %d, err: %d, error: %d\n", proc, err, errno); + err = DIAG_DCI_SEND_DATA_FAIL; + } + *real_time = query.real_time; + return DIAG_DCI_NO_ERROR; +} + +int diag_register_dci_signal_data(int client_id, int signal_type) +{ + int proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + + if (signal_type <= DIAG_INVALID_SIGNAL) + return DIAG_DCI_PARAM_FAIL; + + dci_client_tbl[proc].data_signal_flag = ENABLE; + dci_client_tbl[proc].data_signal_type = signal_type; + return DIAG_DCI_NO_ERROR; +} + +int diag_deregister_dci_signal_data(int client_id) +{ + int proc = diag_dci_get_proc(client_id); + if (!IS_VALID_DCI_PROC(proc)) + return DIAG_DCI_NOT_SUPPORTED; + + if (dci_client_tbl[proc].data_signal_type == DIAG_INVALID_SIGNAL) + return DIAG_DCI_NO_REG; + + dci_client_tbl[proc].data_signal_flag = DISABLE; + dci_client_tbl[proc].data_signal_type = DIAG_INVALID_SIGNAL; + return DIAG_DCI_NO_ERROR; +} + +void diag_send_to_output(FILE *op_file, const char *str, ...) +{ + char buffer[6144]; + va_list arglist; + va_start(arglist, str); + if (!op_file) + return; + vsnprintf(buffer, 6144, str, arglist); + fprintf(op_file, "%s", buffer); + va_end(arglist); +} + diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci_i.h b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci_i.h new file mode 100755 index 000000000..c4f4037f8 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_dci_i.h @@ -0,0 +1,239 @@ +#ifndef DIAG_LSM_DCI_I_H +#define DIAG_LSM_DCI_I_H + +#ifdef __cplusplus +extern "C" +{ +#endif +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* +# Copyright (c) 2014,2016 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + + Diag Consumer Interface (DCI) Internal Header + +GENERAL DESCRIPTION: +Headers specific to DCI. This is an internal file used by Diag. + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +12/13/13 RA Created File +===========================================================================*/ + +#ifdef USE_GLIB +#include +#endif +#include "../include/diag_lsm_dci.h" + +#define DCI_PKT_RSP_TYPE 0 +#define DCI_LOG_TYPE -1 +#define DCI_EVENT_TYPE -2 +#define DCI_EXT_HDR_TYPE -3 + +#define DCI_PKT_RSP_CODE 0x93 +#define DCI_DELAYED_RSP_CODE 0x94 + +#define INVALID_DCI_CLIENT -1 +#define DCI_VERSION 1 + +extern int num_dci_proc; +#define IS_VALID_DCI_PROC(x) (((x < DIAG_PROC_MSM) || (x >= num_dci_proc)) ? 0 : 1) + +/* + * Maximum size of the packet that can be written to the kernel. All DCI data + * transactions must be restricted to this size (including DCI headers). + */ +#define DCI_MAX_REQ_BUF_SIZE (16*1024) + +/* + * Structure to maintain information about every request sent through DCI + * + * @uid: unique identifier for the request + * @func_ptr: callback function to be called on receiving a response + * @rsp_ptr: pointer to hold the response + * @rsp_len: length of the response + * @data_ptr: Additional data specified by the client + */ +typedef struct { + int uid; + void (*func_ptr)(unsigned char *, int len, void *data_ptr); + unsigned char *rsp_ptr; + int rsp_len; + void *data_ptr; +} diag_pkt_tracking_info; + +/* + * Structure to maintain a list of all requests sent by the client for bookkeeping + * purposed. The table is keyed by the UID. + * + * @info: pointer to the current request entry info struct + * @prev: pointer to the previous element in the list + * @next: pointer to the next element in the list + */ +typedef struct diag_pkt_rsp_tracking_tbl { + diag_pkt_tracking_info *info; + struct diag_pkt_rsp_tracking_tbl *prev; + struct diag_pkt_rsp_tracking_tbl *next; +} diag_pkt_rsp_tracking_tbl; + + +/* + * Structure to support Local DCI packets. Defines the header + * format for DCI packets + * + * @start: The start byte + * @version: DCI version + * @length: Length of the DCI packet + * @code: DCI Request Packet Code + * @tag: DCI Request Tag + */ +typedef PACK(struct) { + uint8 start; + uint8 version; + uint16 length; + uint8 code; + uint32 tag; +} diag_dci_pkt_header_t; + +/* + * Structure to support Local DCI Delayed response packets. + * Defines the header format of DCI Delayed Response Packets. + * + * @delayed_rsp_id: Delayed response ID of the delayed response sequence + * @dci_tag: Unique Tag for the DCI request + * @next: points to the next element in the list + * @prev: points to the prev element in the list + */ +typedef PACK(struct) diag_dci_delayed_rsp_tbl_t{ + int delayed_rsp_id; + int dci_tag; + struct diag_dci_delayed_rsp_tbl_t *next; + struct diag_dci_delayed_rsp_tbl_t *prev; +} diag_dci_delayed_rsp_tbl_t; + +/* + * Structre used to query Log or Event mask of the client. + * + * @client_id: Unique id for the client + * @code: log code or event id that is to be queried + * @is_set: pointer that will contain the result - 1 if the code is set; 0 otherwise + */ +PACK(struct) diag_log_event_stats { + int client_id; + uint16 code; + int is_set; +}; + +/* + * This holds registration information about the client. This struct is passed + * betweeen the kernel and user space. + * + * @client_id: Unique id for the client + * @notification_list: Bit mask of Channels to notify the client on channel change + * @signal_type: Signal to raise when there is a channel change + * @token: remote processor identifier + */ +PACK(struct) diag_dci_reg_tbl_t { + int client_id; + uint16 notification_list; + int signal_type; + int token; +}; + +/* + * Structure to hold DCI client information + * + * @client_info: basic information used for registration + * @func_ptr_logs: callback function for streaming logs + * @func_ptr_events: callback function for streaming events + * @data_signal_flag: flag for signaling client whenever there is incoming data + * @data_signal_type: signal to be fired when there in incoming data + * @req_tbl_head: list of all the active command requests + * @req_tbl_mutex: mutex to protect request table list + * @dci_req_buf: temporary buffer to store the requests to kernel + */ +struct diag_dci_client_tbl { + struct diag_dci_reg_tbl_t client_info; + void (*func_ptr_logs)(unsigned char *, int len); + void (*func_ptr_events)(unsigned char *, int len); + int data_signal_flag; + int data_signal_type; + int version; + struct diag_pkt_rsp_tracking_tbl req_tbl_head; + pthread_mutex_t req_tbl_mutex; + unsigned char *dci_req_buf; +}; + +extern struct diag_dci_client_tbl *dci_client_tbl; + +/* + * Header for DCI request packets + * + * @start: DCI data type identifier + * @uid: DCI request transaction id + * @client_id: unique id of the client + */ +PACK(struct) diag_dci_req_header_t { + int start; + int uid; + int client_id; +}; + +/* + * Header for DCI Log and Event Mask updates + * + * @start: DCI data type identifier + * @type: Determines if it a log mask or an event mask + * @client_id: unique id of the client + * @set_flag: flag to enable or disable the log/event codes + * @count: number of log codes or event ids + */ +PACK(struct) diag_dci_stream_header_t { + int start; + int type; + int client_id; + int set_flag; + int count; +}; + +/* + * Structure to query the health of a particular peripheral + * + * @health: pointer to the health statistics structure + * @proc: peripheral that the client is interested in + */ +PACK(struct) diag_dci_health_stats_proc { + int client_id; + struct diag_dci_health_stats health; + int proc; +}; + +/* + * Structure to query the list of peripherals supporting DCI + * + * @proc: processor that the client is interested in + * @list: bit mask for supported peripherals +*/ +PACK(struct) diag_dci_peripheral_list_t { + int proc; + diag_dci_peripherals list; +}; + +/* Internal function used by LSM to find transaction related information */ +void lookup_pkt_rsp_transaction(unsigned char *ptr, int proc); + +int diag_lsm_dci_init(void); + +void diag_lsm_dci_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* DIAG_LSM_DCI_I_H */ diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_event.c b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_event.c new file mode 100755 index 000000000..23129cdc5 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_event.c @@ -0,0 +1,414 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Legacy Service Mapping layer implementation for Events + +GENERAL DESCRIPTION + Contains main implementation of Legacy Service Mapping layer for Diagnostic + Event Services. + +EXTERNALIZED FUNCTIONS + event_report + event_report_payload + +INITIALIZATION AND SEQUENCING REQUIREMENTS + +Copyright (c) 2007-2011, 2014-2015 Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Changes for CBSP2.0 +05/01/08 JV Added support to update the copy of event_mask in this process + during initialization and also on mask change +11/12/07 mad Created + +===========================================================================*/ + + +/* ========================================================================== + Include Files +========================================================================== */ +#include "./../include/event.h" +#include "../include/diag_lsm.h" +#include "diag_lsmi.h" /* for declaration of diag Handle */ +#include "diagsvc_malloc.h" +#include "event_defs.h" +#include "diagdiag.h" +#include "eventi.h" +#include "diag_lsm_event_i.h" +#include "diag_shared_i.h" /* for definition of diag_data struct. */ + +#include "ts_linux.h" +#include +#include +#include "errno.h" +#include "stdio.h" +#include +//#include +//#include + +/*Local Function declarations*/ +static byte *event_alloc (event_id_enum_type id, uint8 payload_length, int* pAlloc_Len); + +/*this keeps track of number of failures to IDiagPkt_Send(). +This will currently be used only internally.*/ +static unsigned int gEvent_commit_to_cs_fail = 0; + +int gnDiag_LSM_Event_Initialized = 0; + +#define DCI_EVENT_MASK_SIZE 512 +unsigned char dci_cumulative_event_mask[DCI_EVENT_MASK_SIZE]; +int num_dci_clients_event; + + +//unsigned char* event_mask = NULL; + +/*=========================================================================== + +FUNCTION event_update_mask + +DESCRIPTION + Update event mask structure as per data from tool + +DEPENDENCIES + None + +RETURN VALUE + None. + +SIDE EFFECTS + None. +===========================================================================*/ +void event_update_mask(unsigned char* ptr, int len) +{ + if (!ptr || len <= 0 || !gnDiag_LSM_Event_Initialized) + return; + + if (len > EVENT_MASK_SIZE) + len = EVENT_MASK_SIZE; + + memcpy(event_mask, ptr, len); +} + +/*=========================================================================== + +FUNCTION event_update_dci_mask + +DESCRIPTION + Update cumulative dci event mask as per data passed from dci in diag kernel + +DEPENDENCIES + None + +RETURN VALUE + None. + +SIDE EFFECTS + None. +===========================================================================*/ +void event_update_dci_mask(unsigned char* ptr, int len) +{ + if (!ptr || !gnDiag_LSM_Event_Initialized || len < (int)sizeof(int)) + return; + + num_dci_clients_event = *(int *)ptr; + ptr += sizeof(int); + len -= sizeof(int); + if ( len > DCI_EVENT_MASK_SIZE) + len = DCI_EVENT_MASK_SIZE; + + /* Populating dci event mask table */ + memcpy(dci_cumulative_event_mask, ptr, len); +} + +/* Externalized functions */ +/*=========================================================================== + +FUNCTION EVENT_REPORT + +DESCRIPTION + Report an event. Published Diag API. + +DEPENDENCIES + Diag Event service must be initialized. + +RETURN VALUE + None. + +SIDE EFFECTS + None. +===========================================================================*/ +void event_report (event_id_enum_type Event_Id) +{ + if(diag_fd != -1) + { + byte *pEvent; + int Alloc_Len = 0; + pEvent = event_alloc (Event_Id, 0, &Alloc_Len); + if(pEvent) + { + int NumberOfBytesWritten = 0; + NumberOfBytesWritten = write(diag_fd, (const void*) pEvent, Alloc_Len); + if(NumberOfBytesWritten != 0) + { + DIAG_LOGE("Diag_LSM_Event: Write failed in %s, bytes written: %d, error: %d\n", + __func__, NumberOfBytesWritten, errno); + gEvent_commit_to_cs_fail++; + } + + DiagSvc_Free(pEvent, GEN_SVC_ID); + } + + } + return; +}/* event_report */ + +/*=========================================================================== + +FUNCTION EVENT_REPORT_PAYLOAD + +DESCRIPTION + Report an event with payload data. + +DEPENDENCIES + Diag Event service must be initialized. + +RETURN VALUE + None. + +SIDE EFFECTS + None. + +===========================================================================*/ +void +event_report_payload (event_id_enum_type Event_Id, uint8 Length, void *pPayload) +{ + if(diag_fd != -1) + { + byte *pEvent = NULL; + int Alloc_Len = 0; + if (Length > 0 && pPayload) + { + pEvent = event_alloc (Event_Id, Length, &Alloc_Len); + if (pEvent) + { + struct event_store_type* temp = (struct event_store_type*) (pEvent + FPOS(diag_data, rest_of_data)); + if(Length <= 2) + memcpy (&temp->payload, pPayload, Length);// Dont need the length field if payload <= 2 bytes + else + memcpy (EVENT_LARGE_PAYLOAD(temp->payload.payload), pPayload, Length); + int NumberOfBytesWritten = 0; + NumberOfBytesWritten = write(diag_fd, (const void*) pEvent, Alloc_Len); + if(NumberOfBytesWritten != 0) + { + DIAG_LOGE("Diag_LSM_Event: Write failed in %s, bytes written: %d, error: %d\n", + __func__, NumberOfBytesWritten, errno); + gEvent_commit_to_cs_fail++; + } + DiagSvc_Free(pEvent, GEN_SVC_ID); + } + + } + else + { + event_report (Event_Id); + } + } + return; +}/* event_report_payload */ + +/*========================================================================== + +FUNCTION event_alloc + +DESCRIPTION + This routine allocates an event item from the process heap and fills in + the following information: + + Event ID + Time stamp + Payload length field + + //TODO :This routine also detects dropped events and handles the reporting of + //dropped events. + +RETURN VALUE + A pointer to the allocated event is returned. + NULL if the event cannot be allocated. + The memory should be freed by the calling function, using DiagSvc_Free(). + pAlloc_Len is an output value, indicating the number of bytes allocated. + +===========================================================================*/ +static byte * +event_alloc (event_id_enum_type id, uint8 payload_length, int* pAlloc_Len) +{ + byte *pEvent = NULL; + int alloc_len = 0, header_length; + boolean mask_set = 0; + boolean dci_mask_set = 0; + + if(!gnDiag_LSM_Event_Initialized) + return NULL; + + /* int idx = 0; + printf("In event_alloc: event_mask = %x \n",(unsigned int)event_mask); + if(event_mask) + { + printf("Attempting to Read event_mask \n"); + for (idx = 0; idx < EVENT_MASK_SIZE && idx < 5; idx++) + { + printf("event_mask[%d]=%d\n",idx,event_mask[idx]); + // if(!gbRemote) + // event_mask[idx]=10; + } + } + */ + /* Verify that the event id is in the right range and that the + corresponding bit is turned on in the event mask. */ +// removed masking for Phase I + + if (id <= EVENT_LAST_ID) { + mask_set = EVENT_MASK_BIT_SET (id); + if (num_dci_clients_event > 0) { + dci_mask_set = (dci_cumulative_event_mask[(id)/8] & + (1 << ((id) & 0x07))); + } + } + if (!mask_set && !dci_mask_set) + { + //printf("event_alloc: mask check returned FALSE \n"); + mask_set = 0; + return NULL; + } + +// alloc_len = FPOS (event_store_type, payload.payload) + payload_length; + // Prototyping Diag 1.5 WM7: Adding a uint32 so the diag driver can identify this as an event. + + alloc_len = FPOS(diag_data, rest_of_data) + FPOS (struct event_store_type, payload.payload) + payload_length ; + pEvent = (byte *) DiagSvc_Malloc(alloc_len, GEN_SVC_ID); + if (pEvent) + { + struct event_store_type* temp = NULL; + diag_data* pdiag_data = (diag_data*) pEvent; + //Prototyping Diag 1.5 WM7:Fill in the fact that this is an event. + pdiag_data->diag_data_type = 0; + if (mask_set) + pdiag_data->diag_data_type |= DIAG_DATA_TYPE_EVENT; + if (dci_mask_set) + pdiag_data->diag_data_type |= DIAG_DATA_TYPE_DCI_EVENT; + + + //Prototyping Diag 1.5 WM7:Advance the pointer to point to the event_store_type part + temp = (struct event_store_type*) (pEvent + FPOS(diag_data, rest_of_data)); + + if(pAlloc_Len) + { + *pAlloc_Len = alloc_len; + } + + ts_get_lohi(&(temp->ts_lo), &(temp->ts_hi)); + temp->cmd_code = 96; + temp->event_id.event_id_field.id = id; + temp->event_id.event_id_field.time_trunc_flag = 0; + header_length = sizeof(temp->event_id) + sizeof(temp->ts_lo) + sizeof(temp->ts_hi); + + if(payload_length <= 2) + { + alloc_len--; + if(pAlloc_Len) + { + *pAlloc_Len = alloc_len; + } + else + { + DIAG_LOGE("event_alloc: Error, null pointer " + "encountered for returning allocation " + "length\n"); + } + temp->length = header_length + payload_length; + } + else + { + // Add the payload length field only if payload more than 2 bytes + temp->payload.length = payload_length; + //adding the payload length field + temp->length = header_length + sizeof(temp->payload.length) + payload_length; + } + + switch(payload_length) + { + case 0: + temp->event_id.event_id_field.payload_len = 0x0; + break; + + case 1: + temp->event_id.event_id_field.payload_len = 0x1; + break; + + case 2: + temp->event_id.event_id_field.payload_len = 0x2; + break; + + default: + temp->event_id.event_id_field.payload_len = 0x3; + } + } + + return pEvent; +} /* event_alloc */ + + /*=========================================================================== + +FUNCTION Diag_LSM_Event_Init + +DESCRIPTION + Initializes the event service + +RETURN VALUE + boolean indicating success + +SIDE EFFECTS + None. +===========================================================================*/ +boolean Diag_LSM_Event_Init(void) +{ + boolean status = TRUE; + if(!gnDiag_LSM_Event_Initialized) + { + num_dci_clients_event = 0; + memset(dci_cumulative_event_mask, 0, DCI_EVENT_MASK_SIZE); + gnDiag_LSM_Event_Initialized = TRUE; + } + return status; + +} /* Diag_LSM_Event_Init */ + +/*=========================================================================== + +FUNCTION Diag_LSM_Event_DeInit + +DESCRIPTION + Deinitializes the event service + + +SIDE EFFECTS + None. +===========================================================================*/ +void Diag_LSM_Event_DeInit(void) +{ + gnDiag_LSM_Event_Initialized = FALSE; + +} /* Diag_LSM_Event_Init */ + diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_event_i.h b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_event_i.h new file mode 100755 index 000000000..1673cab92 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_event_i.h @@ -0,0 +1,38 @@ + +#ifndef DIAG_LSM_EVENT_I_H +#define DIAG_LSM_EVENT_I_H + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Internal Header File for Event Legacy Service Mapping + +GENERAL DESCRIPTION + +Copyright (c) 2007-2011, 2014-2015 Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + +$Header: + +when who what, where, why +-------- --- --------------------------------------------------------- +11/26/07 mad Created File +===========================================================================*/ + +/* Initializes legacy service mapping for Diag event service */ +boolean Diag_LSM_Event_Init(void); + +/* Deinitializes legacy service mapping for Diag event service */ +void Diag_LSM_Event_DeInit(void); + +/* updates the copy of event_mask */ +void event_update_mask(unsigned char*, int len); + +/* updates the copy of dci event_mask */ +void event_update_dci_mask(unsigned char*, int len); + +#endif /* DIAG_LSM_EVENT_I_H */ diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_log.c b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_log.c new file mode 100755 index 000000000..c3f87915a --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_log.c @@ -0,0 +1,844 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Diag Interface + +GENERAL DESCRIPTION + Contains main implementation of Diagnostic Log Services. + +EXTERNALIZED FUNCTIONS + log_set_code + log_set_length + log_set_timestamp + log_submit + log_free + log_get_length + log_get_code + log_status + log_alloc + log_commit + log_shorten + +INITIALIZATION AND SEQUENCING REQUIREMENTS + + +Copyright (c) 2007-2011, 2014-2015, 2016 Qualcomm Technologies, Inc. +All Rights Reserved. +Confidential and Proprietary - Qualcomm Technologies, Inc. + + Edit History + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Changes for CBSP2.0 +05/01/08 JV Added support to update the copy of log_mask in this process + during initialization and also on mask change +02/11/08 JV Changed the comparison of IDiagPkt_Send()'s return value from + AEE_FAILURE to AEE_SUCCESS +01/16/08 JV Created stubs for log_on_demand_register and log_on_demand_unregister + as we do not have function pointer support for Diag 1.5A +11/20/07 JV Created + +===========================================================================*/ + + +/* ========================================================================== + Include Files +========================================================================== */ +#include "stdio.h" +#include "comdef.h" +#include "diagi.h" +#include "diagpkt.h" +#include "diagdiag.h" +#include "log.h" +#include "msg.h" +#include "log_codes.h" +#include "diagsvc_malloc.h" +#include "diag_lsm_log_i.h" +#include "diag_lsmi.h" /* for declaration of IDiagPkt handle, gpiDiagPkt */ + +#include +#include "diag_shared_i.h" /* for definition of diag_data struct, and diag datatypes. */ +#include "ts_linux.h" +#include +#include +#include "errno.h" +#include +#include "diaglogi.h" +#include "../include/diag_lsm.h" + +static int log_inited; +static int log_commit_to_cs_fail; +static int num_dci_clients_log; +static byte *log_mask; +static byte *dci_cumulative_log_mask; +static uint32 log_status_mask (log_code_type code); +static boolean log_search_mask (unsigned int log_type, unsigned int id, unsigned int item); +static boolean log_mask_enabled (const byte *xx_mask_ptr, unsigned int xx_id, + unsigned int xx_item); +static boolean log_dci_mask_enabled(const byte *xx_mask_ptr, unsigned int xx_id, + unsigned int xx_item); + +/* External Function Implementations */ +/*=========================================================================== + +FUNCTION log_update_mask + +DESCRIPTION + Update log masks as per data passed by tool + +DEPENDENCIES: + None + +RETURN VALUE + None + +SIDE EFFECTS + None +===========================================================================*/ + +void log_update_mask(unsigned char* ptr, int len) +{ + int i; + int read_len = 0; + int copy_len = 0; + diag_log_mask_update_t *src = NULL; + diag_log_mask_t *dest = NULL; + + if (!ptr || len <= (int)sizeof(diag_log_mask_update_t) || !log_inited) + return; + + dest = (diag_log_mask_t *)(log_mask); + + for (i = 0; i < MAX_EQUIP_ID && read_len < len; i++, dest++) { + src = (diag_log_mask_update_t *)(ptr + read_len); + read_len += sizeof(diag_log_mask_update_t); + dest->equip_id = src->equip_id; + dest->num_items = src->num_items; + copy_len = LOG_ITEMS_TO_SIZE(dest->num_items); + if (copy_len > MAX_ITEMS_PER_EQUIP_ID) + copy_len = MAX_ITEMS_PER_EQUIP_ID; + memcpy(dest->mask, ptr + read_len, copy_len); + read_len += LOG_ITEMS_TO_SIZE(dest->num_items); + } +} + +/*=========================================================================== + +FUNCTION log_update_dci_mask + +DESCRIPTION + Update cumulative dci log masks as per data passed from dci in diag kernel + +DEPENDENCIES: + None + +RETURN VALUE + None + +SIDE EFFECTS + None +===========================================================================*/ + +void log_update_dci_mask(unsigned char* ptr, int len) +{ + if (!ptr || !log_inited || len < (int)sizeof(int)) + return; + + num_dci_clients_log = *(int *)ptr; + ptr += sizeof(int); + len -= sizeof(int); + + if ( len > DCI_LOG_MASK_SIZE) + len = DCI_LOG_MASK_SIZE; + + memcpy(dci_cumulative_log_mask, ptr, len); +} + + +/*=========================================================================== + +FUNCTION LOG_ALLOC + +DESCRIPTION + This function allocates a buffer of size 'length' for logging data. The + specified length is the length of the entire log, including the log + header. This operation is inteneded only for logs that do not require + data accumulation. + + !!! The header is filled in automatically by this routine. + +DEPENDENCIES: + Diag log service must be initialized. + log_commit() or log_free() must be called ASAP after this call. + +RETURN VALUE + A pointer to the allocated buffer is returned on success. + If the log code is disabled or there is not enough space, NULL is returned. + +SIDE EFFECTS + Since this allocation is made from a shared resource pool, log_commit() + or log_free() must be called as soon as possible and in a timely fashion. + This allocation system has no garbage collection. Calling this routine + places the log buffer in a FIFO queue. If you hold the pointer for a + significant period of time, the diag task will be blocked waiting for + you to call log_commit(). + + If you need to log accumulated data, store the accumulated data in your + own memory space and use log_submit() to log the data. +===========================================================================*/ +void *log_alloc ( + log_code_type code, + unsigned int length +) +{ + diag_log_rsp_type *plog_pkt_ptr; /* Pointer to packet being created */ + log_header_type *phdr_ptr = NULL; + void *return_ptr = NULL; + uint32 enabled_mask = 0; + + if(-1 == diag_fd || !log_inited) + { + return NULL; + } + if (length <= sizeof(log_header_type)) + { + DIAG_LOGE(" Alloc invalid length %d", length); + } + else if ((enabled_mask = log_status_mask(code)) != 0) + { + /*------------------------------------------------ + Allocate enough for entire LOG response packet, + not just the log given. + ------------------------------------------------*/ + + /*WM7 prototyping: need to allocate bytes that indicate diag data type,.*/ + plog_pkt_ptr = (diag_log_rsp_type *) DiagSvc_Malloc + (DIAG_REST_OF_DATA_POS + FPOS (diag_log_rsp_type, log) + length, GEN_SVC_ID); + + if (plog_pkt_ptr != NULL) + { + byte* temp = (byte*)plog_pkt_ptr; + diag_data* pdiag_data = (diag_data*) plog_pkt_ptr; + //Prototyping Diag 1.5 WM7:Fill in the fact that this is a log. + pdiag_data->diag_data_type = enabled_mask; + //Prototyping Diag 1.5 WM7:Advance the pointer to point to the log_header_type part + temp += DIAG_REST_OF_DATA_POS; + plog_pkt_ptr = (diag_log_rsp_type*)temp; + + plog_pkt_ptr->cmd_code = DIAG_LOG_F; + phdr_ptr = (log_header_type *) &(plog_pkt_ptr->log); + ts_get_lohi(&(phdr_ptr->ts_lo), &(phdr_ptr->ts_hi)); + phdr_ptr->len = (uint16)length; + phdr_ptr->code = code; + + /* Fill in top of packet. */ + plog_pkt_ptr->more = 0; + plog_pkt_ptr->len = (uint16)length; + + return_ptr = (void *) &(plog_pkt_ptr->log); + } + else + { + /* Dropped a log. */ + //MSG_LOW("Dropped log 0x%x", code, 0, 0); + /* WM7 prototyping */ + DIAG_LOGE(" Dropped log 0x%x", code); + } + + } /* if valid and enabled */ + + // removed masking for Phase I + else + { + //printf("log_alloc: mask check returned FALSE \n"); + } + + return return_ptr; + +} /* log_alloc */ + + +/*=========================================================================== + +FUNCTION LOG_SHORTEN + +DESCRIPTION + This function shortens the length of a previously allocated logging buffer in + legacy code. This is used when the size of the record is not known at allocation + time.Now that diagbuf is not used in the LSM layer and we just use memory from + a pre-allocated pool, calling log_shorten, does not free the excess memory, it just + updates the length field. + +DEPENDENCIES: + Diag log service must be initialized. + This must be called prior to log_commit(). + +RETURN VALUE + None. + +===========================================================================*/ + void log_shorten ( + void *ptr, + unsigned int length + ) + { + byte *pdiag_pkt = (byte *) ptr; /* use byte* for pointer arithmetic */ + diag_log_rsp_type *pdiag_log; + + if (ptr) + { + /* WM7 Diag 1.5 prototyping */ + pdiag_pkt -= (LOG_DIAGPKT_OFFSET); + pdiag_log = (diag_log_rsp_type *) pdiag_pkt; + + if (length < pdiag_log->len) + { + /* LSM does not free any memory here. We only update + the length parameter. The entire chunk + of pre-malloced memory is freed after use */ + + /* Set the log packet length to the new length */ + pdiag_log->len = (uint16)length; + + /* log_set_length takes the log itself, not the log packet */ + log_set_length (ptr, length); + } + } + } /* log_shorten */ + +/*=========================================================================== + +FUNCTION LOG_COMMIT + +DESCRIPTION + This function commits a log buffer allocated by log_alloc(). Calling this + function tells the logging service that the user is finished with the + allocated buffer. + +DEPENDENCIES: + Diag log service must be initialized. + 'ptr' must point to the address that was returned by a prior call to + log_alloc(). + +RETURN VALUE + None. + +SIDE EFFECTS + Since this allocation is made from a shared resource pool, this must be + called as soon as possible after a log_alloc call. This operation is not + intended for logs that take considerable amounts of time ( > 0.01 sec ). +===========================================================================*/ +void log_commit (void *ptr) +{ + if (ptr) + { + log_header_type *phdr_ptr = NULL; + log_commit_last = (void *) ptr; + /* Set pointer to begining of diag pkt, not the log */ + phdr_ptr = (log_header_type *)ptr; + ptr = ((byte *) ptr - (LOG_DIAGPKT_OFFSET+DIAG_REST_OF_DATA_POS)); /* WM7 prototyping */ + if(-1 != diag_fd) + { + int NumberOfBytesWritten = 0; + if((NumberOfBytesWritten = write(diag_fd, (const void*) ptr, DIAG_REST_OF_DATA_POS+LOG_DIAGPKT_OFFSET + phdr_ptr->len)) != 0) /*TODO: Check the Numberofbyteswritten against number of bytes we wanted to write?*/ + { + DIAG_LOGE("Diag_LSM_log: Write failed in %s, bytes written: %d, error: %d\n", + __func__, NumberOfBytesWritten, errno); + log_commit_to_cs_fail++; + } + DiagSvc_Free(ptr, GEN_SVC_ID); + } + } + return; +} /* log_commit */ + +/*=========================================================================== + +FUNCTION LOG_FREE + +DESCRIPTION + This function frees the buffer in pre-allocated memory. + +DEPENDENCIES: + Diag log service must be initialized. + +RETURN VALUE + +SIDE EFFECTS + None. +===========================================================================*/ +void log_free (void *ptr) +{ + if(ptr) + { + ptr = ((byte *) ptr - (LOG_DIAGPKT_OFFSET + DIAG_REST_OF_DATA_POS)); + DiagSvc_Free(ptr, GEN_SVC_ID); + } + +} /* log_free */ + + + +/*=========================================================================== + +FUNCTION LOG_SUBMIT + +DESCRIPTION + This function is called to log an accumlated log entry. If logging is + enabled for the entry by the external device, then this function essentially + does the folliwng: + log = log_alloc (); + memcpy (log, ptr, log->len); + log_commit (log); + + +DEPENDENCIES + Diag log service must be initialized. + +RETURN VALUE + Boolean indicating success. + +SIDE EFFECTS + None. +===========================================================================*/ +#ifndef MSM5000_IRAM_FWD /* Flag to use internal RAM */ +boolean log_submit (void *ptr) +{ + boolean bReturnVal = FALSE; //# int i; + /* The header is common to all logs, and is always at the beginning of the + * packet. */ + log_header_type *plog_ptr = (log_header_type *) ptr; + uint32 enabled_mask = 0; + + if (plog_ptr && (diag_fd != -1) && log_inited) + { + /* Local vars to avoid use of misaligned variables */ + log_code_type code = plog_ptr->code; + unsigned int length = plog_ptr->len; + + if (length > sizeof(log_header_type)) + { + if ((enabled_mask = log_status_mask(code)) != 0) { + diag_data* pdiag_data = (diag_data*) + DiagSvc_Malloc(DIAG_REST_OF_DATA_POS + FPOS (diag_log_rsp_type, log) + length, GEN_SVC_ID); + if (pdiag_data != NULL) { + diag_log_rsp_type *plog_pkt_ptr = NULL; + byte* temp = (byte*)pdiag_data; + //Prototyping Diag 1.5 WM7:Fill in the fact that this is a log. + pdiag_data->diag_data_type = enabled_mask; + //Prototyping Diag 1.5 WM7:Advance the pointer to point to the log_header_type part + temp += DIAG_REST_OF_DATA_POS; + plog_pkt_ptr = (diag_log_rsp_type*)temp; + plog_pkt_ptr->cmd_code = DIAG_LOG_F; + plog_pkt_ptr->more = 0; + plog_pkt_ptr->len = (uint16)length; + memcpy (&plog_pkt_ptr->log, (void *) ptr, length); + int NumberOfBytesWritten = 0; + if((NumberOfBytesWritten = write(diag_fd, (const void*) pdiag_data, DIAG_REST_OF_DATA_POS + FPOS (diag_log_rsp_type, log) + length)) != 0) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, NumberOfBytesWritten, errno); + log_commit_to_cs_fail++; + bReturnVal = FALSE; + } + else + bReturnVal = TRUE; + DiagSvc_Free(pdiag_data, GEN_SVC_ID); + } /* if (pdiag_data != NULL) */ + else { + /* Dropped a log */ + DIAG_LOGE(" Dropped log 0x%x", code); + } + //removed masking for Phase I + }/* if (log_status (code)) */ + else { + //printf("log_submit: mask check returned FALSE \n"); + } + } /* if (length > sizeof(log_header_type)) */ + } /* if (plog_ptr) */ + return bReturnVal; + +} /* log_submit */ +#endif /* !MSM5000_IRAM_FWD */ + + + + +/*=========================================================================== + +FUNCTION LOG_SET_LENGTH + +DESCRIPTION + This function sets the length field in the given log record. + + !!! Use with caution. It is possible to corrupt a log record using this + command. It is intended for use only with accumulated log records, not + buffers returned by log_alloc(). + +DEPENDENCIES + Diag log service must be initialized. + +RETURN VALUE + None. + +SIDE EFFECTS + None. +===========================================================================*/ +void log_set_length (void *ptr, unsigned int length) +{ + if(ptr) + { + /* All log packets are required to start with 'log_header_type'. */ + ((log_header_type *) ptr)->len = (uint16) length; + } +} /* log_set_length */ + + + +/*=========================================================================== + +FUNCTION LOG_SET_CODE + +DESCRIPTION + This function sets the logging code in the given log record. + +DEPENDENCIES + Diag log service must be initialized. + + +RETURN VALUE + None. + +SIDE EFFECTS + None. +===========================================================================*/ +void log_set_code (void *ptr, log_code_type code) +{ + if (ptr) + { + /* All log packets are required to start with 'log_header_type'. */ + ((log_header_type *) ptr)->code = code; + } + +} /* log_set_code */ + + +/*=========================================================================== + +FUNCTION LOG_SET_TIMESTAMP + +DESCRIPTION + This function captures the system time and stores it in the given log record. + +DEPENDENCIES + Diag log service must be initialized. + +RETURN VALUE + None. + +SIDE EFFECTS + None. +===========================================================================*/ +void log_set_timestamp (void *plog_hdr_ptr) +{ + if (plog_hdr_ptr) + { + ts_get_lohi(&(((log_header_type *) plog_hdr_ptr)->ts_lo), + &(((log_header_type *) plog_hdr_ptr)->ts_hi)); + } +} /* log_set_timestamp */ + + +/*=========================================================================== + +FUNCTION LOG_GET_LENGTH + +DESCRIPTION + This function returns the length field in the given log record. + +DEPENDENCIES + Diag log service must be initialized. + +RETURN VALUE + An unsigned int, the length + +SIDE EFFECTS + None. +===========================================================================*/ +unsigned int log_get_length (void *ptr) +{ + unsigned int length = 0; + if(ptr) + { + log_header_type *plog = (log_header_type *) ptr; + + if (plog) + { + length = plog->len; + } + } + return length; +} + +/*=========================================================================== + +FUNCTION LOG_GET_CODE + +DESCRIPTION + This function returns the log code field in the given log record. + +DEPENDENCIES + Diag log service must be initialized. + +RETURN VALUE + log_code_type, the code + +SIDE EFFECTS + None. +===========================================================================*/ +log_code_type log_get_code (void *ptr) +{ + log_code_type code = 0; + if(ptr) + { + log_header_type *plog = (log_header_type *) ptr; + + if (plog) + { + code = (log_code_type) plog->code; + } + } + return code; +} + +/*=========================================================================== + +FUNCTION LOG_STATUS + +DESCRIPTION + This function returns whether a particular code is enabled for logging. + +DEPENDENCIES + Diag log service must be initialized. + +RETURN VALUE + boolean indicating if enabled + +SIDE EFFECTS + None. +===========================================================================*/ + boolean log_status (log_code_type code) + { + uint32 status = FALSE; + + if (log_inited) + status = log_status_mask (code); + + return (status != 0) ? TRUE : FALSE; + } /* log_status */ + + /*=========================================================================== + +FUNCTION DIAG_LSM_LOG_INIT + +DESCRIPTION + Initializes the log service + +RETURN VALUE + boolean indicating success + +SIDE EFFECTS + None. +===========================================================================*/ + +boolean Diag_LSM_Log_Init(void) +{ + if (log_inited) + return TRUE; + + log_mask = malloc(LOG_MASK_SIZE); + if (!log_mask) { + DIAG_LOGE("diag: unable to alloc memory for log mask\n"); + return FALSE; + } + + dci_cumulative_log_mask = malloc(DCI_LOG_MASK_SIZE); + if (!dci_cumulative_log_mask) { + DIAG_LOGE("diag: unable to alloc memory for dci log mask\n"); + free(log_mask); + return FALSE; + } + + num_dci_clients_log = 0; + memset(dci_cumulative_log_mask, 0, DCI_LOG_MASK_SIZE); + log_inited = TRUE; + + return TRUE; +} /* Diag_LSM_Log_Init */ + + +/*=========================================================================== +FUNCTION DIAG_LSM_LOG_DEINIT + +DESCRIPTION + Releases all resources related to logging service + +RETURN VALUE + None + +SIDE EFFECTS + None. +===========================================================================*/ +void Diag_LSM_Log_DeInit(void) +{ + if (log_mask) + free(log_mask); + if (dci_cumulative_log_mask) + free(dci_cumulative_log_mask); + + log_inited = FALSE; +} + +/*=========================================================================== + +FUNCTION LOG_STATUS_MASK + +DESCRIPTION + This routine is a wrapper for log_search_mask(). It is used to look up + the given code in the log mask. + +RETURN VALUE + A mask indicating if the specified log is enabled. + +===========================================================================*/ +static uint32 +log_status_mask (log_code_type code) +{ + unsigned int id, item; + boolean status = FALSE; + uint32 status_mask = 0; + + id = LOG_GET_EQUIP_ID (code); + item = LOG_GET_ITEM_NUM (code); + status = log_search_mask(DIAG_DATA_TYPE_LOG, id, item); + if (status) + status_mask |= DIAG_DATA_TYPE_LOG; + status = log_search_mask(DIAG_DATA_TYPE_DCI_LOG, id, item); + if (status) + status_mask |= DIAG_DATA_TYPE_DCI_LOG; + + return status_mask; +} + +/*=========================================================================== + +FUNCTION log_search_mask + +DESCRIPTION + This function returns a boolean indicating TRUE if the given ID and 'item' + denotes a valid and enabled log code from the specified log mask. + +===========================================================================*/ +static boolean log_search_mask ( + unsigned int log_type, + unsigned int id, + unsigned int item +) +{ + boolean return_val = FALSE; + /* If valid code val */ + if (log_type == DIAG_DATA_TYPE_LOG) { + if (log_mask_enabled(log_mask, id, item)) + return_val = TRUE; + } else if (num_dci_clients_log > 0 && log_type == DIAG_DATA_TYPE_DCI_LOG) { + if (log_dci_mask_enabled(dci_cumulative_log_mask, id, item)) + return_val = TRUE; + } + + return return_val; +} /* log_search_mask */ + +/*=========================================================================== + +FUNCTION LOG_MASK_ENABLED + +DESCRIPTION + This function returns a boolean indicating if the specified code is enabled. + + The equipment ID and item code are passed in to avoid duplicating the + calculation within this call. It has to be done for most routines that call + this anyways. + +===========================================================================*/ +static boolean log_mask_enabled(const byte *mask_ptr, unsigned int id, + unsigned int item) +{ + unsigned int byte_index, offset; + byte byte_mask; + const byte *ptr = NULL; + boolean enabled = FALSE; + + if (!mask_ptr) + return enabled; + + ptr = mask_ptr; + + if (id >= MAX_EQUIP_ID) { + DIAG_LOGE("diag: Invalid equip id %d in %s\n", id, __func__); + return enabled; + } + + /* + * Seek to the exact byte index in the log mask for a given + * equip id. Also include the offset of equip id (uint8) and the + * number of items in the equipment (unsigned int ) + */ + byte_index = (item/8) + sizeof(uint8) + sizeof(unsigned int); + byte_mask = 0x01 << (item % 8); + offset = (id * LOG_MASK_ITEM_SIZE) + byte_index; + + if (offset > LOG_MASK_SIZE) { + DIAG_LOGE("diag: Invalid offset %d in %s\n", offset, __func__); + return enabled; + } + + enabled = ((*(ptr + offset) & byte_mask) == byte_mask) ? TRUE: FALSE; + return enabled; +} /* log_mask_enabled */ + +/*=========================================================================== + +FUNCTION LOG_DCI_MASK_ENABLED + +DESCRIPTION + This function returns a boolean indicating if the specified code is enabled. + + The equipment ID and item code are passed in to avoid duplicating the + calculation within this call. It has to be done for most routines that call + this anyways. + +===========================================================================*/ +static boolean log_dci_mask_enabled( + const unsigned char *mask_ptr, + unsigned int id, + unsigned int item +) +{ + unsigned char byte_mask; + int byte_index, offset; + boolean enabled = FALSE; + + if (!mask_ptr) + return enabled; + + byte_index = item/8 + 2; + byte_mask = 0x01 << (item % 8); + offset = id * 514; + if ((mask_ptr[offset + byte_index] & byte_mask) == byte_mask) + enabled = TRUE; + + return enabled; +} /* log_dci_mask_enabled */ + + diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_log_i.h b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_log_i.h new file mode 100755 index 000000000..0ad9c1a78 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_log_i.h @@ -0,0 +1,47 @@ +#ifndef DIAG_LSM_LOG_I_H +#define DIAG_LSM_LOG_I_H +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + +EXTENDED DIAGNOSTIC LOG LEGACY SERVICE MAPPING HEADER FILE +(INTERNAL ONLY) + +GENERAL DESCRIPTION + + All the declarations and definitions necessary to support the reporting + of messages. This includes support for the + extended capabilities as well as the legacy messaging scheme. + +Copyright (c) 2007-2011,2014 Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +11/26/07 JV Created File +===========================================================================*/ + +typedef PACK(struct) { + uint8 equip_id; + unsigned int num_items; +} diag_log_mask_update_t; + +#define LOG_ITEMS_TO_SIZE(num_items) ((num_items + 7) / 8) + +/* Initializes legacy service mapping for Diag log service */ +boolean Diag_LSM_Log_Init(void); + +/* Releases all resources related to Diag Log Service */ +void Diag_LSM_Log_DeInit(void); + +/* updates the copy of log_mask */ +void log_update_mask(unsigned char *, int len); + +/* updates the copy of the dci log_mask */ +void log_update_dci_mask(unsigned char*, int len); + +#endif /* DIAG_LSM_LOG_I_H */ diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg.c b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg.c new file mode 100755 index 000000000..0b4a6e3ec --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg.c @@ -0,0 +1,959 @@ +/*=========================================================================== +Diag Legacy Service Mapping Layer Implementation for Debug Message +(F3 Message) Service, and Optimized Debug Message Service +(Also known as QSHRINK Message) + +GENERAL DESCRIPTION + API definitons for Debug Message Service Mapping Layer. + +EXTERNALIZED FUNCTIONS +Note: These functions should not be used directly, use the MSG_* macros instead. + msg_send + msg_send_1 + msg_send_2 + msg_send_3 + msg_send_var + msg_sprintf +Note: These functions or the relevant macros (QSR_MSG*) should not be called directly. + MSG* macros are converted to QSR_MSG* with a text replacement before build. + qsr_msg_send + qsr_msg_send_1 + qsr_msg_send_2 + qsr_msg_send_3 + qsr_msg_send_var + + +INITIALIZATION AND SEQUENCING REQUIREMENTS + +Copyright (c) 2007-2011, 2013-2015 Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential +===========================================================================*/ + +/*=========================================================================== + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Changes for CBSP 2.0 +05/01/08 JV Added support to update the copy of run-time masks in the + msg_mask_tbl in this process during initialization and also + on mask change +11/29/07 mad Created File +===========================================================================*/ + +#include "diagsvc_malloc.h" +#include "diag_lsm_msg_i.h" +#include "msg.h" +#include "msg_qsr.h" +#include "msgcfg.h" +#include "diag_lsmi.h" +#include "diag_lsm.h" +#include "diagcmd.h" +#include "diag_shared_i.h" /* for definition of diag_data struct, and diag datatypes. */ +#include "msg_pkt_defs.h" +#include "msg_arrays_i.h" + +#include +#include +#include "errno.h" +#include "stdio.h" +#include +#include +#include +#include "ts_linux.h" +#include +#include + +/* internal datatypes and defines */ +typedef struct { + uint32 args[10]; +} msg_large_args; + +typedef union { + msg_ext_type ext; +} msg_sprintf_desc_type; + +#define MSG_LARGE_ARGS(X) (((msg_large_args *)X)->args) +#define MSG_TS_TYPE 0 +#define MSG_TIME_FORMAT 3 + +#ifndef MSG_FMT_STR_ARG_SIZE +/* 280 is guess, close enough to accomodate QCRIL messages upto 252 bytes long */ +#define MSG_FMT_STR_ARG_SIZE 280 +#endif + +static uint32 msg_drop_delta; /* number of dropped messages */ +static int gnDiag_LSM_Msg_Initialized = 0; + +/* Internal function declarations */ +static boolean msg_get_ssid_rt_mask(int ssid, uint32* mask); +static byte *msg_send_prep(const msg_const_type *const_blk, unsigned int num_args, + unsigned int *pLength, uint64 timestamp, boolean ts_valid); +static byte *msg_sprintf_prep(const msg_const_type *const_blk, unsigned int num_args, + unsigned int *pLength); +static byte *qsr_msg_send_prep(const msg_qsr_const_type *const_blk, unsigned int num_args, + unsigned int *pLength); +static const char *msg_format_filename2(const char *filename); + +/*--------------------------------------------------------------------------------------------------- + Externalised functions +(Do not call any of these functions directly, use the Macros defined in msg.h instead.) +---------------------------------------------------------------------------------------------------*/ + +/*=========================================================================== +FUNCTION MSG_SEND + +DESCRIPTION + This function sends out a debug message with no arguments across DiagPkt CS interface. + Do not call directly; use macro MSG_* defined in msg.h + +DEPENDENCIES + DiagPkt handle should be initialised. +===========================================================================*/ +void msg_send(const msg_const_type *const_blk) +{ + byte *pMsg = NULL; + const unsigned int num_args = 0; + unsigned int nLength = 0; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE) + return; + + pMsg = msg_send_prep(const_blk, num_args, &nLength, 0, FALSE); + if (!pMsg) + return; + + write_len = write(diag_fd, (const void *)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + + } + + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION MSG_SEND_TS + +DESCRIPTION + This function sends out a debug message with no arguments, and uses + timestamp passed in by client. Do not call directly; use macro MSG_* + defined in msg.h + +DEPENDENCIES + diag driver handle should be initialised. +===========================================================================*/ +void msg_send_ts(const msg_const_type *const_blk, uint64 timestamp) +{ + byte *pMsg = NULL; + const unsigned int num_args = 0; + unsigned int nLength = 0; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE) + return; + + pMsg = msg_send_prep(const_blk, num_args, &nLength, timestamp, TRUE); + if (!pMsg) + return; + + write_len = write(diag_fd, (const void *) pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + + } + + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION MSG_SEND_1 + +DESCRIPTION + This function sends out a debug message with 1 argument across DiagPkt CS interface. + Do not call directly; use macro MSG_* defined in msg.h + +DEPENDENCIES + DiagPkt handle should be initialised. +===========================================================================*/ +void msg_send_1(const msg_const_type *pconst_blk, uint32 xx_arg1) +{ + byte *pMsg = NULL; + msg_ext_type *pTemp = NULL; + uint32 *args = NULL; + unsigned int nLength = 0; + const unsigned int num_args = 1; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE) + return; + + pMsg = msg_send_prep(pconst_blk, num_args, &nLength, 0, FALSE); + if (!pMsg) + return; + + pTemp = (msg_ext_type*)(pMsg + DIAG_REST_OF_DATA_POS); + args = pTemp->args; + args[0] = xx_arg1; + + write_len = write(diag_fd, (const void*)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION MSG_SEND_2 + +DESCRIPTION + This function sends out a debug message with 2 arguments across DiagPkt CS interface. + Do not call directly; use macro MSG_* defined in msg.h + +DEPENDENCIES + DiagPkt handle should be initialised. +===========================================================================*/ +void msg_send_2(const msg_const_type *pconst_blk, uint32 xx_arg1, uint32 xx_arg2) +{ + byte *pMsg = NULL; + msg_ext_type *pTemp = NULL; + uint32 *args = NULL; + unsigned int nLength = 0; + const unsigned int num_args = 2; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE) + return; + + pMsg = msg_send_prep(pconst_blk, num_args, &nLength, 0, FALSE); + if (!pMsg) + return; + + pTemp = (msg_ext_type *)(pMsg + DIAG_REST_OF_DATA_POS); + args = MSG_LARGE_ARGS(pTemp->args); + args[0] = xx_arg1; + args[1] = xx_arg2; + write_len = write(diag_fd, (const void*)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION MSG_SEND_3 + +DESCRIPTION +This function sends out a debug message with 2 arguments across DiagPkt CS interface. +Do not call directly; use macro MSG_* defined in msg.h + +DEPENDENCIES +DiagPkt handle should be initialised. +===========================================================================*/ +void msg_send_3(const msg_const_type *pconst_blk, uint32 xx_arg1, uint32 xx_arg2, uint32 xx_arg3) +{ + byte *pMsg = NULL; + msg_ext_type *pTemp = NULL; + uint32 *args = NULL; + unsigned int nLength = 0; + const unsigned int num_args = 3; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE) + return; + + pMsg = msg_send_prep(pconst_blk, num_args, &nLength, 0, FALSE); + if (!pMsg) + return; + + pTemp = (msg_ext_type *)(pMsg + DIAG_REST_OF_DATA_POS); + args = MSG_LARGE_ARGS(pTemp->args); + args[0] = xx_arg1; + args[1] = xx_arg2; + args[2] = xx_arg3; + write_len = write(diag_fd, (const void*)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION MSG_SEND_VAR + +DESCRIPTION + This function sends out a debug message with variable number of arguments + across DiagPkt CS interface. + Do not call directly; use macro MSG_* defined in msg.h + +DEPENDENCIES + DiagPkt handle should be initialised. + +===========================================================================*/ + +void msg_send_var (const msg_const_type *pconst_blk, uint32 num_args, ...) +{ + byte *pMsg = NULL; + msg_ext_type *pTemp = NULL; + uint32 *args = NULL; + unsigned int nLength = 0; + int write_len = 0; + va_list arg_list; + unsigned int i; + + if (diag_fd == DIAG_INVALID_HANDLE) + return; + + pMsg = msg_send_prep(pconst_blk, num_args, &nLength, 0, FALSE); + if (!pMsg) + return; + pTemp = (msg_ext_type*)(pMsg + DIAG_REST_OF_DATA_POS); + args = MSG_LARGE_ARGS(pTemp->args); + /* Initialize variable arguments */ + va_start (arg_list, num_args); + /* Store arguments from variable list. */ + for (i = 0; i < num_args; i++) + args[i] = va_arg(arg_list, uint32); + /* Reset variable arguments */ + va_end(arg_list); + write_len = write(diag_fd, (const void*)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION MSG_SPRINTF + +DESCRIPTION + + This function sends out a debug message with variable number of arguments + across DiagPkt CS interface. + This will build a message sprintf diagnostic Message with var # + of parameters. + Do not call directly; use macro MSG_SPRINTF_* defined in msg.h + +DEPENDENCIES + DiagPkt handle should be initialised. +===========================================================================*/ +void msg_sprintf(const msg_const_type *const_blk, ...) +{ + int write_len = 0; + byte *pMsg = NULL; + const char* abb_filename = NULL; + msg_sprintf_desc_type *pTemp = NULL; + unsigned int int_cnt = 0; /* Calculate the # args, to allocate buffer */ + unsigned int fname_length = 0; /* Stores the file name along with '\0' */ + unsigned int fmt_length = 0; /* Stores the fmt length,'\0' and arg size */ + unsigned int total_allocated = 0; /* Total buffer allocated */ + char *str = NULL; /* Used to copy the file name and fmt string to the msg */ + va_list arg_list; /* ptr to the variable argument list */ + unsigned int fmt_len_available = 0; /* Remaining buffer for format string */ + + if (diag_fd == DIAG_INVALID_HANDLE || !const_blk) + return; + + abb_filename = msg_format_filename2(const_blk->fname); + fname_length = strlen(abb_filename) + 1; + fmt_length = strlen(const_blk->fmt) + 1 + MSG_FMT_STR_ARG_SIZE; + + /* Calculate # of arguments to ensure enough space is allocated. */ + int_cnt = sizeof(msg_desc_type) - FSIZ(msg_ext_store_type, const_data_ptr) + fmt_length + fname_length; + + /* Calculates number of uint32s required */ + int_cnt = (int_cnt + sizeof(uint32) - 1) / sizeof(uint32); + + /* Allocates the buffer required, fills in the header */ + pMsg = msg_sprintf_prep(const_blk, int_cnt, &total_allocated); + if (!pMsg) + return; + + pTemp = (msg_sprintf_desc_type *)(pMsg + DIAG_REST_OF_DATA_POS); + /* Queue a debug message in Extended Message Format. */ + pTemp->ext.hdr.cmd_code = DIAG_EXT_MSG_F; + /* + * This function embedds the argument in the string itself. Hence the + * num_args is assigned 0 + */ + pTemp->ext.hdr.num_args = 0; + pTemp->ext.desc = const_blk->desc; + /* + * Copy the format string where the argument list would + * start. Since there are no arguments, the format string + * starts in the 'args' field. + */ + str = (char *)pTemp->ext.args; + /* Calculate the buffer left to copy the format string */ + fmt_len_available = total_allocated - (FPOS (msg_ext_type, args) + fname_length); + if (fmt_len_available < fmt_length) + fmt_length = fmt_len_available; + + /* Initialize variable argument list */ + va_start(arg_list, const_blk); + /* Copy the format string with arguments */ + (void)vsnprintf(str, fmt_length, const_blk->fmt, arg_list); + str[fmt_length - 1] = '\0'; + /* Reset variable arguments */ + va_end(arg_list); + /* + * Move the str pass the format string, strlen excludes the terminal + * NULL hence 1 is added to include NULL. + */ + str += strlen((const char *)str) + 1; + /* Copy the filename */ + snprintf(str, fname_length, "%s", abb_filename); + /* + * Move the str pass the filename, strlen excludes the terminal + * NULL hence 1 is added to include NULL. + */ + str += strlen((const char *)str) + 1; + /* + * str is now pointing to the byte after the last valid byte. + * str - msg gives the total length required. + */ + write_len = write(diag_fd, (const void *)pMsg, (uint32)(str - (char *)pMsg)); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); + return; +} + +/*=========================================================================== +FUNCTION qsr_msg_send + +DESCRIPTION + This function sends out a debug message with no arguments. + This function, or the macro QSR_MSG should not be called directly, + MSG macros are converted to QSR_MSG macro by text-replacement. + +DEPENDENCIES + diag driver should be initialized with a Diag_LSM_Init() call. +===========================================================================*/ +void qsr_msg_send(const msg_qsr_const_type *const_blk) +{ + byte *pMsg = NULL; + const unsigned int num_args = 0; /* # of message arguments */ + unsigned int nLength = 0; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE || !const_blk) + return; + + pMsg = qsr_msg_send_prep(const_blk, num_args, &nLength); + if (!pMsg) + return; + write_len = write(diag_fd, (const void *)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION qsr_msg_send_1 + +DESCRIPTION + This function sends out a debug message with no arguments. + This function, or the macro QSR_MSG_1 should not be called directly, + MSG* macros are converted to QSR_MSG* macros by text-replacement. + +DEPENDENCIES + diag driver should be initialized with a Diag_LSM_Init() call. +===========================================================================*/ + +void qsr_msg_send_1(const msg_qsr_const_type *const_blk, uint32 xx_arg1) +{ + byte* pMsg = NULL; + const unsigned int num_args = 1; + unsigned int nLength = 0; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE || !const_blk) + return; + + pMsg = qsr_msg_send_prep (const_blk, num_args, &nLength); + if (!pMsg) + return; + msg_qsr_type *pTemp = (msg_qsr_type *)(pMsg + DIAG_REST_OF_DATA_POS); + pTemp->args[0] = xx_arg1; + write_len = write(diag_fd, (const void *)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION qsr_msg_send_2 + +DESCRIPTION + This function sends out a debug message with no arguments. + This function, or the macro QSR_MSG_2 should not be called directly, + MSG* macros are converted to QSR_MSG* macros by text-replacement. + +DEPENDENCIES + diag driver should be initialized with a Diag_LSM_Init() call. +===========================================================================*/ + +void qsr_msg_send_2(const msg_qsr_const_type * const_blk, uint32 xx_arg1, uint32 xx_arg2) +{ + byte* pMsg = NULL; + const unsigned int num_args = 2; + unsigned int nLength = 0; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE || !const_blk) + return; + + pMsg = qsr_msg_send_prep (const_blk, num_args, &nLength); + if (!pMsg) + return; + msg_qsr_type *pTemp = (msg_qsr_type *)(pMsg + DIAG_REST_OF_DATA_POS); + pTemp->args[0] = xx_arg1; + pTemp->args[1] = xx_arg2; + write_len = write(diag_fd, (const void *)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION qsr_msg_send_3 + +DESCRIPTION + This function sends out a debug message with no arguments. + This function, or the macro QSR_MSG_3 should not be called directly, + MSG* macros are converted to QSR_MSG* macros by text-replacement. + +DEPENDENCIES + diag driver should be initialized with a Diag_LSM_Init() call. +===========================================================================*/ + +void qsr_msg_send_3(const msg_qsr_const_type *const_blk, uint32 xx_arg1, uint32 xx_arg2, uint32 xx_arg3) +{ + byte* pMsg = NULL; + const unsigned int num_args = 3; + unsigned int nLength = 0; + int write_len = 0; + + if (diag_fd == DIAG_INVALID_HANDLE || !const_blk) + return; + + pMsg = qsr_msg_send_prep (const_blk, num_args, &nLength); + if (!pMsg) + return; + msg_qsr_type *pTemp = (msg_qsr_type *)(pMsg + DIAG_REST_OF_DATA_POS); + pTemp->args[0] = xx_arg1; + pTemp->args[1] = xx_arg2; + pTemp->args[2] = xx_arg3; + write_len = write(diag_fd, (const void *)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*=========================================================================== +FUNCTION qsr_msg_send_var + +DESCRIPTION + This function sends out a debug message with no arguments. + This function, or the macro QSR_MSG_* should not be called directly, + MSG* macros are converted to QSR_MSG* macros by text-replacement. + +DEPENDENCIES + diag driver should be initialized with a Diag_LSM_Init() call. +===========================================================================*/ +void qsr_msg_send_var(const msg_qsr_const_type *const_blk, uint32 num_args, ...) +{ + byte *pMsg = NULL; + msg_qsr_type *pTemp = NULL; + uint32 *args = NULL; + unsigned int nLength = 0; + int write_len = 0; + va_list arg_list; + unsigned int i; + + if (diag_fd == DIAG_INVALID_HANDLE) + return; + + pMsg = qsr_msg_send_prep(const_blk, num_args, &nLength); + if (!pMsg) + return; + pTemp = (msg_qsr_type *)(pMsg + DIAG_REST_OF_DATA_POS); + args = MSG_LARGE_ARGS(pTemp->args); + /* Initialize variable arguments */ + va_start (arg_list, num_args); + /* Store arguments from variable list. */ + for (i = 0; i < num_args; i++) + args[i] = va_arg(arg_list, uint32); + /* Reset variable arguments */ + va_end(arg_list); + write_len = write(diag_fd, (const void*)pMsg, nLength); + if (write_len) { + DIAG_LOGE("Diag_LSM_Msg: Write failed in %s, bytes written: %d, error: %d\n", + __func__, write_len, errno); + } + DiagSvc_Free(pMsg, GEN_SVC_ID); +} + +/*---------------------------------------------------------------------------- + Internal functions + -----------------------------------------------------------------------------*/ +static uint32 Diag_LSM_Msg_ComputeMaskSize(void) +{ + uint32 msg_mask_size = 0; + int i = 0; + for (i = 0; i < MSG_MASK_TBL_CNT; i++) { + msg_mask_size += sizeof(uint16) + sizeof(uint16); + msg_mask_size += (msg_mask_tbl[i].ssid_last - msg_mask_tbl[i].ssid_first + 1) * sizeof(uint32); + } + return msg_mask_size; +} + +/*=========================================================================== +FUNCTION Diag_LSM_Msg_Init + +DESCRIPTION +Initializes the Diag Message service mapping layer. + +DEPENDENCIES +None + +===========================================================================*/ +boolean Diag_LSM_Msg_Init (void) +{ + if (!gnDiag_LSM_Msg_Initialized) { + Diag_LSM_Msg_ComputeMaskSize(); + gnDiag_LSM_Msg_Initialized = 1; + } + + return TRUE; +} + +/*=========================================================================== +FUNCTION Diag_LSM_Msg_DeInit + +DESCRIPTION +Prepares mapping layer exit for Diag message service. +Currently does nothing, just returns TRUE. +This is an internal function, to be used only by Diag_LSM module. + +DEPENDENCIES +None. + + +===========================================================================*/ +void Diag_LSM_Msg_DeInit(void) +{ + gnDiag_LSM_Msg_Initialized = 0; +} + +/*=========================================================================== +FUNCTION msg_update_mask + +DESCRIPTION + This function sends updates the data structure for msg masks. + +DEPENDENCIES + None +===========================================================================*/ +void msg_update_mask(unsigned char *ptr, int len) +{ + int i = 0; + int read_len = 0; + unsigned int range = 0; + diag_msg_mask_t *mask_ptr = (diag_msg_mask_t *)msg_mask; + diag_msg_mask_update_t *header; + + if (!ptr || len <= (int)sizeof(diag_msg_mask_update_t) || !gnDiag_LSM_Msg_Initialized) + return; + + for (i = 0; i < MSG_MASK_TBL_CNT && read_len < len; i++, mask_ptr++) { + header = (diag_msg_mask_update_t *)(ptr + read_len); + read_len += sizeof(diag_msg_mask_update_t); + mask_ptr->ssid_first = header->ssid_first; + mask_ptr->ssid_last = header->ssid_last; + range = header->range; + if (range > MAX_SSID_PER_RANGE) { + mask_ptr->ssid_last = mask_ptr->ssid_first + MAX_SSID_PER_RANGE; + range = MAX_SSID_PER_RANGE; + } + memcpy(mask_ptr->ptr, ptr + read_len, range * sizeof(uint32)); + read_len += header->range * sizeof(uint32); + } +} + +boolean msg_get_ssid_rt_mask(int ssid, uint32 *mask) +{ + int i; + uint32 offset = 0; + uint32 t_ssid = (uint32)ssid; + boolean success = FALSE; + diag_msg_mask_t *mask_ptr = NULL; + + mask_ptr = (diag_msg_mask_t *)msg_mask; + for (i = 0; i < MSG_MASK_TBL_CNT; i++, mask_ptr++) { + if (mask_ptr->ssid_first > t_ssid || mask_ptr->ssid_last < t_ssid) + continue; + offset = (t_ssid - mask_ptr->ssid_first); + *mask = *(uint32_t *)(mask_ptr->ptr + offset); + success = TRUE; + break; + } + + return success; +} + +/*=========================================================================== +FUNCTION msg_format_filename2 + +DESCRIPTION +retrieves the position of filename from full file path. + +DEPENDENCIES +None. +===========================================================================*/ +static const char *msg_format_filename2 (const char *filename) +{ + const char *p_front = filename; + const char *p_end = filename + strlen (filename); + + while (p_end != p_front) { + if ((*p_end == '\\') || (*p_end == ':') || (*p_end == '/')) { + p_end++; + break; + } + p_end--; + } + return p_end; +} + +/*=========================================================================== + +FUNCTION MSG_SEND_PREP + +DESCRIPTION + Prepares the buffer needed by msg_send*(). + Allocates, fills in all data except arguments, and returns a pointer + to the allocated message buffer. It also handles message statisitics. + +RETURN VALUE + Returns the allocated buffer, and the length of the buffer + +DEPENDENCIES + None +===========================================================================*/ + +static byte *msg_send_prep(const msg_const_type *const_blk, unsigned int num_args, + unsigned int *pLength, uint64 timestamp, boolean ts_valid) +{ + uint32 rt_mask; + uint32 fmt_pos; + boolean valid_ssid = FALSE; + byte *pMsg = NULL; + const char* abb_filename = NULL; + unsigned int alloc_len = 0; + msg_ext_type* pTemp = NULL; + diag_data* pdiag_data = NULL; + + if(!gnDiag_LSM_Msg_Initialized) + return NULL; + if (pLength) + *pLength = 0; + + /* Check the runtime mask */ + valid_ssid = msg_get_ssid_rt_mask((int)const_blk->desc.ss_id, &rt_mask); + if (!(valid_ssid && (const_blk->desc.ss_mask & rt_mask))) + return NULL; + + abb_filename = msg_format_filename2(const_blk->fname); + + /* total number of bytes to be allocated, including dereferenced FileName and Format strings */ + alloc_len = DIAG_REST_OF_DATA_POS + FPOS (msg_ext_type, args) + num_args * FSIZ (msg_ext_type,args[0]) + + strlen(abb_filename) + 1 + strlen(const_blk->fmt) + 1; + + /* Get a pointer to a buffer. If it's a NULL pointer, there is no memory in the client heap. */ + pMsg = (byte *)DiagSvc_Malloc(alloc_len, GEN_SVC_ID); + if (!pMsg) { + msg_drop_delta++; + return NULL; + } + + /* position of format string in the returned buffer. */ + pTemp = (msg_ext_type*)((byte*)pMsg + DIAG_REST_OF_DATA_POS); + fmt_pos = DIAG_REST_OF_DATA_POS + FPOS (msg_ext_type, args) + num_args * FSIZ (msg_ext_type,args[0]); + pdiag_data = (diag_data*) pMsg; + pdiag_data->diag_data_type = DIAG_DATA_TYPE_F3; + if(pLength) + *pLength = alloc_len; /* return the number of bytes allocated. */ + + /* client timestamp is valid, copy that into the header */ + if (ts_valid) { + timestamp = timestamp * 4; + timestamp = timestamp / 5; + timestamp = timestamp << 16; + memcpy((char *) (&(pTemp->hdr.ts_lo)), (char *) &(timestamp), 4); + memcpy((char *) (&(pTemp->hdr.ts_hi)), ((char *) &(timestamp)) + 4, 4); + } else { + ts_get_lohi(&(pTemp->hdr.ts_lo), &(pTemp->hdr.ts_hi)); + } + + pTemp->hdr.ts_type = MSG_TS_TYPE; + pTemp->hdr.cmd_code = DIAG_EXT_MSG_F; + pTemp->hdr.num_args = (uint8)num_args; + pTemp->hdr.drop_cnt = (unsigned char)((msg_drop_delta > 255) ? 255 : msg_drop_delta); + msg_drop_delta = 0; /* Reset delta drop count */ + + /* + * expand it now, copy over the filename and format strings. The order + * is: hdr,desc,args,format string, filename. args are copied in the + * msg_send_1 etc... functions + */ + memcpy((void *)((char *)(pMsg) + DIAG_REST_OF_DATA_POS + sizeof(msg_hdr_type)), (void *)&(const_blk->desc), sizeof (msg_desc_type)); + memcpy((void *)((char *)(pMsg) + fmt_pos), (void *)(const_blk->fmt), strlen(const_blk->fmt) + 1); + memcpy((void *)((char *)(pMsg) + fmt_pos + strlen(const_blk->fmt) + 1), (void *)(abb_filename), strlen(abb_filename) + 1); + return pMsg; +} + +/*=========================================================================== +FUNCTION qsr_msg_send_prep + +DESCRIPTION + Internal function. + Prepares the buffer that is sent to diag driver by the qsr_msg_send* functions. + The const block is expanded in the context of the caller. +===========================================================================*/ +static byte* qsr_msg_send_prep(const msg_qsr_const_type *const_blk, + unsigned int num_args, unsigned int *pLength) +{ + uint32 rt_mask; + boolean valid_ssid = FALSE; + byte *pMsg = NULL; + unsigned int alloc_len = 0; + msg_qsr_type *pTemp = NULL; + diag_data *pdiag_data = NULL; + + if (!gnDiag_LSM_Msg_Initialized) + return NULL; + + if (pLength) + *pLength = 0; + /* Check the runtime mask */ + valid_ssid = msg_get_ssid_rt_mask(const_blk->desc.ss_id, &rt_mask); + if (!(valid_ssid && (const_blk->desc.ss_mask & rt_mask))) + return NULL; + + /* total number of bytes to be allocated, including space for the hash value */ + alloc_len = DIAG_REST_OF_DATA_POS + FPOS(msg_qsr_type, args) + num_args * FSIZ(msg_qsr_type, args[0]); + + /* Get a pointer to a buffer. If it's a NULL pointer, there is no memory in the client heap. */ + pMsg = (byte *)DiagSvc_Malloc(alloc_len, GEN_SVC_ID); + if (!pMsg) { + msg_drop_delta++; + return NULL; + } + + /* Find the position to copy in the header, const expanded values etc */ + pTemp = (msg_qsr_type *)((byte *)pMsg + DIAG_REST_OF_DATA_POS); + + /* For diag driver to recognize that this is an F3 Msg. */ + pdiag_data = (diag_data *)pMsg; + pdiag_data->diag_data_type = DIAG_DATA_TYPE_F3; + + if (pLength) + *pLength = alloc_len; /* return the number of bytes allocated. */ + + ts_get_lohi(&(pTemp->hdr.ts_lo), &(pTemp->hdr.ts_hi)); + + pTemp->hdr.ts_type = MSG_TS_TYPE; + pTemp->hdr.cmd_code = DIAG_QSR_EXT_MSG_TERSE_F; /* cmd_code = 146 for QSR messages */ + pTemp->hdr.num_args = (uint8)num_args; + pTemp->hdr.drop_cnt = (unsigned char)((msg_drop_delta > 255) ? 255 : msg_drop_delta); + msg_drop_delta = 0; /* Reset delta drop count */ + + /* expand it now. + The order is: hdr (already done),desc,hash,args. args are copied in the qsr_msg_send* functions */ + pTemp->desc.line = const_blk->desc.line; + pTemp->desc.ss_id = const_blk->desc.ss_id; + pTemp->desc.ss_mask = const_blk->desc.ss_mask; + pTemp->msg_hash = const_blk->msg_hash; + + return pMsg; +} + +/*=========================================================================== +FUNCTION MSG_SPRINTF_PREP + +DESCRIPTION + Prepares the buffer needed by msg_sprintf(). + Allocates, fills in all data except arguments, and returns a pointer + to the allocated message buffer. It also handles message statisitics. + +RETURN VALUE + Returns the allocated buffer, and the length of the buffer + +DEPENDENCIES + None +===========================================================================*/ +static byte *msg_sprintf_prep(const msg_const_type *pconst_blk, unsigned int num_args, + unsigned int* pLength) +{ + uint32 rt_mask; + boolean valid_ssid = FALSE; + byte *pMsg = NULL; + unsigned int alloc_len = DIAG_REST_OF_DATA_POS + FPOS(msg_ext_store_type, args) + + num_args * FSIZ(msg_ext_store_type, args[0]); + + if (!gnDiag_LSM_Msg_Initialized) + return NULL; + /* Check the runtime mask */ + valid_ssid = msg_get_ssid_rt_mask((int)pconst_blk->desc.ss_id, &rt_mask); + if (!(valid_ssid && (pconst_blk->desc.ss_mask & rt_mask))) + return NULL; + + /* Get a pointer to a buffer. If it's a NULL pointer, there is no memory in the client heap. */ + pMsg = (byte *)DiagSvc_Malloc(alloc_len, GEN_SVC_ID); + if (!pMsg) { + msg_drop_delta++; + return NULL; + } + + msg_ext_store_type *pTemp = (msg_ext_store_type *)((byte *)pMsg + DIAG_REST_OF_DATA_POS); + diag_data *pdiag_data = (diag_data *)pMsg; + pdiag_data->diag_data_type = DIAG_DATA_TYPE_F3; + + if (pLength) + *pLength = alloc_len; + + ts_get_lohi(&(pTemp->hdr.ts_lo), &(pTemp->hdr.ts_hi)); + pTemp->hdr.ts_type = MSG_TS_TYPE; + pTemp->hdr.num_args = (uint8)num_args; + pTemp->hdr.drop_cnt = (unsigned char)((msg_drop_delta > 255)? 255 : msg_drop_delta); + msg_drop_delta = 0; /* Reset delta drop count */ + /* Set the pointer to the constant blk, to be expanded by msg_sprintf */ + pTemp->const_data_ptr = pconst_blk; + + return pMsg; +} + diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg_i.h b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg_i.h new file mode 100755 index 000000000..c8a94b3ec --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_msg_i.h @@ -0,0 +1,61 @@ +#ifndef DIAG_LSM_MSG_I_H +#define DIAG_LSM_MSG_I_H +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + +EXTENDED DIAGNOSTIC MESSAGE SERVICE LEGACY MAPPING +INTERNAL HEADER FILE + +GENERAL DESCRIPTION +Internal header file + +Copyright (c) 2007-2011, 2013-2015 Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +12/03/07 mad Created File +===========================================================================*/ + +#include "msg.h" +#include "msgcfg.h" + +#define MAX_SSID_PER_RANGE 200 + +typedef PACK(struct) { + uint32 ssid_first; + uint32 ssid_last; + uint32 ptr[MAX_SSID_PER_RANGE]; +} diag_msg_mask_t; + +typedef PACK(struct) { + uint32_t ssid_first; + uint32_t ssid_last; + uint32_t range; +} diag_msg_mask_update_t; + +/* + * Each row contains First (uint32_t), Last (uint32_t) values along with the + * range of SSIDs (MAX_SSID_PER_RANGE * uint32_t). And there are + * MSG_MASK_TBL_CNT rows. + */ +#define MSG_MASK_SIZE (sizeof(diag_msg_mask_t) * MSG_MASK_TBL_CNT) + +unsigned char msg_mask[MSG_MASK_SIZE]; + +/* Initializes Mapping layer for message service*/ +boolean Diag_LSM_Msg_Init(void); + +/* clean up before exiting legacy service mapping layer. +Does nothing as of now, just returns TRUE. */ +void Diag_LSM_Msg_DeInit(void); + +/* updates the copy of the run-time masks for messages */ +void msg_update_mask(unsigned char *ptr, int len); + +#endif /* DIAG_LSM_MSG_I_H */ diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt.c b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt.c new file mode 100755 index 000000000..39f784f1c --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt.c @@ -0,0 +1,1447 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Legacy Service Mapping layer implementation for Packet request/response + +GENERAL DESCRIPTION + Contains main implementation of Legacy Service Mapping layer for Diagnostic Packet Req/Res Services. + +EXTERNALIZED FUNCTIONS + diagpkt_alloc + diagpkt_subsys_alloc + diagpkt_shorten + diagpkt_commit + diagpkt_get_cmd_code + diagpkt_set_cmd_code + diagpkt_subsys_get_id + diagpkt_subsys_get_cmd_code + diagpkt_err_rsp + diagpkt_subsys_alloc_v2 + diagpkt_subsys_alloc_v2_delay + diagpkt_delay_commit + diagpkt_subsys_get_status + diagpkt_subsys_set_status + diagpkt_subsys_get_delayed_rsp_id + diagpkt_subsys_reset_delayed_rsp_id + diagpkt_subsys_set_rsp_cnt + +INITIALIZATION AND SEQUENCING REQUIREMENTS + +Copyright (c) 2007-2011, 2013-2015, 2016 Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Changes for CBSP2.0 +04/14/08 JV Added support to pass a pointer to a locally created object as + an argument to IDiagPkt_BindPkt() +04/14/08 JV Replaced KxMutex lock and unlock with ICritSect enter and leave +02/27/08 JV Created + +===========================================================================*/ + + +/* ========================================================================== + Include Files +========================================================================== */ +#include "stdio.h" +#include "comdef.h" +#include "diagpkt.h" +#include "diag_lsmi.h" +#include "diagdiag.h" +#include "diagcmd.h" +#include "diag.h" /* For definition of diag_cmd_rsp */ +#include "diag_lsm_pkt_i.h" +#include "diagi.h" +#include "diag_shared_i.h" /* data structures for registration */ +#include "diagsvc_malloc.h" + +#include +#include +#include +#include +#include "errno.h" +#include "../include/diag_lsm.h" +#include "diag_lsm_dci.h" +#include "diag_lsm_dci_i.h" + +#define std_strlprintf snprintf +#define DIAGPKT_HDR_PATTERN (0xDEADD00DU) +#define DIAGPKT_OVERRUN_PATTERN (0xDEADU) +#define DIAGPKT_USER_TBL_SIZE 128 +#define DIAGPKT_MAX_DELAYED_RSP 0xFFFF +#define DIAGPKT_PKT2LSMITEM(p) \ + ((diagpkt_lsm_rsp_type *) (((byte *) p) - FPOS (diagpkt_lsm_rsp_type, rsp.pkt))) + +static unsigned int gPkt_commit_fail = 0; +static byte user_tbl_inited = FALSE; +static diag_dci_delayed_rsp_tbl_t dci_delayed_rsp_tbl_head; +static pthread_mutex_t dci_delayed_rsp_tbl_mutex; +static diagpkt_user_table_type *diagpkt_user_table[DIAGPKT_USER_TBL_SIZE]; +static int pkt_type; +static int dci_tag; +static pthread_mutex_t user_tbl_mutex; +/* + * delayed_rsp_id 0 represents no delay in the response. Any other + * number means that the diag packet has a delayed response.* + */ +static uint16 delayed_rsp_id = 1; + +typedef struct { + uint8 command_code; +} diagpkt_hdr_type; + +typedef struct { + uint8 command_code; + uint8 subsys_id; + uint16 subsys_cmd_code; +} diagpkt_subsys_hdr_type; + +typedef struct { + uint8 command_code; + uint8 subsys_id; + uint16 subsys_cmd_code; + uint32 status; + uint16 delayed_rsp_id; + uint16 rsp_cnt; /* 0, means one response and 1, means two responses */ +} diagpkt_subsys_hdr_type_v2; + +/*============================================================================= +FUNCTION DIAG_DCI_ADD_DELAYED_RSP + +DESCRIPTION +Internal function. +Adds the Delayed response ID and the packet tag to an +internal table for lookup + +DEPENDENCIES +DCI + +RETURN VALUE +None + +SIDE EFFECTS +None +=============================================================================*/ +static void diag_dci_add_delayed_rsp(diagpkt_subsys_delayed_rsp_id_type id, int tag) +{ + diag_dci_delayed_rsp_tbl_t *temp = NULL, *head_ptr = NULL; + diag_dci_delayed_rsp_tbl_t *new_entry = (diag_dci_delayed_rsp_tbl_t *)malloc(sizeof(diag_dci_delayed_rsp_tbl_t)); + if (!new_entry) { + DIAG_LOGE("diag: Unable to allocate memory for DCI delayed resonse table entry\n"); + return; + } + + new_entry->delayed_rsp_id = id; + new_entry->dci_tag = tag; + head_ptr = &dci_delayed_rsp_tbl_head; + pthread_mutex_lock(&dci_delayed_rsp_tbl_mutex); + temp = head_ptr->prev; + head_ptr->prev = new_entry; + new_entry->next = head_ptr; + new_entry->prev = temp; + temp->next = new_entry; + pthread_mutex_unlock(&dci_delayed_rsp_tbl_mutex); +} + +/*============================================================================= +FUNCTION DIAG_DCI_DELAYED_RSP_ID_PRESENT + +DESCRIPTION +Internal function. +Looks up the internal DCI delayed response table for a +particular delayed response ID and returns the +corresponding tag. + +DEPENDENCIES +DCI + +RETURN VALUE +DCI Request Tag + +SIDE EFFECTS +None +=============================================================================*/ +static diag_dci_delayed_rsp_tbl_t *diag_dci_delayed_rsp_id_present(diagpkt_subsys_delayed_rsp_id_type id) +{ + diag_dci_delayed_rsp_tbl_t *walk_ptr = NULL, *head_ptr = NULL; + + head_ptr = &dci_delayed_rsp_tbl_head; + for (walk_ptr = head_ptr->next; walk_ptr && walk_ptr != head_ptr; walk_ptr = walk_ptr->next) + if (walk_ptr->delayed_rsp_id == id) + return walk_ptr; + + return NULL; +} + +/*============================================================================= +FUNCTION DIAG_DCI_DELETE_DELAYED_RSP_ENTRY + +DESCRIPTION +Internal function. +Deletes a particular DCI delayed response entry from the table. + +DEPENDENCIES +DCI + +RETURN VALUE +None + +SIDE EFFECTS +None +=============================================================================*/ +static void diag_dci_delete_delayed_rsp_entry(diag_dci_delayed_rsp_tbl_t *entry) +{ + if (!entry || !entry->next || !entry->prev) + return; + + pthread_mutex_lock(&dci_delayed_rsp_tbl_mutex); + entry->prev->next = entry->next; + entry->next->prev = entry->prev; + pthread_mutex_unlock(&dci_delayed_rsp_tbl_mutex); + free(entry); +} + +/*============================================================================= +FUNCTION DIAGPKT_GET_DELAYED_RSP_ID_LSM + +DESCRIPTION +Internal function. +Issues an IOCTL to the diag driver and gets the next delayed response id in the system + +RETURN VALUE +0 if it fails to retrieve the next delayed response id. Valid value otherwise. + +DEPENDENCIES +Diag driver should be initialized. +=============================================================================*/ +static uint16 diagpkt_get_delayed_rsp_id_lsm(void) +{ + uint16 delayed_rsp_id = 0; + int err = 0; + + err = ioctl(diag_fd, DIAG_IOCTL_GET_DELAYED_RSP_ID, &delayed_rsp_id, 0, NULL, 0, NULL, NULL); + if (err) { + delayed_rsp_id = 0; + DIAG_LOGE("diag: Unable to retrieve new delayed response id, err: %d, errno: %d\n", err, errno); + } + + return delayed_rsp_id; +} + +/*=========================================================================== + +FUNCTION DIAGPKT_WITH_DELAY + +DESCRIPTION + This procedure checks if the diagnostic packet has been registered with or + without delay. + +DEPENDENCIES + None. + +RETURN VALUE + Return value is 0 if Diag packet has no delayed response and 1 if Diag + packet has delayed response + +SIDE EFFECTS + None + + + +===========================================================================*/ +static uint32 diagpkt_with_delay (diagpkt_subsys_id_type id, + diagpkt_subsys_cmd_code_type code) +{ + uint16 packet_id = code; /* Command code for std or subsystem */ + uint8 subsys_id = id; + const diagpkt_user_table_type *user_tbl_entry = NULL; + const diagpkt_user_table_entry_type *tbl_entry = NULL; + int tbl_entry_count = 0; + int i, j; + boolean found = FALSE; + uint32 delay_flag = 0; + + /* Search the dispatch table for a matching subsystem ID. If the + subsystem ID matches, search that table for an entry for the given + command code. */ + for (i = 0; !found && i < DIAGPKT_USER_TBL_SIZE; i++) + { + user_tbl_entry = diagpkt_user_table[i]; + if (user_tbl_entry != NULL && user_tbl_entry->subsysid == subsys_id) + { + tbl_entry = user_tbl_entry->user_table; + delay_flag = user_tbl_entry->delay_flag; + tbl_entry_count = (tbl_entry) ? user_tbl_entry->count : 0; + + for (j = 0; (tbl_entry!=NULL) && !found && j < tbl_entry_count; j++) + { + if (packet_id >= tbl_entry->cmd_code_lo && + packet_id <= tbl_entry->cmd_code_hi) + { + /* If the entry has no func, ignore it. */ + found = TRUE; + } + tbl_entry++; + } + } /* endif if (user_tbl_entry != NULL && user_tbl_entry->subsysid == subsys_id) */ + } + return delay_flag; +} /* diagpkt_with_delay */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_DELAY_ALLOC + +DESCRIPTION + This function allocates the specified amount of space in a pre-malloced buffer. + +DEPENDENCIES + None. + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +static void *diagpkt_delay_alloc(diagpkt_cmd_code_type code, unsigned int length) +{ + void *ptr = NULL; + unsigned int size = 0; + diagpkt_subsys_hdr_type_v2 *pkt = NULL; + + size = DIAG_DEL_RESP_REST_OF_DATA_POS + length; + + + /* We allocate from the memory pool used for events, logs and messages + because it is a delayed response. */ + ptr = DiagSvc_Malloc (size, GEN_SVC_ID); + if (NULL != ptr) + { + diag_data_delayed_response* pdiag_data = (diag_data_delayed_response*) ptr; + pdiag_data->length = length; + pdiag_data->diagdata.diag_data_type = DIAG_DATA_TYPE_DELAYED_RESPONSE; + pkt = (diagpkt_subsys_hdr_type_v2*) ((byte*)(pdiag_data)+DIAG_DEL_RESP_REST_OF_DATA_POS); + pkt->command_code = code; + } + else + { + /* Alloc not successful. Return NULL. DiagSvc_Malloc() allocates memory + from client's heap using a malloc call if the pre-malloced buffers are not available. + So if this fails, it means that the client is out of heap. */ + + DIAG_LOGE(" diagpkt_delay_alloc: DiagSvc_Malloc Failed"); + } + return pkt; +} /* diagpkt_delay_alloc */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_LSM_PROCESS_REQUEST + +DESCRIPTION + This procedure formats a response packet in response to a request + packet received from the Diagnostic Monitor. Calls packet processing + functions through a table, counts input and output types + +DEPENDENCIES + None. + +RETURN VALUE + None + +SIDE EFFECTS + None +===========================================================================*/ + +void diagpkt_LSM_process_request(void *req_pkt, uint16 pkt_len, int type) +{ + uint16 packet_id; + uint8 subsys_id = DIAGPKT_NO_SUBSYS_ID; + const diagpkt_user_table_type *user_tbl_entry = NULL; + const diagpkt_user_table_entry_type *tbl_entry = NULL; + int tbl_entry_count = 0; + int i, j; + void *rsp_pkt = NULL; + boolean found = FALSE; + uint16 cmd_code = 0xFF; + void *request_ptr = NULL; + request_ptr = req_pkt; + if (!request_ptr) { + DIAG_LOGE("diag: Invalid request packet in %s\n", __func__); + return; + } + if (type != PKT_TYPE && type != DCI_PKT_TYPE) { + DIAG_LOGE("diag: Invalid packet type %d, in %s\n", type, __func__); + return; + } + pkt_type = (type == PKT_TYPE) ? DIAG_DATA_TYPE_RESPONSE : type; + if (type == DCI_PKT_TYPE) { + if (pkt_len < (sizeof(diag_dci_pkt_header_t) + sizeof(uint8))) { + DIAG_LOGE("diag: In %s, invalid pkt_len for DCI request: %d\n", __func__, pkt_len); + return; + } + diag_dci_pkt_header_t *dci_header; + dci_header = (diag_dci_pkt_header_t *)request_ptr; + dci_tag = dci_header->tag; + request_ptr = (unsigned char *)request_ptr + sizeof(diag_dci_pkt_header_t); + pkt_len -= (sizeof(diag_dci_pkt_header_t) + sizeof(uint8)); + } + packet_id = diagpkt_get_cmd_code(request_ptr); + if (packet_id == DIAG_SUBSYS_CMD_VER_2_F) + cmd_code = packet_id; + if ((packet_id == DIAG_SUBSYS_CMD_F) || (packet_id == DIAG_SUBSYS_CMD_VER_2_F)) { + subsys_id = diagpkt_subsys_get_id(request_ptr); + packet_id = diagpkt_subsys_get_cmd_code(request_ptr); + } + + /* + * Search the dispatch table for a matching subsystem ID. If the + * subsystem ID matches, search that table for an entry for the given + * command code. + */ + for (i = 0; !found && i < DIAGPKT_USER_TBL_SIZE; i++) { + user_tbl_entry = diagpkt_user_table[i]; + if (user_tbl_entry != NULL && user_tbl_entry->subsysid == subsys_id && user_tbl_entry->cmd_code == cmd_code) { + tbl_entry = user_tbl_entry->user_table; + tbl_entry_count = (tbl_entry) ? user_tbl_entry->count : 0; + for (j = 0; (tbl_entry!=NULL) && !found && j < tbl_entry_count; j++) { + if (packet_id >= tbl_entry->cmd_code_lo && packet_id <= tbl_entry->cmd_code_hi) { + found = TRUE; + if (tbl_entry->func_ptr) { + rsp_pkt = (void *) (*tbl_entry->func_ptr) (request_ptr, pkt_len); + if (rsp_pkt) { + /* + * The most common case: response is returned. Go ahead + * and commit it here. + */ + diagpkt_commit(rsp_pkt); + } + } + } + tbl_entry++; + } + } + } + + /* Assume that rsp and rsp_pkt are NULL if !found */ + if (!found) + DIAG_LOGE("diag: In %s, Did not find match in user table.\n", __func__); + return; +} + +/* ========================================================================== +FUNCTION +DIAGPKT_USER_TBL_INIT + +DESCRIPTION + Registers the table given to the diagpkt user table + +DEPENDENCIES + None. + +RETURN VALUE + None + +SIDE EFFECTS + None +============================================================================= */ +static void diagpkt_user_tbl_init(void) +{ + int i = 0; + if (user_tbl_inited) + return; + + pthread_mutex_init(&user_tbl_mutex, NULL); + for (i = 0; i < DIAGPKT_USER_TBL_SIZE; i++) + diagpkt_user_table[i] = NULL; + user_tbl_inited = TRUE; +} +/*=========================================================================== +FUNCTION Diag_LSM_Pkt_Init + +DESCRIPTION + Initializes the Packet Req/Res service. + +DEPENDENCIES + None. + +RETURN VALUE + FALSE = failure, else TRUE + +SIDE EFFECTS + None + +===========================================================================*/ + +boolean Diag_LSM_Pkt_Init(void) +{ + diag_dci_delayed_rsp_tbl_t *head_ptr = &dci_delayed_rsp_tbl_head; + head_ptr->delayed_rsp_id = 0; + head_ptr->dci_tag = 0; + head_ptr->next = head_ptr; + head_ptr->prev = head_ptr; + pthread_mutex_init(&dci_delayed_rsp_tbl_mutex, NULL); + return TRUE; +} /* Diag_LSM_Pkt_Init */ + +/*=========================================================================== + +FUNCTION Diag_LSM_Pkt_DeInit + +DESCRIPTION + De-Initialize the Diag Packet Req/Res service. + +DEPENDENCIES + None. + +RETURN VALUE + boolean: returns TRUE; currently does nothing. + +SIDE EFFECTS + None + +===========================================================================*/ +boolean Diag_LSM_Pkt_DeInit(void) +{ + int i = 0; + int client_id = gdwClientID; + boolean ret = TRUE; + diag_dci_delayed_rsp_tbl_t *walk_ptr = NULL, *head_ptr = NULL; + + if (ioctl(diag_fd, DIAG_IOCTL_COMMAND_DEREG, (void*)&client_id, sizeof(client_id), NULL, 0, NULL, NULL) != 0) { + DIAG_LOGE(" Diag_LSM_Pkt_DeInit: DeviceIOControl failed, Error = %d\n.", errno); + ret = FALSE; + } + + /* free the entries in user table */ + for (i = 0; i < DIAGPKT_USER_TBL_SIZE; i++) { + if (diagpkt_user_table[i] != NULL) { + free(diagpkt_user_table[i]); + diagpkt_user_table[i] = NULL; + } + else + break; + } + + head_ptr = &dci_delayed_rsp_tbl_head; + /* Remove entries from the DCI delayed response table */ + for (walk_ptr = head_ptr->next; walk_ptr && walk_ptr != head_ptr; walk_ptr = walk_ptr->next) + diag_dci_delete_delayed_rsp_entry(walk_ptr); + + return ret; +} /* Diag_LSM_Pkt_DeInit */ + + +/* ==========================================================================*/ +/* Externalized functions */ + +/* Do not call this function directly. Use the macros defined in diagpkt.h. */ +/* ========================================================================== +FUNCTION DIAGPKT_TBL_REG + +DESCRIPTION + Registers the table given to the diagpkt user table + +DEPENDENCIES + None. + +RETURN VALUE + None + +SIDE EFFECTS + None +=============================================================================*/ +void diagpkt_tbl_reg(const diagpkt_user_table_type *tbl_ptr) +{ + int i; + word num_entries = 0; + diag_cmd_reg_entry_t *entries = NULL; + diag_cmd_reg_tbl_t reg_tbl; + + if (-1 == diag_fd) { + DIAG_LOGE("diag: In %s, service not initialized.\n", __func__); + return; + } + + if (!tbl_ptr) { + DIAG_LOGE("diag: In %s, invalid input\n", __func__); + return; + } + + num_entries = tbl_ptr->count; + entries = (diag_cmd_reg_entry_t *)malloc(sizeof(diag_cmd_reg_entry_t) * num_entries); + if (!entries) { + DIAG_LOGE("diag: In %s, unable to create temporary memory for registration\n", __func__); + return; + } + + /* Make sure this is initialized */ + diagpkt_user_tbl_init(); + pthread_mutex_lock(&user_tbl_mutex); + for (i = 0; i < DIAGPKT_USER_TBL_SIZE; i++) { + if (diagpkt_user_table[i] != NULL) + continue; + diagpkt_user_table[i] = (diagpkt_user_table_type *)malloc(sizeof(diagpkt_user_table_type)); + if (!diagpkt_user_table[i]) { + DIAG_LOGE("diag: In %s, unable to allocate entry in the table\n", __func__); + pthread_mutex_unlock(&user_tbl_mutex); + free(entries); + return; + } + memcpy(diagpkt_user_table[i], tbl_ptr, sizeof(diagpkt_user_table_type)); + break; + } + pthread_mutex_unlock(&user_tbl_mutex); + + reg_tbl.count = num_entries; + (void)std_strlprintf(reg_tbl.sync_obj_name, MAX_SYNC_OBJ_NAME_SIZE, + "%s%d", DIAG_LSM_PKT_EVENT_PREFIX, gdwClientID); + for (i = 0; i < num_entries; i++) { + entries[i].cmd_code = tbl_ptr->cmd_code; + entries[i].subsys_id = tbl_ptr->subsysid; + entries[i].cmd_code_lo = tbl_ptr->user_table[i].cmd_code_lo; + entries[i].cmd_code_hi = tbl_ptr->user_table[i].cmd_code_hi; + } + reg_tbl.entries = entries; + if (ioctl(diag_fd, DIAG_IOCTL_COMMAND_REG, ®_tbl, sizeof(reg_tbl), NULL, 0, NULL, NULL)) + DIAG_LOGE("diag: Unable to register commands with the driver, error: %d\n", errno); + free(entries); +} + +/*=========================================================================== + +FUNCTION DIAGPKT_GET_CMD_CODE + +DESCRIPTION + This function returns the command code in the specified diag packet. + +DEPENDENCIES + None. + +RETURN VALUE + cmd_code + +SIDE EFFECTS + None + +===========================================================================*/ +diagpkt_cmd_code_type +diagpkt_get_cmd_code (void *ptr) +{ + diagpkt_cmd_code_type cmd_code = 0; + if(ptr) + { + /* Diag command codes are the first byte */ + return *((diagpkt_cmd_code_type *) ptr); + } + return cmd_code; +} /* diag_get_cmd_code */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_SET_CMD_CODE + +DESCRIPTION + This function sets the command code in the specified diag packet. + +DEPENDENCIES + None. + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void +diagpkt_set_cmd_code (void *ptr, diagpkt_cmd_code_type cmd_code) +{ + if(ptr) + { + *((diagpkt_cmd_code_type *) ptr) = cmd_code; + } +} /* diagpkt_set_cmd_code */ + + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_GET_ID + +DESCRIPTION + This function returns the subsystem ID in the specified diag packet. + + +DEPENDENCIES + None. + +RETURN VALUE + subsys_id. If the packet is not a DIAG_SUBSYS_CMD_F or DIAG_SUBSYS_CMD_VER_2_F packet, + 0xFF is returned. + +SIDE EFFECTS + None + +===========================================================================*/ +diagpkt_subsys_id_type +diagpkt_subsys_get_id (void *ptr) +{ + diagpkt_subsys_id_type id = 0; + if (ptr) + { + diagpkt_subsys_hdr_type *pkt_ptr = (void *) ptr; + + if ((pkt_ptr->command_code == DIAG_SUBSYS_CMD_F) || (pkt_ptr->command_code + == DIAG_SUBSYS_CMD_VER_2_F)) + { + id = (diagpkt_subsys_id_type) pkt_ptr->subsys_id; + } + else + { + id = 0xFF; + } + } + return id; +} /* diagpkt_subsys_get_id */ + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_GET_CMD_CODE + +DESCRIPTION + This function returns the subsystem command code in the specified + diag packet. + +DEPENDENCIES + None. + +RETURN VALUE + subsys_cmd_code. If the packet is not a DIAG_SUBSYS_CMD_F or DIAG_SUBSYS_CMD_VER_2_F packet, + 0xFFFF is returned. + +SIDE EFFECTS + None +===========================================================================*/ +diagpkt_subsys_cmd_code_type +diagpkt_subsys_get_cmd_code (void *ptr) +{ + diagpkt_subsys_cmd_code_type code = 0; + if(ptr) + { + diagpkt_subsys_hdr_type *pkt_ptr = (void *) ptr; + + if ((pkt_ptr->command_code == DIAG_SUBSYS_CMD_F) || (pkt_ptr->command_code + == DIAG_SUBSYS_CMD_VER_2_F)) + { + code = pkt_ptr->subsys_cmd_code; + } + else + { + code = 0xFFFF; + } + } + return code; +} /* diagpkt_subsys_get_cmd_code */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_GET_STATUS + +DESCRIPTION + This function gets the status field in the DIAG_SUBSYS_CMD_VER_2_F packet + +DEPENDENCIES + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +RETURN VALUE + status + +SIDE EFFECTS + None + +===========================================================================*/ +diagpkt_subsys_status_type +diagpkt_subsys_get_status (void *ptr) +{ + diagpkt_subsys_hdr_type_v2 *pkt_ptr = (void *) ptr; + + assert (pkt_ptr != NULL); + assert (pkt_ptr->command_code == DIAG_SUBSYS_CMD_VER_2_F); + + return pkt_ptr->status; +} /* diagpkt_subsys_get_status */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_SET_STATUS + +DESCRIPTION + This function sets the status field in the DIAG_SUBSYS_CMD_VER_2_F packet. + +DEPENDENCIES + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +RETURN VALUE + None + +SIDE EFFECTS + None +===========================================================================*/ +void +diagpkt_subsys_set_status (void *ptr, diagpkt_subsys_status_type status) +{ + diagpkt_subsys_hdr_type_v2 *pkt_ptr = (void *) ptr; + + assert (pkt_ptr != NULL); + assert (pkt_ptr->command_code == DIAG_SUBSYS_CMD_VER_2_F); + + pkt_ptr->status = status; +} /* diagpkt_subsys_set_status */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_GET_DELAYED_RSP_ID + +DESCRIPTION + This function gets the delayed response ID field in the + DIAG_SUBSYS_CMD_VER_2_F packet. + +DEPENDENCIES + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +RETURN VALUE + delayed response ID + +SIDE EFFECTS + None +===========================================================================*/ +diagpkt_subsys_delayed_rsp_id_type +diagpkt_subsys_get_delayed_rsp_id (void *ptr) +{ + diagpkt_subsys_hdr_type_v2 *pkt_ptr = (void *) ptr; + + assert (pkt_ptr != NULL); + assert (pkt_ptr->command_code == DIAG_SUBSYS_CMD_VER_2_F); + + return (pkt_ptr) ? pkt_ptr->delayed_rsp_id : 0; +} /* diagpkt_subsys_get_delayed_rsp_id */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_RESET_DELAYED_RSP_ID + +DESCRIPTION + This function sets the delayed response ID to zero in the + DIAG_SUBSYS_CMD_VER_2_F packet. + +DEPENDENCIES + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void +diagpkt_subsys_reset_delayed_rsp_id (void *ptr) +{ + diagpkt_subsys_hdr_type_v2 *pkt_ptr = (void *) ptr; + + assert (pkt_ptr != NULL); + assert (pkt_ptr->command_code == DIAG_SUBSYS_CMD_VER_2_F); + + pkt_ptr->delayed_rsp_id = 0; +} /* diagpkt_subsys_reset_delayed_rsp_id */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_SET_RSP_CNT + +DESCRIPTION + This function sets the response count in the DIAG_SUBSYS_CMD_VER_2_F packet. + +DEPENDENCIES + This function's first argument (ptr) should always be DIAG_SUBSYS_CMD_VER_2_F + packet. + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void +diagpkt_subsys_set_rsp_cnt (void *ptr, diagpkt_subsys_rsp_cnt rsp_cnt) +{ + diagpkt_subsys_hdr_type_v2 *pkt_ptr = (void *) ptr; + + assert (pkt_ptr != NULL); + assert (pkt_ptr->command_code == DIAG_SUBSYS_CMD_VER_2_F); + + pkt_ptr->rsp_cnt = rsp_cnt; +} /* diagpkt_subsys_set_rsp_cnt */ + + +/*============================================================================ +FUNCTION DIAGPKT_ALLOC + +DESCRIPTION + This function allocates the specified amount of space from a pre-malloced buffer. + If space is unavailable in the pre-malloced buffer, then a malloc is done. + +DEPENDENCIES + diagpkt_commit() must be called to commit the response packet to be sent. + Not calling diagpkt_commit() will result in a memory leak. + +RETURN VALUE + pointer to the allocated memory + +SIDE EFFECTS + None + +============================================================================*/ + + +void * +diagpkt_alloc (diagpkt_cmd_code_type code, unsigned int length) +{ + diagpkt_lsm_rsp_type *item = NULL; + diagpkt_hdr_type *pkt = NULL; + uint16 *pattern = NULL; /* Overrun pattern. */ + unsigned char *p; + diag_data* pdiag_data = NULL; + unsigned int size = 0; + + if(-1 == diag_fd) + { + return NULL; + } + + size = DIAG_REST_OF_DATA_POS + FPOS (diagpkt_lsm_rsp_type, rsp.pkt) + length + sizeof (uint16); + if (size > DIAGSVC_MALLOC_PKT_ITEM_SIZE) { + DIAG_LOGE("diag: In %s, invalid len: %d, max length: %d\n", + __func__, size, DIAGSVC_MALLOC_PKT_ITEM_SIZE); + return NULL; + } + + /*----------------------------------------------- + Try to allocate a buffer. Size of buffer must + include space for overhead and CRC at the end. + -----------------------------------------------*/ + pdiag_data = (diag_data*)DiagSvc_Malloc (size, PKT_SVC_ID); + if(NULL == pdiag_data) + { + /* Alloc not successful. Return NULL. DiagSvc_Malloc() allocates memory + from client's heap using a malloc call if the pre-malloced buffers are not available. + So if this fails, it means that the client is out of heap. */ + return NULL; + } + /* Fill in the fact that this is a response */ + pdiag_data->diag_data_type = DIAG_DATA_TYPE_RESPONSE; + // WM7 prototyping: advance the pointer now + item = (diagpkt_lsm_rsp_type*)((byte*)(pdiag_data)+DIAG_REST_OF_DATA_POS); + + /* This pattern is written to verify pointers elsewhere in this + service are valid. */ + item->rsp.pattern = DIAGPKT_HDR_PATTERN; /* Sanity check pattern */ + + /* length == size unless packet is resized later */ + item->rsp.size = length; + item->rsp.length = length; + + pattern = (uint16 *) &item->rsp.pkt[length]; + + /* We need this to meet alignment requirements - MATS */ + p = (unsigned char *) pattern; + p[0] = (DIAGPKT_OVERRUN_PATTERN >> 8) & 0xff; + p[1] = (DIAGPKT_OVERRUN_PATTERN >> 0) & 0xff; + + pkt = (diagpkt_hdr_type *) & item->rsp.pkt; + + if (pkt) + { + pkt->command_code = code; + } + return (void *) pkt; + +} /* diagpkt_alloc */ + +/*=========================================================================== + +FUNCTION DIAGPKT_DELAY_COMMIT + +DESCRIPTION + This function commits the response. + +DEPENDENCIES + None + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ +void diagpkt_delay_commit (void *pkt) +{ + if (!pkt) + return; + + unsigned int pkt_len = 0; + diag_data_delayed_response* pdiag_del_rsp_data = NULL; + diag_data* pdiag_data = NULL; + diagpkt_subsys_delayed_rsp_id_type delayed_rsp_id; + int is_dci_pkt = 0, num_bytes = 0; + uint32 dci_pkt_type = DCI_PKT_TYPE, dci_cmd_code = DCI_DELAYED_RSP_CODE; + uint32 rsp_len = 0, rsp_index = 0; + unsigned char *temp = NULL; + diagpkt_subsys_rsp_cnt rsp_count = ((diagpkt_subsys_hdr_type_v2 *)pkt)->rsp_cnt; + diag_dci_delayed_rsp_tbl_t *delayed_rsp_dci_entry = NULL; + + delayed_rsp_id = diagpkt_subsys_get_delayed_rsp_id(pkt); + /* Check if it is a DCI packet */ + delayed_rsp_dci_entry = diag_dci_delayed_rsp_id_present(delayed_rsp_id); + if (delayed_rsp_dci_entry) + is_dci_pkt = 1; + + pdiag_del_rsp_data = (diag_data_delayed_response*)((byte *)(pkt) - DIAG_DEL_RESP_REST_OF_DATA_POS); + pkt_len = pdiag_del_rsp_data->length; + /* + * We don't need to Write the "length" field in pdiag_del_rsp_data to DCM, + * so strip that out to get the diag_data from diag_data_delayed_response. + */ + pdiag_data = (diag_data*)((byte*)pdiag_del_rsp_data + sizeof(pdiag_del_rsp_data->length)); + if (pkt_len > 0 && -1 != diag_fd) { + /* This is a DCI packet. Write DCI headers in front of the packet */ + if (is_dci_pkt) { + rsp_len = sizeof(uint32) + sizeof(uint32) + sizeof(int) + pkt_len; + temp = (unsigned char*)DiagSvc_Malloc(rsp_len, PKT_SVC_ID); + if (!temp) { + DIAG_LOGE("diag: In %s Could not allocate memory\n", __func__); + DiagSvc_Free(pdiag_del_rsp_data, GEN_SVC_ID); + return; + } + memcpy(temp, &dci_pkt_type, sizeof(uint32)); + rsp_index += sizeof(uint32); + memcpy(temp + rsp_index, &dci_cmd_code, sizeof(uint32)); + rsp_index += sizeof(uint32); + memcpy(temp + rsp_index, &delayed_rsp_dci_entry->dci_tag, sizeof(int)); + rsp_index += sizeof(int); + memcpy(temp + rsp_index, (void *)((byte *)(pdiag_data) + sizeof(int)), pkt_len); + num_bytes = write(diag_fd, temp, rsp_len); + DiagSvc_Free(temp, PKT_SVC_ID); + /* If it is the last response in the delayed response sequence, delete the entry from table */ + if (rsp_count > 0 && rsp_count < 0x1000) + diag_dci_delete_delayed_rsp_entry(delayed_rsp_dci_entry); + } else { + num_bytes = write(diag_fd, (const void*)pdiag_data, pkt_len + DIAG_REST_OF_DATA_POS); + } + if(num_bytes != 0) { + DIAG_LOGE("Diag_LSM_Pkt: Write failed in %s, bytes written: %d, error: %d\n", + __func__, num_bytes, errno); + gPkt_commit_fail++; + } + } + DiagSvc_Free(pdiag_del_rsp_data, GEN_SVC_ID); +} + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_ALLOC + +DESCRIPTION + This function returns the command code in the specified diag packet. + +DEPENDENCIES + None + +RETURN VALUE + Pointer to allocated memory + +SIDE EFFECTS + None + +===========================================================================*/ +void * +diagpkt_subsys_alloc (diagpkt_subsys_id_type id, + diagpkt_subsys_cmd_code_type code, unsigned int length) +{ + diagpkt_subsys_hdr_type *hdr = NULL; + if(-1 == diag_fd) + { + return NULL; + } + + hdr = (diagpkt_subsys_hdr_type *) diagpkt_alloc (DIAG_SUBSYS_CMD_F, length); + + if( hdr != NULL ) + { + hdr->subsys_id = id; + hdr->subsys_cmd_code = code; + + } + + return (void *) hdr; + +} /* diagpkt_subsys_alloc */ + + +/*=========================================================================== +FUNCTION DIAGPKT_SUBSYS_ALLOC_V2 + +DESCRIPTION + This function allocates the specified amount of space from a pre-malloced buffer. + If space is unavailable in the pre-malloced buffer, then a malloc is done. + +DEPENDENCIES + diagpkt_commit() must be called to commit the response packet to be sent. + Not calling diagpkt_commit() will result in a memory leak. + +RETURN VALUE + pointer to the allocated memory + +SIDE EFFECTS + None + +============================================================================*/ + +void *diagpkt_subsys_alloc_v2(diagpkt_subsys_id_type id, + diagpkt_subsys_cmd_code_type code, unsigned int length) +{ + diagpkt_subsys_hdr_type_v2 *hdr = NULL; + if(diag_fd == DIAG_INVALID_HANDLE) + return NULL; + + hdr = (diagpkt_subsys_hdr_type_v2 *)diagpkt_alloc(DIAG_SUBSYS_CMD_VER_2_F, length); + if (hdr == NULL) + return NULL; + + hdr->subsys_id = id; + hdr->subsys_cmd_code = code; + hdr->status = 0; + if (diagpkt_with_delay(id, code)) { + hdr->delayed_rsp_id = diagpkt_get_delayed_rsp_id_lsm(); + if (!hdr->delayed_rsp_id) { + diagpkt_lsm_rsp_type *item = DIAGPKT_PKT2LSMITEM(hdr); + diag_data* pdiag_data = (diag_data*)((byte*)(item) - DIAG_REST_OF_DATA_POS); + DiagSvc_Free(pdiag_data,PKT_SVC_ID); + return NULL; + } + } else { + hdr->delayed_rsp_id = 0; + } + hdr->rsp_cnt = 0; + return (void *) hdr; +} + +/*=========================================================================== + +FUNCTION DIAGPKT_SUBSYS_ALLOC_V2_DELAY + +DESCRIPTION + This function allocates the specified amount of space from a pre-malloced buffer. + If space is unavailable in the pre-malloced buffer, then a malloc is done.This + function is used to send a delayed response.This response has same priority as + F3 messages and logs. + +DEPENDENCIES + diagpkt_delay_commit() must be called to commit the response packet to be + sent. Not calling diagpkt_delay_commit() will result in a memory leak and + response packet will not be sent. + + Note:User is required to provide delayed response id as an argument. + This helps tools to match the delayed response with the original + request response pair. + +RETURN VALUE + pointer to the allocated memory + +SIDE EFFECTS + None + +===========================================================================*/ +void * +diagpkt_subsys_alloc_v2_delay (diagpkt_subsys_id_type id, + diagpkt_subsys_cmd_code_type code, + diagpkt_subsys_delayed_rsp_id_type delayed_rsp_id_arg, + unsigned int length) +{ + diagpkt_subsys_hdr_type_v2 *hdr = NULL; + if(-1 == diag_fd) + { + return NULL; + } + + hdr = (diagpkt_subsys_hdr_type_v2 *) diagpkt_delay_alloc( + DIAG_SUBSYS_CMD_VER_2_F, + length); + + if(hdr != NULL) + { + hdr->subsys_id = id; + hdr->subsys_cmd_code = code; + hdr->status = 0; + hdr->delayed_rsp_id = delayed_rsp_id_arg; + hdr->rsp_cnt = 1; + } + return (void *) hdr; +} /* diagpkt_subsys_alloc_v2_delay */ + + +/*=========================================================================== + +FUNCTION DIAGPKT_SHORTEN + +DESCRIPTION + In legacy diag, this function was used to shorten a previously allocated + response buffer. Now, since we use pre-malloced buffers, this function will + not serve the purpose of freeing any memory. It just updates the length + field with the new length. + +DEPENDENCIES + None + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ + +void +diagpkt_shorten (void *pkt, unsigned int new_length) +{ + + diagpkt_lsm_rsp_type *item = NULL; + uint16 *pattern = NULL; + + if (pkt) + { + /* Do pointer arithmetic in bytes, then case to q_type; */ + item = DIAGPKT_PKT2LSMITEM (pkt); + + if (new_length < item->rsp.size) + { + unsigned char *p; + item->rsp.length = new_length; + + /* Write the new buffer overrun detection pattern */ + pattern = (uint16 *) & item->rsp.pkt[new_length]; + + /* We need this to meet alignment requirements - MATS */ + p = (unsigned char *) pattern; + p[0] = (DIAGPKT_OVERRUN_PATTERN >> 8) & 0xff; + p[1] = (DIAGPKT_OVERRUN_PATTERN >> 0) & 0xff; + } + else + { + DIAG_LOGE(" diagpkt_shorten: diagpkt_shorten Failed"); + return; + } + } + return; +} /* diagpkt_shorten */ +/*=========================================================================== + +FUNCTION DIAGPKT_COMMIT + +DESCRIPTION + This function commits previously allocated space in the diagnostics output + buffer. + +DEPENDENCIES + None + +RETURN VALUE + None + +SIDE EFFECTS + None + +===========================================================================*/ + +void diagpkt_commit (void *pkt) +{ + if (!pkt) + return; + + unsigned char *temp = NULL; + int ret; + unsigned int rsp_length = 0; + unsigned int rsp_index = 0; + uint8 dci_cmd_code = DCI_PKT_RSP_CODE; + uint8 dci_cmd_code_len = sizeof(uint8); + diagpkt_cmd_code_type packet_id; + + diagpkt_lsm_rsp_type *item = DIAGPKT_PKT2LSMITEM(pkt); + item->rsp_func = NULL; + item->rsp_func_param = NULL; + + if (item->rsp.length <= 0) + goto err; + if (-1 == diag_fd) + goto err; + rsp_length = (int)(item->rsp.length); + if (pkt_type == DIAG_DATA_TYPE_DCI_PKT) { + packet_id = diagpkt_get_cmd_code(pkt); + if (packet_id == DIAG_SUBSYS_CMD_VER_2_F) { + dci_cmd_code_len = sizeof(int); + dci_cmd_code = DCI_DELAYED_RSP_CODE; + diag_dci_add_delayed_rsp(diagpkt_subsys_get_delayed_rsp_id(pkt), dci_tag); + } + rsp_length += sizeof(uint32) + dci_cmd_code_len; + } + temp = (unsigned char*)DiagSvc_Malloc((int)DIAG_REST_OF_DATA_POS + rsp_length, PKT_SVC_ID); + if (!temp) { + DIAG_LOGE("diag: In %s Could not allocate memory\n", __func__); + goto err; + } + + memcpy(temp, (unsigned char*)&pkt_type, sizeof(pkt_type)); + rsp_index += DIAG_REST_OF_DATA_POS; + if (pkt_type == DIAG_DATA_TYPE_DCI_PKT) { + memcpy(temp + rsp_index, &(dci_cmd_code), sizeof(uint8)); + rsp_index += dci_cmd_code_len; + memcpy(temp + rsp_index, &(dci_tag), sizeof(dci_tag)); + rsp_index += sizeof(uint32); + } + memcpy(temp + rsp_index, pkt, item->rsp.length); + if ((ret = write(diag_fd, (const void*) temp, DIAG_REST_OF_DATA_POS + rsp_length)) != 0) { + DIAG_LOGE("Diag_LSM_Pkt: Write failed in %s, bytes written: %d, error: %d\n", __func__, ret, errno); + gPkt_commit_fail++; + } + DiagSvc_Free(temp, PKT_SVC_ID); +err: + /* Free the original response */ + diagpkt_free(pkt); +} + +/*=========================================================================== + +FUNCTION DIAGPKT_ERR_RSP + +DESCRIPTION + This function generates an error response packet. + +DEPENDENCIES + None + +RETURN VALUE + pointer to the error response + +SIDE EFFECTS + None + +===========================================================================*/ + +void * +diagpkt_err_rsp (diagpkt_cmd_code_type code, + void *req_pkt, uint16 req_len) +{ + DIAG_BAD_CMD_F_rsp_type *rsp; + const unsigned int rsp_len = MIN (sizeof (DIAG_BAD_CMD_F_rsp_type), + req_len + FPOS (DIAG_BAD_CMD_F_rsp_type, pkt)); + rsp = (DIAG_BAD_CMD_F_rsp_type *) diagpkt_alloc (code, rsp_len); + + if (!rsp) { + DIAG_LOGE("rsp pointer is null"); + return NULL; + } + + if(req_pkt) + { + memcpy ((void *) rsp->pkt, + (void *) req_pkt, + rsp_len - FPOS (DIAG_BAD_CMD_F_rsp_type, pkt)); + } + else if (req_len != 0) + { + //MSG_HIGH("Non-0 request length (%d) and NULL request pointer!",req_len,0,0); + DIAG_LOGE("Non-0 request length (%d) and NULL request pointer!", + req_len); + } + + return ((void *) rsp); +} /* diagkt_err_rsp */ + +/*========================================================================= +FUNCTION DIAGPKT_FREE + +DESCRIPTION + + This function free the packet allocated by diagpkt_alloc(), which doesn't + + need to 'commit' for sending as a response if it is merely a temporary + + processing packet. + +===========================================================================*/ + +void + +diagpkt_free(void *pkt) + +{ + if (pkt) + { + byte *item = (byte*)DIAGPKT_PKT2LSMITEM(pkt); + item -= DIAG_REST_OF_DATA_POS; + DiagSvc_Free ((void *)item,PKT_SVC_ID); + } + return; +} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt_i.h b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt_i.h new file mode 100755 index 000000000..677bd11d1 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsm_pkt_i.h @@ -0,0 +1,52 @@ +#ifndef DIAG_LSM_PKT_I_H +#define DIAG_LSM_PKT_I_H + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Internal Header File for Event Packet Req/Res Service Mapping + +GENERAL DESCRIPTION + +Copyright (c) 2007-2011, 2013-2014, 2016 Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + +$Header: + +when who what, where, why +-------- --- --------------------------------------------------------- +02/27/08 JV Created File +===========================================================================*/ + +#include "diagi.h" + +typedef struct { + diag_cmd_rsp rsp_func; + void *rsp_func_param; + diagpkt_rsp_type rsp; +} diagpkt_lsm_rsp_type; + +boolean Diag_LSM_Pkt_Init(void); + +/* clean up packet Req/Res service before exiting legacy service mapping layer. +Currently does nothing, just returns TRUE */ +boolean Diag_LSM_Pkt_DeInit(void); + +void diagpkt_LSM_process_request(void *req_pkt, uint16 pkt_len, int type); + +/*=========================================================================== + +FUNCTION DIAGPKT_FREE + +DESCRIPTION + This function free the packet allocated by diagpkt_alloc(), which doesn't + need to 'commit' for sending as a response because it is merely a temporary + processing packet. + +===========================================================================*/ + void diagpkt_free(void *pkt); + +#endif /* DIAG_LSM_EVENT_I_H */ diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_lsmi.h b/feeds/wifi-ax/qca-diag/src/src/diag_lsmi.h new file mode 100755 index 000000000..426897df1 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_lsmi.h @@ -0,0 +1,101 @@ +#ifndef DIAG_LSMI_H +#define DIAG_LSMI_H + +/*=========================================================================== + + Diag Mapping Layer DLL , internal declarations + +DESCRIPTION + Internal declarations for Diag Service Mapping Layer. + + +Copyright (c) 2007-2015 Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential +===========================================================================*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 sj Added featurization for WM specific code & CBSP2.0 +02/04/08 mad Created File +===========================================================================*/ + +#define DIAG_INVALID_HANDLE -1 +#define DIAG_MDLOG_DIR "/tmp/diag_logs/" +#define DIAG_MDLOG_PID_FILE "/tmp/diag_logs/diag_mdlog_pid" +#define DIAG_MDLOG_PID_FILE_SZ 100 +#define NUM_PROC 10 +#define HDLC_DISABLE 1 +extern int diag_fd; +extern int fd_md[NUM_PROC]; +extern int gdwClientID; +void log_to_device(unsigned char *ptr, int logging_mode, int size, int type); +void send_mask_modem(unsigned char mask_buf[], int count_mask_bytes); +int diag_has_remote_device(uint16 *remote_mask); +int diag_register_socket_cb(int (*callback_ptr)(void *data_ptr, int socket_id), void *data_ptr); +int diag_set_socket_fd(int socket_id, int socket_fd); +int diag_send_socket_data(int id, unsigned char buf[], int num_bytes); +int diag_get_max_channels(void); +int diag_read_mask_file_list(char *mask_list_file); + +/* === Functions dealing with diag wakelocks === */ + +/* Returns 1 if a wakelock is initialized for this process, + 0 otherwise. */ +int diag_is_wakelock_init(void); + +/* Opens the wakelock files and initializes the wakelock for + the current process. It doesn't hold any wakelock. To hold + a wakelock, call diag_wakelock_acquire. */ +void diag_wakelock_init(char *wakelock_name); + +/* Closes the wakelock files. It doesn't release the wakelock + for the current process if held. */ +void diag_wakelock_destroy(void); + +/* Acquires a wakelock for the current process under the name + given by diag_wakelock_init. */ +void diag_wakelock_acquire(void); + +/* Releases the wakelock held by the current process. */ +void diag_wakelock_release(void); + +/* To convert an integer/hexadecimal string to an integer */ +int to_integer(char *str); + +/* Request the kernel diag to turn on/off the hdlc encoding of the data. */ +int diag_hdlc_toggle(uint8 hdlc_support); + +/* === Functions dealing with qshrink4 === */ + +/* Creates threads to read the qshrink4 database threads. */ +int create_diag_qshrink4_db_parser_thread(unsigned int peripheral_mask); + +/* Parses the data for qshrink4 command response */ +int parse_data_for_qsr4_db_file_op_rsp(uint8 *ptr, int count_received_bytes); + +/* Add qshrink4 guid information to qmdl2 header */ +int add_guid_to_qshrink4_header(unsigned char * guid); + +/* Notify parser thread when a PD comes up */ +void diag_notify_parser_thread(int type, int peripheral_mask); + +void diag_set_peripheral_mask(unsigned int peripheral_mask); +void diag_get_peripheral_name_from_mask(char *peripheral_name, + unsigned int len, + unsigned int peripheral_mask); +void diag_kill_qshrink4_threads(void); + +extern boolean gbRemote; +#define DIAG_LSM_PKT_EVENT_PREFIX "DIAG_SYNC_EVENT_PKT_" +#define DIAG_LSM_MASK_EVENT_PREFIX "DIAG_SYNC_EVENT_MASK_" +#endif /* DIAG_LSMI_H */ + diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_qshrink4_db_parser.c b/feeds/wifi-ax/qca-diag/src/src/diag_qshrink4_db_parser.c new file mode 100755 index 000000000..902620b6d --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_qshrink4_db_parser.c @@ -0,0 +1,1264 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* +Copyright (c) 2015-2016 by Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential. + + Diag Qshrink4 Support + +GENERAL DESCRIPTION + +Implementation of qshrink 4 database reading using diag command request/responses + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ +#include +#include "comdef.h" +#include "event.h" +#include "msg.h" +#include "log.h" +#include "diag_lsm.h" +#include "diag_lsmi.h" +#include "diag_shared_i.h" +#include "diagdiag.h" +#include "stdio.h" +#include "string.h" +#include +#include "diag_lsm_dci.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "errno.h" +#ifndef FEATURE_LE_DIAG +#include +#endif + +#define std_strlprintf snprintf + +#define QSR4_DB_CMD_REQ_BUF_SIZE 50 +#define QSR4_DB_READ_BUF_SIZE 5000 +#define MAX_QSR4_DB_FILE_READ_PER_RSP 4000 + +#define ESC_CHAR 0x7d +#define CTRL_CHAR 0x7e + +int fd_qsr4_xml[NUM_PROC] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; +int db_thread_initialized = 0; +qsr4_db_file_parser_state parser_state; +int qsr4_db_file_fd = -1; +int kill_thread = 0; +char file_name_curr[NUM_PROC][FILE_NAME_LEN]; +unsigned char qsr4_db_cmd_req_buf[QSR4_DB_CMD_REQ_BUF_SIZE]; + +typedef PACK(struct) { + unsigned int peripheral_mask; + unsigned int peripheral_type; +} qsr4_db_peripheral_info; + +typedef PACK(struct) { + uint32 data1; + uint16 data2; + uint16 data3; + char data4[8]; +} GUID; + +typedef PACK(struct) { + uint16 num_read; + uint32 offset; + uint8 read_status; +} qsr4_db_file_block_status; + +typedef PACK(struct) { + int peripheral; + uint8 guid[GUID_LEN]; + uint32 file_len; + uint8 read_completed; + uint8 *buf; + struct qsr4_db_file_list *next; + uint32 num_blocks; + int fd; + qsr4_db_file_block_status *head; +} qsr4_db_file_list; + +static qsr4_db_file_list* head = NULL; + +struct qsr4_db_write_buf { + int data_ready; + qsr4_db_file_list *write_entry; + pthread_mutex_t read_mutex; + pthread_mutex_t write_mutex; + pthread_cond_t write_cond; + pthread_cond_t read_cond; +}; + +struct qsr4_db_read_buf_pool { + unsigned char* db_read_buf; + int data_ready; + pthread_mutex_t read_rsp_mutex; + pthread_mutex_t write_rsp_mutex; + pthread_cond_t write_rsp_cond; + pthread_cond_t read_rsp_cond; +}; + +static struct qsr4_db_read_buf_pool qsr4_db_buffer_pool[2]; +struct qsr4_db_write_buf qsr4_db_write_buf_pool[1]; + +pthread_t qsr4_db_parser_thread_hdl; +pthread_t db_write_thread_hdl; +pthread_mutex_t qsr4_read_db_mutex; +pthread_cond_t qsr4_read_db_cond; + +volatile int curr_read_idx = 0; +volatile int curr_write_idx = 0; + +qsr4_db_peripheral_info periph_info; +int in_write = 0; +int in_wait_for_peripheral_status = 0; +static int create_qsr4_db_file(qsr4_db_file_list* entry, int peripheral_type) +{ + int qsr4_file_fd = -1; + char temp[10]; + char read_buf[100]; + int err_status; + int i = 0; + int ret_val; + GUID* guid_val; + + if (!entry || (peripheral_type < MSM || peripheral_type > MDM)) + return qsr4_file_fd; + + if (qsr4_file_fd < 0) { + guid_val = (GUID *)&(entry->guid[0]); + + std_strlprintf(read_buf, 100, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", guid_val->data1, + guid_val->data2, guid_val->data3,guid_val->data4[0], guid_val->data4[1], + guid_val->data4[2], guid_val->data4[3], guid_val->data4[4], guid_val->data4[5], + guid_val->data4[6], guid_val->data4[7]); + (void)std_strlprintf(file_name_curr[peripheral_type], + FILE_NAME_LEN, "%s%s%s%s", + output_dir[peripheral_type],"/", read_buf, + ".qdb"); + qsr4_file_fd = open(file_name_curr[peripheral_type], + O_CREAT | O_RDWR | O_SYNC | O_TRUNC, + 0644); + } + return qsr4_file_fd; + +} + +static int diag_qsr4_get_cmd_code_for_peripheral(int peripheral) +{ + switch (peripheral) { + case DIAG_MODEM_PROC: + return DIAGDIAG_QSR4_FILE_OP_MODEM; + case DIAG_LPASS_PROC: + return DIAGDIAG_QSR4_FILE_OP_ADSP; + case DIAG_WCNSS_PROC: + return DIAGDIAG_QSR4_FILE_OP_WCNSS; + case DIAG_SENSORS_PROC: + return DIAGDIAG_QSR4_FILE_OP_SLPI; + default: + return -1; + } + +} + +static void insert_diag_qsr4_db_guid_to_list(file_info* db_file_info, int peripheral_type, int peripheral) +{ + qsr4_db_file_list *temp = NULL; + int i = 0; + char guid[100]; + char read_buf[100]; + GUID* guid_val; + qsr4_db_file_list *entry = NULL; + int ret_val; + + if (!db_file_info || (peripheral_type < MSM || peripheral_type > MDM) || + (peripheral < DIAG_MODEM_PROC || peripheral > DIAG_SENSORS_PROC)) + return; + + temp = (qsr4_db_file_list*)malloc(sizeof(qsr4_db_file_list)); + if (!temp) + return; + memcpy(temp->guid, db_file_info->guid, GUID_LEN); + guid_val = (GUID*)&(db_file_info->guid[0]); + if (hdlc_disabled) { + add_guid_to_qshrink4_header(&db_file_info->guid[0]); + } else { + std_strlprintf(read_buf, 100, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", guid_val->data1, + guid_val->data2, guid_val->data3, guid_val->data4[0], guid_val->data4[1], + guid_val->data4[2], guid_val->data4[3], guid_val->data4[4], guid_val->data4[5], + guid_val->data4[6], guid_val->data4[7]); + ret_val = std_strlprintf(guid, 100, "%s%s%s\n", "", read_buf, ""); + if ((fd_qsr4_xml[peripheral_type] >= 0) && (ret_val > 0)) + write(fd_qsr4_xml[peripheral_type], guid, ret_val); + } + temp->file_len = db_file_info->file_len; + temp->peripheral = peripheral; + temp->read_completed = 0; + temp->next = NULL; + temp->head = NULL; + if (head == NULL) + head = temp; + else { + entry = head; + while (entry->next != NULL) { + if (memcmp(entry->guid, temp->guid, GUID_LEN) == 0) { + free(temp); + temp = NULL; + return; + } + entry = (qsr4_db_file_list *)(entry->next); + } + entry->next = (struct qsr4_db_file_list *)temp; + temp->next = NULL; + } + + return; +} + +static int diag_qsr4_db_file_mem_init(qsr4_db_file_list** file_entry) +{ + qsr4_db_file_block_status* file_block_offset = NULL; + qsr4_db_file_list* entry = NULL; + uint32 num_blocks = 0; + uint32 i = 0; + + if (!file_entry) + return FALSE; + + entry = *file_entry; + if (!entry) + return FALSE; + + num_blocks = ((entry->file_len) / MAX_QSR4_DB_FILE_READ_PER_RSP); + if (((entry->file_len) % MAX_QSR4_DB_FILE_READ_PER_RSP) > 0) + num_blocks++; + + entry->num_blocks = num_blocks; + entry->buf = malloc(entry->file_len); + if (entry->buf == NULL) + return FALSE; + + file_block_offset = calloc(num_blocks, sizeof(qsr4_db_file_block_status)); + if (file_block_offset == NULL) { + free(entry->buf); + return FALSE; + } + if (entry->head == NULL) + entry->head = file_block_offset; + + return TRUE; + +} + +static int diag_send_qsr4_db_file_list_cmd_req(int peripheral, int peripheral_type) +{ + int offset = 0; + int length = 0; + int i; + unsigned char* ptr = qsr4_db_cmd_req_buf; + diag_qsr_header_req* req = NULL; + + if ((peripheral_type < MSM || peripheral_type > MDM) || + (peripheral < DIAG_MODEM_PROC || peripheral > DIAG_SENSORS_PROC)) + return FALSE; + + *(int*)ptr = USER_SPACE_RAW_DATA_TYPE; + offset += sizeof(int); + if (peripheral_type == MDM) { + *(int*)(ptr + offset) = MDM_TOKEN; + offset += sizeof(int); + } else if (peripheral_type == QSC) { + *(int*)(ptr + offset) = QSC_TOKEN; + offset += sizeof(int); + } + ptr = ptr + offset; + req = (diag_qsr_header_req*)ptr; + req->cmd_code = DIAG_SUBSYS_CMD_VER_2_F; + req->subsys_id = DIAG_SUBSYS_DIAG_SERV; + req->subsys_cmd_code = diag_qsr4_get_cmd_code_for_peripheral(peripheral); + req->version = 1; + req->opcode = DIAGDIAG_FILE_LIST_OPERATION; + length = sizeof(diag_qsr_header_req); + if (length + offset <= QSR4_DB_CMD_REQ_BUF_SIZE) + diag_send_data(qsr4_db_cmd_req_buf, offset + length); + return TRUE; +} + +static int process_qsr4_db_file_list_response(int peripheral_type, int peripheral) +{ + int i = 0; + int number_of_files; + diag_qsr_file_list_rsp* rsp; + unsigned char* buf_ptr; + + buf_ptr = &(qsr4_db_buffer_pool[curr_write_idx].db_read_buf[0]); + if (buf_ptr[0] == DIAG_BAD_CMD_F) + return FALSE; + else { + rsp = (diag_qsr_file_list_rsp*)buf_ptr; + if ((rsp->rsp_header.version != 1) || (rsp->rsp_header.opcode != DIAGDIAG_FILE_LIST_OPERATION)) { + return FALSE; + } + + if (rsp->status == 0) { + number_of_files = rsp->num_files; + for (i = 0; i < number_of_files; i++) { + insert_diag_qsr4_db_guid_to_list(&rsp->info[i], peripheral_type, peripheral); + } + return TRUE; + } else + return FALSE; + } + +} + +static int diag_send_qsr4_file_open_cmd_req(qsr4_db_file_list* entry, int peripheral_type, int peripheral) +{ + int offset = 0; + int length = 0; + unsigned char* ptr = qsr4_db_cmd_req_buf; + diag_qsr_file_open_req* req_ptr; + + if (!entry || (peripheral_type < MSM || peripheral_type > MDM) || + (peripheral < DIAG_MODEM_PROC || peripheral > DIAG_SENSORS_PROC)) + return FALSE; + + *(int*)ptr = USER_SPACE_RAW_DATA_TYPE; + offset += sizeof(int); + if (peripheral_type == MDM) { + *(int*)(ptr + offset) = MDM_TOKEN; + offset += sizeof(int); + } else if (peripheral_type == QSC) { + *(int*)(ptr + offset) = QSC_TOKEN; + offset += sizeof(int); + } + ptr = ptr + offset; + req_ptr = (diag_qsr_file_open_req*)ptr; + + length = sizeof(diag_qsr_file_open_req); + if (length + offset <= QSR4_DB_CMD_REQ_BUF_SIZE) { + req_ptr->req.cmd_code = DIAG_SUBSYS_CMD_VER_2_F; + req_ptr->req.subsys_id = DIAG_SUBSYS_DIAG_SERV; + req_ptr->req.subsys_cmd_code = diag_qsr4_get_cmd_code_for_peripheral(peripheral); + req_ptr->req.version = 1; + req_ptr->req.opcode = DIAGDIAG_FILE_OPEN_OPERATION; + memcpy(req_ptr->guid, entry->guid, GUID_LEN); + diag_send_data(qsr4_db_cmd_req_buf, offset + length); + } + return TRUE; + +} + + +static int process_qsr_db_file_open_rsp() +{ + int offset = 0; + int length = 0; + int i = 0; + diag_qsr_file_open_rsp* ptr; + unsigned char* buf_ptr; + buf_ptr = &(qsr4_db_buffer_pool[curr_write_idx].db_read_buf[0]); + + if (buf_ptr[0] == DIAG_BAD_CMD_F) + return -1; + else { + ptr = (diag_qsr_file_open_rsp*)buf_ptr; + if ((ptr->rsp_header.version != 1) || (ptr->rsp_header.opcode != DIAGDIAG_FILE_OPEN_OPERATION)) + return FALSE; + if (ptr->status == 0) + return ptr->read_file_fd; + else + return -1; + } +} + +static int diag_send_qsr4_file_read_cmd_req(uint16 read_file_fd, + int peripheral_type, + int peripheral, + unsigned int file_offset, + int file_len) +{ + int offset = 0; + int length = 0; + int i; + unsigned char* ptr = qsr4_db_cmd_req_buf; + diag_qsr_file_read_req* req; + + if ((peripheral_type < MSM || peripheral_type > MDM) || + (peripheral < DIAG_MODEM_PROC || peripheral > DIAG_SENSORS_PROC)) + return FALSE; + + offset += sizeof(int); + *(int*)ptr = USER_SPACE_RAW_DATA_TYPE; + if (peripheral_type == MDM) { + *(int*)(ptr + offset) = MDM_TOKEN; + offset += sizeof(int); + } else if (peripheral_type == QSC) { + *(int*)(ptr + offset) = QSC_TOKEN; + offset += sizeof(int); + } + ptr = ptr + offset; + req = (diag_qsr_file_read_req*)ptr; + req->req.cmd_code = DIAG_SUBSYS_CMD_VER_2_F; + req->req.subsys_id = DIAG_SUBSYS_DIAG_SERV; + req->req.subsys_cmd_code = diag_qsr4_get_cmd_code_for_peripheral(peripheral); + req->req.version = 1; + req->req.opcode = DIAGDIAG_FILE_READ_OPERATION; + req->read_file_fd = read_file_fd; + req->offset = file_offset; + req->req_bytes = file_len; + length = sizeof(diag_qsr_file_read_req); + if (length + offset <= QSR4_DB_CMD_REQ_BUF_SIZE) + diag_send_data(qsr4_db_cmd_req_buf, offset + length); + return TRUE; +} + +static int process_qsr_db_file_read_rsp(qsr4_db_file_list** file_entry, uint32 offset, + uint32* ret_bytes, int peripheral_type) +{ + (void) peripheral_type; + diag_qsr_file_read_rsp* rsp = NULL; + unsigned char* buf_ptr = NULL; + (void) file_entry; + (void) offset; + (void) ret_bytes; + + buf_ptr = &(qsr4_db_buffer_pool[curr_write_idx].db_read_buf[0]); + + if (buf_ptr[0] == DIAG_BAD_CMD_F) + return 0; + else { + rsp = (diag_qsr_file_read_rsp*)buf_ptr; + if ((rsp->version != 1) || (rsp->opcode != DIAGDIAG_FILE_READ_OPERATION) || + (rsp->status)) + return FALSE; + + return TRUE; + } + +} +static int process_qsr_db_file_read_delayed_rsp(qsr4_db_file_list** file_entry, uint16* rsp_count, + uint32* ret_bytes, int peripheral_type) +{ + diag_qsr_file_read_rsp* rsp; + int i = 0; + uint16 bytes_read; + uint8_t* file_block_src_ptr; + qsr4_db_file_block_status* file_block_offset; + qsr4_db_file_list* entry = *file_entry; + unsigned char* buf_ptr; + struct qsr4_db_read_buf_pool* temp_ptr; + int offset_index = 0; + (void)peripheral_type; + + buf_ptr = &(qsr4_db_buffer_pool[curr_write_idx].db_read_buf[0]); + if (buf_ptr[0] == DIAG_BAD_CMD_F) + return FALSE; + else { + rsp = (diag_qsr_file_read_rsp*)buf_ptr; + if ((rsp->version != 1) || (rsp->opcode != DIAGDIAG_FILE_READ_OPERATION) || + (rsp->status)) + return FALSE; + + if (rsp->status == 0) { + bytes_read = rsp->num_read; + *ret_bytes = rsp->num_read; + *rsp_count = rsp->rsp_cnt; + offset_index = ((rsp->offset) / MAX_QSR4_DB_FILE_READ_PER_RSP); + if((rsp->offset) % MAX_QSR4_DB_FILE_READ_PER_RSP) + offset_index++; + file_block_src_ptr = (uint8 *)entry->head; + file_block_offset = (qsr4_db_file_block_status *) (&file_block_src_ptr[0] + (offset_index*sizeof(qsr4_db_file_block_status))); + if (file_block_offset != NULL ) + file_block_offset->read_status = 1; + if (rsp->offset < entry->file_len) + memcpy(&entry->buf[rsp->offset], rsp->data, bytes_read); + } + + return TRUE; + } + +} +static int diag_send_qsr4_file_close_send_req(uint16 read_file_fd, int peripheral_type, int peripheral) +{ + int offset = 0; + int length = 0; + unsigned char* ptr = qsr4_db_cmd_req_buf; + diag_qsr_file_close_req* req_ptr; + + if ((peripheral_type < MSM || peripheral_type > MDM) || + (peripheral < DIAG_MODEM_PROC || peripheral > DIAG_SENSORS_PROC)) + return FALSE; + + *(int*)ptr = USER_SPACE_RAW_DATA_TYPE; + offset += sizeof(int); + if (peripheral_type == MDM) { + *(int*)(ptr + offset) = MDM_TOKEN; + offset += sizeof(int); + } else if (peripheral_type == QSC) { + *(int*)(ptr + offset) = QSC_TOKEN; + offset += sizeof(int); + } + ptr = ptr + offset; + req_ptr = (diag_qsr_file_close_req*)ptr; + + length = sizeof(diag_qsr_file_close_req); + if (length + offset <= QSR4_DB_CMD_REQ_BUF_SIZE) { + req_ptr->req.cmd_code = DIAG_SUBSYS_CMD_VER_2_F; + req_ptr->req.subsys_id = DIAG_SUBSYS_DIAG_SERV; + switch (peripheral) { + case DIAG_MODEM_PROC: + req_ptr->req.subsys_cmd_code = DIAGDIAG_QSR4_FILE_OP_MODEM; + break; + case DIAG_LPASS_PROC: + req_ptr->req.subsys_cmd_code = DIAGDIAG_QSR4_FILE_OP_ADSP; + break; + case DIAG_WCNSS_PROC: + req_ptr->req.subsys_cmd_code = DIAGDIAG_QSR4_FILE_OP_WCNSS; + break; + case DIAG_SENSORS_PROC: + req_ptr->req.subsys_cmd_code = DIAGDIAG_QSR4_FILE_OP_SLPI; + break; + } + req_ptr->req.version = 1; + req_ptr->req.opcode = DIAGDIAG_FILE_CLOSE_OPERATION; + req_ptr->read_file_fd = read_file_fd; + diag_send_data(qsr4_db_cmd_req_buf, offset + length); + } + return TRUE; + +} +static int process_qsr_db_file_close_rsp() +{ + diag_qsr_file_close_rsp* rsp; + unsigned char* buf_ptr; + buf_ptr = &(qsr4_db_buffer_pool[curr_write_idx].db_read_buf[0]); + qsr4_db_buffer_pool[curr_write_idx].data_ready = 0; + if (buf_ptr[0] == DIAG_BAD_CMD_F) + return 0; + else { + rsp = (diag_qsr_file_close_rsp*)buf_ptr; + if ((rsp->rsp_header.version != 1) || (rsp->rsp_header.opcode != DIAGDIAG_FILE_CLOSE_OPERATION)) + return FALSE; + if (rsp->status == 0) { + return 1; + } else + return 0; + } + +} +static int wait_for_response() +{ + struct timespec time; + struct timeval now; + int rt = 0; + + gettimeofday(&now, NULL); + time.tv_sec = now.tv_sec + 10000 / 1000; + time.tv_nsec = now.tv_usec + (10000 % 1000) * 1000000; + pthread_mutex_lock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + if (!qsr4_db_buffer_pool[curr_write_idx].data_ready) + rt = pthread_cond_timedwait(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_cond), &(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex), &time); + return rt; +} + +static int diag_qsr4_reset_db_read_buffer() +{ + qsr4_db_buffer_pool[curr_write_idx].data_ready = 0; + pthread_mutex_lock(&(qsr4_db_buffer_pool[curr_write_idx].read_rsp_mutex)); + pthread_cond_signal(&(qsr4_db_buffer_pool[curr_write_idx].read_rsp_cond)); + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].read_rsp_mutex)); + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + curr_write_idx = !curr_write_idx; + return 0; +} +static int diag_read_qsr4_db_from_peripheral(int peripheral_type, int peripheral) +{ + qsr4_db_file_list* entry; + int ret; + uint32 ret_bytes; + unsigned int offset = 0; + int read_file_fd; + unsigned int file_len; + int status = 0; + int rt; + uint32 i; + uint16 rsp_count = 0; + qsr4_db_file_block_status* read_entry; + uint8 * block; + + parser_state = DB_PARSER_STATE_ON; + ret = diag_send_qsr4_db_file_list_cmd_req(peripheral, peripheral_type); + if (!ret) { + DIAG_LOGE("diag: In %s failed to send file list cmd for periph type %d periph %d\n", __func__, peripheral_type, peripheral); + parser_state = DB_PARSER_STATE_OFF; + return 0; + } + parser_state = DB_PARSER_STATE_LIST; + rt = wait_for_response(); + if (rt == ETIMEDOUT) { + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + DIAG_LOGE("diag:In %s time out while waiting for file list cmd rsp for periph type:%d periph:%d\n", __func__, peripheral_type, peripheral); + parser_state = DB_PARSER_STATE_OFF; + return 0; + } + + ret = process_qsr4_db_file_list_response(peripheral_type, peripheral); + diag_qsr4_reset_db_read_buffer(); + if (!ret) { + parser_state = DB_PARSER_STATE_OFF; + return 0; + } + + if (ret) { + entry = head; + while (entry != NULL && entry->read_completed == 0) { + ret = diag_qsr4_db_file_mem_init(&entry); + if (!ret) { + DIAG_LOGE("diag: In %s failed to create memory to store database file\n",__func__); + parser_state = DB_PARSER_STATE_OFF; + return 0; + } + file_len = entry->file_len; + ret = diag_send_qsr4_file_open_cmd_req(entry, peripheral_type, peripheral); + if (!ret) { + DIAG_LOGE("diag: In %s failed to send file open cmd for periph type %d periph %d\n", __func__, peripheral_type, peripheral); + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + continue; + } + parser_state = DB_PARSER_STATE_OPEN; + rt = wait_for_response(); + if (rt == ETIMEDOUT) { + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + DIAG_LOGE("diag:In %s time out while waiting for file open cmd rsp for periph type:%d periph:%d\n",__func__, peripheral_type, peripheral); + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + continue; + } + read_file_fd = process_qsr_db_file_open_rsp(); + diag_qsr4_reset_db_read_buffer(); + if (read_file_fd < 0) { + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + continue; + } + qsr4_db_file_fd = create_qsr4_db_file(entry, peripheral_type); + if (qsr4_db_file_fd < 0) { + DIAG_LOGE("diag: In %s Failed to create database file for periph type %d periph %d\n", __func__, peripheral_type, peripheral); + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + if (read_file_fd >= 0) { + ret = diag_send_qsr4_file_read_cmd_req(read_file_fd, peripheral_type, peripheral, offset, file_len); + if (!ret) { + DIAG_LOGE("diag: In %s failed to send file read cmd for periph type %d periph %d\n", __func__, peripheral_type, peripheral); + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + parser_state = DB_PARSER_STATE_READ; + rt = wait_for_response(); + if (rt == ETIMEDOUT) { + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + DIAG_LOGE("diag:In %s time out while waiting for file read cmd rsp for periph type:%d periph:%d\n",__func__, peripheral_type, peripheral); + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + status = process_qsr_db_file_read_rsp(&entry, offset, &ret_bytes, peripheral_type); + diag_qsr4_reset_db_read_buffer(); + if (!status) { + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + do { + rt = wait_for_response(); + if (rt == ETIMEDOUT) { + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + DIAG_LOGE("diag:In %s time out while waiting for file read delayed cmd rsp for periph type:%d periph:%d\n",__func__, peripheral_type, peripheral); + break; + } + status = process_qsr_db_file_read_delayed_rsp(&entry, &rsp_count, &ret_bytes, peripheral_type); + diag_qsr4_reset_db_read_buffer(); + if (!status) { + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + } while (rsp_count > 0 && rsp_count >= 0x1000); + + /* Resend read command for failed blocks*/ + for (i = 0; i < entry->num_blocks; i++) { + block = (uint8 *)entry->head; + read_entry = (qsr4_db_file_block_status*)(&block[0] + (i * (sizeof(qsr4_db_file_block_status)))); + if (!read_entry->read_status) { + offset = i * MAX_QSR4_DB_FILE_READ_PER_RSP; + ret = diag_send_qsr4_file_read_cmd_req(read_file_fd, peripheral_type, peripheral, offset, MAX_QSR4_DB_FILE_READ_PER_RSP); + if (!ret) { + DIAG_LOGE("diag: In %s failed to send file read cmd for periph type %d periph %d\n", __func__, peripheral_type, peripheral); + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + parser_state = DB_PARSER_STATE_READ; + rt = wait_for_response(); + if (rt == ETIMEDOUT) { + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + DIAG_LOGE("diag:In %s time out while waiting for file read cmd rsp for periph type:%d periph:%d\n",__func__, peripheral_type, peripheral); + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + status = process_qsr_db_file_read_rsp(&entry, offset, &ret_bytes, peripheral_type); + diag_qsr4_reset_db_read_buffer(); + if (!status) { + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + rt = wait_for_response(); + if (rt == ETIMEDOUT) { + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + DIAG_LOGE("diag:In %s time out while waiting for file read delayed cmd rsp for periph type:%d periph:%d\n",__func__, peripheral_type, peripheral); + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + status = process_qsr_db_file_read_delayed_rsp(&entry, &rsp_count, &ret_bytes, peripheral_type); + diag_qsr4_reset_db_read_buffer(); + if (!status) { + free(entry->buf); + entry->buf = NULL; + free(entry->head); + entry->head = NULL; + entry->fd = -1; + goto close; + } + } + } + + entry->read_completed = 1; + qsr4_db_write_buf_pool[0].write_entry = entry; + entry->fd = qsr4_db_file_fd; + pthread_mutex_lock(&(qsr4_db_write_buf_pool[0].write_mutex)); + pthread_mutex_lock(&(qsr4_db_write_buf_pool[0].read_mutex)); + if (qsr4_db_write_buf_pool[0].data_ready) { + pthread_mutex_unlock(&(qsr4_db_write_buf_pool[0].write_mutex)); + pthread_cond_wait(&(qsr4_db_write_buf_pool[0].read_cond), + &(qsr4_db_write_buf_pool[0].read_mutex)); + pthread_mutex_lock(&(qsr4_db_write_buf_pool[0].write_mutex)); + } + + pthread_mutex_unlock(&(qsr4_db_write_buf_pool[0].read_mutex)); + qsr4_db_write_buf_pool[0].data_ready = 1; + pthread_cond_signal(&qsr4_db_write_buf_pool[0].write_cond); + pthread_mutex_unlock(&(qsr4_db_write_buf_pool[0].write_mutex)); + close: + diag_send_qsr4_file_close_send_req(read_file_fd, peripheral_type, peripheral); + parser_state = DB_PARSER_STATE_CLOSE; + rt = wait_for_response(); + if (rt == ETIMEDOUT) { + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_write_idx].write_rsp_mutex)); + DIAG_LOGE("diag:In %s time out while waiting for file close cmd rsp for periph type:%d periph:%d\n",__func__, peripheral_type, peripheral); + if (entry->buf){ + free(entry->buf); + entry->buf = NULL; + } + if (entry->head){ + free(entry->head); + entry->head = NULL; + } + entry->fd = -1; + continue; + } + process_qsr_db_file_close_rsp(); + diag_qsr4_reset_db_read_buffer(); + entry = (qsr4_db_file_list*) entry->next; + offset = 0; + i = 0; + if (kill_thread) { + parser_state = DB_PARSER_STATE_OFF; + return 0; + } + + } + } + } + parser_state = DB_PARSER_STATE_OFF; + return 0; +} +void diag_notify_parser_thread(int peripheral_type, int peripheral_mask) +{ + periph_info.peripheral_type = peripheral_type; + periph_info.peripheral_mask = peripheral_mask; + pthread_cond_signal(&qsr4_read_db_cond); +} + +static void* diag_qshrink4_db_parser_thread(void* param) +{ + qsr4_db_file_list* entry; + int ret, ret_bytes; + unsigned int offset = 0; + int read_file_fd; + unsigned int file_len; + int count = 0; + (void)param; + + parser_state = DB_PARSER_STATE_OFF; + while (1) { + + if (periph_info.peripheral_type & DIAG_MSM_MASK) { + if (periph_info.peripheral_mask & DIAG_CON_MPSS) { + diag_read_qsr4_db_from_peripheral(MSM, DIAG_MODEM_PROC); + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_MPSS; + if (kill_thread) + return 0; + } + + if (periph_info.peripheral_mask & DIAG_CON_LPASS) { + diag_read_qsr4_db_from_peripheral(MSM, DIAG_LPASS_PROC); + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_LPASS; + if (kill_thread) + return 0; + } + if (periph_info.peripheral_mask & DIAG_CON_WCNSS) { + diag_read_qsr4_db_from_peripheral(MSM, DIAG_WCNSS_PROC); + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_WCNSS; + if (kill_thread) + return 0; + } + if (periph_info.peripheral_mask & DIAG_CON_SENSORS) { + diag_read_qsr4_db_from_peripheral(MSM, DIAG_SENSORS_PROC); + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_SENSORS; + if (kill_thread) + return 0; + } + if (periph_info.peripheral_mask & DIAG_CON_APSS) { + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_APSS; + if (kill_thread) + return 0; + } + periph_info.peripheral_type = periph_info.peripheral_type ^ DIAG_MSM_MASK; + } + if (periph_info.peripheral_type & DIAG_MDM_MASK) { + if (periph_info.peripheral_mask & DIAG_CON_MPSS) { + diag_read_qsr4_db_from_peripheral(MDM, DIAG_MODEM_PROC); + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_MPSS; + if (kill_thread) + return 0; + } + if (periph_info.peripheral_mask & DIAG_CON_LPASS) { + diag_read_qsr4_db_from_peripheral(MDM, DIAG_LPASS_PROC); + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_LPASS; + if (kill_thread) + return 0; + } + if (periph_info.peripheral_mask & DIAG_CON_WCNSS) { + diag_read_qsr4_db_from_peripheral(MDM, DIAG_WCNSS_PROC); + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_WCNSS; + if (kill_thread) + return 0; + } + if (periph_info.peripheral_mask & DIAG_CON_SENSORS) { + diag_read_qsr4_db_from_peripheral(MDM, DIAG_SENSORS_PROC); + periph_info.peripheral_mask = periph_info.peripheral_mask ^ DIAG_CON_SENSORS; + if (kill_thread) + return 0; + } + periph_info.peripheral_type = periph_info.peripheral_type ^ DIAG_MDM_MASK; + } + pthread_mutex_lock(&qsr4_read_db_mutex); + while (!periph_info.peripheral_mask) { + in_wait_for_peripheral_status = 1; + pthread_cond_wait(&qsr4_read_db_cond, &qsr4_read_db_mutex); + in_wait_for_peripheral_status = 0; + if (kill_thread) + return 0; + } + pthread_mutex_unlock(&qsr4_read_db_mutex); + } + return 0; +} + +static void* diag_write_qshrink4_db_to_disk_thread(void* param) +{ + int file_fd; + qsr4_db_file_list* entry; + int ret; + (void) param; + while (1) { + + pthread_mutex_lock(&qsr4_db_write_buf_pool[0].write_mutex); + while (!qsr4_db_write_buf_pool[0].data_ready) { + in_write = 1; + pthread_cond_wait(&qsr4_db_write_buf_pool[0].write_cond, &qsr4_db_write_buf_pool[0].write_mutex); + in_write = 0; + if (kill_thread) + return 0; + } + entry = qsr4_db_write_buf_pool[0].write_entry; + if (entry && entry->fd >= 0) { + ret = write(entry->fd, entry->buf, entry->file_len); + if (ret < 0) { + DIAG_LOGE("diag:failed to write qsr4 db file err is %d\n", errno); + } + close(entry->fd); + entry->fd = -1; + if (entry->buf) { + free(entry->buf); + entry->buf = NULL; + } + if (entry->head) { + free(entry->head); + entry->head = NULL; + } + } + qsr4_db_write_buf_pool[0].data_ready = 0; + qsr4_db_write_buf_pool[0].write_entry = NULL; + qsr4_db_file_fd = -1; + pthread_mutex_lock(&(qsr4_db_write_buf_pool[0].read_mutex)); + pthread_cond_signal(&(qsr4_db_write_buf_pool[0].read_cond)); + pthread_mutex_unlock(&(qsr4_db_write_buf_pool[0].read_mutex)); + pthread_mutex_unlock(&(qsr4_db_write_buf_pool[0].write_mutex)); + + if (kill_thread) + return 0; + } + return 0; +} + +int create_diag_qshrink4_db_parser_thread(unsigned int peripheral_mask) +{ + uint16 remote_mask = 0; + uint16 z = 1; + + pthread_mutex_init(&qsr4_read_db_mutex, NULL); + pthread_mutex_init(&(qsr4_db_buffer_pool[0].read_rsp_mutex), NULL); + pthread_mutex_init(&(qsr4_db_buffer_pool[1].read_rsp_mutex), NULL); + pthread_mutex_init(&(qsr4_db_buffer_pool[0].write_rsp_mutex), NULL); + pthread_mutex_init(&(qsr4_db_buffer_pool[1].write_rsp_mutex), NULL); + pthread_cond_init(&(qsr4_db_buffer_pool[0].read_rsp_cond), NULL); + pthread_cond_init(&(qsr4_db_buffer_pool[0].write_rsp_cond), NULL); + pthread_cond_init(&(qsr4_db_buffer_pool[1].read_rsp_cond), NULL); + pthread_cond_init(&(qsr4_db_buffer_pool[1].write_rsp_cond), NULL); + + qsr4_db_buffer_pool[0].data_ready = 0; + qsr4_db_buffer_pool[1].data_ready = 0; + pthread_cond_init(&qsr4_read_db_cond, NULL); + + pthread_mutex_init(&(qsr4_db_write_buf_pool[0].write_mutex), NULL); + pthread_cond_init(&(qsr4_db_write_buf_pool[0].write_cond), NULL); + qsr4_db_write_buf_pool[0].data_ready = 0; + + diag_has_remote_device(&remote_mask); + if (peripheral_mask) { + periph_info.peripheral_type |= DIAG_MSM_MASK; + periph_info.peripheral_mask = peripheral_mask; + } + else { + periph_info.peripheral_mask = DIAG_CON_MPSS | DIAG_CON_LPASS | DIAG_CON_WCNSS | DIAG_CON_SENSORS; + periph_info.peripheral_type |= DIAG_MSM_MASK; + while (remote_mask) { + if (remote_mask & 1) { + z = z << 1; + periph_info.peripheral_type |= z; + remote_mask = remote_mask >> 1; + } + } + } + + qsr4_db_buffer_pool[0].db_read_buf = malloc(QSR4_DB_READ_BUF_SIZE); + + if (!qsr4_db_buffer_pool[0].db_read_buf){ + DIAG_LOGE("diag:failed to create data base read buffer 0\n"); + return FALSE; + } + + qsr4_db_buffer_pool[1].db_read_buf = malloc(QSR4_DB_READ_BUF_SIZE); + if (!qsr4_db_buffer_pool[1].db_read_buf){ + DIAG_LOGE("diag:failed to create data base read buffer 1\n"); + free(qsr4_db_buffer_pool[0].db_read_buf); + return FALSE; + } + + pthread_create(&qsr4_db_parser_thread_hdl, NULL, diag_qshrink4_db_parser_thread, NULL); + if (qsr4_db_parser_thread_hdl == 0) { + DIAG_LOGE("diag: Failed to create database parser thread\n"); + free(qsr4_db_buffer_pool[0].db_read_buf); + free(qsr4_db_buffer_pool[1].db_read_buf); + return FALSE; + } + + pthread_create(&db_write_thread_hdl, NULL, diag_write_qshrink4_db_to_disk_thread, NULL); + if (db_write_thread_hdl == 0) { + DIAG_LOGE("diag: Failed to create database write thread\n"); + free(qsr4_db_buffer_pool[0].db_read_buf); + free(qsr4_db_buffer_pool[1].db_read_buf); + return FALSE; + } + db_thread_initialized = 1; + return TRUE; +} + +static int check_for_qsr_db_file_op_cmd(uint8* src_ptr) +{ + uint16 cmd_code; + uint16 version; + uint16 opcode; + unsigned int i ; + unsigned int offset = 0; + if (!src_ptr) + return FALSE; + + if (((*src_ptr == DIAG_SUBSYS_CMD_VER_2_F && *(src_ptr + 1) == DIAG_SUBSYS_DIAG_SERV) || + (*src_ptr == DIAG_BAD_CMD_F && *(src_ptr + 1) == DIAG_SUBSYS_CMD_VER_2_F && + *(src_ptr + 2) == DIAG_SUBSYS_DIAG_SERV))) + { + if (*src_ptr == DIAG_SUBSYS_CMD_VER_2_F) { + memcpy(&cmd_code, src_ptr + 2, sizeof(cmd_code)); + for (i = 8; i < 12; i++) + if (src_ptr[i] == ESC_CHAR || src_ptr[i]== CTRL_CHAR) + offset++; + memcpy(&version, src_ptr + 12 + offset, sizeof(version)); + memcpy(&opcode, src_ptr + 14 + offset, sizeof(opcode)); + } else { + memcpy(&cmd_code,src_ptr + 3, sizeof(cmd_code)); + memcpy(&version, src_ptr + 5, sizeof(version)); + memcpy(&opcode, src_ptr + 7, sizeof(opcode)); + } + + switch (cmd_code) { + case DIAGDIAG_QSR4_FILE_OP_MODEM: + break; + case DIAGDIAG_QSR4_FILE_OP_ADSP: + break; + case DIAGDIAG_QSR4_FILE_OP_WCNSS: + break; + case DIAGDIAG_QSR4_FILE_OP_SLPI: + break; + default: + return FALSE; + } + if(version != 1) + return FALSE; + switch (opcode) { + case DIAGDIAG_FILE_LIST_OPERATION: + return TRUE; + case DIAGDIAG_FILE_OPEN_OPERATION: + return TRUE; + case DIAGDIAG_FILE_READ_OPERATION: + return TRUE; + case DIAGDIAG_FILE_CLOSE_OPERATION: + return TRUE; + default: + return FALSE; + } + + } + else + return FALSE; +} + +static void request_qsr4_database_read_buffer() +{ + pthread_mutex_lock(&(qsr4_db_buffer_pool[curr_read_idx].write_rsp_mutex)); + pthread_mutex_lock(&(qsr4_db_buffer_pool[curr_read_idx].read_rsp_mutex)); + if (qsr4_db_buffer_pool[curr_read_idx].data_ready) { + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_read_idx].write_rsp_mutex)); + pthread_cond_wait(&(qsr4_db_buffer_pool[curr_read_idx].read_rsp_cond), + &(qsr4_db_buffer_pool[curr_read_idx].read_rsp_mutex)); + pthread_mutex_lock(&(qsr4_db_buffer_pool[curr_read_idx].write_rsp_mutex)); + } + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_read_idx].read_rsp_mutex)); +} + +int parse_data_for_qsr4_db_file_op_rsp(uint8* ptr, int count_received_bytes) +{ + int count = 0; + uint8_t* src_ptr = NULL; + unsigned char* dest_ptr = NULL; + unsigned int src_length = 0, dest_length = 0; + unsigned int len = 0; + unsigned int i; + uint8_t src_byte; + int bytes_read = 0; + uint16_t payload_len = 0; + + while (bytes_read < count_received_bytes) { + + src_ptr = ptr + bytes_read; + src_length = count_received_bytes - bytes_read; + + if (hdlc_disabled) { + payload_len = *(uint16_t *)(src_ptr + 2); + if (db_thread_initialized && check_for_qsr_db_file_op_cmd(src_ptr + 4)) + { + request_qsr4_database_read_buffer(); + dest_ptr = &(qsr4_db_buffer_pool[curr_read_idx].db_read_buf[0]); + dest_length = QSR4_DB_READ_BUF_SIZE; + memcpy(dest_ptr, src_ptr + 4, payload_len); + qsr4_db_buffer_pool[curr_read_idx].data_ready = 1; + pthread_cond_signal(&(qsr4_db_buffer_pool[curr_read_idx].write_rsp_cond)); + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_read_idx].write_rsp_mutex)); + curr_read_idx = !curr_read_idx; + bytes_read += payload_len + 5; + + } + else + bytes_read += payload_len + 5; + + } else { + if (db_thread_initialized && check_for_qsr_db_file_op_cmd(src_ptr)) { + request_qsr4_database_read_buffer(); + dest_ptr = &(qsr4_db_buffer_pool[curr_read_idx].db_read_buf[0]); + dest_length = QSR4_DB_READ_BUF_SIZE; + for (i = 0; i < src_length; i++) { + src_byte = src_ptr[i]; + + if (src_byte == ESC_CHAR) { + if (i == (src_length - 1)) { + i++; + break; + } else { + dest_ptr[len++] = src_ptr[++i] + ^ 0x20; + } + } else if (src_byte == CTRL_CHAR) { + if (i == 0 && src_length > 1) + continue; + dest_ptr[len++] = src_byte; + i++; + break; + } else { + dest_ptr[len++] = src_byte; + } + + if (len >= dest_length) { + i++; + break; + } + } + bytes_read += i; + i = 0; + len = 0; + qsr4_db_buffer_pool[curr_read_idx].data_ready = 1; + pthread_cond_signal(&(qsr4_db_buffer_pool[curr_read_idx].write_rsp_cond)); + pthread_mutex_unlock(&(qsr4_db_buffer_pool[curr_read_idx].write_rsp_mutex)); + curr_read_idx = !curr_read_idx; + } else { + for (i = 0; i < src_length; i++) { + if (src_ptr[i] == CTRL_CHAR) { + i++; + break; + } + } + bytes_read += i; + i = 0; + len = 0; + + } + } + } + return 0; +} + +void diag_kill_qshrink4_threads() +{ + int ret; + qsr4_db_file_list* entry = NULL; + qsr4_db_file_list* temp; + entry = head; + kill_thread = 1; + + if (in_wait_for_peripheral_status) { + pthread_cond_signal(&qsr4_read_db_cond); + } + ret = pthread_join(qsr4_db_parser_thread_hdl, NULL); + if (ret != 0) { + DIAG_LOGE("diag: In %s, Error trying to join with qshrink4 read thread: %d\n", + __func__, ret); + } + if (in_write) + pthread_cond_signal(&qsr4_db_write_buf_pool[0].write_cond); + ret = pthread_join(db_write_thread_hdl, NULL); + if (ret != 0) { + DIAG_LOGE("diag: In %s, Error trying to join with qshrink4 write thread: %d\n", + __func__, ret); + } + pthread_mutex_destroy(&qsr4_read_db_mutex); + pthread_mutex_destroy(&(qsr4_db_buffer_pool[0].read_rsp_mutex)); + pthread_mutex_destroy(&(qsr4_db_buffer_pool[1].read_rsp_mutex)); + pthread_mutex_destroy(&(qsr4_db_buffer_pool[0].write_rsp_mutex)); + pthread_mutex_destroy(&(qsr4_db_buffer_pool[1].write_rsp_mutex)); + pthread_cond_destroy(&(qsr4_db_buffer_pool[0].read_rsp_cond)); + pthread_cond_destroy(&(qsr4_db_buffer_pool[0].write_rsp_cond)); + pthread_cond_destroy(&(qsr4_db_buffer_pool[1].read_rsp_cond)); + pthread_cond_destroy(&(qsr4_db_buffer_pool[1].write_rsp_cond)); + pthread_cond_destroy(&qsr4_read_db_cond); + pthread_mutex_destroy(&(qsr4_db_write_buf_pool[0].write_mutex)); + pthread_cond_destroy(&(qsr4_db_write_buf_pool[0].write_cond)); + + if (qsr4_db_buffer_pool[0].db_read_buf) + free(qsr4_db_buffer_pool[0].db_read_buf); + if (qsr4_db_buffer_pool[1].db_read_buf) + free(qsr4_db_buffer_pool[1].db_read_buf); + + while (entry != NULL) { + if (entry->buf) { + free(entry->buf); + entry->buf = NULL; + } + if (entry->head) { + free(entry->head); + entry->head = NULL; + } + temp = (qsr4_db_file_list *)entry->next; + free(entry); + entry = NULL; + entry = temp; + } + DIAG_LOGE("diag:In %s finished killing qshrink4 threads\n", __func__); +} diff --git a/feeds/wifi-ax/qca-diag/src/src/diag_shared_i.h b/feeds/wifi-ax/qca-diag/src/src/diag_shared_i.h new file mode 100755 index 000000000..e874a66b8 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diag_shared_i.h @@ -0,0 +1,182 @@ +#ifndef DIAG_SHARED_I_H +#define DIAG_SHARED_I_H + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + GENERAL DESCRIPTION + + Diag-internal declarations and definitions common to API layer + (Diag_LSM) and diag driver (DCM). + +Copyright (c) 2007-2015 Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE +$Header: $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/03/08 mad Created file. +===========================================================================*/ + +#include +#include "../include/diagi.h" +/*Prototyping Diag: Adding a uint32 to the beginning of the diag packet, + so the diag driver can identify what this is. This will be stripped out in the + WDG_Write() function, and only the rest of the data will + be copied to diagbuf. */ +typedef struct +{ + uint32 diag_data_type; /* This will be used to identify whether the data passed to DCM is an event, log, F3 or response.*/ + uint8 rest_of_data; +} +diag_data; +#define DIAG_REST_OF_DATA_POS (FPOS(diag_data, rest_of_data)) + +/* Reasoning for an extra structure: +diagpkt_delay_alloc allocates a certain length, to send out a delayed response. +On WM, diagpkt_delay_commit needs to know the length of the response, to call WriteFile(), +and the header doesn't have any length field. + +(On AMSS, diagpkt_delay_alloc directly allocates to diagbuf, and length is stored in the +diagbuf header. When diagpkt_delay_commit() (that results in diagbuf_commit()) is called, +we know how much to commit.) + +*/ +typedef struct +{ + uint32 length; /* length of delayed response pkt */ + diag_data diagdata; +}diag_data_delayed_response; +#define DIAG_DEL_RESP_REST_OF_DATA_POS (FPOS(diag_data_delayed_response,diagdata.rest_of_data)) + +/* different values that go in for diag_data_type */ +#define DIAG_DATA_TYPE_EVENT 0 +#define DIAG_DATA_TYPE_F3 1 +#define DIAG_DATA_TYPE_LOG 2 +#define DIAG_DATA_TYPE_RESPONSE 3 +#define DIAG_DATA_TYPE_DELAYED_RESPONSE 4 +#define DIAG_DATA_TYPE_DCI_LOG 0x00000100 +#define DIAG_DATA_TYPE_DCI_EVENT 0x00000200 +#define DIAG_DATA_TYPE_DCI_PKT 0x00000400 + +/* The various IOCTLs */ +#define DIAG_IOCTL_COMMAND_REG 0 /* IOCTL for packet registration + Clients can use this to register to respond to packets from host tool */ +#define DIAG_IOCTL_COMMAND_DEREG 1 /* IOCTL for de-registration */ +/* Client process uses this to de-register itself, while unloading gracefully. */ +#define DIAG_IOCTL_MASK_REG 2 /* IOCTL for registration for mask-change */ +#define DIAG_IOCTL_MASK_DEREG 3 +#define DIAG_IOCTL_GETEVENTMASK 4 /* For Client process to get event mask from DCM */ +#define DIAG_IOCTL_GETLOGMASK 5 +#define DIAG_IOCTL_GETMSGMASK 6 +#define DIAG_IOCTL_GET_DELAYED_RSP_ID 8 /* Diag_LSM uses this IOCTL to get the next delayed response id + in the system. */ +#define DIAG_IOCTL_LSM_DEINIT 9 +#define DIAG_IOCTL_SWITCH_LOGGING 7 +#define DIAG_IOCTL_DCI_INIT 20 +#define DIAG_IOCTL_DCI_DEINIT 21 +#define DIAG_IOCTL_DCI_SUPPORT 22 +#define DIAG_IOCTL_DCI_REG 23 +#define DIAG_IOCTL_DCI_STREAM_INIT 24 +#define DIAG_IOCTL_DCI_HEALTH_STATS 25 +#define DIAG_IOCTL_DCI_LOG_STATUS 26 +#define DIAG_IOCTL_DCI_EVENT_STATUS 27 +#define DIAG_IOCTL_DCI_CLEAR_LOGS 28 +#define DIAG_IOCTL_DCI_CLEAR_EVENTS 29 +#define DIAG_IOCTL_REMOTE_DEV 32 +#define DIAG_IOCTL_VOTE_REAL_TIME 33 +#define DIAG_IOCTL_GET_REAL_TIME 34 +#define DIAG_IOCTL_CONFIG_BUFFERING_TX_MODE 35 +#define DIAG_IOCTL_BUFFERING_DRAIN_IMMEDIATE 36 +#define DIAG_IOCTL_REGISTER_CALLBACK 37 +#define DIAG_IOCTL_HDLC_TOGGLE 38 +#define DIAG_IOCTL_QUERY_PD_LOGGING 39 +#define DIAG_IOCTL_QUERY_CON_ALL 40 +#define DIAG_IOCTL_QUERY_MD_PID 41 +#define DIAG_IOCTL_QUERY_PD_FEATUREMASK 42 +#define DIAG_IOCTL_PASSTHRU_CONTROL 43 + + +#define DIAG_EVENTSVC_MASK_CHANGE 0 +#define DIAG_LOGSVC_MASK_CHANGE 1 +#define DIAG_MSGSVC_MASK_CHANGE 2 + +/* + * Structure for setting diag buffering mode on the peripherals + * + * @peripheral: id of the peripheral interested + * + * @mode: buffering mode - STREAMING_MODE, THRESHOLD_BUFFERING_MODE, + * CIRCULAR_BUFFERING_MODE + * + * @highwmvalue: High watermark value (in percentage of buffer size) 0 keeps + * current value on the peripherals. > 100 is not a value value. This value + * cannot be lower than or equal to lowwmvalue + * + * @lowwmvalue: Low watermark value (in percentage of buffer size) 0 keeps + * current value on the peripherals. > 100 is not a value value. This value + * cannot be higher than or equal to highwmvalue + */ +PACK(struct) diag_periph_buffering_tx_mode { + uint8 peripheral; + uint8 mode; + uint8 high_wm_val; + uint8 low_wm_val; +}; + +#define MAX_SYNC_OBJ_NAME_SIZE 32 + +typedef struct { + uint16_t cmd_code; + uint16_t subsys_id; + uint16_t cmd_code_lo; + uint16_t cmd_code_hi; +} diag_cmd_reg_entry_t; + +/* + * @sync_obj_name: name of the synchronization object associated with this proc + * @count: number of entries in the bind + * @entries: the actual packet registrations + */ +typedef struct { + char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE]; + uint32 count; + diag_cmd_reg_entry_t *entries; +} diag_cmd_reg_tbl_t; + +/* + * To vote for real time or non real time mode + * + * @client_id: The DCI client ID. For other processes it should be -1 + * @proc: which process is voting for RT/NRT mode (DIAG_PROC_DCI or DIAG_PROC_MEMORY_DEVICE) + * @real_time_vote: The actual vote. 0 for NRT mode, 1 for RT mode + */ +struct real_time_vote_t { + int client_id; + uint16 proc; + uint8 real_time_vote; +}; + +PACK(struct) real_time_query_t { + int real_time; + int proc; +}; + +PACK(struct) diag_callback_reg_t { + int proc; +}; + +/* functions used by diag driver to write events into diag buffers */ +void* event_q_alloc (void *in, unsigned int length); +void event_q_pending (void *in); + +void diagpkt_tbl_reg_dcm (void* LSM_obj, const byte * tbl_ptr, unsigned int count); +boolean diagpkt_tbl_dereg_dcm(uint32 client_id); +boolean event_process_LSM_mask_req (unsigned char* mask, int maskLen, int * maskLenReq); +boolean log_process_LSM_mask_req (unsigned char* mask, int maskLen, int * maskLenReq); +boolean msg_process_LSM_mask_req (unsigned char* mask, int maskLen, int * maskLenReq); +boolean diagpkt_mask_tbl_reg (uint32 client_id, uint32 LSM_sync_obj); +#endif diff --git a/feeds/wifi-ax/qca-diag/src/src/diagdiag.h b/feeds/wifi-ax/qca-diag/src/src/diagdiag.h new file mode 100755 index 000000000..cb5c7f038 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diagdiag.h @@ -0,0 +1,1273 @@ +#ifndef DIAGDIAG_H +#define DIAGDIAG_H +/*========================================================================== + + Diagnostic Packet Definitions + + Description: Packet definitions between the diagnostic subsystem + and the external device. + + !!! NOTE: All member structures of diag packets must be PACKED. + + !!! WARNING: Each command code number is part of the externalized + diagnostic command interface. This number *MUST* be assigned + by a member of QCT's tools development team. + +# Copyright (c) 2007-2011, 2014, 2016 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +===========================================================================*/ + +/* */ +/*=========================================================================== + + Edit History + + $Header: //depot/asic/msmshared/services/diag/DIAG_7K/diagdiag.h#2 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Changes for CBSP2.0 +05/17/05 as Added Dual processor Diag support. +06/15/04 gr Added support for getting and setting the event mask. +05/18/04 as Removed support for DIAG_USER_CMD_F & DIAG_PERM_USER_CMD_F +01/07/03 djm add RPC support for WCDMA_PLT +08/20/02 lad Moved DIAG_DLOAD_F packet def to dloaddiag.h. + Moved DIAG_SERIAL_CHG_F definition to diagcomm_sio.c. +01/28/02 as Support for DIAG_LOG_ON_DEMAND_F (log on demand). +09/18/01 jal Support for DIAG_CONTROL_F (mode reset/offline) +08/20/01 jal Support for Diag packet: DIAG_TS_F (timestamp), + DIAG_SPC_F (service programming code), DIAG_DLOAD_F + (start downloader), DIAG_OUTP_F/DIAG_OUTPW_F (IO + port byte/word output), DIAG_INP_F/DIAG_INPW_F (IO + port byte/word input) +06/27/01 lad Use of constants in message response packet. + Added packet definition for DIAG_LOG_CONFIG_F. This + replaces extended logmask processing. + Cleaned up DIAG_STREAMING_CONFIG_F and added subcmd to + get diagbuf size. +04/06/01 lad Added packet definitions for the following: + Peek/Poke + DIAG_STREAMING_CONFIG_F + Debug messages + Log services + Event services +02/23/01 lad Created file. + +===========================================================================*/ + +#include "diagcmd.h" +#include "diagpkt.h" +#include "log_codes.h" +//#include "feature.h" +#include "diag.h" +#include "diagi.h" + +/* Type to hold security code. The security code is fixed length and is */ +/* stored as ASCII string. */ + +#define DIAGPKT_SEC_CODE_SIZE 6 /* 6 digit security code */ + +typedef PACK(struct { + byte digits[DIAGPKT_SEC_CODE_SIZE]; /* Security code array */ +}) diagpkt_sec_code_type; + + +/* ------------------------------------------------------------------------- +** Packet Definitions +** ------------------------------------------------------------------------- */ + +/*========================================================================== + +PACKET DIAG_RPC_F + +PURPOSE RPC Processing Request + +============================================================================*/ +DIAGPKT_REQ_DEFINE( DIAG_RPC_F ) + + /* It's just the command code */ + +DIAGPKT_REQ_END + +DIAGPKT_DEFINE_RSP_AS_REQ( DIAG_RPC_F ) + +/*========================================================================== + +PACKETS DIAG_PEEKB_F + DIAG_PEEKW_F + DIAG_PEEKD_F +PURPOSE Sent from the DM to the DMSS to request a read of a block of data. + The cmd_code specifies byte, word or dword. + +============================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_PEEKB_F) + + byte *ptr; /* starting address for peek operation */ + word length; /* number of bytes, words, or dwords to be + returned */ +DIAGPKT_REQ_END + +typedef DIAG_PEEKB_F_req_type DIAG_PEEKW_F_req_type; +typedef DIAG_PEEKB_F_req_type DIAG_PEEKD_F_req_type; +typedef DIAG_PEEKB_F_req_type diag_peek_req_type; + +#define DIAG_MAX_PEEK_B 16 + /* Maximum number of bytes that can be requested in one Peekb request */ + +DIAGPKT_RSP_DEFINE(DIAG_PEEKB_F) + + byte *ptr; /* starting address for peek operation */ + word length; /* number of bytes to be returned */ + byte data[DIAG_MAX_PEEK_B]; /* bytes from memory */ + +DIAGPKT_RSP_END + +#define DIAG_MAX_PEEK_W 8 + /* Maximum number of words that can be requested in one Peekw request */ + +/* Peekw Response type */ +DIAGPKT_RSP_DEFINE(DIAG_PEEKW_F) + + word *ptr; /* starting address for peek operation */ + word length; /* number of words to be returned */ + word data[DIAG_MAX_PEEK_W]; /* words from memory */ + +DIAGPKT_RSP_END + +#define DIAG_MAX_PEEK_D 4 + /* Maximum number of dwords that can be requested in one Peekd request */ + +DIAGPKT_RSP_DEFINE(DIAG_PEEKD_F) + + dword *ptr; /* starting address for peek operation */ + word length; /* number of dwords to be returned */ + dword data[DIAG_MAX_PEEK_D]; /* dwords from memory */ + +DIAGPKT_RSP_END + +typedef DIAG_PEEKB_F_rsp_type diag_peekb_rsp_type; +typedef DIAG_PEEKW_F_rsp_type diag_peekw_rsp_type; +typedef DIAG_PEEKD_F_rsp_type diag_peekd_rsp_type; + + +/*=========================================================================== + +PACKET DIAG_POKEB_F + DIAG_POKEW_F + DIAG_POKED_F +PURPOSE Sent by the DM to the DMSS to request that a block of data be + written starting at a specified address. + +============================================================================*/ +#define DIAG_MAX_POKE_B 4 + /* Maximum number of bytes allowed for one pokeb request */ + +DIAGPKT_REQ_DEFINE(DIAG_POKEB_F) + byte *ptr; /* starting address for poke operation */ + byte length; /* number of bytes to be poked */ + byte data[DIAG_MAX_POKE_B]; /* bytes to be placed at the addr address */ +DIAGPKT_REQ_END + +typedef DIAG_POKEB_F_req_type DIAG_POKEB_F_rsp_type; + + +#define DIAG_MAX_POKE_W 2 + /* Maximum number of words allowed for one pokew request */ + +DIAGPKT_REQ_DEFINE(DIAG_POKEW_F) + word *ptr; /* starting address for poke operation */ + byte length; /* number of words to be poked */ + word data[DIAG_MAX_POKE_W]; /* words to be placed at the addr address */ +DIAGPKT_REQ_END + +typedef DIAG_POKEW_F_req_type DIAG_POKEW_F_rsp_type; + +#define DIAG_MAX_POKE_D 2 + /* Maximum number of dwords allowed for one poked request this is 2 to + allow possible growth to handle qwords. */ + +DIAGPKT_REQ_DEFINE(DIAG_POKED_F) + dword *ptr; /* starting address for poke operation */ + byte length; /* number of dwords to be poked */ + dword data[DIAG_MAX_POKE_D]; /* dword to be placed at the addr address */ +DIAGPKT_REQ_END + +typedef DIAG_POKED_F_req_type DIAG_POKED_F_rsp_type; + + +/*=========================================================================== + +PACKET DIAG_BAD_CMD_F + DIAG_BAD_PARM_F + DIAG_BAD_LEN_F + DIAG_BAD_VOC_F + DIAG_BAD_MODE_F + DIAG_BAD_SPC_MODE_F + +PURPOSE Sent by DMSS when it detects an erroneous packet from DM. Errors + include command code out of bounds, bad length... Includes the + first DIAG_MAX_ERR bytes of the offending input packet. + Also includes when an nv_read/write is attempted before the correct + SPC has been entered. + +============================================================================*/ +#define DIAGPKT_MAX_ERR 16 + /* maximum number of bytes (starting with the first byte of the packet ) + from the received packet which will be echoed back to the + Diagnostic Monitor if an error is detected in the packet */ + +/* Type to communicate an error in a received packet */ +DIAGPKT_RSP_DEFINE(DIAG_BAD_CMD_F) + byte pkt[DIAGPKT_MAX_ERR]; /* first 16 bytes of received packet */ +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_DIAG_VER_F +PURPOSE Sent by DM to request the version of the diag + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_DIAG_VER_F) +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_DIAG_VER_F) + word ver; /* diag version */ +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_PASSWORD_F +PURPOSE Sent by external device to enter the Security Password, + to then allow operations protected by security. This response + indicates whether the correct Password was given or not. + +NOTE If the incorrect password is entered, DIAG will POWER DOWN + the phone. + +===========================================================================*/ +#define DIAG_PASSWORD_SIZE 8 +DIAGPKT_REQ_DEFINE(DIAG_PASSWORD_F) + byte password[DIAG_PASSWORD_SIZE]; /* The security password */ +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_PASSWORD_F) + boolean password_ok; /* TRUE if Security Password entered correctly */ +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_ERR_CLEAR_F +PURPOSE Sent by the DM to clear the requested buffered error records + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_ERR_CLEAR_F) + byte rec; /* record id, or -1 (0xFF) for all */ +DIAGPKT_REQ_END + +typedef DIAG_ERR_CLEAR_F_req_type DIAG_ERR_CLEAR_F_rsp_type; + +/*=========================================================================== + +PACKET DIAG_ERR_READ_F +PURPOSE Sent by the DM to request the buffered error records + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_ERR_READ_F) +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_ERR_READ_F) + word log_cnt; /* how many logged */ + word ignore_cnt; /* how many ignored */ + + PACK(struct { + byte address; /* Storage address 0 to */ + /* ERR_MAX_LOG-1 */ + byte err_count; /* Number of occurances */ + /* (0=empty,FF=full) */ + byte file_name[8]; + /* File name string */ + word line_num; /* Line number in file */ + boolean fatal; /* TRUE if fatal error */ + }) err_logs[ 20 ]; +DIAGPKT_RSP_END + + +/* Logging Services */ + +/*=========================================================================== + +PACKET DIAG_LOG_CONFIG_F +PURPOSE Sent by the DM to set the equipment ID logging mask in the DMSS. + This is necessary to use logging services with MS Equip ID != 1. + +!!!Note that the log mask is now sanely ordered LSB to MSB using little endian +32-bit integer arrays. This is not the same way the mask was done in +DIAG_EXT_LOGMASK_F. + +TERMINOLOGY: + 'equipment ID' - the 4-bit equipment identifier + 'item ID' - the 12-bit ID that specifies the log item within this equip ID + 'code' - the entire 16-bit log code (contains both equip and item ID) + +===========================================================================*/ +typedef enum { + LOG_CONFIG_DISABLE_OP = 0, + LOG_CONFIG_RETRIEVE_ID_RANGES_OP = 1, + LOG_CONFIG_RETRIEVE_VALID_MASK_OP = 2, + LOG_CONFIG_SET_MASK_OP = 3, + LOG_CONFIG_GET_LOGMASK_OP = 4 +} log_config_command_ops_enum_type; + +/* Logging config return status types. + * (*) denotes applicable to all commands + */ +typedef enum { + LOG_CONFIG_SUCCESS_S = 0, /* Operation Sucessful */ + LOG_CONFIG_INVALID_EQUIP_ID_S = 1, /* (*) Specified invalid equipment ID */ + LOG_CONFIG_NO_VALID_MASK_S = 2 /* Valid mask not available for this ID */ +} log_config_status_enum_type; + +/* Operation data */ +/* DISABLE OP: LOG_CONFIG_DISAPLE_OP -no no supporting data */ + +/* These member structures are not packed intentionally. Each data member will + * align on a 32-bit boundary. + */ +typedef PACK(struct) { + uint32 equip_id; + + uint32 last_item; + +} log_config_range_type; + +typedef PACK(struct) { + log_config_range_type code_range; /* range of log codes */ + + byte mask[1]; /* Array of 8 bit masks of size (num_bits + 7) / 8 */ +} log_config_mask_type; + +/* ID_RANGE_OP response type */ +typedef PACK(struct) { + uint32 last_item[16]; /* The last item for each of the 16 equip IDs */ +} log_config_ranges_rsp_type; + +/* VALID_MASK_OP request type */ +typedef PACK(struct) { + uint32 equip_id; +} log_config_valid_mask_req_type; + +/* VALID_MASK_OP response type */ +typedef log_config_mask_type log_config_valid_mask_rsp_type; + +/* SET_MASK_OP request type */ +typedef log_config_mask_type log_config_set_mask_req_type; + +/* GET_MASK_OP response type */ +typedef log_config_mask_type log_config_get_mask_rsp_type; + +/* SET_MASK_OP response type */ +typedef log_config_mask_type log_config_set_mask_rsp_type; + +/* This is not packed. We use uint32 which is always aligned */ +typedef PACK(union) { + /* LOG_CONFIG_DISABLE_OP */ + /* no additional data */ + + /* LOG_CONFIG_RETRIEVE_ID_RANGES_OP */ + /* no additional data */ + + /* LOG_CONFIG_RETRIEVE_VALID_MASK_OP */ + log_config_valid_mask_req_type valid_mask; + + /* LOG_CONFIG_SET_MASK_OP */ + log_config_set_mask_req_type set_mask; + + /* LOG_CONFIG_GET_MASK_OP */ + /* no additional data */ + +} log_config_op_req_type; + +typedef PACK(union) { + /* LOG_CONFIG_DISABLE_OP */ + /* no additional data */ + + /* LOG_CONFIG_RETRIEVE_ID_RANGES_OP */ + log_config_ranges_rsp_type ranges; + + /* LOG_CONFIG_RETRIEVE_VALID_MASK_OP */ + log_config_valid_mask_rsp_type valid_mask; + + /* LOG_CONFIG_SET_MASK_OP */ + log_config_set_mask_rsp_type set_mask; + + /* LOG_CONFIG_GET_MASK_OP */ + log_config_get_mask_rsp_type get_mask; + +} log_config_op_rsp_type; + + +DIAGPKT_REQ_DEFINE(DIAG_LOG_CONFIG_F) + + byte pad[3]; /* Force following items to be on 32-bit boundary */ + + uint32 operation; /* See log_config_command_ops_enum_type */ + + uint32 op_data[1]; /* Pointer to operation data */ + +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_LOG_CONFIG_F) + + byte pad[3]; /* Force following items to be on 32-bit boundary */ + + uint32 operation; /* See log_config_command_ops_enum_type */ + + uint32 status; + + uint32 op_data[1]; /* Pointer to operation data */ + +DIAGPKT_RSP_END + + +/* Number of bits in a log mask. +*/ +#define DIAG_EXT_LOGMASK_NUM_BITS (LOG_1X_LAST_C & 0x0FFF) + +/* Max # of bytes in a valid log mask. +*/ +#define DIAG_EXT_LOGMASK_NUM_BYTES ((DIAG_EXT_LOGMASK_NUM_BITS / 8) + 1) + +/*=========================================================================== + +PACKET DIAG_EXT_LOGMASK_F +PURPOSE Sent by the DM to set the logging mask in the DMSS. This is + necessary for logmasks > 32 bits. + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_EXT_LOGMASK_F) + word num_bits; /* Number of valid bits */ + byte mask[DIAG_EXT_LOGMASK_NUM_BYTES]; /* mask to use */ +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_EXT_LOGMASK_F) + word num_valid_bits; /* Number of valid bits */ + byte valid_mask[DIAG_EXT_LOGMASK_NUM_BYTES]; /* mask of valid log codes */ +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_LOG_F +PURPOSE Encapsulates a log record. + +===========================================================================*/ + +typedef struct +{ + uint8 cmd_code; + uint8 more; /* Indicates how many log entries, not including the one + returned with this packet, are queued up in the Mobile + Station. If DIAG_DIAGVER >= 8, this should be set to 0 */ + uint16 len; /* Indicates the length, in bytes, of the following log entry */ + uint8 log[1]; /* Contains the log entry data. */ +} +diag_log_rsp_type; + + +/* ------------------------------------------------------------------------- +** Legacy (but still supported) packet definitions for logging services. +** ------------------------------------------------------------------------- */ +/*=========================================================================== + +PACKET DIAG_LOGMASK_F +PURPOSE Sent by the DM to set the 32-bit logging mask in the DMSS. + Note: this is the legacy logging mask format. + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_LOGMASK_F) + uint32 mask; /* 32-bit log mask */ +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_LOGMASK_F) +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_SUBSYS_CMD_F +PURPOSE This is a wrapper command to dispatch diag commands to various + subsystems in the DMSS. This allows new diag commands to be + developed in those subsystems without requiring a change to diag + code. + + The use of this command allows subsystems to manage their own + diagnostics content. + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_SUBSYS_CMD_F) + + uint8 subsys_id; + uint16 subsys_cmd_code; + + uint8 pkt[1]; /* The subsystem's request. Variable length. */ + +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_SUBSYS_CMD_F) + + uint8 subsys_id; + uint16 subsys_cmd_code; + + uint8 pkt[1]; /* The subsystem's response. Variable length. */ + +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_FEATURE_QUERY_F +PURPOSE Sent by external device to query the phone for a bit mask detailing + which phone features are turned on. + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_FEATURE_QUERY_F) +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_FEATURE_QUERY_F) + word feature_mask_size; /* Size of the following Mask */ + byte feature_mask[FEATURE_MASK_LENGTH]; /* Space for the largest possible + feature mask */ +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_EVENT_REPORT_F +PURPOSE Sent by the DM to configure static event reporting in the DMSS. + +===========================================================================*/ +/*-------------------------------------- + Special bit flags in the event ID. +--------------------------------------*/ +#define EVENT_PAY_LENGTH 0x3 +#define EVENT_PAY_TWO_BYTE 0x2 +#define EVENT_PAY_ONE_BYTE 0x1 +#define EVENT_PAY_NONE 0x0 + +/* Bitfields may not be ANSI, but all our compilers +** recognize it and *should* optimize it. +** Not that bit-packed structures are only as long as they need to be. +** Even though we call it uint32, it is a 16 bit structure. +*/ +typedef struct +{ + uint16 id : 12; + uint16 reserved : 1; + uint16 payload_len : 2; /* payload length (0, 1, 2, see payload) */ + uint16 time_trunc_flag : 1; +} event_id_type; + +typedef PACK(struct) +{ + uint16 id; /* event_id_type id; */ + //qword ts; + // removed AMSS code for CBSP 2.0 + uint32 ts_lo; /* Time stamp */ + uint32 ts_hi; + +} event_type; + +/* Used in lieu of event_type if 'time_trunc_flag' is set in event_id_type */ +typedef PACK(struct) +{ + uint16 id; /* event_id_type id; */ + uint16 trunc_ts; +} event_trunc_type; + +/* The event payload follows the event_type structure */ +typedef struct +{ + uint8 length; + uint8 payload[1]; /* 'length' bytes */ +} event_payload_type; + +typedef PACK(struct) +{ + uint16 id; /* event_id_type id; */ + // removed AMSS code for CBSP 2.0 + //qword ts; + uint32 ts_lo; /* Time stamp */ + uint32 ts_hi; + uint32 drop_cnt; +} event_drop_type; + +typedef struct +{ + event_id_type id; + uint16 ts; + uint32 drop_cnt; +} event_drop_trunc_type; + +typedef struct +{ + uint8 cmd_code; + uint8 enable; +// uint16 watermark; /* Maximum size (in bytes) of a event report */ +// uint16 stale_timer; /* Time (in ms) to allow event buffer to accumulate */ + +} event_cfg_req_type; + +typedef PACK(struct) +{ + uint8 cmd_code; + uint16 length; + +} event_cfg_rsp_type; + +typedef PACK(struct) +{ + uint8 cmd_code; + uint16 length; /* Number of bytes to follow */ + uint8 events[1]; /* Series of 'event_type' structures, 'length' bytes long */ +} event_rpt_type; + +/*=========================================================================== + +PACKET DIAG_STREAMING_CONFIG_F +PURPOSE Sent by the DM to configure and tweak streaming diag output services. + +===========================================================================*/ +typedef enum { + DIAG_READ_NICE_C = 0, /* Read "Nice" values for LOG and MSG services */ + DIAG_WRITE_NICE_C = 1, /* Write "Nice" values for LOG and MSG services */ + DIAG_READ_PRI_C = 2, /* Read "priority" values for LOG and MSG services */ + DIAG_WRITE_PRI_C = 3, /* Write "priority" values for LOG and MSG services */ + DIAG_BUF_SIZE_C = 4 /* Return size (in bytes) of output buffer */ + +} diag_streaming_config_subcommand_enum_type; + +typedef PACK(struct) { + uint16 code; /* MSG_LVL value or Log code */ + + int16 val; + +} diagpkt_streaming_config_entry_type; + +typedef PACK(struct) { + + /* Number of entries in the following array */ + uint8 num_entries; + + /* # of log codes + 5 Message Levels is the number max $ in this array */ + diagpkt_streaming_config_entry_type entry[1]; + +} diagpkt_streaming_config_entry_list_type; + + +/*========================================================================== + +PACKET DIAG_TS_F + +PURPOSE Sent from the DM to the DMSS to request the IS-95/IS-2000 time. + +============================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_TS_F) + + /* It's just the command code */ + +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_TS_F) + + //qword ts; /* Time Stamp */ + uint32 ts_lo; /* Time stamp */ + uint32 ts_hi; +DIAGPKT_RSP_END + + +/*========================================================================== + +PACKET DIAG_SPC_F + +PURPOSE Request sent from the DM to the DMSS to enter the Service + Programming Code (SPC), enabling service programming. Response + indicates whether or not the SPC was accepted as correct. + +============================================================================*/ +DIAGPKT_REQ_DEFINE( DIAG_SPC_F ) + + diagpkt_sec_code_type sec_code; + +DIAGPKT_REQ_END + + +DIAGPKT_RSP_DEFINE( DIAG_SPC_F ) + + boolean sec_code_ok; + +DIAGPKT_RSP_END + + + +/*========================================================================== + +PACKET DIAG_OUTP_F + +PURPOSE Request sent from the DM to the DMSS to send a byte to an + IO port + +============================================================================*/ +DIAGPKT_REQ_DEFINE( DIAG_OUTP_F ) + + word port; /* number of port to output to */ + byte data; /* data to write to port */ + +DIAGPKT_REQ_END + +DIAGPKT_DEFINE_RSP_AS_REQ( DIAG_OUTP_F ) + + +/*========================================================================== + +PACKET DIAG_OUTPW_F + +PURPOSE Request sent from the DM to the DMSS to send a 16-bit word to an + IO port + +============================================================================*/ +DIAGPKT_REQ_DEFINE( DIAG_OUTPW_F ) + + word port; /* number of port to output to */ + word data; /* data to write to port */ + +DIAGPKT_REQ_END + +DIAGPKT_DEFINE_RSP_AS_REQ( DIAG_OUTPW_F ) + + + +/*========================================================================== + +PACKET DIAG_INP_F + +PURPOSE Request sent from the DM to the DMSS to read a byte to an + IO port + +============================================================================*/ +DIAGPKT_REQ_DEFINE( DIAG_INP_F ) + + word port; /* number of port to output to */ + +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE( DIAG_INP_F ) + + word port; /* number of port to output to */ + byte data; /* data to write to port */ + +DIAGPKT_REQ_END + + +/*========================================================================== + +PACKET DIAG_INPW_F + +PURPOSE Request sent from the DM to the DMSS to read a 16-bit word from an + IO port + +============================================================================*/ +DIAGPKT_REQ_DEFINE( DIAG_INPW_F ) + + word port; /* number of port to output to */ + +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE( DIAG_INPW_F ) + + word port; /* number of port to output to */ + word data; /* data to write to port */ + +DIAGPKT_REQ_END + + +/*=========================================================================== + +PACKET diag_dipsw_req_type + +ID DIAG_DIPSW_F + +PURPOSE Sent by DM to retreive the current dip switch settings + +RESPONSE DMSS performs the test, then responds. + +===========================================================================*/ +typedef PACK(struct) +{ + byte cmd_code; + word switches; +} diag_dipsw_req_type; + +typedef diag_dipsw_req_type diag_dipsw_rsp_type; + + +/*========================================================================== + +PACKET DIAG_LOG_ON_DEMAND_F + +PURPOSE Request sent from the user to register a function pointer and + log_code with the diagnostic service for every log that needs + logging on demand support. + +============================================================================*/ +DIAGPKT_REQ_DEFINE( DIAG_LOG_ON_DEMAND_F ) + + uint16 log_code; /* The log_code to be sent */ + +DIAGPKT_REQ_END + + +DIAGPKT_RSP_DEFINE( DIAG_LOG_ON_DEMAND_F ) + + uint16 log_code; /* The log_code sent */ + uint8 status; /* status returned from the function pointer */ + +DIAGPKT_RSP_END + +/* Diagnostic extensions */ +/* +** The maximum number of properties and callback functions. These are not +** used to determine the size of any data structure; they are used merely +** to guard against infinite loops caused by corruption of the callback +** and properties tables. +*/ +#define DIAG_MAX_NUM_PROPS 20 +#define DIAG_MAX_NUM_FUNCS 20 + +typedef void (*diag_cb_func_type) ( + unsigned char *data_ptr, + unsigned short data_len, + unsigned char *rsp_ptr, + unsigned short *rsp_len_ptr +); + +typedef struct +{ + char *name; + diag_cb_func_type address; +} diag_cb_struct_type; + +typedef struct +{ + char *name; + void *address; +} diag_prop_struct_type; + +typedef enum +{ + DIAG_EXTN_INVALID_GUID = 1, + DIAG_EXTN_INVALID_SIZE, + DIAG_EXTN_INVALID_ADDRESS, + DIAG_EXTN_INVALID_NAME, + DIAG_EXTN_INVALID_DATA +} diag_extn_err_type; + + +/*=========================================================================== + +PACKET DIAG_GET_PROPERTY_F + +PURPOSE Sent by the DM to retrieve a specified number of bytes from + memory starting at a specified location. + +===========================================================================*/ +#define DIAG_MAX_PROPERTY_SIZE 800 +typedef unsigned long * diag_guid_type[4]; + +DIAGPKT_REQ_DEFINE(DIAG_GET_PROPERTY_F) + diag_guid_type guid; /* GUID for verification */ + dword address; /* Starting address in memory */ + word size; /* Number of bytes to retrieve */ +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_GET_PROPERTY_F) + diag_guid_type guid; /* GUID for verification */ + dword address; /* Starting address in memory */ + word size; /* Number of bytes to retrieve */ + byte data[ DIAG_MAX_PROPERTY_SIZE ]; /* Byte values */ +DIAGPKT_RSP_END + + +/*=========================================================================== + +PACKET DIAG_PUT_PROPERTY_F + +PURPOSE Sent by the DM to set the values of a specified number of bytes + in memory starting at a specified location. + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_PUT_PROPERTY_F) + diag_guid_type guid; /* GUID for verification */ + dword address; /* Starting address in memory */ + word size; /* Number of bytes to set */ + byte data[ DIAG_MAX_PROPERTY_SIZE ]; /* Values */ +DIAGPKT_REQ_END + +DIAGPKT_DEFINE_RSP_AS_REQ(DIAG_PUT_PROPERTY_F) + +/*=========================================================================== + +PACKET DIAG_GET_GUID_F + +PURPOSE Sent by the DM to retrieve the GUID (globally unique identifier) + for the current build. This is stored during the build process. + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_GET_GUID_F) +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_GET_GUID_F) + diag_guid_type guid; /* Globally unique identifier */ +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_GET_PERM_PROPERTY_F + +PURPOSE Sent by the DM to retrieve the contents of a structure specified + by name. + +===========================================================================*/ +#define DIAG_MAX_PROPERTY_NAME_SIZE 40 + +DIAGPKT_REQ_DEFINE(DIAG_GET_PERM_PROPERTY_F) + diag_guid_type guid; /* GUID for verification */ + byte name[ DIAG_MAX_PROPERTY_NAME_SIZE ]; /* Structure name */ + word size; /* Number of bytes to retrieve */ +DIAGPKT_REQ_END + +DIAGPKT_RSP_DEFINE(DIAG_GET_PERM_PROPERTY_F) + diag_guid_type guid; /* GUID for verification */ + byte name[ DIAG_MAX_PROPERTY_NAME_SIZE ]; /* Structure name */ + word size; /* Number of bytes to retrieve */ + byte data[ DIAG_MAX_PROPERTY_SIZE ]; /* Structure Contents */ +DIAGPKT_RSP_END + +/*=========================================================================== + +PACKET DIAG_PUT_PERM_PROPERTY_F + +PURPOSE Sent by the DM to fill in a structure specified by name. + +===========================================================================*/ +DIAGPKT_REQ_DEFINE(DIAG_PUT_PERM_PROPERTY_F) + diag_guid_type guid; /* GUID for verification */ + byte name[ DIAG_MAX_PROPERTY_NAME_SIZE ]; /* Structure name */ + word size; /* Number of bytes of data */ + byte data[ DIAG_MAX_PROPERTY_SIZE ]; /* Values */ +DIAGPKT_REQ_END + +DIAGPKT_DEFINE_RSP_AS_REQ(DIAG_PUT_PERM_PROPERTY_F) + +/*-------------------------------------------------------------------------- + Command Codes between the Diagnostic Monitor and the mobile. These command + codes are used for stress testing. +----------------------------------------------------------------------------*/ + +#define DIAGDIAG_START_STRESS_TEST_F 0x0000 +#define DIAGDIAG_CMD_REQUEST_F 0x0001 +#define DIAGDIAG_ADD_EVENT_LISTENER_F 0x0002 +#define DIAGDIAG_REMOVE_EVENT_LISTENER_F 0x0003 +#define DIAGDIAG_ADD_LOG_LISTENER_F 0x0004 +#define DIAGDIAG_REMOVE_LOG_LISTENER_F 0x0005 +#define DIAGDIAG_START_STRESS_TEST_APPS_F 0x0006 + +#define DIAGDIAG_QSR4_FILE_OP_MODEM 0x0816 +#define DIAGDIAG_QSR4_FILE_OP_APPS 0x020F +#define DIAGDIAG_QSR4_FILE_OP_WCNSS 0x141F +#define DIAGDIAG_QSR4_FILE_OP_ADSP 0x0E10 +#define DIAGDIAG_QSR4_FILE_OP_SLPI 0x1A18 + +#define DIAGDIAG_FILE_LIST_OPERATION 0x00 +#define DIAGDIAG_FILE_OPEN_OPERATION 0x01 +#define DIAGDIAG_FILE_READ_OPERATION 0x02 +#define DIAGDIAG_FILE_CLOSE_OPERATION 0x03 + +/*========================================================================== + +PACKET DIAGDIAG_STRESS_TEST + +PURPOSE Request sent from the DM to the DMSS to stress test events. + +============================================================================*/ +typedef enum { + DIAGDIAG_STRESS_TEST_MSG = 0, + DIAGDIAG_STRESS_TEST_MSG_1 = 1, + DIAGDIAG_STRESS_TEST_MSG_2 = 2, + DIAGDIAG_STRESS_TEST_MSG_3 = 3, + DIAGDIAG_STRESS_TEST_MSG_4 = 4, + DIAGDIAG_STRESS_TEST_MSG_5 = 5, + DIAGDIAG_STRESS_TEST_MSG_6 = 6, + DIAGDIAG_STRESS_TEST_MSG_STR = 7, + DIAGDIAG_STRESS_TEST_MSG_PSEUDO_RANDOM = 8, + DIAGDIAG_STRESS_TEST_MSG_LOW = 9, + DIAGDIAG_STRESS_TEST_MSG_MED = 10, + DIAGDIAG_STRESS_TEST_MSG_HIGH = 11, + DIAGDIAG_STRESS_TEST_MSG_ERROR = 12, + DIAGDIAG_STRESS_TEST_MSG_FATAL = 13, + DIAGDIAG_STRESS_TEST_ERR = 14, + DIAGDIAG_STRESS_TEST_ERR_FATAL = 15, + DIAGDIAG_STRESS_TEST_LOG = 16, + DIAGDIAG_STRESS_TEST_EVENT_NO_PAYLOAD = 17, + DIAGDIAG_STRESS_TEST_EVENT_WITH_PAYLOAD = 18, + DIAGDIAG_STRESS_TEST_ERR_FATAL_ISR = 19, /* test panic mode from ISR */ + DIAGDIAG_STRESS_TEST_CMD_REQ = 20, + /* Reserved space up to 39 */ + DIAGDIAG_STRESS_TEST_LOG_64 = 40, + DIAGDIAG_STRESS_TEST_LOG_128 = 41, + DIAGDIAG_STRESS_TEST_LOG_256 = 42, + /* Log of 512 is test type 16 */ + DIAGDIAG_STRESS_TEST_LOG_1K = 43, + DIAGDIAG_STRESS_TEST_LOG_2K = 44, + DIAGDIAG_STRESS_TEST_LOG_4K = 45, + DIAGDIAG_STRESS_TEST_LOG_6K = 46, + /* Test cases for QSR messages */ + DIAGDIAG_STRESS_TEST_QSR_MSG = 47, + DIAGDIAG_STRESS_TEST_QSR_MSG_1 = 48, + DIAGDIAG_STRESS_TEST_QSR_MSG_2 = 49, + DIAGDIAG_STRESS_TEST_QSR_MSG_3 = 50, + DIAGDIAG_STRESS_TEST_QSR_MSG_4 = 51, + DIAGDIAG_STRESS_TEST_QSR_MSG_5 = 52, + DIAGDIAG_STRESS_TEST_QSR_MSG_6 = 53, + DIAGDIAG_STRESS_TEST_QSR_MSG_LOW = 54, + DIAGDIAG_STRESS_TEST_QSR_MSG_MED = 55, + DIAGDIAG_STRESS_TEST_QSR_MSG_HIGH = 56, + DIAGDIAG_STRESS_TEST_QSR_MSG_ERROR = 57, + DIAGDIAG_STRESS_TEST_QSR_MSG_FATAL = 58, + DIAGDIAG_STRESS_TEST_MSG_SPRINTF_1 = 59, + DIAGDIAG_STRESS_TEST_MSG_SPRINTF_2 = 60, + DIAGDIAG_STRESS_TEST_MSG_SPRINTF_3 = 61, + DIAGDIAG_STRESS_TEST_MSG_SPRINTF_4 = 62, + DIAGDIAG_STRESS_TEST_MSG_SPRINTF_5 = 63, +} diag_stress_test_type_enum_type; + +typedef enum { + EXPLICIT_PRI = 0, /* Priority given by the user */ + RELATIVE_PRI = 1 /* relative priority is relative to DIAG_PRI */ +} diag_stress_pri_type_enum_type; + +typedef struct { + uint8 test_type; /* Decides if it is log, msg or event*/ + uint8 pri_type; /* External or relative priority */ + int16 pri; /* Priority at which the task is created */ +} diag_task_priority_type; + +typedef struct { + diag_task_priority_type priority; /* refer to diag_task_priority_type above*/ + int num_iterations; /* the number of times the test_type should be called */ + int sleep_duration; /* Sleep time in milliseconds */ + int num_iterations_before_sleep; /*After NUM_ITERATIONS_BEFORE_SLEEP iterations, sleep */ +} diag_per_task_test_info; + +typedef struct { + diagpkt_subsys_header_type header; /* Sub System header */ + int num_tasks; /* Number of tasks, to be started */ + diag_per_task_test_info test[1]; /* Place holder for per task info */ +} DIAGDIAG_STRESS_TEST_req_type; + +typedef DIAGDIAG_STRESS_TEST_req_type DIAGDIAG_STRESS_TEST_rsp_type; + +typedef struct { + uint16 pri_type; /* External or relative priority */ + int16 pri; /* Priority at which the task is created */ +} diag_priority_type; + + +/*========================================================================== + +PACKET DIAGDIAG_CMD_REQUEST + +PURPOSE Request sent from the DM to the DMSS to test command request. +============================================================================*/ + +typedef struct { + diagpkt_subsys_header_type header; /* Sub System header */ + uint32 length; /* length of the packet */ + diag_priority_type priority; + byte req[64]; /* Packet sent */ +} diagdiag_cmd_req_type; + +typedef diagdiag_cmd_req_type diagdiag_cmd_rsp_type; + + +/*========================================================================== + +PACKET DIAGDIAG_LOG_EVENT_LISTENER + +PURPOSE Request sent from the DM to the DMSS to test log and event listeners. + This type is used for adding and removing log and event listeners. +============================================================================*/ + +typedef struct { + diagpkt_subsys_header_type header; /* Sub System header */ + uint32 length; + uint32 id; /* log code or event id */ + uint32 param; /* Will be printed by debug message */ +} diag_log_event_listener_req_type; + +typedef diag_log_event_listener_req_type diag_log_event_listener_rsp_type; + +/*========================================================================== + +PACKET DIAG_EVENT_MASK_GET_F + +PURPOSE Request sent from the DM to the DMSS to retrieve the event mask. +============================================================================*/ + +typedef struct { + diagpkt_header_type header; + uint8 pad; + uint16 reserved; +} event_mask_get_req_type; + +typedef struct { + diagpkt_header_type header; + uint8 error_code; + uint16 reserved; + uint16 numbits; /* number of bits in the mask */ + unsigned char mask[1]; /* size of this field = (numbits + 7)/8 */ +} event_mask_get_rsp_type; + +/*========================================================================== + +PACKET DIAG_EVENT_MASK_SET_F + +PURPOSE Request sent from the DM to the DMSS to set the event mask. +============================================================================*/ + +typedef struct { + diagpkt_header_type header; + uint8 pad; + uint16 reserved; + uint16 numbits; /* number of bits in the mask */ + unsigned char mask[1]; /* size of this field = (numbits + 7)/8 */ +} event_mask_set_req_type; + +typedef struct { + diagpkt_header_type header; + uint8 error_code; + uint16 reserved; + uint16 numbits; /* number of bits in the mask */ + unsigned char mask[1]; /* size of this field = (numbits + 7)/8 */ +} event_mask_set_rsp_type; + +/* Error codes for the above two packets. + */ +#define EVENT_MASK_GENERAL_FAILURE 1 +#define EVENT_MASK_ARRAY_TOO_SMALL 2 +#define EVENT_MASK_ARRAY_TOO_BIG 3 + +/* Command request response structures to retrieve Qshrink4 database. + */ + +/*========================================================================== + +PACKET DIAG_QSHRINK4_FILE_LIST_REQ + +PURPOSE Request sent to get the qsr4 file list information +============================================================================*/ + +typedef PACK(struct) { + uint8 cmd_code; + uint8 subsys_id; + uint16 subsys_cmd_code; + uint16 version; + uint16 opcode; +} diag_qsr_header_req; + +typedef PACK(struct) { + uint8 cmd_code; + uint8 subsys_id; + uint16 subsys_cmd_code; + uint32 delayed_rsp_status; + uint16 delayed_rsp_id; + uint16 rsp_cnt; + uint16 version; + uint16 opcode; +} diag_qsr_header_rsp; + +typedef PACK(struct) { + uint8 guid[16]; + uint32 file_len; +} file_info; + +typedef PACK(struct) { + diag_qsr_header_rsp rsp_header; + uint8 status; + uint8 num_files; + file_info info[0]; +} diag_qsr_file_list_rsp; + +/*========================================================================== + +PACKET DIAG_QSHRINK4_FILE_OPEN_REQ + +PURPOSE Request sent to open the qsr4 database file +============================================================================*/ +typedef PACK(struct) { + diag_qsr_header_req req; + uint8 guid[16]; +} diag_qsr_file_open_req; + +typedef PACK(struct) { + diag_qsr_header_rsp rsp_header; + uint8 guid[16]; + uint16 read_file_fd; + uint8 status; +} diag_qsr_file_open_rsp; + + +/*========================================================================== + +PACKET DIAG_QSHRINK4_FILE_READ_REQ + +PURPOSE Request sent to read the qsr4 database file +============================================================================*/ +typedef PACK(struct) { + diag_qsr_header_req req; + uint16 read_file_fd; + uint32 req_bytes; + uint32 offset; +} +diag_qsr_file_read_req; + +typedef PACK(struct) { + uint8 cmd_code; + uint8 subsys_id; + uint16 subsys_cmd_code; + uint32 delayed_rsp_status; + uint16 delayed_rsp_id; + uint16 rsp_cnt; + uint16 version; + uint16 opcode; + uint16 read_file_fd; + uint32 offset; + uint32 num_read; + uint8 status; + uint8 data[0]; +} +diag_qsr_file_read_rsp; + +/*========================================================================== + +PACKET DIAG_QSHRINK4_FILE_CLOSE_REQ + +PURPOSE Request sent to open the qsr4 database file +============================================================================*/ +typedef PACK(struct) { + diag_qsr_header_req req; + uint16 read_file_fd; +} diag_qsr_file_close_req; + +typedef PACK(struct) { + diag_qsr_header_rsp rsp_header; + uint16 read_file_fd; + uint8 status; +} diag_qsr_file_close_rsp; + +#endif /* DIAGDIAG_H */ diff --git a/feeds/wifi-ax/qca-diag/src/src/diaglib.mak b/feeds/wifi-ax/qca-diag/src/src/diaglib.mak new file mode 100755 index 000000000..688fb2c85 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diaglib.mak @@ -0,0 +1,53 @@ +# -*- Mode: text -*- +#============================================================================== +# FILE: diaglib.mak +# +# SERVICE: Diagnostics +# +# DESCRIPTION: +# +# Copyright 2012-2015 Qualcomm Technologies, Inc. All rights reserved. +# Qualcomm Technologies Proprietary and Confidential +#============================================================================== + +default: all + +RELPATHTOROOT = ../../../../.. + +TARGET = libdiag +MAKEFILETYPE = shared +MAKEFILENAME = diaglib.mak + +C_SRC = \ + diag_lsm.c\ + diag_lsm_dci.c\ + diag_lsm_event.c\ + diag_lsm_log.c\ + diag_lsm_msg.c\ + diag_lsm_pkt.c\ + diagsvc_malloc.c\ + msg_arrays_i.c\ + ts_linux.c\ + diag_logger.c\ + diag_qshrink4_db_parser.c\ + +NEEDINC=\ + vendor/qcom/proprietary/diag/include\ + vendor/qcom/proprietary/common/inc\ + +NEEDLIB =\ + +CFLAGS += -m32 +CFLAGS += -DFEATURE_LOG_STDOUT +LDFLAGS += -m32 + +BTBUILD=vendor/qcom/proprietary/test/ril/btbuild +include $(RELPATHTOROOT)/$(BTBUILD)/bt.driver.mki + +-include ./${MAKEFILENAME}.depend.mki + +#====================================================================== +# Add Mannual dependencies and makefile overrides here +#====================================================================== + +#EOF diff --git a/feeds/wifi-ax/qca-diag/src/src/diagsvc_malloc.c b/feeds/wifi-ax/qca-diag/src/src/diagsvc_malloc.c new file mode 100755 index 000000000..61041e43f --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diagsvc_malloc.c @@ -0,0 +1,232 @@ + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Mobile Diagnostic Malloc Module + +General Description + All the declarations, definitions, and routines necessary to support + reporting messages for errors and debugging. + +Initialization and Sequencing Requirements + +# Copyright (c) 2007-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + Edit History + +when who what, where, why +-------- --- ---------------------------------------------------------- +05/19/08 JV Pool to allocate from or de-allocate is now based on + a parameter +02/29/08 JV added support for exclusive pre-malloced buffers for + packet req/res +11/29/07 mad modified to conform to coding standards +11/01/07 vs Created + +===========================================================================*/ + +#include "diagsvc_malloc.h" +#include "stdio.h" +#include + +static diagmem gaDiagSvcMalloc[DIAGSVC_MALLOC_MAX_ITEMS]; +static diagmem gaDiagSvcPktMalloc[DIAGSVC_MALLOC_MAX_ITEMS]; +static int gnDiagSvcMalloc_Initialized = 0; +static pthread_mutex_t gaDiagSvcMalloc_mutex; + +/*=========================================================================== + +FUNCTION DiagSvc_Malloc + +DESCRIPTION + Wrapper function for malloc. Returns a pre-malloced memory region. Does a simple + malloc if the pre-malloced buffers have been exhausted. Uses different memory + pools depending on the Svc_ID. Events, logs, F3s and delayed responses are + allocated from one pool and responses are allocated from nother pool. + +DEPENDENCIES: + DiagSvcMalloc_Init should be called ONCE before this function is called + +RETURN VALUE + Same as malloc + +===========================================================================*/ + +void *DiagSvc_Malloc(size_t size, int Svc_ID) +{ + int i = 0; + void *ret = NULL; + diagmem *pool = NULL; + + if (!gnDiagSvcMalloc_Initialized) + return NULL; + + switch (Svc_ID) { + case GEN_SVC_ID: + if (size > DIAGSVC_MALLOC_ITEM_SIZE) + goto alloc; + pool = gaDiagSvcMalloc; + break; + case PKT_SVC_ID: + if (size > DIAGSVC_MALLOC_PKT_ITEM_SIZE) + return NULL; + pool = gaDiagSvcPktMalloc; + break; + default: + pool = NULL; + break; + } + + if (pool == NULL) + return NULL; + + pthread_mutex_lock(&gaDiagSvcMalloc_mutex); + for (i = 0; i < DIAGSVC_MALLOC_MAX_ITEMS; i++) { + if (pool[i].in_use == 0) { + pool[i].in_use = 1; + ret = pool[i].ptr; + break; + } + } + pthread_mutex_unlock(&gaDiagSvcMalloc_mutex); +alloc: + /* + * We did not find any space in pre-allocated memory, + * call malloc directly + */ + if(ret == NULL) + ret = malloc(size); + + return ret; +} + +/*=========================================================================== + +FUNCTION DiagSvc_Free + +DESCRIPTION + Wrapper function for free. Frees a pre-malloced memory region, by returning + it to the available list of buffers. This function does not invoke "free" + for buffers that were pre-alloacted. The pool to return to is based on a + paarmeter. + +DEPENDENCIES: + DiagSvcMalloc_Init should be called ONCE before this function is called + +RETURN VALUE + None + +===========================================================================*/ +void DiagSvc_Free(void *ptr, int Svc_ID) +{ + int i = 0, found = 0; + diagmem *pool = NULL; + + if (!gnDiagSvcMalloc_Initialized) + return; + if (!ptr) + return; + + switch (Svc_ID) { + case GEN_SVC_ID: + pool = gaDiagSvcMalloc; + break; + case PKT_SVC_ID: + pool = gaDiagSvcPktMalloc; + break; + default: + pool = NULL; + break; + } + + if (pool == NULL) + return; + + pthread_mutex_lock(&gaDiagSvcMalloc_mutex); + for (i = 0; i < DIAGSVC_MALLOC_MAX_ITEMS; i++) { + if (pool[i].ptr == ptr) { + pool[i].in_use = 0; + found = 1; + break; + } + } + pthread_mutex_unlock(&gaDiagSvcMalloc_mutex); + + /* The buffer is not present in pre-allocated memory, Free it manually */ + if (!found) + free(ptr); +} + +/*=========================================================================== + +FUNCTION DiagSvc_Malloc_Init + +DESCRIPTION + Funciton to initialize the buffers used for DiagSvc_Malloc. + +DEPENDENCIES: + +RETURN VALUE + TRUE if initialization is successful, FALSE otherwise + +===========================================================================*/ +boolean DiagSvc_Malloc_Init(void) +{ + int i = 0; + + if (gnDiagSvcMalloc_Initialized) + return TRUE; + + pthread_mutex_init(&gaDiagSvcMalloc_mutex, NULL); + for (i = 0; i < DIAGSVC_MALLOC_MAX_ITEMS; i++) { + gaDiagSvcMalloc[i].ptr = malloc(DIAGSVC_MALLOC_ITEM_SIZE); + gaDiagSvcPktMalloc[i].ptr = malloc(DIAGSVC_MALLOC_PKT_ITEM_SIZE); + if(!(gaDiagSvcMalloc[i].ptr) || !(gaDiagSvcPktMalloc[i].ptr)) { + DiagSvc_Malloc_Exit(); + return FALSE; + } + gaDiagSvcMalloc[i].in_use = 0; + gaDiagSvcPktMalloc[i].in_use = 0; + } + + gnDiagSvcMalloc_Initialized = 1; + return TRUE; +} + +/*=========================================================================== + +FUNCTION DiagSvc_Malloc_Exit + +DESCRIPTION + Funciton to free the buffers used for DiagSvc_Malloc. + +DEPENDENCIES: + +RETURN VALUE + None + +===========================================================================*/ +void DiagSvc_Malloc_Exit(void) +{ + int i = 0; + + pthread_mutex_lock(&gaDiagSvcMalloc_mutex); + for(i = 0; i < DIAGSVC_MALLOC_MAX_ITEMS; i++) { + if (gaDiagSvcMalloc[i].ptr) { + free(gaDiagSvcMalloc[i].ptr); + gaDiagSvcMalloc[i].ptr = NULL; + } + gaDiagSvcMalloc[i].in_use = 0; + if (gaDiagSvcPktMalloc[i].ptr) { + free(gaDiagSvcPktMalloc[i].ptr); + gaDiagSvcPktMalloc[i].ptr = NULL; + } + gaDiagSvcPktMalloc[i].in_use = 0; + } + pthread_mutex_unlock(&gaDiagSvcMalloc_mutex); + + gnDiagSvcMalloc_Initialized = 0; +} + diff --git a/feeds/wifi-ax/qca-diag/src/src/diagsvc_malloc.h b/feeds/wifi-ax/qca-diag/src/src/diagsvc_malloc.h new file mode 100755 index 000000000..152022190 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/diagsvc_malloc.h @@ -0,0 +1,117 @@ +#ifndef DIAGSVCMALLOC_H +#define DIAGSVCMALLOC_H + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Mobile Diagnostic Malloc Module Header + +General Description + +Initialization and Sequencing Requirements + +# Copyright (c) 2007-2011, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + Edit History + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Added diag_types.h, a customized version of comdef.h for DIAG +05/19/08 JV Added the #defines that identify which pool to allocate from +11/01/07 vs Created +===========================================================================*/ + +#include "malloc.h" +#include "comdef.h" +#include "diag_shared_i.h" +#include "diag_lsm_pkt_i.h" + +#define DIAGSVC_MALLOC_MAX_ITEMS 10 +#define DIAGSVC_MALLOC_ITEM_SIZE (2 * 1024) +#define DIAGSVC_MALLOC_PKT_ITEM_SIZE \ + (int)(DIAG_MAX_RX_PKT_SIZ + DIAG_REST_OF_DATA_POS + \ + FPOS (diagpkt_lsm_rsp_type, rsp.pkt) + sizeof (uint16)) \ + +#define GEN_SVC_ID 1 +#define PKT_SVC_ID 2 + +typedef struct +{ + void * ptr; + int in_use; +} diagmem; + +/*=========================================================================== + +FUNCTION DiagSvc_Malloc + +DESCRIPTION + Wrapper function for malloc. Returns a pre-malloced memory region. Does a simple + malloc if the pre-malloced buffers have been exhausted. Uses different memory + pools depending on the Svc_ID. Events, logs, F3s and delayed responses are + allocated from one pool and responses are allocated from nother pool. + +DEPENDENCIES: + DiagSvcMalloc_Init should be called ONCE before this function is called +RETURN VALUE + Same as malloc + +===========================================================================*/ +void *DiagSvc_Malloc(size_t size, int Svc_ID); + + + +/*=========================================================================== + +FUNCTION DiagSvc_Free + +DESCRIPTION + Wrapper function for free. Frees a pre-malloced memory region, by returning + it to the available list of buffers. This function does not invoke "free" + for buffers that were pre-alloacted. The pool to return to is based on a + paarmeter. + +DEPENDENCIES: + DiagSvcMalloc_Init should be called ONCE before this function is called +RETURN VALUE + None + +===========================================================================*/ +void DiagSvc_Free(void *ptr, int Svc_ID); + + +/*=========================================================================== + +FUNCTION DiagSvc_Malloc_Init + +DESCRIPTION + Funciton to initialize the buffers used for DiagSvc_Malloc. + +DEPENDENCIES: + +RETURN VALUE + TRUE if initialization is successful, FALSE otherwise + +===========================================================================*/ +boolean DiagSvc_Malloc_Init(void); + + +/*=========================================================================== + +FUNCTION DiagSvc_Malloc_Exit + +DESCRIPTION + Funciton to free the buffers used for DiagSvc_Malloc. + +DEPENDENCIES: + +RETURN VALUE + None + +===========================================================================*/ +void DiagSvc_Malloc_Exit(void); + + +#endif /* DIAGSVCMALLOC_H */ diff --git a/feeds/wifi-ax/qca-diag/src/src/eventi.h b/feeds/wifi-ax/qca-diag/src/src/eventi.h new file mode 100755 index 000000000..17768cb47 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/eventi.h @@ -0,0 +1,98 @@ +#ifndef EVENTI_H +#define EVENTI_H + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Event Services internal header file + +General Description + Internal declarations to support diag event service. + +Initializing and Sequencing Requirements + None + +# Copyright (c) 2007-2011 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + Edit History + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 sj Changes for CBSP2.0 +01/10/08 mad Added copyright and file description. +12/5/07 as Created + +===========================================================================*/ + +#include "event_defs.h" +#include "diagdiag.h" +#include "comdef.h" + +/* Size of the event mask array, which is derived from the maximum number + of events. +*/ +#define EVENT_MASK_SIZE (EVENT_LAST_ID/8 + 1) + +#define EVENT_MASK_BIT_SET(id) \ + (event_mask[(id)/8] & (1 << ((id) & 0x07))) + +#define EVENT_SEND_MAX 50 +#define EVENT_RPT_PKT_LEN_SIZE 0x200 + +/* The event mask. */ +/* WM7 */ +unsigned char event_mask[EVENT_MASK_SIZE]; +//unsigned char* event_mask; + +/* NOTE: diag_event_type and event_store_type purposely use the same + format, except that event_store type is preceeded by a Q link + and the event ID field has a union for internal packet formatting. + If either types are changed, the service will not function properly. */ +#ifndef FEATURE_LE_DIAG +struct event_store_type +{ + uint8 cmd_code; /* 96 (0x60) */ + uint16 length; /* Length of packet */ + union + { + event_id_type event_id_field; + } + event_id; + uint32 ts_lo; /* Time stamp */ + uint32 ts_hi; + + event_payload_type payload; +} __attribute__((__packed__)); +#else +#pragma pack(push, 1) +struct event_store_type +{ + uint8 cmd_code; // 96 (0x60) + uint16 length; // Length of packet + union + { + event_id_type event_id_field; + } + event_id; + uint32 ts_lo; // Time stamp + uint32 ts_hi; + + event_payload_type payload; +}; +#pragma pack(pop) +#endif + +typedef struct +{ + uint8 payload[32]; +} event_large_payload_type; + +#define EVENT_LARGE_PAYLOAD(X) \ + (((event_large_payload_type *)X)->payload) + +/* WM7 */ +#define DIAG_EVENT_MASK_SHAREMAP_NAME _T("Diag_Event_Mask_Shared") + +#endif /* EVENTI_H */ diff --git a/feeds/wifi-ax/qca-diag/src/src/msg_arrays_i.c b/feeds/wifi-ax/qca-diag/src/src/msg_arrays_i.c new file mode 100755 index 000000000..ac8cc15a0 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/msg_arrays_i.c @@ -0,0 +1,1083 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + DIAGNOSTIC MESSAGE SERVICE: ARRAYS FOR BUILD/RUN-TIME MASKS + + +GENERAL DESCRIPTION + Contains array definitions for build-time and run-time masks. + +Copyright (c) 2010-2015 by Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + EDIT HISTORY FOR FILE + + $Header: //source/qcom/qct/core/services/diag/main/latest/diag_mask_tbl/src/msg_arrays_i.c#42 $ + +when who what, where, why +-------- --- ---------------------------------------------------------- +03/31/14 xy Added new message SSIDs +01/29/14 xy Added new message SSIDs +12/03/13 xy Added new message SSIDs +09/25/13 xy Added new message SSIDs +07/30/13 sr Added new message SSIDs +06/26/13 sr Added new message SSIDs +05/08/13 sr Added new message SSIDs +03/22/13 sr Added new message SSIDs +03/12/13 sr Added new message SSIDs +01/22/13 sr Added new message SSIDs +12/07/12 sr Added new message SSIDs +11/27/12 sr Added new message SSIDs +07/16/12 rh Added new message SSIDs +06/22/12 rh Added new message SSIDs +02/29/12 rh Added new message SSIDs +02/17/12 rs Added build mask for MSG_SSID_SEC_WIDEVINE +01/05/12 rh Added QCNEA SSIDs +12/08/11 rh Added build mask for MSG_SSID_ADC +11/29/11 rh Added SSID category for CTA +10/18/11 hm Renamed reserved MCS SSIDs +09/01/11 hm Added new WCDMA and TDSCDMA SSIDs +08/05/11 hm Added new SSID +07/01/11 hm Added new SSID +04/25/11 hm Added new SSID +04/05/11 hm Added new SSID for PPM module +03/24/11 hm Reverted Octopus Changes and added new QCHAT SSIDs +03/07/11 hm Added new set of SSIDs for Octopus +12/21/10 hm Dual Mask Changes +12/15/10 vg Added GPS SSID and LTE Events +12/13/10 vg Added 2 New SSIDs +12/06/10 vg Added PMIC API +07/27/10 sg Added new SSID for multimedia +07/07/10 sg Added new SSID for data services +07/06/10 sg Changed MSG_SSID_MCS_RESERVED_1 to MSG_SSID_FWS +05/05/10 sg Added new SSID MSG_SSID_CFM +04/27/10 sg Added new SSIDS for Sound Routing Driver , DAL +04/20/10 sg Added new SSIDS for Audio Team +04/09/10 sg Added new SSIDS for OMA device management + Secure Instant Wireless Access +03/04/10 sg Added new SSIDs for IMS team +02/22/10 sg Added new SSIDs for Data Services +02/08/10 sg Added new SSIDs for IMS team +01/13/10 sg Added new SSID for CAD team +12/22/09 sg Added New SSID for Connectivity Engine team +10/28/09 sg Added New SSID for Chaos CoOrdinator Service +10/22/09 sg Added New SSID for MSG_BUILD_MASK_MSG_SSID_DS_MUX +10/06/09 sg Added msg_mask_tbl_size to support compilation with FTM + on older targets +09/29/09 mad Created from msgcfg.h. Moved all mask array definitions + here. +===========================================================================*/ + +#include "msg.h" +#include "msg_arrays_i.h" + +/* This table must be maintained as SSIDs are added! + NOTE: The legacy build mask is handled on a per-file basis. */ +static const uint32 msg_bld_masks_gen[] = +{ + MSG_LVL_LOW, /* special case - may vary by file is MSG_LEVEL is used */ + MSG_BUILD_MASK_MSG_SSID_AUDFMT, + MSG_BUILD_MASK_MSG_SSID_AVS, + MSG_BUILD_MASK_MSG_SSID_BOOT, + MSG_BUILD_MASK_MSG_SSID_BT, + MSG_BUILD_MASK_MSG_SSID_CM, + MSG_BUILD_MASK_MSG_SSID_CMX, + MSG_BUILD_MASK_MSG_SSID_DIAG, + MSG_BUILD_MASK_MSG_SSID_DSM, + MSG_BUILD_MASK_MSG_SSID_FS, + MSG_BUILD_MASK_MSG_SSID_HS, + MSG_BUILD_MASK_MSG_SSID_MDSP, + MSG_BUILD_MASK_MSG_SSID_QDSP, + MSG_BUILD_MASK_MSG_SSID_REX, + MSG_BUILD_MASK_MSG_SSID_RF, + MSG_BUILD_MASK_MSG_SSID_SD, + MSG_BUILD_MASK_MSG_SSID_SIO, + MSG_BUILD_MASK_MSG_SSID_VS, + MSG_BUILD_MASK_MSG_SSID_WMS, + MSG_BUILD_MASK_MSG_SSID_GPS, + MSG_BUILD_MASK_MSG_SSID_MMOC, + MSG_BUILD_MASK_MSG_SSID_RUIM, + MSG_BUILD_MASK_MSG_SSID_TMC, + MSG_BUILD_MASK_MSG_SSID_FTM, + MSG_BUILD_MASK_MSG_SSID_MMGPS, + MSG_BUILD_MASK_MSG_SSID_SLEEP, + MSG_BUILD_MASK_MSG_SSID_SAM, + MSG_BUILD_MASK_MSG_SSID_SRM, + MSG_BUILD_MASK_MSG_SSID_SFAT, + MSG_BUILD_MASK_MSG_SSID_JOYST, + MSG_BUILD_MASK_MSG_SSID_MFLO, + MSG_BUILD_MASK_MSG_SSID_DTV, + MSG_BUILD_MASK_MSG_SSID_TCXOMGR, + MSG_BUILD_MASK_MSG_SSID_EFS, + MSG_BUILD_MASK_MSG_SSID_IRDA, + MSG_BUILD_MASK_MSG_SSID_FM_RADIO, + MSG_BUILD_MASK_MSG_SSID_AAM, + MSG_BUILD_MASK_MSG_SSID_BM, + MSG_BUILD_MASK_MSG_SSID_PE, + MSG_BUILD_MASK_MSG_SSID_QIPCALL, + MSG_BUILD_MASK_MSG_SSID_FLUTE, + MSG_BUILD_MASK_MSG_SSID_CAMERA, + MSG_BUILD_MASK_MSG_SSID_HSUSB, + MSG_BUILD_MASK_MSG_SSID_FC, + MSG_BUILD_MASK_MSG_SSID_USBHOST, + MSG_BUILD_MASK_MSG_SSID_PROFILER, + MSG_BUILD_MASK_MSG_SSID_MGP, + MSG_BUILD_MASK_MSG_SSID_MGPME, + MSG_BUILD_MASK_MSG_SSID_GPSOS, + MSG_BUILD_MASK_MSG_SSID_MGPPE, + MSG_BUILD_MASK_MSG_SSID_GPSSM, + MSG_BUILD_MASK_MSG_SSID_IMS, + MSG_BUILD_MASK_MSG_SSID_MBP_RF, + MSG_BUILD_MASK_MSG_SSID_SNS, + MSG_BUILD_MASK_MSG_SSID_WM, + MSG_BUILD_MASK_MSG_SSID_LK, + MSG_BUILD_MASK_MSG_SSID_PWRDB, + MSG_BUILD_MASK_MSG_SSID_DCVS, + MSG_BUILD_MASK_MSG_SSID_ANDROID_ADB, + MSG_BUILD_MASK_MSG_SSID_VIDEO_ENCODER, + MSG_BUILD_MASK_MSG_SSID_VENC_OMX, + MSG_BUILD_MASK_MSG_SSID_GAN, + MSG_BUILD_MASK_MSG_SSID_KINETO_GAN, + MSG_BUILD_MASK_MSG_SSID_ANDROID_QCRIL, + MSG_BUILD_MASK_MSG_SSID_A2, + MSG_BUILD_MASK_MSG_SSID_LINUX_DATA, + MSG_BUILD_MASK_MSG_SSID_ECALL, + MSG_BUILD_MASK_MSG_SSID_CHORD, + MSG_BUILD_MASK_MSG_SSID_QCNE, + MSG_BUILD_MASK_MSG_SSID_APPS_CAD_GENERAL, + MSG_BUILD_MASK_MSG_SSID_OMADM, /* OMA device management */ + MSG_BUILD_MASK_MSG_SSID_SIWA, /* Secure Instant Wireless Access */ + MSG_BUILD_MASK_MSG_SSID_APR_MODEM, /* Audio Packet Router Modem */ + MSG_BUILD_MASK_MSG_SSID_APR_APPS, /* Audio Packet Router Apps*/ + MSG_BUILD_MASK_MSG_SSID_APR_ADSP, /* Audio Packet Router Adsp*/ + MSG_BUILD_MASK_MSG_SSID_SRD_GENERAL , + MSG_BUILD_MASK_MSG_SSID_ACDB_GENERAL , + MSG_BUILD_MASK_MSG_SSID_DALTF, + MSG_BUILD_MASK_MSG_SSID_CFM, + MSG_BUILD_MASK_MSG_SSID_PMIC, + MSG_BUILD_MASK_MSG_SSID_GPS_SDP, + MSG_BUILD_MASK_MSG_SSID_TLE, + MSG_BUILD_MASK_MSG_SSID_TLE_XTM, + MSG_BUILD_MASK_MSG_SSID_TLE_TLM, + MSG_BUILD_MASK_MSG_SSID_TLE_TLM_MM, + MSG_BUILD_MASK_MSG_SSID_WWAN_LOC, + MSG_BUILD_MASK_MSG_SSID_GNSS_LOCMW, + MSG_BUILD_MASK_MSG_SSID_QSET, + MSG_BUILD_MASK_MSG_SSID_QBI, + MSG_BUILD_MASK_MSG_SSID_ADC, + MSG_BUILD_MASK_MSG_SSID_MMODE_QMI, + MSG_BUILD_MASK_MSG_SSID_MCFG, + MSG_BUILD_MASK_MSG_SSID_SSM, + MSG_BUILD_MASK_MSG_SSID_MPOWER, + MSG_BUILD_MASK_MSG_SSID_RMTS, + MSG_BUILD_MASK_MSG_SSID_ADIE, + MSG_BUILD_MASK_MSG_SSID_VT_VCEL, + MSG_BUILD_MASK_MSG_SSID_FLASH_SCRUB, + MSG_BUILD_MASK_MSG_SSID_STRIDE, + MSG_BUILD_MASK_MSG_SSID_POLICYMAN, + MSG_BUILD_MASK_MSG_SSID_TMS, + MSG_BUILD_MASK_MSG_SSID_LWIP, + MSG_BUILD_MASK_MSG_SSID_RFS, + MSG_BUILD_MASK_MSG_SSID_RFS_ACCESS, + MSG_BUILD_MASK_MSG_SSID_RLC, + MSG_BUILD_MASK_MSG_SSID_MEMHEAP, + MSG_BUILD_MASK_MSG_SSID_WCI2, + MSG_BUILD_MASK_MSG_SSID_LOWI_TEST, + MSG_BUILD_MASK_MSG_SSID_AOSTLM, + MSG_BUILD_MASK_MSG_SSID_LOWI_AP, + MSG_BUILD_MASK_MSG_SSID_LOWI_MP, + MSG_BUILD_MASK_MSG_SSID_LOWI_LP, + MSG_BUILD_MASK_MSG_SSID_MRE, + MSG_BUILD_MASK_MSG_SSID_SLIM, + MSG_BUILD_MASK_MSG_SSID_WLE, + MSG_BUILD_MASK_MSG_SSID_WLM, + MSG_BUILD_MASK_MSG_SSID_Q6ZIP, + MSG_BUILD_MASK_MSG_SSID_RF_DEBUG, + MSG_BUILD_MASK_MSG_SSID_NV +/* EXAMPLE, placing build mask in table for msg.c. All build masks not defined + in diagtgt.h will have a table entry that is the same as msg.c. */ +#if 0 + MSG_BUILD_MASK_MSG_SSID_FOO +#endif +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_gen[2][sizeof (msg_bld_masks_gen) / + sizeof (msg_bld_masks_gen[0])]; + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_oncrpc[] = +{ + MSG_BUILD_MASK_MSG_SSID_ONCRPC, + MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_MODEM, + MSG_BUILD_MASK_MSG_SSID_ONCRPC_MISC_APPS, + MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_MODEM, + MSG_BUILD_MASK_MSG_SSID_ONCRPC_CM_APPS, + MSG_BUILD_MASK_MSG_SSID_ONCRPC_DB, + MSG_BUILD_MASK_MSG_SSID_ONCRPC_SND, +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_oncrpc[2][sizeof (msg_bld_masks_oncrpc) / + sizeof (msg_bld_masks_oncrpc[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_1X[] = +{ + MSG_BUILD_MASK_MSG_SSID_1X, + MSG_BUILD_MASK_MSG_SSID_1X_ACP, + MSG_BUILD_MASK_MSG_SSID_1X_DCP, + MSG_BUILD_MASK_MSG_SSID_1X_DEC, + MSG_BUILD_MASK_MSG_SSID_1X_ENC, + MSG_BUILD_MASK_MSG_SSID_1X_GPSSRCH, + MSG_BUILD_MASK_MSG_SSID_1X_MUX, + MSG_BUILD_MASK_MSG_SSID_1X_SRCH +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_1X[2][sizeof (msg_bld_masks_1X) / + sizeof (msg_bld_masks_1X[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_hdr[] = +{ + MSG_BUILD_MASK_MSG_SSID_HDR_PROT, + MSG_BUILD_MASK_MSG_SSID_HDR_DATA, + MSG_BUILD_MASK_MSG_SSID_HDR_SRCH, + MSG_BUILD_MASK_MSG_SSID_HDR_DRIVERS, + MSG_BUILD_MASK_MSG_SSID_HDR_IS890, + MSG_BUILD_MASK_MSG_SSID_HDR_DEBUG, + MSG_BUILD_MASK_MSG_SSID_HDR_HIT, + MSG_BUILD_MASK_MSG_SSID_HDR_PCP, + MSG_BUILD_MASK_MSG_SSID_HDR_HEAPMEM +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_hdr[2][sizeof (msg_bld_masks_hdr) / + sizeof (msg_bld_masks_hdr[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_umts[] = +{ + MSG_BUILD_MASK_MSG_SSID_UMTS, + MSG_BUILD_MASK_MSG_SSID_WCDMA_L1, + MSG_BUILD_MASK_MSG_SSID_WCDMA_L2, + MSG_BUILD_MASK_MSG_SSID_WCDMA_MAC, + MSG_BUILD_MASK_MSG_SSID_WCDMA_RLC, + MSG_BUILD_MASK_MSG_SSID_WCDMA_RRC, + MSG_BUILD_MASK_MSG_SSID_NAS_CNM, + MSG_BUILD_MASK_MSG_SSID_NAS_MM, + MSG_BUILD_MASK_MSG_SSID_NAS_MN, + MSG_BUILD_MASK_MSG_SSID_NAS_RABM, + MSG_BUILD_MASK_MSG_SSID_NAS_REG, + MSG_BUILD_MASK_MSG_SSID_NAS_SM, + MSG_BUILD_MASK_MSG_SSID_NAS_TC, + MSG_BUILD_MASK_MSG_SSID_NAS_CB, + MSG_BUILD_MASK_MSG_SSID_WCDMA_LEVEL +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_umts[2][sizeof (msg_bld_masks_umts) / + sizeof (msg_bld_masks_umts[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_gsm[] = +{ + MSG_BUILD_MASK_MSG_SSID_GSM, + MSG_BUILD_MASK_MSG_SSID_GSM_L1, + MSG_BUILD_MASK_MSG_SSID_GSM_L2, + MSG_BUILD_MASK_MSG_SSID_GSM_RR, + MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GCOMMON, + MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GLLC, + MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GMAC, + MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GPL1, + MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRLC, + MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GRR, + MSG_BUILD_MASK_MSG_SSID_GSM_GPRS_GSNDCP +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_gsm[2][sizeof (msg_bld_masks_gsm) / + sizeof (msg_bld_masks_gsm[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_wlan[] = +{ + MSG_BUILD_MASK_MSG_SSID_WLAN, + MSG_BUILD_MASK_MSG_SSID_WLAN_ADP, + MSG_BUILD_MASK_MSG_SSID_WLAN_CP, + MSG_BUILD_MASK_MSG_SSID_WLAN_FTM, + MSG_BUILD_MASK_MSG_SSID_WLAN_OEM, + MSG_BUILD_MASK_MSG_SSID_WLAN_SEC, + MSG_BUILD_MASK_MSG_SSID_WLAN_TRP, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_1, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_2, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_3, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_4, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_5, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_6, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_7, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_8, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_9, + MSG_BUILD_MASK_MSG_SSID_WLAN_RESERVED_10, + MSG_BUILD_MASK_MSG_SSID_WLAN_TL, + MSG_BUILD_MASK_MSG_SSID_WLAN_BAL, + MSG_BUILD_MASK_MSG_SSID_WLAN_SAL, + MSG_BUILD_MASK_MSG_SSID_WLAN_SSC, + MSG_BUILD_MASK_MSG_SSID_WLAN_HDD, + MSG_BUILD_MASK_MSG_SSID_WLAN_SME, + MSG_BUILD_MASK_MSG_SSID_WLAN_PE, + MSG_BUILD_MASK_MSG_SSID_WLAN_HAL, + MSG_BUILD_MASK_MSG_SSID_WLAN_SYS, + MSG_BUILD_MASK_MSG_SSID_WLAN_VOSS, + MSG_BUILD_MASK_MSG_SSID_WLAN_ATHOS, + MSG_BUILD_MASK_MSG_SSID_WLAN_WMI, + MSG_BUILD_MASK_MSG_SSID_WLAN_HTT, + MSG_BUILD_MASK_MSG_SSID_WLAN_PS_STA, + MSG_BUILD_MASK_MSG_SSID_WLAN_PS_IBSS, + MSG_BUILD_MASK_MSG_SSID_WLAN_PS_AP, + MSG_BUILD_MASK_MSG_SSID_WLAN_SMPS_STA, + MSG_BUILD_MASK_MSG_SSID_WLAN_WHAL, + MSG_BUILD_MASK_MSG_SSID_WLAN_COEX, + MSG_BUILD_MASK_MSG_SSID_WLAN_ROAM , + MSG_BUILD_MASK_MSG_SSID_WLAN_RESMGR, + MSG_BUILD_MASK_MSG_SSID_WLAN_PROTO, + MSG_BUILD_MASK_MSG_SSID_WLAN_SCAN, + MSG_BUILD_MASK_MSG_SSID_WLAN_BATCH_SCAN, + MSG_BUILD_MASK_MSG_SSID_WLAN_EXTSCAN, + MSG_BUILD_MASK_MSG_SSID_WLAN_RC, + MSG_BUILD_MASK_MSG_SSID_WLAN_BLOCKACK, + MSG_BUILD_MASK_MSG_SSID_WLAN_TXRX_DATA, + MSG_BUILD_MASK_MSG_SSID_WLAN_TXRX_MGMT, + MSG_BUILD_MASK_MSG_SSID_WLAN_BEACON, + MSG_BUILD_MASK_MSG_SSID_WLAN_OFFLOAD_MGR, + MSG_BUILD_MASK_MSG_SSID_WLAN_MACCORE, + MSG_BUILD_MASK_MSG_SSID_WLAN_PCIELP, + MSG_BUILD_MASK_MSG_SSID_WLAN_RTT, + MSG_BUILD_MASK_MSG_SSID_WLAN_DCS, + MSG_BUILD_MASK_MSG_SSID_WLAN_CACHEMGR, + MSG_BUILD_MASK_MSG_SSID_WLAN_ANI, + MSG_BUILD_MASK_MSG_SSID_WLAN_P2P, + MSG_BUILD_MASK_MSG_SSID_WLAN_CSA, + MSG_BUILD_MASK_MSG_SSID_WLAN_NLO, + MSG_BUILD_MASK_MSG_SSID_WLAN_CHATTER, + MSG_BUILD_MASK_MSG_SSID_WLAN_WOW, + MSG_BUILD_MASK_MSG_SSID_WLAN_WMMAC, + MSG_BUILD_MASK_MSG_SSID_WLAN_TDLS, + MSG_BUILD_MASK_MSG_SSID_WLAN_HB, + MSG_BUILD_MASK_MSG_SSID_WLAN_TXBF, + MSG_BUILD_MASK_MSG_SSID_WLAN_THERMAL, + MSG_BUILD_MASK_MSG_SSID_WLAN_DFS, + MSG_BUILD_MASK_MSG_SSID_WLAN_RMC, + MSG_BUILD_MASK_MSG_SSID_WLAN_STATS, + MSG_BUILD_MASK_MSG_SSID_WLAN_NAN, + MSG_BUILD_MASK_MSG_SSID_WLAN_HIF_UART, + MSG_BUILD_MASK_MSG_SSID_WLAN_LPI, + MSG_BUILD_MASK_MSG_SSID_WLAN_MLME, + MSG_BUILD_MASK_MSG_SSID_WLAN_SUPPL, + MSG_BUILD_MASK_MSG_SSID_WLAN_ERE, + MSG_BUILD_MASK_MSG_SSID_WLAN_OCB +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_wlan[2][sizeof (msg_bld_masks_wlan) / + sizeof (msg_bld_masks_wlan[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_mcs[] = +{ + MSG_BUILD_MASK_MSG_SSID_ATS, + MSG_BUILD_MASK_MSG_SSID_MSGR, + MSG_BUILD_MASK_MSG_SSID_APPMGR, + MSG_BUILD_MASK_MSG_SSID_QTF, + MSG_BUILD_MASK_MSG_SSID_FWS, + MSG_BUILD_MASK_MSG_SSID_SRCH4, + MSG_BUILD_MASK_MSG_SSID_CMAPI, + MSG_BUILD_MASK_MSG_SSID_MMAL, + MSG_BUILD_MASK_MSG_SSID_QRARB, + MSG_BUILD_MASK_MSG_SSID_LMTSMGR, + MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_7, + MSG_BUILD_MASK_MSG_SSID_MCS_RESERVED_8, + MSG_BUILD_MASK_MSG_SSID_IRATMAN, + MSG_BUILD_MASK_MSG_SSID_CXM, + MSG_BUILD_MASK_MSG_SSID_VSTMR, + MSG_BUILD_MASK_MSG_SSID_CFCM +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_mcs[2][sizeof (msg_bld_masks_mcs) / + sizeof (msg_bld_masks_mcs[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_ds[] = +{ + MSG_BUILD_MASK_MSG_SSID_DS, + MSG_BUILD_MASK_MSG_SSID_DS_RLP, + MSG_BUILD_MASK_MSG_SSID_DS_PPP, + MSG_BUILD_MASK_MSG_SSID_DS_TCPIP, + MSG_BUILD_MASK_MSG_SSID_DS_IS707, + MSG_BUILD_MASK_MSG_SSID_DS_3GMGR, + MSG_BUILD_MASK_MSG_SSID_DS_PS, + MSG_BUILD_MASK_MSG_SSID_DS_MIP, + MSG_BUILD_MASK_MSG_SSID_DS_UMTS, + MSG_BUILD_MASK_MSG_SSID_DS_GPRS, + MSG_BUILD_MASK_MSG_SSID_DS_GSM, + MSG_BUILD_MASK_MSG_SSID_DS_SOCKETS, + MSG_BUILD_MASK_MSG_SSID_DS_ATCOP, + MSG_BUILD_MASK_MSG_SSID_DS_SIO, + MSG_BUILD_MASK_MSG_SSID_DS_BCMCS, + MSG_BUILD_MASK_MSG_SSID_DS_MLRLP, + MSG_BUILD_MASK_MSG_SSID_DS_RTP, + MSG_BUILD_MASK_MSG_SSID_DS_SIPSTACK, + MSG_BUILD_MASK_MSG_SSID_DS_ROHC, + MSG_BUILD_MASK_MSG_SSID_DS_DOQOS, + MSG_BUILD_MASK_MSG_SSID_DS_IPC, + MSG_BUILD_MASK_MSG_SSID_DS_SHIM, + MSG_BUILD_MASK_MSG_SSID_DS_ACLPOLICY, + MSG_BUILD_MASK_MSG_SSID_DS_APPS, + MSG_BUILD_MASK_MSG_SSID_DS_MUX, + MSG_BUILD_MASK_MSG_SSID_DS_3GPP, + MSG_BUILD_MASK_MSG_SSID_DS_LTE, + MSG_BUILD_MASK_MSG_SSID_DS_WCDMA, + MSG_BUILD_MASK_MSG_SSID_DS_ACLPOLICY_APPS, + MSG_BUILD_MASK_MSG_SSID_DS_HDR, + MSG_BUILD_MASK_MSG_SSID_DS_IPA, + MSG_BUILD_MASK_MSG_SSID_DS_EPC, + MSG_BUILD_MASK_MSG_SSID_DS_APPSRV +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_ds[2][sizeof (msg_bld_masks_ds) / + sizeof (msg_bld_masks_ds[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_sec[] = +{ + MSG_BUILD_MASK_MSG_SSID_SEC, + MSG_BUILD_MASK_MSG_SSID_SEC_CRYPTO, + MSG_BUILD_MASK_MSG_SSID_SEC_SSL, + MSG_BUILD_MASK_MSG_SSID_SEC_IPSEC, + MSG_BUILD_MASK_MSG_SSID_SEC_SFS, + MSG_BUILD_MASK_MSG_SSID_SEC_TEST, + MSG_BUILD_MASK_MSG_SSID_SEC_CNTAGENT, + MSG_BUILD_MASK_MSG_SSID_SEC_RIGHTSMGR, + MSG_BUILD_MASK_MSG_SSID_SEC_ROAP, + MSG_BUILD_MASK_MSG_SSID_SEC_MEDIAMGR, + MSG_BUILD_MASK_MSG_SSID_SEC_IDSTORE, + MSG_BUILD_MASK_MSG_SSID_SEC_IXFILE, + MSG_BUILD_MASK_MSG_SSID_SEC_IXSQL, + MSG_BUILD_MASK_MSG_SSID_SEC_IXCOMMON, + MSG_BUILD_MASK_MSG_SSID_SEC_BCASTCNTAGENT, + MSG_BUILD_MASK_MSG_SSID_SEC_PLAYREADY, + MSG_BUILD_MASK_MSG_SSID_SEC_WIDEVINE, +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_sec[2][sizeof (msg_bld_masks_sec) / + sizeof (msg_bld_masks_sec[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_apps[] = +{ + MSG_BUILD_MASK_MSG_SSID_APPS, + MSG_BUILD_MASK_MSG_SSID_APPS_APPMGR, + MSG_BUILD_MASK_MSG_SSID_APPS_UI, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV, + MSG_BUILD_MASK_MSG_SSID_APPS_QVP, + MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STATISTICS, + MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VENCODER, + MSG_BUILD_MASK_MSG_SSID_APPS_QVP_MODEM, + MSG_BUILD_MASK_MSG_SSID_APPS_QVP_UI, + MSG_BUILD_MASK_MSG_SSID_APPS_QVP_STACK, + MSG_BUILD_MASK_MSG_SSID_APPS_QVP_VDECODER, + MSG_BUILD_MASK_MSG_SSID_APPS_ACM, + MSG_BUILD_MASK_MSG_SSID_APPS_HEAP_PROFILE, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_GENERAL, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEBUG, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STATISTICS, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_UI_TASK, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MP4_PLAYER, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_AUDIO_TASK, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_VIDEO_TASK, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAMING, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_MPEG4_TASK, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_FILE_OPS, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTP, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTCP, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_RTSP, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_SDP_PARSE, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_ATOM_PARSE, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_TEXT_TASK, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_DEC_DSP_IF, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_STREAM_RECORDING, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_CONFIGURATION, + MSG_BUILD_MASK_MSG_SSID_APPS_QCAMERA, + MSG_BUILD_MASK_MSG_SSID_APPS_QCAMCORDER, + MSG_BUILD_MASK_MSG_SSID_APPS_BREW, + MSG_BUILD_MASK_MSG_SSID_APPS_QDJ, + MSG_BUILD_MASK_MSG_SSID_APPS_QDTX, + MSG_BUILD_MASK_MSG_SSID_APPS_QTV_BCAST_FLO, + MSG_BUILD_MASK_MSG_SSID_APPS_MDP_GENERAL, + MSG_BUILD_MASK_MSG_SSID_APPS_PBM, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GENERAL, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_EGL, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENGL, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DIRECT3D, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_SVG, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_OPENVG, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_2D, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_QXPROFILER, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_DSP, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_GRP, + MSG_BUILD_MASK_MSG_SSID_APPS_GRAPHICS_MDP, + MSG_BUILD_MASK_MSG_SSID_APPS_CAD, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_DPL, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_FW, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SIP, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_REGMGR, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RTP, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SDP, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_VS, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_XDM, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_HOM, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_IM_ENABLER, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_IMS_CORE, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_FWAPI, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SERVICES, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_POLICYMGR, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_PRESENCE, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_QIPCALL, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SIGCOMP, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_PSVT, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_UNKNOWN, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_SETTINGS, + MSG_BUILD_MASK_MSG_SSID_OMX_COMMON, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_CD, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_IM, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_FT, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_IS, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_AUTO_CONFIG, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_RCS_COMMON, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_UT, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_XML, + MSG_BUILD_MASK_MSG_SSID_APPS_IMS_COM, + +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_apps[2][sizeof (msg_bld_masks_apps) / + sizeof (msg_bld_masks_apps[0])]; + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_adsptasks[] = +{ + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_KERNEL, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AFETASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOICEPROCTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCDECTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VOCENCTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VFETASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_VIDEOENCTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_JPEGTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPPTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY0TASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY1TASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY2TASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY3TASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPLAY4TASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_LPMTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_DIAGTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDRECTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_AUDPREPROCTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_MODMATHTASK, + MSG_BUILD_MASK_MSG_SSID_ADSPTASKS_GRAPHICSTASK, +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_adsptasks[2][sizeof (msg_bld_masks_adsptasks) / + sizeof (msg_bld_masks_adsptasks[0])]; + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_l4_linux[] = +{ + MSG_BUILD_MASK_MSG_SSID_L4LINUX_KERNEL, + MSG_BUILD_MASK_MSG_SSID_L4LINUX_KEYPAD, + MSG_BUILD_MASK_MSG_SSID_L4LINUX_APPS, + MSG_BUILD_MASK_MSG_SSID_L4LINUX_QDDAEMON, +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_l4_linux[2][sizeof (msg_bld_masks_l4_linux) / + sizeof (msg_bld_masks_l4_linux[0])]; + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_l4_iguana[] = +{ + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_IGUANASERVER, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_EFS2, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_QDMS, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_REX, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SMMS, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_FRAMEBUFFER, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_KEYPAD, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_NAMING, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SDIO, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_SERIAL, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TIMER, + MSG_BUILD_MASK_MSG_SSID_L4IGUANA_TRAMP, +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_l4_iguana[2][sizeof (msg_bld_masks_l4_iguana) / + sizeof (msg_bld_masks_l4_iguana[0])]; + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_l4_amss[] = +{ + MSG_BUILD_MASK_MSG_SSID_L4AMSS_QDIAG, + MSG_BUILD_MASK_MSG_SSID_L4AMSS_APS, +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_l4_amss[2][sizeof (msg_bld_masks_l4_amss) / + sizeof (msg_bld_masks_l4_amss[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_hit[] = +{ + MSG_BUILD_MASK_MSG_SSID_HIT +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_hit[2][sizeof (msg_bld_masks_hit) / + sizeof (msg_bld_masks_hit[0])]; + + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_qdsp6[] = +{ + MSG_BUILD_MASK_MSG_SSID_QDSP6, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_SVC, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_ENCDEC, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VOC, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_VS, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MIDI, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_POSTPROC, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_PREPROC, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_AFE, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_MSESSION, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DSESSION, + MSG_BUILD_MASK_MSG_SSID_ADSP_AUD_DCM, + MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENC, + MSG_BUILD_MASK_MSG_SSID_ADSP_VID_ENCRPC, + MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DEC, + MSG_BUILD_MASK_MSG_SSID_ADSP_VID_DECRPC, + MSG_BUILD_MASK_MSG_SSID_ADSP_VID_COMMONSW, + MSG_BUILD_MASK_MSG_SSID_ADSP_VID_HWDRIVER, + MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_ENC, + MSG_BUILD_MASK_MSG_SSID_ADSP_JPG_DEC, + MSG_BUILD_MASK_MSG_SSID_ADSP_OMM, + MSG_BUILD_MASK_MSG_SSID_ADSP_PWRDEM, + MSG_BUILD_MASK_MSG_SSID_ADSP_RESMGR, + MSG_BUILD_MASK_MSG_SSID_ADSP_CORE, + MSG_BUILD_MASK_MSG_SSID_ADSP_RDA, + MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_TAFE_HAL, + MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_ALGORITHM, + MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_FRAMEWORK, + MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_SRE, + MSG_BUILD_MASK_MSG_SSID_DSP_TOUCH_TAFE_DRIVER, +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_qdsp6[2][sizeof (msg_bld_masks_qdsp6) / + sizeof (msg_bld_masks_qdsp6[0])]; + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_umb[] = +{ + MSG_BUILD_MASK_MSG_SSID_UMB, + MSG_BUILD_MASK_MSG_SSID_UMB_APP, + MSG_BUILD_MASK_MSG_SSID_UMB_DS, + MSG_BUILD_MASK_MSG_SSID_UMB_CP, + MSG_BUILD_MASK_MSG_SSID_UMB_RLL, + MSG_BUILD_MASK_MSG_SSID_UMB_MAC, + MSG_BUILD_MASK_MSG_SSID_UMB_SRCH, + MSG_BUILD_MASK_MSG_SSID_UMB_FW, + MSG_BUILD_MASK_MSG_SSID_UMB_PLT, +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_umb[2][sizeof (msg_bld_masks_umb) / + sizeof (msg_bld_masks_umb[0])]; + +/* This table must be maintained as SSIDs are added! */ +static const uint32 msg_bld_masks_lte[] = +{ + MSG_BUILD_MASK_MSG_SSID_LTE, + MSG_BUILD_MASK_MSG_SSID_LTE_RRC, + MSG_BUILD_MASK_MSG_SSID_LTE_MACUL, + MSG_BUILD_MASK_MSG_SSID_LTE_MACDL, + MSG_BUILD_MASK_MSG_SSID_LTE_MACCTRL, + MSG_BUILD_MASK_MSG_SSID_LTE_RLCUL, + MSG_BUILD_MASK_MSG_SSID_LTE_RLCDL, + MSG_BUILD_MASK_MSG_SSID_LTE_PDCPUL, + MSG_BUILD_MASK_MSG_SSID_LTE_PDCPDL, + MSG_BUILD_MASK_MSG_SSID_LTE_ML1, + MSG_BUILD_MASK_MSG_SSID_LTE_DISCOVERY +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_lte[2][sizeof (msg_bld_masks_lte) / + sizeof (msg_bld_masks_lte[0])]; + +static const uint32 msg_bld_masks_qchat[] = +{ + MSG_BUILD_MASK_MSG_SSID_QCHAT, + MSG_BUILD_MASK_MSG_SSID_QCHAT_CAPP, + MSG_BUILD_MASK_MSG_SSID_QCHAT_CENG, + MSG_BUILD_MASK_MSG_SSID_QCHAT_CREG, + MSG_BUILD_MASK_MSG_SSID_QCHAT_CMED, + MSG_BUILD_MASK_MSG_SSID_QCHAT_CAUTH, + MSG_BUILD_MASK_MSG_SSID_QCHAT_QBAL, + MSG_BUILD_MASK_MSG_SSID_QCHAT_OSAL, + MSG_BUILD_MASK_MSG_SSID_QCHAT_OEMCUST, + MSG_BUILD_MASK_MSG_SSID_QCHAT_MULTI_PROC, + MSG_BUILD_MASK_MSG_SSID_QCHAT_UPK +}; + +/* To will be initialized by msg_init() */ +static uint32 msg_rt_masks_qchat[2][sizeof (msg_bld_masks_qchat) / + sizeof (msg_bld_masks_qchat[0])]; + +static const uint32 msg_bld_masks_tdscdma[] = +{ + MSG_BUILD_MASK_MSG_SSID_TDSCDMA_L1, + MSG_BUILD_MASK_MSG_SSID_TDSCDMA_L2, + MSG_BUILD_MASK_MSG_SSID_TDSCDMA_MAC, + MSG_BUILD_MASK_MSG_SSID_TDSCDMA_RLC, + MSG_BUILD_MASK_MSG_SSID_TDSCDMA_RRC +}; + +static uint32 msg_rt_masks_tdscdma[2][sizeof (msg_bld_masks_tdscdma) / + sizeof (msg_bld_masks_tdscdma[0])]; + +static const uint32 msg_bld_masks_cta[] = +{ + MSG_BUILD_MASK_MSG_SSID_CTA +}; + +static uint32 msg_rt_masks_cta[2][sizeof(msg_bld_masks_cta) / + sizeof(msg_bld_masks_cta[0])]; + +static const uint32 msg_bld_masks_qcnea[] = +{ + MSG_BUILD_MASK_MSG_SSID_QCNEA, + MSG_BUILD_MASK_MSG_SSID_QCNEA_CAC, + MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE, + MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_CAS, + MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_CDE, + MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_COM, + MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_LEE, + MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_QMI, + MSG_BUILD_MASK_MSG_SSID_QCNEA_CORE_SRM, + MSG_BUILD_MASK_MSG_SSID_QCNEA_GENERIC, + MSG_BUILD_MASK_MSG_SSID_QCNEA_NETLINK, + MSG_BUILD_MASK_MSG_SSID_QCNEA_NIMS, + MSG_BUILD_MASK_MSG_SSID_QCNEA_NSRM, + MSG_BUILD_MASK_MSG_SSID_QCNEA_NSRM_CORE, + MSG_BUILD_MASK_MSG_SSID_QCNEA_NSRM_GATESM, + MSG_BUILD_MASK_MSG_SSID_QCNEA_NSRM_TRG, + MSG_BUILD_MASK_MSG_SSID_QCNEA_PLCY, + MSG_BUILD_MASK_MSG_SSID_QCNEA_PLCY_ANDSF, + MSG_BUILD_MASK_MSG_SSID_QCNEA_TEST, + MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE, + MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_BQE, + MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_CQE, + MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_ICD, + MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_IFSEL, + MSG_BUILD_MASK_MSG_SSID_QCNEA_WQE_IFSELRSM, + MSG_BUILD_MASK_MSG_SSID_QCNEA_ATP, + MSG_BUILD_MASK_MSG_SSID_QCNEA_ATP_PLCY, + MSG_BUILD_MASK_MSG_SSID_QCNEA_ATP_RPRT +}; + +static uint32 msg_rt_masks_qcnea[2][sizeof(msg_bld_masks_qcnea) / + sizeof(msg_bld_masks_qcnea[0])]; + +static const uint32 msg_bld_masks_dpm[] = +{ + MSG_BUILD_MASK_MSG_SSID_DPM, + MSG_BUILD_MASK_MSG_SSID_DPM_COMMON, + MSG_BUILD_MASK_MSG_SSID_DPM_COM, + MSG_BUILD_MASK_MSG_SSID_DPM_QMI, + MSG_BUILD_MASK_MSG_SSID_DPM_DSM, + MSG_BUILD_MASK_MSG_SSID_DPM_CONFIG, + MSG_BUILD_MASK_MSG_SSID_DPM_GENERIC, + MSG_BUILD_MASK_MSG_SSID_DPM_NETLINK, + MSG_BUILD_MASK_MSG_SSID_DPM_FD_MGR, + MSG_BUILD_MASK_MSG_SSID_DPM_CT_MGR, + MSG_BUILD_MASK_MSG_SSID_DPM_NSRM, + MSG_BUILD_MASK_MSG_SSID_DPM_NSRM_CORE, + MSG_BUILD_MASK_MSG_SSID_DPM_NSRM_GATESM, + MSG_BUILD_MASK_MSG_SSID_DPM_NSRM_TRG, + MSG_BUILD_MASK_MSG_SSID_DPM_TEST, + MSG_BUILD_MASK_MSG_SSID_DPM_TCM +}; +static uint32 msg_rt_masks_dpm[2][sizeof(msg_bld_masks_dpm) / + sizeof(msg_bld_masks_dpm[0])]; +/*----------!!!! Important Note: !!!!!!!--------*/ +/* MSG_MASK_TBL_CNT needs to be updated manually, +when we add a new RANGE of SSIDs to msg_mask_tbl */ +const msg_mask_tbl_type msg_mask_tbl[] = { + + { + MSG_SSID_GEN_FIRST, + /* FIRST + array count */ + MSG_SSID_GEN_FIRST + + sizeof (msg_bld_masks_gen) / sizeof (msg_bld_masks_gen[0]) - 1, + msg_bld_masks_gen, + (uint32*)msg_rt_masks_gen + } + + , + { + MSG_SSID_ONCRPC, + /* FIRST + array count */ + MSG_SSID_ONCRPC + + sizeof (msg_bld_masks_oncrpc) / sizeof (msg_bld_masks_oncrpc[0]) - 1, + msg_bld_masks_oncrpc, +(uint32*) msg_rt_masks_oncrpc + } + + , + { + MSG_SSID_1X, + /* FIRST + array count */ + MSG_SSID_1X + + sizeof (msg_bld_masks_1X) / sizeof (msg_bld_masks_1X[0]) - 1, + msg_bld_masks_1X, + (uint32*)msg_rt_masks_1X + } + + , + { + MSG_SSID_HDR_PROT, + /* FIRST + array count */ + MSG_SSID_HDR_PROT+ + sizeof (msg_bld_masks_hdr) / sizeof (msg_bld_masks_hdr[0]) - 1, + msg_bld_masks_hdr, +(uint32*)msg_rt_masks_hdr + } + + , + { + MSG_SSID_UMTS, + /* FIRST + array count */ + MSG_SSID_UMTS + + sizeof (msg_bld_masks_umts) / sizeof (msg_bld_masks_umts[0]) - 1, + msg_bld_masks_umts, +(uint32*)msg_rt_masks_umts + } + + , + { + MSG_SSID_GSM, + /* FIRST + array count */ + MSG_SSID_GSM + + sizeof (msg_bld_masks_gsm) / sizeof (msg_bld_masks_gsm[0]) - 1, + msg_bld_masks_gsm, +(uint32*)msg_rt_masks_gsm + } + + , + { + MSG_SSID_WLAN, + /* FIRST + array count */ + MSG_SSID_WLAN + + sizeof (msg_bld_masks_wlan) / sizeof (msg_bld_masks_wlan[0]) - 1, + msg_bld_masks_wlan, +(uint32*)msg_rt_masks_wlan + } + + , + { + MSG_SSID_ATS, + /* FIRST + array count */ + MSG_SSID_ATS + + sizeof (msg_bld_masks_mcs) / sizeof (msg_bld_masks_mcs[0]) - 1, + msg_bld_masks_mcs, +(uint32*) msg_rt_masks_mcs + } + + , + { + MSG_SSID_DS, + /* FIRST + array count */ + MSG_SSID_DS + + sizeof (msg_bld_masks_ds) / sizeof (msg_bld_masks_ds[0]) - 1, + msg_bld_masks_ds, +(uint32*)msg_rt_masks_ds + } + + , + { + MSG_SSID_SEC, + /* FIRST + array count */ + MSG_SSID_SEC + + sizeof (msg_bld_masks_sec) / sizeof (msg_bld_masks_sec[0]) - 1, + msg_bld_masks_sec, +(uint32*)msg_rt_masks_sec + } + + , + { + MSG_SSID_APPS, + /* FIRST + array count */ + MSG_SSID_APPS + + sizeof (msg_bld_masks_apps) / sizeof (msg_bld_masks_apps[0]) - 1, + msg_bld_masks_apps, +(uint32*)msg_rt_masks_apps + } + + , + { + + MSG_SSID_ADSPTASKS, + /* FIRST + array count */ + MSG_SSID_ADSPTASKS + + sizeof (msg_bld_masks_adsptasks) / sizeof (msg_bld_masks_adsptasks[0]) - 1, + msg_bld_masks_adsptasks, +(uint32*)msg_rt_masks_adsptasks + } + + , + { + MSG_SSID_L4LINUX_KERNEL, + /* FIRST + array count */ + MSG_SSID_L4LINUX_KERNEL + + sizeof (msg_bld_masks_l4_linux) / sizeof (msg_bld_masks_l4_linux[0]) - 1, + msg_bld_masks_l4_linux, +(uint32*)msg_rt_masks_l4_linux + } + + , + { + MSG_SSID_L4IGUANA_IGUANASERVER, + /* FIRST + array count */ + MSG_SSID_L4IGUANA_IGUANASERVER + + sizeof (msg_bld_masks_l4_iguana) / sizeof (msg_bld_masks_l4_iguana[0]) - 1, + msg_bld_masks_l4_iguana, +(uint32*)msg_rt_masks_l4_iguana + } + + , + { + MSG_SSID_L4AMSS_QDIAG, + /* FIRST + array count */ + MSG_SSID_L4AMSS_QDIAG + + sizeof (msg_bld_masks_l4_amss) / sizeof (msg_bld_masks_l4_amss[0]) - 1, + msg_bld_masks_l4_amss, +(uint32*)msg_rt_masks_l4_amss + } + + , + { + MSG_SSID_HIT, + /* FIRST + array count */ + MSG_SSID_HIT+ + sizeof (msg_bld_masks_hit) / sizeof (msg_bld_masks_hit[0]) - 1, + msg_bld_masks_hit, +(uint32*) msg_rt_masks_hit + } + + , + { + MSG_SSID_QDSP6, + /* FIRST + array count */ + MSG_SSID_QDSP6+ + sizeof (msg_bld_masks_qdsp6) / sizeof (msg_bld_masks_qdsp6[0]) - 1, + msg_bld_masks_qdsp6, +(uint32*)msg_rt_masks_qdsp6 + } + + , + { + MSG_SSID_UMB, + /* FIRST + array count */ + MSG_SSID_UMB+ + sizeof (msg_bld_masks_umb) / sizeof (msg_bld_masks_umb[0]) - 1, + msg_bld_masks_umb, +(uint32*)msg_rt_masks_umb + } + + , + { + MSG_SSID_LTE, + /* FIRST + array count */ + MSG_SSID_LTE+ + sizeof (msg_bld_masks_lte) / sizeof (msg_bld_masks_lte[0]) - 1, + msg_bld_masks_lte, +(uint32*)msg_rt_masks_lte + } + + , + { + MSG_SSID_QCHAT, + /* FIRST + array count */ + MSG_SSID_QCHAT+ + sizeof (msg_bld_masks_qchat) / sizeof(msg_bld_masks_qchat[0]) - 1, + msg_bld_masks_qchat, +(uint32*)msg_rt_masks_qchat + } + + , + { + MSG_SSID_TDSCDMA_L1, + /* FIRST + array count */ + MSG_SSID_TDSCDMA_L1+ + sizeof (msg_bld_masks_tdscdma) / sizeof(msg_bld_masks_tdscdma[0]) - 1, + msg_bld_masks_tdscdma, +(uint32*)msg_rt_masks_tdscdma + } + + , + { + MSG_SSID_CTA, + MSG_SSID_CTA+ + sizeof(msg_bld_masks_cta) / sizeof(msg_bld_masks_cta[0]) - 1, + msg_bld_masks_cta, +(uint32*)msg_rt_masks_cta + } + , + { + MSG_SSID_QCNEA, + MSG_SSID_QCNEA+ + sizeof(msg_bld_masks_qcnea) / sizeof(msg_bld_masks_qcnea[0]) - 1, + msg_bld_masks_qcnea, +(uint32*)msg_rt_masks_qcnea + } + , + { + MSG_SSID_DPM, + MSG_SSID_DPM+ + sizeof(msg_bld_masks_dpm) / sizeof(msg_bld_masks_dpm[0]) - 1, + msg_bld_masks_dpm, +(uint32*)msg_rt_masks_dpm + } +}; + +const uint32 msg_mask_tbl_size = (sizeof (msg_mask_tbl) / sizeof (msg_mask_tbl[0])) ; diff --git a/feeds/wifi-ax/qca-diag/src/src/ts_linux.c b/feeds/wifi-ax/qca-diag/src/src/ts_linux.c new file mode 100755 index 000000000..ca32aa391 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/ts_linux.c @@ -0,0 +1,201 @@ + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Diag Legacy Service Mapping DLL + +GENERAL DESCRIPTION + +Implementation of entry point and Initialization functions for Diag_LSM.dll. + + +EXTERNALIZED FUNCTIONS +DllMain +Diag_LSM_Init +Diag_LSM_DeInit + +INITIALIZATION AND SEQUENCING REQUIREMENTS + + +# Copyright (c) 2007-2011, 2015-2018 by Qualcomm Technologies, Inc. +# All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Created + +===========================================================================*/ + +#include "ts_linux.h" +#include "string.h" +#include "errno.h" +#include +#include +#include +#include +#include "diag_lsm.h" + +#define TIME_CONV_SCLK_CX32_DIVIDEND 256 +#define TIME_CONV_SCLK_CX32_DIVISOR 125 +#define TIME_CONV_CX32_PER_1p25MS 0xC000 + +#define TIME_SYNC_PARAM "/sys/module/diagchar/parameters/timestamp_switch" +extern unsigned long long time_get_from_timetick(); + +unsigned long long time_get_from_timetick(void) +{ + unsigned long long seconds = 0, ticks_qt = 0; + unsigned long long cx32 = 0, cx32_xos = 0, xos = 0, timestamp = 0, + ticks_1_25ms = 0; + +#if defined __aarch64__ && __aarch64__ == 1 + asm volatile("mrs %0, cntvct_el0" : "=r" (ticks_qt)); +#else + asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (ticks_qt)); + +#endif + xos = ticks_qt; + cx32_xos = ((xos * TIME_CONV_SCLK_CX32_DIVIDEND) / + (TIME_CONV_SCLK_CX32_DIVISOR)); + /* Add the number of 1.25ms units to the timestamp */ + cx32 += cx32_xos; + ticks_1_25ms = cx32/TIME_CONV_CX32_PER_1p25MS; + timestamp += (ticks_1_25ms << 16); + /* + * Determine the remaining cx32s that we didn't add to the timestamp's + * upper part + */ + cx32 -= (ticks_1_25ms * TIME_CONV_CX32_PER_1p25MS); + /* Attach the cx32 back to end of the timestamp */ + timestamp |= cx32&0xffffULL; + seconds = timestamp; + return seconds; +} + + +static unsigned long long get_time_of_day() +{ + struct timeval tv; + unsigned long long seconds, microseconds; + gettimeofday(&tv, NULL); + seconds = (unsigned long long)tv.tv_sec; + /* Offset to sync timestamps between Modem & Apps Proc. + Number of seconds between Jan 1, 1970 & Jan 6, 1980 */ + seconds = seconds - (10*365+5+2)*24*60*60 ; + seconds = seconds * 1000; + microseconds = (unsigned long long)tv.tv_usec; + microseconds = microseconds/1000; + seconds = seconds + microseconds; + seconds = seconds*4; + seconds = seconds/5; + seconds = seconds << 16; + return seconds; +} + +/*=========================================================================== + +FUNCTION ts_get + +DESCRIPTION + This extracts time from the system and feeds the pointer passed in. + +DEPENDENCIES + None. + +RETURN VALUE + none + +SIDE EFFECTS + None + +===========================================================================*/ + +void ts_get (void *timestamp) +{ + char *temp1; + char *temp2; + unsigned long long seconds; + int i, fd_param = -1, ret, time_stamp_switch = 0; + int time_sync_param[1]; + long long int qtimer_secs; + time_sync_param[0] = 0; + + fd_param = open(TIME_SYNC_PARAM, O_RDONLY); + if (fd_param < 0) { + DIAG_LOGE("ts_get: could not open file: %s\n", strerror(errno)); + goto default_ts; + } + ret = read(fd_param, time_sync_param, 1); + if (ret < 0) { + DIAG_LOGE("ts_get: Unable to read file: %s\n", strerror(errno)); + close(fd_param); + goto default_ts; + } + close(fd_param); + time_stamp_switch = time_sync_param[0] - '0'; + switch (time_stamp_switch) { + case 0: + default: + seconds = get_time_of_day(); + break; + case 1: + seconds = time_get_from_timetick(); + break; + } + temp1 = (char *) (timestamp); + temp2 = (char *) &(seconds); + /* + * This is assuming that you have 8 consecutive + * bytes to store the data. + */ + for (i=0;i<8;i++) + *(temp1+i) = *(temp2+i); + return; +default_ts: + seconds = get_time_of_day(); + temp1 = (char *) (timestamp); + temp2 = (char *) &(seconds); + /* + * This is assuming that you have 8 consecutive + * bytes to store the data. + */ + for (i=0;i<8;i++) + *(temp1+i) = *(temp2+i); + return; +} /* ts_get */ + +/*=========================================================================== +FUNCTION ts_get_lohi + +DESCRIPTION + Extracts timestamp from system and places into lo and hi parameters + +DEPENDENCIES + None + +RETURN VALUE + + +SIDE EFFECTS + None + +===========================================================================*/ +void ts_get_lohi(uint32 *ts_lo, uint32 *ts_hi) +{ + char buf[8]; + + ts_get(buf); + *ts_lo = *(uint32 *)&buf[0]; + *ts_hi = *(uint32 *)&buf[4]; + + return; +} + diff --git a/feeds/wifi-ax/qca-diag/src/src/ts_linux.h b/feeds/wifi-ax/qca-diag/src/src/ts_linux.h new file mode 100755 index 000000000..c69fc9146 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/src/ts_linux.h @@ -0,0 +1,66 @@ +#ifndef TS_LINUX_H +#define TS_LINUX_H + +/*=========================================================================== + + Internal header file for timestamp + +DESCRIPTION + API to extract timestamp from system. Used only for Linux + + +# Copyright (c) 2007-2011 by Qualcomm Technologies, Inc. All Rights Reserved. +# Qualcomm Technologies Proprietary and Confidential. +===========================================================================*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/03/08 SJ Created File +===========================================================================*/ +#include "comdef.h" +/*=========================================================================== +FUNCTION ts_get + +DESCRIPTION + Extracts timestamp from system + +DEPENDENCIES + None + +RETURN VALUE + + +SIDE EFFECTS + None + +===========================================================================*/ + void ts_get (void *timestamp); + +/*=========================================================================== +FUNCTION ts_get_lohi + +DESCRIPTION + Extracts timestamp from system and places into lo and hi parameters + +DEPENDENCIES + None + +RETURN VALUE + + +SIDE EFFECTS + None + +===========================================================================*/ + void ts_get_lohi(uint32 *ts_lo, uint32 *ts_hi); + + #endif /* TS_LINUX_H */ diff --git a/feeds/wifi-ax/qca-diag/src/test/Android.mk b/feeds/wifi-ax/qca-diag/src/test/Android.mk new file mode 100755 index 000000000..8c786aad8 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/test/Android.mk @@ -0,0 +1,28 @@ +################################################################################ +# @file pkgs/stringl/Android.mk +# @brief Makefile for building the string library on Android. +################################################################################ + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +libdiag_includes:= \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../src \ + +LOCAL_C_INCLUDES:= $(libdiag_includes) +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc + +LOCAL_SRC_FILES:= \ + test_diag.c \ + +commonSharedLibraries :=libdiag \ + +LOCAL_MODULE:= test_diag +LOCAL_MODULE_TAGS := optional debug +LOCAL_SHARED_LIBRARIES := $(commonSharedLibraries) + +LOCAL_MODULE_OWNER := qcom +include $(BUILD_EXECUTABLE) + diff --git a/feeds/wifi-ax/qca-diag/src/test/Makefile.am b/feeds/wifi-ax/qca-diag/src/test/Makefile.am new file mode 100755 index 000000000..7bbf72e9d --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/test/Makefile.am @@ -0,0 +1,22 @@ + +AM_CFLAGS = -Wall \ + -Wundef \ + -Wstrict-prototypes \ + -Wno-trigraphs + +AM_CPPFLAGS = -D__packed__= \ + -DIMAGE_APPS_PROC \ + -DFEATURE_Q_SINGLE_LINK \ + -DFEATURE_Q_NO_SELF_QPTR \ + -DFEATURE_LINUX \ + -DFEATURE_NATIVELINUX \ + -DFEATURE_DSM_DUP_ITEMS \ + -DFEATURE_LE_DIAG \ + -I../src \ + -I../include + +bin_PROGRAMS = test_diag + +test_diag_SOURCES = test_diag.c +test_diag_LDFLAGS = -lpthread +test_diag_LDADD = ../src/libdiag.la diff --git a/feeds/wifi-ax/qca-diag/src/test/test_diag.c b/feeds/wifi-ax/qca-diag/src/test/test_diag.c new file mode 100755 index 000000000..20c862d2c --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/test/test_diag.c @@ -0,0 +1,551 @@ +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* +Copyright (c) 2007-2015, 2016 by Qualcomm Technologies, Inc. All Rights Reserved. +Qualcomm Technologies Proprietary and Confidential. + + + Test Application for Diag Interface + +GENERAL DESCRIPTION + Contains main implementation of Diagnostic Services Test Application. + +EXTERNALIZED FUNCTIONS + None + +INITIALIZATION AND SEQUENCING REQUIREMENTS + + +Copyright (c) 2007-2015, 2016 Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +10/01/08 SJ Changes for CBSP2.0 +03/26/08 JV Added calls to test packet request/response +12/2/07 jv Added test calls for log APIs +11/19/07 mad Created +===========================================================================*/ + +#include +#include +#include +#include +#include +#include "errno.h" +#include "event.h" +#include "msg.h" +#include "log.h" +#include "diagpkt.h" +#include "diagcmd.h" +#include "diagdiag.h" +#include "diag_lsm.h" +#include "../src/ts_linux.h" +#include + +#define DIAG_CMD_APPS_LOOPBACK_TEST 0x0028 +#define DIAG_CMD_APPS_STRESS_TEST 0x0006 +#define DIAG_CMD_APPS_DELAYED_RSP_TEST 0x0215 + +#define TIMESTAMP_LEN 8 + +#define DIAG_DELAYED_RSP_CNT_BASE 0x8000 +#define DIAG_DELAYED_RSP_CNT_MAX 0xFFF + +#define MAX_NUM_TASKS 50 + +#define PRECISION 1000000 +#define INT_PART(a) (int)a +#define DEC_PART(a) ((a - (int)a) * PRECISION) + +typedef PACK(struct) { + log_hdr_type hdr; + int iteration; + int task_priority; + int req_iterations; + uint32 payload[125]; +} diag_stress_test_log_t; + +typedef PACK(struct) { + int iteration; + int task_priority; + int req_iterations; +} diag_stress_test_event_t; + +typedef PACK(struct) { + uint8 test_type; + uint8 priority_type; + uint16 priority; + uint32 num_iterations; + uint32 sleep_time; + uint32 iterations_sleep; +} diag_stress_test_task_info; + +typedef PACK(struct) { + uint8 cmd_code; + uint8 subsys_cmd_code; + uint16 subsys_id; + uint32 num_tasks; +} diag_stress_test_req_t; + +typedef struct { + uint8 active; + pthread_t thread_hdl; + diag_stress_test_task_info task_info; +} diag_stress_test_hdl_t; + +typedef PACK(struct) { + uint8 cmd_code; + uint8 subsys_id; + uint16 subsys_cmd_code; + uint16 count; +} diag_delayed_test_req_t; + +typedef PACK(struct) { + uint8 command_code; + uint8 subsys_id; + uint16 subsys_cmd_code; + uint32 status; + uint16 delayed_rsp_id; + uint16 rsp_cnt; +} diagpkt_subsys_hdr_type_v2; + +typedef PACK(struct) { + diagpkt_subsys_hdr_type_v2 hdr; + char my_rsp[20]; +} diag_delayed_test_rsp_t; + +typedef PACK(struct) { + diagpkt_subsys_header_type hdr; + unsigned long timestamp; +} diag_loopback_rsp_t; + +static uint8 verbose; +static int max_num_tasks; +static diag_stress_test_hdl_t *test_info; +static pthread_mutex_t test_hdl_lock; + +static diag_stress_test_hdl_t *diag_stress_test_get_hdl() +{ + int i; + diag_stress_test_hdl_t *test_hdl = NULL; + + pthread_mutex_lock(&test_hdl_lock); + for (i = 0; i < max_num_tasks; i++) { + if (test_info[i].active) + continue; + test_info[i].active = 1; + test_hdl = &test_info[i]; + break; + } + pthread_mutex_unlock(&test_hdl_lock); + + return test_hdl; +} + +static void *diag_stress_test_thread(void* param) +{ + diag_stress_test_hdl_t *test_hdl = NULL; + diag_stress_test_task_info *task_info = NULL; + diag_stress_test_log_t *log = NULL; + diag_stress_test_event_t event_payload; + int i; + uint32 payload_stress_test_complete = 0; + + if (!param) { + printf("test_diag: Invalid params in %s\n", __func__); + return 0; + } + + test_hdl = (diag_stress_test_hdl_t *)param; + task_info = &test_hdl->task_info; + + for (i = 1; i <= (int)task_info->num_iterations; i++) { + if (task_info->iterations_sleep > 0 && (i % task_info->iterations_sleep == 0)) + sleep(task_info->sleep_time * 0.001); + + switch (task_info->test_type) { + case DIAGDIAG_STRESS_TEST_MSG: + MSG(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "Test MSG with no arg\n"); + break; + case DIAGDIAG_STRESS_TEST_MSG_1: + MSG_1(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_1 Iter %d\n", i); + break; + case DIAGDIAG_STRESS_TEST_MSG_2: + MSG_2(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_2 Iter %d uid %d\n", i, 1); + break; + case DIAGDIAG_STRESS_TEST_MSG_3: + MSG_3(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_3 Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_MSG_4: + MSG_4(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_4 Iter %d uid %d num_iter %d procid %d\n", i, 1, 2, 3); + break; + case DIAGDIAG_STRESS_TEST_MSG_5: + MSG_5(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_5 Iter %d uid %d num_iter %d procid %d %d\n", i, 1, 2, 3, 4); + break; + case DIAGDIAG_STRESS_TEST_MSG_6: + MSG_6(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_6 Iter %d uid %d num_iter %d procid %d %d %d\n", i, 1, 2, 3, 4, 5); + break; + case DIAGDIAG_STRESS_TEST_MSG_LOW: + MSG_LOW("MSG_LOW Iter %d uid %d num_iter %d \n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_MSG_MED: + MSG_MED("MSG_MED Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_MSG_HIGH: + MSG_HIGH("MSG_HIGH Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_MSG_ERROR: + MSG_ERROR("MSG_ERROR Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_MSG_FATAL: + MSG_FATAL("MSG_FATAL Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_LOG: + log = (diag_stress_test_log_t *)log_alloc(LOG_DIAG_STRESS_TEST_C, + sizeof(diag_stress_test_log_t)); + if (log) { + log->iteration = i; + log->req_iterations = task_info->num_iterations; + log_commit(log); + } + break; + case DIAGDIAG_STRESS_TEST_EVENT_NO_PAYLOAD: + event_report(EVENT_DIAG_STRESS_TEST_NO_PAYLOAD); + break; + case DIAGDIAG_STRESS_TEST_EVENT_WITH_PAYLOAD: + event_payload.iteration = i; + event_payload.req_iterations = task_info->num_iterations; + event_report_payload(EVENT_DIAG_STRESS_TEST_WITH_PAYLOAD, sizeof(event_payload), &event_payload); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG: + QSR_MSG(300000001, MSG_SSID_DIAG, MSG_LEGACY_HIGH, "Test QSR_MSG with no arg\n"); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_1: + QSR_MSG_1(300000002, MSG_SSID_DIAG, MSG_LEGACY_HIGH, "Test QSR_MSG_1 Iter %d\n", i); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_2: + QSR_MSG_2(300000003, MSG_SSID_DIAG, MSG_LEGACY_HIGH, "Test QSR_MSG_2 Iter %d uid %d\n", i, 1); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_3: + QSR_MSG_3(300000004, MSG_SSID_DIAG, MSG_LEGACY_HIGH, "Test QSR_MSG_3 Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_4: + QSR_MSG_4(300000005, MSG_SSID_DIAG, MSG_LEGACY_HIGH, "Test QSR_MSG_4 Iter %d uid %d num_iter %d procid %d\n", i, 1, 2, 3); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_5: + QSR_MSG_5(300000006, MSG_SSID_DIAG, MSG_LEGACY_HIGH, "Test QSR_MSG_5 Iter %d uid %d num_iter %d procid %d %d\n", i, 1, 2, 3, 4); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_6: + QSR_MSG_6(300000007, MSG_SSID_DIAG, MSG_LEGACY_HIGH, "Test QSR_MSG_6 Iter %d uid %d num_iter %d procid %d %d %d\n", i, 1, 2, 3, 4, 5); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_LOW: + QSR_MSG_LOW(300000008, "Test QSR_MSG_LOW Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_MED: + QSR_MSG_MED(300000009, "Test QSR_MSG_MED Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_HIGH: + QSR_MSG_HIGH(300000011, "Test QSR_MSG_HIGH Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_ERROR: + QSR_MSG_ERROR(300000012, "Test QSR_MSG_ERROR Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_QSR_MSG_FATAL: + QSR_MSG_FATAL(300000013, "Test QSR_MSG_FATAL Iter %d uid %d num_iter %d\n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_MSG_SPRINTF_1: + MSG_SPRINTF_1(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_SPRINTF_1 Iter %d\n", i); + break; + case DIAGDIAG_STRESS_TEST_MSG_SPRINTF_2: + MSG_SPRINTF_2(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_SPRINTF_2 Iter %d uid %d\n", i, 1); + break; + case DIAGDIAG_STRESS_TEST_MSG_SPRINTF_3: + MSG_SPRINTF_3(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_SPRINTF_3 Iter %d uid %d num_iter %d \n", i, 1, 2); + break; + case DIAGDIAG_STRESS_TEST_MSG_SPRINTF_4: + MSG_SPRINTF_4(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_SPRINTF_4 Iter %d uid %d num_iter %d %d \n", i, 1, 2, 3); + break; + case DIAGDIAG_STRESS_TEST_MSG_SPRINTF_5: + MSG_SPRINTF_5(MSG_SSID_DIAG, MSG_LEGACY_HIGH, "MSG_SPRINTF_5 Iter %d uid %d num_iter %d %d.%d \n", i, 1, 2, INT_PART(1.234), DEC_PART(1.234)); + break; + } + } + printf("\n"); + sleep(1); + event_report_payload(EVENT_DIAG_STRESS_TEST_COMPLETED, sizeof(uint32), &payload_stress_test_complete); + test_hdl->active = 0; + return 0; +} + +static void *diagdiag_apps_stress_test(void *req_pkt, uint16 pkt_len) +{ + void *rsp = NULL; + int i; + uint8 *request = (uint8 *)req_pkt; + diag_stress_test_req_t *test_info = NULL; + diag_stress_test_task_info *task_info = NULL; + diag_stress_test_hdl_t *test_hdl = NULL; + + test_info = (diag_stress_test_req_t *)(request); + request += sizeof(diag_stress_test_req_t); + + printf("test_diag: Received a stress test command for %d tests\n", (int)test_info->num_tasks); + + for (i = 1; i <= (int)test_info->num_tasks; i++) { + task_info = (diag_stress_test_task_info *)request; + test_hdl = diag_stress_test_get_hdl(); + if (!test_hdl) { + printf("test_diag: Unable to get test handle, i: %d. Try after sometime\n", i); + goto err_rsp; + } + memcpy(&test_hdl->task_info, task_info, sizeof(diag_stress_test_task_info)); + pthread_create(&test_hdl->thread_hdl, NULL, diag_stress_test_thread, test_hdl); + if (test_hdl->thread_hdl == 0) { + printf("test_diag: Unable to create thread handle, i: %d\n", i); + test_hdl->active = 0; + goto err_rsp; + } else { + test_hdl->active = 1; + } + + if (verbose) { + printf(" Task No: %d\n", i); + printf(" Test type: %d\n", (int)task_info->test_type); + printf(" Priority type: %d\n", (int)task_info->priority_type); + printf(" Priority: %d\n", (int)task_info->priority); + printf(" Number of iterations: %d\n", (int)task_info->num_iterations); + printf(" Sleep Duration: %d\n", (int)task_info->sleep_time); + printf(" Iteration before sleep: %d\n", (int)task_info->iterations_sleep); + } + request += sizeof(diag_stress_test_task_info); + } + + rsp = diagpkt_subsys_alloc(DIAG_SUBSYS_DIAG_SERV, DIAG_CMD_APPS_STRESS_TEST, pkt_len); + if (rsp != NULL) { + printf("test_diag: Allocated a response of size: %d\n", pkt_len); + memcpy ((void *)rsp, (void *)req_pkt, pkt_len); + } + + printf("\n"); + return rsp; + +err_rsp: + return diagpkt_err_rsp(DIAG_SUBSYS_CMD_F, req_pkt, pkt_len); +} + +static void *diagdiag_loopback_test(void *req_pkt, uint16 pkt_len) +{ + uint16 actual_len = pkt_len + TIMESTAMP_LEN + 1; + unsigned char *rsp = NULL; + unsigned char *req = (unsigned char *)req_pkt; + uint16 write_len = 0; + uint16 read_len = 0; + + if (!req_pkt || pkt_len == 0) { + printf("test_diag: In %s, invalid pointer %p or length: %d\n", + __func__, req_pkt, pkt_len); + return NULL; + } + + printf("test_diag: Received a loopback request of size: %d\n", pkt_len); + rsp = (unsigned char *)diagpkt_subsys_alloc(DIAG_SUBSYS_DIAG_SERV, + DIAG_CMD_APPS_LOOPBACK_TEST, + actual_len); + if (rsp != NULL) { + printf("test_diag: Allocated a response of size: %d\n", actual_len); + memcpy(rsp, req, sizeof(diagpkt_subsys_header_type)); + write_len += sizeof(diagpkt_subsys_header_type); + read_len += sizeof(diagpkt_subsys_header_type); + ts_get((void *)(rsp + write_len)); + write_len += sizeof(unsigned long); + memcpy(rsp + write_len, req + read_len, pkt_len - read_len); + } + + printf("\n"); + return rsp; +} + +static void *diagdiag_apps_delayed_rsp_test(void *req_pkt, uint16 pkt_len) +{ + void *rsp = NULL; + diag_delayed_test_rsp_t *my_rsp = NULL; + diagpkt_subsys_delayed_rsp_id_type delay_rsp_id = 0; + char first_resp[] = "First response."; + char del_rsp[] = "Delayed response."; + uint16 count; + int i; + (void) pkt_len; + + if (!req_pkt) + return NULL; + count = (*(diag_delayed_test_req_t *)req_pkt).count; + if (count > DIAG_DELAYED_RSP_CNT_MAX) { + printf("test_diag: Count is above limit. Truncating to %d\n", DIAG_DELAYED_RSP_CNT_MAX); + count = DIAG_DELAYED_RSP_CNT_MAX; + } + + /* Allocate the length of response. */ + rsp = diagpkt_subsys_alloc_v2(DIAG_SUBSYS_DIAG_SERV, DIAG_CMD_APPS_DELAYED_RSP_TEST, + sizeof(diag_delayed_test_rsp_t)); + if (!rsp) { + printf("test_diag: In %s, Unable to allocate response, err: %d\n", __func__, errno); + return NULL; + } + + /* + * Get the delayed_rsp_id that was allocated by diag to + * use for the delayed response we're going to send next. + * This id is unique in the system. + */ + delay_rsp_id = diagpkt_subsys_get_delayed_rsp_id(rsp); + + /* Frame and commit the immediate response */ + my_rsp = (diag_delayed_test_rsp_t *)rsp; + memcpy(my_rsp->my_rsp, first_resp, strlen(first_resp)); + diagpkt_commit(rsp); + printf("test_diag: Successfully committed immediate response\n"); + + if (count == 0) { + printf("\n"); + return NULL; + } + + /* Allocate and Commit (count - 1) delayed responses */ + for (i = 1; i < (int)count; i++) { + /* Create the delayed response */ + rsp = diagpkt_subsys_alloc_v2_delay(DIAG_SUBSYS_DIAG_SERV, DIAG_CMD_APPS_DELAYED_RSP_TEST, + delay_rsp_id, sizeof(diag_delayed_test_rsp_t)); + if (!rsp) { + printf("test_diag: In %s, Unable to create delayed response %d, err: %d\n", __func__, i, errno); + continue; + } + + /* Set the response count. Please see the ICD to set this field */ + diagpkt_subsys_set_rsp_cnt(rsp, DIAG_DELAYED_RSP_CNT_BASE + i); + my_rsp = (diag_delayed_test_rsp_t *) rsp; + memcpy(my_rsp->my_rsp, del_rsp, strlen(del_rsp)); + diagpkt_delay_commit(rsp); + if (verbose) + printf("test_diag: Successfully committed delayed response, %d\n", i); + } + + /* Commit the last delayed response */ + rsp = diagpkt_subsys_alloc_v2_delay(DIAG_SUBSYS_DIAG_SERV, DIAG_CMD_APPS_DELAYED_RSP_TEST, + delay_rsp_id, sizeof(diag_delayed_test_rsp_t)); + if (!rsp) { + printf("test_diag: In %s, Unable to create delayed response %d, err: %d\n", __func__, count, errno); + return NULL; + } + + /* Set the response count. Please see the ICD to set this field */ + diagpkt_subsys_set_rsp_cnt(rsp, count - 1); + my_rsp = (diag_delayed_test_rsp_t *)rsp; + memcpy(my_rsp->my_rsp, del_rsp, strlen(del_rsp)); + diagpkt_delay_commit(rsp); + printf("test_diag: Successfully committed last delayed response\n\n"); + + return NULL; +} + +static const diagpkt_user_table_entry_type diag_test_tbl[] = { + {DIAG_CMD_APPS_STRESS_TEST, DIAG_CMD_APPS_STRESS_TEST, diagdiag_apps_stress_test}, + {DIAG_CMD_APPS_LOOPBACK_TEST, DIAG_CMD_APPS_LOOPBACK_TEST, diagdiag_loopback_test} +}; + +static const diagpkt_user_table_entry_type diag_test_tbl_delay[] = { + {DIAG_CMD_APPS_DELAYED_RSP_TEST, DIAG_CMD_APPS_DELAYED_RSP_TEST, diagdiag_apps_delayed_rsp_test} +}; + +static void usage(char *progname) +{ + printf("\n"); + printf(" Usage for %s:\n\n", progname); + printf(" -t, --threads: maximum number of stress test tasks to support\n"); + printf(" -d, --verbose: prints stress test task information\n"); + printf(" -h, --help: help\n"); + printf(" e.g. test_diag -v -t 5 can support upto 5 stress test threads at the same time\n\n"); + exit(0); +} + +static void parse_args(int argc, char **argv) +{ + int command, temp_size; + struct option longopts[] = { + {"threads", 1, NULL, 't'}, + {"verbose", 0, NULL, 'v'}, + {"help", 0, NULL, 'h'}, + }; + + if (argc == 1) + return; + + while ((command = getopt_long(argc, argv, "t:vh", longopts, NULL)) != -1) { + switch (command) { + case 't': + max_num_tasks = atoi(optarg); + if (max_num_tasks <= 0 || max_num_tasks >= MAX_NUM_TASKS) { + printf("test_diag: Invalid number of tasks, %d\n", max_num_tasks); + exit(0); + } + break; + case 'v': + verbose = 1; + break; + case 'h': + default: + usage(argv[0]); + break; + } + } +} + +int main(int argc, char *argv[]) +{ + unsigned int i = 0; + boolean status = FALSE; + verbose = 0; + max_num_tasks = 1; + pthread_mutex_init(&test_hdl_lock, NULL); + parse_args(argc, argv); + + test_info = malloc(max_num_tasks * sizeof(diag_stress_test_hdl_t)); + if (!test_info) { + printf("test_diag: Unable to allocate memory for stress test handle\n"); + exit(0); + } + memset(test_info, 0, sizeof(max_num_tasks * sizeof(diag_stress_test_hdl_t))); + + status = Diag_LSM_Init(NULL); + if (!status) { + printf("test_diag: Diag_LSM_Init failed, error: %d\n", errno); + free(test_info); + return -1; + } + printf("test_diag: Diag_LSM_Init succeeded\n\n"); + + /* Register Apps Test Commands */ + DIAGPKT_DISPATCH_TABLE_REGISTER(DIAG_SUBSYS_DIAG_SERV, diag_test_tbl); + /* Register Delayed Response Test Command */ + DIAGPKT_DISPATCH_TABLE_REGISTER_V2_DELAY(DIAG_SUBSYS_CMD_VER_2_F, + DIAG_SUBSYS_DIAG_SERV, + diag_test_tbl_delay); + + while (i < UINT_MAX) + sleep(5); + + Diag_LSM_DeInit(); + free(test_info); + + return 0; +} diff --git a/feeds/wifi-ax/qca-diag/src/uart_log/Android.mk b/feeds/wifi-ax/qca-diag/src/uart_log/Android.mk new file mode 100755 index 000000000..21411ed6b --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/uart_log/Android.mk @@ -0,0 +1,29 @@ +################################################################################ +# @file pkgs/stringl/Android.mk +# @brief Makefile for building the string library on Android. +################################################################################ + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +libdiag_includes:= \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../src + +LOCAL_C_INCLUDES := $(libdiag_includes) +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/common/inc + +LOCAL_SRC_FILES:= \ + diag_uart_log.c + +commonSharedLibraries :=libdiag + +LOCAL_MODULE := diag_uart_log +LOCAL_MODULE_TAGS := optional +LOCAL_SHARED_LIBRARIES := $(commonSharedLibraries) +LOCAL_SHARED_LIBRARIES += liblog + +LOCAL_MODULE_OWNER := qcom +include $(BUILD_EXECUTABLE) + diff --git a/feeds/wifi-ax/qca-diag/src/uart_log/Makefile.am b/feeds/wifi-ax/qca-diag/src/uart_log/Makefile.am new file mode 100755 index 000000000..83d89be08 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/uart_log/Makefile.am @@ -0,0 +1,27 @@ + +AM_CFLAGS = -Wall \ + -Wundef \ + -Wstrict-prototypes \ + -Wno-trigraphs + +AM_CPPFLAGS = -D__packed__= \ + -DIMAGE_APPS_PROC \ + -DFEATURE_Q_SINGLE_LINK \ + -DFEATURE_Q_NO_SELF_QPTR \ + -DFEATURE_LINUX \ + -DFEATURE_NATIVELINUX \ + -DFEATURE_DSM_DUP_ITEMS \ + -DFEATURE_LE_DIAG \ + -I../src \ + -I../include + +bin_PROGRAMS = diag_uart_log + +diag_uart_log_SOURCES = diag_uart_log.c +diag_uart_log_LDADD = ../src/libdiag.la +if USE_GLIB +diag_uart_log_CFLAGS = -DUSE_GLIB @GLIB_CFLAGS@ +diag_uart_log_LDFLAGS = -lpthread @GLIB_LIBS@ +else +diag_uart_log_LDFLAGS = -lpthread -lcutils +endif diff --git a/feeds/wifi-ax/qca-diag/src/uart_log/diag_uart_log.c b/feeds/wifi-ax/qca-diag/src/uart_log/diag_uart_log.c new file mode 100755 index 000000000..d6fbb4a13 --- /dev/null +++ b/feeds/wifi-ax/qca-diag/src/uart_log/diag_uart_log.c @@ -0,0 +1,394 @@ +// Copyright (c) 2012, 2014 by Qualcomm Technologies, Inc. All Rights Reserved. +//Qualcomm Technologies Proprietary and Confidential. + +/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* + + Test Application for Diag Interface + +GENERAL DESCRIPTION + Contains main implementation of Diagnostic Services Application for UART. + +EXTERNALIZED FUNCTIONS + None + +INITIALIZATION AND SEQUENCING REQUIREMENTS + +Copyright (c) 2012, 2014 Qualcomm Technologies, Inc. +All Rights Reserved. +Qualcomm Technologies Confidential and Proprietary + +*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ + +/*=========================================================================== + + EDIT HISTORY FOR MODULE + +This section contains comments describing changes made to the module. +Notice that changes are listed in reverse chronological order. + +$Header: + +when who what, where, why +-------- --- ---------------------------------------------------------- +01/06/12 SJ Created +===========================================================================*/ + +#include +#include +#include "string.h" +#include "malloc.h" +#include +#include +#include +#include +#include +#include "errno.h" +#include +#include + +#ifndef FEATURE_LE_DIAG +#include +#else +#include +#endif +#include +#include "msg.h" +#include "diag_lsm.h" +#include "stdio.h" +#include "diagpkt.h" +#include "diag_lsmi.h" +#include "diag_shared_i.h" + +/*strlcpy is from OpenBSD and not supported by Meego. + * GNU has an equivalent g_strlcpy implementation into glib. + * Featurized with compile time USE_GLIB flag for Meego builds. + */ +#ifdef USE_GLIB +#define strlcpy g_strlcpy +#define strlcat g_strlcat +#endif + +#define DIAG_UART_WAKELOCK_NAME "diag_uart_wakelock" + +extern int fd_uart; +unsigned char read_buf[4096], buf[4100], send_buf[4100]; +boolean bInit_Success = FALSE; +int i, unused_len = 0, start, end, num_read; +static speed_t input_baudrate = B115200, output_baudrate = B115200; +char dev_name[FILE_NAME_LEN] = "/dev/ttyHSL0"; +char pid_file[32] = "/data/diag_uart_pid"; +char valid_procs[][5] = {"MSM", "MDM", "MDM2", "MDM3", "MDM4", "QSC", ""}; +char proc[5]; +int logging_proc = MSM; +static int enable_wakelock = 0; + +void usage (char *progname) +{ + printf("\n Usage for %s:\n", progname); + printf("\n-d, --device:\t UART device node (/dev/ttyHSL0)\n"); + printf("\n-o, --obaud:\t Output baud rate (115200)\n"); + printf("\n-i, --ibaud:\t Input baud rate (115200)\n"); + printf("\n-p, --proc:\t Logging proc type MSM, MDM\n"); + printf("\n-e --enablelock:\t Run using wake lock to keep APPS processor on\n"); + printf("\n-h, --help:\t usage help\n"); + printf("\ne.g. diag_uartlog -d -b " + " -i \n"); +} + +int checkbaud(long baud, char *type) +{ + switch (baud) { + case 50: + return B50; + case 75: + return B75; + case 110: + return B110; + case 134: + return B134; + case 150: + return B150; + case 200: + return B200; + case 300: + return B300; + case 600: + return B600; + case 1200: + return B1200; + case 1800: + return B1800; + case 2400: + return B2400; + case 4800: + return B4800; + case 9600: + return B9600; + case 19200: + return B19200; + case 38400: + return B38400; + case 57600: + return B57600; + case 115200: + return B115200; + case 230400: + return B230400; + default: + printf("Invalid baudrate for %s using default" + " 115200\n", type); + return B115200; + } +} + +void parse_args(int argc, char **argv) +{ + int command, i = 0; + struct option longopts[] = + { + { "device", 1, NULL, 'd'}, + { "obaud", 1, NULL, 'o'}, + { "ibaud", 1, NULL, 'i'}, + { "proc", 1, NULL, 'p'}, + { "enablelock", 0, NULL, 'e'}, + { "help", 0, NULL, 'h'}, + }; + + while ((command = getopt_long(argc, argv, "d:o:i:p:eh", longopts, + NULL)) != -1) { + switch (command) { + case 'd': + strlcpy(dev_name, optarg, FILE_NAME_LEN); + break; + case 'o': + output_baudrate = checkbaud(atol(optarg), + "output"); + break; + case 'i': + input_baudrate = checkbaud(atol(optarg), + "input"); + break; + case 'p': + strlcpy(proc, optarg, 5); + proc[4] = '\0'; + logging_proc = -1; + while (strnlen(valid_procs[i], 4)) { + if (!strncmp(valid_procs[i], proc, 4)) { + logging_proc = i; + break; + } + i++; + } + if (logging_proc < 0) { + printf("\ndiag: Invalid Proc name\n"); + exit(0); + } + break; + case 'e': + enable_wakelock = 1; + break; + case 'h': + default: + usage(argv[0]); + exit(0); + }; + } +} + +void create_pid_file(int logging_proc) +{ + int pid_fd; + struct diag_uart_tbl_t last_app, last_app1; + + unlink(pid_file); + if ((pid_fd = open(pid_file, O_RDWR | O_CREAT | + O_EXCL | O_SYNC, 0770)) < 0) { + perror("diag: pid_file:"); + printf("\ndiag: Unable to create pid file"); + exit(0); + } + last_app.pid = getpid(); + last_app.proc_type = logging_proc; + write(pid_fd, &last_app, sizeof(last_app)); + close(pid_fd); +#if 0 + /* Test */ + pid_fd = open(pid_file, O_RDONLY); + read(pid_fd, &last_app1.pid, sizeof(int)); + read(pid_fd, &last_app1.proc_type, sizeof(int)); + close(pid_fd); + printf("\n --- %d %d --\n", last_app1.proc_type, last_app1.pid); +#endif +} + +void cleanup_pid_file(int signal) +{ + (void)signal; + + printf("\n .... cleaning the pid file killing app \n"); + unlink(pid_file); + if (diag_is_wakelock_init()) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + exit(0); +} + +int main(int argc, char *argv[]) +{ + struct termios options, options_save; + int token_offset = 4, ret, pid_fd; + struct diag_uart_tbl_t last_app; + struct sigaction sact; + + /* Basic setup for pid file */ + if (mkdir("/data", 0770)) { + if (errno != EEXIST) + printf("\ndiag: Unable to create directory"); + } + + *(int *)send_buf = USER_SPACE_DATA_TYPE; + + parse_args(argc, argv); + /* Open and Configure UART */ + fd_uart = open(dev_name, O_RDWR | O_NOCTTY | O_EXCL); + if (fd_uart < 0) { + printf("\n Unable to open device %s\n", dev_name); + exit(0); + } + tcflush(fd_uart, TCIOFLUSH); + fcntl(fd_uart, F_SETFL, 0); + ioctl(fd_uart, TCGETS, &options_save); + options = options_save; + options.c_cc[VTIME] = 0; /* inter-character timer unused */ + options.c_cc[VMIN] = 4; /* blocking read until 4 chars received */ + options.c_cflag &= ~PARENB; + options.c_cflag &= ~CSTOPB; + options.c_cflag &= ~CSIZE; + options.c_cflag |= (CS8 | CLOCAL | CREAD); + options.c_iflag = 0; + options.c_oflag = 0; + options.c_lflag = 0; + cfsetospeed(&options, output_baudrate); + cfsetispeed(&options, input_baudrate); + ioctl(fd_uart, TCSETS, &options); + + if (!bInit_Success) + bInit_Success = Diag_LSM_Init(NULL); + + sigemptyset(&sact.sa_mask); + sact.sa_flags = 0; + sact.sa_handler = cleanup_pid_file; + sigaction(SIGTERM, &sact, NULL); + sigaction(SIGHUP, &sact, NULL); + sigaction(SIGINT, &sact, NULL); + + /* Open the pid_file to get information about any diag_uart_log + * already running. + */ + pid_fd = open(pid_file, O_RDONLY); + if (pid_fd < 0) { + if (errno != ENOENT) { + perror("diag: pid_file:"); + printf("\ndiag: exiting... error:%d", errno); + return 0; + } else { + /* pid_file not present diag_uart_log is not running + * create pid file and start app. + */ + create_pid_file(logging_proc); + } + } else { + + /* pid_file present diag_uart_log is already running */ + /* Kill the previous APP */ + + ret = read(pid_fd, &last_app.proc_type, sizeof(int)); + if (ret < 0) { + printf("\ndiag: Unable to read pid file"); + perror("diag:"); + close(pid_fd); + return 0; + } + + ret = read(pid_fd, &last_app.pid, sizeof(int)); + if (ret < 0) { + printf("\ndiag: Unable to read pid file"); + perror("diag:"); + close(pid_fd); + return 0; + } + close(pid_fd); + + if ((logging_proc == last_app.proc_type) && + (kill(last_app.pid, 0) == 0)) { + printf("\ndiag: diag_uart_log already running with" + " same proc logging\n"); + return 0; + } + + /* Not checking for the error, we might have a stale file */ + if (last_app.pid != 0) { + kill(last_app.pid, SIGUSR1); + /* Adding sleep to allow switching of mode */ + sleep(5); + } + + create_pid_file(logging_proc); + } + + if (enable_wakelock) { + diag_wakelock_init(DIAG_UART_WAKELOCK_NAME); + diag_wakelock_acquire(); + } + printf("\ndiag: Switching logging to UART mode PROC: %d\n", + logging_proc); + /* Switch the logging mode */ + diag_switch_logging(UART_MODE, (char *)&logging_proc); + + while (1) { + if (fd_uart > 0) { + memset(read_buf, 0, 4096); + /* read from UART */ + num_read = read(fd_uart, (unsigned char *)read_buf, + 4096); + if (num_read > 0) { + memcpy(buf+unused_len, read_buf, num_read); + start = 0; + end = 0; + for (i = 0; i < unused_len+num_read; i++) { + if (buf[i] == CONTROL_CHAR) { + if (logging_proc != MSM) { + token_offset = 4; + *(int *)(send_buf + 4) = -logging_proc; + memcpy(send_buf + 8, buf + start, end-start + 1); + } else + memcpy(send_buf + 4, buf + start, end-start + 1); + + diag_send_data(send_buf, end - start + 5 + token_offset); + + token_offset = 0; + start = i + 1; + end = i + 1; + continue; + } + + end = end + 1; + } + + unused_len = end - start; + memcpy(buf, buf+start, unused_len); + } + } + } + + unlink(pid_file); + if (enable_wakelock) { + diag_wakelock_release(); + diag_wakelock_destroy(); + } + ioctl(fd_uart, TCSETS, &options_save); + close(fd_uart); + Diag_LSM_DeInit(); + return 0; +}