[Feature][ZXW-41] merged 0601 version
Change-Id: I667af6bb09d65581d455b73f8984c160b2c67ad8
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
index 1d009f1..69d83c5 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
@@ -7,6 +7,10 @@
MAINTAINER = "zxic Community Team <xxx@xxx>"
TARGET_VENDOR = "-zxic"
+## OPTEE
+DISTRO_FEATURES += "OPTEE"
+meta_optee += " ${@bb.utils.contains("DISTRO_FEATURES", "OPTEE", " optee-client optee-example ", "", d)} "
+
PREFERRED_PROVIDER_virtual/kernel = "linux-zxic"
PREFERRED_VERSION_linux-zxic = "5.10.156"
PREFERRED_VERSION_busybox = "1.33.1"
@@ -90,6 +94,7 @@
CUSTOM_MACRO += " -DTTY_MODE_MUX=2 "
CUSTOM_MACRO += " -DUSE_UBIFS "
CUSTOM_MACRO += " -DUSE_CAP_SUPPORT "
+CUSTOM_MACRO += " -DFOTA_AB "
CUSTOM_MACRO += "${@bb.utils.contains('ENABLE_TESTBENCH_TTY', 'yes', '-DTESTBENCH_TTY_MODE=TTY_MODE_SINGLE', '-DTESTBENCH_TTY_MODE=TTY_MODE_NO', d)}"
CONFIG_MMI_LCD = "${@bb.utils.contains("DISTRO_FEATURES", "MMI_LCD", "yes","no", d)}"
CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_MMI_LCD', 'yes', '', '-DDISABLE_LCD', d)}"
@@ -132,6 +137,9 @@
libvoice \
libmedia \
libdebug-info \
+ libmtd \
+ libsclog \
+ libupi-ab \
libbinder \
libril \
liblynq-uci \
@@ -149,12 +157,13 @@
#zxic自研应用
zxic_app_open += "\
- nvserver cfg-tool adb \
+ nvserver cfg-tool adb ab-bootinfo \
at-ctl \
atchn-test \
zxic-mainctrl \
zxic-script \
zxic-hotplug \
+ zxic-ramdump \
sntp \
zxic-ipv6-slaac \
zxic-ipv6-addr-conver \
@@ -167,21 +176,33 @@
zlog-agent \
cc-demo \
sim-demo \
+ sms-demo \
i2ctest \
spitest \
uarttest \
bsp-test \
zxic-debug \
crc \
+ crc-api \
crc-modem \
crc-mcu \
voiceipc-mainctrl \
+ voice-demo \
fsmonitor \
ethtest \
sc-at-test \
dialtest \
rild \
sc-nw-mgr-test \
+ sc-cfg-test \
+ sc-softtimer-test \
+ sc-log-test \
+ adctest \
+ rtc-timer-demo \
+ tsctest \
+ fota-upi-ab \
+ sc-net-test \
+ usbtest \
lynq-ril-service \
uci \
gdb \
@@ -207,6 +228,8 @@
sqlcipher \
iperf3 \
tcpdump \
+ mtd-utils-ubifs \
+ ${meta_optee} \
"
#normal的版本应用及库
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_4Gb.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_4Gb.conf
index 282736a..d6dacbf 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_4Gb.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_4Gb.conf
@@ -7,6 +7,10 @@
MAINTAINER = "zxic Community Team <xxx@xxx>"
TARGET_VENDOR = "-zxic"
+## OPTEE
+DISTRO_FEATURES += "OPTEE"
+meta_optee += " ${@bb.utils.contains("DISTRO_FEATURES", "OPTEE", " optee-client optee-example ", "", d)} "
+
PREFERRED_PROVIDER_virtual/kernel = "linux-zxic"
PREFERRED_VERSION_linux-zxic = "5.10.156"
PREFERRED_VERSION_busybox = "1.33.1"
@@ -93,6 +97,7 @@
CUSTOM_MACRO += " -DTTY_MODE_MUX=2 "
CUSTOM_MACRO += " -DUSE_UBIFS "
CUSTOM_MACRO += " -DUSE_CAP_SUPPORT "
+CUSTOM_MACRO += " -DFOTA_AB "
CUSTOM_MACRO += "${@bb.utils.contains('ENABLE_TESTBENCH_TTY', 'yes', '-DTESTBENCH_TTY_MODE=TTY_MODE_SINGLE', '-DTESTBENCH_TTY_MODE=TTY_MODE_NO', d)}"
CONFIG_MMI_LCD = "${@bb.utils.contains("DISTRO_FEATURES", "MMI_LCD", "yes","no", d)}"
CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_MMI_LCD', 'yes', '', '-DDISABLE_LCD', d)}"
@@ -135,43 +140,60 @@
libvoice \
libmedia \
libdebug-info \
+ libmtd \
+ libsclog \
+ libupi-ab \
"
zxic_lib += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', 'libbinder libril', 'libtelsvr', d)}"
#zxic自研应用
zxic_app_open += "\
- nvserver cfg-tool adb \
+ nvserver cfg-tool adb ab-bootinfo \
at-ctl \
atchn-test \
zxic-mainctrl \
zxic-script \
zxic-hotplug \
+ zxic-ramdump \
sntp \
- zxic-ipv6-slaac \
- zxic-ipv6-addr-conver \
+ zxic-ipv6-slaac \
+ zxic-ipv6-addr-conver \
zxic-ndp \
rtc-service \
- fluxstat \
- zxic-audio-ctrl \
+ fluxstat \
dhcp6 \
fscheck \
nv-rpc-daemon \
zlog-agent \
cc-demo \
sim-demo \
+ sms-demo \
i2ctest \
spitest \
uarttest \
+ bsp-test \
zxic-debug \
crc \
+ crc-api \
crc-modem \
crc-mcu \
+ voiceipc-mainctrl \
+ voice-demo \
fsmonitor \
ethtest \
- dialtest \
sc-at-test \
+ dialtest \
sc-nw-mgr-test \
+ sc-cfg-test \
+ sc-softtimer-test \
+ sc-log-test \
+ adctest \
+ rtc-timer-demo \
+ tsctest \
+ fota-upi-ab \
+ sc-net-test \
+ usbtest \
"
zxic_app_open += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', 'rild', '', d)}"
@@ -182,9 +204,9 @@
dropbear \
e2fsprogs \
iptables \
- dnsmasq \
+ dnsmasq \
dhcp6 \
- radvd \
+ radvd \
iproute2 \
busybox-syslog \
ethtool \
@@ -192,6 +214,8 @@
iperf3 \
tcpdump \
python3 \
+ mtd-utils-ubifs \
+ ${meta_optee} \
"
#normal的版本应用及库
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/busybox/busybox/vehicle_dc-normal-busybox.cfg b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/busybox/busybox/vehicle_dc-normal-busybox.cfg
index a051626..2b48930 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/busybox/busybox/vehicle_dc-normal-busybox.cfg
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/busybox/busybox/vehicle_dc-normal-busybox.cfg
@@ -50,7 +50,7 @@
CONFIG_SYSROOT=""
CONFIG_EXTRA_CFLAGS=""
CONFIG_EXTRA_LDFLAGS=""
-CONFIG_EXTRA_LDLIBS=""
+CONFIG_EXTRA_LDLIBS="-lnvram"
#
# Installation Options ("make install" behavior)
@@ -787,13 +787,13 @@
CONFIG_STRINGS=y
CONFIG_TIME=y
CONFIG_TTYSIZE=y
-CONFIG_UBIATTACH=y
-CONFIG_UBIDETACH=y
-CONFIG_UBIMKVOL=y
-CONFIG_UBIRMVOL=y
-CONFIG_UBIRSVOL=y
-CONFIG_UBIUPDATEVOL=y
-CONFIG_UBIRENAME=y
+# CONFIG_UBIATTACH is not set
+# CONFIG_UBIDETACH is not set
+# CONFIG_UBIMKVOL is not set
+# CONFIG_UBIRMVOL is not set
+# CONFIG_UBIRSVOL is not set
+# CONFIG_UBIUPDATEVOL is not set
+# CONFIG_UBIRENAME is not set
CONFIG_VOLNAME=y
CONFIG_WATCHDOG=y
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/readme.txt b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/readme.txt
new file mode 100755
index 0000000..49579bc
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/readme.txt
@@ -0,0 +1,59 @@
+
+1、工具
+所需命令位于allbins/tools/mtd-utils和allbins/tools/squashfskit下,将这两个目录添加到PATH环境变量里。
+
+2、squashfs文件系统
+只读文件系统使用squashfs文件系统,在nandflash上会进行ubinize
+
+使用rootfs_mksqushfs_demo.sh打包,第一个参数是输出文件,第二个参数是打包的目录,第三个参数是卷名,第四个参数为ubi参数,注意要用双引号
+./rootfs_mksqushfs_demo.sh ap_oem.img oemfs oem "-m 0x1000 -p 0x40000 -s 0x1000 -Q 1024"
+会生成ap_oem.img文件
+
+挂载:
+通过cat /proc/mtd查询oem分区编号,假定分区编号是12,ubiattach后ubi设备是ubi2,挂载点是/mnt/oem
+ubiattach /dev/ubi_ctrl -m 12
+ubiblock -c /dev/ubi2_0
+mount -t squashfs -o ro /dev/ubilbock2_0 /mnt/oem
+或者使用板侧的ubi_mount.sh脚本挂载,脚本会自动查询分区名和ubi设备号
+第一个参数是挂载点,第二个参数是mtd分区名,第三个参数为ubi卷名,第四个参数是文件系统类型
+/sbin/ubi_mount.sh /mnt/oem oem vol_oem squashfs
+
+
+3、ubifs文件系统
+ubifs用于可写分区,使用ubinize-cfg.sh打包,下面以oemdata为例
+
+创建一个oemdata.cfg,内容如下:
+[vol_oemdata]
+mode=ubi
+vol_id=1
+vol_size=1MiB
+vol_type=dynamic
+vol_name=vol_oemdata
+vol_flags=autoresize
+
+使用ubinize-cfg.sh脚本,第一个参数为输出文件,第二个参数为cfg文件,第三个参数为ubi参数,注意要用双引号
+./ubinize-cfg.sh ap_oemdata.img oemdata.cfg "-m 0x800 -p 0x20000 -s 0x800 -Q 1024"
+会生成ap_oemdata.img文件
+
+挂载:
+通过cat /proc/mtd查询oem分区编号,假定分区编号是13,ubiattach后ubi设备是ubi3,挂载点是/mnt/oemdata
+ubiattach /dev/ubi_ctrl -m 13
+mount -t ubifs -o rw,noatime ubi3_0 /mnt/oemdata
+或者使用板侧的ubi_mount.sh脚本挂载,脚本会自动查询分区名和ubi设备号
+第一个参数是挂载点,第二个参数是mtd分区名,第三个参数为ubi卷名,第四个参数是文件系统类型,可以不输入,默认是ubifs
+/sbin/ubi_mount.sh /mnt/oemdata oemdata vol_oemdata
+
+ubifs默认挂载参数是rw,noatime,如果要修改挂载选项,使用UBI_MNT_OPT环境变量
+export UBI_MNT_OPT=rw,noatime,sync
+/sbin/ubi_mount.sh /mnt/oemdata oemdata vol_oemdata
+
+4、ab系统判断
+调用ab_bootinfo命令,命令返回1是系统a,命令返回2是系统b。
+ab_bootinfo
+if [ $? -eq 1 ]; then
+ /sbin/ubi_mount.sh /mnt/oem oem vol_oem squashfs
+else
+ /sbin/ubi_mount.sh /mnt/oem oem2 vol_oem squashfs
+fi
+
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/rootfs_mksqushfs_demo.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/rootfs_mksqushfs_demo.sh
index 7be5cd5..8fb770f 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/rootfs_mksqushfs_demo.sh
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/rootfs_mksqushfs_demo.sh
@@ -1,22 +1,28 @@
#!/bin/bash
+
+#UBI_ARGS="-m 0x1000 -p 0x40000 -s 0x1000 -Q 1024"
+if [ $# -lt 4 ]; then
+ echo "[error] $0 parameter to less"
+ echo "$0 out_name dir_name vol_name ubi_args"
+ exit -1
+fi
+OUT_NAME=$1
+DIR_NAME=$2
+VOL_NAME=$3
+UBI_ARGS=$4
MKSQUASHFS_ARGS="-nopad -noappend -root-owned -comp xz -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2 -b 256k -processors 1"
-UBI_ARGS="-m 0x1000 -p 0x40000 -s 0x1000 -Q 1024"
-CURR_DIR=`pwd`
-ALLBINS_TOOLS=$CURR_DIR/../../../../../../allbins/tools
-#export PATH=$CURR_DIR:$PATH
-export PATH=$ALLBINS_TOOLS/squashfskit:$ALLBINS_TOOLS/mtd-utils:$PATH
+echo "out_name: $OUT_NAME"
+echo "dir_name: $DIR_NAME"
+echo "vol_name: $VOL_NAME"
+echo "ubi_args: $UBI_ARGS"
-#echo $CURR_DIR
-#echo $MKSQUASHFS_ARGS
-
-mkdir -p ./rootfs_dir
-echo mksquashfs4 ./rootfs_dir rootfs.out ${MKSQUASHFS_ARGS} -p \'/dev d 755 0 0\' -p \'/dev/console c 600 0 0 5 1\'
-mksquashfs4 ./rootfs_dir rootfs.out ${MKSQUASHFS_ARGS} -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1'
+mkdir -p $DIR_NAME
+mksquashfs4 $DIR_NAME ${VOL_NAME}.out ${MKSQUASHFS_ARGS} -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1'
if [ $? -ne 0 ]; then
echo "mksquashfs error"
exit -1
fi
-./ubinize-static.sh vol_rootfs ap_rootfs.bin rootfs.out "$UBI_ARGS"
+./ubinize-static.sh $VOL_NAME $OUT_NAME ${VOL_NAME}.out "$UBI_ARGS"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/mdl/fs/normal/rootfs/etc_ro/default/default_parameter_user b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/mdl/fs/normal/rootfs/etc_ro/default/default_parameter_user
index b95175b..2832b60 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/mdl/fs/normal/rootfs/etc_ro/default/default_parameter_user
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/mdl/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -449,6 +449,7 @@
uart_ctstrs_enable=
uart_softcontrol_enable=
uart_wakeup_enable=
+uart_app_ctrl=1
uart_test_port=
uart_test_baud=115200
special_cmd_list=$MYNETREAD
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/CHARGING.bmp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/CHARGING.bmp
new file mode 100755
index 0000000..8b49fae
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/CHARGING.bmp
Binary files differ
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/LOGO.bmp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/LOGO.bmp
new file mode 100755
index 0000000..5762972
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/LOGO.bmp
Binary files differ
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/NOBAT.bmp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/NOBAT.bmp
new file mode 100755
index 0000000..b7d36df
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/oem/NOBAT.bmp
Binary files differ
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc/init.d/fscheck.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc/init.d/fscheck.sh
index 0303769..fc6ecc4 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc/init.d/fscheck.sh
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc/init.d/fscheck.sh
@@ -1,8 +1,15 @@
#!/bin/sh
-#sh /sbin/to_mnt_ubifs.sh /mnt/userdata capuserdata
fscheck -f /etc_ro/fscheck/userdata.ini
mkdir -p /mnt/userdata/cache
mkdir -p /mnt/userdata/var/run
mkdir -p /mnt/userdata/var/log
#mkdir -p /mnt/userdata/etc_rw
+
+ab_bootinfo
+#if [ $? -eq 1 ]; then
+# /sbin/ubi_mount.sh /mnt/oem oem vol_oem squashfs
+#else
+# /sbin/ubi_mount.sh /mnt/oem oem2 vol_oem squashfs
+#fi
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc/rc.local b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc/rc.local
index 3888a98..0ef8fb7 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc/rc.local
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc/rc.local
@@ -39,4 +39,5 @@
ln -sf "/etc/zoneinfo/Asia/Shanghai" /etc/localtime
+echo pwr_on_delay 60000000000 > /sys/power/wake_lock
echo mem > /sys/power/autosleep
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_sys b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_sys
old mode 100644
new mode 100755
index dc5c44e..5b2243e
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_sys
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_sys
@@ -115,6 +115,7 @@
fota_ab_upgrade_status=6
fota_ab_upgrade_total_size=0
fota_ab_upgrade_updated_size=0
+fota_ab_aa_sync_status=0
Login=admin
Password=
sntp_server_count=3
@@ -137,6 +138,10 @@
mynetlinkfile=/usr/netlog/mynetlink.log
mynetlinkfileSize=1024
telnetd_enable=n
+
+#syslogdÏà¹ØÅäÖÃ
+syslog_file_size=1
+syslog_file_num=5
print_level=2
syslog_level=4
@@ -324,6 +329,8 @@
###ijЩ¶Ë¿Ú²»ÐèÒªÏòÓ¦ÓÃÉϱ¨¶Ë¿Ú×¼±¸ºÃÏûÏ¢###
notify_forbiden_ports=/dev/ttyS0
+###adbĬÈϹÒÔØºË,0:ap;1:cap###
+adb_core_id=1
######USB¶Ë¿ÚÅäÖÃEND#######
######CP²àNVÅäÖÃÐÅÏ¢#######
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_user b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_user
index 833ed8d..c21ce3a 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_user
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -447,6 +447,8 @@
uart_softcontrol_enable=
uart_wakeup_enable=1
uart_console_coreid=1
+
+uart_app_ctrl=5
special_cmd_list=$MYNETREAD
##为入网入库芯片认证版本添加 begin
atcmd_stream1=AT+ZSET="w_instrument",1
@@ -478,4 +480,7 @@
zlog_num=10
zlog_size=100
zlog_path=/mnt/userdata/zcat
-rule_file=/mnt/userdata/all_3.rule
\ No newline at end of file
+rule_file=/mnt/userdata/all_3.rule
+cap_port_name=/dev/ttyGS0
+customIndCmdList=
+defrt_cid=1
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/fscheck/userdata.ini b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/fscheck/userdata.ini
index c838d13..cb5cf8a 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/fscheck/userdata.ini
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/fscheck/userdata.ini
@@ -3,7 +3,7 @@
ubi_vol_name=etc_rw
ubi_need_attach=1
mount_point=/etc_rw
-image_file=/etc_ro/ap_userdata.bin
+image_file=/etc_ro/ap_capuserdata.img
fs_type=ubifs
mount_opt=rw
file= /etc_rw/nv/main/cfg \
@@ -16,7 +16,7 @@
ubi_vol_name=vol_userdata
ubi_need_attach=0
mount_point=/mnt/userdata
-image_file=/etc_ro/ap_userdata.bin
+image_file=/etc_ro/ap_capuserdata.img
fs_type=ubifs
mount_opt=rw
file=/cache/testfile
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/fdisk_emmc.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/fdisk_emmc.sh
new file mode 100755
index 0000000..2dfa60a
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/fdisk_emmc.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+fdisk /dev/mmcblk1 <<EOF
+d
+1
+d
+2
+
+n
+p
+1
+1
+58752
+n
+p
+2
+58753
+117504
+w
+EOF
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/mount_ext4.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/mount_ext4.sh
new file mode 100755
index 0000000..651351d
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/mount_ext4.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if [ ! -b /dev/mmcblk1p1 ]; then
+ fdisk_emmc.sh
+ mkfs.ext4 /dev/mmcblk1p1
+ mkfs.ext4 /dev/mmcblk1p2
+fi
+
+#mount -o remount,rw /
+#mkdir -p /mnt/emmc1
+#mkdir -p /mnt/emmc2
+#mount -o remount,ro /
+
+mount -t ext4 -o async /dev/mmcblk1p1 /mnt/emmc1
+if [ $? -ne 0 ]; then
+ echo "ext4 mmcblk1p1 mount fail $? !"
+ mkfs.ext4 /dev/mmcblk1p1
+ mount -t ext4 /dev/mmcblk1p1 /mnt/emmc1
+fi
+
+mount -t ext4 -o sync /dev/mmcblk1p2 /mnt/emmc2
+if [ $? -ne 0 ]; then
+ echo "ext4 mmcblk1p1 mount fail $? !"
+ mkfs.ext4 /dev/mmcblk1p2
+ mount -t ext4 /dev/mmcblk1p2 /mnt/emmc2
+fi
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/ubi_mount.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/ubi_mount.sh
new file mode 100755
index 0000000..0f5a394
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/sbin/ubi_mount.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+#Author: zhouguopo
+#
+
+#外部传参
+# 参数1: mount点
+# 参数2: 分区名
+# 参数3: vol_name
+# 参数4: type 默认ubifs,可以是squashfs
+mount_point=$1
+mtd_name=$2
+vol_name=$3
+if [ $# -lt 4 ]; then
+ fs_type=ubifs
+else
+ fs_type=$4
+fi
+
+if [ x"$UBI_MNT_OPT" = x"" ]; then
+ UBI_MNT_OPT=rw,noatime
+fi
+if [ x"$fs_type" = x"squashfs" ]; then
+ UBI_MNT_OPT=ro
+fi
+echo "mount_point:$mount_point"
+echo "mtd_name:$mtd_name"
+echo "vol_name:$vol_name"
+echo "fs_type:$fs_type"
+echo "UBI_MNT_OPT:$UBI_MNT_OPT"
+#exit -1
+
+g_ubi_dev="ubi0_0"
+g_ubiblock_dev="ubiblock0_0"
+# check_vol_is_attached vol_name
+# 1 is attached, 0 not attached
+function check_vol_is_attached()
+{
+ ret=0
+ vol_name=$1
+ found=0
+ #declare -g g_ubi_dev
+ while read -r f; do
+ vol_name_tmp=$(cat "$f")
+ if [ x"$vol_name_tmp" = x"$vol_name" ]; then
+ g_ubi_dev=$(echo "$f" | awk -F'/' '{print $7}')
+ echo "$vol_name already attached $g_ubi_dev"
+ found=1
+ break
+ fi
+ done <<EOF
+$(find /sys/devices/virtual/ubi -name "name")
+EOF
+ if [ "$found" -eq 1 ]; then
+ ret=1
+ fi
+ return "$ret"
+}
+
+function mtd_do_attach()
+{
+ mtd_name_temp=$1
+ #not attached and do attach
+ MTD_NUM=`cat /proc/mtd | grep "$mtd_name\"" | awk '{print $1}'| cut -b 4- |sed 's/://g'`
+ echo "attach $mtd_name mtd$MTD_NUM"
+ ubiattach /dev/ubi_ctrl -m ${MTD_NUM}
+ if [ $? != 0 ];then
+ echo "fail to attach $2"
+ return 1
+ fi
+ return 0
+}
+
+check_vol_is_attached $vol_name
+if [ $? = 0 ];then
+ mtd_do_attach $mtd_name #not attached and do attach
+ if [ $? = 1 ]; then
+ exit -1 #attach fail and exit error
+ else
+ #check again,fill g_ubi_dev
+ check_vol_is_attached $vol_name
+ if [ $? = 0 ];then
+ echo "check ubi vol attached again and fail"
+ exit -2
+ fi
+ fi
+fi
+
+if [ $fs_type = "squashfs" ]; then
+ g_ubiblock_dev=`echo $g_ubi_dev | sed 's/ubi/ubiblock/'`
+ echo "g_ubiblock_dev:$g_ubiblock_dev"
+ if [ ! -b "/dev/$g_ubiblock_dev" ]; then
+ echo "g_ubiblock_dev:$g_ubiblock_dev not exist and create"
+ ubiblock -c /dev/$g_ubi_dev
+ fi
+fi
+
+if [ $fs_type = "squashfs" ]; then
+ mount -t $fs_type -o $UBI_MNT_OPT /dev/$g_ubiblock_dev $mount_point
+else
+ mount -t $fs_type -o $UBI_MNT_OPT $g_ubi_dev $mount_point
+fi
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc/init.d/fscheck.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc/init.d/fscheck.sh
index 0303769..f6a9716 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc/init.d/fscheck.sh
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc/init.d/fscheck.sh
@@ -1,8 +1,15 @@
#!/bin/sh
-#sh /sbin/to_mnt_ubifs.sh /mnt/userdata capuserdata
fscheck -f /etc_ro/fscheck/userdata.ini
mkdir -p /mnt/userdata/cache
mkdir -p /mnt/userdata/var/run
mkdir -p /mnt/userdata/var/log
#mkdir -p /mnt/userdata/etc_rw
+
+ab_bootinfo
+if [ $? -eq 1 ]; then
+ /sbin/ubi_mount.sh /mnt/oem oem vol_oem squashfs
+else
+ /sbin/ubi_mount.sh /mnt/oem oem2 vol_oem squashfs
+fi
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc/rc.local b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc/rc.local
index 3888a98..0ef8fb7 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc/rc.local
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc/rc.local
@@ -39,4 +39,5 @@
ln -sf "/etc/zoneinfo/Asia/Shanghai" /etc/localtime
+echo pwr_on_delay 60000000000 > /sys/power/wake_lock
echo mem > /sys/power/autosleep
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_sys b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_sys
index 7b1aa27..5f6b57c 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_sys
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_sys
@@ -115,6 +115,7 @@
fota_ab_upgrade_status=6
fota_ab_upgrade_total_size=0
fota_ab_upgrade_updated_size=0
+fota_ab_aa_sync_status=0
Login=admin
Password=
sntp_server_count=3
@@ -137,6 +138,10 @@
mynetlinkfile=/usr/netlog/mynetlink.log
mynetlinkfileSize=1024
telnetd_enable=n
+
+#syslogdÏà¹ØÅäÖÃ
+syslog_file_size=1
+syslog_file_num=5
print_level=2
syslog_level=4
@@ -324,6 +329,8 @@
###ijЩ¶Ë¿Ú²»ÐèÒªÏòÓ¦ÓÃÉϱ¨¶Ë¿Ú×¼±¸ºÃÏûÏ¢###
notify_forbiden_ports=
+###adbĬÈϹÒÔØºË,0:ap;1:cap###
+adb_core_id=1
######USB¶Ë¿ÚÅäÖÃEND#######
######CP²àNVÅäÖÃÐÅÏ¢#######
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_user b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_user
index c600687..c26f6a1 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_user
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -447,6 +447,7 @@
uart_softcontrol_enable=
uart_wakeup_enable=1
uart_console_coreid=1
+uart_app_ctrl=5
special_cmd_list=$MYNETREAD
##为入网入库芯片认证版本添加 begin
atcmd_stream1=AT+ZSET="w_instrument",1
@@ -474,3 +475,11 @@
at_atq=
at_at_d=
quick_dial=1
+#for zlog_agent
+zlog_num=10
+zlog_size=100
+zlog_path=/mnt/userdata/zcat
+rule_file=/mnt/userdata/all_3.rule
+cap_port_name=/dev/ttyGS0
+customIndCmdList=
+defrt_cid=1
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/fscheck/userdata.ini b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/fscheck/userdata.ini
index c838d13..cb5cf8a 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/fscheck/userdata.ini
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/fscheck/userdata.ini
@@ -3,7 +3,7 @@
ubi_vol_name=etc_rw
ubi_need_attach=1
mount_point=/etc_rw
-image_file=/etc_ro/ap_userdata.bin
+image_file=/etc_ro/ap_capuserdata.img
fs_type=ubifs
mount_opt=rw
file= /etc_rw/nv/main/cfg \
@@ -16,7 +16,7 @@
ubi_vol_name=vol_userdata
ubi_need_attach=0
mount_point=/mnt/userdata
-image_file=/etc_ro/ap_userdata.bin
+image_file=/etc_ro/ap_capuserdata.img
fs_type=ubifs
mount_opt=rw
file=/cache/testfile
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/all_3.rule
similarity index 79%
copy from cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule
copy to cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/all_3.rule
index 0d18c5e..c4d2c1e 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/all_3.rule
Binary files differ
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/medium_2.rule
similarity index 80%
rename from cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule
rename to cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/medium_2.rule
index 0d18c5e..0c613e1 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/medium_2.rule
Binary files differ
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/simple_1.rule
similarity index 77%
copy from cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule
copy to cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/simple_1.rule
index 0d18c5e..74e69ab 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/log.rule
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/logrule/simple_1.rule
Binary files differ
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/fdisk_emmc.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/fdisk_emmc.sh
new file mode 100755
index 0000000..2dfa60a
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/fdisk_emmc.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+fdisk /dev/mmcblk1 <<EOF
+d
+1
+d
+2
+
+n
+p
+1
+1
+58752
+n
+p
+2
+58753
+117504
+w
+EOF
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/mount_ext4.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/mount_ext4.sh
new file mode 100755
index 0000000..651351d
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/mount_ext4.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if [ ! -b /dev/mmcblk1p1 ]; then
+ fdisk_emmc.sh
+ mkfs.ext4 /dev/mmcblk1p1
+ mkfs.ext4 /dev/mmcblk1p2
+fi
+
+#mount -o remount,rw /
+#mkdir -p /mnt/emmc1
+#mkdir -p /mnt/emmc2
+#mount -o remount,ro /
+
+mount -t ext4 -o async /dev/mmcblk1p1 /mnt/emmc1
+if [ $? -ne 0 ]; then
+ echo "ext4 mmcblk1p1 mount fail $? !"
+ mkfs.ext4 /dev/mmcblk1p1
+ mount -t ext4 /dev/mmcblk1p1 /mnt/emmc1
+fi
+
+mount -t ext4 -o sync /dev/mmcblk1p2 /mnt/emmc2
+if [ $? -ne 0 ]; then
+ echo "ext4 mmcblk1p1 mount fail $? !"
+ mkfs.ext4 /dev/mmcblk1p2
+ mount -t ext4 /dev/mmcblk1p2 /mnt/emmc2
+fi
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/ubi_mount.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/ubi_mount.sh
new file mode 100755
index 0000000..0f5a394
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/sbin/ubi_mount.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+#Author: zhouguopo
+#
+
+#外部传参
+# 参数1: mount点
+# 参数2: 分区名
+# 参数3: vol_name
+# 参数4: type 默认ubifs,可以是squashfs
+mount_point=$1
+mtd_name=$2
+vol_name=$3
+if [ $# -lt 4 ]; then
+ fs_type=ubifs
+else
+ fs_type=$4
+fi
+
+if [ x"$UBI_MNT_OPT" = x"" ]; then
+ UBI_MNT_OPT=rw,noatime
+fi
+if [ x"$fs_type" = x"squashfs" ]; then
+ UBI_MNT_OPT=ro
+fi
+echo "mount_point:$mount_point"
+echo "mtd_name:$mtd_name"
+echo "vol_name:$vol_name"
+echo "fs_type:$fs_type"
+echo "UBI_MNT_OPT:$UBI_MNT_OPT"
+#exit -1
+
+g_ubi_dev="ubi0_0"
+g_ubiblock_dev="ubiblock0_0"
+# check_vol_is_attached vol_name
+# 1 is attached, 0 not attached
+function check_vol_is_attached()
+{
+ ret=0
+ vol_name=$1
+ found=0
+ #declare -g g_ubi_dev
+ while read -r f; do
+ vol_name_tmp=$(cat "$f")
+ if [ x"$vol_name_tmp" = x"$vol_name" ]; then
+ g_ubi_dev=$(echo "$f" | awk -F'/' '{print $7}')
+ echo "$vol_name already attached $g_ubi_dev"
+ found=1
+ break
+ fi
+ done <<EOF
+$(find /sys/devices/virtual/ubi -name "name")
+EOF
+ if [ "$found" -eq 1 ]; then
+ ret=1
+ fi
+ return "$ret"
+}
+
+function mtd_do_attach()
+{
+ mtd_name_temp=$1
+ #not attached and do attach
+ MTD_NUM=`cat /proc/mtd | grep "$mtd_name\"" | awk '{print $1}'| cut -b 4- |sed 's/://g'`
+ echo "attach $mtd_name mtd$MTD_NUM"
+ ubiattach /dev/ubi_ctrl -m ${MTD_NUM}
+ if [ $? != 0 ];then
+ echo "fail to attach $2"
+ return 1
+ fi
+ return 0
+}
+
+check_vol_is_attached $vol_name
+if [ $? = 0 ];then
+ mtd_do_attach $mtd_name #not attached and do attach
+ if [ $? = 1 ]; then
+ exit -1 #attach fail and exit error
+ else
+ #check again,fill g_ubi_dev
+ check_vol_is_attached $vol_name
+ if [ $? = 0 ];then
+ echo "check ubi vol attached again and fail"
+ exit -2
+ fi
+ fi
+fi
+
+if [ $fs_type = "squashfs" ]; then
+ g_ubiblock_dev=`echo $g_ubi_dev | sed 's/ubi/ubiblock/'`
+ echo "g_ubiblock_dev:$g_ubiblock_dev"
+ if [ ! -b "/dev/$g_ubiblock_dev" ]; then
+ echo "g_ubiblock_dev:$g_ubiblock_dev not exist and create"
+ ubiblock -c /dev/$g_ubi_dev
+ fi
+fi
+
+if [ $fs_type = "squashfs" ]; then
+ mount -t $fs_type -o $UBI_MNT_OPT /dev/$g_ubiblock_dev $mount_point
+else
+ mount -t $fs_type -o $UBI_MNT_OPT $g_ubi_dev $mount_point
+fi
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-kernel/linux/files/zx297520v3/optee.cfg b/cap/zx297520v3/sources/meta-zxic-custom/recipes-kernel/linux/files/zx297520v3/optee.cfg
new file mode 100755
index 0000000..31e64fc
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-kernel/linux/files/zx297520v3/optee.cfg
@@ -0,0 +1,6 @@
+#
+# TEE drivers
+#
+CONFIG_TEE=y
+CONFIG_OPTEE=y
+CONFIG_OPTEE_SHM_NUM_PRIV_PAGES=6
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-kernel/linux/linux-zxic_5.10.bbappend b/cap/zx297520v3/sources/meta-zxic-custom/recipes-kernel/linux/linux-zxic_5.10.bbappend
old mode 100644
new mode 100755
index e6ef7f8..58f9fbe
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-kernel/linux/linux-zxic_5.10.bbappend
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-kernel/linux/linux-zxic_5.10.bbappend
@@ -2,4 +2,5 @@
SRC_URI_append = "\
file://${LINUX_CONFIG} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'OPTEE', 'file://optee.cfg', '', d)} \
"
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic/conf/app_com.inc b/cap/zx297520v3/sources/meta-zxic/conf/app_com.inc
index a811432..c2e3f5c 100755
--- a/cap/zx297520v3/sources/meta-zxic/conf/app_com.inc
+++ b/cap/zx297520v3/sources/meta-zxic/conf/app_com.inc
@@ -1,4 +1,4 @@
-CFLAGS_prepend = " -I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/include -I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/include/sctel -Wall -ffunction-sections -fomit-frame-pointer -fno-short-enums "
+CFLAGS_prepend = " -I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/include -I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/sdk/libsclog -I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/include/sctel -Wall -ffunction-sections -fomit-frame-pointer -fno-short-enums "
CFLAGS_append_arm = " -msoft-float -fno-common "
LDFLAGS_append = " -g -fno-common -fno-builtin -Wl,--gc-sections "
CFLAGS_append = " ${CUSTOM_MACRO} "
diff --git a/cap/zx297520v3/sources/meta-zxic/conf/pub.inc b/cap/zx297520v3/sources/meta-zxic/conf/pub.inc
index 4292ae1..f8fda90 100755
--- a/cap/zx297520v3/sources/meta-zxic/conf/pub.inc
+++ b/cap/zx297520v3/sources/meta-zxic/conf/pub.inc
@@ -1,5 +1,6 @@
ZXIC_EXTRA_CFLAGS = "-I${BSPDIR}/zxic_code/pub/include/infra "
+ZXIC_EXTRA_CFLAGS += "-I${BSPDIR}/zxic_code/pub/include/tools "
ZXIC_ZX297520V3_CFLAGS = "-I${BSPDIR}/zxic_code/pub/project/zx297520v3/include/infra "
ZXIC_ZX297520V3_CFLAGS += "-I${BSPDIR}/zxic_code/pub/project/zx297520v3/include/psm "
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/ab-bootinfo/ab-bootinfo.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/ab-bootinfo/ab-bootinfo.bb
new file mode 100755
index 0000000..bd8dadd
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/ab-bootinfo/ab-bootinfo.bb
@@ -0,0 +1,44 @@
+DESCRIPTION = "ab-bootinfo"
+#nv依赖libnvram库
+DEPENDS = "libmtd libnvram libsofttimer libsoftap libupi-ab"
+SECTION = "ab-bootinfo"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/platform:"
+SRC_URI = " \
+ file://ab_bootinfo \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+#编译
+do_compile() {
+ make -C ab_bootinfo
+}
+
+#库文件的安装,封库的宏MK_SDK_VERSION
+do_install () {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/ab_bootinfo/ab_bootinfo ${D}${bindir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/ab_bootinfo/ab_bootinfo ${ELFS-PATH}/
+}
+#清库
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/ab_bootinfo
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+#rootfs包含的文件
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
+SYSTEMD_SERVICE_${PN} = "ab_bootinfo.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/adctest/adctest.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/adctest/adctest.bb
new file mode 100755
index 0000000..48e68f8
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/adctest/adctest.bb
@@ -0,0 +1,53 @@
+DESCRIPTION = "adctest"
+
+DEPENDS = "libbsp"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/test:"
+SRC_URI = " \
+ file://adctest \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+#编译
+do_compile() {
+ make -C adctest
+}
+
+#库文件的安装
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/adctest/adctest ${D}${bindir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/adctest/adctest ${ELFS-PATH}/
+}
+#清库
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/adctest
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+#rootfs包含的文件
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/crc-api/crc-api.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/crc-api/crc-api.bb
new file mode 100755
index 0000000..394ba90
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/crc-api/crc-api.bb
@@ -0,0 +1,53 @@
+DESCRIPTION = "crc-api"
+
+DEPENDS = "libbsp"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/test:"
+SRC_URI = " \
+ file://crc_api \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+#编译
+do_compile() {
+ make -C crc_api
+}
+
+#库文件的安装
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/crc_api/crc_api ${D}${bindir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/crc_api/crc_api ${ELFS-PATH}/
+}
+#清库
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/crc_api
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+#rootfs包含的文件
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/fota-upi-ab/fota-upi-ab.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/fota-upi-ab/fota-upi-ab.bb
new file mode 100755
index 0000000..7c0e66e
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/fota-upi-ab/fota-upi-ab.bb
@@ -0,0 +1,59 @@
+DESCRIPTION = "fota_upi_ab"
+#ota-upgrade依赖库
+DEPENDS = "libmtd libnvram libsoftap libsofttimer libatutils libupi-ab"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/platform:"
+SRC_URI = " \
+ ${@bb.utils.contains("MK_SDK_VERSION", "yes", "", "file://fota_upi_ab", d)} \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+#编译
+do_compile() {
+ if [ ${MK_SDK_VERSION} = "no" ]; then
+ make -C fota_upi_ab
+ fi
+}
+
+#库文件的安装,封库的宏MK_SDK_VERSION
+do_install () {
+ if [ ${MK_SDK_VERSION} = "no" ]; then
+ install -d ${RELEASE-PATH}/executable
+ install -m 0755 ${S}/fota_upi_ab/fota_upi_ab_static ${RELEASE-PATH}/executable
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/fota_upi_ab/fota_upi_ab_static ${ELFS-PATH}/
+ fi
+
+ install -d ${D}${bindir}/
+ install -m 0755 ${RELEASE-PATH}/executable/fota_upi_ab_static ${D}${bindir}/
+}
+#清库
+do_cleanlibs () {
+ if [ ${MK_SDK_VERSION} = "no" ]; then
+ rm -fr ${ELFS-PATH}/fota_upi_ab
+ fi
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+#rootfs包含的文件
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
+
+RDEPENDS_${PN} = "libupi-ab"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/fscheck/fscheck.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/fscheck/fscheck.bb
index e50580f..2d3e2b2 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/fscheck/fscheck.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/fscheck/fscheck.bb
@@ -1,6 +1,6 @@
DESCRIPTION = "fscheck"
-DEPENDS = "libnvram"
+DEPENDS = "libnvram libmtd "
SECTION = "app"
LICENSE = "zte"
PV = "1.0.0"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/libbsp/libbsp.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/libbsp/libbsp.bb
old mode 100644
new mode 100755
index b8df422..51336a8
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/libbsp/libbsp.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/libbsp/libbsp.bb
@@ -1,4 +1,5 @@
DESCRIPTION = "libbsp"
+#DEPENDS = "libnvram"
SECTION = "lib"
LICENSE = "zte"
PV = "1.0.0"
@@ -34,6 +35,9 @@
install -m 0644 ${S}/libbsp/sc_pm.h ${D}/usr/include/
install -m 0644 ${S}/libbsp/sc_bsp.h ${D}/usr/include/
install -m 0644 ${S}/libbsp/sc_eth.h ${D}/usr/include/
+ install -m 0644 ${S}/libbsp/sc_adc.h ${D}/usr/include/
+ install -m 0644 ${S}/libbsp/sc_tsc.h ${D}/usr/include/
+ install -m 0644 ${S}/libbsp/sc_usb.h ${D}/usr/include/
install -d ${ELFS-PATH}/
install -m 0755 ${S}/libbsp/libbsp.so ${ELFS-PATH}/
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/libmedia/libmedia.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/libmedia/libmedia.bb
index 3fed4cd..2147dfd 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/libmedia/libmedia.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/libmedia/libmedia.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "libmedia"
-DEPENDS = "libvoice"
+DEPENDS = "libtinyalsa libvoice"
SECTION = "lib"
LICENSE = "zte"
PV = "1.0.0"
@@ -15,6 +15,7 @@
S = "${WORKDIR}"
#引用公用头文件和编译选项。
include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+CFLAGS_append = "-I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/libtinyalsa/include"
CFLAGS_append = "-I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include"
#编译
@@ -28,6 +29,7 @@
install -d ${D}/usr/include
install -m 0755 ${S}/libmedia/libmedia.so ${D}${libdir}/
install -m 0755 ${S}/libmedia/libmedia.a ${D}${libdir}/
+ install -m 0644 ${S}/libmedia/*.h ${D}/usr/include/
#install elfs
install -d ${ELFS-PATH}/
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/libmtd/libmtd.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/libmtd/libmtd.bb
new file mode 100755
index 0000000..803bcff
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/libmtd/libmtd.bb
@@ -0,0 +1,49 @@
+DESCRIPTION = "libmtd"
+SECTION = "lib"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/platform:"
+SRC_URI = " \
+ file://libmtd \
+ "
+
+S = "${WORKDIR}"
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+#编译
+do_compile () {
+ make -C libmtd
+}
+
+#库和头文件的安装
+do_install () {
+ install -d ${D}${libdir}/
+ install -d ${D}/usr/include
+ install -m 0755 ${S}/libmtd/libmtd.so ${D}${libdir}/
+ install -m 0755 ${S}/libmtd/libmtd.a ${D}${libdir}/
+
+ install -m 0644 ${S}/libmtd/mtd_api.h ${D}/usr/include
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/libmtd/libmtd.so ${ELFS-PATH}/
+}
+
+#清库
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/libmtd.so
+}
+
+#rootfs包含的文件
+FILES_${PN} += "${libdir}/*.so"
+FILES_${PN}-dbg += "${libdir}/.debug"
+FILES_SOLIBSDEV = ""
+INSANE_SKIP_${PN} = "dev-so"
+
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/libreference-ril/libreference-ril.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/libreference-ril/libreference-ril.bb
index c354826..c34e2d8 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/libreference-ril/libreference-ril.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/libreference-ril/libreference-ril.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "libreference-ril"
-DEPENDS = "libatchn libsoftap libnvram libsofttimer libatutils"
+DEPENDS = "libatchn libsoftap libnvram libsofttimer libatutils libtinyalsa libvoice libmedia"
SECTION = "lib"
LICENSE = "zte"
PV = "1.0.0"
@@ -46,4 +46,4 @@
FILES_${PN}-dbg += "${libdir}/.debug"
FILES_SOLIBSDEV = ""
INSANE_SKIP_${PN} = "dev-so"
-RDEPENDS_${PN} = "libatchn libsoftap libnvram libsofttimer libatutils"
\ No newline at end of file
+RDEPENDS_${PN} = "libatchn libsoftap libnvram libsofttimer libatutils libtinyalsa libvoice libmedia"
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/libril/libril.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/libril/libril.bb
index 3f0fbb7..18d4cfb 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/libril/libril.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/libril/libril.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "libril"
-DEPENDS = "libbinder libatchn libsoftap libnvram libsofttimer libatutils"
+DEPENDS = "libbinder libatchn libsoftap libnvram libsofttimer libatutils libtinyalsa libvoice libmedia"
SECTION = "lib"
LICENSE = "zte"
PV = "1.0.0"
@@ -58,4 +58,4 @@
FILES_${PN}-dbg += "${libdir}/.debug"
FILES_SOLIBSDEV = ""
INSANE_SKIP_${PN} = "dev-so"
-RDEPENDS_${PN} = "libbinder libatchn libsoftap libnvram libsofttimer libatutils"
+RDEPENDS_${PN} = "libbinder libatchn libsoftap libnvram libsofttimer libatutils libtinyalsa libvoice libmedia"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/libsclog/libsclog.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/libsclog/libsclog.bb
new file mode 100755
index 0000000..1d04e98
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/libsclog/libsclog.bb
@@ -0,0 +1,44 @@
+DESCRIPTION = "libsclog"
+SECTION = "lib"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/sdk:"
+SRC_URI = " \
+ file://libsclog \
+ "
+
+S = "${WORKDIR}"
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+
+#编译
+do_compile () {
+ make -C libsclog
+}
+
+#库和头文件的安装
+do_install () {
+ install -d ${D}${libdir}/
+ install -d ${D}/usr/include
+ install -m 0755 ${S}/libsclog/libsclog.so ${D}${libdir}/
+ install -m 0755 ${S}/libsclog/libsclog.a ${D}${libdir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/libsclog/libsclog.so ${ELFS-PATH}/
+}
+
+#清库
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/libsclog.so
+}
+
+#rootfs包含的文件
+FILES_${PN} += "${libdir}/*.so"
+FILES_${PN}-dbg += "${libdir}/.debug"
+FILES_SOLIBSDEV = ""
+INSANE_SKIP_${PN} = "dev-so"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/libupi-ab/libupi-ab.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/libupi-ab/libupi-ab.bb
new file mode 100755
index 0000000..cecb662
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/libupi-ab/libupi-ab.bb
@@ -0,0 +1,66 @@
+DESCRIPTION = "libupi_ab"
+DEPENDS = "libnvram libsoftap libsofttimer libatutils zlib openssl libmtd"
+SECTION = "lib"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/sdk:"
+SRC_URI = " \
+ ${@bb.utils.contains("MK_SDK_VERSION", "yes", "", "file://libupi_ab", d)} \
+ "
+
+S = "${WORKDIR}"
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+do_compile () {
+ if [ ${MK_SDK_VERSION} = "no" ]; then
+ make -C libupi_ab
+ fi
+}
+
+do_install () {
+ if [ ${MK_SDK_VERSION} = "no" ]; then
+ install -d ${RELEASE-PATH}/lib
+ install -d ${RELEASE-PATH}/include/upi_ab
+
+ install -m 0755 ${S}/libupi_ab/libupi_ab.so ${RELEASE-PATH}/lib
+ install -m 0755 ${S}/libupi_ab/libupi_ab.a ${RELEASE-PATH}/lib
+ install -m 0644 ${S}/libupi_ab/inc/*.h ${RELEASE-PATH}/include/upi_ab
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/libupi_ab/libupi_ab.so ${ELFS-PATH}/
+ fi
+ install -d ${D}${libdir}/
+ install -d ${D}/usr/include
+
+ install -m 0755 ${RELEASE-PATH}/lib/libupi_ab.so ${D}${libdir}/
+ install -m 0755 ${RELEASE-PATH}/lib/libupi_ab.a ${D}${libdir}/
+ install -m 0644 ${RELEASE-PATH}/include/upi_ab/*.h ${D}/usr/include/
+}
+
+#清库
+
+do_cleanlibs () {
+ if [ ${MK_SDK_VERSION} = "no" ]; then
+ rm -fr ${RELEASE-PATH}/lib/libupi_ab.so
+ rm -fr ${RELEASE-PATH}/lib/libupi_ab.a
+ rm -fr ${RELEASE-PATH}/include/upi_ab/*.h
+
+ rm -fr ${ELFS-PATH}/libupi_ab.so
+ fi
+}
+
+FILES_${PN} += "${libdir}/*.so"
+FILES_${PN}-dbg += "${libdir}/.debug"
+FILES_SOLIBSDEV = ""
+INSANE_SKIP_${PN} = "dev-so"
+
+RDEPENDS_${PN} = "libnvram libsoftap libsofttimer libatutils zlib libmtd"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/libvoice/libvoice.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/libvoice/libvoice.bb
index 8618a97..0654c50 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/libvoice/libvoice.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/libvoice/libvoice.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "libvoice"
-DEPENDS = "libtinyalsa"
+DEPENDS = "libtinyalsa libnvram libsoftap libsofttimer"
SECTION = "lib"
LICENSE = "zte"
PV = "1.0.0"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/nvserver/nvserver.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/nvserver/nvserver.bb
index 817fab5..5dbbb8d 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/nvserver/nvserver.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/nvserver/nvserver.bb
@@ -1,6 +1,6 @@
DESCRIPTION = "nvserver"
#nvserver依赖libnvram库
-DEPENDS = "libnvram"
+DEPENDS = "libmtd libnvram libsofttimer libsoftap libupi-ab"
SECTION = "app"
LICENSE = "zte"
PV = "1.0.0"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-service/rtc-service.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-service/rtc-service.bb
index 7f21bb1..eea34a6 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-service/rtc-service.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-service/rtc-service.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "rtc-service"
-DEPENDS = "libnvram libsofttimer libsoftap libatutils"
+DEPENDS = "libnvram libsofttimer libsoftap libatutils libscipc"
SECTION = "app"
LICENSE = "zte"
PV = "1.0.0"
@@ -74,5 +74,5 @@
SYSTEMD_SERVICE_${PN} = "rtc-service.service"
SYSTEMD_AUTO_ENABLE_${PN} = "disable"
-RDEPENDS_${PN} = " libnvram libsofttimer libsoftap libatutils"
+RDEPENDS_${PN} = " libnvram libsofttimer libsoftap libatutils libscipc"
INSANE_SKIP_${PN} += "ldflags"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo.bb
new file mode 100755
index 0000000..735e222
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo.bb
@@ -0,0 +1,64 @@
+DESCRIPTION = "rtc_timer_demo"
+DEPENDS = "libsctel libscipc libsoftap libnvram libsofttimer"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}:"
+SRC_URI = " \
+ file://test/rtc_timer_demo \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "file://rtc_timer_demo.init","", d)} \
+ ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "file://rtc_timer_demo.service","", d)} \
+ "
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+S_SRC_PATH = "${S}/test/rtc_timer_demo/"
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+
+#inherit autotools pkgconfig systemd
+
+do_compile() {
+ make -C ${S_SRC_PATH}
+}
+
+do_install () {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S_SRC_PATH}/rtc_timer_demo ${D}${bindir}/
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','procd','true','false',d)}; then
+ install -Dm 0755 ${WORKDIR}/rtc_timer_demo.init ${D}${sysconfdir}/init.d/rtc_timer_demo
+ fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system
+ install -m 0644 ${WORKDIR}/rtc_timer_demo.service ${D}${systemd_unitdir}/system
+ fi
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S_SRC_PATH}/rtc_timer_demo ${ELFS-PATH}/
+}
+
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/rtc_timer_demo
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+FILES_${PN} = "\
+ ${bindir}/ \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "${sysconfdir}/init.d/rtc_timer_demo","", d)} \
+ "
+SYSTEMD_SERVICE_${PN} = "rtc_timer_demo.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
+
+RDEPENDS_${PN} = " libsctel libscipc libsoftap libnvram libsofttimer"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo/rtc_timer_demo.init b/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo/rtc_timer_demo.init
new file mode 100755
index 0000000..5943573
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo/rtc_timer_demo.init
@@ -0,0 +1,21 @@
+#!/bin/sh /etc/rc.common
+
+START=18
+STOP=85
+USE_PROCD=1
+
+logger -t rtc_timer_demo
+
+start_service() {
+ procd_open_instance
+ procd_set_param command /usr/bin/rtc_timer_demo
+ procd_set_param stdout 1 # forward stdout of the command to logd
+ procd_set_param stderr 1 # same for stderr
+ procd_set_param respawn
+ procd_close_instance
+}
+
+stop_service()
+{
+ echo "add clean code"
+}
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo/rtc_timer_demo.service b/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo/rtc_timer_demo.service
new file mode 100755
index 0000000..80be85e
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/rtc-timer-demo/rtc-timer-demo/rtc_timer_demo.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=The rtc_timer_demo service
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/rtc_timer_demo
+Restart=always
+
+[Install]
+WantedBy=basic.target
+
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-cfg-test/sc-cfg-test.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-cfg-test/sc-cfg-test.bb
new file mode 100755
index 0000000..bc73bca
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-cfg-test/sc-cfg-test.bb
@@ -0,0 +1,49 @@
+DESCRIPTION = "sc_cfg_test"
+
+DEPENDS = "libnvram"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/test:"
+SRC_URI = " \
+ file://sc_cfg_test \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+do_compile() {
+ make -C sc_cfg_test
+}
+
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0777 ${S}/sc_cfg_test/sc_cfg_test ${D}${bindir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/sc_cfg_test/sc_cfg_test ${ELFS-PATH}/
+}
+
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/sc_cfg_test
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-log-test/sc-log-test.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-log-test/sc-log-test.bb
new file mode 100755
index 0000000..37e6352
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-log-test/sc-log-test.bb
@@ -0,0 +1,44 @@
+DESCRIPTION = "sc_log_test"
+
+DEPENDS = "libnvram libsclog"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/test:"
+SRC_URI = " \
+ file://sc_log_test \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+do_compile() {
+ make -C sc_log_test
+}
+
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0777 ${S}/sc_log_test/sc_log_test ${D}${bindir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/sc_log_test/sc_log_test ${ELFS-PATH}/
+}
+
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/sc_log_test
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc-net-test.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc-net-test.bb
new file mode 100755
index 0000000..2b9b27a
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc-net-test.bb
@@ -0,0 +1,64 @@
+DESCRIPTION = "sc_net_test"
+DEPENDS = "libsctel libsoftap libatutils libsofttimer libnvram libscipc"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}:"
+SRC_URI = " \
+ file://test/sc_net_test \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "file://sc_net_test.init","", d)} \
+ ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "file://sc_net_test.service","", d)} \
+ "
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+S_SRC_PATH = "${S}/test/sc_net_test"
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+#include +=
+#inherit autotools pkgconfig systemd
+
+do_compile() {
+ make -C ${S_SRC_PATH}
+}
+
+do_install () {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S_SRC_PATH}/sc_net_test ${D}${bindir}/
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','procd','true','false',d)}; then
+ install -Dm 0755 ${WORKDIR}/sc_net_test.init ${D}${sysconfdir}/init.d/sc_net_test
+ fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system
+ install -m 0644 ${WORKDIR}/sc_net_test.service ${D}${systemd_unitdir}/system
+ fi
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S_SRC_PATH}/sc_net_test ${ELFS-PATH}/
+}
+
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/sc_net_test
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+FILES_${PN} = "\
+ ${bindir}/ \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "${sysconfdir}/init.d/sc_net_test","", d)} \
+ "
+SYSTEMD_SERVICE_${PN} = "sc_net_test.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
+
+RDEPENDS_${PN} = "libsctel libsoftap libatutils libsofttimer libnvram libscipc"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc_net_test/sc_net_test.init b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc_net_test/sc_net_test.init
new file mode 100755
index 0000000..37ddcca
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc_net_test/sc_net_test.init
@@ -0,0 +1,21 @@
+#!/bin/sh /etc/rc.common
+
+START=18
+STOP=85
+USE_PROCD=1
+
+logger -t sc_net_test
+
+start_service() {
+ procd_open_instance
+ procd_set_param command /usr/bin/sc_net_test
+ procd_set_param stdout 1 # forward stdout of the command to logd
+ procd_set_param stderr 1 # same for stderr
+ procd_set_param respawn
+ procd_close_instance
+}
+
+stop_service()
+{
+ echo "add clean code"
+}
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc_net_test/sc_net_test.service b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc_net_test/sc_net_test.service
new file mode 100755
index 0000000..eed759a
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-net-test/sc_net_test/sc_net_test.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=The sc_net_test service
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/sc_net_test
+Restart=always
+
+[Install]
+WantedBy=basic.target
+
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-softtimer-test/sc-softtimer-test.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-softtimer-test/sc-softtimer-test.bb
new file mode 100755
index 0000000..3d424a7
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sc-softtimer-test/sc-softtimer-test.bb
@@ -0,0 +1,49 @@
+DESCRIPTION = "sc_softtimer_test"
+
+DEPENDS = "libsofttimer"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/test:"
+SRC_URI = " \
+ file://sc_softtimer_test \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+do_compile() {
+ make -C sc_softtimer_test
+}
+
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0777 ${S}/sc_softtimer_test/sc_softtimer_test ${D}${bindir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/sc_softtimer_test/sc_softtimer_test ${ELFS-PATH}/
+}
+
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/sc_softtimer_test
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms-demo.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms-demo.bb
new file mode 100755
index 0000000..a3a8f8f
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms-demo.bb
@@ -0,0 +1,64 @@
+DESCRIPTION = "sms_demo"
+DEPENDS = "libsctel libscipc"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}:"
+SRC_URI = " \
+ file://test/sms_demo \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "file://sms_demo.init","", d)} \
+ ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "file://sms_demo.service","", d)} \
+ "
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+S_SRC_PATH = "${S}/test/sms_demo"
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+
+#inherit autotools pkgconfig systemd
+
+do_compile() {
+ make -C ${S_SRC_PATH}
+}
+
+do_install () {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S_SRC_PATH}/sms_demo ${D}${bindir}/
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','procd','true','false',d)}; then
+ install -Dm 0755 ${WORKDIR}/sms_demo.init ${D}${sysconfdir}/init.d/sms_demo
+ fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system
+ install -m 0644 ${WORKDIR}/sms_demo.service ${D}${systemd_unitdir}/system
+ fi
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S_SRC_PATH}/sms_demo ${ELFS-PATH}/
+}
+
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/sms_demo
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+FILES_${PN} = "\
+ ${bindir}/ \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "${sysconfdir}/init.d/sms_demo","", d)} \
+ "
+SYSTEMD_SERVICE_${PN} = "sms_demo.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
+
+RDEPENDS_${PN} = " libsctel libscipc"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms_demo/sms_demo.init b/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms_demo/sms_demo.init
new file mode 100755
index 0000000..f90548e
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms_demo/sms_demo.init
@@ -0,0 +1,21 @@
+#!/bin/sh /etc/rc.common
+
+START=18
+STOP=85
+USE_PROCD=1
+
+logger -t sms_demo
+
+start_service() {
+ procd_open_instance
+ procd_set_param command /usr/bin/sms_demo
+ procd_set_param stdout 1 # forward stdout of the command to logd
+ procd_set_param stderr 1 # same for stderr
+ procd_set_param respawn
+ procd_close_instance
+}
+
+stop_service()
+{
+ echo "add clean code"
+}
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms_demo/sms_demo.service b/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms_demo/sms_demo.service
new file mode 100755
index 0000000..1ae2304
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/sms-demo/sms_demo/sms_demo.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=The sms_demo service
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/sms_demo
+Restart=always
+
+[Install]
+WantedBy=basic.target
+
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/tel-svr/tel-svr.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/tel-svr/tel-svr.bb
index 5bc435a..cdf287e 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/tel-svr/tel-svr.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/tel-svr/tel-svr.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "tel_svr"
-DEPENDS = "libsoftap libsofttimer libnvram libatutils libscipc libtelsvr libtinyalsa libvoice"
+DEPENDS = "libsoftap libsofttimer libnvram libatutils libscipc libtelsvr libtinyalsa libvoice libmedia"
SECTION = "app"
LICENSE = "zte"
PV = "1.0.0"
@@ -71,4 +71,4 @@
SYSTEMD_SERVICE_${PN} = "tel_svr.service"
SYSTEMD_AUTO_ENABLE_${PN} = "enable"
-RDEPENDS_${PN} = " libsoftap libsofttimer libnvram libatutils libscipc libtinyalsa libvoice"
\ No newline at end of file
+RDEPENDS_${PN} = " libsoftap libsofttimer libnvram libatutils libscipc libtinyalsa libvoice libmedia"
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/tel-svr/tel-svr/tel_svr.sysvinit b/cap/zx297520v3/sources/meta-zxic/recipes-app/tel-svr/tel-svr/tel_svr.sysvinit
index ed3ec0f..0b21f98 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/tel-svr/tel-svr/tel_svr.sysvinit
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/tel-svr/tel-svr/tel_svr.sysvinit
@@ -6,11 +6,10 @@
DAEMON="tel_svr"
PIDFILE="/var/run/$DAEMON.pid"
EXEC="/usr/bin/tel_svr"
-EXEC_ARGS="-d /mnt/userdata -r /mnt/userdata/log.rule -t 1024 -n 10"
start() {
- echo -n "Starting $DAEMON... "
- start-stop-daemon --no-close -S -b -m -p $PIDFILE -x $EXEC -- $EXEC_ARGS
+ echo -n "Starting $DAEMON... "
+ start-stop-daemon --no-close -S -b -m -p $PIDFILE -x $EXEC
[ $? -eq 0 ] && echo "OK" || echo "ERROR"
}
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/tsctest/tsctest.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/tsctest/tsctest.bb
new file mode 100755
index 0000000..1044393
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/tsctest/tsctest.bb
@@ -0,0 +1,53 @@
+DESCRIPTION = "tsctest"
+
+DEPENDS = "libbsp"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/test:"
+SRC_URI = " \
+ file://tsctest \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+#编译
+do_compile() {
+ make -C tsctest
+}
+
+#库文件的安装
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/tsctest/tsctest ${D}${bindir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/tsctest/tsctest ${ELFS-PATH}/
+}
+#清库
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/tsctest
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+#rootfs包含的文件
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/usbtest/usbtest.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/usbtest/usbtest.bb
new file mode 100755
index 0000000..e6e2abf
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/usbtest/usbtest.bb
@@ -0,0 +1,50 @@
+DESCRIPTION = "usbtest"
+
+DEPENDS = "libbsp"
+DEPENDS += "libnvram"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/test:"
+SRC_URI = " \
+ file://usbtest \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+do_compile() {
+ make -C usbtest
+}
+
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0777 ${S}/usbtest/usbtest ${D}${bindir}/
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/usbtest/usbtest ${ELFS-PATH}/
+}
+
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/usbtest
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo.bb
new file mode 100755
index 0000000..97e4b60
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo.bb
@@ -0,0 +1,64 @@
+DESCRIPTION = "voice_demo"
+DEPENDS = "libvoice libmedia"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+inherit ${CLASS_COM}
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}:"
+SRC_URI = " \
+ file://test/voice_demo \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "file://voice_demo.init","", d)} \
+ ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "file://voice_demo.service","", d)} \
+ "
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+S_SRC_PATH = "${S}/test/voice_demo"
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+
+#inherit autotools pkgconfig systemd
+
+do_compile() {
+ make -C ${S_SRC_PATH}
+}
+
+do_install () {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S_SRC_PATH}/voice_demo ${D}${bindir}/
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','procd','true','false',d)}; then
+ install -Dm 0755 ${WORKDIR}/voice_demo.init ${D}${sysconfdir}/init.d/voice_demo
+ fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system
+ install -m 0644 ${WORKDIR}/voice_demo.service ${D}${systemd_unitdir}/system
+ fi
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S_SRC_PATH}/voice_demo ${ELFS-PATH}/
+}
+
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/voice_demo
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+FILES_${PN} = "\
+ ${bindir}/ \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "${sysconfdir}/init.d/voice_demo","", d)} \
+ "
+SYSTEMD_SERVICE_${PN} = "voice_demo.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
+
+RDEPENDS_${PN} = " libvoice libmedia"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo/voice_demo.init b/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo/voice_demo.init
new file mode 100755
index 0000000..ddb1a28
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo/voice_demo.init
@@ -0,0 +1,21 @@
+#!/bin/sh /etc/rc.common
+
+START=18
+STOP=85
+USE_PROCD=1
+
+logger -t voice_demo
+
+start_service() {
+ procd_open_instance
+ procd_set_param command /usr/bin/voice_demo
+ procd_set_param stdout 1 # forward stdout of the command to logd
+ procd_set_param stderr 1 # same for stderr
+ procd_set_param respawn
+ procd_close_instance
+}
+
+stop_service()
+{
+ echo "add clean code"
+}
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo/voice_demo.service b/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo/voice_demo.service
new file mode 100755
index 0000000..ef91f12
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/voice-demo/voice-demo/voice_demo.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=The voice_demo service
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/voice_demo
+Restart=always
+
+[Install]
+WantedBy=basic.target
+
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/voiceipc-mainctrl/voiceipc-mainctrl.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/voiceipc-mainctrl/voiceipc-mainctrl.bb
index f3be15f..e6e3d0b 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/voiceipc-mainctrl/voiceipc-mainctrl.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/voiceipc-mainctrl/voiceipc-mainctrl.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "voiceipc_mainctrl"
-DEPENDS = "libvoice"
+DEPENDS = "libnvram libsoftap libsofttimer libvoice"
SECTION = "app"
LICENSE = "zte"
PV = "1.0.0"
@@ -47,7 +47,7 @@
if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
install -Dm 0755 ${WORKDIR}/voiceipc_mainctrl.sysvinit ${D}${sysconfdir}/init.d/voiceipc_mainctrl
install -d ${D}${sysconfdir}/rcS.d
- ln -s ../init.d/voiceipc_mainctrl ${D}${sysconfdir}/rcS.d/S50voiceipc_mainctrl
+ ln -s ../init.d/voiceipc_mainctrl ${D}${sysconfdir}/rcS.d/S21voiceipc_mainctrl
fi
#install elfs
install -d ${ELFS-PATH}/
@@ -68,4 +68,4 @@
SYSTEMD_SERVICE_${PN} = "voiceipc_mainctrl.service"
SYSTEMD_AUTO_ENABLE_${PN} = "enable"
-RDEPENDS_${PN} = " libvoice"
+RDEPENDS_${PN} = "libnvram libsoftap libsofttimer libvoice"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/voiceipc-mainctrl/voiceipc-mainctrl/voiceipc_mainctrl.init b/cap/zx297520v3/sources/meta-zxic/recipes-app/voiceipc-mainctrl/voiceipc-mainctrl/voiceipc_mainctrl.init
index 1794f4c..c7c1cd9 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-app/voiceipc-mainctrl/voiceipc-mainctrl/voiceipc_mainctrl.init
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/voiceipc-mainctrl/voiceipc-mainctrl/voiceipc_mainctrl.init
@@ -1,6 +1,6 @@
#!/bin/sh /etc/rc.common
-START=50
+START=21
STOP=85
USE_PROCD=1
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-app/zxic-ramdump/zxic-ramdump.bb b/cap/zx297520v3/sources/meta-zxic/recipes-app/zxic-ramdump/zxic-ramdump.bb
new file mode 100755
index 0000000..8a873d2
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-app/zxic-ramdump/zxic-ramdump.bb
@@ -0,0 +1,49 @@
+DESCRIPTION = "zxic_ramdump"
+
+#DEPENDS = "zxic_ramdump"
+SECTION = "app"
+LICENSE = "zte"
+PV = "1.0.0"
+PR = "r0"
+
+#配置code路径信息。
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/platform:"
+SRC_URI = " \
+ file://zxic_ramdump \
+ "
+
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808"
+S = "${WORKDIR}"
+
+#引用公用头文件和编译选项。
+include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
+include ${BSPDIR}/sources/meta-zxic/conf/pub.inc
+CFLAGS_append = "${ZXIC_EXTRA_CFLAGS}"
+
+#编译
+do_compile() {
+ make -C zxic_ramdump
+}
+
+#库文件的安装
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/zxic_ramdump/zxic_ramdump ${D}${bindir}/
+
+
+ #install elfs
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/zxic_ramdump/zxic_ramdump ${ELFS-PATH}/
+}
+#清库
+do_cleanlibs () {
+ rm -fr ${ELFS-PATH}/zxic_ramdump
+}
+
+addtask cleanlibs after do_clean before do_cleansstate
+
+#rootfs包含的文件
+FILES_${PN} = "\
+ ${bindir}/ \
+ "
+
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/010-syslogd-recive-remote-log.patch b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/010-syslogd-recive-remote-log.patch
index 9f8f709..ba51af6 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/010-syslogd-recive-remote-log.patch
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/010-syslogd-recive-remote-log.patch
@@ -8,14 +8,14 @@
+{
+ int err, fd = -1;
+ struct addrinfo hints, *rp, *ai;
-+ int fd4 = -1;
-+
++ int fd4 = -1;
++
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_flags = AI_PASSIVE;
+
-+ err = getaddrinfo(NULL, "514", &hints, &rp);
++ err = getaddrinfo(NULL, "514", &hints, &rp);
+ if (err)
+ {
+ bb_perror_msg("lookup error, suspending inet service");
@@ -45,7 +45,7 @@
+ fd4 = fd;
+ }
+ freeaddrinfo(rp);
-+ return fd4;
++ return fd4;
+}
+
#if ENABLE_FEATURE_REMOTE_LOG
@@ -59,13 +59,13 @@
static void do_syslogd(void) NORETURN;
static void do_syslogd(void)
{
-+ struct pollfd *fdarray;
++ struct pollfd *fdarray;
+ unsigned int nfds = 0;
+ int nready = 0;
-+ unsigned int i = 0;
++ unsigned int i = 0;
+ int sock_read = 0;
-+ struct sockaddr_storage frominet;
-+ socklen_t len = sizeof(frominet);
++ struct sockaddr_storage frominet;
++ socklen_t len = sizeof(frominet);
#if ENABLE_FEATURE_REMOTE_LOG
llist_t *item;
#endif
@@ -74,20 +74,20 @@
alarm(G.markInterval);
#endif
+
-+ /* We add 3 = 1(klog) + 2(inet,inet6), even if they may stay unused. */
++ /* We add 3 = 1(klog) + 2(inet,inet6), even if they may stay unused. */
+ fdarray = (struct pollfd *)malloc(3 * sizeof (*fdarray));
+ if (fdarray == NULL)
-+ bb_perror_msg_and_die("can't allocate fd table");
-+
++ bb_perror_msg_and_die("can't allocate fd table");
++
xmove_fd(create_socket(), STDIN_FILENO);
-+ xmove_fd(create_inet_socket(), SOCKET_FILENO);
++ xmove_fd(create_inet_socket(), SOCKET_FILENO);
+
-+ // log
++ // log
+ fdarray[nfds].fd = STDIN_FILENO;
+ fdarray[nfds].events = POLLIN | POLLPRI;
+ nfds++;
+
-+ // socket
++ // socket
+ fdarray[nfds].fd = SOCKET_FILENO;
+ fdarray[nfds].events = POLLIN | POLLPRI;
+ nfds++;
@@ -127,7 +127,7 @@
- if (recvbuf[sz-1] != '\0' && recvbuf[sz-1] != '\n')
- break;
- sz--;
-+ nready = poll(fdarray, nfds, -1);
++ nready = poll(fdarray, nfds, -1);
+ if (nready == 0) /* ?? noop */
+ goto read_again;
+
@@ -137,22 +137,22 @@
+ timestamp_and_log_internal("syslogd poll");
+ goto read_again;
}
-+ for (i = 0; i < nfds; i++)
-+ {
-+ if (fdarray[i].revents & (POLLIN | POLLPRI))
-+ {
-+ if (fdarray[i].fd == -1)
-+ continue;
-+ else if (fdarray[i].fd == STDIN_FILENO)
-+ sz = read(fdarray[i].fd, recvbuf, MAX_READ - 1);
-+ else if (fdarray[i].fd == SOCKET_FILENO)
-+ sz = recvfrom(fdarray[i].fd, recvbuf, MAX_READ - 1, 0,
-+ (struct sockaddr *)&frominet, &len);
-+ if (sz < 0) {
-+ if (!bb_got_signal)
-+ bb_perror_msg("read from %s", _PATH_LOG);
-+ goto read_exit;
-+ }
++ for (i = 0; i < nfds; i++)
++ {
++ if (fdarray[i].revents & (POLLIN | POLLPRI))
++ {
++ if (fdarray[i].fd == -1)
++ continue;
++ else if (fdarray[i].fd == STDIN_FILENO)
++ sz = read(fdarray[i].fd, recvbuf, MAX_READ - 1);
++ else if (fdarray[i].fd == SOCKET_FILENO)
++ sz = recvfrom(fdarray[i].fd, recvbuf, MAX_READ - 1, 0,
++ (struct sockaddr *)&frominet, &len);
++ if (sz < 0) {
++ if (!bb_got_signal)
++ bb_perror_msg("read from %s", _PATH_LOG);
++ goto read_exit;
++ }
+
+ /* Drop trailing '\n' and NULs (typically there is one NUL) */
+ while (1) {
@@ -174,13 +174,13 @@
- if (memcmp(last_buf, recvbuf, sz) == 0)
- continue;
- last_sz = sz;
-+ if (fdarray[i].fd == STDIN_FILENO)
-+ {
-+ if ((option_mask32 & OPT_dup) && (sz == last_sz))
-+ if (memcmp(last_buf, recvbuf, sz) == 0)
-+ goto loop_again;
-+ last_sz = sz;
-+ }
++ if (fdarray[i].fd == STDIN_FILENO)
++ {
++ if ((option_mask32 & OPT_dup) && (sz == last_sz))
++ if (memcmp(last_buf, recvbuf, sz) == 0)
++ goto loop_again;
++ last_sz = sz;
++ }
#endif
#if ENABLE_FEATURE_REMOTE_LOG
- /* Stock syslogd sends it '\n'-terminated
@@ -222,59 +222,59 @@
- recvbuf[sz] = '\0'; /* ensure it *is* NUL terminated */
- split_escape_and_log(recvbuf, sz);
- }
-+ if (fdarray[i].fd == STDIN_FILENO)
-+ {
-+ /* Stock syslogd sends it '\n'-terminated
-+ * over network, mimic that */
-+ recvbuf[sz] = '\n';
++ if (fdarray[i].fd == STDIN_FILENO)
++ {
++ /* Stock syslogd sends it '\n'-terminated
++ * over network, mimic that */
++ recvbuf[sz] = '\n';
+
-+ /* We are not modifying log messages in any way before send */
-+ /* Remote site cannot trust _us_ anyway and need to do validation again */
-+ for (item = G.remoteHosts; item != NULL; item = item->link) {
-+ remoteHost_t *rh = (remoteHost_t *)item->data;
++ /* We are not modifying log messages in any way before send */
++ /* Remote site cannot trust _us_ anyway and need to do validation again */
++ for (item = G.remoteHosts; item != NULL; item = item->link) {
++ remoteHost_t *rh = (remoteHost_t *)item->data;
+
-+ if (rh->remoteFD == -1) {
-+ rh->remoteFD = try_to_resolve_remote(rh);
-+ if (rh->remoteFD == -1)
-+ continue;
-+ }
++ if (rh->remoteFD == -1) {
++ rh->remoteFD = try_to_resolve_remote(rh);
++ if (rh->remoteFD == -1)
++ continue;
++ }
+
-+ /* Send message to remote logger.
-+ * On some errors, close and set remoteFD to -1
-+ * so that DNS resolution is retried.
-+ */
-+ if (sendto(rh->remoteFD, recvbuf, sz+1,
-+ MSG_DONTWAIT | MSG_NOSIGNAL,
-+ &(rh->remoteAddr->u.sa), rh->remoteAddr->len) == -1
-+ ) {
-+ switch (errno) {
-+ case ECONNRESET:
-+ case ENOTCONN: /* paranoia */
-+ case EPIPE:
-+ close(rh->remoteFD);
-+ rh->remoteFD = -1;
-+ free(rh->remoteAddr);
-+ rh->remoteAddr = NULL;
-+ }
-+ }
-+ }
-+ }
++ /* Send message to remote logger.
++ * On some errors, close and set remoteFD to -1
++ * so that DNS resolution is retried.
++ */
++ if (sendto(rh->remoteFD, recvbuf, sz+1,
++ MSG_DONTWAIT | MSG_NOSIGNAL,
++ &(rh->remoteAddr->u.sa), rh->remoteAddr->len) == -1
++ ) {
++ switch (errno) {
++ case ECONNRESET:
++ case ENOTCONN: /* paranoia */
++ case EPIPE:
++ close(rh->remoteFD);
++ rh->remoteFD = -1;
++ free(rh->remoteAddr);
++ rh->remoteAddr = NULL;
++ }
++ }
++ }
++ }
+#endif
-+ if (!ENABLE_FEATURE_REMOTE_LOG || (option_mask32 & OPT_locallog)) {
-+ recvbuf[sz] = '\0'; /* ensure it *is* NUL terminated */
-+ split_escape_and_log(recvbuf, sz);
-+ }
-+ }
-+ else if (fdarray[i].revents & POLLNVAL)
-+ {
-+ timestamp_and_log_internal("syslogd poll nval");
-+ fdarray[i].fd = -1;
-+ }
-+ else if (fdarray[i].revents & POLLERR)
-+ timestamp_and_log_internal("syslogd poll err");
-+ else if (fdarray[i].revents & POLLHUP)
-+ timestamp_and_log_internal("syslogd poll hup");
-+ }
++ if (!ENABLE_FEATURE_REMOTE_LOG || (option_mask32 & OPT_locallog)) {
++ recvbuf[sz] = '\0'; /* ensure it *is* NUL terminated */
++ split_escape_and_log(recvbuf, sz);
++ }
++ }
++ else if (fdarray[i].revents & POLLNVAL)
++ {
++ timestamp_and_log_internal("syslogd poll nval");
++ fdarray[i].fd = -1;
++ }
++ else if (fdarray[i].revents & POLLERR)
++ timestamp_and_log_internal("syslogd poll err");
++ else if (fdarray[i].revents & POLLHUP)
++ timestamp_and_log_internal("syslogd poll hup");
++ }
} /* while (!bb_got_signal) */
-
+read_exit:
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/020-syslogd-filesize-and-filenum-parameter-nvcfg.patch b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/020-syslogd-filesize-and-filenum-parameter-nvcfg.patch
new file mode 100755
index 0000000..39f45df
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/020-syslogd-filesize-and-filenum-parameter-nvcfg.patch
@@ -0,0 +1,43 @@
+--- /sysklogd/syslogd.c 2021-01-01 21:37:14.000000000 +0800
++++ /sysklogd/syslogd.c 2023-05-16 10:41:37.747299297 +0800
+@@ -167,6 +167,7 @@
+ #define SYSLOG_NAMES_CONST
+ #include <syslog.h>
+ */
++#include "cfg_api.h"
+ #ifndef _PATH_LOG
+ #define _PATH_LOG "/dev/log"
+ #endif
+@@ -1131,6 +1132,8 @@ int syslogd_main(int argc UNUSED_PARAM,
+ {
+ int opts;
+ char OPTION_DECL;
++ char nv_log_rotatecnt[32] = {0};
++ char nv_log_filesize[32] = {0}; //µ¥Î»M
+ #if ENABLE_FEATURE_REMOTE_LOG
+ llist_t *remoteAddrList = NULL;
+ #endif
+@@ -1159,10 +1162,19 @@ int syslogd_main(int argc UNUSED_PARAM,
+ G.logLevel = xatou_range(opt_l, 1, 8);
+ //if (opts & OPT_small) // -S
+ #if ENABLE_FEATURE_ROTATE_LOGFILE
+- if (opts & OPT_filesize) // -s
+- G.logFileSize = xatou_range(opt_s, 0, INT_MAX/1024) * 1024;
+- if (opts & OPT_rotatecnt) // -b
+- G.logFileRotate = xatou_range(opt_b, 0, 99);
++ if (!sc_cfg_get("syslog_file_size", nv_log_filesize, sizeof(nv_log_filesize)))
++ G.logFileSize = xatou_range(nv_log_filesize, 0, INT_MAX/1024/1024) * 1024 * 1024;
++ else {
++ if (opts & OPT_filesize) // -s
++ G.logFileSize = xatou_range(opt_s, 0, INT_MAX/1024) * 1024;
++ }
++ if (!sc_cfg_get("syslog_file_num", nv_log_rotatecnt, sizeof(nv_log_rotatecnt)))
++ G.logFileRotate = xatou_range(nv_log_rotatecnt, 0, 99);
++ else {
++ if (opts & OPT_rotatecnt) // -b
++ G.logFileRotate = xatou_range(opt_b, 0, 99);
++ }
++
+ #endif
+ #if ENABLE_FEATURE_IPC_SYSLOG
+ if (opt_C) // -Cn
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb
index 1949669..14a6595 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb
@@ -3,6 +3,7 @@
SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
file://busybox-1.33.1/busybox-udhcpc-no_deconfig.patch \
file://busybox-1.33.1/010-syslogd-recive-remote-log.patch \
+ file://busybox-1.33.1/020-syslogd-filesize-and-filenum-parameter-nvcfg.patch \
file://find-touchscreen.sh \
file://busybox-cron \
file://busybox-httpd \
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox_1.33.1.inc b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox_1.33.1.inc
old mode 100644
new mode 100755
index 3791da8..ae4d499
--- a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox_1.33.1.inc
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/busybox_1.33.1.inc
@@ -3,7 +3,7 @@
HOMEPAGE = "https://www.busybox.net"
BUGTRACKER = "https://bugs.busybox.net/"
-DEPENDS += "kern-tools-native virtual/crypt"
+DEPENDS += "kern-tools-native virtual/crypt libnvram"
# bzip2 applet in busybox is based on lightly-modified bzip2-1.0.4 source
# the GPL is version 2 only
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/files/syslog.conf b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/files/syslog.conf
old mode 100644
new mode 100755
index 0ca1743..6c89bf0
--- a/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/files/syslog.conf
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-core/busybox/files/syslog.conf
@@ -1,2 +1,4 @@
# /etc/syslog.conf Configuration file for busybox's syslogd utility
-user.* /var/log/syslogd.log
+lpr.* /var/log/capsyslogd.log #capºËÓ¦ÓÃlog
+mail.* /var/log/apsyslogd.log #apºËÓ¦ÓÃlog
+user.* /var/log/kernel.log #capºËºÍapÄÚºËlog
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc-normal-defconfig b/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc-normal-defconfig
index 14b0f1a..a8e91a8 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc-normal-defconfig
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc-normal-defconfig
@@ -2950,8 +2950,8 @@
#
# Debug Oops, Lockups and Hangs
#
-# CONFIG_PANIC_ON_OOPS is not set
-CONFIG_PANIC_ON_OOPS_VALUE=0
+CONFIG_PANIC_ON_OOPS=y
+CONFIG_PANIC_ON_OOPS_VALUE=1
CONFIG_PANIC_TIMEOUT=0
# CONFIG_SOFTLOCKUP_DETECTOR is not set
# CONFIG_DETECT_HUNG_TASK is not set
@@ -2971,6 +2971,11 @@
CONFIG_RAMDUMP=y
#hong.liu modify for close ramdump
#CONFIG_RAMDUMP_USER=y
+#CONFIG_RAMDUMP_USER=y
+#CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK=y
+#CONFIG_RAMDUMP_EMMC=y
+#CONFIG_RAMDUMP_EMMC_BASE=0x40000
+#CONFIG_RAMDUMP_EMMC_SIZE=0x600000
#hong.liu modify for close ramdump
#
# Lock Debugging (spinlocks, mutexes, etc...)
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.init b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.init
new file mode 100755
index 0000000..2eccd3d
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.init
@@ -0,0 +1,21 @@
+#!/bin/sh /etc/rc.common
+
+START=21
+STOP=85
+USE_PROCD=1
+
+logger -t tee-supplicant
+
+start_service() {
+ procd_open_instance
+ procd_set_param command /usr/sbin/tee-supplicant
+ procd_set_param stdout 0 # forward stdout of the command to logd
+ procd_set_param stderr 0 # same for stderr
+ procd_set_param respawn
+ procd_close_instance
+}
+
+stop_service()
+{
+ echo "add clean code"
+}
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.service b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.service
new file mode 100755
index 0000000..ffb54d3
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=TEE Supplicant
+
+[Service]
+User=root
+EnvironmentFile=-/etc/default/tee-supplicant
+ExecStart=/usr/sbin/tee-supplicant $OPTARGS
+
+[Install]
+WantedBy=basic.target
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.sysvinit b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.sysvinit
new file mode 100755
index 0000000..96f070e
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client/tee-supplicant.sysvinit
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Run the daemon
+#
+
+DAEMON="tee-supplicant"
+PIDFILE="/var/run/$DAEMON.pid"
+EXEC="/usr/sbin/tee-supplicant"
+EXEC_ARGS=""
+
+
+start() {
+ echo -n "Starting $DAEMON... "
+ start-stop-daemon --no-close -S -b -m -p $PIDFILE -x $EXEC -- $EXEC_ARGS
+ [ $? -eq 0 ] && echo "OK" || echo "ERROR"
+}
+
+stop() {
+ echo -n "Stopping $DAEMON... "
+ start-stop-daemon -K -p $PIDFILE
+ [ $? -eq 0 ] && echo "OK" || echo "ERROR"
+}
+
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ start|stop|restart)
+ "$1"
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit $?
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client_git.bb b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client_git.bb
new file mode 100755
index 0000000..fb2162b
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-client_git.bb
@@ -0,0 +1,74 @@
+SUMMARY = "OP-TEE Client API"
+DESCRIPTION = "Open Portable Trusted Execution Environment - Normal World Client side of the TEE"
+HOMEPAGE = "https://www.op-tee.org/"
+
+LICENSE = "BSD"
+LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=69663ab153298557a59c67a60a743e5b"
+
+#PV = "3.8.0+git${SRCPV}"
+
+require optee.inc
+
+CLASS_COM = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
+"
+
+inherit python3native ${CLASS_COM}
+
+#SRCREV = "be4fa2e36f717f03ca46e574aa66f697a897d090"
+#SRC_URI = " \
+# git://github.com/OP-TEE/optee_client.git \
+# file://tee-supplicant.service \
+#"
+
+#S = "${WORKDIR}/git"
+
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/sdk/optee:"
+SRC_URI = " \
+ file://optee-client \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "file://tee-supplicant.init","", d)} \
+ ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "file://tee-supplicant.service","", d)} \
+ ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "file://tee-supplicant.sysvinit","", d)} \
+ "
+S = "${WORKDIR}/optee-client"
+
+SYSTEMD_SERVICE_${PN} = "tee-supplicant.service"
+
+do_install() {
+ oe_runmake install
+ install -D -p -m0755 ${S}/out/export/usr/sbin/tee-supplicant ${D}${sbindir}/tee-supplicant
+ install -D -p -m0644 ${S}/out/export/usr/lib/libteec.so.1.0 ${D}${libdir}/libteec.so.1.0
+ ln -sf libteec.so.1.0 ${D}${libdir}/libteec.so
+ ln -sf libteec.so.1.0 ${D}${libdir}/libteec.so.1
+ install -d ${D}${includedir}
+ install -p -m0644 ${S}/out/export/usr/include/*.h ${D}${includedir}
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','procd','true','false',d)}; then
+ install -Dm 0755 ${WORKDIR}/tee-supplicant.init ${D}${sysconfdir}/init.d/tee-supplicant
+ fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ sed -i -e s:/etc:${sysconfdir}:g \
+ -e s:/usr/bin:${bindir}:g \
+ ${WORKDIR}/tee-supplicant.service
+ install -D -p -m0644 ${WORKDIR}/tee-supplicant.service ${D}${systemd_system_unitdir}/tee-supplicant.service
+ fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
+ install -Dm 0755 ${WORKDIR}/tee-supplicant.sysvinit ${D}${sysconfdir}/init.d/tee-supplicant
+ install -d ${D}${sysconfdir}/rcS.d
+ ln -s ../init.d/tee-supplicant ${D}${sysconfdir}/rcS.d/S21tee-supplicant
+ fi
+ #install elfs
+
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${D}${libdir}/* ${ELFS-PATH}/
+ install -m 0755 ${D}${sbindir}/tee-supplicant ${ELFS-PATH}/
+}
+FILES_${PN}-dev += "/usr/lib/libteec.so"
+FILES_${PN} += "${libdir}/ \
+ ${bindir}/ \
+ ${@bb.utils.contains("DISTRO_FEATURES", "procd", "${sysconfdir}/","", d)} \
+ ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "${sysconfdir}/","", d)} \
+ "
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-example_git.bb b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-example_git.bb
new file mode 100755
index 0000000..09e740e
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-example_git.bb
@@ -0,0 +1,56 @@
+SUMMARY = "OP-TEE examples"
+DESCRIPTION = "Open Portable Trusted Execution Environment - Sample Applications"
+HOMEPAGE = "https://github.com/linaro-swg/optee_examples"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=cd95ab417e23b94f381dafc453d70c30"
+
+# PV = "3.8.0+git${SRCPV}"
+
+DEPENDS = "optee-client python3-pycryptodomex-native"
+
+inherit python3native
+
+require optee.inc
+
+#SRC_URI = "git://github.com/linaro-swg/optee_examples.git"
+#SRCREV = "559b2141c16bf0f57ccd72f60e4deb84fc2a05b0"
+
+#S = "${WORKDIR}/git"
+
+FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/test:"
+SRC_URI = " \
+ file://opteetest\
+ "
+S = "${WORKDIR}/opteetest"
+
+OPTEE_CLIENT_EXPORT = "${STAGING_DIR_HOST}${prefix}"
+TEEC_EXPORT = "${STAGING_DIR_HOST}${prefix}"
+TA_DEV_KIT_DIR = "${STAGING_INCDIR}/optee/export-user_ta"
+
+EXTRA_OEMAKE = " TA_DEV_KIT_DIR=${TA_DEV_KIT_DIR} \
+ OPTEE_CLIENT_EXPORT=${OPTEE_CLIENT_EXPORT} \
+ TEEC_EXPORT=${TEEC_EXPORT} \
+ HOST_CROSS_COMPILE=${TARGET_PREFIX} \
+ TA_CROSS_COMPILE=${TARGET_PREFIX} \
+ V=1 \
+ "
+
+do_compile() {
+ oe_runmake
+}
+
+do_install () {
+ mkdir -p ${D}${nonarch_base_libdir}/optee_armtz
+ mkdir -p ${D}${bindir}
+ install -D -p -m0755 ${S}/out/ca/* ${D}${bindir}
+
+ install -d ${ELFS-PATH}/
+ install -m 0755 ${S}/out/ca/* ${ELFS-PATH}/
+
+}
+
+FILES_${PN} += "${nonarch_base_libdir}/optee_armtz/"
+INSANE_SKIP_${PN} = "ldflags"
+# Imports machine specific configs from staging to build
+PACKAGE_ARCH = "${MACHINE_ARCH}"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-os/0001-allow-setting-sysroot-for-libgcc-lookup.patch b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-os/0001-allow-setting-sysroot-for-libgcc-lookup.patch
new file mode 100755
index 0000000..17127d0
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee-os/0001-allow-setting-sysroot-for-libgcc-lookup.patch
@@ -0,0 +1,13 @@
+diff --git a/mk/gcc.mk b/mk/gcc.mk
+index fc38c4d..77b8d74 100644
+--- a/mk/gcc.mk
++++ b/mk/gcc.mk
+@@ -12,7 +12,7 @@ nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \
+ -print-file-name=include 2> /dev/null)
+
+ # Get location of libgcc from gcc
+-libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \
++libgcc$(sm) := $(shell $(CC$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \
+ -print-libgcc-file-name 2> /dev/null)
+
+ # Define these to something to discover accidental use
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee.inc b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee.inc
new file mode 100755
index 0000000..81ac81e
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-security/optee/optee.inc
@@ -0,0 +1,2 @@
+##COMPATIBLE_MACHINE ?= "zx298501"
+# Please add supported machines below or set it in .bbappend or .conf
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-pinctrl.dtsi b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-pinctrl.dtsi
index d5393de..5006bfa 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-pinctrl.dtsi
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-pinctrl.dtsi
@@ -47,7 +47,7 @@
function = "SD1";
drive-strength = <STRENGTH_LEVEL_1>;
- bias-pull-down;
+ //bias-pull-down;
//input-schmitt-enable;
};
sd0_sd0: sd0_sd0 {
@@ -59,6 +59,21 @@
//input-schmitt-enable;
};
+ ext_int3_pins: ext_int3 {
+ pins = "EXT_INT3";
+ function = "EXT_INT3";
+
+// drive-strength = <STRENGTH_LEVEL_3>;
+ bias-pull-up;
+// input-schmitt-disable;
+ };
+ gpio_50_pins: gpio50 {
+ pins = "EXT_INT3";
+ function = "BGPIO";
+ drive-strength = <STRENGTH_LEVEL_3>;
+ //bias-pull-up;
+// input-schmitt-disable;
+ };
ext_int4_pins: ext_int4 {
pins = "EXT_INT4";
function = "EXT_INT4";
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc.dts b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc.dts
index 3d42ca0..a227976 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc.dts
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc.dts
@@ -53,13 +53,6 @@
bootargs = "console=ttyS1,921600n8 earlycon rdinit=/sbin/init ubi.block=0,vol_rootfs root=/dev/ubiblock0_0 rootfstype=squashfs ";
};
- memory {
- #address-cells = <2>;
- #size-cells = <2>;
-
- device_type = "memory";
- reg = <0x0 DDR_BASE_ADDR_CAP 0x0 DDR_BASE_LEN_CAP>;
- };
};
&qspi {
@@ -89,14 +82,14 @@
};
&soc_ssp1 {
- status = "disabled";
+ status = "okay";
};
&spidev0 {
status = "okay";
};
&spidev1 {
- status = "disabled";
+ status = "okay";
};
&soc_uart0 {
@@ -143,3 +136,8 @@
&gmac {
status = "okay";
};
+
+&xp2xp {
+ status = "okay";
+};
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
index 4fcb21d..a115383 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
@@ -284,6 +284,20 @@
interrupts = <EX9_INT IRQ_TYPE_EDGE_FALLING>;
};
+ xp2xp: hal_xp2xp {
+ compatible = "zte,hal_xp2xp";
+ pinctrl-names = "gpio50", "ext_int3";
+ pinctrl-0 = <&gpio_50_pins>;
+ pinctrl-1 = <&ext_int3_pins>;
+ gpios = <&bgpio 50 GPIO_ACTIVE_HIGH
+ &bgpio 53 GPIO_ACTIVE_HIGH
+ &bgpio 130 GPIO_ACTIVE_HIGH
+ &bgpio 131 GPIO_ACTIVE_HIGH>;
+ //interrupt-parent = <&ext8in1>;
+ interrupts = <GIC_SPI EX3_INT IRQ_TYPE_EDGE_RISING>;
+ status = "disabled";
+ };
+
clkc: clock-controller@13B000 {
compatible = "zte,zx297520v3-colck";
reg = <0x0 0x13B000 0x0 0x0001000>, /* top */
@@ -327,9 +341,7 @@
interrupts = <GIC_SPI UART0_MIX_INT IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clkc UART0_WCLK>, <&clkc UART0_PCLK>;
clock-names = "uartclk", "apb_pclk";
- //xf.li@20230508 add for open uart1(zxw-uart0) start
- status = "okay";
- //xf.li@20230508 add for open uart1(zxw-uart0) end
+ status = "disabled";
};
soc_uart1: uart@1408000 {
@@ -527,7 +539,6 @@
<&bgpio 26 GPIO_ACTIVE_HIGH>,/*clk*/
<&bgpio 28 GPIO_ACTIVE_HIGH>,/*tx*/
<&bgpio 27 GPIO_ACTIVE_LOW>;/*rx*/
- enable_dma =<1>;
dma_tx = <4>;
dma_rx = <5>;
@@ -545,6 +556,9 @@
<&bgpio 54 GPIO_ACTIVE_HIGH>;/*int7 status*/
reg = <0>;
mode = <0>;
+ enable_dma = <1>;
+ enable_trans_gap = <0>;
+ trans_gap_num = <0>;
};
/*spi_test:test@0{
compatible = "linux,spi-test";
@@ -557,7 +571,7 @@
};
soc_ssp1: ssp@1410000 {
- compatible = "zte,zx29_ssp_slave";
+ compatible = "zte,zx29_ssp";
reg = <0x0 0x1410000 0x0 0x00001000>;
interrupts = <GIC_SPI SSP1_INT IRQ_TYPE_LEVEL_HIGH>;
clock-frequency = <52000000>;
@@ -571,7 +585,6 @@
<&bgpio 88 GPIO_ACTIVE_LOW>,/*clk*/
<&bgpio 90 GPIO_ACTIVE_LOW>,/*tx*/
<&bgpio 89 GPIO_ACTIVE_LOW>;/*rx*/
- enable_dma = <1>;
dma_tx = <15>;
dma_rx = <16>;
@@ -586,6 +599,9 @@
<&bgpio 51 GPIO_ACTIVE_HIGH>;/*int4 status*/
reg = <0>;
mode = <0>;
+ enable_dma = <1>;
+ enable_trans_gap = <0>;
+ trans_gap_num = <0>;
};
};
@@ -696,7 +712,17 @@
<0x0 IRAM_BASE_ADDR_TPC 0x0 0x400>;
status = "okay";
};
-
+ tsc: tsc@e1e04800 {
+ compatible = "zte,zx29-tsc";
+ reg = <0x0 IRAM_BASE_ADDR_TPC 0x0 0x400>;
+ status = "okay";
+ };
+ };
+ firmware {
+ optee {
+ compatible = "linaro,optee-tz";
+ method = "icp";
+ };
};
};
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/dma/sc/zx297520v3_dma.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/dma/sc/zx297520v3_dma.c
index 7f609c0..a1ebb94 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/dma/sc/zx297520v3_dma.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/dma/sc/zx297520v3_dma.c
@@ -1088,7 +1088,15 @@
dmac_ptr->dma_chan[channel_id].desc.callback(dmac_ptr->dma_chan[channel_id].desc.callback_param);
#else
/* schedule tasklet on this channel */
+ #ifdef _USE_VEHICLE_DC
+ if((channel_id == DMA_CH_UART0_RX) || (channel_id == DMA_CH_UART2_RX)){
+ if (dmac_ptr->dma_chan[channel_id].desc.callback)
+ dmac_ptr->dma_chan[channel_id].desc.callback(dmac_ptr->dma_chan[channel_id].desc.callback_param);
+ }else
+ tasklet_schedule(&dmac_ptr->dma_chan[channel_id].tasklet);
+ #else
tasklet_schedule(&dmac_ptr->dma_chan[channel_id].tasklet);
+ #endif
#endif
}
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/i2c/busses/i2c-zx29.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/i2c/busses/i2c-zx29.c
index d062870..4c3cb50 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/i2c/busses/i2c-zx29.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/i2c/busses/i2c-zx29.c
@@ -390,19 +390,17 @@
root = debugfs_create_dir(i2c->name, NULL);
if (!root) {
dev_err(i2c->dev, "debugfs_create_dir err=%d\n", IS_ERR(root));
- goto err;
+ return;
}
node = debugfs_create_file("regs", S_IRUGO | S_IWUGO, root, i2c, &debugfs_regs_fops);
if (!node) {
dev_err(i2c->dev, "debugfs_create_file err=%d\n", IS_ERR(node));
- goto err;
+ return;
}
debug_zx29_i2c[i2c->id] = i2c;
-err:
- dev_err(i2c->dev, "debugfs err=%d\n", IS_ERR(node));
}
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/Makefile b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/Makefile
index d672ed8..dc7bd70 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/Makefile
@@ -110,6 +110,7 @@
obj-$(CONFIG_MENELAUS) += menelaus.o
obj-$(CONFIG_MFD_ZX234290) += zx234290-i2c.o zx234290-regulator.o zx234290-regulator-wrapper.o
+obj-$(CONFIG_MFD_ZX234290) += zx234290-adc.o
obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
obj-$(CONFIG_MFD_TWL4030_AUDIO) += twl4030-audio.o
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-adc.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-adc.c
new file mode 100644
index 0000000..830630d
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-adc.c
@@ -0,0 +1,428 @@
+#include <linux/init.h> /* For init/exit macros */
+#include <linux/module.h> /* For MODULE_ marcros */
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/platform_device.h>
+
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/cdev.h>
+#include <linux/delay.h>
+#include <linux/mutex.h>
+#include <linux/kthread.h>
+#include <linux/rtc.h>
+#include <linux/mfd/zx234290.h>
+//#include <mach/spinlock.h>
+#include <linux/soc/zte/spinlock.h>
+//#include <linux/wakelock.h>
+#include <linux/pm_wakeup.h>
+
+#define ZX234290_VBAT_ADC_COMPENDATE_VALUE 50
+typedef enum adc_channel
+{
+ ADC_CHANNEL_VBAT_ADC = 0,
+ ADC_CHANNEL_VADC2 = 1, /* 01 */
+ ADC_CHANNEL_VADC1 = 2, /* 10 */
+ MAX_ADC_CHANNEL
+}zx234290_adc_channel;
+
+/*******************************************************************************
+ * Function:zx234290_adc_correspond
+ * Description:adjust battery voltage according to compensate value
+ * Parameters:
+ * Input:
+ * channel: adc channel
+ * value:battery voltage needed be compensated
+ * Output:
+ *
+ * Returns:
+ * 0: success
+ * -1:failed
+ *
+ * Others:
+ ********************************************************************************/
+static int zx234290_adc_correspond(zx234290_adc_channel channel, int *value)
+{
+ int nTemp;
+
+ switch (channel)
+ {
+ case ADC_CHANNEL_VBAT_ADC:
+ {
+ nTemp = (int)((uint64_t)(5000-0)*(*value)/4096);
+ *value = nTemp + 0;//ZX234290_VBAT_ADC_COMPENDATE_VALUE; // compensate the battery voltage value
+ break;
+ }
+ case ADC_CHANNEL_VADC1:
+ {
+ nTemp = (int)((uint64_t)(5000-0)*(*value)/4096);
+ *value = nTemp + 0;
+ break;
+ }
+
+ case ADC_CHANNEL_VADC2:
+ {
+ nTemp = (int)((uint64_t)(5000-0)*(*value)/4096);
+ *value = nTemp + 0;
+ break;
+ }
+ default:
+ {
+ return -1;
+ }
+ }
+
+
+ return 0;
+
+}
+
+/*******************************************************************************
+ * Function:zx234290_adc_read_vbat
+ * Description:read vbat adc value
+ * Parameters:
+ * Input:
+ *
+ * Output:
+ *
+ * Returns:
+ * nTempAdc:the value of vbat adc
+ * Others:
+ ********************************************************************************/
+static int zx234290_adc_read_vbat(void)
+{
+ int nRet;
+ int nTempAdc = 0;
+ unsigned char msb=0, lsb=0;
+
+ /* read msb */
+ //nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC_VBATMSB, &msb);
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_VBATADC_MSB, &msb);
+ if (nRet != 0)
+ {
+ return nRet;
+ }
+
+ /* read lsb */
+ //nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC_VBATLSB, &lsb);
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_VBATADC_LSB, &lsb);
+ if (nRet != 0)
+ {
+ return nRet;
+ }
+ nTempAdc = (int)msb;
+ nTempAdc = ((nTempAdc<<4)|lsb>>4);
+
+ return nTempAdc;
+}
+
+/*******************************************************************************
+ * Function:zx234290_adc_read_adc1
+ * Description:read the channel of adc1 value
+ * Parameters:
+ * Input:
+ *
+ * Output:
+ *
+ * Returns:
+ * nTempAdc:the value of adc1 channel
+ * Others:
+ ********************************************************************************/
+static int zx234290_adc_read_adc1(void)
+{
+ int nRet;
+ int nTempAdc = 0;
+ unsigned char msb=0, lsb=0;
+
+ /* read msb */
+ //nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC1MSB, &msb);
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC1_MSB, &msb);
+ if (nRet != 0)
+ {
+ return nRet;
+ }
+
+ /* read lsb */
+ //nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC1LSB, &lsb);
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC1_LSB, &lsb);
+ if (nRet != 0)
+ {
+ return nRet;
+ }
+
+ nTempAdc = (int)msb;
+ nTempAdc = ((nTempAdc<<4)|lsb>>4);
+
+ return nTempAdc;
+}
+
+/*******************************************************************************
+ * Function:zx234290_adc_read_adc2
+ * Description:read the channel of adc2value
+ * Parameters:
+ * Input:
+ *
+ * Output:
+ *
+ * Returns:
+ * nTempAdc:the value of adc2 channel
+ * Others:
+ ********************************************************************************/
+static int zx234290_adc_read_adc2(void)
+{
+ int nRet;
+ int nTempAdc = 0;
+ unsigned char msb=0, lsb=0;
+
+ /* read msb */
+ //nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC2MSB, &msb);
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC2_MSB, &msb);
+ if (nRet != 0)
+ {
+ return nRet;
+ }
+
+ /* read lsb */
+ //nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC2LSB, &lsb);
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_ADC2_LSB, &lsb);
+ if (nRet != 0)
+ {
+ return nRet;
+ }
+
+ nTempAdc = (int)msb;
+ nTempAdc = ((nTempAdc<<4)|lsb>>4);
+
+ return nTempAdc;
+}
+
+
+/**************************************************************************
+* Function: zx234290_adc_read
+* Description: read ADC value according to adc channel
+* Parameters:
+* Input:
+* channel:which channel want to be read
+*
+* Output:
+* value:the adc value correspond to channel
+* Returns:
+* 0 if success, not 0 if faile
+* Others: None
+**************************************************************************/
+extern struct wakeup_source * adc_wakelock;
+static int zx234290_adc_read(zx234290_adc_channel channel, int *value)
+{
+ int nRet = 0;
+ int nTempAdc = 0;
+ int reg_val=0, mask=0;
+ int num=1;
+ unsigned char status_a=0;
+ unsigned char content =0;
+ if(channel >= MAX_ADC_CHANNEL)
+ {
+ return -1;
+ }
+
+ soft_spin_lock(ADC_SFLOCK);
+ __pm_stay_awake(adc_wakelock);
+ if (channel != ADC_CHANNEL_VBAT_ADC)
+ {
+ /* select channel */
+ reg_val = channel << 3; /* ×óÒÆ3λ£¬Î»¿í 2λ */
+ mask = 0x18;
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_SYS_CTRL, &content);
+ if (nRet != 0)
+ {
+ __pm_relax(adc_wakelock);
+ soft_spin_unlock(ADC_SFLOCK);
+ return nRet;
+ }
+ content &= ~mask;
+ content |= reg_val;
+ nRet = zx234290_i2c_write_simple(ZX234290_REG_ADDR_SYS_CTRL, &content);
+ if (nRet != 0)
+ {
+ __pm_relax(adc_wakelock);
+ soft_spin_unlock(ADC_SFLOCK);
+ return nRet;
+ }
+ }
+#if 0
+ /* set start bit */
+ reg_val = 1 << 5; /* ¸ÃλÖà 1 */
+ mask = 0x20;
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_SYS_CTRL, &content);
+ if (nRet != 0)
+ {
+ return nRet;
+ }
+ content &= ~mask;
+ content |= reg_val;
+ nRet = zx234290_i2c_write_simple(ZX234290_REG_ADDR_SYS_CTRL, &content);
+ if (nRet != 0)
+ {
+ return nRet;
+ }
+
+ msleep(30); /* ÑÓʱ30ms */
+#else
+ reg_val = 1 << 5; /* ¸ÃλÖà 1 */
+ mask = 0x20;
+ for(num=1; num <= 50; num++)
+ {
+ /* set start bit */
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_SYS_CTRL, &content);
+ if (nRet != 0)
+ {
+ __pm_relax(adc_wakelock);
+ soft_spin_unlock(ADC_SFLOCK);
+ return nRet;
+ }
+ content &= ~mask;
+ content |= reg_val;
+ nRet = zx234290_i2c_write_simple(ZX234290_REG_ADDR_SYS_CTRL, &content);
+ if (nRet != 0)
+ {
+ __pm_relax(adc_wakelock);
+ soft_spin_unlock(ADC_SFLOCK);
+ return nRet;
+ }
+ udelay(500);
+ /*read status_A*/
+ nRet = zx234290_i2c_read_simple(ZX234290_REG_ADDR_STSA, &status_a);
+ if (nRet != 0)
+ {
+ __pm_relax(adc_wakelock);
+ soft_spin_unlock(ADC_SFLOCK);
+ return nRet;
+ }
+ if(status_a & 0x04)
+ {
+// printk( "get adc,break num =%d ...\n", num);
+ break;
+ }
+ }
+#endif
+ /* ÕâÀïÒªµÈÖжÏÀ´ ²ÅÄܶÁ */
+ switch (channel) {
+ case ADC_CHANNEL_VBAT_ADC:
+ nTempAdc = zx234290_adc_read_vbat();
+ break;
+ case ADC_CHANNEL_VADC1:
+ nTempAdc = zx234290_adc_read_adc1();
+ break;
+ case ADC_CHANNEL_VADC2:
+ nTempAdc = zx234290_adc_read_adc2();
+ break;
+ default:
+ break;
+ }
+
+ if (nTempAdc < 0)
+ {
+ __pm_relax(adc_wakelock);
+ soft_spin_unlock(ADC_SFLOCK);
+ return 0;
+ }
+
+ /* ת»» */
+ zx234290_adc_correspond(channel, &nTempAdc);
+ *value = (int)nTempAdc;
+ __pm_relax(adc_wakelock);
+ soft_spin_unlock(ADC_SFLOCK);
+ //pmic_AdcUnlock();
+ return nRet;
+}
+
+
+
+/**************************************************************************
+* Function: get_battery_voltage
+* Description: get battery voltage
+* Parameters:
+* Input:
+*
+*
+* Output:
+*
+* Returns:
+* avgValue:battery voltage
+* Others: None
+**************************************************************************/
+uint get_battery_voltage(void)
+{
+ int counter = 3;
+ int index=0;
+ int tmpValue=0,totalValue=0;
+ uint avgValue;
+ for(index = 0; index < counter; index++)
+ {
+ zx234290_adc_read(ADC_CHANNEL_VBAT_ADC, &tmpValue);
+ totalValue += tmpValue;
+ }
+ avgValue = (uint)(totalValue / counter);
+ return avgValue;
+}
+EXPORT_SYMBOL(get_battery_voltage);
+
+/**************************************************************************
+* Function: get_adc1_voltage
+* Description: get adc1 voltage
+* Parameters:
+* Input:
+*
+*
+* Output:
+*
+* Returns:
+* avgValue:adc voltage
+* Others: None
+**************************************************************************/
+uint get_adc1_voltage(void)
+{
+ int counter = 3;
+ int index=0;
+ int tmpValue=0,totalValue=0;
+ uint avgValue;
+ for(index = 0; index < counter; index++)
+ {
+ zx234290_adc_read(ADC_CHANNEL_VADC1, &tmpValue);
+ totalValue += tmpValue;
+ }
+ avgValue = (uint)(totalValue / counter);
+ return avgValue;
+}
+EXPORT_SYMBOL(get_adc1_voltage);
+
+/**************************************************************************
+* Function: get_adc2_voltage
+* Description: get adc2 voltage
+* Parameters:
+* Input:
+*
+*
+* Output:
+*
+* Returns:
+* avgValue:adc2 voltage
+* Others: None
+**************************************************************************/
+//extern struct wake_lock adc_wake_lock;
+uint get_adc2_voltage(void)
+{
+ int counter = 3;
+ int index=0;
+ int tmpValue=0,totalValue=0;
+ uint avgValue;
+ //wake_lock(&adc_wake_lock);
+ for(index = 0; index < counter; index++)
+ {
+ zx234290_adc_read(ADC_CHANNEL_VADC2, &tmpValue);
+ totalValue += tmpValue;
+ }
+ //wake_unlock(&adc_wake_lock);
+ avgValue = (uint)(totalValue / counter);
+ return avgValue;
+}
+EXPORT_SYMBOL(get_adc2_voltage);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-i2c.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-i2c.c
index b3b3d5f..cf6905d 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-i2c.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-i2c.c
@@ -24,6 +24,8 @@
#include <linux/debugfs.h>
#include <asm/uaccess.h>
+struct wakeup_source * adc_wakelock;
+
static struct i2c_client *zx234290_i2c =0;
static DEFINE_MUTEX(zx234290_i2c_lock);
@@ -35,7 +37,7 @@
// struct i2c_client *i2c = zx234290->control_data;
struct i2c_client *i2c = zx234290_i2c;
struct i2c_msg xfer[2];
- int ret;
+ int ret=0;
/* Write register */
xfer[0].addr = i2c->addr;
@@ -69,7 +71,7 @@
// struct i2c_client *i2c = zx234290->control_data;
struct i2c_client *i2c = zx234290_i2c;
struct i2c_msg xfer[2];
- int ret;
+ int ret=0;
/* Write register */
xfer[0].addr = i2c->addr;
@@ -104,7 +106,7 @@
struct i2c_client *i2c = zx234290_i2c;
/* we add 1 byte for device register */
u8 msg[4];
- int ret;
+ int ret=0;
//if (reg > ZX234290_MAX_REGISTER)
// return -EINVAL;
@@ -137,7 +139,7 @@
struct i2c_client *i2c = zx234290_i2c;
/* we add 1 byte for device register */
u8 buf[4];
- int ret;
+ int ret=0;
struct i2c_msg msg;
if (reg > ZX234290_MAX_REGISTER)
@@ -319,6 +321,28 @@
DEBUGFS_FILE_ENTRY(regs);
+static int debugfs_adc_get(void *data, u64 *val)
+{
+ switch ((int)data) {
+ case 0:
+ *val = get_battery_voltage();
+ break;
+ case 1:
+ *val = get_adc1_voltage();
+ break;
+ case 2:
+ *val = get_adc2_voltage();
+ break;
+ default:
+ *val = -1;
+ break;
+ }
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_adc_ro, debugfs_adc_get, NULL, "%llumV\n");
+
static struct dentry *g_pmu_root;
@@ -347,6 +371,26 @@
goto err;
}
+ //print adc0;
+ node = debugfs_create_file("adc0", S_IRUGO, root, 0, &fops_adc_ro);
+ if (!node){
+ dev_err(zx234290->dev, "debugfs_create_dir err=%d\n", IS_ERR(node));
+ goto err;
+ }
+
+ //print adc1;
+ node = debugfs_create_file("adc1", S_IRUGO, root, 1, &fops_adc_ro);
+ if (!node){
+ dev_err(zx234290->dev, "debugfs_create_dir err=%d\n", IS_ERR(node));
+ goto err;
+ }
+
+ //print adc2;
+ node = debugfs_create_file("adc2", S_IRUGO, root, 2, &fops_adc_ro);
+ if (!node){
+ dev_err(zx234290->dev, "debugfs_create_dir err=%d\n", IS_ERR(node));
+ goto err;
+ }
g_pmu_root = (void *)root;
return;
@@ -358,16 +402,19 @@
int zx234290_device_init(struct zx234290 *zx234290)
{
- int ret;
+ int ret=0;
int irq;
mutex_init(&zx234290->io_mutex);
dev_set_drvdata(zx234290->dev, zx234290);
zx234290_get_chip_version();
+ adc_wakelock = wakeup_source_register(NULL, "adc_wake");
+ if (!adc_wakelock)
+ return -ENOMEM;
#if defined(CONFIG_DEBUG_FS)
- printk("qhf %s\n",__func__);
+ printk("%s\n",__func__);
debugfs_pmu_init(zx234290);
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/Makefile b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/Makefile
index 1735559..24dd9e5 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/Makefile
@@ -3,6 +3,15 @@
#
obj-y += ringbuf.o
+obj-y += logcap_hdlc.o
obj-y += logcap_drv_ap.o
obj-y += logcap_drv_print.o
+obj-y += logcap_drv_wakeup.o
+obj-y += logcap_analy_rule.o
obj-y += debug_info.o
+obj-y += zcatagt_phy.o
+obj-y += zcatagt_sig.o
+obj-y += zcatagt_lte.o
+obj-y += zcatagt_w.o
+obj-y += zcatagt_ap.o
+obj-y += zcatagt_td.o
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/debug_info.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/debug_info.c
index 3fdedf6..95202f0 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/debug_info.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/debug_info.c
@@ -42,14 +42,10 @@
#define DEBUG_INFO_READABLE_LEN (0x1400)
#define DEBUG_INFO_MAX_DATA_LEN (128)
#define DEBUG_INFO_MAX_TOTAL_LEN (140) // 8 + 128 + 4
-#define DEBUG_INFO_MEM_HEAD_LEN (8)
-#define DEBUG_INFO_FILE_HEAD_LEN (12)
#define DEBUG_INFO_READ_TIME_MSECS (10000)
#define DEBUG_INFO_CHANNEL (9)
#define DEBUG_INFO_MSG_CAP_SIZE (2 * 1024)
-// #define DEBUG_INFO_MEM_TYPE_KERNEL (0)
-// #define DEBUG_INFO_MEM_TYPE_USER (1)
#define DEBUG_INFO_OK (0)
#define DEBUG_INFO_ERROR (-1)
@@ -71,9 +67,9 @@
typedef struct
{
- UINT32 head; // 0x010a0a0a
- UINT32 time; // time()函数获取
- UINT32 total_len; // 数据内容长度
+ UINT32 head; // 0x010a0a0a
+ UINT32 total_len; // 数据内容长度
+ long long time; // time()函数获取
} T_SAVE_FILE_DATA;
/*******************************************************************************
@@ -294,14 +290,14 @@
copy_to_user(buf, &fileDataHead, sizeof(T_SAVE_FILE_DATA));
- readLen = ReadRingBuffer(g_debug_info_buf, (buf + DEBUG_INFO_FILE_HEAD_LEN), bufSize_used, ZCAT_MEM_TYPE_USER);
+ readLen = ReadRingBuffer(g_debug_info_buf, (buf + sizeof(T_SAVE_FILE_DATA)), bufSize_used, ZCAT_MEM_TYPE_USER);
if (readLen == 0)
{
// printk("ReadRingBuffer failed.\n");
return 0;
}
- return (readLen + DEBUG_INFO_FILE_HEAD_LEN);
+ return (readLen + sizeof(T_SAVE_FILE_DATA));
}
static int sc_debug_info_record_from_user(const char *info, unsigned short count)
@@ -362,7 +358,7 @@
shareMemData->sub_len = len;
shareMemData->time = jiffies;
- writelen = sc_debug_info_write(ZCAT_MEM_TYPE_KERNEL, (UINT8 *)shareMemData, len + DEBUG_INFO_MEM_HEAD_LEN);
+ writelen = sc_debug_info_write(ZCAT_MEM_TYPE_KERNEL, (UINT8 *)shareMemData, len + sizeof(T_SHARED_MEM_DATA));
return writelen;
}
EXPORT_SYMBOL(sc_debug_info_vrecord);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_analy_rule.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_analy_rule.c
new file mode 100755
index 0000000..50d8db0
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_analy_rule.c
@@ -0,0 +1,287 @@
+/**
+ * @file logcap_analy_rule.c
+ * @brief
+ * This file is part of ZLog.
+ * ´¦ÀíAP¡¢CAP¡¢ZSP Phy²àlog¹æÔò
+ *
+ * @copyright Copyright (C) 2023 Sanechips Technology Co., Ltd.
+ * @warning
+ * @details
+ *
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2023/03/12 1.0 syx Create file
+ * ---------------------------------------------------------------------------
+*/
+
+/**
+* Í·Îļþ
+*/
+#include "logcat_drv.h"
+#include "ringbuf.h"
+#include <linux/vmalloc.h>
+#include <linux/uaccess.h>
+
+/**
+ * ºê¶¨Òå
+ */
+#define ZCAP_OK (0)
+#define ZCAP_ERROR (-1)
+#define ZCAP_HDLC_DECODE_CONTINUE (0x00)
+#define ZCAP_HDLC_DECODE_OK (0x01)
+#define ZCAP_HDLC_DECODE_FIRST_ESCAPE (0x02)
+#define ZCAP_HDLC_DECODE_DROP (0x03)
+
+/**
+ * Êý¾ÝÀàÐͶ¨Òå
+ */
+typedef struct
+{
+ void *buf;
+ UINT32 len;
+}T_RULE_DATA;
+
+typedef enum
+{
+ DIAG_TO_PS = 1,
+ DIAG_TO_PHY = 2,
+ DIAG_TO_AP = 4,
+ DIAG_DIRECTION_END = 0xFF
+} T_ZCAT_DIAG_DIRECTION;
+
+typedef enum
+{
+ DISABLE_LOGGING = 0,
+ ENABLE_LOGGING,
+ GET_MASK,
+ SET_MASK,
+ DIAG_LAST_OPERATION
+
+}T_ZCAT_DIAG_CONFIG_OPERATION_TYPE;
+
+/**
+ * ÍⲿÒýÓñäÁ¿
+ */
+extern T_ZCAT_DIAG_CONFIG_FUNC g_SigConfigFunc;
+extern T_ZCAT_DIAG_CONFIG_FUNC g_Ap2KernelConfigFunc;
+extern T_ZCAT_DIAG_CONFIG_FUNC g_Ap2AppConfigFunc;
+extern T_ZCAT_DIAG_CONFIG_FUNC g_WConfigFunc;
+extern T_ZCAT_DIAG_CONFIG_FUNC g_LteConfigFunc;
+extern T_ZCAT_DIAG_CONFIG_FUNC g_TdConfigFunc;
+
+/**
+ * Íⲿº¯ÊýÉùÃ÷
+ */
+UINT32 hdlc_decode(T_RINGBUFFER *dest, unsigned char *src, unsigned int len);
+
+
+/*¾Ö²¿º¯ÊýÉùÃ÷*/
+
+/**
+ * È«¾Ö±äÁ¿¶¨Òå
+ */
+
+T_RINGBUFFER *g_filter_dst = NULL;
+
+static T_ZCAT_DIAG_FILTER_CONFIG_TABLE g_FilterTable[] =
+{
+ { ZCAT_SIG_TYPE, DIAG_TO_PS, &g_SigConfigFunc },
+ { ZCAT_DBG_LTE_PHY, DIAG_TO_PS, &g_LteConfigFunc },
+ { ZCAT_DBG_WCDMA_PHY, DIAG_TO_PS, &g_WConfigFunc },
+ { ZCAT_DBG_TD_PHY, DIAG_TO_PS, &g_TdConfigFunc },
+ { ZCAT_AP2_KERNEL_TYPE, DIAG_TO_PS, &g_Ap2KernelConfigFunc },
+ { ZCAT_AP2_APP_TYPE, DIAG_TO_PS, &g_Ap2AppConfigFunc },
+};
+
+static UINT32 g_FilterTableSize = sizeof(g_FilterTable) / sizeof(T_ZCAT_DIAG_FILTER_CONFIG_TABLE);
+
+/**
+ * @brief FilterÅäÖÃÏûÏ¢´¦Àí
+ * @param[in] buf ÏûÏ¢Êý¾ÝÖ¸Õë
+ * @param[in] len ÏûÏ¢Êý¾Ý³¤¶È
+ * @return N/A
+ * @note
+ * @see
+ */
+VOID zCatAgt_Filter_Analyse(VOID *buf, UINT32 len)
+{
+ T_ZCAT_DIAG_CONFIG_REQ *configHeader = (T_ZCAT_DIAG_CONFIG_REQ *)buf;
+ T_ZCAT_DIAG_CONFIG_FUNC *filterFunc = NULL;
+ UINT8 *sendBuf = NULL;
+ UINT32 sendLen = 0;
+ UINT16 i, type;
+
+ if (buf == NULL || len < sizeof(T_ZCAT_DIAG_CONFIG_REQ))
+ {
+ return;
+ }
+
+ type = configHeader->type;
+
+ for (i = 0; i < g_FilterTableSize; i++)
+ {
+ if (type == g_FilterTable[i].type)
+ {
+ if (g_FilterTable[i].func != NULL)
+ {
+ filterFunc = g_FilterTable[i].func;
+ }
+ break;
+ }
+ }
+
+ if (filterFunc != NULL && configHeader->operation < DIAG_LAST_OPERATION)
+ {
+ if (configHeader->operation == DISABLE_LOGGING)
+ {
+ if (filterFunc->set_enable != NULL)
+ {
+ filterFunc->set_enable(FALSE);
+ }
+ }
+ else if (configHeader->operation == ENABLE_LOGGING)
+ {
+ if (filterFunc->set_enable != NULL)
+ {
+ filterFunc->set_enable(TRUE);
+ }
+ }
+ else if (configHeader->operation == GET_MASK)
+ {
+ if (filterFunc->get_mask != NULL)
+ {
+ filterFunc->get_mask(&sendBuf, &sendLen);
+ }
+ }
+ else if (configHeader->operation == SET_MASK)
+ {
+ if (filterFunc->set_mask != NULL)
+ {
+ filterFunc->set_mask((UINT8 *)(configHeader + 1), len - sizeof(T_ZCAT_DIAG_CONFIG_REQ));
+ }
+ }
+ }
+}
+
+/**
+ * @brief ZCAT´úÀíÄ£¿é´¦ÀíËùÓз¢Ë͵½"Master´¦ÀíÆ÷"µÄÏûÏ¢
+ * @param[in] msg ÏûÏ¢Êý¾ÝÖ¸Õë
+ * @param[in] len ÏûÏ¢Êý¾Ý³¤¶È
+ * @return ³É¹¦·µ»ØZOSS_SUCCESS, ·ñÔò·µ»ØZOSS_ERROR
+ * @note
+ * @see
+ */
+static UINT32 zCatAgt_ProcMsg(UINT8 *msg, UINT32 len)
+{
+ T_ZCAT_HEADER *zcatHeader = (T_ZCAT_HEADER *)msg;
+
+ // ÏûÏ¢ÓÐЧÐÔ¼ì²é: Èç¹ûÏûϢΪ¿Õ»òÕßÏûÏ¢³¤¶ÈÉÙÓÚÏûϢͷ³¤¶È£¬Åׯú£¬±¨´í
+ if (msg == NULL || (len < sizeof(T_ZCAT_HEADER)))
+ {
+ return ZCAP_ERROR;
+ }
+
+ if (zcatHeader->cmd_code == ZCAT_DIAG_REPORT)
+ {
+ T_ZCAT_DIAG_HEADER *diagHeader = (T_ZCAT_DIAG_HEADER *)(zcatHeader + 1);
+
+ UINT8 size = len - sizeof(T_ZCAT_HEADER);
+
+ if (diagHeader->diag_id == DIAG_FILTER_CONFIG)
+ {
+ zCatAgt_Filter_Analyse(diagHeader + 1, size - sizeof(T_ZCAT_DIAG_HEADER));
+ }
+ }
+ return ZCAP_ERROR;
+}
+
+void Comm_ComposeMsgStart(void)
+{
+ VOID *tmp;
+
+ if (g_filter_dst)
+ return;
+
+ tmp = vmalloc(ALIGNED_SIZE(MAX_ENCODE_PACKET_LEN, 3));
+
+ if(!tmp)
+ {
+ printk("Comm_ComposeMsgStart: NOMEM\n");
+ return;
+ }
+ g_filter_dst = CreateRingBufferWithSymbol(tmp, MAX_ENCODE_PACKET_LEN, 0);
+}
+
+
+void Comm_ComposeMsgEnd(void)
+{
+ if (g_filter_dst != NULL)
+ {
+ vfree(g_filter_dst);
+ g_filter_dst = NULL;
+ }
+}
+
+/**
+ * @brief ½«½ÓÊÕµ½µÄÊý¾Ý½âÂëµ½»º³å³ØÖУ¬µ±Óöµ½Ò»¸öÍêÕûdiagÃüÁî°üʱ£¬µ÷ÓÃÏûÏ¢¶ÔÓ¦µÄ»Øµ÷º¯Êý
+ * @param[in] buf ´ý½âÂëµÄÊý¾Ý»º³åÇøÖ¸Õë
+ * @param[in] len ´ý½âÂëµÄÊý¾ÝµÄ³¤¶È
+ * @return ³É¹¦·µ»ØZOSS_SUCCESS£¬Ê§°ÜZOSS_ERROR
+ * @note
+ * @see
+ */
+UINT32 Comm_ComposeMsgAndProcess(UINT32 arg)
+{
+ UINT8 *buf;
+ UINT32 len = 0;
+ UINT32 remainLen = 0;
+ T_COMM_TYPE commHeader = {0};
+ T_RULE_DATA kernRule_arg;
+
+ if ((g_filter_dst == NULL) || arg == 0)
+ {
+ return ZCAP_ERROR;
+ }
+
+ copy_from_user(&kernRule_arg, arg, sizeof(T_RULE_DATA));
+
+ if (kernRule_arg.buf == NULL || kernRule_arg.len == 0)
+ return ZCAP_ERROR;
+
+ len = kernRule_arg.len;
+
+ if(len > MAX_ENCODE_PACKET_LEN) // °ü´óС <= MAX_ENCODE_PACKET_LEN - 12
+ {
+ printk("Comm_ComposeMsgAndProcess user buf len error\n");
+ return ZCAP_ERROR;
+ }
+
+ buf = (UINT8 *)vmalloc(len);
+ if (buf == NULL)
+ panic("NOMEM\n");
+
+ copy_from_user(buf, kernRule_arg.buf, len);
+
+ remainLen = len;
+
+ while (remainLen > 0)
+ {
+ remainLen -= hdlc_decode(g_filter_dst, &buf[len - remainLen], remainLen);
+
+ if (g_filter_dst->symbol == ZCAP_HDLC_DECODE_OK)
+ {
+ if (g_filter_dst->writePoint > sizeof(T_COMM_TYPE))
+ {
+ // È¡ÏûϢͷÐÅÏ¢
+ memcpy(&commHeader, g_filter_dst->buf, sizeof(T_COMM_TYPE));
+ zCatAgt_ProcMsg((UINT8 *)(g_filter_dst->buf + sizeof(T_COMM_TYPE)), g_filter_dst->writePoint - sizeof(T_COMM_TYPE));
+ }
+ g_filter_dst->writePoint = 0;
+ }
+ }
+ vfree(buf);
+ return ZCAP_OK;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_ap.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_ap.c
index 1dfcbe1..13b4bbc 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_ap.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_ap.c
@@ -1,8 +1,8 @@
/**
- * @file logcap_drv_ap.c
- * @brief
- * This file is part of ZCAT.
- * zcat´¦Àícp²àlogµÄÐéÄâÉ豸
+ * @file logcap_drv_ap.c
+ * @brief
+ * This file is part of ZLog.
+ * ´¦ÀíAP¡¢CAP¡¢ZSP Phy²àlogµÄÐéÄâÉ豸
*
* @copyright Copyright (C) 2023 Sanechips Technology Co., Ltd.
* @warning
@@ -10,9 +10,9 @@
*
* Change History :
* ---------------------------------------------------------------------------
- * date version author description
+ * date version author description
* ---------------------------------------------------------------------------
- * 2023/03/12 1.0 syx Create file
+ * 2023/03/12 1.0 syx Create file
* ---------------------------------------------------------------------------
*/
@@ -34,21 +34,49 @@
#include <linux/device.h>
#include <linux/miscdevice.h>
#include <linux/slab.h>
+#include <linux/ioctl.h>
#include <asm/io.h>
#include "logcat_drv.h"
#include "ringbuf.h"
+#include <linux/soc/zte/rpmsg.h>
#include "ram_base_config_7520v3.h"
/**
* ºê¶¨Òå
*/
+#define ZCAP_LOG_BUFF_PHY_READY (0xEF)
+#define ZCAP_AP_LOG_MAX_LENGTH (4096)
+#define ZCAP_LOG_DEFAULT_MOD (2)
+#define ZCAP_LOG_DEFAULT_LEVEL (LEVEL_NOTICE)
+#define ZCAP_READ_BUFFER_SIZE (ZCAT_APP2_RINGBUF_LEN)
+#define ZCAP_MAX_READ_PACKET_LEN (0x40000) /* 16KB--zsp 16KB--CAP kernel 16KB--CAP APP 128KB--PS, 80KB reserved for CAP kernel&&app print header */
+
+#define ZCAP_IOCTL_TYPE 'T'
+#define ZCAP_IOCTL_RULE_START _IO(ZCAP_IOCTL_TYPE, 0)
+#define ZCAP_IOCTL_RULE_PROCESS _IOWR(ZCAP_IOCTL_TYPE, 1, UINT32)
+#define ZCAP_IOCTL_RULE_END _IO(ZCAP_IOCTL_TYPE, 2)
+
+#define COMM_HEADER_REAL_SIZE(len) ((UINT32)(len)&(0x00FFFFFF))
+#define RINGBUF_APLOG_OFFSET_LEN (RINGBUF_CAP_TO_AP_LEN + ADB_CAP_BUF_LEN + RAMDUMP_CAP_CMM_BUF_LEN)
+#define RINGBUF_IOREMAP_DOMAIN_LEN (RINGBUF_APLOG_OFFSET_LEN + RINGBUF_AP_TO_CAP_LEN)
+
+/*Íⲿ±äÁ¿ÉùÃ÷*/
+extern T_RINGBUFFER *g_AP2_KernelToCpBuffer;
+extern T_RINGBUFFER *g_AP2_AppToCpBuffer;
/**
* Íⲿº¯ÊýÒýÓÃ
*/
-extern size_t Comm_Read_AP_TO_CAP_Data(const char __user *buf, size_t len);
-extern size_t Comm_Write_CAP_TO_AP_Data(const char __user *buf, size_t len);
+extern int zCatAgt_Phy_ReadZspFlag(void);
+extern size_t zCapAgt_ReadApToCapLog(const char __user *buf, size_t len);
+extern size_t zCapAgt_WriteCapToAPLog(const char __user *buf, size_t len);
+extern BOOL zCatAgt_Phy_ReadData(void **ptr, UINT32 *size);
+extern VOID zCatAgt_Phy_ReleaseUnit(T_ZCAT_Phy_Log_Unit_Header *buf);
+extern void Comm_ComposeMsgStart(void);
+extern void Comm_ComposeMsgEnd(void);
+extern UINT32 Comm_ComposeMsgAndProcess(UINT32 arg);
+/*¾Ö²¿º¯ÊýÉùÃ÷*/
static int zcap_aplog_open(struct inode *ip, struct file *fp);
static ssize_t zcap_aplog_read(struct file *fp, char __user *buf,size_t count, loff_t *pos);
static ssize_t zcap_aplog_write(struct file *fp, const char __user *buf,size_t count, loff_t *pos);
@@ -57,8 +85,19 @@
/**
* È«¾Ö±äÁ¿¶¨Òå
*/
-UINT8 *log_smbuf;
-static struct mutex gAplog_mutex;
+static int g_CPOriTime = 0;
+static int g_CPOriTick = 0;
+static UINT8 *log_smbuf;
+static void *g_CAP_LogTmpBuffer = NULL;
+UINT8 *g_CAP_IramPhy = NULL;
+UINT8 *g_CAP_ZspLogAddr = NULL;
+
+static struct mutex gAplog_mutex;
+
+unsigned long ZCAT_PS_2_PHY_BUFFER_BASE;
+
+extern BOOL g_Ap2AppEnabled;
+extern BOOL g_Ap2KernelEnabled;
T_RINGBUFFER *g_CAP_ApToCapBuffer = NULL;
EXPORT_SYMBOL(g_CAP_ApToCapBuffer);
@@ -80,57 +119,335 @@
.fops = &Aplog_fops,
};
-size_t Comm_Read_AP_TO_CAP_Data(const char __user *buf, size_t len)
+
+/**
+ * @brief ·ÖÎöAP LOG£¬°´»»ÐÐÖØÐ·ָî
+ * @param[in] src Դ
+ * @param[in] dst Ä¿µÄ
+ * @return Èç¹û³É¹¦·µ»ØTRUE, ·ñÔò·µ»ØFALSE
+ * @note
+ * @see
+ */
+BOOL zCatAgt_Ap_ReadBuffer(T_AP_SRC_BUFFER_TYPE *src, T_AP_DEST_BUFFER_TYPE *dst)
{
+ if (src != NULL && src->buf != NULL && src->bufSize > src->beginIndex && dst != NULL )
+ {
+ UINT8 *src_buf = src->buf + src->beginIndex;
+ UINT32 src_length = src->bufSize - src->beginIndex;
+ UINT32 buf_length = src_length > ZCAP_AP_LOG_MAX_LENGTH ? ZCAP_AP_LOG_MAX_LENGTH : src_length;
+ UINT32 i = 0;
+
+ for (; i < buf_length; i++)
+ {
+ if (src_buf[i] == '\n')
+ {
+ i++;
+ dst->newLine = 1;
+ break;
+ }
+ }
+
+ dst->buf = src->buf + src->beginIndex;
+ dst->len = i;
+ src->beginIndex += i;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * @brief CommHeader³õʼ»¯
+ * @param[in] commHeader commͷ
+ * @param[in] buf_len commÍ·³¤¶È
+ * @param[in] tgt_mdl_no Ä¿±êÄ£¿éºÅ£¬ÊÖ»ú»òPCµÈ
+ * @param[in] tgt_submdl_no Ä¿±ê×ÓÄ£¿éºÅ
+ * @param[in] src_submdl_no Ô´×ÓÄ£¿éºÅ
+ * @return void
+ * @note
+ * @see
+ */
+void Comm_HeaderInit(T_COMM_TYPE *commHeader, unsigned int buf_len,
+ unsigned char tgt_mdl_no, unsigned char tgt_submdl_no, unsigned char src_submdl_no)
+{
+ commHeader->msg_type = 0xCD;
+ commHeader->pad = 0xAA;
+ commHeader->reserved = 0xAAAA;
+ commHeader->tgt_mdl_no = tgt_mdl_no; // Ä¿±êÄ£¿é
+ commHeader->tgt_submdl_no = tgt_submdl_no; // Ä¿±ê×ÓÄ£¿é
+ commHeader->src_mdl_no = MDL_PHONE; // Ô´Ä£¿é
+ commHeader->src_submdl_no = src_submdl_no; // Ô´×ÓÄ£¿é
+ commHeader->buf_len = (0xCD << 24) | buf_len; // Êý¾ÝÇø³¤¶È
+}
+
+/**
+ * @brief »ñȡʱ¼ä
+ * @param[in] void
+ * @return
+ * @note
+ * @see
+ */
+static unsigned int zCatAgt_GetTime(void)
+{
+ struct timespec64 time_val;
+ ktime_get_real_ts64(&time_val);
+ g_CPOriTime = time_val.tv_sec - sys_tz.tz_minuteswest*60;
+ g_CPOriTick = time_val.tv_nsec / 1000;
+ return 0;
+}
+
+/**
+ * @brief ZCATÏûϢͷ³õʼ»¯
+ * @param[out] zcatHeader ÏûϢͷָÕë
+ * @param[in] cmd_code ÏûÏ¢Âë
+ * @param[in] len ÏûÏ¢³¤¶È
+ * @return N/A
+ * @note
+ * @see
+ */
+void zCatAgt_HeaderInit(T_ZCAT_HEADER *zcatHeader, unsigned char cmd_code, unsigned int len)
+{
+ zcatHeader->cmd_code = cmd_code;
+ zcatHeader->padding = 6;
+
+ zcatHeader->cmd_code = cmd_code;
+ zcatHeader->reserved = 0xBBBB;
+ zcatHeader->length = len;
+
+ zCatAgt_GetTime();
+ zcatHeader->timeStamp[0] = g_CPOriTick;//zOss_GetTickCount();
+ zcatHeader->timeStamp[1] = g_CPOriTime;
+}
+
+/**
+ * @brief CAPºË¶ÁÈ¡±¾ºËAPP/KERNELµÄLog
+ * @param[in] dstbuf ¿½±´µ½Óû§Ì¬µÄµØÖ·
+ * @param[in] len Òª¶ÁÈ¡µÄ³¤¶È
+ * @param[in] type LogÀàÐÍ
+ * @return ³É¹¦·µ»Ø¶ÁÈ¡µÄʵ¼Ê³¤¶È, ·ñÔò·µ»ØÊ§°Ü:-1
+ * @note
+ * @see
+ */
+int zCapAgt_ReadData(char __user *dstbuf, size_t len, int type)
+{
+ size_t total_len = 0;
+ UINT32 bufLen = 0;
+ UINT32 readLen = 0;
+ UINT32 bufSize = 0;
+ T_RINGBUFFER *ringbuf = NULL;
+ T_COMM_TYPE comm_header = {0};
+ T_ZCAT_HEADER zcat_header = {0};
+ T_ZCAT_APLOG_HEADER ap_header = {0};
+ T_AP_SRC_BUFFER_TYPE out_logBuf = {0};
+
+ if (dstbuf == NULL)
+ return -1;
+
+ if (type == ZCAT_AP2_APP_LOG)
+ ringbuf = (T_RINGBUFFER *)g_AP2_AppToCpBuffer;
+ else if(type == ZCAT_AP2_KERNEL_LOG)
+ ringbuf = (T_RINGBUFFER *)g_AP2_KernelToCpBuffer;
+ else
+ panic("Error: buf type error\n");
+
+ if(!IsRingBufferValid(ringbuf))
+ {
+ return -1;
+ }
+
+ out_logBuf.buf = g_CAP_LogTmpBuffer;
+ bufSize = GetRingBufferSize(ringbuf);
+
+ while (bufSize > 0)
+ {
+ bufLen = bufSize > ZCAP_READ_BUFFER_SIZE ? ZCAP_READ_BUFFER_SIZE : bufSize;
+ readLen = ReadRingBuffer(ringbuf, out_logBuf.buf, bufLen, ZCAT_MEM_TYPE_KERNEL);
+
+ if (readLen > 0)
+ {
+ T_AP_DEST_BUFFER_TYPE dest = {0};
+ out_logBuf.bufSize = readLen;
+
+ while (zCatAgt_Ap_ReadBuffer(&out_logBuf, &dest))
+ {
+ UINT16 len = dest.len;
+
+ ap_header.len = len;
+ ap_header.mod = ZCAP_LOG_DEFAULT_MOD;
+ ap_header.priority = ZCAP_LOG_DEFAULT_LEVEL;
+
+ zCatAgt_HeaderInit(&zcat_header, type, len + sizeof(T_ZCAT_APLOG_HEADER));
+ Comm_HeaderInit(&comm_header, len + sizeof(T_ZCAT_APLOG_HEADER) + sizeof(T_ZCAT_HEADER), MDL_ZCAT, 1, SUBMDL_ZCATAGT);
+
+ copy_to_user(dstbuf + total_len, &comm_header, sizeof(comm_header));
+ total_len += sizeof(comm_header);
+ copy_to_user(dstbuf + total_len, &zcat_header, sizeof(zcat_header));
+ total_len += sizeof(zcat_header);
+ copy_to_user(dstbuf + total_len, &ap_header, sizeof(ap_header));
+ total_len += sizeof(ap_header);
+ copy_to_user(dstbuf + total_len, dest.buf, dest.len);
+ total_len += dest.len;
+ memset(&dest, 0, sizeof(T_AP_DEST_BUFFER_TYPE));
+ }
+
+ out_logBuf.beginIndex = 0;
+ out_logBuf.bufSize = 0;
+
+ bufSize -= readLen;
+ }
+ else
+ {
+ out_logBuf.beginIndex = 0;
+ out_logBuf.bufSize = 0;
+ break;
+ }
+ }
+
+ return total_len;
+}
+
+/**
+ * @brief CAPºË¶ÁÈ¡APºËµÄLog
+ * @param[in] buf LogÊý¾ÝµØÖ·
+ * @param[in] len Òª¶ÁÈ¡µÄ³¤¶È
+ * @return ·µ»ØÐ´³öµÄʵ¼Ê³¤¶È
+ * @note 128K: AP-CAP Log
+ * @see
+ */
+size_t zCapAgt_ReadApToCapLog(const char __user *buf, size_t len)
+{
+ size_t wlen = 0;
+
if(g_CAP_ApToCapBuffer != NULL && buf && len )
{
- size_t wlen = ReadRingBuffer(g_CAP_ApToCapBuffer, (UINT8*)buf, len, ZCAT_MEM_TYPE_USER);
-
+ wlen = ReadRingBuffer(g_CAP_ApToCapBuffer, (UINT8*)buf, len, ZCAT_MEM_TYPE_USER);
return wlen;
}
-
return 0;
}
-size_t Comm_Write_CAP_TO_AP_Data(const char __user *buf, size_t len)
+/**
+ * @brief CAPºË¶ÁÈ¡ZSPºËPhyµÄLog
+ * @param[in] dstbuf ¿½±´µ½Óû§Ì¬µÄµØÖ·
+ * @param[in] len Òª¶ÁÈ¡µÄ³¤¶È
+ * @return ·µ»Ø¶ÁÈ¡µÄʵ¼Ê³¤¶È
+ * @note
+ * @see
+ */
+int zCapAgt_ReadZspPhyLog(char __user *dstbuf, size_t len)
{
- if(g_CAP_CapToApBuffer != NULL && buf && len )
- {
- mutex_lock(&gAplog_mutex);
- size_t wlen = WriteRingBuffer(g_CAP_CapToApBuffer, (UINT8*)buf, len, ZCAT_MEM_TYPE_USER);
- mutex_unlock(&gAplog_mutex);
-
- return wlen;
+ UINT32 phyLog_flag = 0;
+ UINT32 size = 0;
+ size_t read_len = 0;
+ char *buf = NULL;
+ T_COMM_TYPE *commHeader = NULL;
+
+ if((ZCAP_LOG_BUFF_PHY_READY == zCatAgt_Phy_ReadZspFlag())
+ && (zCatAgt_Phy_ReadData((void **)&buf, &size)))
+ {
+ commHeader = (T_COMM_TYPE *)buf;
+ size = COMM_HEADER_REAL_SIZE(commHeader->buf_len) + sizeof(T_COMM_TYPE);
+ copy_to_user(dstbuf + read_len, commHeader, size);
+ read_len += size;
+
+ zCatAgt_Phy_ReleaseUnit((T_ZCAT_Phy_Log_Unit_Header *)buf);
}
- return 0;
+ return read_len;
}
+/**
+ * @brief CAPºË¶ÁÈ¡ZSPºË/APºË/CAPºËµÄLog×ÜÈë¿Ú
+ * @param[in] dstbuf ¿½±´µ½Óû§Ì¬µÄµØÖ·
+ * @param[in] len Òª¶ÁÈ¡µÄ³¤¶È
+ * @return ·µ»Ø¶ÁÈ¡µÄʵ¼Ê³¤¶È
+ * @note
+ * @see
+ */
static ssize_t zcap_aplog_read(struct file *fp, char __user *buf, size_t count, loff_t *pos)
{
+ char __user *read_buf = buf;
size_t retLen = 0;
+ size_t read_size = 0;
+ size_t remain_count = count;
- if(buf && count)
+ if (buf == NULL || count <= 0)
+ return -1;
+
+ /*¶Ázsp log*/
+ retLen = zCapAgt_ReadZspPhyLog(read_buf + read_size, remain_count - read_size);
+ read_size += retLen;
+ //printk("phy log %d\n",read_size);
+
+ /*¶Áps log*/
+ retLen = zCapAgt_ReadApToCapLog(read_buf + read_size, remain_count - read_size);
+ read_size += retLen;
+ //printk("Ps log %d\n",read_size);
+
+ /*¶ÁCAP APP*/
+ if (g_Ap2AppEnabled)
{
- retLen = Comm_Read_AP_TO_CAP_Data(buf,count);
+ retLen = zCapAgt_ReadData(read_buf + read_size, remain_count - read_size, ZCAT_AP2_APP_LOG);
+ read_size += retLen;
+ }
+ //printk("app log %d\n",read_size);
+
+ /*¶ÁCAP kernel*/
+ if (g_Ap2KernelEnabled)
+ {
+ retLen = zCapAgt_ReadData(read_buf + read_size, remain_count - read_size, ZCAT_AP2_KERNEL_LOG);
+ read_size += retLen;
}
- return retLen;
+ //printk("Kernel log %d\n",read_size);
+
+ return read_size;
}
+/**
+ * @brief CAPºË·¢ËÍÐÄÌø°üºÍ¹æÔò¸øAPºË
+ * @param[in] fp É豸Îļþ¾ä±ú
+ * @param[in] dstbuf дÈëÊý¾ÝµÄµØÖ·
+ * @param[in] count ҪдÈëµÄ³¤¶È
+ * @return ·µ»ØÐ´ÈëµÄʵ¼Ê³¤¶È
+ * @note
+ * @see
+ */
static ssize_t zcap_aplog_write(struct file *fp, const char __user *buf, size_t count, loff_t *pos)
{
size_t retLen = 0;
- if (buf && count)
- {
- retLen = Comm_Write_CAP_TO_AP_Data(buf, count);
+ if(g_CAP_CapToApBuffer != NULL && buf && count)
+ {
+ mutex_lock(&gAplog_mutex);
+ retLen = WriteRingBuffer(g_CAP_CapToApBuffer, (UINT8*)buf, count, ZCAT_MEM_TYPE_USER);
+ mutex_unlock(&gAplog_mutex);
}
- return retLen;
+ return retLen;
}
static long zcap_aplog_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
{
- return 0;
+ switch(cmd)
+ {
+ case ZCAP_IOCTL_RULE_START:
+ Comm_ComposeMsgStart();
+ break;
+
+ case ZCAP_IOCTL_RULE_PROCESS:
+ /*½âÎö¹æÔò±£´æµ½CAPºË*/
+ Comm_ComposeMsgAndProcess(arg);
+ break;
+
+ case ZCAP_IOCTL_RULE_END:
+ Comm_ComposeMsgEnd();
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
}
static int zcap_aplog_open(struct inode *ip, struct file *fp)
@@ -139,35 +456,53 @@
return 0;
}
+/**
+ * @brief CAPºË¶Áȡȫ°æ±¾LogÉ豸Îļþ³õʼ»¯
+ * @param[in] void
+ * @return ×¢²áÉ豸ÎļþÊÇ·ñ³É¹¦
+ * @note ¶Ô¶ÁÈ¡LogÓõ½µÄµØÖ·½øÐÐÓ³Éä
+ * @see
+ */
static int __init aplog_dev_init(void)
{
int ret = misc_register(&Aplog_device);
printk("cap Emmc log_init.\n");
-
+
if (ret)
{
printk(KERN_ERR "cplog driver init failed.\n");
}
+
mutex_init(&gAplog_mutex);
-
- log_smbuf = (UINT8 *)ioremap_wc(RINGBUF_CAP_TO_AP_ADDR, RINGBUF_CAP_TO_AP_LEN + RINGBUF_AP_TO_CAP_LEN);
+
+ g_CAP_IramPhy = (UINT8 *)ioremap(IRAM_BASE_ADDR_ZCAT_PHY_LOG, 256);
+ g_CAP_ZspLogAddr = (UINT8 *)ioremap_cache(TOOL_ZSP_TO_CAP_LOG_ADDR_PA, TOOL_ZSP_TO_CAP_LOG_LEN);
+ ZCAT_PS_2_PHY_BUFFER_BASE = (UINT8 *)ioremap(TOOL_CAP_BUF_ADDR_PA + 32 * 1024, 4 * 1024);
+
+ log_smbuf = (UINT8 *)ioremap_wc(RINGBUF_CAP_TO_AP_ADDR, RINGBUF_IOREMAP_DOMAIN_LEN);
g_CAP_CapToApBuffer = CreateRingBuffer((UINT8 *)log_smbuf, RINGBUF_CAP_TO_AP_LEN);
- g_CAP_ApToCapBuffer = CreateRingBuffer((UINT8 *)(log_smbuf + RINGBUF_CAP_TO_AP_LEN), RINGBUF_AP_TO_CAP_LEN);
-
+ g_CAP_ApToCapBuffer = CreateRingBuffer((UINT8 *)(log_smbuf + RINGBUF_APLOG_OFFSET_LEN), RINGBUF_AP_TO_CAP_LEN);
+
+ g_CAP_LogTmpBuffer = vmalloc(ZCAT_APP2_RINGBUF_LEN);
+ if (g_CAP_LogTmpBuffer == NULL)
+ {
+ panic("[zlog-agent] vmalloc error: ENOMEM\n");
+ }
+
return ret;
}
static void __exit aplog_dev_exit(void)
{
- printk("aplog_exit.\n");
+ printk("aplog_exit.\n");
misc_deregister(&Aplog_device);
}
module_init(aplog_dev_init);
module_exit(aplog_dev_exit);
-MODULE_DESCRIPTION("cplog driver");
+MODULE_DESCRIPTION("aplog driver");
MODULE_LICENSE("GPL");
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_print.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_print.c
index 493236c..6354a00 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_print.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_print.c
@@ -46,12 +46,6 @@
*/
/**
- * ºê¶¨Òå
- */
-#define ZCAT_APP2_RINGBUF_LEN (0x4000)
-#define ZCAT_KERNEL2_RINGBUF_LEN (0x4000)
-
-/**
* Êý¾ÝÀàÐͶ¨Òå
*/
T_RINGBUFFER *g_AP2_KernelToCpBuffer = NULL;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_wakeup.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_wakeup.c
new file mode 100755
index 0000000..9bdfb8a
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_drv_wakeup.c
@@ -0,0 +1,198 @@
+/**
+ * @file logcap_drv_wakeup.c
+ * @brief
+ * This file is part of ZLOG.
+ * capºË´¦ÀíM0»½ÐÑLog¶ÁÏ̵߳ÄÐéÄâÉ豸
+ *
+ * @copyright Copyright (C) 2023 Sanechips Technology Co., Ltd.
+ * @warning
+ * @details
+ *
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2023/05/19 1.0 syx Create file
+ * ---------------------------------------------------------------------------
+*/
+
+/**
+* Í·Îļþ
+*/
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/cdev.h>
+#include <linux/fs.h>
+#include <linux/ioport.h>
+#include <linux/serial_reg.h>
+#include <linux/delay.h>
+#include <linux/wait.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/miscdevice.h>
+#include <asm/io.h>
+#include "logcat_drv.h"
+#include "ringbuf.h"
+#include <linux/soc/zte/rpmsg.h>
+
+/**
+ * ºê¶¨Òå
+ */
+#define ZCAP_LOG_OK (0)
+#define ZCAP_LOG_ERROR (-1)
+
+/*M0ºÍCAP¼äºË¼äͨµÀ*/
+#define ZCAP_LOG_WAKE_CHANNEL (4)
+#define ZCAP_LOG_WAKE_CHANNEL_SIZE (0x10)
+
+/*ASCII:"wake"*/
+#define ZCAP_ICP_MSG_WAKE_INFO_VAL (0x656B6177)
+
+/**
+ * ¾Ö²¿º¯ÊýÉùÃ÷
+ */
+static int zcap_wakelog_open(struct inode *ip, struct file *fp);
+static ssize_t zcap_wakelog_read(struct file *fp, char __user *buf, size_t count, loff_t *pos);
+
+/**
+ * È«¾Ö±äÁ¿¶¨Òå
+ */
+
+static struct mutex gAplog_mutex;
+static BOOL zcap_wake_flag = FALSE;
+static struct semaphore wake_sem;
+
+static const struct file_operations WakeUplog_fops = {
+ .owner = THIS_MODULE,
+ .read = zcap_wakelog_read,
+ .open = zcap_wakelog_open,
+};
+
+static struct miscdevice WakeUplog_device = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "logwakeup",
+ .fops = &WakeUplog_fops,
+};
+
+/**
+ * @brief ×èÈû¶ÁÈ¡»½ÐÑÐéÄâÉ豸Îļþ½Ó¿Ú
+ * @param[in] buf: ºË¼äͨµÀÊý¾Ýbuf
+ * @param[in] len: ºË¼äͨµÀÊý¾Ýbuf³¤¶È
+ * @return void
+ * @note
+ * @see
+ */
+static void sc_wakeup_info_from_m0(void *buf, unsigned int len)
+{
+ if ((buf != NULL) &&
+ (*(UINT32 *)buf == ZCAP_ICP_MSG_WAKE_INFO_VAL))
+ {
+ up(&wake_sem);
+ printk("[zlog-agent] sc_wakeup_info_from_m0 \n");
+ }
+}
+
+/**
+ * @brief ×èÈû¶ÁÈ¡»½ÐÑÐéÄâÉ豸Îļþ½Ó¿Ú
+ * @param[in] fp: ÐéÄâÉ豸Îļþ¾ä±ú
+ * @param[in] buf: ·µ»Ø¸øÓû§Ì¬µÄbuf
+ * @param[in] count:¶ÁÈ¡µÄ³¤¶È
+ * @param[in] pos: ÎļþÆ«ÒÆ
+ * @return ÊÇ·ñ»ñÈ¡ÐźÅÁ¿,³É¹¦·µ»Ø·ñÔò×èÈû¶ÁÈ¡
+ * @note
+ * @see
+ */
+static ssize_t zcap_wakelog_read(struct file *fp, char __user *buf, size_t count, loff_t *pos)
+{
+ return down_interruptible(&wake_sem);
+}
+
+/**
+ * @brief ÐéÄâÉ豸Îļþ¶Á½Ó¿Ú
+ * @param[in] ip: ÐéÄâÉ豸ÎļþinodeÐÅÏ¢
+ * @param[in] fp: ÐéÄâÉ豸Îļþ¾ä±ú
+ * @return
+ * @note
+ * @see
+ */
+static int zcap_wakelog_open(struct inode *ip, struct file *fp)
+{
+ return 0;
+}
+
+/**
+ * @brief CAPºËÓëM0ºËºË¼äͨµÀ³õʼ»¯ºÍ»Øµ÷º¯Êý×¢²á
+ * @param[in] void
+ * @return ×¢²áºËºË¼äͨµÀÊÇ·ñ³É¹¦
+ * @note
+ * @see
+ */
+static int zcap_icp_init(void)
+{
+ int ret = 0;
+
+ ret = rpmsgCreateChannel(
+ CORE_M0,
+ ZCAP_LOG_WAKE_CHANNEL,
+ ZCAP_LOG_WAKE_CHANNEL_SIZE);
+
+ if (ret != ZCAP_LOG_OK)
+ {
+ printk("[zlog-agent]rpmsgCreateChannel failed, ret = %d\n", ret);
+ return ZCAP_LOG_ERROR;
+ }
+
+ ret = rpmsgRegCallBack(
+ CORE_M0,
+ ZCAP_LOG_WAKE_CHANNEL,
+ sc_wakeup_info_from_m0);
+
+ if (ret != ZCAP_LOG_OK)
+ {
+ printk("[zlog-agent]rpmsgRegCallBack failed,ret = %d\n", ret);
+ return ZCAP_LOG_ERROR;
+ }
+
+ return ZCAP_LOG_OK;
+}
+
+/**
+ * @brief CAPºË¶Áȡȫ°æ±¾LogÉ豸Îļþ³õʼ»¯
+ * @param[in] void
+ * @return ×¢²áÉ豸ÎļþÊÇ·ñ³É¹¦
+ * @note ¶Ô¶ÁÈ¡LogÓõ½µÄµØÖ·½øÐÐÓ³Éä
+ * @see
+ */
+static int __init zcap_wakelog_dev_init(void)
+{
+ int ret = misc_register(&WakeUplog_device);
+
+ printk("[zlog-agent]cap Wake read log thread init.\n");
+
+ if (ret)
+ {
+ printk(KERN_ERR "[zlog-agent]wakeup log driver init failed.\n");
+ }
+
+ sema_init(&wake_sem, 0);
+ zcap_icp_init();
+
+ return ret;
+}
+
+static void __exit zcap_wakelog_dev_exit(void)
+{
+ printk("[zlog-agent]wakeuplog_exit.\n");
+ misc_deregister(&WakeUplog_device);
+}
+
+module_init(zcap_wakelog_dev_init);
+module_exit(zcap_wakelog_dev_exit);
+
+MODULE_DESCRIPTION("WakeUplog driver");
+MODULE_LICENSE("GPL");
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_hdlc.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_hdlc.c
new file mode 100755
index 0000000..c2e6cba
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcap_hdlc.c
@@ -0,0 +1,354 @@
+/**
+ *
+ * @file hdlc.c
+ * @brief
+ * This file is part of tools.
+ * hdlc encode/decode lib
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2013/01/21 1.0 lu.xieji Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * 2019/03/12 1.2 dai.kang hdlc±àÂë¶ÁÊý¾Ý·½Ê½ÓÅ»¯
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+#include "ringbuf.h"
+#include "logcat_drv.h"
+
+#define HDLC_CONTROL_CHAR 0x7E // ½áÊø·û
+#define HDLC_ESC_CHAR 0x7D // תÒë×Ö·ûÖµ
+#define HDLC_ESC_MASK 0x20 // תÒëÔËËãÖµ
+#define HDLC_TAIL_SIZE 3 // β²¿Ìí¼Ó×Ö·û³¤¶È
+
+#define HDLC_DECODE_CONTINUE (0x00)
+#define HDLC_DECODE_OK (0x01)
+#define HDLC_DECODE_FIRST_ESCAPE (0x02)
+#define HDLC_DECODE_DROP (0x03)
+
+// CRC table for 16 bit CRC, with generator polynomial 0x8408, calculated 8 bits at a time, LSB first.
+#define CRC_TAB_SIZE 256 // 2^CRC_TAB_BITS
+#define CRC_16_L_SEED 0xFFFF
+#define CRC_16_L_POLYNOMIAL 0x8408
+#define CRC_16_L_OK 0x0F47
+
+#define CRC_16_L_STEP(xx_crc, xx_c) \
+ (((xx_crc) >> 8) ^ crc_16_l_table[((xx_crc) ^ (xx_c)) & 0x00ff])
+
+const unsigned short crc_16_l_table[CRC_TAB_SIZE] =
+{
+ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
+ 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
+ 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
+ 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
+ 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
+ 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
+ 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
+ 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
+ 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
+ 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
+ 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
+ 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
+ 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
+ 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
+ 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
+ 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
+ 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
+ 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
+ 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
+ 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
+ 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
+ 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
+ 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
+ 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
+ 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
+ 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
+ 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
+ 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
+ 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
+ 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
+ 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
+ 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
+};
+
+
+/**
+ * @brief HDLC±àÂë
+ * @param[out] dest Ä¿±êT_HDLC_BUFFER_TYPEÖ¸Õë
+ * @param[in] src Ô´T_HDLC_BUFFER_TYPEÖ¸Õë
+ * @return ³É¹¦·µ»ØTRUE£»Ê§°Ü·µ»ØFALSE
+ * @note
+ * @see
+ */
+BOOL hdlc_encode(T_HDLC_BUFFER_TYPE *dest, const T_HDLC_BUFFER_TYPE *src)
+{
+ if (dest && src && dest->buf && src->buf \
+ && dest->bufSize > dest->bufIndex && src->bufSize > src->bufIndex)
+ {
+ unsigned char *dest_buf = dest->buf + dest->bufIndex;
+ unsigned char *src_buf = src->buf + src->bufIndex;
+ unsigned long src_long = 0;
+ unsigned char src_byte = 0;
+ unsigned short crc = CRC_16_L_SEED;
+ unsigned int converted_length = 0;
+ unsigned int i, src_length;
+
+ src_length = ((src->bufSize - src->bufIndex) >> 2) << 2;
+ for (i = 0; i < src_length; i += 4)
+ {
+ src_long = *((unsigned long *)(src_buf + i));
+
+ src_byte = (unsigned char)(src_long & 0x000000ff);
+
+ if ((src_byte == HDLC_CONTROL_CHAR) || (src_byte == HDLC_ESC_CHAR))
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = HDLC_ESC_CHAR;
+ dest_buf[converted_length++] = src_byte ^ HDLC_ESC_MASK;
+ }
+ else
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = src_byte;
+ }
+
+ src_byte = (unsigned char)((src_long & 0x0000ff00) >> 8);
+
+ if ((src_byte == HDLC_CONTROL_CHAR) || (src_byte == HDLC_ESC_CHAR))
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = HDLC_ESC_CHAR;
+ dest_buf[converted_length++] = src_byte ^ HDLC_ESC_MASK;
+ }
+ else
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = src_byte;
+ }
+
+ src_byte = (unsigned char)((src_long & 0x00ff0000) >> 16);
+
+ if ((src_byte == HDLC_CONTROL_CHAR) || (src_byte == HDLC_ESC_CHAR))
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = HDLC_ESC_CHAR;
+ dest_buf[converted_length++] = src_byte ^ HDLC_ESC_MASK;
+ }
+ else
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = src_byte;
+ }
+
+ src_byte = (unsigned char)((src_long & 0xff000000) >> 24);
+
+ if ((src_byte == HDLC_CONTROL_CHAR) || (src_byte == HDLC_ESC_CHAR))
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = HDLC_ESC_CHAR;
+ dest_buf[converted_length++] = src_byte ^ HDLC_ESC_MASK;
+ }
+ else
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = src_byte;
+ }
+ }
+
+ src_length = src->bufSize - src->bufIndex;
+ for (; i < src_length; i++)
+ {
+ src_byte = src_buf[i];
+
+ if ((src_byte == HDLC_CONTROL_CHAR) || (src_byte == HDLC_ESC_CHAR))
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = HDLC_ESC_CHAR;
+ dest_buf[converted_length++] = src_byte ^ HDLC_ESC_MASK;
+ }
+ else
+ {
+ crc = CRC_16_L_STEP(crc, src_byte);
+ dest_buf[converted_length++] = src_byte;
+ }
+ }
+
+ crc = ~crc;
+ // ¶ÔµÚÒ»¸öunsigned charµÄcrc½øÐÐתÒë
+ src_byte = (crc & 0xFF);
+
+ if ((src_byte == HDLC_CONTROL_CHAR) || (src_byte == HDLC_ESC_CHAR))
+ {
+ dest_buf[converted_length++] = HDLC_ESC_CHAR;
+ dest_buf[converted_length++] = src_byte ^ HDLC_ESC_MASK;
+ }
+ else
+ {
+ dest_buf[converted_length++] = src_byte;
+ }
+
+ // ¶ÔµÚ¶þ¸öunsigned charµÄcrc½øÐÐתÒë
+ src_byte = (crc >> 8);
+
+ if ((src_byte == HDLC_CONTROL_CHAR) || (src_byte == HDLC_ESC_CHAR))
+ {
+ dest_buf[converted_length++] = HDLC_ESC_CHAR;
+ dest_buf[converted_length++] = src_byte ^ HDLC_ESC_MASK;
+ }
+ else
+ {
+ dest_buf[converted_length++] = src_byte;
+ }
+
+ // Ìí¼Ó½áÊø·û
+ dest_buf[converted_length++] = HDLC_CONTROL_CHAR;
+ dest->bufIndex = converted_length;
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+/**
+ * @brief 16λcrcУÑ鼯Ë㣬
+ * @param[in] buf_ptr ´ýУÑéÊý¾ÝÖ¸Õë
+ * @param[in] len ´ýУÑéÊý¾Ý³¤¶È
+ * @return crcУÑéÖµ£¬Èç¹ûbuf_ptr×îºóÁ½Î»°üº¬ÁËУÑ飬½«·µ»ØCRC_16_L_OK
+ * @note
+ * @see
+ */
+unsigned short crc_16_l_calc(unsigned char *buf_ptr, unsigned int len)
+{
+ unsigned short crc_16;
+
+ for (crc_16 = CRC_16_L_SEED ; len >= 8; len -= 8, buf_ptr++)
+ {
+ crc_16 = crc_16_l_table[(crc_16 ^ *buf_ptr) & 0x00ff ] ^ (crc_16 >> 8);
+ }
+
+ return(~crc_16);
+}
+
+
+/**
+ * @brief ½«Êý¾Ý½øÐÐHDLC½âÂëÖÁÖ¸¶¨µÄµ¥ÏòFIFOÖÐ
+ * FIFOÖ»ÄÜ´ÓÍ·(0λÖÃ)°´Õû°ü¶Á³öÊý¾Ý»ò¶ªÆú£¬½âÂëʱ°´Ë³ÐòдÈëµ½FIFO£¬
+ * ÿÕÒµ½Ò»´ÎÕû°ü£¬Í£Ö¹Ð´È룬Ȼºó¶Á³öÊý¾Ý»òÕß¶ªÆú
+ * ¹ý³ÌÖÐÓò»µ½readPoint£¬Ê¼ÖÕΪ0
+ * @param[out] dest ½âÂëºó´æ´¢µÄFIFOÖ¸Õë
+ * @param[in] src ´ý½âÂëµÄ»º´æÖ¸Õë
+ * @param[in] len ´ý½âÂëµÄ»º´æ³¤¶È
+ * @return ·µ»Ø½âÂëµÄʵ¼Ê³¤¶È
+ * @note
+ * @see
+ */
+UINT32 hdlc_decode(T_RINGBUFFER *dest, unsigned char *src, unsigned int len)
+{
+
+ if (dest != NULL && src != NULL && len > 0 /*&& dest->buf != NULL*/&&
+ dest->capacity > len)
+ {
+ unsigned char *dest_buf = dest->buf + dest->writePoint;
+ unsigned char *src_buf = src;
+ unsigned int dest_length = dest->capacity - dest->writePoint;
+ unsigned int src_length = len;
+
+ unsigned char src_byte = 0;
+ unsigned int converted_length = 0;
+ BOOL findEnd = FALSE;
+ unsigned int i = 0;
+
+ if (dest_length <= src_length)
+ {
+ dest->symbol = HDLC_DECODE_DROP;
+ dest->writePoint = 0;
+ return len;
+ }
+
+ if(dest->symbol == HDLC_DECODE_FIRST_ESCAPE)
+ {
+ // µÚÒ»¸ö×Ö·ûÐèҪתÒå
+ dest_buf[converted_length++] = src_buf[++i] ^ HDLC_ESC_MASK;
+ }
+
+ dest->symbol = HDLC_DECODE_CONTINUE; // ¸´Î»×´Ì¬
+
+ for (i = i; i < src_length; i++)
+ {
+ src_byte = src_buf[i];
+
+ if (src_byte == HDLC_ESC_CHAR)
+ {
+ if (i == (src_length - 1))
+ {
+ i++;
+ dest->symbol = HDLC_DECODE_FIRST_ESCAPE; // ±ê¼ÇÏÂÒ»´Î½âÂëµÄµÚÒ»¸ö×Ö·ûÐèҪתÒå
+ break;
+ }
+ else
+ {
+ dest_buf[converted_length++] = src_buf[++i] ^ HDLC_ESC_MASK;
+ }
+ }
+ else if (src_byte == HDLC_CONTROL_CHAR)
+ {
+ dest_buf[converted_length++] = src_byte;
+ i++;
+ findEnd = TRUE;
+ dest->symbol = HDLC_DECODE_OK;
+ break;
+ }
+ else
+ {
+ dest_buf[converted_length++] = src_byte;
+ }
+
+ if (converted_length >= dest_length)
+ {
+ i++;
+ break;
+ }
+ }
+
+ dest->writePoint += converted_length; // ¸üÐÂдָÕë
+
+ if (findEnd)
+ {
+ unsigned short crc = crc_16_l_calc(dest->buf, (dest->writePoint - 1) * 8);
+
+ if (crc == CRC_16_L_OK)
+ {
+ dest->writePoint -= HDLC_TAIL_SIZE;
+ }
+ else
+ {
+ dest->writePoint = 0;
+ findEnd = FALSE;
+ dest->symbol = HDLC_DECODE_DROP;
+ }
+ }
+
+ return i;
+ }
+ else
+ {
+ return len;
+ }
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcat_drv.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcat_drv.h
index e630a0c..7617ada 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcat_drv.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/logcat_drv.h
@@ -30,6 +30,8 @@
/* AP LOG BEGIN */
#ifndef _LOGCAT_DRV_H
#define _LOGCAT_DRV_H
+#include "ram_config.h"
+#include "ZspTrace.h"
/* AP LOG module name */
#define MODULE_NUMBER 24
@@ -71,23 +73,170 @@
#define MODULE_LEVEL_DEBUG 7 // µ÷ÊÔ¼¶±ðµÄÏûÏ¢
/* AP LOG END */
-#define LEVEL_EMERG 1 // ½ô¼±Ê¼þÏûÏ¢£¬ÏµÍ³±ÀÀ£Ö®Ç°Ìáʾ£¬±íʾϵͳ²»¿ÉÓÃ
-#define LEVEL_ALERT 2 // ±¨¸æÏûÏ¢£¬±íʾ±ØÐëÁ¢¼´²ÉÈ¡´ëÊ©
-#define LEVEL_CRIT 4 // ÁÙ½çÌõ¼þ£¬Í¨³£Éæ¼°ÑÏÖØµÄÓ²¼þ»òÈí¼þ²Ù×÷ʧ°Ü
-#define LEVEL_ERR 8 // ´íÎóÌõ¼þ£¬Çý¶¯³ÌÐò³£ÓÃKERN_ERRÀ´±¨¸æÓ²¼þµÄ´íÎó
-#define LEVEL_WARNING 16 // ¾¯¸æÌõ¼þ£¬¶Ô¿ÉÄܳöÏÖÎÊÌâµÄÇé¿ö½øÐо¯¸æ
-#define LEVEL_NOTICE 32 // Õý³£µ«ÓÖÖØÒªµÄÌõ¼þ£¬ÓÃÓÚÌáÐÑ
-#define LEVEL_INFO 64 // ÌáʾÐÅÏ¢£¬ÈçÇý¶¯³ÌÐòÆô¶¯Ê±£¬´òÓ¡Ó²¼þÐÅÏ¢
-#define LEVEL_DEBUG 128 // µ÷ÊÔ¼¶±ðµÄÏûÏ¢
-#define LEVEL_ALL 255 // ËùÓм¶±ð£¬Ä¬ÈÏÊÇ´òÓ¡ËùÓм¶±ð
+ /* ͨѶģ¿éºÅ */
+#define MDL_TOOLS_BASE (100)
+#define SUBMDL_TOOLAGENT_SET (85)
+#define MDL_ZCAT (MDL_TOOLS_BASE + 15) /* ZCAT¹¤¾ß */
+#define SUBMDL_ZCATAGT (SUBMDL_TOOLAGENT_SET + 0) /* ZCAT¹¤¾ß´úÀí */
+#define MDL_PHONE (1)
+/*CAP core APP and Kernel LOG*/
+#define ZCAT_APP2_RINGBUF_LEN (0x4000)
+#define ZCAT_KERNEL2_RINGBUF_LEN (0x4000)
-typedef unsigned int UINT32;
+#define MAX_PACKET_LEN (0x10000)
+#define MAX_ENCODE_PACKET_LEN (MAX_PACKET_LEN * 2)
+
+#define BOOL int
+#define VOID void
+#define TRUE (1)
+#define FALSE (0)
+
+#ifndef NULL
+#define NULL (0)
+#endif
+
typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned int UINT32;
-#define BOOL int
-#define VOID void
+//AP Header ½á¹¹¶¨Òå
+typedef struct
+{
+ unsigned char priority;
+ unsigned char mod;
+ unsigned short len;
+} T_ZCAT_APLOG_HEADER;
+typedef struct
+{
+ unsigned char *buf;
+ unsigned short len;
+ unsigned short newLine;
+} T_AP_DEST_BUFFER_TYPE;
+
+typedef struct
+{
+ unsigned char *buf;
+ unsigned int beginIndex;
+ unsigned int bufSize;
+} T_AP_SRC_BUFFER_TYPE;
+
+// ZCAT Header½á¹¹¶¨Òå
+typedef struct
+{
+ unsigned char cmd_code;
+ unsigned char padding;
+ unsigned short reserved;
+ unsigned int length;
+ unsigned int timeStamp[2];
+} T_ZCAT_HEADER;
+
+//DIAG Header ½á¹¹¶¨Òå
+typedef struct
+{
+ unsigned short diag_id;
+ unsigned short len;
+} T_ZCAT_DIAG_HEADER;
+
+typedef struct
+{
+ UINT16 type;
+ UINT8 operation;
+ UINT8 reserved;
+} T_ZCAT_DIAG_CONFIG_REQ;
+
+// Comm½á¹¹¶¨Òå
+typedef struct
+{
+ unsigned char msg_type; /* ÏûÏ¢ÀàÐÍ */
+ unsigned char pad; /* Ìî³äλ */
+ unsigned short reserved; /* ±£Áô×ֶΣ¬ÌîΪ0xAAAA */
+ unsigned char tgt_mdl_no; /* Ä¿±ê(½ÓÊÕÏûÏ¢)Ä£¿éÄ£¿éºÅ */
+ unsigned char tgt_submdl_no; /* Ä¿±ê(½ÓÊÕÏûÏ¢)Ä£¿é×ÓÄ£¿éºÅ */
+ unsigned char src_mdl_no; /* Ô´(·¢ËÍÏûÏ¢)Ä£¿éÄ£¿éºÅ */
+ unsigned char src_submdl_no; /* Ô´(·¢ËÍÏûÏ¢)Ä£¿é×ÓÄ£¿éºÅ */
+ unsigned int buf_len; /* ÏûÏ¢Êý¾Ý³¤¶È(²»º¬ÏûϢͷ) */
+} T_COMM_TYPE;
+
+typedef struct
+{
+ unsigned short DbgID;
+ unsigned short Filter;
+ unsigned int MsgID;
+ unsigned int Length;
+} T_ZCAT_DBG_HEADER;
+
+/* zcatÈ«¾ÖÐÅÏ¢ */
+typedef struct
+{
+ int status;
+ int peripheral_mode;
+ char usblog_path[8];
+} T_ZCAT_CONFIG_INFO;
+
+typedef BOOL (*GetMask)(UINT8 **buf, UINT32 *len);
+typedef BOOL (*SetMask)(UINT8 *buf, UINT32 len);
+typedef VOID (*SetEnable)(BOOL enable);
+
+typedef struct
+{
+ GetMask get_mask;
+ SetMask set_mask;
+ SetEnable set_enable;
+} T_ZCAT_DIAG_CONFIG_FUNC;
+
+typedef struct
+{
+ UINT16 type;
+ UINT16 direction;
+ T_ZCAT_DIAG_CONFIG_FUNC *func;
+} T_ZCAT_DIAG_FILTER_CONFIG_TABLE;
+
+typedef struct
+{
+ UINT8 *buf;
+ UINT32 bufIndex; // Ö¸ÕëÆ«ÒÆ
+ UINT32 bufSize;
+} T_HDLC_BUFFER_TYPE;
+
+typedef enum
+{
+ ZCAT_STATE_INIT = 0,
+ ZCAT_STATE_RUNNING,
+ ZCAT_STATE_STOP,
+ ZCAT_STATE_EXIT
+} E_ZCAT_STATE;
+
+typedef enum
+{
+ ZCAT_MODE_AP_USB = 0xC1,
+ ZCAT_MODE_AP_NET,
+ ZCAT_MODE_AP_TF,
+ ZCAT_MODE_AP_FS,
+ ZCAT_MODE_CP_USB,
+ ZCAT_MODE_CP_TF,
+ ZCAT_MODE_CP_NET,
+ ZCAT_MODE_CP_FS,
+ ZCAT_MODE_CAP_FS
+} E_ZCAT_MODE;
+
+typedef enum
+{
+ DIAG_FILTER_CONFIG = 1,
+ DIAG_DROP_COUNT,
+ DIAG_LINK_MSG,
+ DIAG_SIG_CONTROL_MSG,
+ DIAG_NV_MSG,
+ DIAG_LTE_CONTROL_MSG,
+ DIAG_PS_GLB_MSG,
+ DIAG_PS_FILTERRANK_MSG,
+ DIAG_UE_MEM_LOOKUP,
+ DIAG_RAMDUMP_MSG,
+ DIAG_TSPVERSION_MSG,
+ DIAG_SYSVIEW_MSG,
+ DIAG_CP_STATUS
+}DIAG_CONDITION;
typedef enum
{
@@ -102,13 +251,108 @@
ZCAT_IPC_ALLOC_CAP_SMLOGBUF,
} E_ZCAT_IPC_HANDSHAKE;
-/* zcatÈ«¾ÖÐÅÏ¢ */
-typedef struct
+typedef enum
{
- int status;
- int peripheral_mode;
- char usblog_path[8];
-} T_ZCAT_CONFIG_INFO;
+ ZCAT_SIG_REPORT = 1,
+ ZCAT_EVT_REPORT = 2,
+ ZCAT_PRN_REPORT = 3,
+ ZCAT_DBG_REPORT = 4,
+ ZCAT_IPPPP_REPORT = 5,
+ ZCAT_DIAG_REPORT = 6,
+ ZCAT_DIAG_NULL, //ֻռһ룬²»Ê¹Óã¬Ê¹ÓëPC¶ÔÆë
+ ZCAT_AP_KERNEL_LOG = 8,
+ ZCAT_AP_APP_LOG = 9,
+ ZCAT_SIG_PHY = 10, // ±ê×¼ÐÅÁîµÄphy log
+ ZCAT_AP2_KERNEL_LOG = 13, // ap kernel log
+ ZCAT_AP2_APP_LOG = 14, // ap app log
+
+ ZCAT_CMDCODE_MAX
+} T_ZCAT_CMDCODE;
+
+typedef enum
+{
+ LEVEL_EMERGENCY = 0, // ÓÃÓÚ½ô¼±Ê¼þÏûÏ¢£¬Ò»°ãÊÇϵͳ±ÀÀ£Ö®Ç°ÌáʾµÄÏûÏ¢
+ LEVEL_ALERT, // ÓÃÓÚÐèÒªÁ¢¼´²ÉÈ¡¶¯×÷µÄÇé¿ö
+ LEVEL_CRITICAL, // ÁÙ½ç״̬£¬Í¨³£Éæ¼°ÑÏÖØµÄÓ²¼þ»òÈí¼þ²Ù×÷ʧ°Ü
+ LEVEL_ERROR, // ÓÃÓÚ±¨¸æ´íÎó״̬£¬ÈçÉ豸Çý¶¯³ÌÐò¾³£ÓÃÀ´±¨¸æÀ´×ÔÓ²¼þµÄÎÊÌâ
+ LEVEL_WARNING, // ¶Ô¿ÉÄܳöÏÖÎÊÌâµÄÇé¿ö½øÐо¯¸æ£¬Í¨³£²»»á¶ÔϵͳÔì³ÉÑÏÖØÎÊÌâ
+ LEVEL_NOTICE, // ÓбØÒª½øÐÐÌáʾµÄÕý³£ÇéÐΣ¬ÈçÓ밲ȫÏà¹ØµÄ×´¿ö»ã±¨
+ LEVEL_INFOMATION, // ÌáʾÐÔÐÅÏ¢£¬ÈçÇý¶¯³ÌÐòÔÚÆô¶¯Ê±´òÓ¡ËûÃÇÕÒµ½µÄÓ²¼þÐÅÏ¢
+ LEVEL_DEBUG, // ÓÃÓÚµ÷ÊÔÐÅÏ¢
+ LEVEL_PRICNT
+} E_ZCAT_AP_PRIORITY;
+
+typedef enum
+{
+ DBG_TYPE_TOTAL = 0,
+ DBG_GSM_PHY = 1,
+ DBG_TD_PHY = 2,
+ DBG_LTE_PHY = 3,
+ DBG_WCDMA_PHY = 4,
+ DBG_PS_PRIMARY = 5,
+
+ DBG_PS_EXCEPTION = 8,
+ DBG_PS_GLOBAL = 9,
+ DBG_NR5G_PHY = 10,
+ DBG_DSP_PHY = 11,
+ DBG_LTE_V2X_PHY = 12,
+ DBG_NR_V2X_PHY = 13,
+ DBG_DSP1_PHY = 14,
+ DBG_LTE_V2X_DSP = 15,
+ DBG_NR_V2X_DSP = 16,
+ DBG_ALL_TYPE
+} DBG_ENUM_TYPE;
+
+typedef enum
+{
+ ZCAT_SIG_TYPE = (ZCAT_SIG_REPORT),
+ ZCAT_EVENT_TYPE = (ZCAT_EVT_REPORT),
+ ZCAT_PRINT_TYPE = (ZCAT_PRN_REPORT),
+ ZCAT_DBG_TYPE = (ZCAT_DBG_REPORT),
+ ZCAT_IPPPP_TYPE = (ZCAT_IPPPP_REPORT),
+ ZCAT_DIAG_TYPE = (ZCAT_DIAG_REPORT),
+ ZCAT_AP_KERNEL_TYPE = (ZCAT_AP_KERNEL_LOG),
+ ZCAT_AP_APP_TYPE = (ZCAT_AP_APP_LOG),
+ ZCAT_AP2_KERNEL_TYPE = (ZCAT_AP2_KERNEL_LOG),
+ ZCAT_AP2_APP_TYPE = (ZCAT_AP2_APP_LOG),
+ ZCAT_DBG_TYPE_TOTAL = ((DBG_TYPE_TOTAL << 8) | ZCAT_DBG_REPORT),
+ ZCAT_DBG_GSM_PHY = ((DBG_GSM_PHY << 8) | ZCAT_DBG_REPORT),
+ ZCAT_DBG_TD_PHY = ((DBG_TD_PHY << 8) | ZCAT_DBG_REPORT),
+ ZCAT_DBG_LTE_PHY = ((DBG_LTE_PHY << 8) | ZCAT_DBG_REPORT),
+ ZCAT_DBG_WCDMA_PHY = ((DBG_WCDMA_PHY << 8) | ZCAT_DBG_REPORT),
+ ZCAT_DBG_PS_PRIMARY = ((DBG_PS_PRIMARY << 8) | ZCAT_DBG_REPORT),
+ ZCAT_DBG_PS_EXCEPTION = ((DBG_PS_EXCEPTION << 8) | ZCAT_DBG_REPORT),
+ ZCAT_DBG_PS_GLOBAL = ((DBG_PS_GLOBAL << 8) | ZCAT_DBG_REPORT),
+ ZCAT_DBG_ALL_TYPE = ((DBG_ALL_TYPE << 8) | ZCAT_DBG_REPORT),
+ ZCAT_FILTER_VIEW = 0xFFFE,
+ ZCAT_ALL_TYPE = 0xFFFF
+} ZCAT_ENUM_TYPE;
+
+/**
+ * @brief commÍ·ÐÅÏ¢³õʼ»¯
+ * @param[in] buf ·¢ËÍÊý¾Ý(±ØÐëÊÇÓÉComm_MallocÉêÇëµÄÄÚ´æ!!!)
+ * @param[in] buf_len ·¢ËÍÊý¾ÝµÄ³¤¶È
+ * @param[in] tgt_mdl_no Ä¿±êÄ£¿éºÅ£¬ÊÖ»ú»òPCµÈ
+ * @param[in] tgt_submdl_no Ä¿±ê×ÓÄ£¿éºÅ
+ * @param[in] src_submdl_no Ô´×ÓÄ£¿éºÅ
+ * @return ³É¹¦·µ»ØZOSS_SUCCESS, ·ñÔò·µ»ØZOSS_ERROR
+ * @note
+ * @see
+ */
+extern VOID Comm_HeaderInit(T_COMM_TYPE *commHeader, UINT32 buf_len,
+ UINT8 tgt_mdl_no, UINT8 tgt_submdl_no, UINT8 src_submdl_no);
+
+/**
+ * @brief ZCATÏûϢͷ³õʼ»¯
+ * @param[out] zcatHeader ÏûϢͷָÕë
+ * @param[in] cmd_code ÏûÏ¢Âë
+ * @param[in] len ÏûÏ¢³¤¶È
+ * @return void
+ * @note
+ * @see
+ */
+extern VOID zCatAgt_HeaderInit(T_ZCAT_HEADER *zcatHeader, UINT8 cmd_code, UINT32 len);
#endif /* !_LOGCAT_DRV_H */
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/ringbuf.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/ringbuf.c
index 4e2b05f..acbdc9b 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/ringbuf.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/ringbuf.c
@@ -117,14 +117,14 @@
{
ringBuf = (T_RINGBUFFER *)buf;
}
- printk("CreateRingBuffer buf 0x%x 000\n", buf);
+ printk("CreateRingBuffer buf 0x%x 000\n", buf);
ringBuf->capacity = bufSize - sizeof(T_RINGBUFFER);
-
- printk("CreateRingBuffer buf 0x%x 11---\n", buf);
+
+ printk("CreateRingBuffer buf 0x%x 11---\n", buf);
ringBuf->readPoint = 0;
ringBuf->writePoint = 0;
ringBuf->symbol = SYMBOL_VALUE;
- printk("CreateRingBuffer buf 0x%x 222---\n", buf);
+ printk("CreateRingBuffer buf 0x%x 222---\n", buf);
return ringBuf;
}
@@ -152,10 +152,10 @@
return 0;
}
if( writePoint >= ringBuf->capacity || readPoint >= ringBuf->capacity )
- {
+ {
return 0;
- }
-
+ }
+
if (writePoint >= readPoint)
{
if (ringBuf->capacity - writePoint > len)
@@ -227,8 +227,11 @@
readLen = writePoint - readPoint;
readLen = (readLen >= len) ? len : readLen;
- if (ZCAT_MEM_TYPE_USER == flags) { copy_to_user(buf, ringBuf->buf + readPoint, readLen); }
- else { memcpy(buf, ringBuf->buf + readPoint, readLen); }
+ if (ZCAT_MEM_TYPE_USER == flags)
+ copy_to_user(buf, ringBuf->buf + readPoint, readLen);
+ else
+ memcpy(buf, ringBuf->buf + readPoint, readLen);
+
ringBuf->readPoint += readLen;
}
else if (writePoint < readPoint)
@@ -238,19 +241,26 @@
if (ringBuf->capacity - readPoint >= readLen)
{
- if (ZCAT_MEM_TYPE_USER == flags) { copy_to_user(buf, ringBuf->buf + readPoint, readLen); }
- else { memcpy(buf, ringBuf->buf + readPoint, readLen); }
+ if (ZCAT_MEM_TYPE_USER == flags)
+ copy_to_user(buf, ringBuf->buf + readPoint, readLen);
+ else
+ memcpy(buf, ringBuf->buf + readPoint, readLen);
+
ringBuf->readPoint = (ringBuf->readPoint + readLen) % ringBuf->capacity;
}
else
{
UINT32 copyLen = ringBuf->capacity - readPoint;
- if (ZCAT_MEM_TYPE_USER == flags) { copy_to_user(buf, ringBuf->buf + readPoint, copyLen); }
- else { memcpy(buf, ringBuf->buf + readPoint, copyLen); }
+ if (ZCAT_MEM_TYPE_USER == flags)
+ copy_to_user(buf, ringBuf->buf + readPoint, copyLen);
+ else
+ memcpy(buf, ringBuf->buf + readPoint, copyLen);
copyLen = readLen - copyLen;
- if (ZCAT_MEM_TYPE_USER == flags) { copy_to_user(buf + (readLen - copyLen), ringBuf->buf, copyLen); }
- else { memcpy(buf + (readLen - copyLen), ringBuf->buf, copyLen);}
+ if (ZCAT_MEM_TYPE_USER == flags)
+ copy_to_user(buf + (readLen - copyLen), ringBuf->buf, copyLen);
+ else
+ memcpy(buf + (readLen - copyLen), ringBuf->buf, copyLen);
ringBuf->readPoint = copyLen;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_ap.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_ap.c
new file mode 100755
index 0000000..5aab8d0
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_ap.c
@@ -0,0 +1,209 @@
+/**
+ *
+ * @file zcatagt_ap.c
+ * @brief
+ * This file is part of ZCAT.
+ * ZCAT¹¤¾ßapÏûÏ¢´¦ÀíÄ£¿é
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2023/05/27 1.0 syx Create file
+ * ---------------------------------------------------------------------------
+ *
+ */
+
+/**
+ * Í·Îļþ
+ */
+#include "logcat_drv.h"
+//#include "zcatagt.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * ºê¶¨Òå
+ */
+
+/**
+ * Êý¾ÝÀàÐͶ¨Òå
+ */
+
+/**
+ * ¾Ö²¿º¯ÊýÉùÃ÷
+ */
+static BOOL zCatAgt_Kernel_GetMask(UINT8 **buf, UINT32 *len);
+static BOOL zCatAgt_Kernel_SetMask(UINT8 *buf, UINT32 len);
+static VOID zCatAgt_Kernel_SetEnable(BOOL enable);
+static BOOL zCatAgt_App_GetMask(UINT8 **buf, UINT32 *len);
+static BOOL zCatAgt_App_SetMask(UINT8 *buf, UINT32 len);
+static VOID zCatAgt_App_SetEnable(BOOL enable);
+static VOID zCatAgt_Ap2_Kernel_SetEnable(BOOL enable);
+static VOID zCatAgt_Ap2_App_SetEnable(BOOL enable);
+
+/**
+ * ÄÚ²¿È«¾Ö±äÁ¿
+ */
+static BOOL g_KernelEnabled;
+static BOOL g_AppEnabled;
+
+BOOL g_Ap2KernelEnabled;
+BOOL g_Ap2AppEnabled;
+
+/**
+ * È«¾Ö±äÁ¿ÉùÃ÷
+ */
+T_ZCAT_DIAG_CONFIG_FUNC g_KernelConfigFunc =
+{
+ zCatAgt_Kernel_GetMask,
+ zCatAgt_Kernel_SetMask,
+ zCatAgt_Kernel_SetEnable,
+};
+
+T_ZCAT_DIAG_CONFIG_FUNC g_AppConfigFunc =
+{
+ zCatAgt_App_GetMask,
+ zCatAgt_App_SetMask,
+ zCatAgt_App_SetEnable,
+};
+
+T_ZCAT_DIAG_CONFIG_FUNC g_Ap2KernelConfigFunc =
+{
+ zCatAgt_Kernel_GetMask,
+ zCatAgt_Kernel_SetMask,
+ zCatAgt_Ap2_Kernel_SetEnable,
+};
+
+T_ZCAT_DIAG_CONFIG_FUNC g_Ap2AppConfigFunc =
+{
+ zCatAgt_App_GetMask,
+ zCatAgt_App_SetMask,
+ zCatAgt_Ap2_App_SetEnable,
+};
+
+/**
+ * Íⲿ±äÁ¿ÒýÓÃ
+ */
+
+/**
+ * º¯ÊýʵÏÖ
+ */
+
+/**
+ * @brief »ñÈ¡AP Kernel LOG¹ýÂ˹æÔò
+ * @param[out] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[out] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_Kernel_GetMask(UINT8 **buf, UINT32 *len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃAP Kernel LOG¹ýÂ˹æÔò
+ * @param[in] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[in] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_Kernel_SetMask(UINT8 *buf, UINT32 len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃAP Kernel LOGÊÇ·ñ¸ú×Ù
+ * @param[in] enable TRUE:¸ú×Ù, FALSE:²»¸ú×Ù
+ * @return void
+ * @note
+ * @see
+ */
+static VOID zCatAgt_Kernel_SetEnable(BOOL enable)
+{
+ g_KernelEnabled = enable;
+}
+
+/**
+ * @brief ÉèÖÃAP2 Kernel LOGÊÇ·ñ¸ú×Ù
+ * @param[in] enable TRUE:¸ú×Ù, FALSE:²»¸ú×Ù
+ * @return void
+ * @note
+ * @see
+ */
+static VOID zCatAgt_Ap2_Kernel_SetEnable(BOOL enable)
+{
+ g_Ap2KernelEnabled = enable;
+}
+
+/**
+ * @brief »ñÈ¡AP App LOG¹ýÂ˹æÔò
+ * @param[out] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[out] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_App_GetMask(UINT8 **buf, UINT32 *len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃAP App LOG¹ýÂ˹æÔò
+ * @param[in] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[in] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_App_SetMask(UINT8 *buf, UINT32 len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃAP App LOGÊÇ·ñ¸ú×Ù
+ * @param[in] enable TRUE:¸ú×Ù, FALSE:²»¸ú×Ù
+ * @return void
+ * @note
+ * @see
+ */
+static VOID zCatAgt_App_SetEnable(BOOL enable)
+{
+ g_AppEnabled = enable;
+}
+
+/**
+ * @brief ÉèÖÃAP2 App LOGÊÇ·ñ¸ú×Ù
+ * @param[in] enable TRUE:¸ú×Ù, FALSE:²»¸ú×Ù
+ * @return void
+ * @note
+ * @see
+ */
+static VOID zCatAgt_Ap2_App_SetEnable(BOOL enable)
+{
+ g_Ap2AppEnabled = enable;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_lte.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_lte.c
new file mode 100755
index 0000000..68eb888
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_lte.c
@@ -0,0 +1,115 @@
+/**
+ *
+ * @file zcatagt_lte.c
+ * @brief
+ * This file is part of ZCAT.
+ * ZCAT¹¤¾ßlte phyÏûÏ¢´¦ÀíÄ£¿é
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2023/05/27 1.0 syx Create file
+ * ---------------------------------------------------------------------------
+
+ *
+ *
+ */
+
+/**
+ * Í·Îļþ
+ */
+#include "logcat_drv.h"
+//#include "zcatagt.h"
+
+/**
+ * ºê¶¨Òå
+ */
+
+/**
+ * Íⲿº¯ÊýÒýÓÃ
+ */
+
+/**
+ * È«¾Öº¯ÊýÉùÃ÷
+ */
+
+/**
+ * ¾Ö²¿º¯ÊýÉùÃ÷
+ */
+static BOOL zCatAgt_Lte_GetMask(UINT8 **buf, UINT32 *len);
+static BOOL zCatAgt_Lte_SetMask(UINT8 *buf, UINT32 len);
+static VOID zCatAgt_Lte_SetEnable(BOOL enable);
+
+/**
+ * Íⲿ±äÁ¿ÒýÓÃ
+ */
+
+/**
+ * È«¾Ö±äÁ¿ÉùÃ÷
+ */
+T_ZCAT_DIAG_CONFIG_FUNC g_LteConfigFunc =
+{
+ zCatAgt_Lte_GetMask,
+ zCatAgt_Lte_SetMask,
+ zCatAgt_Lte_SetEnable
+};
+
+/**
+ * ÄÚ²¿È«¾Ö±äÁ¿
+ */
+BOOL g_LteEnabled = FALSE;
+
+/**
+ * º¯ÊýʵÏÖ
+ */
+
+/**
+ * @brief »ñÈ¡LTE PHY LOG¹ýÂ˹æÔò
+ * @param[out] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[out] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_Lte_GetMask(UINT8 **buf, UINT32 *len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃLTE PHY LOG¹ýÂ˹æÔò
+ * @param[in] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[in] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_Lte_SetMask(UINT8 *buf, UINT32 len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃLTE PHY LOGÊÇ·ñ¸ú×Ù
+ * @param[in] enable TRUE:¸ú×Ù, FALSE:²»¸ú×Ù
+ * @return void
+ * @note
+ * @see
+ */
+static VOID zCatAgt_Lte_SetEnable(BOOL enable)
+{
+ g_LteEnabled = enable;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_phy.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_phy.c
new file mode 100755
index 0000000..ee8c862
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_phy.c
@@ -0,0 +1,220 @@
+/**
+ *
+ * @file zcatagt_phy.c
+ * @brief
+ * This file is part of ZCAT.
+ * ZCAT¹¤¾ßphyÏûÏ¢´¦ÀíÄ£¿é
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2020/09/04
+ * @version 1.0
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2023/05/16 1.0 syx Create file
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+/**
+ * Í·Îļþ
+ */
+
+#include "logcat_drv.h"
+#include <asm/cache.h>
+#include <asm/cacheflush.h>
+#include <linux/dma-direction.h>
+
+/**
+ * Íⲿ±äÁ¿ÉùÃ÷
+ */
+extern int g_LteEnabled;
+extern int g_WEnabled;
+extern int g_SigEnabled;
+extern int g_TdEnabled;
+extern UINT8 *g_CAP_ZspLogAddr;
+extern UINT8 *g_CAP_IramPhy;
+
+/**
+ * ºê¶¨Òå
+ */
+#define CAP_PHYS_TO_VIRT(phy) ((phy) - TOOL_ZSP_TO_CAP_LOG_ADDR_PA + g_CAP_ZspLogAddr)
+#define CAP_VIRT_TO_PHYS(addr) ((addr) - g_CAP_ZspLogAddr + TOOL_ZSP_TO_CAP_LOG_ADDR_PA)
+
+/*CAP read zsp log addr*/
+#undef ZCAT_PHY_LOG_UNIT_HEAD
+#undef ZCAT_PHY_LOG_UNIT_TAIL
+#undef ZCAT_PHY_LOG_Free_UNIT_BUF
+#undef ZCAT_PHY_LOG_Free_UNIT_LEN
+#undef ZCAT_PHY_LOG_OFF
+#undef ZCAT_PHY_LOG_ZSP_BUF_READY
+
+#define ZCAT_PHY_LOG_UNIT_HEAD (g_CAP_IramPhy)
+#define ZCAT_PHY_LOG_UNIT_TAIL (ZCAT_PHY_LOG_UNIT_HEAD + (4>>CPU_SHIFT))
+#define ZCAT_PHY_LOG_Free_UNIT_BUF (ZCAT_PHY_LOG_UNIT_TAIL + (4>>CPU_SHIFT))
+#define ZCAT_PHY_LOG_Free_UNIT_LEN (96>>CPU_SHIFT) /* (24 * 4)B = 384K*/
+#define ZCAT_PHY_LOG_OFF (ZCAT_PHY_LOG_UNIT_HEAD + (16>>CPU_SHIFT) + ZCAT_PHY_LOG_Free_UNIT_LEN) /* ¶àÔ¤ÁôÁË8×Ö½Ú */
+#define ZCAT_PHY_LOG_ZSP_BUF_READY (ZCAT_PHY_LOG_OFF + (4>>CPU_SHIFT))
+
+/**
+ * Íⲿº¯ÊýÉùÃ÷
+ */
+extern void v7_dma_map_area(const void *, size_t, int);
+extern VOID zCatAgt_Sig_ProcessPhyLog(T_ZCAT_Phy_Log_Unit_Header *unit_header);
+extern VOID zCatAgt_Phy_ReleaseUnit(T_ZCAT_Phy_Log_Unit_Header *buf);
+
+/**
+ * º¯ÊýʵÏÖ
+ */
+/**
+ * @brief Porcess PHY Print LOG
+ * @param[in] unit_header:ÎïÀí²ãlogµ¥ÔªÍ·
+ * @return void
+ * @note
+ * @see
+ */
+UINT32 zCatAgt_Phy_ReadZspFlag(void)
+{
+ return *(volatile UINT32 *)ZCAT_PHY_LOG_ZSP_BUF_READY;
+}
+
+/**
+ * @brief Porcess PHY Print LOG
+ * @param[in] unit_header:ÎïÀí²ãlogµ¥ÔªÍ·
+ * @return void
+ * @note
+ * @see
+ */
+VOID zCatAgt_PRT_ProcessPhyLog(T_ZCAT_Phy_Log_Unit_Header *unit_header)
+{
+ UINT32 msgLen = unit_header->len - ZCAT_PHY_PRT_LOG_OFFSET;
+ UINT32 rat_type = unit_header->type;
+ T_COMM_TYPE *comm_header = (T_COMM_TYPE *)unit_header;
+ T_ZCAT_HEADER *zcat_header = (T_ZCAT_HEADER *)((char *)comm_header + sizeof(T_COMM_TYPE));
+ T_ZCAT_DBG_HEADER *zcat_dbg_header = (T_ZCAT_DBG_HEADER *)((char *)zcat_header + sizeof(T_ZCAT_HEADER));
+
+ if (rat_type == LOG_LTE)
+ zcat_dbg_header->DbgID = DBG_LTE_PHY;
+ else if (rat_type == LOG_W)
+ zcat_dbg_header->DbgID = DBG_WCDMA_PHY;
+ else if (rat_type == LOG_TD)
+ zcat_dbg_header->DbgID = DBG_TD_PHY;
+ else
+ panic("error: zCatAgt_PRT_ProcessPhyLog rat_type");
+ zcat_dbg_header->Length = msgLen;
+ zCatAgt_HeaderInit(zcat_header, ZCAT_DBG_REPORT, msgLen + sizeof(T_ZCAT_DBG_HEADER));
+ Comm_HeaderInit(comm_header, msgLen + sizeof(T_ZCAT_DBG_HEADER) + sizeof(T_ZCAT_HEADER), MDL_ZCAT, 1, SUBMDL_ZCATAGT);
+}
+
+static BOOL zCatAgt_Phy_Read(void **ptr, UINT32 *size, UINT16 *read_ptr, UINT16 *write_ptr, UINT32 content)
+{
+ UINT16 read_pos;
+ UINT16 write_pos;
+ UINT32 header_addr;
+ T_ZCAT_Phy_Log_Unit_Header *header;
+
+ read_pos = *read_ptr;
+ write_pos = *write_ptr;
+
+ if (read_pos != write_pos)
+ {
+ header_addr = *(UINT32 *)(content + read_pos);
+ dsb();
+ read_pos += 4;
+
+ if (read_pos == ZCAT_PHY_LOG_CONTROL_LEN)
+ read_pos = 0;
+ *read_ptr = read_pos;
+
+ header = (T_ZCAT_Phy_Log_Unit_Header *)(CAP_PHYS_TO_VIRT(header_addr << 1));
+
+ v7_dma_map_area((void *)header, ZCAT_PHY_LOG_UNIT_SIZE, DMA_FROM_DEVICE);
+
+ dsb();
+ *ptr = header;
+ *size = header->len;
+ if (unlikely(header->type == LOG_SIG))
+ zCatAgt_Sig_ProcessPhyLog(header);
+ else
+ zCatAgt_PRT_ProcessPhyLog(header);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * @brief Read LTE PHY LOG
+ * @param[out] ptr:Ö¸Ïòphy logµÄÖ¸Õë
+ * @param[out] size:logµÄ³¤¶È
+ * @return void
+ * @note
+ * @see
+ */
+BOOL zCatAgt_Phy_ReadData(void **ptr, UINT32 *size)
+{
+ BOOL bRet = FALSE;
+
+ bRet = zCatAgt_Phy_Read(ptr, size, (UINT16 *)ZCAT_LTE_LOG_CONTROL_RPOINTER, (UINT16 *)ZCAT_LTE_LOG_CONTROL_WPOINTER, ZCAT_LTE_LOG_CONTROL_CONTENT);
+ if (bRet)
+ {
+ if (g_LteEnabled)
+ return bRet;
+ else
+ zCatAgt_Phy_ReleaseUnit((T_ZCAT_Phy_Log_Unit_Header *)*ptr);
+ }
+
+ bRet = zCatAgt_Phy_Read(ptr, size, (UINT16 *)ZCAT_SIG_LOG_CONTROL_RPOINTER, (UINT16 *)ZCAT_SIG_LOG_CONTROL_WPOINTER, ZCAT_SIG_LOG_CONTROL_CONTENT);
+ if (bRet)
+ {
+ if (g_SigEnabled)
+ return bRet;
+ else
+ zCatAgt_Phy_ReleaseUnit((T_ZCAT_Phy_Log_Unit_Header *)*ptr);
+ }
+
+ bRet = zCatAgt_Phy_Read(ptr, size, (UINT16 *)ZCAT_W_LOG_CONTROL_RPOINTER, (UINT16 *)ZCAT_W_LOG_CONTROL_WPOINTER, ZCAT_W_LOG_CONTROL_CONTENT);
+ if (bRet)
+ {
+ if (g_WEnabled)
+ return bRet;
+ else
+ zCatAgt_Phy_ReleaseUnit((T_ZCAT_Phy_Log_Unit_Header *)*ptr);
+ }
+
+ bRet = zCatAgt_Phy_Read(ptr, size, (UINT16 *)ZCAT_TD_LOG_CONTROL_RPOINTER, (UINT16 *)ZCAT_TD_LOG_CONTROL_WPOINTER, ZCAT_TD_LOG_CONTROL_CONTENT);
+ if (bRet)
+ {
+ if (g_TdEnabled)
+ return bRet;
+ else
+ zCatAgt_Phy_ReleaseUnit((T_ZCAT_Phy_Log_Unit_Header *)*ptr);
+ }
+ return bRet;
+}
+
+VOID zCatAgt_Phy_ReleaseUnit(T_ZCAT_Phy_Log_Unit_Header *buf)
+{
+ UINT32 tail;
+
+ ((T_ZCAT_Phy_Log_Unit_Header *)buf)->type = 0;
+ v7_dma_map_area((void *)buf, L1_CACHE_BYTES, DMA_TO_DEVICE);
+
+ tail = *(volatile unsigned long *)ZCAT_PHY_LOG_UNIT_TAIL;
+ tail++;
+ if (tail == ZCAT_PHY_LOG_UNIT_NUM)
+ tail = 0;
+ *(volatile unsigned long *)(ZCAT_PHY_LOG_Free_UNIT_BUF + (tail * sizeof(UINT32))) = (unsigned long)((CAP_VIRT_TO_PHYS((UINT8 *)buf)) >> 1);
+ dsb();
+ *(volatile unsigned long *)ZCAT_PHY_LOG_UNIT_TAIL = tail;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_sig.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_sig.c
new file mode 100755
index 0000000..8b68c93
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_sig.c
@@ -0,0 +1,132 @@
+/**
+ *
+ * @file zcatagt_sig.c
+ * @brief
+ * This file is part of ZCAT.
+ * ZCAT¹¤¾ßpsÐÒéÕ»±ê×¼ÐÅÁîÏûÏ¢´¦ÀíÄ£¿é
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2023/05/19 1.0 syx sig phy log
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+/**
+ * Í·Îļþ
+ */
+#include "logcat_drv.h"
+
+/**
+ * ºê¶¨Òå
+ */
+
+/**
+ * ¾Ö²¿º¯ÊýÉùÃ÷
+ */
+static BOOL zCatAgt_Sig_GetMask(UINT8 **buf, UINT32 *len);
+static BOOL zCatAgt_Sig_SetMask(UINT8 *buf, UINT32 len);
+static VOID zCatAgt_Sig_SetEnable(BOOL enable);
+
+/**
+ * È«¾Ö±äÁ¿¶¨Òå
+ */
+BOOL g_SigEnabled = FALSE;
+
+T_ZCAT_DIAG_CONFIG_FUNC g_SigConfigFunc =
+{
+ zCatAgt_Sig_GetMask,
+ zCatAgt_Sig_SetMask,
+ zCatAgt_Sig_SetEnable
+};
+
+
+/**
+ * @brief »ñÈ¡±ê×¼ÐÅÁîLOG¹ýÂ˹æÔò
+ * @param[out] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[out] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_Sig_GetMask(UINT8 **buf, UINT32 *len)
+{
+
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖñê×¼ÐÅÁîLOG¹ýÂ˹æÔò
+ * @param[in] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[in] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_Sig_SetMask(UINT8 *buf, UINT32 len)
+{
+ return TRUE;
+}
+
+
+/**
+ * @brief ÉèÖñê×¼ÐÅÁîLOGÊÇ·ñ¸ú×Ù
+ * @param[in] enable TRUE:¸ú×Ù, FALSE:²»¸ú×Ù
+ * @return void
+ * @note
+ * @see
+ */
+static VOID zCatAgt_Sig_SetEnable(BOOL enable)
+{
+ g_SigEnabled = enable;
+}
+
+/**
+ * @brief ´¦ÀíÎïÀí²ãSig log
+ * @param[in] unit_header ÎïÀí²ãlog unitÍ·
+ * @return void
+ * @note
+ * @see
+ */
+VOID zCatAgt_Sig_ProcessPhyLog(T_ZCAT_Phy_Log_Unit_Header *unit_header)
+{
+ char *phy_log = (char *)unit_header + ZCAT_PHY_STD_LOG_OFFSET;
+ UINT32 msgLen = unit_header->len - ZCAT_PHY_STD_LOG_OFFSET;
+ T_COMM_TYPE *comm_header = (T_COMM_TYPE *)unit_header;
+ T_ZCAT_HEADER *zcat_header = (T_ZCAT_HEADER *)((char *)comm_header + sizeof(T_COMM_TYPE));
+#ifdef _USE_TestHarness
+ THHeader *pThBuf = NULL;
+#endif
+
+ zCatAgt_HeaderInit(zcat_header, ZCAT_SIG_PHY, msgLen);
+ Comm_HeaderInit(comm_header, msgLen + sizeof(T_ZCAT_HEADER), MDL_ZCAT, 1, SUBMDL_ZCATAGT);
+
+#ifdef _USE_TestHarness
+ pThBuf = (THHeader*)Comm_Malloc(sizeof(THHeader) + msgLen);
+ if(pThBuf == NULL)
+ {
+ return;
+ }
+ pThBuf->header = 0x5abc5a5a;
+ pThBuf->type = 3 << 14;
+ pThBuf->len = msgLen;
+ pThBuf->MsgID = 0;
+ memcpy((UINT8 *)pThBuf + sizeof(THHeader), (UINT8 *)phy_log, msgLen);
+ zTools_SendData((UINT8 *)pThBuf, sizeof(THHeader) + msgLen, 118, 1, 87);
+#endif
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_td.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_td.c
new file mode 100755
index 0000000..a6bd3e3
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_td.c
@@ -0,0 +1,104 @@
+/**
+ *
+ * @file zcatagt_td.c
+ * @brief
+ * This file is part of ZCAT.
+ * ZCAT¹¤¾ßtd phyÏûÏ¢´¦ÀíÄ£¿é
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2013/01/21 1.0 lu.xieji Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * 2019/03/11 1.2 dai.kang Ö§³ÖÎïÀí²ãlogÇø¼ä¶¯Ì¬·ÖÅä
+ * 2020/09/04 1.3 dai.kang phy->ps log»º´æ»úÖÆÓÅ»¯£¬psÅäºÏÐÞ¸Ä
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+/**
+ * Í·Îļþ
+ */
+#include "logcat_drv.h"
+
+/**
+ * ºê¶¨Òå
+ */
+
+/**
+ * ¾Ö²¿º¯ÊýÉùÃ÷
+ */
+static BOOL zCatAgt_Td_GetMask(UINT8 **buf, UINT32 *len);
+static BOOL zCatAgt_Td_SetMask(UINT8 *buf, UINT32 len);
+static VOID zCatAgt_Td_SetEnable(BOOL enable);
+
+/**
+ * È«¾Ö±äÁ¿¶¨Òå
+ */
+T_ZCAT_DIAG_CONFIG_FUNC g_TdConfigFunc =
+{
+ zCatAgt_Td_GetMask,
+ zCatAgt_Td_SetMask,
+ zCatAgt_Td_SetEnable
+};
+
+/**
+ * ÄÚ²¿È«¾Ö±äÁ¿
+ */
+BOOL g_TdEnabled = FALSE;
+
+/**
+ * º¯ÊýʵÏÖ
+ */
+
+/**
+ * @brief »ñÈ¡TDS PHY LOG¹ýÂ˹æÔò
+ * @param[out] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[out] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_Td_GetMask(UINT8 **buf, UINT32 *len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃTDS PHY LOG¹ýÂ˹æÔò
+ * @param[in] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[in] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_Td_SetMask(UINT8 *buf, UINT32 len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃTDS PHY LOGÊÇ·ñ¸ú×Ù
+ * @param[in] enable TRUE:¸ú×Ù, FALSE:²»¸ú×Ù
+ * @return void
+ * @note
+ * @see
+ */
+static VOID zCatAgt_Td_SetEnable(BOOL enable)
+{
+ g_TdEnabled = enable;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_w.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_w.c
new file mode 100755
index 0000000..67eefe3
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/misc/zcat/zcatagt_w.c
@@ -0,0 +1,109 @@
+/**
+ *
+ * @file zcatagt_w.c
+ * @brief
+ * This file is part of ZCAT.
+ * ZCAT¹¤¾ßwcdma phyÏûÏ¢´¦ÀíÄ£¿é
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2023/05/27 1.0 syx Create file
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+/**
+ * Í·Îļþ
+ */
+#include "logcat_drv.h"
+//#include "zcatagt.h"
+
+/**
+ * ºê¶¨Òå
+ */
+
+/**
+ * ¾Ö²¿º¯ÊýÉùÃ÷
+ */
+static BOOL zCatAgt_W_GetMask(UINT8 **buf, UINT32 *len);
+static BOOL zCatAgt_W_SetMask(UINT8 *buf, UINT32 len);
+static VOID zCatAgt_W_SetEnable(BOOL enable);
+
+/**
+ * ÄÚ²¿È«¾Ö±äÁ¿
+ */
+BOOL g_WEnabled = FALSE;
+
+/**
+ * È«¾Ö±äÁ¿¶¨Òå
+ */
+T_ZCAT_DIAG_CONFIG_FUNC g_WConfigFunc =
+{
+ zCatAgt_W_GetMask,
+ zCatAgt_W_SetMask,
+ zCatAgt_W_SetEnable
+};
+
+/**
+ * º¯ÊýʵÏÖ
+ */
+
+/**
+ * @brief »ñÈ¡WCDMA PHY LOG¹ýÂ˹æÔò
+ * @param[out] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[out] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_W_GetMask(UINT8 **buf, UINT32 *len)
+{
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃWCDMA PHY LOG¹ýÂ˹æÔò
+ * @param[in] buf ´æ´¢¹æÔòµÄ»º´æÖ¸Õë
+ * @param[in] len ´æ´¢¹æÔòµÄ»º´æ³¤¶È
+ * @return TRUE on success, FALSE is error
+ * @note
+ * @see
+ */
+static BOOL zCatAgt_W_SetMask(UINT8 *buf, UINT32 len)
+{
+ UINT8 *Mask = (UINT8 *)buf;
+ UINT8 typeCnt = 0;
+
+ if (Mask == NULL)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * @brief ÉèÖÃWCDMA PHY LOGÊÇ·ñ¸ú×Ù
+ * @param[in] enable TRUE:¸ú×Ù, FALSE:²»¸ú×Ù
+ * @return void
+ * @note
+ * @see
+ */
+static VOID zCatAgt_W_SetEnable(BOOL enable)
+{
+ g_WEnabled = enable;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/mmc_ramdump.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/mmc_ramdump.c
index 69c7c61..a3591d0 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/mmc_ramdump.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/mmc_ramdump.c
@@ -14,6 +14,7 @@
#include <linux/delay.h>
#include <linux/string.h>
#include <linux/mfd/zx234290.h>
+#include <linux/stddef.h>
#define MMC1_REG_BASE 0x1211000
@@ -135,7 +136,10 @@
printk("SEND CMD ERR,reg_0x44=0x%x\n",mci_read(regs_base,0x44));
return -1;
}
-
+
+ if(response == NULL)
+ return 0;
+
for(i = 0; i < response_words; i++)
{
response[i]= mci_read(regs_base,(0x30 + i));
@@ -384,8 +388,8 @@
{
int ret;
u32 resp, data, wordcount, start_addr, fifo_cnt;
- u32 i= 0;
- u32 j= 0;
+ volatile u32 i= 0;
+ volatile u32 j= 0;
u32 *p= (u32 *)dst;
u32 regs_base = g_reg_base[1];
@@ -444,6 +448,7 @@
}
} while(wordcount < (size >> 2));
+ udelay(2000);
return 0;
@@ -453,8 +458,8 @@
{
int ret;
u32 resp, data, wordcount, start_addr, fifo_cnt;
- u32 i= 0;
- u32 j= 0;
+ volatile u32 i= 0;
+ volatile u32 j= 0;
u32 *p= (u32 *)src_buf;
u32 regs_base = g_reg_base[1];
u32 write_count_per =0;
@@ -517,6 +522,8 @@
}
} while(size-wordcount);
+
+ udelay(2000);
return 0;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/host/dw_mmc-zx29.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/host/dw_mmc-zx29.c
index cf1ae3e..031b657 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/host/dw_mmc-zx29.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/host/dw_mmc-zx29.c
@@ -179,6 +179,8 @@
if (pdev->dev.of_node) {
match = of_match_node(dw_mci_zx29_match, pdev->dev.of_node);
+ if (!match)
+ return NULL;
drv_data = match->data;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/host/dw_mmc.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/host/dw_mmc.c
index a6170f8..2312424 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/host/dw_mmc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/host/dw_mmc.c
@@ -35,8 +35,9 @@
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/mmc/slot-gpio.h>
-
+#include <linux/mmc/mmc_func.h>
#include "dw_mmc.h"
+#include <linux/string.h>
/* Common flag combinations */
#define DW_MCI_DATA_ERROR_FLAGS (SDMMC_INT_DRTO | SDMMC_INT_DCRC | \
@@ -163,6 +164,97 @@
return 0;
}
DEFINE_SHOW_ATTRIBUTE(dw_mci_regs);
+int case_1_init(void)
+{
+ int ret =0;
+ ret = mmc_ramdump_init();
+ printk("ramdump_init ok ret = %d\n",ret);
+ return 0;
+}
+int case_wr_rd(u32 num)
+{
+ u32 start_blk = 0x200;
+ u8 * s_write_buf;
+ u8 * s_read_buf;
+ int i = 0;
+
+ s_write_buf= kmalloc((num*512),GFP_KERNEL);//malloc 4*512
+ s_read_buf= kmalloc(num*512, GFP_KERNEL);
+ memset(s_write_buf,0xaa,num*512);
+ memset(s_read_buf,0x55,num*512);
+
+
+ mmc_bwrite(start_blk*512,num*512,s_write_buf);
+
+ wmb();
+ mmc_bread(start_blk*512,num*512,s_read_buf);
+
+ kfree(s_write_buf);
+ kfree(s_read_buf);
+ printk("test end blknum = %d\n",num);
+
+ return 0;
+
+}
+static ssize_t debugfs_case_write(struct file *file, const char __user *buf,size_t nbytes, loff_t *ppos)
+{
+ struct dw_mci *host = file->private_data;
+
+ unsigned int val1;
+ u8 case_num, value;
+ int ret;
+ char *kern_buf;
+
+ kern_buf = kzalloc(nbytes, GFP_KERNEL);
+
+ if (!kern_buf) {
+ printk(KERN_INFO "dw_mmc: Failed to allocate buffer\n");
+ return -ENOMEM;
+ }
+
+ if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) {
+ kfree(kern_buf);
+ return -ENOMEM;
+ }
+ printk(KERN_INFO "%s input str=%s,nbytes=%d \n", __func__, kern_buf,nbytes);
+
+ ret = sscanf(kern_buf, "%x", &val1);
+ kfree(kern_buf);
+
+ case_num = val1 & 0xff;
+ printk(KERN_INFO "%s input %x; case=%x\n", __func__, val1, case_num);
+ if(case_num == 0)
+ case_1_init();
+ else
+ case_wr_rd(case_num);
+ return nbytes;
+}
+
+static int debugfs_case_show(struct seq_file *s, void *v)
+{
+ seq_printf(s, "test ok\n ");
+
+ return 0;
+}
+
+#define DEBUGFS_FILE_ENTRY(name) \
+static int debugfs_##name##_open(struct inode *inode, struct file *file) \
+{\
+return single_open(file, debugfs_##name##_show, inode->i_private); \
+}\
+\
+static const struct file_operations debugfs_##name##_fops = { \
+.owner= THIS_MODULE, \
+.open= debugfs_##name##_open, \
+.write=debugfs_##name##_write, \
+.read= seq_read, \
+.llseek= seq_lseek, \
+.release= single_release, \
+}
+
+
+DEBUGFS_FILE_ENTRY(case);
+
static void dw_mci_init_debugfs(struct dw_mci_slot *slot)
{
@@ -175,6 +267,8 @@
return;
debugfs_create_file("regs", S_IRUSR, root, host, &dw_mci_regs_fops);
+ debugfs_create_file("case", S_IRUGO | S_IWUGO, root, host, &debugfs_case_fops);
+
debugfs_create_file("req", S_IRUSR, root, slot, &dw_mci_req_fops);
debugfs_create_u32("state", S_IRUSR, root, &host->state);
debugfs_create_xul("pending_events", S_IRUSR, root,
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mtd/nand/spi/core.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mtd/nand/spi/core.c
index 229c1ef..e1be17f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mtd/nand/spi/core.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mtd/nand/spi/core.c
@@ -23,7 +23,7 @@
#include <linux/soc/zte/spinlock.h>
#include <linux/irq.h>
#include <linux/pm_wakeup.h>
-
+#include <linux/soc/sc/common.h>
struct mtd_info *g_mtdinfo = NULL;
struct device spinand_dev;
@@ -39,7 +39,8 @@
//wake_lock(&spinand_wake_lock); palt_zx298501.c //(new...)
//hsy waiting... zx_cpuidle_set_busy(IDLE_FLAG_FLASH);
//pm_stay_awake(&spinand_dev);
- __pm_stay_awake(zx_spinand_ws);
+ if(!zx_suspend_query())
+ __pm_stay_awake(zx_spinand_ws);
soft_spin_lock(NAND_SFLOCK);
enable_irq(g_spinand_irq);
}
@@ -48,7 +49,8 @@
{
disable_irq(g_spinand_irq);
soft_spin_unlock(NAND_SFLOCK);
- __pm_relax(zx_spinand_ws);
+ if(!zx_suspend_query())
+ __pm_relax(zx_spinand_ws);
//pm_relax(&spinand_dev);
//hsy waiting... zx_cpuidle_set_free(IDLE_FLAG_FLASH);
// wake_unlock(&spinand_wake_lock); palt_zx298501.c //(new...)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
index 9fc87eb..c46a198 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
@@ -874,6 +874,90 @@
}
}
+void __iomem *base_clk = NULL;
+void __iomem *base_phy_release = NULL;
+
+static int zx29_gmac_phy_disable(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct net_device *ndev = platform_get_drvdata(pdev);
+ struct zx29_gmac_dev *priv = (struct zx29_gmac_dev *)netdev_priv(ndev);
+ volatile unsigned int *gmac = NULL;
+ gmac = (unsigned *)ndev->base_addr;
+
+ enum of_gpio_flags flags;
+ int gpio = 0;
+ int ret = 0;
+
+ if (ndev) {
+ if (netif_running(ndev)) {
+
+ netif_stop_queue(ndev);
+ netif_carrier_off(ndev);
+ priv->stopped = 1;
+
+ hrtimer_cancel(priv->timer);
+
+ printk("[%s] netif_running\n", __func__);
+
+ gpio = of_get_gpio_flags(pdev->dev.of_node, 0, &flags); /* success? */
+ ret = gpio_request(gpio, "gmac_power"); /* gpio 124 */
+ gpio_direction_output(gpio, 0);
+
+ gmac_stop((void*)ndev->base_addr);
+
+// netif_device_detach(ndev);
+ }
+ }
+ printk("[%s] exit\n", __func__);
+ return 0;
+}
+
+static int zx29_gmac_phy_enable(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct net_device *ndev = platform_get_drvdata(pdev);
+ struct zx29_gmac_dev *priv = (struct zx29_gmac_dev *)netdev_priv(ndev);
+ volatile unsigned int *gmac = NULL;
+ void __iomem *base = NULL;
+ gmac = (unsigned *)ndev->base_addr;
+ enum of_gpio_flags flags;
+ int gpio = 0;
+ int ret = 0;
+ int status = 0;
+ int islink = 0;
+ unsigned int num= 0;
+
+ if(ndev) {
+ if( netif_running(ndev)) {
+ gpio = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);
+ ret = gpio_request(gpio, "gmac_power"); /* gpio 124 */
+ gpio_direction_output(gpio, 1);
+
+ base = base_clk;
+ gmac_set_clk();
+
+ base = base_phy_release;
+ gmac_phy_release();
+
+ printk("[%s] netif_running\n", __func__);
+
+ priv->phydev->drv->config_init(priv->phydev);
+ gmac_hw_init(ndev);
+
+ netif_carrier_on(ndev);
+ netif_start_queue(ndev);
+
+ hrtimer_start(priv->timer, ktime_set(0, GTIMER_INTERVAL * 1000), HRTIMER_MODE_REL);
+
+ priv->stopped = 0;
+// netif_device_attach(ndev);
+ }
+ }
+
+ return 0;
+}
+
static int zx29_gmac_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
{
struct zx29_gmac_dev *priv = netdev_priv(ndev);
@@ -881,6 +965,13 @@
return -EINVAL;
if (!priv->phydev)
return -EINVAL;
+ if (cmd == SIOCDISABLEPHY)
+ return zx29_gmac_phy_disable(ndev->dev.parent);
+
+ if (cmd == SIOCENABLEPHY)
+ return zx29_gmac_phy_enable(ndev->dev.parent);
+
+
return phy_mii_ioctl(priv->phydev, ifr, cmd);
}
@@ -933,6 +1024,8 @@
static const struct ethtool_ops zx29_gmac_ethtool_ops = {
.get_link = zx29_gmac_get_link,
+ .get_link_ksettings = phy_ethtool_get_link_ksettings,
+ .set_link_ksettings = phy_ethtool_set_link_ksettings,
/* other func */
};
@@ -953,7 +1046,7 @@
struct net_device *ndev = alloc_etherdev(sizeof(struct zx29_gmac_dev));
volatile unsigned int *gmac = NULL;
struct device_node *np = pdev->dev.of_node;
- int ret;
+ int ret = -1;
unsigned long i;
struct mii_bus *mb;
struct resource *iomem;
@@ -965,6 +1058,8 @@
char board_name[128] = {"init_failed"};
printk("[%s] #########zx29_gmac_probe begin.\n", __func__);
+ if (!ndev)
+ return -ENOMEM;
#if 1
pctrl = devm_pinctrl_get(&pdev->dev);
@@ -990,9 +1085,8 @@
gpio_direction_output(gpio, 1);
#endif
+
SET_NETDEV_DEV(ndev, &pdev->dev); //if not, will panic
- if (!ndev)
- return -ENOMEM;
base = devm_platform_ioremap_resource(pdev, 0);
@@ -1067,10 +1161,12 @@
}
base = devm_platform_ioremap_resource(pdev, 2);
- gmac_set_clk();
+ gmac_set_clk();
+ base_clk = base;
base = devm_platform_ioremap_resource(pdev, 1);
- gmac_phy_release();
+ gmac_phy_release();
+ base_phy_release = base;
mdelay(500);
ret = mdiobus_register(mb);
@@ -1173,7 +1269,7 @@
tasklet_kill(&priv->tasklet);
if (priv->dma_rx_vir)
- dma_free_coherent(NULL, GMAC_BUF_LEN, priv->dma_rx_vir, priv->dma_rx_phy);
+ dma_free_coherent(ndev->dev.parent, GMAC_BUF_LEN, priv->dma_rx_vir, priv->dma_rx_phy);
pm_relax(&pdev->dev);
/* wake_unlock(&priv->wakelock);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/zvnet/zvnet_dev.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/zvnet/zvnet_dev.c
index 555f9ae..6bec36e 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/zvnet/zvnet_dev.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/zvnet/zvnet_dev.c
@@ -260,11 +260,12 @@
skb->mac_header = (typeof(skb->mac_header))~0U;
skb->transport_header = (typeof(skb->transport_header))~0U;
skb->dev = zvnet_dev[pbuf_temp->dev].net;
- if(IFF_NOARP & skb->dev->flags)
- memcpy(skb->data, skb->dev->dev_addr, 6);
if(skb->len == 0 || skb->len > 2000)
panic("len ERR!!!!!!!!!!\n");
v7_dma_map_area(skb->head, sizeof(struct skb_shared_info) + pbuf_temp->end_off, DMA_FROM_DEVICE);
+ if(IFF_NOARP & skb->dev->flags)
+ memcpy(skb->data, skb->dev->dev_addr, 6);
+ atomic_set(&skb_shinfo(skb)->dataref, 1);
/* make sure we initialize shinfo sequentially */
skb_reset_network_header(skb);
skb_set_kcov_handle(skb, kcov_common_handle());
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/zvnet/zvnet_dev.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/zvnet/zvnet_dev.h
index f4dab0b..d1feaa5 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/zvnet/zvnet_dev.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/zvnet/zvnet_dev.h
@@ -27,7 +27,7 @@
__func__ , ## arg)
//zvnetÉ豸×î´óÊý
-#define DDR_ZVNET_DEV_MAX 9
+#define DDR_ZVNET_DEV_MAX 10
#define ZVNET_IFNAME_PREFIX "zvnet"
#define ICP_CHN_ZVNET1 20 //ICP_CHANNEL_WAN1
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/Kconfig b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/Kconfig
index 145f874..975d613 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/Kconfig
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/Kconfig
@@ -14,5 +14,6 @@
source "drivers/soc/sc/timer/Kconfig"
source "drivers/soc/sc/pcu/Kconfig"
source "drivers/soc/sc/power/Kconfig"
+source "drivers/soc/sc/tsc/Kconfig"
endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/Makefile b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/Makefile
index 2bb9d1f..00a97d8 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/Makefile
@@ -9,3 +9,5 @@
obj-y += timer/
obj-$(CONFIG_ZTE_PCU) += pcu/
obj-y += power/
+obj-y += power_4line/
+obj-y += tsc/
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/plat/plat-zx297520v3.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/plat/plat-zx297520v3.c
index a8ab2ec..c9674ef 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/plat/plat-zx297520v3.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/plat/plat-zx297520v3.c
@@ -1120,13 +1120,14 @@
static DECLARE_WAIT_QUEUE_HEAD(zx_pm_wait);
static bool zx_pm_wake_flag = false;
+static bool zx_in_suspend = false;
void pm_wl_set_event(unsigned int wake_event)
{
if (wake_event >=PM_WL_EVENT_END)
return;
- pm_wl_event = BIT(wake_event);
+ pm_wl_event = BIT(wake_event)&pm_wl_mask;
}
static unsigned int pm_wl_get_event(void)
@@ -1157,6 +1158,21 @@
return 0;
}
+void zx_enter_suspend(void)
+{
+ zx_in_suspend = true;
+}
+
+ void zx_exit_suspend(void)
+ {
+ zx_in_suspend = false;
+ }
+
+ bool zx_suspend_query(void)
+ {
+ return zx_in_suspend;
+ }
+
void pm_notify_wake_event(void)
{
if (pm_wl_event) {
@@ -1195,28 +1211,28 @@
unsigned long arg)
{
int error = 0;
- unsigned int pm_wl_event;
+ unsigned int wl_event;
switch (cmd) {
case SC_PM_WL_SET:
- pm_wl_event = (unsigned int)arg;
- if (pm_wl_event > BIT(PM_WL_EVENT_END)) {
+ wl_event = (unsigned int)arg;
+ if (wl_event > BIT(PM_WL_EVENT_END)) {
error = -ENOTTY;
break;
}
- pm_wl_mask |= pm_wl_event;
- /* pr_info("%s:pm_wl_mask(0x%x) user_set(0x%x)\n", __func__, pm_wl_mask, pm_wl_event); */
+ pm_wl_mask |= wl_event;
+ /* pr_info("%s:pm_wl_mask(0x%x) user_set(0x%x)\n", __func__, pm_wl_mask, wl_event); */
break;
case SC_PM_WL_CLEAR:
- pm_wl_event = (unsigned int)arg;
- if (pm_wl_event > BIT(PM_WL_EVENT_END)) {
+ wl_event = (unsigned int)arg;
+ if (wl_event > BIT(PM_WL_EVENT_END)) {
error = -ENOTTY;
break;
}
- pm_wl_mask &= (~pm_wl_event);
- /* pr_info("%s:pm_wl_mask(0x%x) user_clr(0x%x)\n", __func__, pm_wl_mask, pm_wl_event); */
+ pm_wl_mask &= (~wl_event);
+ /* pr_info("%s:pm_wl_mask(0x%x) user_clr(0x%x)\n", __func__, pm_wl_mask, wl_event); */
break;
case SC_PM_WL_GET:
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/Makefile b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/Makefile
new file mode 100644
index 0000000..f5f7aa9
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/Makefile
@@ -0,0 +1,4 @@
+# When adding new entries keep the list in alphabetical order
+
+obj-y += hal_xp2xp.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
new file mode 100644
index 0000000..581bace
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
@@ -0,0 +1,915 @@
+/*******************************************************************************
+* Copyright (C) 2009, ZTE Corporation.
+*
+* File Name: hal_xp2xp.c
+* File Mark:
+* Description:
+* Others:
+* Version: V1.0
+* Author: xuexingxing
+* Date: 2016-07-04
+* History 1:
+* Date:
+* Version:
+* Author:
+* Modification:
+* History 2:
+********************************************************************************/
+
+/****************************************************************************
+* Include files
+****************************************************************************/
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/kthread.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/types.h>
+#include <linux/suspend.h>
+#include <linux/tick.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+
+#include <linux/of_irq.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/of_gpio.h>
+
+//#include <mach/irqs.h>
+#include <uapi/linux/gpio.h>
+#include <linux/soc/sc/pcu.h>
+#include <linux/irq.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/pm_wakeup.h>
+#include <linux/soc/sc/drv_idle.h>
+
+#include <linux/sysfs.h>
+#include <linux/kobject.h>
+/****************************************************************************
+* Local Macros
+****************************************************************************/
+#define AP2CP_WAKE_GPIO 50 /*AP»½ÐÑCPÖжÏÏß¶ÔÓ¦µÄGPIO*/
+#define AP2CP_SLEEP_GPIO 53 /*AP¸øCPµÄ˯Ãß»½ÐÑ״̬¶ÔÓ¦µÄGPIO*/
+#define CP2AP_WAKE_GPIO 131 /*CP»½ÐÑAPÖжÏÏß¶ÔÓ¦µÄGPIO*/
+#define CP2AP_SLEEP_GPIO 130 /*CP¸øAPµÄ˯Ãß»½ÐÑ״̬¶ÔÓ¦µÄGPIO*/
+
+
+#define AP_SLEEP_STATUS 0 /*AP˯Ãßʱ¸ÃÒý½ÅΪ0*/
+#define AP_WAKE_STATUS 1 /*AP»½ÐÑʱ¸ÃÒý½ÅΪ1*/
+
+#define CP_SLEEP_STATUS 0 /*CP˯Ãßʱ¸ÃÒý½ÅΪ0*/
+#define CP_WAKE_STATUS 1 /*CP»½ÐÑʱ¸ÃÒý½ÅΪ1*/
+
+#ifdef BTRUNK_SUPPORT
+#define CP_WAKE_AP_INT_SET 1
+#define CP_WAKE_AP_INT_CLEAR 0
+#else
+#define CP_WAKE_AP_INT_SET 0
+#define CP_WAKE_AP_INT_CLEAR 1
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+#define HAL_XP2XP_PM 0
+
+
+#define XP2XP_DEBUG
+
+#ifdef XP2XP_DEBUG
+#define xp2xp_debug(fmt, args...) printk(KERN_INFO "[SLP] " fmt, ##args)
+#else
+#define xp2xp_debug(fmt, args...)
+#endif
+
+#define XP2XP_STATE "xp2xp_state"
+/****************************************************************************
+* Local Types
+****************************************************************************/
+struct zx29_pin_table
+{
+ unsigned int gpio_num;
+ unsigned int func_gpio;
+ unsigned int func_int;
+};
+
+typedef enum{
+ SLEEP_NOTIFY,
+ WAKEUP_NOTIFY
+} notify_type;
+
+typedef enum{
+ SET_EDGE_RISING,
+ SET_EDGE_FALLING
+} interrupt_type;
+
+
+struct hal_xp2xp_dev
+{
+ struct device *dev;
+ struct pinctrl *pctrl_wk_int;
+ struct pinctrl_state *st_gpio;
+ struct pinctrl_state *st_int;
+ int wake_state;
+
+ struct task_struct *wake_int_thread;
+ spinlock_t wk_lock;
+
+ struct semaphore wk_sem;
+ int my_slp_st_gpio;
+ int ap_slp_st_gpio;
+ int wake_ap_gpio;
+ int wake_me_gpio;
+ struct gpio_desc *gd;
+
+ int eint_irq;
+
+};
+
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+
+struct wakeup_source *xp2xp_wake_lock;
+static int xp2xp_init_flag = 0;
+static int irq_num = 0;
+static int nWakeupCount=0;
+
+static int currState = 1;
+
+/****************************************************************************
+* Local Constants
+****************************************************************************/
+
+struct kset *kset_xp2xp;
+//struct kset kset_c;
+struct kobject *xp2xpkobj = NULL;
+
+struct hal_xp2xp_dev g_xp2xp = {0};
+
+static struct attribute xp2xp_state_attr =
+{
+ .name = "xp2xp_state",
+ //.mode = S_IRUGO|S_IWUSR,
+ .mode = S_IRUGO,
+};
+
+
+static struct attribute *xp2xp_status_attrs[] =
+{
+ &xp2xp_state_attr,
+ NULL,
+};
+
+ssize_t xp2xp_obj_show(struct kobject *kobject,struct attribute *attr,char *buf)
+{
+
+ if(!strcmp(attr->name, XP2XP_STATE)){
+ sprintf(buf, "nWakeupCount:%d, currState:%s\n",nWakeupCount, (currState == 1 ? "work" : "sleep"));
+ }
+ return strlen(buf);
+}
+
+
+ssize_t xp2xp_obj_store(struct kobject *kobject,struct attribute *attr, const char *buf,size_t size)
+{
+ unsigned int value = 0;
+
+ return size;
+}
+static struct sysfs_ops xp2xp_obj_sysops =
+{
+ .show = xp2xp_obj_show,
+ .store = xp2xp_obj_store,
+};
+
+
+void xp2xp_obj_release(struct kobject *kobject)
+{
+ printk("[kobj_test: release!]\n");
+}
+static struct kobj_type xp2xp_ktype =
+
+{ .release = xp2xp_obj_release,
+ .sysfs_ops = &xp2xp_obj_sysops,
+ .default_attrs = xp2xp_status_attrs,
+};
+
+static int xp2xp_kset_filter(struct kset *kset,struct kobject *kobj)
+{
+ printk("Filter: kobj %s.\n",kobj->name);
+ return 1;
+}
+
+static const char *xp2xp_kset_name(struct kset *kset,struct kobject *kobj)
+{
+ static char buf[20];
+
+ printk("Name kobj %s.\n",kobj->name);
+ sprintf(buf,"%s","xp2xp");
+
+ return buf;
+}
+
+static int xp2xp_kset_uevent(struct kset *kset,struct kobject *kobj, struct kobj_uevent_env *env)
+{
+ int i = 0;
+ printk("uevent: kobj %s.\n",kobj->name);
+
+ while(i < env->envp_idx)
+ {
+ printk("%s.\n",env->envp[i]);
+ i ++;
+ }
+
+ return 0;
+}
+
+
+static struct kset_uevent_ops xp2xp_uevent_ops =
+{
+ .filter = xp2xp_kset_filter,
+ .name = xp2xp_kset_name,
+ .uevent = xp2xp_kset_uevent,
+};
+
+
+/****************************************************************************
+* Local Function Prototypes
+****************************************************************************/
+
+static ATOMIC_NOTIFIER_HEAD(wakeup_notifier);
+int xp2xp_Wakeup_notifier_register(struct notifier_block *nb);
+int xp2xp_Wakeup_notifier_unregister(struct notifier_block *nb);
+
+//static irqreturn_t xp2xp_Ap2CpWakeCpHisr(int irq, void *id);
+bool xp2xp_Ap2CpIsApWakeup(void);
+int xp2xp_Cp2ApWakeApSignal(void);
+int xp2xp_SetSleepState(bool isCpWake);
+int zDrvXp2xp_Cp2ApWakeupAp(void);
+
+
+/****************************************************************************
+* Global Constants
+****************************************************************************/
+
+/****************************************************************************
+* Function Definitions
+****************************************************************************/
+
+
+
+int xp2xp_Wakeup_notifier_register(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_register(&wakeup_notifier, nb);
+}
+EXPORT_SYMBOL_GPL(xp2xp_Wakeup_notifier_register);
+
+int xp2xp_Wakeup_notifier_unregister(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_unregister(&wakeup_notifier, nb);
+}
+EXPORT_SYMBOL_GPL(xp2xp_Wakeup_notifier_unregister);
+
+
+
+/*******************************************************************************
+* Function: xp2xp_wakeup_notifier_call_chain.
+* Description: xp2xp_wakeup_notifier_call_chain.
+* Parameters:
+* Input:wake_or_sleep:means wakeup or sleep notify to other device
+*
+* Output:call_result:means devices been called return result
+*
+* Returns:
+*
+* Others:the callback shall not block or sleep
+********************************************************************************/
+int xp2xp_wakeup_notifier_call_chain(unsigned long wake_or_sleep, void *call_result)
+{
+// printk("xp2xp_wakeup_notifier_call_chain,val=%ld\n", val);
+ return atomic_notifier_call_chain(&wakeup_notifier, wake_or_sleep, call_result);
+}
+EXPORT_SYMBOL_GPL(xp2xp_wakeup_notifier_call_chain);
+
+
+void xp2xp_notify_up(notify_type isWakeup)
+{
+ unsigned char buf[100];
+ int rtv = -1;
+ enum kobject_action action = 0;
+ char*envp_ext[] = {NULL,NULL};
+ strcpy(buf,"USBEVENT=xp2xp_notify");
+ action = ((isWakeup == WAKEUP_NOTIFY)? KOBJ_ONLINE : KOBJ_OFFLINE);
+ envp_ext[0] = buf;
+ rtv = kobject_uevent_env(xp2xpkobj, action,envp_ext);
+ printk("xp2xp_notify_up isWakeup:%d, result:%d\n", isWakeup, rtv);
+}
+
+/*******************************************************************************
+* Function: xp2xp_Ap2CpWakeCpHisr
+* Description: ap2cp wake up int isr
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+static int xp2xp_wkcp_thread(void *ptr)
+{
+ int call_state = 0;
+ int v_gpio = 0;
+ int ret = 0;
+ unsigned long flags;
+struct hal_xp2xp_dev *xp2xp_dev = (struct hal_xp2xp_dev *)ptr;
+#if 0
+ struct sched_param sch_param = { .sched_priority = 1 };
+ sch_param.sched_priority = 40;
+ sched_setscheduler(current, SCHED_FIFO, &sch_param);
+#endif
+ while(!kthread_should_stop()){
+ ret = down_interruptible(&xp2xp_dev->wk_sem);
+
+ printk("[%s-%d]:plug_state = %d!\n",__func__,__LINE__ ,xp2xp_dev->wake_state);
+ if(ret<0)
+ {
+ if(kthread_should_stop())
+ {
+ printk("[%s-%d]: thread is interrupted by signal!\n",__func__,__LINE__ );
+ break;
+ }
+
+ }
+ spin_lock_irqsave(&xp2xp_dev->wk_lock, flags);
+ if(xp2xp_dev->wake_state){
+ spin_unlock_irqrestore(&xp2xp_dev->wk_lock, flags);
+ //now wakeup
+ xp2xp_notify_up(WAKEUP_NOTIFY);
+
+#ifdef CONFIG_KERNEL_CONTROL_WAKEUP
+ xp2xp_wakeup_notifier_call_chain(WAKEUP_NOTIFY, &call_state);
+ if(call_state == 0){//check device wakeup result
+ xp2xp_SetSleepState(TRUE);
+ }
+#endif
+ }else{
+ //now sleep
+ spin_unlock_irqrestore(&xp2xp_dev->wk_lock, flags);
+ xp2xp_notify_up(SLEEP_NOTIFY);
+#ifdef CONFIG_KERNEL_CONTROL_WAKEUP
+ xp2xp_SetSleepState(FALSE);
+ xp2xp_wakeup_notifier_call_chain(SLEEP_NOTIFY, &call_state);
+ if(call_state){//check device sleep result
+ //to do
+ }
+#endif
+ }
+
+
+ enable_irq(xp2xp_dev->eint_irq);
+ //pm_relax(xp2xp_dev->dev);
+
+ }
+
+ return 0;
+}
+
+/*******************************************************************************
+* Function: ApWakeCp int
+* Description: ap2cp wake up int isr
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+irqreturn_t xp2xp_wkcp_handler(int irq, void *priv)
+{
+ unsigned long flags;
+ int gpio_value;
+ unsigned int irq_type;
+ struct hal_xp2xp_dev *xp2xp_dev = (struct hal_xp2xp_dev *)priv;
+
+ disable_irq_nosync(irq);
+ gpio_value = 0 ;
+ //pm_stay_awake(xp2xp_dev->dev);
+
+ if (pinctrl_select_state(xp2xp_dev->pctrl_wk_int, xp2xp_dev->st_gpio) < 0) {
+ printk("setting card detect gpio failed\n");
+ }
+ spin_lock_irqsave(&xp2xp_dev->wk_lock, flags);
+ gpio_value = gpio_get_value(xp2xp_dev->wake_me_gpio) ;
+ spin_unlock_irqrestore(&xp2xp_dev->wk_lock, flags);
+ if(gpio_value < 0)
+ {
+ printk( "[%s-%d]: gpio get state failed\n",__func__,__LINE__);
+ }
+
+ if(1 == gpio_value){
+ irq_type = IRQF_TRIGGER_FALLING;
+ xp2xp_dev->wake_state = 1;
+ //pm_relax(cdns_dev->dev);
+ }else{
+ irq_type = IRQF_TRIGGER_RISING;
+ xp2xp_dev->wake_state = 0;
+ }
+
+ if (pinctrl_select_state(xp2xp_dev->pctrl_wk_int, xp2xp_dev->st_int) < 0) {
+ printk( "setting card detect irq failed\n");
+ }
+
+ irq_set_irq_type(irq,irq_type);
+
+ up(&xp2xp_dev->wk_sem);
+ return IRQ_HANDLED;
+}
+
+
+/*******************************************************************************
+* Function:
+* Description:
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+bool xp2xp_Ap2CpIsApWakeup(void)
+{
+ int apStatus = 0;
+
+ apStatus = gpio_get_value(AP2CP_SLEEP_GPIO);/*get ap status*/
+ if(apStatus == AP_WAKE_STATUS)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+EXPORT_SYMBOL_GPL(xp2xp_Ap2CpIsApWakeup);
+
+/*******************************************************************************
+* Function:
+* Description:
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+bool xp2xp_Ap2CpWaitApWake(void)
+{
+ int apStatus = 0;
+ int i;
+
+#ifdef BTRUNK_SUPPORT
+ for(i=0; i<200; i++)//delay times to be determined?
+#else
+ for(i=0; i<5; i++)//delay times to be determined?
+#endif
+ {
+ apStatus = gpio_get_value(AP2CP_SLEEP_GPIO); /*get ap status*/
+ if(apStatus == AP_WAKE_STATUS)
+ {
+ return TRUE;
+ }
+ msleep(5);//delay time to be determined?
+ }
+ return FALSE;
+}
+
+
+/*******************************************************************************
+* Function:
+* Description:
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+int xp2xp_SetSleepState(bool isCpWake)
+{
+ if(isCpWake == TRUE)//wake
+ {
+ gpio_set_value(CP2AP_SLEEP_GPIO,CP_WAKE_STATUS);
+ xp2xp_debug("XP2XP: cp send wake status:wake, wakeupcount = %d\n",nWakeupCount);
+ }
+ else //sleep
+ {
+ gpio_set_value(CP2AP_SLEEP_GPIO,CP_SLEEP_STATUS);
+ msleep(20);/*between 20ms, cp keep wake, but ap think cp is sleep, if ap want to send data to cp, must sent wake up int*/
+ xp2xp_debug("XP2XP: cp send sleep status:sleep\n");
+ }
+
+ return 0;
+}
+
+
+
+/*******************************************************************************
+* Function:
+* Description:
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+int xp2xp_Cp2ApWakeApSignal(void)
+{
+ gpio_set_value(CP2AP_WAKE_GPIO,CP_WAKE_AP_INT_SET);
+ msleep(10);
+ gpio_set_value(CP2AP_WAKE_GPIO,CP_WAKE_AP_INT_CLEAR);
+
+ xp2xp_debug("XP2XP: cp send wakeup ap signal\n");
+
+ return 0;
+}
+
+
+/*******************************************************************************
+* Function:
+* Description:
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+int zDrvXp2xp_Cp2ApWakeupAp(void)
+{
+ bool apStat = FALSE;
+ int i = 0;
+
+ if( xp2xp_init_flag == 0)
+ {
+ xp2xp_debug("XP2XP: cp wakeup ap cp not init!\n");
+ return -1;
+ }
+
+ apStat = xp2xp_Ap2CpIsApWakeup();
+ xp2xp_debug("XP2XP: call cp2ap wake func, apStat = %d!",apStat);
+ if(apStat == TRUE)
+ {
+ return 0;
+ }
+
+ for(i=0; i<1; i++)//delay times to be determined?
+ {
+ xp2xp_Cp2ApWakeApSignal();
+ apStat = xp2xp_Ap2CpWaitApWake();
+ if(apStat == TRUE)
+ {
+ //wake_lock_timeout(&xp2xp_wake_lock, msecs_to_jiffies(5*1000)); /*between 5 sec, cp can not sleep*/
+ xp2xp_debug("XP2XP: cp wakeup ap ok!\n");
+ return 0;
+ }
+ }
+ xp2xp_debug("XP2XP: cp wakeup ap faild!\n");
+ return -1;
+}
+
+
+/*******************************************************************************
+* Function:
+* Description:
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others: 4 line sleep enable check
+********************************************************************************/
+int xp2xp_enable_4line(void)
+{
+ #ifdef CONFIG_KERNEL_CONTROL_WAKEUP
+ return 1;
+ #endif
+ return 0;
+}
+EXPORT_SYMBOL_GPL(xp2xp_enable_4line);
+
+int kset_xp2xp_init(void)
+{
+ int ret = 0;
+
+ printk("kset test init!\n");
+
+ /* ´´½¨²¢×¢²á kset_p */
+ kset_xp2xp = kset_create_and_add("xp2xp", &xp2xp_uevent_ops, NULL);
+
+ xp2xpkobj = kzalloc(sizeof(*xp2xpkobj),GFP_KERNEL);
+ if(!xp2xpkobj){
+ printk(KERN_WARNING "mallock xp2xpkobj failed \n");
+ return 0;
+ }
+ kobject_init(xp2xpkobj, &xp2xp_ktype);
+ kobject_add(xp2xpkobj,&kset_xp2xp->kobj,"%s","xp2xp_notify");
+ xp2xpkobj->kset = kset_xp2xp;
+
+
+ return ret;
+}
+
+
+void kset_xp2xp_exit(void)
+{
+ printk("kset_xp2xp_exit exit!\n");
+
+ kset_unregister(kset_xp2xp);
+}
+
+#if HAL_XP2XP_PM
+
+static int hal_xp2xp_pm_resume(struct device *dev)
+{
+ //pm_stay_awake(dev);
+
+ pr_info("hal_xp2xp_pm_resume\n");
+ return 0;
+}
+
+static int hal_xp2xp_pm_suspend(struct device *dev)
+{
+ //pm_relax(dev);
+ pr_info("hal_xp2xp_pm_suspend\n");
+ return 0;
+}
+
+static int hal_xp2xp_pm_runtime_resume(struct device *dev)
+{
+ /* enable clk and restore regs */
+ pr_info("hal_xp2xp_pm_runtime_resume\n");
+ return 0;
+}
+
+static int hal_xp2xp_pm_runtime_suspend(struct device *dev)
+{
+ /* backup regs and disable clk */
+ pr_info("hal_xp2xp_pm_runtime_suspend\n");
+ return 0;
+}
+
+static int hal_xp2xp_pm_runtime_idle(struct device *dev)
+{
+ pr_info("hal_xp2xp_pm_runtime_idle\n");
+ return 0;
+}
+
+static const struct dev_pm_ops hal_xp2xp_pm = {
+ .resume = hal_xp2xp_pm_resume,
+ .suspend = hal_xp2xp_pm_suspend,
+ .runtime_resume = hal_xp2xp_pm_runtime_resume,
+ .runtime_suspend = hal_xp2xp_pm_runtime_suspend,
+ .runtime_idle = hal_xp2xp_pm_runtime_idle
+};
+#endif
+
+
+static const struct of_device_id hal_xp2xp_match[] = {
+ { .compatible = "zte,hal_xp2xp", },
+ { }
+};
+
+
+int hal_xp2xp_probe(struct platform_device *pdev)
+{
+ int gpio;
+ int irq;
+ enum of_gpio_flags flags;
+ int ret = 0;
+ g_xp2xp.dev = &pdev->dev;
+
+ sema_init(&g_xp2xp.wk_sem,0);
+ spin_lock_init(&g_xp2xp.wk_lock);
+
+ device_init_wakeup(&pdev->dev, true);
+ //pm_stay_awake(g_xp2xp.dev);
+
+ g_xp2xp.pctrl_wk_int = devm_pinctrl_get(&pdev->dev);
+ if (IS_ERR(g_xp2xp.pctrl_wk_int)) {
+ dev_warn(&pdev->dev, "Failed to get wakeup int pins");
+ g_xp2xp.pctrl_wk_int = NULL;
+ ret = -1;
+ goto pinctrl_init_fail;
+ }
+ g_xp2xp.st_gpio = pinctrl_lookup_state(g_xp2xp.pctrl_wk_int, "gpio50");
+ if (IS_ERR(g_xp2xp.st_gpio)) {
+ dev_err(&pdev->dev, "hal_xp2xp_probe: missing st_gpio\n");
+ }
+ g_xp2xp.st_int = pinctrl_lookup_state(g_xp2xp.pctrl_wk_int, "ext_int3");
+ if (IS_ERR(g_xp2xp.st_int)) {
+ dev_err(&pdev->dev, "hal_xp2xp_probe: missing ext_int3\n");
+ }
+#if 0
+ if ( pinctrl_select_state(g_xp2xp.pctrl_wk_int, g_xp2xp.st_gpio) < 0) {
+ dev_err(&pdev->dev, "hal_xp2xp_probe state0 failed\n");
+ }
+#endif
+ /* eint3 */
+ if ( pinctrl_select_state(g_xp2xp.pctrl_wk_int, g_xp2xp.st_int) < 0) {
+ dev_err(&pdev->dev, "hal_xp2xp_probe eint3 failed\n");
+ }
+
+ /* gpio request */
+ gpio = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);
+ if (!gpio_is_valid(gpio)) {
+ printk("hal_xp2xp_probe gpio 50 no found\n");
+ ret = -ENODEV;
+ goto gpio50_init_fail;
+ }
+ /* pr_info("test gpio :%d flag=0x%x\n", gpio, flags); */
+
+
+ g_xp2xp.wake_me_gpio = gpio;
+
+
+ g_xp2xp.eint_irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+ printk("wake_me_gpio:%d, eint_irq:%d\n", g_xp2xp.wake_me_gpio, g_xp2xp.eint_irq);
+
+ ret = devm_request_threaded_irq(g_xp2xp.dev, g_xp2xp.eint_irq,
+ xp2xp_wkcp_handler,
+ NULL, IRQF_ONESHOT,
+ "xp2xp_wake int", &g_xp2xp);
+
+
+ if(ret<0){
+ panic("hal_xp2xp_probe request_irq fail, %d", ret);
+ }
+
+ g_xp2xp.wake_int_thread = kthread_run(xp2xp_wkcp_thread, (void *)&g_xp2xp, "xp2xp_wake_thread");
+
+ if (IS_ERR(g_xp2xp.wake_int_thread)) {
+ printk("Can't start up our thread");
+ return PTR_ERR(g_xp2xp.wake_int_thread);
+ }
+
+ enable_irq_wake(g_xp2xp.eint_irq);
+
+#ifdef CONFIG_KERNEL_CONTROL_WAKEUP
+ /* gpio request */
+ //gpio_53,ap sleep_state
+ gpio = of_get_gpio_flags(pdev->dev.of_node, 1, &flags);
+ if (!gpio_is_valid(gpio)) {
+ printk("hal_xp2xp_probe gpio no found\n");
+ ret = -ENODEV;
+ goto gpio53_init_fail;
+ }
+ /* pr_info("test gpio :%d flag=0x%x\n", gpio, flags); */
+
+ g_xp2xp.ap_slp_st_gpio = gpio;
+ gpio_direction_input(g_xp2xp.ap_slp_st_gpio);
+
+ //gpio_130,my sleep_state
+ gpio = of_get_gpio_flags(pdev->dev.of_node, 2, &flags);
+ if (!gpio_is_valid(gpio)) {
+ printk("hal_xp2xp_probe gpio no found\n");
+ ret = -ENODEV;
+ goto gpio130_init_fail;
+ }
+
+
+ g_xp2xp.my_slp_st_gpio = gpio;
+gpio_direction_output(g_xp2xp.my_slp_st_gpio, CP_SLEEP_STATUS);
+
+ //gpio_131,wake ap gpio
+ gpio = of_get_gpio_flags(pdev->dev.of_node, 3, &flags);
+ if (!gpio_is_valid(gpio)) {
+ printk("hal_xp2xp_probe gpio no found\n");
+ ret = -ENODEV;
+ goto gpio131_init_fail;
+ }
+ g_xp2xp.wake_ap_gpio = gpio;
+ gpio_direction_output(g_xp2xp.my_slp_st_gpio, CP_WAKE_AP_INT_CLEAR);
+
+#endif
+
+
+gpio131_init_fail:
+ if(ret){
+ printk("\n");
+ }
+gpio130_init_fail:
+ if(ret){
+ printk("\n");
+ }
+
+gpio53_init_fail:
+ if(ret){
+ printk("\n");
+ }
+
+gpio50_init_fail:
+ if(ret){
+ printk("\n");
+ }
+
+pinctrl_init_fail:
+ if(ret){
+ printk("\n");
+ }
+
+ //pm_relax(g_xp2xp.dev);
+ return 0;
+}
+
+static struct platform_driver hal_xp2xp_driver = {
+ .probe = hal_xp2xp_probe,
+ .driver = {
+ .name = "hal_xp2xp",
+#if HAL_XP2XP_PM
+ .pm = &hal_xp2xp_pm,
+#endif
+ .of_match_table = hal_xp2xp_match,
+ },
+};
+
+
+/*******************************************************************************
+* Function: zDrvAp2cp_Initiate
+* Description:
+* Parameters:
+* Input:
+*
+* Output:
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+static int __init zDrvXp2xp_Initiate(void)
+{
+ int ret=0;
+ int errCode = -1;
+ kset_xp2xp_init();
+ //xp2xp_init_flag = 1;
+
+ ret = platform_driver_register(&hal_xp2xp_driver);
+ if (ret != 0){
+ kset_xp2xp_exit();
+ printk("XP2XP: platform_driver_register fail!\n");
+ return ret;
+ }
+
+ if(ret){
+ gpio_free(AP2CP_WAKE_GPIO);
+#ifdef CONFIG_KERNEL_CONTROL_WAKEUP
+ gpio_free(CP2AP_WAKE_GPIO);
+ gpio_free(CP2AP_SLEEP_GPIO);
+ gpio_free(AP2CP_SLEEP_GPIO);
+#endif
+ }
+
+ return 0;
+}
+
+int zDrvXp2xp_Release(void)
+{
+ kset_xp2xp_exit();
+ gpio_free(AP2CP_WAKE_GPIO);
+
+#ifdef CONFIG_KERNEL_CONTROL_WAKEUP
+ gpio_free(AP2CP_SLEEP_GPIO);
+ gpio_free(CP2AP_WAKE_GPIO);
+ gpio_free(CP2AP_SLEEP_GPIO);
+#endif
+ return 0;
+}
+
+
+late_initcall(zDrvXp2xp_Initiate);
+
+//module_exit(zDrvXp2xp_Release);
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/rpmsg/icp_rpmsg.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/rpmsg/icp_rpmsg.c
index 0f7ed5e..97b7a64 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/rpmsg/icp_rpmsg.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/rpmsg/icp_rpmsg.c
@@ -273,13 +273,15 @@
unsigned long flags;
unsigned int result_len = 0;
unsigned int offset;
- T_RpMsg_ChInfo *channelRecv = rpmsgConfig[pMsg->coreID].recvBase + pMsg->chID;
+ T_RpMsg_ChInfo *channelRecv;
// printk("rpmsg_Read:actorID = %d, chID = %d\n",pMsg->coreID, pMsg->chID);
if (unlikely(pMsg == NULL || pMsg->coreID >= CORE_MAXID || pMsg->chID >= CHANNEL_MAXID(pMsg->coreID)))
return RPMSG_INVALID_PARAMETER;
+ channelRecv = rpmsgConfig[pMsg->coreID].recvBase + pMsg->chID;
+
if (unlikely(!channelRecv->offset))
return RPMSG_CHANNEL_INEXISTANCE;
@@ -322,11 +324,13 @@
int ret;
unsigned int size = 0;
unsigned int flags;
- T_RpMsg_ChInfo *channelSend = rpmsgConfig[pMsg->coreID].sendBase + pMsg->chID;
+ T_RpMsg_ChInfo *channelSend;
if (unlikely(pMsg == NULL || pMsg->coreID >= CORE_MAXID || pMsg->chID >= CHANNEL_MAXID(pMsg->coreID)))
return RPMSG_INVALID_PARAMETER;
+ channelSend = rpmsgConfig[pMsg->coreID].sendBase + pMsg->chID;
+
if (unlikely(!channelSend->offset))
return RPMSG_CHANNEL_INEXISTANCE;
@@ -347,8 +351,8 @@
pMsg->coreID,
pMsg->chID);
ret = pMsg->len;
+ asm volatile("dmb sy\n");
channelSend->sendPos = CUR_SEND_POS(pMsg->coreID, pMsg->chID);
-
asm volatile("dmb sy\n");
}
else
@@ -374,13 +378,15 @@
unsigned int offset;
unsigned int result_len = 0;
T_RpMsg_MsgHeader tmpMsgHeader;
- T_RpMsg_ChInfo *channelRecv = rpmsgConfig[pMsg->coreID].recvBase + pMsg->chID;
+ T_RpMsg_ChInfo *channelRecv;
// printk("rpmsg_Read:actorID = %d, chID = %d\n",pMsg->coreID, pMsg->chID);
if (unlikely(pMsg == NULL || pMsg->coreID >= CORE_MAXID || pMsg->chID >= CHANNEL_MAXID(pMsg->coreID)))
return RPMSG_INVALID_PARAMETER;
+ channelRecv = rpmsgConfig[pMsg->coreID].recvBase + pMsg->chID;
+
if (unlikely(!channelRecv->offset))
return RPMSG_CHANNEL_INEXISTANCE;
@@ -437,11 +443,13 @@
unsigned int size = 0;
T_RpMsg_MsgHeader tmpMsgHeader;
unsigned int flags;
- T_RpMsg_ChInfo *channelSend = rpmsgConfig[pMsg->coreID].sendBase + pMsg->chID;
+ T_RpMsg_ChInfo *channelSend;
if (unlikely(pMsg == NULL || pMsg->coreID >= CORE_MAXID || pMsg->chID >= CHANNEL_MAXID(pMsg->coreID)))
return RPMSG_INVALID_PARAMETER;
+ channelSend = rpmsgConfig[pMsg->coreID].sendBase + pMsg->chID;
+
if (unlikely(!channelSend->offset))
return RPMSG_CHANNEL_INEXISTANCE;
@@ -475,8 +483,8 @@
pMsg->coreID,
pMsg->chID);
ret = pMsg->len;
+ asm volatile("dmb sy\n");
channelSend->sendPos = CUR_SEND_POS(pMsg->coreID, pMsg->chID);
-
asm volatile("dmb sy\n");
}
else
@@ -665,13 +673,15 @@
unsigned int offset;
unsigned int result_len = 0;
T_RpMsg_MsgHeader tmpMsgHeader;
- T_RpMsg_ChInfo *channelRecv = rpmsgConfig[pMsg->coreID].recvBase + pMsg->chID;
+ T_RpMsg_ChInfo *channelRecv;
- printk("rpmsg_Read:actorID = %d, chID = %d\n",pMsg->coreID, pMsg->chID);
+// printk("rpmsg_Read:actorID = %d, chID = %d\n",pMsg->coreID, pMsg->chID);
if (pMsg == NULL || pMsg->coreID >= CORE_MAXID || pMsg->chID >= CHANNEL_MAXID(pMsg->coreID))
return RPMSG_INVALID_PARAMETER;
+ channelRecv = rpmsgConfig[pMsg->coreID].recvBase + pMsg->chID;
+
if (!channelRecv->offset)
return RPMSG_CHANNEL_INEXISTANCE;
@@ -732,11 +742,13 @@
unsigned int size = 0;
T_RpMsg_MsgHeader tmpMsgHeader;
unsigned int flags;
- T_RpMsg_ChInfo *channelSend = rpmsgConfig[pMsg->coreID].sendBase + pMsg->chID;
+ T_RpMsg_ChInfo *channelSend;
if (pMsg == NULL || pMsg->coreID >= CORE_MAXID || pMsg->chID >= CHANNEL_MAXID(pMsg->coreID))
return RPMSG_INVALID_PARAMETER;
+ channelSend = rpmsgConfig[pMsg->coreID].sendBase + pMsg->chID;
+
if (!channelSend->offset)
return RPMSG_CHANNEL_INEXISTANCE;
@@ -775,6 +787,7 @@
pMsg->len,
pMsg->coreID,
pMsg->chID);
+ asm volatile("dmb sy\n");
channelSend->sendPos = CUR_SEND_POS(pMsg->coreID, pMsg->chID);
ret = pMsg->len;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/rpmsg/zx29_icp.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/rpmsg/zx29_icp.c
index b4945e5..9c46a98 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/rpmsg/zx29_icp.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/rpmsg/zx29_icp.c
@@ -287,7 +287,7 @@
static int icp_send_message(unsigned int core_id, icp_msg *icp_msg)
{
- if(icp_msg->dest_core > CORE_MAXID || !icp_msg)
+ if(!icp_msg || icp_msg->dest_core > CORE_MAXID )
return -EINVAL;
if(icp_get_int_state(icp_msg->dest_core, icp_msg->event_id)==false)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/timer/timer-zx297520v3.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/timer/timer-zx297520v3.c
index 16086e8..ca6be4e 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/timer/timer-zx297520v3.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/timer/timer-zx297520v3.c
@@ -616,7 +616,6 @@
static int zx_timer_cs_init(t_timer_info *info)
{
- int ret;
struct clocksource *cs;
if (!(info->func & TIMER_FUNC_CS))
@@ -648,7 +647,7 @@
zx29_timer_persistent_init(info);
- return ret;
+ return 0;
}
static int __init zx_timer_of_init(struct device_node *np)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/Kconfig b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/Kconfig
new file mode 100644
index 0000000..7262f15
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/Kconfig
@@ -0,0 +1,4 @@
+#
+#
+#
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/Makefile b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/Makefile
new file mode 100644
index 0000000..f4a9892
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the soc plat drivers
+#
+
+ obj-$(CONFIG_ARCH_ZX297520V3) += zx-tsc.o
+#
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/zx-tsc.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/zx-tsc.c
new file mode 100644
index 0000000..4785a9f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/tsc/zx-tsc.c
@@ -0,0 +1,306 @@
+/*
+ * drivers/soc/zte/timer/timer-zx29.c
+ *
+ * Copyright (C) 2015 ZTE-TSP
+ *
+ * -------------------------------------------------------------------------------------------------------------------- *//**
+ */
+#include <linux/kernel.h>
+#include <linux/module.h> /* For module stuff/... */
+#include <linux/errno.h> /* For the -ENODEV/... values */
+#include <linux/miscdevice.h> /* For handling misc devices */
+#include <linux/fs.h> /* For file operations */
+#include <linux/kthread.h> /*For kthread_run()*/
+#include <linux/init.h> /* For __init/__exit/... */
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <uapi/linux/sched/types.h> /* For struct sched_param */
+#include <linux/delay.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/platform_device.h>
+#include <linux/soc/sc/rpmsg.h> /* For icp operation*/
+#include <linux/soc/sc/spinlock.h>
+#include <linux/uaccess.h>
+#include <linux/syscore_ops.h>
+#include <linux/mutex.h>
+#include <linux/sched.h>
+
+
+#if 1
+#define STRATEGY_PHY_NUM 8
+#define STRATEGY_PS_NUM 3
+#define BIT_PS_RATE 0
+#define BIT_PS_ANYRESIDENT 4
+#define BIT_PS_FREQ 8
+
+#define ZX_TSC_IOC_MAGIC 'T'
+/*ioctl cmd usd by device*/
+#define ZX_TSC_GET_TEMP _IOW(ZX_TSC_IOC_MAGIC, 1, char *)
+#define ZX_TSC_GET_STRATEGY _IOW(ZX_TSC_IOC_MAGIC, 2, char *)
+#define ZX_TSC_DEV "/dev/zx_tsc"
+
+
+ typedef enum _T_TsCtrl_Probe
+{
+ PROBE_ADC1 = 0,
+ PROBE_ADC2,
+ PROBE_ADCRF,
+ PROBE_RESEV2,
+ PROBE_RESEV3,
+
+ PROBE_MAX,
+} T_TsCtrl_Probe;
+
+struct T_Tsc_Pub_Addr{
+ volatile unsigned int tscctrl_phy; //0x00
+ volatile unsigned int tscctrl_ps; //0x04
+ volatile unsigned int tscctrl_ap; //0x08
+ volatile unsigned int tscctrl_perip; //0x0c
+
+ volatile unsigned int tscctrl_reserve1[60];
+
+ volatile int temp_adc1; //0x100
+ volatile int temp_adc2; //0x104
+ volatile int temp_adcRf; //0x108
+ volatile int temp_adcRev1; //0x10c
+ volatile int temp_adcRev2; //0x110
+ volatile int temp_adcRev3; //0x114
+ volatile unsigned int tscctrl_en; //0x118
+};
+
+struct T_Tsc_Device{
+ struct T_Tsc_Pub_Addr __iomem *tsc_pub_addr;
+};
+
+typedef struct _T_TscPhy_Strategy
+{
+ char name[32];
+ volatile unsigned int flag;
+}T_TscP_Strategy;
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+static struct kobject *zx_tsc_kobj;
+static struct T_Tsc_Device tsc_dev;
+int tsc_tempValue[PROBE_MAX]={0};
+
+T_TscP_Strategy g_Strategy[STRATEGY_PHY_NUM+STRATEGY_PS_NUM]={
+ {"ps anyresident", 0},
+ {"ps modemrate limit", 0},
+ {"ps freq 312M", 0},
+
+ {"lte downrate1 limit", 0},
+ {"lte downrate2 limit", 0},
+ {"w downrate1 limit ", 0},
+ {"w downrate2 limit", 0},
+ {"lte up_tansmitepower1 limit", 0},
+ {"lte up_tansmitepower2 limit", 0},
+ {"w up_tansmitepower1 limit", 0},
+ {"w up_tansmitepower2 limit", 0},
+};
+
+static struct mutex tsc_mutexId;
+
+/****************************************************************************
+* Function Definitions
+****************************************************************************/
+static int *tsc_get_probe_temperature(void)
+ {
+
+ mutex_lock(&tsc_mutexId);
+
+ tsc_tempValue[PROBE_ADC1]=tsc_dev.tsc_pub_addr->temp_adc1;
+ tsc_tempValue[PROBE_ADC2]=tsc_dev.tsc_pub_addr->temp_adc2;
+ tsc_tempValue[PROBE_ADCRF]=tsc_dev.tsc_pub_addr->temp_adcRf;
+
+ mutex_unlock(&tsc_mutexId);
+
+ return tsc_tempValue;
+ }
+ /* /sys/zx_tsc/tsc_value */
+static ssize_t tsc_value_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ char *s = buf;
+ int *tsc_val = 0;
+ unsigned int i;
+
+ tsc_val = tsc_get_probe_temperature();
+
+ for(i=0; i<PROBE_MAX;i++){
+ sprintf(s, "%d\n ", tsc_val[i]);
+ s+=4;
+ }
+ return PROBE_MAX*sizeof(int);
+}
+
+static ssize_t tsc_value_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+
+ int error = 0;
+
+ return error;
+ }
+static DEVICE_ATTR(tsc_value, 0600, tsc_value_show, tsc_value_store);
+
+static struct attribute *zx_tsc_attributes[] = {
+ &dev_attr_tsc_value.attr,
+ NULL,
+};
+
+static const struct attribute_group zx_tsc_attr_group = {
+ .attrs = (struct attribute **) zx_tsc_attributes,
+};
+
+static int zx_tsc_open(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
+static int zx_tsc_close(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+static long zx_tsc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+
+ unsigned int ret = 0;
+ unsigned int temp, i;
+ int *tsc_val = 0;
+
+ T_TscP_Strategy Strategy[STRATEGY_PHY_NUM+STRATEGY_PS_NUM];
+
+ switch(cmd)
+ {
+ case ZX_TSC_GET_TEMP:
+ tsc_val = tsc_get_probe_temperature();
+ ret = copy_to_user((void *)arg, tsc_val, PROBE_MAX*sizeof(int));
+ if(ret)
+ printk("%s: copy user failed\n",__func__);
+ break;
+
+ case ZX_TSC_GET_STRATEGY:
+ memset(Strategy, 0, sizeof(Strategy));
+ for(i=0; i<STRATEGY_PHY_NUM+STRATEGY_PS_NUM; i++)
+ {
+ memcpy(Strategy[i].name, g_Strategy[i].name, 32);
+ }
+
+ /*ps modemrate*/
+ if(((tsc_dev.tsc_pub_addr->tscctrl_ps&(0xf<<BIT_PS_RATE))>>BIT_PS_RATE)==1)
+ Strategy[1].flag =1;
+ else if(((tsc_dev.tsc_pub_addr->tscctrl_ps&(0xf<<BIT_PS_RATE))>>BIT_PS_RATE)==2)
+ Strategy[1].flag =2;
+ else
+ Strategy[1].flag =0;
+
+ /*ps ANYRESIDENT*/
+ if(tsc_dev.tsc_pub_addr->tscctrl_ps&(0xf<<BIT_PS_ANYRESIDENT)>>BIT_PS_ANYRESIDENT)
+ Strategy[0].flag =1;
+ else
+ Strategy[0].flag =0;
+
+ /*ps freq*/
+ if((tsc_dev.tsc_pub_addr->tscctrl_ps&(0xf<<BIT_PS_FREQ))>>BIT_PS_FREQ)
+ Strategy[2].flag =1;
+ else
+ Strategy[2].flag =0;
+
+ for(i=0; i<STRATEGY_PHY_NUM; i++)
+ {
+ if((tsc_dev.tsc_pub_addr->tscctrl_phy&(0x1<<i))>>i)
+ Strategy[i+3].flag =1;
+ else
+ Strategy[i+3].flag =0;
+ }
+ ret = copy_to_user((void *)arg, &Strategy, sizeof(Strategy));
+ if(ret)
+ printk("%s: copy user failed\n",__func__);
+
+ break;
+ default:
+ return -1;
+ }
+
+ return ret;
+
+}
+
+static const struct file_operations zx_tsc_fops = {
+ .owner = THIS_MODULE,
+ .unlocked_ioctl = zx_tsc_ioctl,
+ .open = zx_tsc_open,
+ .release = zx_tsc_close,
+};
+
+static struct miscdevice zx_tsc_miscdev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "zx_tsc",
+ .fops = &zx_tsc_fops,
+};
+
+static int zx_tsc_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ int ret=0;;
+ printk("zx_tsc_probe.\n");
+
+ zx_tsc_kobj = kobject_create_and_add("zx_tsc", NULL);
+ if (!zx_tsc_kobj){
+ return -ENOMEM;
+ }
+
+ ret = sysfs_create_group(zx_tsc_kobj, &zx_tsc_attr_group);
+ if (ret){
+ printk(KERN_WARNING "[tsc] sysfs_create_group ret %d\n", ret);
+ return ret;
+ }
+
+ printk("[DEBUG] create tsc sysfs interface OK.\n");
+
+ memset((unsigned char *)&tsc_dev, 0, sizeof(struct T_Tsc_Device));
+
+ /*get addr for tsc*/
+ tsc_dev.tsc_pub_addr = of_iomap(np, 0);
+
+ /**/
+ ret = misc_register(&zx_tsc_miscdev);
+ if (ret != 0) {
+ printk(KERN_ERR"[zx soft tsc]: cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
+ return ret;
+ }
+
+ mutex_init(&tsc_mutexId);
+
+ printk("[DEBUG] zx_tsc_probe OK.\n");
+ return 0;
+}
+
+
+static const struct of_device_id zx_tsc_dt_ids[] = {
+ { .compatible = "zte,zx29-tsc"},
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, zx_tsc_dt_ids);
+
+
+static struct platform_driver zx_tsc_driver = {
+ .probe = zx_tsc_probe,
+ .driver = {
+ .name = "zx29-tsc",
+ .of_match_table = zx_tsc_dt_ids,
+ },
+};
+module_platform_driver(zx_tsc_driver)
+MODULE_AUTHOR("Ludovic Barre <ludovic.barre@st.com>");
+MODULE_DESCRIPTION("ZTEMicroelectronics zxic quad spi driver");
+MODULE_LICENSE("GPL v2");
+
+#endif
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spi-zx29.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spi-zx29.c
index 80cfd61..7cb7f1a 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spi-zx29.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spi-zx29.c
@@ -165,6 +165,11 @@
#define SPI_INTR_SR_SCLR_MASK_RX_THRES_INTR (0x1UL << 4)
#define SPI_INTR_SR_SCLR_MASK_TX_THRES_INTR (0x1UL << 5)
+/*
+ * SPI TIMING Register
+ */
+#define SPI_TIMING_MASK_T_CS_DESEL 0xFUL
+
/* SPI WCLK Freqency */
#define SPI_SPICLK_FREQ_26M (26*1000*1000)
#define SPI_SPICLK_FREQ_104M (104*1000*1000)
@@ -206,6 +211,12 @@
#define SPI_SOD_DISABLED (1)
#define SPI_SOD_ENABLED (0)
+/*
+ * SPI TRANSFER DELAY CFG
+ * DELAY TIME ≈ (1 / Buad_Rate) * 8 + (SPI_TIMING_T_CS_DESEL + 1) / Buad_Rate;
+ */
+
+
enum spi_fifo_threshold_level {
SPI_FIFO_THRES_1,
SPI_FIFO_THRES_2,
@@ -401,10 +412,12 @@
u32 com_ctrl;
u32 fmt_ctrl;
u32 fifo_ctrl;
+ u32 timing;
// u32 intr_en;
u8 n_bytes;
u8 clk_div;/* spi clk divider */
bool enable_dma;
+ bool enable_trans_gap;
enum spi_reading read;
enum spi_writing write;
void (*cs_control) (int dev_id,u32 command);
@@ -509,7 +522,8 @@
// writel(chip->intr_en, SPI_INTR_EN(zx297520v2spi->virtbase));
if(zx29spi->mode == ZX29_SSP_SLAVE_TYPE)
chip->com_ctrl |= GEN_MASK_BITS(SPI_SLAVE, SPI_COM_CTRL_MASK_MS, 2)|GEN_MASK_BITS(SPI_ENABLED, SPI_COM_CTRL_MASK_SSPE, 1);
- writel(chip->com_ctrl, (zx29spi->virtbase + SPI_COM_CTRL_OFFSET));
+ writel(chip->com_ctrl, (SPI_COM_CTRL_OFFSET + zx29spi->virtbase));
+ writel(chip->timing, (SPI_TIMING_OFFSET + zx29spi->virtbase));
}
/*
@@ -748,9 +762,21 @@
}
zx29spi->tx += (zx29spi->cur_chip->n_bytes);
zx29spi->exp_fifo_level++;
+
+ if(zx29spi->cur_chip->enable_trans_gap) {
+ while (readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase)) & SPI_FIFO_SR_MASK_BUSY) {
+ cpu_relax();
+ dev_dbg(&zx29spi->pdev->dev, "FIFO_SR 0x%x...\n",readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase)));
+ }
+ }
}
- cpu_relax();
-
+
+ if(!zx29spi->cur_chip->enable_trans_gap) {
+ while (readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase)) & SPI_FIFO_SR_MASK_BUSY) {
+ cpu_relax();
+ dev_dbg(&zx29spi->pdev->dev, "FIFO_SR 0x%x...\n",readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase)));
+ }
+ }
/*
* When we exit here the TX FIFO should be full and the RX FIFO
* should be empty
@@ -777,8 +803,18 @@
while (zx29spi->tx < zx29spi->tx_end) {
fifo_sr = readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase));
+#if 0
rd_max = (fifo_sr & rx_fifo_cnt_msk) >> SPI_FIFO_SR_SHIFT_RX_CNT;
wr_max = (fifo_sr & tx_fifo_cnt_msk) >> tx_fifo_cnt_pos;
+#else
+ if(!strcmp(zx29spi->pdev->name,"140a000.ssp")) {
+ rd_max = (fifo_sr & rx_fifo_cnt_msk) >> SPI_FIFO_SR_SHIFT_RX_CNT;
+ wr_max = (fifo_sr & tx_fifo_cnt_msk) >> tx_fifo_cnt_pos;
+ }else {
+ rd_max = (fifo_sr>>SPI_FIFO_SR_SHIFT_RX_CNT)&0x7f;
+ wr_max = (fifo_sr>>12)&0x1f;
+ }
+#endif
if (fifo_sr & SPI_FIFO_SR_MASK_BUSY) {
wr_max--;
}
@@ -798,7 +834,7 @@
static void dma_callback(void *data)
{
struct zx29_spi *zx29spi = (struct zx29_spi *)data;
- //printk(KERN_INFO "spi:dma transfer complete\n");
+ //printk(KERN_INFO "spi:dma transfer complete. %X-%X-%x\n", zx29spi->dma_running, readl((SPI_INTR_SR_OFFSET+zx29spi->virtbase)),readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase)));
up(&zx29spi->sema_dma);
}
@@ -1165,12 +1201,58 @@
struct zx29_spi *zx29spi = spi_master_get_devdata(spi->master);
int ret = 0;
- if(!spi || !buf)
+ if(!spi || !buf || !zx29spi)
return ret;
if(!zx29spi->zx29_flush_rxfifo)
return ret;
return zx29spi->zx29_flush_rxfifo(zx29spi,buf);
}
+
+
+void set_spi_timing(struct spi_device *spi,unsigned int param)
+{
+ struct zx29_spi *zx29spi = spi_master_get_devdata(spi->master);
+
+ printk("val set before: 0x%x \n",readl((SPI_TIMING_OFFSET+zx29spi->virtbase)));
+ writel(param, (SPI_TIMING_OFFSET+zx29spi->virtbase));
+ printk("val set after: 0x%x \n",readl((SPI_TIMING_OFFSET+zx29spi->virtbase)));
+}
+
+
+void slave_mode_set(struct spi_device *spi,unsigned int mode)
+{
+ unsigned int regval = 0;
+ struct zx29_spi *zx29spi = spi_master_get_devdata(spi->master);
+
+ regval = readl((SPI_COM_CTRL_OFFSET+zx29spi->virtbase)) & (~SPI_COM_CTRL_MASK_SSPE);
+ writel(regval, (SPI_COM_CTRL_OFFSET+zx29spi->virtbase));
+
+ regval = readl((SPI_FMT_CTRL_OFFSET+zx29spi->virtbase)) & (~(SPI_FMT_CTRL_MASK_POL|SPI_FMT_CTRL_MASK_PHA));
+ printk("val set before: 0x%x \n",regval);
+ switch(mode){
+ case 0:
+ break;
+ case 1:
+ regval |= SPI_FMT_CTRL_MASK_PHA;
+ break;
+ case 2:
+ regval |= SPI_FMT_CTRL_MASK_POL;
+ break;
+ case 3:
+ regval |= (SPI_FMT_CTRL_MASK_POL|SPI_FMT_CTRL_MASK_PHA);
+ break;
+ default:
+ break;
+ }
+ writel(regval, (SPI_FMT_CTRL_OFFSET+zx29spi->virtbase));
+
+ writel(readl((SPI_COM_CTRL_OFFSET+zx29spi->virtbase)) | SPI_COM_CTRL_MASK_SSPE, (SPI_COM_CTRL_OFFSET+zx29spi->virtbase));
+ while(((readl((SPI_COM_CTRL_OFFSET+zx29spi->virtbase))>> 4)&0x1) == 0);
+ printk("val set after: 0x%x \n",readl((SPI_COM_CTRL_OFFSET+zx29spi->virtbase)));
+ return;
+}
+
+
static int zx29_slave_do_interrupt_dma_transfer(struct zx29_spi *zx29spi)
{
struct spi_transfer *transfer = zx29spi->cur_transfer;
@@ -1214,6 +1296,7 @@
while (readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase)) & SPI_FIFO_SR_MASK_BUSY)
{
cpu_relax();
+ msleep(1);
}
if (zx29spi->dma_running == (TX_TRANSFER | RX_TRANSFER)) {
@@ -1333,6 +1416,7 @@
}
while (readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase)) & SPI_FIFO_SR_MASK_BUSY) {
cpu_relax();
+ dev_dbg(&zx29spi->pdev->dev, "FIFO_SR 0x%x...\n",readl((SPI_FIFO_SR_OFFSET+zx29spi->virtbase)));
}
return ret;
}
@@ -1340,14 +1424,17 @@
static int zx29_spi_map_mssg(struct zx29_spi *zx29spi,
struct spi_message *msg)
{
- struct device *dev = &zx29spi->pdev->dev;
+ struct device *dev;
struct spi_transfer *transfer;
int ret = 0;
+
+ if(!zx29spi || !msg)
+ return -EFAULT;
- if (msg->is_dma_mapped || !zx29spi->master_info->enable_dma) {
+ if (msg->is_dma_mapped || !msg->spi->dma_used) {
return 0;
}
-
+ dev = &zx29spi->pdev->dev;
/* Map until end or first fail */
list_for_each_entry(transfer, &msg->transfers, transfer_list) {
@@ -2093,8 +2180,10 @@
zx29spi->tx_lev_trig = chip_info->tx_lev_trig;
/* Now set controller state based on controller data */
- chip->xfer_type = chip_info->com_mode;
-
+ //chip->xfer_type = chip_info->com_mode;
+ chip->xfer_type = spi->dma_used ? DMA_TRANSFER : POLLING_TRANSFER;
+ dev_dbg(&spi->dev, "chip->xfer_type = 0x%x \n",chip->xfer_type);
+
if (!chip_info->cs_control) {
chip->cs_control = default_cs_control;
@@ -2131,8 +2220,9 @@
chip->com_ctrl = 0;
chip->fmt_ctrl = 0;
chip->fifo_ctrl = 0;
-
- if ((chip_info->com_mode == DMA_TRANSFER)
+ chip->timing = 0;
+
+ if ((chip->xfer_type == DMA_TRANSFER)
&& ((zx29spi->master_info)->enable_dma)) {
chip->enable_dma = true;
dev_dbg(&spi->dev, "DMA mode set in controller state\n");
@@ -2185,6 +2275,10 @@
SPI_WRITE_BITS(chip->com_ctrl, chip_info->hierarchy, SPI_COM_CTRL_MASK_MS, 2);
// SPI_WRITE_BITS(chip->com_ctrl, chip_info->slave_tx_disable, SPI_COM_CTRL_MASK_SOD, 3);
+ if(spi->trans_gaped) {
+ chip->enable_trans_gap = true;
+ }
+ SPI_WRITE_BITS(chip->timing, spi->trans_gap_num, SPI_TIMING_MASK_T_CS_DESEL, 0);
/* Save controller_state */
spi_set_ctldata(spi, chip);
@@ -2370,13 +2464,15 @@
if (device_property_read_u8(dev, "num_chipselect", &platform_info->num_chipselect)) {
platform_info->num_chipselect = 1;
}
+#if 0
if (device_property_read_u32(dev, "enable_dma",&enable_dma)) {
dev_err(&pdev->dev,"enable_dma get failed");
platform_info->enable_dma = 0;
}
else {
platform_info->enable_dma = enable_dma;
- }
+ }
+#endif
if (device_property_read_u32(dev, "autosuspend_delay", &platform_info->autosuspend_delay))
platform_info->autosuspend_delay = 0;
@@ -2494,7 +2590,7 @@
return 0;
platform_info->bus_id = 0,
platform_info->num_chipselect = 1,
- platform_info->enable_dma = 0,
+ platform_info->enable_dma = 1,
platform_info->autosuspend_delay=0,
/* Allocate master with space for data */
@@ -2581,7 +2677,6 @@
load_spi_default_config(zx29spi);
writel(0, (SPI_TIMING_OFFSET + zx29spi->virtbase));
-
if(!strcmp(pdev->name,"1410000.ssp")) {
regval = readl((SPI_FMT_CTRL_OFFSET+zx29spi->virtbase))&(~(0x1<<12));
writel(regval, (SPI_FMT_CTRL_OFFSET+zx29spi->virtbase));
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spidev.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spidev.c
index 02f0112..e1d5562 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spidev.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spidev.c
@@ -542,8 +542,9 @@
spidev->speed_hz = tmp;
dev_dbg(&spi->dev, "%d Hz (max)\n",
spidev->speed_hz);
+ } else {
+ spi->max_speed_hz = save;
}
- spi->max_speed_hz = save;
}
break;
case SPI_IOC_WR_RD_DATA_FROM:
@@ -856,6 +857,8 @@
#define MSG_HEAD 0xa5a5
#define MSG_TAIL 0x7e7e
+extern void slave_mode_set(struct spi_device *spi,unsigned int param);
+extern void set_spi_timing(struct spi_device *spi,unsigned int param);
extern int get_spi_rx_fifo(struct spi_device *spi,unsigned char *buf);
static int spidev_get_rxfifo(struct spi_device *spi,unsigned char *buf)
{
@@ -1591,6 +1594,12 @@
dev_info(dev, "get rx_fifo_len(%d bytes) \n",ret);
print_buf_data(buff,ret);
}
+
+ ret = strcmp(cmd_str,"timing-set");
+ if(ret == 0) {
+ dev_info(dev, "timing param(%d) \n",param1);
+ set_spi_timing(spi,param1);
+ }
ret = strcmp(cmd_str,"loop-en");
if(ret == 0) {
@@ -1619,6 +1628,17 @@
ret = spi_setup(spi);
dev_info(dev, "set spi mode(0x%x),ret=%d \n",spi->mode,ret);
}
+
+
+ ret = strcmp(cmd_str,"slave_mode_set");
+ if(ret == 0) {
+ if(param1 != 0 && param1 != 1 && param1 != 2 && param1 != 3)
+ dev_info(dev, "param err(%d) \n",param1);
+ else
+ dev_info(dev, "set spi mode(%d) \n",param1);
+ slave_mode_set(spi,param1);
+ }
+
ret = strcmp(cmd_str,"send_msg_rand_len");
if(ret == 0) {
@@ -1905,7 +1925,7 @@
//printk("send signal %d to pid %d \n",sig_no,spidev->pid);
memset(&info,0,sizeof(struct siginfo));
if(spidev->pid == 0) {
- printk("pid[%d] is not valid %d \n",spidev->pid);
+ printk("send_signal pid is not valid \n");
return;
}
@@ -1917,7 +1937,7 @@
rcu_read_unlock();
if(!my_task) {
- printk("get pid_task failed! \n");
+ printk("%s get pid_task failed! \n",__FUNCTION__);
return;
}
ret = send_sig_info(sig_no, &info, my_task);
@@ -1953,7 +1973,7 @@
spidev->dma_cfg_done= 0;
}
if(spidev->pid == 0) {
- printk("pid[%d] is not valid %d \n",spidev->pid);
+ printk("%s is not valid\n",__FUNCTION__);
return;
}
info.si_signo = sig_no;
@@ -1963,7 +1983,7 @@
rcu_read_unlock();
if(!my_task) {
- printk("get pid_task failed! \n");
+ printk("%s get pid_task failed! \n",__FUNCTION__);
return;
}
ret = send_sig_info(sig_no, &info, my_task);
@@ -2054,7 +2074,7 @@
struct spidev_data *spidev;
int status;
unsigned long minor;
-
+ u32 val;
/*
* spidev should never be referenced in DT without a specific
* compatible string, it is a Linux implementation thing
@@ -2077,6 +2097,33 @@
mutex_init(&spidev->buf_lock);
INIT_LIST_HEAD(&spidev->device_entry);
+
+ if (device_property_read_u32(&spi->dev, "enable_dma",&val)) {
+ spi->dma_used = 0;
+ dev_err(&spi->dev,"enable_dma get failed");
+ }
+ else {
+ spi->dma_used = val;
+ dev_info(&spi->dev,"enable_dma = 0x%x",val);
+ }
+
+ if (device_property_read_u32(&spi->dev, "enable_trans_gap",&val)) {
+ spi->trans_gaped = 0;
+ dev_err(&spi->dev,"enable_trans_gap get failed");
+ }
+ else {
+ spi->trans_gaped = val;
+ dev_info(&spi->dev,"enable_trans_gap = 0x%x",val);
+ }
+
+ if (device_property_read_u32(&spi->dev, "trans_gap_num",&val)) {
+ spi->trans_gap_num = 0;
+ dev_err(&spi->dev,"trans_gap_num get failed");
+ }
+ else {
+ spi->trans_gap_num = val;
+ dev_info(&spi->dev,"trans_gap_num = 0x%x",val);
+ }
/* If we can allocate a minor number, hook up this device.
* Reusing minors is fine so long as udev or mdev is working.
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tee/optee/call.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tee/optee/call.c
index f8f1594..a145b5d 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tee/optee/call.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tee/optee/call.c
@@ -14,12 +14,16 @@
#include <linux/uaccess.h>
#include "optee_private.h"
#include "optee_smc.h"
+#include <linux/delay.h>
struct optee_call_waiter {
struct list_head list_node;
struct completion c;
};
+extern struct mutex optee_mutex;
+extern struct semaphore optee_session_sema;
+
static void optee_cq_wait_init(struct optee_call_queue *cq,
struct optee_call_waiter *w)
{
@@ -131,6 +135,7 @@
struct optee_call_ctx call_ctx = { };
u32 ret;
+ mutex_lock(&optee_mutex);
param.a0 = OPTEE_SMC_CALL_WITH_ARG;
reg_pair_from_64(¶m.a1, ¶m.a2, parg);
/* Initialize waiter */
@@ -168,7 +173,7 @@
* thread waiters wake up one.
*/
optee_cq_wait_final(&optee->call_queue, &w);
-
+ mutex_unlock(&optee_mutex);
return ret;
}
@@ -219,6 +224,8 @@
struct optee_session *sess = NULL;
uuid_t client_uuid;
+ //down_timeout(&optee_session_sema,msecs_to_jiffies(5000));
+ down(&optee_session_sema);
/* +2 for the meta parameters added below */
shm = get_msg_arg(ctx, arg->num_params + 2, &msg_arg, &msg_parg);
if (IS_ERR(shm))
@@ -312,6 +319,7 @@
optee_do_call_with_arg(ctx, msg_parg);
tee_shm_free(shm);
+ up(&optee_session_sema);
return 0;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tee/optee/core.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tee/optee/core.c
index 6ea80ad..8138565 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tee/optee/core.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tee/optee/core.c
@@ -22,11 +22,39 @@
#include "optee_private.h"
#include "optee_smc.h"
#include "shm_pool.h"
+#include <linux/soc/zte/rpmsg.h>
+#include "ram_config.h"
+#include <linux/delay.h>
+#include <linux/cache.h>
+#include <asm/cacheflush.h>
+#include <linux/mutex.h>
+#include <linux/module.h>
+#include <linux/etherdevice.h>
+#include <linux/kthread.h>
+#include "optee_smc.h"
#define DRIVER_NAME "optee"
-#define OPTEE_SHM_NUM_PRIV_PAGES CONFIG_OPTEE_SHM_NUM_PRIV_PAGES
+#define OPTEE_SHM_NUM_PRIV_PAGES CONFIG_OPTEE_SHM_NUM_PRIV_PAGES
+#define OPTEE_ICP_CHID (11)
+#define OPTEE_ICP_RPC_CHID (12)
+struct mutex optee_mutex;
+struct semaphore optee_session_sema;
+extern void v7_dma_map_area(const void *, size_t, int);
+typedef struct optee_rpmsg_arg {
+ unsigned long a0;
+ unsigned long a1;
+ unsigned long a2;
+ unsigned long a3;
+ unsigned long a4;
+ unsigned long a5;
+ unsigned long a6;
+ unsigned long a7;
+}optee_rpmsg_args_t;
+volatile struct optee *optee_svc = NULL;
+size_t optee_shm_size =0;
+phys_addr_t optee_shm_paddr =0;
/**
* optee_from_msg_param() - convert from OPTEE_MSG parameters to
* struct tee_param
@@ -68,6 +96,10 @@
p->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT +
attr - OPTEE_MSG_ATTR_TYPE_TMEM_INPUT;
p->u.memref.size = mp->u.tmem.size;
+ if (optee_svc != NULL)
+ {
+ v7_dma_map_area(optee_svc->memremaped_shm+(mp->u.tmem.buf_ptr -optee_shm_paddr), mp->u.tmem.size, DMA_FROM_DEVICE);
+ }
shm = (struct tee_shm *)(unsigned long)
mp->u.tmem.shm_ref;
if (!shm) {
@@ -495,14 +527,17 @@
pr_err("too small shared memory area\n");
return ERR_PTR(-EINVAL);
}
-
+
+ optee_shm_paddr = paddr;
va = memremap(paddr, size, MEMREMAP_WB);
if (!va) {
pr_err("shared memory ioremap failed\n");
return ERR_PTR(-EINVAL);
}
vaddr = (unsigned long)va;
-
+ optee_shm_size = size;
+ printk("optee memremap va=0x%x pa=0x%x size=0x%x",va,paddr,size);
+
rc = tee_shm_pool_mgr_alloc_res_mem(vaddr, paddr, sz,
3 /* 8 bytes aligned */);
if (IS_ERR(rc))
@@ -554,21 +589,112 @@
arm_smccc_hvc(a0, a1, a2, a3, a4, a5, a6, a7, res);
}
-static optee_invoke_fn *get_invoke_func(struct device *dev)
+void optee_rpmsg_init(void )
+{
+ int ret;
+
+ ret = rpmsgCreateChannel(CORE_PS0, OPTEE_ICP_CHID, 512 );
+ if (ret)
+ printk("optee rpmsgCreateChannel failed %d \n", ret);
+
+ ret = rpmsgCreateChannel(CORE_PS0, OPTEE_ICP_RPC_CHID, 512 );
+ if (ret)
+ printk("optee rpmsgCreateChannel failed %d \n", ret);
+ mutex_init(&optee_mutex);
+ sema_init(&optee_session_sema, 2);
+}
+
+void optee_smccc_rpmsg(unsigned long a0, unsigned long a1,
+ unsigned long a2, unsigned long a3,
+ unsigned long a4, unsigned long a5,
+ unsigned long a6, unsigned long a7,
+ struct arm_smccc_res *res)
{
- const char *method;
+ int ret = 0;
+ T_RpMsg_Msg writerpmsg = {0};
+ T_RpMsg_Msg readrpmsg = {0};
+ optee_rpmsg_args_t optee_args = {0};
+ unsigned long writechid =OPTEE_ICP_CHID;
- pr_info("probing for conduit method.\n");
+ if(a0 == OPTEE_SMC_CALL_RETURN_FROM_RPC)
+ writechid = OPTEE_ICP_RPC_CHID;
+ optee_args.a0= a0;
+ optee_args.a1= a1;
+ optee_args.a2= a2;
+ optee_args.a3= a3;
+ optee_args.a4= a4;
+ optee_args.a5= a5;
+ optee_args.a6= a6;
+ optee_args.a7= a7;
- if (device_property_read_string(dev, "method", &method)) {
- pr_warn("missing \"method\" property\n");
- return ERR_PTR(-ENXIO);
- }
+ writerpmsg.buf = &optee_args;
+ writerpmsg.len = sizeof(optee_args);
+ writerpmsg.coreID = CORE_PS0;
+ writerpmsg.chID = writechid;//OPTEE_ICP_CHID;
+ writerpmsg.flag = 1 ;
- if (!strcmp("hvc", method))
- return optee_smccc_hvc;
- else if (!strcmp("smc", method))
- return optee_smccc_smc;
+ if (optee_svc != NULL)
+ {
+ v7_dma_map_area(optee_svc->memremaped_shm, optee_shm_size, DMA_TO_DEVICE);
+ }
+ while (1)
+ {
+ ret = rpmsgWrite(&writerpmsg);
+ if ((ret == RPMSG_CHANNEL_INEXISTANCE) ||(ret == RPMSG_SPACE_NOT_ENOUGH))
+ {
+ //printk("optee rpmsgWrite ret %d\n", ret);
+ msleep(100);
+ }
+ else
+ break;
+ }
+
+ memset(&optee_args,0,sizeof(optee_args));
+ readrpmsg.coreID = CORE_PS0;
+ readrpmsg.chID = OPTEE_ICP_CHID;
+ readrpmsg.buf = &optee_args;
+ readrpmsg.len = sizeof(optee_args) ;
+ readrpmsg.flag =1;
+
+ if (optee_svc != NULL)
+ {
+ //v7_dma_map_area(optee_svc->memremaped_shm, optee_shm_size, DMA_FROM_DEVICE);
+ v7_dma_map_area(optee_svc->memremaped_shm, 0x1000, DMA_FROM_DEVICE);
+ }
+ while (1)
+ {
+ ret = rpmsgRead(&readrpmsg);
+ if (ret == RPMSG_CHANNEL_INEXISTANCE)
+ {
+ //printk("optee rpmsgRead ret %d\n", ret);
+ msleep(100);
+ }
+ else
+ break;
+ }
+
+ memcpy(res,&optee_args,sizeof(struct arm_smccc_res));
+}
+
+static optee_invoke_fn *get_invoke_func(struct device_node *np)
+{
+ const char *method;
+
+ pr_info("probing for conduit method from DT.\n");
+
+ if (of_property_read_string(np, "method", &method)) {
+ pr_warn("missing \"method\" property\n");
+ return ERR_PTR(-ENXIO);
+ }
+
+ if (!strcmp("hvc", method))
+ return optee_smccc_hvc;
+ else if (!strcmp("smc", method))
+ return optee_smccc_smc;
+ else
+ {
+ return optee_smccc_rpmsg;
+ }
pr_warn("invalid \"method\" property: %s\n", method);
return ERR_PTR(-EINVAL);
@@ -581,9 +707,10 @@
* that it should release the device
*/
-static int optee_remove(struct platform_device *pdev)
+//static int optee_remove(struct platform_device *pdev)
+static void optee_remove(struct optee *optee)
{
- struct optee *optee = platform_get_drvdata(pdev);
+ //struct optee *optee = platform_get_drvdata(pdev);
/* Unregister OP-TEE specific client devices on TEE bus */
optee_unregister_devices();
@@ -609,10 +736,10 @@
optee_wait_queue_exit(&optee->wait_queue);
optee_supp_uninit(&optee->supp);
mutex_destroy(&optee->call_queue.mutex);
-
+ mutex_destroy(&optee_mutex);
kfree(optee);
-
- return 0;
+ optee_svc = NULL;
+ return ;
}
/* optee_shutdown - Device Removal Routine
@@ -627,7 +754,7 @@
optee_disable_shm_cache(platform_get_drvdata(pdev));
}
-static int optee_probe(struct platform_device *pdev)
+static struct optee *optee_probe(struct device_node *np)
{
optee_invoke_fn *invoke_fn;
struct tee_shm_pool *pool = ERR_PTR(-EINVAL);
@@ -645,10 +772,13 @@
* Therefore, we cannot reliably initialize the OP-TEE driver in the
* kdump kernel.
*/
+ printk("optee optee_probe \n");
+
if (is_kdump_kernel())
return -ENODEV;
- invoke_fn = get_invoke_func(&pdev->dev);
+ optee_rpmsg_init();
+ invoke_fn = get_invoke_func(np);
if (IS_ERR(invoke_fn))
return PTR_ERR(invoke_fn);
@@ -742,13 +872,13 @@
if (optee->sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)
pr_info("dynamic shared memory is enabled\n");
- platform_set_drvdata(pdev, optee);
-
- rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES);
- if (rc) {
- optee_remove(pdev);
- return rc;
- }
+// platform_set_drvdata(pdev, optee);
+ optee_svc = optee;
+// rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES);
+// if (rc) {
+// optee_remove(optee);
+// return rc;
+// }
pr_info("initialized driver\n");
return 0;
@@ -770,26 +900,58 @@
return rc;
}
-static const struct of_device_id optee_dt_match[] = {
+static const struct of_device_id optee_match[] = {
{ .compatible = "linaro,optee-tz" },
{},
};
-MODULE_DEVICE_TABLE(of, optee_dt_match);
-static struct platform_driver optee_driver = {
- .probe = optee_probe,
- .remove = optee_remove,
- .shutdown = optee_shutdown,
- .driver = {
- .name = "optee",
- .of_match_table = optee_dt_match,
- },
-};
-module_platform_driver(optee_driver);
+static int optee_driver_init(void *p)
+{
+ struct device_node *fw_np = NULL;
+ struct device_node *np = NULL;
+ struct optee *optee = NULL;
+ int rc = 0;
+
+ /* Node is supposed to be below /firmware */
+ fw_np = of_find_node_by_name(NULL, "firmware");
+ if (!fw_np)
+ return -ENODEV;
+
+ np = of_find_matching_node(fw_np, optee_match);
+ if (!np || !of_device_is_available(np)) {
+ of_node_put(np);
+ return -ENODEV;
+ }
+
+ optee = optee_probe(np);
+ of_node_put(np);
+
+ if (IS_ERR(optee))
+ return PTR_ERR(optee);
+ return 0;
+}
+
+static int __init optee_init(void)
+{
+ kthread_run(optee_driver_init, NULL, "optee");
+ return 0;
+}
+
+module_init(optee_init);
+
+static void __exit optee_driver_exit(void)
+{
+ struct optee *optee = optee_svc;
+
+ optee_svc = NULL;
+ if (optee)
+ optee_remove(optee);
+}
+module_exit(optee_driver_exit);
MODULE_AUTHOR("Linaro");
MODULE_DESCRIPTION("OP-TEE driver");
MODULE_SUPPORTED_DEVICE("");
MODULE_VERSION("1.0");
MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:optee");
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
index 39a6b6b..6336b21 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
@@ -69,36 +69,15 @@
#define CONFIG_SERIAL_ZX29_DMA 1
-typedef struct __UART_STATIC{
- int cnt;
- char head[16];
- unsigned long long s_time;
- int func_step;
-}uart_static;
-#define STATIC_UART_ID 2
-uart_static g_uart_static[256] = {0};
-int g_uart_static_cnt = 0;
-void test_uart_static(int uart_id, char *buf, int cnt, int steps)
-{
- if(uart_id != STATIC_UART_ID)
- return;
+extern bool xp2xp_Ap2CpIsApWakeup(void);
+extern int xp2xp_enable_4line(void);
-
- if(buf){
- if(cnt >= 16){
- strncpy(g_uart_static[g_uart_static_cnt].head, buf, 16);
- }else{
- memcpy(g_uart_static[g_uart_static_cnt].head, buf, cnt);
- }
- }
- g_uart_static[g_uart_static_cnt].cnt = cnt;
- g_uart_static[g_uart_static_cnt].s_time = local_clock();
- g_uart_static[g_uart_static_cnt].func_step = steps;
- if(++g_uart_static_cnt >= 256)
- g_uart_static_cnt = 0;
-
-}
+extern signed int zx29_dma_stop(unsigned int channel_id);
+extern signed int zx29_dma_get_transfer_num(unsigned int channel_id);
+
+
+
char uart_names[5][12] = {
"zx29_uart.0",
"zx29_uart.1",
@@ -111,7 +90,7 @@
#define ZX29_DMA_BUFFER_SIZE PAGE_SIZE
#define UART_DMA_RX_MAX_COUNT 2
//#define RX_DMA_TIMEOUT (HZ / 10)//60
-#define RX_DMA_TIMEOUT 20
+#define RX_DMA_TIMEOUT (HZ / 100)
#define RX_DMA_WORK 1
struct zx29_sgbuf {
struct scatterlist sg;
@@ -147,6 +126,7 @@
#define UART_NUM 5
+int g_uart_overrun = 0;
/****************************************************************************/
@@ -241,8 +221,15 @@
struct zx29_sgbuf *curr_sg;
int enable_ctsrts;
int enable_wakeup;
+
+ struct notifier_block wakeup_notifier;
#endif
+ //means application decide close and release DMA &wakelock
+ int app_ctrl;
+ int sleep_state;
+ //if app_ctrl is set or using kernel control sleep,set this flag
+ int uart_power_mode;
};
@@ -250,7 +237,157 @@
static struct zx29_uart_port zx29_uart_ports[UART_NUM];
#define zx29_MAXPORTS ARRAY_SIZE(zx29_uart_ports)
+typedef struct __UART_STATIC{
+ int cnt;
+ char head[16];
+ unsigned long long s_time;
+ int func_step;
+ unsigned int fr;
+ unsigned int ris;
+}uart_static;
+#define STATIC_UART_ID 0
+uart_static g_uart_static[256] = {0};
+int g_uart_static_cnt = 0;
+void test_uart_static(int uart_id, char *buf, int cnt, int steps)
+{
+ if(uart_id != STATIC_UART_ID)
+ return;
+ if(buf){
+ if(cnt >= 16){
+ strncpy(g_uart_static[g_uart_static_cnt].head, buf, 16);
+ }else{
+ memcpy(g_uart_static[g_uart_static_cnt].head, buf, cnt);
+ }
+ }
+ g_uart_static[g_uart_static_cnt].cnt = cnt;
+ g_uart_static[g_uart_static_cnt].s_time = local_clock();
+ g_uart_static[g_uart_static_cnt].func_step = steps;
+ g_uart_static[g_uart_static_cnt].fr = UART_GET_FR(&zx29_uart_ports[uart_id].port);
+ g_uart_static[g_uart_static_cnt].ris = UART_GET_RIS(&zx29_uart_ports[uart_id].port);
+ if(++g_uart_static_cnt >= 256)
+ g_uart_static_cnt = 0;
+}
+
+
+
+
+#define zx29_MAXPORTS ARRAY_SIZE(zx29_uart_ports)
+void zx29_uart_stop_rx(struct uart_port *port);
+
+#if CONFIG_SERIAL_ZX29_DMA
+static inline bool zx29_dma_tx_start(struct zx29_uart_port *zup);
+static inline void zx29_dma_tx_stop(struct zx29_uart_port *zup);
+static bool zx29_dma_tx_irq(struct zx29_uart_port *zup);
+static int zx29_uart_dma_tx_chars(struct zx29_uart_port *zup);
+void uart_dma_rx_callback(void *data);
+static void zx29_uart_dma_rx_chars(struct zx29_uart_port *zup,
+ //u32 pending, bool use_buf_b,
+ u32 pending, struct zx29_sgbuf *sgbuf,
+ bool readfifo, unsigned long *flags);
+static inline void zx29_dma_rx_stop(struct zx29_uart_port *zup);
+static inline bool zx29_dma_rx_available(struct zx29_uart_port *zup);
+static inline bool zx29_dma_rx_running(struct zx29_uart_port *zup);
+static int zx29_dma_rx_trigger_dma(struct zx29_uart_port *zup);
+
+static void zx29_uart_rx_dma_chars(struct zx29_uart_port *zup, unsigned long *flags);
+dma_peripheral_id uart_get_rx_dma_peripheral_id(struct zx29_uart_port *zup);
+
+#if RX_DMA_WORK
+static void zx29_uart_rx_timeout_chars(struct zx29_uart_port *zup, unsigned long *flags);
+static inline bool zx29_dma_rx_work_scheduled(struct zx29_uart_port *zup);
+
+static void zx29_uart_rt_dma(struct zx29_uart_port *zup, unsigned long *flags);
+#endif
+#endif
+
+
+
+/*******************************************************************************
+* Function: uart_wakeup_callback.
+* Description: uart_wakeup_callback.
+* Parameters:
+* Input:val:means wakeup or sleep notify to other device
+*
+* Output:v:means devices been called return result
+*
+* Returns:
+*
+* Others:
+********************************************************************************/
+int uart_wakeup_callback(struct notifier_block * nb, unsigned long val, void * v)
+{
+ int *call_result = (int *)v;
+ unsigned long flags = 0;
+ struct zx29_uart_port *zup = container_of(nb, struct zx29_uart_port, wakeup_notifier);
+ struct platform_device *pdev = zup->port.private_data;
+ if(!zup || zup->port_close){
+ *call_result |= 0;
+ return 0;
+ }
+ raw_spin_lock_irqsave(&zup->port.lock, flags);
+ if(val == 1){//wakeup
+ zup->sleep_state = 0;
+ pm_stay_awake(&pdev->dev);
+ zx29_uart_rx_dma_chars(zup, &flags);
+
+ }else{//sleep
+ zup->sleep_state = 1;
+ zx29_uart_stop_rx(&zup->port);
+ pm_relax(&pdev->dev);
+
+ }
+ *call_result |= 0;
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
+ return 0;
+}
+
+int zx29_get_sleep_state(int uart_index)
+{
+ if(uart_index < 0 || uart_index > 2){
+ printk("invalid uart index\n");
+ return -1;
+ }
+
+ return zx29_uart_ports[uart_index].sleep_state;
+}
+EXPORT_SYMBOL_GPL(zx29_get_sleep_state);
+
+void zx29_set_sleep_state(int state, int uart_index)
+{
+ if(uart_index < 0 || uart_index > 2){
+ printk("invalid uart index\n");
+ return ;
+ }
+ printk(" uart %d, state change to:%d\n", uart_index, state);
+ zx29_uart_ports[uart_index].sleep_state = (state ? 1: 0);
+}
+EXPORT_SYMBOL_GPL(zx29_set_sleep_state);
+
+static ssize_t sleep_state_show(struct device *_dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct platform_device *pdev = container_of(_dev, struct platform_device, dev);
+ //struct zx29_uart_platdata *pdata = pdev->dev.platform_data;
+
+ return sprintf(buf, "\n wakeup_enable = %d\n",zx29_uart_ports[pdev->id].sleep_state);
+}
+
+static ssize_t sleep_state_store(struct device *_dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ uint32_t flag = 0;
+ struct platform_device *pdev = container_of(_dev, struct platform_device, dev);
+ struct zx29_uart_platdata *pdata = pdev->dev.platform_data;
+ flag = simple_strtoul(buf, NULL, 16);
+ //pdata->uart_wakeup_enable = flag;
+ zx29_uart_ports[pdev->id].sleep_state = (flag ? 1: 0);
+ return count;
+}
+
+DEVICE_ATTR(sleep_state, S_IRUGO | S_IWUSR, sleep_state_show,
+ sleep_state_store);
//bool uart_dma_filter_fn (struct dma_chan *chan, void *param)
//{
// dma_peripheral_id peri_id = (dma_peripheral_id) param;
@@ -326,7 +463,7 @@
uint32_t flag = 0;
struct platform_device *pdev = container_of(_dev, struct platform_device, dev);
- if(pdev->id != 2){
+ if(pdev->id != 0){
printk("ctsrts_input_store, invalid uart id, only uart support hardware control\n");
}
flag = simple_strtoul(buf, NULL, 16);
@@ -365,6 +502,32 @@
DEVICE_ATTR(wakeup_enable, S_IRUGO | S_IWUSR, wakeup_enable_show,
wakeup_enable_store);
+
+static ssize_t app_ctrl_show(struct device *_dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct platform_device *pdev = container_of(_dev, struct platform_device, dev);
+ //struct zx29_uart_platdata *pdata = pdev->dev.platform_data;
+
+ return sprintf(buf, "%d\n",zx29_uart_ports[pdev->id].app_ctrl);
+}
+
+static ssize_t app_ctrl_store(struct device *_dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ uint32_t flag = 0;
+ struct platform_device *pdev = container_of(_dev, struct platform_device, dev);
+ //struct zx29_uart_platdata *pdata = pdev->dev.platform_data;
+ flag = simple_strtoul(buf, NULL, 16);
+ // pdata->uart_wakeup_enable = flag;
+ zx29_uart_ports[pdev->id].app_ctrl = (flag == 0) ? 0 : 1;
+
+ return count;
+}
+DEVICE_ATTR(app_ctrl, S_IRUGO | S_IWUSR, app_ctrl_show,
+ app_ctrl_store);
+
int rxd_wake_cnt = 0;
static ssize_t statics_show(struct device *_dev,
struct device_attribute *attr, char *buf)
@@ -529,36 +692,6 @@
coreid_occupy_uart_store);
#endif
-
-#if CONFIG_SERIAL_ZX29_DMA
-static inline bool zx29_dma_tx_start(struct zx29_uart_port *zup);
-static inline void zx29_dma_tx_stop(struct zx29_uart_port *zup);
-static bool zx29_dma_tx_irq(struct zx29_uart_port *zup);
-static int zx29_uart_dma_tx_chars(struct zx29_uart_port *zup);
-void uart_dma_rx_callback(void *data);
-static void zx29_uart_dma_rx_chars(struct zx29_uart_port *zup,
- //u32 pending, bool use_buf_b,
- u32 pending, struct zx29_sgbuf *sgbuf,
- bool readfifo, unsigned long *flags);
-static inline void zx29_dma_rx_stop(struct zx29_uart_port *zup);
-static inline bool zx29_dma_rx_available(struct zx29_uart_port *zup);
-static inline bool zx29_dma_rx_running(struct zx29_uart_port *zup);
-static int zx29_dma_rx_trigger_dma(struct zx29_uart_port *zup);
-
-static void zx29_uart_rx_dma_chars(struct zx29_uart_port *zup, unsigned long *flags);
-dma_peripheral_id uart_get_rx_dma_peripheral_id(struct zx29_uart_port *zup);
-extern signed int zx29_dma_stop(unsigned int channel);
-extern signed int zx29_dma_get_transfer_num(unsigned int channel_id);// add by gsn for linuxDMA
-extern bool zx29_dma_filter_fn(struct dma_chan *chan, void *param);
-
-#if RX_DMA_WORK
-static void zx29_uart_rx_timeout_chars(struct zx29_uart_port *zup, unsigned long *flags);
-static inline bool zx29_dma_rx_work_scheduled(struct zx29_uart_port *zup);
-
-static void zx29_uart_rt_dma(struct zx29_uart_port *zup, unsigned long *flags);
-#endif
-
-
//extern int (*pm_callback_fn)(void);
#ifdef CONFIG_CPU_IDLE
typedef int (*pm_callback_fn)(void);
@@ -628,7 +761,7 @@
sg->dma_addr = NULL;
}
}
-#endif
+
/****************************************************************************/
static unsigned int zx29_uart_tx_empty(struct uart_port *port)
@@ -896,7 +1029,7 @@
}
/****************************************************************************/
-static void zx29_uart_stop_rx(struct uart_port *port)
+void zx29_uart_stop_rx(struct uart_port *port)
{
struct zx29_uart_port *zup = container_of(port, struct zx29_uart_port, port);
@@ -1346,8 +1479,9 @@
zup->dmacr |= UART_RXDMAE;
UART_PUT_DMACR(&zup->port, zup->dmacr);
zup->dmarx.running = true;
- //zup->imr &= ~UART_RXIM;
- //UART_PUT_IMSC(&zup->port,zup->imr);
+ zup->dmarx.used = true;
+ zup->imr &= ~(UART_RXIM | UART_RTIM);
+ UART_PUT_IMSC(&zup->port,zup->imr);
return 0;
@@ -1362,6 +1496,7 @@
struct dma_chan *rxchan = dmarx->chan;
struct device *dev = NULL;
// struct dma_tx_state state;
+ unsigned int ris_status;
bool lastbuf;
int dma_count = 0;
@@ -1369,6 +1504,23 @@
size_t pending;
spin_lock_irqsave(&zup->port.lock, flags);
+ ris_status = UART_GET_RIS(&zup->port);
+ if(ris_status & (UART_OEIS | UART_BEIS | UART_PEIS | UART_FEIS)){
+ if(ris_status & UART_OEIS){
+ zup->port.icount.overrun++;
+ g_uart_overrun = 4;
+ test_uart_static(zup->port.line, NULL, 0, 20);
+ if(!uart_console(&zup->port))
+ BUG_ON(1);
+ }
+ if(ris_status & UART_BEIS)
+ zup->port.icount.brk++;
+ if(ris_status & UART_PEIS)
+ zup->port.icount.parity++;
+ if(ris_status & UART_FEIS)
+ zup->port.icount.frame++;
+ UART_PUT_ICR(&zup->port, (UART_OEIS | UART_BEIS | UART_PEIS | UART_FEIS));
+ }
dma_peripheral_id rx_id = uart_get_rx_dma_peripheral_id(zup);
zx29_dma_stop(rx_id);
@@ -1414,6 +1566,12 @@
zup->dmacr &= ~UART_RXDMAE;
UART_PUT_DMACR(&zup->port,zup->dmacr);
zx29_dma_stop(rx_id);
+#if 0
+ //do we need check data received?
+ if(zup->pre_pending){
+ printk("pre_pending :%d\n ", zup->pre_pending);
+ }
+#endif
zup->curr_sg = NULL;
}
@@ -1454,8 +1612,8 @@
DMA_TO_DEVICE);
zup->dmatx.queued = false;
}
-
- kfree(zup->dmatx.buf);
+ if(!zup->dmatx.buf)
+ kfree(zup->dmatx.buf);
zup->dmatx.buf = NULL;
zup->using_tx_dma = false;
}
@@ -1688,7 +1846,7 @@
* been taken first.
*/
//if (dma_count == pending && readfifo) {
- if ((pending > 0) && readfifo) {
+ if (readfifo) {
/* Clear any error flags */
//UART_PUT_ICR(&zup->port,UART_OEIC | UART_BEIC | UART_PEIC | UART_FEIC);
/*
@@ -1712,6 +1870,51 @@
}
}
+static void zx29_uart_deal_dma_fifo_rx_chars(struct zx29_uart_port *zup,
+ u32 pending, struct zx29_sgbuf *sgbuf,
+ unsigned long *flags, char *fifo_buf, int fifo_len)
+{
+ struct tty_struct *tty = zup->port.state->port.tty;
+
+ struct device *dev = zup->dmarx.chan->device->dev;
+ int dma_count = 0;
+ int fifo_count = 0;
+ u32 fifotaken = 0; /* only used for vdbg() */
+ if (pending) {
+ dma_sync_sg_for_cpu(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
+ spin_unlock_irqrestore(&zup->port.lock, *flags);
+ dma_count = tty_insert_flip_string(&zup->port.state->port,
+ sgbuf->buf, pending);
+ test_uart_static(zup->port.line, sgbuf->buf, pending, 6);
+ spin_lock_irqsave(&zup->port.lock, *flags);
+ dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
+ zup->port.icount.rx += dma_count;
+ if (dma_count < pending)
+ dev_info(zup->port.dev,
+ "couldn't insert all characters (TTY is full?)\n");
+ }
+
+ if(fifo_len){
+ printk("qq >> fifo len %d.\n",fifo_len);
+ fifo_count = tty_insert_flip_string(&zup->port.state->port,
+ fifo_buf, fifo_len);
+ printk("qq >>fifo count %d,buf is %x %x %x .\n",fifo_count, fifo_buf[0],fifo_buf[1],fifo_buf[2]);
+ fifo_buf[0] = '\0';
+ fifo_buf[1] = '\0';
+ fifo_buf[2] = '\0';
+ //memset(fifo_buf, '\0', 4);
+ }
+
+ zup->port.icount.rx += fifo_count;
+ test_uart_static(zup->port.line, fifo_buf, fifo_count, 18);
+ if(pending > 0 || (fifo_len > 0)){
+ spin_unlock(&zup->port.lock);
+ tty_flip_buffer_push(&zup->port.state->port);
+ spin_lock(&zup->port.lock);
+ }
+}
+
+#if 0
static void zx29_dma_rx_irq(struct zx29_uart_port *zup, unsigned long *flags)
{
struct zx29_dmarx_data *dmarx = &zup->dmarx;
@@ -1791,6 +1994,7 @@
#endif
}
+#endif
/****************************************************************************/
static void zx29_uart_rx_dma_chars(struct zx29_uart_port *zup, unsigned long *flags)
{
@@ -1934,33 +2138,40 @@
#endif
}
+char g_fifo_residue_buf[4] = {'\0','\0','\0','\0'};
+char g_fifo_residue_all[20] = {0};
+unsigned char g_fifo_cnt = 0;
static void zx29_uart_rx_dma_timeout(struct timer_list *t)
{
struct zx29_uart_port *zup = from_timer(zup, t, rx_dma_timer);
- unsigned long flags;
struct zx29_dmarx_data *dmarx = &zup->dmarx;
- struct dma_chan *rxchan = dmarx->chan;
static bool dma_timeout_flag = false;
- size_t pending;
+ size_t pending, tmp_len;
uint32_t ris_status = 0;
+ int cancel_timer = 0;
int sg_idx = (dmarx->use_buf_b ? 1 : 0);
- struct zx29_sgbuf *sgbuf = zup->curr_sg;
- //struct dma_tx_state state;
- spin_lock_irqsave(&zup->port.lock, flags);
- if(!zx29_dma_rx_running(zup)){
+ unsigned long flags;
+ struct zx29_sgbuf *sgbuf = NULL;
+
+ if(!zx29_dma_rx_running(zup))
//printk("---uart_rx_dma_timeout enter, dma stopped\n");
- spin_unlock_irqrestore(&zup->port.lock, flags);
+ return;
+ raw_spin_lock_irqsave(&zup->port.lock, flags);
+ if(zup->port_close || (zup->curr_sg == NULL)){
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
return;
}
- dma_peripheral_id rx_id = uart_get_rx_dma_peripheral_id(zup);
//rxchan->device->device_tx_status(rxchan, dmarx->cookie, &state);
- if(sgbuf == NULL){
- spin_unlock_irqrestore(&zup->port.lock, flags);
- printk("rx_dma_timeout, curr_sg is NULL\n");
+ if(zup->sg2tty) {//dma complete now, later check again
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
+ test_uart_static(zup->port.line, NULL, 0, 14);
+ mod_timer(&(zup->rx_dma_timer), jiffies + RX_DMA_TIMEOUT);
return;
}
+ sgbuf = zup->curr_sg;
+ dma_peripheral_id rx_id = uart_get_rx_dma_peripheral_id(zup);
pending = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
//pending = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
//printk("---uart_rx_dma_timeout enter,sg.length:%d, pending:%d, state.residue:%d\n", sgbuf->sg.length, pending, state.residue);
@@ -1968,24 +2179,23 @@
int fr = UART_GET_FR(&zup->port);
//if RXBUSY,means data come again
- if((fr & UART_FR_RXBUSY) || (( fr & UART_FR_RXFE) == 0)){
+ if((fr & UART_FR_RXBUSY)){
- printk("RXBUSY, data come again\n");
uart_mod_timer(zup, &flags);
test_uart_static(zup->port.line, NULL, 0, 12);
goto deal_end;
}
- zup->imr &= ~UART_RXIM;
- UART_PUT_IMSC(&zup->port, zup->imr);
-
+
ris_status = UART_GET_RIS(&zup->port);
if(ris_status & (UART_OEIS | UART_BEIS | UART_PEIS | UART_FEIS)){
if(ris_status & UART_OEIS){
zup->port.icount.overrun++;
- //if(!uart_console(&zup->port))
- //BUG_ON(1);
+ g_uart_overrun = 1;
+ test_uart_static(zup->port.line, NULL, 0, 19);
+ if(!uart_console(&zup->port))
+ BUG_ON(1);
}
if(ris_status & UART_BEIS)
zup->port.icount.brk++;
@@ -1997,63 +2207,90 @@
UART_PUT_ICR(&zup->port, (UART_OEIS | UART_BEIS | UART_PEIS | UART_FEIS));
}
- //if(zx29_dma_stop(rx_id))
- // printk("unable to pause DMA transfer\n");
- //rxchan->device->device_tx_status(rxchan, dmarx->cookie, &state);
- //zx29_dma_force_stop(rx_id);
- //dmaengine_terminate_all(rxchan);
- /* Disable RX DMA - incoming data will wait in the FIFO */
zup->dmacr &= ~UART_RXDMAE;
UART_PUT_DMACR(&zup->port,zup->dmacr);
zx29_dma_stop(rx_id);
zup->dmarx.running = false;
zup->dmarx.used = false;
-
- zup->imr |= (UART_RTIM|UART_RXIM);
- UART_PUT_IMSC(&zup->port, zup->imr);
- pending = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
+ tmp_len = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
+ if(tmp_len != pending){
+ pending = tmp_len;
+ }
dmarx->use_buf_b = !dmarx->use_buf_b;
wmb();
- if(pending){
- test_uart_static(zup->port.line, NULL, 0, 13);
- zx29_uart_dma_rx_chars(zup, pending, sgbuf, false, &flags);
+ if(zup->uart_power_mode){
+ int i;
+ for(i= 0;i < 3;i++){
+ fr = UART_GET_FR(&zup->port);
+ if((fr & UART_FR_RXFE) == 0){
+ g_fifo_residue_buf[i] = UART_GET_CHAR(&zup->port) | UART_DUMMY_DR_RX;
+ g_fifo_residue_all[g_fifo_cnt++] = g_fifo_residue_buf[i];
+ if(g_fifo_cnt >= 20) g_fifo_cnt = 0;
+ }
+ else
+ break;
+ }
+ if(i){
+ g_fifo_residue_all[g_fifo_cnt++]=i;
+ if(g_fifo_cnt >= 20) g_fifo_cnt = 0;
}
- zup->pre_pending = 0;
- zup->work_state = false;
- if((UART_GET_RIS(&zup->port) & (UART_RXIS | UART_RTIS)) ||
- (UART_GET_FR(&zup->port) & UART_FR_RXBUSY)){
- zup->imr &= ~(UART_RXIM);
- UART_PUT_IMSC(&zup->port, zup->imr);
- // zx29_dma_rx_irq(zup, &flags);
-
- if (zx29_dma_rx_trigger_dma(zup)) {
- printk("uart%d could not retrigger RX DMA job\n",zup->port.line);
- zup->imr |= UART_RXIM;
- UART_PUT_IMSC(&zup->port, zup->imr);
-#if RX_DMA_WORK
- }
- else{
- // mod_timer(&(zup->rx_dma_timer), jiffies + msecs_to_jiffies(RX_DMA_TIMEOUT));
- uart_mod_timer(zup, &flags);
- test_uart_static(zup->port.line, NULL, 0, 14);
- zup->pre_pending = 0;
- zup->work_state = true;
- zup->dmarx.used = true;
- UART_PUT_ICR(&zup->port,(UART_RTIS|UART_RXIS));
-#endif
- }
+ //zup->sg2tty = sgbuf;
+ //when app ctrl sleep ,always start dma receive
+ if(zup->sleep_state == 0){
+ //now start dma again
+ if (zx29_dma_rx_trigger_dma(zup)) {
+ printk("rx_dma_chars RXDMA start fail\n");
+ zup->imr |= UART_RXIM;
+ UART_PUT_IMSC(&zup->port,zup->imr);
+ }else{
+ uart_mod_timer(zup, &flags);
+ zup->pre_pending = 0;
+ zup->dmarx.used = true;
+ zup->work_state = true;
+ }
+ }
+ if(pending || (i > 0)){
+ test_uart_static(zup->port.line, NULL, 0, 13);
+ zx29_uart_deal_dma_fifo_rx_chars(zup, pending, sgbuf, &flags, g_fifo_residue_buf,i);
+ }
+
+ }else{
+ //for normal mode, dma start only on rx busy after timeout came
+ if(pending || (( fr & UART_FR_RXFE) == 0)){
+ test_uart_static(zup->port.line, NULL, 0, 13);
+ zx29_uart_dma_rx_chars(zup, pending, sgbuf, true, &flags);
+ }
+ zup->imr |= (UART_RTIM|UART_RXIM);
+ UART_PUT_IMSC(&zup->port, zup->imr);
+ zup->pre_pending = 0;
+ zup->work_state = false;
+ if((UART_GET_RIS(&zup->port) & (UART_RXIS | UART_RTIS)) ||
+ (UART_GET_FR(&zup->port) & UART_FR_RXBUSY)){
+ zup->imr &= ~(UART_RXIM);
+ UART_PUT_IMSC(&zup->port, zup->imr);
+
+ if (zx29_dma_rx_trigger_dma(zup)) {
+ printk("rx_dma_chars RXDMA start fail\n");
+ zup->imr |= (UART_RTIM|UART_RXIM);
+ UART_PUT_IMSC(&zup->port,zup->imr);
+ }else{
+ uart_mod_timer(zup, &flags);
+ zup->pre_pending = 0;
+ zup->dmarx.used = true;
+ zup->work_state = true;
+ UART_PUT_ICR(&zup->port,(UART_RTIS|UART_RXIS));
+ }
+ }
+
}
deal_end:
- spin_unlock_irqrestore(&zup->port.lock, flags);
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
}else{
- spin_unlock_irqrestore(&zup->port.lock, flags);
- if(zup->port.line == 2)
- printk("rx_dma_timeout, pending:%d, zup->pre_pending:%d\n", pending, zup->pre_pending);
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
zup->pre_pending = pending;
- test_uart_static(zup->port.line, NULL, 0, 15);
- mod_timer(&(zup->rx_dma_timer), jiffies + msecs_to_jiffies(RX_DMA_TIMEOUT));
+ mod_timer(&(zup->rx_dma_timer), jiffies + RX_DMA_TIMEOUT);
//uart_mod_timer(zup, &flags);
}
@@ -2092,11 +2329,12 @@
struct uart_port *port = (struct uart_port *)dev_id;
struct zx29_uart_port *zup = container_of(port, struct zx29_uart_port, port);
unsigned long flags;
- unsigned int status, pass_counter = 256;
+ unsigned int status,ris, pass_counter = 256;
int handled = 0;
spin_lock_irqsave(&zup->port.lock, flags);
status = UART_GET_MIS(port) & zup->imr;
+ ris = UART_GET_RIS(port);
if (status) {
do {
UART_PUT_ICR(port,(status & ~(UART_TXIS|UART_RTIS|UART_RXIS)));
@@ -2109,6 +2347,13 @@
#endif
if (status & (UART_RXIS)){
#if CONFIG_SERIAL_ZX29_DMA
+ if(ris & UART_OEIS){
+ zup->port.icount.overrun++;
+ g_uart_overrun = 8;
+ test_uart_static(zup->port.line, NULL, 0, 21);
+ if(!uart_console(&zup->port))
+ BUG_ON(1);
+ }
if (zx29_dma_rx_used(zup)){
UART_PUT_ICR(port,UART_RXIS);
if(!(zup->imr & UART_RTIM)){
@@ -2345,6 +2590,20 @@
zup->dmacr &= ~UART_DMAONERR;
//zup->dmacr |= UART_DMAONERR;
UART_PUT_DMACR(&zup->port, zup->dmacr);
+ if(zup->uart_power_mode){
+ if (zup->using_rx_dma) {
+ //printk(KERN_INFO "[%s][%d]\n",__func__,__LINE__);
+ if (zx29_dma_rx_trigger_dma(zup)){
+ dev_dbg(zup->port.dev, "could not trigger initial "
+ "RX DMA job, fall back to interrupt mode\n");
+ }else{
+ mod_timer(&(zup->rx_dma_timer), jiffies + RX_DMA_TIMEOUT);
+ zup->pre_pending = 0;
+ zup->work_state = true;
+ }
+ }
+ }
+
}
@@ -2393,6 +2652,12 @@
wmb();
#endif
+ if(DEBUG_CONSOLE != pdev->id){
+ //app ctrl or kernel ctrl set this
+ int kernel_ctrl = xp2xp_enable_4line();
+ zup->uart_power_mode = (kernel_ctrl | zup->app_ctrl);
+ pm_stay_awake(&pdev->dev);
+ }
//when open, clear last statistic info
port->icount.brk = port->icount.buf_overrun = port->icount.frame = 0;
port->icount.overrun = port->icount.parity = port->icount.rng = 0;
@@ -2590,9 +2855,11 @@
spin_lock_irqsave(&zup->port.lock, flags);
/* Clear out any spuriously appearing RX interrupts */
UART_PUT_ICR(port, (UART_RTIS | UART_RXIS));
-
- zup->imr = UART_RTIM | UART_RXIM;
- UART_PUT_IMSC(port, zup->imr);
+ //when dma not running,set UART_RTIM | UART_RXIM
+ if(!zx29_dma_rx_running(zup)){
+ zup->imr = UART_RTIM | UART_RXIM;
+ UART_PUT_IMSC(port, zup->imr);
+ }
#if CONFIG_SERIAL_ZX29_DMA
zup->port_close = false;
#endif
@@ -2650,6 +2917,11 @@
val = UART_GET_LCRH(port);
val &= ~(UART_LCRH_BRK | UART_LCRH_FEN);
UART_PUT_LCRH(port, val);
+ if(zup->uart_power_mode){
+ pm_relax(&pdev->dev);
+ zup->app_ctrl = 0;
+ zup->uart_power_mode = 0;
+ }
#if 0
if(pdata->uart_use)
{
@@ -3290,6 +3562,9 @@
if(pdev->id != DEBUG_CONSOLE){
error = device_create_file(&pdev->dev, &dev_attr_ctsrts_input);
error = device_create_file(&pdev->dev, &dev_attr_wakeup_enable);
+ error = device_create_file(&pdev->dev, &dev_attr_sleep_state);
+ error = device_create_file(&pdev->dev, &dev_attr_app_ctrl);
+
}
error = device_create_file(&pdev->dev, &dev_attr_statics);
/*
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/function/adb_client.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/function/adb_client.c
index 36fd525..46b5743 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/function/adb_client.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/function/adb_client.c
@@ -27,7 +27,9 @@
#include <linux/types.h>
#include <linux/device.h>
#include <linux/miscdevice.h>
+#include <linux/android_notify.h>
#include <linux/soc/sc/rpmsg.h>
+#include <linux/suspend.h>
#define ADB_BULK_BUFFER_SIZE 4096
#define ADB_RPMSG_BUF_SIZE 512
@@ -214,6 +216,8 @@
if (adb_lock(&dev->read_excl))
{
+
+ //printk("adb_read read_excl lock fail, already locked\n");
ret = -EBUSY ;
goto exit ;
}
@@ -221,7 +225,7 @@
/* we will block until we're online */
while (!(dev->online || dev->error)) {
//printk("adb_read: waiting for online state\n");
- ret = wait_event_interruptible(dev->read_wq,
+ ret = wait_event_freezable(dev->read_wq,
(dev->online || dev->error) || !atomic_read(&g_adb_dev.inst_cnt));
if (ret < 0 ) {
//ret = -EAGAIN ;
@@ -253,7 +257,7 @@
//printk("adb_read: waiting for read_wq, dev->rx_done:%d\n", dev->rx_done);
- ret = wait_event_interruptible(dev->read_wq, dev->rx_done || !atomic_read(&g_adb_dev.inst_cnt));
+ ret = wait_event_freezable(dev->read_wq, dev->rx_done || !atomic_read(&g_adb_dev.inst_cnt));
if (ret < 0) {
if (ret != -ERESTARTSYS)
dev->error = 1;
@@ -303,6 +307,7 @@
}
ret = (r == 0) ? count : (count - r);
done:
+ dev->rx_len = 0;
adb_unlock(&dev->read_excl);
exit:
atomic_dec(&g_adb_dev.read_cnt);
@@ -368,7 +373,7 @@
}
//printk("adb_write, waiting write_wq, write_busy:%d\n", atomic_read(&dev->write_busy));
- ret = wait_event_interruptible(dev->write_wq, dev->error || !atomic_read(&g_adb_dev.inst_cnt) || (!atomic_read(&dev->write_busy)));
+ ret = wait_event_freezable(dev->write_wq, dev->error || !atomic_read(&g_adb_dev.inst_cnt) || (!atomic_read(&dev->write_busy)));
if (ret < 0) {
break;
}
@@ -561,8 +566,7 @@
}
if(atomic_read(&g_adb_dev.adb_dev->read_excl)){
printk("adb_release, disable and reenable endpoint");
-
-
+ adb_unlock(&g_adb_dev.adb_dev->read_excl);
}
#endif
exit :
@@ -621,7 +625,25 @@
.name = adb_shortname,
.fops = &adb_fops,
};
-
+void adb_schedule_inform_work(int inform_type)
+{
+ if(inform_type == USB_RPMSG_NOTIFY_ADB_ONLINE){
+ //schedule_work(&g_adb_dev.adb_dev->offline_inform_work);
+ if(atomic_read(&g_adb_dev.adb_dev->open_excl) == 0){
+ printk("schedule_inform_work send online\n");
+ schedule_work(&g_adb_dev.adb_dev->online_inform_work);
+ }else
+ printk("schedule_inform_work already online\n");
+
+ return;
+ }
+ printk("schedule_inform_work notify adb offline\n");
+ g_adb_dev.adb_dev->rx_done = 1;
+ g_adb_dev.adb_dev->online = 0;
+ wake_up(&g_adb_dev.adb_dev->read_wq);
+ schedule_work(&g_adb_dev.adb_dev->offline_inform_work);
+}
+EXPORT_SYMBOL_GPL(adb_schedule_inform_work);
static int adb_setup(void)
{
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_netlink.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_netlink.c
index d5eb6d8..f6fbd5c 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_netlink.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_netlink.c
@@ -36,6 +36,12 @@
unsigned int usb_gpio_detect_enable = 0;
unsigned int multi_packet_num = 10;
+
+//1:cap use adb,2:AP use adb
+#define ADB_SWITCH_TO_CAP 0x1
+#define ADB_SWITCH_TO_AP 0x2
+
+unsigned int adb_state = 2;
unsigned int ether_skb_num = 32;
unsigned int usb_speed_type = 0;
@@ -46,6 +52,9 @@
#define USB_SPEED_TYPE "usb_speed"
+#define USB_SWITCH_MODE "switch_mode"
+#define USB_DL_OPEN "dl_open"
+
#define NET_NAME "netname"
#define USB_SIMULATE_PLUG_TYPE "usb_simulate_plug"
@@ -59,6 +68,7 @@
#define USB_ECM_SLEEP_ENABLE "ecm_sleep"
#define USB_RNDIS_PACKET_NUM "pktNum"
+#define USB_ADB_SWITCH "adb_switch"
@@ -130,6 +140,27 @@
.mode = S_IRUGO|S_IWUSR,
};
+static struct attribute usb_adb_switch_attr =
+{
+ .name = "adb_switch",
+ .mode = S_IRUGO|S_IWUSR,
+};
+
+
+
+static struct attribute usb_switch_mode_attr =
+{
+ .name = "switch_mode",
+ .mode = S_IRUGO|S_IWUSR,
+};
+
+
+static struct attribute usb_dl_open_attr =
+{
+ .name = "dl_open",
+ .mode = S_IRUGO|S_IWUSR,
+};
+
static struct attribute *usb_status_attrs[] =
{
&usbstate_attr,
@@ -140,6 +171,9 @@
&force_net_attr,
&set_panic_attr,
&usb_rndis_packet_num_attr,
+ &usb_adb_switch_attr,
+ &usb_switch_mode_attr,
+ &usb_dl_open_attr,
NULL,
};
@@ -165,7 +199,11 @@
EXPORT_SYMBOL_GPL(get_panic_flag);
-
+void usb_netlink_notify(void)
+{
+
+}
+EXPORT_SYMBOL_GPL(usb_netlink_notify);
void usb_netlink_wakup(void)
{
@@ -230,6 +268,20 @@
}
sprintf(buf, "%s\n",usb_get_resp_data());
// sprintf(buf, "%u\n",usb_speed_type);
+ }else if(!strcmp(attr->name, USB_SWITCH_MODE)){
+ usb_rpmsg_config_cmd(USB_RPMSG_GET_USB_ENUM_MODE, NULL, 0);
+ usb_schedule_work();
+ ret = wait_event_interruptible(usb_netlink_wq, atomic_read(&resp_done));
+ if (ret < 0 ) {
+ sprintf(buf, "%s\n", "got fail \n");
+ goto done;
+ }
+ if(usb_get_resp_type() != USB_RPMSG_GET_USB_ENUM_MODE){
+ printk("usb_netlink invalid resp type\n");
+ sprintf(buf, "%s\n", "got fail \n");
+ goto done;
+ }
+ sprintf(buf, "%s\n",usb_get_resp_data());
}else if(!strcmp(attr->name, RAMDUMP_FLAG)){
sprintf(buf, "%d\n",ramdump_flag);
}else if(!strcmp(attr->name, HOT_PLUG)){
@@ -242,6 +294,9 @@
// sprintf(buf, "%u",generic_usb_get_sleep_range());
}else if(!strcmp(attr->name, USB_RNDIS_PACKET_NUM)){
sprintf(buf, "%u\n",multi_packet_num);
+ }else if(!strcmp(attr->name, USB_ADB_SWITCH)){
+ sprintf(buf, "%u,%s\n",adb_state, (adb_state==1 ? "CAP adb": "AP adb"));
+ return strlen(buf);
}
done:
atomic_set(&resp_done,0);
@@ -267,11 +322,24 @@
// usb_ramdump_config();
}else if(!strcmp(attr->name,FORCE_NET)){
force_net =value;
+ if(force_net == 0){
+ //rndis
+ usb_rpmsg_config_cmd(USB_RPMSG_FORCE_RNDIS, NULL, 0);
+ }else{
+ //ecm
+ usb_rpmsg_config_cmd(USB_RPMSG_FORCE_ECM, NULL, 0);
+ }
+ usb_schedule_work();
}else if(!strcmp(attr->name,SET_PANIC)){
set_panic =value;
}else if(!strcmp(attr->name,USB_ECM_SLEEP_ENABLE)){
//usb_ecm_sleep_en =value;
//generic_usb_set_sleep_range(value);
+ }else if(!strcmp(attr->name,USB_SIMULATE_PLUG_TYPE)){
+ printk("send USB_RPMSG_SIMULATE_PLUG\n");
+ usb_rpmsg_config_cmd(USB_RPMSG_SIMULATE_PLUG, NULL, 0);
+ usb_schedule_work();
+
}else if(!strcmp(attr->name, USB_RNDIS_PACKET_NUM)){
if(value >10 || value <1)
{
@@ -281,7 +349,61 @@
{
multi_packet_num = value ;
}
- }
+
+ }else if(!strcmp(attr->name,USB_ADB_SWITCH)){
+ //usb_ecm_sleep_en =value;
+ //generic_usb_set_sleep_range(value);
+ if((value != ADB_SWITCH_TO_AP) && (value != ADB_SWITCH_TO_CAP)){
+ printk("[%s-%d],parame error:%d\n",__func__,__LINE__,value);
+ }
+ if(adb_state == value){
+ printk("[%s-%d], already state:%d, don;t change again\n",__func__,__LINE__,value);
+ return size;
+ }
+ adb_state = value;
+
+ if(adb_state == ADB_SWITCH_TO_AP)
+ usb_rpmsg_config_cmd(USB_RPMSG_NOTIFY_ADB_TO_AP, NULL, 0);
+ else
+ usb_rpmsg_config_cmd(USB_RPMSG_NOTIFY_ADB_TO_CAP, NULL, 0);
+
+ usb_schedule_work();
+ }else if(!strcmp(attr->name, USB_SWITCH_MODE)){
+ switch(value){
+ case USB_MODE_DEBUG:
+ usb_rpmsg_config_cmd(USB_RPMSG_SWITCH_DEBUG_MODE, NULL, 0);
+
+ break;
+ case USB_MODE_USER:
+ usb_rpmsg_config_cmd(USB_RPMSG_SWITCH_USER_MODE, NULL, 0);
+
+ break;
+ case USB_MODE_FACTORY:
+ usb_rpmsg_config_cmd(USB_RPMSG_SWITCH_FACTORY_MODE, NULL, 0);
+
+ break;
+ case USB_MODE_AMT:
+ usb_rpmsg_config_cmd(USB_RPMSG_SWITCH_AMT_MODE, NULL, 0);
+
+ break;
+ case USB_MODE_EYE_DIAGRAM:
+ usb_rpmsg_config_cmd(USB_RPMSG_SWITCH_EYE_MODE, NULL, 0);
+
+ break;
+ default :
+ printk("%d, invalid mode type\n", value);
+
+ break;
+ }
+
+ usb_schedule_work();
+ }if(!strcmp(attr->name,USB_DL_OPEN)){
+ usb_rpmsg_config_cmd(((value != 0) ? USB_RPMSG_OPEN_DL : USB_RPMSG_CLOSE_DL), NULL, 0);
+
+ usb_schedule_work();
+ }
+
+
return size;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_rpmsg_client.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_rpmsg_client.c
index 9ddc99c..c8fde7a 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_rpmsg_client.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_rpmsg_client.c
@@ -35,7 +35,6 @@
/* number of tx requests to allocate */
#define TX_REQ_MAX 4
-static const char adb_shortname[] = "android_adb";
struct work_struct rpmsg_work;
atomic_t write_busy;
@@ -50,6 +49,7 @@
extern void usb_netlink_wakup(void);
+extern void adb_schedule_inform_work(int inform_type);
@@ -59,6 +59,17 @@
}
EXPORT_SYMBOL_GPL(usb_schedule_work);
+
+void usb_adb_switch(int switch_type)
+{
+ //printk("[ %s-%d]:inst_cnt= %d\n",__func__, __LINE__);
+
+
+
+}
+EXPORT_SYMBOL_GPL(usb_adb_switch);
+
+
e_usb_rpmsg_cmd_type usb_get_resp_type(void)
{
usb_rpmsg_cmd *resp = (usb_rpmsg_cmd *)usb_msg;
@@ -82,20 +93,40 @@
}
EXPORT_SYMBOL_GPL(usb_clean_mem);
+void usb_parse_notify_msg(e_usb_rpmsg_cmd_type msg_type)
+{
+ //usb_rpmsg_cmd *msg = (usb_rpmsg_cmd *)usb_msg;
+ if(msg_type >= USB_RPMSG_NOTIFY_MAX)
+ return;
+
+ switch(msg_type){
+ case USB_RPMSG_NOTIFY_NET_ONLINE:
+ case USB_RPMSG_NOTIFY_NET_OFFLINE:
+
+ break;
+ case USB_RPMSG_NOTIFY_ADB_ONLINE:
+ case USB_RPMSG_NOTIFY_ADB_OFFLINE:
+ adb_schedule_inform_work(msg_type);
+ break;
+#if 0
+ case:
+ break;
+ case:
+ break;
+#endif
+ default:
+ break;
+ }
+
+
+
+}
void usb_recv_from_ps(void *buf, unsigned int len)
{
int i, tmp;
char *data = (char *)buf;
- if (len==0){
- //printk("adb_recv_from_ps,len 0 means notify\n");
- atomic_set(&write_busy, 0);
- wake_up(&usb_write_wq);
-
- return ;
- }
-
//printk("\nusb_recv_from_ps, len = %d \n\n ", len);
memcpy(usb_msg, (char *)buf, len);
@@ -109,7 +140,19 @@
printk("\n");
}
printk("usb_recv_from_ps end\n");
-#endif
+#endif
+#if 1
+ usb_rpmsg_cmd *msg = (usb_rpmsg_cmd *)usb_msg;
+ if (msg->cmd > USB_RPMSG_CMD_MAX){//no param
+ //printk("adb_recv_from_ps,len 0 means notify\n");
+ //atomic_set(&write_busy, 0);
+ //wake_up(&usb_write_wq);
+ usb_parse_notify_msg(msg->cmd);
+ return ;
+ }
+
+#endif
+
usb_netlink_wakup();
}
@@ -121,7 +164,7 @@
char *tmp_buf = (char *)buf;
T_RpMsg_Msg rpmsg_tx;
-
+ memset(&rpmsg_tx, 0, sizeof(T_RpMsg_Msg));
rpmsg_tx.coreID = CORE_PS0;
rpmsg_tx.chID = USB_RPMSG_CH;
rpmsg_tx.flag |= RPMSG_WRITE_INT;
@@ -173,7 +216,7 @@
usb_rpmsg_cmd *send_cmd = (usb_rpmsg_cmd *)usb_cmd;
send_cmd->cmd = cmd;
if(len){
- sprintf(send_cmd->param, "%s\n", param, len);
+ sprintf(send_cmd->param, "%s\n", param);
}
}
@@ -189,6 +232,7 @@
T_RpMsg_Msg rpmsg_tx;
+ memset(&rpmsg_tx, 0, sizeof(T_RpMsg_Msg));
rpmsg_tx.coreID = CORE_PS0;
rpmsg_tx.chID = USB_RPMSG_CH;
rpmsg_tx.flag |= RPMSG_WRITE_INT;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/android_notify.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/android_notify.h
index 70b1d92..09a05ef 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/android_notify.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/android_notify.h
@@ -20,6 +20,8 @@
#define USB_RPMSG_TYPE_QUERY 0x2
+#define USB_RPMSG_TYPE_NOTIFY 0x3
+
typedef enum{
USB_CDROM_OBJECT = 0,
USB_DEVICE_PLUGIN,
@@ -47,14 +49,42 @@
//#ifdef _USE_VEHICLE_DC
-
+
+
+typedef enum{
+ USB_MODE_DEBUG = 0,
+ USB_MODE_USER,
+ USB_MODE_FACTORY,
+ USB_MODE_AMT,
+ USB_MODE_EYE_DIAGRAM,
+ USB_MODE_MAX_CONFIG_NUM,
+}e_usb_modeType;
+
typedef enum __usb_rpmsg_cmd_type{
USB_RPMSG_CMD = 0,
USB_RPMSG_GET_NET_TYPE = USB_RPMSG_CMD,
USB_RPMSG_GET_USB_SPEED,
USB_RPMSG_GET_USB_STATE,
- USB_RPMSG_GET_USB_LINK_STATE,
+ USB_RPMSG_GET_USB_LINK_STATE,
+ USB_RPMSG_GET_USB_ENUM_MODE,
USB_RPMSG_CMD_MAX,
+ USB_RPMSG_NOTIFY_ADB_TO_AP,
+ USB_RPMSG_NOTIFY_ADB_TO_CAP,
+ USB_RPMSG_NOTIFY_NET_ONLINE,
+ USB_RPMSG_NOTIFY_NET_OFFLINE,
+ USB_RPMSG_NOTIFY_ADB_ONLINE,
+ USB_RPMSG_NOTIFY_ADB_OFFLINE,
+ USB_RPMSG_SWITCH_DEBUG_MODE,
+ USB_RPMSG_SWITCH_USER_MODE,
+ USB_RPMSG_SWITCH_FACTORY_MODE,
+ USB_RPMSG_SWITCH_AMT_MODE,
+ USB_RPMSG_SWITCH_EYE_MODE,
+ USB_RPMSG_FORCE_RNDIS,
+ USB_RPMSG_FORCE_ECM,
+ USB_RPMSG_OPEN_DL,
+ USB_RPMSG_CLOSE_DL,
+ USB_RPMSG_SIMULATE_PLUG,
+ USB_RPMSG_NOTIFY_MAX,
}e_usb_rpmsg_cmd_type;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/mfd/zx234290.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/mfd/zx234290.h
index 29f48fc..79333cc 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/mfd/zx234290.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/mfd/zx234290.h
@@ -1063,6 +1063,10 @@
int zDrvPmic_GetNormal_Voltage(T_ZDrvPmic_Regulator regulator, int* voltage);
+/*adc fun*/
+uint get_battery_voltage(void);
+uint get_adc1_voltage(void);
+uint get_adc2_voltage(void);
#endif /* __LINUX_MFD_TPS65912_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/soc/sc/common.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/soc/sc/common.h
index 8338b46..f4f8288 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/soc/sc/common.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/soc/sc/common.h
@@ -94,6 +94,9 @@
void pm_set_sleeptime(u64 sleep_time);
int pm_get_lpmode(void);
bool pm_disable_suspend(void);
+void zx_enter_suspend(void);
+void zx_exit_suspend(void);
+bool zx_suspend_query(void);
/* *INDENT-OFF* */
#ifdef __cplusplus
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/spi/spi.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/spi/spi.h
index e1d8863..9a7620e 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/spi/spi.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/spi/spi.h
@@ -205,6 +205,10 @@
* - chipselect delays
* - ...
*/
+ u16 error;
+ u8 dma_used;
+ u8 trans_gaped;
+ u8 trans_gap_num;
};
static inline struct spi_device *to_spi_device(struct device *dev)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/uapi/linux/sockios.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/uapi/linux/sockios.h
index 9b6a817..2613112 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/uapi/linux/sockios.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/uapi/linux/sockios.h
@@ -167,7 +167,8 @@
#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */
#define SIOCVLAN SIOCDEVPRIVATE+0x0
-
+#define SIOCENABLEPHY SIOCDEVPRIVATE+0x1
+#define SIOCDISABLEPHY SIOCDEVPRIVATE+0x2
/*
* These 16 ioctl calls are protocol private
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/Makefile b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/Makefile
index 9b09372..84b5cc7 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/Makefile
@@ -102,6 +102,7 @@
obj-$(CONFIG_TRACE_CLOCK) += trace/
obj-$(CONFIG_RING_BUFFER) += trace/
obj-$(CONFIG_TRACEPOINTS) += trace/
+obj-y += tracker.o
obj-$(CONFIG_IRQ_WORK) += irq_work.o
obj-$(CONFIG_CPU_PM) += cpu_pm.o
obj-$(CONFIG_BPF) += bpf/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/exit.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/exit.c
index ab900b6..28e43a4 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/exit.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/exit.c
@@ -69,6 +69,8 @@
#include <asm/unistd.h>
#include <asm/mmu_context.h>
+extern bool is_registered_task(const char *tsk_name, u32 *index);
+
static void __unhash_process(struct task_struct *p, bool group_dead)
{
nr_threads--;
@@ -904,6 +906,11 @@
}
spin_unlock_irq(&sighand->siglock);
}
+#ifdef CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK
+ if (exit_code != SIGTERM && is_registered_task(current->comm, NULL)) {
+ panic("do exit:exit task!\n");
+ }
+#endif /* CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK*/
do_exit(exit_code);
/* NOTREACHED */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/irq/irqdesc.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/irq/irqdesc.c
index ca36c61..6730034 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/irq/irqdesc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/irq/irqdesc.c
@@ -23,6 +23,8 @@
* lockdep: we want to handle all irq_desc locks as a single lock-class:
*/
static struct lock_class_key irq_desc_lock_class;
+extern void zxic_trace_irq_enter(u32 irq);
+extern void zxic_trace_irq_exit(u32 irq);
#if defined(CONFIG_SMP)
static int __init irq_affinity_setup(char *str)
@@ -686,7 +688,9 @@
ack_bad_irq(irq);
ret = -EINVAL;
} else {
+ zxic_trace_irq_enter(irq);
generic_handle_irq(irq);
+ zxic_trace_irq_exit(irq);
}
irq_exit();
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/power/suspend.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/power/suspend.c
index 3346971..417ce2c 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/power/suspend.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/power/suspend.c
@@ -614,6 +614,8 @@
#endif
pr_info("suspend entry (%s)\n", mem_sleep_labels[state]);
+ zx_enter_suspend();
+
start = ktime_get_boottime();
error = enter_state(state);
if (error) {
@@ -622,12 +624,15 @@
} else {
suspend_stats.success++;
}
+
elapsed_msecs = ktime_to_ms(ktime_sub(ktime_get_boottime(), start));
if (!error) {
pm_set_sleeptime(elapsed_msecs);
pm_notify_wake_event();
}
+
+ zx_exit_suspend();
pr_info("suspend exit\n");
return error;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/Makefile b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/Makefile
index 04163d5..61af1ee 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/Makefile
@@ -4,9 +4,8 @@
ifeq ($(CONFIG_MMU),y)
ccflags-y += -D__USE_MMU__
endif
-
ccflags-y += -D_OS_LINUX
-obj-$(CONFIG_RAMDUMP) += ramdump_client_cap.o
-obj-$(CONFIG_RAMDUMP) += ramdump_linux.o
-obj-$(CONFIG_RAMDUMP) += ramdump_v7.o
-obj-$(CONFIG_RAMDUMP) += ramdump_v7_asm.o
\ No newline at end of file
+obj-y += ramdump_linux.o ramdump_v7.o ramdump_v7_asm.o ramdump_device_trans.o ramdump_client_cap.o
+ifeq ($(CONFIG_RAMDUMP_EMMC),y)
+obj-y += ramdump_emmc.o ramdump_emmc_driver.o
+endif
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump.h
index e2eadef..fed489d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump.h
@@ -57,6 +57,8 @@
#define ramdump_spin_lock_irq(lock, flags) spin_lock_irqsave(lock, flags);
#define ramdump_spin_unlock_irq(lock, flags) spin_unlock_irqrestore(lock, flags);
+#define RAMDUMP_FILE_NUM_MAX (64)
+
/*******************************************************************************
* Êý¾ÝÀàÐͶ¨Òå *
*******************************************************************************/
@@ -115,6 +117,29 @@
} msg_data_t;
} ramdump_msg_t;
+typedef struct
+{
+ volatile unsigned int core_flag;//0:cp,1:cap
+ volatile unsigned int rw_flag;//0:non,1:w,2:r
+ volatile unsigned int size;
+ char buf[];
+} ramdump_shmem_t;
+
+typedef struct
+{
+ unsigned int magic;
+ char file_name[RAMDUMP_RAMCONF_FILENAME_MAXLEN];
+ unsigned int offset;
+ unsigned int size;
+}ramdump_device_t;
+
+typedef struct
+{
+ unsigned int magic;
+ unsigned int file_num;
+ ramdump_device_t file_fp[RAMDUMP_FILE_NUM_MAX];
+}ramdump_file_t;
+
/*******************************************************************************
* È«¾Ö±äÁ¿ÉùÃ÷ *
*******************************************************************************/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_client_cap.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_client_cap.c
index 12d58cf..904a832 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_client_cap.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_client_cap.c
@@ -41,6 +41,10 @@
*******************************************************************************/
extern void ramdump_register_callbacks(void);
extern unsigned char *ramdump_phy_to_vir(unsigned long phy, unsigned long size);
+extern void ramdump_shared_mem_init(void);
+extern void ramdump_data_transfer_to_device(void);
+extern void ramdump_oss_data_trans_init(void);
+extern unsigned char *ramdump_emmc_flag_base;
/*******************************************************************************
* ¾Ö²¿¾²Ì¬±äÁ¿¶¨Òå *
@@ -49,6 +53,7 @@
#define RAMDUMP_CAP_CMM_BUF_LEN_REAL ((3 * 1024UL)>>CPU_SHIFT)
#define RAMDUMP_CAP_LOG_BUF_ADDR (RAMDUMP_CAP_CMM_BUF_ADDR + RAMDUMP_CAP_CMM_BUF_LEN_REAL)
#define RAMDUMP_CAP_LOG_BUF_LEN ((1 * 1024UL)>>CPU_SHIFT)
+#define RAMDUMP_EMMC_TRANS_FLAG_ADDR (IRAM_BASE_ADDR_ZCAT_MODE)
/*******************************************************************************
* È«¾Ö±äÁ¿¶¨Òå *
@@ -59,7 +64,6 @@
int sysctl_ramdump_on_panic = RAMDUMP_ON_DEFAULT_VAL;
int ramdump_cap_init_flag = -1;
int ramdump_count = 0;
-int ramdump_file_num = 0;
int ramdump_server_exp_core = RAMDUMP_FALSE;
#ifdef CONFIG_RAMDUMP_USER
unsigned int sysctl_ramdump_on_user = 1;
@@ -94,7 +98,6 @@
{ }
};
-//extern unsigned char *ramdump_shared_mem_addr;
/*******************************************************************************
* ¾Ö²¿º¯ÊýʵÏÖ *
*******************************************************************************/
@@ -233,20 +236,20 @@
mem,
"data.load.binary &ramdump_dir\\%s A:0x%x--A:0x%x /noclear\n",
"cap_ddr.bin",
- (unsigned long)DDR_BASE_CAP_ADDR_PA,
+ (unsigned int)DDR_BASE_CAP_ADDR_PA,
(unsigned int)(DDR_BASE_CAP_ADDR_PA + DDR_BASE_LEN_CAP));
mem += sprintf(
mem,
"data.load.binary &ramdump_dir\\%s A:0x%x--A:0x%x /noclear\n",
"cap.cmm",
- (unsigned long)RAMDUMP_CAP_CMM_BUF_ADDR,
- (unsigned long)(RAMDUMP_CAP_CMM_BUF_ADDR + RAMDUMP_CAP_CMM_BUF_LEN_REAL - 1));
+ (unsigned int)RAMDUMP_CAP_CMM_BUF_ADDR,
+ (unsigned int)(RAMDUMP_CAP_CMM_BUF_ADDR + RAMDUMP_CAP_CMM_BUF_LEN_REAL - 1));
mem += sprintf(
mem,
"data.load.binary &ramdump_dir\\%s A:0x%x--A:0x%x /noclear\n",
"cap_err_log.txt",
- (unsigned long)RAMDUMP_CAP_LOG_BUF_ADDR,
- (unsigned long)(RAMDUMP_CAP_LOG_BUF_ADDR + RAMDUMP_CAP_LOG_BUF_LEN - 1));
+ (unsigned int)RAMDUMP_CAP_LOG_BUF_ADDR,
+ (unsigned int)(RAMDUMP_CAP_LOG_BUF_ADDR + RAMDUMP_CAP_LOG_BUF_LEN - 1));
return mem;
}
/*******************************************************************************
@@ -337,10 +340,6 @@
}
-//void ramdump_shared_mem_init(void)
-//{
-// ramdump_shared_mem_addr = ramdump_phy_to_vir(RAMDUMP_SHARED_MEM_ADDR, RAMDUMP_SHARED_MEM_LEN)
-//}
/*******************************************************************************
* ¹¦ÄÜÃèÊö: ramdump_init
* ²ÎÊý˵Ã÷:
@@ -367,7 +366,8 @@
register_sysctl_table(sysctl_ramdump_table);
-// ramdump_shared_mem_init();
+ ramdump_shared_mem_init();
+ ramdump_oss_data_trans_init();
ramdump_printf("Ramdump cap init success!\n");
ramdump_cap_init_flag = RAMDUMP_TRUE;
@@ -412,9 +412,11 @@
/* notify client ramdump */
ramdump_notify_server_panic();
+
ramdump_arch_clean_caches();
-// ramdump_data_transfer_to_emmc();
+ if(*(unsigned int *)ramdump_emmc_flag_base == 1)
+ ramdump_data_transfer_to_device();
while(true)
;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_device_trans.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_device_trans.c
new file mode 100755
index 0000000..0c1d8b6
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_device_trans.c
@@ -0,0 +1,517 @@
+/**
+ * @file oss_ramdump_osa.c
+ * @brief Implementation of Ramdump os adapt
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author Qing Wang <wang.qing@sanechips.com.cn>
+ * @ingroup si_ap_oss_ramdump_id
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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.
+ *
+ */
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "ramdump.h"
+#include "ram_config.h"
+
+#ifdef CONFIG_RAMDUMP_EMMC
+#include "ramdump_emmc.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+* Extern function declarations *
+*******************************************************************************/
+extern unsigned char *ramdump_phy_to_vir(unsigned long phy, unsigned long size);
+
+/*******************************************************************************
+* Extern variable declarations *
+*******************************************************************************/
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+/*Ö¸ÁîÖ¡³¤¶È */
+#define RAMDUMP_INTERACTIVE_DATA_LEN 40
+#define RAMDUMP_INTERACTIVE_ARRAY_LEN 10
+
+/*¹²ÏíÄÚ´æµØÖ·*/
+#define RAMDUMP_SHARED_MEM_BASE (RAMDUMP_AP_TO_CAP_BUF_ADDR_PA)
+#define RAMDUMP_SHARED_MEM_LEN (RAMDUMP_AP_TO_CAP_BUF_LEN)
+
+/* ramdump ºÍ ¹²ÏíÄÚ´æ½»»¥ÃüÁîÔ¼¶¨ */
+/*ͬ²½ÇëÇó*/
+#define RAMDUMP_PC_INTERACTIVE_REQ 1
+/*ͬ²½ÇëÇóÓ¦´ð,´«ÊäramdumpµÄÎļþÊýÄ¿*/
+#define RAMDUMP_TRANS_SERVER_INTERACTIVE_RSP 2
+/*ÇëÇó´«µÝÖ¸¶¨Îļþ±àºÅµÄÎļþÐÅÏ¢*/
+#define RAMDUMP_PC_FILE_INFO_READ_REQ 3
+/*ÇëÇó´«µÝÖ¸¶¨Îļþ±àºÅµÄÎļþÐÅÏ¢µÄÓ¦´ð£¬´«ÊäÎļþÃû¼°´óС*/
+#define RAMDUMP_TRANS_SERVER_FILE_INFO_READ_RSP 4
+/*ÇëÇó¶Áȡָ¶¨Îļþ±àºÅµÄÎļþÄÚÈÝ*/
+#define RAMDUMP_PC_FILE_DATA_TRANS_REQ 5
+/*ÇëÇó¶Áȡָ¶¨Îļþ±àºÅµÄÎļþÄÚÈݵÄÓ¦´ð£¬´«ÊäÎļþÄÚÈÝ*/
+#define RAMDUMP_TRANS_SERVER_FILE_DATA_TRANS_RSP 6
+/*´«Êä½áÊø*/
+#define RAMDUMP_PC_FILE_TRANS_DONE_REQ 7
+/*´«Êä½áÊøÓ¦´ð*/
+#define RAMDUMP_TRANS_SERVER_FILE_TRANS_DONE_RSP 8
+
+/* ´íÎóÀàÐÍ */
+/*Ö¸Áî´íÎó*/
+#define RAMDUMP_INTERACTIVE_CMD_ERROR 9
+/*ÇëÇó´«µÝÖ¸¶¨Îļþ±àºÅ´í*/
+#define RAMDUMP_FILE_NUMBER_ERROR 10
+/*ÇëÇó´«µÝÖ¸¶¨ÎļþλÖôóС´í*/
+#define RAMDUMP_FILE_SIZE_ERROR 11
+
+#define RAMDUMP_DELAY_MS_COUNT (2500)
+
+#define RAMDUMP_SHMEM_ALIGN_SIZE (0x1000)
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+/*
+ * struct TRANS WITH AP
+ */
+
+/* trans_server rsp pc, interactive msg struct */
+typedef struct
+{
+ unsigned int cmd;
+ unsigned int file_num;
+} ramdump_trans_server_interactive_req;
+
+/* trans_server rsp pc, file info msg struct */
+typedef struct
+{
+ unsigned int cmd;
+ char file_name[RAMDUMP_RAMCONF_FILENAME_MAXLEN];
+ unsigned int file_size;
+} ramdump_trans_server_file_info_req;
+
+/* pc req trans_server, file info msg struct */
+typedef struct
+{
+ unsigned int cmd;
+ unsigned int file_id;
+} ramdump_pc_file_info_rsp;
+
+/* trans_server rsp pc, trans data msg struct */
+typedef struct
+{
+ unsigned int cmd;
+ unsigned int buf_addr;
+ unsigned int buf_left_size;
+} ramdump_trans_server_data_trans_req;
+
+/* pc req trans_server, trans data msg struct */
+typedef struct
+{
+ unsigned int cmd;
+ unsigned int file_id; /* Îļþ±àºÅ */
+ unsigned int offset; /* offsetΪÊý¾ÝÆ«ÒÆ */
+ unsigned int length; /* lengthΪÊý¾Ý³¤¶È */
+} ramdump_pc_trans_data_rsp;
+
+/*******************************************************************************
+ * Local function declarations *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Local variable definitions *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Global variable definitions *
+ ******************************************************************************/
+unsigned char *ramdump_shared_mem_base = NULL;
+unsigned char *ramdump_emmc_flag_base = NULL;
+int ramdump_file_num = 0;
+ramdump_file_t ramdump_device_fp = {0};
+unsigned int ramdump_device_file_cnt = 0;
+
+/*******************************************************************************
+ * Inline function implementations *
+ ******************************************************************************/
+static inline void ramdump_wait_delay( unsigned long ms)
+{
+ volatile int j = 0;
+ for (j = 0; j < 10000; j++);
+}
+/*******************************************************************************
+ * extern function implementations *
+ ******************************************************************************/
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_oss_data_trans_write
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for ramdump to trans dump data to PC
+*******************************************************************************/
+int ramdump_oss_data_trans_write(unsigned char *buffer, unsigned int size)
+{
+ int ret;
+ ramdump_shmem_t *msg = (ramdump_shmem_t *)ramdump_shared_mem_base;
+
+ if (size > (RAMDUMP_SHARED_MEM_LEN- roundup(sizeof(ramdump_shmem_t), RAMDUMP_SHMEM_ALIGN_SIZE)));
+ ret = -1;
+
+ while(1){
+ if ((msg->core_flag == 1) && (msg->rw_flag == 1)){
+ memcpy(msg->buf, buffer, size);
+ msg->size = size;
+ msg->core_flag = 0;
+ msg->rw_flag = 2;
+ ret = size;
+ break;
+ }
+ else
+ ramdump_wait_delay(0);
+ }
+ return ret;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_oss_data_trans_read
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for ramdump to trans dump data to PC
+*******************************************************************************/
+int ramdump_oss_data_trans_read(unsigned char *buffer, unsigned int size)
+{
+ int ret;
+ ramdump_shmem_t *msg = (ramdump_shmem_t *)ramdump_shared_mem_base;
+
+ if (size > (RAMDUMP_SHARED_MEM_LEN - roundup(sizeof(ramdump_shmem_t), RAMDUMP_SHMEM_ALIGN_SIZE)))
+ ret = -1;
+
+ while(1){
+ if ((msg->core_flag == 1) && (msg->rw_flag == 2)){
+ if (size < msg->size)
+ return -1;
+ memcpy(buffer, msg->buf, msg->size);
+ msg->size = size;
+ msg->core_flag = 1;
+ msg->rw_flag = 1;
+ ret = size;
+ break;
+ }
+ else
+ ramdump_wait_delay(0);
+ }
+ return ret;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_oss_data_trans_init
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for map ramdump_shared_mem_base
+*******************************************************************************/
+void ramdump_oss_data_trans_init(void)
+{
+ ramdump_shmem_t *msg = (ramdump_shmem_t *)ramdump_shared_mem_base;
+
+ memset(msg, 0, sizeof(ramdump_shmem_t));
+ msg->core_flag = 1;
+ msg->rw_flag = 1;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_device_init
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for init fp head
+*******************************************************************************/
+int ramdump_device_init(ramdump_file_t *fp)
+{
+ int ret = -1;
+#ifdef CONFIG_RAMDUMP_EMMC
+ ret = ramdump_emmc_init(fp);
+ return ret;
+#else
+ return 0;
+#endif
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_device_close
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for print close msg
+*******************************************************************************/
+void ramdump_device_close(void)
+{
+#ifdef CONFIG_RAMDUMP_EMMC
+ ramdump_emmc_close();
+#endif
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_device_write_file
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for write file infomation
+*******************************************************************************/
+int ramdump_device_write_file(ramdump_trans_server_file_info_req *server_to_cap, ramdump_file_t *fp)
+{
+ int ret = -1;
+#ifdef CONFIG_RAMDUMP_EMMC
+ ret = ramdump_emmc_write_file(server_to_cap->file_name, server_to_cap->file_size, fp);
+ return ret;
+#else
+ return 0;
+#endif
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_device_write_file_head
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for write file head
+*******************************************************************************/
+int ramdump_device_write_file_head(ramdump_file_t *fp)
+{
+ int ret = -1;
+#ifdef CONFIG_RAMDUMP_EMMC
+ ret = ramdump_emmc_write_file_head(fp);
+ return ret;
+#else
+ return 0;
+#endif
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_device_write_logbuf
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for write cap logbuf
+*******************************************************************************/
+int ramdump_device_write_logbuf(ramdump_file_t *fp)
+{
+ int ret = -1;
+#ifdef CONFIG_RAMDUMP_EMMC
+
+ ramdump_emmc_write_logbuf(fp);
+ ramdump_printf("device memory trans file:cap_log_buf!!!\n");
+ return ret;
+#else
+ return 0;
+#endif
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_device_write_data
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for write data
+*******************************************************************************/
+int ramdump_device_write_data(ramdump_shmem_t *msg, ramdump_file_t *fp, unsigned int size)
+{
+ int ret = 0;
+#ifdef CONFIG_RAMDUMP_EMMC
+
+ ramdump_emmc_write_data(msg, fp, size);
+ return ret;
+#else
+ return 0;
+#endif
+}
+
+/*******************************************************************************
+ * Global function implementations *
+ ******************************************************************************/
+void ramdump_shared_mem_init(void)
+{
+ ramdump_shared_mem_base = ramdump_phy_to_vir((unsigned long)RAMDUMP_SHARED_MEM_BASE, (unsigned long)RAMDUMP_SHARED_MEM_LEN);
+ ramdump_emmc_flag_base = ramdump_phy_to_vir((unsigned long)IRAM_BASE_ADDR_ZCAT_MODE, sizeof(unsigned long));
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_data_transfer_to_device
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: This function is used for ramdump to trans dump data to ap
+*******************************************************************************/
+void ramdump_data_transfer_to_device(void)
+{
+ int data_trans_max;
+ int file_cnt = 0;
+ int file_size = 0;
+ int file_offset = 0;
+ int file_left_size = 0;
+ int file_trans_size = 0;
+ int error_cmd = 0;
+ int ret = 0;
+
+ unsigned int req_buf[RAMDUMP_INTERACTIVE_ARRAY_LEN] = {0};
+ ramdump_trans_server_interactive_req cap_to_server_msg = {0};
+
+ /* interactive begin */
+ if(ramdump_device_init(&ramdump_device_fp) < 0)
+ return;
+ data_trans_max = RAMDUMP_SHARED_MEM_LEN - roundup(sizeof(ramdump_shmem_t), RAMDUMP_SHMEM_ALIGN_SIZE);
+ cap_to_server_msg.cmd = RAMDUMP_PC_INTERACTIVE_REQ;
+ ramdump_oss_data_trans_write((unsigned char*)(&cap_to_server_msg), sizeof(cap_to_server_msg));
+
+ for(;;)
+ {
+ ramdump_oss_data_trans_read((unsigned char *)req_buf, RAMDUMP_INTERACTIVE_DATA_LEN);
+ switch (*(unsigned int *)req_buf)
+ {
+ case RAMDUMP_TRANS_SERVER_INTERACTIVE_RSP:
+ {
+ ramdump_pc_file_info_rsp cap_to_server_msg ={0};
+ ramdump_trans_server_interactive_req *server_to_cap_msg = (ramdump_trans_server_interactive_req *)req_buf;
+ /* data from server to cap */
+ ramdump_file_num = server_to_cap_msg->file_num;
+ ramdump_device_fp.file_num = ramdump_file_num;
+
+ /* data from cap to server */
+ cap_to_server_msg.cmd = RAMDUMP_PC_FILE_INFO_READ_REQ;
+ cap_to_server_msg.file_id = file_cnt;
+
+ ramdump_oss_data_trans_write(
+ (unsigned char*)(&cap_to_server_msg),
+ sizeof(cap_to_server_msg));
+
+ break;
+ }
+ case RAMDUMP_TRANS_SERVER_FILE_INFO_READ_RSP:
+ {
+ ramdump_pc_trans_data_rsp cap_to_server_msg = {0};
+ ramdump_trans_server_file_info_req *server_to_cap_msg = (ramdump_trans_server_file_info_req *)req_buf;
+ /* data from server to cap */
+ /*device memory file create*/
+ if(ramdump_device_write_file(server_to_cap_msg, &ramdump_device_fp) == -1){
+ cap_to_server_msg.cmd = RAMDUMP_PC_FILE_TRANS_DONE_REQ;
+ ramdump_device_write_file_head(&ramdump_device_fp);//±£Ö¤³ö´íǰ¼¸¸öÎļþ¾ùд¶Ô¡£
+ ramdump_printf("ramdump write emmc file error!\n");
+ }
+ file_size = server_to_cap_msg->file_size;
+ file_offset = 0;
+ file_left_size = file_size;
+ /* data from cap to server */
+ cap_to_server_msg.cmd = RAMDUMP_PC_FILE_DATA_TRANS_REQ;
+ cap_to_server_msg.file_id = file_cnt;
+ cap_to_server_msg.offset = file_offset;
+ if (file_size >= data_trans_max)
+ cap_to_server_msg.length = data_trans_max;
+ else
+ cap_to_server_msg.length = file_size;
+ file_trans_size = cap_to_server_msg.length;
+ file_left_size = file_left_size - cap_to_server_msg.length;
+ file_offset = file_offset + cap_to_server_msg.length;
+ printk("device memory trans file:%s!!!\n", server_to_cap_msg->file_name);
+
+ /* interactive data trans */
+ ramdump_oss_data_trans_write(
+ (unsigned char*)(&cap_to_server_msg),
+ sizeof(cap_to_server_msg));
+
+ break;
+ }
+ case RAMDUMP_TRANS_SERVER_FILE_DATA_TRANS_RSP:
+ {
+ ramdump_pc_trans_data_rsp cap_to_server_msg = {0};
+ /* data from server to cap */
+ ramdump_shmem_t *server_to_cap_msg = (ramdump_shmem_t *)ramdump_shared_mem_base;
+ server_to_cap_msg->core_flag = 0;
+ /*data from cap to emmc*/
+
+ if(ramdump_device_write_data(server_to_cap_msg, &ramdump_device_fp, file_trans_size) == -1)
+ {
+ ramdump_printf("ramdump write emmc data error!\n");
+ }
+ /*ÅжÏÊ£Óà´óС*/
+ if (file_left_size == 0)
+ {
+ file_cnt++;
+ if (file_cnt == ramdump_file_num)
+ {
+ cap_to_server_msg.cmd = RAMDUMP_PC_FILE_TRANS_DONE_REQ;
+ }
+ else
+ {
+ cap_to_server_msg.cmd = RAMDUMP_PC_FILE_INFO_READ_REQ;
+ cap_to_server_msg.file_id = file_cnt;
+ }
+ ramdump_device_file_cnt++;
+ }
+ else
+ {
+ /* data from cap to server */
+ if (file_left_size >= data_trans_max)
+ cap_to_server_msg.length = data_trans_max;
+ else
+ cap_to_server_msg.length = file_left_size;
+ cap_to_server_msg.cmd = RAMDUMP_PC_FILE_DATA_TRANS_REQ;
+ cap_to_server_msg.file_id = file_cnt;
+ cap_to_server_msg.offset = file_offset;
+ file_left_size = file_left_size - cap_to_server_msg.length;
+ file_offset= file_offset + cap_to_server_msg.length;
+ }
+
+ ramdump_oss_data_trans_write((unsigned char *)(&cap_to_server_msg), sizeof(cap_to_server_msg));
+ continue;
+ }
+ case RAMDUMP_TRANS_SERVER_FILE_TRANS_DONE_RSP:
+ {
+ ramdump_device_write_logbuf(&ramdump_device_fp);
+ ramdump_device_close();
+ return;
+ }
+ default:
+ {
+ error_cmd = RAMDUMP_INTERACTIVE_CMD_ERROR;
+ ramdump_printf("ramdump trans emmc error:%d!\n", error_cmd);
+ /* interactive data trans */
+ break;
+ }
+ }
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc.c
new file mode 100755
index 0000000..11e96d8
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc.c
@@ -0,0 +1,184 @@
+/**
+ * @file oss_ramdump_osa.c
+ * @brief Implementation of Ramdump os adapt
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author Qing Wang <wang.qing@sanechips.com.cn>
+ * @ingroup si_ap_oss_ramdump_id
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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.
+ *
+ */
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "ramdump.h"
+#include "ramdump_emmc.h"
+#include "ram_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+* Extern function declarations *
+*******************************************************************************/
+extern unsigned char *ramdump_phy_to_vir(unsigned long phy, unsigned long size);
+
+/*******************************************************************************
+* Extern variable declarations *
+*******************************************************************************/
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+#define RAMDUMP_DELAY_MS_COUNT (2500)
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Local function declarations *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Local variable definitions *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Global variable definitions *
+ ******************************************************************************/
+unsigned int ramdump_write_offset = 0;
+unsigned int ramdump_emmc_size = 0;
+unsigned int ramdump_emmc_offset = 0;
+extern unsigned int ramdump_device_file_cnt;
+char *ramdump_log_buf_region = NULL;
+unsigned int ramdump_log_buf_len = 0;
+
+/*******************************************************************************
+ * Inline function implementations *
+ ******************************************************************************/
+static inline void ramdump_wait_delay( unsigned long ms)
+{
+ volatile int j = 0;
+ for (j = 0; j < 10000; j++);
+}
+
+/*******************************************************************************
+ * Local function implementations *
+ ******************************************************************************/
+int ramdump_emmc_init(ramdump_file_t *fp)
+{
+ fp->magic = 0x2A2A2A2A;
+ ramdump_emmc_offset = roundup(sizeof(ramdump_file_t), RAMDUMP_MEMORY_ALIGN_SIZE);
+ ramdump_emmc_size = RAMDUMP_TRANS_EMMC_LEN - ramdump_emmc_offset;
+ if(mmc_ramdump_init()){
+ ramdump_printf("EMMC init failed! No ramdump data trans to emmc!\n");
+ return -1;
+ }
+ return 0;
+}
+
+int ramdump_emmc_write_file(char *file_name, unsigned int file_size, ramdump_file_t *fp)
+{
+ if (ramdump_device_file_cnt >= RAMDUMP_FILE_NUM_MAX)
+ return -1;
+ if (ramdump_emmc_offset >= RAMDUMP_TRANS_EMMC_LEN)
+ return -1;
+
+ fp->file_fp[ramdump_device_file_cnt].magic = 0x3A3A3A3A;
+ strncpy(fp->file_fp[ramdump_device_file_cnt].file_name, file_name, RAMDUMP_RAMCONF_FILENAME_MAXLEN - 1);
+ fp->file_fp[ramdump_device_file_cnt].offset = ramdump_emmc_offset;
+ fp->file_fp[ramdump_device_file_cnt].size = file_size;
+ ramdump_write_offset = fp->file_fp[ramdump_device_file_cnt].offset;
+ ramdump_emmc_offset = ramdump_emmc_offset + roundup(fp->file_fp[ramdump_device_file_cnt].size, RAMDUMP_MEMORY_ALIGN_SIZE);
+ return 0;
+}
+
+int ramdump_emmc_write_file_head(ramdump_file_t *fp)
+{
+ int ret = -1;
+ mmc_bwrite(RAMDUMP_EMMC_ADDR, roundup(sizeof(ramdump_file_t), RAMDUMP_MEMORY_ALIGN_SIZE), fp);
+ return ret;
+}
+
+int ramdump_emmc_write_data(ramdump_shmem_t *msg, ramdump_file_t *fp, unsigned int size)
+{
+ int ret = 0;
+ unsigned int buffer = RAMDUMP_EMMC_ADDR + ramdump_write_offset;
+
+ if (ramdump_device_file_cnt >= RAMDUMP_FILE_NUM_MAX)
+ return -1;
+
+ while(1){
+ if ((msg->core_flag == 1) && (msg->rw_flag == 2)){
+ if(fp->file_fp[ramdump_device_file_cnt].size > ramdump_emmc_size)
+ return -1;
+
+ if(size >= (ramdump_emmc_size - fp->file_fp[ramdump_device_file_cnt].offset))
+ return -1;
+ mmc_bwrite(buffer, size, msg->buf);
+ msg->size = size;
+ msg->core_flag = 1;
+ msg->rw_flag = 1;
+ ret = size;
+ ramdump_write_offset = ramdump_write_offset + roundup(size, RAMDUMP_MEMORY_ALIGN_SIZE);
+ break;
+ }
+ else
+ ramdump_wait_delay(0);
+ }
+
+ return ret;
+}
+
+int ramdump_emmc_write_logbuf(ramdump_file_t *fp)
+{
+ int ret = -1;
+
+ ramdump_log_buf_region = log_buf_addr_get();
+ ramdump_log_buf_len = log_buf_len_get();
+
+ fp->file_num += 1;
+ fp->file_fp[ramdump_device_file_cnt].magic = 0x3A3A3A3A;
+ strncpy(fp->file_fp[ramdump_device_file_cnt].file_name, "cap_log_buf.bin", RAMDUMP_RAMCONF_FILENAME_MAXLEN - 1);
+ fp->file_fp[ramdump_device_file_cnt].offset = ramdump_emmc_offset;
+ fp->file_fp[ramdump_device_file_cnt].size = ramdump_log_buf_len;
+ ret = mmc_bwrite(RAMDUMP_EMMC_ADDR + ramdump_emmc_offset, ramdump_log_buf_len, ramdump_log_buf_region);
+ ramdump_emmc_write_file_head(fp);
+ ramdump_emmc_offset = ramdump_emmc_offset + roundup(fp->file_fp[ramdump_device_file_cnt].size, RAMDUMP_MEMORY_ALIGN_SIZE);
+ ramdump_device_file_cnt += 1;
+
+ return ret;
+}
+
+int ramdump_emmc_read(char *buffer, ramdump_shmem_t *msg, unsigned int size)
+{
+ int ret = 0;
+
+ return ret;
+}
+
+void ramdump_emmc_close(void)
+{
+ ramdump_printf("ramdump trans emmc finished!\n");
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc.h
new file mode 100755
index 0000000..857b602
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* °æÈ¨ËùÓÐ (C)2016, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ: ramdump_emmc.h
+* Îļþ±êʶ: ramdump_emmc.h
+* ÄÚÈÝÕªÒª: ramdump emmcÍ·Îļþ
+* ʹÓ÷½·¨: #include "ramdump_emmc.h"
+*
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* ------------------------------------------------------------------------------
+* 2016/3/10 V1.0 Create ÕÔ¾ü¿ü ´´½¨
+*
+*******************************************************************************/
+
+#ifndef _RAMDUMP_EMMC_H
+#define _RAMDUMP_EMMC_H
+
+/*******************************************************************************
+* Í·Îļþ *
+*******************************************************************************/
+#include "ramdump.h"
+#include <linux/mmc/mmc_func.h>
+
+/*******************************************************************************
+* Íⲿº¯ÊýÉùÃ÷ *
+*******************************************************************************/
+
+/*******************************************************************************
+* ºê¶¨Òå *
+*******************************************************************************/
+#define RAMDUMP_EMMC_ADDR (CONFIG_RAMDUMP_EMMC_BASE)
+#define RAMDUMP_TRANS_EMMC_LEN (CONFIG_RAMDUMP_EMMC_SIZE)
+#define RAMDUMP_MEMORY_ALIGN_SIZE (512)
+
+/*******************************************************************************
+* Êý¾ÝÀàÐͶ¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* È«¾Ö±äÁ¿ÉùÃ÷ *
+*******************************************************************************/
+
+/*******************************************************************************
+* È«¾Öº¯ÊýÉùÃ÷ *
+*******************************************************************************/
+/**
+ * @brief ramdump_emmc_init .
+ *
+ * @param void.
+ *
+ * @return int.
+ * @retval standard error
+ * @note This function is used for ramdump init
+ */
+int ramdump_emmc_init(ramdump_file_t *fp);
+int ramdump_emmc_write_file(char *file_name, unsigned int file_size, ramdump_file_t *fp);
+int ramdump_emmc_write_file_head(ramdump_file_t *fp);
+int ramdump_emmc_write_data(ramdump_shmem_t *msg, ramdump_file_t *fp, unsigned int size);
+int ramdump_emmc_write_logbuf(ramdump_file_t *fp);
+void ramdump_emmc_close(void);
+
+/*******************************************************************************
+* ÄÚÁªº¯ÊýʵÏÖ *
+*******************************************************************************/
+
+#endif //#ifndef _RAMDUMP_EMMC_H
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc_driver.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc_driver.c
new file mode 100755
index 0000000..e446fe6
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/ramdump/ramdump_emmc_driver.c
@@ -0,0 +1,223 @@
+/**
+ * @file oss_ramdump_osa.c
+ * @brief Implementation of Ramdump os adapt
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author Qing Wang <wang.qing@sanechips.com.cn>
+ * @ingroup si_ap_oss_ramdump_id
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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.
+ *
+ */
+
+/*******************************************************************************
+ * Include header files *
+
+ ******************************************************************************/
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/err.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/miscdevice.h>
+#include "ramdump.h"
+#include "ramdump_emmc.h"
+
+/*******************************************************************************
+* Extern function declarations *
+*******************************************************************************/
+
+/*******************************************************************************
+* Extern variable declarations *
+*******************************************************************************/
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+#define RAMDUMP_EMMC_BUF_LEN (0x8000)
+#define RAMDUMP_EMMC_ALIGN_LEN (512)
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Local function declarations *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Local variable definitions *
+ ******************************************************************************/
+static ssize_t cap_device_read(struct file *fp, char __user *buf,size_t size, loff_t *pos);
+static ssize_t cap_device_write(struct file *fp, const char __user *buf,size_t size, loff_t *pos);
+static long cap_device_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
+static int cap_device_open(struct inode *ip, struct file *fp);
+static int cap_device_release(struct inode *ip, struct file *fp);
+static loff_t cap_device_llseek(struct file *, loff_t, int);
+
+/*******************************************************************************
+ * Global variable definitions *
+ ******************************************************************************/
+static const struct file_operations ramdump_device_fops = {
+ .owner = THIS_MODULE,
+ .read = cap_device_read,
+ .write = cap_device_write,
+ .open = cap_device_open,
+ .unlocked_ioctl = cap_device_ioctl,
+ .release = cap_device_release,
+ .llseek = cap_device_llseek,
+};
+
+static struct miscdevice ramdump_device = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "ramdump_device",
+ .fops = &ramdump_device_fops,
+};
+
+unsigned char *ramdump_device_buf = NULL;
+int ramdump_device_int_flag =-1;
+struct mutex ramdump_device_mutex;
+volatile unsigned int ramdump_dev_offset = 0;
+
+/*******************************************************************************
+ * Inline function implementations *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Local function implementations *
+ ******************************************************************************/
+static ssize_t cap_device_read(struct file *fp, char __user *buf, size_t size, loff_t *pos)
+{
+ ssize_t ret = 0;
+
+ if (roundup(size, RAMDUMP_EMMC_ALIGN_LEN) > RAMDUMP_EMMC_BUF_LEN)
+ size = RAMDUMP_EMMC_BUF_LEN;
+
+ ret = mmc_bread(RAMDUMP_EMMC_ADDR + ramdump_dev_offset, roundup(size, RAMDUMP_EMMC_ALIGN_LEN), ramdump_device_buf);
+ printk("cap ramdump kernel mmc_bread success size is 0x%x!\n", ret);
+ if (ret > 0)
+ {
+ mutex_lock(&ramdump_device_mutex);
+ copy_to_user(buf, ramdump_device_buf, size);
+ ramdump_dev_offset += ret;
+ mutex_unlock(&ramdump_device_mutex);
+ }
+ return ret;
+}
+
+static ssize_t cap_device_write(struct file *fp, const char __user *buf, size_t size, loff_t *pos)
+{
+ ssize_t ret = 0;
+
+ if (size > RAMDUMP_EMMC_BUF_LEN)
+ size = RAMDUMP_EMMC_BUF_LEN;
+
+ mutex_lock(&ramdump_device_mutex);
+ copy_from_user(ramdump_device_buf, buf, size);
+ mutex_unlock(&ramdump_device_mutex);
+
+ ret = mmc_bwrite(RAMDUMP_EMMC_ADDR + ramdump_dev_offset, roundup(size, RAMDUMP_EMMC_ALIGN_LEN), ramdump_device_buf);
+
+ if (ret >= 0)
+ ramdump_dev_offset += ret;
+
+ return ret;
+
+}
+
+static long cap_device_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
+{
+ return 0;
+}
+
+static loff_t cap_device_llseek(struct file *fp, loff_t offset, int whence)
+{
+ unsigned int new_pos = 0;
+ unsigned int old_pos = ramdump_dev_offset;
+
+ switch(whence)
+ {
+ case SEEK_SET:
+ new_pos = offset;
+ break;
+ case SEEK_CUR:
+ new_pos = old_pos + offset;
+ break;
+ case SEEK_END:
+ new_pos = RAMDUMP_TRANS_EMMC_LEN;
+ break;
+ default:
+ printk("cap ramdump llseek: unknow whence");
+ return -EINVAL;
+ }
+
+ ramdump_dev_offset = new_pos;
+ return 0;
+}
+
+static int cap_device_open(struct inode *ip, struct file *fp)
+{
+ int ret = -1;
+
+ ramdump_dev_offset = 0;
+ if (ramdump_device_int_flag < 0)
+ {
+ ramdump_device_buf = vmalloc(RAMDUMP_EMMC_BUF_LEN);
+ ret = mmc_ramdump_init();
+ ramdump_device_int_flag = 1;
+ }
+ else
+ printk("cap ramdump driver already opened!\n");
+
+ return ret;
+}
+
+static int cap_device_release(struct inode *ip, struct file *fp)
+{
+ vfree(ramdump_device_buf);
+ ramdump_device_int_flag = -1;
+ ramdump_dev_offset = 0;
+
+ return 0;
+}
+
+static int __init ramdump_dev_init(void)
+{
+ int ret = misc_register(&ramdump_device);
+
+ printk("cap ramdump driver init.\n");
+
+ if (ret)
+ {
+ printk(KERN_ERR "cap ramdump driver init failed.\n");
+ }
+ mutex_init(&ramdump_device_mutex);
+
+ return ret;
+}
+
+static void __exit ramdump_dev_exit(void)
+{
+ printk("cap ramdump driver exit.\n");
+ misc_deregister(&ramdump_device);
+}
+
+module_init(ramdump_dev_init);
+module_exit(ramdump_dev_exit);
+
+MODULE_DESCRIPTION("cap ramdump device driver");
+MODULE_LICENSE("GPL");
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/sched/core.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/sched/core.c
index da96a30..84c6154 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/sched/core.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/sched/core.c
@@ -81,6 +81,7 @@
*/
int sysctl_sched_rt_runtime = 950000;
+extern void zxic_trace_task_switch(struct task_struct *next);
/*
* Serialization rules:
@@ -3572,6 +3573,7 @@
fire_sched_out_preempt_notifiers(prev, next);
prepare_task(next);
prepare_arch_switch(next);
+ zxic_trace_task_switch(next);
}
/**
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/signal.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/signal.c
index 1471a84..2ddd1d7 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/signal.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/signal.c
@@ -59,6 +59,24 @@
#ifdef CONFIG_RAMDUMP_USER
extern unsigned int sysctl_ramdump_on_user;
#endif
+
+#ifdef CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK
+#include <linux/string.h>
+#include <linux/proc_fs.h>
+#include <linux/ctype.h>
+
+#define TASK_REGISTER_NUM_MAX (30)
+#define TASK_REGISTER_CMD_MAX_LEN (10)
+#define TASK_NAME_LEN_MAX (TASK_COMM_LEN)
+#define TASK_REGISTER_CMD_OPEN "open"
+#define TASK_REGISTER_CMD_OFF "off"
+#define TASK_SPECIAL_CHARACTER(c) ((c) == ';' ||(c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')
+
+static char task_registered_array[TASK_REGISTER_NUM_MAX][TASK_COMM_LEN] = {""};
+bool is_registered_task(const char *tsk_name, u32 *index);
+#endif /*CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK*/
+
+
/*
* SLAB caches for signal bits.
*/
@@ -2750,6 +2768,13 @@
do_coredump(&ksig->info);
}
+#ifdef CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK
+ if (ksig->info.si_signo != SIGTERM && is_registered_task(current->comm, NULL)) {
+ do_coredump(&ksig->info);
+ panic("user dump into kernel panic:abnormal exit task!\n");
+ }
+#endif /* CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK*/
+
/*
* Death signals, no core dump.
*/
@@ -4635,3 +4660,226 @@
kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid);
}
#endif /* CONFIG_KGDB_KDB */
+
+#ifdef CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK
+/**
+ * is_registered_task - check whether the exit tasks has been registered
+ * @tsk_comm: the buffer to extract from
+ *
+ * Returns false for not registered , or 0 for registered.
+ */
+bool is_registered_task(const char *tsk_name, u32 *index)
+{
+ int i;
+ char *arr_item = NULL;
+
+ if (tsk_name == NULL || *tsk_name == '\0')
+ return false;
+
+ for (i = 0; i < TASK_REGISTER_NUM_MAX; i++){
+ arr_item = *(task_registered_array + i);
+ if ((strlen(tsk_name) == strlen(arr_item)) &&
+ strncmp(tsk_name, arr_item, strlen(tsk_name))== 0){
+ if(index != NULL)
+ *index = i;
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * task_get_unused_arr_index - get free index in task_registered_array
+ *
+ * Returns -errno, or index for success.
+ */
+int task_get_unused_arr_index(void)
+{
+ u32 index = 0;
+
+ for (index = 0; index < TASK_REGISTER_NUM_MAX; index++)
+ {
+ if (strlen(*(task_registered_array + index)) == 0)
+ return index;
+ }
+ return -EBUSY;
+}
+
+/**
+ * task_exit_register - register exit tasks to task_registered_array
+ * @tsk_buf: the file to extract from
+ * @size: the buffer size
+ *
+ * Returns -errno, or 0 for success.
+ */
+int task_exit_register_proc(const char *names_buf, size_t size, char *type)
+{
+ int len = 0;
+ int task_name_len = 0;
+ int index = 0;
+ int del_index = 0;
+ char *abnormal_exit_task_buf = NULL;
+ int retval = -EFAULT;
+
+ if(names_buf == NULL || type == NULL)
+ return -EINVAL;
+
+ abnormal_exit_task_buf = kmalloc(TASK_NAME_LEN_MAX, GFP_KERNEL);
+ if (abnormal_exit_task_buf == NULL)
+ return -ENOMEM;
+
+ while(1) {
+ len = 0;
+ for (; *names_buf != '\0' ; names_buf++, size--){
+ if (!TASK_SPECIAL_CHARACTER(*names_buf)
+ && isprint(*names_buf))
+ len++;
+
+ else if ((TASK_SPECIAL_CHARACTER(*names_buf)|| !isprint(*names_buf))&& len > 0)
+ break;
+ }
+ if (len > 0){
+ task_name_len = min(len, TASK_COMM_LEN - 1);
+ strncpy(abnormal_exit_task_buf, names_buf - len, task_name_len);
+ abnormal_exit_task_buf[task_name_len] = '\0';
+
+ /*register abnormal exit task*/
+ if (!strcmp(type, TASK_REGISTER_CMD_OPEN)){
+ if (unlikely(is_registered_task(abnormal_exit_task_buf, NULL)))
+ continue;
+ index = task_get_unused_arr_index();
+ if (index >= 0)
+ strlcpy(*(task_registered_array + index), abnormal_exit_task_buf, sizeof(*(task_registered_array + index)));
+ else
+ printk("[Task abnormal exit]registered tasks num is out of range 0-%d\n", TASK_REGISTER_NUM_MAX);
+ }
+
+ /*unregister abnormal exit task*/
+ else if (!strcmp(type, TASK_REGISTER_CMD_OFF)){
+ if (likely(is_registered_task(abnormal_exit_task_buf, &del_index)))
+ memset(*(task_registered_array + del_index), 0, TASK_COMM_LEN);
+ else
+ printk("[Task abnormal exit] task is not registered, please check it\n");
+ }
+ else
+ break;
+ }
+
+ if (*names_buf == '\0' || size <= 0)
+ break;
+ }
+ kfree(abnormal_exit_task_buf);
+ return retval;
+}
+
+/**
+ * task_abnormal_exit_write - extract exit tasks from a user string
+ * @file: the file to extract from
+ * @user_buf: the buffer to extract from
+ * @size: the length of the buffer
+ * @off: .
+ *
+ * Returns -errno, or 0 for success.
+ */
+static ssize_t task_abnormal_exit_write(struct file *file, const char __user * user_buf, size_t size, loff_t * off)
+{
+ int retval = 0;
+ int prelen = 0;
+ int cmd_len = 0;
+ char *cmd_ptr = NULL;
+ char *names_buf = NULL;
+ char *tsk_buf = NULL;
+ char cmd[TASK_REGISTER_CMD_MAX_LEN] = {0};
+
+ tsk_buf = kmalloc(size + 1, GFP_KERNEL);
+ if (tsk_buf == NULL)
+ return -ENOMEM;
+
+ if (copy_from_user(tsk_buf, user_buf, size)){
+ kfree(tsk_buf);
+ return -EFAULT;
+ }
+ tsk_buf[size] = '\0';
+
+ cmd_ptr = strstr(tsk_buf, TASK_REGISTER_CMD_OPEN);
+
+ if (cmd_ptr != NULL)
+ cmd_len = strlen(TASK_REGISTER_CMD_OPEN);
+ else{
+ cmd_ptr = strstr(tsk_buf, TASK_REGISTER_CMD_OFF);
+ if (cmd_ptr != NULL)
+ cmd_len = strlen(TASK_REGISTER_CMD_OFF);
+ else{
+ kfree(tsk_buf);
+ printk("Err: cmd should be:%s or %s\n", TASK_REGISTER_CMD_OPEN, TASK_REGISTER_CMD_OFF);
+ return -EINVAL;
+ }
+ }
+ strncpy(cmd, cmd_ptr, TASK_REGISTER_CMD_MAX_LEN - 1);
+ cmd[cmd_len]= '\0';
+ prelen = cmd_ptr - tsk_buf + cmd_len;
+ names_buf = cmd_ptr + prelen;
+
+ task_exit_register_proc(names_buf, size, cmd);
+ *off += size;
+ kfree(tsk_buf);
+ retval = size;
+ return retval;
+}
+
+/**
+ * task_abnormal_exit_show - show the registered exit tasks
+ * @m: proc file structure
+ * @v:
+ *
+ * Returns -errno, or 0 for success.
+ */
+static int task_abnormal_exit_show(struct seq_file *m, void *v)
+{
+ int index = 0;
+
+ seq_printf(m,"the registered abnormal exit tasks:\n");
+ for (index =0; index < TASK_REGISTER_NUM_MAX; index++){
+ if(*(task_registered_array + index)[0] == '\0')
+ continue;
+ seq_printf(m,"%d. %s\n", index, *(task_registered_array + index));
+ }
+ return 0;
+}
+
+/**
+ * cpumask_parse_user - open funution
+ * @inode: file inode
+ * @file: file descriptor
+ *
+ * Returns -errno, or 0 for success.
+ */
+static int task_abnormal_exit_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, task_abnormal_exit_show, NULL);
+}
+
+/**
+ * task_exit_registered_proc_fops - proc file ops
+ * @open: open the registed proc file.
+ * @read: read the registed proc file.
+ * @write: write to the registed proc file.
+ *
+ * Returns -errno, or 0 for success.
+ */
+static const struct proc_ops task_exit_registered_proc_fops = {
+ .proc_open = task_abnormal_exit_open,
+ .proc_read = seq_read,
+ .proc_write = task_abnormal_exit_write
+};
+
+static int __init task_abnormal_exit_init(void)
+{
+ proc_create("abnormal_exit_task", 0, NULL, &task_exit_registered_proc_fops);
+ return 0;
+}
+
+module_init(task_abnormal_exit_init);
+
+#endif /*CONFIG_RAMDUMP_ABNORMAL_EXIT_TASK*/
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/softirq.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/softirq.c
index 09229ad..27187b5 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/softirq.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/softirq.c
@@ -61,6 +61,9 @@
"TASKLET", "SCHED", "HRTIMER", "RCU"
};
+extern void zxic_trace_softirq_enter(u32 vec_nr);
+extern void zxic_trace_softirq_exit(u32 vec_nr);
+
/*
* we cannot loop indefinitely here to avoid userspace starvation,
* but we also don't want to introduce a worst case 1/HZ latency
@@ -295,7 +298,9 @@
kstat_incr_softirqs_this_cpu(vec_nr);
trace_softirq_entry(vec_nr);
+ zxic_trace_softirq_enter(vec_nr);
h->action(h);
+ zxic_trace_softirq_exit(vec_nr);
trace_softirq_exit(vec_nr);
if (unlikely(prev_count != preempt_count())) {
pr_err("huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n",
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/time/timer.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/time/timer.c
index e87e638..cc7906e 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/time/timer.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/time/timer.c
@@ -222,6 +222,9 @@
static void timer_update_keys(struct work_struct *work);
static DECLARE_WORK(timer_update_work, timer_update_keys);
+extern void zxic_trace_timer_enter(void *func);
+extern void zxic_trace_timer_exit(void *func);
+
#ifdef CONFIG_SMP
unsigned int sysctl_timer_migration = 1;
@@ -1411,7 +1414,9 @@
lock_map_acquire(&lockdep_map);
trace_timer_expire_entry(timer, baseclk);
+ zxic_trace_timer_enter(fn);
fn(timer);
+ zxic_trace_timer_exit(fn);
trace_timer_expire_exit(timer);
lock_map_release(&lockdep_map);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/tracker.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/tracker.c
new file mode 100755
index 0000000..6f7e1ab
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/kernel/tracker.c
@@ -0,0 +1,459 @@
+/*
+ * tracker.c - System accounting over taskstats interface
+ *
+ * Copyright (C) Jay Lan, <jlan@sgi.com>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/jiffies.h>
+#include <linux/slab.h>
+#include <linux/timer.h>
+#include <linux/delay.h>
+#include <linux/kthread.h>
+#include <linux/timer.h>
+#include <linux/uaccess.h>
+#include <linux/export.h>
+#include <linux/sched/clock.h>
+#include "ram_config.h"
+
+/*******************************************************************************
+* ºê¶¨Òå *
+*******************************************************************************/
+#define _OS_LINUX 1
+
+#if defined(_OS_TOS)
+# define OS_STATISTIC_IRAM_BASE (IRAM_BASE_ADDR_OS_STATISTIC_PSCPU)
+# define OS_STATISTIC_TIME zDrvTimer_Stamp()
+#elif defined(_OS_LINUX)
+# define OS_STATISTIC_IRAM_BASE g_zxic_trace_apcpu_addr //(IRAM_BASE_ADDR_OS_STATISTIC_APCPU)
+# define OS_STATISTIC_TIME (cpu_clock(0)>>10)
+#else
+# error "unknown os"
+#endif
+
+
+
+#define OS_IRAM_STATISTIC_CNT (5)
+#define OS_IRAM_STATISTIC_NAME_LEN (16)
+#define OS_DDR_STATISTIC_CNT (1000)
+
+#define OS_IRAM_THREAD_SWAPIN (OS_STATISTIC_IRAM_BASE)
+#define OS_IRAM_IRQ_START (OS_IRAM_THREAD_SWAPIN + sizeof(t_os_iram_thread_statistic))
+#define OS_IRAM_IRQ_END (OS_IRAM_IRQ_START + sizeof(t_os_iram_statistic))
+
+#if defined(_OS_TOS)
+#define OS_IRAM_DSR_START (OS_IRAM_IRQ_END + sizeof(t_os_iram_statistic))
+#define OS_IRAM_DSR_END (OS_IRAM_DSR_START + sizeof(t_os_iram_statistic))
+#elif defined(_OS_LINUX)
+#define OS_IRAM_SOFTIRQ_START (OS_IRAM_IRQ_END + sizeof(t_os_iram_statistic))
+#define OS_IRAM_SOFTIRQ_END (OS_IRAM_SOFTIRQ_START + sizeof(t_os_iram_statistic))
+#define OS_IRAM_TIMER_START (OS_IRAM_SOFTIRQ_END + sizeof(t_os_iram_statistic))
+#define OS_IRAM_TIMER_END (OS_IRAM_TIMER_START + sizeof(t_os_iram_statistic))
+#endif
+
+#define os_statistic_check() *((volatile unsigned long *)OS_STATISTIC_IRAM_BASE)
+#define os_statistic_enabled() g_os_statistic_enable
+
+/*******************************************************************************
+* Êý¾Ý½á¹¹¶¨Òå *
+*******************************************************************************/
+typedef volatile struct {
+ unsigned int cnt;
+ unsigned int index;
+ struct {
+ unsigned char name[OS_IRAM_STATISTIC_NAME_LEN];
+ unsigned int data2;
+ } statistics[OS_IRAM_STATISTIC_CNT];
+}t_os_iram_thread_statistic;
+
+typedef volatile struct {
+ unsigned int cnt;
+ unsigned int index;
+ struct {
+ unsigned int data1;
+ unsigned int data2;
+ } statistics[OS_IRAM_STATISTIC_CNT];
+}t_os_iram_statistic;
+
+typedef struct {
+ unsigned int cnt;
+ unsigned int index;
+ struct {
+ unsigned int data1;
+ unsigned int data2;
+ } statistics[OS_DDR_STATISTIC_CNT];
+}t_os_ddr_statistic;
+
+/*******************************************************************************
+* È«¾Ö±äÁ¿ *
+*******************************************************************************/
+#if defined(_OS_LINUX)
+volatile static char *g_zxic_trace_apcpu_addr;
+#endif
+
+volatile static int g_os_statistic_enable;
+volatile static unsigned int g_os_statistic_cnt;
+
+volatile static t_os_iram_thread_statistic *g_os_iram_swapin_statistic;
+volatile static t_os_iram_statistic *g_os_iram_irq_start_statistic;
+volatile static t_os_iram_statistic *g_os_iram_irq_end_statistic;
+
+#if defined(_OS_TOS)
+static t_os_iram_statistic *g_os_iram_dsr_start_statistic;
+static t_os_iram_statistic *g_os_iram_dsr_end_statistic;
+#elif defined(_OS_LINUX)
+volatile static t_os_iram_statistic *g_os_iram_softirq_start_statistic;
+volatile static t_os_iram_statistic *g_os_iram_softirq_end_statistic;
+volatile static t_os_iram_statistic *g_os_iram_timer_start_statistic;
+volatile static t_os_iram_statistic *g_os_iram_timer_end_statistic;
+#endif
+
+volatile static t_os_ddr_statistic *g_os_ddr_swapin_statistic;
+volatile static t_os_ddr_statistic *g_os_ddr_irq_start_statistic;
+volatile static t_os_ddr_statistic *g_os_ddr_irq_end_statistic;
+
+#if defined(_OS_TOS)
+static t_os_ddr_statistic *g_os_ddr_dsr_start_statistic;
+static t_os_ddr_statistic *g_os_ddr_dsr_end_statistic;
+#elif defined(_OS_LINUX)
+volatile static t_os_ddr_statistic *g_os_ddr_softirq_start_statistic;
+volatile static t_os_ddr_statistic *g_os_ddr_softirq_end_statistic;
+volatile static t_os_ddr_statistic *g_os_ddr_timer_start_statistic;
+volatile static t_os_ddr_statistic *g_os_ddr_timer_end_statistic;
+#endif
+
+/*******************************************************************************
+* È«¾Öº¯ÊýÉùÃ÷ *
+*******************************************************************************/
+void os_statistic_enable(void);
+/*******************************************************************************
+* ¾Ö²¿º¯Êý *
+*******************************************************************************/
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æµ½IRAM
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) iram_addr: µØÖ·
+ data: ʼþÏî
+ time: ʱ¼ä
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: ÎÞ
+*******************************************************************************/
+static inline void os_statistic_in_iram(volatile void *iram_addr, void *data, unsigned long time)
+{
+ unsigned long index;
+ t_os_iram_statistic *iram;
+
+ iram = (t_os_iram_statistic *)iram_addr;
+
+ index = iram->index;
+ if(index >= OS_IRAM_STATISTIC_CNT)
+ {
+ index = 0;
+ }
+
+ iram->statistics[index].data1 = (unsigned int)data;
+ iram->statistics[index].data2 = time;
+ index++;
+
+ iram->index = index;
+ iram->cnt = g_os_statistic_cnt;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: Ï̹߳켣ͳ¼Æµ½IRAM
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) iram_addr: µØÖ·
+ data: ʼþÏî
+ time: ʱ¼ä
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: ÎÞ
+*******************************************************************************/
+static inline void os_statistic_thread_in_iram(volatile void *iram_addr, void *data, unsigned long time)
+{
+ unsigned long index;
+ t_os_iram_thread_statistic *iram;
+
+ iram = (t_os_iram_thread_statistic *)iram_addr;
+
+ index = iram->index;
+ if(index >= OS_IRAM_STATISTIC_CNT)
+ {
+ index = 0;
+ }
+
+#if defined(_OS_TOS)
+ strncpy((char *)(iram->statistics[index].name), cyg_thread_get_name((cyg_handle_t)data), OS_IRAM_STATISTIC_NAME_LEN - 1);
+#elif defined(_OS_LINUX)
+ strncpy((char *)(iram->statistics[index].name), ((struct task_struct *)data)->comm, OS_IRAM_STATISTIC_NAME_LEN - 1);
+#else
+# error "unkown os"
+#endif
+ iram->statistics[index].name[OS_IRAM_STATISTIC_NAME_LEN - 1] = 0;
+ iram->statistics[index].data2 = time;
+ index++;
+
+ iram->index = index;
+ iram->cnt = g_os_statistic_cnt;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æµ½DDR
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) iram_addr: µØÖ·
+ data: ʼþÏî
+ time: ʱ¼ä
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: ÎÞ
+*******************************************************************************/
+static inline void os_statistic_in_ddr(void *ddr_addr, void *data, unsigned long time)
+{
+ unsigned long index;
+ t_os_ddr_statistic *ddr;
+
+ ddr = (t_os_ddr_statistic *)ddr_addr;
+
+ index = ddr->index;
+ if (index >= OS_DDR_STATISTIC_CNT)
+ {
+ index = 0;
+ }
+ ddr->statistics[index].data1 = (unsigned int)data;
+ ddr->statistics[index].data2 = time;
+ index++;
+
+ ddr->index = index;
+ ddr->cnt = g_os_statistic_cnt;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æµ½DDR
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) iram_addr: µØÖ·
+ data: ʼþÏî
+ time: ʱ¼ä
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: ÎÞ
+*******************************************************************************/
+static inline void os_statistic_info_update(void)
+{
+ g_os_statistic_cnt++;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ¶¨Ê±Æ÷»Øµ÷¹³×Ó
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý)
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: ÎÞ
+*******************************************************************************/
+static int os_statistic_delayed_work_timer_fn(unsigned long data)
+{
+ int sec = 0;
+ msleep(20000);
+ while(!os_statistic_check())
+ {
+ //³¬¹ý40s£¬Ö±½ÓÍ˳ö
+ if(sec >= 4)
+ return 0;
+ msleep(10000);
+ sec++;
+ }
+ os_statistic_enable();
+ return 0;
+}
+
+/*******************************************************************************
+* È«¾Öº¯ÊýʵÏÖ *
+*******************************************************************************/
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ʹÄܹ켣ͳ¼Æ¹¦ÄÜ
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) address: ¼Ç¼µ½IRAMÖеĵØÖ·
+ size: IRAM¿Õ¼ä´óС
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: ÎÞ
+*******************************************************************************/
+void os_statistic_enable(void)
+{
+#if defined(_OS_TOS)
+ g_os_iram_swapin_statistic = (t_os_iram_thread_statistic *)OS_IRAM_THREAD_SWAPIN;
+ g_os_iram_irq_start_statistic = (t_os_iram_statistic *)OS_IRAM_IRQ_START;
+ g_os_iram_irq_end_statistic = (t_os_iram_statistic *)OS_IRAM_IRQ_END;
+ g_os_iram_dsr_start_statistic = (t_os_iram_statistic *)OS_IRAM_DSR_START;
+ g_os_iram_dsr_end_statistic = (t_os_iram_statistic *)OS_IRAM_DSR_END;
+
+ g_os_ddr_swapin_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic));
+ g_os_ddr_irq_start_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic));
+ g_os_ddr_irq_end_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic));
+ g_os_ddr_dsr_start_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic));
+ g_os_ddr_dsr_end_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic));
+#elif defined(_OS_LINUX)
+ g_os_iram_swapin_statistic = (t_os_iram_thread_statistic *)OS_IRAM_THREAD_SWAPIN;
+ g_os_iram_irq_start_statistic = (t_os_iram_statistic *)OS_IRAM_IRQ_START;
+ g_os_iram_irq_end_statistic = (t_os_iram_statistic *)OS_IRAM_IRQ_END;
+ g_os_iram_softirq_start_statistic = (t_os_iram_statistic *)OS_IRAM_SOFTIRQ_START;
+ g_os_iram_softirq_end_statistic = (t_os_iram_statistic *)OS_IRAM_SOFTIRQ_END;
+ g_os_iram_timer_start_statistic = (t_os_iram_statistic *)OS_IRAM_TIMER_START;
+ g_os_iram_timer_end_statistic = (t_os_iram_statistic *)OS_IRAM_TIMER_END;
+
+ g_os_ddr_swapin_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL);
+ g_os_ddr_irq_start_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL);
+ g_os_ddr_irq_end_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL);
+ g_os_ddr_softirq_start_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL);
+ g_os_ddr_softirq_end_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL);
+ g_os_ddr_timer_start_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL);
+ g_os_ddr_timer_end_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL);
+
+#else
+# error "unkown os"
+#endif
+ if ((unsigned int )g_os_iram_timer_end_statistic - (unsigned int )g_os_iram_swapin_statistic > (unsigned int )IRAM_BASE_LEN_OS_STATISTIC_PSCPU )
+ {
+ BUG();
+ }
+ g_os_statistic_enable = 1;
+}
+EXPORT_SYMBOL(os_statistic_enable);
+
+void zxic_trace_task_switch(struct task_struct *next)
+{
+ unsigned long time;
+ if (!g_os_statistic_enable)
+ return ;
+
+ time = OS_STATISTIC_TIME;
+ os_statistic_thread_in_iram(g_os_iram_swapin_statistic, next, time);
+ os_statistic_in_ddr(g_os_ddr_swapin_statistic, next, time);
+ os_statistic_info_update();
+}
+
+void zxic_trace_irq_enter(u32 irq)
+{
+ unsigned long time;
+ if (!g_os_statistic_enable)
+ return ;
+
+ time = OS_STATISTIC_TIME;
+ os_statistic_in_iram(g_os_iram_irq_start_statistic, irq, time);
+ os_statistic_in_ddr(g_os_ddr_irq_start_statistic, irq, time);
+ os_statistic_info_update();
+}
+
+void zxic_trace_irq_exit(u32 irq)
+{
+ unsigned long time;
+ if (!g_os_statistic_enable)
+ return ;
+
+ time = OS_STATISTIC_TIME;
+ os_statistic_in_iram(g_os_iram_irq_end_statistic, irq, time);
+ os_statistic_in_ddr(g_os_ddr_irq_end_statistic, irq, time);
+ os_statistic_info_update();
+}
+
+void zxic_trace_softirq_enter(u32 vec_nr)
+{
+ unsigned long time;
+ if (!g_os_statistic_enable)
+ return ;
+
+ time = OS_STATISTIC_TIME;
+ os_statistic_in_iram(g_os_iram_softirq_start_statistic, vec_nr, time);
+ os_statistic_in_ddr(g_os_ddr_softirq_start_statistic, vec_nr, time);
+ os_statistic_info_update();
+}
+
+void zxic_trace_softirq_exit(u32 vec_nr)
+{
+ unsigned long time;
+ if (!g_os_statistic_enable)
+ return ;
+
+ time = OS_STATISTIC_TIME;
+ os_statistic_in_iram(g_os_iram_softirq_end_statistic, vec_nr, time);
+ os_statistic_in_ddr(g_os_ddr_softirq_end_statistic, vec_nr, time);
+ os_statistic_info_update();
+}
+
+void zxic_trace_timer_enter(void *func)
+{
+ unsigned long time;
+ if (!g_os_statistic_enable)
+ return ;
+
+ time = OS_STATISTIC_TIME;
+ os_statistic_in_iram(g_os_iram_timer_start_statistic, func, time);
+ os_statistic_in_ddr(g_os_ddr_timer_start_statistic, func, time);
+ os_statistic_info_update();
+}
+
+void zxic_trace_timer_exit(void *func)
+{
+ unsigned long time;
+ if (!g_os_statistic_enable)
+ return ;
+
+ time = OS_STATISTIC_TIME;
+ os_statistic_in_iram(g_os_iram_timer_end_statistic, func, time);
+ os_statistic_in_ddr(g_os_ddr_timer_end_statistic, func, time);
+ os_statistic_info_update();
+}
+
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æµ½DDR
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) iram_addr: µØÖ·
+ data: ʼþÏî
+ time: ʱ¼ä
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: ÎÞ
+*******************************************************************************/
+int __init zxic_enable_tracer(void)
+{
+ struct timer_list timer;
+ struct task_struct *task;
+
+#ifdef IRAM_BASE_ADDR_VA
+ g_zxic_trace_apcpu_addr = IRAM_BASE_ADDR_OS_STATISTIC_PSCPU;
+#else
+ g_zxic_trace_apcpu_addr = ioremap(IRAM_BASE_ADDR_OS_STATISTIC_PSCPU, IRAM_BASE_LEN_OS_STATISTIC_PSCPU);
+#endif
+
+ /*
+ init_timer(&timer);
+ timer.expires = jiffies + 40*HZ;//msecs_to_jiffies(40*1000);//ÑÓ³Ù40Ãë
+ timer.data = 0;
+ timer.function = os_statistic_delayed_work_timer_fn;
+ setup_timer(&timer, os_statistic_delayed_work_timer_fn, 0);
+ add_timer(&timer);
+ */
+ //task = kthread_create(os_statistic_delayed_work_timer_fn, 0, "g_zxic_trace_sync_thread", 0);
+ //wake_up_process(task);
+ os_statistic_enable();
+ return 0x0;
+}
+module_init(zxic_enable_tracer);
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/lib/Kconfig.debug b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/lib/Kconfig.debug
index cfe030a..22a0ebd 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/lib/Kconfig.debug
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/lib/Kconfig.debug
@@ -1158,6 +1158,34 @@
certainly want to say Y here. Not necessary on systems that never
need debugging or only ever run flawless code.
+config RAMDUMP_ABNORMAL_EXIT_TASK
+ bool "Enable ramdump abnormal exit support"
+ default n
+ help
+ This option enables support for ramdump abnormal exit. You almost
+ certainly want to say Y here. Not necessary on systems that never
+ need debugging or only ever run flawless code.
+
+config RAMDUMP_EMMC
+ bool "Enable ramdump emmc transport"
+ depends on RAMDUMP
+ default n
+ help
+ This option enables support for ramdump emmc stroage.
+
+config RAMDUMP_EMMC_BASE
+ hex "Default value of emmc base address for ramdump"
+ depends on RAMDUMP_EMMC
+ default 0x0
+ help
+ This option controls emmc base address for ramdump files storage.
+
+config RAMDUMP_EMMC_SIZE
+ hex "Default value of emmc length for ramdump"
+ depends on RAMDUMP_EMMC
+ default 0x0
+ help
+ This option controls length of emmc memory for ramdump files storage.
menu "Lock Debugging (spinlocks, mutexes, etc...)"
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/core/control_compat.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/core/control_compat.c
index 97467f6..74d0611 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/core/control_compat.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/core/control_compat.c
@@ -304,7 +304,9 @@
err = snd_power_wait(card, SNDRV_CTL_POWER_D0);
if (err < 0)
goto error;
+ down_read(&card->controls_rwsem);//update CVE-2023-0266
err = snd_ctl_elem_read(card, data);
+ up_read(&card->controls_rwsem);//update CVE-2023-0266
if (err < 0)
goto error;
err = copy_ctl_value_to_user(userdata, valuep, data, type, count);
@@ -332,7 +334,10 @@
err = snd_power_wait(card, SNDRV_CTL_POWER_D0);
if (err < 0)
goto error;
+
+ down_write(&card->controls_rwsem);//update CVE-2023-0266
err = snd_ctl_elem_write(card, file, data);
+ up_write(&card->controls_rwsem);//update CVE-2023-0266
if (err < 0)
goto error;
err = copy_ctl_value_to_user(userdata, valuep, data, type, count);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/ab_bootinfo/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/ab_bootinfo/Makefile
new file mode 100755
index 0000000..ba8e396
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/ab_bootinfo/Makefile
@@ -0,0 +1,35 @@
+#*******************************************************************************
+# include build/common makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = ab_bootinfo
+OBJS = ab_bootinfo.o
+
+CFLAGS += -I$(APP_DIR)/include
+CFLAGS += -I$(LIB_DIR)/libupi_ab/inc
+CFLAGS += -g -Werror=implicit-function-declaration
+
+
+#LDLIBS = -lnvram_sc -L$(LIB_DIR)/libnvram
+LDLIBS += -lpthread -lmtd -lnvram -lsofttimer -lupi_ab -lsoftap
+#LDLIBS += -lcrypto -L$(LIB_DIR)/libssl/install/lib
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/ab_bootinfo/ab_bootinfo.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/ab_bootinfo/ab_bootinfo.c
new file mode 100644
index 0000000..94d3dfc
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/ab_bootinfo/ab_bootinfo.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "zxic_fota_ab_upgrade.h"
+
+#if 0
+static int zxic_dual_get_current_system(void)
+{
+ return 1;
+}
+#endif
+int main(int argc, char *argv[])
+{
+ int ret = zxic_dual_get_current_system();
+
+ switch (ret)
+ {
+ case 1:
+ printf("ab_bootinfo:ab_a\n");
+ break;
+ case 2:
+ printf("ab_bootinfo:ab_b\n");
+ break;
+ default:
+ printf("[error]ab_bootinfo:%d\n", ret);
+ break;
+ }
+ return ret;
+}
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/adb/usb_linux_client.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/adb/usb_linux_client.c
index 13dddc4..d8cf16d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/adb/usb_linux_client.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/adb/usb_linux_client.c
@@ -188,6 +188,12 @@
int fd = usb_hdl->fd;
int cnt = 1000;
+ if (fd >= 0)
+ {
+ usb_kick(usb_hdl);
+ fd = -1;
+ printf("adbd android_adb online usb_kick\n");
+ }
printf("adbd android_adb online \n");
while (fd < 0 && (--cnt > 0))
{
@@ -208,7 +214,7 @@
}else if(strstr(buf, "offline@")){
if(strstr(buf, "android_adb")){
/*ÔÚinput_thread->transport_unref->usb_kick¹Ø±ÕusbÉ豸£»*/
- // usb_kick(usb_hdl);
+ usb_kick(usb_hdl);
printf("adbd android_adb offline \n");
}
}
@@ -269,4 +275,3 @@
}
}
-
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atconfig/ps_pdp.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atconfig/ps_pdp.c
index 41516fa..8bcf696 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atconfig/ps_pdp.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atconfig/ps_pdp.c
@@ -715,6 +715,7 @@
{
int i = 0;
int iIpv6Item[16] = {0};
+ int flag = 0;
//at_print(AT_DEBUG,"IPV6 before change == %s\n", pstrIpv6);
sscanf(pstrIpv6, "%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d",
@@ -726,12 +727,18 @@
memset(s_strIpv6Addr, 0, v6AddrLen);
for(i=0; i<=15; i++)
{
+ if(iIpv6Item[i] != 0)
+ flag++;
snprintf(s_strIpv6Addr+strlen(s_strIpv6Addr), v6AddrLen-strlen(s_strIpv6Addr), "%02x", iIpv6Item[i]);
if((i%2==1) && (i<15))
{
snprintf(s_strIpv6Addr+strlen(s_strIpv6Addr), v6AddrLen-strlen(s_strIpv6Addr), ":");
}
}
+ if(flag == 0){
+ memset(s_strIpv6Addr, 0, v6AddrLen);
+ at_print(AT_ERR,"IPV6 %s is ::\n", s_strIpv6Addr);
+ }
//at_print(AT_DEBUG,"IPV6 after change == %s\n", s_strIpv6Addr);
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_com.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_com.c
index 30fc1c3..875c93d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_com.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_com.c
@@ -617,7 +617,7 @@
#if (APP_OS_TYPE == APP_OS_LINUX)
-static int at_sys_write(int fd,char *buf,int len)
+int at_sys_write(int fd,char *buf,int len)
{
int resendcnt = 0;
int written_bytes = 0;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_context.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_context.c
index 32e4010..848368d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_context.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_context.c
@@ -261,23 +261,48 @@
}
}
}
- g_farps_fd1 = at_open("/dev/ttyGS0",O_RDWR);
- at_print(AT_ERR,"init open ttyGS0 => fd: %d er_no: %d\n", g_farps_fd1, errno);
- if(g_farps_fd1 >= 0){
- if(at_portmng_set_state_proc("/dev/ttyGS0",1,g_farps_fd1) != 0){
- at_close(g_farps_fd1);
- g_farps_fd1=-1;
- }
- }
- g_farps_fd2 = at_open("/dev/ttyGS1",O_RDWR);
- at_print(AT_ERR,"init open ttyGS1 => fd: %d er_no: %d\n", g_farps_fd2, errno);
- if(g_farps_fd2 >= 0){
- if(at_portmng_set_state_proc("/dev/ttyGS1",1,g_farps_fd2) != 0){
- at_close(g_farps_fd2);
- g_farps_fd2=-1;
- }
- }
+ sc_cfg_get("cap_port_name",port_name,sizeof(port_name));
+ if(strstr("/dev/ttyGS0",port_name) == NULL){
+ g_farps_fd1 = at_open("/dev/ttyGS0",O_RDWR);
+ at_print(AT_ERR,"init open ttyGS0 => fd: %d er_no: %d\n", g_farps_fd1, errno);
+ if(g_farps_fd1 >= 0){
+ if(at_portmng_set_state_proc("/dev/ttyGS0",1,g_farps_fd1) != 0){
+ at_close(g_farps_fd1);
+ g_farps_fd1=-1;
+ }
+ }
+ }else{
+ g_farps_fd1 = at_open("/dev/armps_rpmsgch30",O_RDWR);
+ at_print(AT_ERR,"init open armps_rpmsgch30 => fd: %d er_no: %d\n", g_farps_fd1, errno);
+ if(g_farps_fd1 >= 0){
+ channel_config(g_farps_fd1);
+ if(at_portmng_set_state_proc("/dev/armps_rpmsgch30",1,g_farps_fd1) != 0){
+ at_close(g_farps_fd1);
+ g_farps_fd1=-1;
+ }
+ }
+ }
+ if(strstr("/dev/ttyGS1",port_name) == NULL){
+ g_farps_fd2 = at_open("/dev/ttyGS1",O_RDWR);
+ at_print(AT_ERR,"init open ttyGS1 => fd: %d er_no: %d\n", g_farps_fd2, errno);
+ if(g_farps_fd2 >= 0){
+ if(at_portmng_set_state_proc("/dev/ttyGS1",1,g_farps_fd2) != 0){
+ at_close(g_farps_fd2);
+ g_farps_fd2=-1;
+ }
+ }
+ }else{
+ g_farps_fd2 = at_open("/dev/armps_rpmsgch31",O_RDWR);
+ at_print(AT_ERR,"init open armps_rpmsgch31 => fd: %d er_no: %d\n", g_farps_fd2, errno);
+ if(g_farps_fd2 >= 0){
+ channel_config(g_farps_fd2);
+ if(at_portmng_set_state_proc("/dev/armps_rpmsgch31",1,g_farps_fd2) != 0){
+ at_close(g_farps_fd2);
+ g_farps_fd2=-1;
+ }
+ }
+ }
#endif
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_portmng.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_portmng.c
index cd251cf..79bf906 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_portmng.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_portmng.c
@@ -324,12 +324,14 @@
tcgetattr(fdcom, &termios_old);
/*------------ÉèÖö˿ÚÊôÐÔ----------------*/
- termios_old.c_lflag &= ~ECHO;
- termios_old.c_iflag &= ~ICRNL;
- termios_old.c_oflag &= ~ONLCR;
+ termios_old.c_iflag &= ~(ICRNL | IXON);
+ termios_old.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ISIG);
+ termios_old.c_oflag &= ~OPOST;
+ //termios_old.c_oflag &= ~ONLCR;
+
+ setResult = tcsetattr(fdcom, TCSANOW, &termios_old);
tcflush(fdcom, TCIFLUSH);
- setResult = tcsetattr(fdcom, TCSANOW, &termios_old);
return setResult;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_rcvmsg.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_rcvmsg.c
index 8dc0258..a5ed31c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_rcvmsg.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/atctrl/at_rcvmsg.c
@@ -876,7 +876,7 @@
}
else
{
- sc_cfg_get("customIndCmdList", PsmIndAtCmdPrefix, sizeof(PsmIndAtCmdPrefix));
+ sc_cfg_get("customIndCmdList_cap", PsmIndAtCmdPrefix, sizeof(PsmIndAtCmdPrefix));
}
//at_print(AT_ERR,"[XXX]customIndCmdList =%s\n",PsmIndAtCmdPrefix);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc/zbl_at_atcode.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc/zbl_at_atcode.h
index 1691f5b..3bec26a 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc/zbl_at_atcode.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc/zbl_at_atcode.h
@@ -192,6 +192,7 @@
static SINT32 Make_BootSet_Cmd(CI_AT_CMD_LINE_T *pCmdLine, const ZBL_CHANNEL_MSG_INFO *pMsg);
static SINT32 Make_ModeSet_Cmd(CI_AT_CMD_LINE_T *pCmdLine, const ZBL_CHANNEL_MSG_INFO *pMsg);
static SINT32 Make_Zmena_Cmd(CI_AT_CMD_LINE_T *pCmdLine, const ZBL_CHANNEL_MSG_INFO *pMsg);
+static SINT32 Make_Csdh_Cmd(CI_AT_CMD_LINE_T *pCmdLine, const ZBL_CHANNEL_MSG_INFO *pMsg);
SINT32 Make_GeneralTerminalRsp_Cmd(CI_AT_CMD_LINE_T *pCmdLine, const ZBL_CHANNEL_MSG_INFO *pMsg);
SINT32 Make_MenuSelection_Cmd(CI_AT_CMD_LINE_T *pCmdLine, const ZBL_CHANNEL_MSG_INFO *pMsg);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc/zbl_at_atdecode.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc/zbl_at_atdecode.h
index b20e600..cae05fa 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc/zbl_at_atdecode.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc/zbl_at_atdecode.h
@@ -365,6 +365,7 @@
static int Parse_BoardNum_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id);
int Parse_BoardNum_Ok(ZBL_CHANNEL_MSG_INFO **ppMsg, int nResult);
static int Parse_Zemci_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id);
+static int Parse_Zemsciq_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id);
int Parse_Zemci_Ok(ZBL_CHANNEL_MSG_INFO **ppMsg, int nResult);
static int Parse_Zuli_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id);
static int Parse_Zurdy_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id);
@@ -387,4 +388,8 @@
int Parse_ImsPlus_ok(ZBL_CHANNEL_MSG_INFO **ppMsg, int nResult);
int greaterSpace_info_act(char *at_paras ,int is_query_report);
+
+static int Parse_Csdh_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id);
+int Parse_Csdh_Ok(ZBL_CHANNEL_MSG_INFO **ppMsg, int nResult);
+
#endif /* xxxx_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/phone_adapt.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/phone_adapt.c
index 37d2277..bf9c1e8 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/phone_adapt.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/phone_adapt.c
@@ -124,6 +124,7 @@
register_psclt_func( ATI_SMS_ZMGR_REQ, 0, phone_app_msg_proc);
register_psclt_func( ATI_SMS_CMGL_REQ, 0, phone_app_msg_proc);
register_psclt_func( ATI_SMS_ZMENA_REQ, 0, phone_app_msg_proc);
+ register_psclt_func( ATI_SMS_CSDH_REQ, 0, phone_app_msg_proc);
//MM/SIM
register_psclt_func( ATI_MM_CNUM_REQ, 0, phone_app_msg_proc);
@@ -254,7 +255,7 @@
register_clt_func("CNMA=", phone_ok, phone_err);
register_clt_func("CMMS=", phone_ok, phone_err);
register_clt_func("ZMENA=", phone_ok, phone_err);
-
+ register_clt_func("CSDH=", phone_ok, phone_err);
//PB
register_clt_func("CPBW=", phone_ok, phone_err);
@@ -306,7 +307,7 @@
register_clt_func("ZEMLC=", phone_ok, phone_err);
register_clt_func("BOARDNUM?", phone_ok, phone_err);
register_clt_func("ZFLAG=", phone_ok, phone_err);
- register_clt_func("ZEMCI=", phone_ok, phone_err);
+ register_clt_func("ZEMSCIQ=", phone_ok, phone_err);
register_clt_func("ZURDY=", phone_ok, phone_err);
register_clt_func("ZURDY?", phone_ok, phone_err);
register_clt_func("ZUSLOT=", phone_ok, phone_err);
@@ -421,7 +422,7 @@
register_inform_func("ZUSLOT", phone_info_act);
register_inform_func("ZRAP", phone_info_act);
register_inform_func("BOARDNUM", phone_info_act);
- register_inform_func("ZEMCI", phone_info_act);
+ register_inform_func("ZEMSCIQ", phone_info_act);
register_inform_func("ZULI", phone_info_act);
register_inform_func("ZURDY", phone_info_act);
register_inform_func("ZUINIT", phone_info_act);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/src/zbl_at_atcode.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/src/zbl_at_atcode.c
index dae7a19..2c5b2fc 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/src/zbl_at_atcode.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/src/zbl_at_atcode.c
@@ -106,6 +106,7 @@
{ATI_SMS_CMMS_REQ, "+CMMS" , Make_Cmms_Cmd, NULLPTR},
{ATI_SMS_CMGR_REQ, "+CMGR", Make_Cmgr_Cmd, NULLPTR},
{ATI_SMS_CSCS_REQ, "+CSCS" , Make_SmsCscs_Cmd, NULLPTR},
+ {ATI_SMS_CSDH_REQ, "+CSDH" , Make_Csdh_Cmd, NULLPTR},
/* MM/SIM */
{ATI_MM_CFUN_REQ, "+CFUN" , Make_Cfun_Cmd, NULLPTR},
{ATI_MM_MODE_REQ, "^MODE", Make_Mode_Cmd, NULLPTR},
@@ -182,7 +183,7 @@
{ATI_MM_BOARDNUM_REQ, "+BOARDNUM" , Make_BoardNum_Cmd,NULLPTR},
{ATI_MM_BOOTSET_REQ, "+ZFLAG" , Make_BootSet_Cmd,NULLPTR},
{ATI_MM_MODESET_REQ, "+ZMODE" , Make_ModeSet_Cmd,NULLPTR},
- {ATI_MM_ZEMCI_REQ, "+ZEMCI" , Make_Zemci_Cmd, NULLPTR},
+ {ATI_MM_ZEMCI_REQ, "+ZEMSCIQ" , Make_Zemci_Cmd, NULLPTR},
{ATI_MM_ZURDY_REQ, "+ZURDY" , Make_Zurdy_Cmd, NULLPTR},
{ATI_MM_ZUSLOT_REQ, "+ZUSLOT" , Make_Zuslot_Cmd, NULLPTR},
{ATI_MM_ZUINIT_REQ, "+ZUINIT" , Make_Zuinit_Cmd, NULLPTR},
@@ -1936,6 +1937,31 @@
return 0;
}
+static SINT32 Make_Csdh_Cmd(CI_AT_CMD_LINE_T *pCmdLine, const ZBL_CHANNEL_MSG_INFO *pMsg)
+{
+ if(NULLPTR == pCmdLine || NULLPTR == pMsg || NULLPTR == pMsg->msgData)
+ {
+ return -1;
+ }
+ AtiCsdhReq *req_ptr = (AtiCsdhReq*)pMsg->msgData;
+
+
+ if(CMD_TYPE_SET == req_ptr->cmd_type)
+ {
+ strncpy(pCmdLine->strCmdOperator, "=", 2);
+ snprintf(pCmdLine->strCmdParas, AT_CMD_PARA_MAX_LEN-1, "%d", req_ptr->show);
+ }
+ else
+ {
+ return -1;
+ }
+
+ atiCmdIdSet(CMD_CSDH);
+
+ return 0;
+
+}
+
/* SIM/MM */
static SINT32 Make_Cfun_Cmd(CI_AT_CMD_LINE_T *pCmdLine, const ZBL_CHANNEL_MSG_INFO *pMsg)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/src/zbl_at_atdecode.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/src/zbl_at_atdecode.c
index ba01c34..ab67c7c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/src/zbl_at_atdecode.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/src/zbl_at_atdecode.c
@@ -189,7 +189,8 @@
/* MM/SIM*/
{"+ZRAP", Parse_Zrap_Res, NULLPTR},
{"+BOARDNUM", Parse_BoardNum_Res, NULLPTR},
- {"+ZEMCI", Parse_Zemci_Res, NULLPTR},
+ //{"+ZEMSCIQ", Parse_Zemci_Res, NULLPTR},
+ {"+ZEMSCIQ", Parse_Zemsciq_Res, NULLPTR},
{"+ZULI", Parse_Zuli_Res, NULLPTR},
{"+ZURDY", Parse_Zurdy_Res, NULLPTR},
{"+ZUINIT", Parse_Zuinit_Res, NULLPTR},
@@ -495,6 +496,7 @@
{CMD_SUSS, Parse_Suss_Ok},
{CMD_SPSMSFULL, Parse_Spsmsfull_Ok},
{CMD_SMSCSCS, Parse_SmsCscs_Ok},
+ {CMD_CSDH, Parse_Csdh_Ok},
/* MM/SIM */
{CMD_CFUN, Parse_Cfun_Ok},
{CMD_MODE, Parse_Mode_Ok},
@@ -1208,6 +1210,63 @@
return 0;
}
+static int atParseSplitString(CHAR* str, CHAR* delim, CHAR** result, int max)
+{
+ CHAR* token;
+ int i = 0;
+ for(i=0; i<max; i++)
+ {
+ result[i] = NULL;
+ }
+ i=0;
+ token = strtok(str, delim);
+ while((token != NULL) && (i < max))
+ {
+ printf("%s\n", token);
+ result[i] = token;
+ i++;
+ token = strtok(NULL, delim);
+ };
+ return i;
+}
+
+//È¥³ýÔ´×Ö·û´®Ç°ºóµÄ¿Õ¸ñºÍÒýºÅ
+static int atTrimCopyString(CHAR* pDst, CHAR* pSrc, int dstLen)
+{
+ CHAR* pBegin = pSrc;
+ CHAR* pEnd = NULL;
+ int len = 0;
+ if((pDst == NULL) || (pSrc == NULL))
+ {
+ return -1;
+ }
+ len = strlen(pSrc);
+ if(len == 0)
+ {
+ return -1;
+ }
+ printf("atTrimCopyString pSrc=%s\n", pSrc);
+ pEnd = pSrc + len-1;
+ while(*pBegin && (*pBegin == ' ' || *pBegin == '"' || *pBegin == '\r' || *pBegin == '\n'))
+ {
+ *pBegin = 0;
+ pBegin++;
+ }
+
+ while(*pEnd && (*pEnd == ' ' || *pEnd == '"' || *pEnd == '\r' || *pEnd == '\n'))
+ {
+ *pEnd = 0;
+ pEnd--;
+ }
+
+ if(pBegin<=pEnd)
+ {
+ strncpy(pDst, pBegin, dstLen-1);
+ }
+
+ printf("atTrimCopyString pDst=%s \n", pDst);
+}
+
static int Parse_Ate_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id)
{
if(NULLPTR == ppMsg)
@@ -4538,11 +4597,79 @@
return 0;
}
+static int Parse_Cmt_Text_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, AtiCmtParam* pCmtParam)
+{
+ AtiCmtTextInd *msg_ptr = NULLPTR;
+
+ *ppMsg = zblMallocChannelMsg(sizeof(AtiCmtTextInd));
+ if(NULLPTR == *ppMsg)
+ {
+ return -1;
+ }
+ ZTE_Trace(ZBL_AT, 0, "New text message send: %s", pRes);
+
+ (*ppMsg)->msgId = ATI_SMS_CMT_TEXT_IND;
+ (*ppMsg)->msgSize = sizeof(AtiCmtTextInd);
+ msg_ptr = (AtiCmtTextInd*)(*ppMsg)->msgData;
+ strncpy(msg_ptr->oa, pCmtParam->oa, sizeof(msg_ptr->oa)-1);
+ strncpy(msg_ptr->alpha, pCmtParam->alpha, sizeof(msg_ptr->alpha)-1);
+ memcpy(&msg_ptr->scts, &pCmtParam->scts, sizeof(AtiCmtScts));
+ msg_ptr->tooa = pCmtParam->tooa;
+ msg_ptr->fo = pCmtParam->fo;
+ msg_ptr->pid = pCmtParam->pid;
+ msg_ptr->dcs = pCmtParam->dcs;
+ strncpy(msg_ptr->sca, pCmtParam->sca, sizeof(msg_ptr->sca)-1);
+ msg_ptr->tosca = pCmtParam->tosca;
+
+ msg_ptr->length = pCmtParam->length;
+
+ //sprintf(msg_ptr->pdu, "%s", pRes);
+ atString2Bytes(pRes, msg_ptr->text, pCmtParam->length*2);
+
+ return 0;
+}
+
+//"23/04/23,15:14:25+32"
+static int Parse_Cmt_Scts_Date_Res(const CHAR* pStrScts, AtiCmtScts* pCmtSctsRes)
+{
+ CHAR* date[3];
+ printf("Parse_Cmt_Scts_Date_Res pStrScts=%s \n", pStrScts);
+ atParseSplitString(pStrScts, "/", date, 3);
+ pCmtSctsRes->year = atoi(date[0]);
+ pCmtSctsRes->month = atoi(date[1]);
+ pCmtSctsRes->day = atoi(date[2]);
+
+ return 0;
+}
+
+static int Parse_Cmt_Scts_Time_Res(const CHAR* pStrScts, AtiCmtScts* pCmtSctsRes)
+{
+ CHAR* pScts[2];
+ CHAR* date[3];
+ CHAR* time[3];
+ CHAR timezone[3] = {0};
+ printf("Parse_Cmt_Scts_Time_Res pStrScts=%s \n", pStrScts);
+ atParseSplitString(pStrScts, "+", pScts, 2);
+
+ atParseSplitString(pScts[0], ":", time, 3);
+ pCmtSctsRes->hours = atoi(time[0]);
+ pCmtSctsRes->minutes = atoi(time[1]);
+ pCmtSctsRes->seconds = atoi(time[2]);
+ strncpy(timezone, pScts[1], 2);
+ pCmtSctsRes->timezone = atoi(timezone);
+
+ return 0;
+}
int Parse_Cmt_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id)
{
static unsigned int length = 0;
-
+ static AtiCmtParam cmtParam = {0};
+ static UINT8 type = 0; //0:pdu 1:text
+ CHAR* result[11];
+ CHAR date[10] = {0};
+ CHAR time[20] = {0};
+ int count;
if(NULLPTR == ppMsg || NULLPTR == pRes)
{
zblAssert(0);
@@ -4554,7 +4681,63 @@
ZTE_Trace(ZBL_AT,0,"Parse_Cmt_Res head");
//if('\"' == pRes[2]) //ÓÉÓÚչѶ²»·ûºÏ¹æ·¶£¬ÏÈÆÁ±Î
{
- Parse_Cmt_Pre_Res(pRes, &length);
+ printf("pRes=%s\n", pRes);
+
+ count = atParseSplitString(&pRes[1], ",", result, 11);
+
+ printf("count=%d\n", count);
+ if(count > 2) //textÀàÐͶÌÐÅ
+ {
+ type = 1;
+ #if 0
+ strncpy(cmtParam.oa, result[0], sizeof(cmtParam.oa)-1);
+ strncpy(cmtParam.alpha, result[1], sizeof(cmtParam.alpha)-1);
+ Parse_Cmt_Scts_Date_Res(result[2], &cmtParam.scts);
+ Parse_Cmt_Scts_Time_Res(result[3], &cmtParam.scts);
+ strncpy(cmtParam.tooa, result[4], sizeof(cmtParam.tooa)-1);
+ cmtParam.fo = atoi(result[5]);
+ cmtParam.pid = atoi(result[6]);
+ cmtParam.dcs = atoi(result[7]);
+ strncpy(cmtParam.sca, result[8], sizeof(cmtParam.sca)-1);
+ strncpy(cmtParam.tosca, result[9], sizeof(cmtParam.tosca)-1);
+ length = atoi(result[10]);
+ cmtParam.length = length;
+ #endif
+ atTrimCopyString(cmtParam.oa, result[0], sizeof(cmtParam.oa)-1);
+ atTrimCopyString(cmtParam.alpha, result[1], sizeof(cmtParam.alpha)-1);
+ atTrimCopyString(date, result[2], sizeof(date)-1);
+ Parse_Cmt_Scts_Date_Res(date, &cmtParam.scts);
+ atTrimCopyString(time, result[3], sizeof(time)-1);
+ Parse_Cmt_Scts_Time_Res(time, &cmtParam.scts);
+ if(result[4] != NULL)
+ cmtParam.tooa = atoi(result[4]);
+
+ if(result[5] != NULL)
+ cmtParam.fo = atoi(result[5]);
+
+ if(result[6] != NULL)
+ cmtParam.pid = atoi(result[6]);
+
+ if(result[7] != NULL)
+ cmtParam.dcs = atoi(result[7]);
+ atTrimCopyString(cmtParam.sca, result[8], sizeof(cmtParam.sca)-1);
+
+ if(result[9] != NULL)
+ cmtParam.tosca = atoi(result[9]);
+
+ if(result[10] != NULL)
+ length = atoi(result[10]);
+
+ cmtParam.length = length;
+ }
+ else //pdu¶ÌПñʽ
+ {
+ type = 0;
+ //Parse_Cmt_Pre_Res(pRes, &length);
+ if(result[1] != NULL)
+ length = atoi(result[1]);
+ }
+
}
//else
//{
@@ -4566,7 +4749,14 @@
else
{
ZTE_Trace(ZBL_AT,0,"phone_info_act pdu");
- Parse_Cmt_Pdu_Res(ppMsg, pRes, length);
+ if(0 == type) //pdu
+ {
+ Parse_Cmt_Pdu_Res(ppMsg, pRes, length);
+ }
+ else if(1 == type) //text
+ {
+ Parse_Cmt_Text_Res(ppMsg, pRes, &cmtParam);
+ }
bNewMsgRcv = FALSE;
length = 0;
}
@@ -4610,6 +4800,62 @@
return 0;
}
+static int Parse_Csdh_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id)
+{
+ AtiCsdhCnf * msg_ptr = NULLPTR;
+ unsigned int show = 0;
+
+
+ //if(isdigit(pRes[2])) // ÉèÖÃÃüÁîµÄ·µ»Ø
+ if((pRes[2] >= '0') && (pRes[2] <= '9'))
+ {
+ sscanf(&pRes[2], "%u", &show);
+ }
+ else
+ {
+ return -1;
+ }
+
+ *ppMsg = zblMallocChannelMsg(sizeof(AtiCsdhCnf));
+ if(NULLPTR == *ppMsg)
+ {
+ return -1;
+ }
+
+ (*ppMsg)->msgId = ATI_SMS_CSDH_CNF;
+ (*ppMsg)->msgSize = sizeof(AtiCsdhCnf);
+ msg_ptr = (AtiCsdhCnf*)(*ppMsg)->msgData;
+ msg_ptr->result = 0;
+ msg_ptr->show = show;
+
+ zbl_chm_CmdIdSet(iChannel_id, CMD_NON);
+
+ return 0;
+}
+
+int Parse_Csdh_Ok(ZBL_CHANNEL_MSG_INFO **ppMsg, int nResult)
+{
+ AtiCsdhCnf *msg_ptr = NULLPTR;
+
+ if(NULLPTR == ppMsg)
+ {
+ return -1;
+ }
+
+ *ppMsg = zblMallocChannelMsg(sizeof(AtiCsdhCnf));
+ if(NULLPTR == *ppMsg)
+ {
+ return -1;
+ }
+
+ (*ppMsg)->msgId = ATI_SMS_CSDH_CNF;
+ (*ppMsg)->msgSize = sizeof(AtiCsdhCnf);
+ msg_ptr = (AtiCsdhCnf*)(*ppMsg)->msgData;
+ msg_ptr->result = nResult;
+
+ return 0;
+}
+
extern CHAR SmsCmgwPduSend[ATI_MAX_SMS_PDU_LENGTH] ;
extern CHAR SmsCmgsPduSend[ATI_MAX_SMS_PDU_LENGTH] ;
extern CHAR SmsCnmaPduSend[ATI_MAX_SMS_PDU_LENGTH] ;
@@ -8018,6 +8264,30 @@
return 0;
}
+static int Parse_Zemsciq_Res(ZBL_CHANNEL_MSG_INFO **ppMsg, const CHAR *pRes, unsigned int nSize, unsigned int iChannel_id)
+{
+ char *msg_ptr = NULLPTR;
+
+ int para_len = strlen(pRes)+1;
+ *ppMsg = zblMallocChannelMsg(sizeof(para_len));
+ if(NULLPTR == *ppMsg || NULLPTR == pRes)
+ {
+ return -1;
+ }
+
+ msg_ptr = (char*)(*ppMsg)->msgData;
+ (*ppMsg)->msgSize = para_len;
+ memcpy(msg_ptr, pRes, para_len-1);
+ //printf("zemsciq res len %d text %s", para_len, msg_ptr);
+
+
+
+ (*ppMsg)->msgId = ATI_MM_ZEMCI_IND;
+ //(*ppMsg)->msgSize = sizeof(AtiZemciInd);
+
+ return 0;
+}
+
int Parse_Zemci_Ok(ZBL_CHANNEL_MSG_INFO **ppMsg, int nResult)
{
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fota_upi_ab/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fota_upi_ab/Makefile
new file mode 100755
index 0000000..694a25d
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fota_upi_ab/Makefile
@@ -0,0 +1,122 @@
+# /*****************************************************************************
+#* °æÈ¨ËùÓÐ (C)2015, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+#*
+#* ÎļþÃû³Æ: Makefile
+#* Îļþ±êʶ: Makefile
+#* ÄÚÈÝÕªÒª: Makefile of ZTE applications
+#* ʹÓ÷½·¨: void
+#*
+#* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+#* -----------------------------------------------------------------------------
+#* 2022/07/13 V1.0 Create zln ´´½¨
+#*
+# ******************************************************************************/
+
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+.EXPORT_ALL_VARIABLES:
+include $(COMMON_MK)
+#*******************************************************************************
+# execute
+#*******************************************************************************
+EXEC = fota_upi_ab
+
+#*******************************************************************************
+# objects
+#*******************************************************************************
+SRCS=$(wildcard ./src/*.c)
+OBJS = $(patsubst %.c,%.o,$(SRCS))
+
+#*******************************************************************************
+# include path
+#*******************************************************************************
+
+
+
+CFLAGS += -Wall -g
+
+CFLAGS += -Werror=implicit-int \
+ -Werror=implicit-function-declaration \
+ -Werror=float-equal \
+ -Werror=return-type \
+ -Werror=enum-compare \
+ -Werror=init-self
+
+CFLAGS += -O2
+CFLAGS += -I../include
+CFLAGS += -I./inc \
+ -I$(zte_lib_path)/libssl/install/include \
+ -I$(zte_lib_path)/libupi_ab/inc
+#*******************************************************************************
+# macro definition
+#*******************************************************************************
+
+ifeq ($(PRJ_IS_MIN),yes)
+
+CFLAGS += -D_IS_MIN
+
+endif
+
+ifeq ($(CONFIG_USER_FOTA_OPEN_SOURCE),n)
+CFLAGS += -D_USE_SYSTEM_COMMAND
+endif
+
+
+#*******************************************************************************
+# library
+#*******************************************************************************
+#LDLIBS += -lsoft_timer_sc -L$(zte_lib_path)/libsoft_timer
+
+LDLIBS += -lpthread
+#LDLIBS += -lsoftap
+#LDLIBS += -lnvram_sc
+
+# SHA512 functions in libcrypto.a not libssl
+#LDLIBS += -lssl
+#LDLIBS += -lcrypto
+#LDLIBS += -L$(zte_lib_path)/libssl/install/lib
+#LDLIBS += -L$(zte_lib_path)/libnvram
+#LDLIBS += -L$(zte_lib_path)/libsoftap
+
+#LDLIBS += -lcpnv -L$(LIB_DIR)/libcpnv
+
+CFLAGS += -I$(LIB_DIR)/libnvram
+CFLAGS += -I$(LIB_DIR)/libsoftap
+CFLAGS += -I$(LIB_DIR)/libsofttimer
+
+LDLIBS += -lmtd
+LDLIBS += -lnvram -L$(LIB_DIR)/libnvram
+LDLIBS += -lsofttimer -L$(LIB_DIR)/libsofttimer
+LDLIBS += -latutils -L$(LIB_DIR)/libatutils
+LDLIBS += -lsoftap -L$(LIB_DIR)/libsoftap
+
+LDLIBS += -lupi_ab
+LDLIBS += -L$(zte_lib_path)/libupi_ab
+
+#CFLAGS += -I$(zte_lib_path)/libnvram
+
+#*******************************************************************************
+# library path
+#*******************************************************************************
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ $(CC) $(LD_BEGIN) -static $(LDFLAGS) -o $@_static $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group $(LD_END)
+ cp $(EXEC) $(EXEC).elf
+ cp $(EXEC)_static $(EXEC)_static.elf
+
+
+
+romfs root_fs:
+ $(ROMFSINST) /bin/$(EXEC)_static
+
+
+clean:
+ -rm -f $(EXEC) $(EXEC)_static *.elf *.gdb *.o ./src/*.o
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fota_upi_ab/src/main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fota_upi_ab/src/main.c
new file mode 100755
index 0000000..b30ea01
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fota_upi_ab/src/main.c
@@ -0,0 +1,518 @@
+/**
+* @file main.c
+* @brief fotaÉý¼¶Ö÷Èë¿Ú
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+*/
+
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <dirent.h>
+#include <getopt.h>
+#include <unistd.h>
+
+//#include "upi_log.h"
+#include "zxic_fota_ab_upgrade.h"
+//#include "upi_fotaflag_partition.h"
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+
+#define POWER_WAKE_LOCK_FILE ("/sys/power/wake_lock")
+#define POWER_WAKE_UNLOCK_FILE ("/sys/power/wake_unlock")
+#define FOTA_UPGRADE_LOCK ("fota_upgrade_lock")
+
+#define FOTA_UPI_VERIFY ("verify")
+#define FOTA_UPI_UPDATE ("update")
+
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+
+typedef struct {
+ int option_value;
+ int (*func)(char *);
+} option_handle_t;
+
+
+
+/*******************************************************************************
+ * Static function declarations *
+ ******************************************************************************/
+
+
+static int excute_command_upgrade(char * option_para);
+static int excute_command_get_current_system(char * option_para);
+static int excute_command_set_boot_to_system(char * option_para);
+static int excute_command_get_boot_to_system(char * option_para);
+static int excute_command_get_status(char * option_para);
+static int excute_command_get_system_info(char * option_para);
+static int excute_command_set_system1_status(char * option_para);
+static int excute_command_set_system2_status(char * option_para);
+static int excute_command_get_fota_status(char * option_para);
+static int excute_command_set_fota_status(char * option_para);
+static int excute_command_help(char * option_para);
+static int execute_command_version(char * option_para);
+static int execute_command_sync(char *option_para);
+static int execute_command_get_upgrade_type(char *option_para);
+static int execute_command_get_sync_status(char * option_para);
+static int execute_command_set_sync_status(char * option_para);
+
+
+
+/*******************************************************************************
+ * Global variable declarations *
+ ******************************************************************************/
+
+/*----------Command parser begin---------------------------------------------------------*/
+
+static char * g_short_string = "u:cgb:sio:t:qr:hvypne:";
+
+static struct option g_long_options[] = {
+ {"upgrade", required_argument, NULL, 'u'},
+ {"get-current", no_argument, NULL, 'c'},
+ {"get-boot", no_argument, NULL, 'g'},
+ {"set-boot", required_argument, NULL, 'b'},
+ {"get-upgrade_status", no_argument, NULL, 's'},
+ {"get-system-info", no_argument, NULL, 'i'},
+ {"set-system1-status", required_argument, NULL, 'o'},
+ {"set-system2-status", required_argument, NULL, 't'},
+ {"get-fota-status", no_argument, NULL, 'q'},
+ {"set-fota-status", required_argument, NULL, 'r'},
+ {"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'v'},
+ {"sync", no_argument, NULL, 'y'},
+ {"get-upgrade-type", no_argument, NULL, 'p'},
+ {"get-sync-status", no_argument, NULL, 'n'},
+ {"set-sync-status", required_argument, NULL, 'e'},
+ {0, 0, 0, 0}
+};
+
+static option_handle_t g_option_handle[] = {
+ {'u', excute_command_upgrade},
+ {'c', excute_command_get_current_system},
+ {'g', excute_command_get_boot_to_system},
+ {'b', excute_command_set_boot_to_system},
+ {'s', excute_command_get_status},
+ {'i', excute_command_get_system_info},
+ {'o', excute_command_set_system1_status},
+ {'t', excute_command_set_system2_status},
+ {'q', excute_command_get_fota_status},
+ {'r', excute_command_set_fota_status},
+ {'h', excute_command_help},
+ {'v', execute_command_version},
+ {'y', execute_command_sync},
+ {'p', execute_command_get_upgrade_type},
+ {'n', execute_command_get_sync_status},
+ {'e', execute_command_set_sync_status}
+};
+
+
+/*----------Command parser end----------------------------------------------------------*/
+
+
+
+/*******************************************************************************
+ * Static function define *
+ ******************************************************************************/
+
+
+
+
+static void usage(void)
+{
+ printf("fota_upi [-cgsiqhvypn] [-u <target>][-b <boot to system>][-otr <system info>][-e <sync status>]\n "
+ " -u, --upgrade verify or update \n"
+ " -c , --get-current get current system \n"
+ " -g , --get-boot get boot to system \n"
+ " -b, --set-boot set boot to system \n"
+ " -s, --get-status get system status \n"
+ " -i, --get-system-info get system info \n"
+ " -o, --set-system1-status set system1 status info \n"
+ " -t, --set-system2-status set system2 status info \n"
+ " -q, --get-fota-status get fota status to show if need sync NV when next reboot, 0:no 1:yes \n"
+ " -r, --set-fota-status set fota status to show if need sync NV when next reboot, 0:no 1:yes \n"
+ " -h , --help show this usage text\n"
+ " -v, --version show current version \n"
+ " -y, --sync sync \n"
+ " -p, --get-upgrade-type get upgrade type \n"
+ " -n, --get-sync-status get sync status \n"
+ " -e, --set-sync-status set sync status \n");
+}
+
+z_upgrade_status_info_t g_upgrade_status;
+void g_flush_upgrade_status(z_upgrade_status_info_t *p_status)
+{
+// LOG_FUNC_BEGIN
+ printf("Current status:%d \n", p_status->upgrade_status);
+
+ printf("Total size:%d \n", p_status->total_size);
+
+ printf("Updated size:%d \n", p_status->upgraded_size);
+// LOG_FUNC_END
+}
+
+
+/*----------Command parser function begin------------------------------------------------*/
+static int excute_command_upgrade(char * option_para)
+{
+ int ret = -1;
+
+ if (NULL == option_para) {
+ usage();
+ printf("Command input invalid! null input upgrade para, please choose verify or recovery or system! \n");
+ return -1;
+ }
+
+
+ if (0 == strcmp(FOTA_UPI_VERIFY, option_para)) {
+ printf("Begin to verify upgrade package \n");
+ ret = zxic_dual_verify();
+ } else if (0 == strcmp(FOTA_UPI_UPDATE, option_para)) {
+// ret = upi_update();
+ z_upgrade_flush_status_t flush_status;
+ z_upgrade_status_info_t status ;
+ memset(&status, 0, sizeof(z_upgrade_status_info_t));
+ flush_status.status = &status;
+ flush_status.status_cb = &g_flush_upgrade_status;
+ ret = zxic_dual_upgrade(&flush_status);
+ } else {
+ printf("Unknow input upgrade para, verify or update! \n");
+ return -1;
+ }
+
+
+ return ret;
+}
+
+
+static int excute_command_get_current_system(char * option_para)
+{
+ int current = zxic_dual_get_current_system();
+
+ printf("Current system:0x%08X[%d] \n", current, current);
+
+ return current;
+}
+
+
+static int excute_command_get_boot_to_system(char * option_para)
+{
+ int boot_to = zxic_dual_get_boot_to_system();
+
+ printf("Boot to system:0x%08X[%d]\n", boot_to, boot_to);
+
+ return 0;
+}
+
+static int excute_command_set_boot_to_system(char * option_para)
+{
+ int ret = 0;
+
+ if (NULL == option_para) {
+ usage();
+ printf("Command input invalid value! null option parameters! \n");
+ return -1;
+ }
+
+ ret = zxic_dual_set_boot_to_system(atoi(option_para), 0);
+ if(ret < 0){
+ printf("Set boot to [%s] error \n", option_para);
+ }
+
+ return ret;
+}
+
+
+static int excute_command_get_status(char *option_para)
+{
+ z_upgrade_status_info_t status;
+ if(zxic_dual_get_upgrade_status(&status) < 0){
+ printf("Get upgrade status fail! \n");
+ return -1;
+ }
+
+ printf("Current upgrade info: \n");
+ printf("Current upgrade status:%d \n", status.upgrade_status);
+ printf("Current upgrade total size:%d \n", status.total_size);
+ printf("Current upgrade updated size:%d \n", status.upgraded_size);
+
+ return 0;
+}
+
+static int excute_command_get_system_info(char * option_para)
+
+{
+ z_upgrade_system_info_t system_info;
+ if(zxic_dual_get_system_status(&system_info) < 0){
+ printf("Get upgrade status fail! \n");
+ return -1;
+ }else{
+ printf("System info: \n");
+ printf("Boot to:0x%08X[%d] \n", system_info.boot_to, system_info.boot_to);
+ printf("Fota status:%d \n", system_info.fota_status);
+ printf("System1 system:0x%08X [%d] \n", system_info.system_1.system, system_info.system_1.system);
+ printf("System1 status:%d \n", system_info.system_1.status);
+ printf("System1 try_cnt:%d \n", system_info.system_1.try_cnt);
+ printf("System2 system:0x%08X [%d] \n", system_info.system_2.system, system_info.system_2.system);
+ printf("System2 status:%d \n", system_info.system_2.status);
+ printf("System2 try_cnt:%d \n", system_info.system_2.try_cnt);
+ }
+
+
+ return 0;
+}
+
+
+static int excute_command_set_system1_status(char * option_para)
+{
+ int ret = -1;
+ if (NULL == option_para) {
+ usage();
+ printf("Command input invalid value! null option parameters! \n");
+ return -1;
+ }
+
+ ret = zxic_dual_set_system_status(34650, atoi(option_para));
+ if(ret < 0){
+ printf("Set system 1 status to [%s] error \n", option_para);
+ }
+
+ return ret;
+}
+
+static int excute_command_set_system2_status(char * option_para)
+{
+ int ret = -1;
+ if (NULL == option_para) {
+ usage();
+ printf("Command input invalid value! null option parameters! \n");
+ return -1;
+ }
+
+ ret = zxic_dual_set_system_status(39019, atoi(option_para));
+ if(ret < 0){
+ printf("Set system 2 status to [%s] error \n", option_para);
+ }
+
+ return ret;
+}
+
+static int excute_command_get_fota_status(char * option_para)
+{
+ int status = zxic_dual_get_fota_status_for_nv();
+
+ printf("Fota status:%d \n", status);
+
+ return 0;
+}
+
+static int excute_command_set_fota_status(char * option_para)
+{
+ int ret = 0;
+
+ if (NULL == option_para) {
+ usage();
+ printf("Command input invalid value! null option parameters! \n");
+ return -1;
+ }
+
+ ret = zxic_dual_set_fota_status_for_nv(atoi(option_para));
+ if(ret < 0){
+ printf("Set fota_status to [%s] error \n", option_para);
+ }
+
+ return ret;
+}
+
+
+static int excute_command_help(char * option_para)
+{
+ usage();
+ return 0;
+}
+
+
+
+
+
+static int execute_command_version(char *option_para)
+{
+ int version = 0;
+
+
+ return version;
+}
+
+
+
+
+
+static int execute_command_sync(char *option_para)
+{
+ int ret = -1;
+
+ ret = zxic_dual_sync_system();
+
+ return ret;
+}
+
+
+
+
+
+static int execute_command_get_upgrade_type(char *option_para)
+{
+ int upgrade_type = -1;
+
+ upgrade_type = zxic_dual_get_upgrade_type();
+ printf("upgrade type is %d\n", upgrade_type);
+
+ return 0;
+}
+
+
+static int execute_command_get_sync_status(char * option_para)
+{
+ int sync_status = -2;
+
+ zxic_dual_get_sync_status(&sync_status);
+ printf("Current sync status is %d\n", sync_status);
+
+ return 0;
+}
+
+
+static int execute_command_set_sync_status(char * option_para)
+{
+ int ret = -1;
+
+ if (NULL == option_para) {
+ usage();
+ printf("Command input invalid value! null option parameters! \n");
+
+ return ret;
+ }
+
+ ret = zxic_dual_set_sync_status(atoi(option_para));
+ if (0 != ret)
+ {
+ printf("set sync status fail\n");
+
+ return ret;
+ }
+
+ ret = 0;
+
+ return ret;
+}
+
+
+/*----------Command parser function end---------------------------------------------------*/
+
+
+/**
+ * @brief Ð´ËøÎļþ
+ * @param filepath: Îļþ·¾¶
+ * @param setbuf: дÈëÄÚÈÝ
+ * @return NA
+ * @retval
+ * @note
+ */
+static void write_lockfile(char *filepath, char *setbuf)
+{
+ int f, len = 0;
+
+ f = open(filepath, O_RDWR | O_SYNC);
+ if (f == -1) {
+ perror("open lock failed\n");
+ return;
+ }
+
+ len = strlen(setbuf);
+
+ if (write(f, setbuf, len) != len) {
+ perror("write lock failed\n");
+ }
+
+ close(f);
+}
+
+/*******************************************************************************
+ * Global function declarations *
+ ******************************************************************************/
+
+int main(int argc, char *argv[])
+{
+ int i = 0;
+ int option_index = 0;
+ int cmd_num = 0;
+
+ int ret = -1;
+ int ch = -1;
+
+ printf("build date: %s %s\n", __DATE__, __TIME__);
+
+
+ write_lockfile(POWER_WAKE_LOCK_FILE, FOTA_UPGRADE_LOCK);
+
+ while ((ch = getopt_long(argc, argv, g_short_string, g_long_options, &option_index)) != -1) {
+ for (i = 0; i < sizeof(g_option_handle) / sizeof(option_handle_t); i++) {
+ if (ch != g_option_handle[i].option_value)
+ continue;
+
+
+ cmd_num++;
+
+ if (NULL == g_option_handle[i].func) {
+ printf("Command short string is:%c, but option handle func is NULL", ch);
+ break;
+ }
+
+ ret = g_option_handle[i].func(optarg);
+
+ if (ret < 0) {
+ ret = -1;
+ goto end;
+ }
+ }
+ }
+
+ if (0 == cmd_num) {
+ printf("Can not find valid command!");
+ usage();
+ ret = -1;
+ goto end;
+ }
+
+ ret = 0;
+
+end:
+
+ write_lockfile(POWER_WAKE_UNLOCK_FILE, FOTA_UPGRADE_LOCK);
+
+ return ret ;
+
+}
+
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/Makefile
index dcc064a..c4f5c71 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/Makefile
@@ -11,7 +11,7 @@
#LDLIBS = -lpthread -lm
-LDLIBS += -lnvram
+LDLIBS += -lnvram -lmtd
#LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
#LDLIBS += -lsofttimer -L$(zte_lib_path)/libsofttimer
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/fscheck.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/fscheck.c
index dbf6ab3..9bcc8a3 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/fscheck.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/fscheck.c
@@ -6,7 +6,7 @@
#include "iniparser.h"
#include "fscheck.h"
//#include "pub_flags.h"
-//#include "flags_api.h"
+#include "mtd_api.h"
/*******************************************************************************
* 宏定义 *
@@ -50,18 +50,17 @@
/*******************************************************************************
* 全局变量定义 *
*******************************************************************************/
-static int s_check_file_num = 0;
+static int s_check_file_num[MAX_INI_SEC_NUM] = {0};
static char s_ini_file_name[MAX_FILE_NAME_LEN] = {0};
-static char s_file_name[MAX_FS_INFO_FILE_NUM][MAX_FILE_NAME_LEN] = {0};
+static char s_file_name[MAX_INI_SEC_NUM][MAX_FS_INFO_FILE_NUM][MAX_FILE_NAME_LEN] = {0};
static struct mtd_fs fs_array[MAX_INI_SEC_NUM] = {0};
/*******************************************************************************
* 外部引用函数 *
*******************************************************************************/
extern int mount_fs_partition(struct mtd_fs *p_fs);
-extern int mtd_erase_partition(const char* partition_name);
-extern int mtd_write_partition(const char* partition_name, const char* image_file);
extern int unmount_fs_partition(struct mtd_fs *p_fs);
extern int check_file_is_normal(const char *pFile);
+extern int wipe_out_vol_ubi(struct mtd_fs *p_fs);
/*******************************************************************************
* 内部函数 *
@@ -110,7 +109,6 @@
**************************************************************************/
static int getVal_int(const dictionary *d, const char *sec_name, const char *key_name)
{
- int val;
char buf[MAX_INI_KEY_LEN] = {0};
if (sec_name)
@@ -132,16 +130,15 @@
* index: 结构体成员对应枚举序号
* secIndex: ini文件section序号
* (OUT)
-* 返 回 值:成功返回int型value, 否则返回 RET_INI_INVALID_KEY_INT
+* 返 回 值:成功返回0
* 其它说明:
**************************************************************************/
static int getVal(const dictionary *d, const char *sec_name, int index, int secIndex)
{
const char *strVal;
int val;
- int i = 0;
+ int file_num = 0;
char file_name_total[MAX_INI_VAL_LEN];
- char temp[MAX_FILE_NAME_LEN];
switch (index)
{
@@ -209,21 +206,21 @@
char *p = strtok(file_name_total, " ");
while(p)
{
- strncpy(s_file_name[i], p, sizeof(s_file_name[i]) - 1);
- fs_array[secIndex].file[i] = (char *)s_file_name[i];
- // printf("file[%d]:[%s]\n", i, fs_array[secIndex].file[i]);
+ strncpy(s_file_name[secIndex][file_num], p, sizeof(s_file_name[file_num]) - 1);
+ fs_array[secIndex].file[file_num] = (char *)s_file_name[secIndex][file_num];
+ printf("fs_check: getVal, secIndex = %d, file[%d]:[%s]\n",secIndex, file_num, fs_array[secIndex].file[file_num]);
p = strtok(NULL," ");
- i++;
- if(i >= MAX_FS_INFO_FILE_NUM)
+ file_num++;
+ if(file_num >= MAX_FS_INFO_FILE_NUM)
{
- s_check_file_num = i;
break;
}
}
+ s_check_file_num[secIndex] = file_num;
}
break;
default:
- printf("[fscheck]: getVal, index = %d\n", index);
+ printf("fscheck: getVal, index is not exist, %d\n", index);
break;
}
@@ -235,7 +232,7 @@
* 参数说明: (IN)
* d: dictionary结构体指针
* (OUT)
-* 返 回 值:成功返回-1, 否则返回 section个数
+* 返 回 值:成功返回section个数, 否则返回-1
* 其它说明:
**************************************************************************/
static int getValToArray(const dictionary *d)
@@ -276,12 +273,13 @@
return nsec;
}
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
int i,j;
int ch;
int ret;
- int result;
+ int result = 0;
dictionary *ini;
int fs_cnt;
@@ -309,8 +307,9 @@
iniparser_freedict(ini);
//normal版本文件系统挂载
- for(i = 0; i < fs_cnt; i++) {
- printf("fs_check mount_fs_partition begin\n");
+ for (i = 0; i < fs_cnt; i++)
+ {
+ printf("fs_check mount_fs_partition begin\n");
ret = mount_fs_partition(&fs_array[i]);
if(ret)
{
@@ -326,22 +325,31 @@
else
{
//挂载成功后检查文件是否被破坏,如果破坏则恢复
- for(j = 0; j < s_check_file_num; j++)
+ for(j = 0; j < s_check_file_num[i]; j++)
{
result = check_file_is_normal(fs_array[i].file[j]);
if(result < 0)
- {
+ {
+ printf("fs_check: check_file_is_normal failed, fs_array[%d].file[%d] = %s\n", i, j, fs_array[i].file[j]);
break;
}
}
if(result)
{
unmount_fs_partition(&fs_array[i]);
- //printf("fs_check mount %s fail\n", fs_array[i].patition_name);
- mtd_erase_partition(fs_array[i].patition_name);
- printf("fs_check mtd_erase %s\n", fs_array[i].patition_name);
- ret = mtd_write_partition(fs_array[i].patition_name, fs_array[i].image_file);
- printf("fs_check mtd_write %s ret = %d\n", fs_array[i].patition_name, ret);
+
+ if (strcmp(fs_array[i].fs_type, "jffs2") == 0)
+ {
+ mtd_erase_partition(fs_array[i].patition_name);
+ printf("fs_check mtd_erase %s\n", fs_array[i].patition_name);
+ ret = mtd_write_partition(fs_array[i].patition_name, fs_array[i].image_file);
+ printf("fs_check mtd_write %s ret = %d\n", fs_array[i].patition_name, ret);
+ }
+ else if (strcmp(fs_array[i].fs_type, "ubifs") == 0)
+ {
+ wipe_out_vol_ubi(&fs_array[i]);
+ }
+
ret = mount_fs_partition(&fs_array[i]);
if(ret)
assert(0);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/mtd.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/mtd.c
index 7f3f0b6..c0d2b1b 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/mtd.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/fscheck/mtd.c
@@ -15,40 +15,44 @@
#include <sys/ioctl.h>
#include "fscheck.h"
#include "cfg_api.h"
-//#include "pub_flags.h"
-//#include "flags_api.h"
-
+#include "mtd_api.h"
/*******************************************************************************
* Macro definitions *
******************************************************************************/
-#define MOUNTS_INFO_FILE "/proc/mounts"
+#define MOUNTS_INFO_FILE ("/proc/mounts")
-#define NV_FS_FAC_MAIN_PATH "/mnt/imagefs/nvrwall.bin"
-#define NV_FS_RW_HASH_FAC_PATH "/mnt/imagefs/nvrwall.hash"
-#define NV_FS_RW_HASH_WORK_PATH "/etc_rw/psnv/nvrwall.hash"
-#define NV_FS_RW_MAIN_PATH "/etc_rw/psnv/rw_work"
-#define NV_FS_RW_BACKUP_PATH "/etc_rw/psnv/rw_backup"
-#define NV_FS_FAC_SYMBOL_PATH "/etc_rw/psnv/fac_flag"
-#define NV_FS_RW_MAIN_SYMBOL_PATH "/etc_rw/psnv/work_flag"
-#define NV_FS_RW_BACKUP_SYMBOL_PATH "/etc_rw/psnv/backup_flag"
+#define NV_FS_FAC_MAIN_PATH ("/mnt/imagefs/nvrwall.bin")
+#define NV_FS_RW_HASH_FAC_PATH ("/mnt/imagefs/nvrwall.hash")
+#define NV_FS_RW_HASH_WORK_PATH ("/etc_rw/psnv/nvrwall.hash")
+#define NV_FS_RW_MAIN_PATH ("/etc_rw/psnv/rw_work")
+#define NV_FS_RW_BACKUP_PATH ("/etc_rw/psnv/rw_backup")
+#define NV_FS_FAC_SYMBOL_PATH ("/etc_rw/psnv/fac_flag")
+#define NV_FS_RW_MAIN_SYMBOL_PATH ("/etc_rw/psnv/work_flag")
+#define NV_FS_RW_BACKUP_SYMBOL_PATH ("/etc_rw/psnv/backup_flag")
-#define NV_FS_RW_AP_NV_MAIN_PATH "/etc_rw/nv/main/cfg"
-#define NV_FS_RW_AP_NV_BACKUP_PATH "/etc_rw/nv/backup/cfg"
+#define NV_FS_RW_AP_NV_MAIN_PATH ("/etc_rw/nv/main/cfg")
+#define NV_FS_RW_AP_NV_BACKUP_PATH ("/etc_rw/nv/backup/cfg")
-#define MOUNTS_LINE_LEN (256)
-#define MOUNTS_LINE_ELEMENT_LEN (64)
-#define MAX_PATH (256)
-#define BUF_MAX_LEN (32)
-#define UBI_DEV_MAX_NUM (10)
-#define SYSTEM_EXEC_FAIL (0)
-#define SYSTEM_EXEC_SUCC (1)
+#define MOUNTS_LINE_LEN (256)
+#define MOUNTS_LINE_ELEMENT_LEN (64)
+#define MAX_PATH (256)
+#define BUF_MAX_LEN (32)
+#define UBI_DEV_MAX_NUM (10)
+#define SYSTEM_EXEC_FAIL (0)
+#define SYSTEM_EXEC_SUCC (1)
+#define FS_MAX_MOUNT_TIMES (2)
-typedef enum {
- DEVICE_MTD = 0,
- DEVICE_ZFTL = 1,
- DEVICE_MTD_BLOCK,
-} device_type_t;
+/*******************************************************************************
+ * ÄÚ²¿º¯Êý *
+ *******************************************************************************/
+static int check_mount_result(const char *parti_mp);
+static int system_exec_status(int status);
+static int get_ubifs_device_num(int recv_mtdnum);
+static int get_vol_id(int ubi_num, char *vol_name);
+static int get_ubi_device_num(const char *dev_path, int *major_num, int *minor_num);
+static int check_ubi_device_is_char(const char *dev_path);
+static int mknod_ubi_device(void);
static int check_mount_result(const char *parti_mp)
{
@@ -107,66 +111,7 @@
return -1;
}
-int mtd_find(const char *i_parti_name, char *o_mtd_path, device_type_t device_type, unsigned int o_mtd_path_len)
-{
- FILE *fd_mtd = 0;
- char buf[128];
- char *line_str;
-
- if (!o_mtd_path_len)
- return -1;
-
- fd_mtd = fopen("/proc/mtd", "r+");
- if (NULL == fd_mtd) {
- printf("fs_check open file error:%s", strerror(errno));
- goto error0;
- }
- //printf("fs_check partition name:%s\n", i_parti_name);
-
- while (1) {
- int matches = 0;
- char mtdname[64] = {0};
- int mtdnum = 0;
- unsigned int mtdsize, mtderasesize;
- memset(buf, 0x00, sizeof(buf));
- line_str = fgets(buf, sizeof(buf), fd_mtd);
-
- if (NULL == line_str) {
- printf("fs_check get info from mtd error:%s\n", strerror(errno));
- goto error1;
- }
- //mtd5: 00100000 00020000 "fotaflag"
- matches = sscanf(buf, "mtd%d: %x %x \"%63[^\"]",
- &mtdnum, &mtdsize, &mtderasesize, mtdname);
- mtdname[63] = '\0';
-
- if ((matches == 4) && (strcmp(mtdname, i_parti_name) == 0)) {
- memset(o_mtd_path, 0x00, o_mtd_path_len);
- if (device_type == DEVICE_MTD_BLOCK) {
- snprintf(o_mtd_path, o_mtd_path_len, "/dev/mtdblock%d", mtdnum);
- } else if (device_type == DEVICE_MTD) {
- snprintf(o_mtd_path, o_mtd_path_len, "/dev/mtd%d", mtdnum);
- } else if (device_type == DEVICE_ZFTL) {
- snprintf(o_mtd_path, o_mtd_path_len, "/dev/zftl%d", mtdnum);
- } else {
- printf("fs_check unknown device type %d\n", device_type);
- goto error1;
- }
- //printf("fs_check o_mtd_path=[%s]\n", o_mtd_path);
- break;
- }
-
- }
- fclose(fd_mtd);
- return 0;
-
-error1:
- fclose(fd_mtd);
-error0:
- return -1;
-}
-
-int system_exec_status(int status)
+static int system_exec_status(int status)
{
if (-1 == status)
return SYSTEM_EXEC_FAIL;
@@ -180,7 +125,7 @@
return SYSTEM_EXEC_SUCC;
}
-int get_ubifs_device_num(int recv_mtdnum)
+static int get_ubifs_device_num(int recv_mtdnum)
{
int vol_num = -1;
int fd_ubi = -1;
@@ -228,7 +173,7 @@
return vol_num;
}
-int get_vol_id(int ubi_num, char *vol_name)
+static int get_vol_id(int ubi_num, char *vol_name)
{
int vol_id = -1;
int fd_ubi = -1;
@@ -278,7 +223,7 @@
return vol_id;
}
-int get_ubi_device_num(const char *dev_path, int *major_num, int *minor_num)
+static int get_ubi_device_num(const char *dev_path, int *major_num, int *minor_num)
{
struct stat st = {0};
int fd_ubi = -1;
@@ -315,7 +260,7 @@
}
}
-int check_ubi_device_is_char(const char *dev_path)
+static int check_ubi_device_is_char(const char *dev_path)
{
struct stat st = {0};
int ret = -1;
@@ -335,7 +280,7 @@
return 0;
}
-int mknod_ubi_device(void)
+static int mknod_ubi_device(void)
{
int mychar = 3;
char *ubi_array[] = {"ubi1", "ubi1_0", "ubi1_1"};
@@ -480,11 +425,14 @@
return 0;
}
+/*******************************************************************************
+ * È«¾Öº¯Êý *
+ *******************************************************************************/
/**************************************************************************
-* º¯ÊýÃû³Æ£º check_files_access
-* ¹¦ÄÜÃèÊö£º ¼ì²éuserdataÎļþϵͳϵÄÎļþÊÇ·ñ´æÔÚÇÒÓжÁдȨÏÞ
-* ²ÎÊý˵Ã÷£º ÎÞ
-* ·µ »Ø Öµ£º¼ì²éÕý³£·µ»Ø0, ·ñÔò·µ»Ø-1£¬½øÐÐuserdata·ÖÇøµÄ²Á³ý
+* º¯ÊýÃû³Æ£º check_file_is_normal
+* ¹¦ÄÜÃèÊö£º ¼ì²éuserdata·ÖÇøÏÂÃæµÄÎļþÊÇ·ñÕý³££¬Èç¹û´æÔÚÒì³££¬ÔòÐèÒªÖØÐ»ָ´userdata·ÖÇø
+* ²ÎÊý˵Ã÷£º pFile: Ðè¼ì²éµÄÎļþ
+* ·µ »Ø Öµ£º¼ì²éÕý³£·µ»Ø0, ÐèÒªÖØÐ»ָ´·ÖÇø·µ»Ø-1
* ÆäËü˵Ã÷£º
**************************************************************************/
int check_file_is_normal(const char *pFile)
@@ -493,6 +441,11 @@
int result;
struct stat st;
+ if(pFile == NULL)
+ {
+ return 0;
+ }
+
result = stat(pFile, &st);
if(result == 0)
{
@@ -528,31 +481,84 @@
}
}
+int wipe_out_vol_ubi(struct mtd_fs *p_fs)
+{
+ int ret = -1;
+ int mtd_blk_num = 0;
+ int ubi_num = 0;
+ int vol_id = 0;
+ char mtd_path[MAX_PATH] = {0};
+ char updatevol_cmd[MAX_PATH] = {0};
+
+ if (NULL == p_fs->patition_name || NULL == p_fs->fs_type)
+ {
+ return -1;
+ }
+
+ if (strcmp(p_fs->fs_type, "ubifs") == 0)
+ {
+ ret = mtd_find(p_fs->patition_name, DEVICE_MTD_BLOCK, mtd_path, MAX_PATH);
+ if (ret < 0)
+ {
+ printf("fs_check partition name is not find\n");
+ return -1;
+ }
+
+ sscanf(mtd_path, "/dev/mtdblock%d", &mtd_blk_num);
+ printf("fs_check: wipe_out_vol_ubi, /dev/mtdblock%d\n", mtd_blk_num);
+
+ ubi_num = get_ubifs_device_num(mtd_blk_num);
+ if (ubi_num < 0)
+ {
+ printf("fs_check ubi_num not match\n");
+ return -1;
+ }
+ vol_id = get_vol_id(ubi_num, p_fs->ubi_vol_name);
+ if (vol_id < 0)
+ {
+ printf("fs_check vol_id not match,vol_name:%s\n", p_fs->ubi_vol_name);
+ return -1;
+ }
+
+ snprintf(updatevol_cmd, sizeof(updatevol_cmd), "/usr/sbin/ubiupdatevol /dev/ubi%d_%d -t", ubi_num, vol_id);
+ ret = zxic_system(updatevol_cmd);
+ }
+
+ return ret;
+}
+
int mount_fs_partition(struct mtd_fs *p_fs)
{
+ int i;
int ret = -1;
int ubi_num = 0;
int vol_id = 0;
int mtd_blk_num = 0;
char mount_cmd[MAX_PATH] = {0};
char mtd_path[MAX_PATH] = {0};
- char attach_cmd[MAX_PATH] = {0};
-
+ char attach_cmd[MAX_PATH] = {0};
+ char updatevol_cmd[MAX_PATH] = {0};
+
if (NULL == p_fs->patition_name || NULL == p_fs->mount_point || NULL == p_fs->fs_type)
return -1;
//printf("fs_check i_parti_name=%s, parti_mp=%s, parti_mt=%s\n", p_fs->patition_name, p_fs->mount_point, p_fs->fs_type);
- if (strcmp(p_fs->fs_type, "jffs2") == 0) {
- ret = mtd_find(p_fs->patition_name, mtd_path, DEVICE_MTD_BLOCK, MAX_PATH);
- if (ret < 0) {
+ if (strcmp(p_fs->fs_type, "jffs2") == 0)
+ {
+ ret = mtd_find(p_fs->patition_name, DEVICE_MTD_BLOCK, mtd_path, MAX_PATH);
+ if (ret < 0)
+ {
printf("fs_check partition name is not find\n");
return -1;
}
- snprintf(mount_cmd, sizeof(mount_cmd), "/bin/mount -t jffs2 -o %s %s %s", p_fs->mount_opt,mtd_path, p_fs->mount_point);
- } else if (strcmp(p_fs->fs_type, "ubifs") == 0) {
- ret = mtd_find(p_fs->patition_name, mtd_path, DEVICE_MTD_BLOCK, MAX_PATH);
- if (ret < 0) {
+ snprintf(mount_cmd, sizeof(mount_cmd), "/bin/mount -t jffs2 -o %s %s %s", p_fs->mount_opt, mtd_path, p_fs->mount_point);
+ }
+ else if (strcmp(p_fs->fs_type, "ubifs") == 0)
+ {
+ ret = mtd_find(p_fs->patition_name, DEVICE_MTD_BLOCK, mtd_path, MAX_PATH);
+ if (ret < 0)
+ {
printf("fs_check partition name is not find\n");
return -1;
}
@@ -564,24 +570,28 @@
{
snprintf(attach_cmd, sizeof(attach_cmd), "/usr/sbin/ubiattach /dev/ubi_ctrl -m %d", mtd_blk_num);
ret = system_exec_status(zxic_system(attach_cmd));
- if (ret == SYSTEM_EXEC_FAIL) {
- printf("fs_check: %s fail\n",attach_cmd);
+ if (ret == SYSTEM_EXEC_FAIL)
+ {
+ printf("fs_check: %s fail\n", attach_cmd);
return -1;
}
}
ubi_num = get_ubifs_device_num(mtd_blk_num);
- if (ubi_num < 0) {
+ if (ubi_num < 0)
+ {
printf("fs_check ubi_num not match\n");
return -1;
}
vol_id = get_vol_id(ubi_num, p_fs->ubi_vol_name);
- if (vol_id < 0) {
+ if (vol_id < 0)
+ {
printf("fs_check vol_id not match,vol_name:%s\n", p_fs->ubi_vol_name);
return -1;
}
- if (mknod_ubi_device() < 0) {
+ if (mknod_ubi_device() < 0)
+ {
printf("fs_check ubi dev not found\n");
return -1;
}
@@ -594,19 +604,32 @@
{
snprintf(mount_cmd, sizeof(mount_cmd), "/bin/mount -t ubifs -o %s ubi%d_%d %s",p_fs->mount_opt, ubi_num, vol_id, p_fs->mount_point);
}
-
- } else {
+ }
+ else
+ {
printf("fs_check unknown mount type: %s\n", p_fs->fs_type);
return -1;
}
printf("fs_check mount commond: %s\n", mount_cmd);
- ret = zxic_system(mount_cmd);
- if (check_mount_result(p_fs->mount_point) < 0) {
- printf("fs_check : %s fail\n", mount_cmd);
- return -1;
+ for (i = 0; i < FS_MAX_MOUNT_TIMES; i++)
+ {
+ zxic_system(mount_cmd);
+
+ ret = check_mount_result(p_fs->mount_point);
+ if (ret < 0)
+ {
+ if ((strcmp(p_fs->fs_type, "ubifs") == 0) && (i == 0))
+ {
+ snprintf(updatevol_cmd, sizeof(updatevol_cmd), "/usr/sbin/ubiupdatevol /dev/ubi%d_%d -t", ubi_num, vol_id);
+ zxic_system(updatevol_cmd);
+ continue;
+ }
+ printf("fs_check : %s fail\n", mount_cmd);
+ return -1;
+ }
+ return 0;
}
- return 0;
}
int unmount_fs_partition(struct mtd_fs *p_fs)
@@ -631,7 +654,7 @@
zxic_system(umount_cmd);
printf("fs_check umount : %s\n", umount_cmd);
- ret = mtd_find(p_fs->patition_name, mtd_path, DEVICE_MTD_BLOCK, MAX_PATH);
+ ret = mtd_find(p_fs->patition_name, DEVICE_MTD_BLOCK, mtd_path, MAX_PATH);
if (ret < 0) {
printf("fs_check partition name is not find\n");
return -1;
@@ -659,160 +682,3 @@
return 0;
}
-int mtd_erase_partition(const char* partition_name)
-{
- int ret = 0;
- char mtd_path[MAX_PATH] = {0};
- int fd_mtd = -1;
-
- struct mtd_info_user meminfo = {0};
- struct erase_info_user64 erase_info = {0};
-
- if (NULL == partition_name) {
- return -1;
- }
- ret = mtd_find(partition_name, mtd_path, DEVICE_MTD, MAX_PATH);
- if (ret < 0) {
- printf("fs_check mtd_find %s failed\n", partition_name);
- ret = -1;
- goto out;
- }
- fd_mtd = open(mtd_path, O_RDWR);
- if (fd_mtd < 0) {
- printf("fs_check open %s error, %s\n", partition_name, strerror(errno));
- ret = -1;
- goto out;
- }
- if (ioctl(fd_mtd, MEMGETINFO, &meminfo) != 0) {
- printf("fs_check get %s info error, %s\n", partition_name, strerror(errno));
- ret = -1;
- goto out;
- }
- erase_info.length = meminfo.erasesize;
- for (erase_info.start = 0; erase_info.start < meminfo.size; erase_info.start += meminfo.erasesize) {
- if (ioctl(fd_mtd, MEMGETBADBLOCK, &(erase_info.start)) > 0) {
- printf("fs_check mtd, not erasing bad block at 0x%llx\n", erase_info.start);
- continue;
- }
- if (ioctl(fd_mtd, MEMERASE64, &erase_info) < 0) {
- printf("fs_check mtd, erasing failure at 0x%llx\n", erase_info.start);
- }
- }
- ret = 0;
-out:
- if (fd_mtd >= 0) {
- close(fd_mtd);
- }
- return ret;
-}
-
-int mtd_write_partition(const char* partition_name, const char* image_file)
-{
- int ret = 0;
- char mtd_path[MAX_PATH] = {0};
- int fd_mtd = -1;
- struct mtd_info_user meminfo = {0};
-
- long long index = 0;
- int len = 0;
- FILE * fp = NULL;
- char * buf = NULL;
- struct stat statbuff = {0};
-
- if (NULL == partition_name || NULL == image_file)
- return -1;
-
- ret = mtd_find(partition_name, mtd_path, DEVICE_MTD, MAX_PATH);
- if (ret < 0) {
- printf("fs_check mtd_find %s failed\n", partition_name);
- ret = -1;
- goto out;
- }
- fd_mtd = open(mtd_path, O_RDWR);
- if (fd_mtd < 0) {
- printf("fs_check open %s error, %s\n", partition_name, strerror(errno));
- ret = -1;
- goto out;
- }
- if (ioctl(fd_mtd, MEMGETINFO, &meminfo) != 0) {
- printf("fs_check get %s info error, %s\n", partition_name, strerror(errno));
- ret = -1;
- goto out;
- }
-
- if(stat(image_file, &statbuff) < 0)
- {
- printf("fs_check stat %s failed\n", image_file);
- ret = -1;
- goto out;
- }
-
- fp = fopen(image_file, "ro");
- if (!fp)
- {
- printf("fs_check fopen %s failed\n", image_file);
- ret = -1;
- goto out;
- }
-
- buf = (char *)malloc(meminfo.erasesize);
- if(!buf)
- {
- printf("fs_check malloc failed\n");
- ret = -1;
- goto out;
- }
-
- for (index = 0; index < meminfo.size && len < statbuff.st_size; index += meminfo.erasesize)
- {
- if (ioctl(fd_mtd, MEMGETBADBLOCK, &index) > 0)
- {
- printf("fs_check mtd, not erasing bad block at %lld\n", index);
- continue;
- }
-
- ret = fread(buf, 1, meminfo.erasesize, fp);
- if(ret < 0)
- {
- printf("fs_check mtd, fread error = %d!\n", ret);
- ret = -1;
- goto out;
- }
-
- ret = lseek(fd_mtd, (long)index, SEEK_SET);
- if(ret < 0)
- {
- printf("fs_check mtd, lseek error = %s!\n", strerror(errno));
- ret = -1;
- goto out;
- }
- ret = write(fd_mtd, buf, meminfo.erasesize);
- if (ret != meminfo.erasesize)
- {
- printf("fs_check mtd, write error = %d!\n", ret);
- ret = -1;
- goto out;
- }
- len += meminfo.erasesize;
- }
- if (len < statbuff.st_size)
- printf("fs_check mtd, No space left,writelen=%d, filesize=%d\n",len,statbuff.st_size);
-
- ret = 0;
-out:
- if (fd_mtd >= 0)
- close(fd_mtd);
-
- if (buf != NULL) {
- memset(buf, 0, meminfo.erasesize);
- free(buf);
- }
-
- if (fp != NULL)
- fclose(fp);
-
- return ret;
-}
-
-
-
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/absvr_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/absvr_msg.h
new file mode 100755
index 0000000..4940ece
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/absvr_msg.h
@@ -0,0 +1,82 @@
+/**
+ * @file absvr_msg.h
+ * @brief Extern MSG APIs of absvr_msg
+ *
+ * Copyright (C) 2023 Sanechips Technology Co., Ltd.
+ * @author
+ * @ingroup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+
+#ifndef _ABSVR_MSG_H
+#define _ABSVR_MSG_H
+
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "message.h"
+
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+enum absvr_msg_cmd
+{
+ ABSVR_GET_UPGRADE_TYPE_REQ = MSG_CMD_ABSVR_BASE,
+ ABSVR_GET_UPGRADE_TYPE_RSP,
+
+ ABSVR_VRITFY_REQ,
+ ABSVR_VRITFY_RSP,
+
+ ABSVR_UPDATE_REQ,
+ ABSVR_UPDATING_RSP,
+ ABSVR_UPDATE_RSP,
+
+ ABSVR_SYNC_REQ,
+ ABSVR_SYNC_RSP,
+
+ ABSVR_GET_UPGRADE_STATUS_REQ,
+ ABSVR_GET_UPGRADE_STATUS_RSP,
+
+ ABSVR_GET_CURRENT_SYSTEM_REQ,
+ ABSVR_GET_CURRENT_SYSTEM_RSP,
+
+ ABSVR_GET_BOOT_TO_SYSTEM_REQ,
+ ABSVR_GET_BOOT_TO_SYSTEM_RSP,
+
+ ABSVR_SET_BOOT_TO_SYSTEM_REQ,
+ ABSVR_SET_BOOT_TO_SYSTEM_RSP,
+
+ ABSVR_GET_SYSTEM_STATUS_REQ,
+ ABSVR_GET_SYSTEM_STATUS_RSP,
+
+ ABSVR_SET_SYSTEM_STATUS_REQ,
+ ABSVR_SET_SYSTEM_STATUS_RSP,
+
+ ABSVR_GET_FOTA_STATUS_FOR_NV_REQ,
+ ABSVR_GET_FOTA_STATUS_FOR_NV_RSP,
+
+ ABSVR_SET_FOTA_STATUS_FOR_NV_REQ,
+ ABSVR_SET_FOTA_STATUS_FOR_NV_RSP,
+
+ ABSVR_GET_SYNC_STATUS_REQ,
+ ABSVR_GET_SYNC_STATUS_RSP,
+
+ ABSVR_SET_SYNC_STATUS_REQ,
+ ABSVR_SET_SYNC_STATUS_RSP
+};
+
+
+#endif
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/message.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/message.h
index cafdf97..7e25a73 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/message.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/message.h
@@ -109,6 +109,10 @@
MODULE_ID_GUODIAN_BASE,
MODULE_ID_GPS, // GPSÓ¦ÓÃÄ£¿éID
+ //absvr
+ MODULE_ID_ABSVR,
+ MODULE_ID_ABCLIENT,
+
// for audio-ctrl
#ifndef USE_CAP_SUPPORT
MODULE_ID_ZCORE,
@@ -144,6 +148,10 @@
MODULE_ID_CPIPC,
MODULE_ID_CPIPC_SERVER,
+ //voice
+ MODULE_ID_VOICE_SERVER,
+ MODULE_ID_VOICE_CLIENT,
+
/***************************ATCHN******************************/
MSG_CMD_ATCHN_STOP, //ֹͣat channel
MSG_CMD_DEL_MSG_IS_FD, //ɾ³ýͨµÀ
@@ -278,10 +286,18 @@
//amt device test
MSG_CMD_AMT_DEVICE_TEST_BASE = 0x9001,
MSG_CMD_AMT_DEVICE_TEST_END = 0x90C8,
+
+ //VOICE
+ MSG_CMD_VOICE_BASE = 0x90D0,
+ MSG_CMD_VOICE_END = 0x90FF,
//pocsvr
MSG_CMD_POCSVR_BASE = 0x9101,
MSG_CMD_POCSVR_END = 0x9200,
+
+ //absvr
+ MSG_CMD_ABSVR_BASE = 0x9201,
+ MSG_CMD_ABSVR_END = 0x9300,
};
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/rtc_timer.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/rtc_timer.h
index 8069d93..230e92e 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/rtc_timer.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/rtc_timer.h
@@ -71,6 +71,8 @@
RTC_ID_TRACK_AGPS,
RTC_ID_TRACK_WEATHER_UPDATE,
RTC_ID_TRACK_END,
+ RTC_ID_SC_TIMER,
+ RTC_ID_SC_ALARM,
RTC_ID_END,
} RTC_ID;
#endif
@@ -92,6 +94,7 @@
RTC_MSG_ALARM_ELAPSED, //µ±¶¨Ê±Æ÷´¥·¢Ê±»á·¢Õâ¸öÏûÏ¢¸ø¶¨Ê±Æ÷ÓµÓÐÕß
RTC_MSG_DEL_ALL, //Çå³ýËùÓйػú²»±£´æµÄ¶¨Ê±Æ÷£¬·ñÔòrtc¶¨Ê±Æ÷µ½µã»¹»áÉϱ¨
RTC_MSG_TIME_CHANGED, //RTCʱ¼ä¸üÐÂ:±íʾÊÀ½çʱ¼ä·¢Éú±ä»¯£¬¼´Ê±¼äͬ²½Íê³É»òÕßÓû§ÊÖ¶¯ÖØÐÂÉèÖõ±Ç°µÄÊÀ½çʱ¼äÁË£¬´ËʱRTC½ø³Ì»á¹ã²¥¸øÒÑ×¢²áÊÀ½çʱ¼äµÄÄ£¿é£¬ÒÔÈÃÏà¹ØÄ£¿é½øÐÐÊÀ½çʱ¼ä¶¨Ê±Æ÷µÄÖØÐÂÉèÖÃ
+ RTC_MSG_SNTP_UPDATE, //SNTPͬ²½
};
#endif
@@ -166,6 +169,14 @@
*/
int rtc_set_time(int src_id);
+/**
+* @brief »ñÈ¡rtcµ±Ç°Ê±¼ä
+* @param src_id ÉèÖÃʱ¼äµÄÄ£¿éID
+* @return ²Ù×÷³É¹¦
+*/
+int rtc_get_time(int src_id);
+
+
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_net_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_net_msg.h
new file mode 100755
index 0000000..b9abed7
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_net_msg.h
@@ -0,0 +1,173 @@
+/**
+ * @sc_sim_msg.h
+ * @brief SC Inter-Process-Communication.
+ *
+ * Copyright (C) 2023 Sanechips Technology Co., Ltd.
+ * @author
+ * @ingroup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _SC_NET_MSG_H
+#define _SC_NET_MSG_H
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "sc_tel_msg.h"
+#include "os_type_def.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+#define NET_CONN_ENABLE 1
+#define NET_CONN_DISABLE 0
+
+
+#define NET_NUM_OPERATOR_MAX 30
+#define NET_MCC_LENGHT 3
+#define NET_MNC_MAX 3
+
+ /* ³¤ÃûOPERÔÊÐíµÄ×î´ó³¤¶È */
+#define NET_MAX_LONG_OPER_LEN 20 //LONG_OPER_MAX_LEN
+ /* ¶ÌÃûOPERÔÊÐíµÄ×î´ó³¤¶È */
+#define NET_MAX_SHORT_OPER_LEN 12 //SHORT_OPER_MAX_LEN
+ /* Êý×Ö¸ñʽOPERÔÊÐíµÄ×î´ó³¤¶È */
+#define NET_MAX_NUM_OPER_LEN 8 //NUM_OPER_MAX_LEN
+
+
+#define NET_EM_TD_ACT 1
+#define NET_EM_W_ACT 2
+#define NET_EM_GSM_ACT 4
+#define NET_EM_LTE_ACT 16
+
+ typedef struct {
+ int enable;
+ } net_connect_t;
+
+ typedef struct {
+ int result;
+ } net_common_res_t;
+
+ typedef enum _SC_NET_CMD_ENUM {
+ MSG_CMD_NET_CONN_REQ = SC_NET_CMD_BASE,
+ MSG_CMD_NET_CONN_RSP,
+ MSG_CMD_NET_SCAN,
+ MSG_CMD_NET_SCAN_RSP,
+ MSG_CMD_GET_OPERATOR,
+ MSG_CMD_GET_OPERATOR_RSP,
+ MSG_CMD_NET_MODE_SELECT,
+ MSG_CMD_NET_MODE_SELECT_RSP,
+ MSG_CMD_NET_MODE_SET,
+ MSG_CMD_NET_MODE_SET_RSP,
+ MSG_CMD_NET_REGISTER,
+ MSG_CMD_NET_REGISTER_RSP,
+ MSG_CMD_NET_DEREGISTER,
+ MSG_CMD_NET_DEREGISTER_RSP,
+ MSG_CMD_NET_GET_REGISTER_STATE,
+ MSG_CMD_NET_GET_REGISTER_STATE_RSP,
+ MSG_CMD_GET_CSQ,
+ MSG_CMD_GET_CSQ_RSP,
+ MSG_CMD_GET_CELL_INFO,
+ MSG_CMD_GET_CELL_INFO_RSP,
+ } net_cmd_e;
+
+typedef struct
+{
+ int result;
+}netc_comm_result_t;
+
+
+ typedef struct
+ {
+ UINT8 act;
+ UINT32 cellId;
+ UINT16 rac;
+ CHAR plmnId[10];
+ UINT16 pci;
+ UINT16 arfcn;
+ UINT16 rssi;
+ UINT16 rsrq;
+ UINT16 ecno;
+ UINT16 diBandWidth;
+ UINT16 rankInd;
+ UINT16 c_rnti;
+ UINT16 band;
+ }net_cell_info_t;
+
+ typedef struct
+{
+ UINT8 mode;
+ UINT8 format;
+ CHAR oper[NET_MAX_LONG_OPER_LEN];
+ UINT8 uAcT;
+} net_cur_operator_t;
+
+typedef struct
+{
+ UINT32 state;
+ UINT8 loper_a[NET_MAX_LONG_OPER_LEN];
+ UINT8 soper_a[NET_MAX_SHORT_OPER_LEN];
+ UINT8 noper_a[NET_MAX_NUM_OPER_LEN];
+ UINT32 act;
+} net_operator_t;
+
+typedef struct
+{
+ UINT32 len;
+ net_operator_t operators[NET_NUM_OPERATOR_MAX];
+} net_operator_list_t;
+
+typedef struct
+{
+ UINT8 iSvrStatus;
+ UINT8 iSvrDomain;
+ UINT8 iRoamStaus;
+ UINT8 iSysMode;
+ UINT8 iSimStatus;
+ UINT8 iSysSubMode;
+} net_sysinfo_t;
+
+// AT^sysconfig
+typedef struct
+{
+ UINT8 imode;
+ UINT8 acqorder;
+ UINT8 roam;
+ UINT8 svrdomain;
+} net_sysconfig_t;
+
+// Çл»µÄ¸÷¸öģʽ²ÎÊý¶¨Òå
+typedef enum
+{
+ SC_NET_SWITCH_AUTO,
+ SC_NET_SWITCH_MANUAL_GSM,
+ SC_NET_SWITCH_MANUAL_TD,
+ SC_NET_SWITCH_MANUAL_LTE,
+ SC_NET_SWITCH_PRE_LTE, //LTEÓÅÏÈ
+ SC_NET_SWITCH_PRE_UTRAN, // 3GÓÅÏÈ
+ SC_NET_SWITCH_PRE_GSM, //GSMÓÅÏÈ
+ SC_NET_SWITCH_GSM_ONLY,
+ SC_NET_SWITCH_TDS_GSM, //TDS/GSM˫ģÉèÖýӿÚ
+ SC_NET_SWITCH_WCDMA_GSM, //WCDMA/GSM˫ģÉèÖýӿÚ
+ SC_NET_SWITCH_ONLY_TD, //TDS only
+ SC_NET_SWITCH_ONLY_LTE, //LTE only
+ SC_NET_SWITCH_ONLY_WCDMA, //WCDMA only
+ SC_NET_SWITCH_GSM_LTE, //GSM ºÍ LTE Á½Ä£
+ SC_NET_SWITCH_LTE_WCDMA, //WCDMA ºÍ LTE Á½Ä£ ÏÈLTEºóW
+ SC_NET_SWITCH_WCDMA_TD_GSM //WCDMA¡¢TDºÍGSMÈýÄ£
+} net_switch_mode_t;
+
+
+#ifdef __cplusplus
+ }
+#endif
+#endif /* _SC_NET_MSG_H*/
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_rtc_timer_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_rtc_timer_msg.h
new file mode 100755
index 0000000..630485f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_rtc_timer_msg.h
@@ -0,0 +1,44 @@
+/**
+ * @sc_rtc_timer_msg.h
+ * @brief SC Inter-Process-Communication.
+ *
+ * Copyright (C) 2023 Sanechips Technology Co., Ltd.
+ * @author
+ * @ingroup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _SC_RTC_TIMER_MSG_H
+#define _SC_RTC_TIMER_MSG_H
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "sc_tel_msg.h"
+#include "os_type_def.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+typedef enum _SC_RTC_TIMER_CMD_ENUM {
+ SC_RTC_MSG_CMD_GET_TIME_RSP = SC_RTC_TIMER_CMD_BASE,
+ SC_RTC_MSG_CMD_TIMEOUT,
+} SC_RTC_TIMER_CMD_ENUM;
+
+#ifdef __cplusplus
+ }
+#endif
+#endif /* _SC_RTC_TIMER_MSG_H*/
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_sim_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_sim_msg.h
index 0a5020b..400e2e5 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_sim_msg.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_sim_msg.h
@@ -86,7 +86,6 @@
}pin_info;
typedef struct {
- int subscription;
int app_state;
int pin1_state;
UINT8 pin1_num_retries;
@@ -128,14 +127,7 @@
typedef enum {
SIM_CARD_STATE_UNKNOWN = 0xB01,
SIM_CARD_STATE_ABSENT = 0xB02,
- SIM_CARD_STATE_PRESENT = 0xB03,
- SIM_CARD_STATE_ERROR_UNKNOWN = 0xB04,
- SIM_CARD_STATE_ERROR_POWER_DOWN = 0xB05,
- SIM_CARD_STATE_ERROR_POLL_ERROR = 0xB06,
- SIM_CARD_STATE_ERROR_NO_ATR_RECEIVED = 0xB07,
- SIM_CARD_STATE_ERROR_VOLT_MISMATCH = 0xB08,
- SIM_CARD_STATE_ERROR_PARITY_ERROR = 0xB09,
- SIM_CARD_STATE_ERROR_SIM_TECHNICAL_PROBLEMS = 0xB0A,
+ SIM_CARD_STATE_PRESENT = 0xB03,
} sim_card_state_e;
typedef enum {
@@ -148,17 +140,11 @@
} sim_pin_state_e;
typedef enum {
- SIM_APP_STATE_UNKNOWN = 0xB00,
- SIM_APP_STATE_DETECTED = 0xB01,
- SIM_APP_STATE_PIN1_REQ = 0xB02,
- SIM_APP_STATE_PUK1_REQ = 0xB03,
- SIM_APP_STATE_INITALIZATING = 0xB04,
- SIM_APP_STATE_PERSO_CK_REQ = 0xB05,
- SIM_APP_STATE_PERSO_PUK_REQ = 0xB06,
- SIM_APP_STATE_PERSO_PERMANENTLY_BLOCKED = 0xB07,
- SIM_APP_STATE_PIN1_PERM_BLOCKED = 0xB08,
- SIM_APP_STATE_ILLEGAL = 0xB09,
- SIM_APP_STATE_READY = 0xB0A,
+ SIM_APP_STATE_UNKNOWN = 0xB00,
+ SIM_APP_STATE_PIN1_REQ = 0xB01,
+ SIM_APP_STATE_PUK1_REQ = 0xB02,
+ SIM_APP_STATE_PIN1_PERM_BLOCKED = 0xB03,
+ SIM_APP_STATE_READY = 0xB04,
} sim_app_state_e;
typedef struct
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_sms_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_sms_msg.h
new file mode 100755
index 0000000..e18f2d7
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_sms_msg.h
@@ -0,0 +1,143 @@
+/**
+ * @sc_sim_msg.h
+ * @brief SC Inter-Process-Communication.
+ *
+ * Copyright (C) 2023 Sanechips Technology Co., Ltd.
+ * @author
+ * @ingroup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _SC_SMS_MSG_H
+#define _SC_SMS_MSG_H
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "sc_tel_msg.h"
+#include "os_type_def.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+#define SC_SMS_MAX_ADDR_LENGTH 64
+#define SC_SMS_MAX_SEND_MSG_LENGTH 1024
+#define SC_SMS_MAX_SEND_PDU_LENGTH 1024
+#define SC_SMS_MAX_PDU_LENGTH 176
+#define SC_SMS_CMD_NAME_MAX_LEN 20
+#define SC_SMS_MAX_TEXT_LENGTH 400
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+typedef struct {
+ /*0-disable connect 1-enable connect*/
+ int enable;
+} sc_sms_connect_t;
+
+typedef struct {
+ int result;
+} sc_sms_common_res_t;
+
+typedef enum _SC_SMS_CMD_ENUM {
+ MSG_SMS_CMD_CONN_REQ = SC_SMS_CMD_BASE,
+ MSG_SMS_CMD_CONN_RSP,
+ MSG_SMS_CMD_DISCONN_REQ,
+ MSG_SMS_CMD_DISCONN_RSP,
+ MSG_SMS_CMD_SET_CENTER_ADDR_REQ,
+ MSG_SMS_CMD_SET_CENTER_ADDR_RSP,
+ MSG_SMS_CMD_GET_CENTER_ADDR_REQ,
+ MSG_SMS_CMD_GET_CENTER_ADDR_RSP,
+ MSG_SMS_CMD_SEND_MESSAGE_REQ,
+ MSG_SMS_CMD_SEND_MESSAGE_RSP,
+ MSG_SMS_CMD_SEND_MESSAGE_ASYNC_REQ,
+ MSG_SMS_CMD_SEND_MESSAGE_ASYNC_RSP,
+ MSG_SMS_CMD_SEND_PDU_REQ,
+ MSG_SMS_CMD_SEND_PDU_RSP,
+ MSG_SMS_CMD_SEND_PDU_ASYNC_REQ,
+ MSG_SMS_CMD_SEND_PDU_ASYNC_RSP,
+ MSG_SMS_CMD_PDU_IND,
+ MSG_SMS_CMD_TEXT_IND,
+} sc_sms_cmd_enum;
+
+typedef struct
+{
+ int slot;
+ int len;
+ char addr[SC_SMS_MAX_ADDR_LENGTH+1];
+ int result;
+ int reason;
+}sc_sms_center_addr;
+
+typedef struct
+{
+ int result;
+ int reason;
+ int id;
+}sms_op_result;
+
+typedef enum
+{
+ SMS_MSG_FORMAT_GSM_7BIT = 0,
+ SMS_MSG_FORMAT_BINARY_DATA = 1,
+ SMS_MSG_FORMAT_UCS2 = 2,
+ SMS_PDU_FORMAT_CDMA = 3, //CDMA
+ SMS_PDU_FORMAT_GW_PP = 4, // GSM & WCDMA
+ SMS_MSG_FORMAT_MAX
+}sms_msg_format_t;
+
+typedef struct
+{
+ int slot;
+ sms_msg_format_t format;
+ char addr[SC_SMS_MAX_ADDR_LENGTH+1];
+ int content_size;
+ char content[SC_SMS_MAX_SEND_MSG_LENGTH];
+ int id;
+}sms_msg_info;
+
+typedef struct
+{
+ sms_msg_format_t format;
+ UINT8 total_length;
+ UINT8 tpdu_length;
+ UINT8 pdu[SC_SMS_MAX_PDU_LENGTH];
+}sms_pdu_ind_info;
+
+typedef struct {
+ UINT8 year;
+ UINT8 month;
+ UINT8 day;
+ UINT8 hours;
+ UINT8 minutes;
+ UINT8 seconds;
+ UINT8 timezone;
+}sms_scts_info;
+
+typedef struct {
+ CHAR oa[SC_SMS_CMD_NAME_MAX_LEN];
+ CHAR alpha[SC_SMS_CMD_NAME_MAX_LEN];
+ sms_scts_info scts;
+ UINT8 tooa;
+ UINT8 fo;
+ UINT8 pid;
+ UINT8 dcs;
+ CHAR sca[SC_SMS_CMD_NAME_MAX_LEN];
+ UINT8 tosca;
+ UINT8 length;
+ UINT8 smRejected;/*0:received,1:rejected, 2:special sm received but already deal*/
+ UINT8 text[SC_SMS_MAX_TEXT_LENGTH];
+} sms_text_ind_info;
+
+#ifdef __cplusplus
+ }
+#endif
+#endif /* _SC_SIM_MSG_H*/
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_tel_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_tel_msg.h
index 05acaff..b748e54 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_tel_msg.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/sctel/sc_tel_msg.h
@@ -46,6 +46,12 @@
/*SIM模块消息基地址*/
SC_SIM_CMD_BASE = 0x10000201,
SC_SIM_CMD_END = 0x10000300,
+ /*RTC-TIMER模块消息基地址*/
+ SC_RTC_TIMER_CMD_BASE = 0x10000301,
+ SC_RTC_TIMER_CMD_END = 0x10000400,
+ /*NET模块消息基地址*/
+ SC_NET_CMD_BASE = 0x10000401,
+ SC_NET_CMD_END = 0x10000500,
} SC_CMD_BASE_ENUM;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/softap_log.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/softap_log.h
index 05919b5..b2260bf 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/softap_log.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/include/softap_log.h
@@ -46,6 +46,7 @@
#define CPNV_PRINT "[cpnv]"
#define EAP_PRINT "[atchn]"
#define TELSVR_PRINT "[telsvr]"
+#define ABCLIENT_PRINT "[abclient]"
extern int asprintf(char **strp, const char *fmt, ...);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatext/ext_normal_func.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatext/ext_normal_func.c
index 399e83d..8d60044 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatext/ext_normal_func.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatext/ext_normal_func.c
@@ -175,14 +175,14 @@
int ext_normal_regist(void)
{
- register_serv_func2("shell=",0,0,0,ext_atshell_req,NULL);
+ register_serv_func2("shellcap=",0,0,0,ext_atshell_req,NULL);
//¿ØÖÆtelnetÆô¶¯
register_serv_func2("ztelnet?",0,0,0,ztelnetGet_req,NULL);
register_serv_func2("ztelnet=",0,0,0,ztelnetSet_req,NULL);
//Íâ²¿Ëø¿ªÆôÊÍ·ÅÃüÁî
- register_serv_func("ZWORKLOCK=", 0, ext_worklock_set_func);
+ register_serv_func("ZWORKLOCKCAP=", 0, ext_worklock_set_func);
return 0;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/atreg_common.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/atreg_common.h
index 3ea1dc3..7c51d29 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/atreg_common.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/atreg_common.h
Binary files differ
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/atreg_thread.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/atreg_thread.c
index 714cd01..034c744 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/atreg_thread.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/atreg_thread.c
@@ -233,12 +233,12 @@
static void atreg_ser_cb_proc(void *patreg_instance, unsigned char *aucDataBuf)
{
int send_ret = -1;
- unsigned char res_msg[MAX_MSG_LEN] = {0};
+ unsigned char res_msg[MSG_DATA_MAX_LEN] = {0};
struct atreg_ser_instance_t *patreg_ser_instance = (struct atreg_ser_instance_t *)patreg_instance;
patreg_ser_instance->cb(aucDataBuf, res_msg);
- send_ret = ipc_send_message2(atreg_common_ctx.modid, MODULE_ID_AT_CTL, patreg_ser_instance->rsp_msg_id, sizeof(res_msg), (unsigned char *)res_msg, 0);
+ send_ret = ipc_send_message2(atreg_common_ctx.modid, MODULE_ID_AT_CTL, patreg_ser_instance->rsp_msg_id, strlen(res_msg), (unsigned char *)res_msg, 0);
if (0 != send_ret) {
slog(ATREG_PRINT, SLOG_ERR, "Err: atreg_ser_cb_proc ipc fail!\n");
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/libatreg.a b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/libatreg.a
deleted file mode 100755
index 39e4d4d..0000000
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/libatreg.a
+++ /dev/null
Binary files differ
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/libatreg.so b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/libatreg.so
deleted file mode 100755
index 2e01557..0000000
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libatreg/libatreg.so
+++ /dev/null
Binary files differ
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/Makefile
new file mode 100644
index 0000000..3c37667
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/Makefile
@@ -0,0 +1,32 @@
+#*******************************************************************************
+# include ZTE library makefile
+#*******************************************************************************
+#include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+LIB_STATIC = libmtd.a
+LIB_SHARED = libmtd.so
+
+OBJS = mtd.o
+
+CFLAGS += -g -I.
+#LDFLAGS += -lpthread
+##############USER COMIZE END##################
+
+CFLAGS += -fPIC
+LDFLAGS += -shared
+
+all: $(LIB_STATIC) $(LIB_SHARED)
+
+$(LIB_STATIC) : $(OBJS)
+ $(AR) rcs $(LIB_STATIC) $(OBJS)
+
+$(LIB_SHARED): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^
+
+romfs:
+ #$(ROMFSINST) $(LIB_SHARED) /lib/$(LIB_SHARED)
+
+clean:
+ -$(RM) *.a *.o *.so $(LIB_SHARED) $(LIB_STATIC) $(OBJS)
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/mtd.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/mtd.c
new file mode 100644
index 0000000..5754368
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/mtd.c
@@ -0,0 +1,819 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <mtd/mtd-abi.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include "mtd_api.h"
+
+#define MTD_PATH_LENGTH_MAX (256)
+
+static ssize_t readn(int fd, void *vptr, size_t n);
+static ssize_t writen(int fd, const void *vptr, size_t n);
+
+/*******************************************************************************
+ * 内部函数/mtd_private.h *
+ *******************************************************************************/
+/**
+ * @brief 从文件描述符读取数据
+ * @param fd 入参,文件描述符
+ * @param vptr 出参,数据缓冲区
+ * @param n 入参,内容字节数
+ * @return 成功返回成功读取的字节数,失败返回-1
+ * @retval
+ * @note 封装read接口,读取被打断时会重试直到全部读取成功
+ * @warning
+ */
+static ssize_t readn(int fd, void *vptr, size_t n)
+{
+ size_t nleft;
+ ssize_t nread;
+ char *ptr;
+
+ ptr = vptr;
+ nleft = n;
+ while (nleft > 0)
+ {
+ if ((nread = read(fd, ptr, nleft)) < 0)
+ {
+ if (errno == EINTR)
+ {
+ nread = 0; /* and call read() again */
+ }
+ else
+ {
+ return (-1);
+ }
+ }
+ else if (nread == 0)
+ {
+ break; /* EOF */
+ }
+
+ nleft -= nread;
+ ptr += nread;
+ }
+ return (n - nleft); /* return >= 0 */
+}
+
+/**
+ * @brief 向文件描述符写入数据
+ * @param fd 入参,文件描述符
+ * @param vptr 入参,数据缓冲区
+ * @param n 入参,内容字节数
+ * @return 成功返回成功写入的字节数,失败返回-1
+ * @retval
+ * @note 封装write接口,写入被打断时会重试直到全部写入成功
+ * @warning
+ */
+static ssize_t writen(int fd, const void *vptr, size_t n)
+{
+ size_t nleft;
+ ssize_t nwritten;
+ const char *ptr;
+
+ ptr = vptr;
+ nleft = n;
+ while (nleft > 0)
+ {
+ nwritten = write(fd, ptr, nleft);
+ if (nwritten < 0)
+ {
+ if (errno == EINTR)
+ {
+ nwritten = 0; /* call write() again */
+ }
+ else
+ {
+ return (-1); /* error */
+ }
+ }
+ else if (nwritten == 0)
+ {
+ break;
+ }
+
+ nleft -= nwritten;
+ ptr += nwritten;
+ }
+ return (n - nleft); /* return >= 0 */
+}
+
+/*******************************************************************************
+ * 外部函数定义 *
+ *******************************************************************************/
+int mtd_find(const char *i_parti_name, device_type_t device_type, char *o_mtd_path, unsigned int o_mtd_path_len)
+{
+ FILE *fp_mtd = 0;
+ char buf[128];
+ char *line_str;
+
+ if (!o_mtd_path_len)
+ {
+ return -1;
+ }
+
+ fp_mtd = fopen("/proc/mtd", "r+");
+ if (NULL == fp_mtd)
+ {
+ printf("[libmtd]: mtd_find, open file error:%s", strerror(errno));
+ return -1;
+ }
+ // printf("[libmtd]: partition name:%s\n", i_parti_name);
+
+ while (1)
+ {
+ int matches = 0;
+ char mtdname[64] = {0};
+ int mtdnum = 0;
+ unsigned int mtdsize, mtderasesize;
+ memset(buf, 0, sizeof(buf));
+ line_str = fgets(buf, sizeof(buf) - 1, fp_mtd);
+
+ if (NULL == line_str)
+ {
+ printf("[libmtd]: mtd_find, get info from mtd error:%s\n", strerror(errno));
+ fclose(fp_mtd);
+ return -1;
+ }
+ // mtd5: 00100000 00020000 "fotaflag"
+ matches = sscanf(buf, "mtd%d: %x %x \"%63[^\"]",
+ &mtdnum, &mtdsize, &mtderasesize, mtdname);
+ mtdname[63] = '\0';
+
+ if ((matches == 4) && (strcmp(mtdname, i_parti_name) == 0))
+ {
+ memset(o_mtd_path, 0, o_mtd_path_len);
+ if (device_type == DEVICE_MTD_BLOCK)
+ {
+ snprintf(o_mtd_path, o_mtd_path_len, "/dev/mtdblock%d", mtdnum);
+ }
+ else if (device_type == DEVICE_MTD)
+ {
+ snprintf(o_mtd_path, o_mtd_path_len, "/dev/mtd%d", mtdnum);
+ }
+ else if (device_type == DEVICE_ZFTL)
+ {
+ snprintf(o_mtd_path, o_mtd_path_len, "/dev/zftl%d", mtdnum);
+ }
+ else
+ {
+ printf("[libmtd]: mtd_find, unknown device type %d\n", device_type);
+ fclose(fp_mtd);
+ return -1;
+ }
+ // printf("[libmtd]: o_mtd_path=[%s]\n", o_mtd_path);
+ break;
+ }
+ }
+ fclose(fp_mtd);
+ return 0;
+}
+
+int mtd_get_info(int fd, struct mtd_info_user *info)
+{
+ if (0 != ioctl(fd, MEMGETINFO, info))
+ {
+ printf("[libmtd]: mtd_get_info, get fd(%d) info error, %s\n", fd, strerror(errno));
+ return -1;
+ }
+ return 0;
+}
+
+int mtd_block_isbad(int fd, off_t offset)
+{
+ int ret = 0;
+ ret = ioctl(fd, MEMGETBADBLOCK, &offset);
+ if (ret > 0)
+ {
+ printf("[libmtd]: mtd_block_isbad, bad block at 0x%lx, ret = %d\n", offset, ret);
+ ret = 1;
+ }
+ else if (ret < 0)
+ {
+ printf("[libmtd]: mtd_block_isbad, ioctl(MEMGETBADBLOCK) error at 0x%lx, %s, ret = %d\n", offset, strerror(errno), ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+int mtd_erase_partition(const char *partition_name)
+{
+ int ret = 0;
+ char mtd_path[MTD_PATH_LENGTH_MAX] = {0};
+ int fd_mtd = -1;
+
+ struct mtd_info_user meminfo = {0};
+ struct erase_info_user64 erase_info = {0};
+
+ if (NULL == partition_name)
+ {
+ return -1;
+ }
+
+ ret = mtd_find(partition_name, DEVICE_MTD, mtd_path, MTD_PATH_LENGTH_MAX);
+ if (ret < 0)
+ {
+ printf("[libmtd]: mtd_erase_partition, mtd_find %s failed\n", partition_name);
+ ret = -1;
+ goto out;
+ }
+ fd_mtd = open(mtd_path, O_RDWR);
+ if (fd_mtd < 0)
+ {
+ printf("[libmtd]: mtd_erase_partition, open %s error, %s\n", partition_name, strerror(errno));
+ return -1;
+ }
+ ret = mtd_get_info(fd_mtd, &meminfo);
+ if (ret < 0)
+ {
+ printf("[libmtd]: mtd_erase_partition, get %s info error, %s\n", partition_name, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ erase_info.length = meminfo.erasesize;
+ for (erase_info.start = 0; erase_info.start < meminfo.size; erase_info.start += meminfo.erasesize)
+ {
+ ret = mtd_block_isbad(fd_mtd, erase_info.start);
+ if (1 == ret)
+ {
+ continue;
+ }
+ else if (-1 == ret)
+ {
+ printf("[libmtd]: mtd_erase_partition, mtd_block_isbad %s error\n", partition_name);
+ goto out;
+ }
+
+ if (0 != ioctl(fd_mtd, MEMERASE64, &erase_info))
+ {
+ printf("[libmtd]: mtd_erase_partition, erasing %s failure at 0x%llx\n", partition_name, erase_info.start);
+ if (ioctl(fd_mtd, MEMSETBADBLOCK, &(erase_info.start)) < 0)
+ {
+ printf("[libmtd]: mtd_erase_partition, mark %s bad block error, %s\n", partition_name, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+ continue;
+ }
+ }
+ ret = 0;
+out:
+ if (fd_mtd >= 0)
+ {
+ close(fd_mtd);
+ }
+ return ret;
+}
+
+int mtd_write_partition(const char *partition_name, const char *image_file)
+{
+ int ret = 0;
+ ssize_t wr_len;
+ char mtd_path[MTD_PATH_LENGTH_MAX] = {0};
+ int fd_mtd = -1;
+ struct mtd_info_user meminfo = {0};
+
+ off_t data_size = 0;
+ off_t index = 0;
+ off_t fd_img_index = 0;
+ int fd_img = -1;
+ char *buf = NULL;
+ struct stat statbuff = {0};
+
+ if (NULL == partition_name || NULL == image_file)
+ {
+ return -1;
+ }
+
+ ret = mtd_find(partition_name, DEVICE_MTD, mtd_path, MTD_PATH_LENGTH_MAX);
+ if (ret < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, mtd_find %s failed\n", partition_name);
+ ret = -1;
+ goto out;
+ }
+ fd_mtd = open(mtd_path, O_RDWR);
+ if (fd_mtd < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, open %s error, %s\n", partition_name, strerror(errno));
+ return -1;
+ }
+ ret = mtd_get_info(fd_mtd, &meminfo);
+ if (ret < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, get %s info error, %s\n", partition_name, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ if (stat(image_file, &statbuff) < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, stat %s failed, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ fd_img = open(image_file, O_RDONLY);
+ if (fd_img < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, open %s failed, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ buf = (char *)malloc(meminfo.erasesize);
+ if (!buf)
+ {
+ printf("[libmtd]: mtd_write_partition, malloc failed\n");
+ ret = -1;
+ goto out;
+ }
+
+ for (index = 0; index < meminfo.size && fd_img_index < statbuff.st_size; index += meminfo.erasesize)
+ {
+ ret = mtd_block_isbad(fd_mtd, index);
+ if (1 == ret)
+ {
+ continue;
+ }
+ else if (-1 == ret)
+ {
+ printf("[libmtd]: mtd_write_partition, mtd_block_isbad %s error,at 0x%llx\n", partition_name, index);
+ goto out;
+ }
+
+ if (lseek(fd_img, fd_img_index, SEEK_SET) < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, lseek %s error = %s!\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+ if (fd_img_index + meminfo.erasesize > statbuff.st_size)
+ {
+ data_size = statbuff.st_size - fd_img_index;
+ }
+ else
+ {
+ data_size = meminfo.erasesize;
+ }
+ wr_len = readn(fd_img, buf, (size_t)data_size);
+ if (wr_len < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, read %s error, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+ fd_img_index += data_size;
+
+ if (lseek(fd_mtd, index, SEEK_SET) < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, lseek %s error = %s!\n", partition_name, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+ wr_len = writen(fd_mtd, buf, (size_t)data_size);
+ if (wr_len < 0)
+ {
+ printf("[libmtd]: mtd_write_partition, write %s error, %s\n", partition_name, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+ memset(buf, 0xFF, meminfo.erasesize);
+ }
+ if (fd_img_index < statbuff.st_size)
+ {
+ printf("[libmtd]: mtd_write_partition, No space left, writelen=0x%lx, filesize=0x%lx\n", fd_img_index, statbuff.st_size);
+ ret = -1;
+ goto out;
+ }
+ ret = 0;
+out:
+ if (fd_mtd >= 0)
+ {
+ close(fd_mtd);
+ }
+
+ if (buf != NULL)
+ {
+ // memset(buf, 0xFF, meminfo.erasesize);
+ free(buf);
+ }
+
+ if (fd_img >= 0)
+ {
+ close(fd_img);
+ }
+
+ return ret;
+}
+
+int mtd_erase_offset(int fd, off_t offset)
+{
+ struct mtd_info_user meminfo = {0};
+ struct erase_info_user64 erase_info = {0};
+
+ if (fd < 0)
+ {
+ printf("[libmtd]: mtd_erase_offset, fd(%d) error\n", fd);
+ return -1;
+ }
+
+ if (0 != mtd_get_info(fd, &meminfo))
+ {
+ printf("[libmtd]: mtd_erase_offset, get fd(%d) info error, %s\n", fd, strerror(errno));
+ return -1;
+ }
+
+ if (0 != (offset % meminfo.erasesize))
+ {
+ printf("[libmtd]: mtd_erase_offset, not at the beginning of a block, erasesize is %d\n", meminfo.erasesize);
+ return -1;
+ }
+
+ erase_info.length = meminfo.erasesize;
+ erase_info.start = offset;
+
+ if (mtd_block_isbad(fd, erase_info.start))
+ {
+ return -1;
+ }
+ if (0 != ioctl(fd, MEMERASE64, &erase_info))
+ {
+ printf("[libmtd]: mtd_erase_offset, erasing failure at 0x%llx\n", erase_info.start);
+ if (ioctl(fd, MEMSETBADBLOCK, &(erase_info.start)) < 0)
+ {
+ printf("[libmtd]: mtd_erase_offset, mark bad block error, %s\n", strerror(errno));
+ }
+ return -1;
+ }
+
+ return 0;
+}
+
+ssize_t mtd_write_offset(int fd, off_t offset, const void *buf, size_t count)
+{
+ ssize_t writen_len;
+ struct mtd_info_user meminfo = {0};
+
+ if (fd < 0)
+ {
+ return -1;
+ }
+
+ if (0 != mtd_get_info(fd, &meminfo))
+ {
+ printf("[libmtd]: mtd_write_offset, get fd(%d) info error, %s\n", fd, strerror(errno));
+ return -1;
+ }
+ if (count <= 0 || count > meminfo.erasesize)
+ {
+ printf("[libmtd]: mtd_write_offset, count(0x%lx), less than 0, or larger than erasesize(0x%x)\n", count, meminfo.erasesize);
+ return -1;
+ }
+ if (0 != (offset % meminfo.erasesize))
+ {
+ printf("[libmtd]: mtd_write_offset, not at the beginning of a block, erasesize is 0x%x\n", meminfo.erasesize);
+ return -1;
+ }
+
+ if (mtd_block_isbad(fd, offset))
+ {
+ return -1;
+ }
+
+ if (lseek(fd, offset, SEEK_SET) < 0)
+ {
+ printf("[libmtd]: mtd_write_offset, lseek error = %s!\n", strerror(errno));
+ return -1;
+ }
+ writen_len = writen(fd, buf, count);
+ if (writen_len != count)
+ {
+ if (-1 == writen_len)
+ {
+ printf("[libmtd]: mtd_write_offset, write error, %s\n", strerror(errno));
+ }
+ return -1;
+ }
+
+ return writen_len;
+}
+
+ssize_t mtd_read_offset(int fd, off_t offset, void *buf, size_t count)
+{
+ ssize_t readn_len;
+ struct mtd_info_user meminfo = {0};
+
+ if (fd < 0)
+ {
+ return -1;
+ }
+
+ if (0 != mtd_get_info(fd, &meminfo))
+ {
+ printf("[libmtd]: mtd_read_offset, get fd(%d) info error, %s\n", fd, strerror(errno));
+ return -1;
+ }
+ if (count <= 0 || count > meminfo.erasesize)
+ {
+ printf("[libmtd]: mtd_read_offset, count(0x%lx), less than 0, or larger than erasesize(0x%x)\n", count, meminfo.erasesize);
+ return -1;
+ }
+ if (0 != (offset % meminfo.erasesize))
+ {
+ printf("[libmtd]: mtd_read_offset, not at the beginning of a block, erasesize is %x\n", meminfo.erasesize);
+ return -1;
+ }
+
+ if (mtd_block_isbad(fd, offset))
+ {
+ return -1;
+ }
+
+ if (lseek(fd, offset, SEEK_SET) < 0)
+ {
+ printf("[libmtd]: mtd_read_offset, lseek error = %s!\n", strerror(errno));
+ return -1;
+ }
+ readn_len = readn(fd, buf, count);
+ if (readn_len != count)
+ {
+ if (-1 == readn_len)
+ {
+ printf("[libmtd]: mtd_read_offset, read error, %s\n", strerror(errno));
+ }
+ return -1;
+ }
+
+ return readn_len;
+}
+
+static int zftl_verify_partition(const char *partition_name, const char *image_file)
+{
+ int ret = 0;
+ ssize_t rd_len;
+ size_t read_size = 4096;
+ char zftl_path[MTD_PATH_LENGTH_MAX] = {0};
+ int fd_zftl = -1;
+ struct mtd_info_user meminfo = {0};
+
+ off_t data_size = 0;
+ off_t index = 0;
+ off_t fd_img_index = 0;
+ int fd_img = -1;
+ char *buf = NULL;
+ char *buf2 = NULL;
+ struct stat statbuff = {0};
+
+ if (NULL == partition_name || NULL == image_file)
+ {
+ return -1;
+ }
+
+ ret = mtd_find(partition_name, DEVICE_ZFTL, zftl_path, MTD_PATH_LENGTH_MAX);
+ if (ret < 0)
+ {
+ printf("[libmtd]: zftl_verify_partition, mtd_find %s failed\n", partition_name);
+ return -1;
+ }
+ fd_zftl = open(zftl_path, O_RDONLY);
+ if (fd_zftl < 0)
+ {
+ printf("[libmtd]: zftl_verify_partition, open %s error, %s\n", partition_name, strerror(errno));
+ return -1;
+ }
+
+ if (stat(image_file, &statbuff) < 0)
+ {
+ printf("[libmtd]: zftl_verify_partition, stat %s failed, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ fd_img = open(image_file, O_RDONLY);
+ if (fd_img < 0)
+ {
+ printf("[libmtd]: zftl_verify_partition, open %s failed, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ buf = (char *)malloc(read_size);
+ if (!buf)
+ {
+ printf("[libmtd]: zftl_verify_partition, malloc failed\n");
+ ret = -1;
+ goto out;
+ }
+ buf2 = (char *)malloc(read_size);
+ if (!buf2)
+ {
+ printf("[libmtd]: zftl_verify_partition, malloc2 failed\n");
+ ret = -1;
+ goto out;
+ }
+
+ for (index = 0; fd_img_index < statbuff.st_size; index += read_size)
+ {
+ //memset(buf, 0xFF, read_size);
+
+ if (fd_img_index + read_size > statbuff.st_size)
+ {
+ data_size = statbuff.st_size - fd_img_index;
+ }
+ else
+ {
+ data_size = read_size;
+ }
+ // data_size = (fd_img_index + read_size > statbuff.st_size) ? (statbuff.st_size - fd_img_index) : (read_size);
+
+ rd_len = readn(fd_img, buf, (size_t)data_size);
+ if (rd_len < 0)
+ {
+ printf("[libmtd]: zftl_verify_partition, read image file %s error, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+ fd_img_index += data_size;
+
+ rd_len = readn(fd_zftl, buf2, (size_t)data_size);
+ if (rd_len < 0)
+ {
+ printf("[libmtd]: zftl_verify_partition, read zftl %s error, %s\n", partition_name, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ if (memcmp(buf, buf2, (size_t)data_size) != 0)
+ {
+ printf("[libmtd]: zftl_verify_partition, data memcmp %s error\n", partition_name);
+ ret = -1;
+ goto out;
+ }
+ }
+
+ ret = 0;
+out:
+ if (fd_zftl >= 0)
+ {
+ //fsync(fd_zftl);
+ close(fd_zftl);
+ }
+
+ if (buf != NULL)
+ {
+ // memset(buf, 0xFF, meminfo.erasesize);
+ free(buf);
+ }
+ if (buf2 != NULL)
+ {
+ // memset(buf, 0xFF, meminfo.erasesize);
+ free(buf2);
+ }
+
+ if (fd_img >= 0)
+ {
+ close(fd_img);
+ }
+ if (ret == 0)
+ {
+ printf("[libmtd]: zftl %s verify sucess\n", partition_name);
+ }
+ else
+ {
+ printf("[libmtd]: zftl %s verify fail\n", partition_name);
+ }
+
+ return ret;
+}
+
+int zftl_write_partition(const char *partition_name, const char *image_file)
+{
+ int ret = 0;
+ ssize_t wr_len;
+ size_t write_size = 4096;
+ char zftl_path[MTD_PATH_LENGTH_MAX] = {0};
+ int fd_zftl = -1;
+ struct mtd_info_user meminfo = {0};
+
+ off_t data_size = 0;
+ off_t index = 0;
+ off_t fd_img_index = 0;
+ int fd_img = -1;
+ char *buf = NULL;
+ struct stat statbuff = {0};
+
+ if (NULL == partition_name || NULL == image_file)
+ {
+ return -1;
+ }
+
+ ret = mtd_find(partition_name, DEVICE_ZFTL, zftl_path, MTD_PATH_LENGTH_MAX);
+ if (ret < 0)
+ {
+ printf("[libmtd]: zftl_write_partition, mtd_find %s failed\n", partition_name);
+ return -1;
+ }
+ fd_zftl = open(zftl_path, O_RDWR);
+ if (fd_zftl < 0)
+ {
+ printf("[libmtd]: zftl_write_partition, open %s error, %s\n", partition_name, strerror(errno));
+ return -1;
+ }
+
+ if (stat(image_file, &statbuff) < 0)
+ {
+ printf("[libmtd]: zftl_write_partition, stat %s failed, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ fd_img = open(image_file, O_RDONLY);
+ if (fd_img < 0)
+ {
+ printf("[libmtd]: zftl_write_partition, open %s failed, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ buf = (char *)malloc(write_size);
+ if (!buf)
+ {
+ printf("[libmtd]: zftl_write_partition, malloc failed\n");
+ ret = -1;
+ goto out;
+ }
+
+ for (index = 0; fd_img_index < statbuff.st_size; index += write_size)
+ {
+ memset(buf, 0xFF, write_size);
+
+ if (fd_img_index + write_size > statbuff.st_size)
+ {
+ data_size = statbuff.st_size - fd_img_index;
+ }
+ else
+ {
+ data_size = write_size;
+ }
+ // data_size = (fd_img_index + write_size > statbuff.st_size) ? (statbuff.st_size - fd_img_index) : (write_size);
+
+ wr_len = readn(fd_img, buf, (size_t)data_size);
+ if (wr_len < 0)
+ {
+ printf("[libmtd]: zftl_write_partition, read %s error, %s\n", image_file, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+ fd_img_index += data_size;
+
+ wr_len = writen(fd_zftl, buf, (size_t)data_size);
+ if (wr_len < 0)
+ {
+ printf("[libmtd]: zftl_write_partition, write %s error, %s\n", partition_name, strerror(errno));
+ ret = -1;
+ goto out;
+ }
+
+ }
+ if (fd_img_index < statbuff.st_size)
+ {
+ printf("[libmtd]: zftl_write_partition, No space left, writelen=0x%lx, filesize=0x%lx\n", fd_img_index, statbuff.st_size);
+ ret = -1;
+ goto out;
+ }
+ ret = 0;
+out:
+ if (fd_zftl >= 0)
+ {
+ fsync(fd_zftl);
+ close(fd_zftl);
+ }
+
+ if (buf != NULL)
+ {
+ // memset(buf, 0xFF, meminfo.erasesize);
+ free(buf);
+ }
+
+ if (fd_img >= 0)
+ {
+ close(fd_img);
+ }
+
+ if (ret == 0)
+ {
+ //write sucess then do verify
+ ret = zftl_verify_partition(partition_name, image_file);
+ }
+
+ return ret;
+}
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/mtd_api.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/mtd_api.h
new file mode 100755
index 0000000..bd95421
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libmtd/mtd_api.h
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 版权所有 (C)2022, 中兴通讯股份有限公司。
+ *
+ * 文件名称: pub_flags.h
+ * 文件标识: pub_flags
+ * 内容摘要: zx298501芯片平台flags分区规划头文件
+ * 使用方法:
+ *
+ * 修改日期 版本号 修改标记 修改人 修改内容
+ * ------------------------------------------------------------------------------
+ * 2022/09/15 V1.0 Create 周国坡 创建
+ *
+ *******************************************************************************/
+
+#ifndef _MTD_API_H
+#define _MTD_API_H
+
+typedef enum
+{
+ DEVICE_MTD = 0,
+ DEVICE_ZFTL = 1,
+ DEVICE_MTD_BLOCK,
+} device_type_t;
+
+/**
+ * @brief 根据分区名查找分区设备文件路径
+ * @param partition_name 入参,分区名
+ * @param type 入参,设备类型
+ * @param out_mtd_path 出参,设备文件路径缓冲区
+ * @param out_mtd_path_len 入参,out_mtd_path数据缓冲区长度
+ * @return 成功返回0,失败返回-1
+ * @retval
+ * @note
+ * @warning
+ */
+extern int mtd_find(const char *i_parti_name, device_type_t type, char *out_mtd_path, unsigned int out_mtd_path_len);
+
+/**
+ * @brief 根据分区名获取mtd分区信息
+ * @param fd 入参,mtd分区文件fd
+ * @param info 出参,包括分区大小和擦除块大小
+ * @return 成功返回0,失败返回-1
+ * @retval
+ * @note fd为打开/dev/mtdN设备句柄
+ * @warning
+ */
+extern int mtd_get_info(int fd, struct mtd_info_user *info);
+
+/**
+ * @brief 判断block是否是坏块
+ * @param fd 入参,mtd分区文件fd
+ * @param offset 入参,mtd分区偏移位置,包含坏块
+ * @return 0表示非坏块,1表示坏块,-1表示失败
+ * @retval
+ * @note fd为打开/dev/mtdN设备句柄
+ * @warning
+ */
+extern int mtd_block_isbad(int fd, off_t offset);
+
+/**
+ * @brief 擦除指定分区
+ * @param partition_name 入参,分区名
+ * @return 成功返回0,失败返回-1
+ * @retval
+ * @note
+ * @warning
+ */
+extern int mtd_erase_partition(const char *partition_name);
+
+/**
+ * @brief 将指定镜像文件写到指定分区
+ * @param partition_name 入参,分区名
+ * @param image_file 入参,指定的镜像文件
+ * @return 成功返回0,失败返回-1
+ * @retval
+ * @note
+ * @warning 先要mtd_erase_partition函数擦除分区
+ */
+extern int mtd_write_partition(const char *partition_name, const char *image_file);
+
+/**
+ * @brief 擦除mtd分区指定位置数据
+ * @param fd 入参,mtd分区文件fd
+ * @param offset 入参,mtd分区偏移位置,包含坏块
+ * @return 成功返回0,失败返回-1
+ * @retval
+ * @note fd为打开/dev/mtdN设备句柄
+ * @warning
+ */
+extern int mtd_erase_offset(int fd, off_t offset);
+
+/**
+ * @brief 将数据写到mtd分区指定偏移位置
+ * @param fd 入参,mtd分区文件fd
+ * @param offset 入参,mtd分区偏移位置
+ * @param buf 入参,数据缓冲区
+ * @param count 入参,buf数据长度,不超过一个擦除块
+ * @return 成功返回写入数据长度,失败返回-1
+ * @retval
+ * @note fd为打开/dev/mtdN设备句柄
+ * @warning 先要mtd_erase_partition函数擦除分区
+ */
+extern ssize_t mtd_write_offset(int fd, off_t offset, const void *buf, size_t count);
+
+/**
+ * @brief 读取mtd分区指定偏移位置的数据
+ * @param fd 入参,mtd分区文件fd
+ * @param offset 入参,mtd分区偏移位置
+ * @param buf 出参,数据缓冲区
+ * @param count 入参,buf数据长度,不超过一个擦除块
+ * @return 成功返回读取数据长度,失败返回-1
+ * @retval
+ * @note fd为打开/dev/mtdN设备句柄
+ * @warning
+ */
+extern ssize_t mtd_read_offset(int fd, off_t offset, void *buf, size_t count);
+
+#endif /* _MTD_API_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/netapi.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/netapi.c
index 0d9d322..a28620f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/netapi.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/netapi.c
@@ -753,6 +753,7 @@
(void)sc_cfg_set("lan_ipaddr", dhcp_req->lan_ip);
(void)sc_cfg_set("lan_netmask", dhcp_req->lan_netmask);
+ (void)sc_cfg_set("lan_netmask_cap", dhcp_req->lan_netmask);
(void)sc_cfg_set("dhcpStart", dhcp_req->dhcp_start);
(void)sc_cfg_set("dhcpEnd", dhcp_req->dhcp_end);
(void)sc_cfg_set("dhcpLease_hour", dhcp_req->dhcp_lease);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/rtc_timer.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/rtc_timer.c
index 8260e9b..6cd53ab 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/rtc_timer.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libsoftap/rtc_timer.c
@@ -101,7 +101,7 @@
buf.cpu = RTC_CPU_CAP;
data_len = sizeof(RTC_DATA_BUF);
- slog(MISC_PRINT, SLOG_ERR, "rtc add utc timer, cur:%ld, set:%ld, ulSec:%d; year:%d, mon:%d, day:%d, hour:%d, min:%d, sec:%d, wday:%d, yday:%d \n", buf.time_val, set_sec, buf.ulSec, sec->tm_year, sec->tm_mon, sec->tm_mday, sec->tm_hour, sec->tm_min, sec->tm_sec, sec->tm_wday, sec->tm_yday);
+ slog(MISC_PRINT, SLOG_ERR, "rtc add utc timer, cur:%ld, set:%ld, ulSec:%d; year:%d, mon:%d, day:%d, hour:%d, min:%d, sec:%d, wday:%d, yday:%d \n", buf.time_val, set_sec, buf.ulSec, sec->tm_year+1900, sec->tm_mon+1, sec->tm_mday, sec->tm_hour, sec->tm_min, sec->tm_sec, sec->tm_wday, sec->tm_yday);
ret = ipc_send_message(src_id, MODULE_ID_RTC_SERVICE, RTC_MSG_ADD_ALARM, data_len, (unsigned char *)&buf, 0);
if (ret != 0) {
slog(MISC_PRINT, SLOG_ERR, "rtc: set rtc utc timer send msg failed \n");
@@ -152,4 +152,22 @@
return -1;
}
+int rtc_get_time(int src_id)
+{
+ int ret = -1;
+
+ int data_len = 0;
+ RTC_DATA_BUF buf = {0};
+ buf.srcModule = src_id;
+ buf.cpu = RTC_CPU_CAP;
+
+ data_len = sizeof(RTC_DATA_BUF);
+
+ ret = ipc_send_message(src_id, MODULE_ID_RTC_SERVICE, RTC_MSG_GET_TIME, data_len, (unsigned char *) &buf, 0);
+ if (ret == 0)
+ return 0;
+ else
+ return -1;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_ati.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_ati.h
index 563773e..276ae04 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_ati.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_ati.h
@@ -278,6 +278,7 @@
CMD_ZMGL,
CMD_SUSS,
CMD_SPSMSFULL,
+ CMD_CSDH,
/* PB */
CMD_CPBW,
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_ati_sms_msg.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_ati_sms_msg.h
index 95cbc49..01550e4 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_ati_sms_msg.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_ati_sms_msg.h
@@ -57,8 +57,9 @@
#define ATI_SMS_CSMP_CNF (ATI_SMS_AT_BASE + 0x28)
#define ATI_SMS_CSCS_REQ (ATI_SMS_AT_BASE + 0x29)
#define ATI_SMS_CSCS_CNF (ATI_SMS_AT_BASE + 0x30)
-
-
+#define ATI_SMS_CSDH_REQ (ATI_SMS_AT_BASE + 0x31)
+#define ATI_SMS_CSDH_CNF (ATI_SMS_AT_BASE + 0x32)
+#define ATI_SMS_CMT_TEXT_IND (ATI_SMS_AT_BASE + 0x33)
/**************************************************************************
* Êý¾ÝÀàÐÍ *
@@ -295,6 +296,44 @@
CHAR pdu[ATI_MAX_SMS_PDU_LENGTH];
} AtiCmtInd;
+typedef struct {
+ UINT8 year;
+ UINT8 month;
+ UINT8 day;
+ UINT8 hours;
+ UINT8 minutes;
+ UINT8 seconds;
+ UINT8 timezone;
+}AtiCmtScts;
+
+typedef struct {
+ CHAR oa[AT_CMD_NAME_MAX_LEN];
+ CHAR alpha[AT_CMD_NAME_MAX_LEN];
+ AtiCmtScts scts;
+ UINT8 tooa;;
+ UINT8 fo;
+ UINT8 pid;
+ UINT8 dcs;
+ CHAR sca[AT_CMD_NAME_MAX_LEN];
+ UINT8 tosca;
+ UINT8 length;
+ UINT8 smRejected;/*0:received,1:rejected, 2:special sm received but already deal*/
+ CHAR text[ATI_MAX_SMS_PDU_LENGTH];
+} AtiCmtTextInd;
+
+typedef struct {
+ UINT8 type; //0:pdu 1:text
+ CHAR oa[AT_CMD_NAME_MAX_LEN];
+ CHAR alpha[AT_CMD_NAME_MAX_LEN];
+ AtiCmtScts scts;
+ UINT8 tooa;
+ UINT8 fo;
+ UINT8 pid;
+ UINT8 dcs;
+ CHAR sca[AT_CMD_NAME_MAX_LEN];
+ UINT8 tosca;
+ UINT8 length;
+} AtiCmtParam;
typedef struct {
UINT32 index;
@@ -348,17 +387,15 @@
}
AtiSpsmsfullCnf;
+typedef struct {
+ AtiCmdType cmd_type;
+ UINT8 show;
+} AtiCsdhReq;
-
-
-
-
-
-
-
-
-
-
+typedef struct {
+ SINT32 result;
+ UINT8 show;
+} AtiCsdhCnf;
/**************************************************************************
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_mm_interface.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_mm_interface.h
index 4133032..c1e339a 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_mm_interface.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_mm_interface.h
@@ -217,6 +217,18 @@
#define ZBL_NET_LOCK_STATE_RSP (MSG_ID_ZBL_TPM_MM_BASE+0xAF)
#define ZBL_NET_QUERY_PIN_RESULT (MSG_ID_ZBL_TPM_MM_BASE+0xB0)
#define ZBL_NET_QUERY_CARDMODE_RESULT (MSG_ID_ZBL_TPM_MM_BASE+0xB1)
+//µ±Ç°ÔËÓªÉÌÐÅÏ¢
+#define ZBL_NET_CUR_OPER_RESULT (MSG_ID_ZBL_TPM_MM_BASE+0xB2)
+//sysinfo
+#define ZBL_NET_SYSINFO_RESULT (MSG_ID_ZBL_TPM_MM_BASE+0xB3)
+//cops set result
+#define ZBL_NET_COPS_SET_RESULT (MSG_ID_ZBL_TPM_MM_BASE+0xB4)
+#define ZBL_NET_MODE_SET_RESULT (MSG_ID_ZBL_TPM_MM_BASE+0xB5)
+#define ZBL_NET_GET_CELL_INFO_REQ (MSG_ID_ZBL_TPM_MM_BASE+0xB6)
+//#define ZBL_NET_GET_CELL_INFO_RESULT (MSG_ID_ZBL_TPM_MM_BASE+0xB7)
+
+
+
/**************************************************************************
* Êý¾ÝÀàÐÍ *
@@ -834,6 +846,21 @@
UINT16 ext_ci;
} zblMmLocationInfo;
+typedef struct
+{
+ AtiCmdType cmd_type;
+ UINT8 mode;
+ UINT8 format;
+ CHAR oper[ZBL_LONG_OPER_MAX_LEN];
+ UINT8 act;
+} zblMmCopsSetReq;
+
+typedef struct
+{
+ UINT8 mode;
+} ZblSysMode;
+
+
/**************************************************************************
* ÀàÉùÃ÷ £¨¶ÔÓÚCÓïÑÔµÄÍ·Îļþ£¬¿É²Ã¼ô£© *
**************************************************************************/
@@ -1419,6 +1446,25 @@
*************************************************************************/
extern UINT32 dmp_net_get_simstat(VOID);
extern SINT32 dmp_get_pin_lock_state(AtiFacilityType fac, WORKMODE eWorkMode);
+
+/*************************************************************************
+* º¯ÊýÃû³Æ£º dmp_net_cur_oper_get
+* ¹¦ÄÜÃèÊö£º µ±Ç°ÔËÓªÉÌ»ñÈ¡
+* ²ÎÊý˵Ã÷£º (IN)£º
+ mode:0 --×Ô¶¯£¬1 -- ÊÖ¶¯
+ eWorkMode: WORK_MODE_AP ¿¨1£¬WORK_MODE_MODEM ¿¨2£¬WORK_MODE_NON δ֪ģʽ¡££¨Ô¤ÁôË«¿¨Ë«´ýʹÓ㬵¥¿¨Ã»ÓÐʵ¼ÊÒâÒ壩
+* OUT):
+
+* ·µ »Ø Öµ£º µ÷Ó÷µ»ØÖµ: 0±íʾ³É¹¦£¬-1±íʾʧ°Ü
+* ÆäËü˵Ã÷£º ¸Ãº¯Êý¹¦ÄÜʵÏÖ½á¹ûÒÔÏûÏ¢ÐÎʽ·µ»Ø£ºZBL_NET_PLMN_INFO
+*************************************************************************/
+extern SINT32 dmp_net_cur_oper_get (UINT32 mode,WORKMODE eWorkMode);
+extern SINT32 dmp_get_sysinfo(WORKMODE eWorkMode);
+extern SINT32 dmp_sysconfig_req(int mode);
+extern SINT32 dmp_oper_set_req(zblMmCopsSetReq* req);
+extern SINT32 dmp_mode_set_req (UINT8 mode);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_sms_interface.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_sms_interface.h
index 2d68118..36ad021 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_sms_interface.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/include/zbl_sms_interface.h
@@ -83,6 +83,9 @@
*/
#define ZBL_SMS_MAX_TPDU_LEN 176
+#define ZBL_SMS_SE_CMD_NAME_MAX_LEN 20
+#define ZBL_SMS_SE_MAX_TEXT_LENGTH 400
+
/* ¶ÌÏûÏ¢²ÎÊýSMS_PARAMÓÐЧÆÚvalid_timeµÄ¸÷¸ö˵Ã÷ */
#define ZBL_SMS_VP_UNLIMITED 255//ÔÀ´µÄ¶¨Òå#define SMS_VP_UNLIMITED 255
#define ZBL_SMS_VP_ONE_HOUR 11//ÔÀ´µÄ¶¨Òå#define SMS_VP_ONE_HOUR 11
@@ -278,6 +281,18 @@
#define ZBL_TPM_SMS_CMMB_WAPPUSH_RECEIVE_IND (MSG_ID_ZBL_TPM_SMS_BASE+0x26) //¶ÔÓ¦µÄ½á¹¹ÌåΪ ZblSmsCmmbPushNotice
+#define ZBL_TPM_SMS_GET_CENTER_NUMBER_REQ (MSG_ID_ZBL_TPM_SMS_BASE+0x27)
+#define ZBL_TPM_SMS_GET_CENTER_NUMBER_RSP (MSG_ID_ZBL_TPM_SMS_BASE+0x28)
+
+#define ZBL_TPM_SMS_SET_CENTER_NUMBER_REQ (MSG_ID_ZBL_TPM_SMS_BASE+0x29)
+#define ZBL_TPM_SMS_SET_CENTER_NUMBER_RSP (MSG_ID_ZBL_TPM_SMS_BASE+0x2A)
+
+#define ZBL_TPM_SMS_SEND_PDU_REQ (MSG_ID_ZBL_TPM_SMS_BASE+0x2B)
+#define ZBL_TPM_SMS_SEND_PDU_RSP (MSG_ID_ZBL_TPM_SMS_BASE+0x2C)
+
+#define ZBL_TPM_SMS_NEW_PDU_MSG (MSG_ID_ZBL_TPM_SMS_BASE+0x2D)
+#define ZBL_TPM_SMS_NEW_TEXT_MSG (MSG_ID_ZBL_TPM_SMS_BASE+0x2E)
+
typedef struct
{
DWORD buflen;
@@ -468,12 +483,13 @@
/* ¶ÌÐÅ·¢Ëͽá¹ûÊý¾Ý½á¹¹ */
typedef struct
{
- UINT8 sendResult;/*0: success, 1: failure*/
- UINT8 saveResult;/*0: success, 1: failure*/
+ UINT32 sendResult;/*0: success, 1: failure*/
+ UINT32 saveResult;/*0: success, 1: failure*/
UINT32 uiNodeAddr;
UINT32 uiSucNodeAddr;
ZblSmsSendModule modle;
WORKMODE workMode;
+ INT32 id;
} ZBL_SMS_SEND_RESULT;
/* ¶ÌÐŽÓÊÕµÄÊý¾Ý½á¹¹ */
@@ -546,6 +562,8 @@
{
UINT16 count; // Ⱥ·¢ºÅÂëµÄ¸öÊý, 1~20¡£
UINT16 index; // µ±Ç°ÎªµÚ¼¸¸öºÅÂë¡£
+ INT32 id;
+ UINT8 format;
} SMS_MUTINUM;
/* ºÅÂëµÄÊý¾Ý½á¹¹*/
@@ -1147,6 +1165,54 @@
UINT8 result_state;//µ±Ç°×´Ì¬ 1 isms ,2 normal sms ,3 have no idea
} ZblISmsState;
+/* ¶ÌÐÅÖÐÐĺÅÂë²éѯ½á¹ûµÄÊý¾Ý½á¹¹ */
+typedef struct
+{
+ UINT8 smsAddr[ZBL_SMS_CARD_RELATE_NUMBER_LEN + 1];
+ UINT8 result;/*0: success,otherwise(usually 1):failure*/
+ WORKMODE workMode;
+ SINT32 reason;
+} ZblScParamInfo;
+
+typedef struct
+{
+ UINT8 pdu_len;
+ UINT8 pdu_data[ZBL_SMS_MAX_TPDU_LEN];
+ SINT32 id;
+} ZblSmsPduData;
+
+typedef struct
+{
+ UINT8 iTotalLength;
+ UINT8 iTpduLength;
+ UINT8 strPdu[ZBL_SMS_MAX_TPDU_LEN];
+} ZblSmsIndPduData;
+
+typedef struct {
+ UINT8 year;
+ UINT8 month;
+ UINT8 day;
+ UINT8 hours;
+ UINT8 minutes;
+ UINT8 seconds;
+ UINT8 timezone;
+}ZblSmsIndScts;
+
+typedef struct {
+ CHAR oa[ZBL_SMS_SE_CMD_NAME_MAX_LEN];
+ CHAR alpha[ZBL_SMS_SE_CMD_NAME_MAX_LEN];
+ ZblSmsIndScts scts;
+ UINT8 tooa;;
+ UINT8 fo;
+ UINT8 pid;
+ UINT8 dcs;
+ CHAR sca[ZBL_SMS_SE_CMD_NAME_MAX_LEN];
+ UINT8 tosca;
+ UINT8 length;
+ UINT8 smRejected;/*0:received,1:rejected, 2:special sm received but already deal*/
+ CHAR text[ZBL_SMS_SE_MAX_TEXT_LENGTH];
+} ZblSmsIndTextData;
+
/***********************************************************************************************
* ½Ó¿Ú˵Ã÷
***********************************************************************************************/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/platadapt/osa/tp_osa.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/platadapt/osa/tp_osa.c
index 9a4c9aa..3d3dfa6 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/platadapt/osa/tp_osa.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/platadapt/osa/tp_osa.c
@@ -414,6 +414,7 @@
zOss_ASSERT (NULL != name);
zOss_ASSERT (NULL != entry);
SC_Trace(101,0,"tp_os_thread_create NULL == name || NULL == entry\n");
+ assert(0);
return OS_FAILURE;
}
@@ -422,6 +423,7 @@
if (ZOSS_INVALID_THREAD_ID == threadId)
{
SC_Trace(101,0,"tp_os_thread_create ZOSS_INVALID_THREAD_ID == threadId\n");
+ assert(0);
return OS_FAILURE;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/adapt_inner/zbl_psa_mm.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/adapt_inner/zbl_psa_mm.h
index a98e3db..51dc0c0 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/adapt_inner/zbl_psa_mm.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/adapt_inner/zbl_psa_mm.h
@@ -158,6 +158,51 @@
UINT8 res_or_auts[TAPI_MM_UICC_AUTH_CNF_LEN];
} TapiNetUiccAuthCnf;
+/* at+cops? */
+typedef struct
+{
+ SINT32 result;
+ UINT8 mode;
+ UINT8 format;
+ CHAR oper[ATI_MAX_LONG_OPER_LEN];
+ UINT8 act;
+} TapiNetCopsReadCnf;
+
+typedef struct
+{
+ AtiCmdType cmd_type;
+ UINT8 mode;
+ UINT8 format;
+ CHAR oper[ATI_MAX_LONG_OPER_LEN];
+ UINT8 act;
+} TapiNetCopsSetReq;
+
+
+/* at+cops=1,2,"46000",7 */
+/*
+typedef struct
+{
+ AtiCmdType cmd_type;
+ UINT8 mode;
+ UINT8 format;
+ CHAR oper[ATI_MAX_LONG_OPER_LEN];
+ UINT8 act;
+} TapiNetCopsSetReq;
+
+
+typedef struct
+{
+ AtiCmdType cmd_type;
+} TapiNetCopsGetReq;
+*/
+
+typedef struct
+{
+ AtiCmdType cmd_type;
+} TapiNetSysinfoReq;
+
+
+
/**************************************************************************
* È«¾Ö±äÁ¿ÉùÃ÷ *
**************************************************************************/
@@ -687,6 +732,10 @@
extern SINT32 tapi_net_boot_set(TapiNetBootSwitch netBootSwitch);
extern SINT32 tapi_net_mode_set(TapiNetModeSwitch netModeSwitch);
extern SINT32 tapi_net_get_lock_state();
+extern SINT32 tapi_net_get_cops_info();
+extern SINT32 tapi_net_get_sysinfo();
+extern SINT32 tapi_net_set_cops_info(TapiNetCopsSetReq* req);
+extern SINT32 tapi_net_set_mode(UINT8 mode);
#endif /* xxxx_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/adapt_inner/zbl_psa_sms.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/adapt_inner/zbl_psa_sms.h
index dacf64a..af5a178 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/adapt_inner/zbl_psa_sms.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/adapt_inner/zbl_psa_sms.h
@@ -25,6 +25,8 @@
#define TAPI_SMS_SE_ACKNOWLEDGE_NEW_MSG_RESULT (MSG_ID_TAPI_ATI_SMS_BASE + 0x03)
#define TAPI_SMS_SE_NEW_SMS_INFO (MSG_ID_TAPI_ATI_SMS_BASE + 0x04)
#define TAPI_SELECT_SERVICE_TYPE_RESULT (MSG_ID_TAPI_ATI_SMS_BASE + 0x05)
+#define TAPI_SMS_SE_NEW_TEXT_SMS (MSG_ID_TAPI_ATI_SMS_BASE + 0x06)
+
/*************************************************************************************/
/**************************************************************************
@@ -32,6 +34,8 @@
**************************************************************************/
#define TAPI_SMS_SE_MAX_USIM_BITMAP_LEN 202
#define TAPI_SMS_SE_MAX_PDU_LENGTH 176
+#define TAPI_SMS_SE_CMD_NAME_MAX_LEN 20
+#define TAPI_SMS_SE_MAX_TEXT_LENGTH 400
/* sms status(receive unread/receive read/unsent/sent) */
#define TAPI_SMS_SE_STATUS_UNREAD 0
@@ -94,6 +98,31 @@
UINT32 index;
} TapiSmsNewSmsInfo;
+typedef struct {
+ UINT8 year;
+ UINT8 month;
+ UINT8 day;
+ UINT8 hours;
+ UINT8 minutes;
+ UINT8 seconds;
+ UINT8 timezone;
+}TapiSmsSeScts;
+
+typedef struct {
+ CHAR oa[TAPI_SMS_SE_CMD_NAME_MAX_LEN];
+ CHAR alpha[TAPI_SMS_SE_CMD_NAME_MAX_LEN];
+ TapiSmsSeScts scts;
+ UINT8 tooa;
+ UINT8 fo;
+ UINT8 pid;
+ UINT8 dcs;
+ CHAR sca[TAPI_SMS_SE_CMD_NAME_MAX_LEN];
+ UINT8 tosca;
+ UINT8 length;
+ UINT8 smRejected;/*0:received,1:rejected, 2:special sm received but already deal*/
+ CHAR text[TAPI_SMS_SE_MAX_TEXT_LENGTH];
+} TapiSmsSeTextData;
+
/**************************************************************************
* È«¾Ö±äÁ¿ÉùÃ÷ *
**************************************************************************/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/server_inner/zbl_svr_mm.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/server_inner/zbl_svr_mm.h
index b3bd7fc..c10229b 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/server_inner/zbl_svr_mm.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/include/server_inner/zbl_svr_mm.h
@@ -135,6 +135,12 @@
#define ZBL_MM_CFUN_MODE_SWICH (MSG_ID_ZBL_MMI_MM_BASE + 0x43) // 0x8100
+#define ZBL_MM_NET_CUR_OPER_GET (MSG_ID_ZBL_MMI_MM_BASE + 0x44) // 0x8100
+#define ZBL_MM_NET_OPER_SET (MSG_ID_ZBL_MMI_MM_BASE + 0x45) // 0x8100
+#define ZBL_MM_NET_SYSINFO_GET (MSG_ID_ZBL_MMI_MM_BASE + 0x46) // 0x8100
+#define ZBL_MM_NET_MODE_SET (MSG_ID_ZBL_MMI_MM_BASE + 0x47) // 0x8100
+
+
/*ͨÓÃÒµÎñÄÜÁ¦*/
#define ZBL_MM_SET_QUERY_PENDING_PIN (MSG_ID_ZBL_MMI_MM_BASE + 0x55) // 0x8101
#define ZBL_MM_SET_VERIFY_PIN (MSG_ID_ZBL_MMI_MM_BASE + 0x56) // 0x8101
@@ -666,6 +672,13 @@
AtiFacilityType fac;
} ZblPinLockStateReq;
+typedef struct
+{
+ UINT8 mode;
+ UINT8 formate;
+ CHAR oper[20];
+ UINT8 act;
+} ZblCopsSetReq;
/**************************************************************************
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_psam_sc/src/zbl_psam.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_psam_sc/src/zbl_psam.c
index 342d492..99e5a81 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_psam_sc/src/zbl_psam.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_psam_sc/src/zbl_psam.c
@@ -251,6 +251,8 @@
case ATI_SMS_SUSS_CNF:
case ATI_SMS_SPSMSFULL_CNF:
case ATI_SMS_CSCS_CNF:
+ case ATI_SMS_CSDH_CNF:
+ case ATI_SMS_CMT_TEXT_IND:
{
//SC_Trace(0, 0, "tapiHandleAtiMsg() tapiSmsHandleMdmMsg msgid=0x%x", pMsg->msgId);
tapiSmsHandleMdmMsg(pMsg);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/inc/zbl_tapi_mmCom.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/inc/zbl_tapi_mmCom.h
index 684ae83..3f0ed68 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/inc/zbl_tapi_mmCom.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/inc/zbl_tapi_mmCom.h
@@ -43,6 +43,7 @@
AtiMbauCnf mbauCnf;
AtiZpukCnf zpukCnf;
AtiIccidCnf iccidCnf;
+ AtiSysInfoCnf sysinfoCnf;
}
TapiNetCmdComCnf;
@@ -109,6 +110,7 @@
const CHAR ss_ptr[ZBL_CC_MAX_NUMBER_LENGTH];
} TapiNetSsCfTable;
+/*
typedef struct
{
AtiCmdType cmd_type;
@@ -117,6 +119,7 @@
CHAR oper[ATI_MAX_LONG_OPER_LEN];
UINT8 act;
} TapiNetCopsSetReq;
+*/
typedef struct
{
@@ -183,6 +186,15 @@
SINT32 tapiNetCopsTestReq(TapiNetCopsTestReq *copsSetReq);
SINT32 tapiNetCopsTestWait(AtiCopsTestCnf* tpReturn, TapiNetCopsTestReq* tpReq);
SINT32 tapiNetCopsTestCnf(ZBL_CHANNEL_MSG_INFO *pMsg);
+//net_demoÐÂÔö
+SINT32 tapiNetCopsGetReq(void);
+SINT32 tapiNetCopsGetWait(TapiNetCopsReadCnf* tpReturn);
+SINT32 tapiNetCopsGetCnf(ZBL_CHANNEL_MSG_INFO *pMsg);
+SINT32 tapiNetSysinfoWait(AtiSysInfoCnf* tpReturn, TapiNetSysinfoReq* tpReq);
+
+
+
+
SINT32 tapiNetCardModeReq(VOID);
SINT32 tapiNetCardModeWait(SINT32 *pCardMode);
SINT32 tapiNetCardModeCnf(ZBL_CHANNEL_MSG_INFO *pMsg);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/inc/zbl_tapi_smsCom.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/inc/zbl_tapi_smsCom.h
index 2ea444a..43e8a20 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/inc/zbl_tapi_smsCom.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/inc/zbl_tapi_smsCom.h
@@ -44,6 +44,7 @@
AtiCnmaCnf cnma_cnf;
AtiCmmsCnf cmms_cnf;
AtiZmenaCnf zmena_cnf;
+ AtiCsmsCnf csdh_cnf;
AtiSmsListEndInd sm_list_end;
}
TapiSmsComCmdCnf;
@@ -152,6 +153,8 @@
SINT32 tapiSmsSendDataToSvr(UINT32 id, CONST VOID *data, UINT32 size);
SINT32 tapiSmsCnmaCnf(VOID * pMsg);
SINT32 tapiSmsCscsCnf(VOID *pMsg);
+SINT32 tapiSmsCsdhWait(AtiCmdType cmdType,UINT8 show);
+SINT32 tapiSmsCsdhCnf(VOID * pMsg);
#endif /* xxxx_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/src/zbl_tapi_mmCom.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/src/zbl_tapi_mmCom.c
index 4e5b5fa..73f09a3 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/src/zbl_tapi_mmCom.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/src/zbl_tapi_mmCom.c
@@ -991,6 +991,86 @@
return TAPI_MM_RETURN_TRUE;
}
+SINT32 tapiNetCopsGetReq(void)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ AtiCopsReq *req_ptr = NULLPTR;
+ SINT32 snd_ret = TAPI_MM_RETURN_FALSE;
+
+ msg_ptr = zblMallocChannelMsg(sizeof(AtiCopsReq));
+ if(NULLPTR == msg_ptr)
+ {
+ return TAPI_MM_RETURN_FALSE;
+ }
+
+ msg_ptr->msgId = ATI_MM_COPS_REQ;
+ msg_ptr->msgSize = sizeof(AtiCopsReq);
+ req_ptr = (AtiCopsReq*)msg_ptr->msgData;
+
+ memset(req_ptr,0,sizeof(AtiCopsReq));
+
+ req_ptr->cmd_type = CMD_TYPE_READ;
+
+ snd_ret = tapiSendMsgToAti((VOID*)msg_ptr);
+
+ return snd_ret;
+}
+
+SINT32 tapiNetCopsGetWait(TapiNetCopsReadCnf* tpReturn)
+{
+ TapiNetCmdComInfo *cmd_info_ptr = tapiNetGetNetCmdComInfo();
+
+ /* ´´½¨ÐźÅÁ¿ */
+ cmd_info_ptr->sema_id = tp_os_sema_create("copsget sema", 0);
+ if(OS_FAILURE == cmd_info_ptr->sema_id)
+ {
+ return TAPI_MM_RETURN_FALSE;
+ }
+
+ tapiNetComWaitPre(ATI_MM_COPS_READ_CNF, cmd_info_ptr);
+
+ /* ·¢ËÍÃüÁî */
+ if(TAPI_MM_RETURN_FALSE == tapiNetCopsGetReq())
+ {
+ tp_os_sema_delete(cmd_info_ptr->sema_id);
+ return TAPI_MM_RETURN_FALSE;
+ }
+
+ tapiNetComWaitFun(ATI_MM_COPS_READ_CNF, cmd_info_ptr->sema_id, cmd_info_ptr);
+
+ tp_os_mem_cpy(tpReturn, (TapiNetCopsReadCnf*)&cmd_info_ptr->cmd_cnf.operReadCnf, sizeof(TapiNetCopsReadCnf));
+
+ return TAPI_MM_RETURN_TRUE;
+}
+
+
+SINT32 tapiNetCopsGetCnf(ZBL_CHANNEL_MSG_INFO *pMsg)
+{
+ TapiNetCmdComInfo *cmd_info_ptr = &(g_tapiMmComContext.cmdComInfo);
+
+ if(NULLPTR == pMsg)
+ {
+ return TAPI_MM_RETURN_FALSE;
+ }
+
+ if((TRUE == cmd_info_ptr->is_waiting) && (ATI_MM_COPS_READ_CNF == cmd_info_ptr->cmd_id))
+ {
+ memcpy(&(cmd_info_ptr->cmd_cnf.operReadCnf), (AtiCopsReadCnf*)(pMsg->msgData), sizeof(AtiCopsReadCnf));
+
+ if(OS_FAILURE != cmd_info_ptr->sema_id)
+ {
+ tp_os_sema_put(cmd_info_ptr->sema_id);
+ }
+ }
+ else
+ {
+ tapiNetHandleForCopsRead(pMsg->msgData);
+ }
+
+ return TAPI_MM_RETURN_TRUE;
+}
+
+
SINT32 tapiNetCardModeReq(VOID)
{
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/src/zbl_tapi_smsCom.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/src/zbl_tapi_smsCom.c
index 7a14283..27ea9bf 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/src/zbl_tapi_smsCom.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi/src/zbl_tapi_smsCom.c
@@ -559,7 +559,10 @@
if(0 != cmd_info_ptr->cmd_cnf.csca_cnf.result)
{
tp_os_mutex_put(Sms_mutexId);
- return TAPI_SMS_RETURN_FALSE;
+
+ SC_Trace(ZBL_SMS, 0, "[ZBL_SMS] tapiSmsCscaWait result=%d",cmd_info_ptr->cmd_cnf.csca_cnf.result);
+ return cmd_info_ptr->cmd_cnf.csca_cnf.result;
+ //return TAPI_SMS_RETURN_FALSE;
}
if(CMD_TYPE_READ == cmdType)
@@ -1086,7 +1089,8 @@
if(0 != cmd_info_ptr->cmd_cnf.cmgs_cnf.result)
{
tp_os_mutex_put(Sms_mutexId);
- return TAPI_SMS_RETURN_FALSE;
+ return cmd_info_ptr->cmd_cnf.cmgs_cnf.result;
+ //return TAPI_SMS_RETURN_FALSE;
}
tp_os_mutex_put(Sms_mutexId);
return TAPI_SMS_RETURN_TRUE;
@@ -1418,6 +1422,91 @@
return TAPI_SMS_RETURN_TRUE;
}
+SINT32 tapiSmsCsdhReq(AtiCmdType cmdType, UINT8 show)
+{
+ ZBL_CHANNEL_MSG_INFO * msg_ptr = NULLPTR;
+ AtiCsdhReq * req_ptr = NULLPTR;
+
+ msg_ptr = zblMallocChannelMsg(sizeof(AtiCsdhReq));
+ if (NULLPTR == msg_ptr)
+ {
+ return TAPI_SMS_RETURN_FALSE;
+ }
+
+ msg_ptr->msgId = ATI_SMS_CSDH_REQ;
+ msg_ptr->msgSize = sizeof(AtiCsdhReq);
+
+ req_ptr = (AtiCsdhReq*)msg_ptr->msgData;
+ req_ptr->cmd_type = cmdType;
+ req_ptr->show = show;
+
+ if(OS_SUCCESS != tapiSendMsgToAti((VOID*)msg_ptr))
+ {
+ return TAPI_SMS_RETURN_FALSE;
+ }
+ SC_Trace(ZBL_SMS, 0, "msg ATI_SMS_CSDH_REQ has been send to CI!in zblSmsCsmsReq()\r\n");
+
+ return TAPI_SMS_RETURN_TRUE;
+}
+
+SINT32 tapiSmsCsdhWait(AtiCmdType cmdType,UINT8 show)
+{
+ TapiSmsComCmdInfo *cmd_info_ptr = &(g_TapiSmsComContext.smsComCmdInfo);
+ tp_os_mutex_get(Sms_mutexId,OS_WAIT_FOREVER);
+ /* create the semaphore */
+ cmd_info_ptr->sema_id = tp_os_sema_create("csdh sema", 0);
+ if (OS_FAILURE == cmd_info_ptr->sema_id)
+ {
+ tp_os_mutex_put(Sms_mutexId);
+ return TAPI_SMS_RETURN_FALSE;
+ }
+
+ tapiSmsComWaitPre(ATI_SMS_CSDH_CNF, cmd_info_ptr);
+ /*send the at+csms command*/
+ if (TAPI_SMS_RETURN_TRUE != tapiSmsCsdhReq(cmdType,show))
+ {
+ tp_os_sema_delete(cmd_info_ptr->sema_id);
+ tp_os_mutex_put(Sms_mutexId);
+ return TAPI_SMS_RETURN_FALSE;
+ }
+
+ tapiSmsComWaitFun(ATI_SMS_CSDH_CNF, cmd_info_ptr->sema_id, cmd_info_ptr);
+
+ /*judge the result of the confirm message*/
+ if (0 != cmd_info_ptr->cmd_cnf.csdh_cnf.result)
+ {
+ tp_os_mutex_put(Sms_mutexId);
+ return TAPI_SMS_RETURN_FALSE;
+ }
+ tp_os_mutex_put(Sms_mutexId);
+ return TAPI_SMS_RETURN_TRUE;
+}
+SINT32 tapiSmsCsdhCnf(VOID * pMsg)
+{
+ TapiSmsComCmdInfo * cmd_info_ptr = &(g_TapiSmsComContext.smsComCmdInfo);
+
+ if (NULLPTR == pMsg)
+ {
+ return TAPI_SMS_RETURN_FALSE;
+ }
+
+ if ((TRUE == cmd_info_ptr->is_waiting) && (ATI_SMS_CSDH_CNF == cmd_info_ptr->cmd_id))
+ {
+ memcpy((VOID*)&(cmd_info_ptr->cmd_cnf.csdh_cnf),pMsg, sizeof(AtiCsdhCnf));
+
+ if (OS_FAILURE != cmd_info_ptr->sema_id)
+ {
+ tp_os_sema_put(cmd_info_ptr->sema_id);
+ }
+ }
+ else
+ {
+ return TAPI_SMS_RETURN_FALSE;
+ }
+
+ return TAPI_SMS_RETURN_TRUE;
+}
+
SINT32 tapiSmsInternalAddNodeToBitMap(UINT8 posInByte, UINT32 posInMap)
{
UINT8 *bitmap = simBitmap.strBitmap;
@@ -1609,14 +1698,14 @@
Bytes2String(pTapiPdudata->strPdu, pdu, pTapiPdudata->iTotalLength);
SC_Trace(ZBL_SMS, 0, "the length of tpdu is (%d)! in tapi_sms_se_send()!",tpduLen);
- //SC_Trace(ZBL_SMS, 0, "in tapi_sms_se_send()! the pdu is: %s",pdu);
+ SC_Trace(ZBL_SMS, 0, "in tapi_sms_se_send()! the pdu is: %s",pdu);
iRet = tapiSmsCmgsWait(CMD_TYPE_SET, tpduLen, pdu);
if (TAPI_SMS_RETURN_TRUE != iRet)
{
SC_Trace(ZBL_SMS, 0, "the at command failed! in tapi_sms_se_send()!");
- return TAPI_SMS_RETURN_FALSE;
+ return iRet; //TAPI_SMS_RETURN_FALSE;
}
*pMsgReg = g_TapiSmsComContext.smsComCmdInfo.cmd_cnf.cmgs_cnf.mr;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/inc/zbl_tapi_mm.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/inc/zbl_tapi_mm.h
index 513fcc3..803821c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/inc/zbl_tapi_mm.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/inc/zbl_tapi_mm.h
@@ -221,6 +221,7 @@
SINT32 tapiNetZemciWait(UINT8 iReportType);
SINT32 tapiNetZemciCnf(ZBL_CHANNEL_MSG_INFO *pMsg);
SINT32 tapiNetZemciInd(ZBL_CHANNEL_MSG_INFO *pMsg);
+SINT32 tapiNetZemsciqInd(ZBL_CHANNEL_MSG_INFO *pMsg);
SINT32 tapiNetZuliCnf(ZBL_CHANNEL_MSG_INFO *pMsg);
//add by majun for volte 20160406
static SINT32 tapiNetImsVModeInd(ZBL_CHANNEL_MSG_INFO *pMsg);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/inc/zbl_tapi_sms.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/inc/zbl_tapi_sms.h
index 5783087..3933c2f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/inc/zbl_tapi_sms.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/inc/zbl_tapi_sms.h
@@ -86,6 +86,7 @@
SINT32 tapiSmsHandleMdmMsg(ZBL_CHANNEL_MSG_INFO *pMsg);
SINT32 tapiSmsUsimReadyInd(VOID *pData);
SINT32 tapiSmsNewSmsIndForAt(VOID * pMsgInfoPtr);
+SINT32 tapiSmsNewSmsTextIndForAt(VOID * pMsgInfoPtr);
SINT32 tapiSmsNewSmsAckCnf(UINT16 iResult);
SINT32 tapiSmsNewSmsStorageIndForAt(VOID * pMsgInfoPtr);
SINT32 tapiSmsTspWaitPre(UINT32 cmd_id, TapiSmsTspCmdInfo *cmdInfoPtr);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/src/zbl_tapi_mm.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/src/zbl_tapi_mm.c
index 6902ee3..f7f68bd 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/src/zbl_tapi_mm.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/src/zbl_tapi_mm.c
@@ -80,7 +80,8 @@
{ATI_MM_SYSCONFIG_CNF, tapiNetSysconfigCnf},
{ATI_MM_ZEMLC_CNF, tapiNetZemlcCnf},
{ATI_MM_ZEMCI_CNF, tapiNetZemciCnf},
- {ATI_MM_ZEMCI_IND, tapiNetZemciInd},
+ //{ATI_MM_ZEMCI_IND, tapiNetZemciInd},
+ {ATI_MM_ZEMCI_IND, tapiNetZemsciqInd},
{ATI_MM_ZSQR_CNF, tapiNetZsqrCnf},
{ATI_MM_ZSQR_IND, tapiNetZsqrInd},
{ATI_MM_ZULI_CNF, tapiNetZuliCnf},
@@ -1347,6 +1348,32 @@
return TAPI_MM_RETURN_TRUE;
}
+SINT32 tapiNetSysinfoWait(AtiSysInfoCnf* tpReturn, TapiNetSysinfoReq* tpReq)
+{
+ TapiNetCmdComInfo *cmd_info_ptr = tapiNetGetNetCmdComInfo();
+
+ /* ´´½¨ÐźÅÁ¿ */
+ cmd_info_ptr->sema_id = tp_os_sema_create("sysinfo sema", 0);
+ if(OS_FAILURE == cmd_info_ptr->sema_id)
+ {
+ return TAPI_MM_RETURN_FALSE;
+ }
+
+ tapiNetComWaitPre(ATI_MM_SYSINFO_CNF, cmd_info_ptr);
+
+ /* ·¢ËÍÃüÁî */
+ if(TAPI_MM_RETURN_FALSE == tapiNetSysinfoReq())
+ {
+ tp_os_sema_delete(cmd_info_ptr->sema_id);
+ return TAPI_MM_RETURN_FALSE;
+ }
+
+ tapiNetComWaitFun(ATI_MM_SYSINFO_CNF, cmd_info_ptr->sema_id, cmd_info_ptr);
+
+ tp_os_mem_cpy(tpReturn, &cmd_info_ptr->cmd_cnf.sysinfoCnf, sizeof(AtiSysInfoCnf));
+
+ return TAPI_MM_RETURN_TRUE;
+}
static SINT32 tapiNetSysinfoCnf(ZBL_CHANNEL_MSG_INFO *pMsg)
@@ -1369,6 +1396,24 @@
tapiNetNotifyZsvrRegisterStatus(&g_TapiMmTspContext.netStatusinfo);
}
+ //g_TapiMmTspContextÐÂÔösysinfoCnf£¬°ÑpMsgÄÚÈÝ´«µ½cmd_info_ptrµÄsysinfoCnfÖÐ
+ TapiNetCmdComInfo *cmd_info_ptr = tapiNetGetNetCmdComInfo();
+
+ if(NULLPTR == pMsg)
+ {
+ return TAPI_MM_RETURN_FALSE;
+ }
+
+ if((TRUE == cmd_info_ptr->is_waiting) && (ATI_MM_SYSINFO_CNF == cmd_info_ptr->cmd_id))
+ {
+ memcpy(&(cmd_info_ptr->cmd_cnf.sysinfoCnf), (AtiSysInfoCnf*)(pMsg->msgData), sizeof(AtiSysInfoCnf));
+
+ if(OS_FAILURE != cmd_info_ptr->sema_id)
+ {
+ tp_os_sema_put(cmd_info_ptr->sema_id);
+ }
+ }
+
return TAPI_MM_RETURN_TRUE;
}
@@ -2068,6 +2113,21 @@
return TAPI_MM_RETURN_TRUE;
}
+SINT32 tapiNetZemsciqInd(ZBL_CHANNEL_MSG_INFO *pMsg)
+{
+
+ if(NULLPTR == pMsg || NULLPTR == pMsg->msgData)
+ {
+ return TAPI_MM_RETURN_FALSE;
+ }
+ //SC_Trace(0, 0, "\r\n tapiNetZemsciInd data %s len %d\r\n", (char*)pMsg->msgData, pMsg->msgSize);
+
+ tapiNetSendDataToSvr(TAPI_CELL_DATA_IND, (char*)pMsg->msgData, pMsg->msgSize);
+
+ return TAPI_MM_RETURN_TRUE;
+}
+
+
SINT32 tapiNetZuliReq(UINT8 iLocalInfoType)
{
@@ -3861,6 +3921,60 @@
return 0;
}
+
+SINT32 tapi_net_get_cops_info()
+{
+ TapiNetCopsReadCnf tpReturn = {0};
+ if(-1 == tapiNetCopsGetWait(&tpReturn))
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ tp_itc_message_post(ZBL_NET_CUR_OPER_RESULT, (VOID*)&tpReturn, sizeof(TapiNetCopsReadCnf));
+ return 0;
+}
+
+SINT32 tapi_net_get_sysinfo()
+{
+ AtiSysInfoCnf tpReturn = {0};
+ TapiNetSysinfoReq tpReq = {0};
+ tpReq.cmd_type = CMD_TYPE_SET;
+ if(-1 == tapiNetSysinfoWait(&tpReturn, &tpReq))
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ tp_itc_message_post(ZBL_NET_SYSINFO_RESULT, (VOID*)&tpReturn, sizeof(AtiSysInfoCnf));
+ return 0;
+}
+
+SINT32 tapi_net_set_cops_info(TapiNetCopsSetReq* req)
+{
+ if(-1 == tapiNetCopsSetWait(req))
+ {
+ zblAssert(0);
+ return -1;
+ }
+ UINT8 ret = 0;
+ tp_itc_message_post(ZBL_NET_COPS_SET_RESULT, (VOID*)&ret, sizeof(UINT8));
+ return 0;
+}
+
+SINT32 tapi_net_set_mode(UINT8 mode)
+{
+ if(-1 == tapiNetModeWait(CMD_TYPE_SET, mode))
+ {
+ SC_Trace(ZBL_MM,4,"%s: NULL msg!!",__FUNCTION__);
+ zblAssert(0);
+ return -1;
+ }
+ UINT8* ret = 0;
+ tp_itc_message_post(ZBL_NET_MODE_SET_RESULT, (VOID*)&ret, sizeof(UINT8));
+ return 0;
+}
+
/**************************************************************************
* ÏûÏ¢´¦Àíº¯ÊýʵÏÖ *
**************************************************************************/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/src/zbl_tapi_sms.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/src/zbl_tapi_sms.c
index ed23a78..4da1e00 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/src/zbl_tapi_sms.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_adapter/zbl_tapi_sc/src/zbl_tapi_sms.c
@@ -296,6 +296,12 @@
return iRet;
}
+ iRet = tapiSmsCscsWait(CMD_TYPE_SET, CH_SET_GSM);
+ if(TAPI_SMS_RETURN_FALSE == iRet)
+ {
+ return iRet;
+ }
+
iRet = tapiSmsCgSmsWait(CMD_TYPE_SET, CGSMS_TYPE_CS_ONLY);
if(TAPI_SMS_RETURN_FALSE == iRet)
@@ -303,6 +309,13 @@
return iRet;
}
+ iRet = tapiSmsCsdhWait(CMD_TYPE_SET, 1);
+
+ if(TAPI_SMS_RETURN_FALSE == iRet)
+ {
+ return iRet;
+ }
+
tp_os_mem_set(&recPara, 0, sizeof(AtiCnmiReq));
recPara.mode = 2;
recPara.mt = 2;
@@ -848,6 +861,8 @@
{ATI_SMS_ZMENA_CNF, tapiSmsZmenaCnf},
{ATI_SMS_ZMGR_CNF, tapiSmsZmgrCnf},
{ATI_SMS_CSCS_CNF, tapiSmsCscsCnf},
+ {ATI_SMS_CSDH_CNF, tapiSmsCsdhCnf},
+ {ATI_SMS_CMT_TEXT_IND, tapiSmsNewSmsTextIndForAt},
{0, NULLPTR}
};
@@ -929,10 +944,11 @@
}
smsSePduData.iTotalLength = String2Bytes(cmtPdu.pdu, smsSePduData.strPdu, iTotalStrLen);
smsSePduData.iTpduLength = smsSePduData.iTotalLength - smsSePduData.strPdu[0] - 1;
-
+ SC_Trace(ZTE_BL, 0, "tapiSmsNewSmsIndForAt send TAPI_SMS_SE_NEW_SMS\n");
tapiSmsSendDataToSvr(TAPI_SMS_SE_NEW_SMS, &smsSePduData, sizeof(TapiSmsSePduData));
-
- if(zblSmsJudgeMemIsFull())
+
+ //if(zblSmsJudgeMemIsFull())
+ if(0)
{
TapiSmsSePduData tapiPdudata = {0};
tapiPdudata.strPdu[0] = 0x00;
@@ -950,6 +966,41 @@
return TAPI_SMS_RETURN_TRUE;
}
+SINT32 tapiSmsNewSmsTextIndForAt(VOID * pMsgInfoPtr)
+{
+ SINT32 iTotalStrLen = 0;
+ AtiCmtTextInd cmtPdu = {0};
+
+ if(NULL == pMsgInfoPtr)
+ {
+ return TAPI_SMS_RETURN_FALSE;
+ }
+
+ memcpy((VOID*)&cmtPdu, pMsgInfoPtr, sizeof(AtiCmtTextInd));
+
+ SC_Trace(ZTE_BL, 0, "tapiSmsNewSmsTextIndForAt send TAPI_SMS_SE_NEW_TEXT_SMS\n");
+ tapiSmsSendDataToSvr(TAPI_SMS_SE_NEW_TEXT_SMS, &cmtPdu, sizeof(AtiCmtTextInd));
+
+ //if(zblSmsJudgeMemIsFull())
+ if(0)
+ {
+ TapiSmsSePduData tapiPdudata = {0};
+ tapiPdudata.strPdu[0] = 0x00;
+ tapiPdudata.strPdu[1] = 0xD3;
+ tapiPdudata.strPdu[2] = 0x00;
+ tapiPdudata.iTotalLength = 3;
+ tapiPdudata.iTpduLength = 3;
+ SC_Trace(ZTE_BL, 0, "tapiSmsSeAcknowledgeNewMsg(ZBL_SMS_SE_NACK_WITH_PDU, &tapiPdudata) \n");
+ tapiSmsSeAcknowledgeNewMsg(ZBL_SMS_SE_NACK_WITH_PDU, &tapiPdudata);
+ }
+ else
+ {
+ SC_Trace(ZTE_BL, 0, "tapiSmsSeAcknowledgeNewMsg(1, NULL) \n");
+ tapiSmsSeAcknowledgeNewMsg(1, NULL);
+ }
+
+ return TAPI_SMS_RETURN_TRUE;
+}
SINT32 tapiSmsNewSmsAckCnf(UINT16 iResult)
{
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_common/src/zbl_common.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_common/src/zbl_common.c
index cba5c7c..00ab7e9 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_common/src/zbl_common.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_common/src/zbl_common.c
@@ -504,7 +504,7 @@
case TAPI_SMS_SE_ACKNOWLEDGE_NEW_MSG_RESULT:
case TAPI_SMS_SE_NEW_SMS_INFO:
case TAPI_SELECT_SERVICE_TYPE_RESULT:
-
+ case TAPI_SMS_SE_NEW_TEXT_SMS:
{
zblSmsHandleMdmMsg(pMsg);
//SC_Trace(ZTE_BL, PRN_NOMAL, "pMsg->msgId = %d", pMsg->msgId);
@@ -608,6 +608,10 @@
case ZBL_RESET_SUBSYSTEM_IND:
case ZBL_MM_POWER_SAVE_REQ:
case ZBL_MM_NET_QUERY_LOCK_STATE:
+ case ZBL_MM_NET_CUR_OPER_GET:
+ case ZBL_MM_NET_OPER_SET:
+ case ZBL_MM_NET_SYSINFO_GET:
+ case ZBL_MM_NET_MODE_SET:
{
//SC_Trace(ZTE_BL, PRN_NOMAL, "zblHandleMmiMsg mm pMsg->msgId = %x", pMsg->msgId);
zblMmHandleMmiMsg(pMsg);
@@ -812,6 +816,9 @@
/*huanglei 2010-11-19*/
case ZBL_INTERNAL_SMS_139OPEN_SEND:/* send 139 open sm*/
case ZBL_INTERNAL_SMS_FEITION_SEND: // send feition sms
+ case ZBL_TPM_SMS_GET_CENTER_NUMBER_REQ:
+ case ZBL_TPM_SMS_SET_CENTER_NUMBER_REQ:
+ case ZBL_TPM_SMS_SEND_PDU_REQ:
{
zblSmsHandleMmiMsg(pMsg);
break;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/inc/zbl_mm_fnc.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/inc/zbl_mm_fnc.h
index 0a2b870..557512c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/inc/zbl_mm_fnc.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/inc/zbl_mm_fnc.h
@@ -184,6 +184,14 @@
static SINT32 zblNetRegisterAp(VOID);
static SINT32 zblHandleNetRegisterState(ZBL_CHANNEL_MSG_INFO *pMsg);
static SINT32 zblHandleNetDeregisterReq(ZBL_CHANNEL_MSG_INFO *pMsg );
+//net_demoÐÂÔö
+static SINT32 zblHandleNetCopsReadReq(ZBL_CHANNEL_MSG_INFO *pMsg );
+static SINT32 zblHandleNetCopsSetReq(ZBL_CHANNEL_MSG_INFO *pMsg );
+static SINT32 zblHandleNetSysinfoReq(ZBL_CHANNEL_MSG_INFO *pMsg );
+static SINT32 zblHandleNetModeSetReq(ZBL_CHANNEL_MSG_INFO *pMsg );
+
+
+
static SINT32 zblNetDeregisterAp(VOID);
static SINT32 zblHandleNetDeregister(ZBL_CHANNEL_MSG_INFO *pMsg);
static SINT32 zblHandleNetDeregisterFail(ZBL_CHANNEL_MSG_INFO *pMsg);
@@ -232,6 +240,7 @@
static SINT32 zblHandleNetUnLockCellCmdSucc(ZBL_CHANNEL_MSG_INFO *pMsg);
static SINT32 zblHandleNetUnLockCellCmdFail(ZBL_CHANNEL_MSG_INFO *pMsg);
static SINT32 zblHandleNetCellReadDataInd(ZBL_CHANNEL_MSG_INFO *pMsg);
+static SINT32 zblHandleNetCellGetDataInd(ZBL_CHANNEL_MSG_INFO *pMsg);
SINT32 zblHandleModfiyPinReq(ZBL_CHANNEL_MSG_INFO *pMsg );
VOID zblHandleNetPrintRegisterState(ZblNetRegisterState *pRegisterState);
VOID zblHandleNetPrintNetStateInfo(ZblNetStatusInfo *pStatusInfo);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/src/zbl_mm.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/src/zbl_mm.c
index ae0702e..728909f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/src/zbl_mm.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/src/zbl_mm.c
@@ -2131,11 +2131,6 @@
return tapi_net_get_iccid(strIccid);
}
-UINT32 dmp_net_get_simstat(VOID)
-{
- return tapi_net_get_sim_state();
-}
-
SINT32 dmp_get_pin_lock_state(AtiFacilityType fac, WORKMODE eWorkMode)
{
ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
@@ -2170,4 +2165,184 @@
return 0;
}
+
+/*************************************************************************
+* º¯ÊýÃû³Æ£º dmp_net_cur_oper_get
+* ¹¦ÄÜÃèÊö£º µ±Ç°ÔËÓªÉÌ»ñÈ¡
+* ²ÎÊý˵Ã÷£º (IN)£º
+ mode:0 --×Ô¶¯£¬1 -- ÊÖ¶¯
+ eWorkMode: WORK_MODE_AP ¿¨1£¬WORK_MODE_MODEM ¿¨2£¬WORK_MODE_NON δ֪ģʽ¡££¨Ô¤ÁôË«¿¨Ë«´ýʹÓ㬵¥¿¨Ã»ÓÐʵ¼ÊÒâÒ壩
+* OUT):
+
+* ·µ »Ø Öµ£º µ÷Ó÷µ»ØÖµ: 0±íʾ³É¹¦£¬-1±íʾʧ°Ü
+* ÆäËü˵Ã÷£º ¸Ãº¯Êý¹¦ÄÜʵÏÖ½á¹ûÒÔÏûÏ¢ÐÎʽ·µ»Ø£ºZBL_NET_PLMN_INFO
+*************************************************************************/
+SINT32 dmp_net_cur_oper_get (UINT32 mode,WORKMODE eWorkMode)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ SINT32 snd_ret = -1;
+
+ SC_Trace(ZBL_MM, 2, "%s: <%d>",__FUNCTION__,__LINE__);
+
+ msg_ptr = zblMallocChannelMsg(0);
+ if(NULLPTR == msg_ptr)
+ {
+ zblAssert(0);
+ return -1;
+ }
+ msg_ptr->msgId = ZBL_MM_NET_CUR_OPER_GET;
+ msg_ptr->msgFrom = eWorkMode;
+ msg_ptr->msgSize = 0;
+
+ /* send message to zblRcvMmiQueue */
+ snd_ret = tp_os_queue_send(zblRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER);
+ if((SINT32)OS_FAILURE == snd_ret)
+ {
+ SC_Trace(ZBL_MM, 2, "%s: tp_os_queue_send fail! <%d>",__FUNCTION__,__LINE__);
+ zblFreeChannelMsg(&msg_ptr);
+ assert(0);
+ return -1;
+ }
+ return 0;
+}
+
+SINT32 dmp_get_sysinfo(WORKMODE eWorkMode)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ SINT32 snd_ret = -1;
+
+ SC_Trace(ZBL_MM, 0, "dmp_get_pin_lock_state");
+
+ msg_ptr = zblMallocChannelMsg(sizeof(ZblPinLockStateReq));
+ if(NULLPTR == msg_ptr)
+ {
+ zblAssert(0);
+ return -1;
+ }
+ msg_ptr->msgId = ZBL_MM_NET_SYSINFO_GET;
+ msg_ptr->msgFrom = eWorkMode;
+ msg_ptr->msgSize = 0;
+
+ /* send message to zblRcvMmiQueue */
+ snd_ret = tp_os_queue_send(zblRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER);
+ if((SINT32)OS_FAILURE == snd_ret)
+ {
+ zblFreeChannelMsg(&msg_ptr);
+ assert(0);
+ return -1;
+ }
+
+ return 0;
+}
+
+SINT32 dmp_sysconfig_req(int mode)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ ZBLNetSwitchModeReq *pSwitchModeReq = NULL;
+
+ SINT32 snd_ret = -1;
+
+ SC_Trace(ZBL_MM, 0, "dmp_sysconfig_req");
+
+ msg_ptr = zblMallocChannelMsg(sizeof(ZblPinLockStateReq));
+ if(NULLPTR == msg_ptr)
+ {
+ zblAssert(0);
+ return -1;
+ }
+ msg_ptr->msgId = ZBL_MM_NET_SWITCH_MODE_REQ;
+ msg_ptr->msgFrom = WORK_MODE_AP;
+ msg_ptr->msgSize = sizeof(ZBLNetSwitchModeReq);
+ pSwitchModeReq = (ZBLNetSwitchModeReq*)msg_ptr->msgData;
+ pSwitchModeReq->switchmode = mode;
+
+ /* send message to zblRcvMmiQueue */
+ snd_ret = tp_os_queue_send(zblRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER);
+ if((SINT32)OS_FAILURE == snd_ret)
+ {
+ zblFreeChannelMsg(&msg_ptr);
+ assert(0);
+ return -1;
+ }
+
+ return 0;
+}
+
+SINT32 dmp_oper_set_req(zblMmCopsSetReq* req)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ zblMmCopsSetReq *req_ptr = NULLPTR;
+ SINT32 snd_ret = -1;
+
+ SC_Trace(ZBL_MM, 1, "dmp_oper_set_req enter");
+
+ msg_ptr = zblMallocChannelMsg(sizeof(zblMmCopsSetReq));
+ if(NULLPTR == msg_ptr)
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ msg_ptr->msgId = ZBL_MM_NET_OPER_SET;
+ msg_ptr->msgFrom = WORK_MODE_AP;
+ msg_ptr->msgSize = sizeof(zblMmCopsSetReq);
+
+ req_ptr = (zblMmCopsSetReq*)msg_ptr->msgData;
+ req_ptr->mode = req->mode;
+ req_ptr->format = req->format;
+ req_ptr->act = req->act;
+ memcpy(req_ptr->oper, req->oper, ZBL_LONG_OPER_MAX_LEN-1);
+
+ SC_Trace(ZBL_MM, 1, "dmp_net_se_switch_mode tp_os_queue_send");
+
+ /* send message to zblRcvMmiQueue */
+ snd_ret = tp_os_queue_send(zblRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER);
+
+ if((SINT32)OS_FAILURE == snd_ret)
+ {
+ zblFreeChannelMsg(&msg_ptr);
+ assert(0);
+ }
+
+ return 0;
+}
+
+SINT32 dmp_mode_set_req(UINT8 mode)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ ZblSysMode* reqPtr = NULLPTR;
+ SINT32 snd_ret = -1;
+
+ SC_Trace(ZBL_MM, 1, "dmp_net_se_switch_mode mode = %d msgId == %0x", mode, ZBL_MM_NET_MODE_SET);
+
+ msg_ptr = zblMallocChannelMsg(sizeof(ZblSysMode));
+ if(NULLPTR == msg_ptr)
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ msg_ptr->msgId = ZBL_MM_NET_MODE_SET;
+ msg_ptr->msgFrom = WORK_MODE_AP;
+ msg_ptr->msgSize = sizeof(ZblSysMode);
+
+
+ reqPtr = (ZblSysMode*)msg_ptr->msgData;
+ reqPtr->mode = mode;
+
+ SC_Trace(ZBL_MM, 1, "dmp_net_se_switch_mode tp_os_queue_send");
+
+ /* send message to zblRcvMmiQueue */
+ snd_ret = tp_os_queue_send(zblRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER);
+
+ if((SINT32)OS_FAILURE == snd_ret)
+ {
+ zblFreeChannelMsg(&msg_ptr);
+ assert(0);
+ }
+
+ return 0;
+}
+
+
/* end of file */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/src/zbl_mm_fnc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/src/zbl_mm_fnc.c
index 2158ad2..547d29f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/src/zbl_mm_fnc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_mm/src/zbl_mm_fnc.c
@@ -61,6 +61,10 @@
{ZBL_MM_NET_INIT, zblHandleNetInitReq},
{ZBL_MM_NET_REGISTER, zblHandleNetRegisterReq},
{ZBL_MM_NET_DEREGISTER, zblHandleNetDeregisterReq},
+ {ZBL_MM_NET_CUR_OPER_GET, zblHandleNetCopsReadReq},
+ {ZBL_MM_NET_OPER_SET, zblHandleNetCopsSetReq},
+ {ZBL_MM_NET_SYSINFO_GET, zblHandleNetSysinfoReq},
+ {ZBL_MM_NET_MODE_SET, zblHandleNetModeSetReq},
//{ZBL_MM_NET_DEACTIVE_USIM, zblHandleNetDeactiveUsimReq},
{ZBL_MM_NET_PLMN_REELECT, zblHandleNetPlmnReelectReq},
{ZBL_MM_NET_SELECT_PLMN_WITH_ACC_TECH, zblHandleNetSelectPlmnWithAccTechReq},
@@ -116,7 +120,8 @@
{TAPI_CELL_LOCK_FAIL, zblHandleNetLockCellCmdFail},
{TAPI_CELL_UNLOCK_SUCC, zblHandleNetUnLockCellCmdSucc},
{TAPI_CELL_UNLOCK_FAIL, zblHandleNetUnLockCellCmdFail},
- {TAPI_CELL_DATA_IND, zblHandleNetCellReadDataInd},
+ //{TAPI_CELL_DATA_IND, zblHandleNetCellReadDataInd},
+ {TAPI_CELL_DATA_IND, zblHandleNetCellGetDataInd},
/* CELLÏà¹Øend */
{TAPI_NET_SIGNAL_POWER, zblHandleNetSignalPower}, /* TÍøÉèÖõÄÐźÅÉϱ¨ */
/* Çл»Ïà¹Øbegin */
@@ -1261,6 +1266,113 @@
return 0;
}
+/**************************************************************************
+* º¯ÊýÃû³Æ£º
+* ¹¦ÄÜÃèÊö£º
+* ²ÎÊý˵Ã÷£º (IN)
+ (OUT)
+* ·µ »Ø Öµ£º
+* ÆäËü˵Ã÷£º ¿ÉÑ¡
+**************************************************************************/
+static SINT32 zblHandleNetCopsReadReq(ZBL_CHANNEL_MSG_INFO *pMsg )
+{
+ if(NULLPTR == pMsg)
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ if(-1 == tapi_net_get_cops_info())
+ {
+ zblAssert(0);
+ return -1;
+ }
+ return 0;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º
+* ¹¦ÄÜÃèÊö£º
+* ²ÎÊý˵Ã÷£º (IN)
+ (OUT)
+* ·µ »Ø Öµ£º
+* ÆäËü˵Ã÷£º ¿ÉÑ¡
+**************************************************************************/
+static SINT32 zblHandleNetCopsSetReq(ZBL_CHANNEL_MSG_INFO *pMsg )
+{
+ zblMmCopsSetReq* in = NULLPTR;
+ TapiNetCopsSetReq tpReq = {0};
+ if(NULLPTR == pMsg)
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ in = (zblMmCopsSetReq*)pMsg->msgData;
+ tpReq.mode = in->mode;
+ tpReq.format = in->format;
+ tpReq.act = in->act;
+ memcpy(tpReq.oper, in->oper, ZBL_LONG_OPER_MAX_LEN-1);
+
+ tpReq.cmd_type = CMD_TYPE_SET;
+ if(-1 == tapi_net_set_cops_info(&tpReq))
+ {
+ zblAssert(0);
+ return -1;
+ }
+ return 0;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º
+* ¹¦ÄÜÃèÊö£º
+* ²ÎÊý˵Ã÷£º (IN)
+ (OUT)
+* ·µ »Ø Öµ£º
+* ÆäËü˵Ã÷£º ¿ÉÑ¡
+**************************************************************************/
+static SINT32 zblHandleNetSysinfoReq(ZBL_CHANNEL_MSG_INFO *pMsg )
+{
+ if(NULLPTR == pMsg)
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ if(-1 == tapi_net_get_sysinfo())
+ {
+ zblAssert(0);
+ return -1;
+ }
+ return 0;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º
+* ¹¦ÄÜÃèÊö£º
+* ²ÎÊý˵Ã÷£º (IN)
+ (OUT)
+* ·µ »Ø Öµ£º
+* ÆäËü˵Ã÷£º ¿ÉÑ¡
+**************************************************************************/
+static SINT32 zblHandleNetModeSetReq(ZBL_CHANNEL_MSG_INFO *pMsg )
+{
+ if(NULLPTR == pMsg)
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ ZblSysMode* set = (ZblSysMode*)pMsg->msgData;
+ if(-1 == tapi_net_set_mode(set->mode))
+ {
+ printf("tapi_net_set_mode failed\n");
+ zblAssert(0);
+ return -1;
+ }
+ return 0;
+}
+
/**************************************************************************
* º¯ÊýÃû³Æ£º
@@ -2626,6 +2738,29 @@
return 0;
}
+static SINT32 zblHandleNetCellGetDataInd(ZBL_CHANNEL_MSG_INFO *pMsg)
+{
+
+ if(NULLPTR == pMsg)
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ if(NULLPTR == pMsg->msgData)
+ {
+ zblAssert(0);
+ return -1;
+ }
+
+ zblNetSendMessageToMMI(ZBL_CELL_DATA_IND, (char*)pMsg->msgData, pMsg->msgSize);
+
+ SC_Trace(ZTE_BL, PRN_NOMAL, "DT zblHandleNetCellGetDataInd");
+
+ return 0;
+}
+
+
SINT32 zblHandleModfiyPinReq(ZBL_CHANNEL_MSG_INFO *pMsg )
{
ZblModifyPinReq *req_ptr = NULLPTR;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/inc/zbl_sms_codec.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/inc/zbl_sms_codec.h
index fcfb698..f2e3af2 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/inc/zbl_sms_codec.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/inc/zbl_sms_codec.h
@@ -29,6 +29,7 @@
SINT32 EncodeOkbTimetoPDUFormat(ZblSmsTimeStamp *pSrc, CHAR *pDst);
SINT32 EncodeCurrentTimeToTimeStamp(ZblSmsTimeStamp *sts);
SINT32 EncodePdu_Submit(CONST SM_PARAM* pSrc, CHAR* pDst, UINT8* tp_udl);
+SINT32 EncodePdu_Submit_Binary(CONST SM_PARAM* pSrc, UINT8 tpud_len,CHAR* pDst, UINT8* tp_udl);
SINT32 EncodePdu_Delivery(CONST SM_PARAM* pSrc, CHAR* pDst, UINT8 *tp_udl);
SINT32 DecodePdu_Delivery(CONST CHAR* pSrc, SM_PARAM* pDst);
SINT32 DecodePdu_Submit(CONST CHAR* pSrc, SM_PARAM* pDst);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/inc/zbl_sms_fnc.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/inc/zbl_sms_fnc.h
index 7405392..22118f8 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/inc/zbl_sms_fnc.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/inc/zbl_sms_fnc.h
@@ -806,6 +806,7 @@
* Ìṩ¸øBL_SMS ¶ÔÍâ½Ó¿Úº¯ÊýʹÓà *
**************************************************************************/
SINT32 zblSmsPretreatSendInfo(CONST ZblSmsData *data, UINT8 saveFlag, SMS_MUTINUM *pMutiNum, WORKMODE workMode);
+SINT32 zblSmsPretreatSendInfoBinary(CONST ZblSmsData *data, UINT8 saveFlag, SMS_MUTINUM *pMutiNum, WORKMODE workMode);
SINT32 zblSmsGetParam( ZblSmsParam * param, WORKMODE workMode,UINT8 netMode);
SINT32 zblSmsGetCount(ZBL_SMS_STATUS_COUNT * count, UINT32 status, UINT8 userId, UINT8 stoArea);
SINT32 zblMsgGetCount( ZBL_SMS_STATUS_COUNT * count, UINT32 status, UINT8 userId,UINT8 stoArea, E_ZBL_MSG_TYPE tMsgType);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms.c
index 085ce46..32f9db8 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms.c
@@ -351,12 +351,23 @@
{
return -1;
}
-
- if (0 != zblSmsPretreatSendInfo(data,saveFlag, pMutiNum, workMode))
+ if(pMutiNum->format == GSM_8BIT)
{
- SC_Trace(ZBL_SMS, 0, "pretreat sm send infomation failed! in dmp_sms_send()\r\n");
- return -1;
- }
+ if (0 != zblSmsPretreatSendInfoBinary(data,saveFlag, pMutiNum, workMode))
+ {
+ SC_Trace(ZBL_SMS, 0, "pretreat sm send infomation failed! in dmp_sms_send()\r\n");
+ return -1;
+ }
+ }
+ else
+ {
+ if (0 != zblSmsPretreatSendInfo(data,saveFlag, pMutiNum, workMode))
+ {
+ SC_Trace(ZBL_SMS, 0, "pretreat sm send infomation failed! in dmp_sms_send()\r\n");
+ return -1;
+ }
+ }
+
return 0;
}
@@ -2908,3 +2919,97 @@
return 0; /* ´íÎóÖµ */
}
+SINT32 dmp_sms_get_center_number(WORKMODE eWorkMode)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ SINT32 snd_ret = -1;
+ SC_Trace(ZBL_MM, 0, "dmp_sms_get_center_number");
+
+ msg_ptr = zblMallocChannelMsg(0);
+ if(NULLPTR == msg_ptr)
+ {
+ zblAssert(0);
+ return -1;
+ }
+ msg_ptr->msgId = ZBL_TPM_SMS_GET_CENTER_NUMBER_REQ;
+ msg_ptr->msgFrom = eWorkMode;
+ msg_ptr->msgSize = 0;
+
+ /* send message to zblRcvMmiQueue */
+ snd_ret = tp_os_queue_send(zblSmsRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER);
+ if((SINT32)OS_FAILURE == snd_ret)
+ {
+ zblFreeChannelMsg(&msg_ptr);
+ assert(0);
+ return -1;
+ }
+
+ return 0;
+}
+
+SINT32 dmp_sms_set_center_number(UINT8* smsAddr, WORKMODE eWorkMode)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ ZblScParamInfo* pScParamInfo = NULLPTR;
+ SINT32 snd_ret = -1;
+ SC_Trace(ZBL_MM, 0, "dmp_sms_set_center_number");
+
+ msg_ptr = zblMallocChannelMsg(sizeof(ZblScParamInfo));
+ if(NULLPTR == msg_ptr)
+ {
+ zblAssert(0);
+ return -1;
+ }
+ msg_ptr->msgId = ZBL_TPM_SMS_SET_CENTER_NUMBER_REQ;
+ msg_ptr->msgFrom = eWorkMode;
+ msg_ptr->msgSize = 0;
+ pScParamInfo = (ZblScParamInfo*)msg_ptr->msgData;
+ strncpy(pScParamInfo->smsAddr, smsAddr, sizeof(pScParamInfo->smsAddr)-1);
+ /* send message to zblRcvMmiQueue */
+ snd_ret = tp_os_queue_send(zblSmsRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER);
+ if((SINT32)OS_FAILURE == snd_ret)
+ {
+ zblFreeChannelMsg(&msg_ptr);
+ assert(0);
+ return -1;
+ }
+
+ return 0;
+}
+
+SINT32 dmp_sms_send_pdu_msg(CONST ZblSmsPduData *data, WORKMODE eWorkMode)
+{
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+ ZblSmsPduData* psms_data = NULLPTR;
+ SINT32 snd_ret = -1;
+
+ if (NULLPTR == data)
+ {
+ return -1;
+ }
+
+ msg_ptr = zblMallocChannelMsg(sizeof(ZblSmsPduData));
+ if(NULLPTR == msg_ptr)
+ {
+ zblAssert(0);
+ return -1;
+ }
+ msg_ptr->msgId = ZBL_TPM_SMS_SEND_PDU_REQ;
+ msg_ptr->msgFrom = eWorkMode;
+ msg_ptr->msgSize = 0;
+ psms_data = (ZblSmsPduData*)msg_ptr->msgData;
+ memcpy(psms_data->pdu_data, data->pdu_data, sizeof(ZblSmsPduData));
+ psms_data->pdu_len = data->pdu_len;
+ psms_data->id = data->id;
+ /* send message to zblRcvMmiQueue */
+ snd_ret = tp_os_queue_send(zblSmsRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER);
+ if((SINT32)OS_FAILURE == snd_ret)
+ {
+ zblFreeChannelMsg(&msg_ptr);
+ assert(0);
+ return -1;
+ }
+
+ return 0;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms_codec.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms_codec.c
index 3d5e89e..a9e1be9 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms_codec.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms_codec.c
@@ -1947,7 +1947,7 @@
buf[0] = pSrc->TP_PID; // ÐÒé±êʶ(TP-PID)
buf[1] = pSrc->TP_DCS; // Óû§ÐÅÏ¢±àÂ뷽ʽ(TP-DCS)
buf[2] = pSrc->TP_VP; // ÓÐЧÆÚ(TP-VP)
-
+ SC_Trace(ZBL_SMS, 0, "nLength=%d, pSrc->TP_DCS = %d\r\n", nLength, pSrc->TP_DCS);
if(pSrc->TP_DCS == GSM_7BIT)
{
// 7-bit±àÂ뷽ʽ
@@ -2029,6 +2029,129 @@
return nDstLength; // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
}
+SINT32 EncodePdu_Submit_Binary(CONST SM_PARAM* pSrc, UINT8 tpud_len,CHAR* pDst, UINT8* tp_udl)
+{
+ SINT32 nLength = 0; // ÄÚ²¿ÓõĴ®³¤¶È
+ SINT32 nDstLength = 0; // Ä¿±êPDU´®³¤¶È
+ UINT8 buf[256] = {0}; // ÄÚ²¿ÓõĻº³åÇø
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL)
+ {
+ return -1;
+ }
+ SC_Trace(ZBL_SMS, 0, "pSrc->SCA = %s\r\n", pSrc->SCA);
+ // SMSCµØÖ·ÐÅÏ¢¶Î
+ if(pSrc->SCA[0] == '+')
+ {
+ nLength = strlen(pSrc->SCA) - 1; // SMSCµØÖ·×Ö·û´®µÄ³¤¶È
+ if(nLength != 0)
+ {
+ buf[0] = (CHAR)((nLength & 1) == 0 ? nLength : nLength + 1) / 2 + 1; // SMSCµØÖ·ÐÅÏ¢³¤¶È
+ buf[1] = 0x91; // ¹Ì¶¨: Óùú¼Ê¸ñʽºÅÂë
+ nDstLength = Bytes2String(buf, pDst, 2); // ת»»2¸ö×Ö½Úµ½Ä¿±êPDU´®
+ nDstLength += InvertNumbers(&(pSrc->SCA[1]), &pDst[nDstLength], nLength); // ת»»SMSCºÅÂ뵽Ŀ±êPDU´®
+ }
+ else
+ {
+ buf[0]=0;
+ nDstLength = Bytes2String(buf, pDst, 1);// ת»»1¸ö×Ö½Úµ½Ä¿±êPDU´®
+ }
+ }
+ else
+ {
+ nLength = strlen(pSrc->SCA); // SMSCµØÖ·×Ö·û´®µÄ³¤¶È
+ if(nLength != 0)
+ {
+ buf[0] = (CHAR)((nLength & 1) == 0 ? nLength : nLength + 1) / 2 + 1; // SMSCµØÖ·ÐÅÏ¢³¤¶È
+ buf[1] = 0x81; // ¹Ì¶¨: Óùú¼Ê¸ñʽºÅÂë
+ nDstLength = Bytes2String(buf, pDst, 2); // ת»»2¸ö×Ö½Úµ½Ä¿±êPDU´®
+ nDstLength += InvertNumbers(pSrc->SCA, &pDst[nDstLength], nLength); // ת»»SMSCºÅÂ뵽Ŀ±êPDU´®
+ }
+ else
+ {
+ buf[0]=0;
+ nDstLength = Bytes2String(buf, pDst, 1);
+ }
+ }
+ // TPDU¶Î»ù±¾²ÎÊý¡¢Ä¿±êµØÖ·µÈ
+ SC_Trace(ZBL_SMS, 0, "pSrc->TPA = %s\r\n", pSrc->TPA);
+ if(pSrc->TPA[0] == '+')
+ {
+ nLength = strlen(&(pSrc->TPA[1])); // TP-DAµØÖ·×Ö·û´®µÄ³¤¶È
+ }
+ else
+ {
+ nLength = strlen(pSrc->TPA); // TP-DAµØÖ·×Ö·û´®µÄ³¤¶È
+ }
+
+ buf[0] = 0x11; // ÊÇ·¢ËͶÌÐÅ(TP-MTI=01)£¬TP-VPÓÃÏà¶Ô¸ñʽ(TP-VPF=10)
+
+ if(pSrc->TP_SRR == 0) //²»ÒªÇó·¢ËÍ״̬±¨¸æ
+ {
+ if(pSrc->smConcat.totalNum == 1)
+ buf[0] = 0x11;
+ else
+ buf[0] = 0x51;
+ }
+
+ if(pSrc->TP_SRR == 1) //ÒªÇó·¢ËÍ״̬±¨¸æ
+ {
+ if(pSrc->smConcat.totalNum == 1)
+ buf[0] = 0x31;
+ else
+ buf[0] = 0x71;
+ }
+ buf[1] = 0; // TP-MR=0
+ buf[2] = (CHAR)nLength; // Ä¿±êµØÖ·Êý×Ö¸öÊý(TP-DAµØÖ·×Ö·û´®ÕæÊµ³¤¶È)
+
+ if(pSrc->TPA[0] == '+')
+ {
+ buf[3] = 0x91; // ¹Ì¶¨: ¹ú¼ÊºÅÂë¸ñʽ
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], 4); // ת»»4¸ö×Ö½Úµ½Ä¿±êPDU´®
+ nDstLength += InvertNumbers(&(pSrc->TPA[1]), &pDst[nDstLength], nLength); // ת»»TP-DAµ½Ä¿±êPDU´®
+ }
+ else
+ {
+ buf[3] = 0x81; // ¹Ì¶¨: ²»Ö¸Ã÷ºÅÂë¸ñʽ
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], 4); // ת»»4¸ö×Ö½Úµ½Ä¿±êPDU´®
+ nDstLength += InvertNumbers(pSrc->TPA, &pDst[nDstLength], nLength); // ת»»TP-DAµ½Ä¿±êPDU´®
+ }
+
+ // TPDU¶ÎÐÒé±êʶ¡¢±àÂ뷽ʽ¡¢Óû§ÐÅÏ¢µÈ
+ nLength = tpud_len; // Óû§ÐÅÏ¢×Ö·û´®µÄ³¤¶È
+ buf[0] = pSrc->TP_PID; // ÐÒé±êʶ(TP-PID)
+ buf[1] = pSrc->TP_DCS; // Óû§ÐÅÏ¢±àÂ뷽ʽ(TP-DCS)
+ buf[2] = pSrc->TP_VP; // ÓÐЧÆÚ(TP-VP)
+ SC_Trace(ZBL_SMS, 0, "nLength=%d, pSrc->TP_DCS = %d\r\n", nLength, pSrc->TP_DCS);
+
+ // 8-bit±àÂ뷽ʽ
+ if(pSrc->smConcat.totalNum <= 1)//single sms
+ {
+ buf[3] = Encode8bit(pSrc->TP_UD, &buf[4], nLength); // ת»»TP-DAµ½Ä¿±êPDU´®
+ nLength = buf[3] + 4; // nLengthµÈÓڸöÎÊý¾Ý³¤¶È
+ }
+ else
+ {
+ buf[3] = Encode8bit(pSrc->TP_UD, &buf[10], nLength) + 6; // ת»»TP-DAµ½Ä¿±êPDU´®
+ buf[4] = 0x05;//UDHL
+ buf[5] = 0x00;//IEI
+ buf[6] = 0x03;//IEIDL
+ buf[7] = (UINT8)pSrc->smConcat.refNum;//IEID-ref-num
+ buf[8] = pSrc->smConcat.totalNum;//IEID-total-num
+ buf[9] = pSrc->smConcat.index;//IEID-seq-num
+ nLength = buf[3] + 4;
+ }
+
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], nLength); // ת»»¸Ã¶ÎÊý¾Ýµ½Ä¿±êPDU´®
+ if(tp_udl != NULLPTR)
+ {
+ *tp_udl = buf[3];
+ }
+
+ return nDstLength; // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+}
+
/**************************************************************************
* º¯ÊýÃû³Æ£º int DecodePdu_Submit(const char* pSrc, SM_PARAM* pDst)
* ¹¦ÄÜÃèÊö£º PDU½âÂ룬ÓÃÓÚ½ÓÊÕ¡¢ÔĶÁ¶ÌÏûÏ¢
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms_fnc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms_fnc.c
index 819968e..96f8402 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms_fnc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtelsvr/source/tel_svr/zbl_sms/src/zbl_sms_fnc.c
@@ -27,7 +27,9 @@
SINT32 tp_gbk_to_sc_str(UINT8 *gbk_ptr, UINT8 *sc_str_ptr, UINT32 sc_str_max_len);
SINT32 tp_sc_str_to_gbk(UINT8 *sc_str_ptr, UINT8 *gbk_ptr, UINT32 gbk_max_len);
SINT32 tp_sc_utf8_to_gbk( CONST CHAR *utf8_ptr, CHAR *gbk_ptr1, UINT32 gbk_max_len);
-
+static SINT32 zblSmsGetSmsCenterNumber(ZBL_CHANNEL_MSG_INFO * zblMsgInfoPtr);
+static SINT32 zblSmsSetSmsCenterNumber(ZBL_CHANNEL_MSG_INFO * zblMsgInfoPtr);
+static SINT32 zblSmsSendPdu(ZBL_CHANNEL_MSG_INFO * zblMsgInfoPtr);
/**********************************************************************************************
* È«¾Ö±äÁ¿ *
@@ -6161,6 +6163,169 @@
return 0;
}
+SINT32 zblSmsPretreatSendInfoBinary(CONST ZblSmsData *data, UINT8 saveFlag, SMS_MUTINUM *pMutiNum, WORKMODE workMode)
+{
+ TapiSmsSePduData seSmsData = {0x00};
+ UINT8 gbkData[ZBL_SMS_MAX_USER_DATA_LEN+1] = {0x00};
+ UINT8 scStr[ZBL_SMS_MAX_USER_DATA_LEN+1] = {0x00};
+
+ UINT8 gsm7bitStr[ZBL_SMS_MAX_USER_DATA_LEN] = {0x00};
+ UINT8 gsm7PreData[ZBL_SMS_INTERNAL_MAX_PREVIEW_LENGTH+4] = {0x00};
+ SINT32 gsm7bitLen = 0;
+
+ UINT32 i = 0;
+ UINT8 preData[ZBL_SMS_INTERNAL_MAX_PREVIEW_LENGTH+4] = {0x00};
+ SINT32 scLen = 0;
+ SM_PARAM smPara = {0x00};
+ T_AbSmRecord abSmRecord;
+ T_SmRecord smRecord = {0x00};
+
+
+ ZBL_SMS_SEND_INFO zblSmsSendInfo = {0};
+ /*for message*/
+ UINT32 msgDataSize = 0;
+ ZBL_CHANNEL_MSG_INFO *msg_ptr = NULLPTR;
+
+ UINT32 iMaxPreLen = 0;
+
+ if (NULLPTR == data || NULLPTR == pMutiNum)
+ {
+ return -1;
+ }
+ SC_Trace(ZBL_SMS, 0, "Enter the zblSmsPretreatSendInfoBinary Func! saveFlag=%d,workMode=%d\r\n",saveFlag,workMode);
+
+ memcpy((VOID*)gbkData, (VOID*)(data->text_data.text), ZBL_SMS_MAX_USER_DATA_LEN);
+ SC_Trace(ZBL_SMS, 0, "gbkData=%s\r\n",gbkData);
+ //strncpy((char*)scStr,(char*)gbkData,ZBL_SMS_MAX_USER_DATA_LEN);
+ //scLen = GetScStrLen(scStr);
+ scLen = String2Bytes(gbkData, scStr, strlen(gbkData));
+
+ SC_Trace(ZBL_SMS, 0, "scLen=%d\r\n",scLen);
+
+ memset((VOID *)&abSmRecord, 0x00, sizeof(T_AbSmRecord));
+ memset((VOID *)&smRecord, 0x00, sizeof(T_SmRecord));
+ memset((VOID*)&smPara, 0x00, sizeof(SM_PARAM));
+ abSmRecord.tMsgType = MSG_TYPE_SMS;
+ abSmRecord.smDataValid = TRUE;
+
+ zblSmsFillSmParaFromContext(&smPara, (CHAR*)data->text_data.number, 0x00, scLen,workMode);
+ smPara.TP_DCS = GSM_8BIT;
+ if (1 < smPara.smConcat.totalNum)
+ {
+ concatRefNum++;
+ smPara.smConcat.refNum = concatRefNum;
+ }
+ SC_Trace(ZBL_SMS, 0, "smPara.smConcat.refNum is %d\r\n", smPara.smConcat.refNum);
+ SC_Trace(ZBL_SMS, 0, "smPara.smConcat.totalNum is %d\r\n", smPara.smConcat.totalNum);
+
+ memset((VOID*)preData, 0x00, sizeof(preData));
+
+ ////abSmRecord.previewLen = iMaxPreLen; //ÐÞ¸ÄÔ¤ÀÀ³¤¶È
+ for (i = 0; i < smPara.smConcat.totalNum; i++)
+ {
+ smPara.smConcat.index = i+1;
+ memset((VOID*)smPara.TP_UD, 0x00, SMS_MAX_TPDU_SEPTETS+1);
+
+ /* Ìí¼Ó³¤¶ÌÐŵĶÌÏûϢ״̬±¨¸æÉèÖã¬Ê¹×îºóÒ»Ìõ²ÅÀ´±¨¸æÐÅÏ¢ */
+ /*+2010 -06-16 add status report status indicate for CQ CQNJ00192673 if the concat message open status report
+ only the end message to be set TP_SRR*/
+ if(smPara.smConcat.index == smPara.smConcat.totalNum)
+ {
+ smPara.TP_SRR = msgContext.smsApParam.ack? 1:0;
+ }
+ else
+ {
+ smPara.TP_SRR = 0;
+ }
+
+ if (smPara.smConcat.index == smPara.smConcat.totalNum)
+ {
+ memcpy((VOID*)smPara.TP_UD, (VOID*)&scStr[i*SMS_MAX_CONCAT_TPDU_SEPTETS], scLen-(i*SMS_MAX_CONCAT_TPDU_SEPTETS));
+
+ smPara.TP_UDL = scLen-i*SMS_MAX_CONCAT_TPDU_SEPTETS;
+ if (smPara.TP_UDL > iMaxPreLen)
+ {
+ abSmRecord.previewLen = iMaxPreLen;
+ }
+ else
+ {
+ abSmRecord.previewLen =smPara.TP_UDL;
+ }
+ }
+ else
+ {
+ memcpy((VOID*)smPara.TP_UD, (VOID*)&scStr[i*SMS_MAX_CONCAT_TPDU_SEPTETS], SMS_MAX_CONCAT_TPDU_SEPTETS);
+
+ smPara.TP_UDL = SMS_MAX_CONCAT_TPDU_SEPTETS;
+
+ }
+
+ EncodeCurrentTimetoPDUFormat(smPara.TP_SCTS);
+ memset((VOID*)&seSmsData, 0x00, sizeof(TapiSmsSePduData));
+
+ EncodePdu_Submit_Binary(&smPara, scLen, smRecord.smsTpdu, &(seSmsData.iTpduLength));
+ SC_Trace(ZBL_SMS, 0, "smRecord.smsTpdu = %s\r\n", smRecord.smsTpdu);
+ seSmsData.iTotalLength = String2Bytes(smRecord.smsTpdu, seSmsData.strPdu, strlen(smRecord.smsTpdu));
+ seSmsData.iTpduLength = seSmsData.iTotalLength - (seSmsData.strPdu[0] + 1);
+ SC_Trace(ZBL_SMS, 0, "total_length of is: %ld, tpdu_length is: %ld\r\n", seSmsData.iTotalLength, seSmsData.iTpduLength);
+ //SC_Trace(ZBL_SMS, 0, "the SUBMITE pdu string which will be send is: %s\r\n", smRecord.smsTpdu);
+
+ abSmRecord.mem_area = ZBL_SMS_STORAGE_AREA_FLASH;
+
+ memcpy((VOID*)&(abSmRecord.smConcat), (VOID*)&(smPara.smConcat), sizeof(T_SmConcat));
+ abSmRecord.smDataValid = TRUE;
+ strncpy((CHAR*)abSmRecord.smeAddr, smPara.TPA, sizeof(smPara.TPA));
+ //DecodePDUFormatToTimeStamp(&(abSmRecord.smsTime), smPara.TP_SCTS);
+ EncodeCurrentTimeToTimeStamp(&(abSmRecord.smsTime));
+
+ //SMS·¢ËÍºó¸ø·¢Ë͵ÄÄÚ´æÊý¾ÝÌí¼ÓID
+ abSmRecord.okbID = zblSmsGetOkbID();
+
+ SC_Trace(ZBL_SMS, 0, "zblSmsPretreatSendInfo abSmRecord.okbID ==%d\n", abSmRecord.okbID);
+
+ memcpy((VOID*)&(smRecord.smConcat), (VOID*)&(smPara.smConcat), sizeof(T_SmConcat));
+ smRecord.smDataValid = TRUE;
+ strncpy((CHAR*)smRecord.smeAddr, smPara.TPA, sizeof(smPara.TPA));
+
+#if 1 //huangleiɾ³ý´Ëºê//#ifdef APP_SMS_SEND_BACK#ifdef APP_SMS_SEND_BACK
+ smRecord.index = data->text_data.uiIndex; /* ´«µÝ¸ø·¢Ëͺ¯Êý */
+#endif
+ /*here we fill the ZBL_SMS_SEND_INFO struct,which provide the necessary infomation for the send funtion.*/
+ memset((VOID*)&zblSmsSendInfo, 0x00, sizeof(ZBL_SMS_SEND_INFO));
+ zblSmsSendInfo.saveFlag = saveFlag;
+ memcpy((VOID*)&zblSmsSendInfo.abSmRecord, (VOID*)&abSmRecord, sizeof(T_AbSmRecord));
+ memcpy((VOID*)&zblSmsSendInfo.smRecord, (VOID*)&smRecord, sizeof(T_SmRecord));
+ memcpy((VOID*)&zblSmsSendInfo.mutiNum, (VOID*)pMutiNum, sizeof(SMS_MUTINUM));
+
+ /*now all the pretreatment have been finished,we send the message to tell the sms engine thread or CI to do the
+ *rest job according the work mode.*/
+ msgDataSize = sizeof(ZBL_SMS_SEND_INFO);
+ msg_ptr = zblMallocChannelMsg(msgDataSize);
+ if (msg_ptr == NULLPTR)
+ {
+ SC_Trace(ZBL_SMS, 0, "tp_os_mem_malloc(sizeof(ZBL_SMS_SEND_INFO) failed!\r\n");
+ return -1;
+ }
+
+ msg_ptr->msgId = ZBL_INTERNAL_SMS_SEND;
+ msg_ptr->msgFrom = workMode;
+ msg_ptr->msgSize = msgDataSize;
+ memcpy(msg_ptr->msgData,(VOID*)&zblSmsSendInfo,msgDataSize);
+ /*send the message to msg queue,if fail free the memory*/
+ if (OS_SUCCESS != tp_os_queue_send(zblSmsRcvMmiQueueId, (VOID*)msg_ptr, OS_WAIT_FOREVER))
+ {
+ assert(0);
+ zblFreeChannelMsg(&msg_ptr);
+ SC_Trace(ZBL_SMS, 0, "Msg sent to msgEngineQue failed!in zblSmsPretreatSendInfo()\r\n");
+ return -1;
+ }
+
+ SC_Trace(ZBL_SMS, 0, "Msg sent to msgEngineQue success!in zblSmsPretreatSendInfo()\r\n");
+ }
+
+ return 0;
+}
+
/******************************************************************************************************
*Function Name£º zblSmsGetPreViewInfo
*Function Description£º get the preview data infomation.
@@ -9930,7 +10095,7 @@
if(zblSmsSendInfo.smRecord.smConcat.totalNum == zblSmsSendInfo.smRecord.smConcat.index)
{
zblSmsSendResult.workMode = workMode;
- zblSmsSendResult.sendResult = (sendresult == 0)? 0 : 1;
+ zblSmsSendResult.sendResult = sendresult; //(sendresult == 0)? 0 : 1;
/* sbt add start FIX CQNJ00084703,CQNJ00084647 sucess save and failure save message send to MMI 2009.05.12 */
if(zblSmsSendInfo.mutiNum.count == zblSmsSendInfo.mutiNum.index) // Ⱥ·¢×îºóÒ»Ìõ
@@ -9948,6 +10113,7 @@
}
zblSmsSendResult.modle = ZBL_SMS_NORMAL_MODULE;
+ zblSmsSendResult.id = zblSmsSendInfo.mutiNum.id;
tp_comm_channel_post_msg(sms_channel, ZBL_TPM_SMS_SEND_RESULT, &zblSmsSendResult, sizeof(ZBL_SMS_SEND_RESULT));
}
SC_Trace(ZBL_SMS, 0, "ZBL TRACE: FINAL_SEND SEND ZBL_TPM_SMS_SEND_RESULT(%x) To MMI\r\n",ZBL_TPM_SMS_SEND_RESULT);
@@ -9965,6 +10131,7 @@
}
zblSmsSendResult.modle = ZBL_SMS_NORMAL_MODULE;
+ zblSmsSendResult.id = zblSmsSendInfo.mutiNum.id;
tp_comm_channel_post_msg(sms_channel, ZBL_TPM_SMS_SEND_RESULT, &zblSmsSendResult, sizeof(ZBL_SMS_SEND_RESULT));
}
SC_Trace(ZBL_SMS, 0, "ZBL TRACE: INTERMEDIATE_SEND SEND ZBL_TPM_SMS_SEND_RESULT(%x) To MMI\r\n",ZBL_TPM_SMS_SEND_RESULT);
@@ -13800,6 +13967,16 @@
return 0;
}
+static SINT32 zblSmsHandleMdmSeNewTextSmMsg(ZBL_CHANNEL_MSG_INFO * zblMsgInfoPtr)
+{
+ ZblSmsIndTextData smsTextInd = {0};
+ SC_Trace(ZBL_SMS, 0, "zblSmsHandleMdmSeNewTextSmMsg send ZBL_TPM_SMS_NEW_TEXT_MSG\r\n");
+ memcpy(&smsTextInd, zblMsgInfoPtr->msgData,sizeof(ZblSmsIndTextData));
+ tp_itc_message_post(ZBL_TPM_SMS_NEW_TEXT_MSG, &smsTextInd, sizeof(ZblSmsIndTextData));
+
+ return 0;
+}
+
static SINT32 zblSmsHandleMdmSeAckNewMsgResult(ZBL_CHANNEL_MSG_INFO * zblMsgInfoPtr)
{
UINT16 result = 0;
@@ -14238,7 +14415,8 @@
}
case ZBL_INTERNAL_SMS_NEW:/*new arrived sm*/
{
- if(g_engineIsInvalid)
+ SC_Trace(ZBL_SMS, 0, "g_engineIsInvalid =%d !\r\n", g_engineIsInvalid);
+ if(g_engineIsInvalid)
{
TapiSmsSePduData deliverReport = {0};
@@ -14345,6 +14523,27 @@
}
break;
+ case ZBL_TPM_SMS_GET_CENTER_NUMBER_REQ:
+ {
+ SC_Trace(ZBL_SMS, 0, "%s: ZBL_INTERNAL_SMS_GET_CENTER_NUMBER !\r\n", __func__);
+ zblSmsGetSmsCenterNumber(zblMsgInfoPtr);
+ }
+ break;
+
+ case ZBL_TPM_SMS_SET_CENTER_NUMBER_REQ:
+ {
+ SC_Trace(ZBL_SMS, 0, "%s: ZBL_INTERNAL_SMS_SET_CENTER_NUMBER !\r\n", __func__);
+ zblSmsSetSmsCenterNumber(zblMsgInfoPtr);
+ }
+ break;
+
+ case ZBL_TPM_SMS_SEND_PDU_REQ:
+ {
+ SC_Trace(ZBL_SMS, 0, "%s: ZBL_INTERNAL_SMS_SET_CENTER_NUMBER !\r\n", __func__);
+ zblSmsSendPdu(zblMsgInfoPtr);
+ }
+ break;
+
default :
{
SC_Trace(ZBL_SMS, 0, "%s: unknown msgid!\r\n", __func__);
@@ -14436,6 +14635,15 @@
}
break;
}
+ case TAPI_SMS_SE_NEW_TEXT_SMS:
+ {
+ if(0 != zblSmsHandleMdmSeNewTextSmMsg(zblMsgInfoPtr))
+ {
+
+ return -1;
+ }
+ break;
+ }
case TAPI_SMS_SE_NEW_SMS_INFO:
{
if(0 != zblSmsHandleMdmSeNewSmInfoMsg(zblMsgInfoPtr))
@@ -16424,6 +16632,8 @@
return -1;
}
memcpy((VOID*)&newSmPdu, zblMsgInfoPtr->msgData, zblMsgInfoPtr->msgSize);
+ SC_Trace(ZBL_SMS, 0, "zblSmsDealNewArrivedSm send ZBL_TPM_SMS_NEW_PDU_MSG\r\n");
+ tp_itc_message_post(ZBL_TPM_SMS_NEW_PDU_MSG, &newSmPdu, sizeof(TapiSmsSePduData));
workMode = zblMsgInfoPtr->msgFrom;
if (WORK_MODE_AP == workMode)
{
@@ -22804,5 +23014,70 @@
return ret;
}
+static SINT32 zblSmsGetSmsCenterNumber(ZBL_CHANNEL_MSG_INFO * zblMsgInfoPtr)
+{
+ ZblScParamInfo sc_req_result = {0};
+ SINT32 iRet = -1;
+ iRet = tapi_sms_se_get_sc((CHAR *)(sc_req_result.smsAddr));
+ sc_req_result.result = iRet;
+ sc_req_result.reason = iRet;
+ sc_req_result.workMode = zblMsgInfoPtr->msgFrom;
+ SC_Trace(ZBL_SMS, 0, "zblSmsGetSmsCenterNumber smsAddr=%s, reason=%d\r\n", sc_req_result.smsAddr,sc_req_result.reason);
+ tp_comm_channel_post_msg(NULL, ZBL_TPM_SMS_GET_CENTER_NUMBER_RSP, &sc_req_result, sizeof(ZblScParamInfo));
+}
+
+static SINT32 zblSmsSetSmsCenterNumber(ZBL_CHANNEL_MSG_INFO * zblMsgInfoPtr)
+{
+ ZblScParamInfo* pScParamInfo = NULLPTR;
+ ZblScParamInfo sc_req_result = {0};
+ SINT32 iRet = -1;
+ pScParamInfo = (ZblScParamInfo*)zblMsgInfoPtr->msgData;
+ iRet = tapi_sms_se_set_sc((CHAR *)(pScParamInfo->smsAddr));
+ sc_req_result.result = iRet;
+ sc_req_result.reason = iRet;
+ sc_req_result.workMode = zblMsgInfoPtr->msgFrom;
+ tp_comm_channel_post_msg(NULL, ZBL_TPM_SMS_SET_CENTER_NUMBER_RSP, &sc_req_result, sizeof(ZblScParamInfo));
+}
+
+
+static SINT32 zblSmsSendPdu(ZBL_CHANNEL_MSG_INFO * zblMsgInfoPtr)
+{
+ ZblSmsPduData *psms_data = NULLPTR;
+ UINT8 tp_mr = 0;
+ UINT8 tpduLen = 0x00;
+ TapiSmsSePduData zblSmsSePduData = {0x00};
+ SINT32 sendresult = -1;
+ ZBL_SMS_SEND_RESULT zblSmsSendResultInfo = {0};
+
+ SC_Trace(ZBL_SMS, 0, "zblSmsSendPdu is called!\r\n");
+
+ psms_data = (ZblSmsPduData *)zblMsgInfoPtr->msgData;
+
+ memset((VOID*)&zblSmsSePduData, 0x00, sizeof(TapiSmsSePduData));
+
+ zblSmsSePduData.iTotalLength = psms_data->pdu_len;
+ tpduLen = psms_data->pdu_len;
+ printf("psms_data->tpdu_data[0]=%d, iTotalLength=%d\n", psms_data->pdu_data[0], zblSmsSePduData.iTotalLength);
+
+ if(psms_data->pdu_data[0] == 0x0)
+ {
+ zblSmsSePduData.iTpduLength = tpduLen -1;
+ }
+ else
+ {
+ zblSmsSePduData.iTpduLength = tpduLen-(psms_data->pdu_data[0]+1);
+ }
+ memcpy(zblSmsSePduData.strPdu, psms_data->pdu_data, psms_data->pdu_len);
+ printf("zblSmsSePduData.iTpduLength=%d\n", zblSmsSePduData.iTpduLength);
+ sendresult = tapi_sms_se_usat_send(&zblSmsSePduData, &tp_mr);
+
+ zblSmsSendResultInfo.sendResult = sendresult;
+ zblSmsSendResultInfo.workMode = WORK_MODE_AP;
+ zblSmsSendResultInfo.id = psms_data->id;
+ tp_comm_channel_post_msg(0, ZBL_TPM_SMS_SEND_PDU_RSP, &zblSmsSendResultInfo, sizeof(ZBL_SMS_SEND_RESULT));
+
+ return sendresult;
+}
+
#endif/*_ZBL_SMS_FUC_C*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtinyalsa/tinyalsa_voice_ref.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtinyalsa/tinyalsa_voice_ref.c
index 3e4923b..9cdc264 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtinyalsa/tinyalsa_voice_ref.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libtinyalsa/tinyalsa_voice_ref.c
@@ -33,7 +33,7 @@
voice_mixer = mixer_open(0);
if(!voice_mixer)
{
- printf("zte voice_mixer open failed!");
+ printf("voice_mixer open failed!");
goto err_ret;
}
@@ -60,26 +60,26 @@
voicePcmOut = pcm_open(0, 1, PCM_OUT, &config_voice);
if(!voicePcmOut || !pcm_is_ready(voicePcmOut))
{
- printf( "zte voicePcmOut open failed!");
+ printf( "voicePcmOut open failed!");
goto err_ret;
}
voicePcmIn = pcm_open(0, 1, PCM_IN, &config_voice);
if(!voicePcmIn || !pcm_is_ready(voicePcmIn))
{
- printf( "zte voicePcmIn open failed!");
+ printf( "voicePcmIn open failed!");
goto err_ret;
}
if(0 != pcm_prepare(voicePcmOut))
{
- printf("zte voicePcmOut pcm_prepare failed!");
+ printf("voicePcmOut pcm_prepare failed!");
goto err_ret;
}
if(0 != pcm_prepare(voicePcmIn))
{
- printf("zte voicePcmIn pcm_prepare failed!");
+ printf("voicePcmIn pcm_prepare failed!");
goto err_ret;
}
return 0;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/Makefile
index 7a8f156..4b78650 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/Makefile
@@ -47,6 +47,10 @@
LDLIBS += -lpthread
LDLIBS += -ltinyalsa
+LDLIBS += -lnvram -L$(LIB_DIR)/libnvram
+LDLIBS += -lsoftap -L$(LIB_DIR)/libsoftap
+LDLIBS += -lsofttimer -L$(LIB_DIR)/libsofttimer
+
LDFLAGS += -Wl,--no-as-needed
LDFLAGS += -Wl,--no-undefined
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include/voice_ipc.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include/voice_ipc.h
index df56de1..b325fbe 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include/voice_ipc.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include/voice_ipc.h
@@ -1,4 +1,5 @@
#ifdef USE_CAP_SUPPORT
+#include "message.h"
#define VOICEIPC_OK 0
#define VOICEIPC_ERROR -1
@@ -23,47 +24,80 @@
IPC_GET_RX_VOICE_MUTE_STATE = 9,
IPC_SET_LOOPBACK_ENABLE_STATE = 10,
IPC_GET_LOOPBACK_ENABLE_STATE = 11,
+ IPC_AP_ALSA_VOICE_OPEN = 12,
+ IPC_AP_ALSA_VOICE_CLOSE = 13,
+ IPC_CAP_ALSA_VOICE_OPEN = 14,
+ IPC_CAP_ALSA_VOICE_CLOSE = 15,
IPC_VOICE_FUNC_MAX
};
-typedef struct {
+enum voice_msg_cmd{
+ MSG_CMD_SET_VOICE_DEVICE_MODE = MSG_CMD_VOICE_BASE + 0x0, //37070
+ MSG_CMD_GET_VOICE_DEVICE_MODE,
+ MSG_CMD_SET_RX_VOICE_VOL,
+ MSG_CMD_GET_RX_VOICE_VOL,
+ MSG_CMD_SET_TX_VOICE_VOL,
+ MSG_CMD_GET_TX_VOICE_VOL,
+ MSG_CMD_SET_TX_VOICE_MUTE_STATE,
+ MSG_CMD_GET_TX_VOICE_MUTE_STATE,
+ MSG_CMD_SET_RX_VOICE_MUTE_STATE,
+ MSG_CMD_GET_RX_VOICE_MUTE_STATE,
+ MSG_CMD_SET_LOOPBACK_ENABLE_STATE,
+ MSG_CMD_GET_LOOPBACK_ENABLE_STATE,
+ MSG_CMD_AP_ALSA_VOICE_OPEN,
+ MSG_CMD_AP_ALSA_VOICE_CLOSE
+};
+
+typedef struct{
int func_id;
int param_len;
unsigned char param[VOICE_CONTROL_MAX_LEN];
}voice_ipc_control_msg;
+//msg
+int msg_send_and_recv(int src_id, int dst_id, int msg_cmd, int *value);
+int msg_set_voice_device_mode(int dev_mode);
+int msg_get_voice_device_mode(void);
+int msg_set_rx_voice_vol(int vol);
+int msg_get_rx_voice_vol(void);
+int msg_set_tx_voice_vol(int vol);
+int msg_get_tx_voice_vol(void);
+int msg_set_tx_voice_mute_state(int mute);
+int msg_get_tx_voice_mute_state(void);
+int msg_set_rx_voice_mute_state(int mute);
+int msg_get_rx_voice_mute_state(void);
+int msg_set_loopback_enable_state(int enable);
+int msg_get_loopback_enable_state(void);
+int msg_ap_alsa_voice_open(int vmode);
+int msg_ap_alsa_voice_close(int vmode);
+
+//ipc
int voice_ipc_init(void);
int Voice_Ctrl_Rpmsg_Send(int func_id, int *msg);
void Voice_Ctrl_Rpmsg_Recv(void);
+void voice_ipc_recv_proc(voice_ipc_control_msg msg);
-int ipc_set_voice_device_mode(int func_id, int dev_mode);
-int ipc_get_voice_device_mode(int func_id, int *p_dev_mode);
-int ipc_set_rx_voice_vol(int func_id, int vol);
-int ipc_get_rx_voice_vol(int func_id, int *p_vol);
-int ipc_set_tx_voice_vol(int func_id, int vol);
-int ipc_get_tx_voice_vol(int func_id, int *p_vol);
-int ipc_set_tx_voice_mute_state(int func_id, int mute);
-int ipc_get_tx_voice_mute_state(int func_id, int *p_mute);
-int ipc_set_rx_voice_mute_state(int func_id, int mute);
-int ipc_get_rx_voice_mute_state(int func_id, int *p_mute);
-int ipc_set_loopback_enable_state(int func_id, int enable);
-int ipc_get_loopback_enable_state(int func_id, int *p_enable);
+//ipc send message to ap_ps
+int ipc_set_voice_device_mode(int dev_mode);
+int ipc_get_voice_device_mode(int *p_dev_mode);
+int ipc_set_rx_voice_vol(int vol);
+int ipc_get_rx_voice_vol(int *p_vol);
+int ipc_set_tx_voice_vol(int vol);
+int ipc_get_tx_voice_vol(int *p_vol);
+int ipc_set_tx_voice_mute_state(int mute);
+int ipc_get_tx_voice_mute_state(int *p_mute);
+int ipc_set_rx_voice_mute_state(int mute);
+int ipc_get_rx_voice_mute_state(int *p_mute);
+int ipc_set_loopback_enable_state(int enable);
+int ipc_get_loopback_enable_state(int *p_enable);
+int ipc_ap_alsa_voice_open(int vmode);
+int ipc_ap_alsa_voice_close(int vmode);
-int set_voice_device_mode(int dev_mode);
-
-#if 0
-int get_voice_device_mode(int *p_dev_mode);
-int set_rx_voice_vol(int vol);
-int get_rx_voice_vol(int * p_vol);
-int set_tx_voice_vol(int vol);
-int get_tx_voice_vol(int *p_vol);
-int set_tx_voice_mute_state(int mute );
-int get_tx_voice_mute_state(int *p_mute);
-int set_rx_voice_mute_state(int mute);
-int get_rx_voice_mute_state(int *p_mute);
-int set_loopback_enable_state(int enable);
-int get_loopback_enable_state(int *p_enable);
+//ipc receive message from ap_ps
+#ifdef _USE_VOICE_ALSA
+void ipc_cap_alsa_voice_open_rcv(voice_ipc_control_msg msg);
+void ipc_cap_alsa_voice_close_rcv(voice_ipc_control_msg msg);
#endif
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include/voice_lib.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include/voice_lib.h
index 28e276f..fca2f8d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include/voice_lib.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/include/voice_lib.h
@@ -25,7 +25,7 @@
#define AVOICE_5G_DEV_NUM 1
#endif
-#ifdef _USE_VOICE_ALSA
+
//#include "volte_drv.h"
@@ -44,10 +44,9 @@
AVOICE_5G_WB,
MAX_AVOICE_MODE
}T_Alsa_Voice_Mode;
+#ifdef _USE_VOICE_ALSA
int alsa_voice_open(int vmode);
-int alsa_voice_close(int vmode);
-
-
+int alsa_voice_close(int vmode);
#endif
int voice_close(T_Voice_Para *para);
int voice_open(T_Voice_Para *para);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/voice.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/voice.c
index b5ba036..01267be 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/voice.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/voice.c
@@ -225,7 +225,7 @@
//open mixer dev for codec control
voice_mixer = mixer_open(0);
if (!voice_mixer) {
- printf("zte voice_mixer open failed!\n");
+ printf("voice_mixer open failed!\n");
return -1;
}
@@ -251,23 +251,23 @@
//23G card 0 dev 2
volte_pcm_voice_out = pcm_open(0, AVOICE_4G_DEV_NUM, PCM_OUT, &config_voice);
if (!volte_pcm_voice_out || !pcm_is_ready(volte_pcm_voice_out)) {
- printf("zte volte_pcm_voice_out open failed!\n");
+ printf("volte_pcm_voice_out open failed!\n");
goto err_ret;
}
volte_pcm_voice_in = pcm_open(0, AVOICE_4G_DEV_NUM, PCM_IN, &config_voice);
if (!volte_pcm_voice_in || !pcm_is_ready(volte_pcm_voice_in)) {
- printf("zte volte_pcm_voice_in open failed!\n");
+ printf("volte_pcm_voice_in open failed!\n");
goto err_ret;
}
if (0 != pcm_prepare(volte_pcm_voice_out)) {
- printf("zte volte_pcm_voice_out pcm_prepare failed!\n");
+ printf("volte_pcm_voice_out pcm_prepare failed!\n");
goto err_ret;
}
if (0 != pcm_prepare(volte_pcm_voice_in)) {
- printf("zte volte_pcm_voice_in pcm_prepare failed!\n");
+ printf("volte_pcm_voice_in pcm_prepare failed!\n");
goto err_ret;
}
return 0;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/voice_ipc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/voice_ipc.c
index e9a94f7..f910fc7 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/voice_ipc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/libvoice/voice_ipc.c
@@ -8,7 +8,10 @@
#include <fcntl.h>
#include <linux/rpmsg/rpmsg_zx29.h>
#include "voice_ipc.h"
+#include "voice_lib.h"
#include <tinyalsa/audio_mixer_ctrl.h>
+#include "softap_api.h"
+#include "pthread.h"
extern int mix_set_voice_vol(struct mixer *mixer, int volume);
extern int mix_get_voice_vol(struct mixer *mixer, int *volume);
@@ -21,581 +24,646 @@
extern int mix_set_voice_path(struct mixer *mixer, int path);
extern int mix_get_voice_path(struct mixer *mixer, int *path);
-#define VOCIE_SND_CARD_NUM 0
-
int voice_ipc_fd = -1;
voice_ipc_control_msg voice_ctrl_recvmsg[IPC_VOICE_FUNC_MAX] = {0};
-int set_voice_device_mode(int dev_mode)
-{
- struct mixer *voice_mixer = NULL;
- printf("%s: start dev_mode=%d!\n", __func__, dev_mode);
-
- if ((dev_mode < T_OUTPUT_HANDSET) || (dev_mode >= T_OUTPUT_MAX)){
- printf("%s: dev_mode not support, dev_mode=%d!\n", __func__, dev_mode);
- return -1;
- }
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_set_voice_path(voice_mixer, dev_mode);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
-
- return 0;
-}
-
-#if 0
-int get_voice_device_mode(int *p_dev_mode)
-{
- struct mixer *voice_mixer = NULL;
- printf("%s: start!\n", __func__);
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_get_voice_path(voice_mixer, p_dev_mode);
- if((*p_dev_mode < T_OUTPUT_HANDSET ) || (*p_dev_mode >= T_OUTPUT_MAX)){
- printf("%s: dev_mode not support, *p_dev_mode=%d!\n", __func__, *p_dev_mode);
- //return -1;
- }
- printf("%s: start *p_dev_mode=%d!\n", __func__, *p_dev_mode);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
-
- return 0;
-}
-
-int set_rx_voice_vol(int vol)
-{
- struct mixer *voice_mixer = NULL;
- printf("%s: start vol=%d!\n", __func__, vol);
-
- if ((vol < 0 ) ||(vol > 11)){
- printf("%s: vol not support, vol=%d!\n", __func__, vol);
- return -1;
- }
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_set_voice_vol(voice_mixer, vol);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
-
- return 0;
-}
-
-int get_rx_voice_vol(int * p_vol)
-{
- struct mixer *voice_mixer = NULL;
-
- printf("%s: start!\n", __func__);
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_get_voice_vol(voice_mixer, p_vol);
-
- if ((*p_vol < 0) || (*p_vol > 11)){
- printf("%s: vol not support, *p_vol=%d!\n", __func__, *p_vol);
- //return -1;
- }
- printf("%s: *p_vol=%d!\n", __func__, *p_vol);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
-
- return 0;
-}
-
-int set_tx_voice_vol(int vol)
-{
- struct mixer *voice_mixer = NULL;
- printf("%s: start vol=%d!\n", __func__, vol);
-
- if ((vol < 0 ) ||(vol > 11)){
- printf("%s: vol not support, vol=%d!\n", __func__, vol);
- return -1;
- }
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_set_tx_voice_vol(voice_mixer, vol);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
-
- return 0;
-}
-
-int get_tx_voice_vol(int *p_vol)
-{
- struct mixer *voice_mixer = NULL;
- printf("%s: start!\n", __func__);
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_get_tx_voice_vol(voice_mixer, p_vol);
-
- if((*p_vol < 0 ) ||(*p_vol > 5)){
- printf("%s: vol not support, *p_vol=%d!\n", __func__, *p_vol);
- //return -1;
- }
- printf("%s: *p_vol=%d!\n", __func__, *p_vol);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
- return 0;
-}
-
-int set_tx_voice_mute_state(int mute )
-{
- struct mixer *voice_mixer = NULL;
- printf("%s: start mute=%d!\n", __func__, mute);
-
- if((mute != 0 ) &&(mute != 1)) {
- printf("%s: mute not support, mute=%d!\n", __func__, mute);
- return -1;
- }
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_set_voice_mute(voice_mixer, mute);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
-
- return 0;
-}
-
-int get_tx_voice_mute_state(int *p_mute)
-{
- struct mixer *voice_mixer = NULL;
-
- printf("%s: start!\n", __func__);
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_get_voice_mute(voice_mixer, p_mute);
-
- if((*p_mute != 0 ) && (*p_mute != 1)) {
- printf("%s: *p_mute not support, *p_mute=%d!\n", __func__, *p_mute);
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
- return -1;
- }
- printf("%s: *p_mute=%d!\n", __func__, *p_mute);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
-
- return 0;
-}
-
-int set_rx_voice_mute_state(int mute)
-{
- struct mixer *voice_mixer = NULL;
- printf("%s: start mute=%d!\n", __func__, mute);
-
- if((mute != 0 ) &&(mute != 1)) {
- printf("%s: mute not support, mute=%d!\n", __func__, mute);
- return -1;
- }
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_set_rx_voice_mute(voice_mixer, mute);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
- return 0;
-}
-
-
-int get_rx_voice_mute_state(int *p_mute){
- struct mixer *voice_mixer = NULL;
-
- printf("%s: start!\n", __func__);
-
- //open mixer dev for control
- voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
- if (!voice_mixer) {
- printf("voice_mixer open failed!\n");
- return -1;
- }
-
- //config mixer dev
- mix_get_rx_voice_mute(voice_mixer, p_mute);
-
- if((*p_mute != 0 ) && (*p_mute != 1)) {
-
- printf("%s: *p_mute not support, *p_mute=%d!\n", __func__, *p_mute);
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
- return -1;
- }
- printf("%s: *p_mute=%d!\n", __func__, *p_mute);
-
- //close mixer
- mixer_close(voice_mixer);
- voice_mixer = NULL;
-
- return 0;
-}
-
-int set_loopback_enable_state(int enable)
-{
- return 0;
-}
-
-int get_loopback_enable_state(int *p_enable)
-{
- return 0;
-}
-#endif
-
-int ipc_set_voice_device_mode(int func_id, int dev_mode)
+int msg_send_and_recv(int src_id, int dst_id, int msg_cmd, int *value)
{
int ret = 0;
+ int msg_handle = 0;
+ MSG_BUF msg;
+ LONG msg_size = sizeof(MSG_BUF)-sizeof(LONG);
+
+ //´´½¨ÏûÏ¢¶ÓÁÐ
+ msg_handle = msgget(src_id, IPC_CREAT|0600);
+
+ //·¢ËÍÏûÏ¢
+ if(NULL == value){
+ ret = ipc_send_message(src_id, dst_id, msg_cmd, 0, NULL, 0);;
+ }else{
+ ret = ipc_send_message(src_id, dst_id, msg_cmd, sizeof(int), (unsigned char *)value, 0);
+ }
+ if(0 != ret){
+ printf("%s: send msg error(%d)!\n", __func__, ret);
+ msgctl(msg_handle,IPC_RMID,0);
+ return ret;
+ }
+ printf("%s: send msg success(%d)!\n", __func__, ret);
+
+ //½ÓÊÕÏûÏ¢
+ while(1)
+ {
+ memset(&msg, 0x00, sizeof(MSG_BUF));
+ //printf("%s: msgrcv start, msg.usMsgCmd=%d\n", __func__, msg.usMsgCmd);
+ //»ñÈ¡ÏûÏ¢¶ÓÁÐÏûÏ¢²¢´¦Àí£¬×èÈûʽ
+ ret = msgrcv(msg_handle, &msg, msg_size, 0, 0);
+ if(0 > ret){
+ continue;
+ }
+ printf("%s: msgrcv end, msg.usMsgCmd=%d\n", __func__, msg.usMsgCmd);
+ //Æ¥Åäµ½ÊÇMSG_CMD_CAP_VALSA_OPENʱ²Å´¦Àí
+ if(msg_cmd == msg.usMsgCmd){
+ ret = *((int *)msg.aucDataBuf);
+ msgctl(msg_handle,IPC_RMID,0);
+ printf("%s: receive msg success(%d)!\n", __func__, ret);
+ break;
+ }
+ }
+
+ return ret;
+}
+
+int msg_set_voice_device_mode(int dev_mode)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_SET_VOICE_DEVICE_MODE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, &dev_mode);
+
+ return ret;
+}
+
+//int msg_get_voice_device_mode(int *p_dev_mode)
+int msg_get_voice_device_mode(void)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_GET_VOICE_DEVICE_MODE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, NULL);
+
+ return ret;
+}
+
+int msg_set_rx_voice_vol(int vol)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_SET_RX_VOICE_VOL;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, &vol);
+
+ return ret;
+}
+
+int msg_get_rx_voice_vol(void)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_GET_RX_VOICE_VOL;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, NULL);
+
+ return ret;
+}
+
+int msg_set_tx_voice_vol(int vol)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_SET_TX_VOICE_VOL;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, &vol);
+
+ return ret;
+}
+
+int msg_get_tx_voice_vol(void)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_GET_TX_VOICE_VOL;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, NULL);
+
+ return ret;
+}
+
+int msg_set_tx_voice_mute_state(int mute)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_SET_TX_VOICE_MUTE_STATE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, &mute);
+
+ return ret;
+}
+
+int msg_get_tx_voice_mute_state(void)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_GET_TX_VOICE_MUTE_STATE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, NULL);
+
+ return ret;
+}
+
+int msg_set_rx_voice_mute_state(int mute)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_SET_RX_VOICE_MUTE_STATE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, &mute);
+
+ return ret;
+}
+
+int msg_get_rx_voice_mute_state(void)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_GET_RX_VOICE_MUTE_STATE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, NULL);
+
+ return ret;
+}
+
+int msg_set_loopback_enable_state(int enable)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_SET_LOOPBACK_ENABLE_STATE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, &enable);
+
+ return ret;
+}
+
+int msg_get_loopback_enable_state(void)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_GET_LOOPBACK_ENABLE_STATE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, NULL);
+
+ return ret;
+}
+
+int msg_ap_alsa_voice_open(int vmode)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_AP_ALSA_VOICE_OPEN;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, &vmode);
+
+ return ret;
+}
+
+int msg_ap_alsa_voice_close(int vmode)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_CLIENT;
+ int dst_id = MODULE_ID_VOICE_SERVER;
+ int msg_cmd = MSG_CMD_AP_ALSA_VOICE_CLOSE;
+
+ ret = msg_send_and_recv(module_id, dst_id, msg_cmd, &vmode);
+
+ return ret;
+}
+
+int ipc_set_voice_device_mode(int dev_mode)
+{
+ int ret = 0;
+ int func_id = IPC_SET_VOICE_DEVICE_MODE;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, &dev_mode);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_get_voice_device_mode(int func_id, int *p_dev_mode)
+int ipc_get_voice_device_mode(int *p_dev_mode)
{
int ret = 0;
+ int func_id = IPC_GET_VOICE_DEVICE_MODE;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, p_dev_mode);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_set_rx_voice_vol(int func_id, int vol)
+int ipc_set_rx_voice_vol(int vol)
{
int ret = 0;
+ int func_id = IPC_SET_RX_VOICE_VOL;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, &vol);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_get_rx_voice_vol(int func_id, int *p_vol)
+int ipc_get_rx_voice_vol(int *p_vol)
{
int ret = 0;
+ int func_id = IPC_GET_RX_VOICE_VOL;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, p_vol);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_set_tx_voice_vol(int func_id, int vol)
+int ipc_set_tx_voice_vol(int vol)
{
int ret = 0;
+ int func_id = IPC_SET_TX_VOICE_VOL;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, &vol);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_get_tx_voice_vol(int func_id, int *p_vol)
+int ipc_get_tx_voice_vol(int *p_vol)
{
int ret = 0;
+ int func_id = IPC_GET_TX_VOICE_VOL;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, p_vol);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_set_tx_voice_mute_state(int func_id, int mute)
+int ipc_set_tx_voice_mute_state(int mute)
{
int ret = 0;
+ int func_id = IPC_SET_TX_VOICE_MUTE_STATE;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, &mute);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_get_tx_voice_mute_state(int func_id, int *p_mute)
+int ipc_get_tx_voice_mute_state(int *p_mute)
{
int ret = 0;
+ int func_id = IPC_GET_TX_VOICE_MUTE_STATE;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, p_mute);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_set_rx_voice_mute_state(int func_id, int mute)
+int ipc_set_rx_voice_mute_state(int mute)
{
int ret = 0;
+ int func_id = IPC_SET_RX_VOICE_MUTE_STATE;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, &mute);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_get_rx_voice_mute_state(int func_id, int *p_mute)
+int ipc_get_rx_voice_mute_state(int *p_mute)
{
int ret = 0;
+ int func_id = IPC_GET_RX_VOICE_MUTE_STATE;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, p_mute);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_set_loopback_enable_state(int func_id, int enable)
+int ipc_set_loopback_enable_state(int enable)
{
int ret = 0;
+ int func_id = IPC_SET_LOOPBACK_ENABLE_STATE;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, &enable);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
-int ipc_get_loopback_enable_state(int func_id, int *p_enable)
+int ipc_get_loopback_enable_state(int *p_enable)
{
int ret = 0;
+ int func_id = IPC_GET_LOOPBACK_ENABLE_STATE;
voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
ret = Voice_Ctrl_Rpmsg_Send(func_id, p_enable);
if (0 >= ret){
- printf("%s: write error(%d)!\n", __func__, ret);
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
return VOICEIPC_ERROR;
}
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
- for(;;){
- if(voice_ctrl_recvmsg[func_id].func_id != VOICE_WAIT_MSG_FROM_AP){
- break;
- }
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
}
memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
return ret;
}
+int ipc_ap_alsa_voice_open(int vmode)
+{
+ int ret = 0;
+ int func_id = IPC_AP_ALSA_VOICE_OPEN;
+ voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
+
+ ret = Voice_Ctrl_Rpmsg_Send(func_id, &vmode);
+
+ if (0 >= ret){
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
+ return VOICEIPC_ERROR;
+ }
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
+
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
+ }
+
+ memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
+
+ return ret;
+}
+
+int ipc_ap_alsa_voice_close(int vmode)
+{
+ int ret = 0;
+ int func_id = IPC_AP_ALSA_VOICE_CLOSE;
+ voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_AP;
+
+ ret = Voice_Ctrl_Rpmsg_Send(func_id, &vmode);
+
+ if (0 >= ret){
+ printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
+ return VOICEIPC_ERROR;
+ }
+ printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
+
+ while(func_id != voice_ctrl_recvmsg[func_id].func_id){
+ usleep(1);
+ }
+
+ memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
+ printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
+
+ return ret;
+}
+
+#ifdef _USE_VOICE_ALSA
+void ipc_cap_alsa_voice_open_rcv(voice_ipc_control_msg msg)
+{
+ int ret = VOICEIPC_OK;
+ int msg_len = 0;
+ int vmode = 0;
+
+ vmode = *((int *)msg.param);
+ ret = alsa_voice_open(vmode);
+
+ //msg.func_id²»±ä
+ msg.param_len = sizeof(int);
+ memcpy(msg.param, &ret, msg.param_len);
+ msg_len = VOICE_HEAD_LEN + msg.param_len;
+
+ ret = write(voice_ipc_fd, &msg, msg_len);
+
+ if (0 >= ret){
+ printf("%s: write error(%d)!\n", __func__, ret);
+ }
+ printf("%s: ipc write success, ret=%d\n", __func__, ret);
+}
+
+void ipc_cap_alsa_voice_close_rcv(voice_ipc_control_msg msg)
+{
+ int ret = VOICEIPC_OK;
+ int msg_len = 0;
+ int vmode = 0;
+
+ vmode = *((int *)msg.param);
+ ret = alsa_voice_close(vmode);
+
+ //msg.func_id²»±ä
+ msg.param_len = sizeof(int);
+ memcpy(msg.param, &ret, msg.param_len);
+ msg_len = VOICE_HEAD_LEN + msg.param_len;
+
+ ret = write(voice_ipc_fd, &msg, msg_len);
+
+ if (0 >= ret){
+ printf("%s: write error(%d)!\n", __func__, ret);
+ }
+ printf("%s: ipc write success, ret=%d\n", __func__, ret);
+}
+#endif
+
+void voice_ipc_recv_proc(voice_ipc_control_msg msg)
+{
+ switch(msg.func_id){
+#ifdef _USE_VOICE_ALSA
+ case IPC_CAP_ALSA_VOICE_OPEN:
+ ipc_cap_alsa_voice_open_rcv(voice_ctrl_recvmsg[msg.func_id]);
+ break;
+ case IPC_CAP_ALSA_VOICE_CLOSE:
+ ipc_cap_alsa_voice_close_rcv(voice_ctrl_recvmsg[msg.func_id]);
+ break;
+#endif
+ default:
+ break;
+ }
+}
+
+void Voice_Ctrl_Rpmsg_Recv(void)
+{
+ int read_len = 0;
+ voice_ipc_control_msg tmpbuf = {0};
+
+ while(1){
+ read_len = 0;
+ read_len = read(voice_ipc_fd, &tmpbuf, (VOICE_HEAD_LEN + VOICE_CONTROL_MAX_LEN));
+ if (0 >= read_len){
+ sleep(1);
+ continue;
+ }
+ printf("%s: voice_ipc_fd=%d, read_len=%d\n", __func__, voice_ipc_fd, read_len);
+
+ //×îºóÔٸıäfunc_id£¬È·±£ÆäËûµØ·½ÅжÏfunc_id¸Ä±äºóÓÐÊý¾Ý¿É¶Á
+ memcpy(voice_ctrl_recvmsg[tmpbuf.func_id].param, tmpbuf.param, tmpbuf.param_len);
+ voice_ctrl_recvmsg[tmpbuf.func_id].param_len = tmpbuf.param_len;
+ voice_ctrl_recvmsg[tmpbuf.func_id].func_id = tmpbuf.func_id;
+ printf("%s: tmpbuf.param_len=%d, tmpbuf.func_id=%d\n", __func__, tmpbuf.param_len, tmpbuf.func_id);
+
+ voice_ipc_recv_proc(voice_ctrl_recvmsg[tmpbuf.func_id]);
+ }
+}
+
int Voice_Ctrl_Rpmsg_Send(int func_id, int *msg)
{
voice_ipc_control_msg tmpbuf = {0};
@@ -613,31 +681,13 @@
tmpbuf_len = VOICE_HEAD_LEN + tmpbuf.param_len;
+ //printf("Voice_Ctrl_Rpmsg_Send, voice_ipc_fd = %d\n", voice_ipc_fd);
write_len = write(voice_ipc_fd, &tmpbuf, tmpbuf_len);
return write_len;
}
-void Voice_Ctrl_Rpmsg_Recv(void)
-{
- int read_len = 0;
- voice_ipc_control_msg tmpbuf = {0};
-
- for(;;){
- read_len = 0;
- read_len = read(voice_ipc_fd, &tmpbuf, (VOICE_HEAD_LEN + VOICE_CONTROL_MAX_LEN));
- if (0 >= read_len){
- continue;
- }
-
- //最后再改变func_id,确保其他地方判断func_id改变后有数据可读
- memcpy(voice_ctrl_recvmsg[tmpbuf.func_id].param, tmpbuf.param, tmpbuf.param_len);
- voice_ctrl_recvmsg[tmpbuf.func_id].param_len = tmpbuf.param_len;
- voice_ctrl_recvmsg[tmpbuf.func_id].func_id = tmpbuf.func_id;
- }
-}
-
-int voice_ipc_init(void) //通道初始化
+int voice_ipc_init(void) //ͨµÀ³õʼ»¯
{
voice_ipc_fd = open(VOICE_IPC_CONTROL_CHANNEL, O_RDWR);
@@ -653,21 +703,24 @@
return VOICEIPC_ERROR;
}
- if(0 > ioctl(voice_ipc_fd, RPMSG_SET_INT_FLAG, NULL)){ //写中断
+ if(0 > ioctl(voice_ipc_fd, RPMSG_SET_INT_FLAG, NULL)){ //дÖжÏ
printf("%s: ioctl RPMSG_SET_INT_FLAG fail!\n", __func__);
close(voice_ipc_fd);
voice_ipc_fd = -1;
return VOICEIPC_ERROR;
}
- if(0 > ioctl(voice_ipc_fd, RPMSG_CLEAR_POLL_FLAG, NULL)){ //阻塞方式读数据
+ if(0 > ioctl(voice_ipc_fd, RPMSG_CLEAR_POLL_FLAG, NULL)){ //×èÈû·½Ê½¶ÁÊý¾Ý
printf("%s: ioctl RPMSG_CLEAR_POLL_FLAG fail!\n", __func__);
close(voice_ipc_fd);
voice_ipc_fd = -1;
return VOICEIPC_ERROR;
}
+ printf("voice_ipc_init %s create success! voice_ipc_fd = %d\n", VOICE_IPC_CONTROL_CHANNEL);
+
return VOICEIPC_OK;
}
#endif
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nv-rpc-daemon/main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nv-rpc-daemon/main.c
index df82831..cf58719 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nv-rpc-daemon/main.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nv-rpc-daemon/main.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <assert.h>
#include <dirent.h>
#include <string.h>
#include <sys/file.h>
@@ -27,12 +28,10 @@
#include <sys/msg.h>
#include <message.h>
#include <sched.h>
+#include <sys/syscall.h>
#include "nv_typedef.h"
#include "sc_rpc.h"
-#ifdef FOTA_AB
-#include "zxic_fota_ab_upgrade.h"
-#endif
#ifdef __cplusplus
extern "C"
@@ -64,10 +63,42 @@
/*******************************************************************************
* È«¾Ö±äÁ¿¶¨Òå *
*******************************************************************************/
+static long g_pid;
+static long g_ap_pid_backup;
/*******************************************************************************
* ¾Ö²¿º¯ÊýʵÏÖ *
*******************************************************************************/
+static void print_nv_info(T_NV_MSG_INFO *msg)
+{
+ switch(msg->nvType)
+ {
+ case MSG_GET:
+ printf("[nvrpc] cfg_get key:%s\n", msg->key);
+ break;
+ case MSG_SET:
+ printf("[nvrpc] cfg_set key:%s value:%s\n", msg->key, msg->value);
+ break;
+ case MSG_UNSET:
+ printf("[nvrpc] cfg_unset key:%s\n", msg->key);
+ break;
+ case MSG_CLEAR:
+ printf("[nvrpc] cfg_clear\n");
+ break;
+ case MSG_RESET:
+ printf("[nvrpc] cfg_reset\n");
+ break;
+ case MSG_SHOW:
+ printf("[nvrpc] cfg_show\n");
+ break;
+ case MSG_COMMIT:
+ printf("[nvrpc] cfg_save\n");
+ break;
+ default:
+ printf("[nvrpc] cfg other action\n");
+ break;
+ }
+}
/*******************************************************************************
* ¹¦ÄÜÃèÊö: analyMsg
* ²ÎÊý˵Ã÷:
@@ -81,11 +112,11 @@
int msgId;
T_NV_MSG_INFO msgSnd;
T_NV_MSG_RESULT msgRcv;
- static int msgIndex = 0;
+ //static int msgIndex = 0;
- msgSnd.msgType = MSG_TYPE_NV;
- msgRcv.msgType = MSG_TYPE_NV;
- msgSnd.msgIndex = msgIndex++;
+ //msgSnd.msgType = MSG_TYPE_NV;
+ //msgRcv.msgType = MSG_TYPE_NV;
+ //msgSnd.msgIndex = msgIndex++;
msgId = msgget(MODULE_ID_NV, IPC_CREAT | 0600);
if (-1 == msgId)
{
@@ -95,6 +126,11 @@
}
memcpy(&msgSnd, data->data, sizeof(T_NV_MSG_INFO));
+ g_ap_pid_backup = msgSnd.pid;
+ msgSnd.msgType = MSG_TYPE_NV;
+ msgSnd.pid = g_pid;
+ //printf("apnv_cap msgsnd to nvserver pid:%d\n", msgSnd.pid);
+ print_nv_info(&msgSnd);
retry1:
if (-1 == msgsnd(msgId, &msgSnd, sizeof(T_NV_MSG_INFO) - sizeof(long), 0))
@@ -117,12 +153,43 @@
goto retry1;
}
+ msgRcv.msgType = g_ap_pid_backup;
+ //printf("apnv_cap msgRcv to ap pid:%d\n", msgRcv.msgType);
memcpy(data->data, &msgRcv, sizeof(T_NV_MSG_RESULT));
ret:
data->msg_type = RPC_MSG_TYPE_REPLY;
}
+static int nv_rpc_wait_ready(int fd)
+{
+ T_sc_rpc_header *rpc_data;
+ unsigned int timeout = 200; //ms
+ int write_flag = 1;
+
+ rpc_data = malloc(sizeof(T_sc_rpc_header));
+ if (rpc_data == NULL)
+ return -1;
+ while(1)
+ {
+ rpc_data->msg_type = RPC_MSG_TYPE_READY;
+ if (write_flag)
+ {
+ if (write(fd, rpc_data, sizeof(T_sc_rpc_header)) != 0)
+ write_flag = 0; // write ok and write sonly once
+ }
+ if (read(fd, rpc_data, sizeof(T_sc_rpc_header)) == 0)
+ {
+ usleep(timeout * 1000);
+ continue;
+ }
+ break; /* read some data mean channel ok */
+ }
+
+ free(rpc_data);
+ return 0;
+}
+
static void write_lockfile(char *filepath, char *setbuf)
{
int f = -1;
@@ -186,6 +253,12 @@
nvrpc_set_priority();
wake_nvrpc_lock();
fd = sc_rpc_open(RPC_RPMSG_DEV);
+ g_pid = syscall(SYS_gettid);
+
+ if (nv_rpc_wait_ready(fd) < 0)
+ {
+ assert(0);
+ }
while (1)
{
@@ -195,6 +268,8 @@
//printf("nvrpc rpmsg recv error\n");
continue;
}
+ if (data.msg_type != RPC_MSG_TYPE_REQUEST)
+ continue;
//printf("nvrpc rpmsg recv ok\n");
wake_nvrpc_lock();
analyMsg(&data);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nv-rpc-daemon/sc_rpc.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nv-rpc-daemon/sc_rpc.h
index 34b84ee..29d36f1 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nv-rpc-daemon/sc_rpc.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nv-rpc-daemon/sc_rpc.h
@@ -17,7 +17,8 @@
enum
{
RPC_MSG_TYPE_REQUEST = 0xAA,
- RPC_MSG_TYPE_REPLY = 0xBB
+ RPC_MSG_TYPE_REPLY = 0xBB,
+ RPC_MSG_TYPE_READY = 0x55
};
enum
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/Makefile
index 2a3b76e..eaaf617 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/Makefile
@@ -6,11 +6,11 @@
CFLAGS += -I$(LIB_DIR)/libnvram
CFLAGS += -I$(APP_DIR)/include
LDLIBS += -L$(LIB_DIR)/libnvram
-LDLIBS += -lnvram
+LDLIBS += -lpthread -lmtd -lnvram -lsofttimer -lupi_ab -lsoftap
all: $(EXEC)
$(EXEC): $(OBJS)
- $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS$(LDLIBS_$@))
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
romfs:
cp $(EXEC) $(EXEC).elf
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/nvserver.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/nvserver.c
index 9a5fa52..a7c4b07 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/nvserver.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/nvserver.c
@@ -399,7 +399,7 @@
nvcommit(list->nvFile);
#ifdef FOTA_AB
//clear fotaflag for fota ab
- dual_AB_set_fota_status_for_nv(0);
+ zxic_dual_set_fota_status_for_nv(0);
#endif
}
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/nvupdate.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/nvupdate.c
index 958010b..7c415ba 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/nvupdate.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/nvserver/nvupdate.c
@@ -75,7 +75,7 @@
#ifdef FOTA_AB
int get_update_status (void)
{
- int ret = dual_AB_get_fota_status_for_nv();
+ int ret = zxic_dual_get_fota_status_for_nv();
if (ret == 1)
return 2;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/rtc-service/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/rtc-service/Makefile
index 8588909..c69ca28 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/rtc-service/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/rtc-service/Makefile
@@ -25,6 +25,7 @@
LDLIBS += -lsoftap -L$(LIB_DIR)/libsoftap
LDLIBS += -lsofttimer -L$(LIB_DIR)/libsofttimer
LDLIBS += -latutils -L$(LIB_DIR)/libatutils
+LDLIBS += -lscipc -L$(zte_lib_path)/libscipc
##############USER COMIZE END##################
#*******************************************************************************
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/rtc-service/rtc-service.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/rtc-service/rtc-service.c
index a4a3ad5..8772ad9 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/rtc-service/rtc-service.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/rtc-service/rtc-service.c
@@ -17,6 +17,8 @@
#include "rtc-service.h"
#include "hotplug.h"
#include <limits.h>
+#include "sc_ipc.h"
+#include "sc_rtc_timer_msg.h"
/*******************************************************************************
* Global variable definitions *
@@ -37,6 +39,7 @@
static pthread_t rtc_looper_id = 0;
static int g_clean_flag = 0;
static int g_time_offset = 2; //ÔÊÐíÎó²î·¶Î§£¬ÊÊÅärtcºÍOSʱÖÓÆµÂʲ»Ò»ÖÂÎÊÌâ
+
/*******************************************************************************
* Local function implementations *
******************************************************************************/
@@ -79,6 +82,26 @@
}
+static void send_rtc_msg(int src_id, unsigned int msg_id, const void *msg_data, unsigned int msg_size)
+{
+ int ret =0;
+ sc_ipc_msg *sc_rtc_msg = sc_ipc_msg_new(msg_size);
+
+ sc_rtc_msg->type = 1;
+ sc_rtc_msg->fd_cli = MODULE_ID_RTC_SERVICE;
+ sc_rtc_msg->fd_svr = src_id;
+ sc_rtc_msg->msg_req = msg_id;
+ sc_rtc_msg->data_len = msg_size;
+ memcpy(sc_rtc_msg->data, msg_data, msg_size);
+
+ ret = sc_ipc_send_msg(sc_rtc_msg);
+ if(0 != ret) {
+ slog(TELSVR_PRINT, SLOG_ERR, "send_rtc_msg sc_ipc_send_msg fail,ret=%d.\n",ret);
+ }
+
+ sc_ipc_msg_free(sc_rtc_msg);
+}
+
static long get_RtcTime()
{
long curRtcTime = 0;
@@ -854,6 +877,7 @@
else
{
slog(RTC_PRINT, SLOG_NORMAL, "to cap: RTC_MSG_GET_TIME :%lu \n",buf->ulSec);
+ send_rtc_msg(buf->srcModule,SC_RTC_MSG_CMD_GET_TIME_RSP,(void *)buf, sizeof(RTC_DATA_BUF));
}
break;
case RTC_MSG_SET_TIME:
@@ -870,6 +894,13 @@
}
}
break;
+ case RTC_MSG_SNTP_UPDATE:
+ ptm = (struct tm *)pmsg_buf->aucDataBuf;
+ ret = send_soc_msg(NEAR_PS, MODULE_ID_RTC_SERVICE, cmd, pmsg_buf->usDataLen, (void *)pmsg_buf->aucDataBuf);
+ if (ret != 0) {
+ slog(RTC_PRINT, SLOG_ERR, "process_msg_to_cp: ipc_send_message unexpected,ret:%d\n",ret);
+ }
+ break;
case RTC_MSG_ADD_ALARM:
case RTC_MSG_DEL_ALARM:
buf = (RTC_DATA_BUF *)pmsg_buf->aucDataBuf;
@@ -890,9 +921,17 @@
buf = (RTC_DATA_BUF *)pmsg_buf->aucDataBuf;
if (buf->cpu == RTC_CPU_AP) {
slog(RTC_PRINT, SLOG_NORMAL, "from ap: cmd:0x%x, module:0x%x, msg_id:0x%x, sec:%ld: %d, %d, %d \n", cmd, buf->module, buf->srcModule, buf->ulSec, buf->cpu, buf->is_utc, buf->wakeup);
- ret = ipc_send_message(MODULE_ID_RTC_SERVICE, buf->srcModule, RTC_MSG_ALARM_ELAPSED, sizeof(RTC_DATA_BUF), buf, 0);
- if (ret != 0) {
- slog(RTC_PRINT, SLOG_ERR, "process_msg_to_cp: ipc_send_message unexpected,ret:%d\n",ret);
+ if((buf->module==RTC_ID_SC_TIMER)||(buf->module==RTC_ID_SC_ALARM))
+ {
+ send_rtc_msg(buf->srcModule,SC_RTC_MSG_CMD_TIMEOUT,(void *)buf, sizeof(RTC_DATA_BUF));
+ }
+ else
+ {
+ ret = ipc_send_message(MODULE_ID_RTC_SERVICE, buf->srcModule, RTC_MSG_ALARM_ELAPSED, sizeof(RTC_DATA_BUF), buf, 0);
+ if (ret != 0)
+ {
+ slog(RTC_PRINT, SLOG_ERR, "process_msg_to_cp: ipc_send_message unexpected,ret:%d\n",ret);
+ }
}
}
break;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/sntp/sntp.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/sntp/sntp.c
index 787d9c0..a3257db 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/sntp/sntp.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/sntp/sntp.c
@@ -547,6 +547,8 @@
if (0 == settimeofday(&tp, NULL)) {
system("zxic-rtc-clock");
+ time_t cur_time = time(0);
+ ipc_send_message(0, MODULE_ID_RTC_SERVICE, RTC_MSG_SNTP_UPDATE, sizeof(time_t),&cur_time, 0);
slog(MISC_PRINT, SLOG_DEBUG, "[zyl]system zxic-rtc-clock \n");
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/Makefile
index 0cfc788..69789db 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/Makefile
@@ -25,7 +25,7 @@
LDLIBS += -lvoice -L$(zte_lib_path)/libvoice
LDLIBS += -lscipc -L$(zte_lib_path)/libscipc
LDLIBS += -ltelsvr -L$(zte_lib_path)/libtelecom/lib/libtelsvr.a
-
+LDLIBS += -lmedia -L$(zte_lib_path)/libmedia
##############USER COMIZE END##################
#*******************************************************************************
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/call/telecom_cc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/call/telecom_cc.c
index 20db5a1..cca75fc 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/call/telecom_cc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/call/telecom_cc.c
@@ -54,7 +54,7 @@
else {
comm_res.result = -1;
cc_client_modid = -1;
- slog(TELSVR_PRINT, SLOG_NORMAL, "cc_connect_request dmp_cc_init fail.");
+ slog(TELSVR_PRINT, SLOG_NORMAL, "cc_connect_request dmp_cc_init fail.\n");
}
cc_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
@@ -85,28 +85,65 @@
static int cc_hangupall_request(int callid)
{
- cc_stop_ringback();
+ zblCcCallDetail call_detail;
+
+ cc_stop_ringback();
+
+ memset(&call_detail, 0, sizeof(call_detail));
+ if(0 != dmp_cc_query_detail(&call_detail, WORK_MODE_AP)) {
+ slog(TELSVR_PRINT, SLOG_ERR, "cc_hangupall_request dmp_cc_query_detail fail.\n");
+ return -1;
+ }
+ if(0 == call_detail.count) {
+ slog(TELSVR_PRINT, SLOG_ERR, "cc_hangupall_request fail. the call count is 0.\n");
+ return -1;
+ }
return dmp_cc_endall(WORK_MODE_AP);
}
static int cc_hangup_request(int callid)
{
+ ZblCcCallState call_state = dmp_cc_query_state(callid, WORK_MODE_AP);
+
+ if(ZBL_CALL_NON == call_state) {
+ slog(TELSVR_PRINT, SLOG_ERR, "cc_hangup_request fail.callid=%d,call_state=%d.\n",callid,call_state);
+ return -1;
+ }
+
cc_stop_ringback();
return dmp_cc_hangup(callid, 0, WORK_MODE_AP);
}
static int cc_answer_request(int callid)
{
+ ZblCcCallState call_state = dmp_cc_query_state(callid, WORK_MODE_AP);
+
+ if(ZBL_CALL_INCOMING != call_state) {
+ slog(TELSVR_PRINT, SLOG_ERR, "cc_answer_request fail.callid=%d,call_state=%d.\n",callid,call_state);
+ return -1;
+ }
return dmp_cc_answer(callid, WORK_MODE_AP);
}
static int cc_hold_request(int callid)
{
+ ZblCcCallState call_state = dmp_cc_query_state(callid, WORK_MODE_AP);
+
+ if(ZBL_CALL_NON == call_state || ZBL_CALL_HELD == call_state) {
+ slog(TELSVR_PRINT, SLOG_ERR, "cc_hold_request fail.callid=%d,call_state=%d.\n",callid,call_state);
+ return -1;
+ }
return dmp_cc_hold(callid, WORK_MODE_AP);
}
static int cc_unhold_request(int callid)
{
+ ZblCcCallState call_state = dmp_cc_query_state(callid, WORK_MODE_AP);
+
+ if(ZBL_CALL_HELD != call_state) {
+ slog(TELSVR_PRINT, SLOG_ERR, "cc_unhold_request fail.callid=%d,call_state=%d.\n",callid,call_state);
+ return -1;
+ }
return dmp_cc_resume(callid, WORK_MODE_AP);
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/call/telecom_cc_voice.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/call/telecom_cc_voice.c
index 7eae460..4fa4afe 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/call/telecom_cc_voice.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/call/telecom_cc_voice.c
@@ -11,6 +11,7 @@
#include <tinyalsa/audio_mixer_ctrl.h>
#include "voice_lib.h"
+#include "sc_voice_api.h"
#include "zbl_cc_interface.h"
#include "zbl_interface.h"
@@ -46,8 +47,8 @@
{
cc_stop_ringback();
}
-#ifdef _USE_VOICE_ALSA
-int cc_voice_open_at(int onoff, int mode)
+#if defined(_USE_VOICE_ALSA) && defined(_USE_ALSA_AT_INTF)
+static int cc_voice_open_at(int onoff, int mode)
{
char cmd[32] = {0};
@@ -64,7 +65,7 @@
}
else {
if(0 != alsa_voice_close(mode)) {
- slog(TELSVR_PRINT, SLOG_NORMAL,"cc_voice_open_at alsa_voice_close\n");
+ slog(TELSVR_PRINT, SLOG_ERR,"cc_voice_open_api cc_voice_open_at fail.\n");
return -1;
}
}
@@ -75,14 +76,72 @@
return 0;
}
+#elif defined(_USE_VOICE_ALSA)
+static int cc_voice_open_api(int onoff, int mode)
+{
+ if(1 == onoff) {
+ if(0 != alsa_voice_open(mode)) {
+ slog(TELSVR_PRINT, SLOG_ERR,"cc_voice_open_api cap alsa_voice_open TEAK_2G_3G fail\n");
+ return -1;
+ }
+
+ if(0 != sc_audio_ap_alsa_voice_open(mode)) {
+ alsa_voice_close(mode);
+ slog(TELSVR_PRINT, SLOG_ERR,"cc_voice_open_api ap alsa_voice_open TEAK_2G_3G fail\n");
+ return -1;
+ }
+ }
+ else {
+ if(0 != sc_audio_ap_alsa_voice_close(mode)) {
+ slog(TELSVR_PRINT, SLOG_ERR,"cc_voice_open_api sc_audio_ap_alsa_voice_close fail.\n");
+ }
+ if(0 != alsa_voice_close(mode)) {
+ slog(TELSVR_PRINT, SLOG_ERR,"cc_voice_open_api alsa_voice_close fail.\n");
+ }
+ }
+
+ return 0;
+}
+
#endif
-static void cc_voice_close(void)
+static void cc_voice_close(ZblCcVoicdChnlInd *pVoiceChnl )
{
+ int mode = pVoiceChnl->mode;
+ int code_type = pVoiceChnl->CodeType;
+ int amr_path = pVoiceChnl->AmrPath;
+ int voice_mode;
+
slog(TELSVR_PRINT, SLOG_NORMAL, "cc_voice_close\n");
-#ifdef _USE_VOICE_ALSA
- cc_voice_open_at(0,AVOICE_TEAK_2G_3G);
+ if(3 == mode) {
+ voice_mode = AVOICE_TEAK_2G_3G;
+ }
+ /*WCDMA/TD-SCDMAģʽ*/
+ else if(((5 == mode) || (15 == mode)) ) {
+ /* 3G-NB ʹÓÃHW*/
+ if((code_type == 0) && (amr_path==0 )) {
+ voice_mode = AVOICE_TEAK_2G_3G;
+ }
+ /* 3G-NBʹÓÃSW*/
+ else if((code_type == 0) && (amr_path== 1)) {
+ voice_mode = AVOICE_SOFT_3G_NB;
+ }
+ /* 3G-WB*/
+ else if((code_type == 1) && (amr_path== 1 )) {
+ voice_mode = AVOICE_SOFT_3G_WB;
+ }
+ }
+ else
+ {
+ slog(TELSVR_PRINT, SLOG_ERR,"cc_voice_close unknown mode.\n");
+ return;
+ }
+#if defined(_USE_VOICE_ALSA) && defined(_USE_ALSA_AT_INTF)
+ cc_voice_open_at(0, voice_mode);
+#elif defined(_USE_VOICE_ALSA)
+ cc_voice_open_api(0, voice_mode);
#endif
+
/* send msg to audio ctrl */
cc_pcm_audio_resource_release(MODULE_ID_CALL_23G, VOICE_23G);
}
@@ -95,6 +154,7 @@
int amr_path = pVoiceChn->AmrPath;
T_audio_Res_Request requestParam = {0};
T_audio_UseRsp RspData = {0};
+ int voice_mode;
slog(TELSVR_PRINT, SLOG_NORMAL,"cc_voice_open mode:%d,code_type:%d,amr_path:%d\n",mode,code_type,amr_path);
@@ -106,30 +166,38 @@
/* GSM/GPRS */
if(3 == mode) {
-#ifdef _USE_VOICE_ALSA
- cc_voice_open_at(1, AVOICE_TEAK_2G_3G);
-#endif
+ voice_mode = AVOICE_TEAK_2G_3G;
}
/*WCDMA/TD-SCDMAģʽ*/
else if(((5 == mode) || (15 == mode)) ) {
/* 3G-NB ʹÓÃHW*/
if((code_type == 0) && (amr_path==0 )) {
+ voice_mode = AVOICE_TEAK_2G_3G;
}
/* 3G-NBʹÓÃSW*/
else if((code_type == 0) && (amr_path== 1)) {
+ voice_mode = AVOICE_SOFT_3G_NB;
}
/* 3G-WB*/
else if((code_type == 1) && (amr_path== 1 )) {
+ voice_mode = AVOICE_SOFT_3G_WB;
}
-#ifdef _USE_VOICE_ALSA
- cc_voice_open_at(1,AVOICE_TEAK_2G_3G);
-#endif
}
else
{
slog(TELSVR_PRINT, SLOG_ERR,"cc_voice_open unknown mode.\n");
goto error;
}
+
+#if defined(_USE_VOICE_ALSA) && defined(_USE_ALSA_AT_INTF)
+ if(0 != cc_voice_open_at(1,voice_mode)) {
+ goto error;
+ }
+#elif defined(_USE_VOICE_ALSA)
+ if(0 != cc_voice_open_api(1,voice_mode)) {
+ goto error;
+ }
+#endif
if(0 != cc_voice_mixer_config(0,T_OUTPUT_RECEIVER,T_AUDIO_OUTPUT_VOL_LEVEL_8, T_AUDIO_INPUT_VOL_LEVEL_8)) {
slog(TELSVR_PRINT, SLOG_ERR, "cc_voice_open cc_voice_mixer_config fail!\n");
@@ -138,7 +206,7 @@
return 0;
error:
- cc_voice_close();
+ cc_voice_close(pVoiceChnl);
return 0;
}
@@ -152,7 +220,7 @@
}
else {
/* close pcm2 device. */
- cc_voice_close();
+ cc_voice_close(pzbl_voicechnl);
}
return NULL;
@@ -204,7 +272,7 @@
dmp_cc_notify_audio_closed(rate,4);
#if 1 //modify for 4G test
- #ifdef _USE_VOICE_ALSA
+ #if defined(_USE_VOICE_ALSA) && defined(_USE_ALSA_AT_INTF)
cc_voice_open_at(1,AVOICE_4G_WB);
#endif
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server.c
index f55bf4a..8c6e17d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server.c
@@ -15,6 +15,9 @@
extern void tel_register_cc_event(void);
extern void sc_sim_register_svr_event(void);
+extern void sc_sms_register_svr_event(void);
+extern void sc_net_register_svr_event(void);
+
static void zbl_msg_post_cb(const char *channel_name, unsigned int msg_id, const void *msg_data, unsigned int msg_size)
{
@@ -39,10 +42,12 @@
zblDoInitialize(zbl_msg_post_cb);
- sc_ipc_start_loop(0);
+ sc_ipc_start_loop("telecom-server");
tel_register_cc_event();
sc_sim_register_svr_event();
+ sc_sms_register_svr_event();
+ sc_net_register_svr_event();
for(;;)
{
sleep(0x100000);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_net.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_net.c
new file mode 100755
index 0000000..2c3980b
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_net.c
@@ -0,0 +1,422 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <time.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <ctype.h>
+#include "sc_net_msg.h"
+#include "zbl_interface.h"
+#include "zbl_mm_interface.h"
+#include "zbl_ati_mm_msg.h"
+#include "sc_ipc.h"
+#include <softap_api.h>
+
+
+#define SUCCESS 0
+#define FAILED 1
+static int g_client_fd = -1;
+static void sc_net_print_msg(const sc_ipc_msg* const pmsg)
+{
+ printf("pmsg->fd_cli=%d \n", pmsg->fd_cli);
+ printf("pmsg->fd_svr=%d \n", pmsg->fd_svr);
+ printf("pmsg->msg_req=%d \n", pmsg->msg_req);
+ printf("pmsg->msg_rsp=%d \n", pmsg->msg_rsp);
+}
+
+static void net_ipcmsg_set(int fdsvr, int msgreq, void *data, int len, sc_ipc_msg *pipcmsg)
+{
+ pipcmsg->fd_cli = sc_ipc_get_self_fd();
+ pipcmsg->fd_svr = fdsvr;
+ pipcmsg->msg_req = msgreq;
+ pipcmsg->data_len = len;
+ memcpy(pipcmsg->data, data, len);
+}
+
+
+static sc_ipc_msg* sc_net_rsp_msg_create(unsigned int msg_rsp, unsigned int datalen)
+{
+ sc_ipc_msg *pmsg_rsp = NULL;
+ pmsg_rsp = (sc_ipc_msg *)malloc(sizeof(sc_ipc_msg) + datalen);
+ if(NULL == pmsg_rsp) {
+ return NULL;
+ }
+ memset(pmsg_rsp, 0, sizeof(sc_ipc_msg) + datalen);
+
+ pmsg_rsp->type = 1;
+ pmsg_rsp->fd_cli = sc_ipc_get_self_fd();
+ pmsg_rsp->fd_svr = g_client_fd;
+ pmsg_rsp->token = 0;
+ pmsg_rsp->msg_req = msg_rsp;
+
+ pmsg_rsp->data_len = datalen;
+ sc_net_print_msg(pmsg_rsp);
+ return pmsg_rsp;
+}
+
+static sc_ipc_msg* sc_net_rsp_msg_create_by_msgid(unsigned int msg_rsp, unsigned int datalen)
+{
+ sc_ipc_msg *pmsg_rsp = NULL;
+ pmsg_rsp = (sc_ipc_msg *)sc_ipc_msg_new(datalen);
+ if(NULL == pmsg_rsp) {
+ return NULL;
+ }
+ memset(pmsg_rsp, 0, sizeof(sc_ipc_msg) + datalen);
+
+ pmsg_rsp->type = 1;
+ pmsg_rsp->fd_cli = sc_ipc_get_self_fd();
+ pmsg_rsp->fd_svr = g_client_fd;
+ pmsg_rsp->token = 0;
+ pmsg_rsp->msg_req = msg_rsp;
+ pmsg_rsp->data_len = datalen;
+
+ sc_net_print_msg(pmsg_rsp);
+ return pmsg_rsp;
+}
+
+//at+cops=?
+static int handle_net_scan_request_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ dmp_net_plmn_reelect(1, WORK_MODE_AP);
+ return 0;
+}
+
+//at^sysconfig=20,5,0,0
+static int handle_net_mode_select_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ int mode =-1;
+ memcpy(&mode, pmsg->data, pmsg->data_len);
+ dmp_sysconfig_req (mode);
+ return 0;
+}
+
+//at^mode=0/1
+static int handle_net_mode_set_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ int mode = -1;
+ memcpy(&mode, pmsg->data, pmsg->data_len);
+ printf("handle_net_mode_set_evt mode:%d\n", mode);
+ dmp_mode_set_req(mode);
+ return 0;
+}
+
+
+//at+cops=1,2,"46008"
+static int handle_net_register_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ zblMmCopsSetReq set = {0};
+ net_cur_operator_t req = {0};
+ memcpy(&req, pmsg->data, pmsg->data_len);
+ printf("cops set info size %d %d %d %d %s %d",pmsg->data_len, sizeof(net_cur_operator_t), req.mode, req.format, req.oper, req.uAcT);
+ set.mode = req.mode;
+ set.format = req.format;
+ memcpy(set.oper, req.oper, NET_MAX_LONG_OPER_LEN-1);
+ printf("cops set info %d %d %s %d", set.mode, set.format, set.oper, set.act);
+ dmp_oper_set_req (&set);
+ return 0;
+}
+
+//at+cops=2
+static int handle_net_deregister_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ dmp_net_deregister(WORK_MODE_AP);
+ return 0;
+}
+
+//at^sysinfo?
+static int handle_get_register_state_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ dmp_net_get_register_state (1, 0, WORK_MODE_AP);
+ return 0;
+}
+
+//at+cops?
+static int handle_get_operator_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ dmp_net_cur_oper_get(0, WORK_MODE_AP);
+ return 0;
+}
+//at+csq
+static int handle_get_signal_power_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ dmp_net_get_signal_power (WORK_MODE_AP);
+ return 0;
+}
+
+//at^sysinfo
+static int handle_get_sysinfo_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ dmp_get_sysinfo(WORK_MODE_AP);
+ return 0;
+}
+
+//at+zemsciq=1
+static int handle_get_cell_info_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ dmp_cell_data_read_start();
+ return 0;
+}
+
+
+static int handle_net_cur_oper_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ AtiCopsReadCnf ret = {0};
+ memcpy(&ret, pmsg->data, pmsg->data_len);
+ net_cur_operator_t oper = {0};
+ oper.mode = ret.mode;
+ oper.format = ret.format;
+ oper.uAcT = ret.uAcT;
+ memcpy(oper.oper, ret.oper, NET_MAX_LONG_OPER_LEN-1);
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_GET_OPERATOR_RSP, sizeof(net_cur_operator_t));
+ memcpy(pmsg_rsp->data, &oper, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_mode_select_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblNetSwitchAccTechResult switchAccTechResult;
+ memcpy(&switchAccTechResult, pmsg->data, pmsg->data_len);
+ int result = switchAccTechResult.sResult;
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_MODE_SELECT_RSP, sizeof(result));
+ memcpy(pmsg_rsp->data, &result, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_get_register_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblNetRegisterState registerState = {0};
+ memcpy(®isterState, pmsg->data, pmsg->data_len);
+
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_GET_REGISTER_STATE_RSP, sizeof(ZblNetRegisterState));
+ memcpy(pmsg_rsp->data, ®isterState, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_get_scan_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblNetPlmnList plmn_list = {0};
+ //net_operator_list_t net_operator_list = {0};
+ memcpy(&plmn_list, pmsg->data, pmsg->data_len);
+ net_operator_list_t net_operator_list = {0};
+
+ int i = 0;
+ if(0 == plmn_list.count)
+ {
+ net_operator_list.len = 0;
+ }
+ if(plmn_list.count > NET_MAX_LONG_OPER_LEN)
+ {
+ plmn_list.count = NET_MAX_LONG_OPER_LEN;
+ }
+ net_operator_list.len = plmn_list.count;
+ for(i=0; i < plmn_list.count; i++)
+ {
+ net_operator_list.operators[i].state = plmn_list.plmn_a[i].state;
+ strncpy(net_operator_list.operators[i].loper_a, plmn_list.plmn_a[i].loper_a, strlen(plmn_list.plmn_a[i].loper_a));
+ strncpy(net_operator_list.operators[i].soper_a, plmn_list.plmn_a[i].soper_a, strlen(plmn_list.plmn_a[i].soper_a));
+ strncpy(net_operator_list.operators[i].noper_a, plmn_list.plmn_a[i].noper_a, strlen(plmn_list.plmn_a[i].noper_a));
+ net_operator_list.operators[i].act = plmn_list.plmn_a[i].act;
+ }
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_SCAN_RSP, sizeof(net_operator_list_t));
+ memcpy(pmsg_rsp->data, &net_operator_list, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_get_scan_result_fail_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int ret = 1;
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_SCAN_RSP, sizeof(int));
+ memcpy(pmsg_rsp->data, &ret, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_get_deregister_succ_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int ret = 0;
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_DEREGISTER_RSP, sizeof(ret));
+ memcpy(pmsg_rsp->data, &ret, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_get_deregister_fail_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int ret = -1;
+
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_DEREGISTER_RSP, sizeof(ret));
+ memcpy(pmsg_rsp->data, &ret, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_get_register_state_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblNetRegisterState registerState = {0};
+ memcpy(®isterState, pmsg->data, pmsg->data_len);
+
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_GET_REGISTER_STATE_RSP, sizeof(ZblNetRegisterState));
+ memcpy(pmsg_rsp->data, ®isterState, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_get_signal_power_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblNetSignalPower signalPower = {0};
+ memcpy(&signalPower, pmsg->data, pmsg->data_len);
+ printf("signalPower power_value:%d power_class:%d call_mode:%d\n",
+ signalPower.power_value, signalPower.power_class, signalPower.call_mode);
+ int signal = signalPower.power_value;
+
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_GET_CSQ_RSP, sizeof(signal));
+ memcpy(pmsg_rsp->data, &signal, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_get_sysinfo_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ AtiSysInfoCnf sysInfo = {0};
+ memcpy(&sysInfo, pmsg->data, pmsg->data_len);
+ net_sysinfo_t info = {0};
+ info.iSimStatus = sysInfo.iSvrStatus;
+ info.iSvrDomain = sysInfo.iSvrDomain;
+ info.iRoamStaus = sysInfo.iRoamStaus;
+ info.iSysMode = sysInfo.iSysMode;
+ info.iSysSubMode = sysInfo.iSysSubMode;
+
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_GET_REGISTER_STATE_RSP, sizeof(net_sysinfo_t));
+ memcpy(pmsg_rsp->data, &info, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_set_cops_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ UINT8 ret = 1;
+ memcpy(&ret, pmsg->data, pmsg->data_len);
+
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_REGISTER_RSP, sizeof(ret));
+ memcpy(pmsg_rsp->data, &ret, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_mode_set_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int ret = 1;
+ memcpy(&ret, pmsg->data, pmsg->data_len);
+
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_NET_MODE_SET_RSP, sizeof(ret));
+ memcpy(pmsg_rsp->data, &ret, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_get_cell_info_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int ret = 1;
+ char res[128] = {0};
+ memcpy(res, pmsg->data, pmsg->data_len);
+ printf("handle_net_get_cell_info_result_evt %s %s %d", pmsg->data, res, pmsg->data_len);
+
+ pmsg_rsp = sc_net_rsp_msg_create_by_msgid(MSG_CMD_GET_CELL_INFO_RSP, strlen(res));
+ memcpy(pmsg_rsp->data, res, pmsg->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_net_conn_request_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ net_connect_t *pconn_info = (net_connect_t *)pmsg->data;
+ net_common_res_t comm_res;
+ sc_ipc_msg *pmsg_rsp = sc_ipc_msg_new(sizeof(comm_res));
+
+ if(NULL == pmsg_rsp) {
+ assert(0);
+ return NULL;
+ }
+ if(0 == pconn_info->enable) {
+ slog(TELSVR_PRINT, SLOG_NORMAL, "handle_net_conn_request_evt client(0x%x) request disconnect.\n", g_client_fd);
+ g_client_fd = -1;
+ }
+ else {
+ g_client_fd = pmsg->fd_cli;
+ slog(TELSVR_PRINT, SLOG_NORMAL, "handle_net_conn_request_evt client(0x%x) request connect.\n", g_client_fd);
+ }
+ comm_res.result = 0;
+
+ net_ipcmsg_set(pmsg->fd_cli, pmsg->msg_rsp, (void *)&comm_res, sizeof(comm_res), pmsg_rsp);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+
+
+
+static sc_ipc_event s_net_evts[] =
+{
+ {0, 1, 0, MSG_CMD_NET_CONN_REQ, handle_net_conn_request_evt, 0, 0}, //Íê³É
+ {0, 1, 0, MSG_CMD_NET_SCAN, handle_net_scan_request_evt, 0, 0}, //Íê³É
+ {0, 1, 0, MSG_CMD_NET_MODE_SELECT, handle_net_mode_select_evt, 0, 0},//Íê³É
+ {0, 1, 0, MSG_CMD_NET_MODE_SET, handle_net_mode_set_evt, 0, 0},//Íê³É
+ {0, 1, 0, MSG_CMD_NET_REGISTER, handle_net_register_evt, 0, 0},
+ {0, 1, 0, MSG_CMD_NET_DEREGISTER, handle_net_deregister_evt, 0, 0},
+ {0, 1, 0, MSG_CMD_NET_GET_REGISTER_STATE, handle_get_sysinfo_evt, 0, 0}, //Íê³É
+ {0, 1, 0, MSG_CMD_GET_OPERATOR, handle_get_operator_evt, 0, 0}, //Íê³É
+ {0, 1, 0, MSG_CMD_GET_CSQ, handle_get_signal_power_evt, 0, 0}, //Íê³É
+ {0, 1, 0, MSG_CMD_GET_CELL_INFO, handle_get_cell_info_evt, 0, 0}, //Íê³É
+ //blÏìÓ¦ÏûÏ¢
+ {0, 1, 0, ZBL_NET_PLMN_LIST, handle_net_get_scan_result_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_PLMN_REELECT_FAIL, handle_net_get_scan_result_fail_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_SWITCH_ACC_TECH_CNF, handle_net_mode_select_result_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_DEREGISTER, handle_net_get_deregister_succ_result_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_DEREGISTER_FAIL, handle_net_get_deregister_fail_result_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_CUR_OPER_RESULT, handle_net_cur_oper_result_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_SIGNAL_POWER, handle_get_signal_power_result_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_SYSINFO_RESULT, handle_get_sysinfo_result_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_COPS_SET_RESULT, handle_set_cops_result_evt, 0, 0},
+ {0, 1, 0, ZBL_NET_MODE_SET_RESULT, handle_net_mode_set_result_evt, 0, 0},//Íê³É
+ {0, 1, 0, ZBL_CELL_DATA_IND, handle_net_get_cell_info_result_evt, 0, 0},//Íê³É
+};
+
+void sc_net_register_svr_event(void)
+{
+ sc_ipc_register_events(s_net_evts, sizeof(s_net_evts)/sizeof(s_net_evts[0]));
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_sim.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_sim.c
index a42594c..530f2a3 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_sim.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_sim.c
@@ -67,7 +67,7 @@
pmsg_rsp->msg_req = msg_rsp;
pmsg_rsp->data_len = datalen;
- sc_sim_print_msg(pmsg_rsp);
+ //sc_sim_print_msg(pmsg_rsp);
return pmsg_rsp;
}
@@ -87,7 +87,7 @@
pmsg_rsp->msg_req = msg_rsp;
pmsg_rsp->data_len = datalen;
- sc_sim_print_msg(pmsg_rsp);
+ //sc_sim_print_msg(pmsg_rsp);
return pmsg_rsp;
}
@@ -179,7 +179,8 @@
}
else
{
- work_mode = WORK_MODE_MODEM;
+ //work_mode = WORK_MODE_MODEM;
+ work_mode = WORK_MODE_AP;
}
dmp_net_prefer_plmn_list_get (0, work_mode);
return 0;
@@ -724,6 +725,26 @@
return 0;
}
+static int handle_net_prefer_plmn_list_fail_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblNetPreferPlmnList plmn_list = {0};
+ memcpy(&plmn_list, pmsg->data, pmsg->data_len);
+ sim_operator_list_t sim_operator_list = {0};
+ int i = 0;
+
+ sim_operator_list.len = 0;
+
+ printf("handle_net_prefer_plmn_list_fail_evt enter \n");
+
+ pmsg_rsp = sc_sim_rsp_msg_create_by_msgid(MSG_CMD_GET_OPERATORS_RSP, sizeof(sim_operator_list_t));
+
+ memcpy(pmsg_rsp->data, &sim_operator_list, pmsg_rsp->data_len);
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
void sc_sim_send_query_result(const sc_ipc_msg* const pmsg, char result)
{
sc_ipc_msg* pmsg_rsp = NULL;
@@ -780,7 +801,7 @@
{0, 1, 0, ZBL_PIN_REQ_PENDING, handle_pin_req_pending_evt, 0, 0},
{0, 1, 0, ZBL_USIM_NOT_INSERTED, handle_simcard_not_insert_evt, 0, 0},
{0, 1, 0, ZBL_NET_PREFER_PLMN_LIST, handle_net_prefer_plmn_list_evt, 0, 0},
-
+ {0, 1, 0, ZBL_NET_PREFER_PLMN_LIST_FAIL, handle_net_prefer_plmn_list_fail_evt, 0, 0},
};
void sc_sim_register_svr_event(void)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_sms.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_sms.c
new file mode 100755
index 0000000..1187b3f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/telecom_svr/telecom_server_sms.c
@@ -0,0 +1,510 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <time.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <ctype.h>
+#include "sc_sms_msg.h"
+#include "zbl_interface.h"
+#include "zbl_mm_interface.h"
+#include "zbl_ati_mm_msg.h"
+#include "zbl_sms_interface.h"
+#include "sc_ipc.h"
+#include <softap_api.h>
+
+#define SIM_PARAM_LEN 50
+#define SUCCESS 0
+#define FAILED 1
+#define GSM_7BIT 0x00
+#define GSM_8BIT 0x04
+#define GSM_UCS2 0x08
+
+void sc_sms_send_query_result(const sc_ipc_msg* const pmsg, char result);
+static void sc_sms_print_msg(const sc_ipc_msg* const pmsg);
+extern SINT32 dmp_ati_bl_sms_set_csca(UINT8 *sc_addr,WORKMODE cardMode);
+extern SINT32 dmp_ati_bl_sms_read_csca(UINT8 *sc_addr,WORKMODE cardMode);
+extern SINT32 dmp_sms_send( CONST ZblSmsData *data, UINT8 saveFlag, SMS_MUTINUM *pMutiNum, WORKMODE workMode );
+extern SINT32 dmp_sms_start_engine(WORKMODE workMode);
+extern SINT32 dmp_sms_close_engine(WORKMODE workMode);
+extern SINT32 dmp_sms_get_center_number(WORKMODE eWorkMode);
+extern SINT32 dmp_sms_set_center_number(UINT8* smsAddr, WORKMODE eWorkMode);
+extern SINT32 dmp_sms_send_usat_pdu(CONST ZblSmsData *data, ZblSmsSendModule module);
+extern SINT32 dmp_sms_send_pdu_msg(CONST ZblSmsPduData *data, WORKMODE eWorkMode);
+extern SINT32 tp_sc_unicode_to_gbk( CONST UINT16 *ucs2_ptr, SINT32 ucs2_len, CHAR *gbk_ptr, SINT32 gbk_len );
+extern SINT32 Decode7bit(CONST UINT8* pSrc, CHAR* pDst, SINT32 nSrcLength);
+
+static int g_client_fd = -1;
+
+static SINT32 Bytes2String(CONST UINT8* pSrc, CHAR* pDst, SINT32 nSrcLength)
+{
+ CONST CHAR tab[]="0123456789ABCDEF"; // 0x0-0xfµÄ×Ö·û²éÕÒ±í
+ SINT32 i = 0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i=0; i<nSrcLength; i++)
+ {
+ *pDst++ = tab[*pSrc >> 4]; // Êä³öµÍ4λ
+ *pDst++ = tab[*pSrc & 0x0f]; // Êä³ö¸ß4λ
+ pSrc++;
+ }
+
+ // Êä³ö×Ö·û´®¼Ó¸ö½áÊø·û
+ *pDst = '\0';
+
+ // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+ return nSrcLength * 2;
+}
+
+static sc_ipc_msg* sc_sms_rsp_msg_create(unsigned int msg_rsp, unsigned int datalen)
+{
+ sc_ipc_msg *pmsg_rsp = NULL;
+ pmsg_rsp = (sc_ipc_msg *)sc_ipc_msg_new(datalen);
+ if(NULL == pmsg_rsp) {
+ return NULL;
+ }
+ memset(pmsg_rsp, 0, sizeof(sc_ipc_msg) + datalen);
+
+ pmsg_rsp->type = 1;
+ pmsg_rsp->fd_cli = sc_ipc_get_self_fd();
+ pmsg_rsp->fd_svr = g_client_fd;
+ pmsg_rsp->token = 0;
+ pmsg_rsp->msg_req = msg_rsp;
+
+ pmsg_rsp->data_len = datalen;
+ //sc_sms_print_msg(pmsg_rsp);
+ return pmsg_rsp;
+}
+
+static sc_ipc_msg* sc_sms_rsp_msg_create_by_msgid(unsigned int msg_rsp, unsigned int datalen)
+{
+ sc_ipc_msg *pmsg_rsp = NULL;
+ pmsg_rsp = (sc_ipc_msg *)malloc(sizeof(sc_ipc_msg) + datalen);
+ if(NULL == pmsg_rsp) {
+ return NULL;
+ }
+ memset(pmsg_rsp, 0, sizeof(sc_ipc_msg) + datalen);
+
+ pmsg_rsp->type = 1;
+ pmsg_rsp->fd_cli = sc_ipc_get_self_fd();
+ pmsg_rsp->fd_svr = g_client_fd;
+ pmsg_rsp->token = 0;
+ pmsg_rsp->msg_req = msg_rsp;
+ pmsg_rsp->data_len = datalen;
+
+ //sc_sms_print_msg(pmsg_rsp);
+ return pmsg_rsp;
+}
+
+static int handle_connect_request_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_sms_connect_t *pconn_info = (sc_sms_connect_t *)pmsg->data;
+ sc_sms_common_res_t comm_res;
+ sc_ipc_msg *pmsg_rsp = sc_ipc_msg_new(sizeof(comm_res));
+ WORKMODE work_mode = WORK_MODE_AP;
+ char test[] = "text¸ñʽ¶ÌÐŲâÊÔ";
+ if(NULL == pmsg_rsp) {
+ assert(0);
+ return NULL;
+ }
+ if(0 == pconn_info->enable) {
+ g_client_fd = -1;
+ slog(TELSVR_PRINT, SLOG_NORMAL, "handle_connect_request_evt client(0x%x) request disconnect.\n", g_client_fd);
+ }
+ else {
+ g_client_fd = pmsg->fd_cli;
+ slog(TELSVR_PRINT, SLOG_NORMAL, "handle_connect_request_evt client(0x%x) request connect.\n", g_client_fd);
+ }
+ dmp_sms_start_engine(work_mode);
+ pmsg_rsp = sc_sms_rsp_msg_create(pmsg->msg_rsp, sizeof(comm_res));
+ comm_res.result = 0;
+ pmsg_rsp->data_len = sizeof(comm_res);
+ memcpy(pmsg_rsp->data, &comm_res, sizeof(comm_res));
+ printf("test text = %s \n", test);
+ for(int i=0; i<strlen(test)*2; i++)
+ {
+ printf("%x", test[i]);
+ }
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_disconnect_request_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_sms_common_res_t comm_res;
+ sc_ipc_msg *pmsg_rsp = sc_ipc_msg_new(sizeof(comm_res));
+ WORKMODE work_mode = WORK_MODE_AP;
+ if(NULL == pmsg_rsp) {
+ assert(0);
+ return NULL;
+ }
+
+ dmp_sms_close_engine(work_mode);
+ pmsg_rsp = sc_sms_rsp_msg_create(pmsg->msg_rsp, sizeof(comm_res));
+ comm_res.result = 0;
+ pmsg_rsp->data_len = sizeof(comm_res);
+ memcpy(pmsg_rsp->data, &comm_res, sizeof(comm_res));
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_sms_set_center_addr_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_sms_center_addr* psms_center_addr = NULL;
+ psms_center_addr = (sc_sms_center_addr*)pmsg->data;
+ WORKMODE work_mode = WORK_MODE_AP;
+ char sc_number[SC_SMS_MAX_ADDR_LENGTH+1] = {0};
+ strncpy(sc_number, psms_center_addr->addr, sizeof(sc_number)-1);
+ dmp_sms_set_center_number(sc_number, work_mode);
+ return 0;
+}
+
+static int handle_sms_get_center_addr_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ WORKMODE work_mode = WORK_MODE_AP;
+ printf("handle_sms_get_center_addr_evt enter!\n");
+ dmp_sms_get_center_number(work_mode);
+ return 0;
+}
+
+static int handle_sms_send_text_message_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sms_msg_info* psms_msginfo = NULL;
+ ZblSmsData sms_data = {0};
+ WORKMODE workMode = WORK_MODE_AP;
+ UINT8 saveFlag = 0;
+ SMS_MUTINUM sms_multinum = {0};
+ psms_msginfo = (sms_msg_info*)pmsg->data;
+ strncpy(sms_data.text_data.number, psms_msginfo->addr, sizeof(sms_data.text_data.number)-1);
+ strncpy(sms_data.text_data.text, psms_msginfo->content, sizeof(sms_data.text_data.text)-1);
+ sms_multinum.count = 1;
+ sms_multinum.index = 0;
+ sms_multinum.id = -1;
+ if(SMS_MSG_FORMAT_BINARY_DATA == psms_msginfo->format)
+ {
+ sms_multinum.format = GSM_8BIT;
+ }
+
+ printf("handle_sms_send_text_message_evt \n");
+ dmp_sms_send(&sms_data, saveFlag, &sms_multinum, workMode);
+ return 0;
+}
+
+static int handle_sms_send_text_message_async_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sms_op_result smsop_result = {0};
+ sms_msg_info* psms_msginfo = NULL;
+ ZblSmsData sms_data = {0};
+ WORKMODE workMode = WORK_MODE_AP;
+ UINT8 saveFlag = 0;
+ SMS_MUTINUM sms_multinum = {0};
+ int result = -1;
+ psms_msginfo = (sms_msg_info*)pmsg->data;
+ strncpy(sms_data.text_data.number, psms_msginfo->addr, sizeof(sms_data.text_data.number)-1);
+ strncpy(sms_data.text_data.text, psms_msginfo->content, sizeof(sms_data.text_data.text)-1);
+ sms_multinum.count = 1;
+ sms_multinum.index = 0;
+ sms_multinum.id = psms_msginfo->id;
+ result = dmp_sms_send(&sms_data, saveFlag, &sms_multinum, workMode);
+
+ return result;
+}
+
+static int handle_sms_send_pdu_message_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sms_msg_info* psms_msginfo = NULL;
+ ZblSmsPduData sms_data = {0};
+ WORKMODE workMode = WORK_MODE_AP;
+ UINT8 saveFlag = 0;
+ //SMS_MUTINUM sms_multinum = {0};
+ printf("handle_sms_send_pdu_message_evt \n");
+ psms_msginfo = (sms_msg_info*)pmsg->data;
+ printf("psms_msginfo->content_size=%d \n", psms_msginfo->content_size);
+ memcpy(sms_data.pdu_data, psms_msginfo->content, psms_msginfo->content_size);
+ sms_data.pdu_len = psms_msginfo->content_size;
+ //sms_multinum.count = 1;
+ //sms_multinum.index = 0;
+ sms_data.id = -1;
+ printf("dmp_sms_send_pdu_msg call \n");
+ dmp_sms_send_pdu_msg(&sms_data, workMode);
+ return 0;
+}
+
+static int handle_sms_send_pdu_message_async_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sms_msg_info* psms_msginfo = NULL;
+ ZblSmsPduData sms_data = {0};
+ WORKMODE workMode = WORK_MODE_AP;
+ UINT8 saveFlag = 0;
+ //SMS_MUTINUM sms_multinum = {0};
+ printf("handle_sms_send_pdu_message_async_evt \n");
+ psms_msginfo = (sms_msg_info*)pmsg->data;
+ printf("psms_msginfo->content_size=%d \n", psms_msginfo->content_size);
+ memcpy(sms_data.pdu_data, psms_msginfo->content, psms_msginfo->content_size);
+ sms_data.pdu_len = psms_msginfo->content_size;
+ //sms_multinum.count = 1;
+ //sms_multinum.index = 0;
+ sms_data.id = psms_msginfo->id;
+ printf("dmp_sms_send_pdu_msg call sms_data.id=%d\n", sms_data.id);
+ dmp_sms_send_pdu_msg(&sms_data, workMode);
+ return 0;
+}
+
+static int handle_sms_set_para_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblScParamInfo* psms_setpara_result = NULL;
+ sms_op_result smsop_result = {0};
+ psms_setpara_result = (ZBL_SMS_SET_PARA_RESULT*)pmsg->data;
+ if(psms_setpara_result->result == 0)
+ {
+ smsop_result.result = SUCCESS;
+ }
+ else
+ {
+ smsop_result.result = FAILED;
+ smsop_result.reason = psms_setpara_result->reason;
+ }
+
+ pmsg_rsp = sc_sms_rsp_msg_create(MSG_SMS_CMD_SET_CENTER_ADDR_RSP, sizeof(sms_op_result));
+
+ pmsg_rsp->data_len = sizeof(sms_op_result);
+ memcpy(pmsg_rsp->data, &smsop_result, sizeof(sms_op_result));
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_sms_get_sc_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblScParamInfo* psms_setpara_result = NULL;
+ WORKMODE work_mode = WORK_MODE_AP;
+ sc_sms_center_addr sms_center_addr = {0};
+ printf("handle_sms_get_sc_result_evt \n");
+ psms_setpara_result = (ZblScParamInfo*)pmsg->data;
+
+ if(0 == psms_setpara_result->result)
+ {
+ printf("result: success, addr=%s\n", psms_setpara_result->smsAddr);
+ sms_center_addr.result = SUCCESS;
+ strncpy(sms_center_addr.addr, psms_setpara_result->smsAddr, sizeof(sms_center_addr.addr)-1);
+ sms_center_addr.len = strlen(psms_setpara_result->smsAddr);
+ }
+ else
+ {
+ printf("result: failed\n");
+ sms_center_addr.result = FAILED;
+ sms_center_addr.reason = psms_setpara_result->reason;
+ }
+
+ pmsg_rsp = sc_sms_rsp_msg_create(MSG_SMS_CMD_GET_CENTER_ADDR_RSP, sizeof(sc_sms_center_addr));
+ pmsg_rsp->data_len = sizeof(sc_sms_center_addr);
+
+ memcpy(pmsg_rsp->data, &sms_center_addr, sizeof(sc_sms_center_addr));
+
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_sms_send_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZBL_SMS_SEND_RESULT *psms_send_result = NULL;
+ sms_op_result smsop_result = {0};
+ psms_send_result = (ZBL_SMS_SEND_RESULT*)pmsg->data;
+ printf("handle_sms_send_result_evt: sendResult=%d \n", psms_send_result->sendResult);
+ if(psms_send_result->sendResult == 0)
+ {
+ smsop_result.result = SUCCESS;
+ }
+ else
+ {
+ smsop_result.result = FAILED;
+ smsop_result.reason = psms_send_result->sendResult;
+ }
+ printf("handle_sms_send_result_evt: id=%d \n", psms_send_result->id);
+ smsop_result.id = psms_send_result->id;
+ if(-1 == psms_send_result->id) //ͬ²½ÇëÇó
+ {
+ pmsg_rsp = sc_sms_rsp_msg_create(MSG_SMS_CMD_SEND_MESSAGE_RSP, sizeof(sms_op_result));
+ }
+ else
+ {
+ pmsg_rsp = sc_sms_rsp_msg_create(MSG_SMS_CMD_SEND_MESSAGE_ASYNC_RSP, sizeof(sms_op_result));
+ }
+
+ pmsg_rsp->data_len = sizeof(sms_op_result);
+ memcpy(pmsg_rsp->data, &smsop_result, sizeof(sms_op_result));
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_sms_send_pdu_result_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZBL_SMS_SEND_RESULT *psms_send_result = NULL;
+ sms_op_result smsop_result = {0};
+ psms_send_result = (ZBL_SMS_SEND_RESULT*)pmsg->data;
+ printf("handle_sms_send_pdu_result_evt: sendResult=%d \n", psms_send_result->sendResult);
+ if(psms_send_result->sendResult == 0)
+ {
+ smsop_result.result = SUCCESS;
+ }
+ else
+ {
+ smsop_result.result = FAILED;
+ smsop_result.reason = psms_send_result->sendResult;
+ }
+ printf("handle_sms_send_pdu_result_evt: id=%d \n", psms_send_result->id);
+ smsop_result.id = psms_send_result->id;
+ if(-1 == psms_send_result->id) //ͬ²½ÇëÇó
+ {
+ printf("handle_sms_send_pdu_result_evt: send MSG_SMS_CMD_SEND_PDU_RSP \n");
+ pmsg_rsp = sc_sms_rsp_msg_create(MSG_SMS_CMD_SEND_PDU_RSP, sizeof(sms_op_result));
+ }
+ else
+ {
+ pmsg_rsp = sc_sms_rsp_msg_create(MSG_SMS_CMD_SEND_PDU_ASYNC_RSP, sizeof(sms_op_result));
+ }
+
+ pmsg_rsp->data_len = sizeof(sms_op_result);
+ memcpy(pmsg_rsp->data, &smsop_result, sizeof(sms_op_result));
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+void sc_sms_send_query_result(const sc_ipc_msg* const pmsg, char result)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ pmsg_rsp = sc_sms_rsp_msg_create(pmsg, sizeof(int));
+
+ pmsg_rsp->data_len = strlen(sizeof(int));
+ pmsg_rsp->data[0] = SUCCESS;
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+}
+
+static int handle_sms_new_pdu_ind_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblSmsIndPduData *pSmsPduData = NULL;
+ sms_pdu_ind_info pdu_ind_info = {0};
+ char strPdu[SC_SMS_MAX_PDU_LENGTH*2+1] = {0};
+ pSmsPduData = (ZblSmsIndPduData*)pmsg->data;
+ printf("handle_sms_new_pdu_ind_evt \n");
+ pdu_ind_info.format = SMS_PDU_FORMAT_GW_PP;
+ pdu_ind_info.total_length = pSmsPduData->iTotalLength;
+ pdu_ind_info.tpdu_length = pSmsPduData->iTpduLength;
+ memcpy(pdu_ind_info.pdu, pSmsPduData->strPdu, pSmsPduData->iTotalLength);
+ printf("total_length=%d, tpdu_length=%d\n", pdu_ind_info.total_length, pdu_ind_info.tpdu_length);
+ Bytes2String(pdu_ind_info.pdu, strPdu, pdu_ind_info.total_length);
+ printf("strPdu=%s \n", strPdu);
+ pmsg_rsp = sc_sms_rsp_msg_create(MSG_SMS_CMD_PDU_IND, sizeof(sms_pdu_ind_info));
+
+ pmsg_rsp->data_len = sizeof(sms_pdu_ind_info);
+ memcpy(pmsg_rsp->data, &pdu_ind_info, sizeof(sms_pdu_ind_info));
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static int handle_sms_new_text_ind_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sc_ipc_msg* pmsg_rsp = NULL;
+ ZblSmsIndTextData *pSmsTextData = NULL;
+ sms_text_ind_info text_ind_info = {0};
+ char smsText[SC_SMS_MAX_TEXT_LENGTH] = {0};
+ char gbkText[SC_SMS_MAX_TEXT_LENGTH] = {0};
+ char utf8[SC_SMS_MAX_TEXT_LENGTH] = {0};
+ int gbkLen = 0;
+ int i = 0;
+ pSmsTextData = (ZblSmsIndTextData*)pmsg->data;
+ printf("handle_sms_new_text_ind_evt \n");
+ strncpy(text_ind_info.oa, pSmsTextData->oa, sizeof(text_ind_info.oa)-1);
+ strncpy(text_ind_info.alpha, pSmsTextData->alpha, sizeof(text_ind_info.alpha)-1);
+ text_ind_info.tooa = pSmsTextData->tooa;
+ strncpy(text_ind_info.sca, pSmsTextData->sca, sizeof(text_ind_info.sca)-1);
+ text_ind_info.tosca = pSmsTextData->tosca;
+ text_ind_info.fo = pSmsTextData->fo;
+ text_ind_info.pid = pSmsTextData->pid;
+ text_ind_info.dcs = pSmsTextData->dcs;
+ text_ind_info.length = pSmsTextData->length;
+ text_ind_info.smRejected = pSmsTextData->smRejected;
+ memcpy(&text_ind_info.scts, &pSmsTextData->scts, sizeof(text_ind_info.scts));
+ memcpy(text_ind_info.text, pSmsTextData->text, pSmsTextData->length);
+ if(GSM_UCS2 == text_ind_info.dcs)
+ {
+ memcpy(smsText, text_ind_info.text, text_ind_info.length);
+ for ( i = 0; i < text_ind_info.length; i += 2 )
+ {
+ unsigned char bTemp = smsText[i];
+ smsText[i] = smsText[i + 1];
+ smsText[i + 1] = bTemp;
+ }
+
+ gbkLen = tp_sc_unicode_to_gbk((UINT16 *)smsText, text_ind_info.length, gbkText, 2*text_ind_info.length);
+ printf("gbkLen=%d, gbkText = %s \n", gbkLen, gbkText);
+ }
+ else if(GSM_7BIT == text_ind_info.dcs)
+ {
+ Decode7bit(text_ind_info.text, smsText, text_ind_info.length);
+ printf("smsText = %s \n", smsText);
+ }
+ pmsg_rsp = sc_sms_rsp_msg_create(MSG_SMS_CMD_TEXT_IND, sizeof(sms_text_ind_info));
+
+ pmsg_rsp->data_len = sizeof(sms_text_ind_info);
+ memcpy(pmsg_rsp->data, &text_ind_info, sizeof(sms_text_ind_info));
+
+ sc_ipc_send_msg(pmsg_rsp);
+ sc_ipc_msg_free(pmsg_rsp);
+ return 0;
+}
+
+static void sc_sms_print_msg(const sc_ipc_msg* const pmsg)
+{
+ printf("pmsg->fd_cli=%d \n", pmsg->fd_cli);
+ printf("pmsg->fd_svr=%d \n", pmsg->fd_svr);
+ printf("pmsg->msg_req=%d \n", pmsg->msg_req);
+ printf("pmsg->msg_rsp=%d \n", pmsg->msg_rsp);
+}
+
+static sc_ipc_event s_sms_evts[] =
+{
+ {0, 1, 0, MSG_SMS_CMD_CONN_REQ, handle_connect_request_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_DISCONN_REQ, handle_disconnect_request_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_SET_CENTER_ADDR_REQ, handle_sms_set_center_addr_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_GET_CENTER_ADDR_REQ, handle_sms_get_center_addr_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_SEND_MESSAGE_REQ, handle_sms_send_text_message_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_SEND_MESSAGE_ASYNC_REQ, handle_sms_send_text_message_async_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_SEND_PDU_REQ, handle_sms_send_pdu_message_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_SEND_PDU_ASYNC_REQ, handle_sms_send_pdu_message_async_evt, 0, 0},
+
+ //blÏìÓ¦ÃüÁî
+ {0, 1, 0, ZBL_TPM_SMS_SET_CENTER_NUMBER_RSP, handle_sms_set_para_result_evt, 0, 0},
+ {0, 1, 0, ZBL_TPM_SMS_GET_CENTER_NUMBER_RSP, handle_sms_get_sc_result_evt, 0, 0},
+ {0, 1, 0, ZBL_TPM_SMS_SEND_RESULT, handle_sms_send_result_evt, 0, 0},
+ {0, 1, 0, ZBL_TPM_SMS_SEND_PDU_RSP, handle_sms_send_pdu_result_evt, 0, 0},
+ {0, 1, 0, ZBL_TPM_SMS_NEW_PDU_MSG, handle_sms_new_pdu_ind_evt, 0, 0},
+ {0, 1, 0, ZBL_TPM_SMS_NEW_TEXT_MSG, handle_sms_new_text_ind_evt, 0, 0},
+};
+
+void sc_sms_register_svr_event(void)
+{
+ sc_ipc_register_events(s_sms_evts, sizeof(s_sms_evts)/sizeof(s_sms_evts[0]));
+ //dmp_net_active_usim(WORK_MODE_AP);
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/voiceipc_mainctrl/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/voiceipc_mainctrl/Makefile
index 4305fa5..cc81c90 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/voiceipc_mainctrl/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/voiceipc_mainctrl/Makefile
@@ -13,6 +13,9 @@
LDLIBS += -lpthread
LDLIBS += -lvoice -L$(LIB_DIR)/libvoice
+LDLIBS += -lnvram -L$(LIB_DIR)/libnvram
+LDLIBS += -lsoftap -L$(LIB_DIR)/libsoftap
+LDLIBS += -lsofttimer -L$(LIB_DIR)/libsofttimer
all: $(EXEC)
$(EXEC)all: $(EXEC)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/voiceipc_mainctrl/voiceipc_mainctrl.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/voiceipc_mainctrl/voiceipc_mainctrl.c
index afa5b38..dfcac14 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/voiceipc_mainctrl/voiceipc_mainctrl.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/voiceipc_mainctrl/voiceipc_mainctrl.c
@@ -7,79 +7,200 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include "voice_ipc.h"
+#include "softap_api.h"
+#include "pthread.h"
+
+int recv_msg_proc(MSG_BUF msg);
+void recv_voice_ipc(void);
+
+int recv_msg_proc(MSG_BUF msg)
+{
+ int ret = 0;
+ int module_id = MODULE_ID_VOICE_SERVER;
+ int dst_id = MODULE_ID_VOICE_CLIENT;
+ int *p_value = NULL;
+
+ switch(msg.usMsgCmd){
+ case MSG_CMD_SET_VOICE_DEVICE_MODE:
+ p_value = (int *)msg.aucDataBuf;
+ ret = ipc_set_voice_device_mode(*p_value);
+ //dst_id = MODULE_ID_SET_VOICE_DEVICE_MODE;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_GET_VOICE_DEVICE_MODE:
+ ret = ipc_get_voice_device_mode(p_value);
+ //dst_id = MODULE_ID_GET_VOICE_DEVICE_MODE;
+ //printf("%s: ipc_send_message start, msg.usMsgCmd=%d\n", __func__, msg.usMsgCmd);
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ //printf("%s: ipc_send_message end(%d)!\n", __func__, ret);
+ break;
+ case MSG_CMD_SET_RX_VOICE_VOL:
+ p_value = (int *)msg.aucDataBuf;
+ ret = ipc_set_rx_voice_vol(*p_value);
+ //dst_id = MODULE_ID_SET_RX_VOICE_VOL;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_GET_RX_VOICE_VOL:
+ ret = ipc_get_rx_voice_vol(p_value);
+ //dst_id = MODULE_ID_GET_RX_VOICE_VOL;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_SET_TX_VOICE_VOL:
+ p_value = (int *)msg.aucDataBuf;
+ ret = ipc_set_tx_voice_vol(*p_value);
+ //dst_id = MODULE_ID_SET_TX_VOICE_VOL;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_GET_TX_VOICE_VOL:
+ ret = ipc_get_tx_voice_vol(p_value);
+ //dst_id = MODULE_ID_GET_TX_VOICE_VOL;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_SET_TX_VOICE_MUTE_STATE:
+ p_value = (int *)msg.aucDataBuf;
+ ret = ipc_set_tx_voice_mute_state(*p_value);
+ //dst_id = MODULE_ID_SET_TX_VOICE_MUTE_STATE;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_GET_TX_VOICE_MUTE_STATE:
+ ret = ipc_get_tx_voice_mute_state(p_value);
+ //dst_id = MODULE_ID_GET_TX_VOICE_MUTE_STATE;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_SET_RX_VOICE_MUTE_STATE:
+ p_value = (int *)msg.aucDataBuf;
+ ret = ipc_set_rx_voice_mute_state(*p_value);
+ //dst_id = MODULE_ID_SET_RX_VOICE_MUTE_STATE;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_GET_RX_VOICE_MUTE_STATE:
+ ret = ipc_get_rx_voice_mute_state(p_value);
+ //dst_id = MODULE_ID_GET_RX_VOICE_MUTE_STATE;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_SET_LOOPBACK_ENABLE_STATE:
+ p_value = (int *)msg.aucDataBuf;
+ ret = ipc_set_loopback_enable_state(*p_value);
+ //dst_id = MODULE_ID_SET_LOOPBACK_ENABLE_STATE;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_GET_LOOPBACK_ENABLE_STATE:
+ ret = ipc_get_loopback_enable_state(p_value);
+ //dst_id = MODULE_ID_GET_LOOPBACK_ENABLE_STATE;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_AP_ALSA_VOICE_OPEN:
+ p_value = (int *)msg.aucDataBuf;
+ ret = ipc_ap_alsa_voice_open(*p_value);
+ //dst_id = MODULE_ID_AP_ALSA_VOICE_OPEN;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ case MSG_CMD_AP_ALSA_VOICE_CLOSE:
+ p_value = (int *)msg.aucDataBuf;
+ ret = ipc_ap_alsa_voice_close(*p_value);
+ //dst_id = MODULE_ID_AP_ALSA_VOICE_CLOSE;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ break;
+ default:
+ ret = -1;
+ ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
+ if(0 != ret){
+ printf("%s: send message error(%d)!\n", __func__, ret);
+ }
+ printf("%s: msg.usMsgCmd not support(%d)!\n", __func__, ret);
+ break;
+ }
+
+ return ret;
+}
+
+void recv_voice_ipc(void)
+{
+ int ret = 0;
+ int msg_handle = 0;
+ MSG_BUF msg;
+ LONG msg_size = sizeof(MSG_BUF)-sizeof(LONG);
+ int module_id = MODULE_ID_VOICE_SERVER;
+
+ //创建消息队列
+ msg_handle = msgget(module_id, IPC_CREAT|0600);
+
+ //接收消息
+ while(1)
+ {
+ memset(&msg, 0x00, sizeof(MSG_BUF));
+
+ //获取消息队列消息并处理
+ ret = msgrcv(msg_handle, &msg, msg_size, 0, 0);
+
+ if(0 > ret){
+ continue;
+ }
+
+ recv_msg_proc(msg);
+ }
+}
int main(int argc, char *argv)
{
int ret = 0;
-
+
+ //ipc通道初始化
ret = voice_ipc_init();
-
- if(ret < 0){
- printf("voice_ipc_init error!\n");
+ if(0 > ret){
+ printf("voice_ipc_init %s error!\n" , VOICE_IPC_CONTROL_CHANNEL);
return -1;
}
- printf("voice_ipc_init %s create success!\n", VOICE_IPC_CONTROL_CHANNEL);
+ //ipc初始化后,创建msg消息接收线程
+ pthread_t recv_thread_tid;
+ if(0 != pthread_create(&recv_thread_tid, NULL, (void *)recv_voice_ipc, NULL)){
+ printf("recv_cap_voice_alsa create error!\n");
+ }
-#if 0 //test
- int *func_id = (int *)argv[1];
-
- int dev_mode = 2;
- int *p_dev_mode = NULL;
- int rx_vol = 5;
- int *p_rx_vol = NULL;
- int tx_vol = 5;
- int *p_tx_vol = NULL;
- int tx_mute = 1;
- int *p_tx_mute = NULL;
- int rx_mute = 1;
- int *p_rx_mute = NULL;
- int enable = 1;
- int *p_enable = NULL;
-
- switch(*func_id){
- case 0:
- sc_audio_set_voice_device_mode(dev_mode);
- break;
- case 1:
- sc_audio_get_voice_device_mode(p_dev_mode);
- break;
- case 2:
- sc_audio_set_rx_voice_vol(rx_vol);
- break;
- case 3:
- sc_audio_get_rx_voice_vol(p_rx_vol);
- break;
- case 4:
- sc_audio_set_tx_voice_vol(tx_vol);
- break;
- case 5:
- sc_audio_get_tx_voice_vol(p_tx_vol);
- break;
- case 6:
- sc_audio_set_tx_voice_mute_state(tx_mute);
- break;
- case 7:
- sc_audio_get_tx_voice_mute_state(p_tx_mute);
- break;
- case 8:
- sc_audio_set_rx_voice_mute_state(rx_mute);
- break;
- case 9:
- sc_audio_get_rx_voice_mute_state(p_rx_mute);
- break;
- case 10:
- sc_audio_set_loopback_enable_state(enable);
- break;
- case 11:
- sc_audio_get_loopback_enable_state(p_enable);
- break;
- default:
- printf("test func_id(%c) error\n", *func_id);
- break;
- }
-#endif
-
+ sleep(4);
Voice_Ctrl_Rpmsg_Recv();
return 0;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_aplog_transfer.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_aplog_transfer.c
index a0c8f7c..de55480 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_aplog_transfer.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_aplog_transfer.c
@@ -19,6 +19,7 @@
#include <string.h>
#include <time.h>
+#include <sched.h>
#include <pthread.h>
#include <sys/prctl.h>
#include "cap_loginfo.h"
@@ -28,7 +29,7 @@
*/
#define SLEEP_TIME_20MS (20000000)
#define MAX_PACKET_LEN (0x10000)
-#define MAX_AP_PACKET_LEN (MAX_PACKET_LEN * 2)
+#define MAX_AP_PACKET_LEN (0x40000) /* 16KB--zsp 16KB--CAP kernel 16KB--CAP APP 128KB--PS, 80KB reserved for CAP kernel&&app print header */
/**
* Íⲿº¯ÊýÉùÃ÷
@@ -38,10 +39,73 @@
/**
* È«¾Ö±äÁ¿¶¨Òå
*/
-int aplog_fd = -1;
-const char *aplog_dev = "/dev/aplog";
+int aplog_fd = -1;
+const char *aplog_dev = "/dev/aplog";
static UINT8 gReadLogBuffer[MAX_AP_PACKET_LEN] = {0};
+/**
+ * @brief ˯Ãß»½ÐÑÏ̷߳¢À´µÄSIGALRMÐźŴ¦Àíº¯Êý
+ * @param[in] signoÐźÅÖµ
+ * @return void
+ * @note
+ * @see
+ */
+void cap_alarm_sighand(int signo)
+{
+ return;
+}
+
+/**
+ * @brief Ê¡µçLockËøÎļþ²Ù×÷½Ó¿Ú
+ * @param[in] filepath Îļþ·¾¶
+ * @param[in] setbuf ´ýдÈëµÄÖµ
+ * @return void
+ * @note
+ * @see
+ */
+static void write_lockfile(char *filepath, char *setbuf)
+{
+ int f = -1;
+ int len = 0;
+
+ f = open(filepath, O_RDWR);
+ if (f < 0)
+ {
+ perror("logctrl wakelock open error");
+ return;
+ }
+
+ len = strlen(setbuf);
+ if (write(f, setbuf, len) != len)
+ {
+ printf("logctrl wakelock write fail\n");
+ }
+ close(f);
+}
+
+/**
+ * @brief Ê¡µçLockËø,´Ëʱ²»½øÈëÊ¡µç״̬
+ * @param[in] void
+ * @return void
+ * @note
+ * @see
+ */
+static void WAKE_READ_LOCK()
+{
+ write_lockfile("/sys/power/wake_lock", "logctrl_lock");
+}
+
+/**
+ * @brief Ê¡µçLockËøÊÍ·Å,´ËʱÔÊÐí½øÈëÊ¡µç״̬
+ * @param[in] void
+ * @return void
+ * @note
+ * @see
+ */
+static void WAKE_READ_UNLOCK()
+{
+ write_lockfile("/sys/power/wake_unlock", "logctrl_lock");
+}
/**
* @brief ¶ÁÈ¡aplogÏ̺߳¯Êý£¬\n
@@ -55,30 +119,35 @@
{
int read_Len = -1;
const struct timespec nstime = {0, SLEEP_TIME_20MS};
-
+ struct sigaction actions;
+
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = cap_alarm_sighand;
+ sigaction(SIGALRM, &actions, NULL);
+
prctl(PR_SET_NAME, "cap_read_aplog");
-
+
+ WAKE_READ_LOCK();
while(1)
- {
+ {
read_Len = read(aplog_fd, gReadLogBuffer, MAX_AP_PACKET_LEN);
-
+
if(read_Len > 0)
{
send_log_out(gReadLogBuffer, read_Len);
// memset(gReadLogBuffer, 0, MAX_AP_PACKET_LEN);
}
- else if(read_Len == 0)
+ else
{
+ WAKE_READ_UNLOCK();
if(nanosleep(&nstime, NULL) < 0)
{
sleep(1);
}
+ WAKE_READ_LOCK();
}
- else
- {
- sleep(1);
- }
-
}
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_emmc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_fs.c
similarity index 76%
rename from cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_emmc.c
rename to cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_fs.c
index 8808260..10ddb3c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_emmc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_fs.c
@@ -1,6 +1,6 @@
/**
*
- * @file cap_logagt_emmc.c
+ * @file cap_logagt_fs.c
* @brief
* This file is part of ZCAT.
* Ó¦Óòãzlog_agent´¦ÀíÊý¾ÝÁ÷±£´æµ½FS
@@ -30,6 +30,8 @@
#include <pthread.h>
#include <sys/prctl.h>
#include <sys/statfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
#include "cap_loginfo.h"
#include "cfg_api.h"
@@ -41,7 +43,12 @@
#define ZCAT_RULE_MAX_SIZE (2048)
#define ZCAT_ONE_MB_SIZE (1024*1024)
#define ZCAT_SINGLE_LOG_SIZE (100*1024*1024)
-#define ZCAT_SHELL_CMD_SIZE (64)
+#define ZCAT_FILE_NAME_SIZE (64)
+
+#define ZCAP_IOCTL_TYPE 'T'
+#define ZCAP_IOCTL_RULE_START _IO(ZCAP_IOCTL_TYPE, 0)
+#define ZCAP_IOCTL_RULE_PROCESS _IOWR(ZCAP_IOCTL_TYPE, 1, UINT32)
+#define ZCAP_IOCTL_RULE_END _IO(ZCAP_IOCTL_TYPE, 2)
/*CAPFS ģʽ:±£´æµ½fs£¬¹ÒÔØÂ·¾¶ºÍ¹æÔò·¾¶ÓÉÓû§ÅäÖÃ*/
#define ZCAT_FS_CFG_LOG_PATH "/zcat"
@@ -49,7 +56,9 @@
#define MAX_STRING_LENGTH (256)
#define MAX_NVCFG_LOG_SIZE (1000)
#define MAX_NUMSIZE_STRING_LEN (16)
-
+#define MASK_SEC_TO_MSEC (1000)
+#define MASK_NSEC_TO_MSEC (1000000)
+#define MIN_VALUE(x, y) ((x) < (y) ? (x) : (y))
/**
* Íⲿ±äÁ¿º¯ÊýÉùÃ÷
*/
@@ -59,6 +68,12 @@
typedef struct
{
+ void *buf;
+ unsigned int len;
+}T_RULE_DATA;
+
+typedef struct
+{
char head1[16];
int heartbeat_pos;
int heartbeat_len;
@@ -115,17 +130,40 @@
}
/**
+ * @brief ½«NVÏîÖеÄ×Ö·û´®ÀàÐÍת»»ÎªÊýÖµÀàÐÍ
+ * @param[in] nvItem_str ×Ö·û´®ÀàÐÍ
+ * @return[out] error: -1.
+ * @note
+ * @see
+ */
+int strtol_check(const char *nvItem_str)
+{
+ int nvItem_val = 0;
+
+ errno = 0;
+ nvItem_val = (int)strtol(nvItem_str, NULL, 0);
+
+ if(errno == ERANGE)
+ {
+ printf("[zlog-agent] strtol error, return\n");
+ return -1;
+ }
+ return nvItem_val;
+}
+
+/**
* @brief ³õʼ»¯sd¿¨´ælogµÄÅäÖòÎÊý
* @return void
- * @note
- * zte_log_agent -t total_size -n max_lognum ÍÆ¼öʹÓÃ
- * else ·ÖÖ§:
- zte_log_agent : ĬÈÏÖµ(µ¥¸öZCAT_SINGLE_LOG_SIZE£¬Log¸öÊýZCAT_MAX_LOG_NUM)
+ * @note
+ * zlog_agent -t total_size -n max_lognum ÍÆ¼öʹÓÃ
+ * Óû§Î´Ð´Æô¶¯²ÎÊýʱ: ´ÓNV»ñȡ·¾¶ºÍÎļþ´óСÏÞÖÆ²ÎÊý
+ zlog_agent : ĬÈÏÖµ(µ¥¸öZCAT_SINGLE_LOG_SIZE£¬Log¸öÊýZCAT_MAX_LOG_NUM)
* @see
*/
static void init_cfg_param(int zcat_mode)
{
int nvint_size = 0;
+ int nvint_num = 0;
int max_logNum = 0;
UINT64 total_size = 0;
char nvstr_num[MAX_NUMSIZE_STRING_LEN] = {0};
@@ -134,16 +172,22 @@
if(gLogSaveParam.max_file_num == 0)
{
sc_cfg_get("zlog_num", nvstr_num, MAX_NUMSIZE_STRING_LEN - 1);
- gLogSaveParam.max_file_num = (int)strtol(nvstr_num, NULL, 0);
+ nvint_num = strtol_check(nvstr_num);
+
+ if (nvint_num > 0)
+ {
+ gLogSaveParam.max_file_num = MIN_VALUE(nvint_num, ZCAT_MAX_LOG_NUM);
+ }
}
if(gLogSaveParam.max_total_size == 0)
{
sc_cfg_get("zlog_size", nvstr_size, MAX_NUMSIZE_STRING_LEN - 1);
- nvint_size = (int)strtol(nvstr_size, NULL, 0);
+ nvint_size = strtol_check(nvstr_size);
+
if((nvint_size > 0) && (nvint_size < MAX_NVCFG_LOG_SIZE))
{
- gLogSaveParam.max_total_size = (UINT64)((nvint_size) * ZCAT_ONE_MB_SIZE);
+ gLogSaveParam.max_total_size = (UINT64)(nvint_size) * ZCAT_ONE_MB_SIZE;
}
}
max_logNum = gLogSaveParam.max_file_num;
@@ -174,38 +218,53 @@
* @note
* @see
*/
-static void zlogAgt_DelFile(char* dir_path)
+static void zlogAgt_DelFile(char *dir_path)
{
- DIR *p_dir = NULL;
- char *oldest_file = MAX_FILE_DATE_VALUE; /*ÈÕÆÚµÄ×î´óÖµ*/
- struct dirent *p_entry = NULL;
- char file_name[MAX_STRING_LENGTH] = {0};
+ int index = 0;
+ time_t creatime_min = 0;
+ time_t creatime_real = 0;
+ DIR *p_dir = NULL;
+ char *file_name = NULL;
+ struct dirent *p_entry = NULL;
+ struct stat t_stat = {0};
+ char delfile[MAX_STRING_LENGTH] = {0};
p_dir = opendir(dir_path);
- if(p_dir)
+ file_name = (char *)malloc(MAX_STRING_LENGTH);
+ if (file_name == NULL )
{
+ printf("[zlog-agent] No memory, return\n");
+ return;
+ }
+
+ if(p_dir)
+ {
while ((p_entry = readdir(p_dir)) != NULL)
{
if (strncmp(p_entry->d_name, ".", 1) == 0)
continue;
- if (strcmp(p_entry->d_name, oldest_file) < 0)
- {
- strncpy(oldest_file, p_entry->d_name, 64 - 1);
+ snprintf(file_name, MAX_STRING_LENGTH - 1, "%s/%s", dir_path, p_entry->d_name);
+
+ stat(file_name, &t_stat);
+ creatime_real = t_stat.st_atim.tv_sec * MASK_SEC_TO_MSEC + (time_t)(t_stat.st_atim.tv_nsec / MASK_NSEC_TO_MSEC);
+
+ if ((index ++ == 0) || (creatime_real < creatime_min))
+ {
+ creatime_min = creatime_real;
+ strncpy(delfile, file_name, MAX_STRING_LENGTH - 1);
}
}
-
- snprintf(file_name, MAX_STRING_LENGTH, "%s/%s", dir_path, oldest_file);
- if(remove(file_name) != 0)
+ if(remove(delfile) != 0)
{
- printf("[zlog-agent] remove %s fail!errno=%d(%s)\n",file_name,errno,strerror(errno));
+ printf("[zlog-agent] remove %s fail! errno=%d(%s)\n",delfile, errno, strerror(errno));
}
closedir(p_dir);
}
+ free(file_name);
}
-
/**
* @brief ÔÚdir_pathĿ¼Ï´ò¿ªlogÊä³öÎļþ²¢·µ»ØÎļþ¾ä±ú,\n
* ÒÔµ±Ç°Ê±¼äΪÎļþÃû£¬´´½¨logÊä³öÎļþ¡£
@@ -218,13 +277,15 @@
static int open_log_file(T_LOG_FS_PARA *logParam)
{
int fd = -1;
- struct tm *cur_time;
time_t now;
+ struct tm *cur_time;
+ BOOL space_limit = FALSE;
+ BOOL flcnt_limit = FALSE;
char file_name[MAX_STRING_LENGTH] = {0};
if (logParam == NULL)
return -1;
-
+
now = time(NULL);
cur_time = localtime(&now);
@@ -236,15 +297,17 @@
if (logParam->log_overwrite)
{
logParam->file_counts++;
-
struct statfs diskInfo;
statfs(gLogSaveParam.log_dir, &diskInfo);
+ flcnt_limit = (logParam->file_counts) > (logParam->max_file_num);
+ space_limit = (diskInfo.f_bfree * diskInfo.f_bsize) < logParam->free_space_limit;
- if ((diskInfo.f_bfree * diskInfo.f_bsize < logParam->free_space_limit)
- || (logParam->file_counts > logParam->max_file_num))
+ /*We Can print the reason when the earliest logfile is deleted*/
+ if (flcnt_limit || space_limit)
{
- zlogAgt_DelFile(logParam->log_dir);
- logParam->file_counts--;
+ zlogAgt_DelFile(logParam->log_dir);
+ logParam->file_counts--;
+ //printf("[zlog-agent]Delete the earliest log: filenum limit %d, space limit %d, file_num is %d\n", flcnt_limit, space_limit, logParam->file_counts);
}
}
@@ -327,7 +390,7 @@
}
if (fnum_flag^tsize_flag)
{
- printf("param error: \"log_agent -t 100 -n 10\" or \"log_agent\" !");
+ printf("param error: \"zlog_agent -t 100 -n 10\" or \"zlog_agent\" !");
return -1;
}
else
@@ -367,7 +430,7 @@
if (access(glogFsPath, R_OK|W_OK) < 0)
{
sc_cfg_get("zlog_path", log_path, logdir_size);
- printf("[zlog-agent]Fs path error, errno=%d\n", errno);
+ printf("[zlog-agent]Fs path error, errno=%d\n", errno);
}
else
{
@@ -386,13 +449,15 @@
printf("[zlog-agent]log_path: %s, rule_path %s\n", log_path, rule_file);
- if(test_dir_exist(log_path) < 0)//´´½¨ÈÕÖ¾Îļþ¼Ð
+ /*´´½¨ÈÕÖ¾Îļþ¼Ð*/
+ if(test_dir_exist(log_path) < 0)
{
printf("[zlog-agent] test %s dir exist failed. \n", gLogSaveParam.log_dir);
return -1;
}
- gLogSaveParam.output_fd = open_log_file(&gLogSaveParam);//´ò¿ªÈÕÖ¾Îļþ
+ /*´ò¿ªÈÕÖ¾Îļþ*/
+ gLogSaveParam.output_fd = open_log_file(&gLogSaveParam);
if (gLogSaveParam.output_fd == -1)
{
printf("[zlog-agent] failed to open log file!\n");
@@ -402,34 +467,36 @@
}
/**
- * @brief bufferÄÚÈÝдÈëµ½EMMC
+ * @brief bufferÄÚÈÝдÈëµ½Îļþϵͳ·¾¶ÖÐ
* @param[in] buffer ´ýдÈëÊý¾ÝÖ¸Õë
* @param[in] buffer_len ´ýдÈëÊý¾Ý³¤¶È
* @return ʵ¼ÊдÈëµÄ³¤¶È
* @note
* @see
*/
-int send_message_to_emmc(unsigned char* buf, int len)
+int send_message_to_fs(unsigned char* buf, int len)
{
- int write_len = 0;
- int output_fd = 0;
- T_LOG_FS_PARA* para_emmc = NULL;
+ int write_len = 0;
+ int output_fd = 0;
+ T_LOG_FS_PARA *msg_para = NULL;
+
output_fd = gLogSaveParam.output_fd;
- para_emmc = &gLogSaveParam;
- para_emmc->file_size += len;
+ msg_para = &gLogSaveParam;
+
+ msg_para->file_size += len;
/* Èç¹ûÎļþ´óС´ïµ½×î´óÎļþ³ß´ç£¬Ôòн¨Ò»¸öÎļþ*/
- if (para_emmc->file_size > para_emmc->max_file_size)
+ if (msg_para->file_size > msg_para->max_file_size)
{
close(output_fd);
- output_fd = open_log_file(para_emmc);
+ output_fd = open_log_file(msg_para);
if (output_fd == -1)
{
return -1;
}
- para_emmc->output_fd = output_fd;
- para_emmc->file_size = len;
+ msg_para->output_fd = output_fd;
+ msg_para->file_size = len;
}
write_len = write(output_fd, buf, len);
@@ -460,6 +527,7 @@
int read_len = 0;
int next_buf_len = 0;
char *read_buf = NULL;
+ T_RULE_DATA rule_cfg;
if(lseek(fd, offset, SEEK_SET) == -1)
{
@@ -475,9 +543,12 @@
}
left_len = length;
- next_buf_len = sizeof(read_buf) < left_len ? sizeof(read_buf) : left_len;
+ next_buf_len = left_len > ZCAT_RULE_MAX_SIZE ? ZCAT_RULE_MAX_SIZE : left_len;
while((read_len = read(fd, read_buf, next_buf_len)) > 0)
{
+ rule_cfg.buf = read_buf;
+ rule_cfg.len = read_len;
+ ioctl(aplog_fd, ZCAP_IOCTL_RULE_PROCESS, &rule_cfg);
int write_len = write(aplog_fd, read_buf, read_len);
if (write_len != read_len)
{
@@ -486,7 +557,7 @@
return -1;
}
left_len -= read_len;
- next_buf_len = sizeof(read_buf) < left_len ? sizeof(read_buf) : left_len;
+ next_buf_len = left_len > ZCAT_RULE_MAX_SIZE ? ZCAT_RULE_MAX_SIZE : left_len;
}
free(read_buf);
return 0;
@@ -534,7 +605,7 @@
printf("[zlog-agent] check_rule, read heartbeat data error.\n");
return -1;
}
-
+
return len;
}
@@ -585,7 +656,9 @@
return;
}
printf("[zlog-agent] check rule success, len is %d\n", rule_len);
-
+
+ ioctl(aplog_fd, ZCAP_IOCTL_RULE_START, 0);
+
/*·¢ËÍcp¹æÔò*/
ret = send_rules_to_ap(rule_fd, rule_info.rule_pos, rule_info.rule_len);
@@ -599,13 +672,13 @@
rule_info.ap_rule_len,
rule_info.ap_rule_pos);
+ ioctl(aplog_fd, ZCAP_IOCTL_RULE_END, 0);
close(rule_fd);
bSendRule = TRUE;
}
}
}
-
/**
* @brief ³õʼ»¯FSģʽ£¬´´½¨¹æÔòºÍÐÄÌø·¢ËÍÏß³Ì.
* @param[in] void
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_main.c
index a0b12e1..7f69c13 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_main.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_main.c
@@ -38,10 +38,14 @@
/**
* Íⲿ±äÁ¿º¯ÊýÉùÃ÷
*/
-extern int aplog_fd;
+extern int aplog_fd;
+extern int g_wakefd;
+
extern const char *aplog_dev;
-extern pthread_t cap_heartbeat_thread;
+extern pthread_t cap_heartbeat_thread;
extern void *cap_read_aplog(void* args);
+extern void *cap_open_wakeup(void* args);
+
extern int zLogAgt_initCapTools();
extern int zLogAgt_initFsMode();
extern int zLogAgt_argvProc(int argc, char *argv[]);
@@ -50,10 +54,11 @@
* È«¾Ö±äÁ¿¶¨Òå
*/
pthread_t read_aplog_thread;
+pthread_t icp_wakeup_thread;
+
E_ZCAT_MODE g_log_dir = ZCAT_MODE_AP_USB;
E_ZCAT_STATE g_log_state = ZCAT_STATE_INIT;
-
/**
* @brief Logģʽ³õʼ»¯
* @param[in] void
@@ -108,6 +113,10 @@
if(ret != 0) {
goto __exit;
}
+ ret = pthread_create(&icp_wakeup_thread, NULL, cap_open_wakeup, NULL);
+ if(ret != 0) {
+ goto __exit;
+ }
}
else
{
@@ -125,9 +134,15 @@
if(read_aplog_thread > 0)
pthread_join(read_aplog_thread, NULL);
+ if(icp_wakeup_thread > 0)
+ pthread_join(icp_wakeup_thread, NULL);
+
if(aplog_fd >= 0)
close(aplog_fd);
+ if(g_wakefd >= 0)
+ close(g_wakefd);
+
printf("[zlog-agent] log_agent exit.\n");
return 0;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_tool.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_tool.c
index 1a4abac..3e18dd3 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_tool.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_tool.c
@@ -49,8 +49,7 @@
extern E_ZCAT_MODE g_log_dir;
extern E_ZCAT_STATE g_log_state;
-extern int send_message_to_client(unsigned char* buf, int len);
-extern int send_message_to_emmc(unsigned char* buf, int len);
+extern int send_message_to_fs(unsigned char* buf, int len);
extern int init_fs_log_dir();
extern BOOL hdlc_encode(T_HDLC_BUFFER_TYPE *dest, const T_HDLC_BUFFER_TYPE *src);
extern BOOL hdlc_decode(T_HDLC_BUFFER_TYPE *dest, T_HDLC_BUFFER_TYPE *src);
@@ -170,7 +169,7 @@
if(bSDSet == TRUE)
{
pthread_mutex_lock(&mutex_EMMC);
- send_message_to_emmc(buf, len);
+ send_message_to_fs(buf, len);
pthread_mutex_unlock(&mutex_EMMC);
}
}
@@ -356,7 +355,7 @@
{
printf("[zcat] malloc buffer failed!\n");
return -1;
- }
+ }
apHeader = (T_ZCAT_APLOG_HEADER *)(newBuffer + sizeof(T_ZCAT_HEADER) + sizeof(T_COMM_TYPE));
#if 0
if (apHeader == NULL)
@@ -366,14 +365,13 @@
}
else
#endif
- {
+ {
apHeader->priority = priority;
apHeader->mod = mod;
apHeader->len = len;
memcpy(apHeader + 1, buf, len);
return zCatAgt_SendMsg(cmd_code, (unsigned char *)apHeader, sizeof(T_ZCAT_APLOG_HEADER) + len);
- }
-
+ }
}
/**
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_wakeup.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_wakeup.c
new file mode 100755
index 0000000..b453f58
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_logagt_wakeup.c
@@ -0,0 +1,78 @@
+/**
+ *
+ * @file cap_logagt_wakeup.c
+ * @brief
+ * This file is part of ZCAT.
+ * Ó¦Óò㴦ÀílogwakeupÉ豸
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2023 Sanechips Technology Co., Ltd.
+ * @warning
+ * @post
+ * @date 2023/03/23
+ * @version 1.1
+ * @par
+ * note This program Capture M0's icp msg and wake up logread thread.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+#include <time.h>
+#include <pthread.h>
+#include <sys/prctl.h>
+#include "cap_loginfo.h"
+
+/**
+ * ºê¶¨Òå
+ */
+#define SLEEP_TIME_20MS (20000000)
+#define MAX_CAP_PACKET_LEN (0x20)
+
+/**
+ * Íⲿ±äÁ¿ÉùÃ÷
+ */
+extern pthread_t read_aplog_thread;
+
+/**
+ * È«¾Ö±äÁ¿¶¨Òå
+ */
+int g_wakefd = -1;
+const char *wakeup_dev = "/dev/logwakeup";
+static UINT8 gReadLogBuffer[MAX_CAP_PACKET_LEN] = {0};
+
+/**
+ * @brief ´ò¿ªwakeuplogÏ̺߳¯Êý£¬\n
+ * wakeuplogÉ豸ÖÐÊÕµ½M0µÄºË¼ä»½ÐÑÏûÏ¢£¬»½ÐѶÁÏ̱߳£´æLog
+ * @param[in] args Ï̺߳¯Êý²ÎÊý
+ * @return void
+ * @note
+ * @see
+ */
+void *cap_open_wakeup(void* args)
+{
+ int read_Len = -1;
+ const struct timespec nstime = {0, SLEEP_TIME_20MS};
+ int i=0;
+ prctl(PR_SET_NAME, "cap_open_wakeup");
+ printf("[zlog-agent] cap_open_wakeup enter\n");
+
+ g_wakefd = open(wakeup_dev, O_RDWR);
+ if (g_wakefd < 0)
+ {
+ printf("[zlog-agent] open logwakeup file errno %d, %s\n", errno, strerror(errno));
+ return;
+ }
+
+ while(1)
+ {
+ read_Len = read(g_wakefd, gReadLogBuffer, MAX_CAP_PACKET_LEN);
+ if (read_Len > 0)
+ printf("[zlog-agent]cap_open_wakeup read len %d\n", read_Len);
+ pthread_kill(read_aplog_thread, SIGALRM);
+ }
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_loginfo.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_loginfo.h
index 4409f3c..af338c9 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_loginfo.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zlog_agent/cap_loginfo.h
@@ -37,6 +37,9 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <dirent.h>
+#include <signal.h>
+#include <string.h>
+#include <time.h>
/********************************************
* receive result
@@ -71,7 +74,6 @@
#define DIR_LOG_USB_AP_VALUE (0x04)
#define MAX_STRING_LENGTH (256)
-#define MAX_FILE_DATE_VALUE "99999999999999"
typedef int BOOL;
typedef void VOID;
@@ -158,8 +160,10 @@
ZCAT_DIAG_REPORT = 6,
ZCAT_DIAG_NULL, //ֻռһ룬²»Ê¹Óã¬Ê¹ÓëPC¶ÔÆë
- ZCAT_AP_KERNEL_LOG = 8,
- ZCAT_AP_APP_LOG = 9,
+ ZCAT_AP_KERNEL_LOG = 8,
+ ZCAT_AP_APP_LOG = 9,
+ ZCAT_AP2_KERNEL_LOG = 13, // ap kernel log
+ ZCAT_AP2_APP_LOG = 14, // ap app log
ZCAT_CMDCODE_MAX
} T_ZCAT_CMDCODE;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_debug/zxic_debug.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_debug/zxic_debug.c
index 2d52171..7247e6f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_debug/zxic_debug.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_debug/zxic_debug.c
@@ -20,6 +20,7 @@
#define DEBUG_INFO_DEFAULT_TOTAL_FILE_SIZE (1024 * 1024)
#define DEBUG_INFO_TOTAL_FILE_SIZE_MAX (1024 * 1024 * 1024)
#define DEBUG_INFO_FILE_NUM_MAX (10)
+#define DEBUG_INFO_FILE_NUM_MIN (2)
#define DEBUG_INFO_FILE_NUM (2)
#define DEBUG_INFO_READ_BUFFFER_SIZE (9 * 1024)
#define DEBUG_INFO_FOLDER_PATH_LENGTH_MAX (256)
@@ -34,9 +35,6 @@
/*******************************************************************************
* 全局变量定义 *
*******************************************************************************/
-// static int g_dev_fd = -1;
-// static int g_file_fd[DEBUG_INFO_FILE_NUM] = {-1, -1};
-// static char *g_save_file_name[DEBUG_INFO_FILE_NUM] = {DEBUG_INFO_FILE1_NAME, DEBUG_INFO_FILE2_NAME};
static int g_file_num = DEBUG_INFO_FILE_NUM;
static int g_file_size_total = DEBUG_INFO_DEFAULT_TOTAL_FILE_SIZE;
static int g_file_size_single = DEBUG_INFO_DEFAULT_TOTAL_FILE_SIZE / DEBUG_INFO_FILE_NUM;
@@ -57,9 +55,9 @@
typedef struct
{
- unsigned int head; /* 0x010a0a0a */
- unsigned int time; /* time()函数获取 */
- unsigned int total_len; /* 数据内容长度 */
+ unsigned int head; /* 0x010a0a0a */
+ unsigned int total_len; /* 数据内容长度 */
+ long long time; /* time()函数获取 */
} T_SAVE_FILE_DATA;
/*******************************************************************************
@@ -394,7 +392,11 @@
if(strlen(file_num))
{
g_file_num = atoi(file_num);
- if(g_file_num > DEBUG_INFO_FILE_NUM_MAX)
+ if(g_file_num < DEBUG_INFO_FILE_NUM_MIN)
+ {
+ g_file_num = DEBUG_INFO_FILE_NUM_MIN;
+ }
+ else if(g_file_num > DEBUG_INFO_FILE_NUM_MAX)
{
g_file_num = DEBUG_INFO_FILE_NUM_MAX;
}
@@ -479,7 +481,11 @@
return ret;
case 'n':
g_file_num = atoi(optarg);
- if(g_file_num > DEBUG_INFO_FILE_NUM_MAX)
+ if(g_file_num < DEBUG_INFO_FILE_NUM_MIN)
+ {
+ g_file_num = DEBUG_INFO_FILE_NUM_MIN;
+ }
+ else if(g_file_num > DEBUG_INFO_FILE_NUM_MAX)
{
g_file_num = DEBUG_INFO_FILE_NUM_MAX;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_ramdump/makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_ramdump/makefile
new file mode 100755
index 0000000..17155d8
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_ramdump/makefile
@@ -0,0 +1,28 @@
+#*******************************************************************************
+# include build/common makefile
+#*******************************************************************************
+
+##############USER COMIZE BEGIN################
+EXEC = zxic_ramdump
+OBJS = ramdump_app.o
+
+CFLAGS += -I$(APP_DIR)/include
+CFLAGS += -g -Werror=implicit-function-declaration
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /sbin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_ramdump/ramdump_app.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_ramdump/ramdump_app.c
new file mode 100755
index 0000000..ca0b0ff
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/zxic_ramdump/ramdump_app.c
@@ -0,0 +1,263 @@
+/*******************************************************************************
+* °æÈ¨ËùÓÐ (C)2016, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ: ramdump_app.c
+* Îļþ±êʶ: ramdump_app.c
+* ÄÚÈÝÕªÒª: ramdump capÓû§µ¼³öemmc´æ´¢ÐÅÏ¢
+*
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* ------------------------------------------------------------------------------
+* 2019/10/10 V1.0 Create 00130574 ´´½¨
+*
+*******************************************************************************/
+
+/*******************************************************************************
+* Í·Îļþ *
+*******************************************************************************/
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include<time.h>
+
+/*******************************************************************************
+* ³£Á¿¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* ºê¶¨Òå *
+*******************************************************************************/
+#define RAMDUMP_DEVICE_NAME "/dev/ramdump_device"
+#define RAMDUMP_DEFAULT_PATH "/mnt/userdata/ramdump_file"
+
+#define RAMDUMP_TRANS_DEVICE_LEN (0x20000)
+#define RAMDUMP_RAMCONF_FILENAME_MAXLEN (32)
+#define RAMDUMP_FILE_NUM_MAX (64)
+#define RAMDUMP_FILE_PATH_LEN (128)
+#define RAMDUMP_DATA_ALIGN_SIZE (512)
+#define RAMDUMP_DEVICE_BUF_LEN (0x20000)
+
+#define roundup(x, y) ( \
+{ \
+ typeof(y) __y = y; \
+ (((x) + (__y - 1)) / __y) * __y; \
+} \
+)
+
+/*******************************************************************************
+* Êý¾ÝÀàÐͶ¨Òå *
+*******************************************************************************/
+typedef struct
+{
+ unsigned int magic;
+ char file_name[RAMDUMP_RAMCONF_FILENAME_MAXLEN];
+ unsigned int offset;
+ unsigned int size;
+}ramdump_device_t;
+
+typedef struct
+{
+ unsigned int magic;
+ unsigned int file_num;
+ ramdump_device_t file_fp[RAMDUMP_FILE_NUM_MAX];
+}ramdump_file_t;
+
+/*******************************************************************************
+* º¯ÊýÉùÃ÷ *
+*******************************************************************************/
+
+/*******************************************************************************
+* ¾Ö²¿¾²Ì¬±äÁ¿¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* È«¾Ö±äÁ¿¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* ¾Ö²¿º¯ÊýʵÏÖ *
+*******************************************************************************/
+static int get_time_str(char *buf, size_t size)
+{
+ struct tm cur_tm;
+ time_t now = time(NULL);
+ if (NULL==buf || size<=0)
+ return -1;
+ localtime_r(&now, &cur_tm);
+ strftime(buf, size, "%Y_%m%d_%H%M%S", &cur_tm);
+ printf("%s %s\n", __FUNCTION__, buf);
+ return 0;
+}
+
+static int ramdump_fold_name(char *ramdump_path, size_t size, char *file_path, char *time_buffer)
+{
+ DIR *pdir = NULL;
+ int ret = -1;
+
+ if (ramdump_path == NULL || size <= 0 || time_buffer == NULL)
+ return -1;
+
+ if ((pdir = opendir(file_path)) == NULL) {
+ ret = mkdir(file_path, S_IRWXU);
+ if (ret < 0) {
+ printf("%s create fold %s failed (%s)", __FUNCTION__, file_path, strerror(errno));
+ return -1;
+ }
+ }
+ if (pdir != NULL)
+ closedir(pdir);
+
+ strcat(ramdump_path, file_path);
+ strcat(ramdump_path, "/");
+ strcat(ramdump_path, time_buffer);
+ strcat(ramdump_path, ".bin");
+
+ printf("%s %s\n", __FUNCTION__, ramdump_path);
+ return 0;
+}
+
+static int ramdump_dev_open(void)
+{
+ int fd;
+
+ fd = open(RAMDUMP_DEVICE_NAME, O_RDWR);
+ if (fd < 0)
+ {
+ printf("%s : open device error\n", __func__);
+ return -1;
+ }
+
+ printf("%s : ok\n", __func__);
+ return fd;
+}
+
+static ssize_t ramdump_dev_read(int fd, unsigned char *buf, size_t size)
+{
+ size_t ret = 0;
+ size_t count = 0;
+
+ do
+ {
+ count = read(fd, buf, size);
+ if (size <= count)
+ {
+ ret += count;
+ break;
+ }
+ buf += count;
+ size -= count;
+ ret += count;
+ }while (size > 0);
+
+ printf("cap ramdump read data size is 0x%x\n", ret);
+ return ret;
+}
+
+static ssize_t ramdump_dev_write(int fd, unsigned char *buf, size_t size)
+{
+ size_t ret = 0;
+ size_t count = 0;
+
+ do
+ {
+ count = write(fd, buf, size);
+ if (size <= count)
+ {
+ ret += count;
+ break;
+ }
+ buf += count;
+ size -= count;
+ ret += count;
+ }while (size > 0);
+
+ return ret;
+}
+
+/*******************************************************************************
+* È«¾Öº¯ÊýʵÏÖ *
+*******************************************************************************/
+int main(int argc, char **argv)
+{
+ int size = 0;
+ int ret = -1;
+ int opt = 0;
+ FILE *fp = NULL;
+ int file_num = 0;
+ size_t file_size = 0;
+ int ramdump_dev_fd = -1;
+ ramdump_file_t *file_fp =NULL;
+ unsigned char *ramdump_buf = NULL;
+ char time_str[64] = {0};
+ char file_path[RAMDUMP_FILE_PATH_LEN] = {0};
+ unsigned int file_align = roundup(sizeof(ramdump_file_t), RAMDUMP_DATA_ALIGN_SIZE);
+
+ ramdump_dev_fd = ramdump_dev_open();
+ if (ramdump_dev_fd < 0)
+ {
+ close(ramdump_dev_fd);
+ return -1;
+ }
+
+ ramdump_buf = malloc(RAMDUMP_TRANS_DEVICE_LEN);
+ while((opt = getopt(argc, argv, "p:")) != -1){
+ switch(opt){
+ case 'p':
+ {
+ ret = ramdump_fold_name(file_path, RAMDUMP_FILE_PATH_LEN, optarg, "ramdump");
+ break;
+ }
+ case '?':
+ {
+ printf("invailed arguments!\n");
+ close(ramdump_dev_fd);
+ free(ramdump_buf);
+ return -1;
+ }
+ }
+ }
+
+ if (file_path[0] == '\0')
+ ret = ramdump_fold_name(file_path, RAMDUMP_FILE_PATH_LEN, RAMDUMP_DEFAULT_PATH, "ramdump");
+ printf("cap ramdump file name is %s\n", file_path);
+ fp = fopen(file_path, "wb+");
+ if(!fp)
+ {
+ printf("cap ramdump user open file failed,fp is %d!\n", fp);
+ close(ramdump_dev_fd);
+ free(ramdump_buf);
+ return -1;
+ }
+
+ /*read data from device*/
+ ramdump_dev_read(ramdump_dev_fd, ramdump_buf, file_align);
+ file_fp = (ramdump_file_t *)ramdump_buf;
+ file_num = file_fp->file_num;
+ file_size = file_fp->file_fp[file_num - 1].offset + file_fp->file_fp[file_num - 1].size;
+ file_size -= file_align;
+ fwrite(ramdump_buf, 1, file_align, fp);
+ while(file_size > 0)
+ {
+ if (file_size > RAMDUMP_TRANS_DEVICE_LEN)
+ size = RAMDUMP_TRANS_DEVICE_LEN;
+ else
+ size = file_size;
+ ramdump_dev_read(ramdump_dev_fd, ramdump_buf, size);
+ fwrite(ramdump_buf, 1, size, fp);
+ file_size -= size;
+ }
+ fclose(fp);
+ close(ramdump_dev_fd);
+ free(ramdump_buf);
+ return 0;
+}
+
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/Makefile
index aa2c7a0..b606c71 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/Makefile
@@ -12,9 +12,9 @@
#CFLAGS += -I$(APP_DIR)/at_ctl/inc
#CFLAGS += -I$(LIB_DIR)/libatutils
-CFLAGS += -I$(LINUX_DIR)/include/uapi
-CFLAGS += -I$(LINUX_DIR)/include
-CFLAGS += -I${BSPDIR}/zxic_code/linux-5.10/include/uapi
+#CFLAGS += -I$(LINUX_DIR)/include/uapi
+#CFLAGS += -I$(LINUX_DIR)/include
+#CFLAGS += -I${BSPDIR}/zxic_code/linux-5.10/include/uapi
CFLAGS += -g
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_adc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_adc.c
new file mode 100644
index 0000000..4360fb2
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_adc.c
@@ -0,0 +1,60 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+//#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+#define ADC0_PATH "/sys/kernel/debug/pmu_zx29/adc0"
+#define ADC1_PATH "/sys/kernel/debug/pmu_zx29/adc1"
+#define ADC2_PATH "/sys/kernel/debug/pmu_zx29/adc2"
+#define ADC_VAL_LENGTH 8
+
+
+typedef enum{
+ ADC0 = 0,
+ ADC1 = 1,
+ ADC2 = 2,
+ ADC_END
+}E_ADC;
+
+int sc_adc_show(E_ADC adc)
+{
+ struct file *fb_path = "";
+ FILE* fd_voltage = NULL;
+ char buf_volt[ADC_VAL_LENGTH] = {0};
+ int len = 0;
+ int voltagepower = 0;
+
+ switch(adc){
+ case ADC0:
+ fb_path=ADC0_PATH;
+ break;
+ case ADC1:
+ fb_path=ADC1_PATH;
+ break;
+ case ADC2:
+ fb_path=ADC2_PATH;
+ break;
+ default:
+ return -1;
+ }
+
+ fd_voltage=fopen(fb_path, "r");
+ if (fd_voltage == NULL)
+ return -1;
+
+ len = fread(buf_volt, 1,ADC_VAL_LENGTH, fd_voltage);
+ if (len > 0) {
+ voltagepower = atoi(buf_volt);
+ fclose(fd_voltage);
+ return voltagepower;
+ }
+
+ fclose(fd_voltage);
+}
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_adc.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_adc.h
new file mode 100644
index 0000000..73010d5
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_adc.h
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <linux/netlink.h>
+#include <poll.h>
+#include <linux/serial.h>
+#include <termios.h>
+#include "softap_api.h"
+
+typedef enum{
+ ADC0 = 0,
+ ADC1 = 1,
+ ADC2 = 2,
+ ADC_END
+}E_ADC;
+
+int sc_adc_show(E_ADC adc);
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_eth.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_eth.c
index 5e91d7f..37d30f8 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_eth.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_eth.c
@@ -154,13 +154,38 @@
int sc_eth_enable(void)
{
printf("[%s]\n", __func__);
- return 0;
+ struct ifreq ifr;
+ int fd = -1;
+
+ memset(&ifr, 0x00, sizeof(struct ifreq));
+ strcpy(ifr.ifr_name, "eth0");
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ printf("socket failed\n");
+ return -1;
+ }
+
+ return ioctl(fd, SIOCENABLEPHY, &ifr);
+
}
int sc_eth_disable(void)
{
printf("[%s]\n", __func__);
- return 0;
+ struct ifreq ifr;
+ int fd = -1;
+
+ memset(&ifr, 0x00, sizeof(struct ifreq));
+ strcpy(ifr.ifr_name, "eth0");
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ printf("socket failed\n");
+ return -1;
+ }
+
+ return ioctl(fd, SIOCDISABLEPHY, &ifr);
}
int sc_eth_autoneg_set(E_ETH_AUTONEG autoneg)
@@ -405,11 +430,89 @@
return 0;
}
+
+char *get_name(char *name, char *p)
+{
+ while (isspace(*p))
+ p++;
+ while (*p) {
+ if (isspace(*p))
+ break;
+ if (*p == ':') { /* could be an alias */
+ char *dot = p, *dotname = name;
+ *name++ = *p++;
+ while (isdigit(*p))
+ *name++ = *p++;
+ if (*p != ':') { /* it wasn't, backup */
+ p = dot;
+ name = dotname;
+ }
+ if (*p == '\0')
+ return NULL;
+ p++;
+ break;
+ }
+ *name++ = *p++;
+ }
+ *name++ = '\0';
+ return p;
+}
+
+
+int get_dev_fields(char *bp, struct interface *ife)
+{
+ sscanf(bp,
+ "%llu %llu %lu %lu %lu %lu %lu %lu %llu %llu %lu %lu %lu %lu %lu %lu",
+ &ife->stats.rx_bytes,
+ &ife->stats.rx_packets,
+ &ife->stats.rx_errors,
+ &ife->stats.rx_dropped,
+ &ife->stats.rx_fifo_errors,
+ &ife->stats.rx_frame_errors,
+ &ife->stats.rx_compressed,
+ &ife->stats.rx_multicast,
+
+ &ife->stats.tx_bytes,
+ &ife->stats.tx_packets,
+ &ife->stats.tx_errors,
+ &ife->stats.tx_dropped,
+ &ife->stats.tx_fifo_errors,
+ &ife->stats.collisions,
+ &ife->stats.tx_carrier_errors,
+ &ife->stats.tx_compressed);
+}
+
+int proc_read(struct interface *ife)
+{
+ FILE *fh;
+ char buf[512];
+
+ fh = fopen(_PATH_PROCNET_DEV, "r");
+ if (!fh) {
+ printf("open /dev/proc/dev failed\n");
+ return -1;
+ }
+ fgets(buf, sizeof buf, fh);
+ fgets(buf, sizeof buf, fh);
+
+ while (fgets(buf, sizeof buf, fh)) {
+ char *s, name[IFNAMSIZ];
+ s = get_name(name, buf);
+ if (strcmp(name, "eth0")) {
+ continue;
+ }
+ get_dev_fields(s, ife);
+ break;
+ }
+ return 0;
+}
+
int sc_eth_info_get(struct sc_eth_info *info)
{
struct sc_eth_info local_info;
struct cmd_context ctx;
struct ethool_link_usettings *link_usettings;
+ struct interface ife;
int ret = 0;
printf("[%s]\n", __func__);
@@ -440,6 +543,15 @@
memcpy(info, &local_info, sizeof(struct sc_eth_info));
+
+ proc_read(&ife);
+
+ info->tx_bytes = ife.stats.tx_bytes;
+ info->tx_pkts = ife.stats.tx_packets;
+
+ info->rx_bytes = ife.stats.rx_bytes;
+ info->rx_pkts = ife.stats.rx_packets;
+
return 0;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_eth.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_eth.h
index 3cf470a..c6c6e29 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_eth.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_eth.h
@@ -6,6 +6,7 @@
#include <linux/types.h>
#include <linux/sockios.h>
#include <stdint.h>
+#include <linux/if.h>
typedef unsigned long long u64;
typedef uint32_t u32;
@@ -18,6 +19,74 @@
#define ETHTOOL_DECLARE_LINK_MODE_MASK(name) \
u32 name[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]
+#define SIOCENABLEPHY (SIOCDEVPRIVATE + 0x1)
+#define SIOCDISABLEPHY (SIOCDEVPRIVATE + 0x2)
+#define _PATH_PROCNET_DEV "/proc/net/dev"
+
+
+struct user_net_device_stats {
+ unsigned long long rx_packets; /* total packets received */
+ unsigned long long tx_packets; /* total packets transmitted */
+ unsigned long long rx_bytes; /* total bytes received */
+ unsigned long long tx_bytes; /* total bytes transmitted */
+ unsigned long rx_errors; /* bad packets received */
+ unsigned long tx_errors; /* packet transmit problems */
+ unsigned long rx_dropped; /* no space in linux buffers */
+ unsigned long tx_dropped; /* no space available in linux */
+ unsigned long rx_multicast; /* multicast packets received */
+ unsigned long rx_compressed;
+ unsigned long tx_compressed;
+ unsigned long collisions;
+
+ /* detailed rx_errors: */
+ unsigned long rx_length_errors;
+ unsigned long rx_over_errors; /* receiver ring buff overflow */
+ unsigned long rx_crc_errors; /* recved pkt with crc error */
+ unsigned long rx_frame_errors; /* recv'd frame alignment error */
+ unsigned long rx_fifo_errors; /* recv'r fifo overrun */
+ unsigned long rx_missed_errors; /* receiver missed packet */
+ /* detailed tx_errors */
+ unsigned long tx_aborted_errors;
+ unsigned long tx_carrier_errors;
+ unsigned long tx_fifo_errors;
+ unsigned long tx_heartbeat_errors;
+ unsigned long tx_window_errors;
+};
+
+struct interface {
+ struct interface *next, *prev;
+ char name[IFNAMSIZ]; /* interface name */
+ short type; /* if type */
+ short flags; /* various flags */
+ int metric; /* routing metric */
+ int mtu; /* MTU value */
+ int tx_queue_len; /* transmit queue length */
+ struct ifmap map; /* hardware setup */
+ struct sockaddr addr; /* IP address */
+ struct sockaddr dstaddr; /* P-P IP address */
+ struct sockaddr broadaddr; /* IP broadcast address */
+ struct sockaddr netmask; /* IP network mask */
+ struct sockaddr ipxaddr_bb; /* IPX network address */
+ struct sockaddr ipxaddr_sn; /* IPX network address */
+ struct sockaddr ipxaddr_e3; /* IPX network address */
+ struct sockaddr ipxaddr_e2; /* IPX network address */
+ struct sockaddr ddpaddr; /* Appletalk DDP address */
+ struct sockaddr ecaddr; /* Econet address */
+ int has_ip;
+ int has_ipx_bb;
+ int has_ipx_sn;
+ int has_ipx_e3;
+ int has_ipx_e2;
+ int has_ax25;
+ int has_ddp;
+ int has_econet;
+ char hwaddr[32]; /* HW address */
+ int statistics_valid;
+ struct user_net_device_stats stats; /* statistics */
+ int keepalive; /* keepalive value for SLIP */
+ int outfill; /* outfill value for SLIP */
+};
+
struct cmd_context {
const char *devname;
int fd;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_tsc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_tsc.c
new file mode 100644
index 0000000..77328c9
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_tsc.c
@@ -0,0 +1,80 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+//#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+#include "sc_tsc.h"
+
+#define SC_TSC_IOC_MAGIC 'T'
+#define SC_TSC_GET_TEMP _IOW(SC_TSC_IOC_MAGIC, 1, char *)
+#define SC_TSC_GET_STRATEGY _IOW(SC_TSC_IOC_MAGIC, 2, char *)
+#define SCTSC_PATTH "/dev/zx_tsc"
+
+/*
+ * get temprature
+ *
+ * temp: 5¸öintÀàÐ͵ÄÊý¾Ý
+ * first: adc1; second: adc2; third:adcRF
+ *
+ * return 0 if succeed, others failed
+ */
+int sc_tsc_get_temp(int *temp)
+{
+ int ret=0;
+ int fd;
+
+ fd= open(SCTSC_PATTH, O_RDWR);
+ if(fd < 0)
+ {
+ printf("%s %d temp open failed \r\n",__FUNCTION__,__LINE__);
+ return fd;
+ }
+
+ if(ioctl(fd, SC_TSC_GET_TEMP, temp) < 0)
+ {
+ printf("%s %d temp ioctrl failed \r\n",__FUNCTION__,__LINE__);
+ ret = -EPERM;
+ }
+
+ close(fd);
+
+ return ret;
+
+}
+
+/*
+ * get strategy
+ *
+ * s: T_StrategyÀàÐ͵ÄÊý¾Ý
+ * name: name of strategy
+ * flag: 0--stop; 1:start; 2- hold
+ * return 0 if succeed, others failed
+ */
+int sc_tsc_get_strategy(T_Strategy *s)
+{
+ int ret=0;
+ int fd;
+
+ fd= open(SCTSC_PATTH, O_RDWR);
+ if(fd < 0)
+ {
+ return fd;
+ }
+
+ if(ioctl(fd, SC_TSC_GET_STRATEGY, s) < 0)
+ {
+ printf("%s %d parn set failed \r\n",__FUNCTION__,__LINE__);
+ ret = -EPERM;
+ }
+
+ close(fd);
+
+ return ret;
+
+}
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_tsc.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_tsc.h
new file mode 100644
index 0000000..8e09fd6
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_tsc.h
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <linux/netlink.h>
+#include <poll.h>
+#include <linux/serial.h>
+#include <termios.h>
+#include "softap_api.h"
+
+#define STRATEGY_PS_NUM 3
+#define STRATEGY_PHY_NUM 8
+#define STRATEGY_NUM (STRATEGY_PS_NUM+STRATEGY_PHY_NUM)
+
+typedef enum{
+ PROBE_ADC1 = 0,
+ PROBE_ADC2 = 1,
+ PROBE_ADCRF = 2,
+ PROBE_RESEV2,
+ PROBE_RESEV3,
+
+ PROBE_MAX,
+}E_Probe;
+
+typedef struct
+{
+ char name[32];
+ unsigned int flag;
+}T_Strategy;
+
+
+/*
+ * get temprature
+ *
+ * temp: 5¸öintÀàÐ͵ÄÊý¾Ý
+ * first: adc1; second: adc2; third:adcRF
+ *
+ * return 0 if succeed, others failed
+ */
+int sc_tsc_get_temp(int *temp);
+
+/*
+ * get strategy
+ *
+ * s: T_StrategyÀàÐ͵ÄÊý¾Ý
+ * name: name of strategy
+ * flag: 0--stop; 1:start; 2- hold
+ *
+ * return 0 if succeed, others failed
+ */
+int sc_tsc_get_strategy(T_Strategy *s);
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_uart.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_uart.c
index c7a3a6a..300b0fb 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_uart.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_uart.c
@@ -323,3 +323,51 @@
}
+int sc_uart_set_raw_mode(int fd)
+{
+ struct termios tOldTermios = {0};
+
+ bzero(&tOldTermios, sizeof(tOldTermios));
+ tcgetattr(fd, &tOldTermios); // get the serial port attributions
+ tOldTermios.c_iflag &= ~(ICRNL | IXON);
+ tOldTermios.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ISIG);
+ tOldTermios.c_oflag &= ~OPOST;
+ if(tcsetattr(fd, TCSANOW, &tOldTermios) != 0) //ÉèÖÃÐÂÊôÐÔ, TCSANOW: ËùÓɸıäÁ¢¼´ÉúЧ
+ {
+ return -1;
+ }
+ tcflush(fd, TCIOFLUSH);
+ return 0;
+}
+
+
+int sc_uart_set_app_ctrl_lowpower(int index, int flag)
+{
+ FILE *fp;
+ int rtv = 0;
+ char *dev_path = NULL;
+ //only uart 0&2 can set this flag
+ if(index != 0 && index != 2)
+ return -22;
+
+ dev_path = UART_0_ATTR_APPCTRL;
+ if(index == 2){
+ dev_path = UART_2_ATTR_APPCTRL;
+ }
+
+ if((fp=fopen(dev_path,"w"))==NULL)
+ {
+ return -1;
+ }
+
+ if(flag){
+ rtv = fwrite("1",1,1, fp);
+ } else{
+ rtv = fwrite("0",1,1, fp);
+ }
+
+
+ fclose(fp);
+ return rtv;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_uart.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_uart.h
index 9292919..5d3314d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_uart.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_uart.h
@@ -17,6 +17,18 @@
#include <fcntl.h>
#include <sys/ioctl.h>
+
+#define UART_0_ATTR_APPCTRL "/sys/devices/platform/soc/131000.uart/app_ctrl"
+#define UART_0_ATTR_CTSRTS_INPUT "/sys/devices/platform/soc/131000.uart/ctsrts_input"
+#define UART_0_ATTR_SLEEP_STATE "/sys/devices/platform/soc/131000.uart/sleep_state"
+#define UART_0_ATTR_WAKEUP_ENABLE "/sys/devices/platform/soc/131000.uart/wakeup_enable"
+
+#define UART_2_ATTR_APPCTRL "/sys/devices/platform/soc/140d000.uart/app_ctrl"
+#define UART_2_ATTR_SLEEP_STATE "/sys/devices/platform/soc/140d000.uart/sleep_state"
+
+#define UART_2_ATTR_PATH "/sys/devices/platform/soc/140d000.uart/"
+#define UART_0_ATTR_PATH "/sys/devices/platform/soc/131000.uart/"
+
/*baud rate flags*/
typedef enum {
B_300 = 300,
@@ -166,3 +178,24 @@
* @note
*/
int sc_uart_set_timeout(int fd, int time);
+
+
+
+/**
+ * @brief 设置uart 不进行ICRNL ICANON ISIG OPOST
+ * @param fd 设备描述符
+ * @retval 成功 0, 失败 其它值
+ * @note
+ */
+int sc_uart_set_raw_mode(int fd);
+
+
+/**
+ * @brief set attribute app_ctrl, using this flag, before enter lowpower, app should close ttyS* dev
+ * @param index uart id index
+ * @param flag set value
+ * @return result
+ * @retval success 0, fail others
+ * @note
+ */
+int sc_uart_set_app_ctrl_lowpower(int index, int flag);
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c
new file mode 100644
index 0000000..6a1bd73
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c
@@ -0,0 +1,182 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+//add for cmux
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <linux/netlink.h>
+#include <poll.h>
+#include <linux/serial.h>
+#include <termios.h>
+#include "sc_usb.h"
+//#include "nv_api.h"
+
+
+/*¶ÁдÎļþÏà¹Ø²Ù×÷begin*/
+static int filelength(FILE *fp)
+{
+ int num;
+ fseek(fp,0,SEEK_END);
+ num=ftell(fp);
+ fseek(fp,0,SEEK_SET);
+ return num;
+}
+
+int readfile(char *path, char* buf, unsigned len)
+{
+ FILE *fp;
+ unsigned int length;
+ if((fp=fopen(path,"r"))==NULL)
+ {
+ //slog(USBCFGMNG_PRINT,SLOG_ERR, "[usbCfgMng] open file %s error.\n",path);
+ return -1;
+ }
+ length=filelength(fp);
+ length = length > len? len: length;
+ //ch=(char *)malloc(length+1);
+ int read_len = fread(buf,length,1,fp);
+ if(read_len < 1) // cov M CHECKED_RETURN
+ {
+ //slog(SDCARD_PRINT, SLOG_ERR, "fread %s error.\n",path);
+ }
+
+ fclose(fp);
+ *(buf+length) = '\0';
+ return (int)length;
+}
+
+
+
+int writefile(char*path, char*buf, unsigned len)
+{
+ FILE *fp;
+ int rtv = 0;
+ if((fp=fopen(path,"w"))==NULL)
+ {
+ return -1;
+ }
+ rtv = fwrite(buf,len,1, fp);
+ fclose(fp);
+ return rtv;
+}
+
+
+void sc_usb_dl_open(void)
+{
+ writefile(USB_ATTR_DL_OPEN, "1", 1);
+}
+
+void sc_usb_dl_close(void)
+{
+ writefile(USB_ATTR_DL_OPEN, "0", 1);
+}
+
+int sc_usb_get_mode(char* buf, int len)
+{
+ int ret = 0;
+ ret = readfile(USB_ATTR_SWITCH_MODE, buf, len);
+ return ret;
+}
+
+int sc_usb_switch_mode(char *type)
+{
+ int ret = 0;
+
+ ret = writefile(USB_ATTR_SWITCH_MODE, type, strlen(type));
+ return ret;
+}
+
+void sc_usb_set_usermode(void)
+{
+ sc_usb_switch_mode("1");
+}
+
+void sc_usb_user_closedl(void)
+{
+ sc_usb_dl_close();
+ sc_usb_switch_mode("1");
+}
+
+void sc_usb_set_debugmode(void)
+{
+ sc_usb_switch_mode("0");
+
+}
+
+void sc_usb_debug_opendl(void)
+{
+ sc_usb_dl_open();
+ sc_usb_switch_mode("0");
+
+}
+void sc_usb_set_amtmode(void)
+{
+ sc_usb_switch_mode("3");
+}
+
+void sc_usb_set_factorymode(void)
+{
+ sc_usb_switch_mode("2");
+}
+
+void sc_usb_set_eyemode(void)
+{
+ sc_usb_switch_mode("4");
+}
+
+
+int sc_usb_get_usbstate(char* buf, int len)
+{
+ int ret = 0;
+ ret = readfile(USB_ATTR_USB_STATE, buf, len);
+ return ret;
+}
+
+int sc_usb_get_usb_speed(char* buf, int len)
+{
+ int ret = 0;
+ ret = readfile(USB_ATTR_SPEED, buf, len);
+ return ret;
+}
+
+
+int sc_usb_get_netname(char* buf, int len)
+{
+ int ret = 0;
+ ret = readfile(USB_ATTR_NETNAME, buf, len);
+ return ret;
+}
+
+
+int sc_usb_set_netcardtype(e_usb_net_type type)
+{
+ int ret = 0;
+ if(type == USB_NET_RNDIS)
+ ret = writefile(USB_ATTR_FORCENET, "0", 1);
+ else
+ ret = writefile(USB_ATTR_FORCENET, "1", 1);
+ return ret;
+}
+
+void sc_usb_set_net_rndis(void)
+{
+ //nv_set_item(NV_RO, STR_FORCE_NETCARD_TYPE, "force_rndis", 1);
+ sc_usb_set_netcardtype(USB_NET_RNDIS);
+}
+
+void sc_usb_set_net_ecm(void)
+{
+ //nv_set_item(NV_RO, STR_FORCE_NETCARD_TYPE, "force_ecm", 1);
+ sc_usb_set_netcardtype(USB_NET_ECM);
+}
+
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.h
new file mode 100644
index 0000000..32820a3
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.h
@@ -0,0 +1,135 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <linux/netlink.h>
+#include <poll.h>
+#include <linux/serial.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#ifndef __SC_USB_H
+#define __SC_USB_H
+
+#define USB_ATTR_PATH "/sys/gen_usb/usb_state/"
+#define USB_ATTR_SWITCH_MODE "/sys/gen_usb/usb_state/switch_mode"
+#define USB_ATTR_DL_OPEN "/sys/gen_usb/usb_state/dl_open"
+#define USB_ATTR_SPEED "/sys/gen_usb/usb_state/usb_speed"
+#define USB_ATTR_USB_STATE "/sys/gen_usb/usb_state/usbstate"
+#define USB_ATTR_NETNAME "/sys/gen_usb/usb_state/netname"
+#define USB_ATTR_FORCENET "/sys/gen_usb/usb_state/forcenet"
+#define USB_ATTR_SIMULATE_PLUG "/sys/gen_usb/usb_state/usb_simulate_plug"
+#define USB_ATTR_BOOT_MODE "/sys/gen_usb/usb_state/boot_mode"
+#define STR_FORCE_NETCARD_TYPE "forcenetcard_type"
+
+#define USB_ATTR_FAST_POWEROFF "/sys/gen_usb/usb_state/fast_poweroff"
+//#define USB_ATTR_
+//#define USB_ATTR_
+//#define USB_ATTR_
+
+/*usbģʽÀàÐÍ*/
+typedef enum{
+ USB_NET_RNDIS = 0,
+ USB_NET_ECM,
+ USB_NET_MAX_NUM,
+}e_usb_net_type;
+
+/*usbģʽÀàÐÍ*/
+typedef enum{
+ USB_MODETYPE_DEBUG = 0,
+ USB_MODETYPE_USER,
+ USB_MODETYPE_FACTORY,
+ USB_MODETYPE_AMT,
+ USB_MODETYPE_EYE_DIAGRAM,
+ USB_MODETYPE_MAX_CONFIG_NUM,
+}e_usbEnum_modeType;
+
+/*usbÅäÖÃö¾ÙÀàÐÍ*/
+typedef enum{
+ USB_CDROM = 0,
+ USB_DEBUG,
+ USB_USER,
+ USB_FACTORY,
+ USB_AMT,
+ USB_EYE_DIAGRAM,
+ USB_MAX_CONFIG_NUM,
+ USB_INVALID,
+}e_usbEnum_type;
+
+/*wangchao add to force netCard type*/
+typedef enum _T_SYS_NV_FORCE_NETCARD_TYPE
+{
+ FORCE_INVALID =0xFFUL,
+ FORCE_NDIS =0x00UL,
+ FORCE_RNDIS =0x01UL,
+ FORCE_ECM =0x02UL,
+ FORCE_MBIM =0x03UL,
+ FORCE_ERR =0x55UL
+}T_SYS_NV_FORCE_NETCARD_TYPE;
+#endif /*__SC_USB_H*/
+
+
+void sc_usb_dl_open(void);
+
+
+void sc_usb_dl_close(void);
+
+
+int sc_usb_get_mode(char* buf, int len);
+
+
+int sc_usb_switch_mode(char *type);
+
+
+void sc_usb_set_usermode(void);
+
+
+void sc_usb_user_closedl(void);
+
+
+void sc_usb_set_debugmode(void);
+
+
+void sc_usb_debug_opendl(void);
+
+void sc_usb_set_amtmode(void);
+
+
+void sc_usb_set_factorymode(void);
+
+
+void sc_usb_set_eyemode(void);
+
+
+
+int sc_usb_get_usbstate(char* buf, int len);
+
+
+int sc_usb_get_usb_speed(char* buf, int len);
+
+
+
+int sc_usb_get_netname(char* buf, int len);
+
+
+int sc_usb_set_netcardtype(e_usb_net_type type);
+
+
+void sc_usb_set_net_rndis(void);
+
+
+void sc_usb_set_net_ecm(void);
+
+
+
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/Makefile
index f539081..b409df9 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/Makefile
@@ -24,7 +24,7 @@
LIB_SHARED = libmedia.so
LIB_STATIC = libmedia.a
-OBJS = voice_api.o audio_api.o
+OBJS = sc_voice_api.o audio_api.o
CFLAGS += -g
#LDFLAGS += -lpthread
@@ -53,8 +53,8 @@
##CFLAGS += -g -Werror=implicit-function-declaration
LDLIBS += -lpthread
-LDLIBS += -lvoice -L$(LIB_DIR)/libvoice
LDLIBS += -ltinyalsa -L$(LIB_DIR)/libtinyalsa
+LDLIBS += -lvoice -L$(LIB_DIR)/libvoice
LDFLAGS += -Wl,--no-as-needed
LDFLAGS += -Wl,--no-undefined
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/sc_voice_api.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/sc_voice_api.c
new file mode 100755
index 0000000..feb40fb
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/sc_voice_api.c
@@ -0,0 +1,161 @@
+#ifdef USE_CAP_SUPPORT
+#include <tinyalsa/audio_mixer_ctrl.h>
+#include "voice_ipc.h"
+#include "sc_voice_api.h"
+
+int sc_audio_set_voice_device_mode(int dev_mode)
+{
+ int ret = VOICEIPC_OK;
+
+ set_voice_device_mode(dev_mode);
+
+ ret = msg_set_voice_device_mode(dev_mode);
+
+ return ret;
+}
+
+int sc_audio_get_voice_device_mode(int *p_dev_mode)
+{
+ int ret = VOICEIPC_OK;
+
+ *p_dev_mode = msg_get_voice_device_mode();
+ if(0 > *p_dev_mode){
+ ret = VOICEIPC_ERROR;
+ printf("%s: get err, *p_dev_mode=%d", __func__, *p_dev_mode);
+ }
+
+ return ret;
+}
+
+int sc_audio_set_rx_voice_vol(int vol)
+{
+ int ret = VOICEIPC_OK;
+
+ ret = msg_set_rx_voice_vol(vol);
+
+ return ret;
+}
+
+int sc_audio_get_rx_voice_vol(int *p_vol)
+{
+ int ret = VOICEIPC_OK;
+
+ *p_vol = msg_get_rx_voice_vol();
+ if(0 > *p_vol){
+ ret = VOICEIPC_ERROR;
+ printf("%s: get err, *p_vol=%d", __func__, *p_vol);
+ }
+
+ return ret;
+}
+
+int sc_audio_set_tx_voice_vol(int vol)
+{
+ int ret = VOICEIPC_OK;
+
+ ret = msg_set_tx_voice_vol(vol);
+
+ return ret;
+}
+
+int sc_audio_get_tx_voice_vol(int *p_vol)
+{
+ int ret = VOICEIPC_OK;
+
+ *p_vol = msg_get_tx_voice_vol();
+ if(0 > *p_vol){
+ ret = VOICEIPC_ERROR;
+ printf("%s: get err, *p_vol=%d", __func__, *p_vol);
+ }
+
+ return ret;
+}
+
+int sc_audio_set_tx_voice_mute_state(int mute)
+{
+ int ret = VOICEIPC_OK;
+
+ ret = msg_set_tx_voice_mute_state(mute);
+
+ return ret;
+}
+
+int sc_audio_get_tx_voice_mute_state(int *p_mute)
+{
+ int ret = VOICEIPC_OK;
+
+ *p_mute = msg_get_tx_voice_mute_state();
+ if(0 > *p_mute){
+ ret = VOICEIPC_ERROR;
+ printf("%s: get err, *p_mute=%d", __func__, *p_mute);
+ }
+
+ return ret;
+}
+
+int sc_audio_set_rx_voice_mute_state(int mute)
+{
+ int ret = VOICEIPC_OK;
+
+ ret = msg_set_rx_voice_mute_state(mute);
+
+ return ret;
+}
+
+int sc_audio_get_rx_voice_mute_state(int *p_mute)
+{
+ int ret = VOICEIPC_OK;
+
+ *p_mute = msg_get_rx_voice_mute_state();
+ if(0 > *p_mute){
+ ret = VOICEIPC_ERROR;
+ printf("%s: get err, *p_mute=%d", __func__, *p_mute);
+ }
+
+ return ret;
+}
+
+int sc_audio_set_loopback_enable_state(int enable)
+{
+ int ret = VOICEIPC_OK;
+
+ ret = msg_set_loopback_enable_state(enable);
+
+ return ret;
+}
+
+int sc_audio_get_loopback_enable_state(int *p_enable)
+{
+ int ret = VOICEIPC_OK;
+
+ *p_enable = msg_get_loopback_enable_state();
+ if(0 > *p_enable){
+ ret = VOICEIPC_ERROR;
+ printf("%s: get err, *p_enable=%d", __func__, *p_enable);
+ }
+
+ return ret;
+}
+int sc_audio_ap_alsa_voice_open(int vmode)
+{
+ int ret = VOICEIPC_OK;
+
+ ret = msg_ap_alsa_voice_open(vmode);
+
+ return ret;
+}
+
+int sc_audio_ap_alsa_voice_close(int vmode)
+{
+ int ret = VOICEIPC_OK;
+
+ ret = msg_ap_alsa_voice_close(vmode);
+
+ return ret;
+}
+
+
+
+
+
+#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/sc_voice_api.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/sc_voice_api.h
new file mode 100755
index 0000000..cdc52da
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libmedia/sc_voice_api.h
@@ -0,0 +1,17 @@
+#ifdef USE_CAP_SUPPORT
+int sc_audio_set_voice_device_mode(int dev_mode);
+int sc_audio_get_voice_device_mode(int *p_dev_mode);
+int sc_audio_set_rx_voice_vol(int vol);
+int sc_audio_get_rx_voice_vol(int *p_vol);
+int sc_audio_set_tx_voice_vol(int vol);
+int sc_audio_get_tx_voice_vol(int *p_vol);
+int sc_audio_set_tx_voice_mute_state(int mute);
+int sc_audio_get_tx_voice_mute_state(int *p_mute);
+int sc_audio_set_rx_voice_mute_state(int mute);
+int sc_audio_get_rx_voice_mute_state(int *p_mute);
+int sc_audio_set_loopback_enable_state(int enable);
+int sc_audio_get_loopback_enable_state(int *p_enable);
+int sc_audio_ap_alsa_voice_open(int vmode);
+int sc_audio_ap_alsa_voice_close(int vmode);
+
+#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
index 64ada0d..4e9e6d8 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
@@ -225,53 +225,54 @@
{
sc_ipc_msg *pmsg = 0;
sc_ipc_event_ex *pevt = 0;
-
+ char* p = (char *)param;
+ char name[64];
+ int ret = 0;
+
sc_ipc_event_init();
- s_local_fd = sc_ipc_create_msg_fd("sc_tele_fd");
+ memset(name, 0, sizeof(name));
+ if(NULL != p) {
+ snprintf(name, sizeof(name) - 1, "%s", p);
+ }
+ else {
+ snprintf(name, sizeof(name) - 1, "scipc");
+ }
+
+ s_local_fd = sc_ipc_create_msg_fd(name);
pmsg = sc_ipc_msg_new(SC_IPC_MSG_PAYLOAD_SIZE);
-#if 0
- /* Handle loop-exit request. */
- pevt = sc_ipc_event_ex_new();
- sc_ipc_event_set(&(pevt->event), s_local_fd, SC_IPC_EVT_TERMINATE_LOOP, 1, handle_loop_terminated_evt, 0);
- sc_ipc_event_add(&(pevt->event));
-
- /* Handle remote listening-msg-register request. */
- pevt = sc_ipc_event_ex_new();
- sc_ipc_event_set(&(pevt->event), s_local_fd, SC_IPC_EVT_REGISTER_MSG, 1, handle_register_msg_evt, 0);
- sc_ipc_event_add(&(pevt->event));
-
- /* Handle remote listening-msg-unregister request. */
- pevt = sc_ipc_event_ex_new();
- sc_ipc_event_set(&(pevt->event), s_local_fd, SC_IPC_EVT_UNREGISTER_MSG, 1, handle_unregister_msg_evt, 0);
- sc_ipc_event_add(&(pevt->event));
-
- /* Notify remote the listening-msg triggered. */
- pevt = sc_ipc_event_ex_new();
- sc_ipc_event_set(&(pevt->event), s_local_fd, SC_IPC_EVT_NOTIFY_REGISTRANT, 1, handle_notify_registrant_evt, 0);
- sc_ipc_event_add(&(pevt->event));
-#else
sc_ipc_register_events(s_standard_evts, sizeof(s_standard_evts)/sizeof(s_standard_evts[0]));
-#endif
pthread_mutex_lock(&s_startupMutex);
s_started = 1;
pthread_cond_broadcast(&s_startupCond);
pthread_mutex_unlock(&s_startupMutex);
+ prctl(PR_SET_NAME, name, 0, 0, 0);
+
for(;;)
{
- memset(pmsg, 0, sizeof(*pmsg));
+ ret = 0;
+ memset(pmsg, 0, sizeof(*pmsg));
pmsg->fd_svr = s_local_fd;
pmsg->data_len = SC_IPC_MSG_PAYLOAD_SIZE;
- sc_ipc_recv_msg(pmsg);
-
- MUTEX_ACQUIRE();
- handle_ipc_event(pmsg);
- MUTEX_RELEASE();
+ ret = sc_ipc_recv_msg(pmsg);
+ if (ret >= 0)
+ {
+ MUTEX_ACQUIRE();
+ handle_ipc_event(pmsg);
+ MUTEX_RELEASE();
+ }
+ else
+ {
+ if(errno != EINTR)
+ SCLOGE("sc_ipc_inner_event_loop: errno = %d, errmsg = %s\n", errno,strerror(errno));
+ }
+
if(!s_started)
{
+ SCLOGE("Warning:The thread(%s) is term!\n",name);
break;
}
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/Makefile
new file mode 100755
index 0000000..47bd085
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/Makefile
@@ -0,0 +1,38 @@
+#*******************************************************************************
+# include ZTE library makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+
+LIB_STATIC = libsclog.a
+LIB_SHARED = libsclog.so
+
+OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
+
+#CFLAGS += -I$(APP_DIR)/at_ctl/inc
+#CFLAGS += -I$(LIB_DIR)/libatutils
+#CFLAGS += -I$(LINUX_DIR)/include
+CFLAGS += -g
+
+
+##############USER COMIZE END##################
+
+CFLAGS += -I$(APP_DIR)/include
+CFLAGS += -fPIC
+LDFLAGS += -shared
+
+all: $(LIB_STATIC) $(LIB_SHARED)
+
+$(LIB_STATIC) : $(OBJS)
+ $(AR) rcs $(LIB_STATIC) $(OBJS)
+
+$(LIB_SHARED): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^
+
+romfs:
+ $(ROMFSINST) $(LIB_SHARED) /lib/$(LIB_SHARED)
+
+clean:
+ -$(RM) *.a *.o *.so $(LIB_SHARED) $(LIB_STATIC) $(OBJS)
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/readme.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/readme.txt
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/readme.txt
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/sc_log.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/sc_log.c
new file mode 100755
index 0000000..be62aab
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/sc_log.c
@@ -0,0 +1,120 @@
+#define _POSIX_C_SOURCE 199309
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <time.h>
+#include <syslog.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include "sc_log.h"
+
+int slog_printlevel = SLOG_ERR;
+int slog_sysloglevel = SLOG_OFF;
+char slog_printmode[32];
+
+void sc_log(int prio, const char *fmt, ...);
+
+static void log_sig_hdl(int sig, siginfo_t *siginfo, void *ptr)
+{
+ int level = 0;
+ int printlog = 0, syslog = 0;
+}
+
+//注册动态调整打印级别信号量
+static void register_sig_logswitch(void)
+{
+ struct sigaction st;
+
+ memset(&st, 0, sizeof(st));
+ st.sa_flags = SA_SIGINFO;
+ st.sa_sigaction = log_sig_hdl;
+ sigaction(SIGUSR2, &st, NULL);
+}
+
+//根据NV初始化打印级别
+void sc_log_init(char *mod)
+{
+ char nv_print_level[32] = {0};
+ char nv_syslog_level[32] = {0};
+
+ sc_cfg_get("print_level", nv_print_level, sizeof(nv_print_level));
+ sc_cfg_get("syslog_level", nv_syslog_level, sizeof(nv_syslog_level));
+ strncpy(slog_printmode, mod, sizeof(slog_printmode));
+
+ //loglevel非有效值时,将默认打印级别设置为off,即关闭打印
+ slog_printlevel = atoi(nv_print_level);
+ if((slog_printlevel < SLOG_DEBUG) || (slog_printlevel > SLOG_OFF)) {
+ slog_printlevel = SLOG_OFF;
+ }
+
+ slog_sysloglevel = atoi(nv_syslog_level);
+ if((slog_sysloglevel < SLOG_DEBUG) || (slog_sysloglevel > SLOG_OFF)) {
+ slog_sysloglevel = SLOG_OFF;
+ }
+
+ register_sig_logswitch();
+
+ sc_log(SLOG_DEBUG, "sc_log_init, print:%d, syslog:%d \n",
+ slog_printlevel, slog_sysloglevel);
+}
+
+void sys_log(int prio, const char * fmt, va_list arg)
+{
+ vsyslog(prio, fmt, arg);
+}
+
+
+#define put_to_console(fmt, arg) do {\
+ char buf[1024] = {0}; \
+ snprintf(buf, 1023, "%s[%d]: ", slog_printmode, syscall(SYS_gettid)); \
+ int n = strlen(buf); \
+ va_start(arg, fmt); \
+ vsnprintf(buf+n, 1023-n, fmt, arg); \
+ va_end(arg); \
+ printf("%s",buf); \
+}while(0)
+
+
+#define put_to_syslog(LEVEL) do { \
+ openlog(slog_printmode, LOG_PID, LOG_LPR); \
+ va_start(arg, fmt); \
+ sys_log(LOG_##LEVEL, fmt, arg); \
+ va_end(arg); \
+ closelog(); \
+}while(0)
+
+void sc_log(int prio, const char *fmt, ...)
+{
+ va_list arg = {0};
+
+ if (slog_sysloglevel > 0 && slog_sysloglevel <= prio) {
+ switch (prio) {
+ case SLOG_NORMAL: {
+ put_to_syslog(NOTICE);
+ }
+ break;
+
+ case SLOG_DEBUG: {
+ put_to_syslog(DEBUG);
+ }
+ break;
+
+ case SLOG_ERR: {
+ put_to_syslog(ERR);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (slog_printlevel > 0 && slog_printlevel <= prio) {
+ put_to_console(fmt, arg);
+ }
+}
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/sc_log.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/sc_log.h
new file mode 100755
index 0000000..c5b9dae
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsclog/sc_log.h
@@ -0,0 +1,77 @@
+/**
+* @file sc_log.h
+* @brief nv接口头文件
+*
+* Copyright (C) 2022 Sanechips Technology Co., Ltd.
+*
+*/
+
+#ifndef _SC_LOG_H
+#define _SC_LOG_H
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+extern void sc_log(int prio, const char *fmt, ...);
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+#define SLOG_DEBUG 1 //研发个体行为log输出,量很大
+#define SLOG_NORMAL 2 //集成测试阶段log输出,量适中
+#define SLOG_ERR 3 //致命或快照类log输出,量小
+#define SLOG_OFF 4 //全部关闭打印
+
+/**
+* @brief 调试log信息输出
+* @param fmt 入参,格式化字符串,参考printf
+* @return none
+* @note
+* @warning
+*/
+#define sc_log_debug(fmt, ...) sc_log(SLOG_DEBUG, fmt, ##__VA_ARGS__)
+
+/**
+* @brief 普通log信息输出
+* @param fmt 入参,格式化字符串,参考printf
+* @return none
+* @note
+* @warning
+*/
+#define sc_log_normal(fmt, ...) sc_log(SLOG_NORMAL, fmt, ##__VA_ARGS__)
+
+/**
+* @brief 错误log信息输出
+* @param fmt 入参,格式化字符串,参考printf
+* @return none
+* @note
+* @warning
+*/
+#define sc_log_error(fmt, ...) sc_log(SLOG_ERR, fmt, ##__VA_ARGS__)
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Global variable declarations *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Global function declarations *
+ ******************************************************************************/
+/**
+* @brief log系统初始化,应用程序在调用log输出接口前调用
+* @param mod 入参,标签名,用户自定义字符串,用于区分模块
+* @return none
+* @note
+* @warning
+*/
+void sc_log_init(char *mod);
+
+/*******************************************************************************
+ * Inline function implementations *
+ ******************************************************************************/
+
+#endif // #ifndef _SC_LOG_H
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/Makefile
index 4989e03..9ada63f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/Makefile
@@ -9,7 +9,8 @@
LIB_STATIC = libsctel.a
LIB_SHARED = libsctel.so
-OBJS += $(patsubst %.c,%.o,$(wildcard ./call/*.c ./sim/*.c ./data/*.c ./at/*.c ./nw_mgr/*.c))
+OBJS += $(patsubst %.c,%.o,$(wildcard ./call/*.c ./sim/*.c ./data/*.c ./at/*.c ./nw_mgr/*.c ./sms/*.c ./rtc_timer/*.c ./mnet/*.c))
+OBJS += $(patsubst %.c,%.o,$(wildcard ./audio/*.c))
CFLAGS += -I$(zte_app_path)/zte_comm/at_ctl/inc
CFLAGS += -I$(APP_DIR)/include/sctel
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/at/sc_at.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/at/sc_at.c
index d3d1884..213e3f2 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/at/sc_at.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/at/sc_at.c
@@ -12,6 +12,7 @@
#include <time.h>
#include <syslog.h>
#include <pthread.h>
+#include <semaphore.h>
#include "soft_timer.h"
#include "sc_at.h"
@@ -49,6 +50,7 @@
int g_init_state=0;
int g_deinit_state=0;
int g_sync_moduleId=-1;
+sem_t g_sc_atsend_sem;
pthread_t g_asyn_thread;
pthread_mutex_t g_sc_atsend_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -64,7 +66,7 @@
module_id++;
if (module_id > MODULE_ID_ATDYNAMIC_END) {
//µ±module_id´óÓÚMODULE_ID_ATDYNAMIC_ENDֵʱ£¬Ö÷¶¯¶ÏÑÔ
- slog(AT_API_PRINT, SLOG_ERR, "no free at dynamic module id left.\n");
+ SCLOGE("no free at dynamic module id left.\n");
return -1;
}
}
@@ -73,14 +75,14 @@
//¸øat_ctl·¢ËÍÏûÏ¢£¬·¢Ë͵ÄÏûÏ¢ÄÚÈÝÊÇatÃüÁî×Ö·û´®
/*´´½¨Í¨µÀ*/
if(0 != ipc_send_message(module_id, MODULE_ID_AT_CTL, MSG_CMD_SET_MSG_IS_FD, sizeof(chn_info), &chn_info, 0)) {
- slog(AT_API_PRINT, SLOG_ERR, "send_and_wait create channel fail.\n");
+ SCLOGE("send_and_wait create channel fail.\n");
return -1;
}
//·¢ËÍatÃüÁî
printf("send_at_req module_id:%d,handle:%d,at_req:%s\n",module_id,my_handle,req_at);
if(0 != ipc_send_message(module_id, MODULE_ID_AT_CTL, MSG_CMD_SEND_ATREQ_BY_MSG, strlen(req_at), req_at, 0))
{
- slog(AT_API_PRINT, SLOG_ERR, "send_and_wait send at req fail.\n");
+ SCLOGE("send_and_wait send at req fail.\n");
return -1;
}
@@ -96,7 +98,7 @@
LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
int iRet = 0;
if(send_at_req(&module_id,&my_handle,req_at) == -1 ){
- slog(AT_API_PRINT, SLOG_ERR, "send_and_wait get module_id %d fail\n",module_id);
+ SCLOGE("send_and_wait get module_id %d fail\n",module_id);
sprintf(rsp_buf,"%s","send at req fail\n");
return 1;
}
@@ -111,23 +113,23 @@
continue;
}
if(MODULE_ID_AT_CTL != rsp_msg.src_id) {
- slog(AT_API_PRINT, SLOG_ERR, "Drop unknow src_id(%d) msg!\n",rsp_msg.src_id);
+ SCLOGE("Drop unknow src_id(%d) msg!\n",rsp_msg.src_id);
continue;
}
if(MSG_CMD_AT_RSP == rsp_msg.usMsgCmd){
sprintf(rsp_buf, "%s", rsp_msg.aucDataBuf);
- slog(AT_API_PRINT, SLOG_DEBUG, "get rsp:%s!\n",rsp_msg.aucDataBuf);
+ SCLOGD("get rsp:%s!\n",rsp_msg.aucDataBuf);
/*ɾ³ýͨµÀ*/
ipc_send_message(module_id, MODULE_ID_AT_CTL, MSG_CMD_DEL_MSG_IS_FD,0, NULL, 0);
if(msgctl(my_handle,IPC_RMID,0) < 0)
- slog(AT_API_PRINT, SLOG_ERR, "%d:%s",errno,strerror(errno));
+ SCLOGE("%d:%s",errno,strerror(errno));
return 0;
}else if(MSG_CMD_ATCHN_STOP == rsp_msg.usMsgCmd){
/*ɾ³ýͨµÀ*/
ipc_send_message(module_id, MODULE_ID_AT_CTL, MSG_CMD_DEL_MSG_IS_FD,0, NULL, 0);
if(msgctl(my_handle,IPC_RMID,0) < 0)
- slog(AT_API_PRINT, SLOG_ERR, "%d:%s",errno,strerror(errno));
+ SCLOGE("%d:%s",errno,strerror(errno));
return 0;
}
}
@@ -137,10 +139,10 @@
void asyn_rcv_loop(void* arg)
{
struct at_asyn_list *patcc = (struct at_asyn_list*)arg;
- slog(AT_API_PRINT, SLOG_DEBUG, "async_recv_loop module_id:%d handle:%d at:%s \n",
+ SCLOGD("async_recv_loop module_id:%d handle:%d at:%s \n",
patcc->module_id, patcc->handle, patcc->at_str);
if(NULL == patcc) {
- slog(AT_API_PRINT, SLOG_ERR, "Err: asyn_rcv_loop Arg Invalid.\n");
+ SCLOGE("Err: asyn_rcv_loop Arg Invalid.\n");
return;
}
int iret = 0;
@@ -160,21 +162,21 @@
}
if(MODULE_ID_AT_CTL != rsp_msg.src_id ){
- slog(AT_API_PRINT, SLOG_ERR, "Drop unknow src_id(%d) msg!\n",rsp_msg.src_id);
+ SCLOGE("Drop unknow src_id(%d) msg!\n",rsp_msg.src_id);
continue;
}
if(MSG_CMD_AT_RSP == rsp_msg.usMsgCmd){
patcc->cb(patcc->sID, patcc->index, patcc->at_str, rsp_msg.aucDataBuf, 1);
patcc->flag = CMD_GET_RESULT;
- slog(AT_API_PRINT, SLOG_DEBUG, "asyn thread get cmd %s usMsgCmd:%d result %s", patcc->at_str, rsp_msg.usMsgCmd, rsp_msg.aucDataBuf);
+ SCLOGD("asyn thread get cmd %s usMsgCmd:%d result %s", patcc->at_str, rsp_msg.usMsgCmd, rsp_msg.aucDataBuf);
pthread_exit(0);
}else if(AT_TYPE_INFORM == rsp_msg.usMsgCmd){
- slog(AT_API_PRINT, SLOG_DEBUG, "AT_TYPE_INFORM %s get result %s\n",patcc->at_str, rsp_msg.aucDataBuf);
+ SCLOGD("AT_TYPE_INFORM %s get result %s\n",patcc->at_str, rsp_msg.aucDataBuf);
patcc->cb(patcc->sID, patcc->index, patcc->at_str, rsp_msg.aucDataBuf, 0);
}else if(MSG_CMD_ATCHN_STOP == rsp_msg.usMsgCmd){
ipc_send_message(patcc->module_id, MODULE_ID_AT_CTL, MSG_CMD_DEL_MSG_IS_FD,0, NULL, 0);
if(msgctl(patcc->handle,IPC_RMID,0) < 0)
- slog(AT_API_PRINT, SLOG_ERR, "%d:%s",errno,strerror(errno));
+ SCLOGE("%d:%s",errno,strerror(errno));
pthread_exit(0);
}
}
@@ -184,41 +186,43 @@
void asyn_snd_loop()
{
int handle=-1,module_id=MODULE_ID_ATDYNAMIC_BASE;
- slog(AT_API_PRINT, SLOG_DEBUG, "enter send_async\n");
- while(1)
+ while(g_asyn_thread)
{
if(errno == EINTR){
- slog(AT_API_PRINT, SLOG_ERR, "EINTR continue\n");
+ SCLOGE("EINTR continue\n");
continue;
}
- if(g_cur_chann_num < MAX_ASYNC_CHAN_NUM && g_cur_cmd_num > 0){
- slog(AT_API_PRINT, SLOG_ERR, "cur send condition g_cur_chann_num:%d g_cur_cmd_num:%d\n",g_cur_chann_num, g_cur_cmd_num);
- struct at_asyn_list* entry;
+ if(g_cur_cmd_num > 0 ){
pthread_mutex_lock(&g_sc_atsend_mutex);
- list_for_each_entry(entry, &g_asyn_cmd_list, list){
- if(g_cur_chann_num >= MAX_ASYNC_CHAN_NUM){
- slog(AT_API_PRINT, SLOG_ERR, "channel full\n");
- break;
- }
+ struct at_asyn_list* entry;
+ list_for_each_entry(entry, &g_asyn_cmd_list, list){
if(entry->flag == CMD_GET_RESULT){
- slog(AT_API_PRINT, SLOG_DEBUG, "asyn_snd_loop get CMD_GET_RESULT index %d flag %d module_id %d handle %d at %s\n",
+ SCLOGD("asyn_snd_loop get CMD_GET_RESULT index %d flag %d module_id %d handle %d at %s\n",
entry->index, entry->flag, module_id, handle, entry->at_str);
ipc_send_message(entry->module_id, MODULE_ID_AT_CTL, MSG_CMD_DEL_MSG_IS_FD,0, NULL, 0);
if(msgctl(entry->handle,IPC_RMID,0) < 0)
- slog(AT_API_PRINT, SLOG_ERR, "%d:%s",errno,strerror(errno));
+ SCLOGE("%d:%s",errno,strerror(errno));
list_del((struct list_head * )entry);
g_cur_chann_num--;
g_cur_cmd_num--;
break;
+ }
+ if(g_cur_chann_num >= MAX_ASYNC_CHAN_NUM){
+ SCLOGE("channel full\n");
+ break;
+ }
+ if(g_cur_cmd_num < 1){
+ SCLOGE("no comond to send\n");
+ break;
}
if(strlen(entry->at_str) != 0 && entry->flag == CMD_INSERTED_IN)
{
if(send_at_req(&module_id, &handle, entry->at_str) == -1){
- slog(AT_API_PRINT, SLOG_ERR, "get module_id %d fail\n", module_id);
+ SCLOGE("get module_id %d fail\n", module_id);
break;
}
entry->flag = CMD_SENT_TO_AT_CTL;
- slog(AT_API_PRINT, SLOG_ERR, "asyn_snd_loop send index %d flag %d module_id %d handle %d at %s\n",
+ SCLOGD("asyn_snd_loop send index %d flag %d module_id %d handle %d at %s\n",
entry->index, entry->flag, module_id, handle, entry->at_str);
entry->module_id = module_id;
entry->handle = handle;
@@ -228,7 +232,7 @@
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&attr, 128*1024);
if(0 != pthread_create(&stHandle, &attr, (void *)asyn_rcv_loop, (void*)entry)) {
- slog(AT_API_PRINT, SLOG_ERR, "async pthread_create fail!errnno %d.\n", errno);
+ SCLOGE("async pthread_create fail!errnno %d.\n", errno);
}else{
g_cur_chann_num++;
@@ -238,8 +242,11 @@
}
}
pthread_mutex_unlock(&g_sc_atsend_mutex);
- }
- }
+ }
+ }
+ sem_wait(&g_sc_atsend_sem);
+ sem_destroy(&g_sc_atsend_sem);
+ SCLOGI("asyn_snd_loop quit\n");
pthread_exit(0);
return;
}
@@ -259,7 +266,7 @@
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&attr, 128*1024);
if(0 != pthread_create(&g_asyn_thread, &attr, (void *)asyn_snd_loop, NULL)) {
- slog(AT_API_PRINT, SLOG_ERR, "async pthread_create fail!errnno %d.\n", errno);
+ SCLOGE("async pthread_create fail!errnno %d.\n", errno);
pthread_mutex_unlock(&g_sc_atsend_mutex);
return -1;
}
@@ -268,6 +275,7 @@
g_init_state=1;
g_deinit_state=0;
g_async_index=1;
+ sem_init(&g_sc_atsend_sem,0,0);
pthread_mutex_unlock(&g_sc_atsend_mutex);
return 1;
}
@@ -295,8 +303,9 @@
}
INIT_LIST_HEAD(&g_asyn_cmd_list);
g_deinit_state=1;
- pthread_cancel(g_asyn_thread);
+ g_asyn_thread=0;
g_sync_moduleId = -1;
+ sem_post(&g_sc_atsend_sem);
pthread_mutex_unlock(&g_sc_atsend_mutex);
return 1;
}
@@ -321,7 +330,7 @@
int sc_at_async_send(int sID, char* at_str, int* async_index, sc_at_async_cb at_cb)
{
assert(at_str && async_index && at_cb);
- slog(AT_API_PRINT, SLOG_DEBUG, "asyn send enter g_cur_chann_num %d g_cur_cmd_num %d\n",g_cur_chann_num, g_cur_cmd_num);
+ SCLOGD("asyn send enter g_cur_chann_num %d g_cur_cmd_num %d\n",g_cur_chann_num, g_cur_cmd_num);
pthread_mutex_lock(&g_sc_atsend_mutex);
if(g_cur_cmd_num < MAX_ASYNC_CMD_NUM){
struct at_asyn_list *node =(struct at_asyn_list *)malloc(sizeof(struct at_asyn_list));
@@ -332,14 +341,14 @@
node->index = *async_index;
node->cb = at_cb;
node->flag=CMD_INSERTED_IN;
- slog(AT_API_PRINT, SLOG_DEBUG, "asyn send index %d flag %d module %d handle %d at %s\n",
+ SCLOGD("asyn send index %d flag %d module %d handle %d at %s\n",
node->index, node->flag,node->module_id, node->handle, node->at_str);
list_add_tail((struct list_head *)node, &g_asyn_cmd_list);
g_cur_cmd_num++;
pthread_mutex_unlock(&g_sc_atsend_mutex);
return 0;
}else{
- slog(AT_API_PRINT, SLOG_DEBUG, "cmd list full,please send cmd later\n");
+ SCLOGD("cmd list full,please send cmd later\n");
pthread_mutex_unlock(&g_sc_atsend_mutex);
return 1;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/audio/sc_audio.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/audio/sc_audio.c
index 0512c08..61b6f17 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/audio/sc_audio.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/audio/sc_audio.c
@@ -1,3 +1,20 @@
+/**
+ * @file sc_audio.c
+ * @brief Implementation of the public APIs of libsctel.
+ *
+ * Copyright (C) 2023 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. £¨±ØÑ¡£ºGPLv2 Licence£©
+ *
+ */
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
@@ -13,6 +30,34 @@
#include <syslog.h>
#include <pthread.h>
+#include "sc_ipc.h"
+#include "sc_audio.h"
+#include "sc_tel_types.h"
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+/*******************************************************************************
+ * Local variable definitions *
+ ******************************************************************************/
+/*******************************************************************************
+ * Global variable definitions *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Local function declarations *
+ ******************************************************************************/
+/*******************************************************************************
+ * Local function implementations *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Global function implementations *
+ ******************************************************************************/
+
int sc_audio_init(void)
{
return 0;
@@ -22,3 +67,109 @@
{
return 0;
}
+
+sc_audio_handle_t sc_audio_playback_open(sc_audio_fe_pcm_dev_e fe_pcm_dev, unsigned int be_dai_mask)
+{
+ return SC_AUDIO_INVALID_HANDLE;
+}
+
+int sc_audio_playback_file_prepare(sc_audio_handle_t handle,
+ const char *file_name,
+ sc_audio_pcm_config_t *pcm_config,
+ sc_audio_playback_state_cb_f playback_state_cb,
+ void *params)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_playback_stream_prepare(sc_audio_handle_t handle,
+ sc_audio_pcm_config_t *pcm_config,
+ sc_audio_playback_state_cb_f playback_state_cb,
+ void *params)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_playback_play(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_playback_push_stream(sc_audio_handle_t handle, void *stream_buf, unsigned int buf_size)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_playback_pause(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_playback_resume(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_playback_stop(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_playback_close(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+void sc_audio_playback_get_state(sc_audio_handle_t handle, sc_audio_playback_state_e *playback_state)
+{
+}
+int sc_audio_playback_set_block_flag(sc_audio_handle_t handle, unsigned int flags)
+{
+ return SC_ERR_SUCCESS;
+}
+sc_audio_handle_t sc_audio_capture_open(sc_audio_fe_pcm_dev_e fe_pcm_dev, unsigned int be_dai_mask)
+{
+ return SC_AUDIO_INVALID_HANDLE;
+}
+int sc_audio_capture_file_prepare(sc_audio_handle_t handle,
+ const char *file_name,
+ sc_audio_stream_format_e type,
+ sc_audio_pcm_config_t *pcm_config,
+ sc_audio_capture_state_cb_f capture_state_cb,
+ void *params)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_capture_stream_prepare(sc_audio_handle_t handle,
+ sc_audio_pcm_config_t *pcm_config,
+ sc_audio_capture_state_cb_f capture_state_cb,
+ void *params)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_capture_record(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_capture_pull_stream(sc_audio_handle_t handle, void *stream_buf, unsigned int buf_size)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_capture_pause(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_capture_resume(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_capture_stop(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+int sc_audio_capture_close(sc_audio_handle_t handle)
+{
+ return SC_ERR_SUCCESS;
+}
+void sc_audio_capture_get_state(sc_audio_handle_t handle, sc_audio_capture_state_e *capture_state)
+{
+}
+int sc_audio_set_service_error_cb(sc_audio_service_error_cb_f cb)
+{
+ return SC_ERR_SUCCESS;
+}
+
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/call/sc_call.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/call/sc_call.c
index 7907896..36eadd5 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/call/sc_call.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/call/sc_call.c
@@ -289,7 +289,7 @@
int i;
sc_ipc_event *pevt;
- sc_ipc_start_loop(NULL);
+ sc_ipc_start_loop("sc-call");
/* ×¢²áÖ÷¶¯Éϱ¨ÏûÏ¢´¦Àí*/
for(i = 0; i < sizeof(cc_auto_notify_evt) / sizeof(sc_ipc_event); i ++) {
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/data/sc_data.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/data/sc_data.c
index f3c2742..a4255cb 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/data/sc_data.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/data/sc_data.c
@@ -116,6 +116,7 @@
rsp->act_info.ip46flag = V46_VALID;
}
}
+ rsp->result = ret;
return ret;
}
@@ -210,7 +211,7 @@
temp->action = 0;
temp->state = state;
memcpy(&temp->rsp, p_rsp, sizeof(temp->rsp));
- if(is_act && temp->time_num){
+ if(is_act && temp->time_num && temp->rsp.result != SC_DATA_ERR_NORMAL_ACT_EXIST){
if(state){
temp->time_num_now = 0;
if(temp->req.act_type == SCDATA_ACT_TYPE_NORMAL)
@@ -289,7 +290,7 @@
state = 1;
scdata_call_ind_proc(id, state, &rsp, 1);
}else if(action == SCDATA_ACTION_DODEACT){
- scdata_deact_by_cid(cid);
+ temp->rsp.result = scdata_deact_by_cid(cid);
scdata_call_ind_proc(id, state, &rsp, 0);
}
}while(id);
@@ -348,6 +349,7 @@
INIT_LIST_HEAD(&g_sc_datacall_list);
g_sc_datacall_thread = 0;
unreg_at_info_func("CGEV");
+ g_sc_datacall_default = NULL;
sem_post(&g_sc_datacall_sem);
pthread_mutex_unlock(&g_sc_datacall_mutex);
return SC_ERR_SUCCESS;
@@ -413,8 +415,9 @@
}
if(temp->req.act_type == SCDATA_ACT_TYPE_NORMAL &&
g_sc_datacall_default && g_sc_datacall_default != temp){
+ temp->rsp.result = SC_DATA_ERR_NORMAL_ACT_EXIST;
pthread_mutex_unlock(&g_sc_datacall_mutex);
- return SC_ERR_FAIL;
+ return SC_DATA_ERR_NORMAL_ACT_EXIST;
}
if(async){
temp->action = SCDATA_ACTION_DOACT;
@@ -467,7 +470,7 @@
pthread_mutex_unlock(&g_sc_datacall_mutex);
return SC_ERR_SUCCESS;
}
- scdata_deact_by_cid(temp->rsp.c_id);
+ temp->rsp.result = scdata_deact_by_cid(temp->rsp.c_id);
if(temp == g_sc_datacall_default)
g_sc_datacall_default = NULL;
temp->state = 0;
@@ -695,7 +698,7 @@
unsigned short id = 0;
if(g_sc_datacall_thread == 0){
SCLOGE("sc_data not init");
- return SC_ERR_FAIL;
+ return 0;
}
pthread_mutex_lock(&g_sc_datacall_mutex);
if(g_sc_datacall_default)
@@ -705,3 +708,19 @@
return id;
}
+int sc_data_call_get_default_cid(void)
+{
+ int cid = 0;
+ char name[40] = {0};
+ char value[40] = {0};
+ void *p[] = {name, value};
+
+ get_modem_info("AT+ZNVGET=\"default_cid\"\r\n", "%s,%s", (void **)p);
+
+ cid = atoi(value);
+
+ SCLOGI("sc_data_call_get_default_cid=%d\n", cid);
+
+ return cid;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_at.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_at.h
index 623cabd..f6ce071 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_at.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_at.h
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include "sc_ipc.h"
#ifdef __cplusplus
extern "C" {
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_audio.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_audio.h
index 28d0236..32a047e 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_audio.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_audio.h
@@ -29,12 +29,202 @@
/*******************************************************************************
* Macro definitions *
******************************************************************************/
+/**
+ * @brief audioÉÏÏÂÎÄÎÞЧ¾ä±ú
+ */
+#define SC_AUDIO_INVALID_HANDLE (0)
-
+#define SC_AUDIO_PLAYBACK_BLOCK (1)
+#define SC_AUDIO_PLAYBACK_NONBLOCK (0)
/*******************************************************************************
* Type definitions *
******************************************************************************/
+/**
+ * @brief audioÉÏÏÂÎľä±ú
+ */
+typedef long sc_audio_handle_t;
+/**
+ * @brief ǰ¶Ë PCM É豸ÀàÐÍö¾Ù¶¨Òå
+ */
+typedef enum _sc_audio_fe_pcm_dev_e{
+ /*PCMÉ豸×îСֵ£¬ÎÞЧֵ*/
+ SC_AUDIO_FE_PCM_DEV_MIN = -1,
+ /*Ò»°ãÒôƵ²¥·Å¡¢²¶»ñ¿ÉÓõĵÚÒ»¸ö PCM É豸*/
+ SC_AUDIO_FE_PCM_DEV_MULTIMEDIA1 = 0,
+ /*Ò»°ãÒôƵ²¥·Å¡¢²¶»ñ¿ÉÓõĵڶþ¸ö PCM É豸*/
+ SC_AUDIO_FE_PCM_DEV_MULTIMEDIA2,
+ /*Ò»°ãÒôƵ²¥·Å¡¢²¶»ñ¿ÉÓõĵÚÈý¸ö PCM É豸*/
+ SC_AUDIO_FE_PCM_DEV_MULTIMEDIA3,
+ /*רÓÃÓڵ绰ÁåÉùÎļþ²¥·ÅµÄ PCM É豸*/
+ SC_AUDIO_FE_PCM_DEV_VOICE_SERVICE,
+ /*PCMÉ豸×î´óÖµ£¬ÎÞЧֵ*/
+ SC_AUDIO_FE_PCM_DEV_MAX
+}sc_audio_fe_pcm_dev_e;
+
+/**
+ * @brief ºó¶Ë DAI ÀàÐÍö¾Ù¶¨Òå
+ */
+typedef enum _sc_audio_be_dai_e {
+ /*×îСֵ£¬ÎÞЧ*/
+ SC_AUDIO_BE_DAI_MIN = -1,
+ /*½«ÒôƵ²¥·Åµ½µÚһ· PCM ½Ó¿Ú*/
+ SC_AUDIO_BE_DAI_PLAYBACK_PRI_PCM = 0,
+ /*½«ÒôƵ²¥·Åµ½µÚ¶þ· PCM ½Ó¿Ú*/
+ SC_AUDIO_BE_DAI_PLAYBACK_SEC_PCM,
+ /*½«ÒôƵ²¥·Åµ½µÚһ· I2S ½Ó¿Ú*/
+ SC_AUDIO_BE_DAI_PLAYBACK_PRI_I2S,
+ /*½«ÒôƵ²¥·Åµ½µÚ¶þ· I2S ½Ó¿Ú*/
+ SC_AUDIO_BE_DAI_PLAYBACK_SEC_I2S,
+ /*½«ÒôƵ²¥·Åµ½ÓïÒôͨ»°ÉÏÐÐÁ´Â·*/
+ SC_AUDIO_BE_DAI_PLAYBACK_VOICE_TX,
+ /*½«ÒôƵ²¥·Åµ½ÒôƵǰ¶Ë*/
+ SC_AUDIO_BE_DAI_PLAYBACK_AFE,
+ /*Ôݲ»Ö§³Ö*/
+ SC_AUDIO_BE_DAI_PLAYBACK_BT,
+ /*Ôݲ»Ö§³Ö*/
+ SC_AUDIO_BE_DAI_PLAYBACK_USB,
+ /*Ôݲ»Ö§³Ö*/
+ SC_AUDIO_BE_DAI_PLAYBACK_EAVB,
+ /*´ÓµÚһ· PCM ½Ó¿Ú²¶»ñÒôƵ*/
+ SC_AUDIO_BE_DAI_CAPTURE_PRI_PCM,
+ /*´ÓµÚ¶þ· PCM ½Ó¿Ú²¶»ñÒôƵ*/
+ SC_AUDIO_BE_DAI_CAPTURE_SEC_PCM,
+ /*´ÓµÚһ· I2S ½Ó¿Ú²¶»ñÒôƵ*/
+ SC_AUDIO_BE_DAI_CAPTURE_PRI_I2S,
+ /*´ÓµÚ¶þ· I2S ½Ó¿Ú²¶»ñÒôƵ*/
+ SC_AUDIO_BE_DAI_CAPTURE_SEC_I2S,
+ /*´ÓÓïÒôͨ»°ÉÏÐÐÁ´Â·²¶»ñÓïÒôÁ÷*/
+ SC_AUDIO_BE_DAI_CAPTURE_VOICE_UL,
+ /*´ÓÓïÒôͨ»°ÏÂÐÐÁ´Â·²¶»ñÓïÒôÁ÷*/
+ SC_AUDIO_BE_DAI_CAPTURE_VOICE_DL,
+ /*´ÓÒôƵǰ¶Ë²¶»ñÒôƵ*/
+ SC_AUDIO_BE_DAI_CAPTURE_AFE,
+ /*Ôݲ»Ö§³Ö*/
+ SC_AUDIO_BE_DAI_CAPTURE_BT,
+ /*Ôݲ»Ö§³Ö*/
+ SC_AUDIO_BE_DAI_CAPTURE_USB,
+ /*Ôݲ»Ö§³Ö*/
+ SC_AUDIO_BE_DAI_CAPTURE_EAVB,
+ /*×î´óÖµ£¬ÎÞЧ*/
+ SC_AUDIO_BE_DAI_MAX
+}sc_audio_be_dai_e;
+
+/**
+ * @brief ÒôƵ²¥·Å״̬ö¾Ù¶¨Òå
+ */
+typedef enum _sc_audio_playback_state_e {
+ /*¹Ø±Õ״̬*/
+ SC_AUDIO_PLAYBACK_STATE_CLOSE = 0,
+ /*´ò¿ª×´Ì¬*/
+ SC_AUDIO_PLAYBACK_STATE_OPEN,
+ /*¾ÍÐ÷״̬*/
+ SC_AUDIO_PLAYBACK_STATE_PREPARE,
+ /*²¥·Å״̬*/
+ SC_AUDIO_PLAYBACK_STATE_PLAYING,
+ /*Íê³É״̬*/
+ SC_AUDIO_PLAYBACK_STATE_FINISHED,
+ /*ÔÝͣ״̬*/
+ SC_AUDIO_PLAYBACK_STATE_PAUSE,
+ /*³ö´í״̬*/
+ SC_AUDIO_PLAYBACK_STATE_ERROR,
+} sc_audio_playback_state_e;
+
+/**
+ * @brief ÒôƵÁ÷¸ñʽö¾Ù¶¨Òå
+ */
+typedef enum _sc_audio_stream_format_e {
+ /*PCM ¸ñʽ*/
+ SC_AUDIO_STREAM_FORMAT_PCM = 1,
+ /*MP3 ¸ñʽ*/
+ SC_AUDIO_STREAM_FORMAT_MP3,
+ /*AMR ¸ñʽ*/
+ SC_AUDIO_STREAM_FORMAT_AMR,
+ /*AMR-NB ¸ñʽ*/
+ SC_AUDIO_STREAM_FORMAT_AMRNB,
+ /*AMR-WB ¸ñʽ*/
+ SC_AUDIO_STREAM_FORMAT_AMRWB,
+} sc_audio_stream_format_e;
+
+/**
+ * @brief ÒôƵ²¶»ñ״̬ö¾Ù¶¨Òå
+ */
+typedef enum _sc_audio_capture_state_e {
+ SC_AUDIO_CAPTURE_STATE_CLOSE = 0,
+ SC_AUDIO_CAPTURE_STATE_OPEN,
+ SC_AUDIO_CAPTURE_STATE_PREPARE,
+ SC_AUDIO_CAPTURE_STATE_CAPTURING,
+ SC_AUDIO_CAPTURE_STATE_FINISHED,
+ SC_AUDIO_CAPTURE_STATE_PAUSE,
+ SC_AUDIO_CAPTURE_STATE_ERROR,
+} sc_audio_capture_state_e;
+
+/**
+ * @brief PCM ÅäÖòÎÊý½á¹¹Ì嶨Òå
+ */
+typedef struct sc_audio_pcm_config_struct
+{
+ /*ÿ¸öÉù¿¨¶¼»áά»¤Ò»¸öÓ²¼þ»º³åÇøÀ´±£´æÒôƵÊý¾Ý£¬Ó²¼þ»º³å
+ ÇøÓÖ±»»®·Ö³ÉÈô¸É¸ö period£¬Éù¿¨ÒÔ period Ϊµ¥ÔªÀ´´«ÊäÊý¾Ý£¬
+ Ò»¸ö period ´æ´¢Ò»Ð©Êý¾ÝÖ¡¡£
+ period_size ÓÃÓÚÉèÖÃÓ²¼þ»º³åÇø period ´óС£¬µ± period_size
+ ÉèÖÃΪ 0 ʱ£¬±íʾӲ¼þ»º³åÇøµÄ period ´óСÓÉµ×²ã¼ÆËãµÃ³öÒ»
+ ¸öĬÈÏÖµ£»Èô period_size ²»Îª 0£¬½¨ÒéȡֵΪ 128~960£¬
+ perod_size Ô½´ó±íʾÄں˿ªÏúÔ½´ó
+ */
+ unsigned int period_size;
+ /*±íʾӦÓóÌÐò´ÓÓ²¼þ»º³åÇø¶ÁÈ¡µÄÊý¾ÝËùÕ¼ÓÃµÄ period ¸öÊý£¬
+ »òÕßÏòÓ²¼þ»º³åÇøÐ´ÈëµÄÊý¾ÝËùÕ¼ÓÃµÄ period ¸öÊý¡£
+ Ó¦ÓóÌÐò¿ÉÒÔÿ´Î´ÓÓ²¼þ»º³åÇø¶ÁÈ¡£¨¼´²¶»ñÒôƵ£©»òÕßÿ´Îд
+ Èëµ½Ó²¼þ»º³åÇø£¨Ò²¼´²¥·ÅÒôƵ£©period_count ³ËÒÔ period_size
+ ´óСµÄÊý¾Ý¡£Ó²¼þ»º³åÇøÄ¬ÈÏ×î¶àÓÐ 8 ¸ö period£»½¨Òé
+ period_count µÄȡֵΪ 1~3¡£
+ */
+ unsigned int period_count;
+ /*PCM ±ê־λ¡£Ä¿Ç°½öÖ§³Ö 0*/
+ unsigned int flags;
+ /*ÉùµÀÊý¡£ 1 µ¥ÉùµÀ 2 Ë«ÉùµÀ */
+ unsigned int num_channels;
+ /*²ÉÑùÂÊ¡£PCM ½Ó¿ÚÖ§³Ö 8000 ºÍ 16000£»I2S ½Ó¿Ú¿ÉÖ§³Ö 48000£»µ¥Î»£ºHz*/
+ unsigned int sample_rate;
+ /*PCM Êý¾Ý¸ñʽ¡£Ä¿Ç°½öÖ§³Öȡֵ 2£¬±íʾ 16 bit С¶Ë¸ñʽ¡£*/
+ unsigned int pcm_format;
+} sc_audio_pcm_config_t;
+
+/**
+ * @brief Éϱ¨µ±Ç°²¥·Å״̬»Øµ÷º¯Êý¶¨Òå¡£
+ * @param (in) handle ²¥·Å¾ä±ú¡£Îª sc_audio_playback_open()µÄ·µ»ØÖµ¡£
+ * @param (in) params »Øµ÷º¯ÊýЯ´øµÄ²ÎÊý¡£
+ * @param (in) state µ±Ç°µÄÒôƵ²¥·Å״̬¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+typedef int (*sc_audio_playback_state_cb_f)(sc_audio_handle_t handle, void *params, sc_audio_playback_state_e state);
+/**
+ * @brief Éϱ¨ÒôƵ²¶»ñ״̬»Øµ÷º¯Êý¶¨Òå¡£
+ * @param (in) handle ²¶»ñ¾ä±ú¡£Îª sc_audio_capture_open()µÄ·µ»ØÖµ¡£
+ * @param (in) params »Øµ÷º¯ÊýЯ´øµÄ²ÎÊý¡£
+ * @param (in) state µ±Ç°µÄÒôƵ²¶»ñ״̬¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+typedef int (*sc_audio_capture_state_cb_f)(sc_audio_handle_t handle, void *params, sc_audio_capture_state_e state);
+
+/**
+ * @brief ´¦ÀíÒôƵ·þÎñÒì³£»Øµ÷º¯Êý¡£
+ * @param (in) error ´íÎóÂë¡£
+ * @param (out) ÎÞ¡£
+ * @return ÎÞ¡£
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+typedef void (*sc_audio_service_error_cb_f)(int error);
/*******************************************************************************
* Global variable declarations *
@@ -64,7 +254,257 @@
* ×¢ÊÍ¡£
*/
int sc_audio_uninit(void);
+/**
+ * @brief ´ò¿ªÒôƵ²¥·ÅÉÏÏÂÎÄ¡£
+ * @param (in) fe_pcm_dev ǰ¶Ë PCM É豸ÀàÐÍ¡£
+ * @param (in) be_dai_mask ºó¶Ë DAI ÑÚÂë¡£¸ÃÈë²Î±£Áô¡£
+ * @param (out) ÎÞ¡£
+ * @return ·µ»ØÒ»¸öÓÐЧ¾ä±ú ´ò¿ªÒôƵ²¥·ÅÉÏÏÂÎijɹ¦¡£
+ * SC_AUDIO_INVALID_HANDLE ´ò¿ªÒôƵ²¥·ÅÉÏÏÂÎÄʧ°Ü£¬ÎÞЧ¾ä±ú¡£
+ * @note
+ */
+sc_audio_handle_t sc_audio_playback_open(sc_audio_fe_pcm_dev_e fe_pcm_dev, unsigned int be_dai_mask);
+/**
+ * @brief ½øÐв¥·ÅÒôƵÎļþ֮ǰµÄ×¼±¸¹¤×÷¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (in) file_name ´ý²¥·ÅµÄÎļþÃû¡£
+ * @param (in) pcm_config PCM ÅäÖòÎÊý¡£Ò»°ãÖ¸¶¨Îª NULL£¬±íʾ²ÉÓÃĬÈÏÖµ¡£
+ * @param (in) playback_state_cb ÒôƵ²¥·Å״̬»Øµ÷º¯Êý£¬Éϱ¨µ±Ç°µÄ²¥·Å״̬¡£
+ * @param (in) params »Øµ÷º¯ÊýЯ´øµÄ²ÎÊý¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note
+ * 1. µ÷Óøú¯Êý֮ǰ£¬±ØÐëÏȵ÷Óà sc_audio_playback_open()¡£
+ * 2. Èô ÆÚ Íû ²¥ ·Å Òô Ƶ ÎÄ ¼þ £¬ Ôò Ðè ÏÈ µ÷ Óà ¸Ã º¯ Êý ×ö ºÃ ²¥ ·Å Òô Ƶ ÎÄ ¼þ Ö® ǰ µÄ ×¼ ±¸ ¹¤ ×÷ £¬ ÔÙ µ÷ ÓÃ
+ * sc_audio_playback_play()¿ªÊ¼²¥·ÅÒôƵÊý¾Ý¡£
+ */
+int sc_audio_playback_file_prepare(sc_audio_handle_t handle,
+ const char *file_name,
+ sc_audio_pcm_config_t *pcm_config,
+ sc_audio_playback_state_cb_f playback_state_cb,
+ void *params);
+/**
+ * @brief ½øÐв¥·ÅÒôƵÁ÷֮ǰµÄ×¼±¸¹¤×÷¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (in) pcm_config PCM ÅäÖòÎÊý¡£Ò»°ãÖ¸¶¨Îª NULL£¬±íʾ²ÉÓÃĬÈÏÖµ¡£
+ * @param (in) playback_state_cb ÒôƵ²¥·Å״̬»Øµ÷º¯Êý£¬Éϱ¨µ±Ç°µÄ²¥·Å״̬¡£
+ * @param (in) params »Øµ÷º¯ÊýЯ´øµÄ²ÎÊý¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note
+ * 1. µ÷Óøú¯Êý֮ǰ£¬±ØÐëÏȵ÷Óà sc_audio_playback_open()¡£
+ * 2. Èô ÆÚ Íû ²¥ ·Å Ò» ¶Î Òô Ƶ Á÷ £¬ Ôò Ðè ÏÈ µ÷ Óà ¸Ã º¯ Êý ×ö ºÃ ²¥ ·Å Òô Ƶ Á÷ Ö® ǰ µÄ ×¼ ±¸ ¹¤ ×÷ £¬ ÔÙ µ÷ ÓÃ
+ * sc_audio_playback_push_stream()¿ªÊ¼²¥·ÅÒôƵÁ÷Êý¾Ý¡£
+*/
+
+int sc_audio_playback_stream_prepare(sc_audio_handle_t handle,
+ sc_audio_pcm_config_t *pcm_config,
+ sc_audio_playback_state_cb_f playback_state_cb,
+ void *params);
+/**
+ * @brief ¿ªÊ¼²¥·ÅÒôƵÊý¾Ý¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_audio_playback_play(sc_audio_handle_t handle);
+/**
+ * @brief ²¥·Å»º³åÇøÖеÄÒôƵÁ÷Êý¾Ý¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (in) stream_buf ´æ·Å´ý²¥·ÅÒôƵÁ÷Êý¾ÝµÄ»º³åÇø¡£
+ * @param (in) buf_size ´ý²¥·ÅµÄÒôƵÁ÷Êý¾Ý´óС¡£µ¥Î»£º×Ö½Ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_audio_playback_push_stream(sc_audio_handle_t handle, void *stream_buf, unsigned int buf_size);
+/**
+ * @brief ÔÝÍ£ÒôƵ²¥·Å¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_audio_playback_pause(sc_audio_handle_t handle);
+/**
+ * @brief »Ö¸´ÒôƵ²¥·Å¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_audio_playback_resume(sc_audio_handle_t handle);
+/**
+ * @brief Í£Ö¹ÒôƵ²¥·Å¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ÈôÒôƵ´¦ÓÚ²¥·Å״̬»òÕßÔÝͣ״̬£¬µ÷Óøú¯Êý¶¼»á½áÊøÒôƵ²¥·Å£¬ÇÒÎÞ·¨»Ö¸´¡£
+ */
+int sc_audio_playback_stop(sc_audio_handle_t handle);
+/**
+ * @brief ¹Ø±ÕÒôƵ²¥·ÅÉÏÏÂÎÄ¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ÒôƵ²¥·Å½áÊøºó£¬±ØÐëµ÷Óøú¯Êý¹Ø±ÕÒôƵ²¥·ÅÉÏÏÂÎÄ£¬·ñÔò»áÓ°ÏìºóÐø ql_audio_playback_open()µÄÕý³£µ÷Óá£
+ */
+int sc_audio_playback_close(sc_audio_handle_t handle);
+/**
+ * @brief »ñÈ¡ÒôƵ²¥·Å״̬¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) playback_state µ±Ç°µÄÒôƵ²¥·Å״̬¡£
+ * @return ÎÞ¡£
+ * @note
+ */
+void sc_audio_playback_get_state(sc_audio_handle_t handle, sc_audio_playback_state_e *playback_state);
+/**
+ * @brief ÉèÖÃÒôƵ²¥·Å×èÈû״̬¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_playback_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) flags ×èÈû±êÖ¾¡£
+ * SC_AUDIO_PLAYBACK_BLOCK ×èÈû£»
+ * SC_AUDIO_PLAYBACK_NONBLOCK ·Ç×èÈû¡£
+ * @return ÎÞ¡£
+ * @note
+ */
+int sc_audio_playback_set_block_flag(sc_audio_handle_t handle, unsigned int flags);
+/**
+ * @brief ´ò¿ªÒôƵ²¶»ñÉÏÏÂÎÄ¡£
+ * @param (in) fe_pcm_dev ǰ¶Ë PCM É豸ÀàÐÍ¡£
+ * @param (in) be_dai_mask ºó¶Ë DAI ÑÚÂë¡£¸ÃÈë²Î±£Áô¡£
+ * @param (out) ÎÞ¡£
+ * @return ·µ»ØÒ»¸öÓÐЧ¾ä±ú º¯ÊýÖ´Ðгɹ¦¡£
+ * SC_AUDIO_INVALID_HANDLE º¯ÊýÖ´ÐÐʧ°Ü£¬ÎÞЧ¾ä±ú¡£
+ * @note
+ */
+sc_audio_handle_t sc_audio_capture_open(sc_audio_fe_pcm_dev_e fe_pcm_dev, unsigned int be_dai_mask);
+/**
+ * @brief ½øÐв¶»ñÒôƵÎļþ֮ǰµÄ×¼±¸¹¤×÷¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (in) file_name ´ý²¥·ÅµÄÎļþÃû¡£
+ * @param (in) type ÒôƵÎļþÖÐÒôƵÊý¾ÝµÄ¸ñʽ¡£
+ * @param (in) pcm_config PCM ÅäÖòÎÊý¡£Ò»°ãÖ¸¶¨Îª NULL£¬±íʾ²ÉÓÃĬÈÏÖµ¡£
+ * @param (in) capture_state_cb ÒôƵ²¶»ñ״̬»Øµ÷º¯Êý¡£Éϱ¨µ±Ç°µÄ²¶»ñ״̬¡£
+ * @param (in) params »Øµ÷º¯ÊýЯ´øµÄ²ÎÊý¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note
+ * 1. µ÷Óøú¯Êý֮ǰ£¬±ØÐëÏȵ÷Óà sc_audio_capture_open()¡£
+ * 2. Èô ÆÚ Íû ²¶ »ñ Òô Ƶ ÎÄ ¼þ £¬ Ôò Ðè ÏÈ µ÷ Óà ¸Ã º¯ Êý ×ö ºÃ ²¶ »ñ Òô Ƶ ÎÄ ¼þ Ö® ǰ µÄ ×¼ ±¸ ¹¤ ×÷ £¬ ÔÙ µ÷ ÓÃ
+ * sc_audio_capture_record()¿ªÊ¼²¶»ñÒôƵÊý¾Ý
+ */
+int sc_audio_capture_file_prepare(sc_audio_handle_t handle,
+ const char *file_name,
+ sc_audio_stream_format_e type,
+ sc_audio_pcm_config_t *pcm_config,
+ sc_audio_capture_state_cb_f capture_state_cb,
+ void *params);
+/**
+ * @brief ½øÐв¶»ñÒôƵÁ÷֮ǰµÄ×¼±¸¹¤×÷¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (in) type ÒôƵÎļþÖÐÒôƵÊý¾ÝµÄ¸ñʽ¡£
+ * @param (in) pcm_config PCM ÅäÖòÎÊý¡£Ò»°ãÖ¸¶¨Îª NULL£¬±íʾ²ÉÓÃĬÈÏÖµ¡£
+ * @param (in) capture_state_cb ÒôƵ²¶»ñ״̬»Øµ÷º¯Êý¡£Éϱ¨µ±Ç°µÄ²¶»ñ״̬¡£
+ * @param (in) params »Øµ÷º¯ÊýЯ´øµÄ²ÎÊý¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note
+ * 1. µ÷Óøú¯Êý֮ǰ£¬±ØÐëÏȵ÷Óà sc_audio_capture_open()¡£
+ * 2. Èô ÆÚ Íû ²¶ »ñ Ò» ¶Î Òô Ƶ Á÷ £¬ Ôò Ðè ÏÈ µ÷ Óà ¸Ã º¯ Êý ×ö ºÃ ²¶ »ñ Òô Ƶ Á÷ Ö® ǰ µÄ ×¼ ±¸ ¹¤ ×÷ £¬ ÔÙ µ÷ ÓÃ
+ * sc_audio_capture_push_stream()¿ªÊ¼²¶»ñÒôƵÁ÷Êý¾Ý¡£
+ */
+int sc_audio_capture_stream_prepare(sc_audio_handle_t handle,
+ sc_audio_pcm_config_t *pcm_config,
+ sc_audio_capture_state_cb_f capture_state_cb,
+ void *params);
+/**
+ * @brief ¿ªÊ¼²¶»ñÒôƵÊý¾Ý¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note
+ */
+int sc_audio_capture_record(sc_audio_handle_t handle);
+/**
+ * @brief ²¶»ñÒôƵÁ÷Êý¾Ýµ½»º³åÇøÖС£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (in) buf_size »º³åÇø´óС¡£µ¥Î»£º×Ö½Ú¡£
+ * @param (out) stream_buf ´æ·Å´ý²¶»ñÒôƵÁ÷Êý¾ÝµÄ»º³åÇø¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note
+ */
+int sc_audio_capture_pull_stream(sc_audio_handle_t handle, void *stream_buf, unsigned int buf_size);
+/**
+ * @brief ÔÝÍ£ÒôƵ²¶»ñ¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note
+ */
+int sc_audio_capture_pause(sc_audio_handle_t handle);
+/**
+ * @brief »Ö¸´ÒôƵ²¶»ñ¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note
+ */
+int sc_audio_capture_resume(sc_audio_handle_t handle);
+/**
+ * @brief Í£Ö¹ÒôƵ²¶»ñ¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ÈôÒôƵ´¦ÓÚ²¶»ñ״̬»òÕßÔÝͣ״̬£¬µ÷Óøú¯Êý½«»á½áÊøÒôƵ²¶»ñ£¬ÇÒÎÞ·¨»Ö¸´¡£
+ */
+int sc_audio_capture_stop(sc_audio_handle_t handle);
+/**
+ * @brief ¹Ø±ÕÒôƵ²¶»ñÉÏÏÂÎÄ¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ÒôƵ²¶»ñ½áÊøºó£¬±ØÐëµ÷Óøú¯Êý¹Ø±ÕÒôƵ²¶»ñÉÏÏÂÎÄ£¬·ñÔò»áÓ°ÏìºóÐø sc_audio_capture_open()µÄÕý
+ * ³£µ÷Óá£
+ */
+int sc_audio_capture_close(sc_audio_handle_t handle);
+/**
+ * @brief »ñÈ¡µ±Ç°µÄÒôƵ²¶»ñ״̬¡£
+ * @param (in) handle Óɺ¯Êý sc_audio_capture_open()·µ»ØµÄ¾ä±ú¡£
+ * @param (out) capture_state µ±Ç°µÄÒôƵ²¶»ñ״̬¡£
+ * @return ÎÞ¡£
+ * @note
+ */
+void sc_audio_capture_get_state(sc_audio_handle_t handle, sc_audio_capture_state_e *capture_state);
+/**
+ * @brief ÉèÖÃÒôƵ·þÎñÒì³£»Øµ÷º¯Êý¡£
+ * @param (in) cb ÒôƵ·þÎñÒì³£»Øµ÷º¯Êý¡£
+ * @param (out) ÎÞ¡£
+ * @return ÎÞ¡£
+ * @note
+ */
+int sc_audio_set_service_error_cb(sc_audio_service_error_cb_f cb);
#ifdef __cplusplus
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_data.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_data.h
index 5f5c65b..22b19be 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_data.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_data.h
@@ -52,6 +52,11 @@
*/
#define MAX_TIME_LIST 20
+/**
+ * @brief ĬÈϲ¦ºÅºÍĬÈÏ·ÓÉÒÑ´æÔÚ
+ */
+#define SC_DATA_ERR_NORMAL_ACT_EXIST 8002
+
/*******************************************************************************
* Type definitions *
******************************************************************************/
@@ -81,7 +86,7 @@
* @brief ¶¨Òå×éÍøÀàÐÍ
* @param SCDATA_ACT_TYPE_NULL ³õʼֵ£¬²»×éÍø
* @param SCDATA_ACT_TYPE_LOCAL ±¾µØ²¦ºÅ,ÐèÒªbind¶ÔÓ¦IP»òÍø¿Ú½øÐÐͨѶ
-* @param SCDATA_ACT_TYPE_NORMAL ĬÈϲ¦ºÅ,Æô¶¯Ä¬ÈÏ·ÓÉ,É豸ËùÓÐÓ¦Óö¼¿ÉÒÔÖ±½ÓÉÏÎç,Ö»Äܲ¥Ò»Â·
+* @param SCDATA_ACT_TYPE_NORMAL ĬÈϲ¦ºÅ,Æô¶¯Ä¬ÈÏ·ÓÉ,É豸ËùÓÐÓ¦Óö¼¿ÉÒÔÖ±½ÓÉÏÍø,Ö»Äܲ¥Ò»Â·
*/
typedef enum {
SCDATA_ACT_TYPE_NULL = 0,
@@ -118,10 +123,10 @@
/**
* @brief ¶¨ÒåPDP¼¤»îÀàÐÍ
-* @param SCDATA_V4V6_INVALID ³õʼֵ£¬²»½øÐÐÈκβÙ×÷
-* @param SCDATA_V4_VALID ¶ÔV4½øÐвÙ×÷£¬°üÀ¨¼¤»îºÍÈ¥»î
-* @param SCDATA_V6_VALID ¶ÔV6½øÐвÙ×÷£¬°üÀ¨¼¤»îºÍÈ¥»î
-* @param SCDATA_V46_VALID ¶ÔV4ºÍV6½øÐвÙ×÷£¬°üÀ¨¼¤»îºÍÈ¥»î
+* @param SCDATA_V4V6_INVALID ³õʼֵ£¬Î´²¦ºÅ
+* @param SCDATA_V4_VALID V4ÒѼ¤»î²¦ºÅ
+* @param SCDATA_V6_VALID V6ÒѼ¤»î²¦ºÅ
+* @param SCDATA_V46_VALID V4ºÍV6ÒѼ¤»î²¦ºÅ
*/
typedef enum {
SCDATA_V4V6_INVALID = 0,
@@ -159,12 +164,14 @@
* @brief pdp¼¤»îÏìÓ¦ÐÅÏ¢£¬ÓÃÓÚÍâÍø¿Ú£¬ÆäÖÐcidÓÃÓÚʶ±ð²»Í¬µÄÍâÍø¿Ú
* @param c_id PDPΨһ±êʶ
* @param pdp_type pdp ¼¤»îÀàÐÍ
+ * @param result pdp ¼¤»î»òÈ¥¼¤»î²Ù×÷µÄ½á¹ûÂë
* @param act_info Íø¿ÚµØÖ·µÈÐÅÏ¢
* @note pdp_type µÄȡֵ²Î¼ûscdata_act_type_t
*/
typedef struct sc_pdp_act_rsp_info {
int c_id;
int pdp_type;
+ int result;
struct sc_netdev_act_info act_info;
} sc_pdp_act_rsp_info_t;
@@ -305,7 +312,7 @@
int sc_data_call_start(unsigned short id, int async);
/**
- * @brief ·¢ÆðÊý¾ÝÈ¥²¦ºÅ
+ * @brief ¶Ï¿ªÊý¾ÝÁ¬½ÓÈ¥²¦ºÅ
* @param (in) id ±êʶ
* @param (in) async ÊÇ·ñÒ첽ȥ²¦ºÅ
* @param (out) ÎÞ
@@ -362,7 +369,7 @@
int sc_data_call_set_status_ind_cb(sc_data_call_status_ind_cb_f cb);
/**
- * @brief »ñÈ¡¶ÔÓ¦CIDµÄÊý¾Ý°üͳ¼ÆÐÅÏ¢
+ * @brief »ñÈ¡ID¶ÔÓ¦ÍøÂçÉ豸µÄÊý¾Ý°üͳ¼ÆÐÅÏ¢
* @param (in) id ±êʶ
* @param (out) p_sta Êý¾Ý°üͳ¼ÆÐÅÏ¢
* @return 0 - ³É¹¦
@@ -421,6 +428,17 @@
*/
unsigned short sc_data_call_get_default_id(void);
+/**
+ * @brief »ñȡĬÈÏ·ÓɶÔÓ¦µÄCID
+ * @param (in) ÎÞ
+ * @param (out) ÎÞ
+ * @return 0 - δ·¢ÆðĬÈϲ¦ºÅ,ûÓÐĬÈÏ·ÓÉ
+ * ÆäËû - ĬÈÏ·ÓɶÔÓ¦CID
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_data_call_get_default_cid(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_mnet.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_mnet.h
index adf88d8..b82e263 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_mnet.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_mnet.h
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include "os_type_def.h"
#ifdef __cplusplus
extern "C" {
@@ -29,6 +30,18 @@
/*******************************************************************************
* Macro definitions *
******************************************************************************/
+#define SC_NET_NUM_OPERATOR_MAX 30
+#define SC_NET_MCC_LENGHT 3
+#define SC_NET_MNC_MAX 3
+
+/* ³¤ÃûOPERÔÊÐíµÄ×î´ó³¤¶È */
+#define SC_MAX_LONG_OPER_LEN 20 //LONG_OPER_MAX_LEN
+/* ¶ÌÃûOPERÔÊÐíµÄ×î´ó³¤¶È */
+#define SC_MAX_SHORT_OPER_LEN 12 //SHORT_OPER_MAX_LEN
+/* Êý×Ö¸ñʽOPERÔÊÐíµÄ×î´ó³¤¶È */
+#define SC_MAX_NUM_OPER_LEN 8 //NUM_OPER_MAX_LEN
+
+
/*******************************************************************************
@@ -36,6 +49,80 @@
******************************************************************************/
+typedef struct
+{
+ UINT8 mode;
+ UINT8 format;
+ CHAR oper[SC_MAX_LONG_OPER_LEN];
+ UINT8 uAcT;
+} sc_net_cur_operator_t;
+
+typedef struct
+{
+ UINT32 state;
+ UINT8 loper_a[SC_MAX_LONG_OPER_LEN];
+ UINT8 soper_a[SC_MAX_SHORT_OPER_LEN];
+ UINT8 noper_a[SC_MAX_NUM_OPER_LEN];
+ UINT32 act;
+} sc_net_operator_t;
+
+
+typedef struct
+{
+ UINT32 len;
+ sc_net_operator_t operators[SC_NET_NUM_OPERATOR_MAX];
+} sc_net_operator_list_t;
+
+
+typedef struct
+{
+ UINT8 iSvrStatus;
+ UINT8 iSvrDomain;
+ UINT8 iRoamStaus;
+ UINT8 iSysMode;
+ UINT8 iSimStatus;
+ UINT8 iSysSubMode;
+} sc_net_sysinfo_t;
+
+/* AT^sysconfig */
+typedef struct
+{
+ UINT8 imode;
+ UINT8 acqorder;
+ UINT8 roam;
+ UINT8 svrdomain;
+} sc_net_sysconfig_t;
+
+typedef struct
+{
+ UINT8 mode;
+ UINT8 format;
+ CHAR oper[SC_MAX_LONG_OPER_LEN];
+ UINT8 act;
+} sc_net_cops_ser_t;
+
+typedef struct {
+ int enable;
+} sc_net_connect_t;
+
+typedef struct {
+ int result;
+} sc_net_common_res_t;
+
+
+/**
+ * @brief ÍøÂçɨÃè»Øµ÷º¯Êý
+ * @param (in) async_index Òì²½²Ù×÷Ë÷ÒýÖµ¡£
+ * @param (in) p_info ÍøÂçɨÃè½á¹û¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+typedef void (*sc_network_scan_async_cb)(int async_index, sc_net_operator_list_t *p_info);
+
+
/*******************************************************************************
* Global variable declarations *
******************************************************************************/
@@ -65,6 +152,107 @@
*/
int sc_mnet_uninit(int sID);
+/**
+ * @brief ÍøÂçɨÃè¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (in) cb ɨÃè½á¹û»Øµ÷º¯Êý¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_scan(int cardID, sc_network_scan_async_cb cb);
+
+/**
+ * @brief ÔËÓªÉÌÐÅÏ¢»ñÈ¡¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (out) pinfo ÔËÓªÉÌÐÅÏ¢¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_get_operator_info(int cardID, sc_net_cur_operator_t* oper);
+
+/**
+ * @brief ÖÆÊ½Ñ¡Ôñ¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (in) mode ÍøÂçÖÆÊ½¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_select_mode(int cardID, int mode);
+/**
+ * @brief ¿ØÖÆ^MODEÖ÷¶¯Éϱ¨Ê¼þ¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (in) mode ϵͳģʽ±ä»¯Ö÷¶¯Éϱ¨¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_set_mode(int cardID, int mode);
+
+/**
+ * @brief ÓïÒôºÍÊý¾Ý×¢²á¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_register(int cardID, sc_net_cops_ser_t* req);
+
+/**
+ * @brief ÓïÒôºÍÊý¾Ý×¢Ïú¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_deregister(int cardID);
+
+/**
+ * @brief ÓïÒôºÍÊý¾Ý×¢²á״̬²éѯ¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_register_state(int cardID, sc_net_sysinfo_t* sysinfo);
+
+/**
+ * @brief ÐźÅÇ¿¶È²éѯ¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (out) csq ÐźÅÇ¿¶È¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_get_signal_strength(int cardID, int* csq);
+
+int sc_net_set_mode(int cardID, int mode);
+
+/**
+ * @brief ÐźÅÇ¿¶È²éѯ¡£
+ * @param (in) cardID SIM¿¨±êʶ¡£
+ * @param (out) csq ÐźÅÇ¿¶È¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_net_get_cell_info(int cardID);
+
#ifdef __cplusplus
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_nw_mgr.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_nw_mgr.h
index 5578af3..38968b4 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_nw_mgr.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_nw_mgr.h
@@ -95,8 +95,8 @@
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
- * @note ×¢ÊÍ
- * ×¢ÊÍ¡£
+ * @note 1. ÍâÍø¼¤»îʱÅäÖÃÓÐЧ
+ * 2. ¹Ø»ú²»±£´æ£¬ÐèҪʹÓÃÕß×Ô¼º¹ÜÀí
*/
extern int sc_net_firewall_add(int af, char *ip);
@@ -125,7 +125,7 @@
/**
* @brief ÉèÖÃMTUÖµ¡£
- * @param (in) ÎÞ¡£
+ * @param (in) mtu£ºÅäÖõÄMTUÖµ£¬ÓÐЧ·¶Î§£º[572, 1500]
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_rtc_timer.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_rtc_timer.h
index 005eaa7..94aba9f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_rtc_timer.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_rtc_timer.h
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include "zxic_list.h"
#ifdef __cplusplus
extern "C" {
@@ -34,6 +35,41 @@
/*******************************************************************************
* Type definitions *
******************************************************************************/
+typedef struct
+{
+ int srcModule;
+ unsigned int module;
+ unsigned long ulSec;
+ unsigned long time_val;
+ int wakeup;
+ int is_utc;
+ int cpu;
+}sc_rtc_data_info;
+
+typedef struct{
+ unsigned long time;
+ unsigned int src_id;
+} sc_rtc_user_t;
+
+/****************************************************************************
+* Timer expire callback function Definition
+***************************************************************************/
+typedef int (*sc_rtc_timer_exp_cb)(unsigned int src_id);
+
+
+/****************************************************************************
+* Get rtc time callback function Definition
+***************************************************************************/
+typedef int (*sc_rtc_time_get_cb)(unsigned int src_id,unsigned long ulsec);
+
+
+typedef struct{
+ struct list_head list;
+ unsigned long time;
+ unsigned int src_id;
+ sc_rtc_time_get_cb rtc_time_get_cb;
+ sc_rtc_timer_exp_cb rtc_timerout_cb;
+} sc_rtc_user_cb_t;
/*******************************************************************************
@@ -65,6 +101,57 @@
*/
int sc_rtc_timer_uninit(void);
+/**
+ * @brief ÉèÖÃrtc¶¨Ê±Æ÷¡£
+ * @param (in) ulSec ¶¨Ê±Ê±¼ä£¨Ã룩¡£
+ * srcid Óû§ID¡£
+ * sc_rtc_idÔÝÎÞÓÃ
+ * rtc_notifyÓû§×¢²áµÄ»Øµ÷º¯Êý
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_rtc_timer_add(unsigned long ulSec, int srcid, sc_rtc_timer_exp_cb rtc_notify);
+
+/**
+ * @brief »ñÈ¡rtcʱ¼ä¡£
+ * @param (in) srcid Óû§ID¡£
+ * @param (out) rtc_notifyÓû§×¢²áµÄ»Øµ÷º¯Êý¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_rtc_time_get(int srcid, sc_rtc_time_get_cb rtc_notify);
+
+/**
+ * @brief ÉèÖÃrtcʱ¼ä¡£
+ * @param (in) srcid Óû§ID¡£
+ * ulsec ÔÝʱÎÞÓÃ.
+ * @param (out) rtc_notifyÓû§×¢²áµÄ»Øµ÷º¯Êý¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_rtc_time_set(int srcid);
+
+/**
+ * @brief ÉèÖÃrtc¶¨Ê±Æ÷(utc,¶¨Ê±µ½/Äê/ÔÂ/ÈÕ/ʱ/·Ö/Ãë)¡£
+ * @param (in) utc_sec ¶¨Ê±Ê±¼ä£¨/Äê/ÔÂ/ÈÕ/ʱ/·Ö/Ã룩¡£
+ * srcid Óû§ID¡£
+ * sc_rtc_idÔÝÎÞÓÃ
+ * wakeupÔÝÎÞÓÃ
+ * rtc_notifyÓû§×¢²áµÄ»Øµ÷º¯Êý
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_rtc_timer_add_utc(struct tm *utc_sec, int srcid, int wakeup,sc_rtc_timer_exp_cb rtc_notify);
#ifdef __cplusplus
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_sim.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_sim.h
index 970019a..a09e471 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_sim.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_sim.h
@@ -40,14 +40,6 @@
/*******************************************************************************
* Type definitions *
******************************************************************************/
-typedef enum
-{
- SC_SIM_APP_TYPE_3GPP = 0, //3GPP ÀàÐ͵ÄÓ¦ÓóÌÐò
- SC_SIM_APP_TYPE_3GPP2 = 1, //3GPP2 ÀàÐ͵ÄÓ¦ÓóÌÐò
- SC_SIM_APP_TYPE_ISIM = 2, //ISIM רÓÃÓ¦ÓóÌÐò
- SC_SIM_APP_TYPE_MAX
-}sc_sim_app_type_e;
-
typedef struct
{
char mcc[SC_SIM_MCC_LENGHT+1];
@@ -72,13 +64,6 @@
SC_SIM_CARD_STATE_UNKNOWN = 0xB01, //δ֪״̬
SC_SIM_CARD_STATE_ABSENT = 0xB02, //ÎÞ¿¨×´Ì¬
SC_SIM_CARD_STATE_PRESENT = 0xB03, //¼ì²âµ½¿¨
- SC_SIM_CARD_STATE_ERROR_UNKNOWN = 0xB04, //δ֪´íÎó
- SC_SIM_CARD_STATE_ERROR_POWER_DOWN = 0xB05, //SIM ¿¨Î´Éϵç
- SC_SIM_CARD_STATE_ERROR_POLL_ERROR = 0xB06, //ÂÖѯ´íÎó
- SC_SIM_CARD_STATE_ERROR_NO_ATR_RECEIVED = 0xB07, //δÊÕµ½¸´Î»Ó¦´ð
- SC_SIM_CARD_STATE_ERROR_VOLT_MISMATCH = 0xB08, //µçѹʧÅä
- SC_SIM_CARD_STATE_ERROR_PARITY_ERROR = 0xB09, //ÆæÅ¼Ð£Ñé´íÎó
- SC_SIM_CARD_STATE_ERROR_SIM_TECHNICAL_PROBLEMS = 0xB0A, //SIM ¿¨¼¼ÊõÎÊÌâ
} sc_sim_card_state_e; /**< Card state. */
typedef enum
@@ -89,23 +74,11 @@
} sc_sim_card_type_e;
typedef enum {
- SC_SIM_SUBSCRIPTION_NONE = 0xB00, //δ¶©ÔÄ
- SC_SIM_SUBSCRIPTION_PRI = 0xB01, //Ö÷¿¨
- SC_SIM_SUBSCRIPTION_SEC = 0xB02, //¸±¿¨
-} sc_sim_subscription_e;
-
-typedef enum {
- SC_SIM_APP_STATE_UNKNOWN = 0xB00, //δ֪״̬
- SC_SIM_APP_STATE_DETECTED = 0xB01, //ÒѼì²âµ½
- SC_SIM_APP_STATE_PIN1_REQ = 0xB02, //µÈ´ýÊäÈë PIN1 Âë
- SC_SIM_APP_STATE_PUK1_REQ = 0xB03, //µÈ´ýÊäÈë PUK1 Âë
- SC_SIM_APP_STATE_INITALIZATING = 0xB04, //³õʼ»¯ÖÐ
- SC_SIM_APP_STATE_PERSO_CK_REQ = 0xB05, //µÈ´ýÊäÈë PCK ÃÜÂë
- SC_SIM_APP_STATE_PERSO_PUK_REQ = 0xB06, //µÈ´ýÊäÈë½âËø¸öÐÔ»¯ÉèÖõÄÃÜÂë
- SC_SIM_APP_STATE_PERSO_PERMANENTLY_BLOCKED = 0xB07, //¸öÐÔ»¯ÉèÖñ»ÓÀ¾ÃËø¶¨
- SC_SIM_APP_STATE_PIN1_PERM_BLOCKED = 0xB08, //PIN1 Âë±»ÓÀ¾ÃËø¶¨
- SC_SIM_APP_STATE_ILLEGAL = 0xB09, //·Ç·¨×´Ì¬
- SC_SIM_APP_STATE_READY = 0xB0A, //³õʼ»¯Íê³É
+ SC_SIM_APP_STATE_UNKNOWN = 0xB00, //δ֪״̬
+ SC_SIM_APP_STATE_PIN1_REQ = 0xB01, //µÈ´ýÊäÈë PIN1 Âë
+ SC_SIM_APP_STATE_PUK1_REQ = 0xB02, //µÈ´ýÊäÈë PUK1 Âë
+ SC_SIM_APP_STATE_PIN1_PERM_BLOCKED = 0xB03, //PIN1 Âë±»ÓÀ¾ÃËø¶¨
+ SC_SIM_APP_STATE_READY = 0xB04, //³õʼ»¯Íê³É
} sc_sim_app_state_e;
typedef enum {
@@ -133,7 +106,6 @@
} sc_sim_error_code_e;
typedef struct {
- sc_sim_subscription_e subscription;
sc_sim_app_state_e app_state;
sc_sim_pin_state_e pin1_state;
uint8_t pin1_num_retries;
@@ -147,9 +119,7 @@
{
sc_sim_card_state_e state;
sc_sim_card_type_e type;
- sc_sim_app_info_t app_3gpp;
- sc_sim_app_info_t app_3gpp2;
- sc_sim_app_info_t app_isim;
+ sc_sim_app_info_t app_3gpp;
} sc_sim_card_info_t;
typedef void (*sc_sim_card_status_cb_f)(int sID, sc_sim_card_info_t *p_info);
@@ -195,7 +165,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_get_imsi(int sID, sc_sim_app_type_e app_type, char *imsi, int imsi_len);
+int sc_sim_get_imsi(int sID, char *imsi, int imsi_len);
/**
* @brief »ñÈ¡ iccid¡£
@@ -220,7 +190,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_get_phone_num(int sID, sc_sim_app_type_e app_type, char *phone_num, int phone_num_len);
+int sc_sim_get_phone_num(int sID, char *phone_num, int phone_num_len);
/**
* @brief »ñÈ¡ÔËÓªÉÌÐÅÏ¢¡£
@@ -245,7 +215,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_enable_pin(int sID, sc_sim_app_type_e app_type, sc_sim_pin_e pin, const char *pin_value);
+int sc_sim_enable_pin(int sID, sc_sim_pin_e pin, const char *pin_value);
/**
* @brief ¹Ø±ÕpinÂë¡£
@@ -259,7 +229,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_disable_pin(int sID, sc_sim_app_type_e app_type, sc_sim_pin_e pin, const char *pin_value);
+int sc_sim_disable_pin(int sID, sc_sim_pin_e pin, const char *pin_value);
/**
* @brief ÑéÖ¤pinÂë¡£
@@ -273,7 +243,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_verify_pin(int sID, sc_sim_app_type_e app_type, sc_sim_pin_e pin, const char *pin_value);
+int sc_sim_verify_pin(int sID, sc_sim_pin_e pin, const char *pin_value);
/**
* @brief ÐÞ¸ÄpinÂë¡£
@@ -288,7 +258,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_change_pin(int sID, sc_sim_app_type_e app_type,sc_sim_pin_e pin, const char *old_pin_value, const char *new_pin_value);
+int sc_sim_change_pin(int sID, sc_sim_pin_e pin, const char *old_pin_value, const char *new_pin_value);
/**
* @brief ½â¿ªSIM¿¨µÄËø¶¨×´Ì¬²¢ÉèÖÃеÄPINÂë¡£
@@ -303,7 +273,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_unblock_pin(int sID, sc_sim_app_type_e app_type, sc_sim_pin_e pin, const char *puk_value, const char *pin_value);
+int sc_sim_unblock_pin(int sID, sc_sim_pin_e pin, const char *puk_value, const char *pin_value);
/**
* @brief »ñÈ¡SIM¿¨ÐÅÏ¢¡£
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_sms.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_sms.h
index 19c421b..d0e9e8c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_sms.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/include/sc_sms.h
@@ -39,37 +39,37 @@
******************************************************************************/
typedef enum
{
- SC_SMS_MSG_FORMAT_GSM_7BIT = 0,
- SC_SMS_MSG_FORMAT_BINARY_DATA = 1,
- SC_SMS_MSG_FORMAT_UCS2 = 2,
+ SC_SMS_MSG_FORMAT_GSM_7BIT = 0, //7bit¸ñʽ¶ÌÐÅ
+ SC_SMS_MSG_FORMAT_BINARY_DATA = 1, //8bit¸ñʽ¶ÌÐÅ
+ SC_SMS_MSG_FORMAT_UCS2 = 2, //ucs-2¸ñʽ¶ÌÐÅ
SC_SMS_MSG_FORMAT_MAX
-}SC_SMS_MSG_FORMAT_E;
+}sc_sms_msg_format_e;
typedef struct
{
- SC_SMS_MSG_FORMAT_E format;
- char addr[SC_SMS_MAX_ADDR_LENGTH+1];
- int content_size;
- char content[SC_SMS_MAX_SEND_MSG_LENGTH];
+ sc_sms_msg_format_e format; //¶ÌПñʽ
+ char addr[SC_SMS_MAX_ADDR_LENGTH+1]; //·¢ËͶÌÐÅʱΪ½ÓÊÕ·½µØÖ·£»½ÓÊÕ¶ÌÐÅʱΪ·¢ËÍ·½µØÖ·
+ int content_size; //¶ÌÐų¤¶È
+ char content[SC_SMS_MAX_SEND_MSG_LENGTH]; //¶ÌÐÅÄÚÈÝ
}sc_sms_msg_t;
typedef struct
{
- uint8_t year;
- uint8_t month;
- uint8_t day;
- uint8_t hours;
- uint8_t minutes;
- uint8_t seconds;
- uint8_t timezone;
+ uint8_t year; //Äê ×Ô2000ÄêÆð¼ÆË㣬ÀýÈ磬19±íʾ2019
+ uint8_t month; //ÔÂ
+ uint8_t day; //ÈÕ
+ uint8_t hours; //Сʱ 00 ~ 23
+ uint8_t minutes; //·ÖÖÓ
+ uint8_t seconds; //Ãë
+ uint8_t timezone; //Ê±Çø¡£µ¥Î»£º1/4 Сʱ¡£ÀýÈ磬ÖйúλÓÚ+8 Çø£¬Æä timezone Ϊ+32¡£
}sc_sms_timestamp_t;
typedef struct
{
- uint8_t valid; /*Indicate whether following is valid, 1-valid; 0-invalid*/
- uint8_t total_seg; /*The number of long message segment*/
- uint8_t cur_seg_num; /*Current number*/
- uint8_t ref_num; /*reference number*/
+ uint8_t valid; //ָʾÒÔÏÂÄÚÈÝÊÇ·ñÓÐЧ, 1-valid; 0-invalid
+ uint8_t total_seg; //³¤¶ÌÐŵÄ×ܶÎÊý
+ uint8_t cur_seg_num; //±¾Ìõ¶ÌÐŵĶÎÊý±àºÅ
+ uint8_t ref_num; //±¾Ìõ¶ÌÐŵĽÓÊÕ±àºÅ£¬Îª±¾Ìõ¶ÌÐŵÄΨһ±êʶºÅ
}sc_sms_user_data_head_t;
typedef enum
@@ -77,15 +77,32 @@
SC_SMS_PDU_FORMAT_CDMA = 0, //CDMA
SC_SMS_PDU_FORMAT_GW_PP = 1, // GSM & WCDMA
SC_SMS_PDU_FORMAT_MAX
-}SC_SMS_PDU_FORMAT_E;
+}sc_sms_pdu_format_e;
typedef struct
{
- SC_SMS_PDU_FORMAT_E format;
- int content_size;
- char content[SC_SMS_MAX_SEND_PDU_LENGTH];
+ sc_sms_pdu_format_e format; //PDU ¶ÌПñʽ
+ int content_size; //PDU ¶ÌÐų¤¶È
+ char content[SC_SMS_MAX_SEND_PDU_LENGTH]; //PDU ¶ÌÐÅÄÚÈÝ
}sc_sms_pdu_t;
+typedef enum {
+ SC_SMS_ERROR_UNKNOWN = 1,
+ SC_SMS_ERROR_NOTALLOW_OP,
+ SC_SMS_ERROR_NOTSUPPORT_OP,
+ SC_SMS_ERROR_SIM_NOT_INSERT,
+ SC_SMS_ERROR_REQUIRE_PIN,
+ SC_SMS_ERROR_REQUIRE_PUK,
+ SC_SMS_ERROR_SIM_INIT_FAIL,
+ SC_SMS_ERROR_SIM_BUSY,
+ SC_SMS_ERROR_SIM_ERROR,
+ SC_SMS_ERROR_WRONG_PASSWORD,
+ SC_SMS_ERROR_REQUIRE_PIN2,
+ SC_SMS_ERROR_REQUIRE_PUK2,
+ SC_SMS_ERROR_NO_NETWORK_SERVICE,
+ SC_SMS_ERROR_NETWORK_TIMEOUT,
+}sc_sms_error_code_e;
+
typedef void(*sc_sms_msg_async_cb_f)(int id, int result);
typedef void(*sc_sms_msg_recv_cb_f)(sc_sms_msg_t *p_msg, sc_sms_timestamp_t *timestamp, sc_sms_user_data_head_t *head);
typedef void(*sc_sms_pdu_async_cb_f)(int id, int result);
@@ -123,51 +140,53 @@
/**
* @brief ÉèÖöÌÐÅÖÐÐĺÅÂë¡£
- * @param (in) addr ¶ÌÐÅÖÐÐĺÅÂë
- * (in) len ¶ÌÐÅÖÐÐĺÅÂ볤¶È
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * addr ¶ÌÐÅÖÐÐĺÅÂë
+ * len ¶ÌÐÅÖÐÐĺÅÂ볤¶È
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_set_service_center_addr(char* addr, int len);
+int sc_sms_set_service_center_addr(int sID, char* addr, int len);
/**
* @brief »ñÈ¡¶ÌÐÅÖÐÐĺÅÂë¡£
- * @param (in) ÎÞ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£¡£
* @param (out) addr ¶ÌÐÅÖÐÐĺÅÂë¡£
- * (out) len ¶ÌÐÅÖÐÐĺÅÂ볤¶È¡£
+ * len ¶ÌÐÅÖÐÐĺÅÂ볤¶È¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_get_service_center_addr(char* addr, int len);
+int sc_sms_get_service_center_addr(int sID, char* addr, int len);
/**
* @brief ·¢ËÍÎı¾¶ÌÐÅ¡£
- * @param (in) p_msg Îı¾¶ÌÐÅ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * p_msg Îı¾¶ÌÐÅ¡£
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_send_msg(sc_sms_msg_t* p_msg);
+int sc_sms_send_text_msg(int sID, sc_sms_msg_t* p_msg);
/**
* @brief Òì²½·¢ËÍÎı¾¶ÌÐÅ¡£
- * @param (in) p_msg Îı¾¶ÌÐÅ¡£
- * (in) id Òì²½·¢ËÍÎı¾¶ÌÐÅʼþID¡£
- * (in) cb Òì²½·¢ËÍÎı¾¶ÌÐŻص÷º¯Êý¡£
- * @param (out) ÎÞ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * p_msg Îı¾¶ÌÐÅ¡£
+ * cb Òì²½·¢ËÍÎı¾¶ÌÐŻص÷º¯Êý¡£
+ * @param (out) id Òì²½·¢ËÍÎı¾¶ÌÐÅʼþID¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_send_msg_async(sc_sms_msg_t* p_msg, int* id, sc_sms_msg_async_cb_f cb);
+int sc_sms_send_text_msg_async(int sID, sc_sms_msg_t* p_msg, int* id, sc_sms_msg_async_cb_f cb);
/**
* @brief ÉèÖÃÎı¾¶ÌÐŽÓÊջص÷º¯Êý¡£
@@ -178,31 +197,32 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_set_msg_recv_cb(sc_sms_msg_recv_cb_f* cb);
+int sc_sms_set_text_msg_recv_cb(sc_sms_msg_recv_cb_f cb);
/**
* @brief ·¢ËÍPDU¶ÌÐÅ¡£
- * @param (in) p_pdu PDU¶ÌÐÅÄÚÈÝ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * p_pdu PDU¶ÌÐÅÄÚÈÝ¡£
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_send_pdu(sc_sms_pdu_t* p_pdu);
+int sc_sms_send_pdu_msg(int sID, sc_sms_pdu_t* p_pdu);
/**
* @brief Òì²½·¢ËÍPDU¶ÌÐÅ¡£
- * @param (in) p_pdu PDU¶ÌÐÅÄÚÈÝ¡£
- * (in) id Òì²½·¢ËÍPDU¶ÌÐÅʼþID
- * (in) cb Òì²½·¢ËÍPDU¶ÌÐŻص÷º¯Êý
- * @param (out) ÎÞ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * p_pdu PDU¶ÌÐÅÄÚÈÝ¡£ *
+ * cb Òì²½·¢ËÍPDU¶ÌÐŻص÷º¯Êý
+ * @param (out) id Òì²½·¢ËÍPDU¶ÌÐÅʼþID¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_send_pdu_async(sc_sms_pdu_t* p_pdu, int* id, sc_sms_pdu_async_cb_f cb);
+int sc_sms_send_pdu_msg_async(int sID, sc_sms_pdu_t* p_pdu, int* id, sc_sms_pdu_async_cb_f cb);
/**
* @brief ÉèÖÃPDU¶ÌÐŽÓÊջص÷º¯Êý¡£
@@ -213,7 +233,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_set_pdu_recv_cb(sc_sms_pdu_recv_cb_f cb);
+int sc_sms_set_pdu_msg_recv_cb(sc_sms_pdu_recv_cb_f cb);
/**
* @brief ÉèÖÃSMSÒì³£»Øµ÷º¯Êý¡£
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/mnet/sc_mnet.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/mnet/sc_mnet.c
index cd71db7..653e8e8 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/mnet/sc_mnet.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/mnet/sc_mnet.c
@@ -13,12 +13,377 @@
#include <syslog.h>
#include <pthread.h>
-int sc_mnet_init(void)
+#include "sc_mnet.h"
+#include "sc_ipc.h"
+#include "sc_net_msg.h"
+#include "sc_tel_types.h"
+
+
+static int sc_net_have_init = 0;
+static sc_ipc_event net_auto_notify_evt[] = {
+
+};
+
+
+/**
+ * @brief ´òÓ¡½ø³Ì¼äÏûÏ¢²ÎÊý¡£
+ * @param (in) pmsg ½ø³Ì¼äÏûÏ¢¡£
+ * @param (out) ÎÞ¡£
+ * @return ÎÞ
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static void sc_net_print_msg(const sc_ipc_msg* const pmsg)
{
- return 0;
+ SCLOGD("pmsg->fd_cli=%d \n", pmsg->fd_cli);
+ SCLOGD("pmsg->fd_svr=%d \n", pmsg->fd_svr);
+ SCLOGD("pmsg->msg_req=%d \n", pmsg->msg_req);
+ SCLOGD("pmsg->msg_rsp=%d \n", pmsg->msg_rsp);
}
-int sc_mnet_uninit(void)
+/**
+ * @brief ´´½¨½ø³Ì¼äÏûÏ¢¡£
+ * @param (in) req ÇëÇóÏûÏ¢id
+ * rsp ÏìÓ¦ÏûÏ¢id
+ * wait ÊÇ·ñΪͬ²½ÏûÏ¢ 0£º·Çͬ²½ 1£ºÍ¬²½
+ * data ´«ÊäÊý¾Ý
+ * datalen ´«ÊäÊý¾Ý³¤¶È
+ * @param (out) ÎÞ¡£
+ * @return ·ÇNULL - ³É¹¦
+ * NULL-ʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static sc_ipc_msg* sc_net_ipc_msg_create(unsigned int req, unsigned int rsp, int wait, void *data, unsigned int datalen)
{
- return 0;
+ sc_ipc_msg *pmsg = NULL;
+ pmsg = (sc_ipc_msg *)malloc(sizeof(sc_ipc_msg) + datalen);
+ if(NULL == pmsg) {
+ return NULL;
+ }
+ memset(pmsg, 0, sizeof(sc_ipc_msg));
+
+ pmsg->type = 1;
+ pmsg->fd_svr = sc_ipc_get_svr_fd(NULL);
+ pmsg->fd_cli = sc_ipc_get_self_fd();
+ pmsg->token = 0;
+ pmsg->msg_req = req;
+ pmsg->msg_rsp = rsp;
+ pmsg->wait_rsp = wait;
+ pmsg->data_len = datalen;
+
+ if(0 < datalen) {
+ memcpy(pmsg->data, data, pmsg->data_len);
+ }
+
+ return pmsg;
}
+
+
+/**
+ * @brief Á¬½Ó·þÎñ¶Ë¡£
+ * @param (in) enable 1£ºÁ¬½Ó 0£º¶Ï¿ª
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static int sc_net_connect(int enable)
+{
+ sc_ipc_msg *req_msg = NULL;
+ sc_ipc_msg *rsp_msg = NULL;
+ sc_net_connect_t connect_info;
+ net_common_res_t *comm_res = NULL;
+ int ret = SC_ERR_SUCCESS;
+ if((enable != 0) && (enable != 1))
+ {
+ SCLOGD("sc_net_connect invalid param!\n");
+ return SC_ERR_FAIL;
+ }
+
+ memset(&connect_info, 0, sizeof(connect_info));
+ connect_info.enable = enable;
+ req_msg = sc_net_ipc_msg_create(MSG_CMD_NET_CONN_REQ, MSG_CMD_NET_CONN_RSP, 1, &connect_info, sizeof(connect_info));
+ if(NULL == req_msg) {
+ return SC_ERR_FAIL;
+ }
+
+ if(0 != sc_ipc_send_msg_wait_rsp(req_msg, &rsp_msg)) {
+ ret = SC_ERR_FAIL;
+ }
+ else {
+ comm_res = (net_common_res_t *)rsp_msg->data;
+ if(0 != comm_res->result) {
+ ret = SC_ERR_FAIL;
+ }
+ }
+ sc_ipc_msg_free(req_msg);
+ return ret;
+}
+
+
+int sc_mnet_init(int sID)
+{
+ if(sc_net_have_init)
+ {
+ return SC_ERR_SUCCESS;
+ }
+ sc_ipc_start_loop("sc-net");
+ /* ×¢²áÖ÷¶¯Éϱ¨ÏûÏ¢´¦Àí*/
+ sc_ipc_register_events(net_auto_notify_evt, sizeof(net_auto_notify_evt) / sizeof(sc_ipc_event));
+ if(0 == sc_net_connect(1)) {
+ SCLOGD("sc_net_init connect telsvr success.\n");
+ }
+ SCLOGD("sc_net_init finish\n");
+ return SC_ERR_SUCCESS;
+}
+
+/**
+ * @brief ×¢Ïú¿Í»§¶ËSIM½Ó¿Ú·þÎñ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_mnet_uninit(int sID)
+{
+ int i;
+ sc_ipc_event *pevt;
+
+ sc_net_have_init = 0;
+
+ for(i = 0; i < sizeof(net_auto_notify_evt) / sizeof(sc_ipc_event); i ++) {
+ pevt = &net_auto_notify_evt[i];
+ sc_ipc_event_del(pevt);
+ }
+
+ if(0 == sc_net_connect(0)) {
+ SCLOGD("sc_mnet_uninit disconnect telsvr success.\n");
+ }
+ sc_ipc_terminate_loop();
+ SCLOGD("sc_net_uninit finish\n");
+ return SC_ERR_SUCCESS;
+}
+
+//at+cops=?
+int sc_net_scan(int cardID, sc_network_scan_async_cb cb)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_NET_SCAN, MSG_CMD_NET_SCAN_RSP, 1, (void*)&cardID, sizeof(cardID));
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+ if(pmsg_rsp->data_len == sizeof(int)){
+ if(pmsg_rsp->data == 1){
+ SCLOGD("sc_net_scan failed \n");
+ return SC_ERR;
+ }
+ SCLOGD("sc_net_scan failed 1\n");
+ return SC_ERR;
+ }
+
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+ sc_net_operator_list_t list = {0};
+ memcpy(&list, pmsg_rsp->data, pmsg_rsp->data_len);
+ for(int i=0; i < list.len; i++)
+ {
+ printf("operator i %ld state=%d loper_a=%s soper_a=%s noper_a=%s act=%ld\n", i,
+ list.operators[i].state,
+ list.operators[i].loper_a,
+ list.operators[i].soper_a,
+ list.operators[i].noper_a,
+ list.operators[i].act);
+ }
+ cb(1, &list);
+ SCLOGD("sc_net_scan succ 1\n");
+ return SC_ERR_SUCCESS;
+}
+
+//at+cops?
+int sc_net_get_operator_info(int cardID, sc_net_cur_operator_t* oper)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_GET_OPERATOR, MSG_CMD_GET_OPERATOR_RSP, 1, (void*)&cardID, sizeof(cardID));
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+ sc_net_cur_operator_t* ret = (sc_net_cur_operator_t*)pmsg_rsp->data;
+ //memcpy(oper, ret, sizeof(sc_net_cur_operator_t));
+ memcpy(oper, pmsg_rsp->data, pmsg_rsp->data_len);
+ printf("get operator info %d %d %s %d\n", oper->mode, oper->format, oper->oper, oper->uAcT);
+ return SC_ERR_SUCCESS;
+}
+
+//at^sysconfig=20,6,1,2
+int sc_net_select_mode(int cardID, int mode)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ netc_comm_result_t* ret = NULL;
+ SCLOGD("sc_net_select_mode enter \n");
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_NET_MODE_SELECT, MSG_CMD_NET_MODE_SELECT_RSP, 1, (void*)(&mode), sizeof(mode));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+ //sc_net_print_msg(pmsg_req);
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+
+ ret = (netc_comm_result_t*)pmsg_rsp->data;
+ if(0 != ret->result){
+ SCLOGD("sc_net_select_mode failed, ret:%d", ret);
+ return ret->result;
+ }
+ SCLOGD("sc_net_select_mode succ, mode:%d \n", mode);
+ return SC_ERR_SUCCESS;
+}
+
+//at+cops=1,2,"46000"
+int sc_net_register(int cardID, sc_net_cops_ser_t* req)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ UINT8* ret = NULL;
+ SCLOGD("sc_net_register enter size %d \n",sizeof(sc_net_cops_ser_t));
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_NET_REGISTER, MSG_CMD_NET_REGISTER_RSP, 1, req, sizeof(sc_net_cops_ser_t));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+ //sc_net_print_msg(pmsg_req);
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+ ret = (UINT8*)pmsg_rsp->data;
+
+ if(0 != *ret){
+ SCLOGD("sc_net_register failed, ret:%d", *ret);
+ return SC_ERR_FAIL;
+ }
+ SCLOGD("sc_net_register succ\n");
+ return SC_ERR_SUCCESS;
+}
+
+//at+cops=2 È¥×¢²áÍøÂç
+int sc_net_deregister(int cardID)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int* ret = NULL;
+ SCLOGD("sc_net_deregister enter \n");
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_NET_DEREGISTER, MSG_CMD_NET_DEREGISTER_RSP, 1, &cardID, sizeof(cardID));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+ //sc_net_print_msg(pmsg_req);
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+
+ ret = (int*)pmsg_rsp->data;
+ if(-1 == *ret){
+ SCLOGD("sc_net_deregister failed\n");
+ return SC_ERR_FAIL;
+ }
+ SCLOGD("sc_net_deregister succ\n");
+ return SC_ERR_SUCCESS;
+}
+
+//at^sysinfo
+int sc_net_register_state(int cardID, sc_net_sysinfo_t* sysinfo)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ SCLOGD("sc_net_register_state sysinfo enter \n");
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_NET_GET_REGISTER_STATE, MSG_CMD_NET_GET_REGISTER_STATE_RSP, 1, NULL, 0);
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+
+
+ memcpy(sysinfo, pmsg_rsp->data, pmsg_rsp->data_len);
+ SCLOGD("sysinfo %d %d %d %d %d %d\n",
+ sysinfo->iSvrStatus, sysinfo->iSvrDomain, sysinfo->iRoamStaus, sysinfo->iSysMode, sysinfo->iSimStatus, sysinfo->iSysSubMode);
+ return SC_ERR_SUCCESS;
+}
+
+//at+csq
+int sc_net_get_signal_strength(int cardID, int* csq)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ SCLOGD("sc_net_get_signal_strength enter \n");
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_GET_CSQ, MSG_CMD_GET_CSQ_RSP, 1, &cardID, sizeof(cardID));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+ int* ret = (int*)pmsg_rsp->data;
+ *csq=*ret;
+ SCLOGD("sc_net_get_signal_strength succ csq:%ld \n", *csq);
+ return SC_ERR_SUCCESS;
+}
+
+//at^mode=1/0
+int sc_net_set_mode(int cardID, int mode){
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int* ret = NULL;
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_NET_MODE_SET, MSG_CMD_NET_MODE_SET_RSP, 1, &mode, sizeof(mode));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+ //sc_net_print_msg(pmsg_req);
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+
+ ret = (int*)pmsg_rsp->data;
+ if(0 != *ret){
+ SCLOGD("sc_net_set_mode failed, ret:%d", *ret);
+ return SC_ERR_FAIL;
+ }
+ SCLOGD("sc_net_set_mode succ");
+ return SC_ERR_SUCCESS;
+
+}
+
+
+//at+zemsciq=1
+int sc_net_get_cell_info(int cardID)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ SCLOGD("sc_net_get_cell_info enter \n");
+ pmsg_req = sc_net_ipc_msg_create(MSG_CMD_GET_CELL_INFO, MSG_CMD_GET_CELL_INFO_RSP, 1, &cardID, sizeof(cardID));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+
+ char res[128] = {0};
+ memcpy(res, pmsg_rsp->data, pmsg_rsp->data_len);
+ SCLOGD("sc_net_get_cell_info succ %s\n", res);
+ return SC_ERR_SUCCESS;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/rtc_timer/sc_rtc_timer.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/rtc_timer/sc_rtc_timer.c
index 383ab08..cfa1eff 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/rtc_timer/sc_rtc_timer.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/rtc_timer/sc_rtc_timer.c
@@ -12,13 +12,144 @@
#include <time.h>
#include <syslog.h>
#include <pthread.h>
+#include "sc_ipc.h"
+#include "sc_rtc_timer.h"
+#include "sc_rtc_timer_msg.h"
+#include "sc_tel_types.h"
+#include "rtc_timer.h"
+#include "softap_api.h"
+#include "message.h"
+
+static int sc_rtc_timer_have_init = 0;
+sc_rtc_user_cb_t sc_rtc_cb;
+
+static int sc_rtc_timeout_cb(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ int ret = 0;
+ sc_rtc_data_info *rtc_info = NULL;
+ rtc_info = (sc_rtc_data_info*)pmsg->data;
+
+ ret = sc_rtc_cb.rtc_timerout_cb(rtc_info->srcModule);
+ return SC_ERR_SUCCESS;
+}
+
+static int sc_rtc_get_time_cb(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ int ret = 0;
+ sc_rtc_data_info *rtc_info = NULL;
+ rtc_info = (sc_rtc_data_info*)pmsg->data;
+
+ ret = sc_rtc_cb.rtc_time_get_cb(rtc_info->srcModule,rtc_info->ulSec);
+ return SC_ERR_SUCCESS;
+}
+
+static sc_ipc_event rtc_timer_auto_notify_evt[] = {
+ {0, 1, 0, SC_RTC_MSG_CMD_GET_TIME_RSP, sc_rtc_get_time_cb, NULL, NULL},
+ {0, 1, 0, SC_RTC_MSG_CMD_TIMEOUT, sc_rtc_timeout_cb, NULL, NULL},
+};
+
+static int sc_rtc_timer_connect(void)
+{
+ int rtc_client_id = -1;
+ int ret = -1;
+ rtc_client_id = sc_ipc_get_self_fd();
+
+ if(rtc_client_id!=-1)
+ {
+ sc_rtc_cb.src_id = rtc_client_id;
+ ret = 0;
+ }
+ else
+ {
+ return -1;
+ }
+
+ return ret;
+}
int sc_rtc_timer_init(void)
{
- return 0;
+ if(sc_rtc_timer_have_init)
+ {
+ return SC_ERR_SUCCESS;
+ }
+ sc_ipc_start_loop(NULL);
+
+ /* 注册主动上报消息处理*/
+ sc_ipc_register_events(rtc_timer_auto_notify_evt, sizeof(rtc_timer_auto_notify_evt) / sizeof(sc_ipc_event));
+
+ if(0 == sc_rtc_timer_connect( ))
+ {
+ SCLOGD("sc_rtc_timer_init connect success.\n");
+ SCLOGD("sc_rtc_timer_init finish\n");
+
+ return sc_rtc_cb.src_id;
+ }
+
+ return -1;
}
int sc_rtc_timer_uninit(void)
{
- return 0;
+ int i;
+
+ sc_ipc_event *pevt;
+
+ sc_rtc_timer_have_init = 0;
+
+ for(i = 0; i < sizeof(rtc_timer_auto_notify_evt) / sizeof(sc_ipc_event); i ++)
+ {
+ pevt = &rtc_timer_auto_notify_evt[i];
+ sc_ipc_event_del(pevt);
+ }
+
+ SCLOGD("sc_rtc_timer_uninit finish\n");
+ return SC_ERR_SUCCESS;
}
+
+int sc_rtc_time_set(int srcid)
+{
+ int ret = -1;
+
+ ret = rtc_set_time(srcid);
+
+ return ret;
+}
+
+int sc_rtc_timer_add(unsigned long ulSec, int srcid, sc_rtc_timer_exp_cb rtc_notify)
+{
+ int ret = -1;
+
+ if(ulSec<=0)
+ {
+ return ret;
+ }
+
+ sc_rtc_cb.rtc_timerout_cb = rtc_notify;
+ ret = rtc_timer_add(ulSec,RTC_ID_SC_TIMER,srcid);
+
+ return ret;
+}
+
+int sc_rtc_timer_add_utc(struct tm *utc_sec, int srcid, int wakeup,sc_rtc_timer_exp_cb rtc_notify)
+{
+ time_t ulsec = 0;
+ int ret = -1;
+
+ ulsec = mktime(utc_sec);
+ sc_rtc_cb.rtc_timerout_cb = rtc_notify;
+ ret = rtc_timer_add_utc(utc_sec,RTC_ID_SC_ALARM,srcid,wakeup);
+
+ return ret;
+}
+
+int sc_rtc_time_get(int srcid, sc_rtc_time_get_cb rtc_notify)
+{
+ int ret =-1;
+
+ sc_rtc_cb.rtc_time_get_cb = rtc_notify;
+ ret = rtc_get_time(srcid);
+
+ return ret;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/sim/sc_sim.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/sim/sc_sim.c
index 242972f..f0cb746 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/sim/sc_sim.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/sim/sc_sim.c
@@ -45,7 +45,7 @@
{
return SC_ERR_SUCCESS;
}
- sc_ipc_start_loop(NULL);
+ sc_ipc_start_loop("sc-sim");
/* ×¢²áÖ÷¶¯Éϱ¨ÏûÏ¢´¦Àí*/
sc_ipc_register_events(sim_auto_notify_evt, sizeof(sim_auto_notify_evt) / sizeof(sc_ipc_event));
if(0 == sc_sim_connect(1)) {
@@ -172,15 +172,19 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_get_imsi(int sID, sc_sim_app_type_e app_type, char *imsi, int imsi_len)
+int sc_sim_get_imsi(int sID, char *imsi, int imsi_len)
{
sc_ipc_msg* pmsg_req = NULL;
sc_ipc_msg* pmsg_rsp = NULL;
int len = 0;
sim_info sim_info = {0};
SCLOGD("sc_sim_get_imsi enter \n");
+ if((NULL == imsi) || (0 == imsi_len))
+ {
+ SCLOGD("sc_sim_get_imsi param is invalide \n");
+ return SC_ERR_FAIL;
+ }
sim_info.slot = sID;
- sim_info.app_type = app_type;
pmsg_req = sc_sim_ipc_msg_create(MSG_CMD_GET_IMSI, MSG_CMD_GET_IMSI_RSP, 1, &sim_info, sizeof(sim_info));
if(NULL == pmsg_req)
@@ -212,8 +216,13 @@
sc_ipc_msg* pmsg_rsp = NULL;
int len = 0;
sim_info sim_info = {0};
- sim_info.slot = sID;
+ if((NULL == iccid) || (0 == iccid_len))
+ {
+ SCLOGD("sc_sim_get_iccid param is invalide \n");
+ return SC_ERR_FAIL;
+ }
+ sim_info.slot = sID;
pmsg_req = sc_sim_ipc_msg_create(MSG_CMD_GET_ICCID, MSG_CMD_GET_ICCID_RSP, 1, &sim_info, sizeof(sim_info));
if(NULL == pmsg_req)
{
@@ -239,14 +248,18 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_get_phone_num(int sID, sc_sim_app_type_e app_type, char *phone_num, int phone_num_len)
+int sc_sim_get_phone_num(int sID, char *phone_num, int phone_num_len)
{
sc_ipc_msg* pmsg_req = NULL;
sc_ipc_msg* pmsg_rsp = NULL;
int len = 0;
sim_info sim_info = {0};
+ if((NULL == phone_num) || (0 == phone_num_len))
+ {
+ SCLOGD("sc_sim_get_phone_num param is invalide \n");
+ return SC_ERR_FAIL;
+ }
sim_info.slot = sID;
- sim_info.app_type = app_type;
pmsg_req = sc_sim_ipc_msg_create(MSG_CMD_GET_PHONENUM, MSG_CMD_GET_PHONENUM_RSP, 1, &sim_info, sizeof(sim_info));
if(NULL == pmsg_req)
{
@@ -284,6 +297,7 @@
}
sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+
memcpy(list, pmsg_rsp->data, pmsg_rsp->data_len);
return SC_ERR_SUCCESS;
}
@@ -300,7 +314,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_enable_pin(int sID, sc_sim_app_type_e app_type, sc_sim_pin_e pin, const char *pin_value)
+int sc_sim_enable_pin(int sID, sc_sim_pin_e pin, const char *pin_value)
{
sc_ipc_msg* pmsg_req = NULL;
sc_ipc_msg* pmsg_rsp = NULL;
@@ -322,7 +336,6 @@
}
pin_info.sim_info.slot = sID;
- pin_info.sim_info.app_type = app_type;
pin_info.pin_type = pin;
strncpy(pin_info.old_pin, pin_value, sizeof(pin_info.old_pin)-1);
@@ -356,7 +369,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_disable_pin(int sID, sc_sim_app_type_e app_type, sc_sim_pin_e pin, const char *pin_value)
+int sc_sim_disable_pin(int sID, sc_sim_pin_e pin, const char *pin_value)
{
sc_ipc_msg* pmsg_req = NULL;
sc_ipc_msg* pmsg_rsp = NULL;
@@ -378,7 +391,6 @@
}
pin_info.sim_info.slot = sID;
- pin_info.sim_info.app_type = app_type;
pin_info.pin_type = pin;
strncpy(pin_info.old_pin, pin_value, sizeof(pin_info.old_pin)-1);
pmsg_req = sc_sim_ipc_msg_create(MSG_CMD_DISABLE_PIN, MSG_CMD_DISABLE_PIN_RSP, 1, &pin_info, sizeof(pin_info));
@@ -411,7 +423,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_verify_pin(int sID, sc_sim_app_type_e app_type, sc_sim_pin_e pin, const char *pin_value)
+int sc_sim_verify_pin(int sID, sc_sim_pin_e pin, const char *pin_value)
{
sc_ipc_msg* pmsg_req = NULL;
sc_ipc_msg* pmsg_rsp = NULL;
@@ -433,7 +445,6 @@
}
pin_info.sim_info.slot = sID;
- pin_info.sim_info.app_type = app_type;
pin_info.pin_type = pin;
strncpy(pin_info.old_pin, pin_value, sizeof(pin_info.old_pin)-1);
@@ -468,7 +479,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_change_pin(int sID, sc_sim_app_type_e app_type,sc_sim_pin_e pin, const char *old_pin_value, const char *new_pin_value)
+int sc_sim_change_pin(int sID, sc_sim_pin_e pin, const char *old_pin_value, const char *new_pin_value)
{
sc_ipc_msg* pmsg_req = NULL;
sc_ipc_msg* pmsg_rsp = NULL;
@@ -496,7 +507,6 @@
}
pin_info.sim_info.slot = sID;
- pin_info.sim_info.app_type = app_type;
pin_info.pin_type = pin;
strncpy(pin_info.old_pin, old_pin_value, sizeof(pin_info.old_pin)-1);
strncpy(pin_info.new_pin, new_pin_value, sizeof(pin_info.new_pin)-1);
@@ -532,7 +542,7 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sim_unblock_pin(int sID, sc_sim_app_type_e app_type, sc_sim_pin_e pin, const char *puk_value, const char *pin_value)
+int sc_sim_unblock_pin(int sID, sc_sim_pin_e pin, const char *puk_value, const char *pin_value)
{
sc_ipc_msg* pmsg_req = NULL;
sc_ipc_msg* pmsg_rsp = NULL;
@@ -560,7 +570,6 @@
}
pin_info.sim_info.slot = sID;
- pin_info.sim_info.app_type = app_type;
pin_info.pin_type = pin;
strncpy(pin_info.old_pin, puk_value, sizeof(pin_info.old_pin)-1);
strncpy(pin_info.new_pin, pin_value, sizeof(pin_info.new_pin)-1);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/sms/sc_sms.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/sms/sc_sms.c
index d251e8a..d934f1d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/sms/sc_sms.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/sms/sc_sms.c
@@ -12,92 +12,635 @@
#include <time.h>
#include <syslog.h>
#include <pthread.h>
+#include "sc_sms.h"
+#include "sc_ipc.h"
+#include "sc_sms_msg.h"
+#include "sc_tel_types.h"
+#include "zxic_list.h"
+
+typedef struct
+{
+ struct list_head list;
+ int id;
+ sc_sms_msg_async_cb_f cb;
+}sms_async_msg;
+
+typedef struct
+{
+ int id;
+ struct list_head ctx_list;
+}sms_context;
+
+static int sc_sms_connect(int enable);
+static int sc_sms_convert_reason(int reason);
+static sc_ipc_msg* sc_sms_ipc_msg_create(unsigned int req, unsigned int rsp, int wait, void *data, unsigned int datalen);
+static int handle_sms_pdu_msg_ind_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg);
+static int handle_sms_text_msg_ind_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg);
+static int handle_sms_send_message_async_rsp_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg);
+//text ¶ÌÐŽÓÊջص÷º¯Êý
+static sc_sms_msg_recv_cb_f g_sms_text_ind_cb = NULL;
+// PDU ¶ÌÐŽÓÊջص÷º¯Êý
+static sc_sms_pdu_recv_cb_f g_sms_pdu_ind_cb = NULL;
+//smsÄ£¿éÊÇ·ñ³õʼ»¯
+static int sc_sms_have_init = 0;
+//Òì²½»Øµ÷º¯ÊýÁбí
+sms_context g_sms_context = {0};
+//Ö÷¶¯Éϱ¨ÏûÏ¢Áбí
+static sc_ipc_event sms_auto_notify_evt[] = {
+ {0, 1, 0, MSG_SMS_CMD_SEND_MESSAGE_ASYNC_RSP, handle_sms_send_message_async_rsp_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_SEND_PDU_ASYNC_RSP, handle_sms_send_message_async_rsp_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_PDU_IND, handle_sms_pdu_msg_ind_evt, 0, 0},
+ {0, 1, 0, MSG_SMS_CMD_TEXT_IND, handle_sms_text_msg_ind_evt, 0, 0},
+};
/**
- * @brief ³õʼ»¯¿Í»§¶ËSIM½Ó¿Ú·þÎñ¡£
- * @param (in) SID SIM¿¨±êʶ¡£
+ * @brief ³õʼ»¯¿Í»§¶ËSMS½Ó¿Ú·þÎñ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_init(void)
+int sc_sms_init(int sID)
{
- return 0;
+ if(sc_sms_have_init)
+ {
+ return SC_ERR_SUCCESS;
+ }
+ sc_ipc_start_loop(NULL);
+ /* ×¢²áÖ÷¶¯Éϱ¨ÏûÏ¢´¦Àí*/
+ sc_ipc_register_events(sms_auto_notify_evt, sizeof(sms_auto_notify_evt) / sizeof(sc_ipc_event));
+ if(0 == sc_sms_connect(1)) {
+ SCLOGD("sc_sms_init connect telsvr success.\n");
+ }
+ INIT_LIST_HEAD(&g_sms_context.ctx_list);
+ SCLOGD("sc_sms_init finish\n");
+ return SC_ERR_SUCCESS;
}
/**
- * @brief ×¢Ïú¿Í»§¶ËSIM½Ó¿Ú·þÎñ¡£
- * @param (in) SID SIM¿¨±êʶ¡£
+ * @brief ×¢Ïú¿Í»§¶ËSMS½Ó¿Ú·þÎñ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_uninit(void)
+int sc_sms_uninit(int sID)
{
- return 0;
+ int i;
+ sc_ipc_event *pevt;
+
+ sc_sms_have_init = 0;
+
+ for(i = 0; i < sizeof(sms_auto_notify_evt) / sizeof(sc_ipc_event); i ++) {
+ pevt = &sms_auto_notify_evt[i];
+ sc_ipc_event_del(pevt);
+ }
+
+ SCLOGD("sc_sms_uninit finish\n");
+ return SC_ERR_SUCCESS;
}
/**
- * @brief ÉèÖöÌÐÅÖÐÐĺÅÂë¡£
- * @param (in) addr ¶ÌÐÅÖÐÐĺÅÂë
- * (in) len ¶ÌÐÅÖÐÐĺÅÂ볤¶È
+ * @brief ²úÉúÒì²½·¢ËͶÌÐÅʼþID¡£
+ * @param (in) ÎÞ¡£
+ * @param (out) ÎÞ¡£
+ * @return ʼþID
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static int sc_sms_increase_id(void)
+{
+ g_sms_context.id++;
+ if(g_sms_context.id >= INT_MAX)
+ {
+ g_sms_context.id = 0;
+ }
+
+ return g_sms_context.id;
+}
+
+/**
+ * @brief ¸ù¾Ýʼþid²éÕÒ¶ÔÓ¦µÄÒì²½»Øµ÷º¯Êý¡£
+ * @param (in) id ʼþid¡£
+ * @param (out) ÎÞ¡£
+ * @return Òì²½»Øµ÷º¯Êý
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static sms_async_msg* sc_sms_find_req_by_id(id)
+{
+ sms_async_msg *entry;
+ if (!list_empty(&g_sms_context.ctx_list))
+ {
+ list_for_each_entry(entry,&g_sms_context.ctx_list,list)
+ {
+ if(entry->id == id)
+ return entry;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * @brief ¸ù¾ÝʼþidÊͷŶÔÓ¦µÄÒì²½»Øµ÷º¯Êý¡£
+ * @param (in) id ʼþid¡£
+ * @param (out) ÎÞ¡£
+ * @return ÎÞ¡£
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static void sc_sms_free_req_by_id(id)
+{
+ sms_async_msg *entry, *pTmp;
+ if (!list_empty(&g_sms_context.ctx_list))
+ {
+ list_for_each_entry_safe(entry,pTmp,&g_sms_context.ctx_list,list)
+ {
+ if(entry && entry->id == id)
+ {
+ list_del(&(entry->list));
+ free(entry);
+ }
+ }
+ }
+}
+
+/**
+ * @brief ×¢²áÒì²½»Øµ÷º¯Êý¡£
+ * @param (in) id ʼþid¡£
+ * cb »Øµ÷º¯Êý¡£
+ * @param (out) ÎÞ¡£
+ * @return ÎÞ¡£
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_sms_register_async_msg(int id, sc_sms_msg_async_cb_f cb)
+{
+ sms_async_msg *sms_async_req_node =(sms_async_msg *)malloc(sizeof(sms_async_msg ));
+ if(NULL == sms_async_req_node)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ if(NULL != sc_sms_find_req_by_id(id))
+ {
+ free(sms_async_req_node);
+ SCLOGD("ERR: duplicate id: %d\n",id);
+ return SC_ERR_FAIL;
+ }
+
+ memset(sms_async_req_node,0,sizeof(sms_async_msg ));
+ sms_async_req_node->id = id;
+ sms_async_req_node->cb = cb;
+ list_add_tail((struct list_head *)sms_async_req_node,&g_sms_context.ctx_list);
+ return SC_ERR_SUCCESS;
+}
+
+/**
+ * @brief Á¬½Ó·þÎñ¶Ë¡£
+ * @param (in) enable 1£ºÁ¬½Ó 0£º¶Ï¿ª
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_set_service_center_addr(char* addr, int len)
+static int sc_sms_connect(int enable)
{
- return 0;
+ sc_ipc_msg *req_msg = NULL;
+ sc_ipc_msg *rsp_msg = NULL;
+ sc_sms_connect_t connect_info;
+ sc_sms_common_res_t *comm_res = NULL;
+ int ret = SC_ERR_SUCCESS;
+
+ if((enable != 0) && (enable != 1))
+ {
+ SCLOGD("sc_sms_connect invalid param!\n");
+ return SC_ERR_FAIL;
+ }
+
+ memset(&connect_info, 0, sizeof(connect_info));
+ connect_info.enable = enable;
+ req_msg = sc_sms_ipc_msg_create(MSG_SMS_CMD_CONN_REQ, MSG_SMS_CMD_CONN_RSP, 1, &connect_info, sizeof(connect_info));
+ if(NULL == req_msg) {
+ return SC_ERR_FAIL;
+ }
+
+ if(0 != sc_ipc_send_msg_wait_rsp(req_msg, &rsp_msg)) {
+ ret = SC_ERR_FAIL;
+ }
+ else {
+ comm_res = (sc_sms_common_res_t *)rsp_msg->data;
+ if(0 != comm_res->result) {
+ ret = SC_ERR_FAIL;
+ }
+ }
+ sc_ipc_msg_free(req_msg);
+ return ret;
+}
+
+/**
+ * @brief ´´½¨½ø³Ì¼äÏûÏ¢¡£
+ * @param (in) req ÇëÇóÏûÏ¢id
+ * rsp ÏìÓ¦ÏûÏ¢id
+ * wait ÊÇ·ñΪͬ²½ÏûÏ¢ 0£º·Çͬ²½ 1£ºÍ¬²½
+ * data ´«ÊäÊý¾Ý
+ * datalen ´«ÊäÊý¾Ý³¤¶È
+ * @param (out) ÎÞ¡£
+ * @return ·ÇNULL - ³É¹¦
+ * NULL-ʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static sc_ipc_msg* sc_sms_ipc_msg_create(unsigned int req, unsigned int rsp, int wait, void *data, unsigned int datalen)
+{
+ sc_ipc_msg *pmsg = NULL;
+ pmsg = (sc_ipc_msg *)malloc(sizeof(sc_ipc_msg) + datalen);
+ if(NULL == pmsg) {
+ return NULL;
+ }
+ memset(pmsg, 0, sizeof(sc_ipc_msg) + datalen);
+
+ pmsg->type = 1;
+ pmsg->fd_svr = sc_ipc_get_svr_fd(NULL);
+ pmsg->fd_cli = sc_ipc_get_self_fd();
+ pmsg->token = 0;
+ pmsg->msg_req = req;
+ pmsg->msg_rsp = rsp;
+ pmsg->wait_rsp = wait;
+ pmsg->data_len = datalen;
+
+ if(0 < datalen) {
+ memcpy(pmsg->data, data, pmsg->data_len);
+ }
+
+ return pmsg;
}
/**
* @brief »ñÈ¡¶ÌÐÅÖÐÐĺÅÂë¡£
- * @param (in) ÎÞ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£¡£
* @param (out) addr ¶ÌÐÅÖÐÐĺÅÂë¡£
- * (out) len ¶ÌÐÅÖÐÐĺÅÂ볤¶È¡£
+ * len ¶ÌÐÅÖÐÐĺÅÂ볤¶È¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_get_service_center_addr(char* addr, int len)
+int sc_sms_get_service_center_addr(int sID, char* addr, int len)
{
- return 0;
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ sc_sms_center_addr sms_center_info_req = {0};
+ sc_sms_center_addr* psms_center_info_rsp = NULL;
+ int reason = -1;
+ SCLOGD("sc_sms_get_service_center_addr enter \n");
+ if((NULL == addr) || (0 == len))
+ {
+ SCLOGD("sc_sms_get_service_center_addr param is invalide \n");
+ return SC_ERR_FAIL;
+ }
+ sms_center_info_req.slot = sID;
+ pmsg_req = sc_sms_ipc_msg_create(MSG_SMS_CMD_GET_CENTER_ADDR_REQ, MSG_SMS_CMD_GET_CENTER_ADDR_RSP, 1, &sms_center_info_req, sizeof(sms_center_info_req));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ memcpy(pmsg_req->data, &sms_center_info_req, sizeof(sc_sms_center_addr));
+ pmsg_req->data_len = sizeof(sc_sms_center_addr);
+
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+
+ psms_center_info_rsp = (sc_sms_center_addr*)pmsg_rsp->data;
+
+ if(0 != psms_center_info_rsp->result)
+ {
+ reason = sc_sms_convert_reason(psms_center_info_rsp->reason);
+ return reason;
+ //return SC_ERR_FAIL;
+ }
+
+ if(len > psms_center_info_rsp->len)
+ len = psms_center_info_rsp->len;
+
+ SCLOGD("len=%d, psms_center_info->addr=%s \n", len, psms_center_info_rsp->addr);
+
+ strncpy(addr, psms_center_info_rsp->addr, len);
+ return SC_ERR_SUCCESS;
+}
+
+/**
+ * @brief ÉèÖöÌÐÅÖÐÐĺÅÂë¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * addr ¶ÌÐÅÖÐÐĺÅÂë
+ * len ¶ÌÐÅÖÐÐĺÅÂ볤¶È
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_sms_set_service_center_addr(int sID, char* addr, int len)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+
+ sc_sms_center_addr sms_center_info = {0};
+ sms_op_result* psms_op_result = NULL;
+ int reason = -1;
+ SCLOGD("sc_sms_set_service_center_addr enter \n");
+ sms_center_info.slot = sID;
+
+ if((NULL == addr) || (0 == len))
+ {
+ SCLOGD("sc_sms_set_service_center_addr param is invalide \n");
+ return SC_ERR_FAIL;
+ }
+
+ if(len > SC_SMS_MAX_ADDR_LENGTH)
+ {
+ len = SC_SMS_MAX_ADDR_LENGTH;
+ }
+ strncpy(sms_center_info.addr, addr, len);
+
+ pmsg_req = sc_sms_ipc_msg_create(MSG_SMS_CMD_SET_CENTER_ADDR_REQ, MSG_SMS_CMD_SET_CENTER_ADDR_RSP, 1, &sms_center_info, sizeof(sc_sms_center_addr));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ memcpy(pmsg_req->data, &sms_center_info, sizeof(sc_sms_center_addr));
+ pmsg_req->data_len = sizeof(sc_sms_center_addr);
+
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+
+ psms_op_result = (sms_op_result*)pmsg_rsp->data;
+ if(0 != psms_op_result->result)
+ {
+ reason = sc_sms_convert_reason(psms_op_result->reason);
+ return reason;
+ }
+ return SC_ERR_SUCCESS;
}
/**
* @brief ·¢ËÍÎı¾¶ÌÐÅ¡£
- * @param (in) p_msg Îı¾¶ÌÐÅ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * p_msg Îı¾¶ÌÐÅ¡£
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_send_msg(sc_sms_msg_t* p_msg)
+int sc_sms_send_text_msg(int sID, sc_sms_msg_t* p_msg)
{
- return 0;
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int len = 0;
+ sms_msg_info sms_msg_info = {0};
+ sms_op_result* psms_op_result = NULL;
+ int reason = -1;
+ SCLOGD("sc_sms_send_text_msg enter \n");
+ if(NULL == p_msg)
+ {
+ SCLOGD("sc_sms_send_text_msg p_msg is NULL \n");
+ return SC_ERR_FAIL;
+ }
+
+ if((p_msg->format < SC_SMS_MSG_FORMAT_GSM_7BIT) || (p_msg->format > SC_SMS_MSG_FORMAT_UCS2))
+ {
+ return SC_ERR_BADPARAM;
+ }
+ sms_msg_info.slot = sID;
+ sms_msg_info.format = p_msg->format;
+ strncpy(sms_msg_info.addr, p_msg->addr, strlen(p_msg->addr));
+ if(p_msg->content_size > SC_SMS_MAX_SEND_MSG_LENGTH-1)
+ {
+ p_msg->content_size = SC_SMS_MAX_SEND_MSG_LENGTH-1;
+ }
+ strncpy(sms_msg_info.content, p_msg->content, p_msg->content_size);
+ sms_msg_info.content_size = p_msg->content_size;
+
+ pmsg_req = sc_sms_ipc_msg_create(MSG_SMS_CMD_SEND_MESSAGE_REQ, MSG_SMS_CMD_SEND_MESSAGE_RSP, 1, &sms_msg_info, sizeof(sms_msg_info));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+ psms_op_result = (sms_op_result*)pmsg_rsp->data;
+
+ if(0 != psms_op_result->result)
+ {
+ reason = sc_sms_convert_reason(psms_op_result->reason);
+ return reason;
+ }
+ return SC_ERR_SUCCESS;
+}
+
+/**
+ * @brief ·¢ËÍPDU¶ÌÐÅ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * p_pdu PDU¶ÌÐÅÄÚÈÝ¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_sms_send_pdu_msg(int sID, sc_sms_pdu_t* p_pdu)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ sc_ipc_msg* pmsg_rsp = NULL;
+ int len = 0;
+ sms_msg_info sms_msg_info = {0};
+ sms_op_result* psms_op_result = NULL;
+ int reason = -1;
+ SCLOGD("sc_sms_send_pdu_msg enter \n");
+ if(NULL == p_pdu)
+ {
+ SCLOGD("sc_sms_send_text_msg p_pdu is NULL \n");
+ return SC_ERR_FAIL;
+ }
+
+ sms_msg_info.slot = sID;
+ sms_msg_info.format = p_pdu->format;
+
+ if(p_pdu->content_size > SC_SMS_MAX_SEND_MSG_LENGTH-1)
+ {
+ p_pdu->content_size = SC_SMS_MAX_SEND_MSG_LENGTH-1;
+ }
+
+ memcpy(sms_msg_info.content, p_pdu->content, p_pdu->content_size);
+ sms_msg_info.content_size = p_pdu->content_size;
+ SCLOGD("sms_msg_info.content_size=%d\n", sms_msg_info.content_size);
+ pmsg_req = sc_sms_ipc_msg_create(MSG_SMS_CMD_SEND_PDU_REQ, MSG_SMS_CMD_SEND_PDU_RSP, 1, &sms_msg_info, sizeof(sms_msg_info));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ sc_ipc_send_msg_wait_rsp(pmsg_req, &pmsg_rsp);
+ psms_op_result = (sms_op_result*)pmsg_rsp->data;
+
+ if(0 != psms_op_result->result)
+ {
+ reason = sc_sms_convert_reason(psms_op_result->reason);
+ return reason;
+ }
+ return SC_ERR_SUCCESS;
}
/**
* @brief Òì²½·¢ËÍÎı¾¶ÌÐÅ¡£
- * @param (in) p_msg Îı¾¶ÌÐÅ¡£
- * (in) id Òì²½·¢ËÍÎı¾¶ÌÐÅʼþID¡£
- * (in) cb Òì²½·¢ËÍÎı¾¶ÌÐŻص÷º¯Êý¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * p_msg Îı¾¶ÌÐÅ¡£
+ * cb Òì²½·¢ËÍÎı¾¶ÌÐŻص÷º¯Êý¡£
+ * @param (out) id Òì²½·¢ËÍÎı¾¶ÌÐÅʼþID¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_sms_send_text_msg_async(int sID, sc_sms_msg_t* p_msg, int* id, sc_sms_msg_async_cb_f cb)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ int len = 0;
+ sms_msg_info sms_msg_info = {0};
+ int reason = -1;
+ int async_id = -1;
+ SCLOGD("sc_sms_send_text_msg_async enter \n");
+ if((NULL == p_msg) || (NULL == cb))
+ {
+ SCLOGD("sc_sms_send_text_msg_async param is invalid! \n");
+ return SC_ERR_FAIL;
+ }
+
+ async_id = sc_sms_increase_id();
+
+ sms_msg_info.format = p_msg->format;
+ strncpy(sms_msg_info.addr, p_msg->addr, strlen(p_msg->addr));
+ if(p_msg->content_size > SC_SMS_MAX_SEND_MSG_LENGTH-1)
+ {
+ p_msg->content_size = SC_SMS_MAX_SEND_MSG_LENGTH-1;
+ }
+ strncpy(sms_msg_info.content, p_msg->content, p_msg->content_size);
+ sms_msg_info.content_size = p_msg->content_size;
+ sms_msg_info.id = async_id;
+ pmsg_req = sc_sms_ipc_msg_create(MSG_SMS_CMD_SEND_MESSAGE_ASYNC_REQ, MSG_SMS_CMD_SEND_MESSAGE_ASYNC_RSP, 0, &sms_msg_info, sizeof(sms_msg_info));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ sc_ipc_send_msg(pmsg_req);
+
+ *id = async_id;
+ sc_sms_register_async_msg(async_id, cb);
+ return SC_ERR_SUCCESS;
+}
+
+/**
+ * @brief Òì²½·¢ËÍPDU¶ÌÐÅ¡£
+ * @param (in) sID SIM¿¨±êʶ¡£
+ * p_pdu PDU¶ÌÐÅÄÚÈÝ¡£ *
+ * cb Òì²½·¢ËÍPDU¶ÌÐŻص÷º¯Êý
+ * @param (out) id Òì²½·¢ËÍPDU¶ÌÐÅʼþID¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+int sc_sms_send_pdu_msg_async(int sID, sc_sms_pdu_t* p_pdu, int* id, sc_sms_pdu_async_cb_f cb)
+{
+ sc_ipc_msg* pmsg_req = NULL;
+ int len = 0;
+ sms_msg_info sms_msg_info = {0};
+ int reason = -1;
+ int async_id = -1;
+ SCLOGD("sc_sms_send_msg_async enter \n");
+ if((NULL == p_pdu) || (NULL == cb))
+ {
+ SCLOGD("sc_sms_send_pdu_msg_async param is invalid! \n");
+ return SC_ERR_FAIL;
+ }
+ async_id = sc_sms_increase_id();
+
+ sms_msg_info.format = p_pdu->format;
+
+ if(p_pdu->content_size > SC_SMS_MAX_SEND_MSG_LENGTH-1)
+ {
+ p_pdu->content_size = SC_SMS_MAX_SEND_MSG_LENGTH-1;
+ }
+ memcpy(sms_msg_info.content, p_pdu->content, p_pdu->content_size);
+ sms_msg_info.content_size = p_pdu->content_size;
+ sms_msg_info.id = async_id;
+ SCLOGD("sms_msg_info.content_size=%d\n", sms_msg_info.content_size);
+ pmsg_req = sc_sms_ipc_msg_create(MSG_SMS_CMD_SEND_PDU_ASYNC_REQ, MSG_SMS_CMD_SEND_PDU_ASYNC_RSP, 0, &sms_msg_info, sizeof(sms_msg_info));
+
+ if(NULL == pmsg_req)
+ {
+ return SC_ERR_NO_MEMORY;
+ }
+
+ sc_ipc_send_msg(pmsg_req);
+
+ *id = async_id;
+ sc_sms_register_async_msg(async_id, cb);
+
+ return SC_ERR_SUCCESS;
+}
+
+/**
+ * @brief Òì²½·¢ËͶÌÐÅÏìӦʼþ¡£
+ * @param (in) pevt ½ø³Ì¼äͨÐÅʼþ¡£
+ * pmsg ½ø³Ì¼äͨÐÅÏûÏ¢¡£
* @param (out) ÎÞ¡£
* @return 0 - ³É¹¦
* ÆäËüʧ°Ü:
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_send_msg_async(sc_sms_msg_t* p_msg, int* id, sc_sms_msg_async_cb_f cb)
-{
+static int handle_sms_send_message_async_rsp_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sms_async_msg* pasync_sms = NULL;
+ sms_op_result* psms_op_result = NULL;
+ int id = -1;
+ if(NULL == pmsg)
+ {
+ SCLOGD("handle_sms_send_message_async_rsp_evt pmsg is NULL!\n");
+ }
+ psms_op_result = (sms_op_result*)pmsg->data;
+ id = psms_op_result->id;
+ SCLOGD("handle_sms_send_message_async_rsp_evt id=%d \n", id);
+ pasync_sms = sc_sms_find_req_by_id(id);
+
+ if(NULL != pasync_sms)
+ {
+ if(pasync_sms->cb)
+ {
+ pasync_sms->cb(id, psms_op_result->result);
+ }
+
+ sc_sms_free_req_by_id(id);
+ }
+ else
+ {
+ SCLOGD("Don't find callback function! \n");
+ }
+
return 0;
}
@@ -110,38 +653,9 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_set_msg_recv_cb(sc_sms_msg_recv_cb_f* cb)
+int sc_sms_set_text_msg_recv_cb(sc_sms_msg_recv_cb_f cb)
{
- return 0;
-}
-
-/**
- * @brief ·¢ËÍPDU¶ÌÐÅ¡£
- * @param (in) p_pdu PDU¶ÌÐÅÄÚÈÝ¡£
- * @param (out) ÎÞ¡£
- * @return 0 - ³É¹¦
- * ÆäËüʧ°Ü:
- * @note ×¢ÊÍ
- * ×¢ÊÍ¡£
- */
-int sc_sms_send_pdu(sc_sms_pdu_t* p_pdu)
-{
- return 0;
-}
-
-/**
- * @brief Òì²½·¢ËÍPDU¶ÌÐÅ¡£
- * @param (in) p_pdu PDU¶ÌÐÅÄÚÈÝ¡£
- * (in) id Òì²½·¢ËÍPDU¶ÌÐÅʼþID
- * (in) cb Òì²½·¢ËÍPDU¶ÌÐŻص÷º¯Êý
- * @param (out) ÎÞ¡£
- * @return 0 - ³É¹¦
- * ÆäËüʧ°Ü:
- * @note ×¢ÊÍ
- * ×¢ÊÍ¡£
- */
-int sc_sms_send_pdu_async(sc_sms_pdu_t* p_pdu, int* id, sc_sms_pdu_async_cb_f cb)
-{
+ g_sms_text_ind_cb = cb;
return 0;
}
@@ -154,8 +668,105 @@
* @note ×¢ÊÍ
* ×¢ÊÍ¡£
*/
-int sc_sms_set_pdu_recv_cb(sc_sms_pdu_recv_cb_f cb)
+int sc_sms_set_pdu_msg_recv_cb(sc_sms_pdu_recv_cb_f cb)
{
+ g_sms_pdu_ind_cb = cb;
+ return 0;
+}
+
+/**
+ * @brief text¶ÌÐÅÖ÷¶¯Éϱ¨Ê¼þ¡£
+ * @param (in) pevt ½ø³Ì¼äͨÐÅʼþ¡£
+ * pmsg ½ø³Ì¼äͨÐÅÏûÏ¢¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static int handle_sms_text_msg_ind_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sms_text_ind_info* psms_text_info = NULL;
+ sc_sms_msg_t sms_msg = {0};
+ sc_sms_timestamp_t timestamp = {0};
+ sc_sms_user_data_head_t head = {0};
+ SCLOGD("handle_sms_text_msg_ind_evt \n");
+ if(NULL == pmsg)
+ {
+ SCLOGD("handle_sms_text_msg_ind_evt pmsg is NULL!\n");
+ }
+
+ psms_text_info = (sms_text_ind_info*)pmsg->data;
+
+ strncpy(sms_msg.addr, psms_text_info->oa, sizeof(sms_msg.addr)-1);
+ sms_msg.content_size = psms_text_info->length;
+ memcpy(sms_msg.content, psms_text_info->text, psms_text_info->length);
+
+ if(psms_text_info->dcs == 0)
+ {
+ sms_msg.format = SC_SMS_MSG_FORMAT_GSM_7BIT;
+ }
+ else if(psms_text_info->dcs == 4)
+ {
+ sms_msg.format = SC_SMS_MSG_FORMAT_BINARY_DATA;
+ }
+ else if(psms_text_info->dcs == 8)
+ {
+ sms_msg.format = SC_SMS_MSG_FORMAT_UCS2;
+ }
+
+ timestamp.year = psms_text_info->scts.year;
+ timestamp.month = psms_text_info->scts.month;
+ timestamp.day = psms_text_info->scts.day;
+ timestamp.hours = psms_text_info->scts.hours;
+ timestamp.minutes = psms_text_info->scts.minutes;
+ timestamp.seconds = psms_text_info->scts.seconds;
+ timestamp.timezone = psms_text_info->scts.timezone;
+
+ SCLOGD("format=%d, addr=%s, content_size=%d \n", sms_msg.format,sms_msg.addr, sms_msg.content_size);
+
+ SCLOGD("timestamp: %d/%d/%d %d:%d:%d-%d \n", 2000+timestamp.year, timestamp.month, timestamp.day, timestamp.hours, timestamp.minutes, timestamp.seconds, timestamp.timezone);
+ if(NULL != g_sms_text_ind_cb)
+ {
+ g_sms_text_ind_cb(&sms_msg, ×tamp, &head);
+ }
+ return 0;
+}
+
+/**
+ * @brief PDU¶ÌÐÅÖ÷¶¯Éϱ¨Ê¼þ¡£
+ * @param (in) pevt ½ø³Ì¼äͨÐÅʼþ¡£
+ * pmsg ½ø³Ì¼äͨÐÅÏûÏ¢¡£
+ * @param (out) ÎÞ¡£
+ * @return 0 - ³É¹¦
+ * ÆäËüʧ°Ü:
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static int handle_sms_pdu_msg_ind_evt(const sc_ipc_event* const pevt, const sc_ipc_msg* const pmsg)
+{
+ sms_pdu_ind_info* psms_pdu_info = NULL;
+ sc_sms_pdu_t sms_pdu_data = {0};
+ if(NULL == pmsg)
+ {
+ SCLOGD("handle_sms_pdu_msg_ind_evt pmsg is NULL!\n");
+ }
+ psms_pdu_info = (sms_pdu_ind_info*)pmsg->data;
+ if(psms_pdu_info->format == SMS_PDU_FORMAT_GW_PP)
+ {
+ sms_pdu_data.format = SC_SMS_PDU_FORMAT_GW_PP;
+ }
+ else if(psms_pdu_info->format == SMS_PDU_FORMAT_CDMA)
+ {
+ sms_pdu_data.format = SC_SMS_PDU_FORMAT_CDMA;
+ }
+
+ sms_pdu_data.content_size = psms_pdu_info->total_length;
+ memcpy(sms_pdu_data.content, psms_pdu_info->pdu, psms_pdu_info->total_length);
+ if(NULL != g_sms_pdu_ind_cb)
+ {
+ g_sms_pdu_ind_cb(&sms_pdu_data);
+ }
return 0;
}
@@ -171,4 +782,61 @@
int sc_sms_set_service_error_cb(sc_sms_service_error_cb_f cb)
{
return 0;
-}
\ No newline at end of file
+}
+
+/**
+ * @brief ´íÎóÔÒòת»»¡£
+ * @param (in) reason ·þÎñ¶ËÉϱ¨µÄ´íÎóÔÒò¡£
+ * @param (out) ÎÞ¡£
+ * @return ¿Í»§¶Ë´íÎóÔÒò
+ * @note ×¢ÊÍ
+ * ×¢ÊÍ¡£
+ */
+static int sc_sms_convert_reason(int reason)
+{
+ sc_sms_error_code_e error_code = SC_SMS_ERROR_UNKNOWN;
+ SCLOGD("the fail reason code = %d \n", reason);
+ switch(reason)
+ {
+ case 302:
+ error_code = SC_SMS_ERROR_NOTALLOW_OP;
+ break;
+ case 303:
+ error_code = SC_SMS_ERROR_NOTSUPPORT_OP;
+ break;
+ case 310:
+ error_code = SC_SMS_ERROR_SIM_NOT_INSERT;
+ break;
+ case 311:
+ error_code = SC_SMS_ERROR_REQUIRE_PIN;
+ break;
+ case 313:
+ error_code = SC_SMS_ERROR_SIM_INIT_FAIL;
+ break;
+ case 314:
+ error_code = SC_SMS_ERROR_SIM_BUSY;
+ break;
+ case 315:
+ error_code = SC_SMS_ERROR_SIM_ERROR;
+ break;
+ case 316:
+ error_code = SC_SMS_ERROR_REQUIRE_PUK;
+ break;
+ case 317:
+ error_code = SC_SMS_ERROR_REQUIRE_PIN2;
+ break;
+ case 318:
+ error_code = SC_SMS_ERROR_REQUIRE_PUK2;
+ break;
+ case 331:
+ error_code = SC_SMS_ERROR_NO_NETWORK_SERVICE;
+ break;
+ case 332:
+ error_code = SC_SMS_ERROR_NETWORK_TIMEOUT;
+ break;
+ default:
+ break;
+ }
+ //SCLOGD("the fail reason errorcode = %d \n", error_code);
+ return error_code;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/Makefile
new file mode 100755
index 0000000..bc017c3
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/Makefile
@@ -0,0 +1,62 @@
+#*******************************************************************************
+# include ZTE library makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+LIB_STATIC = libupi_ab.a
+LIB_SHARED = libupi_ab.so
+
+SRCS=$(wildcard ./src/*.c)
+OBJS = $(patsubst %.c,%.o,$(SRCS))
+
+#定义宏和头文件目录,要用+=,不要用=,否则会覆盖COMMON_MK里的值
+CFLAGS += -g -O2 -marm -I./upi_ab/inc
+CFLAGS += -Wall -g
+
+CFLAGS += -Werror=implicit-int \
+ -Werror=implicit-function-declaration \
+ -Werror=float-equal \
+ -Werror=return-type \
+ -Werror=enum-compare \
+ -Werror=init-self
+
+CFLAGS += -O2
+CFLAGS += -I../../app/include
+CFLAGS += -I./inc \
+ -I$(zte_lib_path)/libssl/install/include
+
+#下面不要修改
+CFLAGS += -fPIC
+LDFLAGS += -shared
+
+CFLAGS += -I$(LIB_DIR)/libnvram
+CFLAGS += -I$(LIB_DIR)/libsoftap
+CFLAGS += -I$(LIB_DIR)/libsofttimer
+
+LDLIBS += -lnvram -L$(LIB_DIR)/libnvram
+LDLIBS += -lsofttimer -L$(LIB_DIR)/libsofttimer
+LDLIBS += -latutils -L$(LIB_DIR)/libatutils
+LDLIBS += -lsoftap -L$(LIB_DIR)/libsoftap
+
+ifeq ($(MK_SDK_VERSION),yes)
+all:
+ echo "libupi_ab skip build in sdk version"
+else
+all: $(LIB_STATIC) $(LIB_SHARED)
+endif
+
+$(LIB_STATIC) : $(OBJS)
+ $(AR) rcs $(LIB_STATIC) $(OBJS)
+
+$(LIB_SHARED): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^
+
+romfs:
+ $(ROMFSINST) $(LIB_SHARED) /lib/$(LIB_SHARED)
+
+clean:
+ifeq ($(MK_SDK_VERSION),yes)
+ echo "libupi_ab skip clean in sdk version"
+else
+ -@rm *.a *.o *.so $(LIB_SHARED) $(LIB_STATIC) $(OBJS)
+endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/inc/upi_fotaflag_partition.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/inc/upi_fotaflag_partition.h
new file mode 100755
index 0000000..eae8e70
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/inc/upi_fotaflag_partition.h
@@ -0,0 +1,154 @@
+/**
+* @file upi_fotaflag_partition.h
+* @brief °æ±¾·ÖÇøÅäÖÃÐÅÏ¢
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author
+*
+*/
+
+#ifndef _UPI_FOTAFLAG_PARTITION_H
+#define _UPI_FOTAFLAG_PARTITION_H
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+
+// fotaflagÔÚzftl5ÖÐÕ¼ÓõÄ×Ö½ÚÊý
+#define FOTA_FLAG_SIZE (32)
+
+#define PARTITION_NAME_FOTA_FLAG "flags"
+
+// fotaflag ±éÀúÓú궨Òå
+#define ZTE_DUA_FOTAFLAG_PART ("/device/name")
+#define ZTE_DUA_FOTAFLAG ("fotaflag")
+#define ZTE_DUA_PART_UPDATED_DEV ("/dev")
+#define ZTE_DUA_FOTAFLAG_BLOCK_PART ("/sys/class/block")
+
+#define LOG_FUNC_BEGIN
+#define LOG_FUNC_END
+#define MAX_PATH_LEN (256)
+
+/* Êý¾ÝÀàÐÍ */
+typedef enum
+{
+ SYSTEM_FLAG_FOTA_MAIN = 0,
+ SYSTEM_FLAG_FOTA_BACKUP,
+} E_SYSTEM_FLAG_DATA_TYPE;
+
+
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+
+/* ÔÚflags·ÖÇøÀïÆ«ÒÆµØÖ· */
+
+#define FLAGS_MAGIC (0x464C4147UL)
+
+
+
+#define DUALSYSTEM_STATUS_BOOTABLE (0xB0AB) /* ¿ÉÆô¶¯ */
+#define DUALSYSTEM_STATUS_SUCCESSFUL (0x5CCF) /* Äܳɹ¦Æô¶¯ */
+#define DUALSYSTEM_STATUS_UNBOOTABLE (0xBABE) /* ²»¿ÉÆô¶¯ */
+
+typedef struct
+{
+ int status; /* bootable/successful/unbootable */
+ int try_cnt;
+} T_DualSystem_Status;
+
+typedef enum
+{
+ DUAL_SYSTEM = 0x875A, /* µÚÒ»¸öϵͳ */
+ DUAL_SYSTEM2 = 0x986B, /* µÚ¶þ¸öϵͳ */
+} T_BOOT_TARGET;
+
+/* ˫ϵͳÀàÐÍ */
+typedef enum
+{
+ DUALSYSTEM_RECOVERY = 0x7575, /* normal-recovery˫ϵͳ */
+ DUALSYSTEM_AA = 0xAAAA, /* AA˫ϵͳ */
+ DUALSYSTEM_AB = 0xABAB /* AB˫ϵͳ */
+} T_BOOT_DUALSYSTEM_TYPE;
+
+typedef struct
+{
+ unsigned int magic; /* Êý¾ÝÓÐЧÐÔħÊõ×Ö */
+ T_BOOT_TARGET boot_to; /* µ±Ç°Æô¶¯ÏµÍ³±êÖ¾*/
+ unsigned int fota_status; /* fota״̬ */
+ T_DualSystem_Status system; /* µÚÒ»¸öϵͳ״̬ */
+ T_DualSystem_Status system2; /* µÚ¶þ¸öϵͳ״̬ */
+} T_BOOT_FOTA_FLAG;
+
+typedef struct
+{
+ unsigned int magic; /* Êý¾ÝÓÐЧÐÔħÊõ×Ö */
+ T_BOOT_DUALSYSTEM_TYPE dualsys_type; /* ˫ϵͳÀàÐÍ */
+ char system_boot_env[128];
+ char system2_boot_env[128];
+} T_BOOT_ENV;
+
+
+typedef struct
+{
+ T_BOOT_FOTA_FLAG boot_flag;
+ T_BOOT_ENV boot_env;
+} T_FOTA_FLAG_INFO;
+
+typedef struct {
+ unsigned int mtd_totalsize; // mtd device total size
+ unsigned int mtd_pageperblock; // mtd device page per block
+ unsigned int mtd_blocksize; // mtd device block size
+ unsigned int mtd_pagesize; // mtd device page size
+ unsigned int mtd_oobsize; // mtd device oob size
+// char mtd_path[256]; // mtd path
+ int parti_file_desc; // partition update file description
+}partition_mtd_info_t;
+
+/*******************************************************************************
+ * Global variable declarations *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Global function declarations *
+ ******************************************************************************/
+
+void upi_reboot();
+int check_fota_flag_partition(void);
+
+
+
+int upi_get_boot_env(T_BOOT_ENV* boot_env);
+int upi_set_boot_fota_flag(T_BOOT_FOTA_FLAG* fota_flag);
+int upi_get_system_boot_to();
+int upi_set_system_boot_to(int boot_to, int boot_to_status);
+int upi_set_system_status(int system, int status);
+
+int upi_get_boot_flag(T_BOOT_FOTA_FLAG *boot_flag);
+int init_fotaflag_partition();
+
+int upi_get_system_info(T_FOTA_FLAG_INFO *p_system_info);
+
+// Éý¼¶ºófota±êÖ¾£¬Ö÷ÒªÓÃÀ´±êÖ¾ÊÇ·ñÐèҪͬ²½NV
+int upi_get_system_fota_status();
+int upi_set_system_fota_stauts(int status);
+
+
+
+
+/*******************************************************************************
+ * Inline function implementations *
+ ******************************************************************************/
+
+
+
+
+#endif // _UPI_FOTAFLAG_PARTITION_H
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/inc/zxic_fota_ab_upgrade.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/inc/zxic_fota_ab_upgrade.h
new file mode 100755
index 0000000..bea70b8
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/inc/zxic_fota_ab_upgrade.h
@@ -0,0 +1,366 @@
+/**
+* @file zxic_fota_ab_upgrade.h
+* @brief ABϵͳFOTAÉý¼¶¶ÔÍâ½Ó¿Ú
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author
+*
+*/
+
+#ifndef ZXIC_FOTA_AB_UPGRADE_H
+#define ZXIC_FOTA_AB_UPGRADE_H
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+
+
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+
+#define Z_FOTA_SUCCESS (0)
+#define Z_FOTA_FAIL (-1)
+
+/*
+ ºê¶¨Ò壺Éý¼¶×´Ì¬ºê
+ */
+#define Z_UPGRAGE_STATUS_FREE (-1)
+#define Z_UPGRADE_STATUS_VERIFING (0)
+#define Z_UPGRADE_STATUS_VERIFY_SUCCESS (1)
+#define Z_UPGRADE_STATUS_VERIFY_FAIL (2)
+#define Z_UPGRADE_STATUS_UPDATING (3)
+#define Z_UPGRADE_STATUS_UPDATE_SUCCESS (4)
+#define Z_UPGRADE_STATUS_UPDATE_FAIL (5)
+
+
+/*
+ * ºê¶¨Ò壺˫ϵͳÆô¶¯£¬ÏµÍ³×´Ì¬
+ */
+#define Z_DUALSYSTEM_STATUS_BOOTABLE (0xB0AB) /* ¿ÉÆô¶¯ */
+#define Z_DUALSYSTEM_STATUS_SUCCESSFUL (0x5CCF) /* Äܳɹ¦Æô¶¯ */
+#define Z_DUALSYSTEM_STATUS_UNBOOTABLE (0xBABE) /* ²»¿ÉÆô¶¯ */
+
+
+#define Z_DUAL_SYSTEM (0x875A)
+#define Z_DUAL_SYSTEM2 (0x986B)
+
+
+/*
+ *ºê¶¨Ò壺Éý¼¶ÀàÐÍ
+ */
+#define Z_UPGRADE_TYPE_ALL (0) /* È«°æ±¾ÀàÐÍ */
+#define Z_UPGRADE_TYPE_PLATFORM (1) /* ƽ̨ÀàÐÍ */
+#define Z_UPGRADE_TYPE_OEM (2) /* OEMÀàÐÍ */
+#define Z_UPGRADE_TYPE_INVALID (-1) /* ÎÞЧÀàÐÍ */
+
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+
+
+
+/*
+ * ˵Ã÷£ºÉý¼¶×´Ì¬ÐÅÏ¢½á¹¹Ìå
+ * upgrade_status:Éý¼¶×´Ì¬£¬È¡Öµ²Î¿¼¡¾Éý¼¶×´Ì¬ºê¡¿
+ * total_size:´ýдÈëÉý¼¶·ÖÇø×ܳ¤¶È
+ * upgraded_size:ÒÑÉý¼¶·ÖÇø³¤¶È
+ * ×¢Ò⣺
+ * ³¤¶ÈÐÅÏ¢½öÔÚÉý¼¶×´Ì¬ÎªUPGRADE_STATUS_UPDATINGʱÓÐЧ£¬ÆäËü״̬²ÎÊýÖµÎÞʵ¼ÊÒâÒå
+ */
+
+typedef struct {
+ int upgrade_status;
+ int total_size;
+ int upgraded_size;
+}z_upgrade_status_info_t;
+
+
+/*
+ * ˵Ã÷£ºµ¥ÏµÍ³×´Ì¬
+ * system:µ±Ç°ÏµÍ³ Z_DUAL_SYSTEM¡¢Z_DUAL_SYSTEM2
+ * status:ϵͳ״̬ Z_DUALSYSTEM_STATUS_BOOTABLE¡¢Z_DUALSYSTEM_STATUS_SUCCESSFUL¡¢Z_DUALSYSTEM_STATUS_UNBOOTABLE
+ * try_cnt:ÖØÆô´ÎÊý
+ * ×¢Ò⣺
+ * ³¤¶ÈÐÅÏ¢½öÔÚÉý¼¶×´Ì¬ÎªUPGRADE_STATUS_UPDATINGʱÓÐЧ£¬ÆäËü״̬²ÎÊýÖµÎÞʵ¼ÊÒâÒå
+ */
+typedef struct {
+ int system;
+ int status; /* bootable/successful/unbootable */
+ int try_cnt;
+}z_system_info_t;
+
+
+/*
+ * ˵Ã÷£ºÏµÍ³×´Ì¬
+ * boot_to:ÏÂ´ÎÆô¶¯ÏµÍ³
+ * system_1:ϵͳ1״̬
+ * system_2:ϵͳ2״̬
+ * ×¢Ò⣺
+ *
+ */
+typedef struct
+{
+ int boot_to; /* µ±Ç°Æô¶¯ÏµÍ³±êÖ¾*/
+ int fota_status;
+ z_system_info_t system_1;
+ z_system_info_t system_2;
+}z_upgrade_system_info_t;
+
+
+typedef struct {
+ z_upgrade_status_info_t *status;
+ void(* status_cb)(z_upgrade_status_info_t *status);
+} z_upgrade_flush_status_t;
+
+
+//typedef void(* flush_upgrade_status)(z_upgrade_status_info_t *status);
+
+
+/*******************************************************************************
+ * Global variable declarations *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Global function declarations *
+ ******************************************************************************/
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_verify
+ * ¹¦ÄÜÃèÊö:Éý¼¶°üºÏ·¨ÐÔУÑé
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS УÑé³É¹¦
+ * Z_FOTA_FAILУÑéʧ°Ü
+ * ×¢Òâ:
+ * ͬ²½½Ó¿Ú£¬½¨ÒéÒì²½µ÷ÓÃ
+ ********************************************************************************/
+int zxic_dual_verify();
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_upgrade
+ * ¹¦ÄÜÃèÊö:¿ªÊ¼Éý¼¶
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ * flush_upgrade_status ״̬»Øµ÷½Ó¿Ú
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS Éý¼¶³É¹¦
+ * Z_FOTA_FAILÉý¼¶Ê§°Ü
+ * ×¢Òâ:
+ * ͬ²½½Ó¿Ú£¬½¨ÒéÒì²½µ÷Ó㬱ÜÃâ×èÈû
+ * ״̬»Øµ÷½Ó¿ÚÖнûÖ¹×ö¸´ÔÓ²Ù×÷£¬½¨Òé½ö½øÐÐ״̬Êä³ö
+********************************************************************************/
+
+int zxic_dual_upgrade(z_upgrade_flush_status_t* flush_status);
+
+
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_upgrade_status
+ * ¹¦ÄÜÃèÊö:Éý¼¶×´Ì¬»ñÈ¡
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:
+ * upgrade_info_t *upgrade_info Éý¼¶×´Ì¬
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS Éý¼¶³É¹¦
+ * Z_FOTA_FAILÉý¼¶Ê§°Ü
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_upgrade_status(z_upgrade_status_info_t *upgrade_info);
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_current_system
+ * ¹¦ÄÜÃèÊö:»ñÈ¡µ±Ç°ÔËÐÐϵͳ
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * µ±Ç°ÔËÐÐϵͳ
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_current_system();
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_boot_to_system
+ * ¹¦ÄÜÃèÊö:»ñÈ¡ÖØÆôºóÄ¿±êÆô¶¯ÏµÍ³
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * µ±Ç°ÔËÐÐϵͳ
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_boot_to_system();
+
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_set_boot_to_system
+ * ¹¦ÄÜÃèÊö:ÉèÖÃÄ¿±êÔËÐÐϵͳ
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ * system:Ä¿±êϵͳ
+ * reboot_flag:ÉèÖÃÍê±ÏºóÊÇ·ñÁ¢¼´ÖØÆô 0:²»ÖØÆô,1:ÖØÆô
+ * Êä³ö²ÎÊý:
+ * ϵͳ״̬ÐÅÏ¢
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS »ñÈ¡ÐÅÏ¢³É¹¦
+ * Z_FOTA_FAIL»ñÈ¡ÐÅϢʧ°Ü
+ * ×¢Òâ:
+ * ·µ»ØÖµ£ºÖ»ÔÚ²»ÐèÒªÖØÆôʱÓÐЧ
+********************************************************************************/
+int zxic_dual_set_boot_to_system(int system, int reboot_flag);
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_system_status
+ * ¹¦ÄÜÃèÊö:²éѯABϵͳ״̬
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:
+ * system_info ϵͳ״̬ÐÅÏ¢
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS »ñÈ¡ÐÅÏ¢³É¹¦
+ * Z_FOTA_FAIL»ñÈ¡ÐÅϢʧ°Ü
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_system_status(z_upgrade_system_info_t *system_info);
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_set_system_status
+ * ¹¦ÄÜÃèÊö:ÉèÖÃϵͳ״̬
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ * system:´ýÉèÖÃϵͳ
+ * status:ÉèÖÃϵͳ״̬
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS »ñÈ¡ÐÅÏ¢³É¹¦
+ * Z_FOTA_FAIL»ñÈ¡ÐÅϢʧ°Ü
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_set_system_status(int system, int status);
+
+/*******************************************************************************
+ * Inline function implementations *
+ ******************************************************************************/
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_init_flag_partition
+ * ¹¦ÄÜÃèÊö:³õʼ»¯flag·ÖÇøÐÅÏ¢,²âÊÔ½Ó¿Ú£¬Õý³£Á÷³Ì²»¿ÉʹÓÃ
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý:ÎÞ
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS »ñÈ¡ÐÅÏ¢³É¹¦
+ * Z_FOTA_FAIL»ñÈ¡ÐÅϢʧ°Ü
+ * ×¢Òâ:
+********************************************************************************/
+
+int zxic_init_flag_partition();
+
+
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_fota_status_for_nv
+ * ¹¦ÄÜÃèÊö:»ñȡϵͳNVÊÇ·ñͬ²½±êÖ¾
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * ״̬±êÖ¾ 0£º²»ÐèҪͬ²½£¬1£ºÐèҪͬ²½
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_fota_status_for_nv();
+int dual_AB_get_fota_status_for_nv();
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_set_fota_status_for_nv
+ * ¹¦ÄÜÃèÊö:ÉèÖÃϵͳNVÊÇ·ñͬ²½±êÖ¾
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ * status:״̬±êÖ¾£¬0£º²»ÐèҪͬ²½£¬1£ºÐèҪͬ²½
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS ÉèÖóɹ¦
+ * Z_FOTA_FAIL ÉèÖÃʧ°Ü
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_set_fota_status_for_nv(int status);
+int dual_AB_set_fota_status_for_nv(int status);
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_sync_system
+ * ¹¦ÄÜÃèÊö: AB-AAϵͳͬ²½
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý: ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS ͬ²½³É¹¦
+ * Z_FOTA_FAIL ͬ²½Ê§°Ü
+ * ×¢Òâ:
+ ********************************************************************************/
+int zxic_dual_sync_system(void);
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_upgrade_type
+ * ¹¦ÄÜÃèÊö: »ñÈ¡Éý¼¶ÀàÐÍ
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý: ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_UPGRADE_TYPE_ALL È«°æ±¾ÀàÐÍ
+ * Z_UPGRADE_TYPE_PLATFORM ƽ̨ÀàÐÍ
+ * Z_UPGRADE_TYPE_OEM OEMÀàÐÍ
+ * Z_UPGRADE_TYPE_INVALID ÎÞЧÀàÐÍ
+ * ×¢Òâ:
+ ********************************************************************************/
+int zxic_dual_get_upgrade_type(void);
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_sync_status
+ * ¹¦ÄÜÃèÊö: »ñȡͬ²½×´Ì¬
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:
+ * sync_status ͬ²½×´Ì¬
+ * ·µ»ØÖµ£ºÎÞ
+ * ×¢Òâ:
+ ********************************************************************************/
+void zxic_dual_get_sync_status(int *sync_status);
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_set_sync_status
+ * ¹¦ÄÜÃèÊö: ÉèÖÃͬ²½×´Ì¬
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ * sync_status ͬ²½×´Ì¬
+ * Êä³ö²ÎÊý: ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS ÉèÖóɹ¦
+ * Z_FOTA_FAIL ÉèÖÃʧ°Ü
+ * ×¢Òâ:
+ ********************************************************************************/
+int zxic_dual_set_sync_status(int sync_status);
+
+
+
+#endif // ZXIC_FOTA_AB_UPGRADE_H
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/src/upi_fotaflag_partition.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/src/upi_fotaflag_partition.c
new file mode 100755
index 0000000..3e5a9fd
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/src/upi_fotaflag_partition.c
@@ -0,0 +1,786 @@
+/**
+* @file upi_fotaflag_partition.c
+* @brief °æ±¾FOTA±êÖ¾·ÖÇøÅäÖÃÐÅÏ¢
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+*/
+
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <mtd/mtd-abi.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+
+
+//#include "upi_update.h"
+#include "upi_fotaflag_partition.h"
+//#include "upi_public.h"
+//#include "upi_mtd.h"
+//#include "upi_log.h"
+//#include "upi_img_interface.h"
+#include "mtd_api.h"
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+#define GOOD_BLOCK (0)
+#define BAD_BLOCK (1)
+
+#define INIT_VALID_BLOCKS_COUNT (8)
+
+#define upi_malloc malloc
+#define upi_free free
+
+#define upi_log(...)
+#define upi_err(...)
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Global variable declarations *
+ ******************************************************************************/
+
+
+
+/*******************************************************************************
+ * Static function declarations *
+ ******************************************************************************/
+
+
+static void show_fota_flag_info(int line, char* title, T_FOTA_FLAG_INFO *p_info)
+{
+#if 0
+ upi_log("Line %d:%s", line, title);
+ upi_log("boot_flag.magic :0x%08X", p_info->boot_flag.magic);
+ upi_log("boot_flag.boot_to :0x%08X[%d]", p_info->boot_flag.boot_to, p_info->boot_flag.boot_to);
+ upi_log("boot_flag.fota_status :%d", p_info->boot_flag.fota_status);
+ upi_log("boot_flag.system.status :0x%08X[%d]", p_info->boot_flag.system.status, p_info->boot_flag.system.status);
+ upi_log("boot_flag.system.try_cnt :%d", p_info->boot_flag.system.try_cnt);
+ upi_log("boot_flag.system2.status :0x%08X[%d]", p_info->boot_flag.system2.status, p_info->boot_flag.system2.status);
+ upi_log("boot_flag.system2.try_cnt :%d", p_info->boot_flag.system2.try_cnt);
+ upi_log("boot_env.magic :0x%08X", p_info->boot_env.magic);
+ upi_log("boot_env.dualsys_type :0x%08X[%d]", p_info->boot_env.dualsys_type, p_info->boot_env.dualsys_type);
+#endif
+}
+
+
+static void copy_fota_flag_info(T_FOTA_FLAG_INFO *dest, T_FOTA_FLAG_INFO *src)
+{
+ dest->boot_flag.magic = src->boot_flag.magic;
+ dest->boot_flag.boot_to =src->boot_flag.boot_to;
+ dest->boot_flag.fota_status = src->boot_flag.fota_status;
+ dest->boot_flag.system.status = src->boot_flag.system.status;
+ dest->boot_flag.system.try_cnt = src->boot_flag.system.try_cnt;
+ dest->boot_flag.system2.status = src->boot_flag.system2.status;
+ dest->boot_flag.system2.try_cnt = src->boot_flag.system2.try_cnt;
+ dest->boot_env.magic = src->boot_env.magic;
+ dest->boot_env.dualsys_type = src->boot_env.dualsys_type;
+
+}
+
+static int upi_get_boot_flags_content(T_FOTA_FLAG_INFO *main, int *p_main_index, T_FOTA_FLAG_INFO *backup, int *p_backup_index)
+{
+
+ int ret = -1;
+ int fd_dst = -1;
+ char mtd_path[MAX_PATH_LEN] = {0};
+ struct mtd_info_user meminfo;
+ partition_mtd_info_t mtd_info;
+ int index = 0;
+ int block_num = 0;
+ int good_index = 0;
+ int read_len = 0;
+
+ long long offs = 0;
+
+ int block_flag = GOOD_BLOCK;
+
+ ret = mtd_find(PARTITION_NAME_FOTA_FLAG, DEVICE_MTD, mtd_path, MAX_PATH_LEN);
+ if (ret < 0) {
+ upi_err("partition[%s] name is not find", PARTITION_NAME_FOTA_FLAG);
+ goto error;
+ }
+
+ if ((fd_dst = open(mtd_path, O_RDWR | O_SYNC)) < 0) {
+ upi_err("Open flash error: %d[%s]", errno, strerror(errno));
+ goto error;
+ }
+ mtd_info.parti_file_desc = fd_dst;
+
+
+ // Fill in MTD device capability structure
+ if (ioctl(fd_dst, MEMGETINFO, &meminfo) != 0) {
+ upi_err("get flash info error: %d[%s]", errno, strerror(errno));
+ goto error_close;
+ }
+
+ // out nand info
+ mtd_info.mtd_blocksize = meminfo.erasesize;
+ mtd_info.mtd_oobsize = meminfo.oobsize;
+ mtd_info.mtd_pageperblock = meminfo.erasesize / meminfo.writesize;
+ mtd_info.mtd_pagesize = meminfo.writesize;
+ mtd_info.mtd_totalsize = meminfo.size;
+
+ block_num = mtd_info.mtd_totalsize / mtd_info.mtd_blocksize;
+
+ for(index=0; (good_index <2 && index < block_num); index++){
+
+ offs = index * mtd_info.mtd_blocksize;
+ if (ioctl(mtd_info.parti_file_desc , MEMGETBADBLOCK, &offs) == 0) {
+ block_flag = GOOD_BLOCK;
+ } else {
+ upi_log("Fotaflag block [%d] is bad, errno no:%d[%s]", index, errno, strerror(errno));
+ block_flag = BAD_BLOCK;
+ }
+
+ if(block_flag == GOOD_BLOCK){
+ if(lseek(mtd_info.parti_file_desc, index*mtd_info.mtd_blocksize, SEEK_SET) < 0){
+ upi_err("Lseek error: %d[%s]", errno, strerror(errno));
+ goto error_close;
+ }
+
+ if(good_index == 0){
+ read_len = read(mtd_info.parti_file_desc, (unsigned char*)main, sizeof(T_FOTA_FLAG_INFO));
+ *p_main_index = index;
+ }else if(good_index == 1){
+ read_len = read(mtd_info.parti_file_desc, (unsigned char*)backup, sizeof(T_FOTA_FLAG_INFO));
+ *p_backup_index = index;
+ }else{
+ upi_err("Read enough info ");
+ break;
+ }
+
+ if (read_len < sizeof(T_FOTA_FLAG_INFO)) {
+ upi_err("Read len (%d) < need len (%d)!", read_len, sizeof(T_FOTA_FLAG_INFO));
+ goto error_close;
+ }
+
+ good_index++;
+ }
+
+ }
+
+ close(fd_dst);
+ return 0;
+
+
+
+error_close:
+
+ close(fd_dst);
+error:
+ return -1;
+
+}
+
+
+static int upi_write_fota_flag_img_content(partition_mtd_info_t *p_mtd_info, int index, unsigned char * content, int len)
+{
+ struct erase_info_user erase_info;
+ int write_len = 0;
+ long long offs = 0;
+
+ erase_info.start = index * p_mtd_info->mtd_blocksize;
+ erase_info.length = p_mtd_info->mtd_blocksize;
+
+
+ offs = (long long)index * p_mtd_info->mtd_blocksize;
+#if 0
+ // enable mtd writeable
+ if(ioctl(p_mtd_info->parti_file_desc, WRITEENABLE, 0) != 0){
+ upi_err("Failed to enable mtd writeable! error:%d[%s]", errno, strerror(errno));
+ return -1;
+ }
+#endif
+ if (ioctl(p_mtd_info->parti_file_desc , MEMGETBADBLOCK, &offs) != 0){
+ upi_err("Ioctl [MEMGETBADBLOCK] block: %d , change to be bad block errno: %d[%s]!", index, errno, strerror(errno));
+ return BAD_BLOCK;
+ }
+
+ if(ioctl(p_mtd_info->parti_file_desc, MEMERASE, &erase_info) < 0)
+ {
+ upi_err("Ioctl [MEMERASE] block: %d error, errno=%d[%s]!", index, errno, strerror(errno));
+ return -1;
+ }
+
+ if (ioctl(p_mtd_info->parti_file_desc , MEMGETBADBLOCK, &offs) != 0){
+ upi_err("Ioctl [MEMGETBADBLOCK] block:%d , change to be bad block errno: %d[%s]!", index, errno, strerror(errno));
+ return BAD_BLOCK;
+ }
+
+ /*
+ *[comlee]: ÎļþÖ¸ÕëÆ«ÒÆµ½ÏàÓ¦µØÖ·£¬È»ºóд.
+ */
+ if(lseek(p_mtd_info->parti_file_desc, index * p_mtd_info->mtd_blocksize , SEEK_SET)<0){
+ upi_err("Lseek error: %d[%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ write_len = write(p_mtd_info->parti_file_desc, content, p_mtd_info->mtd_blocksize);
+
+ if (write_len != p_mtd_info->mtd_blocksize) {
+ upi_err("Write flash error: %d[%s]", errno, strerror(errno));
+ return -1;
+ }
+#if 0
+ // disable mtd writeable
+ if(ioctl(p_mtd_info->parti_file_desc, WRITEDISABLE, 0) != 0){
+ upi_err("Failed to disable mtd writeable! error:%d[%s]", errno, strerror(errno));
+ }
+#endif
+ return 0;
+
+}
+
+static int upi_set_boot_flags_content(T_FOTA_FLAG_INFO *info, int *p_main_index, int *p_backup_index)
+{
+ int ret = -1;
+ int fd_dst = -1;
+ char mtd_path[MAX_PATH_LEN] = {0};
+ struct mtd_info_user meminfo;
+ partition_mtd_info_t mtd_info;
+
+ unsigned char *real_write_content = NULL;
+ T_FOTA_FLAG_INFO *p_write = NULL;
+
+ int index = 0;
+ int block_num = 0;
+ int main_index = *p_main_index;
+ int back_index = *p_backup_index;
+
+ LOG_FUNC_BEGIN
+
+ ret = mtd_find(PARTITION_NAME_FOTA_FLAG, DEVICE_MTD, mtd_path, MAX_PATH_LEN);
+ if (ret < 0) {
+ upi_err("Partition[%s] not found!", PARTITION_NAME_FOTA_FLAG);
+ return -1;
+ }
+
+ if ((fd_dst = open(mtd_path, O_RDWR | O_SYNC)) < 0) {
+ upi_err("Open flash error: %d[%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ // Fill in MTD device capability structure
+ if (ioctl(fd_dst, MEMGETINFO, &meminfo) != 0) {
+ upi_err("Get flash info error: %d[%s]", errno, strerror(errno));
+ goto error;
+ }
+
+ // out nand info
+ mtd_info.parti_file_desc = fd_dst;
+ mtd_info.mtd_blocksize = meminfo.erasesize;
+ mtd_info.mtd_oobsize = meminfo.oobsize;
+ mtd_info.mtd_pageperblock = meminfo.erasesize / meminfo.writesize;
+ mtd_info.mtd_pagesize = meminfo.writesize;
+ mtd_info.mtd_totalsize = meminfo.size;
+
+ block_num = mtd_info.mtd_totalsize / mtd_info.mtd_blocksize;
+
+ real_write_content = (unsigned char *)upi_malloc(mtd_info.mtd_blocksize);
+ if (NULL == real_write_content) {
+ upi_err("Malloc for block fail!");
+ goto error;
+ }
+
+ // Ìî0xFF²¹Î»
+ memset(real_write_content, 0xFF, mtd_info.mtd_blocksize);
+ memcpy(real_write_content, (char *)info, sizeof(T_FOTA_FLAG_INFO));
+
+ show_fota_flag_info(__LINE__, "Input write content", info);
+ p_write = (T_FOTA_FLAG_INFO *)real_write_content;
+ show_fota_flag_info(__LINE__, "Write to flash content", p_write);
+
+ upi_log("Fotaflag partition fd:%d", mtd_info.parti_file_desc);
+ upi_log("begin to write main fotaflag");
+
+ for(index = 0; index < block_num; index++){
+ if(index == back_index){
+ continue;
+ }
+
+ upi_log("Write main to [%d] block!", index);
+ ret = upi_write_fota_flag_img_content(&mtd_info, index, real_write_content, mtd_info.mtd_blocksize);
+ if(ret == 0){
+ // д³É¹¦£¬Í˳ö£¬²¢¸üеÚÒ»¿éλÖÃ
+ upi_log("Main fotaflag location:[%d]->[%d]", main_index, index);
+ main_index = index;
+ break;
+ }else if(ret == BAD_BLOCK){
+ // Óöµ½»µ¿é£¬ÏòºóÌøÒ»¿é
+ upi_log("Fotaflag index [%d] is bad block", index);
+ continue;
+ }else{
+ upi_err("Write main Error");
+ main_index = -1;
+ break;
+ }
+ }
+
+ upi_log("begin to write backup fotaflag");
+
+ for(index = 0; index < block_num; index++){
+ if(index == main_index){
+ continue;
+ }
+
+ upi_log("Write backup to [%d] block!", index);
+ ret = upi_write_fota_flag_img_content(&mtd_info, index, real_write_content, mtd_info.mtd_blocksize);
+ if(ret == 0){
+ // д³É¹¦£¬Í˳ö£¬²¢¸üеÚÒ»¿éλÖÃ
+ upi_log("Backup fotaflag location:[%d]->[%d]", back_index, index);
+ back_index = index;
+ break;
+ }else if(ret == BAD_BLOCK){
+ // Óöµ½»µ¿é£¬ÏòºóÌøÒ»¿é
+ continue;
+ }else{
+ upi_err("Write backup Error");
+ back_index = -1;
+ break;
+ }
+ }
+
+ if(main_index == -1 && back_index == -1){
+ goto error;
+ }else{
+ ret = 0;
+ goto end;
+ }
+
+
+error:
+ ret = -1;
+
+end:
+ close(fd_dst);
+ upi_free(real_write_content);
+ LOG_FUNC_END
+ return ret;
+
+}
+
+
+static int get_info_from_img_boot_flag(T_FOTA_FLAG_INFO *p_flag_info)
+{
+ T_FOTA_FLAG_INFO main_flag;
+ T_FOTA_FLAG_INFO backup_flag;
+ int main_index = 0;
+ int backup_index = 1;
+
+ if(upi_get_boot_flags_content(&main_flag, &main_index, &backup_flag, &backup_index) < 0){
+ upi_err("Get boot flags content fail!");
+ return -1;
+ }
+
+ show_fota_flag_info(__LINE__, "Read content from flash", &main_flag);
+
+
+ if((FLAGS_MAGIC == main_flag.boot_flag.magic) && (FLAGS_MAGIC == main_flag.boot_env.magic))
+ {
+ copy_fota_flag_info(p_flag_info, &main_flag);
+ return 0;
+ }
+
+ if((FLAGS_MAGIC == backup_flag.boot_flag.magic) && (FLAGS_MAGIC == backup_flag.boot_env.magic))
+ {
+ copy_fota_flag_info(p_flag_info, &backup_flag);
+ return 0;
+ }
+
+ upi_err("Do not find valid flag info!");
+
+ return -1;
+}
+
+
+
+
+/*******************************************************************************
+ * Global function declarations *
+ ******************************************************************************/
+
+int upi_get_system_info(T_FOTA_FLAG_INFO *p_system_info)
+{
+ T_FOTA_FLAG_INFO flag_info;
+ if(get_info_from_img_boot_flag(&flag_info) < 0){
+ upi_err("get flag info fail~");
+
+ return -1;
+ }
+
+// show_fota_flag_info(__LINE__, "Get info", &flag_info);
+
+ copy_fota_flag_info(p_system_info, &flag_info);
+
+// show_fota_flag_info(__LINE__, "Set info to zxic", p_system_info);
+
+ return 0;
+}
+
+
+int upi_get_system_boot_to()
+{
+ T_FOTA_FLAG_INFO flag_info;
+ if(get_info_from_img_boot_flag(&flag_info) < 0){
+ upi_err("get flag info fail~");
+
+ return -1;
+ }
+
+ return flag_info.boot_flag.boot_to;
+}
+
+
+int upi_get_system_fota_status()
+{
+ T_FOTA_FLAG_INFO flag_info;
+ if(get_info_from_img_boot_flag(&flag_info) < 0){
+ upi_err("get flag info fail~");
+
+ return -1;
+ }
+
+ return flag_info.boot_flag.fota_status;
+}
+
+
+
+int upi_get_boot_flag(T_BOOT_FOTA_FLAG *p_boot_flag)
+{
+ T_FOTA_FLAG_INFO flag_info;
+
+ if(!p_boot_flag){
+ upi_err("Input invalid paramter, null point");
+ return -1;
+ }
+
+ if(get_info_from_img_boot_flag(&flag_info) < 0){
+ upi_err("get flag info fail~");
+ return -1;
+ }
+
+ strncpy((char *)p_boot_flag, (char *)(&(flag_info.boot_flag)), sizeof(T_BOOT_FOTA_FLAG));
+
+ p_boot_flag->magic = flag_info.boot_flag.magic;
+ p_boot_flag->boot_to = flag_info.boot_flag.boot_to;
+ p_boot_flag->fota_status = flag_info.boot_flag.fota_status;
+ p_boot_flag->system.status = flag_info.boot_flag.system.status;
+ p_boot_flag->system.try_cnt = flag_info.boot_flag.system.try_cnt;
+ p_boot_flag->system2.status = flag_info.boot_flag.system2.status;
+ p_boot_flag->system2.try_cnt = flag_info.boot_flag.system2.try_cnt;
+
+ return 0;
+}
+
+
+int upi_set_system_boot_to(int boot_to, int boot_to_status)
+{
+ T_FOTA_FLAG_INFO main_flag;
+ T_FOTA_FLAG_INFO backup_flag;
+ T_FOTA_FLAG_INFO *p_flag_info;
+ int main_index = 0;
+ int backup_index = 1;
+ int ret = -1;
+
+ // Ê×ÏÈУÑéºÏ·¨ÐÔ;
+ if(boot_to != DUAL_SYSTEM && boot_to != DUAL_SYSTEM2){
+ upi_err("Invalid boot_to :%d", boot_to);
+ return -1;
+ }
+
+ ret = upi_get_boot_flags_content(&main_flag, &main_index, &backup_flag, &backup_index);
+ if(ret < 0){
+ upi_err("Get boot flags content fail");
+ return -1;
+ }
+
+ if(main_flag.boot_flag.magic == FLAGS_MAGIC){
+ p_flag_info = &main_flag;
+ }else if(backup_flag.boot_flag.magic == FLAGS_MAGIC){
+ p_flag_info = &backup_flag;
+ }else{
+ upi_err("Get boot flag invalid");
+ return -1;
+ }
+
+ // ÐÞ¸ÄǰºóÊý¾Ý²»Ò»Ö£¬ÉèÖÃNVÖØÖñêÖ¾
+ if(main_flag.boot_flag.boot_to != boot_to){
+ upi_log("Set boot to %d, current flag is :%d~", boot_to, main_flag.boot_flag.boot_to);
+ // ²»Ò»ÖÂʱ£¬Í¬²½ÐÞ¸ÄNVͬ²½±êÖ¾£¬ÓÃÀ´Í¬²½NV
+ p_flag_info->boot_flag.fota_status = 1;
+ }
+
+ p_flag_info->boot_flag.boot_to = boot_to;
+
+
+ if(boot_to_status == DUALSYSTEM_STATUS_BOOTABLE
+ || boot_to_status == DUALSYSTEM_STATUS_SUCCESSFUL
+ || boot_to_status == DUALSYSTEM_STATUS_UNBOOTABLE){
+ if(boot_to == DUAL_SYSTEM){
+ p_flag_info->boot_flag.system.status = boot_to_status;
+ }else if(boot_to == DUAL_SYSTEM2){
+ p_flag_info->boot_flag.system2.status = boot_to_status;
+ }
+ }
+
+ if(upi_set_boot_flags_content(p_flag_info, &main_index, &backup_index) < 0){
+ upi_err("Set boot flag fail!");
+ return -1;
+ }
+
+ upi_log("Set system boot to success");
+ return 0;
+}
+
+
+int upi_set_system_fota_stauts(int status)
+{
+ T_FOTA_FLAG_INFO main_flag;
+ T_FOTA_FLAG_INFO backup_flag;
+ T_FOTA_FLAG_INFO *p_flag_info;
+ int main_index = 0;
+ int backup_index = 1;
+ int ret = -1;
+
+ // Ê×ÏÈУÑéºÏ·¨ÐÔ;
+ if(status != 0 && status != 1){
+ upi_err("Invalid status :%d", status);
+ return -1;
+ }
+
+ ret = upi_get_boot_flags_content(&main_flag, &main_index, &backup_flag, &backup_index);
+ if(ret < 0){
+ upi_err("Get boot flags content fail");
+ return -1;
+ }
+
+ if(main_flag.boot_flag.magic == FLAGS_MAGIC){
+ p_flag_info = &main_flag;
+ }else if(backup_flag.boot_flag.magic == FLAGS_MAGIC){
+ p_flag_info = &backup_flag;
+ }else{
+ upi_err("Get boot flag invalid");
+ return -1;
+ }
+
+ // ÐÞ¸ÄǰºóÊý¾ÝÒ»Ö£¬²»ÐèÒªÖØÐÂдÈë
+ if(main_flag.boot_flag.fota_status == status && backup_flag.boot_flag.fota_status == status){
+ upi_log("Set fota_status %d, current fota_status is :%d~", status, main_flag.boot_flag.fota_status);
+ return 0;
+ }
+
+ p_flag_info->boot_flag.fota_status = status;
+
+ if(upi_set_boot_flags_content(p_flag_info, &main_index, &backup_index) < 0){
+ upi_err("Set boot flag fail!");
+ return -1;
+ }
+
+ upi_log("Set system boot to success");
+ return 0;
+}
+
+
+int upi_set_system_status(int system, int status)
+{
+ T_FOTA_FLAG_INFO main_flag;
+ T_FOTA_FLAG_INFO backup_flag;
+ T_FOTA_FLAG_INFO *p_flag_info;
+ int main_index = 0;
+ int backup_index = 1;
+ int ret = -1;
+
+ // Ê×ÏÈУÑéºÏ·¨ÐÔ;
+ if(system != DUAL_SYSTEM && system != DUAL_SYSTEM2){
+ upi_err("Invalid system :%d", system);
+ return -1;
+ }
+
+ if(status != DUALSYSTEM_STATUS_BOOTABLE
+ && status != DUALSYSTEM_STATUS_SUCCESSFUL
+ && status != DUALSYSTEM_STATUS_UNBOOTABLE){
+ upi_err("Invalide status:%d, valid is:bootable(%d), successful(%d), unbootable(%d)", status, DUALSYSTEM_STATUS_BOOTABLE, DUALSYSTEM_STATUS_SUCCESSFUL, DUALSYSTEM_STATUS_UNBOOTABLE);
+ return -1;
+ }
+
+ ret = upi_get_boot_flags_content(&main_flag, &main_index, &backup_flag, &backup_index);
+ if(ret < 0){
+ upi_err("get boot flags content fail~");
+ return -1;
+ }
+
+ if(main_flag.boot_flag.magic == FLAGS_MAGIC){
+ p_flag_info = &main_flag;
+ }else if(backup_flag.boot_flag.magic == FLAGS_MAGIC){
+ p_flag_info = &backup_flag;
+ }else{
+ upi_err("Get boot flag invalid");
+ return -1;
+ }
+
+ if(system == DUAL_SYSTEM){
+ p_flag_info->boot_flag.system.status = status;
+ upi_log("Set %d system status to %d", system, status);
+ }else if(system == DUAL_SYSTEM2){
+ p_flag_info->boot_flag.system2.status = status;
+ upi_log("Set %d system status to %d", system, status);
+ }else{
+ upi_log("Unreachable branch, unknown system!");
+ }
+
+ upi_log("Current status:system1:%d system2:%d", p_flag_info->boot_flag.system.status, p_flag_info->boot_flag.system2.status);
+
+ if(upi_set_boot_flags_content(p_flag_info, &main_index, &backup_index) < 0){
+ upi_err("Set boot flag fail!");
+ return -1;
+ }
+
+ upi_log("Set system status success");
+ return 0;
+}
+
+
+
+int check_fota_flag_partition()
+{
+ return 0;
+}
+
+
+void upi_reboot()
+{
+ system("reboot");
+ return;
+}
+
+
+
+int init_fotaflag_partition()
+{
+ T_FOTA_FLAG_INFO flag;
+ int main_index = 0;
+ int back_index = 1;
+ int ret = -1;
+ int fd_dst = -1;
+ char mtd_path[MAX_PATH_LEN] = {0};
+ struct mtd_info_user meminfo;
+ partition_mtd_info_t mtd_info;
+
+ unsigned char *real_write_content = NULL;
+ T_FOTA_FLAG_INFO *p_write = NULL;
+
+ int index = 0;
+ int block_num = 0;
+ int already_write = 0;
+
+ LOG_FUNC_BEGIN
+
+ memset((unsigned char *)(&flag), 0, sizeof(T_FOTA_FLAG_INFO));
+ flag.boot_flag.magic = FLAGS_MAGIC;
+ flag.boot_flag.boot_to = DUAL_SYSTEM;
+ flag.boot_flag.fota_status = 0;
+ flag.boot_flag.system.status = DUALSYSTEM_STATUS_BOOTABLE;
+ flag.boot_flag.system.try_cnt = 0;
+ flag.boot_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
+ flag.boot_flag.system2.try_cnt = 0;
+
+ flag.boot_env.magic = FLAGS_MAGIC;
+ flag.boot_env.dualsys_type = DUALSYSTEM_AB;
+
+
+ ret = mtd_find(PARTITION_NAME_FOTA_FLAG, DEVICE_MTD, mtd_path, MAX_PATH_LEN);
+ if (ret < 0) {
+ upi_err("Partition[%s] not found!", PARTITION_NAME_FOTA_FLAG);
+ return -1;
+ }
+
+ if ((fd_dst = open(mtd_path, O_RDWR | O_SYNC)) < 0) {
+ upi_err("Open flash error: %d[%s]", errno, strerror(errno));
+ return -1;
+ }
+
+ // Fill in MTD device capability structure
+ if (ioctl(fd_dst, MEMGETINFO, &meminfo) != 0) {
+ upi_err("Get flash info error: %d[%s]", errno, strerror(errno));
+ goto error;
+ }
+
+ // out nand info
+ mtd_info.parti_file_desc = fd_dst;
+ mtd_info.mtd_blocksize = meminfo.erasesize;
+ mtd_info.mtd_oobsize = meminfo.oobsize;
+ mtd_info.mtd_pageperblock = meminfo.erasesize / meminfo.writesize;
+ mtd_info.mtd_pagesize = meminfo.writesize;
+ mtd_info.mtd_totalsize = meminfo.size;
+
+ block_num = mtd_info.mtd_totalsize / mtd_info.mtd_blocksize;
+
+ real_write_content = (unsigned char *)upi_malloc(mtd_info.mtd_blocksize);
+ if (NULL == real_write_content) {
+ upi_err("Malloc for block fail!");
+ goto error;
+ }
+
+ // Ìî0xFF²¹Î»
+ memset(real_write_content, 0xFF, mtd_info.mtd_blocksize);
+ memcpy(real_write_content, (char *)(&flag), sizeof(T_FOTA_FLAG_INFO));
+
+ for(index = 0; index < block_num; index++){
+ if(already_write >= INIT_VALID_BLOCKS_COUNT){
+ break;
+ }
+
+ ret = upi_write_fota_flag_img_content(&mtd_info, index, real_write_content, mtd_info.mtd_blocksize);
+ if(ret == 0){
+ already_write++;
+ upi_log("Write init valid block num:%d!", already_write);
+ continue;
+ }else if(ret == BAD_BLOCK){
+ // Óöµ½»µ¿é£¬ÏòºóÌøÒ»¿é
+ continue;
+ }
+ }
+
+ LOG_FUNC_END
+
+ if(already_write >= 2){
+ upi_log("Init system status success, alread write block :%d", already_write);
+ ret = 0;
+ }else{
+ upi_log("Init system status fail, alread write block :%d", already_write);
+ ret = -1;
+ }
+
+ goto end;
+
+error:
+ ret = -1;
+
+end:
+ close(fd_dst);
+ upi_free(real_write_content);
+ return ret;
+}
+
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/src/zxic_fota_ab_upgrade.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/src/zxic_fota_ab_upgrade.c
new file mode 100755
index 0000000..075e60e
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libupi_ab/src/zxic_fota_ab_upgrade.c
@@ -0,0 +1,1442 @@
+/**
+* @file zxic_fota_ab_upgrade.c
+* @brief °æ±¾Éý¼¶Íⲿ½Ó¿ÚʵÏÖÎļþ
+*
+* Copyright (C) 2023 Sanechips Technology Co., Ltd.
+* @author
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+*/
+
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdbool.h>
+#include <errno.h>
+
+#include "softap_log.h"
+#include "at_reg.h"
+#include "softap_api.h"
+#include "absvr_msg.h"
+
+#include "zxic_fota_ab_upgrade.h"
+
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+//#define ABCLIENT_PRINT "SC_AB_CLIENT"
+#define upi_log(...) slog(ABCLIENT_PRINT, SLOG_NORMAL, __VA_ARGS__)
+#define upi_err(...) slog(ABCLIENT_PRINT, SLOG_ERR, __VA_ARGS__)
+
+#define MSG_DATABUF_MAX_LEN (128)
+
+#define FILE_PATH_PROC_CMDLINE "/proc/cmdline"
+
+#define SYSTEM_INDEX_UNKNOWN (-1)
+
+#define PROC_CMDLINE_SYSTEM_A_FLAG "system=system_a"
+#define PROC_CMDLINE_SYSTEM_B_FLAG "system=system_b"
+
+#define SYSTEM_INDEX_1 (1)
+#define SYSTEM_INDEX_2 (2)
+
+#define Z_DUAL_SYSTEM (0x875A)
+#define Z_DUAL_SYSTEM2 (0x986B)
+
+#define Z_FOTA_FAIL (-1)
+
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+typedef struct
+{
+ int result; // 0: ³É¹¦ ·Ç0: ʧ°Ü
+ unsigned char dataBuf[MSG_DATABUF_MAX_LEN];
+} absvr_common_result_t;
+
+
+typedef struct
+{
+ int boot_to_system;
+ int reboot_flag;
+
+ int system;
+ int status;
+
+ int status_for_nv;
+
+ int sync_status;
+} absvr_common_req_msg_t;
+
+
+/*******************************************************************************
+ * Local variable definitions *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Global variable definitions *
+ ******************************************************************************/
+z_upgrade_flush_status_t *g_flush_status = NULL;
+z_upgrade_status_info_t *g_upgrade_info = NULL;
+z_upgrade_system_info_t *g_system_info = NULL;
+int *g_sync_status = NULL;
+
+
+/*******************************************************************************
+ * Local function declarations *
+ ******************************************************************************/
+static int absvr_verify_rsp_proc(MSG_BUF *msg);
+static int absvr_updating_rsp_proc(MSG_BUF *msg);
+static int absvr_update_rsp_proc(MSG_BUF *msg);
+static int absvr_get_upgrade_status_proc(MSG_BUF *msg);
+static int absvr_get_current_system_proc(MSG_BUF *msg);
+static int absvr_get_boot_to_system_proc(MSG_BUF *msg);
+static int absvr_get_system_status_proc(MSG_BUF *msg);
+static int absvr_set_boot_to_system_proc(MSG_BUF *msg);
+static int absvr_set_system_status_rsp_proc(MSG_BUF *msg);
+static int absvr_get_fota_status_for_nv_rsp_proc(MSG_BUF *msg);
+static int absvr_set_fota_status_for_nv_rsp_proc(MSG_BUF *msg);
+static int absvr_sync_rsp_proc(MSG_BUF *msg);
+static int absvr_get_upgrade_type_rsp_proc(MSG_BUF *msg);
+static int absvr_get_sync_status_rsp_proc(MSG_BUF *msg);
+static int absvr_set_sync_status_rsp_proc(MSG_BUF *msg);
+
+static int upi_get_current_system();
+
+// Éý¼¶ºófota±êÖ¾£¬Ö÷ÒªÓÃÀ´±êÖ¾ÊÇ·ñÐèҪͬ²½NV
+int upi_get_system_fota_status();
+int upi_set_system_fota_stauts(int status);
+
+/*******************************************************************************
+ * Local function implementations *
+ ******************************************************************************/
+static int absvr_verify_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ if (0 != common_result.result)
+ {
+ upi_err("<<<<<<<<<<<< Verify Fail >>>>>>>>>>>>> \n");
+ return -1;
+ }
+ else
+ {
+ upi_log("<<<<<<<<<< Verify Success >>>>>>>>>>> \n");
+ return 0;
+ }
+}
+
+
+static int absvr_updating_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ if (g_flush_status && (g_flush_status->status))
+ {
+ memcpy(g_flush_status->status, (z_upgrade_status_info_t *)(common_result.dataBuf), sizeof(z_upgrade_status_info_t));
+ }
+
+ if (g_flush_status && (g_flush_status->status) && (g_flush_status->status_cb))
+ {
+ g_flush_status->status_cb(g_flush_status->status);
+ }
+
+ return 0;
+}
+
+
+static int absvr_update_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ if (0 != common_result.result)
+ {
+ upi_err("<<<<<<<<<<<< Upgrade Fail >>>>>>>>>>>>> \n");
+ return -1;
+ }
+ else
+ {
+ upi_log("<<<<<<<<<<<< Upgrade Success >>>>>>>>>>>>> \n");
+ return 0;
+ }
+}
+
+
+static int absvr_get_upgrade_status_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_get_upgrade_status_proc result=%d\n", common_result.result);
+
+ if (0 != common_result.result)
+ {
+ return common_result.result;
+ }
+ else
+ {
+ memcpy(g_upgrade_info, (z_upgrade_status_info_t *)(common_result.dataBuf), sizeof(z_upgrade_status_info_t));
+ return common_result.result;
+ }
+}
+
+
+static int absvr_get_current_system_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_get_current_system_proc result=%d\n", common_result.result);
+
+ return common_result.result;
+}
+
+
+static int absvr_get_boot_to_system_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_get_boot_to_system_proc result=%d\n", common_result.result);
+
+ return common_result.result;
+}
+
+
+static int absvr_get_system_status_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_get_upgrade_status_proc result=%d\n", common_result.result);
+
+ if (0 != common_result.result)
+ {
+ return common_result.result;
+ }
+ else
+ {
+ memcpy(g_system_info, (z_upgrade_system_info_t *)(common_result.dataBuf), sizeof(z_upgrade_system_info_t));
+ return common_result.result;
+ }
+}
+
+
+static int absvr_set_boot_to_system_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_set_boot_to_system_proc result=%d\n", common_result.result);
+
+ return common_result.result;
+}
+
+
+static int absvr_set_system_status_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_set_system_status_rsp_proc result=%d\n", common_result.result);
+
+ return common_result.result;
+}
+
+
+static int absvr_get_fota_status_for_nv_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_get_fota_status_for_nv_rsp_proc result=%d\n", common_result.result);
+
+ return common_result.result;
+}
+
+
+static int absvr_set_fota_status_for_nv_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_set_fota_status_for_nv_rsp_proc result=%d\n", common_result.result);
+
+ return common_result.result;
+}
+
+
+static int absvr_sync_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ if (0 != common_result.result)
+ {
+ upi_err("<<<<<<<<<<<< Sync Fail >>>>>>>>>>>>> \n");
+ return -1;
+ }
+ else
+ {
+ upi_log("<<<<<<<<<< Sync Success >>>>>>>>>>> \n");
+ return 0;
+ }
+}
+
+
+static int absvr_get_upgrade_type_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_get_upgrade_type_rsp_proc result=%d\n", common_result.result);
+
+ return common_result.result;
+}
+
+
+static int absvr_get_sync_status_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_get_sync_status_rsp_proc result=%d\n", common_result.result);
+
+ *g_sync_status = common_result.result;
+
+ return common_result.result;
+}
+
+
+static int absvr_set_sync_status_rsp_proc(MSG_BUF *msg)
+{
+ absvr_common_result_t common_result = {0};
+
+ memcpy(&common_result, (absvr_common_result_t *)(msg->aucDataBuf), sizeof(absvr_common_result_t));
+
+ upi_log("absvr_set_sync_status_rsp_proc result=%d\n", common_result.result);
+
+ return common_result.result;
+}
+
+
+static int upi_get_current_system()
+{
+ char buf[1024] = {0};
+
+ char *para = NULL;
+ int matches = 0;
+
+ FILE *fd_cmd = NULL;
+ char *line_str = NULL;
+
+ int current_system = -1;
+
+ fd_cmd = fopen(FILE_PATH_PROC_CMDLINE, "r");
+ if(!fd_cmd){
+ upi_err("Open file %s error, error:%s", FILE_PATH_PROC_CMDLINE, strerror(errno));
+ return SYSTEM_INDEX_UNKNOWN;
+ }
+
+ while(!feof(fd_cmd)){
+ memset(buf, 0, sizeof(buf));
+ line_str = fgets(buf, sizeof(buf), fd_cmd);
+
+ if (NULL == line_str) {
+ upi_err("get info from /proc/cmdline error:%s", strerror(errno));
+ goto end;
+ }
+
+ upi_log("buff:%s", buf);
+
+ para = strtok(buf, " ");
+ while(para){
+ upi_log("para:%s", para);
+ if(strncmp(para, PROC_CMDLINE_SYSTEM_A_FLAG,strlen(PROC_CMDLINE_SYSTEM_A_FLAG)) == 0){
+ current_system = SYSTEM_INDEX_1;
+ goto end;
+ }else if(strncmp(para, PROC_CMDLINE_SYSTEM_B_FLAG, strlen(PROC_CMDLINE_SYSTEM_B_FLAG)) == 0){
+ current_system = SYSTEM_INDEX_2;
+ goto end;
+ }else{
+ //:
+ }
+ para = strtok(NULL, " ");
+ }
+ }
+
+end:
+ if(fd_cmd){
+ fclose(fd_cmd);
+ }
+
+ return current_system;
+
+}
+
+
+/*******************************************************************************
+ * Global function implementations *
+ ******************************************************************************/
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_verify
+ *
+ * ¹¦ÄÜÃèÊö:Éý¼¶°üºÏ·¨ÐÔУÑé
+ *
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ *
+ *
+ *
+ * Êä³ö²ÎÊý:ÎÞ
+ *
+ *
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS УÑé³É¹¦
+ * Z_FOTA_FAIL УÑéʧ°Ü
+ * ×¢Òâ:
+ ********************************************************************************/
+int zxic_dual_verify()
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_VRITFY_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_verify send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_VRITFY_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_VRITFY_RSP:
+ ret = absvr_verify_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: upi_verify recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_VRITFY_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_upgrade
+ *
+ * ¹¦ÄÜÃèÊö:¿ªÊ¼Éý¼¶
+ *
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ *
+ *
+ *
+ * Êä³ö²ÎÊý:ÎÞ
+ *
+ *
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS Éý¼¶³É¹¦
+ * Z_FOTA_FAIL Éý¼¶Ê§°Ü
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_upgrade(z_upgrade_flush_status_t* flush_status)
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+
+ g_flush_status = flush_status;
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_UPDATE_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_upgrade send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_UPDATE_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_UPDATING_RSP:
+ ret = absvr_updating_rsp_proc(&stMsg);
+ break;
+ case ABSVR_UPDATE_RSP:
+ ret = absvr_update_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: upi_update recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_UPDATE_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_upgrade_status
+ *
+ * ¹¦ÄÜÃèÊö:Éý¼¶×´Ì¬»ñÈ¡
+ *
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ *
+ *
+ *
+ * Êä³ö²ÎÊý:
+ * upgrade_info_t *upgrade_info Éý¼¶×´Ì¬
+ *
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS Éý¼¶³É¹¦
+ * Z_FOTA_FAIL Éý¼¶Ê§°Ü
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_upgrade_status(z_upgrade_status_info_t *upgrade_info)
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+ g_upgrade_info = upgrade_info;
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_GET_UPGRADE_STATUS_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_get_upgrade_status send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_GET_UPGRADE_STATUS_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_GET_UPGRADE_STATUS_RSP:
+ ret = absvr_get_upgrade_status_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_get_upgrade_status recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_GET_UPGRADE_STATUS_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_current_system
+ * ¹¦ÄÜÃèÊö:»ñÈ¡µ±Ç°ÔËÐÐϵͳ
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * µ±Ç°ÔËÐÐϵͳ
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_current_system()
+{
+ int current = upi_get_current_system();
+ if(current == 1){
+ return Z_DUAL_SYSTEM;
+ }else if(current == 2){
+ return Z_DUAL_SYSTEM2;
+ }
+
+ return Z_FOTA_FAIL;
+}
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_boot_to_system
+ * ¹¦ÄÜÃèÊö:»ñÈ¡ÖØÆôºóÄ¿±êÆô¶¯ÏµÍ³
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * µ±Ç°ÔËÐÐϵͳ
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_boot_to_system()
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_GET_BOOT_TO_SYSTEM_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_get_boot_to_system send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_GET_BOOT_TO_SYSTEM_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_GET_BOOT_TO_SYSTEM_RSP:
+ ret = absvr_get_boot_to_system_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_get_boot_to_system recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_GET_BOOT_TO_SYSTEM_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_system_status
+ * ¹¦ÄÜÃèÊö:²éѯABϵͳ״̬
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:
+ * ϵͳ״̬ÐÅÏ¢
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS »ñÈ¡ÐÅÏ¢³É¹¦
+ * Z_FOTA_FAIL »ñÈ¡ÐÅϢʧ°Ü
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_get_system_status(z_upgrade_system_info_t *system_info)
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+ g_system_info = system_info;
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_GET_SYSTEM_STATUS_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_get_system_status send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_GET_SYSTEM_STATUS_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_GET_SYSTEM_STATUS_RSP:
+ ret = absvr_get_system_status_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_get_system_status recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_GET_SYSTEM_STATUS_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_set_boot_to_system
+ * ¹¦ÄÜÃèÊö:ÉèÖÃÄ¿±êÔËÐÐϵͳ
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ * system:Ä¿±êϵͳ
+ * reboot_flag:ÉèÖÃÍê±ÏºóÊÇ·ñÁ¢¼´ÖØÆô 0:²»ÖØÆô,1:ÖØÆô
+ * Êä³ö²ÎÊý:
+ * ϵͳ״̬ÐÅÏ¢
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS »ñÈ¡ÐÅÏ¢³É¹¦
+ * Z_FOTA_FAIL »ñÈ¡ÐÅϢʧ°Ü
+ * ×¢Òâ:
+ * ·µ»ØÖµ£ºÖ»ÔÚ²»ÐèÒªÖØÆôʱÓÐЧ
+********************************************************************************/
+int zxic_dual_set_boot_to_system(int system, int reboot_flag)
+{
+ int ret = -1;
+
+ absvr_common_req_msg_t common_req_msg = {0};
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ common_req_msg.boot_to_system = system;
+ common_req_msg.reboot_flag = reboot_flag;
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_SET_BOOT_TO_SYSTEM_REQ, sizeof(common_req_msg), (unsigned char *)(&common_req_msg)))
+ {
+ upi_err("Err: zxic_dual_set_boot_to_system send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_SET_BOOT_TO_SYSTEM_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_SET_BOOT_TO_SYSTEM_RSP:
+ ret = absvr_set_boot_to_system_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_set_boot_to_system recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_SET_BOOT_TO_SYSTEM_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_set_system_status
+ *
+ * ¹¦ÄÜÃèÊö:ÉèÖÃϵͳ״̬
+ *
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ *
+ *
+ *
+ * Êä³ö²ÎÊý:ÎÞ
+ *
+ *
+ * ·µ»ØÖµ£º
+
+ * ×¢Òâ:
+********************************************************************************/
+int zxic_dual_set_system_status(int system, int status)
+{
+ int ret = -1;
+
+ absvr_common_req_msg_t common_req_msg = {0};
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ common_req_msg.system = system;
+ common_req_msg.status = status;
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_SET_SYSTEM_STATUS_REQ, sizeof(common_req_msg), (unsigned char *)(&common_req_msg)))
+ {
+ upi_err("Err: zxic_dual_get_current_system send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_SET_SYSTEM_STATUS_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_SET_SYSTEM_STATUS_RSP:
+ ret = absvr_set_system_status_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_get_current_system recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_SET_SYSTEM_STATUS_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_fota_status_for_nv
+ * ¹¦ÄÜÃèÊö:»ñȡϵͳNVÊÇ·ñͬ²½±êÖ¾
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * ״̬±êÖ¾ 0£º²»ÐèҪͬ²½£¬1£ºÐèҪͬ²½ -1:»ñȡʧ°Ü
+ * ×¢Òâ:
+********************************************************************************/
+#if 1
+int zxic_dual_get_fota_status_for_nv()
+{
+ return upi_get_system_fota_status();
+}
+#else
+int zxic_dual_get_fota_status_for_nv()
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_GET_FOTA_STATUS_FOR_NV_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_get_fota_status_for_nv send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_GET_FOTA_STATUS_FOR_NV_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_GET_FOTA_STATUS_FOR_NV_RSP:
+ ret = absvr_get_fota_status_for_nv_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_get_fota_status_for_nv recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_GET_FOTA_STATUS_FOR_NV_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+#endif
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_set_fota_status_for_nv
+ * ¹¦ÄÜÃèÊö:ÉèÖÃϵͳNVÊÇ·ñͬ²½±êÖ¾
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ * status:״̬±êÖ¾£¬0£º²»ÐèҪͬ²½£¬1£ºÐèҪͬ²½
+ * Êä³ö²ÎÊý:ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS ÉèÖóɹ¦
+ * Z_FOTA_FAIL ÉèÖÃʧ°Ü
+ * ×¢Òâ:
+********************************************************************************/
+#if 1
+int zxic_dual_set_fota_status_for_nv(int status)
+{
+ return upi_set_system_fota_stauts(status);
+}
+#else
+int zxic_dual_set_fota_status_for_nv(int status)
+{
+ int ret = -1;
+
+ absvr_common_req_msg_t common_req_msg = {0};
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ common_req_msg.status_for_nv = status;
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_SET_FOTA_STATUS_FOR_NV_REQ, sizeof(common_req_msg), (unsigned char *)(&common_req_msg)))
+ {
+ upi_err("Err: zxic_dual_set_fota_status_for_nv send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_SET_FOTA_STATUS_FOR_NV_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_SET_FOTA_STATUS_FOR_NV_RSP:
+ ret = absvr_set_fota_status_for_nv_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_set_fota_status_for_nv recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_SET_FOTA_STATUS_FOR_NV_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+#endif
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_sync_system
+ * ¹¦ÄÜÃèÊö: AB-AAϵͳͬ²½
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý: ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS ͬ²½³É¹¦
+ * Z_FOTA_FAIL ͬ²½Ê§°Ü
+ * ×¢Òâ:
+ ********************************************************************************/
+int zxic_dual_sync_system(void)
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_SYNC_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_sync_system send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_SYNC_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_SYNC_RSP:
+ ret = absvr_sync_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: upi_sync_system recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_SYNC_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_upgrade_type
+ * ¹¦ÄÜÃèÊö: »ñÈ¡Éý¼¶ÀàÐÍ
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý: ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_UPGRADE_TYPE_ALL È«°æ±¾ÀàÐÍ
+ * Z_UPGRADE_TYPE_PLATFORM ƽ̨ÀàÐÍ
+ * Z_UPGRADE_TYPE_OEM OEMÀàÐÍ
+ * Z_UPGRADE_TYPE_INVALID ÎÞЧÀàÐÍ
+ * ×¢Òâ:
+ ********************************************************************************/
+int zxic_dual_get_upgrade_type(void)
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_GET_UPGRADE_TYPE_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_get_upgrade_type send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_GET_UPGRADE_TYPE_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_GET_UPGRADE_TYPE_RSP:
+ ret = absvr_get_upgrade_type_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: upi_get_upgrade_type recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_GET_UPGRADE_TYPE_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_get_sync_status
+ * ¹¦ÄÜÃèÊö: »ñȡͬ²½×´Ì¬
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£ºÎÞ
+ * Êä³ö²ÎÊý:
+ * sync_status ͬ²½×´Ì¬
+ * ·µ»ØÖµ£ºÎÞ
+ * ×¢Òâ:
+ ********************************************************************************/
+void zxic_dual_get_sync_status(int *sync_status)
+{
+ int ret = -1;
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ unsigned char send_msg[1] = {0};
+ g_sync_status = sync_status;
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_GET_SYNC_STATUS_REQ, sizeof(send_msg), (unsigned char *)(&send_msg)))
+ {
+ upi_err("Err: zxic_dual_get_sync_status send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_GET_SYNC_STATUS_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_GET_SYNC_STATUS_RSP:
+ ret = absvr_get_sync_status_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_get_sync_status recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_GET_SYNC_STATUS_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return;
+}
+
+
+/********************************************************************************
+ * º¯ÊýÃû: zxic_dual_set_sync_status
+ * ¹¦ÄÜÃèÊö: ÉèÖÃͬ²½×´Ì¬
+ * ²ÎÊý˵Ã÷£º
+ * ÊäÈë²ÎÊý£º
+ * sync_status ͬ²½×´Ì¬
+ * Êä³ö²ÎÊý: ÎÞ
+ * ·µ»ØÖµ£º
+ * Z_FOTA_SUCCESS ÉèÖóɹ¦
+ * Z_FOTA_FAIL ÉèÖÃʧ°Ü
+ * ×¢Òâ:
+ ********************************************************************************/
+int zxic_dual_set_sync_status(int sync_status)
+{
+ int ret = -1;
+
+ absvr_common_req_msg_t common_req_msg = {0};
+
+ int iRet = 0;
+ int iMsgHandle = -1;
+ MSG_BUF stMsg = {0};
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+ common_req_msg.sync_status = sync_status;
+
+ iMsgHandle = msgget(MODULE_ID_ABCLIENT, IPC_CREAT | 0600);
+ if (-1 == iMsgHandle)
+ {
+ upi_err("Err: can not create msg queue for sc_abclient \n");
+ goto end;
+ }
+
+ if (0 != send_soc_msg(NEAR_PS, MODULE_ID_ABSVR, (unsigned short)ABSVR_SET_SYNC_STATUS_REQ, sizeof(common_req_msg), (unsigned char *)(&common_req_msg)))
+ {
+ upi_err("Err: zxic_dual_set_sync_status send_soc_msg dst_id[%d] usMsgCmd[%d] fail \n", MODULE_ID_ABSVR, ABSVR_SET_SYNC_STATUS_REQ);
+ goto end;
+ }
+ else
+ {
+ for (;;)
+ {
+ iRet = msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0);
+ if (-1 == iRet)
+ {
+ upi_err("Err: recv msg fail errno = %d \n", errno);
+ continue;
+ }
+
+ switch(stMsg.usMsgCmd)
+ {
+ case ABSVR_SET_SYNC_STATUS_RSP:
+ ret = absvr_set_sync_status_rsp_proc(&stMsg);
+ break;
+ default:
+ upi_err("Err: zxic_dual_set_sync_status recv usMsgCmd [%hu] unknown\n", stMsg.usMsgCmd);
+ break;
+ }
+
+ if (ABSVR_SET_SYNC_STATUS_RSP == stMsg.usMsgCmd)
+ {
+ break;
+ }
+ }
+ }
+
+end:
+ if (iMsgHandle > 0 && msgctl(iMsgHandle, IPC_RMID, 0) < 0)
+ {
+ upi_err("Err: msgctl fail \n");
+ }
+ iMsgHandle = -1;
+
+ return ret;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/.travis.yml b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/.travis.yml
new file mode 100755
index 0000000..4fe51b8
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/.travis.yml
@@ -0,0 +1,21 @@
+# One may have a look at http://docs.travis-ci.com/user/installing-dependencies/
+
+language: c
+
+notifications:
+ - email: true
+
+# Install the cross-compiler
+before_install:
+ - sudo apt-get update -qq
+ - sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
+ - arm-linux-gnueabihf-gcc --version
+ # Travis does 'export CC=gcc'. Unset CC so that ./flags.mk properly
+ # defines the cross-compiler to the default value: $(CROSS_COMPILE)gcc.
+ - unset CC
+
+# Several compilation options are checked
+script:
+ - make clean all
+ - CFG_TEE_CLIENT_LOG_LEVEL=0 make clean all
+ - CFG_TEE_CLIENT_LOG_LEVEL=5 make clean all
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/Android.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/Android.mk
new file mode 100755
index 0000000..cc58a4a
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/Android.mk
@@ -0,0 +1,55 @@
+################################################################################
+# Android optee-client and optee-supplicant makefile #
+################################################################################
+LOCAL_PATH := $(call my-dir)
+
+# set CFG_TEE_CLIENT_LOAD_PATH before include config.mk
+CFG_TEE_CLIENT_LOAD_PATH ?= /vendor/lib
+
+# set CFG_TEE_FS_PARENT_PATH before include config.mk
+TEEC_TEST_LOAD_PATH ?= /data/vendor/tee
+CFG_TEE_FS_PARENT_PATH ?= /data/vendor/tee
+
+################################################################################
+# Include optee-client common config and flags #
+################################################################################
+include $(LOCAL_PATH)/config.mk
+include $(LOCAL_PATH)/android_flags.mk
+
+optee_CFLAGS = $(CFLAGS)
+
+################################################################################
+# Build libteec.so - TEE (Trusted Execution Environment) shared library #
+################################################################################
+include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(optee_CFLAGS)
+
+ifneq ($(CFG_TEE_CLIENT_LOG_FILE),)
+LOCAL_CFLAGS += -DTEEC_LOG_FILE=\"$(CFG_TEE_CLIENT_LOG_FILE)\"
+endif
+
+LOCAL_CFLAGS += -DDEBUGLEVEL_$(CFG_TEE_CLIENT_LOG_LEVEL)
+LOCAL_CFLAGS += -DBINARY_PREFIX=\"TEEC\"
+
+LOCAL_SRC_FILES := libteec/src/tee_client_api.c\
+ libteec/src/teec_trace.c
+ifeq ($(CFG_TEE_BENCHMARK),y)
+LOCAL_CFLAGS += -DCFG_TEE_BENCHMARK
+LOCAL_SRC_FILES += teec_benchmark.c
+endif
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/public \
+ $(LOCAL_PATH)/libteec/include \
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libteec
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_VENDOR_MODULE := true
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/public
+
+include $(BUILD_SHARED_LIBRARY)
+
+# TEE Supplicant
+include $(LOCAL_PATH)/tee-supplicant/tee_supplicant_android.mk
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/CMakeLists.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/CMakeLists.txt
new file mode 100755
index 0000000..bc6b57b
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required (VERSION 3.4)
+project (optee_client C)
+
+# https://cmake.org/Wiki/CMake_Useful_Variables
+set (CMAKE_TOOLCHAIN_FILE CMakeToolchain.txt)
+
+set (CFG_WERROR 1 CACHE BOOL "Build with -Werror")
+
+include(GNUInstallDirs)
+
+################################################################################
+# Compiler flags:
+# We want to use the same flags in the entire optee_client git
+################################################################################
+add_compile_options (
+ -Wall -Wbad-function-cast -Wcast-align
+ -Werror-implicit-function-declaration -Wextra
+ -Wfloat-equal -Wformat-nonliteral -Wformat-security
+ -Wformat=2 -Winit-self -Wmissing-declarations
+ -Wmissing-format-attribute -Wmissing-include-dirs
+ -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs
+ -Wpointer-arith -Wshadow -Wstrict-prototypes
+ -Wswitch-default -Wunsafe-loop-optimizations
+ -Wwrite-strings -fPIC
+)
+if(CFG_WERROR)
+ add_compile_options(-Werror)
+endif(CFG_WERROR)
+
+find_program(CCACHE_FOUND ccache)
+if(CCACHE_FOUND)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+endif(CCACHE_FOUND)
+
+add_subdirectory (libteec)
+add_subdirectory (tee-supplicant)
+add_subdirectory (public)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/CMakeToolchain.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/CMakeToolchain.txt
new file mode 100755
index 0000000..71eb52f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/CMakeToolchain.txt
@@ -0,0 +1,3 @@
+set (CMAKE_SYSTEM_NAME Linux)
+
+set (CMAKE_SYSTEM_PROCESSOR arm)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/LICENSE b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/LICENSE
new file mode 100755
index 0000000..76c5d00
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/LICENSE
@@ -0,0 +1,27 @@
+Unless it has its own copyright/license embedded in its body, each source file
+is subject to the following license terms:
+
+Copyright (c) 2015, Linaro Limited
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/Makefile
new file mode 100755
index 0000000..0cb7c5f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/Makefile
@@ -0,0 +1,129 @@
+# Public variables are stored in config.mk
+include ./config.mk
+
+#########################################################################
+# Set Internal Variables #
+# May be modified to match your setup #
+#########################################################################
+ifneq ($(V),1)
+VPREFIX := @
+endif
+export VPREFIX
+
+EXPORT_DIR ?= $(O)/export
+DESTDIR ?= $(EXPORT_DIR)
+SBINDIR ?= /usr/sbin
+LIBDIR ?= /usr/lib
+INCLUDEDIR ?= /usr/include
+
+.PHONY: all build build-libteec install copy_export \
+ clean cscope clean-cscope \
+ checkpatch-pre-req checkpatch-modified-patch checkpatch-modified-file \
+ checkpatch-last-commit-patch checkpatch-last-commit-file \
+ checkpatch-base-commit-patch checkpatch-base-commit-file \
+ checkpatch-all-files distclean
+
+all: build install
+
+build-libteec:
+ @echo "Building libteec.so"
+ @$(MAKE) --directory=libteec --no-print-directory --no-builtin-variables \
+ CFG_TEE_BENCHMARK=$(CFG_TEE_BENCHMARK) CFG_TEE_CLIENT_LOG_LEVEL=$(CFG_TEE_CLIENT_LOG_LEVEL)
+
+
+build-tee-supplicant: build-libteec
+ @echo "Building tee-supplicant"
+ $(MAKE) --directory=tee-supplicant --no-print-directory --no-builtin-variables CFG_TEE_SUPP_LOG_LEVEL=$(CFG_TEE_SUPP_LOG_LEVEL)
+
+build: build-libteec build-tee-supplicant
+
+install: copy_export
+
+clean: clean-libteec clean-tee-supplicant clean-cscope
+
+clean-libteec:
+ @$(MAKE) --directory=libteec --no-print-directory clean
+
+clean-tee-supplicant:
+ @$(MAKE) --directory=tee-supplicant --no-print-directory clean
+
+cscope:
+ @echo " CSCOPE"
+ ${VPREFIX}find ${CURDIR} -name "*.[chsS]" > cscope.files
+ ${VPREFIX}cscope -b -q -k
+
+clean-cscope:
+ ${VPREFIX}rm -f cscope.*
+
+# Various checkpatch targets. The ones ending with "patch" only considers the
+# patch, whilst the ones ending with "file" checks the complete file.
+# +-------------------------------+------------+----------------------------+
+# | Target commit | File/Patch | Comment |
+# +-------------------------------+------------+----------------------------+
+# | checkpatch-modified-patch | Patch | Check local modifications |
+# +-------------------------------+------------+----------------------------+
+# | checkpatch-modified-file | File | Check Local modifications |
+# +-------------------------------+------------+----------------------------+
+# | checkpatch-last-commit-patch | Patch | Check against HEAD^ |
+# +-------------------------------+------------+----------------------------+
+# | checkpatch-last-commit-file | File | Check against HEAD^ |
+# +-------------------------------+------------+----------------------------+
+# | checkpatch-base-commit-patch | Patch | Against specic commit |
+# +-------------------------------+------------+----------------------------+
+# | checkpatch-base-commit-file | File | Against specic commit |
+# +-------------------------------+------------+----------------------------+
+# | checkpatch-all-files | File | Check all tracked files |
+# +-------------------------------+------------+----------------------------+
+CHECKPATCH_IGNORE ?= --ignore NEW_TYPEDEFS --no-signoff
+CHECKPATCH_STRICT ?= --strict
+CHECKPATCH_ARGS ?= $(CHECKPATCH_IGNORE) $(CHECKPATCH_STRICT) --no-tree --terse
+CHECKPATCH_PATCH_ARGS := $(CHECKPATCH_ARGS) --patch
+CHECKPATCH_FILE_ARGS := $(CHECKPATCH_ARGS) --file --no-patch
+
+checkpatch-pre-req:
+ @echo " CHECKPATCH"
+ifndef CHECKPATCH
+ $(error "Environment variable CHECKPATCH must point to Linux kernels checkpatch script")
+else
+ifeq (,$(wildcard ${CHECKPATCH}))
+ $(error "CHECKPATCH points to the incorrect file")
+endif
+endif
+
+checkpatch-modified-patch: checkpatch-pre-req
+ ${VPREFIX}git diff | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true
+
+checkpatch-modified-file: checkpatch-pre-req
+ ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only)
+
+
+checkpatch-last-commit-patch: checkpatch-pre-req
+ ${VPREFIX}git diff HEAD^ | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true
+
+checkpatch-last-commit-file: checkpatch-pre-req
+ ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only HEAD^)
+
+
+checkpatch-base-commit-patch: checkpatch-pre-req
+ifndef BASE_COMMIT
+ $(error "Environment variable BASE_COMMIT must contain a valid commit")
+endif
+ ${VPREFIX}git diff $(BASE_COMMIT) | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true
+
+checkpatch-base-commit-file: checkpatch-pre-req
+ifndef BASE_COMMIT
+ $(error "Environment variable BASE_COMMIT must contain a valid commit")
+endif
+ ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only ${BASE_COMMIT})
+
+checkpatch-all-files: checkpatch-pre-req
+ ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git ls-files)
+
+distclean: clean
+
+copy_export: build
+ mkdir -p $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCLUDEDIR)
+ cp -a ${O}/libteec/libteec.so* $(DESTDIR)$(LIBDIR)
+ cp -a ${O}/libteec/libteec.a $(DESTDIR)$(LIBDIR)
+ cp ${O}/tee-supplicant/tee-supplicant $(DESTDIR)$(SBINDIR)
+ cp public/*.h $(DESTDIR)$(INCLUDEDIR)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/README.md b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/README.md
new file mode 100755
index 0000000..22e11ba
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/README.md
@@ -0,0 +1,10 @@
+# OP-TEE Client API
+This git contains source code for the non-secure side implementation of the
+OP-TEE project making up the client library and tee-supplicant.
+
+All official OP-TEE documentation has moved to http://optee.readthedocs.io. The
+information that used to be here in this git can be found under [optee_client].
+
+// OP-TEE core maintainers
+
+[optee_client]: https://optee.readthedocs.io/building/gits/optee_client.html
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/android_flags.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/android_flags.mk
new file mode 100755
index 0000000..34e3085
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/android_flags.mk
@@ -0,0 +1,23 @@
+#########################################################################
+# COMMON COMPILATION FLAGS #
+#########################################################################
+CFLAGS := -Wall -Wbad-function-cast -Wcast-align \
+ -Werror-implicit-function-declaration -Wextra \
+ -Wfloat-equal -Wformat-nonliteral -Wformat-security \
+ -Wformat=2 -Winit-self -Wmissing-declarations \
+ -Wmissing-format-attribute \
+ -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs \
+ -Wpointer-arith -Wshadow -Wstrict-prototypes \
+ -Wswitch-default \
+ -Wwrite-strings
+ifeq ($(CFG_WERROR),y)
+CFLAGS += -Werror
+endif
+CFLAGS += -c -fPIC
+
+DEBUG ?= 0
+ifeq ($(DEBUG), 1)
+CFLAGS += -DDEBUG -O0 -g
+endif
+
+RM := rm -rf
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/config.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/config.mk
new file mode 100755
index 0000000..78a528f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/config.mk
@@ -0,0 +1,74 @@
+#########################################################################
+# Public variables #
+# Developers may override these values when calling the makefile, #
+# as for example #
+# CFG_TEE_CLIENT_LOG_LEVEL=1 make #
+# Note: #
+# Please do not use export to declare the variables, so that to avoid #
+# compiling problem for android platform #
+#########################################################################
+
+# CFG_TEE_CLIENT_LOG_LEVEL
+# Client (User Non Secure) log level
+# Supported values: 0 (no traces) to 4 (all traces)
+CFG_TEE_CLIENT_LOG_LEVEL?=1
+
+# CFG_TEE_SUPP_LOG_LEVEL
+# Supplicant log level
+# Supported values: 0 (no traces) to 4 (all traces)
+CFG_TEE_SUPP_LOG_LEVEL?=1
+
+# CFG_TEE_FS_PARENT_PATH
+# Path to folder that will contain TEE filesystem.
+# This folder can be created with the required permission in an init
+# script during boot, else it will be created by the tee-supplicant on
+# first REE FS access.
+CFG_TEE_FS_PARENT_PATH ?= /etc_rw/tee
+
+# CFG_TEE_CLIENT_LOG_FILE
+# The location of the client log file when logging to file is enabled.
+CFG_TEE_CLIENT_LOG_FILE ?= $(CFG_TEE_FS_PARENT_PATH)/teec.log
+
+# CFG_TEE_CLIENT_LOAD_PATH
+# The location of the client library file.
+CFG_TEE_CLIENT_LOAD_PATH ?= /lib
+
+# CFG_TA_TEST_PATH
+# Enable the tee test path. When enabled, the supplicant will try
+# loading from a debug path before the regular path. This allows test
+# such as 1008.5 that test loading of corrupt TAs.
+CFG_TA_TEST_PATH ?= n
+
+# CFG_GP_SOCKETS
+# Enable Global Platform Sockets support
+CFG_GP_SOCKETS ?= y
+
+# CFG_TA_GPROF_SUPPORT
+# Enable dumping gprof data, not used unless secure world decides
+# to dump something
+CFG_TA_GPROF_SUPPORT ?= y
+
+# CFG_FTRACE_SUPPORT
+# Enable dumping ftrace data, not used unless secure world decides
+# to dump something
+CFG_FTRACE_SUPPORT ?= y
+
+# Default output directory.
+# May be absolute, or relative to the optee_client source directory.
+O ?= out
+
+# To be used instead of $(O) in sub-directories
+OO := $(if $(filter /%,$(O)),$(O),$(CURDIR)/../$(O))
+
+#########################################################################
+# Private Values #
+#########################################################################
+
+# Check that settings are coherent.
+
+ifdef ARM_TOOLCHAIN_DIR
+ifeq ($(wildcard ${ARM_TOOLCHAIN_DIR}/bin/${ARM_GCC_PREFIX}-gcc),)
+ $(error "ARM_TOOLCHAIN_DIR wrongly setup. Is ${ARM_TOOLCHAIN_DIR}")
+endif
+endif
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/flags.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/flags.mk
new file mode 100755
index 0000000..c2f0e1c
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/flags.mk
@@ -0,0 +1,32 @@
+#########################################################################
+# COMMON COMPILATION FLAGS #
+#########################################################################
+
+CROSS_COMPILE ?= arm-linux-gnueabihf-
+CC ?= $(CROSS_COMPILE)gcc
+AR ?= $(CROSS_COMPILE)ar
+
+CFLAGS := -Wall -Wbad-function-cast -Wcast-align \
+ -Werror-implicit-function-declaration -Wextra \
+ -Wfloat-equal -Wformat-nonliteral -Wformat-security \
+ -Wformat=2 -Winit-self -Wmissing-declarations \
+ -Wmissing-format-attribute -Wmissing-include-dirs \
+ -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs \
+ -Wpointer-arith -Wshadow -Wstrict-prototypes \
+ -Wswitch-default -Wunsafe-loop-optimizations \
+ -Wwrite-strings -D_FILE_OFFSET_BITS=64
+ifeq ($(CFG_WERROR),y)
+CFLAGS += -Werror
+endif
+CFLAGS += -c -fPIC
+
+DEBUG ?= 0
+ifeq ($(DEBUG), 1)
+CFLAGS += -DDEBUG -O0 -g
+endif
+
+RM := rm -f
+
+define rmdir
+if [ -d "$(1)" ] ; then rmdir --ignore-fail-on-non-empty $(1) ; fi
+endef
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/CMakeLists.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/CMakeLists.txt
new file mode 100755
index 0000000..9422eeb
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/CMakeLists.txt
@@ -0,0 +1,75 @@
+project(libteec C)
+
+set(PROJECT_VERSION "1.0.0")
+
+################################################################################
+# Packages
+################################################################################
+find_package(Threads REQUIRED)
+if(NOT THREADS_FOUND)
+ message(FATAL_ERROR "Threads not found")
+endif()
+
+################################################################################
+# Configuration flags always included
+################################################################################
+option (CFG_TEE_BENCHMARK "Build with benchmark support" OFF)
+
+set (CFG_TEE_CLIENT_LOG_LEVEL "1" CACHE STRING "libteec log level")
+set (CFG_TEE_CLIENT_LOG_FILE "/data/tee/teec.log" CACHE STRING "Location of libteec log")
+
+################################################################################
+# Source files
+################################################################################
+set (SRC
+ src/tee_client_api.c
+ src/teec_trace.c
+)
+
+if (CFG_TEE_BENCHMARK)
+ set (SRC ${SRC} src/teec_benchmark.c)
+endif()
+
+################################################################################
+# Built library
+################################################################################
+add_library (teec ${SRC})
+
+set_target_properties (teec PROPERTIES
+ VERSION ${PROJECT_VERSION}
+ SOVERSION 1
+)
+
+################################################################################
+# Flags always set
+################################################################################
+target_compile_definitions (teec
+ PRIVATE -D_GNU_SOURCE
+ PRIVATE -DCFG_TEE_CLIENT_LOG_LEVEL=${CFG_TEE_CLIENT_LOG_LEVEL}
+ PRIVATE -DTEEC_LOG_FILE="${CFG_TEE_CLIENT_LOG_FILE}"
+ PRIVATE -DBINARY_PREFIX="LT"
+)
+
+################################################################################
+# Optional flags
+################################################################################
+if (CFG_TEE_BENCHMARK)
+ target_compile_definitions (teec PRIVATE -DCFG_TEE_BENCHMARK)
+endif()
+
+################################################################################
+# Public and private header and library dependencies
+################################################################################
+target_include_directories(teec PUBLIC include)
+
+target_link_libraries (teec
+ PUBLIC ${CMAKE_THREAD_LIBS_INIT} # this is pthreads
+ PRIVATE optee-client-headers)
+
+################################################################################
+# Install targets
+################################################################################
+# FIXME: This should in someway harmonize with CFG_TEE_CLIENT_LOAD_PATH
+# FIXME: Should we change this to /usr/local/lib?
+install (TARGETS teec LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/Makefile
new file mode 100755
index 0000000..57f2ff8
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/Makefile
@@ -0,0 +1,72 @@
+include ../flags.mk
+include ../config.mk
+
+OUT_DIR := $(OO)/libteec
+
+.PHONY: all libteec clean
+
+all: libteec
+################################################################################
+# Teec configuration
+################################################################################
+MAJOR_VERSION := 1
+MINOR_VERSION := 0
+PATCH_VERSION := 0
+LIB_NAME := libteec.so
+LIB_MAJOR := $(LIB_NAME).$(MAJOR_VERSION)
+LIB_MAJ_MIN := $(LIB_NAME).$(MAJOR_VERSION).$(MINOR_VERSION)
+LIB_MAJ_MIN_P := $(LIB_NAME).$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)
+
+TEEC_SRCS := tee_client_api.c \
+ teec_trace.c \
+ teec_api.c
+
+ifeq ($(CFG_TEE_BENCHMARK),y)
+TEEC_SRCS += teec_benchmark.c
+endif
+
+TEEC_SRC_DIR := src
+TEEC_OBJ_DIR := $(OUT_DIR)
+TEEC_OBJS := $(patsubst %.c,$(TEEC_OBJ_DIR)/%.o, $(TEEC_SRCS))
+TEEC_INCLUDES := \
+ ${CURDIR}/include \
+ ${CURDIR}/../public \
+
+TEEC_CFLAGS := $(addprefix -I, $(TEEC_INCLUDES)) $(CFLAGS) -D_GNU_SOURCE \
+ -DDEBUGLEVEL_$(CFG_TEE_CLIENT_LOG_LEVEL) \
+ -DBINARY_PREFIX=\"TEEC\"
+
+ifeq ($(CFG_TEE_BENCHMARK),y)
+TEEC_CFLAGS += -DCFG_TEE_BENCHMARK
+endif
+
+TEEC_LFLAGS := $(LDFLAGS) -lpthread
+TEEC_LIBRARY := $(OUT_DIR)/$(LIB_MAJ_MIN_P)
+
+libteec: $(TEEC_LIBRARY) $(OUT_DIR)/libteec.a
+ $(VPREFIX)ln -sf $(LIB_MAJ_MIN_P) $(OUT_DIR)/$(LIB_MAJOR)
+ $(VPREFIX)ln -sf $(LIB_MAJ_MIN_P) $(OUT_DIR)/$(LIB_MAJ_MIN)
+ $(VPREFIX)ln -sf $(LIB_MAJOR) $(OUT_DIR)/$(LIB_NAME)
+
+$(TEEC_LIBRARY): $(TEEC_OBJS)
+ @echo " LINK $@"
+ $(VPREFIX)$(CC) -shared -Wl,-soname,$(LIB_MAJOR) $(TEEC_LFLAGS) -o $@ $+
+ @echo ""
+
+$(OUT_DIR)/libteec.a: $(TEEC_OBJS)
+ @echo " AR $@"
+ $(VPREFIX)$(AR) rcs $@ $+
+
+$(TEEC_OBJ_DIR)/%.o: ${TEEC_SRC_DIR}/%.c
+ $(VPREFIX)mkdir -p $(TEEC_OBJ_DIR)
+ @echo " CC $<"
+ $(VPREFIX)$(CC) $(TEEC_CFLAGS) -c $< -o $@
+
+################################################################################
+# Cleaning up configuration
+################################################################################
+clean:
+ $(RM) $(TEEC_OBJS) $(TEEC_LIBRARY) $(OUT_DIR)/$(LIB_MAJOR) \
+ $(OUT_DIR)/$(LIB_MAJ_MIN) $(OUT_DIR)/$(LIB_NAME)
+ $(RM) $(OUT_DIR)/libteec.a
+ $(call rmdir,$(OUT_DIR))
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/include/linux/tee.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/include/linux/tee.h
new file mode 100755
index 0000000..f19b2b4
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/include/linux/tee.h
@@ -0,0 +1,470 @@
+/*
+ * Copyright (c) 2015-2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __TEE_H
+#define __TEE_H
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+/*
+ * This file describes the API provided by a TEE driver to user space.
+ *
+ * Each TEE driver defines a TEE specific protocol which is used for the
+ * data passed back and forth using TEE_IOC_CMD.
+ */
+
+/* Helpers to make the ioctl defines */
+#define TEE_IOC_MAGIC 0xa4
+#define TEE_IOC_BASE 0
+
+/* Flags relating to shared memory */
+#define TEE_IOCTL_SHM_MAPPED 0x1 /* memory mapped in normal world */
+#define TEE_IOCTL_SHM_DMA_BUF 0x2 /* dma-buf handle on shared memory */
+
+#define TEE_MAX_ARG_SIZE 1024
+
+#define TEE_GEN_CAP_GP (1 << 0)/* GlobalPlatform compliant TEE */
+#define TEE_GEN_CAP_REG_MEM (1 << 2)/* Supports registering shared memory */
+
+/*
+ * TEE Implementation ID
+ */
+#define TEE_IMPL_ID_OPTEE 1
+
+/*
+ * OP-TEE specific capabilities
+ */
+#define TEE_OPTEE_CAP_TZ (1 << 0)
+
+/**
+ * struct tee_ioctl_version_data - TEE version
+ * @impl_id: [out] TEE implementation id
+ * @impl_caps: [out] Implementation specific capabilities
+ * @gen_caps: [out] Generic capabilities, defined by TEE_GEN_CAPS_* above
+ *
+ * Identifies the TEE implementation, @impl_id is one of TEE_IMPL_ID_* above.
+ * @impl_caps is implementation specific, for example TEE_OPTEE_CAP_*
+ * is valid when @impl_id == TEE_IMPL_ID_OPTEE.
+ */
+struct tee_ioctl_version_data {
+ __u32 impl_id;
+ __u32 impl_caps;
+ __u32 gen_caps;
+};
+
+/**
+ * TEE_IOC_VERSION - query version of TEE
+ *
+ * Takes a tee_ioctl_version_data struct and returns with the TEE version
+ * data filled in.
+ */
+#define TEE_IOC_VERSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 0, \
+ struct tee_ioctl_version_data)
+
+/**
+ * struct tee_ioctl_shm_alloc_data - Shared memory allocate argument
+ * @size: [in/out] Size of shared memory to allocate
+ * @flags: [in/out] Flags to/from allocation.
+ * @id: [out] Identifier of the shared memory
+ *
+ * The flags field should currently be zero as input. Updated by the call
+ * with actual flags as defined by TEE_IOCTL_SHM_* above.
+ * This structure is used as argument for TEE_IOC_SHM_ALLOC below.
+ */
+struct tee_ioctl_shm_alloc_data {
+ __u64 size;
+ __u32 flags;
+ __s32 id;
+};
+
+/**
+ * TEE_IOC_SHM_ALLOC - allocate shared memory
+ *
+ * Allocates shared memory between the user space process and secure OS.
+ *
+ * Returns a file descriptor on success or < 0 on failure
+ *
+ * The returned file descriptor is used to map the shared memory into user
+ * space. The shared memory is freed when the descriptor is closed and the
+ * memory is unmapped.
+ */
+#define TEE_IOC_SHM_ALLOC _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 1, \
+ struct tee_ioctl_shm_alloc_data)
+
+/**
+ * struct tee_ioctl_shm_register_fd_data - Shared memory registering argument
+ * @fd: [in] file descriptor identifying the shared memory
+ * @size: [out] Size of shared memory to allocate
+ * @flags: [in] Flags to/from allocation.
+ * @id: [out] Identifier of the shared memory
+ *
+ * The flags field should currently be zero as input. Updated by the call
+ * with actual flags as defined by TEE_IOCTL_SHM_* above.
+ * This structure is used as argument for TEE_IOC_SHM_ALLOC below.
+ */
+struct tee_ioctl_shm_register_fd_data {
+ __s64 fd;
+ __u64 size;
+ __u32 flags;
+ __s32 id;
+} __aligned(8);
+
+/**
+ * TEE_IOC_SHM_REGISTER_FD - register a shared memory from a file descriptor
+ *
+ * Returns a file descriptor on success or < 0 on failure
+ *
+ * The returned file descriptor refers to the shared memory object in kernel
+ * land. The shared memory is freed when the descriptor is closed.
+ */
+#define TEE_IOC_SHM_REGISTER_FD _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 8, \
+ struct tee_ioctl_shm_register_fd_data)
+
+/**
+ * struct tee_ioctl_shm_register_data - Shared memory register argument
+ * @addr: [in] Start address of shared memory to register
+ * @length: [in/out] Length of shared memory to register
+ * @flags: [in/out] Flags to/from registration.
+ * @id: [out] Identifier of the shared memory
+ *
+ * The flags field should currently be zero as input. Updated by the call
+ * with actual flags as defined by TEE_IOCTL_SHM_* above.
+ * This structure is used as argument for TEE_IOC_SHM_REGISTER below.
+ */
+struct tee_ioctl_shm_register_data {
+ __u64 addr;
+ __u64 length;
+ __u32 flags;
+ __s32 id;
+};
+
+/**
+ * TEE_IOC_SHM_REGISTER - Register shared memory
+ *
+ * Registers shared memory between the user space process and secure OS.
+ *
+ * Returns a file descriptor on success or < 0 on failure
+ *
+ * The shared memory is unregisterred when the descriptor is closed.
+ */
+#define TEE_IOC_SHM_REGISTER _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 9, \
+ struct tee_ioctl_shm_register_data)
+
+/**
+ * struct tee_ioctl_buf_data - Variable sized buffer
+ * @buf_ptr: [in] A __user pointer to a buffer
+ * @buf_len: [in] Length of the buffer above
+ *
+ * Used as argument for TEE_IOC_OPEN_SESSION, TEE_IOC_INVOKE,
+ * TEE_IOC_SUPPL_RECV, and TEE_IOC_SUPPL_SEND below.
+ */
+struct tee_ioctl_buf_data {
+ __u64 buf_ptr;
+ __u64 buf_len;
+};
+
+/*
+ * Attributes for struct tee_ioctl_param, selects field in the union
+ */
+#define TEE_IOCTL_PARAM_ATTR_TYPE_NONE 0 /* parameter not used */
+
+/*
+ * These defines value parameters (struct tee_ioctl_param_value)
+ */
+#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT 1
+#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT 2
+#define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT 3 /* input and output */
+
+/*
+ * These defines shared memory reference parameters (struct
+ * tee_ioctl_param_memref)
+ */
+#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT 5
+#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT 6
+#define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT 7 /* input and output */
+
+/*
+ * Mask for the type part of the attribute, leaves room for more types
+ */
+#define TEE_IOCTL_PARAM_ATTR_TYPE_MASK 0xff
+
+/* Meta parameter carrying extra information about the message. */
+#define TEE_IOCTL_PARAM_ATTR_META 0x100
+
+/* Mask of all known attr bits */
+#define TEE_IOCTL_PARAM_ATTR_MASK \
+ (TEE_IOCTL_PARAM_ATTR_TYPE_MASK | TEE_IOCTL_PARAM_ATTR_META)
+
+/*
+ * Matches TEEC_LOGIN_* in GP TEE Client API
+ * Are only defined for GP compliant TEEs
+ */
+#define TEE_IOCTL_LOGIN_PUBLIC 0
+#define TEE_IOCTL_LOGIN_USER 1
+#define TEE_IOCTL_LOGIN_GROUP 2
+#define TEE_IOCTL_LOGIN_APPLICATION 4
+#define TEE_IOCTL_LOGIN_USER_APPLICATION 5
+#define TEE_IOCTL_LOGIN_GROUP_APPLICATION 6
+
+/**
+ * struct tee_ioctl_param_memref - memory reference
+ * @shm_offs: Offset into the shared memory object
+ * @size: Size of the buffer
+ * @shm_id: Shared memory identifier
+ *
+ * Shared memory is allocated with TEE_IOC_SHM_ALLOC which returns an
+ * identifier representing the shared memory object. A memref can reference
+ * a part of a shared memory by specifying an offset (@shm_offs) and @size
+ * of the object. To supply the entire shared memory object set @shm_offs
+ * to 0 and @size to the previously returned size of the object.
+ */
+struct tee_ioctl_param_memref {
+ __u64 shm_offs;
+ __u64 size;
+ __s64 shm_id;
+};
+
+/**
+ * struct tee_ioctl_param_value - values
+ * @a: first value
+ * @b: second value
+ * @c: third value
+ *
+ * Value parameters are passed unchecked to the destination
+ */
+struct tee_ioctl_param_value {
+ __u64 a;
+ __u64 b;
+ __u64 c;
+};
+
+/**
+ * struct tee_ioctl_param - parameter
+ * @attr: attributes
+ * @memref: a memory reference
+ * @value: a value
+ *
+ * @attr & TEE_PARAM_ATTR_TYPE_MASK indicates if memref or value is used in
+ * the union. TEE_PARAM_ATTR_TYPE_VALUE_* indicates value and
+ * TEE_PARAM_ATTR_TYPE_MEMREF_* indicates memref. TEE_PARAM_ATTR_TYPE_NONE
+ * indicates that none of the members are used.
+ */
+struct tee_ioctl_param {
+ __u64 attr;
+ union {
+ struct tee_ioctl_param_memref memref;
+ struct tee_ioctl_param_value value;
+ } u;
+};
+
+#define TEE_IOCTL_UUID_LEN 16
+
+/**
+ * struct tee_ioctl_open_session_arg - Open session argument
+ * @uuid: [in] UUID of the Trusted Application
+ * @clnt_uuid: [in] UUID of client
+ * @clnt_login: [in] Login class of client, TEE_IOCTL_LOGIN_* above
+ * @cancel_id: [in] Cancellation id, a unique value to identify this request
+ * @session: [out] Session id
+ * @ret: [out] return value
+ * @ret_origin [out] origin of the return value
+ * @num_params [in] number of parameters following this struct
+ */
+struct tee_ioctl_open_session_arg {
+ __u8 uuid[TEE_IOCTL_UUID_LEN];
+ __u8 clnt_uuid[TEE_IOCTL_UUID_LEN];
+ __u32 clnt_login;
+ __u32 cancel_id;
+ __u32 session;
+ __u32 ret;
+ __u32 ret_origin;
+ __u32 num_params;
+ /*
+ * this struct is 8 byte aligned since the 'struct tee_ioctl_param'
+ * which follows requires 8 byte alignment.
+ *
+ * Commented out element used to visualize the layout dynamic part
+ * of the struct. This field is not available at all if
+ * num_params == 0.
+ *
+ * struct tee_ioctl_param params[num_params];
+ */
+} __aligned(8);
+
+/**
+ * TEE_IOC_OPEN_SESSION - opens a session to a Trusted Application
+ *
+ * Takes a struct tee_ioctl_buf_data which contains a struct
+ * tee_ioctl_open_session_arg followed by any array of struct
+ * tee_ioctl_param
+ */
+#define TEE_IOC_OPEN_SESSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 2, \
+ struct tee_ioctl_buf_data)
+
+/**
+ * struct tee_ioctl_invoke_func_arg - Invokes a function in a Trusted
+ * Application
+ * @func: [in] Trusted Application function, specific to the TA
+ * @session: [in] Session id
+ * @cancel_id: [in] Cancellation id, a unique value to identify this request
+ * @ret: [out] return value
+ * @ret_origin [out] origin of the return value
+ * @num_params [in] number of parameters following this struct
+ */
+struct tee_ioctl_invoke_arg {
+ __u32 func;
+ __u32 session;
+ __u32 cancel_id;
+ __u32 ret;
+ __u32 ret_origin;
+ __u32 num_params;
+ /*
+ * this struct is 8 byte aligned since the 'struct tee_ioctl_param'
+ * which follows requires 8 byte alignment.
+ *
+ * Commented out element used to visualize the layout dynamic part
+ * of the struct. This field is not available at all if
+ * num_params == 0.
+ *
+ * struct tee_ioctl_param params[num_params];
+ */
+} __aligned(8);
+
+/**
+ * TEE_IOC_INVOKE - Invokes a function in a Trusted Application
+ *
+ * Takes a struct tee_ioctl_buf_data which contains a struct
+ * tee_invoke_func_arg followed by any array of struct tee_param
+ */
+#define TEE_IOC_INVOKE _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 3, \
+ struct tee_ioctl_buf_data)
+
+/**
+ * struct tee_ioctl_cancel_arg - Cancels an open session or invoke ioctl
+ * @cancel_id: [in] Cancellation id, a unique value to identify this request
+ * @session: [in] Session id, if the session is opened, else set to 0
+ */
+struct tee_ioctl_cancel_arg {
+ __u32 cancel_id;
+ __u32 session;
+};
+
+/**
+ * TEE_IOC_CANCEL - Cancels an open session or invoke
+ */
+#define TEE_IOC_CANCEL _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 4, \
+ struct tee_ioctl_cancel_arg)
+
+/**
+ * struct tee_ioctl_close_session_arg - Closes an open session
+ * @session: [in] Session id
+ */
+struct tee_ioctl_close_session_arg {
+ __u32 session;
+};
+
+/**
+ * TEE_IOC_CLOSE_SESSION - Closes a session
+ */
+#define TEE_IOC_CLOSE_SESSION _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 5, \
+ struct tee_ioctl_close_session_arg)
+
+/**
+ * struct tee_iocl_supp_recv_arg - Receive a request for a supplicant function
+ * @func: [in] supplicant function
+ * @num_params [in/out] number of parameters following this struct
+ *
+ * @num_params is the number of params that tee-supplicant has room to
+ * receive when input, @num_params is the number of actual params
+ * tee-supplicant receives when output.
+ */
+struct tee_iocl_supp_recv_arg {
+ __u32 func;
+ __u32 num_params;
+ /*
+ * this struct is 8 byte aligned since the 'struct tee_ioctl_param'
+ * which follows requires 8 byte alignment.
+ *
+ * Commented out element used to visualize the layout dynamic part
+ * of the struct. This field is not available at all if
+ * num_params == 0.
+ *
+ * struct tee_ioctl_param params[num_params];
+ */
+} __aligned(8);
+
+/**
+ * TEE_IOC_SUPPL_RECV - Receive a request for a supplicant function
+ *
+ * Takes a struct tee_ioctl_buf_data which contains a struct
+ * tee_iocl_supp_recv_arg followed by any array of struct tee_param
+ */
+#define TEE_IOC_SUPPL_RECV _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 6, \
+ struct tee_ioctl_buf_data)
+
+/**
+ * struct tee_iocl_supp_send_arg - Send a response to a received request
+ * @ret: [out] return value
+ * @num_params [in] number of parameters following this struct
+ */
+struct tee_iocl_supp_send_arg {
+ __u32 ret;
+ __u32 num_params;
+ /*
+ * this struct is 8 byte aligned since the 'struct tee_ioctl_param'
+ * which follows requires 8 byte alignment.
+ *
+ * Commented out element used to visualize the layout dynamic part
+ * of the struct. This field is not available at all if
+ * num_params == 0.
+ *
+ * struct tee_ioctl_param params[num_params];
+ */
+} __aligned(8);
+/**
+ * TEE_IOC_SUPPL_SEND - Receive a request for a supplicant function
+ *
+ * Takes a struct tee_ioctl_buf_data which contains a struct
+ * tee_iocl_supp_send_arg followed by any array of struct tee_param
+ */
+#define TEE_IOC_SUPPL_SEND _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 7, \
+ struct tee_ioctl_buf_data)
+
+/*
+ * Five syscalls are used when communicating with the TEE driver.
+ * open(): opens the device associated with the driver
+ * ioctl(): as described above operating on the file descriptor from open()
+ * close(): two cases
+ * - closes the device file descriptor
+ * - closes a file descriptor connected to allocated shared memory
+ * mmap(): maps shared memory into user space using information from struct
+ * tee_ioctl_shm_alloc_data
+ * munmap(): unmaps previously shared memory
+ */
+
+#endif /*__TEE_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/include/teec_benchmark.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/include/teec_benchmark.h
new file mode 100755
index 0000000..17d99ac
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/include/teec_benchmark.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __TEEC_BENCHMARK_H
+#define __TEEC_BENCHMARK_H
+
+#ifdef CFG_TEE_BENCHMARK
+void bm_timestamp(void);
+#else
+static inline void bm_timestamp(void) {}
+#endif
+
+#endif /* __TEEC_BENCHMARK_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/tee_client_api.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/tee_client_api.c
new file mode 100755
index 0000000..7099f6d
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/tee_client_api.c
@@ -0,0 +1,804 @@
+/*
+ * Copyright (c) 2015-2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <tee_client_api_extensions.h>
+#include <tee_client_api.h>
+#include <teec_trace.h>
+#include <unistd.h>
+
+#ifndef __aligned
+#define __aligned(x) __attribute__((__aligned__(x)))
+#endif
+#include <linux/tee.h>
+
+#include "teec_benchmark.h"
+
+/* How many device sequence numbers will be tried before giving up */
+#define TEEC_MAX_DEV_SEQ 10
+
+static pthread_mutex_t teec_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static void teec_mutex_lock(pthread_mutex_t *mu)
+{
+ pthread_mutex_lock(mu);
+}
+
+static void teec_mutex_unlock(pthread_mutex_t *mu)
+{
+ pthread_mutex_unlock(mu);
+}
+
+static int teec_open_dev(const char *devname, const char *capabilities,
+ uint32_t *gen_caps)
+{
+ int fd = 0;
+ struct tee_ioctl_version_data vers;
+
+ memset(&vers, 0, sizeof(vers));
+
+ fd = open(devname, O_RDWR);
+ if (fd < 0)
+ return -1;
+
+ if (ioctl(fd, TEE_IOC_VERSION, &vers)) {
+ EMSG("TEE_IOC_VERSION failed");
+ goto err;
+ }
+
+ /* We can only handle GP TEEs */
+ if (!(vers.gen_caps & TEE_GEN_CAP_GP))
+ goto err;
+
+ if (capabilities) {
+ if (strcmp(capabilities, "optee-tz") == 0) {
+ if (vers.impl_id != TEE_IMPL_ID_OPTEE)
+ goto err;
+ if (!(vers.impl_caps & TEE_OPTEE_CAP_TZ))
+ goto err;
+ } else {
+ /* Unrecognized capability requested */
+ goto err;
+ }
+ }
+
+ *gen_caps = vers.gen_caps;
+ return fd;
+err:
+ close(fd);
+ return -1;
+}
+
+static int teec_shm_alloc(int fd, size_t size, int *id)
+{
+ int shm_fd = 0;
+ struct tee_ioctl_shm_alloc_data data;
+
+ memset(&data, 0, sizeof(data));
+
+ data.size = size;
+ shm_fd = ioctl(fd, TEE_IOC_SHM_ALLOC, &data);
+ if (shm_fd < 0)
+ return -1;
+ *id = data.id;
+ return shm_fd;
+}
+
+static int teec_shm_register(int fd, void *buf, size_t size, int *id)
+{
+ int shm_fd = 0;
+ struct tee_ioctl_shm_register_data data;
+
+ memset(&data, 0, sizeof(data));
+
+ data.addr = (uintptr_t)buf;
+ data.length = size;
+ shm_fd = ioctl(fd, TEE_IOC_SHM_REGISTER, &data);
+ if (shm_fd < 0)
+ return -1;
+ *id = data.id;
+ return shm_fd;
+}
+
+TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *ctx)
+{
+ char devname[PATH_MAX] = { 0 };
+ int fd = 0;
+ size_t n = 0;
+
+ if (!ctx)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ for (n = 0; n < TEEC_MAX_DEV_SEQ; n++) {
+ uint32_t gen_caps = 0;
+
+ snprintf(devname, sizeof(devname), "/dev/tee%zu", n);
+ fd = teec_open_dev(devname, name, &gen_caps);
+ if (fd >= 0) {
+ ctx->fd = fd;
+ ctx->reg_mem = gen_caps & TEE_GEN_CAP_REG_MEM;
+ return TEEC_SUCCESS;
+ }
+ }
+
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+}
+
+void TEEC_FinalizeContext(TEEC_Context *ctx)
+{
+ if (ctx)
+ close(ctx->fd);
+}
+
+
+static TEEC_Result teec_pre_process_tmpref(TEEC_Context *ctx,
+ uint32_t param_type, TEEC_TempMemoryReference *tmpref,
+ struct tee_ioctl_param *param,
+ TEEC_SharedMemory *shm)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+
+ switch (param_type) {
+ case TEEC_MEMREF_TEMP_INPUT:
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT;
+ shm->flags = TEEC_MEM_INPUT;
+ break;
+ case TEEC_MEMREF_TEMP_OUTPUT:
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT;
+ shm->flags = TEEC_MEM_OUTPUT;
+ break;
+ case TEEC_MEMREF_TEMP_INOUT:
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT;
+ shm->flags = TEEC_MEM_INPUT | TEEC_MEM_OUTPUT;
+ break;
+ default:
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ shm->size = tmpref->size;
+
+ res = TEEC_AllocateSharedMemory(ctx, shm);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ memcpy(shm->buffer, tmpref->buffer, tmpref->size);
+ param->u.memref.size = tmpref->size;
+ param->u.memref.shm_id = shm->id;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result teec_pre_process_whole(
+ TEEC_RegisteredMemoryReference *memref,
+ struct tee_ioctl_param *param)
+{
+ const uint32_t inout = TEEC_MEM_INPUT | TEEC_MEM_OUTPUT;
+ uint32_t flags = memref->parent->flags & inout;
+ TEEC_SharedMemory *shm = NULL;
+
+ if (flags == inout)
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT;
+ else if (flags & TEEC_MEM_INPUT)
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT;
+ else if (flags & TEEC_MEM_OUTPUT)
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT;
+ else
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ shm = memref->parent;
+ /*
+ * We're using a shadow buffer in this reference, copy the real buffer
+ * into the shadow buffer if needed. We'll copy it back once we've
+ * returned from the call to secure world.
+ */
+ if (shm->shadow_buffer && (flags & TEEC_MEM_INPUT))
+ memcpy(shm->shadow_buffer, shm->buffer, shm->size);
+
+ param->u.memref.shm_id = shm->id;
+ param->u.memref.size = shm->size;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result teec_pre_process_partial(uint32_t param_type,
+ TEEC_RegisteredMemoryReference *memref,
+ struct tee_ioctl_param *param)
+{
+ uint32_t req_shm_flags = 0;
+ TEEC_SharedMemory *shm = NULL;
+
+ switch (param_type) {
+ case TEEC_MEMREF_PARTIAL_INPUT:
+ req_shm_flags = TEEC_MEM_INPUT;
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT;
+ break;
+ case TEEC_MEMREF_PARTIAL_OUTPUT:
+ req_shm_flags = TEEC_MEM_OUTPUT;
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT;
+ break;
+ case TEEC_MEMREF_PARTIAL_INOUT:
+ req_shm_flags = TEEC_MEM_OUTPUT | TEEC_MEM_INPUT;
+ param->attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT;
+ break;
+ default:
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ shm = memref->parent;
+
+ if ((shm->flags & req_shm_flags) != req_shm_flags)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ /*
+ * We're using a shadow buffer in this reference, copy the real buffer
+ * into the shadow buffer if needed. We'll copy it back once we've
+ * returned from the call to secure world.
+ */
+ if (shm->shadow_buffer && param_type != TEEC_MEMREF_PARTIAL_OUTPUT)
+ memcpy((char *)shm->shadow_buffer + memref->offset,
+ (char *)shm->buffer + memref->offset, memref->size);
+
+ param->u.memref.shm_id = shm->id;
+ param->u.memref.shm_offs = memref->offset;
+ param->u.memref.size = memref->size;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result teec_pre_process_operation(TEEC_Context *ctx,
+ TEEC_Operation *operation,
+ struct tee_ioctl_param *params,
+ TEEC_SharedMemory *shms)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ size_t n = 0;
+
+ memset(shms, 0, sizeof(TEEC_SharedMemory) *
+ TEEC_CONFIG_PAYLOAD_REF_COUNT);
+ if (!operation) {
+ memset(params, 0, sizeof(struct tee_ioctl_param) *
+ TEEC_CONFIG_PAYLOAD_REF_COUNT);
+ return TEEC_SUCCESS;
+ }
+
+ for (n = 0; n < TEEC_CONFIG_PAYLOAD_REF_COUNT; n++) {
+ uint32_t param_type = 0;
+
+ param_type = TEEC_PARAM_TYPE_GET(operation->paramTypes, n);
+ switch (param_type) {
+ case TEEC_NONE:
+ params[n].attr = param_type;
+ break;
+ case TEEC_VALUE_INPUT:
+ case TEEC_VALUE_OUTPUT:
+ case TEEC_VALUE_INOUT:
+ params[n].attr = param_type;
+ params[n].u.value.a = operation->params[n].value.a;
+ params[n].u.value.b = operation->params[n].value.b;
+ break;
+ case TEEC_MEMREF_TEMP_INPUT:
+ case TEEC_MEMREF_TEMP_OUTPUT:
+ case TEEC_MEMREF_TEMP_INOUT:
+ res = teec_pre_process_tmpref(ctx, param_type,
+ &operation->params[n].tmpref, params + n,
+ shms + n);
+ if (res != TEEC_SUCCESS)
+ return res;
+ break;
+ case TEEC_MEMREF_WHOLE:
+ res = teec_pre_process_whole(
+ &operation->params[n].memref,
+ params + n);
+ if (res != TEEC_SUCCESS)
+ return res;
+ break;
+ case TEEC_MEMREF_PARTIAL_INPUT:
+ case TEEC_MEMREF_PARTIAL_OUTPUT:
+ case TEEC_MEMREF_PARTIAL_INOUT:
+ res = teec_pre_process_partial(param_type,
+ &operation->params[n].memref, params + n);
+ if (res != TEEC_SUCCESS)
+ return res;
+ break;
+ default:
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ }
+
+ return TEEC_SUCCESS;
+}
+
+static void teec_post_process_tmpref(uint32_t param_type,
+ TEEC_TempMemoryReference *tmpref,
+ struct tee_ioctl_param *param,
+ TEEC_SharedMemory *shm)
+{
+ if (param_type != TEEC_MEMREF_TEMP_INPUT) {
+ if (param->u.memref.size <= tmpref->size && tmpref->buffer)
+ memcpy(tmpref->buffer, shm->buffer,
+ param->u.memref.size);
+
+ tmpref->size = param->u.memref.size;
+ }
+}
+
+static void teec_post_process_whole(TEEC_RegisteredMemoryReference *memref,
+ struct tee_ioctl_param *param)
+{
+ TEEC_SharedMemory *shm = memref->parent;
+
+ if (shm->flags & TEEC_MEM_OUTPUT) {
+
+ /*
+ * We're using a shadow buffer in this reference, copy back
+ * the shadow buffer into the real buffer now that we've
+ * returned from secure world.
+ */
+ if (shm->shadow_buffer && param->u.memref.size <= shm->size)
+ memcpy(shm->buffer, shm->shadow_buffer,
+ param->u.memref.size);
+
+ memref->size = param->u.memref.size;
+ }
+}
+
+static void teec_post_process_partial(uint32_t param_type,
+ TEEC_RegisteredMemoryReference *memref,
+ struct tee_ioctl_param *param)
+{
+ if (param_type != TEEC_MEMREF_PARTIAL_INPUT) {
+ TEEC_SharedMemory *shm = memref->parent;
+
+ /*
+ * We're using a shadow buffer in this reference, copy back
+ * the shadow buffer into the real buffer now that we've
+ * returned from secure world.
+ */
+ if (shm->shadow_buffer && param->u.memref.size <= memref->size)
+ memcpy((char *)shm->buffer + memref->offset,
+ (char *)shm->shadow_buffer + memref->offset,
+ param->u.memref.size);
+
+ memref->size = param->u.memref.size;
+ }
+}
+
+static void teec_post_process_operation(TEEC_Operation *operation,
+ struct tee_ioctl_param *params,
+ TEEC_SharedMemory *shms)
+{
+ size_t n = 0;
+
+ if (!operation)
+ return;
+
+ for (n = 0; n < TEEC_CONFIG_PAYLOAD_REF_COUNT; n++) {
+ uint32_t param_type = 0;
+
+ param_type = TEEC_PARAM_TYPE_GET(operation->paramTypes, n);
+ switch (param_type) {
+ case TEEC_VALUE_INPUT:
+ break;
+ case TEEC_VALUE_OUTPUT:
+ case TEEC_VALUE_INOUT:
+ operation->params[n].value.a = params[n].u.value.a;
+ operation->params[n].value.b = params[n].u.value.b;
+ break;
+ case TEEC_MEMREF_TEMP_INPUT:
+ case TEEC_MEMREF_TEMP_OUTPUT:
+ case TEEC_MEMREF_TEMP_INOUT:
+ teec_post_process_tmpref(param_type,
+ &operation->params[n].tmpref, params + n,
+ shms + n);
+ break;
+ case TEEC_MEMREF_WHOLE:
+ teec_post_process_whole(&operation->params[n].memref,
+ params + n);
+ break;
+ case TEEC_MEMREF_PARTIAL_INPUT:
+ case TEEC_MEMREF_PARTIAL_OUTPUT:
+ case TEEC_MEMREF_PARTIAL_INOUT:
+ teec_post_process_partial(param_type,
+ &operation->params[n].memref, params + n);
+ default:
+ break;
+ }
+ }
+}
+
+static void teec_free_temp_refs(TEEC_Operation *operation,
+ TEEC_SharedMemory *shms)
+{
+ size_t n = 0;
+
+ if (!operation)
+ return;
+
+ for (n = 0; n < TEEC_CONFIG_PAYLOAD_REF_COUNT; n++) {
+ switch (TEEC_PARAM_TYPE_GET(operation->paramTypes, n)) {
+ case TEEC_MEMREF_TEMP_INPUT:
+ case TEEC_MEMREF_TEMP_OUTPUT:
+ case TEEC_MEMREF_TEMP_INOUT:
+ TEEC_ReleaseSharedMemory(shms + n);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static TEEC_Result ioctl_errno_to_res(int err)
+{
+ switch (err) {
+ case ENOMEM:
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ default:
+ return TEEC_ERROR_GENERIC;
+ }
+}
+
+static void uuid_to_octets(uint8_t d[TEE_IOCTL_UUID_LEN], const TEEC_UUID *s)
+{
+ d[0] = s->timeLow >> 24;
+ d[1] = s->timeLow >> 16;
+ d[2] = s->timeLow >> 8;
+ d[3] = s->timeLow;
+ d[4] = s->timeMid >> 8;
+ d[5] = s->timeMid;
+ d[6] = s->timeHiAndVersion >> 8;
+ d[7] = s->timeHiAndVersion;
+ memcpy(d + 8, s->clockSeqAndNode, sizeof(s->clockSeqAndNode));
+}
+
+TEEC_Result TEEC_OpenSession(TEEC_Context *ctx, TEEC_Session *session,
+ const TEEC_UUID *destination,
+ uint32_t connection_method, const void *connection_data,
+ TEEC_Operation *operation, uint32_t *ret_origin)
+{
+ struct tee_ioctl_open_session_arg *arg = NULL;
+ struct tee_ioctl_param *params = NULL;
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ uint32_t eorig = 0;
+ int rc = 0;
+ const size_t arg_size = sizeof(struct tee_ioctl_open_session_arg) +
+ TEEC_CONFIG_PAYLOAD_REF_COUNT *
+ sizeof(struct tee_ioctl_param);
+ union {
+ struct tee_ioctl_open_session_arg arg;
+ uint8_t data[arg_size];
+ } buf;
+ struct tee_ioctl_buf_data buf_data;
+ TEEC_SharedMemory shm[TEEC_CONFIG_PAYLOAD_REF_COUNT];
+
+ memset(&buf, 0, sizeof(buf));
+ memset(&shm, 0, sizeof(shm));
+ memset(&buf_data, 0, sizeof(buf_data));
+
+ (void)&connection_data;
+
+ if (!ctx || !session) {
+ eorig = TEEC_ORIGIN_API;
+ res = TEEC_ERROR_BAD_PARAMETERS;
+ goto out;
+ }
+
+ buf_data.buf_ptr = (uintptr_t)&buf;
+ buf_data.buf_len = sizeof(buf);
+
+ arg = &buf.arg;
+ arg->num_params = TEEC_CONFIG_PAYLOAD_REF_COUNT;
+ params = (struct tee_ioctl_param *)(arg + 1);
+
+ uuid_to_octets(arg->uuid, destination);
+ arg->clnt_login = connection_method;
+
+ res = teec_pre_process_operation(ctx, operation, params, shm);
+ if (res != TEEC_SUCCESS) {
+ eorig = TEEC_ORIGIN_API;
+ goto out_free_temp_refs;
+ }
+
+ rc = ioctl(ctx->fd, TEE_IOC_OPEN_SESSION, &buf_data);
+ if (rc) {
+ EMSG("TEE_IOC_OPEN_SESSION failed");
+ eorig = TEEC_ORIGIN_COMMS;
+ res = ioctl_errno_to_res(errno);
+ goto out_free_temp_refs;
+ }
+ res = arg->ret;
+ eorig = arg->ret_origin;
+ if (res == TEEC_SUCCESS) {
+ session->ctx = ctx;
+ session->session_id = arg->session;
+ }
+ teec_post_process_operation(operation, params, shm);
+
+out_free_temp_refs:
+ teec_free_temp_refs(operation, shm);
+out:
+ if (ret_origin)
+ *ret_origin = eorig;
+ return res;
+}
+
+void TEEC_CloseSession(TEEC_Session *session)
+{
+ struct tee_ioctl_close_session_arg arg;
+
+ memset(&arg, 0, sizeof(arg));
+
+ if (!session)
+ return;
+
+ arg.session = session->session_id;
+ if (ioctl(session->ctx->fd, TEE_IOC_CLOSE_SESSION, &arg))
+ EMSG("Failed to close session 0x%x", session->session_id);
+}
+
+TEEC_Result TEEC_InvokeCommand(TEEC_Session *session, uint32_t cmd_id,
+ TEEC_Operation *operation, uint32_t *error_origin)
+{
+ struct tee_ioctl_invoke_arg *arg = NULL;
+ struct tee_ioctl_param *params = NULL;
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ uint32_t eorig = 0;
+ int rc = 0;
+ const size_t arg_size = sizeof(struct tee_ioctl_invoke_arg) +
+ TEEC_CONFIG_PAYLOAD_REF_COUNT *
+ sizeof(struct tee_ioctl_param);
+ union {
+ struct tee_ioctl_invoke_arg arg;
+ uint8_t data[arg_size];
+ } buf;
+ struct tee_ioctl_buf_data buf_data;
+ TEEC_SharedMemory shm[TEEC_CONFIG_PAYLOAD_REF_COUNT];
+
+ memset(&buf, 0, sizeof(buf));
+ memset(&buf_data, 0, sizeof(buf_data));
+ memset(&shm, 0, sizeof(shm));
+
+ if (!session) {
+ eorig = TEEC_ORIGIN_API;
+ res = TEEC_ERROR_BAD_PARAMETERS;
+ goto out;
+ }
+
+ bm_timestamp();
+
+ buf_data.buf_ptr = (uintptr_t)&buf;
+ buf_data.buf_len = sizeof(buf);
+
+ arg = &buf.arg;
+ arg->num_params = TEEC_CONFIG_PAYLOAD_REF_COUNT;
+ params = (struct tee_ioctl_param *)(arg + 1);
+
+ arg->session = session->session_id;
+ arg->func = cmd_id;
+
+ if (operation) {
+ teec_mutex_lock(&teec_mutex);
+ operation->session = session;
+ teec_mutex_unlock(&teec_mutex);
+ }
+
+ res = teec_pre_process_operation(session->ctx, operation, params, shm);
+ if (res != TEEC_SUCCESS) {
+ eorig = TEEC_ORIGIN_API;
+ goto out_free_temp_refs;
+ }
+
+ rc = ioctl(session->ctx->fd, TEE_IOC_INVOKE, &buf_data);
+ if (rc) {
+ EMSG("TEE_IOC_INVOKE failed");
+ eorig = TEEC_ORIGIN_COMMS;
+ res = ioctl_errno_to_res(errno);
+ goto out_free_temp_refs;
+ }
+
+ res = arg->ret;
+ eorig = arg->ret_origin;
+ teec_post_process_operation(operation, params, shm);
+
+ bm_timestamp();
+
+out_free_temp_refs:
+ teec_free_temp_refs(operation, shm);
+out:
+ if (error_origin)
+ *error_origin = eorig;
+ return res;
+}
+
+void TEEC_RequestCancellation(TEEC_Operation *operation)
+{
+ TEEC_Session *session = NULL;
+ struct tee_ioctl_cancel_arg arg;
+
+ memset(&arg, 0, sizeof(arg));
+
+ if (!operation)
+ return;
+
+ teec_mutex_lock(&teec_mutex);
+ session = operation->session;
+ teec_mutex_unlock(&teec_mutex);
+
+ if (!session)
+ return;
+
+ arg.session = session->session_id;
+ arg.cancel_id = 0;
+
+ if (ioctl(session->ctx->fd, TEE_IOC_CANCEL, &arg))
+ EMSG("TEE_IOC_CANCEL: %s", strerror(errno));
+}
+
+TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *ctx, TEEC_SharedMemory *shm)
+{
+ int fd = 0;
+ size_t s = 0;
+
+ if (!ctx || !shm)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!shm->flags || (shm->flags & ~(TEEC_MEM_INPUT | TEEC_MEM_OUTPUT)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ s = shm->size;
+ if (!s)
+ s = 8;
+ if (ctx->reg_mem) {
+ fd = teec_shm_register(ctx->fd, shm->buffer, s, &shm->id);
+ if (fd < 0)
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ shm->registered_fd = fd;
+ shm->shadow_buffer = NULL;
+ } else {
+ fd = teec_shm_alloc(ctx->fd, s, &shm->id);
+ if (fd < 0)
+ return TEEC_ERROR_OUT_OF_MEMORY;
+
+ shm->shadow_buffer = mmap(NULL, s, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ close(fd);
+ if (shm->shadow_buffer == (void *)MAP_FAILED) {
+ shm->id = -1;
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ }
+ shm->registered_fd = -1;
+ }
+
+ shm->alloced_size = s;
+ shm->buffer_allocated = false;
+ return TEEC_SUCCESS;
+}
+
+TEEC_Result TEEC_RegisterSharedMemoryFileDescriptor(TEEC_Context *ctx,
+ TEEC_SharedMemory *shm,
+ int fd)
+{
+ int rfd = 0;
+ struct tee_ioctl_shm_register_fd_data data;
+
+ memset(&data, 0, sizeof(data));
+
+ if (!ctx || !shm || fd < 0)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!shm->flags || (shm->flags & ~(TEEC_MEM_INPUT | TEEC_MEM_OUTPUT)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ data.fd = fd;
+ rfd = ioctl(ctx->fd, TEE_IOC_SHM_REGISTER_FD, &data);
+ if (rfd < 0)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ shm->buffer = NULL;
+ shm->shadow_buffer = NULL;
+ shm->registered_fd = rfd;
+ shm->id = data.id;
+ shm->size = data.size;
+ return TEEC_SUCCESS;
+}
+
+TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *ctx, TEEC_SharedMemory *shm)
+{
+ int fd = 0;
+ size_t s = 0;
+
+ if (!ctx || !shm)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!shm->flags || (shm->flags & ~(TEEC_MEM_INPUT | TEEC_MEM_OUTPUT)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ s = shm->size;
+ if (!s)
+ s = 8;
+
+ if (ctx->reg_mem) {
+ shm->buffer = malloc(s);
+ if (!shm->buffer)
+ return TEEC_ERROR_OUT_OF_MEMORY;
+
+ fd = teec_shm_register(ctx->fd, shm->buffer, s, &shm->id);
+ if (fd < 0) {
+ free(shm->buffer);
+ shm->buffer = NULL;
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ }
+ shm->registered_fd = fd;
+ } else {
+ fd = teec_shm_alloc(ctx->fd, s, &shm->id);
+ if (fd < 0)
+ return TEEC_ERROR_OUT_OF_MEMORY;
+
+ shm->buffer = mmap(NULL, s, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ close(fd);
+ if (shm->buffer == (void *)MAP_FAILED) {
+ shm->id = -1;
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ }
+ shm->registered_fd = -1;
+ }
+
+ shm->shadow_buffer = NULL;
+ shm->alloced_size = s;
+ shm->buffer_allocated = true;
+ return TEEC_SUCCESS;
+}
+
+void TEEC_ReleaseSharedMemory(TEEC_SharedMemory *shm)
+{
+ if (!shm || shm->id == -1)
+ return;
+
+ if (shm->shadow_buffer)
+ munmap(shm->shadow_buffer, shm->alloced_size);
+ else if (shm->buffer) {
+ if (shm->registered_fd >= 0) {
+ if (shm->buffer_allocated)
+ free(shm->buffer);
+ close(shm->registered_fd);
+ } else
+ munmap(shm->buffer, shm->alloced_size);
+ } else if (shm->registered_fd >= 0)
+ close(shm->registered_fd);
+
+ shm->id = -1;
+ shm->shadow_buffer = NULL;
+ shm->buffer = NULL;
+ shm->registered_fd = -1;
+ shm->buffer_allocated = false;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_api.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_api.c
new file mode 100755
index 0000000..07ce951
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_api.c
@@ -0,0 +1,433 @@
+/*
+ * Copyright (c) 2015-2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+/* OP-TEE TEE client API (built by optee_client) */
+#include <tee_client_api.h>
+
+/* TA API: UUID and command IDs */
+#include <ta_api.h>
+
+/*
+ * teec_session_init - ³õʼ»¯tee client×ÊÔ´²¢¸úuuidÖ¸¶¨µÄ·þÎñ½¨Á¢Í¨ÐÅ
+ * ctx: TEE client info
+ * uuid: ta ·þÎñµÄuuid
+ */
+TEEC_Result teec_session_init(teec_info *ctx,TEEC_UUID uuid)
+{
+ uint32_t origin;
+ TEEC_Result res;
+
+ /* Initialize a context connecting us to the TEE */
+ res = TEEC_InitializeContext(NULL, &ctx->ctx);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ /* Open a session with the TA */
+ res = TEEC_OpenSession(&ctx->ctx, &ctx->sess, &uuid, TEEC_LOGIN_PUBLIC, NULL, NULL, &origin);
+ if (res != TEEC_SUCCESS)
+ {
+ TEEC_FinalizeContext(&ctx->ctx);
+ }
+
+ return res;
+}
+
+/*
+ * teec_session_close - ÊÍ·Å tee client×ÊÔ´²¢¹Ø±ÕͨÐÅ
+ * ctx: TEE client info
+ */
+void teec_session_close(teec_info *ctx)
+{
+ TEEC_CloseSession(&ctx->sess);
+ TEEC_FinalizeContext(&ctx->ctx);
+}
+
+TEEC_Result teec_gen_keys( teec_info *ctx,uint32_t ago,uint32_t key_size,char *outkey, int *outlen)
+{
+ TEEC_Result res;
+ TEEC_Operation op;
+ uint32_t origin;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE);
+ op.params[0].value.a = ago;
+ op.params[1].value.a = key_size;
+ op.params[2].tmpref.buffer = outkey;
+ op.params[2].tmpref.size = *outlen;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_CIPHER_GENKEYS,&op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("\nTEEC_InvokeCommand(TA_RSA_CMD_GENKEYS) failed %#x\n", res);
+ *outlen = op.params[2].tmpref.size;
+
+ return res;
+}
+
+TEEC_Result teec_set_key( teec_info *ctx, uint32_t ago_type,char *key, size_t key_sz)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ memset(&op, 0, sizeof(op));
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE, TEEC_NONE);
+ op.params[0].value.a = ago_type;
+ op.params[1].tmpref.buffer = key;
+ op.params[1].tmpref.size = key_sz;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_CIPHER_SET_KEY, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("TEEC_InvokeCommand(SET_KEY) failed 0x%x origin 0x%x",res, origin);
+
+ return res;
+}
+
+TEEC_Result teec_cipher_init( teec_info *ctx, uint32_t alg,int encode, char *iv, size_t iv_sz)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE);
+ op.params[0].value.a = alg;
+ op.params[1].value.a = encode;
+ op.params[2].tmpref.buffer = iv;
+ op.params[2].tmpref.size = iv_sz;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_SET_CIPHER_INFO, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("TEEC_InvokeCommand(PREPARE) failed 0x%x origin 0x%x", res, origin);
+
+ return res;
+}
+
+TEEC_Result teec_cipher( teec_info *ctx, char *in, size_t insz, char *out, size_t *outsz)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE);
+ op.params[0].tmpref.buffer = in;
+ op.params[0].tmpref.size = insz;
+ op.params[1].tmpref.buffer = out;
+ op.params[1].tmpref.size = *outsz;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_CIPHER, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf( "TEEC_InvokeCommand(CIPHER) failed 0x%x origin 0x%x", res, origin);
+ *outsz = op.params[1].tmpref.size;
+
+ return res;
+}
+
+TEEC_Result teec_asy_gen_keys(teec_info *ctx,uint32_t ago,uint32_t key_size)
+{
+ TEEC_Result res;
+ TEEC_Operation op;
+ uint32_t origin;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE);
+ op.params[0].value.a = ago;
+ op.params[1].value.a = key_size;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_ASY_GENKEYS,&op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf( "\n teec TA_CRYPT_CMD_ASY_GENKEYS failed %#x\n", res);
+
+ return res;
+}
+
+TEEC_Result teec_rsa_public_keys(teec_info *ctx,uint32_t ago, uint32_t key_size, key_data_t *key_data)
+{
+ TEEC_Result res;
+ TEEC_Operation op;
+ uint32_t origin;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE);
+ op.params[0].value.a = ago ;
+ op.params[0].value.b = key_size;
+ op.params[1].tmpref.buffer = key_data->public1;
+ op.params[1].tmpref.size = key_data->pub_size1;
+ op.params[2].tmpref.buffer = key_data->public2;
+ op.params[2].tmpref.size = key_data->pub_size2;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_RSA_PUBLICKEYS, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf( "\n teec TA_CRYPT_CMD_RSA_PUBLICKEYS failed %#x\n", res);
+
+ return res;
+}
+
+TEEC_Result teec_rsa_private_keys(teec_info *ctx,uint32_t ago, uint32_t key_size, key_data_t *key_data)
+{
+ TEEC_Result res;
+ TEEC_Operation op;
+ uint32_t origin;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT);
+ op.params[0].value.a = ago ;
+ op.params[0].value.b = key_size;
+ op.params[1].tmpref.buffer = key_data->public1;
+ op.params[1].tmpref.size = key_data->pub_size1;
+ op.params[2].tmpref.buffer = key_data->public2;
+ op.params[2].tmpref.size = key_data->pub_size2;
+ op.params[3].tmpref.buffer = key_data->private;
+ op.params[3].tmpref.size = key_data->priv_size;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_RSA_PRIVATEKEYS, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("\n teec TA_CRYPT_CMD_RSA_PRIVATEKEYS failed %#x\n", res);
+
+ return res;
+}
+
+TEEC_Result teec_sm2_public_keys(teec_info *ctx,uint32_t ago, uint32_t key_size, key_data_t *key_data)
+{
+ TEEC_Result res;
+ TEEC_Operation op;
+ uint32_t origin;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE);
+ op.params[0].value.a = ago ;
+ op.params[0].value.b = key_size;
+ op.params[1].tmpref.buffer = key_data->public1;
+ op.params[1].tmpref.size = key_data->pub_size1;
+ op.params[2].tmpref.buffer = key_data->public2;
+ op.params[2].tmpref.size = key_data->pub_size2;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_SM2_PUBLICKEYS, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf( "\n teec TA_CRYPT_CMD_RSA_PUBLICKEYS failed %#x\n", res);
+
+ return res;
+}
+
+TEEC_Result teec_sm2_private_keys(teec_info *ctx,uint32_t ago, uint32_t key_size, key_data_t *key_data)
+{
+ TEEC_Result res;
+ TEEC_Operation op;
+ uint32_t origin;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT);
+ op.params[0].value.a = ago ;
+ op.params[0].value.b = key_size;
+ op.params[1].tmpref.buffer = key_data->public1;
+ op.params[1].tmpref.size = key_data->pub_size1;
+ op.params[2].tmpref.buffer = key_data->public2;
+ op.params[2].tmpref.size = key_data->pub_size2;
+ op.params[3].tmpref.buffer = key_data->private;
+ op.params[3].tmpref.size = key_data->priv_size;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_SM2_PRIVATEKEYS, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("\n teec TA_CRYPT_CMD_RSA_PRIVATEKEYS failed %#x\n", res);
+
+ return res;
+}
+
+TEEC_Result teec_asy_encrypt(teec_info *ctx,uint32_t ago, char *in, size_t in_sz, char *out, size_t *out_sz)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE);
+ op.params[0].value.a = ago;
+ op.params[1].tmpref.buffer = in;
+ op.params[1].tmpref.size = in_sz;
+ op.params[2].tmpref.buffer = out;
+ op.params[2].tmpref.size = *out_sz;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_ASY_ENCRYPT, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("\n teec TA_CRYPT_CMD_ASY_ENCRYPT failed 0x%x origin 0x%x\n", res, origin);
+
+ *out_sz = op.params[2].tmpref.size;
+ return res;
+}
+
+TEEC_Result teec_asy_decrypt(teec_info *ctx, uint32_t ago, char *in, size_t in_sz, char *out, size_t *out_sz)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE);
+ op.params[0].value.a = ago;
+ op.params[1].tmpref.buffer = in;
+ op.params[1].tmpref.size = in_sz;
+ op.params[2].tmpref.buffer = out;
+ op.params[2].tmpref.size = *out_sz;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_ASY_DECRYPT, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("\n teec TA_CRYPT_CMD_ASY_DECRYPT failed 0x%x origin 0x%x\n", res, origin);
+ *out_sz = op.params[2].tmpref.size;
+
+ return res;
+}
+
+TEEC_Result teec_digest(teec_info *ctx, uint32_t ago, char *in, size_t in_sz, char *out, size_t *out_sz)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE);
+ op.params[0].value.a = ago;
+ op.params[1].tmpref.buffer = in;
+ op.params[1].tmpref.size = in_sz;
+ op.params[2].tmpref.buffer = out;
+ op.params[2].tmpref.size = *out_sz;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_DIGEST, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("\n teec TA_CRYPT_CMD_DIGEST failed 0x%x origin 0x%x\n", res, origin);
+ *out_sz = op.params[2].tmpref.size;
+
+ return res;
+}
+
+TEEC_Result teec_asy_sign(teec_info *ctx, uint32_t ago, char *in, size_t in_sz, char *out, size_t *out_sz)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE);
+ op.params[0].value.a = ago;
+ op.params[1].tmpref.buffer = in;
+ op.params[1].tmpref.size = in_sz;
+ op.params[2].tmpref.buffer = out;
+ op.params[2].tmpref.size = *out_sz;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_ASY_SIGN, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf("\n teec TA_CRYPT_CMD_ASY_SIGN failed 0x%x origin 0x%x\n", res, origin);
+ *out_sz = op.params[2].tmpref.size;
+
+ return res;
+}
+
+TEEC_Result teec_asy_verify(teec_info *ctx, uint32_t ago, char *digest, size_t dig_len, char *sign, size_t sign_len)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE);
+ op.params[0].value.a = ago;
+ op.params[1].tmpref.buffer = digest;
+ op.params[1].tmpref.size = dig_len;
+ op.params[2].tmpref.buffer = sign;
+ op.params[2].tmpref.size = sign_len;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_CRYPT_CMD_ASY_VERIFY, &op, &origin);
+ if (res != TEEC_SUCCESS)
+ printf( "\nTEEC_InvokeCommand(TA_RSA_CMD_VERIFY) failed 0x%x origin 0x%x\n", res, origin);
+
+ return res;
+}
+
+/*
+ * teec_ss_read -¶ÁÈ¡°²È«¶ÔÏóµÄÄÚÈÝ
+ * ctx: TEE client info
+ * id: °²È«¶ÔÏó×Ö·û´®id
+ * data: Êý¾Ýbuffer,×î´ó8kb;
+ * data_len: Êý¾Ý³¤¶È
+ */
+TEEC_Result teec_ss_read(teec_info *ctx, char *id, char *data, size_t *data_len)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE);
+ op.params[0].tmpref.buffer = id;
+ op.params[0].tmpref.size = strlen(id);
+ op.params[1].tmpref.buffer = data;
+ op.params[1].tmpref.size = *data_len;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_SECURE_STORAGE_CMD_READ_RAW, &op, &origin);
+ switch (res) {
+ case TEEC_SUCCESS:
+ case TEEC_ERROR_SHORT_BUFFER:
+ case TEEC_ERROR_ITEM_NOT_FOUND:
+ break;
+ default:
+ printf("Command READ_RAW failed: 0x%x / %u\n", res, origin);
+ }
+ *data_len =op.params[1].tmpref.size;
+
+ return res;
+}
+
+/*
+ * teec_ss_write -Ïò°²È«¶ÔÏóµÄдÈëÄÚÈÝ
+ * ctx: TEE client info
+ * id: °²È«¶ÔÏó×Ö·û´®id
+ * data: Êý¾Ýbuffer,×î´ó8kb;
+ * data_len: Êý¾Ý³¤¶È
+ */
+TEEC_Result teec_ss_write(teec_info *ctx, char *id, char *data, size_t data_len)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE, TEEC_NONE);
+ op.params[0].tmpref.buffer = id;
+ op.params[0].tmpref.size = strlen(id);
+ op.params[1].tmpref.buffer = data;
+ op.params[1].tmpref.size = data_len;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_SECURE_STORAGE_CMD_WRITE_RAW, &op, &origin);
+ switch (res) {
+ case TEEC_SUCCESS:
+ break;
+ default:
+ printf("Command WRITE_RAW failed: 0x%x / %u\n", res, origin);
+ }
+
+ return res;
+}
+
+/*
+ * teec_ss_delete -ɾµô°²È«¶ÔÏó
+ * ctx: TEE client info
+ * id: °²È«¶ÔÏó×Ö·û´®id
+ */
+ TEEC_Result teec_ss_delete(teec_info *ctx, char *id)
+{
+ TEEC_Operation op;
+ uint32_t origin;
+ TEEC_Result res;
+ size_t id_len = strlen(id);
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,TEEC_NONE, TEEC_NONE, TEEC_NONE);
+ op.params[0].tmpref.buffer = id;
+ op.params[0].tmpref.size = id_len;
+ res = TEEC_InvokeCommand(&ctx->sess, TA_SECURE_STORAGE_CMD_DELETE, &op, &origin);
+ switch (res) {
+ case TEEC_SUCCESS:
+ case TEEC_ERROR_ITEM_NOT_FOUND:
+ break;
+ default:
+ printf("Command DELETE failed: 0x%x / %u\n", res, origin);
+ }
+
+ return res;
+}
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_benchmark.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_benchmark.c
new file mode 100755
index 0000000..f7a82e0
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_benchmark.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <err.h>
+#include <fcntl.h>
+#include <math.h>
+#include <pthread.h>
+#include <sched.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <tee_bench.h>
+#include <tee_client_api.h>
+#include <unistd.h>
+
+#include "teec_benchmark.h"
+
+struct tee_ts_global *bench_ts_global;
+static const TEEC_UUID pta_benchmark_uuid = PTA_BENCHMARK_UUID;
+
+static TEEC_Context bench_ctx;
+static TEEC_Session bench_sess;
+
+static pthread_mutex_t teec_bench_mu = PTHREAD_MUTEX_INITIALIZER;
+
+/* Cycle counter */
+static inline uint64_t read_ccounter(void)
+{
+ uint64_t ccounter = 0;
+#ifdef __aarch64__
+ asm volatile("mrs %0, PMCCNTR_EL0" : "=r"(ccounter));
+#else
+ asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(ccounter));
+#endif
+ return ccounter * TEE_BENCH_DIVIDER;
+}
+
+static TEEC_Result benchmark_pta_open(void)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ uint32_t ret_orig = 0;
+
+ res = TEEC_InitializeContext(NULL, &bench_ctx);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ res = TEEC_OpenSession(&bench_ctx, &bench_sess,
+ &pta_benchmark_uuid,
+ TEEC_LOGIN_PUBLIC, NULL, NULL, &ret_orig);
+ if (res != TEEC_SUCCESS) {
+ TEEC_FinalizeContext(&bench_ctx);
+ return res;
+ }
+
+ return res;
+}
+
+static void benchmark_pta_close(void)
+{
+ TEEC_CloseSession(&bench_sess);
+ TEEC_FinalizeContext(&bench_ctx);
+}
+
+static TEEC_Result benchmark_get_bench_buf_paddr(uint64_t *paddr_ts_buf,
+ uint64_t *size)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ uint32_t ret_orig = 0;
+ TEEC_Operation op;
+
+ memset(&op, 0, sizeof(op));
+
+ res = benchmark_pta_open();
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_OUTPUT, TEEC_NONE,
+ TEEC_NONE, TEEC_NONE);
+
+ res = TEEC_InvokeCommand(&bench_sess, BENCHMARK_CMD_GET_MEMREF,
+ &op, &ret_orig);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ *paddr_ts_buf = op.params[0].value.a;
+ *size = op.params[0].value.b;
+
+ benchmark_pta_close();
+
+ return res;
+}
+
+static void *mmap_paddr(intptr_t paddr, uint64_t size)
+{
+ int devmem = 0;
+ off_t offset = 0;
+ off_t page_addr = 0;
+ intptr_t *hw_addr = NULL;
+
+ devmem = open("/dev/mem", O_RDWR);
+ if (!devmem)
+ return NULL;
+
+ offset = (off_t)paddr % getpagesize();
+ page_addr = (off_t)(paddr - offset);
+
+ hw_addr = (intptr_t *)mmap(0, size, PROT_READ|PROT_WRITE,
+ MAP_SHARED, devmem, page_addr);
+ if (hw_addr == MAP_FAILED) {
+ close(devmem);
+ return NULL;
+ }
+
+ close(devmem);
+ return (hw_addr + offset);
+}
+
+/* check if we are in benchmark mode */
+static bool benchmark_check_mode(void)
+{
+ uint64_t ts_buf_raw = 0;
+ uint64_t ts_buf_size = 0;
+ bool res = true;
+
+ if (!bench_ts_global) {
+ /* receive buffer from Benchmark PTA and register it */
+ benchmark_get_bench_buf_paddr(&ts_buf_raw, &ts_buf_size);
+ if (ts_buf_raw && ts_buf_size) {
+ bench_ts_global = mmap_paddr(ts_buf_raw, ts_buf_size);
+ res = (bench_ts_global) ? true : false;
+ } else {
+ res = false;
+ }
+ }
+
+ return res;
+}
+
+/* Adding timestamp to buffer */
+void bm_timestamp(void)
+{
+ struct tee_ts_cpu_buf *cpu_buf = NULL;
+ uint64_t ts_i = 0;
+ void *ret_addr = NULL;
+ uint32_t cur_cpu = 0;
+ int ret = 0;
+ cpu_set_t cpu_set_old;
+ cpu_set_t cpu_set_tmp;
+ struct tee_time_st ts_data;
+
+ memset(&cpu_set_old, 0, sizeof(cpu_set_old));
+ memset(&cpu_set_tmp, 0, sizeof(cpu_set_tmp));
+ memset(&ts_data, 0, sizeof(ts_data));
+
+ if (pthread_mutex_trylock(&teec_bench_mu))
+ return;
+
+ if (!benchmark_check_mode())
+ goto error;
+
+ CPU_ZERO(&cpu_set_old);
+ ret = sched_getaffinity(0, sizeof(cpu_set_old), &cpu_set_old);
+ if (ret)
+ goto error;
+
+ /* stick to the same core while putting timestamp */
+ cur_cpu = sched_getcpu();
+ CPU_ZERO(&cpu_set_tmp);
+ CPU_SET(cur_cpu, &cpu_set_tmp);
+ ret = sched_setaffinity(0, sizeof(cpu_set_tmp), &cpu_set_tmp);
+ if (ret)
+ goto error;
+
+ /* fill timestamp data */
+ if (cur_cpu >= bench_ts_global->cores) {
+ ret = sched_setaffinity(0, sizeof(cpu_set_old), &cpu_set_old);
+ goto error;
+ }
+
+ ret_addr = __builtin_return_address(0);
+
+ cpu_buf = &bench_ts_global->cpu_buf[cur_cpu];
+ ts_i = __sync_fetch_and_add(&cpu_buf->head, 1);
+ ts_data.cnt = read_ccounter();
+ ts_data.addr = (uintptr_t)ret_addr;
+ ts_data.src = TEE_BENCH_CLIENT;
+ cpu_buf->stamps[ts_i & TEE_BENCH_MAX_MASK] = ts_data;
+
+ /* set back affinity mask */
+ sched_setaffinity(0, sizeof(cpu_set_old), &cpu_set_old);
+
+error:
+ pthread_mutex_unlock(&teec_bench_mu);
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_trace.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_trace.c
new file mode 100755
index 0000000..7194c8c
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/libteec/src/teec_trace.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <pthread.h>
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+
+#include "teec_trace.h"
+
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+
+/*
+ * The length of the prefix is 37, for example it looks like this:
+ * P = Prefix
+ * M = Message
+ * F = Function name
+ * L = Line number
+ * PPPP: MMMMM [FFFFFFFFFFFFFFF : LLLLL]
+ */
+#define MAX_PRINT_SIZE 256
+
+#ifdef TEEC_LOG_FILE
+static void log_to_file(const char *buffer)
+{
+ FILE *log_file = fopen(TEEC_LOG_FILE, "a");
+
+ if (log_file != NULL) {
+ fprintf(log_file, "%s", buffer);
+ fclose(log_file);
+ log_file = NULL;
+ }
+}
+#else
+#define log_to_file(buffer)
+#endif
+
+static const char * const trace_level_strings[] = {
+ "", "ERR", "INF", "DBG", "FLW"
+};
+
+void _dprintf(const char *function, int line, int level, const char *prefix,
+ const char *fmt, ...)
+{
+ char msg[MAX_PRINT_SIZE];
+ int n = 0;
+ va_list ap;
+
+ if (function) {
+ int thread_id = syscall(SYS_gettid);
+
+ n = snprintf(msg, sizeof(msg), "%s [%d] %s:%s:%d: ",
+ trace_level_strings[level], thread_id, prefix,
+ function, line);
+ if (n < 0)
+ return;
+ }
+
+ if ((size_t)n < sizeof(msg)) {
+ va_start(ap, fmt);
+ n = vsnprintf(msg + n, sizeof(msg) - n, fmt, ap);
+ va_end(ap);
+ if (n < 0)
+ return;
+ }
+
+ fprintf(stdout, "%s", msg);
+ log_to_file(msg);
+}
+
+#if (defined(DEBUGLEVEL_3) || defined(DEBUGLEVEL_true) || defined(DEBUGLEVEL_4))
+void dump_buffer(const char *bname, const uint8_t *buffer, size_t blen)
+{
+ fprintf(stderr, "#### %s\n", bname);
+
+ while (blen > 0) {
+ size_t n = 0;
+
+ for (n = 0; n < 16; n++) {
+ if (n < blen)
+ fprintf(stderr, "%02x ", (int)buffer[n]);
+ else
+ fprintf(stderr, " ");
+
+ if (n == 7)
+ fprintf(stderr, " ");
+ }
+
+ fprintf(stderr, " |");
+
+ for (n = 0; n < 16; n++) {
+ if (n < blen) {
+ if (isprint(buffer[n]))
+ fprintf(stderr, "%c", (int)buffer[n]);
+ else
+ fprintf(stderr, ".");
+ }
+ }
+
+ fprintf(stderr, "|\n");
+
+ blen -= MIN(blen, 16);
+ buffer += 16;
+ }
+}
+#else
+void dump_buffer(const char *bname, const uint8_t *buffer, size_t blen)
+{
+ (void)bname;
+ (void)buffer;
+ (void)blen;
+}
+#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/CMakeLists.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/CMakeLists.txt
new file mode 100755
index 0000000..0fa4348
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/CMakeLists.txt
@@ -0,0 +1,21 @@
+project (optee-client-headers C)
+
+################################################################################
+# Header files to be exported
+################################################################################
+FILE(GLOB INSTALL_HEADERS "*.h")
+
+################################################################################
+# Built library
+################################################################################
+add_library(${PROJECT_NAME} INTERFACE)
+
+################################################################################
+# Public and private header and library dependencies
+################################################################################
+target_include_directories(teec PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+
+################################################################################
+# Install targets
+################################################################################
+install (FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/ta_api.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/ta_api.h
new file mode 100755
index 0000000..9d4e06f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/ta_api.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TA_API_H
+#define TA_API_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TEE_ALG_AES_ECB_NOPAD 0x10000010
+#define TEE_ALG_AES_CBC_NOPAD 0x10000110
+#define TEE_ALG_AES_CTR 0x10000210
+#define TEE_ALG_AES_CTS 0x10000310
+#define TEE_ALG_AES_XTS 0x10000410
+#define TEE_ALG_AES_CBC_MAC_NOPAD 0x30000110
+#define TEE_ALG_AES_CBC_MAC_PKCS5 0x30000510
+#define TEE_ALG_AES_CMAC 0x30000610
+#define TEE_ALG_AES_CCM 0x40000710
+#define TEE_ALG_AES_GCM 0x40000810
+#define TEE_ALG_DES_ECB_NOPAD 0x10000011
+#define TEE_ALG_DES_CBC_NOPAD 0x10000111
+#define TEE_ALG_DES_CBC_MAC_NOPAD 0x30000111
+#define TEE_ALG_DES_CBC_MAC_PKCS5 0x30000511
+#define TEE_ALG_DES3_ECB_NOPAD 0x10000013
+#define TEE_ALG_DES3_CBC_NOPAD 0x10000113
+#define TEE_ALG_DES3_CBC_MAC_NOPAD 0x30000113
+#define TEE_ALG_DES3_CBC_MAC_PKCS5 0x30000513
+#define TEE_ALG_SM4_ECB_NOPAD 0x10000014
+#define TEE_ALG_SM4_CBC_NOPAD 0x10000114
+#define TEE_ALG_SM4_CTR 0x10000214
+#define TEE_ALG_RSASSA_PKCS1_V1_5_MD5 0x70001830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA1 0x70002830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA224 0x70003830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA256 0x70004830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA384 0x70005830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA512 0x70006830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_MD5SHA1 0x7000F830
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1 0x70212930
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224 0x70313930
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256 0x70414930
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384 0x70515930
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512 0x70616930
+#define TEE_ALG_RSAES_PKCS1_V1_5 0x60000130
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1 0x60210230
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224 0x60310230
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256 0x60410230
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384 0x60510230
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512 0x60610230
+#define TEE_ALG_RSA_NOPAD 0x60000030
+#define TEE_ALG_DSA_SHA1 0x70002131
+#define TEE_ALG_DSA_SHA224 0x70003131
+#define TEE_ALG_DSA_SHA256 0x70004131
+#define TEE_ALG_SM2_DSA_SM3 0x70006045
+#define TEE_ALG_DH_DERIVE_SHARED_SECRET 0x80000032
+#define TEE_ALG_SM2_KEP 0x60000045
+#define TEE_ALG_MD5 0x50000001
+#define TEE_ALG_SHA1 0x50000002
+#define TEE_ALG_SHA224 0x50000003
+#define TEE_ALG_SHA256 0x50000004
+#define TEE_ALG_SHA384 0x50000005
+#define TEE_ALG_SHA512 0x50000006
+#define TEE_ALG_MD5SHA1 0x5000000F
+#define TEE_ALG_HMAC_MD5 0x30000001
+#define TEE_ALG_HMAC_SHA1 0x30000002
+#define TEE_ALG_HMAC_SHA224 0x30000003
+#define TEE_ALG_HMAC_SHA256 0x30000004
+#define TEE_ALG_HMAC_SHA384 0x30000005
+#define TEE_ALG_HMAC_SHA512 0x30000006
+#define TEE_ALG_HMAC_SM3 0x30000007
+/*
+ * Fix GP Internal Core API v1.1
+ * "Table 6-12: Structure of Algorithm Identifier"
+ * indicates ECDSA have the algorithm "0x41" and ECDH "0x42"
+ * whereas
+ * "Table 6-11: List of Algorithm Identifiers" defines
+ * TEE_ALG_ECDSA_P192 as 0x70001042
+ *
+ * We chose to define TEE_ALG_ECDSA_P192 as 0x70001041 (conform to table 6-12)
+ */
+#define TEE_ALG_ECDSA_P192 0x70001041
+#define TEE_ALG_ECDSA_P224 0x70002041
+#define TEE_ALG_ECDSA_P256 0x70003041
+#define TEE_ALG_ECDSA_P384 0x70004041
+#define TEE_ALG_ECDSA_P521 0x70005041
+#define TEE_ALG_ECDH_P192 0x80001042
+#define TEE_ALG_ECDH_P224 0x80002042
+#define TEE_ALG_ECDH_P256 0x80003042
+#define TEE_ALG_ECDH_P384 0x80004042
+#define TEE_ALG_ECDH_P521 0x80005042
+#define TEE_ALG_SM2_PKE 0x80000045
+#define TEE_ALG_SM3 0x50000007
+#define TEE_ALG_X25519 0x80000044
+#define TEE_ALG_ILLEGAL_VALUE 0xEFFFFFFF
+/* Object Types */
+
+#define TEE_TYPE_AES 0xA0000010
+#define TEE_TYPE_DES 0xA0000011
+#define TEE_TYPE_DES3 0xA0000013
+#define TEE_TYPE_SM4 0xA0000014
+#define TEE_TYPE_HMAC_MD5 0xA0000001
+#define TEE_TYPE_HMAC_SHA1 0xA0000002
+#define TEE_TYPE_HMAC_SHA224 0xA0000003
+#define TEE_TYPE_HMAC_SHA256 0xA0000004
+#define TEE_TYPE_HMAC_SHA384 0xA0000005
+#define TEE_TYPE_HMAC_SHA512 0xA0000006
+#define TEE_TYPE_HMAC_SM3 0xA0000007 /* Not in spec */
+#define TEE_TYPE_RSA_PUBLIC_KEY 0xA0000030
+#define TEE_TYPE_RSA_KEYPAIR 0xA1000030
+#define TEE_TYPE_DSA_PUBLIC_KEY 0xA0000031
+#define TEE_TYPE_DSA_KEYPAIR 0xA1000031
+#define TEE_TYPE_DH_KEYPAIR 0xA1000032
+#define TEE_TYPE_ECDSA_PUBLIC_KEY 0xA0000041
+#define TEE_TYPE_ECDSA_KEYPAIR 0xA1000041
+#define TEE_TYPE_ECDH_PUBLIC_KEY 0xA0000042
+#define TEE_TYPE_ECDH_KEYPAIR 0xA1000042
+#define TEE_TYPE_SM2_DSA_PUBLIC_KEY 0xA0000045
+#define TEE_TYPE_SM2_DSA_KEYPAIR 0xA1000045
+#define TEE_TYPE_SM2_KEP_PUBLIC_KEY 0xA0000046
+#define TEE_TYPE_SM2_KEP_KEYPAIR 0xA1000046
+#define TEE_TYPE_SM2_PKE_PUBLIC_KEY 0xA0000047
+#define TEE_TYPE_SM2_PKE_KEYPAIR 0xA1000047
+#define TEE_TYPE_GENERIC_SECRET 0xA0000000
+#define TEE_TYPE_CORRUPTED_OBJECT 0xA00000BE
+#define TEE_TYPE_DATA 0xA00000BF
+#define TEE_TYPE_X25519_PUBLIC_KEY 0xA0000044
+#define TEE_TYPE_X25519_KEYPAIR 0xA1000044
+
+typedef enum {
+ TEE_MODE_ENCRYPT = 0,
+ TEE_MODE_DECRYPT = 1,
+ TEE_MODE_SIGN = 2,
+ TEE_MODE_VERIFY = 3,
+ TEE_MODE_MAC = 4,
+ TEE_MODE_DIGEST = 5,
+ TEE_MODE_DERIVE = 6
+} TEE_OperationMode;
+
+/* TEE client info */
+typedef struct {
+ TEEC_Context ctx;
+ TEEC_Session sess;
+} teec_info;
+
+typedef struct{
+ char *public1;
+ uint32_t pub_size1;
+ char *public2;
+ uint32_t pub_size2;
+ char *private;
+ uint32_t priv_size;
+ }key_data_t;
+
+/* UUID of the trusted secure storage application */
+#define TA_SECURE_STORAGE_UUID { 0xf4e750bb, 0x1437, 0x4fbf, { 0x87, 0x85, 0x8d, 0x35, 0x80, 0xc3, 0x49, 0x94 } }
+
+/* UUID of the AES example trusted application */
+#define TA_CRYPT_UUID { 0x5dbac793, 0xf574, 0x4871, { 0x8a, 0xd3, 0x04, 0x33, 0x1e, 0xc1, 0x7f, 0x24 } }
+
+#define TA_CRYPT_MODE_ENCODE 1
+#define TA_CRYPT_MODE_DECODE 0
+
+#define TA_CRYPT_CMD_CIPHER_SET_KEY 1
+#define TA_CRYPT_CMD_CIPHER_GENKEYS 2
+#define TA_CRYPT_CMD_SET_CIPHER_INFO 3
+#define TA_CRYPT_CMD_CIPHER 4
+
+#define TA_CRYPT_CMD_ASY_GENKEYS 1000
+#define TA_CRYPT_CMD_ASY_ENCRYPT 1001
+#define TA_CRYPT_CMD_ASY_DECRYPT 1002
+#define TA_CRYPT_CMD_DIGEST 1003
+#define TA_CRYPT_CMD_ASY_SIGN 1004
+#define TA_CRYPT_CMD_ASY_VERIFY 1005
+#define TA_CRYPT_CMD_RSA_PUBLICKEYS 2006
+#define TA_CRYPT_CMD_RSA_PRIVATEKEYS 2007
+#define TA_CRYPT_CMD_SM2_PUBLICKEYS 2008
+#define TA_CRYPT_CMD_SM2_PRIVATEKEYS 2009
+
+#define TA_SECURE_STORAGE_CMD_READ_RAW 0
+#define TA_SECURE_STORAGE_CMD_WRITE_RAW 1
+#define TA_SECURE_STORAGE_CMD_DELETE 2
+
+TEEC_Result teec_session_init(teec_info *ctx,TEEC_UUID uuid);
+void teec_session_close(teec_info *ctx);
+TEEC_Result teec_gen_keys( teec_info *ctx,uint32_t ago,uint32_t key_size,char *outkey, int *outlen);
+TEEC_Result teec_set_key( teec_info *ctx, uint32_t ago_type,char *key, size_t key_sz);
+TEEC_Result teec_cipher_init( teec_info *ctx, uint32_t alg,int encode, char *iv, size_t iv_sz);
+TEEC_Result teec_cipher( teec_info *ctx, char *in, size_t insz, char *out, size_t *outsz);
+TEEC_Result teec_asy_gen_keys(teec_info *ctx,uint32_t ago,uint32_t key_size);
+TEEC_Result teec_asy_encrypt(teec_info *ctx,uint32_t ago, char *in, size_t in_sz, char *out, size_t *out_sz);
+TEEC_Result teec_asy_decrypt(teec_info *ctx, uint32_t ago, char *in, size_t in_sz, char *out, size_t *out_sz);
+TEEC_Result teec_digest(teec_info *ctx, uint32_t ago, char *in, size_t in_sz, char *out, size_t *out_sz);
+TEEC_Result teec_asy_sign(teec_info *ctx, uint32_t ago, char *in, size_t in_sz, char *out, size_t *out_sz);
+TEEC_Result teec_asy_verify(teec_info *ctx, uint32_t ago, char *digest, size_t dig_len, char *sign, size_t sign_len);
+TEEC_Result teec_rsa_public_keys(teec_info *ctx,uint32_t ago, uint32_t key_size, key_data_t *key_data);
+TEEC_Result teec_rsa_private_keys(teec_info *ctx,uint32_t ago, uint32_t key_size, key_data_t *key_data);
+TEEC_Result teec_ss_read(teec_info *ctx, char *id, char *data, size_t *data_len);
+TEEC_Result teec_ss_write(teec_info *ctx, char *id, char *data, size_t data_len);
+TEEC_Result teec_ss_delete(teec_info *ctx, char *id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TA_API_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_bench.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_bench.h
new file mode 100755
index 0000000..600407f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_bench.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TEE_BENCH_H
+#define TEE_BENCH_H
+
+#include <inttypes.h>
+
+#define PTA_BENCHMARK_UUID \
+ { 0x0b9a63b0, 0xb4c6, 0x4c85, \
+ { 0xa2, 0x84, 0xa2, 0x28, 0xef, 0x54, 0x7b, 0x4e } }
+
+#define BENCHMARK_CMD(id) (0xFA190000 | ((id) & 0xFFFF))
+#define BENCHMARK_CMD_REGISTER_MEMREF BENCHMARK_CMD(1)
+#define BENCHMARK_CMD_GET_MEMREF BENCHMARK_CMD(2)
+#define BENCHMARK_CMD_UNREGISTER BENCHMARK_CMD(3)
+
+/*
+ * Cycle count divider is enabled (in PMCR),
+ * CCNT value is incremented every 64th clock cycle
+ */
+#define TEE_BENCH_DIVIDER 64
+/* max amount of timestamps per buffer */
+#define TEE_BENCH_MAX_STAMPS 32
+#define TEE_BENCH_MAX_MASK (TEE_BENCH_MAX_STAMPS - 1)
+
+/* OP-TEE susbsystems ids */
+#define TEE_BENCH_CLIENT 0x10000000
+#define TEE_BENCH_KMOD 0x20000000
+#define TEE_BENCH_CORE 0x30000000
+#define TEE_BENCH_UTEE 0x40000000
+#define TEE_BENCH_DUMB_TA 0xF0000001
+
+/* storing timestamp */
+struct tee_time_st {
+ uint64_t cnt; /* stores value from CNTPCT register */
+ uint64_t addr; /* stores value from program counter register */
+ uint64_t src; /* OP-TEE subsystem id */
+};
+
+/* per-cpu circular buffer for timestamps */
+struct tee_ts_cpu_buf {
+ uint64_t head;
+ uint64_t tail;
+ struct tee_time_st stamps[TEE_BENCH_MAX_STAMPS];
+};
+
+/* memory layout for shared memory, where timestamps will be stored */
+struct tee_ts_global {
+ uint64_t cores;
+ struct tee_ts_cpu_buf cpu_buf[];
+};
+#endif /* TEE_BENCH_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_client_api.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_client_api.h
new file mode 100755
index 0000000..70e76ae
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_client_api.h
@@ -0,0 +1,550 @@
+/*
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ * Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TEE_CLIENT_API_H
+#define TEE_CLIENT_API_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+#include <limits.h>
+
+/*
+ * Defines the number of available memory references in an open session or
+ * invoke command operation payload.
+ */
+#define TEEC_CONFIG_PAYLOAD_REF_COUNT 4
+
+/**
+ * Defines the maximum size of a single shared memory block, in bytes, of both
+ * API allocated and API registered memory. There is no good value to put here
+ * (limits depend on specific config used), so this define does not provide any
+ * restriction in this implementation.
+ */
+#define TEEC_CONFIG_SHAREDMEM_MAX_SIZE ULONG_MAX
+
+/**
+ * Flag constants indicating the type of parameters encoded inside the
+ * operation payload (TEEC_Operation), Type is uint32_t.
+ *
+ * TEEC_NONE The Parameter is not used
+ *
+ * TEEC_VALUE_INPUT The Parameter is a TEEC_Value tagged as input.
+ *
+ * TEEC_VALUE_OUTPUT The Parameter is a TEEC_Value tagged as output.
+ *
+ * TEEC_VALUE_INOUT The Parameter is a TEEC_Value tagged as both as
+ * input and output, i.e., for which both the
+ * behaviors of TEEC_VALUE_INPUT and
+ * TEEC_VALUE_OUTPUT apply.
+ *
+ * TEEC_MEMREF_TEMP_INPUT The Parameter is a TEEC_TempMemoryReference
+ * describing a region of memory which needs to be
+ * temporarily registered for the duration of the
+ * Operation and is tagged as input.
+ *
+ * TEEC_MEMREF_TEMP_OUTPUT Same as TEEC_MEMREF_TEMP_INPUT, but the Memory
+ * Reference is tagged as output. The
+ * Implementation may update the size field to
+ * reflect the required output size in some use
+ * cases.
+ *
+ * TEEC_MEMREF_TEMP_INOUT A Temporary Memory Reference tagged as both
+ * input and output, i.e., for which both the
+ * behaviors of TEEC_MEMREF_TEMP_INPUT and
+ * TEEC_MEMREF_TEMP_OUTPUT apply.
+ *
+ * TEEC_MEMREF_WHOLE The Parameter is a Registered Memory Reference
+ * that refers to the entirety of its parent Shared
+ * Memory block. The parameter structure is a
+ * TEEC_MemoryReference. In this structure, the
+ * Implementation MUST read only the parent field
+ * and MAY update the size field when the operation
+ * completes.
+ *
+ * TEEC_MEMREF_PARTIAL_INPUT A Registered Memory Reference structure that
+ * refers to a partial region of its parent Shared
+ * Memory block and is tagged as input.
+ *
+ * TEEC_MEMREF_PARTIAL_OUTPUT Registered Memory Reference structure that
+ * refers to a partial region of its parent Shared
+ * Memory block and is tagged as output.
+ *
+ * TEEC_MEMREF_PARTIAL_INOUT The Registered Memory Reference structure that
+ * refers to a partial region of its parent Shared
+ * Memory block and is tagged as both input and
+ * output, i.e., for which both the behaviors of
+ * TEEC_MEMREF_PARTIAL_INPUT and
+ * TEEC_MEMREF_PARTIAL_OUTPUT apply.
+ */
+#define TEEC_NONE 0x00000000
+#define TEEC_VALUE_INPUT 0x00000001
+#define TEEC_VALUE_OUTPUT 0x00000002
+#define TEEC_VALUE_INOUT 0x00000003
+#define TEEC_MEMREF_TEMP_INPUT 0x00000005
+#define TEEC_MEMREF_TEMP_OUTPUT 0x00000006
+#define TEEC_MEMREF_TEMP_INOUT 0x00000007
+#define TEEC_MEMREF_WHOLE 0x0000000C
+#define TEEC_MEMREF_PARTIAL_INPUT 0x0000000D
+#define TEEC_MEMREF_PARTIAL_OUTPUT 0x0000000E
+#define TEEC_MEMREF_PARTIAL_INOUT 0x0000000F
+
+/**
+ * Flag constants indicating the data transfer direction of memory in
+ * TEEC_Parameter. TEEC_MEM_INPUT signifies data transfer direction from the
+ * client application to the TEE. TEEC_MEM_OUTPUT signifies data transfer
+ * direction from the TEE to the client application. Type is uint32_t.
+ *
+ * TEEC_MEM_INPUT The Shared Memory can carry data from the client
+ * application to the Trusted Application.
+ * TEEC_MEM_OUTPUT The Shared Memory can carry data from the Trusted
+ * Application to the client application.
+ */
+#define TEEC_MEM_INPUT 0x00000001
+#define TEEC_MEM_OUTPUT 0x00000002
+
+/**
+ * Return values. Type is TEEC_Result
+ *
+ * TEEC_SUCCESS The operation was successful.
+ * TEEC_ERROR_GENERIC Non-specific cause.
+ * TEEC_ERROR_ACCESS_DENIED Access privileges are not sufficient.
+ * TEEC_ERROR_CANCEL The operation was canceled.
+ * TEEC_ERROR_ACCESS_CONFLICT Concurrent accesses caused conflict.
+ * TEEC_ERROR_EXCESS_DATA Too much data for the requested operation was
+ * passed.
+ * TEEC_ERROR_BAD_FORMAT Input data was of invalid format.
+ * TEEC_ERROR_BAD_PARAMETERS Input parameters were invalid.
+ * TEEC_ERROR_BAD_STATE Operation is not valid in the current state.
+ * TEEC_ERROR_ITEM_NOT_FOUND The requested data item is not found.
+ * TEEC_ERROR_NOT_IMPLEMENTED The requested operation should exist but is not
+ * yet implemented.
+ * TEEC_ERROR_NOT_SUPPORTED The requested operation is valid but is not
+ * supported in this implementation.
+ * TEEC_ERROR_NO_DATA Expected data was missing.
+ * TEEC_ERROR_OUT_OF_MEMORY System ran out of resources.
+ * TEEC_ERROR_BUSY The system is busy working on something else.
+ * TEEC_ERROR_COMMUNICATION Communication with a remote party failed.
+ * TEEC_ERROR_SECURITY A security fault was detected.
+ * TEEC_ERROR_SHORT_BUFFER The supplied buffer is too short for the
+ * generated output.
+ * TEEC_ERROR_TARGET_DEAD Trusted Application has panicked
+ * during the operation.
+ */
+
+/**
+ * Standard defined error codes.
+ */
+#define TEEC_SUCCESS 0x00000000
+#define TEEC_ERROR_STORAGE_NOT_AVAILABLE 0xF0100003
+#define TEEC_ERROR_GENERIC 0xFFFF0000
+#define TEEC_ERROR_ACCESS_DENIED 0xFFFF0001
+#define TEEC_ERROR_CANCEL 0xFFFF0002
+#define TEEC_ERROR_ACCESS_CONFLICT 0xFFFF0003
+#define TEEC_ERROR_EXCESS_DATA 0xFFFF0004
+#define TEEC_ERROR_BAD_FORMAT 0xFFFF0005
+#define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006
+#define TEEC_ERROR_BAD_STATE 0xFFFF0007
+#define TEEC_ERROR_ITEM_NOT_FOUND 0xFFFF0008
+#define TEEC_ERROR_NOT_IMPLEMENTED 0xFFFF0009
+#define TEEC_ERROR_NOT_SUPPORTED 0xFFFF000A
+#define TEEC_ERROR_NO_DATA 0xFFFF000B
+#define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C
+#define TEEC_ERROR_BUSY 0xFFFF000D
+#define TEEC_ERROR_COMMUNICATION 0xFFFF000E
+#define TEEC_ERROR_SECURITY 0xFFFF000F
+#define TEEC_ERROR_SHORT_BUFFER 0xFFFF0010
+#define TEEC_ERROR_EXTERNAL_CANCEL 0xFFFF0011
+#define TEEC_ERROR_TARGET_DEAD 0xFFFF3024
+
+/**
+ * Function error origins, of type TEEC_ErrorOrigin. These indicate where in
+ * the software stack a particular return value originates from.
+ *
+ * TEEC_ORIGIN_API The error originated within the TEE Client API
+ * implementation.
+ * TEEC_ORIGIN_COMMS The error originated within the underlying
+ * communications stack linking the rich OS with
+ * the TEE.
+ * TEEC_ORIGIN_TEE The error originated within the common TEE code.
+ * TEEC_ORIGIN_TRUSTED_APP The error originated within the Trusted Application
+ * code.
+ */
+#define TEEC_ORIGIN_API 0x00000001
+#define TEEC_ORIGIN_COMMS 0x00000002
+#define TEEC_ORIGIN_TEE 0x00000003
+#define TEEC_ORIGIN_TRUSTED_APP 0x00000004
+
+/**
+ * Session login methods, for use in TEEC_OpenSession() as parameter
+ * connectionMethod. Type is uint32_t.
+ *
+ * TEEC_LOGIN_PUBLIC No login data is provided.
+ * TEEC_LOGIN_USER Login data about the user running the Client
+ * Application process is provided.
+ * TEEC_LOGIN_GROUP Login data about the group running the Client
+ * Application process is provided.
+ * TEEC_LOGIN_APPLICATION Login data about the running Client Application
+ * itself is provided.
+ * TEEC_LOGIN_USER_APPLICATION Login data about the user and the running
+ * Client Application itself is provided.
+ * TEEC_LOGIN_GROUP_APPLICATION Login data about the group and the running
+ * Client Application itself is provided.
+ */
+#define TEEC_LOGIN_PUBLIC 0x00000000
+#define TEEC_LOGIN_USER 0x00000001
+#define TEEC_LOGIN_GROUP 0x00000002
+#define TEEC_LOGIN_APPLICATION 0x00000004
+#define TEEC_LOGIN_USER_APPLICATION 0x00000005
+#define TEEC_LOGIN_GROUP_APPLICATION 0x00000006
+
+/**
+ * Encode the paramTypes according to the supplied types.
+ *
+ * @param p0 The first param type.
+ * @param p1 The second param type.
+ * @param p2 The third param type.
+ * @param p3 The fourth param type.
+ */
+#define TEEC_PARAM_TYPES(p0, p1, p2, p3) \
+ ((p0) | ((p1) << 4) | ((p2) << 8) | ((p3) << 12))
+
+/**
+ * Get the i_th param type from the paramType.
+ *
+ * @param p The paramType.
+ * @param i The i-th parameter to get the type for.
+ */
+#define TEEC_PARAM_TYPE_GET(p, i) (((p) >> (i * 4)) & 0xF)
+
+typedef uint32_t TEEC_Result;
+
+/**
+ * struct TEEC_Context - Represents a connection between a client application
+ * and a TEE.
+ */
+typedef struct {
+ /* Implementation defined */
+ int fd;
+ bool reg_mem;
+} TEEC_Context;
+
+/**
+ * This type contains a Universally Unique Resource Identifier (UUID) type as
+ * defined in RFC4122. These UUID values are used to identify Trusted
+ * Applications.
+ */
+typedef struct {
+ uint32_t timeLow;
+ uint16_t timeMid;
+ uint16_t timeHiAndVersion;
+ uint8_t clockSeqAndNode[8];
+} TEEC_UUID;
+
+/**
+ * struct TEEC_SharedMemory - Memory to transfer data between a client
+ * application and trusted code.
+ *
+ * @param buffer The memory buffer which is to be, or has been, shared
+ * with the TEE.
+ * @param size The size, in bytes, of the memory buffer.
+ * @param flags Bit-vector which holds properties of buffer.
+ * The bit-vector can contain either or both of the
+ * TEEC_MEM_INPUT and TEEC_MEM_OUTPUT flags.
+ *
+ * A shared memory block is a region of memory allocated in the context of the
+ * client application memory space that can be used to transfer data between
+ * that client application and a trusted application. The user of this struct
+ * is responsible to populate the buffer pointer.
+ */
+typedef struct {
+ void *buffer;
+ size_t size;
+ uint32_t flags;
+ /*
+ * Implementation-Defined
+ */
+ int id;
+ size_t alloced_size;
+ void *shadow_buffer;
+ int registered_fd;
+ bool buffer_allocated;
+} TEEC_SharedMemory;
+
+/**
+ * struct TEEC_TempMemoryReference - Temporary memory to transfer data between
+ * a client application and trusted code, only used for the duration of the
+ * operation.
+ *
+ * @param buffer The memory buffer which is to be, or has been shared with
+ * the TEE.
+ * @param size The size, in bytes, of the memory buffer.
+ *
+ * A memory buffer that is registered temporarily for the duration of the
+ * operation to be called.
+ */
+typedef struct {
+ void *buffer;
+ size_t size;
+} TEEC_TempMemoryReference;
+
+/**
+ * struct TEEC_RegisteredMemoryReference - use a pre-registered or
+ * pre-allocated shared memory block of memory to transfer data between
+ * a client application and trusted code.
+ *
+ * @param parent Points to a shared memory structure. The memory reference
+ * may utilize the whole shared memory or only a part of it.
+ * Must not be NULL
+ *
+ * @param size The size, in bytes, of the memory buffer.
+ *
+ * @param offset The offset, in bytes, of the referenced memory region from
+ * the start of the shared memory block.
+ *
+ */
+typedef struct {
+ TEEC_SharedMemory *parent;
+ size_t size;
+ size_t offset;
+} TEEC_RegisteredMemoryReference;
+
+/**
+ * struct TEEC_Value - Small raw data container
+ *
+ * Instead of allocating a shared memory buffer this structure can be used
+ * to pass small raw data between a client application and trusted code.
+ *
+ * @param a The first integer value.
+ *
+ * @param b The second value.
+ */
+typedef struct {
+ uint32_t a;
+ uint32_t b;
+} TEEC_Value;
+
+/**
+ * union TEEC_Parameter - Memory container to be used when passing data between
+ * client application and trusted code.
+ *
+ * Either the client uses a shared memory reference, parts of it or a small raw
+ * data container.
+ *
+ * @param tmpref A temporary memory reference only valid for the duration
+ * of the operation.
+ *
+ * @param memref The entire shared memory or parts of it.
+ *
+ * @param value The small raw data container to use
+ */
+typedef union {
+ TEEC_TempMemoryReference tmpref;
+ TEEC_RegisteredMemoryReference memref;
+ TEEC_Value value;
+} TEEC_Parameter;
+
+/**
+ * struct TEEC_Session - Represents a connection between a client application
+ * and a trusted application.
+ */
+typedef struct {
+ /* Implementation defined */
+ TEEC_Context *ctx;
+ uint32_t session_id;
+} TEEC_Session;
+
+/**
+ * struct TEEC_Operation - Holds information and memory references used in
+ * TEEC_InvokeCommand().
+ *
+ * @param started Client must initialize to zero if it needs to cancel
+ * an operation about to be performed.
+ * @param paramTypes Type of data passed. Use TEEC_PARAMS_TYPE macro to
+ * create the correct flags.
+ * 0 means TEEC_NONE is passed for all params.
+ * @param params Array of parameters of type TEEC_Parameter.
+ * @param session Internal pointer to the last session used by
+ * TEEC_InvokeCommand with this operation.
+ *
+ */
+typedef struct {
+ uint32_t started;
+ uint32_t paramTypes;
+ TEEC_Parameter params[TEEC_CONFIG_PAYLOAD_REF_COUNT];
+ /* Implementation-Defined */
+ TEEC_Session *session;
+} TEEC_Operation;
+
+/**
+ * TEEC_InitializeContext() - Initializes a context holding connection
+ * information on the specific TEE, designated by the name string.
+
+ * @param name A zero-terminated string identifying the TEE to connect to.
+ * If name is set to NULL, the default TEE is connected to. NULL
+ * is the only supported value in this version of the API
+ * implementation.
+ *
+ * @param context The context structure which is to be initialized.
+ *
+ * @return TEEC_SUCCESS The initialization was successful.
+ * @return TEEC_Result Something failed.
+ */
+TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context);
+
+/**
+ * TEEC_FinalizeContext() - Destroys a context holding connection information
+ * on the specific TEE.
+ *
+ * This function destroys an initialized TEE context, closing the connection
+ * between the client application and the TEE. This function must only be
+ * called when all sessions related to this TEE context have been closed and
+ * all shared memory blocks have been released.
+ *
+ * @param context The context to be destroyed.
+ */
+void TEEC_FinalizeContext(TEEC_Context *context);
+
+/**
+ * TEEC_OpenSession() - Opens a new session with the specified trusted
+ * application.
+ *
+ * @param context The initialized TEE context structure in which
+ * scope to open the session.
+ * @param session The session to initialize.
+ * @param destination A structure identifying the trusted application
+ * with which to open a session.
+ *
+ * @param connectionMethod The connection method to use.
+ * @param connectionData Any data necessary to connect with the chosen
+ * connection method. Not supported, should be set to
+ * NULL.
+ * @param operation An operation structure to use in the session. May
+ * be set to NULL to signify no operation structure
+ * needed.
+ *
+ * @param returnOrigin A parameter which will hold the error origin if
+ * this function returns any value other than
+ * TEEC_SUCCESS.
+ *
+ * @return TEEC_SUCCESS OpenSession successfully opened a new session.
+ * @return TEEC_Result Something failed.
+ *
+ */
+TEEC_Result TEEC_OpenSession(TEEC_Context *context,
+ TEEC_Session *session,
+ const TEEC_UUID *destination,
+ uint32_t connectionMethod,
+ const void *connectionData,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin);
+
+/**
+ * TEEC_CloseSession() - Closes the session which has been opened with the
+ * specific trusted application.
+ *
+ * @param session The opened session to close.
+ */
+void TEEC_CloseSession(TEEC_Session *session);
+
+/**
+ * TEEC_InvokeCommand() - Executes a command in the specified trusted
+ * application.
+ *
+ * @param session A handle to an open connection to the trusted
+ * application.
+ * @param commandID Identifier of the command in the trusted application
+ * to invoke.
+ * @param operation An operation structure to use in the invoke command.
+ * May be set to NULL to signify no operation structure
+ * needed.
+ * @param returnOrigin A parameter which will hold the error origin if this
+ * function returns any value other than TEEC_SUCCESS.
+ *
+ * @return TEEC_SUCCESS OpenSession successfully opened a new session.
+ * @return TEEC_Result Something failed.
+ */
+TEEC_Result TEEC_InvokeCommand(TEEC_Session *session,
+ uint32_t commandID,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin);
+
+/**
+ * TEEC_RegisterSharedMemory() - Register a block of existing memory as a
+ * shared block within the scope of the specified context.
+ *
+ * @param context The initialized TEE context structure in which scope to
+ * open the session.
+ * @param sharedMem pointer to the shared memory structure to register.
+ *
+ * @return TEEC_SUCCESS The registration was successful.
+ * @return TEEC_ERROR_OUT_OF_MEMORY Memory exhaustion.
+ * @return TEEC_Result Something failed.
+ */
+TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *context,
+ TEEC_SharedMemory *sharedMem);
+
+/**
+ * TEEC_AllocateSharedMemory() - Allocate shared memory for TEE.
+ *
+ * @param context The initialized TEE context structure in which scope to
+ * open the session.
+ * @param sharedMem Pointer to the allocated shared memory.
+ *
+ * @return TEEC_SUCCESS The registration was successful.
+ * @return TEEC_ERROR_OUT_OF_MEMORY Memory exhaustion.
+ * @return TEEC_Result Something failed.
+ */
+TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *context,
+ TEEC_SharedMemory *sharedMem);
+
+/**
+ * TEEC_ReleaseSharedMemory() - Free or deregister the shared memory.
+ *
+ * @param sharedMem Pointer to the shared memory to be freed.
+ */
+void TEEC_ReleaseSharedMemory(TEEC_SharedMemory *sharedMemory);
+
+/**
+ * TEEC_RequestCancellation() - Request the cancellation of a pending open
+ * session or command invocation.
+ *
+ * @param operation Pointer to an operation previously passed to open session
+ * or invoke.
+ */
+void TEEC_RequestCancellation(TEEC_Operation *operation);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_client_api_extensions.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_client_api_extensions.h
new file mode 100755
index 0000000..85298aa
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/tee_client_api_extensions.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TEE_CLIENT_API_EXTENSIONS_H
+#define TEE_CLIENT_API_EXTENSIONS_H
+
+#include <tee_client_api.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * TEEC_RegisterMemoryFileDescriptor() - Register a block of existing memory as
+ * a shared block within the scope of the specified context.
+ *
+ * @param context The initialized TEE context structure in which scope to
+ * open the session.
+ * @param sharedMem pointer to the shared memory structure to register.
+ * @param fd file descriptor of the target memory.
+ *
+ * @return TEEC_SUCCESS The registration was successful.
+ * @return TEEC_ERROR_OUT_OF_MEMORY Memory exhaustion.
+ * @return TEEC_Result Something failed.
+ */
+TEEC_Result TEEC_RegisterSharedMemoryFileDescriptor(TEEC_Context *context,
+ TEEC_SharedMemory *sharedMem,
+ int fd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TEE_CLIENT_API_EXTENSIONS_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/teec_trace.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/teec_trace.h
new file mode 100755
index 0000000..f75358f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/public/teec_trace.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TEEC_TRACE_H
+#define TEEC_TRACE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+#include <stdio.h>
+#include <stdint.h>
+
+#ifndef BINARY_PREFIX
+#error "BINARY_PREFIX not defined"
+#endif
+
+/*
+ * Trace levels.
+ *
+ * ERROR is used when some kind of error has happened, this is most likely the
+ * print you will use most of the time when you report some kind of error.
+ *
+ * INFO is used when you want to print some 'normal' text to the user.
+ * This is the default level.
+ *
+ * DEBUG is used to print extra information to enter deeply in the module.
+ *
+ * FLOW is used to print the execution flox, typically the in/out of functions.
+ *
+ * */
+
+#define TRACE_ERROR 1
+#define TRACE_INFO 2
+#define TRACE_DEBUG 3
+#define TRACE_FLOW 4
+
+#if defined(DEBUGLEVEL_0) && !defined(DEBUGLEVEL)
+#define DEBUGLEVEL TRACE_ERROR
+#endif
+
+#if defined(DEBUGLEVEL_1) && !defined(DEBUGLEVEL)
+#define DEBUGLEVEL TRACE_ERROR
+#endif
+
+#if defined(DEBUGLEVEL_2) && !defined(DEBUGLEVEL)
+#define DEBUGLEVEL TRACE_INFO
+#endif
+
+#if defined(DEBUGLEVEL_3) && !defined(DEBUGLEVEL)
+#define DEBUGLEVEL TRACE_DEBUG
+#endif
+
+#if defined(DEBUGLEVEL_4) && !defined(DEBUGLEVEL)
+#define DEBUGLEVEL TRACE_FLOW
+#endif
+
+#ifndef DEBUGLEVEL
+/* Default debug level. */
+#define DEBUGLEVEL TRACE_INFO
+#endif
+
+/*
+ * This define make sure that parameters are checked in the same manner as it
+ * is done in the normal printf function.
+ */
+#define __PRINTFLIKE(__fmt, __varargs) __attribute__\
+ ((__format__(__printf__, __fmt, __varargs)))
+
+void _dprintf(const char *function, int line, int level, const char *prefix,
+ const char *fmt, ...) __PRINTFLIKE(5, 6);
+
+#define dprintf(level, x...) do { \
+ if ((level) <= DEBUGLEVEL) { \
+ _dprintf(__func__, __LINE__, level, \
+ BINARY_PREFIX, x); \
+ } \
+ } while (0)
+
+#define EMSG(fmt, ...) dprintf(TRACE_ERROR, fmt "\n", ##__VA_ARGS__)
+#define IMSG(fmt, ...) dprintf(TRACE_INFO, fmt "\n", ##__VA_ARGS__)
+#define DMSG(fmt, ...) dprintf(TRACE_DEBUG, fmt "\n", ##__VA_ARGS__)
+#define FMSG(fmt, ...) dprintf(TRACE_FLOW, fmt "\n", ##__VA_ARGS__)
+
+#define INMSG(fmt, ...) FMSG("> " fmt, ##__VA_ARGS__)
+#define OUTMSG(fmt, ...) FMSG("< " fmt, ##__VA_ARGS__)
+#define OUTRMSG(r) \
+ do { \
+ if (r) \
+ EMSG("Function returns with [%d]", r); \
+ OUTMSG("r=[%d]", r); \
+ return r; \
+ } while (0)
+
+#define dprintf_raw(level, x...) do { \
+ if ((level) <= DEBUGLEVEL) \
+ _dprintf(0, 0, (level), BINARY_PREFIX, x); \
+ } while (0)
+
+#define EMSG_RAW(fmt, ...) dprintf_raw(TRACE_ERROR, fmt, ##__VA_ARGS__)
+#define IMSG_RAW(fmt, ...) dprintf_raw(TRACE_INFO, fmt, ##__VA_ARGS__)
+#define DMSG_RAW(fmt, ...) dprintf_raw(TRACE_DEBUG, fmt, ##__VA_ARGS__)
+#define FMSG_RAW(fmt, ...) dprintf_raw(TRACE_FLOW, fmt, ##__VA_ARGS__)
+
+/*
+ * This function will hex and ascii dump a buffer.
+ *
+ * Note that this function will only print if debug flag
+ * DEBUGLEVEL is INFO or FLOOD.
+ *
+ * @param bname Information string describing the buffer.
+ * @param buffer Pointer to the buffer.
+ * @param blen Length of the buffer.
+ *
+ * @return void
+ */
+void dump_buffer(const char *bname, const uint8_t *buffer, size_t blen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/CMakeLists.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/CMakeLists.txt
new file mode 100755
index 0000000..e41ba8a
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/CMakeLists.txt
@@ -0,0 +1,94 @@
+project (tee-supplicant C)
+
+################################################################################
+# Configuration flags always included
+################################################################################
+option (CFG_TA_TEST_PATH "Enable tee-supplicant to load from test/debug path" OFF)
+option (RPMB_EMU "Enable tee-supplicant to emulate RPMB" ON)
+option (CFG_TA_GPROF_SUPPORT "Enable tee-supplicant support for TAs instrumented with gprof" ON)
+option (CFG_FTRACE_SUPPORT "Enable tee-supplicant support for TAs instrumented with ftrace" ON)
+
+set (CFG_TEE_SUPP_LOG_LEVEL "1" CACHE STRING "tee-supplicant log level")
+# FIXME: Question is, is this really needed? Should just use defaults from # GNUInstallDirs?
+set (CFG_TEE_CLIENT_LOAD_PATH "/lib" CACHE STRING "Location of libteec.so")
+set (CFG_TEE_FS_PARENT_PATH "/data/tee" CACHE STRING "Location of TEE filesystem (secure storage)")
+# FIXME: Why do we have if defined(CFG_GP_SOCKETS) && CFG_GP_SOCKETS == 1 in the c-file?
+set (CFG_GP_SOCKETS "1" CACHE STRING "Enable GlobalPlatform Socket API support")
+
+################################################################################
+# Source files
+################################################################################
+set (SRC
+ src/handle.c
+ src/hmac_sha2.c
+ src/rpmb.c
+ src/sha2.c
+ src/tee_supp_fs.c
+ src/tee_supplicant.c
+ src/teec_ta_load.c
+)
+
+if (CFG_GP_SOCKETS)
+ set (SRC ${SRC} src/tee_socket.c)
+endif()
+
+if (CFG_TA_GPROF_SUPPORT OR CFG_FTRACE_SUPPORT)
+ set (SRC ${SRC} src/prof.c)
+endif()
+
+################################################################################
+# Built binary
+################################################################################
+add_executable (${PROJECT_NAME} ${SRC})
+
+################################################################################
+# Flags always set
+################################################################################
+target_compile_definitions (${PROJECT_NAME}
+ PRIVATE -DCFG_TEE_SUPP_LOG_LEVEL=${CFG_TEE_SUPP_LOG_LEVEL}
+ PRIVATE -DTEEC_LOAD_PATH="${CFG_TEE_CLIENT_LOAD_PATH}"
+ PRIVATE -DTEE_FS_PARENT_PATH="${CFG_TEE_FS_PARENT_PATH}"
+ PRIVATE -DBINARY_PREFIX="TSUP"
+)
+
+################################################################################
+# Optional flags
+################################################################################
+if (CFG_GP_SOCKETS)
+ target_compile_definitions (${PROJECT_NAME}
+ PRIVATE -DCFG_GP_SOCKETS=${CFG_GP_SOCKETS})
+endif()
+
+if (CFG_TA_TEST_PATH)
+ target_compile_definitions (${PROJECT_NAME}
+ PRIVATE -DCFG_TA_TEST_PATH=${CFG_TA_TEST_PATH})
+endif()
+
+if (RPMB_EMU)
+ target_compile_definitions (${PROJECT_NAME}
+ PRIVATE -DRPMB_EMU=1)
+endif()
+
+if (CFG_TA_GPROF_SUPPORT)
+ target_compile_definitions (${PROJECT_NAME}
+ PRIVATE -DCFG_TA_GPROF_SUPPORT)
+endif()
+
+if (CFG_FTRACE_SUPPORT)
+ target_compile_definitions (${PROJECT_NAME}
+ PRIVATE -DCFG_FTRACE_SUPPORT)
+endif()
+
+################################################################################
+# Public and private header and library dependencies
+################################################################################
+target_include_directories(${PROJECT_NAME} PRIVATE src)
+
+target_link_libraries (${PROJECT_NAME}
+ PRIVATE teec
+ PRIVATE optee-client-headers)
+
+################################################################################
+# Install targets
+################################################################################
+install (TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/Makefile
new file mode 100755
index 0000000..b7cf39a
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/Makefile
@@ -0,0 +1,89 @@
+include ../flags.mk
+include ../config.mk
+
+OUT_DIR := $(OO)/tee-supplicant
+
+# Emulate RPMB ioctl's
+RPMB_EMU := 1
+
+.PHONY: all tee-supplicant clean
+
+all: tee-supplicant
+################################################################################
+# Teec configuration
+################################################################################
+PACKAGE_NAME := tee-supplicant
+
+TEES_SRCS := tee_supplicant.c \
+ teec_ta_load.c \
+ tee_supp_fs.c \
+ rpmb.c \
+ handle.c
+
+
+ifeq ($(CFG_GP_SOCKETS),y)
+TEES_SRCS += tee_socket.c
+endif
+
+ifeq ($(RPMB_EMU),1)
+TEES_SRCS += sha2.c hmac_sha2.c
+endif
+ifneq (,$(filter y,$(CFG_TA_GPROF_SUPPORT) $(CFG_FTRACE_SUPPORT)))
+TEES_SRCS += prof.c
+endif
+
+TEES_SRC_DIR := src
+TEES_OBJ_DIR := $(OUT_DIR)
+TEES_OBJS := $(patsubst %.c,$(TEES_OBJ_DIR)/%.o, $(TEES_SRCS))
+TEES_INCLUDES := ${CURDIR}/../libteec/include \
+ ${CURDIR}/src \
+ ${CURDIR}/../public \
+
+TEES_CFLAGS := $(addprefix -I, $(TEES_INCLUDES)) $(CFLAGS) \
+ -DDEBUGLEVEL_$(CFG_TEE_SUPP_LOG_LEVEL) \
+ -DBINARY_PREFIX=\"TEES\" \
+ -DTEE_FS_PARENT_PATH=\"$(CFG_TEE_FS_PARENT_PATH)\" \
+ -DTEEC_LOAD_PATH=\"$(CFG_TEE_CLIENT_LOAD_PATH)\"
+
+ifeq ($(CFG_GP_SOCKETS),y)
+TEES_CFLAGS += -DCFG_GP_SOCKETS=1
+endif
+ifeq ($(RPMB_EMU),1)
+TEES_CFLAGS += -DRPMB_EMU=1
+endif
+ifeq ($(CFG_TA_TEST_PATH),y)
+TEES_CFLAGS += -DCFG_TA_TEST_PATH=1
+endif
+TEES_FILE := $(OUT_DIR)/$(PACKAGE_NAME)
+TEES_LFLAGS := $(LDFLAGS) -L$(OUT_DIR)/../libteec -lteec
+
+ifeq ($(CFG_TA_GPROF_SUPPORT),y)
+TEES_CFLAGS += -DCFG_TA_GPROF_SUPPORT
+endif
+
+ifeq ($(CFG_FTRACE_SUPPORT),y)
+TEES_CFLAGS += -DCFG_FTRACE_SUPPORT
+endif
+
+TEES_LFLAGS += -lpthread
+# Needed to get clock_gettime() for for glibc versions before 2.17
+TEES_LFLAGS += -lrt
+
+tee-supplicant: $(TEES_FILE)
+
+$(TEES_FILE): $(TEES_OBJS)
+ @echo " LINK $@"
+ $(VPREFIX)$(CC) -o $@ $+ $(TEES_LFLAGS)
+ @echo ""
+
+$(TEES_OBJ_DIR)/%.o: $(TEES_SRC_DIR)/%.c
+ $(VPREFIX)mkdir -p $(dir $@)
+ @echo " CC $<"
+ $(VPREFIX)$(CC) $(TEES_CFLAGS) $(TEES_CFLAGS_$(notdir $<)) -c $< -o $@
+
+################################################################################
+# Cleaning up configuration
+################################################################################
+clean:
+ $(RM) $(TEES_OBJS) $(TEES_FILE)
+ $(call rmdir,$(OUT_DIR))
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_ipsocket.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_ipsocket.h
new file mode 100755
index 0000000..7c33666
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_ipsocket.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016-2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ____TEE_IPSOCKET_H
+#define ____TEE_IPSOCKET_H
+
+typedef enum TEE_ipSocket_ipVersion_e {
+ TEE_IP_VERSION_DC = 0, /* don’t care */
+ TEE_IP_VERSION_4 = 1,
+ TEE_IP_VERSION_6 = 2
+} TEE_ipSocket_ipVersion;
+
+#endif /*____TEE_IPSOCKET_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_isocket_defines.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_isocket_defines.h
new file mode 100755
index 0000000..b38457a
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_isocket_defines.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016-2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef ____TEE_ISOCKET_DEFINES_H
+#define ____TEE_ISOCKET_DEFINES_H
+
+#define TEE_ISOCKET_VERSION 0x01000000
+
+#define TEE_ISOCKET_ERROR_PROTOCOL 0xF1007001
+#define TEE_ISOCKET_ERROR_REMOTE_CLOSED 0xF1007002
+#define TEE_ISOCKET_ERROR_TIMEOUT 0xF1007003
+#define TEE_ISOCKET_ERROR_OUT_OF_RESOURCES 0xF1007004
+#define TEE_ISOCKET_ERROR_LARGE_BUFFER 0xF1007005
+#define TEE_ISOCKET_WARNING_PROTOCOL 0xF1007006
+#define TEE_ISOCKET_ERROR_HOSTNAME 0xF1007007
+
+#endif /*____TEE_ISOCKET_DEFINES_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_tcpsocket_defines.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_tcpsocket_defines.h
new file mode 100755
index 0000000..21853e0
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_tcpsocket_defines.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016-2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ____TEE_TCPSOCKET_DEFINES_H
+#define ____TEE_TCPSOCKET_DEFINES_H
+
+/* Protocol identifier */
+#define TEE_ISOCKET_PROTOCOLID_TCP 0x65
+
+/* Instance specific errors */
+#define TEE_ISOCKET_TCP_WARNING_UNKNOWN_OUT_OF_BAND 0xF1010002
+
+#endif /*____TEE_TCPSOCKET_DEFINES_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_tcpsocket_defines_extensions.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_tcpsocket_defines_extensions.h
new file mode 100755
index 0000000..3a03a2c
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_tcpsocket_defines_extensions.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016-2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ____TEE_TCPSOCKET_DEFINES_EXTENSIONS_H
+#define ____TEE_TCPSOCKET_DEFINES_EXTENSIONS_H
+
+/* Instance and implementation specific ioctl functions */
+#define TEE_TCP_SET_RECVBUF 0x65f00000
+#define TEE_TCP_SET_SENDBUF 0x65f00001
+
+#endif /*____TEE_TCPSOCKET_DEFINES_EXTENSIONS_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_udpsocket_defines.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_udpsocket_defines.h
new file mode 100755
index 0000000..64ec09c
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/__tee_udpsocket_defines.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016-2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ____TEE_UDPSOCKET_DEFINES_H
+#define ____TEE_UDPSOCKET_DEFINES_H
+
+/* Protocol identifier */
+#define TEE_ISOCKET_PROTOCOLID_UDP 0x66
+
+/* Instance specific errors */
+#define TEE_ISOCKET_UDP_WARNING_UNKNOWN_OUT_OF_BAND 0xF1020002
+
+/* Instance specific ioctl functions */
+#define TEE_UDP_CHANGEADDR 0x66000001
+#define TEE_UDP_CHANGEPORT 0x66000002
+
+#endif /*____TEE_UDPSOCKET_DEFINES_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/handle.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/handle.c
new file mode 100755
index 0000000..58254bd
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/handle.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdlib.h>
+#include <string.h>
+#include "handle.h"
+
+/*
+ * Define the initial capacity of the database. It should be a low number
+ * multiple of 2 since some databases a likely to only use a few handles.
+ * Since the algorithm is to doubles up when growing it shouldn't cause a
+ * noticable overhead on large databases.
+ */
+#define HANDLE_DB_INITIAL_MAX_PTRS 4
+
+static void mutex_lock(struct handle_db *db)
+{
+ if (db->mu)
+ pthread_mutex_lock(db->mu);
+}
+
+static void mutex_unlock(struct handle_db *db)
+{
+ if (db->mu)
+ pthread_mutex_unlock(db->mu);
+}
+
+
+void handle_db_set_mutex(struct handle_db *db, pthread_mutex_t *mu)
+{
+ db->mu = mu;
+}
+
+void handle_db_destroy(struct handle_db *db)
+{
+ if (db) {
+ mutex_lock(db);
+ free(db->ptrs);
+ db->ptrs = NULL;
+ db->max_ptrs = 0;
+ mutex_unlock(db);
+ }
+}
+
+int handle_get(struct handle_db *db, void *ptr)
+{
+ size_t n = 0;
+ void *p = NULL;
+ size_t new_max_ptrs = 0;
+ int ret = 0;
+
+ if (!db || !ptr)
+ return -1;
+
+ mutex_lock(db);
+
+ /* Try to find an empty location */
+ for (n = 0; n < db->max_ptrs; n++) {
+ if (!db->ptrs[n]) {
+ db->ptrs[n] = ptr;
+ ret = n;
+ goto out;
+ }
+ }
+
+ /* No location available, grow the ptrs array */
+ if (db->max_ptrs)
+ new_max_ptrs = db->max_ptrs * 2;
+ else
+ new_max_ptrs = HANDLE_DB_INITIAL_MAX_PTRS;
+ p = realloc(db->ptrs, new_max_ptrs * sizeof(void *));
+ if (!p) {
+ ret = -1;
+ goto out;
+ }
+ db->ptrs = p;
+ memset(db->ptrs + db->max_ptrs, 0,
+ (new_max_ptrs - db->max_ptrs) * sizeof(void *));
+ db->max_ptrs = new_max_ptrs;
+
+ /* Since n stopped at db->max_ptrs there is an empty location there */
+ db->ptrs[n] = ptr;
+ ret = n;
+
+out:
+ mutex_unlock(db);
+ return ret;
+}
+
+void *handle_put(struct handle_db *db, int handle)
+{
+ void *p = NULL;
+
+ if (!db || handle < 0)
+ return NULL;
+
+ mutex_lock(db);
+
+ if ((size_t)handle >= db->max_ptrs) {
+ p = NULL;
+ goto out;
+ }
+
+ p = db->ptrs[handle];
+ db->ptrs[handle] = NULL;
+
+out:
+ mutex_unlock(db);
+ return p;
+}
+
+void *handle_lookup(struct handle_db *db, int handle)
+{
+ void *p = NULL;
+
+ if (!db || handle < 0)
+ return NULL;
+
+ mutex_lock(db);
+
+ if ((size_t)handle >= db->max_ptrs) {
+ p = NULL;
+ goto out;
+ }
+
+ p = db->ptrs[handle];
+
+out:
+ mutex_unlock(db);
+ return p;
+}
+
+void handle_foreach_put(struct handle_db *db,
+ void (*cb)(int handle, void *ptr, void *arg),
+ void *arg)
+{
+ size_t n = 0;
+
+ if (!db || !cb)
+ return;
+
+ mutex_lock(db);
+
+ for (n = 0; n < db->max_ptrs; n++) {
+ if (db->ptrs[n]) {
+ cb(n, db->ptrs[n], arg);
+ db->ptrs[n] = NULL;
+ }
+ }
+
+ mutex_unlock(db);
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/handle.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/handle.h
new file mode 100755
index 0000000..5be5461
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/handle.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef HANDLE_H
+#define HANDLE_H
+
+#include <stdint.h>
+#include <pthread.h>
+
+struct handle_db {
+ void **ptrs;
+ size_t max_ptrs;
+ pthread_mutex_t *mu;
+};
+
+#define HANDLE_DB_INITIALIZER { NULL, 0, NULL }
+#define HANDLE_DB_INITIALIZER_WITH_MUTEX(mu) { NULL, 0, (mu) }
+
+/*
+ * Assigns a mutex for the database. If mu != NULL the mutex will be
+ * acquired before each access to the database and released when
+ * the operation is done.
+ */
+void handle_db_set_mutex(struct handle_db *db, pthread_mutex_t *mu);
+
+/*
+ * Frees all internal data structures of the database, but does not free
+ * the db pointer. The database is safe to reuse after it's destroyed, it
+ * just be empty again. The assigned mutex is also preserved.
+ */
+void handle_db_destroy(struct handle_db *db);
+
+/*
+ * Allocates a new handle and assigns the supplied pointer to it,
+ * ptr must not be NULL.
+ * The function returns
+ * >= 0 on success and
+ * -1 on failure
+ */
+int handle_get(struct handle_db *db, void *ptr);
+
+/*
+ * Deallocates a handle. Returns the assiciated pointer of the handle
+ * the the handle was valid or NULL if it's invalid.
+ */
+void *handle_put(struct handle_db *db, int handle);
+
+/*
+ * Returns the assiciated pointer of the handle if the handle is a valid
+ * handle.
+ * Returns NULL on failure.
+ */
+void *handle_lookup(struct handle_db *db, int handle);
+
+void handle_foreach_put(struct handle_db *db,
+ void (*cb)(int handle, void *ptr, void *arg),
+ void *arg);
+
+#endif /*HANDLE_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/hmac_sha2.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/hmac_sha2.c
new file mode 100755
index 0000000..20e994a
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/hmac_sha2.c
@@ -0,0 +1,126 @@
+/*
+ * HMAC-SHA-224/256/384/512 implementation
+ * Last update: 06/15/2005
+ * Issue date: 06/15/2005
+ *
+ * Copyright (C) 2005 Olivier Gay <olivier.gay@a3.epfl.ch>
+ * All rights reserved.
+ *
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+#include "hmac_sha2.h"
+
+/* HMAC-SHA-256 functions */
+
+void hmac_sha256_init(hmac_sha256_ctx *ctx, const unsigned char *key,
+ unsigned int key_size)
+{
+ unsigned int fill = 0;
+ unsigned int num = 0;
+ const unsigned char *key_used = NULL;
+ unsigned char key_temp[SHA256_DIGEST_SIZE] = { 0 };
+ int i = 0;
+
+ if (key_size == SHA256_BLOCK_SIZE) {
+ key_used = key;
+ num = SHA256_BLOCK_SIZE;
+ } else {
+ if (key_size > SHA256_BLOCK_SIZE){
+ num = SHA256_DIGEST_SIZE;
+ sha256(key, key_size, key_temp);
+ key_used = key_temp;
+ } else { /* key_size > SHA256_BLOCK_SIZE */
+ key_used = key;
+ num = key_size;
+ }
+ fill = SHA256_BLOCK_SIZE - num;
+
+ memset(ctx->block_ipad + num, 0x36, fill);
+ memset(ctx->block_opad + num, 0x5c, fill);
+ }
+
+ for (i = 0; i < (int) num; i++) {
+ ctx->block_ipad[i] = key_used[i] ^ 0x36;
+ ctx->block_opad[i] = key_used[i] ^ 0x5c;
+ }
+
+ sha256_init(&ctx->ctx_inside);
+ sha256_update(&ctx->ctx_inside, ctx->block_ipad, SHA256_BLOCK_SIZE);
+
+ sha256_init(&ctx->ctx_outside);
+ sha256_update(&ctx->ctx_outside, ctx->block_opad,
+ SHA256_BLOCK_SIZE);
+
+ /* for hmac_reinit */
+ memcpy(&ctx->ctx_inside_reinit, &ctx->ctx_inside,
+ sizeof(sha256_ctx));
+ memcpy(&ctx->ctx_outside_reinit, &ctx->ctx_outside,
+ sizeof(sha256_ctx));
+}
+
+void hmac_sha256_reinit(hmac_sha256_ctx *ctx)
+{
+ memcpy(&ctx->ctx_inside, &ctx->ctx_inside_reinit,
+ sizeof(sha256_ctx));
+ memcpy(&ctx->ctx_outside, &ctx->ctx_outside_reinit,
+ sizeof(sha256_ctx));
+}
+
+void hmac_sha256_update(hmac_sha256_ctx *ctx, const unsigned char *message,
+ unsigned int message_len)
+{
+ sha256_update(&ctx->ctx_inside, message, message_len);
+}
+
+void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac,
+ unsigned int mac_size)
+{
+ unsigned char digest_inside[SHA256_DIGEST_SIZE] = { 0 };
+ unsigned char mac_temp[SHA256_DIGEST_SIZE] = { 0 };
+
+ sha256_final(&ctx->ctx_inside, digest_inside);
+ sha256_update(&ctx->ctx_outside, digest_inside, SHA256_DIGEST_SIZE);
+ sha256_final(&ctx->ctx_outside, mac_temp);
+ memcpy(mac, mac_temp, mac_size);
+}
+
+void hmac_sha256(const unsigned char *key, unsigned int key_size,
+ const unsigned char *message, unsigned int message_len,
+ unsigned char *mac, unsigned mac_size)
+{
+ hmac_sha256_ctx ctx;
+
+ memset(&ctx, 0, sizeof(ctx));
+
+ hmac_sha256_init(&ctx, key, key_size);
+ hmac_sha256_update(&ctx, message, message_len);
+ hmac_sha256_final(&ctx, mac, mac_size);
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/hmac_sha2.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/hmac_sha2.h
new file mode 100755
index 0000000..1044524
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/hmac_sha2.h
@@ -0,0 +1,74 @@
+/*
+ * HMAC-SHA-224/256/384/512 implementation
+ * Last update: 06/15/2005
+ * Issue date: 06/15/2005
+ *
+ * Copyright (C) 2005 Olivier Gay <olivier.gay@a3.epfl.ch>
+ * All rights reserved.
+ *
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef HMAC_SHA2_H
+#define HMAC_SHA2_H
+
+#include "sha2.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ sha256_ctx ctx_inside;
+ sha256_ctx ctx_outside;
+
+ /* for hmac_reinit */
+ sha256_ctx ctx_inside_reinit;
+ sha256_ctx ctx_outside_reinit;
+
+ unsigned char block_ipad[SHA256_BLOCK_SIZE];
+ unsigned char block_opad[SHA256_BLOCK_SIZE];
+} hmac_sha256_ctx;
+
+void hmac_sha256_init(hmac_sha256_ctx *ctx, const unsigned char *key,
+ unsigned int key_size);
+void hmac_sha256_reinit(hmac_sha256_ctx *ctx);
+void hmac_sha256_update(hmac_sha256_ctx *ctx, const unsigned char *message,
+ unsigned int message_len);
+void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac,
+ unsigned int mac_size);
+void hmac_sha256(const unsigned char *key, unsigned int key_size,
+ const unsigned char *message, unsigned int message_len,
+ unsigned char *mac, unsigned mac_size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !HMAC_SHA2_H */
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/optee_msg_supplicant.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/optee_msg_supplicant.h
new file mode 100755
index 0000000..f91b0b1
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/optee_msg_supplicant.h
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 2016-2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __OPTEE_MSG_SUPPLICANT_H
+#define __OPTEE_MSG_SUPPLICANT_H
+
+/*
+ * Load a TA into memory
+ */
+#define OPTEE_MSG_RPC_CMD_LOAD_TA 0
+
+/*
+ * Replay Protected Memory Block access
+ */
+#define OPTEE_MSG_RPC_CMD_RPMB 1
+
+/*
+ * File system access
+ */
+#define OPTEE_MSG_RPC_CMD_FS 2
+
+/*
+ * Define protocol for messages with .cmd == OPTEE_MSG_RPC_CMD_FS and first
+ * parameter has the attribute OPTEE_MSG_ATTR_TYPE_VALUE_INPUT.
+ */
+
+/*
+ * Open a file
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_OPEN
+ * [in] param[1].u.tmem a string holding the file name
+ * [out] param[2].u.value.a file descriptor of open file
+ */
+#define OPTEE_MRF_OPEN 0
+
+/*
+ * Create a file
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_CREATE
+ * [in] param[1].u.tmem a string holding the file name
+ * [out] param[2].u.value.a file descriptor of open file
+ */
+#define OPTEE_MRF_CREATE 1
+
+/*
+ * Close a file
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_CLOSE
+ * [in] param[0].u.value.b file descriptor of open file.
+ */
+#define OPTEE_MRF_CLOSE 2
+
+/*
+ * Read from a file
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_READ
+ * [in] param[0].u.value.b file descriptor of open file
+ * [in] param[0].u.value.c offset into file
+ * [out] param[1].u.tmem buffer to hold returned data
+ */
+#define OPTEE_MRF_READ 3
+
+/*
+ * Write to a file
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_WRITE
+ * [in] param[0].u.value.b file descriptor of open file
+ * [in] param[0].u.value.c offset into file
+ * [in] param[1].u.tmem buffer holding data to be written
+ */
+#define OPTEE_MRF_WRITE 4
+
+/*
+ * Truncate a file
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_TRUNCATE
+ * [in] param[0].u.value.b file descriptor of open file
+ * [in] param[0].u.value.c length of file.
+ */
+#define OPTEE_MRF_TRUNCATE 5
+
+/*
+ * Remove a file
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_REMOVE
+ * [in] param[1].u.tmem a string holding the file name
+ */
+#define OPTEE_MRF_REMOVE 6
+
+/*
+ * Rename a file
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_RENAME
+ * [in] param[0].u.value.b true if existing target should be removed
+ * [in] param[1].u.tmem a string holding the old file name
+ * [in] param[2].u.tmem a string holding the new file name
+ */
+#define OPTEE_MRF_RENAME 7
+
+/*
+ * Opens a directory for file listing
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_OPENDIR
+ * [in] param[1].u.tmem a string holding the name of the directory
+ * [out] param[2].u.value.a handle to open directory
+ */
+#define OPTEE_MRF_OPENDIR 8
+
+/*
+ * Closes a directory handle
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_CLOSEDIR
+ * [in] param[0].u.value.b handle to open directory
+ */
+#define OPTEE_MRF_CLOSEDIR 9
+
+/*
+ * Read next file name of directory
+ *
+ *
+ * [in] param[0].u.value.a OPTEE_MRF_READDIR
+ * [in] param[0].u.value.b handle to open directory
+ * [out] param[1].u.tmem a string holding the file name
+ */
+#define OPTEE_MRF_READDIR 10
+
+/*
+ * End of definitions for messages with .cmd == OPTEE_MSG_RPC_CMD_FS
+ */
+
+/*
+ * Command Ids 3, 4 and 5 of OPTEE_MSG_RPC_CMD_xxx macros are reserved for use
+ * by the kernel driver.
+ */
+
+/*
+ * Shared memory allocation
+ */
+#define OPTEE_MSG_RPC_CMD_SHM_ALLOC 6
+#define OPTEE_MSG_RPC_CMD_SHM_FREE 7
+
+/*
+ * Was OPTEE_MSG_RPC_CMD_SQL_FS, which isn't supported any longer
+ */
+#define OPTEE_MSG_RPC_CMD_SQL_FS_RESERVED 8
+
+/*
+ * GPROF support management commands
+ */
+#define OPTEE_MSG_RPC_CMD_GPROF 9
+
+/*
+ * Socket commands
+ */
+#define OPTEE_MSG_RPC_CMD_SOCKET 10
+
+/*
+ * Function tracing support management commands
+ */
+#define OPTEE_MSG_RPC_CMD_FTRACE 11
+
+
+/*
+ * Define protocol for messages with .cmd == OPTEE_MSG_RPC_CMD_SOCKET
+ */
+
+#define OPTEE_MRC_SOCKET_TIMEOUT_NONBLOCKING 0
+#define OPTEE_MRC_SOCKET_TIMEOUT_BLOCKING 0xffffffff
+
+/*
+ * Open socket
+ *
+ * [in] param[0].u.value.a OPTEE_MRC_SOCKET_OPEN
+ * [in] param[0].u.value.b TA instance id
+ * [in] param[1].u.value.a server port number
+ * [in] param[1].u.value.b protocol, TEE_ISOCKET_PROTOCOLID_*
+ * [in] param[1].u.value.c ip version TEE_IP_VERSION_* from tee_ipsocket.h
+ * [in] param[2].u.tmem server address
+ * [out] param[3].u.value.a socket handle (32-bit)
+ */
+#define OPTEE_MRC_SOCKET_OPEN 0
+
+/*
+ * Close socket
+ *
+ * [in] param[0].u.value.a OPTEE_MRC_SOCKET_CLOSE
+ * [in] param[0].u.value.b TA instance id
+ * [in] param[0].u.value.c socket handle
+ */
+#define OPTEE_MRC_SOCKET_CLOSE 1
+
+/*
+ * Close all sockets
+ *
+ * [in] param[0].u.value.a OPTEE_MRC_SOCKET_CLOSE_ALL
+ * [in] param[0].u.value.b TA instance id
+ */
+#define OPTEE_MRC_SOCKET_CLOSE_ALL 2
+
+/*
+ * Send data on socket
+ *
+ * [in] param[0].u.value.a OPTEE_MRC_SOCKET_SEND
+ * [in] param[0].u.value.b TA instance id
+ * [in] param[0].u.value.c socket handle
+ * [in] param[1].u.tmem buffer to transmit
+ * [in] param[2].u.value.a timeout ms or OPTEE_MRC_SOCKET_TIMEOUT_*
+ * [out] param[2].u.value.b number of transmitted bytes
+ */
+#define OPTEE_MRC_SOCKET_SEND 3
+
+/*
+ * Receive data on socket
+ *
+ * [in] param[0].u.value.a OPTEE_MRC_SOCKET_RECV
+ * [in] param[0].u.value.b TA instance id
+ * [in] param[0].u.value.c socket handle
+ * [out] param[1].u.tmem buffer to receive
+ * [in] param[2].u.value.a timeout ms or OPTEE_MRC_SOCKET_TIMEOUT_*
+ */
+#define OPTEE_MRC_SOCKET_RECV 4
+
+/*
+ * Perform IOCTL on socket
+ *
+ * [in] param[0].u.value.a OPTEE_MRC_SOCKET_IOCTL
+ * [in] param[0].u.value.b TA instance id
+ * [in] param[0].u.value.c socket handle
+ * [in/out] param[1].u.tmem buffer
+ * [in] param[2].u.value.a ioctl command
+ */
+#define OPTEE_MRC_SOCKET_IOCTL 5
+
+/*
+ * End of definitions for messages with .cmd == OPTEE_MSG_RPC_CMD_SOCKET
+ */
+
+#endif /*__OPTEE_MSG_SUPPLICANT_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/prof.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/prof.c
new file mode 100755
index 0000000..08fb278
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/prof.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <tee_client_api.h>
+#include <tee_supplicant.h>
+#include "prof.h"
+
+#ifndef __aligned
+#define __aligned(x) __attribute__((__aligned__(x)))
+#endif
+#include <linux/tee.h>
+
+TEEC_Result prof_process(size_t num_params, struct tee_ioctl_param *params,
+ const char *prefix)
+{
+ char vers[5] = "";
+ char path[255] = { 0 };
+ size_t bufsize = 0;
+ TEEC_UUID *u = NULL;
+ int fd = -1;
+ void *buf = NULL;
+ int flags = 0;
+ int id = 0;
+ int st = 0;
+ int n = 0;
+
+ if (num_params != 3 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT ||
+ (params[2].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ id = params[0].u.value.a;
+
+ if (params[1].u.memref.size != sizeof(TEEC_UUID))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ u = tee_supp_param_to_va(params + 1);
+ if (!u)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ buf = tee_supp_param_to_va(params + 2);
+ if (!buf)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ bufsize = params[2].u.memref.size;
+
+ if (id < 0 || id > 100)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ flags = O_APPEND | O_WRONLY;
+ if (!id) {
+ /* id == 0 means create file */
+ flags |= O_CREAT | O_EXCL;
+ id = 1;
+ }
+
+ for (;;) {
+ if (id > 1) {
+ /*
+ * id == 1 is file 0 (no suffix), id == 2 is file .1
+ * etc.
+ */
+ if (id > 100)
+ id = 100; /* Avoid GCC truncation warning */
+ snprintf(vers, sizeof(vers), ".%d", id - 1);
+ }
+ n = snprintf(path, sizeof(path),
+ "/tmp/%s"
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"
+ "%s.out",
+ prefix,
+ u->timeLow, u->timeMid, u->timeHiAndVersion,
+ u->clockSeqAndNode[0], u->clockSeqAndNode[1],
+ u->clockSeqAndNode[2], u->clockSeqAndNode[3],
+ u->clockSeqAndNode[4], u->clockSeqAndNode[5],
+ u->clockSeqAndNode[6], u->clockSeqAndNode[7],
+ vers);
+ if ((n < 0) || (n >= (int)sizeof(path)))
+ break;
+ fd = open(path, flags, 0644);
+ if (fd >= 0) {
+ do {
+ st = write(fd, buf, bufsize);
+ } while (st < 0 && errno == EINTR);
+ close(fd);
+ if (st < 0 || st != (int)bufsize)
+ break;
+ params[0].u.value.a = id;
+ goto success;
+ }
+ if (errno != EEXIST)
+ break;
+ if (id++ == 100)
+ break;
+ }
+
+ /* An error occurred */
+ return TEEC_ERROR_GENERIC;
+
+success:
+ return TEEC_SUCCESS;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/prof.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/prof.h
new file mode 100755
index 0000000..48c8993
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/prof.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PROF_H
+#define PROF_H
+
+#include <tee_client_api.h>
+
+struct tee_ioctl_param;
+
+#if defined(CFG_TA_GPROF_SUPPORT) || defined(CFG_FTRACE_SUPPORT)
+
+TEEC_Result prof_process(size_t num_params, struct tee_ioctl_param *params,
+ const char *prefix);
+
+#else
+
+static inline TEEC_Result prof_process(size_t num_params,
+ struct tee_ioctl_param *params,
+ const char *prefix)
+{
+ (void)num_params;
+ (void)params;
+ (void)prefix;
+
+ return TEEC_ERROR_NOT_SUPPORTED;
+}
+
+#endif /* CFG_TA_GPROF_SUPPORT || CFG_FTRACE_SUPPORT */
+#endif /* PROF_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/rpmb.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/rpmb.c
new file mode 100755
index 0000000..c90c049
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/rpmb.c
@@ -0,0 +1,816 @@
+/*
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <fcntl.h>
+#include <linux/types.h>
+#include <linux/mmc/ioctl.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <rpmb.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <tee_client_api.h>
+#include <teec_trace.h>
+#include <tee_supplicant.h>
+#include <unistd.h>
+
+#ifdef RPMB_EMU
+#include <stdarg.h>
+#include "hmac_sha2.h"
+#else
+#include <errno.h>
+#endif
+
+/*
+ * Request and response definitions must be in sync with the secure side
+ */
+
+/* Request */
+struct rpmb_req {
+ uint16_t cmd;
+#define RPMB_CMD_DATA_REQ 0x00
+#define RPMB_CMD_GET_DEV_INFO 0x01
+ uint16_t dev_id;
+ uint16_t block_count;
+ /* Optional data frames (rpmb_data_frame) follow */
+};
+#define RPMB_REQ_DATA(req) ((void *)((struct rpmb_req *)(req) + 1))
+
+/* Response to device info request */
+struct rpmb_dev_info {
+ uint8_t cid[16];
+ uint8_t rpmb_size_mult; /* EXT CSD-slice 168: RPMB Size */
+ uint8_t rel_wr_sec_c; /* EXT CSD-slice 222: Reliable Write Sector */
+ /* Count */
+ uint8_t ret_code;
+#define RPMB_CMD_GET_DEV_INFO_RET_OK 0x00
+#define RPMB_CMD_GET_DEV_INFO_RET_ERROR 0x01
+};
+
+/*
+ * This structure is shared with OP-TEE and the MMC ioctl layer.
+ * It is the "data frame for RPMB access" defined by JEDEC, minus the
+ * start and stop bits.
+ */
+struct rpmb_data_frame {
+ uint8_t stuff_bytes[196];
+ uint8_t key_mac[32];
+ uint8_t data[256];
+ uint8_t nonce[16];
+ uint32_t write_counter;
+ uint16_t address;
+ uint16_t block_count;
+ uint16_t op_result;
+#define RPMB_RESULT_OK 0x00
+#define RPMB_RESULT_GENERAL_FAILURE 0x01
+#define RPMB_RESULT_AUTH_FAILURE 0x02
+#define RPMB_RESULT_ADDRESS_FAILURE 0x04
+#define RPMB_RESULT_AUTH_KEY_NOT_PROGRAMMED 0x07
+ uint16_t msg_type;
+#define RPMB_MSG_TYPE_REQ_AUTH_KEY_PROGRAM 0x0001
+#define RPMB_MSG_TYPE_REQ_WRITE_COUNTER_VAL_READ 0x0002
+#define RPMB_MSG_TYPE_REQ_AUTH_DATA_WRITE 0x0003
+#define RPMB_MSG_TYPE_REQ_AUTH_DATA_READ 0x0004
+#define RPMB_MSG_TYPE_REQ_RESULT_READ 0x0005
+#define RPMB_MSG_TYPE_RESP_AUTH_KEY_PROGRAM 0x0100
+#define RPMB_MSG_TYPE_RESP_WRITE_COUNTER_VAL_READ 0x0200
+#define RPMB_MSG_TYPE_RESP_AUTH_DATA_WRITE 0x0300
+#define RPMB_MSG_TYPE_RESP_AUTH_DATA_READ 0x0400
+};
+
+
+static pthread_mutex_t rpmb_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/*
+ * ioctl() interface
+ * Comes from: uapi/linux/major.h, linux/mmc/core.h
+ */
+
+#define MMC_BLOCK_MAJOR 179
+
+/* mmc_ioc_cmd.opcode */
+#define MMC_SEND_EXT_CSD 8
+#define MMC_READ_MULTIPLE_BLOCK 18
+#define MMC_WRITE_MULTIPLE_BLOCK 25
+
+/* mmc_ioc_cmd.flags */
+#define MMC_RSP_PRESENT (1 << 0)
+#define MMC_RSP_136 (1 << 1) /* 136 bit response */
+#define MMC_RSP_CRC (1 << 2) /* Expect valid CRC */
+#define MMC_RSP_OPCODE (1 << 4) /* Response contains opcode */
+
+#define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
+
+#define MMC_CMD_ADTC (1 << 5) /* Addressed data transfer command */
+
+/* mmc_ioc_cmd.write_flag */
+#define MMC_CMD23_ARG_REL_WR (1 << 31) /* CMD23 reliable write */
+
+#ifndef RPMB_EMU
+
+#define IOCTL(fd, request, ...) \
+ ({ \
+ int ret; \
+ ret = ioctl((fd), (request), ##__VA_ARGS__); \
+ if (ret < 0) \
+ EMSG("ioctl ret=%d errno=%d", ret, errno); \
+ ret; \
+ })
+
+
+/* Open and/or return file descriptor to RPMB partition of device dev_id */
+static int mmc_rpmb_fd(uint16_t dev_id)
+{
+ static int id;
+ static int fd = -1;
+ char path[PATH_MAX] = { 0 };
+
+ DMSG("dev_id = %u", dev_id);
+ if (fd < 0) {
+#ifdef __ANDROID__
+ snprintf(path, sizeof(path), "/dev/mmcblk%urpmb", dev_id);
+#else
+ snprintf(path, sizeof(path), "/dev/mmcblk%urpmb", dev_id);
+#endif
+ fd = open(path, O_RDWR);
+ if (fd < 0) {
+ EMSG("Could not open %s (%s)", path, strerror(errno));
+ return -1;
+ }
+ id = dev_id;
+ }
+ if (id != dev_id) {
+ EMSG("Only one MMC device is supported");
+ return -1;
+ }
+ return fd;
+}
+
+/* Open eMMC device dev_id */
+static int mmc_fd(uint16_t dev_id)
+{
+ int fd = 0;
+ char path[PATH_MAX] = { 0 };
+
+ DMSG("dev_id = %u", dev_id);
+#ifdef __ANDROID__
+ snprintf(path, sizeof(path), "/dev/block/mmcblk%u", dev_id);
+#else
+ snprintf(path, sizeof(path), "/dev/mmcblk%u", dev_id);
+#endif
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ EMSG("Could not open %s (%s)", path, strerror(errno));
+
+ return fd;
+}
+
+static void close_mmc_fd(int fd)
+{
+ close(fd);
+}
+
+/* Device Identification (CID) register is 16 bytes. It is read from sysfs. */
+static uint32_t read_cid(uint16_t dev_id, uint8_t *cid)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ char path[48] = { 0 };
+ char hex[3] = { 0 };
+ int st = 0;
+ int fd = 0;
+ int i = 0;
+
+ snprintf(path, sizeof(path),
+ "/sys/class/mmc_host/mmc%u/mmc%u:0001/cid", dev_id, dev_id);
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ EMSG("Could not open %s (%s)", path, strerror(errno));
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+ }
+
+ for (i = 0; i < 16; i++) {
+ st = read(fd, hex, 2);
+ if (st < 0) {
+ EMSG("Read CID error (%s)", strerror(errno));
+ res = TEEC_ERROR_NO_DATA;
+ goto err;
+ }
+ cid[i] = (uint8_t)strtol(hex, NULL, 16);
+ }
+ res = TEEC_SUCCESS;
+err:
+ close(fd);
+ return res;
+}
+
+#else /* RPMB_EMU */
+
+#define IOCTL(fd, request, ...) ioctl_emu((fd), (request), ##__VA_ARGS__)
+
+/* Emulated rel_wr_sec_c value (reliable write size, *256 bytes) */
+#define EMU_RPMB_REL_WR_SEC_C 1
+/* Emulated rpmb_size_mult value (RPMB size, *128 kB) */
+#define EMU_RPMB_SIZE_MULT 2
+
+#define EMU_RPMB_SIZE_BYTES (EMU_RPMB_SIZE_MULT * 128 * 1024)
+
+/* Emulated eMMC device state */
+struct rpmb_emu {
+ uint8_t buf[EMU_RPMB_SIZE_BYTES];
+ size_t size;
+ uint8_t key[32];
+ bool key_set;
+ uint8_t nonce[16];
+ uint32_t write_counter;
+ struct {
+ uint16_t msg_type;
+ uint16_t op_result;
+ uint16_t address;
+ } last_op;
+};
+static struct rpmb_emu rpmb_emu = {
+ .size = EMU_RPMB_SIZE_BYTES
+};
+
+static struct rpmb_emu *mem_for_fd(int fd)
+{
+ static int sfd = -1;
+
+ if (sfd == -1)
+ sfd = fd;
+ if (sfd != fd) {
+ EMSG("Emulating more than 1 RPMB partition is not supported");
+ return NULL;
+ }
+
+ return &rpmb_emu;
+}
+
+#if (DEBUGLEVEL >= TRACE_FLOW)
+static void dump_blocks(size_t startblk, size_t numblk, uint8_t *ptr,
+ bool to_mmc)
+{
+ char msg[100] = { 0 };
+ size_t i = 0;
+
+ for (i = 0; i < numblk; i++) {
+ snprintf(msg, sizeof(msg), "%s MMC block %zu",
+ to_mmc ? "Write" : "Read", startblk + i);
+ dump_buffer(msg, ptr, 256);
+ ptr += 256;
+ }
+}
+#else
+static void dump_blocks(size_t startblk, size_t numblk, uint8_t *ptr,
+ bool to_mmc)
+{
+ (void)startblk;
+ (void)numblk;
+ (void)ptr;
+ (void)to_mmc;
+}
+#endif
+
+#define CUC(x) ((const unsigned char *)(x))
+static void hmac_update_frm(hmac_sha256_ctx *ctx, struct rpmb_data_frame *frm)
+{
+ hmac_sha256_update(ctx, CUC(frm->data), 256);
+ hmac_sha256_update(ctx, CUC(frm->nonce), 16);
+ hmac_sha256_update(ctx, CUC(&frm->write_counter), 4);
+ hmac_sha256_update(ctx, CUC(&frm->address), 2);
+ hmac_sha256_update(ctx, CUC(&frm->block_count), 2);
+ hmac_sha256_update(ctx, CUC(&frm->op_result), 2);
+ hmac_sha256_update(ctx, CUC(&frm->msg_type), 2);
+}
+
+static bool is_hmac_valid(struct rpmb_emu *mem, struct rpmb_data_frame *frm,
+ size_t nfrm)
+{
+ uint8_t mac[32] = { 0 };
+ size_t i = 0;
+ hmac_sha256_ctx ctx;
+
+ memset(&ctx, 0, sizeof(ctx));
+
+ if (!mem->key_set) {
+ EMSG("Cannot check MAC (key not set)");
+ return false;
+ }
+
+ hmac_sha256_init(&ctx, mem->key, sizeof(mem->key));
+ for (i = 0; i < nfrm; i++, frm++)
+ hmac_update_frm(&ctx, frm);
+ frm--;
+ hmac_sha256_final(&ctx, mac, 32);
+
+ if (memcmp(mac, frm->key_mac, 32)) {
+ EMSG("Invalid MAC");
+ return false;
+ }
+ return true;
+}
+
+static uint16_t gen_msb1st_result(uint8_t byte)
+{
+ return (uint16_t)byte << 8;
+}
+
+static uint16_t compute_hmac(struct rpmb_emu *mem, struct rpmb_data_frame *frm,
+ size_t nfrm)
+{
+ size_t i = 0;
+ hmac_sha256_ctx ctx;
+
+ memset(&ctx, 0, sizeof(ctx));
+
+ if (!mem->key_set) {
+ EMSG("Cannot compute MAC (key not set)");
+ return gen_msb1st_result(RPMB_RESULT_AUTH_KEY_NOT_PROGRAMMED);
+ }
+
+ hmac_sha256_init(&ctx, mem->key, sizeof(mem->key));
+ for (i = 0; i < nfrm; i++, frm++)
+ hmac_update_frm(&ctx, frm);
+ frm--;
+ hmac_sha256_final(&ctx, frm->key_mac, 32);
+
+ return gen_msb1st_result(RPMB_RESULT_OK);
+}
+
+static uint16_t ioctl_emu_mem_transfer(struct rpmb_emu *mem,
+ struct rpmb_data_frame *frm,
+ size_t nfrm, int to_mmc)
+{
+ size_t start = mem->last_op.address * 256;
+ size_t size = nfrm * 256;
+ size_t i = 0;
+ uint8_t *memptr = NULL;
+
+ if (start > mem->size || start + size > mem->size) {
+ EMSG("Transfer bounds exceeed emulated memory");
+ return gen_msb1st_result(RPMB_RESULT_ADDRESS_FAILURE);
+ }
+ if (to_mmc && !is_hmac_valid(mem, frm, nfrm))
+ return gen_msb1st_result(RPMB_RESULT_AUTH_FAILURE);
+
+ DMSG("Transferring %zu 256-byte data block%s %s MMC (block offset=%zu)",
+ nfrm, (nfrm > 1) ? "s" : "", to_mmc ? "to" : "from", start / 256);
+ for (i = 0; i < nfrm; i++) {
+ memptr = mem->buf + start + i * 256;
+ if (to_mmc) {
+ memcpy(memptr, frm[i].data, 256);
+ mem->write_counter++;
+ frm[i].write_counter = htonl(mem->write_counter);
+ frm[i].msg_type =
+ htons(RPMB_MSG_TYPE_RESP_AUTH_DATA_WRITE);
+ } else {
+ memcpy(frm[i].data, memptr, 256);
+ frm[i].msg_type =
+ htons(RPMB_MSG_TYPE_RESP_AUTH_DATA_READ);
+ frm[i].address = htons(mem->last_op.address);
+ frm[i].block_count = nfrm;
+ memcpy(frm[i].nonce, mem->nonce, 16);
+ }
+ frm[i].op_result = gen_msb1st_result(RPMB_RESULT_OK);
+ }
+ dump_blocks(mem->last_op.address, nfrm, mem->buf + start, to_mmc);
+
+ if (!to_mmc)
+ compute_hmac(mem, frm, nfrm);
+
+ return gen_msb1st_result(RPMB_RESULT_OK);
+}
+
+static void ioctl_emu_get_write_result(struct rpmb_emu *mem,
+ struct rpmb_data_frame *frm)
+{
+ frm->msg_type = htons(RPMB_MSG_TYPE_RESP_AUTH_DATA_WRITE);
+ frm->op_result = mem->last_op.op_result;
+ frm->address = htons(mem->last_op.address);
+ frm->write_counter = htonl(mem->write_counter);
+ compute_hmac(mem, frm, 1);
+}
+
+static uint16_t ioctl_emu_setkey(struct rpmb_emu *mem,
+ struct rpmb_data_frame *frm)
+{
+ if (mem->key_set) {
+ EMSG("Key already set");
+ return gen_msb1st_result(RPMB_RESULT_GENERAL_FAILURE);
+ }
+ dump_buffer("Setting key", frm->key_mac, 32);
+ memcpy(mem->key, frm->key_mac, 32);
+ mem->key_set = true;
+
+ return gen_msb1st_result(RPMB_RESULT_OK);
+}
+
+static void ioctl_emu_get_keyprog_result(struct rpmb_emu *mem,
+ struct rpmb_data_frame *frm)
+{
+ frm->msg_type =
+ htons(RPMB_MSG_TYPE_RESP_AUTH_KEY_PROGRAM);
+ frm->op_result = mem->last_op.op_result;
+}
+
+static void ioctl_emu_read_ctr(struct rpmb_emu *mem,
+ struct rpmb_data_frame *frm)
+{
+ DMSG("Reading counter");
+ frm->msg_type = htons(RPMB_MSG_TYPE_RESP_WRITE_COUNTER_VAL_READ);
+ frm->write_counter = htonl(mem->write_counter);
+ memcpy(frm->nonce, mem->nonce, 16);
+ frm->op_result = compute_hmac(mem, frm, 1);
+}
+
+static uint32_t read_cid(uint16_t dev_id, uint8_t *cid)
+{
+ /* Taken from an actual eMMC chip */
+ static const uint8_t test_cid[] = {
+ /* MID (Manufacturer ID): Micron */
+ 0xfe,
+ /* CBX (Device/BGA): BGA */
+ 0x01,
+ /* OID (OEM/Application ID) */
+ 0x4e,
+ /* PNM (Product name) "MMC04G" */
+ 0x4d, 0x4d, 0x43, 0x30, 0x34, 0x47,
+ /* PRV (Product revision): 4.2 */
+ 0x42,
+ /* PSN (Product serial number) */
+ 0xc8, 0xf6, 0x55, 0x2a,
+ /*
+ * MDT (Manufacturing date):
+ * June, 2014
+ */
+ 0x61,
+ /* (CRC7 (0xA) << 1) | 0x1 */
+ 0x15
+ };
+
+ (void)dev_id;
+ memcpy(cid, test_cid, sizeof(test_cid));
+
+ return TEEC_SUCCESS;
+}
+
+static void ioctl_emu_set_ext_csd(uint8_t *ext_csd)
+{
+ ext_csd[168] = EMU_RPMB_SIZE_MULT;
+ ext_csd[222] = EMU_RPMB_REL_WR_SEC_C;
+}
+
+/* A crude emulation of the MMC ioctls we need for RPMB */
+static int ioctl_emu(int fd, unsigned long request, ...)
+{
+ struct mmc_ioc_cmd *cmd = NULL;
+ struct rpmb_data_frame *frm = NULL;
+ uint16_t msg_type = 0;
+ struct rpmb_emu *mem = mem_for_fd(fd);
+ va_list ap;
+
+ if (request != MMC_IOC_CMD) {
+ EMSG("Unsupported ioctl: 0x%lx", request);
+ return -1;
+ }
+ if (!mem)
+ return -1;
+
+ va_start(ap, request);
+ cmd = va_arg(ap, struct mmc_ioc_cmd *);
+ va_end(ap);
+
+ switch (cmd->opcode) {
+ case MMC_SEND_EXT_CSD:
+ ioctl_emu_set_ext_csd((uint8_t *)(uintptr_t)cmd->data_ptr);
+ break;
+
+ case MMC_WRITE_MULTIPLE_BLOCK:
+ frm = (struct rpmb_data_frame *)(uintptr_t)cmd->data_ptr;
+ msg_type = ntohs(frm->msg_type);
+
+ switch (msg_type) {
+ case RPMB_MSG_TYPE_REQ_AUTH_KEY_PROGRAM:
+ mem->last_op.msg_type = msg_type;
+ mem->last_op.op_result = ioctl_emu_setkey(mem, frm);
+ break;
+
+ case RPMB_MSG_TYPE_REQ_AUTH_DATA_WRITE:
+ mem->last_op.msg_type = msg_type;
+ mem->last_op.address = ntohs(frm->address);
+ mem->last_op.op_result =
+ ioctl_emu_mem_transfer(mem, frm,
+ cmd->blocks, 1);
+ break;
+
+ case RPMB_MSG_TYPE_REQ_WRITE_COUNTER_VAL_READ:
+ case RPMB_MSG_TYPE_REQ_AUTH_DATA_READ:
+ memcpy(mem->nonce, frm->nonce, 16);
+ mem->last_op.msg_type = msg_type;
+ mem->last_op.address = ntohs(frm->address);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case MMC_READ_MULTIPLE_BLOCK:
+ frm = (struct rpmb_data_frame *)(uintptr_t)cmd->data_ptr;
+ msg_type = ntohs(frm->msg_type);
+
+ switch (mem->last_op.msg_type) {
+ case RPMB_MSG_TYPE_REQ_AUTH_KEY_PROGRAM:
+ ioctl_emu_get_keyprog_result(mem, frm);
+ break;
+
+ case RPMB_MSG_TYPE_REQ_AUTH_DATA_WRITE:
+ ioctl_emu_get_write_result(mem, frm);
+ break;
+
+ case RPMB_MSG_TYPE_REQ_WRITE_COUNTER_VAL_READ:
+ ioctl_emu_read_ctr(mem, frm);
+ break;
+
+ case RPMB_MSG_TYPE_REQ_AUTH_DATA_READ:
+ ioctl_emu_mem_transfer(mem, frm, cmd->blocks, 0);
+ break;
+
+ default:
+ EMSG("Unexpected");
+ break;
+ }
+ break;
+
+ default:
+ EMSG("Unsupported ioctl opcode 0x%08x", cmd->opcode);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int mmc_rpmb_fd(uint16_t dev_id)
+{
+ (void)dev_id;
+
+ /* Any value != -1 will do in test mode */
+ return 0;
+}
+
+static int mmc_fd(uint16_t dev_id)
+{
+ (void)dev_id;
+
+ return 0;
+}
+
+static void close_mmc_fd(int fd)
+{
+ (void)fd;
+}
+
+#endif /* RPMB_EMU */
+
+/*
+ * Extended CSD Register is 512 bytes and defines device properties
+ * and selected modes.
+ */
+static uint32_t read_ext_csd(int fd, uint8_t *ext_csd)
+{
+ int st = 0;
+ struct mmc_ioc_cmd cmd = {
+ .blksz = 512,
+ .blocks = 1,
+ .flags = MMC_RSP_R1 | MMC_CMD_ADTC,
+ .opcode = MMC_SEND_EXT_CSD,
+ };
+
+ mmc_ioc_cmd_set_data(cmd, ext_csd);
+
+ st = IOCTL(fd, MMC_IOC_CMD, &cmd);
+ if (st < 0)
+ return TEEC_ERROR_GENERIC;
+
+ return TEEC_SUCCESS;
+}
+
+static uint32_t rpmb_data_req(int fd, struct rpmb_data_frame *req_frm,
+ size_t req_nfrm, struct rpmb_data_frame *rsp_frm,
+ size_t rsp_nfrm)
+{
+ int st = 0;
+ size_t i = 0;
+ uint16_t msg_type = ntohs(req_frm->msg_type);
+ struct mmc_ioc_cmd cmd = {
+ .blksz = 512,
+ .blocks = req_nfrm,
+ .data_ptr = (uintptr_t)req_frm,
+ .flags = MMC_RSP_R1 | MMC_CMD_ADTC,
+ .opcode = MMC_WRITE_MULTIPLE_BLOCK,
+ .write_flag = 1,
+ };
+
+ for (i = 1; i < req_nfrm; i++) {
+ if (req_frm[i].msg_type != msg_type) {
+ EMSG("All request frames shall be of the same type");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ }
+
+ DMSG("Req: %zu frame(s) of type 0x%04x", req_nfrm, msg_type);
+ DMSG("Rsp: %zu frame(s)", rsp_nfrm);
+
+ switch(msg_type) {
+ case RPMB_MSG_TYPE_REQ_AUTH_KEY_PROGRAM:
+ case RPMB_MSG_TYPE_REQ_AUTH_DATA_WRITE:
+ if (rsp_nfrm != 1) {
+ EMSG("Expected only one response frame");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ /* Send write request frame(s) */
+ cmd.write_flag |= MMC_CMD23_ARG_REL_WR;
+ /*
+ * Black magic: tested on a HiKey board with a HardKernel eMMC
+ * module. When postsleep values are zero, the kernel logs
+ * random errors: "mmc_blk_ioctl_cmd: Card Status=0x00000E00"
+ * and ioctl() fails.
+ */
+ cmd.postsleep_min_us = 20000;
+ cmd.postsleep_max_us = 50000;
+ st = IOCTL(fd, MMC_IOC_CMD, &cmd);
+ if (st < 0)
+ return TEEC_ERROR_GENERIC;
+ cmd.postsleep_min_us = 0;
+ cmd.postsleep_max_us = 0;
+
+ /* Send result request frame */
+ memset(rsp_frm, 0, 1);
+ rsp_frm->msg_type = htons(RPMB_MSG_TYPE_REQ_RESULT_READ);
+ cmd.data_ptr = (uintptr_t)rsp_frm;
+ cmd.write_flag &= ~MMC_CMD23_ARG_REL_WR;
+ st = IOCTL(fd, MMC_IOC_CMD, &cmd);
+ if (st < 0)
+ return TEEC_ERROR_GENERIC;
+
+ /* Read response frame */
+ cmd.opcode = MMC_READ_MULTIPLE_BLOCK;
+ cmd.write_flag = 0;
+ cmd.blocks = rsp_nfrm;
+ st = IOCTL(fd, MMC_IOC_CMD, &cmd);
+ if (st < 0)
+ return TEEC_ERROR_GENERIC;
+ break;
+
+ case RPMB_MSG_TYPE_REQ_WRITE_COUNTER_VAL_READ:
+ if (rsp_nfrm != 1) {
+ EMSG("Expected only one response frame");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+#if __GNUC__ > 6
+ __attribute__((fallthrough));
+#endif
+
+ case RPMB_MSG_TYPE_REQ_AUTH_DATA_READ:
+ if (req_nfrm != 1) {
+ EMSG("Expected only one request frame");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ /* Send request frame */
+ st = IOCTL(fd, MMC_IOC_CMD, &cmd);
+ if (st < 0)
+ return TEEC_ERROR_GENERIC;
+
+ /* Read response frames */
+ cmd.data_ptr = (uintptr_t)rsp_frm;
+ cmd.opcode = MMC_READ_MULTIPLE_BLOCK;
+ cmd.write_flag = 0;
+ cmd.blocks = rsp_nfrm;
+ st = IOCTL(fd, MMC_IOC_CMD, &cmd);
+ if (st < 0)
+ return TEEC_ERROR_GENERIC;
+ break;
+
+ default:
+ EMSG("Unsupported message type: %d", msg_type);
+ return TEEC_ERROR_GENERIC;
+ }
+
+ return TEEC_SUCCESS;
+}
+
+static uint32_t rpmb_get_dev_info(uint16_t dev_id, struct rpmb_dev_info *info)
+{
+ int fd = 0;
+ uint32_t res = 0;
+ uint8_t ext_csd[512] = { 0 };
+
+ res = read_cid(dev_id, info->cid);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ fd = mmc_fd(dev_id);
+ if (fd < 0)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ res = read_ext_csd(fd, ext_csd);
+ if (res != TEEC_SUCCESS)
+ goto err;
+
+ info->rel_wr_sec_c = ext_csd[222];
+ info->rpmb_size_mult = ext_csd[168];
+ info->ret_code = RPMB_CMD_GET_DEV_INFO_RET_OK;
+
+err:
+ close_mmc_fd(fd);
+ return res;
+}
+
+
+/*
+ * req is one struct rpmb_req followed by one or more struct rpmb_data_frame
+ * rsp is either one struct rpmb_dev_info or one or more struct rpmb_data_frame
+ */
+static uint32_t rpmb_process_request_unlocked(void *req, size_t req_size,
+ void *rsp, size_t rsp_size)
+{
+ struct rpmb_req *sreq = req;
+ size_t req_nfrm = 0;
+ size_t rsp_nfrm = 0;
+ uint32_t res = 0;
+ int fd = 0;
+
+ if (req_size < sizeof(*sreq))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ switch (sreq->cmd) {
+ case RPMB_CMD_DATA_REQ:
+ req_nfrm = (req_size - sizeof(struct rpmb_req)) / 512;
+ rsp_nfrm = rsp_size / 512;
+ fd = mmc_rpmb_fd(sreq->dev_id);
+ if (fd < 0)
+ return TEEC_ERROR_BAD_PARAMETERS;
+ res = rpmb_data_req(fd, RPMB_REQ_DATA(req), req_nfrm, rsp,
+ rsp_nfrm);
+ break;
+
+ case RPMB_CMD_GET_DEV_INFO:
+ if (req_size != sizeof(struct rpmb_req) ||
+ rsp_size != sizeof(struct rpmb_dev_info)) {
+ EMSG("Invalid req/rsp size");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ res = rpmb_get_dev_info(sreq->dev_id,
+ (struct rpmb_dev_info *)rsp);
+ break;
+
+ default:
+ EMSG("Unsupported RPMB command: %d", sreq->cmd);
+ res = TEEC_ERROR_BAD_PARAMETERS;
+ break;
+ }
+
+ return res;
+}
+
+
+uint32_t rpmb_process_request(void *req, size_t req_size, void *rsp,
+ size_t rsp_size)
+{
+ uint32_t res = 0;
+
+ tee_supp_mutex_lock(&rpmb_mutex);
+ res = rpmb_process_request_unlocked(req, req_size, rsp, rsp_size);
+ tee_supp_mutex_unlock(&rpmb_mutex);
+
+ return res;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/rpmb.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/rpmb.h
new file mode 100755
index 0000000..feeed5b
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/rpmb.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RPMB_H
+#define RPMB_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+uint32_t rpmb_process_request(void *req, size_t req_size, void *rsp,
+ size_t rsp_size);
+
+#endif /* RPMB_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/sha2.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/sha2.c
new file mode 100755
index 0000000..b884033
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/sha2.c
@@ -0,0 +1,249 @@
+/*
+ * FIPS 180-2 SHA-224/256/384/512 implementation
+ * Last update: 02/02/2007
+ * Issue date: 04/30/2005
+ *
+ * Copyright (C) 2005, 2007 Olivier Gay <olivier.gay@a3.epfl.ch>
+ * All rights reserved.
+ *
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include "sha2.h"
+
+#define SHFR(x, n) (x >> n)
+#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
+#define ROTL(x, n) ((x << n) | (x >> ((sizeof(x) << 3) - n)))
+#define CH(x, y, z) ((x & y) ^ (~x & z))
+#define MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
+
+#define SHA256_F1(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
+#define SHA256_F2(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
+#define SHA256_F3(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3))
+#define SHA256_F4(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10))
+
+#define UNPACK32(x, str) \
+{ \
+ *((str) + 3) = (uint8) ((x) ); \
+ *((str) + 2) = (uint8) ((x) >> 8); \
+ *((str) + 1) = (uint8) ((x) >> 16); \
+ *((str) + 0) = (uint8) ((x) >> 24); \
+}
+
+#define PACK32(str, x) \
+{ \
+ *(x) = ((uint32) *((str) + 3) ) \
+ | ((uint32) *((str) + 2) << 8) \
+ | ((uint32) *((str) + 1) << 16) \
+ | ((uint32) *((str) + 0) << 24); \
+}
+
+#define UNPACK64(x, str) \
+{ \
+ *((str) + 7) = (uint8) ((x) ); \
+ *((str) + 6) = (uint8) ((x) >> 8); \
+ *((str) + 5) = (uint8) ((x) >> 16); \
+ *((str) + 4) = (uint8) ((x) >> 24); \
+ *((str) + 3) = (uint8) ((x) >> 32); \
+ *((str) + 2) = (uint8) ((x) >> 40); \
+ *((str) + 1) = (uint8) ((x) >> 48); \
+ *((str) + 0) = (uint8) ((x) >> 56); \
+}
+
+#define PACK64(str, x) \
+{ \
+ *(x) = ((uint64) *((str) + 7) ) \
+ | ((uint64) *((str) + 6) << 8) \
+ | ((uint64) *((str) + 5) << 16) \
+ | ((uint64) *((str) + 4) << 24) \
+ | ((uint64) *((str) + 3) << 32) \
+ | ((uint64) *((str) + 2) << 40) \
+ | ((uint64) *((str) + 1) << 48) \
+ | ((uint64) *((str) + 0) << 56); \
+}
+
+#define SHA256_SCR(i) \
+{ \
+ w[i] = SHA256_F4(w[i - 2]) + w[i - 7] \
+ + SHA256_F3(w[i - 15]) + w[i - 16]; \
+}
+
+uint32 sha256_h0[8] =
+ {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
+ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
+
+uint32 sha256_k[64] =
+ {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
+
+/* SHA-256 functions */
+
+static void sha256_transf(sha256_ctx *ctx, const unsigned char *message,
+ unsigned int block_nb)
+{
+ uint32 w[64] = { 0 };
+ uint32 wv[8] = { 0 };
+ uint32 t1 = 0;
+ uint32 t2 = 0;
+ const unsigned char *sub_block = NULL;
+ int i = 0;
+ int j = 0;
+
+ for (i = 0; i < (int) block_nb; i++) {
+ sub_block = message + (i << 6);
+
+ for (j = 0; j < 16; j++) {
+ PACK32(&sub_block[j << 2], &w[j]);
+ }
+
+ for (j = 16; j < 64; j++) {
+ SHA256_SCR(j);
+ }
+
+ for (j = 0; j < 8; j++) {
+ wv[j] = ctx->h[j];
+ }
+
+ for (j = 0; j < 64; j++) {
+ t1 = wv[7] + SHA256_F2(wv[4]) + CH(wv[4], wv[5], wv[6])
+ + sha256_k[j] + w[j];
+ t2 = SHA256_F1(wv[0]) + MAJ(wv[0], wv[1], wv[2]);
+ wv[7] = wv[6];
+ wv[6] = wv[5];
+ wv[5] = wv[4];
+ wv[4] = wv[3] + t1;
+ wv[3] = wv[2];
+ wv[2] = wv[1];
+ wv[1] = wv[0];
+ wv[0] = t1 + t2;
+ }
+
+ for (j = 0; j < 8; j++) {
+ ctx->h[j] += wv[j];
+ }
+ }
+}
+
+void sha256(const unsigned char *message, unsigned int len,
+ unsigned char *digest)
+{
+ sha256_ctx ctx;
+
+ memset(&ctx, 0, sizeof(ctx));
+
+ sha256_init(&ctx);
+ sha256_update(&ctx, message, len);
+ sha256_final(&ctx, digest);
+}
+
+void sha256_init(sha256_ctx *ctx)
+{
+ int i = 0;
+
+ for (i = 0; i < 8; i++) {
+ ctx->h[i] = sha256_h0[i];
+ }
+
+ ctx->len = 0;
+ ctx->tot_len = 0;
+}
+
+void sha256_update(sha256_ctx *ctx, const unsigned char *message,
+ unsigned int len)
+{
+ unsigned int block_nb = 0;
+ unsigned int new_len = 0;
+ unsigned int rem_len = 0;
+ unsigned int tmp_len = 0;
+ const unsigned char *shifted_message = NULL;
+
+ tmp_len = SHA256_BLOCK_SIZE - ctx->len;
+ rem_len = len < tmp_len ? len : tmp_len;
+
+ memcpy(&ctx->block[ctx->len], message, rem_len);
+
+ if (ctx->len + len < SHA256_BLOCK_SIZE) {
+ ctx->len += len;
+ return;
+ }
+
+ new_len = len - rem_len;
+ block_nb = new_len / SHA256_BLOCK_SIZE;
+
+ shifted_message = message + rem_len;
+
+ sha256_transf(ctx, ctx->block, 1);
+ sha256_transf(ctx, shifted_message, block_nb);
+
+ rem_len = new_len % SHA256_BLOCK_SIZE;
+
+ memcpy(ctx->block, &shifted_message[block_nb << 6],
+ rem_len);
+
+ ctx->len = rem_len;
+ ctx->tot_len += (block_nb + 1) << 6;
+}
+
+void sha256_final(sha256_ctx *ctx, unsigned char *digest)
+{
+ unsigned int block_nb = 0;
+ unsigned int pm_len = 0;
+ unsigned int len_b = 0;
+ int i = 0;
+
+ block_nb = (1 + ((SHA256_BLOCK_SIZE - 9)
+ < (ctx->len % SHA256_BLOCK_SIZE)));
+
+ len_b = (ctx->tot_len + ctx->len) << 3;
+ pm_len = block_nb << 6;
+
+ memset(ctx->block + ctx->len, 0, pm_len - ctx->len);
+ ctx->block[ctx->len] = 0x80;
+ UNPACK32(len_b, ctx->block + pm_len - 4);
+
+ sha256_transf(ctx, ctx->block, block_nb);
+
+ for (i = 0 ; i < 8; i++) {
+ UNPACK32(ctx->h[i], &digest[i << 2]);
+ }
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/sha2.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/sha2.h
new file mode 100755
index 0000000..3a17fae
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/sha2.h
@@ -0,0 +1,75 @@
+/*
+ * FIPS 180-2 SHA-224/256/384/512 implementation
+ * Last update: 02/02/2007
+ * Issue date: 04/30/2005
+ *
+ * Copyright (C) 2005, 2007 Olivier Gay <olivier.gay@a3.epfl.ch>
+ * All rights reserved.
+ *
+ * Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef SHA2_H
+#define SHA2_H
+
+#define SHA256_DIGEST_SIZE ( 256 / 8)
+#define SHA256_BLOCK_SIZE ( 512 / 8)
+
+#ifndef SHA2_TYPES
+#define SHA2_TYPES
+typedef unsigned char uint8;
+typedef unsigned int uint32;
+typedef unsigned long long uint64;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ unsigned int tot_len;
+ unsigned int len;
+ unsigned char block[2 * SHA256_BLOCK_SIZE];
+ uint32 h[8];
+} sha256_ctx;
+
+typedef sha256_ctx sha224_ctx;
+
+void sha256_init(sha256_ctx * ctx);
+void sha256_update(sha256_ctx *ctx, const unsigned char *message,
+ unsigned int len);
+void sha256_final(sha256_ctx *ctx, unsigned char *digest);
+void sha256(const unsigned char *message, unsigned int len,
+ unsigned char *digest);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !SHA2_H */
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_socket.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_socket.c
new file mode 100755
index 0000000..41d71b1
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_socket.c
@@ -0,0 +1,746 @@
+/*
+ * Copyright (c) 2016-2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <optee_msg_supplicant.h>
+#include <poll.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/queue.h>
+#include <sys/socket.h>
+#include <tee_client_api.h>
+#include <teec_trace.h>
+#include <tee_socket.h>
+#include <tee_supplicant.h>
+#include <unistd.h>
+
+#include "handle.h"
+#include "__tee_isocket_defines.h"
+#include "__tee_ipsocket.h"
+#include "__tee_tcpsocket_defines.h"
+#include "__tee_tcpsocket_defines_extensions.h"
+#include "__tee_udpsocket_defines.h"
+
+#ifndef __aligned
+#define __aligned(x) __attribute__((__aligned__(x)))
+#endif
+#include <linux/tee.h>
+
+
+struct sock_instance {
+ uint32_t id;
+ struct handle_db db;
+ TAILQ_ENTRY(sock_instance) link;
+};
+
+static pthread_mutex_t sock_mutex = PTHREAD_MUTEX_INITIALIZER;
+TAILQ_HEAD(, sock_instance) sock_instances =
+ TAILQ_HEAD_INITIALIZER(sock_instances);
+
+static void sock_lock(void)
+{
+ pthread_mutex_lock(&sock_mutex);
+}
+
+static void sock_unlock(void)
+{
+ pthread_mutex_unlock(&sock_mutex);
+}
+
+static struct sock_instance *sock_instance_find(uint32_t instance_id)
+{
+ struct sock_instance *si = NULL;
+
+ TAILQ_FOREACH(si, &sock_instances, link) {
+ if (si->id == instance_id)
+ return si;
+ }
+ return NULL;
+}
+
+static void *fd_to_handle_ptr(int fd)
+{
+ uintptr_t ptr = 0;
+
+ assert(fd >= 0);
+ ptr = fd + 1;
+ return (void *)ptr;
+}
+
+static int handle_ptr_to_fd(void *ptr)
+{
+ assert(ptr);
+ return (uintptr_t)ptr - 1;
+}
+
+static int sock_handle_get(uint32_t instance_id, int fd)
+{
+ int handle = -1;
+ struct sock_instance *si = NULL;
+
+ sock_lock();
+
+ si = sock_instance_find(instance_id);
+ if (!si) {
+ si = calloc(1, sizeof(*si));
+ if (!si)
+ goto out;
+ si->id = instance_id;
+ TAILQ_INSERT_TAIL(&sock_instances, si, link);
+ }
+
+ handle = handle_get(&si->db, fd_to_handle_ptr(fd));
+out:
+ sock_unlock();
+ return handle;
+}
+
+static int sock_handle_to_fd(uint32_t instance_id, uint32_t handle)
+{
+ int fd = -1;
+ struct sock_instance *si = NULL;
+
+ sock_lock();
+ si = sock_instance_find(instance_id);
+ if (si)
+ fd = handle_ptr_to_fd(handle_lookup(&si->db, handle));
+ sock_unlock();
+ return fd;
+}
+
+static void sock_handle_put(uint32_t instance_id, uint32_t handle)
+{
+ struct sock_instance *si = NULL;
+
+ sock_lock();
+ si = sock_instance_find(instance_id);
+ if (si)
+ handle_put(&si->db, handle);
+ sock_unlock();
+}
+
+static bool chk_pt(struct tee_ioctl_param *param, uint32_t type)
+{
+ return (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) == type;
+}
+
+static int fd_flags_add(int fd, int flags)
+{
+ int val = 0;
+
+ val = fcntl(fd, F_GETFD, 0);
+ if (val == -1)
+ return -1;
+
+ val |= flags;
+
+ return fcntl(fd, F_SETFL, val);
+}
+
+static TEEC_Result sock_connect(uint32_t ip_vers, unsigned int protocol,
+ const char *server, uint16_t port, int *ret_fd)
+{
+ TEEC_Result r = TEEC_ERROR_GENERIC;
+ struct addrinfo *res0 = NULL;
+ struct addrinfo *res = NULL;
+ int fd = -1;
+ char port_name[10] = { 0 };
+ struct addrinfo hints;
+
+ memset(&hints, 0, sizeof(hints));
+
+ snprintf(port_name, sizeof(port_name), "%" PRIu16, port);
+
+ switch (ip_vers) {
+ case TEE_IP_VERSION_DC:
+ hints.ai_family = AF_UNSPEC;
+ break;
+ case TEE_IP_VERSION_4:
+ hints.ai_family = AF_INET;
+ break;
+ case TEE_IP_VERSION_6:
+ hints.ai_family = AF_INET6;
+ break;
+ default:
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ if (protocol == TEE_ISOCKET_PROTOCOLID_TCP)
+ hints.ai_socktype = SOCK_STREAM;
+ else if (protocol == TEE_ISOCKET_PROTOCOLID_UDP)
+ hints.ai_socktype = SOCK_DGRAM;
+ else
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (getaddrinfo(server, port_name, &hints, &res0))
+ return TEE_ISOCKET_ERROR_HOSTNAME;
+
+ for (res = res0; res; res = res->ai_next) {
+ fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (fd == -1) {
+ if (errno == ENOMEM || errno == ENOBUFS)
+ r = TEE_ISOCKET_ERROR_OUT_OF_RESOURCES;
+ else
+ r = TEEC_ERROR_GENERIC;
+ continue;
+ }
+
+ if (connect(fd, res->ai_addr, res->ai_addrlen)) {
+ if (errno == ETIMEDOUT)
+ r = TEE_ISOCKET_ERROR_TIMEOUT;
+ else
+ r = TEEC_ERROR_COMMUNICATION;
+
+ close(fd);
+ fd = -1;
+ continue;
+ }
+
+ if (fd_flags_add(fd, O_NONBLOCK)) {
+ close(fd);
+ fd = -1;
+ r = TEEC_ERROR_GENERIC;
+ break;
+ }
+
+ r = TEEC_SUCCESS;
+ break;
+ }
+
+ freeaddrinfo(res0);
+ *ret_fd = fd;
+ return r;
+}
+
+static TEEC_Result tee_socket_open(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ int handle = 0;
+ int fd = 0;
+ uint32_t instance_id = 0;
+ char *server = NULL;
+ uint32_t ip_vers = 0;
+ uint16_t port = 0;
+ uint32_t protocol = 0;
+
+ if (num_params != 4 ||
+ !chk_pt(params + 0, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT) ||
+ !chk_pt(params + 1, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT) ||
+ !chk_pt(params + 2, TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT) ||
+ !chk_pt(params + 3, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ instance_id = params[0].u.value.b;
+ port = params[1].u.value.a;
+ protocol = params[1].u.value.b;
+ ip_vers = params[1].u.value.c;
+
+ server = tee_supp_param_to_va(params + 2);
+ if (!server || server[params[2].u.memref.size - 1] != '\0')
+ return TEE_ISOCKET_ERROR_HOSTNAME;
+
+ res = sock_connect(ip_vers, protocol, server, port, &fd);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ handle = sock_handle_get(instance_id, fd);
+ if (handle < 0) {
+ close(fd);
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ }
+
+ params[3].u.value.a = handle;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result tee_socket_close(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ int handle = 0;
+ uint32_t instance_id = 0;
+ int fd = 0;
+
+ if (num_params != 1 ||
+ !chk_pt(params + 0, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ instance_id = params[0].u.value.b;
+ handle = params[0].u.value.c;
+ fd = sock_handle_to_fd(instance_id, handle);
+ if (fd < 0)
+ return TEEC_ERROR_BAD_PARAMETERS;
+ sock_handle_put(instance_id, handle);
+ if (close(fd)) {
+ EMSG("tee_socket_close: close(%d): %s", fd, strerror(errno));
+ return TEEC_ERROR_GENERIC;
+ }
+ return TEEC_SUCCESS;
+}
+
+static void sock_close_cb(int handle, void *ptr, void *arg)
+{
+ struct sock_instance *si = arg;
+ int fd = handle_ptr_to_fd(ptr);
+
+ if (close(fd))
+ EMSG("sock_close_cb instance_id %d handle %d fd %d: %s",
+ si->id, handle, fd, strerror(errno));
+}
+
+static TEEC_Result tee_socket_close_all(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ uint32_t instance_id = 0;
+ struct sock_instance *si = NULL;
+
+ if (num_params != 1 ||
+ !chk_pt(params + 0, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ instance_id = params[0].u.value.b;
+ sock_lock();
+ si = sock_instance_find(instance_id);
+ if (si)
+ handle_foreach_put(&si->db, sock_close_cb, si);
+ sock_unlock();
+
+ return TEEC_SUCCESS;
+}
+
+#define TS_NSEC_PER_SEC 1000000000
+
+static void ts_add(const struct timespec *a, const struct timespec *b,
+ struct timespec *res)
+{
+ res->tv_sec = a->tv_sec + b->tv_sec;
+ res->tv_nsec = a->tv_nsec + b->tv_nsec;
+ if (res->tv_nsec >= TS_NSEC_PER_SEC) {
+ res->tv_sec++;
+ res->tv_nsec -= TS_NSEC_PER_SEC;
+ }
+}
+
+static int ts_diff_to_polltimeout(const struct timespec *a,
+ const struct timespec *b)
+{
+ struct timespec diff;
+
+ memset(&diff, 0, sizeof(diff));
+
+ diff.tv_sec = a->tv_sec - b->tv_sec;
+ diff.tv_nsec = a->tv_nsec - b->tv_nsec;
+ if (a->tv_nsec < b->tv_nsec) {
+ diff.tv_nsec += TS_NSEC_PER_SEC;
+ diff.tv_sec--;
+ }
+
+ if ((diff.tv_sec - 1) > (INT_MAX / 1000))
+ return INT_MAX;
+ return diff.tv_sec * 1000 + diff.tv_nsec / (TS_NSEC_PER_SEC / 1000);
+}
+
+static void ts_delay_from_millis(uint32_t millis, struct timespec *res)
+{
+ res->tv_sec = millis / 1000;
+ res->tv_nsec = (millis % 1000) * (TS_NSEC_PER_SEC / 1000);
+}
+
+static TEEC_Result poll_with_timeout(struct pollfd *pfd, nfds_t nfds,
+ uint32_t timeout)
+{
+ int to = 0;
+ int r = 0;
+ struct timespec now;
+ struct timespec until;
+
+ memset(&now, 0, sizeof(now));
+ memset(&until, 0, sizeof(until));
+
+ if (timeout == OPTEE_MRC_SOCKET_TIMEOUT_BLOCKING) {
+ to = -1;
+ } else {
+ struct timespec delay;
+
+ memset(&delay, 0, sizeof(delay));
+
+ ts_delay_from_millis(timeout, &delay);
+
+ if (clock_gettime(CLOCK_REALTIME, &now))
+ return TEEC_ERROR_GENERIC;
+
+ ts_add(&now, &delay, &until);
+ }
+
+ while (true) {
+ if (to != -1)
+ to = ts_diff_to_polltimeout(&until, &now);
+
+ r = poll(pfd, nfds, to);
+ if (!r)
+ return TEE_ISOCKET_ERROR_TIMEOUT;
+ if (r == -1) {
+ /*
+ * If we're interrupted by a signal treat
+ * recalculate the timeout (if needed) and wait
+ * again.
+ */
+ if (errno == EINTR) {
+ if (to != -1 &&
+ clock_gettime(CLOCK_REALTIME, &now))
+ return TEEC_ERROR_GENERIC;
+ continue;
+ }
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ return TEEC_SUCCESS;
+ }
+}
+
+static TEEC_Result write_with_timeout(int fd, const void *buf, size_t *blen,
+ uint32_t timeout)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ struct pollfd pfd = { .fd = fd, .events = POLLOUT };
+ ssize_t r = 0;
+
+ res = poll_with_timeout(&pfd, 1, timeout);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ r = write(fd, buf, *blen);
+ if (r == -1) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
+ return TEE_ISOCKET_ERROR_TIMEOUT;
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ *blen = r;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result tee_socket_send(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ int handle = 0;
+ int fd = 0;
+ uint32_t instance_id = 0;
+ void *buf = NULL;
+ size_t bytes = 0;
+
+ if (num_params != 3 ||
+ !chk_pt(params + 0, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT) ||
+ !chk_pt(params + 1, TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT) ||
+ !chk_pt(params + 2, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ instance_id = params[0].u.value.b;
+ handle = params[0].u.value.c;
+ fd = sock_handle_to_fd(instance_id, handle);
+ if (fd < 0)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ buf = tee_supp_param_to_va(params + 1);
+ bytes = params[1].u.memref.size;
+ res = write_with_timeout(fd, buf, &bytes, params[2].u.value.a);
+ if (res == TEEC_SUCCESS)
+ params[2].u.value.b = bytes;
+ return res;
+}
+
+static TEEC_Result read_with_timeout(int fd, void *buf, size_t *blen,
+ uint32_t timeout)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ struct pollfd pfd = { .fd = fd, .events = POLLIN };
+ ssize_t r = 0;
+
+ res = poll_with_timeout(&pfd, 1, timeout);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ r = read(fd, buf, *blen);
+ if (r == -1) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
+ return TEE_ISOCKET_ERROR_TIMEOUT;
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ *blen = r;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result tee_socket_recv(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ int handle = 0;
+ int fd = 0;
+ uint32_t instance_id = 0;
+ void *buf = NULL;
+ size_t bytes = 0;
+
+ if (num_params != 3 ||
+ !chk_pt(params + 0, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT) ||
+ !chk_pt(params + 1, TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT) ||
+ !chk_pt(params + 2, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ instance_id = params[0].u.value.b;
+ handle = params[0].u.value.c;
+ fd = sock_handle_to_fd(instance_id, handle);
+ if (fd < 0)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ buf = tee_supp_param_to_va(params + 1);
+
+ bytes = params[1].u.memref.size;
+ res = read_with_timeout(fd, buf, &bytes, params[2].u.value.a);
+ if (res == TEEC_SUCCESS)
+ params[1].u.memref.size = bytes;
+
+ return res;
+}
+
+static TEEC_Result tee_socket_ioctl_tcp(int fd, uint32_t command,
+ void *buf, size_t *blen)
+{
+ switch (command) {
+ case TEE_TCP_SET_RECVBUF:
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, buf, *blen))
+ return TEEC_ERROR_BAD_PARAMETERS;
+ return TEEC_SUCCESS;
+ case TEE_TCP_SET_SENDBUF:
+ if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, buf, *blen))
+ return TEEC_ERROR_BAD_PARAMETERS;
+ return TEEC_SUCCESS;
+ default:
+ return TEEC_ERROR_NOT_SUPPORTED;
+ }
+}
+
+static TEEC_Result sa_set_port(struct sockaddr *sa, socklen_t slen,
+ uint16_t port)
+{
+ if (sa->sa_family == AF_INET) {
+ struct sockaddr_in *sain = (void *)sa;
+
+ if (slen < (socklen_t)sizeof(*sain))
+ return TEEC_ERROR_BAD_PARAMETERS;
+ sain->sin_port = htons(port);
+
+ return TEEC_SUCCESS;
+ }
+
+ if (sa->sa_family == AF_INET6) {
+ struct sockaddr_in6 *sain6 = (void *)sa;
+
+ if (slen < (socklen_t)sizeof(*sain6))
+ return TEEC_ERROR_BAD_PARAMETERS;
+ sain6->sin6_port = htons(port);
+
+ return TEEC_SUCCESS;
+ }
+
+ return TEEC_ERROR_BAD_PARAMETERS;
+}
+
+static TEEC_Result sa_get_port(struct sockaddr *sa, socklen_t slen,
+ uint16_t *port)
+{
+ if (sa->sa_family == AF_INET) {
+ struct sockaddr_in *sain = (void *)sa;
+
+ if (slen < (socklen_t)sizeof(*sain))
+ return TEEC_ERROR_BAD_PARAMETERS;
+ *port = ntohs(sain->sin_port);
+
+ return TEEC_SUCCESS;
+ }
+
+ if (sa->sa_family == AF_INET6) {
+ struct sockaddr_in6 *sain6 = (void *)sa;
+
+ if (slen < (socklen_t)sizeof(*sain6))
+ return TEEC_ERROR_BAD_PARAMETERS;
+ *port = ntohs(sain6->sin6_port);
+
+ return TEEC_SUCCESS;
+ }
+
+ return TEEC_ERROR_BAD_PARAMETERS;
+}
+
+static TEEC_Result udp_changeaddr(int fd, int family, const char *server,
+ uint16_t port)
+{
+ TEEC_Result r = TEE_ISOCKET_ERROR_HOSTNAME;
+ struct addrinfo *res0 = NULL;
+ struct addrinfo *res = NULL;
+ char port_name[10] = { 0 };
+ struct addrinfo hints;
+
+ memset(&hints, 0, sizeof(hints));
+
+ snprintf(port_name, sizeof(port_name), "%" PRIu16, port);
+
+ hints.ai_family = family;
+ hints.ai_socktype = SOCK_DGRAM;
+ if (getaddrinfo(server, port_name, &hints, &res0))
+ return TEE_ISOCKET_ERROR_HOSTNAME;
+ for (res = res0; res; res = res->ai_next) {
+ if (connect(fd, res->ai_addr, res->ai_addrlen)) {
+ if (errno == ETIMEDOUT)
+ r = TEE_ISOCKET_ERROR_TIMEOUT;
+ else
+ r = TEEC_ERROR_COMMUNICATION;
+ continue;
+ }
+ r = TEEC_SUCCESS;
+ break;
+ }
+ freeaddrinfo(res0);
+
+ return r;
+}
+
+static TEEC_Result tee_socket_ioctl_udp(int fd, uint32_t command,
+ void *buf, size_t *blen)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ uint16_t port = 0;
+ struct sockaddr_storage sass;
+ struct sockaddr *sa = (struct sockaddr *)&sass;
+ socklen_t len = sizeof(sass);
+
+ memset(&sass, 0, sizeof(sass));
+
+ if (getpeername(fd, sa, &len))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ switch (command) {
+ case TEE_UDP_CHANGEADDR:
+ res = sa_get_port(sa, len, &port);
+ if (res != TEEC_SUCCESS)
+ return res;
+
+ if (!blen || *((char *)buf + *blen - 1) != '\0')
+ return TEE_ISOCKET_ERROR_HOSTNAME;
+
+ return udp_changeaddr(fd, sa->sa_family, buf, port);
+ case TEE_UDP_CHANGEPORT:
+ if (*blen != sizeof(port))
+ return TEEC_ERROR_BAD_PARAMETERS;
+ memcpy(&port, buf, sizeof(port));
+ res = sa_set_port(sa, len, port);
+ if (res != TEEC_SUCCESS)
+ return res;
+ if (connect(fd, sa, len))
+ return TEEC_ERROR_GENERIC;
+ return TEEC_SUCCESS;
+ default:
+ return TEEC_ERROR_NOT_SUPPORTED;
+ }
+}
+
+static TEEC_Result tee_socket_ioctl(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ TEEC_Result res = TEEC_ERROR_GENERIC;
+ int handle = 0;
+ int fd = 0;
+ uint32_t instance_id = 0;
+ uint32_t command = 0;
+ void *buf = NULL;
+ int socktype = 0;
+ socklen_t l = 0;
+ size_t sz = 0;
+
+ if (num_params != 3 ||
+ !chk_pt(params + 0, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT) ||
+ !chk_pt(params + 1, TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT) ||
+ !chk_pt(params + 2, TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ instance_id = params[0].u.value.b;
+ handle = params[0].u.value.c;
+ command = params[2].u.value.a;
+ fd = sock_handle_to_fd(instance_id, handle);
+ if (fd < 0)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ l = sizeof(socktype);
+ if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &socktype, &l))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ buf = tee_supp_param_to_va(params + 1);
+
+ switch (socktype) {
+ case SOCK_STREAM:
+ sz = params[1].u.memref.size;
+ res = tee_socket_ioctl_tcp(fd, command, buf, &sz);
+ params[1].u.memref.size = sz;
+ return res;
+ case SOCK_DGRAM:
+ sz = params[1].u.memref.size;
+ res = tee_socket_ioctl_udp(fd, command, buf, &sz);
+ params[1].u.memref.size = sz;
+ return res;
+ default:
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+}
+
+TEEC_Result tee_socket_process(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ if (!num_params || !tee_supp_param_is_value(params))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ switch (params->u.value.a) {
+ case OPTEE_MRC_SOCKET_OPEN:
+ return tee_socket_open(num_params, params);
+ case OPTEE_MRC_SOCKET_CLOSE:
+ return tee_socket_close(num_params, params);
+ case OPTEE_MRC_SOCKET_CLOSE_ALL:
+ return tee_socket_close_all(num_params, params);
+ case OPTEE_MRC_SOCKET_SEND:
+ return tee_socket_send(num_params, params);
+ case OPTEE_MRC_SOCKET_RECV:
+ return tee_socket_recv(num_params, params);
+ case OPTEE_MRC_SOCKET_IOCTL:
+ return tee_socket_ioctl(num_params, params);
+ default:
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_socket.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_socket.h
new file mode 100755
index 0000000..800c27c
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_socket.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016-2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __TEE_SOCKET_H
+#define __TEE_SOCKET_H
+
+#include <tee_client_api.h>
+
+struct tee_ioctl_param;
+
+#if defined(CFG_GP_SOCKETS) && CFG_GP_SOCKETS == 1
+TEEC_Result tee_socket_process(size_t num_params,
+ struct tee_ioctl_param *params);
+#else
+static inline TEEC_Result tee_socket_process(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ (void)num_params;
+ (void)params;
+
+ return TEEC_ERROR_NOT_SUPPORTED;
+}
+#endif
+
+#endif /*__SOCKET_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supp_fs.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supp_fs.c
new file mode 100755
index 0000000..09ac81f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supp_fs.c
@@ -0,0 +1,648 @@
+/*
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <handle.h>
+#include <libgen.h>
+#include <optee_msg_supplicant.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <teec_trace.h>
+#include <tee_supp_fs.h>
+#include <tee_supplicant.h>
+#include <unistd.h>
+
+#ifndef __aligned
+#define __aligned(x) __attribute__((__aligned__(x)))
+#endif
+#include <linux/tee.h>
+
+#ifndef PATH_MAX
+#define PATH_MAX 255
+#endif
+
+/* Path to all secure storage files. */
+static char tee_fs_root[PATH_MAX];
+
+#define TEE_FS_FILENAME_MAX_LENGTH 150
+
+static pthread_mutex_t dir_handle_db_mutex = PTHREAD_MUTEX_INITIALIZER;
+static struct handle_db dir_handle_db =
+ HANDLE_DB_INITIALIZER_WITH_MUTEX(&dir_handle_db_mutex);
+
+static size_t tee_fs_get_absolute_filename(char *file, char *out,
+ size_t out_size)
+{
+ int s = 0;
+
+ if (!file || !out || (out_size <= strlen(tee_fs_root) + 1))
+ return 0;
+
+ s = snprintf(out, out_size, "%s%s", tee_fs_root, file);
+ if (s < 0 || (size_t)s >= out_size)
+ return 0;
+
+ /* Safe to cast since we have checked that sizes are OK */
+ return (size_t)s;
+}
+
+static int do_mkdir(const char *path, mode_t mode)
+{
+ struct stat st;
+
+ memset(&st, 0, sizeof(st));
+
+ if (mkdir(path, mode) != 0 && errno != EEXIST)
+ return -1;
+
+ if (stat(path, &st) != 0 && !S_ISDIR(st.st_mode))
+ return -1;
+
+ return 0;
+}
+
+static int mkpath(const char *path, mode_t mode)
+{
+ int status = 0;
+ char *subpath = strdup(path);
+ char *prev = subpath;
+ char *curr = NULL;
+
+ while (status == 0 && (curr = strchr(prev, '/')) != 0) {
+ /*
+ * Check for root or double slash
+ */
+ if (curr != prev) {
+ *curr = '\0';
+ status = do_mkdir(subpath, mode);
+ *curr = '/';
+ }
+ prev = curr + 1;
+ }
+ if (status == 0)
+ status = do_mkdir(path, mode);
+
+ free(subpath);
+ return status;
+}
+
+static int tee_supp_fs_init(void)
+{
+ size_t n = 0;
+ mode_t mode = 0700;
+
+ n = snprintf(tee_fs_root, sizeof(tee_fs_root), "%s", TEE_FS_PARENT_PATH);
+ if (n >= sizeof(tee_fs_root))
+ return -1;
+
+ if (mkpath(tee_fs_root, mode) != 0)
+ return -1;
+
+ return 0;
+}
+
+static int open_wrapper(const char *fname, int flags)
+{
+ int fd = 0;
+
+ while (true) {
+ fd = open(fname, flags | O_SYNC, 0600);
+ if (fd >= 0 || errno != EINTR)
+ return fd;
+ }
+}
+
+static TEEC_Result ree_fs_new_open(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ char abs_filename[PATH_MAX] = { 0 };
+ char *fname = NULL;
+ int fd = 0;
+
+ if (num_params != 3 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT ||
+ (params[2].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fname = tee_supp_param_to_va(params + 1);
+ if (!fname)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!tee_fs_get_absolute_filename(fname, abs_filename,
+ sizeof(abs_filename)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fd = open_wrapper(abs_filename, O_RDWR);
+ if (fd < 0) {
+ /*
+ * In case the problem is the filesystem is RO, retry with the
+ * open flags restricted to RO.
+ */
+ fd = open_wrapper(abs_filename, O_RDONLY);
+ if (fd < 0)
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+ }
+
+ params[2].u.value.a = fd;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_create(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ char abs_filename[PATH_MAX] = { 0 };
+ char abs_dir[PATH_MAX] = { 0 };
+ char *fname = NULL;
+ char *d = NULL;
+ int fd = 0;
+ const int flags = O_RDWR | O_CREAT | O_TRUNC;
+
+ if (num_params != 3 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT ||
+ (params[2].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fname = tee_supp_param_to_va(params + 1);
+ if (!fname)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!tee_fs_get_absolute_filename(fname, abs_filename,
+ sizeof(abs_filename)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fd = open_wrapper(abs_filename, flags);
+ if (fd >= 0)
+ goto out;
+ if (errno != ENOENT)
+ return TEEC_ERROR_GENERIC;
+
+ /* Directory for file missing, try make to it */
+ strncpy(abs_dir, abs_filename, sizeof(abs_dir));
+ abs_dir[sizeof(abs_dir) - 1] = '\0';
+ d = dirname(abs_dir);
+ if (!mkdir(d, 0700)) {
+ fd = open_wrapper(abs_filename, flags);
+ if (fd >= 0)
+ goto out;
+ /*
+ * The directory was made but the file could still not be
+ * created.
+ */
+ rmdir(d);
+ return TEEC_ERROR_GENERIC;
+ }
+ if (errno != ENOENT)
+ return TEEC_ERROR_GENERIC;
+
+ /* Parent directory for file missing, try to make it */
+ d = dirname(d);
+ if (mkdir(d, 0700))
+ return TEEC_ERROR_GENERIC;
+
+ /* Try to make directory for file again */
+ strncpy(abs_dir, abs_filename, sizeof(abs_dir));
+ abs_dir[sizeof(abs_dir) - 1] = '\0';
+ d = dirname(abs_dir);
+ if (mkdir(d, 0700)) {
+ d = dirname(d);
+ rmdir(d);
+ return TEEC_ERROR_GENERIC;
+ }
+
+ fd = open_wrapper(abs_filename, flags);
+ if (fd < 0) {
+ rmdir(d);
+ d = dirname(d);
+ rmdir(d);
+ return TEEC_ERROR_GENERIC;
+ }
+
+out:
+ params[2].u.value.a = fd;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_close(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ int fd = 0;
+
+ if (num_params != 1 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fd = params[0].u.value.b;
+ while (close(fd)) {
+ if (errno != EINTR)
+ return TEEC_ERROR_GENERIC;
+ }
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_read(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ uint8_t *buf = NULL;
+ size_t len = 0;
+ off_t offs = 0;
+ int fd = 0;
+ ssize_t r = 0;
+ size_t s = 0;
+
+ if (num_params != 2 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fd = params[0].u.value.b;
+ offs = params[0].u.value.c;
+
+ buf = tee_supp_param_to_va(params + 1);
+ if (!buf)
+ return TEEC_ERROR_BAD_PARAMETERS;
+ len = params[1].u.memref.size;
+
+ s = 0;
+ r = -1;
+ while (r && len) {
+ r = pread(fd, buf, len, offs);
+ if (r < 0) {
+ if (errno == EINTR)
+ continue;
+ return TEEC_ERROR_GENERIC;
+ }
+ assert((size_t)r <= len);
+ buf += r;
+ len -= r;
+ offs += r;
+ s += r;
+ }
+
+ params[1].u.memref.size = s;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_write(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ uint8_t *buf = NULL;
+ size_t len = 0;
+ off_t offs = 0;
+ int fd = 0;
+ ssize_t r = 0;
+
+ if (num_params != 2 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fd = params[0].u.value.b;
+ offs = params[0].u.value.c;
+
+ buf = tee_supp_param_to_va(params + 1);
+ if (!buf)
+ return TEEC_ERROR_BAD_PARAMETERS;
+ len = params[1].u.memref.size;
+
+ while (len) {
+ r = pwrite(fd, buf, len, offs);
+ if (r < 0) {
+ if (errno == EINTR)
+ continue;
+ return TEEC_ERROR_GENERIC;
+ }
+ assert((size_t)r <= len);
+ buf += r;
+ len -= r;
+ offs += r;
+ }
+
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_truncate(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ size_t len = 0;
+ int fd = 0;
+
+ if (num_params != 1 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fd = params[0].u.value.b;
+ len = params[0].u.value.c;
+
+ while (ftruncate(fd, len)) {
+ if (errno != EINTR)
+ return TEEC_ERROR_GENERIC;
+ }
+
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_remove(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ char abs_filename[PATH_MAX] = { 0 };
+ char *fname = NULL;
+ char *d = NULL;
+
+ if (num_params != 2 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fname = tee_supp_param_to_va(params + 1);
+ if (!fname)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!tee_fs_get_absolute_filename(fname, abs_filename,
+ sizeof(abs_filename)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (unlink(abs_filename)) {
+ if (errno == ENOENT)
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+ return TEEC_ERROR_GENERIC;
+ }
+
+ /* If a file is removed, maybe the directory can be removed to? */
+ d = dirname(abs_filename);
+ if (!rmdir(d)) {
+ /*
+ * If the directory was removed, maybe the parent directory
+ * can be removed too?
+ */
+ d = dirname(d);
+ rmdir(d);
+ }
+
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_rename(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ char old_abs_filename[PATH_MAX] = { 0 };
+ char new_abs_filename[PATH_MAX] = { 0 };
+ char *old_fname = NULL;
+ char *new_fname = NULL;
+ bool overwrite = false;
+
+ if (num_params != 3 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT ||
+ (params[2].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ overwrite = !!params[0].u.value.b;
+
+ old_fname = tee_supp_param_to_va(params + 1);
+ if (!old_fname)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ new_fname = tee_supp_param_to_va(params + 2);
+ if (!new_fname)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!tee_fs_get_absolute_filename(old_fname, old_abs_filename,
+ sizeof(old_abs_filename)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!tee_fs_get_absolute_filename(new_fname, new_abs_filename,
+ sizeof(new_abs_filename)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!overwrite) {
+ struct stat st;
+
+ if (!stat(new_abs_filename, &st))
+ return TEEC_ERROR_ACCESS_CONFLICT;
+ }
+ if (rename(old_abs_filename, new_abs_filename)) {
+ if (errno == ENOENT)
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+ }
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_opendir(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ char abs_filename[PATH_MAX] = { 0 };
+ char *fname = NULL;
+ DIR *dir = NULL;
+ int handle = 0;
+ struct dirent *dent = NULL;
+ bool empty = true;
+
+ if (num_params != 3 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT ||
+ (params[2].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ fname = tee_supp_param_to_va(params + 1);
+ if (!fname)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (!tee_fs_get_absolute_filename(fname, abs_filename,
+ sizeof(abs_filename)))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ dir = opendir(abs_filename);
+ if (!dir)
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+
+ /*
+ * Ignore empty directories. Works around an issue when the
+ * data path is mounted over NFS. Due to the way OP-TEE implements
+ * TEE_CloseAndDeletePersistentObject1() currently, tee-supplicant
+ * still has a file descriptor open to the file when it's removed in
+ * ree_fs_new_remove(). In this case the NFS server may create a
+ * temporary reference called .nfs????, and the rmdir() call fails
+ * so that the TA directory is left over. Checking this special case
+ * here avoids that TEE_StartPersistentObjectEnumerator() returns
+ * TEE_SUCCESS when it should return TEEC_ERROR_ITEM_NOT_FOUND.
+ * Test case: "xtest 6009 6010".
+ */
+ while ((dent = readdir(dir))) {
+ if (dent->d_name[0] == '.')
+ continue;
+ empty = false;
+ break;
+ }
+ if (empty) {
+ closedir(dir);
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+ }
+ rewinddir(dir);
+
+ handle = handle_get(&dir_handle_db, dir);
+ if (handle < 0) {
+ closedir(dir);
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ }
+
+ params[2].u.value.a = handle;
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_closedir(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ DIR *dir = NULL;
+
+ if (num_params != 1 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ dir = handle_put(&dir_handle_db, params[0].u.value.b);
+ if (!dir)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ closedir(dir);
+
+ return TEEC_SUCCESS;
+}
+
+static TEEC_Result ree_fs_new_readdir(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ DIR *dir = NULL;
+ struct dirent *dirent = NULL;
+ char *buf = NULL;
+ size_t len = 0;
+ size_t fname_len = 0;
+
+ if (num_params != 2 ||
+ (params[0].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT ||
+ (params[1].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) !=
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+
+ buf = tee_supp_param_to_va(params + 1);
+ if (!buf)
+ return TEEC_ERROR_BAD_PARAMETERS;
+ len = params[1].u.memref.size;
+
+ dir = handle_lookup(&dir_handle_db, params[0].u.value.b);
+ if (!dir)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ while (true) {
+ dirent = readdir(dir);
+ if (!dirent)
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+ if (dirent->d_name[0] != '.')
+ break;
+ }
+
+ fname_len = strlen(dirent->d_name) + 1;
+ params[1].u.memref.size = fname_len;
+ if (fname_len > len)
+ return TEEC_ERROR_SHORT_BUFFER;
+
+ memcpy(buf, dirent->d_name, fname_len);
+
+ return TEEC_SUCCESS;
+}
+
+TEEC_Result tee_supp_fs_process(size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ if (!num_params || !tee_supp_param_is_value(params))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (strlen(tee_fs_root) == 0) {
+ if (tee_supp_fs_init() != 0) {
+ EMSG("error tee_supp_fs_init: failed to create %s/",
+ TEE_FS_PARENT_PATH);
+ memset(tee_fs_root, 0, sizeof(tee_fs_root));
+ return TEEC_ERROR_STORAGE_NOT_AVAILABLE;
+ }
+ }
+
+ switch (params->u.value.a) {
+ case OPTEE_MRF_OPEN:
+ return ree_fs_new_open(num_params, params);
+ case OPTEE_MRF_CREATE:
+ return ree_fs_new_create(num_params, params);
+ case OPTEE_MRF_CLOSE:
+ return ree_fs_new_close(num_params, params);
+ case OPTEE_MRF_READ:
+ return ree_fs_new_read(num_params, params);
+ case OPTEE_MRF_WRITE:
+ return ree_fs_new_write(num_params, params);
+ case OPTEE_MRF_TRUNCATE:
+ return ree_fs_new_truncate(num_params, params);
+ case OPTEE_MRF_REMOVE:
+ return ree_fs_new_remove(num_params, params);
+ case OPTEE_MRF_RENAME:
+ return ree_fs_new_rename(num_params, params);
+ case OPTEE_MRF_OPENDIR:
+ return ree_fs_new_opendir(num_params, params);
+ case OPTEE_MRF_CLOSEDIR:
+ return ree_fs_new_closedir(num_params, params);
+ case OPTEE_MRF_READDIR:
+ return ree_fs_new_readdir(num_params, params);
+ default:
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supp_fs.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supp_fs.h
new file mode 100755
index 0000000..43e13fe
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supp_fs.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TEE_SUPP_FS_H
+#define TEE_SUPP_FS_H
+
+#include <tee_client_api.h>
+
+struct tee_ioctl_param;
+
+TEEC_Result tee_supp_fs_process(size_t num_params,
+ struct tee_ioctl_param *params);
+
+#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supplicant.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supplicant.c
new file mode 100755
index 0000000..d5aad85
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supplicant.c
@@ -0,0 +1,785 @@
+/*
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ * Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <prof.h>
+#include <pthread.h>
+#include <rpmb.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <tee_client_api.h>
+#include <teec_ta_load.h>
+#include <teec_trace.h>
+#include <tee_socket.h>
+#include <tee_supp_fs.h>
+#include <tee_supplicant.h>
+#include <unistd.h>
+
+#include "optee_msg_supplicant.h"
+
+#ifndef __aligned
+#define __aligned(x) __attribute__((__aligned__(x)))
+#endif
+#include <linux/tee.h>
+
+#define RPC_NUM_PARAMS 5
+
+#define RPC_BUF_SIZE (sizeof(struct tee_iocl_supp_send_arg) + \
+ RPC_NUM_PARAMS * sizeof(struct tee_ioctl_param))
+
+union tee_rpc_invoke {
+ uint64_t buf[(RPC_BUF_SIZE - 1) / sizeof(uint64_t) + 1];
+ struct tee_iocl_supp_recv_arg recv;
+ struct tee_iocl_supp_send_arg send;
+};
+
+struct tee_shm {
+ int id;
+ void *p;
+ size_t size;
+ bool registered;
+ int fd;
+ struct tee_shm *next;
+};
+
+struct thread_arg {
+ int fd;
+ uint32_t gen_caps;
+ bool abort;
+ size_t num_waiters;
+ pthread_mutex_t mutex;
+};
+
+static pthread_mutex_t shm_mutex = PTHREAD_MUTEX_INITIALIZER;
+static struct tee_shm *shm_head;
+
+static const char *ta_dir;
+
+static void *thread_main(void *a);
+
+static size_t num_waiters_inc(struct thread_arg *arg)
+{
+ size_t ret = 0;
+
+ tee_supp_mutex_lock(&arg->mutex);
+ arg->num_waiters++;
+ assert(arg->num_waiters);
+ ret = arg->num_waiters;
+ tee_supp_mutex_unlock(&arg->mutex);
+
+ return ret;
+}
+
+static size_t num_waiters_dec(struct thread_arg *arg)
+{
+ size_t ret = 0;
+
+ tee_supp_mutex_lock(&arg->mutex);
+ assert(arg->num_waiters);
+ arg->num_waiters--;
+ ret = arg->num_waiters;
+ tee_supp_mutex_unlock(&arg->mutex);
+
+ return ret;
+}
+
+static int get_value(size_t num_params, struct tee_ioctl_param *params,
+ const uint32_t idx, struct tee_ioctl_param_value **value)
+{
+ if (idx >= num_params)
+ return -1;
+
+ switch (params[idx].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) {
+ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT:
+ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT:
+ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT:
+ *value = ¶ms[idx].u.value;
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+static struct tee_shm *find_tshm(int id)
+{
+ struct tee_shm *tshm = NULL;
+
+ tee_supp_mutex_lock(&shm_mutex);
+
+ tshm = shm_head;
+ while (tshm && tshm->id != id)
+ tshm = tshm->next;
+
+ tee_supp_mutex_unlock(&shm_mutex);
+
+ return tshm;
+}
+
+static struct tee_shm *pop_tshm(int id)
+{
+ struct tee_shm *tshm = NULL;
+ struct tee_shm *prev = NULL;
+
+ tee_supp_mutex_lock(&shm_mutex);
+
+ tshm = shm_head;
+ if (!tshm)
+ goto out;
+
+ if (tshm->id == id) {
+ shm_head = tshm->next;
+ goto out;
+ }
+
+ do {
+ prev = tshm;
+ tshm = tshm->next;
+ if (!tshm)
+ goto out;
+ } while (tshm->id != id);
+ prev->next = tshm->next;
+
+out:
+ tee_supp_mutex_unlock(&shm_mutex);
+
+ return tshm;
+}
+
+static void push_tshm(struct tee_shm *tshm)
+{
+ tee_supp_mutex_lock(&shm_mutex);
+
+ tshm->next = shm_head;
+ shm_head = tshm;
+
+ tee_supp_mutex_unlock(&shm_mutex);
+}
+
+/* Get parameter allocated by secure world */
+static int get_param(size_t num_params, struct tee_ioctl_param *params,
+ const uint32_t idx, TEEC_SharedMemory *shm)
+{
+ struct tee_shm *tshm = NULL;
+
+ if (idx >= num_params)
+ return -1;
+
+ switch (params[idx].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) {
+ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT:
+ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
+ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
+ break;
+ default:
+ return -1;
+ }
+
+ memset(shm, 0, sizeof(*shm));
+
+ tshm = find_tshm(params[idx].u.memref.shm_id);
+ if (!tshm) {
+ /*
+ * It doesn't make sense to query required size of an
+ * input buffer.
+ */
+ if ((params[idx].attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) ==
+ TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT)
+ return -1;
+
+ /*
+ * Buffer isn't found, the caller is querying required size
+ * of the buffer.
+ */
+ return 0;
+ }
+ if ((params[idx].u.memref.size + params[idx].u.memref.shm_offs) <
+ params[idx].u.memref.size)
+ return -1;
+ if ((params[idx].u.memref.size + params[idx].u.memref.shm_offs) >
+ tshm->size)
+ return -1;
+
+ shm->flags = TEEC_MEM_INPUT | TEEC_MEM_OUTPUT;
+ shm->size = params[idx].u.memref.size - params[idx].u.memref.shm_offs;
+ shm->id = params[idx].u.memref.shm_id;
+ shm->buffer = (uint8_t *)tshm->p + params[idx].u.memref.shm_offs;
+ return 0;
+}
+
+static void uuid_from_octets(TEEC_UUID *d, const uint8_t s[TEE_IOCTL_UUID_LEN])
+{
+ d->timeLow = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
+ d->timeMid = (s[4] << 8) | s[5];
+ d->timeHiAndVersion = (s[6] << 8) | s[7];
+ memcpy(d->clockSeqAndNode, s + 8, sizeof(d->clockSeqAndNode));
+}
+
+static uint32_t load_ta(size_t num_params, struct tee_ioctl_param *params)
+{
+ int ta_found = 0;
+ size_t size = 0;
+ struct tee_ioctl_param_value *val_cmd = NULL;
+ TEEC_UUID uuid;
+ TEEC_SharedMemory shm_ta;
+
+ memset(&uuid, 0, sizeof(uuid));
+ memset(&shm_ta, 0, sizeof(shm_ta));
+
+ if (num_params != 2 || get_value(num_params, params, 0, &val_cmd) ||
+ get_param(num_params, params, 1, &shm_ta))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ uuid_from_octets(&uuid, (void *)val_cmd);
+
+ size = shm_ta.size;
+ ta_found = TEECI_LoadSecureModule(ta_dir, &uuid, shm_ta.buffer, &size);
+ if (ta_found != TA_BINARY_FOUND) {
+ EMSG(" TA not found");
+ return TEEC_ERROR_ITEM_NOT_FOUND;
+ }
+
+ params[1].u.memref.size = size;
+
+ /*
+ * If a buffer wasn't provided, just tell which size it should be.
+ * If it was provided but isn't big enough, report an error.
+ */
+ if (shm_ta.buffer && size > shm_ta.size)
+ return TEEC_ERROR_SHORT_BUFFER;
+
+ return TEEC_SUCCESS;
+}
+
+static struct tee_shm *alloc_shm(int fd, size_t size)
+{
+ struct tee_shm *shm = NULL;
+ struct tee_ioctl_shm_alloc_data data;
+
+ memset(&data, 0, sizeof(data));
+
+ shm = calloc(1, sizeof(*shm));
+ if (!shm)
+ return NULL;
+
+ data.size = size;
+ shm->fd = ioctl(fd, TEE_IOC_SHM_ALLOC, &data);
+ if (shm->fd < 0) {
+ free(shm);
+ return NULL;
+ }
+
+ shm->p = mmap(NULL, data.size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ shm->fd, 0);
+ if (shm->p == (void *)MAP_FAILED) {
+ close(shm->fd);
+ free(shm);
+ return NULL;
+ }
+
+ shm->id = data.id;
+ shm->registered = false;
+ return shm;
+}
+
+static struct tee_shm *register_local_shm(int fd, size_t size)
+{
+ struct tee_shm *shm = NULL;
+ void *buf = NULL;
+ struct tee_ioctl_shm_register_data data;
+
+ memset(&data, 0, sizeof(data));
+
+ buf = malloc(size);
+ if (!buf)
+ return NULL;
+
+ shm = calloc(1, sizeof(*shm));
+ if (!shm) {
+ free(buf);
+ return NULL;
+ }
+
+ data.addr = (uintptr_t)buf;
+ data.length = size;
+
+ shm->fd = ioctl(fd, TEE_IOC_SHM_REGISTER, &data);
+ if (shm->fd < 0) {
+ free(shm);
+ free(buf);
+ return NULL;
+ }
+
+ shm->p = buf;
+ shm->registered = true;
+ shm->id = data.id;
+
+ return shm;
+}
+
+static uint32_t process_alloc(struct thread_arg *arg, size_t num_params,
+ struct tee_ioctl_param *params)
+{
+ struct tee_ioctl_param_value *val = NULL;
+ struct tee_shm *shm = NULL;
+
+ if (num_params != 1 || get_value(num_params, params, 0, &val))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (arg->gen_caps & TEE_GEN_CAP_REG_MEM)
+ shm = register_local_shm(arg->fd, val->b);
+ else
+ shm = alloc_shm(arg->fd, val->b);
+
+ if (!shm)
+ return TEEC_ERROR_OUT_OF_MEMORY;
+
+ shm->size = val->b;
+ val->c = shm->id;
+ push_tshm(shm);
+
+ return TEEC_SUCCESS;
+}
+
+static uint32_t process_free(size_t num_params, struct tee_ioctl_param *params)
+{
+ struct tee_ioctl_param_value *val = NULL;
+ struct tee_shm *shm = NULL;
+ int id = 0;
+
+ if (num_params != 1 || get_value(num_params, params, 0, &val))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ id = val->b;
+
+ shm = pop_tshm(id);
+ if (!shm)
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ if (shm->registered) {
+ free(shm->p);
+ } else {
+ if (munmap(shm->p, shm->size) != 0) {
+ EMSG("munmap(%p, %zu) failed - Error = %s",
+ shm->p, shm->size, strerror(errno));
+ close(shm->fd);
+ free(shm);
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ }
+
+ close(shm->fd);
+ free(shm);
+ return TEEC_SUCCESS;
+}
+
+
+
+/* How many device sequence numbers will be tried before giving up */
+#define MAX_DEV_SEQ 10000
+
+static int open_dev(const char *devname, uint32_t *gen_caps)
+{
+ int fd = 0;
+ struct tee_ioctl_version_data vers;
+
+ memset(&vers, 0, sizeof(vers));
+
+ fd = open(devname, O_RDWR);
+ if (fd < 0)
+ return -1;
+
+ if (ioctl(fd, TEE_IOC_VERSION, &vers))
+ goto err;
+
+ /* Only OP-TEE supported */
+ if (vers.impl_id != TEE_IMPL_ID_OPTEE)
+ goto err;
+
+ ta_dir = "optee_armtz";
+ if (gen_caps)
+ *gen_caps = vers.gen_caps;
+
+ DMSG("using device \"%s\"", devname);
+ return fd;
+err:
+ close(fd);
+ return -1;
+}
+
+static int get_dev_fd(uint32_t *gen_caps)
+{
+ int fd = 0;
+ char name[PATH_MAX] = { 0 };
+ size_t n = 0;
+
+ for (n = 0; n < MAX_DEV_SEQ; n++) {
+ snprintf(name, sizeof(name), "/dev/teepriv%zu", n);
+ fd = open_dev(name, gen_caps);
+ if (fd >= 0)
+ return fd;
+ usleep(10000);
+ }
+ return -1;
+}
+
+static int usage(int status)
+{
+ fprintf(stderr, "Usage: tee-supplicant [-d] [<device-name>]\n");
+ fprintf(stderr, " -d: run as a daemon (fork after successful "
+ "initialization)\n");
+ return status;
+}
+
+static uint32_t process_rpmb(size_t num_params, struct tee_ioctl_param *params)
+{
+ TEEC_SharedMemory req;
+ TEEC_SharedMemory rsp;
+
+ memset(&req, 0, sizeof(req));
+ memset(&rsp, 0, sizeof(rsp));
+
+ if (get_param(num_params, params, 0, &req) ||
+ get_param(num_params, params, 1, &rsp))
+ return TEEC_ERROR_BAD_PARAMETERS;
+
+ return rpmb_process_request(req.buffer, req.size, rsp.buffer, rsp.size);
+}
+
+static bool read_request(int fd, union tee_rpc_invoke *request)
+{
+ struct tee_ioctl_buf_data data;
+
+ memset(&data, 0, sizeof(data));
+
+ data.buf_ptr = (uintptr_t)request;
+ data.buf_len = sizeof(*request);
+ if (ioctl(fd, TEE_IOC_SUPPL_RECV, &data)) {
+ EMSG("TEE_IOC_SUPPL_RECV: %s", strerror(errno));
+ return false;
+ }
+ return true;
+}
+
+static bool write_response(int fd, union tee_rpc_invoke *request)
+{
+ struct tee_ioctl_buf_data data;
+
+ memset(&data, 0, sizeof(data));
+
+ data.buf_ptr = (uintptr_t)&request->send;
+ data.buf_len = sizeof(struct tee_iocl_supp_send_arg) +
+ sizeof(struct tee_ioctl_param) *
+ request->send.num_params;
+ if (ioctl(fd, TEE_IOC_SUPPL_SEND, &data)) {
+ EMSG("TEE_IOC_SUPPL_SEND: %s", strerror(errno));
+ return false;
+ }
+ return true;
+}
+
+static bool find_params(union tee_rpc_invoke *request, uint32_t *func,
+ size_t *num_params, struct tee_ioctl_param **params,
+ size_t *num_meta)
+{
+ struct tee_ioctl_param *p = NULL;
+ size_t n = 0;
+
+ p = (struct tee_ioctl_param *)(&request->recv + 1);
+
+ /* Skip meta parameters in the front */
+ for (n = 0; n < request->recv.num_params; n++)
+ if (!(p[n].attr & TEE_IOCTL_PARAM_ATTR_META))
+ break;
+
+ *func = request->recv.func;
+ *num_params = request->recv.num_params - n;
+ *params = p + n;
+ *num_meta = n;
+
+ /* Make sure that no meta parameters follows a non-meta parameter */
+ for (; n < request->recv.num_params; n++) {
+ if (p[n].attr & TEE_IOCTL_PARAM_ATTR_META) {
+ EMSG("Unexpected meta parameter");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static bool spawn_thread(struct thread_arg *arg)
+{
+ int e = 0;
+ pthread_t tid;
+
+ memset(&tid, 0, sizeof(tid));
+
+ DMSG("Spawning a new thread");
+
+ /*
+ * Increase number of waiters now to avoid starting another thread
+ * before this thread has been scheduled.
+ */
+ num_waiters_inc(arg);
+
+ e = pthread_create(&tid, NULL, thread_main, arg);
+ if (e) {
+ EMSG("pthread_create: %s", strerror(e));
+ num_waiters_dec(arg);
+ return false;
+ }
+
+ e = pthread_detach(tid);
+ if (e)
+ EMSG("pthread_detach: %s", strerror(e));
+
+ return true;
+}
+
+static bool process_one_request(struct thread_arg *arg)
+{
+ size_t num_params = 0;
+ size_t num_meta = 0;
+ struct tee_ioctl_param *params = NULL;
+ uint32_t func = 0;
+ uint32_t ret = 0;
+ union tee_rpc_invoke request;
+
+ memset(&request, 0, sizeof(request));
+
+ DMSG("looping");
+ request.recv.num_params = RPC_NUM_PARAMS;
+
+ /* Let it be known that we can deal with meta parameters */
+ params = (struct tee_ioctl_param *)(&request.send + 1);
+ params->attr = TEE_IOCTL_PARAM_ATTR_META;
+
+ num_waiters_inc(arg);
+
+ if (!read_request(arg->fd, &request))
+ return false;
+
+ if (!find_params(&request, &func, &num_params, ¶ms, &num_meta))
+ return false;
+
+ if (num_meta && !num_waiters_dec(arg) && !spawn_thread(arg))
+ return false;
+
+ switch (func) {
+ case OPTEE_MSG_RPC_CMD_LOAD_TA:
+ ret = load_ta(num_params, params);
+ break;
+ case OPTEE_MSG_RPC_CMD_FS:
+ ret = tee_supp_fs_process(num_params, params);
+ break;
+ case OPTEE_MSG_RPC_CMD_RPMB:
+ ret = process_rpmb(num_params, params);
+ break;
+ case OPTEE_MSG_RPC_CMD_SHM_ALLOC:
+ ret = process_alloc(arg, num_params, params);
+ break;
+ case OPTEE_MSG_RPC_CMD_SHM_FREE:
+ ret = process_free(num_params, params);
+ break;
+ case OPTEE_MSG_RPC_CMD_GPROF:
+ ret = prof_process(num_params, params, "gmon-");
+ break;
+ case OPTEE_MSG_RPC_CMD_SOCKET:
+ ret = tee_socket_process(num_params, params);
+ break;
+ case OPTEE_MSG_RPC_CMD_FTRACE:
+ ret = prof_process(num_params, params, "ftrace-");
+ break;
+ default:
+ EMSG("Cmd [0x%" PRIx32 "] not supported", func);
+ /* Not supported. */
+ ret = TEEC_ERROR_NOT_SUPPORTED;
+ break;
+ }
+
+ request.send.ret = ret;
+ return write_response(arg->fd, &request);
+}
+
+static void *thread_main(void *a)
+{
+ struct thread_arg *arg = a;
+
+ /*
+ * Now that this thread has been scheduled, compensate for the
+ * initial increase in spawn_thread() before.
+ */
+ num_waiters_dec(arg);
+
+ while (!arg->abort) {
+ if (!process_one_request(arg))
+ arg->abort = true;
+ }
+
+ return NULL;
+}
+
+int main(int argc, char *argv[])
+{
+ struct thread_arg arg = { .fd = -1 };
+ bool daemonize = false;
+ char *dev = NULL;
+ int e = 0;
+ int i = 0;
+
+
+ e = pthread_mutex_init(&arg.mutex, NULL);
+ if (e) {
+ EMSG("pthread_mutex_init: %s", strerror(e));
+ EMSG("terminating...");
+ exit(EXIT_FAILURE);
+ }
+
+ if (argc > 3)
+ return usage(EXIT_FAILURE);
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-d"))
+ daemonize = true;
+ else if (!strcmp(argv[i], "-h"))
+ return usage(EXIT_SUCCESS);
+ else
+ dev = argv[i];
+ }
+
+ if (dev) {
+ arg.fd = open_dev(dev, &arg.gen_caps);
+ printf("\n \r OP-TEE supplicant open_dev !!!\n");
+ if (arg.fd < 0) {
+ EMSG("OP-TEE supplicant failed to open \"%s\"", argv[1]);
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ arg.fd = get_dev_fd(&arg.gen_caps);
+ printf("\n \r OP-TEE supplicant get_dev_fd !!!\n");
+ if (arg.fd < 0) {
+ EMSG("failed to find an OP-TEE supplicant device");
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if (daemonize && daemon(0, 0) < 0) {
+ EMSG("daemon(): %s", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ while (!arg.abort) {
+ if (!process_one_request(&arg))
+ arg.abort = true;
+ }
+
+ close(arg.fd);
+
+ return EXIT_FAILURE;
+}
+
+bool tee_supp_param_is_memref(struct tee_ioctl_param *param)
+{
+ switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) {
+ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT:
+ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT:
+ case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool tee_supp_param_is_value(struct tee_ioctl_param *param)
+{
+ switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) {
+ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT:
+ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT:
+ case TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void *tee_supp_param_to_va(struct tee_ioctl_param *param)
+{
+ struct tee_shm *tshm = NULL;
+ size_t end_offs = 0;
+
+ if (!tee_supp_param_is_memref(param))
+ return NULL;
+
+ end_offs = param->u.memref.size + param->u.memref.shm_offs;
+ if (end_offs < param->u.memref.size ||
+ end_offs < param->u.memref.shm_offs)
+ return NULL;
+
+ tshm = find_tshm(param->u.memref.shm_id);
+ if (!tshm)
+ return NULL;
+
+ if (end_offs > tshm->size)
+ return NULL;
+
+ return (uint8_t *)tshm->p + param->u.memref.shm_offs;
+}
+
+void tee_supp_mutex_lock(pthread_mutex_t *mu)
+{
+ int e = pthread_mutex_lock(mu);
+
+ if (e) {
+ EMSG("pthread_mutex_lock: %s", strerror(e));
+ EMSG("terminating...");
+ exit(EXIT_FAILURE);
+ }
+}
+
+void tee_supp_mutex_unlock(pthread_mutex_t *mu)
+{
+ int e = pthread_mutex_unlock(mu);
+
+ if (e) {
+ EMSG("pthread_mutex_unlock: %s", strerror(e));
+ EMSG("terminating...");
+ exit(EXIT_FAILURE);
+ }
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supplicant.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supplicant.h
new file mode 100755
index 0000000..7e7c9cc
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/tee_supplicant.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, Linaro Limited
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TEE_SUPPLICANT_H
+#define TEE_SUPPLICANT_H
+
+#include <stdbool.h>
+#include <pthread.h>
+
+struct tee_ioctl_param;
+
+bool tee_supp_param_is_memref(struct tee_ioctl_param *param);
+bool tee_supp_param_is_value(struct tee_ioctl_param *param);
+void *tee_supp_param_to_va(struct tee_ioctl_param *param);
+
+void tee_supp_mutex_lock(pthread_mutex_t *mu);
+void tee_supp_mutex_unlock(pthread_mutex_t *mu);
+
+#endif /*TEE_SUPPLICANT_H*/
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/teec_ta_load.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/teec_ta_load.c
new file mode 100755
index 0000000..fd6a966
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/teec_ta_load.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+
+#include <teec_trace.h>
+#include <teec_ta_load.h>
+
+/*
+ * Attempt to first load TAs from a writable directory. This is
+ * intended for testing (xtest 1008, load_corrupt_ta specifically),
+ * and should not be enabled in a production system, as it would
+ * greatly facilitate loading rogue TA code.
+ */
+#ifdef CFG_TA_TEST_PATH
+# ifndef TEEC_TEST_LOAD_PATH
+# ifdef __ANDROID__
+# define TEEC_TEST_LOAD_PATH "/data/vendor/tee"
+# else
+# define TEEC_TEST_LOAD_PATH "/tmp"
+# endif
+# endif
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 255
+#endif
+
+struct tee_rpc_cmd {
+ void *buffer;
+ uint32_t size;
+ uint32_t type;
+ int fd;
+};
+
+/*
+ * Based on the uuid this function will try to find a TA-binary on the
+ * filesystem and return it back to the caller in the parameter ta.
+ *
+ * @param: destination The uuid of the TA we are searching for.
+ * @param: ta A pointer which this function will allocate and copy
+ * the TA from the filesystem to the pointer itself. It is
+ * the callers responsibility to free the pointer.
+ * @param: ta_size The size of the TA found on file system. It will be 0
+ * if no TA was not found.
+ *
+ * @return 0 if TA was found, otherwise -1.
+ */
+static int try_load_secure_module(const char* prefix,
+ const char* dev_path,
+ const TEEC_UUID *destination, void *ta,
+ size_t *ta_size)
+{
+ char fname[PATH_MAX] = { 0 };
+ FILE *file = NULL;
+ bool first_try = true;
+ size_t s = 0;
+ int n = 0;
+
+ if (!ta_size || !destination) {
+ printf("wrong inparameter to TEECI_LoadSecureModule\n");
+ return TA_BINARY_NOT_FOUND;
+ }
+
+ /*
+ * We expect the TA binary to be named after the UUID as per RFC4122,
+ * that is: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.ta
+ * If the file cannot be open, try the deprecated format:
+ * xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx.ta
+ */
+again:
+ n = snprintf(fname, PATH_MAX,
+ "%s/%s/%08x-%04x-%04x-%02x%02x%s%02x%02x%02x%02x%02x%02x.ta",
+ prefix, dev_path,
+ destination->timeLow,
+ destination->timeMid,
+ destination->timeHiAndVersion,
+ destination->clockSeqAndNode[0],
+ destination->clockSeqAndNode[1],
+ first_try ? "-" : "",
+ destination->clockSeqAndNode[2],
+ destination->clockSeqAndNode[3],
+ destination->clockSeqAndNode[4],
+ destination->clockSeqAndNode[5],
+ destination->clockSeqAndNode[6],
+ destination->clockSeqAndNode[7]);
+
+ DMSG("Attempt to load %s", fname);
+
+ if ((n < 0) || (n >= PATH_MAX)) {
+ EMSG("wrong TA path [%s]", fname);
+ return TA_BINARY_NOT_FOUND;
+ }
+
+ file = fopen(fname, "r");
+ if (file == NULL) {
+ DMSG("failed to open the ta %s TA-file", fname);
+ if (first_try) {
+ first_try = false;
+ goto again;
+ }
+ return TA_BINARY_NOT_FOUND;
+ }
+
+ if (fseek(file, 0, SEEK_END) != 0) {
+ fclose(file);
+ return TA_BINARY_NOT_FOUND;
+ }
+
+ s = ftell(file);
+ if (s > *ta_size || !ta) {
+ /*
+ * Buffer isn't large enough, return the required size to
+ * let the caller increase the size of the buffer and try
+ * again.
+ */
+ goto out;
+ }
+
+ if (fseek(file, 0, SEEK_SET) != 0) {
+ fclose(file);
+ return TA_BINARY_NOT_FOUND;
+ }
+
+ if (s != fread(ta, 1, s, file)) {
+ printf("error fread TA file\n");
+ fclose(file);
+ return TA_BINARY_NOT_FOUND;
+ }
+
+out:
+ *ta_size = s;
+ fclose(file);
+ return TA_BINARY_FOUND;
+}
+
+int TEECI_LoadSecureModule(const char* dev_path,
+ const TEEC_UUID *destination, void *ta,
+ size_t *ta_size)
+{
+#ifdef TEEC_TEST_LOAD_PATH
+ int res = 0;
+
+ res = try_load_secure_module(TEEC_TEST_LOAD_PATH,
+ dev_path, destination, ta, ta_size);
+ if (res != TA_BINARY_NOT_FOUND)
+ return res;
+#endif
+
+ return try_load_secure_module(TEEC_LOAD_PATH,
+ dev_path, destination, ta, ta_size);
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/teec_ta_load.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/teec_ta_load.h
new file mode 100755
index 0000000..42ddc9f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/src/teec_ta_load.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014, STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _TEEC_TA_LOAD_H
+#define _TEEC_TA_LOAD_H
+#include <tee_client_api.h>
+
+#define TA_BINARY_FOUND 0
+#define TA_BINARY_NOT_FOUND -1
+
+/**
+ * Based on the uuid this function will try to find a TA-binary on the
+ * filesystem and return it back to the caller in the parameter ta.
+ *
+ * @param: destination The uuid of the TA we are searching for.
+ * @param: ta A pointer which this function will copy
+ * the TA from the filesystem to if *@ta_size i large
+ * enough.
+ * @param: ta_size The size of the TA found on file system. It will be 0
+ * if no TA was not found.
+ *
+ * @return 0 if TA was found, otherwise -1.
+ */
+int TEECI_LoadSecureModule(const char *name,
+ const TEEC_UUID *destination, void *ta,
+ size_t *ta_size);
+#endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/tee_supplicant_android.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/tee_supplicant_android.mk
new file mode 100755
index 0000000..182f6ea
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/optee/optee-client/tee-supplicant/tee_supplicant_android.mk
@@ -0,0 +1,60 @@
+################################################################################
+# Build tee supplicant #
+################################################################################
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS += $(optee_CFLAGS)
+
+LOCAL_CFLAGS += -DDEBUGLEVEL_$(CFG_TEE_SUPP_LOG_LEVEL) \
+ -DBINARY_PREFIX=\"TEES\" \
+ -DTEEC_LOAD_PATH=\"$(CFG_TEE_CLIENT_LOAD_PATH)\" \
+ -DTEE_FS_PARENT_PATH=\"$(CFG_TEE_FS_PARENT_PATH)\"
+
+ifneq ($(TEEC_TEST_LOAD_PATH),)
+LOCAL_CFLAGS += -DTEEC_TEST_LOAD_PATH=\"$(TEEC_TEST_LOAD_PATH)\"
+endif
+
+ifeq ($(CFG_TA_TEST_PATH),y)
+LOCAL_CFLAGS += -DCFG_TA_TEST_PATH=1
+endif
+
+LOCAL_SRC_FILES += src/handle.c \
+ src/tee_supp_fs.c \
+ src/tee_supplicant.c \
+ src/teec_ta_load.c \
+ src/rpmb.c
+
+ifeq ($(CFG_GP_SOCKETS),y)
+LOCAL_SRC_FILES += src/tee_socket.c
+LOCAL_CFLAGS += -DCFG_GP_SOCKETS=1
+endif
+
+RPMB_EMU := 1
+ifeq ($(RPMB_EMU),1)
+LOCAL_SRC_FILES += src/sha2.c src/hmac_sha2.c
+LOCAL_CFLAGS += -DRPMB_EMU=1
+endif
+
+ifneq (,$(filter y,$(CFG_TA_GPROF_SUPPORT) $(CFG_FTRACE_SUPPORT)))
+LOCAL_SRC_FILES += src/prof.c
+endif
+
+ifeq ($(CFG_TA_GPROF_SUPPORT),y)
+LOCAL_CFLAGS += -DCFG_TA_GPROF_SUPPORT
+endif
+
+ifeq ($(CFG_FTRACE_SUPPORT),y)
+LOCAL_CFLAGS += -DCFG_FTRACE_SUPPORT
+endif
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/../public \
+ $(LOCAL_PATH)/../libteec/include \
+ $(LOCAL_PATH)/src
+
+LOCAL_SHARED_LIBRARIES := libteec
+
+LOCAL_MODULE := tee-supplicant
+LOCAL_MODULE_TAGS := optional
+LOCAL_VENDOR_MODULE := true
+include $(BUILD_EXECUTABLE)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/libril/ril.cpp b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/libril/ril.cpp
index e4142dc..80743a7 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/libril/ril.cpp
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/libril/ril.cpp
@@ -3475,7 +3475,7 @@
static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) {
p.writeInt32(num_apps);
- startResponse;
+ //startResponse;
for (int i = 0; i < num_apps; i++) {
p.writeInt32(appStatus[i].app_type);
p.writeInt32(appStatus[i].app_state);
@@ -3511,17 +3511,25 @@
if (responselen == sizeof (RIL_CardStatus_v6)) {
RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
-
+ startResponse;
p.writeInt32(p_cur->card_state);
p.writeInt32(p_cur->universal_pin_state);
p.writeInt32(p_cur->gsm_umts_subscription_app_index);
p.writeInt32(p_cur->cdma_subscription_app_index);
p.writeInt32(p_cur->ims_subscription_app_index);
-
+ appendPrintBuf("%s[card_state=%d,universal_pin_state=%d,gsm_umts_subscription_app_index=%d,\
+ gsm_umts_subscription_app_index=%d,ims_subscription_app_index=%d,num_applications=%d],",
+ printBuf,
+ p_cur->card_state,
+ p_cur->universal_pin_state,
+ p_cur->gsm_umts_subscription_app_index,
+ p_cur->cdma_subscription_app_index,
+ p_cur->ims_subscription_app_index,
+ p_cur->num_applications);
sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications);
} else if (responselen == sizeof (RIL_CardStatus_v5)) {
RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response);
-
+ startResponse;
p.writeInt32(p_cur->card_state);
p.writeInt32(p_cur->universal_pin_state);
p.writeInt32(p_cur->gsm_umts_subscription_app_index);
@@ -4027,6 +4035,94 @@
free(args);
}
+enum options {
+ /*radiooptions 0 1 0*/
+ RADIO_OFF = 0,
+ /*radiooptions 1 1 0*/
+ RADIO_ON = 1,
+ /*radiooptions 2 atcmd 1 0*/
+ OEM_HOOK_RAW = 2,
+ /*radiooptions 3 "testapn" 1 0*/
+ SETUP_PDP = 3,
+ /*radiooptions 4 cid 1 0*/
+ DEACTIVATE_PDP = 4,
+ /*radiooptions 5 "IPV6" 1 0*/
+ SETUP_DATA_CALL = 5,
+ /*radiooptions 6 1 0*/
+ DATA_CALL_LIST = 6,
+ /*radiooptions 7 "10086" 1 0*/
+ DIAL_CALL = 7,
+ /*radiooptions 8 1 0*/
+ ANSWER_CALL = 8,
+ /*radiooptions 9 callid 1 0*/
+ END_CALL = 9,
+ /*radiooptions 10 1 0*/
+ GET_CURRENT_CALLS = 10,
+ /*radiooptions 11 1 0*/
+ REQUEST_UDUB = 11,
+ /*radiooptions 12 c 1 0*/
+ REQUEST_DTMF = 12,
+ /*radiooptions 13 mute 1 0*/
+ SET_MUTE = 13,
+ /*radiooptions 14 1 0*/
+ GET_MUTE = 14,
+ /*radiooptions 15 "1"/"0" 1 0*/
+ SET_IMS_ENABLE = 15,
+ /*radiooptions 16 1 0*/
+ GET_SIM_STATUS = 16,
+ /*radiooptions 17 1 0*/
+ DEVICE_IDENTITY = 17,
+ /*radiooptions 18 1 0*/
+ QUERY_ICCID = 18,
+ /*radiooptions 19 1 0*/
+ OPERATOR = 19,
+ /*radiooptions 20 1 0*/
+ GET_PREFERRED_NETWORK_TYPE = 20,
+ /*radiooptions 21 1 0*///GSM ONLY
+ /*radiooptions 21 type 1 0*///type:RIL_PreferredNetworkType
+ SET_PREFERRED_NETWORK_TYPE = 21,
+ /*radiooptions 22 1 0*///LTE ONLY
+ SET_PREFERRED_NETWORK_TYPE_LTE = 22,
+ /*radiooptions 23 1 0*/
+ QUERY_NETWORK_SELECTION_MODE = 23,
+ /*radiooptions 24 1 0*/
+ SET_NETWORK_SELECTION_AUTOMATIC = 24,
+ /*radiooptions 25 1 0*/
+ SET_NETWORK_SELECTION_MANUAL = 25,
+ /*radiooptions 26 "data" 1 0*///"data":DATA_REGISTRATION_STATE
+ /*radiooptions 26 "voice" 1 0*///"voice":VOICE_REGISTRATION_STATE
+ /*radiooptions 26 1 0*///VOICE_REGISTRATION_STATE
+ REGISTRATION_STATE = 26,
+
+ /*radiooptions 27 1 0*/
+ QUERY_AVAILABLE_NETWORKS = 27,
+ /*radiooptions 28 1 0*/
+ VOICE_RADIO_TECH = 28,
+ /*radiooptions 29 1 0*/
+ SIGNAL_STRENGTH = 29,
+ /*radiooptions 30 1 0*/
+ GET_CELL_INFO_LIST = 30,
+ /*radiooptions 31 t 1 0*/
+ SET_UNSOL_CELL_INFO_LIST_RATE = 31,
+ /*radiooptions 32 1 0*/
+ /*radiooptions 32 pdu 1 0*/
+ /*radiooptions 32 smsc(00) pdu 1 0*/
+ SEND_SMS = 32,
+ /*radiooptions 33 1 0*/
+ SMS_ACKNOWLEDGE = 33,
+ /*radiooptions 34 1 0*/
+ GET_SMSC_ADDRESS = 34,
+ /*radiooptions 35 smsc 1 0*/
+ SET_SMSC_ADDRESS = 35,
+
+ /*radiooptions 38 fac 1 0*/
+ QUERY_FACILITY_LOCK = 38,
+ /*radiooptions 39 fac act passwd 1 0*/
+ SET_FACILITY_LOCK = 39,
+ /*radiooptions 40 pin 1 0*/
+ ENTER_SIM_PIN = 40,
+};
+
static void debugCallback (int fd, short flags, void *param) {
int acceptFD, option;
struct sockaddr_un peeraddr;
@@ -4114,11 +4210,7 @@
}
switch (atoi(args[0])) {
- case 0:
- RLOGI ("Connection on debug port: issuing reset.");
- issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0, socket_id);
- break;
- case 1:
+ case RADIO_OFF:
RLOGI ("Connection on debug port: issuing radio power off.");
data = 0;
issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int), socket_id);
@@ -4134,11 +4226,15 @@
}
#endif
break;
- case 2:
- RLOGI ("Debug port: issuing unsolicited voice network change.");
- RIL_UNSOL_RESPONSE(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, NULL, 0, socket_id);
+ case RADIO_ON:
+ RLOGI("Debug port: Radio On");
+ data = 1;
+ issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int), socket_id);
+ sleep(2);
+ // Set network selection automatic.
+ issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0, socket_id);
break;
- case 3:
+ case OEM_HOOK_RAW:
RLOGI ("Debug port: OEM Hook Raw.");
memset(atcmd, 0, sizeof(atcmd));
@@ -4152,26 +4248,8 @@
issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, atcmd, strlen(atcmd), socket_id);
break;
- case 4:
- RLOGI ("Debug port: QXDM log disable.");
- qxdm_data[0] = 65536;
- qxdm_data[1] = 16;
- qxdm_data[2] = 0; // mode: 0 for 'stop logging'
- qxdm_data[3] = 32;
- qxdm_data[4] = 0;
- qxdm_data[5] = 8;
- issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data,
- 6 * sizeof(int), socket_id);
- break;
- case 5:
- RLOGI("Debug port: Radio On");
- data = 1;
- issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int), socket_id);
- sleep(2);
- // Set network selection automatic.
- issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0, socket_id);
- break;
- case 6:
+
+ case SETUP_PDP:
RLOGI("Debug port: Setup Data Call");
char apn[16];
@@ -4180,7 +4258,7 @@
actData[2] = apn;
issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, (8 * sizeof(char *)), socket_id);
break;
- case 7:
+ case DEACTIVATE_PDP:
RLOGI("Debug port: Deactivate Data Call");
char cid[16];
@@ -4191,7 +4269,7 @@
issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
sizeof(deactData), socket_id);
break;
- case 8:
+ case DIAL_CALL:
RLOGI("Debug port: Dial Call");
dialData.clir = 0;
if (strlen(args[1]) > MAX_DIAL_ADDRESS) {
@@ -4204,29 +4282,32 @@
dialData.uusInfo = NULL;
issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData), socket_id);
break;
- case 9:
+ case ANSWER_CALL:
RLOGI("Debug port: Answer Call");
issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0, socket_id);
break;
- case 10:
+ case END_CALL:
RLOGI("Debug port: End Call");
+ if(3 == number) {
+ hangupData[0] = atoi(args[1]);
+ }
issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
sizeof(hangupData), socket_id);
break;
- case 11: //RIL_REQUEST_GET_SIM_STATUS
+ case GET_SIM_STATUS: //RIL_REQUEST_GET_SIM_STATUS
RLOGI("Debug port: Get Sim Status");
issueLocalRequest(RIL_REQUEST_GET_SIM_STATUS, NULL, 0, socket_id);
break;
- case 12:
+ case GET_PREFERRED_NETWORK_TYPE:
RLOGI("Debug port: Get Prefered Network Type");
issueLocalRequest(RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, NULL, 0, socket_id);
break;
- case 13:
+ case SET_PREFERRED_NETWORK_TYPE_LTE:
RLOGI("Debug port: Set Prefered Network Type(LTE only)");
data = 11; //PREF_NET_TYPE_LTE_ONLY
issueLocalRequest(RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, &data, sizeof(data), socket_id);
break;
- case 14:
+ case SET_PREFERRED_NETWORK_TYPE:
if(3 == number) {
data = atoi(args[1]);
@@ -4238,7 +4319,7 @@
}
issueLocalRequest(RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, &data, sizeof(data), socket_id);
break;
- case 15:
+ case SETUP_DATA_CALL:
RLOGI("Debug port: Setup Data Call");
char pdptype[16];
@@ -4251,11 +4332,11 @@
}
issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, (8 * sizeof(char *)), socket_id);
break;
- case 16:
+ case DATA_CALL_LIST:
RLOGI("Debug port: Data Call List");
issueLocalRequest(RIL_REQUEST_DATA_CALL_LIST, NULL, 0, socket_id);
break;
- case 17:
+ case REGISTRATION_STATE:
if((3 == number) && (0 == strcmp(args[1], "data"))) {
RLOGI("Debug port: Data Registration State");
issueLocalRequest(RIL_REQUEST_DATA_REGISTRATION_STATE, NULL, 0, socket_id);
@@ -4265,12 +4346,12 @@
RLOGI("Debug port: Voice Registration State");
issueLocalRequest(RIL_REQUEST_VOICE_REGISTRATION_STATE, NULL, 0, socket_id);
break;
- case 18:
+ case GET_CURRENT_CALLS:
RLOGI("Debug port: Get Current Calls");
issueLocalRequest(RIL_REQUEST_GET_CURRENT_CALLS, NULL, 0, socket_id);
break;
- case 19:
+ case SEND_SMS:
RLOGI("Debug port: Send Sms");
char smsc[8];
char pdu[400];
@@ -4292,11 +4373,12 @@
}
issueLocalRequest(RIL_REQUEST_SEND_SMS, &smsData, (2 * sizeof(char *)), socket_id);
break;
- case 20:
+ case SMS_ACKNOWLEDGE:
RLOGI("Debug port: Sms Acknowledge");
data = 1;
issueLocalRequest(RIL_REQUEST_SMS_ACKNOWLEDGE, &data, sizeof(data), socket_id);
break;
+#if 0
case 21:
RLOGI("Debug port: Write Sms to SIM");
RIL_SMS_WriteArgs p_args;
@@ -4317,19 +4399,20 @@
}
issueLocalRequest(RIL_REQUEST_DELETE_SMS_ON_SIM, &data, sizeof(data), socket_id);
break;
- case 23:
+#endif
+ case OPERATOR:
RLOGI("Debug port: Operator");
issueLocalRequest(RIL_REQUEST_OPERATOR, NULL, 0, socket_id);
break;
- case 24:
+ case QUERY_NETWORK_SELECTION_MODE:
RLOGI("Debug port: Network Selection Mode");
issueLocalRequest(RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE, NULL, 0, socket_id);
break;
- case 25:
+ case SET_NETWORK_SELECTION_AUTOMATIC:
RLOGI("Debug port: Set Network Selection Auto");
issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0, socket_id);
break;
- case 26:
+ case SET_NETWORK_SELECTION_MANUAL:
RLOGI("Debug port: Set Network Selection Manual");
if(3 == number) {
@@ -4341,27 +4424,27 @@
}
break;
- case 27:
+ case VOICE_RADIO_TECH:
RLOGI("Debug port: Voice Radio Tech");
issueLocalRequest(RIL_REQUEST_VOICE_RADIO_TECH, NULL, 0, socket_id);
break;
- case 28:
+ case SIGNAL_STRENGTH:
RLOGI("Debug port: Singal Strength");
issueLocalRequest(RIL_REQUEST_SIGNAL_STRENGTH, NULL, 0, socket_id);
break;
- case 29:
+ case DEVICE_IDENTITY:
RLOGI("Debug port: Device Identity");
issueLocalRequest(RIL_REQUEST_DEVICE_IDENTITY, NULL, 0, socket_id);
break;
- case 30:
+ case QUERY_ICCID:
RLOGI("Debug port: Query Iccid");
issueLocalRequest(RIL_REQUEST_QUERY_ICCID, NULL, 0, socket_id);
break;
- case 31:
+ case GET_CELL_INFO_LIST:
RLOGI("Debug port: Get Cell Info List");
issueLocalRequest(RIL_REQUEST_GET_CELL_INFO_LIST, NULL, 0, socket_id);
break;
- case 32:
+ case SET_IMS_ENABLE:
RLOGI("Debug port: Set Ims Enable");
{
int onOff = 0;
@@ -4375,11 +4458,11 @@
}
}
break;
- case 33:
+ case GET_SMSC_ADDRESS:
RLOGI("Debug port: Get Smsc Address");
issueLocalRequest(RIL_REQUEST_GET_SMSC_ADDRESS, NULL, 0, socket_id);
break;
- case 34:
+ case SET_SMSC_ADDRESS:
{
char *sSmscAddr = NULL;
RLOGI("Debug port: Set Smsc Address");
@@ -4392,7 +4475,7 @@
}
}
break;
- case 35:
+ case QUERY_FACILITY_LOCK:
{
RLOGI("Debug port: Query Facility Lock");
char *fLock[4] = {"SC","","7",""};//fac,passwd,class,aid
@@ -4404,16 +4487,29 @@
}
break;
- case 36:
+ case SET_FACILITY_LOCK:
+ {
+ RLOGI("Debug port: Set Facility Lock");
+ char *fLock[5] = {"SC","0","","7",""};//fac,act,passwd,class,aid
+
+ if(3 <= number) {
+ fLock[0] = args[1]; //fac
+ fLock[1] = args[2]; //act
+ fLock[2] = args[3]; //passwd
+ }
+
+ issueLocalRequest(RIL_REQUEST_SET_FACILITY_LOCK, &fLock, (5 * sizeof(char *)), socket_id);
+ }
+ case QUERY_AVAILABLE_NETWORKS:
RLOGI("Debug port: Query Available Networks");
issueLocalRequest(RIL_REQUEST_QUERY_AVAILABLE_NETWORKS, NULL, 0, socket_id);
break;
- case 37:
+ case REQUEST_UDUB:
RLOGI("Debug port: Udub");
issueLocalRequest(RIL_REQUEST_UDUB, NULL, 0, socket_id);
break;
- case 38:
+ case REQUEST_DTMF:
{
char cDtmf;
RLOGI("Debug port: Dtmf");
@@ -4425,13 +4521,34 @@
issueLocalRequest(RIL_REQUEST_DTMF, &cDtmf, sizeof(char), socket_id);
}
break;
- case 39:
+ case SET_UNSOL_CELL_INFO_LIST_RATE:
RLOGI("Debug port: Set Unsol Cell Info List Rate");
if(3 == number) {
data = atoi(args[1]);
}
issueLocalRequest(RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, &data, sizeof(data), socket_id);
break;
+ case SET_MUTE:
+ RLOGI("Debug port: Set Mute");
+ if(3 == number) {
+ data = atoi(args[1]);
+ issueLocalRequest(RIL_REQUEST_SET_MUTE, &data, sizeof(data), socket_id);
+ }
+ break;
+ case GET_MUTE:
+ RLOGI("Debug port: Get Mute");
+ issueLocalRequest(RIL_REQUEST_GET_MUTE, NULL, 0, socket_id);
+ break;
+
+ case ENTER_SIM_PIN:
+ RLOGI("Debug port: ENTER SIM PIN");
+ if(3 <= number) {
+ char *fData[2] = {"",""}; //PIN AID
+
+ fData[0] = args[1];
+ issueLocalRequest(RIL_REQUEST_ENTER_SIM_PIN, &fData, (2 * sizeof(char *)), socket_id);
+ }
+ break;
default:
RLOGE ("Invalid request");
break;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/Makefile
index c3dcc63..da61d9d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/Makefile
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/Makefile
@@ -34,7 +34,9 @@
-lsofttimer -L$(zte_lib_path)/libsofttimer \
-latutils -L$(zte_lib_path)/libatutils
LOCAL_LDLIBS += -latchn -L$(zte_lib_path)/libatchn
-
+LOCAL_LDLIBS += -ltinyalsa -L$(zte_lib_path)/libtinyalsa
+LOCAL_LDLIBS += -lvoice -L$(zte_lib_path)/libvoice
+LOCAL_LDLIBS += -lmedia -L$(zte_lib_path)/libmedia
#LOCAL_LDFLAGS += -shared
LDFLAGS += -shared
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.c
index ec6490e..bb4ef0e 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.c
@@ -1005,36 +1005,42 @@
* Returns error code from response
* Assumes AT+CMEE=1 (numeric) mode
*/
-AT_CME_Error at_get_cme_error(const ATResponse *p_response)
+int at_get_error(const ATResponse *p_response, const char *prefix)
{
int ret;
int err;
- char *p_cur;
+ char *p_cur;
if (p_response->success > 0) {
- return CME_SUCCESS;
+ return 0;
}
- if (p_response->finalResponse == NULL
- || !strStartsWith(p_response->finalResponse, "+CME ERROR:")
- ) {
- return CME_ERROR_NON_CME;
+ if (p_response->finalResponse == NULL || !strStartsWith(p_response->finalResponse, prefix)) {
+ return -1;
}
p_cur = p_response->finalResponse;
err = at_tok_start(&p_cur);
-
if (err < 0) {
- return CME_ERROR_NON_CME;
+ return -1;
}
err = at_tok_nextint(&p_cur, &ret);
-
if (err < 0) {
- return CME_ERROR_NON_CME;
+ return -1;
}
- return (AT_CME_Error) ret;
+ return ret;
+}
+
+AT_CME_Error at_get_cme_error(const ATResponse *p_response)
+{
+ return (AT_CME_Error) at_get_error(p_response, "+CME ERROR:");
+}
+
+AT_CMS_Error at_get_cms_error(const ATResponse *p_response)
+{
+ return (AT_CMS_Error) at_get_error(p_response, "+CMS ERROR:");
}
static struct atchn_info * at_get_channel_by_name(char *name)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.h
index 550f850..9c9b921 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.h
@@ -190,6 +190,15 @@
} AT_CME_Error;
AT_CME_Error at_get_cme_error(const ATResponse *p_response);
+typedef enum
+{
+ CMS_ERROR_NON_CMS = -1,
+ CMS_SUCCESS = 0,
+ CMS_NW_TIMEOUT = 332,
+ CMS_UNKNOWN_ERROR = 500,
+} AT_CMS_Error;
+
+AT_CMS_Error at_get_cms_error(const ATResponse *p_response);
int at_channel_init(void);
int at_channel_deinit(void);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/reference-ril.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/reference-ril.c
index 3601517..b43b12d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/reference-ril.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/reference-ril.c
Binary files differ
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
index 38e440f..1be7cb4 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
@@ -40,6 +40,11 @@
#include "ril_ref.h"
#include "at_utils.h"
#include "pstraceint.h"
+
+#include <tinyalsa/audio_mixer_ctrl.h>
+#include "voice_lib.h"
+#include "sc_voice_api.h"
+
#define __unused __attribute__((__unused__))
@@ -62,6 +67,246 @@
static int s_ims_services = 1; // & 0x1 == sms over ims supported
static int s_ims_format = 1; // FORMAT_3GPP(1) vs FORMAT_3GPP2(2);
+/* ÉêÇëÒôƵ×ÊÔ´. */
+static int cc_pcm_audio_resource_request(int modid, int type)
+{
+ T_audio_Res_Request requestParam = {0};
+ T_audio_UseRsp RspData = {0};
+
+ requestParam.moduleId = modid;
+ requestParam.audioType = type;
+ requestParam.tempMouduleId = 0;
+
+ if(!audio_resource_request(&requestParam, &RspData))
+ {
+ RLOGE("cc_pcm_audio_resource_request: usin_type(%d)\n", RspData.using_type);
+ return -1;
+ }
+ return 0;
+}
+static void cc_pcm_audio_resource_release(int modid, int type)
+{
+ T_audio_RelInd relInd = {0};
+ relInd.moduleId = modid;
+ relInd.type = type;
+ /* send msg to audio ctrl */
+ if(0 >platform_send_msg(MODULE_ID_ZCORE,MODULE_ID_CODEC, REL_AUDIO_IND, sizeof(T_audio_RelInd), (unsigned char *)&relInd)) {
+ RLOGE("cc_pcm_audio_resource_release: send msg error!\n");
+ }
+}
+
+static int cc_voice_play_ring_back(void)
+{
+ return 0;
+}
+static void cc_voice_stop_ring_back(void)
+{
+ return;
+}
+static int cc_voice_mixer_config(unsigned int card, int path, int output_volume, int input_volume)
+{
+ struct mixer *mixer;
+
+ mixer = mixer_open(card);
+ if (!mixer) {
+ RLOGE("cc_voice_mixer_config Failed to open mixer\n");
+ return -1;
+ }
+
+ mix_set_voice_path(mixer, path);
+ mix_set_output_vol(mixer, output_volume);
+ mix_set_input_vol(mixer, input_volume);
+
+ mixer_close(mixer);
+
+ return 0;
+}
+
+#if defined(_USE_VOICE_ALSA) && defined(_USE_ALSA_AT_INTF)
+static int cc_voice_open_at(int onoff, int mode)
+{
+ char cmd[32] = {0};
+
+ memset(cmd, 0, sizeof(cmd));
+
+ if(1 == onoff) {
+ if(0 != alsa_voice_open(mode)) {
+ RLOGD("cc_voice_open_at alsa_voice_open\n");
+ return -1;
+ }
+
+ /*0-handset,1-headset,2-speaker*/
+ get_modem_info("AT+VPATH=0\r\n", NULL, NULL);
+ }
+ else {
+ if(0 != alsa_voice_close(mode)) {
+ RLOGE("cc_voice_open_api cc_voice_open_at fail.\n");
+ return -1;
+ }
+ }
+
+ /*open 23G 2-device,AVOICE_TEAK_2G_3G,1/0-o/c*/
+ snprintf(cmd,sizeof(cmd)-1,"AT+VALSA=%d,%d\r\n",mode,onoff);
+ get_modem_info(cmd, NULL, NULL);
+
+ return 0;
+}
+#elif defined(_USE_VOICE_ALSA)
+static int cc_voice_open_api(int onoff, int mode)
+{
+ if(1 == onoff) {
+ if(0 != alsa_voice_open(mode)) {
+ RLOGE("cc_voice_open_api cap alsa_voice_open TEAK_2G_3G fail\n");
+ return -1;
+ }
+
+ if(0 != sc_audio_ap_alsa_voice_open(mode)) {
+ alsa_voice_close(mode);
+ RLOGE("cc_voice_open_api ap alsa_voice_open TEAK_2G_3G fail\n");
+ return -1;
+ }
+ }
+ else {
+ if(0 != sc_audio_ap_alsa_voice_close(mode)) {
+ RLOGE("cc_voice_open_api sc_audio_ap_alsa_voice_close fail.\n");
+ }
+ if(0 != alsa_voice_close(mode)) {
+ RLOGE("cc_voice_open_api alsa_voice_close fail.\n");
+ }
+ }
+
+ return 0;
+}
+
+#endif
+
+static void cc_voice_close(unsigned int op, unsigned int mode, unsigned int code_type, unsigned int amr_path)
+{
+ int voice_mode;
+
+ RLOGD("cc_voice_close\n");
+ if(3 == mode) {
+ voice_mode = AVOICE_TEAK_2G_3G;
+ }
+ /*WCDMA/TD-SCDMAģʽ*/
+ else if(((5 == mode) || (15 == mode)) ) {
+ /* 3G-NB ʹÓÃHW*/
+ if((code_type == 0) && (amr_path==0 )) {
+ voice_mode = AVOICE_TEAK_2G_3G;
+ }
+ /* 3G-NBʹÓÃSW*/
+ else if((code_type == 0) && (amr_path== 1)) {
+ voice_mode = AVOICE_SOFT_3G_NB;
+ }
+ /* 3G-WB*/
+ else if((code_type == 1) && (amr_path== 1 )) {
+ voice_mode = AVOICE_SOFT_3G_WB;
+ }
+ }
+ else
+ {
+ RLOGE("cc_voice_close unknown mode.\n");
+ return;
+ }
+#if defined(_USE_VOICE_ALSA) && defined(_USE_ALSA_AT_INTF)
+ cc_voice_open_at(0, voice_mode);
+#elif defined(_USE_VOICE_ALSA)
+ cc_voice_open_api(0, voice_mode);
+#endif
+
+ /* send msg to audio ctrl */
+ cc_pcm_audio_resource_release(MODULE_ID_CALL_23G, VOICE_23G);
+}
+
+static int cc_voice_open(unsigned int op, unsigned int mode, unsigned int code_type, unsigned int amr_path)
+{
+ T_audio_Res_Request requestParam = {0};
+ T_audio_UseRsp RspData = {0};
+ int voice_mode;
+
+ RLOGD("cc_voice_open mode:%d,code_type:%d,amr_path:%d\n",mode,code_type,amr_path);
+
+ /* request the audio resource */
+ if(0 != cc_pcm_audio_resource_request(MODULE_ID_CALL_23G, VOICE_23G)) {
+ RLOGE("cc_voice_open audio-res request fail.\n");
+ return 0;
+ }
+
+ /* GSM/GPRS */
+ if(3 == mode) {
+ voice_mode = AVOICE_TEAK_2G_3G;
+ }
+ /*WCDMA/TD-SCDMAģʽ*/
+ else if(((5 == mode) || (15 == mode)) ) {
+ /* 3G-NB ʹÓÃHW*/
+ if((code_type == 0) && (amr_path==0 )) {
+ voice_mode = AVOICE_TEAK_2G_3G;
+ }
+ /* 3G-NBʹÓÃSW*/
+ else if((code_type == 0) && (amr_path== 1)) {
+ voice_mode = AVOICE_SOFT_3G_NB;
+ }
+ /* 3G-WB*/
+ else if((code_type == 1) && (amr_path== 1 )) {
+ voice_mode = AVOICE_SOFT_3G_WB;
+ }
+ }
+ else
+ {
+ RLOGE("cc_voice_open unknown mode.\n");
+ goto error;
+ }
+
+#if defined(_USE_VOICE_ALSA) && defined(_USE_ALSA_AT_INTF)
+ if(0 != cc_voice_open_at(1,voice_mode)) {
+ goto error;
+ }
+#elif defined(_USE_VOICE_ALSA)
+ if(0 != cc_voice_open_api(1,voice_mode)) {
+ goto error;
+ }
+#endif
+
+ if(0 != cc_voice_mixer_config(0,T_OUTPUT_RECEIVER,T_AUDIO_OUTPUT_VOL_LEVEL_8, T_AUDIO_INPUT_VOL_LEVEL_8)) {
+ RLOGE("cc_voice_open cc_voice_mixer_config fail!\n");
+ goto error;
+ }
+ return 0;
+
+error:
+ cc_voice_close(op, mode, code_type, amr_path);
+ return 0;
+}
+
+int cc_voicechnl_handle(unsigned int op, unsigned int act, unsigned int codetype, unsigned int amrpath)
+{
+ if(1 == op) {
+ /* open pcm2 device. */
+ if(0 != cc_voice_open(op,act,codetype,amrpath)) {
+ RLOGE("cc_voicechnl_handle cc_voice_open failed.\n");
+ }
+ }
+ else {
+ /* close pcm2 device. */
+ cc_voice_close(op,act,codetype,amrpath);
+ }
+
+ return NULL;
+}
+static void notify_audio_closed(unsigned int callid)
+{
+ char *cmd;
+
+ if(asprintf(&cmd, "AT+ZIMSPLUS=%d,4\r\n", callid) < 0) {
+ RLOGE("notify_audio_closed asprintf fail");
+ return;
+ }
+
+ at_send_command(cmd, NULL);
+
+ free(cmd);
+}
+
static void sendCallStateChanged(void *param __unused)
{
RIL_onUnsolicitedResponse (
@@ -72,12 +317,15 @@
static int clccStateToRILState(int state, RIL_CallState *p_state)
{
switch(state) {
- case 0: *p_state = RIL_CALL_ACTIVE; return 0;
- case 1: *p_state = RIL_CALL_HOLDING; return 0;
- case 2: *p_state = RIL_CALL_DIALING; return 0;
- case 3: *p_state = RIL_CALL_ALERTING; return 0;
- case 4: *p_state = RIL_CALL_INCOMING; return 0;
- case 5: *p_state = RIL_CALL_WAITING; return 0;
+ case 0: *p_state = RIL_CALL_ACTIVE; return 0; /*»î¶¯ÖÐ*/
+ case 1: *p_state = RIL_CALL_HOLDING; return 0; /*±£³ÖÖÐ*/
+ case 2: *p_state = RIL_CALL_DIALING; return 0; /*²¦ºÅÖУ¨MOºô½Ð£©*/
+ case 3: *p_state = RIL_CALL_ALERTING; return 0; /*ÕñÁåÖУ¨MOºô½Ð£©*/
+ case 4: *p_state = RIL_CALL_INCOMING; return 0; /*À´µç½¨Á¢ÖУ¨MTºô½Ð£©*/
+ case 5: *p_state = RIL_CALL_WAITING; return 0; /*µÈ´ýÖÐ*/
+ case 6: return -1; /*ºô½Ð½áÊø*/
+ case 7: *p_state = RIL_CALL_INCOMING; return 0; /*À´µç½ÓÌýÖÐ*/
+ case 8: return -1; /*ºô½ÐÊÍ·ÅÖÐ*/
default: return -1;
}
}
@@ -88,37 +336,43 @@
*/
static int callFromCLCCLine(char *line, RIL_Call *p_call)
{
- //+CLCC: 1,0,2,0,0,\"+18005551212\",145
- // index,isMT,state,mode,isMpty(,number,TOA)?
-
+ /*[+CLCC: <id1>,<dir>,<stat>,<mode>,<mpty>[,<number>,<type>[,<alpha>[,<priority>]]] [<CR><LF>
+ +CLCC: <id2>,<dir>,<stat>,<mode>,<mpty>[,<number>,<type>[,<alpha>[,<priority>]]]
+ [...]]]
+ */
int err;
int state;
int mode;
err = at_tok_start(&line);
if (err < 0) goto error;
-
+ /*id*/
err = at_tok_nextint(&line, &(p_call->index));
if (err < 0) goto error;
- err = at_tok_nextbool(&line, &(p_call->isMT));
+ /*<dir>*/
+ err = at_tok_nextint(&line, &(p_call->isMT));
if (err < 0) goto error;
+ /*<state>*/
err = at_tok_nextint(&line, &state);
if (err < 0) goto error;
err = clccStateToRILState(state, &(p_call->state));
if (err < 0) goto error;
+ /*<mode>*/
err = at_tok_nextint(&line, &mode);
if (err < 0) goto error;
p_call->isVoice = (mode == 0);
+ /*<mpty>*/
err = at_tok_nextbool(&line, &(p_call->isMpty));
if (err < 0) goto error;
if (at_tok_hasmore(&line)) {
+ /*<number>*/
err = at_tok_nextstr(&line, &(p_call->number));
/* tolerate null here */
@@ -131,7 +385,7 @@
) {
p_call->number = NULL;
}
-
+ /*<type>*/
err = at_tok_nextint(&line, &p_call->toa);
if (err < 0) goto error;
}
@@ -150,125 +404,77 @@
void requestGetCurrentCalls(void *data __unused, size_t datalen __unused, RIL_Token t)
{
- int err;
- ATResponse *p_response;
- ATLine *p_cur;
+ ATResponse *response = NULL;
+ ATLine *p_cur;
int countCalls;
int countValidCalls;
- RIL_Call *p_calls;
- RIL_Call **pp_calls;
- int i;
+ RIL_Call *p_calls;
+ RIL_Call **pp_calls;
+ int i,
+ err;
int needRepoll = 0;
+ RIL_RadioState currentState = getRadioState();
-#ifdef WORKAROUND_ERRONEOUS_ANSWER
- int prevIncomingOrWaitingLine;
+ /* Android will call +CLCC to clean variable when RADIO_OFF, return radio_available directly */
+ if (currentState == RADIO_STATE_SIM_NOT_READY)
+ {
+ RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
+ goto exit;
+ }
- prevIncomingOrWaitingLine = s_incomingOrWaitingLine;
- s_incomingOrWaitingLine = -1;
-#endif /*WORKAROUND_ERRONEOUS_ANSWER*/
-
- err = at_send_command_multiline ("AT+CLCC", "+CLCC:", &p_response);
-
- if (err != 0 || p_response->success == 0) {
- RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
- return;
+ err = at_send_command_multiline("AT+CLCC", "+CLCC:", &response);
+ if (err < 0 )
+ {
+ RLOGD("ril_request_get_current_calls err= %d", err);
+ RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
+ at_response_free(response);
+ return;
+ }
+
+ if (response->success == 0)
+ {
+ goto error;
}
/* count the calls */
- for (countCalls = 0, p_cur = p_response->p_intermediates
- ; p_cur != NULL
- ; p_cur = p_cur->p_next
- ) {
+ for (countCalls = 0, p_cur = response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next)
+ {
countCalls++;
}
/* yes, there's an array of pointers and then an array of structures */
-
- pp_calls = (RIL_Call **)alloca(countCalls * sizeof(RIL_Call *));
- p_calls = (RIL_Call *)alloca(countCalls * sizeof(RIL_Call));
- memset (p_calls, 0, countCalls * sizeof(RIL_Call));
+ pp_calls = (RIL_Call * *) alloca(countCalls * sizeof(RIL_Call *));
+ p_calls = (RIL_Call *) alloca(countCalls * sizeof(RIL_Call));
+ memset(p_calls, 0, countCalls * sizeof(RIL_Call));
/* init the pointer array */
- for(i = 0; i < countCalls ; i++) {
+ for (i = 0; i < countCalls; i++)
+ {
pp_calls[i] = &(p_calls[i]);
}
- for (countValidCalls = 0, p_cur = p_response->p_intermediates
- ; p_cur != NULL
- ; p_cur = p_cur->p_next
- ) {
+ /* Analyze AT response and report */
+ for (countValidCalls = 0, p_cur = response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next)
+ {
err = callFromCLCCLine(p_cur->line, p_calls + countValidCalls);
-
- if (err != 0) {
+ if (err != 0)
+ {
continue;
}
-#ifdef WORKAROUND_ERRONEOUS_ANSWER
- if (p_calls[countValidCalls].state == RIL_CALL_INCOMING
- || p_calls[countValidCalls].state == RIL_CALL_WAITING
- ) {
- s_incomingOrWaitingLine = p_calls[countValidCalls].index;
- }
-#endif /*WORKAROUND_ERRONEOUS_ANSWER*/
-
- if (p_calls[countValidCalls].state != RIL_CALL_ACTIVE
- && p_calls[countValidCalls].state != RIL_CALL_HOLDING
- ) {
- needRepoll = 1;
- }
-
countValidCalls++;
}
-#ifdef WORKAROUND_ERRONEOUS_ANSWER
- // Basically:
- // A call was incoming or waiting
- // Now it's marked as active
- // But we never answered it
- //
- // This is probably a bug, and the call will probably
- // disappear from the call list in the next poll
- if (prevIncomingOrWaitingLine >= 0
- && s_incomingOrWaitingLine < 0
- && s_expectAnswer == 0
- ) {
- for (i = 0; i < countValidCalls ; i++) {
+ //current_call_num = countValidCalls;
- if (p_calls[i].index == prevIncomingOrWaitingLine
- && p_calls[i].state == RIL_CALL_ACTIVE
- && s_repollCallsCount < REPOLL_CALLS_COUNT_MAX
- ) {
- RLOGI(
- "Hit WORKAROUND_ERRONOUS_ANSWER case."
- " Repoll count: %d\n", s_repollCallsCount);
- s_repollCallsCount++;
- goto error;
- }
- }
- }
-
- s_expectAnswer = 0;
- s_repollCallsCount = 0;
-#endif /*WORKAROUND_ERRONEOUS_ANSWER*/
-
- RIL_onRequestComplete(t, RIL_E_SUCCESS, pp_calls,
- countValidCalls * sizeof (RIL_Call *));
-
- at_response_free(p_response);
-
-//#ifdef POLL_CALL_STATE
-// if (countValidCalls) { // We don't seem to get a "NO CARRIER" message from
- // smd, so we're forced to poll until the call ends.
-//#else
- if (needRepoll) {
-//#endif
- RIL_requestTimedCallback (sendCallStateChanged, NULL, &TIMEVAL_CALLSTATEPOLL);
- }
-
- return;
+ RIL_onRequestComplete(t, RIL_E_SUCCESS, pp_calls, countValidCalls * sizeof(RIL_Call *));
+
+ goto exit;
error:
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
- at_response_free(p_response);
+ //dtmf_end = 0;
+exit:
+ at_response_free(response);
}
void requestDial(void *data, size_t datalen __unused, RIL_Token t)
@@ -484,6 +690,45 @@
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
}
+
+void requestSetMute(void *data, size_t datalen, RIL_Token t)
+{
+ int mute;
+
+ int err;
+ ATResponse *p_response = NULL;
+
+ assert (datalen >= sizeof(int *));
+ mute = ((int *)data)[0];/*1-enable mute;0-disable mute*/
+ RLOGD("requestSetMute mute %d",mute);
+
+#ifdef USE_CAP_SUPPORT
+ if(0 != sc_audio_set_tx_voice_mute_state(mute)) {
+#else
+ if(1) {
+#endif
+ RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
+ return;
+ }
+ RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
+}
+
+void requestGetMute(void *data, size_t datalen, RIL_Token t)
+{
+ int mute = 0;
+
+#ifdef USE_CAP_SUPPORT
+ if(0 != sc_audio_get_tx_voice_mute_state(&mute)) {
+#else
+ if(1) {
+#endif
+ RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, mute, sizeof(mute));
+ return;
+ }
+ RLOGD("requestGetMute mute %d",mute);
+ RIL_onRequestComplete(t, RIL_E_SUCCESS, &mute, sizeof(mute));
+}
+
void handle_imsvmode (const char *s, const char *smsPdu)
{
char *line = s;
@@ -502,4 +747,77 @@
}
RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED, NULL, 0);
+}
+
+void handle_zimsplus(const char *s, const char *smsPdu)
+{
+ char *line = s;
+ unsigned int m,k;
+ int onOff;
+ int err;
+
+ err = at_tok_start(&line);
+ if (err < 0) {
+ RLOGE("handle_zimsplus at_tok_start err.");
+ assert(0);
+ }
+ err = at_tok_nextint(&line, &m);
+ if (err < 0) {
+ RLOGE("handle_zimsplus at_tok_nextint err.");
+ assert(0);
+ }
+ err = at_tok_nextint(&line, &k);
+ if (err < 0) {
+ RLOGE("handle_zimsplus at_tok_nextint err.");
+ assert(0);
+ }
+
+ if (m == 2) { /*֪ͨ¿ªÊ¼²¥·Å±¾µØÕñÁåÒô*/
+ cc_voice_play_ring_back();
+
+ onOff = 1;
+ RIL_onUnsolicitedResponse(RIL_UNSOL_RINGBACK_TONE, &onOff, sizeof(onOff));
+ }
+ else if (m == 3) { /*ֹ֪ͨͣ²¥·Å±¾µØÕñÁåÒô*/
+ cc_voice_stop_ring_back();
+
+ onOff = 0;
+ RIL_onUnsolicitedResponse(RIL_UNSOL_RINGBACK_TONE, &onOff, sizeof(onOff));
+ /* ·¢ËÍZIMSPLUS£¬·ÀÖ¹Volteºô½Ðʱ½µµ½SRCCʱÐÒéÕ»²»ÖªµÀ*/
+ notify_audio_closed(k);
+ }
+}
+
+void handle_zvoicechnl(const char *s, const char *smsPdu)
+{
+ char *line = s;
+ int err;
+ unsigned int op;
+ unsigned int act;
+ unsigned int codetype;
+ unsigned int amrpath;
+
+ /*+ZVOICECHNL: <op>,<act>,<CodeType>,<AmrPath>*/
+ err = at_tok_start(&line);
+ if (err < 0) {
+ assert(0);
+ }
+ err = at_tok_nextint(&line, &op);
+ if (err < 0) {
+ assert(0);
+ }
+ err = at_tok_nextint(&line, &act);
+ if (err < 0) {
+ assert(0);
+ }
+ err = at_tok_nextint(&line, &codetype);
+ if (err < 0) {
+ assert(0);
+ }
+ err = at_tok_nextint(&line, &amrpath);
+ if (err < 0) {
+ assert(0);
+ }
+
+ cc_voicechnl_handle(op,act,codetype,amrpath);
}
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ps.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ps.c
index c497ba5..66db9ab 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ps.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ps.c
@@ -57,6 +57,7 @@
#define NV_IP_LEN 128
char nv_pswan[NV_NAME_LEN];
+ char nv_pswan_cap[NV_NAME_LEN];
char nv_buf[NV_NAME_LEN];
char ip_addr_buf[NV_IP_LEN];
char ip_addr_buf1[NV_IP_LEN];
@@ -251,10 +252,15 @@
/*if(responses[i].cid == default_cid)*/ {
memset(nv_pswan, 0, sizeof(nv_pswan));
sc_cfg_get("pswan", nv_pswan, sizeof(nv_pswan));
-
+
/*set ifname*/
memset(nv_buf, 0, sizeof(nv_buf));
+#ifdef USE_CAP_SUPPORT
+ sc_cfg_get("pswan_cap", nv_pswan_cap, sizeof(nv_pswan_cap));
+ snprintf(nv_buf, sizeof(nv_buf), "%s%d", nv_pswan_cap, responses[i].cid);
+#else
snprintf(nv_buf, sizeof(nv_buf), "%s%d", nv_pswan, responses[i].cid);
+#endif
responses[i].ifname = alloca(strlen(nv_buf) + 1);
memset(responses[i].ifname, 0, strlen(nv_buf) + 1);
strncpy(responses[i].ifname, nv_buf, strlen(nv_buf));
@@ -264,7 +270,7 @@
/*set V4 addresses*/
memset(nv_buf, 0, sizeof(nv_buf));
memset(ip_addr_buf, 0, sizeof(ip_addr_buf));
- snprintf(nv_buf, sizeof(nv_buf), "%s%d_ip", nv_pswan, responses[i].cid);
+ snprintf(nv_buf, sizeof(nv_buf), "%s%d_pdp_ip", nv_pswan, responses[i].cid);
sc_cfg_get(nv_buf, ip_addr_buf, sizeof(ip_addr_buf) - 1);
if (0 != strncmp(ip_addr_buf, "0.0.0.0", NV_IP_LEN) && (0 != strncmp(ip_addr_buf, "", NV_IP_LEN))) {
@@ -293,8 +299,9 @@
snprintf(nv_buf, sizeof(nv_buf), "%s%d_secdns", nv_pswan, responses[i].cid);
sc_cfg_get(nv_buf, ip_addr_buf1, sizeof(ip_addr_buf1)-1);
- snprintf(ip_addr_buf, sizeof(ip_addr_buf)-1, "%s %s", ip_addr_buf, ip_addr_buf1);
- strncpy(responses[i].dnses, ip_addr_buf, strlen(ip_addr_buf));
+ memset(ip_addr_buf2, 0, sizeof(ip_addr_buf2));
+ snprintf(ip_addr_buf2, sizeof(ip_addr_buf2)-1, "%s %s", ip_addr_buf, ip_addr_buf1);
+ strncpy(responses[i].dnses, ip_addr_buf2, strlen(ip_addr_buf2));
}
}
@@ -303,7 +310,8 @@
memset(nv_buf, 0, sizeof(nv_buf));
memset(ip_addr_buf, 0, sizeof(ip_addr_buf));
- snprintf(nv_buf, sizeof(nv_buf), "%s%d_ipv6_ip", nv_pswan, responses[i].cid);
+ //snprintf(nv_buf, sizeof(nv_buf), "%s%d_ipv6_ip", nv_pswan, responses[i].cid);
+ snprintf(nv_buf, sizeof(nv_buf), "%s%d_ipv6_pdp", nv_pswan, responses[i].cid);
sc_cfg_get(nv_buf, ip_addr_buf, sizeof(ip_addr_buf) - 1);
if ((0 != strcmp(ip_addr_buf, "::")) && (0 != strcmp(ip_addr_buf, ""))) {
@@ -380,7 +388,7 @@
/*set mtu*/
memset(nv_buf, 0, sizeof(nv_buf));
sc_cfg_get("mtu", nv_buf, sizeof(nv_buf));
- responses[i].mtu = atoi(nv_buf);
+ responses[i].mtu = 1500;//atoi(nv_buf);
}
}
@@ -418,6 +426,7 @@
#define NV_IP_LEN 128
char nv_pswan[NV_NAME_LEN];
+ char nv_pswan_cap[NV_NAME_LEN];
char nv_buf[NV_NAME_LEN];
char ip_addr_buf[NV_IP_LEN];
char ip_addr_buf1[NV_IP_LEN];
@@ -468,12 +477,16 @@
responses->status = 0;
//get ip etc.
- memset(nv_pswan, 0, sizeof(nv_pswan));
+ memset(nv_pswan, 0, sizeof(nv_pswan));
sc_cfg_get("pswan", nv_pswan, sizeof(nv_pswan));
-
/*set ifname*/
memset(nv_buf, 0, sizeof(nv_buf));
+#ifdef USE_CAP_SUPPORT
+ sc_cfg_get("pswan_cap", nv_pswan_cap, sizeof(nv_pswan_cap));
+ snprintf(nv_buf, sizeof(nv_buf), "%s%d", nv_pswan_cap, responses->cid);
+#else
snprintf(nv_buf, sizeof(nv_buf), "%s%d", nv_pswan, responses->cid);
+#endif
responses->ifname = alloca(strlen(nv_buf) + 1);
memset(responses->ifname, 0, strlen(nv_buf) + 1);
strncpy(responses->ifname, nv_buf, strlen(nv_buf));
@@ -483,7 +496,7 @@
/*set V4 addresses*/
memset(nv_buf, 0, sizeof(nv_buf));
memset(ip_addr_buf, 0, sizeof(ip_addr_buf));
- snprintf(nv_buf, sizeof(nv_buf), "%s%d_ip", nv_pswan, responses->cid);
+ snprintf(nv_buf, sizeof(nv_buf), "%s%d_pdp_ip", nv_pswan, responses->cid);
sc_cfg_get(nv_buf, ip_addr_buf, sizeof(ip_addr_buf) - 1);
if (0 != strncmp(ip_addr_buf, "0.0.0.0", NV_IP_LEN) && (0 != strncmp(ip_addr_buf, "", NV_IP_LEN))) {
@@ -512,8 +525,9 @@
snprintf(nv_buf, sizeof(nv_buf), "%s%d_secdns", nv_pswan, responses->cid);
sc_cfg_get(nv_buf, ip_addr_buf1, sizeof(ip_addr_buf1)-1);
- snprintf(ip_addr_buf, sizeof(ip_addr_buf)-1, "%s %s", ip_addr_buf, ip_addr_buf1);
- strncpy(responses->dnses, ip_addr_buf, strlen(ip_addr_buf));
+ memset(ip_addr_buf2, 0, sizeof(ip_addr_buf2));
+ snprintf(ip_addr_buf2, sizeof(ip_addr_buf2)-1, "%s %s", ip_addr_buf, ip_addr_buf1);
+ strncpy(responses->dnses, ip_addr_buf2, strlen(ip_addr_buf2));
}
}
@@ -522,7 +536,8 @@
memset(nv_buf, 0, sizeof(nv_buf));
memset(ip_addr_buf, 0, sizeof(ip_addr_buf));
- snprintf(nv_buf, sizeof(nv_buf), "%s%d_ipv6_ip", nv_pswan, responses->cid);
+ //snprintf(nv_buf, sizeof(nv_buf), "%s%d_ipv6_ip", nv_pswan, responses->cid);
+ snprintf(nv_buf, sizeof(nv_buf), "%s%d_ipv6_pdp", nv_pswan, responses->cid);
sc_cfg_get(nv_buf, ip_addr_buf, sizeof(ip_addr_buf) - 1);
if ((0 != strcmp(ip_addr_buf, "::")) && (0 != strcmp(ip_addr_buf, ""))) {
@@ -598,7 +613,7 @@
/*set mtu*/
memset(nv_buf, 0, sizeof(nv_buf));
sc_cfg_get("mtu", nv_buf, sizeof(nv_buf));
- responses->mtu = atoi(nv_buf);
+ responses->mtu = 1500;//atoi(nv_buf);
RIL_onRequestComplete(t, RIL_E_SUCCESS, responses, sizeof(RIL_Data_Call_Response_v11));
@@ -681,7 +696,8 @@
void requestSetupDataCall(void *data, size_t datalen, RIL_Token t)
{
const char *apn = NULL;
- char *cmd;
+ char atstr[MAX_AT_LENGTH + 1];
+ char *cmd = atstr;
int err;
ATResponse *p_response = NULL;
int fd, qmistatus;
@@ -690,49 +706,108 @@
ssize_t written, rlen;
char status[32] = {0};
int retry = 10;
- const char *pdp_type;
- char pdptype[32] = {0};
+ const char *radio_technology = NULL;
+ const char *profile_type = NULL;
+ const char *pdp_type = NULL;
+ const char *authtype = NULL;
+ const char *username = NULL;
+ const char *password = NULL;
+ const char *challenge = NULL;
+ int auth_type = 0;
+ int profile = 0;
+ char pdptype[32] = {0};
+
if(NULL != data) {
- apn = ((const char **)data)[2];
- RLOGD("requesting data connection to APN '%s'", apn);
+ radio_technology = ((const char **) data)[0];
+ profile_type = ((const char **) data)[1];
+ apn = ((const char **)data)[2];
+ username = ((const char **)data)[3];
+ password = ((const char **)data)[4];
+ authtype = ((const char **)data)[5];
+ if(NULL != authtype) {
+ auth_type = atoi(authtype);
+ }
+ if(NULL != profile_type) {
+ profile = atoi(profile_type);
+ }
}
- if (datalen > 6 * sizeof(char *)) {
- pdp_type = ((const char **)data)[6];
+ if (datalen > 6 * sizeof(char *)) {
+ pdp_type = ((const char **)data)[6];/*"IP", "IPV6", "IPV4V6", or "PPP"*/
if(NULL == pdp_type) {
sc_cfg_get("pdp_type", pdptype, sizeof(pdptype));
pdp_type = pdptype;
}
else {
+ RLOGD("requesting data connection to pdp_type '%s'", pdp_type);
+
if( 0 == strncmp(pdp_type, "IP", strlen("IP")) ||
0 == strncmp(pdp_type, "IPV6", strlen("IPV6")) ||
0 == strncmp(pdp_type, "IPV4V6", strlen("IPV4V6"))) {
sc_cfg_set("pdp_type", pdp_type);
}
- }
- RLOGD("requesting data connection to pdp_type '%s'", pdp_type);
+ else if(0 == strncmp(pdp_type, "PPP", strlen("PPP"))) {
+ RLOGE("requesting data connection to pdp_type '%s' no support.", pdp_type);
+ goto error;
+ }
+ else {
+ RLOGE("requesting data connection to pdp_type '%s' no support.", pdp_type);
+ goto error;
+ }
+ }
} else {
sc_cfg_get("pdp_type", pdptype, sizeof(pdptype));
pdp_type = pdptype;
}
-
- /*AT+ZPDPACT=<Actcid>,<pdp_type>,[<APN>],<emergency?indication>,<P-CSCF_discovery>,<IM_CN_Signalling_Flag_Ind>*/
+ RLOGD("requestSetupDataCall: profile=%d,apn=%s,user=%s,passwd=%s,auth_type=%d,pdp_type=%s", \
+ profile, apn, username ? username : "NULL", password ? password : "NULL", auth_type, pdp_type);
+
+ memset(atstr, 0, sizeof(atstr));
+ /*AT+ZPDPACT=<cid>,<pdp_type>,<APN>[,<emergency indication>,<P-CSCF_discovery>,<IM_CN_Signalling_Flag_Ind>][,<auth_type>,\
+ <username>,<password>,<challenge>][,<ppp_cid>][,<default_flag>][,<act_type>] */
if(NULL != apn) {
- asprintf(&cmd, "AT+ZPDPACT=0,\"%s\",\"%s\",0,1,1", pdp_type, apn);
+ snprintf(cmd, sizeof(atstr)-1, "AT+ZPDPACT=0,\"%s\",\"%s\",,,,%d",pdp_type, apn, auth_type);
}
else {
- asprintf(&cmd, "AT+ZPDPACT=0,\"%s\",\"\",0,1,1", pdp_type);
+ asprintf(&cmd, "AT+ZPDPACT=0,\"%s\",\"\",,,,%d", pdp_type, auth_type);
}
- /*+ZPDPACT:<cid>,<pdp_type>[,<v4_addr>,<v4_gw>,<v4_dns1>,<v4_dns2>][,<v6_addr>,<v6_gw>,<v6_dns1>,<v6_dns2>]*/
- err = at_send_command_singleline_timeout(cmd, "+ZPDPACT:", &p_response, TIMEOUT_ZPDPACT);
- free(cmd);
+
+ cmd = atstr + strlen(atstr);
+ if(NULL == username) {
+ snprintf(cmd, sizeof(atstr)-strlen(atstr)-1, ",\"\"");
+ }
+ else {
+ snprintf(cmd, sizeof(atstr)-strlen(atstr)-1, ",\"%s\"", username);
+ }
+
+ cmd = atstr + strlen(atstr);
+ if(NULL == password) {
+ snprintf(cmd, sizeof(atstr)-strlen(atstr)-1, ",\"\"");
+ }
+ else {
+ snprintf(cmd, sizeof(atstr)-strlen(atstr)-1, ",\"%s\"", password);
+ }
+
+ cmd = atstr + strlen(atstr);
+ if(NULL == challenge) {
+ snprintf(cmd, sizeof(atstr)-strlen(atstr)-1, ",\"\"");
+ }
+ else {
+ snprintf(cmd, sizeof(atstr)-strlen(atstr)-1, ",\"%s\"", challenge);
+ }
+
+ cmd = atstr + strlen(atstr);
+ /*act_typeΪ¼¤»î×éÍøÀàÐÍ£¬0ΪAPºË±¾µØ²¦ºÅ,1ΪCAPºË±¾µØ²¦ºÅ,2ΪĬÈϲ¦ºÅ,Æô¶¯Ä¬ÈÏ·ÓÉ,É豸ËùÓÐÓ¦Óö¼¿ÉÒÔÖ±½ÓÉÏÍø,Ö»Äܲ¥Ò»Â·;*/
+ snprintf(cmd, sizeof(atstr)-strlen(atstr)-1, ",,,1");
+
+ err = at_send_command_singleline_timeout(atstr, "+ZPDPACT:", &p_response, TIMEOUT_ZPDPACT);
if (err < 0 || (p_response->success == 0)) {
RLOGE("requestSetupDataCall err:%d", err);
goto error;
}
- RLOGD("requestSetupDataCall %d", __LINE__);
+ /*+ZPDPACT:<cid>,<pdp_type>[,<v4_addr>,<v4_gw>,<v4_dns1>,<v4_dns2>][,<v6_addr>,<v6_gw>,<v6_dns1>,<v6_dns2>]*/
if(0 > parseSetupDataCall(p_response->p_intermediates->line, t)) {
goto error;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.c
index db8e807..9f21958 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.c
@@ -170,39 +170,6 @@
exit : at_response_free(response);
}
-void handle_zimsplus(const char *s, const char *smsPdu)
-{
- char *line = s;
- unsigned int m,k;
- int onOff;
- int err;
-
- err = at_tok_start(&line);
- if (err < 0) {
- RLOGE("handle_zimsplus at_tok_start err.");
- assert(0);
- }
- err = at_tok_nextint(&line, &m);
- if (err < 0) {
- RLOGE("handle_zimsplus at_tok_nextint err.");
- assert(0);
- }
- err = at_tok_nextint(&line, &k);
- if (err < 0) {
- RLOGE("handle_zimsplus at_tok_nextint err.");
- assert(0);
- }
-
- if (m == 2) { /*֪ͨ¿ªÊ¼²¥·Å±¾µØÕñÁåÒô*/
- onOff = 1;
- RIL_onUnsolicitedResponse(RIL_UNSOL_RINGBACK_TONE, &onOff, sizeof(onOff));
- }
- else if (m == 3) { /*ֹ֪ͨͣ²¥·Å±¾µØÕñÁåÒô*/
- onOff = 0;
- RIL_onUnsolicitedResponse(RIL_UNSOL_RINGBACK_TONE, &onOff, sizeof(onOff));
- }
-}
-
void handle_dsci(const char *s, const char *smsPdu)
{
return;
@@ -638,6 +605,12 @@
case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS:
ril_request_query_available_networks(data, datalen, t);
break;
+ case RIL_REQUEST_GET_MUTE:
+ requestGetMute(data, datalen, t);
+ break;
+ case RIL_REQUEST_SET_MUTE:
+ requestSetMute(data, datalen, t);
+ break;
default:
RLOGD("requestProc Request not supported.");
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.h
index 0a6766a..1c50ce6 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.h
@@ -134,7 +134,6 @@
/*********************************************/
/*ril_ref.c*/
-void handle_zimsplus(const char *s, const char *smsPdu);
void handle_dsci(const char *s, const char *smsPdu);
void handle_call_state_changed (const char *s, const char *smsPdu);
void handle_cmt (const char *s, const char *smsPdu);
@@ -201,8 +200,11 @@
void requestDtmf(void *data, size_t datalen, RIL_Token t);
void requestSetImsEnable(void *data, size_t datalen, RIL_Token t);
void requestImsRegistrationState(void *data, size_t datalen, RIL_Token t);
+void requestSetMute(void *data, size_t datalen, RIL_Token t);
+void requestGetMute(void *data, size_t datalen, RIL_Token t);
void handle_imsvmode (const char *s, const char *smsPdu);
-
+void handle_zimsplus(const char *s, const char *smsPdu);
+void handle_zvoicechnl(const char *s, const char *smsPdu);
/*ril_ps.c*/
void requestDataCallList(void *data, size_t datalen, RIL_Token t);
void onDataCallListChanged(void *param);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_sms.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_sms.c
index ec4d0ca..f953602 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_sms.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_sms.c
@@ -41,6 +41,8 @@
#include "at_utils.h"
#include "pstraceint.h"
#define __unused __attribute__((__unused__))
+#define MAX_SIM_PDU_LENGTH 164
+#define MAX_PDU_LENGTH 400
static int s_ims_cause_retry = 0; // 1==causes sms over ims to temp fail
static int s_ims_cause_perm_failure = 0; // 1==causes sms over ims to permanent fail
@@ -48,8 +50,78 @@
static int s_ims_gsm_fail = 0; // 1==causes sms over gsm to permanent fail
+static void ril_handle_cmd_send_sms_timeout(const char *cmd, const char *smsPdu, const char *prefix, RIL_Token token, long long timeoutMS)
+{
+ ATResponse *response = NULL;
+ int err;
+ RIL_SMS_Response result;
+ char *line;
+
+ err = at_send_command_sms_timeout(cmd, smsPdu, prefix, &response, timeoutMS);
+ if (err < 0 || (response->success == 1 && !response->p_intermediates))
+ {
+ goto error;
+ }
+ else if (response->success == 0)
+ {
+ goto cms_error;
+ }
+ line = response->p_intermediates->line;
+ memset(&result, 0, sizeof(result));
+ err = at_tok_start(&line);
+ DO_ERROR_JDUGE;
+
+ err = at_tok_nextint(&line, &(result.messageRef));
+ DO_ERROR_JDUGE;
+ if (at_tok_hasmore(&line))
+ {
+ err = at_tok_nextstr(&line, &(result.ackPDU));
+ DO_ERROR_JDUGE;
+ }
+ RIL_onRequestComplete(token, RIL_E_SUCCESS, &result, sizeof(result));
+ goto exit;
+cms_error:
+ if (at_get_cms_error(response) == CMS_NW_TIMEOUT)
+ {
+ RIL_onRequestComplete(token, RIL_E_SMS_SEND_FAIL_RETRY, NULL, 0);
+ goto exit;
+ }
+error:
+ RIL_onRequestComplete(token, RIL_E_GENERIC_FAILURE, NULL, 0);
+exit:
+ at_response_free(response);
+}
+static void ril_request_send_sms(void *data, size_t datalen __unused, RIL_Token token)
+{
+ char cmdString[MAX_AT_LENGTH];
+ char smsPdu[MAX_PDU_LENGTH];
+ const char *smsc, *tpdu;
+ int tpLayerLength;
+ char temp[20];
+ int err;
+
+ /*if(1 == get_send_multisms_flag())
+ {
+ err = at_send_command("AT+CMMS=1", NULL);
+ }*/
+ smsc = ((const char * *) data)[0];
+ tpdu = ((const char * *) data)[1];
+ tpLayerLength = strlen(tpdu) / 2;
+ if (smsc == NULL)
+ {
+ smsc = "00";
+ }
+
+ sprintf(temp, "AT+CMGS=%d", tpLayerLength);
+ strcpy(cmdString, temp);
+ sprintf(smsPdu, "%s%s", smsc, tpdu);
+ ril_handle_cmd_send_sms_timeout(cmdString, smsPdu, "+CMGS:", token, TIMEOUT_CMGS);
+}
+
+
void requestSendSMS(void *data, size_t datalen, RIL_Token t)
{
+#if 0
int err;
const char *smsc;
const char *pdu;
@@ -118,6 +190,9 @@
RIL_onRequestComplete(t, RIL_E_SMS_SEND_FAIL_RETRY, &response, sizeof(response));
at_response_free(p_response);
return;
+#else
+ ril_request_send_sms(data, datalen, t);
+#endif
}
void requestImsSendSMS(void *data, size_t datalen, RIL_Token t)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/rild/radiooptions.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/rild/radiooptions.c
index 66b24d5..7326bf0 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/rild/radiooptions.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/rild/radiooptions.c
@@ -24,148 +24,188 @@
#define SOCKET_NAME_RIL2_DEBUG "rild2-debug"
enum options {
- RADIO_RESET, /*radiooptions 0 0 0*/
- RADIO_OFF, /*radiooptions 1 1 0*/
- UNSOL_NETWORK_STATE_CHANGE,
- OEM_HOOK_RAW,
- QXDM_DISABLE,
- RADIO_ON, /*radiooptions 5 1 0*/
- SETUP_PDP, /*radiooptions 6 "testapn" 1 0*/
- DEACTIVATE_PDP, /*radiooptions 7 cid 1 0*/
- DIAL_CALL, /*radiooptions 8 "10086" 1 0*/
- ANSWER_CALL, /*radiooptions 9 1 0*/
- END_CALL, /*radiooptions 10 1 0*/
- GET_SIM_STATUS, /*radiooptions 11 1 0*/
- GET_PREFERRED_NETWORK_TYPE, /*radiooptions 12 1 0*/
- SET_PREFERRED_NETWORK_TYPE_LTE, /*radiooptions 13 1 0*///LTE ONLY
- SET_PREFERRED_NETWORK_TYPE, /*radiooptions 14 1 0*///GSM ONLY
- /*radiooptions 14 type 1 0*///type:RIL_PreferredNetworkType
- SETUP_DATA_CALL, /*radiooptions 15 "IPV6" 1 0*/
- DATA_CALL_LIST, /*radiooptions 16 1 0*/
- REGISTRATION_STATE, /*radiooptions 17 "data" 1 0*///"data":DATA_REGISTRATION_STATE
- /*radiooptions 17 "voice" 1 0*///"voice":VOICE_REGISTRATION_STATE
- /*radiooptions 17 1 0*///VOICE_REGISTRATION_STATE
+ /*radiooptions 0 1 0*/
+ RADIO_OFF = 0,
+ /*radiooptions 1 1 0*/
+ RADIO_ON = 1,
+ /*radiooptions 2 atcmd 1 0*/
+ OEM_HOOK_RAW = 2,
+ /*radiooptions 3 "testapn" 1 0*/
+ SETUP_PDP = 3,
+ /*radiooptions 4 cid 1 0*/
+ DEACTIVATE_PDP = 4,
+ /*radiooptions 5 "IPV6" 1 0*/
+ SETUP_DATA_CALL = 5,
+ /*radiooptions 6 1 0*/
+ DATA_CALL_LIST = 6,
+ /*radiooptions 7 "10086" 1 0*/
+ DIAL_CALL = 7,
+ /*radiooptions 8 1 0*/
+ ANSWER_CALL = 8,
+ /*radiooptions 9 callid 1 0*/
+ END_CALL = 9,
+ /*radiooptions 10 1 0*/
+ GET_CURRENT_CALLS = 10,
+ /*radiooptions 11 1 0*/
+ REQUEST_UDUB = 11,
+ /*radiooptions 12 c 1 0*/
+ REQUEST_DTMF = 12,
+ /*radiooptions 13 mute 1 0*/
+ SET_MUTE = 13,
+ /*radiooptions 14 1 0*/
+ GET_MUTE = 14,
+ /*radiooptions 15 "1"/"0" 1 0*/
+ SET_IMS_ENABLE = 15,
+ /*radiooptions 16 1 0*/
+ GET_SIM_STATUS = 16,
+ /*radiooptions 17 1 0*/
+ DEVICE_IDENTITY = 17,
+ /*radiooptions 18 1 0*/
+ QUERY_ICCID = 18,
+ /*radiooptions 19 1 0*/
+ OPERATOR = 19,
+ /*radiooptions 20 1 0*/
+ GET_PREFERRED_NETWORK_TYPE = 20,
+ /*radiooptions 21 1 0*///GSM ONLY
+ /*radiooptions 21 type 1 0*///type:RIL_PreferredNetworkType
+ SET_PREFERRED_NETWORK_TYPE = 21,
+ /*radiooptions 22 1 0*///LTE ONLY
+ SET_PREFERRED_NETWORK_TYPE_LTE = 22,
+ /*radiooptions 23 1 0*/
+ QUERY_NETWORK_SELECTION_MODE = 23,
+ /*radiooptions 24 1 0*/
+ SET_NETWORK_SELECTION_AUTOMATIC = 24,
+ /*radiooptions 25 1 0*/
+ SET_NETWORK_SELECTION_MANUAL = 25,
+ /*radiooptions 26 "data" 1 0*///"data":DATA_REGISTRATION_STATE
+ /*radiooptions 26 "voice" 1 0*///"voice":VOICE_REGISTRATION_STATE
+ /*radiooptions 26 1 0*///VOICE_REGISTRATION_STATE
+ REGISTRATION_STATE = 26,
- GET_CURRENT_CALLS, /*radiooptions 18 1 0*/
- SEND_SMS, /*radiooptions 19 1 0*/
- /*radiooptions 19 pdu 1 0*/
- /*radiooptions 19 smsc(00) pdu 1 0*/
- SMS_ACKNOWLEDGE, /*radiooptions 20 1 0*/
- WRITE_SMS_TO_SIM, /*radiooptions 21 1 0*/
- DELETE_SMS_ON_SIM, /*radiooptions 22 1 0*/
- OPERATOR, /*radiooptions 23 1 0*/
- QUERY_NETWORK_SELECTION_MODE, /*radiooptions 24 1 0*/
- SET_NETWORK_SELECTION_AUTOMATIC, /*radiooptions 25 1 0*/
- SET_NETWORK_SELECTION_MANUAL, /*radiooptions 26 1 0*/
- VOICE_RADIO_TECH, /*radiooptions 27 1 0*/
- SIGNAL_STRENGTH, /*radiooptions 28 1 0*/
- DEVICE_IDENTITY, /*radiooptions 29 1 0*/
- QUERY_ICCID, /*radiooptions 30 1 0*/
- GET_CELL_INFO_LIST, /*radiooptions 31 1 0*/
- SET_IMS_ENABLE, /*radiooptions 32 "1"/"0" 1 0*/
- GET_SMSC_ADDRESS, /*radiooptions 33 1 0*/
- SET_SMSC_ADDRESS, /*radiooptions 34 smsc 1 0*/
- QUERY_FACILITY_LOCK, /*radiooptions 35 fac 1 0*/
- QUERY_AVAILABLE_NETWORKS, /*radiooptions 36 1 0*/
- REQUEST_UDUB, /*radiooptions 37 1 0*/
- REQUEST_DTMF, /*radiooptions 38 c 1 0*/
- SET_UNSOL_CELL_INFO_LIST_RATE, /*radiooptions 39 t 1 0*/
+ /*radiooptions 27 1 0*/
+ QUERY_AVAILABLE_NETWORKS = 27,
+ /*radiooptions 28 1 0*/
+ VOICE_RADIO_TECH = 28,
+ /*radiooptions 29 1 0*/
+ SIGNAL_STRENGTH = 29,
+ /*radiooptions 30 1 0*/
+ GET_CELL_INFO_LIST = 30,
+ /*radiooptions 31 t 1 0*/
+ SET_UNSOL_CELL_INFO_LIST_RATE = 31,
+ /*radiooptions 32 1 0*/
+ /*radiooptions 32 pdu 1 0*/
+ /*radiooptions 32 smsc(00) pdu 1 0*/
+ SEND_SMS = 32,
+ /*radiooptions 33 1 0*/
+ SMS_ACKNOWLEDGE = 33,
+ /*radiooptions 34 1 0*/
+ GET_SMSC_ADDRESS = 34,
+ /*radiooptions 35 smsc 1 0*/
+ SET_SMSC_ADDRESS = 35,
+
+ /*radiooptions 38 fac 1 0*/
+ QUERY_FACILITY_LOCK = 38,
+ /*radiooptions 39 fac act passwd 1 0*/
+ SET_FACILITY_LOCK = 39,
+ /*radiooptions 40 pin 1 0*/
+ ENTER_SIM_PIN = 40,
+
};
char *options_arrays[] = {
- "RADIO_RESET",
- "RADIO_OFF",
- "UNSOL_NETWORK_STATE_CHANGE",
- "OEM_HOOK_RAW",
- "QXDM_ENABLE",
- "RADIO_ON",
- "SETUP_PDP",
- "DEACTIVATE_PDP",
- "DIAL_CALL",
- "ANSWER_CALL",
- "END_CALL",
- "GET_SIM_STATUS",
- "GET_PREFERRED_NETWORK_TYPE",
- "SET_PREFERRED_NETWORK_TYPE_LTE",
- "SET_PREFERRED_NETWORK_TYPE",
- "SETUP_DATA_CALL",
- "DATA_CALL_LIST",
- "REGISTRATION_STATE",
- "GET_CURRENT_CALLS",
- "SEND_SMS",
- "SMS_ACKNOWLEDGE",
- "WRITE_SMS_TO_SIM",
- "DELETE_SMS_ON_SIM",
- "OPERATOR",
- "QUERY_NETWORK_SELECTION_MODE",
- "SET_NETWORK_SELECTION_AUTOMATIC",
- "SET_NETWORK_SELECTION_MANUAL",
- "VOICE_RADIO_TECH",
- "SIGNAL_STRENGTH",
- "DEVICE_IDENTITY",
- "QUERY_ICCID",
- "GET_CELL_INFO_LIST",
- "SET_IMS_ENABLE",
- "GET_SMSC_ADDRESS",
- "SET_SMSC_ADDRESS",
- "QUERY_FACILITY_LOCK",
- "QUERY_AVAILABLE_NETWORKS",
- "REQUEST_UDUB",
- "REQUEST_DTMF",
- "SET_UNSOL_CELL_INFO_LIST_RATE",
+ "RADIO_OFF",// = 0,
+ "RADIO_ON",// = 1,
+ "OEM_HOOK_RAW",// = 2,
+ "SETUP_PDP",// = 3,
+ "DEACTIVATE_PDP",// = 4,
+ "SETUP_DATA_CALL",// = 5,
+ "DATA_CALL_LIST",// = 6,
+ "DIAL_CALL",// = 7,
+ "ANSWER_CALL",// = 8,
+ "END_CALL",// = 9,
+ "GET_CURRENT_CALLS",// = 10,
+ "REQUEST_UDUB",// = 11,
+ "REQUEST_DTMF",// = 12,
+ "SET_MUTE",// = 13,
+ "GET_MUTE",// = 14,
+ "SET_IMS_ENABLE",// = 15,
+ "GET_SIM_STATUS",// = 16,
+ "DEVICE_IDENTITY",// = 17,
+ "QUERY_ICCID",// = 18,
+ "OPERATOR",// = 19,
+ "GET_PREFERRED_NETWORK_TYPE",// = 20,
+ "SET_PREFERRED_NETWORK_TYPE",// = 21,
+ "SET_PREFERRED_NETWORK_TYPE_LTE",// = 22,
+ "QUERY_NETWORK_SELECTION_MODE",// = 23,
+ "SET_NETWORK_SELECTION_AUTOMATIC",// = 24,
+ "SET_NETWORK_SELECTION_MANUAL",// = 25,
+ "REGISTRATION_STATE",// = 26,
+ "QUERY_AVAILABLE_NETWORKS",// = 27,
+ "VOICE_RADIO_TECH",// = 28,
+ "SIGNAL_STRENGTH",// = 29,
+ "GET_CELL_INFO_LIST",// = 30,
+ "SET_UNSOL_CELL_INFO_LIST_RATE",// = 31,
+ "SEND_SMS",// = 32,
+ "SMS_ACKNOWLEDGE",// = 33,
+ "GET_SMSC_ADDRESS",// = 34,
+ "SET_SMSC_ADDRESS",// = 35,
+ "UNKNOW",// = 36,
+ "UNKNOW",// = 37,
+ "QUERY_FACILITY_LOCK",// = 38,
+ "SET_FACILITY_LOCK",// = 39
+ "ENTER_SIM_PIN",// = 40
};
static void print_usage() {
perror("Usage: radiooptions [option] [extra_socket_args]\n\
- 0 - RADIO_RESET, \n\
- 1 - RADIO_OFF, \n\
- 2 - UNSOL_NETWORK_STATE_CHANGE, \n\
- 3 atcmd - OEM_HOOK_RAW, \n\
- 4 - QXDM_DISABLE, \n\
- 5 - RADIO_ON, \n\
- 6 apn- SETUP_PDP apn, \n\
- 7 cid - DEACTIVE_PDP, \n\
- 8 number - DIAL_CALL number, \n\
- 9 - ANSWER_CALL, \n\
- 10 - END_CALL \n\
- 11 - GET_SIM_STATUS \n\
- 12 - GET_PREFERRED_NETWORK_TYPE \n\
- 13 - SET_PREFERRED_NETWORK_TYPE_LTE \n\
- 14 - SET_PREFERRED_NETWORK_TYPE_GSM \n\
- 14 type - SET_PREFERRED_NETWORK_TYPE \n\
- 15 pdptype - SETUP_DATA_CALL pdptype, \n\
- 16 - DATA_CALL_LIST \n\
- 17 data - DATA_REGISTRATION_STATE \n\
- 17 voice - VOICE_REGISTRATION_STATE \n\
- 17 - VOICE_REGISTRATION_STATE \n\
- 18 - GET_CURRENT_CALLS \n\
- 19 - SEND_SMS \n\
- 19 pdu - SEND_SMS \n\
- 19 smsc pdu - SEND_SMS \n\
- 20 - SMS_ACKNOWLEDGE \n\
- 21 - WRITE_SMS_TO_SIM \n\
- 22 index - DELETE_SMS_ON_SIM \n\
- 23 - OPERATOR \n\
- 24 - QUERY_NETWORK_SELECTION_MODE \n\
- 25 - SET_NETWORK_SELECTION_AUTOMATIC \n\
- 26 - SET_NETWORK_SELECTION_MANUAL \n\
- 27 - VOICE_RADIO_TECH \n\
- 28 - SIGNAL_STRENGTH \n\
- 29 - DEVICE_IDENTITY \n\
- 30 - QUERY_ICCID \n\
- 31 - GET_CELL_INFO_LIST \n\
- 32 1/0 - SET_IMS_ENABLE \n\
- 33 - GET_SMSC_ADDRESS \n\
- 34 smsc - SET_SMSC_ADDRESS \n\
- 35 fac - QUERY_FACILITY_LOCK \n\
- 36 - QUERY_AVAILABLE_NETWORKS \n\
- 37 - REQUEST_UDUB \n\
- 38 - REQUEST_DTMF \n\
- 39 time - SET_UNSOL_CELL_INFO_LIST_RATE \n\
+ 0 - RADIO_OFF, \n\
+ 1 - RADIO_ON, \n\
+ 2 atcmd - OEM_HOOK_RAW, \n\
+ 3 apn- SETUP_PDP apn, \n\
+ 4 cid - DEACTIVE_PDP, \n\
+ 5 pdptype - SETUP_DATA_CALL pdptype, \n\
+ 6 - DATA_CALL_LIST \n\
+ 7 number - DIAL_CALL number, \n\
+ 8 - ANSWER_CALL, \n\
+ 9 callid - END_CALL \n\
+ 10 - GET_CURRENT_CALLS \n\
+ 11 - REQUEST_UDUB \n\
+ 12 - REQUEST_DTMF \n\
+ 13 mute - SET_MUTE \n\
+ 14 - GET_MUTE \n\
+ 15 1/0 - SET_IMS_ENABLE \n\
+ 16 - GET_SIM_STATUS \n\
+ 17 - DEVICE_IDENTITY \n\
+ 18 - QUERY_ICCID \n\
+ 19 - OPERATOR \n\
+ 20 - GET_PREFERRED_NETWORK_TYPE \n\
+ 21 type - SET_PREFERRED_NETWORK_TYPE \n\
+ 21 - SET_PREFERRED_NETWORK_TYPE_GSM \n\
+ 22 - SET_PREFERRED_NETWORK_TYPE_LTE \n\
+ 23 - QUERY_NETWORK_SELECTION_MODE \n\
+ 24 - SET_NETWORK_SELECTION_AUTOMATIC \n\
+ 25 - SET_NETWORK_SELECTION_MANUAL \n\
+ 26 - VOICE_REGISTRATION_STATE \n\
+ 26 data - DATA_REGISTRATION_STATE \n\
+ 26 voice - VOICE_REGISTRATION_STATE \n\
+ 27 - QUERY_AVAILABLE_NETWORKS \n\
+ 28 - VOICE_RADIO_TECH \n\
+ 29 - SIGNAL_STRENGTH \n\
+ 30 - GET_CELL_INFO_LIST \n\
+ 31 time - SET_UNSOL_CELL_INFO_LIST_RATE \n\
+ 32 - SEND_SMS \n\
+ 32 pdu - SEND_SMS \n\
+ 32 smsc pdu - SEND_SMS \n\
+ 33 - SMS_ACKNOWLEDGE \n\
+ 34 - GET_SMSC_ADDRESS \n\
+ 35 smsc - SET_SMSC_ADDRESS \n\
+ 38 fac - QUERY_FACILITY_LOCK \n\
+ 39 fac act passwd - SET_FACILITY_LOCK \n\
+ 40 pin - ENTER_SIM_PIN \n\
The argument before the last one must be SIM slot \n\
- 0 - SIM1, \n\
- 1 - SIM2, \n\
- 2 - SIM3, \n\
- 3 - SIM4, \n\
+ 1 - SIM1, \n\
+ 2 - SIM2, \n\
+ 3 - SIM3, \n\
+ 4 - SIM4, \n\
The last argument must be modem-socket style \n\
0 - one modem for one debug-socket, \n\
1 - one modem for multiple debug socket \n");
@@ -175,8 +215,11 @@
if (argc < 2) {
return -1;
}
- const int option = atoi(argv[1]);
- if (option < 0 || option > 10 || option == DEACTIVATE_PDP) {
+ else {
+ return 0;
+ }
+ /*const int option = atoi(argv[1]);
+ if (option < 0 || option > 10 || option == DEACTIVATE_PDP || option == END_CALL) {
return 0;
} else if ((option == DIAL_CALL || option == SETUP_PDP || option == SETUP_DATA_CALL) && argc == 5) {
return 0;
@@ -189,7 +232,7 @@
else if( option == DELETE_SMS_ON_SIM) {
return 0;
}
- return -1;
+ return -1;*/
}
static int get_number_args(int argc, char *argv[]) {
@@ -222,6 +265,7 @@
print_usage();
exit(-1);
}
+#if 0
modem_socket_type = atoi(argv[(num_socket_args-1)]);
sim_id = atoi(argv[(num_socket_args-2)]);
memset(socket_name, 0, sizeof(char)*20);
@@ -230,7 +274,10 @@
} else if (sim_id == 1) {
strncpy(socket_name, SOCKET_NAME_RIL2_DEBUG, 19);
}
-
+#else
+ memset(socket_name, 0, sizeof(socket_name));
+ strncpy(socket_name, SOCKET_NAME_RIL_DEBUG, sizeof(socket_name) - 1);
+#endif
fd = socket_local_client(socket_name,
ANDROID_SOCKET_NAMESPACE_RESERVED,
SOCK_STREAM);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/adctest/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/adctest/Makefile
new file mode 100644
index 0000000..eed53fb
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/adctest/Makefile
@@ -0,0 +1,34 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = adctest
+OBJS = adctest.o
+
+CFLAGS += -g -Werror=implicit-function-declaration
+
+
+LDLIBS = -lpthread -lm
+#LDLIBS += -lnvram
+LDLIBS += -lbsp -L$(zte_lib_path)/libbsp
+#LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) $(EXEC)_recovery *.elf *.gdb *.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/adctest/adctest.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/adctest/adctest.c
new file mode 100644
index 0000000..825e699
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/adctest/adctest.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "sc_adc.h"
+
+int main(int argc, char *argv[])
+{
+ int vol = 0;
+ vol = sc_adc_show(ADC0);
+ printf("adc 0 vol = %d\n",vol);
+ vol = sc_adc_show(ADC1);
+ printf("adc 0 vol = %d\n",vol);
+ vol = sc_adc_show(ADC2);
+ printf("adc 0 vol = %d\n",vol);
+
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc/crc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc/crc.c
index ee14405..7fd7af9 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc/crc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc/crc.c
@@ -329,7 +329,23 @@
}
+static void com_SetIO_Para(int32_t iFdCom)
+{
+ struct termios tOldTermios = {0};
+ bzero(&tOldTermios, sizeof(tOldTermios));
+ tcgetattr(iFdCom, &tOldTermios); // get the serial port attributions
+ tOldTermios.c_iflag &= ~(ICRNL | IXON);
+ tOldTermios.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ISIG);
+ tOldTermios.c_oflag &= ~OPOST;
+ if(tcsetattr(iFdCom, TCSANOW, &tOldTermios) != 0) //设置新属性, TCSANOW: 所由改变立即生效
+ {
+ printf("Set TimeOut error. iFd == %d\n", iFdCom);
+ return;
+ }
+ tcflush(iFdCom, TCIOFLUSH);
+ printf("com_SetIO_Para over.\n");
+}
static int zUP_SetPort_0(int32_t iFd ,int ctsrts_en, int iBaud, int iDelay)
{
com_SetBaud(iFd, iBaud);
@@ -338,6 +354,7 @@
//com_SetParity(iFd, 'O');
com_SetnStop(iFd,1);
com_SetCtrl(iFd,ctsrts_en); //add flow control
+ com_SetIO_Para(iFd);
com_SetTimeOut(iFd,iDelay); //timeout 100ms
printf("set serial port done!\n");
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_api/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_api/Makefile
new file mode 100755
index 0000000..bcfbf24
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_api/Makefile
@@ -0,0 +1,38 @@
+#*******************************************************************************
+# include build/common makefile
+# ÒÔÉú³ÉÁ½¸öÓ¦ÓÃΪÀý£¬Èç¹ûÖ»ÓÐÒ»¸öɾ³ýEXEC2 OBJS2¼´¿É
+#*******************************************************************************
+include $(COMMON_MK)
+
+EXEC = crc_api
+OBJS = crc_api.o
+#EXEC ÌØÓеÄLIB²ÎÊý
+#LDLIBS_demo1 = -lnvram -L$(LIB_DIR)/libnvram
+
+#EXEC2 = demo2
+#OBJS2 = demo2.o
+#EXEC2 ÌØÓеÄLIB²ÎÊý
+#LDLIBS_demo2 = -lsoft_timer -L$(LIB_DIR)/libsoft_timer
+
+#ºêºÍÍ·ÎļþĿ¼ÔÚCFLAGSÀﶨÒ壬ҪÓÃ+=,²»ÒªÓÃ=,·ñÔò»á¸²¸ÇCOMMON_MKÀïµÄÖµ
+#CFLAGS += -I$(APP_DIR)/include
+CFLAGS += -g -Werror=implicit-function-declaration
+
+#EXEC EXEC2 ¹«¹²LIB²ÎÊý£¬µÚÒ»Ðж¨ÒåLDLIBSÓÃ=£¬²»ÒªÓÃ+=,Ó¦ÓÃÁ¬½ÓµÄ¿â¶¼ÔÚ±¾Makefile¶¨Òå
+LDLIBS = -lpthread -lm
+LDLIBS += -lbsp
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+######## $(ROMFSINST) $(EXEC2) /bin/$(EXEC2)
+
+clean:
+ -@rm -f $(EXEC) $(EXEC)_recovery *.elf *.gdb *.o
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_api/crc_api.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_api/crc_api.c
new file mode 100755
index 0000000..a15d226
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_api/crc_api.c
@@ -0,0 +1,316 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <netinet/in.h>
+#include <linux/sockios.h>
+//#include <cfg_api.h>
+#include <termios.h>
+#include <sys/prctl.h>
+#include <pthread.h>
+#include <assert.h>
+#include <sys/select.h>
+#include "sc_uart.h"
+
+#define UART_DEV "/dev/ttyS0"
+#define ONE_LEN 4095
+#define BUAD_RATE B_115200
+
+typedef unsigned int uint32_t;
+typedef unsigned char uint8_t;
+
+int uart_fd_0 = -1;
+int uart_fd_1 = -1;
+int times = 0;
+int tlen = 0;
+uint8_t dbuf[2100000];
+SC_UART_ATTR attr_set = {.baudrate = BUAD_RATE,
+ .databit = DB_CS8,
+ .stopbit = SB_1,
+ .parity = PB_NONE,
+ .flowctrl = FC_NONE,};
+
+static const uint8_t crc_table[] =
+{
+ 0x00,0x31,0x62,0x53,0xc4,0xf5,0xa6,0x97,0xb9,0x88,0xdb,0xea,0x7d,0x4c,0x1f,0x2e,
+ 0x43,0x72,0x21,0x10,0x87,0xb6,0xe5,0xd4,0xfa,0xcb,0x98,0xa9,0x3e,0x0f,0x5c,0x6d,
+ 0x86,0xb7,0xe4,0xd5,0x42,0x73,0x20,0x11,0x3f,0x0e,0x5d,0x6c,0xfb,0xca,0x99,0xa8,
+ 0xc5,0xf4,0xa7,0x96,0x01,0x30,0x63,0x52,0x7c,0x4d,0x1e,0x2f,0xb8,0x89,0xda,0xeb,
+ 0x3d,0x0c,0x5f,0x6e,0xf9,0xc8,0x9b,0xaa,0x84,0xb5,0xe6,0xd7,0x40,0x71,0x22,0x13,
+ 0x7e,0x4f,0x1c,0x2d,0xba,0x8b,0xd8,0xe9,0xc7,0xf6,0xa5,0x94,0x03,0x32,0x61,0x50,
+ 0xbb,0x8a,0xd9,0xe8,0x7f,0x4e,0x1d,0x2c,0x02,0x33,0x60,0x51,0xc6,0xf7,0xa4,0x95,
+ 0xf8,0xc9,0x9a,0xab,0x3c,0x0d,0x5e,0x6f,0x41,0x70,0x23,0x12,0x85,0xb4,0xe7,0xd6,
+ 0x7a,0x4b,0x18,0x29,0xbe,0x8f,0xdc,0xed,0xc3,0xf2,0xa1,0x90,0x07,0x36,0x65,0x54,
+ 0x39,0x08,0x5b,0x6a,0xfd,0xcc,0x9f,0xae,0x80,0xb1,0xe2,0xd3,0x44,0x75,0x26,0x17,
+ 0xfc,0xcd,0x9e,0xaf,0x38,0x09,0x5a,0x6b,0x45,0x74,0x27,0x16,0x81,0xb0,0xe3,0xd2,
+ 0xbf,0x8e,0xdd,0xec,0x7b,0x4a,0x19,0x28,0x06,0x37,0x64,0x55,0xc2,0xf3,0xa0,0x91,
+ 0x47,0x76,0x25,0x14,0x83,0xb2,0xe1,0xd0,0xfe,0xcf,0x9c,0xad,0x3a,0x0b,0x58,0x69,
+ 0x04,0x35,0x66,0x57,0xc0,0xf1,0xa2,0x93,0xbd,0x8c,0xdf,0xee,0x79,0x48,0x1b,0x2a,
+ 0xc1,0xf0,0xa3,0x92,0x05,0x34,0x67,0x56,0x78,0x49,0x1a,0x2b,0xbc,0x8d,0xde,0xef,
+ 0x82,0xb3,0xe0,0xd1,0x46,0x77,0x24,0x15,0x3b,0x0a,0x59,0x68,0xff,0xce,0x9d,0xac
+};
+
+uint8_t fibo_crc_calc( uint8_t *datain,uint32_t datalen)
+{
+ uint8_t *input = (uint8_t*)datain;
+ uint8_t fcs = (uint8_t)0xFF;
+ int32_t i;
+ for (i = 0; i < (int32_t)datalen; i++)
+ fcs = crc_table[fcs ^ (uint8_t)input[i]];
+
+ return (uint8_t) (0xFF - fcs);
+
+}
+
+void int_handle(int signo)
+{
+ if(signo == SIGINT)
+ {
+ printf("recv signal\n");
+ exit(1);
+ }
+}
+
+int32_t com_Convbaud(uint32_t iBaudrate)
+{
+ switch(iBaudrate)
+ {
+ case 4800:
+ return B_4800;
+ case 9600:
+ return B_9600;
+ case 19200:
+ return B_19200;
+ case 38400:
+ return B_38400;
+ case 57600:
+ return B_57600;
+ case 115200:
+ return B_115200;
+ case 230400:
+ return B_230400;
+ case 460800:
+ return B_460800;
+ case 921600:
+ return B_921600;
+ default:
+ return B_115200;
+ }
+}
+
+
+static int zUP_SetPort(int32_t iFd , int iBaud, int iDelay)
+{
+ int ret = 0;
+ attr_set.baudrate = com_Convbaud(iBaud);
+
+ ret = sc_uart_set_termios(iFd, &attr_set);
+ if(ret != 0)
+ {
+ printf("uart_0 sc_uart_set_termios fail ret %d.\n", ret);
+ return -1;
+ }
+
+ ret = sc_uart_set_raw_mode(iFd);
+ if(ret != 0)
+ {
+ printf("uart_0 sc_uart_set_raw_mode fail ret %d.\n", ret);
+ return -1;
+ }
+
+ ret = sc_uart_set_timeout(iFd, iDelay);
+ if(ret != 0)
+ {
+ printf("uart_0 sc_uart_set_timeout fail ret %d.\n", ret);
+ return -1;
+ }
+
+ printf("set serial port done!\n");
+
+ return 0;
+}
+
+int block_select_one_time()
+{
+ int ret;
+ fd_set rfds;
+ FD_ZERO(&rfds);
+ FD_SET(uart_fd_0,&rfds);
+
+ ret = select(uart_fd_0+1,&rfds,NULL,NULL,NULL);
+ if(ret == -1)
+ {
+ printf("select error: -1");
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+
+ return 1;
+}
+
+void check_one_time()
+{
+ uint8_t crc_board = 0;
+ if((dbuf[0] != 0xA5)||(dbuf[1] != 0x5A)||(dbuf[tlen-2] != 0xD5)||(dbuf[tlen-1] != 0x5D))
+ {
+ printf("head or tail error \n");
+ assert(0);
+ }
+
+ uint8_t* dbuf2 = NULL;
+ dbuf2 = (uint8_t*)malloc(2100000);
+ if(dbuf2 == NULL)
+ {
+ printf("malloc failed!\n");
+ exit(1);
+ }
+
+ memcpy(dbuf2, dbuf+2, tlen-5);
+
+ crc_board = fibo_crc_calc(dbuf2,tlen-5);
+ if(crc_board != dbuf[tlen-3])
+ {
+ printf("crc error, value is %d\n", crc_board);
+ assert(0);
+ }
+
+ printf("----------------------crc pass! value :%d----------------------\n", crc_board);
+
+ if(dbuf2 != NULL)
+ {
+ free(dbuf2);
+ dbuf2 = NULL;
+ }
+}
+
+
+int send_one_time()
+{
+ int len = 0;
+
+ len = sc_uart_write(uart_fd_0, ×, 4);
+ if(len <= 0)
+ {
+ printf("Ack write failed %s\n",strerror(errno));
+ return -1;
+ }
+
+ printf("Ack send success index :%d\n", times);
+ return 0;
+}
+
+
+int read_datas_tty()
+{
+ int recv_len = 0;
+ tlen = 0;
+
+ while(1)
+ {
+ recv_len = sc_uart_read(uart_fd_0, dbuf+tlen, ONE_LEN);
+ if(recv_len == 0)
+ {
+ printf("read end! please wait for this packet's handle\n");
+ break;
+ }
+ else if(recv_len < 0)
+ {
+ printf("read_datas_tty error %s\n",strerror(errno));
+ return 0;
+ }
+ else
+ {
+ tlen += recv_len;
+ }
+ }
+
+ printf("read last time len :%d total len :%d\n",recv_len, tlen);
+ //printf("0 is %#x, 1 is %#x, -3 is %#x, -2 is %#x, -1 is %#x\n",dbuf[0],dbuf[1],dbuf[tlen-3],dbuf[tlen-2],dbuf[tlen-1]);
+
+ return 1;
+}
+
+int main(int argc, char** argv)
+{
+ printf("crc_api main programe start...\n");
+ int ret0 = 0;
+ int baud = atoi(argv[1]);
+ int delay = atoi(argv[2]);
+
+ signal(SIGINT,int_handle);
+
+ ret0 = sc_uart_set_app_ctrl_lowpower(0,1);
+ if(ret0 <= 0)
+ {
+ printf("sc_uart_set_app_ctrl_lowpower failed!");
+ return -1;
+ }
+
+ uart_fd_0 = sc_uart_open(UART_DEV,O_RDWR);
+ if(uart_fd_0 < 0)
+ {
+ printf("sc_uart_open failed :%s\n",strerror(errno));
+ return -1;
+ }
+
+ ret0 = zUP_SetPort(uart_fd_0, baud, delay);
+ if(ret0 < 0)
+ {
+ printf("zUP_SetPort failed!");
+ return -1;
+ }
+
+ memset(dbuf,0,2100000);
+ while(1)
+ {
+ ret0 = send_one_time();
+ if(ret0)
+ {
+ break;
+ }
+
+ if(block_select_one_time())
+ {
+ ret0 = read_datas_tty();
+ if(ret0)
+ {
+ check_one_time();
+ times++;
+ }
+ else
+ {
+ printf("read_datas_tty failed\n");
+ break;
+ }
+ }
+ }
+
+
+ close(uart_fd_0);
+
+ ret0 = sc_uart_set_app_ctrl_lowpower(0,0);
+ if(ret0 <= 0)
+ {
+ printf("sc_uart_set_app_ctrl_lowpower failed!");
+ return -1;
+ }
+
+ printf("crc main programe end...\n");
+ return 1;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_mcu/uartcrc_mcu.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_mcu/uartcrc_mcu.c
index 96e1341..ae2244c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_mcu/uartcrc_mcu.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_mcu/uartcrc_mcu.c
Binary files differ
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_modem/uartcrc_modem.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_modem/uartcrc_modem.c
index 261856a..82b5f4f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_modem/uartcrc_modem.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/crc_modem/uartcrc_modem.c
Binary files differ
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/dialtest/sc_data_main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/dialtest/sc_data_main.c
index 7dc0d65..64a7135 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/dialtest/sc_data_main.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/dialtest/sc_data_main.c
@@ -36,13 +36,14 @@
printf("sc_data_call_set_status_ind_cb\n");
printf("sc_data_call_set_service_error_cb\n");
printf("sc_data_call_get_default_id\n");
+ printf("sc_data_call_get_default_cid\n");
printf("\n");
}
void sc_data_call_status_ind_cb(unsigned short id, unsigned short state, sc_pdp_act_rsp_info_t *p_sta)
{
printf("sc_data_call_status_ind_cb \n");
- printf("id=%d,stat=%d\n", id,state);
+ printf("id=%d,stat=%d,result=%d\n", id,state,p_sta->result);
printf("cid=%d,pdptype=%d,ip46flag=%d\n", p_sta->c_id,p_sta->pdp_type,p_sta->act_info.ip46flag);
printf("V4=%s,%s,%s,%s\n", p_sta->act_info.ip,p_sta->act_info.gateway,
p_sta->act_info.pri_dns,p_sta->act_info.sec_dns);
@@ -84,6 +85,10 @@
ret = sc_data_call_get_default_id();
printf("sc_data_call_get_default_id ret=%d\n", ret);
}
+ else if(0 == strncmp(data, "sc_data_call_get_default_cid", data_len)) {
+ ret = sc_data_call_get_default_cid();
+ printf("sc_data_call_get_default_cid ret=%d\n", ret);
+ }
else if(0 == strncmp(data, "sc_data_call_create", data_len)) {
unsigned short id = 0;
sc_pdp_act_req_info_t call_info = {0};
@@ -147,7 +152,7 @@
printf("%d\n",id);
ret = sc_data_call_get_status(id, &status, &rsp_info);
printf("sc_data_call_get_status ret=%d\n", ret);
- printf("id=%d,stat=%d\n", id,status);
+ printf("id=%d,stat=%d,result=%d\n", id,status,rsp_info.result);
printf("cid=%d,pdptype=%d,ip46flag=%d\n", rsp_info.c_id,rsp_info.pdp_type,rsp_info.act_info.ip46flag);
printf("V4=%s,%s,%s,%s\n", rsp_info.act_info.ip,rsp_info.act_info.gateway,
rsp_info.act_info.pri_dns,rsp_info.act_info.sec_dns);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/Android.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/Android.mk
new file mode 100755
index 0000000..5053e7d
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/CMakeLists.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/CMakeLists.txt
new file mode 100755
index 0000000..b8879b8
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required (VERSION 3.2)
+project (optee_examples C)
+
+# https://cmake.org/Wiki/CMake_Useful_Variables
+set (CMAKE_TOOLCHAIN_FILE CMakeToolchain.txt)
+
+include(GNUInstallDirs)
+
+add_compile_options (-Wall)
+#add_compile_options (
+# -Wall -Wbad-function-cast -Wcast-align
+# -Werror-implicit-function-declaration -Wextra
+# -Wfloat-equal -Wformat-nonliteral -Wformat-security
+# -Wformat=2 -Winit-self -Wmissing-declarations
+# -Wmissing-format-attribute -Wmissing-include-dirs
+# -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs
+# -Wpointer-arith -Wshadow -Wstrict-prototypes
+# -Wswitch-default -Wunsafe-loop-optimizations
+# -Wwrite-strings -Werror -fPIC
+#)
+
+find_program(CCACHE_FOUND ccache)
+if(CCACHE_FOUND)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+endif(CCACHE_FOUND)
+
+file(GLOB dirs *)
+foreach(dir ${dirs})
+ if(EXISTS ${dir}/CMakeLists.txt)
+ add_subdirectory(${dir})
+ endif()
+endforeach()
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/CMakeToolchain.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/CMakeToolchain.txt
new file mode 100755
index 0000000..3c10f45
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/CMakeToolchain.txt
@@ -0,0 +1 @@
+set (CMAKE_SYSTEM_NAME Linux)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/LICENSE b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/LICENSE
new file mode 100755
index 0000000..12e3c07
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/LICENSE
@@ -0,0 +1,27 @@
+Unless it has its own copyright/license embedded in its body, each source file
+is subject to the following license terms:
+
+Copyright (c) 2018, Linaro Limited
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/Makefile
new file mode 100755
index 0000000..a44af92
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/Makefile
@@ -0,0 +1,35 @@
+export V ?= 0
+
+OUTPUT_DIR := $(CURDIR)/out
+
+EXAMPLE_LIST := $(subst /,,$(dir $(wildcard */Makefile)))
+
+.PHONY: all
+all: examples prepare-for-rootfs
+
+.PHONY: clean
+clean: examples-clean prepare-for-rootfs-clean
+
+examples:
+ @for example in $(EXAMPLE_LIST); do \
+ $(MAKE) -C $$example CROSS_COMPILE="$(HOST_CROSS_COMPILE)" || exit -1; \
+ done
+
+examples-clean:
+ @for example in $(EXAMPLE_LIST); do \
+ $(MAKE) -C $$example clean || exit -1; \
+ done
+
+prepare-for-rootfs: examples
+ @echo "Copying example CA and TA binaries to $(OUTPUT_DIR)..."
+ @mkdir -p $(OUTPUT_DIR)
+ @mkdir -p $(OUTPUT_DIR)/ca
+ @for example in $(EXAMPLE_LIST); do \
+ if [ -e $$example/host/optee_example_$$example ]; then \
+ cp -p $$example/host/optee_example_$$example $(OUTPUT_DIR)/ca/; \
+ fi; \
+ done
+
+prepare-for-rootfs-clean:
+ @rm -rf $(OUTPUT_DIR)/ca
+ @rmdir --ignore-fail-on-non-empty $(OUTPUT_DIR) || test ! -e $(OUTPUT_DIR)
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/README.md b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/README.md
new file mode 100755
index 0000000..08a24ab
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/README.md
@@ -0,0 +1,11 @@
+# OP-TEE Sample Applications
+This git contains source code for sample host and Trusted Application that can
+be used directly in the OP-TEE project.
+
+All official OP-TEE documentation has moved to http://optee.readthedocs.io. The
+information that used to be here in this git can be found under
+[optee_examples].
+
+// OP-TEE core maintainers
+
+[optee_examples]: https://optee.readthedocs.io/building/gits/optee_examples/optee_examples.html
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/Android.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/Android.mk
new file mode 100755
index 0000000..57a9625
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/Android.mk
@@ -0,0 +1,20 @@
+LOCAL_PATH := $(call my-dir)
+
+OPTEE_CLIENT_EXPORT ?= $(LOCAL_PATH)/../../optee_client/out/export
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS += -DANDROID_BUILD
+LOCAL_CFLAGS += -Wall
+
+LOCAL_SRC_FILES += host/main.c
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/ta/include \
+ $(OPTEE_CLIENT_EXPORT)/include
+
+LOCAL_SHARED_LIBRARIES := libteec
+LOCAL_MODULE := optee_example_aes
+LOCAL_VENDOR_MODULE := true
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(LOCAL_PATH)/ta/Android.mk
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/CMakeLists.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/CMakeLists.txt
new file mode 100755
index 0000000..8c29b52
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/CMakeLists.txt
@@ -0,0 +1,13 @@
+project (optee_example_aes C)
+
+set (SRC host/main.c)
+
+add_executable (${PROJECT_NAME} ${SRC})
+
+target_include_directories(${PROJECT_NAME}
+ PRIVATE ta/include
+ PRIVATE include)
+
+target_link_libraries (${PROJECT_NAME} PRIVATE teec)
+
+install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/Makefile
new file mode 100755
index 0000000..5592b54
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/Makefile
@@ -0,0 +1,13 @@
+export V ?= 0
+
+# If _HOST or _TA specific compilers are not specified, then use CROSS_COMPILE
+HOST_CROSS_COMPILE ?= $(CROSS_COMPILE)
+TA_CROSS_COMPILE ?= $(CROSS_COMPILE)
+
+.PHONY: all
+all:
+ $(MAKE) -C host CROSS_COMPILE="$(HOST_CROSS_COMPILE)" --no-builtin-variables
+
+.PHONY: clean
+clean:
+ $(MAKE) -C host clean
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/Makefile
new file mode 100755
index 0000000..d09dd86
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/Makefile
@@ -0,0 +1,28 @@
+CC ?= $(CROSS_COMPILE)gcc
+LD ?= $(CROSS_COMPILE)ld
+AR ?= $(CROSS_COMPILE)ar
+NM ?= $(CROSS_COMPILE)nm
+OBJCOPY ?= $(CROSS_COMPILE)objcopy
+OBJDUMP ?= $(CROSS_COMPILE)objdump
+READELF ?= $(CROSS_COMPILE)readelf
+
+OBJS = main.o
+
+CFLAGS += -Wall -I./include
+CFLAGS += -I$(TEEC_EXPORT)/include
+LDADD += -lteec -L$(TEEC_EXPORT)/lib
+
+BINARY = optee_example_aes
+
+.PHONY: all
+all: $(BINARY)
+
+$(BINARY): $(OBJS)
+ $(CC) -o $@ $< $(LDADD)
+
+.PHONY: clean
+clean:
+ rm -f $(OBJS) $(BINARY)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/include/aes_ta.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/include/aes_ta.h
new file mode 100755
index 0000000..a13904f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/include/aes_ta.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __AES_TA_H__
+#define __AES_TA_H__
+
+/* UUID of the AES example trusted application */
+#define TA_AES_UUID \
+ { 0x5dbac793, 0xf574, 0x4871, \
+ { 0x8a, 0xd3, 0x04, 0x33, 0x1e, 0xc1, 0x7f, 0x24 } }
+
+/*
+ * TA_AES_CMD_PREPARE - Allocate resources for the AES ciphering
+ * param[0] (value) a: TA_AES_ALGO_xxx, b: unused
+ * param[1] (value) a: key size in bytes, b: unused
+ * param[2] (value) a: TA_AES_MODE_ENCODE/_DECODE, b: unused
+ * param[3] unused
+ */
+#define TA_AES_CMD_PREPARE 0
+
+#define TA_AES_ALGO_ECB 0
+#define TA_AES_ALGO_CBC 1
+#define TA_AES_ALGO_CTR 2
+#define TA_SM4_ALGO_CTR 3
+
+#define TA_AES_SIZE_128BIT (128 / 8)
+#define TA_AES_SIZE_256BIT (256 / 8)
+
+#if 0
+#define TA_AES_MODE_ENCODE 1
+#define TA_AES_MODE_DECODE 0
+
+/*
+ * TA_AES_CMD_SET_KEY - Allocate resources for the AES ciphering
+ * param[0] (memref) key data, size shall equal key length
+ * param[1] unused
+ * param[2] unused
+ * param[3] unused
+ */
+#define TA_AES_CMD_SET_KEY 1
+
+/*
+ * TA_AES_CMD_SET_IV - reset IV
+ * param[0] (memref) initial vector, size shall equal block length
+ * param[1] unused
+ * param[2] unused
+ * param[3] unused
+ */
+#define TA_AES_CMD_SET_IV 2
+
+/*
+ * TA_AES_CMD_CIPHER - Cipher input buffer into output buffer
+ * param[0] (memref) input buffer
+ * param[1] (memref) output buffer (shall be bigger than input buffer)
+ * param[2] unused
+ * param[3] unused
+ */
+#define TA_AES_CMD_CIPHER 3
+
+#define TA_AES_CMD_GENKEYS 8
+#define TA_AES_CMD_SET_CIPHER_INFO 9
+#endif
+#endif /* __AES_TA_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/main.c
new file mode 100755
index 0000000..b8619da
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/aes/host/main.c
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+
+/* OP-TEE TEE client API (built by optee_client) */
+#include <tee_client_api.h>
+#include <ta_api.h>
+
+#define AES_TEST_BUFFER_SIZE 4096
+#define AES_TEST_KEY_SIZE 16
+#define AES_BLOCK_SIZE 16
+#define AES_TEST_KEY_SIZE_256 32
+#define AES_BLOCK_SIZE_256 32
+
+int main(void)
+{
+ teec_info ctx;
+ char key[AES_TEST_KEY_SIZE_256];
+ char iv[AES_BLOCK_SIZE_256];
+ char clear[AES_TEST_BUFFER_SIZE];
+ char ciph[AES_TEST_BUFFER_SIZE];
+ char temp[AES_TEST_BUFFER_SIZE];
+ int i = 0;
+ int keylen = AES_TEST_KEY_SIZE_256;
+ int bufflen = AES_TEST_BUFFER_SIZE;
+ TEEC_UUID uuid = TA_CRYPT_UUID;
+ TEEC_Result rc = 0;
+ rc = teec_session_init(&ctx,uuid);
+ if (rc != 0)
+ {
+ printf("teec_session_init %d \n",rc);
+ return rc;
+ }
+//AES TEST TEE_ALG_AES_CTR 128bit
+ printf("AES TEST TEE_ALG_AES_CTR 128bits\n");
+ printf("Load key in TA\n");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ //teec_set_key(&ctx, TEE_TYPE_AES,key, AES_TEST_KEY_SIZE);
+ teec_gen_keys(&ctx,TEE_TYPE_AES,AES_TEST_KEY_SIZE,key,&keylen);
+ for (i = 0; i < keylen; i++)
+ printf("%x", key[i]);
+
+ memset(iv, 0, sizeof(iv)); /* Load some dummy value */
+ printf("\n Load teec_cipher_init\n");
+ teec_cipher_init(&ctx,TEE_ALG_AES_CTR,TEE_MODE_ENCRYPT,iv,AES_BLOCK_SIZE);
+ printf("Encode buffer from TA\n");
+ memset(clear, 0x5a, sizeof(clear)); /* Load some dummy value */
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, clear,AES_TEST_BUFFER_SIZE, ciph, &bufflen);
+
+ printf("\n \rcipher_buffer Encode Encode \n \r");
+
+ printf("\n \rLoad key in TA\n \r");
+ // memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx, TEE_TYPE_AES,key, AES_TEST_KEY_SIZE);
+ memset(iv, 0, sizeof(iv)); /* Load some dummy value */
+ teec_cipher_init(&ctx,TEE_ALG_AES_CTR,TEE_MODE_DECRYPT,iv,AES_BLOCK_SIZE);
+ printf("\n \rDecode rom TA \n \r");
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, ciph, AES_TEST_BUFFER_SIZE,temp, &bufflen);
+
+ // for (i = 0; i < AES_TEST_BUFFER_SIZE; i++)
+ // printf("%x", temp[i]);
+ printf("\n \r cipher_buffer Decode end \n");
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, AES_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < AES_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("\n Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+ teec_session_close(&ctx);
+
+//AES TEST TEE_ALG_AES_ECB_NOPAD 128bits
+
+ rc = teec_session_init(&ctx,uuid);
+ if (rc != 0)
+ {
+ printf("teec_session_init %d \n",rc);
+ return rc;
+ }
+
+ printf("AES TEST TEE_ALG_AES_ECB_NOPAD 128bits!!\n");
+ printf("Load key in TA\n");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx, TEE_TYPE_AES,key, AES_TEST_KEY_SIZE);
+ printf("Load teec_cipher_init\n");
+ teec_cipher_init(&ctx,TEE_ALG_AES_ECB_NOPAD,TEE_MODE_ENCRYPT,NULL,0);
+ printf("Encode buffer from TA\n");
+ memset(clear, 0x5a, sizeof(clear)); /* Load some dummy value */
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, clear,AES_TEST_BUFFER_SIZE, ciph, &bufflen);
+
+ printf("\n \rcipher_buffer Encode Encode \n \r");
+
+ printf("\n \rLoad key in TA\n \r");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx,TEE_TYPE_AES, key, AES_TEST_KEY_SIZE);
+ teec_cipher_init(&ctx,TEE_ALG_AES_ECB_NOPAD,TEE_MODE_DECRYPT,NULL,0);
+ printf("\n \rDecode rom TA \n \r");
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, ciph,AES_TEST_BUFFER_SIZE, temp, &bufflen);
+
+ printf("\n \r cipher_buffer Decode end \n");
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, AES_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < AES_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("\n Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+ teec_session_close(&ctx);
+
+//AES TEST TEE_ALG_AES_CBC_NOPAD 128bits
+ printf("AES TEST TEE_ALG_AES_CBC_NOPAD 128bits!!\n");
+ rc = teec_session_init(&ctx,uuid);
+ if (rc != 0)
+ {
+ printf("teec_session_init %d \n",rc);
+ return rc;
+ }
+ printf("Load key in TA\n");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx, TEE_TYPE_AES,key, AES_TEST_KEY_SIZE);
+ printf("Load teec_cipher_init\n");
+ memset(iv, 0, sizeof(iv)); /* Load some dummy value */
+ teec_cipher_init(&ctx,TEE_ALG_AES_CBC_NOPAD,TEE_MODE_ENCRYPT,iv,AES_BLOCK_SIZE);
+ printf("Encode buffer from TA\n");
+ memset(clear, 0x5a, sizeof(clear)); /* Load some dummy value */
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, clear,AES_TEST_BUFFER_SIZE, ciph, &bufflen);
+
+ printf("\n \rcipher_buffer Encode Encode \n \r");
+
+ printf("\n \rLoad key in TA\n \r");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx, TEE_TYPE_AES,key, AES_TEST_KEY_SIZE);
+ memset(iv, 0, sizeof(iv)); /* Load some dummy value */
+ teec_cipher_init(&ctx,TEE_ALG_AES_CBC_NOPAD,TEE_MODE_DECRYPT,iv,AES_BLOCK_SIZE);
+ printf("\n \rDecode rom TA \n \r");
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, ciph, AES_TEST_BUFFER_SIZE,temp, &bufflen);
+
+ printf("\n \r cipher_buffer Decode end \n");
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, AES_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < AES_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("\n Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+ teec_session_close(&ctx);
+//AES TEST TEE_ALG_AES_CTR 256bit
+ printf("AES TEST TEE_ALG_AES_CTR 256bit \n");
+ rc = teec_session_init(&ctx,uuid);
+ if (rc != 0)
+ {
+ printf("teec_session_init %d \n",rc);
+ return rc;
+ }
+ printf("Load key in TA\n");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx,TEE_TYPE_AES, key, AES_TEST_KEY_SIZE_256);
+ printf("Load teec_cipher_init\n");
+ memset(iv, 0, sizeof(iv)); /* Load some dummy value */
+ teec_cipher_init(&ctx,TEE_ALG_AES_CTR,TEE_MODE_ENCRYPT,iv,AES_BLOCK_SIZE);
+ printf("Encode buffer from TA\n");
+ memset(clear, 0x5a, sizeof(clear)); /* Load some dummy value */
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, clear, AES_TEST_BUFFER_SIZE,ciph, &bufflen);
+
+ printf("\n \rcipher_buffer Encode Encode \n \r");
+
+ printf("\n \rLoad key in TA\n \r");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx, TEE_TYPE_AES,key, AES_TEST_KEY_SIZE_256);
+ teec_cipher_init(&ctx,TEE_ALG_AES_CTR,TEE_MODE_DECRYPT,iv,AES_BLOCK_SIZE);
+ printf("\n \rDecode rom TA \n \r");
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, ciph, AES_TEST_BUFFER_SIZE,temp, &bufflen);
+
+ printf("\n \r cipher_buffer Decode end \n");
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, AES_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < AES_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("\n Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+ teec_session_close(&ctx);
+
+//AES TEST AES TEE_ALG_AES_ECB_NOPAD 256bits!!
+ printf("AES TEST TEE_ALG_AES_ECB_NOPAD 256bits!!\n");
+ rc = teec_session_init(&ctx,uuid);
+ if (rc != 0)
+ {
+ printf("teec_session_init %d \n",rc);
+ return rc;
+ }
+ printf("Load key in TA\n");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ // teec_set_key(&ctx,TEE_TYPE_AES, key, AES_TEST_KEY_SIZE_256);
+ keylen =0;
+ teec_gen_keys(&ctx,TEE_TYPE_AES,AES_TEST_KEY_SIZE_256,NULL,&keylen);
+ for (i = 0; i < keylen; i++)
+ printf("%x", key[i]);
+ printf("\n Load teec_cipher_init\n");
+ teec_cipher_init(&ctx,TEE_ALG_AES_ECB_NOPAD,TEE_MODE_ENCRYPT,NULL,0);
+ printf("Encode buffer from TA\n");
+ memset(clear, 0x5a, sizeof(clear)); /* Load some dummy value */
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, clear,AES_TEST_BUFFER_SIZE, ciph, &bufflen);
+
+ printf("\n \rcipher_buffer Encode Encode \n \r");
+
+ printf("\n \rLoad key in TA\n \r");
+ // memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ //teec_set_key(&ctx, TEE_TYPE_AES,key, AES_TEST_KEY_SIZE_256);
+ teec_cipher_init(&ctx,TEE_ALG_AES_ECB_NOPAD,TEE_MODE_DECRYPT,NULL,0);
+ printf("\n \rDecode rom TA \n \r");
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, ciph,AES_TEST_BUFFER_SIZE, temp, &bufflen);
+ printf("\n \r cipher_buffer Decode end \n");
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, AES_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < AES_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("\n Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+ teec_session_close(&ctx);
+//AES TEST AES TEE_ALG_AES_CBC_NOPAD 256bits
+ printf("AES TEST AES TEE_ALG_AES_CBC_NOPAD 256bits!!\n");
+ rc = teec_session_init(&ctx,uuid);
+ if (rc != 0)
+ {
+ printf("teec_session_init %d \n",rc);
+ return rc;
+ }
+ printf("Load key in TA\n");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx,TEE_TYPE_AES, key, AES_TEST_KEY_SIZE_256);
+ printf("Load teec_cipher_init\n");
+ teec_cipher_init(&ctx,TEE_ALG_AES_CBC_NOPAD,TEE_MODE_ENCRYPT,iv,AES_BLOCK_SIZE);
+ printf("Encode buffer from TA\n");
+ memset(clear, 0x5a, sizeof(clear)); /* Load some dummy value */
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, clear,AES_TEST_BUFFER_SIZE, ciph, &bufflen);
+
+ printf("\n \rcipher_buffer Encode Encode \n \r");
+ printf("\n \rLoad key in TA\n \r");
+ memset(key, 0xa5, sizeof(key)); /* Load some dummy value */
+ teec_set_key(&ctx, TEE_TYPE_AES,key, AES_TEST_KEY_SIZE_256);
+ teec_cipher_init(&ctx,TEE_ALG_AES_CBC_NOPAD,TEE_MODE_DECRYPT,iv,AES_BLOCK_SIZE);
+ printf("\n \rDecode rom TA \n \r");
+ bufflen =AES_TEST_BUFFER_SIZE;
+ teec_cipher(&ctx, ciph,AES_TEST_BUFFER_SIZE, temp, &bufflen);
+ printf("\n \r cipher_buffer Decode end \n");
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, AES_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < AES_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("\n Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+ teec_session_close(&ctx);
+ return 0;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/CMakeLists.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/CMakeLists.txt
new file mode 100755
index 0000000..f22b5cd
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/CMakeLists.txt
@@ -0,0 +1,13 @@
+project (rsa C)
+
+set (SRC host/main.c)
+
+add_executable (${PROJECT_NAME} ${SRC})
+
+target_include_directories(${PROJECT_NAME}
+ PRIVATE ta/include
+ PRIVATE include)
+
+target_link_libraries (${PROJECT_NAME} PRIVATE teec)
+
+install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/LICENSE b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/LICENSE
new file mode 100755
index 0000000..261eeb9
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/LICENSE
@@ -0,0 +1,201 @@
+ 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
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/Makefile
new file mode 100755
index 0000000..5592b54
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/Makefile
@@ -0,0 +1,13 @@
+export V ?= 0
+
+# If _HOST or _TA specific compilers are not specified, then use CROSS_COMPILE
+HOST_CROSS_COMPILE ?= $(CROSS_COMPILE)
+TA_CROSS_COMPILE ?= $(CROSS_COMPILE)
+
+.PHONY: all
+all:
+ $(MAKE) -C host CROSS_COMPILE="$(HOST_CROSS_COMPILE)" --no-builtin-variables
+
+.PHONY: clean
+clean:
+ $(MAKE) -C host clean
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/README.md b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/README.md
new file mode 100755
index 0000000..b5725e7
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/README.md
@@ -0,0 +1,55 @@
+# optee_rsa_example
+This is an example of RSA encrypt/decrypt methods running on OP-TEE.
+
+Below, you find the steps to setup the environment to run OPTEE on QEMU. These steps are available in the build page of the OPTEE github (https://github.com/OP-TEE/build).
+
+To get and build OPTEE on QEMU, you have to follow the steps below:
+
+1. Install the following packages:
+
+ sudo apt-get install android-tools-adb android-tools-fastboot autoconf \
+ automake bc bison build-essential cscope curl device-tree-compiler \
+ expect flex ftp-upload gdisk iasl libattr1-dev libc6:i386 libcap-dev \
+ libfdt-dev libftdi-dev libglib2.0-dev libhidapi-dev libncurses5-dev \
+ libpixman-1-dev libssl-dev libstdc++6:i386 libtool libz1:i386 make \
+ mtools netcat python-crypto python-serial python-wand unzip uuid-dev \
+ xdg-utils xterm xz-utils zlib1g-dev
+
+2. Get the repo tool and make it executable:
+
+ wget https://storage.googleapis.com/git-repo-downloads/repo
+ chmod a+x repo
+
+3. Create a directory for optee and enter inside it:
+
+ mkdir optee
+ cd optee
+
+4. Get the source code:
+
+ ./../repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml
+ ./../repo sync
+
+5. Get the toolchains:
+
+ cd build
+ make toolchains
+
+6. Build the solution:
+
+ make
+
+7. Run OPTEE on QEMU:
+
+ make run
+
+8. When the process stops, the QEMU console will be waiting. Just type c to continue. Two terminals will open: one with the "Rich OS" (Normal World) and another with the "Trusted OS" (Trusted World - OPTEE).
+
+9. In the Rich OS (Normal World), enter "root" to login. You now can test the examples, running one of the following:
+
+ hello_world
+ aes
+ hotp
+ random
+
+10. To run this RSA example, clone this GitHub repository in the optee/optee_examples folder, update the needed references according to the organization in your system and `make run`again. When this process finishes and you login in the normal world, you can run also the rsa application, just typing rsa.
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/Makefile
new file mode 100755
index 0000000..b1bc471
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/Makefile
@@ -0,0 +1,28 @@
+CC ?= $(CROSS_COMPILE)gcc
+LD ?= $(CROSS_COMPILE)ld
+AR ?= $(CROSS_COMPILE)ar
+NM ?= $(CROSS_COMPILE)nm
+OBJCOPY ?= $(CROSS_COMPILE)objcopy
+OBJDUMP ?= $(CROSS_COMPILE)objdump
+READELF ?= $(CROSS_COMPILE)readelf
+
+OBJS = main.o
+
+CFLAGS += -Wall -I../ta/include -I./include
+CFLAGS += -I$(TEEC_EXPORT)/include
+LDADD += -lteec -L$(TEEC_EXPORT)/lib
+
+BINARY = optee_example_rsa
+
+.PHONY: all
+all: $(BINARY)
+
+$(BINARY): $(OBJS)
+ $(CC) -o $@ $< $(LDADD)
+
+.PHONY: clean
+clean:
+ rm -f $(OBJS) $(BINARY)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/include/rsa_ta.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/include/rsa_ta.h
new file mode 100755
index 0000000..7559f6c
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/include/rsa_ta.h
@@ -0,0 +1,25 @@
+#ifndef __RSA_TA_H__
+#define __RSA_TA_H__
+
+#define TA_RSA_UUID \
+ { 0x21d38c70, 0xf25a, 0x4b95, \
+ { 0xac, 0x25, 0x07, 0xd1, 0xbf, 0xdb, 0xc1, 0x12 } }
+
+/* The function ID(s) implemented in this TA */
+#define TA_RSA_CMD_GENKEYS 0
+#define TA_RSA_CMD_ENCRYPT 1
+#define TA_RSA_CMD_DECRYPT 2
+#define TA_RSA_CMD_DIGEST 3
+#define TA_RSA_CMD_SIGN 4
+#define TA_RSA_CMD_VERIFY 5
+#define TA_RSA_CMD_PUBLICKEYS 6
+#define TA_RSA_CMD_PRIVATEKEYS 7
+#define TA_SM2_CMD_PUBLICKEYS 8
+#define TA_SM2_CMD_PUBLICKEYS_DATA 9
+#define TA_SM2_CMD_PRIVATEKEYS 10
+#define TA_SM2_CMD_PRIVATEKEYS_DATA 11
+
+
+
+#endif
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/main.c
new file mode 100755
index 0000000..c048fe5
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/rsa/host/main.c
@@ -0,0 +1,306 @@
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+/* OP-TEE TEE client API (built by optee_client) */
+#include <tee_client_api.h>
+#include <ta_api.h>
+
+#define RSA_KEY_SIZE 1024
+#define RSA_MAX_PLAIN_LEN_1024 86 // (1024/8) - 42 (padding)
+#define RSA_CIPHER_LEN_1024 (RSA_KEY_SIZE / 8)
+#define RSA_MSG_LEN 2048
+#define SM2_KEY_SIZE 256
+char g_Publickey1024_N[] =
+{
+ 0xab, 0x89, 0x1c, 0x98, 0xdf, 0xe8, 0x29, 0xa8, 0x26, 0x8f, 0x88, 0x51, 0x8b, 0x8c,
+ 0x6e, 0xa5, 0xd7, 0x60, 0x48, 0x07, 0xe1, 0xb6, 0x0d, 0x86, 0x32, 0xcb, 0x97, 0x91, 0xa8,
+ 0xb5, 0xf8, 0xc0, 0x4d, 0xf3, 0x3b, 0xb7, 0xf2, 0xe7, 0x40, 0xc6, 0x83, 0xe7, 0x31, 0xec,
+ 0x3f, 0x76, 0x3e, 0x14, 0x82, 0x5e, 0x35, 0xf9, 0x5b, 0x43, 0x79, 0x88, 0x1e, 0x1b, 0x7a,
+ 0x29, 0x5b, 0x93, 0xc4, 0x5d, 0xee, 0x60, 0x2d, 0x62, 0x21, 0x34, 0x69, 0x39, 0xa8, 0x82,
+ 0x8d, 0x20, 0x8c, 0xf8, 0xc8, 0x2c, 0x11, 0x3e, 0x56, 0x1b, 0xe8, 0xd1, 0x91, 0xad, 0x93,
+ 0x00, 0xcf, 0x10, 0xab, 0x2a, 0xc7, 0x24, 0x13, 0xde, 0x04, 0xeb, 0x71, 0x62, 0x2e, 0x35,
+ 0xa3, 0x4e, 0x24, 0xf2, 0xa0, 0x32, 0x07, 0xd1, 0x87, 0x49, 0x28, 0xf7, 0x82, 0x95, 0x3d,
+ 0x19, 0x12, 0x36, 0x0d, 0x78, 0x22, 0x51, 0x80, 0x15
+};
+
+char g_Publickey1024_E[] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01
+};
+
+char g_Publickey1024_D[] =
+{
+ 0x8b, 0x7d, 0xae, 0x61, 0xab, 0x03, 0x32, 0x8c, 0xe8, 0xfe, 0xa3, 0x8e, 0x1c, 0x7b,
+ 0x10, 0xa7, 0x90, 0x23, 0x5d, 0xaf, 0xfb, 0x1e, 0x7e, 0x94, 0xf8, 0xcd, 0x92, 0xee, 0x02,
+ 0x52, 0x28, 0x7c, 0xc9, 0x66, 0xd8, 0xd3, 0x57, 0x96, 0x32, 0x98, 0xbc, 0x3e, 0xcf, 0xdc,
+ 0x1c, 0x27, 0x5d, 0x88, 0x74, 0x13, 0x84, 0xb4, 0xc8, 0x40, 0x70, 0x9d, 0xfe, 0x4d, 0xbd,
+ 0xe3, 0xcf, 0xf2, 0xb4, 0x25, 0x91, 0x90, 0xc4, 0xb5, 0x02, 0x49, 0x9b, 0xcc, 0xa9, 0xe9,
+ 0x16, 0xf5, 0x00, 0x65, 0xc0, 0x05, 0x24, 0x25, 0x40, 0x48, 0xf1, 0xcc, 0xef, 0xb6, 0x1e,
+ 0xf2, 0x2d, 0x7a, 0x35, 0xce, 0xc7, 0x52, 0x27, 0x5e, 0x0b, 0x99, 0x35, 0xf5, 0x67, 0xf1,
+ 0x37, 0x2b, 0x10, 0x34, 0xe1, 0x1d, 0xf6, 0xe6, 0x7f, 0x67, 0x5a, 0xdd, 0xd4, 0xde, 0x10,
+ 0x84, 0x3b, 0x0e, 0x75, 0xba, 0x6a, 0x0a, 0xe6, 0x41
+};
+
+char g_Publickey2048_N[] =
+{
+ 0xc6, 0x23, 0x15, 0x60, 0xd5, 0xf5, 0x34, 0x1a, 0xd9, 0xa0, 0x1a, 0x55, 0x4f, 0x04,
+ 0xfb, 0x2f, 0x83, 0x42, 0x90, 0x71, 0x73, 0xb0, 0xa3, 0xf1, 0x33, 0xbd, 0x21, 0x59, 0x9c,
+ 0xff, 0x87, 0xd1, 0xda, 0x49, 0xdb, 0xe2, 0xa5, 0xd1, 0xb3, 0x88, 0x36, 0xdf, 0xea, 0x54,
+ 0xc0, 0x53, 0x27, 0xae, 0x02, 0x5a, 0xce, 0x17, 0x40, 0xd7, 0x01, 0x44, 0xaf, 0xff, 0xbf,
+ 0x28, 0x3b, 0x4c, 0xc9, 0x66, 0x56, 0x36, 0x02, 0xd0, 0x09, 0x15, 0x5e, 0x4c, 0x08, 0x84,
+ 0x4c, 0xa5, 0x7a, 0x30, 0x8e, 0x68, 0xff, 0x8d, 0x5a, 0x66, 0x61, 0xcb, 0x16, 0xf3, 0x8b,
+ 0x10, 0x6e, 0x5c, 0xff, 0xa6, 0xf3, 0xf3, 0xe9, 0xb3, 0x8f, 0xe7, 0x7d, 0x7d, 0xea, 0x4d,
+ 0x98, 0x96, 0x39, 0x45, 0xe5, 0xcf, 0xb6, 0x69, 0x8a, 0xf1, 0x1a, 0xfd, 0xee, 0xb0, 0xa5,
+ 0x4b, 0x15, 0x76, 0x1f, 0x7b, 0x95, 0x12, 0x9d, 0x9f, 0x52, 0x2e, 0x8b, 0x3d, 0x5c, 0x41,
+ 0x94, 0xbc, 0x16, 0x64, 0xcf, 0x58, 0x61, 0xc8, 0x06, 0xdf, 0xca, 0xeb, 0xf4, 0x82, 0xd0,
+ 0x43, 0x62, 0xbc, 0x1e, 0x1c, 0x83, 0xaa, 0xee, 0x8f, 0x47, 0x7f, 0x87, 0xb1, 0x58, 0xee,
+ 0xb1, 0x49, 0x56, 0x95, 0x1c, 0xf9, 0x49, 0x8e, 0xa6, 0xa3, 0x5b, 0x77, 0xe6, 0xb4, 0x2e,
+ 0xeb, 0x96, 0x69, 0x00, 0xb6, 0xc2, 0xbb, 0xbd, 0x50, 0xbf, 0x6a, 0x15, 0xb0, 0x35, 0xc9,
+ 0x67, 0x70, 0x6c, 0xaf, 0xd5, 0xfa, 0x9f, 0xbf, 0x2d, 0xaa, 0x8e, 0x81, 0xed, 0x5e, 0x09,
+ 0x17, 0x55, 0x32, 0x7d, 0xc7, 0x23, 0x0e, 0x2e, 0xd3, 0xa5, 0x36, 0xcf, 0xc1, 0x80, 0xab,
+ 0x37, 0x62, 0x05, 0xb4, 0x8b, 0x10, 0xe7, 0x4e, 0x83, 0x80, 0x06, 0xf4, 0x2e, 0x91, 0x44,
+ 0xff, 0x2c, 0x9a, 0xc9, 0x99, 0x6c, 0x44, 0x83, 0x65, 0x3e, 0xcb, 0xa5, 0x0d, 0x9f, 0x5f,
+ 0xf1, 0x79
+};
+
+char g_Publickey2048_D[] =
+{
+ 0x7a, 0x5f, 0x9e, 0xcb, 0x91, 0x3a, 0x01, 0xb5, 0x77, 0xa5, 0xff, 0xbd, 0xa2, 0xb1, 0x63,
+ 0xe6, 0x63, 0x7e, 0x90, 0x31, 0xd2, 0x0f, 0x4e, 0x22, 0x22, 0x1f, 0x74, 0xe2, 0xa1, 0x29,
+ 0xdd, 0x9c, 0x09, 0xe3, 0x46, 0x30, 0x84, 0xd3, 0xb0, 0xbb, 0xb7, 0x90, 0xb2, 0x6d, 0x27,
+ 0xdf, 0xf4, 0x08, 0xf0, 0x21, 0x5f, 0x5a, 0x53, 0x4c, 0xb7, 0xd6, 0xd1, 0x90, 0xf6, 0x62,
+ 0x85, 0xc5, 0x96, 0x3a, 0x63, 0x92, 0xb6, 0x48, 0x00, 0xe4, 0x36, 0xba, 0x65, 0x24, 0x39,
+ 0x26, 0x97, 0x02, 0x38, 0x62, 0xb7, 0x3b, 0x79, 0x92, 0xf4, 0x61, 0x77, 0xca, 0x71, 0xa0,
+ 0x73, 0x59, 0x72, 0xf8, 0x8d, 0x81, 0x9f, 0x5c, 0xac, 0xcb, 0x7f, 0xe1, 0x6d, 0xfe, 0x00,
+ 0xf8, 0xff, 0x64, 0xa1, 0x5c, 0x99, 0xc0, 0x33, 0xf5, 0x58, 0x03, 0x70, 0x11, 0x9f, 0xf5,
+ 0x70, 0xca, 0xe5, 0x04, 0xf1, 0xfc, 0x6e, 0x66, 0xab, 0x1e, 0x6b, 0xff, 0x2f, 0xee, 0x70,
+ 0xc1, 0xc5, 0x19, 0xf9, 0x70, 0x5e, 0xcb, 0x62, 0xf3, 0x48, 0x8e, 0x6a, 0x9a, 0x2e, 0xea,
+ 0x23, 0x7b, 0xba, 0x09, 0x33, 0xeb, 0x43, 0xe2, 0xb4, 0x36, 0xae, 0x72, 0x78, 0x10, 0x11,
+ 0x04, 0x81, 0xcc, 0x49, 0xf2, 0x40, 0xef, 0xfe, 0x94, 0x27, 0xc3, 0x06, 0x2d, 0xb8, 0x7a,
+ 0x58, 0xdd, 0x3f, 0x47, 0x01, 0x6f, 0x5f, 0xb5, 0xc9, 0x29, 0x33, 0xc9, 0x07, 0x50, 0x04,
+ 0xcd, 0x69, 0x9a, 0x43, 0xd7, 0xb2, 0xff, 0x62, 0xe5, 0x30, 0x78, 0xe3, 0xb9, 0xde, 0x0f,
+ 0x4e, 0x71, 0xa3, 0x64, 0x5b, 0xb8, 0xf9, 0xf1, 0xa7, 0xf8, 0x67, 0xad, 0x99, 0x94, 0x39,
+ 0x3a, 0xd3, 0x98, 0x97, 0x5d, 0xe8, 0xfa, 0x92, 0xc8, 0x78, 0x79, 0xa3, 0x7b, 0x15, 0x3a,
+ 0x6b, 0x00, 0xfa, 0x9b, 0xe3, 0x58, 0x4c, 0x03, 0x62, 0x80, 0xf2, 0x50, 0x8b, 0xa5, 0x6b,
+ 0xa5
+};
+
+char g_Publickey2048_E[] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01
+};
+
+
+char *g_test_string ="MIIEpAIBAAKCAQEAploYrcCzzuMMkCt9QJusu1pJiEIKseCSwIaR5p7voOHxL5D2Zt3qFVrAKLSd31IMbqXGGUOsaajyX/5gAKXSOswSAfNbugxRHCz0sHe51nI1HA9zzS8W+bqJhKCbv4tbf+iLi5/IceocbB8AoO7KPr8YjlebSGbri9RAUa6GoYb40Av6ti4lLgX/dgFG1z3rH3z83x6Ci16wyqPqFr4tblRQnLhB7xfHf2BUqvlwoPiYLoL5jF/7nIiOd7Aycpka4ARevx2q9/AFPLSV3U26OnGh+HKOHZjjE7rKsCe/h1lUJ/jo7MaFN9I6leSlCZrQH6OGsJLYAh4zddsmvyf8NQIDAQABAoIBAEoooBfVcFMqpM8glBXZUIe1GFLGHj5t/v4U/7Xv5KO0FfE+jpoNE+2xJzj+S+LikOhCvq1Enff8eRCSNfoT8kSD9QMpmhq2ovIMmIiS1yXihAqeWOF/vJ5XqjaV4tjhJ0k+Qfdco98knscUixMzYLXYOvo509/TAe60EHhZdWtMKCmHqvFBRDhYFF+HUxWnJa39G1u828ljv8uNiRCXbEjoaWDwBJWRzDZJehrkQc2gQAkFpyePVqA3wm1tx1ZHEVwCqYOXOP49/LAcrQfoWUpm4chjEHnZEb+dQxa3N8Qeq2lqgcqrOX8NIfpzWTWQ1JM+ksinQwMJ0BDV+Lf1nAECgYEA2KBBtsj41ITez8iA0DpXovH1F9oU9aJ9JKopNos8zIZg012bE5IbkFII0LiBGKLUP2PepTsPDIOxibLQDojg1aBGHISZVp/y81B4Rk7Wwg206ZQ848dMAhACIrzOtJLoVEZTPf7C5QrNMhViyf2c8vFBjfTuM7Ze6a0fsvfJ2ikCgYEAxJaOXKnOgKoG1Fe9JVM01U+260BEybNUbbXQCnvMjTSZCsOEmST9mhXhC56lhCNqmyntFxNuq/JMwtS3TRhrYCPPCLFly+JNTqUS1mLQ9ytVbaw6fp9mSxFUQE9d9obkGwJC3uXEx+bc7YSGuwD34wikX0tB1zzGIXRH2JlB6y0CgYEAgFlDVjdxJwmqslXL7JQExKizXPR7oqYpm4WucYDB/zRHPjSh41CYQEQ6sOAArUYcl4pmqmN5oSKOGFX37ASxoiEaKV9vMuIGIp+1A4NGvyc734FTKmo04Kv3d/mCR38bZINeYscFVou11EzTgXZgfZjwDFnooH8XcUCAHZuu3zECgYEAt6pltSMcgE7Z9JdIas/TI5vHLQEtgzhdH+bmSHUjRaWnekvy3VWW7deVGtMMlmi0V+US0iVgl5rXposv+gJfh0HNUrTSg2qZiWlmMQ+/Zb2BoeZv/A8Wdfnpue+svP+Hq8gwC6mlcJI7RFk1uw8LiXxwfWuFRv9LqMPHwBBnar0CgYAJF3ukzm7rnut19lzS4r1uEIuuPwk/DjEkkil7U9wE5fr+ds5rCtXj9591DLHrtE/CBOWym2+tIDr7OnmfU+934524mtLWVZdf39/DFM9Fc1VaSualrj/1BOLhBb7MEZqN7hHcQP7+49YW72GgX3pm0Ov5ke33FzN3ubIwAS6T7A==";
+//char g_RsaPaddingRaw2[] = "YAO YAO qie ke nao! Zai han leng de dong tian lai tao jian bing guo zi, you!";
+#define SEC_TO_US (1000000)
+int main(int argc, char *argv[])
+{
+ struct timeval tv;
+ struct timeval tvend;
+ uint64_t timelen;
+ teec_info ctx;
+ char clear[4096] = {0};
+ char ciph[4096];
+ int len =RSA_CIPHER_LEN_1024;
+ int plain_len = RSA_MAX_PLAIN_LEN_1024;
+ uint8_t msg_buffer[RSA_MSG_LEN] = {0};
+ uint32_t msg_len =RSA_MSG_LEN;
+ char digest[RSA_MSG_LEN] = {0};
+ int dig_len =RSA_MSG_LEN/8;
+ char sign[RSA_MSG_LEN];
+ int sign_len=RSA_MSG_LEN/8;
+ int i;
+ TEEC_UUID uuid = TA_CRYPT_UUID;
+ key_data_t key_data;
+ TEEC_Result res= TEEC_SUCCESS;
+ int key_size =0;
+ //prepare_ta_session(&ta);
+ res = teec_session_init(&ctx,uuid);
+ if (res != 0)
+ {
+ printf("teec_session_init %d \n",res);
+ return res;
+ }
+ //printf("\nType something to be encrypted and decrypted in the TA:\n");
+ strncpy(clear,g_test_string,RSA_MAX_PLAIN_LEN_1024-1);
+
+ gettimeofday(&tv, NULL);
+ res = teec_asy_gen_keys(&ctx,TEE_TYPE_RSA_KEYPAIR,RSA_KEY_SIZE);
+ gettimeofday(&tvend, NULL);
+ timelen=( tvend.tv_sec -tv.tv_sec)*SEC_TO_US + ( tvend.tv_usec -tv.tv_usec);
+ printf("\n teec_asy_gen_keys res=%d line %d timelen = %d \n",res, __LINE__,timelen);
+ res = teec_asy_encrypt(&ctx,TEE_ALG_RSA_NOPAD, clear, RSA_MAX_PLAIN_LEN_1024, ciph, &len);
+ printf("\n teec_asy_encrypt res=%d line %d \n",res, __LINE__);
+ res = teec_asy_decrypt(&ctx,TEE_ALG_RSA_NOPAD, ciph, len, clear, &plain_len);
+ printf("\n teec_asy_decrypt res=%d line %d \n",res, __LINE__);
+ memset(msg_buffer,0xAB,RSA_MSG_LEN);
+ res = teec_digest(&ctx, TEE_ALG_SHA256,msg_buffer, RSA_MSG_LEN, digest, &dig_len);
+ printf("\n teec_digest res=%d line %d \n",res, __LINE__);
+ printf("\n \r digest dig_len =%d \n \r",dig_len);
+ for (i = 0; i < dig_len; i++)
+ printf("%x", digest[i]);
+ printf("\n");
+ res = teec_asy_sign(&ctx, TEE_ALG_RSASSA_PKCS1_V1_5_SHA256,digest, dig_len, sign, &sign_len);
+ printf("\n teec_asy_sign res=%d line %d \n",res, __LINE__);
+ res = teec_asy_verify(&ctx,TEE_ALG_RSASSA_PKCS1_V1_5_SHA256, digest, dig_len, sign, sign_len);
+ printf("\n teec_asy_verify res=%d line %d \n",res, __LINE__);
+
+ key_data.public1 = g_Publickey1024_N;
+ key_data.pub_size1 = sizeof(g_Publickey1024_N);
+ key_data.public2 = g_Publickey1024_E;
+ key_data.pub_size2 = sizeof(g_Publickey1024_E);
+ res = teec_rsa_public_keys(&ctx,TEE_TYPE_RSA_PUBLIC_KEY,RSA_KEY_SIZE,&key_data);
+ printf("\n teec_rsa_public_keys res=%d line %d \n",res, __LINE__);
+ res = teec_asy_encrypt(&ctx,TEE_ALG_RSA_NOPAD, clear, RSA_MAX_PLAIN_LEN_1024, ciph, &len);
+ printf("\n teec_asy_encrypt res=%d line %d \n",res, __LINE__);
+
+ key_data.public1 = g_Publickey1024_N;
+ key_data.pub_size1 = sizeof(g_Publickey1024_N);
+ key_data.public2 = g_Publickey1024_E;
+ key_data.pub_size2 = sizeof(g_Publickey1024_E);
+ key_data.private = g_Publickey1024_D;
+ key_data.priv_size = sizeof(g_Publickey1024_D);
+ res = teec_rsa_private_keys(&ctx,TEE_TYPE_RSA_KEYPAIR,RSA_KEY_SIZE,&key_data);
+ printf("\n teec_rsa_private_keys res=%d line %d \n",res, __LINE__);
+ res = teec_asy_decrypt(&ctx,TEE_ALG_RSA_NOPAD, ciph, len, clear, &plain_len);
+ printf("\n teec_asy_decrypt res=%d line %d \n",res, __LINE__);
+ key_data.public1 = g_Publickey1024_N;
+ key_data.pub_size1 = sizeof(g_Publickey1024_N);
+ key_data.public2 = g_Publickey1024_E;
+ key_data.pub_size2 = sizeof(g_Publickey1024_E);
+ key_data.private = g_Publickey1024_D;
+ key_data.priv_size = sizeof(g_Publickey1024_D);
+ res = teec_rsa_private_keys(&ctx,TEE_TYPE_RSA_KEYPAIR,RSA_KEY_SIZE,&key_data);
+ printf("\n teec_rsa_private_keys res=%d line %d \n",res, __LINE__);
+ res = teec_asy_sign(&ctx, TEE_ALG_RSASSA_PKCS1_V1_5_SHA256,digest, dig_len, sign, &sign_len);
+ printf("\n teec_asy_sign res=%d line %d \n",res, __LINE__);
+ key_data.public1 = g_Publickey1024_N;
+ key_data.pub_size1 = sizeof(g_Publickey1024_N);
+ key_data.public2 = g_Publickey1024_E;
+ key_data.pub_size2 = sizeof(g_Publickey1024_E);
+ res = teec_rsa_public_keys(&ctx,TEE_TYPE_RSA_PUBLIC_KEY,RSA_KEY_SIZE,&key_data);
+ printf("\n teec_rsa_public_keys res=%d line %d \n",res, __LINE__);
+ res = teec_asy_verify(&ctx,TEE_ALG_RSASSA_PKCS1_V1_5_SHA256, digest, dig_len, sign, sign_len);
+ printf("\n teec_asy_verify res=%d line %d \n",res, __LINE__);
+
+ key_size = 2048;
+ gettimeofday(&tv, NULL);
+ res = teec_asy_gen_keys(&ctx,TEE_TYPE_RSA_KEYPAIR,key_size);
+ gettimeofday(&tvend, NULL);
+ timelen=( tvend.tv_sec -tv.tv_sec)*SEC_TO_US + ( tvend.tv_usec -tv.tv_usec);
+ printf("\n teec_asy_gen_keys res=%d line %d timelen = %d \n",res, __LINE__,timelen);
+ printf("\n teec_asy_gen_keys res=%d line %d \n",res, __LINE__);
+ plain_len=128;
+ memset(clear,0x5a,plain_len);
+ len=4096;
+ res = teec_asy_encrypt(&ctx,TEE_ALG_RSAES_PKCS1_V1_5, clear, plain_len, ciph, &len);
+ printf("\n teec_asy_encrypt res=%d line %d len =%d \n",res, __LINE__,len);
+ plain_len=4096;
+ res = teec_asy_decrypt(&ctx,TEE_ALG_RSAES_PKCS1_V1_5, ciph, len, clear, &plain_len);
+ printf("\n teec_asy_decrypt res=%d line %d plain_len =%d\n",res, __LINE__,plain_len);
+ memset(msg_buffer,0xAB,RSA_MSG_LEN);
+ dig_len = 64;
+ res = teec_digest(&ctx, TEE_ALG_SHA512,msg_buffer, RSA_MSG_LEN, digest, &dig_len);
+ printf("\n teec_digest res=%d line %d \n",res, __LINE__);
+ printf("\n \r digest dig_len =%d \n \r",dig_len);
+ for (i = 0; i < dig_len; i++)
+ printf("%x", digest[i]);
+ printf("\n");
+ sign_len = 256;
+ res = teec_asy_sign(&ctx, TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512,digest, dig_len, sign, &sign_len);
+ printf("\n teec_asy_sign res=%d line %d sign_len=%d \n",res, __LINE__,sign_len);
+ res = teec_asy_verify(&ctx,TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512, digest, dig_len, sign, sign_len);
+ printf("\n teec_asy_verify res=%d line %d \n",res, __LINE__);
+
+ key_size = 2048;
+ key_data.public1 = g_Publickey2048_N;
+ key_data.pub_size1 = sizeof(g_Publickey2048_N);
+ key_data.public2 = g_Publickey2048_E;
+ key_data.pub_size2 = sizeof(g_Publickey2048_E);
+ res = teec_rsa_public_keys(&ctx,TEE_TYPE_RSA_PUBLIC_KEY,key_size,&key_data);
+ printf("\n teec_rsa_public_keys res=%d line %d \n",res, __LINE__);
+
+ plain_len=256;
+ len=4096;
+ res = teec_asy_encrypt(&ctx,TEE_ALG_RSA_NOPAD, clear, plain_len, ciph, &len);
+ printf("\n teec_asy_encrypt res=%d line %d \n",res, __LINE__);
+
+ key_data.public1 = g_Publickey2048_N;
+ key_data.pub_size1 = sizeof(g_Publickey2048_N);
+ key_data.public2 = g_Publickey2048_E;
+ key_data.pub_size2 = sizeof(g_Publickey2048_E);
+ key_data.private = g_Publickey2048_D;
+ key_data.priv_size = sizeof(g_Publickey2048_D);
+
+ res = teec_rsa_private_keys(&ctx,TEE_TYPE_RSA_KEYPAIR,key_size,&key_data);
+ printf("\n teec_rsa_private_keys res=%d line %d \n",res, __LINE__);
+ plain_len=4096;
+ res = teec_asy_decrypt(&ctx,TEE_ALG_RSA_NOPAD, ciph, len, clear, &plain_len);
+ printf("\n teec_asy_decrypt res=%d line %d \n",res, __LINE__);
+ key_data.public1 = g_Publickey2048_N;
+ key_data.pub_size1 = sizeof(g_Publickey2048_N);
+ key_data.public2 = g_Publickey2048_E;
+ key_data.pub_size2 = sizeof(g_Publickey2048_E);
+ key_data.private = g_Publickey2048_D;
+ key_data.priv_size = sizeof(g_Publickey2048_D);
+ res = teec_rsa_private_keys(&ctx,TEE_TYPE_RSA_KEYPAIR,key_size,&key_data);
+ printf("\n teec_rsa_private_keys res=%d line %d \n",res, __LINE__);
+ dig_len=64;
+ res = teec_digest(&ctx, TEE_ALG_SHA256,msg_buffer, RSA_MSG_LEN, digest, &dig_len);
+ printf("\n teec_digest res=%d line %d \n",res, __LINE__);
+ printf("\n \r digest dig_len =%d \n \r",dig_len);
+ for (i = 0; i < dig_len; i++)
+ printf("%x", digest[i]);
+ printf("\n");
+ res = teec_asy_sign(&ctx, TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256,digest, dig_len, sign, &sign_len);
+ printf("\n teec_asy_sign res=%d line %d \n",res, __LINE__);
+ key_data.public1 = g_Publickey2048_N;
+ key_data.pub_size1 = sizeof(g_Publickey2048_N);
+ key_data.public2 = g_Publickey2048_E;
+ key_data.pub_size2 = sizeof(g_Publickey2048_E);
+ res = teec_rsa_public_keys(&ctx,TEE_TYPE_RSA_PUBLIC_KEY,key_size,&key_data);
+ printf("\n teec_rsa_public_keys res=%d line %d \n",res, __LINE__);
+ res = teec_asy_verify(&ctx,TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256, digest, dig_len, sign, sign_len);
+ printf("\n teec_asy_verify res=%d line %d \n",res, __LINE__);
+
+ key_size = 4096;
+ gettimeofday(&tv, NULL);
+ res = teec_asy_gen_keys(&ctx,TEE_TYPE_RSA_KEYPAIR,key_size);
+ gettimeofday(&tvend, NULL);
+ timelen=( tvend.tv_sec -tv.tv_sec)*SEC_TO_US + ( tvend.tv_usec -tv.tv_usec);
+ printf("\n teec_asy_gen_keys res=%d line %d timelen = %d \n",res, __LINE__,timelen);
+ plain_len=256;
+ len=4096;
+ res = teec_asy_encrypt(&ctx,TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256, clear, plain_len, ciph, &len);
+ printf("\n teec_asy_encrypt res=%d line %d \n",res, __LINE__);
+ res = teec_asy_decrypt(&ctx,TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256, ciph, len, clear, &plain_len);
+ printf("\n teec_asy_decrypt res=%d line %d \n",res, __LINE__);
+
+ teec_session_close(&ctx);
+
+ return 0;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/Android.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/Android.mk
new file mode 100755
index 0000000..6deae5b
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/Android.mk
@@ -0,0 +1,20 @@
+LOCAL_PATH := $(call my-dir)
+
+OPTEE_CLIENT_EXPORT ?= $(LOCAL_PATH)/../../optee_client/out/export
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS += -DANDROID_BUILD
+LOCAL_CFLAGS += -Wall
+
+LOCAL_SRC_FILES += host/main.c
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/ta/include \
+ $(OPTEE_CLIENT_EXPORT)/include
+
+LOCAL_SHARED_LIBRARIES := libteec
+LOCAL_MODULE := optee_example_secure_storage
+LOCAL_VENDOR_MODULE := true
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(LOCAL_PATH)/ta/Android.mk
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/CMakeLists.txt b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/CMakeLists.txt
new file mode 100755
index 0000000..f61693d
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/CMakeLists.txt
@@ -0,0 +1,13 @@
+project (optee_example_secure_storage C)
+
+set (SRC host/main.c)
+
+add_executable (${PROJECT_NAME} ${SRC})
+
+target_include_directories(${PROJECT_NAME}
+ PRIVATE ta/include
+ PRIVATE include)
+
+target_link_libraries (${PROJECT_NAME} PRIVATE teec)
+
+install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/Makefile
new file mode 100755
index 0000000..5592b54
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/Makefile
@@ -0,0 +1,13 @@
+export V ?= 0
+
+# If _HOST or _TA specific compilers are not specified, then use CROSS_COMPILE
+HOST_CROSS_COMPILE ?= $(CROSS_COMPILE)
+TA_CROSS_COMPILE ?= $(CROSS_COMPILE)
+
+.PHONY: all
+all:
+ $(MAKE) -C host CROSS_COMPILE="$(HOST_CROSS_COMPILE)" --no-builtin-variables
+
+.PHONY: clean
+clean:
+ $(MAKE) -C host clean
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/host/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/host/Makefile
new file mode 100755
index 0000000..639fd7a
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/host/Makefile
@@ -0,0 +1,28 @@
+CC ?= $(CROSS_COMPILE)gcc
+LD ?= $(CROSS_COMPILE)ld
+AR ?= $(CROSS_COMPILE)ar
+NM ?= $(CROSS_COMPILE)nm
+OBJCOPY ?= $(CROSS_COMPILE)objcopy
+OBJDUMP ?= $(CROSS_COMPILE)objdump
+READELF ?= $(CROSS_COMPILE)readelf
+
+OBJS = main.o
+
+CFLAGS += -Wall -I./include
+CFLAGS += -I$(TEEC_EXPORT)/include
+LDADD += -lteec -L$(TEEC_EXPORT)/lib
+
+BINARY = optee_example_secure_storage
+
+.PHONY: all
+all: $(BINARY)
+
+$(BINARY): $(OBJS)
+ $(CC) -o $@ $< $(LDADD)
+
+.PHONY: clean
+clean:
+ rm -f $(OBJS) $(BINARY)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/host/main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/host/main.c
new file mode 100755
index 0000000..328b6e6
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/secure_storage/host/main.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+/* OP-TEE TEE client API (built by optee_client) */
+#include <tee_client_api.h>
+
+/* TA API: UUID and command IDs */
+#include <ta_api.h>
+
+#define SSF_OBJECT_SIZE 8192
+#define TEST_OBJECT_SIZE 8192
+#define SEC_TO_US (1000000)
+#define TEST_CNT (10)
+volatile uint64_t writetimelen =0;
+volatile uint64_t readtimelen =0;
+volatile uint64_t deltimelen =0;
+
+void ssf_press_test(teec_info *ctx)
+{
+ char objet[128] = {0};
+ int i =0;
+ int res =0;
+ int bufflen =SSF_OBJECT_SIZE;
+
+ char *writedata = malloc(bufflen);
+ char *readdata = malloc(bufflen);
+
+ memset(writedata, 0xbb, bufflen);
+ printf("ssf_test_fuc start \n");
+ for(i =0; i<TEST_CNT; i++)
+ {
+ sprintf(objet, "ssfobjext%d", i);
+ res = teec_ss_write(ctx, objet,writedata,bufflen);
+ if (res != TEEC_SUCCESS)
+ {
+ printf("write_secure_object error error = %d \n",res);
+ }
+ res = teec_ss_read(ctx, objet, readdata, &bufflen);
+ if (res != TEEC_SUCCESS)
+ {
+ printf("read_secure_object error error = %d \n",res);
+ }
+ if (memcmp(writedata, readdata,SSF_OBJECT_SIZE))
+ {
+ printf("memcmp error error error = %d \n",res);
+ }
+ printf("ssf_test_fuc success = %d \n",i);
+ }
+ printf("ssf_test_fuc success = %d \n",i);
+ for(i =0; i<TEST_CNT; i++)
+ {
+ sprintf(objet, "ssfobjext%d", i);
+ res = teec_ss_delete(ctx, objet);
+ if (res != TEEC_SUCCESS)
+ printf("teec_ss_delete error error = %d \n",res);
+ }
+
+ printf("teec_ss_delete success = %d \n",i);
+ free(readdata);
+ free(writedata);
+}
+
+int main(void)
+{
+ teec_info ctx;
+ struct timeval tv;
+ struct timeval tvend;
+ uint64_t timelen;
+ int i =0;
+ char obj1_id[] = "object#1"; /* string identification for the object */
+ char obj2_id[] = "object#2"; /* string identification for the object */
+ char obj1_data[TEST_OBJECT_SIZE];
+ char read_data[TEST_OBJECT_SIZE];
+ TEEC_Result res;
+ int bufflen =SSF_OBJECT_SIZE;
+ TEEC_UUID uuid = TA_SECURE_STORAGE_UUID;
+
+ printf("Prepare session with the TA\n");
+ res = teec_session_init(&ctx,uuid);
+ if (res != 0)
+ {
+ printf("teec_session_init %d \n",res);
+ return res;
+ }
+
+ /*
+ * Create object, read it, delete it.
+ */
+ for(i =0; i<TEST_CNT; i++)
+ {
+ printf("\nTest on object \"%s\"\n", obj1_id);
+ printf("- Create and load object in the TA secure storage\n");
+ memset(obj1_data, 0xA1, sizeof(obj1_data));
+ gettimeofday(&tv, NULL);
+ res = teec_ss_write(&ctx, obj1_id, obj1_data, sizeof(obj1_data));
+ if (res != TEEC_SUCCESS)
+ errx(1, "Failed to create an object in the secure storage");
+ gettimeofday(&tvend, NULL);
+
+ timelen=tvend.tv_sec *SEC_TO_US + tvend.tv_usec - ( tv.tv_sec *SEC_TO_US + tv.tv_usec );
+ printf("\n teec_ss_write res=%d line %d timelen = %d \n",res, __LINE__,timelen);
+ writetimelen += timelen;
+ gettimeofday(&tv, NULL);
+ res = teec_ss_read(&ctx, obj1_id, read_data, &bufflen);
+ if (res != TEEC_SUCCESS)
+ errx(1, "Failed to read an object from the secure storage");
+ gettimeofday(&tvend, NULL);
+
+ timelen=tvend.tv_sec *SEC_TO_US + tvend.tv_usec - ( tv.tv_sec *SEC_TO_US + tv.tv_usec );
+ printf("\n teec_ss_read res=%d line %d timelen = %d \n",res, __LINE__,timelen);
+ readtimelen += timelen;
+ if (memcmp(obj1_data, read_data, sizeof(obj1_data)))
+ errx(1, "Unexpected content found in secure storage");
+
+ printf("- Delete the object\n");
+ gettimeofday(&tv, NULL);
+ res = teec_ss_delete(&ctx, obj1_id);
+ if (res != TEEC_SUCCESS)
+ errx(1, "Failed to delete the object: 0x%x", res);
+ gettimeofday(&tvend, NULL);
+
+ timelen=tvend.tv_sec *SEC_TO_US + tvend.tv_usec - ( tv.tv_sec *SEC_TO_US + tv.tv_usec );
+ printf("\n teec_ss_delete res=%d line %d timelen = %d \n",res, __LINE__,timelen);
+ deltimelen += timelen;
+ }
+
+ printf("\n teec_ss_write res=%d line %d total writetimelen = %d \n",res, __LINE__,writetimelen);
+ printf("\n teec_ss_read res=%d line %d total readtimelen = %d \n",res, __LINE__,readtimelen);
+ printf("\n teec_ss_delete res=%d line %d total deltimelen = %d \n",res, __LINE__,deltimelen);
+ /*
+ * Non volatile storage: create object2 if not found, delete it if found
+ */
+ printf("\nTest on object \"%s\"\n", obj2_id);
+ res = teec_ss_read(&ctx, obj2_id, read_data, &bufflen);
+ if (res != TEEC_SUCCESS && res != TEEC_ERROR_ITEM_NOT_FOUND)
+ errx(1, "Unexpected status when reading an object : 0x%x", res);
+
+ if (res == TEEC_ERROR_ITEM_NOT_FOUND) {
+ char data[] = "This is data stored in the secure storage.\n";
+ printf("- Object not found in TA secure storage, create it.\n");
+ res = teec_ss_write(&ctx, obj2_id, data, sizeof(data));
+ if (res != TEEC_SUCCESS)
+ errx(1, "Failed to create/load an object");
+
+ } else if (res == TEEC_SUCCESS) {
+ printf("- Object found in TA secure storage, delete it.\n");
+ res = teec_ss_delete(&ctx, obj2_id);
+ if (res != TEEC_SUCCESS)
+ errx(1, "Failed to delete an object");
+ }
+ //ѹÁ¦²âÊÔ
+ //while(1)
+ ssf_press_test(&ctx);
+ printf("\nWe're done, close and release TEE resources\n");
+ teec_session_close(&ctx);
+ return 0;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/LICENSE b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/LICENSE
new file mode 100755
index 0000000..261eeb9
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/LICENSE
@@ -0,0 +1,201 @@
+ 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
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/Makefile
new file mode 100755
index 0000000..5592b54
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/Makefile
@@ -0,0 +1,13 @@
+export V ?= 0
+
+# If _HOST or _TA specific compilers are not specified, then use CROSS_COMPILE
+HOST_CROSS_COMPILE ?= $(CROSS_COMPILE)
+TA_CROSS_COMPILE ?= $(CROSS_COMPILE)
+
+.PHONY: all
+all:
+ $(MAKE) -C host CROSS_COMPILE="$(HOST_CROSS_COMPILE)" --no-builtin-variables
+
+.PHONY: clean
+clean:
+ $(MAKE) -C host clean
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/README.md b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/README.md
new file mode 100755
index 0000000..b5725e7
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/README.md
@@ -0,0 +1,55 @@
+# optee_rsa_example
+This is an example of RSA encrypt/decrypt methods running on OP-TEE.
+
+Below, you find the steps to setup the environment to run OPTEE on QEMU. These steps are available in the build page of the OPTEE github (https://github.com/OP-TEE/build).
+
+To get and build OPTEE on QEMU, you have to follow the steps below:
+
+1. Install the following packages:
+
+ sudo apt-get install android-tools-adb android-tools-fastboot autoconf \
+ automake bc bison build-essential cscope curl device-tree-compiler \
+ expect flex ftp-upload gdisk iasl libattr1-dev libc6:i386 libcap-dev \
+ libfdt-dev libftdi-dev libglib2.0-dev libhidapi-dev libncurses5-dev \
+ libpixman-1-dev libssl-dev libstdc++6:i386 libtool libz1:i386 make \
+ mtools netcat python-crypto python-serial python-wand unzip uuid-dev \
+ xdg-utils xterm xz-utils zlib1g-dev
+
+2. Get the repo tool and make it executable:
+
+ wget https://storage.googleapis.com/git-repo-downloads/repo
+ chmod a+x repo
+
+3. Create a directory for optee and enter inside it:
+
+ mkdir optee
+ cd optee
+
+4. Get the source code:
+
+ ./../repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml
+ ./../repo sync
+
+5. Get the toolchains:
+
+ cd build
+ make toolchains
+
+6. Build the solution:
+
+ make
+
+7. Run OPTEE on QEMU:
+
+ make run
+
+8. When the process stops, the QEMU console will be waiting. Just type c to continue. Two terminals will open: one with the "Rich OS" (Normal World) and another with the "Trusted OS" (Trusted World - OPTEE).
+
+9. In the Rich OS (Normal World), enter "root" to login. You now can test the examples, running one of the following:
+
+ hello_world
+ aes
+ hotp
+ random
+
+10. To run this RSA example, clone this GitHub repository in the optee/optee_examples folder, update the needed references according to the organization in your system and `make run`again. When this process finishes and you login in the normal world, you can run also the rsa application, just typing rsa.
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/host/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/host/Makefile
new file mode 100755
index 0000000..68e4a45
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/host/Makefile
@@ -0,0 +1,28 @@
+CC ?= $(CROSS_COMPILE)gcc
+LD ?= $(CROSS_COMPILE)ld
+AR ?= $(CROSS_COMPILE)ar
+NM ?= $(CROSS_COMPILE)nm
+OBJCOPY ?= $(CROSS_COMPILE)objcopy
+OBJDUMP ?= $(CROSS_COMPILE)objdump
+READELF ?= $(CROSS_COMPILE)readelf
+
+OBJS = main.o
+
+CFLAGS += -Wall -I../ta/include -I./include
+CFLAGS += -I$(TEEC_EXPORT)/include
+LDADD += -lteec -L$(TEEC_EXPORT)/lib
+
+BINARY = optee_example_sm2
+
+.PHONY: all
+all: $(BINARY)
+
+$(BINARY): $(OBJS)
+ $(CC) -o $@ $< $(LDADD)
+
+.PHONY: clean
+clean:
+ rm -f $(OBJS) $(BINARY)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/host/main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/host/main.c
new file mode 100755
index 0000000..7269d63
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm2/host/main.c
@@ -0,0 +1,208 @@
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+
+/* OP-TEE TEE client API (built by optee_client) */
+#include <tee_client_api.h>
+#include <ta_api.h>
+//#define SM2_KEY_SIZE 1024
+#define SM2_MAX_PLAIN_LEN_1024 86 // (1024/8) - 42 (padding)
+#define SM2_CIPHER_LEN_1024 (128)//(SM2_KEY_SIZE / 8)
+#define SM2_MSG_LEN 2048
+#define SM2_KEY_SIZE 256
+/* SM2 encryption/decryption */
+static const uint8_t sm2_testvector2_ptx[] =
+/* M */
+ "This test vector is used to test encryption then decryption. The "
+ "plain text is longer than 64 characters, so it will exercise parts "
+ "of the code that are not used for shorter messages.";
+static const uint8_t sm2_testvector2_private[] = {
+/* dB */
+ 0x39, 0x45, 0x20, 0x8F, 0x7B, 0x21, 0x44, 0xB1, 0x3F, 0x36, 0xE3, 0x8A,
+ 0xC6, 0xD3, 0x9F, 0x95, 0x88, 0x93, 0x93, 0x69, 0x28, 0x60, 0xB5, 0x1A,
+ 0x42, 0xFB, 0x81, 0xEF, 0x4D, 0xF7, 0xC5, 0xB8
+};
+static const uint8_t sm2_testvector2_public_x[] = {
+/* xB */
+ 0x09, 0xF9, 0xDF, 0x31, 0x1E, 0x54, 0x21, 0xA1, 0x50, 0xDD, 0x7D, 0x16,
+ 0x1E, 0x4B, 0xC5, 0xC6, 0x72, 0x17, 0x9F, 0xAD, 0x18, 0x33, 0xFC, 0x07,
+ 0x6B, 0xB0, 0x8F, 0xF3, 0x56, 0xF3, 0x50, 0x20
+};
+static const uint8_t sm2_testvector2_public_y[] = {
+/* yB */
+ 0xCC, 0xEA, 0x49, 0x0C, 0xE2, 0x67, 0x75, 0xA5, 0x2D, 0xC6, 0xEA, 0x71,
+ 0x8C, 0xC1, 0xAA, 0x60, 0x0A, 0xED, 0x05, 0xFB, 0xF3, 0x5E, 0x08, 0x4A,
+ 0x66, 0x32, 0xF6, 0x07, 0x2D, 0xA9, 0xAD, 0x13
+};
+static const uint8_t sm2_testvector2_out[] = {
+ 0x00, /* Not used -- test runs in encrypt/decrypt mode */
+};
+
+/*
+ * G/MT 0003 (SM2) Part 5 Annex A.2 - SM2 digital signature based on
+ * elliptic curves
+ */
+static const uint8_t gmt_003_part5_a2_ptx[] = {
+ /* ZA = SM3(ENTLA || IDA || a || b || xG || yG || xA || yA) */
+ 0xB2, 0xE1, 0x4C, 0x5C, 0x79, 0xC6, 0xDF, 0x5B, 0x85, 0xF4, 0xFE, 0x7E,
+ 0xD8, 0xDB, 0x7A, 0x26, 0x2B, 0x9D, 0xA7, 0xE0, 0x7C, 0xCB, 0x0E, 0xA9,
+ 0xF4, 0x74, 0x7B, 0x8C, 0xCD, 0xA8, 0xA4, 0xF3,
+ /* M */
+ 0x6D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x64, 0x69, 0x67, 0x65,
+ 0x73, 0x74
+};
+static const uint8_t gmt_003_part5_a2_private[] = {
+ /* dA */
+ 0x39, 0x45, 0x20, 0x8F, 0x7B, 0x21, 0x44, 0xB1, 0x3F, 0x36, 0xE3, 0x8A,
+ 0xC6, 0xD3, 0x9F, 0x95, 0x88, 0x93, 0x93, 0x69, 0x28, 0x60, 0xB5, 0x1A,
+ 0x42, 0xFB, 0x81, 0xEF, 0x4D, 0xF7, 0xC5, 0xB8,
+};
+static const uint8_t gmt_003_part5_a2_public_x[] = {
+ /* xA */
+ 0x09, 0xF9, 0xDF, 0x31, 0x1E, 0x54, 0x21, 0xA1, 0x50, 0xDD, 0x7D, 0x16,
+ 0x1E, 0x4B, 0xC5, 0xC6, 0x72, 0x17, 0x9F, 0xAD, 0x18, 0x33, 0xFC, 0x07,
+ 0x6B, 0xB0, 0x8F, 0xF3, 0x56, 0xF3, 0x50, 0x20,
+};
+static const uint8_t gmt_003_part5_a2_public_y[] = {
+ /* yA */
+ 0xCC, 0xEA, 0x49, 0x0C, 0xE2, 0x67, 0x75, 0xA5, 0x2D, 0xC6, 0xEA, 0x71,
+ 0x8C, 0xC1, 0xAA, 0x60, 0x0A, 0xED, 0x05, 0xFB, 0xF3, 0x5E, 0x08, 0x4A,
+ 0x66, 0x32, 0xF6, 0x07, 0x2D, 0xA9, 0xAD, 0x13,
+};
+static const uint8_t gmt_003_part5_a2_out[] = {
+ /* r */
+ 0xF5, 0xA0, 0x3B, 0x06, 0x48, 0xD2, 0xC4, 0x63, 0x0E, 0xEA, 0xC5, 0x13,
+ 0xE1, 0xBB, 0x81, 0xA1, 0x59, 0x44, 0xDA, 0x38, 0x27, 0xD5, 0xB7, 0x41,
+ 0x43, 0xAC, 0x7E, 0xAC, 0xEE, 0xE7, 0x20, 0xB3,
+ /* s */
+ 0xB1, 0xB6, 0xAA, 0x29, 0xDF, 0x21, 0x2F, 0xD8, 0x76, 0x31, 0x82, 0xBC,
+ 0x0D, 0x42, 0x1C, 0xA1, 0xBB, 0x90, 0x38, 0xFD, 0x1F, 0x7F, 0x42, 0xD4,
+ 0x84, 0x0B, 0x69, 0xC4, 0x85, 0xBB, 0xC1, 0xAA,
+};
+
+char *g_test_string ="MIIEpAIBAAKCAQEAploYrcCzzuMMkCt9QJusu1pJiEIKseCSwIaR5p7voOHxL5D2Zt3qFVrAKLSd31IMbqXGGUOsaajyX/5gAKXSOswSAfNbugxRHCz0sHe51nI1HA9zzS8W+bqJhKCbv4tbf+iLi5/IceocbB8AoO7KPr8YjlebSGbri9RAUa6GoYb40Av6ti4lLgX/dgFG1z3rH3z83x6Ci16wyqPqFr4tblRQnLhB7xfHf2BUqvlwoPiYLoL5jF/7nIiOd7Aycpka4ARevx2q9/AFPLSV3U26OnGh+HKOHZjjE7rKsCe/h1lUJ/jo7MaFN9I6leSlCZrQH6OGsJLYAh4zddsmvyf8NQIDAQABAoIBAEoooBfVcFMqpM8glBXZUIe1GFLGHj5t/v4U/7Xv5KO0FfE+jpoNE+2xJzj+S+LikOhCvq1Enff8eRCSNfoT8kSD9QMpmhq2ovIMmIiS1yXihAqeWOF/vJ5XqjaV4tjhJ0k+Qfdco98knscUixMzYLXYOvo509/TAe60EHhZdWtMKCmHqvFBRDhYFF+HUxWnJa39G1u828ljv8uNiRCXbEjoaWDwBJWRzDZJehrkQc2gQAkFpyePVqA3wm1tx1ZHEVwCqYOXOP49/LAcrQfoWUpm4chjEHnZEb+dQxa3N8Qeq2lqgcqrOX8NIfpzWTWQ1JM+ksinQwMJ0BDV+Lf1nAECgYEA2KBBtsj41ITez8iA0DpXovH1F9oU9aJ9JKopNos8zIZg012bE5IbkFII0LiBGKLUP2PepTsPDIOxibLQDojg1aBGHISZVp/y81B4Rk7Wwg206ZQ848dMAhACIrzOtJLoVEZTPf7C5QrNMhViyf2c8vFBjfTuM7Ze6a0fsvfJ2ikCgYEAxJaOXKnOgKoG1Fe9JVM01U+260BEybNUbbXQCnvMjTSZCsOEmST9mhXhC56lhCNqmyntFxNuq/JMwtS3TRhrYCPPCLFly+JNTqUS1mLQ9ytVbaw6fp9mSxFUQE9d9obkGwJC3uXEx+bc7YSGuwD34wikX0tB1zzGIXRH2JlB6y0CgYEAgFlDVjdxJwmqslXL7JQExKizXPR7oqYpm4WucYDB/zRHPjSh41CYQEQ6sOAArUYcl4pmqmN5oSKOGFX37ASxoiEaKV9vMuIGIp+1A4NGvyc734FTKmo04Kv3d/mCR38bZINeYscFVou11EzTgXZgfZjwDFnooH8XcUCAHZuu3zECgYEAt6pltSMcgE7Z9JdIas/TI5vHLQEtgzhdH+bmSHUjRaWnekvy3VWW7deVGtMMlmi0V+US0iVgl5rXposv+gJfh0HNUrTSg2qZiWlmMQ+/Zb2BoeZv/A8Wdfnpue+svP+Hq8gwC6mlcJI7RFk1uw8LiXxwfWuFRv9LqMPHwBBnar0CgYAJF3ukzm7rnut19lzS4r1uEIuuPwk/DjEkkil7U9wE5fr+ds5rCtXj9591DLHrtE/CBOWym2+tIDr7OnmfU+934524mtLWVZdf39/DFM9Fc1VaSualrj/1BOLhBb7MEZqN7hHcQP7+49YW72GgX3pm0Ov5ke33FzN3ubIwAS6T7A==";
+
+int main(int argc, char *argv[])
+{
+ teec_info ctx;
+ char clear[SM2_MAX_PLAIN_LEN_1024] = {0};
+ char ciph[SM2_CIPHER_LEN_1024];
+ int len =SM2_CIPHER_LEN_1024;
+ int plain_len = SM2_MAX_PLAIN_LEN_1024;
+ uint8_t msg_buffer[SM2_MSG_LEN] = {0};
+ uint32_t msg_len =SM2_MSG_LEN;
+ char digest[SM2_MSG_LEN] = {0};
+ int dig_len =SM2_MSG_LEN/8;
+ char sign[SM2_MSG_LEN];
+ int sign_len=SM2_MSG_LEN/8;
+ int i;
+ key_data_t key_data;
+ TEEC_Result res= TEEC_SUCCESS;
+ TEEC_UUID uuid = TA_CRYPT_UUID;
+ int key_size =SM2_KEY_SIZE;
+
+ res = teec_session_init(&ctx,uuid);
+ if (res != 0)
+ {
+ printf("teec_session_init %d \n",res);
+ return res;
+ }
+
+ strncpy(clear,g_test_string,SM2_MAX_PLAIN_LEN_1024-1);
+ res = teec_asy_gen_keys(&ctx,TEE_TYPE_SM2_PKE_KEYPAIR,key_size);
+ printf("\n teec_asy_gen_keys res=%d line %d \n",res, __LINE__);
+ len=len+len;
+ res = teec_asy_encrypt(&ctx,TEE_ALG_SM2_PKE, clear, SM2_MAX_PLAIN_LEN_1024, ciph, &len);
+ printf("\n teec_asy_encrypt res=%d line %d \n",res, __LINE__);
+
+ res = teec_asy_decrypt(&ctx,TEE_ALG_SM2_PKE, ciph, len, clear, &plain_len);
+ printf("\n teec_asy_decrypt res=%d line %d \n",res, __LINE__);
+
+ memset(msg_buffer,0xAB,SM2_MSG_LEN);
+ res = teec_digest(&ctx, TEE_ALG_SM3,msg_buffer, SM2_MSG_LEN, digest, &dig_len);
+ printf("\n teec_digest res=%d line = %d digest = %d \n",res, __LINE__,dig_len);
+
+ res = teec_asy_gen_keys(&ctx,TEE_TYPE_SM2_DSA_KEYPAIR,SM2_KEY_SIZE);
+ printf("\n teec_asy_gen_keys res=%d line %d \n",res, __LINE__);
+ sign_len =sign_len+sign_len;
+
+ res = teec_asy_sign(&ctx, TEE_ALG_SM2_DSA_SM3,digest, dig_len, sign, &sign_len);
+ printf("\n teec_asy_sign res=%d line %d \n",res, __LINE__);
+ printf("\n \r sign sign_len =%d \n \r",sign_len);
+ for (i = 0; i < sign_len; i++)
+ printf("%x", sign[i]);
+ printf("\n");
+
+ res = teec_asy_verify(&ctx,TEE_ALG_SM2_DSA_SM3, digest, dig_len, sign, sign_len);
+ printf("\n teec_asy_verify res=%d line %d \n",res, __LINE__);
+ teec_session_close(&ctx);
+
+ res = teec_session_init(&ctx,uuid);
+ if (res != 0)
+ {
+ printf("teec_session_init %d \n",res);
+ return res;
+ }
+ strncpy(clear,g_test_string,SM2_MAX_PLAIN_LEN_1024-1);
+
+ key_data.public1 = sm2_testvector2_public_x;
+ key_data.pub_size1 = sizeof(sm2_testvector2_public_x);
+ key_data.public2 = sm2_testvector2_public_y;
+ key_data.pub_size2 = sizeof(sm2_testvector2_public_y);
+
+ res = teec_sm2_public_keys(&ctx,TEE_TYPE_SM2_PKE_PUBLIC_KEY,SM2_KEY_SIZE,&key_data);
+ printf("\n teec_rsa_public_keys res=%d line %d \n",res, __LINE__);
+
+ len=len+len;
+ printf("\n \r plain_len =%d \n \r",SM2_MAX_PLAIN_LEN_1024);
+ for (i = 0; i < SM2_MAX_PLAIN_LEN_1024; i++)
+ printf("%x", clear[i]);
+ printf("\n");
+
+ res = teec_asy_encrypt(&ctx,TEE_ALG_SM2_PKE, clear, SM2_MAX_PLAIN_LEN_1024, ciph, &len);
+ printf("\n teec_asy_encrypt res=%d line %d \n",res, __LINE__);
+
+ key_data.public1 = sm2_testvector2_public_x;
+ key_data.pub_size1 = sizeof(sm2_testvector2_public_x);
+ key_data.public2 = sm2_testvector2_public_y;
+ key_data.pub_size2 = sizeof(sm2_testvector2_public_y);
+ key_data.private = sm2_testvector2_private;
+ key_data.priv_size = sizeof(sm2_testvector2_private);
+
+ res = teec_sm2_private_keys(&ctx,TEE_TYPE_SM2_PKE_KEYPAIR,SM2_KEY_SIZE,&key_data);
+ printf("\n teec_rsa_private_keys res=%d line %d \n",res, __LINE__);
+ res = teec_asy_decrypt(&ctx,TEE_ALG_SM2_PKE, ciph, len, clear, &plain_len);
+ printf("\n teec_asy_decrypt res=%d line %d \n",res, __LINE__);
+
+ memset(msg_buffer,0xAB,SM2_MSG_LEN);
+ res = teec_digest(&ctx, TEE_ALG_SM3,msg_buffer, SM2_MSG_LEN, digest, &dig_len);
+ printf("\n teec_digest res=%d line %d \n",res, __LINE__);
+ printf("\n \r digest dig_len =%d \n \r",dig_len);
+ for (i = 0; i < dig_len; i++)
+ printf("%x", digest[i]);
+ printf("\n");
+
+ key_data.public1 = gmt_003_part5_a2_public_x;
+ key_data.pub_size1 = sizeof(gmt_003_part5_a2_public_x);
+ key_data.public2 = gmt_003_part5_a2_public_y;
+ key_data.pub_size2 = sizeof(gmt_003_part5_a2_public_y);
+ key_data.private = gmt_003_part5_a2_private;
+ key_data.priv_size = sizeof(gmt_003_part5_a2_private);
+ res = teec_sm2_private_keys(&ctx,TEE_TYPE_SM2_DSA_KEYPAIR,SM2_KEY_SIZE,&key_data);
+ printf("\n teec_rsa_private_keys res=%d line %d \n",res, __LINE__);
+ res = teec_asy_sign(&ctx, TEE_ALG_SM2_DSA_SM3,digest, dig_len, sign, &sign_len);
+ printf("\n teec_asy_sign res=%d line %d \n",res, __LINE__);
+
+ key_data.public1 = gmt_003_part5_a2_public_x;
+ key_data.pub_size1 = sizeof(gmt_003_part5_a2_public_x);
+ key_data.public2 = gmt_003_part5_a2_public_y;
+ key_data.pub_size2 = sizeof(gmt_003_part5_a2_public_y);
+ res = teec_sm2_public_keys(&ctx,TEE_TYPE_SM2_DSA_PUBLIC_KEY,SM2_KEY_SIZE,&key_data);
+ printf("\n teec_rsa_public_keys res=%d line %d \n",res, __LINE__);
+
+ res = teec_asy_verify(&ctx,TEE_ALG_SM2_DSA_SM3, digest, dig_len, sign, sign_len);
+ printf("\n teec_asy_verify res=%d line %d \n",res, __LINE__);
+ teec_session_close(&ctx);
+
+ return 0;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/Android.mk b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/Android.mk
new file mode 100755
index 0000000..a8b6bc7
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/Android.mk
@@ -0,0 +1,20 @@
+LOCAL_PATH := $(call my-dir)
+
+OPTEE_CLIENT_EXPORT ?= $(LOCAL_PATH)/../../optee_client/out/export
+
+include $(CLEAR_VARS)
+LOCAL_CFLAGS += -DANDROID_BUILD
+LOCAL_CFLAGS += -Wall
+
+LOCAL_SRC_FILES += host/main.c
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/ta/include \
+ $(OPTEE_CLIENT_EXPORT)/include
+
+LOCAL_SHARED_LIBRARIES := libteec
+LOCAL_MODULE := optee_example_sm4
+LOCAL_VENDOR_MODULE := true
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(LOCAL_PATH)/ta/Android.mk
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/Makefile
new file mode 100755
index 0000000..5592b54
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/Makefile
@@ -0,0 +1,13 @@
+export V ?= 0
+
+# If _HOST or _TA specific compilers are not specified, then use CROSS_COMPILE
+HOST_CROSS_COMPILE ?= $(CROSS_COMPILE)
+TA_CROSS_COMPILE ?= $(CROSS_COMPILE)
+
+.PHONY: all
+all:
+ $(MAKE) -C host CROSS_COMPILE="$(HOST_CROSS_COMPILE)" --no-builtin-variables
+
+.PHONY: clean
+clean:
+ $(MAKE) -C host clean
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/host/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/host/Makefile
new file mode 100755
index 0000000..06a3f0e
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/host/Makefile
@@ -0,0 +1,28 @@
+CC ?= $(CROSS_COMPILE)gcc
+LD ?= $(CROSS_COMPILE)ld
+AR ?= $(CROSS_COMPILE)ar
+NM ?= $(CROSS_COMPILE)nm
+OBJCOPY ?= $(CROSS_COMPILE)objcopy
+OBJDUMP ?= $(CROSS_COMPILE)objdump
+READELF ?= $(CROSS_COMPILE)readelf
+
+OBJS = main.o
+
+CFLAGS += -Wall -I./include
+CFLAGS += -I$(TEEC_EXPORT)/include
+LDADD += -lteec -L$(TEEC_EXPORT)/lib
+
+BINARY = optee_example_sm4
+
+.PHONY: all
+all: $(BINARY)
+
+$(BINARY): $(OBJS)
+ $(CC) -o $@ $< $(LDADD)
+
+.PHONY: clean
+clean:
+ rm -f $(OBJS) $(BINARY)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/host/main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/host/main.c
new file mode 100755
index 0000000..c7bd572
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/opteetest/sm4/host/main.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+
+/* OP-TEE TEE client API (built by optee_client) */
+#include <tee_client_api.h>
+#include <ta_api.h>
+
+#define SM4_TEST_BUFFER_SIZE 4096
+#define SM4_TEST_KEY_SIZE 16
+#define SM4_BLOCK_SIZE 16
+
+int main(void)
+{
+ teec_info ctx;
+ char key[SM4_TEST_KEY_SIZE];
+ char iv[SM4_BLOCK_SIZE];
+ char clear[SM4_TEST_BUFFER_SIZE];
+ char ciph[SM4_TEST_BUFFER_SIZE];
+ char temp[SM4_TEST_BUFFER_SIZE];
+ int i =0;
+ TEEC_Result res= TEEC_SUCCESS;
+ int keylen =SM4_TEST_KEY_SIZE;
+ int bufflen =SM4_TEST_BUFFER_SIZE;
+ TEEC_UUID uuid = TA_CRYPT_UUID;
+
+ res = teec_session_init(&ctx,uuid);
+ if (res != 0)
+ {
+ printf("teec_session_init %d \n",res);
+ return res;
+ }
+ memset(key, 0xa5, keylen);
+ res=teec_set_key(&ctx, TEE_TYPE_SM4,key, keylen);
+ printf("\n TEE_ALG_SM4_CTR res=%d line %d \n",res, __LINE__);
+ printf("\n TEE_TYPE_SM4 res=%d line %d \n",res, __LINE__);
+ for (i = 0; i < keylen; i++)
+ printf("%x", key[i]);
+
+ memset(iv, 0, sizeof(iv));
+ res= teec_cipher_init(&ctx,TEE_ALG_SM4_CTR,TEE_MODE_ENCRYPT,iv,SM4_BLOCK_SIZE);
+ printf("\n TEE_ALG_SM4_CTR teec_cipher_init res=%d line %d \n",res, __LINE__);
+ memset(clear, 0x5a, sizeof(clear));
+ bufflen =SM4_TEST_BUFFER_SIZE;
+ res= teec_cipher(&ctx, clear, SM4_TEST_BUFFER_SIZE,ciph, &bufflen);
+ printf("\n teec_cipher res=%d line %d \n",res, __LINE__);
+ memset(key, 0xa5, keylen);
+ res=teec_set_key(&ctx, TEE_TYPE_SM4,key, keylen);
+ printf("\n TEE_ALG_SM4_CTR res=%d line %d \n",res, __LINE__);
+ memset(iv, 0, sizeof(iv));
+ res= teec_cipher_init(&ctx,TEE_ALG_SM4_CTR,TEE_MODE_DECRYPT,iv,SM4_BLOCK_SIZE);
+ printf("\n TEE_ALG_SM4_CTR set_cipher_infores=%d line %d \n",res, __LINE__);
+ bufflen =SM4_TEST_BUFFER_SIZE;
+ res= teec_cipher(&ctx, ciph, SM4_TEST_BUFFER_SIZE,temp, &bufflen);
+ printf("\n TEE_ALG_SM4_CTR teec_cipher =%d line %d \n",res, __LINE__);
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, SM4_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < SM4_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+
+ teec_session_close(&ctx);
+
+ res = teec_session_init(&ctx,uuid);
+ if (res != 0)
+ {
+ printf("teec_session_init %d \n",res);
+ return res;
+ }
+ keylen = 32;
+ res= teec_gen_keys(&ctx,TEE_TYPE_SM4,SM4_TEST_KEY_SIZE,key,&keylen);
+ printf("\n TEE_TYPE_SM4 res=%d line %d \n",res, __LINE__);
+ for (i = 0; i < keylen; i++)
+ printf("%x", key[i]);
+
+ res= teec_cipher_init(&ctx,TEE_ALG_SM4_ECB_NOPAD,TEE_MODE_ENCRYPT,NULL,0);
+ printf("\n TEE_ALG_SM4_ECB_NOPAD teec_cipher_init res=%d line %d \n",res, __LINE__);
+ memset(clear, 0x5a, sizeof(clear));
+ bufflen =SM4_TEST_BUFFER_SIZE;
+ res= teec_cipher(&ctx, clear, SM4_TEST_BUFFER_SIZE,ciph, &bufflen);
+ printf("\n teec_cipher res=%d line %d \n",res, __LINE__);
+
+ res= teec_cipher_init(&ctx,TEE_ALG_SM4_ECB_NOPAD,TEE_MODE_DECRYPT,NULL,0);
+ printf("\n TEE_ALG_SM4_ECB_NOPAD set_cipher_infores=%d line %d \n",res, __LINE__);
+ bufflen =SM4_TEST_BUFFER_SIZE;
+ res= teec_cipher(&ctx, ciph, SM4_TEST_BUFFER_SIZE,temp, &bufflen);
+ printf("\n TEE_ALG_SM4_ECB_NOPAD teec_cipher =%d line %d \n",res, __LINE__);
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, SM4_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < SM4_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+
+ teec_session_close(&ctx);
+ res = teec_session_init(&ctx,uuid);
+ if (res != 0)
+ {
+ printf("teec_session_init %d \n",res);
+ return res;
+ }
+ keylen = SM4_TEST_KEY_SIZE;
+ memset(key, 0xa5,keylen);
+ res=teec_set_key(&ctx, TEE_TYPE_SM4,key, keylen);
+ printf("\n TEE_ALG_SM4_CTR res=%d line %d \n",res, __LINE__);
+ printf("\n TEE_TYPE_SM4 res=%d line %d \n",res, __LINE__);
+ for (i = 0; i < keylen; i++)
+ printf("%x", key[i]);
+
+ memset(iv, 0, sizeof(iv));
+ res= teec_cipher_init(&ctx,TEE_ALG_SM4_CBC_NOPAD,TEE_MODE_ENCRYPT,iv,SM4_BLOCK_SIZE);
+ printf("\n TEE_ALG_SM4_CBC_NOPAD teec_cipher_init res=%d line %d \n",res, __LINE__);
+ memset(clear, 0x5a, sizeof(clear));
+ bufflen =SM4_TEST_BUFFER_SIZE;
+ res= teec_cipher(&ctx, clear, SM4_TEST_BUFFER_SIZE,ciph, &bufflen);
+ printf("\n teec_cipher res=%d line %d \n",res, __LINE__);
+ memset(key, 0xa5, keylen);
+ res=teec_set_key(&ctx, TEE_TYPE_SM4,key, keylen);
+ printf("\n TEE_ALG_SM4_CTR res=%d line %d \n",res, __LINE__);
+ memset(iv, 0, sizeof(iv));
+ res= teec_cipher_init(&ctx,TEE_ALG_SM4_CBC_NOPAD,TEE_MODE_DECRYPT,iv,SM4_BLOCK_SIZE);
+ printf("\n TEE_ALG_SM4_CBC_NOPAD set_cipher_infores=%d line %d \n",res, __LINE__);
+ bufflen =SM4_TEST_BUFFER_SIZE;
+ res= teec_cipher(&ctx, ciph, SM4_TEST_BUFFER_SIZE,temp, &bufflen);
+ printf("\n TEE_ALG_SM4_CTR teec_cipher =%d line %d \n",res, __LINE__);
+
+ /* Check decoded is the clear content */
+ if (memcmp(clear, temp, SM4_TEST_BUFFER_SIZE))
+ {
+ for (i = 0; i < SM4_TEST_BUFFER_SIZE; i++)
+ printf("%x", temp[i]);
+ printf("Clear text and decoded text differ => ERROR\n");
+ }
+ else
+ printf("Clear text and decoded text match\n");
+
+ teec_session_close(&ctx);
+ return 0;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/rtc_timer_demo/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/rtc_timer_demo/Makefile
new file mode 100755
index 0000000..083deb4
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/rtc_timer_demo/Makefile
@@ -0,0 +1,43 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+SOFTAP_APP_DIR=$(shell pwd)
+##############USER COMIZE BEGIN################
+EXEC1 = rtc_timer_demo
+
+OBJS1 = $(patsubst %.c,%.o,$(wildcard *.c))
+
+CFLAGS += -I.
+CFLAGS += -I./../inc
+CFLAGS += -I$(zte_app_path)/include
+CFLAGS += -I$(zte_lib_path)/libnvram
+CFLAGS += -I$(zte_lib_path)/libsoftap
+
+CFLAGS += -g -Werror=implicit-function-declaration
+
+
+LDLIBS += -lpthread
+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram
+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS += -lsofttimer -L$(zte_lib_path)/libsoft_timer
+LDLIBS += -lsctel -L$(LIB_DIR)/libsctel
+LDLIBS += -lscipc -L$(LIB_DIR)/libscipc
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC1)
+
+$(EXEC1): $(OBJS1)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+
+romfs:
+ $(ROMFSINST) -e CONFIG_USER_ZTE_APP /sbin/$(EXEC1)
+
+clean:
+ -rm -f $(EXEC1) *.elf *.gdb *.o
+ -find . -name \*.o -exec rm -rf {} \;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/rtc_timer_demo/sc_rtc_timer_main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/rtc_timer_demo/sc_rtc_timer_main.c
new file mode 100755
index 0000000..62ffac2
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/rtc_timer_demo/sc_rtc_timer_main.c
@@ -0,0 +1,279 @@
+#include <ctype.h>
+#include <errno.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <limits.h>
+#include <netdb.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <syslog.h>
+#include <pthread.h>
+#include "message.h"
+#include "sc_rtc_timer.h"
+#include "mainctl_msg.h"
+
+#define CMD_ADD "add\n"
+#define CMD_ADD_UTC "add_utc\n"
+#define CMD_SET "set\n"
+#define CMD_GET "get\n"
+#define CMD_HELP "?\n"
+#define CMD_Q "q\n"
+
+static int year=0;
+static int mouth=0;
+static int date=0;
+static int hour=0;
+static int minute=0;
+static int seconds=0;
+static int wakeup=0;
+static int demo=0;
+static int timer_sec=0;
+
+static void printUsage(const char *Opt)
+{
+ printf("Usage: %s\n", Opt);
+ printf("-Y<Year> set year,please input number\n");
+ printf("-M<Mouth> set mouth,please input number\n");
+ printf("-D<Date> set date,please input number\n");
+ printf("-h<hour> set hour,please input number\n");
+ printf("-m<minute> set minute,please input number\n");
+ printf("-s<sec> set seconds,please input number\n");
+ printf("-w<wakeup> set timer wakeup\n");
+ printf("-d<callback demo> set callback demo,please input number\n");
+ printf("add add rtc timer\n");
+ printf("add_utc add rtc utc timer\n");
+ printf("set set rtc time\n");
+ printf("get get rtc time\n");
+ printf("q exit rtc-timer-demo\n");
+}
+
+static int parseOpts(int argc, char *argv[])
+{
+ int rc = 0;
+ int c;
+ while ((c = getopt(argc, argv, "?Y:M:D:h:m:s:w:d:t:")) != -1) {
+ switch (c) {
+ case 'Y':
+ year = atoi(optarg);
+ break;
+ case 'M':
+ mouth = atoi(optarg);
+ break;
+ case 'D':
+ date = atoi(optarg);
+ break;
+ case 'h':
+ hour = atoi(optarg);
+ break;
+ case 'm':
+ minute = atoi(optarg);
+ break;
+ case 's':
+ seconds = atoi(optarg);
+ break;
+ case 'w':
+ wakeup = atoi(optarg);
+ break;
+ case 'd':
+ demo = atoi(optarg);
+ break;
+ case 't':
+ timer_sec = atoi(optarg);
+ break;
+ case '?':
+ default:
+ printUsage(argv[0]);
+ return -1;
+ }
+ }
+
+ return rc;
+}
+
+int rtc_get_time_cb_demo0(unsigned int srcid,unsigned long ulsec)
+{
+ struct tm rtc_time = {0};
+ time_t tmp = 0;
+
+ tmp = (time_t)ulsec;
+
+ rtc_time = *localtime(&tmp);
+
+ printf("user id(srcid):0x%x,callback(rtc_get_time_cb_demo0) is success,%ld-%d-%d,%d:%d:%d!\n",srcid,rtc_time.tm_year+1900,rtc_time.tm_mon+1,rtc_time.tm_mday,rtc_time.tm_hour,rtc_time.tm_min,rtc_time.tm_sec);
+}
+
+int rtc_get_time_cb_demo1(unsigned int srcid,unsigned long ulsec)
+{
+ struct tm rtc_time = {0};
+ time_t tmp = 0;
+
+ tmp = (time_t)ulsec;
+
+ rtc_time = *localtime(&tmp);
+
+ printf("user id:0x%x,callback(rtc_get_time_cb_demo1) is success,%ld-%d-%d,%d:%d:%d!\n",srcid,rtc_time.tm_year+1900,rtc_time.tm_mon+1,rtc_time.tm_mday,rtc_time.tm_hour,rtc_time.tm_min,rtc_time.tm_sec);
+}
+
+int sc_rtc_timer_id_exp_cb_demo0(unsigned int src_id)
+{
+ int ret =0;
+
+ printf("user id:0x%x,callback(sc_rtc_timer_exp_cb_demo0) is success!\n",src_id);
+
+ return ret;
+}
+
+int sc_rtc_timer_id_exp_cb_demo1(unsigned int src_id)
+{
+ int ret =0;
+
+ printf("user id:0x%x,callback(sc_rtc_timer_exp_cb_demo1) is success!\n",src_id);
+
+ return ret;
+}
+
+static int rtc_timer_init(void)
+{
+ int ret = 0;
+
+ ret = sc_rtc_timer_init( );
+ if(ret <= 0 ) {
+ return -1;
+ }
+
+ return ret;
+}
+
+static int rtc_timer_deinit(void)
+{
+ return sc_rtc_timer_uninit();
+}
+
+static int sc_rtc_timer_add_utc_demo(struct tm *utc_sec, int src_id, int wakeup,sc_rtc_timer_exp_cb rtc_cb)
+{
+ int iRet = -1;
+
+ printf("sc_rtc_timer_add_utc_demo test \n");
+
+ iRet = sc_rtc_timer_add_utc(utc_sec, src_id, wakeup, rtc_cb);
+
+ printf("iRet=%d\n", iRet);
+
+ return 0;
+}
+
+static int sc_rtc_timer_add_demo(int srcid,unsigned long ulsec,sc_rtc_timer_exp_cb rtc_cb)
+{
+ int iRet = -1;
+
+ printf("sc_rtc_timer_add_demo test \n");
+
+ iRet = sc_rtc_timer_add(ulsec, srcid, rtc_cb);
+
+ printf("iRet=%d\n", iRet);
+
+ return 0;
+}
+
+static int sc_rtc_set_time_demo(int src_id)
+{
+ int iRet = -1;
+
+ printf("sc_rtc_set_time_demo test \n");
+
+ iRet = sc_rtc_time_set(src_id);
+
+ printf("iRet=%d\n", iRet);
+
+ return 0;
+}
+
+static int sc_rtc_get_time_demo(int src_id,sc_rtc_time_get_cb rtc_cb)
+{
+ int iRet = -1;
+
+ printf("sc_rtc_get_time_demo test \n");
+
+ iRet = sc_rtc_time_get(src_id,rtc_cb);
+
+ printf("iRet=%d\n", iRet);
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ char atstr[15] = {0};
+ int len = 0;
+ int srcid = 0 ;
+ printf("sc_rtc_timer_demo:Demo go.\n");
+
+ if(parseOpts(argc,argv) == -1)
+ {
+ printf("sc_rtc_timer_demo:Arg error.\n");
+ return -1;
+ }
+
+ if((srcid = rtc_timer_init( )) <= 0)
+ {
+ printf("rtc_timer_demo:rtc_timer_init fail!\n");
+ return 0;
+ }
+ printf("srcid:0x%x\n",srcid);
+ while(1)
+ {
+ memset(atstr,0,sizeof(atstr));
+ printf("Please input an at command:\n");
+ if(NULL != fgets(atstr,15 - 1,stdin))
+ {
+ if(0 == strcmp(CMD_ADD,atstr))
+ {
+ if(demo==1)
+ {sc_rtc_timer_add_demo(srcid,timer_sec,sc_rtc_timer_id_exp_cb_demo1);}
+ else
+ {sc_rtc_timer_add_demo(srcid,timer_sec,sc_rtc_timer_id_exp_cb_demo0);}
+ }
+ else if(0 == strcmp(CMD_GET,atstr))
+ {
+ if(demo==1)
+ {sc_rtc_get_time_demo(srcid,rtc_get_time_cb_demo1);}
+ else
+ {sc_rtc_get_time_demo(srcid,rtc_get_time_cb_demo0);}
+ }
+ else if(0 == strcmp(CMD_SET,atstr))
+ {
+ sc_rtc_set_time_demo(srcid);
+ }
+ else if(0 == strcmp(CMD_ADD_UTC,atstr))
+ {
+ struct tm sec = {0};
+ sec.tm_year = year-1900;
+ sec.tm_mon = mouth-1;
+ sec.tm_mday = date;
+ sec.tm_hour = hour;
+ sec.tm_min = minute;
+ sec.tm_sec = seconds;
+ if(demo==1)
+ {sc_rtc_timer_add_utc_demo(&sec,srcid,wakeup,sc_rtc_timer_id_exp_cb_demo1);}
+ else
+ {sc_rtc_timer_add_utc_demo(&sec,srcid,wakeup,sc_rtc_timer_id_exp_cb_demo0);}
+ }
+ else if(0 == strcmp(CMD_HELP,atstr))
+ {
+ printUsage(atstr);
+ }
+ else if(0 == strcmp(CMD_Q,atstr))
+ {
+ break;
+ }
+ }
+ }
+
+ rtc_timer_deinit( );
+ printf("sc_rtc_timer_demo:Demo over.\n");
+ return 0;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_cfg_test/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_cfg_test/Makefile
new file mode 100755
index 0000000..c1e9c62
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_cfg_test/Makefile
@@ -0,0 +1,33 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = sc_cfg_test
+OBJS = sc_cfg_test.o
+
+CFLAGS += -g -Werror=implicit-function-declaration
+
+# LDLIBS = -lpthread -lm
+LDLIBS += -lnvram
+# LDLIBS += -lbsp
+#LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) $(EXEC)_recovery *.elf *.gdb *.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_cfg_test/sc_cfg_test.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_cfg_test/sc_cfg_test.c
new file mode 100755
index 0000000..35e8b5f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_cfg_test/sc_cfg_test.c
@@ -0,0 +1,88 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <linux/netlink.h>
+#include <poll.h>
+#include <linux/serial.h>
+#include <termios.h>
+#include <pthread.h>
+
+#include "cfg_api.h"
+
+int main(int argc, char **argv)
+{
+ char buf[4096] = {0};
+ char *name, *value;
+ int ret = 0;
+ ++argv;
+
+ if (!*argv)
+ {
+ return -2;
+ }
+
+ for (; *argv; argv++)
+ {
+ if (!strcmp(*argv, "get"))
+ {
+ if (*++argv)
+ {
+ ret = sc_cfg_get(*argv, buf, sizeof(buf));
+ if (0 != strncmp("", buf, sizeof(buf)))
+ {
+ puts(buf);
+ }
+ }
+ }
+ else if (!strcmp(*argv, "set"))
+ {
+ if (*++argv)
+ {
+ value = buf;
+ strncpy(value, *argv, sizeof(buf) - 1);
+ value[sizeof(buf) - 1] = '\0';
+ name = strsep(&value, "=");
+ ret = sc_cfg_set(name, value);
+ }
+ }
+ else if (!strcmp(*argv, "unset"))
+ {
+ if (*++argv)
+ {
+ ret = sc_cfg_unset(*argv);
+ }
+ }
+ else if (!strcmp(*argv, "show"))
+ {
+ ret = sc_cfg_show();
+ }
+ else if (!strcmp(*argv, "save"))
+ {
+ ret = sc_cfg_save();
+ }
+ else if (!strcmp(*argv, "reset"))
+ {
+ ret = sc_cfg_reset();
+ }
+ else
+ {
+ return -2;
+ }
+
+ if (!*argv)
+ {
+ return -2;
+ }
+ }
+
+ return ret;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_log_test/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_log_test/Makefile
new file mode 100755
index 0000000..558a10d
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_log_test/Makefile
@@ -0,0 +1,35 @@
+#*******************************************************************************
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = sc_log_test
+
+OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
+
+CFLAGS += -I.
+CFLAGS += -I$(APP_DIR)/include
+CFLAGS += -I./../inc
+
+CFLAGS += -g -Werror=implicit-function-declaration
+
+
+LDLIBS += -lsclog -lnvram
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_log_test/sc_log_test.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_log_test/sc_log_test.c
new file mode 100755
index 0000000..267af57
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_log_test/sc_log_test.c
@@ -0,0 +1,25 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "sc_log.h"
+
+
+int main (int argc, char *argv[])
+{
+ int i = 10;
+ sc_log_init("sc_log_test");
+
+ for(i = 0; i < 10; i++)
+ {
+ sc_log_debug("This is %d syslog ----------debug----------\n", i);
+ sc_log_normal("This is %d syslog ----------normal----------\n", i);
+ sc_log_error("This is %d syslog ----------error----------\n", i);
+ }
+
+ return 0;
+}
+
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/Makefile
new file mode 100755
index 0000000..d5098e3
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/Makefile
@@ -0,0 +1,39 @@
+include $(COMMON_MK)
+
+EXEC = sc_net_test
+OBJS = sc_net_test.o sc_net_tok.o
+
+CFLAGS += -I.
+CFLAGS += -I./inc
+CFLAGS += -I$(APP_DIR)/include
+
+
+CFLAGS += -g
+CFLAGS += -g -Werror=implicit-function-declaration
+
+LDLIBS += -lpthread
+LDLIBS += -lsctel -L$(LIB_DIR)/libsctel
+LDLIBS += -lscipc -L$(LIB_DIR)/libscipc
+LDLIBS += -latutils -L$(LIB_DIR)/libatutils
+LDLIBS += -lsoftap -L$(LIB_DIR)/libsoftap
+LDLIBS += -lsofttimer -L$(LIB_DIR)/libsofttimer
+LDLIBS += -lnvram -L$(LIB_DIR)/libnvram
+#LDLIBS += -ltelsvr -L$(zte_lib_path)/libtelecom/lib/libtelsvr.a
+#LDLIBS += -ltelsvr -L$(zte_lib_path)/libtelsvr/lib/libtelsvr.a
+
+all: $(EXEC)
+$(EXEC)all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) -e /sbin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
+
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS$(LDLIBS_$@))
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_test.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_test.c
new file mode 100755
index 0000000..e68ae00
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_test.c
@@ -0,0 +1,338 @@
+#include <ctype.h>
+#include <errno.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <limits.h>
+#include <netdb.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <syslog.h>
+#include <pthread.h>
+#include <stdarg.h>
+
+#include "sc_net_tok.h"
+#include "sc_mnet.h"
+#include "sc_tel_types.h"
+
+#define NET_CMD_MAX_LEN 64
+#define EXIT_CMD_STOP "stop\n"
+#define EXIT_CMD_Q "qq\n"
+#define EXIT_CMD_EXIT "exit\n"
+
+
+#define NET_REQ_SCAN 's' //at+cops=?
+#define NET_REQ_OPER 'o' //at+cops?
+#define NET_REQ_SYSCONFIG 'c' //at^sysconfig=20
+#define NET_REQ_REG 'r' //at+cops=1,2,"46000"
+#define NET_REQ_DEREG 'd' //at+cops=2
+#define NET_REQ_SYSINFO 'i' //at^sysinfo
+#define NET_REQ_CSQ 'q' //at+csq
+#define NET_REQ_MODE 'm' //at^mode=1
+#define NET_REQ_CELL 'e' //at+zemsci=1
+
+
+void scan_async_cb(int async_index, sc_net_operator_list_t *p_info)
+{
+ printf("scan_async_cb enter\n");
+ for(int i=0; i<p_info->len; i++){
+ printf("list %ld operator info %ld %s %s %s %ld\n",i,
+ p_info->operators[i].state,
+ p_info->operators[i].loper_a,
+ p_info->operators[i].soper_a,
+ p_info->operators[i].noper_a,
+ p_info->operators[i].act);
+ }
+
+}
+static void netdemo_log(const char *fmt, ...)
+{
+ va_list arg = {0};
+ char log_buf[1024]= {0};
+
+ if(NULL == fmt)
+ {
+ return ;
+ }
+ va_start(arg,fmt);
+ vsnprintf(log_buf, 1023, fmt, arg);
+ va_end(arg);
+
+ printf("[netdemo] %s\n",log_buf);
+ return;
+}
+
+static void printUsage(const char *Opt)
+{
+ printf("Usage: %s\n", Opt);
+ printf("s at+cops=?\n");
+ printf("o at+cops?\n");
+ printf("c:num at^sysconfig=<mode>\n");
+ printf("r at+cops=[<mode>[,<format>[,<oper>\n");
+ printf("d at+cfun=0\n");
+ printf("i at^sysinfo\n");
+ printf("q at+csq\n");
+ printf("m:mode at^mode=0/1\n");
+ printf("e at+zemsciq=1\n");
+ printf("\n");
+}
+
+static int parseOpts(int argc, char *argv[])
+{
+ int rc = 0;
+ int c;
+ while ((c = getopt(argc, argv, "?n:a:")) != -1) {
+ switch (c) {
+ case 'a':
+ break;
+ case 'n':
+ break;
+ case '?':
+ default:
+ printUsage(argv[0]);
+ return -1;
+ }
+ }
+
+ return rc;
+}
+
+static int net_cops_set(int sID, char *data, int data_len)
+{
+ int ret;
+ sc_net_cops_ser_t req = {0};
+
+ if (at_tok_start(&data) < 0) {
+ netdemo_log("cops_set:at_tok_start error\n");
+ return -1;
+ }
+ if(at_tok_nextint(&data, &req.mode) < 0) {
+ netdemo_log("cops_set:get mode error\n");
+ return -1;
+ }
+ if(at_tok_nextint(&data, &req.format) < 0) {
+ netdemo_log("cops_set:get formate error\n");
+ return -1;
+ }
+ sprintf(req.oper, "%s", data);
+ /*
+ if(at_tok_nextstr(&data, &req.oper) < 0) {
+ netdemo_log("cops_set:get oper error\n");
+ return -1;
+ }
+ */
+ printf("cops req infor mode %d formate %d oper %s\n", req.mode, req.format, req.oper);
+
+ ret = sc_net_register(sID,&req);
+ netdemo_log("cops_set return result:%d",ret);
+ return ret;
+}
+
+static int net_sysconfig_set(int sID, char *data, int data_len)
+{
+ int ret;
+ sc_net_sysconfig_t req = {0};
+
+ if (at_tok_start(&data) < 0) {
+ netdemo_log("net_sysconfig_set:at_tok_start error\n");
+ return -1;
+ }
+ if(at_tok_nextint(&data, &req.imode) < 0) {
+ netdemo_log("net_sysconfig_set:get imode error\n");
+ return -1;
+ }
+ /*
+ if(at_tok_nextint(&data, &req.acqorder) < 0) {
+ netdemo_log("net_sysconfig_set:get acqorder error\n");
+ return -1;
+ }
+ if(at_tok_nextstr(&data, req.roam) < 0) {
+ netdemo_log("net_sysconfig_set:get roam error\n");
+ return -1;
+ }
+ if(at_tok_nextstr(&data, req.svrdomain) < 0) {
+ netdemo_log("net_sysconfig_set:get svrdomain error\n");
+ return -1;
+ }
+ */
+ printf("sysconfig req infor mode %d acqorder %d roam %d domain %d", req.imode, req.acqorder, req.roam, req.svrdomain);
+
+ ret = sc_net_select_mode(sID,req.imode);
+ netdemo_log("sysconfig set result:%d",ret);
+ return ret;
+}
+
+static int net_mode_set(int sID, char *data, int data_len)
+{
+ int ret;
+ int mode = -1;
+
+ if (at_tok_start(&data) < 0) {
+ netdemo_log("net_mode_set:at_tok_start error\n");
+ return -1;
+ }
+ if(at_tok_nextint(&data, &mode) < 0) {
+ netdemo_log("net_mode_set:get mode error\n");
+ return -1;
+ }
+
+ ret = sc_net_set_mode(0,mode);
+ netdemo_log("net_mode_set return result:%d",ret);
+ return ret;
+}
+
+static void net_scan(void)
+{
+ sc_net_scan(0, (void*)&scan_async_cb);
+}
+
+static void net_get_oper(void)
+{
+ sc_net_cur_operator_t oper={0};
+ sc_net_get_operator_info(1, &oper);
+ printf("oper info %d %s %d %d\n", oper.mode, oper.oper, oper.format, oper.uAcT);
+}
+
+static void net_sysconfig(void)
+{
+ sc_net_sysinfo_t sysinfo = {0};
+ sc_net_register_state(1, &sysinfo);
+}
+
+static void net_reg(void)
+{
+ sc_net_cops_ser_t req = {0};
+ sc_net_register(1, &req);
+}
+
+static void net_dereg(void)
+{
+ sc_net_deregister(1);
+}
+
+static void net_get_sysinfo(void)
+{
+ sc_net_sysinfo_t sysinfo={0};
+ sc_net_register_state(0, &sysinfo);
+}
+
+static void net_get_csq(void)
+{
+ int csq=-1;
+ sc_net_get_signal_strength(0, &csq);
+ printf("net_get_csq :%d\n",csq);
+}
+
+static void net_set_mode(void)
+{
+ int csq=-1;
+ sc_net_set_mode(0, 1);
+ printf("net_set_mode \n");
+}
+
+static void net_get_cell_info()
+{
+ int ret = sc_net_get_cell_info(1);
+ printf("net_get_cell_info ret %d", ret);
+}
+
+static void net_cmd_proc(char *cmdstr)
+{
+ char *data = cmdstr;
+ int data_len = strlen(data) - 1;/* -strlen("\r")*/
+ char request = data[0];
+
+ cmdstr[data_len] = '\0';
+ switch(request) {
+ case NET_REQ_SCAN:
+ netdemo_log("Request scan.\n");
+ net_scan();
+ break;
+ case NET_REQ_OPER:
+ netdemo_log("Request oper.\n");
+ net_get_oper();
+ break;
+ case NET_REQ_SYSCONFIG:
+ netdemo_log("Request set sysconfig.\n");
+ net_sysconfig_set(0, data, data_len);
+ break;
+ case NET_REQ_REG:
+ netdemo_log("Request set cops.\n");
+ net_cops_set(0, data, data_len);
+ break;
+ case NET_REQ_DEREG:
+ netdemo_log("Request deregister.\n");
+ net_dereg();
+ break;
+ case NET_REQ_SYSINFO:
+ netdemo_log("Request get sysinfo.\n");
+ net_get_sysinfo();
+ break;
+ case NET_REQ_CSQ:
+ netdemo_log("Request get CSQ.\n");
+ net_get_csq();
+ break;
+ case NET_REQ_MODE:
+ netdemo_log("Request set mode.\n");
+ net_mode_set(0, data, data_len);
+ break;
+ case NET_REQ_CELL:
+ netdemo_log("Request get cell info.\n");
+ net_get_cell_info();
+ break;
+ default:
+ netdemo_log("Request unknow.\n");
+ printUsage(cmdstr);
+ break;
+ }
+}
+int main(int argc, char *argv[])
+{
+ char cmdstr[NET_CMD_MAX_LEN];
+
+ netdemo_log("net_demo:Demo go.\n");
+ /*
+ if(parseOpts(argc,argv) == -1) {
+ netdemo_log("net_demo:Arg error.\n");
+ return -1;
+ }
+ */
+
+ if(sc_mnet_init(1)) {
+ netdemo_log("net_demo:net_init fail!\n");
+ return 0;
+ }
+
+ while(1) {
+ memset(cmdstr,0,NET_CMD_MAX_LEN);
+
+ netdemo_log("Please input an net command:\n");
+
+ if(NULL != fgets(cmdstr,NET_CMD_MAX_LEN - 1,stdin)) {
+ if(0 == strcmp(EXIT_CMD_STOP,cmdstr) ||
+ 0 == strcmp(EXIT_CMD_Q,cmdstr) ||
+ 0 == strcmp(EXIT_CMD_EXIT,cmdstr)) {
+ break;
+ }
+
+ netdemo_log("cmdstr:%d %s\n",strlen(cmdstr),cmdstr);
+ if(1 >= strlen(cmdstr)) {
+ continue;
+ }
+
+ /*request format:
+ *Q:1,2,10086
+ */
+ net_cmd_proc(cmdstr);
+ }
+ }
+
+ sc_mnet_uninit(1);
+
+ netdemo_log("net_demo:Demo end.\n");
+ return 0;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_tok.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_tok.c
new file mode 100755
index 0000000..dcc08b9
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_tok.c
@@ -0,0 +1,190 @@
+/*
+**
+** Copyright 2006, 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.
+*/
+
+#include "sc_net_tok.h"
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+/**
+ * Starts tokenizing an AT response string
+ * returns -1 if this is not a valid response string, 0 on success.
+ * updates *p_cur with current position
+ */
+int at_tok_start(char **p_cur)
+{
+ if (*p_cur == NULL) {
+ return -1;
+ }
+
+ // skip prefix
+ // consume "^[^:]:"
+
+ *p_cur = strchr(*p_cur, ':');
+
+ if (*p_cur == NULL) {
+ return -1;
+ }
+
+ (*p_cur)++;
+
+ return 0;
+}
+
+static void skipWhiteSpace(char **p_cur)
+{
+ if (*p_cur == NULL) return;
+
+ while (**p_cur != '\0' && isspace(**p_cur)) {
+ (*p_cur)++;
+ }
+}
+
+static void skipNextComma(char **p_cur)
+{
+ if (*p_cur == NULL) return;
+
+ while (**p_cur != '\0' && **p_cur != ',') {
+ (*p_cur)++;
+ }
+
+ if (**p_cur == ',') {
+ (*p_cur)++;
+ }
+}
+
+static char * nextTok(char **p_cur)
+{
+ char *ret = NULL;
+
+ skipWhiteSpace(p_cur);
+
+ if (*p_cur == NULL) {
+ ret = NULL;
+ } else if (**p_cur == '"') {
+ (*p_cur)++;
+ ret = strsep(p_cur, "\"");
+ skipNextComma(p_cur);
+ } else {
+ ret = strsep(p_cur, ",");
+ }
+
+ return ret;
+}
+
+
+/**
+ * Parses the next integer in the AT response line and places it in *p_out
+ * returns 0 on success and -1 on fail
+ * updates *p_cur
+ * "base" is the same as the base param in strtol
+ */
+
+static int at_tok_nextint_base(char **p_cur, int *p_out, int base, int uns)
+{
+ char *ret;
+
+ if (*p_cur == NULL) {
+ return -1;
+ }
+
+ ret = nextTok(p_cur);
+
+ if (ret == NULL) {
+ return -1;
+ } else {
+ long l;
+ char *end;
+
+ if (uns)
+ l = strtoul(ret, &end, base);
+ else
+ l = strtol(ret, &end, base);
+
+ *p_out = (int)l;
+
+ if (end == ret) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Parses the next base 10 integer in the AT response line
+ * and places it in *p_out
+ * returns 0 on success and -1 on fail
+ * updates *p_cur
+ */
+int at_tok_nextint(char **p_cur, int *p_out)
+{
+ return at_tok_nextint_base(p_cur, p_out, 10, 0);
+}
+
+/**
+ * Parses the next base 16 integer in the AT response line
+ * and places it in *p_out
+ * returns 0 on success and -1 on fail
+ * updates *p_cur
+ */
+int at_tok_nexthexint(char **p_cur, int *p_out)
+{
+ return at_tok_nextint_base(p_cur, p_out, 16, 1);
+}
+
+int at_tok_nextbool(char **p_cur, char *p_out)
+{
+ int ret;
+ int result;
+
+ ret = at_tok_nextint(p_cur, &result);
+
+ if (ret < 0) {
+ return -1;
+ }
+
+ // booleans should be 0 or 1
+ if (!(result == 0 || result == 1)) {
+ return -1;
+ }
+
+ if (p_out != NULL) {
+ *p_out = (char)result;
+ }
+
+ return ret;
+}
+
+int at_tok_nextstr(char **p_cur, char **p_out)
+{
+ if (*p_cur == NULL) {
+ return -1;
+ }
+
+ *p_out = nextTok(p_cur);
+
+ return 0;
+}
+
+/** returns 1 on "has more tokens" and 0 if no */
+int at_tok_hasmore(char **p_cur)
+{
+ return ! (*p_cur == NULL || **p_cur == '\0');
+}
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_tok.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_tok.h
new file mode 100755
index 0000000..4da7ca8
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_net_test/sc_net_tok.h
@@ -0,0 +1,30 @@
+/*
+**
+** Copyright 2006, 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.
+*/
+
+#ifndef SC_NET_TOK_H
+#define SC_NET_TOK_H 1
+
+int at_tok_start(char **p_cur);
+int at_tok_nextint(char **p_cur, int *p_out);
+int at_tok_nexthexint(char **p_cur, int *p_out);
+
+int at_tok_nextbool(char **p_cur, char *p_out);
+int at_tok_nextstr(char **p_cur, char **out);
+
+int at_tok_hasmore(char **p_cur);
+
+#endif /*SC_NET_TOK_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_softtimer_test/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_softtimer_test/Makefile
new file mode 100755
index 0000000..379d5d6
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_softtimer_test/Makefile
@@ -0,0 +1,33 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = sc_softtimer_test
+OBJS = sc_softtimer_test.o
+
+CFLAGS += -g -Werror=implicit-function-declaration
+
+LDLIBS = -lpthread
+# LDLIBS += -lnvram
+# LDLIBS += -lbsp
+LDLIBS += -lsoft_timer
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) $(EXEC)_recovery *.elf *.gdb *.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_softtimer_test/sc_softtimer_test.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_softtimer_test/sc_softtimer_test.c
new file mode 100755
index 0000000..963e16b
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sc_softtimer_test/sc_softtimer_test.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <linux/netlink.h>
+#include <poll.h>
+#include <linux/serial.h>
+#include <termios.h>
+#include <pthread.h>
+
+#include "soft_timer.h"
+
+static int sc_softtimer_test_callback(void *arg)
+{
+ printf("%s\n", (char *)arg);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned short timer_id = 101;
+ unsigned char flag = TIMER_FLAG_RESTART;
+ unsigned long interval = 3000;
+ char message[50] = "callback";
+ int i;
+ int ret;
+
+ if (5 == argc)
+ {
+ timer_id = atoi(argv[1]);
+ flag = atoi(argv[2]);
+ interval = atoi(argv[3]);
+ strcpy(message, argv[4]);
+ message[49] = '\0';
+ }
+ ret = sc_timer_create(timer_id + 1, flag, interval, sc_softtimer_test_callback, (void *)message);
+ if(0 != ret)
+ {
+ printf("sc_timer_create fail, ret: %d", ret);
+ exit(-1);
+ }
+ ret = sc_timer_delete(timer_id + 1);
+ if(0 != ret)
+ {
+ printf("sc_timer_delete fail, ret: %d", ret);
+ exit(-2);
+ }
+ ret = sc_timer_create(timer_id, flag, interval, sc_softtimer_test_callback, (void *)message);
+ if(0 != ret)
+ {
+ printf("sc_timer_create fail, ret: %d", ret);
+ exit(-3);
+ }
+ for (i = 0; i < 10; i++)
+ {
+ printf("----------\ntime: %d s\n", i);
+ sleep(1);
+ }
+ printf("----------\ntime: 10 s\n");
+ return 0;
+}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sim_demo/sc_sim_main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sim_demo/sc_sim_main.c
index b2dc8a2..ac7f44c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sim_demo/sc_sim_main.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sim_demo/sc_sim_main.c
@@ -101,7 +101,7 @@
int iRet = -1;
printf("sim_get_imsi test \n");
char imsi[sim_param_len] = {0};
- iRet = sc_sim_get_imsi(sID, 0, imsi, sizeof(imsi));
+ iRet = sc_sim_get_imsi(sID, imsi, sizeof(imsi));
printf("iRet=%d, imsi = %s \n", iRet, imsi);
return 0;
}
@@ -122,7 +122,7 @@
int iRet = -1;
printf("sim_get_phonenum test \n");
char phonenum[sim_param_len] = {0};
- iRet = sc_sim_get_phone_num(sID, 0, phonenum, sizeof(phonenum));
+ iRet = sc_sim_get_phone_num(sID, phonenum, sizeof(phonenum));
printf("iRet=%d, phonenum = %s \n", iRet, phonenum);
return 0;
}
@@ -171,7 +171,7 @@
printf("pin_type=%d, pin_value=%s \n", pin_type, pin_value);
- iRet = sc_sim_enable_pin(sID, 0, pin_type, pin_value);
+ iRet = sc_sim_enable_pin(sID, pin_type, pin_value);
printf("iRet=%d\n", iRet);
sim_print_result("sim_pin_enable",iRet);
@@ -196,7 +196,7 @@
printf("sim_pin_disable:at_tok_nextstr error\n");
}
printf("pin_type=%d, pin_value=%s \n", pin_type, pin_value);
- iRet = sc_sim_disable_pin(sID, 0, pin_type, pin_value);
+ iRet = sc_sim_disable_pin(sID, pin_type, pin_value);
printf("iRet=%d\n", iRet);
sim_print_result("sim_pin_disable",iRet);
@@ -221,7 +221,7 @@
printf("sim_pin_verify:at_tok_nextstr error\n");
}
printf("pin_type=%d, pin_value=%s \n", pin_type, pin_value);
- iRet = sc_sim_verify_pin(sID, 0, pin_type, pin_value);
+ iRet = sc_sim_verify_pin(sID, pin_type, pin_value);
printf("iRet=%d\n", iRet);
sim_print_result("sim_pin_verify",iRet);
@@ -251,7 +251,7 @@
printf("sim_change_pin:at_tok_nextstr error\n");
}
printf("pin_type=%d, oldpin_value=%s, newpin_value=%s\n", pin_type, oldpin_value, newpin_value);
- iRet = sc_sim_change_pin(sID, 0, pin_type, oldpin_value, newpin_value);
+ iRet = sc_sim_change_pin(sID, pin_type, oldpin_value, newpin_value);
printf("iRet=%d\n", iRet);
sim_print_result("sim_change_pin",iRet);
@@ -281,7 +281,7 @@
printf("sim_unblock_pin:at_tok_nextstr error\n");
}
printf("pin_type=%d, puk_value=%s, newpin_value=%s\n", pin_type, puk_value, pin_value);
- iRet = sc_sim_unblock_pin(sID, 0, pin_type, puk_value, pin_value);
+ iRet = sc_sim_unblock_pin(sID, pin_type, puk_value, pin_value);
printf("iRet=%d\n", iRet);
sim_print_result("sim_unblock_pin",iRet);
@@ -334,11 +334,13 @@
{
case 0xB00:
return "UNKNOWN";
- case 0xB02:
+ case 0xB01:
return "PIN1_REQ";
- case 0xB03:
+ case 0xB02:
return "PUK1_REQ";
- case 0xB0A:
+ case 0xB03:
+ return "PERM_BLOCKED";
+ case 0xB04:
return "READY";
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/Makefile
new file mode 100755
index 0000000..7a83c29
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/Makefile
@@ -0,0 +1,33 @@
+include $(COMMON_MK)
+
+EXEC = sms_demo
+OBJS = sc_sms_main.o sc_sms_tok.o
+
+CFLAGS += -I.
+CFLAGS += -I./inc
+CFLAGS += -I$(APP_DIR)/include
+
+
+CFLAGS += -g
+CFLAGS += -g -Werror=implicit-function-declaration
+
+LDLIBS += -lpthread
+LDLIBS += -lsctel -L$(LIB_DIR)/libsctel
+LDLIBS += -lscipc -L$(LIB_DIR)/libscipc
+
+all: $(EXEC)
+$(EXEC)all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) -e /sbin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
+
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS$(LDLIBS_$@))
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_main.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_main.c
new file mode 100755
index 0000000..e5aa673
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_main.c
@@ -0,0 +1,574 @@
+#include <ctype.h>
+#include <errno.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <limits.h>
+#include <netdb.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <syslog.h>
+#include <pthread.h>
+
+#include "sc_sms_tok.h"
+#include "sc_sms.h"
+
+/*deault sim id*/
+#define SMS_ID_DEFULT 0
+/*command max len 64*/
+#define SMS_CMD_MAX_LEN 512
+
+#define EXIT_CMD_STOP "stop\n"
+#define EXIT_CMD_Q "q\n"
+#define EXIT_CMD_EXIT "exit\n"
+
+#define SMS_SET_SC "set_sc"
+#define SMS_GET_SC "get_sc"
+#define SMS_SEND_TEXT "send_text"
+#define SMS_SEND_TEXT_ASYN "send_text_asyn"
+#define SMS_SEND_PDU "send_pdu"
+#define SMS_SEND_PDU_ASYN "send_pdu_asyn"
+
+#define sms_param_len 50
+
+typedef unsigned short UINT16;
+typedef unsigned long int UINT32;
+
+static void sms_print_result(char* opname, int result);
+static char* sms_convert_cardinfo_state(int type, int value);
+
+static void printUsage(const char *Opt)
+{
+ printf("Usage: %s\n", Opt);
+ printf("set_sc:center_num set sms center number(eg. set_sc:13812345678)\n");
+ printf("get_sc get sms center number\n");
+ printf("send_text:format,tonum,content send text sms message(eg. send_text:0,13812345678,\"text test\")\n");
+ printf("send_text_asyn:format,tonum,content send text sms message asyn(eg. send_text:0,13812345678,\"text test\")\n");
+ printf("send_pdu:format,pducontent send pdu sms message(eg. send_pdu:0,0031000D91683170521337F70000000870721D442FCFE9)\n");
+ printf("send_pud_asyn:format,pducontent send pdu sms message asyn(eg. send_pud_asyn:0,0031000D91683170521337F70000000870721D442FCFE9)\n");
+ printf("\n");
+}
+
+static int parseOpts(int argc, char *argv[])
+{
+ int rc = 0;
+ int c;
+ while ((c = getopt(argc, argv, "?n:a:")) != -1) {
+ switch (c) {
+ case 'a':
+ break;
+ case 'n':
+ break;
+ case '?':
+ default:
+ printUsage(argv[0]);
+ return -1;
+ }
+ }
+
+ return rc;
+}
+
+static int String2Bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
+{
+ int i=0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i=0; i<nSrcLength; i+=2)
+ {
+ // Êä³ö¸ß4λ
+ if(*pSrc>='0' && *pSrc<='9')
+ {
+ *pDst = (*pSrc - '0') << 4;
+ }
+ else
+ {
+ *pDst = (*pSrc - 'A' + 10) << 4;
+ }
+
+ pSrc++;
+
+ // Êä³öµÍ4λ
+ if(*pSrc>='0' && *pSrc<='9')
+ {
+ *pDst |= *pSrc - '0';
+ }
+ else
+ {
+ *pDst |= *pSrc - 'A' + 10;
+ }
+
+ pSrc++;
+ pDst++;
+ }
+
+ // ·µ»ØÄ¿±êÊý¾Ý³¤¶È
+ return nSrcLength / 2;
+}
+
+static int Bytes2String(const unsigned char* pSrc, char* pDst, int nSrcLength)
+{
+ const char tab[]="0123456789ABCDEF"; // 0x0-0xfµÄ×Ö·û²éÕÒ±í
+ int i = 0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i=0; i<nSrcLength; i++)
+ {
+ *pDst++ = tab[*pSrc >> 4]; // Êä³öµÍ4λ
+ *pDst++ = tab[*pSrc & 0x0f]; // Êä³ö¸ß4λ
+ pSrc++;
+ }
+
+ // Êä³ö×Ö·û´®¼Ó¸ö½áÊø·û
+ *pDst = '\0';
+
+ // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+ return nSrcLength * 2;
+}
+
+int Ucs2ToUtf8(const UINT16 *pwBufIn, UINT32 uiLenIn, char *pszBufOut, UINT32 uiLenOut)
+{
+ const UINT16 *pwBufEnd = pwBufIn + uiLenIn;
+ char *pszBufEnd, *pszBufEnd2, *pszBufEnd3;
+
+ if(pwBufIn != NULL && (int)uiLenIn > 0 && pszBufOut != NULL && (int)uiLenOut > 0)
+ {
+ pszBufEnd = pszBufOut + uiLenOut;
+ pszBufEnd2 = pszBufEnd - 1;
+ pszBufEnd3 = pszBufEnd2- 1;
+ uiLenOut = 0;
+
+ while(pwBufIn < pwBufEnd)
+ {
+ if(pszBufOut < pszBufEnd && *pwBufIn >= 0 && *pwBufIn < 0x0080)
+ {
+ // U-00000000 - U-0000007F: 0xxxxxxx
+ *pszBufOut++ = (char)*pwBufIn & 0x7f;
+ ++uiLenOut;
+ }
+ else if(pszBufOut < pszBufEnd2 && (UINT16)*pwBufIn >= 0x0080 && (UINT16)*pwBufIn < 0x0800)
+ {
+ // U-00000080 - U-000007FF: 110xxxxx 10xxxxxx
+ *pszBufOut++ = (char)((*pwBufIn >> 6) & 0x001f) | 0xc0;
+ *pszBufOut++ = (char)(*pwBufIn & 0x003f) | 0x80;
+ uiLenOut += 2;
+ }
+ else if(pszBufOut < pszBufEnd3)
+ {
+ // U-00000800 - U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
+ *pszBufOut++ = (char)((*pwBufIn >> 12) & 0x000f) | 0xe0;
+ *pszBufOut++ = (char)((*pwBufIn >> 6) & 0x003f) | 0x80;
+ *pszBufOut++ = (char)(*pwBufIn & 0x003f) | 0x80;
+ uiLenOut += 3;
+ }
+ else
+ {
+ break;
+ }
+
+ ++pwBufIn;
+ }
+
+ return (int)uiLenOut;
+ }
+
+ return -1;
+}
+
+void sc_sms_pdu_recv_cb(sc_sms_pdu_t *p_pdu)
+{
+ char strPdu[176*2+1] = {0};
+ printf("sc_sms_pdu_recv_cb \n");
+ printf("format=%d \n", p_pdu->format);
+ printf("content_size=%d \n", p_pdu->content_size);
+ Bytes2String(p_pdu->content, strPdu, p_pdu->content_size);
+ printf("pdu content=%s \n", strPdu);
+}
+
+void sc_sms_msg_recv_cb(sc_sms_msg_t *p_msg, sc_sms_timestamp_t *timestamp, sc_sms_user_data_head_t *head)
+{
+ char smsText[256] = {0};
+ printf("sc_sms_msg_recv_cb \n");
+ printf("content_size=%d \n", p_msg->content_size);
+ Bytes2String(p_msg->content, smsText, p_msg->content_size);
+ printf("content string=%s \n", smsText);
+}
+
+static int sms_init(int sID)
+{
+ int ret = 0;
+
+ ret = sc_sms_init(sID);
+ if(0 != ret) {
+ return -1;
+ }
+ sc_sms_set_pdu_msg_recv_cb(sc_sms_pdu_recv_cb);
+ sc_sms_set_text_msg_recv_cb(sc_sms_msg_recv_cb);
+ return ret;
+}
+
+static int sms_deinit(int sID)
+{
+ return sc_sms_uninit(sID);
+}
+
+static int sms_set_sc(char *data, int data_len)
+{
+ int iRet = -1;
+ printf("sms_set_sc test \n");
+ char *psms_addr = NULL;
+ if (at_tok_start(&data) < 0) {
+ printf("sms_set_sc:at_tok_start error\n");
+ }
+
+ if(at_tok_nextstr(&data, &psms_addr) < 0) {
+ printf("sms_set_sc:at_tok_nextstr error\n");
+ }
+
+ iRet = sc_sms_set_service_center_addr(0, psms_addr, strlen(psms_addr));
+ sms_print_result("sms_set_sc", iRet);
+
+ return 0;
+}
+
+static int sms_get_sc(char *data, int data_len)
+{
+ int iRet = -1;
+ char sms_addr[sms_param_len] = {0};
+ printf("sms_get_sc test \n");
+
+ iRet = sc_sms_get_service_center_addr(0, sms_addr, sms_param_len);
+ printf("iRet=%d, sms_addr = %s \n", iRet, sms_addr);
+ sms_print_result("sms_get_sc", iRet);
+ return 0;
+}
+
+static int sms_send_text(char *data, int data_len)
+{
+ int iRet = -1;
+ sc_sms_msg_t sms_msg = {0};
+ int psms_format = NULL;
+ char* psms_addr = NULL;
+ char* psms_content = NULL;
+
+ if (at_tok_start(&data) < 0) {
+ printf("sms_send_text:at_tok_start error\n");
+ }
+
+ if(at_tok_nextint(&data, &psms_format) < 0) {
+ printf("sms_send_text:at_tok_nextint error\n");
+ }
+
+ if(at_tok_nextstr(&data, &psms_addr) < 0) {
+ printf("sms_send_text:at_tok_nextstr error\n");
+ }
+
+ if(at_tok_nextstr(&data, &psms_content) < 0) {
+ printf("sms_send_text:at_tok_nextstr error\n");
+ }
+
+ sms_msg.format = psms_format;
+ strncpy(sms_msg.addr, psms_addr, SC_SMS_MAX_ADDR_LENGTH);
+ strncpy(sms_msg.content, psms_content, SC_SMS_MAX_SEND_MSG_LENGTH-1);
+ sms_msg.content_size = strlen(sms_msg.content);
+ iRet = sc_sms_send_text_msg(0, &sms_msg);
+#if 0
+ sms_msg.format = SC_SMS_MSG_FORMAT_GSM_7BIT;
+ strncpy(sms_msg.addr, "15850627580", SC_SMS_MAX_ADDR_LENGTH);
+ strncpy(sms_msg.content, "test123456", SC_SMS_MAX_SEND_MSG_LENGTH-1);
+ sms_msg.content_size = strlen(sms_msg.content);
+ sc_sms_send_msg(&sms_msg);
+
+ memset(&sms_msg, 0, sizeof(sc_sms_msg_t));
+
+ sms_msg.format = SC_SMS_MSG_FORMAT_UCS2;
+ strncpy(sms_msg.addr, "15850627580", SC_SMS_MAX_ADDR_LENGTH);
+ strncpy(sms_msg.content, "²âÊÔ²âÊÔ12421534543", SC_SMS_MAX_SEND_MSG_LENGTH-1);
+ sms_msg.content_size = strlen(sms_msg.content);
+ sc_sms_send_msg(&sms_msg);
+#endif
+
+ sms_print_result("sms_send_text", iRet);
+ return 0;
+}
+
+void sms_msg_async_cb_f(int id, int result)
+{
+ printf("sc_sms_msg_async_cb_f id=%d, result=%d \n", id, result);
+ sms_print_result("sms_msg_async_cb_f", result);
+}
+
+static int sms_send_text_asyn(char *data, int data_len)
+{
+ int iRet = -1;
+ sc_sms_msg_t sms_msg = {0};
+ int psms_format = NULL;
+ char* psms_addr = NULL;
+ char* psms_content = NULL;
+ int id;
+ if (at_tok_start(&data) < 0) {
+ printf("sms_send_text_asyn:at_tok_start error\n");
+ }
+
+ if(at_tok_nextint(&data, &psms_format) < 0) {
+ printf("sms_send_text_asyn:at_tok_nextint error\n");
+ }
+
+ if(at_tok_nextstr(&data, &psms_addr) < 0) {
+ printf("sms_send_text_asyn:at_tok_nextstr error\n");
+ }
+
+ if(at_tok_nextstr(&data, &psms_content) < 0) {
+ printf("sms_send_text_asyn:at_tok_nextstr error\n");
+ }
+
+ sms_msg.format = psms_format;
+ strncpy(sms_msg.addr, psms_addr, SC_SMS_MAX_ADDR_LENGTH);
+ strncpy(sms_msg.content, psms_content, SC_SMS_MAX_SEND_MSG_LENGTH-1);
+ sms_msg.content_size = strlen(sms_msg.content);
+ iRet = sc_sms_send_text_msg_async(0, &sms_msg, &id, sms_msg_async_cb_f);
+ printf("sms_send_text_asyn iRet=%d, id=%d \n", iRet, id);
+#if 0
+ sms_msg.format = SC_SMS_MSG_FORMAT_GSM_7BIT;
+ strncpy(sms_msg.addr, "15850627580", SC_SMS_MAX_ADDR_LENGTH);
+ strncpy(sms_msg.content, "test123456", SC_SMS_MAX_SEND_MSG_LENGTH-1);
+ sms_msg.content_size = strlen(sms_msg.content);
+ sc_sms_send_msg(&sms_msg);
+
+ memset(&sms_msg, 0, sizeof(sc_sms_msg_t));
+
+ sms_msg.format = SC_SMS_MSG_FORMAT_UCS2;
+ strncpy(sms_msg.addr, "15850627580", SC_SMS_MAX_ADDR_LENGTH);
+ strncpy(sms_msg.content, "²âÊÔ²âÊÔ12421534543", SC_SMS_MAX_SEND_MSG_LENGTH-1);
+ sms_msg.content_size = strlen(sms_msg.content);
+ sc_sms_send_msg(&sms_msg);
+ printf("sms_send_text_asyn test \n");
+ printf("iRet=%d \n", iRet);
+#endif
+
+ return 0;
+}
+
+static int sms_send_pdu(char *data, int data_len)
+{
+ int iRet = -1;
+ sc_sms_pdu_t sms_msg = {0};
+ int psms_format = NULL;
+ char* psms_content = NULL;
+ int pduLen = 0;
+ printf("sms_send_pdu \n");
+ if (at_tok_start(&data) < 0) {
+ printf("sms_send_pdu:at_tok_start error\n");
+ }
+
+ if(at_tok_nextint(&data, &psms_format) < 0) {
+ printf("sms_send_pdu:at_tok_nextint error\n");
+ }
+
+ if(at_tok_nextstr(&data, &psms_content) < 0) {
+ printf("sms_send_pdu:at_tok_nextstr error\n");
+ }
+
+ printf("rawlen=%d, psms_content=%s \n", strlen(psms_content), psms_content);
+
+ sms_msg.format = psms_format;
+ pduLen = String2Bytes(psms_content, sms_msg.content, strlen(psms_content));
+ //strncpy(sms_msg.content, psms_content, SC_SMS_MAX_SEND_MSG_LENGTH-1);
+ sms_msg.content_size = pduLen;
+
+ printf("pduLen=%d\n", pduLen);
+
+ iRet = sc_sms_send_pdu_msg(0, &sms_msg);
+ printf("sc_sms_send_pdu_msg iRet=%d \n", iRet);
+ sms_print_result("sc_sms_send_pdu_msg", iRet);
+ return 0;
+}
+
+static int sms_send_pdu_sync(char *data, int data_len)
+{
+ int iRet = -1;
+ sc_sms_pdu_t sms_msg = {0};
+ int psms_format = NULL;
+ char* psms_content = NULL;
+ int pduLen = 0;
+ int id;
+ if (at_tok_start(&data) < 0) {
+ printf("sms_send_pdu_sync:at_tok_start error\n");
+ }
+
+ if(at_tok_nextint(&data, &psms_format) < 0) {
+ printf("sms_send_pdu_sync:at_tok_nextint error\n");
+ }
+
+ if(at_tok_nextstr(&data, &psms_content) < 0) {
+ printf("sms_send_pdu_sync:at_tok_nextstr error\n");
+ }
+
+ sms_msg.format = psms_format;
+ pduLen = String2Bytes(psms_content, sms_msg.content, strlen(psms_content));
+ //strncpy(sms_msg.content, psms_content, SC_SMS_MAX_SEND_MSG_LENGTH-1);
+ sms_msg.content_size = pduLen;
+
+ printf("pduLen=%d\n", pduLen);
+ iRet = sc_sms_send_pdu_msg_async(0, &sms_msg, &id, sms_msg_async_cb_f);
+ printf("sms_send_pdu_sync iRet=%d \n", iRet);
+ sms_print_result("sms_send_pdu_sync", iRet);
+ return 0;
+}
+
+static void sms_print_result(char* opname, int result)
+{
+ if(0 == result)
+ {
+ printf("%s: success! \n", opname);
+ }
+ else
+ {
+ printf("%s: failed! \n", opname);
+ printf("The fail reason is: \n");
+ switch(result)
+ {
+ case 1:
+ printf("Unknown error! \n");
+ break;
+ case 2:
+ printf("The operation not allow! \n");
+ break;
+ case 3:
+ printf("The operation not support!\n");
+ break;
+ case 4:
+ printf("No sim card! \n");
+ break;
+ case 5:
+ printf("Require enter pin! \n");
+ break;
+ case 6:
+ printf("Require enter puk! \n");
+ break;
+ case 7:
+ printf("Sim card init fail! \n");
+ break;
+ case 8:
+ printf("Sim card busy! \n");
+ break;
+ case 9:
+ printf("Sim card error! \n");
+ break;
+ case 10:
+ printf("Wrong passwrod! \n");
+ break;
+ case 11:
+ printf("Require enter pin2! \n");
+ break;
+ case 12:
+ printf("Require enter puk2! \n");
+ break;
+ case 13:
+ printf("No network service! \n");
+ break;
+ case 14:
+ printf("Network timeout! \n");
+ break;
+ default:
+ printf("Unknown error! \n");
+ break;
+ }
+ }
+}
+static void sms_cmd_proc(char *cmdstr)
+{
+ int sim_id = SMS_ID_DEFULT;
+ char *data = cmdstr;
+ int data_len = strlen(data) - 1;/* -strlen("\r")*/
+ char request = data[0];
+
+ cmdstr[data_len] = '\0';
+ printf("sim_cmd_proc data=%s \n", data);
+ if(0 == strncmp(data, SMS_SET_SC, strlen(SMS_SET_SC))) {
+ printf("Request set sms center num.\n");
+ sms_set_sc(data, data_len);
+ }
+ else if(0 == strncmp(data, SMS_GET_SC, strlen(SMS_GET_SC))) {
+ printf("Request get sms center num.\n");
+ sms_get_sc(data, data_len);
+ }
+ else if(0 == strncmp(data, SMS_SEND_TEXT_ASYN, strlen(SMS_SEND_TEXT_ASYN))) {
+ printf("Request send text asyn.\n");
+ sms_send_text_asyn(data, data_len);
+ }
+ else if(0 == strncmp(data, SMS_SEND_TEXT, strlen(SMS_SEND_TEXT))) {
+ printf("Request send text.\n");
+ sms_send_text(data, data_len);
+ }
+ else if(0 == strncmp(data, SMS_SEND_PDU_ASYN, strlen(SMS_SEND_PDU_ASYN))) {
+ printf("Request send pdu sync.\n");
+ sms_send_pdu_sync(data, data_len);
+ }
+ else if(0 == strncmp(data, SMS_SEND_PDU, strlen(SMS_SEND_PDU))) {
+ printf("Request send pdu.\n");
+ sms_send_pdu(data, data_len);
+ }
+ else {
+ printf("Request unknow.\n");
+ printUsage(cmdstr);
+ }
+}
+int main(int argc, char *argv[])
+{
+ char cmdstr[SMS_CMD_MAX_LEN];
+
+ printf("sms_demo:Demo go.\n");
+ if(parseOpts(argc,argv) == -1) {
+ printf("sms_demo:Arg error.\n");
+ return -1;
+ }
+
+ if(sms_init(SMS_ID_DEFULT)) {
+ printf("sms_demo:sms_init fail!\n");
+ return 0;
+ }
+
+ while(1) {
+ memset(cmdstr,0,SMS_CMD_MAX_LEN);
+
+ printf("Please input an sms command:\n");
+
+ if(NULL != fgets(cmdstr,SMS_CMD_MAX_LEN - 1,stdin)) {
+ if(0 == strcmp(EXIT_CMD_STOP,cmdstr) ||
+ 0 == strcmp(EXIT_CMD_Q,cmdstr) ||
+ 0 == strcmp(EXIT_CMD_EXIT,cmdstr)) {
+ break;
+ }
+
+ printf("cmdstr:%d %s\n",strlen(cmdstr),cmdstr);
+ if(1 >= strlen(cmdstr)) {
+ continue;
+ }
+
+ /*request format:
+ *Q:1,2,10086
+ */
+ sms_cmd_proc(cmdstr);
+ }
+ }
+
+ sms_deinit(SMS_ID_DEFULT);
+
+ printf("sms_demo:Demo end.\n");
+ return 0;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_tok.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_tok.c
new file mode 100755
index 0000000..b8f208f
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_tok.c
@@ -0,0 +1,190 @@
+/*
+**
+** Copyright 2006, 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.
+*/
+
+#include "sc_sms_tok.h"
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+/**
+ * Starts tokenizing an AT response string
+ * returns -1 if this is not a valid response string, 0 on success.
+ * updates *p_cur with current position
+ */
+int at_tok_start(char **p_cur)
+{
+ if (*p_cur == NULL) {
+ return -1;
+ }
+
+ // skip prefix
+ // consume "^[^:]:"
+
+ *p_cur = strchr(*p_cur, ':');
+
+ if (*p_cur == NULL) {
+ return -1;
+ }
+
+ (*p_cur)++;
+
+ return 0;
+}
+
+static void skipWhiteSpace(char **p_cur)
+{
+ if (*p_cur == NULL) return;
+
+ while (**p_cur != '\0' && isspace(**p_cur)) {
+ (*p_cur)++;
+ }
+}
+
+static void skipNextComma(char **p_cur)
+{
+ if (*p_cur == NULL) return;
+
+ while (**p_cur != '\0' && **p_cur != ',') {
+ (*p_cur)++;
+ }
+
+ if (**p_cur == ',') {
+ (*p_cur)++;
+ }
+}
+
+static char * nextTok(char **p_cur)
+{
+ char *ret = NULL;
+
+ skipWhiteSpace(p_cur);
+
+ if (*p_cur == NULL) {
+ ret = NULL;
+ } else if (**p_cur == '"') {
+ (*p_cur)++;
+ ret = strsep(p_cur, "\"");
+ skipNextComma(p_cur);
+ } else {
+ ret = strsep(p_cur, ",");
+ }
+
+ return ret;
+}
+
+
+/**
+ * Parses the next integer in the AT response line and places it in *p_out
+ * returns 0 on success and -1 on fail
+ * updates *p_cur
+ * "base" is the same as the base param in strtol
+ */
+
+static int at_tok_nextint_base(char **p_cur, int *p_out, int base, int uns)
+{
+ char *ret;
+
+ if (*p_cur == NULL) {
+ return -1;
+ }
+
+ ret = nextTok(p_cur);
+
+ if (ret == NULL) {
+ return -1;
+ } else {
+ long l;
+ char *end;
+
+ if (uns)
+ l = strtoul(ret, &end, base);
+ else
+ l = strtol(ret, &end, base);
+
+ *p_out = (int)l;
+
+ if (end == ret) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Parses the next base 10 integer in the AT response line
+ * and places it in *p_out
+ * returns 0 on success and -1 on fail
+ * updates *p_cur
+ */
+int at_tok_nextint(char **p_cur, int *p_out)
+{
+ return at_tok_nextint_base(p_cur, p_out, 10, 0);
+}
+
+/**
+ * Parses the next base 16 integer in the AT response line
+ * and places it in *p_out
+ * returns 0 on success and -1 on fail
+ * updates *p_cur
+ */
+int at_tok_nexthexint(char **p_cur, int *p_out)
+{
+ return at_tok_nextint_base(p_cur, p_out, 16, 1);
+}
+
+int at_tok_nextbool(char **p_cur, char *p_out)
+{
+ int ret;
+ int result;
+
+ ret = at_tok_nextint(p_cur, &result);
+
+ if (ret < 0) {
+ return -1;
+ }
+
+ // booleans should be 0 or 1
+ if (!(result == 0 || result == 1)) {
+ return -1;
+ }
+
+ if (p_out != NULL) {
+ *p_out = (char)result;
+ }
+
+ return ret;
+}
+
+int at_tok_nextstr(char **p_cur, char **p_out)
+{
+ if (*p_cur == NULL) {
+ return -1;
+ }
+
+ *p_out = nextTok(p_cur);
+
+ return 0;
+}
+
+/** returns 1 on "has more tokens" and 0 if no */
+int at_tok_hasmore(char **p_cur)
+{
+ return ! (*p_cur == NULL || **p_cur == '\0');
+}
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_tok.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_tok.h
new file mode 100755
index 0000000..6aa6e72
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/sms_demo/sc_sms_tok.h
@@ -0,0 +1,30 @@
+/*
+**
+** Copyright 2006, 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.
+*/
+
+#ifndef SC_SMS_TOK_H
+#define SC_SMS_TOK_H
+
+int at_tok_start(char **p_cur);
+int at_tok_nextint(char **p_cur, int *p_out);
+int at_tok_nexthexint(char **p_cur, int *p_out);
+
+int at_tok_nextbool(char **p_cur, char *p_out);
+int at_tok_nextstr(char **p_cur, char **out);
+
+int at_tok_hasmore(char **p_cur);
+
+#endif /*SC_CC_TOK_H */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/spitest/test_spidev.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/spitest/test_spidev.c
index de38219..b281d1d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/spitest/test_spidev.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/spitest/test_spidev.c
@@ -52,7 +52,7 @@
p[0] = PACK_HEAD;
p[len-1] = PACK_TAIL;
- for(i = 2;i<len-2;i++)
+ for(i = 2;i<len-1;i++)
sum += p[i];
p[1] = sum;
@@ -69,7 +69,7 @@
return ret;
}
if( (p[0] == PACK_HEAD) && (p[len-1] == PACK_TAIL) ) {
- for(i = 2;i<len-2;i++)
+ for(i = 2;i<len-1;i++)
sum +=p[i];
if(sum == p[1])
ret = 0;
@@ -93,6 +93,7 @@
while(1) {
printf("thread_send \n");
+ srand(time(0));
for(i = 0;i<dev_info->len;i++)
buffer[i] = rand()&0xFF;
ret = data_to_packet(buffer, dev_info->len);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/spitest/test_spidev_used_gpio_ctrl.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/spitest/test_spidev_used_gpio_ctrl.c
index ed428e9..8735e33 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/spitest/test_spidev_used_gpio_ctrl.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/spitest/test_spidev_used_gpio_ctrl.c
@@ -125,7 +125,7 @@
p[0] = PACK_HEAD;
p[len-1] = PACK_TAIL;
- for(i = 2;i<len-2;i++)
+ for(i = 2;i<len-1;i++)
sum += p[i];
p[1] = sum;
@@ -142,7 +142,7 @@
return ret;
}
if( (p[0] == PACK_HEAD) && (p[len-1] == PACK_TAIL) ) {
- for(i = 2;i<len-2;i++)
+ for(i = 2;i<len-1;i++)
sum +=p[i];
if(sum == p[1])
ret = 0;
@@ -534,7 +534,8 @@
//debug_level = 0;
} else {
message_type_recv_cnt[1]++;
- msgsnd(msgid,&message,sizeof(message_t),0);
+ msgsnd(msgid,&message,sizeof(message_t),0);
+ PRINT_LOG(0,"msgsnd type_recv=%d ",message_type_recv_cnt[1]);
}
}
else {
@@ -909,9 +910,12 @@
ret = sem_timedwait_ms(&wait_req,25);
if(ret != 0) {
PRINT_LOG(3,"wait req time out");
+ ret = sem_timedwait_ms(&wait_req,25);
+ if(ret != 0) PRINT_LOG(3,"wait req time out again");
ret = get_exint_level(dev_id);
if(ret != 0) {
PRINT_LOG(3,"wait req time out,ex_int_st(%d) err",ret);
+ debug_level = 0;
}
}
//sem_wait(&wait_req);
@@ -956,9 +960,9 @@
ret = read(spi_dev_fd[dev_id],&recv_msg,sizeof(shakehand_t));
if(recv_msg.head == MSG_HEAD && recv_msg.tail == MSG_TAIL) {
sysfs_gpio_set_value(GPIO_FOR_MASTER, GPIO_LEVEL_LOW);
+ PRINT_LOG(2,"type_recv_cnt=%d r_len=%d",message_type_recv_cnt[dev_id],recv_msg.len);
sem_wait(&wait_req);
message_type_recv_cnt[dev_id]--;
- PRINT_LOG(2,"type_recv_cnt=%d r_len=%d",message_type_recv_cnt[dev_id],recv_msg.len);
ret = read(spi_dev_fd[dev_id],rx_buf, recv_msg.len); /*set dma and recv data msg*/
//ret = packet_check(rx_buf,recv_msg.len);
ret = packet_check_only_head_tail(rx_buf,recv_msg.len);
@@ -1037,6 +1041,7 @@
ret = packet_check(rx_buf,recv_msg.len);
if(ret) {
rx_data_check_err_cnt[dev_id]++;
+ print_buf_data(rx_buf, recv_msg.len);
}else {
rx_data_check_ok_cnt[dev_id]++;
rx_cnt_in_tx_thread[dev_id]++;
@@ -1174,6 +1179,10 @@
}
else if(!strcmp("send",argv[2])) {
+ times = atoi(argv[3]);
+ speed = atoi(argv[4]);
+ delay = atoi(argv[5]);
+ debug_level = atoi(argv[6]);
if(dev_id == 0)
ret = spi_dev_open(SPI_DEV_0,dev_id,speed);
else
@@ -1182,10 +1191,7 @@
printf("%d return \n",__LINE__);
return ret;
}
- times = atoi(argv[3]);
- speed = atoi(argv[4]);
- delay = atoi(argv[5]);
- debug_level = atoi(argv[6]);
+
signal_init(dev_id);
if(dev_id == 1) slave_dma_cfg_done_sig_init(dev_id);
@@ -1216,6 +1222,10 @@
}else if(!strcmp("recv",argv[2])) {
+ times = atoi(argv[3]);
+ speed = atoi(argv[4]);
+ delay = atoi(argv[5]);
+ debug_level = atoi(argv[6]);
if(dev_id == 0)
ret = spi_dev_open(SPI_DEV_0,dev_id,speed);
else
@@ -1226,7 +1236,7 @@
}
signal_init(dev_id);
if(dev_id == 1) slave_dma_cfg_done_sig_init(dev_id);
- debug_level = atoi(argv[6]);
+
sem_init(&wait_req, 0,0);
sem_init(&done_req, 0,0);
sem_init(&head_msg_req, 0,0);
@@ -1252,6 +1262,10 @@
}
}else if(!strcmp("concurrent",argv[2])) {
+ times = atoi(argv[3]);
+ speed = atoi(argv[4]);
+ delay = atoi(argv[5]);
+ debug_level = atoi(argv[6]);
if(dev_id == 0)
ret = spi_dev_open(SPI_DEV_0,dev_id,speed);
else
@@ -1260,11 +1274,7 @@
printf("%d return \n",__LINE__);
return ret;
}
- times = atoi(argv[3]);
- speed = atoi(argv[4]);
- delay = atoi(argv[5]);
- debug_level = atoi(argv[6]);
-
+
signal_init(dev_id);
if(dev_id == 1) slave_dma_cfg_done_sig_init(dev_id);
sem_init(&wait_req, 0,0);
@@ -1296,7 +1306,52 @@
sleep(1);
}
- } else {
+ } else if(!strcmp("testsemdw",argv[2])) {
+
+ sem_init(&wait_req,0,0);
+ i = 0;
+ while(i<100) {
+ struct timespec t_start = {0};
+ struct timespec t_end = {0};
+
+ clock_gettime(CLOCK_REALTIME, &t_start);
+ usleep(25000);
+ clock_gettime(CLOCK_REALTIME, &t_end);
+ i++;
+ printf("usleep %d %d %d %d %d\r\n",t_start.tv_sec,t_start.tv_nsec,t_end.tv_sec,t_end.tv_nsec,(t_end.tv_nsec-t_start.tv_nsec)/1000000);
+ }
+ i = 0;
+ while(i<100) {
+ struct timespec t_start = {0};
+ struct timespec t_end = {0};
+
+ clock_gettime(CLOCK_REALTIME, &t_start);
+ //usleep(25000);
+ sem_timedwait_ms(&wait_req,25);
+ clock_gettime(CLOCK_REALTIME, &t_end);
+ i++;
+ printf("sem_timedwait_ms %d %d %d %d %d\r\n",t_start.tv_sec,t_start.tv_nsec,t_end.tv_sec,t_end.tv_nsec,(t_end.tv_nsec-t_start.tv_nsec)/1000000);
+ }
+ i = 0;
+ while(i<100) {
+ struct timespec t_start = {0};
+ struct timespec t_end = {0};
+
+ clock_gettime(CLOCK_REALTIME, &t_start);
+
+ if(sem_trywait(&wait_req) == 0){
+ printf("%d wait req \r\n",i);
+ }else {
+ usleep(25000);
+ }
+ clock_gettime(CLOCK_REALTIME, &t_end);
+ i++;
+ printf("sem_trywait %d %d %d %d %d\r\n",t_start.tv_sec,t_start.tv_nsec,t_end.tv_sec,t_end.tv_nsec,(t_end.tv_nsec-t_start.tv_nsec)/1000000);
+ }
+ while(1) {
+ sleep(1);
+ }
+ } else {
printf("cmd invalid \n",argv[2]);
ret = -1;
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/tsctest/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/tsctest/Makefile
new file mode 100644
index 0000000..238f106
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/tsctest/Makefile
@@ -0,0 +1,34 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = tsctest
+OBJS = tsctest.o
+
+CFLAGS += -g -Werror=implicit-function-declaration
+
+
+LDLIBS = -lpthread -lm
+#LDLIBS += -lnvram
+LDLIBS += -lbsp -L$(zte_lib_path)/libbsp
+#LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) $(EXEC)_recovery *.elf *.gdb *.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/tsctest/tsctest.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/tsctest/tsctest.c
new file mode 100644
index 0000000..70f977e
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/tsctest/tsctest.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "sc_tsc.h"
+
+int main(int argc, char *argv[])
+{
+ T_Strategy sss[STRATEGY_NUM];
+ int temp[PROBE_MAX];
+ int i;
+
+ sc_tsc_get_temp(temp);
+ for(i=0; i<PROBE_MAX; i++)
+ printf("temp[%d]: %d. \n", i, temp[i]);
+
+ printf("\n");
+
+ sc_tsc_get_strategy(sss);
+ for(i=0; i<STRATEGY_NUM; i++)
+ printf("%s is %d. \n", sss[i].name, sss[i].flag);
+
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/Makefile
new file mode 100644
index 0000000..cdc9b98
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/Makefile
@@ -0,0 +1,34 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = usbtest
+OBJS = usbtest.o
+
+CFLAGS += -g -Werror=implicit-function-declaration
+
+
+LDLIBS = -lpthread -lm
+LDLIBS += -lnvram
+LDLIBS += -lbsp -L$(zte_lib_path)/libbsp
+#LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) $(LDLIBS_$@) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) $(EXEC)_recovery *.elf *.gdb *.o
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/usbtest.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/usbtest.c
new file mode 100644
index 0000000..87e5655
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/usbtest.c
@@ -0,0 +1,131 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "sc_usb.h"
+#include "nv_api.h"
+
+#define BUF_LEN 32
+#define STR_FORCE_NETCARD_TYPE "forcenetcard_type"
+
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ char read_buf[BUF_LEN] = {0};
+ memset(read_buf, 0, BUF_LEN);
+
+ ret = sc_usb_get_usbstate(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb state fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb state:%s\n", read_buf);
+ }
+
+ memset(read_buf, 0, BUF_LEN);
+ ret = sc_usb_get_usb_speed(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb speed fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb speed:%s\n", read_buf);
+ }
+
+ memset(read_buf, 0, BUF_LEN);
+
+ ret = sc_usb_get_mode(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb mode fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb mode:%s\n", read_buf);
+ }
+
+ memset(read_buf, 0, BUF_LEN);
+ ret = sc_usb_get_netname(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb net name fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb net:%s\n", read_buf);
+ }
+
+ sc_usb_set_usermode();
+ memset(read_buf, 0, BUF_LEN);
+
+ ret = sc_usb_get_mode(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb mode fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb mode:%s\n", read_buf);
+ }
+
+ sc_usb_set_amtmode();
+ memset(read_buf, 0, BUF_LEN);
+
+ ret = sc_usb_get_mode(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb mode fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb mode:%s\n", read_buf);
+ }
+
+ sc_usb_set_factorymode();
+ memset(read_buf, 0, BUF_LEN);
+
+ ret = sc_usb_get_mode(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb mode fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb mode:%s\n", read_buf);
+ }
+
+
+ sc_usb_set_debugmode();
+ memset(read_buf, 0, BUF_LEN);
+
+ ret = sc_usb_get_mode(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb mode fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb mode:%s\n", read_buf);
+ }
+
+
+ nv_set_item(NV_RO, STR_FORCE_NETCARD_TYPE, "force_ecm", 1);
+ sc_usb_set_net_ecm();
+ memset(read_buf, 0, BUF_LEN);
+
+ ret = sc_usb_get_netname(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb net name fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb net:%s\n", read_buf);
+ }
+
+
+
+ nv_set_item(NV_RO, STR_FORCE_NETCARD_TYPE, "force_rndis", 1);
+ sc_usb_set_net_rndis();
+ memset(read_buf, 0, BUF_LEN);
+
+ ret = sc_usb_get_netname(read_buf, BUF_LEN);
+ if(ret){
+ printf("get usb net name fail,ret:%d \n", ret);
+
+ }else{
+ printf("usb net:%s\n", read_buf);
+ }
+
+
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/voice_demo/Makefile b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/voice_demo/Makefile
new file mode 100755
index 0000000..96e7e81
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/voice_demo/Makefile
@@ -0,0 +1,33 @@
+include $(COMMON_MK)
+
+EXEC = voice_demo
+OBJS = voice_demo.o
+
+CFLAGS += -I.
+CFLAGS += -I./inc
+CFLAGS += -I$(APP_DIR)/include
+
+
+CFLAGS += -g
+CFLAGS += -g -Werror=implicit-function-declaration
+
+LDLIBS += -lpthread
+LDLIBS += -lvoice -L$(LIB_DIR)/libvoice
+LDLIBS += -lmedia -L$(LIB_DIR)/libmedia
+
+all: $(EXEC)
+$(EXEC)all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) -e /sbin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
+
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS$(LDLIBS_$@))
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/voice_demo/voice_demo.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/voice_demo/voice_demo.c
new file mode 100755
index 0000000..992b9e2
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/voice_demo/voice_demo.c
@@ -0,0 +1,305 @@
+#ifdef USE_CAP_SUPPORT
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include "voice_ipc.h"
+#include "sc_voice_api.h"
+
+extern int sc_audio_set_codec_up_vol(int volume);
+extern int sc_audio_get_codec_up_vol(int *p_volume);
+extern int sc_audio_set_codec_down_vol(int volume);
+extern int sc_audio_get_codec_down_vol(int *p_volume);
+extern int sc_audio_set_codec_up_path(int path);
+extern int sc_audio_get_codec_up_path(int *p_path);
+extern int sc_audio_set_codec_down_path(int path);
+extern int sc_audio_get_codec_down_path(int *p_path);
+
+/*command max len*/
+#define VOICE_CMD_MAX_LEN 64
+
+#define EXIT_CMD_STOP "stop\n"
+#define EXIT_CMD_Q "q\n"
+#define EXIT_CMD_EXIT "exit\n"
+
+//voice api
+#define REQ_SET_VOICE_DEVICE_MODE "set_voice_device_mode"
+#define REQ_GET_VOICE_DEVICE_MODE "get_voice_device_mode"
+#define REQ_SET_RX_VOICE_VOL "set_rx_voice_vol"
+#define REQ_GET_RX_VOICE_VOL "get_rx_voice_vol"
+#define REQ_SET_TX_VOICE_VOL "set_tx_voice_vol"
+#define REQ_GET_TX_VOICE_VOL "get_tx_voice_vol"
+#define REQ_SET_TX_VOICE_MUTE_STATE "set_tx_voice_mute_state"
+#define REQ_GET_TX_VOICE_MUTE_STATE "get_tx_voice_mute_state"
+#define REQ_SET_RX_VOICE_MUTE_STATE "set_rx_voice_mute_state"
+#define REQ_GET_RX_VOICE_MUTE_STATE "get_rx_voice_mute_state"
+#define REQ_SET_LOOPBACK_ENABLE_STATE "set_loopback_enable_state"
+#define REQ_GET_LOOPBACK_ENABLE_STATE "get_loopback_enable_state"
+#define REQ_AP_ALSA_VOICE_OPEN "ap_alsa_voice_open"
+#define REQ_AP_ALSA_VOICE_CLOSE "ap_alsa_voice_close"
+
+//audio api
+#define REQ_AUDIO_SET_CODEC_UP_VOL "audio_set_codec_up_vol"
+#define REQ_AUDIO_GET_CODEC_UP_VOL "audio_get_codec_up_vol"
+#define REQ_AUDIO_SET_CODEC_DOWN_VOL "audio_set_codec_down_vol"
+#define REQ_AUDIO_GET_CODEC_DOWN_VOL "audio_get_codec_down_vol"
+#define REQ_AUDIO_SET_CODEC_UP_PATH "audio_set_codec_up_path"
+#define REQ_AUDIO_GET_CODEC_UP_PATH "audio_get_codec_up_path"
+#define REQ_AUDIO_SET_CODEC_DOWN_PATH "audio_set_codec_down_path"
+#define REQ_AUDIO_GET_CODEC_DOWN_PATH "audio_get_codec_down_path"
+
+static void printUsage(const char *Opt)
+{
+ printf("Usage: %s\n", Opt);
+
+ printf("set_voice_device_mode <value> value: 0-handset, 1-speaker, 2-headset\n");
+ printf("set_rx_voice_vol <value> value: 0~5, corresponds to 0~5 level\n");
+ printf("set_tx_voice_vol <value> value: 0~5, corresponds to 0~5 level\n");
+ printf("set_tx_voice_mute_state <value> value: 0-unmute, 1-mute\n");
+ printf("set_rx_voice_mute_state <value> value: 0-unmute, 1-mute\n");
+ //printf("set_loopback_enable_state <value> value: 0-disable, 1-enable\n");
+
+ //printf("ap_alsa_voice_open <value> value: 0-TEAK_2G_3G, 1-SOFT_3G_NB, 2-SOFT_3G_WB, \n \
+ // 3-4G_NB, 4-4G_WB, 5-5G_NB, 6-5G_WB\n");
+ //printf("ap_alsa_voice_close <value> value: 0-TEAK_2G_3G, 1-SOFT_3G_NB, 2-SOFT_3G_WB, \n \
+ // 3-4G_NB, 4-4G_WB, 5-5G_NB, 6-5G_WB\n");
+ //ap_alsa_voice_open, ap_alsa_voice_closeÊÜºê¿ØÖÆ£¬cap²àÒ²ÒªÓÃºê¿ØÖÆ
+
+ printf("audio_set_codec_up_vol <value> value: 0~11, corresponds to 0~11 level\n");
+ printf("audio_set_codec_down_vol <value> value: 0~11, corresponds to 0~11 level\n");
+ printf("audio_set_codec_up_path <value> value: 0-main mic, 1-headset mic\n");
+ printf("audio_set_codec_down_path <value> value: 0-handset, 1-speaker, 2-headset\n");
+
+ printf("get_voice_device_mode no value input\n");
+ printf("get_rx_voice_vol no value input\n");
+ printf("get_tx_voice_vol no value input\n");
+ printf("get_tx_voice_mute_state no value input\n");
+ printf("get_rx_voice_mute_state no value input\n");
+ //printf("get_loopback_enable_state no value input\n");
+ printf("audio_get_codec_up_vol no value input\n");
+ printf("audio_get_codec_down_vol no value input\n");
+ printf("audio_get_codec_up_path no value input\n");
+ printf("audio_get_codec_down_path no value input\n");
+
+ printf("\n");
+}
+
+void voice_cmd_proc(char *cmdstr)
+{
+ int ret = 0;
+ char data[VOICE_CMD_MAX_LEN];
+ int cmdstr_len = strlen(cmdstr) -1; //-strlen("\r")
+ int value = 0;
+ int *p_value = &value;
+
+ cmdstr[cmdstr_len] = '\0'; //+strlen("\0")
+
+ ret = sscanf(cmdstr, "%s", data);
+ if(1 != ret){
+ printf("data sscanf failed!(%d)\n", ret);
+ return;
+ }
+
+ if(0 == strncmp(data, REQ_SET_VOICE_DEVICE_MODE, strlen(REQ_SET_VOICE_DEVICE_MODE))){
+ ret = sscanf(cmdstr, "%*s %d", &value); //"%*s": Ìø¹ý×Ö·ûÖ±½Ó¶ÁÈ¡ÕûÐÍÊý
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_voice_device_mode(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_GET_VOICE_DEVICE_MODE, strlen(REQ_GET_VOICE_DEVICE_MODE))){
+ ret = sc_audio_get_voice_device_mode(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_SET_RX_VOICE_VOL, strlen(REQ_SET_RX_VOICE_VOL))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_rx_voice_vol(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_GET_RX_VOICE_VOL, strlen(REQ_GET_RX_VOICE_VOL))){
+ ret = sc_audio_get_rx_voice_vol(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_SET_TX_VOICE_VOL, strlen(REQ_SET_TX_VOICE_VOL))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_tx_voice_vol(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_GET_TX_VOICE_VOL, strlen(REQ_GET_TX_VOICE_VOL))){
+ ret = sc_audio_get_tx_voice_vol(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_SET_TX_VOICE_MUTE_STATE, strlen(REQ_SET_TX_VOICE_MUTE_STATE))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_tx_voice_mute_state(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_GET_TX_VOICE_MUTE_STATE, strlen(REQ_GET_TX_VOICE_MUTE_STATE))){
+ ret = sc_audio_get_tx_voice_mute_state(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_SET_RX_VOICE_MUTE_STATE, strlen(REQ_SET_RX_VOICE_MUTE_STATE))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_rx_voice_mute_state(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_GET_RX_VOICE_MUTE_STATE, strlen(REQ_GET_RX_VOICE_MUTE_STATE))){
+ ret = sc_audio_get_rx_voice_mute_state(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_SET_LOOPBACK_ENABLE_STATE, strlen(REQ_SET_LOOPBACK_ENABLE_STATE))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_loopback_enable_state(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_GET_LOOPBACK_ENABLE_STATE, strlen(REQ_GET_LOOPBACK_ENABLE_STATE))){
+ ret = sc_audio_get_loopback_enable_state(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AP_ALSA_VOICE_OPEN, strlen(REQ_AP_ALSA_VOICE_OPEN))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_ap_alsa_voice_open(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AP_ALSA_VOICE_CLOSE, strlen(REQ_AP_ALSA_VOICE_CLOSE))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_ap_alsa_voice_close(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AUDIO_SET_CODEC_UP_VOL, strlen(REQ_AUDIO_SET_CODEC_UP_VOL))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_codec_up_vol(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AUDIO_GET_CODEC_UP_VOL, strlen(REQ_AUDIO_GET_CODEC_UP_VOL))){
+ ret = sc_audio_get_codec_up_vol(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AUDIO_SET_CODEC_DOWN_VOL, strlen(REQ_AUDIO_SET_CODEC_DOWN_VOL))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_codec_down_vol(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AUDIO_GET_CODEC_DOWN_VOL, strlen(REQ_AUDIO_GET_CODEC_DOWN_VOL))){
+ ret = sc_audio_get_codec_down_vol(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AUDIO_SET_CODEC_UP_PATH, strlen(REQ_AUDIO_SET_CODEC_UP_PATH))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_codec_up_path(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AUDIO_GET_CODEC_UP_PATH, strlen(REQ_AUDIO_GET_CODEC_UP_PATH))){
+ ret = sc_audio_get_codec_up_path(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AUDIO_SET_CODEC_DOWN_PATH, strlen(REQ_AUDIO_SET_CODEC_DOWN_PATH))){
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("value sscanf failed!(%d)\n", ret);
+ return;
+ }
+ printf("%s set value %d\n", data, value);
+ ret = sc_audio_set_codec_down_path(value);
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_AUDIO_GET_CODEC_DOWN_PATH, strlen(REQ_AUDIO_GET_CODEC_DOWN_PATH))){
+ ret = sc_audio_get_codec_down_path(p_value);
+ printf("%s return %d\n", data, ret);
+ }
+ else{
+ printf("Request unknow.\n");
+ printUsage(cmdstr);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ char cmdstr[VOICE_CMD_MAX_LEN];
+ printf("voice_demo start\n");
+
+ while(1){
+ memset(cmdstr, 0, VOICE_CMD_MAX_LEN);
+
+ printf("Please input an voice_demo command:\n");
+
+ if(NULL != fgets(cmdstr, VOICE_CMD_MAX_LEN - 1, stdin)){
+ if(0 == strcmp(EXIT_CMD_STOP, cmdstr) ||
+ 0 == strcmp(EXIT_CMD_Q, cmdstr) ||
+ 0 == strcmp(EXIT_CMD_EXIT, cmdstr)){
+ break;
+ }
+
+ printf("len:%d, cmdstr:%s\n", strlen(cmdstr), cmdstr);
+
+ if(1 >= strlen(cmdstr)){
+ continue;
+ }
+
+ voice_cmd_proc(cmdstr);
+ }
+ }
+
+ printf("voice_demo end\n");
+
+ return 0;
+}
+
+#endif
+